@toolbox-web/grid-react 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/chunks/feature-registry-DKPyd2rV.js +2 -0
- package/chunks/{react-column-config-Cto2WHGC.js → react-column-config-CkBIwx2L.js} +1 -1
- package/chunks/{react-grid-adapter-C_TSA5_P.js → react-grid-adapter-DP9A9ytc.js} +131 -93
- package/chunks/use-grid-is-ready-Baa67cu3.js +15 -0
- package/features/editing.js +3 -3
- package/features/export.d.ts +6 -0
- package/features/export.d.ts.map +1 -1
- package/features/export.js +17 -15
- package/features/filtering.d.ts +6 -0
- package/features/filtering.d.ts.map +1 -1
- package/features/filtering.js +40 -38
- package/features/grouping-columns.js +1 -1
- package/features/grouping-rows.js +1 -1
- package/features/master-detail.js +2 -2
- package/features/pinned-rows.js +1 -1
- package/features/print.d.ts +6 -0
- package/features/print.d.ts.map +1 -1
- package/features/print.js +10 -8
- package/features/responsive.js +2 -2
- package/features/selection.d.ts +32 -0
- package/features/selection.d.ts.map +1 -1
- package/features/selection.js +35 -19
- package/features/undo-redo.d.ts +6 -0
- package/features/undo-redo.d.ts.map +1 -1
- package/features/undo-redo.js +38 -27
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -1
- package/index.js +242 -229
- package/lib/column-options.d.ts +33 -0
- package/lib/column-options.d.ts.map +1 -0
- package/lib/grid-column.d.ts +21 -11
- package/lib/grid-column.d.ts.map +1 -1
- package/lib/react-grid-adapter.d.ts +37 -1
- package/lib/react-grid-adapter.d.ts.map +1 -1
- package/lib/use-grid-is-ready.d.ts +9 -0
- package/lib/use-grid-is-ready.d.ts.map +1 -0
- package/lib/use-grid.d.ts +2 -0
- package/lib/use-grid.d.ts.map +1 -1
- package/package.json +1 -1
- package/chunks/feature-registry-8K2rOVnC.js +0 -2
package/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
5
|
-
import "./chunks/feature-registry-
|
|
6
|
-
import { t as
|
|
7
|
-
import { t as
|
|
8
|
-
import { t as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
1
|
+
import { a as e, d as t, f as n, h as r, i, l as a, m as o, n as s, p as c, r as l, t as u, u as d } from "./chunks/react-grid-adapter-DP9A9ytc.js";
|
|
2
|
+
import { a as f, i as p, o as m } from "./chunks/portal-bridge-zxgm_jwK.js";
|
|
3
|
+
import { n as h, t as g } from "./chunks/post-mount-refresh-hooks-D7BDK4Kl.js";
|
|
4
|
+
import { r as _, s as v } from "./chunks/react-column-config-CkBIwx2L.js";
|
|
5
|
+
import { a as y, i as b, n as x, o as S, r as C, t as w } from "./chunks/feature-registry-DKPyd2rV.js";
|
|
6
|
+
import { t as T } from "./chunks/grid-element-context-DpuQsoie.js";
|
|
7
|
+
import { t as E } from "./chunks/grid-detail-panel-CLdX0T_A.js";
|
|
8
|
+
import { t as D } from "./chunks/grid-responsive-card-Dx5U6Prm.js";
|
|
9
|
+
import { t as O } from "./chunks/use-grid-is-ready-Baa67cu3.js";
|
|
10
|
+
import { DataGridElement as ee, parseColumnShorthand as k } from "@toolbox-web/grid";
|
|
11
|
+
import { Component as A, createContext as j, createElement as te, forwardRef as M, useCallback as N, useContext as P, useEffect as F, useId as I, useImperativeHandle as ne, useLayoutEffect as re, useMemo as L, useReducer as R, useRef as z, useState as B } from "react";
|
|
12
|
+
import { Fragment as V, jsx as H, jsxs as ie } from "react/jsx-runtime";
|
|
13
|
+
import { createPortal as U, flushSync as W } from "react-dom";
|
|
14
|
+
import { createPluginsFromFeatures as G } from "@toolbox-web/grid/features/registry";
|
|
14
15
|
//#region libs/grid-react/src/lib/column-shorthand.ts
|
|
15
|
-
function
|
|
16
|
-
let { field: t, header: n, type: r } =
|
|
16
|
+
function K(e) {
|
|
17
|
+
let { field: t, header: n, type: r } = k(e);
|
|
17
18
|
return r === void 0 ? {
|
|
18
19
|
field: t,
|
|
19
20
|
header: n
|
|
@@ -23,21 +24,21 @@ function R(e) {
|
|
|
23
24
|
type: r
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
return e.map((e) => typeof e == "string" ?
|
|
27
|
+
function ae(e) {
|
|
28
|
+
return e.map((e) => typeof e == "string" ? K(e) : e);
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
+
function oe(e, t) {
|
|
30
31
|
return t ? e.map((e) => ({
|
|
31
32
|
...t,
|
|
32
33
|
...e
|
|
33
34
|
})) : e;
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
+
function q(e) {
|
|
36
37
|
return e.some((e) => typeof e == "string");
|
|
37
38
|
}
|
|
38
39
|
//#endregion
|
|
39
40
|
//#region libs/grid-react/src/lib/event-props.ts
|
|
40
|
-
var
|
|
41
|
+
var J = {
|
|
41
42
|
onCellClick: "cell-click",
|
|
42
43
|
onRowClick: "row-click",
|
|
43
44
|
onCellActivate: "cell-activate",
|
|
@@ -85,24 +86,24 @@ var H = {
|
|
|
85
86
|
onPrintComplete: "print-complete",
|
|
86
87
|
onTbwScroll: "tbw-scroll",
|
|
87
88
|
onRender: "render"
|
|
88
|
-
},
|
|
89
|
+
}, Y = j(null), se = ({ icons: e, children: t }) => /* @__PURE__ */ H(Y.Provider, {
|
|
89
90
|
value: e,
|
|
90
91
|
children: t
|
|
91
92
|
});
|
|
92
|
-
function
|
|
93
|
-
return
|
|
93
|
+
function ce() {
|
|
94
|
+
return P(Y);
|
|
94
95
|
}
|
|
95
|
-
var
|
|
96
|
+
var le = Y, X = j(null), ue = ({ defaults: e, children: t }) => /* @__PURE__ */ H(X.Provider, {
|
|
96
97
|
value: e,
|
|
97
98
|
children: t
|
|
98
99
|
});
|
|
99
|
-
function
|
|
100
|
-
return
|
|
100
|
+
function de() {
|
|
101
|
+
return P(X);
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
103
|
+
function fe(e) {
|
|
104
|
+
return P(X)?.[e];
|
|
104
105
|
}
|
|
105
|
-
var
|
|
106
|
+
var pe = X, me = class extends A {
|
|
106
107
|
state = { failed: !1 };
|
|
107
108
|
static getDerivedStateFromError() {
|
|
108
109
|
return { failed: !0 };
|
|
@@ -113,10 +114,10 @@ var ae = K, X = class extends S {
|
|
|
113
114
|
render() {
|
|
114
115
|
return this.state.failed ? null : this.props.children;
|
|
115
116
|
}
|
|
116
|
-
},
|
|
117
|
-
let n =
|
|
117
|
+
}, he = M(function(e, t) {
|
|
118
|
+
let n = z(/* @__PURE__ */ new Map()), [, r] = R((e) => e + 1, 0), i = z(!1), a = z(0), o = z(0), s = z(!1), c = z(!1), l = () => {
|
|
118
119
|
i.current || (i.current = !0, queueMicrotask(() => {
|
|
119
|
-
i.current = !1, !c.current && (
|
|
120
|
+
i.current = !1, !c.current && (W(r), u());
|
|
120
121
|
}));
|
|
121
122
|
}, u = () => {
|
|
122
123
|
a.current ||= requestAnimationFrame(() => {
|
|
@@ -125,7 +126,7 @@ var ae = K, X = class extends S {
|
|
|
125
126
|
}, d = (e, t) => {
|
|
126
127
|
console.error(`[grid-react] Portal "${e}" crashed; dropping.`, t), n.current.delete(e), u();
|
|
127
128
|
};
|
|
128
|
-
|
|
129
|
+
ne(t, () => ({
|
|
129
130
|
renderPortal(e, t, r) {
|
|
130
131
|
c.current || (n.current.set(e, {
|
|
131
132
|
container: t,
|
|
@@ -137,7 +138,7 @@ var ae = K, X = class extends S {
|
|
|
137
138
|
n.current.delete(e);
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
140
|
-
n.current.delete(e) && (o.current > 0 ? s.current = !0 : t ?
|
|
141
|
+
n.current.delete(e) && (o.current > 0 ? s.current = !0 : t ? W(r) : l());
|
|
141
142
|
},
|
|
142
143
|
beginBatch() {
|
|
143
144
|
o.current++;
|
|
@@ -152,7 +153,7 @@ var ae = K, X = class extends S {
|
|
|
152
153
|
}
|
|
153
154
|
n.current.size > 0 && (n.current.clear(), a.current &&= (cancelAnimationFrame(a.current), 0), l());
|
|
154
155
|
}
|
|
155
|
-
}), []),
|
|
156
|
+
}), []), re(() => {
|
|
156
157
|
c.current = !1;
|
|
157
158
|
let e = n.current;
|
|
158
159
|
return () => {
|
|
@@ -165,7 +166,7 @@ var ae = K, X = class extends S {
|
|
|
165
166
|
(p ??= []).push(e);
|
|
166
167
|
continue;
|
|
167
168
|
}
|
|
168
|
-
f.push(
|
|
169
|
+
f.push(U(/* @__PURE__ */ H(me, {
|
|
169
170
|
portalKey: e,
|
|
170
171
|
onError: d,
|
|
171
172
|
children: r
|
|
@@ -177,11 +178,11 @@ var ae = K, X = class extends S {
|
|
|
177
178
|
for (let t of e) n.current.delete(t);
|
|
178
179
|
});
|
|
179
180
|
}
|
|
180
|
-
return /* @__PURE__ */
|
|
181
|
+
return /* @__PURE__ */ H(V, { children: f });
|
|
181
182
|
});
|
|
182
183
|
//#endregion
|
|
183
184
|
//#region libs/grid-react/src/lib/row-diff.ts
|
|
184
|
-
function
|
|
185
|
+
function ge(e, t, n) {
|
|
185
186
|
if (t.length === 0 || e.length !== t.length) return null;
|
|
186
187
|
let r = [];
|
|
187
188
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -196,117 +197,117 @@ function se(e, t, n) {
|
|
|
196
197
|
}
|
|
197
198
|
//#endregion
|
|
198
199
|
//#region libs/grid-react/src/lib/use-sync-plugins.ts
|
|
199
|
-
var
|
|
200
|
+
var _e = {
|
|
200
201
|
undoRedo: ["editing"],
|
|
201
202
|
clipboard: ["selection"]
|
|
202
203
|
};
|
|
203
|
-
function
|
|
204
|
+
function ve(e) {
|
|
204
205
|
let t = new Set(e);
|
|
205
206
|
for (let n of e) {
|
|
206
|
-
let e =
|
|
207
|
+
let e = _e[n];
|
|
207
208
|
if (e) for (let r of e) t.has(r) || console.warn(`[DataGrid] Feature "${n}" requires "${r}" to be enabled. Add the "${r}" prop to your DataGrid.`);
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
|
-
function
|
|
211
|
+
function ye(e) {
|
|
211
212
|
let t = [];
|
|
212
213
|
for (let [n, r] of Object.entries(e)) r === void 0 || r === !1 || t.push(n);
|
|
213
|
-
return
|
|
214
|
+
return ve(t), G(e);
|
|
214
215
|
}
|
|
215
216
|
//#endregion
|
|
216
217
|
//#region libs/grid-react/src/lib/data-grid.tsx
|
|
217
|
-
var
|
|
218
|
-
function
|
|
219
|
-
return
|
|
218
|
+
var be = !1, Z = null;
|
|
219
|
+
function Q() {
|
|
220
|
+
return be ||= (Z = new u(), ee.registerAdapter(Z), !0), Z;
|
|
220
221
|
}
|
|
221
|
-
|
|
222
|
-
var
|
|
223
|
-
function
|
|
224
|
-
let t =
|
|
225
|
-
return t === void 0 && (t = ++
|
|
222
|
+
Q();
|
|
223
|
+
var xe = /* @__PURE__ */ new WeakMap(), Se = 0;
|
|
224
|
+
function Ce(e) {
|
|
225
|
+
let t = xe.get(e);
|
|
226
|
+
return t === void 0 && (t = ++Se, xe.set(e, t)), t;
|
|
226
227
|
}
|
|
227
|
-
|
|
228
|
+
r("GridDetailPanel", (e) => {
|
|
228
229
|
let t = e.props;
|
|
229
230
|
return { masterDetail: {
|
|
230
231
|
showExpandColumn: t.showExpandColumn ?? !0,
|
|
231
232
|
animation: t.animation ?? "slide"
|
|
232
233
|
} };
|
|
233
|
-
}),
|
|
234
|
-
var
|
|
235
|
-
let { rows: r, gridConfig: i, columns: a, columnDefaults:
|
|
236
|
-
let e = {}, t =
|
|
237
|
-
for (let
|
|
238
|
-
let
|
|
239
|
-
|
|
234
|
+
}), r("GridResponsiveCard", () => ({ responsive: !0 }));
|
|
235
|
+
var we = M(function(e, t) {
|
|
236
|
+
let { rows: r, gridConfig: i, columns: a, columnDefaults: s, fitMode: c, columnInference: l, sortable: u, filterable: d, selectable: f, loading: p, customStyles: h, className: v, style: y, children: b, plugins: x, onRowsChange: S, ...C } = e, w = z(null), E = z(null), D = z(!1), O = z([]), k = z(void 0), A = P(pe), j = P(le), M = L(() => {
|
|
237
|
+
let e = {}, t = C;
|
|
238
|
+
for (let r of n()) {
|
|
239
|
+
let n = t[r];
|
|
240
|
+
n !== void 0 && (e[r] = n);
|
|
240
241
|
}
|
|
241
242
|
return e;
|
|
242
|
-
}, [
|
|
243
|
-
let t =
|
|
243
|
+
}, [L(() => n().map((e) => {
|
|
244
|
+
let t = C[e];
|
|
244
245
|
if (t === void 0) return "";
|
|
245
246
|
let n;
|
|
246
247
|
try {
|
|
247
248
|
n = JSON.stringify(t) ?? "undefined";
|
|
248
249
|
} catch {
|
|
249
|
-
n = typeof t == "object" && t ? `ref#${
|
|
250
|
+
n = typeof t == "object" && t ? `ref#${Ce(t)}` : `prim:${String(t)}`;
|
|
250
251
|
}
|
|
251
252
|
return `${e}:${n}`;
|
|
252
|
-
}).filter(Boolean).join("|"), [
|
|
253
|
+
}).filter(Boolean).join("|"), [C])]), N = L(() => o(b), [b]), I = L(() => {
|
|
253
254
|
let e = i?.features, t = {};
|
|
254
|
-
for (let [n, r] of Object.entries(
|
|
255
|
+
for (let [n, r] of Object.entries(N)) e && n in e && e[n] !== void 0 && e[n] !== !1 || (t[n] = r);
|
|
255
256
|
return {
|
|
256
257
|
...t,
|
|
257
|
-
...
|
|
258
|
+
...M
|
|
258
259
|
};
|
|
259
260
|
}, [
|
|
260
|
-
|
|
261
|
-
|
|
261
|
+
M,
|
|
262
|
+
N,
|
|
262
263
|
i
|
|
263
|
-
]),
|
|
264
|
-
if (
|
|
265
|
-
let e = new Set(
|
|
266
|
-
return [...
|
|
264
|
+
]), R = L(() => x ? [] : ye(I), [I, x]), B = L(() => {
|
|
265
|
+
if (x) {
|
|
266
|
+
let e = new Set(x.map((e) => e.name)), t = R.filter((t) => !e.has(t.name));
|
|
267
|
+
return [...x, ...t];
|
|
267
268
|
}
|
|
268
|
-
return
|
|
269
|
-
}, [
|
|
270
|
-
let e =
|
|
271
|
-
if (u !== void 0 && (t.sortable = u), d !== void 0 && (t.filterable = d),
|
|
269
|
+
return R;
|
|
270
|
+
}, [x, R]), U = L(() => a && oe(ae(a), s), [a, s]), W = L(() => {
|
|
271
|
+
let e = _(i), t = {};
|
|
272
|
+
if (u !== void 0 && (t.sortable = u), d !== void 0 && (t.filterable = d), f !== void 0 && (t.selectable = f), j) {
|
|
272
273
|
let n = e?.icons || i?.icons || {};
|
|
273
274
|
t.icons = {
|
|
274
|
-
...
|
|
275
|
+
...j,
|
|
275
276
|
...n
|
|
276
277
|
};
|
|
277
278
|
}
|
|
278
|
-
if (
|
|
279
|
-
let n = e.plugins || [], r = new Set(n.map((e) => e.name)), i =
|
|
279
|
+
if (B.length > 0 && e) {
|
|
280
|
+
let n = e.plugins || [], r = new Set(n.map((e) => e.name)), i = B.filter((e) => !r.has(e.name));
|
|
280
281
|
return {
|
|
281
282
|
...e,
|
|
282
283
|
...t,
|
|
283
284
|
plugins: [...n, ...i]
|
|
284
285
|
};
|
|
285
286
|
}
|
|
286
|
-
return
|
|
287
|
+
return B.length > 0 && !e ? {
|
|
287
288
|
...t,
|
|
288
|
-
plugins:
|
|
289
|
+
plugins: B
|
|
289
290
|
} : Object.keys(t).length > 0 ? {
|
|
290
291
|
...e,
|
|
291
292
|
...t
|
|
292
293
|
} : e;
|
|
293
294
|
}, [
|
|
294
295
|
i,
|
|
295
|
-
|
|
296
|
+
B,
|
|
296
297
|
u,
|
|
297
298
|
d,
|
|
298
|
-
|
|
299
|
-
|
|
299
|
+
f,
|
|
300
|
+
j
|
|
300
301
|
]);
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}, [
|
|
304
|
-
|
|
305
|
-
}, [
|
|
306
|
-
let e =
|
|
302
|
+
F(() => {
|
|
303
|
+
k.current = W?.getRowId;
|
|
304
|
+
}, [W]), F(() => {
|
|
305
|
+
Q().setTypeDefaults(A);
|
|
306
|
+
}, [A]), F(() => {
|
|
307
|
+
let e = w.current;
|
|
307
308
|
if (!e) return;
|
|
308
|
-
let t =
|
|
309
|
-
if (
|
|
309
|
+
let t = k.current, n = t ? ge(r, O.current, t) : null;
|
|
310
|
+
if (O.current = r, n !== null) {
|
|
310
311
|
if (n.length > 0) try {
|
|
311
312
|
e.updateRows(n, "sync");
|
|
312
313
|
} catch {
|
|
@@ -315,129 +316,150 @@ var me = w(function(e, t) {
|
|
|
315
316
|
return;
|
|
316
317
|
}
|
|
317
318
|
e.rows = r;
|
|
318
|
-
}, [r]),
|
|
319
|
-
|
|
320
|
-
}, [
|
|
321
|
-
|
|
322
|
-
}, [
|
|
323
|
-
|
|
324
|
-
}, [
|
|
325
|
-
|
|
326
|
-
}, [
|
|
327
|
-
|
|
328
|
-
}, [
|
|
329
|
-
let e =
|
|
319
|
+
}, [r]), F(() => {
|
|
320
|
+
w.current && W && (w.current.gridConfig = W);
|
|
321
|
+
}, [W]), F(() => {
|
|
322
|
+
w.current && U && (w.current.columns = U);
|
|
323
|
+
}, [U]), F(() => {
|
|
324
|
+
w.current && c !== void 0 && (w.current.fitMode = c);
|
|
325
|
+
}, [c]), F(() => {
|
|
326
|
+
w.current && (w.current.columnInference = l);
|
|
327
|
+
}, [l]), F(() => {
|
|
328
|
+
w.current && p !== void 0 && (w.current.loading = p);
|
|
329
|
+
}, [p]), F(() => {
|
|
330
|
+
let e = w.current;
|
|
330
331
|
if (!e) return;
|
|
331
|
-
e.__frameworkAdapter =
|
|
332
|
+
e.__frameworkAdapter = Q(), g(e);
|
|
332
333
|
let t = !1, n = requestAnimationFrame(() => {
|
|
333
334
|
t || (typeof e.refreshColumns == "function" && e.refreshColumns(), typeof e.refreshShellHeader == "function" && e.refreshShellHeader());
|
|
334
335
|
});
|
|
335
336
|
return () => {
|
|
336
337
|
t = !0, cancelAnimationFrame(n);
|
|
337
338
|
};
|
|
338
|
-
}, []),
|
|
339
|
-
if (!
|
|
340
|
-
let e =
|
|
339
|
+
}, []), F(() => {
|
|
340
|
+
if (!w.current || !h) return;
|
|
341
|
+
let e = w.current, t = "react-custom-styles", n = !0;
|
|
341
342
|
return e.ready?.().then(() => {
|
|
342
|
-
n &&
|
|
343
|
+
n && h && (e.registerStyles?.(t, h), E.current = t);
|
|
343
344
|
}), () => {
|
|
344
|
-
n = !1,
|
|
345
|
+
n = !1, E.current &&= (e.unregisterStyles?.(E.current), null);
|
|
345
346
|
};
|
|
346
|
-
}, [
|
|
347
|
-
let e =
|
|
347
|
+
}, [h]), F(() => {
|
|
348
|
+
let e = w.current;
|
|
348
349
|
if (!e) return;
|
|
349
350
|
let t = [];
|
|
350
|
-
return
|
|
351
|
+
return S && t.push(e.on("rows-change", (e) => S(e.rows))), () => {
|
|
351
352
|
t.forEach((e) => e());
|
|
352
353
|
};
|
|
353
|
-
}, [
|
|
354
|
-
let
|
|
355
|
-
for (let e of Object.keys(
|
|
356
|
-
|
|
357
|
-
let e =
|
|
354
|
+
}, [S]);
|
|
355
|
+
let G = L(() => Object.keys(J).filter((e) => typeof C[e] == "function").sort().join("|"), [C]), K = z({});
|
|
356
|
+
for (let e of Object.keys(J)) K.current[e] = C[e];
|
|
357
|
+
F(() => {
|
|
358
|
+
let e = w.current;
|
|
358
359
|
if (!e) return;
|
|
359
360
|
let t = [];
|
|
360
|
-
for (let [n, r] of Object.entries(
|
|
361
|
-
|
|
361
|
+
for (let [n, r] of Object.entries(J)) G.includes(n) && t.push(e.on(r, (e, t) => {
|
|
362
|
+
K.current[n]?.(e, t);
|
|
362
363
|
}));
|
|
363
364
|
return () => {
|
|
364
365
|
t.forEach((e) => e());
|
|
365
366
|
};
|
|
366
|
-
}, [
|
|
367
|
+
}, [G]), ne(t, () => ({
|
|
367
368
|
get element() {
|
|
368
|
-
return
|
|
369
|
+
return w.current;
|
|
369
370
|
},
|
|
370
371
|
async getConfig() {
|
|
371
|
-
return
|
|
372
|
+
return w.current?.getConfig?.() ?? {};
|
|
372
373
|
},
|
|
373
374
|
async ready() {
|
|
374
|
-
return
|
|
375
|
+
return w.current?.ready?.();
|
|
375
376
|
},
|
|
376
377
|
async forceLayout() {
|
|
377
|
-
return
|
|
378
|
+
return w.current?.forceLayout?.();
|
|
378
379
|
},
|
|
379
380
|
async toggleGroup(e) {
|
|
380
|
-
return
|
|
381
|
+
return w.current?.toggleGroup?.(e);
|
|
381
382
|
},
|
|
382
383
|
registerStyles(e, t) {
|
|
383
|
-
|
|
384
|
+
w.current?.registerStyles?.(e, t);
|
|
384
385
|
},
|
|
385
386
|
unregisterStyles(e) {
|
|
386
|
-
|
|
387
|
+
w.current?.unregisterStyles?.(e);
|
|
387
388
|
},
|
|
388
389
|
setRowLoading(e, t) {
|
|
389
|
-
|
|
390
|
+
w.current?.setRowLoading?.(e, t);
|
|
390
391
|
},
|
|
391
392
|
setCellLoading(e, t, n) {
|
|
392
|
-
|
|
393
|
+
w.current?.setCellLoading?.(e, t, n);
|
|
393
394
|
},
|
|
394
395
|
isRowLoading(e) {
|
|
395
|
-
return
|
|
396
|
+
return w.current?.isRowLoading?.(e) ?? !1;
|
|
396
397
|
},
|
|
397
398
|
isCellLoading(e, t) {
|
|
398
|
-
return
|
|
399
|
+
return w.current?.isCellLoading?.(e, t) ?? !1;
|
|
399
400
|
},
|
|
400
401
|
clearAllLoading() {
|
|
401
|
-
|
|
402
|
+
w.current?.clearAllLoading?.();
|
|
402
403
|
}
|
|
403
404
|
}), []);
|
|
404
|
-
let
|
|
405
|
-
return
|
|
406
|
-
let e =
|
|
407
|
-
return e &&
|
|
408
|
-
e &&
|
|
405
|
+
let q = z(null);
|
|
406
|
+
return re(() => {
|
|
407
|
+
let e = w.current;
|
|
408
|
+
return e && q.current && m(e, q.current), () => {
|
|
409
|
+
e && m(e, null);
|
|
409
410
|
};
|
|
410
|
-
}, []), /* @__PURE__ */
|
|
411
|
+
}, []), /* @__PURE__ */ ie(V, { children: [/* @__PURE__ */ H(he, { ref: q }), te(ee.activeTag, {
|
|
411
412
|
ref: (e) => {
|
|
412
|
-
if (
|
|
413
|
-
|
|
413
|
+
if (w.current = e, e && !D.current) {
|
|
414
|
+
D.current = !0;
|
|
414
415
|
let t = e;
|
|
415
|
-
|
|
416
|
+
W && (t.gridConfig = W), r && (t.rows = r), U && (t.columns = U);
|
|
416
417
|
}
|
|
417
418
|
},
|
|
418
|
-
class:
|
|
419
|
-
style:
|
|
420
|
-
}, /* @__PURE__ */
|
|
421
|
-
value:
|
|
422
|
-
children:
|
|
419
|
+
class: v,
|
|
420
|
+
style: y
|
|
421
|
+
}, /* @__PURE__ */ H(T.Provider, {
|
|
422
|
+
value: w,
|
|
423
|
+
children: b
|
|
423
424
|
}))] });
|
|
424
425
|
});
|
|
425
426
|
//#endregion
|
|
427
|
+
//#region libs/grid-react/src/lib/column-options.ts
|
|
428
|
+
function Te(e) {
|
|
429
|
+
if (e.length !== 0) return e.map((e) => {
|
|
430
|
+
if (typeof e == "string" || typeof e == "number") return $(String(e));
|
|
431
|
+
let t = $(String(e.value)), n = $(e.label);
|
|
432
|
+
return e.label === t ? t : `${t}:${n}`;
|
|
433
|
+
}).join(",");
|
|
434
|
+
}
|
|
435
|
+
function $(e) {
|
|
436
|
+
return (e.includes(",") || e.includes(":")) && console.warn(`[tbw-grid:column] Option "${e}" contains "," or ":", which the grid's options parser treats as separators. The option list will not round-trip. Use the \`columns\` config instead of the \`options\` prop for such values.`), e;
|
|
437
|
+
}
|
|
438
|
+
//#endregion
|
|
426
439
|
//#region libs/grid-react/src/lib/grid-column.tsx
|
|
427
|
-
function
|
|
428
|
-
let { field:
|
|
429
|
-
|
|
430
|
-
}, [
|
|
431
|
-
|
|
432
|
-
|
|
440
|
+
function Ee(t) {
|
|
441
|
+
let { field: n, header: r, type: a, editable: o, sortable: c, resizable: u, width: d, minWidth: f, order: p, hidden: m, lockVisible: h, options: g, children: _, editor: v, headerRenderer: y, headerLabelRenderer: b } = t, x = z(null), S = N((t) => {
|
|
442
|
+
x.current = t, t && (_ && e(t, _), v && s(t, v), y && i(t, y), b && l(t, b));
|
|
443
|
+
}, [
|
|
444
|
+
_,
|
|
445
|
+
v,
|
|
446
|
+
y,
|
|
447
|
+
b
|
|
448
|
+
]), C = typeof d == "number" ? `${d}px` : d, w = {
|
|
449
|
+
field: n,
|
|
450
|
+
ref: S
|
|
433
451
|
};
|
|
434
|
-
|
|
452
|
+
if (r !== void 0 && (w.header = r), a !== void 0 && (w.type = a), o !== void 0 && (w.editable = o), c !== void 0 && (w.sortable = c), u !== void 0 && (w.resizable = u), C !== void 0 && (w.width = C), f !== void 0 && (w["min-width"] = f), p !== void 0 && (w.order = p), m !== void 0 && (w.hidden = m), h !== void 0 && (w["lock-visible"] = h), g) {
|
|
453
|
+
let e = Te(g);
|
|
454
|
+
e !== void 0 && (w.options = e);
|
|
455
|
+
}
|
|
456
|
+
return /* @__PURE__ */ H("tbw-grid-column", { ...w });
|
|
435
457
|
}
|
|
436
458
|
//#endregion
|
|
437
459
|
//#region libs/grid-react/src/lib/grid-header-content.tsx
|
|
438
|
-
function
|
|
439
|
-
let r =
|
|
440
|
-
return
|
|
460
|
+
function De({ id: e, order: t = 100, children: n }) {
|
|
461
|
+
let r = I(), i = e ?? `tbw-header-content-${r}`, a = P(T), [o, s] = B(null), c = z(null);
|
|
462
|
+
return F(() => {
|
|
441
463
|
let e = a?.current;
|
|
442
464
|
if (!e) return;
|
|
443
465
|
let n = c, r = !1;
|
|
@@ -455,16 +477,16 @@ function ge({ id: e, order: t = 100, children: n }) {
|
|
|
455
477
|
};
|
|
456
478
|
e.getPluginByName?.("shell")?.registerHeaderContent(n);
|
|
457
479
|
})(), () => {
|
|
458
|
-
r = !0, e.getPluginByName?.("shell")?.unregisterHeaderContent(i), n.current &&= (
|
|
480
|
+
r = !0, e.getPluginByName?.("shell")?.unregisterHeaderContent(i), n.current &&= (p(n.current, { sync: !0 }), null), s(null);
|
|
459
481
|
};
|
|
460
482
|
}, [
|
|
461
483
|
a,
|
|
462
484
|
i,
|
|
463
485
|
t
|
|
464
|
-
]),
|
|
486
|
+
]), F(() => {
|
|
465
487
|
if (!o) return;
|
|
466
488
|
let e = a?.current ?? void 0;
|
|
467
|
-
c.current =
|
|
489
|
+
c.current = f(o, n, c.current ?? void 0, e);
|
|
468
490
|
}, [
|
|
469
491
|
n,
|
|
470
492
|
o,
|
|
@@ -473,14 +495,14 @@ function ge({ id: e, order: t = 100, children: n }) {
|
|
|
473
495
|
}
|
|
474
496
|
//#endregion
|
|
475
497
|
//#region libs/grid-react/src/lib/grid-tool-button.tsx
|
|
476
|
-
function
|
|
477
|
-
return /* @__PURE__ */
|
|
498
|
+
function Oe({ children: e }) {
|
|
499
|
+
return /* @__PURE__ */ H("tbw-grid-tool-buttons", { children: e });
|
|
478
500
|
}
|
|
479
501
|
//#endregion
|
|
480
502
|
//#region libs/grid-react/src/lib/grid-toolbar-content.tsx
|
|
481
|
-
function
|
|
482
|
-
let r =
|
|
483
|
-
return
|
|
503
|
+
function ke({ id: e, order: t = 100, children: n }) {
|
|
504
|
+
let r = I(), i = e ?? `tbw-toolbar-content-${r}`, a = P(T), [o, s] = B(null), c = z(null);
|
|
505
|
+
return F(() => {
|
|
484
506
|
let e = a?.current;
|
|
485
507
|
if (!e) return;
|
|
486
508
|
let n = c, r = !1;
|
|
@@ -498,16 +520,16 @@ function ve({ id: e, order: t = 100, children: n }) {
|
|
|
498
520
|
};
|
|
499
521
|
e.getPluginByName?.("shell")?.registerToolbarContent(n);
|
|
500
522
|
})(), () => {
|
|
501
|
-
r = !0, e.getPluginByName?.("shell")?.unregisterToolbarContent(i), n.current &&= (
|
|
523
|
+
r = !0, e.getPluginByName?.("shell")?.unregisterToolbarContent(i), n.current &&= (p(n.current, { sync: !0 }), null), s(null);
|
|
502
524
|
};
|
|
503
525
|
}, [
|
|
504
526
|
a,
|
|
505
527
|
i,
|
|
506
528
|
t
|
|
507
|
-
]),
|
|
529
|
+
]), F(() => {
|
|
508
530
|
if (!o) return;
|
|
509
531
|
let e = a?.current ?? void 0;
|
|
510
|
-
c.current =
|
|
532
|
+
c.current = f(o, n, c.current ?? void 0, e);
|
|
511
533
|
}, [
|
|
512
534
|
n,
|
|
513
535
|
o,
|
|
@@ -516,107 +538,98 @@ function ve({ id: e, order: t = 100, children: n }) {
|
|
|
516
538
|
}
|
|
517
539
|
//#endregion
|
|
518
540
|
//#region libs/grid-react/src/lib/grid-type.tsx
|
|
519
|
-
function
|
|
541
|
+
function Ae(e) {
|
|
520
542
|
return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
|
|
521
543
|
}
|
|
522
|
-
function
|
|
523
|
-
let { name:
|
|
524
|
-
name:
|
|
525
|
-
ref:
|
|
526
|
-
o.current =
|
|
527
|
-
}, [
|
|
544
|
+
function je(e) {
|
|
545
|
+
let { name: t, params: n, children: r, editor: i } = e, o = z(null), s = {
|
|
546
|
+
name: t,
|
|
547
|
+
ref: N((e) => {
|
|
548
|
+
o.current = e, e && (r && d(e, r), i && a(e, i));
|
|
549
|
+
}, [r, i])
|
|
528
550
|
};
|
|
529
|
-
if (
|
|
530
|
-
return /* @__PURE__ */
|
|
531
|
-
...
|
|
532
|
-
children: [
|
|
551
|
+
if (n) for (let [e, t] of Object.entries(n)) s[`data-${Ae(e)}`] = String(t);
|
|
552
|
+
return /* @__PURE__ */ ie("tbw-grid-type", {
|
|
553
|
+
...s,
|
|
554
|
+
children: [r ? /* @__PURE__ */ H("tbw-grid-column-view", {}) : null, i ? /* @__PURE__ */ H("tbw-grid-column-editor", {}) : null]
|
|
533
555
|
});
|
|
534
556
|
}
|
|
535
557
|
//#endregion
|
|
536
558
|
//#region libs/grid-react/src/lib/grid-provider.tsx
|
|
537
|
-
var
|
|
559
|
+
var Me = ({ icons: e, defaults: t, children: n }) => {
|
|
538
560
|
let r = n;
|
|
539
|
-
return t && (r = /* @__PURE__ */
|
|
561
|
+
return t && (r = /* @__PURE__ */ H(ue, {
|
|
540
562
|
defaults: t,
|
|
541
563
|
children: r
|
|
542
|
-
})), e && (r = /* @__PURE__ */
|
|
564
|
+
})), e && (r = /* @__PURE__ */ H(se, {
|
|
543
565
|
icons: e,
|
|
544
566
|
children: r
|
|
545
|
-
})), /* @__PURE__ */
|
|
567
|
+
})), /* @__PURE__ */ H(V, { children: r });
|
|
546
568
|
};
|
|
547
569
|
//#endregion
|
|
548
570
|
//#region libs/grid-react/src/lib/use-grid.ts
|
|
549
|
-
function
|
|
550
|
-
let t =
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
if (o.current = t, await t.ready?.(), n) {
|
|
559
|
-
r(!0);
|
|
560
|
-
let e = await t.getConfig?.();
|
|
561
|
-
n && e && a(e);
|
|
562
|
-
}
|
|
563
|
-
} else {
|
|
564
|
-
let e = t.current;
|
|
565
|
-
if (!e) return;
|
|
566
|
-
if (await e.ready?.(), n) {
|
|
567
|
-
r(!0);
|
|
568
|
-
let t = await e.getConfig?.();
|
|
569
|
-
n && t && a(t);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
} catch {}
|
|
573
|
-
})(), () => {
|
|
574
|
-
n = !1;
|
|
571
|
+
function Ne(e) {
|
|
572
|
+
let t = z(null), [n, r] = B(null), i = z(null), a = N(() => e ? (i.current ??= document.querySelector(e), i.current) : t.current?.element ?? null, [e]), o = O(a);
|
|
573
|
+
F(() => {
|
|
574
|
+
if (!o) return;
|
|
575
|
+
let e = !0, t = a();
|
|
576
|
+
if (t) return Promise.resolve(t.getConfig?.()).then((t) => {
|
|
577
|
+
e && t && r(t);
|
|
578
|
+
}).catch(() => {}), () => {
|
|
579
|
+
e = !1;
|
|
575
580
|
};
|
|
576
|
-
}, [
|
|
577
|
-
let
|
|
578
|
-
let e =
|
|
581
|
+
}, [o, a]);
|
|
582
|
+
let s = N(async () => {
|
|
583
|
+
let e = a();
|
|
579
584
|
if (e) return await e.getConfig?.() ?? null;
|
|
580
585
|
let n = t.current;
|
|
581
586
|
return n ? await n.getConfig?.() ?? null : null;
|
|
582
|
-
}, [
|
|
583
|
-
let e =
|
|
587
|
+
}, [a]), c = N(async () => {
|
|
588
|
+
let e = a();
|
|
584
589
|
if (e) {
|
|
585
590
|
await e.forceLayout?.();
|
|
586
591
|
return;
|
|
587
592
|
}
|
|
588
593
|
let n = t.current;
|
|
589
594
|
n && await n.forceLayout?.();
|
|
590
|
-
}, [
|
|
591
|
-
let
|
|
595
|
+
}, [a]), l = N(async () => {
|
|
596
|
+
let e = a();
|
|
597
|
+
if (e) {
|
|
598
|
+
await e.ready?.();
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
await t.current?.ready?.();
|
|
602
|
+
}, [a]), u = N(async (e) => {
|
|
603
|
+
let n = a();
|
|
592
604
|
if (n) {
|
|
593
605
|
await n.toggleGroup?.(e);
|
|
594
606
|
return;
|
|
595
607
|
}
|
|
596
608
|
let r = t.current;
|
|
597
609
|
r && await r.toggleGroup?.(e);
|
|
598
|
-
}, [
|
|
599
|
-
let r =
|
|
610
|
+
}, [a]), d = N((e) => a()?.getPlugin?.(e), [a]), f = N(((e) => a()?.getPluginByName?.(e)), [a]), p = N((e, n) => {
|
|
611
|
+
let r = a();
|
|
600
612
|
if (r) {
|
|
601
613
|
r.registerStyles?.(e, n);
|
|
602
614
|
return;
|
|
603
615
|
}
|
|
604
616
|
t.current?.registerStyles?.(e, n);
|
|
605
|
-
}, [
|
|
606
|
-
let n =
|
|
617
|
+
}, [a]), m = N((e) => {
|
|
618
|
+
let n = a();
|
|
607
619
|
if (n) {
|
|
608
620
|
n.unregisterStyles?.(e);
|
|
609
621
|
return;
|
|
610
622
|
}
|
|
611
623
|
t.current?.unregisterStyles?.(e);
|
|
612
|
-
}, [
|
|
624
|
+
}, [a]), h = N(() => n?.columns ? n.columns.filter((e) => !e.hidden) : [], [n]);
|
|
613
625
|
return {
|
|
614
626
|
ref: t,
|
|
615
|
-
element:
|
|
616
|
-
isReady:
|
|
617
|
-
config:
|
|
618
|
-
getConfig:
|
|
619
|
-
|
|
627
|
+
element: a(),
|
|
628
|
+
isReady: o,
|
|
629
|
+
config: n,
|
|
630
|
+
getConfig: s,
|
|
631
|
+
ready: l,
|
|
632
|
+
forceLayout: c,
|
|
620
633
|
toggleGroup: u,
|
|
621
634
|
getPlugin: d,
|
|
622
635
|
getPluginByName: f,
|
|
@@ -627,9 +640,9 @@ function Se(e) {
|
|
|
627
640
|
}
|
|
628
641
|
//#endregion
|
|
629
642
|
//#region libs/grid-react/src/lib/use-grid-overlay.ts
|
|
630
|
-
function
|
|
631
|
-
let { open: n = !0, gridElement: r } = t, i =
|
|
632
|
-
|
|
643
|
+
function Pe(e, t = {}) {
|
|
644
|
+
let { open: n = !0, gridElement: r } = t, i = P(T);
|
|
645
|
+
F(() => {
|
|
633
646
|
if (!n) return;
|
|
634
647
|
let t = e.current;
|
|
635
648
|
if (!t) return;
|
|
@@ -645,4 +658,4 @@ function Ce(e, t = {}) {
|
|
|
645
658
|
]);
|
|
646
659
|
}
|
|
647
660
|
//#endregion
|
|
648
|
-
export {
|
|
661
|
+
export { we as DataGrid, u as GridAdapter, Ee as GridColumn, E as GridDetailPanel, De as GridHeaderContent, se as GridIconProvider, Me as GridProvider, D as GridResponsiveCard, Oe as GridToolButtons, t as GridToolPanel, ke as GridToolbarContent, je as GridType, ue as GridTypeProvider, oe as applyColumnDefaults, w as clearFeatureRegistry, x as createPluginFromFeature, C as getFeatureFactory, b as getRegisteredFeatures, q as hasColumnShorthands, y as isFeatureRegistered, ae as normalizeColumns, K as parseColumnShorthand, r as registerChildFeatureDetector, v as registerEditorMountHook, S as registerFeature, c as registerFeaturePropKey, h as registerPostMountRefresh, Ne as useGrid, ce as useGridIcons, Pe as useGridOverlay, de as useGridTypeDefaults, fe as useTypeDefault };
|