@toolbox-web/grid-react 0.18.0 → 0.18.1
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/filtering.d.ts +16 -4
- package/features/filtering.d.ts.map +1 -1
- package/features/filtering.js +54 -51
- package/package.json +1 -1
package/features/filtering.d.ts
CHANGED
|
@@ -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
|
|
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[]
|
|
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: (
|
|
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
|
|
41
|
+
clearFieldFilter: (field: string, options?: {
|
|
42
|
+
silent?: boolean;
|
|
43
|
+
}) => void;
|
|
32
44
|
/**
|
|
33
45
|
* Check if a field has an active filter.
|
|
34
46
|
*/
|
|
@@ -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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,CAuHnD"}
|
package/features/filtering.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { FilteringPlugin as c } from "@toolbox-web/grid/plugins/filtering";
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { flushSync as
|
|
4
|
-
import { createRoot as
|
|
5
|
-
import { registerFeature as
|
|
6
|
-
import { G as
|
|
7
|
-
|
|
8
|
-
if (typeof
|
|
9
|
-
if (!
|
|
10
|
-
const e =
|
|
2
|
+
import { useContext as h, useCallback as n } from "react";
|
|
3
|
+
import { flushSync as G } from "react-dom";
|
|
4
|
+
import { createRoot as R } from "react-dom/client";
|
|
5
|
+
import { registerFeature as E } from "@toolbox-web/grid/features/registry";
|
|
6
|
+
import { G as y } 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 e = l, g = { ...e };
|
|
11
11
|
if (typeof e.filterPanelRenderer == "function" && e.filterPanelRenderer.length <= 1) {
|
|
12
12
|
const s = e.filterPanelRenderer;
|
|
13
13
|
g.filterPanelRenderer = (a, d) => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const f =
|
|
17
|
-
|
|
14
|
+
const o = document.createElement("div");
|
|
15
|
+
o.style.display = "contents";
|
|
16
|
+
const f = R(o);
|
|
17
|
+
G(() => {
|
|
18
18
|
f.render(s(d));
|
|
19
|
-
}), a.appendChild(
|
|
19
|
+
}), a.appendChild(o);
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
return new c(g);
|
|
23
23
|
});
|
|
24
|
-
function
|
|
25
|
-
const
|
|
26
|
-
(t, i) => {
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
24
|
+
function S() {
|
|
25
|
+
const l = h(y), e = n(() => l?.current?.getPluginByName("filtering"), [l]), g = n(
|
|
26
|
+
(t, i, r) => {
|
|
27
|
+
const u = e();
|
|
28
|
+
if (!u) {
|
|
29
29
|
console.warn(
|
|
30
30
|
`[tbw-grid:filtering] FilteringPlugin not found.
|
|
31
31
|
|
|
@@ -34,13 +34,13 @@ function x() {
|
|
|
34
34
|
);
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
u.setFilter(t, i, r);
|
|
38
38
|
},
|
|
39
39
|
[e]
|
|
40
40
|
), s = n((t) => e()?.getFilter(t), [e]), a = n(() => e()?.getFilters() ?? [], [e]), d = n(
|
|
41
|
-
(t) => {
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
41
|
+
(t, i) => {
|
|
42
|
+
const r = e();
|
|
43
|
+
if (!r) {
|
|
44
44
|
console.warn(
|
|
45
45
|
`[tbw-grid:filtering] FilteringPlugin not found.
|
|
46
46
|
|
|
@@ -49,22 +49,10 @@ function x() {
|
|
|
49
49
|
);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
r.setFilterModel(t, i);
|
|
53
53
|
},
|
|
54
54
|
[e]
|
|
55
|
-
),
|
|
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(
|
|
55
|
+
), o = n(
|
|
68
56
|
(t) => {
|
|
69
57
|
const i = e();
|
|
70
58
|
if (!i) {
|
|
@@ -76,16 +64,31 @@ function x() {
|
|
|
76
64
|
);
|
|
77
65
|
return;
|
|
78
66
|
}
|
|
79
|
-
i.
|
|
67
|
+
i.clearAllFilters(t);
|
|
68
|
+
},
|
|
69
|
+
[e]
|
|
70
|
+
), f = n(
|
|
71
|
+
(t, i) => {
|
|
72
|
+
const r = e();
|
|
73
|
+
if (!r) {
|
|
74
|
+
console.warn(
|
|
75
|
+
`[tbw-grid:filtering] FilteringPlugin not found.
|
|
76
|
+
|
|
77
|
+
→ Enable filtering on the grid:
|
|
78
|
+
<DataGrid filtering />`
|
|
79
|
+
);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
r.clearFieldFilter(t, i);
|
|
80
83
|
},
|
|
81
84
|
[e]
|
|
82
|
-
),
|
|
85
|
+
), F = n((t) => e()?.isFieldFiltered(t) ?? !1, [e]), p = n(() => e()?.getFilteredRowCount() ?? 0, [e]), m = n((t) => e()?.getUniqueValues(t) ?? [], [e]), w = n(() => e()?.getStaleFilters() ?? [], [e]), b = n(
|
|
83
86
|
(t) => e()?.getBlankMode(t) ?? "all",
|
|
84
87
|
[e]
|
|
85
|
-
),
|
|
88
|
+
), P = n(
|
|
86
89
|
(t, i) => {
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
90
|
+
const r = e();
|
|
91
|
+
if (!r) {
|
|
89
92
|
console.warn(
|
|
90
93
|
`[tbw-grid:filtering] FilteringPlugin not found.
|
|
91
94
|
|
|
@@ -94,7 +97,7 @@ function x() {
|
|
|
94
97
|
);
|
|
95
98
|
return;
|
|
96
99
|
}
|
|
97
|
-
|
|
100
|
+
r.toggleBlankFilter(t, i);
|
|
98
101
|
},
|
|
99
102
|
[e]
|
|
100
103
|
);
|
|
@@ -103,16 +106,16 @@ function x() {
|
|
|
103
106
|
getFilter: s,
|
|
104
107
|
getFilters: a,
|
|
105
108
|
setFilterModel: d,
|
|
106
|
-
clearAllFilters:
|
|
109
|
+
clearAllFilters: o,
|
|
107
110
|
clearFieldFilter: f,
|
|
108
|
-
isFieldFiltered:
|
|
109
|
-
getFilteredRowCount:
|
|
110
|
-
getUniqueValues:
|
|
111
|
-
getStaleFilters:
|
|
112
|
-
getBlankMode:
|
|
113
|
-
toggleBlankFilter:
|
|
111
|
+
isFieldFiltered: F,
|
|
112
|
+
getFilteredRowCount: p,
|
|
113
|
+
getUniqueValues: m,
|
|
114
|
+
getStaleFilters: w,
|
|
115
|
+
getBlankMode: b,
|
|
116
|
+
toggleBlankFilter: P
|
|
114
117
|
};
|
|
115
118
|
}
|
|
116
119
|
export {
|
|
117
|
-
|
|
120
|
+
S as useGridFiltering
|
|
118
121
|
};
|