@editora/ui-core 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +27 -23
- package/dist/color-picker.cjs.js +8 -8
- package/dist/color-picker.esm.js +7 -7
- package/dist/components/ui-collection.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-portal.d.ts.map +1 -1
- package/dist/components/ui-positioner.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-tabs.d.ts.map +1 -1
- package/dist/components/ui-textarea.d.ts.map +1 -1
- package/dist/date-time-picker.cjs.js +4 -4
- package/dist/date-time-picker.esm.js +7 -7
- package/dist/multi-select.cjs.js +3 -3
- package/dist/multi-select.esm.js +39 -31
- 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/selector.d.ts +4 -0
- package/dist/primitives/selector.d.ts.map +1 -0
- package/dist/selector-BvAh35ve.js +1 -0
- package/dist/selector-WI8pD7YO.mjs +18 -0
- package/dist/sortable.cjs.js +70 -56
- package/dist/sortable.esm.js +644 -561
- package/dist/tabs.cjs.js +7 -7
- package/dist/tabs.esm.js +67 -67
- package/dist/textarea.cjs.js +9 -9
- package/dist/textarea.esm.js +31 -25
- package/dist/transfer-list.cjs.js +29 -29
- package/dist/transfer-list.esm.js +54 -54
- package/package.json +1 -1
package/dist/sortable.esm.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
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);
|
|
@@ -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);
|
|
@@ -731,10 +761,10 @@ function V(l) {
|
|
|
731
761
|
return [];
|
|
732
762
|
}
|
|
733
763
|
}
|
|
734
|
-
function
|
|
764
|
+
function y(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)), f = i ? c.map(P) : c.filter((g) => !d.has(g.id)), _ = i ? h.map((g) => s(g, o)) : h.map(P), I = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
|
|
814
|
+
i && h.forEach((g, x) => {
|
|
815
|
+
I.set(g.id, _[x].id), m.set(_[x].id, g.id);
|
|
816
|
+
}), _.forEach((g) => {
|
|
817
|
+
const x = i ? m.get(g.id) : g.id, M = x ? n.get(x) : null;
|
|
818
|
+
M && (i && (g.parentId = M.parentId && I.has(M.parentId) && I.get(M.parentId) || null), g.listId = t.listId);
|
|
789
819
|
});
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
const [,
|
|
793
|
-
(
|
|
820
|
+
const v = r.map((g) => I.get(g) || g), D = [...f, ..._], A = E(f), z = k(t.listId, t.parentId), b = [...A.get(z) || []], S = t.beforeId ? b.indexOf(t.beforeId) : b.length, R = S >= 0 ? S : b.length;
|
|
821
|
+
b.splice(R, 0, ...v), A.set(z, b), E(_).forEach((g, x) => {
|
|
822
|
+
const [, M] = x.split("::");
|
|
823
|
+
(M || "") !== "__root__" && A.set(x, [...g]);
|
|
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,16 +874,16 @@ 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
|
|
853
|
-
|
|
854
|
-
id:
|
|
855
|
-
label:
|
|
856
|
-
listId:
|
|
880
|
+
const c = typeof o?.id == "string" && o.id.trim() ? o.id.trim() : "", h = typeof o?.label == "string" && o.label.trim() ? o.label.trim() : "";
|
|
881
|
+
if (!c || !h) return;
|
|
882
|
+
const f = typeof o?.listId == "string" && t.has(o.listId) ? o.listId : l[0].id;
|
|
883
|
+
r.push({
|
|
884
|
+
id: c,
|
|
885
|
+
label: h,
|
|
886
|
+
listId: f,
|
|
857
887
|
parentId: typeof o?.parentId == "string" && o.parentId.trim() ? o.parentId.trim() : null,
|
|
858
888
|
description: typeof o?.description == "string" ? o.description : "",
|
|
859
889
|
order: Number.isFinite(o?.order) ? Number(o.order) : u,
|
|
@@ -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, f) => {
|
|
909
|
+
a.has(h.id) || (a.add(h.id), h.order = f, 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" &&
|
|
937
|
-
const
|
|
938
|
-
return !
|
|
939
|
-
}), _;
|
|
940
|
-
}, o = (p, m, _) => {
|
|
941
|
-
const f = [];
|
|
942
|
-
return d(p, m).forEach((v) => {
|
|
943
|
-
const b = s.get(v);
|
|
944
|
-
if (!b || b.hidden) return;
|
|
945
|
-
const y = o(p, b.id);
|
|
946
|
-
!W(b, t) && y.length === 0 || (f.push({
|
|
947
|
-
id: b.id,
|
|
948
|
-
disabled: b.disabled
|
|
949
|
-
}), y.length && f.push(...y));
|
|
963
|
+
function Q(l, e, t, r, i) {
|
|
964
|
+
const s = T(l), n = E(l), a = /* @__PURE__ */ new Map(), d = (c, h) => {
|
|
965
|
+
const f = [...n.get(k(c, h)) || []];
|
|
966
|
+
return i === "label" && f.sort((_, I) => {
|
|
967
|
+
const m = s.get(_), v = s.get(I);
|
|
968
|
+
return !m || !v ? 0 : m.label.localeCompare(v.label);
|
|
950
969
|
}), f;
|
|
970
|
+
}, o = (c, h, f) => {
|
|
971
|
+
const _ = [];
|
|
972
|
+
return d(c, h).forEach((I) => {
|
|
973
|
+
const m = s.get(I);
|
|
974
|
+
if (!m || m.hidden) return;
|
|
975
|
+
const v = o(c, m.id);
|
|
976
|
+
!W(m, r) && v.length === 0 || (_.push({
|
|
977
|
+
id: m.id,
|
|
978
|
+
disabled: m.disabled
|
|
979
|
+
}), v.length && _.push(...v));
|
|
980
|
+
}), _;
|
|
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, f = this.getAttribute("allow-nesting") !== "false", _ = this.getAttribute("drop-indicator-visibility") === "always" ? "always" : "active", I = this._dropzoneStyle(), m = this.getAttribute("show-selection-badge") !== "false", v = this._dragHandleMode(), D = this._usesCustomHandleSelector(), A = c ? this.sort === "label" ? "Dragging is paused while alphabetical sorting is active." : this.filterQuery && !this.hasAttribute("allow-filtered-drag") ? "Dragging is paused while the list is filtered." : "Dragging is currently disabled." : this._dragState?.keyboard ? "Keyboard drag active. Use arrow keys to choose a drop target, Space or Enter to drop, and Escape to cancel." : v === "item" ? "Drag from anywhere on an item, or press Space on a focused item to start keyboard reordering." : D ? "Use your custom drag handle element, or press Space on a focused item to start keyboard reordering." : "Use the handle to drag, or press Space on a focused item to start keyboard reordering.", z = `
|
|
1102
|
+
<style>${ae}</style>
|
|
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="${_}"
|
|
1109
|
+
data-dropzone-style="${I}"
|
|
1068
1110
|
>
|
|
1069
1111
|
<div class="toolbar" part="toolbar">
|
|
1070
|
-
<div class="helper">${
|
|
1112
|
+
<div class="helper">${y(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((b) => {
|
|
1120
|
+
const S = o.get(b.id) || [], R = S.length ? this._renderListTree(n, b, u, t, f, a, m) : "", $ = b.disabled ? "This list is read-only." : b.cloneOnDrag ? "Dragging from this list creates a copy." : b.accepts?.length ? `Accepts drops from: ${b.accepts.join(", ")}` : "";
|
|
1079
1121
|
return `
|
|
1080
1122
|
<section
|
|
1081
1123
|
class="list"
|
|
1082
1124
|
part="list"
|
|
1083
|
-
data-list-id="${
|
|
1084
|
-
data-orientation="${
|
|
1085
|
-
data-disabled="${
|
|
1086
|
-
aria-label="${
|
|
1125
|
+
data-list-id="${y(b.id)}"
|
|
1126
|
+
data-orientation="${b.orientation}"
|
|
1127
|
+
data-disabled="${b.disabled}"
|
|
1128
|
+
aria-label="${y(b.label)}"
|
|
1087
1129
|
>
|
|
1088
1130
|
<header class="list-header">
|
|
1089
|
-
<div class="list-custom-header" part="list-custom-header" data-list-header-target="${
|
|
1131
|
+
<div class="list-custom-header" part="list-custom-header" data-list-header-target="${y(b.id)}"></div>
|
|
1090
1132
|
<div class="list-default-header">
|
|
1091
1133
|
<div class="list-topline">
|
|
1092
|
-
<div class="list-label">${
|
|
1093
|
-
<span class="list-count">${
|
|
1134
|
+
<div class="list-label">${y(b.label)}</div>
|
|
1135
|
+
<span class="list-count">${S.length}</span>
|
|
1094
1136
|
</div>
|
|
1095
|
-
${
|
|
1096
|
-
${
|
|
1137
|
+
${b.description ? `<div class="list-description">${y(b.description)}</div>` : ""}
|
|
1138
|
+
${$ ? `<div class="list-helper">${y($)}</div>` : ""}
|
|
1097
1139
|
</div>
|
|
1098
1140
|
</header>
|
|
1099
|
-
<div class="items" role="listbox" aria-multiselectable="true">
|
|
1100
|
-
${
|
|
1101
|
-
listId:
|
|
1141
|
+
<div class="items" role="listbox" aria-multiselectable="true" aria-label="${y(b.label)}">
|
|
1142
|
+
${R || `<div class="list-custom-empty" part="list-custom-empty" data-list-empty-target="${y(b.id)}"></div><div class="empty">${y(b.emptyLabel)}</div>${this._renderDropzone({
|
|
1143
|
+
listId: b.id,
|
|
1102
1144
|
parentId: null,
|
|
1103
1145
|
beforeId: null,
|
|
1104
1146
|
mode: "before"
|
|
@@ -1108,70 +1150,70 @@ class ce extends ee {
|
|
|
1108
1150
|
`;
|
|
1109
1151
|
}).join("")}
|
|
1110
1152
|
</div>
|
|
1111
|
-
<div class="sr-only" aria-live="polite" aria-atomic="true">${
|
|
1153
|
+
<div class="sr-only" aria-live="polite" aria-atomic="true">${y(this._liveMessage)}</div>
|
|
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
|
-
<div class="placeholder-kicker">${
|
|
1312
|
-
<div class="placeholder-title">${
|
|
1313
|
-
<div class="placeholder-description">${
|
|
1353
|
+
<div class="placeholder-kicker">${y(e.kicker)}</div>
|
|
1354
|
+
<div class="placeholder-title">${y(e.title)}</div>
|
|
1355
|
+
<div class="placeholder-description">${y(e.description)}</div>
|
|
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)), f = 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(f)}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"), i.setAttribute("aria-grabbed", 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,154 +1390,163 @@ 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
|
|
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)) || [], f = this.sort === "label" ? [...h].sort((I, m) => {
|
|
1489
|
+
const v = d.get(I), D = d.get(m);
|
|
1490
|
+
return !v || !D ? 0 : v.label.localeCompare(D.label);
|
|
1491
|
+
}) : h;
|
|
1492
|
+
let _ = "";
|
|
1493
|
+
return f.forEach((I) => {
|
|
1494
|
+
const m = d.get(I);
|
|
1495
|
+
if (!m || m.hidden) return;
|
|
1496
|
+
const v = this._renderChildBranch(
|
|
1497
|
+
m,
|
|
1498
|
+
r,
|
|
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"') || (_ += this._renderDropzone({
|
|
1506
|
+
listId: t.id,
|
|
1507
|
+
parentId: c,
|
|
1508
|
+
beforeId: I,
|
|
1458
1509
|
mode: "before"
|
|
1459
|
-
}, "Drop here"),
|
|
1460
|
-
}),
|
|
1461
|
-
listId:
|
|
1462
|
-
parentId:
|
|
1510
|
+
}, "Drop here"), _ += v);
|
|
1511
|
+
}), _ += this._renderDropzone({
|
|
1512
|
+
listId: t.id,
|
|
1513
|
+
parentId: c,
|
|
1463
1514
|
beforeId: null,
|
|
1464
1515
|
mode: "before"
|
|
1465
|
-
}, "Drop here"),
|
|
1516
|
+
}, "Drop here"), _;
|
|
1466
1517
|
};
|
|
1467
1518
|
return `<div class="tree">${u(null)}</div>`;
|
|
1468
1519
|
}
|
|
1469
|
-
_renderChildBranch(e,
|
|
1470
|
-
const d =
|
|
1520
|
+
_renderChildBranch(e, t, r, i, s, n, a) {
|
|
1521
|
+
const d = y(e.id), o = n.has(e.id), u = o ? "" : i(e.id), c = u.includes('class="item"'), h = o ? !1 : this._selection.includes(e.id), f = o ? !1 : r.has(e.id), _ = e.disabled, I = _ || e.dragDisabled || this._isDragLocked(), m = this._dragState?.dropTarget?.mode === "inside" && this._dragState.dropTarget.parentId === e.id, v = this._dragState?.clone ? "Copy preview" : "Drop preview", D = this._dragState?.clone ? "Release to add a copy here." : this._dragState && this._dragState.movedRootIds.length > 1 ? "Release to place this selection here." : "Release to place this item here.", A = this._dragHandleMode(), z = this._usesCustomHandleSelector(), b = z ? "custom" : A, S = !z && A === "handle";
|
|
1471
1522
|
return `
|
|
1472
1523
|
<div class="item-shell" data-item-shell="${d}">
|
|
1473
1524
|
<article
|
|
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" :
|
|
1481
|
-
data-dragging="${
|
|
1482
|
-
data-disabled="${
|
|
1483
|
-
data-drop-inside-active="${
|
|
1528
|
+
data-drag-handle-mode="${b}"
|
|
1529
|
+
${!o && b === "item" ? 'data-drag-trigger="item"' : ""}
|
|
1530
|
+
data-selected="${h}"
|
|
1531
|
+
data-focused="${o ? "false" : t === e.id}"
|
|
1532
|
+
data-dragging="${f}"
|
|
1533
|
+
data-disabled="${_}"
|
|
1534
|
+
data-drop-inside-active="${m ? "true" : "false"}"
|
|
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="${_}"
|
|
1538
|
+
aria-grabbed="${o ? "false" : f}"
|
|
1488
1539
|
aria-hidden="${o ? "true" : "false"}"
|
|
1489
|
-
tabindex="${o ? "-1" :
|
|
1540
|
+
tabindex="${o ? "-1" : t === e.id ? "0" : "-1"}"
|
|
1490
1541
|
>
|
|
1491
1542
|
${o ? `
|
|
1492
1543
|
<div class="placeholder-content">
|
|
1493
|
-
<div class="placeholder-kicker">${
|
|
1494
|
-
<div class="placeholder-title">${
|
|
1495
|
-
<div class="placeholder-description">${
|
|
1544
|
+
<div class="placeholder-kicker">${y(v)}</div>
|
|
1545
|
+
<div class="placeholder-title">${y(e.label)}</div>
|
|
1546
|
+
<div class="placeholder-description">${y(D)}</div>
|
|
1496
1547
|
</div>
|
|
1497
1548
|
` : `
|
|
1498
|
-
${
|
|
1549
|
+
${S ? `
|
|
1499
1550
|
<button
|
|
1500
1551
|
class="handle"
|
|
1501
1552
|
part="handle"
|
|
@@ -1504,8 +1555,8 @@ class ce extends ee {
|
|
|
1504
1555
|
data-drag-trigger="handle"
|
|
1505
1556
|
data-id="${d}"
|
|
1506
1557
|
draggable="false"
|
|
1507
|
-
${
|
|
1508
|
-
aria-label="Drag ${
|
|
1558
|
+
${I ? "disabled" : ""}
|
|
1559
|
+
aria-label="Drag ${y(e.label)}"
|
|
1509
1560
|
>
|
|
1510
1561
|
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
1511
1562
|
<circle cx="5" cy="4" r="1.25"></circle>
|
|
@@ -1520,10 +1571,10 @@ class ce extends ee {
|
|
|
1520
1571
|
<div class="item-content" data-action="select" data-id="${d}">
|
|
1521
1572
|
<div class="item-custom-content" part="item-custom-content" data-item-content-target="${d}"></div>
|
|
1522
1573
|
<div class="item-default-content">
|
|
1523
|
-
<div class="item-title">${
|
|
1524
|
-
${e.description ? `<div class="item-description">${
|
|
1574
|
+
<div class="item-title">${y(e.label)}</div>
|
|
1575
|
+
${e.description ? `<div class="item-description">${y(e.description)}</div>` : ""}
|
|
1525
1576
|
<div class="item-meta">
|
|
1526
|
-
<span class="item-badge selection-badge" data-selection-badge="true" ${
|
|
1577
|
+
<span class="item-badge selection-badge" data-selection-badge="true" ${h && a ? "" : "hidden"}>${h && a ? "Selected" : ""}</span>
|
|
1527
1578
|
${e.cloneOnDrag ? '<span class="item-badge">Clone on drag</span>' : ""}
|
|
1528
1579
|
${e.dragDisabled ? '<span class="item-badge">Pinned</span>' : ""}
|
|
1529
1580
|
${s ? '<span class="item-badge drop-badge">Nest here</span>' : ""}
|
|
@@ -1538,66 +1589,74 @@ class ce extends ee {
|
|
|
1538
1589
|
beforeId: null,
|
|
1539
1590
|
mode: "inside"
|
|
1540
1591
|
}, "Nest here") : ""}
|
|
1541
|
-
${
|
|
1592
|
+
${c ? `<div class="children">${u}</div>` : ""}
|
|
1542
1593
|
</div>
|
|
1543
1594
|
`;
|
|
1544
1595
|
}
|
|
1545
|
-
_renderDropzone(e,
|
|
1546
|
-
const
|
|
1596
|
+
_renderDropzone(e, t) {
|
|
1597
|
+
const r = this._dragState?.dropTarget && this._dragState.dropTarget.listId === e.listId && this._dragState.dropTarget.parentId === e.parentId && this._dragState.dropTarget.beforeId === e.beforeId && this._dragState.dropTarget.mode === e.mode;
|
|
1547
1598
|
return `
|
|
1548
1599
|
<div
|
|
1549
1600
|
class="dropzone"
|
|
1550
1601
|
part="dropzone"
|
|
1551
|
-
data-list-id="${
|
|
1552
|
-
data-parent-id="${
|
|
1553
|
-
data-before-id="${
|
|
1602
|
+
data-list-id="${y(e.listId)}"
|
|
1603
|
+
data-parent-id="${y(e.parentId ?? "")}"
|
|
1604
|
+
data-before-id="${y(e.beforeId ?? "")}"
|
|
1554
1605
|
data-mode="${e.mode}"
|
|
1555
|
-
data-active="${
|
|
1606
|
+
data-active="${r ? "true" : "false"}"
|
|
1556
1607
|
aria-hidden="true"
|
|
1557
1608
|
>
|
|
1558
|
-
<span class="dropzone-label">${
|
|
1609
|
+
<span class="dropzone-label">${y(t)}</span>
|
|
1559
1610
|
</div>
|
|
1560
1611
|
`;
|
|
1561
1612
|
}
|
|
1562
1613
|
_onClick(e) {
|
|
1563
|
-
const
|
|
1614
|
+
const t = e.composedPath(), r = t.find((o) => o instanceof HTMLElement && o.classList?.contains("toolbar")), i = this._dragActivatorFromPath(t), s = t.find((o) => o instanceof HTMLElement && o.classList.contains("item"));
|
|
1564
1615
|
if (i && i.kind !== "item") return;
|
|
1565
1616
|
if (!s)
|
|
1566
|
-
return
|
|
1567
|
-
const
|
|
1568
|
-
if (!
|
|
1569
|
-
const
|
|
1570
|
-
if (!
|
|
1617
|
+
return r && !(e.target instanceof HTMLButtonElement), void 0;
|
|
1618
|
+
const n = s.getAttribute("data-id");
|
|
1619
|
+
if (!n) return;
|
|
1620
|
+
const a = this._items.find((o) => o.id === n);
|
|
1621
|
+
if (!a || a.disabled) return;
|
|
1571
1622
|
const d = e;
|
|
1572
|
-
if (d.shiftKey ? this._selectRangeTo(
|
|
1623
|
+
if (d.shiftKey ? this._selectRangeTo(n) : d.metaKey || d.ctrlKey ? this._toggleSelection(n) : this._setSelection([n], "pointer"), this._focusedId = n, this._rangeAnchorId = n, this._pendingFocusId = n, this._hasCustomItemRendering()) {
|
|
1573
1624
|
this._syncSelectionVisualState(), this._restorePendingFocus();
|
|
1574
1625
|
return;
|
|
1575
1626
|
}
|
|
1576
1627
|
this.requestRender();
|
|
1577
1628
|
}
|
|
1578
1629
|
_onFocusIn(e) {
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1630
|
+
const r = e.composedPath().find((i) => i instanceof HTMLElement && i.classList.contains("item"))?.getAttribute("data-id");
|
|
1631
|
+
r && (this._focusedId = r, this._syncSelectionVisualState());
|
|
1632
|
+
}
|
|
1633
|
+
// Keys typed into a control that lives inside an item (an <input> or <button> in a custom card)
|
|
1634
|
+
// belong to that control: swallowing Space/Enter/arrows there made it impossible to type a space
|
|
1635
|
+
// or press the button from the keyboard. The drag handle is part of the item, not a foreign control.
|
|
1636
|
+
_isForeignControl(e) {
|
|
1637
|
+
const t = e.composedPath()[0];
|
|
1638
|
+
return !(t instanceof HTMLElement) || t.classList.contains("handle") || t.classList.contains("item") ? !1 : t.isContentEditable || t.matches('input, textarea, select, button, summary, a[href], [role="button"], [role="textbox"], [role="combobox"]');
|
|
1581
1639
|
}
|
|
1582
1640
|
_onKeyDown(e) {
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1641
|
+
if (this._isForeignControl(e)) return;
|
|
1642
|
+
const t = this._visibleItemIds();
|
|
1643
|
+
if (!t.length) return;
|
|
1644
|
+
const r = this._focusedId && t.includes(this._focusedId) ? this._focusedId : t[0], i = t.indexOf(r), s = this._items.find((c) => c.id === r), a = (s ? this._lists.find((c) => c.id === s.listId) : null)?.orientation === "horizontal", d = this._isRtl(), o = a ? d ? "ArrowLeft" : "ArrowRight" : "ArrowDown", u = a ? d ? "ArrowRight" : "ArrowLeft" : "ArrowUp";
|
|
1586
1645
|
if (!this._dragState?.keyboard) {
|
|
1587
|
-
if (e.key ===
|
|
1588
|
-
e.preventDefault(), this._moveFocusBy(
|
|
1646
|
+
if (e.key === o) {
|
|
1647
|
+
e.preventDefault(), this._moveFocusBy(t, i, 1);
|
|
1589
1648
|
return;
|
|
1590
1649
|
}
|
|
1591
|
-
if (e.key ===
|
|
1592
|
-
e.preventDefault(), this._moveFocusBy(
|
|
1650
|
+
if (e.key === u) {
|
|
1651
|
+
e.preventDefault(), this._moveFocusBy(t, i, -1);
|
|
1593
1652
|
return;
|
|
1594
1653
|
}
|
|
1595
1654
|
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a") {
|
|
1596
|
-
e.preventDefault(), this._setSelection(
|
|
1655
|
+
e.preventDefault(), this._setSelection(t, "keyboard"), this._announce(`${t.length} items selected.`);
|
|
1597
1656
|
return;
|
|
1598
1657
|
}
|
|
1599
1658
|
if (e.key === "Enter") {
|
|
1600
|
-
e.preventDefault(), this._setSelection([
|
|
1659
|
+
e.preventDefault(), this._setSelection([r], "keyboard");
|
|
1601
1660
|
return;
|
|
1602
1661
|
}
|
|
1603
1662
|
if (e.key === " " || e.code === "Space") {
|
|
@@ -1605,20 +1664,20 @@ class ce extends ee {
|
|
|
1605
1664
|
this._announce("Dragging is disabled right now.");
|
|
1606
1665
|
return;
|
|
1607
1666
|
}
|
|
1608
|
-
const
|
|
1609
|
-
if (!
|
|
1610
|
-
const
|
|
1667
|
+
const c = this._selectedRootIds(r);
|
|
1668
|
+
if (!c.length) return;
|
|
1669
|
+
const h = this._itemClonesOnDrag(r);
|
|
1611
1670
|
this._dragState = {
|
|
1612
|
-
snapshot: this._items.map(
|
|
1613
|
-
movedRootIds:
|
|
1614
|
-
originId:
|
|
1615
|
-
clone:
|
|
1671
|
+
snapshot: this._items.map(P),
|
|
1672
|
+
movedRootIds: c,
|
|
1673
|
+
originId: r,
|
|
1674
|
+
clone: h,
|
|
1616
1675
|
keyboard: !0,
|
|
1617
|
-
dropTarget: this._initialKeyboardDropTarget(
|
|
1676
|
+
dropTarget: this._initialKeyboardDropTarget(r),
|
|
1618
1677
|
committed: !1
|
|
1619
1678
|
};
|
|
1620
|
-
const
|
|
1621
|
-
this._announce(`${
|
|
1679
|
+
const f = c.length === 1 ? `Lifted ${s?.label || "item"}.` : `Lifted ${c.length} items.`;
|
|
1680
|
+
this._announce(`${f} Use arrow keys to choose a destination.`), this.requestRender();
|
|
1622
1681
|
return;
|
|
1623
1682
|
}
|
|
1624
1683
|
if (e.key === "Escape") {
|
|
@@ -1633,24 +1692,28 @@ class ce extends ee {
|
|
|
1633
1692
|
}
|
|
1634
1693
|
if (e.key === "Enter" || e.key === " " || e.code === "Space") {
|
|
1635
1694
|
e.preventDefault();
|
|
1636
|
-
const
|
|
1637
|
-
if (!
|
|
1638
|
-
this._commitMove(
|
|
1695
|
+
const c = this._dragState.dropTarget;
|
|
1696
|
+
if (!c) return;
|
|
1697
|
+
this._commitMove(c, this._dragState.movedRootIds, this._dragState.clone, "keyboard");
|
|
1639
1698
|
return;
|
|
1640
1699
|
}
|
|
1641
1700
|
if (["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"].includes(e.key)) {
|
|
1642
1701
|
e.preventDefault();
|
|
1643
|
-
const d = e.key === "ArrowDown" || e.key ===
|
|
1644
|
-
this._moveKeyboardDropTarget(
|
|
1702
|
+
const c = d ? "ArrowLeft" : "ArrowRight", h = e.key === "ArrowDown" || e.key === c ? 1 : -1;
|
|
1703
|
+
this._moveKeyboardDropTarget(h);
|
|
1645
1704
|
}
|
|
1646
1705
|
}
|
|
1647
|
-
|
|
1648
|
-
const
|
|
1706
|
+
_isRtl() {
|
|
1707
|
+
const e = this.ownerDocument?.defaultView?.getComputedStyle(this).direction;
|
|
1708
|
+
return e ? e === "rtl" : this.closest("[dir]")?.getAttribute("dir") === "rtl";
|
|
1709
|
+
}
|
|
1710
|
+
_moveFocusBy(e, t, r) {
|
|
1711
|
+
const i = Math.max(0, Math.min(e.length - 1, t + r)), s = e[i];
|
|
1649
1712
|
this._focusedId = s, this._pendingFocusId = s, !this._applyInteractiveStateInPlace({ restoreFocus: !0 }) && this.requestRender();
|
|
1650
1713
|
}
|
|
1651
1714
|
_onDragStart(e) {
|
|
1652
|
-
const
|
|
1653
|
-
if (!
|
|
1715
|
+
const t = this._dragActivatorFromPath(e.composedPath()), r = t?.id;
|
|
1716
|
+
if (!t || !r) {
|
|
1654
1717
|
e.preventDefault();
|
|
1655
1718
|
return;
|
|
1656
1719
|
}
|
|
@@ -1658,97 +1721,102 @@ class ce extends ee {
|
|
|
1658
1721
|
e.preventDefault(), this._announce("Dragging is disabled right now.");
|
|
1659
1722
|
return;
|
|
1660
1723
|
}
|
|
1661
|
-
const i = this._items.find((
|
|
1724
|
+
const i = this._items.find((a) => a.id === r);
|
|
1662
1725
|
if (!i || i.disabled || i.dragDisabled) {
|
|
1663
1726
|
e.preventDefault();
|
|
1664
1727
|
return;
|
|
1665
1728
|
}
|
|
1666
|
-
const s = this._selection.includes(
|
|
1667
|
-
this._selection.includes(
|
|
1668
|
-
const
|
|
1729
|
+
const s = this._selection.includes(r) ? this._selectedRootIds(r) : [r];
|
|
1730
|
+
this._selection.includes(r) || this._setSelection([r], "pointer");
|
|
1731
|
+
const n = this._itemClonesOnDrag(r);
|
|
1669
1732
|
this._dragState = {
|
|
1670
|
-
snapshot: this._items.map(
|
|
1733
|
+
snapshot: this._items.map(P),
|
|
1671
1734
|
movedRootIds: s,
|
|
1672
|
-
originId:
|
|
1673
|
-
clone:
|
|
1735
|
+
originId: r,
|
|
1736
|
+
clone: n,
|
|
1674
1737
|
keyboard: !1,
|
|
1675
1738
|
dropTarget: null,
|
|
1676
1739
|
committed: !1
|
|
1677
|
-
}, e.dataTransfer && (e.dataTransfer.effectAllowed =
|
|
1678
|
-
|
|
1740
|
+
}, e.dataTransfer && (e.dataTransfer.effectAllowed = n ? "copyMove" : "move", e.dataTransfer.setData("text/plain", s.join(",")), this._applyDragImage(e.dataTransfer, s.length)), this._announce(
|
|
1741
|
+
n ? `Dragging ${s.length === 1 ? i.label : `${s.length} items`} as a copy.` : `Dragging ${s.length === 1 ? i.label : `${s.length} items`}.`
|
|
1679
1742
|
), this.requestRender();
|
|
1680
1743
|
}
|
|
1681
1744
|
_onDragOver(e) {
|
|
1682
1745
|
if (!this._dragState || this._dragState.keyboard) return;
|
|
1683
|
-
const
|
|
1684
|
-
if (!
|
|
1746
|
+
const t = this._dropTargetFromEvent(e);
|
|
1747
|
+
if (!t || !this._canDrop(t, this._dragState.movedRootIds)) {
|
|
1685
1748
|
this._queueDropTarget(null, e.timeStamp);
|
|
1686
1749
|
return;
|
|
1687
1750
|
}
|
|
1688
|
-
e.preventDefault(), this._queueDropTarget(
|
|
1751
|
+
e.preventDefault(), this._queueDropTarget(t, e.timeStamp), e.dataTransfer && (e.dataTransfer.dropEffect = this._dragState.clone ? "copy" : "move");
|
|
1689
1752
|
}
|
|
1690
1753
|
_onDrop(e) {
|
|
1691
1754
|
if (!this._dragState || this._dragState.keyboard) return;
|
|
1692
|
-
const
|
|
1693
|
-
!
|
|
1755
|
+
const t = this._dropTargetFromEvent(e);
|
|
1756
|
+
!t || !this._canDrop(t, this._dragState.movedRootIds) || (e.preventDefault(), this._commitMove(t, this._dragState.movedRootIds, this._dragState.clone, "pointer"));
|
|
1694
1757
|
}
|
|
1695
1758
|
_onDocumentKeyDown(e) {
|
|
1696
1759
|
e.key === "Escape" && (!this._dragState || this._dragState.keyboard || (e.preventDefault(), this._cancelDrag(!0)));
|
|
1697
1760
|
}
|
|
1698
1761
|
_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());
|
|
1762
|
+
!this._dragState || this._dragState.keyboard || this._dragState.committed || (this._setDraggingVisualState(this._draggingIds(), !1), this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this._announce("Drag cancelled."), this.requestRender());
|
|
1700
1763
|
}
|
|
1701
1764
|
_dropTargetFromEvent(e) {
|
|
1702
1765
|
return this._dropTargetFromPath(e.composedPath(), e.clientX, e.clientY);
|
|
1703
1766
|
}
|
|
1704
|
-
_dropTargetFromPath(e,
|
|
1705
|
-
const i = e.find((
|
|
1767
|
+
_dropTargetFromPath(e, t, r) {
|
|
1768
|
+
const i = e.find((S) => S instanceof HTMLElement && S.classList.contains("dropzone"));
|
|
1706
1769
|
if (i) {
|
|
1707
|
-
const
|
|
1770
|
+
const S = {
|
|
1708
1771
|
listId: i.getAttribute("data-list-id") || "",
|
|
1709
1772
|
parentId: i.getAttribute("data-parent-id") || null,
|
|
1710
1773
|
beforeId: i.getAttribute("data-before-id") || null,
|
|
1711
1774
|
mode: i.getAttribute("data-mode") === "inside" ? "inside" : "before"
|
|
1712
1775
|
};
|
|
1713
|
-
if (
|
|
1776
|
+
if (S.listId) return S;
|
|
1714
1777
|
}
|
|
1715
|
-
const s = e.find((
|
|
1716
|
-
if (!s)
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1778
|
+
const s = e.find((S) => S instanceof HTMLElement && S.classList.contains("item"));
|
|
1779
|
+
if (!s) {
|
|
1780
|
+
const R = e.find(
|
|
1781
|
+
($) => $ instanceof HTMLElement && $.classList.contains("list") && $.hasAttribute("data-list-id")
|
|
1782
|
+
)?.getAttribute("data-list-id");
|
|
1783
|
+
return R ? { listId: R, parentId: null, beforeId: null, mode: "before" } : null;
|
|
1784
|
+
}
|
|
1785
|
+
const n = s.getAttribute("data-id");
|
|
1720
1786
|
if (!n) return null;
|
|
1721
|
-
const
|
|
1722
|
-
if (
|
|
1787
|
+
const a = this._items.find((S) => S.id === n);
|
|
1788
|
+
if (!a) return null;
|
|
1789
|
+
const d = this._lists.find((S) => S.id === a.listId), o = s.getBoundingClientRect(), u = d?.orientation === "horizontal", c = u ? o.left : o.top, h = u ? o.right : o.bottom, f = u ? t : r, _ = Math.max(1, h - c), I = (f - c) / _, m = u && this._isRtl() ? 1 - I : I, v = this.getAttribute("allow-nesting") !== "false" && !a.disabled;
|
|
1790
|
+
if (m <= 0.34)
|
|
1723
1791
|
return {
|
|
1724
|
-
listId:
|
|
1725
|
-
parentId:
|
|
1726
|
-
beforeId:
|
|
1792
|
+
listId: a.listId,
|
|
1793
|
+
parentId: a.parentId,
|
|
1794
|
+
beforeId: a.id,
|
|
1727
1795
|
mode: "before"
|
|
1728
1796
|
};
|
|
1729
|
-
if (
|
|
1797
|
+
if (v && m >= 0.34 && m <= 0.74)
|
|
1730
1798
|
return {
|
|
1731
|
-
listId:
|
|
1732
|
-
parentId:
|
|
1799
|
+
listId: a.listId,
|
|
1800
|
+
parentId: a.id,
|
|
1733
1801
|
beforeId: null,
|
|
1734
1802
|
mode: "inside"
|
|
1735
1803
|
};
|
|
1736
|
-
const
|
|
1804
|
+
const A = E(this._items).get(k(a.listId, a.parentId)) || [], z = A.indexOf(a.id), b = z >= 0 && A[z + 1] || null;
|
|
1737
1805
|
return {
|
|
1738
|
-
listId:
|
|
1739
|
-
parentId:
|
|
1740
|
-
beforeId:
|
|
1806
|
+
listId: a.listId,
|
|
1807
|
+
parentId: a.parentId,
|
|
1808
|
+
beforeId: b,
|
|
1741
1809
|
mode: "before"
|
|
1742
1810
|
};
|
|
1743
1811
|
}
|
|
1744
|
-
_dropTargetFromPoint(e,
|
|
1745
|
-
return this._dropTargetFromPath(this._pathFromPoint(e,
|
|
1812
|
+
_dropTargetFromPoint(e, t) {
|
|
1813
|
+
return this._dropTargetFromPath(this._pathFromPoint(e, t), e, t);
|
|
1746
1814
|
}
|
|
1747
|
-
_beginPointerDrag(e,
|
|
1815
|
+
_beginPointerDrag(e, t) {
|
|
1748
1816
|
if (!this._pointerGesture || this._dragState) return;
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1751
|
-
snapshot: this._items.map(
|
|
1817
|
+
const r = this._items.find((i) => i.id === this._pointerGesture?.originId);
|
|
1818
|
+
r && (this._dragState = {
|
|
1819
|
+
snapshot: this._items.map(P),
|
|
1752
1820
|
movedRootIds: [...this._pointerGesture.movedRootIds],
|
|
1753
1821
|
originId: this._pointerGesture.originId,
|
|
1754
1822
|
clone: this._pointerGesture.clone,
|
|
@@ -1757,41 +1825,41 @@ class ce extends ee {
|
|
|
1757
1825
|
committed: !1
|
|
1758
1826
|
}, this._pendingDropTarget = null, this._applyPointerPreview(
|
|
1759
1827
|
e,
|
|
1760
|
-
|
|
1828
|
+
t,
|
|
1761
1829
|
this._dragState.movedRootIds.length,
|
|
1762
1830
|
this._dragState.clone
|
|
1763
1831
|
), this._setDraggingVisualState(this._draggingIds(), !0), this._announce(
|
|
1764
|
-
this._dragState.clone ? `Dragging ${this._dragState.movedRootIds.length === 1 ?
|
|
1832
|
+
this._dragState.clone ? `Dragging ${this._dragState.movedRootIds.length === 1 ? r.label : `${this._dragState.movedRootIds.length} items`} as a copy.` : `Dragging ${this._dragState.movedRootIds.length === 1 ? r.label : `${this._dragState.movedRootIds.length} items`}.`
|
|
1765
1833
|
));
|
|
1766
1834
|
}
|
|
1767
1835
|
_onPointerDown(e) {
|
|
1768
|
-
const
|
|
1769
|
-
if (!
|
|
1836
|
+
const t = this._dragActivatorFromPath(e.composedPath()), r = t?.id;
|
|
1837
|
+
if (!t || !r) return;
|
|
1770
1838
|
if (this._isDragLocked()) {
|
|
1771
1839
|
e.preventDefault(), this._announce("Dragging is disabled right now.");
|
|
1772
1840
|
return;
|
|
1773
1841
|
}
|
|
1774
|
-
const i = this._items.find((
|
|
1842
|
+
const i = this._items.find((n) => n.id === r);
|
|
1775
1843
|
if (!i || i.disabled || i.dragDisabled) {
|
|
1776
1844
|
e.preventDefault();
|
|
1777
1845
|
return;
|
|
1778
1846
|
}
|
|
1779
1847
|
e.preventDefault();
|
|
1780
1848
|
try {
|
|
1781
|
-
|
|
1849
|
+
t.element.setPointerCapture?.(e.pointerId);
|
|
1782
1850
|
} catch {
|
|
1783
1851
|
}
|
|
1784
|
-
const s = this._selection.includes(
|
|
1852
|
+
const s = this._selection.includes(r) ? this._selectedRootIds(r) : [r];
|
|
1785
1853
|
this._pointerGesture = {
|
|
1786
1854
|
pointerId: e.pointerId,
|
|
1787
1855
|
pointerType: e.pointerType,
|
|
1788
|
-
originId:
|
|
1856
|
+
originId: r,
|
|
1789
1857
|
movedRootIds: s,
|
|
1790
|
-
clone: this._itemClonesOnDrag(
|
|
1858
|
+
clone: this._itemClonesOnDrag(r),
|
|
1791
1859
|
startX: e.clientX,
|
|
1792
1860
|
startY: e.clientY,
|
|
1793
1861
|
moved: !1,
|
|
1794
|
-
captureTarget:
|
|
1862
|
+
captureTarget: t.element
|
|
1795
1863
|
};
|
|
1796
1864
|
}
|
|
1797
1865
|
_onPointerMove(e) {
|
|
@@ -1800,16 +1868,24 @@ class ce extends ee {
|
|
|
1800
1868
|
if (Math.hypot(e.clientX - this._pointerGesture.startX, e.clientY - this._pointerGesture.startY) < 6) return;
|
|
1801
1869
|
this._pointerGesture.moved = !0, this._beginPointerDrag(e.clientX, e.clientY);
|
|
1802
1870
|
}
|
|
1803
|
-
if (!(!this._dragState || this._dragState.keyboard) && (this._movePointerPreview(e.clientX, e.clientY), !this._dragState.committed)) {
|
|
1804
|
-
const
|
|
1805
|
-
if (!
|
|
1871
|
+
if (!(!this._dragState || this._dragState.keyboard) && (this._movePointerPreview(e.clientX, e.clientY), this._updateAutoScroll(e.clientX, e.clientY), !this._dragState.committed)) {
|
|
1872
|
+
const t = this._dropTargetFromPoint(e.clientX, e.clientY);
|
|
1873
|
+
if (!t || !this._canDrop(t, this._dragState.movedRootIds)) {
|
|
1806
1874
|
this._queueDropTarget(null, e.timeStamp);
|
|
1807
1875
|
return;
|
|
1808
1876
|
}
|
|
1809
|
-
this._queueDropTarget(
|
|
1877
|
+
this._queueDropTarget(t, e.timeStamp);
|
|
1810
1878
|
}
|
|
1811
1879
|
}
|
|
1812
1880
|
}
|
|
1881
|
+
// Holding a dragged card near the top or bottom edge scrolls the page (or the nearest scrolling
|
|
1882
|
+
// container), so lists and positions that are off screen can be reached with the pointer.
|
|
1883
|
+
_updateAutoScroll(e, t) {
|
|
1884
|
+
this._autoScrollPoint = { x: e, y: t }, !this._autoScrollFrame && typeof requestAnimationFrame == "function" && (this._autoScrollFrame = requestAnimationFrame(this._autoScrollTick));
|
|
1885
|
+
}
|
|
1886
|
+
_stopAutoScroll() {
|
|
1887
|
+
this._autoScrollFrame && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(this._autoScrollFrame), this._autoScrollFrame = 0, this._autoScrollPoint = null;
|
|
1888
|
+
}
|
|
1813
1889
|
_onPointerUp(e) {
|
|
1814
1890
|
if (!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId) return;
|
|
1815
1891
|
e.preventDefault();
|
|
@@ -1817,26 +1893,26 @@ class ce extends ee {
|
|
|
1817
1893
|
this._pointerGesture.captureTarget?.releasePointerCapture?.(e.pointerId);
|
|
1818
1894
|
} catch {
|
|
1819
1895
|
}
|
|
1820
|
-
const
|
|
1821
|
-
if (this._pointerGesture = null, !this._dragState || this._dragState.keyboard) return;
|
|
1822
|
-
const
|
|
1823
|
-
if (
|
|
1824
|
-
this._commitMove(
|
|
1896
|
+
const t = this._pointerGesture;
|
|
1897
|
+
if (this._pointerGesture = null, this._stopAutoScroll(), !this._dragState || this._dragState.keyboard) return;
|
|
1898
|
+
const r = t.moved ? this._releaseDropTarget(e.clientX, e.clientY) : null;
|
|
1899
|
+
if (t.moved && r) {
|
|
1900
|
+
this._commitMove(r, this._dragState.movedRootIds, this._dragState.clone, "pointer");
|
|
1825
1901
|
return;
|
|
1826
1902
|
}
|
|
1827
|
-
|
|
1903
|
+
t.moved ? this._cancelDrag(!0) : (this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this.requestRender());
|
|
1828
1904
|
}
|
|
1829
1905
|
_onPointerCancel(e) {
|
|
1830
|
-
!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId || (this._pointerGesture = null, this._dragState && this._cancelDrag(!0));
|
|
1906
|
+
!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId || (this._pointerGesture = null, this._stopAutoScroll(), this._dragState && this._cancelDrag(!0));
|
|
1831
1907
|
}
|
|
1832
|
-
_setSelection(e,
|
|
1833
|
-
const
|
|
1908
|
+
_setSelection(e, t) {
|
|
1909
|
+
const r = new Set(this._items.map((a) => a.id)), i = Array.from(new Set(e.filter((a) => r.has(a)))), s = [...this._selection];
|
|
1834
1910
|
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 =
|
|
1911
|
+
const n = X(i);
|
|
1912
|
+
if (this.getAttribute("selection") !== n) {
|
|
1913
|
+
this._lastSelectionAttr = n, this._suppressAttributeRender = !0;
|
|
1838
1914
|
try {
|
|
1839
|
-
i.length ? this.setAttribute("selection",
|
|
1915
|
+
i.length ? this.setAttribute("selection", n) : this.removeAttribute("selection");
|
|
1840
1916
|
} finally {
|
|
1841
1917
|
this._suppressAttributeRender = !1;
|
|
1842
1918
|
}
|
|
@@ -1848,154 +1924,154 @@ class ce extends ee {
|
|
|
1848
1924
|
},
|
|
1849
1925
|
bubbles: !0,
|
|
1850
1926
|
composed: !0
|
|
1851
|
-
})),
|
|
1927
|
+
})), t !== "restore") {
|
|
1852
1928
|
if (this._applyInteractiveStateInPlace({ restoreFocus: !0 })) return;
|
|
1853
1929
|
this.requestRender();
|
|
1854
1930
|
}
|
|
1855
1931
|
}
|
|
1856
1932
|
_toggleSelection(e) {
|
|
1857
|
-
const
|
|
1858
|
-
this._setSelection(
|
|
1933
|
+
const t = this._selection.includes(e) ? this._selection.filter((r) => r !== e) : [...this._selection, e];
|
|
1934
|
+
this._setSelection(t, "pointer"), this._announce(`${t.length} items selected.`);
|
|
1859
1935
|
}
|
|
1860
1936
|
_selectRangeTo(e) {
|
|
1861
|
-
const
|
|
1937
|
+
const t = this._visibleItemIds(), r = this._rangeAnchorId || this._focusedId || e, i = t.indexOf(r), s = t.indexOf(e);
|
|
1862
1938
|
if (i < 0 || s < 0) {
|
|
1863
1939
|
this._setSelection([e], "pointer");
|
|
1864
1940
|
return;
|
|
1865
1941
|
}
|
|
1866
|
-
const [
|
|
1867
|
-
this._setSelection(
|
|
1942
|
+
const [n, a] = i <= s ? [i, s] : [s, i];
|
|
1943
|
+
this._setSelection(t.slice(n, a + 1), "pointer"), this._announce(`${a - n + 1} items selected.`);
|
|
1868
1944
|
}
|
|
1869
1945
|
_visibleItemIds() {
|
|
1870
1946
|
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((
|
|
1947
|
+
return Array.from(e.values()).flat().filter((t) => !t.disabled).map((t) => t.id);
|
|
1872
1948
|
}
|
|
1873
1949
|
_selectedRootIds(e) {
|
|
1874
|
-
const
|
|
1875
|
-
return
|
|
1876
|
-
const
|
|
1877
|
-
if (!
|
|
1878
|
-
let
|
|
1879
|
-
for (;
|
|
1880
|
-
if (i.has(
|
|
1881
|
-
|
|
1950
|
+
const t = this._selection.length ? [...this._selection] : e ? [e] : [], r = T(this._items), i = new Set(t);
|
|
1951
|
+
return t.filter((s) => {
|
|
1952
|
+
const n = r.get(s);
|
|
1953
|
+
if (!n) return !1;
|
|
1954
|
+
let a = n.parentId;
|
|
1955
|
+
for (; a; ) {
|
|
1956
|
+
if (i.has(a)) return !1;
|
|
1957
|
+
a = r.get(a)?.parentId ?? null;
|
|
1882
1958
|
}
|
|
1883
|
-
return !
|
|
1959
|
+
return !n.disabled;
|
|
1884
1960
|
});
|
|
1885
1961
|
}
|
|
1886
1962
|
_draggingIds() {
|
|
1887
1963
|
if (!this._dragState) return [];
|
|
1888
|
-
const e =
|
|
1889
|
-
|
|
1890
|
-
const
|
|
1891
|
-
if (!
|
|
1892
|
-
(
|
|
1964
|
+
const e = T(this._items), t = E(this._items), r = [], i = (s) => {
|
|
1965
|
+
r.push(s);
|
|
1966
|
+
const n = e.get(s);
|
|
1967
|
+
if (!n) return;
|
|
1968
|
+
(t.get(k(n.listId, s)) || []).forEach(i);
|
|
1893
1969
|
};
|
|
1894
|
-
return this._dragState.movedRootIds.forEach(i),
|
|
1970
|
+
return this._dragState.movedRootIds.forEach(i), r;
|
|
1895
1971
|
}
|
|
1896
1972
|
_itemClonesOnDrag(e) {
|
|
1897
|
-
const
|
|
1898
|
-
return
|
|
1973
|
+
const t = this._items.find((i) => i.id === e);
|
|
1974
|
+
return t ? t.cloneOnDrag ? !0 : !!this._lists.find((i) => i.id === t.listId)?.cloneOnDrag : !1;
|
|
1899
1975
|
}
|
|
1900
1976
|
_isDragLocked() {
|
|
1901
1977
|
return !!(this.hasAttribute("disabled") || this.sort !== "manual" || this.filterQuery && !this.hasAttribute("allow-filtered-drag"));
|
|
1902
1978
|
}
|
|
1903
|
-
_canDrop(e,
|
|
1979
|
+
_canDrop(e, t) {
|
|
1904
1980
|
if (this._isDragLocked()) return !1;
|
|
1905
|
-
const
|
|
1906
|
-
if (!
|
|
1907
|
-
const i =
|
|
1981
|
+
const r = this._lists.find((o) => o.id === e.listId);
|
|
1982
|
+
if (!r || r.disabled) return !1;
|
|
1983
|
+
const i = T(this._items), s = /* @__PURE__ */ new Set(), n = E(this._items), a = (o) => {
|
|
1908
1984
|
s.add(o);
|
|
1909
1985
|
const u = i.get(o);
|
|
1910
|
-
u && (
|
|
1986
|
+
u && (n.get(k(u.listId, o)) || []).forEach(a);
|
|
1911
1987
|
};
|
|
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 ||
|
|
1988
|
+
if (t.forEach(a), e.parentId && s.has(e.parentId) || e.beforeId && s.has(e.beforeId)) return !1;
|
|
1989
|
+
const d = Array.from(new Set(t.map((o) => i.get(o)?.listId).filter(Boolean)));
|
|
1990
|
+
return !(r.accepts?.length && d.some((o) => !r.accepts?.includes(o)) || e.mode === "inside" && this.getAttribute("allow-nesting") === "false");
|
|
1991
|
+
}
|
|
1992
|
+
_commitMove(e, t, r, i) {
|
|
1993
|
+
if (!this._canDrop(e, t)) return;
|
|
1994
|
+
const s = T(this._items), n = E(this._items), a = /* @__PURE__ */ new Set(), d = [], o = (p) => {
|
|
1995
|
+
const w = s.get(p);
|
|
1996
|
+
!w || a.has(p) || (a.add(p), d.push(p), (n.get(k(w.listId, p)) || []).forEach(o));
|
|
1921
1997
|
};
|
|
1922
|
-
|
|
1923
|
-
const u = this._items.map(
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
}),
|
|
1927
|
-
const w =
|
|
1928
|
-
|
|
1998
|
+
t.forEach(o);
|
|
1999
|
+
const u = this._items.map(P), c = u.filter((p) => a.has(p.id)), h = r ? u.map(P) : u.filter((p) => !a.has(p.id)), f = r ? c.map((p) => this._cloneSubtreeItem(p, d)) : c.map(P), _ = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map();
|
|
2000
|
+
r && c.forEach((p, w) => {
|
|
2001
|
+
_.set(p.id, f[w].id), I.set(f[w].id, p.id);
|
|
2002
|
+
}), f.forEach((p) => {
|
|
2003
|
+
const w = r ? I.get(p.id) : p.id, F = w ? s.get(w) : null;
|
|
2004
|
+
F && (r && (p.parentId = F.parentId && _.has(F.parentId) && _.get(F.parentId) || null), p.listId = e.listId);
|
|
1929
2005
|
});
|
|
1930
|
-
const
|
|
1931
|
-
|
|
1932
|
-
const [,
|
|
1933
|
-
(
|
|
2006
|
+
const m = t.map((p) => _.get(p) || p), v = [...h, ...f], D = E(h), A = k(e.listId, e.parentId), z = [...D.get(A) || []], b = e.beforeId ? z.indexOf(e.beforeId) : z.length, S = b >= 0 ? b : z.length;
|
|
2007
|
+
z.splice(S, 0, ...m), D.set(A, z), E(f).forEach((p, w) => {
|
|
2008
|
+
const [, F] = w.split("::");
|
|
2009
|
+
(F || "") !== "__root__" && D.set(w, [...p]);
|
|
1934
2010
|
});
|
|
1935
|
-
const
|
|
1936
|
-
|
|
1937
|
-
const w =
|
|
2011
|
+
const $ = T(v);
|
|
2012
|
+
m.forEach((p) => {
|
|
2013
|
+
const w = $.get(p);
|
|
1938
2014
|
w && (w.parentId = e.parentId, w.listId = e.listId);
|
|
1939
2015
|
});
|
|
1940
|
-
const
|
|
1941
|
-
(
|
|
1942
|
-
const
|
|
1943
|
-
!
|
|
2016
|
+
const O = [], L = /* @__PURE__ */ new Set(), q = (p, w) => {
|
|
2017
|
+
(D.get(k(p, w)) || []).forEach((V, Z) => {
|
|
2018
|
+
const N = $.get(V);
|
|
2019
|
+
!N || L.has(V) || (L.add(V), N.listId = p, N.parentId = w, N.order = Z, O.push(N), q(p, V));
|
|
1944
2020
|
});
|
|
1945
2021
|
};
|
|
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
|
|
2022
|
+
this._lists.forEach((p) => q(p.id, null)), v.forEach((p) => {
|
|
2023
|
+
L.has(p.id) || (p.parentId = null, O.push(p));
|
|
2024
|
+
}), this._dragState && (this._dragState.committed = !0), this._items = O.map(P), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage();
|
|
2025
|
+
const H = [...m], g = [...this._selection];
|
|
2026
|
+
this._selection = H, this._focusedId = H[0] || null, this._pendingFocusId = this._focusedId, this._syncAttributesFromState();
|
|
2027
|
+
const x = J(this._items);
|
|
2028
|
+
this._persistSnapshot(x);
|
|
2029
|
+
const M = t.map((p) => s.get(p)).filter((p) => !!p), C = r ? "clone" : e.mode === "inside" ? "nest" : M.some((p) => p.listId !== e.listId) ? "transfer" : "reorder", G = {
|
|
1954
2030
|
items: this.items,
|
|
1955
2031
|
lists: this.lists,
|
|
1956
|
-
selection: [...
|
|
2032
|
+
selection: [...H],
|
|
1957
2033
|
previousSelection: g,
|
|
1958
|
-
movedIds: [...
|
|
2034
|
+
movedIds: [...m],
|
|
1959
2035
|
source: i,
|
|
1960
|
-
operation:
|
|
1961
|
-
persistence:
|
|
2036
|
+
operation: C,
|
|
2037
|
+
persistence: x
|
|
1962
2038
|
};
|
|
1963
2039
|
this.dispatchEvent(new CustomEvent("change", {
|
|
1964
|
-
detail:
|
|
2040
|
+
detail: G,
|
|
1965
2041
|
bubbles: !0,
|
|
1966
2042
|
composed: !0
|
|
1967
2043
|
})), this.dispatchEvent(new CustomEvent("persist-request", {
|
|
1968
|
-
detail:
|
|
2044
|
+
detail: G,
|
|
1969
2045
|
bubbles: !0,
|
|
1970
2046
|
composed: !0
|
|
1971
|
-
})), this._announce(this._messageForMove(
|
|
2047
|
+
})), this._announce(this._messageForMove(C, m.length, e)), this.requestRender();
|
|
1972
2048
|
}
|
|
1973
2049
|
_syncAttributesFromState() {
|
|
1974
|
-
const e =
|
|
1975
|
-
this._lastListsAttr = e, this._lastItemsAttr =
|
|
2050
|
+
const e = pe(this._lists), t = ue(this._items), r = X(this._selection);
|
|
2051
|
+
this._lastListsAttr = e, this._lastItemsAttr = t, this._lastSelectionAttr = r, this._suppressAttributeRender = !0;
|
|
1976
2052
|
try {
|
|
1977
|
-
this.setAttribute("lists", e), this.setAttribute("items",
|
|
2053
|
+
this.setAttribute("lists", e), this.setAttribute("items", t), this._selection.length ? this.setAttribute("selection", r) : this.removeAttribute("selection");
|
|
1978
2054
|
} finally {
|
|
1979
2055
|
this._suppressAttributeRender = !1;
|
|
1980
2056
|
}
|
|
1981
2057
|
}
|
|
1982
|
-
_cloneSubtreeItem(e,
|
|
1983
|
-
const i = `copy-${this._cloneSeed++}`,
|
|
2058
|
+
_cloneSubtreeItem(e, t) {
|
|
2059
|
+
const i = `copy-${this._cloneSeed++}`, n = `${e.id.includes("--copy-") ? e.id.split("--copy-")[0] : e.id}--${i}`;
|
|
1984
2060
|
return {
|
|
1985
2061
|
...e,
|
|
1986
|
-
id:
|
|
1987
|
-
label:
|
|
2062
|
+
id: n,
|
|
2063
|
+
label: t[0] === e.id ? `${e.label} copy` : e.label
|
|
1988
2064
|
};
|
|
1989
2065
|
}
|
|
1990
|
-
_messageForMove(e,
|
|
1991
|
-
const s = this._lists.find((
|
|
1992
|
-
return e === "clone" ? `${
|
|
2066
|
+
_messageForMove(e, t, r) {
|
|
2067
|
+
const s = this._lists.find((n) => n.id === r.listId)?.label || r.listId;
|
|
2068
|
+
return e === "clone" ? `${t === 1 ? "Item copied" : `${t} items copied`} into ${s}.` : e === "nest" ? `${t === 1 ? "Item nested" : `${t} items nested`} in ${s}.` : e === "transfer" ? `${t === 1 ? "Item moved" : `${t} items moved`} to ${s}.` : `${t === 1 ? "Item reordered" : `${t} items reordered`} in ${s}.`;
|
|
1993
2069
|
}
|
|
1994
2070
|
_persistSnapshot(e) {
|
|
1995
|
-
const
|
|
1996
|
-
if (
|
|
2071
|
+
const t = this.getAttribute("persist-key");
|
|
2072
|
+
if (t)
|
|
1997
2073
|
try {
|
|
1998
|
-
window.localStorage.setItem(
|
|
2074
|
+
window.localStorage.setItem(t, JSON.stringify(e));
|
|
1999
2075
|
} catch {
|
|
2000
2076
|
}
|
|
2001
2077
|
}
|
|
@@ -2003,12 +2079,12 @@ class ce extends ee {
|
|
|
2003
2079
|
this._liveMessage = e, this._applyLiveMessage();
|
|
2004
2080
|
}
|
|
2005
2081
|
_cancelDrag(e) {
|
|
2006
|
-
this._dragState && (this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._items = this._dragState.snapshot.map(
|
|
2082
|
+
this._stopAutoScroll(), this._dragState && (this._setDraggingVisualState(this._draggingIds(), !1), this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._items = this._dragState.snapshot.map(P), this._dragState = null, this._pointerGesture = null, this._removeDragImage(), e && this._announce("Drag cancelled."), this._syncAttributesFromState(), this.requestRender());
|
|
2007
2083
|
}
|
|
2008
|
-
_applyDragImage(e,
|
|
2084
|
+
_applyDragImage(e, t) {
|
|
2009
2085
|
this._removeDragImage();
|
|
2010
|
-
const
|
|
2011
|
-
|
|
2086
|
+
const r = document.createElement("div");
|
|
2087
|
+
r.textContent = t === 1 ? "Dragging item" : `Dragging ${t} items`, r.style.position = "fixed", r.style.top = "-999px", r.style.left = "-999px", r.style.padding = "8px 12px", r.style.borderRadius = "999px", r.style.background = "rgba(15, 23, 42, 0.92)", r.style.color = "#f8fafc", r.style.font = "600 12px/1 Inter, sans-serif", r.style.pointerEvents = "none", document.body.appendChild(r), e.setDragImage(r, 12, 12), this._dragImage = r;
|
|
2012
2088
|
}
|
|
2013
2089
|
_removeDragImage() {
|
|
2014
2090
|
this._dragImage?.remove(), this._dragImage = null;
|
|
@@ -2016,61 +2092,68 @@ class ce extends ee {
|
|
|
2016
2092
|
_removeDragPreviewOverlay() {
|
|
2017
2093
|
this._dragPreviewOverlay?.remove(), this._dragPreviewOverlay = null;
|
|
2018
2094
|
}
|
|
2019
|
-
_applyPointerPreview(e,
|
|
2095
|
+
_applyPointerPreview(e, t, r, i) {
|
|
2020
2096
|
this._removeDragImage();
|
|
2021
2097
|
const s = document.createElement("div");
|
|
2022
|
-
s.textContent = i ?
|
|
2098
|
+
s.textContent = i ? r === 1 ? "Copying item" : `Copying ${r} items` : r === 1 ? "Moving item" : `Moving ${r} items`, s.style.position = "fixed", s.style.top = "0", s.style.left = "0", s.style.zIndex = "2147483647", s.style.padding = "8px 12px", s.style.borderRadius = "999px", s.style.background = "rgba(15, 23, 42, 0.92)", s.style.color = "#f8fafc", s.style.font = "600 12px/1 Inter, sans-serif", s.style.pointerEvents = "none", s.style.boxShadow = "0 12px 28px rgba(15, 23, 42, 0.22)", document.body.appendChild(s), this._dragImage = s, this._movePointerPreview(e, t);
|
|
2023
2099
|
}
|
|
2024
|
-
_movePointerPreview(e,
|
|
2025
|
-
this._dragImage && (this._dragImage.style.transform = `translate(${Math.round(e + 14)}px, ${Math.round(
|
|
2100
|
+
_movePointerPreview(e, t) {
|
|
2101
|
+
this._dragImage && (this._dragImage.style.transform = `translate(${Math.round(e + 14)}px, ${Math.round(t + 14)}px)`);
|
|
2026
2102
|
}
|
|
2027
2103
|
_keyboardDropTargets() {
|
|
2028
|
-
const e =
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2104
|
+
const e = T(this._items), t = E(this._items), r = [], i = this.getAttribute("allow-nesting") !== "false", s = (n, a) => {
|
|
2105
|
+
const d = t.get(k(n, a)) || [];
|
|
2106
|
+
d.forEach((o) => {
|
|
2107
|
+
const u = e.get(o);
|
|
2108
|
+
!u || u.hidden || (r.push({
|
|
2109
|
+
listId: n,
|
|
2033
2110
|
parentId: a,
|
|
2034
|
-
beforeId:
|
|
2111
|
+
beforeId: o,
|
|
2035
2112
|
mode: "before",
|
|
2036
|
-
label: `Before ${
|
|
2037
|
-
}),
|
|
2038
|
-
listId:
|
|
2039
|
-
parentId:
|
|
2113
|
+
label: `Before ${u.label}`
|
|
2114
|
+
}), i && r.push({
|
|
2115
|
+
listId: n,
|
|
2116
|
+
parentId: o,
|
|
2040
2117
|
beforeId: null,
|
|
2041
2118
|
mode: "inside",
|
|
2042
|
-
label: `Nest inside ${
|
|
2043
|
-
}),
|
|
2044
|
-
}),
|
|
2045
|
-
listId:
|
|
2119
|
+
label: `Nest inside ${u.label}`
|
|
2120
|
+
}), s(n, o));
|
|
2121
|
+
}), a ? i && d.length > 0 && r.push({
|
|
2122
|
+
listId: n,
|
|
2123
|
+
parentId: a,
|
|
2124
|
+
beforeId: null,
|
|
2125
|
+
mode: "before",
|
|
2126
|
+
label: "After children"
|
|
2127
|
+
}) : r.push({
|
|
2128
|
+
listId: n,
|
|
2046
2129
|
parentId: a,
|
|
2047
2130
|
beforeId: null,
|
|
2048
2131
|
mode: "before",
|
|
2049
|
-
label:
|
|
2132
|
+
label: `End of ${this._lists.find((o) => o.id === n)?.label || n}`
|
|
2050
2133
|
});
|
|
2051
2134
|
};
|
|
2052
|
-
return this._lists.forEach((
|
|
2135
|
+
return this._lists.forEach((n) => s(n.id, null)), r.filter((n) => this._canDrop(n, this._dragState?.movedRootIds || []));
|
|
2053
2136
|
}
|
|
2054
2137
|
_initialKeyboardDropTarget(e) {
|
|
2055
|
-
const
|
|
2056
|
-
return
|
|
2057
|
-
listId:
|
|
2058
|
-
parentId:
|
|
2138
|
+
const t = this._items.find((r) => r.id === e);
|
|
2139
|
+
return t ? {
|
|
2140
|
+
listId: t.listId,
|
|
2141
|
+
parentId: t.parentId,
|
|
2059
2142
|
beforeId: e,
|
|
2060
2143
|
mode: "before"
|
|
2061
2144
|
} : null;
|
|
2062
2145
|
}
|
|
2063
2146
|
_moveKeyboardDropTarget(e) {
|
|
2064
2147
|
if (!this._dragState) return;
|
|
2065
|
-
const
|
|
2066
|
-
if (!
|
|
2067
|
-
const
|
|
2148
|
+
const t = this._keyboardDropTargets();
|
|
2149
|
+
if (!t.length) return;
|
|
2150
|
+
const r = Math.max(0, t.findIndex(
|
|
2068
2151
|
(s) => s.listId === this._dragState?.dropTarget?.listId && s.parentId === this._dragState?.dropTarget?.parentId && s.beforeId === this._dragState?.dropTarget?.beforeId && s.mode === this._dragState?.dropTarget?.mode
|
|
2069
|
-
)), i = Math.max(0, Math.min(
|
|
2070
|
-
this._setDropTarget(
|
|
2152
|
+
)), i = Math.max(0, Math.min(t.length - 1, r + e));
|
|
2153
|
+
this._setDropTarget(t[i], { announceLabel: t[i].label });
|
|
2071
2154
|
}
|
|
2072
2155
|
}
|
|
2073
|
-
typeof customElements < "u" && !customElements.get("ui-sortable") && customElements.define("ui-sortable",
|
|
2156
|
+
typeof customElements < "u" && !customElements.get("ui-sortable") && customElements.define("ui-sortable", he);
|
|
2074
2157
|
export {
|
|
2075
|
-
|
|
2158
|
+
he as UISortable
|
|
2076
2159
|
};
|