tuix-webcomponents 0.0.32 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/custom-elements.json +1549 -1369
- package/dist/src/index.d.ts +1 -1
- package/dist/src/react/index.d.ts +2 -1
- package/dist/src/react/index.js +1 -0
- package/dist/src/tuix-button/TuixBaseButton.d.ts +2 -2
- package/dist/src/tuix-button/TuixBaseButton.js +2 -2
- package/dist/src/tuix-button/TuixButton.d.ts +2 -2
- package/dist/src/tuix-button/TuixButton.js +4 -4
- package/dist/src/tuix-button/TuixButton.styles.js +6 -6
- package/dist/src/tuix-button/enums/tuix-button.enums.d.ts +1 -1
- package/dist/src/tuix-button/enums/tuix-button.enums.js +2 -2
- package/dist/src/tuix-checkbox/TuixCheckbox.d.ts +1 -1
- package/dist/src/tuix-checkbox/TuixCheckbox.js +4 -4
- package/dist/src/tuix-checkbox/TuixCheckbox.styles.js +3 -3
- package/dist/src/tuix-checkbox/enums/tuix-checkbox.enums.d.ts +2 -2
- package/dist/src/tuix-checkbox/enums/tuix-checkbox.enums.js +2 -2
- package/dist/src/tuix-checkbox/interfaces/tuix-checkbox.interface.d.ts +1 -1
- package/dist/src/tuix-dropdown/TuixDropdown.d.ts +3 -3
- package/dist/src/tuix-dropdown/TuixDropdown.js +4 -4
- package/dist/src/tuix-dropdown/TuixDropdown.styles.js +4 -4
- package/dist/src/tuix-dropdown/interfaces/tuix-dropdown.interface.d.ts +2 -2
- package/dist/src/tuix-icon/TuixIcon.d.ts +2 -2
- package/dist/src/tuix-icon/TuixIcon.icons.d.ts +1 -1
- package/dist/src/tuix-icon/TuixIcon.icons.js +2 -13
- package/dist/src/tuix-icon/TuixIcon.js +4 -4
- package/dist/src/tuix-icon/enums/tuix-icon.enums.d.ts +0 -3
- package/dist/src/tuix-icon/enums/tuix-icon.enums.js +0 -3
- package/dist/src/tuix-icon-button/TuixIconButton.d.ts +2 -2
- package/dist/src/tuix-icon-button/TuixIconButton.js +4 -4
- package/dist/src/tuix-input/TuixInput.d.ts +1 -1
- package/dist/src/tuix-input/TuixInput.js +1 -1
- package/dist/src/tuix-input/TuixInput.styles.js +4 -4
- package/dist/src/tuix-input/enums/tuix-input.enums.d.ts +3 -3
- package/dist/src/tuix-input/enums/tuix-input.enums.js +3 -3
- package/dist/src/tuix-input/interfaces/tuix-input.interface.d.ts +5 -5
- package/dist/src/tuix-link/TuixLink.d.ts +2 -2
- package/dist/src/tuix-link/TuixLink.js +4 -4
- package/dist/src/tuix-link/TuixLink.styles.js +3 -3
- package/dist/src/tuix-modal/TuixModal.styles.js +2 -2
- package/dist/src/tuix-paper/TuixPaper.d.ts +1 -1
- package/dist/src/tuix-paper/TuixPaper.js +2 -2
- package/dist/src/tuix-paper/TuixPaper.styles.js +2 -2
- package/dist/src/tuix-radio-button/TuixRadioButton.d.ts +2 -2
- package/dist/src/tuix-radio-button/TuixRadioButton.js +3 -3
- package/dist/src/tuix-radio-button/TuixRadioButton.styles.js +3 -3
- package/dist/src/tuix-radio-button/interfaces/tuix-radio-button.interface.d.ts +1 -1
- package/dist/src/tuix-table/TuixTable.d.ts +10 -2
- package/dist/src/tuix-table/TuixTable.js +168 -84
- package/dist/src/tuix-table/TuixTable.styles.d.ts +1 -0
- package/dist/src/tuix-table/TuixTable.styles.js +137 -34
- package/dist/src/tuix-table/interfaces/tuix-table.interface.d.ts +11 -0
- package/dist/src/tuix-text/TuixText.styles.js +3 -3
- package/dist/src/tuix-text/enums/tuix-text.enums.js +2 -2
- package/dist/src/tuix-toast/TuixToast.styles.js +1 -1
- package/dist/src/tuix-toast/enums/tuix-toast.enums.d.ts +3 -3
- package/dist/src/tuix-toast/enums/tuix-toast.enums.js +3 -3
- package/dist/src/tuix-toggle-button/TuixToggleButton.d.ts +1 -1
- package/dist/src/tuix-toggle-button/TuixToggleButton.js +3 -3
- package/dist/src/tuix-toggle-button/TuixToggleButton.styles.js +4 -4
- package/dist/src/tuix-toggle-button/interfaces/tuix-toggle.interface.d.ts +1 -1
- package/package.json +2 -3
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { LitElement, html } from 'lit';
|
|
2
|
+
import { LitElement, html, nothing } from 'lit';
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
4
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
5
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
6
|
import { repeat } from 'lit/directives/repeat.js';
|
|
6
7
|
import '../tuix-icon/TuixIcon.js';
|
|
7
8
|
import '../tuix-text/TuixText.js';
|
|
8
|
-
import { tableStyles, threeDots } from './TuixTable.styles
|
|
9
|
-
import { TextSize, TextVariant } from '../tuix-text/enums/tuix-text.enums
|
|
10
|
-
import { IconName } from '../tuix-icon/enums/tuix-icon.enums.js';
|
|
11
|
-
import { Palette } from '../utils/colors
|
|
12
|
-
import {
|
|
9
|
+
import { tableHostStyles, tableStyles, threeDots } from './TuixTable.styles';
|
|
10
|
+
import { TextSize, TextVariant } from '../tuix-text/enums/tuix-text.enums';
|
|
11
|
+
import { IconName, IconSizeVariant, } from '../tuix-icon/enums/tuix-icon.enums.js';
|
|
12
|
+
import { Palette } from '../utils/colors';
|
|
13
|
+
import { DarkPalette } from '../utils/darkColors';
|
|
14
|
+
import { ScreenSizes } from '../utils/screenSizes.enum';
|
|
13
15
|
let TuixTable = class TuixTable extends LitElement {
|
|
14
16
|
constructor() {
|
|
15
17
|
super(...arguments);
|
|
18
|
+
this.dark = false;
|
|
16
19
|
this.paginated = false;
|
|
17
20
|
this.disableMobileTable = false;
|
|
18
21
|
this.showMobileTableInTablet = false;
|
|
@@ -20,6 +23,7 @@ let TuixTable = class TuixTable extends LitElement {
|
|
|
20
23
|
this.headers = [];
|
|
21
24
|
this.pageSizeOptions = [5, 10, 20];
|
|
22
25
|
this.isLoadingData = false;
|
|
26
|
+
this.sortDirection = 'asc';
|
|
23
27
|
this._isTabletView = false;
|
|
24
28
|
this._isMobileView = false;
|
|
25
29
|
this._headerPercents = [];
|
|
@@ -28,7 +32,7 @@ let TuixTable = class TuixTable extends LitElement {
|
|
|
28
32
|
this._isMobileView = !!this._mqMobile?.matches;
|
|
29
33
|
};
|
|
30
34
|
this._nextPage = () => {
|
|
31
|
-
if (this.
|
|
35
|
+
if (this._effectiveCurrentPage >= this.totalPages)
|
|
32
36
|
return;
|
|
33
37
|
const next = Math.min(this.totalPages, this._effectiveCurrentPage + 1);
|
|
34
38
|
const detail = {
|
|
@@ -42,7 +46,7 @@ let TuixTable = class TuixTable extends LitElement {
|
|
|
42
46
|
}));
|
|
43
47
|
};
|
|
44
48
|
this._prevPage = () => {
|
|
45
|
-
if (this.
|
|
49
|
+
if (this._effectiveCurrentPage <= 1)
|
|
46
50
|
return;
|
|
47
51
|
const prev = Math.max(1, this._effectiveCurrentPage - 1);
|
|
48
52
|
const detail = {
|
|
@@ -66,7 +70,7 @@ let TuixTable = class TuixTable extends LitElement {
|
|
|
66
70
|
}));
|
|
67
71
|
};
|
|
68
72
|
}
|
|
69
|
-
static { this.styles = [tableStyles, threeDots]; }
|
|
73
|
+
static { this.styles = [tableHostStyles, tableStyles, threeDots]; }
|
|
70
74
|
connectedCallback() {
|
|
71
75
|
super.connectedCallback();
|
|
72
76
|
this._mqTablet = window.matchMedia(`(max-width:${ScreenSizes.TABLET}px)`);
|
|
@@ -115,8 +119,21 @@ let TuixTable = class TuixTable extends LitElement {
|
|
|
115
119
|
onPreviousPage: this._prevPage,
|
|
116
120
|
onItemsPerPageChange: this._setPageSize,
|
|
117
121
|
isLoading: this.isLoadingData,
|
|
122
|
+
stickyInTablet: this.showMobileTableInTablet,
|
|
118
123
|
};
|
|
119
124
|
}
|
|
125
|
+
_sort(sortKey) {
|
|
126
|
+
const isActive = this.sortBy === sortKey;
|
|
127
|
+
const detail = {
|
|
128
|
+
sortKey,
|
|
129
|
+
sortDirection: isActive && this.sortDirection === 'asc' ? 'desc' : 'asc',
|
|
130
|
+
};
|
|
131
|
+
this.dispatchEvent(new CustomEvent('sort', {
|
|
132
|
+
detail,
|
|
133
|
+
bubbles: true,
|
|
134
|
+
composed: true,
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
120
137
|
_computeHeaderPercents() {
|
|
121
138
|
const total = this.headers.reduce((acum, header) => acum + header.width, 0);
|
|
122
139
|
this._headerPercents =
|
|
@@ -124,42 +141,90 @@ let TuixTable = class TuixTable extends LitElement {
|
|
|
124
141
|
? this.headers.map(() => 100 / this.headers.length)
|
|
125
142
|
: this.headers.map(header => (header.width / total) * 100);
|
|
126
143
|
}
|
|
127
|
-
|
|
128
|
-
return
|
|
144
|
+
_cellBackgroundColor(header, row) {
|
|
145
|
+
return header.cellBackgroundColor?.(row) || '';
|
|
129
146
|
}
|
|
130
147
|
_textVariantColor(header, row) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
148
|
+
return header.cellColor?.(row) ?? TextVariant.PRIMARY;
|
|
149
|
+
}
|
|
150
|
+
_renderSortIcons(header) {
|
|
151
|
+
if (!header.sortKey)
|
|
152
|
+
return nothing;
|
|
153
|
+
const isActive = this.sortBy === header.sortKey;
|
|
154
|
+
return html `<span class="sort-icons" aria-hidden="true">
|
|
155
|
+
<tuix-icon
|
|
156
|
+
?dark=${this.dark}
|
|
157
|
+
name=${IconName.CHEVRON_UP}
|
|
158
|
+
size=${IconSizeVariant.MEDIUM}
|
|
159
|
+
color=${isActive && this.sortDirection === 'asc'
|
|
160
|
+
? TextVariant.SECTION
|
|
161
|
+
: TextVariant.STROKE}
|
|
162
|
+
></tuix-icon>
|
|
163
|
+
<tuix-icon
|
|
164
|
+
?dark=${this.dark}
|
|
165
|
+
name=${IconName.CHEVRON_DOWN}
|
|
166
|
+
size=${IconSizeVariant.MEDIUM}
|
|
167
|
+
color=${isActive && this.sortDirection === 'desc'
|
|
168
|
+
? TextVariant.SECTION
|
|
169
|
+
: TextVariant.STROKE}
|
|
170
|
+
></tuix-icon>
|
|
171
|
+
</span>`;
|
|
172
|
+
}
|
|
173
|
+
_ariaSort(header) {
|
|
174
|
+
if (!this.sortBy || this.sortBy !== header.sortKey)
|
|
175
|
+
return nothing;
|
|
176
|
+
return this.sortDirection === 'asc' ? 'ascending' : 'descending';
|
|
177
|
+
}
|
|
178
|
+
_onHeaderKeyDown(event, sortKey) {
|
|
179
|
+
if (event.key !== 'Enter' && event.key !== ' ')
|
|
180
|
+
return;
|
|
181
|
+
event.preventDefault();
|
|
182
|
+
this._sort(sortKey);
|
|
135
183
|
}
|
|
136
184
|
_renderHeaderCells() {
|
|
137
185
|
return html `<tr>
|
|
138
|
-
${this.headers.map((header, idx) =>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
186
|
+
${this.headers.map((header, idx) => {
|
|
187
|
+
const sortKey = header.sortKey;
|
|
188
|
+
return html `<th
|
|
189
|
+
class=${classMap({ sortable: !!sortKey })}
|
|
190
|
+
style=${styleMap({ width: `${this._headerPercents[idx]}%` })}
|
|
191
|
+
tabindex=${sortKey ? 0 : nothing}
|
|
192
|
+
aria-sort=${this._ariaSort(header)}
|
|
193
|
+
@click=${sortKey ? () => this._sort(sortKey) : nothing}
|
|
194
|
+
@keydown=${sortKey
|
|
195
|
+
? (event) => this._onHeaderKeyDown(event, sortKey)
|
|
196
|
+
: nothing}
|
|
143
197
|
>
|
|
144
|
-
<
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
198
|
+
<span class="header-cell">
|
|
199
|
+
<tuix-text
|
|
200
|
+
class="header-name"
|
|
201
|
+
?dark=${this.dark}
|
|
202
|
+
size=${TextSize.Body1}
|
|
203
|
+
color=${TextVariant.SECTION}
|
|
204
|
+
>${header.name}</tuix-text
|
|
205
|
+
>
|
|
206
|
+
${this._renderSortIcons(header)}
|
|
207
|
+
</span>
|
|
208
|
+
</th>`;
|
|
209
|
+
})}
|
|
148
210
|
</tr>`;
|
|
149
211
|
}
|
|
150
212
|
_renderCell(header, row) {
|
|
213
|
+
const cellStyle = styleMap({
|
|
214
|
+
backgroundColor: this._cellBackgroundColor(header, row) || undefined,
|
|
215
|
+
});
|
|
151
216
|
if (header.isSlot) {
|
|
152
217
|
const slotName = `${header.slotName}-${row.id}`;
|
|
153
|
-
return html `<td style
|
|
218
|
+
return html `<td style=${cellStyle}>
|
|
154
219
|
<slot name=${slotName}></slot>
|
|
155
220
|
</td>`;
|
|
156
221
|
}
|
|
157
|
-
|
|
158
|
-
return html `<td style="${this._cellStyleString()}">
|
|
222
|
+
return html `<td style=${cellStyle}>
|
|
159
223
|
<tuix-text
|
|
160
|
-
|
|
224
|
+
?dark=${this.dark}
|
|
225
|
+
size=${TextSize.Body2}
|
|
161
226
|
color=${this._textVariantColor(header, row)}
|
|
162
|
-
>${
|
|
227
|
+
>${row[header.dataKey]}</tuix-text
|
|
163
228
|
>
|
|
164
229
|
</td>`;
|
|
165
230
|
}
|
|
@@ -179,7 +244,7 @@ let TuixTable = class TuixTable extends LitElement {
|
|
|
179
244
|
_renderSpinner() {
|
|
180
245
|
const threeDotsConfiguration = {
|
|
181
246
|
size: '14px',
|
|
182
|
-
color: Palette.MAIN,
|
|
247
|
+
color: this.dark ? DarkPalette.MAIN : Palette.MAIN,
|
|
183
248
|
visible: true,
|
|
184
249
|
ariaLabel: 'Loading',
|
|
185
250
|
wrapperStyle: {
|
|
@@ -213,17 +278,18 @@ let TuixTable = class TuixTable extends LitElement {
|
|
|
213
278
|
</div>`;
|
|
214
279
|
}
|
|
215
280
|
_renderPagination() {
|
|
216
|
-
const { totalItems, startItem, endItem, itemsPerPage, isLoading } = this._paginationProps;
|
|
281
|
+
const { totalItems, startItem, endItem, itemsPerPage, isLoading, stickyInTablet, } = this._paginationProps;
|
|
282
|
+
const iconSize = this._isMobileView
|
|
283
|
+
? IconSizeVariant.SMALL
|
|
284
|
+
: IconSizeVariant.MEDIUM;
|
|
217
285
|
return html `<footer
|
|
218
|
-
|
|
219
|
-
class="table_footer sticky"
|
|
286
|
+
class=${classMap({ table_footer: true, sticky: !!stickyInTablet })}
|
|
220
287
|
>
|
|
221
288
|
<div class="items-per-page">
|
|
222
|
-
<tuix-text size=${TextSize.Body2}
|
|
223
|
-
|
|
224
|
-
style="outline: 1px solid ${Palette.NEUTRAL_200};"
|
|
225
|
-
class="dropdown_container"
|
|
289
|
+
<tuix-text ?dark=${this.dark} size=${TextSize.Body2}
|
|
290
|
+
>Items per page</tuix-text
|
|
226
291
|
>
|
|
292
|
+
<div class="dropdown_container">
|
|
227
293
|
<select
|
|
228
294
|
class="items-per-page-dropdown"
|
|
229
295
|
.value=${String(itemsPerPage)}
|
|
@@ -234,81 +300,90 @@ let TuixTable = class TuixTable extends LitElement {
|
|
|
234
300
|
</select>
|
|
235
301
|
<tuix-icon
|
|
236
302
|
class="arrow-icon"
|
|
303
|
+
?dark=${this.dark}
|
|
237
304
|
name=${IconName.CHEVRON_DOWN}
|
|
238
305
|
></tuix-icon>
|
|
239
306
|
</div>
|
|
240
307
|
</div>
|
|
241
308
|
|
|
242
309
|
<div class="navigation">
|
|
243
|
-
<tuix-text size=${TextSize.Body2}
|
|
310
|
+
<tuix-text ?dark=${this.dark} size=${TextSize.Body2}
|
|
244
311
|
>${startItem} - ${endItem} of ${totalItems}</tuix-text
|
|
245
312
|
>
|
|
246
313
|
<div class="buttons">
|
|
247
314
|
<tuix-icon
|
|
248
|
-
class="arrow
|
|
315
|
+
class="arrow"
|
|
316
|
+
?dark=${this.dark}
|
|
249
317
|
name=${IconName.CHEVRON_LEFT}
|
|
250
|
-
|
|
318
|
+
size=${iconSize}
|
|
319
|
+
@click=${startItem > 1 ? this._prevPage : nothing}
|
|
251
320
|
></tuix-icon>
|
|
252
321
|
<tuix-icon
|
|
253
|
-
class="arrow
|
|
322
|
+
class="arrow"
|
|
323
|
+
?dark=${this.dark}
|
|
254
324
|
name=${IconName.CHEVRON_RIGHT}
|
|
255
|
-
|
|
325
|
+
size=${iconSize}
|
|
326
|
+
@click=${totalItems !== endItem ? this._nextPage : nothing}
|
|
256
327
|
></tuix-icon>
|
|
257
328
|
</div>
|
|
258
329
|
</div>
|
|
259
330
|
</footer>`;
|
|
260
331
|
}
|
|
261
332
|
_renderTable() {
|
|
262
|
-
return html `<
|
|
263
|
-
<
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
333
|
+
return html `<div class="table_wrapper">
|
|
334
|
+
<table>
|
|
335
|
+
<thead>
|
|
336
|
+
${this._renderHeaderCells()}
|
|
337
|
+
</thead>
|
|
338
|
+
${this.isLoadingData
|
|
267
339
|
? html `<tbody>
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
340
|
+
<tr>
|
|
341
|
+
<td colspan=${this.headers.length}>
|
|
342
|
+
${this._renderSpinner()}
|
|
343
|
+
</td>
|
|
344
|
+
</tr>
|
|
345
|
+
</tbody>`
|
|
272
346
|
: html `<tbody>
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
347
|
+
${this._renderRows()}
|
|
348
|
+
</tbody>`}
|
|
349
|
+
</table>
|
|
350
|
+
</div>
|
|
276
351
|
${this.paginated ? this._renderPagination() : null}`;
|
|
277
352
|
}
|
|
353
|
+
_renderCard(row) {
|
|
354
|
+
return html `<div class="table_entity">
|
|
355
|
+
${this.headers.map(header => html `<div
|
|
356
|
+
class="table_row"
|
|
357
|
+
style=${styleMap({
|
|
358
|
+
backgroundColor: this._cellBackgroundColor(header, row) || undefined,
|
|
359
|
+
})}
|
|
360
|
+
>
|
|
361
|
+
<div class="header">
|
|
362
|
+
<tuix-text
|
|
363
|
+
?dark=${this.dark}
|
|
364
|
+
size=${TextSize.Body1}
|
|
365
|
+
color=${TextVariant.PRIMARY}
|
|
366
|
+
>${header.name}</tuix-text
|
|
367
|
+
>
|
|
368
|
+
</div>
|
|
369
|
+
<div class="content">
|
|
370
|
+
${header.isSlot
|
|
371
|
+
? html `<slot name="${header.slotName}-${row.id}"></slot>`
|
|
372
|
+
: html `<tuix-text
|
|
373
|
+
?dark=${this.dark}
|
|
374
|
+
size=${TextSize.Body2}
|
|
375
|
+
color=${this._textVariantColor(header, row)}
|
|
376
|
+
>${row[header.dataKey]}</tuix-text
|
|
377
|
+
>`}
|
|
378
|
+
</div>
|
|
379
|
+
</div>`)}
|
|
380
|
+
</div>`;
|
|
381
|
+
}
|
|
278
382
|
_renderCards() {
|
|
279
|
-
const rows = this.data;
|
|
280
383
|
return html `<div class="mobile_table">
|
|
281
384
|
${this.isLoadingData
|
|
282
385
|
? this._renderSpinner()
|
|
283
|
-
:
|
|
284
|
-
style="border-bottom: 2px solid ${Palette.MAIN};"
|
|
285
|
-
class="table_entity"
|
|
286
|
-
>
|
|
287
|
-
${this.headers.map(header => html `<div
|
|
288
|
-
class="table_row"
|
|
289
|
-
style="border-bottom:1px solid ${Palette.NEUTRAL_200};"
|
|
290
|
-
>
|
|
291
|
-
<div
|
|
292
|
-
class="header"
|
|
293
|
-
style="background-color:${Palette.SECTION_BG};"
|
|
294
|
-
>
|
|
295
|
-
<tuix-text
|
|
296
|
-
size=${TextSize.Body1}
|
|
297
|
-
color=${TextVariant.PRIMARY}
|
|
298
|
-
>${header.name}</tuix-text
|
|
299
|
-
>
|
|
300
|
-
</div>
|
|
301
|
-
<div class="content">
|
|
302
|
-
${header.isSlot
|
|
303
|
-
? html `<slot
|
|
304
|
-
name="${header.slotName}-${row.id}"
|
|
305
|
-
></slot>`
|
|
306
|
-
: html `<tuix-text size=${TextSize.Body1}
|
|
307
|
-
>${row[header.dataKey]}</tuix-text
|
|
308
|
-
>`}
|
|
309
|
-
</div>
|
|
310
|
-
</div>`)}
|
|
311
|
-
</div>`)}
|
|
386
|
+
: this.data.map(row => this._renderCard(row))}
|
|
312
387
|
</div>
|
|
313
388
|
${this.paginated ? this._renderPagination() : null}`;
|
|
314
389
|
}
|
|
@@ -321,6 +396,9 @@ let TuixTable = class TuixTable extends LitElement {
|
|
|
321
396
|
: html `${this._renderTable()}`;
|
|
322
397
|
}
|
|
323
398
|
};
|
|
399
|
+
__decorate([
|
|
400
|
+
property({ type: Boolean, reflect: true })
|
|
401
|
+
], TuixTable.prototype, "dark", void 0);
|
|
324
402
|
__decorate([
|
|
325
403
|
property({ type: Boolean })
|
|
326
404
|
], TuixTable.prototype, "paginated", void 0);
|
|
@@ -354,6 +432,12 @@ __decorate([
|
|
|
354
432
|
__decorate([
|
|
355
433
|
property({ type: Boolean })
|
|
356
434
|
], TuixTable.prototype, "isLoadingData", void 0);
|
|
435
|
+
__decorate([
|
|
436
|
+
property({ type: String })
|
|
437
|
+
], TuixTable.prototype, "sortBy", void 0);
|
|
438
|
+
__decorate([
|
|
439
|
+
property({ type: String })
|
|
440
|
+
], TuixTable.prototype, "sortDirection", void 0);
|
|
357
441
|
__decorate([
|
|
358
442
|
state()
|
|
359
443
|
], TuixTable.prototype, "_isTabletView", void 0);
|
|
@@ -1,11 +1,43 @@
|
|
|
1
|
-
import { css } from 'lit';
|
|
2
|
-
import { ScreenSizes } from '../utils/screenSizes.enum
|
|
3
|
-
|
|
1
|
+
import { css, unsafeCSS } from 'lit';
|
|
2
|
+
import { ScreenSizes } from '../utils/screenSizes.enum';
|
|
3
|
+
import { Palette } from '../utils/colors';
|
|
4
|
+
import { DarkPalette } from '../utils/darkColors';
|
|
5
|
+
import { LINK_TEXT_COLOR_VAR_NAME } from '../tuix-link/TuixLink.styles';
|
|
6
|
+
export const tableHostStyles = css `
|
|
4
7
|
:host {
|
|
5
8
|
display: block;
|
|
6
9
|
width: 100%;
|
|
10
|
+
|
|
11
|
+
--t-table-header-bg: ${unsafeCSS(Palette.PRIMARY_100)};
|
|
12
|
+
--t-table-header-text-color: ${unsafeCSS(Palette.PRIMARY_700)};
|
|
13
|
+
--t-table-header-focus-color: ${unsafeCSS(Palette.MAIN)};
|
|
14
|
+
--t-table-cell-bg: ${unsafeCSS(Palette.WHITE)};
|
|
15
|
+
--t-table-cell-border-color: ${unsafeCSS(Palette.NEUTRAL_200)};
|
|
16
|
+
--t-table-entity-border-color: ${unsafeCSS(Palette.MAIN)};
|
|
17
|
+
--t-table-row-border-color: ${unsafeCSS(Palette.NEUTRAL_200)};
|
|
18
|
+
--t-table-mobile-header-bg: ${unsafeCSS(Palette.SECTION_BG)};
|
|
19
|
+
--t-table-footer-bg: ${unsafeCSS(Palette.WHITE)};
|
|
20
|
+
--t-table-dropdown-stroke: ${unsafeCSS(Palette.NEUTRAL_200)};
|
|
21
|
+
--t-table-dropdown-text-color: ${unsafeCSS(Palette.BLACK)};
|
|
22
|
+
--t-table-dropdown-option-bg: ${unsafeCSS(Palette.WHITE)};
|
|
7
23
|
}
|
|
8
24
|
|
|
25
|
+
:host([dark]) {
|
|
26
|
+
--t-table-header-bg: ${unsafeCSS(DarkPalette.PRIMARY_800)};
|
|
27
|
+
--t-table-header-text-color: ${unsafeCSS(DarkPalette.WHITE)};
|
|
28
|
+
--t-table-header-focus-color: ${unsafeCSS(DarkPalette.PRIMARY_300)};
|
|
29
|
+
--t-table-cell-bg: ${unsafeCSS(DarkPalette.BLACK)};
|
|
30
|
+
--t-table-cell-border-color: ${unsafeCSS(DarkPalette.PRIMARY_800)};
|
|
31
|
+
--t-table-entity-border-color: ${unsafeCSS(DarkPalette.PRIMARY_800)};
|
|
32
|
+
--t-table-row-border-color: ${unsafeCSS(DarkPalette.ELEVATION_4)};
|
|
33
|
+
--t-table-mobile-header-bg: ${unsafeCSS(DarkPalette.PRIMARY_800)};
|
|
34
|
+
--t-table-footer-bg: ${unsafeCSS(DarkPalette.PRIMARY_900)};
|
|
35
|
+
--t-table-dropdown-stroke: ${unsafeCSS(DarkPalette.PRIMARY_800)};
|
|
36
|
+
--t-table-dropdown-text-color: ${unsafeCSS(DarkPalette.PRIMARY_50)};
|
|
37
|
+
--t-table-dropdown-option-bg: ${unsafeCSS(DarkPalette.ELEVATION_2)};
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
export const tableStyles = css `
|
|
9
41
|
.table_wrapper {
|
|
10
42
|
width: 100%;
|
|
11
43
|
overflow-x: auto;
|
|
@@ -18,23 +50,68 @@ export const tableStyles = css `
|
|
|
18
50
|
border-collapse: collapse;
|
|
19
51
|
}
|
|
20
52
|
|
|
53
|
+
thead {
|
|
54
|
+
background-color: var(--t-table-header-bg);
|
|
55
|
+
}
|
|
56
|
+
|
|
21
57
|
thead th {
|
|
22
58
|
box-sizing: border-box;
|
|
23
|
-
padding: 8px;
|
|
59
|
+
padding: 8px 16px;
|
|
24
60
|
text-align: left;
|
|
25
61
|
overflow: hidden;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
thead th.sortable {
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
thead th.sortable:focus-visible {
|
|
69
|
+
outline: 2px solid var(--t-table-header-focus-color);
|
|
70
|
+
outline-offset: -2px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
thead th .header-cell {
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: space-between;
|
|
77
|
+
gap: 8px;
|
|
78
|
+
|
|
79
|
+
${unsafeCSS(LINK_TEXT_COLOR_VAR_NAME)}: var(--t-table-header-text-color);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
thead th .header-cell .header-name {
|
|
83
|
+
overflow: hidden;
|
|
26
84
|
text-overflow: ellipsis;
|
|
27
85
|
white-space: nowrap;
|
|
28
86
|
}
|
|
29
87
|
|
|
88
|
+
thead th .sort-icons {
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
thead th .sort-icons tuix-icon {
|
|
95
|
+
height: 12px;
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
}
|
|
99
|
+
|
|
30
100
|
tbody tr td {
|
|
101
|
+
border-bottom: 1px solid var(--t-table-cell-border-color);
|
|
31
102
|
box-sizing: border-box;
|
|
32
103
|
height: 52px;
|
|
33
|
-
padding: 6px
|
|
104
|
+
padding: 6px 16px;
|
|
34
105
|
text-align: left;
|
|
35
|
-
overflow:
|
|
36
|
-
|
|
37
|
-
|
|
106
|
+
overflow-x: auto;
|
|
107
|
+
scrollbar-width: none;
|
|
108
|
+
background-color: var(--t-table-cell-bg);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
tbody tr td::-webkit-scrollbar {
|
|
112
|
+
width: 0;
|
|
113
|
+
height: 0;
|
|
114
|
+
display: none;
|
|
38
115
|
}
|
|
39
116
|
|
|
40
117
|
::slotted(*) {
|
|
@@ -47,12 +124,15 @@ export const tableStyles = css `
|
|
|
47
124
|
.dropdown_container {
|
|
48
125
|
position: relative;
|
|
49
126
|
border-radius: 4px;
|
|
127
|
+
outline: 1px solid var(--t-table-dropdown-stroke);
|
|
50
128
|
}
|
|
51
129
|
|
|
52
130
|
.dropdown_container .items-per-page-dropdown {
|
|
53
131
|
width: 55px;
|
|
54
132
|
border: none;
|
|
55
133
|
background-color: transparent;
|
|
134
|
+
color: var(--t-table-dropdown-text-color);
|
|
135
|
+
font-family: 'Rubik', sans-serif;
|
|
56
136
|
padding: 8px;
|
|
57
137
|
cursor: pointer;
|
|
58
138
|
-webkit-appearance: none;
|
|
@@ -60,6 +140,10 @@ export const tableStyles = css `
|
|
|
60
140
|
appearance: none;
|
|
61
141
|
}
|
|
62
142
|
|
|
143
|
+
.dropdown_container .items-per-page-dropdown option {
|
|
144
|
+
background-color: var(--t-table-dropdown-option-bg);
|
|
145
|
+
}
|
|
146
|
+
|
|
63
147
|
.dropdown_container .items-per-page-dropdown:focus-visible {
|
|
64
148
|
border: none;
|
|
65
149
|
outline: none;
|
|
@@ -80,6 +164,7 @@ export const tableStyles = css `
|
|
|
80
164
|
display: flex;
|
|
81
165
|
justify-content: space-between;
|
|
82
166
|
align-items: center;
|
|
167
|
+
background-color: var(--t-table-footer-bg);
|
|
83
168
|
box-sizing: border-box;
|
|
84
169
|
}
|
|
85
170
|
|
|
@@ -98,35 +183,61 @@ export const tableStyles = css `
|
|
|
98
183
|
footer.table_footer .navigation .buttons {
|
|
99
184
|
display: flex;
|
|
100
185
|
gap: 8px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
footer.table_footer .navigation .buttons .arrow {
|
|
101
189
|
cursor: pointer;
|
|
102
190
|
}
|
|
103
191
|
|
|
104
|
-
.mobile_table {
|
|
105
|
-
|
|
192
|
+
.mobile_table .table_entity {
|
|
193
|
+
border-bottom: 2px solid var(--t-table-entity-border-color);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.mobile_table .table_row {
|
|
197
|
+
display: flex;
|
|
198
|
+
border-bottom: 1px solid var(--t-table-row-border-color);
|
|
199
|
+
min-height: 40px;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.mobile_table .table_row > * {
|
|
203
|
+
padding: 0 16px;
|
|
204
|
+
width: 50%;
|
|
205
|
+
text-overflow: ellipsis;
|
|
206
|
+
overflow: hidden;
|
|
207
|
+
display: flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.mobile_table .table_row .content {
|
|
212
|
+
padding: 12px 16px;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.mobile_table .table_row .content > * {
|
|
216
|
+
min-width: 0;
|
|
217
|
+
max-width: 100%;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.mobile_table .table_row .header {
|
|
221
|
+
background-color: var(--t-table-mobile-header-bg);
|
|
222
|
+
|
|
223
|
+
${unsafeCSS(LINK_TEXT_COLOR_VAR_NAME)}: var(--t-table-header-text-color);
|
|
106
224
|
}
|
|
107
225
|
|
|
108
226
|
@media only screen and (max-width: ${ScreenSizes.TABLET}px) {
|
|
109
|
-
.
|
|
110
|
-
|
|
227
|
+
footer.table_footer.sticky {
|
|
228
|
+
position: sticky;
|
|
229
|
+
bottom: 0;
|
|
111
230
|
}
|
|
231
|
+
}
|
|
112
232
|
|
|
233
|
+
@media only screen and (max-width: ${ScreenSizes.MOBILE}px) {
|
|
113
234
|
footer.table_footer {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.mobile_table .table_row {
|
|
119
|
-
display: flex;
|
|
120
|
-
min-height: 40px;
|
|
235
|
+
position: sticky;
|
|
236
|
+
bottom: 0;
|
|
121
237
|
}
|
|
122
238
|
|
|
123
|
-
.
|
|
124
|
-
|
|
125
|
-
width: 50%;
|
|
126
|
-
text-overflow: ellipsis;
|
|
127
|
-
overflow: hidden;
|
|
128
|
-
display: flex;
|
|
129
|
-
align-items: center;
|
|
239
|
+
footer.table_footer .navigation .buttons {
|
|
240
|
+
gap: 4px;
|
|
130
241
|
}
|
|
131
242
|
}
|
|
132
243
|
`;
|
|
@@ -186,12 +297,4 @@ export const threeDots = css `
|
|
|
186
297
|
width: 1px;
|
|
187
298
|
white-space: nowrap;
|
|
188
299
|
}
|
|
189
|
-
|
|
190
|
-
.clientsLoader,
|
|
191
|
-
.mobileClientsLoader,
|
|
192
|
-
.tabletClientsLoader {
|
|
193
|
-
display: flex;
|
|
194
|
-
justify-content: center;
|
|
195
|
-
padding: 16px 0;
|
|
196
|
-
}
|
|
197
300
|
`;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
export type SortDirection = 'asc' | 'desc';
|
|
1
2
|
export interface IDataTableHeader<TRowData = Record<string, unknown>> {
|
|
2
3
|
cellColor?: (rowData: TRowData) => string | undefined;
|
|
4
|
+
cellBackgroundColor?: (rowData: TRowData) => string | undefined;
|
|
3
5
|
isSlot?: boolean;
|
|
4
6
|
slotName?: string;
|
|
5
7
|
name?: string;
|
|
6
8
|
dataKey: Extract<keyof TRowData, string>;
|
|
9
|
+
sortKey?: Extract<keyof TRowData, string>;
|
|
7
10
|
width: number;
|
|
8
11
|
}
|
|
9
12
|
export interface TablePaginationProps {
|
|
@@ -37,9 +40,17 @@ export interface TuixTableElement<TRowData = any> extends HTMLElement {
|
|
|
37
40
|
disableMobileTable?: boolean;
|
|
38
41
|
pageSizeOptions?: number[];
|
|
39
42
|
loader?: ThreeDotsLoaderConfig;
|
|
43
|
+
dark?: boolean;
|
|
44
|
+
sortBy?: string;
|
|
45
|
+
sortDirection?: SortDirection;
|
|
40
46
|
}
|
|
41
47
|
export interface PaginationEventDetail {
|
|
42
48
|
page: number;
|
|
43
49
|
pageSize: number;
|
|
44
50
|
}
|
|
51
|
+
export interface SortEventDetail {
|
|
52
|
+
sortKey: string;
|
|
53
|
+
sortDirection: SortDirection;
|
|
54
|
+
}
|
|
45
55
|
export type TuixPaginationEvent = CustomEvent<PaginationEventDetail>;
|
|
56
|
+
export type TuixSortEvent = CustomEvent<SortEventDetail>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { css, unsafeCSS } from 'lit';
|
|
2
|
-
import { ScreenSizes } from '../utils/screenSizes.enum
|
|
3
|
-
import { TextSize } from './enums/tuix-text.enums
|
|
4
|
-
import slottedClassName from '../utils/slottedClassName
|
|
2
|
+
import { ScreenSizes } from '../utils/screenSizes.enum';
|
|
3
|
+
import { TextSize } from './enums/tuix-text.enums';
|
|
4
|
+
import slottedClassName from '../utils/slottedClassName';
|
|
5
5
|
export const linkFontStyles = css `
|
|
6
6
|
${unsafeCSS(`
|
|
7
7
|
${slottedClassName(TextSize.Link)} {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Palette } from '../../utils/colors
|
|
2
|
-
import { DarkPalette } from '../../utils/darkColors
|
|
1
|
+
import { Palette } from '../../utils/colors';
|
|
2
|
+
import { DarkPalette } from '../../utils/darkColors';
|
|
3
3
|
export var TextSize;
|
|
4
4
|
(function (TextSize) {
|
|
5
5
|
TextSize["XXL"] = "xxl";
|