@ztwoint/z-ui 0.1.27 → 0.1.28
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/chevron-left.d.ts +7 -0
- package/dist/components/assets/icons/chevron-left.js +20 -0
- package/dist/components/assets/icons/chevron-right.js +30 -0
- package/dist/components/assets/icons/double-chevron-left.d.ts +7 -0
- package/dist/components/assets/icons/double-chevron-left.js +24 -0
- package/dist/components/assets/icons/double-chevron-right.d.ts +7 -0
- package/dist/components/assets/icons/double-chevron-right.js +24 -0
- package/dist/components/assets/icons/info-icon.js +16 -0
- package/dist/components/assets/icons/magnifier-icon.js +16 -0
- package/dist/components/assets/icons/sub-nav-indicator.d.ts +3 -2
- package/dist/components/assets/icons/sub-nav-indicator.js +26 -41
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +45 -30
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-content.js +16 -16
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-footer.js +1 -1
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-group.js +24 -16
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-header.js +60 -54
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-item.js +61 -62
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-provider.js +23 -23
- package/dist/components/collapsible-side-nav-bar/side-nav-bar.d.ts +1 -1
- package/dist/components/collapsible-side-nav-bar/side-nav-bar.js +14 -14
- package/dist/components/dialog/dialog.js +1 -1
- package/dist/components/dropdown-menu/z2-dropdown-menu.js +255 -0
- package/dist/components/nav-header/nav-header.js +7 -7
- package/dist/components/table/components/cell/boolean-cell.d.ts +7 -0
- package/dist/components/table/components/cell/boolean-cell.js +7 -0
- package/dist/components/table/components/cell/index.d.ts +3 -0
- package/dist/components/table/components/cell/number-cell.d.ts +7 -0
- package/dist/components/table/components/cell/number-cell.js +5 -0
- package/dist/components/table/components/cell/text-cell.d.ts +7 -0
- package/dist/components/table/components/cell/text-cell.js +5 -0
- package/dist/components/table/components/index.d.ts +11 -0
- package/dist/components/table/components/pagination/components/index.d.ts +3 -0
- package/dist/components/table/components/pagination/components/pagination-info.d.ts +4 -0
- package/dist/components/table/components/pagination/components/pagination-info.js +27 -0
- package/dist/components/table/components/pagination/components/pagination-quick-jumper.d.ts +4 -0
- package/dist/components/table/components/pagination/components/pagination-quick-jumper.hook.d.ts +6 -0
- package/dist/components/table/components/pagination/components/pagination-quick-jumper.hook.js +24 -0
- package/dist/components/table/components/pagination/components/pagination-quick-jumper.js +35 -0
- package/dist/components/table/components/pagination/index.d.ts +6 -0
- package/dist/components/table/components/pagination/pagination.const.d.ts +26 -0
- package/dist/components/table/components/pagination/pagination.const.js +22 -0
- package/dist/components/table/components/pagination/pagination.d.ts +4 -0
- package/dist/components/table/components/pagination/pagination.hook.d.ts +5 -0
- package/dist/components/table/components/pagination/pagination.hook.js +22 -0
- package/dist/components/table/components/pagination/pagination.js +112 -0
- package/dist/components/table/components/pagination/pagination.type.d.ts +33 -0
- package/dist/components/table/components/pagination/pagination.utils.d.ts +7 -0
- package/dist/components/table/components/pagination/pagination.utils.js +35 -0
- package/dist/components/table/components/table-cell.d.ts +15 -0
- package/dist/components/table/components/table-cell.js +45 -0
- package/dist/components/table/components/table-empty-state.d.ts +7 -0
- package/dist/components/table/components/table-empty-state.js +6 -0
- package/dist/components/table/components/table-filter/filters/boolean.d.ts +3 -0
- package/dist/components/table/components/table-filter/filters/boolean.js +31 -0
- package/dist/components/table/components/table-filter/filters/index.d.ts +3 -0
- package/dist/components/table/components/table-filter/filters/number.d.ts +3 -0
- package/dist/components/table/components/table-filter/filters/number.js +28 -0
- package/dist/components/table/components/table-filter/filters/text.d.ts +3 -0
- package/dist/components/table/components/table-filter/filters/text.js +28 -0
- package/dist/components/table/components/table-filter/index.d.ts +1 -0
- package/dist/components/table/components/table-filter/table-filter.d.ts +9 -0
- package/dist/components/table/components/table-filter/table-filter.hook.d.ts +15 -0
- package/dist/components/table/components/table-filter/table-filter.hook.js +34 -0
- package/dist/components/table/components/table-filter/table-filter.js +105 -0
- package/dist/components/table/components/table-filter/table-filter.type.d.ts +18 -0
- package/dist/components/table/components/table-footer-content.d.ts +7 -0
- package/dist/components/table/components/table-footer-content.js +9 -0
- package/dist/components/table/components/table-footer.d.ts +7 -0
- package/dist/components/table/components/table-footer.js +6 -0
- package/dist/components/table/components/table-header/index.d.ts +2 -0
- package/dist/components/table/components/table-header/table-header.d.ts +9 -0
- package/dist/components/table/components/table-header/table-header.js +27 -0
- package/dist/components/table/components/table-header/table-header.utils.d.ts +5 -0
- package/dist/components/table/components/table-header/table-header.utils.js +15 -0
- package/dist/components/table/components/table-header/table-sort-icon.d.ts +8 -0
- package/dist/components/table/components/table-header/table-sort-icon.js +13 -0
- package/dist/components/table/components/table-header-content.d.ts +7 -0
- package/dist/components/table/components/table-header-content.js +9 -0
- package/dist/components/table/components/table-header-wrapper.d.ts +7 -0
- package/dist/components/table/components/table-header-wrapper.js +9 -0
- package/dist/components/table/components/table-loading-state.d.ts +7 -0
- package/dist/components/table/components/table-loading-state.js +9 -0
- package/dist/components/table/components/table-row.d.ts +11 -0
- package/dist/components/table/components/table-row.js +23 -0
- package/dist/components/table/index.d.ts +9 -0
- package/dist/components/table/table-provider.d.ts +26 -0
- package/dist/components/table/table-provider.js +45 -0
- package/dist/components/table/table.const.d.ts +24 -0
- package/dist/components/table/table.const.js +27 -0
- package/dist/components/table/table.context.d.ts +7 -0
- package/dist/components/table/table.context.js +11 -0
- package/dist/components/table/table.d.ts +4 -0
- package/dist/components/table/table.js +39 -0
- package/dist/components/table/table.type.d.ts +63 -0
- package/dist/components/table/table.utils.d.ts +3 -0
- package/dist/components/table/table.utils.js +5 -0
- package/dist/css/config/colors/components/select.css +1 -1
- package/dist/css/config/colors/defaults.css +378 -137
- package/dist/css/config/colors/semantic-colors.css +356 -0
- package/dist/css/config/components/button.css +152 -0
- package/dist/css/config/components/index.css +1 -0
- package/dist/css/config/config-deprecated.css +41 -0
- package/dist/css/config/config.css +4 -18
- package/dist/css/config/typography/2xl.css +7 -0
- package/dist/css/config/typography/3xl.css +7 -0
- package/dist/css/config/typography/4xl.css +7 -0
- package/dist/css/config/typography/base.css +7 -0
- package/dist/css/config/typography/lg.css +7 -0
- package/dist/css/config/typography/sm.css +7 -0
- package/dist/css/config/typography/xl.css +7 -0
- package/dist/css/config/typography/xs.css +7 -0
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/devComponents/navigation/index.d.ts +1 -0
- package/dist/devComponents/navigation/navigation.d.ts +1 -0
- package/dist/index.d.ts +41 -8
- package/dist/index.js +176 -102
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/theme.hook.d.ts +8 -0
- package/dist/lib/theme.hook.js +50 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/CheckCircleIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/XCircleIcon.js +26 -0
- package/dist/routes/default.d.ts +2 -0
- package/dist/routes/index.d.ts +2 -0
- package/dist/routes/table.d.ts +2 -0
- package/dist/sample/text-cell.d.ts +3 -0
- package/dist/types/components/assets/icons/chevron-left.d.ts +7 -0
- package/dist/types/components/assets/icons/double-chevron-left.d.ts +7 -0
- package/dist/types/components/assets/icons/double-chevron-right.d.ts +7 -0
- package/dist/types/components/assets/icons/sub-nav-indicator.d.ts +3 -2
- package/dist/types/components/button/button.d.ts +1 -1
- package/dist/types/components/collapsible-side-nav-bar/side-nav-bar.d.ts +1 -1
- package/dist/types/components/table/components/cell/boolean-cell.d.ts +7 -0
- package/dist/types/components/table/components/cell/index.d.ts +3 -0
- package/dist/types/components/table/components/cell/number-cell.d.ts +7 -0
- package/dist/types/components/table/components/cell/text-cell.d.ts +7 -0
- package/dist/types/components/table/components/index.d.ts +11 -0
- package/dist/types/components/table/components/pagination/components/index.d.ts +3 -0
- package/dist/types/components/table/components/pagination/components/pagination-info.d.ts +4 -0
- package/dist/types/components/table/components/pagination/components/pagination-quick-jumper.d.ts +4 -0
- package/dist/types/components/table/components/pagination/components/pagination-quick-jumper.hook.d.ts +6 -0
- package/dist/types/components/table/components/pagination/index.d.ts +6 -0
- package/dist/types/components/table/components/pagination/pagination.const.d.ts +26 -0
- package/dist/types/components/table/components/pagination/pagination.d.ts +4 -0
- package/dist/types/components/table/components/pagination/pagination.hook.d.ts +5 -0
- package/dist/types/components/table/components/pagination/pagination.type.d.ts +33 -0
- package/dist/types/components/table/components/pagination/pagination.utils.d.ts +7 -0
- package/dist/types/components/table/components/table-cell.d.ts +15 -0
- package/dist/types/components/table/components/table-empty-state.d.ts +7 -0
- package/dist/types/components/table/components/table-filter/filters/boolean.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/filters/index.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/filters/number.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/filters/text.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/index.d.ts +1 -0
- package/dist/types/components/table/components/table-filter/table-filter.d.ts +9 -0
- package/dist/types/components/table/components/table-filter/table-filter.hook.d.ts +15 -0
- package/dist/types/components/table/components/table-filter/table-filter.type.d.ts +18 -0
- package/dist/types/components/table/components/table-footer-content.d.ts +7 -0
- package/dist/types/components/table/components/table-footer.d.ts +7 -0
- package/dist/types/components/table/components/table-header/index.d.ts +2 -0
- package/dist/types/components/table/components/table-header/table-header.d.ts +10 -0
- package/dist/types/components/table/components/table-header/table-header.utils.d.ts +5 -0
- package/dist/types/components/table/components/table-header/table-sort-icon.d.ts +8 -0
- package/dist/types/components/table/components/table-header-content.d.ts +7 -0
- package/dist/types/components/table/components/table-header-wrapper.d.ts +7 -0
- package/dist/types/components/table/components/table-loading-state.d.ts +7 -0
- package/dist/types/components/table/components/table-row.d.ts +11 -0
- package/dist/types/components/table/index.d.ts +9 -0
- package/dist/types/components/table/table-provider.d.ts +26 -0
- package/dist/types/components/table/table.const.d.ts +24 -0
- package/dist/types/components/table/table.context.d.ts +7 -0
- package/dist/types/components/table/table.d.ts +4 -0
- package/dist/types/components/table/table.type.d.ts +63 -0
- package/dist/types/components/table/table.utils.d.ts +3 -0
- package/dist/types/devComponents/navigation/index.d.ts +1 -0
- package/dist/types/devComponents/navigation/navigation.d.ts +1 -0
- package/dist/types/index.d.ts +41 -8
- package/dist/types/lib/index.d.ts +3 -0
- package/dist/types/lib/theme.hook.d.ts +8 -0
- package/dist/types/routes/default.d.ts +2 -0
- package/dist/types/routes/index.d.ts +2 -0
- package/dist/types/routes/table.d.ts +2 -0
- package/dist/types/sample/text-cell.d.ts +3 -0
- package/package.json +3 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsxs as I, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { usePagination as S } from "./pagination.hook.js";
|
|
3
|
+
import { PAGINATION_LABELS as o, PAGINATION_DEFAULTS as x, PAGINATION_CSS_CLASSES as E } from "./pagination.const.js";
|
|
4
|
+
import { Button as d } from "../../../button/button.js";
|
|
5
|
+
import k from "../../../assets/icons/chevron-left.js";
|
|
6
|
+
import N from "../../../assets/icons/chevron-right.js";
|
|
7
|
+
import L from "../../../assets/icons/double-chevron-left.js";
|
|
8
|
+
import _ from "../../../assets/icons/double-chevron-right.js";
|
|
9
|
+
import "react";
|
|
10
|
+
import { cn as z } from "../../../../lib/utils.js";
|
|
11
|
+
const p = () => /* @__PURE__ */ s("span", { className: E.ellipsis, children: "..." }), V = ({
|
|
12
|
+
currentPage: i,
|
|
13
|
+
totalPage: r,
|
|
14
|
+
onChange: b,
|
|
15
|
+
disabled: t = !1
|
|
16
|
+
}) => {
|
|
17
|
+
const { visiblePages: m, hasEllipsisStart: v, hasEllipsisEnd: A } = S({
|
|
18
|
+
currentPage: i,
|
|
19
|
+
totalPage: r,
|
|
20
|
+
maxVisiblePages: x.MAX_VISIBLE_PAGES
|
|
21
|
+
});
|
|
22
|
+
if (r <= 1)
|
|
23
|
+
return null;
|
|
24
|
+
const f = i === 1, c = i === r, a = (e) => {
|
|
25
|
+
!t && e !== i && e >= 1 && e <= r && b(e);
|
|
26
|
+
}, C = () => {
|
|
27
|
+
const e = [];
|
|
28
|
+
let h = !1, u = !1;
|
|
29
|
+
return m.forEach((l, y) => {
|
|
30
|
+
v && l === m[1] && !h && (e.push(/* @__PURE__ */ s(p, {}, "ellipsis-start")), h = !0);
|
|
31
|
+
const n = l === i;
|
|
32
|
+
e.push(
|
|
33
|
+
/* @__PURE__ */ s(
|
|
34
|
+
d,
|
|
35
|
+
{
|
|
36
|
+
onClick: () => a(l),
|
|
37
|
+
variant: "stroke",
|
|
38
|
+
shade: n ? "brand" : "neutral",
|
|
39
|
+
size: "small",
|
|
40
|
+
"aria-label": `${o.page} ${l}`,
|
|
41
|
+
"aria-current": n ? "page" : void 0,
|
|
42
|
+
className: z(
|
|
43
|
+
"min-w-[29px] text-text-neutral-secondary",
|
|
44
|
+
n && "border border-button-primary-brand-surface-default"
|
|
45
|
+
),
|
|
46
|
+
style: {
|
|
47
|
+
borderStyle: n ? "solid" : "none",
|
|
48
|
+
boxShadow: n ? "none" : ""
|
|
49
|
+
},
|
|
50
|
+
children: l
|
|
51
|
+
},
|
|
52
|
+
l
|
|
53
|
+
)
|
|
54
|
+
), A && l === m[m.length - 2] && !u && (e.push(/* @__PURE__ */ s(p, {}, "ellipsis-end")), u = !0);
|
|
55
|
+
}), e;
|
|
56
|
+
};
|
|
57
|
+
return /* @__PURE__ */ I("div", { className: "flex gap-1", children: [
|
|
58
|
+
/* @__PURE__ */ s(
|
|
59
|
+
d,
|
|
60
|
+
{
|
|
61
|
+
"aria-label": o.first,
|
|
62
|
+
onClick: () => a(1),
|
|
63
|
+
disabled: t || f,
|
|
64
|
+
variant: "stroke",
|
|
65
|
+
shade: "neutral",
|
|
66
|
+
size: "small",
|
|
67
|
+
leftIcon: /* @__PURE__ */ s(L, {})
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ s(
|
|
71
|
+
d,
|
|
72
|
+
{
|
|
73
|
+
"aria-label": o.previous,
|
|
74
|
+
onClick: () => a(i - 1),
|
|
75
|
+
disabled: t || f,
|
|
76
|
+
variant: "stroke",
|
|
77
|
+
shade: "neutral",
|
|
78
|
+
size: "small",
|
|
79
|
+
leftIcon: /* @__PURE__ */ s(k, {})
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
C(),
|
|
83
|
+
/* @__PURE__ */ s(
|
|
84
|
+
d,
|
|
85
|
+
{
|
|
86
|
+
"aria-label": o.next,
|
|
87
|
+
onClick: () => a(i + 1),
|
|
88
|
+
disabled: t || c,
|
|
89
|
+
variant: "stroke",
|
|
90
|
+
shade: "neutral",
|
|
91
|
+
size: "small",
|
|
92
|
+
leftIcon: /* @__PURE__ */ s(N, {})
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
/* @__PURE__ */ s(
|
|
96
|
+
d,
|
|
97
|
+
{
|
|
98
|
+
"aria-label": o.last,
|
|
99
|
+
onClick: () => a(r),
|
|
100
|
+
disabled: t || c,
|
|
101
|
+
variant: "stroke",
|
|
102
|
+
shade: "neutral",
|
|
103
|
+
size: "small",
|
|
104
|
+
leftIcon: /* @__PURE__ */ s(_, {})
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
] });
|
|
108
|
+
};
|
|
109
|
+
export {
|
|
110
|
+
V as Pagination,
|
|
111
|
+
V as default
|
|
112
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface PaginationProps {
|
|
2
|
+
currentPage: number;
|
|
3
|
+
totalPage: number;
|
|
4
|
+
onChange: (page: number) => void;
|
|
5
|
+
itemsPerPage?: number;
|
|
6
|
+
totalItems?: number;
|
|
7
|
+
showPageSizeSelector?: boolean;
|
|
8
|
+
showQuickJumper?: boolean;
|
|
9
|
+
showTotal?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface PaginationHookProps {
|
|
13
|
+
currentPage: number;
|
|
14
|
+
totalPage: number;
|
|
15
|
+
maxVisiblePages?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface PaginationHookReturn {
|
|
18
|
+
visiblePages: number[];
|
|
19
|
+
hasEllipsisStart: boolean;
|
|
20
|
+
hasEllipsisEnd: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface PaginationInfoProps {
|
|
23
|
+
showTotal: boolean;
|
|
24
|
+
totalItems?: number;
|
|
25
|
+
currentPage: number;
|
|
26
|
+
itemsPerPage: number;
|
|
27
|
+
}
|
|
28
|
+
export interface PaginationQuickJumperProps {
|
|
29
|
+
disabled: boolean;
|
|
30
|
+
currentPage: number;
|
|
31
|
+
totalPage: number;
|
|
32
|
+
onChange: (page: number) => void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PaginationHookProps, PaginationHookReturn } from './pagination.type';
|
|
2
|
+
export declare const calculateVisiblePages: ({ currentPage, totalPage, maxVisiblePages, }: PaginationHookProps) => PaginationHookReturn;
|
|
3
|
+
export declare const calculateItemRange: (currentPage: number, itemsPerPage: number, totalItems: number) => {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const isValidPageNumber: (page: number, totalPage: number) => boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PAGINATION_DEFAULTS as p } from "./pagination.const.js";
|
|
2
|
+
const M = ({
|
|
3
|
+
currentPage: i,
|
|
4
|
+
totalPage: s,
|
|
5
|
+
maxVisiblePages: n = p.MAX_VISIBLE_PAGES
|
|
6
|
+
}) => {
|
|
7
|
+
if (s <= n)
|
|
8
|
+
return {
|
|
9
|
+
visiblePages: Array.from({ length: s }, (f, m) => m + 1),
|
|
10
|
+
hasEllipsisStart: !1,
|
|
11
|
+
hasEllipsisEnd: !1
|
|
12
|
+
};
|
|
13
|
+
const h = Math.floor((n - 3) / 2);
|
|
14
|
+
let r = Math.max(2, i - h), t = Math.min(s - 1, i + h);
|
|
15
|
+
i <= h + 2 && (t = Math.min(s - 1, n - 2), r = 2), i >= s - h - 1 && (r = Math.max(2, s - n + 3), t = s - 1);
|
|
16
|
+
const c = [];
|
|
17
|
+
s > 0 && c.push(1);
|
|
18
|
+
const l = r > 2;
|
|
19
|
+
for (let f = r; f <= t; f++)
|
|
20
|
+
f !== 1 && f !== s && c.push(f);
|
|
21
|
+
const E = t < s - 1;
|
|
22
|
+
return s > 1 && c.push(s), {
|
|
23
|
+
visiblePages: c,
|
|
24
|
+
hasEllipsisStart: l,
|
|
25
|
+
hasEllipsisEnd: E
|
|
26
|
+
};
|
|
27
|
+
}, d = (i, s, n) => {
|
|
28
|
+
const h = (i - 1) * s + 1, r = Math.min(i * s, n);
|
|
29
|
+
return { start: h, end: r };
|
|
30
|
+
}, A = (i, s) => i >= 1 && i <= s && Number.isInteger(i);
|
|
31
|
+
export {
|
|
32
|
+
d as calculateItemRange,
|
|
33
|
+
M as calculateVisiblePages,
|
|
34
|
+
A as isValidPageNumber
|
|
35
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CellValue, CellType, CellRenderer, TableProps } from '../table.type';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
interface TableCellProps {
|
|
4
|
+
value: CellValue;
|
|
5
|
+
cellType: CellType;
|
|
6
|
+
cellRenderer?: CellRenderer;
|
|
7
|
+
customCells?: Record<string, CellRenderer>;
|
|
8
|
+
record: Record<string, unknown>;
|
|
9
|
+
index: number;
|
|
10
|
+
align?: 'left' | 'center' | 'right';
|
|
11
|
+
width?: string | number;
|
|
12
|
+
cell: TableProps['cell'];
|
|
13
|
+
}
|
|
14
|
+
export declare const TableCell: React.FC<TableCellProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { TABLE_CSS_CLASSES as r } from "../table.const.js";
|
|
3
|
+
import { TextCell as p } from "./cell/text-cell.js";
|
|
4
|
+
import { NumberCell as h } from "./cell/number-cell.js";
|
|
5
|
+
import { BooleanCell as S } from "./cell/boolean-cell.js";
|
|
6
|
+
import "react";
|
|
7
|
+
import { cn as b } from "../../../lib/utils.js";
|
|
8
|
+
const E = ({
|
|
9
|
+
value: o,
|
|
10
|
+
cellType: m,
|
|
11
|
+
cellRenderer: n,
|
|
12
|
+
record: f,
|
|
13
|
+
index: i,
|
|
14
|
+
customCells: e,
|
|
15
|
+
cell: C
|
|
16
|
+
}) => {
|
|
17
|
+
const c = {
|
|
18
|
+
text: p,
|
|
19
|
+
number: h,
|
|
20
|
+
boolean: S
|
|
21
|
+
}, s = e == null ? void 0 : e[m];
|
|
22
|
+
let t;
|
|
23
|
+
if (n)
|
|
24
|
+
t = n({ value: o, record: f, index: i });
|
|
25
|
+
else if (s)
|
|
26
|
+
t = /* @__PURE__ */ l(s, { value: o, record: f, index: i });
|
|
27
|
+
else {
|
|
28
|
+
const a = c[m] ?? p;
|
|
29
|
+
t = /* @__PURE__ */ l(a, { value: o });
|
|
30
|
+
}
|
|
31
|
+
return /* @__PURE__ */ l(
|
|
32
|
+
"td",
|
|
33
|
+
{
|
|
34
|
+
className: b(
|
|
35
|
+
r.cell.default,
|
|
36
|
+
r.cell.cellHeight[C.cellHeight],
|
|
37
|
+
r.cell.hasBorder[C.hasBorder ? "true" : "false"]
|
|
38
|
+
),
|
|
39
|
+
children: t
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
E as TableCell
|
|
45
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { TABLE_CSS_CLASSES as m } from "../table.const.js";
|
|
3
|
+
const a = ({ colSpan: r, message: e }) => /* @__PURE__ */ t("tbody", { children: /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { colSpan: r, className: m.emptyState, children: e }) }) });
|
|
4
|
+
export {
|
|
5
|
+
a as TableEmptyState
|
|
6
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsxs as a, Fragment as n, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as u } from "react";
|
|
3
|
+
const o = ["equals", "notEqual"], s = ({ value: r, onChange: l }) => (u(() => {
|
|
4
|
+
r.condition || l({ condition: o[0] });
|
|
5
|
+
}, []), /* @__PURE__ */ a(n, { children: [
|
|
6
|
+
/* @__PURE__ */ t(
|
|
7
|
+
"select",
|
|
8
|
+
{
|
|
9
|
+
value: r.condition,
|
|
10
|
+
onChange: (e) => l({ condition: e.target.value }),
|
|
11
|
+
className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary rounded px-2 py-1 text-sm",
|
|
12
|
+
children: o.map((e) => /* @__PURE__ */ t("option", { value: e, children: e }, e))
|
|
13
|
+
}
|
|
14
|
+
),
|
|
15
|
+
/* @__PURE__ */ a(
|
|
16
|
+
"select",
|
|
17
|
+
{
|
|
18
|
+
value: r.value,
|
|
19
|
+
onChange: (e) => l({ value: e.target.value }),
|
|
20
|
+
className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary rounded px-2 py-1 text-sm flex-1",
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ t("option", { value: "", children: "Select value" }),
|
|
23
|
+
/* @__PURE__ */ t("option", { value: "true", children: "True" }),
|
|
24
|
+
/* @__PURE__ */ t("option", { value: "false", children: "False" })
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
] }));
|
|
29
|
+
export {
|
|
30
|
+
s as default
|
|
31
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsxs as o, Fragment as u, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as d } from "react";
|
|
3
|
+
const l = [">", "<", "=", "!="], s = ({ value: t, onChange: r }) => (d(() => {
|
|
4
|
+
t.condition || r({ condition: l[0] });
|
|
5
|
+
}, []), /* @__PURE__ */ o(u, { children: [
|
|
6
|
+
/* @__PURE__ */ a(
|
|
7
|
+
"select",
|
|
8
|
+
{
|
|
9
|
+
value: t.condition,
|
|
10
|
+
onChange: (e) => r({ condition: e.target.value }),
|
|
11
|
+
className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary rounded px-2 py-1 text-sm",
|
|
12
|
+
children: l.map((e) => /* @__PURE__ */ a("option", { value: e, children: e }, e))
|
|
13
|
+
}
|
|
14
|
+
),
|
|
15
|
+
/* @__PURE__ */ a(
|
|
16
|
+
"input",
|
|
17
|
+
{
|
|
18
|
+
type: "number",
|
|
19
|
+
value: t.value,
|
|
20
|
+
onChange: (e) => r({ value: e.target.value }),
|
|
21
|
+
placeholder: "Value",
|
|
22
|
+
className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary placeholder:text-text-neutral-muted rounded px-2 py-1 text-sm flex-1"
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
] }));
|
|
26
|
+
export {
|
|
27
|
+
s as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsxs as o, Fragment as u, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as n } from "react";
|
|
3
|
+
const l = ["contains", "notEqual", "equals"], i = ({ value: t, onChange: r }) => (n(() => {
|
|
4
|
+
t.condition || r({ condition: l[0] });
|
|
5
|
+
}, []), /* @__PURE__ */ o(u, { children: [
|
|
6
|
+
/* @__PURE__ */ a(
|
|
7
|
+
"select",
|
|
8
|
+
{
|
|
9
|
+
value: t.condition,
|
|
10
|
+
onChange: (e) => r({ condition: e.target.value }),
|
|
11
|
+
className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary rounded px-2 py-1 text-sm",
|
|
12
|
+
children: l.map((e) => /* @__PURE__ */ a("option", { value: e, children: e }, e))
|
|
13
|
+
}
|
|
14
|
+
),
|
|
15
|
+
/* @__PURE__ */ a(
|
|
16
|
+
"input",
|
|
17
|
+
{
|
|
18
|
+
type: "text",
|
|
19
|
+
value: t.value,
|
|
20
|
+
onChange: (e) => r({ value: e.target.value }),
|
|
21
|
+
placeholder: "Value",
|
|
22
|
+
className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary placeholder:text-text-neutral-muted rounded px-2 py-1 text-sm flex-1"
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
] }));
|
|
26
|
+
export {
|
|
27
|
+
i as default
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TableFilter } from './table-filter';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FilterComponentType } from './table-filter.type';
|
|
2
|
+
import { TableSchema, TableFilter as TableFilterType } from '../../table.type';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export interface TableFilterProps {
|
|
5
|
+
filterComponents?: Record<string, FilterComponentType>;
|
|
6
|
+
schema: TableSchema;
|
|
7
|
+
filter?: TableFilterType;
|
|
8
|
+
}
|
|
9
|
+
export declare const TableFilter: React.FC<TableFilterProps>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TableFilterProps } from './table-filter.type';
|
|
3
|
+
import { FilterRule } from '../../table.type';
|
|
4
|
+
declare const useTableFilter: ({ filter, schema }: TableFilterProps) => {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
addFilterRule: () => void;
|
|
7
|
+
updateFilterRule: (index: number, updates: Partial<FilterRule>) => void;
|
|
8
|
+
removeFilterRule: (index: number) => void;
|
|
9
|
+
applyFilters: () => void;
|
|
10
|
+
hasActiveFilters: boolean;
|
|
11
|
+
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
12
|
+
tempFilters: FilterRule[];
|
|
13
|
+
filterableFields: import('../../table.type').TableSchemaColumn[];
|
|
14
|
+
};
|
|
15
|
+
export default useTableFilter;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import u from "react";
|
|
2
|
+
const h = ({ filter: t, schema: r }) => {
|
|
3
|
+
const [p, o] = u.useState(!1), [s, a] = u.useState(t.value), c = r.filter((e) => e.filterable !== !1), d = () => {
|
|
4
|
+
var l;
|
|
5
|
+
const e = {
|
|
6
|
+
field: ((l = c[0]) == null ? void 0 : l.key) || "",
|
|
7
|
+
value: ""
|
|
8
|
+
};
|
|
9
|
+
a([...s, e]);
|
|
10
|
+
}, f = (e, l) => {
|
|
11
|
+
const n = s.map((i, R) => R === e ? { ...i, ...l } : i);
|
|
12
|
+
a(n);
|
|
13
|
+
}, F = (e) => {
|
|
14
|
+
a(s.filter((l, n) => n !== e));
|
|
15
|
+
}, v = () => {
|
|
16
|
+
t.onChange(s), o(!1);
|
|
17
|
+
}, m = t.value.length > 0;
|
|
18
|
+
return u.useEffect(() => {
|
|
19
|
+
a(t.value);
|
|
20
|
+
}, [t.value]), {
|
|
21
|
+
isOpen: p,
|
|
22
|
+
addFilterRule: d,
|
|
23
|
+
updateFilterRule: f,
|
|
24
|
+
removeFilterRule: F,
|
|
25
|
+
applyFilters: v,
|
|
26
|
+
hasActiveFilters: m,
|
|
27
|
+
setIsOpen: o,
|
|
28
|
+
tempFilters: s,
|
|
29
|
+
filterableFields: c
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
h as default
|
|
34
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { Button as s } from "../../../button/button.js";
|
|
3
|
+
import N from "./table-filter.hook.js";
|
|
4
|
+
import T from "./filters/text.js";
|
|
5
|
+
import z from "./filters/boolean.js";
|
|
6
|
+
import w from "./filters/number.js";
|
|
7
|
+
const C = ({
|
|
8
|
+
filterComponents: o = {},
|
|
9
|
+
schema: c,
|
|
10
|
+
filter: n
|
|
11
|
+
}) => {
|
|
12
|
+
const {
|
|
13
|
+
addFilterRule: b,
|
|
14
|
+
applyFilters: y,
|
|
15
|
+
filterableFields: k,
|
|
16
|
+
hasActiveFilters: d,
|
|
17
|
+
isOpen: m,
|
|
18
|
+
removeFilterRule: F,
|
|
19
|
+
setIsOpen: p,
|
|
20
|
+
tempFilters: x,
|
|
21
|
+
updateFilterRule: u
|
|
22
|
+
} = N({ schema: c, filter: n || { value: [], onChange: () => {
|
|
23
|
+
} } });
|
|
24
|
+
return n ? /* @__PURE__ */ r("div", { className: "relative mb-4", children: [
|
|
25
|
+
/* @__PURE__ */ r(
|
|
26
|
+
s,
|
|
27
|
+
{
|
|
28
|
+
onClick: () => p(!m),
|
|
29
|
+
variant: d ? "filled" : "stroke",
|
|
30
|
+
shade: d ? "brand" : "neutral",
|
|
31
|
+
size: "small",
|
|
32
|
+
children: [
|
|
33
|
+
"Filter ",
|
|
34
|
+
d && `(${n.value.length})`
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
m && /* @__PURE__ */ t("div", { className: "absolute top-full left-0 mt-2 min-w-96 bg-surface-neutral-default border border-stroke-solid-medium rounded-md shadow-default z-10 p-4", children: /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
39
|
+
x.map((i, a) => {
|
|
40
|
+
const e = c.find((l) => l.key === i.field), h = {
|
|
41
|
+
boolean: z,
|
|
42
|
+
text: T,
|
|
43
|
+
number: w
|
|
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,
|
|
61
|
+
{
|
|
62
|
+
onChange: ({ condition: l, value: f }) => {
|
|
63
|
+
u(a, {
|
|
64
|
+
...l ? { condition: l } : {},
|
|
65
|
+
...f ? { value: f } : {}
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
value: { value: i.value, condition: i.condition }
|
|
69
|
+
},
|
|
70
|
+
a
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ t(
|
|
73
|
+
s,
|
|
74
|
+
{
|
|
75
|
+
onClick: () => F(a),
|
|
76
|
+
variant: "ghost",
|
|
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(
|
|
89
|
+
s,
|
|
90
|
+
{
|
|
91
|
+
onClick: () => p(!1),
|
|
92
|
+
variant: "stroke",
|
|
93
|
+
shade: "neutral",
|
|
94
|
+
size: "small",
|
|
95
|
+
children: "Cancel"
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ t(s, { onClick: y, variant: "filled", shade: "brand", size: "small", children: "Apply" })
|
|
99
|
+
] })
|
|
100
|
+
] }) })
|
|
101
|
+
] }) : null;
|
|
102
|
+
};
|
|
103
|
+
export {
|
|
104
|
+
C as TableFilter
|
|
105
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { TableFilter, TableSchema } from '../../table.type';
|
|
3
|
+
export interface TableFilterProps {
|
|
4
|
+
schema: TableSchema;
|
|
5
|
+
filter: TableFilter;
|
|
6
|
+
filterComponents?: Record<string, FilterComponentType>;
|
|
7
|
+
}
|
|
8
|
+
export type FilterComponentProps = {
|
|
9
|
+
onChange: (input: {
|
|
10
|
+
condition?: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
}) => void;
|
|
13
|
+
value: {
|
|
14
|
+
condition?: string;
|
|
15
|
+
value: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type FilterComponentType = FC<FilterComponentProps>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TableSchemaColumn, TableSort, TableProps } from '../../table.type';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
interface TableHeaderProps {
|
|
4
|
+
schema: TableSchemaColumn[];
|
|
5
|
+
sort?: TableSort;
|
|
6
|
+
cell: TableProps['cell'];
|
|
7
|
+
}
|
|
8
|
+
export declare const TableHeader: React.FC<TableHeaderProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as r, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { TABLE_CSS_CLASSES as t } from "../../table.const.js";
|
|
3
|
+
import { TableSortIcon as c } from "./table-sort-icon.js";
|
|
4
|
+
import { getCurrentSortDirection as n, isSortActive as h, handleSortClick as p } from "./table-header.utils.js";
|
|
5
|
+
import "react";
|
|
6
|
+
import { cn as C } from "../../../../lib/utils.js";
|
|
7
|
+
const y = ({ schema: a, sort: i, cell: o }) => /* @__PURE__ */ r("thead", { className: t.header, children: /* @__PURE__ */ r("tr", { children: a.map((e) => {
|
|
8
|
+
const s = n(e.key, i), l = h(e.key, i);
|
|
9
|
+
return /* @__PURE__ */ r(
|
|
10
|
+
"th",
|
|
11
|
+
{
|
|
12
|
+
className: C(
|
|
13
|
+
e.sortable ? t.sortableHeaderCell : t.headerCell,
|
|
14
|
+
t.cell.hasBorder[o.hasBorder ? "true" : "false"]
|
|
15
|
+
),
|
|
16
|
+
onClick: e.sortable ? () => p(e.key, i) : void 0,
|
|
17
|
+
children: /* @__PURE__ */ d("div", { className: t.headerCellContent, children: [
|
|
18
|
+
/* @__PURE__ */ r("span", { children: e.title }),
|
|
19
|
+
e.sortable && /* @__PURE__ */ r(c, { direction: s, isActive: l })
|
|
20
|
+
] })
|
|
21
|
+
},
|
|
22
|
+
e.key
|
|
23
|
+
);
|
|
24
|
+
}) }) });
|
|
25
|
+
export {
|
|
26
|
+
y as TableHeader
|
|
27
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TableSort, SortDirection } from '../../table.type';
|
|
2
|
+
export declare const getCurrentSortDirection: (field: string, sort?: TableSort) => SortDirection;
|
|
3
|
+
export declare const getNextSortDirection: (currentDirection: SortDirection) => SortDirection;
|
|
4
|
+
export declare const isSortActive: (field: string, sort?: TableSort) => boolean;
|
|
5
|
+
export declare const handleSortClick: (field: string, sort?: TableSort) => void;
|