@toolbox-web/grid-react 0.12.2 → 0.13.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 +18 -18
- package/features/selection.d.ts +12 -2
- package/features/selection.d.ts.map +1 -1
- package/features/selection.js +21 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -695,11 +695,11 @@ import type {
|
|
|
695
695
|
// Deprecated aliases
|
|
696
696
|
ReactGridConfig,
|
|
697
697
|
ReactColumnConfig,
|
|
698
|
-
// Context types
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
698
|
+
// Context types (React-specific wrappers)
|
|
699
|
+
GridCellContext,
|
|
700
|
+
GridEditorContext,
|
|
701
|
+
GridDetailContext,
|
|
702
|
+
GridToolPanelContext,
|
|
703
703
|
DataGridRef,
|
|
704
704
|
DataGridProps,
|
|
705
705
|
// Feature props
|
|
@@ -760,28 +760,28 @@ import type {
|
|
|
760
760
|
|
|
761
761
|
### GridColumn Props
|
|
762
762
|
|
|
763
|
-
| Prop | Type
|
|
764
|
-
| ----------- |
|
|
765
|
-
| `field` | `string`
|
|
766
|
-
| `header` | `string`
|
|
767
|
-
| `type` | `'string' \| 'number' \| 'date' \| 'boolean'`
|
|
768
|
-
| `editable` | `boolean`
|
|
769
|
-
| `sortable` | `boolean`
|
|
770
|
-
| `resizable` | `boolean`
|
|
771
|
-
| `width` | `string \| number`
|
|
772
|
-
| `children` | `(ctx: CellRenderContext) => ReactNode`
|
|
773
|
-
| `editor` | `(ctx: ColumnEditorContext) => ReactNode`
|
|
763
|
+
| Prop | Type | Description |
|
|
764
|
+
| ----------- | ------------------------------------------------------- | ------------------------------------------------------- |
|
|
765
|
+
| `field` | `string` | Field key in row object |
|
|
766
|
+
| `header` | `string` | Column header text |
|
|
767
|
+
| `type` | `'string' \| 'number' \| 'date' \| 'boolean'` | Data type |
|
|
768
|
+
| `editable` | `boolean` | Enable editing |
|
|
769
|
+
| `sortable` | `boolean` | Enable sorting |
|
|
770
|
+
| `resizable` | `boolean` | Enable column resizing |
|
|
771
|
+
| `width` | `string \| number` | Column width |
|
|
772
|
+
| `children` | `(ctx: CellRenderContext<TRow, TValue>) => ReactNode` | Custom renderer (context type from `@toolbox-web/grid`) |
|
|
773
|
+
| `editor` | `(ctx: ColumnEditorContext<TRow, TValue>) => ReactNode` | Custom editor (context type from `@toolbox-web/grid`) |
|
|
774
774
|
|
|
775
775
|
### DataGridRef Methods
|
|
776
776
|
|
|
777
777
|
| Method | Description |
|
|
778
|
-
| ------------------------- | --------------------------- |
|
|
778
|
+
| ------------------------- | --------------------------- |
|
|
779
779
|
| `getConfig()` | Get effective configuration |
|
|
780
780
|
| `ready()` | Wait for grid ready |
|
|
781
781
|
| `forceLayout()` | Force layout recalculation |
|
|
782
782
|
| `toggleGroup(key)` | Toggle group expansion |
|
|
783
783
|
| `registerStyles(id, css)` | Register custom styles |
|
|
784
|
-
| `unregisterStyles(id)` |
|
|
784
|
+
| `unregisterStyles(id)` | Remove custom styles |
|
|
785
785
|
|
|
786
786
|
### ReactGridAdapter
|
|
787
787
|
|
package/features/selection.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { CellRange, SelectionResult } from '@toolbox-web/grid/plugins/selection'
|
|
|
5
5
|
* Uses React context to access the grid ref - works reliably regardless of
|
|
6
6
|
* when the grid mounts or conditional rendering.
|
|
7
7
|
*/
|
|
8
|
-
export interface SelectionMethods {
|
|
8
|
+
export interface SelectionMethods<TRow = unknown> {
|
|
9
9
|
/**
|
|
10
10
|
* Select all rows (row mode) or all cells (range mode).
|
|
11
11
|
*/
|
|
@@ -27,6 +27,16 @@ export interface SelectionMethods {
|
|
|
27
27
|
* Set selection ranges programmatically.
|
|
28
28
|
*/
|
|
29
29
|
setRanges: (ranges: CellRange[]) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Get actual row objects for the current selection.
|
|
32
|
+
* Works in all selection modes (row, cell, range) — resolves indices
|
|
33
|
+
* against the grid's processed (sorted/filtered) rows.
|
|
34
|
+
*
|
|
35
|
+
* This is the recommended way to get selected rows. Unlike manual
|
|
36
|
+
* index mapping, it correctly resolves rows even when the grid is
|
|
37
|
+
* sorted or filtered.
|
|
38
|
+
*/
|
|
39
|
+
getSelectedRows: () => TRow[];
|
|
30
40
|
}
|
|
31
41
|
/**
|
|
32
42
|
* Hook for programmatic selection control.
|
|
@@ -52,5 +62,5 @@ export interface SelectionMethods {
|
|
|
52
62
|
* }
|
|
53
63
|
* ```
|
|
54
64
|
*/
|
|
55
|
-
export declare function useGridSelection<TRow = unknown>(): SelectionMethods
|
|
65
|
+
export declare function useGridSelection<TRow = unknown>(): SelectionMethods<TRow>;
|
|
56
66
|
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAmB,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAc5G;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAmB,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAc5G;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,GAAG,OAAO;IAC9C;;OAEG;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;;;;;;;;OAQG;IACH,eAAe,EAAE,MAAM,IAAI,EAAE,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAG,OAAO,KAAK,gBAAgB,CAAC,IAAI,CAAC,CAuEzE"}
|
package/features/selection.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SelectionPlugin as i } from "@toolbox-web/grid/plugins/selection";
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { G as
|
|
4
|
-
import { r as
|
|
5
|
-
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
const n =
|
|
2
|
+
import { useContext as S, useCallback as o } from "react";
|
|
3
|
+
import { G as C } from "../chunks/data-grid-CGvHh_mp.js";
|
|
4
|
+
import { r as R } from "../chunks/feature-registry-Y3KvnN54.js";
|
|
5
|
+
R("selection", (t) => t === "cell" || t === "row" || t === "range" ? new i({ mode: t }) : new i(t ?? void 0));
|
|
6
|
+
function b() {
|
|
7
|
+
const t = S(C), e = o(() => t?.current?.getPlugin(i), [t]), g = o(() => {
|
|
8
|
+
const n = e();
|
|
9
9
|
if (!n) {
|
|
10
10
|
console.warn(
|
|
11
11
|
`[tbw-grid:selection] SelectionPlugin not found.
|
|
@@ -15,7 +15,7 @@ function P() {
|
|
|
15
15
|
);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
const r =
|
|
18
|
+
const r = t?.current, u = n.config?.mode;
|
|
19
19
|
if (u === "row") {
|
|
20
20
|
const s = r?.rows?.length ?? 0, l = /* @__PURE__ */ new Set();
|
|
21
21
|
for (let c = 0; c < s; c++) l.add(c);
|
|
@@ -24,25 +24,26 @@ function P() {
|
|
|
24
24
|
const s = r?.rows?.length ?? 0, l = r?._columns?.length ?? 0;
|
|
25
25
|
s > 0 && l > 0 && n.setRanges([{ from: { row: 0, col: 0 }, to: { row: s - 1, col: l - 1 } }]);
|
|
26
26
|
}
|
|
27
|
-
}, [
|
|
28
|
-
|
|
29
|
-
}, [
|
|
30
|
-
(n, r) =>
|
|
31
|
-
[
|
|
32
|
-
),
|
|
27
|
+
}, [e, t]), d = o(() => {
|
|
28
|
+
e()?.clearSelection();
|
|
29
|
+
}, [e]), a = o(() => e()?.getSelection() ?? null, [e]), w = o(
|
|
30
|
+
(n, r) => e()?.isCellSelected(n, r) ?? !1,
|
|
31
|
+
[e]
|
|
32
|
+
), m = o(
|
|
33
33
|
(n) => {
|
|
34
|
-
|
|
34
|
+
e()?.setRanges(n);
|
|
35
35
|
},
|
|
36
|
-
[
|
|
37
|
-
);
|
|
36
|
+
[e]
|
|
37
|
+
), f = o(() => e()?.getSelectedRows() ?? [], [e]);
|
|
38
38
|
return {
|
|
39
39
|
selectAll: g,
|
|
40
40
|
clearSelection: d,
|
|
41
41
|
getSelection: a,
|
|
42
|
-
isCellSelected:
|
|
43
|
-
setRanges:
|
|
42
|
+
isCellSelected: w,
|
|
43
|
+
setRanges: m,
|
|
44
|
+
getSelectedRows: f
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
47
|
export {
|
|
47
|
-
|
|
48
|
+
b as useGridSelection
|
|
48
49
|
};
|