@toolbox-web/grid-react 2.5.0 → 2.6.1
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/features/selection.d.ts
CHANGED
|
@@ -8,7 +8,9 @@ export type { _Augmentation as _SelectionAugmentation } from '@toolbox-web/grid/
|
|
|
8
8
|
*/
|
|
9
9
|
export interface SelectionMethods<TRow = unknown> {
|
|
10
10
|
/**
|
|
11
|
-
* Select all rows (row mode) or
|
|
11
|
+
* Select all selectable rows (row mode) or one range over every row and all
|
|
12
|
+
* non-hidden columns (range mode).
|
|
13
|
+
* Array modes use their row/range axis.
|
|
12
14
|
*/
|
|
13
15
|
selectAll: () => void;
|
|
14
16
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EACL,KAAK,SAAS,EAGd,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAC;AAK7C,OAAO,sCAAsC,CAAC;AAI9C,YAAY,EAAE,aAAa,IAAI,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEpG;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,GAAG,OAAO;IAC9C
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EACL,KAAK,SAAS,EAGd,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAC;AAK7C,OAAO,sCAAsC,CAAC;AAI9C,YAAY,EAAE,aAAa,IAAI,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEpG;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,GAAG,OAAO;IAC9C;;;;OAIG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IAEtB;;OAEG;IACH,cAAc,EAAE,MAAM,IAAI,CAAC;IAE3B;;;OAGG;IACH,YAAY,EAAE,MAAM,eAAe,GAAG,IAAI,CAAC;IAE3C;;OAEG;IACH,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IAEtD;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAEzC;;;;;;;;;;OAUG;IACH,eAAe,EAAE,MAAM,IAAI,EAAE,CAAC;IAE9B;;;;;OAKG;IACH,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;IAElC;;;;;;;;OAQG;IACH,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAE7B;;;;OAIG;IACH,YAAY,EAAE,IAAI,EAAE,CAAC;IAErB;;;;;OAKG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAG,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAuG1F"}
|
package/features/selection.js
CHANGED
|
@@ -27,25 +27,8 @@ function a(a) {
|
|
|
27
27
|
console.warn("[tbw-grid:selection] SelectionPlugin not found.\n\n → Enable selection on the grid:\n <DataGrid selection=\"range\" />");
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
let n = t?.rows?.length ?? 0, r = /* @__PURE__ */ new Set();
|
|
33
|
-
for (let e = 0; e < n; e++) r.add(e);
|
|
34
|
-
e.selected = r, e.requestAfterRender?.();
|
|
35
|
-
} else if (n === "range") {
|
|
36
|
-
let n = t?.rows?.length ?? 0, r = t?._columns?.length ?? 0;
|
|
37
|
-
n > 0 && r > 0 && e.setRanges([{
|
|
38
|
-
from: {
|
|
39
|
-
row: 0,
|
|
40
|
-
col: 0
|
|
41
|
-
},
|
|
42
|
-
to: {
|
|
43
|
-
row: n - 1,
|
|
44
|
-
col: r - 1
|
|
45
|
-
}
|
|
46
|
-
}]);
|
|
47
|
-
}
|
|
48
|
-
}, [c, s]),
|
|
30
|
+
e.selectAll();
|
|
31
|
+
}, [c]),
|
|
49
32
|
clearSelection: t(() => {
|
|
50
33
|
c()?.clearSelection();
|
|
51
34
|
}, [c]),
|
package/index.js
CHANGED
|
@@ -210,7 +210,7 @@ function ve(e) {
|
|
|
210
210
|
}
|
|
211
211
|
function ye(e) {
|
|
212
212
|
let t = [];
|
|
213
|
-
for (let [n, r] of Object.entries(e)) r
|
|
213
|
+
for (let [n, r] of Object.entries(e)) r !== void 0 && r !== !1 && t.push(n);
|
|
214
214
|
return ve(t), G(e);
|
|
215
215
|
}
|
|
216
216
|
//#endregion
|
|
@@ -233,14 +233,7 @@ r("GridDetailPanel", (e) => {
|
|
|
233
233
|
} };
|
|
234
234
|
}), r("GridResponsiveCard", () => ({ responsive: !0 }));
|
|
235
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);
|
|
241
|
-
}
|
|
242
|
-
return e;
|
|
243
|
-
}, [L(() => n().map((e) => {
|
|
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(() => n().map((e) => {
|
|
244
237
|
let t = C[e];
|
|
245
238
|
if (t === void 0) return "";
|
|
246
239
|
let n;
|
|
@@ -250,24 +243,31 @@ var we = M(function(e, t) {
|
|
|
250
243
|
n = typeof t == "object" && t ? `ref#${Ce(t)}` : `prim:${String(t)}`;
|
|
251
244
|
}
|
|
252
245
|
return `${e}:${n}`;
|
|
253
|
-
}).filter(Boolean).join("|"), [C])
|
|
246
|
+
}).filter(Boolean).join("|"), [C]), N = L(() => {
|
|
247
|
+
let e = {}, t = C;
|
|
248
|
+
for (let r of n()) {
|
|
249
|
+
let n = t[r];
|
|
250
|
+
n !== void 0 && (e[r] = n);
|
|
251
|
+
}
|
|
252
|
+
return e;
|
|
253
|
+
}, [M]), I = L(() => o(b), [b]), R = L(() => {
|
|
254
254
|
let e = i?.features, t = {};
|
|
255
|
-
for (let [n, r] of Object.entries(
|
|
255
|
+
for (let [n, r] of Object.entries(I)) e && n in e && e[n] !== void 0 && e[n] !== !1 || (t[n] = r);
|
|
256
256
|
return {
|
|
257
257
|
...t,
|
|
258
|
-
...
|
|
258
|
+
...N
|
|
259
259
|
};
|
|
260
260
|
}, [
|
|
261
|
-
M,
|
|
262
261
|
N,
|
|
262
|
+
I,
|
|
263
263
|
i
|
|
264
|
-
]),
|
|
264
|
+
]), B = L(() => x ? [] : ye(R), [R, x]), U = L(() => {
|
|
265
265
|
if (x) {
|
|
266
|
-
let e = new Set(x.map((e) => e.name)), t =
|
|
266
|
+
let e = new Set(x.map((e) => e.name)), t = B.filter((t) => !e.has(t.name));
|
|
267
267
|
return [...x, ...t];
|
|
268
268
|
}
|
|
269
|
-
return
|
|
270
|
-
}, [x,
|
|
269
|
+
return B;
|
|
270
|
+
}, [x, B]), W = L(() => a && oe(ae(a), s), [a, s]), G = L(() => {
|
|
271
271
|
let e = _(i), t = {};
|
|
272
272
|
if (u !== void 0 && (t.sortable = u), d !== void 0 && (t.filterable = d), f !== void 0 && (t.selectable = f), j) {
|
|
273
273
|
let n = e?.icons || i?.icons || {};
|
|
@@ -276,32 +276,32 @@ var we = M(function(e, t) {
|
|
|
276
276
|
...n
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
|
-
if (
|
|
280
|
-
let n = e.plugins || [], r = new Set(n.map((e) => e.name)), i =
|
|
279
|
+
if (U.length > 0 && e) {
|
|
280
|
+
let n = e.plugins || [], r = new Set(n.map((e) => e.name)), i = U.filter((e) => !r.has(e.name));
|
|
281
281
|
return {
|
|
282
282
|
...e,
|
|
283
283
|
...t,
|
|
284
284
|
plugins: [...n, ...i]
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
|
-
return
|
|
287
|
+
return U.length > 0 && !e ? {
|
|
288
288
|
...t,
|
|
289
|
-
plugins:
|
|
289
|
+
plugins: U
|
|
290
290
|
} : Object.keys(t).length > 0 ? {
|
|
291
291
|
...e,
|
|
292
292
|
...t
|
|
293
293
|
} : e;
|
|
294
294
|
}, [
|
|
295
295
|
i,
|
|
296
|
-
|
|
296
|
+
U,
|
|
297
297
|
u,
|
|
298
298
|
d,
|
|
299
299
|
f,
|
|
300
300
|
j
|
|
301
301
|
]);
|
|
302
302
|
F(() => {
|
|
303
|
-
k.current =
|
|
304
|
-
}, [
|
|
303
|
+
k.current = G?.getRowId;
|
|
304
|
+
}, [G]), F(() => {
|
|
305
305
|
Q().setTypeDefaults(A);
|
|
306
306
|
}, [A]), F(() => {
|
|
307
307
|
let e = w.current;
|
|
@@ -317,10 +317,10 @@ var we = M(function(e, t) {
|
|
|
317
317
|
}
|
|
318
318
|
e.rows = r;
|
|
319
319
|
}, [r]), F(() => {
|
|
320
|
-
w.current &&
|
|
320
|
+
w.current && G && (w.current.gridConfig = G);
|
|
321
|
+
}, [G]), F(() => {
|
|
322
|
+
w.current && W && (w.current.columns = W);
|
|
321
323
|
}, [W]), F(() => {
|
|
322
|
-
w.current && U && (w.current.columns = U);
|
|
323
|
-
}, [U]), F(() => {
|
|
324
324
|
w.current && c !== void 0 && (w.current.fitMode = c);
|
|
325
325
|
}, [c]), F(() => {
|
|
326
326
|
w.current && (w.current.columnInference = l);
|
|
@@ -352,19 +352,19 @@ var we = M(function(e, t) {
|
|
|
352
352
|
t.forEach((e) => e());
|
|
353
353
|
};
|
|
354
354
|
}, [S]);
|
|
355
|
-
let
|
|
356
|
-
for (let e of Object.keys(J))
|
|
355
|
+
let K = L(() => Object.keys(J).filter((e) => typeof C[e] == "function").sort().join("|"), [C]), q = z({});
|
|
356
|
+
for (let e of Object.keys(J)) q.current[e] = C[e];
|
|
357
357
|
F(() => {
|
|
358
358
|
let e = w.current;
|
|
359
359
|
if (!e) return;
|
|
360
360
|
let t = [];
|
|
361
|
-
for (let [n, r] of Object.entries(J))
|
|
362
|
-
|
|
361
|
+
for (let [n, r] of Object.entries(J)) K.includes(n) && t.push(e.on(r, (e, t) => {
|
|
362
|
+
q.current[n]?.(e, t);
|
|
363
363
|
}));
|
|
364
364
|
return () => {
|
|
365
365
|
t.forEach((e) => e());
|
|
366
366
|
};
|
|
367
|
-
}, [
|
|
367
|
+
}, [K]), ne(t, () => ({
|
|
368
368
|
get element() {
|
|
369
369
|
return w.current;
|
|
370
370
|
},
|
|
@@ -402,18 +402,18 @@ var we = M(function(e, t) {
|
|
|
402
402
|
w.current?.clearAllLoading?.();
|
|
403
403
|
}
|
|
404
404
|
}), []);
|
|
405
|
-
let
|
|
405
|
+
let Y = z(null);
|
|
406
406
|
return re(() => {
|
|
407
407
|
let e = w.current;
|
|
408
|
-
return e &&
|
|
408
|
+
return e && Y.current && m(e, Y.current), () => {
|
|
409
409
|
e && m(e, null);
|
|
410
410
|
};
|
|
411
|
-
}, []), /* @__PURE__ */ ie(V, { children: [/* @__PURE__ */ H(he, { ref:
|
|
411
|
+
}, []), /* @__PURE__ */ ie(V, { children: [/* @__PURE__ */ H(he, { ref: Y }), te(ee.activeTag, {
|
|
412
412
|
ref: (e) => {
|
|
413
413
|
if (w.current = e, e && !D.current) {
|
|
414
414
|
D.current = !0;
|
|
415
415
|
let t = e;
|
|
416
|
-
|
|
416
|
+
G && (t.gridConfig = G), r && (t.rows = r), W && (t.columns = W);
|
|
417
417
|
}
|
|
418
418
|
},
|
|
419
419
|
class: v,
|
|
@@ -4,14 +4,17 @@ import { FC, ReactNode } from 'react';
|
|
|
4
4
|
/**
|
|
5
5
|
* Type default configuration for React applications.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Inherits every core {@link BaseTypeDefault} property (which is itself a
|
|
8
|
+
* partial `ColumnConfig` — `format`, `width`, `sortable`, `cellClass`,
|
|
9
|
+
* `filterable`, …) and widens the renderer/editor slots to accept React
|
|
10
|
+
* function components.
|
|
9
11
|
*
|
|
10
12
|
* @example
|
|
11
13
|
* ```tsx
|
|
12
14
|
* import type { TypeDefault } from '@toolbox-web/grid-react';
|
|
13
15
|
*
|
|
14
16
|
* const countryDefault: TypeDefault<Employee, string> = {
|
|
17
|
+
* width: 140,
|
|
15
18
|
* renderer: (ctx) => <CountryFlag code={ctx.value} />,
|
|
16
19
|
* editor: (ctx) => (
|
|
17
20
|
* <CountrySelect value={ctx.value} onSelect={ctx.commit} />
|
|
@@ -19,7 +22,7 @@ import { FC, ReactNode } from 'react';
|
|
|
19
22
|
* };
|
|
20
23
|
* ```
|
|
21
24
|
*/
|
|
22
|
-
export interface TypeDefault<TRow = unknown, TValue = unknown> {
|
|
25
|
+
export interface TypeDefault<TRow = unknown, TValue = unknown> extends Omit<BaseTypeDefault<TRow>, 'renderer' | 'editor' | 'editorParams' | 'filterPanelRenderer'> {
|
|
23
26
|
/** React component/function for rendering cells of this type */
|
|
24
27
|
renderer?: (ctx: CellRenderContext<TRow, TValue>) => ReactNode;
|
|
25
28
|
/** React component/function for editing cells of this type */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-type-registry.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/grid-type-registry.tsx"],"names":[],"mappings":"A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