@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.global.js
CHANGED
|
@@ -241,7 +241,8 @@ var zx = (() => {
|
|
|
241
241
|
);
|
|
242
242
|
}
|
|
243
243
|
function isElement(value) {
|
|
244
|
-
return Boolean(value && typeof value === "object" &&
|
|
244
|
+
return Boolean(value && typeof value === "object" && /** @type {{nodeType?: unknown}} */
|
|
245
|
+
value.nodeType === 1);
|
|
245
246
|
}
|
|
246
247
|
function clamp(n, min, max) {
|
|
247
248
|
return Math.min(max, Math.max(min, n));
|
|
@@ -249,11 +250,15 @@ var zx = (() => {
|
|
|
249
250
|
function toArray(value) {
|
|
250
251
|
if (value == null) return [];
|
|
251
252
|
if (Array.isArray(value)) return value.slice();
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
const candidate = (
|
|
254
|
+
/** @type {any} */
|
|
255
|
+
value
|
|
256
|
+
);
|
|
257
|
+
if (typeof value !== "string" && typeof candidate?.[Symbol.iterator] === "function") {
|
|
258
|
+
return Array.from(candidate);
|
|
254
259
|
}
|
|
255
|
-
if (typeof value !== "string" && typeof
|
|
256
|
-
return Array.from(
|
|
260
|
+
if (typeof value !== "string" && typeof candidate?.length === "number") {
|
|
261
|
+
return Array.from(candidate);
|
|
257
262
|
}
|
|
258
263
|
return [
|
|
259
264
|
/** @type {T} */
|
|
@@ -462,8 +467,12 @@ var zx = (() => {
|
|
|
462
467
|
}
|
|
463
468
|
function isPropsObject(value) {
|
|
464
469
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
465
|
-
|
|
466
|
-
|
|
470
|
+
const candidate = (
|
|
471
|
+
/** @type {Record<string, unknown>} */
|
|
472
|
+
value
|
|
473
|
+
);
|
|
474
|
+
if (typeof candidate.nodeType === "number") return false;
|
|
475
|
+
return typeof candidate.toElement !== "function";
|
|
467
476
|
}
|
|
468
477
|
function applyProperty(element, key, value) {
|
|
469
478
|
if (key === "ref") {
|
|
@@ -521,15 +530,33 @@ var zx = (() => {
|
|
|
521
530
|
return "aria-" + key.slice(4).toLowerCase();
|
|
522
531
|
}
|
|
523
532
|
function appendChildren(parent, children) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
533
|
+
const host = (
|
|
534
|
+
/** @type {ParentNode} */
|
|
535
|
+
parent
|
|
536
|
+
);
|
|
537
|
+
for (
|
|
538
|
+
const raw2 of
|
|
539
|
+
/** @type {any[]} */
|
|
540
|
+
children.flat(Infinity)
|
|
541
|
+
) {
|
|
542
|
+
if (raw2 == null) continue;
|
|
543
|
+
if (typeof raw2 === "string" || typeof raw2 === "number") {
|
|
544
|
+
host.append(document.createTextNode(String(raw2)));
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
if (typeof raw2 !== "object") continue;
|
|
548
|
+
const child = (
|
|
549
|
+
/** @type {{nodeType?: number, toElement?: () => Node|null}} */
|
|
550
|
+
raw2
|
|
551
|
+
);
|
|
552
|
+
if (typeof child.nodeType === "number") {
|
|
553
|
+
host.append(
|
|
554
|
+
/** @type {Node} */
|
|
555
|
+
raw2
|
|
556
|
+
);
|
|
557
|
+
} else if (typeof child.toElement === "function") {
|
|
531
558
|
const element = child.toElement();
|
|
532
|
-
if (element)
|
|
559
|
+
if (element) host.append(element);
|
|
533
560
|
}
|
|
534
561
|
}
|
|
535
562
|
}
|
|
@@ -584,11 +611,18 @@ var zx = (() => {
|
|
|
584
611
|
var Component = class extends EventTarget {
|
|
585
612
|
/** @type {ComponentOptions} */
|
|
586
613
|
static defaults = {};
|
|
614
|
+
/**
|
|
615
|
+
* BEM block a subclass wants on its root, without the `zx-` prefix. Empty on the base, which is
|
|
616
|
+
* the same falsy answer the undeclared property gave — declared so the statics are visible to
|
|
617
|
+
* `this.constructor` and to the generated declarations.
|
|
618
|
+
* @type {string}
|
|
619
|
+
*/
|
|
620
|
+
static cssName = "";
|
|
587
621
|
/** @type {Element} Root element. */
|
|
588
622
|
el;
|
|
589
623
|
/** @type {Record<string, Element>} Elements captured by `h()` ref properties. */
|
|
590
624
|
refs;
|
|
591
|
-
/** @type {Readonly<
|
|
625
|
+
/** @type {Readonly<TOptions>} Merged component options. */
|
|
592
626
|
options;
|
|
593
627
|
#abort = new AbortController();
|
|
594
628
|
#created = false;
|
|
@@ -597,17 +631,27 @@ var zx = (() => {
|
|
|
597
631
|
/**
|
|
598
632
|
* Creates a component around an existing target, or asks `render()` to create its root.
|
|
599
633
|
* @param {Element|string|null} target Existing element, selector, or null.
|
|
600
|
-
* @param {
|
|
634
|
+
* @param {TOptions} [options={}] Component options.
|
|
601
635
|
*/
|
|
602
|
-
constructor(target, options =
|
|
636
|
+
constructor(target, options = (
|
|
637
|
+
/** @type {TOptions} */
|
|
638
|
+
{}
|
|
639
|
+
)) {
|
|
603
640
|
super();
|
|
641
|
+
const self = (
|
|
642
|
+
/** @type {typeof Component} */
|
|
643
|
+
this.constructor
|
|
644
|
+
);
|
|
604
645
|
this.#created = target === null;
|
|
605
646
|
const resolved = resolveElement(target);
|
|
606
647
|
if (target !== null && !resolved) throw new TypeError("Component target could not be resolved");
|
|
607
648
|
this.el = /** @type {Element} */
|
|
608
649
|
resolved;
|
|
609
650
|
this.refs = {};
|
|
610
|
-
const merged =
|
|
651
|
+
const merged = (
|
|
652
|
+
/** @type {TOptions} */
|
|
653
|
+
mergeOptions(self, options)
|
|
654
|
+
);
|
|
611
655
|
const eventOptions = [];
|
|
612
656
|
for (const [key, value] of Object.entries(merged)) {
|
|
613
657
|
if (/^on[a-z]/.test(key) && typeof value === "function") {
|
|
@@ -637,7 +681,7 @@ var zx = (() => {
|
|
|
637
681
|
this.#abort.abort();
|
|
638
682
|
throw new TypeError("Component requires a root Element");
|
|
639
683
|
}
|
|
640
|
-
const cssName =
|
|
684
|
+
const cssName = self.cssName;
|
|
641
685
|
if (typeof cssName === "string" && cssName) {
|
|
642
686
|
const className = `zx-${cssName}`;
|
|
643
687
|
this.#addedRootClass = !this.el.classList.contains(className);
|
|
@@ -758,7 +802,10 @@ var zx = (() => {
|
|
|
758
802
|
this.#destroyed = true;
|
|
759
803
|
this.#abort.abort();
|
|
760
804
|
if (registry.get(this.el) === this) registry.delete(this.el);
|
|
761
|
-
const cssName =
|
|
805
|
+
const cssName = (
|
|
806
|
+
/** @type {typeof Component} */
|
|
807
|
+
this.constructor.cssName
|
|
808
|
+
);
|
|
762
809
|
if (this.#addedRootClass && typeof cssName === "string" && this.el) {
|
|
763
810
|
this.el.classList.remove(`zx-${cssName}`);
|
|
764
811
|
}
|
|
@@ -1742,7 +1789,10 @@ var zx = (() => {
|
|
|
1742
1789
|
if (!lang) return 1;
|
|
1743
1790
|
if (lang.toLowerCase() === "en") return 1;
|
|
1744
1791
|
try {
|
|
1745
|
-
const locale =
|
|
1792
|
+
const locale = (
|
|
1793
|
+
/** @type {Intl.Locale & {getWeekInfo?: () => {firstDay?: number}, weekInfo?: {firstDay?: number}}} */
|
|
1794
|
+
new Intl.Locale(lang)
|
|
1795
|
+
);
|
|
1746
1796
|
const weekInfo = locale.getWeekInfo?.() ?? locale.weekInfo;
|
|
1747
1797
|
if (weekInfo?.firstDay) return weekInfo.firstDay % 7;
|
|
1748
1798
|
} catch {
|
|
@@ -1870,25 +1920,28 @@ var zx = (() => {
|
|
|
1870
1920
|
const url = kitUrl(kit);
|
|
1871
1921
|
const pending = kitLoads.get(url);
|
|
1872
1922
|
if (pending) return pending;
|
|
1873
|
-
const promise =
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1923
|
+
const promise = (
|
|
1924
|
+
/** @type {Promise<void>} */
|
|
1925
|
+
new Promise((resolve, reject) => {
|
|
1926
|
+
const absolute = new URL(url, document.baseURI).href;
|
|
1927
|
+
const existing = [...document.scripts].find((script2) => script2.src === absolute);
|
|
1928
|
+
if (existing && globalThis.FontAwesomeKitConfig) {
|
|
1929
|
+
resolve();
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1932
|
+
const script = existing ?? document.createElement("script");
|
|
1933
|
+
script.addEventListener("load", () => resolve(), { once: true });
|
|
1934
|
+
script.addEventListener("error", () => {
|
|
1935
|
+
kitLoads.delete(url);
|
|
1936
|
+
reject(new Error(`Font Awesome kit failed to load: ${url}`));
|
|
1937
|
+
}, { once: true });
|
|
1938
|
+
if (existing) return;
|
|
1939
|
+
script.src = url;
|
|
1940
|
+
script.async = true;
|
|
1941
|
+
script.crossOrigin = "anonymous";
|
|
1942
|
+
document.head.append(script);
|
|
1943
|
+
})
|
|
1944
|
+
);
|
|
1892
1945
|
kitLoads.set(url, promise);
|
|
1893
1946
|
return promise;
|
|
1894
1947
|
}
|
|
@@ -3145,9 +3198,11 @@ var zx = (() => {
|
|
|
3145
3198
|
const topY = anchorRect.top - offset - floatingRect.height;
|
|
3146
3199
|
if (flip) {
|
|
3147
3200
|
if (prefersBottom && bottomY + floatingRect.height > viewportHeight && topY >= 0) {
|
|
3148
|
-
actualPlacement = placement
|
|
3201
|
+
actualPlacement = /** @type {typeof placement} */
|
|
3202
|
+
placement.replace("bottom", "top");
|
|
3149
3203
|
} else if (!prefersBottom && topY < 0 && bottomY + floatingRect.height <= viewportHeight) {
|
|
3150
|
-
actualPlacement = placement
|
|
3204
|
+
actualPlacement = /** @type {typeof placement} */
|
|
3205
|
+
placement.replace("top", "bottom");
|
|
3151
3206
|
}
|
|
3152
3207
|
}
|
|
3153
3208
|
let left;
|
|
@@ -6160,10 +6215,13 @@ var zx = (() => {
|
|
|
6160
6215
|
const originals = /* @__PURE__ */ new Map();
|
|
6161
6216
|
let destroyed = false;
|
|
6162
6217
|
function items() {
|
|
6163
|
-
return
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6218
|
+
return (
|
|
6219
|
+
/** @type {HTMLElement[]} */
|
|
6220
|
+
Array.from(container.querySelectorAll(itemSelector)).filter((item) => {
|
|
6221
|
+
remember(item);
|
|
6222
|
+
return isAvailable(item);
|
|
6223
|
+
})
|
|
6224
|
+
);
|
|
6167
6225
|
}
|
|
6168
6226
|
function remember(item) {
|
|
6169
6227
|
if (!originals.has(item)) originals.set(item, item.getAttribute("tabindex"));
|
|
@@ -6178,7 +6236,11 @@ var zx = (() => {
|
|
|
6178
6236
|
}
|
|
6179
6237
|
function onKeydown(event) {
|
|
6180
6238
|
const available = items();
|
|
6181
|
-
const current =
|
|
6239
|
+
const current = (
|
|
6240
|
+
/** @type {HTMLElement|null} */
|
|
6241
|
+
/** @type {Element|null} */
|
|
6242
|
+
event.target?.closest?.(itemSelector) ?? null
|
|
6243
|
+
);
|
|
6182
6244
|
const index = available.indexOf(current);
|
|
6183
6245
|
if (index < 0) return;
|
|
6184
6246
|
const previousKey = orientation === "horizontal" ? "ArrowLeft" : "ArrowUp";
|
|
@@ -6196,7 +6258,11 @@ var zx = (() => {
|
|
|
6196
6258
|
available[nextIndex].focus();
|
|
6197
6259
|
}
|
|
6198
6260
|
function onFocus(event) {
|
|
6199
|
-
const item =
|
|
6261
|
+
const item = (
|
|
6262
|
+
/** @type {HTMLElement|null} */
|
|
6263
|
+
/** @type {Element|null} */
|
|
6264
|
+
event.target?.closest?.(itemSelector) ?? null
|
|
6265
|
+
);
|
|
6200
6266
|
if (item && container.contains(item)) update(item);
|
|
6201
6267
|
}
|
|
6202
6268
|
container.addEventListener("keydown", onKeydown, { signal: controller.signal });
|
|
@@ -6256,8 +6322,9 @@ var zx = (() => {
|
|
|
6256
6322
|
};
|
|
6257
6323
|
}
|
|
6258
6324
|
function focusableItems(container) {
|
|
6259
|
-
return
|
|
6260
|
-
|
|
6325
|
+
return (
|
|
6326
|
+
/** @type {HTMLElement[]} */
|
|
6327
|
+
Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR)).filter((item) => isAvailable(item) && item.getClientRects().length > 0)
|
|
6261
6328
|
);
|
|
6262
6329
|
}
|
|
6263
6330
|
function isAvailable(item) {
|
|
@@ -6271,7 +6338,11 @@ var zx = (() => {
|
|
|
6271
6338
|
return String(item.textContent ?? "").trim().toLocaleLowerCase();
|
|
6272
6339
|
}
|
|
6273
6340
|
if (item && typeof item === "object") {
|
|
6274
|
-
const
|
|
6341
|
+
const shape = (
|
|
6342
|
+
/** @type {{label?: unknown, text?: unknown, value?: unknown}} */
|
|
6343
|
+
item
|
|
6344
|
+
);
|
|
6345
|
+
const value = shape.label ?? shape.text ?? shape.value;
|
|
6275
6346
|
if (value != null) return String(value).trim().toLocaleLowerCase();
|
|
6276
6347
|
}
|
|
6277
6348
|
return String(item ?? "").trim().toLocaleLowerCase();
|
|
@@ -8754,11 +8825,19 @@ var zx = (() => {
|
|
|
8754
8825
|
}
|
|
8755
8826
|
function onBreakpoint(handler, options = {}) {
|
|
8756
8827
|
if (typeof handler !== "function") throw new TypeError("onBreakpoint requires a handler");
|
|
8828
|
+
if ("target" in options && !isElement(options.target) && /** @type {unknown} */
|
|
8829
|
+
options.target !== /** @type {unknown} */
|
|
8830
|
+
globalThis) {
|
|
8831
|
+
throw new TypeError("onBreakpoint target must be an Element or the window");
|
|
8832
|
+
}
|
|
8757
8833
|
const target = options.target ?? globalThis;
|
|
8758
|
-
const element = target
|
|
8834
|
+
const element = isElement(target) ? (
|
|
8835
|
+
/** @type {Element} */
|
|
8836
|
+
target
|
|
8837
|
+
) : null;
|
|
8759
8838
|
let name = (
|
|
8760
|
-
/** @type {BreakpointName} */
|
|
8761
|
-
|
|
8839
|
+
/** @type {BreakpointName|null} */
|
|
8840
|
+
null
|
|
8762
8841
|
);
|
|
8763
8842
|
let destroyed = false;
|
|
8764
8843
|
let observer = null;
|
|
@@ -8766,24 +8845,33 @@ var zx = (() => {
|
|
|
8766
8845
|
const update = () => {
|
|
8767
8846
|
if (destroyed) return;
|
|
8768
8847
|
const width = measure();
|
|
8848
|
+
if (element && width === 0) return;
|
|
8769
8849
|
const next = breakpointOf(width);
|
|
8770
8850
|
if (next === name) return;
|
|
8771
8851
|
name = next;
|
|
8772
8852
|
handler(name, width);
|
|
8773
8853
|
};
|
|
8774
|
-
|
|
8775
|
-
|
|
8854
|
+
update();
|
|
8855
|
+
let frame = 0;
|
|
8856
|
+
const schedule = () => {
|
|
8857
|
+
if (frame || destroyed) return;
|
|
8858
|
+
frame = requestAnimationFrame(() => {
|
|
8859
|
+
frame = 0;
|
|
8860
|
+
update();
|
|
8861
|
+
});
|
|
8862
|
+
};
|
|
8776
8863
|
if (element && typeof ResizeObserver === "function") {
|
|
8777
|
-
observer = new ResizeObserver(
|
|
8864
|
+
observer = new ResizeObserver(schedule);
|
|
8778
8865
|
observer.observe(element);
|
|
8779
8866
|
} else {
|
|
8780
8867
|
globalThis.addEventListener?.("resize", update, { passive: true });
|
|
8781
8868
|
}
|
|
8782
8869
|
return {
|
|
8783
|
-
current: () => name,
|
|
8870
|
+
current: () => name ?? breakpointOf(measure()),
|
|
8784
8871
|
destroy: () => {
|
|
8785
8872
|
if (destroyed) return;
|
|
8786
8873
|
destroyed = true;
|
|
8874
|
+
if (frame) cancelAnimationFrame(frame);
|
|
8787
8875
|
observer?.disconnect();
|
|
8788
8876
|
globalThis.removeEventListener?.("resize", update);
|
|
8789
8877
|
}
|
|
@@ -8850,7 +8938,10 @@ var zx = (() => {
|
|
|
8850
8938
|
try {
|
|
8851
8939
|
json2 = JSON.parse(text4);
|
|
8852
8940
|
} catch (cause) {
|
|
8853
|
-
const error =
|
|
8941
|
+
const error = (
|
|
8942
|
+
/** @type {Error & {response?: Response}} */
|
|
8943
|
+
new Error("Invalid JSON response", { cause })
|
|
8944
|
+
);
|
|
8854
8945
|
error.response = response;
|
|
8855
8946
|
throw error;
|
|
8856
8947
|
}
|
|
@@ -8862,7 +8953,10 @@ var zx = (() => {
|
|
|
8862
8953
|
error2.response = response;
|
|
8863
8954
|
throw error2;
|
|
8864
8955
|
}
|
|
8865
|
-
const error =
|
|
8956
|
+
const error = (
|
|
8957
|
+
/** @type {Error & {response?: Response}} */
|
|
8958
|
+
new Error(`HTTP ${response.status} ${response.statusText}`.trim())
|
|
8959
|
+
);
|
|
8866
8960
|
error.response = response;
|
|
8867
8961
|
throw error;
|
|
8868
8962
|
}
|
|
@@ -8970,7 +9064,10 @@ var zx = (() => {
|
|
|
8970
9064
|
for (const item of value) appendFormValue2(form, key, item);
|
|
8971
9065
|
} else {
|
|
8972
9066
|
const isBlob = typeof Blob === "function" && value instanceof Blob;
|
|
8973
|
-
form.append(key, typeof value === "object" && !isBlob ? JSON.stringify(value) :
|
|
9067
|
+
form.append(key, typeof value === "object" && !isBlob ? JSON.stringify(value) : (
|
|
9068
|
+
/** @type {string|Blob} */
|
|
9069
|
+
value
|
|
9070
|
+
));
|
|
8974
9071
|
}
|
|
8975
9072
|
}
|
|
8976
9073
|
function isFileList(value) {
|
|
@@ -9043,7 +9140,11 @@ var zx = (() => {
|
|
|
9043
9140
|
const diff = target.getTime() - reference.getTime();
|
|
9044
9141
|
const division = TIME_DIVISIONS.find(({ ms, limit }) => Math.abs(diff) / ms < limit) ?? TIME_DIVISIONS[TIME_DIVISIONS.length - 1];
|
|
9045
9142
|
const value = Math.round(diff / division.ms);
|
|
9046
|
-
return relativeFormatter(locale, numeric).format(
|
|
9143
|
+
return relativeFormatter(locale, numeric).format(
|
|
9144
|
+
value,
|
|
9145
|
+
/** @type {Intl.RelativeTimeFormatUnit} */
|
|
9146
|
+
division.unit
|
|
9147
|
+
);
|
|
9047
9148
|
}
|
|
9048
9149
|
function format(locale, options, value) {
|
|
9049
9150
|
const key = `${locale}\0${JSON.stringify(options)}`;
|
|
@@ -9347,7 +9448,10 @@ var zx = (() => {
|
|
|
9347
9448
|
}
|
|
9348
9449
|
function toBlob(data, type) {
|
|
9349
9450
|
if (typeof Blob === "function" && data instanceof Blob) return data;
|
|
9350
|
-
const parts =
|
|
9451
|
+
const parts = (
|
|
9452
|
+
/** @type {BlobPart[]} */
|
|
9453
|
+
typeof data === "string" && /^text\/csv\b/i.test(type) ? ["\uFEFF", data] : [data]
|
|
9454
|
+
);
|
|
9351
9455
|
return new Blob(parts, { type });
|
|
9352
9456
|
}
|
|
9353
9457
|
|
|
@@ -10736,6 +10840,8 @@ var zx = (() => {
|
|
|
10736
10840
|
sortMode: "local",
|
|
10737
10841
|
selectable: false,
|
|
10738
10842
|
stickyHeader: true,
|
|
10843
|
+
responsive: false,
|
|
10844
|
+
growing: false,
|
|
10739
10845
|
height: null,
|
|
10740
10846
|
emptyText: null,
|
|
10741
10847
|
rowClass: null,
|
|
@@ -10756,6 +10862,7 @@ var zx = (() => {
|
|
|
10756
10862
|
/** @type {HTMLElement} */
|
|
10757
10863
|
this.el ?? h("div")
|
|
10758
10864
|
);
|
|
10865
|
+
this.el = root;
|
|
10759
10866
|
this._originalChildren = this.el ? Array.from(this.el.childNodes) : null;
|
|
10760
10867
|
this._columns = Array.isArray(this.options.columns) ? this.options.columns.map((column) => ({ ...column })) : [];
|
|
10761
10868
|
this._data = Array.isArray(this.options.data) ? [...this.options.data] : [];
|
|
@@ -10768,6 +10875,11 @@ var zx = (() => {
|
|
|
10768
10875
|
this._editMode = normalizeEditMode(this.options.editMode);
|
|
10769
10876
|
this._edit = null;
|
|
10770
10877
|
this._editMessage = null;
|
|
10878
|
+
this._stacked = false;
|
|
10879
|
+
this._width = null;
|
|
10880
|
+
this._growStep = growStep(this.options.growing);
|
|
10881
|
+
this._rendered = this._growStep ?? Infinity;
|
|
10882
|
+
this._more = null;
|
|
10771
10883
|
this._rovingKey = null;
|
|
10772
10884
|
this._rovingCell = null;
|
|
10773
10885
|
this._rovingMatched = false;
|
|
@@ -10802,6 +10914,7 @@ var zx = (() => {
|
|
|
10802
10914
|
this._renderColumns();
|
|
10803
10915
|
this._renderHeader();
|
|
10804
10916
|
this._renderBody();
|
|
10917
|
+
this._watchWidth();
|
|
10805
10918
|
this.listen(this._tbody, "click", (event) => this._handleBodyClick(event));
|
|
10806
10919
|
this.listen(this._tbody, "dblclick", (event) => this._handleBodyDoubleClick(event));
|
|
10807
10920
|
if (this._editMode !== false) {
|
|
@@ -10835,6 +10948,7 @@ var zx = (() => {
|
|
|
10835
10948
|
* @fires Table#editcancel
|
|
10836
10949
|
*/
|
|
10837
10950
|
setData(rows) {
|
|
10951
|
+
this._rendered = this._growStep ?? Infinity;
|
|
10838
10952
|
this.setLoading(false);
|
|
10839
10953
|
assertRows(rows);
|
|
10840
10954
|
this._data = [...rows];
|
|
@@ -11109,9 +11223,150 @@ var zx = (() => {
|
|
|
11109
11223
|
getEditing() {
|
|
11110
11224
|
return this._edit ? { id: this._edit.id, columnId: this._edit.columnId } : null;
|
|
11111
11225
|
}
|
|
11226
|
+
/**
|
|
11227
|
+
* The rows currently rendered — all of them unless `growing` is on.
|
|
11228
|
+
* @returns {TableRow[]}
|
|
11229
|
+
*/
|
|
11230
|
+
_visibleData() {
|
|
11231
|
+
return this._rendered === Infinity ? this._data : this._data.slice(0, this._rendered);
|
|
11232
|
+
}
|
|
11233
|
+
/**
|
|
11234
|
+
* Renders the next batch of rows.
|
|
11235
|
+
* @param {number} [count] How many to add; defaults to the configured batch size.
|
|
11236
|
+
* @returns {this}
|
|
11237
|
+
* @fires Table#grow
|
|
11238
|
+
*/
|
|
11239
|
+
growBy(count2) {
|
|
11240
|
+
if (!this._growStep) return this;
|
|
11241
|
+
const step = Number(count2) > 0 ? Math.trunc(Number(count2)) : this._growStep;
|
|
11242
|
+
const before = this._rendered;
|
|
11243
|
+
this._rendered = Math.min(this._data.length, this._rendered + step);
|
|
11244
|
+
if (this._rendered === before) return this;
|
|
11245
|
+
this._renderBody();
|
|
11246
|
+
this.emit("grow", { rendered: this._rendered, total: this._data.length });
|
|
11247
|
+
return this;
|
|
11248
|
+
}
|
|
11249
|
+
/**
|
|
11250
|
+
* Renders every remaining row.
|
|
11251
|
+
* @returns {this}
|
|
11252
|
+
* @fires Table#grow
|
|
11253
|
+
*/
|
|
11254
|
+
showAll() {
|
|
11255
|
+
return this.growBy(this._data.length);
|
|
11256
|
+
}
|
|
11257
|
+
/**
|
|
11258
|
+
* How many rows are currently rendered.
|
|
11259
|
+
* @returns {number}
|
|
11260
|
+
*/
|
|
11261
|
+
getRenderedCount() {
|
|
11262
|
+
return Math.min(this._rendered, this._data.length);
|
|
11263
|
+
}
|
|
11264
|
+
/**
|
|
11265
|
+
* Keeps the "show more" control in step with what is rendered.
|
|
11266
|
+
*
|
|
11267
|
+
* The control sits outside the table rather than in a `<tfoot>` row spanning every column: it is
|
|
11268
|
+
* a command, not data, and a button inside the grid would be reachable by the row navigation
|
|
11269
|
+
* keys as though it were a cell.
|
|
11270
|
+
* @returns {void}
|
|
11271
|
+
*/
|
|
11272
|
+
_syncGrowing() {
|
|
11273
|
+
if (!this._growStep) return;
|
|
11274
|
+
const remaining = this._data.length - this.getRenderedCount();
|
|
11275
|
+
if (remaining <= 0) {
|
|
11276
|
+
this._more?.remove();
|
|
11277
|
+
this._more = null;
|
|
11278
|
+
return;
|
|
11279
|
+
}
|
|
11280
|
+
const label = this._message("table.more", "Show %1 more", [remaining]);
|
|
11281
|
+
if (!this._more) {
|
|
11282
|
+
this._more = h("button", {
|
|
11283
|
+
class: "zx-table__more",
|
|
11284
|
+
type: "button",
|
|
11285
|
+
onclick: () => this.growBy()
|
|
11286
|
+
});
|
|
11287
|
+
this.el.append(this._more);
|
|
11288
|
+
}
|
|
11289
|
+
this._more.textContent = label;
|
|
11290
|
+
this._more.setAttribute("aria-label", label);
|
|
11291
|
+
}
|
|
11292
|
+
/**
|
|
11293
|
+
* Resolves a localized message, falling back to a built-in template.
|
|
11294
|
+
* @param {string} key Message key.
|
|
11295
|
+
* @param {string} fallback Template used when the host has no translation.
|
|
11296
|
+
* @param {unknown[]} args Positional interpolation values.
|
|
11297
|
+
* @returns {string}
|
|
11298
|
+
*/
|
|
11299
|
+
_message(key, fallback, args) {
|
|
11300
|
+
const message = this.msg(key, ...args);
|
|
11301
|
+
return message === key ? printf(fallback, args) : message;
|
|
11302
|
+
}
|
|
11303
|
+
/**
|
|
11304
|
+
* Watches the table's own width and stacks the rows below `responsive`.
|
|
11305
|
+
*
|
|
11306
|
+
* The width comes from `onBreakpoint` observing this element rather than the window, which is the
|
|
11307
|
+
* whole point of the option: a table inside a split pane or a modal has no idea how wide the
|
|
11308
|
+
* viewport is, and a media query would stack it on a phone while leaving it unreadable in a
|
|
11309
|
+
* 320px pane on a desktop.
|
|
11310
|
+
* @returns {void}
|
|
11311
|
+
*/
|
|
11312
|
+
_watchWidth() {
|
|
11313
|
+
this._width?.destroy();
|
|
11314
|
+
this._width = null;
|
|
11315
|
+
const threshold = this.options.responsive;
|
|
11316
|
+
if (!threshold || !(threshold in breakpoints)) return;
|
|
11317
|
+
this._width = onBreakpoint(
|
|
11318
|
+
(_name, width) => this._setStacked(width > 0 && width < breakpoints[threshold]),
|
|
11319
|
+
{ target: this.el }
|
|
11320
|
+
);
|
|
11321
|
+
}
|
|
11322
|
+
/**
|
|
11323
|
+
* Enters or leaves stacked mode.
|
|
11324
|
+
* @param {boolean} stacked Whether rows should stack.
|
|
11325
|
+
* @returns {void}
|
|
11326
|
+
* @fires Table#stackedchange
|
|
11327
|
+
*/
|
|
11328
|
+
_setStacked(stacked) {
|
|
11329
|
+
if (this._stacked === stacked) return;
|
|
11330
|
+
this._stacked = stacked;
|
|
11331
|
+
this.el.toggleAttribute("data-stacked", stacked);
|
|
11332
|
+
this._applyStackedRoles(stacked);
|
|
11333
|
+
this.emit("stackedchange", { stacked });
|
|
11334
|
+
}
|
|
11335
|
+
/**
|
|
11336
|
+
* States the table roles explicitly while stacked, and removes them again on the way out.
|
|
11337
|
+
*
|
|
11338
|
+
* Stacking works by changing `display` on the table elements, and a table whose display is not
|
|
11339
|
+
* `table` loses its implicit ARIA roles — leaving a screen reader with a pile of generic blocks
|
|
11340
|
+
* where a table used to be. The roles are only asserted while the layout has taken them away.
|
|
11341
|
+
* @param {boolean} stacked Whether the roles should be present.
|
|
11342
|
+
* @returns {void}
|
|
11343
|
+
*/
|
|
11344
|
+
_applyStackedRoles(stacked) {
|
|
11345
|
+
const parts = [[this._table, "table"], [this._thead, "rowgroup"], [this._tbody, "rowgroup"]];
|
|
11346
|
+
for (const [element, role] of parts) {
|
|
11347
|
+
if (!element) continue;
|
|
11348
|
+
if (stacked) element.setAttribute("role", role);
|
|
11349
|
+
else element.removeAttribute("role");
|
|
11350
|
+
}
|
|
11351
|
+
for (const [selector, role] of [["tr", "row"], ["td", "cell"], ["th", "columnheader"]]) {
|
|
11352
|
+
for (const element of this._table.querySelectorAll(selector)) {
|
|
11353
|
+
if (stacked) element.setAttribute("role", role);
|
|
11354
|
+
else element.removeAttribute("role");
|
|
11355
|
+
}
|
|
11356
|
+
}
|
|
11357
|
+
}
|
|
11358
|
+
/**
|
|
11359
|
+
* Reports whether the rows are currently stacked.
|
|
11360
|
+
* @returns {boolean}
|
|
11361
|
+
*/
|
|
11362
|
+
isStacked() {
|
|
11363
|
+
return Boolean(this._stacked);
|
|
11364
|
+
}
|
|
11112
11365
|
/** Restores an enhanced target and releases all component listeners. @returns {void} */
|
|
11113
11366
|
destroy() {
|
|
11114
11367
|
this._teardownEdit();
|
|
11368
|
+
this._width?.destroy();
|
|
11369
|
+
this._width = null;
|
|
11115
11370
|
if (this.el) delete this.el.dataset.editMode;
|
|
11116
11371
|
if (!this._restored && this._originalChildren) {
|
|
11117
11372
|
this.el.replaceChildren(...this._originalChildren);
|
|
@@ -11196,17 +11451,35 @@ var zx = (() => {
|
|
|
11196
11451
|
this._rovingCell = null;
|
|
11197
11452
|
this._rovingMatched = false;
|
|
11198
11453
|
if (this._data.length === 0) {
|
|
11199
|
-
const text4 = this.options.emptyText == null ? this.msg("table.empty") : String(this.options.emptyText);
|
|
11200
11454
|
fragment.append(h(
|
|
11201
11455
|
"tr",
|
|
11202
11456
|
{ class: "zx-table__empty-row" },
|
|
11203
|
-
h("td", {
|
|
11457
|
+
h("td", {
|
|
11458
|
+
class: "zx-table__empty",
|
|
11459
|
+
colspan: this._columns.length + (this.options.selectable === "multi" ? 1 : 0)
|
|
11460
|
+
}, this._emptyContent())
|
|
11204
11461
|
));
|
|
11205
11462
|
} else {
|
|
11206
|
-
this.
|
|
11463
|
+
this._visibleData().forEach((row2, index) => fragment.append(this._createRow(row2, index)));
|
|
11207
11464
|
}
|
|
11208
11465
|
this._tbody.replaceChildren(fragment);
|
|
11209
11466
|
this._syncSelectAll();
|
|
11467
|
+
this._syncGrowing();
|
|
11468
|
+
if (this._stacked) this._applyStackedRoles(true);
|
|
11469
|
+
}
|
|
11470
|
+
/**
|
|
11471
|
+
* What to put in the empty row.
|
|
11472
|
+
*
|
|
11473
|
+
* An empty table is a screen in its own right — the place to say why there is nothing and what to
|
|
11474
|
+
* do about it — so this takes a node as readily as a string. A function is re-called on every
|
|
11475
|
+
* render, which matters when the placeholder contains a button: reusing one node would move the
|
|
11476
|
+
* same element between renders and quietly share its listeners.
|
|
11477
|
+
* @returns {Node|string}
|
|
11478
|
+
*/
|
|
11479
|
+
_emptyContent() {
|
|
11480
|
+
const empty = this.options.emptyText;
|
|
11481
|
+
if (empty == null) return this.msg("table.empty");
|
|
11482
|
+
return typeof empty === "function" ? empty() : empty;
|
|
11210
11483
|
}
|
|
11211
11484
|
/** @param {TableRow} row @param {number} index @returns {HTMLTableRowElement} */
|
|
11212
11485
|
_createRow(row2, index) {
|
|
@@ -11237,6 +11510,8 @@ var zx = (() => {
|
|
|
11237
11510
|
h("td")
|
|
11238
11511
|
);
|
|
11239
11512
|
if (column.align) cell.dataset.align = column.align;
|
|
11513
|
+
cell.dataset.label = column.label;
|
|
11514
|
+
if (column.popin === false) cell.dataset.popin = "false";
|
|
11240
11515
|
if (this._editMode !== false) {
|
|
11241
11516
|
cell.dataset.column = column.id;
|
|
11242
11517
|
if (resolveEditable(column, row2) !== false) {
|
|
@@ -11855,6 +12130,10 @@ var zx = (() => {
|
|
|
11855
12130
|
function sameSet(left, right) {
|
|
11856
12131
|
return left.size === right.size && [...left].every((value) => right.has(value));
|
|
11857
12132
|
}
|
|
12133
|
+
function growStep(growing) {
|
|
12134
|
+
const step = Math.trunc(Number(growing));
|
|
12135
|
+
return Number.isFinite(step) && step > 0 ? step : null;
|
|
12136
|
+
}
|
|
11858
12137
|
|
|
11859
12138
|
// src/elements/reflect.js
|
|
11860
12139
|
var INVALID_ATTRIBUTE = /* @__PURE__ */ Symbol("invalid attribute");
|