impact-nova 1.7.21 → 1.7.23

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.
@@ -1,37 +1,37 @@
1
- import { useCallback as a } from "react";
2
- import { useSensors as W, useSensor as F, MouseSensor as X, TouchSensor as j, closestCorners as q } from "@dnd-kit/core";
3
- import { arrayMove as M } from "@dnd-kit/sortable";
4
- const Y = "droppable-", L = /* @__PURE__ */ new Set(["root-frozen", "root-scrollable"]);
5
- function g(f) {
6
- if (f.startsWith(Y)) {
7
- const c = f.slice(Y.length);
8
- if (L.has(c)) return c;
1
+ import { useCallback as h } from "react";
2
+ import { useSensors as W, useSensor as A, MouseSensor as X, TouchSensor as j, closestCorners as q } from "@dnd-kit/core";
3
+ import { arrayMove as w } from "@dnd-kit/sortable";
4
+ const B = "droppable-", O = /* @__PURE__ */ new Set(["root-frozen", "root-scrollable"]);
5
+ function Y(f) {
6
+ if (f.startsWith(B)) {
7
+ const c = f.slice(B.length);
8
+ if (O.has(c)) return c;
9
9
  }
10
10
  return null;
11
11
  }
12
- const Q = (f) => {
13
- const c = q(f), x = c.filter(
14
- (s) => !L.has(s.id)
12
+ const K = (f) => {
13
+ const c = q(f), a = c.filter(
14
+ (s) => !O.has(s.id)
15
15
  );
16
- return x.length > 0 ? x : c;
16
+ return a.length > 0 ? a : c;
17
17
  };
18
- function b(f, c) {
19
- for (const x of f) {
20
- if (x.id === c) return x;
21
- if (x.children) {
22
- const s = b(x.children, c);
18
+ function F(f, c) {
19
+ for (const a of f) {
20
+ if (a.id === c) return a;
21
+ if (a.children) {
22
+ const s = F(a.children, c);
23
23
  if (s) return s;
24
24
  }
25
25
  }
26
26
  }
27
- const U = ({
27
+ const Q = ({
28
28
  items: f,
29
29
  onDragEnd: c
30
30
  }) => {
31
- const x = W(
32
- F(X),
33
- F(j)
34
- ), s = a(
31
+ const a = W(
32
+ A(X),
33
+ A(j)
34
+ ), s = h(
35
35
  (t, r, o = 0) => {
36
36
  for (const n of t) {
37
37
  if (n.id === r) return o;
@@ -43,19 +43,19 @@ const U = ({
43
43
  return null;
44
44
  },
45
45
  []
46
- ), h = a(
46
+ ), S = h(
47
47
  (t, r, o = null) => {
48
48
  for (const n of t) {
49
49
  if (n.id === r) return o;
50
50
  if (n.children) {
51
- const e = h(n.children, r, n.id);
51
+ const e = S(n.children, r, n.id);
52
52
  if (e !== null) return e;
53
53
  }
54
54
  }
55
55
  return null;
56
56
  },
57
57
  []
58
- ), T = a(
58
+ ), M = h(
59
59
  (t, r, o) => t.map((n) => {
60
60
  if (n.children && n.children.length > 0) {
61
61
  const e = n.children.findIndex(
@@ -64,7 +64,7 @@ const U = ({
64
64
  (l) => l.id === o
65
65
  );
66
66
  if (e !== -1 && i !== -1) {
67
- const l = M(n.children, e, i);
67
+ const l = w(n.children, e, i);
68
68
  return {
69
69
  ...n,
70
70
  children: l
@@ -72,15 +72,15 @@ const U = ({
72
72
  }
73
73
  return {
74
74
  ...n,
75
- children: T(n.children, r, o)
75
+ children: M(n.children, r, o)
76
76
  };
77
77
  }
78
78
  return n;
79
79
  }),
80
80
  []
81
- ), N = a(
81
+ ), _ = h(
82
82
  (t, r, o) => {
83
- const n = h(t, o);
83
+ const n = S(t, o);
84
84
  if (!n) return null;
85
85
  const e = t.findIndex(
86
86
  (l) => l.id === n
@@ -88,7 +88,7 @@ const U = ({
88
88
  (l) => l.id === r
89
89
  );
90
90
  if (e !== -1 && i !== -1) {
91
- const l = M(
91
+ const l = w(
92
92
  t,
93
93
  i,
94
94
  e
@@ -97,122 +97,120 @@ const U = ({
97
97
  }
98
98
  return null;
99
99
  },
100
- [h, c]
101
- ), _ = a(
100
+ [S, c]
101
+ ), g = h(
102
102
  (t, r, o) => {
103
103
  const n = t.findIndex((i) => i.id === r), e = t.findIndex((i) => i.id === o);
104
104
  if (n !== -1 && e !== -1) {
105
- const i = M(t, n, e);
105
+ const i = w(t, n, e);
106
106
  return c?.(r, o), i;
107
107
  }
108
108
  return null;
109
109
  },
110
110
  [c]
111
- ), y = a(
111
+ ), p = h(
112
112
  (t, r, o) => {
113
- const n = T(t, r, o);
113
+ const n = M(t, r, o);
114
114
  return c?.(r, o), n;
115
115
  },
116
- [T, c]
117
- ), A = a(
116
+ [M, c]
117
+ ), y = h(
118
118
  (t, r, o, n = !1) => {
119
- const e = h(t, r), i = h(t, o);
120
- if (!e || !i) return null;
121
- const l = b(t, r);
122
- if (!l) return null;
123
- const P = t.map((u) => {
124
- if (u.id === e)
125
- return {
126
- ...u,
127
- children: u.children ? u.children.filter((d) => d.id !== r) : []
128
- };
129
- if (u.id === i) {
130
- const d = u.children ? [...u.children] : [], C = d.findIndex(
131
- (S) => S.id === o
132
- );
133
- if (C !== -1) {
134
- const S = n ? C + 1 : C;
135
- d.splice(S, 0, l);
136
- } else
137
- d.push(l);
138
- return {
139
- ...u,
140
- children: d
141
- };
119
+ const e = F(t, r);
120
+ if (!e) return null;
121
+ const i = (C) => C.filter((u) => u.id !== r).map(
122
+ (u) => u.children ? { ...u, children: i(u.children) } : u
123
+ ), l = (C) => {
124
+ const u = C.findIndex((d) => d.id === o);
125
+ if (u !== -1) {
126
+ const d = [...C], T = n ? u + 1 : u;
127
+ return d.splice(T, 0, e), { nodes: d, inserted: !0 };
142
128
  }
143
- return u;
144
- });
145
- return c?.(r, o), P;
129
+ let P = !1;
130
+ return { nodes: C.map((d) => {
131
+ if (P || !d.children) return d;
132
+ const T = l(d.children);
133
+ return T.inserted ? (P = !0, { ...d, children: T.nodes }) : d;
134
+ }), inserted: P };
135
+ }, L = i(t), { nodes: x, inserted: R } = l(L);
136
+ return R ? (c?.(r, o), x) : null;
146
137
  },
147
- [h, c]
148
- ), O = a(
138
+ [c]
139
+ ), b = h(
149
140
  (t, r, o) => {
150
- const n = b(t, r);
141
+ const n = F(t, r);
151
142
  if (!n) return t;
152
143
  const e = t.map((i) => {
153
- let l = i.children ? i.children.filter((P) => P.id !== r) : [];
144
+ let l = i.children ? i.children.filter((L) => L.id !== r) : [];
154
145
  return i.id === o && (l = [n, ...l]), { ...i, children: l };
155
146
  });
156
147
  return c?.(r, o), e;
157
148
  },
158
149
  [c]
159
- ), k = a(
150
+ ), k = h(
160
151
  (t, r) => {
161
152
  const { active: o, over: n } = t;
162
153
  !n || o.id === n.id || r((e) => {
163
- const i = o.id, l = n.id, P = g(l);
164
- if (P)
165
- return O(e, i, P);
166
- const u = s(e, i), d = s(e, l), C = h(e, i), S = h(e, l);
167
- if (L.has(l) && u !== null && u > 0)
168
- return O(e, i, l);
169
- if (u === 0 && d !== null && d > 0)
170
- return N(
154
+ const i = o.id, l = n.id, L = Y(l);
155
+ if (L)
156
+ return console.log("[NL-drop] route=section", { activeId: i, sectionId: L }), b(e, i, L);
157
+ const x = s(e, i), R = s(e, l), C = S(e, i), u = S(e, l);
158
+ if (console.log("[NL-drop] event", {
159
+ activeId: i,
160
+ overId: l,
161
+ activeLevel: x,
162
+ overLevel: R,
163
+ activeParentId: C,
164
+ overParentId: u
165
+ }), O.has(l) && x !== null && x > 0)
166
+ return b(e, i, l);
167
+ if (x === 0 && R !== null && R > 0)
168
+ return _(
171
169
  e,
172
170
  i,
173
171
  l
174
172
  ) || e;
175
- if (u === null || d === null || u !== d)
173
+ if (x === null || R === null)
176
174
  return e;
177
- if (u > 0 && C !== S) {
178
- const R = o.rect.current.translated, w = n.rect;
179
- let B = !1;
180
- if (R && w) {
181
- const H = R.top + R.height / 2, V = w.top + w.height / 2;
182
- B = H > V;
175
+ if (x > 0 && R > 0 && C !== u) {
176
+ const P = o.rect.current.translated, N = n.rect;
177
+ let d = !1;
178
+ if (P && N) {
179
+ const H = P.top + P.height / 2, V = N.top + N.height / 2;
180
+ d = H > V;
183
181
  }
184
- return A(e, i, l, B) || e;
182
+ return y(e, i, l, d) || e;
185
183
  }
186
- return u === 0 ? _(e, i, l) || e : y(e, i, l);
184
+ return x === 0 ? g(e, i, l) || e : p(e, i, l);
187
185
  });
188
186
  },
189
187
  [
190
188
  s,
191
- h,
192
- N,
189
+ S,
193
190
  _,
191
+ g,
192
+ p,
194
193
  y,
195
- A,
196
- O
194
+ b
197
195
  ]
198
- ), z = a(
196
+ ), z = h(
199
197
  (t, r) => {
200
198
  if (!t || !r || t === r)
201
199
  return !1;
202
200
  const o = t ? s(f, t) : null, n = r ? s(f, r) : null;
203
- return g(r) !== null || L.has(r) ? !0 : o === null || n === null ? !1 : o === 0 && n > 0 || o === n;
201
+ return Y(r) !== null || O.has(r) ? !0 : o === null || n === null ? !1 : o === 0 && n > 0 || o === n || o > 0 && n > 0;
204
202
  },
205
203
  [f, s]
206
204
  );
207
205
  return {
208
- sensors: x,
206
+ sensors: a,
209
207
  handleDragEnd: k,
210
208
  isValidDrop: z,
211
209
  findItemLevel: s,
212
- findParentId: h
210
+ findParentId: S
213
211
  };
214
212
  };
215
213
  export {
216
- Q as customCollisionDetection,
217
- U as useNestedListDragDrop
214
+ K as customCollisionDetection,
215
+ Q as useNestedListDragDrop
218
216
  };