@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
package/dist/slider.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("./ElementBase-EV6mVBUV.js"),_=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-slider-width: min(340px, 100%);
|
|
4
4
|
--ui-slider-track-size: 6px;
|
package/dist/slider.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as f } from "./ElementBase-
|
|
1
|
+
import { E as f } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
2
|
const x = `
|
|
3
3
|
:host {
|
|
4
4
|
--ui-slider-width: min(340px, 100%);
|
|
@@ -477,8 +477,7 @@ function b(n) {
|
|
|
477
477
|
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
478
478
|
}
|
|
479
479
|
function m(n, t, e) {
|
|
480
|
-
if (!n)
|
|
481
|
-
return [];
|
|
480
|
+
if (!n) return [];
|
|
482
481
|
try {
|
|
483
482
|
const r = JSON.parse(n);
|
|
484
483
|
return Array.isArray(r) ? r.map((i) => typeof i == "number" ? { value: i } : i && typeof i == "object" && Number.isFinite(Number(i.value)) ? {
|
|
@@ -490,8 +489,7 @@ function m(n, t, e) {
|
|
|
490
489
|
}
|
|
491
490
|
}
|
|
492
491
|
function p(n, t = !1) {
|
|
493
|
-
if (n == null)
|
|
494
|
-
return t;
|
|
492
|
+
if (n == null) return t;
|
|
495
493
|
const e = String(n).toLowerCase();
|
|
496
494
|
return e !== "false" && e !== "0" && e !== "off";
|
|
497
495
|
}
|
|
@@ -632,21 +630,18 @@ class k extends f {
|
|
|
632
630
|
t.classList.contains("start") ? this._valueStart = Math.min(l, this._valueEnd) : this._valueEnd = Math.max(l, this._valueStart), this._valueStart = Math.round(this._valueStart / i) * i, this._valueEnd = Math.round(this._valueEnd / i) * i, this._value = this._valueEnd, this.setAttribute("value-start", String(this._valueStart)), this.setAttribute("value-end", String(this._valueEnd)), this.setAttribute("value", String(this._valueEnd));
|
|
633
631
|
}
|
|
634
632
|
_onInput(t) {
|
|
635
|
-
if (p(this.getAttribute("disabled")) || this.hasAttribute("disabled"))
|
|
636
|
-
return;
|
|
633
|
+
if (p(this.getAttribute("disabled")) || this.hasAttribute("disabled")) return;
|
|
637
634
|
const e = t.target;
|
|
638
635
|
!e || e.type !== "range" || (this._updateFromInput(e), this._syncDom(), this._emit("input"), this._emit("valuechange"));
|
|
639
636
|
}
|
|
640
637
|
_onChange(t) {
|
|
641
|
-
if (p(this.getAttribute("disabled")) || this.hasAttribute("disabled"))
|
|
642
|
-
return;
|
|
638
|
+
if (p(this.getAttribute("disabled")) || this.hasAttribute("disabled")) return;
|
|
643
639
|
const e = t.target;
|
|
644
640
|
!e || e.type !== "range" || (this._updateFromInput(e), this._syncDom(), this._emit("change"));
|
|
645
641
|
}
|
|
646
642
|
_renderMarks(t, e) {
|
|
647
643
|
const r = m(this.getAttribute("marks"), t, e);
|
|
648
|
-
if (!r.length)
|
|
649
|
-
return '<div class="marks" part="marks" hidden></div>';
|
|
644
|
+
if (!r.length) return '<div class="marks" part="marks" hidden></div>';
|
|
650
645
|
const i = Math.max(1, e - t), l = this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal";
|
|
651
646
|
return `<div class="marks" part="marks">${r.map((s) => {
|
|
652
647
|
const o = (s.value - t) / i * 100, d = l === "vertical" ? `style="bottom:${o}%"` : `style="left:${o}%"`, c = s.label != null ? b(s.label) : String(s.value);
|
package/dist/slot.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"),u=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-slot-bg: transparent;
|
|
4
4
|
--ui-slot-text: inherit;
|
|
@@ -150,10 +150,10 @@
|
|
|
150
150
|
--ui-slot-border-color: CanvasText;
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
`;function o(l){return l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}class a extends r.ElementBase{constructor(){super(),this._slotEl=null,this._shellEl=null,this._lastEmpty=!0,this._lastCount=-1,this._lastName="",this._initialized=!1,this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["name","headless","inline","align","size","variant","tone","fallback","required"]}disconnectedCallback(){this._slotEl&&this._slotEl.removeEventListener("slotchange",this._onSlotChange),this._slotEl=null,this._shellEl=null,this._initialized=!1,this._lastCount=-1,this._lastName="",this._lastEmpty=!0,super.disconnectedCallback()}attributeChangedCallback(
|
|
153
|
+
`;function o(l){return l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}class a extends r.ElementBase{constructor(){super(),this._slotEl=null,this._shellEl=null,this._lastEmpty=!0,this._lastCount=-1,this._lastName="",this._initialized=!1,this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["name","headless","inline","align","size","variant","tone","fallback","required"]}disconnectedCallback(){this._slotEl&&this._slotEl.removeEventListener("slotchange",this._onSlotChange),this._slotEl=null,this._shellEl=null,this._initialized=!1,this._lastCount=-1,this._lastName="",this._lastEmpty=!0,super.disconnectedCallback()}attributeChangedCallback(e,t,s){if(t!==s){if(e==="required"){this.isConnected&&this._syncState(!0);return}super.attributeChangedCallback(e,t,s)}}_assignedCount(){return this._slotEl?this._slotEl.assignedNodes({flatten:!0}).filter(t=>t.nodeType===Node.ELEMENT_NODE?!0:t.nodeType===Node.TEXT_NODE?!!t.textContent?.trim():!1).length:0}_syncState(e=!1){const t=this._assignedCount(),s=t===0,i=this.getAttribute("name")||"",n=e||!this._initialized||t!==this._lastCount||i!==this._lastName;this._shellEl&&this._shellEl.setAttribute("data-empty",s?"true":"false"),n&&this.dispatchEvent(new CustomEvent("slotchange",{detail:{name:i,count:t,empty:s},bubbles:!0,composed:!0})),s&&this.hasAttribute("required")&&(!this._initialized||!this._lastEmpty)&&this.dispatchEvent(new CustomEvent("missing",{bubbles:!0,composed:!0})),!s&&(!this._initialized||this._lastEmpty)&&this.dispatchEvent(new CustomEvent("resolved",{bubbles:!0,composed:!0})),this._lastEmpty=s,this._lastCount=t,this._lastName=i,this._initialized=!0}_onSlotChange(){this._syncState()}render(){const e=(this.getAttribute("name")||"").trim(),t=this.getAttribute("fallback")||"",s=e?`<slot name="${o(e)}"></slot>`:"<slot></slot>";this.setContent(`
|
|
154
154
|
<style>${u}</style>
|
|
155
155
|
<span class="shell" part="shell" data-empty="true">
|
|
156
|
-
<span class="content" part="content">${
|
|
156
|
+
<span class="content" part="content">${s}</span>
|
|
157
157
|
<span class="fallback" part="fallback"><slot name="fallback">${o(t)}</slot></span>
|
|
158
158
|
</span>
|
|
159
|
-
`),this._shellEl=this.root.querySelector(".shell"),this._slotEl&&this._slotEl.removeEventListener("slotchange",this._onSlotChange),this._slotEl=this.root.querySelector('slot:not([name="fallback"])'),this._slotEl&&this._slotEl.addEventListener("slotchange",this._onSlotChange),this._syncState()}shouldRenderOnAttributeChange(
|
|
159
|
+
`),this._shellEl=this.root.querySelector(".shell"),this._slotEl&&this._slotEl.removeEventListener("slotchange",this._onSlotChange),this._slotEl=this.root.querySelector('slot:not([name="fallback"])'),this._slotEl&&this._slotEl.addEventListener("slotchange",this._onSlotChange),this._syncState()}shouldRenderOnAttributeChange(e,t,s){return e==="name"||e==="fallback"}}typeof customElements<"u"&&!customElements.get("ui-slot")&&customElements.define("ui-slot",a);exports.UISlot=a;
|
package/dist/slot.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as n } from "./ElementBase-
|
|
1
|
+
import { E as n } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
2
|
const r = `
|
|
3
3
|
:host {
|
|
4
4
|
--ui-slot-bg: transparent;
|
|
@@ -175,50 +175,47 @@ class u extends n {
|
|
|
175
175
|
disconnectedCallback() {
|
|
176
176
|
this._slotEl && this._slotEl.removeEventListener("slotchange", this._onSlotChange), this._slotEl = null, this._shellEl = null, this._initialized = !1, this._lastCount = -1, this._lastName = "", this._lastEmpty = !0, super.disconnectedCallback();
|
|
177
177
|
}
|
|
178
|
-
attributeChangedCallback(
|
|
179
|
-
if (t !==
|
|
180
|
-
if (
|
|
178
|
+
attributeChangedCallback(e, t, s) {
|
|
179
|
+
if (t !== s) {
|
|
180
|
+
if (e === "required") {
|
|
181
181
|
this.isConnected && this._syncState(!0);
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
|
-
super.attributeChangedCallback(
|
|
184
|
+
super.attributeChangedCallback(e, t, s);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
_assignedCount() {
|
|
188
|
-
return this._slotEl ? this._slotEl.assignedNodes({ flatten: !0 }).filter((t) =>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
_syncState(s = !1) {
|
|
194
|
-
const t = this._assignedCount(), e = t === 0, i = this.getAttribute("name") || "", a = s || !this._initialized || t !== this._lastCount || i !== this._lastName;
|
|
195
|
-
this._shellEl && this._shellEl.setAttribute("data-empty", e ? "true" : "false"), a && this.dispatchEvent(
|
|
188
|
+
return this._slotEl ? this._slotEl.assignedNodes({ flatten: !0 }).filter((t) => t.nodeType === Node.ELEMENT_NODE ? !0 : t.nodeType === Node.TEXT_NODE ? !!t.textContent?.trim() : !1).length : 0;
|
|
189
|
+
}
|
|
190
|
+
_syncState(e = !1) {
|
|
191
|
+
const t = this._assignedCount(), s = t === 0, i = this.getAttribute("name") || "", a = e || !this._initialized || t !== this._lastCount || i !== this._lastName;
|
|
192
|
+
this._shellEl && this._shellEl.setAttribute("data-empty", s ? "true" : "false"), a && this.dispatchEvent(
|
|
196
193
|
new CustomEvent("slotchange", {
|
|
197
194
|
detail: {
|
|
198
195
|
name: i,
|
|
199
196
|
count: t,
|
|
200
|
-
empty:
|
|
197
|
+
empty: s
|
|
201
198
|
},
|
|
202
199
|
bubbles: !0,
|
|
203
200
|
composed: !0
|
|
204
201
|
})
|
|
205
|
-
),
|
|
202
|
+
), s && this.hasAttribute("required") && (!this._initialized || !this._lastEmpty) && this.dispatchEvent(new CustomEvent("missing", { bubbles: !0, composed: !0 })), !s && (!this._initialized || this._lastEmpty) && this.dispatchEvent(new CustomEvent("resolved", { bubbles: !0, composed: !0 })), this._lastEmpty = s, this._lastCount = t, this._lastName = i, this._initialized = !0;
|
|
206
203
|
}
|
|
207
204
|
_onSlotChange() {
|
|
208
205
|
this._syncState();
|
|
209
206
|
}
|
|
210
207
|
render() {
|
|
211
|
-
const
|
|
208
|
+
const e = (this.getAttribute("name") || "").trim(), t = this.getAttribute("fallback") || "", s = e ? `<slot name="${o(e)}"></slot>` : "<slot></slot>";
|
|
212
209
|
this.setContent(`
|
|
213
210
|
<style>${r}</style>
|
|
214
211
|
<span class="shell" part="shell" data-empty="true">
|
|
215
|
-
<span class="content" part="content">${
|
|
212
|
+
<span class="content" part="content">${s}</span>
|
|
216
213
|
<span class="fallback" part="fallback"><slot name="fallback">${o(t)}</slot></span>
|
|
217
214
|
</span>
|
|
218
215
|
`), this._shellEl = this.root.querySelector(".shell"), this._slotEl && this._slotEl.removeEventListener("slotchange", this._onSlotChange), this._slotEl = this.root.querySelector('slot:not([name="fallback"])'), this._slotEl && this._slotEl.addEventListener("slotchange", this._onSlotChange), this._syncState();
|
|
219
216
|
}
|
|
220
|
-
shouldRenderOnAttributeChange(
|
|
221
|
-
return
|
|
217
|
+
shouldRenderOnAttributeChange(e, t, s) {
|
|
218
|
+
return e === "name" || e === "fallback";
|
|
222
219
|
}
|
|
223
220
|
}
|
|
224
221
|
typeof customElements < "u" && !customElements.get("ui-slot") && customElements.define("ui-slot", u);
|
package/dist/sortable.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const te=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const te=require("./ElementBase-EV6mVBUV.js"),re=1,ie=44,se=72,oe=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-sortable-accent: var(--ui-color-primary, #2563eb);
|
|
4
4
|
--ui-sortable-surface: var(--ui-color-surface, #ffffff);
|
|
@@ -720,93 +720,93 @@
|
|
|
720
720
|
background: Highlight;
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
`;function V(u){if(!u)return[];try{const e=JSON.parse(u);return Array.isArray(e)?e:[]}catch{return[]}}function I(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function z(u,e){return`${u}::${e??"__root__"}`}function X(u){return u?[u.listId,u.parentId??"",u.beforeId??"",u.mode].join("::"):""}function B(u,e){return X(u)===X(e)}function oe(u){if(!u||u==="none")return{x:1,y:1};const e=u.match(/^matrix3d\((.+)\)$/);if(e){const t=e[1].split(",").map(i=>Number.parseFloat(i.trim()));if(t.length===16&&t.every(i=>Number.isFinite(i)))return{x:t[0]||1,y:t[5]||1}}const r=u.match(/^matrix\((.+)\)$/);if(r){const t=r[1].split(",").map(i=>Number.parseFloat(i.trim()));if(t.length===6&&t.every(i=>Number.isFinite(i))){const[i,s,o,a]=t;return{x:Math.sqrt(i*i+s*s)||1,y:Math.sqrt(o*o+a*a)||1}}}return{x:1,y:1}}function ae(u){return u==="item"?"item":"handle"}function $(u){return{...u}}function de(u,e,r,t,i,s){const o=M(u),a=E(u),l=new Set,n=[],d=h=>{const x=o.get(h);!x||l.has(h)||(l.add(h),n.push(h),(a.get(z(x.listId,h))||[]).forEach(d))};t.forEach(d);const c=u.map($),g=c.filter(h=>l.has(h.id)),m=i?c.map($):c.filter(h=>!l.has(h.id)),f=i?g.map(h=>s(h,n)):g.map($),v=new Map,b=new Map;i&&g.forEach((h,x)=>{v.set(h.id,f[x].id),b.set(f[x].id,h.id)}),f.forEach(h=>{const x=i?b.get(h.id):h.id,F=x?o.get(x):null;F&&(i&&(h.parentId=F.parentId&&v.has(F.parentId)&&v.get(F.parentId)||null),h.listId=r.listId)});const y=t.map(h=>v.get(h)||h),w=[...m,...f],k=E(m),A=z(r.listId,r.parentId),_=[...k.get(A)||[]],R=r.beforeId?_.indexOf(r.beforeId):_.length,S=R>=0?R:_.length;_.splice(S,0,...y),k.set(A,_),E(f).forEach((h,x)=>{const[,F]=x.split("::");(F||"")!=="__root__"&&k.set(x,[...h])});const T=M(w);y.forEach(h=>{const x=T.get(h);x&&(x.parentId=r.parentId,x.listId=r.listId)});const P=[],L=new Set,G=(h,x)=>{(k.get(z(h,x))||[]).forEach((O,K)=>{const p=T.get(O);!p||L.has(O)||(L.add(O),p.listId=h,p.parentId=x,p.order=K,P.push(p),G(h,O))})};return e.forEach(h=>G(h.id,null)),w.forEach(h=>{L.has(h.id)||(h.parentId=null,P.push(h))}),{items:P.map($),insertedRootIds:y}}function E(u){const e=new Map;return u.forEach(r=>{const t=z(r.listId,r.parentId),i=e.get(t);i?i.push(r.id):e.set(t,[r.id])}),e}function M(u){return new Map(u.map(e=>[e.id,e]))}function Y(u){const e=new Set,r=[];return u.forEach((t,i)=>{const s=typeof(t==null?void 0:t.id)=="string"&&t.id.trim()?t.id.trim():`list-${i+1}`;e.has(s)||(e.add(s),r.push({id:s,label:typeof(t==null?void 0:t.label)=="string"&&t.label.trim()?t.label.trim():`List ${i+1}`,description:typeof(t==null?void 0:t.description)=="string"?t.description:"",emptyLabel:typeof(t==null?void 0:t.emptyLabel)=="string"&&t.emptyLabel.trim()?t.emptyLabel.trim():"Drop items here.",orientation:(t==null?void 0:t.orientation)==="horizontal"?"horizontal":"vertical",disabled:!!(t!=null&&t.disabled),cloneOnDrag:!!(t!=null&&t.cloneOnDrag),accepts:Array.isArray(t==null?void 0:t.accepts)?t.accepts.filter(o=>typeof o=="string"&&o.trim().length>0):void 0}))}),r.length?r:[{id:"default",label:"Items",description:"",emptyLabel:"Drop items here.",orientation:"vertical",disabled:!1,cloneOnDrag:!1}]}function U(u,e){const r=new Set(u.map(n=>n.id)),t=[];e.forEach((n,d)=>{const c=typeof(n==null?void 0:n.id)=="string"&&n.id.trim()?n.id.trim():"",g=typeof(n==null?void 0:n.label)=="string"&&n.label.trim()?n.label.trim():"";if(!c||!g)return;const m=typeof(n==null?void 0:n.listId)=="string"&&r.has(n.listId)?n.listId:u[0].id;t.push({id:c,label:g,listId:m,parentId:typeof(n==null?void 0:n.parentId)=="string"&&n.parentId.trim()?n.parentId.trim():null,description:typeof(n==null?void 0:n.description)=="string"?n.description:"",order:Number.isFinite(n==null?void 0:n.order)?Number(n.order):d,disabled:!!(n!=null&&n.disabled),dragDisabled:!!(n!=null&&n.dragDisabled),cloneOnDrag:!!(n!=null&&n.cloneOnDrag),hidden:!!(n!=null&&n.hidden)})});const i=new Map(t.map(n=>[n.id,n]));t.forEach(n=>{if(!n.parentId)return;const d=i.get(n.parentId);(!d||d.id===n.id||d.listId!==n.listId)&&(n.parentId=null)});const s=new Map;t.forEach(n=>{const d=z(n.listId,n.parentId),c=s.get(d);c?c.push(n):s.set(d,[n])}),s.forEach(n=>n.sort((d,c)=>d.order-c.order||d.label.localeCompare(c.label)));const o=[],a=new Set,l=(n,d)=>{(s.get(z(n,d))||[]).forEach((g,m)=>{a.has(g.id)||(a.add(g.id),g.order=m,o.push(g),l(n,g.id))})};return u.forEach(n=>l(n.id,null)),t.forEach(n=>{a.has(n.id)||(n.parentId=null,o.push(n))}),o.map($)}function le(u){return JSON.stringify(u.map(e=>({id:e.id,label:e.label,listId:e.listId,parentId:e.parentId,description:e.description,order:e.order,disabled:e.disabled,dragDisabled:e.dragDisabled,cloneOnDrag:e.cloneOnDrag,hidden:e.hidden})))}function ce(u){return JSON.stringify(u.map(e=>({id:e.id,label:e.label,description:e.description,emptyLabel:e.emptyLabel,orientation:e.orientation,disabled:e.disabled,cloneOnDrag:e.cloneOnDrag,accepts:e.accepts})))}function j(u){return JSON.stringify(u)}function J(u){const e=new Map,r=u.map(t=>{const i=z(t.listId,t.parentId),s=e.get(i)??0;return e.set(i,s+1),{id:t.id,listId:t.listId,parentId:t.parentId,index:s}});return{version:re,records:r}}function W(u,e){return e?`${u.label} ${u.description}`.toLowerCase().includes(e.toLowerCase()):!0}function Q(u,e,r,t,i){const s=M(u),o=E(u),a=new Map,l=(c,g)=>{const m=[...o.get(z(c,g))||[]];return i==="label"&&m.sort((f,v)=>{const b=s.get(f),y=s.get(v);return!b||!y?0:b.label.localeCompare(y.label)}),m},n=(c,g,m)=>{const f=[];return l(c,g).forEach(v=>{const b=s.get(v);if(!b||b.hidden)return;const y=n(c,b.id);!W(b,t)&&y.length===0||(f.push({id:b.id,disabled:b.disabled}),y.length&&f.push(...y))}),f};return Array.from(new Set(u.map(c=>c.listId))).forEach(c=>{a.set(c,n(c,null))}),a}class Z extends te.ElementBase{constructor(){super(),this._lists=Y([]),this._items=[],this._selection=[],this._focusedId=null,this._rangeAnchorId=null,this._dragState=null,this._liveMessage="Sortable list ready.",this._lastListsAttr=null,this._lastItemsAttr=null,this._lastSelectionAttr=null,this._hydratedPersistKey=null,this._cloneSeed=1,this._dragImage=null,this._dragPreviewOverlay=null,this._pendingFocusId=null,this._pointerGesture=null,this._pendingDropTarget=null,this._suppressAttributeRender=!1,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onDragStart=this._onDragStart.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDrop=this._onDrop.bind(this),this._onDragEnd=this._onDragEnd.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerCancel=this._onPointerCancel.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onDocumentKeyDown=this._onDocumentKeyDown.bind(this)}static get observedAttributes(){return["lists","items","selection","filter-query","sort","persist-key","allow-filtered-drag","allow-nesting","drop-indicator-visibility","dropzone-style","drag-preview-size","drag-handle-mode","drag-handle-selector","custom-item-rendering","show-selection-badge","disabled"]}shouldRenderOnAttributeChange(e,r,t){return this._suppressAttributeRender?!["lists","items","selection"].includes(e):!0}attributeChangedCallback(e,r,t){if(r!==t&&this.isConnected){if(e==="selection"&&!this._suppressAttributeRender&&this._canSyncInteractiveStateInPlace()){this._syncSelectionFromAttribute(t??null),this._syncSelectionVisualState();return}if(e==="show-selection-badge"&&this._canSyncInteractiveStateInPlace()){this._syncSelectionVisualState();return}super.attributeChangedCallback(e,r,t)}}connectedCallback(){var e,r,t,i;super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this.root.addEventListener("dragstart",this._onDragStart),this.root.addEventListener("dragover",this._onDragOver),this.root.addEventListener("drop",this._onDrop),this.root.addEventListener("dragend",this._onDragEnd),this.root.addEventListener("pointerdown",this._onPointerDown),this.root.addEventListener("focusin",this._onFocusIn),(e=this.ownerDocument)==null||e.addEventListener("keydown",this._onDocumentKeyDown,!0),(r=this.ownerDocument)==null||r.addEventListener("pointermove",this._onPointerMove,!0),(t=this.ownerDocument)==null||t.addEventListener("pointerup",this._onPointerUp,!0),(i=this.ownerDocument)==null||i.addEventListener("pointercancel",this._onPointerCancel,!0)}disconnectedCallback(){var e,r,t,i;this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this.root.removeEventListener("dragstart",this._onDragStart),this.root.removeEventListener("dragover",this._onDragOver),this.root.removeEventListener("drop",this._onDrop),this.root.removeEventListener("dragend",this._onDragEnd),this.root.removeEventListener("pointerdown",this._onPointerDown),this.root.removeEventListener("focusin",this._onFocusIn),(e=this.ownerDocument)==null||e.removeEventListener("keydown",this._onDocumentKeyDown,!0),(r=this.ownerDocument)==null||r.removeEventListener("pointermove",this._onPointerMove,!0),(t=this.ownerDocument)==null||t.removeEventListener("pointerup",this._onPointerUp,!0),(i=this.ownerDocument)==null||i.removeEventListener("pointercancel",this._onPointerCancel,!0),this._removeDragPreviewOverlay(),this._removeDragImage(),super.disconnectedCallback()}get lists(){return this._lists.map(e=>({...e}))}set lists(e){this.setAttribute("lists",JSON.stringify(e??[]))}get items(){return this._items.map(e=>({...e}))}set items(e){this.setAttribute("items",JSON.stringify(e??[]))}get selection(){return[...this._selection]}set selection(e){this.setAttribute("selection",JSON.stringify(e??[]))}get sort(){return this.getAttribute("sort")==="label"?"label":"manual"}set sort(e){!e||e==="manual"?this.removeAttribute("sort"):this.setAttribute("sort",e)}get filterQuery(){return this.getAttribute("filter-query")||""}set filterQuery(e){e?this.setAttribute("filter-query",e):this.removeAttribute("filter-query")}select(e){this._setSelection(e,"api")}clearSelection(){this._setSelection([],"api")}cancelDrag(){this._cancelDrag(!0)}focusItem(e){this._items.some(r=>r.id===e)&&(this._focusedId=e,this._pendingFocusId=e,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender())}moveSelection(e){this._syncSelectionFromAttribute(this.getAttribute("selection"));const r=this._selectedRootIds();r.length&&this._commitMove({listId:e.targetListId,parentId:e.parentId??null,beforeId:e.beforeId??null,mode:e.mode??(e.parentId?"inside":"before")},r,!!e.clone,e.source??"api")}getPersistenceSnapshot(){return J(this._items)}render(){var _,R;this._syncStateFromAttributes();const e=this._measureItemShellRects(),r=new Set(this._draggingIds()),t=new Set(this._selection),s=!!((_=this._dragState)!=null&&_.keyboard)?this._projectedMoveResult():null,o=(s==null?void 0:s.items)||this._items,a=new Set((s==null?void 0:s.insertedRootIds)||[]),l=!!this._dragState&&!this._dragState.keyboard&&!!this._dragState.dropTarget,n=Q(o,t,r,this.filterQuery,this.sort),d=this._resolvedFocusedId(n),c=this._isDragLocked(),g=this._selection.length,m=this.getAttribute("allow-nesting")!=="false",f=this.getAttribute("drop-indicator-visibility")==="always"?"always":"active",v=this._dropzoneStyle(),b=this.getAttribute("show-selection-badge")!=="false",y=this._dragHandleMode(),w=this._usesCustomHandleSelector(),k=c?this.sort==="label"?"Dragging is paused while alphabetical sorting is active.":this.filterQuery&&!this.hasAttribute("allow-filtered-drag")?"Dragging is paused while the list is filtered.":"Dragging is currently disabled.":(R=this._dragState)!=null&&R.keyboard?"Keyboard drag active. Use arrow keys to choose a drop target, Space or Enter to drop, and Escape to cancel.":y==="item"?"Drag from anywhere on an item, or press Space on a focused item to start keyboard reordering.":w?"Use your custom drag handle element, or press Space on a focused item to start keyboard reordering.":"Use the handle to drag, or press Space on a focused item to start keyboard reordering.",A=`
|
|
724
|
-
<style>${
|
|
723
|
+
`;function V(l){if(!l)return[];try{const e=JSON.parse(l);return Array.isArray(e)?e:[]}catch{return[]}}function I(l){return l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(l,e){return`${l}::${e??"__root__"}`}function j(l){return l?[l.listId,l.parentId??"",l.beforeId??"",l.mode].join("::"):""}function B(l,e){return j(l)===j(e)}function ne(l){if(!l||l==="none")return{x:1,y:1};const e=l.match(/^matrix3d\((.+)\)$/);if(e){const t=e[1].split(",").map(i=>Number.parseFloat(i.trim()));if(t.length===16&&t.every(i=>Number.isFinite(i)))return{x:t[0]||1,y:t[5]||1}}const r=l.match(/^matrix\((.+)\)$/);if(r){const t=r[1].split(",").map(i=>Number.parseFloat(i.trim()));if(t.length===6&&t.every(i=>Number.isFinite(i))){const[i,s,a,n]=t;return{x:Math.sqrt(i*i+s*s)||1,y:Math.sqrt(a*a+n*n)||1}}}return{x:1,y:1}}function ae(l){return l==="item"?"item":"handle"}function A(l){return{...l}}function de(l,e,r,t,i,s){const a=$(l),n=P(l),d=new Set,o=[],u=g=>{const S=a.get(g);!S||d.has(g)||(d.add(g),o.push(g),(n.get(D(S.listId,g))||[]).forEach(u))};t.forEach(u);const p=l.map(A),m=p.filter(g=>d.has(g.id)),_=i?p.map(A):p.filter(g=>!d.has(g.id)),f=i?m.map(g=>s(g,o)):m.map(A),v=new Map,b=new Map;i&&m.forEach((g,S)=>{v.set(g.id,f[S].id),b.set(f[S].id,g.id)}),f.forEach(g=>{const S=i?b.get(g.id):g.id,T=S?a.get(S):null;T&&(i&&(g.parentId=T.parentId&&v.has(T.parentId)&&v.get(T.parentId)||null),g.listId=r.listId)});const y=t.map(g=>v.get(g)||g),x=[..._,...f],z=P(_),k=D(r.listId,r.parentId),h=[...z.get(k)||[]],E=r.beforeId?h.indexOf(r.beforeId):h.length,H=E>=0?E:h.length;h.splice(H,0,...y),z.set(k,h),P(f).forEach((g,S)=>{const[,T]=S.split("::");(T||"")!=="__root__"&&z.set(S,[...g])});const F=$(x);y.forEach(g=>{const S=F.get(g);S&&(S.parentId=r.parentId,S.listId=r.listId)});const M=[],O=new Set,q=(g,S)=>{(z.get(D(g,S))||[]).forEach((R,K)=>{const c=F.get(R);!c||O.has(R)||(O.add(R),c.listId=g,c.parentId=S,c.order=K,M.push(c),q(g,R))})};return e.forEach(g=>q(g.id,null)),x.forEach(g=>{O.has(g.id)||(g.parentId=null,M.push(g))}),{items:M.map(A),insertedRootIds:y}}function P(l){const e=new Map;return l.forEach(r=>{const t=D(r.listId,r.parentId),i=e.get(t);i?i.push(r.id):e.set(t,[r.id])}),e}function $(l){return new Map(l.map(e=>[e.id,e]))}function X(l){const e=new Set,r=[];return l.forEach((t,i)=>{const s=typeof t?.id=="string"&&t.id.trim()?t.id.trim():`list-${i+1}`;e.has(s)||(e.add(s),r.push({id:s,label:typeof t?.label=="string"&&t.label.trim()?t.label.trim():`List ${i+1}`,description:typeof t?.description=="string"?t.description:"",emptyLabel:typeof t?.emptyLabel=="string"&&t.emptyLabel.trim()?t.emptyLabel.trim():"Drop items here.",orientation:t?.orientation==="horizontal"?"horizontal":"vertical",disabled:!!t?.disabled,cloneOnDrag:!!t?.cloneOnDrag,accepts:Array.isArray(t?.accepts)?t.accepts.filter(a=>typeof a=="string"&&a.trim().length>0):void 0}))}),r.length?r:[{id:"default",label:"Items",description:"",emptyLabel:"Drop items here.",orientation:"vertical",disabled:!1,cloneOnDrag:!1}]}function Y(l,e){const r=new Set(l.map(o=>o.id)),t=[];e.forEach((o,u)=>{const p=typeof o?.id=="string"&&o.id.trim()?o.id.trim():"",m=typeof o?.label=="string"&&o.label.trim()?o.label.trim():"";if(!p||!m)return;const _=typeof o?.listId=="string"&&r.has(o.listId)?o.listId:l[0].id;t.push({id:p,label:m,listId:_,parentId:typeof o?.parentId=="string"&&o.parentId.trim()?o.parentId.trim():null,description:typeof o?.description=="string"?o.description:"",order:Number.isFinite(o?.order)?Number(o.order):u,disabled:!!o?.disabled,dragDisabled:!!o?.dragDisabled,cloneOnDrag:!!o?.cloneOnDrag,hidden:!!o?.hidden})});const i=new Map(t.map(o=>[o.id,o]));t.forEach(o=>{if(!o.parentId)return;const u=i.get(o.parentId);(!u||u.id===o.id||u.listId!==o.listId)&&(o.parentId=null)});const s=new Map;t.forEach(o=>{const u=D(o.listId,o.parentId),p=s.get(u);p?p.push(o):s.set(u,[o])}),s.forEach(o=>o.sort((u,p)=>u.order-p.order||u.label.localeCompare(p.label)));const a=[],n=new Set,d=(o,u)=>{(s.get(D(o,u))||[]).forEach((m,_)=>{n.has(m.id)||(n.add(m.id),m.order=_,a.push(m),d(o,m.id))})};return l.forEach(o=>d(o.id,null)),t.forEach(o=>{n.has(o.id)||(o.parentId=null,a.push(o))}),a.map(A)}function le(l){return JSON.stringify(l.map(e=>({id:e.id,label:e.label,listId:e.listId,parentId:e.parentId,description:e.description,order:e.order,disabled:e.disabled,dragDisabled:e.dragDisabled,cloneOnDrag:e.cloneOnDrag,hidden:e.hidden})))}function ce(l){return JSON.stringify(l.map(e=>({id:e.id,label:e.label,description:e.description,emptyLabel:e.emptyLabel,orientation:e.orientation,disabled:e.disabled,cloneOnDrag:e.cloneOnDrag,accepts:e.accepts})))}function U(l){return JSON.stringify(l)}function J(l){const e=new Map,r=l.map(t=>{const i=D(t.listId,t.parentId),s=e.get(i)??0;return e.set(i,s+1),{id:t.id,listId:t.listId,parentId:t.parentId,index:s}});return{version:re,records:r}}function W(l,e){return e?`${l.label} ${l.description}`.toLowerCase().includes(e.toLowerCase()):!0}function Q(l,e,r,t,i){const s=$(l),a=P(l),n=new Map,d=(p,m)=>{const _=[...a.get(D(p,m))||[]];return i==="label"&&_.sort((f,v)=>{const b=s.get(f),y=s.get(v);return!b||!y?0:b.label.localeCompare(y.label)}),_},o=(p,m,_)=>{const f=[];return d(p,m).forEach(v=>{const b=s.get(v);if(!b||b.hidden)return;const y=o(p,b.id);!W(b,t)&&y.length===0||(f.push({id:b.id,disabled:b.disabled}),y.length&&f.push(...y))}),f};return Array.from(new Set(l.map(p=>p.listId))).forEach(p=>{n.set(p,o(p,null))}),n}class Z extends te.ElementBase{constructor(){super(),this._lists=X([]),this._items=[],this._selection=[],this._focusedId=null,this._rangeAnchorId=null,this._dragState=null,this._liveMessage="Sortable list ready.",this._lastListsAttr=null,this._lastItemsAttr=null,this._lastSelectionAttr=null,this._hydratedPersistKey=null,this._cloneSeed=1,this._dragImage=null,this._dragPreviewOverlay=null,this._pendingFocusId=null,this._pointerGesture=null,this._pendingDropTarget=null,this._suppressAttributeRender=!1,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onDragStart=this._onDragStart.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDrop=this._onDrop.bind(this),this._onDragEnd=this._onDragEnd.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerCancel=this._onPointerCancel.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onDocumentKeyDown=this._onDocumentKeyDown.bind(this)}static get observedAttributes(){return["lists","items","selection","filter-query","sort","persist-key","allow-filtered-drag","allow-nesting","drop-indicator-visibility","dropzone-style","drag-preview-size","drag-handle-mode","drag-handle-selector","custom-item-rendering","show-selection-badge","disabled"]}shouldRenderOnAttributeChange(e,r,t){return this._suppressAttributeRender?!["lists","items","selection"].includes(e):!0}attributeChangedCallback(e,r,t){if(r!==t&&this.isConnected){if(e==="selection"&&!this._suppressAttributeRender&&this._canSyncInteractiveStateInPlace()){this._syncSelectionFromAttribute(t??null),this._syncSelectionVisualState();return}if(e==="show-selection-badge"&&this._canSyncInteractiveStateInPlace()){this._syncSelectionVisualState();return}super.attributeChangedCallback(e,r,t)}}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this.root.addEventListener("dragstart",this._onDragStart),this.root.addEventListener("dragover",this._onDragOver),this.root.addEventListener("drop",this._onDrop),this.root.addEventListener("dragend",this._onDragEnd),this.root.addEventListener("pointerdown",this._onPointerDown),this.root.addEventListener("focusin",this._onFocusIn),this.ownerDocument?.addEventListener("keydown",this._onDocumentKeyDown,!0),this.ownerDocument?.addEventListener("pointermove",this._onPointerMove,!0),this.ownerDocument?.addEventListener("pointerup",this._onPointerUp,!0),this.ownerDocument?.addEventListener("pointercancel",this._onPointerCancel,!0)}disconnectedCallback(){this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this.root.removeEventListener("dragstart",this._onDragStart),this.root.removeEventListener("dragover",this._onDragOver),this.root.removeEventListener("drop",this._onDrop),this.root.removeEventListener("dragend",this._onDragEnd),this.root.removeEventListener("pointerdown",this._onPointerDown),this.root.removeEventListener("focusin",this._onFocusIn),this.ownerDocument?.removeEventListener("keydown",this._onDocumentKeyDown,!0),this.ownerDocument?.removeEventListener("pointermove",this._onPointerMove,!0),this.ownerDocument?.removeEventListener("pointerup",this._onPointerUp,!0),this.ownerDocument?.removeEventListener("pointercancel",this._onPointerCancel,!0),this._removeDragPreviewOverlay(),this._removeDragImage(),super.disconnectedCallback()}get lists(){return this._lists.map(e=>({...e}))}set lists(e){this.setAttribute("lists",JSON.stringify(e??[]))}get items(){return this._items.map(e=>({...e}))}set items(e){this.setAttribute("items",JSON.stringify(e??[]))}get selection(){return[...this._selection]}set selection(e){this.setAttribute("selection",JSON.stringify(e??[]))}get sort(){return this.getAttribute("sort")==="label"?"label":"manual"}set sort(e){!e||e==="manual"?this.removeAttribute("sort"):this.setAttribute("sort",e)}get filterQuery(){return this.getAttribute("filter-query")||""}set filterQuery(e){e?this.setAttribute("filter-query",e):this.removeAttribute("filter-query")}select(e){this._setSelection(e,"api")}clearSelection(){this._setSelection([],"api")}cancelDrag(){this._cancelDrag(!0)}focusItem(e){this._items.some(r=>r.id===e)&&(this._focusedId=e,this._pendingFocusId=e,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender())}moveSelection(e){this._syncSelectionFromAttribute(this.getAttribute("selection"));const r=this._selectedRootIds();r.length&&this._commitMove({listId:e.targetListId,parentId:e.parentId??null,beforeId:e.beforeId??null,mode:e.mode??(e.parentId?"inside":"before")},r,!!e.clone,e.source??"api")}getPersistenceSnapshot(){return J(this._items)}render(){this._syncStateFromAttributes();const e=this._measureItemShellRects(),r=new Set(this._draggingIds()),t=new Set(this._selection),s=!!this._dragState?.keyboard?this._projectedMoveResult():null,a=s?.items||this._items,n=new Set(s?.insertedRootIds||[]),d=!!this._dragState&&!this._dragState.keyboard&&!!this._dragState.dropTarget,o=Q(a,t,r,this.filterQuery,this.sort),u=this._resolvedFocusedId(o),p=this._isDragLocked(),m=this._selection.length,_=this.getAttribute("allow-nesting")!=="false",f=this.getAttribute("drop-indicator-visibility")==="always"?"always":"active",v=this._dropzoneStyle(),b=this.getAttribute("show-selection-badge")!=="false",y=this._dragHandleMode(),x=this._usesCustomHandleSelector(),z=p?this.sort==="label"?"Dragging is paused while alphabetical sorting is active.":this.filterQuery&&!this.hasAttribute("allow-filtered-drag")?"Dragging is paused while the list is filtered.":"Dragging is currently disabled.":this._dragState?.keyboard?"Keyboard drag active. Use arrow keys to choose a drop target, Space or Enter to drop, and Escape to cancel.":y==="item"?"Drag from anywhere on an item, or press Space on a focused item to start keyboard reordering.":x?"Use your custom drag handle element, or press Space on a focused item to start keyboard reordering.":"Use the handle to drag, or press Space on a focused item to start keyboard reordering.",k=`
|
|
724
|
+
<style>${oe}</style>
|
|
725
725
|
<div
|
|
726
726
|
class="root"
|
|
727
727
|
part="root"
|
|
728
|
-
data-drag-locked="${
|
|
729
|
-
data-drag-preview="${
|
|
728
|
+
data-drag-locked="${p}"
|
|
729
|
+
data-drag-preview="${n.size||d?"true":"false"}"
|
|
730
730
|
data-drop-indicator-visibility="${f}"
|
|
731
731
|
data-dropzone-style="${v}"
|
|
732
732
|
>
|
|
733
733
|
<div class="toolbar" part="toolbar">
|
|
734
|
-
<div class="helper">${I(
|
|
734
|
+
<div class="helper">${I(z)}</div>
|
|
735
735
|
<div class="helper selection-summary">
|
|
736
|
-
<span class="selection-pill" part="selection-count">${
|
|
737
|
-
<span class="selection-text">${
|
|
736
|
+
<span class="selection-pill" part="selection-count">${m}</span>
|
|
737
|
+
<span class="selection-text">${m===1?"item selected":"items selected"}</span>
|
|
738
738
|
</div>
|
|
739
739
|
</div>
|
|
740
740
|
<div class="lists" part="lists">
|
|
741
|
-
${this._lists.map(
|
|
741
|
+
${this._lists.map(h=>{const E=o.get(h.id)||[],H=E.length?this._renderListTree(a,h,u,r,_,n,b):"",L=h.disabled?"This list is read-only.":h.cloneOnDrag?"Dragging from this list creates a copy.":h.accepts?.length?`Accepts drops from: ${h.accepts.join(", ")}`:"";return`
|
|
742
742
|
<section
|
|
743
743
|
class="list"
|
|
744
744
|
part="list"
|
|
745
|
-
data-list-id="${I(
|
|
746
|
-
data-orientation="${
|
|
747
|
-
data-disabled="${
|
|
748
|
-
aria-label="${I(
|
|
745
|
+
data-list-id="${I(h.id)}"
|
|
746
|
+
data-orientation="${h.orientation}"
|
|
747
|
+
data-disabled="${h.disabled}"
|
|
748
|
+
aria-label="${I(h.label)}"
|
|
749
749
|
>
|
|
750
750
|
<header class="list-header">
|
|
751
|
-
<div class="list-custom-header" part="list-custom-header" data-list-header-target="${I(
|
|
751
|
+
<div class="list-custom-header" part="list-custom-header" data-list-header-target="${I(h.id)}"></div>
|
|
752
752
|
<div class="list-default-header">
|
|
753
753
|
<div class="list-topline">
|
|
754
|
-
<div class="list-label">${I(
|
|
755
|
-
<span class="list-count">${
|
|
754
|
+
<div class="list-label">${I(h.label)}</div>
|
|
755
|
+
<span class="list-count">${E.length}</span>
|
|
756
756
|
</div>
|
|
757
|
-
${
|
|
758
|
-
${
|
|
757
|
+
${h.description?`<div class="list-description">${I(h.description)}</div>`:""}
|
|
758
|
+
${L?`<div class="list-helper">${I(L)}</div>`:""}
|
|
759
759
|
</div>
|
|
760
760
|
</header>
|
|
761
761
|
<div class="items" role="listbox" aria-multiselectable="true">
|
|
762
|
-
${
|
|
762
|
+
${H||`<div class="list-custom-empty" part="list-custom-empty" data-list-empty-target="${I(h.id)}"></div><div class="empty">${I(h.emptyLabel)}</div>${this._renderDropzone({listId:h.id,parentId:null,beforeId:null,mode:"before"},"Drop here")}`}
|
|
763
763
|
</div>
|
|
764
764
|
</section>
|
|
765
765
|
`}).join("")}
|
|
766
766
|
</div>
|
|
767
767
|
<div class="sr-only" aria-live="polite" aria-atomic="true">${I(this._liveMessage)}</div>
|
|
768
768
|
</div>
|
|
769
|
-
`;this.setContent(
|
|
769
|
+
`;this.setContent(k),queueMicrotask(()=>{this._restorePendingFocus(),this._applyCurrentDropTargetVisualState(),this._applyLiveMessage(),this._updatePointerDragPreview(),this._animateItemShellReflow(e)})}_syncStateFromAttributes(){const e=this.getAttribute("lists");e!==this._lastListsAttr&&(this._lastListsAttr=e,this._lists=X(V(e)));const r=this.getAttribute("items");if(r!==this._lastItemsAttr){this._lastItemsAttr=r,this._items=Y(this._lists,V(r));const i=this.getAttribute("persist-key");i&&this._hydratedPersistKey!==i&&(this._items=this._restorePersistedItems(i,this._items),this._hydratedPersistKey=i)}const t=this.getAttribute("selection");t!==this._lastSelectionAttr&&this._syncSelectionFromAttribute(t),this._focusedId||(this._focusedId=this._items.find(i=>!i.hidden)?.id||null)}_restorePersistedItems(e,r){try{const t=window.localStorage.getItem(e);if(!t)return r;const i=JSON.parse(t);if(!i||typeof i!="object"||!Array.isArray(i.records))return r;const s=new Map(i.records.map(n=>[n.id,n])),a=r.map((n,d)=>{const o=s.get(n.id);return o?{...n,listId:this._lists.some(u=>u.id===o.listId)?o.listId:n.listId,parentId:typeof o.parentId=="string"?o.parentId:null,order:Number.isFinite(o.index)?o.index:d}:{...n,order:d}});return Y(this._lists,a)}catch{return r}}_resolvedFocusedId(e){const r=new Set(Array.from(e.values()).flat().map(i=>i.id));return this._focusedId&&r.has(this._focusedId)?this._focusedId:Array.from(e.values()).flat().find(i=>!i.disabled)?.id||null}_restorePendingFocus(){const e=this._pendingFocusId||this._focusedId;if(!e)return;const r=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"'),t=this.root.querySelector(`.item[data-id="${r}"]`);t&&(document.activeElement!==t&&t.focus({preventScroll:!0}),this._pendingFocusId=null)}_escapeSelectorValue(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"')}_findDropzone(e){const r=this._escapeSelectorValue(e.listId),t=this._escapeSelectorValue(e.parentId??""),i=this._escapeSelectorValue(e.beforeId??""),s=this._escapeSelectorValue(e.mode);return this.root.querySelector(`.dropzone[data-list-id="${r}"][data-parent-id="${t}"][data-before-id="${i}"][data-mode="${s}"]`)}_findItemElement(e){const r=this._escapeSelectorValue(e);return this.root.querySelector(`.item[data-id="${r}"]`)}_dragHandleMode(){return ae(this.getAttribute("drag-handle-mode"))}_dropzoneStyle(){return this.getAttribute("dropzone-style")==="container"?"container":"indicator"}_usesCustomHandleSelector(){return!!this.getAttribute("drag-handle-selector")?.trim()}_dragActivatorFromPath(e){const r=e.find(a=>a instanceof HTMLElement&&!!a.getAttribute("data-drag-trigger"));if(!r)return null;const t=r.getAttribute("data-drag-trigger"),i=t==="item"?"item":t==="custom"?"custom":"handle",s=r.getAttribute("data-id")||r.closest(".item[data-id]")?.getAttribute("data-id");return s?{element:r,id:s,kind:i}:null}_setDropTargetVisualState(e,r){if(!e)return;const t=this._findDropzone(e);t&&(t.setAttribute("data-active",r?"true":"false"),r?this._syncDropzoneContainerSize(t,e):this._clearDropzoneContainerSize(t)),e.mode==="inside"&&e.parentId&&this._findItemElement(e.parentId)?.setAttribute("data-drop-inside-active",r?"true":"false")}_applyCurrentDropTargetVisualState(e){this._setDropTargetVisualState(e??null,!1),this._setDropTargetVisualState(this._dragState?.dropTarget??null,!0)}_applyLiveMessage(){const e=this.root.querySelector(".sr-only[aria-live]");e&&(e.textContent=this._liveMessage)}_canSyncInteractiveStateInPlace(){return!!this.root.querySelector(".root")&&!this._dragState}_applyInteractiveStateInPlace(e){return this._canSyncInteractiveStateInPlace()?(this._syncSelectionVisualState(),e?.restoreFocus&&this._restorePendingFocus(),this._applyLiveMessage(),!0):!1}_hasCustomItemRendering(){return this.hasAttribute("custom-item-rendering")}_syncSelectionFromAttribute(e){this._lastSelectionAttr=e;const r=new Set(this._items.map(t=>t.id));this._selection=V(e).filter(t=>r.has(t)),!this._selection.length&&this._focusedId&&!r.has(this._focusedId)&&(this._focusedId=null)}_syncSelectionVisualState(){const e=new Set(this._selection),r=this.getAttribute("show-selection-badge")!=="false";this.root.querySelectorAll(".item[data-id]").forEach(s=>{const a=s.getAttribute("data-id");if(!a)return;const n=e.has(a),d=this._focusedId===a;s.setAttribute("data-selected",n?"true":"false"),s.setAttribute("aria-selected",n?"true":"false"),s.setAttribute("data-focused",d?"true":"false"),s.setAttribute("tabindex",d?"0":"-1");const o=s.querySelector('[data-selection-badge="true"]');if(o){const u=n&&r;o.hidden=!u,o.textContent=u?"Selected":""}});const t=this.root.querySelector(".selection-pill");t&&(t.textContent=String(this._selection.length));const i=this.root.querySelector(".selection-text");i&&(i.textContent=this._selection.length===1?"item selected":"items selected")}_clearDropzoneContainerSize(e){e.style.removeProperty("--ui-sortable-dropzone-match-block-size"),e.style.removeProperty("--ui-sortable-dropzone-match-inline-size")}_dropzoneReferenceElement(e,r){if(e.mode==="inside"&&e.parentId)return this._findItemElement(e.parentId);let t=r.nextElementSibling;for(;t;){if(t instanceof HTMLElement&&t.classList.contains("item-shell"))return t.querySelector(".item[data-id]");t=t.nextElementSibling}let i=r.previousElementSibling;for(;i;){if(i instanceof HTMLElement&&i.classList.contains("item-shell"))return i.querySelector(".item[data-id]");i=i.previousElementSibling}const s=this._escapeSelectorValue(e.listId),a=this.root.querySelector(`.list[data-list-id="${s}"] .items`),n=a?.querySelector(".item[data-id]");return n||a||null}_syncDropzoneContainerSize(e,r){if(this._clearDropzoneContainerSize(e),this._dropzoneStyle()!=="container")return;const t=this._dropzoneReferenceElement(r,e);if(!t)return;const i=t.getBoundingClientRect();e.style.setProperty("--ui-sortable-dropzone-match-block-size",`${Math.max(76,Math.round(i.height))}px`),e.style.setProperty("--ui-sortable-dropzone-match-inline-size",`${Math.max(180,Math.round(i.width))}px`)}_ensureDragPreviewOverlay(){if(this._dragPreviewOverlay&&this._dragPreviewOverlay.isConnected)return this._dragPreviewOverlay;const e=document.createElement("div");return e.className="drag-preview-overlay",e.setAttribute("data-visible","false"),this.root.appendChild(e),this._dragPreviewOverlay=e,e}_clearPointerDragPreview(){this._dragPreviewOverlay?.setAttribute("data-visible","false"),this._dragPreviewOverlay?.style.setProperty("left","-9999px"),this._dragPreviewOverlay?.style.setProperty("top","-9999px");const e=this.root.querySelector(".root");e&&!this._dragState?.keyboard&&e.setAttribute("data-drag-preview","false")}_pointerPreviewContent(){if(!this._dragState||this._dragState.keyboard)return null;const e=this._dragState.movedRootIds[0],r=this._items.find(t=>t.id===e);return r?{kicker:this._dragState.clone?"Copy preview":"Drop preview",title:this._dragState.clone?`${r.label} copy`:r.label,description:this._dragState.clone?"Release to add a copy here.":this._dragState.movedRootIds.length>1?"Release to place this selection here.":"Release to place this item here."}:null}_pointerPreviewSize(){if(this.getAttribute("drag-preview-size")==="compact"||!this._dragState||this._dragState.keyboard)return null;const e=this._dragState.movedRootIds[0],r=e?this._findItemElement(e):null;if(!r)return null;const t=window.getComputedStyle(r),i=ne(t.transform);return{width:r.offsetWidth*i.x,height:r.offsetHeight*i.y}}_updatePointerDragPreview(){if(!this._dragState||this._dragState.keyboard){this._clearPointerDragPreview();return}const e=this._pointerPreviewContent();if(!e){this._clearPointerDragPreview();return}const r=this.root.querySelector(".root"),i=this._dragPreviewOverlay?.getAttribute("data-visible")==="true",s=this._pointerPreviewSize();if(!this._dragState.dropTarget){i&&r&&r.setAttribute("data-drag-preview","true");return}const a=this._findDropzone(this._dragState.dropTarget);if(!a){i&&r&&r.setAttribute("data-drag-preview","true");return}const n=this._ensureDragPreviewOverlay();n.innerHTML=`
|
|
770
770
|
<div class="placeholder-content">
|
|
771
771
|
<div class="placeholder-kicker">${I(e.kicker)}</div>
|
|
772
772
|
<div class="placeholder-title">${I(e.title)}</div>
|
|
773
773
|
<div class="placeholder-description">${I(e.description)}</div>
|
|
774
774
|
</div>
|
|
775
|
-
`;const
|
|
776
|
-
<div class="item-shell" data-item-shell="${
|
|
775
|
+
`;const d=a.getBoundingClientRect();r&&r.setAttribute("data-drag-preview","true"),n.style.setProperty("left","-9999px"),n.style.setProperty("top","-9999px"),s?(n.style.setProperty("inline-size",`${s.width}px`),n.style.setProperty("block-size",`${s.height}px`)):(n.style.removeProperty("inline-size"),n.style.removeProperty("block-size")),n.setAttribute("data-visible","true");const o=n.getBoundingClientRect(),u=s?.width??o.width,p=s?.height??o.height,m=Math.max(16,Math.min(d.left,window.innerWidth-u-16)),_=Math.max(16,Math.min(d.top+(d.height-p)/2,window.innerHeight-p-16));n.style.setProperty("left",`${Math.round(m)}px`),n.style.setProperty("top",`${Math.round(_)}px`)}_setDraggingVisualState(e,r){e.forEach(t=>{const i=this._findItemElement(t);i&&(i.setAttribute("data-dragging",r?"true":"false"),i.setAttribute("aria-grabbed",r?"true":"false"),r&&i.getBoundingClientRect())})}_setDropTarget(e,r){const t=this._dragState?.dropTarget??null;if(!(!this._dragState||B(t,e))){if(this._pendingDropTarget=null,this._dragState.dropTarget=e,this._applyCurrentDropTargetVisualState(t),r?.announceLabel&&this._announce(r.announceLabel),this._dragState.keyboard){this.requestRender();return}this._updatePointerDragPreview()}}_queueDropTarget(e,r,t){if(!this._dragState)return;const i=this._dragState.dropTarget??null;if(B(i,e)){this._pendingDropTarget=null;return}if(!i&&e){this._setDropTarget(e,t);return}const s=typeof r=="number"&&Number.isFinite(r)?r:performance.now(),a=this._pendingDropTarget;if(a&&B(a.target,e)){const n=e?ie:se;s-a.startedAt>=n&&this._setDropTarget(e,a.announceLabel?{announceLabel:a.announceLabel}:t);return}this._pendingDropTarget={target:e,startedAt:s,announceLabel:t?.announceLabel}}_releaseDropTarget(e,r){if(!this._dragState)return null;if(Number.isFinite(e)&&Number.isFinite(r)){const s=this._dropTargetFromPoint(e,r);if(s&&this._canDrop(s,this._dragState.movedRootIds))return this._pendingDropTarget=null,s}const t=this._pendingDropTarget?.target??null;if(this._pendingDropTarget=null,t&&this._canDrop(t,this._dragState.movedRootIds))return t;const i=this._dragState.dropTarget??null;return i&&this._canDrop(i,this._dragState.movedRootIds)?i:null}_pathFromPoint(e,r){const t=[],i=this.root;let s=typeof i.elementFromPoint=="function"?i.elementFromPoint(e,r):this.ownerDocument?.elementFromPoint(e,r)??null;for(;s&&(s instanceof HTMLElement&&t.push(s),s!==this);){if(s instanceof ShadowRoot){s=s.host;continue}s=s.parentNode,!s&&t[t.length-1]?.getRootNode()instanceof ShadowRoot&&(s=t[t.length-1].getRootNode().host)}return t}_measureItemShellRects(){const e=new Map;return this.root.querySelectorAll(".item-shell[data-item-shell]").forEach(r=>{const t=r.getAttribute("data-item-shell");if(!t)return;const i=r.getBoundingClientRect();e.set(t,{top:i.top,left:i.left})}),e}_animateItemShellReflow(e){if(!e.size)return;const r=new Set(this._draggingIds());this.root.querySelectorAll(".item-shell[data-item-shell]").forEach(t=>{const i=t.getAttribute("data-item-shell");if(!i||r.has(i))return;const s=e.get(i);if(!s)return;const a=t.getBoundingClientRect(),n=s.left-a.left,d=s.top-a.top;Math.abs(n)<.5&&Math.abs(d)<.5||(t.style.transition="none",t.style.transform=`translate(${n}px, ${d}px)`,t.style.willChange="transform",t.getBoundingClientRect(),requestAnimationFrame(()=>{t.style.transition="transform 180ms ease",t.style.transform="";const o=()=>{t.style.transition="",t.style.willChange="",t.removeEventListener("transitionend",o)};t.addEventListener("transitionend",o),window.setTimeout(o,220)}))})}_previewCloneSubtreeItem(e,r){const t=e.id.includes("--copy-")?e.id.split("--copy-")[0]:e.id;return{...e,id:`${t}--preview`,label:r[0]===e.id?`${e.label} copy`:e.label}}_projectedMoveResult(){return!this._dragState?.dropTarget||!this._canDrop(this._dragState.dropTarget,this._dragState.movedRootIds)?null:de(this._items,this._lists,this._dragState.dropTarget,this._dragState.movedRootIds,this._dragState.clone,(e,r)=>this._previewCloneSubtreeItem(e,r))}_renderListTree(e,r,t,i,s,a,n){const d=$(e),o=P(e),u=p=>{const m=o.get(D(r.id,p))||[],_=this.sort==="label"?[...m].sort((v,b)=>{const y=d.get(v),x=d.get(b);return!y||!x?0:y.label.localeCompare(x.label)}):m;let f="";return _.forEach(v=>{const b=d.get(v);if(!b||b.hidden)return;const y=this._renderChildBranch(b,t,i,u,s,a,n);!W(b,this.filterQuery)&&!y.includes('class="item"')||(f+=this._renderDropzone({listId:r.id,parentId:p,beforeId:v,mode:"before"},"Drop here"),f+=y)}),f+=this._renderDropzone({listId:r.id,parentId:p,beforeId:null,mode:"before"},"Drop here"),f};return`<div class="tree">${u(null)}</div>`}_renderChildBranch(e,r,t,i,s,a,n){const d=I(e.id),o=a.has(e.id),u=o?"":i(e.id),p=u.includes('class="item"'),m=o?!1:this._selection.includes(e.id),_=o?!1:t.has(e.id),f=e.disabled,v=f||e.dragDisabled||this._isDragLocked(),b=this._dragState?.dropTarget?.mode==="inside"&&this._dragState.dropTarget.parentId===e.id,y=this._dragState?.clone?"Copy preview":"Drop preview",x=this._dragState?.clone?"Release to add a copy here.":this._dragState&&this._dragState.movedRootIds.length>1?"Release to place this selection here.":"Release to place this item here.",z=this._dragHandleMode(),k=this._usesCustomHandleSelector(),h=k?"custom":z,E=!k&&z==="handle";return`
|
|
776
|
+
<div class="item-shell" data-item-shell="${d}">
|
|
777
777
|
<article
|
|
778
|
-
class="item${
|
|
778
|
+
class="item${o?" item-placeholder":""}"
|
|
779
779
|
part="item"
|
|
780
|
-
data-id="${
|
|
781
|
-
data-drag-handle-mode="${
|
|
782
|
-
${!
|
|
783
|
-
data-selected="${
|
|
784
|
-
data-focused="${
|
|
785
|
-
data-dragging="${
|
|
780
|
+
data-id="${d}"
|
|
781
|
+
data-drag-handle-mode="${h}"
|
|
782
|
+
${!o&&h==="item"?'data-drag-trigger="item"':""}
|
|
783
|
+
data-selected="${m}"
|
|
784
|
+
data-focused="${o?"false":r===e.id}"
|
|
785
|
+
data-dragging="${_}"
|
|
786
786
|
data-disabled="${f}"
|
|
787
787
|
data-drop-inside-active="${b?"true":"false"}"
|
|
788
|
-
role="${
|
|
789
|
-
aria-selected="${
|
|
788
|
+
role="${o?"presentation":"option"}"
|
|
789
|
+
aria-selected="${o?"false":m}"
|
|
790
790
|
aria-disabled="${f}"
|
|
791
|
-
aria-grabbed="${
|
|
792
|
-
aria-hidden="${
|
|
793
|
-
tabindex="${
|
|
791
|
+
aria-grabbed="${o?"false":_}"
|
|
792
|
+
aria-hidden="${o?"true":"false"}"
|
|
793
|
+
tabindex="${o?"-1":r===e.id?"0":"-1"}"
|
|
794
794
|
>
|
|
795
|
-
${
|
|
795
|
+
${o?`
|
|
796
796
|
<div class="placeholder-content">
|
|
797
797
|
<div class="placeholder-kicker">${I(y)}</div>
|
|
798
798
|
<div class="placeholder-title">${I(e.label)}</div>
|
|
799
|
-
<div class="placeholder-description">${I(
|
|
799
|
+
<div class="placeholder-description">${I(x)}</div>
|
|
800
800
|
</div>
|
|
801
801
|
`:`
|
|
802
|
-
${
|
|
802
|
+
${E?`
|
|
803
803
|
<button
|
|
804
804
|
class="handle"
|
|
805
805
|
part="handle"
|
|
806
806
|
type="button"
|
|
807
807
|
data-action="handle"
|
|
808
808
|
data-drag-trigger="handle"
|
|
809
|
-
data-id="${
|
|
809
|
+
data-id="${d}"
|
|
810
810
|
draggable="false"
|
|
811
811
|
${v?"disabled":""}
|
|
812
812
|
aria-label="Drag ${I(e.label)}"
|
|
@@ -821,13 +821,13 @@
|
|
|
821
821
|
</svg>
|
|
822
822
|
</button>
|
|
823
823
|
`:""}
|
|
824
|
-
<div class="item-content" data-action="select" data-id="${
|
|
825
|
-
<div class="item-custom-content" part="item-custom-content" data-item-content-target="${
|
|
824
|
+
<div class="item-content" data-action="select" data-id="${d}">
|
|
825
|
+
<div class="item-custom-content" part="item-custom-content" data-item-content-target="${d}"></div>
|
|
826
826
|
<div class="item-default-content">
|
|
827
827
|
<div class="item-title">${I(e.label)}</div>
|
|
828
828
|
${e.description?`<div class="item-description">${I(e.description)}</div>`:""}
|
|
829
829
|
<div class="item-meta">
|
|
830
|
-
<span class="item-badge selection-badge" data-selection-badge="true" ${
|
|
830
|
+
<span class="item-badge selection-badge" data-selection-badge="true" ${m&&n?"":"hidden"}>${m&&n?"Selected":""}</span>
|
|
831
831
|
${e.cloneOnDrag?'<span class="item-badge">Clone on drag</span>':""}
|
|
832
832
|
${e.dragDisabled?'<span class="item-badge">Pinned</span>':""}
|
|
833
833
|
${s?'<span class="item-badge drop-badge">Nest here</span>':""}
|
|
@@ -836,10 +836,10 @@
|
|
|
836
836
|
</div>
|
|
837
837
|
`}
|
|
838
838
|
</article>
|
|
839
|
-
${s&&!
|
|
840
|
-
${
|
|
839
|
+
${s&&!o?this._renderDropzone({listId:e.listId,parentId:e.id,beforeId:null,mode:"inside"},"Nest here"):""}
|
|
840
|
+
${p?`<div class="children">${u}</div>`:""}
|
|
841
841
|
</div>
|
|
842
|
-
`}_renderDropzone(e,r){
|
|
842
|
+
`}_renderDropzone(e,r){const t=this._dragState?.dropTarget&&this._dragState.dropTarget.listId===e.listId&&this._dragState.dropTarget.parentId===e.parentId&&this._dragState.dropTarget.beforeId===e.beforeId&&this._dragState.dropTarget.mode===e.mode;return`
|
|
843
843
|
<div
|
|
844
844
|
class="dropzone"
|
|
845
845
|
part="dropzone"
|
|
@@ -852,4 +852,4 @@
|
|
|
852
852
|
>
|
|
853
853
|
<span class="dropzone-label">${I(r)}</span>
|
|
854
854
|
</div>
|
|
855
|
-
`}_onClick(e){const r=e.composedPath(),t=r.find(n=>{var d;return n instanceof HTMLElement&&((d=n.classList)==null?void 0:d.contains("toolbar"))}),i=this._dragActivatorFromPath(r),s=r.find(n=>n instanceof HTMLElement&&n.classList.contains("item"));if(i&&i.kind!=="item")return;if(!s)return t&&!(e.target instanceof HTMLButtonElement),void 0;const o=s.getAttribute("data-id");if(!o)return;const a=this._items.find(n=>n.id===o);if(!a||a.disabled)return;const l=e;if(l.shiftKey?this._selectRangeTo(o):l.metaKey||l.ctrlKey?this._toggleSelection(o):this._setSelection([o],"pointer"),this._focusedId=o,this._rangeAnchorId=o,this._pendingFocusId=o,this._hasCustomItemRendering()){this._syncSelectionVisualState(),this._restorePendingFocus();return}this.requestRender()}_onFocusIn(e){const r=e.composedPath().find(i=>i instanceof HTMLElement&&i.classList.contains("item")),t=r==null?void 0:r.getAttribute("data-id");t&&(this._focusedId=t,this._syncSelectionVisualState())}_onKeyDown(e){var l;const r=this._visibleItemIds();if(!r.length)return;const t=this._focusedId&&r.includes(this._focusedId)?this._focusedId:r[0],i=r.indexOf(t),s=this._items.find(n=>n.id===t),o=s?this._lists.find(n=>n.id===s.listId):null,a=(o==null?void 0:o.orientation)==="horizontal";if(!((l=this._dragState)!=null&&l.keyboard)){if(e.key==="ArrowDown"&&!a||e.key==="ArrowRight"&&a){e.preventDefault(),this._moveFocusBy(r,i,1);return}if(e.key==="ArrowUp"&&!a||e.key==="ArrowLeft"&&a){e.preventDefault(),this._moveFocusBy(r,i,-1);return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="a"){e.preventDefault(),this._setSelection(r,"keyboard"),this._announce(`${r.length} items selected.`);return}if(e.key==="Enter"){e.preventDefault(),this._setSelection([t],"keyboard");return}if(e.key===" "||e.code==="Space"){if(e.preventDefault(),this._isDragLocked()){this._announce("Dragging is disabled right now.");return}const n=this._selectedRootIds(t);if(!n.length)return;const d=this._itemClonesOnDrag(t);this._dragState={snapshot:this._items.map($),movedRootIds:n,originId:t,clone:d,keyboard:!0,dropTarget:this._initialKeyboardDropTarget(t),committed:!1};const c=n.length===1?`Lifted ${(s==null?void 0:s.label)||"item"}.`:`Lifted ${n.length} items.`;this._announce(`${c} Use arrow keys to choose a destination.`),this.requestRender();return}if(e.key==="Escape"){this._setSelection([],"keyboard");return}return}if(e.key==="Escape"){e.preventDefault(),this._cancelDrag(!0);return}if(e.key==="Enter"||e.key===" "||e.code==="Space"){e.preventDefault();const n=this._dragState.dropTarget;if(!n)return;this._commitMove(n,this._dragState.movedRootIds,this._dragState.clone,"keyboard");return}if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(e.key)){e.preventDefault();const n=e.key==="ArrowDown"||e.key==="ArrowRight"?1:-1;this._moveKeyboardDropTarget(n)}}_moveFocusBy(e,r,t){const i=Math.max(0,Math.min(e.length-1,r+t)),s=e[i];this._focusedId=s,this._pendingFocusId=s,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender()}_onDragStart(e){const r=this._dragActivatorFromPath(e.composedPath()),t=r==null?void 0:r.id;if(!r||!t){e.preventDefault();return}if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(a=>a.id===t);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}const s=this._selection.includes(t)?this._selectedRootIds(t):[t];this._selection.includes(t)||this._setSelection([t],"pointer");const o=this._itemClonesOnDrag(t);this._dragState={snapshot:this._items.map($),movedRootIds:s,originId:t,clone:o,keyboard:!1,dropTarget:null,committed:!1},e.dataTransfer&&(e.dataTransfer.effectAllowed=o?"copyMove":"move",e.dataTransfer.setData("text/plain",s.join(",")),this._applyDragImage(e.dataTransfer,s.length)),this._announce(o?`Dragging ${s.length===1?i.label:`${s.length} items`} as a copy.`:`Dragging ${s.length===1?i.label:`${s.length} items`}.`),this.requestRender()}_onDragOver(e){if(!this._dragState||this._dragState.keyboard)return;const r=this._dropTargetFromEvent(e);if(!r||!this._canDrop(r,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}e.preventDefault(),this._queueDropTarget(r,e.timeStamp),e.dataTransfer&&(e.dataTransfer.dropEffect=this._dragState.clone?"copy":"move")}_onDrop(e){if(!this._dragState||this._dragState.keyboard)return;const r=this._dropTargetFromEvent(e);!r||!this._canDrop(r,this._dragState.movedRootIds)||(e.preventDefault(),this._commitMove(r,this._dragState.movedRootIds,this._dragState.clone,"pointer"))}_onDocumentKeyDown(e){e.key==="Escape"&&(!this._dragState||this._dragState.keyboard||(e.preventDefault(),this._cancelDrag(!0)))}_onDragEnd(){!this._dragState||this._dragState.keyboard||this._dragState.committed||(this._pendingDropTarget=null,this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage(),this._announce("Drag cancelled."),this.requestRender())}_dropTargetFromEvent(e){return this._dropTargetFromPath(e.composedPath(),e.clientX,e.clientY)}_dropTargetFromPath(e,r,t){const i=e.find(_=>_ instanceof HTMLElement&&_.classList.contains("dropzone"));if(i){const _={listId:i.getAttribute("data-list-id")||"",parentId:i.getAttribute("data-parent-id")||null,beforeId:i.getAttribute("data-before-id")||null,mode:i.getAttribute("data-mode")==="inside"?"inside":"before"};if(_.listId)return _}const s=e.find(_=>_ instanceof HTMLElement&&_.classList.contains("item"));if(!s)return null;const o=s.getAttribute("data-id");if(!o)return null;const a=this._items.find(_=>_.id===o);if(!a)return null;const l=this._lists.find(_=>_.id===a.listId),n=s.getBoundingClientRect(),d=(l==null?void 0:l.orientation)==="horizontal",c=d?n.left:n.top,g=d?n.right:n.bottom,m=d?r:t,f=Math.max(1,g-c),v=(m-c)/f,b=this.getAttribute("allow-nesting")!=="false"&&!a.disabled;if(v<=.34)return{listId:a.listId,parentId:a.parentId,beforeId:a.id,mode:"before"};if(b&&v>=.34&&v<=.74)return{listId:a.listId,parentId:a.id,beforeId:null,mode:"inside"};const w=E(this._items).get(z(a.listId,a.parentId))||[],k=w.indexOf(a.id),A=k>=0&&w[k+1]||null;return{listId:a.listId,parentId:a.parentId,beforeId:A,mode:"before"}}_dropTargetFromPoint(e,r){return this._dropTargetFromPath(this._pathFromPoint(e,r),e,r)}_beginPointerDrag(e,r){if(!this._pointerGesture||this._dragState)return;const t=this._items.find(i=>{var s;return i.id===((s=this._pointerGesture)==null?void 0:s.originId)});t&&(this._dragState={snapshot:this._items.map($),movedRootIds:[...this._pointerGesture.movedRootIds],originId:this._pointerGesture.originId,clone:this._pointerGesture.clone,keyboard:!1,dropTarget:null,committed:!1},this._pendingDropTarget=null,this._applyPointerPreview(e,r,this._dragState.movedRootIds.length,this._dragState.clone),this._setDraggingVisualState(this._draggingIds(),!0),this._announce(this._dragState.clone?`Dragging ${this._dragState.movedRootIds.length===1?t.label:`${this._dragState.movedRootIds.length} items`} as a copy.`:`Dragging ${this._dragState.movedRootIds.length===1?t.label:`${this._dragState.movedRootIds.length} items`}.`))}_onPointerDown(e){var o,a;const r=this._dragActivatorFromPath(e.composedPath()),t=r==null?void 0:r.id;if(!r||!t)return;if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(l=>l.id===t);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}e.preventDefault();try{(a=(o=r.element).setPointerCapture)==null||a.call(o,e.pointerId)}catch{}const s=this._selection.includes(t)?this._selectedRootIds(t):[t];this._pointerGesture={pointerId:e.pointerId,pointerType:e.pointerType,originId:t,movedRootIds:s,clone:this._itemClonesOnDrag(t),startX:e.clientX,startY:e.clientY,moved:!1,captureTarget:r.element}}_onPointerMove(e){if(!(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)){if(e.preventDefault(),!this._pointerGesture.moved){if(Math.hypot(e.clientX-this._pointerGesture.startX,e.clientY-this._pointerGesture.startY)<6)return;this._pointerGesture.moved=!0,this._beginPointerDrag(e.clientX,e.clientY)}if(!(!this._dragState||this._dragState.keyboard)&&(this._movePointerPreview(e.clientX,e.clientY),!this._dragState.committed)){const r=this._dropTargetFromPoint(e.clientX,e.clientY);if(!r||!this._canDrop(r,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}this._queueDropTarget(r,e.timeStamp)}}}_onPointerUp(e){var i,s;if(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)return;e.preventDefault();try{(s=(i=this._pointerGesture.captureTarget)==null?void 0:i.releasePointerCapture)==null||s.call(i,e.pointerId)}catch{}const r=this._pointerGesture;if(this._pointerGesture=null,!this._dragState||this._dragState.keyboard)return;const t=r.moved?this._releaseDropTarget(e.clientX,e.clientY):null;if(r.moved&&t){this._commitMove(t,this._dragState.movedRootIds,this._dragState.clone,"pointer");return}r.moved?this._cancelDrag(!0):(this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage(),this.requestRender())}_onPointerCancel(e){!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId||(this._pointerGesture=null,this._dragState&&this._cancelDrag(!0))}_setSelection(e,r){const t=new Set(this._items.map(a=>a.id)),i=Array.from(new Set(e.filter(a=>t.has(a)))),s=[...this._selection];this._selection=i,this._rangeAnchorId=i[i.length-1]||null,this._focusedId=i[i.length-1]||this._focusedId;const o=j(i);if(this.getAttribute("selection")!==o){this._lastSelectionAttr=o,this._suppressAttributeRender=!0;try{i.length?this.setAttribute("selection",o):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}if(this.dispatchEvent(new CustomEvent("selection-change",{detail:{selection:[...i],previousSelection:s},bubbles:!0,composed:!0})),r!=="restore"){if(this._applyInteractiveStateInPlace({restoreFocus:!0}))return;this.requestRender()}}_toggleSelection(e){const r=this._selection.includes(e)?this._selection.filter(t=>t!==e):[...this._selection,e];this._setSelection(r,"pointer"),this._announce(`${r.length} items selected.`)}_selectRangeTo(e){const r=this._visibleItemIds(),t=this._rangeAnchorId||this._focusedId||e,i=r.indexOf(t),s=r.indexOf(e);if(i<0||s<0){this._setSelection([e],"pointer");return}const[o,a]=i<=s?[i,s]:[s,i];this._setSelection(r.slice(o,a+1),"pointer"),this._announce(`${a-o+1} items selected.`)}_visibleItemIds(){const e=Q(this._items,new Set(this._selection),new Set(this._draggingIds()),this.filterQuery,this.sort);return Array.from(e.values()).flat().filter(r=>!r.disabled).map(r=>r.id)}_selectedRootIds(e){const r=this._selection.length?[...this._selection]:e?[e]:[],t=M(this._items),i=new Set(r);return r.filter(s=>{var l;const o=t.get(s);if(!o)return!1;let a=o.parentId;for(;a;){if(i.has(a))return!1;a=((l=t.get(a))==null?void 0:l.parentId)??null}return!o.disabled})}_draggingIds(){if(!this._dragState)return[];const e=M(this._items),r=E(this._items),t=[],i=s=>{t.push(s);const o=e.get(s);if(!o)return;(r.get(z(o.listId,s))||[]).forEach(i)};return this._dragState.movedRootIds.forEach(i),t}_itemClonesOnDrag(e){const r=this._items.find(i=>i.id===e);if(!r)return!1;if(r.cloneOnDrag)return!0;const t=this._lists.find(i=>i.id===r.listId);return!!(t!=null&&t.cloneOnDrag)}_isDragLocked(){return!!(this.hasAttribute("disabled")||this.sort!=="manual"||this.filterQuery&&!this.hasAttribute("allow-filtered-drag"))}_canDrop(e,r){var n;if(this._isDragLocked())return!1;const t=this._lists.find(d=>d.id===e.listId);if(!t||t.disabled)return!1;const i=M(this._items),s=new Set,o=E(this._items),a=d=>{s.add(d);const c=i.get(d);c&&(o.get(z(c.listId,d))||[]).forEach(a)};if(r.forEach(a),e.parentId&&s.has(e.parentId)||e.beforeId&&s.has(e.beforeId))return!1;const l=Array.from(new Set(r.map(d=>{var c;return(c=i.get(d))==null?void 0:c.listId}).filter(Boolean)));return!((n=t.accepts)!=null&&n.length&&l.some(d=>{var c;return!((c=t.accepts)!=null&&c.includes(d))})||e.mode==="inside"&&this.getAttribute("allow-nesting")==="false")}_commitMove(e,r,t,i){if(!this._canDrop(e,r))return;const s=M(this._items),o=E(this._items),a=new Set,l=[],n=p=>{const D=s.get(p);!D||a.has(p)||(a.add(p),l.push(p),(o.get(z(D.listId,p))||[]).forEach(n))};r.forEach(n);const d=this._items.map($),c=d.filter(p=>a.has(p.id)),g=t?d.map($):d.filter(p=>!a.has(p.id)),m=t?c.map(p=>this._cloneSubtreeItem(p,l)):c.map($),f=new Map,v=new Map;t&&c.forEach((p,D)=>{f.set(p.id,m[D].id),v.set(m[D].id,p.id)}),m.forEach(p=>{const D=t?v.get(p.id):p.id,q=D?s.get(D):null;q&&(t&&(p.parentId=q.parentId&&f.has(q.parentId)&&f.get(q.parentId)||null),p.listId=e.listId)});const b=r.map(p=>f.get(p)||p),y=[...g,...m],w=E(g),k=z(e.listId,e.parentId),A=[...w.get(k)||[]],_=e.beforeId?A.indexOf(e.beforeId):A.length,R=_>=0?_:A.length;A.splice(R,0,...b),w.set(k,A),E(m).forEach((p,D)=>{const[,q]=D.split("::");(q||"")!=="__root__"&&w.set(D,[...p])});const C=M(y);b.forEach(p=>{const D=C.get(p);D&&(D.parentId=e.parentId,D.listId=e.listId)});const T=[],P=new Set,L=(p,D)=>{(w.get(z(p,D))||[]).forEach((N,ee)=>{const H=C.get(N);!H||P.has(N)||(P.add(N),H.listId=p,H.parentId=D,H.order=ee,T.push(H),L(p,N))})};this._lists.forEach(p=>L(p.id,null)),y.forEach(p=>{P.has(p.id)||(p.parentId=null,T.push(p))}),this._dragState&&(this._dragState.committed=!0),this._items=T.map($),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage();const G=[...b],h=[...this._selection];this._selection=G,this._focusedId=G[0]||null,this._pendingFocusId=this._focusedId,this._syncAttributesFromState();const x=J(this._items);this._persistSnapshot(x);const F=r.map(p=>s.get(p)).filter(p=>!!p),O=t?"clone":e.mode==="inside"?"nest":F.some(p=>p.listId!==e.listId)?"transfer":"reorder",K={items:this.items,lists:this.lists,selection:[...G],previousSelection:h,movedIds:[...b],source:i,operation:O,persistence:x};this.dispatchEvent(new CustomEvent("change",{detail:K,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("persist-request",{detail:K,bubbles:!0,composed:!0})),this._announce(this._messageForMove(O,b.length,e)),this.requestRender()}_syncAttributesFromState(){const e=ce(this._lists),r=le(this._items),t=j(this._selection);this._lastListsAttr=e,this._lastItemsAttr=r,this._lastSelectionAttr=t,this._suppressAttributeRender=!0;try{this.setAttribute("lists",e),this.setAttribute("items",r),this._selection.length?this.setAttribute("selection",t):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}_cloneSubtreeItem(e,r){const i=`copy-${this._cloneSeed++}`,o=`${e.id.includes("--copy-")?e.id.split("--copy-")[0]:e.id}--${i}`;return{...e,id:o,label:r[0]===e.id?`${e.label} copy`:e.label}}_messageForMove(e,r,t){const i=this._lists.find(o=>o.id===t.listId),s=(i==null?void 0:i.label)||t.listId;return e==="clone"?`${r===1?"Item copied":`${r} items copied`} into ${s}.`:e==="nest"?`${r===1?"Item nested":`${r} items nested`} in ${s}.`:e==="transfer"?`${r===1?"Item moved":`${r} items moved`} to ${s}.`:`${r===1?"Item reordered":`${r} items reordered`} in ${s}.`}_persistSnapshot(e){const r=this.getAttribute("persist-key");if(r)try{window.localStorage.setItem(r,JSON.stringify(e))}catch{}}_announce(e){this._liveMessage=e,this._applyLiveMessage()}_cancelDrag(e){this._dragState&&(this._pendingDropTarget=null,this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._items=this._dragState.snapshot.map($),this._dragState=null,this._pointerGesture=null,this._removeDragImage(),e&&this._announce("Drag cancelled."),this._syncAttributesFromState(),this.requestRender())}_applyDragImage(e,r){this._removeDragImage();const t=document.createElement("div");t.textContent=r===1?"Dragging item":`Dragging ${r} items`,t.style.position="fixed",t.style.top="-999px",t.style.left="-999px",t.style.padding="8px 12px",t.style.borderRadius="999px",t.style.background="rgba(15, 23, 42, 0.92)",t.style.color="#f8fafc",t.style.font="600 12px/1 Inter, sans-serif",t.style.pointerEvents="none",document.body.appendChild(t),e.setDragImage(t,12,12),this._dragImage=t}_removeDragImage(){var e;(e=this._dragImage)==null||e.remove(),this._dragImage=null}_removeDragPreviewOverlay(){var e;(e=this._dragPreviewOverlay)==null||e.remove(),this._dragPreviewOverlay=null}_applyPointerPreview(e,r,t,i){this._removeDragImage();const s=document.createElement("div");s.textContent=i?t===1?"Copying item":`Copying ${t} items`:t===1?"Moving item":`Moving ${t} items`,s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.zIndex="2147483647",s.style.padding="8px 12px",s.style.borderRadius="999px",s.style.background="rgba(15, 23, 42, 0.92)",s.style.color="#f8fafc",s.style.font="600 12px/1 Inter, sans-serif",s.style.pointerEvents="none",s.style.boxShadow="0 12px 28px rgba(15, 23, 42, 0.22)",document.body.appendChild(s),this._dragImage=s,this._movePointerPreview(e,r)}_movePointerPreview(e,r){this._dragImage&&(this._dragImage.style.transform=`translate(${Math.round(e+14)}px, ${Math.round(r+14)}px)`)}_keyboardDropTargets(){const e=M(this._items),r=E(this._items),t=[],i=(s,o)=>{var l;(r.get(z(s,o))||[]).forEach(n=>{const d=e.get(n);!d||d.hidden||(t.push({listId:s,parentId:o,beforeId:n,mode:"before",label:`Before ${d.label}`}),this.getAttribute("allow-nesting")!=="false"&&t.push({listId:s,parentId:n,beforeId:null,mode:"inside",label:`Nest inside ${d.label}`}),i(s,n))}),t.push({listId:s,parentId:o,beforeId:null,mode:"before",label:o?"After children":`End of ${((l=this._lists.find(n=>n.id===s))==null?void 0:l.label)||s}`})};return this._lists.forEach(s=>i(s.id,null)),t.filter(s=>{var o;return this._canDrop(s,((o=this._dragState)==null?void 0:o.movedRootIds)||[])})}_initialKeyboardDropTarget(e){const r=this._items.find(t=>t.id===e);return r?{listId:r.listId,parentId:r.parentId,beforeId:e,mode:"before"}:null}_moveKeyboardDropTarget(e){if(!this._dragState)return;const r=this._keyboardDropTargets();if(!r.length)return;const t=Math.max(0,r.findIndex(s=>{var o,a,l,n,d,c,g,m;return s.listId===((a=(o=this._dragState)==null?void 0:o.dropTarget)==null?void 0:a.listId)&&s.parentId===((n=(l=this._dragState)==null?void 0:l.dropTarget)==null?void 0:n.parentId)&&s.beforeId===((c=(d=this._dragState)==null?void 0:d.dropTarget)==null?void 0:c.beforeId)&&s.mode===((m=(g=this._dragState)==null?void 0:g.dropTarget)==null?void 0:m.mode)})),i=Math.max(0,Math.min(r.length-1,t+e));this._setDropTarget(r[i],{announceLabel:r[i].label})}}typeof customElements<"u"&&!customElements.get("ui-sortable")&&customElements.define("ui-sortable",Z);exports.UISortable=Z;
|
|
855
|
+
`}_onClick(e){const r=e.composedPath(),t=r.find(o=>o instanceof HTMLElement&&o.classList?.contains("toolbar")),i=this._dragActivatorFromPath(r),s=r.find(o=>o instanceof HTMLElement&&o.classList.contains("item"));if(i&&i.kind!=="item")return;if(!s)return t&&!(e.target instanceof HTMLButtonElement),void 0;const a=s.getAttribute("data-id");if(!a)return;const n=this._items.find(o=>o.id===a);if(!n||n.disabled)return;const d=e;if(d.shiftKey?this._selectRangeTo(a):d.metaKey||d.ctrlKey?this._toggleSelection(a):this._setSelection([a],"pointer"),this._focusedId=a,this._rangeAnchorId=a,this._pendingFocusId=a,this._hasCustomItemRendering()){this._syncSelectionVisualState(),this._restorePendingFocus();return}this.requestRender()}_onFocusIn(e){const t=e.composedPath().find(i=>i instanceof HTMLElement&&i.classList.contains("item"))?.getAttribute("data-id");t&&(this._focusedId=t,this._syncSelectionVisualState())}_onKeyDown(e){const r=this._visibleItemIds();if(!r.length)return;const t=this._focusedId&&r.includes(this._focusedId)?this._focusedId:r[0],i=r.indexOf(t),s=this._items.find(d=>d.id===t),n=(s?this._lists.find(d=>d.id===s.listId):null)?.orientation==="horizontal";if(!this._dragState?.keyboard){if(e.key==="ArrowDown"&&!n||e.key==="ArrowRight"&&n){e.preventDefault(),this._moveFocusBy(r,i,1);return}if(e.key==="ArrowUp"&&!n||e.key==="ArrowLeft"&&n){e.preventDefault(),this._moveFocusBy(r,i,-1);return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="a"){e.preventDefault(),this._setSelection(r,"keyboard"),this._announce(`${r.length} items selected.`);return}if(e.key==="Enter"){e.preventDefault(),this._setSelection([t],"keyboard");return}if(e.key===" "||e.code==="Space"){if(e.preventDefault(),this._isDragLocked()){this._announce("Dragging is disabled right now.");return}const d=this._selectedRootIds(t);if(!d.length)return;const o=this._itemClonesOnDrag(t);this._dragState={snapshot:this._items.map(A),movedRootIds:d,originId:t,clone:o,keyboard:!0,dropTarget:this._initialKeyboardDropTarget(t),committed:!1};const u=d.length===1?`Lifted ${s?.label||"item"}.`:`Lifted ${d.length} items.`;this._announce(`${u} Use arrow keys to choose a destination.`),this.requestRender();return}if(e.key==="Escape"){this._setSelection([],"keyboard");return}return}if(e.key==="Escape"){e.preventDefault(),this._cancelDrag(!0);return}if(e.key==="Enter"||e.key===" "||e.code==="Space"){e.preventDefault();const d=this._dragState.dropTarget;if(!d)return;this._commitMove(d,this._dragState.movedRootIds,this._dragState.clone,"keyboard");return}if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(e.key)){e.preventDefault();const d=e.key==="ArrowDown"||e.key==="ArrowRight"?1:-1;this._moveKeyboardDropTarget(d)}}_moveFocusBy(e,r,t){const i=Math.max(0,Math.min(e.length-1,r+t)),s=e[i];this._focusedId=s,this._pendingFocusId=s,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender()}_onDragStart(e){const r=this._dragActivatorFromPath(e.composedPath()),t=r?.id;if(!r||!t){e.preventDefault();return}if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(n=>n.id===t);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}const s=this._selection.includes(t)?this._selectedRootIds(t):[t];this._selection.includes(t)||this._setSelection([t],"pointer");const a=this._itemClonesOnDrag(t);this._dragState={snapshot:this._items.map(A),movedRootIds:s,originId:t,clone:a,keyboard:!1,dropTarget:null,committed:!1},e.dataTransfer&&(e.dataTransfer.effectAllowed=a?"copyMove":"move",e.dataTransfer.setData("text/plain",s.join(",")),this._applyDragImage(e.dataTransfer,s.length)),this._announce(a?`Dragging ${s.length===1?i.label:`${s.length} items`} as a copy.`:`Dragging ${s.length===1?i.label:`${s.length} items`}.`),this.requestRender()}_onDragOver(e){if(!this._dragState||this._dragState.keyboard)return;const r=this._dropTargetFromEvent(e);if(!r||!this._canDrop(r,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}e.preventDefault(),this._queueDropTarget(r,e.timeStamp),e.dataTransfer&&(e.dataTransfer.dropEffect=this._dragState.clone?"copy":"move")}_onDrop(e){if(!this._dragState||this._dragState.keyboard)return;const r=this._dropTargetFromEvent(e);!r||!this._canDrop(r,this._dragState.movedRootIds)||(e.preventDefault(),this._commitMove(r,this._dragState.movedRootIds,this._dragState.clone,"pointer"))}_onDocumentKeyDown(e){e.key==="Escape"&&(!this._dragState||this._dragState.keyboard||(e.preventDefault(),this._cancelDrag(!0)))}_onDragEnd(){!this._dragState||this._dragState.keyboard||this._dragState.committed||(this._pendingDropTarget=null,this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage(),this._announce("Drag cancelled."),this.requestRender())}_dropTargetFromEvent(e){return this._dropTargetFromPath(e.composedPath(),e.clientX,e.clientY)}_dropTargetFromPath(e,r,t){const i=e.find(h=>h instanceof HTMLElement&&h.classList.contains("dropzone"));if(i){const h={listId:i.getAttribute("data-list-id")||"",parentId:i.getAttribute("data-parent-id")||null,beforeId:i.getAttribute("data-before-id")||null,mode:i.getAttribute("data-mode")==="inside"?"inside":"before"};if(h.listId)return h}const s=e.find(h=>h instanceof HTMLElement&&h.classList.contains("item"));if(!s)return null;const a=s.getAttribute("data-id");if(!a)return null;const n=this._items.find(h=>h.id===a);if(!n)return null;const d=this._lists.find(h=>h.id===n.listId),o=s.getBoundingClientRect(),u=d?.orientation==="horizontal",p=u?o.left:o.top,m=u?o.right:o.bottom,_=u?r:t,f=Math.max(1,m-p),v=(_-p)/f,b=this.getAttribute("allow-nesting")!=="false"&&!n.disabled;if(v<=.34)return{listId:n.listId,parentId:n.parentId,beforeId:n.id,mode:"before"};if(b&&v>=.34&&v<=.74)return{listId:n.listId,parentId:n.id,beforeId:null,mode:"inside"};const x=P(this._items).get(D(n.listId,n.parentId))||[],z=x.indexOf(n.id),k=z>=0&&x[z+1]||null;return{listId:n.listId,parentId:n.parentId,beforeId:k,mode:"before"}}_dropTargetFromPoint(e,r){return this._dropTargetFromPath(this._pathFromPoint(e,r),e,r)}_beginPointerDrag(e,r){if(!this._pointerGesture||this._dragState)return;const t=this._items.find(i=>i.id===this._pointerGesture?.originId);t&&(this._dragState={snapshot:this._items.map(A),movedRootIds:[...this._pointerGesture.movedRootIds],originId:this._pointerGesture.originId,clone:this._pointerGesture.clone,keyboard:!1,dropTarget:null,committed:!1},this._pendingDropTarget=null,this._applyPointerPreview(e,r,this._dragState.movedRootIds.length,this._dragState.clone),this._setDraggingVisualState(this._draggingIds(),!0),this._announce(this._dragState.clone?`Dragging ${this._dragState.movedRootIds.length===1?t.label:`${this._dragState.movedRootIds.length} items`} as a copy.`:`Dragging ${this._dragState.movedRootIds.length===1?t.label:`${this._dragState.movedRootIds.length} items`}.`))}_onPointerDown(e){const r=this._dragActivatorFromPath(e.composedPath()),t=r?.id;if(!r||!t)return;if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(a=>a.id===t);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}e.preventDefault();try{r.element.setPointerCapture?.(e.pointerId)}catch{}const s=this._selection.includes(t)?this._selectedRootIds(t):[t];this._pointerGesture={pointerId:e.pointerId,pointerType:e.pointerType,originId:t,movedRootIds:s,clone:this._itemClonesOnDrag(t),startX:e.clientX,startY:e.clientY,moved:!1,captureTarget:r.element}}_onPointerMove(e){if(!(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)){if(e.preventDefault(),!this._pointerGesture.moved){if(Math.hypot(e.clientX-this._pointerGesture.startX,e.clientY-this._pointerGesture.startY)<6)return;this._pointerGesture.moved=!0,this._beginPointerDrag(e.clientX,e.clientY)}if(!(!this._dragState||this._dragState.keyboard)&&(this._movePointerPreview(e.clientX,e.clientY),!this._dragState.committed)){const r=this._dropTargetFromPoint(e.clientX,e.clientY);if(!r||!this._canDrop(r,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}this._queueDropTarget(r,e.timeStamp)}}}_onPointerUp(e){if(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)return;e.preventDefault();try{this._pointerGesture.captureTarget?.releasePointerCapture?.(e.pointerId)}catch{}const r=this._pointerGesture;if(this._pointerGesture=null,!this._dragState||this._dragState.keyboard)return;const t=r.moved?this._releaseDropTarget(e.clientX,e.clientY):null;if(r.moved&&t){this._commitMove(t,this._dragState.movedRootIds,this._dragState.clone,"pointer");return}r.moved?this._cancelDrag(!0):(this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage(),this.requestRender())}_onPointerCancel(e){!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId||(this._pointerGesture=null,this._dragState&&this._cancelDrag(!0))}_setSelection(e,r){const t=new Set(this._items.map(n=>n.id)),i=Array.from(new Set(e.filter(n=>t.has(n)))),s=[...this._selection];this._selection=i,this._rangeAnchorId=i[i.length-1]||null,this._focusedId=i[i.length-1]||this._focusedId;const a=U(i);if(this.getAttribute("selection")!==a){this._lastSelectionAttr=a,this._suppressAttributeRender=!0;try{i.length?this.setAttribute("selection",a):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}if(this.dispatchEvent(new CustomEvent("selection-change",{detail:{selection:[...i],previousSelection:s},bubbles:!0,composed:!0})),r!=="restore"){if(this._applyInteractiveStateInPlace({restoreFocus:!0}))return;this.requestRender()}}_toggleSelection(e){const r=this._selection.includes(e)?this._selection.filter(t=>t!==e):[...this._selection,e];this._setSelection(r,"pointer"),this._announce(`${r.length} items selected.`)}_selectRangeTo(e){const r=this._visibleItemIds(),t=this._rangeAnchorId||this._focusedId||e,i=r.indexOf(t),s=r.indexOf(e);if(i<0||s<0){this._setSelection([e],"pointer");return}const[a,n]=i<=s?[i,s]:[s,i];this._setSelection(r.slice(a,n+1),"pointer"),this._announce(`${n-a+1} items selected.`)}_visibleItemIds(){const e=Q(this._items,new Set(this._selection),new Set(this._draggingIds()),this.filterQuery,this.sort);return Array.from(e.values()).flat().filter(r=>!r.disabled).map(r=>r.id)}_selectedRootIds(e){const r=this._selection.length?[...this._selection]:e?[e]:[],t=$(this._items),i=new Set(r);return r.filter(s=>{const a=t.get(s);if(!a)return!1;let n=a.parentId;for(;n;){if(i.has(n))return!1;n=t.get(n)?.parentId??null}return!a.disabled})}_draggingIds(){if(!this._dragState)return[];const e=$(this._items),r=P(this._items),t=[],i=s=>{t.push(s);const a=e.get(s);if(!a)return;(r.get(D(a.listId,s))||[]).forEach(i)};return this._dragState.movedRootIds.forEach(i),t}_itemClonesOnDrag(e){const r=this._items.find(i=>i.id===e);return r?r.cloneOnDrag?!0:!!this._lists.find(i=>i.id===r.listId)?.cloneOnDrag:!1}_isDragLocked(){return!!(this.hasAttribute("disabled")||this.sort!=="manual"||this.filterQuery&&!this.hasAttribute("allow-filtered-drag"))}_canDrop(e,r){if(this._isDragLocked())return!1;const t=this._lists.find(o=>o.id===e.listId);if(!t||t.disabled)return!1;const i=$(this._items),s=new Set,a=P(this._items),n=o=>{s.add(o);const u=i.get(o);u&&(a.get(D(u.listId,o))||[]).forEach(n)};if(r.forEach(n),e.parentId&&s.has(e.parentId)||e.beforeId&&s.has(e.beforeId))return!1;const d=Array.from(new Set(r.map(o=>i.get(o)?.listId).filter(Boolean)));return!(t.accepts?.length&&d.some(o=>!t.accepts?.includes(o))||e.mode==="inside"&&this.getAttribute("allow-nesting")==="false")}_commitMove(e,r,t,i){if(!this._canDrop(e,r))return;const s=$(this._items),a=P(this._items),n=new Set,d=[],o=c=>{const w=s.get(c);!w||n.has(c)||(n.add(c),d.push(c),(a.get(D(w.listId,c))||[]).forEach(o))};r.forEach(o);const u=this._items.map(A),p=u.filter(c=>n.has(c.id)),m=t?u.map(A):u.filter(c=>!n.has(c.id)),_=t?p.map(c=>this._cloneSubtreeItem(c,d)):p.map(A),f=new Map,v=new Map;t&&p.forEach((c,w)=>{f.set(c.id,_[w].id),v.set(_[w].id,c.id)}),_.forEach(c=>{const w=t?v.get(c.id):c.id,C=w?s.get(w):null;C&&(t&&(c.parentId=C.parentId&&f.has(C.parentId)&&f.get(C.parentId)||null),c.listId=e.listId)});const b=r.map(c=>f.get(c)||c),y=[...m,..._],x=P(m),z=D(e.listId,e.parentId),k=[...x.get(z)||[]],h=e.beforeId?k.indexOf(e.beforeId):k.length,E=h>=0?h:k.length;k.splice(E,0,...b),x.set(z,k),P(_).forEach((c,w)=>{const[,C]=w.split("::");(C||"")!=="__root__"&&x.set(w,[...c])});const L=$(y);b.forEach(c=>{const w=L.get(c);w&&(w.parentId=e.parentId,w.listId=e.listId)});const F=[],M=new Set,O=(c,w)=>{(x.get(D(c,w))||[]).forEach((N,ee)=>{const G=L.get(N);!G||M.has(N)||(M.add(N),G.listId=c,G.parentId=w,G.order=ee,F.push(G),O(c,N))})};this._lists.forEach(c=>O(c.id,null)),y.forEach(c=>{M.has(c.id)||(c.parentId=null,F.push(c))}),this._dragState&&(this._dragState.committed=!0),this._items=F.map(A),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage();const q=[...b],g=[...this._selection];this._selection=q,this._focusedId=q[0]||null,this._pendingFocusId=this._focusedId,this._syncAttributesFromState();const S=J(this._items);this._persistSnapshot(S);const T=r.map(c=>s.get(c)).filter(c=>!!c),R=t?"clone":e.mode==="inside"?"nest":T.some(c=>c.listId!==e.listId)?"transfer":"reorder",K={items:this.items,lists:this.lists,selection:[...q],previousSelection:g,movedIds:[...b],source:i,operation:R,persistence:S};this.dispatchEvent(new CustomEvent("change",{detail:K,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("persist-request",{detail:K,bubbles:!0,composed:!0})),this._announce(this._messageForMove(R,b.length,e)),this.requestRender()}_syncAttributesFromState(){const e=ce(this._lists),r=le(this._items),t=U(this._selection);this._lastListsAttr=e,this._lastItemsAttr=r,this._lastSelectionAttr=t,this._suppressAttributeRender=!0;try{this.setAttribute("lists",e),this.setAttribute("items",r),this._selection.length?this.setAttribute("selection",t):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}_cloneSubtreeItem(e,r){const i=`copy-${this._cloneSeed++}`,a=`${e.id.includes("--copy-")?e.id.split("--copy-")[0]:e.id}--${i}`;return{...e,id:a,label:r[0]===e.id?`${e.label} copy`:e.label}}_messageForMove(e,r,t){const s=this._lists.find(a=>a.id===t.listId)?.label||t.listId;return e==="clone"?`${r===1?"Item copied":`${r} items copied`} into ${s}.`:e==="nest"?`${r===1?"Item nested":`${r} items nested`} in ${s}.`:e==="transfer"?`${r===1?"Item moved":`${r} items moved`} to ${s}.`:`${r===1?"Item reordered":`${r} items reordered`} in ${s}.`}_persistSnapshot(e){const r=this.getAttribute("persist-key");if(r)try{window.localStorage.setItem(r,JSON.stringify(e))}catch{}}_announce(e){this._liveMessage=e,this._applyLiveMessage()}_cancelDrag(e){this._dragState&&(this._pendingDropTarget=null,this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._items=this._dragState.snapshot.map(A),this._dragState=null,this._pointerGesture=null,this._removeDragImage(),e&&this._announce("Drag cancelled."),this._syncAttributesFromState(),this.requestRender())}_applyDragImage(e,r){this._removeDragImage();const t=document.createElement("div");t.textContent=r===1?"Dragging item":`Dragging ${r} items`,t.style.position="fixed",t.style.top="-999px",t.style.left="-999px",t.style.padding="8px 12px",t.style.borderRadius="999px",t.style.background="rgba(15, 23, 42, 0.92)",t.style.color="#f8fafc",t.style.font="600 12px/1 Inter, sans-serif",t.style.pointerEvents="none",document.body.appendChild(t),e.setDragImage(t,12,12),this._dragImage=t}_removeDragImage(){this._dragImage?.remove(),this._dragImage=null}_removeDragPreviewOverlay(){this._dragPreviewOverlay?.remove(),this._dragPreviewOverlay=null}_applyPointerPreview(e,r,t,i){this._removeDragImage();const s=document.createElement("div");s.textContent=i?t===1?"Copying item":`Copying ${t} items`:t===1?"Moving item":`Moving ${t} items`,s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.zIndex="2147483647",s.style.padding="8px 12px",s.style.borderRadius="999px",s.style.background="rgba(15, 23, 42, 0.92)",s.style.color="#f8fafc",s.style.font="600 12px/1 Inter, sans-serif",s.style.pointerEvents="none",s.style.boxShadow="0 12px 28px rgba(15, 23, 42, 0.22)",document.body.appendChild(s),this._dragImage=s,this._movePointerPreview(e,r)}_movePointerPreview(e,r){this._dragImage&&(this._dragImage.style.transform=`translate(${Math.round(e+14)}px, ${Math.round(r+14)}px)`)}_keyboardDropTargets(){const e=$(this._items),r=P(this._items),t=[],i=(s,a)=>{(r.get(D(s,a))||[]).forEach(d=>{const o=e.get(d);!o||o.hidden||(t.push({listId:s,parentId:a,beforeId:d,mode:"before",label:`Before ${o.label}`}),this.getAttribute("allow-nesting")!=="false"&&t.push({listId:s,parentId:d,beforeId:null,mode:"inside",label:`Nest inside ${o.label}`}),i(s,d))}),t.push({listId:s,parentId:a,beforeId:null,mode:"before",label:a?"After children":`End of ${this._lists.find(d=>d.id===s)?.label||s}`})};return this._lists.forEach(s=>i(s.id,null)),t.filter(s=>this._canDrop(s,this._dragState?.movedRootIds||[]))}_initialKeyboardDropTarget(e){const r=this._items.find(t=>t.id===e);return r?{listId:r.listId,parentId:r.parentId,beforeId:e,mode:"before"}:null}_moveKeyboardDropTarget(e){if(!this._dragState)return;const r=this._keyboardDropTargets();if(!r.length)return;const t=Math.max(0,r.findIndex(s=>s.listId===this._dragState?.dropTarget?.listId&&s.parentId===this._dragState?.dropTarget?.parentId&&s.beforeId===this._dragState?.dropTarget?.beforeId&&s.mode===this._dragState?.dropTarget?.mode)),i=Math.max(0,Math.min(r.length-1,t+e));this._setDropTarget(r[i],{announceLabel:r[i].label})}}typeof customElements<"u"&&!customElements.get("ui-sortable")&&customElements.define("ui-sortable",Z);exports.UISortable=Z;
|