@toolbox-web/grid-react 0.18.0 → 0.18.2

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.
@@ -54,6 +54,9 @@ export interface ExportMethods {
54
54
  * );
55
55
  * }
56
56
  * ```
57
+ * @param selector - Optional CSS selector to target a specific grid element via
58
+ * DOM query instead of using React context. Use when the component contains
59
+ * multiple grids, e.g. `'tbw-grid.primary'` or `'#my-grid'`.
57
60
  */
58
- export declare function useGridExport(): ExportMethods;
61
+ export declare function useGridExport(selector?: string): ExportMethods;
59
62
  //# sourceMappingURL=export.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAqB,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAK3G,OAAO,mCAAmC,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAEzE;;;;OAIG;IACH,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAE3E;;;;OAIG;IACH,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAE1E;;OAEG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC;IAE3B;;OAEG;IACH,aAAa,EAAE,MAAM;QAAE,MAAM,EAAE,YAAY,CAAC;QAAC,SAAS,EAAE,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CACvE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,IAAI,aAAa,CAuE7C"}
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAqB,MAAM,kCAAkC,CAAC;AAK3G,OAAO,mCAAmC,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAEzE;;;;OAIG;IACH,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAE3E;;;;OAIG;IACH,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAE1E;;OAEG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC;IAE3B;;OAEG;IACH,aAAa,EAAE,MAAM;QAAE,MAAM,EAAE,YAAY,CAAC;QAAC,SAAS,EAAE,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CACvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,aAAa,CAuE9D"}
@@ -1,8 +1,8 @@
1
- import { useContext as g, useCallback as n } from "react";
2
- import { G as c } from "../chunks/grid-element-context-BU3WvNtM.js";
1
+ import { useContext as c, useCallback as n } from "react";
2
+ import { G as a } from "../chunks/grid-element-context-BU3WvNtM.js";
3
3
  import "@toolbox-web/grid/features/export";
4
- function E() {
5
- const i = g(c), t = n(() => i?.current?.getPluginByName("export"), [i]), x = n(
4
+ function m(i) {
5
+ const x = c(a), t = n(() => (i ? document.querySelector(i) : x?.current)?.getPluginByName("export"), [x, i]), p = n(
6
6
  (r, o) => {
7
7
  const e = t();
8
8
  if (!e) {
@@ -17,7 +17,7 @@ function E() {
17
17
  e.exportCsv({ ...o, fileName: r ?? o?.fileName ?? "export.csv" });
18
18
  },
19
19
  [t]
20
- ), p = n(
20
+ ), l = n(
21
21
  (r, o) => {
22
22
  const e = t();
23
23
  if (!e) {
@@ -32,7 +32,7 @@ function E() {
32
32
  e.exportExcel({ ...o, fileName: r ?? o?.fileName ?? "export.xlsx" });
33
33
  },
34
34
  [t]
35
- ), l = n(
35
+ ), u = n(
36
36
  (r, o) => {
37
37
  const e = t();
38
38
  if (!e) {
@@ -47,15 +47,15 @@ function E() {
47
47
  e.exportJson({ ...o, fileName: r ?? o?.fileName ?? "export.json" });
48
48
  },
49
49
  [t]
50
- ), s = n(() => t()?.isExporting() ?? !1, [t]), u = n(() => t()?.getLastExport() ?? null, [t]);
50
+ ), s = n(() => t()?.isExporting() ?? !1, [t]), g = n(() => t()?.getLastExport() ?? null, [t]);
51
51
  return {
52
- exportToCsv: x,
53
- exportToExcel: p,
54
- exportToJson: l,
52
+ exportToCsv: p,
53
+ exportToExcel: l,
54
+ exportToJson: u,
55
55
  isExporting: s,
56
- getLastExport: u
56
+ getLastExport: g
57
57
  };
58
58
  }
59
59
  export {
60
- E as useGridExport
60
+ m as useGridExport
61
61
  };
@@ -7,8 +7,11 @@ export interface FilteringMethods {
7
7
  * Set a filter on a specific field.
8
8
  * @param field - The field name to filter
9
9
  * @param filter - Filter configuration, or null to remove
10
+ * @param options - `{ silent: true }` applies the filter without emitting `filter-change`
10
11
  */
11
- setFilter: (field: string, filter: Omit<FilterModel, 'field'> | null) => void;
12
+ setFilter: (field: string, filter: Omit<FilterModel, 'field'> | null, options?: {
13
+ silent?: boolean;
14
+ }) => void;
12
15
  /**
13
16
  * Get the current filter for a field.
14
17
  */
@@ -19,16 +22,25 @@ export interface FilteringMethods {
19
22
  getFilters: () => FilterModel[];
20
23
  /**
21
24
  * Set all filters at once (replaces existing).
25
+ * @param options - `{ silent: true }` applies filters without emitting `filter-change`
22
26
  */
23
- setFilterModel: (filters: FilterModel[]) => void;
27
+ setFilterModel: (filters: FilterModel[], options?: {
28
+ silent?: boolean;
29
+ }) => void;
24
30
  /**
25
31
  * Clear all active filters.
32
+ * @param options - `{ silent: true }` clears filters without emitting `filter-change`
26
33
  */
27
- clearAllFilters: () => void;
34
+ clearAllFilters: (options?: {
35
+ silent?: boolean;
36
+ }) => void;
28
37
  /**
29
38
  * Clear filter for a specific field.
39
+ * @param options - `{ silent: true }` clears filter without emitting `filter-change`
30
40
  */
31
- clearFieldFilter: (field: string) => void;
41
+ clearFieldFilter: (field: string, options?: {
42
+ silent?: boolean;
43
+ }) => void;
32
44
  /**
33
45
  * Check if a field has an active filter.
34
46
  */
@@ -78,6 +90,9 @@ export interface FilteringMethods {
78
90
  * );
79
91
  * }
80
92
  * ```
