@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 CHANGED
@@ -695,11 +695,11 @@ import type {
695
695
  // Deprecated aliases
696
696
  ReactGridConfig,
697
697
  ReactColumnConfig,
698
- // Context types
699
- CellRenderContext,
700
- ColumnEditorContext,
701
- DetailPanelContext,
702
- ToolPanelContext,
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 | 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) => ReactNode` | Custom renderer |
773
- | `editor` | `(ctx: ColumnEditorContext) => ReactNode` | Custom editor |
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)` | `void` | Remove custom styles |
784
+ | `unregisterStyles(id)` | Remove custom styles |
785
785
 
786
786
  ### ReactGridAdapter
787
787
 
@@ -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;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;;;;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"}
@@ -1,11 +1,11 @@
1
1
  import { SelectionPlugin as i } from "@toolbox-web/grid/plugins/selection";
2
- import { useContext as w, useCallback as o } from "react";
3
- import { G as S } from "../chunks/data-grid-CGvHh_mp.js";
4
- import { r as C } from "../chunks/feature-registry-Y3KvnN54.js";
5
- C("selection", (e) => e === "cell" || e === "row" || e === "range" ? new i({ mode: e }) : new i(e ?? void 0));
6
- function P() {
7
- const e = w(S), t = o(() => e?.current?.getPlugin(i), [e]), g = o(() => {
8
- const n = t();
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 = e?.current, u = n.config?.mode;
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
- }, [t, e]), d = o(() => {
28
- t()?.clearSelection();
29
- }, [t]), a = o(() => t()?.getSelection() ?? null, [t]), m = o(
30
- (n, r) => t()?.isCellSelected(n, r) ?? !1,
31
- [t]
32
- ), f = o(
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
- t()?.setRanges(n);
34
+ e()?.setRanges(n);
35
35
  },
36
- [t]
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: m,
43
- setRanges: f
42
+ isCellSelected: w,
43
+ setRanges: m,
44
+ getSelectedRows: f
44
45
  };
45
46
  }
46
47
  export {
47
- P as useGridSelection
48
+ b as useGridSelection
48
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolbox-web/grid-react",
3
- "version": "0.12.2",
3
+ "version": "0.13.0",
4
4
  "description": "React adapter for @toolbox-web/grid data grid component",
5
5
  "type": "module",
6
6
  "main": "./index.js",