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