kanto-ds 1.4.0 → 1.5.2
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 +10 -10
- package/dist/chunks/{defaults-BwgjMcww.js → defaults-CFrjqae2.js} +22 -21
- package/dist/chunks/{defaults-BwgjMcww.js.map → defaults-CFrjqae2.js.map} +1 -1
- package/dist/chunks/events-r51msXNf.js +22 -0
- package/dist/chunks/{events-Bjl5Zmmq.js.map → events-r51msXNf.js.map} +1 -1
- package/dist/chunks/floating-B7_Dahpn.js +54 -0
- package/dist/chunks/floating-B7_Dahpn.js.map +1 -0
- package/dist/chunks/{form-control-CxjBTt1c.js → form-control-B74_EHtG.js} +7 -7
- package/dist/chunks/form-control-B74_EHtG.js.map +1 -0
- package/dist/chunks/{index-DSSLJirw.js → index-STEEvEP7.js} +24 -12
- package/dist/chunks/index-STEEvEP7.js.map +1 -0
- package/dist/chunks/kt-calendar-B_hFdD9V.js +640 -0
- package/dist/chunks/kt-calendar-B_hFdD9V.js.map +1 -0
- package/dist/chunks/{kt-element-E-tfJpGQ.js → kt-element-Djx2JcGl.js} +2 -2
- package/dist/chunks/{kt-element-E-tfJpGQ.js.map → kt-element-Djx2JcGl.js.map} +1 -1
- package/dist/chunks/{listbox-Sm3nvsC6.js → listbox-llcUu_V-.js} +18 -14
- package/dist/chunks/{listbox-Sm3nvsC6.js.map → listbox-llcUu_V-.js.map} +1 -1
- package/dist/chunks/locale-C5xLkGx5.js +14 -0
- package/dist/chunks/locale-C5xLkGx5.js.map +1 -0
- package/dist/chunks/position-Cx_ZH5zh.js +39 -0
- package/dist/chunks/position-Cx_ZH5zh.js.map +1 -0
- package/dist/components/core/kt-avatar/kt-avatar.js +2 -2
- package/dist/components/core/kt-badge/kt-badge.js +3 -3
- package/dist/components/core/kt-button/kt-button.js +1 -1
- package/dist/components/core/kt-card/kt-card.js +2 -2
- package/dist/components/core/kt-code/kt-code.js +3 -3
- package/dist/components/core/kt-icon/kt-icon.js +2 -2
- package/dist/components/core/kt-kbd/kt-kbd.js +1 -1
- package/dist/components/core/kt-split-button/kt-split-button.js +4 -4
- package/dist/components/data/kt-chart/kt-chart.js +3 -3
- package/dist/components/data/kt-meter/kt-meter.js +1 -1
- package/dist/components/data/kt-pagination/kt-pagination.js +3 -3
- package/dist/components/data/kt-stat/kt-stat.js +1 -1
- package/dist/components/data/kt-table/kt-table.d.ts +53 -3
- package/dist/components/data/kt-table/kt-table.js +286 -131
- package/dist/components/data/kt-table/kt-table.js.map +1 -1
- package/dist/components/data/kt-table/window.d.ts +19 -0
- package/dist/components/data/kt-timeline/kt-timeline.js +1 -1
- package/dist/components/feedback/kt-alert/kt-alert.js +3 -3
- package/dist/components/feedback/kt-empty-state/kt-empty-state.js +1 -1
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js +10 -10
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js.map +1 -1
- package/dist/components/feedback/kt-skeleton/kt-skeleton.js +1 -1
- package/dist/components/feedback/kt-toast/kt-toast.js +58 -42
- package/dist/components/feedback/kt-toast/kt-toast.js.map +1 -1
- package/dist/components/feedback/kt-toast-container/kt-toast-container.js +1 -1
- package/dist/components/feedback/kt-tooltip/kt-tooltip.d.ts +20 -0
- package/dist/components/feedback/kt-tooltip/kt-tooltip.js +95 -51
- package/dist/components/feedback/kt-tooltip/kt-tooltip.js.map +1 -1
- package/dist/components/forms/kt-calendar/kt-calendar.d.ts +96 -0
- package/dist/components/forms/kt-calendar/kt-calendar.js +13 -0
- package/dist/components/forms/kt-calendar/kt-calendar.js.map +1 -0
- package/dist/components/forms/kt-checkbox/kt-checkbox.d.ts +9 -0
- package/dist/components/forms/kt-checkbox/kt-checkbox.js +34 -20
- package/dist/components/forms/kt-checkbox/kt-checkbox.js.map +1 -1
- package/dist/components/forms/kt-date-picker/kt-date-picker.d.ts +105 -0
- package/dist/components/forms/kt-date-picker/kt-date-picker.js +382 -0
- package/dist/components/forms/kt-date-picker/kt-date-picker.js.map +1 -0
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.d.ts +9 -0
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js +36 -22
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js.map +1 -1
- package/dist/components/forms/kt-form/kt-form.js +2 -2
- package/dist/components/forms/kt-input/kt-input.d.ts +37 -1
- package/dist/components/forms/kt-input/kt-input.js +380 -194
- package/dist/components/forms/kt-input/kt-input.js.map +1 -1
- package/dist/components/forms/kt-input-menu/kt-input-menu.d.ts +13 -0
- package/dist/components/forms/kt-input-menu/kt-input-menu.js +73 -42
- package/dist/components/forms/kt-input-menu/kt-input-menu.js.map +1 -1
- package/dist/components/forms/kt-label-input/kt-label-input.js +1 -1
- package/dist/components/forms/kt-radio-group/kt-radio-group.d.ts +9 -0
- package/dist/components/forms/kt-radio-group/kt-radio-group.js +67 -53
- package/dist/components/forms/kt-radio-group/kt-radio-group.js.map +1 -1
- package/dist/components/forms/kt-select/kt-select.d.ts +13 -0
- package/dist/components/forms/kt-select/kt-select.js +87 -56
- package/dist/components/forms/kt-select/kt-select.js.map +1 -1
- package/dist/components/forms/kt-textarea/kt-textarea.d.ts +9 -0
- package/dist/components/forms/kt-textarea/kt-textarea.js +28 -14
- package/dist/components/forms/kt-textarea/kt-textarea.js.map +1 -1
- package/dist/components/forms/kt-toggle/kt-toggle.d.ts +9 -0
- package/dist/components/forms/kt-toggle/kt-toggle.js +43 -29
- package/dist/components/forms/kt-toggle/kt-toggle.js.map +1 -1
- package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js +3 -3
- package/dist/components/navigation/kt-header/kt-header.js +3 -3
- package/dist/components/navigation/kt-page-header/kt-page-header.js +1 -1
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.d.ts +9 -0
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js +40 -22
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js.map +1 -1
- package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js +3 -3
- package/dist/components/navigation/kt-tabs/kt-tabs.js +2 -2
- package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js +2 -2
- package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js +3 -3
- package/dist/components/overlays/kt-collapsible/kt-collapsible.js +2 -2
- package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js +3 -3
- package/dist/components/overlays/kt-dropdown/kt-dropdown.d.ts +7 -5
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js +67 -57
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js.map +1 -1
- package/dist/components/overlays/kt-modal/kt-modal.js +3 -3
- package/dist/components/overlays/kt-side-panel/kt-side-panel.js +3 -3
- package/dist/custom-elements.json +2110 -124
- package/dist/icons/defaults.d.ts +1 -0
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +91 -87
- package/dist/index.js.map +1 -1
- package/dist/internal/countries.d.ts +24 -9
- package/dist/internal/date.d.ts +53 -0
- package/dist/internal/events.d.ts +5 -0
- package/dist/internal/floating.d.ts +48 -0
- package/dist/internal/form-control.d.ts +5 -1
- package/dist/internal/locale.d.ts +15 -0
- package/dist/internal/position.d.ts +27 -0
- package/dist/internal/strings.d.ts +15 -0
- package/dist/react/index.d.ts +12 -0
- package/dist/react/index.js +180 -166
- package/dist/react/index.js.map +1 -1
- package/dist/react/jsx.d.ts +11 -1
- package/dist/strings/index.js +1 -1
- package/dist/tokens/base.css +2 -0
- package/dist/tokens/responsive.css +1 -0
- package/dist/tokens/spacing.css +1 -0
- package/dist/vscode.css-custom-data.json +8 -0
- package/dist/vscode.html-custom-data.json +138 -11
- package/dist/vue/index.d.ts +4 -0
- package/dist/vue/index.js +9 -7
- package/dist/vue/index.js.map +1 -1
- package/dist/web-types.json +292 -14
- package/package.json +10 -1
- package/dist/chunks/events-Bjl5Zmmq.js +0 -18
- package/dist/chunks/form-control-CxjBTt1c.js.map +0 -1
- package/dist/chunks/index-DSSLJirw.js.map +0 -1
|
@@ -1,37 +1,61 @@
|
|
|
1
|
-
import { css as k,
|
|
2
|
-
import {
|
|
3
|
-
import { classMap as
|
|
4
|
-
import { styleMap as
|
|
5
|
-
import { K as
|
|
6
|
-
import { e as g } from "../../../chunks/events-
|
|
7
|
-
import {
|
|
1
|
+
import { css as k, nothing as d, html as c } from "lit";
|
|
2
|
+
import { property as l, state as f } from "lit/decorators.js";
|
|
3
|
+
import { classMap as S } from "lit/directives/class-map.js";
|
|
4
|
+
import { styleMap as w } from "lit/directives/style-map.js";
|
|
5
|
+
import { K as v, d as R } from "../../../chunks/kt-element-Djx2JcGl.js";
|
|
6
|
+
import { e as g } from "../../../chunks/events-r51msXNf.js";
|
|
7
|
+
import { r as M } from "../../../chunks/locale-C5xLkGx5.js";
|
|
8
|
+
import { s as u } from "../../../chunks/index-STEEvEP7.js";
|
|
9
|
+
import "../../core/kt-icon/kt-icon.js";
|
|
8
10
|
import "../kt-pagination/kt-pagination.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const H = 50;
|
|
12
|
+
function z({
|
|
13
|
+
rowCount: r,
|
|
14
|
+
rowHeight: t,
|
|
15
|
+
viewportHeight: e,
|
|
16
|
+
scrollTop: i,
|
|
17
|
+
overscan: s
|
|
18
|
+
}) {
|
|
19
|
+
if (r === 0) return { start: 0, end: 0 };
|
|
20
|
+
if (t <= 0) return { start: 0, end: Math.min(r, H) };
|
|
21
|
+
const h = Math.ceil(e / t), a = Math.min(Math.floor(i / t), Math.max(0, r - h)), p = Math.ceil((i + e) / t);
|
|
22
|
+
return {
|
|
23
|
+
start: Math.max(0, a - s),
|
|
24
|
+
end: Math.min(r, p + s)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var D = Object.defineProperty, n = (r, t, e, i) => {
|
|
28
|
+
for (var s = void 0, h = r.length - 1, a; h >= 0; h--)
|
|
29
|
+
(a = r[h]) && (s = a(t, e, s) || s);
|
|
30
|
+
return s && D(t, e, s), s;
|
|
13
31
|
};
|
|
14
|
-
const
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
const K = 8, x = /* @__PURE__ */ new Map();
|
|
33
|
+
function C(r) {
|
|
34
|
+
let t = x.get(r);
|
|
35
|
+
return t || (t = new Intl.Collator(r, { numeric: !0, sensitivity: "base" }), x.set(r, t)), t;
|
|
36
|
+
}
|
|
37
|
+
function $(r) {
|
|
38
|
+
if (typeof r == "string") return r;
|
|
39
|
+
if (typeof r == "number" || typeof r == "boolean" || typeof r == "bigint")
|
|
40
|
+
return String(r);
|
|
19
41
|
try {
|
|
20
|
-
return JSON.stringify(
|
|
42
|
+
return JSON.stringify(r) ?? "";
|
|
21
43
|
} catch {
|
|
22
44
|
return "";
|
|
23
45
|
}
|
|
24
46
|
}
|
|
25
|
-
function y(
|
|
26
|
-
return
|
|
47
|
+
function y(r) {
|
|
48
|
+
return r.id ?? r.uid ?? r;
|
|
27
49
|
}
|
|
28
|
-
class
|
|
50
|
+
class o extends v {
|
|
29
51
|
constructor() {
|
|
30
|
-
super(...arguments), this.page = 1, this.columns = [], this.data = [], this.selectable = !1, this.selectionMode = "multiple", this.selected = [], this.pageSize = 0, this.loading = !1, this.compact = !1, this.sortKey = null, this.sortDirection = null, this.emptyText = void 0, this.loadingText = void 0, this.label = ""
|
|
52
|
+
super(...arguments), this.page = 1, this.manual = !1, this.virtual = !1, this.scrollOffset = 0, this.viewportHeight = 0, this.headerHeight = 0, this.rowHeight = 0, this.totalRows = 0, this.columns = [], this.data = [], this.selectable = !1, this.selectionMode = "multiple", this.selected = [], this.pageSize = 0, this.loading = !1, this.compact = !1, this.sortKey = null, this.sortDirection = null, this.emptyText = void 0, this.loadingText = void 0, this.label = "", this.locale = "", this.onScroll = (t) => {
|
|
53
|
+
this.scrollOffset = t.currentTarget.scrollTop;
|
|
54
|
+
};
|
|
31
55
|
}
|
|
32
56
|
static {
|
|
33
57
|
this.styles = [
|
|
34
|
-
|
|
58
|
+
v.styles,
|
|
35
59
|
k`
|
|
36
60
|
:host {
|
|
37
61
|
display: block;
|
|
@@ -89,12 +113,17 @@ class r extends m {
|
|
|
89
113
|
}
|
|
90
114
|
|
|
91
115
|
.indicator {
|
|
116
|
+
display: inline-flex;
|
|
92
117
|
color: var(--color-primary-text);
|
|
93
|
-
font-size: 10px;
|
|
94
118
|
}
|
|
95
119
|
|
|
96
120
|
tbody tr {
|
|
97
|
-
transition: background-color
|
|
121
|
+
transition: background-color var(--duration-instant) linear;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
table[aria-busy='true'] tbody {
|
|
125
|
+
opacity: 0.5;
|
|
126
|
+
transition: opacity var(--duration-fast) var(--easing-standard);
|
|
98
127
|
}
|
|
99
128
|
|
|
100
129
|
tbody tr:hover {
|
|
@@ -114,6 +143,34 @@ class r extends m {
|
|
|
114
143
|
:host([compact]) td {
|
|
115
144
|
padding: 8px 12px;
|
|
116
145
|
}
|
|
146
|
+
|
|
147
|
+
/* === VIRTUAL ===
|
|
148
|
+
The table scrolls inside its own box, whose height the page sets,
|
|
149
|
+
and the header stays on top of the rows passing under it. */
|
|
150
|
+
:host([virtual]) {
|
|
151
|
+
display: flex;
|
|
152
|
+
flex-direction: column;
|
|
153
|
+
}
|
|
154
|
+
:host([virtual]) .scroller {
|
|
155
|
+
flex: 1;
|
|
156
|
+
min-height: 0;
|
|
157
|
+
}
|
|
158
|
+
:host([virtual]) thead th {
|
|
159
|
+
position: sticky;
|
|
160
|
+
top: 0;
|
|
161
|
+
z-index: 1;
|
|
162
|
+
background: var(--surface-card);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* Stand-ins for the rows above and below the window: height only. */
|
|
166
|
+
tbody tr.spacer,
|
|
167
|
+
tbody tr.spacer:hover {
|
|
168
|
+
background: none;
|
|
169
|
+
}
|
|
170
|
+
tr.spacer td {
|
|
171
|
+
padding: 0;
|
|
172
|
+
border: none;
|
|
173
|
+
}
|
|
117
174
|
:host([compact]) th {
|
|
118
175
|
padding: 10px 12px;
|
|
119
176
|
}
|
|
@@ -149,22 +206,45 @@ class r extends m {
|
|
|
149
206
|
`
|
|
150
207
|
];
|
|
151
208
|
}
|
|
152
|
-
/**
|
|
209
|
+
/**
|
|
210
|
+
* The rows after sorting, before paging.
|
|
211
|
+
*
|
|
212
|
+
* Sorted once per change of `data`, `sortKey`, `sortDirection` or locale, not on
|
|
213
|
+
* every render: hovering a row or ticking a box re-renders the table, and
|
|
214
|
+
* re-sorting a few thousand rows each time is what made that lag. Assign a
|
|
215
|
+
* new array to `data` rather than changing it in place.
|
|
216
|
+
*/
|
|
153
217
|
get sortedRows() {
|
|
218
|
+
if (this.manual) return this.data;
|
|
219
|
+
const t = this.sortCache, e = M(this.locale);
|
|
220
|
+
if (t?.data === this.data && t.key === this.sortKey && t.direction === this.sortDirection && t.locale === e)
|
|
221
|
+
return t.rows;
|
|
222
|
+
const i = this.sort(C(e));
|
|
223
|
+
return this.sortCache = {
|
|
224
|
+
data: this.data,
|
|
225
|
+
key: this.sortKey,
|
|
226
|
+
direction: this.sortDirection,
|
|
227
|
+
locale: e,
|
|
228
|
+
rows: i
|
|
229
|
+
}, i;
|
|
230
|
+
}
|
|
231
|
+
sort(t) {
|
|
154
232
|
if (!this.sortKey || !this.sortDirection) return this.data;
|
|
155
|
-
const
|
|
156
|
-
return [...this.data].sort((s,
|
|
157
|
-
const
|
|
158
|
-
return
|
|
233
|
+
const e = this.sortKey, i = this.sortDirection === "asc" ? 1 : -1;
|
|
234
|
+
return [...this.data].sort((s, h) => {
|
|
235
|
+
const a = s[e], p = h[e], b = a == null, m = p == null;
|
|
236
|
+
return b && m ? 0 : b ? 1 : m ? -1 : typeof a == "number" && typeof p == "number" ? (a - p) * i : t.compare($(a), $(p)) * i;
|
|
159
237
|
});
|
|
160
238
|
}
|
|
161
239
|
get totalPages() {
|
|
162
|
-
|
|
240
|
+
if (this.pageSize <= 0) return 1;
|
|
241
|
+
const t = this.manual ? this.totalRows || this.data.length : this.data.length;
|
|
242
|
+
return Math.max(1, Math.ceil(t / this.pageSize));
|
|
163
243
|
}
|
|
164
244
|
/** The rows actually on screen. */
|
|
165
245
|
get visibleRows() {
|
|
166
246
|
const t = this.sortedRows;
|
|
167
|
-
if (this.pageSize <= 0) return t;
|
|
247
|
+
if (this.pageSize <= 0 || this.manual) return t;
|
|
168
248
|
const e = Math.min(this.page, this.totalPages);
|
|
169
249
|
return t.slice((e - 1) * this.pageSize, e * this.pageSize);
|
|
170
250
|
}
|
|
@@ -173,24 +253,50 @@ class r extends m {
|
|
|
173
253
|
* press restoring the original order is what makes sorting undoable.
|
|
174
254
|
*/
|
|
175
255
|
toggleSort(t) {
|
|
176
|
-
t.sortable && (this.sortKey !== t.key ? (this.sortKey = t.key, this.sortDirection = "asc") : this.sortDirection === "asc" ? this.sortDirection = "desc" : (this.sortKey = null, this.sortDirection = null), g(this, "kt-sort-change", { key: this.sortKey, direction: this.sortDirection }));
|
|
256
|
+
t.sortable && (this.sortKey !== t.key ? (this.sortKey = t.key, this.sortDirection = "asc") : this.sortDirection === "asc" ? this.sortDirection = "desc" : (this.sortKey = null, this.sortDirection = null), this.manual && (this.page = 1), g(this, "kt-sort-change", { key: this.sortKey, direction: this.sortDirection }));
|
|
177
257
|
}
|
|
178
258
|
isSelected(t) {
|
|
179
259
|
return this.selected.includes(y(t));
|
|
180
260
|
}
|
|
181
261
|
toggleSelection(t) {
|
|
182
262
|
const e = y(t);
|
|
183
|
-
this.selectionMode === "single" ? this.selected = this.isSelected(t) ? [] : [e] : this.selected = this.isSelected(t) ? this.selected.filter((
|
|
263
|
+
this.selectionMode === "single" ? this.selected = this.isSelected(t) ? [] : [e] : this.selected = this.isSelected(t) ? this.selected.filter((i) => i !== e) : [...this.selected, e], g(this, "kt-selection-change", { selected: this.selected, rows: this.selectedRows });
|
|
184
264
|
}
|
|
185
265
|
/** Selects or clears every row on the current page. */
|
|
186
266
|
toggleAll() {
|
|
187
|
-
const e = this.visibleRows.map(y),
|
|
188
|
-
this.selected =
|
|
267
|
+
const e = this.visibleRows.map(y), i = e.every((s) => this.selected.includes(s));
|
|
268
|
+
this.selected = i ? this.selected.filter((s) => !e.includes(s)) : [.../* @__PURE__ */ new Set([...this.selected, ...e])], g(this, "kt-selection-change", { selected: this.selected, rows: this.selectedRows });
|
|
189
269
|
}
|
|
190
270
|
/** The selected rows themselves, not just their identities. */
|
|
191
271
|
get selectedRows() {
|
|
192
272
|
return this.data.filter((t) => this.selected.includes(y(t)));
|
|
193
273
|
}
|
|
274
|
+
/** Virtual rendering, unless a page size pages the rows instead. */
|
|
275
|
+
get isVirtual() {
|
|
276
|
+
return this.virtual && this.pageSize <= 0;
|
|
277
|
+
}
|
|
278
|
+
// Untyped: the measurements are private, so not among PropertyValues<this>.
|
|
279
|
+
updated(t) {
|
|
280
|
+
if (t.has("compact") && (this.rowHeight = 0), !this.isVirtual) {
|
|
281
|
+
this.observe(void 0);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const e = this.shadowRoot?.querySelector(".scroller") ?? void 0;
|
|
285
|
+
this.observe(e);
|
|
286
|
+
const i = this.shadowRoot?.querySelector('tbody tr[part="row"]');
|
|
287
|
+
i && this.rowHeight === 0 && (this.rowHeight = i.getBoundingClientRect().height);
|
|
288
|
+
const s = this.shadowRoot?.querySelector("thead");
|
|
289
|
+
s && (this.headerHeight = s.getBoundingClientRect().height), e && (this.viewportHeight = e.clientHeight);
|
|
290
|
+
}
|
|
291
|
+
disconnectedCallback() {
|
|
292
|
+
super.disconnectedCallback(), this.observe(void 0);
|
|
293
|
+
}
|
|
294
|
+
/** Follows the scroller's height, which the page can change at any time. */
|
|
295
|
+
observe(t) {
|
|
296
|
+
t !== this.observed && (this.resizeObserver?.disconnect(), this.observed = t, !(!t || typeof ResizeObserver > "u") && (this.resizeObserver ??= new ResizeObserver(([e]) => {
|
|
297
|
+
e && (this.viewportHeight = e.target.clientHeight);
|
|
298
|
+
}), this.resizeObserver.observe(t)));
|
|
299
|
+
}
|
|
194
300
|
onPageChange(t) {
|
|
195
301
|
t.stopPropagation(), this.page = t.detail.page, g(this, "kt-page-change", { page: this.page });
|
|
196
302
|
}
|
|
@@ -204,74 +310,99 @@ class r extends m {
|
|
|
204
310
|
return this.sortKey !== t.key || !this.sortDirection ? "none" : this.sortDirection === "asc" ? "ascending" : "descending";
|
|
205
311
|
}
|
|
206
312
|
renderHeaderCell(t) {
|
|
207
|
-
const e = t.label ?? t.key,
|
|
208
|
-
return
|
|
313
|
+
const e = t.label ?? t.key, i = this.sortKey === t.key && this.sortDirection !== null;
|
|
314
|
+
return c`<th
|
|
209
315
|
part="header-cell"
|
|
210
316
|
scope="col"
|
|
211
|
-
style=${
|
|
317
|
+
style=${w(t.width ? { width: t.width } : {})}
|
|
212
318
|
aria-sort=${this.sortStateFor(t)}
|
|
213
319
|
>
|
|
214
|
-
${t.sortable ?
|
|
320
|
+
${t.sortable ? c`<button type="button" @click=${() => this.toggleSort(t)}>
|
|
215
321
|
<span>${e}</span>
|
|
216
|
-
<span class="indicator" aria-hidden="true"
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
322
|
+
<span class="indicator" aria-hidden="true">
|
|
323
|
+
${i ? c`<kt-icon
|
|
324
|
+
name=${this.sortDirection === "asc" ? "arrow-up" : "arrow-down"}
|
|
325
|
+
size="14"
|
|
326
|
+
></kt-icon>` : d}
|
|
327
|
+
</span>
|
|
328
|
+
</button>` : c`<span>${e}</span>`}
|
|
220
329
|
</th>`;
|
|
221
330
|
}
|
|
222
331
|
renderBody() {
|
|
223
332
|
const t = this.visibleRows, e = this.columns.length + (this.selectable ? 1 : 0);
|
|
224
|
-
|
|
333
|
+
if (t.length === 0)
|
|
334
|
+
return c`<tr>
|
|
225
335
|
<td colspan=${e}>
|
|
226
336
|
<div class="placeholder">${this.emptyText ?? u().noData}</div>
|
|
227
337
|
</td>
|
|
228
|
-
</tr>` : d`${t.map((s, i) => {
|
|
229
|
-
const c = this.isSelected(s);
|
|
230
|
-
return d`<tr
|
|
231
|
-
part="row"
|
|
232
|
-
class=${v({ selected: c })}
|
|
233
|
-
aria-selected=${this.selectable ? String(c) : h}
|
|
234
|
-
@click=${() => g(this, "kt-row-click", { row: s, index: i })}
|
|
235
|
-
>
|
|
236
|
-
${this.selectable ? d`<td class="select-cell">
|
|
237
|
-
<input
|
|
238
|
-
type=${this.selectionMode === "single" ? "radio" : "checkbox"}
|
|
239
|
-
name=${this.selectionMode === "single" ? "kt-table-selection" : h}
|
|
240
|
-
.checked=${c}
|
|
241
|
-
aria-label=${u().selectRow}
|
|
242
|
-
@click=${(l) => l.stopPropagation()}
|
|
243
|
-
@change=${() => this.toggleSelection(s)}
|
|
244
|
-
/>
|
|
245
|
-
</td>` : h}
|
|
246
|
-
${this.columns.map((l) => {
|
|
247
|
-
const p = this.renderCell?.(s, l);
|
|
248
|
-
return d`<td part="cell" style=${f({ textAlign: l.align ?? "left" })}>
|
|
249
|
-
${p === void 0 ? s[l.key] : p}
|
|
250
|
-
</td>`;
|
|
251
|
-
})}
|
|
252
338
|
</tr>`;
|
|
253
|
-
|
|
339
|
+
if (!this.isVirtual)
|
|
340
|
+
return c`${t.map((a, p) => this.renderRow(a, p))}`;
|
|
341
|
+
const { start: i, end: s } = z({
|
|
342
|
+
rowCount: t.length,
|
|
343
|
+
rowHeight: this.rowHeight,
|
|
344
|
+
viewportHeight: Math.max(0, this.viewportHeight - this.headerHeight),
|
|
345
|
+
scrollTop: Math.max(0, this.scrollOffset - this.headerHeight),
|
|
346
|
+
overscan: K
|
|
347
|
+
}), h = (a) => a > 0 && this.rowHeight > 0 ? c`<tr class="spacer" aria-hidden="true">
|
|
348
|
+
<td colspan=${e} style=${`height: ${a * this.rowHeight}px`}></td>
|
|
349
|
+
</tr>` : d;
|
|
350
|
+
return c`${h(i)}${t.slice(i, s).map((a, p) => this.renderRow(a, i + p))}${h(t.length - s)}`;
|
|
351
|
+
}
|
|
352
|
+
/** `index` counts from the first row of the data, not of the rows rendered. */
|
|
353
|
+
renderRow(t, e) {
|
|
354
|
+
const i = this.isSelected(t);
|
|
355
|
+
return c`<tr
|
|
356
|
+
part="row"
|
|
357
|
+
class=${S({ selected: i })}
|
|
358
|
+
aria-selected=${this.selectable ? String(i) : d}
|
|
359
|
+
aria-rowindex=${this.isVirtual ? e + 2 : d}
|
|
360
|
+
@click=${() => g(this, "kt-row-click", { row: t, index: e })}
|
|
361
|
+
>
|
|
362
|
+
${this.selectable ? c`<td class="select-cell">
|
|
363
|
+
<input
|
|
364
|
+
type=${this.selectionMode === "single" ? "radio" : "checkbox"}
|
|
365
|
+
name=${this.selectionMode === "single" ? "kt-table-selection" : d}
|
|
366
|
+
.checked=${i}
|
|
367
|
+
aria-label=${u().selectRow}
|
|
368
|
+
@click=${(s) => s.stopPropagation()}
|
|
369
|
+
@change=${() => this.toggleSelection(t)}
|
|
370
|
+
/>
|
|
371
|
+
</td>` : d}
|
|
372
|
+
${this.columns.map((s) => {
|
|
373
|
+
const h = this.renderCell?.(t, s);
|
|
374
|
+
return c`<td part="cell" style=${w({ textAlign: s.align ?? "left" })}>
|
|
375
|
+
${h === void 0 ? t[s.key] : h}
|
|
376
|
+
</td>`;
|
|
377
|
+
})}
|
|
378
|
+
</tr>`;
|
|
254
379
|
}
|
|
255
380
|
render() {
|
|
256
|
-
|
|
257
|
-
|
|
381
|
+
const t = this.loading && this.manual && this.data.length > 0;
|
|
382
|
+
if (this.loading && !t)
|
|
383
|
+
return c`<div class="placeholder" role="status" aria-live="polite">
|
|
258
384
|
${this.loadingText ?? u().loading}
|
|
259
385
|
</div>`;
|
|
260
|
-
const
|
|
261
|
-
return
|
|
262
|
-
<table
|
|
386
|
+
const e = this.visibleRows, i = e.length > 0 && e.every((a) => this.isSelected(a)), s = e.some((a) => this.isSelected(a)), h = this.isVirtual;
|
|
387
|
+
return c`<div class="scroller" @scroll=${h ? this.onScroll : d}>
|
|
388
|
+
<table
|
|
389
|
+
part="table"
|
|
390
|
+
aria-label=${this.label || d}
|
|
391
|
+
aria-busy=${t ? "true" : d}
|
|
392
|
+
aria-rowcount=${h ? e.length + 1 : d}
|
|
393
|
+
>
|
|
263
394
|
<thead>
|
|
264
|
-
<tr>
|
|
265
|
-
${this.selectable ?
|
|
266
|
-
${this.selectionMode === "multiple" ?
|
|
395
|
+
<tr aria-rowindex=${h ? 1 : d}>
|
|
396
|
+
${this.selectable ? c`<th class="select-cell" scope="col">
|
|
397
|
+
${this.selectionMode === "multiple" ? c`<input
|
|
267
398
|
type="checkbox"
|
|
268
|
-
.checked=${
|
|
269
|
-
.indeterminate=${s && !
|
|
399
|
+
.checked=${i}
|
|
400
|
+
.indeterminate=${s && !i}
|
|
270
401
|
aria-label=${u().selectAll}
|
|
271
402
|
@change=${this.toggleAll}
|
|
272
|
-
/>` :
|
|
273
|
-
</th>` :
|
|
274
|
-
${this.columns.map((
|
|
403
|
+
/>` : d}
|
|
404
|
+
</th>` : d}
|
|
405
|
+
${this.columns.map((a) => this.renderHeaderCell(a))}
|
|
275
406
|
</tr>
|
|
276
407
|
</thead>
|
|
277
408
|
<tbody>
|
|
@@ -280,62 +411,86 @@ class r extends m {
|
|
|
280
411
|
</table>
|
|
281
412
|
</div>
|
|
282
413
|
|
|
283
|
-
${this.pageSize > 0 ?
|
|
414
|
+
${this.pageSize > 0 ? c`<footer>
|
|
284
415
|
<kt-pagination
|
|
285
416
|
.page=${Math.min(this.page, this.totalPages)}
|
|
286
417
|
.totalPages=${this.totalPages}
|
|
287
418
|
@kt-page-change=${this.onPageChange}
|
|
288
419
|
></kt-pagination>
|
|
289
|
-
</footer>` :
|
|
420
|
+
</footer>` : d}`;
|
|
290
421
|
}
|
|
291
422
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
],
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
],
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
],
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
],
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
],
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
],
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
],
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
],
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
],
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
],
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
],
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
],
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
],
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
],
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
],
|
|
337
|
-
|
|
423
|
+
n([
|
|
424
|
+
l({ type: Number })
|
|
425
|
+
], o.prototype, "page");
|
|
426
|
+
n([
|
|
427
|
+
l({ type: Boolean, reflect: !0 })
|
|
428
|
+
], o.prototype, "manual");
|
|
429
|
+
n([
|
|
430
|
+
l({ type: Boolean, reflect: !0 })
|
|
431
|
+
], o.prototype, "virtual");
|
|
432
|
+
n([
|
|
433
|
+
f()
|
|
434
|
+
], o.prototype, "scrollOffset");
|
|
435
|
+
n([
|
|
436
|
+
f()
|
|
437
|
+
], o.prototype, "viewportHeight");
|
|
438
|
+
n([
|
|
439
|
+
f()
|
|
440
|
+
], o.prototype, "headerHeight");
|
|
441
|
+
n([
|
|
442
|
+
f()
|
|
443
|
+
], o.prototype, "rowHeight");
|
|
444
|
+
n([
|
|
445
|
+
l({ type: Number, attribute: "total-rows" })
|
|
446
|
+
], o.prototype, "totalRows");
|
|
447
|
+
n([
|
|
448
|
+
l({ attribute: !1 })
|
|
449
|
+
], o.prototype, "columns");
|
|
450
|
+
n([
|
|
451
|
+
l({ attribute: !1 })
|
|
452
|
+
], o.prototype, "data");
|
|
453
|
+
n([
|
|
454
|
+
l({ type: Boolean, reflect: !0 })
|
|
455
|
+
], o.prototype, "selectable");
|
|
456
|
+
n([
|
|
457
|
+
l({ type: String, attribute: "selection-mode" })
|
|
458
|
+
], o.prototype, "selectionMode");
|
|
459
|
+
n([
|
|
460
|
+
l({ attribute: !1 })
|
|
461
|
+
], o.prototype, "selected");
|
|
462
|
+
n([
|
|
463
|
+
l({ type: Number, attribute: "page-size" })
|
|
464
|
+
], o.prototype, "pageSize");
|
|
465
|
+
n([
|
|
466
|
+
l({ type: Boolean, reflect: !0 })
|
|
467
|
+
], o.prototype, "loading");
|
|
468
|
+
n([
|
|
469
|
+
l({ type: Boolean, reflect: !0 })
|
|
470
|
+
], o.prototype, "compact");
|
|
471
|
+
n([
|
|
472
|
+
l({ type: String, attribute: "sort-key" })
|
|
473
|
+
], o.prototype, "sortKey");
|
|
474
|
+
n([
|
|
475
|
+
l({ type: String, attribute: "sort-direction" })
|
|
476
|
+
], o.prototype, "sortDirection");
|
|
477
|
+
n([
|
|
478
|
+
l({ attribute: !1 })
|
|
479
|
+
], o.prototype, "renderCell");
|
|
480
|
+
n([
|
|
481
|
+
l({ type: String, attribute: "empty-text" })
|
|
482
|
+
], o.prototype, "emptyText");
|
|
483
|
+
n([
|
|
484
|
+
l({ type: String, attribute: "loading-text" })
|
|
485
|
+
], o.prototype, "loadingText");
|
|
486
|
+
n([
|
|
487
|
+
l({ type: String })
|
|
488
|
+
], o.prototype, "label");
|
|
489
|
+
n([
|
|
490
|
+
l({ type: String })
|
|
491
|
+
], o.prototype, "locale");
|
|
492
|
+
R("kt-table", o);
|
|
338
493
|
export {
|
|
339
|
-
|
|
494
|
+
o as KtTable
|
|
340
495
|
};
|
|
341
496
|
//# sourceMappingURL=kt-table.js.map
|