impact-nova 1.7.29 → 1.7.30
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/components/ui/data-table/data-table-column-list.js +86 -82
- package/dist/components/ui/nested-list/hooks/useNestedListDragDrop.d.ts +2 -1
- package/dist/components/ui/nested-list/hooks/useNestedListDragDrop.js +134 -133
- package/dist/components/ui/nested-list/hooks/useNestedListState.d.ts +2 -1
- package/dist/components/ui/nested-list/hooks/useNestedListState.js +67 -66
- package/dist/components/ui/nested-list/nested-list.js +183 -175
- package/dist/components/ui/types/nested-list.types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as N, useRef as
|
|
3
|
-
import { useDataTable as
|
|
4
|
-
import { NestedList as
|
|
5
|
-
import { SelectionMode as
|
|
6
|
-
import { mergePartialOrderedColumnState as
|
|
7
|
-
import { useImpactNovaI18n as
|
|
8
|
-
const
|
|
9
|
-
enableApplyDiscard:
|
|
10
|
-
showSearch:
|
|
11
|
-
showSelectAll:
|
|
12
|
-
showCollapse:
|
|
1
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N, useRef as C, useCallback as b, useEffect as F } from "react";
|
|
3
|
+
import { useDataTable as X } from "./data-table-context.js";
|
|
4
|
+
import { NestedList as Y } from "../nested-list/nested-list.js";
|
|
5
|
+
import { SelectionMode as Z } from "../types/nested-list.types.js";
|
|
6
|
+
import { mergePartialOrderedColumnState as ee } from "./data-table-column-state.js";
|
|
7
|
+
import { useImpactNovaI18n as te } from "../../../i18n/ImpactNovaI18nContext.js";
|
|
8
|
+
const de = ({
|
|
9
|
+
enableApplyDiscard: v = !1,
|
|
10
|
+
showSearch: q = !0,
|
|
11
|
+
showSelectAll: j = !0,
|
|
12
|
+
showCollapse: K = !0
|
|
13
13
|
}) => {
|
|
14
|
-
const { gridApi: l } =
|
|
14
|
+
const { gridApi: l } = X(), { t: p } = te(), [V, w] = N([]), [W, B] = N(!1), f = C(!1), T = C(null), y = C(0), z = C({}), [O, P] = N(!1), L = C(/* @__PURE__ */ new Map()), g = b(() => {
|
|
15
15
|
if (!l || f.current) return;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const c = l.getColumns() || [], i = new Map(c.map((t) => [t.getColId(), t])),
|
|
19
|
-
const
|
|
16
|
+
const r = l.getColumnState(), s = new Map(r.map((t) => [t.colId, t]));
|
|
17
|
+
L.current = s;
|
|
18
|
+
const c = l.getColumns() || [], i = new Map(c.map((t) => [t.getColId(), t])), n = [], e = [], k = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), J = (t, a) => {
|
|
19
|
+
const o = t.getGroupId(), u = `${o}::${a === n ? "f" : "s"}`, d = k.get(u);
|
|
20
20
|
if (d && d.list === a && a[a.length - 1] === d.node)
|
|
21
21
|
return d.node;
|
|
22
22
|
const m = D.get(u) || 0;
|
|
23
23
|
D.set(u, m + 1);
|
|
24
|
-
const
|
|
25
|
-
id: m === 0 ? `${
|
|
26
|
-
label:
|
|
24
|
+
const I = t.getColGroupDef(), h = a === n ? "f" : "s", R = {
|
|
25
|
+
id: m === 0 ? `${o}__${h}` : `${o}__${h}__${m}`,
|
|
26
|
+
label: I?.headerName || o,
|
|
27
27
|
checked: !0,
|
|
28
28
|
children: [],
|
|
29
29
|
category: "group"
|
|
30
30
|
};
|
|
31
|
-
return a.push(
|
|
31
|
+
return a.push(R), k.set(u, { list: a, node: R }), R;
|
|
32
32
|
};
|
|
33
|
-
let E = 0,
|
|
34
|
-
|
|
33
|
+
let E = 0, $ = 0, G = 0, A = 0;
|
|
34
|
+
r.forEach((t) => {
|
|
35
35
|
const a = i.get(t.colId);
|
|
36
36
|
if (!a) return;
|
|
37
|
-
let
|
|
38
|
-
if (
|
|
39
|
-
if (
|
|
37
|
+
let o = l.getDisplayNameForColumn(a, "header");
|
|
38
|
+
if (o === "") return;
|
|
39
|
+
if (o == null) {
|
|
40
40
|
const h = a.getColDef();
|
|
41
41
|
if (h.headerName === "") return;
|
|
42
|
-
|
|
42
|
+
o = h.headerName || h.field || t.colId;
|
|
43
43
|
}
|
|
44
|
-
if (!
|
|
44
|
+
if (!o || o.trim() === "")
|
|
45
45
|
return;
|
|
46
46
|
const u = !t.hide, d = {
|
|
47
47
|
id: t.colId,
|
|
48
|
-
label:
|
|
48
|
+
label: o,
|
|
49
49
|
checked: u
|
|
50
50
|
};
|
|
51
|
-
t.pinned ? (E++, u &&
|
|
52
|
-
const m = t.pinned ?
|
|
53
|
-
|
|
51
|
+
t.pinned ? (E++, u && $++) : (G++, u && A++);
|
|
52
|
+
const m = t.pinned ? n : e, I = a.getOriginalParent();
|
|
53
|
+
I?.getColGroupDef()?.children ? J(I, m).children.push(d) : m.push(d);
|
|
54
54
|
});
|
|
55
55
|
const M = (t) => {
|
|
56
56
|
let a = t.length > 0;
|
|
57
|
-
for (const
|
|
58
|
-
|
|
57
|
+
for (const o of t)
|
|
58
|
+
o.children && (o.checked = M(o.children)), o.checked || (a = !1);
|
|
59
59
|
return a;
|
|
60
60
|
};
|
|
61
|
-
M(
|
|
62
|
-
const
|
|
61
|
+
M(n), M(e);
|
|
62
|
+
const Q = [
|
|
63
63
|
{
|
|
64
64
|
id: "root-frozen",
|
|
65
65
|
label: p("dataTable.frozenColumns"),
|
|
66
|
-
checked: E > 0 &&
|
|
67
|
-
children:
|
|
66
|
+
checked: E > 0 && $ === E,
|
|
67
|
+
children: n,
|
|
68
68
|
category: "structure",
|
|
69
69
|
isDragDisabled: !0
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
id: "root-scrollable",
|
|
73
73
|
label: p("dataTable.scrollableColumns"),
|
|
74
|
-
checked: G > 0 &&
|
|
74
|
+
checked: G > 0 && A === G,
|
|
75
75
|
children: e,
|
|
76
76
|
category: "structure",
|
|
77
77
|
isDragDisabled: !0
|
|
78
78
|
}
|
|
79
79
|
];
|
|
80
|
-
w(
|
|
80
|
+
w(Q), B(!0);
|
|
81
81
|
}, [l, p]);
|
|
82
|
-
|
|
82
|
+
F(() => {
|
|
83
83
|
if (!l) return;
|
|
84
|
-
const
|
|
84
|
+
const r = setTimeout(() => g(), 0), s = [
|
|
85
85
|
"columnVisible",
|
|
86
86
|
"columnPinned",
|
|
87
87
|
"columnMoved",
|
|
@@ -99,23 +99,23 @@ const ue = ({
|
|
|
99
99
|
const i = () => {
|
|
100
100
|
c && clearTimeout(c), c = setTimeout(() => {
|
|
101
101
|
c = null;
|
|
102
|
-
const
|
|
103
|
-
f.current = !1, g(),
|
|
102
|
+
const n = !f.current;
|
|
103
|
+
f.current = !1, g(), n && P((e) => !e);
|
|
104
104
|
}, 150);
|
|
105
105
|
};
|
|
106
|
-
return l.isDestroyed() || s.forEach((
|
|
107
|
-
clearTimeout(
|
|
106
|
+
return l.isDestroyed() || s.forEach((n) => l.addEventListener(n, i)), () => {
|
|
107
|
+
clearTimeout(r), c && clearTimeout(c), l.isDestroyed() || s.forEach((n) => l.removeEventListener(n, i));
|
|
108
108
|
};
|
|
109
|
-
}, [l, g]),
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
112
|
-
const s =
|
|
113
|
-
s && (s.scrollTop =
|
|
109
|
+
}, [l, g]), F(() => {
|
|
110
|
+
if (y.current === 0) return;
|
|
111
|
+
const r = requestAnimationFrame(() => {
|
|
112
|
+
const s = T.current?.querySelector('[data-component="nested-list"] .overflow-y-auto');
|
|
113
|
+
s && (s.scrollTop = y.current, y.current = 0);
|
|
114
114
|
});
|
|
115
|
-
return () => cancelAnimationFrame(
|
|
116
|
-
}, [
|
|
117
|
-
const
|
|
118
|
-
const s = [], c = (i,
|
|
115
|
+
return () => cancelAnimationFrame(r);
|
|
116
|
+
}, [O]);
|
|
117
|
+
const _ = b((r) => {
|
|
118
|
+
const s = [], c = (i, n) => {
|
|
119
119
|
i.forEach((e) => {
|
|
120
120
|
if (e.id === "root-frozen") {
|
|
121
121
|
e.children && c(e.children, "left");
|
|
@@ -125,57 +125,61 @@ const ue = ({
|
|
|
125
125
|
e.children && c(e.children, null);
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
|
-
e.category === "group" || e.children && e.children.length > 0 ? e.children && c(e.children,
|
|
128
|
+
e.category === "group" || e.children && e.children.length > 0 ? e.children && c(e.children, n) : l?.getColumn(e.id) && s.push({
|
|
129
129
|
colId: e.id,
|
|
130
|
-
pinned:
|
|
130
|
+
pinned: n,
|
|
131
131
|
hide: !e.checked
|
|
132
132
|
});
|
|
133
133
|
});
|
|
134
134
|
};
|
|
135
|
-
return c(
|
|
136
|
-
}, [l]),
|
|
135
|
+
return c(r, null), s;
|
|
136
|
+
}, [l]), S = b((r) => {
|
|
137
137
|
if (!l) return;
|
|
138
138
|
f.current = !0;
|
|
139
|
-
const s =
|
|
139
|
+
const s = _(r);
|
|
140
140
|
if (s.length === 0) {
|
|
141
141
|
setTimeout(() => {
|
|
142
142
|
f.current = !1;
|
|
143
143
|
}, 300);
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
const c = l.getColumnState(), i =
|
|
146
|
+
const c = l.getColumnState(), i = ee(c, s);
|
|
147
147
|
l.applyColumnState({
|
|
148
148
|
state: i,
|
|
149
149
|
applyOrder: !0
|
|
150
150
|
}), setTimeout(() => {
|
|
151
151
|
f.current = !1;
|
|
152
|
-
const
|
|
153
|
-
|
|
152
|
+
const n = T.current?.querySelector('[data-component="nested-list"] .overflow-y-auto');
|
|
153
|
+
n && (y.current = n.scrollTop), g(), P((e) => !e);
|
|
154
154
|
}, 300);
|
|
155
|
-
}, [l,
|
|
156
|
-
|
|
157
|
-
}, [
|
|
158
|
-
|
|
159
|
-
}, [
|
|
160
|
-
return
|
|
161
|
-
|
|
155
|
+
}, [l, _, g]), U = b((r) => {
|
|
156
|
+
S(r);
|
|
157
|
+
}, [S]), H = b((r) => {
|
|
158
|
+
v || S(r), w(r);
|
|
159
|
+
}, [v, S]);
|
|
160
|
+
return W ? /* @__PURE__ */ x("div", { ref: T, className: "flex flex-col h-full bg-canvas-elevated", children: /* @__PURE__ */ x(
|
|
161
|
+
Y,
|
|
162
162
|
{
|
|
163
|
-
items:
|
|
164
|
-
onChange:
|
|
165
|
-
onSubmit:
|
|
166
|
-
enableApplyDiscard:
|
|
167
|
-
enableSearch:
|
|
168
|
-
enableSelectAll:
|
|
163
|
+
items: V,
|
|
164
|
+
onChange: H,
|
|
165
|
+
onSubmit: U,
|
|
166
|
+
enableApplyDiscard: v,
|
|
167
|
+
enableSearch: q,
|
|
168
|
+
enableSelectAll: j,
|
|
169
169
|
enableDragDrop: !0,
|
|
170
170
|
enableCollapse: !0,
|
|
171
|
-
enableGlobalCollapse:
|
|
172
|
-
selectionMode:
|
|
171
|
+
enableGlobalCollapse: K,
|
|
172
|
+
selectionMode: Z.CASCADE_DOWN,
|
|
173
173
|
searchPlaceholder: p("dataTable.searchColumnsPlaceholder"),
|
|
174
|
-
className: "h-full"
|
|
174
|
+
className: "h-full",
|
|
175
|
+
initialCollapsedItems: z.current,
|
|
176
|
+
onCollapseChange: (r) => {
|
|
177
|
+
z.current = r;
|
|
178
|
+
}
|
|
175
179
|
},
|
|
176
|
-
|
|
177
|
-
) }) : /* @__PURE__ */
|
|
180
|
+
O ? "sync-a" : "sync-b"
|
|
181
|
+
) }) : /* @__PURE__ */ x("div", { className: "p-4 text-[13px] text-content-placeholder", children: p("dataTable.loadingColumns") });
|
|
178
182
|
};
|
|
179
183
|
export {
|
|
180
|
-
|
|
184
|
+
de as DataTableColumnList
|
|
181
185
|
};
|
|
@@ -15,8 +15,9 @@ export declare const customCollisionDetection: CollisionDetection;
|
|
|
15
15
|
interface UseNestedListDragDropProps {
|
|
16
16
|
items: NestedListItem[];
|
|
17
17
|
onDragEnd?: (activeId: string, overId: string | null) => void;
|
|
18
|
+
collapsedItems?: Record<string, boolean>;
|
|
18
19
|
}
|
|
19
|
-
export declare const useNestedListDragDrop: ({ items, onDragEnd, }: UseNestedListDragDropProps) => {
|
|
20
|
+
export declare const useNestedListDragDrop: ({ items, onDragEnd, collapsedItems, }: UseNestedListDragDropProps) => {
|
|
20
21
|
sensors: import('@dnd-kit/core').SensorDescriptor<import('@dnd-kit/core').SensorOptions>[];
|
|
21
22
|
handleDragEnd: (event: DragEndEvent, setItems: (updater: (prevItems: NestedListItem[]) => NestedListItem[]) => void) => void;
|
|
22
23
|
isValidDrop: (activeItemId: string | null, overItemId: string | null) => boolean;
|
|
@@ -1,239 +1,240 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
import { useSensors as
|
|
3
|
-
import { arrayMove as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
if (a.startsWith(
|
|
7
|
-
const s = a.slice(
|
|
8
|
-
if (
|
|
1
|
+
import { useCallback as x } from "react";
|
|
2
|
+
import { useSensors as Q, useSensor as V, MouseSensor as U, TouchSensor as Z, closestCenter as $ } from "@dnd-kit/core";
|
|
3
|
+
import { arrayMove as w } from "@dnd-kit/sortable";
|
|
4
|
+
const W = "droppable-", y = /* @__PURE__ */ new Set(["root-frozen", "root-scrollable"]);
|
|
5
|
+
function X(a) {
|
|
6
|
+
if (a.startsWith(W)) {
|
|
7
|
+
const s = a.slice(W.length);
|
|
8
|
+
if (y.has(s)) return s;
|
|
9
9
|
}
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
|
-
const
|
|
13
|
-
const s =
|
|
14
|
-
(
|
|
12
|
+
const I = (a) => {
|
|
13
|
+
const s = $(a), d = s.filter(
|
|
14
|
+
(R) => !y.has(R.id)
|
|
15
15
|
);
|
|
16
|
-
return
|
|
16
|
+
return d.length > 0 ? d : s;
|
|
17
17
|
};
|
|
18
|
-
function
|
|
19
|
-
for (const
|
|
20
|
-
if (
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
18
|
+
function M(a, s) {
|
|
19
|
+
for (const d of a) {
|
|
20
|
+
if (d.id === s) return d;
|
|
21
|
+
if (d.children) {
|
|
22
|
+
const R = M(d.children, s);
|
|
23
|
+
if (R) return R;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
for (const
|
|
29
|
-
if (
|
|
30
|
-
if (
|
|
31
|
-
return
|
|
27
|
+
function j(a, s) {
|
|
28
|
+
for (const d of a) {
|
|
29
|
+
if (d.id === s) return null;
|
|
30
|
+
if (d.children && M(d.children, s))
|
|
31
|
+
return d.id;
|
|
32
32
|
}
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
|
-
const
|
|
35
|
+
const nn = ({
|
|
36
36
|
items: a,
|
|
37
|
-
onDragEnd: s
|
|
37
|
+
onDragEnd: s,
|
|
38
|
+
collapsedItems: d = {}
|
|
38
39
|
}) => {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
),
|
|
43
|
-
(i, e,
|
|
40
|
+
const R = Q(
|
|
41
|
+
V(U),
|
|
42
|
+
V(Z)
|
|
43
|
+
), C = x(
|
|
44
|
+
(i, e, t = 0) => {
|
|
44
45
|
for (const n of i) {
|
|
45
|
-
if (n.id === e) return
|
|
46
|
+
if (n.id === e) return t;
|
|
46
47
|
if (n.children) {
|
|
47
|
-
const r =
|
|
48
|
+
const r = C(n.children, e, t + 1);
|
|
48
49
|
if (r !== null) return r;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
return null;
|
|
52
53
|
},
|
|
53
54
|
[]
|
|
54
|
-
),
|
|
55
|
-
(i, e,
|
|
55
|
+
), T = x(
|
|
56
|
+
(i, e, t = null) => {
|
|
56
57
|
for (const n of i) {
|
|
57
|
-
if (n.id === e) return
|
|
58
|
+
if (n.id === e) return t;
|
|
58
59
|
if (n.children) {
|
|
59
|
-
const r =
|
|
60
|
+
const r = T(n.children, e, n.id);
|
|
60
61
|
if (r !== null) return r;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
return null;
|
|
64
65
|
},
|
|
65
66
|
[]
|
|
66
|
-
),
|
|
67
|
-
(i, e,
|
|
67
|
+
), A = x(
|
|
68
|
+
(i, e, t) => i.map((n) => {
|
|
68
69
|
if (n.children && n.children.length > 0) {
|
|
69
70
|
const r = n.children.findIndex(
|
|
70
|
-
(
|
|
71
|
+
(o) => o.id === e
|
|
71
72
|
), c = n.children.findIndex(
|
|
72
|
-
(
|
|
73
|
+
(o) => o.id === t
|
|
73
74
|
);
|
|
74
75
|
if (r !== -1 && c !== -1) {
|
|
75
|
-
const
|
|
76
|
+
const o = w(n.children, r, c);
|
|
76
77
|
return {
|
|
77
78
|
...n,
|
|
78
|
-
children:
|
|
79
|
+
children: o
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
82
|
return {
|
|
82
83
|
...n,
|
|
83
|
-
children:
|
|
84
|
+
children: A(n.children, e, t)
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
return n;
|
|
87
88
|
}),
|
|
88
89
|
[]
|
|
89
|
-
),
|
|
90
|
-
(i, e,
|
|
91
|
-
const n =
|
|
90
|
+
), B = x(
|
|
91
|
+
(i, e, t) => {
|
|
92
|
+
const n = T(i, t);
|
|
92
93
|
if (!n) return null;
|
|
93
94
|
const r = i.findIndex(
|
|
94
|
-
(
|
|
95
|
+
(o) => o.id === n
|
|
95
96
|
), c = i.findIndex(
|
|
96
|
-
(
|
|
97
|
+
(o) => o.id === e
|
|
97
98
|
);
|
|
98
99
|
if (r !== -1 && c !== -1) {
|
|
99
|
-
const
|
|
100
|
+
const o = w(
|
|
100
101
|
i,
|
|
101
102
|
c,
|
|
102
103
|
r
|
|
103
104
|
);
|
|
104
|
-
return s?.(e, n),
|
|
105
|
+
return s?.(e, n), o;
|
|
105
106
|
}
|
|
106
107
|
return null;
|
|
107
108
|
},
|
|
108
|
-
[
|
|
109
|
-
),
|
|
110
|
-
(i, e,
|
|
111
|
-
const n = i.findIndex((c) => c.id === e), r = i.findIndex((c) => c.id ===
|
|
109
|
+
[T, s]
|
|
110
|
+
), k = x(
|
|
111
|
+
(i, e, t) => {
|
|
112
|
+
const n = i.findIndex((c) => c.id === e), r = i.findIndex((c) => c.id === t);
|
|
112
113
|
if (n !== -1 && r !== -1) {
|
|
113
|
-
const c =
|
|
114
|
-
return s?.(e,
|
|
114
|
+
const c = w(i, n, r);
|
|
115
|
+
return s?.(e, t), c;
|
|
115
116
|
}
|
|
116
117
|
return null;
|
|
117
118
|
},
|
|
118
119
|
[s]
|
|
119
|
-
),
|
|
120
|
-
(i, e,
|
|
121
|
-
const n =
|
|
122
|
-
return s?.(e,
|
|
120
|
+
), z = x(
|
|
121
|
+
(i, e, t) => {
|
|
122
|
+
const n = A(i, e, t);
|
|
123
|
+
return s?.(e, t), n;
|
|
123
124
|
},
|
|
124
|
-
[
|
|
125
|
-
),
|
|
126
|
-
(i, e,
|
|
127
|
-
const r =
|
|
125
|
+
[A, s]
|
|
126
|
+
), G = x(
|
|
127
|
+
(i, e, t, n = !1) => {
|
|
128
|
+
const r = M(i, e);
|
|
128
129
|
if (!r) return null;
|
|
129
130
|
const c = (u) => u.filter((l) => l.id !== e).map(
|
|
130
131
|
(l) => l.children ? { ...l, children: c(l.children) } : l
|
|
131
|
-
).filter((l) => !(l.children && l.children.length === 0 && l.category === "group")),
|
|
132
|
+
).filter((l) => !(l.children && l.children.length === 0 && l.category === "group")), o = M(i, t), f = !r.children || r.children.length === 0, S = o?.children && o.children.length > 0, g = d[t] === !0, _ = f && S && !g, Y = (u) => {
|
|
132
133
|
for (let l = 0; l < u.length; l++) {
|
|
133
|
-
if (u[l].id ===
|
|
134
|
-
if (
|
|
135
|
-
const
|
|
134
|
+
if (u[l].id === t)
|
|
135
|
+
if (_) {
|
|
136
|
+
const P = {
|
|
136
137
|
...u[l],
|
|
137
138
|
children: [r, ...u[l].children || []]
|
|
138
|
-
},
|
|
139
|
-
return
|
|
139
|
+
}, h = [...u];
|
|
140
|
+
return h[l] = P, { nodes: h, inserted: !0 };
|
|
140
141
|
} else {
|
|
141
|
-
const
|
|
142
|
-
return
|
|
142
|
+
const P = [...u], h = n ? l + 1 : l;
|
|
143
|
+
return P.splice(h, 0, r), { nodes: P, inserted: !0 };
|
|
143
144
|
}
|
|
144
145
|
if (u[l].children) {
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
147
|
-
const
|
|
148
|
-
return
|
|
146
|
+
const P = Y(u[l].children);
|
|
147
|
+
if (P.inserted) {
|
|
148
|
+
const h = [...u];
|
|
149
|
+
return h[l] = { ...u[l], children: P.nodes }, { nodes: h, inserted: !0 };
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
return { nodes: u, inserted: !1 };
|
|
153
|
-
},
|
|
154
|
-
return
|
|
154
|
+
}, L = c(i), { nodes: b, inserted: O } = Y(L);
|
|
155
|
+
return O ? (s?.(e, t), b) : null;
|
|
155
156
|
},
|
|
156
|
-
[s]
|
|
157
|
-
),
|
|
158
|
-
(i, e,
|
|
159
|
-
const n =
|
|
157
|
+
[s, d]
|
|
158
|
+
), N = x(
|
|
159
|
+
(i, e, t) => {
|
|
160
|
+
const n = M(i, e);
|
|
160
161
|
if (!n) return i;
|
|
161
|
-
const r = (
|
|
162
|
-
(
|
|
163
|
-
), c = i.map((
|
|
164
|
-
let
|
|
165
|
-
return
|
|
162
|
+
const r = (o) => o.filter((f) => f.id !== e).map(
|
|
163
|
+
(f) => f.children ? { ...f, children: r(f.children) } : f
|
|
164
|
+
), c = i.map((o) => {
|
|
165
|
+
let f = o.children ? r(o.children) : [];
|
|
166
|
+
return o.id === t && (f = [n, ...f]), { ...o, children: f };
|
|
166
167
|
});
|
|
167
|
-
return s?.(e,
|
|
168
|
+
return s?.(e, t), c;
|
|
168
169
|
},
|
|
169
170
|
[s]
|
|
170
|
-
),
|
|
171
|
+
), q = x(
|
|
171
172
|
(i, e) => {
|
|
172
|
-
const { active:
|
|
173
|
-
!n ||
|
|
174
|
-
const c =
|
|
175
|
-
if (
|
|
176
|
-
return
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
return
|
|
180
|
-
if (
|
|
181
|
-
return
|
|
173
|
+
const { active: t, over: n } = i;
|
|
174
|
+
!n || t.id === n.id || e((r) => {
|
|
175
|
+
const c = t.id, o = n.id, f = X(o);
|
|
176
|
+
if (f)
|
|
177
|
+
return N(r, c, f);
|
|
178
|
+
const S = C(r, c), g = C(r, o), _ = T(r, c), Y = T(r, o);
|
|
179
|
+
if (y.has(o) && S !== null && S > 0)
|
|
180
|
+
return N(r, c, o);
|
|
181
|
+
if (S === 0 && g !== null && g > 0)
|
|
182
|
+
return B(
|
|
182
183
|
r,
|
|
183
184
|
c,
|
|
184
|
-
|
|
185
|
+
o
|
|
185
186
|
) || r;
|
|
186
|
-
if (
|
|
187
|
+
if (S === null || g === null)
|
|
187
188
|
return r;
|
|
188
|
-
if (
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
191
|
-
const
|
|
192
|
-
let
|
|
193
|
-
if (
|
|
194
|
-
const
|
|
195
|
-
|
|
189
|
+
if (S > 0 && g > 0 && _ !== Y) {
|
|
190
|
+
const L = j(r, c), b = j(r, o);
|
|
191
|
+
if (L && b && L !== b) {
|
|
192
|
+
const h = t.rect.current.translated, F = n.rect;
|
|
193
|
+
let H = !1;
|
|
194
|
+
if (h && F) {
|
|
195
|
+
const J = h.top + h.height / 2, K = F.top + F.height / 2;
|
|
196
|
+
H = J > K;
|
|
196
197
|
}
|
|
197
|
-
return
|
|
198
|
+
return G(r, c, o, H) || r;
|
|
198
199
|
}
|
|
199
|
-
const
|
|
200
|
-
let
|
|
201
|
-
if (
|
|
202
|
-
const
|
|
203
|
-
|
|
200
|
+
const O = t.rect.current.translated, u = n.rect;
|
|
201
|
+
let l = !1;
|
|
202
|
+
if (O && u) {
|
|
203
|
+
const h = O.top + O.height / 2, F = u.top + u.height / 2;
|
|
204
|
+
l = h > F;
|
|
204
205
|
}
|
|
205
|
-
return
|
|
206
|
+
return G(r, c, o, l) || r;
|
|
206
207
|
}
|
|
207
|
-
return
|
|
208
|
+
return S === 0 ? k(r, c, o) || r : z(r, c, o);
|
|
208
209
|
});
|
|
209
210
|
},
|
|
210
211
|
[
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
w,
|
|
212
|
+
C,
|
|
213
|
+
T,
|
|
214
214
|
B,
|
|
215
215
|
k,
|
|
216
|
-
|
|
217
|
-
G
|
|
216
|
+
z,
|
|
217
|
+
G,
|
|
218
|
+
N
|
|
218
219
|
]
|
|
219
|
-
),
|
|
220
|
+
), D = x(
|
|
220
221
|
(i, e) => {
|
|
221
222
|
if (!i || !e || i === e)
|
|
222
223
|
return !1;
|
|
223
|
-
const
|
|
224
|
-
return
|
|
224
|
+
const t = i ? C(a, i) : null, n = e ? C(a, e) : null;
|
|
225
|
+
return X(e) !== null || y.has(e) ? !0 : t === null || n === null ? !1 : t === 0 && n > 0 || t === n || t > 0 && n > 0;
|
|
225
226
|
},
|
|
226
|
-
[a,
|
|
227
|
+
[a, C]
|
|
227
228
|
);
|
|
228
229
|
return {
|
|
229
|
-
sensors:
|
|
230
|
-
handleDragEnd:
|
|
231
|
-
isValidDrop:
|
|
232
|
-
findItemLevel:
|
|
233
|
-
findParentId:
|
|
230
|
+
sensors: R,
|
|
231
|
+
handleDragEnd: q,
|
|
232
|
+
isValidDrop: D,
|
|
233
|
+
findItemLevel: C,
|
|
234
|
+
findParentId: T
|
|
234
235
|
};
|
|
235
236
|
};
|
|
236
237
|
export {
|
|
237
|
-
|
|
238
|
-
|
|
238
|
+
I as customCollisionDetection,
|
|
239
|
+
nn as useNestedListDragDrop
|
|
239
240
|
};
|