tuix-webcomponents 0.92.0 → 0.94.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/custom-elements.json +643 -463
- 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-icon/TuixIcon.icons.js +11 -0
- package/dist/src/tuix-icon/enums/tuix-icon.enums.d.ts +3 -0
- package/dist/src/tuix-icon/enums/tuix-icon.enums.js +3 -0
- package/dist/src/tuix-table/TuixTable.d.ts +10 -2
- package/dist/src/tuix-table/TuixTable.js +165 -81
- package/dist/src/tuix-table/TuixTable.styles.d.ts +1 -0
- package/dist/src/tuix-table/TuixTable.styles.js +136 -33
- package/dist/src/tuix-table/interfaces/tuix-table.interface.d.ts +11 -0
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { TuixCheckbox } from './tuix-checkbox/TuixCheckbox.js';
|
|
|
17
17
|
export { TuixRadioButton } from './tuix-radio-button/TuixRadioButton.js';
|
|
18
18
|
export { TuixToggleButton } from './tuix-toggle-button/TuixToggleButton.js';
|
|
19
19
|
export { TuixTable } from './tuix-table/TuixTable.js';
|
|
20
|
-
export type { IDataTableHeader, PaginationEventDetail, ThreeDotsLoaderConfig, TuixPaginationEvent, TuixTableElement, } from './tuix-table/interfaces/tuix-table.interface.js';
|
|
20
|
+
export type { IDataTableHeader, PaginationEventDetail, SortDirection, SortEventDetail, ThreeDotsLoaderConfig, TuixPaginationEvent, TuixSortEvent, TuixTableElement, } from './tuix-table/interfaces/tuix-table.interface.js';
|
|
21
21
|
export { TuixToast } from './tuix-toast/TuixToast.js';
|
|
22
22
|
export { TuixModal } from './tuix-modal/TuixModal.js';
|
|
23
23
|
export { ToastType } from './tuix-toast/enums/tuix-toast.enums.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EventName } from '@lit/react';
|
|
2
2
|
import { TuixText as WrappedTuixText, TuixIcon as WrappedTuixIcon, TuixButton as WrappedTuixButton, TuixPaper as WrappedTuixPaper, TuixIconButton as WrappedTuixIconButton, TuixLink as WrappedTuixLink, TuixInput as WrappedTuixInput, TuixDropdown as WrappedTuixDropdown, TuixCheckbox as WrappedTuixCheckbox, TuixRadioButton as WrappedTuixRadioButton, TuixToggleButton as WrappedTuixToggleButton, TuixTable as WrappedTuixTable, TuixToast as WrappedTuixToast, TuixModal as WrappedTuixModal } from '../index.js';
|
|
3
|
-
import type { DetailValue, DetailValueCheckbox, PaginationEventDetail, TuixDropdownPlainOption } from '../index.js';
|
|
3
|
+
import type { DetailValue, DetailValueCheckbox, PaginationEventDetail, SortEventDetail, TuixDropdownPlainOption } from '../index.js';
|
|
4
4
|
export declare const TuixText: import("@lit/react").ReactWebComponent<WrappedTuixText, {}>;
|
|
5
5
|
export declare const TuixIcon: import("@lit/react").ReactWebComponent<WrappedTuixIcon, {}>;
|
|
6
6
|
export declare const TuixButton: import("@lit/react").ReactWebComponent<WrappedTuixButton, {
|
|
@@ -33,6 +33,7 @@ export declare const TuixTable: import("@lit/react").ReactWebComponent<WrappedTu
|
|
|
33
33
|
onNextPage: EventName<CustomEvent<PaginationEventDetail>>;
|
|
34
34
|
onPreviousPage: EventName<CustomEvent<PaginationEventDetail>>;
|
|
35
35
|
onPageSizeChange: EventName<CustomEvent<PaginationEventDetail>>;
|
|
36
|
+
onSort: EventName<CustomEvent<SortEventDetail>>;
|
|
36
37
|
}>;
|
|
37
38
|
export declare const TuixToast: import("@lit/react").ReactWebComponent<WrappedTuixToast, {
|
|
38
39
|
onClose: EventName<CustomEvent<undefined>>;
|
package/dist/src/react/index.js
CHANGED
|
@@ -349,6 +349,17 @@ export const iconContentMap = {
|
|
|
349
349
|
[IconName.BOOK]: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
350
350
|
<path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20" stroke="#121212" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
351
351
|
<path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2" stroke="#121212" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
352
|
+
</svg>`,
|
|
353
|
+
[IconName.BOOK_PLUS]: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
354
|
+
<path d="M12 7v6m-8 6.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5A2.5 2.5 0 0 1 4 19.5m0 0A2.5 2.5 0 0 1 6.5 17H20M9 10h6" stroke="#121212" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
355
|
+
</svg>`,
|
|
356
|
+
[IconName.BOOKS]: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
357
|
+
<path d="M5 7a2 2 0 0 0-2 2v11" stroke="#121212" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
358
|
+
<path d="M5.803 18H5a2 2 0 1 0 0 4h9.5a.5.5 0 0 0 .5-.5V21m-6-6V4a2 2 0 0 1 2-2h9.5a.5.5 0 0 1 .5.5v14a.5.5 0 0 1-.5.5H11a2 2 0 0 1-2-2m0 0a2 2 0 0 1 2-2h10" stroke="#121212" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
359
|
+
</svg>`,
|
|
360
|
+
[IconName.BOOK_SEARCH]: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
361
|
+
<path d="M11 22H5.5a2.5 2.5 0 0 1 0-5h4.501M21 22l-1.879-1.878" stroke="#121212" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
362
|
+
<path d="M3 19.5v-15A2.5 2.5 0 0 1 5.5 2H18a1 1 0 0 1 1 1v8M17 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6" stroke="#121212" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
352
363
|
</svg>`,
|
|
353
364
|
[IconName.MORE_HORIZONTAL]: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
354
365
|
<path d="M12 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2M19 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2M5 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2" stroke="#121212" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -77,6 +77,9 @@ export declare enum IconName {
|
|
|
77
77
|
CHAT = "chat",
|
|
78
78
|
MESSAGE_CIRCLE = "message-circle",
|
|
79
79
|
BOOK = "book",
|
|
80
|
+
BOOK_PLUS = "book-plus",
|
|
81
|
+
BOOKS = "books",
|
|
82
|
+
BOOK_SEARCH = "book-search",
|
|
80
83
|
MORE_HORIZONTAL = "more-horizontal",
|
|
81
84
|
BOT = "bot",
|
|
82
85
|
SCROLL_DOWN = "scroll-down",
|
|
@@ -84,6 +84,9 @@ export var IconName;
|
|
|
84
84
|
IconName["CHAT"] = "chat";
|
|
85
85
|
IconName["MESSAGE_CIRCLE"] = "message-circle";
|
|
86
86
|
IconName["BOOK"] = "book";
|
|
87
|
+
IconName["BOOK_PLUS"] = "book-plus";
|
|
88
|
+
IconName["BOOKS"] = "books";
|
|
89
|
+
IconName["BOOK_SEARCH"] = "book-search";
|
|
87
90
|
IconName["MORE_HORIZONTAL"] = "more-horizontal";
|
|
88
91
|
IconName["BOT"] = "bot";
|
|
89
92
|
IconName["SCROLL_DOWN"] = "scroll-down";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import '../tuix-icon/TuixIcon.js';
|
|
3
3
|
import '../tuix-text/TuixText.js';
|
|
4
|
-
import type { IDataTableHeader, ThreeDotsLoaderConfig } from './interfaces/tuix-table.interface.js';
|
|
4
|
+
import type { IDataTableHeader, SortDirection, ThreeDotsLoaderConfig } from './interfaces/tuix-table.interface.js';
|
|
5
5
|
export declare class TuixTable extends LitElement {
|
|
6
6
|
static styles: import("lit").CSSResult[];
|
|
7
|
+
dark: boolean;
|
|
7
8
|
paginated: boolean;
|
|
8
9
|
disableMobileTable: boolean;
|
|
9
10
|
showMobileTableInTablet: boolean;
|
|
@@ -15,6 +16,8 @@ export declare class TuixTable extends LitElement {
|
|
|
15
16
|
currentPage?: number;
|
|
16
17
|
currentSize?: number;
|
|
17
18
|
isLoadingData: boolean;
|
|
19
|
+
sortBy?: string;
|
|
20
|
+
sortDirection: SortDirection;
|
|
18
21
|
private _isTabletView;
|
|
19
22
|
private _isMobileView;
|
|
20
23
|
private _headerPercents;
|
|
@@ -32,9 +35,13 @@ export declare class TuixTable extends LitElement {
|
|
|
32
35
|
private _nextPage;
|
|
33
36
|
private _prevPage;
|
|
34
37
|
private _setPageSize;
|
|
38
|
+
private _sort;
|
|
35
39
|
private _computeHeaderPercents;
|
|
36
|
-
private
|
|
40
|
+
private _cellBackgroundColor;
|
|
37
41
|
private _textVariantColor;
|
|
42
|
+
private _renderSortIcons;
|
|
43
|
+
private _ariaSort;
|
|
44
|
+
private _onHeaderKeyDown;
|
|
38
45
|
private _renderHeaderCells;
|
|
39
46
|
private _renderCell;
|
|
40
47
|
private _renderRows;
|
|
@@ -43,6 +50,7 @@ export declare class TuixTable extends LitElement {
|
|
|
43
50
|
private _renderSpinner;
|
|
44
51
|
private _renderPagination;
|
|
45
52
|
private _renderTable;
|
|
53
|
+
private _renderCard;
|
|
46
54
|
private _renderCards;
|
|
47
55
|
render(): import("lit-html").TemplateResult<1>;
|
|
48
56
|
}
|
|
@@ -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 { tableHostStyles, tableStyles, threeDots } from './TuixTable.styles';
|
|
9
10
|
import { TextSize, TextVariant } from '../tuix-text/enums/tuix-text.enums';
|
|
10
|
-
import { IconName } from '../tuix-icon/enums/tuix-icon.enums.js';
|
|
11
|
+
import { IconName, IconSizeVariant, } from '../tuix-icon/enums/tuix-icon.enums.js';
|
|
11
12
|
import { Palette } from '../utils/colors';
|
|
13
|
+
import { DarkPalette } from '../utils/darkColors';
|
|
12
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);
|