impact-nova 1.7.32 → 1.7.33

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,87 +1,85 @@
1
- import { jsx as x } from "react/jsx-runtime";
2
- import { useState as N, useRef as C, useCallback as b, useEffect as F } from "react";
3
- import { useDataTable as X } from "./data-table-context.js";
4
- import { NestedList as Y } from "../nested-list/nested-list.js";
5
- import { SelectionMode as Z } from "../types/nested-list.types.js";
6
- import { mergePartialOrderedColumnState as ee } from "./data-table-column-state.js";
7
- import { useImpactNovaI18n as te } from "../../../i18n/ImpactNovaI18nContext.js";
8
- const de = ({
9
- enableApplyDiscard: v = !1,
10
- showSearch: q = !0,
11
- showSelectAll: j = !0,
12
- showCollapse: K = !0
1
+ import { jsx as w } from "react/jsx-runtime";
2
+ import { useState as A, useRef as _, useCallback as k, useEffect as F } from "react";
3
+ import { useDataTable as J } from "./data-table-context.js";
4
+ import { NestedList as Q } from "../nested-list/nested-list.js";
5
+ import { SelectionMode as X } from "../types/nested-list.types.js";
6
+ import { mergePartialOrderedColumnState as Z } from "./data-table-column-state.js";
7
+ import { useImpactNovaI18n as ee } from "../../../i18n/ImpactNovaI18nContext.js";
8
+ const te = 300, M = 100, de = ({
9
+ enableApplyDiscard: R = !1,
10
+ showSearch: U = !0,
11
+ showSelectAll: q = !0,
12
+ showCollapse: W = !0
13
13
  }) => {
14
- const { gridApi: l } = X(), { t: p } = te(), [V, w] = N([]), [W, B] = N(!1), f = C(!1), T = C(null), y = C(0), z = C({}), [O, P] = N(!1), L = C(/* @__PURE__ */ new Map()), g = b(() => {
15
- if (!l || f.current) return;
16
- const r = l.getColumnState(), s = new Map(r.map((t) => [t.colId, t]));
17
- L.current = s;
18
- const c = l.getColumns() || [], i = new Map(c.map((t) => [t.getColId(), t])), n = [], e = [], k = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), J = (t, a) => {
19
- const o = t.getGroupId(), u = `${o}::${a === n ? "f" : "s"}`, d = k.get(u);
20
- if (d && d.list === a && a[a.length - 1] === d.node)
21
- return d.node;
22
- const m = D.get(u) || 0;
23
- D.set(u, m + 1);
24
- const I = t.getColGroupDef(), h = a === n ? "f" : "s", R = {
25
- id: m === 0 ? `${o}__${h}` : `${o}__${h}__${m}`,
26
- label: I?.headerName || o,
14
+ const { gridApi: e } = J(), { t: T } = ee(), [K, O] = A([]), [V, B] = A(!1), v = _(!1), x = _(null), E = _(0), z = _({}), [L, $] = A(!1), D = k(() => {
15
+ if (!e || v.current) return;
16
+ const r = e.getColumnState(), u = e.getColumns() || [], c = new Map(u.map((t) => [t.getColId(), t])), a = [], i = [], l = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = (t, o) => {
17
+ const n = t.getGroupId(), d = `${n}::${o === a ? "f" : "s"}`, p = l.get(d);
18
+ if (p && p.list === o && o[o.length - 1] === p.node)
19
+ return p.node;
20
+ const S = h.get(d) || 0;
21
+ h.set(d, S + 1);
22
+ const G = t.getColGroupDef(), y = o === a ? "f" : "s", N = {
23
+ id: S === 0 ? `${n}__${y}` : `${n}__${y}__${S}`,
24
+ label: G?.headerName || n,
27
25
  checked: !0,
28
26
  children: [],
29
27
  category: "group"
30
28
  };
31
- return a.push(R), k.set(u, { list: a, node: R }), R;
29
+ return o.push(N), l.set(d, { list: o, node: N }), N;
32
30
  };
33
- let E = 0, $ = 0, G = 0, A = 0;
31
+ let f = 0, C = 0, m = 0, s = 0;
34
32
  r.forEach((t) => {
35
- const a = i.get(t.colId);
36
- if (!a) return;
37
- let o = l.getDisplayNameForColumn(a, "header");
38
- if (o === "") return;
39
- if (o == null) {
40
- const h = a.getColDef();
41
- if (h.headerName === "") return;
42
- o = h.headerName || h.field || t.colId;
33
+ const o = c.get(t.colId);
34
+ if (!o) return;
35
+ let n = e.getDisplayNameForColumn(o, "header");
36
+ if (n === "") return;
37
+ if (n == null) {
38
+ const y = o.getColDef();
39
+ if (y.headerName === "") return;
40
+ n = y.headerName || y.field || t.colId;
43
41
  }
44
- if (!o || o.trim() === "")
42
+ if (!n || n.trim() === "")
45
43
  return;
46
- const u = !t.hide, d = {
44
+ const d = !t.hide, p = {
47
45
  id: t.colId,
48
- label: o,
49
- checked: u
46
+ label: n,
47
+ checked: d
50
48
  };
51
- t.pinned ? (E++, u && $++) : (G++, u && A++);
52
- const m = t.pinned ? n : e, I = a.getOriginalParent();
53
- I?.getColGroupDef()?.children ? J(I, m).children.push(d) : m.push(d);
49
+ t.pinned ? (f++, d && C++) : (m++, d && s++);
50
+ const S = t.pinned ? a : i, G = o.getOriginalParent();
51
+ G?.getColGroupDef()?.children ? g(G, S).children.push(p) : S.push(p);
54
52
  });
55
- const M = (t) => {
56
- let a = t.length > 0;
57
- for (const o of t)
58
- o.children && (o.checked = M(o.children)), o.checked || (a = !1);
59
- return a;
53
+ const I = (t) => {
54
+ let o = t.length > 0;
55
+ for (const n of t)
56
+ n.children && (n.checked = I(n.children)), n.checked || (o = !1);
57
+ return o;
60
58
  };
61
- M(n), M(e);
62
- const Q = [
59
+ I(a), I(i);
60
+ const b = [
63
61
  {
64
62
  id: "root-frozen",
65
- label: p("dataTable.frozenColumns"),
66
- checked: E > 0 && $ === E,
67
- children: n,
63
+ label: T("dataTable.frozenColumns"),
64
+ checked: f > 0 && C === f,
65
+ children: a,
68
66
  category: "structure",
69
67
  isDragDisabled: !0
70
68
  },
71
69
  {
72
70
  id: "root-scrollable",
73
- label: p("dataTable.scrollableColumns"),
74
- checked: G > 0 && A === G,
75
- children: e,
71
+ label: T("dataTable.scrollableColumns"),
72
+ checked: m > 0 && s === m,
73
+ children: i,
76
74
  category: "structure",
77
75
  isDragDisabled: !0
78
76
  }
79
77
  ];
80
- w(Q), B(!0);
81
- }, [l, p]);
78
+ O(b), B(!0);
79
+ }, [e, T]);
82
80
  F(() => {
83
- if (!l) return;
84
- const r = setTimeout(() => g(), 0), s = [
81
+ if (!e) return;
82
+ const r = setTimeout(() => D(), 0), u = [
85
83
  "columnVisible",
86
84
  "columnPinned",
87
85
  "columnMoved",
@@ -96,89 +94,111 @@ const de = ({
96
94
  "displayedColumnsChanged"
97
95
  ];
98
96
  let c = null;
99
- const i = () => {
97
+ const a = () => {
100
98
  c && clearTimeout(c), c = setTimeout(() => {
101
- c = null;
102
- const n = !f.current;
103
- f.current = !1, g(), n && P((e) => !e);
99
+ c = null, !v.current && (D(), $((i) => !i));
104
100
  }, 150);
105
101
  };
106
- return l.isDestroyed() || s.forEach((n) => l.addEventListener(n, i)), () => {
107
- clearTimeout(r), c && clearTimeout(c), l.isDestroyed() || s.forEach((n) => l.removeEventListener(n, i));
102
+ return e.isDestroyed() || u.forEach((i) => e.addEventListener(i, a)), () => {
103
+ clearTimeout(r), c && clearTimeout(c), e.isDestroyed() || u.forEach((i) => e.removeEventListener(i, a));
108
104
  };
109
- }, [l, g]), F(() => {
110
- if (y.current === 0) return;
105
+ }, [e, D]), F(() => {
106
+ if (E.current === 0) return;
111
107
  const r = requestAnimationFrame(() => {
112
- const s = T.current?.querySelector('[data-component="nested-list"] .overflow-y-auto');
113
- s && (s.scrollTop = y.current, y.current = 0);
108
+ const u = x.current?.querySelector('[data-component="nested-list"] .overflow-y-auto');
109
+ u && (u.scrollTop = E.current, E.current = 0);
114
110
  });
115
111
  return () => cancelAnimationFrame(r);
116
- }, [O]);
117
- const _ = b((r) => {
118
- const s = [], c = (i, n) => {
119
- i.forEach((e) => {
120
- if (e.id === "root-frozen") {
121
- e.children && c(e.children, "left");
112
+ }, [L]);
113
+ const j = k((r) => {
114
+ const u = [], c = (a, i) => {
115
+ a.forEach((l) => {
116
+ if (l.id === "root-frozen") {
117
+ l.children && c(l.children, "left");
122
118
  return;
123
119
  }
124
- if (e.id === "root-scrollable") {
125
- e.children && c(e.children, null);
120
+ if (l.id === "root-scrollable") {
121
+ l.children && c(l.children, null);
126
122
  return;
127
123
  }
128
- e.category === "group" || e.children && e.children.length > 0 ? e.children && c(e.children, n) : l?.getColumn(e.id) && s.push({
129
- colId: e.id,
130
- pinned: n,
131
- hide: !e.checked
124
+ l.category === "group" || l.children && l.children.length > 0 ? l.children && c(l.children, i) : e?.getColumn(l.id) && u.push({
125
+ colId: l.id,
126
+ pinned: i,
127
+ hide: !l.checked
132
128
  });
133
129
  });
134
130
  };
135
- return c(r, null), s;
136
- }, [l]), S = b((r) => {
137
- if (!l) return;
138
- f.current = !0;
139
- const s = _(r);
140
- if (s.length === 0) {
131
+ return c(r, null), u;
132
+ }, [e]), P = k((r) => {
133
+ if (!e) return;
134
+ v.current = !0;
135
+ const u = j(r);
136
+ if (u.length === 0) {
141
137
  setTimeout(() => {
142
- f.current = !1;
143
- }, 300);
138
+ v.current = !1;
139
+ }, M);
144
140
  return;
145
141
  }
146
- const c = l.getColumnState(), i = ee(c, s);
147
- l.applyColumnState({
148
- state: i,
149
- applyOrder: !0
150
- }), setTimeout(() => {
151
- f.current = !1;
152
- const n = T.current?.querySelector('[data-component="nested-list"] .overflow-y-auto');
153
- n && (y.current = n.scrollTop), g(), P((e) => !e);
154
- }, 300);
155
- }, [l, _, g]), U = b((r) => {
156
- S(r);
157
- }, [S]), H = b((r) => {
158
- v || S(r), w(r);
159
- }, [v, S]);
160
- return W ? /* @__PURE__ */ x("div", { ref: T, className: "flex flex-col h-full bg-canvas-elevated", children: /* @__PURE__ */ x(
161
- Y,
142
+ const c = e.getColumnState(), a = Z(c, u), i = new Set(c.filter((s) => s.pinned).map((s) => s.colId)), l = a.filter((s) => s.pinned && !i.has(s.colId)), h = new Set(l.map((s) => s.colId));
143
+ e.applyColumnState({ state: a, applyOrder: !0 });
144
+ const g = () => {
145
+ v.current = !1;
146
+ const s = x.current?.querySelector('[data-component="nested-list"] .overflow-y-auto');
147
+ s && (E.current = s.scrollTop), D(), $((I) => !I);
148
+ };
149
+ if (h.size === 0) {
150
+ setTimeout(g, M);
151
+ return;
152
+ }
153
+ let f = !1, C = null;
154
+ const m = () => {
155
+ if (f || e.isDestroyed()) return;
156
+ const s = e.getColumnState();
157
+ if (l.filter((b) => {
158
+ const t = s.find((o) => o.colId === b.colId);
159
+ return t && !t.pinned;
160
+ }).length > 0) {
161
+ f = !0, C && clearTimeout(C), e.removeEventListener("columnPinned", m);
162
+ const b = a.filter((t) => t.pinned && !h.has(t.colId));
163
+ if (b.length > 0) {
164
+ const t = b[0], o = a.map(
165
+ (n) => n.colId === t.colId ? { ...n, pinned: null } : n
166
+ );
167
+ e.applyColumnState({ state: o, applyOrder: !0 });
168
+ }
169
+ setTimeout(g, M);
170
+ }
171
+ };
172
+ e.addEventListener("columnPinned", m), C = setTimeout(() => {
173
+ e.removeEventListener("columnPinned", m), f || g();
174
+ }, te);
175
+ }, [e, j, D]), Y = k((r) => {
176
+ P(r);
177
+ }, [P]), H = k((r) => {
178
+ R || P(r), O(r);
179
+ }, [R, P]);
180
+ return V ? /* @__PURE__ */ w("div", { ref: x, className: "flex flex-col h-full bg-canvas-elevated", children: /* @__PURE__ */ w(
181
+ Q,
162
182
  {
163
- items: V,
183
+ items: K,
164
184
  onChange: H,
165
- onSubmit: U,
166
- enableApplyDiscard: v,
167
- enableSearch: q,
168
- enableSelectAll: j,
185
+ onSubmit: Y,
186
+ enableApplyDiscard: R,
187
+ enableSearch: U,
188
+ enableSelectAll: q,
169
189
  enableDragDrop: !0,
170
190
  enableCollapse: !0,
171
- enableGlobalCollapse: K,
172
- selectionMode: Z.CASCADE_DOWN,
173
- searchPlaceholder: p("dataTable.searchColumnsPlaceholder"),
191
+ enableGlobalCollapse: W,
192
+ selectionMode: X.CASCADE_DOWN,
193
+ searchPlaceholder: T("dataTable.searchColumnsPlaceholder"),
174
194
  className: "h-full",
175
195
  initialCollapsedItems: z.current,
176
196
  onCollapseChange: (r) => {
177
197
  z.current = r;
178
198
  }
179
199
  },
180
- O ? "sync-a" : "sync-b"
181
- ) }) : /* @__PURE__ */ x("div", { className: "p-4 text-[13px] text-content-placeholder", children: p("dataTable.loadingColumns") });
200
+ L ? "sync-a" : "sync-b"
201
+ ) }) : /* @__PURE__ */ w("div", { className: "p-4 text-[13px] text-content-placeholder", children: T("dataTable.loadingColumns") });
182
202
  };
183
203
  export {
184
204
  de as DataTableColumnList
@@ -1,6 +1,6 @@
1
1
  import { useCallback as S } from "react";
2
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";
3
+ import { arrayMove as A } from "@dnd-kit/sortable";
4
4
  const W = "droppable-", y = /* @__PURE__ */ new Set(["root-frozen", "root-scrollable"]);
5
5
  function X(h) {
6
6
  if (h.startsWith(W)) {
@@ -65,7 +65,7 @@ const rn = ({
65
65
  return null;
66
66
  },
67
67
  []
68
- ), A = S(
68
+ ), G = S(
69
69
  (t, e, o) => t.map((r) => {
70
70
  if (r.children && r.children.length > 0) {
71
71
  const n = r.children.findIndex(
@@ -74,7 +74,7 @@ const rn = ({
74
74
  (i) => i.id === o
75
75
  );
76
76
  if (n !== -1 && l !== -1) {
77
- const i = w(r.children, n, l);
77
+ const i = A(r.children, n, l);
78
78
  return {
79
79
  ...r,
80
80
  children: i
@@ -82,7 +82,7 @@ const rn = ({
82
82
  }
83
83
  return {
84
84
  ...r,
85
- children: A(r.children, e, o)
85
+ children: G(r.children, e, o)
86
86
  };
87
87
  }
88
88
  return r;
@@ -98,7 +98,7 @@ const rn = ({
98
98
  (i) => i.id === e
99
99
  );
100
100
  if (n !== -1 && l !== -1) {
101
- const i = w(
101
+ const i = A(
102
102
  t,
103
103
  l,
104
104
  n
@@ -112,7 +112,7 @@ const rn = ({
112
112
  (t, e, o) => {
113
113
  const r = t.findIndex((l) => l.id === e), n = t.findIndex((l) => l.id === o);
114
114
  if (r !== -1 && n !== -1) {
115
- const l = w(t, r, n);
115
+ const l = A(t, r, n);
116
116
  return u?.(e, o), l;
117
117
  }
118
118
  return null;
@@ -120,20 +120,20 @@ const rn = ({
120
120
  [u]
121
121
  ), z = S(
122
122
  (t, e, o) => {
123
- const r = A(t, e, o);
123
+ const r = G(t, e, o);
124
124
  return u?.(e, o), r;
125
125
  },
126
- [A, u]
127
- ), G = S(
126
+ [G, u]
127
+ ), N = S(
128
128
  (t, e, o, r = !1) => {
129
129
  const n = F(t, e);
130
130
  if (!n) return null;
131
131
  const l = (s) => s.filter((c) => c.id !== e).map(
132
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) => {
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, w = f && R && !M && r, g = (s) => {
134
134
  for (let c = 0; c < s.length; c++) {
135
135
  if (s[c].id === o)
136
- if (_) {
136
+ if (w) {
137
137
  const L = {
138
138
  ...s[c],
139
139
  children: [n, ...s[c].children || []]
@@ -156,7 +156,7 @@ const rn = ({
156
156
  return Y ? (u?.(e, o), O) : null;
157
157
  },
158
158
  [u, d]
159
- ), N = S(
159
+ ), _ = S(
160
160
  (t, e, o) => {
161
161
  const r = F(t, e);
162
162
  if (!r) return t;
@@ -181,10 +181,10 @@ const rn = ({
181
181
  }
182
182
  const f = X(i);
183
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);
184
+ return _(n, l, f);
185
+ const R = C(n, l), M = C(n, i), w = T(n, l), g = T(n, i);
186
186
  if (y.has(i) && R !== null && R > 0)
187
- return N(n, l, i);
187
+ return _(n, l, i);
188
188
  if (R === 0 && M !== null && M > 0)
189
189
  return B(
190
190
  n,
@@ -193,7 +193,7 @@ const rn = ({
193
193
  ) || n;
194
194
  if (R === null || M === null)
195
195
  return n;
196
- if (R > 0 && M > 0 && _ !== g) {
196
+ if (R > 0 && M > 0 && w !== g) {
197
197
  const P = j(n, l), O = j(n, i);
198
198
  if (P && O && P !== O) {
199
199
  const a = o.rect.current.translated, b = r.rect;
@@ -202,7 +202,7 @@ const rn = ({
202
202
  const Q = a.top + a.height / 2, U = b.top + b.height / 2;
203
203
  H = Q > U;
204
204
  }
205
- return G(n, l, i, H) || n;
205
+ return N(n, l, i, H) || n;
206
206
  }
207
207
  const Y = o.rect.current.translated, s = r.rect;
208
208
  let c = !1;
@@ -210,7 +210,7 @@ const rn = ({
210
210
  const a = Y.top + Y.height / 2, b = s.top + s.height / 2;
211
211
  c = a > b;
212
212
  }
213
- return G(n, l, i, c) || n;
213
+ return N(n, l, i, c) || n;
214
214
  }
215
215
  return R === 0 ? k(n, l, i) || n : z(n, l, i);
216
216
  });
@@ -221,8 +221,8 @@ const rn = ({
221
221
  B,
222
222
  k,
223
223
  z,
224
- G,
225
224
  N,
225
+ _,
226
226
  x
227
227
  ]
228
228
  ), K = S(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impact-nova",
3
- "version": "1.7.32",
3
+ "version": "1.7.33",
4
4
  "description": "Enterprise-grade React design system built with React 19, Vite, Tailwind CSS, and Radix UI. Built-in internationalization (i18n) and comprehensive UI component library for scalable, accessible, and performant applications.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",