@ztwoint/z-ui 0.1.84 → 0.1.86
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/assets/icons/index.d.ts +1 -0
- package/dist/components/assets/icons/vector_3.d.ts +6 -0
- package/dist/components/assets/icons/vector_3.js +34 -0
- package/dist/components/radio/z2-radio.js +72 -0
- package/dist/components/table/components/cell/avatar-cell.js +3 -2
- package/dist/components/table/table-provider.js +1 -0
- package/dist/components/table-card/table-card.js +38 -36
- package/dist/components/table-card/table-card.type.d.ts +2 -1
- package/dist/components/table-filter/filters/boolean.js +28 -32
- package/dist/components/table-filter/filters/checkbox.js +24 -26
- package/dist/components/table-filter/filters/number/number.hook.d.ts +2 -12
- package/dist/components/table-filter/filters/number/number.hook.js +18 -18
- package/dist/components/table-filter/filters/text.js +25 -28
- package/dist/components/table-filter/table-filter-column-button.js +36 -39
- package/dist/components/table-filter/table-filter-provider.js +10 -10
- package/dist/components/table-filter/table-filter.hook.js +46 -42
- package/dist/components/table-filter/table-filter.type.d.ts +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +105 -99
- package/dist/types/components/assets/icons/index.d.ts +1 -0
- package/dist/types/components/assets/icons/vector_3.d.ts +6 -0
- package/dist/types/components/table-card/table-card.type.d.ts +2 -1
- package/dist/types/components/table-filter/filters/number/number.hook.d.ts +2 -12
- package/dist/types/components/table-filter/table-filter.type.d.ts +3 -2
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const o = [
|
|
1
|
+
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import i from "../../assets/icons/x.js";
|
|
3
|
+
import { MagnifierIcon as o } from "../../assets/icons/magnifier-icon.js";
|
|
4
|
+
import { Input as c } from "../../input/input.js";
|
|
5
|
+
const d = [
|
|
7
6
|
{ label: "Contains", value: "contains" },
|
|
8
7
|
{ label: "Does not equal", value: "notEqual" },
|
|
9
8
|
{ label: "Equals", value: "equals" }
|
|
10
|
-
],
|
|
11
|
-
var
|
|
12
|
-
const
|
|
13
|
-
|
|
9
|
+
], x = ({ value: e, onChange: n }) => {
|
|
10
|
+
var a;
|
|
11
|
+
const s = () => {
|
|
12
|
+
n({ value: "" });
|
|
14
13
|
};
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/* @__PURE__ */ e("div", { className: "p-4 relative", children: /* @__PURE__ */ e(
|
|
19
|
-
d,
|
|
14
|
+
return /* @__PURE__ */ r("div", { className: "flex flex-col gap-3", children: [
|
|
15
|
+
/* @__PURE__ */ t("div", { className: "p-4 relative", children: /* @__PURE__ */ t(
|
|
16
|
+
c,
|
|
20
17
|
{
|
|
21
|
-
leftIcon: /* @__PURE__ */
|
|
18
|
+
leftIcon: /* @__PURE__ */ t(o, {}),
|
|
22
19
|
size: "large",
|
|
23
20
|
placeholder: "Search options",
|
|
24
|
-
value:
|
|
25
|
-
rightIcon:
|
|
26
|
-
onChange: (
|
|
21
|
+
value: e == null ? void 0 : e.value,
|
|
22
|
+
rightIcon: e != null && e.value ? /* @__PURE__ */ t(i, { onClick: s }) : null,
|
|
23
|
+
onChange: (l) => n({ value: l.target.value }),
|
|
27
24
|
className: ""
|
|
28
25
|
}
|
|
29
26
|
) }),
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
-
/* @__PURE__ */
|
|
33
|
-
/* @__PURE__ */
|
|
27
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col gap-2 p-3", children: !!(e != null && e.value) && /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2 px-3 py-2", children: [
|
|
28
|
+
/* @__PURE__ */ t("span", { className: "text-text-neutral-muted text-xs font-medium uppercase tracking-wide", children: (a = d.find((l) => l.value === (e == null ? void 0 : e.condition))) == null ? void 0 : a.label }),
|
|
29
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
|
|
30
|
+
/* @__PURE__ */ r("span", { className: "text-text-neutral-primary text-sm font-medium px-2 py-1 bg-surface-neutral-default rounded border border-stroke-solid-medium", children: [
|
|
34
31
|
"“",
|
|
35
|
-
|
|
32
|
+
e.value,
|
|
36
33
|
"”"
|
|
37
34
|
] }),
|
|
38
|
-
/* @__PURE__ */
|
|
35
|
+
/* @__PURE__ */ t(
|
|
39
36
|
"button",
|
|
40
37
|
{
|
|
41
|
-
onClick:
|
|
38
|
+
onClick: s,
|
|
42
39
|
className: "flex items-center justify-center w-5 h-5 rounded-full bg-surface-neutral-hovered hover:bg-surface-neutral-pressed transition-colors",
|
|
43
40
|
title: "Remove filter",
|
|
44
|
-
children: /* @__PURE__ */
|
|
41
|
+
children: /* @__PURE__ */ t(i, { className: "w-3 h-3 text-text-neutral-muted" })
|
|
45
42
|
}
|
|
46
43
|
)
|
|
47
44
|
] })
|
|
@@ -49,5 +46,5 @@ const o = [
|
|
|
49
46
|
] });
|
|
50
47
|
};
|
|
51
48
|
export {
|
|
52
|
-
|
|
49
|
+
x as default
|
|
53
50
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as a, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import * as x from "react";
|
|
3
3
|
import * as p from "@radix-ui/react-popover";
|
|
4
|
-
import { Button as
|
|
5
|
-
import { useTableFilterContext as
|
|
4
|
+
import { Button as d } from "../button/button.js";
|
|
5
|
+
import { useTableFilterContext as U } from "./table-filter.context.js";
|
|
6
6
|
import q from "./filters/text.js";
|
|
7
7
|
import E from "./filters/boolean.js";
|
|
8
8
|
import G from "./filters/number/number.js";
|
|
@@ -11,63 +11,60 @@ import J from "../assets/icons/circle-check-filled.js";
|
|
|
11
11
|
import { getFilterCount as L } from "./selected-filters-display/selected-filters-display.utils.js";
|
|
12
12
|
import { FilterConfirmationDialog as M } from "./close-filter-confirm/filter-confirmation-dialog.js";
|
|
13
13
|
import { hasUnsavedFilterChangesForColumn as w } from "./close-filter-confirm/filter-confirmation-dialog.utils.js";
|
|
14
|
-
const
|
|
15
|
-
const [k,
|
|
14
|
+
const ne = ({ filterName: t }) => {
|
|
15
|
+
const [k, s] = x.useState(!1), [f, r] = x.useState(!1), {
|
|
16
16
|
getFilterForColumn: A,
|
|
17
17
|
hasAppliedFilterForColumn: O,
|
|
18
18
|
updateColumnFilter: u,
|
|
19
19
|
applyFilters: c,
|
|
20
20
|
resetToAppliedFilters: P,
|
|
21
21
|
filterSchema: T,
|
|
22
|
-
filterComponents:
|
|
22
|
+
filterComponents: m = {},
|
|
23
23
|
tempFilters: C,
|
|
24
24
|
filter: g
|
|
25
|
-
} =
|
|
26
|
-
!
|
|
25
|
+
} = U(), $ = (e) => {
|
|
26
|
+
!e && f ? w(t, C, g.value) ? s(!0) : r(!1) : r(e);
|
|
27
27
|
}, j = () => {
|
|
28
|
-
c(),
|
|
28
|
+
c(), s(!1), r(!1);
|
|
29
29
|
}, D = () => {
|
|
30
|
-
|
|
30
|
+
s(!1), r(!1);
|
|
31
31
|
}, K = () => {
|
|
32
|
-
P(),
|
|
32
|
+
P(), s(!1), r(!1);
|
|
33
33
|
}, R = () => {
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
if (!
|
|
37
|
-
return console.warn(`Column "${
|
|
34
|
+
s(!1);
|
|
35
|
+
}, F = w(t, C, g.value), o = T.find((e) => e.filterKey === t);
|
|
36
|
+
if (!o)
|
|
37
|
+
return console.warn(`Column "${t}" not found in schema`), null;
|
|
38
38
|
const S = {
|
|
39
39
|
boolean: E,
|
|
40
40
|
string: q,
|
|
41
41
|
number: G,
|
|
42
42
|
checkbox: H
|
|
43
|
-
},
|
|
44
|
-
if (!
|
|
43
|
+
}, v = o.type && (m == null ? void 0 : m[o.type]) || S[o.type ?? "string"];
|
|
44
|
+
if (!v)
|
|
45
45
|
return console.warn(
|
|
46
|
-
`No filter component found for column "${
|
|
46
|
+
`No filter component found for column "${o.filterKey}" with type "${o.type}". Provide a custom filter component or use supported types: "string", "number", "boolean", "checkbox".`
|
|
47
47
|
), null;
|
|
48
|
-
const
|
|
49
|
-
label:
|
|
50
|
-
value:
|
|
48
|
+
const n = A(t), h = O(t), b = o.options ? Object.entries(o.options).map(([e, i]) => ({
|
|
49
|
+
label: e,
|
|
50
|
+
value: e,
|
|
51
51
|
total: i
|
|
52
|
-
})) : void 0, y =
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
})) : void 0, y = n ? L(n, b) : void 0, z = n != null && n.value ? Array.isArray(n.value) ? n.value.length : 1 : 0, B = () => {
|
|
53
|
+
const e = u(t, "", "");
|
|
54
|
+
c(e), r(!1);
|
|
55
55
|
}, I = () => {
|
|
56
|
-
|
|
57
|
-
c(o), s(!1);
|
|
58
|
-
}, U = () => {
|
|
59
|
-
c(), s(!1);
|
|
56
|
+
c(), r(!1);
|
|
60
57
|
};
|
|
61
58
|
return /* @__PURE__ */ a(p.Root, { open: f, onOpenChange: $, children: [
|
|
62
59
|
/* @__PURE__ */ l(p.Trigger, { asChild: !0, children: /* @__PURE__ */ l(
|
|
63
|
-
|
|
60
|
+
d,
|
|
64
61
|
{
|
|
65
|
-
variant:
|
|
66
|
-
shade:
|
|
62
|
+
variant: h ? "filled" : "stroke",
|
|
63
|
+
shade: h ? "brand" : "neutral",
|
|
67
64
|
size: "small",
|
|
68
65
|
children: /* @__PURE__ */ a("span", { className: "flex items-center gap-2", children: [
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
o.title,
|
|
67
|
+
h && /* @__PURE__ */ l(J, { className: "w-4 h-4 text-white flex-shrink-0" })
|
|
71
68
|
] })
|
|
72
69
|
}
|
|
73
70
|
) }),
|
|
@@ -79,16 +76,16 @@ const le = ({ filterName: n }) => {
|
|
|
79
76
|
align: "start",
|
|
80
77
|
children: [
|
|
81
78
|
/* @__PURE__ */ l(
|
|
82
|
-
|
|
79
|
+
v,
|
|
83
80
|
{
|
|
84
|
-
value:
|
|
85
|
-
onChange: ({ condition:
|
|
81
|
+
value: n,
|
|
82
|
+
onChange: ({ condition: e, value: i }) => u(t, e, i),
|
|
86
83
|
filterOptions: b
|
|
87
84
|
}
|
|
88
85
|
),
|
|
89
|
-
(
|
|
90
|
-
/* @__PURE__ */ l(
|
|
91
|
-
|
|
86
|
+
(F || !!z) && /* @__PURE__ */ a("div", { className: "flex justify-between gap-2 p-3 border-t border-stroke-solid-medium", children: [
|
|
87
|
+
/* @__PURE__ */ l(d, { onClick: B, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
|
|
88
|
+
F && /* @__PURE__ */ l(d, { onClick: I, variant: "filled", shade: "neutral", size: "small", children: `Apply${y !== void 0 ? ` ${y}` : ""}` })
|
|
92
89
|
] })
|
|
93
90
|
]
|
|
94
91
|
}
|
|
@@ -105,5 +102,5 @@ const le = ({ filterName: n }) => {
|
|
|
105
102
|
] });
|
|
106
103
|
};
|
|
107
104
|
export {
|
|
108
|
-
|
|
105
|
+
ne as TableFilterColumnButton
|
|
109
106
|
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { TableFilterContext as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import a from "./table-filter.hook.js";
|
|
3
|
+
import { TableFilterContext as u } from "./table-filter.context.js";
|
|
4
|
+
const c = ({
|
|
5
5
|
children: r,
|
|
6
6
|
filterComponents: t = {},
|
|
7
7
|
filterSchema: e,
|
|
8
8
|
filter: o
|
|
9
9
|
}) => {
|
|
10
|
-
const
|
|
10
|
+
const n = a({
|
|
11
11
|
filterSchema: e,
|
|
12
12
|
filter: o || { value: [], onChange: () => {
|
|
13
|
-
} }
|
|
13
|
+
}, onDynamicChange: void 0 }
|
|
14
14
|
});
|
|
15
15
|
if (!o)
|
|
16
16
|
return null;
|
|
17
|
-
const
|
|
18
|
-
...
|
|
17
|
+
const l = {
|
|
18
|
+
...n,
|
|
19
19
|
filterSchema: e,
|
|
20
20
|
filter: o,
|
|
21
21
|
filterComponents: t
|
|
22
22
|
};
|
|
23
|
-
return /* @__PURE__ */ u
|
|
23
|
+
return /* @__PURE__ */ i(u.Provider, { value: l, children: r });
|
|
24
24
|
};
|
|
25
25
|
export {
|
|
26
|
-
|
|
26
|
+
c as TableFilterProvider
|
|
27
27
|
};
|
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
const [
|
|
4
|
-
|
|
5
|
-
!
|
|
6
|
-
}, [
|
|
7
|
-
const
|
|
8
|
-
const e =
|
|
1
|
+
import o from "react";
|
|
2
|
+
const w = ({ filter: n, filterSchema: c }) => {
|
|
3
|
+
const [v, d] = o.useState(null), [l, i] = o.useState(n.value);
|
|
4
|
+
o.useEffect(() => {
|
|
5
|
+
!v && c.length > 0 && d(c[0].filterKey);
|
|
6
|
+
}, [v, c]);
|
|
7
|
+
const F = (t) => l.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
|
+
}, g = (t) => n.value.find((e) => e.field === t), m = (t) => {
|
|
11
|
+
const e = g(t);
|
|
12
12
|
return e ? Array.isArray(e.value) ? e.value.length > 0 : e.value !== "" : !1;
|
|
13
|
-
},
|
|
14
|
-
const
|
|
13
|
+
}, y = (t, e, a) => {
|
|
14
|
+
const f = l.findIndex((r) => r.field === t);
|
|
15
15
|
let u = [];
|
|
16
|
-
if (
|
|
17
|
-
u =
|
|
18
|
-
(
|
|
19
|
-
...
|
|
16
|
+
if (f >= 0)
|
|
17
|
+
u = l.map(
|
|
18
|
+
(s, x) => x === f ? {
|
|
19
|
+
...s,
|
|
20
20
|
...e !== void 0 ? { condition: e } : {},
|
|
21
|
-
...
|
|
22
|
-
} :
|
|
21
|
+
...a !== void 0 ? { value: a } : {}
|
|
22
|
+
} : s
|
|
23
23
|
);
|
|
24
24
|
else {
|
|
25
|
-
const
|
|
25
|
+
const r = {
|
|
26
26
|
field: t,
|
|
27
27
|
...e ? { condition: e } : {},
|
|
28
|
-
value:
|
|
28
|
+
value: a || ""
|
|
29
29
|
};
|
|
30
|
-
u = [...
|
|
30
|
+
u = [...l, r];
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
if (i(u), n.onDynamicChange) {
|
|
33
|
+
const r = u.filter((s) => Array.isArray(s.value) ? s.value.length > 0 : s.value !== "");
|
|
34
|
+
n.onDynamicChange(r);
|
|
35
|
+
}
|
|
36
|
+
return u;
|
|
35
37
|
}, h = () => {
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
i([]), n.onDynamicChange && n.onDynamicChange([]);
|
|
39
|
+
}, C = () => {
|
|
40
|
+
i(n.value), n.onDynamicChange && n.onDynamicChange(n.value);
|
|
41
|
+
}, A = (t) => {
|
|
42
|
+
const e = (t || l).filter((a) => Array.isArray(a.value) ? a.value.length > 0 : a.value !== "");
|
|
43
|
+
n.onChange(e);
|
|
44
|
+
}, D = n.value.length > 0;
|
|
45
|
+
return o.useEffect(() => {
|
|
46
|
+
i(n.value);
|
|
47
|
+
}, [n.value]), {
|
|
48
|
+
selectedColumn: v,
|
|
49
|
+
setSelectedColumn: d,
|
|
50
|
+
getFilterForColumn: F,
|
|
47
51
|
hasFilterForColumn: p,
|
|
48
52
|
hasAppliedFilterForColumn: m,
|
|
49
|
-
updateColumnFilter:
|
|
50
|
-
clearAllFilters:
|
|
51
|
-
resetToAppliedFilters:
|
|
52
|
-
applyFilters:
|
|
53
|
-
hasActiveFilters:
|
|
54
|
-
tempFilters:
|
|
53
|
+
updateColumnFilter: y,
|
|
54
|
+
clearAllFilters: h,
|
|
55
|
+
resetToAppliedFilters: C,
|
|
56
|
+
applyFilters: A,
|
|
57
|
+
hasActiveFilters: D,
|
|
58
|
+
tempFilters: l
|
|
55
59
|
};
|
|
56
60
|
};
|
|
57
61
|
export {
|
|
58
|
-
|
|
62
|
+
w as default
|
|
59
63
|
};
|
|
@@ -21,6 +21,7 @@ export type FilterSchema = FilterSchemaField[];
|
|
|
21
21
|
export type TableFilter = {
|
|
22
22
|
value: FilterRule[];
|
|
23
23
|
onChange: (filters: FilterRule[]) => void;
|
|
24
|
+
onDynamicChange?: (filters: FilterRule[]) => void;
|
|
24
25
|
};
|
|
25
26
|
export interface TableFilterProps {
|
|
26
27
|
filterSchema: FilterSchema;
|
|
@@ -32,9 +33,9 @@ export type FilterComponentProps = {
|
|
|
32
33
|
condition?: string;
|
|
33
34
|
value?: string | string[];
|
|
34
35
|
}) => void;
|
|
35
|
-
value
|
|
36
|
+
value?: {
|
|
36
37
|
condition?: string;
|
|
37
|
-
value
|
|
38
|
+
value?: string | string[];
|
|
38
39
|
};
|
|
39
40
|
filterOptions?: FilterOption[];
|
|
40
41
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export * from './components/text-preset/text-preset';
|
|
|
22
22
|
export * from './components/column-reorder';
|
|
23
23
|
export * from './components/tree-checkbox-select';
|
|
24
24
|
export * from './components/breadcrumb/z2-breadcrumb';
|
|
25
|
+
export * from './components/radio/z2-radio';
|
|
25
26
|
export * from './components/assets/icons';
|
|
26
27
|
export * from './lib/theme.hook';
|
|
27
28
|
export * from './lib/utils';
|