@toolbox-web/grid-react 0.17.4 → 0.17.5
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 +13 -1
- package/features/filtering.d.ts.map +1 -1
- package/features/filtering.js +44 -23
- package/package.json +1 -1
package/features/filtering.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterModel } from '@toolbox-web/grid/plugins/filtering';
|
|
1
|
+
import { BlankMode, FilterModel } from '@toolbox-web/grid/plugins/filtering';
|
|
2
2
|
/**
|
|
3
3
|
* Filtering methods returned from useGridFiltering.
|
|
4
4
|
*/
|
|
@@ -41,6 +41,18 @@ export interface FilteringMethods {
|
|
|
41
41
|
* Get unique values for a field (for building filter dropdowns).
|
|
42
42
|
*/
|
|
43
43
|
getUniqueValues: (field: string) => unknown[];
|
|
44
|
+
/**
|
|
45
|
+
* Get set filters whose values no longer match any rows in the current data.
|
|
46
|
+
*/
|
|
47
|
+
getStaleFilters: () => FilterModel[];
|
|
48
|
+
/**
|
|
49
|
+
* Get the current blank mode for a field.
|
|
50
|
+
*/
|
|
51
|
+
getBlankMode: (field: string) => BlankMode;
|
|
52
|
+
/**
|
|
53
|
+
* Toggle blank filter mode for a field.
|
|
54
|
+
*/
|
|
55
|
+
toggleBlankFilter: (field: string, mode: BlankMode) => void;
|
|
44
56
|
}
|
|
45
57
|
/**
|
|
46
58
|
* Hook for programmatic filter control.
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/features/filtering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AA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
|
-
import { useContext as
|
|
3
|
-
import { flushSync as
|
|
4
|
-
import { createRoot as
|
|
5
|
-
import { G as b } from "../chunks/grid-element-context-BU3WvNtM.js";
|
|
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";
|
|
6
5
|
import { registerFeature as R } from "@toolbox-web/grid/features/registry";
|
|
6
|
+
import { G as E } from "../chunks/grid-element-context-BU3WvNtM.js";
|
|
7
7
|
R("filtering", (r) => {
|
|
8
8
|
if (typeof r == "boolean") return new c();
|
|
9
9
|
if (!r) return new c();
|
|
10
|
-
const e = r,
|
|
10
|
+
const e = r, g = { ...e };
|
|
11
11
|
if (typeof e.filterPanelRenderer == "function" && e.filterPanelRenderer.length <= 1) {
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const s = e.filterPanelRenderer;
|
|
13
|
+
g.filterPanelRenderer = (a, d) => {
|
|
14
14
|
const l = document.createElement("div");
|
|
15
15
|
l.style.display = "contents";
|
|
16
|
-
const f =
|
|
17
|
-
|
|
18
|
-
f.render(
|
|
19
|
-
}),
|
|
16
|
+
const f = G(l);
|
|
17
|
+
h(() => {
|
|
18
|
+
f.render(s(d));
|
|
19
|
+
}), a.appendChild(l);
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
return new c(
|
|
22
|
+
return new c(g);
|
|
23
23
|
});
|
|
24
24
|
function x() {
|
|
25
|
-
const r =
|
|
25
|
+
const r = P(E), e = n(() => r?.current?.getPluginByName("filtering"), [r]), g = n(
|
|
26
26
|
(t, i) => {
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
27
|
+
const o = e();
|
|
28
|
+
if (!o) {
|
|
29
29
|
console.warn(
|
|
30
30
|
`[tbw-grid:filtering] FilteringPlugin not found.
|
|
31
31
|
|
|
@@ -34,10 +34,10 @@ function x() {
|
|
|
34
34
|
);
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
o.setFilter(t, i);
|
|
38
38
|
},
|
|
39
39
|
[e]
|
|
40
|
-
),
|
|
40
|
+
), s = n((t) => e()?.getFilter(t), [e]), a = n(() => e()?.getFilters() ?? [], [e]), d = n(
|
|
41
41
|
(t) => {
|
|
42
42
|
const i = e();
|
|
43
43
|
if (!i) {
|
|
@@ -79,17 +79,38 @@ function x() {
|
|
|
79
79
|
i.clearFieldFilter(t);
|
|
80
80
|
},
|
|
81
81
|
[e]
|
|
82
|
-
),
|
|
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(
|
|
83
|
+
(t) => e()?.getBlankMode(t) ?? "all",
|
|
84
|
+
[e]
|
|
85
|
+
), b = n(
|
|
86
|
+
(t, i) => {
|
|
87
|
+
const o = e();
|
|
88
|
+
if (!o) {
|
|
89
|
+
console.warn(
|
|
90
|
+
`[tbw-grid:filtering] FilteringPlugin not found.
|
|
91
|
+
|
|
92
|
+
→ Enable filtering on the grid:
|
|
93
|
+
<DataGrid filtering />`
|
|
94
|
+
);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
o.toggleBlankFilter(t, i);
|
|
98
|
+
},
|
|
99
|
+
[e]
|
|
100
|
+
);
|
|
83
101
|
return {
|
|
84
|
-
setFilter:
|
|
85
|
-
getFilter:
|
|
86
|
-
getFilters:
|
|
102
|
+
setFilter: g,
|
|
103
|
+
getFilter: s,
|
|
104
|
+
getFilters: a,
|
|
87
105
|
setFilterModel: d,
|
|
88
106
|
clearAllFilters: l,
|
|
89
107
|
clearFieldFilter: f,
|
|
90
|
-
isFieldFiltered:
|
|
108
|
+
isFieldFiltered: u,
|
|
91
109
|
getFilteredRowCount: F,
|
|
92
|
-
getUniqueValues: p
|
|
110
|
+
getUniqueValues: p,
|
|
111
|
+
getStaleFilters: m,
|
|
112
|
+
getBlankMode: w,
|
|
113
|
+
toggleBlankFilter: b
|
|
93
114
|
};
|
|
94
115
|
}
|
|
95
116
|
export {
|