impact-nova 1.7.31 → 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.
- package/dist/components/ui/data-table/data-table-column-list.js +135 -115
- package/dist/components/ui/date-picker/date-range-picker.js +182 -165
- package/dist/components/ui/date-picker/month-range-picker.js +221 -166
- package/dist/components/ui/horizontal-scroller/horizontal-scroller.js +98 -93
- package/dist/components/ui/nested-list/hooks/useNestedListDragDrop.js +19 -19
- package/dist/components/ui/types/horizontal-scroller.types.d.ts +4 -0
- package/dist/impact-nova.css +1 -1
- package/package.json +1 -1
|
@@ -1,87 +1,85 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useDataTable as
|
|
4
|
-
import { NestedList as
|
|
5
|
-
import { SelectionMode as
|
|
6
|
-
import { mergePartialOrderedColumnState as
|
|
7
|
-
import { useImpactNovaI18n as
|
|
8
|
-
const de = ({
|
|
9
|
-
enableApplyDiscard:
|
|
10
|
-
showSearch:
|
|
11
|
-
showSelectAll:
|
|
12
|
-
showCollapse:
|
|
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:
|
|
15
|
-
if (!
|
|
16
|
-
const r =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
29
|
+
return o.push(N), l.set(d, { list: o, node: N }), N;
|
|
32
30
|
};
|
|
33
|
-
let
|
|
31
|
+
let f = 0, C = 0, m = 0, s = 0;
|
|
34
32
|
r.forEach((t) => {
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
-
let
|
|
38
|
-
if (
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
|
|
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 (!
|
|
42
|
+
if (!n || n.trim() === "")
|
|
45
43
|
return;
|
|
46
|
-
const
|
|
44
|
+
const d = !t.hide, p = {
|
|
47
45
|
id: t.colId,
|
|
48
|
-
label:
|
|
49
|
-
checked:
|
|
46
|
+
label: n,
|
|
47
|
+
checked: d
|
|
50
48
|
};
|
|
51
|
-
t.pinned ? (
|
|
52
|
-
const
|
|
53
|
-
|
|
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
|
|
56
|
-
let
|
|
57
|
-
for (const
|
|
58
|
-
|
|
59
|
-
return
|
|
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
|
-
|
|
62
|
-
const
|
|
59
|
+
I(a), I(i);
|
|
60
|
+
const b = [
|
|
63
61
|
{
|
|
64
62
|
id: "root-frozen",
|
|
65
|
-
label:
|
|
66
|
-
checked:
|
|
67
|
-
children:
|
|
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:
|
|
74
|
-
checked:
|
|
75
|
-
children:
|
|
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
|
-
|
|
81
|
-
}, [
|
|
78
|
+
O(b), B(!0);
|
|
79
|
+
}, [e, T]);
|
|
82
80
|
F(() => {
|
|
83
|
-
if (!
|
|
84
|
-
const r = setTimeout(() =>
|
|
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
|
|
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
|
|
107
|
-
clearTimeout(r), c && clearTimeout(c),
|
|
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
|
-
}, [
|
|
110
|
-
if (
|
|
105
|
+
}, [e, D]), F(() => {
|
|
106
|
+
if (E.current === 0) return;
|
|
111
107
|
const r = requestAnimationFrame(() => {
|
|
112
|
-
const
|
|
113
|
-
|
|
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
|
-
}, [
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
if (
|
|
121
|
-
|
|
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 (
|
|
125
|
-
|
|
120
|
+
if (l.id === "root-scrollable") {
|
|
121
|
+
l.children && c(l.children, null);
|
|
126
122
|
return;
|
|
127
123
|
}
|
|
128
|
-
|
|
129
|
-
colId:
|
|
130
|
-
pinned:
|
|
131
|
-
hide: !
|
|
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),
|
|
136
|
-
}, [
|
|
137
|
-
if (!
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
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
|
-
|
|
143
|
-
},
|
|
138
|
+
v.current = !1;
|
|
139
|
+
}, M);
|
|
144
140
|
return;
|
|
145
141
|
}
|
|
146
|
-
const c =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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:
|
|
183
|
+
items: K,
|
|
164
184
|
onChange: H,
|
|
165
|
-
onSubmit:
|
|
166
|
-
enableApplyDiscard:
|
|
167
|
-
enableSearch:
|
|
168
|
-
enableSelectAll:
|
|
185
|
+
onSubmit: Y,
|
|
186
|
+
enableApplyDiscard: R,
|
|
187
|
+
enableSearch: U,
|
|
188
|
+
enableSelectAll: q,
|
|
169
189
|
enableDragDrop: !0,
|
|
170
190
|
enableCollapse: !0,
|
|
171
|
-
enableGlobalCollapse:
|
|
172
|
-
selectionMode:
|
|
173
|
-
searchPlaceholder:
|
|
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
|
-
|
|
181
|
-
) }) : /* @__PURE__ */
|
|
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
|