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