tuix-webcomponents 0.64.0 → 0.65.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/package-build/src/index.d.ts +36 -0
- package/package-build/src/index.js +42 -0
- package/package-build/src/tuix-button/TuixBaseButton.d.ts +17 -0
- package/package-build/src/tuix-button/TuixBaseButton.js +60 -0
- package/package-build/src/tuix-button/TuixButton.d.ts +11 -0
- package/package-build/src/tuix-button/TuixButton.js +84 -0
- package/package-build/src/tuix-button/TuixButton.styles.d.ts +3 -0
- package/package-build/src/tuix-button/TuixButton.styles.js +107 -0
- package/package-build/src/tuix-button/enums/tuix-button.enums.d.ts +2 -0
- package/package-build/src/tuix-button/enums/tuix-button.enums.js +6 -0
- package/package-build/src/tuix-button/interfaces/tuix-button.interface.d.ts +1 -0
- package/package-build/src/tuix-button/interfaces/tuix-button.interface.js +1 -0
- package/package-build/src/tuix-checkbox/TuixCheckbox.d.ts +15 -0
- package/package-build/src/tuix-checkbox/TuixCheckbox.js +106 -0
- package/package-build/src/tuix-checkbox/TuixCheckbox.styles.d.ts +4 -0
- package/package-build/src/tuix-checkbox/TuixCheckbox.styles.js +132 -0
- package/package-build/src/tuix-checkbox/enums/tuix-checkbox.enums.d.ts +21 -0
- package/package-build/src/tuix-checkbox/enums/tuix-checkbox.enums.js +23 -0
- package/package-build/src/tuix-checkbox/interfaces/tuix-checkbox.interface.d.ts +5 -0
- package/package-build/src/tuix-checkbox/interfaces/tuix-checkbox.interface.js +1 -0
- package/package-build/src/tuix-dropdown/TuixDropdown.d.ts +55 -0
- package/package-build/src/tuix-dropdown/TuixDropdown.js +360 -0
- package/package-build/src/tuix-dropdown/TuixDropdown.styles.d.ts +3 -0
- package/package-build/src/tuix-dropdown/TuixDropdown.styles.js +125 -0
- package/package-build/src/tuix-dropdown/enums/tuix-dropdown.enums.d.ts +4 -0
- package/package-build/src/tuix-dropdown/enums/tuix-dropdown.enums.js +5 -0
- package/package-build/src/tuix-dropdown/interfaces/tuix-dropdown.interface.d.ts +15 -0
- package/package-build/src/tuix-dropdown/interfaces/tuix-dropdown.interface.js +1 -0
- package/package-build/src/tuix-icon/TuixIcon.d.ts +15 -0
- package/package-build/src/tuix-icon/TuixIcon.icons.d.ts +6 -0
- package/{dist/assets/TuixIconButton-eQtxZNXh.js → package-build/src/tuix-icon/TuixIcon.icons.js} +125 -203
- package/package-build/src/tuix-icon/TuixIcon.js +79 -0
- package/package-build/src/tuix-icon/enums/tuix-icon.enums.d.ts +62 -0
- package/package-build/src/tuix-icon/enums/tuix-icon.enums.js +69 -0
- package/package-build/src/tuix-icon-button/TuixIconButton.d.ts +9 -0
- package/package-build/src/tuix-icon-button/TuixIconButton.js +51 -0
- package/package-build/src/tuix-input/TuixInput.d.ts +52 -0
- package/package-build/src/tuix-input/TuixInput.js +370 -0
- package/package-build/src/tuix-input/TuixInput.styles.d.ts +8 -0
- package/package-build/src/tuix-input/TuixInput.styles.js +295 -0
- package/package-build/src/tuix-input/enums/tuix-input.enums.d.ts +38 -0
- package/package-build/src/tuix-input/enums/tuix-input.enums.js +41 -0
- package/package-build/src/tuix-input/interfaces/tuix-input.interface.d.ts +18 -0
- package/package-build/src/tuix-input/interfaces/tuix-input.interface.js +5 -0
- package/package-build/src/tuix-link/TuixLink.d.ts +15 -0
- package/package-build/src/tuix-link/TuixLink.js +71 -0
- package/package-build/src/tuix-link/TuixLink.styles.d.ts +2 -0
- package/package-build/src/tuix-link/TuixLink.styles.js +55 -0
- package/package-build/src/tuix-link/enums/linkTarget.enum.d.ts +6 -0
- package/package-build/src/tuix-link/enums/linkTarget.enum.js +7 -0
- package/package-build/src/tuix-modal/TuixModal.d.ts +9 -0
- package/package-build/src/tuix-modal/TuixModal.js +63 -0
- package/package-build/src/tuix-modal/TuixModal.styles.d.ts +2 -0
- package/package-build/src/tuix-modal/TuixModal.styles.js +55 -0
- package/package-build/src/tuix-paper/TuixPaper.d.ts +10 -0
- package/package-build/src/tuix-paper/TuixPaper.js +46 -0
- package/package-build/src/tuix-paper/TuixPaper.styles.d.ts +1 -0
- package/package-build/src/tuix-paper/TuixPaper.styles.js +30 -0
- package/package-build/src/tuix-paper/enums/tuix-paper.enum.d.ts +13 -0
- package/package-build/src/tuix-paper/enums/tuix-paper.enum.js +15 -0
- package/package-build/src/tuix-radio-button/TuixRadioButton.d.ts +16 -0
- package/package-build/src/tuix-radio-button/TuixRadioButton.js +95 -0
- package/package-build/src/tuix-radio-button/TuixRadioButton.styles.d.ts +5 -0
- package/package-build/src/tuix-radio-button/TuixRadioButton.styles.js +135 -0
- package/package-build/src/tuix-radio-button/interfaces/tuix-radio-button.interface.d.ts +3 -0
- package/package-build/src/tuix-radio-button/interfaces/tuix-radio-button.interface.js +1 -0
- package/package-build/src/tuix-table/TuixTable.d.ts +46 -0
- package/package-build/src/tuix-table/TuixTable.js +367 -0
- package/package-build/src/tuix-table/TuixTable.styles.d.ts +2 -0
- package/package-build/src/tuix-table/TuixTable.styles.js +197 -0
- package/package-build/src/tuix-table/interfaces/tuix-table.interface.d.ts +45 -0
- package/package-build/src/tuix-table/interfaces/tuix-table.interface.js +1 -0
- package/package-build/src/tuix-text/TuixText.d.ts +12 -0
- package/package-build/src/tuix-text/TuixText.js +66 -0
- package/package-build/src/tuix-text/TuixText.styles.d.ts +2 -0
- package/package-build/src/tuix-text/TuixText.styles.js +158 -0
- package/package-build/src/tuix-text/enums/tuix-text.enums.d.ts +31 -0
- package/package-build/src/tuix-text/enums/tuix-text.enums.js +63 -0
- package/package-build/src/tuix-toast/TuixToast.d.ts +15 -0
- package/package-build/src/tuix-toast/TuixToast.js +100 -0
- package/package-build/src/tuix-toast/TuixToast.styles.d.ts +3 -0
- package/package-build/src/tuix-toast/TuixToast.styles.js +43 -0
- package/package-build/src/tuix-toast/enums/tuix-toast.enums.d.ts +20 -0
- package/package-build/src/tuix-toast/enums/tuix-toast.enums.js +59 -0
- package/package-build/src/tuix-toggle-button/TuixToggleButton.d.ts +13 -0
- package/package-build/src/tuix-toggle-button/TuixToggleButton.js +85 -0
- package/package-build/src/tuix-toggle-button/TuixToggleButton.styles.d.ts +5 -0
- package/package-build/src/tuix-toggle-button/TuixToggleButton.styles.js +134 -0
- package/package-build/src/tuix-toggle-button/interfaces/tuix-toggle.interface.d.ts +2 -0
- package/package-build/src/tuix-toggle-button/interfaces/tuix-toggle.interface.js +1 -0
- package/package-build/src/utils/colors.d.ts +29 -0
- package/package-build/src/utils/colors.js +30 -0
- package/package-build/src/utils/darkColors.d.ts +31 -0
- package/package-build/src/utils/darkColors.js +32 -0
- package/package-build/src/utils/hex-rgb.d.ts +5 -0
- package/package-build/src/utils/hex-rgb.js +15 -0
- package/package-build/src/utils/interfaces/detail-value.interface.d.ts +3 -0
- package/package-build/src/utils/interfaces/detail-value.interface.js +1 -0
- package/package-build/src/utils/mainVariant.enum.d.ts +4 -0
- package/package-build/src/utils/mainVariant.enum.js +5 -0
- package/package-build/src/utils/screenSizes.enum.d.ts +4 -0
- package/package-build/src/utils/screenSizes.enum.js +5 -0
- package/package-build/src/utils/slottedClassName.d.ts +2 -0
- package/package-build/src/utils/slottedClassName.js +1 -0
- package/package-build/tsconfig.publish.tsbuildinfo +1 -0
- package/package.json +9 -9
- package/dist/addon-visual-tests-assets/visual-test-illustration.mp4 +0 -0
- package/dist/assets/Color-AVL7NMMY-IH_JbDEF.js +0 -1
- package/dist/assets/DocsRenderer-PQXLIZUC-C0ZKNA9m.js +0 -1286
- package/dist/assets/TuixModal-BZFIHTi_.js +0 -78
- package/dist/assets/TuixToast-BhxwZIGo.js +0 -62
- package/dist/assets/_commonjsHelpers-CqkleIqs.js +0 -1
- package/dist/assets/axe-C59a3kt3.js +0 -30
- package/dist/assets/iframe-ClsPaEIM.js +0 -1057
- package/dist/assets/index-DBzYXxxs.js +0 -1554
- package/dist/assets/index-TjhCmV-u.js +0 -1
- package/dist/assets/matchers-7Z3WT2CE-CcSi9QFY.js +0 -14
- package/dist/assets/screenSizes.enum-C1IhC_dy.js +0 -13
- package/dist/assets/state-CLjydI9z.js +0 -13
- package/dist/assets/tuix-button.stories-Dm_yifox.js +0 -30
- package/dist/assets/tuix-checkbox.stories-DmzoygjC.js +0 -44
- package/dist/assets/tuix-dropdown-object-list.stories-Neeajtj-.js +0 -56
- package/dist/assets/tuix-dropdown.stories-B7ea8QAz.js +0 -28
- package/dist/assets/tuix-icon-button.stories-CgbOSRO4.js +0 -21
- package/dist/assets/tuix-icon.enums-DYTtwLZl.js +0 -1
- package/dist/assets/tuix-icon.stories-CjN2XsKx.js +0 -19
- package/dist/assets/tuix-input.stories-CD7onvw2.js +0 -33
- package/dist/assets/tuix-link.stories-CT7pzGlx.js +0 -35
- package/dist/assets/tuix-modal.stories-B6v3cOPq.js +0 -39
- package/dist/assets/tuix-paper.enum-DhmlUJB7.js +0 -1
- package/dist/assets/tuix-paper.stories-CLnRPHNK.js +0 -31
- package/dist/assets/tuix-radio-button.stories-BwkKC3a9.js +0 -35
- package/dist/assets/tuix-table.stories-Bn-aZa0J.js +0 -65
- package/dist/assets/tuix-text.enums-Ck8cVqZZ.js +0 -1
- package/dist/assets/tuix-text.stories-BNIqPsGD.js +0 -29
- package/dist/assets/tuix-toast.stories-CRYiLiHK.js +0 -21
- package/dist/assets/tuix-toggle-button.stories-CY6wlDnA.js +0 -40
- package/dist/favicon-wrapper.svg +0 -46
- package/dist/favicon.svg +0 -1
- package/dist/iframe.html +0 -685
- package/dist/index.html +0 -160
- package/dist/index.json +0 -1
- package/dist/nunito-sans-bold-italic.woff2 +0 -0
- package/dist/nunito-sans-bold.woff2 +0 -0
- package/dist/nunito-sans-italic.woff2 +0 -0
- package/dist/nunito-sans-regular.woff2 +0 -0
- package/dist/project.json +0 -1
- package/dist/sb-addons/a11y-3/manager-bundle.js +0 -5
- package/dist/sb-addons/a11y-3/manager-bundle.js.LEGAL.txt +0 -0
- package/dist/sb-addons/chromatic-com-storybook-1/manager-bundle.js +0 -356
- package/dist/sb-addons/chromatic-com-storybook-1/manager-bundle.js.LEGAL.txt +0 -40
- package/dist/sb-addons/docs-2/manager-bundle.js +0 -151
- package/dist/sb-addons/docs-2/manager-bundle.js.LEGAL.txt +0 -0
- package/dist/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +0 -971
- package/dist/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
- package/dist/sb-addons/vitest-4/manager-bundle.js +0 -3
- package/dist/sb-addons/vitest-4/manager-bundle.js.LEGAL.txt +0 -0
- package/dist/sb-common-assets/favicon-wrapper.svg +0 -46
- package/dist/sb-common-assets/favicon.svg +0 -1
- package/dist/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/dist/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/dist/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/dist/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/dist/sb-manager/globals-module-info.js +0 -797
- package/dist/sb-manager/globals-runtime.js +0 -69679
- package/dist/sb-manager/globals.js +0 -34
- package/dist/sb-manager/runtime.js +0 -13195
|
@@ -0,0 +1,367 @@
|
|
|
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';
|
|
7
|
+
import { TextSize, TextVariant } from '../tuix-text/enums/tuix-text.enums';
|
|
8
|
+
import { IconName } from '../tuix-icon/enums/tuix-icon.enums.js';
|
|
9
|
+
import { Palette } from '../utils/colors';
|
|
10
|
+
import { ScreenSizes } from '../utils/screenSizes.enum';
|
|
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
|
+
this._isTabletView = !!this._mqTablet?.matches;
|
|
26
|
+
this._isMobileView = !!this._mqMobile?.matches;
|
|
27
|
+
};
|
|
28
|
+
this._nextPage = () => {
|
|
29
|
+
if (this.currentPage === this.totalPages)
|
|
30
|
+
return;
|
|
31
|
+
const next = Math.min(this.totalPages, this._effectiveCurrentPage + 1);
|
|
32
|
+
const detail = {
|
|
33
|
+
page: next,
|
|
34
|
+
pageSize: this._effectivePageSize,
|
|
35
|
+
};
|
|
36
|
+
this.dispatchEvent(new CustomEvent('next-page', {
|
|
37
|
+
detail,
|
|
38
|
+
bubbles: true,
|
|
39
|
+
composed: true,
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
this._prevPage = () => {
|
|
43
|
+
if (this.currentPage === 1)
|
|
44
|
+
return;
|
|
45
|
+
const prev = Math.max(1, this._effectiveCurrentPage - 1);
|
|
46
|
+
const detail = {
|
|
47
|
+
page: prev,
|
|
48
|
+
pageSize: this._effectivePageSize,
|
|
49
|
+
};
|
|
50
|
+
this.dispatchEvent(new CustomEvent('previous-page', {
|
|
51
|
+
detail,
|
|
52
|
+
bubbles: true,
|
|
53
|
+
composed: true,
|
|
54
|
+
}));
|
|
55
|
+
};
|
|
56
|
+
this._setPageSize = (value) => {
|
|
57
|
+
const newSize = Math.max(1, Math.floor(value));
|
|
58
|
+
const newPage = 1;
|
|
59
|
+
const detail = { page: newPage, pageSize: newSize };
|
|
60
|
+
this.dispatchEvent(new CustomEvent('page-size-change', {
|
|
61
|
+
detail,
|
|
62
|
+
bubbles: true,
|
|
63
|
+
composed: true,
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
static { this.styles = [tableStyles, threeDots]; }
|
|
68
|
+
connectedCallback() {
|
|
69
|
+
super.connectedCallback();
|
|
70
|
+
this._mqTablet = window.matchMedia(`(max-width:${ScreenSizes.TABLET}px)`);
|
|
71
|
+
this._mqMobile = window.matchMedia(`(max-width:${ScreenSizes.MOBILE}px)`);
|
|
72
|
+
this._onScreenSizeChange();
|
|
73
|
+
this._mqTablet.addEventListener('change', this._onScreenSizeChange);
|
|
74
|
+
this._mqMobile.addEventListener('change', this._onScreenSizeChange);
|
|
75
|
+
this._computeHeaderPercents();
|
|
76
|
+
}
|
|
77
|
+
disconnectedCallback() {
|
|
78
|
+
super.disconnectedCallback();
|
|
79
|
+
this._mqTablet?.removeEventListener('change', this._onScreenSizeChange);
|
|
80
|
+
this._mqMobile?.removeEventListener('change', this._onScreenSizeChange);
|
|
81
|
+
}
|
|
82
|
+
updated(changedProps) {
|
|
83
|
+
if (changedProps.has('headers'))
|
|
84
|
+
this._computeHeaderPercents();
|
|
85
|
+
}
|
|
86
|
+
get _effectiveTotalItems() {
|
|
87
|
+
return this.totalItems ?? this.data.length;
|
|
88
|
+
}
|
|
89
|
+
get _effectiveCurrentPage() {
|
|
90
|
+
return this.currentPage ?? 1;
|
|
91
|
+
}
|
|
92
|
+
get _effectivePageSize() {
|
|
93
|
+
return this.currentSize ?? 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
|
+
_computeHeaderPercents() {
|
|
119
|
+
const total = this.headers.reduce((acum, header) => acum + header.width, 0);
|
|
120
|
+
this._headerPercents =
|
|
121
|
+
total === 0
|
|
122
|
+
? this.headers.map(() => 100 / this.headers.length)
|
|
123
|
+
: this.headers.map(header => (header.width / total) * 100);
|
|
124
|
+
}
|
|
125
|
+
_cellStyleString() {
|
|
126
|
+
return `border-bottom:1px solid ${Palette.NEUTRAL_200};`;
|
|
127
|
+
}
|
|
128
|
+
_textVariantColor(header, row) {
|
|
129
|
+
const color = header.cellColor
|
|
130
|
+
? header.cellColor(row)
|
|
131
|
+
: TextVariant.PRIMARY;
|
|
132
|
+
return color;
|
|
133
|
+
}
|
|
134
|
+
_renderHeaderCells() {
|
|
135
|
+
return html `<tr>
|
|
136
|
+
${this.headers.map((header, idx) => html `<th
|
|
137
|
+
style=${styleMap({
|
|
138
|
+
width: `${this._headerPercents[idx]}%`,
|
|
139
|
+
color: Palette.WHITE,
|
|
140
|
+
})}
|
|
141
|
+
>
|
|
142
|
+
<tuix-text size=${TextSize.Body1} color=${TextVariant.SECONDARY}
|
|
143
|
+
>${header.name}</tuix-text
|
|
144
|
+
>
|
|
145
|
+
</th>`)}
|
|
146
|
+
</tr>`;
|
|
147
|
+
}
|
|
148
|
+
_renderCell(header, row) {
|
|
149
|
+
if (header.isSlot) {
|
|
150
|
+
const slotName = `${header.slotName}-${row.id}`;
|
|
151
|
+
return html `<td style="${this._cellStyleString()}">
|
|
152
|
+
<slot name=${slotName}></slot>
|
|
153
|
+
</td>`;
|
|
154
|
+
}
|
|
155
|
+
const content = row[header.dataKey];
|
|
156
|
+
return html `<td style="${this._cellStyleString()}">
|
|
157
|
+
<tuix-text
|
|
158
|
+
size=${TextSize.Body1}
|
|
159
|
+
color=${this._textVariantColor(header, row)}
|
|
160
|
+
>${content}</tuix-text
|
|
161
|
+
>
|
|
162
|
+
</td>`;
|
|
163
|
+
}
|
|
164
|
+
_renderRows() {
|
|
165
|
+
const rows = this.data;
|
|
166
|
+
return repeat(rows, row => row.id, row => html `<tr>
|
|
167
|
+
${this.headers.map(header => this._renderCell(header, row))}
|
|
168
|
+
</tr>`);
|
|
169
|
+
}
|
|
170
|
+
_onPageSizeChange(e) {
|
|
171
|
+
const selectedValue = parseInt(e.target.value);
|
|
172
|
+
this._setPageSize(selectedValue);
|
|
173
|
+
}
|
|
174
|
+
_renderPageSizeOptions() {
|
|
175
|
+
return this.pageSizeOptions.map(size => html `<option value=${size}>${size}</option>`);
|
|
176
|
+
}
|
|
177
|
+
_renderSpinner() {
|
|
178
|
+
const threeDotsConfiguration = {
|
|
179
|
+
size: '14px',
|
|
180
|
+
color: Palette.MAIN,
|
|
181
|
+
visible: true,
|
|
182
|
+
ariaLabel: 'Loading',
|
|
183
|
+
wrapperStyle: {
|
|
184
|
+
width: '100%',
|
|
185
|
+
display: 'flex',
|
|
186
|
+
justifyContent: 'center',
|
|
187
|
+
padding: '48px 0',
|
|
188
|
+
},
|
|
189
|
+
...this.loader,
|
|
190
|
+
};
|
|
191
|
+
if (!threeDotsConfiguration.visible)
|
|
192
|
+
return null;
|
|
193
|
+
const wrapperVars = {
|
|
194
|
+
'--dot-size': threeDotsConfiguration.size,
|
|
195
|
+
'--dot-color': threeDotsConfiguration.color,
|
|
196
|
+
...threeDotsConfiguration.wrapperStyle,
|
|
197
|
+
};
|
|
198
|
+
const aria = threeDotsConfiguration.ariaLabel;
|
|
199
|
+
return html `<div class="tuix-spinner-wrapper">
|
|
200
|
+
<div
|
|
201
|
+
class="three-dots-wrapper"
|
|
202
|
+
role="status"
|
|
203
|
+
aria-label=${aria}
|
|
204
|
+
style=${styleMap(wrapperVars)}
|
|
205
|
+
>
|
|
206
|
+
<span class="dot" aria-hidden="true"></span>
|
|
207
|
+
<span class="dot" aria-hidden="true"></span>
|
|
208
|
+
<span class="dot" aria-hidden="true"></span>
|
|
209
|
+
<span class="sr-only">${aria}</span>
|
|
210
|
+
</div>
|
|
211
|
+
</div>`;
|
|
212
|
+
}
|
|
213
|
+
_renderPagination() {
|
|
214
|
+
const { totalItems, startItem, endItem, itemsPerPage, isLoading } = this._paginationProps;
|
|
215
|
+
return html `<footer
|
|
216
|
+
style="background-color:${Palette.SECTION_BG};"
|
|
217
|
+
class="table_footer sticky"
|
|
218
|
+
>
|
|
219
|
+
<div class="items-per-page">
|
|
220
|
+
<tuix-text size=${TextSize.Body2}>Items per page</tuix-text>
|
|
221
|
+
<div
|
|
222
|
+
style="outline: 1px solid ${Palette.NEUTRAL_200};"
|
|
223
|
+
class="dropdown_container"
|
|
224
|
+
>
|
|
225
|
+
<select
|
|
226
|
+
class="items-per-page-dropdown"
|
|
227
|
+
.value=${String(itemsPerPage)}
|
|
228
|
+
@change=${this._onPageSizeChange}
|
|
229
|
+
?disabled=${isLoading}
|
|
230
|
+
>
|
|
231
|
+
${this._renderPageSizeOptions()}
|
|
232
|
+
</select>
|
|
233
|
+
<tuix-icon
|
|
234
|
+
class="arrow-icon"
|
|
235
|
+
name=${IconName.CHEVRON_DOWN}
|
|
236
|
+
></tuix-icon>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
<div class="navigation">
|
|
241
|
+
<tuix-text size=${TextSize.Body2}
|
|
242
|
+
>${startItem} - ${endItem} of ${totalItems}</tuix-text
|
|
243
|
+
>
|
|
244
|
+
<div class="buttons">
|
|
245
|
+
<tuix-icon
|
|
246
|
+
class="arrow-icon"
|
|
247
|
+
name=${IconName.CHEVRON_LEFT}
|
|
248
|
+
@click=${this._prevPage}
|
|
249
|
+
></tuix-icon>
|
|
250
|
+
<tuix-icon
|
|
251
|
+
class="arrow-icon"
|
|
252
|
+
name=${IconName.CHEVRON_RIGHT}
|
|
253
|
+
@click=${this._nextPage}
|
|
254
|
+
></tuix-icon>
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
</footer>`;
|
|
258
|
+
}
|
|
259
|
+
_renderTable() {
|
|
260
|
+
return html `<table>
|
|
261
|
+
<thead style="background-color: ${Palette.MAIN}">
|
|
262
|
+
${this._renderHeaderCells()}
|
|
263
|
+
</thead>
|
|
264
|
+
${this.isLoadingData
|
|
265
|
+
? html `<tbody>
|
|
266
|
+
<tr>
|
|
267
|
+
<td colspan=${this.headers.length}>${this._renderSpinner()}</td>
|
|
268
|
+
</tr>
|
|
269
|
+
</tbody>`
|
|
270
|
+
: html `<tbody>
|
|
271
|
+
${this._renderRows()}
|
|
272
|
+
</tbody>`}
|
|
273
|
+
</table>
|
|
274
|
+
${this.paginated ? this._renderPagination() : null}`;
|
|
275
|
+
}
|
|
276
|
+
_renderCards() {
|
|
277
|
+
const rows = this.data;
|
|
278
|
+
return html `<div class="mobile_table">
|
|
279
|
+
${this.isLoadingData
|
|
280
|
+
? this._renderSpinner()
|
|
281
|
+
: rows.map(row => html `<div
|
|
282
|
+
style="border-bottom: 2px solid ${Palette.MAIN};"
|
|
283
|
+
class="table_entity"
|
|
284
|
+
>
|
|
285
|
+
${this.headers.map(header => html `<div
|
|
286
|
+
class="table_row"
|
|
287
|
+
style="border-bottom:1px solid ${Palette.NEUTRAL_200};"
|
|
288
|
+
>
|
|
289
|
+
<div
|
|
290
|
+
class="header"
|
|
291
|
+
style="background-color:${Palette.SECTION_BG};"
|
|
292
|
+
>
|
|
293
|
+
<tuix-text
|
|
294
|
+
size=${TextSize.Body1}
|
|
295
|
+
color=${TextVariant.PRIMARY}
|
|
296
|
+
>${header.name}</tuix-text
|
|
297
|
+
>
|
|
298
|
+
</div>
|
|
299
|
+
<div class="content">
|
|
300
|
+
${header.isSlot
|
|
301
|
+
? html `<slot
|
|
302
|
+
name="${header.slotName}-${row.id}"
|
|
303
|
+
></slot>`
|
|
304
|
+
: html `<tuix-text size=${TextSize.Body1}
|
|
305
|
+
>${row[header.dataKey]}</tuix-text
|
|
306
|
+
>`}
|
|
307
|
+
</div>
|
|
308
|
+
</div>`)}
|
|
309
|
+
</div>`)}
|
|
310
|
+
</div>
|
|
311
|
+
${this.paginated ? this._renderPagination() : null}`;
|
|
312
|
+
}
|
|
313
|
+
render() {
|
|
314
|
+
const shouldRenderCards = !this.disableMobileTable &&
|
|
315
|
+
(this._isMobileView ||
|
|
316
|
+
(this._isTabletView && this.showMobileTableInTablet));
|
|
317
|
+
return shouldRenderCards
|
|
318
|
+
? html `${this._renderCards()}`
|
|
319
|
+
: html `${this._renderTable()}`;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
__decorate([
|
|
323
|
+
property({ type: Boolean })
|
|
324
|
+
], TuixTable.prototype, "paginated", void 0);
|
|
325
|
+
__decorate([
|
|
326
|
+
property({ type: Boolean })
|
|
327
|
+
], TuixTable.prototype, "disableMobileTable", void 0);
|
|
328
|
+
__decorate([
|
|
329
|
+
property({ type: Boolean })
|
|
330
|
+
], TuixTable.prototype, "showMobileTableInTablet", void 0);
|
|
331
|
+
__decorate([
|
|
332
|
+
property({ type: Object })
|
|
333
|
+
], TuixTable.prototype, "loader", void 0);
|
|
334
|
+
__decorate([
|
|
335
|
+
property({ type: Array })
|
|
336
|
+
], TuixTable.prototype, "data", void 0);
|
|
337
|
+
__decorate([
|
|
338
|
+
property({ type: Array })
|
|
339
|
+
], TuixTable.prototype, "headers", void 0);
|
|
340
|
+
__decorate([
|
|
341
|
+
property({ type: Array })
|
|
342
|
+
], TuixTable.prototype, "pageSizeOptions", void 0);
|
|
343
|
+
__decorate([
|
|
344
|
+
property({ type: Number })
|
|
345
|
+
], TuixTable.prototype, "totalItems", void 0);
|
|
346
|
+
__decorate([
|
|
347
|
+
property({ type: Number })
|
|
348
|
+
], TuixTable.prototype, "currentPage", void 0);
|
|
349
|
+
__decorate([
|
|
350
|
+
property({ type: Number })
|
|
351
|
+
], TuixTable.prototype, "currentSize", void 0);
|
|
352
|
+
__decorate([
|
|
353
|
+
property({ type: Boolean })
|
|
354
|
+
], TuixTable.prototype, "isLoadingData", void 0);
|
|
355
|
+
__decorate([
|
|
356
|
+
state()
|
|
357
|
+
], TuixTable.prototype, "_isTabletView", void 0);
|
|
358
|
+
__decorate([
|
|
359
|
+
state()
|
|
360
|
+
], TuixTable.prototype, "_isMobileView", void 0);
|
|
361
|
+
__decorate([
|
|
362
|
+
state()
|
|
363
|
+
], TuixTable.prototype, "_headerPercents", void 0);
|
|
364
|
+
TuixTable = __decorate([
|
|
365
|
+
customElement('tuix-table')
|
|
366
|
+
], TuixTable);
|
|
367
|
+
export { TuixTable };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
import { ScreenSizes } from '../utils/screenSizes.enum';
|
|
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
|
+
`;
|
|
@@ -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>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { TextSize, TextVariant } from './enums/tuix-text.enums.js';
|
|
3
|
+
export declare class TuixText extends LitElement {
|
|
4
|
+
size: TextSize;
|
|
5
|
+
color?: TextVariant | undefined;
|
|
6
|
+
dark: boolean;
|
|
7
|
+
static styles: import("lit").CSSResult[];
|
|
8
|
+
private _getTextColor;
|
|
9
|
+
private _getStyleMap;
|
|
10
|
+
private _getClassMap;
|
|
11
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, css, LitElement, unsafeCSS } from 'lit';
|
|
3
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import { TextSize, TextVariant, colorText, colorTextDark, } from './enums/tuix-text.enums.js';
|
|
6
|
+
import { linkFontStyles, textStyles } from './TuixText.styles.js';
|
|
7
|
+
import { buttonSizeStyles } from '../tuix-button/TuixButton.styles.js';
|
|
8
|
+
import slottedClassName from '../utils/slottedClassName.js';
|
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
10
|
+
import { LINK_TEXT_COLOR_VAR_NAME } from '../tuix-link/TuixLink.styles.js';
|
|
11
|
+
let TuixText = class TuixText extends LitElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.size = TextSize.Body1;
|
|
15
|
+
this.color = TextVariant.PRIMARY;
|
|
16
|
+
this.dark = false;
|
|
17
|
+
this._getStyleMap = () => {
|
|
18
|
+
return {
|
|
19
|
+
color: `var(${LINK_TEXT_COLOR_VAR_NAME}, ${this._getTextColor()})`,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
this._getClassMap = () => {
|
|
23
|
+
return {
|
|
24
|
+
text: true,
|
|
25
|
+
[this.size]: true,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
static { this.styles = [
|
|
30
|
+
css `
|
|
31
|
+
${unsafeCSS(slottedClassName('text'))} {
|
|
32
|
+
font-family: 'Rubik', sans-serif;
|
|
33
|
+
display: inline;
|
|
34
|
+
margin: 0;
|
|
35
|
+
}
|
|
36
|
+
`,
|
|
37
|
+
textStyles,
|
|
38
|
+
linkFontStyles,
|
|
39
|
+
buttonSizeStyles,
|
|
40
|
+
]; }
|
|
41
|
+
_getTextColor() {
|
|
42
|
+
const colorMap = this.dark ? colorTextDark : colorText;
|
|
43
|
+
return colorMap[this.color || TextVariant.PRIMARY];
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
return html ` <div
|
|
47
|
+
class="${classMap(this._getClassMap())}"
|
|
48
|
+
style="${styleMap(this._getStyleMap())}"
|
|
49
|
+
>
|
|
50
|
+
<slot></slot>
|
|
51
|
+
</div>`;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
__decorate([
|
|
55
|
+
property({ type: TextSize })
|
|
56
|
+
], TuixText.prototype, "size", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
property({ type: TextVariant })
|
|
59
|
+
], TuixText.prototype, "color", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
property({ type: Boolean, reflect: true })
|
|
62
|
+
], TuixText.prototype, "dark", void 0);
|
|
63
|
+
TuixText = __decorate([
|
|
64
|
+
customElement('tuix-text')
|
|
65
|
+
], TuixText);
|
|
66
|
+
export { TuixText };
|