93
+ * @param selector - Optional CSS selector to target a specific grid element via
94
+ * DOM query instead of using React context. Use when the component contains
95
+ * multiple grids, e.g. `'tbw-grid.primary'` or `'#my-grid'`.
81
96
  */
82
- export declare function useGridFiltering(): FilteringMethods;
97
+ export declare function useGridFiltering(selector?: string): FilteringMethods;
83
98
  //# sourceMappingURL=filtering.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/filtering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,WAAW,EAEjB,MAAM,qCAAqC,CAAC;AAgC7C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAA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AAC,EAAE,MAAM,GAAG,gBAAgB,CAuHpE"}
@@ -1,31 +1,46 @@
1
1
  import { FilteringPlugin as c } from "@toolbox-web/grid/plugins/filtering";
2
- import { useContext as P, useCallback as n } from "react";
3
- import { flushSync as h } from "react-dom";
4
- import { createRoot as G } from "react-dom/client";
5
- import { registerFeature as R } from "@toolbox-web/grid/features/registry";
6
- import { G as E } from "../chunks/grid-element-context-BU3WvNtM.js";
7
- R("filtering", (r) => {
8
- if (typeof r == "boolean") return new c();
9
- if (!r) return new c();
10
- const e = r, g = { ...e };
11
- if (typeof e.filterPanelRenderer == "function" && e.filterPanelRenderer.length <= 1) {
12
- const s = e.filterPanelRenderer;
13
- g.filterPanelRenderer = (a, d) => {
14
- const l = document.createElement("div");
15
- l.style.display = "contents";
16
- const f = G(l);
17
- h(() => {
2
+ import { useContext as G, useCallback as n } from "react";
3
+ import { flushSync as R } from "react-dom";
4
+ import { createRoot as y } from "react-dom/client";
5
+ import { registerFeature as E } from "@toolbox-web/grid/features/registry";
6
+ import { G as k } from "../chunks/grid-element-context-BU3WvNtM.js";
7
+ E("filtering", (l) => {
8
+ if (typeof l == "boolean") return new c();
9
+ if (!l) return new c();
10
+ const o = l, e = { ...o };
11
+ if (typeof o.filterPanelRenderer == "function" && o.filterPanelRenderer.length <= 1) {
12
+ const s = o.filterPanelRenderer;
13
+ e.filterPanelRenderer = (a, d) => {
14
+ const g = document.createElement("div");
15
+ g.style.display = "contents";
16
+ const f = y(g);
17
+ R(() => {
18
18
  f.render(s(d));
19
- }), a.appendChild(l);
19
+ }), a.appendChild(g);
20
20
  };
21
21
  }
22
- return new c(g);
22
+ return new c(e);
23
23
  });
24
- function x() {
25
- const r = P(E), e = n(() => r?.current?.getPluginByName("filtering"), [r]), g = n(
24
+ function x(l) {
25
+ const o = G(k), e = n(() => (l ? document.querySelector(l) : o?.current)?.getPluginByName("filtering"), [o, l]), s = n(
26
+ (t, i, r) => {
27
+ const u = e();
28
+ if (!u) {
29
+ console.warn(
30
+ `[tbw-grid:filtering] FilteringPlugin not found.
31
+
32
+ → Enable filtering on the grid:
33
+ <DataGrid filtering />`
34
+ );
35
+ return;
36
+ }
37
+ u.setFilter(t, i, r);
38
+ },
39
+ [e]
40
+ ), a = n((t) => e()?.getFilter(t), [e]), d = n(() => e()?.getFilters() ?? [], [e]), g = n(
26
41
  (t, i) => {
27
- const o = e();
28
- if (!o) {
42
+ const r = e();
43
+ if (!r) {
29
44
  console.warn(
30
45
  `[tbw-grid:filtering] FilteringPlugin not found.
31
46
 
@@ -34,10 +49,10 @@ function x() {
34
49
  );
35
50
  return;
36
51
  }
37
- o.setFilter(t, i);
52
+ r.setFilterModel(t, i);
38
53
  },
39
54
  [e]
40
- ), s = n((t) => e()?.getFilter(t), [e]), a = n(() => e()?.getFilters() ?? [], [e]), d = n(
55
+ ), f = n(
41
56
  (t) => {
42
57
  const i = e();
43
58
  if (!i) {
@@ -49,25 +64,13 @@ function x() {
49
64
  );
50
65
  return;
51
66
  }
52
- i.setFilterModel(t);
67
+ i.clearAllFilters(t);
53
68
  },
54
69
  [e]
55
- ), l = n(() => {
56
- const t = e();
57
- if (!t) {
58
- console.warn(
59
- `[tbw-grid:filtering] FilteringPlugin not found.
60
-
61
- → Enable filtering on the grid:
62
- <DataGrid filtering />`
63
- );
64
- return;
65
- }
66
- t.clearAllFilters();
67
- }, [e]), f = n(
68
- (t) => {
69
- const i = e();
70
- if (!i) {
70
+ ), F = n(
71
+ (t, i) => {
72
+ const r = e();
73
+ if (!r) {
71
74
  console.warn(
72
75
  `[tbw-grid:filtering] FilteringPlugin not found.
73
76
 
@@ -76,16 +79,16 @@ function x() {
76
79
  );
77
80
  return;
78
81
  }
79
- i.clearFieldFilter(t);
82
+ r.clearFieldFilter(t, i);
80
83
  },
81
84
  [e]
82
- ), u = n((t) => e()?.isFieldFiltered(t) ?? !1, [e]), F = n(() => e()?.getFilteredRowCount() ?? 0, [e]), p = n((t) => e()?.getUniqueValues(t) ?? [], [e]), m = n(() => e()?.getStaleFilters() ?? [], [e]), w = n(
85
+ ), p = n((t) => e()?.isFieldFiltered(t) ?? !1, [e]), m = n(() => e()?.getFilteredRowCount() ?? 0, [e]), w = n((t) => e()?.getUniqueValues(t) ?? [], [e]), b = n(() => e()?.getStaleFilters() ?? [], [e]), P = n(
83
86
  (t) => e()?.getBlankMode(t) ?? "all",
84
87
  [e]
85
- ), b = n(
88
+ ), h = n(
86
89
  (t, i) => {
87
- const o = e();
88
- if (!o) {
90
+ const r = e();
91
+ if (!r) {
89
92
  console.warn(
90
93
  `[tbw-grid:filtering] FilteringPlugin not found.
91
94
 
@@ -94,23 +97,23 @@ function x() {
94
97
  );
95
98
  return;
96
99
  }
97
- o.toggleBlankFilter(t, i);
100
+ r.toggleBlankFilter(t, i);
98
101
  },
99
102
  [e]
100
103
  );
101
104
  return {
102
- setFilter: g,
103
- getFilter: s,
104
- getFilters: a,
105
- setFilterModel: d,
106
- clearAllFilters: l,
107
- clearFieldFilter: f,
108
- isFieldFiltered: u,
109
- getFilteredRowCount: F,
110
- getUniqueValues: p,
111
- getStaleFilters: m,
112
- getBlankMode: w,
113
- toggleBlankFilter: b
105
+ setFilter: s,
106
+ getFilter: a,
107
+ getFilters: d,
108
+ setFilterModel: g,
109
+ clearAllFilters: f,
110
+ clearFieldFilter: F,
111
+ isFieldFiltered: p,
112
+ getFilteredRowCount: m,
113
+ getUniqueValues: w,
114
+ getStaleFilters: b,
115
+ getBlankMode: P,
116
+ toggleBlankFilter: h
114
117
  };
115
118
  }
116
119
  export {
@@ -38,6 +38,9 @@ export interface PrintMethods {
38
38
  * );
39
39
  * }
40
40
  * ```
41
+ * @param selector - Optional CSS selector to target a specific grid element via
42
+ * DOM query instead of using React context. Use when the component contains
43
+ * multiple grids, e.g. `'tbw-grid.primary'` or `'#my-grid'`.
41
44
  */
42
- export declare function useGridPrint(): PrintMethods;
45
+ export declare function useGridPrint(selector?: string): PrintMethods;
43
46
  //# sourceMappingURL=print.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/print.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAKrF,OAAO,kCAAkC,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;OAEG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,IAAI,YAAY,CAyB3C"}
1
+ {"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/print.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,iCAAiC,CAAC;AAKrF,OAAO,kCAAkC,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;OAEG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,YAAY,CAyB5D"}
package/features/print.js CHANGED
@@ -1,11 +1,11 @@
1
- import { useContext as g, useCallback as t } from "react";
2
- import { G as u } from "../chunks/grid-element-context-BU3WvNtM.js";
1
+ import { useContext as s, useCallback as r } from "react";
2
+ import { G as a } from "../chunks/grid-element-context-BU3WvNtM.js";
3
3
  import "@toolbox-web/grid/features/print";
4
- function l() {
5
- const r = g(u), n = t(() => r?.current?.getPluginByName("print"), [r]), o = t(
6
- async (i) => {
7
- const e = n();
8
- if (!e) {
4
+ function l(t) {
5
+ const i = s(a), n = r(() => (t ? document.querySelector(t) : i?.current)?.getPluginByName("print"), [i, t]), u = r(
6
+ async (e) => {
7
+ const o = n();
8
+ if (!o) {
9
9
  console.warn(
10
10
  `[tbw-grid:print] PrintPlugin not found.
11
11
 
@@ -14,11 +14,11 @@ function l() {
14
14
  );
15
15
  return;
16
16
  }
17
- await e.print(i);
17
+ await o.print(e);
18
18
  },
19
19
  [n]
20
- ), s = t(() => n()?.isPrinting() ?? !1, [n]);
21
- return { print: o, isPrinting: s };
20
+ ), g = r(() => n()?.isPrinting() ?? !1, [n]);
21
+ return { print: u, isPrinting: g };
22
22
  }
23
23
  export {
24
24
  l as useGridPrint
@@ -61,6 +61,9 @@ export interface SelectionMethods<TRow = unknown> {
61
61
  * return <button onClick={handleExport}>Export Selected</button>;
62
62
  * }
63
63
  * ```
64
+ * @param selector - Optional CSS selector to target a specific grid element via
65
+ * DOM query instead of using React context. Use when the component contains
66
+ * multiple grids, e.g. `'tbw-grid.primary'` or `'#my-grid'`.
64
67
  */
65
- export declare function useGridSelection<TRow = unknown>(): SelectionMethods<TRow>;
68
+ export declare function useGridSelection<TRow = unknown>(selector?: string): SelectionMethods<TRow>;
66
69
  //# 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,EAAwB,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAKjH,OAAO,sCAAsC,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,GAAG,OAAO;IAC9C;;OAEG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IAEtB;;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BAAgB,gBAAgB,CAAC,IAAI,GAAG,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAuE1F"}
@@ -1,8 +1,8 @@
1
- import { useContext as m, useCallback as n } from "react";
2
- import { G as S } from "../chunks/grid-element-context-BU3WvNtM.js";
1
+ import { useContext as w, useCallback as n } from "react";
2
+ import { G as C } from "../chunks/grid-element-context-BU3WvNtM.js";
3
3
  import "@toolbox-web/grid/features/selection";
4
- function h() {
5
- const l = m(S), e = n(() => l?.current?.getPluginByName("selection"), [l]), g = n(() => {
4
+ function G(o) {
5
+ const l = w(C), e = n(() => (o ? document.querySelector(o) : l?.current)?.getPluginByName("selection"), [l, o]), g = n(() => {
6
6
  const t = e();
7
7
  if (!t) {
8
8
  console.warn(
@@ -13,35 +13,35 @@ function h() {
13
13
  );
14
14
  return;
15
15
  }
16
- const o = l?.current, i = t.config?.mode;
17
- if (i === "row") {
18
- const c = o?.rows?.length ?? 0, r = /* @__PURE__ */ new Set();
19
- for (let s = 0; s < c; s++) r.add(s);
20
- t.selected = r, t.requestAfterRender?.();
21
- } else if (i === "range") {
22
- const c = o?.rows?.length ?? 0, r = o?._columns?.length ?? 0;
23
- c > 0 && r > 0 && t.setRanges([{ from: { row: 0, col: 0 }, to: { row: c - 1, col: r - 1 } }]);
16
+ const r = o ? document.querySelector(o) : l?.current, u = t.config?.mode;
17
+ if (u === "row") {
18
+ const s = r?.rows?.length ?? 0, c = /* @__PURE__ */ new Set();
19
+ for (let i = 0; i < s; i++) c.add(i);
20
+ t.selected = c, t.requestAfterRender?.();
21
+ } else if (u === "range") {
22
+ const s = r?.rows?.length ?? 0, c = r?._columns?.length ?? 0;
23
+ s > 0 && c > 0 && t.setRanges([{ from: { row: 0, col: 0 }, to: { row: s - 1, col: c - 1 } }]);
24
24
  }
25
- }, [e, l]), u = n(() => {
25
+ }, [e, l, o]), d = n(() => {
26
26
  e()?.clearSelection();
27
- }, [e]), d = n(() => e()?.getSelection() ?? null, [e]), a = n(
28
- (t, o) => e()?.isCellSelected(t, o) ?? !1,
27
+ }, [e]), a = n(() => e()?.getSelection() ?? null, [e]), f = n(
28
+ (t, r) => e()?.isCellSelected(t, r) ?? !1,
29
29
  [e]
30
- ), f = n(
30
+ ), m = n(
31
31
  (t) => {
32
32
  e()?.setRanges(t);
33
33
  },
34
34
  [e]
35
- ), w = n(() => e()?.getSelectedRows() ?? [], [e]);
35
+ ), S = n(() => e()?.getSelectedRows() ?? [], [e]);
36
36
  return {
37
37
  selectAll: g,
38
- clearSelection: u,
39
- getSelection: d,
40
- isCellSelected: a,
41
- setRanges: f,
42
- getSelectedRows: w
38
+ clearSelection: d,
39
+ getSelection: a,
40
+ isCellSelected: f,
41
+ setRanges: m,
42
+ getSelectedRows: S
43
43
  };
44
44
  }
45
45
  export {
46
- h as useGridSelection
46
+ G as useGridSelection
47
47
  };
@@ -73,6 +73,9 @@ export interface UndoRedoMethods {
73
73
  * );
74
74
  * }
75
75
  * ```
76
+ * @param selector - Optional CSS selector to target a specific grid element via
77
+ * DOM query instead of using React context. Use when the component contains
78
+ * multiple grids, e.g. `'tbw-grid.primary'` or `'#my-grid'`.
76
79
  */
77
- export declare function useGridUndoRedo(): UndoRedoMethods;
80
+ export declare function useGridUndoRedo(selector?: string): UndoRedoMethods;
78
81
  //# sourceMappingURL=undo-redo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"undo-redo.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/undo-redo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAK/F,OAAO,sCAAsC,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,EAAE,MAAM,cAAc,GAAG,IAAI,CAAC;IAElC;;;OAGG;IACH,IAAI,EAAE,MAAM,c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Y,EAAE,MAAM,cAAc,EAAE,CAAC;IAErC;;;OAGG;IACH,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAE5F;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAE7B;;;;;OAKG;IACH,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,eAAe,CA6GlE"}
@@ -1,8 +1,8 @@
1
- import { useContext as U, useCallback as d } from "react";
2
- import { G as p } from "../chunks/grid-element-context-BU3WvNtM.js";
1
+ import { useContext as p, useCallback as d } from "react";
2
+ import { G as E } from "../chunks/grid-element-context-BU3WvNtM.js";
3
3
  import "@toolbox-web/grid/features/undo-redo";
4
- function m() {
5
- const e = U(p), n = d(() => e?.current?.getPluginByName("undoRedo"), [e]), r = d(() => {
4
+ function h(e) {
5
+ const t = p(E), n = d(() => (e ? document.querySelector(e) : t?.current)?.getPluginByName("undoRedo"), [t, e]), i = d(() => {
6
6
  const o = n();
7
7
  return o ? o.undo() : (console.warn(
8
8
  `[tbw-grid:undoRedo] UndoRedoPlugin not found.
@@ -10,7 +10,7 @@ function m() {
10
10
  → Enable undo/redo on the grid:
11
11
  <DataGrid editing="dblclick" undoRedo />`
12
12
  ), null);
13
- }, [n]), i = d(() => {
13
+ }, [n]), u = d(() => {
14
14
  const o = n();
15
15
  return o ? o.redo() : (console.warn(
16
16
  `[tbw-grid:undoRedo] UndoRedoPlugin not found.
@@ -18,7 +18,7 @@ function m() {
18
18
  → Enable undo/redo on the grid:
19
19
  <DataGrid editing="dblclick" undoRedo />`
20
20
  ), null);
21
- }, [n]), u = d(() => n()?.canUndo() ?? !1, [n]), c = d(() => n()?.canRedo() ?? !1, [n]), l = d(() => {
21
+ }, [n]), c = d(() => n()?.canUndo() ?? !1, [n]), a = d(() => n()?.canRedo() ?? !1, [n]), l = d(() => {
22
22
  const o = n();
23
23
  if (!o) {
24
24
  console.warn(
@@ -30,10 +30,10 @@ function m() {
30
30
  return;
31
31
  }
32
32
  o.clearHistory();
33
- }, [n]), a = d(() => n()?.getUndoStack() ?? [], [n]), g = d(() => n()?.getRedoStack() ?? [], [n]), s = d(
34
- (o, f, w, k) => {
35
- const t = n();
36
- if (!t) {
33
+ }, [n]), g = d(() => n()?.getUndoStack() ?? [], [n]), s = d(() => n()?.getRedoStack() ?? [], [n]), R = d(
34
+ (o, w, k, U) => {
35
+ const r = n();
36
+ if (!r) {
37
37
  console.warn(
38
38
  `[tbw-grid:undoRedo] UndoRedoPlugin not found.
39
39
 
@@ -42,10 +42,10 @@ function m() {
42
42
  );
43
43
  return;
44
44
  }
45
- t.recordEdit(o, f, w, k);
45
+ r.recordEdit(o, w, k, U);
46
46
  },
47
47
  [n]
48
- ), R = d(() => {
48
+ ), b = d(() => {
49
49
  const o = n();
50
50
  if (!o) {
51
51
  console.warn(
@@ -57,7 +57,7 @@ function m() {
57
57
  return;
58
58
  }
59
59
  o.beginTransaction();
60
- }, [n]), b = d(() => {
60
+ }, [n]), f = d(() => {
61
61
  const o = n();
62
62
  if (!o) {
63
63
  console.warn(
@@ -71,18 +71,18 @@ function m() {
71
71
  o.endTransaction();
72
72
  }, [n]);
73
73
  return {
74
- undo: r,
75
- redo: i,
76
- canUndo: u,
77
- canRedo: c,
74
+ undo: i,
75
+ redo: u,
76
+ canUndo: c,
77
+ canRedo: a,
78
78
  clearHistory: l,
79
- getUndoStack: a,
80
- getRedoStack: g,
81
- recordEdit: s,
82
- beginTransaction: R,
83
- endTransaction: b
79
+ getUndoStack: g,
80
+ getRedoStack: s,
81
+ recordEdit: R,
82
+ beginTransaction: b,
83
+ endTransaction: f
84
84
  };
85
85
  }
86
86
  export {
87
- m as useGridUndoRedo
87
+ h as useGridUndoRedo
88
88
  };