@deepfuture/dui-components 0.0.12 → 0.0.14
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/_deprecated/center/center.js +2 -2
- package/_deprecated/hstack/hstack.js +79 -33
- package/_deprecated/page-inset/page-inset.js +104 -56
- package/_deprecated/vstack/vstack.js +61 -19
- package/accordion/accordion-item.js +217 -147
- package/accordion/accordion.js +214 -149
- package/alert-dialog/alert-dialog-close.js +2 -2
- package/alert-dialog/alert-dialog-popup.js +230 -166
- package/alert-dialog/alert-dialog-trigger.js +2 -2
- package/alert-dialog/alert-dialog.js +128 -73
- package/avatar/avatar.js +175 -115
- package/badge/badge.js +2 -2
- package/breadcrumb/breadcrumb-ellipsis.js +2 -2
- package/breadcrumb/breadcrumb-item.js +2 -2
- package/breadcrumb/breadcrumb-link.js +2 -2
- package/breadcrumb/breadcrumb-page.js +2 -2
- package/breadcrumb/breadcrumb-separator.js +2 -2
- package/breadcrumb/breadcrumb.js +2 -2
- package/button/button.js +109 -65
- package/calendar/calendar.js +368 -290
- package/checkbox/checkbox-group.js +146 -87
- package/checkbox/checkbox.js +232 -167
- package/collapsible/collapsible.js +210 -132
- package/combobox/combobox.js +318 -252
- package/command/command-empty.js +67 -25
- package/command/command-group.js +87 -47
- package/command/command-input.js +84 -44
- package/command/command-item.js +168 -124
- package/command/command-list.js +60 -18
- package/command/command-separator.js +2 -2
- package/command/command-shortcut.js +2 -2
- package/command/command.js +297 -232
- package/data-table/data-table.js +225 -153
- package/dialog/dialog-close.js +2 -2
- package/dialog/dialog-popup.js +247 -181
- package/dialog/dialog-trigger.js +2 -2
- package/dialog/dialog.js +128 -73
- package/dropzone/dropzone.js +310 -249
- package/icon/icon.js +2 -2
- package/input/input.js +204 -143
- package/link/link.js +62 -24
- package/menu/menu-item.js +66 -24
- package/menu/menu.js +189 -136
- package/menubar/menubar.js +142 -91
- package/number-field/number-field.js +277 -204
- package/package.json +2 -3
- package/popover/popover-close.js +2 -2
- package/popover/popover-popup.js +126 -76
- package/popover/popover-trigger.js +2 -2
- package/popover/popover.js +181 -120
- package/portal/portal.js +128 -86
- package/preview-card/preview-card-popup.js +114 -66
- package/preview-card/preview-card-trigger.js +2 -2
- package/preview-card/preview-card.js +211 -142
- package/progress/progress.js +91 -45
- package/radio/radio-group.js +153 -90
- package/radio/radio.js +137 -94
- package/scroll-area/scroll-area.js +382 -283
- package/select/select.js +260 -203
- package/separator/separator.js +60 -18
- package/sidebar/sidebar-content.js +2 -2
- package/sidebar/sidebar-footer.js +2 -2
- package/sidebar/sidebar-group-label.js +2 -2
- package/sidebar/sidebar-group.js +2 -2
- package/sidebar/sidebar-header.js +2 -2
- package/sidebar/sidebar-inset.js +2 -2
- package/sidebar/sidebar-menu-button.js +118 -74
- package/sidebar/sidebar-menu-item.js +2 -2
- package/sidebar/sidebar-menu.js +2 -2
- package/sidebar/sidebar-provider.js +202 -129
- package/sidebar/sidebar-separator.js +2 -2
- package/sidebar/sidebar-trigger.js +2 -2
- package/sidebar/sidebar.js +150 -85
- package/slider/slider.js +217 -159
- package/spinner/spinner.js +70 -28
- package/switch/switch.js +174 -111
- package/tabs/tab.js +89 -47
- package/tabs/tabs-indicator.js +2 -2
- package/tabs/tabs-list.js +92 -54
- package/tabs/tabs-panel.js +90 -44
- package/tabs/tabs.js +130 -71
- package/textarea/textarea.js +153 -95
- package/toggle/toggle-group.js +184 -125
- package/toggle/toggle.js +131 -76
- package/toolbar/toolbar.js +79 -33
- package/tooltip/tooltip-popup.js +108 -60
- package/tooltip/tooltip-trigger.js +93 -55
- package/tooltip/tooltip.js +225 -154
- package/trunc/trunc.js +78 -34
package/data-table/data-table.js
CHANGED
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
/** Ported from original DUI: deep-future-app/app/client/components/dui/data-table */
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
7
39
|
};
|
|
8
40
|
import { css, html, LitElement, nothing } from "lit";
|
|
9
|
-
import { property } from "lit/decorators.js";
|
|
41
|
+
import { property, state } from "lit/decorators.js";
|
|
10
42
|
import { repeat } from "lit/directives/repeat.js";
|
|
11
43
|
import { styleMap } from "lit/directives/style-map.js";
|
|
12
44
|
import { base } from "@deepfuture/dui-core/base";
|
|
@@ -174,173 +206,222 @@ const componentStyles = css `
|
|
|
174
206
|
* @fires sort-change - Fired when a sortable column header is clicked. Detail: SortState
|
|
175
207
|
* @fires page-change - Fired when the page changes. Detail: PageState
|
|
176
208
|
*/
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
209
|
+
let DuiDataTable = (() => {
|
|
210
|
+
let _classSuper = LitElement;
|
|
211
|
+
let _columns_decorators;
|
|
212
|
+
let _columns_initializers = [];
|
|
213
|
+
let _columns_extraInitializers = [];
|
|
214
|
+
let _data_decorators;
|
|
215
|
+
let _data_initializers = [];
|
|
216
|
+
let _data_extraInitializers = [];
|
|
217
|
+
let _pageSize_decorators;
|
|
218
|
+
let _pageSize_initializers = [];
|
|
219
|
+
let _pageSize_extraInitializers = [];
|
|
220
|
+
let _rowKey_decorators;
|
|
221
|
+
let _rowKey_initializers = [];
|
|
222
|
+
let _rowKey_extraInitializers = [];
|
|
223
|
+
let _emptyText_decorators;
|
|
224
|
+
let _emptyText_initializers = [];
|
|
225
|
+
let _emptyText_extraInitializers = [];
|
|
226
|
+
let _private_sort_decorators;
|
|
227
|
+
let _private_sort_initializers = [];
|
|
228
|
+
let _private_sort_extraInitializers = [];
|
|
229
|
+
let _private_sort_descriptor;
|
|
230
|
+
let _private_page_decorators;
|
|
231
|
+
let _private_page_initializers = [];
|
|
232
|
+
let _private_page_extraInitializers = [];
|
|
233
|
+
let _private_page_descriptor;
|
|
234
|
+
let _private_displayRows_decorators;
|
|
235
|
+
let _private_displayRows_initializers = [];
|
|
236
|
+
let _private_displayRows_extraInitializers = [];
|
|
237
|
+
let _private_displayRows_descriptor;
|
|
238
|
+
return class DuiDataTable extends _classSuper {
|
|
239
|
+
static {
|
|
240
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
241
|
+
_columns_decorators = [property({ attribute: false })];
|
|
242
|
+
_data_decorators = [property({ attribute: false })];
|
|
243
|
+
_pageSize_decorators = [property({ type: Number, attribute: "page-size" })];
|
|
244
|
+
_rowKey_decorators = [property({ attribute: false })];
|
|
245
|
+
_emptyText_decorators = [property({ attribute: "empty-text" })];
|
|
246
|
+
_private_sort_decorators = [state()];
|
|
247
|
+
_private_page_decorators = [state()];
|
|
248
|
+
_private_displayRows_decorators = [state()];
|
|
249
|
+
__esDecorate(this, null, _columns_decorators, { kind: "accessor", name: "columns", static: false, private: false, access: { has: obj => "columns" in obj, get: obj => obj.columns, set: (obj, value) => { obj.columns = value; } }, metadata: _metadata }, _columns_initializers, _columns_extraInitializers);
|
|
250
|
+
__esDecorate(this, null, _data_decorators, { kind: "accessor", name: "data", static: false, private: false, access: { has: obj => "data" in obj, get: obj => obj.data, set: (obj, value) => { obj.data = value; } }, metadata: _metadata }, _data_initializers, _data_extraInitializers);
|
|
251
|
+
__esDecorate(this, null, _pageSize_decorators, { kind: "accessor", name: "pageSize", static: false, private: false, access: { has: obj => "pageSize" in obj, get: obj => obj.pageSize, set: (obj, value) => { obj.pageSize = value; } }, metadata: _metadata }, _pageSize_initializers, _pageSize_extraInitializers);
|
|
252
|
+
__esDecorate(this, null, _rowKey_decorators, { kind: "accessor", name: "rowKey", static: false, private: false, access: { has: obj => "rowKey" in obj, get: obj => obj.rowKey, set: (obj, value) => { obj.rowKey = value; } }, metadata: _metadata }, _rowKey_initializers, _rowKey_extraInitializers);
|
|
253
|
+
__esDecorate(this, null, _emptyText_decorators, { kind: "accessor", name: "emptyText", static: false, private: false, access: { has: obj => "emptyText" in obj, get: obj => obj.emptyText, set: (obj, value) => { obj.emptyText = value; } }, metadata: _metadata }, _emptyText_initializers, _emptyText_extraInitializers);
|
|
254
|
+
__esDecorate(this, _private_sort_descriptor = { get: __setFunctionName(function () { return this.#sort_accessor_storage; }, "#sort", "get"), set: __setFunctionName(function (value) { this.#sort_accessor_storage = value; }, "#sort", "set") }, _private_sort_decorators, { kind: "accessor", name: "#sort", static: false, private: true, access: { has: obj => #sort in obj, get: obj => obj.#sort, set: (obj, value) => { obj.#sort = value; } }, metadata: _metadata }, _private_sort_initializers, _private_sort_extraInitializers);
|
|
255
|
+
__esDecorate(this, _private_page_descriptor = { get: __setFunctionName(function () { return this.#page_accessor_storage; }, "#page", "get"), set: __setFunctionName(function (value) { this.#page_accessor_storage = value; }, "#page", "set") }, _private_page_decorators, { kind: "accessor", name: "#page", static: false, private: true, access: { has: obj => #page in obj, get: obj => obj.#page, set: (obj, value) => { obj.#page = value; } }, metadata: _metadata }, _private_page_initializers, _private_page_extraInitializers);
|
|
256
|
+
__esDecorate(this, _private_displayRows_descriptor = { get: __setFunctionName(function () { return this.#displayRows_accessor_storage; }, "#displayRows", "get"), set: __setFunctionName(function (value) { this.#displayRows_accessor_storage = value; }, "#displayRows", "set") }, _private_displayRows_decorators, { kind: "accessor", name: "#displayRows", static: false, private: true, access: { has: obj => #displayRows in obj, get: obj => obj.#displayRows, set: (obj, value) => { obj.#displayRows = value; } }, metadata: _metadata }, _private_displayRows_initializers, _private_displayRows_extraInitializers);
|
|
257
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
258
|
+
}
|
|
259
|
+
static tagName = "dui-data-table";
|
|
260
|
+
static styles = [base, hostStyles, componentStyles];
|
|
261
|
+
#columns_accessor_storage = __runInitializers(this, _columns_initializers, []);
|
|
262
|
+
/** Column definitions describing each visible column. */
|
|
263
|
+
get columns() { return this.#columns_accessor_storage; }
|
|
264
|
+
set columns(value) { this.#columns_accessor_storage = value; }
|
|
265
|
+
#data_accessor_storage = (__runInitializers(this, _columns_extraInitializers), __runInitializers(this, _data_initializers, []));
|
|
266
|
+
/** The full data array. Sorting and pagination are applied internally. */
|
|
267
|
+
get data() { return this.#data_accessor_storage; }
|
|
268
|
+
set data(value) { this.#data_accessor_storage = value; }
|
|
269
|
+
#pageSize_accessor_storage = (__runInitializers(this, _data_extraInitializers), __runInitializers(this, _pageSize_initializers, 10));
|
|
270
|
+
/** Number of rows per page. Set to 0 to disable pagination. */
|
|
271
|
+
get pageSize() { return this.#pageSize_accessor_storage; }
|
|
272
|
+
set pageSize(value) { this.#pageSize_accessor_storage = value; }
|
|
273
|
+
#rowKey_accessor_storage = (__runInitializers(this, _pageSize_extraInitializers), __runInitializers(this, _rowKey_initializers, undefined));
|
|
274
|
+
/** Key function to derive a unique identifier from each row. */
|
|
275
|
+
get rowKey() { return this.#rowKey_accessor_storage; }
|
|
276
|
+
set rowKey(value) { this.#rowKey_accessor_storage = value; }
|
|
277
|
+
#emptyText_accessor_storage = (__runInitializers(this, _rowKey_extraInitializers), __runInitializers(this, _emptyText_initializers, "No results."));
|
|
278
|
+
/** Text shown when the data array is empty. */
|
|
279
|
+
get emptyText() { return this.#emptyText_accessor_storage; }
|
|
280
|
+
set emptyText(value) { this.#emptyText_accessor_storage = value; }
|
|
281
|
+
#sort_accessor_storage = (__runInitializers(this, _emptyText_extraInitializers), __runInitializers(this, _private_sort_initializers, null));
|
|
282
|
+
get #sort() { return _private_sort_descriptor.get.call(this); }
|
|
283
|
+
set #sort(value) { return _private_sort_descriptor.set.call(this, value); }
|
|
284
|
+
#page_accessor_storage = (__runInitializers(this, _private_sort_extraInitializers), __runInitializers(this, _private_page_initializers, 1));
|
|
285
|
+
get #page() { return _private_page_descriptor.get.call(this); }
|
|
286
|
+
set #page(value) { return _private_page_descriptor.set.call(this, value); }
|
|
287
|
+
#displayRows_accessor_storage = (__runInitializers(this, _private_page_extraInitializers), __runInitializers(this, _private_displayRows_initializers, []));
|
|
288
|
+
get #displayRows() { return _private_displayRows_descriptor.get.call(this); }
|
|
289
|
+
set #displayRows(value) { return _private_displayRows_descriptor.set.call(this, value); }
|
|
290
|
+
// ── Lifecycle ──────────────────────────────────────────────────────
|
|
291
|
+
willUpdate(changed) {
|
|
292
|
+
// Recompute display rows when data, sort, page, or pageSize change.
|
|
293
|
+
if (changed.has("data") ||
|
|
294
|
+
changed.has("pageSize") ||
|
|
295
|
+
changed.has("#sort") ||
|
|
296
|
+
changed.has("#page")) {
|
|
297
|
+
// Reset page when data changes.
|
|
298
|
+
if (changed.has("data")) {
|
|
299
|
+
this.#page = 1;
|
|
300
|
+
}
|
|
301
|
+
const sorted = sortData(this.data, this.#sort);
|
|
302
|
+
if (this.pageSize > 0) {
|
|
303
|
+
this.#displayRows = paginateData(sorted, this.#page, this.pageSize);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
this.#displayRows = sorted;
|
|
307
|
+
}
|
|
226
308
|
}
|
|
227
309
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return 1;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
310
|
+
// ── Computed ───────────────────────────────────────────────────────
|
|
311
|
+
get #totalPages() {
|
|
312
|
+
if (this.pageSize <= 0)
|
|
313
|
+
return 1;
|
|
314
|
+
return Math.max(1, Math.ceil(this.data.length / this.pageSize));
|
|
315
|
+
}
|
|
316
|
+
get #pageState() {
|
|
317
|
+
return {
|
|
318
|
+
page: this.#page,
|
|
319
|
+
pageSize: this.pageSize,
|
|
320
|
+
totalRows: this.data.length,
|
|
321
|
+
totalPages: this.#totalPages,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
// ── Sort handling ─────────────────────────────────────────────────
|
|
325
|
+
#handleSort(column) {
|
|
326
|
+
if (this.#sort?.column === column) {
|
|
327
|
+
if (this.#sort.direction === "asc") {
|
|
328
|
+
this.#sort = { column, direction: "desc" };
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
// desc → clear
|
|
332
|
+
this.#sort = null;
|
|
333
|
+
}
|
|
248
334
|
}
|
|
249
335
|
else {
|
|
250
|
-
|
|
251
|
-
this.#sort = null;
|
|
336
|
+
this.#sort = { column, direction: "asc" };
|
|
252
337
|
}
|
|
338
|
+
this.#page = 1;
|
|
339
|
+
this.dispatchEvent(sortChangeEvent(this.#sort));
|
|
253
340
|
}
|
|
254
|
-
|
|
255
|
-
|
|
341
|
+
// ── Pagination handling ───────────────────────────────────────────
|
|
342
|
+
#goToPage(page) {
|
|
343
|
+
this.#page = Math.max(1, Math.min(page, this.#totalPages));
|
|
344
|
+
this.dispatchEvent(pageChangeEvent(this.#pageState));
|
|
256
345
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this.dispatchEvent(pageChangeEvent(this.#pageState));
|
|
264
|
-
}
|
|
265
|
-
// ── Render ────────────────────────────────────────────────────────
|
|
266
|
-
#renderSortIcon(column) {
|
|
267
|
-
if (!column.sortable)
|
|
268
|
-
return nothing;
|
|
269
|
-
if (this.#sort?.column === column.key) {
|
|
270
|
-
return html `<span class="SortIcon"
|
|
346
|
+
// ── Render ────────────────────────────────────────────────────────
|
|
347
|
+
#renderSortIcon(column) {
|
|
348
|
+
if (!column.sortable)
|
|
349
|
+
return nothing;
|
|
350
|
+
if (this.#sort?.column === column.key) {
|
|
351
|
+
return html `<span class="SortIcon"
|
|
271
352
|
>${this.#sort.direction === "asc" ? chevronUp : chevronDown}</span
|
|
272
353
|
>`;
|
|
354
|
+
}
|
|
355
|
+
return html `<span class="SortIcon">${chevronUpDown}</span>`;
|
|
273
356
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
#renderHeader() {
|
|
277
|
-
return html `
|
|
357
|
+
#renderHeader() {
|
|
358
|
+
return html `
|
|
278
359
|
<thead>
|
|
279
360
|
<tr>
|
|
280
361
|
${this.columns.map((col) => {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
362
|
+
const style = col.width ? { width: col.width } : {};
|
|
363
|
+
const sortAttr = col.sortable
|
|
364
|
+
? this.#sort?.column === col.key
|
|
365
|
+
? this.#sort.direction === "asc"
|
|
366
|
+
? "ascending"
|
|
367
|
+
: "descending"
|
|
368
|
+
: "none"
|
|
369
|
+
: undefined;
|
|
370
|
+
return html `
|
|
290
371
|
<th
|
|
291
372
|
style=${styleMap(style)}
|
|
292
373
|
aria-sort=${sortAttr ?? nothing}
|
|
293
374
|
@click=${col.sortable
|
|
294
|
-
|
|
295
|
-
|
|
375
|
+
? () => this.#handleSort(col.key)
|
|
376
|
+
: nothing}
|
|
296
377
|
>
|
|
297
378
|
<span class="HeaderContent">
|
|
298
379
|
${col.header} ${this.#renderSortIcon(col)}
|
|
299
380
|
</span>
|
|
300
381
|
</th>
|
|
301
382
|
`;
|
|
302
|
-
|
|
383
|
+
})}
|
|
303
384
|
</tr>
|
|
304
385
|
</thead>
|
|
305
386
|
`;
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
387
|
+
}
|
|
388
|
+
#renderBody() {
|
|
389
|
+
if (this.#displayRows.length === 0) {
|
|
390
|
+
return html `
|
|
310
391
|
<tbody>
|
|
311
392
|
<tr class="EmptyRow">
|
|
312
393
|
<td colspan=${this.columns.length}>${this.emptyText}</td>
|
|
313
394
|
</tr>
|
|
314
395
|
</tbody>
|
|
315
396
|
`;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
397
|
+
}
|
|
398
|
+
const keyFn = this.rowKey
|
|
399
|
+
? (row, index) => this.rowKey(row)
|
|
400
|
+
: (_row, index) => index;
|
|
401
|
+
return html `
|
|
321
402
|
<tbody>
|
|
322
403
|
${repeat(this.#displayRows, keyFn, (row) => html `
|
|
323
404
|
<tr>
|
|
324
405
|
${this.columns.map((col) => {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
406
|
+
const value = row[col.key];
|
|
407
|
+
const content = col.render
|
|
408
|
+
? col.render(value, row)
|
|
409
|
+
: (value ?? "");
|
|
410
|
+
return html `<td>${content}</td>`;
|
|
411
|
+
})}
|
|
331
412
|
</tr>
|
|
332
413
|
`)}
|
|
333
414
|
</tbody>
|
|
334
415
|
`;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
416
|
+
}
|
|
417
|
+
#renderPagination() {
|
|
418
|
+
if (this.pageSize <= 0 || this.data.length === 0)
|
|
419
|
+
return nothing;
|
|
420
|
+
const start = (this.#page - 1) * this.pageSize + 1;
|
|
421
|
+
const end = Math.min(this.#page * this.pageSize, this.data.length);
|
|
422
|
+
const isFirst = this.#page === 1;
|
|
423
|
+
const isLast = this.#page === this.#totalPages;
|
|
424
|
+
return html `
|
|
344
425
|
<div class="Pagination" part="pagination">
|
|
345
426
|
<div class="PageInfo">
|
|
346
427
|
<span>${start}-${end} of ${this.data.length}</span>
|
|
@@ -381,9 +462,9 @@ export class DuiDataTable extends LitElement {
|
|
|
381
462
|
</div>
|
|
382
463
|
</div>
|
|
383
464
|
`;
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
465
|
+
}
|
|
466
|
+
render() {
|
|
467
|
+
return html `
|
|
387
468
|
<div class="DataTable" part="root">
|
|
388
469
|
<div class="TableWindow" part="table-window">
|
|
389
470
|
<table part="table">
|
|
@@ -393,20 +474,11 @@ export class DuiDataTable extends LitElement {
|
|
|
393
474
|
${this.#renderPagination()}
|
|
394
475
|
</div>
|
|
395
476
|
`;
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
__decorate([
|
|
405
|
-
property({ type: Number, attribute: "page-size" })
|
|
406
|
-
], DuiDataTable.prototype, "pageSize", null);
|
|
407
|
-
__decorate([
|
|
408
|
-
property({ attribute: false })
|
|
409
|
-
], DuiDataTable.prototype, "rowKey", null);
|
|
410
|
-
__decorate([
|
|
411
|
-
property({ attribute: "empty-text" })
|
|
412
|
-
], DuiDataTable.prototype, "emptyText", null);
|
|
477
|
+
}
|
|
478
|
+
constructor() {
|
|
479
|
+
super(...arguments);
|
|
480
|
+
__runInitializers(this, _private_displayRows_extraInitializers);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
})();
|
|
484
|
+
export { DuiDataTable };
|
package/dialog/dialog-close.js
CHANGED
|
@@ -16,8 +16,8 @@ const hostStyles = css `
|
|
|
16
16
|
* @slot - Content that closes the dialog (usually a button).
|
|
17
17
|
*/
|
|
18
18
|
export class DuiDialogClose extends LitElement {
|
|
19
|
-
static
|
|
20
|
-
static
|
|
19
|
+
static tagName = "dui-dialog-close";
|
|
20
|
+
static styles = [base, hostStyles];
|
|
21
21
|
#ctx = new ContextConsumer(this, {
|
|
22
22
|
context: dialogContext,
|
|
23
23
|
subscribe: true,
|