@toolbox-web/grid-react 0.6.0 → 0.8.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.
- package/README.md +158 -2
- package/chunks/feature-registry-Y3KvnN54.js +26 -0
- package/chunks/multi-sort-Ae2VVdZb.js +3 -0
- package/features/clipboard.d.ts +18 -0
- package/features/clipboard.d.ts.map +1 -0
- package/features/clipboard.js +6 -0
- package/features/column-virtualization.d.ts +16 -0
- package/features/column-virtualization.d.ts.map +1 -0
- package/features/column-virtualization.js +6 -0
- package/features/context-menu.d.ts +16 -0
- package/features/context-menu.d.ts.map +1 -0
- package/features/context-menu.js +6 -0
- package/features/editing.d.ts +16 -0
- package/features/editing.d.ts.map +1 -0
- package/features/editing.js +3 -0
- package/features/export.d.ts +16 -0
- package/features/export.d.ts.map +1 -0
- package/features/export.js +6 -0
- package/features/filtering.d.ts +16 -0
- package/features/filtering.d.ts.map +1 -0
- package/features/filtering.js +6 -0
- package/features/grouping-columns.d.ts +16 -0
- package/features/grouping-columns.d.ts.map +1 -0
- package/features/grouping-columns.js +6 -0
- package/features/grouping-rows.d.ts +16 -0
- package/features/grouping-rows.d.ts.map +1 -0
- package/features/grouping-rows.js +6 -0
- package/features/index.d.ts +1 -0
- package/features/index.d.ts.map +1 -0
- package/features/index.js +22 -0
- package/features/master-detail.d.ts +18 -0
- package/features/master-detail.d.ts.map +1 -0
- package/features/master-detail.js +6 -0
- package/features/multi-sort.d.ts +22 -0
- package/features/multi-sort.d.ts.map +1 -0
- package/features/pinned-columns.d.ts +16 -0
- package/features/pinned-columns.d.ts.map +1 -0
- package/features/pinned-columns.js +6 -0
- package/features/pinned-rows.d.ts +16 -0
- package/features/pinned-rows.d.ts.map +1 -0
- package/features/pinned-rows.js +6 -0
- package/features/pivot.d.ts +16 -0
- package/features/pivot.d.ts.map +1 -0
- package/features/pivot.js +3 -0
- package/features/print.d.ts +16 -0
- package/features/print.d.ts.map +1 -0
- package/features/print.js +3 -0
- package/features/reorder.d.ts +16 -0
- package/features/reorder.d.ts.map +1 -0
- package/features/reorder.js +6 -0
- package/features/responsive.d.ts +16 -0
- package/features/responsive.d.ts.map +1 -0
- package/features/responsive.js +6 -0
- package/features/row-reorder.d.ts +16 -0
- package/features/row-reorder.d.ts.map +1 -0
- package/features/row-reorder.js +3 -0
- package/features/selection.d.ts +16 -0
- package/features/selection.d.ts.map +1 -0
- package/features/selection.js +3 -0
- package/features/server-side.d.ts +16 -0
- package/features/server-side.d.ts.map +1 -0
- package/features/server-side.js +3 -0
- package/features/sorting.d.ts +1 -0
- package/features/sorting.d.ts.map +1 -0
- package/features/sorting.js +1 -0
- package/features/tree.d.ts +16 -0
- package/features/tree.d.ts.map +1 -0
- package/features/tree.js +6 -0
- package/features/undo-redo.d.ts +18 -0
- package/features/undo-redo.d.ts.map +1 -0
- package/features/undo-redo.js +6 -0
- package/features/visibility.d.ts +16 -0
- package/features/visibility.d.ts.map +1 -0
- package/features/visibility.js +6 -0
- package/index.d.ts +6 -3
- package/index.d.ts.map +1 -1
- package/index.js +625 -430
- package/lib/column-shorthand.d.ts +59 -0
- package/lib/column-shorthand.d.ts.map +1 -0
- package/lib/context-types.d.ts +1 -1
- package/lib/data-grid.d.ts +118 -26
- package/lib/data-grid.d.ts.map +1 -1
- package/lib/event-props.d.ts +305 -0
- package/lib/event-props.d.ts.map +1 -0
- package/lib/feature-props.d.ts +329 -0
- package/lib/feature-props.d.ts.map +1 -0
- package/lib/feature-registry.d.ts +56 -0
- package/lib/feature-registry.d.ts.map +1 -0
- package/lib/grid-column.d.ts +1 -1
- package/lib/grid-detail-panel.d.ts +3 -0
- package/lib/grid-detail-panel.d.ts.map +1 -1
- package/lib/grid-responsive-card.d.ts +3 -0
- package/lib/grid-responsive-card.d.ts.map +1 -1
- package/lib/grid-type-registry.d.ts +1 -1
- package/lib/grid-type-registry.d.ts.map +1 -1
- package/lib/react-column-config.d.ts +1 -1
- package/lib/react-grid-adapter.d.ts +1 -1
- package/lib/react-grid-adapter.d.ts.map +1 -1
- package/lib/use-grid-event.d.ts +23 -19
- package/lib/use-grid-event.d.ts.map +1 -1
- package/lib/use-grid.d.ts +46 -2
- package/lib/use-grid.d.ts.map +1 -1
- package/lib/use-sync-plugins.d.ts +21 -0
- package/lib/use-sync-plugins.d.ts.map +1 -0
- package/package.json +11 -1
package/index.js
CHANGED
|
@@ -1,205 +1,258 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { DataGridElement as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { flushSync as
|
|
5
|
-
import { createRoot as
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
if (t) {
|
|
10
|
-
const r = L.get(t);
|
|
11
|
-
if (r) return r;
|
|
12
|
-
}
|
|
13
|
-
const e = n.id || n.getAttribute("data-grid-id");
|
|
14
|
-
if (e)
|
|
15
|
-
return N.get(e);
|
|
1
|
+
import { jsx as I } from "react/jsx-runtime";
|
|
2
|
+
import { DataGridElement as ue } from "@toolbox-web/grid";
|
|
3
|
+
import { useRef as P, useCallback as h, useEffect as w, createContext as fe, useContext as Q, forwardRef as ge, useMemo as D, useImperativeHandle as pe, Children as me, isValidElement as ye, useState as ie } from "react";
|
|
4
|
+
import { flushSync as R } from "react-dom";
|
|
5
|
+
import { createRoot as S } from "react-dom/client";
|
|
6
|
+
import { c as he } from "./chunks/feature-registry-Y3KvnN54.js";
|
|
7
|
+
function we(r) {
|
|
8
|
+
return r.charAt(0).toUpperCase() + r.slice(1);
|
|
16
9
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (c) {
|
|
33
|
-
L.delete(c);
|
|
34
|
-
const d = c.closest("tbw-grid");
|
|
35
|
-
if (d) {
|
|
36
|
-
const h = d.id || d.getAttribute("data-grid-id");
|
|
37
|
-
h && N.delete(h);
|
|
38
|
-
}
|
|
39
|
-
const u = c.parentNode;
|
|
40
|
-
u && u.contains(c);
|
|
41
|
-
}
|
|
42
|
-
}, []), /* @__PURE__ */ x(
|
|
43
|
-
"tbw-grid-detail",
|
|
44
|
-
{
|
|
45
|
-
ref: s,
|
|
46
|
-
showExpandColumn: e ? void 0 : "false",
|
|
47
|
-
animation: r === !1 ? "false" : r
|
|
10
|
+
function se(r) {
|
|
11
|
+
return r.toLowerCase() === "id" ? "ID" : r.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").split(" ").filter(Boolean).map(we).join(" ");
|
|
12
|
+
}
|
|
13
|
+
const ve = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
|
|
14
|
+
function Ce(r) {
|
|
15
|
+
const t = r.lastIndexOf(":");
|
|
16
|
+
if (t > 0) {
|
|
17
|
+
const e = r.slice(t + 1).toLowerCase();
|
|
18
|
+
if (ve.has(e)) {
|
|
19
|
+
const n = r.slice(0, t);
|
|
20
|
+
return {
|
|
21
|
+
field: n,
|
|
22
|
+
header: se(n),
|
|
23
|
+
type: e
|
|
24
|
+
};
|
|
48
25
|
}
|
|
49
|
-
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
field: r,
|
|
29
|
+
header: se(r)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function Re(r) {
|
|
33
|
+
return r.map((t) => typeof t == "string" ? Ce(t) : t);
|
|
50
34
|
}
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
35
|
+
const z = {
|
|
36
|
+
onCellClick: "cell-click",
|
|
37
|
+
onRowClick: "row-click",
|
|
38
|
+
onCellActivate: "cell-activate",
|
|
39
|
+
onCellChange: "cell-change",
|
|
40
|
+
onCellCommit: "cell-commit",
|
|
41
|
+
onRowCommit: "row-commit",
|
|
42
|
+
onSortChange: "sort-change",
|
|
43
|
+
onFilterChange: "filter-change",
|
|
44
|
+
onColumnResize: "column-resize",
|
|
45
|
+
onColumnMove: "column-move",
|
|
46
|
+
onColumnVisibility: "column-visibility",
|
|
47
|
+
onColumnStateChange: "column-state-change",
|
|
48
|
+
onSelectionChange: "selection-change",
|
|
49
|
+
onRowMove: "row-move",
|
|
50
|
+
onGroupToggle: "group-toggle",
|
|
51
|
+
onTreeExpand: "tree-expand",
|
|
52
|
+
onDetailExpand: "detail-expand",
|
|
53
|
+
onResponsiveChange: "responsive-change",
|
|
54
|
+
onCopy: "copy",
|
|
55
|
+
onPaste: "paste",
|
|
56
|
+
onUndoRedo: "undo-redo",
|
|
57
|
+
onExportComplete: "export-complete",
|
|
58
|
+
onPrintStart: "print-start",
|
|
59
|
+
onPrintComplete: "print-complete"
|
|
60
|
+
}, W = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new Map();
|
|
61
|
+
function le(r) {
|
|
62
|
+
const t = r.querySelector("tbw-grid-responsive-card");
|
|
54
63
|
if (t) {
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
64
|
+
const n = W.get(t);
|
|
65
|
+
if (n) return n;
|
|
57
66
|
}
|
|
58
|
-
const e =
|
|
67
|
+
const e = r.id || r.getAttribute("data-grid-id");
|
|
59
68
|
if (e)
|
|
60
|
-
return
|
|
69
|
+
return $.get(e);
|
|
61
70
|
}
|
|
62
|
-
function
|
|
63
|
-
const { children: t, cardRowHeight: e = "auto" } =
|
|
64
|
-
(
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
+
function be(r) {
|
|
72
|
+
const { children: t, cardRowHeight: e = "auto" } = r, n = P(null), o = h(
|
|
73
|
+
(i) => {
|
|
74
|
+
if (n.current = i, !i) return;
|
|
75
|
+
W.set(i, t);
|
|
76
|
+
const s = i.closest("tbw-grid");
|
|
77
|
+
if (s) {
|
|
78
|
+
const l = s.id || s.getAttribute("data-grid-id");
|
|
79
|
+
l && $.set(l, t);
|
|
71
80
|
}
|
|
72
81
|
},
|
|
73
82
|
[t]
|
|
74
83
|
);
|
|
75
84
|
w(() => () => {
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
const
|
|
82
|
-
|
|
85
|
+
const i = n.current;
|
|
86
|
+
if (i) {
|
|
87
|
+
W.delete(i);
|
|
88
|
+
const s = i.closest("tbw-grid");
|
|
89
|
+
if (s) {
|
|
90
|
+
const l = s.id || s.getAttribute("data-grid-id");
|
|
91
|
+
l && $.delete(l);
|
|
83
92
|
}
|
|
84
93
|
}
|
|
85
94
|
}, []);
|
|
86
|
-
const
|
|
87
|
-
return /* @__PURE__ */
|
|
95
|
+
const a = e === "auto" ? "auto" : String(e);
|
|
96
|
+
return /* @__PURE__ */ I("tbw-grid-responsive-card", { ref: o, cardRowHeight: a });
|
|
88
97
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
be.displayName = "GridResponsiveCard";
|
|
99
|
+
const H = fe(null), Je = ({ defaults: r, children: t }) => /* @__PURE__ */ I(H.Provider, { value: r, children: t });
|
|
100
|
+
function Ue() {
|
|
101
|
+
return Q(H);
|
|
92
102
|
}
|
|
93
|
-
function
|
|
94
|
-
return
|
|
103
|
+
function Ke(r) {
|
|
104
|
+
return Q(H)?.[r];
|
|
95
105
|
}
|
|
96
|
-
const
|
|
97
|
-
function
|
|
106
|
+
const Ee = H;
|
|
107
|
+
function Se(r) {
|
|
98
108
|
const t = /* @__PURE__ */ new WeakMap();
|
|
99
109
|
return (e) => {
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
}),
|
|
110
|
+
const n = e.cellEl;
|
|
111
|
+
if (n) {
|
|
112
|
+
const i = t.get(n);
|
|
113
|
+
if (i)
|
|
114
|
+
return R(() => {
|
|
115
|
+
i.root.render(r(e));
|
|
116
|
+
}), i.container;
|
|
107
117
|
}
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
return
|
|
112
|
-
|
|
113
|
-
}),
|
|
118
|
+
const o = document.createElement("div");
|
|
119
|
+
o.className = "react-cell-renderer", o.style.display = "contents";
|
|
120
|
+
const a = S(o);
|
|
121
|
+
return R(() => {
|
|
122
|
+
a.render(r(e));
|
|
123
|
+
}), n && t.set(n, { root: a, container: o }), o;
|
|
114
124
|
};
|
|
115
125
|
}
|
|
116
|
-
function
|
|
126
|
+
function xe(r) {
|
|
117
127
|
return (t) => {
|
|
118
128
|
const e = document.createElement("div");
|
|
119
129
|
e.className = "react-cell-editor", e.style.display = "contents";
|
|
120
|
-
const
|
|
121
|
-
return
|
|
122
|
-
|
|
130
|
+
const n = S(e);
|
|
131
|
+
return R(() => {
|
|
132
|
+
n.render(r(t));
|
|
123
133
|
}), e;
|
|
124
134
|
};
|
|
125
135
|
}
|
|
126
|
-
function
|
|
127
|
-
if (!
|
|
128
|
-
if (!
|
|
129
|
-
const t =
|
|
130
|
-
const { renderer:
|
|
131
|
-
return
|
|
136
|
+
function De(r) {
|
|
137
|
+
if (!r) return;
|
|
138
|
+
if (!r.columns) return r;
|
|
139
|
+
const t = r.columns.map((e) => {
|
|
140
|
+
const { renderer: n, editor: o, ...a } = e, i = { ...a };
|
|
141
|
+
return n && (i.renderer = Se(n)), o && (i.editor = xe(o)), i;
|
|
132
142
|
});
|
|
133
143
|
return {
|
|
134
|
-
...
|
|
144
|
+
...r,
|
|
135
145
|
columns: t
|
|
136
146
|
};
|
|
137
147
|
}
|
|
138
|
-
const
|
|
139
|
-
function
|
|
140
|
-
const t =
|
|
148
|
+
const J = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new Map();
|
|
149
|
+
function Pe(r) {
|
|
150
|
+
const t = r.querySelector("tbw-grid-detail");
|
|
151
|
+
if (t) {
|
|
152
|
+
const n = J.get(t);
|
|
153
|
+
if (n) return n;
|
|
154
|
+
}
|
|
155
|
+
const e = r.id || r.getAttribute("data-grid-id");
|
|
156
|
+
if (e)
|
|
157
|
+
return U.get(e);
|
|
158
|
+
}
|
|
159
|
+
function Ge(r) {
|
|
160
|
+
const { children: t, showExpandColumn: e = !0, animation: n = "slide" } = r, o = P(null), a = h(
|
|
161
|
+
(s) => {
|
|
162
|
+
if (o.current = s, !s) return;
|
|
163
|
+
J.set(s, t);
|
|
164
|
+
const l = s.closest("tbw-grid");
|
|
165
|
+
if (l) {
|
|
166
|
+
const m = l.id || l.getAttribute("data-grid-id");
|
|
167
|
+
m && U.set(m, t);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
[t]
|
|
171
|
+
);
|
|
172
|
+
return w(() => () => {
|
|
173
|
+
const s = o.current;
|
|
174
|
+
if (s) {
|
|
175
|
+
J.delete(s);
|
|
176
|
+
const l = s.closest("tbw-grid");
|
|
177
|
+
if (l) {
|
|
178
|
+
const v = l.id || l.getAttribute("data-grid-id");
|
|
179
|
+
v && U.delete(v);
|
|
180
|
+
}
|
|
181
|
+
const m = s.parentNode;
|
|
182
|
+
m && m.contains(s);
|
|
183
|
+
}
|
|
184
|
+
}, []), /* @__PURE__ */ I(
|
|
185
|
+
"tbw-grid-detail",
|
|
186
|
+
{
|
|
187
|
+
ref: a,
|
|
188
|
+
showExpandColumn: e ? void 0 : "false",
|
|
189
|
+
animation: n === !1 ? "false" : n
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
Ge.displayName = "GridDetailPanel";
|
|
194
|
+
const K = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new Map();
|
|
195
|
+
function Ae(r) {
|
|
196
|
+
const t = K.get(r);
|
|
141
197
|
if (t) return t;
|
|
142
|
-
const e =
|
|
198
|
+
const e = r.id;
|
|
143
199
|
if (e)
|
|
144
|
-
return
|
|
200
|
+
return Y.get(e);
|
|
145
201
|
}
|
|
146
|
-
function
|
|
147
|
-
const { id: t, title: e, icon:
|
|
148
|
-
(
|
|
149
|
-
|
|
202
|
+
function Ye(r) {
|
|
203
|
+
const { id: t, title: e, icon: n, tooltip: o, order: a = 100, children: i } = r, s = P(null), l = h(
|
|
204
|
+
(m) => {
|
|
205
|
+
s.current = m, m && (K.set(m, i), t && Y.set(t, i));
|
|
150
206
|
},
|
|
151
|
-
[
|
|
207
|
+
[i, t]
|
|
152
208
|
);
|
|
153
209
|
return w(() => () => {
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
}, [t]), /* @__PURE__ */
|
|
210
|
+
const m = s.current;
|
|
211
|
+
m && (K.delete(m), t && Y.delete(t));
|
|
212
|
+
}, [t]), /* @__PURE__ */ I(
|
|
157
213
|
"tbw-grid-tool-panel",
|
|
158
214
|
{
|
|
159
|
-
ref:
|
|
215
|
+
ref: l,
|
|
160
216
|
id: t,
|
|
161
217
|
title: e,
|
|
162
|
-
icon:
|
|
163
|
-
tooltip:
|
|
164
|
-
order:
|
|
218
|
+
icon: n,
|
|
219
|
+
tooltip: o,
|
|
220
|
+
order: a?.toString()
|
|
165
221
|
}
|
|
166
222
|
);
|
|
167
223
|
}
|
|
168
|
-
const G = /* @__PURE__ */ new WeakMap(),
|
|
169
|
-
function
|
|
170
|
-
const e =
|
|
171
|
-
if (
|
|
172
|
-
const
|
|
173
|
-
|
|
224
|
+
const G = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new Map();
|
|
225
|
+
function Ne(r, t) {
|
|
226
|
+
const e = r.getAttribute("field"), n = G.get(r) ?? {};
|
|
227
|
+
if (n.renderer = t, G.set(r, n), e) {
|
|
228
|
+
const o = N.get(e) ?? {};
|
|
229
|
+
o.renderer = t, N.set(e, o);
|
|
174
230
|
}
|
|
175
231
|
}
|
|
176
|
-
function
|
|
177
|
-
const e =
|
|
178
|
-
if (
|
|
179
|
-
const
|
|
180
|
-
|
|
232
|
+
function Ie(r, t) {
|
|
233
|
+
const e = r.getAttribute("field"), n = G.get(r) ?? {};
|
|
234
|
+
if (n.editor = t, G.set(r, n), e) {
|
|
235
|
+
const o = N.get(e) ?? {};
|
|
236
|
+
o.editor = t, N.set(e, o);
|
|
181
237
|
}
|
|
182
238
|
}
|
|
183
|
-
function
|
|
184
|
-
let t = G.get(
|
|
239
|
+
function Te(r) {
|
|
240
|
+
let t = G.get(r)?.renderer;
|
|
185
241
|
if (!t) {
|
|
186
|
-
const e =
|
|
187
|
-
e && (t =
|
|
242
|
+
const e = r.getAttribute("field");
|
|
243
|
+
e && (t = N.get(e)?.renderer);
|
|
188
244
|
}
|
|
189
245
|
return t;
|
|
190
246
|
}
|
|
191
|
-
function
|
|
192
|
-
let t = G.get(
|
|
247
|
+
function Ve(r) {
|
|
248
|
+
let t = G.get(r)?.editor;
|
|
193
249
|
if (!t) {
|
|
194
|
-
const e =
|
|
195
|
-
e && (t =
|
|
250
|
+
const e = r.getAttribute("field");
|
|
251
|
+
e && (t = N.get(e)?.editor);
|
|
196
252
|
}
|
|
197
253
|
return t;
|
|
198
254
|
}
|
|
199
|
-
|
|
200
|
-
return Array.from(k.keys());
|
|
201
|
-
}
|
|
202
|
-
class ce {
|
|
255
|
+
class ke {
|
|
203
256
|
mountedViews = [];
|
|
204
257
|
typeDefaults = null;
|
|
205
258
|
/**
|
|
@@ -217,13 +270,13 @@ class ce {
|
|
|
217
270
|
*/
|
|
218
271
|
canHandle(t) {
|
|
219
272
|
const e = t.getAttribute("field");
|
|
220
|
-
let
|
|
221
|
-
if (!
|
|
222
|
-
const
|
|
223
|
-
|
|
273
|
+
let n = G.get(t);
|
|
274
|
+
if (!n && e) {
|
|
275
|
+
const i = N.get(e);
|
|
276
|
+
i && (i.renderer || i.editor) && (n = i, G.set(t, n));
|
|
224
277
|
}
|
|
225
|
-
const
|
|
226
|
-
return
|
|
278
|
+
const o = n?.renderer !== void 0, a = n?.editor !== void 0;
|
|
279
|
+
return n !== void 0 && (o || a);
|
|
227
280
|
}
|
|
228
281
|
/**
|
|
229
282
|
* Creates a view renderer function that renders a React component
|
|
@@ -237,31 +290,31 @@ class ce {
|
|
|
237
290
|
* allowing the grid to use its default rendering.
|
|
238
291
|
*/
|
|
239
292
|
createRenderer(t) {
|
|
240
|
-
const e =
|
|
293
|
+
const e = Te(t);
|
|
241
294
|
if (!e)
|
|
242
295
|
return;
|
|
243
|
-
const
|
|
244
|
-
return (
|
|
245
|
-
const
|
|
246
|
-
if (
|
|
247
|
-
const
|
|
248
|
-
if (
|
|
249
|
-
return
|
|
250
|
-
|
|
251
|
-
}),
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
return
|
|
256
|
-
|
|
257
|
-
}),
|
|
296
|
+
const n = /* @__PURE__ */ new WeakMap();
|
|
297
|
+
return (o) => {
|
|
298
|
+
const a = o.cellEl;
|
|
299
|
+
if (a) {
|
|
300
|
+
const l = n.get(a);
|
|
301
|
+
if (l)
|
|
302
|
+
return R(() => {
|
|
303
|
+
l.root.render(e(o));
|
|
304
|
+
}), l.container;
|
|
305
|
+
const m = document.createElement("div");
|
|
306
|
+
m.className = "react-cell-renderer", m.style.display = "contents";
|
|
307
|
+
const v = S(m);
|
|
308
|
+
return R(() => {
|
|
309
|
+
v.render(e(o));
|
|
310
|
+
}), n.set(a, { root: v, container: m, lastRowIndex: o.rowIndex ?? -1 }), this.mountedViews.push({ root: v, container: m }), m;
|
|
258
311
|
}
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
}), this.mountedViews.push({ root:
|
|
312
|
+
const i = document.createElement("div");
|
|
313
|
+
i.className = "react-cell-renderer", i.style.display = "contents";
|
|
314
|
+
const s = S(i);
|
|
315
|
+
return R(() => {
|
|
316
|
+
s.render(e(o));
|
|
317
|
+
}), this.mountedViews.push({ root: s, container: i }), i;
|
|
265
318
|
};
|
|
266
319
|
}
|
|
267
320
|
/**
|
|
@@ -269,14 +322,14 @@ class ce {
|
|
|
269
322
|
* with commit/cancel callbacks passed as props.
|
|
270
323
|
*/
|
|
271
324
|
createEditor(t) {
|
|
272
|
-
const e =
|
|
273
|
-
return e ? (
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
return
|
|
278
|
-
|
|
279
|
-
}), this.mountedViews.push({ root:
|
|
325
|
+
const e = Ve(t);
|
|
326
|
+
return e ? (n) => {
|
|
327
|
+
const o = document.createElement("div");
|
|
328
|
+
o.className = "react-cell-editor", o.style.display = "contents";
|
|
329
|
+
const a = S(o);
|
|
330
|
+
return R(() => {
|
|
331
|
+
a.render(e(n));
|
|
332
|
+
}), this.mountedViews.push({ root: a, container: o }), o;
|
|
280
333
|
} : () => document.createElement("div");
|
|
281
334
|
}
|
|
282
335
|
/**
|
|
@@ -284,15 +337,15 @@ class ce {
|
|
|
284
337
|
* Renders React components for expandable detail rows.
|
|
285
338
|
*/
|
|
286
339
|
createDetailRenderer(t) {
|
|
287
|
-
const e =
|
|
340
|
+
const e = Pe(t);
|
|
288
341
|
if (e)
|
|
289
|
-
return (
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
return
|
|
294
|
-
|
|
295
|
-
}), this.mountedViews.push({ root:
|
|
342
|
+
return (n, o) => {
|
|
343
|
+
const a = document.createElement("div");
|
|
344
|
+
a.className = "react-detail-panel";
|
|
345
|
+
const i = { row: n, rowIndex: o }, s = S(a);
|
|
346
|
+
return R(() => {
|
|
347
|
+
s.render(e(i));
|
|
348
|
+
}), this.mountedViews.push({ root: s, container: a }), a;
|
|
296
349
|
};
|
|
297
350
|
}
|
|
298
351
|
/**
|
|
@@ -309,15 +362,15 @@ class ce {
|
|
|
309
362
|
* Renders React components for card layout in responsive mode.
|
|
310
363
|
*/
|
|
311
364
|
createResponsiveCardRenderer(t) {
|
|
312
|
-
const e =
|
|
365
|
+
const e = le(t);
|
|
313
366
|
if (e)
|
|
314
|
-
return (
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
const
|
|
318
|
-
return
|
|
319
|
-
|
|
320
|
-
}), this.mountedViews.push({ root:
|
|
367
|
+
return (n, o) => {
|
|
368
|
+
const a = document.createElement("div");
|
|
369
|
+
a.className = "react-responsive-card";
|
|
370
|
+
const i = { row: n, index: o }, s = S(a);
|
|
371
|
+
return R(() => {
|
|
372
|
+
s.render(e(i));
|
|
373
|
+
}), this.mountedViews.push({ root: s, container: a }), a;
|
|
321
374
|
};
|
|
322
375
|
}
|
|
323
376
|
/**
|
|
@@ -325,25 +378,25 @@ class ce {
|
|
|
325
378
|
* Renders React components into tool panel containers.
|
|
326
379
|
*/
|
|
327
380
|
createToolPanelRenderer(t) {
|
|
328
|
-
const e =
|
|
381
|
+
const e = Ae(t);
|
|
329
382
|
if (!e)
|
|
330
383
|
return;
|
|
331
|
-
const
|
|
332
|
-
return (
|
|
333
|
-
const
|
|
334
|
-
grid:
|
|
335
|
-
},
|
|
336
|
-
return
|
|
337
|
-
|
|
338
|
-
}), this.mountedViews.push({ root:
|
|
339
|
-
const
|
|
340
|
-
if (
|
|
341
|
-
const { root:
|
|
384
|
+
const n = t.closest("tbw-grid");
|
|
385
|
+
return (o) => {
|
|
386
|
+
const a = {
|
|
387
|
+
grid: n ?? o
|
|
388
|
+
}, i = S(o);
|
|
389
|
+
return R(() => {
|
|
390
|
+
i.render(e(a));
|
|
391
|
+
}), this.mountedViews.push({ root: i, container: o }), () => {
|
|
392
|
+
const s = this.mountedViews.findIndex((l) => l.container === o);
|
|
393
|
+
if (s !== -1) {
|
|
394
|
+
const { root: l } = this.mountedViews[s];
|
|
342
395
|
try {
|
|
343
|
-
|
|
396
|
+
l.unmount();
|
|
344
397
|
} catch {
|
|
345
398
|
}
|
|
346
|
-
this.mountedViews.splice(
|
|
399
|
+
this.mountedViews.splice(s, 1);
|
|
347
400
|
}
|
|
348
401
|
};
|
|
349
402
|
};
|
|
@@ -378,10 +431,10 @@ class ce {
|
|
|
378
431
|
const e = this.typeDefaults[t];
|
|
379
432
|
if (!e)
|
|
380
433
|
return;
|
|
381
|
-
const
|
|
434
|
+
const n = {
|
|
382
435
|
editorParams: e.editorParams
|
|
383
436
|
};
|
|
384
|
-
return e.renderer && (
|
|
437
|
+
return e.renderer && (n.renderer = this.createTypeRenderer(e.renderer)), e.editor && (n.editor = this.createTypeEditor(e.editor)), n;
|
|
385
438
|
}
|
|
386
439
|
/**
|
|
387
440
|
* Creates a renderer function from a React render function for type defaults.
|
|
@@ -389,12 +442,12 @@ class ce {
|
|
|
389
442
|
*/
|
|
390
443
|
createTypeRenderer(t) {
|
|
391
444
|
return (e) => {
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
return this.mountedViews.push({ root:
|
|
396
|
-
|
|
397
|
-
}),
|
|
445
|
+
const n = document.createElement("span");
|
|
446
|
+
n.style.display = "contents";
|
|
447
|
+
const o = S(n);
|
|
448
|
+
return this.mountedViews.push({ root: o, container: n }), R(() => {
|
|
449
|
+
o.render(t(e));
|
|
450
|
+
}), n;
|
|
398
451
|
};
|
|
399
452
|
}
|
|
400
453
|
/**
|
|
@@ -403,12 +456,12 @@ class ce {
|
|
|
403
456
|
*/
|
|
404
457
|
createTypeEditor(t) {
|
|
405
458
|
return (e) => {
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
const
|
|
409
|
-
return this.mountedViews.push({ root:
|
|
410
|
-
|
|
411
|
-
}),
|
|
459
|
+
const n = document.createElement("span");
|
|
460
|
+
n.style.display = "contents";
|
|
461
|
+
const o = S(n);
|
|
462
|
+
return this.mountedViews.push({ root: o, container: n }), R(() => {
|
|
463
|
+
o.render(t(e));
|
|
464
|
+
}), n;
|
|
412
465
|
};
|
|
413
466
|
}
|
|
414
467
|
/**
|
|
@@ -427,229 +480,323 @@ class ce {
|
|
|
427
480
|
* Unmount a specific container (called when cell is recycled).
|
|
428
481
|
*/
|
|
429
482
|
unmount(t) {
|
|
430
|
-
const e = this.mountedViews.findIndex((
|
|
483
|
+
const e = this.mountedViews.findIndex((n) => n.container === t);
|
|
431
484
|
if (e !== -1) {
|
|
432
|
-
const { root:
|
|
485
|
+
const { root: n } = this.mountedViews[e];
|
|
433
486
|
try {
|
|
434
|
-
|
|
487
|
+
n.unmount();
|
|
435
488
|
} catch {
|
|
436
489
|
}
|
|
437
490
|
this.mountedViews.splice(e, 1);
|
|
438
491
|
}
|
|
439
492
|
}
|
|
440
493
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
494
|
+
const Fe = {
|
|
495
|
+
undoRedo: ["editing"],
|
|
496
|
+
clipboard: ["selection"]
|
|
497
|
+
};
|
|
498
|
+
function Me(r) {
|
|
499
|
+
const t = new Set(r);
|
|
500
|
+
for (const e of r) {
|
|
501
|
+
const n = Fe[e];
|
|
502
|
+
if (n)
|
|
503
|
+
for (const o of n)
|
|
504
|
+
t.has(o) || console.warn(
|
|
505
|
+
`[DataGrid] Feature "${e}" requires "${o}" to be enabled. Add the "${o}" prop to your DataGrid.`
|
|
506
|
+
);
|
|
507
|
+
}
|
|
444
508
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
509
|
+
function Le(r) {
|
|
510
|
+
const t = [], e = [], n = { ...r };
|
|
511
|
+
n.multiSort !== void 0 ? delete n.sorting : n.sorting !== void 0 && (n.multiSort = n.sorting, delete n.sorting);
|
|
512
|
+
for (const [i, s] of Object.entries(n)) {
|
|
513
|
+
if (s === void 0 || s === !1) continue;
|
|
514
|
+
const l = i;
|
|
515
|
+
e.push(l);
|
|
451
516
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
plugins: [...D, l]
|
|
467
|
-
};
|
|
468
|
-
}).catch(() => {
|
|
469
|
-
});
|
|
517
|
+
Me(e);
|
|
518
|
+
const o = [
|
|
519
|
+
"selection",
|
|
520
|
+
"editing",
|
|
521
|
+
// Then everything else in the order they were specified
|
|
522
|
+
...e.filter((i) => i !== "selection" && i !== "editing")
|
|
523
|
+
], a = [...new Set(o)].filter((i) => e.includes(i));
|
|
524
|
+
for (const i of a) {
|
|
525
|
+
const s = r[i];
|
|
526
|
+
if (s === void 0 || s === !1) continue;
|
|
527
|
+
const l = he(i, s);
|
|
528
|
+
l && t.push(l);
|
|
529
|
+
}
|
|
530
|
+
return t;
|
|
470
531
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
532
|
+
let ce = !1, _ = null;
|
|
533
|
+
function Z() {
|
|
534
|
+
return ce || (_ = new ke(), ue.registerAdapter(_), ce = !0), _;
|
|
535
|
+
}
|
|
536
|
+
Z();
|
|
537
|
+
function Oe(r) {
|
|
538
|
+
const e = r.getPluginByName?.("masterDetail");
|
|
539
|
+
e && typeof e.refreshDetailRenderer == "function" && e.refreshDetailRenderer();
|
|
540
|
+
}
|
|
541
|
+
function Be(r, t) {
|
|
542
|
+
const e = r;
|
|
543
|
+
if (!r.querySelector("tbw-grid-responsive-card") || !le(r)) return;
|
|
544
|
+
const a = e.getPluginByName?.("responsive");
|
|
545
|
+
if (a && typeof a.setCardRenderer == "function") {
|
|
546
|
+
const i = t.createResponsiveCardRenderer(r);
|
|
547
|
+
i && a.setCardRenderer(i);
|
|
479
548
|
}
|
|
480
|
-
console.warn(
|
|
481
|
-
`[tbw-grid-react] <GridResponsiveCard> found but ResponsivePlugin is not configured.
|
|
482
|
-
Add ResponsivePlugin to your gridConfig.plugins array:
|
|
483
|
-
|
|
484
|
-
import { ResponsivePlugin } from "@toolbox-web/grid/all";
|
|
485
|
-
const config = {
|
|
486
|
-
plugins: [new ResponsivePlugin({ breakpoint: 500 })],
|
|
487
|
-
};`
|
|
488
|
-
);
|
|
489
549
|
}
|
|
490
|
-
|
|
550
|
+
function je(r) {
|
|
551
|
+
const t = {};
|
|
552
|
+
return me.forEach(r, (e) => {
|
|
553
|
+
if (ye(e)) {
|
|
554
|
+
if (e.type && e.type.displayName === "GridDetailPanel") {
|
|
555
|
+
const n = e.props;
|
|
556
|
+
t.masterDetail = {
|
|
557
|
+
// Use props from the child component for configuration
|
|
558
|
+
showExpandColumn: n.showExpandColumn ?? !0,
|
|
559
|
+
animation: n.animation ?? "slide"
|
|
560
|
+
// detailRenderer will be wired up by refreshMasterDetailRenderer after mount
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
e.type && e.type.displayName === "GridResponsiveCard" && (t.responsive = !0);
|
|
564
|
+
}
|
|
565
|
+
}), t;
|
|
566
|
+
}
|
|
567
|
+
const Ze = ge(function(t, e) {
|
|
491
568
|
const {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
569
|
+
// Core props
|
|
570
|
+
rows: n,
|
|
571
|
+
gridConfig: o,
|
|
572
|
+
columns: a,
|
|
573
|
+
columnDefaults: i,
|
|
574
|
+
fitMode: s,
|
|
575
|
+
sortable: l,
|
|
576
|
+
filterable: m,
|
|
577
|
+
selectable: v,
|
|
578
|
+
editOn: x,
|
|
579
|
+
customStyles: b,
|
|
580
|
+
className: M,
|
|
581
|
+
style: T,
|
|
582
|
+
children: A,
|
|
583
|
+
// Plugin props
|
|
584
|
+
plugins: E,
|
|
585
|
+
// SSR mode
|
|
586
|
+
ssr: f,
|
|
587
|
+
// Legacy event handlers
|
|
501
588
|
onRowsChange: p,
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
589
|
+
// Feature props and event props are in ...rest
|
|
590
|
+
...g
|
|
591
|
+
} = t, u = P(null), V = P(null), k = Q(Ee), X = [
|
|
592
|
+
"selection",
|
|
593
|
+
"editing",
|
|
594
|
+
"filtering",
|
|
595
|
+
"multiSort",
|
|
596
|
+
"sorting",
|
|
597
|
+
// deprecated alias for multiSort
|
|
598
|
+
"clipboard",
|
|
599
|
+
"contextMenu",
|
|
600
|
+
"reorder",
|
|
601
|
+
"rowReorder",
|
|
602
|
+
"visibility",
|
|
603
|
+
"undoRedo",
|
|
604
|
+
"tree",
|
|
605
|
+
"groupingRows",
|
|
606
|
+
"groupingColumns",
|
|
607
|
+
"pinnedColumns",
|
|
608
|
+
"pinnedRows",
|
|
609
|
+
"masterDetail",
|
|
610
|
+
"responsive",
|
|
611
|
+
"columnVirtualization",
|
|
612
|
+
"export",
|
|
613
|
+
"print",
|
|
614
|
+
"pivot",
|
|
615
|
+
"serverSide"
|
|
616
|
+
], de = D(() => X.map((c) => {
|
|
617
|
+
const d = g[c];
|
|
618
|
+
return d !== void 0 ? `${c}:${JSON.stringify(d)}` : "";
|
|
619
|
+
}).filter(Boolean).join("|"), [g]), ee = D(() => {
|
|
620
|
+
const c = {};
|
|
621
|
+
for (const d of X)
|
|
622
|
+
d in g && g[d] !== void 0 && (c[d] = g[d]);
|
|
623
|
+
return c;
|
|
624
|
+
}, [de]), te = D(() => je(A), [A]), re = D(() => ({ ...te, ...ee }), [ee, te]), q = D(() => E || f ? [] : Le(re), [re, E, f]), L = D(() => {
|
|
625
|
+
if (E) {
|
|
626
|
+
const c = new Set(E.map((y) => y.name)), d = q.filter((y) => !c.has(y.name));
|
|
627
|
+
return [...E, ...d];
|
|
628
|
+
}
|
|
629
|
+
return q;
|
|
630
|
+
}, [E, q]), O = D(() => {
|
|
631
|
+
if (!a) return a;
|
|
632
|
+
const c = Re(a);
|
|
633
|
+
return i ? c.map((d) => ({
|
|
634
|
+
...i,
|
|
635
|
+
...d
|
|
636
|
+
// Individual column props override defaults
|
|
637
|
+
})) : c;
|
|
638
|
+
}, [a, i]), B = D(() => {
|
|
639
|
+
const c = De(o), d = {};
|
|
640
|
+
if (l !== void 0 && (d.sortable = l), m !== void 0 && (d.filterable = m), v !== void 0 && (d.selectable = v), L.length > 0 && c) {
|
|
641
|
+
const y = c.plugins || [], C = new Set(y.map((F) => F.name)), j = L.filter((F) => !C.has(F.name));
|
|
642
|
+
return {
|
|
643
|
+
...c,
|
|
644
|
+
...d,
|
|
645
|
+
plugins: [...y, ...j]
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
return L.length > 0 && !c ? { ...d, plugins: L } : Object.keys(d).length > 0 ? { ...c, ...d } : c;
|
|
649
|
+
}, [o, L, l, m, v]);
|
|
650
|
+
w(() => {
|
|
651
|
+
Z().setTypeDefaults(k);
|
|
652
|
+
}, [k]), w(() => {
|
|
653
|
+
u.current && (u.current.rows = n);
|
|
654
|
+
}, [n]), w(() => {
|
|
655
|
+
u.current && B && (u.current.gridConfig = B);
|
|
656
|
+
}, [B]), w(() => {
|
|
657
|
+
u.current && O && (u.current.columns = O);
|
|
658
|
+
}, [O]), w(() => {
|
|
659
|
+
u.current && s !== void 0 && (u.current.fitMode = s);
|
|
515
660
|
}, [s]), w(() => {
|
|
516
|
-
|
|
517
|
-
}, [
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
const R = requestAnimationFrame(() => {
|
|
526
|
-
g || (typeof a.refreshColumns == "function" && a.refreshColumns(), typeof a.refreshShellHeader == "function" && a.refreshShellHeader());
|
|
661
|
+
u.current && x !== void 0 && (u.current.editOn = x);
|
|
662
|
+
}, [x]), w(() => {
|
|
663
|
+
const c = u.current;
|
|
664
|
+
if (!c) return;
|
|
665
|
+
const d = Z();
|
|
666
|
+
c.__frameworkAdapter = d, Oe(c), Be(c, d);
|
|
667
|
+
let y = !1;
|
|
668
|
+
const C = requestAnimationFrame(() => {
|
|
669
|
+
y || (typeof c.refreshColumns == "function" && c.refreshColumns(), typeof c.refreshShellHeader == "function" && c.refreshShellHeader());
|
|
527
670
|
});
|
|
528
671
|
return () => {
|
|
529
|
-
|
|
672
|
+
y = !0, cancelAnimationFrame(C);
|
|
530
673
|
};
|
|
531
674
|
}, []), w(() => {
|
|
532
|
-
if (!
|
|
533
|
-
const
|
|
534
|
-
let
|
|
535
|
-
return
|
|
536
|
-
|
|
675
|
+
if (!u.current || !b) return;
|
|
676
|
+
const c = u.current, d = "react-custom-styles";
|
|
677
|
+
let y = !0;
|
|
678
|
+
return c.ready?.().then(() => {
|
|
679
|
+
y && b && (c.registerStyles?.(d, b), V.current = d);
|
|
537
680
|
}), () => {
|
|
538
|
-
|
|
681
|
+
y = !1, V.current && (c.unregisterStyles?.(V.current), V.current = null);
|
|
539
682
|
};
|
|
540
|
-
}, [
|
|
541
|
-
const
|
|
542
|
-
if (!
|
|
543
|
-
const
|
|
683
|
+
}, [b]), w(() => {
|
|
684
|
+
const c = u.current;
|
|
685
|
+
if (!c) return;
|
|
686
|
+
const d = [];
|
|
544
687
|
if (p) {
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
if (D) {
|
|
549
|
-
const g = ((R) => D(R));
|
|
550
|
-
a.addEventListener("cell-edit", g), m.push(["cell-edit", g]);
|
|
551
|
-
}
|
|
552
|
-
if (A) {
|
|
553
|
-
const g = ((R) => A(R));
|
|
554
|
-
a.addEventListener("row-click", g), m.push(["row-click", g]);
|
|
555
|
-
}
|
|
556
|
-
if (P) {
|
|
557
|
-
const g = ((R) => P(R));
|
|
558
|
-
a.addEventListener("column-state-change", g), m.push(["column-state-change", g]);
|
|
559
|
-
}
|
|
560
|
-
if (I) {
|
|
561
|
-
const g = ((R) => I(R));
|
|
562
|
-
a.addEventListener("sort-change", g), m.push(["sort-change", g]);
|
|
688
|
+
const y = ((C) => p(C.detail.rows));
|
|
689
|
+
c.addEventListener("rows-change", y), d.push(["rows-change", y]);
|
|
563
690
|
}
|
|
564
691
|
return () => {
|
|
565
|
-
|
|
566
|
-
|
|
692
|
+
d.forEach(([y, C]) => {
|
|
693
|
+
c.removeEventListener(y, C);
|
|
567
694
|
});
|
|
568
695
|
};
|
|
569
|
-
}, [p
|
|
696
|
+
}, [p]);
|
|
697
|
+
const ne = D(() => Object.keys(z).filter((c) => typeof g[c] == "function").sort().join("|"), [g]), oe = P({});
|
|
698
|
+
for (const c of Object.keys(z))
|
|
699
|
+
oe.current[c] = g[c];
|
|
700
|
+
return w(() => {
|
|
701
|
+
const c = u.current;
|
|
702
|
+
if (!c) return;
|
|
703
|
+
const d = [];
|
|
704
|
+
for (const [y, C] of Object.entries(z))
|
|
705
|
+
if (ne.includes(y)) {
|
|
706
|
+
const j = ((F) => {
|
|
707
|
+
oe.current[y]?.(F.detail, F);
|
|
708
|
+
});
|
|
709
|
+
c.addEventListener(C, j), d.push([C, j]);
|
|
710
|
+
}
|
|
711
|
+
return () => {
|
|
712
|
+
d.forEach(([y, C]) => {
|
|
713
|
+
c.removeEventListener(y, C);
|
|
714
|
+
});
|
|
715
|
+
};
|
|
716
|
+
}, [ne]), pe(
|
|
570
717
|
e,
|
|
571
718
|
() => ({
|
|
572
719
|
get element() {
|
|
573
|
-
return
|
|
720
|
+
return u.current;
|
|
574
721
|
},
|
|
575
722
|
async getConfig() {
|
|
576
|
-
return
|
|
723
|
+
return u.current?.getConfig?.() ?? {};
|
|
577
724
|
},
|
|
578
725
|
async ready() {
|
|
579
|
-
return
|
|
726
|
+
return u.current?.ready?.();
|
|
580
727
|
},
|
|
581
728
|
async forceLayout() {
|
|
582
|
-
return
|
|
729
|
+
return u.current?.forceLayout?.();
|
|
583
730
|
},
|
|
584
|
-
async toggleGroup(
|
|
585
|
-
return
|
|
731
|
+
async toggleGroup(c) {
|
|
732
|
+
return u.current?.toggleGroup?.(c);
|
|
586
733
|
},
|
|
587
|
-
registerStyles(
|
|
588
|
-
|
|
734
|
+
registerStyles(c, d) {
|
|
735
|
+
u.current?.registerStyles?.(c, d);
|
|
589
736
|
},
|
|
590
|
-
unregisterStyles(
|
|
591
|
-
|
|
737
|
+
unregisterStyles(c) {
|
|
738
|
+
u.current?.unregisterStyles?.(c);
|
|
592
739
|
}
|
|
593
740
|
}),
|
|
594
741
|
[]
|
|
595
|
-
), /* @__PURE__ */
|
|
742
|
+
), /* @__PURE__ */ I(
|
|
596
743
|
"tbw-grid",
|
|
597
744
|
{
|
|
598
|
-
ref: (
|
|
599
|
-
if (
|
|
600
|
-
const
|
|
601
|
-
|
|
745
|
+
ref: (c) => {
|
|
746
|
+
if (u.current = c, c) {
|
|
747
|
+
const d = c;
|
|
748
|
+
B && (d.gridConfig = B), n && (d.rows = n), O && (d.columns = O);
|
|
602
749
|
}
|
|
603
750
|
},
|
|
604
|
-
class:
|
|
605
|
-
style:
|
|
606
|
-
children:
|
|
751
|
+
class: M,
|
|
752
|
+
style: T,
|
|
753
|
+
children: A
|
|
607
754
|
}
|
|
608
755
|
);
|
|
609
756
|
});
|
|
610
|
-
function
|
|
757
|
+
function Qe(r) {
|
|
611
758
|
const {
|
|
612
759
|
field: t,
|
|
613
760
|
header: e,
|
|
614
|
-
type:
|
|
615
|
-
editable:
|
|
616
|
-
sortable:
|
|
617
|
-
resizable:
|
|
618
|
-
width:
|
|
619
|
-
minWidth:
|
|
620
|
-
hidden:
|
|
621
|
-
lockVisible:
|
|
622
|
-
children:
|
|
623
|
-
editor:
|
|
624
|
-
options:
|
|
625
|
-
multi:
|
|
626
|
-
format:
|
|
627
|
-
} =
|
|
628
|
-
(
|
|
629
|
-
|
|
761
|
+
type: n,
|
|
762
|
+
editable: o,
|
|
763
|
+
sortable: a,
|
|
764
|
+
resizable: i,
|
|
765
|
+
width: s,
|
|
766
|
+
minWidth: l,
|
|
767
|
+
hidden: m,
|
|
768
|
+
lockVisible: v,
|
|
769
|
+
children: x,
|
|
770
|
+
editor: b,
|
|
771
|
+
options: M,
|
|
772
|
+
multi: T,
|
|
773
|
+
format: A
|
|
774
|
+
} = r, E = P(null), f = h(
|
|
775
|
+
(u) => {
|
|
776
|
+
E.current = u, u && (x && Ne(u, x), b && Ie(u, b));
|
|
630
777
|
},
|
|
631
|
-
[
|
|
632
|
-
),
|
|
778
|
+
[x, b, t]
|
|
779
|
+
), p = typeof s == "number" ? `${s}px` : s, g = {
|
|
633
780
|
field: t,
|
|
634
781
|
ref: f
|
|
635
782
|
};
|
|
636
|
-
return e !== void 0 && (
|
|
783
|
+
return e !== void 0 && (g.header = e), n !== void 0 && (g.type = n), o !== void 0 && (g.editable = o), a !== void 0 && (g.sortable = a), i !== void 0 && (g.resizable = i), p !== void 0 && (g.width = p), l !== void 0 && (g["min-width"] = l), m !== void 0 && (g.hidden = m), v !== void 0 && (g["lock-visible"] = v), T !== void 0 && (g.multi = T), A && (g["data-has-format"] = "true"), M && (g["data-has-options"] = "true"), /* @__PURE__ */ I("tbw-grid-column", { ...g });
|
|
637
784
|
}
|
|
638
|
-
function
|
|
639
|
-
return /* @__PURE__ */
|
|
785
|
+
function Xe({ children: r }) {
|
|
786
|
+
return /* @__PURE__ */ I("tbw-grid-tool-buttons", { children: r });
|
|
640
787
|
}
|
|
641
|
-
function
|
|
642
|
-
const
|
|
788
|
+
function et() {
|
|
789
|
+
const r = P(null), [t, e] = ie(!1), [n, o] = ie(null);
|
|
643
790
|
w(() => {
|
|
644
|
-
const
|
|
645
|
-
if (!
|
|
791
|
+
const f = r.current;
|
|
792
|
+
if (!f) return;
|
|
646
793
|
let p = !0;
|
|
647
794
|
return (async () => {
|
|
648
795
|
try {
|
|
649
|
-
if (await
|
|
796
|
+
if (await f.ready?.(), p) {
|
|
650
797
|
e(!0);
|
|
651
|
-
const
|
|
652
|
-
p &&
|
|
798
|
+
const u = await f.getConfig?.();
|
|
799
|
+
p && u && o(u);
|
|
653
800
|
}
|
|
654
801
|
} catch {
|
|
655
802
|
}
|
|
@@ -657,60 +804,108 @@ function De() {
|
|
|
657
804
|
p = !1;
|
|
658
805
|
};
|
|
659
806
|
}, []);
|
|
660
|
-
const
|
|
661
|
-
const
|
|
662
|
-
return
|
|
663
|
-
}, []),
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
}, []),
|
|
667
|
-
const p =
|
|
668
|
-
p && await p.toggleGroup?.(
|
|
669
|
-
}, []),
|
|
670
|
-
|
|
671
|
-
}, []),
|
|
672
|
-
|
|
673
|
-
}, []),
|
|
807
|
+
const a = h(async () => {
|
|
808
|
+
const f = r.current;
|
|
809
|
+
return f ? await f.getConfig?.() ?? null : null;
|
|
810
|
+
}, []), i = h(async () => {
|
|
811
|
+
const f = r.current;
|
|
812
|
+
f && await f.forceLayout?.();
|
|
813
|
+
}, []), s = h(async (f) => {
|
|
814
|
+
const p = r.current;
|
|
815
|
+
p && await p.toggleGroup?.(f);
|
|
816
|
+
}, []), l = h((f, p) => {
|
|
817
|
+
r.current?.registerStyles?.(f, p);
|
|
818
|
+
}, []), m = h((f) => {
|
|
819
|
+
r.current?.unregisterStyles?.(f);
|
|
820
|
+
}, []), v = h(() => n?.columns ? n.columns.filter((f) => !f.hidden) : [], [n]), x = h(() => {
|
|
821
|
+
const f = r.current?.element, p = f?.getPluginByName?.("selection");
|
|
822
|
+
if (!p) {
|
|
823
|
+
console.warn("[useGrid] selectAll requires SelectionPlugin");
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
if (p.config?.mode === "row") {
|
|
827
|
+
const g = f?.rows ?? [], u = new Set(g.map((V, k) => k));
|
|
828
|
+
p.selected = u, p.requestAfterRender?.();
|
|
829
|
+
}
|
|
830
|
+
}, []), b = h(() => {
|
|
831
|
+
const p = r.current?.element?.getPluginByName?.("selection");
|
|
832
|
+
p && p.clearSelection?.();
|
|
833
|
+
}, []), M = h(() => {
|
|
834
|
+
const p = r.current?.element?.getPluginByName?.("selection");
|
|
835
|
+
return p ? new Set(p.selected ?? []) : /* @__PURE__ */ new Set();
|
|
836
|
+
}, []), T = h(() => {
|
|
837
|
+
const f = r.current?.element, p = f?.getPluginByName?.("selection");
|
|
838
|
+
if (!p) return [];
|
|
839
|
+
const g = f?.rows ?? [], u = p.selected ?? /* @__PURE__ */ new Set();
|
|
840
|
+
return g.filter((V, k) => u.has(k));
|
|
841
|
+
}, []), A = h((f) => {
|
|
842
|
+
const g = r.current?.element?.getPluginByName?.("export");
|
|
843
|
+
if (!g) {
|
|
844
|
+
console.warn("[useGrid] exportToCsv requires ExportPlugin (use export prop)");
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
g.exportCsv?.({ filename: f ?? "export.csv" });
|
|
848
|
+
}, []), E = h((f) => {
|
|
849
|
+
const g = r.current?.element?.getPluginByName?.("export");
|
|
850
|
+
if (!g) {
|
|
851
|
+
console.warn("[useGrid] exportToJson requires ExportPlugin (use export prop)");
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
g.exportJson?.({ filename: f ?? "export.json" });
|
|
855
|
+
}, []);
|
|
674
856
|
return {
|
|
675
|
-
ref:
|
|
676
|
-
element:
|
|
857
|
+
ref: r,
|
|
858
|
+
element: r.current?.element ?? null,
|
|
677
859
|
isReady: t,
|
|
678
|
-
config:
|
|
679
|
-
getConfig:
|
|
680
|
-
forceLayout:
|
|
681
|
-
toggleGroup:
|
|
682
|
-
registerStyles:
|
|
683
|
-
unregisterStyles:
|
|
684
|
-
getVisibleColumns:
|
|
860
|
+
config: n,
|
|
861
|
+
getConfig: a,
|
|
862
|
+
forceLayout: i,
|
|
863
|
+
toggleGroup: s,
|
|
864
|
+
registerStyles: l,
|
|
865
|
+
unregisterStyles: m,
|
|
866
|
+
getVisibleColumns: v,
|
|
867
|
+
// Selection methods
|
|
868
|
+
selectAll: x,
|
|
869
|
+
clearSelection: b,
|
|
870
|
+
getSelectedIndices: M,
|
|
871
|
+
getSelectedRows: T,
|
|
872
|
+
// Export methods
|
|
873
|
+
exportToCsv: A,
|
|
874
|
+
exportToJson: E
|
|
685
875
|
};
|
|
686
876
|
}
|
|
687
|
-
|
|
688
|
-
|
|
877
|
+
let ae = !1;
|
|
878
|
+
function tt(r, t, e, n = []) {
|
|
879
|
+
!ae && typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes(".local")) && (ae = !0, console.warn(
|
|
880
|
+
`[useGridEvent] Deprecated: Use event props directly on DataGrid instead.
|
|
881
|
+
Example: <DataGrid onSelectionChange={(e) => ...} />
|
|
882
|
+
See migration guide: https://toolbox-web.dev/grid-react/migration`
|
|
883
|
+
));
|
|
884
|
+
const o = P(e);
|
|
689
885
|
w(() => {
|
|
690
|
-
|
|
691
|
-
}, [e, ...
|
|
692
|
-
const
|
|
693
|
-
if (!
|
|
694
|
-
const
|
|
695
|
-
|
|
886
|
+
o.current = e;
|
|
887
|
+
}, [e, ...n]), w(() => {
|
|
888
|
+
const a = r.current, i = a && "element" in a ? a.element : a;
|
|
889
|
+
if (!i) return;
|
|
890
|
+
const s = ((l) => {
|
|
891
|
+
o.current(l);
|
|
696
892
|
});
|
|
697
|
-
return
|
|
698
|
-
|
|
893
|
+
return i.addEventListener(t, s), () => {
|
|
894
|
+
i.removeEventListener(t, s);
|
|
699
895
|
};
|
|
700
|
-
}, [
|
|
896
|
+
}, [r, t]);
|
|
701
897
|
}
|
|
702
898
|
export {
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
Re as useTypeDefault
|
|
899
|
+
Ze as DataGrid,
|
|
900
|
+
Qe as GridColumn,
|
|
901
|
+
Ge as GridDetailPanel,
|
|
902
|
+
be as GridResponsiveCard,
|
|
903
|
+
Xe as GridToolButtons,
|
|
904
|
+
Ye as GridToolPanel,
|
|
905
|
+
Je as GridTypeProvider,
|
|
906
|
+
ke as ReactGridAdapter,
|
|
907
|
+
et as useGrid,
|
|
908
|
+
tt as useGridEvent,
|
|
909
|
+
Ue as useGridTypeDefaults,
|
|
910
|
+
Ke as useTypeDefault
|
|
716
911
|
};
|