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,166 +1,167 @@
1
- import { useState as u, useMemo as O, useCallback as g } from "react";
2
- function p(s) {
3
- const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), d = [], i = (r, h) => {
4
- r.forEach((o) => {
5
- e.set(o.id, o), n.set(o.id, h), o.children && o.children.length > 0 ? (t.set(o.id, o.children.map((C) => C.id)), i(o.children, o.id)) : t.set(o.id, []), h === null && d.push(o.id);
1
+ import { useState as o, useCallback as y, useRef as N, useEffect as z, useMemo as ss } from "react";
2
+ function l(t) {
3
+ const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), u = [], i = (I, h) => {
4
+ I.forEach((r) => {
5
+ n.set(r.id, r), e.set(r.id, h), r.children && r.children.length > 0 ? (s.set(r.id, r.children.map((C) => C.id)), i(r.children, r.id)) : s.set(r.id, []), h === null && u.push(r.id);
6
6
  });
7
7
  };
8
- return i(s, null), { byId: e, childrenById: t, parentById: n, rootIds: d };
8
+ return i(t, null), { byId: n, childrenById: s, parentById: e, rootIds: u };
9
9
  }
10
- function a(s) {
11
- const e = (t) => {
12
- const n = [];
13
- for (const d of t) {
14
- const i = s.byId.get(d);
10
+ function T(t) {
11
+ const n = (s) => {
12
+ const e = [];
13
+ for (const u of s) {
14
+ const i = t.byId.get(u);
15
15
  if (!i) continue;
16
- const r = s.childrenById.get(d) || [], h = r.length > 0 ? e(r) : void 0;
17
- n.push({
16
+ const I = t.childrenById.get(u) || [], h = I.length > 0 ? n(I) : void 0;
17
+ e.push({
18
18
  ...i,
19
19
  children: h
20
20
  });
21
21
  }
22
- return n;
22
+ return e;
23
23
  };
24
- return e(s.rootIds);
24
+ return n(t.rootIds);
25
25
  }
26
- function R(s, e, t) {
27
- const n = s.byId.get(e);
28
- if (!n) return s;
29
- const d = new Map(s.byId);
30
- return d.set(e, { ...n, ...t }), {
31
- ...s,
32
- byId: d
26
+ function j(t, n, s) {
27
+ const e = t.byId.get(n);
28
+ if (!e) return t;
29
+ const u = new Map(t.byId);
30
+ return u.set(n, { ...e, ...s }), {
31
+ ...t,
32
+ byId: u
33
33
  };
34
34
  }
35
- function N(s, e) {
36
- return s.byId.get(e) || null;
35
+ function ts(t, n) {
36
+ return t.byId.get(n) || null;
37
37
  }
38
- function z(s, e) {
39
- const t = [];
40
- let n = s.parentById.get(e) || null;
41
- for (; n !== null; )
42
- t.push(n), n = s.parentById.get(n) || null;
43
- return t;
38
+ function es(t, n) {
39
+ const s = [];
40
+ let e = t.parentById.get(n) || null;
41
+ for (; e !== null; )
42
+ s.push(e), e = t.parentById.get(e) || null;
43
+ return s;
44
44
  }
45
- function tt(s, e) {
46
- const t = [], n = (d) => {
47
- (s.childrenById.get(d) || []).forEach((r) => {
48
- t.push(r), n(r);
45
+ function ns(t, n) {
46
+ const s = [], e = (u) => {
47
+ (t.childrenById.get(u) || []).forEach((I) => {
48
+ s.push(I), e(I);
49
49
  });
50
50
  };
51
- return n(e), t;
51
+ return e(n), s;
52
52
  }
53
- const nt = ({
54
- initialItems: s,
55
- enableApplyDiscard: e,
56
- enableNormalizedState: t = !1,
57
- initialCollapsedItems: n
53
+ const rs = ({
54
+ initialItems: t,
55
+ enableApplyDiscard: n,
56
+ enableNormalizedState: s = !1,
57
+ initialCollapsedItems: e
58
58
  }) => {
59
- const [d, i] = u(s), [r, h] = u(!1), o = O(() => ({
60
- get current() {
61
- return r;
62
- },
63
- set current(c) {
64
- c !== r && queueMicrotask(() => h(c));
65
- }
66
- }), [r]), C = d !== s, [j, x] = u(s), [v, l] = u(s), [f, w] = u(
67
- () => t ? p(s) : {
59
+ const [u, i] = o(t), [I, h] = o(!1), r = y(() => h(!0), []), C = u !== t, [m, x] = o(t), [p, w] = o(t), k = N(p);
60
+ z(() => {
61
+ k.current = p;
62
+ }, [p]);
63
+ const [f, B] = o(
64
+ () => s ? l(t) : {
68
65
  byId: /* @__PURE__ */ new Map(),
69
66
  childrenById: /* @__PURE__ */ new Map(),
70
67
  parentById: /* @__PURE__ */ new Map(),
71
68
  rootIds: []
72
69
  }
73
- ), [k, E] = u(
74
- () => t ? p(s) : {
70
+ ), [E, U] = o(
71
+ () => s ? l(t) : {
75
72
  byId: /* @__PURE__ */ new Map(),
76
73
  childrenById: /* @__PURE__ */ new Map(),
77
74
  parentById: /* @__PURE__ */ new Map(),
78
75
  rootIds: []
79
76
  }
80
- ), [G, J] = u(""), [K, P] = u(n ?? {}), [Q, V] = u(!1), [W, X] = u(null), [Y, Z] = u(null), [_, $] = u(
77
+ ), [q, G] = o(""), [J, K] = o(e ?? {}), [P, Q] = o(!1), [V, W] = o(null), [X, Y] = o(null), [Z, _] = o(
81
78
  /* @__PURE__ */ new Set()
82
- ), [m, b] = u(/* @__PURE__ */ new Set());
83
- if (C && !r && (i(s), l(s), e && x(s), t)) {
84
- const c = p(s);
85
- w(c), e && E(c);
86
- }
87
- r && !C && h(!1);
88
- const U = g((c) => t ? N(f, c) : null, [t, f]), L = g((c, y) => {
89
- t && (w((I) => R(I, c, y)), l((I) => a(R(p(I), c, y))));
90
- }, [t]), A = g((c) => t ? z(f, c) : [], [t, f]), F = g((c) => t ? tt(f, c) : [], [t, f]), q = g((c) => {
91
- t && (w((y) => {
92
- const I = new Map(y.byId);
93
- return c.forEach((T, B) => {
94
- const M = I.get(B);
95
- M && I.set(B, { ...M, ...T });
96
- }), { ...y, byId: I };
97
- }), l((y) => {
98
- const I = p(y);
99
- return c.forEach((T, B) => {
100
- const M = I.byId.get(B);
101
- M && I.byId.set(B, { ...M, ...T });
102
- }), a(I);
79
+ ), [$, b] = o(/* @__PURE__ */ new Set());
80
+ if (C) {
81
+ if (i(t), I)
82
+ h(!1);
83
+ else if (w(t), n && x(t), s) {
84
+ const c = l(t);
85
+ B(c), n && U(c);
86
+ }
87
+ } else I && h(!1);
88
+ const L = y((c) => s ? ts(f, c) : null, [s, f]), A = y((c, g) => {
89
+ s && (B((d) => j(d, c, g)), w((d) => T(j(l(d), c, g))));
90
+ }, [s]), F = y((c) => s ? es(f, c) : [], [s, f]), R = y((c) => s ? ns(f, c) : [], [s, f]), D = y((c) => {
91
+ s && (B((g) => {
92
+ const d = new Map(g.byId);
93
+ return c.forEach((a, M) => {
94
+ const v = d.get(M);
95
+ v && d.set(M, { ...v, ...a });
96
+ }), { ...g, byId: d };
97
+ }), w((g) => {
98
+ const d = l(g);
99
+ return c.forEach((a, M) => {
100
+ const v = d.byId.get(M);
101
+ v && d.byId.set(M, { ...v, ...a });
102
+ }), T(d);
103
103
  }));
104
- }, [t]), D = g(() => {
105
- t && l(a(f));
106
- }, [t, f]), H = g(() => {
107
- t && w(p(v));
108
- }, [t, v]), S = O(() => ({
109
- findItemByIdFast: U,
110
- updateItemFast: L,
111
- getAncestors: A,
112
- getDescendants: F,
113
- batchUpdateItems: q,
114
- syncToTreeState: D,
115
- syncToNormalizedState: H,
116
- isNormalized: t,
104
+ }, [s]), H = y(() => {
105
+ s && w(T(f));
106
+ }, [s, f]), O = y(() => {
107
+ s && B(l(p));
108
+ }, [s, p]), S = ss(() => ({
109
+ findItemByIdFast: L,
110
+ updateItemFast: A,
111
+ getAncestors: F,
112
+ getDescendants: R,
113
+ batchUpdateItems: D,
114
+ syncToTreeState: H,
115
+ syncToNormalizedState: O,
116
+ isNormalized: s,
117
117
  normalizedState: f,
118
- setNormalizedState: w,
119
- savedNormalizedState: k,
120
- setSavedNormalizedState: E
118
+ setNormalizedState: B,
119
+ savedNormalizedState: E,
120
+ setSavedNormalizedState: U
121
121
  }), [
122
- U,
123
122
  L,
124
123
  A,
125
124
  F,
126
- q,
125
+ R,
127
126
  D,
128
127
  H,
129
- t,
128
+ O,
129
+ s,
130
130
  f,
131
- k
131
+ E
132
132
  ]);
133
133
  return {
134
134
  // Standard state (backward compatible)
135
- items: v,
136
- setItems: l,
137
- savedItems: j,
135
+ items: p,
136
+ setItems: w,
137
+ itemsRef: k,
138
+ savedItems: m,
138
139
  setSavedItems: x,
139
- isUserChangeRef: o,
140
- searchText: G,
141
- setSearchText: J,
142
- collapsedItems: K,
143
- setCollapsedItems: P,
144
- isListCollapsed: Q,
145
- setIsListCollapsed: V,
146
- activeId: W,
147
- setActiveId: X,
148
- overId: Y,
149
- setOverId: Z,
150
- selectedCategories: _,
151
- setSelectedCategories: $,
152
- itemsToBlink: m,
140
+ markUserChange: r,
141
+ searchText: q,
142
+ setSearchText: G,
143
+ collapsedItems: J,
144
+ setCollapsedItems: K,
145
+ isListCollapsed: P,
146
+ setIsListCollapsed: Q,
147
+ activeId: V,
148
+ setActiveId: W,
149
+ overId: X,
150
+ setOverId: Y,
151
+ selectedCategories: Z,
152
+ setSelectedCategories: _,
153
+ itemsToBlink: $,
153
154
  setItemsToBlink: b,
154
155
  // Normalized state helpers (for optimized operations)
155
156
  ...S
156
157
  };
157
158
  };
158
159
  export {
159
- a as denormalizeItems,
160
- z as getAncestorIds,
161
- tt as getDescendantIds,
162
- N as getItemById,
163
- p as normalizeItems,
164
- R as updateNormalizedItem,
165
- nt as useNestedListState
160
+ T as denormalizeItems,
161
+ es as getAncestorIds,
162
+ ns as getDescendantIds,
163
+ ts as getItemById,
164
+ l as normalizeItems,
165
+ j as updateNormalizedItem,
166
+ rs as useNestedListState
166
167
  };