@editora/ui-core 0.1.19 → 0.1.21
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 +30 -29
- package/dist/color-picker.cjs.js +10 -10
- package/dist/color-picker.esm.js +190 -253
- 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-collection.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-orbiter.d.ts.map +1 -1
- package/dist/components/ui-portal.d.ts.map +1 -1
- package/dist/components/ui-positioner.d.ts.map +1 -1
- package/dist/components/ui-skeleton.d.ts.map +1 -1
- package/dist/components/ui-sortable.d.ts +8 -0
- package/dist/components/ui-sortable.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-tabs.d.ts.map +1 -1
- package/dist/components/ui-textarea.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 +7 -7
- package/dist/date-time-picker.esm.js +115 -147
- 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 +5 -5
- package/dist/multi-select.esm.js +125 -137
- 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 +3 -3
- package/dist/portal.esm.js +20 -28
- 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 +22 -28
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +7 -13
- package/dist/primitives/auto-scroll.d.ts +9 -0
- package/dist/primitives/auto-scroll.d.ts.map +1 -0
- package/dist/primitives/selector.d.ts +4 -0
- package/dist/primitives/selector.d.ts.map +1 -0
- 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/selector-BvAh35ve.js +1 -0
- package/dist/selector-WI8pD7YO.mjs +18 -0
- 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 +79 -65
- package/dist/sortable.esm.js +714 -734
- 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 +8 -8
- package/dist/tabs.esm.js +89 -109
- package/dist/tags-input.cjs.js +4 -4
- package/dist/tags-input.esm.js +45 -62
- package/dist/textarea.cjs.js +10 -10
- package/dist/textarea.esm.js +49 -52
- 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 +31 -31
- package/dist/transfer-list.esm.js +114 -127
- 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/sortable.esm.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import { E as ee } from "./ElementBase-
|
|
2
|
-
|
|
1
|
+
import { E as ee } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
function te(l, e, t, r = 56, i = 18) {
|
|
3
|
+
if (!Number.isFinite(l) || !(t > e)) return 0;
|
|
4
|
+
const s = Math.min(r, (t - e) / 2);
|
|
5
|
+
return s <= 0 ? 0 : l < e + s ? -Math.ceil(i * Math.min(1, (e + s - l) / s)) : l > t - s ? Math.ceil(i * Math.min(1, (l - (t - s)) / s)) : 0;
|
|
6
|
+
}
|
|
7
|
+
const re = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
8
|
+
function ie(l) {
|
|
9
|
+
let e = l;
|
|
10
|
+
for (; e; ) {
|
|
11
|
+
if (e = e.parentNode instanceof ShadowRoot ? e.parentNode.host : e.parentNode, !(e instanceof HTMLElement)) continue;
|
|
12
|
+
if (e === e.ownerDocument.body || e === e.ownerDocument.documentElement) return null;
|
|
13
|
+
const { overflowY: t } = e.ownerDocument.defaultView?.getComputedStyle(e) ?? { overflowY: "" };
|
|
14
|
+
if (re.has(t) && e.scrollHeight > e.clientHeight) return e;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const se = 1, oe = 44, ne = 72, ae = `
|
|
3
19
|
:host {
|
|
4
20
|
--ui-sortable-accent: var(--ui-color-primary, #2563eb);
|
|
5
21
|
--ui-sortable-surface: var(--ui-color-surface, #ffffff);
|
|
@@ -103,6 +119,20 @@ const te = 1, re = 44, ie = 72, se = `
|
|
|
103
119
|
align-items: stretch;
|
|
104
120
|
}
|
|
105
121
|
|
|
122
|
+
/* The cards live inside one root .tree wrapper, which is a vertical grid. Without this the
|
|
123
|
+
lane was a flex row holding a single column, so a "horizontal" list rendered vertically. */
|
|
124
|
+
.list[data-orientation="horizontal"] .items > .tree {
|
|
125
|
+
display: flex;
|
|
126
|
+
flex-wrap: nowrap;
|
|
127
|
+
align-items: stretch;
|
|
128
|
+
min-inline-size: min-content;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.list[data-orientation="horizontal"] .items > .tree > .item-shell {
|
|
132
|
+
flex: 0 0 auto;
|
|
133
|
+
min-inline-size: min(220px, 70vw);
|
|
134
|
+
}
|
|
135
|
+
|
|
106
136
|
.list[data-disabled="true"] {
|
|
107
137
|
opacity: 0.68;
|
|
108
138
|
}
|
|
@@ -722,120 +752,119 @@ const te = 1, re = 44, ie = 72, se = `
|
|
|
722
752
|
}
|
|
723
753
|
}
|
|
724
754
|
`;
|
|
725
|
-
function
|
|
726
|
-
if (!
|
|
727
|
-
return [];
|
|
755
|
+
function K(l) {
|
|
756
|
+
if (!l) return [];
|
|
728
757
|
try {
|
|
729
|
-
const e = JSON.parse(
|
|
758
|
+
const e = JSON.parse(l);
|
|
730
759
|
return Array.isArray(e) ? e : [];
|
|
731
760
|
} catch {
|
|
732
761
|
return [];
|
|
733
762
|
}
|
|
734
763
|
}
|
|
735
|
-
function
|
|
736
|
-
return
|
|
764
|
+
function y(l) {
|
|
765
|
+
return l.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
737
766
|
}
|
|
738
|
-
function
|
|
739
|
-
return `${
|
|
767
|
+
function k(l, e) {
|
|
768
|
+
return `${l}::${e ?? "__root__"}`;
|
|
740
769
|
}
|
|
741
|
-
function
|
|
742
|
-
return
|
|
770
|
+
function j(l) {
|
|
771
|
+
return l ? [l.listId, l.parentId ?? "", l.beforeId ?? "", l.mode].join("::") : "";
|
|
743
772
|
}
|
|
744
|
-
function B(
|
|
745
|
-
return
|
|
773
|
+
function B(l, e) {
|
|
774
|
+
return j(l) === j(e);
|
|
746
775
|
}
|
|
747
|
-
function
|
|
748
|
-
if (!
|
|
776
|
+
function le(l) {
|
|
777
|
+
if (!l || l === "none")
|
|
749
778
|
return { x: 1, y: 1 };
|
|
750
|
-
const e =
|
|
779
|
+
const e = l.match(/^matrix3d\((.+)\)$/);
|
|
751
780
|
if (e) {
|
|
752
|
-
const
|
|
753
|
-
if (
|
|
781
|
+
const r = e[1].split(",").map((i) => Number.parseFloat(i.trim()));
|
|
782
|
+
if (r.length === 16 && r.every((i) => Number.isFinite(i)))
|
|
754
783
|
return {
|
|
755
|
-
x:
|
|
756
|
-
y:
|
|
784
|
+
x: r[0] || 1,
|
|
785
|
+
y: r[5] || 1
|
|
757
786
|
};
|
|
758
787
|
}
|
|
759
|
-
const
|
|
760
|
-
if (
|
|
761
|
-
const
|
|
762
|
-
if (
|
|
763
|
-
const [i, s,
|
|
788
|
+
const t = l.match(/^matrix\((.+)\)$/);
|
|
789
|
+
if (t) {
|
|
790
|
+
const r = t[1].split(",").map((i) => Number.parseFloat(i.trim()));
|
|
791
|
+
if (r.length === 6 && r.every((i) => Number.isFinite(i))) {
|
|
792
|
+
const [i, s, n, a] = r;
|
|
764
793
|
return {
|
|
765
794
|
x: Math.sqrt(i * i + s * s) || 1,
|
|
766
|
-
y: Math.sqrt(
|
|
795
|
+
y: Math.sqrt(n * n + a * a) || 1
|
|
767
796
|
};
|
|
768
797
|
}
|
|
769
798
|
}
|
|
770
799
|
return { x: 1, y: 1 };
|
|
771
800
|
}
|
|
772
|
-
function
|
|
773
|
-
return
|
|
801
|
+
function de(l) {
|
|
802
|
+
return l === "item" ? "item" : "handle";
|
|
774
803
|
}
|
|
775
|
-
function P(
|
|
776
|
-
return { ...
|
|
804
|
+
function P(l) {
|
|
805
|
+
return { ...l };
|
|
777
806
|
}
|
|
778
|
-
function
|
|
779
|
-
const
|
|
780
|
-
const x =
|
|
781
|
-
!x ||
|
|
807
|
+
function ce(l, e, t, r, i, s) {
|
|
808
|
+
const n = T(l), a = E(l), d = /* @__PURE__ */ new Set(), o = [], u = (g) => {
|
|
809
|
+
const x = n.get(g);
|
|
810
|
+
!x || d.has(g) || (d.add(g), o.push(g), (a.get(k(x.listId, g)) || []).forEach(u));
|
|
782
811
|
};
|
|
783
|
-
|
|
784
|
-
const c =
|
|
785
|
-
i &&
|
|
786
|
-
|
|
787
|
-
}),
|
|
788
|
-
const x = i ?
|
|
789
|
-
|
|
812
|
+
r.forEach(u);
|
|
813
|
+
const c = l.map(P), h = c.filter((g) => d.has(g.id)), f = i ? c.map(P) : c.filter((g) => !d.has(g.id)), _ = i ? h.map((g) => s(g, o)) : h.map(P), I = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
|
|
814
|
+
i && h.forEach((g, x) => {
|
|
815
|
+
I.set(g.id, _[x].id), m.set(_[x].id, g.id);
|
|
816
|
+
}), _.forEach((g) => {
|
|
817
|
+
const x = i ? m.get(g.id) : g.id, M = x ? n.get(x) : null;
|
|
818
|
+
M && (i && (g.parentId = M.parentId && I.has(M.parentId) && I.get(M.parentId) || null), g.listId = t.listId);
|
|
790
819
|
});
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
const [,
|
|
794
|
-
(
|
|
820
|
+
const v = r.map((g) => I.get(g) || g), D = [...f, ..._], A = E(f), z = k(t.listId, t.parentId), b = [...A.get(z) || []], S = t.beforeId ? b.indexOf(t.beforeId) : b.length, R = S >= 0 ? S : b.length;
|
|
821
|
+
b.splice(R, 0, ...v), A.set(z, b), E(_).forEach((g, x) => {
|
|
822
|
+
const [, M] = x.split("::");
|
|
823
|
+
(M || "") !== "__root__" && A.set(x, [...g]);
|
|
795
824
|
});
|
|
796
|
-
const
|
|
797
|
-
|
|
798
|
-
const x =
|
|
799
|
-
x && (x.parentId =
|
|
825
|
+
const O = T(D);
|
|
826
|
+
v.forEach((g) => {
|
|
827
|
+
const x = O.get(g);
|
|
828
|
+
x && (x.parentId = t.parentId, x.listId = t.listId);
|
|
800
829
|
});
|
|
801
|
-
const
|
|
802
|
-
(
|
|
803
|
-
const p =
|
|
804
|
-
!p ||
|
|
830
|
+
const L = [], q = /* @__PURE__ */ new Set(), H = (g, x) => {
|
|
831
|
+
(A.get(k(g, x)) || []).forEach((C, G) => {
|
|
832
|
+
const p = O.get(C);
|
|
833
|
+
!p || q.has(C) || (q.add(C), p.listId = g, p.parentId = x, p.order = G, L.push(p), H(g, C));
|
|
805
834
|
});
|
|
806
835
|
};
|
|
807
|
-
return e.forEach((
|
|
808
|
-
|
|
836
|
+
return e.forEach((g) => H(g.id, null)), D.forEach((g) => {
|
|
837
|
+
q.has(g.id) || (g.parentId = null, L.push(g));
|
|
809
838
|
}), {
|
|
810
|
-
items:
|
|
811
|
-
insertedRootIds:
|
|
839
|
+
items: L.map(P),
|
|
840
|
+
insertedRootIds: v
|
|
812
841
|
};
|
|
813
842
|
}
|
|
814
|
-
function E(
|
|
843
|
+
function E(l) {
|
|
815
844
|
const e = /* @__PURE__ */ new Map();
|
|
816
|
-
return
|
|
817
|
-
const
|
|
818
|
-
i ? i.push(
|
|
845
|
+
return l.forEach((t) => {
|
|
846
|
+
const r = k(t.listId, t.parentId), i = e.get(r);
|
|
847
|
+
i ? i.push(t.id) : e.set(r, [t.id]);
|
|
819
848
|
}), e;
|
|
820
849
|
}
|
|
821
|
-
function
|
|
822
|
-
return new Map(
|
|
850
|
+
function T(l) {
|
|
851
|
+
return new Map(l.map((e) => [e.id, e]));
|
|
823
852
|
}
|
|
824
|
-
function Y(
|
|
825
|
-
const e = /* @__PURE__ */ new Set(),
|
|
826
|
-
return
|
|
827
|
-
const s = typeof
|
|
828
|
-
e.has(s) || (e.add(s),
|
|
853
|
+
function Y(l) {
|
|
854
|
+
const e = /* @__PURE__ */ new Set(), t = [];
|
|
855
|
+
return l.forEach((r, i) => {
|
|
856
|
+
const s = typeof r?.id == "string" && r.id.trim() ? r.id.trim() : `list-${i + 1}`;
|
|
857
|
+
e.has(s) || (e.add(s), t.push({
|
|
829
858
|
id: s,
|
|
830
|
-
label: typeof
|
|
831
|
-
description: typeof
|
|
832
|
-
emptyLabel: typeof
|
|
833
|
-
orientation:
|
|
834
|
-
disabled: !!
|
|
835
|
-
cloneOnDrag: !!
|
|
836
|
-
accepts: Array.isArray(
|
|
859
|
+
label: typeof r?.label == "string" && r.label.trim() ? r.label.trim() : `List ${i + 1}`,
|
|
860
|
+
description: typeof r?.description == "string" ? r.description : "",
|
|
861
|
+
emptyLabel: typeof r?.emptyLabel == "string" && r.emptyLabel.trim() ? r.emptyLabel.trim() : "Drop items here.",
|
|
862
|
+
orientation: r?.orientation === "horizontal" ? "horizontal" : "vertical",
|
|
863
|
+
disabled: !!r?.disabled,
|
|
864
|
+
cloneOnDrag: !!r?.cloneOnDrag,
|
|
865
|
+
accepts: Array.isArray(r?.accepts) ? r.accepts.filter((n) => typeof n == "string" && n.trim().length > 0) : void 0
|
|
837
866
|
}));
|
|
838
|
-
}),
|
|
867
|
+
}), t.length ? t : [{
|
|
839
868
|
id: "default",
|
|
840
869
|
label: "Items",
|
|
841
870
|
description: "",
|
|
@@ -845,49 +874,47 @@ function Y(u) {
|
|
|
845
874
|
cloneOnDrag: !1
|
|
846
875
|
}];
|
|
847
876
|
}
|
|
848
|
-
function U(
|
|
849
|
-
const
|
|
850
|
-
e.forEach((
|
|
851
|
-
const c = typeof
|
|
852
|
-
if (!c || !
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
t.push({
|
|
877
|
+
function U(l, e) {
|
|
878
|
+
const t = new Set(l.map((o) => o.id)), r = [];
|
|
879
|
+
e.forEach((o, u) => {
|
|
880
|
+
const c = typeof o?.id == "string" && o.id.trim() ? o.id.trim() : "", h = typeof o?.label == "string" && o.label.trim() ? o.label.trim() : "";
|
|
881
|
+
if (!c || !h) return;
|
|
882
|
+
const f = typeof o?.listId == "string" && t.has(o.listId) ? o.listId : l[0].id;
|
|
883
|
+
r.push({
|
|
856
884
|
id: c,
|
|
857
|
-
label:
|
|
858
|
-
listId:
|
|
859
|
-
parentId: typeof
|
|
860
|
-
description: typeof
|
|
861
|
-
order: Number.isFinite(
|
|
862
|
-
disabled: !!
|
|
863
|
-
dragDisabled: !!
|
|
864
|
-
cloneOnDrag: !!
|
|
865
|
-
hidden: !!
|
|
885
|
+
label: h,
|
|
886
|
+
listId: f,
|
|
887
|
+
parentId: typeof o?.parentId == "string" && o.parentId.trim() ? o.parentId.trim() : null,
|
|
888
|
+
description: typeof o?.description == "string" ? o.description : "",
|
|
889
|
+
order: Number.isFinite(o?.order) ? Number(o.order) : u,
|
|
890
|
+
disabled: !!o?.disabled,
|
|
891
|
+
dragDisabled: !!o?.dragDisabled,
|
|
892
|
+
cloneOnDrag: !!o?.cloneOnDrag,
|
|
893
|
+
hidden: !!o?.hidden
|
|
866
894
|
});
|
|
867
895
|
});
|
|
868
|
-
const i = new Map(
|
|
869
|
-
|
|
870
|
-
if (!
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
(!d || d.id === n.id || d.listId !== n.listId) && (n.parentId = null);
|
|
896
|
+
const i = new Map(r.map((o) => [o.id, o]));
|
|
897
|
+
r.forEach((o) => {
|
|
898
|
+
if (!o.parentId) return;
|
|
899
|
+
const u = i.get(o.parentId);
|
|
900
|
+
(!u || u.id === o.id || u.listId !== o.listId) && (o.parentId = null);
|
|
874
901
|
});
|
|
875
902
|
const s = /* @__PURE__ */ new Map();
|
|
876
|
-
|
|
877
|
-
const
|
|
878
|
-
c ? c.push(
|
|
879
|
-
}), s.forEach((
|
|
880
|
-
const
|
|
881
|
-
(s.get(
|
|
882
|
-
a.has(
|
|
903
|
+
r.forEach((o) => {
|
|
904
|
+
const u = k(o.listId, o.parentId), c = s.get(u);
|
|
905
|
+
c ? c.push(o) : s.set(u, [o]);
|
|
906
|
+
}), s.forEach((o) => o.sort((u, c) => u.order - c.order || u.label.localeCompare(c.label)));
|
|
907
|
+
const n = [], a = /* @__PURE__ */ new Set(), d = (o, u) => {
|
|
908
|
+
(s.get(k(o, u)) || []).forEach((h, f) => {
|
|
909
|
+
a.has(h.id) || (a.add(h.id), h.order = f, n.push(h), d(o, h.id));
|
|
883
910
|
});
|
|
884
911
|
};
|
|
885
|
-
return
|
|
886
|
-
a.has(
|
|
887
|
-
}),
|
|
912
|
+
return l.forEach((o) => d(o.id, null)), r.forEach((o) => {
|
|
913
|
+
a.has(o.id) || (o.parentId = null, n.push(o));
|
|
914
|
+
}), n.map(P);
|
|
888
915
|
}
|
|
889
|
-
function
|
|
890
|
-
return JSON.stringify(
|
|
916
|
+
function ue(l) {
|
|
917
|
+
return JSON.stringify(l.map((e) => ({
|
|
891
918
|
id: e.id,
|
|
892
919
|
label: e.label,
|
|
893
920
|
listId: e.listId,
|
|
@@ -900,8 +927,8 @@ function de(u) {
|
|
|
900
927
|
hidden: e.hidden
|
|
901
928
|
})));
|
|
902
929
|
}
|
|
903
|
-
function
|
|
904
|
-
return JSON.stringify(
|
|
930
|
+
function pe(l) {
|
|
931
|
+
return JSON.stringify(l.map((e) => ({
|
|
905
932
|
id: e.id,
|
|
906
933
|
label: e.label,
|
|
907
934
|
description: e.description,
|
|
@@ -912,54 +939,65 @@ function le(u) {
|
|
|
912
939
|
accepts: e.accepts
|
|
913
940
|
})));
|
|
914
941
|
}
|
|
915
|
-
function
|
|
916
|
-
return JSON.stringify(
|
|
942
|
+
function X(l) {
|
|
943
|
+
return JSON.stringify(l);
|
|
917
944
|
}
|
|
918
|
-
function J(
|
|
919
|
-
const e = /* @__PURE__ */ new Map(),
|
|
920
|
-
const i =
|
|
945
|
+
function J(l) {
|
|
946
|
+
const e = /* @__PURE__ */ new Map(), t = l.map((r) => {
|
|
947
|
+
const i = k(r.listId, r.parentId), s = e.get(i) ?? 0;
|
|
921
948
|
return e.set(i, s + 1), {
|
|
922
|
-
id:
|
|
923
|
-
listId:
|
|
924
|
-
parentId:
|
|
949
|
+
id: r.id,
|
|
950
|
+
listId: r.listId,
|
|
951
|
+
parentId: r.parentId,
|
|
925
952
|
index: s
|
|
926
953
|
};
|
|
927
954
|
});
|
|
928
955
|
return {
|
|
929
|
-
version:
|
|
930
|
-
records:
|
|
956
|
+
version: se,
|
|
957
|
+
records: t
|
|
931
958
|
};
|
|
932
959
|
}
|
|
933
|
-
function W(
|
|
934
|
-
return e ? `${
|
|
960
|
+
function W(l, e) {
|
|
961
|
+
return e ? `${l.label} ${l.description}`.toLowerCase().includes(e.toLowerCase()) : !0;
|
|
935
962
|
}
|
|
936
|
-
function Q(
|
|
937
|
-
const s =
|
|
938
|
-
const
|
|
939
|
-
return i === "label" &&
|
|
940
|
-
const
|
|
941
|
-
return !
|
|
942
|
-
}), m;
|
|
943
|
-
}, n = (c, g, m) => {
|
|
944
|
-
const f = [];
|
|
945
|
-
return l(c, g).forEach((v) => {
|
|
946
|
-
const b = s.get(v);
|
|
947
|
-
if (!b || b.hidden)
|
|
948
|
-
return;
|
|
949
|
-
const y = n(c, b.id);
|
|
950
|
-
!W(b, t) && y.length === 0 || (f.push({
|
|
951
|
-
id: b.id,
|
|
952
|
-
disabled: b.disabled
|
|
953
|
-
}), y.length && f.push(...y));
|
|
963
|
+
function Q(l, e, t, r, i) {
|
|
964
|
+
const s = T(l), n = E(l), a = /* @__PURE__ */ new Map(), d = (c, h) => {
|
|
965
|
+
const f = [...n.get(k(c, h)) || []];
|
|
966
|
+
return i === "label" && f.sort((_, I) => {
|
|
967
|
+
const m = s.get(_), v = s.get(I);
|
|
968
|
+
return !m || !v ? 0 : m.label.localeCompare(v.label);
|
|
954
969
|
}), f;
|
|
970
|
+
}, o = (c, h, f) => {
|
|
971
|
+
const _ = [];
|
|
972
|
+
return d(c, h).forEach((I) => {
|
|
973
|
+
const m = s.get(I);
|
|
974
|
+
if (!m || m.hidden) return;
|
|
975
|
+
const v = o(c, m.id);
|
|
976
|
+
!W(m, r) && v.length === 0 || (_.push({
|
|
977
|
+
id: m.id,
|
|
978
|
+
disabled: m.disabled
|
|
979
|
+
}), v.length && _.push(...v));
|
|
980
|
+
}), _;
|
|
955
981
|
};
|
|
956
|
-
return Array.from(new Set(
|
|
957
|
-
a.set(c,
|
|
982
|
+
return Array.from(new Set(l.map((c) => c.listId))).forEach((c) => {
|
|
983
|
+
a.set(c, o(c, null));
|
|
958
984
|
}), a;
|
|
959
985
|
}
|
|
960
|
-
class
|
|
986
|
+
class he extends ee {
|
|
961
987
|
constructor() {
|
|
962
|
-
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.
|
|
988
|
+
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._autoScrollFrame = 0, this._autoScrollPoint = null, this._autoScrollTick = () => {
|
|
989
|
+
this._autoScrollFrame = 0;
|
|
990
|
+
const e = this._autoScrollPoint;
|
|
991
|
+
if (!e || !this._dragState || this._dragState.keyboard) return;
|
|
992
|
+
const t = this.ownerDocument?.defaultView, r = ie(this), i = r ? r.getBoundingClientRect() : null, s = Math.max(0, i ? i.top : 0), n = Math.min(t?.innerHeight ?? 0, i ? i.bottom : 1 / 0), a = te(e.y, s, n);
|
|
993
|
+
if (a) {
|
|
994
|
+
if (r ? r.scrollTop += a : t?.scrollBy(0, a), !this._dragState.committed) {
|
|
995
|
+
const d = this._dropTargetFromPoint(e.x, e.y), o = d && this._canDrop(d, this._dragState.movedRootIds) ? d : null;
|
|
996
|
+
this._queueDropTarget(o, performance.now());
|
|
997
|
+
}
|
|
998
|
+
this._autoScrollFrame = requestAnimationFrame(this._autoScrollTick);
|
|
999
|
+
}
|
|
1000
|
+
}, 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);
|
|
963
1001
|
}
|
|
964
1002
|
static get observedAttributes() {
|
|
965
1003
|
return [
|
|
@@ -981,29 +1019,27 @@ class ce extends ee {
|
|
|
981
1019
|
"disabled"
|
|
982
1020
|
];
|
|
983
1021
|
}
|
|
984
|
-
shouldRenderOnAttributeChange(e,
|
|
1022
|
+
shouldRenderOnAttributeChange(e, t, r) {
|
|
985
1023
|
return this._suppressAttributeRender ? !["lists", "items", "selection"].includes(e) : !0;
|
|
986
1024
|
}
|
|
987
|
-
attributeChangedCallback(e,
|
|
988
|
-
if (
|
|
1025
|
+
attributeChangedCallback(e, t, r) {
|
|
1026
|
+
if (t !== r && this.isConnected) {
|
|
989
1027
|
if (e === "selection" && !this._suppressAttributeRender && this._canSyncInteractiveStateInPlace()) {
|
|
990
|
-
this._syncSelectionFromAttribute(
|
|
1028
|
+
this._syncSelectionFromAttribute(r ?? null), this._syncSelectionVisualState();
|
|
991
1029
|
return;
|
|
992
1030
|
}
|
|
993
1031
|
if (e === "show-selection-badge" && this._canSyncInteractiveStateInPlace()) {
|
|
994
1032
|
this._syncSelectionVisualState();
|
|
995
1033
|
return;
|
|
996
1034
|
}
|
|
997
|
-
super.attributeChangedCallback(e,
|
|
1035
|
+
super.attributeChangedCallback(e, t, r);
|
|
998
1036
|
}
|
|
999
1037
|
}
|
|
1000
1038
|
connectedCallback() {
|
|
1001
|
-
|
|
1002
|
-
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);
|
|
1039
|
+
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);
|
|
1003
1040
|
}
|
|
1004
1041
|
disconnectedCallback() {
|
|
1005
|
-
|
|
1006
|
-
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();
|
|
1042
|
+
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._stopAutoScroll(), this._removeDragPreviewOverlay(), this._removeDragImage(), super.disconnectedCallback();
|
|
1007
1043
|
}
|
|
1008
1044
|
get lists() {
|
|
1009
1045
|
return this._lists.map((e) => ({ ...e }));
|
|
@@ -1045,68 +1081,66 @@ class ce extends ee {
|
|
|
1045
1081
|
this._cancelDrag(!0);
|
|
1046
1082
|
}
|
|
1047
1083
|
focusItem(e) {
|
|
1048
|
-
this._items.some((
|
|
1084
|
+
this._items.some((t) => t.id === e) && (this._focusedId = e, this._pendingFocusId = e, !this._applyInteractiveStateInPlace({ restoreFocus: !0 }) && this.requestRender());
|
|
1049
1085
|
}
|
|
1050
1086
|
moveSelection(e) {
|
|
1051
1087
|
this._syncSelectionFromAttribute(this.getAttribute("selection"));
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1088
|
+
const t = this._selectedRootIds();
|
|
1089
|
+
t.length && this._commitMove({
|
|
1054
1090
|
listId: e.targetListId,
|
|
1055
1091
|
parentId: e.parentId ?? null,
|
|
1056
1092
|
beforeId: e.beforeId ?? null,
|
|
1057
1093
|
mode: e.mode ?? (e.parentId ? "inside" : "before")
|
|
1058
|
-
},
|
|
1094
|
+
}, t, !!e.clone, e.source ?? "api");
|
|
1059
1095
|
}
|
|
1060
1096
|
getPersistenceSnapshot() {
|
|
1061
1097
|
return J(this._items);
|
|
1062
1098
|
}
|
|
1063
1099
|
render() {
|
|
1064
|
-
var _, R;
|
|
1065
1100
|
this._syncStateFromAttributes();
|
|
1066
|
-
const e = this._measureItemShellRects(),
|
|
1067
|
-
<style>${
|
|
1101
|
+
const e = this._measureItemShellRects(), t = new Set(this._draggingIds()), r = new Set(this._selection), s = !!this._dragState?.keyboard ? this._projectedMoveResult() : null, n = s?.items || this._items, a = new Set(s?.insertedRootIds || []), d = !!this._dragState && !this._dragState.keyboard && !!this._dragState.dropTarget, o = Q(n, r, t, this.filterQuery, this.sort), u = this._resolvedFocusedId(o), c = this._isDragLocked(), h = this._selection.length, f = this.getAttribute("allow-nesting") !== "false", _ = this.getAttribute("drop-indicator-visibility") === "always" ? "always" : "active", I = this._dropzoneStyle(), m = this.getAttribute("show-selection-badge") !== "false", v = this._dragHandleMode(), D = this._usesCustomHandleSelector(), A = 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." : this._dragState?.keyboard ? "Keyboard drag active. Use arrow keys to choose a drop target, Space or Enter to drop, and Escape to cancel." : v === "item" ? "Drag from anywhere on an item, or press Space on a focused item to start keyboard reordering." : D ? "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.", z = `
|
|
1102
|
+
<style>${ae}</style>
|
|
1068
1103
|
<div
|
|
1069
1104
|
class="root"
|
|
1070
1105
|
part="root"
|
|
1071
1106
|
data-drag-locked="${c}"
|
|
1072
|
-
data-drag-preview="${a.size ||
|
|
1073
|
-
data-drop-indicator-visibility="${
|
|
1074
|
-
data-dropzone-style="${
|
|
1107
|
+
data-drag-preview="${a.size || d ? "true" : "false"}"
|
|
1108
|
+
data-drop-indicator-visibility="${_}"
|
|
1109
|
+
data-dropzone-style="${I}"
|
|
1075
1110
|
>
|
|
1076
1111
|
<div class="toolbar" part="toolbar">
|
|
1077
|
-
<div class="helper">${
|
|
1112
|
+
<div class="helper">${y(A)}</div>
|
|
1078
1113
|
<div class="helper selection-summary">
|
|
1079
|
-
<span class="selection-pill" part="selection-count">${
|
|
1080
|
-
<span class="selection-text">${
|
|
1114
|
+
<span class="selection-pill" part="selection-count">${h}</span>
|
|
1115
|
+
<span class="selection-text">${h === 1 ? "item selected" : "items selected"}</span>
|
|
1081
1116
|
</div>
|
|
1082
1117
|
</div>
|
|
1083
1118
|
<div class="lists" part="lists">
|
|
1084
|
-
${this._lists.map((
|
|
1085
|
-
|
|
1086
|
-
const C = n.get(S.id) || [], T = C.length ? this._renderListTree(o, S, d, r, m, a, b) : "", $ = S.disabled ? "This list is read-only." : S.cloneOnDrag ? "Dragging from this list creates a copy." : (L = S.accepts) != null && L.length ? `Accepts drops from: ${S.accepts.join(", ")}` : "";
|
|
1119
|
+
${this._lists.map((b) => {
|
|
1120
|
+
const S = o.get(b.id) || [], R = S.length ? this._renderListTree(n, b, u, t, f, a, m) : "", $ = b.disabled ? "This list is read-only." : b.cloneOnDrag ? "Dragging from this list creates a copy." : b.accepts?.length ? `Accepts drops from: ${b.accepts.join(", ")}` : "";
|
|
1087
1121
|
return `
|
|
1088
1122
|
<section
|
|
1089
1123
|
class="list"
|
|
1090
1124
|
part="list"
|
|
1091
|
-
data-list-id="${
|
|
1092
|
-
data-orientation="${
|
|
1093
|
-
data-disabled="${
|
|
1094
|
-
aria-label="${
|
|
1125
|
+
data-list-id="${y(b.id)}"
|
|
1126
|
+
data-orientation="${b.orientation}"
|
|
1127
|
+
data-disabled="${b.disabled}"
|
|
1128
|
+
aria-label="${y(b.label)}"
|
|
1095
1129
|
>
|
|
1096
1130
|
<header class="list-header">
|
|
1097
|
-
<div class="list-custom-header" part="list-custom-header" data-list-header-target="${
|
|
1131
|
+
<div class="list-custom-header" part="list-custom-header" data-list-header-target="${y(b.id)}"></div>
|
|
1098
1132
|
<div class="list-default-header">
|
|
1099
1133
|
<div class="list-topline">
|
|
1100
|
-
<div class="list-label">${
|
|
1101
|
-
<span class="list-count">${
|
|
1134
|
+
<div class="list-label">${y(b.label)}</div>
|
|
1135
|
+
<span class="list-count">${S.length}</span>
|
|
1102
1136
|
</div>
|
|
1103
|
-
${
|
|
1104
|
-
${$ ? `<div class="list-helper">${
|
|
1137
|
+
${b.description ? `<div class="list-description">${y(b.description)}</div>` : ""}
|
|
1138
|
+
${$ ? `<div class="list-helper">${y($)}</div>` : ""}
|
|
1105
1139
|
</div>
|
|
1106
1140
|
</header>
|
|
1107
|
-
<div class="items" role="listbox" aria-multiselectable="true">
|
|
1108
|
-
${
|
|
1109
|
-
listId:
|
|
1141
|
+
<div class="items" role="listbox" aria-multiselectable="true" aria-label="${y(b.label)}">
|
|
1142
|
+
${R || `<div class="list-custom-empty" part="list-custom-empty" data-list-empty-target="${y(b.id)}"></div><div class="empty">${y(b.emptyLabel)}</div>${this._renderDropzone({
|
|
1143
|
+
listId: b.id,
|
|
1110
1144
|
parentId: null,
|
|
1111
1145
|
beforeId: null,
|
|
1112
1146
|
mode: "before"
|
|
@@ -1116,103 +1150,90 @@ class ce extends ee {
|
|
|
1116
1150
|
`;
|
|
1117
1151
|
}).join("")}
|
|
1118
1152
|
</div>
|
|
1119
|
-
<div class="sr-only" aria-live="polite" aria-atomic="true">${
|
|
1153
|
+
<div class="sr-only" aria-live="polite" aria-atomic="true">${y(this._liveMessage)}</div>
|
|
1120
1154
|
</div>
|
|
1121
1155
|
`;
|
|
1122
|
-
this.setContent(
|
|
1156
|
+
this.setContent(z), queueMicrotask(() => {
|
|
1123
1157
|
this._restorePendingFocus(), this._applyCurrentDropTargetVisualState(), this._applyLiveMessage(), this._updatePointerDragPreview(), this._animateItemShellReflow(e);
|
|
1124
1158
|
});
|
|
1125
1159
|
}
|
|
1126
1160
|
_syncStateFromAttributes() {
|
|
1127
|
-
var i;
|
|
1128
1161
|
const e = this.getAttribute("lists");
|
|
1129
|
-
e !== this._lastListsAttr && (this._lastListsAttr = e, this._lists = Y(
|
|
1130
|
-
const
|
|
1131
|
-
if (
|
|
1132
|
-
this._lastItemsAttr =
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1162
|
+
e !== this._lastListsAttr && (this._lastListsAttr = e, this._lists = Y(K(e)));
|
|
1163
|
+
const t = this.getAttribute("items");
|
|
1164
|
+
if (t !== this._lastItemsAttr) {
|
|
1165
|
+
this._lastItemsAttr = t, this._items = U(this._lists, K(t));
|
|
1166
|
+
const i = this.getAttribute("persist-key");
|
|
1167
|
+
i && this._hydratedPersistKey !== i && (this._items = this._restorePersistedItems(i, this._items), this._hydratedPersistKey = i);
|
|
1135
1168
|
}
|
|
1136
|
-
const
|
|
1137
|
-
|
|
1169
|
+
const r = this.getAttribute("selection");
|
|
1170
|
+
r !== this._lastSelectionAttr && this._syncSelectionFromAttribute(r), this._focusedId || (this._focusedId = this._items.find((i) => !i.hidden)?.id || null);
|
|
1138
1171
|
}
|
|
1139
|
-
_restorePersistedItems(e,
|
|
1172
|
+
_restorePersistedItems(e, t) {
|
|
1140
1173
|
try {
|
|
1141
|
-
const
|
|
1142
|
-
if (!t
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
const n = s.get(a.id);
|
|
1149
|
-
return n ? {
|
|
1174
|
+
const r = window.localStorage.getItem(e);
|
|
1175
|
+
if (!r) return t;
|
|
1176
|
+
const i = JSON.parse(r);
|
|
1177
|
+
if (!i || typeof i != "object" || !Array.isArray(i.records)) return t;
|
|
1178
|
+
const s = new Map(i.records.map((a) => [a.id, a])), n = t.map((a, d) => {
|
|
1179
|
+
const o = s.get(a.id);
|
|
1180
|
+
return o ? {
|
|
1150
1181
|
...a,
|
|
1151
|
-
listId: this._lists.some((
|
|
1152
|
-
parentId: typeof
|
|
1153
|
-
order: Number.isFinite(
|
|
1154
|
-
} : { ...a, order:
|
|
1182
|
+
listId: this._lists.some((u) => u.id === o.listId) ? o.listId : a.listId,
|
|
1183
|
+
parentId: typeof o.parentId == "string" ? o.parentId : null,
|
|
1184
|
+
order: Number.isFinite(o.index) ? o.index : d
|
|
1185
|
+
} : { ...a, order: d };
|
|
1155
1186
|
});
|
|
1156
|
-
return U(this._lists,
|
|
1187
|
+
return U(this._lists, n);
|
|
1157
1188
|
} catch {
|
|
1158
|
-
return
|
|
1189
|
+
return t;
|
|
1159
1190
|
}
|
|
1160
1191
|
}
|
|
1161
1192
|
_resolvedFocusedId(e) {
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
return this._focusedId;
|
|
1165
|
-
const t = Array.from(e.values()).flat().find((i) => !i.disabled);
|
|
1166
|
-
return (t == null ? void 0 : t.id) || null;
|
|
1193
|
+
const t = new Set(Array.from(e.values()).flat().map((i) => i.id));
|
|
1194
|
+
return this._focusedId && t.has(this._focusedId) ? this._focusedId : Array.from(e.values()).flat().find((i) => !i.disabled)?.id || null;
|
|
1167
1195
|
}
|
|
1168
1196
|
_restorePendingFocus() {
|
|
1169
1197
|
const e = this._pendingFocusId || this._focusedId;
|
|
1170
|
-
if (!e)
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
t && (document.activeElement !== t && t.focus({ preventScroll: !0 }), this._pendingFocusId = null);
|
|
1198
|
+
if (!e) return;
|
|
1199
|
+
const t = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/"/g, '\\"'), r = this.root.querySelector(`.item[data-id="${t}"]`);
|
|
1200
|
+
r && (document.activeElement !== r && r.focus({ preventScroll: !0 }), this._pendingFocusId = null);
|
|
1174
1201
|
}
|
|
1175
1202
|
_escapeSelectorValue(e) {
|
|
1176
1203
|
return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/"/g, '\\"');
|
|
1177
1204
|
}
|
|
1178
1205
|
_findDropzone(e) {
|
|
1179
|
-
const
|
|
1206
|
+
const t = this._escapeSelectorValue(e.listId), r = this._escapeSelectorValue(e.parentId ?? ""), i = this._escapeSelectorValue(e.beforeId ?? ""), s = this._escapeSelectorValue(e.mode);
|
|
1180
1207
|
return this.root.querySelector(
|
|
1181
|
-
`.dropzone[data-list-id="${
|
|
1208
|
+
`.dropzone[data-list-id="${t}"][data-parent-id="${r}"][data-before-id="${i}"][data-mode="${s}"]`
|
|
1182
1209
|
);
|
|
1183
1210
|
}
|
|
1184
1211
|
_findItemElement(e) {
|
|
1185
|
-
const
|
|
1186
|
-
return this.root.querySelector(`.item[data-id="${
|
|
1212
|
+
const t = this._escapeSelectorValue(e);
|
|
1213
|
+
return this.root.querySelector(`.item[data-id="${t}"]`);
|
|
1187
1214
|
}
|
|
1188
1215
|
_dragHandleMode() {
|
|
1189
|
-
return
|
|
1216
|
+
return de(this.getAttribute("drag-handle-mode"));
|
|
1190
1217
|
}
|
|
1191
1218
|
_dropzoneStyle() {
|
|
1192
1219
|
return this.getAttribute("dropzone-style") === "container" ? "container" : "indicator";
|
|
1193
1220
|
}
|
|
1194
1221
|
_usesCustomHandleSelector() {
|
|
1195
|
-
|
|
1196
|
-
return !!((e = this.getAttribute("drag-handle-selector")) != null && e.trim());
|
|
1222
|
+
return !!this.getAttribute("drag-handle-selector")?.trim();
|
|
1197
1223
|
}
|
|
1198
1224
|
_dragActivatorFromPath(e) {
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
if (!e)
|
|
1209
|
-
return;
|
|
1210
|
-
const t = this._findDropzone(e);
|
|
1211
|
-
t && (t.setAttribute("data-active", r ? "true" : "false"), r ? this._syncDropzoneContainerSize(t, e) : this._clearDropzoneContainerSize(t)), e.mode === "inside" && e.parentId && ((i = this._findItemElement(e.parentId)) == null || i.setAttribute("data-drop-inside-active", r ? "true" : "false"));
|
|
1225
|
+
const t = e.find((n) => n instanceof HTMLElement && !!n.getAttribute("data-drag-trigger"));
|
|
1226
|
+
if (!t) return null;
|
|
1227
|
+
const r = t.getAttribute("data-drag-trigger"), i = r === "item" ? "item" : r === "custom" ? "custom" : "handle", s = t.getAttribute("data-id") || t.closest(".item[data-id]")?.getAttribute("data-id");
|
|
1228
|
+
return s ? { element: t, id: s, kind: i } : null;
|
|
1229
|
+
}
|
|
1230
|
+
_setDropTargetVisualState(e, t) {
|
|
1231
|
+
if (!e) return;
|
|
1232
|
+
const r = this._findDropzone(e);
|
|
1233
|
+
r && (r.setAttribute("data-active", t ? "true" : "false"), t ? this._syncDropzoneContainerSize(r, e) : this._clearDropzoneContainerSize(r)), e.mode === "inside" && e.parentId && this._findItemElement(e.parentId)?.setAttribute("data-drop-inside-active", t ? "true" : "false");
|
|
1212
1234
|
}
|
|
1213
1235
|
_applyCurrentDropTargetVisualState(e) {
|
|
1214
|
-
|
|
1215
|
-
this._setDropTargetVisualState(e ?? null, !1), this._setDropTargetVisualState(((r = this._dragState) == null ? void 0 : r.dropTarget) ?? null, !0);
|
|
1236
|
+
this._setDropTargetVisualState(e ?? null, !1), this._setDropTargetVisualState(this._dragState?.dropTarget ?? null, !0);
|
|
1216
1237
|
}
|
|
1217
1238
|
_applyLiveMessage() {
|
|
1218
1239
|
const e = this.root.querySelector(".sr-only[aria-live]");
|
|
@@ -1222,97 +1243,88 @@ class ce extends ee {
|
|
|
1222
1243
|
return !!this.root.querySelector(".root") && !this._dragState;
|
|
1223
1244
|
}
|
|
1224
1245
|
_applyInteractiveStateInPlace(e) {
|
|
1225
|
-
return this._canSyncInteractiveStateInPlace() ? (this._syncSelectionVisualState(), e
|
|
1246
|
+
return this._canSyncInteractiveStateInPlace() ? (this._syncSelectionVisualState(), e?.restoreFocus && this._restorePendingFocus(), this._applyLiveMessage(), !0) : !1;
|
|
1226
1247
|
}
|
|
1227
1248
|
_hasCustomItemRendering() {
|
|
1228
1249
|
return this.hasAttribute("custom-item-rendering");
|
|
1229
1250
|
}
|
|
1230
1251
|
_syncSelectionFromAttribute(e) {
|
|
1231
1252
|
this._lastSelectionAttr = e;
|
|
1232
|
-
const
|
|
1233
|
-
this._selection =
|
|
1253
|
+
const t = new Set(this._items.map((r) => r.id));
|
|
1254
|
+
this._selection = K(e).filter((r) => t.has(r)), !this._selection.length && this._focusedId && !t.has(this._focusedId) && (this._focusedId = null);
|
|
1234
1255
|
}
|
|
1235
1256
|
_syncSelectionVisualState() {
|
|
1236
|
-
const e = new Set(this._selection),
|
|
1257
|
+
const e = new Set(this._selection), t = this.getAttribute("show-selection-badge") !== "false";
|
|
1237
1258
|
this.root.querySelectorAll(".item[data-id]").forEach((s) => {
|
|
1238
|
-
const
|
|
1239
|
-
if (!
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
n.hidden = !d, n.textContent = d ? "Selected" : "";
|
|
1259
|
+
const n = s.getAttribute("data-id");
|
|
1260
|
+
if (!n) return;
|
|
1261
|
+
const a = e.has(n), d = this._focusedId === n;
|
|
1262
|
+
s.setAttribute("data-selected", a ? "true" : "false"), s.setAttribute("aria-selected", a ? "true" : "false"), s.setAttribute("data-focused", d ? "true" : "false"), s.setAttribute("tabindex", d ? "0" : "-1");
|
|
1263
|
+
const o = s.querySelector('[data-selection-badge="true"]');
|
|
1264
|
+
if (o) {
|
|
1265
|
+
const u = a && t;
|
|
1266
|
+
o.hidden = !u, o.textContent = u ? "Selected" : "";
|
|
1247
1267
|
}
|
|
1248
1268
|
});
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1269
|
+
const r = this.root.querySelector(".selection-pill");
|
|
1270
|
+
r && (r.textContent = String(this._selection.length));
|
|
1251
1271
|
const i = this.root.querySelector(".selection-text");
|
|
1252
1272
|
i && (i.textContent = this._selection.length === 1 ? "item selected" : "items selected");
|
|
1253
1273
|
}
|
|
1254
1274
|
_clearDropzoneContainerSize(e) {
|
|
1255
1275
|
e.style.removeProperty("--ui-sortable-dropzone-match-block-size"), e.style.removeProperty("--ui-sortable-dropzone-match-inline-size");
|
|
1256
1276
|
}
|
|
1257
|
-
_dropzoneReferenceElement(e,
|
|
1258
|
-
if (e.mode === "inside" && e.parentId)
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
t = t.nextElementSibling;
|
|
1277
|
+
_dropzoneReferenceElement(e, t) {
|
|
1278
|
+
if (e.mode === "inside" && e.parentId) return this._findItemElement(e.parentId);
|
|
1279
|
+
let r = t.nextElementSibling;
|
|
1280
|
+
for (; r; ) {
|
|
1281
|
+
if (r instanceof HTMLElement && r.classList.contains("item-shell"))
|
|
1282
|
+
return r.querySelector(".item[data-id]");
|
|
1283
|
+
r = r.nextElementSibling;
|
|
1265
1284
|
}
|
|
1266
|
-
let i =
|
|
1285
|
+
let i = t.previousElementSibling;
|
|
1267
1286
|
for (; i; ) {
|
|
1268
1287
|
if (i instanceof HTMLElement && i.classList.contains("item-shell"))
|
|
1269
1288
|
return i.querySelector(".item[data-id]");
|
|
1270
1289
|
i = i.previousElementSibling;
|
|
1271
1290
|
}
|
|
1272
|
-
const s = this._escapeSelectorValue(e.listId),
|
|
1273
|
-
return a ||
|
|
1274
|
-
}
|
|
1275
|
-
_syncDropzoneContainerSize(e,
|
|
1276
|
-
if (this._clearDropzoneContainerSize(e), this._dropzoneStyle() !== "container")
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
return;
|
|
1281
|
-
const i = t.getBoundingClientRect();
|
|
1291
|
+
const s = this._escapeSelectorValue(e.listId), n = this.root.querySelector(`.list[data-list-id="${s}"] .items`), a = n?.querySelector(".item[data-id]");
|
|
1292
|
+
return a || n || null;
|
|
1293
|
+
}
|
|
1294
|
+
_syncDropzoneContainerSize(e, t) {
|
|
1295
|
+
if (this._clearDropzoneContainerSize(e), this._dropzoneStyle() !== "container") return;
|
|
1296
|
+
const r = this._dropzoneReferenceElement(t, e);
|
|
1297
|
+
if (!r) return;
|
|
1298
|
+
const i = r.getBoundingClientRect();
|
|
1282
1299
|
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`);
|
|
1283
1300
|
}
|
|
1284
1301
|
_ensureDragPreviewOverlay() {
|
|
1285
|
-
if (this._dragPreviewOverlay && this._dragPreviewOverlay.isConnected)
|
|
1286
|
-
return this._dragPreviewOverlay;
|
|
1302
|
+
if (this._dragPreviewOverlay && this._dragPreviewOverlay.isConnected) return this._dragPreviewOverlay;
|
|
1287
1303
|
const e = document.createElement("div");
|
|
1288
1304
|
return e.className = "drag-preview-overlay", e.setAttribute("data-visible", "false"), this.root.appendChild(e), this._dragPreviewOverlay = e, e;
|
|
1289
1305
|
}
|
|
1290
1306
|
_clearPointerDragPreview() {
|
|
1291
|
-
|
|
1292
|
-
(r = this._dragPreviewOverlay) == null || r.setAttribute("data-visible", "false"), (t = this._dragPreviewOverlay) == null || t.style.setProperty("left", "-9999px"), (i = this._dragPreviewOverlay) == null || i.style.setProperty("top", "-9999px");
|
|
1307
|
+
this._dragPreviewOverlay?.setAttribute("data-visible", "false"), this._dragPreviewOverlay?.style.setProperty("left", "-9999px"), this._dragPreviewOverlay?.style.setProperty("top", "-9999px");
|
|
1293
1308
|
const e = this.root.querySelector(".root");
|
|
1294
|
-
e && !
|
|
1309
|
+
e && !this._dragState?.keyboard && e.setAttribute("data-drag-preview", "false");
|
|
1295
1310
|
}
|
|
1296
1311
|
_pointerPreviewContent() {
|
|
1297
|
-
if (!this._dragState || this._dragState.keyboard)
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
return r ? {
|
|
1312
|
+
if (!this._dragState || this._dragState.keyboard) return null;
|
|
1313
|
+
const e = this._dragState.movedRootIds[0], t = this._items.find((r) => r.id === e);
|
|
1314
|
+
return t ? {
|
|
1301
1315
|
kicker: this._dragState.clone ? "Copy preview" : "Drop preview",
|
|
1302
|
-
title: this._dragState.clone ? `${
|
|
1316
|
+
title: this._dragState.clone ? `${t.label} copy` : t.label,
|
|
1303
1317
|
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."
|
|
1304
1318
|
} : null;
|
|
1305
1319
|
}
|
|
1306
1320
|
_pointerPreviewSize() {
|
|
1307
|
-
if (this.getAttribute("drag-preview-size") === "compact" || !this._dragState || this._dragState.keyboard)
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
return null;
|
|
1312
|
-
const t = window.getComputedStyle(r), i = ne(t.transform);
|
|
1321
|
+
if (this.getAttribute("drag-preview-size") === "compact" || !this._dragState || this._dragState.keyboard) return null;
|
|
1322
|
+
const e = this._dragState.movedRootIds[0], t = e ? this._findItemElement(e) : null;
|
|
1323
|
+
if (!t) return null;
|
|
1324
|
+
const r = window.getComputedStyle(t), i = le(r.transform);
|
|
1313
1325
|
return {
|
|
1314
|
-
width:
|
|
1315
|
-
height:
|
|
1326
|
+
width: t.offsetWidth * i.x,
|
|
1327
|
+
height: t.offsetHeight * i.y
|
|
1316
1328
|
};
|
|
1317
1329
|
}
|
|
1318
1330
|
_updatePointerDragPreview() {
|
|
@@ -1325,230 +1337,226 @@ class ce extends ee {
|
|
|
1325
1337
|
this._clearPointerDragPreview();
|
|
1326
1338
|
return;
|
|
1327
1339
|
}
|
|
1328
|
-
const
|
|
1340
|
+
const t = this.root.querySelector(".root"), i = this._dragPreviewOverlay?.getAttribute("data-visible") === "true", s = this._pointerPreviewSize();
|
|
1329
1341
|
if (!this._dragState.dropTarget) {
|
|
1330
|
-
i &&
|
|
1342
|
+
i && t && t.setAttribute("data-drag-preview", "true");
|
|
1331
1343
|
return;
|
|
1332
1344
|
}
|
|
1333
|
-
const
|
|
1334
|
-
if (!
|
|
1335
|
-
i &&
|
|
1345
|
+
const n = this._findDropzone(this._dragState.dropTarget);
|
|
1346
|
+
if (!n) {
|
|
1347
|
+
i && t && t.setAttribute("data-drag-preview", "true");
|
|
1336
1348
|
return;
|
|
1337
1349
|
}
|
|
1338
1350
|
const a = this._ensureDragPreviewOverlay();
|
|
1339
1351
|
a.innerHTML = `
|
|
1340
1352
|
<div class="placeholder-content">
|
|
1341
|
-
<div class="placeholder-kicker">${
|
|
1342
|
-
<div class="placeholder-title">${
|
|
1343
|
-
<div class="placeholder-description">${
|
|
1353
|
+
<div class="placeholder-kicker">${y(e.kicker)}</div>
|
|
1354
|
+
<div class="placeholder-title">${y(e.title)}</div>
|
|
1355
|
+
<div class="placeholder-description">${y(e.description)}</div>
|
|
1344
1356
|
</div>
|
|
1345
1357
|
`;
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1348
|
-
const
|
|
1358
|
+
const d = n.getBoundingClientRect();
|
|
1359
|
+
t && t.setAttribute("data-drag-preview", "true"), a.style.setProperty("left", "-9999px"), a.style.setProperty("top", "-9999px"), s ? (a.style.setProperty("inline-size", `${s.width}px`), a.style.setProperty("block-size", `${s.height}px`)) : (a.style.removeProperty("inline-size"), a.style.removeProperty("block-size")), a.setAttribute("data-visible", "true");
|
|
1360
|
+
const o = a.getBoundingClientRect(), u = s?.width ?? o.width, c = s?.height ?? o.height, h = Math.max(16, Math.min(d.left, window.innerWidth - u - 16)), f = Math.max(
|
|
1349
1361
|
16,
|
|
1350
1362
|
Math.min(
|
|
1351
|
-
|
|
1363
|
+
d.top + (d.height - c) / 2,
|
|
1352
1364
|
window.innerHeight - c - 16
|
|
1353
1365
|
)
|
|
1354
1366
|
);
|
|
1355
|
-
a.style.setProperty("left", `${Math.round(
|
|
1367
|
+
a.style.setProperty("left", `${Math.round(h)}px`), a.style.setProperty("top", `${Math.round(f)}px`);
|
|
1356
1368
|
}
|
|
1357
|
-
_setDraggingVisualState(e,
|
|
1358
|
-
e.forEach((
|
|
1359
|
-
const i = this._findItemElement(
|
|
1360
|
-
i && (i.setAttribute("data-dragging",
|
|
1369
|
+
_setDraggingVisualState(e, t) {
|
|
1370
|
+
e.forEach((r) => {
|
|
1371
|
+
const i = this._findItemElement(r);
|
|
1372
|
+
i && (i.setAttribute("data-dragging", t ? "true" : "false"), i.setAttribute("aria-grabbed", t ? "true" : "false"), t && i.getBoundingClientRect());
|
|
1361
1373
|
});
|
|
1362
1374
|
}
|
|
1363
|
-
_setDropTarget(e,
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
if (this._pendingDropTarget = null, this._dragState.dropTarget = e, this._applyCurrentDropTargetVisualState(t), r != null && r.announceLabel && this._announce(r.announceLabel), this._dragState.keyboard) {
|
|
1375
|
+
_setDropTarget(e, t) {
|
|
1376
|
+
const r = this._dragState?.dropTarget ?? null;
|
|
1377
|
+
if (!(!this._dragState || B(r, e))) {
|
|
1378
|
+
if (this._pendingDropTarget = null, this._dragState.dropTarget = e, this._applyCurrentDropTargetVisualState(r), t?.announceLabel && this._announce(t.announceLabel), this._dragState.keyboard) {
|
|
1368
1379
|
this.requestRender();
|
|
1369
1380
|
return;
|
|
1370
1381
|
}
|
|
1371
1382
|
this._updatePointerDragPreview();
|
|
1372
1383
|
}
|
|
1373
1384
|
}
|
|
1374
|
-
_queueDropTarget(e,
|
|
1375
|
-
if (!this._dragState)
|
|
1376
|
-
return;
|
|
1385
|
+
_queueDropTarget(e, t, r) {
|
|
1386
|
+
if (!this._dragState) return;
|
|
1377
1387
|
const i = this._dragState.dropTarget ?? null;
|
|
1378
1388
|
if (B(i, e)) {
|
|
1379
1389
|
this._pendingDropTarget = null;
|
|
1380
1390
|
return;
|
|
1381
1391
|
}
|
|
1382
1392
|
if (!i && e) {
|
|
1383
|
-
this._setDropTarget(e,
|
|
1393
|
+
this._setDropTarget(e, r);
|
|
1384
1394
|
return;
|
|
1385
1395
|
}
|
|
1386
|
-
const s = typeof
|
|
1387
|
-
if (
|
|
1388
|
-
const a = e ?
|
|
1389
|
-
s -
|
|
1396
|
+
const s = typeof t == "number" && Number.isFinite(t) ? t : performance.now(), n = this._pendingDropTarget;
|
|
1397
|
+
if (n && B(n.target, e)) {
|
|
1398
|
+
const a = e ? oe : ne;
|
|
1399
|
+
s - n.startedAt >= a && this._setDropTarget(e, n.announceLabel ? { announceLabel: n.announceLabel } : r);
|
|
1390
1400
|
return;
|
|
1391
1401
|
}
|
|
1392
1402
|
this._pendingDropTarget = {
|
|
1393
1403
|
target: e,
|
|
1394
1404
|
startedAt: s,
|
|
1395
|
-
announceLabel:
|
|
1405
|
+
announceLabel: r?.announceLabel
|
|
1396
1406
|
};
|
|
1397
1407
|
}
|
|
1398
|
-
_releaseDropTarget(e,
|
|
1399
|
-
|
|
1400
|
-
if (
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
if (o && this._canDrop(o, this._dragState.movedRootIds))
|
|
1405
|
-
return this._pendingDropTarget = null, o;
|
|
1408
|
+
_releaseDropTarget(e, t) {
|
|
1409
|
+
if (!this._dragState) return null;
|
|
1410
|
+
if (Number.isFinite(e) && Number.isFinite(t)) {
|
|
1411
|
+
const n = this._dropTargetFromPoint(e, t);
|
|
1412
|
+
if (n && this._canDrop(n, this._dragState.movedRootIds))
|
|
1413
|
+
return this._pendingDropTarget = null, n;
|
|
1406
1414
|
}
|
|
1407
|
-
const
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1415
|
+
const r = this._pendingDropTarget?.target ?? null;
|
|
1416
|
+
this._pendingDropTarget = null;
|
|
1417
|
+
const i = (n) => this._pointerIsOverList(n.listId, e, t);
|
|
1418
|
+
if (r && this._canDrop(r, this._dragState.movedRootIds) && i(r)) return r;
|
|
1419
|
+
const s = this._dragState.dropTarget ?? null;
|
|
1420
|
+
return s && this._canDrop(s, this._dragState.movedRootIds) && i(s) ? s : null;
|
|
1421
|
+
}
|
|
1422
|
+
_pointerIsOverList(e, t, r) {
|
|
1423
|
+
if (!Number.isFinite(t) || !Number.isFinite(r)) return !0;
|
|
1424
|
+
const s = Array.from(this.root.querySelectorAll(".list[data-list-id]")).find((a) => a.getAttribute("data-list-id") === e);
|
|
1425
|
+
if (!s) return !0;
|
|
1426
|
+
const n = s.getBoundingClientRect();
|
|
1427
|
+
return t >= n.left && t <= n.right && r >= n.top && r <= n.bottom;
|
|
1428
|
+
}
|
|
1429
|
+
_pathFromPoint(e, t) {
|
|
1430
|
+
const r = [], i = this.root;
|
|
1431
|
+
let s = typeof i.elementFromPoint == "function" ? i.elementFromPoint(e, t) : this.ownerDocument?.elementFromPoint(e, t) ?? null;
|
|
1432
|
+
for (; s && (s instanceof HTMLElement && r.push(s), s !== this); ) {
|
|
1418
1433
|
if (s instanceof ShadowRoot) {
|
|
1419
1434
|
s = s.host;
|
|
1420
1435
|
continue;
|
|
1421
1436
|
}
|
|
1422
|
-
s = s.parentNode, !s &&
|
|
1437
|
+
s = s.parentNode, !s && r[r.length - 1]?.getRootNode() instanceof ShadowRoot && (s = r[r.length - 1].getRootNode().host);
|
|
1423
1438
|
}
|
|
1424
|
-
return
|
|
1439
|
+
return r;
|
|
1425
1440
|
}
|
|
1426
1441
|
_measureItemShellRects() {
|
|
1427
1442
|
const e = /* @__PURE__ */ new Map();
|
|
1428
|
-
return this.root.querySelectorAll(".item-shell[data-item-shell]").forEach((
|
|
1429
|
-
const
|
|
1430
|
-
if (!
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
e.set(t, { top: i.top, left: i.left });
|
|
1443
|
+
return this.root.querySelectorAll(".item-shell[data-item-shell]").forEach((t) => {
|
|
1444
|
+
const r = t.getAttribute("data-item-shell");
|
|
1445
|
+
if (!r) return;
|
|
1446
|
+
const i = t.getBoundingClientRect();
|
|
1447
|
+
e.set(r, { top: i.top, left: i.left });
|
|
1434
1448
|
}), e;
|
|
1435
1449
|
}
|
|
1436
1450
|
_animateItemShellReflow(e) {
|
|
1437
|
-
if (!e.size)
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
if (!i || r.has(i))
|
|
1443
|
-
return;
|
|
1451
|
+
if (!e.size) return;
|
|
1452
|
+
const t = new Set(this._draggingIds());
|
|
1453
|
+
this.root.querySelectorAll(".item-shell[data-item-shell]").forEach((r) => {
|
|
1454
|
+
const i = r.getAttribute("data-item-shell");
|
|
1455
|
+
if (!i || t.has(i)) return;
|
|
1444
1456
|
const s = e.get(i);
|
|
1445
|
-
if (!s)
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
t.style.transition = "", t.style.willChange = "", t.removeEventListener("transitionend", n);
|
|
1457
|
+
if (!s) return;
|
|
1458
|
+
const n = r.getBoundingClientRect(), a = s.left - n.left, d = s.top - n.top;
|
|
1459
|
+
Math.abs(a) < 0.5 && Math.abs(d) < 0.5 || (r.style.transition = "none", r.style.transform = `translate(${a}px, ${d}px)`, r.style.willChange = "transform", r.getBoundingClientRect(), requestAnimationFrame(() => {
|
|
1460
|
+
r.style.transition = "transform 180ms ease", r.style.transform = "";
|
|
1461
|
+
const o = () => {
|
|
1462
|
+
r.style.transition = "", r.style.willChange = "", r.removeEventListener("transitionend", o);
|
|
1452
1463
|
};
|
|
1453
|
-
|
|
1464
|
+
r.addEventListener("transitionend", o), window.setTimeout(o, 220);
|
|
1454
1465
|
}));
|
|
1455
1466
|
});
|
|
1456
1467
|
}
|
|
1457
|
-
_previewCloneSubtreeItem(e,
|
|
1458
|
-
const
|
|
1468
|
+
_previewCloneSubtreeItem(e, t) {
|
|
1469
|
+
const r = e.id.includes("--copy-") ? e.id.split("--copy-")[0] : e.id;
|
|
1459
1470
|
return {
|
|
1460
1471
|
...e,
|
|
1461
|
-
id: `${
|
|
1462
|
-
label:
|
|
1472
|
+
id: `${r}--preview`,
|
|
1473
|
+
label: t[0] === e.id ? `${e.label} copy` : e.label
|
|
1463
1474
|
};
|
|
1464
1475
|
}
|
|
1465
1476
|
_projectedMoveResult() {
|
|
1466
|
-
|
|
1467
|
-
return !((e = this._dragState) != null && e.dropTarget) || !this._canDrop(this._dragState.dropTarget, this._dragState.movedRootIds) ? null : ae(
|
|
1477
|
+
return !this._dragState?.dropTarget || !this._canDrop(this._dragState.dropTarget, this._dragState.movedRootIds) ? null : ce(
|
|
1468
1478
|
this._items,
|
|
1469
1479
|
this._lists,
|
|
1470
1480
|
this._dragState.dropTarget,
|
|
1471
1481
|
this._dragState.movedRootIds,
|
|
1472
1482
|
this._dragState.clone,
|
|
1473
|
-
(
|
|
1483
|
+
(e, t) => this._previewCloneSubtreeItem(e, t)
|
|
1474
1484
|
);
|
|
1475
1485
|
}
|
|
1476
|
-
_renderListTree(e,
|
|
1477
|
-
const
|
|
1478
|
-
const
|
|
1479
|
-
const
|
|
1480
|
-
return !
|
|
1481
|
-
}) :
|
|
1482
|
-
let
|
|
1483
|
-
return
|
|
1484
|
-
const
|
|
1485
|
-
if (!
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
t,
|
|
1486
|
+
_renderListTree(e, t, r, i, s, n, a) {
|
|
1487
|
+
const d = T(e), o = E(e), u = (c) => {
|
|
1488
|
+
const h = o.get(k(t.id, c)) || [], f = this.sort === "label" ? [...h].sort((I, m) => {
|
|
1489
|
+
const v = d.get(I), D = d.get(m);
|
|
1490
|
+
return !v || !D ? 0 : v.label.localeCompare(D.label);
|
|
1491
|
+
}) : h;
|
|
1492
|
+
let _ = "";
|
|
1493
|
+
return f.forEach((I) => {
|
|
1494
|
+
const m = d.get(I);
|
|
1495
|
+
if (!m || m.hidden) return;
|
|
1496
|
+
const v = this._renderChildBranch(
|
|
1497
|
+
m,
|
|
1498
|
+
r,
|
|
1490
1499
|
i,
|
|
1491
|
-
|
|
1500
|
+
u,
|
|
1492
1501
|
s,
|
|
1493
|
-
|
|
1502
|
+
n,
|
|
1494
1503
|
a
|
|
1495
1504
|
);
|
|
1496
|
-
!W(
|
|
1497
|
-
listId:
|
|
1505
|
+
!W(m, this.filterQuery) && !v.includes('class="item"') || (_ += this._renderDropzone({
|
|
1506
|
+
listId: t.id,
|
|
1498
1507
|
parentId: c,
|
|
1499
|
-
beforeId:
|
|
1508
|
+
beforeId: I,
|
|
1500
1509
|
mode: "before"
|
|
1501
|
-
}, "Drop here"),
|
|
1502
|
-
}),
|
|
1503
|
-
listId:
|
|
1510
|
+
}, "Drop here"), _ += v);
|
|
1511
|
+
}), _ += this._renderDropzone({
|
|
1512
|
+
listId: t.id,
|
|
1504
1513
|
parentId: c,
|
|
1505
1514
|
beforeId: null,
|
|
1506
1515
|
mode: "before"
|
|
1507
|
-
}, "Drop here"),
|
|
1516
|
+
}, "Drop here"), _;
|
|
1508
1517
|
};
|
|
1509
|
-
return `<div class="tree">${
|
|
1518
|
+
return `<div class="tree">${u(null)}</div>`;
|
|
1510
1519
|
}
|
|
1511
|
-
_renderChildBranch(e,
|
|
1512
|
-
|
|
1513
|
-
const l = I(e.id), n = o.has(e.id), d = n ? "" : i(e.id), c = d.includes('class="item"'), g = n ? !1 : this._selection.includes(e.id), m = n ? !1 : t.has(e.id), f = e.disabled, v = f || e.dragDisabled || this._isDragLocked(), b = ((C = (S = this._dragState) == null ? void 0 : S.dropTarget) == null ? void 0 : C.mode) === "inside" && this._dragState.dropTarget.parentId === e.id, y = (T = this._dragState) != null && T.clone ? "Copy preview" : "Drop preview", w = ($ = this._dragState) != null && $.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.", k = this._dragHandleMode(), A = this._usesCustomHandleSelector(), _ = A ? "custom" : k, R = !A && k === "handle";
|
|
1520
|
+
_renderChildBranch(e, t, r, i, s, n, a) {
|
|
1521
|
+
const d = y(e.id), o = n.has(e.id), u = o ? "" : i(e.id), c = u.includes('class="item"'), h = o ? !1 : this._selection.includes(e.id), f = o ? !1 : r.has(e.id), _ = e.disabled, I = _ || e.dragDisabled || this._isDragLocked(), m = this._dragState?.dropTarget?.mode === "inside" && this._dragState.dropTarget.parentId === e.id, v = this._dragState?.clone ? "Copy preview" : "Drop preview", D = 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.", A = this._dragHandleMode(), z = this._usesCustomHandleSelector(), b = z ? "custom" : A, S = !z && A === "handle";
|
|
1514
1522
|
return `
|
|
1515
|
-
<div class="item-shell" data-item-shell="${
|
|
1523
|
+
<div class="item-shell" data-item-shell="${d}">
|
|
1516
1524
|
<article
|
|
1517
|
-
class="item${
|
|
1525
|
+
class="item${o ? " item-placeholder" : ""}"
|
|
1518
1526
|
part="item"
|
|
1519
|
-
data-id="${
|
|
1520
|
-
data-drag-handle-mode="${
|
|
1521
|
-
${!
|
|
1522
|
-
data-selected="${
|
|
1523
|
-
data-focused="${
|
|
1524
|
-
data-dragging="${
|
|
1525
|
-
data-disabled="${
|
|
1526
|
-
data-drop-inside-active="${
|
|
1527
|
-
role="${
|
|
1528
|
-
aria-selected="${
|
|
1529
|
-
aria-disabled="${
|
|
1530
|
-
aria-grabbed="${
|
|
1531
|
-
aria-hidden="${
|
|
1532
|
-
tabindex="${
|
|
1527
|
+
data-id="${d}"
|
|
1528
|
+
data-drag-handle-mode="${b}"
|
|
1529
|
+
${!o && b === "item" ? 'data-drag-trigger="item"' : ""}
|
|
1530
|
+
data-selected="${h}"
|
|
1531
|
+
data-focused="${o ? "false" : t === e.id}"
|
|
1532
|
+
data-dragging="${f}"
|
|
1533
|
+
data-disabled="${_}"
|
|
1534
|
+
data-drop-inside-active="${m ? "true" : "false"}"
|
|
1535
|
+
role="${o ? "presentation" : "option"}"
|
|
1536
|
+
aria-selected="${o ? "false" : h}"
|
|
1537
|
+
aria-disabled="${_}"
|
|
1538
|
+
aria-grabbed="${o ? "false" : f}"
|
|
1539
|
+
aria-hidden="${o ? "true" : "false"}"
|
|
1540
|
+
tabindex="${o ? "-1" : t === e.id ? "0" : "-1"}"
|
|
1533
1541
|
>
|
|
1534
|
-
${
|
|
1542
|
+
${o ? `
|
|
1535
1543
|
<div class="placeholder-content">
|
|
1536
|
-
<div class="placeholder-kicker">${
|
|
1537
|
-
<div class="placeholder-title">${
|
|
1538
|
-
<div class="placeholder-description">${
|
|
1544
|
+
<div class="placeholder-kicker">${y(v)}</div>
|
|
1545
|
+
<div class="placeholder-title">${y(e.label)}</div>
|
|
1546
|
+
<div class="placeholder-description">${y(D)}</div>
|
|
1539
1547
|
</div>
|
|
1540
1548
|
` : `
|
|
1541
|
-
${
|
|
1549
|
+
${S ? `
|
|
1542
1550
|
<button
|
|
1543
1551
|
class="handle"
|
|
1544
1552
|
part="handle"
|
|
1545
1553
|
type="button"
|
|
1546
1554
|
data-action="handle"
|
|
1547
1555
|
data-drag-trigger="handle"
|
|
1548
|
-
data-id="${
|
|
1556
|
+
data-id="${d}"
|
|
1549
1557
|
draggable="false"
|
|
1550
|
-
${
|
|
1551
|
-
aria-label="Drag ${
|
|
1558
|
+
${I ? "disabled" : ""}
|
|
1559
|
+
aria-label="Drag ${y(e.label)}"
|
|
1552
1560
|
>
|
|
1553
1561
|
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
1554
1562
|
<circle cx="5" cy="4" r="1.25"></circle>
|
|
@@ -1560,13 +1568,13 @@ class ce extends ee {
|
|
|
1560
1568
|
</svg>
|
|
1561
1569
|
</button>
|
|
1562
1570
|
` : ""}
|
|
1563
|
-
<div class="item-content" data-action="select" data-id="${
|
|
1564
|
-
<div class="item-custom-content" part="item-custom-content" data-item-content-target="${
|
|
1571
|
+
<div class="item-content" data-action="select" data-id="${d}">
|
|
1572
|
+
<div class="item-custom-content" part="item-custom-content" data-item-content-target="${d}"></div>
|
|
1565
1573
|
<div class="item-default-content">
|
|
1566
|
-
<div class="item-title">${
|
|
1567
|
-
${e.description ? `<div class="item-description">${
|
|
1574
|
+
<div class="item-title">${y(e.label)}</div>
|
|
1575
|
+
${e.description ? `<div class="item-description">${y(e.description)}</div>` : ""}
|
|
1568
1576
|
<div class="item-meta">
|
|
1569
|
-
<span class="item-badge selection-badge" data-selection-badge="true" ${
|
|
1577
|
+
<span class="item-badge selection-badge" data-selection-badge="true" ${h && a ? "" : "hidden"}>${h && a ? "Selected" : ""}</span>
|
|
1570
1578
|
${e.cloneOnDrag ? '<span class="item-badge">Clone on drag</span>' : ""}
|
|
1571
1579
|
${e.dragDisabled ? '<span class="item-badge">Pinned</span>' : ""}
|
|
1572
1580
|
${s ? '<span class="item-badge drop-badge">Nest here</span>' : ""}
|
|
@@ -1575,81 +1583,80 @@ class ce extends ee {
|
|
|
1575
1583
|
</div>
|
|
1576
1584
|
`}
|
|
1577
1585
|
</article>
|
|
1578
|
-
${s && !
|
|
1586
|
+
${s && !o ? this._renderDropzone({
|
|
1579
1587
|
listId: e.listId,
|
|
1580
1588
|
parentId: e.id,
|
|
1581
1589
|
beforeId: null,
|
|
1582
1590
|
mode: "inside"
|
|
1583
1591
|
}, "Nest here") : ""}
|
|
1584
|
-
${c ? `<div class="children">${
|
|
1592
|
+
${c ? `<div class="children">${u}</div>` : ""}
|
|
1585
1593
|
</div>
|
|
1586
1594
|
`;
|
|
1587
1595
|
}
|
|
1588
|
-
_renderDropzone(e,
|
|
1589
|
-
|
|
1590
|
-
const t = ((i = this._dragState) == null ? void 0 : i.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;
|
|
1596
|
+
_renderDropzone(e, t) {
|
|
1597
|
+
const r = 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;
|
|
1591
1598
|
return `
|
|
1592
1599
|
<div
|
|
1593
1600
|
class="dropzone"
|
|
1594
1601
|
part="dropzone"
|
|
1595
|
-
data-list-id="${
|
|
1596
|
-
data-parent-id="${
|
|
1597
|
-
data-before-id="${
|
|
1602
|
+
data-list-id="${y(e.listId)}"
|
|
1603
|
+
data-parent-id="${y(e.parentId ?? "")}"
|
|
1604
|
+
data-before-id="${y(e.beforeId ?? "")}"
|
|
1598
1605
|
data-mode="${e.mode}"
|
|
1599
|
-
data-active="${
|
|
1606
|
+
data-active="${r ? "true" : "false"}"
|
|
1600
1607
|
aria-hidden="true"
|
|
1601
1608
|
>
|
|
1602
|
-
<span class="dropzone-label">${
|
|
1609
|
+
<span class="dropzone-label">${y(t)}</span>
|
|
1603
1610
|
</div>
|
|
1604
1611
|
`;
|
|
1605
1612
|
}
|
|
1606
1613
|
_onClick(e) {
|
|
1607
|
-
const
|
|
1608
|
-
|
|
1609
|
-
return n instanceof HTMLElement && ((d = n.classList) == null ? void 0 : d.contains("toolbar"));
|
|
1610
|
-
}), i = this._dragActivatorFromPath(r), s = r.find((n) => n instanceof HTMLElement && n.classList.contains("item"));
|
|
1611
|
-
if (i && i.kind !== "item")
|
|
1612
|
-
return;
|
|
1614
|
+
const t = e.composedPath(), r = t.find((o) => o instanceof HTMLElement && o.classList?.contains("toolbar")), i = this._dragActivatorFromPath(t), s = t.find((o) => o instanceof HTMLElement && o.classList.contains("item"));
|
|
1615
|
+
if (i && i.kind !== "item") return;
|
|
1613
1616
|
if (!s)
|
|
1614
|
-
return
|
|
1615
|
-
const
|
|
1616
|
-
if (!
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
const l = e;
|
|
1622
|
-
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()) {
|
|
1617
|
+
return r && !(e.target instanceof HTMLButtonElement), void 0;
|
|
1618
|
+
const n = s.getAttribute("data-id");
|
|
1619
|
+
if (!n) return;
|
|
1620
|
+
const a = this._items.find((o) => o.id === n);
|
|
1621
|
+
if (!a || a.disabled) return;
|
|
1622
|
+
const d = e;
|
|
1623
|
+
if (d.shiftKey ? this._selectRangeTo(n) : d.metaKey || d.ctrlKey ? this._toggleSelection(n) : this._setSelection([n], "pointer"), this._focusedId = n, this._rangeAnchorId = n, this._pendingFocusId = n, this._hasCustomItemRendering()) {
|
|
1623
1624
|
this._syncSelectionVisualState(), this._restorePendingFocus();
|
|
1624
1625
|
return;
|
|
1625
1626
|
}
|
|
1626
1627
|
this.requestRender();
|
|
1627
1628
|
}
|
|
1628
1629
|
_onFocusIn(e) {
|
|
1629
|
-
const r = e.composedPath().find((i) => i instanceof HTMLElement && i.classList.contains("item"))
|
|
1630
|
-
|
|
1630
|
+
const r = e.composedPath().find((i) => i instanceof HTMLElement && i.classList.contains("item"))?.getAttribute("data-id");
|
|
1631
|
+
r && (this._focusedId = r, this._syncSelectionVisualState());
|
|
1632
|
+
}
|
|
1633
|
+
// Keys typed into a control that lives inside an item (an <input> or <button> in a custom card)
|
|
1634
|
+
// belong to that control: swallowing Space/Enter/arrows there made it impossible to type a space
|
|
1635
|
+
// or press the button from the keyboard. The drag handle is part of the item, not a foreign control.
|
|
1636
|
+
_isForeignControl(e) {
|
|
1637
|
+
const t = e.composedPath()[0];
|
|
1638
|
+
return !(t instanceof HTMLElement) || t.classList.contains("handle") || t.classList.contains("item") ? !1 : t.isContentEditable || t.matches('input, textarea, select, button, summary, a[href], [role="button"], [role="textbox"], [role="combobox"]');
|
|
1631
1639
|
}
|
|
1632
1640
|
_onKeyDown(e) {
|
|
1633
|
-
|
|
1634
|
-
const
|
|
1635
|
-
if (!
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
e.preventDefault(), this._moveFocusBy(r, i, 1);
|
|
1641
|
+
if (this._isForeignControl(e)) return;
|
|
1642
|
+
const t = this._visibleItemIds();
|
|
1643
|
+
if (!t.length) return;
|
|
1644
|
+
const r = this._focusedId && t.includes(this._focusedId) ? this._focusedId : t[0], i = t.indexOf(r), s = this._items.find((c) => c.id === r), a = (s ? this._lists.find((c) => c.id === s.listId) : null)?.orientation === "horizontal", d = this._isRtl(), o = a ? d ? "ArrowLeft" : "ArrowRight" : "ArrowDown", u = a ? d ? "ArrowRight" : "ArrowLeft" : "ArrowUp";
|
|
1645
|
+
if (!this._dragState?.keyboard) {
|
|
1646
|
+
if (e.key === o) {
|
|
1647
|
+
e.preventDefault(), this._moveFocusBy(t, i, 1);
|
|
1641
1648
|
return;
|
|
1642
1649
|
}
|
|
1643
|
-
if (e.key ===
|
|
1644
|
-
e.preventDefault(), this._moveFocusBy(
|
|
1650
|
+
if (e.key === u) {
|
|
1651
|
+
e.preventDefault(), this._moveFocusBy(t, i, -1);
|
|
1645
1652
|
return;
|
|
1646
1653
|
}
|
|
1647
1654
|
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a") {
|
|
1648
|
-
e.preventDefault(), this._setSelection(
|
|
1655
|
+
e.preventDefault(), this._setSelection(t, "keyboard"), this._announce(`${t.length} items selected.`);
|
|
1649
1656
|
return;
|
|
1650
1657
|
}
|
|
1651
1658
|
if (e.key === "Enter") {
|
|
1652
|
-
e.preventDefault(), this._setSelection([
|
|
1659
|
+
e.preventDefault(), this._setSelection([r], "keyboard");
|
|
1653
1660
|
return;
|
|
1654
1661
|
}
|
|
1655
1662
|
if (e.key === " " || e.code === "Space") {
|
|
@@ -1657,21 +1664,20 @@ class ce extends ee {
|
|
|
1657
1664
|
this._announce("Dragging is disabled right now.");
|
|
1658
1665
|
return;
|
|
1659
1666
|
}
|
|
1660
|
-
const
|
|
1661
|
-
if (!
|
|
1662
|
-
|
|
1663
|
-
const d = this._itemClonesOnDrag(t);
|
|
1667
|
+
const c = this._selectedRootIds(r);
|
|
1668
|
+
if (!c.length) return;
|
|
1669
|
+
const h = this._itemClonesOnDrag(r);
|
|
1664
1670
|
this._dragState = {
|
|
1665
1671
|
snapshot: this._items.map(P),
|
|
1666
|
-
movedRootIds:
|
|
1667
|
-
originId:
|
|
1668
|
-
clone:
|
|
1672
|
+
movedRootIds: c,
|
|
1673
|
+
originId: r,
|
|
1674
|
+
clone: h,
|
|
1669
1675
|
keyboard: !0,
|
|
1670
|
-
dropTarget: this._initialKeyboardDropTarget(
|
|
1676
|
+
dropTarget: this._initialKeyboardDropTarget(r),
|
|
1671
1677
|
committed: !1
|
|
1672
1678
|
};
|
|
1673
|
-
const
|
|
1674
|
-
this._announce(`${
|
|
1679
|
+
const f = c.length === 1 ? `Lifted ${s?.label || "item"}.` : `Lifted ${c.length} items.`;
|
|
1680
|
+
this._announce(`${f} Use arrow keys to choose a destination.`), this.requestRender();
|
|
1675
1681
|
return;
|
|
1676
1682
|
}
|
|
1677
1683
|
if (e.key === "Escape") {
|
|
@@ -1686,25 +1692,28 @@ class ce extends ee {
|
|
|
1686
1692
|
}
|
|
1687
1693
|
if (e.key === "Enter" || e.key === " " || e.code === "Space") {
|
|
1688
1694
|
e.preventDefault();
|
|
1689
|
-
const
|
|
1690
|
-
if (!
|
|
1691
|
-
|
|
1692
|
-
this._commitMove(n, this._dragState.movedRootIds, this._dragState.clone, "keyboard");
|
|
1695
|
+
const c = this._dragState.dropTarget;
|
|
1696
|
+
if (!c) return;
|
|
1697
|
+
this._commitMove(c, this._dragState.movedRootIds, this._dragState.clone, "keyboard");
|
|
1693
1698
|
return;
|
|
1694
1699
|
}
|
|
1695
1700
|
if (["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"].includes(e.key)) {
|
|
1696
1701
|
e.preventDefault();
|
|
1697
|
-
const
|
|
1698
|
-
this._moveKeyboardDropTarget(
|
|
1702
|
+
const c = d ? "ArrowLeft" : "ArrowRight", h = e.key === "ArrowDown" || e.key === c ? 1 : -1;
|
|
1703
|
+
this._moveKeyboardDropTarget(h);
|
|
1699
1704
|
}
|
|
1700
1705
|
}
|
|
1701
|
-
|
|
1702
|
-
const
|
|
1706
|
+
_isRtl() {
|
|
1707
|
+
const e = this.ownerDocument?.defaultView?.getComputedStyle(this).direction;
|
|
1708
|
+
return e ? e === "rtl" : this.closest("[dir]")?.getAttribute("dir") === "rtl";
|
|
1709
|
+
}
|
|
1710
|
+
_moveFocusBy(e, t, r) {
|
|
1711
|
+
const i = Math.max(0, Math.min(e.length - 1, t + r)), s = e[i];
|
|
1703
1712
|
this._focusedId = s, this._pendingFocusId = s, !this._applyInteractiveStateInPlace({ restoreFocus: !0 }) && this.requestRender();
|
|
1704
1713
|
}
|
|
1705
1714
|
_onDragStart(e) {
|
|
1706
|
-
const
|
|
1707
|
-
if (!
|
|
1715
|
+
const t = this._dragActivatorFromPath(e.composedPath()), r = t?.id;
|
|
1716
|
+
if (!t || !r) {
|
|
1708
1717
|
e.preventDefault();
|
|
1709
1718
|
return;
|
|
1710
1719
|
}
|
|
@@ -1712,106 +1721,101 @@ class ce extends ee {
|
|
|
1712
1721
|
e.preventDefault(), this._announce("Dragging is disabled right now.");
|
|
1713
1722
|
return;
|
|
1714
1723
|
}
|
|
1715
|
-
const i = this._items.find((a) => a.id ===
|
|
1724
|
+
const i = this._items.find((a) => a.id === r);
|
|
1716
1725
|
if (!i || i.disabled || i.dragDisabled) {
|
|
1717
1726
|
e.preventDefault();
|
|
1718
1727
|
return;
|
|
1719
1728
|
}
|
|
1720
|
-
const s = this._selection.includes(
|
|
1721
|
-
this._selection.includes(
|
|
1722
|
-
const
|
|
1729
|
+
const s = this._selection.includes(r) ? this._selectedRootIds(r) : [r];
|
|
1730
|
+
this._selection.includes(r) || this._setSelection([r], "pointer");
|
|
1731
|
+
const n = this._itemClonesOnDrag(r);
|
|
1723
1732
|
this._dragState = {
|
|
1724
1733
|
snapshot: this._items.map(P),
|
|
1725
1734
|
movedRootIds: s,
|
|
1726
|
-
originId:
|
|
1727
|
-
clone:
|
|
1735
|
+
originId: r,
|
|
1736
|
+
clone: n,
|
|
1728
1737
|
keyboard: !1,
|
|
1729
1738
|
dropTarget: null,
|
|
1730
1739
|
committed: !1
|
|
1731
|
-
}, e.dataTransfer && (e.dataTransfer.effectAllowed =
|
|
1732
|
-
|
|
1740
|
+
}, e.dataTransfer && (e.dataTransfer.effectAllowed = n ? "copyMove" : "move", e.dataTransfer.setData("text/plain", s.join(",")), this._applyDragImage(e.dataTransfer, s.length)), this._announce(
|
|
1741
|
+
n ? `Dragging ${s.length === 1 ? i.label : `${s.length} items`} as a copy.` : `Dragging ${s.length === 1 ? i.label : `${s.length} items`}.`
|
|
1733
1742
|
), this.requestRender();
|
|
1734
1743
|
}
|
|
1735
1744
|
_onDragOver(e) {
|
|
1736
|
-
if (!this._dragState || this._dragState.keyboard)
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
if (!r || !this._canDrop(r, this._dragState.movedRootIds)) {
|
|
1745
|
+
if (!this._dragState || this._dragState.keyboard) return;
|
|
1746
|
+
const t = this._dropTargetFromEvent(e);
|
|
1747
|
+
if (!t || !this._canDrop(t, this._dragState.movedRootIds)) {
|
|
1740
1748
|
this._queueDropTarget(null, e.timeStamp);
|
|
1741
1749
|
return;
|
|
1742
1750
|
}
|
|
1743
|
-
e.preventDefault(), this._queueDropTarget(
|
|
1751
|
+
e.preventDefault(), this._queueDropTarget(t, e.timeStamp), e.dataTransfer && (e.dataTransfer.dropEffect = this._dragState.clone ? "copy" : "move");
|
|
1744
1752
|
}
|
|
1745
1753
|
_onDrop(e) {
|
|
1746
|
-
if (!this._dragState || this._dragState.keyboard)
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
!r || !this._canDrop(r, this._dragState.movedRootIds) || (e.preventDefault(), this._commitMove(r, this._dragState.movedRootIds, this._dragState.clone, "pointer"));
|
|
1754
|
+
if (!this._dragState || this._dragState.keyboard) return;
|
|
1755
|
+
const t = this._dropTargetFromEvent(e);
|
|
1756
|
+
!t || !this._canDrop(t, this._dragState.movedRootIds) || (e.preventDefault(), this._commitMove(t, this._dragState.movedRootIds, this._dragState.clone, "pointer"));
|
|
1750
1757
|
}
|
|
1751
1758
|
_onDocumentKeyDown(e) {
|
|
1752
1759
|
e.key === "Escape" && (!this._dragState || this._dragState.keyboard || (e.preventDefault(), this._cancelDrag(!0)));
|
|
1753
1760
|
}
|
|
1754
1761
|
_onDragEnd() {
|
|
1755
|
-
!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());
|
|
1762
|
+
!this._dragState || this._dragState.keyboard || this._dragState.committed || (this._setDraggingVisualState(this._draggingIds(), !1), this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this._announce("Drag cancelled."), this.requestRender());
|
|
1756
1763
|
}
|
|
1757
1764
|
_dropTargetFromEvent(e) {
|
|
1758
1765
|
return this._dropTargetFromPath(e.composedPath(), e.clientX, e.clientY);
|
|
1759
1766
|
}
|
|
1760
|
-
_dropTargetFromPath(e,
|
|
1761
|
-
const i = e.find((
|
|
1767
|
+
_dropTargetFromPath(e, t, r) {
|
|
1768
|
+
const i = e.find((S) => S instanceof HTMLElement && S.classList.contains("dropzone"));
|
|
1762
1769
|
if (i) {
|
|
1763
|
-
const
|
|
1770
|
+
const S = {
|
|
1764
1771
|
listId: i.getAttribute("data-list-id") || "",
|
|
1765
1772
|
parentId: i.getAttribute("data-parent-id") || null,
|
|
1766
1773
|
beforeId: i.getAttribute("data-before-id") || null,
|
|
1767
1774
|
mode: i.getAttribute("data-mode") === "inside" ? "inside" : "before"
|
|
1768
1775
|
};
|
|
1769
|
-
if (
|
|
1770
|
-
return _;
|
|
1776
|
+
if (S.listId) return S;
|
|
1771
1777
|
}
|
|
1772
|
-
const s = e.find((
|
|
1773
|
-
if (!s)
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
return null;
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
const
|
|
1782
|
-
if (
|
|
1778
|
+
const s = e.find((S) => S instanceof HTMLElement && S.classList.contains("item"));
|
|
1779
|
+
if (!s) {
|
|
1780
|
+
const R = e.find(
|
|
1781
|
+
($) => $ instanceof HTMLElement && $.classList.contains("list") && $.hasAttribute("data-list-id")
|
|
1782
|
+
)?.getAttribute("data-list-id");
|
|
1783
|
+
return R ? { listId: R, parentId: null, beforeId: null, mode: "before" } : null;
|
|
1784
|
+
}
|
|
1785
|
+
const n = s.getAttribute("data-id");
|
|
1786
|
+
if (!n) return null;
|
|
1787
|
+
const a = this._items.find((S) => S.id === n);
|
|
1788
|
+
if (!a) return null;
|
|
1789
|
+
const d = this._lists.find((S) => S.id === a.listId), o = s.getBoundingClientRect(), u = d?.orientation === "horizontal", c = u ? o.left : o.top, h = u ? o.right : o.bottom, f = u ? t : r, _ = Math.max(1, h - c), I = (f - c) / _, m = u && this._isRtl() ? 1 - I : I, v = this.getAttribute("allow-nesting") !== "false" && !a.disabled;
|
|
1790
|
+
if (m <= 0.34)
|
|
1783
1791
|
return {
|
|
1784
1792
|
listId: a.listId,
|
|
1785
1793
|
parentId: a.parentId,
|
|
1786
1794
|
beforeId: a.id,
|
|
1787
1795
|
mode: "before"
|
|
1788
1796
|
};
|
|
1789
|
-
if (
|
|
1797
|
+
if (v && m >= 0.34 && m <= 0.74)
|
|
1790
1798
|
return {
|
|
1791
1799
|
listId: a.listId,
|
|
1792
1800
|
parentId: a.id,
|
|
1793
1801
|
beforeId: null,
|
|
1794
1802
|
mode: "inside"
|
|
1795
1803
|
};
|
|
1796
|
-
const
|
|
1804
|
+
const A = E(this._items).get(k(a.listId, a.parentId)) || [], z = A.indexOf(a.id), b = z >= 0 && A[z + 1] || null;
|
|
1797
1805
|
return {
|
|
1798
1806
|
listId: a.listId,
|
|
1799
1807
|
parentId: a.parentId,
|
|
1800
|
-
beforeId:
|
|
1808
|
+
beforeId: b,
|
|
1801
1809
|
mode: "before"
|
|
1802
1810
|
};
|
|
1803
1811
|
}
|
|
1804
|
-
_dropTargetFromPoint(e,
|
|
1805
|
-
return this._dropTargetFromPath(this._pathFromPoint(e,
|
|
1812
|
+
_dropTargetFromPoint(e, t) {
|
|
1813
|
+
return this._dropTargetFromPath(this._pathFromPoint(e, t), e, t);
|
|
1806
1814
|
}
|
|
1807
|
-
_beginPointerDrag(e,
|
|
1808
|
-
if (!this._pointerGesture || this._dragState)
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
var s;
|
|
1812
|
-
return i.id === ((s = this._pointerGesture) == null ? void 0 : s.originId);
|
|
1813
|
-
});
|
|
1814
|
-
t && (this._dragState = {
|
|
1815
|
+
_beginPointerDrag(e, t) {
|
|
1816
|
+
if (!this._pointerGesture || this._dragState) return;
|
|
1817
|
+
const r = this._items.find((i) => i.id === this._pointerGesture?.originId);
|
|
1818
|
+
r && (this._dragState = {
|
|
1815
1819
|
snapshot: this._items.map(P),
|
|
1816
1820
|
movedRootIds: [...this._pointerGesture.movedRootIds],
|
|
1817
1821
|
originId: this._pointerGesture.originId,
|
|
@@ -1821,92 +1825,94 @@ class ce extends ee {
|
|
|
1821
1825
|
committed: !1
|
|
1822
1826
|
}, this._pendingDropTarget = null, this._applyPointerPreview(
|
|
1823
1827
|
e,
|
|
1824
|
-
|
|
1828
|
+
t,
|
|
1825
1829
|
this._dragState.movedRootIds.length,
|
|
1826
1830
|
this._dragState.clone
|
|
1827
1831
|
), this._setDraggingVisualState(this._draggingIds(), !0), this._announce(
|
|
1828
|
-
this._dragState.clone ? `Dragging ${this._dragState.movedRootIds.length === 1 ?
|
|
1832
|
+
this._dragState.clone ? `Dragging ${this._dragState.movedRootIds.length === 1 ? r.label : `${this._dragState.movedRootIds.length} items`} as a copy.` : `Dragging ${this._dragState.movedRootIds.length === 1 ? r.label : `${this._dragState.movedRootIds.length} items`}.`
|
|
1829
1833
|
));
|
|
1830
1834
|
}
|
|
1831
1835
|
_onPointerDown(e) {
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
if (!r || !t)
|
|
1835
|
-
return;
|
|
1836
|
+
const t = this._dragActivatorFromPath(e.composedPath()), r = t?.id;
|
|
1837
|
+
if (!t || !r) return;
|
|
1836
1838
|
if (this._isDragLocked()) {
|
|
1837
1839
|
e.preventDefault(), this._announce("Dragging is disabled right now.");
|
|
1838
1840
|
return;
|
|
1839
1841
|
}
|
|
1840
|
-
const i = this._items.find((
|
|
1842
|
+
const i = this._items.find((n) => n.id === r);
|
|
1841
1843
|
if (!i || i.disabled || i.dragDisabled) {
|
|
1842
1844
|
e.preventDefault();
|
|
1843
1845
|
return;
|
|
1844
1846
|
}
|
|
1845
1847
|
e.preventDefault();
|
|
1846
1848
|
try {
|
|
1847
|
-
|
|
1849
|
+
t.element.setPointerCapture?.(e.pointerId);
|
|
1848
1850
|
} catch {
|
|
1849
1851
|
}
|
|
1850
|
-
const s = this._selection.includes(
|
|
1852
|
+
const s = this._selection.includes(r) ? this._selectedRootIds(r) : [r];
|
|
1851
1853
|
this._pointerGesture = {
|
|
1852
1854
|
pointerId: e.pointerId,
|
|
1853
1855
|
pointerType: e.pointerType,
|
|
1854
|
-
originId:
|
|
1856
|
+
originId: r,
|
|
1855
1857
|
movedRootIds: s,
|
|
1856
|
-
clone: this._itemClonesOnDrag(
|
|
1858
|
+
clone: this._itemClonesOnDrag(r),
|
|
1857
1859
|
startX: e.clientX,
|
|
1858
1860
|
startY: e.clientY,
|
|
1859
1861
|
moved: !1,
|
|
1860
|
-
captureTarget:
|
|
1862
|
+
captureTarget: t.element
|
|
1861
1863
|
};
|
|
1862
1864
|
}
|
|
1863
1865
|
_onPointerMove(e) {
|
|
1864
1866
|
if (!(!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId)) {
|
|
1865
1867
|
if (e.preventDefault(), !this._pointerGesture.moved) {
|
|
1866
|
-
if (Math.hypot(e.clientX - this._pointerGesture.startX, e.clientY - this._pointerGesture.startY) < 6)
|
|
1867
|
-
return;
|
|
1868
|
+
if (Math.hypot(e.clientX - this._pointerGesture.startX, e.clientY - this._pointerGesture.startY) < 6) return;
|
|
1868
1869
|
this._pointerGesture.moved = !0, this._beginPointerDrag(e.clientX, e.clientY);
|
|
1869
1870
|
}
|
|
1870
|
-
if (!(!this._dragState || this._dragState.keyboard) && (this._movePointerPreview(e.clientX, e.clientY), !this._dragState.committed)) {
|
|
1871
|
-
const
|
|
1872
|
-
if (!
|
|
1871
|
+
if (!(!this._dragState || this._dragState.keyboard) && (this._movePointerPreview(e.clientX, e.clientY), this._updateAutoScroll(e.clientX, e.clientY), !this._dragState.committed)) {
|
|
1872
|
+
const t = this._dropTargetFromPoint(e.clientX, e.clientY);
|
|
1873
|
+
if (!t || !this._canDrop(t, this._dragState.movedRootIds)) {
|
|
1873
1874
|
this._queueDropTarget(null, e.timeStamp);
|
|
1874
1875
|
return;
|
|
1875
1876
|
}
|
|
1876
|
-
this._queueDropTarget(
|
|
1877
|
+
this._queueDropTarget(t, e.timeStamp);
|
|
1877
1878
|
}
|
|
1878
1879
|
}
|
|
1879
1880
|
}
|
|
1881
|
+
// Holding a dragged card near the top or bottom edge scrolls the page (or the nearest scrolling
|
|
1882
|
+
// container), so lists and positions that are off screen can be reached with the pointer.
|
|
1883
|
+
_updateAutoScroll(e, t) {
|
|
1884
|
+
this._autoScrollPoint = { x: e, y: t }, !this._autoScrollFrame && typeof requestAnimationFrame == "function" && (this._autoScrollFrame = requestAnimationFrame(this._autoScrollTick));
|
|
1885
|
+
}
|
|
1886
|
+
_stopAutoScroll() {
|
|
1887
|
+
this._autoScrollFrame && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(this._autoScrollFrame), this._autoScrollFrame = 0, this._autoScrollPoint = null;
|
|
1888
|
+
}
|
|
1880
1889
|
_onPointerUp(e) {
|
|
1881
|
-
|
|
1882
|
-
if (!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId)
|
|
1883
|
-
return;
|
|
1890
|
+
if (!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId) return;
|
|
1884
1891
|
e.preventDefault();
|
|
1885
1892
|
try {
|
|
1886
|
-
|
|
1893
|
+
this._pointerGesture.captureTarget?.releasePointerCapture?.(e.pointerId);
|
|
1887
1894
|
} catch {
|
|
1888
1895
|
}
|
|
1889
|
-
const
|
|
1890
|
-
if (this._pointerGesture = null, !this._dragState || this._dragState.keyboard)
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
this._commitMove(t, this._dragState.movedRootIds, this._dragState.clone, "pointer");
|
|
1896
|
+
const t = this._pointerGesture;
|
|
1897
|
+
if (this._pointerGesture = null, this._stopAutoScroll(), !this._dragState || this._dragState.keyboard) return;
|
|
1898
|
+
const r = t.moved ? this._releaseDropTarget(e.clientX, e.clientY) : null;
|
|
1899
|
+
if (t.moved && r) {
|
|
1900
|
+
this._commitMove(r, this._dragState.movedRootIds, this._dragState.clone, "pointer");
|
|
1895
1901
|
return;
|
|
1896
1902
|
}
|
|
1897
|
-
|
|
1903
|
+
t.moved ? this._cancelDrag(!0) : (this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this.requestRender());
|
|
1898
1904
|
}
|
|
1899
1905
|
_onPointerCancel(e) {
|
|
1900
|
-
!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId || (this._pointerGesture = null, this._dragState && this._cancelDrag(!0));
|
|
1906
|
+
!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId || (this._pointerGesture = null, this._stopAutoScroll(), this._dragState && this._cancelDrag(!0));
|
|
1901
1907
|
}
|
|
1902
|
-
_setSelection(e,
|
|
1903
|
-
const
|
|
1908
|
+
_setSelection(e, t) {
|
|
1909
|
+
const r = new Set(this._items.map((a) => a.id)), i = Array.from(new Set(e.filter((a) => r.has(a)))), s = [...this._selection];
|
|
1904
1910
|
this._selection = i, this._rangeAnchorId = i[i.length - 1] || null, this._focusedId = i[i.length - 1] || this._focusedId;
|
|
1905
|
-
const
|
|
1906
|
-
if (this.getAttribute("selection") !==
|
|
1907
|
-
this._lastSelectionAttr =
|
|
1911
|
+
const n = X(i);
|
|
1912
|
+
if (this.getAttribute("selection") !== n) {
|
|
1913
|
+
this._lastSelectionAttr = n, this._suppressAttributeRender = !0;
|
|
1908
1914
|
try {
|
|
1909
|
-
i.length ? this.setAttribute("selection",
|
|
1915
|
+
i.length ? this.setAttribute("selection", n) : this.removeAttribute("selection");
|
|
1910
1916
|
} finally {
|
|
1911
1917
|
this._suppressAttributeRender = !1;
|
|
1912
1918
|
}
|
|
@@ -1918,176 +1924,154 @@ class ce extends ee {
|
|
|
1918
1924
|
},
|
|
1919
1925
|
bubbles: !0,
|
|
1920
1926
|
composed: !0
|
|
1921
|
-
})),
|
|
1922
|
-
if (this._applyInteractiveStateInPlace({ restoreFocus: !0 }))
|
|
1923
|
-
return;
|
|
1927
|
+
})), t !== "restore") {
|
|
1928
|
+
if (this._applyInteractiveStateInPlace({ restoreFocus: !0 })) return;
|
|
1924
1929
|
this.requestRender();
|
|
1925
1930
|
}
|
|
1926
1931
|
}
|
|
1927
1932
|
_toggleSelection(e) {
|
|
1928
|
-
const
|
|
1929
|
-
this._setSelection(
|
|
1933
|
+
const t = this._selection.includes(e) ? this._selection.filter((r) => r !== e) : [...this._selection, e];
|
|
1934
|
+
this._setSelection(t, "pointer"), this._announce(`${t.length} items selected.`);
|
|
1930
1935
|
}
|
|
1931
1936
|
_selectRangeTo(e) {
|
|
1932
|
-
const
|
|
1937
|
+
const t = this._visibleItemIds(), r = this._rangeAnchorId || this._focusedId || e, i = t.indexOf(r), s = t.indexOf(e);
|
|
1933
1938
|
if (i < 0 || s < 0) {
|
|
1934
1939
|
this._setSelection([e], "pointer");
|
|
1935
1940
|
return;
|
|
1936
1941
|
}
|
|
1937
|
-
const [
|
|
1938
|
-
this._setSelection(
|
|
1942
|
+
const [n, a] = i <= s ? [i, s] : [s, i];
|
|
1943
|
+
this._setSelection(t.slice(n, a + 1), "pointer"), this._announce(`${a - n + 1} items selected.`);
|
|
1939
1944
|
}
|
|
1940
1945
|
_visibleItemIds() {
|
|
1941
1946
|
const e = Q(this._items, new Set(this._selection), new Set(this._draggingIds()), this.filterQuery, this.sort);
|
|
1942
|
-
return Array.from(e.values()).flat().filter((
|
|
1947
|
+
return Array.from(e.values()).flat().filter((t) => !t.disabled).map((t) => t.id);
|
|
1943
1948
|
}
|
|
1944
1949
|
_selectedRootIds(e) {
|
|
1945
|
-
const
|
|
1946
|
-
return
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
return !1;
|
|
1951
|
-
let a = o.parentId;
|
|
1950
|
+
const t = this._selection.length ? [...this._selection] : e ? [e] : [], r = T(this._items), i = new Set(t);
|
|
1951
|
+
return t.filter((s) => {
|
|
1952
|
+
const n = r.get(s);
|
|
1953
|
+
if (!n) return !1;
|
|
1954
|
+
let a = n.parentId;
|
|
1952
1955
|
for (; a; ) {
|
|
1953
|
-
if (i.has(a))
|
|
1954
|
-
|
|
1955
|
-
a = ((l = t.get(a)) == null ? void 0 : l.parentId) ?? null;
|
|
1956
|
+
if (i.has(a)) return !1;
|
|
1957
|
+
a = r.get(a)?.parentId ?? null;
|
|
1956
1958
|
}
|
|
1957
|
-
return !
|
|
1959
|
+
return !n.disabled;
|
|
1958
1960
|
});
|
|
1959
1961
|
}
|
|
1960
1962
|
_draggingIds() {
|
|
1961
|
-
if (!this._dragState)
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
return;
|
|
1968
|
-
(r.get(z(o.listId, s)) || []).forEach(i);
|
|
1963
|
+
if (!this._dragState) return [];
|
|
1964
|
+
const e = T(this._items), t = E(this._items), r = [], i = (s) => {
|
|
1965
|
+
r.push(s);
|
|
1966
|
+
const n = e.get(s);
|
|
1967
|
+
if (!n) return;
|
|
1968
|
+
(t.get(k(n.listId, s)) || []).forEach(i);
|
|
1969
1969
|
};
|
|
1970
|
-
return this._dragState.movedRootIds.forEach(i),
|
|
1970
|
+
return this._dragState.movedRootIds.forEach(i), r;
|
|
1971
1971
|
}
|
|
1972
1972
|
_itemClonesOnDrag(e) {
|
|
1973
|
-
const
|
|
1974
|
-
|
|
1975
|
-
return !1;
|
|
1976
|
-
if (r.cloneOnDrag)
|
|
1977
|
-
return !0;
|
|
1978
|
-
const t = this._lists.find((i) => i.id === r.listId);
|
|
1979
|
-
return !!(t != null && t.cloneOnDrag);
|
|
1973
|
+
const t = this._items.find((i) => i.id === e);
|
|
1974
|
+
return t ? t.cloneOnDrag ? !0 : !!this._lists.find((i) => i.id === t.listId)?.cloneOnDrag : !1;
|
|
1980
1975
|
}
|
|
1981
1976
|
_isDragLocked() {
|
|
1982
1977
|
return !!(this.hasAttribute("disabled") || this.sort !== "manual" || this.filterQuery && !this.hasAttribute("allow-filtered-drag"));
|
|
1983
1978
|
}
|
|
1984
|
-
_canDrop(e,
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
const
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
s.add(d);
|
|
1993
|
-
const c = i.get(d);
|
|
1994
|
-
c && (o.get(z(c.listId, d)) || []).forEach(a);
|
|
1979
|
+
_canDrop(e, t) {
|
|
1980
|
+
if (this._isDragLocked()) return !1;
|
|
1981
|
+
const r = this._lists.find((o) => o.id === e.listId);
|
|
1982
|
+
if (!r || r.disabled) return !1;
|
|
1983
|
+
const i = T(this._items), s = /* @__PURE__ */ new Set(), n = E(this._items), a = (o) => {
|
|
1984
|
+
s.add(o);
|
|
1985
|
+
const u = i.get(o);
|
|
1986
|
+
u && (n.get(k(u.listId, o)) || []).forEach(a);
|
|
1995
1987
|
};
|
|
1996
|
-
if (
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
}) || e.mode === "inside" && this.getAttribute("allow-nesting") === "false");
|
|
2006
|
-
}
|
|
2007
|
-
_commitMove(e, r, t, i) {
|
|
2008
|
-
if (!this._canDrop(e, r))
|
|
2009
|
-
return;
|
|
2010
|
-
const s = M(this._items), o = E(this._items), a = /* @__PURE__ */ new Set(), l = [], n = (p) => {
|
|
2011
|
-
const D = s.get(p);
|
|
2012
|
-
!D || a.has(p) || (a.add(p), l.push(p), (o.get(z(D.listId, p)) || []).forEach(n));
|
|
1988
|
+
if (t.forEach(a), e.parentId && s.has(e.parentId) || e.beforeId && s.has(e.beforeId)) return !1;
|
|
1989
|
+
const d = Array.from(new Set(t.map((o) => i.get(o)?.listId).filter(Boolean)));
|
|
1990
|
+
return !(r.accepts?.length && d.some((o) => !r.accepts?.includes(o)) || e.mode === "inside" && this.getAttribute("allow-nesting") === "false");
|
|
1991
|
+
}
|
|
1992
|
+
_commitMove(e, t, r, i) {
|
|
1993
|
+
if (!this._canDrop(e, t)) return;
|
|
1994
|
+
const s = T(this._items), n = E(this._items), a = /* @__PURE__ */ new Set(), d = [], o = (p) => {
|
|
1995
|
+
const w = s.get(p);
|
|
1996
|
+
!w || a.has(p) || (a.add(p), d.push(p), (n.get(k(w.listId, p)) || []).forEach(o));
|
|
2013
1997
|
};
|
|
2014
|
-
|
|
2015
|
-
const
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
}),
|
|
2019
|
-
const
|
|
2020
|
-
|
|
1998
|
+
t.forEach(o);
|
|
1999
|
+
const u = this._items.map(P), c = u.filter((p) => a.has(p.id)), h = r ? u.map(P) : u.filter((p) => !a.has(p.id)), f = r ? c.map((p) => this._cloneSubtreeItem(p, d)) : c.map(P), _ = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map();
|
|
2000
|
+
r && c.forEach((p, w) => {
|
|
2001
|
+
_.set(p.id, f[w].id), I.set(f[w].id, p.id);
|
|
2002
|
+
}), f.forEach((p) => {
|
|
2003
|
+
const w = r ? I.get(p.id) : p.id, F = w ? s.get(w) : null;
|
|
2004
|
+
F && (r && (p.parentId = F.parentId && _.has(F.parentId) && _.get(F.parentId) || null), p.listId = e.listId);
|
|
2021
2005
|
});
|
|
2022
|
-
const
|
|
2023
|
-
|
|
2024
|
-
const [,
|
|
2025
|
-
(
|
|
2006
|
+
const m = t.map((p) => _.get(p) || p), v = [...h, ...f], D = E(h), A = k(e.listId, e.parentId), z = [...D.get(A) || []], b = e.beforeId ? z.indexOf(e.beforeId) : z.length, S = b >= 0 ? b : z.length;
|
|
2007
|
+
z.splice(S, 0, ...m), D.set(A, z), E(f).forEach((p, w) => {
|
|
2008
|
+
const [, F] = w.split("::");
|
|
2009
|
+
(F || "") !== "__root__" && D.set(w, [...p]);
|
|
2026
2010
|
});
|
|
2027
|
-
const
|
|
2028
|
-
|
|
2029
|
-
const
|
|
2030
|
-
|
|
2011
|
+
const $ = T(v);
|
|
2012
|
+
m.forEach((p) => {
|
|
2013
|
+
const w = $.get(p);
|
|
2014
|
+
w && (w.parentId = e.parentId, w.listId = e.listId);
|
|
2031
2015
|
});
|
|
2032
|
-
const
|
|
2033
|
-
(
|
|
2034
|
-
const
|
|
2035
|
-
!
|
|
2016
|
+
const O = [], L = /* @__PURE__ */ new Set(), q = (p, w) => {
|
|
2017
|
+
(D.get(k(p, w)) || []).forEach((V, Z) => {
|
|
2018
|
+
const N = $.get(V);
|
|
2019
|
+
!N || L.has(V) || (L.add(V), N.listId = p, N.parentId = w, N.order = Z, O.push(N), q(p, V));
|
|
2036
2020
|
});
|
|
2037
2021
|
};
|
|
2038
|
-
this._lists.forEach((p) =>
|
|
2039
|
-
|
|
2040
|
-
}), this._dragState && (this._dragState.committed = !0), this._items =
|
|
2041
|
-
const
|
|
2042
|
-
this._selection =
|
|
2022
|
+
this._lists.forEach((p) => q(p.id, null)), v.forEach((p) => {
|
|
2023
|
+
L.has(p.id) || (p.parentId = null, O.push(p));
|
|
2024
|
+
}), this._dragState && (this._dragState.committed = !0), this._items = O.map(P), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage();
|
|
2025
|
+
const H = [...m], g = [...this._selection];
|
|
2026
|
+
this._selection = H, this._focusedId = H[0] || null, this._pendingFocusId = this._focusedId, this._syncAttributesFromState();
|
|
2043
2027
|
const x = J(this._items);
|
|
2044
2028
|
this._persistSnapshot(x);
|
|
2045
|
-
const
|
|
2029
|
+
const M = t.map((p) => s.get(p)).filter((p) => !!p), C = r ? "clone" : e.mode === "inside" ? "nest" : M.some((p) => p.listId !== e.listId) ? "transfer" : "reorder", G = {
|
|
2046
2030
|
items: this.items,
|
|
2047
2031
|
lists: this.lists,
|
|
2048
|
-
selection: [...
|
|
2049
|
-
previousSelection:
|
|
2050
|
-
movedIds: [...
|
|
2032
|
+
selection: [...H],
|
|
2033
|
+
previousSelection: g,
|
|
2034
|
+
movedIds: [...m],
|
|
2051
2035
|
source: i,
|
|
2052
|
-
operation:
|
|
2036
|
+
operation: C,
|
|
2053
2037
|
persistence: x
|
|
2054
2038
|
};
|
|
2055
2039
|
this.dispatchEvent(new CustomEvent("change", {
|
|
2056
|
-
detail:
|
|
2040
|
+
detail: G,
|
|
2057
2041
|
bubbles: !0,
|
|
2058
2042
|
composed: !0
|
|
2059
2043
|
})), this.dispatchEvent(new CustomEvent("persist-request", {
|
|
2060
|
-
detail:
|
|
2044
|
+
detail: G,
|
|
2061
2045
|
bubbles: !0,
|
|
2062
2046
|
composed: !0
|
|
2063
|
-
})), this._announce(this._messageForMove(
|
|
2047
|
+
})), this._announce(this._messageForMove(C, m.length, e)), this.requestRender();
|
|
2064
2048
|
}
|
|
2065
2049
|
_syncAttributesFromState() {
|
|
2066
|
-
const e =
|
|
2067
|
-
this._lastListsAttr = e, this._lastItemsAttr =
|
|
2050
|
+
const e = pe(this._lists), t = ue(this._items), r = X(this._selection);
|
|
2051
|
+
this._lastListsAttr = e, this._lastItemsAttr = t, this._lastSelectionAttr = r, this._suppressAttributeRender = !0;
|
|
2068
2052
|
try {
|
|
2069
|
-
this.setAttribute("lists", e), this.setAttribute("items",
|
|
2053
|
+
this.setAttribute("lists", e), this.setAttribute("items", t), this._selection.length ? this.setAttribute("selection", r) : this.removeAttribute("selection");
|
|
2070
2054
|
} finally {
|
|
2071
2055
|
this._suppressAttributeRender = !1;
|
|
2072
2056
|
}
|
|
2073
2057
|
}
|
|
2074
|
-
_cloneSubtreeItem(e,
|
|
2075
|
-
const i = `copy-${this._cloneSeed++}`,
|
|
2058
|
+
_cloneSubtreeItem(e, t) {
|
|
2059
|
+
const i = `copy-${this._cloneSeed++}`, n = `${e.id.includes("--copy-") ? e.id.split("--copy-")[0] : e.id}--${i}`;
|
|
2076
2060
|
return {
|
|
2077
2061
|
...e,
|
|
2078
|
-
id:
|
|
2079
|
-
label:
|
|
2062
|
+
id: n,
|
|
2063
|
+
label: t[0] === e.id ? `${e.label} copy` : e.label
|
|
2080
2064
|
};
|
|
2081
2065
|
}
|
|
2082
|
-
_messageForMove(e,
|
|
2083
|
-
const
|
|
2084
|
-
return e === "clone" ? `${
|
|
2066
|
+
_messageForMove(e, t, r) {
|
|
2067
|
+
const s = this._lists.find((n) => n.id === r.listId)?.label || r.listId;
|
|
2068
|
+
return e === "clone" ? `${t === 1 ? "Item copied" : `${t} items copied`} into ${s}.` : e === "nest" ? `${t === 1 ? "Item nested" : `${t} items nested`} in ${s}.` : e === "transfer" ? `${t === 1 ? "Item moved" : `${t} items moved`} to ${s}.` : `${t === 1 ? "Item reordered" : `${t} items reordered`} in ${s}.`;
|
|
2085
2069
|
}
|
|
2086
2070
|
_persistSnapshot(e) {
|
|
2087
|
-
const
|
|
2088
|
-
if (
|
|
2071
|
+
const t = this.getAttribute("persist-key");
|
|
2072
|
+
if (t)
|
|
2089
2073
|
try {
|
|
2090
|
-
window.localStorage.setItem(
|
|
2074
|
+
window.localStorage.setItem(t, JSON.stringify(e));
|
|
2091
2075
|
} catch {
|
|
2092
2076
|
}
|
|
2093
2077
|
}
|
|
@@ -2095,85 +2079,81 @@ class ce extends ee {
|
|
|
2095
2079
|
this._liveMessage = e, this._applyLiveMessage();
|
|
2096
2080
|
}
|
|
2097
2081
|
_cancelDrag(e) {
|
|
2098
|
-
this._dragState && (this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._items = this._dragState.snapshot.map(P), this._dragState = null, this._pointerGesture = null, this._removeDragImage(), e && this._announce("Drag cancelled."), this._syncAttributesFromState(), this.requestRender());
|
|
2082
|
+
this._stopAutoScroll(), this._dragState && (this._setDraggingVisualState(this._draggingIds(), !1), this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._items = this._dragState.snapshot.map(P), this._dragState = null, this._pointerGesture = null, this._removeDragImage(), e && this._announce("Drag cancelled."), this._syncAttributesFromState(), this.requestRender());
|
|
2099
2083
|
}
|
|
2100
|
-
_applyDragImage(e,
|
|
2084
|
+
_applyDragImage(e, t) {
|
|
2101
2085
|
this._removeDragImage();
|
|
2102
|
-
const
|
|
2103
|
-
|
|
2086
|
+
const r = document.createElement("div");
|
|
2087
|
+
r.textContent = t === 1 ? "Dragging item" : `Dragging ${t} items`, r.style.position = "fixed", r.style.top = "-999px", r.style.left = "-999px", r.style.padding = "8px 12px", r.style.borderRadius = "999px", r.style.background = "rgba(15, 23, 42, 0.92)", r.style.color = "#f8fafc", r.style.font = "600 12px/1 Inter, sans-serif", r.style.pointerEvents = "none", document.body.appendChild(r), e.setDragImage(r, 12, 12), this._dragImage = r;
|
|
2104
2088
|
}
|
|
2105
2089
|
_removeDragImage() {
|
|
2106
|
-
|
|
2107
|
-
(e = this._dragImage) == null || e.remove(), this._dragImage = null;
|
|
2090
|
+
this._dragImage?.remove(), this._dragImage = null;
|
|
2108
2091
|
}
|
|
2109
2092
|
_removeDragPreviewOverlay() {
|
|
2110
|
-
|
|
2111
|
-
(e = this._dragPreviewOverlay) == null || e.remove(), this._dragPreviewOverlay = null;
|
|
2093
|
+
this._dragPreviewOverlay?.remove(), this._dragPreviewOverlay = null;
|
|
2112
2094
|
}
|
|
2113
|
-
_applyPointerPreview(e,
|
|
2095
|
+
_applyPointerPreview(e, t, r, i) {
|
|
2114
2096
|
this._removeDragImage();
|
|
2115
2097
|
const s = document.createElement("div");
|
|
2116
|
-
s.textContent = i ?
|
|
2098
|
+
s.textContent = i ? r === 1 ? "Copying item" : `Copying ${r} items` : r === 1 ? "Moving item" : `Moving ${r} 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, t);
|
|
2117
2099
|
}
|
|
2118
|
-
_movePointerPreview(e,
|
|
2119
|
-
this._dragImage && (this._dragImage.style.transform = `translate(${Math.round(e + 14)}px, ${Math.round(
|
|
2100
|
+
_movePointerPreview(e, t) {
|
|
2101
|
+
this._dragImage && (this._dragImage.style.transform = `translate(${Math.round(e + 14)}px, ${Math.round(t + 14)}px)`);
|
|
2120
2102
|
}
|
|
2121
2103
|
_keyboardDropTargets() {
|
|
2122
|
-
const e =
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
const
|
|
2126
|
-
!
|
|
2127
|
-
listId:
|
|
2128
|
-
parentId:
|
|
2129
|
-
beforeId:
|
|
2104
|
+
const e = T(this._items), t = E(this._items), r = [], i = this.getAttribute("allow-nesting") !== "false", s = (n, a) => {
|
|
2105
|
+
const d = t.get(k(n, a)) || [];
|
|
2106
|
+
d.forEach((o) => {
|
|
2107
|
+
const u = e.get(o);
|
|
2108
|
+
!u || u.hidden || (r.push({
|
|
2109
|
+
listId: n,
|
|
2110
|
+
parentId: a,
|
|
2111
|
+
beforeId: o,
|
|
2130
2112
|
mode: "before",
|
|
2131
|
-
label: `Before ${
|
|
2132
|
-
}),
|
|
2133
|
-
listId:
|
|
2134
|
-
parentId:
|
|
2113
|
+
label: `Before ${u.label}`
|
|
2114
|
+
}), i && r.push({
|
|
2115
|
+
listId: n,
|
|
2116
|
+
parentId: o,
|
|
2135
2117
|
beforeId: null,
|
|
2136
2118
|
mode: "inside",
|
|
2137
|
-
label: `Nest inside ${
|
|
2138
|
-
}),
|
|
2139
|
-
}),
|
|
2140
|
-
listId:
|
|
2141
|
-
parentId:
|
|
2119
|
+
label: `Nest inside ${u.label}`
|
|
2120
|
+
}), s(n, o));
|
|
2121
|
+
}), a ? i && d.length > 0 && r.push({
|
|
2122
|
+
listId: n,
|
|
2123
|
+
parentId: a,
|
|
2124
|
+
beforeId: null,
|
|
2125
|
+
mode: "before",
|
|
2126
|
+
label: "After children"
|
|
2127
|
+
}) : r.push({
|
|
2128
|
+
listId: n,
|
|
2129
|
+
parentId: a,
|
|
2142
2130
|
beforeId: null,
|
|
2143
2131
|
mode: "before",
|
|
2144
|
-
label:
|
|
2132
|
+
label: `End of ${this._lists.find((o) => o.id === n)?.label || n}`
|
|
2145
2133
|
});
|
|
2146
2134
|
};
|
|
2147
|
-
return this._lists.forEach((
|
|
2148
|
-
var o;
|
|
2149
|
-
return this._canDrop(s, ((o = this._dragState) == null ? void 0 : o.movedRootIds) || []);
|
|
2150
|
-
});
|
|
2135
|
+
return this._lists.forEach((n) => s(n.id, null)), r.filter((n) => this._canDrop(n, this._dragState?.movedRootIds || []));
|
|
2151
2136
|
}
|
|
2152
2137
|
_initialKeyboardDropTarget(e) {
|
|
2153
|
-
const
|
|
2154
|
-
return
|
|
2155
|
-
listId:
|
|
2156
|
-
parentId:
|
|
2138
|
+
const t = this._items.find((r) => r.id === e);
|
|
2139
|
+
return t ? {
|
|
2140
|
+
listId: t.listId,
|
|
2141
|
+
parentId: t.parentId,
|
|
2157
2142
|
beforeId: e,
|
|
2158
2143
|
mode: "before"
|
|
2159
2144
|
} : null;
|
|
2160
2145
|
}
|
|
2161
2146
|
_moveKeyboardDropTarget(e) {
|
|
2162
|
-
if (!this._dragState)
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
var o, a, l, n, d, c, g, m;
|
|
2170
|
-
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);
|
|
2171
|
-
}
|
|
2172
|
-
)), i = Math.max(0, Math.min(r.length - 1, t + e));
|
|
2173
|
-
this._setDropTarget(r[i], { announceLabel: r[i].label });
|
|
2147
|
+
if (!this._dragState) return;
|
|
2148
|
+
const t = this._keyboardDropTargets();
|
|
2149
|
+
if (!t.length) return;
|
|
2150
|
+
const r = Math.max(0, t.findIndex(
|
|
2151
|
+
(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
|
|
2152
|
+
)), i = Math.max(0, Math.min(t.length - 1, r + e));
|
|
2153
|
+
this._setDropTarget(t[i], { announceLabel: t[i].label });
|
|
2174
2154
|
}
|
|
2175
2155
|
}
|
|
2176
|
-
typeof customElements < "u" && !customElements.get("ui-sortable") && customElements.define("ui-sortable",
|
|
2156
|
+
typeof customElements < "u" && !customElements.get("ui-sortable") && customElements.define("ui-sortable", he);
|
|
2177
2157
|
export {
|
|
2178
|
-
|
|
2158
|
+
he as UISortable
|
|
2179
2159
|
};
|