impact-nova 2.4.0 → 2.5.0

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,31 +1,31 @@
1
- import { jsx as S, jsxs as de } from "react/jsx-runtime";
2
- import Q, { useMemo as T, useCallback as w } from "react";
3
- import { SortableItem as Je } from "./components/SortableItem.js";
1
+ import { jsx as S, jsxs as ie } from "react/jsx-runtime";
2
+ import X, { useMemo as T, useCallback as A } from "react";
3
+ import { SortableItem as Ke } from "./components/SortableItem.js";
4
4
  import { SelectionMode as _ } from "./nested-list.types.js";
5
- import { useNestedListDragDrop as Ke } from "./hooks/useNestedListDragDrop.js";
6
- import { useNestedListSelectAll as Qe } from "./hooks/useNestedListSelectAll.js";
7
- import { useNestedListState as Xe } from "./hooks/useNestedListState.js";
8
- import { useNestedListHandlers as Ye } from "./hooks/useNestedListHandlers.js";
9
- import { NestedListHeader as Ze } from "./components/NestedListHeader.js";
10
- import { NestedListCategoryFilters as $e } from "./components/NestedListCategoryFilters.js";
11
- import { NestedListContent as Me } from "./components/NestedListContent.js";
12
- import { NestedListApplyDiscardButtons as Ge } from "./components/NestedListApplyDiscardButtons.js";
13
- import { shouldUseNestedListRevisionTracking as et, computeNestedListHasChanges as tt } from "./nested-list-change-detection.js";
14
- import { cn as st } from "../../../lib/utils.js";
15
- import { useImpactNovaI18n as rt } from "../../../i18n/use-impact-nova-i18n.js";
16
- const ie = (a, t) => {
17
- if (!t || typeof t != "string") return a;
5
+ import { useNestedListDragDrop as Qe } from "./hooks/useNestedListDragDrop.js";
6
+ import { useNestedListSelectAll as Xe } from "./hooks/useNestedListSelectAll.js";
7
+ import { useNestedListState as Ye } from "./hooks/useNestedListState.js";
8
+ import { useNestedListHandlers as Ze } from "./hooks/useNestedListHandlers.js";
9
+ import { NestedListHeader as $e } from "./components/NestedListHeader.js";
10
+ import { NestedListCategoryFilters as Me } from "./components/NestedListCategoryFilters.js";
11
+ import { NestedListContent as Ge } from "./components/NestedListContent.js";
12
+ import { NestedListApplyDiscardButtons as et } from "./components/NestedListApplyDiscardButtons.js";
13
+ import { shouldUseNestedListRevisionTracking as tt, computeNestedListHasChanges as st } from "./nested-list-change-detection.js";
14
+ import { cn as rt } from "../../../lib/utils.js";
15
+ import { useImpactNovaI18n as nt } from "../../../i18n/use-impact-nova-i18n.js";
16
+ const ae = (i, t) => {
17
+ if (!t || typeof t != "string") return i;
18
18
  const o = t.toLowerCase(), c = [];
19
- return a.forEach((n) => {
20
- const i = n.label.toLowerCase().includes(o), l = n.children ? ie(n.children, t) : void 0;
21
- (i || l && l.length > 0) && c.push({
19
+ return i.forEach((n) => {
20
+ const d = n.label.toLowerCase().includes(o), l = n.children ? ae(n.children, t) : void 0;
21
+ (d || l && l.length > 0) && c.push({
22
22
  ...n,
23
23
  children: l || n.children
24
24
  });
25
25
  }), c;
26
- }, ae = (a) => a.map((t) => {
26
+ }, he = (i) => i.map((t) => {
27
27
  if (t.children && t.children.length > 0) {
28
- const o = ae(t.children), c = o.every((n) => n.checked);
28
+ const o = he(t.children), c = o.every((n) => n.checked);
29
29
  return {
30
30
  ...t,
31
31
  checked: c,
@@ -33,35 +33,35 @@ const ie = (a, t) => {
33
33
  };
34
34
  }
35
35
  return t;
36
- }), nt = (a, t) => {
36
+ }), lt = (i, t) => {
37
37
  const o = /* @__PURE__ */ new Set(), c = (n) => {
38
- n.forEach((i) => {
39
- const l = t ? t(i) : i.category;
40
- l && o.add(l), i.children && c(i.children);
38
+ n.forEach((d) => {
39
+ const l = t ? t(d) : d.category;
40
+ l && o.add(l), d.children && c(d.children);
41
41
  });
42
42
  };
43
- return c(a), Array.from(o).sort();
44
- }, he = (a, t, o) => {
45
- if (t.size === 0) return a;
43
+ return c(i), Array.from(o).sort();
44
+ }, ue = (i, t, o) => {
45
+ if (t.size === 0) return i;
46
46
  const c = [];
47
- return a.forEach((n) => {
48
- const i = o ? o(n) : n.category, l = i && t.has(i), m = n.children ? he(n.children, t, o) : void 0;
47
+ return i.forEach((n) => {
48
+ const d = o ? o(n) : n.category, l = d && t.has(d), m = n.children ? ue(n.children, t, o) : void 0;
49
49
  (l || m && m.length > 0) && c.push({
50
50
  ...n,
51
51
  children: m
52
52
  });
53
53
  }), c;
54
- }, ue = (a, t, o, c = 0, n = 0) => {
55
- const i = [];
56
- return a.forEach((l) => {
57
- if (i.push({
54
+ }, fe = (i, t, o, c = 0, n = 0) => {
55
+ const d = [];
56
+ return i.forEach((l) => {
57
+ if (d.push({
58
58
  item: l,
59
59
  level: c,
60
60
  indentLevel: l.category === "structure" ? 0 : n
61
61
  }), !t[l.id] && l.children && l.children.length > 0 && l.id !== o) {
62
62
  const y = l.category === "structure" ? 0 : n + 1;
63
- i.push(
64
- ...ue(
63
+ d.push(
64
+ ...fe(
65
65
  l.children,
66
66
  t,
67
67
  o,
@@ -70,216 +70,214 @@ const ie = (a, t) => {
70
70
  )
71
71
  );
72
72
  }
73
- }), i;
74
- }, Lt = ({
75
- items: a,
73
+ }), d;
74
+ }, St = ({
75
+ items: i,
76
76
  onChange: t,
77
77
  onSubmit: o,
78
78
  onCancel: c,
79
79
  onItemToggle: n,
80
- onDragEnd: i,
80
+ onDragEnd: d,
81
81
  renderLabelExtras: l,
82
82
  renderActions: m,
83
83
  enableSearch: y = !0,
84
84
  enableDragDrop: H = !0,
85
- enableSelectAll: fe = !0,
85
+ enableSelectAll: pe = !0,
86
86
  enableGroupBy: g = !1,
87
- getCategory: N,
88
- searchPlaceholder: pe,
89
- className: me = "",
90
- groupLabel: Ce,
87
+ getCategory: C,
88
+ searchPlaceholder: me,
89
+ className: Ie = "",
90
+ groupLabel: ve,
91
91
  enableApplyDiscard: p = !1,
92
- enableCollapse: X = !0,
93
- enableGlobalCollapse: Ie = !0,
92
+ enableCollapse: Y = !0,
93
+ enableGlobalCollapse: Ce = !0,
94
94
  submitButtonLabel: Ne,
95
- cancelButtonLabel: ve,
96
- selectionMode: v = _.CASCADE_DOWN,
97
- initialCollapsedItems: Le,
98
- onCollapseChange: Y,
99
- canDrag: A
95
+ cancelButtonLabel: Le,
96
+ selectionMode: N = _.CASCADE_DOWN,
97
+ initialCollapsedItems: Se,
98
+ onCollapseChange: Z,
99
+ canDrag: w
100
100
  }) => {
101
- const { t: P } = rt(), Se = pe ?? P("nestedList.searchPlaceholder"), ge = Ne ?? P("nestedList.apply"), ke = ve ?? P("nestedList.reset"), {
101
+ const { t: P } = nt(), ge = me ?? P("nestedList.searchPlaceholder"), ke = Ne ?? P("nestedList.apply"), Ee = Le ?? P("nestedList.reset"), {
102
102
  items: h,
103
103
  setItems: L,
104
- savedItems: b,
105
- setSavedItems: Z,
106
- isUserChangeRef: R,
107
- searchText: x,
108
- setSearchText: Ee,
109
- collapsedItems: C,
110
- setCollapsedItems: De,
104
+ itemsRef: O,
105
+ savedItems: x,
106
+ setSavedItems: $,
107
+ markUserChange: R,
108
+ searchText: b,
109
+ setSearchText: De,
110
+ collapsedItems: I,
111
+ setCollapsedItems: Te,
111
112
  isListCollapsed: z,
112
- setIsListCollapsed: Te,
113
- activeId: I,
114
- setActiveId: O,
115
- setOverId: W,
113
+ setIsListCollapsed: Ae,
114
+ activeId: v,
115
+ setActiveId: W,
116
+ setOverId: j,
116
117
  selectedCategories: B,
117
118
  setSelectedCategories: we,
118
- itemsToBlink: $,
119
- setItemsToBlink: j,
119
+ itemsToBlink: M,
120
+ setItemsToBlink: F,
120
121
  // Normalized state helpers (for optimized operations)
121
- isNormalized: Ae,
122
- normalizedState: Pe,
123
- batchUpdateItems: be
124
- } = Xe({
125
- initialItems: a,
122
+ isNormalized: Pe,
123
+ normalizedState: xe,
124
+ batchUpdateItems: Re
125
+ } = Ye({
126
+ initialItems: i,
126
127
  enableApplyDiscard: p,
127
128
  // Enable normalized state for large datasets (can be made configurable via props)
128
- enableNormalizedState: et(a.length),
129
- initialCollapsedItems: Le
129
+ enableNormalizedState: tt(i.length),
130
+ initialCollapsedItems: Se
130
131
  });
131
- Q.useEffect(() => {
132
- Y?.(C);
133
- }, [C, Y]);
134
- const [U, M] = Q.useState(0), [V, Re] = Q.useState(0), {
135
- sensors: xe,
136
- handleDragEnd: ze,
137
- isValidDrop: G
138
- } = Ke({
132
+ X.useEffect(() => {
133
+ Z?.(I);
134
+ }, [I, Z]);
135
+ const [V, G] = X.useState(0), [U, be] = X.useState(0), {
136
+ sensors: ze,
137
+ handleDragEnd: Be,
138
+ isValidDrop: ee
139
+ } = Qe({
139
140
  items: h,
140
- onDragEnd: i,
141
- collapsedItems: C,
142
- canDrag: A
143
- }), Be = T(
144
- () => g ? nt(h, N) : [],
145
- [h, g, N]
141
+ onDragEnd: d,
142
+ collapsedItems: I,
143
+ canDrag: w
144
+ }), Ve = T(
145
+ () => g ? lt(h, C) : [],
146
+ [h, g, C]
146
147
  ), k = T(() => {
147
148
  let e = h;
148
- return g && B.size > 0 && (e = he(e, B, N)), x && (e = ie(e, x)), e;
149
- }, [h, x, g, B, N]), F = T(
150
- () => ue(k, C, I),
151
- [k, C, I]
149
+ return g && B.size > 0 && (e = ue(e, B, C)), b && (e = ae(e, b)), e;
150
+ }, [h, b, g, B, C]), q = T(
151
+ () => fe(k, I, v),
152
+ [k, I, v]
152
153
  ), { allChecked: E, someChecked: Ue } = T(() => {
153
154
  let e = !0, s = !1;
154
- for (const { item: r } of F)
155
+ for (const { item: r } of q)
155
156
  if (!(!(!r.children || r.children.length === 0) || r.category === "structure") && (r.checked ? s = !0 : e = !1, s && !e))
156
157
  break;
157
158
  return { allChecked: e && s, someChecked: s };
158
- }, [F]), Ve = Ue && !E, q = (e, s) => {
159
+ }, [q]), _e = Ue && !E, J = (e, s) => {
159
160
  for (const r of e) {
160
161
  if (r.id === s) return r;
161
162
  if (r.children) {
162
- const u = q(r.children, s);
163
+ const u = J(r.children, s);
163
164
  if (u) return u;
164
165
  }
165
166
  }
166
167
  return null;
167
- }, _e = w(
168
+ }, ye = A(
168
169
  (e, s) => {
169
- if (v === _.INDEPENDENT)
170
+ if (N === _.INDEPENDENT)
170
171
  return e;
171
- const r = (f, d) => f.id === d ? !0 : f.children ? f.children.some(
172
- (D) => r(D, d)
173
- ) : !1, u = (f) => f.map((d) => {
174
- if (d.id === s)
175
- return d;
176
- if (d.children && r(d, s)) {
177
- const D = u(d.children);
178
- let J;
179
- return v === _.CASCADE_UP_DOWN ? J = D.some((K) => K.checked) : J = D.every((K) => K.checked), {
180
- ...d,
181
- checked: J,
172
+ const r = (f, a) => f.id === a ? !0 : f.children ? f.children.some(
173
+ (D) => r(D, a)
174
+ ) : !1, u = (f) => f.map((a) => {
175
+ if (a.id === s)
176
+ return a;
177
+ if (a.children && r(a, s)) {
178
+ const D = u(a.children);
179
+ let K;
180
+ return N === _.CASCADE_UP_DOWN ? K = D.some((Q) => Q.checked) : K = D.every((Q) => Q.checked), {
181
+ ...a,
182
+ checked: K,
182
183
  children: D
183
184
  };
184
185
  }
185
- return d;
186
+ return a;
186
187
  });
187
188
  return u(e);
188
189
  },
189
- [v]
190
- ), ee = (e) => {
190
+ [N]
191
+ ), te = (e) => {
191
192
  const s = [];
192
193
  return e.forEach((r) => {
193
- r.children && r.children.length > 0 && (s.push(r.id), s.push(...ee(r.children)));
194
+ r.children && r.children.length > 0 && (s.push(r.id), s.push(...te(r.children)));
194
195
  }), s;
195
196
  }, {
196
- handleToggle: te,
197
- handleToggleCollapse: se,
198
- handleCollapseAll: ye,
199
- handleToggleCategory: He
200
- } = Ye({
197
+ handleToggle: se,
198
+ handleToggleCollapse: re,
199
+ handleCollapseAll: He,
200
+ handleToggleCategory: Oe
201
+ } = Ze({
201
202
  setItems: L,
202
- findItemById: q,
203
- updateParentsUpward: _e,
203
+ itemsRef: O,
204
+ findItemById: J,
205
+ updateParentsUpward: ye,
204
206
  onChange: (e) => {
205
- M((s) => s + 1), t(e);
207
+ G((s) => s + 1), t(e);
206
208
  },
207
209
  onItemToggle: n,
208
- getCategory: N,
209
- setCollapsedItems: De,
210
- setIsListCollapsed: Te,
210
+ getCategory: C,
211
+ setCollapsedItems: Te,
212
+ setIsListCollapsed: Ae,
211
213
  setSelectedCategories: we,
212
- isUserChangeRef: R,
213
- selectionMode: v,
214
+ markUserChange: R,
215
+ selectionMode: N,
214
216
  // Pass normalized state helpers for optimized operations
215
- isNormalized: Ae,
216
- normalizedState: Pe,
217
- batchUpdateItems: be
217
+ isNormalized: Pe,
218
+ normalizedState: xe,
219
+ batchUpdateItems: Re
218
220
  }), {
219
- collectVisibleItemIds: re,
220
- findItemsNotSelected: ne,
221
- collectVisibleItemsForCallback: le,
222
- updateVisibleItems: oe
223
- } = Qe({
224
- findItemById: q,
225
- getCategory: N
226
- }), Oe = w(() => {
227
- R.current = !0, L((e) => {
228
- const s = re(k), r = ne(
229
- k,
230
- e,
231
- s
232
- );
233
- if (r.size > 0) {
234
- const d = new Set(r);
235
- j(d), setTimeout(() => j(/* @__PURE__ */ new Set()), 600);
236
- }
237
- const u = oe(
221
+ collectVisibleItemIds: ne,
222
+ findItemsNotSelected: le,
223
+ collectVisibleItemsForCallback: oe,
224
+ updateVisibleItems: ce
225
+ } = Xe({
226
+ findItemById: J,
227
+ getCategory: C
228
+ }), We = A(() => {
229
+ R();
230
+ const e = O.current, s = ne(k), r = le(
231
+ k,
232
+ e,
233
+ s
234
+ );
235
+ r.size > 0 && (F(new Set(r)), setTimeout(() => F(/* @__PURE__ */ new Set()), 600));
236
+ const u = ce(
237
+ e,
238
+ s,
239
+ !E
240
+ ), f = N === _.INDEPENDENT ? u : he(u);
241
+ if (L(f), t(f), n) {
242
+ const a = oe(
238
243
  e,
239
244
  s,
240
245
  !E
241
- ), f = v === _.INDEPENDENT ? u : ae(u);
242
- if (t(f), n) {
243
- const d = le(
244
- e,
245
- s,
246
- !E
247
- );
248
- n(d);
249
- }
250
- return f;
251
- });
246
+ );
247
+ n(a);
248
+ }
252
249
  }, [
253
250
  E,
254
251
  t,
255
252
  n,
256
253
  k,
257
- re,
258
254
  ne,
259
255
  le,
260
256
  oe,
257
+ ce,
261
258
  R,
259
+ O,
262
260
  L,
263
- j,
264
- v
265
- ]), We = w(
261
+ F,
262
+ N
263
+ ]), je = A(
266
264
  (e, s, r) => {
267
- const u = I ? G(I, e.id) : !1, f = $.has(e.id), d = A ? !A(e, s) : e.isDragDisabled ?? !1;
265
+ const u = v ? ee(v, e.id) : !1, f = M.has(e.id), a = w ? !w(e, s) : e.isDragDisabled ?? !1;
268
266
  return /* @__PURE__ */ S(
269
- Je,
267
+ Ke,
270
268
  {
271
269
  item: e,
272
270
  level: s,
273
271
  indentLevel: r,
274
- isCollapsed: C[e.id] || !1,
275
- onToggle: te,
276
- onToggleCollapse: se,
277
- isAnyDragging: I !== null,
272
+ isCollapsed: I[e.id] || !1,
273
+ onToggle: se,
274
+ onToggleCollapse: re,
275
+ isAnyDragging: v !== null,
278
276
  isValidDrop: u,
279
277
  enableDragDrop: H,
280
- enableCollapse: X,
278
+ enableCollapse: Y,
281
279
  shouldBlink: f,
282
- isDragDisabled: d,
280
+ isDragDisabled: a,
283
281
  renderLabelExtras: l,
284
282
  renderActions: m
285
283
  },
@@ -287,108 +285,108 @@ const ie = (a, t) => {
287
285
  );
288
286
  },
289
287
  [
290
- C,
291
- te,
292
- se,
293
288
  I,
294
- G,
289
+ se,
290
+ re,
291
+ v,
292
+ ee,
295
293
  H,
296
- $,
297
- X,
298
- A,
294
+ M,
295
+ Y,
296
+ w,
299
297
  l,
300
298
  m
301
299
  ]
302
- ), je = ee(h).length > 0, ce = T(
303
- () => tt({
300
+ ), Fe = te(h).length > 0, de = T(
301
+ () => st({
304
302
  enableApplyDiscard: p,
305
303
  items: h,
306
- savedItems: b,
307
- revision: U,
308
- savedRevision: V
304
+ savedItems: x,
305
+ revision: V,
306
+ savedRevision: U
309
307
  }),
310
- [p, h, b, U, V]
311
- ), Fe = w(() => {
312
- p && (Z(h), Re(U), o?.(h));
313
- }, [p, h, o, Z, U]), qe = w(() => {
314
- p && (L(b), M(V), c?.());
315
- }, [p, b, c, L, V]);
316
- return /* @__PURE__ */ de(
308
+ [p, h, x, V, U]
309
+ ), qe = A(() => {
310
+ p && ($(h), be(V), o?.(h));
311
+ }, [p, h, o, $, V]), Je = A(() => {
312
+ p && (L(x), G(U), c?.());
313
+ }, [p, x, c, L, U]);
314
+ return /* @__PURE__ */ ie(
317
315
  "div",
318
316
  {
319
- className: st("flex flex-col", me),
317
+ className: rt("flex flex-col min-h-0", Ie),
320
318
  "data-component": "nested-list",
321
- "data-has-changes": ce ? "" : void 0,
319
+ "data-has-changes": de ? "" : void 0,
322
320
  "data-list-collapsed": z ? "" : void 0,
323
321
  children: [
324
- /* @__PURE__ */ de("div", { className: "flex-shrink-0", children: [
322
+ /* @__PURE__ */ ie("div", { className: "flex-shrink-0", children: [
325
323
  /* @__PURE__ */ S(
326
- Ze,
324
+ $e,
327
325
  {
328
- hasItemsWithChildren: je,
326
+ hasItemsWithChildren: Fe,
329
327
  isListCollapsed: z,
330
- onCollapseAll: ye,
328
+ onCollapseAll: He,
331
329
  enableSearch: y,
332
- enableSelectAll: fe,
333
- groupLabel: Ce,
330
+ enableSelectAll: pe,
331
+ groupLabel: ve,
334
332
  allChecked: E,
335
- isIndeterminate: Ve,
336
- onSelectAll: Oe,
337
- searchText: x,
333
+ isIndeterminate: _e,
334
+ onSelectAll: We,
335
+ searchText: b,
338
336
  onSearchChange: (e) => {
339
- Ee(e.target.value);
337
+ De(e.target.value);
340
338
  },
341
- searchPlaceholder: Se,
339
+ searchPlaceholder: ge,
342
340
  selectAllLabel: P("nestedList.selectAll"),
343
- enableCollapse: Ie
341
+ enableCollapse: Ce
344
342
  }
345
343
  ),
346
344
  /* @__PURE__ */ S(
347
- $e,
345
+ Me,
348
346
  {
349
347
  isListCollapsed: z,
350
348
  enableGroupBy: g,
351
- categories: Be,
349
+ categories: Ve,
352
350
  selectedCategories: B,
353
- onToggleCategory: He
351
+ onToggleCategory: Oe
354
352
  }
355
353
  )
356
354
  ] }),
357
355
  /* @__PURE__ */ S("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ S(
358
- Me,
356
+ Ge,
359
357
  {
360
358
  isListCollapsed: z,
361
359
  enableDragDrop: H,
362
- sensors: xe,
363
- items: F,
364
- renderItem: We,
365
- activeId: I,
360
+ sensors: ze,
361
+ items: q,
362
+ renderItem: je,
363
+ activeId: v,
366
364
  onDragStart: (e) => {
367
- O(e.active.id);
365
+ W(e.active.id);
368
366
  },
369
367
  onDragOver: (e) => {
370
- W(e.over?.id);
368
+ j(e.over?.id);
371
369
  },
372
370
  onDragEnd: (e) => {
373
- O(null), W(null), R.current = !0, ze(e, (s) => {
371
+ W(null), j(null), R(), Be(e, (s) => {
374
372
  const r = s(h);
375
373
  L(r), t(r);
376
374
  });
377
375
  },
378
376
  onDragCancel: () => {
379
- O(null), W(null);
377
+ W(null), j(null);
380
378
  }
381
379
  }
382
380
  ) }),
383
381
  /* @__PURE__ */ S(
384
- Ge,
382
+ et,
385
383
  {
386
384
  enableApplyDiscard: p,
387
- hasChanges: ce,
388
- onDiscard: qe,
389
- onApply: Fe,
390
- cancelButtonLabel: ke,
391
- submitButtonLabel: ge
385
+ hasChanges: de,
386
+ onDiscard: Je,
387
+ onApply: qe,
388
+ cancelButtonLabel: Ee,
389
+ submitButtonLabel: ke
392
390
  }
393
391
  )
394
392
  ]
@@ -396,5 +394,5 @@ const ie = (a, t) => {
396
394
  );
397
395
  };
398
396
  export {
399
- Lt as NestedList
397
+ St as NestedList
400
398
  };