tuix-webcomponents 0.57.0 → 0.59.0
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/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/tuix-icon/TuixIcon.icons.js +3 -0
- package/dist/src/tuix-icon/TuixIcon.icons.js.map +1 -1
- package/dist/src/tuix-icon/enums/tuix-icon.enums.d.ts +2 -1
- package/dist/src/tuix-icon/enums/tuix-icon.enums.js +1 -0
- package/dist/src/tuix-icon/enums/tuix-icon.enums.js.map +1 -1
- package/dist/src/tuix-table/TuixTable.d.ts +47 -0
- package/dist/src/tuix-table/TuixTable.js +378 -0
- package/dist/src/tuix-table/TuixTable.js.map +1 -0
- package/dist/src/tuix-table/TuixTable.styles.d.ts +2 -0
- package/dist/src/tuix-table/TuixTable.styles.js +198 -0
- package/dist/src/tuix-table/TuixTable.styles.js.map +1 -0
- package/dist/src/tuix-table/interfaces/tuix-table.interface.d.ts +45 -0
- package/dist/src/tuix-table/interfaces/tuix-table.interface.js +2 -0
- package/dist/src/tuix-table/interfaces/tuix-table.interface.js.map +1 -0
- package/dist/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, html } from 'lit';
|
|
3
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
5
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
6
|
+
import { tableStyles, threeDots } from './TuixTable.styles.js';
|
|
7
|
+
import { TextSize, TextVariant } from '../tuix-text/enums/tuix-text.enums.js';
|
|
8
|
+
import { IconName } from '../tuix-icon/enums/tuix-icon.enums.js';
|
|
9
|
+
import { Palette } from '../utils/colors.js';
|
|
10
|
+
import { ScreenSizes } from '../utils/screenSizes.enum.js';
|
|
11
|
+
let TuixTable = class TuixTable extends LitElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.paginated = false;
|
|
15
|
+
this.disableMobileTable = false;
|
|
16
|
+
this.showMobileTableInTablet = false;
|
|
17
|
+
this.data = [];
|
|
18
|
+
this.headers = [];
|
|
19
|
+
this.pageSizeOptions = [5, 10, 20];
|
|
20
|
+
this.isLoadingData = false;
|
|
21
|
+
this._isTabletView = false;
|
|
22
|
+
this._isMobileView = false;
|
|
23
|
+
this._headerPercents = [];
|
|
24
|
+
this._onScreenSizeChange = () => {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
this._isTabletView = !!((_a = this._mqTablet) === null || _a === void 0 ? void 0 : _a.matches);
|
|
27
|
+
this._isMobileView = !!((_b = this._mqMobile) === null || _b === void 0 ? void 0 : _b.matches);
|
|
28
|
+
};
|
|
29
|
+
this._nextPage = () => {
|
|
30
|
+
const next = Math.min(this.totalPages, this._effectiveCurrentPage + 1);
|
|
31
|
+
const detail = {
|
|
32
|
+
page: next,
|
|
33
|
+
pageSize: this._effectivePageSize,
|
|
34
|
+
};
|
|
35
|
+
this.dispatchEvent(new CustomEvent('next-page', {
|
|
36
|
+
detail,
|
|
37
|
+
bubbles: true,
|
|
38
|
+
composed: true,
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
this._prevPage = () => {
|
|
42
|
+
const prev = Math.max(1, this._effectiveCurrentPage - 1);
|
|
43
|
+
const detail = {
|
|
44
|
+
page: prev,
|
|
45
|
+
pageSize: this._effectivePageSize,
|
|
46
|
+
};
|
|
47
|
+
this.dispatchEvent(new CustomEvent('previous-page', {
|
|
48
|
+
detail,
|
|
49
|
+
bubbles: true,
|
|
50
|
+
composed: true,
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
this._setPageSize = (value) => {
|
|
54
|
+
const newSize = Math.max(1, Math.floor(value));
|
|
55
|
+
const newPage = 1;
|
|
56
|
+
const detail = { page: newPage, pageSize: newSize };
|
|
57
|
+
this.dispatchEvent(new CustomEvent('page-size-change', {
|
|
58
|
+
detail,
|
|
59
|
+
bubbles: true,
|
|
60
|
+
composed: true,
|
|
61
|
+
}));
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
connectedCallback() {
|
|
65
|
+
super.connectedCallback();
|
|
66
|
+
this._mqTablet = window.matchMedia(`(max-width:${ScreenSizes.TABLET}px)`);
|
|
67
|
+
this._mqMobile = window.matchMedia(`(max-width:${ScreenSizes.MOBILE}px)`);
|
|
68
|
+
this._onScreenSizeChange();
|
|
69
|
+
this._mqTablet.addEventListener('change', this._onScreenSizeChange);
|
|
70
|
+
this._mqMobile.addEventListener('change', this._onScreenSizeChange);
|
|
71
|
+
this._computeHeaderPercents();
|
|
72
|
+
}
|
|
73
|
+
disconnectedCallback() {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
super.disconnectedCallback();
|
|
76
|
+
(_a = this._mqTablet) === null || _a === void 0 ? void 0 : _a.removeEventListener('change', this._onScreenSizeChange);
|
|
77
|
+
(_b = this._mqMobile) === null || _b === void 0 ? void 0 : _b.removeEventListener('change', this._onScreenSizeChange);
|
|
78
|
+
}
|
|
79
|
+
updated(changedProps) {
|
|
80
|
+
if (changedProps.has('headers'))
|
|
81
|
+
this._computeHeaderPercents();
|
|
82
|
+
}
|
|
83
|
+
get _effectiveTotalItems() {
|
|
84
|
+
var _a;
|
|
85
|
+
return (_a = this.data.length) !== null && _a !== void 0 ? _a : this.totalItems;
|
|
86
|
+
}
|
|
87
|
+
get _effectiveCurrentPage() {
|
|
88
|
+
var _a;
|
|
89
|
+
return (_a = this.currentPage) !== null && _a !== void 0 ? _a : 1;
|
|
90
|
+
}
|
|
91
|
+
get _effectivePageSize() {
|
|
92
|
+
var _a;
|
|
93
|
+
return (_a = this.currentSize) !== null && _a !== void 0 ? _a : this.pageSizeOptions[0];
|
|
94
|
+
}
|
|
95
|
+
get totalPages() {
|
|
96
|
+
const denom = this._effectivePageSize;
|
|
97
|
+
return Math.max(1, Math.ceil(this._effectiveTotalItems / denom));
|
|
98
|
+
}
|
|
99
|
+
get _paginationProps() {
|
|
100
|
+
const totalItems = this._effectiveTotalItems;
|
|
101
|
+
const itemsPerPage = this._effectivePageSize;
|
|
102
|
+
const startItem = totalItems
|
|
103
|
+
? (this._effectiveCurrentPage - 1) * itemsPerPage + 1
|
|
104
|
+
: 0;
|
|
105
|
+
const endItem = Math.min(this._effectiveCurrentPage * itemsPerPage, totalItems);
|
|
106
|
+
return {
|
|
107
|
+
totalItems,
|
|
108
|
+
currentPage: this._effectiveCurrentPage,
|
|
109
|
+
itemsPerPage,
|
|
110
|
+
startItem,
|
|
111
|
+
endItem,
|
|
112
|
+
onNextPage: this._nextPage,
|
|
113
|
+
onPreviousPage: this._prevPage,
|
|
114
|
+
onItemsPerPageChange: this._setPageSize,
|
|
115
|
+
isLoading: this.isLoadingData,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
_paginatedData() {
|
|
119
|
+
if (!this.paginated)
|
|
120
|
+
return this.data;
|
|
121
|
+
const page = this._effectiveCurrentPage;
|
|
122
|
+
const size = this._effectivePageSize;
|
|
123
|
+
const start = (page - 1) * size;
|
|
124
|
+
const end = start + size;
|
|
125
|
+
return this.data.slice(start, end);
|
|
126
|
+
}
|
|
127
|
+
_computeHeaderPercents() {
|
|
128
|
+
const total = this.headers.reduce((acum, header) => acum + header.width, 0);
|
|
129
|
+
this._headerPercents =
|
|
130
|
+
total === 0
|
|
131
|
+
? this.headers.map(() => 100 / this.headers.length)
|
|
132
|
+
: this.headers.map(header => (header.width / total) * 100);
|
|
133
|
+
}
|
|
134
|
+
_cellStyleString() {
|
|
135
|
+
return `border-bottom:1px solid ${Palette.NEUTRAL_200};`;
|
|
136
|
+
}
|
|
137
|
+
_textVariantColor(header, row) {
|
|
138
|
+
const color = header.cellColor
|
|
139
|
+
? header.cellColor(row)
|
|
140
|
+
: TextVariant.PRIMARY;
|
|
141
|
+
return color;
|
|
142
|
+
}
|
|
143
|
+
_renderHeaderCells() {
|
|
144
|
+
return html `<tr>
|
|
145
|
+
${this.headers.map((header, idx) => html `<th
|
|
146
|
+
style=${styleMap({
|
|
147
|
+
width: `${this._headerPercents[idx]}%`,
|
|
148
|
+
color: Palette.WHITE,
|
|
149
|
+
})}
|
|
150
|
+
>
|
|
151
|
+
<tuix-text size=${TextSize.Body1} color=${TextVariant.SECONDARY}
|
|
152
|
+
>${header.name}</tuix-text
|
|
153
|
+
>
|
|
154
|
+
</th>`)}
|
|
155
|
+
</tr>`;
|
|
156
|
+
}
|
|
157
|
+
_renderCell(header, row) {
|
|
158
|
+
if (header.isSlot) {
|
|
159
|
+
const slotName = `${header.slotName}-${row.id}`;
|
|
160
|
+
return html `<td style="${this._cellStyleString()}">
|
|
161
|
+
<slot name=${slotName}></slot>
|
|
162
|
+
</td>`;
|
|
163
|
+
}
|
|
164
|
+
const content = row[header.dataKey];
|
|
165
|
+
return html `<td style="${this._cellStyleString()}">
|
|
166
|
+
<tuix-text
|
|
167
|
+
size=${TextSize.Body1}
|
|
168
|
+
color=${this._textVariantColor(header, row)}
|
|
169
|
+
>${content}</tuix-text
|
|
170
|
+
>
|
|
171
|
+
</td>`;
|
|
172
|
+
}
|
|
173
|
+
_renderRows() {
|
|
174
|
+
const rows = this._paginatedData();
|
|
175
|
+
return repeat(rows, row => row.id, row => html `<tr>
|
|
176
|
+
${this.headers.map(header => this._renderCell(header, row))}
|
|
177
|
+
</tr>`);
|
|
178
|
+
}
|
|
179
|
+
_onPageSizeChange(e) {
|
|
180
|
+
const selectedValue = parseInt(e.target.value);
|
|
181
|
+
this._setPageSize(selectedValue);
|
|
182
|
+
}
|
|
183
|
+
_renderPageSizeOptions() {
|
|
184
|
+
return this.pageSizeOptions.map(size => html `<option value=${size}>${size}</option>`);
|
|
185
|
+
}
|
|
186
|
+
_renderSpinner() {
|
|
187
|
+
const threeDotsConfiguration = {
|
|
188
|
+
size: '14px',
|
|
189
|
+
color: Palette.MAIN,
|
|
190
|
+
visible: true,
|
|
191
|
+
ariaLabel: 'Loading',
|
|
192
|
+
wrapperStyle: {
|
|
193
|
+
width: '100%',
|
|
194
|
+
display: 'flex',
|
|
195
|
+
justifyContent: 'center',
|
|
196
|
+
padding: '48px 0',
|
|
197
|
+
},
|
|
198
|
+
...this.loader,
|
|
199
|
+
};
|
|
200
|
+
if (!threeDotsConfiguration.visible)
|
|
201
|
+
return null;
|
|
202
|
+
const wrapperVars = {
|
|
203
|
+
'--dot-size': threeDotsConfiguration.size,
|
|
204
|
+
'--dot-color': threeDotsConfiguration.color,
|
|
205
|
+
...threeDotsConfiguration.wrapperStyle,
|
|
206
|
+
};
|
|
207
|
+
const aria = threeDotsConfiguration.ariaLabel;
|
|
208
|
+
return html `<div class="tuix-spinner-wrapper">
|
|
209
|
+
<div
|
|
210
|
+
class="three-dots-wrapper"
|
|
211
|
+
role="status"
|
|
212
|
+
aria-label=${aria}
|
|
213
|
+
style=${styleMap(wrapperVars)}
|
|
214
|
+
>
|
|
215
|
+
<span class="dot" aria-hidden="true"></span>
|
|
216
|
+
<span class="dot" aria-hidden="true"></span>
|
|
217
|
+
<span class="dot" aria-hidden="true"></span>
|
|
218
|
+
<span class="sr-only">${aria}</span>
|
|
219
|
+
</div>
|
|
220
|
+
</div>`;
|
|
221
|
+
}
|
|
222
|
+
_renderPagination() {
|
|
223
|
+
const { totalItems, startItem, endItem, itemsPerPage, isLoading } = this._paginationProps;
|
|
224
|
+
return html `<footer
|
|
225
|
+
style="background-color:${Palette.SECTION_BG};"
|
|
226
|
+
class="table_footer sticky"
|
|
227
|
+
>
|
|
228
|
+
<div class="items-per-page">
|
|
229
|
+
<tuix-text size=${TextSize.Body2}>Items per page</tuix-text>
|
|
230
|
+
<div
|
|
231
|
+
style="outline: 1px solid ${Palette.NEUTRAL_200};"
|
|
232
|
+
class="dropdown_container"
|
|
233
|
+
>
|
|
234
|
+
<select
|
|
235
|
+
class="items-per-page-dropdown"
|
|
236
|
+
.value=${String(itemsPerPage)}
|
|
237
|
+
@change=${this._onPageSizeChange}
|
|
238
|
+
?disabled=${isLoading}
|
|
239
|
+
>
|
|
240
|
+
${this._renderPageSizeOptions()}
|
|
241
|
+
</select>
|
|
242
|
+
<tuix-icon
|
|
243
|
+
class="arrow-icon"
|
|
244
|
+
name=${IconName.CHEVRON_DOWN}
|
|
245
|
+
></tuix-icon>
|
|
246
|
+
</div>
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
<div class="navigation">
|
|
250
|
+
<tuix-text size=${TextSize.Body2}
|
|
251
|
+
>${startItem} - ${endItem} of ${totalItems}</tuix-text
|
|
252
|
+
>
|
|
253
|
+
<div class="buttons">
|
|
254
|
+
<tuix-icon
|
|
255
|
+
class="arrow-icon"
|
|
256
|
+
name=${IconName.CHEVRON_LEFT}
|
|
257
|
+
@click=${this._prevPage}
|
|
258
|
+
></tuix-icon>
|
|
259
|
+
<tuix-icon
|
|
260
|
+
class="arrow-icon"
|
|
261
|
+
name=${IconName.CHEVRON_RIGHT}
|
|
262
|
+
@click=${this._nextPage}
|
|
263
|
+
></tuix-icon>
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
</footer>`;
|
|
267
|
+
}
|
|
268
|
+
_renderTable() {
|
|
269
|
+
return html `<table>
|
|
270
|
+
<thead style="background-color: ${Palette.MAIN}">
|
|
271
|
+
${this._renderHeaderCells()}
|
|
272
|
+
</thead>
|
|
273
|
+
${this.isLoadingData
|
|
274
|
+
? html `<tbody>
|
|
275
|
+
<tr>
|
|
276
|
+
<td colspan=${this.headers.length}>${this._renderSpinner()}</td>
|
|
277
|
+
</tr>
|
|
278
|
+
</tbody>`
|
|
279
|
+
: html `<tbody>
|
|
280
|
+
${this._renderRows()}
|
|
281
|
+
</tbody>`}
|
|
282
|
+
</table>
|
|
283
|
+
${this.paginated ? this._renderPagination() : null}`;
|
|
284
|
+
}
|
|
285
|
+
_renderCards() {
|
|
286
|
+
const rows = this._paginatedData();
|
|
287
|
+
return html `<div class="mobile_table">
|
|
288
|
+
${this.isLoadingData
|
|
289
|
+
? this._renderSpinner()
|
|
290
|
+
: rows.map(row => html `<div
|
|
291
|
+
style="border-bottom: 2px solid ${Palette.MAIN};"
|
|
292
|
+
class="table_entity"
|
|
293
|
+
>
|
|
294
|
+
${this.headers.map(header => html `<div
|
|
295
|
+
class="table_row"
|
|
296
|
+
style="border-bottom:1px solid ${Palette.NEUTRAL_200};"
|
|
297
|
+
>
|
|
298
|
+
<div
|
|
299
|
+
class="header"
|
|
300
|
+
style="background-color:${Palette.SECTION_BG};"
|
|
301
|
+
>
|
|
302
|
+
<tuix-text
|
|
303
|
+
size=${TextSize.Body1}
|
|
304
|
+
color=${TextVariant.PRIMARY}
|
|
305
|
+
>${header.name}</tuix-text
|
|
306
|
+
>
|
|
307
|
+
</div>
|
|
308
|
+
<div class="content">
|
|
309
|
+
${header.isSlot
|
|
310
|
+
? html `<slot
|
|
311
|
+
name="${header.slotName}-${row.id}"
|
|
312
|
+
></slot>`
|
|
313
|
+
: html `<tuix-text size=${TextSize.Body1}
|
|
314
|
+
>${row[header.dataKey]}</tuix-text
|
|
315
|
+
>`}
|
|
316
|
+
</div>
|
|
317
|
+
</div>`)}
|
|
318
|
+
</div>`)}
|
|
319
|
+
</div>
|
|
320
|
+
${this.paginated ? this._renderPagination() : null}`;
|
|
321
|
+
}
|
|
322
|
+
render() {
|
|
323
|
+
const shouldRenderCards = !this.disableMobileTable &&
|
|
324
|
+
(this._isMobileView ||
|
|
325
|
+
(this._isTabletView && this.showMobileTableInTablet));
|
|
326
|
+
return shouldRenderCards
|
|
327
|
+
? html `${this._renderCards()}`
|
|
328
|
+
: html `${this._renderTable()}`;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
TuixTable.styles = [tableStyles, threeDots];
|
|
332
|
+
__decorate([
|
|
333
|
+
property({ type: Boolean })
|
|
334
|
+
], TuixTable.prototype, "paginated", void 0);
|
|
335
|
+
__decorate([
|
|
336
|
+
property({ type: Boolean })
|
|
337
|
+
], TuixTable.prototype, "disableMobileTable", void 0);
|
|
338
|
+
__decorate([
|
|
339
|
+
property({ type: Boolean })
|
|
340
|
+
], TuixTable.prototype, "showMobileTableInTablet", void 0);
|
|
341
|
+
__decorate([
|
|
342
|
+
property({ type: Object })
|
|
343
|
+
], TuixTable.prototype, "loader", void 0);
|
|
344
|
+
__decorate([
|
|
345
|
+
property({ type: Array })
|
|
346
|
+
], TuixTable.prototype, "data", void 0);
|
|
347
|
+
__decorate([
|
|
348
|
+
property({ type: Array })
|
|
349
|
+
], TuixTable.prototype, "headers", void 0);
|
|
350
|
+
__decorate([
|
|
351
|
+
property({ type: Array })
|
|
352
|
+
], TuixTable.prototype, "pageSizeOptions", void 0);
|
|
353
|
+
__decorate([
|
|
354
|
+
property({ type: Number })
|
|
355
|
+
], TuixTable.prototype, "totalItems", void 0);
|
|
356
|
+
__decorate([
|
|
357
|
+
property({ type: Number })
|
|
358
|
+
], TuixTable.prototype, "currentPage", void 0);
|
|
359
|
+
__decorate([
|
|
360
|
+
property({ type: Number })
|
|
361
|
+
], TuixTable.prototype, "currentSize", void 0);
|
|
362
|
+
__decorate([
|
|
363
|
+
property({ type: Boolean })
|
|
364
|
+
], TuixTable.prototype, "isLoadingData", void 0);
|
|
365
|
+
__decorate([
|
|
366
|
+
state()
|
|
367
|
+
], TuixTable.prototype, "_isTabletView", void 0);
|
|
368
|
+
__decorate([
|
|
369
|
+
state()
|
|
370
|
+
], TuixTable.prototype, "_isMobileView", void 0);
|
|
371
|
+
__decorate([
|
|
372
|
+
state()
|
|
373
|
+
], TuixTable.prototype, "_headerPercents", void 0);
|
|
374
|
+
TuixTable = __decorate([
|
|
375
|
+
customElement('tuix-table')
|
|
376
|
+
], TuixTable);
|
|
377
|
+
export { TuixTable };
|
|
378
|
+
//# sourceMappingURL=TuixTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TuixTable.js","sourceRoot":"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B;IAAhB,KAAK,EAAE;kDAAwC;AAlBrC,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAwXrB;SAxXY,SAAS","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { tableStyles, threeDots } from './TuixTable.styles';\nimport { TextSize, TextVariant } from '../tuix-text/enums/tuix-text.enums';\nimport { IconName } from '../tuix-icon/enums/tuix-icon.enums.js';\nimport { Palette } from '../utils/colors';\nimport { ScreenSizes } from '../utils/screenSizes.enum';\n\nimport type {\n IDataTableHeader,\n TablePaginationProps,\n PaginationEventDetail,\n ThreeDotsLoaderConfig,\n} from './interfaces/tuix-table.interface.js';\n\n@customElement('tuix-table')\nexport class TuixTable extends LitElement {\n static styles = [tableStyles, threeDots];\n\n @property({ type: Boolean }) paginated = false;\n @property({ type: Boolean }) disableMobileTable = false;\n @property({ type: Boolean }) showMobileTableInTablet = false;\n @property({ type: Object }) loader?: ThreeDotsLoaderConfig;\n @property({ type: Array }) data: Record<string, any>[] = [];\n @property({ type: Array }) headers: IDataTableHeader<any>[] = [];\n @property({ type: Array }) pageSizeOptions: number[] = [5, 10, 20];\n\n @property({ type: Number }) totalItems?: number;\n @property({ type: Number }) currentPage?: number;\n @property({ type: Number }) currentSize?: number;\n @property({ type: Boolean }) isLoadingData = false;\n\n @state() private _isTabletView = false;\n @state() private _isMobileView = false;\n @state() private _headerPercents: number[] = [];\n\n private _mqTablet?: MediaQueryList;\n private _mqMobile?: MediaQueryList;\n\n private _onScreenSizeChange = () => {\n this._isTabletView = !!this._mqTablet?.matches;\n this._isMobileView = !!this._mqMobile?.matches;\n };\n\n connectedCallback() {\n super.connectedCallback();\n this._mqTablet = window.matchMedia(`(max-width:${ScreenSizes.TABLET}px)`);\n this._mqMobile = window.matchMedia(`(max-width:${ScreenSizes.MOBILE}px)`);\n this._onScreenSizeChange();\n this._mqTablet.addEventListener('change', this._onScreenSizeChange);\n this._mqMobile.addEventListener('change', this._onScreenSizeChange);\n this._computeHeaderPercents();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this._mqTablet?.removeEventListener('change', this._onScreenSizeChange);\n this._mqMobile?.removeEventListener('change', this._onScreenSizeChange);\n }\n\n updated(changedProps: Map<string, any>) {\n if (changedProps.has('headers')) this._computeHeaderPercents();\n }\n\n private get _effectiveTotalItems() {\n return this.data.length ?? this.totalItems;\n }\n\n private get _effectiveCurrentPage() {\n return this.currentPage ?? 1;\n }\n\n private get _effectivePageSize() {\n return this.currentSize ?? this.pageSizeOptions[0];\n }\n\n private get totalPages() {\n const denom = this._effectivePageSize;\n return Math.max(1, Math.ceil(this._effectiveTotalItems / denom));\n }\n\n private get _paginationProps(): TablePaginationProps {\n const totalItems = this._effectiveTotalItems;\n const itemsPerPage = this._effectivePageSize;\n const startItem = totalItems\n ? (this._effectiveCurrentPage - 1) * itemsPerPage + 1\n : 0;\n const endItem = Math.min(\n this._effectiveCurrentPage * itemsPerPage,\n totalItems\n );\n\n return {\n totalItems,\n currentPage: this._effectiveCurrentPage,\n itemsPerPage,\n startItem,\n endItem,\n onNextPage: this._nextPage,\n onPreviousPage: this._prevPage,\n onItemsPerPageChange: this._setPageSize,\n isLoading: this.isLoadingData,\n } as TablePaginationProps;\n }\n\n private _nextPage = () => {\n const next = Math.min(this.totalPages, this._effectiveCurrentPage + 1);\n const detail: PaginationEventDetail = {\n page: next,\n pageSize: this._effectivePageSize,\n };\n this.dispatchEvent(\n new CustomEvent<PaginationEventDetail>('next-page', {\n detail,\n bubbles: true,\n composed: true,\n })\n );\n };\n\n private _prevPage = () => {\n const prev = Math.max(1, this._effectiveCurrentPage - 1);\n const detail: PaginationEventDetail = {\n page: prev,\n pageSize: this._effectivePageSize,\n };\n this.dispatchEvent(\n new CustomEvent<PaginationEventDetail>('previous-page', {\n detail,\n bubbles: true,\n composed: true,\n })\n );\n };\n\n private _setPageSize = (value: number) => {\n const newSize = Math.max(1, Math.floor(value));\n const newPage = 1;\n const detail: PaginationEventDetail = { page: newPage, pageSize: newSize };\n this.dispatchEvent(\n new CustomEvent<PaginationEventDetail>('page-size-change', {\n detail,\n bubbles: true,\n composed: true,\n })\n );\n };\n\n private _paginatedData() {\n if (!this.paginated) return this.data;\n\n const page = this._effectiveCurrentPage;\n const size = this._effectivePageSize;\n const start = (page - 1) * size;\n const end = start + size;\n return this.data.slice(start, end);\n }\n\n private _computeHeaderPercents() {\n const total = this.headers.reduce((acum, header) => acum + header.width, 0);\n this._headerPercents =\n total === 0\n ? this.headers.map(() => 100 / this.headers.length)\n : this.headers.map(header => (header.width / total) * 100);\n }\n\n private _cellStyleString() {\n return `border-bottom:1px solid ${Palette.NEUTRAL_200};`;\n }\n\n private _textVariantColor(header: IDataTableHeader<any>, row: any) {\n const color = header.cellColor\n ? header.cellColor(row)\n : TextVariant.PRIMARY;\n return color;\n }\n\n private _renderHeaderCells() {\n return html`<tr>\n ${this.headers.map(\n (header, idx) => html`<th\n style=${styleMap({\n width: `${this._headerPercents[idx]}%`,\n color: Palette.WHITE,\n })}\n >\n <tuix-text size=${TextSize.Body1} color=${TextVariant.SECONDARY}\n >${header.name}</tuix-text\n >\n </th>`\n )}\n </tr>`;\n }\n\n private _renderCell(header: IDataTableHeader<any>, row: any) {\n if (header.isSlot) {\n const slotName = `${header.slotName}-${row.id}`;\n return html`<td style=\"${this._cellStyleString()}\">\n <slot name=${slotName}></slot>\n </td>`;\n }\n const content = row[header.dataKey];\n return html`<td style=\"${this._cellStyleString()}\">\n <tuix-text\n size=${TextSize.Body1}\n color=${this._textVariantColor(header, row)}\n >${content}</tuix-text\n >\n </td>`;\n }\n\n private _renderRows() {\n const rows = this._paginatedData();\n return repeat(\n rows,\n row => row.id,\n row =>\n html`<tr>\n ${this.headers.map(header => this._renderCell(header, row))}\n </tr>`\n );\n }\n\n private _onPageSizeChange(e: Event) {\n const selectedValue = parseInt((e.target as HTMLSelectElement).value);\n this._setPageSize(selectedValue);\n }\n\n private _renderPageSizeOptions() {\n return this.pageSizeOptions.map(\n size => html`<option value=${size}>${size}</option>`\n );\n }\n\n private _renderSpinner() {\n const threeDotsConfiguration = {\n size: '14px',\n color: Palette.MAIN,\n visible: true,\n ariaLabel: 'Loading',\n wrapperStyle: {\n width: '100%',\n display: 'flex',\n justifyContent: 'center',\n padding: '48px 0',\n },\n ...this.loader,\n } as Required<ThreeDotsLoaderConfig>;\n\n if (!threeDotsConfiguration.visible) return null;\n\n const wrapperVars: Record<string, string | number> = {\n '--dot-size': threeDotsConfiguration.size,\n '--dot-color': threeDotsConfiguration.color,\n ...threeDotsConfiguration.wrapperStyle,\n };\n\n const aria = threeDotsConfiguration.ariaLabel;\n\n return html`<div class=\"tuix-spinner-wrapper\">\n <div\n class=\"three-dots-wrapper\"\n role=\"status\"\n aria-label=${aria}\n style=${styleMap(wrapperVars)}\n >\n <span class=\"dot\" aria-hidden=\"true\"></span>\n <span class=\"dot\" aria-hidden=\"true\"></span>\n <span class=\"dot\" aria-hidden=\"true\"></span>\n <span class=\"sr-only\">${aria}</span>\n </div>\n </div>`;\n }\n private _renderPagination() {\n const { totalItems, startItem, endItem, itemsPerPage, isLoading } =\n this._paginationProps;\n\n return html`<footer\n style=\"background-color:${Palette.SECTION_BG};\"\n class=\"table_footer sticky\"\n >\n <div class=\"items-per-page\">\n <tuix-text size=${TextSize.Body2}>Items per page</tuix-text>\n <div\n style=\"outline: 1px solid ${Palette.NEUTRAL_200};\"\n class=\"dropdown_container\"\n >\n <select\n class=\"items-per-page-dropdown\"\n .value=${String(itemsPerPage)}\n @change=${this._onPageSizeChange}\n ?disabled=${isLoading}\n >\n ${this._renderPageSizeOptions()}\n </select>\n <tuix-icon\n class=\"arrow-icon\"\n name=${IconName.CHEVRON_DOWN}\n ></tuix-icon>\n </div>\n </div>\n\n <div class=\"navigation\">\n <tuix-text size=${TextSize.Body2}\n >${startItem} - ${endItem} of ${totalItems}</tuix-text\n >\n <div class=\"buttons\">\n <tuix-icon\n class=\"arrow-icon\"\n name=${IconName.CHEVRON_LEFT}\n @click=${this._prevPage}\n ></tuix-icon>\n <tuix-icon\n class=\"arrow-icon\"\n name=${IconName.CHEVRON_RIGHT}\n @click=${this._nextPage}\n ></tuix-icon>\n </div>\n </div>\n </footer>`;\n }\n\n private _renderTable() {\n return html`<table>\n <thead style=\"background-color: ${Palette.MAIN}\">\n ${this._renderHeaderCells()}\n </thead>\n ${this.isLoadingData\n ? html`<tbody>\n <tr>\n <td colspan=${this.headers.length}>${this._renderSpinner()}</td>\n </tr>\n </tbody>`\n : html`<tbody>\n ${this._renderRows()}\n </tbody>`}\n </table>\n ${this.paginated ? this._renderPagination() : null}`;\n }\n\n private _renderCards() {\n const rows = this._paginatedData();\n return html`<div class=\"mobile_table\">\n ${this.isLoadingData\n ? this._renderSpinner()\n : rows.map(\n row => html`<div\n style=\"border-bottom: 2px solid ${Palette.MAIN};\"\n class=\"table_entity\"\n >\n ${this.headers.map(\n header => html`<div\n class=\"table_row\"\n style=\"border-bottom:1px solid ${Palette.NEUTRAL_200};\"\n >\n <div\n class=\"header\"\n style=\"background-color:${Palette.SECTION_BG};\"\n >\n <tuix-text\n size=${TextSize.Body1}\n color=${TextVariant.PRIMARY}\n >${header.name}</tuix-text\n >\n </div>\n <div class=\"content\">\n ${header.isSlot\n ? html`<slot\n name=\"${header.slotName}-${row.id}\"\n ></slot>`\n : html`<tuix-text size=${TextSize.Body1}\n >${row[header.dataKey]}</tuix-text\n >`}\n </div>\n </div>`\n )}\n </div>`\n )}\n </div>\n ${this.paginated ? this._renderPagination() : null}`;\n }\n\n render() {\n const shouldRenderCards =\n !this.disableMobileTable &&\n (this._isMobileView ||\n (this._isTabletView && this.showMobileTableInTablet));\n\n return shouldRenderCards\n ? html`${this._renderCards()}`\n : html`${this._renderTable()}`;\n }\n}\n"]}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
import { ScreenSizes } from '../utils/screenSizes.enum.js';
|
|
3
|
+
export const tableStyles = css `
|
|
4
|
+
:host {
|
|
5
|
+
display: block;
|
|
6
|
+
width: 100%;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.table_wrapper {
|
|
10
|
+
width: 100%;
|
|
11
|
+
overflow-x: auto;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
table {
|
|
15
|
+
min-width: 650px;
|
|
16
|
+
table-layout: fixed;
|
|
17
|
+
width: 100%;
|
|
18
|
+
border-collapse: collapse;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
thead th {
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
padding: 8px;
|
|
24
|
+
text-align: left;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
text-overflow: ellipsis;
|
|
27
|
+
white-space: nowrap;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
tbody tr td {
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
height: 52px;
|
|
33
|
+
padding: 6px 8px;
|
|
34
|
+
text-align: left;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
text-overflow: ellipsis;
|
|
37
|
+
white-space: nowrap;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
::slotted(*) {
|
|
41
|
+
display: inline-flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
margin-right: 8px;
|
|
44
|
+
gap: 10px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.dropdown_container {
|
|
48
|
+
position: relative;
|
|
49
|
+
border-radius: 4px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.dropdown_container .items-per-page-dropdown {
|
|
53
|
+
width: 55px;
|
|
54
|
+
border: none;
|
|
55
|
+
background-color: transparent;
|
|
56
|
+
padding: 8px;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
-webkit-appearance: none;
|
|
59
|
+
-moz-appearance: none;
|
|
60
|
+
appearance: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.dropdown_container .items-per-page-dropdown:focus-visible {
|
|
64
|
+
border: none;
|
|
65
|
+
outline: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.dropdown_container .arrow-icon {
|
|
69
|
+
position: absolute;
|
|
70
|
+
right: 8px;
|
|
71
|
+
bottom: 8px;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
pointer-events: none;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
footer.table_footer {
|
|
77
|
+
height: 48px;
|
|
78
|
+
padding: 8px;
|
|
79
|
+
width: 100%;
|
|
80
|
+
display: flex;
|
|
81
|
+
justify-content: space-between;
|
|
82
|
+
align-items: center;
|
|
83
|
+
box-sizing: border-box;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
footer.table_footer .items-per-page {
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
gap: 8px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
footer.table_footer .navigation {
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
gap: 8px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
footer.table_footer .navigation .buttons {
|
|
99
|
+
display: flex;
|
|
100
|
+
gap: 8px;
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.mobile_table {
|
|
105
|
+
display: none;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@media only screen and (max-width: ${ScreenSizes.TABLET}px) {
|
|
109
|
+
.mobile_table {
|
|
110
|
+
display: block;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
footer.table_footer {
|
|
114
|
+
align-items: flex-start;
|
|
115
|
+
gap: 8px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.mobile_table .table_row {
|
|
119
|
+
display: flex;
|
|
120
|
+
min-height: 40px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.mobile_table .table_row > * {
|
|
124
|
+
padding: 0 16px;
|
|
125
|
+
width: 50%;
|
|
126
|
+
text-overflow: ellipsis;
|
|
127
|
+
overflow: hidden;
|
|
128
|
+
display: flex;
|
|
129
|
+
align-items: center;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
133
|
+
export const threeDots = css `
|
|
134
|
+
.tuix-spinner-wrapper {
|
|
135
|
+
display: flex;
|
|
136
|
+
justify-content: center;
|
|
137
|
+
align-items: center;
|
|
138
|
+
padding: 24px 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.three-dots-wrapper {
|
|
142
|
+
display: inline-flex;
|
|
143
|
+
gap: calc(var(--dot-size) * 0.5);
|
|
144
|
+
align-items: center;
|
|
145
|
+
justify-content: center;
|
|
146
|
+
position: relative;
|
|
147
|
+
}
|
|
148
|
+
.three-dots-wrapper .dot {
|
|
149
|
+
width: var(--dot-size);
|
|
150
|
+
height: var(--dot-size);
|
|
151
|
+
background: var(--dot-color);
|
|
152
|
+
border-radius: 50%;
|
|
153
|
+
display: inline-block;
|
|
154
|
+
animation: threeDots 0.9s infinite ease-in-out both;
|
|
155
|
+
}
|
|
156
|
+
.three-dots-wrapper .dot:nth-child(2) {
|
|
157
|
+
animation-delay: 0.15s;
|
|
158
|
+
}
|
|
159
|
+
.three-dots-wrapper .dot:nth-child(3) {
|
|
160
|
+
animation-delay: 0.3s;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@keyframes threeDots {
|
|
164
|
+
0%,
|
|
165
|
+
80%,
|
|
166
|
+
100% {
|
|
167
|
+
transform: scale(0.6);
|
|
168
|
+
opacity: 0.6;
|
|
169
|
+
}
|
|
170
|
+
40% {
|
|
171
|
+
transform: scale(1);
|
|
172
|
+
opacity: 1;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.sr-only {
|
|
177
|
+
border: 0;
|
|
178
|
+
clip: rect(1px, 1px, 1px, 1px);
|
|
179
|
+
-webkit-clip-path: inset(50%);
|
|
180
|
+
clip-path: inset(50%);
|
|
181
|
+
height: 1px;
|
|
182
|
+
margin: -1px;
|
|
183
|
+
overflow: hidden;
|
|
184
|
+
padding: 0;
|
|
185
|
+
position: absolute;
|
|
186
|
+
width: 1px;
|
|
187
|
+
white-space: nowrap;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.clientsLoader,
|
|
191
|
+
.mobileClientsLoader,
|
|
192
|
+
.tabletClientsLoader {
|
|
193
|
+
display: flex;
|
|
194
|
+
justify-content: center;
|
|
195
|
+
padding: 16px 0;
|
|
196
|
+
}
|
|
197
|
+
`;
|
|
198
|
+
//# sourceMappingURL=TuixTable.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TuixTable.styles.js","sourceRoot":"","sources":["../../../src/tuix-table/TuixTable.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCAyGS,WAAW,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;CAwBxD,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgE3B,CAAC","sourcesContent":["import { css } from 'lit';\nimport { ScreenSizes } from '../utils/screenSizes.enum';\n\nexport const tableStyles = css`\n :host {\n display: block;\n width: 100%;\n }\n\n .table_wrapper {\n width: 100%;\n overflow-x: auto;\n }\n\n table {\n min-width: 650px;\n table-layout: fixed;\n width: 100%;\n border-collapse: collapse;\n }\n\n thead th {\n box-sizing: border-box;\n padding: 8px;\n text-align: left;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n tbody tr td {\n box-sizing: border-box;\n height: 52px;\n padding: 6px 8px;\n text-align: left;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n ::slotted(*) {\n display: inline-flex;\n align-items: center;\n margin-right: 8px;\n gap: 10px;\n }\n\n .dropdown_container {\n position: relative;\n border-radius: 4px;\n }\n\n .dropdown_container .items-per-page-dropdown {\n width: 55px;\n border: none;\n background-color: transparent;\n padding: 8px;\n cursor: pointer;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n }\n\n .dropdown_container .items-per-page-dropdown:focus-visible {\n border: none;\n outline: none;\n }\n\n .dropdown_container .arrow-icon {\n position: absolute;\n right: 8px;\n bottom: 8px;\n cursor: pointer;\n pointer-events: none;\n }\n\n footer.table_footer {\n height: 48px;\n padding: 8px;\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n box-sizing: border-box;\n }\n\n footer.table_footer .items-per-page {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n footer.table_footer .navigation {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n footer.table_footer .navigation .buttons {\n display: flex;\n gap: 8px;\n cursor: pointer;\n }\n\n .mobile_table {\n display: none;\n }\n\n @media only screen and (max-width: ${ScreenSizes.TABLET}px) {\n .mobile_table {\n display: block;\n }\n\n footer.table_footer {\n align-items: flex-start;\n gap: 8px;\n }\n\n .mobile_table .table_row {\n display: flex;\n min-height: 40px;\n }\n\n .mobile_table .table_row > * {\n padding: 0 16px;\n width: 50%;\n text-overflow: ellipsis;\n overflow: hidden;\n display: flex;\n align-items: center;\n }\n }\n`;\n\nexport const threeDots = css`\n .tuix-spinner-wrapper {\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 24px 0;\n }\n\n .three-dots-wrapper {\n display: inline-flex;\n gap: calc(var(--dot-size) * 0.5);\n align-items: center;\n justify-content: center;\n position: relative;\n }\n .three-dots-wrapper .dot {\n width: var(--dot-size);\n height: var(--dot-size);\n background: var(--dot-color);\n border-radius: 50%;\n display: inline-block;\n animation: threeDots 0.9s infinite ease-in-out both;\n }\n .three-dots-wrapper .dot:nth-child(2) {\n animation-delay: 0.15s;\n }\n .three-dots-wrapper .dot:nth-child(3) {\n animation-delay: 0.3s;\n }\n\n @keyframes threeDots {\n 0%,\n 80%,\n 100% {\n transform: scale(0.6);\n opacity: 0.6;\n }\n 40% {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n .sr-only {\n border: 0;\n clip: rect(1px, 1px, 1px, 1px);\n -webkit-clip-path: inset(50%);\n clip-path: inset(50%);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px;\n white-space: nowrap;\n }\n\n .clientsLoader,\n .mobileClientsLoader,\n .tabletClientsLoader {\n display: flex;\n justify-content: center;\n padding: 16px 0;\n }\n`;\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface IDataTableHeader<TRowData = Record<string, unknown>> {
|
|
2
|
+
cellColor?: (rowData: TRowData) => string | undefined;
|
|
3
|
+
isSlot?: boolean;
|
|
4
|
+
slotName?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
dataKey: Extract<keyof TRowData, string>;
|
|
7
|
+
width: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TablePaginationProps {
|
|
10
|
+
totalItems: number;
|
|
11
|
+
currentPage: number;
|
|
12
|
+
itemsPerPage: number;
|
|
13
|
+
startItem: number;
|
|
14
|
+
endItem: number;
|
|
15
|
+
onNextPage: () => void;
|
|
16
|
+
onPreviousPage: () => void;
|
|
17
|
+
onItemsPerPageChange: (newPageSize: number) => void;
|
|
18
|
+
isLoading?: boolean;
|
|
19
|
+
stickyInTablet?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ThreeDotsLoaderConfig {
|
|
22
|
+
size?: string;
|
|
23
|
+
color?: string;
|
|
24
|
+
visible?: boolean;
|
|
25
|
+
ariaLabel?: string;
|
|
26
|
+
wrapperStyle?: Record<string, string | number>;
|
|
27
|
+
}
|
|
28
|
+
export interface TuixTableElement<TRowData = any> extends HTMLElement {
|
|
29
|
+
data: TRowData[];
|
|
30
|
+
headers: IDataTableHeader<TRowData>[];
|
|
31
|
+
totalItems?: number;
|
|
32
|
+
currentPage?: number;
|
|
33
|
+
currentSize?: number;
|
|
34
|
+
isLoadingData?: boolean;
|
|
35
|
+
paginated?: boolean;
|
|
36
|
+
showMobileTableInTablet?: boolean;
|
|
37
|
+
disableMobileTable?: boolean;
|
|
38
|
+
pageSizeOptions?: number[];
|
|
39
|
+
loader?: ThreeDotsLoaderConfig;
|
|
40
|
+
}
|
|
41
|
+
export interface PaginationEventDetail {
|
|
42
|
+
page: number;
|
|
43
|
+
pageSize: number;
|
|
44
|
+
}
|
|
45
|
+
export type TuixPaginationEvent = CustomEvent<PaginationEventDetail>;
|