@zeyos/zx 2.1.0 → 2.2.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/CHANGELOG.md +39 -0
- package/README.md +15 -0
- package/dist/types/compat/base.d.ts +156 -0
- package/dist/types/compat/globals.d.ts +20 -0
- package/dist/types/compat/index.d.ts +128 -0
- package/dist/types/compat/map/basic.d.ts +175 -0
- package/dist/types/compat/map/data.d.ts +102 -0
- package/dist/types/compat/map/date-time.d.ts +80 -0
- package/dist/types/compat/map/factory.d.ts +9 -0
- package/dist/types/compat/map/form.d.ts +98 -0
- package/dist/types/compat/map/helpers.d.ts +12 -0
- package/dist/types/compat/map/http.d.ts +36 -0
- package/dist/types/compat/map/layout.d.ts +106 -0
- package/dist/types/compat/map/options.d.ts +80 -0
- package/dist/types/compat/map/select.d.ts +95 -0
- package/dist/types/compat/map/stubs.d.ts +32 -0
- package/dist/types/compat/map/utilities.d.ts +37 -0
- package/dist/types/compat-entry.d.ts +5 -0
- package/dist/types/components/badge/badge.d.ts +46 -0
- package/dist/types/components/breadcrumb/breadcrumb.d.ts +200 -0
- package/dist/types/components/button/button.d.ts +42 -0
- package/dist/types/components/check-button/check-button.d.ts +98 -0
- package/dist/types/components/checklist/checklist.d.ts +143 -0
- package/dist/types/components/checklist/field-adapter.d.ts +5 -0
- package/dist/types/components/context-menu/context-menu.d.ts +130 -0
- package/dist/types/components/copy/copy-button.d.ts +48 -0
- package/dist/types/components/copy/copy-input.d.ts +91 -0
- package/dist/types/components/data-filter/data-filter.d.ts +250 -0
- package/dist/types/components/data-filter/filter-core.d.ts +52 -0
- package/dist/types/components/date-picker/date-picker.d.ts +137 -0
- package/dist/types/components/date-picker/date-range-picker.d.ts +350 -0
- package/dist/types/components/date-picker/field-adapter.d.ts +6 -0
- package/dist/types/components/date-picker/month-picker.d.ts +75 -0
- package/dist/types/components/date-picker/range-field-adapter.d.ts +7 -0
- package/dist/types/components/date-picker/time-picker.d.ts +127 -0
- package/dist/types/components/datebox/date-range-box.d.ts +218 -0
- package/dist/types/components/datebox/datebox.d.ts +160 -0
- package/dist/types/components/datebox/field-adapter.d.ts +5 -0
- package/dist/types/components/dialog/dialog.d.ts +284 -0
- package/dist/types/components/dropdown/dropdown.d.ts +118 -0
- package/dist/types/components/empty-state/empty-state.d.ts +38 -0
- package/dist/types/components/field/field.d.ts +231 -0
- package/dist/types/components/field-upload/field-adapter.d.ts +5 -0
- package/dist/types/components/field-upload/field-upload.d.ts +213 -0
- package/dist/types/components/fieldset/fieldset.d.ts +125 -0
- package/dist/types/components/finder/finder.d.ts +252 -0
- package/dist/types/components/form/form.d.ts +194 -0
- package/dist/types/components/groupbox/groupbox.d.ts +89 -0
- package/dist/types/components/layout/layout.d.ts +132 -0
- package/dist/types/components/loading/inline-loading.d.ts +86 -0
- package/dist/types/components/loading/progress-bar.d.ts +168 -0
- package/dist/types/components/loading/spinner.d.ts +34 -0
- package/dist/types/components/master-panel/master-panel.d.ts +112 -0
- package/dist/types/components/menu-button/menu-button.d.ts +142 -0
- package/dist/types/components/message/message.d.ts +212 -0
- package/dist/types/components/modal/modal.d.ts +105 -0
- package/dist/types/components/multi-value-editor/field-adapter.d.ts +5 -0
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +66 -0
- package/dist/types/components/navigation-bar/navigation-bar.d.ts +229 -0
- package/dist/types/components/number-field/field-adapter.d.ts +5 -0
- package/dist/types/components/number-field/number-field.d.ts +292 -0
- package/dist/types/components/pagination/pagination.d.ts +267 -0
- package/dist/types/components/panel/panel.d.ts +194 -0
- package/dist/types/components/permission/permission.d.ts +93 -0
- package/dist/types/components/rating/field-adapter.d.ts +5 -0
- package/dist/types/components/rating/rating.d.ts +213 -0
- package/dist/types/components/search/search.d.ts +98 -0
- package/dist/types/components/select/field-adapter.d.ts +5 -0
- package/dist/types/components/select/filter.d.ts +11 -0
- package/dist/types/components/select/select.d.ts +235 -0
- package/dist/types/components/skeleton/skeleton.d.ts +97 -0
- package/dist/types/components/slider/field-adapter.d.ts +5 -0
- package/dist/types/components/slider/slider.d.ts +216 -0
- package/dist/types/components/split-view/split-view.d.ts +335 -0
- package/dist/types/components/stepper/stepper.d.ts +314 -0
- package/dist/types/components/stepper/steps.d.ts +131 -0
- package/dist/types/components/tabbox/tabbox.d.ts +230 -0
- package/dist/types/components/table/sort.d.ts +49 -0
- package/dist/types/components/table/table.d.ts +872 -0
- package/dist/types/components/tag-picker/field-adapter.d.ts +5 -0
- package/dist/types/components/tag-picker/tag-picker.d.ts +375 -0
- package/dist/types/components/timebox/field-adapter.d.ts +5 -0
- package/dist/types/components/timebox/timebox.d.ts +121 -0
- package/dist/types/components/toggle/field-adapter.d.ts +5 -0
- package/dist/types/components/toggle/toggle.d.ts +94 -0
- package/dist/types/components/toolbar/toolbar.d.ts +230 -0
- package/dist/types/components/tooltip/tooltip.d.ts +183 -0
- package/dist/types/components/tree/hierarchy.d.ts +113 -0
- package/dist/types/components/tree/tree.d.ts +383 -0
- package/dist/types/components/truncate/truncate.d.ts +61 -0
- package/dist/types/components/value-list/field-adapter.d.ts +5 -0
- package/dist/types/components/value-list/value-list.d.ts +143 -0
- package/dist/types/core/breakpoint.d.ts +68 -0
- package/dist/types/core/component.d.ts +115 -0
- package/dist/types/core/date.d.ts +50 -0
- package/dist/types/core/dom.d.ts +86 -0
- package/dist/types/core/export.d.ts +70 -0
- package/dist/types/core/fontawesome.d.ts +107 -0
- package/dist/types/core/format.d.ts +107 -0
- package/dist/types/core/http.d.ts +122 -0
- package/dist/types/core/i18n.d.ts +35 -0
- package/dist/types/core/icons.d.ts +137 -0
- package/dist/types/core/keyboard.d.ts +72 -0
- package/dist/types/core/position.d.ts +45 -0
- package/dist/types/core/storage.d.ts +46 -0
- package/dist/types/core/util.d.ts +117 -0
- package/dist/types/elements/define.d.ts +73 -0
- package/dist/types/elements/reflect.d.ts +27 -0
- package/dist/types/index.d.ts +79 -0
- package/dist/types/zeyos/connect.d.ts +65 -0
- package/dist/types/zeyos/form.d.ts +140 -0
- package/dist/types/zeyos/icons.d.ts +104 -0
- package/dist/types/zeyos/index.d.ts +12 -0
- package/dist/types/zeyos/modules.d.ts +110 -0
- package/dist/types/zeyos/query.d.ts +157 -0
- package/dist/types/zeyos/schema.d.ts +79 -0
- package/dist/types/zeyos/select.d.ts +167 -0
- package/dist/types/zeyos/table.d.ts +205 -0
- package/dist/zx-compat.esm.js +362 -33
- package/dist/zx-compat.esm.min.js +1 -1
- package/dist/zx-compat.global.js +359 -67
- package/dist/zx-compat.global.min.js +3 -3
- package/dist/zx-zeyos.esm.js +342 -43
- package/dist/zx-zeyos.esm.min.js +1 -1
- package/dist/zx.css +68 -6
- package/dist/zx.esm.js +346 -67
- package/dist/zx.esm.min.js +3 -3
- package/dist/zx.global.js +346 -67
- package/dist/zx.global.min.js +3 -3
- package/dist/zx.min.css +1 -1
- package/docs/api.json +48 -2
- package/docs/llms.md +28 -0
- package/package.json +37 -9
- package/src/compat/base.js +291 -0
- package/src/compat/globals.js +165 -0
- package/src/compat/index.js +84 -0
- package/src/compat/map/basic.js +464 -0
- package/src/compat/map/data.js +232 -0
- package/src/compat/map/date-time.js +177 -0
- package/src/compat/map/factory.js +45 -0
- package/src/compat/map/form.js +330 -0
- package/src/compat/map/helpers.js +46 -0
- package/src/compat/map/http.js +117 -0
- package/src/compat/map/layout.js +256 -0
- package/src/compat/map/options.js +267 -0
- package/src/compat/map/select.js +198 -0
- package/src/compat/map/stubs.js +26 -0
- package/src/compat/map/utilities.js +113 -0
- package/src/compat-entry.js +11 -0
- package/src/components/badge/badge.css +147 -0
- package/src/components/badge/badge.js +92 -0
- package/src/components/breadcrumb/breadcrumb.css +105 -0
- package/src/components/breadcrumb/breadcrumb.js +331 -0
- package/src/components/button/button.css +104 -0
- package/src/components/button/button.js +76 -0
- package/src/components/check-button/check-button.css +66 -0
- package/src/components/check-button/check-button.js +167 -0
- package/src/components/checklist/checklist.css +65 -0
- package/src/components/checklist/checklist.js +282 -0
- package/src/components/checklist/field-adapter.js +46 -0
- package/src/components/context-menu/context-menu.css +54 -0
- package/src/components/context-menu/context-menu.js +334 -0
- package/src/components/copy/copy-button.css +27 -0
- package/src/components/copy/copy-button.js +78 -0
- package/src/components/copy/copy-input.css +59 -0
- package/src/components/copy/copy-input.js +123 -0
- package/src/components/data-filter/data-filter.css +53 -0
- package/src/components/data-filter/data-filter.js +400 -0
- package/src/components/data-filter/filter-core.js +128 -0
- package/src/components/date-picker/date-picker.css +181 -0
- package/src/components/date-picker/date-picker.js +500 -0
- package/src/components/date-picker/date-range-picker.css +264 -0
- package/src/components/date-picker/date-range-picker.js +990 -0
- package/src/components/date-picker/field-adapter.js +36 -0
- package/src/components/date-picker/month-picker.js +223 -0
- package/src/components/date-picker/range-field-adapter.js +31 -0
- package/src/components/date-picker/time-picker.css +191 -0
- package/src/components/date-picker/time-picker.js +406 -0
- package/src/components/datebox/date-range-box.css +128 -0
- package/src/components/datebox/date-range-box.js +492 -0
- package/src/components/datebox/datebox.css +108 -0
- package/src/components/datebox/datebox.js +358 -0
- package/src/components/datebox/field-adapter.js +34 -0
- package/src/components/dialog/dialog.css +74 -0
- package/src/components/dialog/dialog.js +450 -0
- package/src/components/dropdown/dropdown.css +24 -0
- package/src/components/dropdown/dropdown.js +288 -0
- package/src/components/empty-state/empty-state.css +80 -0
- package/src/components/empty-state/empty-state.js +92 -0
- package/src/components/field/field.css +127 -0
- package/src/components/field/field.js +605 -0
- package/src/components/field-upload/field-adapter.js +21 -0
- package/src/components/field-upload/field-upload.css +108 -0
- package/src/components/field-upload/field-upload.js +475 -0
- package/src/components/fieldset/fieldset.css +37 -0
- package/src/components/fieldset/fieldset.js +307 -0
- package/src/components/finder/finder.css +98 -0
- package/src/components/finder/finder.js +509 -0
- package/src/components/form/form.css +32 -0
- package/src/components/form/form.js +302 -0
- package/src/components/groupbox/groupbox.css +51 -0
- package/src/components/groupbox/groupbox.js +199 -0
- package/src/components/layout/layout.css +117 -0
- package/src/components/layout/layout.js +136 -0
- package/src/components/loading/inline-loading.css +34 -0
- package/src/components/loading/inline-loading.js +140 -0
- package/src/components/loading/progress-bar.css +115 -0
- package/src/components/loading/progress-bar.js +259 -0
- package/src/components/loading/spinner.css +58 -0
- package/src/components/loading/spinner.js +57 -0
- package/src/components/master-panel/master-panel.css +51 -0
- package/src/components/master-panel/master-panel.js +203 -0
- package/src/components/menu-button/menu-button.css +49 -0
- package/src/components/menu-button/menu-button.js +294 -0
- package/src/components/message/message.css +122 -0
- package/src/components/message/message.js +499 -0
- package/src/components/modal/modal.css +47 -0
- package/src/components/modal/modal.js +203 -0
- package/src/components/multi-value-editor/field-adapter.js +44 -0
- package/src/components/multi-value-editor/multi-value-editor.css +56 -0
- package/src/components/multi-value-editor/multi-value-editor.js +170 -0
- package/src/components/navigation-bar/navigation-bar.css +130 -0
- package/src/components/navigation-bar/navigation-bar.js +450 -0
- package/src/components/number-field/field-adapter.js +40 -0
- package/src/components/number-field/number-field.css +77 -0
- package/src/components/number-field/number-field.js +545 -0
- package/src/components/pagination/pagination.css +95 -0
- package/src/components/pagination/pagination.js +481 -0
- package/src/components/panel/panel.css +123 -0
- package/src/components/panel/panel.js +336 -0
- package/src/components/permission/permission.css +47 -0
- package/src/components/permission/permission.js +198 -0
- package/src/components/rating/field-adapter.js +34 -0
- package/src/components/rating/rating.css +97 -0
- package/src/components/rating/rating.js +395 -0
- package/src/components/search/search.css +70 -0
- package/src/components/search/search.js +193 -0
- package/src/components/select/field-adapter.js +24 -0
- package/src/components/select/filter.js +39 -0
- package/src/components/select/select.css +180 -0
- package/src/components/select/select.js +663 -0
- package/src/components/skeleton/skeleton.css +76 -0
- package/src/components/skeleton/skeleton.js +139 -0
- package/src/components/slider/field-adapter.js +36 -0
- package/src/components/slider/slider.css +181 -0
- package/src/components/slider/slider.js +399 -0
- package/src/components/split-view/split-view.css +139 -0
- package/src/components/split-view/split-view.js +806 -0
- package/src/components/stepper/stepper.css +234 -0
- package/src/components/stepper/stepper.js +459 -0
- package/src/components/stepper/steps.js +131 -0
- package/src/components/tabbox/tabbox.css +281 -0
- package/src/components/tabbox/tabbox.js +484 -0
- package/src/components/table/sort.js +85 -0
- package/src/components/table/table.css +364 -0
- package/src/components/table/table.js +1693 -0
- package/src/components/tag-picker/field-adapter.js +35 -0
- package/src/components/tag-picker/tag-picker.css +169 -0
- package/src/components/tag-picker/tag-picker.js +837 -0
- package/src/components/timebox/field-adapter.js +24 -0
- package/src/components/timebox/timebox.css +51 -0
- package/src/components/timebox/timebox.js +276 -0
- package/src/components/toggle/field-adapter.js +24 -0
- package/src/components/toggle/toggle.css +66 -0
- package/src/components/toggle/toggle.js +150 -0
- package/src/components/toolbar/toolbar.css +81 -0
- package/src/components/toolbar/toolbar.js +511 -0
- package/src/components/tooltip/tooltip.css +36 -0
- package/src/components/tooltip/tooltip.js +420 -0
- package/src/components/tree/hierarchy.js +151 -0
- package/src/components/tree/tree.css +99 -0
- package/src/components/tree/tree.js +784 -0
- package/src/components/truncate/truncate.css +20 -0
- package/src/components/truncate/truncate.js +92 -0
- package/src/components/value-list/field-adapter.js +24 -0
- package/src/components/value-list/value-list.css +108 -0
- package/src/components/value-list/value-list.js +336 -0
- package/src/core/breakpoint.js +150 -0
- package/src/core/component.js +292 -0
- package/src/core/date.js +216 -0
- package/src/core/dom.js +260 -0
- package/src/core/export.js +204 -0
- package/src/core/fontawesome.js +177 -0
- package/src/core/format.js +283 -0
- package/src/core/http.js +246 -0
- package/src/core/i18n.js +83 -0
- package/src/core/icons.js +283 -0
- package/src/core/keyboard.js +240 -0
- package/src/core/position.js +177 -0
- package/src/core/storage.js +175 -0
- package/src/core/util.js +336 -0
- package/src/elements/define.js +715 -0
- package/src/elements/reflect.js +79 -0
- package/src/index.js +131 -0
- package/src/zeyos/connect.js +142 -0
- package/src/zeyos/form.js +254 -0
- package/src/zeyos/icons.js +92 -0
- package/src/zeyos/index.js +21 -0
- package/src/zeyos/modules.js +269 -0
- package/src/zeyos/query.js +199 -0
- package/src/zeyos/schema.js +474 -0
- package/src/zeyos/select.js +175 -0
- package/src/zeyos/table.js +272 -0
- package/styles/base.css +124 -0
- package/styles/icons.css +34 -0
- package/styles/tokens/dark.css +84 -0
- package/styles/tokens/density.css +9 -0
- package/styles/tokens/global.css +80 -0
- package/styles/tokens/modules.css +109 -0
- package/styles/tokens/semantic.css +49 -0
- package/styles/zx.css +61 -0
package/dist/zx.esm.js
CHANGED
|
@@ -70,7 +70,8 @@ function deepMerge(a, b) {
|
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
72
|
function isElement(value) {
|
|
73
|
-
return Boolean(value && typeof value === "object" &&
|
|
73
|
+
return Boolean(value && typeof value === "object" && /** @type {{nodeType?: unknown}} */
|
|
74
|
+
value.nodeType === 1);
|
|
74
75
|
}
|
|
75
76
|
function clamp(n, min, max) {
|
|
76
77
|
return Math.min(max, Math.max(min, n));
|
|
@@ -78,11 +79,15 @@ function clamp(n, min, max) {
|
|
|
78
79
|
function toArray(value) {
|
|
79
80
|
if (value == null) return [];
|
|
80
81
|
if (Array.isArray(value)) return value.slice();
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
const candidate = (
|
|
83
|
+
/** @type {any} */
|
|
84
|
+
value
|
|
85
|
+
);
|
|
86
|
+
if (typeof value !== "string" && typeof candidate?.[Symbol.iterator] === "function") {
|
|
87
|
+
return Array.from(candidate);
|
|
83
88
|
}
|
|
84
|
-
if (typeof value !== "string" && typeof
|
|
85
|
-
return Array.from(
|
|
89
|
+
if (typeof value !== "string" && typeof candidate?.length === "number") {
|
|
90
|
+
return Array.from(candidate);
|
|
86
91
|
}
|
|
87
92
|
return [
|
|
88
93
|
/** @type {T} */
|
|
@@ -291,8 +296,12 @@ function resolveElement(target) {
|
|
|
291
296
|
}
|
|
292
297
|
function isPropsObject(value) {
|
|
293
298
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
294
|
-
|
|
295
|
-
|
|
299
|
+
const candidate = (
|
|
300
|
+
/** @type {Record<string, unknown>} */
|
|
301
|
+
value
|
|
302
|
+
);
|
|
303
|
+
if (typeof candidate.nodeType === "number") return false;
|
|
304
|
+
return typeof candidate.toElement !== "function";
|
|
296
305
|
}
|
|
297
306
|
function applyProperty(element, key, value) {
|
|
298
307
|
if (key === "ref") {
|
|
@@ -350,15 +359,33 @@ function ariaAttribute(key) {
|
|
|
350
359
|
return "aria-" + key.slice(4).toLowerCase();
|
|
351
360
|
}
|
|
352
361
|
function appendChildren(parent, children) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
362
|
+
const host = (
|
|
363
|
+
/** @type {ParentNode} */
|
|
364
|
+
parent
|
|
365
|
+
);
|
|
366
|
+
for (
|
|
367
|
+
const raw2 of
|
|
368
|
+
/** @type {any[]} */
|
|
369
|
+
children.flat(Infinity)
|
|
370
|
+
) {
|
|
371
|
+
if (raw2 == null) continue;
|
|
372
|
+
if (typeof raw2 === "string" || typeof raw2 === "number") {
|
|
373
|
+
host.append(document.createTextNode(String(raw2)));
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
if (typeof raw2 !== "object") continue;
|
|
377
|
+
const child = (
|
|
378
|
+
/** @type {{nodeType?: number, toElement?: () => Node|null}} */
|
|
379
|
+
raw2
|
|
380
|
+
);
|
|
381
|
+
if (typeof child.nodeType === "number") {
|
|
382
|
+
host.append(
|
|
383
|
+
/** @type {Node} */
|
|
384
|
+
raw2
|
|
385
|
+
);
|
|
386
|
+
} else if (typeof child.toElement === "function") {
|
|
360
387
|
const element = child.toElement();
|
|
361
|
-
if (element)
|
|
388
|
+
if (element) host.append(element);
|
|
362
389
|
}
|
|
363
390
|
}
|
|
364
391
|
}
|
|
@@ -413,11 +440,18 @@ var registry = /* @__PURE__ */ new WeakMap();
|
|
|
413
440
|
var Component = class extends EventTarget {
|
|
414
441
|
/** @type {ComponentOptions} */
|
|
415
442
|
static defaults = {};
|
|
443
|
+
/**
|
|
444
|
+
* BEM block a subclass wants on its root, without the `zx-` prefix. Empty on the base, which is
|
|
445
|
+
* the same falsy answer the undeclared property gave — declared so the statics are visible to
|
|
446
|
+
* `this.constructor` and to the generated declarations.
|
|
447
|
+
* @type {string}
|
|
448
|
+
*/
|
|
449
|
+
static cssName = "";
|
|
416
450
|
/** @type {Element} Root element. */
|
|
417
451
|
el;
|
|
418
452
|
/** @type {Record<string, Element>} Elements captured by `h()` ref properties. */
|
|
419
453
|
refs;
|
|
420
|
-
/** @type {Readonly<
|
|
454
|
+
/** @type {Readonly<TOptions>} Merged component options. */
|
|
421
455
|
options;
|
|
422
456
|
#abort = new AbortController();
|
|
423
457
|
#created = false;
|
|
@@ -426,17 +460,27 @@ var Component = class extends EventTarget {
|
|
|
426
460
|
/**
|
|
427
461
|
* Creates a component around an existing target, or asks `render()` to create its root.
|
|
428
462
|
* @param {Element|string|null} target Existing element, selector, or null.
|
|
429
|
-
* @param {
|
|
463
|
+
* @param {TOptions} [options={}] Component options.
|
|
430
464
|
*/
|
|
431
|
-
constructor(target, options =
|
|
465
|
+
constructor(target, options = (
|
|
466
|
+
/** @type {TOptions} */
|
|
467
|
+
{}
|
|
468
|
+
)) {
|
|
432
469
|
super();
|
|
470
|
+
const self = (
|
|
471
|
+
/** @type {typeof Component} */
|
|
472
|
+
this.constructor
|
|
473
|
+
);
|
|
433
474
|
this.#created = target === null;
|
|
434
475
|
const resolved = resolveElement(target);
|
|
435
476
|
if (target !== null && !resolved) throw new TypeError("Component target could not be resolved");
|
|
436
477
|
this.el = /** @type {Element} */
|
|
437
478
|
resolved;
|
|
438
479
|
this.refs = {};
|
|
439
|
-
const merged =
|
|
480
|
+
const merged = (
|
|
481
|
+
/** @type {TOptions} */
|
|
482
|
+
mergeOptions(self, options)
|
|
483
|
+
);
|
|
440
484
|
const eventOptions = [];
|
|
441
485
|
for (const [key, value] of Object.entries(merged)) {
|
|
442
486
|
if (/^on[a-z]/.test(key) && typeof value === "function") {
|
|
@@ -466,7 +510,7 @@ var Component = class extends EventTarget {
|
|
|
466
510
|
this.#abort.abort();
|
|
467
511
|
throw new TypeError("Component requires a root Element");
|
|
468
512
|
}
|
|
469
|
-
const cssName =
|
|
513
|
+
const cssName = self.cssName;
|
|
470
514
|
if (typeof cssName === "string" && cssName) {
|
|
471
515
|
const className = `zx-${cssName}`;
|
|
472
516
|
this.#addedRootClass = !this.el.classList.contains(className);
|
|
@@ -587,7 +631,10 @@ var Component = class extends EventTarget {
|
|
|
587
631
|
this.#destroyed = true;
|
|
588
632
|
this.#abort.abort();
|
|
589
633
|
if (registry.get(this.el) === this) registry.delete(this.el);
|
|
590
|
-
const cssName =
|
|
634
|
+
const cssName = (
|
|
635
|
+
/** @type {typeof Component} */
|
|
636
|
+
this.constructor.cssName
|
|
637
|
+
);
|
|
591
638
|
if (this.#addedRootClass && typeof cssName === "string" && this.el) {
|
|
592
639
|
this.el.classList.remove(`zx-${cssName}`);
|
|
593
640
|
}
|
|
@@ -1571,7 +1618,10 @@ function getWeekStart(lang = getLanguage()) {
|
|
|
1571
1618
|
if (!lang) return 1;
|
|
1572
1619
|
if (lang.toLowerCase() === "en") return 1;
|
|
1573
1620
|
try {
|
|
1574
|
-
const locale =
|
|
1621
|
+
const locale = (
|
|
1622
|
+
/** @type {Intl.Locale & {getWeekInfo?: () => {firstDay?: number}, weekInfo?: {firstDay?: number}}} */
|
|
1623
|
+
new Intl.Locale(lang)
|
|
1624
|
+
);
|
|
1575
1625
|
const weekInfo = locale.getWeekInfo?.() ?? locale.weekInfo;
|
|
1576
1626
|
if (weekInfo?.firstDay) return weekInfo.firstDay % 7;
|
|
1577
1627
|
} catch {
|
|
@@ -1699,25 +1749,28 @@ function loadFontAwesomeKit(kit) {
|
|
|
1699
1749
|
const url = kitUrl(kit);
|
|
1700
1750
|
const pending = kitLoads.get(url);
|
|
1701
1751
|
if (pending) return pending;
|
|
1702
|
-
const promise =
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1752
|
+
const promise = (
|
|
1753
|
+
/** @type {Promise<void>} */
|
|
1754
|
+
new Promise((resolve, reject) => {
|
|
1755
|
+
const absolute = new URL(url, document.baseURI).href;
|
|
1756
|
+
const existing = [...document.scripts].find((script2) => script2.src === absolute);
|
|
1757
|
+
if (existing && globalThis.FontAwesomeKitConfig) {
|
|
1758
|
+
resolve();
|
|
1759
|
+
return;
|
|
1760
|
+
}
|
|
1761
|
+
const script = existing ?? document.createElement("script");
|
|
1762
|
+
script.addEventListener("load", () => resolve(), { once: true });
|
|
1763
|
+
script.addEventListener("error", () => {
|
|
1764
|
+
kitLoads.delete(url);
|
|
1765
|
+
reject(new Error(`Font Awesome kit failed to load: ${url}`));
|
|
1766
|
+
}, { once: true });
|
|
1767
|
+
if (existing) return;
|
|
1768
|
+
script.src = url;
|
|
1769
|
+
script.async = true;
|
|
1770
|
+
script.crossOrigin = "anonymous";
|
|
1771
|
+
document.head.append(script);
|
|
1772
|
+
})
|
|
1773
|
+
);
|
|
1721
1774
|
kitLoads.set(url, promise);
|
|
1722
1775
|
return promise;
|
|
1723
1776
|
}
|
|
@@ -2974,9 +3027,11 @@ function updateFallback(anchor, floating, { placement, offset, flip, matchWidth
|
|
|
2974
3027
|
const topY = anchorRect.top - offset - floatingRect.height;
|
|
2975
3028
|
if (flip) {
|
|
2976
3029
|
if (prefersBottom && bottomY + floatingRect.height > viewportHeight && topY >= 0) {
|
|
2977
|
-
actualPlacement = placement
|
|
3030
|
+
actualPlacement = /** @type {typeof placement} */
|
|
3031
|
+
placement.replace("bottom", "top");
|
|
2978
3032
|
} else if (!prefersBottom && topY < 0 && bottomY + floatingRect.height <= viewportHeight) {
|
|
2979
|
-
actualPlacement = placement
|
|
3033
|
+
actualPlacement = /** @type {typeof placement} */
|
|
3034
|
+
placement.replace("top", "bottom");
|
|
2980
3035
|
}
|
|
2981
3036
|
}
|
|
2982
3037
|
let left;
|
|
@@ -5989,10 +6044,13 @@ function rovingTabindex(container, itemSelector, { orientation = "vertical", wra
|
|
|
5989
6044
|
const originals = /* @__PURE__ */ new Map();
|
|
5990
6045
|
let destroyed = false;
|
|
5991
6046
|
function items() {
|
|
5992
|
-
return
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
6047
|
+
return (
|
|
6048
|
+
/** @type {HTMLElement[]} */
|
|
6049
|
+
Array.from(container.querySelectorAll(itemSelector)).filter((item) => {
|
|
6050
|
+
remember(item);
|
|
6051
|
+
return isAvailable(item);
|
|
6052
|
+
})
|
|
6053
|
+
);
|
|
5996
6054
|
}
|
|
5997
6055
|
function remember(item) {
|
|
5998
6056
|
if (!originals.has(item)) originals.set(item, item.getAttribute("tabindex"));
|
|
@@ -6007,7 +6065,11 @@ function rovingTabindex(container, itemSelector, { orientation = "vertical", wra
|
|
|
6007
6065
|
}
|
|
6008
6066
|
function onKeydown(event) {
|
|
6009
6067
|
const available = items();
|
|
6010
|
-
const current =
|
|
6068
|
+
const current = (
|
|
6069
|
+
/** @type {HTMLElement|null} */
|
|
6070
|
+
/** @type {Element|null} */
|
|
6071
|
+
event.target?.closest?.(itemSelector) ?? null
|
|
6072
|
+
);
|
|
6011
6073
|
const index = available.indexOf(current);
|
|
6012
6074
|
if (index < 0) return;
|
|
6013
6075
|
const previousKey = orientation === "horizontal" ? "ArrowLeft" : "ArrowUp";
|
|
@@ -6025,7 +6087,11 @@ function rovingTabindex(container, itemSelector, { orientation = "vertical", wra
|
|
|
6025
6087
|
available[nextIndex].focus();
|
|
6026
6088
|
}
|
|
6027
6089
|
function onFocus(event) {
|
|
6028
|
-
const item =
|
|
6090
|
+
const item = (
|
|
6091
|
+
/** @type {HTMLElement|null} */
|
|
6092
|
+
/** @type {Element|null} */
|
|
6093
|
+
event.target?.closest?.(itemSelector) ?? null
|
|
6094
|
+
);
|
|
6029
6095
|
if (item && container.contains(item)) update(item);
|
|
6030
6096
|
}
|
|
6031
6097
|
container.addEventListener("keydown", onKeydown, { signal: controller.signal });
|
|
@@ -6085,8 +6151,9 @@ function typeahead(getItems, onMatch) {
|
|
|
6085
6151
|
};
|
|
6086
6152
|
}
|
|
6087
6153
|
function focusableItems(container) {
|
|
6088
|
-
return
|
|
6089
|
-
|
|
6154
|
+
return (
|
|
6155
|
+
/** @type {HTMLElement[]} */
|
|
6156
|
+
Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR)).filter((item) => isAvailable(item) && item.getClientRects().length > 0)
|
|
6090
6157
|
);
|
|
6091
6158
|
}
|
|
6092
6159
|
function isAvailable(item) {
|
|
@@ -6100,7 +6167,11 @@ function itemText(item) {
|
|
|
6100
6167
|
return String(item.textContent ?? "").trim().toLocaleLowerCase();
|
|
6101
6168
|
}
|
|
6102
6169
|
if (item && typeof item === "object") {
|
|
6103
|
-
const
|
|
6170
|
+
const shape = (
|
|
6171
|
+
/** @type {{label?: unknown, text?: unknown, value?: unknown}} */
|
|
6172
|
+
item
|
|
6173
|
+
);
|
|
6174
|
+
const value = shape.label ?? shape.text ?? shape.value;
|
|
6104
6175
|
if (value != null) return String(value).trim().toLocaleLowerCase();
|
|
6105
6176
|
}
|
|
6106
6177
|
return String(item ?? "").trim().toLocaleLowerCase();
|
|
@@ -8583,11 +8654,19 @@ function matchBreakpoint(name, width) {
|
|
|
8583
8654
|
}
|
|
8584
8655
|
function onBreakpoint(handler, options = {}) {
|
|
8585
8656
|
if (typeof handler !== "function") throw new TypeError("onBreakpoint requires a handler");
|
|
8657
|
+
if ("target" in options && !isElement(options.target) && /** @type {unknown} */
|
|
8658
|
+
options.target !== /** @type {unknown} */
|
|
8659
|
+
globalThis) {
|
|
8660
|
+
throw new TypeError("onBreakpoint target must be an Element or the window");
|
|
8661
|
+
}
|
|
8586
8662
|
const target = options.target ?? globalThis;
|
|
8587
|
-
const element = target
|
|
8663
|
+
const element = isElement(target) ? (
|
|
8664
|
+
/** @type {Element} */
|
|
8665
|
+
target
|
|
8666
|
+
) : null;
|
|
8588
8667
|
let name = (
|
|
8589
|
-
/** @type {BreakpointName} */
|
|
8590
|
-
|
|
8668
|
+
/** @type {BreakpointName|null} */
|
|
8669
|
+
null
|
|
8591
8670
|
);
|
|
8592
8671
|
let destroyed = false;
|
|
8593
8672
|
let observer = null;
|
|
@@ -8595,24 +8674,33 @@ function onBreakpoint(handler, options = {}) {
|
|
|
8595
8674
|
const update = () => {
|
|
8596
8675
|
if (destroyed) return;
|
|
8597
8676
|
const width = measure();
|
|
8677
|
+
if (element && width === 0) return;
|
|
8598
8678
|
const next = breakpointOf(width);
|
|
8599
8679
|
if (next === name) return;
|
|
8600
8680
|
name = next;
|
|
8601
8681
|
handler(name, width);
|
|
8602
8682
|
};
|
|
8603
|
-
|
|
8604
|
-
|
|
8683
|
+
update();
|
|
8684
|
+
let frame = 0;
|
|
8685
|
+
const schedule = () => {
|
|
8686
|
+
if (frame || destroyed) return;
|
|
8687
|
+
frame = requestAnimationFrame(() => {
|
|
8688
|
+
frame = 0;
|
|
8689
|
+
update();
|
|
8690
|
+
});
|
|
8691
|
+
};
|
|
8605
8692
|
if (element && typeof ResizeObserver === "function") {
|
|
8606
|
-
observer = new ResizeObserver(
|
|
8693
|
+
observer = new ResizeObserver(schedule);
|
|
8607
8694
|
observer.observe(element);
|
|
8608
8695
|
} else {
|
|
8609
8696
|
globalThis.addEventListener?.("resize", update, { passive: true });
|
|
8610
8697
|
}
|
|
8611
8698
|
return {
|
|
8612
|
-
current: () => name,
|
|
8699
|
+
current: () => name ?? breakpointOf(measure()),
|
|
8613
8700
|
destroy: () => {
|
|
8614
8701
|
if (destroyed) return;
|
|
8615
8702
|
destroyed = true;
|
|
8703
|
+
if (frame) cancelAnimationFrame(frame);
|
|
8616
8704
|
observer?.disconnect();
|
|
8617
8705
|
globalThis.removeEventListener?.("resize", update);
|
|
8618
8706
|
}
|
|
@@ -8679,7 +8767,10 @@ var Http = class {
|
|
|
8679
8767
|
try {
|
|
8680
8768
|
json2 = JSON.parse(text4);
|
|
8681
8769
|
} catch (cause) {
|
|
8682
|
-
const error =
|
|
8770
|
+
const error = (
|
|
8771
|
+
/** @type {Error & {response?: Response}} */
|
|
8772
|
+
new Error("Invalid JSON response", { cause })
|
|
8773
|
+
);
|
|
8683
8774
|
error.response = response;
|
|
8684
8775
|
throw error;
|
|
8685
8776
|
}
|
|
@@ -8691,7 +8782,10 @@ var Http = class {
|
|
|
8691
8782
|
error2.response = response;
|
|
8692
8783
|
throw error2;
|
|
8693
8784
|
}
|
|
8694
|
-
const error =
|
|
8785
|
+
const error = (
|
|
8786
|
+
/** @type {Error & {response?: Response}} */
|
|
8787
|
+
new Error(`HTTP ${response.status} ${response.statusText}`.trim())
|
|
8788
|
+
);
|
|
8695
8789
|
error.response = response;
|
|
8696
8790
|
throw error;
|
|
8697
8791
|
}
|
|
@@ -8799,7 +8893,10 @@ function appendFormValue2(form, key, value) {
|
|
|
8799
8893
|
for (const item of value) appendFormValue2(form, key, item);
|
|
8800
8894
|
} else {
|
|
8801
8895
|
const isBlob = typeof Blob === "function" && value instanceof Blob;
|
|
8802
|
-
form.append(key, typeof value === "object" && !isBlob ? JSON.stringify(value) :
|
|
8896
|
+
form.append(key, typeof value === "object" && !isBlob ? JSON.stringify(value) : (
|
|
8897
|
+
/** @type {string|Blob} */
|
|
8898
|
+
value
|
|
8899
|
+
));
|
|
8803
8900
|
}
|
|
8804
8901
|
}
|
|
8805
8902
|
function isFileList(value) {
|
|
@@ -8872,7 +8969,11 @@ function formatRelativeTime(date, options = {}) {
|
|
|
8872
8969
|
const diff = target.getTime() - reference.getTime();
|
|
8873
8970
|
const division = TIME_DIVISIONS.find(({ ms, limit }) => Math.abs(diff) / ms < limit) ?? TIME_DIVISIONS[TIME_DIVISIONS.length - 1];
|
|
8874
8971
|
const value = Math.round(diff / division.ms);
|
|
8875
|
-
return relativeFormatter(locale, numeric).format(
|
|
8972
|
+
return relativeFormatter(locale, numeric).format(
|
|
8973
|
+
value,
|
|
8974
|
+
/** @type {Intl.RelativeTimeFormatUnit} */
|
|
8975
|
+
division.unit
|
|
8976
|
+
);
|
|
8876
8977
|
}
|
|
8877
8978
|
function format(locale, options, value) {
|
|
8878
8979
|
const key = `${locale}\0${JSON.stringify(options)}`;
|
|
@@ -9176,7 +9277,10 @@ function escapeField(field, delimiter, guard = false) {
|
|
|
9176
9277
|
}
|
|
9177
9278
|
function toBlob(data, type) {
|
|
9178
9279
|
if (typeof Blob === "function" && data instanceof Blob) return data;
|
|
9179
|
-
const parts =
|
|
9280
|
+
const parts = (
|
|
9281
|
+
/** @type {BlobPart[]} */
|
|
9282
|
+
typeof data === "string" && /^text\/csv\b/i.test(type) ? ["\uFEFF", data] : [data]
|
|
9283
|
+
);
|
|
9180
9284
|
return new Blob(parts, { type });
|
|
9181
9285
|
}
|
|
9182
9286
|
|
|
@@ -10565,6 +10669,8 @@ var Table = class extends Component {
|
|
|
10565
10669
|
sortMode: "local",
|
|
10566
10670
|
selectable: false,
|
|
10567
10671
|
stickyHeader: true,
|
|
10672
|
+
responsive: false,
|
|
10673
|
+
growing: false,
|
|
10568
10674
|
height: null,
|
|
10569
10675
|
emptyText: null,
|
|
10570
10676
|
rowClass: null,
|
|
@@ -10585,6 +10691,7 @@ var Table = class extends Component {
|
|
|
10585
10691
|
/** @type {HTMLElement} */
|
|
10586
10692
|
this.el ?? h("div")
|
|
10587
10693
|
);
|
|
10694
|
+
this.el = root;
|
|
10588
10695
|
this._originalChildren = this.el ? Array.from(this.el.childNodes) : null;
|
|
10589
10696
|
this._columns = Array.isArray(this.options.columns) ? this.options.columns.map((column) => ({ ...column })) : [];
|
|
10590
10697
|
this._data = Array.isArray(this.options.data) ? [...this.options.data] : [];
|
|
@@ -10597,6 +10704,11 @@ var Table = class extends Component {
|
|
|
10597
10704
|
this._editMode = normalizeEditMode(this.options.editMode);
|
|
10598
10705
|
this._edit = null;
|
|
10599
10706
|
this._editMessage = null;
|
|
10707
|
+
this._stacked = false;
|
|
10708
|
+
this._width = null;
|
|
10709
|
+
this._growStep = growStep(this.options.growing);
|
|
10710
|
+
this._rendered = this._growStep ?? Infinity;
|
|
10711
|
+
this._more = null;
|
|
10600
10712
|
this._rovingKey = null;
|
|
10601
10713
|
this._rovingCell = null;
|
|
10602
10714
|
this._rovingMatched = false;
|
|
@@ -10631,6 +10743,7 @@ var Table = class extends Component {
|
|
|
10631
10743
|
this._renderColumns();
|
|
10632
10744
|
this._renderHeader();
|
|
10633
10745
|
this._renderBody();
|
|
10746
|
+
this._watchWidth();
|
|
10634
10747
|
this.listen(this._tbody, "click", (event) => this._handleBodyClick(event));
|
|
10635
10748
|
this.listen(this._tbody, "dblclick", (event) => this._handleBodyDoubleClick(event));
|
|
10636
10749
|
if (this._editMode !== false) {
|
|
@@ -10664,6 +10777,7 @@ var Table = class extends Component {
|
|
|
10664
10777
|
* @fires Table#editcancel
|
|
10665
10778
|
*/
|
|
10666
10779
|
setData(rows) {
|
|
10780
|
+
this._rendered = this._growStep ?? Infinity;
|
|
10667
10781
|
this.setLoading(false);
|
|
10668
10782
|
assertRows(rows);
|
|
10669
10783
|
this._data = [...rows];
|
|
@@ -10938,9 +11052,150 @@ var Table = class extends Component {
|
|
|
10938
11052
|
getEditing() {
|
|
10939
11053
|
return this._edit ? { id: this._edit.id, columnId: this._edit.columnId } : null;
|
|
10940
11054
|
}
|
|
11055
|
+
/**
|
|
11056
|
+
* The rows currently rendered — all of them unless `growing` is on.
|
|
11057
|
+
* @returns {TableRow[]}
|
|
11058
|
+
*/
|
|
11059
|
+
_visibleData() {
|
|
11060
|
+
return this._rendered === Infinity ? this._data : this._data.slice(0, this._rendered);
|
|
11061
|
+
}
|
|
11062
|
+
/**
|
|
11063
|
+
* Renders the next batch of rows.
|
|
11064
|
+
* @param {number} [count] How many to add; defaults to the configured batch size.
|
|
11065
|
+
* @returns {this}
|
|
11066
|
+
* @fires Table#grow
|
|
11067
|
+
*/
|
|
11068
|
+
growBy(count2) {
|
|
11069
|
+
if (!this._growStep) return this;
|
|
11070
|
+
const step = Number(count2) > 0 ? Math.trunc(Number(count2)) : this._growStep;
|
|
11071
|
+
const before = this._rendered;
|
|
11072
|
+
this._rendered = Math.min(this._data.length, this._rendered + step);
|
|
11073
|
+
if (this._rendered === before) return this;
|
|
11074
|
+
this._renderBody();
|
|
11075
|
+
this.emit("grow", { rendered: this._rendered, total: this._data.length });
|
|
11076
|
+
return this;
|
|
11077
|
+
}
|
|
11078
|
+
/**
|
|
11079
|
+
* Renders every remaining row.
|
|
11080
|
+
* @returns {this}
|
|
11081
|
+
* @fires Table#grow
|
|
11082
|
+
*/
|
|
11083
|
+
showAll() {
|
|
11084
|
+
return this.growBy(this._data.length);
|
|
11085
|
+
}
|
|
11086
|
+
/**
|
|
11087
|
+
* How many rows are currently rendered.
|
|
11088
|
+
* @returns {number}
|
|
11089
|
+
*/
|
|
11090
|
+
getRenderedCount() {
|
|
11091
|
+
return Math.min(this._rendered, this._data.length);
|
|
11092
|
+
}
|
|
11093
|
+
/**
|
|
11094
|
+
* Keeps the "show more" control in step with what is rendered.
|
|
11095
|
+
*
|
|
11096
|
+
* The control sits outside the table rather than in a `<tfoot>` row spanning every column: it is
|
|
11097
|
+
* a command, not data, and a button inside the grid would be reachable by the row navigation
|
|
11098
|
+
* keys as though it were a cell.
|
|
11099
|
+
* @returns {void}
|
|
11100
|
+
*/
|
|
11101
|
+
_syncGrowing() {
|
|
11102
|
+
if (!this._growStep) return;
|
|
11103
|
+
const remaining = this._data.length - this.getRenderedCount();
|
|
11104
|
+
if (remaining <= 0) {
|
|
11105
|
+
this._more?.remove();
|
|
11106
|
+
this._more = null;
|
|
11107
|
+
return;
|
|
11108
|
+
}
|
|
11109
|
+
const label = this._message("table.more", "Show %1 more", [remaining]);
|
|
11110
|
+
if (!this._more) {
|
|
11111
|
+
this._more = h("button", {
|
|
11112
|
+
class: "zx-table__more",
|
|
11113
|
+
type: "button",
|
|
11114
|
+
onclick: () => this.growBy()
|
|
11115
|
+
});
|
|
11116
|
+
this.el.append(this._more);
|
|
11117
|
+
}
|
|
11118
|
+
this._more.textContent = label;
|
|
11119
|
+
this._more.setAttribute("aria-label", label);
|
|
11120
|
+
}
|
|
11121
|
+
/**
|
|
11122
|
+
* Resolves a localized message, falling back to a built-in template.
|
|
11123
|
+
* @param {string} key Message key.
|
|
11124
|
+
* @param {string} fallback Template used when the host has no translation.
|
|
11125
|
+
* @param {unknown[]} args Positional interpolation values.
|
|
11126
|
+
* @returns {string}
|
|
11127
|
+
*/
|
|
11128
|
+
_message(key, fallback, args) {
|
|
11129
|
+
const message = this.msg(key, ...args);
|
|
11130
|
+
return message === key ? printf(fallback, args) : message;
|
|
11131
|
+
}
|
|
11132
|
+
/**
|
|
11133
|
+
* Watches the table's own width and stacks the rows below `responsive`.
|
|
11134
|
+
*
|
|
11135
|
+
* The width comes from `onBreakpoint` observing this element rather than the window, which is the
|
|
11136
|
+
* whole point of the option: a table inside a split pane or a modal has no idea how wide the
|
|
11137
|
+
* viewport is, and a media query would stack it on a phone while leaving it unreadable in a
|
|
11138
|
+
* 320px pane on a desktop.
|
|
11139
|
+
* @returns {void}
|
|
11140
|
+
*/
|
|
11141
|
+
_watchWidth() {
|
|
11142
|
+
this._width?.destroy();
|
|
11143
|
+
this._width = null;
|
|
11144
|
+
const threshold = this.options.responsive;
|
|
11145
|
+
if (!threshold || !(threshold in breakpoints)) return;
|
|
11146
|
+
this._width = onBreakpoint(
|
|
11147
|
+
(_name, width) => this._setStacked(width > 0 && width < breakpoints[threshold]),
|
|
11148
|
+
{ target: this.el }
|
|
11149
|
+
);
|
|
11150
|
+
}
|
|
11151
|
+
/**
|
|
11152
|
+
* Enters or leaves stacked mode.
|
|
11153
|
+
* @param {boolean} stacked Whether rows should stack.
|
|
11154
|
+
* @returns {void}
|
|
11155
|
+
* @fires Table#stackedchange
|
|
11156
|
+
*/
|
|
11157
|
+
_setStacked(stacked) {
|
|
11158
|
+
if (this._stacked === stacked) return;
|
|
11159
|
+
this._stacked = stacked;
|
|
11160
|
+
this.el.toggleAttribute("data-stacked", stacked);
|
|
11161
|
+
this._applyStackedRoles(stacked);
|
|
11162
|
+
this.emit("stackedchange", { stacked });
|
|
11163
|
+
}
|
|
11164
|
+
/**
|
|
11165
|
+
* States the table roles explicitly while stacked, and removes them again on the way out.
|
|
11166
|
+
*
|
|
11167
|
+
* Stacking works by changing `display` on the table elements, and a table whose display is not
|
|
11168
|
+
* `table` loses its implicit ARIA roles — leaving a screen reader with a pile of generic blocks
|
|
11169
|
+
* where a table used to be. The roles are only asserted while the layout has taken them away.
|
|
11170
|
+
* @param {boolean} stacked Whether the roles should be present.
|
|
11171
|
+
* @returns {void}
|
|
11172
|
+
*/
|
|
11173
|
+
_applyStackedRoles(stacked) {
|
|
11174
|
+
const parts = [[this._table, "table"], [this._thead, "rowgroup"], [this._tbody, "rowgroup"]];
|
|
11175
|
+
for (const [element, role] of parts) {
|
|
11176
|
+
if (!element) continue;
|
|
11177
|
+
if (stacked) element.setAttribute("role", role);
|
|
11178
|
+
else element.removeAttribute("role");
|
|
11179
|
+
}
|
|
11180
|
+
for (const [selector, role] of [["tr", "row"], ["td", "cell"], ["th", "columnheader"]]) {
|
|
11181
|
+
for (const element of this._table.querySelectorAll(selector)) {
|
|
11182
|
+
if (stacked) element.setAttribute("role", role);
|
|
11183
|
+
else element.removeAttribute("role");
|
|
11184
|
+
}
|
|
11185
|
+
}
|
|
11186
|
+
}
|
|
11187
|
+
/**
|
|
11188
|
+
* Reports whether the rows are currently stacked.
|
|
11189
|
+
* @returns {boolean}
|
|
11190
|
+
*/
|
|
11191
|
+
isStacked() {
|
|
11192
|
+
return Boolean(this._stacked);
|
|
11193
|
+
}
|
|
10941
11194
|
/** Restores an enhanced target and releases all component listeners. @returns {void} */
|
|
10942
11195
|
destroy() {
|
|
10943
11196
|
this._teardownEdit();
|
|
11197
|
+
this._width?.destroy();
|
|
11198
|
+
this._width = null;
|
|
10944
11199
|
if (this.el) delete this.el.dataset.editMode;
|
|
10945
11200
|
if (!this._restored && this._originalChildren) {
|
|
10946
11201
|
this.el.replaceChildren(...this._originalChildren);
|
|
@@ -11025,17 +11280,35 @@ var Table = class extends Component {
|
|
|
11025
11280
|
this._rovingCell = null;
|
|
11026
11281
|
this._rovingMatched = false;
|
|
11027
11282
|
if (this._data.length === 0) {
|
|
11028
|
-
const text4 = this.options.emptyText == null ? this.msg("table.empty") : String(this.options.emptyText);
|
|
11029
11283
|
fragment.append(h(
|
|
11030
11284
|
"tr",
|
|
11031
11285
|
{ class: "zx-table__empty-row" },
|
|
11032
|
-
h("td", {
|
|
11286
|
+
h("td", {
|
|
11287
|
+
class: "zx-table__empty",
|
|
11288
|
+
colspan: this._columns.length + (this.options.selectable === "multi" ? 1 : 0)
|
|
11289
|
+
}, this._emptyContent())
|
|
11033
11290
|
));
|
|
11034
11291
|
} else {
|
|
11035
|
-
this.
|
|
11292
|
+
this._visibleData().forEach((row2, index) => fragment.append(this._createRow(row2, index)));
|
|
11036
11293
|
}
|
|
11037
11294
|
this._tbody.replaceChildren(fragment);
|
|
11038
11295
|
this._syncSelectAll();
|
|
11296
|
+
this._syncGrowing();
|
|
11297
|
+
if (this._stacked) this._applyStackedRoles(true);
|
|
11298
|
+
}
|
|
11299
|
+
/**
|
|
11300
|
+
* What to put in the empty row.
|
|
11301
|
+
*
|
|
11302
|
+
* An empty table is a screen in its own right — the place to say why there is nothing and what to
|
|
11303
|
+
* do about it — so this takes a node as readily as a string. A function is re-called on every
|
|
11304
|
+
* render, which matters when the placeholder contains a button: reusing one node would move the
|
|
11305
|
+
* same element between renders and quietly share its listeners.
|
|
11306
|
+
* @returns {Node|string}
|
|
11307
|
+
*/
|
|
11308
|
+
_emptyContent() {
|
|
11309
|
+
const empty = this.options.emptyText;
|
|
11310
|
+
if (empty == null) return this.msg("table.empty");
|
|
11311
|
+
return typeof empty === "function" ? empty() : empty;
|
|
11039
11312
|
}
|
|
11040
11313
|
/** @param {TableRow} row @param {number} index @returns {HTMLTableRowElement} */
|
|
11041
11314
|
_createRow(row2, index) {
|
|
@@ -11066,6 +11339,8 @@ var Table = class extends Component {
|
|
|
11066
11339
|
h("td")
|
|
11067
11340
|
);
|
|
11068
11341
|
if (column.align) cell.dataset.align = column.align;
|
|
11342
|
+
cell.dataset.label = column.label;
|
|
11343
|
+
if (column.popin === false) cell.dataset.popin = "false";
|
|
11069
11344
|
if (this._editMode !== false) {
|
|
11070
11345
|
cell.dataset.column = column.id;
|
|
11071
11346
|
if (resolveEditable(column, row2) !== false) {
|
|
@@ -11684,6 +11959,10 @@ function assertRows(rows) {
|
|
|
11684
11959
|
function sameSet(left, right) {
|
|
11685
11960
|
return left.size === right.size && [...left].every((value) => right.has(value));
|
|
11686
11961
|
}
|
|
11962
|
+
function growStep(growing) {
|
|
11963
|
+
const step = Math.trunc(Number(growing));
|
|
11964
|
+
return Number.isFinite(step) && step > 0 ? step : null;
|
|
11965
|
+
}
|
|
11687
11966
|
|
|
11688
11967
|
// src/elements/reflect.js
|
|
11689
11968
|
var INVALID_ATTRIBUTE = /* @__PURE__ */ Symbol("invalid attribute");
|