@toolbox-web/grid-react 2.0.0-rc.0 → 2.0.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.
@@ -1,61 +1,46 @@
1
- import { useContext as c, useCallback as n } from "react";
2
- import { G as a } from "../chunks/grid-element-context-BU3WvNtM.js";
1
+ import { t as e } from "../chunks/grid-element-context-DpuQsoie.js";
2
+ import { useCallback as t, useContext as n } from "react";
3
3
  import "@toolbox-web/grid/features/export";
4
- function m(i) {
5
- const x = c(a), t = n(() => (i ? document.querySelector(i) : x?.current)?.getPluginByName("export"), [x, i]), p = n(
6
- (r, o) => {
7
- const e = t();
8
- if (!e) {
9
- console.warn(
10
- `[tbw-grid:export] ExportPlugin not found.
11
-
12
- → Enable export on the grid:
13
- <DataGrid export />`
14
- );
15
- return;
16
- }
17
- e.exportCsv({ ...o, fileName: r ?? o?.fileName ?? "export.csv" });
18
- },
19
- [t]
20
- ), l = n(
21
- (r, o) => {
22
- const e = t();
23
- if (!e) {
24
- console.warn(
25
- `[tbw-grid:export] ExportPlugin not found.
26
-
27
- → Enable export on the grid:
28
- <DataGrid export />`
29
- );
30
- return;
31
- }
32
- e.exportExcel({ ...o, fileName: r ?? o?.fileName ?? "export.xlsx" });
33
- },
34
- [t]
35
- ), u = n(
36
- (r, o) => {
37
- const e = t();
38
- if (!e) {
39
- console.warn(
40
- `[tbw-grid:export] ExportPlugin not found.
41
-
42
- → Enable export on the grid:
43
- <DataGrid export />`
44
- );
45
- return;
46
- }
47
- e.exportJson({ ...o, fileName: r ?? o?.fileName ?? "export.json" });
48
- },
49
- [t]
50
- ), s = n(() => t()?.isExporting() ?? !1, [t]), g = n(() => t()?.getLastExport() ?? null, [t]);
51
- return {
52
- exportToCsv: p,
53
- exportToExcel: l,
54
- exportToJson: u,
55
- isExporting: s,
56
- getLastExport: g
57
- };
4
+ //#region libs/grid-react/src/features/export.ts
5
+ function r(r) {
6
+ let i = n(e), a = t(() => (r ? document.querySelector(r) : i?.current)?.getPluginByName("export"), [i, r]);
7
+ return {
8
+ exportToCsv: t((e, t) => {
9
+ let n = a();
10
+ if (!n) {
11
+ console.warn("[tbw-grid:export] ExportPlugin not found.\n\n → Enable export on the grid:\n <DataGrid export />");
12
+ return;
13
+ }
14
+ n.exportCsv({
15
+ ...t,
16
+ fileName: e ?? t?.fileName ?? "export.csv"
17
+ });
18
+ }, [a]),
19
+ exportToExcel: t((e, t) => {
20
+ let n = a();
21
+ if (!n) {
22
+ console.warn("[tbw-grid:export] ExportPlugin not found.\n\n → Enable export on the grid:\n <DataGrid export />");
23
+ return;
24
+ }
25
+ n.exportExcel({
26
+ ...t,
27
+ fileName: e ?? t?.fileName ?? "export.xlsx"
28
+ });
29
+ }, [a]),
30
+ exportToJson: t((e, t) => {
31
+ let n = a();
32
+ if (!n) {
33
+ console.warn("[tbw-grid:export] ExportPlugin not found.\n\n → Enable export on the grid:\n <DataGrid export />");
34
+ return;
35
+ }
36
+ n.exportJson({
37
+ ...t,
38
+ fileName: e ?? t?.fileName ?? "export.json"
39
+ });
40
+ }, [a]),
41
+ isExporting: t(() => a()?.isExporting() ?? !1, [a]),
42
+ getLastExport: t(() => a()?.getLastExport() ?? null, [a])
43
+ };
58
44
  }
59
- export {
60
- m as useGridExport
61
- };
45
+ //#endregion
46
+ export { r as useGridExport };
@@ -1,134 +1,84 @@
1
- import { FilteringPlugin as F } from "@toolbox-web/grid/plugins/filtering";
2
- import { useContext as h, useCallback as n } from "react";
3
- import { registerFeature as E } from "@toolbox-web/grid/features/registry";
4
- import { G as k } from "../chunks/grid-element-context-BU3WvNtM.js";
5
- import { r as v, a as m } from "../chunks/portal-bridge-CvxNt40O.js";
6
- import { r as C } from "../chunks/react-grid-adapter-BhC9x425.js";
7
- E(
8
- "filtering",
9
- (l) => {
10
- if (typeof l == "boolean") return new F();
11
- if (!l) return new F();
12
- const o = l, e = { ...o };
13
- if (typeof o.filterPanelRenderer == "function" && o.filterPanelRenderer.length <= 1) {
14
- const f = o.filterPanelRenderer, s = /* @__PURE__ */ new WeakMap();
15
- e.filterPanelRenderer = (a, g) => {
16
- const c = s.get(a);
17
- c && v(c);
18
- const d = document.createElement("div");
19
- d.style.display = "contents";
20
- const u = m(d, f(g));
21
- s.set(a, u), a.appendChild(d);
22
- };
23
- }
24
- return new F(e);
25
- },
26
- { override: !0 }
27
- );
28
- C((l, o, { trackPortal: e }) => {
29
- const f = l;
30
- return (s, a) => {
31
- const g = document.createElement("div");
32
- g.style.display = "contents";
33
- const c = s.closest("tbw-grid, [data-tbw-grid]") ?? o, d = m(g, f(a), void 0, c);
34
- e(d, g, !1), s.appendChild(g);
35
- };
1
+ import { a as e } from "../chunks/react-grid-adapter-CZfpPJvo.js";
2
+ import { a as t, i as n } from "../chunks/portal-bridge-zxgm_jwK.js";
3
+ import { t as r } from "../chunks/feature-registry-8K2rOVnC.js";
4
+ import { t as i } from "../chunks/grid-element-context-DpuQsoie.js";
5
+ import { useCallback as a, useContext as o } from "react";
6
+ import { FilteringPlugin as s } from "@toolbox-web/grid/plugins/filtering";
7
+ r("filtering", (e) => {
8
+ if (typeof e == "boolean" || !e) return new s();
9
+ let r = e, i = { ...r };
10
+ if (typeof r.filterPanelRenderer == "function" && r.filterPanelRenderer.length <= 1) {
11
+ let e = r.filterPanelRenderer, a = /* @__PURE__ */ new WeakMap();
12
+ i.filterPanelRenderer = (r, i) => {
13
+ let o = a.get(r);
14
+ o && n(o);
15
+ let s = document.createElement("div");
16
+ s.style.display = "contents";
17
+ let c = t(s, e(i));
18
+ a.set(r, c), r.appendChild(s);
19
+ };
20
+ }
21
+ return new s(i);
22
+ }, { override: !0 }), e((e, n, { trackPortal: r }) => {
23
+ let i = e;
24
+ return (e, a) => {
25
+ let o = document.createElement("div");
26
+ o.style.display = "contents";
27
+ let s = e.closest("tbw-grid, [data-tbw-grid]") ?? n;
28
+ r(t(o, i(a), void 0, s), o, !1), e.appendChild(o);
29
+ };
36
30
  });
37
- function K(l) {
38
- const o = h(k), e = n(() => (l ? document.querySelector(l) : o?.current)?.getPluginByName("filtering"), [o, l]), f = n(
39
- (t, r, i) => {
40
- const p = e();
41
- if (!p) {
42
- console.warn(
43
- `[tbw-grid:filtering] FilteringPlugin not found.
44
-
45
- → Enable filtering on the grid:
46
- <DataGrid filtering />`
47
- );
48
- return;
49
- }
50
- p.setFilter(t, r, i);
51
- },
52
- [e]
53
- ), s = n((t) => e()?.getFilter(t), [e]), a = n(() => e()?.getFilters() ?? [], [e]), g = n(
54
- (t, r) => {
55
- const i = e();
56
- if (!i) {
57
- console.warn(
58
- `[tbw-grid:filtering] FilteringPlugin not found.
59
-
60
- → Enable filtering on the grid:
61
- <DataGrid filtering />`
62
- );
63
- return;
64
- }
65
- i.setFilterModel(t, r);
66
- },
67
- [e]
68
- ), c = n(
69
- (t) => {
70
- const r = e();
71
- if (!r) {
72
- console.warn(
73
- `[tbw-grid:filtering] FilteringPlugin not found.
74
-
75
- → Enable filtering on the grid:
76
- <DataGrid filtering />`
77
- );
78
- return;
79
- }
80
- r.clearAllFilters(t);
81
- },
82
- [e]
83
- ), d = n(
84
- (t, r) => {
85
- const i = e();
86
- if (!i) {
87
- console.warn(
88
- `[tbw-grid:filtering] FilteringPlugin not found.
89
-
90
- → Enable filtering on the grid:
91
- <DataGrid filtering />`
92
- );
93
- return;
94
- }
95
- i.clearFieldFilter(t, r);
96
- },
97
- [e]
98
- ), u = n((t) => e()?.isFieldFiltered(t) ?? !1, [e]), w = n(() => e()?.getFilteredRowCount() ?? 0, [e]), b = n((t) => e()?.getUniqueValues(t) ?? [], [e]), y = n(() => e()?.getStaleFilters() ?? [], [e]), P = n(
99
- (t) => e()?.getBlankMode(t) ?? "all",
100
- [e]
101
- ), G = n(
102
- (t, r) => {
103
- const i = e();
104
- if (!i) {
105
- console.warn(
106
- `[tbw-grid:filtering] FilteringPlugin not found.
107
-
108
- → Enable filtering on the grid:
109
- <DataGrid filtering />`
110
- );
111
- return;
112
- }
113
- i.toggleBlankFilter(t, r);
114
- },
115
- [e]
116
- );
117
- return {
118
- setFilter: f,
119
- getFilter: s,
120
- getFilters: a,
121
- setFilterModel: g,
122
- clearAllFilters: c,
123
- clearFieldFilter: d,
124
- isFieldFiltered: u,
125
- getFilteredRowCount: w,
126
- getUniqueValues: b,
127
- getStaleFilters: y,
128
- getBlankMode: P,
129
- toggleBlankFilter: G
130
- };
31
+ function c(e) {
32
+ let t = o(i), n = a(() => (e ? document.querySelector(e) : t?.current)?.getPluginByName("filtering"), [t, e]);
33
+ return {
34
+ setFilter: a((e, t, r) => {
35
+ let i = n();
36
+ if (!i) {
37
+ console.warn("[tbw-grid:filtering] FilteringPlugin not found.\n\n → Enable filtering on the grid:\n <DataGrid filtering />");
38
+ return;
39
+ }
40
+ i.setFilter(e, t, r);
41
+ }, [n]),
42
+ getFilter: a((e) => n()?.getFilter(e), [n]),
43
+ getFilters: a(() => n()?.getFilters() ?? [], [n]),
44
+ setFilterModel: a((e, t) => {
45
+ let r = n();
46
+ if (!r) {
47
+ console.warn("[tbw-grid:filtering] FilteringPlugin not found.\n\n → Enable filtering on the grid:\n <DataGrid filtering />");
48
+ return;
49
+ }
50
+ r.setFilterModel(e, t);
51
+ }, [n]),
52
+ clearAllFilters: a((e) => {
53
+ let t = n();
54
+ if (!t) {
55
+ console.warn("[tbw-grid:filtering] FilteringPlugin not found.\n\n → Enable filtering on the grid:\n <DataGrid filtering />");
56
+ return;
57
+ }
58
+ t.clearAllFilters(e);
59
+ }, [n]),
60
+ clearFieldFilter: a((e, t) => {
61
+ let r = n();
62
+ if (!r) {
63
+ console.warn("[tbw-grid:filtering] FilteringPlugin not found.\n\n → Enable filtering on the grid:\n <DataGrid filtering />");
64
+ return;
65
+ }
66
+ r.clearFieldFilter(e, t);
67
+ }, [n]),
68
+ isFieldFiltered: a((e) => n()?.isFieldFiltered(e) ?? !1, [n]),
69
+ getFilteredRowCount: a(() => n()?.getFilteredRowCount() ?? 0, [n]),
70
+ getUniqueValues: a((e) => n()?.getUniqueValues(e) ?? [], [n]),
71
+ getStaleFilters: a(() => n()?.getStaleFilters() ?? [], [n]),
72
+ getBlankMode: a((e) => n()?.getBlankMode(e) ?? "all", [n]),
73
+ toggleBlankFilter: a((e, t) => {
74
+ let r = n();
75
+ if (!r) {
76
+ console.warn("[tbw-grid:filtering] FilteringPlugin not found.\n\n → Enable filtering on the grid:\n <DataGrid filtering />");
77
+ return;
78
+ }
79
+ r.toggleBlankFilter(e, t);
80
+ }, [n])
81
+ };
131
82
  }
132
- export {
133
- K as useGridFiltering
134
- };
83
+ //#endregion
84
+ export { c as useGridFiltering };
@@ -1,25 +1,25 @@
1
- import { GroupingColumnsPlugin as t } from "@toolbox-web/grid/plugins/grouping-columns";
2
- import { registerFeature as c } from "@toolbox-web/grid/features/registry";
3
- import { c as p } from "../chunks/portal-bridge-CvxNt40O.js";
4
- function u(n) {
5
- const r = p(n);
6
- return (o) => r(o) ?? document.createElement("div");
1
+ import { n as e } from "../chunks/portal-bridge-zxgm_jwK.js";
2
+ import { t } from "../chunks/feature-registry-8K2rOVnC.js";
3
+ import { GroupingColumnsPlugin as n } from "@toolbox-web/grid/plugins/grouping-columns";
4
+ //#region libs/grid-react/src/features/grouping-columns.ts
5
+ function r(t) {
6
+ let n = e(t);
7
+ return (e) => n(e) ?? document.createElement("div");
7
8
  }
8
- c(
9
- "groupingColumns",
10
- (n) => {
11
- if (typeof n == "boolean") return new t();
12
- if (!n) return new t();
13
- const r = n, o = { ...r };
14
- if (typeof r.groupHeaderRenderer == "function") {
15
- const e = r.groupHeaderRenderer;
16
- o.groupHeaderRenderer = u(e);
17
- }
18
- return Array.isArray(r.columnGroups) && (o.columnGroups = r.columnGroups.map((e) => {
19
- if (typeof e.renderer != "function") return e;
20
- const i = e.renderer;
21
- return { ...e, renderer: u(i) };
22
- })), new t(o);
23
- },
24
- { override: !0 }
25
- );
9
+ t("groupingColumns", (e) => {
10
+ if (typeof e == "boolean" || !e) return new n();
11
+ let t = e, i = { ...t };
12
+ if (typeof t.groupHeaderRenderer == "function") {
13
+ let e = t.groupHeaderRenderer;
14
+ i.groupHeaderRenderer = r(e);
15
+ }
16
+ return Array.isArray(t.columnGroups) && (i.columnGroups = t.columnGroups.map((e) => {
17
+ if (typeof e.renderer != "function") return e;
18
+ let t = e.renderer;
19
+ return {
20
+ ...e,
21
+ renderer: r(t)
22
+ };
23
+ })), new n(i);
24
+ }, { override: !0 });
25
+ //#endregion
@@ -1,17 +1,14 @@
1
- import { GroupingRowsPlugin as o } from "@toolbox-web/grid/plugins/grouping-rows";
2
- import { registerFeature as c } from "@toolbox-web/grid/features/registry";
3
- import { c as p } from "../chunks/portal-bridge-CvxNt40O.js";
4
- c(
5
- "groupingRows",
6
- (e) => {
7
- if (typeof e == "boolean") return new o();
8
- if (!e) return new o();
9
- const r = e, n = { ...r };
10
- if (typeof r.groupRowRenderer == "function") {
11
- const t = r.groupRowRenderer, i = p(t);
12
- n.groupRowRenderer = (u) => i(u) ?? document.createElement("div");
13
- }
14
- return new o(n);
15
- },
16
- { override: !0 }
17
- );
1
+ import { n as e } from "../chunks/portal-bridge-zxgm_jwK.js";
2
+ import { t } from "../chunks/feature-registry-8K2rOVnC.js";
3
+ import { GroupingRowsPlugin as n } from "@toolbox-web/grid/plugins/grouping-rows";
4
+ //#region libs/grid-react/src/features/grouping-rows.ts
5
+ t("groupingRows", (t) => {
6
+ if (typeof t == "boolean" || !t) return new n();
7
+ let r = t, i = { ...r };
8
+ if (typeof r.groupRowRenderer == "function") {
9
+ let t = r.groupRowRenderer, n = e(t);
10
+ i.groupRowRenderer = (e) => n(e) ?? document.createElement("div");
11
+ }
12
+ return new n(i);
13
+ }, { override: !0 });
14
+ //#endregion
package/features/index.js CHANGED
@@ -1,27 +1,25 @@
1
- import "@toolbox-web/grid/features/clipboard";
2
- import "@toolbox-web/grid/features/column-virtualization";
3
- import "@toolbox-web/grid/features/context-menu";
1
+ import "./clipboard.js";
2
+ import "./column-virtualization.js";
3
+ import "./context-menu.js";
4
4
  import "./editing.js";
5
- import "react";
6
- import "../chunks/grid-element-context-BU3WvNtM.js";
7
- import "@toolbox-web/grid/features/export";
5
+ import "./export.js";
8
6
  import "./filtering.js";
9
7
  import "./grouping-columns.js";
10
8
  import "./grouping-rows.js";
11
9
  import "./master-detail.js";
12
- import "@toolbox-web/grid/features/multi-sort";
13
- import "@toolbox-web/grid/features/pinned-columns";
10
+ import "./multi-sort.js";
11
+ import "./pinned-columns.js";
14
12
  import "./pinned-rows.js";
15
- import "@toolbox-web/grid/features/pivot";
16
- import "@toolbox-web/grid/features/print";
17
- import "@toolbox-web/grid/features/reorder-columns";
13
+ import "./pivot.js";
14
+ import "./print.js";
15
+ import "./reorder-columns.js";
18
16
  import "./responsive.js";
19
- import "@toolbox-web/grid/features/row-drag-drop";
20
- import "@toolbox-web/grid/features/selection";
21
- import "@toolbox-web/grid/features/server-side";
22
- import "@toolbox-web/grid/features/shell";
23
- import "@toolbox-web/grid/features/sticky-rows";
24
- import "@toolbox-web/grid/features/tooltip";
25
- import "@toolbox-web/grid/features/tree";
26
- import "@toolbox-web/grid/features/undo-redo";
27
- import "@toolbox-web/grid/features/visibility";
17
+ import "./row-drag-drop.js";
18
+ import "./selection.js";
19
+ import "./server-side.js";
20
+ import "./shell.js";
21
+ import "./sticky-rows.js";
22
+ import "./tooltip.js";
23
+ import "./tree.js";
24
+ import "./undo-redo.js";
25
+ import "./visibility.js";
@@ -1,65 +1,50 @@
1
+ import { i as e } from "../chunks/react-grid-adapter-CZfpPJvo.js";
2
+ import { a as t, i as n } from "../chunks/portal-bridge-zxgm_jwK.js";
3
+ import { n as r } from "../chunks/post-mount-refresh-hooks-D7BDK4Kl.js";
4
+ import { t as i } from "../chunks/feature-registry-8K2rOVnC.js";
5
+ import { n as a } from "../chunks/grid-detail-panel-CLdX0T_A.js";
1
6
  import "@toolbox-web/grid/features/master-detail";
2
- import { MasterDetailPlugin as c } from "@toolbox-web/grid/plugins/master-detail";
3
- import { registerFeature as m } from "@toolbox-web/grid/features/registry";
4
- import { g as f } from "../chunks/grid-detail-panel-BZFcujsZ.js";
5
- import { r as p, a as d } from "../chunks/portal-bridge-CvxNt40O.js";
6
- import { r as g } from "../chunks/post-mount-refresh-hooks-Dt7mPoZC.js";
7
- import { a as y } from "../chunks/react-grid-adapter-BhC9x425.js";
8
- y((t, { trackPortal: e }) => {
9
- const n = f(t);
10
- if (n)
11
- return (s, a) => {
12
- const o = document.createElement("div");
13
- o.className = "react-detail-panel";
14
- const r = d(
15
- o,
16
- n({ row: s, rowIndex: a }),
17
- void 0,
18
- t
19
- );
20
- return e(r, o, !1), o;
21
- };
7
+ import { MasterDetailPlugin as o } from "@toolbox-web/grid/plugins/master-detail";
8
+ e((e, { trackPortal: n }) => {
9
+ let r = a(e);
10
+ if (r) return (i, a) => {
11
+ let o = document.createElement("div");
12
+ return o.className = "react-detail-panel", n(t(o, r({
13
+ row: i,
14
+ rowIndex: a
15
+ }), void 0, e), o, !1), o;
16
+ };
17
+ }), r("masterDetail", ({ gridEl: e }) => {
18
+ e.getPluginByName("masterDetail")?.refreshDetailRenderer?.();
22
19
  });
23
- g("masterDetail", ({ gridEl: t }) => {
24
- t.getPluginByName("masterDetail")?.refreshDetailRenderer?.();
25
- });
26
- class h extends c {
27
- #e;
28
- constructor(e, n) {
29
- super(e), this.#e = n;
30
- }
31
- detach() {
32
- super.detach();
33
- for (const e of this.#e)
34
- try {
35
- p(e, { sync: !1 });
36
- } catch {
37
- }
38
- this.#e.clear();
39
- }
40
- }
41
- m(
42
- "masterDetail",
43
- (t) => {
44
- const e = t == null || typeof t == "boolean" ? {} : t, n = e.detailRenderer;
45
- if (typeof n != "function")
46
- return new c(e);
47
- const s = /* @__PURE__ */ new Set(), a = (o, l) => {
48
- const r = n(
49
- o,
50
- l
51
- );
52
- if (r == null || r === !1) return document.createElement("div");
53
- if (typeof r == "string" || r instanceof HTMLElement) return r;
54
- const i = document.createElement("div");
55
- i.className = "react-detail-panel";
56
- const u = d(i, r);
57
- return s.add(u), i;
58
- };
59
- return new h(
60
- { ...e, detailRenderer: a },
61
- s
62
- );
63
- },
64
- { override: !0 }
65
- );
20
+ var s = class extends o {
21
+ #e;
22
+ constructor(e, t) {
23
+ super(e), this.#e = t;
24
+ }
25
+ detach() {
26
+ super.detach();
27
+ for (let e of this.#e) try {
28
+ n(e, { sync: !1 });
29
+ } catch {}
30
+ this.#e.clear();
31
+ }
32
+ };
33
+ i("masterDetail", (e) => {
34
+ let n = e == null || typeof e == "boolean" ? {} : e, r = n.detailRenderer;
35
+ if (typeof r != "function") return new o(n);
36
+ let i = /* @__PURE__ */ new Set(), a = (e, n) => {
37
+ let a = r(e, n);
38
+ if (a == null || a === !1) return document.createElement("div");
39
+ if (typeof a == "string" || a instanceof HTMLElement) return a;
40
+ let o = document.createElement("div");
41
+ o.className = "react-detail-panel";
42
+ let s = t(o, a);
43
+ return i.add(s), o;
44
+ };
45
+ return new s({
46
+ ...n,
47
+ detailRenderer: a
48
+ }, i);
49
+ }, { override: !0 });
50
+ //#endregion