@toolbox-web/grid-react 0.18.1 → 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.
- package/features/export.d.ts +4 -1
- package/features/export.d.ts.map +1 -1
- package/features/export.js +12 -12
- package/features/filtering.d.ts +4 -1
- package/features/filtering.d.ts.map +1 -1
- package/features/filtering.js +34 -34
- package/features/print.d.ts +4 -1
- package/features/print.d.ts.map +1 -1
- package/features/print.js +10 -10
- package/features/selection.d.ts +4 -1
- package/features/selection.d.ts.map +1 -1
- package/features/selection.js +23 -23
- package/features/undo-redo.d.ts +4 -1
- package/features/undo-redo.d.ts.map +1 -1
- package/features/undo-redo.js +23 -23
- package/index.js +428 -380
- package/lib/use-grid.d.ts +5 -1
- package/lib/use-grid.d.ts.map +1 -1
- package/package.json +1 -1
package/features/export.d.ts
CHANGED
|
@@ -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
|
package/features/export.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,
|
|
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"}
|
package/features/export.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useContext as
|
|
2
|
-
import { G as
|
|
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
|
|
5
|
-
const
|
|
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
|
-
),
|
|
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
|
-
),
|
|
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]),
|
|
50
|
+
), s = n(() => t()?.isExporting() ?? !1, [t]), g = n(() => t()?.getLastExport() ?? null, [t]);
|
|
51
51
|
return {
|
|
52
|
-
exportToCsv:
|
|
53
|
-
exportToExcel:
|
|
54
|
-
exportToJson:
|
|
52
|
+
exportToCsv: p,
|
|
53
|
+
exportToExcel: l,
|
|
54
|
+
exportToJson: u,
|
|
55
55
|
isExporting: s,
|
|
56
|
-
getLastExport:
|
|
56
|
+
getLastExport: g
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
export {
|
|
60
|
-
|
|
60
|
+
m as useGridExport
|
|
61
61
|
};
|
package/features/filtering.d.ts
CHANGED
|
@@ -90,6 +90,9 @@ export interface FilteringMethods {
|
|
|
90
90
|
* );
|
|
91
91
|
* }
|
|
92
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'`.
|
|
93
96
|
*/
|
|
94
|
-
export declare function useGridFiltering(): FilteringMethods;
|
|
97
|
+
export declare function useGridFiltering(selector?: string): FilteringMethods;
|
|
95
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;;;;;OAKG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAE9G;;OAEG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IAEtD;;OAEG;IACH,UAAU,EAAE,MAAM,WAAW,EAAE,CAAC;IAEhC;;;OAGG;IACH,cAAc,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAEjF;;;OAGG;IACH,eAAe,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAE1D;;;OAGG;IACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAE1E;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAE5C;;OAEG;IACH,mBAAmB,EAAE,MAAM,MAAM,CAAC;IAElC;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;IAE9C;;OAEG;IACH,eAAe,EAAE,MAAM,WAAW,EAAE,CAAC;IAErC;;OAEG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IAE3C;;OAEG;IACH,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CAC7D;AAED
|
|
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;;;;;OAKG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAE9G;;OAEG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IAEtD;;OAEG;IACH,UAAU,EAAE,MAAM,WAAW,EAAE,CAAC;IAEhC;;;OAGG;IACH,cAAc,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAEjF;;;OAGG;IACH,eAAe,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAE1D;;;OAGG;IACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAE1E;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAE5C;;OAEG;IACH,mBAAmB,EAAE,MAAM,MAAM,CAAC;IAElC;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;IAE9C;;OAEG;IACH,eAAe,EAAE,MAAM,WAAW,EAAE,CAAC;IAErC;;OAEG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IAE3C;;OAEG;IACH,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CAC7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAuHpE"}
|
package/features/filtering.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { FilteringPlugin as c } from "@toolbox-web/grid/plugins/filtering";
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { flushSync as
|
|
4
|
-
import { createRoot as
|
|
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
5
|
import { registerFeature as E } from "@toolbox-web/grid/features/registry";
|
|
6
|
-
import { G as
|
|
6
|
+
import { G as k } from "../chunks/grid-element-context-BU3WvNtM.js";
|
|
7
7
|
E("filtering", (l) => {
|
|
8
8
|
if (typeof l == "boolean") return new c();
|
|
9
9
|
if (!l) return new c();
|
|
10
|
-
const
|
|
11
|
-
if (typeof
|
|
12
|
-
const s =
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const f =
|
|
17
|
-
|
|
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(
|
|
19
|
+
}), a.appendChild(g);
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
return new c(
|
|
22
|
+
return new c(e);
|
|
23
23
|
});
|
|
24
|
-
function
|
|
25
|
-
const
|
|
24
|
+
function x(l) {
|
|
25
|
+
const o = G(k), e = n(() => (l ? document.querySelector(l) : o?.current)?.getPluginByName("filtering"), [o, l]), s = n(
|
|
26
26
|
(t, i, r) => {
|
|
27
27
|
const u = e();
|
|
28
28
|
if (!u) {
|
|
@@ -37,7 +37,7 @@ function S() {
|
|
|
37
37
|
u.setFilter(t, i, r);
|
|
38
38
|
},
|
|
39
39
|
[e]
|
|
40
|
-
),
|
|
40
|
+
), a = n((t) => e()?.getFilter(t), [e]), d = n(() => e()?.getFilters() ?? [], [e]), g = n(
|
|
41
41
|
(t, i) => {
|
|
42
42
|
const r = e();
|
|
43
43
|
if (!r) {
|
|
@@ -52,7 +52,7 @@ function S() {
|
|
|
52
52
|
r.setFilterModel(t, i);
|
|
53
53
|
},
|
|
54
54
|
[e]
|
|
55
|
-
),
|
|
55
|
+
), f = n(
|
|
56
56
|
(t) => {
|
|
57
57
|
const i = e();
|
|
58
58
|
if (!i) {
|
|
@@ -67,7 +67,7 @@ function S() {
|
|
|
67
67
|
i.clearAllFilters(t);
|
|
68
68
|
},
|
|
69
69
|
[e]
|
|
70
|
-
),
|
|
70
|
+
), F = n(
|
|
71
71
|
(t, i) => {
|
|
72
72
|
const r = e();
|
|
73
73
|
if (!r) {
|
|
@@ -82,10 +82,10 @@ function S() {
|
|
|
82
82
|
r.clearFieldFilter(t, i);
|
|
83
83
|
},
|
|
84
84
|
[e]
|
|
85
|
-
),
|
|
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(
|
|
86
86
|
(t) => e()?.getBlankMode(t) ?? "all",
|
|
87
87
|
[e]
|
|
88
|
-
),
|
|
88
|
+
), h = n(
|
|
89
89
|
(t, i) => {
|
|
90
90
|
const r = e();
|
|
91
91
|
if (!r) {
|
|
@@ -102,20 +102,20 @@ function S() {
|
|
|
102
102
|
[e]
|
|
103
103
|
);
|
|
104
104
|
return {
|
|
105
|
-
setFilter:
|
|
106
|
-
getFilter:
|
|
107
|
-
getFilters:
|
|
108
|
-
setFilterModel:
|
|
109
|
-
clearAllFilters:
|
|
110
|
-
clearFieldFilter:
|
|
111
|
-
isFieldFiltered:
|
|
112
|
-
getFilteredRowCount:
|
|
113
|
-
getUniqueValues:
|
|
114
|
-
getStaleFilters:
|
|
115
|
-
getBlankMode:
|
|
116
|
-
toggleBlankFilter:
|
|
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
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
export {
|
|
120
|
-
|
|
120
|
+
x as useGridFiltering
|
|
121
121
|
};
|
package/features/print.d.ts
CHANGED
|
@@ -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
|
package/features/print.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/print.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,
|
|
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
|
|
2
|
-
import { G as
|
|
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
|
|
6
|
-
async (
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
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
|
|
17
|
+
await o.print(e);
|
|
18
18
|
},
|
|
19
19
|
[n]
|
|
20
|
-
),
|
|
21
|
-
return { print:
|
|
20
|
+
), g = r(() => n()?.isPrinting() ?? !1, [n]);
|
|
21
|
+
return { print: u, isPrinting: g };
|
|
22
22
|
}
|
|
23
23
|
export {
|
|
24
24
|
l as useGridPrint
|
package/features/selection.d.ts
CHANGED
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,KAAK,SAAS,EAAwB,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;;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;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAG,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAuE1F"}
|
package/features/selection.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useContext as
|
|
2
|
-
import { G as
|
|
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
|
|
5
|
-
const l =
|
|
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
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
for (let
|
|
20
|
-
t.selected =
|
|
21
|
-
} else if (
|
|
22
|
-
const
|
|
23
|
-
|
|
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]),
|
|
25
|
+
}, [e, l, o]), d = n(() => {
|
|
26
26
|
e()?.clearSelection();
|
|
27
|
-
}, [e]),
|
|
28
|
-
(t,
|
|
27
|
+
}, [e]), a = n(() => e()?.getSelection() ?? null, [e]), f = n(
|
|
28
|
+
(t, r) => e()?.isCellSelected(t, r) ?? !1,
|
|
29
29
|
[e]
|
|
30
|
-
),
|
|
30
|
+
), m = n(
|
|
31
31
|
(t) => {
|
|
32
32
|
e()?.setRanges(t);
|
|
33
33
|
},
|
|
34
34
|
[e]
|
|
35
|
-
),
|
|
35
|
+
), S = n(() => e()?.getSelectedRows() ?? [], [e]);
|
|
36
36
|
return {
|
|
37
37
|
selectAll: g,
|
|
38
|
-
clearSelection:
|
|
39
|
-
getSelection:
|
|
40
|
-
isCellSelected:
|
|
41
|
-
setRanges:
|
|
42
|
-
getSelectedRows:
|
|
38
|
+
clearSelection: d,
|
|
39
|
+
getSelection: a,
|
|
40
|
+
isCellSelected: f,
|
|
41
|
+
setRanges: m,
|
|
42
|
+
getSelectedRows: S
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
export {
|
|
46
|
-
|
|
46
|
+
G as useGridSelection
|
|
47
47
|
};
|
package/features/undo-redo.d.ts
CHANGED
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"undo-redo.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/undo-redo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EAAE,KAAK,cAAc,EAAuB,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,cAAc,GAAG,IAAI,CAAC;IAElC;;OAEG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC;IAEvB;;OAEG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC;IAEvB;;OAEG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IAEzB;;OAEG;IACH,YAAY,EAAE,MAAM,cAAc,EAAE,CAAC;IAErC;;OAEG;IACH,YAAY,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"}
|
package/features/undo-redo.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useContext as
|
|
2
|
-
import { G as
|
|
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
|
|
5
|
-
const
|
|
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]),
|
|
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]),
|
|
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]),
|
|
34
|
-
(o,
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
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
|
-
|
|
45
|
+
r.recordEdit(o, w, k, U);
|
|
46
46
|
},
|
|
47
47
|
[n]
|
|
48
|
-
),
|
|
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]),
|
|
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:
|
|
75
|
-
redo:
|
|
76
|
-
canUndo:
|
|
77
|
-
canRedo:
|
|
74
|
+
undo: i,
|
|
75
|
+
redo: u,
|
|
76
|
+
canUndo: c,
|
|
77
|
+
canRedo: a,
|
|
78
78
|
clearHistory: l,
|
|
79
|
-
getUndoStack:
|
|
80
|
-
getRedoStack:
|
|
81
|
-
recordEdit:
|
|
82
|
-
beginTransaction:
|
|
83
|
-
endTransaction:
|
|
79
|
+
getUndoStack: g,
|
|
80
|
+
getRedoStack: s,
|
|
81
|
+
recordEdit: R,
|
|
82
|
+
beginTransaction: b,
|
|
83
|
+
endTransaction: f
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
export {
|
|
87
|
-
|
|
87
|
+
h as useGridUndoRedo
|
|
88
88
|
};
|