import { customElement, html, DeesElement, property, TemplateResult, cssManager, css, unsafeCSS, } from '@designestate/dees-element'; import * as domtools from '@designestate/dees-domtools'; declare global { interface HTMLElementTagNameMap { 'dees-table': DeesTable; } } @customElement('dees-table') export class DeesTable extends DeesElement { public static demo = () => html`
This is a slotted Text
`; @property({ type: String, }) public heading1: string = 'heading 1'; @property({ type: String, }) public heading2: string = 'heading 2'; @property({ type: Array, }) public data: T[] = []; @property({ type: Object, }) public selectedDataRow: T; @property({ type: String, }) public type: 'normal' | 'highlighted' | 'discreet' | 'big' = 'normal'; @property({ type: String, }) public status: 'normal' | 'pending' | 'success' | 'error' = 'normal'; constructor() { super(); } public static styles = [ cssManager.defaultStyles, css` .mainbox { color: ${cssManager.bdTheme('#333', '#fff')}; font-family: Roboto Mono; padding: 20px; display: block; width: 100%; min-height: 50px; background: ${cssManager.bdTheme('#fafafa', '#333333')}; border-radius: 3px; box-shadow: 0px 0px 5px rgba(0,0,0,0.3); } .headingSeparation { margin-top: 7px; border-bottom: 1px solid ${cssManager.bdTheme('#bcbcbc', '#bcbcbc')}; } table, .noDataSet { margin-top: 20px; color: ${cssManager.bdTheme('#333', '#fff')}; border-collapse: collapse; width: 100%; } .noDataSet { text-align: center; } tr { border-bottom: 1px dashed ${cssManager.bdTheme('#999', '#808080')}; text-align: left; } tr:last-child { border-bottom: none; text-align: left; } tr:hover { cursor: pointer; } tr:hover .innerCellContainer { background: ${cssManager.bdTheme('#22222210', '#ffffff20')}; } tr:first-child:hover { cursor: auto; } tr:first-child:hover .innerCellContainer { background: none; } tr.selected .innerCellContainer { background: ${cssManager.bdTheme('#22222220', '#ffffff20')}; } th { text-transform: uppercase; } th, td { padding: 3px 0px; border-right: 1px dashed ${cssManager.bdTheme('#999', '#808080')}; } .innerCellContainer { padding: 7px 10px; } th:first-child .innerCellContainer, td:first-child .innerCellContainer { padding-left: 0px; } th:last-child .innerCellContainer, td:last-child .innerCellContainer { padding-right: 0px; } th:last-child, td:last-child { border-right: none; } .tableStatistics { padding: 5px 20px; font-size: 14px; color: ${cssManager.bdTheme('#111', '#ffffff90')}; background: ${cssManager.bdTheme('#eeeeeb', '#00000050')}; margin: 20px -20px -20px -20px; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; } `, ]; public render(): TemplateResult { return html`
${this.heading1}
${this.heading2}
${this.data.length > 0 ? (() => { const headings: string[] = Object.keys(this.data[0]); return html` ${headings.map( (headingArg) => html` ` )} ${this.data.map( (itemArg) => html` { this.selectedDataRow = itemArg; }} class="${itemArg === this.selectedDataRow ? 'selected' : ''}" > ${headings.map( (headingArg) => html` ` )} ` )}
${headingArg}
${itemArg[headingArg]}
`; })() : html`
No data set!
`}
${this.data.length} data rows (total) | ${this.selectedDataRow ? html`Row ${this.data.indexOf(this.selectedDataRow) + 1} selected` : html`No row selected`}
`; } public async firstUpdated() {} }