impact-nova 1.7.30 → 1.7.31

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,211 +1,218 @@
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";
1
+ import { useCallback as S } from "react";
2
+ import { useSensors as Z, useSensor as V, MouseSensor as $, TouchSensor as E, closestCenter as p } from "@dnd-kit/core";
3
3
  import { arrayMove as w } from "@dnd-kit/sortable";
4
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;
5
+ function X(h) {
6
+ if (h.startsWith(W)) {
7
+ const u = h.slice(W.length);
8
+ if (y.has(u)) return u;
9
9
  }
10
10
  return null;
11
11
  }
12
- const I = (a) => {
13
- const s = $(a), d = s.filter(
14
- (R) => !y.has(R.id)
12
+ const nn = (h) => {
13
+ const u = p(h), d = u.filter(
14
+ (x) => !y.has(x.id)
15
15
  );
16
- return d.length > 0 ? d : s;
16
+ return d.length > 0 ? d : u;
17
17
  };
18
- function M(a, s) {
19
- for (const d of a) {
20
- if (d.id === s) return d;
18
+ function F(h, u) {
19
+ for (const d of h) {
20
+ if (d.id === u) return d;
21
21
  if (d.children) {
22
- const R = M(d.children, s);
23
- if (R) return R;
22
+ const x = F(d.children, u);
23
+ if (x) return x;
24
24
  }
25
25
  }
26
26
  }
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))
27
+ function j(h, u) {
28
+ for (const d of h) {
29
+ if (d.id === u) return null;
30
+ if (d.children && F(d.children, u))
31
31
  return d.id;
32
32
  }
33
33
  return null;
34
34
  }
35
- const nn = ({
36
- items: a,
37
- onDragEnd: s,
38
- collapsedItems: d = {}
35
+ const rn = ({
36
+ items: h,
37
+ onDragEnd: u,
38
+ collapsedItems: d = {},
39
+ canDrag: x
39
40
  }) => {
40
- const R = Q(
41
- V(U),
42
- V(Z)
43
- ), C = x(
44
- (i, e, t = 0) => {
45
- for (const n of i) {
46
- if (n.id === e) return t;
47
- if (n.children) {
48
- const r = C(n.children, e, t + 1);
49
- if (r !== null) return r;
41
+ const q = Z(
42
+ V($),
43
+ V(E)
44
+ ), C = S(
45
+ (t, e, o = 0) => {
46
+ for (const r of t) {
47
+ if (r.id === e) return o;
48
+ if (r.children) {
49
+ const n = C(r.children, e, o + 1);
50
+ if (n !== null) return n;
50
51
  }
51
52
  }
52
53
  return null;
53
54
  },
54
55
  []
55
- ), T = x(
56
- (i, e, t = null) => {
57
- for (const n of i) {
58
- if (n.id === e) return t;
59
- if (n.children) {
60
- const r = T(n.children, e, n.id);
61
- if (r !== null) return r;
56
+ ), T = S(
57
+ (t, e, o = null) => {
58
+ for (const r of t) {
59
+ if (r.id === e) return o;
60
+ if (r.children) {
61
+ const n = T(r.children, e, r.id);
62
+ if (n !== null) return n;
62
63
  }
63
64
  }
64
65
  return null;
65
66
  },
66
67
  []
67
- ), A = x(
68
- (i, e, t) => i.map((n) => {
69
- if (n.children && n.children.length > 0) {
70
- const r = n.children.findIndex(
71
- (o) => o.id === e
72
- ), c = n.children.findIndex(
73
- (o) => o.id === t
68
+ ), A = S(
69
+ (t, e, o) => t.map((r) => {
70
+ if (r.children && r.children.length > 0) {
71
+ const n = r.children.findIndex(
72
+ (i) => i.id === e
73
+ ), l = r.children.findIndex(
74
+ (i) => i.id === o
74
75
  );
75
- if (r !== -1 && c !== -1) {
76
- const o = w(n.children, r, c);
76
+ if (n !== -1 && l !== -1) {
77
+ const i = w(r.children, n, l);
77
78
  return {
78
- ...n,
79
- children: o
79
+ ...r,
80
+ children: i
80
81
  };
81
82
  }
82
83
  return {
83
- ...n,
84
- children: A(n.children, e, t)
84
+ ...r,
85
+ children: A(r.children, e, o)
85
86
  };
86
87
  }
87
- return n;
88
+ return r;
88
89
  }),
89
90
  []
90
- ), B = x(
91
- (i, e, t) => {
92
- const n = T(i, t);
93
- if (!n) return null;
94
- const r = i.findIndex(
95
- (o) => o.id === n
96
- ), c = i.findIndex(
97
- (o) => o.id === e
91
+ ), B = S(
92
+ (t, e, o) => {
93
+ const r = T(t, o);
94
+ if (!r) return null;
95
+ const n = t.findIndex(
96
+ (i) => i.id === r
97
+ ), l = t.findIndex(
98
+ (i) => i.id === e
98
99
  );
99
- if (r !== -1 && c !== -1) {
100
- const o = w(
101
- i,
102
- c,
103
- r
100
+ if (n !== -1 && l !== -1) {
101
+ const i = w(
102
+ t,
103
+ l,
104
+ n
104
105
  );
105
- return s?.(e, n), o;
106
+ return u?.(e, r), i;
106
107
  }
107
108
  return null;
108
109
  },
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);
113
- if (n !== -1 && r !== -1) {
114
- const c = w(i, n, r);
115
- return s?.(e, t), c;
110
+ [T, u]
111
+ ), k = S(
112
+ (t, e, o) => {
113
+ const r = t.findIndex((l) => l.id === e), n = t.findIndex((l) => l.id === o);
114
+ if (r !== -1 && n !== -1) {
115
+ const l = w(t, r, n);
116
+ return u?.(e, o), l;
116
117
  }
117
118
  return null;
118
119
  },
119
- [s]
120
- ), z = x(
121
- (i, e, t) => {
122
- const n = A(i, e, t);
123
- return s?.(e, t), n;
120
+ [u]
121
+ ), z = S(
122
+ (t, e, o) => {
123
+ const r = A(t, e, o);
124
+ return u?.(e, o), r;
124
125
  },
125
- [A, s]
126
- ), G = x(
127
- (i, e, t, n = !1) => {
128
- const r = M(i, e);
129
- if (!r) return null;
130
- const c = (u) => u.filter((l) => l.id !== e).map(
131
- (l) => l.children ? { ...l, children: c(l.children) } : l
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) => {
133
- for (let l = 0; l < u.length; l++) {
134
- if (u[l].id === t)
126
+ [A, u]
127
+ ), G = S(
128
+ (t, e, o, r = !1) => {
129
+ const n = F(t, e);
130
+ if (!n) return null;
131
+ const l = (s) => s.filter((c) => c.id !== e).map(
132
+ (c) => c.children ? { ...c, children: l(c.children) } : c
133
+ ).filter((c) => !(c.children && c.children.length === 0 && c.category === "group")), i = F(t, o), f = !n.children || n.children.length === 0, R = i?.children && i.children.length > 0, M = d[o] === !0, _ = f && R && !M, g = (s) => {
134
+ for (let c = 0; c < s.length; c++) {
135
+ if (s[c].id === o)
135
136
  if (_) {
136
- const P = {
137
- ...u[l],
138
- children: [r, ...u[l].children || []]
139
- }, h = [...u];
140
- return h[l] = P, { nodes: h, inserted: !0 };
137
+ const L = {
138
+ ...s[c],
139
+ children: [n, ...s[c].children || []]
140
+ }, a = [...s];
141
+ return a[c] = L, { nodes: a, inserted: !0 };
141
142
  } else {
142
- const P = [...u], h = n ? l + 1 : l;
143
- return P.splice(h, 0, r), { nodes: P, inserted: !0 };
143
+ const L = [...s], a = r ? c + 1 : c;
144
+ return L.splice(a, 0, n), { nodes: L, inserted: !0 };
144
145
  }
145
- if (u[l].children) {
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 };
146
+ if (s[c].children) {
147
+ const L = g(s[c].children);
148
+ if (L.inserted) {
149
+ const a = [...s];
150
+ return a[c] = { ...s[c], children: L.nodes }, { nodes: a, inserted: !0 };
150
151
  }
151
152
  }
152
153
  }
153
- return { nodes: u, inserted: !1 };
154
- }, L = c(i), { nodes: b, inserted: O } = Y(L);
155
- return O ? (s?.(e, t), b) : null;
154
+ return { nodes: s, inserted: !1 };
155
+ }, P = l(t), { nodes: O, inserted: Y } = g(P);
156
+ return Y ? (u?.(e, o), O) : null;
156
157
  },
157
- [s, d]
158
- ), N = x(
159
- (i, e, t) => {
160
- const n = M(i, e);
161
- if (!n) return i;
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 };
158
+ [u, d]
159
+ ), N = S(
160
+ (t, e, o) => {
161
+ const r = F(t, e);
162
+ if (!r) return t;
163
+ const n = (i) => i.filter((f) => f.id !== e).map(
164
+ (f) => f.children ? { ...f, children: n(f.children) } : f
165
+ ), l = t.map((i) => {
166
+ let f = i.children ? n(i.children) : [];
167
+ return i.id === o && (f = [r, ...f]), { ...i, children: f };
167
168
  });
168
- return s?.(e, t), c;
169
+ return u?.(e, o), l;
169
170
  },
170
- [s]
171
- ), q = x(
172
- (i, e) => {
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);
171
+ [u]
172
+ ), J = S(
173
+ (t, e) => {
174
+ const { active: o, over: r } = t;
175
+ !r || o.id === r.id || e((n) => {
176
+ const l = o.id, i = r.id;
177
+ if (x) {
178
+ const P = F(n, l), O = C(n, l);
179
+ if (P && O !== null && !x(P, O))
180
+ return n;
181
+ }
182
+ const f = X(i);
176
183
  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)
184
+ return N(n, l, f);
185
+ const R = C(n, l), M = C(n, i), _ = T(n, l), g = T(n, i);
186
+ if (y.has(i) && R !== null && R > 0)
187
+ return N(n, l, i);
188
+ if (R === 0 && M !== null && M > 0)
182
189
  return B(
183
- r,
184
- c,
185
- o
186
- ) || r;
187
- if (S === null || g === null)
188
- return r;
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;
190
+ n,
191
+ l,
192
+ i
193
+ ) || n;
194
+ if (R === null || M === null)
195
+ return n;
196
+ if (R > 0 && M > 0 && _ !== g) {
197
+ const P = j(n, l), O = j(n, i);
198
+ if (P && O && P !== O) {
199
+ const a = o.rect.current.translated, b = r.rect;
193
200
  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;
201
+ if (a && b) {
202
+ const Q = a.top + a.height / 2, U = b.top + b.height / 2;
203
+ H = Q > U;
197
204
  }
198
- return G(r, c, o, H) || r;
205
+ return G(n, l, i, H) || n;
199
206
  }
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;
207
+ const Y = o.rect.current.translated, s = r.rect;
208
+ let c = !1;
209
+ if (Y && s) {
210
+ const a = Y.top + Y.height / 2, b = s.top + s.height / 2;
211
+ c = a > b;
205
212
  }
206
- return G(r, c, o, l) || r;
213
+ return G(n, l, i, c) || n;
207
214
  }
208
- return S === 0 ? k(r, c, o) || r : z(r, c, o);
215
+ return R === 0 ? k(n, l, i) || n : z(n, l, i);
209
216
  });
210
217
  },
211
218
  [
@@ -215,26 +222,32 @@ const nn = ({
215
222
  k,
216
223
  z,
217
224
  G,
218
- N
225
+ N,
226
+ x
219
227
  ]
220
- ), D = x(
221
- (i, e) => {
222
- if (!i || !e || i === e)
228
+ ), K = S(
229
+ (t, e) => {
230
+ if (!t || !e || t === e)
223
231
  return !1;
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;
232
+ if (x) {
233
+ const n = F(h, t), l = C(h, t);
234
+ if (n && l !== null && !x(n, l))
235
+ return !1;
236
+ }
237
+ const o = t ? C(h, t) : null, r = e ? C(h, e) : null;
238
+ return X(e) !== null || y.has(e) ? !0 : o === null || r === null ? !1 : o === 0 && r > 0 || o === r || o > 0 && r > 0;
226
239
  },
227
- [a, C]
240
+ [h, C, x]
228
241
  );
229
242
  return {
230
- sensors: R,
231
- handleDragEnd: q,
232
- isValidDrop: D,
243
+ sensors: q,
244
+ handleDragEnd: J,
245
+ isValidDrop: K,
233
246
  findItemLevel: C,
234
247
  findParentId: T
235
248
  };
236
249
  };
237
250
  export {
238
- I as customCollisionDetection,
239
- nn as useNestedListDragDrop
251
+ nn as customCollisionDetection,
252
+ rn as useNestedListDragDrop
240
253
  };