@ztwoint/z-ui 0.1.45 → 0.1.47
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/check.d.ts +8 -0
- package/dist/components/assets/icons/check.js +17 -0
- package/dist/components/assets/icons/x-mark.d.ts +8 -0
- package/dist/components/assets/icons/x-mark.js +17 -0
- package/dist/components/table/components/cell/avatar-cell.d.ts +15 -0
- package/dist/components/table/components/cell/avatar-cell.js +74 -0
- package/dist/components/table/components/cell/boolean-cell.d.ts +1 -2
- package/dist/components/table/components/cell/boolean-cell.js +5 -5
- package/dist/components/table/components/cell/description-cell.d.ts +7 -0
- package/dist/components/table/components/cell/description-cell.js +16 -0
- package/dist/components/table/components/cell/index.d.ts +10 -1
- package/dist/components/table/components/cell/label-cell.d.ts +10 -0
- package/dist/components/table/components/cell/label-cell.js +47 -0
- package/dist/components/table/components/cell/link-cell.d.ts +10 -0
- package/dist/components/table/components/cell/link-cell.js +35 -0
- package/dist/components/table/components/cell/number-cell.d.ts +5 -3
- package/dist/components/table/components/cell/number-cell.js +40 -3
- package/dist/components/table/components/index.d.ts +1 -1
- package/dist/components/table/components/pagination/index.d.ts +1 -0
- package/dist/components/table/components/pagination/pagination.hook.d.ts +1 -1
- package/dist/components/table/components/pagination/pagination.hook.js +20 -16
- package/dist/components/table/components/table-cell.d.ts +1 -1
- package/dist/components/table/components/table-cell.js +41 -32
- package/dist/components/table/components/table-filter/filters/boolean.js +52 -44
- package/dist/components/table/components/table-filter/filters/checkbox.js +35 -51
- package/dist/components/table/components/table-filter/filters/text.js +41 -39
- package/dist/components/table/components/table-filter/index.d.ts +4 -1
- package/dist/components/table/components/table-filter/selected-filters-display/index.d.ts +2 -0
- package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.d.ts +3 -0
- package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.js +30 -0
- package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.type.d.ts +12 -0
- package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.utils.d.ts +6 -0
- package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.utils.js +26 -0
- package/dist/components/table/components/table-filter/table-filter-button.d.ts +2 -0
- package/dist/components/table/components/table-filter/table-filter-button.js +113 -0
- package/dist/components/table/components/table-filter/table-filter-column-button.d.ts +3 -0
- package/dist/components/table/components/table-filter/table-filter-column-button.js +79 -0
- package/dist/components/table/components/table-filter/table-filter-column-button.type.d.ts +3 -0
- package/dist/components/table/components/table-filter/table-filter-provider.d.ts +14 -0
- package/dist/components/table/components/table-filter/table-filter-provider.js +32 -0
- package/dist/components/table/components/table-filter/table-filter.context.d.ts +21 -0
- package/dist/components/table/components/table-filter/table-filter.context.js +13 -0
- package/dist/components/table/components/table-filter/table-filter.hook.d.ts +1 -2
- package/dist/components/table/components/table-filter/table-filter.hook.js +39 -37
- package/dist/components/table/components/table-header/stories/basic-header.d.ts +1 -1
- package/dist/components/table/components/table-header/table-header.js +10 -10
- package/dist/components/table/index.d.ts +2 -3
- package/dist/components/table/table-provider.d.ts +1 -1
- package/dist/components/table/table-provider.js +50 -21
- package/dist/components/table/table.const.d.ts +10 -8
- package/dist/components/table/table.const.js +10 -8
- package/dist/components/table/table.js +1 -7
- package/dist/components/table/table.type.d.ts +37 -4
- package/dist/components/table/table.utils.d.ts +1 -2
- package/dist/components/table/table.utils.js +7 -3
- package/dist/components/table-card/table-card.js +113 -81
- package/dist/components/table-card/table-card.type.d.ts +7 -7
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/hooks/useClickOutside.d.ts +1 -0
- package/dist/hooks/useClickOutside.js +14 -0
- package/dist/index.js +106 -111
- package/dist/types/components/assets/icons/check.d.ts +8 -0
- package/dist/types/components/assets/icons/x-mark.d.ts +8 -0
- package/dist/types/components/table/components/cell/avatar-cell.d.ts +15 -0
- package/dist/types/components/table/components/cell/boolean-cell.d.ts +1 -2
- package/dist/types/components/table/components/cell/description-cell.d.ts +7 -0
- package/dist/types/components/table/components/cell/index.d.ts +10 -1
- package/dist/types/components/table/components/cell/label-cell.d.ts +10 -0
- package/dist/types/components/table/components/cell/link-cell.d.ts +10 -0
- package/dist/types/components/table/components/cell/number-cell.d.ts +5 -3
- package/dist/types/components/table/components/index.d.ts +1 -1
- package/dist/types/components/table/components/pagination/index.d.ts +1 -0
- package/dist/types/components/table/components/pagination/pagination.hook.d.ts +1 -1
- package/dist/types/components/table/components/table-cell.d.ts +1 -1
- package/dist/types/components/table/components/table-filter/index.d.ts +4 -1
- package/dist/types/components/table/components/table-filter/selected-filters-display/index.d.ts +2 -0
- package/dist/types/components/table/components/table-filter/selected-filters-display/selected-filters-display.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/selected-filters-display/selected-filters-display.type.d.ts +12 -0
- package/dist/types/components/table/components/table-filter/selected-filters-display/selected-filters-display.utils.d.ts +6 -0
- package/dist/types/components/table/components/table-filter/table-filter-button.d.ts +2 -0
- package/dist/types/components/table/components/table-filter/table-filter-column-button.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/table-filter-column-button.type.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/table-filter-provider.d.ts +14 -0
- package/dist/types/components/table/components/table-filter/table-filter.context.d.ts +21 -0
- package/dist/types/components/table/components/table-filter/table-filter.hook.d.ts +1 -2
- package/dist/types/components/table/components/table-header/stories/basic-header.d.ts +1 -1
- package/dist/types/components/table/index.d.ts +2 -3
- package/dist/types/components/table/table-provider.d.ts +1 -1
- package/dist/types/components/table/table.const.d.ts +10 -8
- package/dist/types/components/table/table.type.d.ts +37 -4
- package/dist/types/components/table/table.utils.d.ts +1 -2
- package/dist/types/components/table-card/table-card.type.d.ts +7 -7
- package/dist/types/hooks/useClickOutside.d.ts +1 -0
- package/package.json +2 -1
- package/dist/components/table/components/cell/text-cell.d.ts +0 -7
- package/dist/components/table/components/cell/text-cell.js +0 -5
- package/dist/components/table/components/table-filter/table-filter.d.ts +0 -9
- package/dist/components/table/components/table-filter/table-filter.js +0 -120
- package/dist/node_modules/@heroicons/react/24/solid/esm/CheckCircleIcon.js +0 -26
- package/dist/node_modules/@heroicons/react/24/solid/esm/XCircleIcon.js +0 -26
- package/dist/types/components/table/components/cell/text-cell.d.ts +0 -7
- package/dist/types/components/table/components/table-filter/table-filter.d.ts +0 -9
|
@@ -1,63 +1,71 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useEffect as
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as n } from "react";
|
|
3
|
+
const d = ["equals", "notEqual"], u = ({ value: t, onChange: s }) => {
|
|
4
|
+
n(() => {
|
|
5
|
+
t.condition || s({ condition: d[0] });
|
|
6
6
|
}, []);
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
}, n = (e) => {
|
|
10
|
-
switch (e) {
|
|
11
|
-
case "equals":
|
|
12
|
-
return "Equals";
|
|
13
|
-
case "notEqual":
|
|
14
|
-
return "Not equal to";
|
|
15
|
-
default:
|
|
16
|
-
return e;
|
|
17
|
-
}
|
|
7
|
+
const i = (r, a) => {
|
|
8
|
+
s(a ? { value: r } : { value: "" });
|
|
18
9
|
};
|
|
19
|
-
return /* @__PURE__ */
|
|
20
|
-
/* @__PURE__ */
|
|
21
|
-
/* @__PURE__ */
|
|
22
|
-
/* @__PURE__ */
|
|
10
|
+
return /* @__PURE__ */ e("div", { className: "w-full", children: /* @__PURE__ */ l("div", { className: "p-4 space-y-3", children: [
|
|
11
|
+
/* @__PURE__ */ l("label", { className: "flex items-center p-3 rounded-lg border border-stroke-solid-light hover:border-stroke-solid-medium hover:bg-gray-50 transition-all duration-200 cursor-pointer group", children: [
|
|
12
|
+
/* @__PURE__ */ l("div", { className: "relative", children: [
|
|
13
|
+
/* @__PURE__ */ e(
|
|
23
14
|
"input",
|
|
24
15
|
{
|
|
25
16
|
type: "checkbox",
|
|
26
|
-
checked:
|
|
27
|
-
onChange: (
|
|
28
|
-
className: "rounded border-stroke-solid-medium text-
|
|
17
|
+
checked: t.value === "true",
|
|
18
|
+
onChange: (r) => i("true", r.target.checked),
|
|
19
|
+
className: "w-5 h-5 rounded border-2 border-stroke-solid-medium text-blue-600 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors duration-200"
|
|
29
20
|
}
|
|
30
21
|
),
|
|
31
|
-
/* @__PURE__ */
|
|
22
|
+
t.value === "true" && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e("svg", { className: "w-3 h-3 text-white", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ e(
|
|
23
|
+
"path",
|
|
24
|
+
{
|
|
25
|
+
fillRule: "evenodd",
|
|
26
|
+
d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
|
|
27
|
+
clipRule: "evenodd"
|
|
28
|
+
}
|
|
29
|
+
) }) })
|
|
32
30
|
] }),
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
31
|
+
/* @__PURE__ */ l("div", { className: "ml-3 flex-1", children: [
|
|
32
|
+
/* @__PURE__ */ l("div", { className: "flex items-center", children: [
|
|
33
|
+
/* @__PURE__ */ e("span", { className: "text-sm font-medium text-text-neutral-primary", children: "True" }),
|
|
34
|
+
t.value === "true" && /* @__PURE__ */ e("span", { className: "ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800", children: "Selected" })
|
|
35
|
+
] }),
|
|
36
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-text-neutral-secondary mt-0.5", children: "Include records with true values" })
|
|
37
|
+
] })
|
|
38
|
+
] }),
|
|
39
|
+
/* @__PURE__ */ l("label", { className: "flex items-center p-3 rounded-lg border border-stroke-solid-light hover:border-stroke-solid-medium hover:bg-gray-50 transition-all duration-200 cursor-pointer group", children: [
|
|
40
|
+
/* @__PURE__ */ l("div", { className: "relative", children: [
|
|
41
|
+
/* @__PURE__ */ e(
|
|
35
42
|
"input",
|
|
36
43
|
{
|
|
37
44
|
type: "checkbox",
|
|
38
|
-
checked:
|
|
39
|
-
onChange: (
|
|
40
|
-
className: "rounded border-stroke-solid-medium text-
|
|
45
|
+
checked: t.value === "false",
|
|
46
|
+
onChange: (r) => i("false", r.target.checked),
|
|
47
|
+
className: "w-5 h-5 rounded border-2 border-stroke-solid-medium text-blue-600 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors duration-200"
|
|
41
48
|
}
|
|
42
49
|
),
|
|
43
|
-
/* @__PURE__ */
|
|
50
|
+
t.value === "false" && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e("svg", { className: "w-3 h-3 text-white", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ e(
|
|
51
|
+
"path",
|
|
52
|
+
{
|
|
53
|
+
fillRule: "evenodd",
|
|
54
|
+
d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
|
|
55
|
+
clipRule: "evenodd"
|
|
56
|
+
}
|
|
57
|
+
) }) })
|
|
58
|
+
] }),
|
|
59
|
+
/* @__PURE__ */ l("div", { className: "ml-3 flex-1", children: [
|
|
60
|
+
/* @__PURE__ */ l("div", { className: "flex items-center", children: [
|
|
61
|
+
/* @__PURE__ */ e("span", { className: "text-sm font-medium text-text-neutral-primary", children: "False" }),
|
|
62
|
+
t.value === "false" && /* @__PURE__ */ e("span", { className: "ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800", children: "Selected" })
|
|
63
|
+
] }),
|
|
64
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-text-neutral-secondary mt-0.5", children: "Include records with false values" })
|
|
44
65
|
] })
|
|
45
|
-
] }),
|
|
46
|
-
/* @__PURE__ */ t(
|
|
47
|
-
"select",
|
|
48
|
-
{
|
|
49
|
-
value: r.condition,
|
|
50
|
-
onChange: (e) => l({ condition: e.target.value }),
|
|
51
|
-
className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary rounded px-2 py-1 text-sm mb-3",
|
|
52
|
-
children: c.map((e) => /* @__PURE__ */ t("option", { value: e, children: n(e) }, e))
|
|
53
|
-
}
|
|
54
|
-
),
|
|
55
|
-
r.value && /* @__PURE__ */ a("div", { className: "mt-3 p-2 bg-surface-neutral-muted rounded text-sm", children: [
|
|
56
|
-
/* @__PURE__ */ t("div", { className: "text-text-neutral-muted mb-1", children: "Selected:" }),
|
|
57
|
-
/* @__PURE__ */ t("div", { className: "text-text-neutral-primary", children: r.value === "true" ? "True" : "False" })
|
|
58
66
|
] })
|
|
59
67
|
] }) });
|
|
60
68
|
};
|
|
61
69
|
export {
|
|
62
|
-
|
|
70
|
+
u as default
|
|
63
71
|
};
|
|
@@ -1,74 +1,58 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { MagnifierIcon as
|
|
1
|
+
import { jsx as t, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { useState as i, useEffect as h } from "react";
|
|
3
|
+
import { MagnifierIcon as y } from "../../../../assets/icons/magnifier-icon.js";
|
|
4
4
|
import C from "../../../../assets/icons/x.js";
|
|
5
|
-
const
|
|
6
|
-
const [n,
|
|
5
|
+
const k = ["includesAny", "includesAll", "excludes"], j = ({ value: r, onChange: d, filterOptions: c = [] }) => {
|
|
6
|
+
const [n, o] = i([]), [u, m] = i(""), [x, f] = i(c), p = (e) => {
|
|
7
7
|
m(e.target.value);
|
|
8
|
-
const
|
|
9
|
-
(
|
|
8
|
+
const a = c.filter(
|
|
9
|
+
(l) => l.label.toLowerCase().includes(e.target.value.toLowerCase())
|
|
10
10
|
);
|
|
11
|
-
|
|
11
|
+
f(a);
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, []),
|
|
16
|
-
Array.isArray(
|
|
17
|
-
}, [
|
|
18
|
-
const v = (e,
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
m(""),
|
|
13
|
+
h(() => {
|
|
14
|
+
r.condition || d({ condition: k[0] });
|
|
15
|
+
}, []), h(() => {
|
|
16
|
+
Array.isArray(r.value) ? o(r.value.filter(Boolean)) : o([]);
|
|
17
|
+
}, [r.value]);
|
|
18
|
+
const v = (e, a) => {
|
|
19
|
+
let l;
|
|
20
|
+
a ? l = [...n, e] : l = n.filter((g) => g !== e), o(l), d({ value: l });
|
|
21
|
+
}, b = () => {
|
|
22
|
+
m(""), f(c);
|
|
23
23
|
}, N = (e) => n.includes(e);
|
|
24
|
-
return c.length === 0 ? /* @__PURE__ */ t("div", { className: "text-text-neutral-muted text-sm", children: "No filter options available for this column" }) : /* @__PURE__ */
|
|
25
|
-
/* @__PURE__ */
|
|
26
|
-
/* @__PURE__ */ t(
|
|
24
|
+
return c.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", children: [
|
|
25
|
+
/* @__PURE__ */ s("div", { className: "relative border-b border-stroke-solid-medium", children: [
|
|
26
|
+
/* @__PURE__ */ t(y, { className: "absolute left-3 top-3.5 text-text-neutral-muted" }),
|
|
27
27
|
/* @__PURE__ */ t(
|
|
28
28
|
"input",
|
|
29
29
|
{
|
|
30
30
|
placeholder: "Search options",
|
|
31
|
-
value:
|
|
32
|
-
onChange:
|
|
33
|
-
className: "border-none outline-none bg-surface-neutral-default text-text-neutral-primary rounded p-3 pl-
|
|
31
|
+
value: u,
|
|
32
|
+
onChange: p,
|
|
33
|
+
className: "border-none outline-none bg-surface-neutral-default text-text-neutral-primary rounded p-3 pl-8 leading-none-medium-sm w-full"
|
|
34
34
|
}
|
|
35
35
|
),
|
|
36
|
-
|
|
36
|
+
u && /* @__PURE__ */ t("span", { className: "absolute right-3 top-3.5", onClick: b, children: /* @__PURE__ */ t(C, {}) })
|
|
37
37
|
] }),
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
"select",
|
|
41
|
-
{
|
|
42
|
-
value: s.condition,
|
|
43
|
-
onChange: (e) => d({ condition: e.target.value }),
|
|
44
|
-
className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary rounded px-2 py-1 text-sm mb-3",
|
|
45
|
-
children: h.map((e) => /* @__PURE__ */ r("option", { value: e, children: [
|
|
46
|
-
e === "includesAny" && "Includes any of",
|
|
47
|
-
e === "includesAll" && "Includes all of",
|
|
48
|
-
e === "excludes" && "Excludes"
|
|
49
|
-
] }, e))
|
|
50
|
-
}
|
|
51
|
-
),
|
|
52
|
-
/* @__PURE__ */ t("div", { className: "space-y-2 max-h-48 overflow-y-auto", children: p.map((e) => /* @__PURE__ */ r("label", { className: "flex items-center space-x-2 cursor-pointer", children: [
|
|
38
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col p-3", children: /* @__PURE__ */ t("div", { className: "space-y-5 h-full overflow-y-auto", children: x.map((e) => /* @__PURE__ */ s("div", { className: "flex justify-between items-center", children: [
|
|
39
|
+
/* @__PURE__ */ s("label", { className: "flex items-center space-x-2 cursor-pointer", children: [
|
|
53
40
|
/* @__PURE__ */ t(
|
|
54
41
|
"input",
|
|
55
42
|
{
|
|
56
43
|
type: "checkbox",
|
|
57
44
|
checked: N(e.value),
|
|
58
|
-
onChange: (
|
|
59
|
-
className: "rounded border-stroke-solid-medium text-text-neutral-primary focus:ring-2 focus:ring-blue-500"
|
|
45
|
+
onChange: (a) => v(e.value, a.target.checked)
|
|
60
46
|
}
|
|
61
47
|
),
|
|
62
|
-
/* @__PURE__ */ t("span", { className: "text-text-neutral-primary
|
|
63
|
-
] }
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return (l == null ? void 0 : l.label) || e;
|
|
69
|
-
}).join(", ") })
|
|
48
|
+
/* @__PURE__ */ t("span", { className: "text-text-neutral-primary leading-none-medium-sm", children: e.label })
|
|
49
|
+
] }),
|
|
50
|
+
e.total && /* @__PURE__ */ s("span", { className: "text-text-neutral-muted text-sm", children: [
|
|
51
|
+
"[",
|
|
52
|
+
e.total,
|
|
53
|
+
"]"
|
|
70
54
|
] })
|
|
71
|
-
] })
|
|
55
|
+
] }, e.value)) }) })
|
|
72
56
|
] });
|
|
73
57
|
};
|
|
74
58
|
export {
|
|
@@ -1,51 +1,53 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useEffect as
|
|
3
|
-
import
|
|
4
|
-
import { MagnifierIcon as
|
|
1
|
+
import { jsxs as l, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as c } from "react";
|
|
3
|
+
import s from "../../../../assets/icons/x.js";
|
|
4
|
+
import { MagnifierIcon as u } from "../../../../assets/icons/magnifier-icon.js";
|
|
5
|
+
import { Input as d } from "../../../../input/input.js";
|
|
5
6
|
const o = [
|
|
6
7
|
{ label: "Contains", value: "contains" },
|
|
7
8
|
{ label: "Does not equal", value: "notEqual" },
|
|
8
9
|
{ label: "Equals", value: "equals" }
|
|
9
|
-
],
|
|
10
|
-
var
|
|
11
|
-
const
|
|
10
|
+
], h = ({ value: t, onChange: a }) => {
|
|
11
|
+
var i;
|
|
12
|
+
const n = () => {
|
|
12
13
|
a({ value: "" });
|
|
13
14
|
};
|
|
14
|
-
return
|
|
15
|
+
return c(() => {
|
|
15
16
|
t.condition || a({ condition: o[0].value });
|
|
16
|
-
}, []), /* @__PURE__ */
|
|
17
|
-
/* @__PURE__ */
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/* @__PURE__ */ l(
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
17
|
+
}, []), /* @__PURE__ */ l("div", { className: "flex flex-col gap-3", children: [
|
|
18
|
+
/* @__PURE__ */ e("div", { className: "p-4 relative", children: /* @__PURE__ */ e(
|
|
19
|
+
d,
|
|
20
|
+
{
|
|
21
|
+
leftIcon: /* @__PURE__ */ e(u, {}),
|
|
22
|
+
size: "large",
|
|
23
|
+
placeholder: "Search options",
|
|
24
|
+
value: t.value,
|
|
25
|
+
rightIcon: t.value ? /* @__PURE__ */ e(s, { onClick: n }) : null,
|
|
26
|
+
onChange: (r) => a({ value: r.target.value }),
|
|
27
|
+
className: ""
|
|
28
|
+
}
|
|
29
|
+
) }),
|
|
30
|
+
/* @__PURE__ */ e("div", { className: "flex flex-col gap-2 p-3", children: t.value && /* @__PURE__ */ l("div", { className: "flex items-center justify-center gap-2 px-3 py-2", children: [
|
|
31
|
+
/* @__PURE__ */ e("span", { className: "text-text-neutral-muted text-xs font-medium uppercase tracking-wide", children: (i = o.find((r) => r.value === t.condition)) == null ? void 0 : i.label }),
|
|
32
|
+
/* @__PURE__ */ l("div", { className: "flex items-center gap-1", children: [
|
|
33
|
+
/* @__PURE__ */ l("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
|
+
"“",
|
|
35
|
+
t.value,
|
|
36
|
+
"”"
|
|
37
|
+
] }),
|
|
38
|
+
/* @__PURE__ */ e(
|
|
39
|
+
"button",
|
|
40
|
+
{
|
|
41
|
+
onClick: n,
|
|
42
|
+
className: "flex items-center justify-center w-5 h-5 rounded-full bg-surface-neutral-hovered hover:bg-surface-neutral-pressed transition-colors",
|
|
43
|
+
title: "Remove filter",
|
|
44
|
+
children: /* @__PURE__ */ e(s, { className: "w-3 h-3 text-text-neutral-muted" })
|
|
45
|
+
}
|
|
46
|
+
)
|
|
45
47
|
] })
|
|
46
|
-
] })
|
|
48
|
+
] }) })
|
|
47
49
|
] });
|
|
48
50
|
};
|
|
49
51
|
export {
|
|
50
|
-
|
|
52
|
+
h as default
|
|
51
53
|
};
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export { TableFilter } from './table-filter';
|
|
1
|
+
export { TableFilterProvider, TableFilter } from './table-filter-provider';
|
|
2
|
+
export { TableFilterButton } from './table-filter-button';
|
|
3
|
+
export { TableFilterColumnButton } from './table-filter-column-button';
|
|
4
|
+
export { useTableFilterContext } from './table-filter.context';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsxs as e, jsx as a, Fragment as i } from "react/jsx-runtime";
|
|
2
|
+
import * as m from "react";
|
|
3
|
+
import { createFilterDisplayItems as d, calculateTotalCount as o } from "./selected-filters-display.utils.js";
|
|
4
|
+
const u = ({
|
|
5
|
+
selectedFilters: r,
|
|
6
|
+
schema: s
|
|
7
|
+
}) => {
|
|
8
|
+
const l = d(r, s), n = o(l);
|
|
9
|
+
return /* @__PURE__ */ e("div", { className: "flex flex-col gap-2.5 max-w-md", children: [
|
|
10
|
+
n > 0 && /* @__PURE__ */ e("span", { className: "text-text-neutral-primary leading-none-medium-sm", children: [
|
|
11
|
+
n,
|
|
12
|
+
" total"
|
|
13
|
+
] }),
|
|
14
|
+
/* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2.5 max-w-md", children: l.map((t, c) => /* @__PURE__ */ e(m.Fragment, { children: [
|
|
15
|
+
/* @__PURE__ */ a("div", { className: "inline-flex items-center text-text-neutral-secondary rounded-md leading-none-regular-sm", children: /* @__PURE__ */ e("span", { className: "text-text-neutral-muted", children: [
|
|
16
|
+
t.fieldTitle,
|
|
17
|
+
" ",
|
|
18
|
+
t.count !== void 0 && /* @__PURE__ */ e(i, { children: [
|
|
19
|
+
"[",
|
|
20
|
+
/* @__PURE__ */ a("span", { className: "text-text-neutral-secondary", children: t.count }),
|
|
21
|
+
"]"
|
|
22
|
+
] })
|
|
23
|
+
] }) }),
|
|
24
|
+
c < l.length - 1 && /* @__PURE__ */ a("span", { className: "text-text-neutral-muted", children: "•" })
|
|
25
|
+
] }, t.field)) })
|
|
26
|
+
] });
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
u as SelectedFiltersDisplay
|
|
30
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FilterRule, TableSchema } from '../../../table.type';
|
|
2
|
+
export interface SelectedFilterDisplayProps {
|
|
3
|
+
selectedFilters: FilterRule[];
|
|
4
|
+
schema: TableSchema;
|
|
5
|
+
}
|
|
6
|
+
export interface FilterDisplayItem {
|
|
7
|
+
field: string;
|
|
8
|
+
fieldTitle: string;
|
|
9
|
+
value: string | string[];
|
|
10
|
+
condition?: string;
|
|
11
|
+
count?: number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FilterRule, TableSchema, FilterOption } from '../../../table.type';
|
|
2
|
+
import { FilterDisplayItem } from './selected-filters-display.type';
|
|
3
|
+
export declare const formatFilterValue: (value: string | string[]) => string;
|
|
4
|
+
export declare const getFilterCount: (filterRule: FilterRule, filterOptions?: FilterOption[]) => number | undefined;
|
|
5
|
+
export declare const createFilterDisplayItems: (selectedFilters: FilterRule[], schema: TableSchema) => FilterDisplayItem[];
|
|
6
|
+
export declare const calculateTotalCount: (filterDisplayItems: FilterDisplayItem[]) => number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const o = (n, u) => {
|
|
2
|
+
if (!u || u.length === 0) return n.value !== "" ? 1 : 0;
|
|
3
|
+
if (Array.isArray(n.value)) {
|
|
4
|
+
const t = u.filter(
|
|
5
|
+
(r) => n.value.includes(r.value)
|
|
6
|
+
).reduce((r, a) => r + (a.total || 0), 0);
|
|
7
|
+
return t > 0 ? t : void 0;
|
|
8
|
+
} else {
|
|
9
|
+
const e = u.find((t) => t.value === n.value);
|
|
10
|
+
return e == null ? void 0 : e.total;
|
|
11
|
+
}
|
|
12
|
+
}, l = (n, u) => n.filter((e) => Array.isArray(e.value) ? e.value.length > 0 : e.value !== "").map((e) => {
|
|
13
|
+
const t = u.find((a) => a.key === e.field), r = o(e, t == null ? void 0 : t.filterOptions);
|
|
14
|
+
return {
|
|
15
|
+
field: e.field,
|
|
16
|
+
fieldTitle: (t == null ? void 0 : t.title) || e.field,
|
|
17
|
+
value: e.value,
|
|
18
|
+
condition: e.condition,
|
|
19
|
+
count: r
|
|
20
|
+
};
|
|
21
|
+
}), c = (n) => n.reduce((u, e) => u + (e.count || 1), 0);
|
|
22
|
+
export {
|
|
23
|
+
c as calculateTotalCount,
|
|
24
|
+
l as createFilterDisplayItems,
|
|
25
|
+
o as getFilterCount
|
|
26
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import * as x from "react";
|
|
3
|
+
import { Button as d } from "../../../button/button.js";
|
|
4
|
+
import { useTableFilterContext as z } from "./table-filter.context.js";
|
|
5
|
+
import S from "./filters/text.js";
|
|
6
|
+
import B from "./filters/boolean.js";
|
|
7
|
+
import D from "./filters/number/number.js";
|
|
8
|
+
import I from "./filters/checkbox.js";
|
|
9
|
+
import R from "../../../assets/icons/circle-check-filled.js";
|
|
10
|
+
import { SelectedFiltersDisplay as P } from "./selected-filters-display/selected-filters-display.js";
|
|
11
|
+
import { useClickOutside as V } from "../../../../hooks/useClickOutside.js";
|
|
12
|
+
import { createFilterDisplayItems as q, calculateTotalCount as E } from "./selected-filters-display/selected-filters-display.utils.js";
|
|
13
|
+
const Z = () => {
|
|
14
|
+
const [m, o] = x.useState(!1), p = x.useRef(null), {
|
|
15
|
+
selectedColumn: r,
|
|
16
|
+
setSelectedColumn: b,
|
|
17
|
+
getFilterForColumn: y,
|
|
18
|
+
hasFilterForColumn: v,
|
|
19
|
+
updateColumnFilter: F,
|
|
20
|
+
clearAllFilters: k,
|
|
21
|
+
applyFilters: N,
|
|
22
|
+
hasActiveFilters: i,
|
|
23
|
+
filterableFields: g,
|
|
24
|
+
tempFilters: u,
|
|
25
|
+
schema: a,
|
|
26
|
+
filter: C,
|
|
27
|
+
filterComponents: n = {}
|
|
28
|
+
} = z();
|
|
29
|
+
V(p, () => o(!1));
|
|
30
|
+
const w = () => {
|
|
31
|
+
N(), o(!1);
|
|
32
|
+
}, T = q(u, a), f = E(T), j = () => {
|
|
33
|
+
if (!r) return null;
|
|
34
|
+
const e = a.find((c) => c.key === r), A = {
|
|
35
|
+
boolean: B,
|
|
36
|
+
text: S,
|
|
37
|
+
number: D,
|
|
38
|
+
checkbox: I
|
|
39
|
+
}, h = (e == null ? void 0 : e.cellType) && (n == null ? void 0 : n[e.cellType]) || A[(e == null ? void 0 : e.cellType) ?? "text"];
|
|
40
|
+
if (!h)
|
|
41
|
+
return console.warn(
|
|
42
|
+
`No filter component found for column "${e == null ? void 0 : e.key}" with cellType "${e == null ? void 0 : e.cellType}". Provide a custom filter component or use supported types: "text", "number", "boolean", "checkbox".`
|
|
43
|
+
), null;
|
|
44
|
+
const s = y(r), O = {
|
|
45
|
+
condition: (s == null ? void 0 : s.condition) || "",
|
|
46
|
+
value: (s == null ? void 0 : s.value) || ""
|
|
47
|
+
};
|
|
48
|
+
return /* @__PURE__ */ t("div", { className: "flex-1", children: /* @__PURE__ */ t("div", { className: "mb-4", children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ t(
|
|
49
|
+
h,
|
|
50
|
+
{
|
|
51
|
+
value: O,
|
|
52
|
+
onChange: ({ condition: c, value: $ }) => F(r, c, $),
|
|
53
|
+
filterOptions: e == null ? void 0 : e.filterOptions
|
|
54
|
+
}
|
|
55
|
+
) }) }) });
|
|
56
|
+
};
|
|
57
|
+
return /* @__PURE__ */ l("div", { className: "relative", ref: p, children: [
|
|
58
|
+
/* @__PURE__ */ l(
|
|
59
|
+
d,
|
|
60
|
+
{
|
|
61
|
+
onClick: (e) => {
|
|
62
|
+
e.stopPropagation(), o(!m);
|
|
63
|
+
},
|
|
64
|
+
variant: i ? "filled" : "stroke",
|
|
65
|
+
shade: i ? "brand" : "neutral",
|
|
66
|
+
size: "small",
|
|
67
|
+
children: [
|
|
68
|
+
"Filter ",
|
|
69
|
+
i && `(${C.value.length})`
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
m && /* @__PURE__ */ l("div", { className: "absolute top-full left-0 mt-2 w-[512px] bg-surface-neutral-default border border-stroke-solid-light rounded-2xl z-10 overflow-hidden shadow-lg", children: [
|
|
74
|
+
/* @__PURE__ */ l("div", { className: "flex min-h-[442px]", children: [
|
|
75
|
+
/* @__PURE__ */ l("div", { className: "w-48 border-r border-stroke-solid-light p-2 flex flex-col gap-1.5", children: [
|
|
76
|
+
/* @__PURE__ */ t("div", { className: "p-2 pb-1", children: /* @__PURE__ */ t("h3", { className: "leading-none-medium-sm text-text-neutral-secondary", children: "Filters" }) }),
|
|
77
|
+
g.map((e) => /* @__PURE__ */ l(
|
|
78
|
+
"button",
|
|
79
|
+
{
|
|
80
|
+
onClick: () => b(e.key),
|
|
81
|
+
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.key ? "bg-surface-neutral-focused text-text-brand-primary" : "text-text-neutral-primary"}`,
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: e.title }),
|
|
84
|
+
v(e.key) && /* @__PURE__ */ t(R, { className: "w-4 h-4 text-text-brand-secondary flex-shrink-0 ml-2" })
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
e.key
|
|
88
|
+
))
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ t("div", { className: "flex-1 flex flex-col", children: r ? j() : /* @__PURE__ */ t("div", { className: "flex-1 flex items-center justify-center text-text-neutral-muted", children: "Select a column to configure its filter" }) })
|
|
91
|
+
] }),
|
|
92
|
+
!!f && /* @__PURE__ */ l("div", { className: "flex justify-between items-end p-4 border-t border-stroke-solid-medium min-h-[71px]", children: [
|
|
93
|
+
/* @__PURE__ */ t(P, { selectedFilters: u, schema: a }),
|
|
94
|
+
/* @__PURE__ */ l("div", { className: "flex justify-end gap-2", children: [
|
|
95
|
+
/* @__PURE__ */ t(d, { onClick: k, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
|
|
96
|
+
/* @__PURE__ */ t(
|
|
97
|
+
d,
|
|
98
|
+
{
|
|
99
|
+
onClick: w,
|
|
100
|
+
variant: "filled",
|
|
101
|
+
shade: "neutral",
|
|
102
|
+
size: "small",
|
|
103
|
+
children: `Apply ${f || ""}`
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] })
|
|
107
|
+
] })
|
|
108
|
+
] })
|
|
109
|
+
] });
|
|
110
|
+
};
|
|
111
|
+
export {
|
|
112
|
+
Z as TableFilterButton
|
|
113
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import * as C from "react";
|
|
3
|
+
import { Button as d } from "../../../button/button.js";
|
|
4
|
+
import { useTableFilterContext as T } from "./table-filter.context.js";
|
|
5
|
+
import O from "./filters/text.js";
|
|
6
|
+
import $ from "./filters/boolean.js";
|
|
7
|
+
import A from "./filters/number/number.js";
|
|
8
|
+
import z from "./filters/checkbox.js";
|
|
9
|
+
import j from "../../../assets/icons/circle-check-filled.js";
|
|
10
|
+
import { useClickOutside as B } from "../../../../hooks/useClickOutside.js";
|
|
11
|
+
import { getFilterCount as R } from "./selected-filters-display/selected-filters-display.utils.js";
|
|
12
|
+
const J = ({ filterName: o }) => {
|
|
13
|
+
const [u, n] = C.useState(!1), m = C.useRef(null);
|
|
14
|
+
B(m, () => n(!1));
|
|
15
|
+
const {
|
|
16
|
+
getFilterForColumn: b,
|
|
17
|
+
hasAppliedFilterForColumn: x,
|
|
18
|
+
updateColumnFilter: p,
|
|
19
|
+
applyFilters: f,
|
|
20
|
+
schema: F,
|
|
21
|
+
filterComponents: i = {}
|
|
22
|
+
} = T(), e = F.find((c) => c.key === o);
|
|
23
|
+
if (!e)
|
|
24
|
+
return console.warn(`Column "${o}" not found in schema`), null;
|
|
25
|
+
if (e.filterable === !1)
|
|
26
|
+
return console.warn(`Column "${o}" is not filterable`), null;
|
|
27
|
+
const k = {
|
|
28
|
+
boolean: $,
|
|
29
|
+
text: O,
|
|
30
|
+
number: A,
|
|
31
|
+
checkbox: z
|
|
32
|
+
}, h = e.cellType && (i == null ? void 0 : i[e.cellType]) || k[e.cellType ?? "text"];
|
|
33
|
+
if (!h)
|
|
34
|
+
return console.warn(
|
|
35
|
+
`No filter component found for column "${e.key}" with cellType "${e.cellType}". Provide a custom filter component or use supported types: "text", "number", "boolean", "checkbox".`
|
|
36
|
+
), null;
|
|
37
|
+
const l = b(o), s = x(o), a = l ? R(l, e.filterOptions) : void 0, v = {
|
|
38
|
+
condition: (l == null ? void 0 : l.condition) || "",
|
|
39
|
+
value: (l == null ? void 0 : l.value) || ""
|
|
40
|
+
}, y = () => {
|
|
41
|
+
p(o, "", ""), f(), n(!1);
|
|
42
|
+
}, w = () => {
|
|
43
|
+
f(), n(!1);
|
|
44
|
+
};
|
|
45
|
+
return /* @__PURE__ */ r("div", { className: "relative", ref: m, children: [
|
|
46
|
+
/* @__PURE__ */ t(
|
|
47
|
+
d,
|
|
48
|
+
{
|
|
49
|
+
onClick: () => {
|
|
50
|
+
n(!u);
|
|
51
|
+
},
|
|
52
|
+
variant: s ? "filled" : "stroke",
|
|
53
|
+
shade: s ? "brand" : "neutral",
|
|
54
|
+
size: "small",
|
|
55
|
+
children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
|
|
56
|
+
e.title,
|
|
57
|
+
s && /* @__PURE__ */ t(j, { className: "w-4 h-4 text-white flex-shrink-0" })
|
|
58
|
+
] })
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
u && /* @__PURE__ */ r("div", { className: "absolute top-full left-0 mt-2 w-80 bg-surface-neutral-default border border-stroke-solid-light rounded-2xl z-10 overflow-hidden shadow-lg", children: [
|
|
62
|
+
/* @__PURE__ */ t(
|
|
63
|
+
h,
|
|
64
|
+
{
|
|
65
|
+
value: v,
|
|
66
|
+
onChange: ({ condition: c, value: g }) => p(o, c, g),
|
|
67
|
+
filterOptions: e.filterOptions
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
!!a && /* @__PURE__ */ r("div", { className: "flex justify-between gap-2 p-3 border-t border-stroke-solid-medium", children: [
|
|
71
|
+
/* @__PURE__ */ t(d, { onClick: y, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
|
|
72
|
+
/* @__PURE__ */ t(d, { onClick: w, variant: "filled", shade: "neutral", size: "small", children: `Apply${a !== void 0 ? ` ${a}` : ""}` })
|
|
73
|
+
] })
|
|
74
|
+
] })
|
|
75
|
+
] });
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
J as TableFilterColumnButton
|
|
79
|
+
};
|