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