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