@ztwoint/z-ui 0.1.69 → 0.1.71
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/dist/components/table-filter/close-filter-confirm/filter-confirmation-dialog.utils.js +13 -13
- package/dist/components/table-filter/filters/checkbox.js +1 -1
- package/dist/components/table-filter/table-filter-button.js +58 -57
- package/dist/components/table-filter/table-filter-column-button.js +68 -67
- package/dist/components/table-filter/table-filter.context.d.ts +2 -2
- package/dist/components/table-filter/table-filter.hook.d.ts +2 -2
- package/dist/components/table-filter/table-filter.hook.js +38 -37
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/types/components/table-filter/table-filter.context.d.ts +2 -2
- package/dist/types/components/table-filter/table-filter.hook.d.ts +2 -2
- package/package.json +1 -1
package/dist/components/table-filter/close-filter-confirm/filter-confirmation-dialog.utils.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const v = (
|
|
2
|
-
if (
|
|
1
|
+
const v = (u, t) => {
|
|
2
|
+
if (u.length !== t.length)
|
|
3
3
|
return !1;
|
|
4
|
-
const
|
|
5
|
-
return
|
|
6
|
-
const a =
|
|
7
|
-
return
|
|
4
|
+
const i = [...u].sort((r, l) => r.field.localeCompare(l.field)), e = [...t].sort((r, l) => r.field.localeCompare(l.field));
|
|
5
|
+
return i.every((r, l) => {
|
|
6
|
+
const a = e[l];
|
|
7
|
+
return r.field !== a.field || r.condition !== a.condition ? !1 : Array.isArray(r.value) && Array.isArray(a.value) ? r.value.length !== a.value.length ? !1 : r.value.every((n, s) => n === a.value[s]) : Array.isArray(r.value) || Array.isArray(a.value) ? !1 : r.value === a.value;
|
|
8
8
|
});
|
|
9
|
-
}, o = (
|
|
10
|
-
const
|
|
11
|
-
return !v(
|
|
12
|
-
},
|
|
13
|
-
const
|
|
14
|
-
return !
|
|
9
|
+
}, o = (u, t) => {
|
|
10
|
+
const i = u.filter((e) => Array.isArray(e.value) ? e.value.length > 0 : e.value !== "");
|
|
11
|
+
return !v(i, t);
|
|
12
|
+
}, y = (u, t, i) => {
|
|
13
|
+
const e = t.find((n) => n.field === u), r = i.find((n) => n.field === u), l = e && (Array.isArray(e.value) ? e.value.length > 0 : e.value !== ""), a = r && (Array.isArray(r.value) ? r.value.length > 0 : r.value !== "");
|
|
14
|
+
return !l && a || l && !a ? !0 : !l && !a ? !1 : l && a && e && r ? e.condition !== r.condition ? !0 : Array.isArray(e.value) && Array.isArray(r.value) ? e.value.length !== r.value.length ? !0 : !e.value.every((n, s) => n === r.value[s]) : Array.isArray(e.value) || Array.isArray(r.value) ? !0 : e.value !== r.value : !1;
|
|
15
15
|
};
|
|
16
16
|
export {
|
|
17
17
|
v as areFiltersEqual,
|
|
18
18
|
o as hasUnsavedFilterChanges,
|
|
19
|
-
|
|
19
|
+
y as hasUnsavedFilterChangesForColumn
|
|
20
20
|
};
|
|
@@ -2,72 +2,72 @@ import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
|
2
2
|
import * as y from "react";
|
|
3
3
|
import * as m from "@radix-ui/react-popover";
|
|
4
4
|
import { Button as u } from "../button/button.js";
|
|
5
|
-
import { useTableFilterContext as
|
|
6
|
-
import
|
|
5
|
+
import { useTableFilterContext as U } from "./table-filter.context.js";
|
|
6
|
+
import H from "./filters/text.js";
|
|
7
7
|
import V from "./filters/boolean.js";
|
|
8
8
|
import q from "./filters/number/number.js";
|
|
9
9
|
import E from "./filters/checkbox.js";
|
|
10
10
|
import G from "../assets/icons/circle-check-filled.js";
|
|
11
|
-
import { SelectedFiltersDisplay as
|
|
12
|
-
import { createFilterDisplayItems as
|
|
13
|
-
import { FilterConfirmationDialog as
|
|
14
|
-
import { hasUnsavedFilterChanges as
|
|
15
|
-
const
|
|
16
|
-
const [
|
|
11
|
+
import { SelectedFiltersDisplay as J } from "./selected-filters-display/selected-filters-display.js";
|
|
12
|
+
import { createFilterDisplayItems as L, calculateTotalCount as M } from "./selected-filters-display/selected-filters-display.utils.js";
|
|
13
|
+
import { FilterConfirmationDialog as Q } from "./close-filter-confirm/filter-confirmation-dialog.js";
|
|
14
|
+
import { hasUnsavedFilterChanges as C } from "./close-filter-confirm/filter-confirmation-dialog.utils.js";
|
|
15
|
+
const ae = () => {
|
|
16
|
+
const [F, a] = y.useState(!1), [x, n] = y.useState(!1), {
|
|
17
17
|
selectedColumn: r,
|
|
18
|
-
setSelectedColumn:
|
|
18
|
+
setSelectedColumn: N,
|
|
19
19
|
getFilterForColumn: w,
|
|
20
|
-
hasFilterForColumn:
|
|
21
|
-
updateColumnFilter:
|
|
22
|
-
clearAllFilters:
|
|
23
|
-
resetToAppliedFilters:
|
|
24
|
-
applyFilters:
|
|
20
|
+
hasFilterForColumn: k,
|
|
21
|
+
updateColumnFilter: K,
|
|
22
|
+
clearAllFilters: j,
|
|
23
|
+
resetToAppliedFilters: A,
|
|
24
|
+
applyFilters: D,
|
|
25
25
|
hasActiveFilters: d,
|
|
26
26
|
tempFilters: i,
|
|
27
27
|
filterSchema: c,
|
|
28
28
|
filter: p,
|
|
29
|
-
filterComponents:
|
|
30
|
-
} =
|
|
31
|
-
!e && x ?
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
},
|
|
29
|
+
filterComponents: f = {}
|
|
30
|
+
} = U(), g = C(i, p.value), O = (e) => {
|
|
31
|
+
!e && x ? g ? a(!0) : n(!1) : n(e);
|
|
32
|
+
}, v = () => {
|
|
33
|
+
D(), n(!1);
|
|
34
|
+
}, P = () => {
|
|
35
35
|
a(!1), n(!1);
|
|
36
|
+
}, S = () => {
|
|
37
|
+
A(), a(!1), n(!1);
|
|
36
38
|
}, T = () => {
|
|
37
|
-
D(), a(!1), n(!1);
|
|
38
|
-
}, $ = () => {
|
|
39
39
|
a(!1);
|
|
40
|
-
},
|
|
40
|
+
}, $ = L(i, c), R = M($), z = () => {
|
|
41
41
|
if (!r) return null;
|
|
42
|
-
const e = c.find((
|
|
42
|
+
const e = c.find((s) => s.filterKey === r), B = {
|
|
43
43
|
boolean: V,
|
|
44
|
-
string:
|
|
44
|
+
string: H,
|
|
45
45
|
number: q,
|
|
46
46
|
checkbox: E
|
|
47
|
-
},
|
|
48
|
-
if (!
|
|
47
|
+
}, b = (e == null ? void 0 : e.type) && (f == null ? void 0 : f[e.type]) || B[(e == null ? void 0 : e.type) ?? "string"];
|
|
48
|
+
if (!b)
|
|
49
49
|
return console.warn(
|
|
50
50
|
`No filter component found for column "${e == null ? void 0 : e.filterKey}" with type "${e == null ? void 0 : e.type}". Provide a custom filter component or use supported types: "string", "number", "boolean", "checkbox".`
|
|
51
51
|
), null;
|
|
52
|
-
const
|
|
53
|
-
condition: (
|
|
54
|
-
value: (
|
|
52
|
+
const o = w(r), I = {
|
|
53
|
+
condition: (o == null ? void 0 : o.condition) || "",
|
|
54
|
+
value: (o == null ? void 0 : o.value) || ""
|
|
55
55
|
};
|
|
56
56
|
return /* @__PURE__ */ t("div", { className: "flex-1 h-full", children: /* @__PURE__ */ t("div", { className: "mb-4 h-full", children: /* @__PURE__ */ t(
|
|
57
|
-
|
|
57
|
+
b,
|
|
58
58
|
{
|
|
59
|
-
value:
|
|
60
|
-
onChange: ({ condition:
|
|
61
|
-
filterOptions: e != null && e.options ? Object.entries(e.options).map(([
|
|
62
|
-
label:
|
|
63
|
-
value:
|
|
64
|
-
total:
|
|
59
|
+
value: I,
|
|
60
|
+
onChange: ({ condition: s, value: h }) => K(r, s, h),
|
|
61
|
+
filterOptions: e != null && e.options ? Object.entries(e.options).map(([s, h]) => ({
|
|
62
|
+
label: s,
|
|
63
|
+
value: s,
|
|
64
|
+
total: h
|
|
65
65
|
})) : void 0
|
|
66
66
|
},
|
|
67
67
|
r
|
|
68
68
|
) }) });
|
|
69
69
|
};
|
|
70
|
-
return /* @__PURE__ */ l(m.Root, { open: x, onOpenChange:
|
|
70
|
+
return /* @__PURE__ */ l(m.Root, { open: x, onOpenChange: O, children: [
|
|
71
71
|
/* @__PURE__ */ t(m.Trigger, { asChild: !0, children: /* @__PURE__ */ l(
|
|
72
72
|
u,
|
|
73
73
|
{
|
|
@@ -83,40 +83,41 @@ const ne = () => {
|
|
|
83
83
|
/* @__PURE__ */ t(m.Portal, { children: /* @__PURE__ */ l(
|
|
84
84
|
m.Content,
|
|
85
85
|
{
|
|
86
|
-
className: "
|
|
86
|
+
className: "w-[512px] bg-surface-neutral-default border border-stroke-solid-light rounded-2xl overflow-hidden shadow-lg",
|
|
87
87
|
sideOffset: 8,
|
|
88
88
|
align: "start",
|
|
89
89
|
children: [
|
|
90
|
-
/* @__PURE__ */ l("div", { className: "flex h-[
|
|
91
|
-
/* @__PURE__ */ l("div", { className: "w-48 border-r border-stroke-solid-light p-2 flex flex-col gap-1.5", children: [
|
|
90
|
+
/* @__PURE__ */ l("div", { className: "flex h-[422px]", style: { maxHeight: "calc(100vh - 8rem)" }, children: [
|
|
91
|
+
/* @__PURE__ */ l("div", { className: "w-48 border-r border-stroke-solid-light p-2 flex flex-col gap-1.5 overflow-y-auto", children: [
|
|
92
92
|
/* @__PURE__ */ t("div", { className: "p-2 pb-1", children: /* @__PURE__ */ t("h3", { className: "leading-none-medium-sm text-text-neutral-secondary", children: "Filters" }) }),
|
|
93
93
|
c.map((e) => /* @__PURE__ */ l(
|
|
94
94
|
"button",
|
|
95
95
|
{
|
|
96
|
-
onClick: () =>
|
|
96
|
+
onClick: () => N(e.filterKey),
|
|
97
97
|
className: `w-full text-left p-2 text-sm flex items-center justify-between hover:bg-surface-neutral-hovered transition-colors rounded-lg ${r === e.filterKey ? "bg-surface-neutral-focused text-text-brand-primary" : "text-text-neutral-primary"}`,
|
|
98
98
|
children: [
|
|
99
99
|
/* @__PURE__ */ t("span", { className: "truncate", children: e.title }),
|
|
100
|
-
|
|
100
|
+
k(e.filterKey) && /* @__PURE__ */ t(G, { className: "w-4 h-4 text-text-brand-secondary flex-shrink-0 ml-2" })
|
|
101
101
|
]
|
|
102
102
|
},
|
|
103
103
|
e.filterKey
|
|
104
104
|
))
|
|
105
105
|
] }),
|
|
106
|
-
/* @__PURE__ */ t("div", { className: "flex-1 flex flex-col", children: r ?
|
|
106
|
+
/* @__PURE__ */ t("div", { className: "flex-1 flex flex-col", children: r ? z() : /* @__PURE__ */ t("div", { className: "flex-1 flex items-center justify-center text-text-neutral-muted", children: "Select a column to configure its filter" }) })
|
|
107
107
|
] }),
|
|
108
|
-
|
|
109
|
-
/* @__PURE__ */ t(
|
|
108
|
+
g && /* @__PURE__ */ l("div", { className: "flex justify-between items-end p-4 border-t border-stroke-solid-medium min-h-[73px]", children: [
|
|
109
|
+
/* @__PURE__ */ t(J, { selectedFilters: i, schema: c }),
|
|
110
110
|
/* @__PURE__ */ l("div", { className: "flex justify-end gap-2", children: [
|
|
111
|
-
/* @__PURE__ */ t(u, { onClick:
|
|
111
|
+
/* @__PURE__ */ t(u, { onClick: j, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
|
|
112
112
|
/* @__PURE__ */ t(
|
|
113
113
|
u,
|
|
114
114
|
{
|
|
115
|
-
onClick:
|
|
115
|
+
onClick: v,
|
|
116
116
|
variant: "filled",
|
|
117
117
|
shade: "neutral",
|
|
118
118
|
size: "small",
|
|
119
|
-
|
|
119
|
+
className: "min-w-20",
|
|
120
|
+
children: `Apply ${R || ""}`
|
|
120
121
|
}
|
|
121
122
|
)
|
|
122
123
|
] })
|
|
@@ -124,18 +125,18 @@ const ne = () => {
|
|
|
124
125
|
]
|
|
125
126
|
}
|
|
126
127
|
) }),
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
F && /* @__PURE__ */ t(
|
|
129
|
+
Q,
|
|
129
130
|
{
|
|
130
|
-
onClose:
|
|
131
|
-
onKeepChanges:
|
|
132
|
-
onRevertChanges:
|
|
133
|
-
onApplyChanges:
|
|
134
|
-
hasUnsavedChanges:
|
|
131
|
+
onClose: T,
|
|
132
|
+
onKeepChanges: P,
|
|
133
|
+
onRevertChanges: S,
|
|
134
|
+
onApplyChanges: v,
|
|
135
|
+
hasUnsavedChanges: C(i, p.value)
|
|
135
136
|
}
|
|
136
137
|
)
|
|
137
138
|
] });
|
|
138
139
|
};
|
|
139
140
|
export {
|
|
140
|
-
|
|
141
|
+
ae as TableFilterButton
|
|
141
142
|
};
|
|
@@ -1,106 +1,107 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
1
|
+
import { jsxs as i, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import * as x from "react";
|
|
3
|
+
import * as a from "@radix-ui/react-popover";
|
|
4
4
|
import { Button as f } from "../button/button.js";
|
|
5
|
-
import { useTableFilterContext as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { getFilterCount as
|
|
12
|
-
import { FilterConfirmationDialog as
|
|
13
|
-
import { hasUnsavedFilterChangesForColumn as
|
|
14
|
-
const
|
|
15
|
-
const [k, r] =
|
|
16
|
-
getFilterForColumn:
|
|
17
|
-
hasAppliedFilterForColumn:
|
|
5
|
+
import { useTableFilterContext as V } from "./table-filter.context.js";
|
|
6
|
+
import q from "./filters/text.js";
|
|
7
|
+
import E from "./filters/boolean.js";
|
|
8
|
+
import G from "./filters/number/number.js";
|
|
9
|
+
import H from "./filters/checkbox.js";
|
|
10
|
+
import J from "../assets/icons/circle-check-filled.js";
|
|
11
|
+
import { getFilterCount as L } from "./selected-filters-display/selected-filters-display.utils.js";
|
|
12
|
+
import { FilterConfirmationDialog as M } from "./close-filter-confirm/filter-confirmation-dialog.js";
|
|
13
|
+
import { hasUnsavedFilterChangesForColumn as w } from "./close-filter-confirm/filter-confirmation-dialog.utils.js";
|
|
14
|
+
const le = ({ filterName: n }) => {
|
|
15
|
+
const [k, r] = x.useState(!1), [u, s] = x.useState(!1), {
|
|
16
|
+
getFilterForColumn: A,
|
|
17
|
+
hasAppliedFilterForColumn: O,
|
|
18
18
|
updateColumnFilter: C,
|
|
19
|
-
applyFilters:
|
|
20
|
-
resetToAppliedFilters:
|
|
21
|
-
filterSchema:
|
|
22
|
-
filterComponents:
|
|
19
|
+
applyFilters: p,
|
|
20
|
+
resetToAppliedFilters: P,
|
|
21
|
+
filterSchema: T,
|
|
22
|
+
filterComponents: d = {},
|
|
23
23
|
tempFilters: g,
|
|
24
24
|
filter: v
|
|
25
|
-
} =
|
|
26
|
-
!o && u ?
|
|
27
|
-
}, $ = () => {
|
|
28
|
-
d(), s(!1);
|
|
25
|
+
} = V(), c = w(n, g, v.value), $ = (o) => {
|
|
26
|
+
!o && u ? c ? r(!0) : s(!1) : s(o);
|
|
29
27
|
}, j = () => {
|
|
30
|
-
|
|
31
|
-
}, z = () => {
|
|
32
|
-
O(), r(!1), s(!1);
|
|
28
|
+
p(), s(!1);
|
|
33
29
|
}, D = () => {
|
|
30
|
+
r(!1), s(!1);
|
|
31
|
+
}, K = () => {
|
|
32
|
+
P(), r(!1), s(!1);
|
|
33
|
+
}, R = () => {
|
|
34
34
|
r(!1);
|
|
35
|
-
},
|
|
36
|
-
if (!
|
|
37
|
-
return console.warn(`Column "${
|
|
38
|
-
const
|
|
39
|
-
boolean:
|
|
40
|
-
string:
|
|
41
|
-
number:
|
|
42
|
-
checkbox:
|
|
43
|
-
}, F =
|
|
35
|
+
}, t = T.find((o) => o.filterKey === n);
|
|
36
|
+
if (!t)
|
|
37
|
+
return console.warn(`Column "${n}" not found in schema`), null;
|
|
38
|
+
const S = {
|
|
39
|
+
boolean: E,
|
|
40
|
+
string: q,
|
|
41
|
+
number: G,
|
|
42
|
+
checkbox: H
|
|
43
|
+
}, F = t.type && (d == null ? void 0 : d[t.type]) || S[t.type ?? "string"];
|
|
44
44
|
if (!F)
|
|
45
45
|
return console.warn(
|
|
46
|
-
`No filter component found for column "${
|
|
46
|
+
`No filter component found for column "${t.filterKey}" with type "${t.type}". Provide a custom filter component or use supported types: "string", "number", "boolean", "checkbox".`
|
|
47
47
|
), null;
|
|
48
|
-
const
|
|
48
|
+
const e = A(n), m = O(n), b = t.options ? Object.entries(t.options).map(([o, h]) => ({
|
|
49
49
|
label: o,
|
|
50
50
|
value: o,
|
|
51
|
-
total:
|
|
52
|
-
})) : void 0,
|
|
53
|
-
condition: (
|
|
54
|
-
value: (
|
|
55
|
-
},
|
|
56
|
-
C(
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
total: h
|
|
52
|
+
})) : void 0, y = e ? L(e, b) : void 0, z = e != null && e.value ? Array.isArray(e.value) ? e.value.length : 1 : 0, B = {
|
|
53
|
+
condition: (e == null ? void 0 : e.condition) || "",
|
|
54
|
+
value: (e == null ? void 0 : e.value) || ""
|
|
55
|
+
}, I = () => {
|
|
56
|
+
const o = C(n, "", "");
|
|
57
|
+
p(o), s(!1);
|
|
58
|
+
}, U = () => {
|
|
59
|
+
p(), s(!1);
|
|
59
60
|
};
|
|
60
|
-
return /* @__PURE__ */ a
|
|
61
|
-
/* @__PURE__ */ l(
|
|
61
|
+
return /* @__PURE__ */ i(a.Root, { open: u, onOpenChange: $, children: [
|
|
62
|
+
/* @__PURE__ */ l(a.Trigger, { asChild: !0, children: /* @__PURE__ */ l(
|
|
62
63
|
f,
|
|
63
64
|
{
|
|
64
65
|
variant: m ? "filled" : "stroke",
|
|
65
66
|
shade: m ? "brand" : "neutral",
|
|
66
67
|
size: "small",
|
|
67
|
-
children: /* @__PURE__ */
|
|
68
|
-
|
|
69
|
-
m && /* @__PURE__ */ l(
|
|
68
|
+
children: /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
|
|
69
|
+
t.title,
|
|
70
|
+
m && /* @__PURE__ */ l(J, { className: "w-4 h-4 text-white flex-shrink-0" })
|
|
70
71
|
] })
|
|
71
72
|
}
|
|
72
73
|
) }),
|
|
73
|
-
/* @__PURE__ */ l(
|
|
74
|
-
|
|
74
|
+
/* @__PURE__ */ l(a.Portal, { children: /* @__PURE__ */ i(
|
|
75
|
+
a.Content,
|
|
75
76
|
{
|
|
76
|
-
className: "
|
|
77
|
+
className: "w-80 bg-surface-neutral-default border border-stroke-solid-light rounded-2xl overflow-hidden shadow-lg",
|
|
77
78
|
sideOffset: 8,
|
|
78
79
|
align: "start",
|
|
79
80
|
children: [
|
|
80
81
|
/* @__PURE__ */ l(
|
|
81
82
|
F,
|
|
82
83
|
{
|
|
83
|
-
value:
|
|
84
|
-
onChange: ({ condition: o, value:
|
|
84
|
+
value: B,
|
|
85
|
+
onChange: ({ condition: o, value: h }) => C(n, o, h),
|
|
85
86
|
filterOptions: b
|
|
86
87
|
}
|
|
87
88
|
),
|
|
88
|
-
!!
|
|
89
|
-
/* @__PURE__ */ l(f, { onClick:
|
|
90
|
-
/* @__PURE__ */ l(f, { onClick:
|
|
89
|
+
(c || !!z) && /* @__PURE__ */ i("div", { className: "flex justify-between gap-2 p-3 border-t border-stroke-solid-medium", children: [
|
|
90
|
+
/* @__PURE__ */ l(f, { onClick: I, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
|
|
91
|
+
c && /* @__PURE__ */ l(f, { onClick: U, variant: "filled", shade: "neutral", size: "small", children: `Apply${y !== void 0 ? ` ${y}` : ""}` })
|
|
91
92
|
] })
|
|
92
93
|
]
|
|
93
94
|
}
|
|
94
95
|
) }),
|
|
95
96
|
k && /* @__PURE__ */ l(
|
|
96
|
-
|
|
97
|
+
M,
|
|
97
98
|
{
|
|
98
|
-
onClose:
|
|
99
|
-
onKeepChanges:
|
|
100
|
-
onRevertChanges:
|
|
101
|
-
onApplyChanges:
|
|
102
|
-
hasUnsavedChanges:
|
|
103
|
-
|
|
99
|
+
onClose: R,
|
|
100
|
+
onKeepChanges: D,
|
|
101
|
+
onRevertChanges: K,
|
|
102
|
+
onApplyChanges: j,
|
|
103
|
+
hasUnsavedChanges: w(
|
|
104
|
+
n,
|
|
104
105
|
g,
|
|
105
106
|
v.value
|
|
106
107
|
)
|
|
@@ -109,5 +110,5 @@ const te = ({ filterName: t }) => {
|
|
|
109
110
|
] });
|
|
110
111
|
};
|
|
111
112
|
export {
|
|
112
|
-
|
|
113
|
+
le as TableFilterColumnButton
|
|
113
114
|
};
|
|
@@ -6,10 +6,10 @@ export interface TableFilterContextValue {
|
|
|
6
6
|
getFilterForColumn: (columnKey: string) => FilterRule | undefined;
|
|
7
7
|
hasFilterForColumn: (columnKey: string) => boolean;
|
|
8
8
|
hasAppliedFilterForColumn: (columnKey: string) => boolean;
|
|
9
|
-
updateColumnFilter: (columnKey: string, condition?: string, value?: string | string[]) =>
|
|
9
|
+
updateColumnFilter: (columnKey: string, condition?: string, value?: string | string[]) => FilterRule[];
|
|
10
10
|
clearAllFilters: () => void;
|
|
11
11
|
resetToAppliedFilters: () => void;
|
|
12
|
-
applyFilters: () => void;
|
|
12
|
+
applyFilters: (newFilters?: FilterRule[]) => void;
|
|
13
13
|
hasActiveFilters: boolean;
|
|
14
14
|
tempFilters: FilterRule[];
|
|
15
15
|
filterSchema: FilterSchema;
|
|
@@ -6,10 +6,10 @@ declare const useTableFilter: ({ filter, filterSchema }: TableFilterProps) => {
|
|
|
6
6
|
getFilterForColumn: (columnKey: string) => FilterRule | undefined;
|
|
7
7
|
hasFilterForColumn: (columnKey: string) => boolean;
|
|
8
8
|
hasAppliedFilterForColumn: (columnKey: string) => boolean;
|
|
9
|
-
updateColumnFilter: (columnKey: string, condition?: string, value?: string | string[]) =>
|
|
9
|
+
updateColumnFilter: (columnKey: string, condition?: string, value?: string | string[]) => FilterRule[];
|
|
10
10
|
clearAllFilters: () => void;
|
|
11
11
|
resetToAppliedFilters: () => void;
|
|
12
|
-
applyFilters: () => void;
|
|
12
|
+
applyFilters: (newFilters?: FilterRule[]) => void;
|
|
13
13
|
hasActiveFilters: boolean;
|
|
14
14
|
tempFilters: FilterRule[];
|
|
15
15
|
};
|
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
import
|
|
2
|
-
const E = ({ filter: l, filterSchema:
|
|
3
|
-
const [
|
|
4
|
-
|
|
5
|
-
!
|
|
6
|
-
}, [
|
|
7
|
-
const
|
|
8
|
-
const e =
|
|
1
|
+
import i from "react";
|
|
2
|
+
const E = ({ filter: l, filterSchema: o }) => {
|
|
3
|
+
const [d, c] = i.useState(null), [n, s] = i.useState(l.value);
|
|
4
|
+
i.useEffect(() => {
|
|
5
|
+
!d && o.length > 0 && c(o[0].filterKey);
|
|
6
|
+
}, [d, o]);
|
|
7
|
+
const f = (t) => n.find((e) => e.field === t), p = (t) => {
|
|
8
|
+
const e = f(t);
|
|
9
9
|
return e ? Array.isArray(e.value) ? e.value.length > 0 : e.value !== "" : !1;
|
|
10
|
-
},
|
|
11
|
-
const e =
|
|
10
|
+
}, A = (t) => l.value.find((e) => e.field === t), m = (t) => {
|
|
11
|
+
const e = A(t);
|
|
12
12
|
return e ? Array.isArray(e.value) ? e.value.length > 0 : e.value !== "" : !1;
|
|
13
|
-
}, g = (t, e,
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
}, g = (t, e, r) => {
|
|
14
|
+
const F = n.findIndex((a) => a.field === t);
|
|
15
|
+
let u = [];
|
|
16
|
+
if (F >= 0)
|
|
17
|
+
u = n.map(
|
|
18
|
+
(v, T) => T === F ? {
|
|
18
19
|
...v,
|
|
19
20
|
...e !== void 0 ? { condition: e } : {},
|
|
20
|
-
...
|
|
21
|
+
...r !== void 0 ? { value: r } : {}
|
|
21
22
|
} : v
|
|
22
23
|
);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const n = {
|
|
24
|
+
else {
|
|
25
|
+
const a = {
|
|
26
26
|
field: t,
|
|
27
27
|
...e ? { condition: e } : {},
|
|
28
|
-
value:
|
|
28
|
+
value: r || ""
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
u = [...n, a];
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
s([]);
|
|
32
|
+
return s(u), u;
|
|
34
33
|
}, C = () => {
|
|
35
|
-
s(
|
|
34
|
+
s([]);
|
|
36
35
|
}, h = () => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
s(l.value);
|
|
37
|
+
}, y = (t) => {
|
|
38
|
+
const e = (t || n).filter((r) => Array.isArray(r.value) ? r.value.length > 0 : r.value !== "");
|
|
39
|
+
l.onChange(e);
|
|
40
|
+
}, x = l.value.length > 0;
|
|
41
|
+
return i.useEffect(() => {
|
|
41
42
|
s(l.value);
|
|
42
43
|
}, [l.value]), {
|
|
43
|
-
selectedColumn:
|
|
44
|
+
selectedColumn: d,
|
|
44
45
|
setSelectedColumn: c,
|
|
45
|
-
getFilterForColumn:
|
|
46
|
-
hasFilterForColumn:
|
|
47
|
-
hasAppliedFilterForColumn:
|
|
46
|
+
getFilterForColumn: f,
|
|
47
|
+
hasFilterForColumn: p,
|
|
48
|
+
hasAppliedFilterForColumn: m,
|
|
48
49
|
updateColumnFilter: g,
|
|
49
|
-
clearAllFilters:
|
|
50
|
-
resetToAppliedFilters:
|
|
51
|
-
applyFilters:
|
|
52
|
-
hasActiveFilters:
|
|
53
|
-
tempFilters:
|
|
50
|
+
clearAllFilters: C,
|
|
51
|
+
resetToAppliedFilters: h,
|
|
52
|
+
applyFilters: y,
|
|
53
|
+
hasActiveFilters: x,
|
|
54
|
+
tempFilters: n
|
|
54
55
|
};
|
|
55
56
|
};
|
|
56
57
|
export {
|