@ztwoint/z-ui 0.1.33 → 0.1.34
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/components/table-cell.js +25 -24
- package/dist/components/table/components/table-filter/filters/boolean.js +60 -28
- package/dist/components/table/components/table-filter/filters/checkbox.d.ts +3 -0
- package/dist/components/table/components/table-filter/filters/checkbox.js +76 -0
- package/dist/components/table/components/table-filter/filters/index.d.ts +1 -0
- package/dist/components/table/components/table-filter/filters/number/filter-input-field.d.ts +11 -0
- package/dist/components/table/components/table-filter/filters/number/filter-input-field.js +38 -0
- package/dist/components/table/components/table-filter/filters/number/index.d.ts +1 -0
- package/dist/components/table/components/table-filter/filters/{number.d.ts → number/number.d.ts} +1 -1
- package/dist/components/table/components/table-filter/filters/number/number.hook.d.ts +23 -0
- package/dist/components/table/components/table-filter/filters/number/number.hook.js +33 -0
- package/dist/components/table/components/table-filter/filters/number/number.js +55 -0
- package/dist/components/table/components/table-filter/filters/text.js +49 -26
- package/dist/components/table/components/table-filter/table-filter.hook.d.ts +6 -3
- package/dist/components/table/components/table-filter/table-filter.hook.js +49 -29
- package/dist/components/table/components/table-filter/table-filter.js +93 -79
- package/dist/components/table/components/table-filter/table-filter.type.d.ts +4 -3
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/table.type.d.ts +6 -1
- package/dist/components/table-card/table-card.js +105 -0
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +19 -17
- package/dist/types/components/table/components/table-filter/filters/checkbox.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/filters/index.d.ts +1 -0
- package/dist/types/components/table/components/table-filter/filters/number/filter-input-field.d.ts +11 -0
- package/dist/types/components/table/components/table-filter/filters/number/index.d.ts +1 -0
- package/dist/types/components/table/components/table-filter/filters/{number.d.ts → number/number.d.ts} +1 -1
- package/dist/types/components/table/components/table-filter/filters/number/number.hook.d.ts +23 -0
- package/dist/types/components/table/components/table-filter/table-filter.hook.d.ts +6 -3
- package/dist/types/components/table/components/table-filter/table-filter.type.d.ts +4 -3
- package/dist/types/components/table/index.d.ts +1 -1
- package/dist/types/components/table/table.type.d.ts +6 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/components/table/components/table-filter/filters/number.js +0 -28
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { TABLE_CSS_CLASSES as r } from "../table.const.js";
|
|
3
|
-
import { TextCell as
|
|
3
|
+
import { TextCell as m } from "./cell/text-cell.js";
|
|
4
4
|
import { NumberCell as h } from "./cell/number-cell.js";
|
|
5
|
-
import { BooleanCell as
|
|
5
|
+
import { BooleanCell as b } from "./cell/boolean-cell.js";
|
|
6
6
|
import "react";
|
|
7
|
-
import { cn as
|
|
7
|
+
import { cn as S } from "../../../lib/utils.js";
|
|
8
8
|
const E = ({
|
|
9
|
-
value:
|
|
10
|
-
cellType:
|
|
11
|
-
cellRenderer:
|
|
12
|
-
record:
|
|
13
|
-
index:
|
|
9
|
+
value: t,
|
|
10
|
+
cellType: n,
|
|
11
|
+
cellRenderer: f,
|
|
12
|
+
record: i,
|
|
13
|
+
index: C,
|
|
14
14
|
customCells: e,
|
|
15
|
-
cell:
|
|
15
|
+
cell: s
|
|
16
16
|
}) => {
|
|
17
|
-
const
|
|
18
|
-
text:
|
|
17
|
+
const p = {
|
|
18
|
+
text: m,
|
|
19
19
|
number: h,
|
|
20
|
-
boolean:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
boolean: b,
|
|
21
|
+
checkbox: m
|
|
22
|
+
}, a = e == null ? void 0 : e[n];
|
|
23
|
+
let o;
|
|
24
|
+
if (f)
|
|
25
|
+
o = f({ value: t, record: i, index: C });
|
|
26
|
+
else if (a)
|
|
27
|
+
o = /* @__PURE__ */ l(a, { value: t, record: i, index: C });
|
|
27
28
|
else {
|
|
28
|
-
const
|
|
29
|
-
|
|
29
|
+
const c = p[n] ?? m;
|
|
30
|
+
o = /* @__PURE__ */ l(c, { value: t });
|
|
30
31
|
}
|
|
31
32
|
return /* @__PURE__ */ l(
|
|
32
33
|
"td",
|
|
33
34
|
{
|
|
34
|
-
className:
|
|
35
|
+
className: S(
|
|
35
36
|
r.cell.default,
|
|
36
|
-
r.cell.cellHeight[
|
|
37
|
-
r.cell.hasBorder[
|
|
37
|
+
r.cell.cellHeight[s.cellHeight],
|
|
38
|
+
r.cell.hasBorder[s.hasBorder ? "true" : "false"]
|
|
38
39
|
),
|
|
39
|
-
children:
|
|
40
|
+
children: o
|
|
40
41
|
}
|
|
41
42
|
);
|
|
42
43
|
};
|
|
@@ -1,31 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect as
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { jsx as t, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as i } from "react";
|
|
3
|
+
const c = ["equals", "notEqual"], m = ({ value: r, onChange: l }) => {
|
|
4
|
+
i(() => {
|
|
5
|
+
r.condition || l({ condition: c[0] });
|
|
6
|
+
}, []);
|
|
7
|
+
const s = (e, u) => {
|
|
8
|
+
l(u ? { value: e } : { value: "" });
|
|
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;
|
|
13
17
|
}
|
|
14
|
-
|
|
15
|
-
/* @__PURE__ */ a(
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
] })
|
|
18
|
+
};
|
|
19
|
+
return /* @__PURE__ */ t("div", { className: "flex flex-col", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-2 p-3", children: [
|
|
20
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
21
|
+
/* @__PURE__ */ a("label", { className: "flex items-center space-x-2 cursor-pointer", children: [
|
|
22
|
+
/* @__PURE__ */ t(
|
|
23
|
+
"input",
|
|
24
|
+
{
|
|
25
|
+
type: "checkbox",
|
|
26
|
+
checked: r.value === "true",
|
|
27
|
+
onChange: (e) => s("true", e.target.checked),
|
|
28
|
+
className: "rounded border-stroke-solid-medium text-text-neutral-primary focus:ring-2 focus:ring-blue-500"
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
/* @__PURE__ */ t("span", { className: "text-text-neutral-primary text-sm", children: "True" })
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ a("label", { className: "flex items-center space-x-2 cursor-pointer", children: [
|
|
34
|
+
/* @__PURE__ */ t(
|
|
35
|
+
"input",
|
|
36
|
+
{
|
|
37
|
+
type: "checkbox",
|
|
38
|
+
checked: r.value === "false",
|
|
39
|
+
onChange: (e) => s("false", e.target.checked),
|
|
40
|
+
className: "rounded border-stroke-solid-medium text-text-neutral-primary focus:ring-2 focus:ring-blue-500"
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
/* @__PURE__ */ t("span", { className: "text-text-neutral-primary text-sm", children: "False" })
|
|
44
|
+
] })
|
|
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
|
+
] })
|
|
59
|
+
] }) });
|
|
60
|
+
};
|
|
29
61
|
export {
|
|
30
|
-
|
|
62
|
+
m as default
|
|
31
63
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as t, jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as o, useEffect as f } from "react";
|
|
3
|
+
import { MagnifierIcon as k } from "../../../../assets/icons/magnifier-icon.js";
|
|
4
|
+
import C from "../../../../assets/icons/x.js";
|
|
5
|
+
const h = ["includesAny", "includesAll", "excludes"], j = ({ value: s, onChange: d, filterOptions: c = [] }) => {
|
|
6
|
+
const [n, u] = o([]), [i, m] = o(""), [p, x] = o(c), b = (e) => {
|
|
7
|
+
m(e.target.value);
|
|
8
|
+
const l = c.filter(
|
|
9
|
+
(a) => a.label.toLowerCase().includes(e.target.value.toLowerCase())
|
|
10
|
+
);
|
|
11
|
+
x(l);
|
|
12
|
+
};
|
|
13
|
+
f(() => {
|
|
14
|
+
s.condition || d({ condition: h[0] });
|
|
15
|
+
}, []), f(() => {
|
|
16
|
+
Array.isArray(s.value) ? u(s.value.filter(Boolean)) : u([]);
|
|
17
|
+
}, [s.value]);
|
|
18
|
+
const v = (e, l) => {
|
|
19
|
+
let a;
|
|
20
|
+
l ? a = [...n, e] : a = n.filter((y) => y !== e), u(a), d({ value: a });
|
|
21
|
+
}, g = () => {
|
|
22
|
+
m(""), x(c);
|
|
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__ */ r("div", { className: "flex flex-col", children: [
|
|
25
|
+
/* @__PURE__ */ r("div", { className: "relative border-b border-stroke-solid-medium", children: [
|
|
26
|
+
/* @__PURE__ */ t(k, { className: "absolute left-3 top-3.5 text-text-neutral-muted" }),
|
|
27
|
+
/* @__PURE__ */ t(
|
|
28
|
+
"input",
|
|
29
|
+
{
|
|
30
|
+
placeholder: "Search options",
|
|
31
|
+
value: i,
|
|
32
|
+
onChange: b,
|
|
33
|
+
className: "border-none outline-none bg-surface-neutral-default text-text-neutral-primary rounded p-3 pl-10 text-sm w-full"
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
i && /* @__PURE__ */ t("span", { className: "absolute right-3 top-3.5", onClick: g, children: /* @__PURE__ */ t(C, {}) })
|
|
37
|
+
] }),
|
|
38
|
+
/* @__PURE__ */ r("div", { className: "flex flex-col gap-2 p-3", children: [
|
|
39
|
+
/* @__PURE__ */ t(
|
|
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: [
|
|
53
|
+
/* @__PURE__ */ t(
|
|
54
|
+
"input",
|
|
55
|
+
{
|
|
56
|
+
type: "checkbox",
|
|
57
|
+
checked: N(e.value),
|
|
58
|
+
onChange: (l) => v(e.value, l.target.checked),
|
|
59
|
+
className: "rounded border-stroke-solid-medium text-text-neutral-primary focus:ring-2 focus:ring-blue-500"
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
/* @__PURE__ */ t("span", { className: "text-text-neutral-primary text-sm", children: e.label })
|
|
63
|
+
] }, e.value)) }),
|
|
64
|
+
n.length > 0 && /* @__PURE__ */ r("div", { className: "mt-3 p-2 bg-surface-neutral-muted rounded text-sm", children: [
|
|
65
|
+
/* @__PURE__ */ t("div", { className: "text-text-neutral-muted mb-1", children: "Selected:" }),
|
|
66
|
+
/* @__PURE__ */ t("div", { className: "text-text-neutral-primary", children: n.map((e) => {
|
|
67
|
+
const l = c.find((a) => a.value === e);
|
|
68
|
+
return (l == null ? void 0 : l.label) || e;
|
|
69
|
+
}).join(", ") })
|
|
70
|
+
] })
|
|
71
|
+
] })
|
|
72
|
+
] });
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
j as default
|
|
76
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface FilterInputFieldProps {
|
|
2
|
+
label: string;
|
|
3
|
+
operator: string;
|
|
4
|
+
value: string;
|
|
5
|
+
onChange: (value: string) => void;
|
|
6
|
+
onReset: () => void;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const FilterInputField: React.FC<FilterInputFieldProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import i from "../../../../../assets/icons/x.js";
|
|
3
|
+
const d = ({
|
|
4
|
+
label: l,
|
|
5
|
+
operator: n,
|
|
6
|
+
value: e,
|
|
7
|
+
onChange: o,
|
|
8
|
+
onReset: s,
|
|
9
|
+
disabled: r,
|
|
10
|
+
placeholder: m = "0.00"
|
|
11
|
+
}) => /* @__PURE__ */ a("div", { className: "flex flex-col gap-2", children: [
|
|
12
|
+
/* @__PURE__ */ t("label", { className: "text-sm font-medium text-text-neutral-primary", children: l }),
|
|
13
|
+
/* @__PURE__ */ a("div", { className: "relative", children: [
|
|
14
|
+
/* @__PURE__ */ t("span", { className: "absolute left-3 top-1/2 transform -translate-y-1/2 text-text-neutral-muted", children: n }),
|
|
15
|
+
/* @__PURE__ */ t(
|
|
16
|
+
"input",
|
|
17
|
+
{
|
|
18
|
+
type: "number",
|
|
19
|
+
value: e,
|
|
20
|
+
onChange: (u) => o(u.target.value),
|
|
21
|
+
placeholder: m,
|
|
22
|
+
disabled: r,
|
|
23
|
+
className: `border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary placeholder:text-text-neutral-muted rounded px-2 py-2 pl-10 pr-8 text-sm w-full ${r ? "opacity-50 cursor-not-allowed" : ""}`
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
e && /* @__PURE__ */ t(
|
|
27
|
+
"button",
|
|
28
|
+
{
|
|
29
|
+
onClick: s,
|
|
30
|
+
className: "absolute right-2 top-1/2 transform -translate-y-1/2 text-text-neutral-muted hover:text-text-neutral-primary",
|
|
31
|
+
children: /* @__PURE__ */ t(i, {})
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
] })
|
|
35
|
+
] });
|
|
36
|
+
export {
|
|
37
|
+
d as FilterInputField
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './number';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface UseNumberFilterProps {
|
|
2
|
+
value: {
|
|
3
|
+
condition: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
onChange: (update: {
|
|
7
|
+
condition?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
}) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const useNumberFilter: ({ value, onChange }: UseNumberFilterProps) => {
|
|
12
|
+
specificAmount: string;
|
|
13
|
+
atLeast: string;
|
|
14
|
+
noMoreThan: string;
|
|
15
|
+
activeField: string | null;
|
|
16
|
+
handleSpecificAmountChange: (newValue: string) => void;
|
|
17
|
+
handleAtLeastChange: (newValue: string) => void;
|
|
18
|
+
handleNoMoreThanChange: (newValue: string) => void;
|
|
19
|
+
resetSpecificAmount: () => void;
|
|
20
|
+
resetAtLeast: () => void;
|
|
21
|
+
resetNoMoreThan: () => void;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState as s, useEffect as l } from "react";
|
|
2
|
+
const T = ({ value: t, onChange: i }) => {
|
|
3
|
+
const [r, o] = s(""), [d, n] = s(""), [a, c] = s(""), f = r ? "specific" : d ? "atLeast" : a ? "noMoreThan" : null;
|
|
4
|
+
return l(() => {
|
|
5
|
+
t.condition === "=" && t.value ? (o(t.value), n(""), c("")) : t.condition === ">" && t.value ? (n(t.value), o(""), c("")) : t.condition === "<" && t.value && (c(t.value), o(""), n(""));
|
|
6
|
+
}, [t.condition, t.value]), {
|
|
7
|
+
specificAmount: r,
|
|
8
|
+
atLeast: d,
|
|
9
|
+
noMoreThan: a,
|
|
10
|
+
activeField: f,
|
|
11
|
+
handleSpecificAmountChange: (e) => {
|
|
12
|
+
o(e), e ? (n(""), c(""), i({ condition: "=", value: e })) : i({ condition: "", value: "" });
|
|
13
|
+
},
|
|
14
|
+
handleAtLeastChange: (e) => {
|
|
15
|
+
n(e), e ? (o(""), c(""), i({ condition: ">", value: e })) : i({ condition: "", value: "" });
|
|
16
|
+
},
|
|
17
|
+
handleNoMoreThanChange: (e) => {
|
|
18
|
+
c(e), e ? (o(""), n(""), i({ condition: "<", value: e })) : i({ condition: "", value: "" });
|
|
19
|
+
},
|
|
20
|
+
resetSpecificAmount: () => {
|
|
21
|
+
o(""), i({ condition: "", value: "" });
|
|
22
|
+
},
|
|
23
|
+
resetAtLeast: () => {
|
|
24
|
+
n(""), i({ condition: "", value: "" });
|
|
25
|
+
},
|
|
26
|
+
resetNoMoreThan: () => {
|
|
27
|
+
c(""), i({ condition: "", value: "" });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
T as useNumberFilter
|
|
33
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsxs as m, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useNumberFilter as f } from "./number.hook.js";
|
|
3
|
+
import { FilterInputField as t } from "./filter-input-field.js";
|
|
4
|
+
const C = ({ value: o, onChange: l }) => {
|
|
5
|
+
const {
|
|
6
|
+
specificAmount: n,
|
|
7
|
+
atLeast: r,
|
|
8
|
+
noMoreThan: s,
|
|
9
|
+
activeField: e,
|
|
10
|
+
handleSpecificAmountChange: i,
|
|
11
|
+
handleAtLeastChange: c,
|
|
12
|
+
handleNoMoreThanChange: h,
|
|
13
|
+
resetSpecificAmount: p,
|
|
14
|
+
resetAtLeast: u,
|
|
15
|
+
resetNoMoreThan: d
|
|
16
|
+
} = f({ value: o, onChange: l });
|
|
17
|
+
return /* @__PURE__ */ m("div", { className: "flex flex-col gap-4 p-4", children: [
|
|
18
|
+
/* @__PURE__ */ a(
|
|
19
|
+
t,
|
|
20
|
+
{
|
|
21
|
+
label: "Specific",
|
|
22
|
+
operator: "=",
|
|
23
|
+
value: n,
|
|
24
|
+
onChange: i,
|
|
25
|
+
onReset: p,
|
|
26
|
+
disabled: e !== null && e !== "specific"
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
/* @__PURE__ */ a(
|
|
30
|
+
t,
|
|
31
|
+
{
|
|
32
|
+
label: "At least...",
|
|
33
|
+
operator: "≥",
|
|
34
|
+
value: r,
|
|
35
|
+
onChange: c,
|
|
36
|
+
onReset: u,
|
|
37
|
+
disabled: e !== null && e !== "atLeast"
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
/* @__PURE__ */ a(
|
|
41
|
+
t,
|
|
42
|
+
{
|
|
43
|
+
label: "No more than...",
|
|
44
|
+
operator: "≤",
|
|
45
|
+
value: s,
|
|
46
|
+
onChange: h,
|
|
47
|
+
onReset: d,
|
|
48
|
+
disabled: e !== null && e !== "noMoreThan"
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
] });
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
C as default
|
|
55
|
+
};
|
|
@@ -1,28 +1,51 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useEffect as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { jsxs as r, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as s } from "react";
|
|
3
|
+
import u from "../../../../assets/icons/x.js";
|
|
4
|
+
import { MagnifierIcon as c } from "../../../../assets/icons/magnifier-icon.js";
|
|
5
|
+
const o = [
|
|
6
|
+
{ label: "Contains", value: "contains" },
|
|
7
|
+
{ label: "Does not equal", value: "notEqual" },
|
|
8
|
+
{ label: "Equals", value: "equals" }
|
|
9
|
+
], f = ({ value: t, onChange: a }) => {
|
|
10
|
+
var n;
|
|
11
|
+
const i = () => {
|
|
12
|
+
a({ value: "" });
|
|
13
|
+
};
|
|
14
|
+
return s(() => {
|
|
15
|
+
t.condition || a({ condition: o[0].value });
|
|
16
|
+
}, []), /* @__PURE__ */ r("div", { className: "flex flex-col gap-3", children: [
|
|
17
|
+
/* @__PURE__ */ r("div", { className: "relative border-b border-stroke-solid-medium", children: [
|
|
18
|
+
/* @__PURE__ */ l(c, { className: "absolute left-3 top-3.5 text-text-neutral-muted" }),
|
|
19
|
+
/* @__PURE__ */ l(
|
|
20
|
+
"input",
|
|
21
|
+
{
|
|
22
|
+
placeholder: "Search options",
|
|
23
|
+
value: t.value,
|
|
24
|
+
onChange: (e) => a({ value: e.target.value }),
|
|
25
|
+
className: "border-none outline-none bg-surface-neutral-default text-text-neutral-primary rounded p-3 pl-10 text-sm w-full"
|
|
26
|
+
}
|
|
27
|
+
),
|
|
28
|
+
t.value && /* @__PURE__ */ l("span", { className: "absolute right-3 top-3.5", onClick: i, children: /* @__PURE__ */ l(u, {}) })
|
|
29
|
+
] }),
|
|
30
|
+
/* @__PURE__ */ r("div", { className: "flex flex-col gap-2 p-3", children: [
|
|
31
|
+
/* @__PURE__ */ l(
|
|
32
|
+
"select",
|
|
33
|
+
{
|
|
34
|
+
value: t.condition,
|
|
35
|
+
onChange: (e) => a({ condition: e.target.value }),
|
|
36
|
+
className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary rounded px-2 py-1 text-sm",
|
|
37
|
+
children: o.map((e) => /* @__PURE__ */ l("option", { value: e.value, children: e.label }, e.value))
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
t.value && /* @__PURE__ */ r("div", { className: "text-text-neutral-primary text-sm text-center", children: [
|
|
41
|
+
(n = o.find((e) => e.value === t.condition)) == null ? void 0 : n.label,
|
|
42
|
+
":",
|
|
43
|
+
" ",
|
|
44
|
+
t.value
|
|
45
|
+
] })
|
|
46
|
+
] })
|
|
47
|
+
] });
|
|
48
|
+
};
|
|
26
49
|
export {
|
|
27
|
-
|
|
50
|
+
f as default
|
|
28
51
|
};
|
|
@@ -3,9 +3,12 @@ import { TableFilterProps } from './table-filter.type';
|
|
|
3
3
|
import { FilterRule } from '../../table.type';
|
|
4
4
|
declare const useTableFilter: ({ filter, schema }: TableFilterProps) => {
|
|
5
5
|
isOpen: boolean;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
selectedColumn: string | null;
|
|
7
|
+
setSelectedColumn: React.Dispatch<React.SetStateAction<string | null>>;
|
|
8
|
+
getFilterForColumn: (columnKey: string) => FilterRule | undefined;
|
|
9
|
+
hasFilterForColumn: (columnKey: string) => boolean;
|
|
10
|
+
updateColumnFilter: (columnKey: string, condition?: string, value?: string | string[]) => void;
|
|
11
|
+
clearAllFilters: () => void;
|
|
9
12
|
applyFilters: () => void;
|
|
10
13
|
hasActiveFilters: boolean;
|
|
11
14
|
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -1,34 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
const [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import a from "react";
|
|
2
|
+
const b = ({ filter: s, schema: p }) => {
|
|
3
|
+
const [m, o] = a.useState(!1), [i, c] = a.useState(null), [l, n] = a.useState(s.value), u = p.filter((t) => t.filterable !== !1);
|
|
4
|
+
a.useEffect(() => {
|
|
5
|
+
!i && u.length > 0 && c(u[0].key);
|
|
6
|
+
}, [i, u]);
|
|
7
|
+
const d = (t) => l.find((e) => e.field === t), g = (t) => {
|
|
8
|
+
const e = d(t);
|
|
9
|
+
return e ? Array.isArray(e.value) ? e.value.length > 0 : e.value !== "" : !1;
|
|
10
|
+
}, h = (t, e, f) => {
|
|
11
|
+
const F = l.findIndex((r) => r.field === t);
|
|
12
|
+
if (F >= 0) {
|
|
13
|
+
const r = l.map(
|
|
14
|
+
(v, x) => x === F ? {
|
|
15
|
+
...v,
|
|
16
|
+
...e !== void 0 ? { condition: e } : {},
|
|
17
|
+
...f !== void 0 ? { value: f } : {}
|
|
18
|
+
} : v
|
|
19
|
+
);
|
|
20
|
+
n(r);
|
|
21
|
+
} else {
|
|
22
|
+
const r = {
|
|
23
|
+
field: t,
|
|
24
|
+
...e ? { condition: e } : {},
|
|
25
|
+
value: f || ""
|
|
26
|
+
};
|
|
27
|
+
n([...l, r]);
|
|
28
|
+
}
|
|
29
|
+
}, A = () => {
|
|
30
|
+
n([]);
|
|
31
|
+
}, C = () => {
|
|
32
|
+
const t = l.filter((e) => Array.isArray(e.value) ? e.value.length > 0 : e.value !== "");
|
|
33
|
+
s.onChange(t), o(!1);
|
|
34
|
+
}, y = s.value.length > 0;
|
|
35
|
+
return a.useEffect(() => {
|
|
36
|
+
n(s.value);
|
|
37
|
+
}, [s.value]), {
|
|
38
|
+
isOpen: m,
|
|
39
|
+
selectedColumn: i,
|
|
40
|
+
setSelectedColumn: c,
|
|
41
|
+
getFilterForColumn: d,
|
|
42
|
+
hasFilterForColumn: g,
|
|
43
|
+
updateColumnFilter: h,
|
|
44
|
+
clearAllFilters: A,
|
|
45
|
+
applyFilters: C,
|
|
46
|
+
hasActiveFilters: y,
|
|
27
47
|
setIsOpen: o,
|
|
28
|
-
tempFilters:
|
|
29
|
-
filterableFields:
|
|
48
|
+
tempFilters: l,
|
|
49
|
+
filterableFields: u
|
|
30
50
|
};
|
|
31
51
|
};
|
|
32
52
|
export {
|
|
33
|
-
|
|
53
|
+
b as default
|
|
34
54
|
};
|