@editora/ui-core 0.1.19 → 0.1.20
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/dist/{ElementBase-1b301e7f.js → ElementBase-EV6mVBUV.js} +1 -1
- package/dist/{ElementBase-909688f3.mjs → ElementBase-YlTLMsGk.mjs} +3 -3
- package/dist/accordion.cjs.js +3 -3
- package/dist/accordion.esm.js +39 -62
- package/dist/alert-dialog.cjs.js +19 -19
- package/dist/alert-dialog.esm.js +69 -87
- package/dist/alert.cjs.js +1 -1
- package/dist/alert.esm.js +4 -7
- package/dist/anchor.cjs.js +2 -2
- package/dist/anchor.esm.js +3 -3
- package/dist/animated-beam.cjs.js +83 -83
- package/dist/animated-beam.esm.js +250 -277
- package/dist/animated-list.cjs.js +4 -4
- package/dist/animated-list.esm.js +47 -61
- package/dist/animated-text.cjs.js +2 -2
- package/dist/animated-text.esm.js +13 -24
- package/dist/app-header.cjs.js +3 -3
- package/dist/app-header.esm.js +11 -13
- package/dist/aspect-ratio.cjs.js +1 -1
- package/dist/aspect-ratio.esm.js +4 -7
- package/dist/avatar.cjs.js +1 -1
- package/dist/avatar.esm.js +7 -13
- package/dist/badge.cjs.js +1 -1
- package/dist/badge.esm.js +4 -7
- package/dist/block-controls.cjs.js +2 -2
- package/dist/block-controls.esm.js +19 -35
- package/dist/box.cjs.js +1 -1
- package/dist/box.esm.js +8 -15
- package/dist/breadcrumb.cjs.js +2 -2
- package/dist/breadcrumb.esm.js +20 -37
- package/dist/button.cjs.js +1 -521
- package/dist/button.esm.js +2 -671
- package/dist/{calendar-2c11b824.mjs → calendar-DLY4acgn.mjs} +293 -342
- package/dist/{calendar-a8735e40.js → calendar-Dkof-FTK.js} +25 -25
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +8 -9
- package/dist/card.cjs.js +4 -4
- package/dist/card.esm.js +13 -19
- package/dist/chart.cjs.js +64 -64
- package/dist/chart.esm.js +223 -254
- package/dist/checkbox.cjs.js +1 -1
- package/dist/checkbox.esm.js +2 -3
- package/dist/collapsible.cjs.js +1 -1
- package/dist/collapsible.esm.js +5 -9
- package/dist/{collection-a1aac0c6.mjs → collection-C7URGjEI.mjs} +8 -14
- package/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +4 -7
- package/dist/color-picker.cjs.js +9 -9
- package/dist/color-picker.esm.js +189 -252
- package/dist/combobox.cjs.js +13 -13
- package/dist/combobox.esm.js +93 -126
- package/dist/command-palette.cjs.js +3 -3
- package/dist/command-palette.esm.js +19 -30
- package/dist/command.cjs.js +4 -4
- package/dist/command.esm.js +41 -53
- package/dist/components/ui-orbiter.d.ts.map +1 -1
- package/dist/components/ui-skeleton.d.ts.map +1 -1
- package/dist/components/ui-split-button.d.ts +1 -0
- package/dist/components/ui-split-button.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/container.cjs.js +2 -2
- package/dist/container.esm.js +2 -3
- package/dist/context-menu.cjs.js +8 -8
- package/dist/context-menu.esm.js +157 -219
- package/dist/control-group.cjs.js +1 -1
- package/dist/control-group.esm.js +2 -3
- package/dist/data-table.cjs.js +4 -4
- package/dist/data-table.esm.js +299 -381
- package/dist/date-field.cjs.js +3 -3
- package/dist/date-field.esm.js +68 -80
- package/dist/date-picker.cjs.js +9 -9
- package/dist/date-picker.esm.js +69 -97
- package/dist/date-range-picker.cjs.js +3 -3
- package/dist/date-range-picker.esm.js +32 -56
- package/dist/date-range-time-picker.cjs.js +9 -9
- package/dist/date-range-time-picker.esm.js +111 -140
- package/dist/date-time-picker.cjs.js +4 -4
- package/dist/date-time-picker.esm.js +112 -144
- package/dist/date-time-utils-Dmost5Ee.js +1 -0
- package/dist/date-time-utils-y1N2gvG2.mjs +268 -0
- package/dist/description.cjs.js +1 -1
- package/dist/description.esm.js +3 -5
- package/dist/dialog.cjs.js +12 -12
- package/dist/dialog.esm.js +44 -63
- package/dist/direction-provider.cjs.js +1 -1
- package/dist/direction-provider.esm.js +2 -3
- package/dist/{dismissable-layer-9c7e6b58.mjs → dismissable-layer-BmPIoK80.mjs} +29 -33
- package/dist/dismissable-layer-DNfrKA20.js +1 -0
- package/dist/dismissable-layer.cjs.js +2 -2
- package/dist/dismissable-layer.esm.js +4 -6
- package/dist/dock.cjs.js +5 -5
- package/dist/dock.esm.js +134 -155
- package/dist/drawer.cjs.js +2 -2
- package/dist/drawer.esm.js +18 -35
- package/dist/dropdown.cjs.js +2 -2
- package/dist/dropdown.esm.js +119 -149
- package/dist/dropzone.cjs.js +1 -1
- package/dist/dropzone.esm.js +0 -1
- package/dist/empty-state.cjs.js +1 -1
- package/dist/empty-state.esm.js +1 -1
- package/dist/field-error.cjs.js +1 -1
- package/dist/field-error.esm.js +3 -5
- package/dist/field.cjs.js +5 -5
- package/dist/field.esm.js +27 -34
- package/dist/fieldset.cjs.js +4 -4
- package/dist/fieldset.esm.js +19 -24
- package/dist/file-upload.cjs.js +4 -4
- package/dist/file-upload.esm.js +69 -93
- package/dist/flex.cjs.js +1 -1
- package/dist/flex.esm.js +5 -9
- package/dist/floating-toolbar.cjs.js +4 -4
- package/dist/floating-toolbar.esm.js +60 -85
- package/dist/focus-scope-Bwug2gDv.js +1 -0
- package/dist/{focus-scope-103833ee.mjs → focus-scope-CmEsG5UZ.mjs} +39 -48
- package/dist/focus-scope.cjs.js +2 -2
- package/dist/focus-scope.esm.js +15 -20
- package/dist/form.cjs.js +2 -2
- package/dist/form.esm.js +26 -53
- package/dist/gantt.cjs.js +43 -43
- package/dist/gantt.esm.js +295 -322
- package/dist/grid.cjs.js +1 -1
- package/dist/grid.esm.js +5 -9
- package/dist/hover-card.cjs.js +4 -4
- package/dist/hover-card.esm.js +22 -28
- package/dist/icon-cloud.cjs.js +7 -7
- package/dist/icon-cloud.esm.js +48 -62
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +2 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +378 -390
- package/dist/inline-edit.cjs.js +11 -11
- package/dist/inline-edit.esm.js +32 -36
- package/dist/input.cjs.js +17 -17
- package/dist/input.esm.js +50 -63
- package/dist/label.cjs.js +2 -2
- package/dist/label.esm.js +8 -17
- package/dist/layout.cjs.js +2 -2
- package/dist/layout.esm.js +20 -26
- package/dist/listbox-B6QgECax.js +46 -0
- package/dist/listbox-DJamVeFj.mjs +200 -0
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.esm.js +2 -4
- package/dist/marquee.cjs.js +5 -5
- package/dist/marquee.esm.js +33 -50
- package/dist/masonry-grid.cjs.js +1 -1
- package/dist/masonry-grid.esm.js +5 -9
- package/dist/menu.cjs.js +3 -3
- package/dist/menu.esm.js +106 -126
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +118 -164
- package/dist/meter.cjs.js +2 -2
- package/dist/meter.esm.js +4 -4
- package/dist/multi-select.cjs.js +4 -4
- package/dist/multi-select.esm.js +120 -140
- package/dist/navigation-menu.cjs.js +4 -4
- package/dist/navigation-menu.esm.js +44 -55
- package/dist/number-field.cjs.js +2 -2
- package/dist/number-field.esm.js +73 -98
- package/dist/number-ticker.cjs.js +3 -3
- package/dist/number-ticker.esm.js +22 -43
- package/dist/odometer.cjs.js +1 -1
- package/dist/odometer.esm.js +5 -9
- package/dist/orbiter.cjs.js +13 -13
- package/dist/orbiter.esm.js +79 -90
- package/dist/{overlayManager-5bbd4dc3.mjs → overlayManager-BJjU1VA8.mjs} +4 -5
- package/dist/{overlayManager-0eda4e08.js → overlayManager-CSy3fJmJ.js} +1 -1
- package/dist/pagination.cjs.js +2 -2
- package/dist/pagination.esm.js +14 -18
- package/dist/{panel-group-a376cc5e.mjs → panel-group-8sVNnGxg.mjs} +24 -46
- package/dist/panel-group-CaD0_KQf.js +36 -0
- package/dist/panel-group.cjs.js +1 -1
- package/dist/panel-group.esm.js +2 -5
- package/dist/panel.cjs.js +4 -4
- package/dist/panel.esm.js +8 -10
- package/dist/password-field.cjs.js +9 -9
- package/dist/password-field.esm.js +62 -82
- package/dist/pin-input.cjs.js +3 -3
- package/dist/pin-input.esm.js +33 -39
- package/dist/placement-grid.cjs.js +4 -4
- package/dist/placement-grid.esm.js +108 -131
- package/dist/plugin-panel.cjs.js +7 -7
- package/dist/plugin-panel.esm.js +13 -15
- package/dist/popover.cjs.js +2 -2
- package/dist/popover.esm.js +21 -31
- package/dist/portal-DgpQ3Jo1.js +1 -0
- package/dist/{portal-fe73e5cc.mjs → portal-bR42gHvG.mjs} +43 -48
- package/dist/portal.cjs.js +2 -2
- package/dist/portal.esm.js +10 -19
- package/dist/{positioner-e9770c66.mjs → positioner-D0VGxtYU.mjs} +189 -209
- package/dist/positioner-D_fqyx_j.js +1 -0
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +11 -18
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +7 -13
- package/dist/progress.cjs.js +1 -1
- package/dist/progress.esm.js +5 -9
- package/dist/quick-actions.cjs.js +6 -6
- package/dist/quick-actions.esm.js +52 -62
- package/dist/radio-group.cjs.js +13 -13
- package/dist/radio-group.esm.js +39 -51
- package/dist/radio.cjs.js +1 -1
- package/dist/radio.esm.js +5 -9
- package/dist/rating.cjs.js +1 -1
- package/dist/rating.esm.js +12 -23
- package/dist/{roving-focus-group-4350c9a7.mjs → roving-focus-group-Dbm1Jko_.mjs} +3 -6
- package/dist/roving-focus-group.cjs.js +1 -1
- package/dist/roving-focus-group.esm.js +3 -5
- package/dist/runtime-CTaOSmBj.js +1 -0
- package/dist/{runtime-161f68a2.mjs → runtime-D1gFh1fS.mjs} +338 -366
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +6 -6
- package/dist/scroll-area.cjs.js +3 -3
- package/dist/scroll-area.esm.js +38 -46
- package/dist/{scroll-lock-31da444f.mjs → scroll-lock-LfqXXqsu.mjs} +5 -9
- package/dist/section.cjs.js +1 -1
- package/dist/section.esm.js +1 -1
- package/dist/select.cjs.js +7 -7
- package/dist/select.esm.js +67 -97
- package/dist/selection-popup.cjs.js +1 -1
- package/dist/selection-popup.esm.js +8 -15
- package/dist/separator.cjs.js +1 -1
- package/dist/separator.esm.js +1 -1
- package/dist/sidebar.cjs.js +18 -18
- package/dist/sidebar.esm.js +117 -139
- package/dist/skeleton.cjs.js +11 -11
- package/dist/skeleton.esm.js +27 -24
- package/dist/slider.cjs.js +1 -1
- package/dist/slider.esm.js +6 -11
- package/dist/slot.cjs.js +4 -4
- package/dist/slot.esm.js +16 -19
- package/dist/sortable.cjs.js +45 -45
- package/dist/sortable.esm.js +421 -524
- package/dist/spinning-text.cjs.js +12 -12
- package/dist/spinning-text.esm.js +80 -92
- package/dist/split-button.cjs.js +4 -4
- package/dist/split-button.esm.js +77 -62
- package/dist/splitter.cjs.js +1 -1
- package/dist/splitter.esm.js +1 -1
- package/dist/stepper.cjs.js +8 -8
- package/dist/stepper.esm.js +32 -52
- package/dist/switch.cjs.js +7 -7
- package/dist/switch.esm.js +23 -31
- package/dist/table.cjs.js +2 -2
- package/dist/table.esm.js +46 -56
- package/dist/tabs.cjs.js +3 -3
- package/dist/tabs.esm.js +35 -55
- package/dist/tags-input.cjs.js +4 -4
- package/dist/tags-input.esm.js +45 -62
- package/dist/textarea.cjs.js +6 -6
- package/dist/textarea.esm.js +32 -41
- package/dist/time-field.cjs.js +4 -4
- package/dist/time-field.esm.js +70 -84
- package/dist/time-picker.cjs.js +22 -22
- package/dist/time-picker.esm.js +88 -110
- package/dist/timeline.cjs.js +1 -1
- package/dist/timeline.esm.js +3 -5
- package/dist/toast.cjs.js +2 -2
- package/dist/toast.esm.js +33 -47
- package/dist/toggle-group.cjs.js +6 -6
- package/dist/toggle-group.esm.js +85 -105
- package/dist/toggle.cjs.js +1 -1
- package/dist/toggle.esm.js +3 -5
- package/dist/toolbar.cjs.js +1 -1
- package/dist/toolbar.esm.js +13 -24
- package/dist/tooltip.cjs.js +2 -2
- package/dist/tooltip.esm.js +31 -42
- package/dist/transfer-list.cjs.js +19 -19
- package/dist/transfer-list.esm.js +98 -111
- package/dist/{tree-dcd74a4a.mjs → tree-B3kE8ESs.mjs} +55 -62
- package/dist/tree-Dx_kv_ih.js +39 -0
- package/dist/tree-item.cjs.js +2 -2
- package/dist/tree-item.esm.js +2 -3
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +2 -5
- package/dist/ui-button-Q0GNNWKC.mjs +665 -0
- package/dist/ui-button-rXQOS9QJ.js +521 -0
- package/dist/{icon-9e9da03b.js → ui-icon-BzVNC_lr.js} +4 -4
- package/dist/{icon-e2a85cc1.mjs → ui-icon-YI6lyuqU.mjs} +58 -65
- package/dist/visually-hidden.cjs.js +1 -1
- package/dist/visually-hidden.esm.js +1 -1
- package/dist/wizard.cjs.js +14 -14
- package/dist/wizard.esm.js +85 -105
- package/package.json +2 -2
- package/dist/date-time-utils-66480de4.js +0 -1
- package/dist/date-time-utils-a2c7af25.mjs +0 -307
- package/dist/dismissable-layer-193e3bed.js +0 -1
- package/dist/focus-scope-2b12b4e7.js +0 -1
- package/dist/listbox-308789a0.mjs +0 -210
- package/dist/listbox-ef2f708e.js +0 -46
- package/dist/panel-group-40254cdd.js +0 -36
- package/dist/portal-c69756c0.js +0 -1
- package/dist/positioner-33529bb8.js +0 -1
- package/dist/runtime-3f13807b.js +0 -1
- package/dist/tree-0a7a8d05.js +0 -39
- /package/dist/{collection-a2969ad2.js → collection-qv8A8rq4.js} +0 -0
- /package/dist/{menu-item-styles-27fdbac4.mjs → menu-item-styles-CZiPwPwl.mjs} +0 -0
- /package/dist/{menu-item-styles-83ad1e22.js → menu-item-styles-CbNUEwP2.js} +0 -0
- /package/dist/{roving-focus-group-5c059bf9.js → roving-focus-group-BdJ_4Njm.js} +0 -0
- /package/dist/{scroll-lock-d7b0df21.js → scroll-lock-BX6e3Ced.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as D } from "./ElementBase-
|
|
1
|
+
import { E as D } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
2
|
const q = `
|
|
3
3
|
:host {
|
|
4
4
|
--ui-transfer-accent: var(--ui-color-primary, #2563eb);
|
|
@@ -661,69 +661,63 @@ const q = `
|
|
|
661
661
|
function l(n) {
|
|
662
662
|
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
663
663
|
}
|
|
664
|
-
function
|
|
665
|
-
if (!n)
|
|
666
|
-
return [];
|
|
664
|
+
function x(n) {
|
|
665
|
+
if (!n) return [];
|
|
667
666
|
try {
|
|
668
|
-
const
|
|
669
|
-
if (!Array.isArray(
|
|
670
|
-
return [];
|
|
667
|
+
const e = JSON.parse(n);
|
|
668
|
+
if (!Array.isArray(e)) return [];
|
|
671
669
|
const t = [];
|
|
672
|
-
return
|
|
673
|
-
if (!
|
|
674
|
-
return;
|
|
670
|
+
return e.forEach((r) => {
|
|
671
|
+
if (!r || typeof r != "object") return;
|
|
675
672
|
const a = {
|
|
676
|
-
value: String(
|
|
677
|
-
label: String(
|
|
678
|
-
disabled: !!
|
|
673
|
+
value: String(r.value ?? ""),
|
|
674
|
+
label: String(r.label ?? r.value ?? ""),
|
|
675
|
+
disabled: !!r.disabled
|
|
679
676
|
};
|
|
680
|
-
|
|
677
|
+
r.description && (a.description = String(r.description)), a.value && t.push(a);
|
|
681
678
|
}), t;
|
|
682
679
|
} catch {
|
|
683
680
|
return [];
|
|
684
681
|
}
|
|
685
682
|
}
|
|
686
|
-
function
|
|
687
|
-
if (!n)
|
|
688
|
-
return [];
|
|
683
|
+
function z(n) {
|
|
684
|
+
if (!n) return [];
|
|
689
685
|
try {
|
|
690
|
-
const
|
|
691
|
-
return Array.isArray(
|
|
686
|
+
const e = JSON.parse(n);
|
|
687
|
+
return Array.isArray(e) ? e.map((t) => String(t)) : [];
|
|
692
688
|
} catch {
|
|
693
689
|
return [];
|
|
694
690
|
}
|
|
695
691
|
}
|
|
696
|
-
function
|
|
697
|
-
return new Set(Array.from(n).filter((t) =>
|
|
692
|
+
function y(n, e) {
|
|
693
|
+
return new Set(Array.from(n).filter((t) => e.has(t)));
|
|
698
694
|
}
|
|
699
695
|
function R(n) {
|
|
700
696
|
return n === "tick" || n === "none" ? n : "checkbox";
|
|
701
697
|
}
|
|
702
|
-
function
|
|
703
|
-
return n == null ?
|
|
698
|
+
function p(n, e) {
|
|
699
|
+
return n == null ? e : n === "" || n === "true" || n === "1" || n === "yes" ? !0 : n === "false" || n === "0" || n === "no" ? !1 : e;
|
|
704
700
|
}
|
|
705
|
-
function
|
|
701
|
+
function _(n) {
|
|
706
702
|
return `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true"><path d="${n === "right" ? "M9 6l6 6-6 6" : "M15 6l-6 6 6 6"}"/></svg>`;
|
|
707
703
|
}
|
|
708
704
|
class U extends D {
|
|
709
705
|
constructor() {
|
|
710
|
-
super(...arguments), this._options = [], this._value = [], this._selectedAvailable = /* @__PURE__ */ new Set(), this._selectedChosen = /* @__PURE__ */ new Set(), this._formUnregister = null, this._suppressValueAttr = !1, this._delegatedListenersAttached = !1, this._handleRootClick = (
|
|
711
|
-
const t =
|
|
712
|
-
if (!t)
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
this._move(e.getAttribute("data-action"));
|
|
706
|
+
super(...arguments), this._options = [], this._value = [], this._selectedAvailable = /* @__PURE__ */ new Set(), this._selectedChosen = /* @__PURE__ */ new Set(), this._formUnregister = null, this._suppressValueAttr = !1, this._delegatedListenersAttached = !1, this._handleRootClick = (e) => {
|
|
707
|
+
const t = e.target;
|
|
708
|
+
if (!t) return;
|
|
709
|
+
const r = t.closest(".move-btn");
|
|
710
|
+
if (r && this.root.contains(r)) {
|
|
711
|
+
this._move(r.getAttribute("data-action"));
|
|
717
712
|
return;
|
|
718
713
|
}
|
|
719
714
|
const a = t.closest(".item");
|
|
720
715
|
a && this.root.contains(a) && this._toggleItem(a);
|
|
721
|
-
}, this._handleRootKeyDown = (
|
|
722
|
-
const t =
|
|
723
|
-
if (!t)
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
e && this.root.contains(e) && this._onItemKeyDown(r, e);
|
|
716
|
+
}, this._handleRootKeyDown = (e) => {
|
|
717
|
+
const t = e.target;
|
|
718
|
+
if (!t) return;
|
|
719
|
+
const r = t.closest(".item");
|
|
720
|
+
r && this.root.contains(r) && this._onItemKeyDown(e, r);
|
|
727
721
|
};
|
|
728
722
|
}
|
|
729
723
|
static get observedAttributes() {
|
|
@@ -755,8 +749,8 @@ class U extends D {
|
|
|
755
749
|
get value() {
|
|
756
750
|
return [...this._value];
|
|
757
751
|
}
|
|
758
|
-
set value(
|
|
759
|
-
this._applyValue(
|
|
752
|
+
set value(e) {
|
|
753
|
+
this._applyValue(e, "api");
|
|
760
754
|
}
|
|
761
755
|
connectedCallback() {
|
|
762
756
|
super.connectedCallback(), this._attachDelegatedListeners(), this._registerWithForm();
|
|
@@ -764,14 +758,14 @@ class U extends D {
|
|
|
764
758
|
disconnectedCallback() {
|
|
765
759
|
this._formUnregister && this._formUnregister(), this._detachDelegatedListeners(), super.disconnectedCallback();
|
|
766
760
|
}
|
|
767
|
-
attributeChangedCallback(
|
|
768
|
-
t !==
|
|
761
|
+
attributeChangedCallback(e, t, r) {
|
|
762
|
+
t !== r && (e === "options" && (this._options = x(r)), e === "value" && !this._suppressValueAttr && (this._value = z(r)), e === "name" && this.isConnected && this._registerWithForm(), e === "disabled" && (this._selectedAvailable.clear(), this._selectedChosen.clear()), this.isConnected && this.requestRender());
|
|
769
763
|
}
|
|
770
764
|
render() {
|
|
771
|
-
this._options.length || (this._options =
|
|
772
|
-
const
|
|
773
|
-
this._selectedAvailable =
|
|
774
|
-
const s = this.getAttribute("label") || "", c = this.getAttribute("description") || "", u = this.getAttribute("error") || "",
|
|
765
|
+
this._options.length || (this._options = x(this.getAttribute("options"))), !this._value.length && this.getAttribute("value") && (this._value = z(this.getAttribute("value")));
|
|
766
|
+
const e = new Set(this._value), t = this._options.filter((i) => !e.has(i.value)), r = this._options.filter((i) => e.has(i.value)), a = new Set(t.map((i) => i.value)), o = new Set(r.map((i) => i.value));
|
|
767
|
+
this._selectedAvailable = y(this._selectedAvailable, a), this._selectedChosen = y(this._selectedChosen, o);
|
|
768
|
+
const s = this.getAttribute("label") || "", c = this.getAttribute("description") || "", u = this.getAttribute("error") || "", k = this.getAttribute("available-label") || "Available", w = this.getAttribute("selected-label") || "Selected", A = this.getAttribute("available-empty-label") || "No items available to add.", $ = this.getAttribute("selected-empty-label") || "No items selected yet.", C = R(this.getAttribute("selection-indicator")), S = this.getAttribute("add-action-label") || "Add selected", L = this.getAttribute("remove-action-label") || "Remove selected", d = p(this.getAttribute("show-action-labels"), !0), f = p(this.getAttribute("show-action-counts"), !0), b = p(this.getAttribute("show-panel-counts"), !0), h = this.getAttribute("radius"), E = h ? ` style="--ui-transfer-panel-radius:${l(h)};"` : "", m = () => C === "none" ? "" : '<span class="indicator" part="indicator" aria-hidden="true"><span class="indicator-box"><span class="indicator-mark">✓</span></span></span>', g = (i) => d ? `<span class="move-btn-text">${l(i)}</span>` : "", v = (i) => f ? `<span class="move-btn-count">${i}</span>` : "", I = t.length ? t.map(
|
|
775
769
|
(i) => `<div
|
|
776
770
|
class="item"
|
|
777
771
|
part="item available-item"
|
|
@@ -783,13 +777,13 @@ class U extends D {
|
|
|
783
777
|
aria-disabled="${i.disabled ? "true" : "false"}"
|
|
784
778
|
tabindex="${i.disabled ? "-1" : "0"}"
|
|
785
779
|
>
|
|
786
|
-
${
|
|
780
|
+
${m()}
|
|
787
781
|
<div class="item-copy">
|
|
788
782
|
<span class="item-title">${l(i.label)}</span>
|
|
789
783
|
${i.description ? `<span class="item-description">${l(i.description)}</span>` : ""}
|
|
790
784
|
</div>
|
|
791
785
|
</div>`
|
|
792
|
-
).join("") : `<div class="empty" part="empty">${l(A)}</div>`, V =
|
|
786
|
+
).join("") : `<div class="empty" part="empty">${l(A)}</div>`, V = r.length ? r.map(
|
|
793
787
|
(i) => `<div
|
|
794
788
|
class="item"
|
|
795
789
|
part="item selected-item"
|
|
@@ -801,7 +795,7 @@ class U extends D {
|
|
|
801
795
|
aria-disabled="${i.disabled ? "true" : "false"}"
|
|
802
796
|
tabindex="${i.disabled ? "-1" : "0"}"
|
|
803
797
|
>
|
|
804
|
-
${
|
|
798
|
+
${m()}
|
|
805
799
|
<div class="item-copy">
|
|
806
800
|
<span class="item-title">${l(i.label)}</span>
|
|
807
801
|
${i.description ? `<span class="item-description">${l(i.description)}</span>` : ""}
|
|
@@ -817,8 +811,8 @@ class U extends D {
|
|
|
817
811
|
<section class="panel" part="panel panel-available">
|
|
818
812
|
<div class="panel-header" part="panel-header">
|
|
819
813
|
<div class="panel-heading">
|
|
820
|
-
<div class="panel-title">${l(
|
|
821
|
-
${
|
|
814
|
+
<div class="panel-title">${l(k)}</div>
|
|
815
|
+
${b ? `<span class="panel-count" part="count">${t.length}</span>` : ""}
|
|
822
816
|
</div>
|
|
823
817
|
<div class="panel-help">Choose entries to move into the selected list.</div>
|
|
824
818
|
</div>
|
|
@@ -826,79 +820,73 @@ class U extends D {
|
|
|
826
820
|
<div class="summary" part="summary">${t.length} available</div>
|
|
827
821
|
</section>
|
|
828
822
|
<div class="actions" part="actions">
|
|
829
|
-
<button class="move-btn" part="action-button action-add" data-compact="${!
|
|
830
|
-
<span class="move-btn-icon" aria-hidden="true">${
|
|
831
|
-
${
|
|
832
|
-
${
|
|
823
|
+
<button class="move-btn" part="action-button action-add" data-compact="${!d && !f}" data-action="add" type="button"${this._selectedAvailable.size ? "" : " disabled"}>
|
|
824
|
+
<span class="move-btn-icon" aria-hidden="true">${_("right")}</span>
|
|
825
|
+
${g(S)}
|
|
826
|
+
${v(this._selectedAvailable.size || 0)}
|
|
833
827
|
</button>
|
|
834
|
-
<button class="move-btn" part="action-button action-remove" data-compact="${!
|
|
835
|
-
<span class="move-btn-icon" aria-hidden="true">${
|
|
836
|
-
${
|
|
837
|
-
${
|
|
828
|
+
<button class="move-btn" part="action-button action-remove" data-compact="${!d && !f}" data-action="remove" type="button"${this._selectedChosen.size ? "" : " disabled"}>
|
|
829
|
+
<span class="move-btn-icon" aria-hidden="true">${_("left")}</span>
|
|
830
|
+
${g(L)}
|
|
831
|
+
${v(this._selectedChosen.size || 0)}
|
|
838
832
|
</button>
|
|
839
833
|
</div>
|
|
840
834
|
<section class="panel" part="panel panel-selected">
|
|
841
835
|
<div class="panel-header" part="panel-header">
|
|
842
836
|
<div class="panel-heading">
|
|
843
|
-
<div class="panel-title">${l(
|
|
844
|
-
${
|
|
837
|
+
<div class="panel-title">${l(w)}</div>
|
|
838
|
+
${b ? `<span class="panel-count" part="count">${r.length}</span>` : ""}
|
|
845
839
|
</div>
|
|
846
840
|
<div class="panel-help">Use the remove action to send items back.</div>
|
|
847
841
|
</div>
|
|
848
842
|
<div class="list" part="list selected-list" data-list="chosen" role="listbox" aria-multiselectable="true">${V}</div>
|
|
849
|
-
<div class="summary" part="summary">${
|
|
843
|
+
<div class="summary" part="summary">${r.length} selected</div>
|
|
850
844
|
</section>
|
|
851
845
|
</div>
|
|
852
846
|
${u ? `<p class="error" part="error">${l(u)}</p>` : ""}
|
|
853
847
|
</div>
|
|
854
848
|
`);
|
|
855
849
|
}
|
|
856
|
-
_toggleItem(
|
|
857
|
-
if (this.hasAttribute("disabled"))
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
if (!e)
|
|
861
|
-
return;
|
|
850
|
+
_toggleItem(e) {
|
|
851
|
+
if (this.hasAttribute("disabled")) return;
|
|
852
|
+
const t = e.getAttribute("data-side"), r = e.getAttribute("data-value") || "";
|
|
853
|
+
if (!r) return;
|
|
862
854
|
const a = t === "chosen" ? this._selectedChosen : this._selectedAvailable;
|
|
863
|
-
a.has(
|
|
855
|
+
a.has(r) ? a.delete(r) : a.add(r), e.setAttribute("data-selected", a.has(r) ? "true" : "false"), e.setAttribute("aria-selected", a.has(r) ? "true" : "false"), this._syncActionButtons();
|
|
864
856
|
}
|
|
865
|
-
_onItemKeyDown(
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
if (
|
|
869
|
-
|
|
870
|
-
if (r.key === "Enter" || r.key === " ") {
|
|
871
|
-
r.preventDefault(), this._toggleItem(t);
|
|
857
|
+
_onItemKeyDown(e, t) {
|
|
858
|
+
const r = t.getAttribute("data-side");
|
|
859
|
+
if (!r) return;
|
|
860
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
861
|
+
e.preventDefault(), this._toggleItem(t);
|
|
872
862
|
return;
|
|
873
863
|
}
|
|
874
|
-
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(
|
|
875
|
-
|
|
876
|
-
r.
|
|
877
|
-
|
|
878
|
-
if (!o.length)
|
|
879
|
-
return;
|
|
864
|
+
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(e.key)) return;
|
|
865
|
+
e.preventDefault();
|
|
866
|
+
const a = this.root.querySelector(`[data-list="${r}"]`), o = Array.from(a?.querySelectorAll('.item[tabindex="0"]') || []);
|
|
867
|
+
if (!o.length) return;
|
|
880
868
|
const s = o.indexOf(t);
|
|
881
|
-
if (
|
|
882
|
-
|
|
869
|
+
if (e.key === "Home") {
|
|
870
|
+
o[0]?.focus();
|
|
883
871
|
return;
|
|
884
872
|
}
|
|
885
|
-
if (
|
|
886
|
-
|
|
873
|
+
if (e.key === "End") {
|
|
874
|
+
o[o.length - 1]?.focus();
|
|
887
875
|
return;
|
|
888
876
|
}
|
|
889
|
-
const c =
|
|
890
|
-
|
|
877
|
+
const c = e.key === "ArrowDown" ? Math.min(o.length - 1, s + 1) : Math.max(0, s - 1);
|
|
878
|
+
o[c]?.focus();
|
|
891
879
|
}
|
|
892
|
-
_move(
|
|
880
|
+
_move(e) {
|
|
893
881
|
if (!this.hasAttribute("disabled")) {
|
|
894
|
-
if (
|
|
895
|
-
const t = [...this._value, ...Array.from(this._selectedAvailable).filter((
|
|
882
|
+
if (e === "add") {
|
|
883
|
+
const t = [...this._value, ...Array.from(this._selectedAvailable).filter((r) => !this._value.includes(r))];
|
|
896
884
|
this._selectedAvailable.clear(), this._applyValue(t, "transfer-right");
|
|
897
885
|
return;
|
|
898
886
|
}
|
|
899
|
-
if (
|
|
900
|
-
const t = new Set(this._selectedChosen),
|
|
901
|
-
this._selectedChosen.clear(), this._applyValue(
|
|
887
|
+
if (e === "remove") {
|
|
888
|
+
const t = new Set(this._selectedChosen), r = this._value.filter((a) => !t.has(a));
|
|
889
|
+
this._selectedChosen.clear(), this._applyValue(r, "transfer-left");
|
|
902
890
|
}
|
|
903
891
|
}
|
|
904
892
|
}
|
|
@@ -908,8 +896,8 @@ class U extends D {
|
|
|
908
896
|
_detachDelegatedListeners() {
|
|
909
897
|
this._delegatedListenersAttached && (this.root.removeEventListener("click", this._handleRootClick), this.root.removeEventListener("keydown", this._handleRootKeyDown), this._delegatedListenersAttached = !1);
|
|
910
898
|
}
|
|
911
|
-
_applyValue(
|
|
912
|
-
const
|
|
899
|
+
_applyValue(e, t) {
|
|
900
|
+
const r = new Set(this._options.map((s) => s.value)), a = Array.from(new Set(e.filter((s) => s && (r.size === 0 || r.has(s))))), o = [...this._value];
|
|
913
901
|
this._value = a, this._suppressValueAttr = !0;
|
|
914
902
|
try {
|
|
915
903
|
a.length ? this.setAttribute("value", JSON.stringify(a)) : this.removeAttribute("value");
|
|
@@ -930,33 +918,32 @@ class U extends D {
|
|
|
930
918
|
);
|
|
931
919
|
}
|
|
932
920
|
_syncActionButtons() {
|
|
933
|
-
const
|
|
934
|
-
if (
|
|
935
|
-
|
|
936
|
-
const
|
|
937
|
-
|
|
921
|
+
const e = this.root.querySelector('[data-action="add"]'), t = this.root.querySelector('[data-action="remove"]');
|
|
922
|
+
if (e) {
|
|
923
|
+
e.disabled = this._selectedAvailable.size === 0;
|
|
924
|
+
const r = e.querySelector(".move-btn-count");
|
|
925
|
+
r && (r.textContent = String(this._selectedAvailable.size));
|
|
938
926
|
}
|
|
939
927
|
if (t) {
|
|
940
928
|
t.disabled = this._selectedChosen.size === 0;
|
|
941
|
-
const
|
|
942
|
-
|
|
929
|
+
const r = t.querySelector(".move-btn-count");
|
|
930
|
+
r && (r.textContent = String(this._selectedChosen.size));
|
|
943
931
|
}
|
|
944
932
|
}
|
|
945
933
|
_registerWithForm() {
|
|
946
|
-
var r;
|
|
947
934
|
this._formUnregister && (this._formUnregister(), this._formUnregister = null);
|
|
948
935
|
try {
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
name:
|
|
936
|
+
const a = this.getRootNode().host?.closest?.("ui-form") || null || this.closest("ui-form"), o = this.getAttribute("name");
|
|
937
|
+
a && typeof a.registerField == "function" && o && (this._formUnregister = a.registerField(o, {
|
|
938
|
+
name: o,
|
|
952
939
|
getValue: () => [...this._value],
|
|
953
|
-
setValue: (
|
|
954
|
-
const
|
|
955
|
-
this._applyValue(
|
|
940
|
+
setValue: (s) => {
|
|
941
|
+
const c = Array.isArray(s) ? s.map((u) => String(u)) : [];
|
|
942
|
+
this._applyValue(c, "api");
|
|
956
943
|
},
|
|
957
944
|
validate: async () => ({ valid: !this.hasAttribute("required") || this._value.length > 0, message: "Select at least one item." }),
|
|
958
|
-
setError: (
|
|
959
|
-
|
|
945
|
+
setError: (s) => {
|
|
946
|
+
s ? (this.setAttribute("error", s), this.setAttribute("invalid", "")) : (this.removeAttribute("error"), this.removeAttribute("invalid")), this.requestRender();
|
|
960
947
|
}
|
|
961
948
|
}));
|
|
962
949
|
} catch {
|
|
@@ -1,56 +1,55 @@
|
|
|
1
|
-
import { E as g } from "./ElementBase-
|
|
2
|
-
import { n as b } from "./collection-
|
|
1
|
+
import { E as g } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
import { n as b } from "./collection-C7URGjEI.mjs";
|
|
3
3
|
import { UITreeItem as f } from "./tree-item.esm.js";
|
|
4
|
-
function C(
|
|
5
|
-
const e = [], i = t.getExpanded || (() => !1), r = t.getDisabled || (() => !1), s = (
|
|
6
|
-
|
|
7
|
-
const u = t.getChildren(
|
|
8
|
-
item:
|
|
9
|
-
id: t.getId(
|
|
10
|
-
label: t.getLabel(
|
|
11
|
-
level:
|
|
12
|
-
parentId:
|
|
13
|
-
disabled: r(
|
|
14
|
-
expanded: i(
|
|
4
|
+
function C(l, t) {
|
|
5
|
+
const e = [], i = t.getExpanded || (() => !1), r = t.getDisabled || (() => !1), s = (d, n, o) => {
|
|
6
|
+
d.forEach((a) => {
|
|
7
|
+
const u = t.getChildren(a) || [], c = {
|
|
8
|
+
item: a,
|
|
9
|
+
id: t.getId(a),
|
|
10
|
+
label: t.getLabel(a),
|
|
11
|
+
level: n,
|
|
12
|
+
parentId: o,
|
|
13
|
+
disabled: r(a),
|
|
14
|
+
expanded: i(a),
|
|
15
15
|
hasChildren: u.length > 0
|
|
16
16
|
};
|
|
17
|
-
e.push(c), s(u,
|
|
17
|
+
e.push(c), s(u, n + 1, c.id);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
|
-
return s(
|
|
20
|
+
return s(l, 1, null), e;
|
|
21
21
|
}
|
|
22
|
-
function _(
|
|
23
|
-
const e = [], i = t.getExpanded || (() => !1), r = t.getDisabled || (() => !1), s = (
|
|
24
|
-
|
|
25
|
-
const u = t.getChildren(
|
|
26
|
-
item:
|
|
27
|
-
id: t.getId(
|
|
28
|
-
label: t.getLabel(
|
|
29
|
-
level:
|
|
30
|
-
parentId:
|
|
31
|
-
disabled: r(
|
|
22
|
+
function _(l, t) {
|
|
23
|
+
const e = [], i = t.getExpanded || (() => !1), r = t.getDisabled || (() => !1), s = (d, n, o) => {
|
|
24
|
+
d.forEach((a) => {
|
|
25
|
+
const u = t.getChildren(a) || [], c = i(a), h = {
|
|
26
|
+
item: a,
|
|
27
|
+
id: t.getId(a),
|
|
28
|
+
label: t.getLabel(a),
|
|
29
|
+
level: n,
|
|
30
|
+
parentId: o,
|
|
31
|
+
disabled: r(a),
|
|
32
32
|
expanded: c,
|
|
33
33
|
hasChildren: u.length > 0
|
|
34
34
|
};
|
|
35
|
-
e.push(h), h.hasChildren && c && s(u,
|
|
35
|
+
e.push(h), h.hasChildren && c && s(u, n + 1, h.id);
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
|
-
return s(
|
|
38
|
+
return s(l, 1, null), e;
|
|
39
39
|
}
|
|
40
|
-
function p(
|
|
41
|
-
return
|
|
40
|
+
function p(l, t) {
|
|
41
|
+
return l.findIndex((e) => e.id === t);
|
|
42
42
|
}
|
|
43
|
-
function m(
|
|
44
|
-
const e =
|
|
45
|
-
return e
|
|
43
|
+
function m(l, t) {
|
|
44
|
+
const e = l[t];
|
|
45
|
+
return e?.parentId ? l.findIndex((i) => i.id === e.parentId) : -1;
|
|
46
46
|
}
|
|
47
|
-
function y(
|
|
47
|
+
function y(l, t, e = -1) {
|
|
48
48
|
const i = b(t);
|
|
49
|
-
if (!i)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!o.disabled && b(o.label).startsWith(i))
|
|
49
|
+
if (!i) return -1;
|
|
50
|
+
for (let r = 1; r <= l.length; r += 1) {
|
|
51
|
+
const s = (e + r + l.length) % l.length, d = l[s];
|
|
52
|
+
if (!d.disabled && b(d.label).startsWith(i))
|
|
54
53
|
return s;
|
|
55
54
|
}
|
|
56
55
|
return -1;
|
|
@@ -100,8 +99,7 @@ class x extends g {
|
|
|
100
99
|
super.connectedCallback(), this.addEventListener("click", this._onClick), this.addEventListener("keydown", this._onKeyDown), this._observer = new MutationObserver(this._onMutation), this._observer.observe(this, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["expanded", "selected", "disabled", "label", "value"] }), queueMicrotask(() => this._syncTree());
|
|
101
100
|
}
|
|
102
101
|
disconnectedCallback() {
|
|
103
|
-
|
|
104
|
-
this.removeEventListener("click", this._onClick), this.removeEventListener("keydown", this._onKeyDown), (t = this._observer) == null || t.disconnect(), this._observer = null, this._typeaheadTimer != null && window.clearTimeout(this._typeaheadTimer), super.disconnectedCallback();
|
|
102
|
+
this.removeEventListener("click", this._onClick), this.removeEventListener("keydown", this._onKeyDown), this._observer?.disconnect(), this._observer = null, this._typeaheadTimer != null && window.clearTimeout(this._typeaheadTimer), super.disconnectedCallback();
|
|
105
103
|
}
|
|
106
104
|
get value() {
|
|
107
105
|
return this.getAttribute("value") || "";
|
|
@@ -119,8 +117,7 @@ class x extends g {
|
|
|
119
117
|
}
|
|
120
118
|
toggle(t) {
|
|
121
119
|
const e = this._findByValue(t);
|
|
122
|
-
if (!e || e.childItems.length === 0)
|
|
123
|
-
return;
|
|
120
|
+
if (!e || e.childItems.length === 0) return;
|
|
124
121
|
const i = !e.hasAttribute("expanded");
|
|
125
122
|
e.toggleAttribute("expanded", i), this._emitToggle(e, i), this._syncTree();
|
|
126
123
|
}
|
|
@@ -158,14 +155,13 @@ class x extends g {
|
|
|
158
155
|
return this._allItems().find((e) => e.value === t) || null;
|
|
159
156
|
}
|
|
160
157
|
_syncTree() {
|
|
161
|
-
|
|
162
|
-
const t = this._allItems(), e = this._visibleRecords(), i = this.value || ((d = e.find((n) => !n.disabled)) == null ? void 0 : d.id) || "", r = this._focusedValue && e.some((n) => n.id === this._focusedValue) ? this._focusedValue : i;
|
|
158
|
+
const t = this._allItems(), e = this._visibleRecords(), i = this.value || e.find((n) => !n.disabled)?.id || "", r = this._focusedValue && e.some((n) => n.id === this._focusedValue) ? this._focusedValue : i;
|
|
163
159
|
this._focusedValue = r || null;
|
|
164
|
-
const s = new Set(e.map((n) => n.id)),
|
|
160
|
+
const s = new Set(e.map((n) => n.id)), d = new Map(e.map((n) => [n.id, n]));
|
|
165
161
|
t.forEach((n) => {
|
|
166
|
-
const
|
|
162
|
+
const o = d.get(n.value);
|
|
167
163
|
n.style.setProperty("--ui-tree-indent", this.getAttribute("indent-size") || "16px"), n.applyTreeState({
|
|
168
|
-
level:
|
|
164
|
+
level: o?.level || 1,
|
|
169
165
|
hasChildren: n.childItems.length > 0,
|
|
170
166
|
expanded: n.hasAttribute("expanded"),
|
|
171
167
|
selected: n.value === i,
|
|
@@ -176,13 +172,12 @@ class x extends g {
|
|
|
176
172
|
}
|
|
177
173
|
_moveFocus(t) {
|
|
178
174
|
const e = this._visibleRecords();
|
|
179
|
-
if (!e.length)
|
|
180
|
-
return;
|
|
175
|
+
if (!e.length) return;
|
|
181
176
|
const i = p(e, this._focusedValue || this.value || ""), r = i >= 0 ? i : -1;
|
|
182
177
|
for (let s = 1; s <= e.length; s += 1) {
|
|
183
|
-
const
|
|
184
|
-
if (!
|
|
185
|
-
this.focusValue(
|
|
178
|
+
const d = (r + t * s + e.length) % e.length, n = e[d];
|
|
179
|
+
if (!n.disabled) {
|
|
180
|
+
this.focusValue(n.id);
|
|
186
181
|
return;
|
|
187
182
|
}
|
|
188
183
|
}
|
|
@@ -207,8 +202,7 @@ class x extends g {
|
|
|
207
202
|
}
|
|
208
203
|
_onClick(t) {
|
|
209
204
|
const e = t.composedPath(), i = e.find((s) => s instanceof f);
|
|
210
|
-
if (!i || i.hasAttribute("disabled"))
|
|
211
|
-
return;
|
|
205
|
+
if (!i || i.hasAttribute("disabled")) return;
|
|
212
206
|
const r = e.find((s) => s instanceof HTMLElement && s.getAttribute("data-action") === "toggle");
|
|
213
207
|
if (this._focusedValue = i.value, r && i.childItems.length > 0) {
|
|
214
208
|
this.toggle(i.value);
|
|
@@ -218,8 +212,7 @@ class x extends g {
|
|
|
218
212
|
}
|
|
219
213
|
_onKeyDown(t) {
|
|
220
214
|
const e = this._visibleRecords();
|
|
221
|
-
if (!e.length)
|
|
222
|
-
return;
|
|
215
|
+
if (!e.length) return;
|
|
223
216
|
const i = p(e, this._focusedValue || this.value || ""), r = i >= 0 ? e[i] : e[0];
|
|
224
217
|
if (r) {
|
|
225
218
|
if (t.key === "ArrowDown") {
|
|
@@ -245,7 +238,7 @@ class x extends g {
|
|
|
245
238
|
}
|
|
246
239
|
if (r.hasChildren && r.expanded) {
|
|
247
240
|
const s = e[i + 1];
|
|
248
|
-
|
|
241
|
+
s?.parentId === r.id && this.focusValue(s.id);
|
|
249
242
|
}
|
|
250
243
|
return;
|
|
251
244
|
}
|
|
@@ -286,9 +279,9 @@ class x extends g {
|
|
|
286
279
|
typeof customElements < "u" && !customElements.get("ui-tree") && customElements.define("ui-tree", x);
|
|
287
280
|
export {
|
|
288
281
|
x as U,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
282
|
+
p as a,
|
|
283
|
+
y as b,
|
|
284
|
+
C as c,
|
|
285
|
+
_ as d,
|
|
286
|
+
m as f
|
|
294
287
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";const v=require("./ElementBase-EV6mVBUV.js"),p=require("./collection-qv8A8rq4.js"),f=require("./tree-item.cjs.js");function x(l,t){const e=[],i=t.getExpanded||(()=>!1),r=t.getDisabled||(()=>!1),s=(d,n,o)=>{d.forEach(a=>{const u=t.getChildren(a)||[],c={item:a,id:t.getId(a),label:t.getLabel(a),level:n,parentId:o,disabled:r(a),expanded:i(a),hasChildren:u.length>0};e.push(c),s(u,n+1,c.id)})};return s(l,1,null),e}function g(l,t){const e=[],i=t.getExpanded||(()=>!1),r=t.getDisabled||(()=>!1),s=(d,n,o)=>{d.forEach(a=>{const u=t.getChildren(a)||[],c=i(a),h={item:a,id:t.getId(a),label:t.getLabel(a),level:n,parentId:o,disabled:r(a),expanded:c,hasChildren:u.length>0};e.push(h),h.hasChildren&&c&&s(u,n+1,h.id)})};return s(l,1,null),e}function b(l,t){return l.findIndex(e=>e.id===t)}function _(l,t){const e=l[t];return e?.parentId?l.findIndex(i=>i.id===e.parentId):-1}function y(l,t,e=-1){const i=p.normalizeCollectionText(t);if(!i)return-1;for(let r=1;r<=l.length;r+=1){const s=(e+r+l.length)%l.length,d=l[s];if(!d.disabled&&p.normalizeCollectionText(d.label).startsWith(i))return s}return-1}const T=`
|
|
2
|
+
:host {
|
|
3
|
+
--ui-tree-indent: 16px;
|
|
4
|
+
--ui-tree-radius: 14px;
|
|
5
|
+
--ui-tree-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 98%, transparent);
|
|
6
|
+
--ui-tree-border: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 72%, transparent);
|
|
7
|
+
--ui-tree-text: var(--ui-color-text, #0f172a);
|
|
8
|
+
--ui-tree-muted: var(--ui-color-muted, #64748b);
|
|
9
|
+
display: block;
|
|
10
|
+
min-inline-size: 0;
|
|
11
|
+
color-scheme: light dark;
|
|
12
|
+
font-family: "Inter", "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.tree {
|
|
16
|
+
min-inline-size: 0;
|
|
17
|
+
display: grid;
|
|
18
|
+
gap: 4px;
|
|
19
|
+
padding: 10px;
|
|
20
|
+
border: 1px solid var(--ui-tree-border);
|
|
21
|
+
border-radius: var(--ui-tree-radius);
|
|
22
|
+
background: var(--ui-tree-bg);
|
|
23
|
+
color: var(--ui-tree-text);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@media (forced-colors: active) {
|
|
27
|
+
.tree {
|
|
28
|
+
forced-color-adjust: none;
|
|
29
|
+
background: Canvas;
|
|
30
|
+
color: CanvasText;
|
|
31
|
+
border-color: CanvasText;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;class m extends v.ElementBase{constructor(){super(),this._observer=null,this._focusedValue=null,this._typeaheadBuffer="",this._typeaheadTimer=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onMutation=this._onMutation.bind(this)}static get observedAttributes(){return["value","indent-size"]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onClick),this.addEventListener("keydown",this._onKeyDown),this._observer=new MutationObserver(this._onMutation),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["expanded","selected","disabled","label","value"]}),queueMicrotask(()=>this._syncTree())}disconnectedCallback(){this.removeEventListener("click",this._onClick),this.removeEventListener("keydown",this._onKeyDown),this._observer?.disconnect(),this._observer=null,this._typeaheadTimer!=null&&window.clearTimeout(this._typeaheadTimer),super.disconnectedCallback()}get value(){return this.getAttribute("value")||""}set value(t){t?this.setAttribute("value",t):this.removeAttribute("value")}expand(t){const e=this._findByValue(t);!e||e.childItems.length===0||(e.setAttribute("expanded",""),this._emitToggle(e,!0),this._syncTree())}collapse(t){const e=this._findByValue(t);!e||e.childItems.length===0||(e.removeAttribute("expanded"),this._emitToggle(e,!1),this._syncTree())}toggle(t){const e=this._findByValue(t);if(!e||e.childItems.length===0)return;const i=!e.hasAttribute("expanded");e.toggleAttribute("expanded",i),this._emitToggle(e,i),this._syncTree()}select(t){const e=this._findByValue(t);!e||e.hasAttribute("disabled")||(this.value=t,this._focusedValue=t,this._emitSelect(e),this._syncTree())}focusValue(t){const e=this._findByValue(t);e&&(this._focusedValue=t,this._syncTree(),e.focusRow({preventScroll:!0}))}_onMutation(){this._syncTree()}_allItems(){return Array.from(this.querySelectorAll("ui-tree-item")).filter(t=>t instanceof f.UITreeItem&&t.closest("ui-tree")===this)}_rootItems(){return Array.from(this.children).filter(t=>t instanceof f.UITreeItem)}_visibleRecords(){const t=this._rootItems();return g(t,{getId:e=>e.value,getLabel:e=>e.label,getChildren:e=>e.childItems,getExpanded:e=>e.hasAttribute("expanded"),getDisabled:e=>e.hasAttribute("disabled")}).map(e=>({...e,item:e.item}))}_findByValue(t){return this._allItems().find(e=>e.value===t)||null}_syncTree(){const t=this._allItems(),e=this._visibleRecords(),i=this.value||e.find(n=>!n.disabled)?.id||"",r=this._focusedValue&&e.some(n=>n.id===this._focusedValue)?this._focusedValue:i;this._focusedValue=r||null;const s=new Set(e.map(n=>n.id)),d=new Map(e.map(n=>[n.id,n]));t.forEach(n=>{const o=d.get(n.value);n.style.setProperty("--ui-tree-indent",this.getAttribute("indent-size")||"16px"),n.applyTreeState({level:o?.level||1,hasChildren:n.childItems.length>0,expanded:n.hasAttribute("expanded"),selected:n.value===i,active:n.value===r,hidden:!s.has(n.value)})})}_moveFocus(t){const e=this._visibleRecords();if(!e.length)return;const i=b(e,this._focusedValue||this.value||""),r=i>=0?i:-1;for(let s=1;s<=e.length;s+=1){const d=(r+t*s+e.length)%e.length,n=e[d];if(!n.disabled){this.focusValue(n.id);return}}}_emitSelect(t){this.dispatchEvent(new CustomEvent("select",{detail:{value:t.value,label:t.label},bubbles:!0,composed:!0}))}_emitToggle(t,e){this.dispatchEvent(new CustomEvent("expanded-change",{detail:{value:t.value,expanded:e},bubbles:!0,composed:!0}))}_onClick(t){const e=t.composedPath(),i=e.find(s=>s instanceof f.UITreeItem);if(!i||i.hasAttribute("disabled"))return;const r=e.find(s=>s instanceof HTMLElement&&s.getAttribute("data-action")==="toggle");if(this._focusedValue=i.value,r&&i.childItems.length>0){this.toggle(i.value);return}this.select(i.value)}_onKeyDown(t){const e=this._visibleRecords();if(!e.length)return;const i=b(e,this._focusedValue||this.value||""),r=i>=0?e[i]:e[0];if(r){if(t.key==="ArrowDown"){t.preventDefault(),this._moveFocus(1);return}if(t.key==="ArrowUp"){t.preventDefault(),this._moveFocus(-1);return}if(t.key==="Home"){t.preventDefault(),this.focusValue(e[0].id);return}if(t.key==="End"){t.preventDefault(),this.focusValue(e[e.length-1].id);return}if(t.key==="ArrowRight"){if(t.preventDefault(),r.hasChildren&&!r.expanded){this.expand(r.id);return}if(r.hasChildren&&r.expanded){const s=e[i+1];s?.parentId===r.id&&this.focusValue(s.id)}return}if(t.key==="ArrowLeft"){if(t.preventDefault(),r.hasChildren&&r.expanded){this.collapse(r.id);return}const s=_(e,i);s>=0&&this.focusValue(e[s].id);return}if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.select(r.id);return}if(t.key.length===1&&/\S/.test(t.key)){this._typeaheadBuffer=`${this._typeaheadBuffer}${t.key.toLowerCase()}`.slice(0,24),this._typeaheadTimer!=null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>{this._typeaheadBuffer="",this._typeaheadTimer=null},420);const s=y(e,this._typeaheadBuffer,i);s>=0&&(t.preventDefault(),this.focusValue(e[s].id))}}}shouldRenderOnAttributeChange(t){return t==="indent-size"}render(){this.setContent(`
|
|
35
|
+
<style>${T}</style>
|
|
36
|
+
<div class="tree" part="tree" role="tree">
|
|
37
|
+
<slot></slot>
|
|
38
|
+
</div>
|
|
39
|
+
`),queueMicrotask(()=>this._syncTree())}}typeof customElements<"u"&&!customElements.get("ui-tree")&&customElements.define("ui-tree",m);exports.UITree=m;exports.findParentTreeRecordIndex=_;exports.findTreeRecordIndexById=b;exports.findTreeTypeaheadMatch=y;exports.flattenTree=x;exports.flattenVisibleTree=g;
|
package/dist/tree-item.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./ElementBase-EV6mVBUV.js"),i=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-tree-indent: 16px;
|
|
4
4
|
--ui-tree-level: 1;
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
transition: none !important;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
`;class t extends r.ElementBase{constructor(){super(...arguments),this._row=null,this._children=null,this._twist=null}static get observedAttributes(){return["expanded","selected","disabled","hidden"]}get value(){return this.getAttribute("value")||this.id||""}get label(){
|
|
92
|
+
`;class t extends r.ElementBase{constructor(){super(...arguments),this._row=null,this._children=null,this._twist=null}static get observedAttributes(){return["expanded","selected","disabled","hidden"]}get value(){return this.getAttribute("value")||this.id||""}get label(){return this.getAttribute("label")||this.textContent?.trim()||""}get childItems(){return Array.from(this.children).filter(e=>e instanceof t)}focusRow(e){if(this._row)try{this._row.focus(e)}catch{this._row.focus()}}applyTreeState(e){this.hidden=e.hidden,this.style.setProperty("--ui-tree-level",String(e.level)),this.toggleAttribute("expanded",e.expanded),this.toggleAttribute("selected",e.selected),!(!this._row||!this._children||!this._twist)&&(this._row.tabIndex=e.active?0:-1,this._row.setAttribute("aria-level",String(e.level)),this._row.setAttribute("aria-selected",e.selected?"true":"false"),this._row.setAttribute("aria-expanded",e.hasChildren?String(e.expanded):"false"),this._twist.setAttribute("data-has-children",e.hasChildren?"true":"false"),this._children.hidden=!e.hasChildren||!e.expanded)}shouldRenderOnAttributeChange(){return!1}render(){this.setContent(`
|
|
93
93
|
<style>${i}</style>
|
|
94
94
|
<div class="row" part="row" role="treeitem" tabindex="-1">
|
|
95
95
|
<span class="twist" part="twist" data-action="toggle">▸</span>
|