@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,105 +1,119 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as t, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { Button as s } from "../../../button/button.js";
|
|
3
|
-
import
|
|
3
|
+
import C from "./table-filter.hook.js";
|
|
4
4
|
import T from "./filters/text.js";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
import j from "./filters/boolean.js";
|
|
6
|
+
import z from "./filters/number/number.js";
|
|
7
|
+
import A from "./filters/checkbox.js";
|
|
8
|
+
import O from "../../../assets/icons/circle-check-filled.js";
|
|
9
|
+
const E = ({
|
|
10
|
+
filterComponents: n = {},
|
|
11
|
+
schema: d,
|
|
12
|
+
filter: o
|
|
11
13
|
}) => {
|
|
12
14
|
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
selectedColumn: r,
|
|
16
|
+
setSelectedColumn: p,
|
|
17
|
+
getFilterForColumn: x,
|
|
18
|
+
hasFilterForColumn: b,
|
|
19
|
+
updateColumnFilter: f,
|
|
20
|
+
clearAllFilters: v,
|
|
21
|
+
applyFilters: k,
|
|
22
|
+
hasActiveFilters: i,
|
|
17
23
|
isOpen: m,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
updateFilterRule: u
|
|
22
|
-
} = N({ schema: c, filter: n || { value: [], onChange: () => {
|
|
24
|
+
setIsOpen: u,
|
|
25
|
+
filterableFields: y
|
|
26
|
+
} = C({ schema: d, filter: o || { value: [], onChange: () => {
|
|
23
27
|
} } });
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
if (!o)
|
|
29
|
+
return null;
|
|
30
|
+
const N = () => {
|
|
31
|
+
if (!r) return null;
|
|
32
|
+
const e = d.find((c) => c.key === r), F = {
|
|
33
|
+
boolean: j,
|
|
34
|
+
text: T,
|
|
35
|
+
number: z,
|
|
36
|
+
checkbox: A
|
|
37
|
+
}, h = (n == null ? void 0 : n[(e == null ? void 0 : e.cellType) || ""]) || F[(e == null ? void 0 : e.cellType) || "text"];
|
|
38
|
+
if (!h)
|
|
39
|
+
return console.warn(
|
|
40
|
+
`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".`
|
|
41
|
+
), null;
|
|
42
|
+
const a = x(r), g = {
|
|
43
|
+
condition: (a == null ? void 0 : a.condition) || "",
|
|
44
|
+
value: (a == null ? void 0 : a.value) || ""
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ l("div", { className: "flex-1", children: /* @__PURE__ */ l("div", { className: "mb-4", children: /* @__PURE__ */ l("div", { className: "", children: /* @__PURE__ */ l(
|
|
47
|
+
h,
|
|
48
|
+
{
|
|
49
|
+
value: g,
|
|
50
|
+
onChange: ({ condition: c, value: w }) => f(r, c, w),
|
|
51
|
+
filterOptions: e == null ? void 0 : e.filterOptions
|
|
52
|
+
}
|
|
53
|
+
) }) }) });
|
|
54
|
+
};
|
|
55
|
+
return /* @__PURE__ */ t("div", { className: "relative", children: [
|
|
56
|
+
/* @__PURE__ */ t(
|
|
26
57
|
s,
|
|
27
58
|
{
|
|
28
|
-
onClick: () =>
|
|
29
|
-
variant:
|
|
30
|
-
shade:
|
|
59
|
+
onClick: () => u(!m),
|
|
60
|
+
variant: i ? "filled" : "stroke",
|
|
61
|
+
shade: i ? "brand" : "neutral",
|
|
31
62
|
size: "small",
|
|
32
63
|
children: [
|
|
33
64
|
"Filter ",
|
|
34
|
-
|
|
65
|
+
i && `(${o.value.length})`
|
|
35
66
|
]
|
|
36
67
|
}
|
|
37
68
|
),
|
|
38
|
-
m && /* @__PURE__ */ t("div", { className: "absolute top-full left-0 mt-2 min-w-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, v = (o == null ? void 0 : o[(e == null ? void 0 : e.cellType) || ""]) || h[(e == null ? void 0 : e.cellType) || "text"];
|
|
45
|
-
v || console.warn(
|
|
46
|
-
`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".`
|
|
47
|
-
);
|
|
48
|
-
const g = v ?? h.text;
|
|
49
|
-
return /* @__PURE__ */ r("div", { className: "flex gap-2 items-center", children: [
|
|
50
|
-
/* @__PURE__ */ t(
|
|
51
|
-
"select",
|
|
52
|
-
{
|
|
53
|
-
value: i.field,
|
|
54
|
-
onChange: (l) => u(a, { field: l.target.value, condition: void 0 }),
|
|
55
|
-
className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary rounded px-2 py-1 text-sm flex-1",
|
|
56
|
-
children: k.map((l) => /* @__PURE__ */ t("option", { value: l.key, children: l.title }, l.key))
|
|
57
|
-
}
|
|
58
|
-
),
|
|
59
|
-
/* @__PURE__ */ t(
|
|
60
|
-
g,
|
|
69
|
+
m && /* @__PURE__ */ t("div", { className: "absolute top-full left-0 mt-2 min-w-[600px] bg-surface-neutral-default border border-stroke-solid-medium rounded-md shadow-default z-10", children: [
|
|
70
|
+
/* @__PURE__ */ t("div", { className: "flex min-h-[300px]", children: [
|
|
71
|
+
/* @__PURE__ */ t("div", { className: "w-48 border-r border-stroke-solid-medium", children: [
|
|
72
|
+
/* @__PURE__ */ l("div", { className: "p-3 border-b border-stroke-solid-medium", children: /* @__PURE__ */ l("h3", { className: "text-sm font-medium text-text-neutral-primary", children: "Columns" }) }),
|
|
73
|
+
/* @__PURE__ */ l("div", { className: "py-2", children: y.map((e) => /* @__PURE__ */ t(
|
|
74
|
+
"button",
|
|
61
75
|
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
value: { value: i.value, condition: i.condition }
|
|
76
|
+
onClick: () => p(e.key),
|
|
77
|
+
className: `w-full text-left px-3 py-2 text-sm flex items-center justify-between hover:bg-surface-neutral-hovered transition-colors ${r === e.key ? "bg-surface-brand-subtle text-text-brand-primary" : "text-text-neutral-primary"}`,
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ l("span", { className: "truncate", children: e.title }),
|
|
80
|
+
b(e.key) && /* @__PURE__ */ l(O, { className: "w-4 h-4 text-icon-brand-primary flex-shrink-0 ml-2" })
|
|
81
|
+
]
|
|
69
82
|
},
|
|
70
|
-
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
shade: "danger",
|
|
78
|
-
size: "small",
|
|
79
|
-
className: "!px-2 !py-1",
|
|
80
|
-
children: "×"
|
|
81
|
-
}
|
|
82
|
-
)
|
|
83
|
-
] }, a);
|
|
84
|
-
}),
|
|
85
|
-
/* @__PURE__ */ r("div", { className: "flex gap-2", children: [
|
|
86
|
-
/* @__PURE__ */ t(s, { onClick: b, variant: "stroke", shade: "neutral", size: "small", children: "+ Add" }),
|
|
87
|
-
/* @__PURE__ */ t("div", { className: "flex-1" }),
|
|
88
|
-
/* @__PURE__ */ t(
|
|
83
|
+
e.key
|
|
84
|
+
)) })
|
|
85
|
+
] }),
|
|
86
|
+
/* @__PURE__ */ l("div", { className: "flex-1 flex flex-col", children: r ? N() : /* @__PURE__ */ l("div", { className: "flex-1 flex items-center justify-center text-text-neutral-muted", children: "Select a column to configure its filter" }) })
|
|
87
|
+
] }),
|
|
88
|
+
/* @__PURE__ */ t("div", { className: "flex justify-between items-center p-4 border-t border-stroke-solid-medium", children: [
|
|
89
|
+
/* @__PURE__ */ l(
|
|
89
90
|
s,
|
|
90
91
|
{
|
|
91
|
-
onClick:
|
|
92
|
-
variant: "
|
|
92
|
+
onClick: v,
|
|
93
|
+
variant: "ghost",
|
|
93
94
|
shade: "neutral",
|
|
94
95
|
size: "small",
|
|
95
|
-
|
|
96
|
+
disabled: !i,
|
|
97
|
+
children: "Clear All"
|
|
96
98
|
}
|
|
97
99
|
),
|
|
98
|
-
/* @__PURE__ */ t(
|
|
100
|
+
/* @__PURE__ */ t("div", { className: "flex gap-2", children: [
|
|
101
|
+
/* @__PURE__ */ l(
|
|
102
|
+
s,
|
|
103
|
+
{
|
|
104
|
+
onClick: () => u(!1),
|
|
105
|
+
variant: "stroke",
|
|
106
|
+
shade: "neutral",
|
|
107
|
+
size: "small",
|
|
108
|
+
children: "Cancel"
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ l(s, { onClick: k, variant: "filled", shade: "neutral", size: "small", children: "Apply" })
|
|
112
|
+
] })
|
|
99
113
|
] })
|
|
100
|
-
] })
|
|
101
|
-
] })
|
|
114
|
+
] })
|
|
115
|
+
] });
|
|
102
116
|
};
|
|
103
117
|
export {
|
|
104
|
-
|
|
118
|
+
E as TableFilter
|
|
105
119
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { TableFilter, TableSchema } from '../../table.type';
|
|
2
|
+
import { TableFilter, TableSchema, FilterOption } from '../../table.type';
|
|
3
3
|
export interface TableFilterProps {
|
|
4
4
|
schema: TableSchema;
|
|
5
5
|
filter: TableFilter;
|
|
@@ -8,11 +8,12 @@ export interface TableFilterProps {
|
|
|
8
8
|
export type FilterComponentProps = {
|
|
9
9
|
onChange: (input: {
|
|
10
10
|
condition?: string;
|
|
11
|
-
value?: string;
|
|
11
|
+
value?: string | string[];
|
|
12
12
|
}) => void;
|
|
13
13
|
value: {
|
|
14
14
|
condition?: string;
|
|
15
|
-
value: string;
|
|
15
|
+
value: string | string[];
|
|
16
16
|
};
|
|
17
|
+
filterOptions?: FilterOption[];
|
|
17
18
|
};
|
|
18
19
|
export type FilterComponentType = FC<FilterComponentProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Table as default, Table, TableProvider } from './table-provider';
|
|
2
2
|
export { TableBody } from './table';
|
|
3
|
-
export type { TableProps, TableSchema, TableSchemaColumn, CellType, CellValue, CellRenderer, CellRendererProps, FilterRule, FilterCondition, TableFilter as TableFilterType, TablePaginationConfig, SortDirection, SortColumn, TableSort, } from './table.type';
|
|
3
|
+
export type { TableProps, TableSchema, TableSchemaColumn, CellType, CellValue, CellRenderer, CellRendererProps, FilterRule, FilterCondition, FilterOption, TableFilter as TableFilterType, TablePaginationConfig, SortDirection, SortColumn, TableSort, } from './table.type';
|
|
4
4
|
export { getNestedValue, extractCellValue } from './table.utils';
|
|
5
5
|
export { DEFAULT_EMPTY_MESSAGE, TABLE_CSS_CLASSES } from './table.const';
|
|
6
6
|
export { TableContext, useTableContext } from './table.context';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { FilterComponentType } from './components/table-filter/table-filter.type';
|
|
3
|
-
export type CellType = 'text' | 'number' | 'boolean';
|
|
3
|
+
export type CellType = 'text' | 'number' | 'boolean' | 'checkbox';
|
|
4
4
|
export type CellValue = string | number | boolean | null | undefined;
|
|
5
5
|
export type CellRendererProps = {
|
|
6
6
|
value: CellValue;
|
|
@@ -12,6 +12,10 @@ export type FilterCondition = 'contains' | 'notEqual' | 'equal' | '>' | '<' | '=
|
|
|
12
12
|
export type FilterRule = {
|
|
13
13
|
field: string;
|
|
14
14
|
condition?: string;
|
|
15
|
+
value: string | string[];
|
|
16
|
+
};
|
|
17
|
+
export type FilterOption = {
|
|
18
|
+
label: string;
|
|
15
19
|
value: string;
|
|
16
20
|
};
|
|
17
21
|
export type TableFilter = {
|
|
@@ -49,6 +53,7 @@ export type TableSchemaColumn = {
|
|
|
49
53
|
filterable?: boolean;
|
|
50
54
|
hideable?: boolean;
|
|
51
55
|
sortable?: boolean;
|
|
56
|
+
filterOptions?: FilterOption[];
|
|
52
57
|
};
|
|
53
58
|
export type TableSchema = TableSchemaColumn[];
|
|
54
59
|
export type TableProps = {
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as a, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { Table as e } from "../table/table-provider.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import { cn as c } from "../../lib/utils.js";
|
|
5
|
+
import "../table/table.context.js";
|
|
6
|
+
import "../button/button.js";
|
|
7
|
+
import "../input/input.js";
|
|
8
|
+
const J = ({
|
|
9
|
+
dataSource: g,
|
|
10
|
+
schema: h,
|
|
11
|
+
className: C,
|
|
12
|
+
showHeader: b = !0,
|
|
13
|
+
headerClassName: x,
|
|
14
|
+
search: m,
|
|
15
|
+
filter: f,
|
|
16
|
+
body: k = {
|
|
17
|
+
cell: { cellHeight: "small", hasBorder: !0 },
|
|
18
|
+
className: "",
|
|
19
|
+
stickyHeader: !0
|
|
20
|
+
},
|
|
21
|
+
showFooter: N = !0,
|
|
22
|
+
footerClassName: v,
|
|
23
|
+
paginationInfo: u,
|
|
24
|
+
paginationQuickJumper: P,
|
|
25
|
+
pagination: p,
|
|
26
|
+
overrides: n = {},
|
|
27
|
+
...y
|
|
28
|
+
}) => {
|
|
29
|
+
const r = m ? { ...m, ...n.search } : void 0, d = f ? { ...f, ...n.filter } : void 0, i = { ...k, ...n.body }, o = u ? { ...u, ...n.paginationInfo } : void 0, t = P ? { ...P, ...n.paginationQuickJumper } : void 0, l = p ? { ...p, ...n.pagination } : void 0;
|
|
30
|
+
return /* @__PURE__ */ a("div", { className: c("flex flex-col overflow-hidden", C), children: /* @__PURE__ */ s(e, { dataSource: g, schema: h, ...y, children: [
|
|
31
|
+
b && /* @__PURE__ */ a(e.Header, { className: c("flex-shrink-0", x), children: /* @__PURE__ */ s(e.HeaderContent, { children: [
|
|
32
|
+
r && /* @__PURE__ */ a(
|
|
33
|
+
e.Search,
|
|
34
|
+
{
|
|
35
|
+
search: {
|
|
36
|
+
value: r.value || "",
|
|
37
|
+
onChange: r.onChange || (() => {
|
|
38
|
+
}),
|
|
39
|
+
placeholder: r.placeholder
|
|
40
|
+
},
|
|
41
|
+
className: r.className
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
d && /* @__PURE__ */ a(
|
|
45
|
+
e.Filter,
|
|
46
|
+
{
|
|
47
|
+
schema: h,
|
|
48
|
+
filter: {
|
|
49
|
+
value: d.value || [],
|
|
50
|
+
onChange: d.onChange || (() => {
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
] }) }),
|
|
56
|
+
/* @__PURE__ */ a(
|
|
57
|
+
e.Body,
|
|
58
|
+
{
|
|
59
|
+
cell: i.cell,
|
|
60
|
+
sort: i.sort,
|
|
61
|
+
className: c(
|
|
62
|
+
"flex-1 min-h-0",
|
|
63
|
+
g.length < 1 && "border-stroke-solid-light border-b-1 border-x-1 border-t-0 rounded-b-xl",
|
|
64
|
+
i.className
|
|
65
|
+
),
|
|
66
|
+
stickyHeader: i.stickyHeader
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
N && (o || t || l) && /* @__PURE__ */ s(e.Footer, { className: c("flex-shrink-0", v), children: [
|
|
70
|
+
o && /* @__PURE__ */ a(e.FooterContent, { children: /* @__PURE__ */ a(
|
|
71
|
+
e.PaginationInfo,
|
|
72
|
+
{
|
|
73
|
+
showTotal: o.showTotal || !1,
|
|
74
|
+
totalItems: o.totalItems || 0,
|
|
75
|
+
currentPage: o.currentPage || 1,
|
|
76
|
+
itemsPerPage: o.itemsPerPage || 10
|
|
77
|
+
}
|
|
78
|
+
) }),
|
|
79
|
+
(t || l) && /* @__PURE__ */ s(e.FooterContent, { children: [
|
|
80
|
+
t && /* @__PURE__ */ a(
|
|
81
|
+
e.PaginationQuickJumper,
|
|
82
|
+
{
|
|
83
|
+
currentPage: t.currentPage || 1,
|
|
84
|
+
totalPage: t.totalPage || 1,
|
|
85
|
+
onChange: t.onChange || (() => {
|
|
86
|
+
}),
|
|
87
|
+
disabled: t.disabled || !1
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
l && /* @__PURE__ */ a(
|
|
91
|
+
e.Pagination,
|
|
92
|
+
{
|
|
93
|
+
currentPage: l.currentPage || 1,
|
|
94
|
+
totalPage: l.totalPage || 1,
|
|
95
|
+
onChange: l.onChange || (() => {
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
] })
|
|
100
|
+
] })
|
|
101
|
+
] }) });
|
|
102
|
+
};
|
|
103
|
+
export {
|
|
104
|
+
J as default
|
|
105
|
+
};
|