@ztwoint/z-ui 0.1.46 → 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/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/selected-filters-display/selected-filters-display.utils.js +16 -16
- package/dist/components/table/components/table-filter/table-filter-button.js +59 -49
- package/dist/components/table/components/table-filter/table-filter-column-button.js +42 -41
- 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 +1 -1
- package/dist/components/table/table-provider.js +37 -8
- 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 +36 -5
- package/dist/components/table/table.utils.d.ts +1 -1
- package/dist/components/table/table.utils.js +5 -3
- package/dist/components/table-card/table-card.js +116 -89
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/index.js +62 -64
- 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/table-cell.d.ts +1 -1
- package/dist/types/components/table/components/table-header/stories/basic-header.d.ts +1 -1
- package/dist/types/components/table/index.d.ts +1 -1
- package/dist/types/components/table/table.const.d.ts +10 -8
- package/dist/types/components/table/table.type.d.ts +36 -5
- package/dist/types/components/table/table.utils.d.ts +1 -1
- package/package.json +1 -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/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
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
const
|
|
2
|
-
if (!
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}, l = (
|
|
13
|
-
const t =
|
|
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
14
|
return {
|
|
15
15
|
field: e.field,
|
|
16
16
|
fieldTitle: (t == null ? void 0 : t.title) || e.field,
|
|
17
17
|
value: e.value,
|
|
18
18
|
condition: e.condition,
|
|
19
|
-
count:
|
|
19
|
+
count: r
|
|
20
20
|
};
|
|
21
|
-
}), c = (
|
|
21
|
+
}), c = (n) => n.reduce((u, e) => u + (e.count || 1), 0);
|
|
22
22
|
export {
|
|
23
23
|
c as calculateTotalCount,
|
|
24
24
|
l as createFilterDisplayItems,
|
|
25
|
-
|
|
25
|
+
o as getFilterCount
|
|
26
26
|
};
|
|
@@ -1,103 +1,113 @@
|
|
|
1
1
|
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
3
|
-
import { Button as
|
|
4
|
-
import { useTableFilterContext as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
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
9
|
import R from "../../../assets/icons/circle-check-filled.js";
|
|
10
10
|
import { SelectedFiltersDisplay as P } from "./selected-filters-display/selected-filters-display.js";
|
|
11
|
-
import { useClickOutside as
|
|
12
|
-
|
|
13
|
-
|
|
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), {
|
|
14
15
|
selectedColumn: r,
|
|
15
|
-
setSelectedColumn:
|
|
16
|
-
getFilterForColumn:
|
|
17
|
-
hasFilterForColumn:
|
|
18
|
-
updateColumnFilter:
|
|
19
|
-
clearAllFilters:
|
|
20
|
-
applyFilters:
|
|
16
|
+
setSelectedColumn: b,
|
|
17
|
+
getFilterForColumn: y,
|
|
18
|
+
hasFilterForColumn: v,
|
|
19
|
+
updateColumnFilter: F,
|
|
20
|
+
clearAllFilters: k,
|
|
21
|
+
applyFilters: N,
|
|
21
22
|
hasActiveFilters: i,
|
|
22
|
-
filterableFields:
|
|
23
|
-
tempFilters:
|
|
24
|
-
schema:
|
|
25
|
-
filter:
|
|
23
|
+
filterableFields: g,
|
|
24
|
+
tempFilters: u,
|
|
25
|
+
schema: a,
|
|
26
|
+
filter: C,
|
|
26
27
|
filterComponents: n = {}
|
|
27
|
-
} =
|
|
28
|
-
|
|
28
|
+
} = z();
|
|
29
|
+
V(p, () => o(!1));
|
|
29
30
|
const w = () => {
|
|
30
|
-
|
|
31
|
-
},
|
|
31
|
+
N(), o(!1);
|
|
32
|
+
}, T = q(u, a), f = E(T), j = () => {
|
|
32
33
|
if (!r) return null;
|
|
33
|
-
const e =
|
|
34
|
-
boolean:
|
|
35
|
-
text:
|
|
36
|
-
number:
|
|
37
|
-
checkbox:
|
|
38
|
-
},
|
|
39
|
-
if (!
|
|
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)
|
|
40
41
|
return console.warn(
|
|
41
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".`
|
|
42
43
|
), null;
|
|
43
|
-
const s =
|
|
44
|
+
const s = y(r), O = {
|
|
44
45
|
condition: (s == null ? void 0 : s.condition) || "",
|
|
45
46
|
value: (s == null ? void 0 : s.value) || ""
|
|
46
47
|
};
|
|
47
48
|
return /* @__PURE__ */ t("div", { className: "flex-1", children: /* @__PURE__ */ t("div", { className: "mb-4", children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ t(
|
|
48
|
-
|
|
49
|
+
h,
|
|
49
50
|
{
|
|
50
|
-
value:
|
|
51
|
-
onChange: ({ condition:
|
|
51
|
+
value: O,
|
|
52
|
+
onChange: ({ condition: c, value: $ }) => F(r, c, $),
|
|
52
53
|
filterOptions: e == null ? void 0 : e.filterOptions
|
|
53
54
|
}
|
|
54
55
|
) }) }) });
|
|
55
56
|
};
|
|
56
|
-
return /* @__PURE__ */ l("div", { className: "relative", ref:
|
|
57
|
+
return /* @__PURE__ */ l("div", { className: "relative", ref: p, children: [
|
|
57
58
|
/* @__PURE__ */ l(
|
|
58
|
-
|
|
59
|
+
d,
|
|
59
60
|
{
|
|
60
61
|
onClick: (e) => {
|
|
61
|
-
e.stopPropagation(), o(!
|
|
62
|
+
e.stopPropagation(), o(!m);
|
|
62
63
|
},
|
|
63
64
|
variant: i ? "filled" : "stroke",
|
|
64
65
|
shade: i ? "brand" : "neutral",
|
|
65
66
|
size: "small",
|
|
66
67
|
children: [
|
|
67
68
|
"Filter ",
|
|
68
|
-
i && `(${
|
|
69
|
+
i && `(${C.value.length})`
|
|
69
70
|
]
|
|
70
71
|
}
|
|
71
72
|
),
|
|
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: [
|
|
73
74
|
/* @__PURE__ */ l("div", { className: "flex min-h-[442px]", children: [
|
|
74
75
|
/* @__PURE__ */ l("div", { className: "w-48 border-r border-stroke-solid-light p-2 flex flex-col gap-1.5", children: [
|
|
75
76
|
/* @__PURE__ */ t("div", { className: "p-2 pb-1", children: /* @__PURE__ */ t("h3", { className: "leading-none-medium-sm text-text-neutral-secondary", children: "Filters" }) }),
|
|
76
|
-
|
|
77
|
+
g.map((e) => /* @__PURE__ */ l(
|
|
77
78
|
"button",
|
|
78
79
|
{
|
|
79
|
-
onClick: () =>
|
|
80
|
+
onClick: () => b(e.key),
|
|
80
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"}`,
|
|
81
82
|
children: [
|
|
82
83
|
/* @__PURE__ */ t("span", { className: "truncate", children: e.title }),
|
|
83
|
-
|
|
84
|
+
v(e.key) && /* @__PURE__ */ t(R, { className: "w-4 h-4 text-text-brand-secondary flex-shrink-0 ml-2" })
|
|
84
85
|
]
|
|
85
86
|
},
|
|
86
87
|
e.key
|
|
87
88
|
))
|
|
88
89
|
] }),
|
|
89
|
-
/* @__PURE__ */ t("div", { className: "flex-1 flex flex-col", children: r ?
|
|
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" }) })
|
|
90
91
|
] }),
|
|
91
|
-
/* @__PURE__ */ l("div", { className: "flex justify-between items-end p-4 border-t border-stroke-solid-medium", children: [
|
|
92
|
-
/* @__PURE__ */ t(P, { selectedFilters:
|
|
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 }),
|
|
93
94
|
/* @__PURE__ */ l("div", { className: "flex justify-end gap-2", children: [
|
|
94
|
-
/* @__PURE__ */ t(
|
|
95
|
-
/* @__PURE__ */ t(
|
|
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
|
+
)
|
|
96
106
|
] })
|
|
97
107
|
] })
|
|
98
108
|
] })
|
|
99
109
|
] });
|
|
100
110
|
};
|
|
101
111
|
export {
|
|
102
|
-
|
|
112
|
+
Z as TableFilterButton
|
|
103
113
|
};
|
|
@@ -1,78 +1,79 @@
|
|
|
1
1
|
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
3
|
-
import { Button as
|
|
4
|
-
import { useTableFilterContext as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
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
8
|
import z from "./filters/checkbox.js";
|
|
9
|
-
import
|
|
10
|
-
import { useClickOutside as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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));
|
|
14
15
|
const {
|
|
15
16
|
getFilterForColumn: b,
|
|
16
|
-
hasAppliedFilterForColumn:
|
|
17
|
-
updateColumnFilter:
|
|
18
|
-
applyFilters:
|
|
19
|
-
schema:
|
|
17
|
+
hasAppliedFilterForColumn: x,
|
|
18
|
+
updateColumnFilter: p,
|
|
19
|
+
applyFilters: f,
|
|
20
|
+
schema: F,
|
|
20
21
|
filterComponents: i = {}
|
|
21
|
-
} =
|
|
22
|
+
} = T(), e = F.find((c) => c.key === o);
|
|
22
23
|
if (!e)
|
|
23
|
-
return console.warn(`Column "${
|
|
24
|
+
return console.warn(`Column "${o}" not found in schema`), null;
|
|
24
25
|
if (e.filterable === !1)
|
|
25
|
-
return console.warn(`Column "${
|
|
26
|
+
return console.warn(`Column "${o}" is not filterable`), null;
|
|
26
27
|
const k = {
|
|
27
|
-
boolean:
|
|
28
|
-
text:
|
|
29
|
-
number:
|
|
28
|
+
boolean: $,
|
|
29
|
+
text: O,
|
|
30
|
+
number: A,
|
|
30
31
|
checkbox: z
|
|
31
|
-
},
|
|
32
|
-
if (!
|
|
32
|
+
}, h = e.cellType && (i == null ? void 0 : i[e.cellType]) || k[e.cellType ?? "text"];
|
|
33
|
+
if (!h)
|
|
33
34
|
return console.warn(
|
|
34
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".`
|
|
35
36
|
), null;
|
|
36
|
-
const
|
|
37
|
-
condition: (
|
|
38
|
-
value: (
|
|
39
|
-
},
|
|
40
|
-
|
|
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);
|
|
41
42
|
}, w = () => {
|
|
42
|
-
|
|
43
|
+
f(), n(!1);
|
|
43
44
|
};
|
|
44
|
-
return /* @__PURE__ */ r("div", { className: "relative", ref:
|
|
45
|
+
return /* @__PURE__ */ r("div", { className: "relative", ref: m, children: [
|
|
45
46
|
/* @__PURE__ */ t(
|
|
46
|
-
|
|
47
|
+
d,
|
|
47
48
|
{
|
|
48
49
|
onClick: () => {
|
|
49
|
-
n(!
|
|
50
|
+
n(!u);
|
|
50
51
|
},
|
|
51
52
|
variant: s ? "filled" : "stroke",
|
|
52
53
|
shade: s ? "brand" : "neutral",
|
|
53
54
|
size: "small",
|
|
54
55
|
children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
|
|
55
56
|
e.title,
|
|
56
|
-
s && /* @__PURE__ */ t(
|
|
57
|
+
s && /* @__PURE__ */ t(j, { className: "w-4 h-4 text-white flex-shrink-0" })
|
|
57
58
|
] })
|
|
58
59
|
}
|
|
59
60
|
),
|
|
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: [
|
|
61
62
|
/* @__PURE__ */ t(
|
|
62
|
-
|
|
63
|
+
h,
|
|
63
64
|
{
|
|
64
|
-
value:
|
|
65
|
-
onChange: ({ condition:
|
|
65
|
+
value: v,
|
|
66
|
+
onChange: ({ condition: c, value: g }) => p(o, c, g),
|
|
66
67
|
filterOptions: e.filterOptions
|
|
67
68
|
}
|
|
68
69
|
),
|
|
69
|
-
/* @__PURE__ */ r("div", { className: "flex justify-between gap-2 p-3 border-t border-stroke-solid-medium", children: [
|
|
70
|
-
/* @__PURE__ */ t(
|
|
71
|
-
/* @__PURE__ */ t(
|
|
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}` : ""}` })
|
|
72
73
|
] })
|
|
73
74
|
] })
|
|
74
75
|
] });
|
|
75
76
|
};
|
|
76
77
|
export {
|
|
77
|
-
|
|
78
|
+
J as TableFilterColumnButton
|
|
78
79
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react';
|
|
2
|
-
export declare const basicHeaderUsageCode = "import { Table, TableHeader } from '@/components/table';\n\nconst schema = [\n {\n key: 'id',\n title: 'ID',\n cellType: 'number',\n sortable: true,\n },\n {\n key: 'name',\n title: 'Name',\n cellType: '
|
|
2
|
+
export declare const basicHeaderUsageCode = "import { Table, TableHeader } from '@/components/table';\n\nconst schema = [\n {\n key: 'id',\n title: 'ID',\n cellType: 'number',\n sortable: true,\n },\n {\n key: 'name',\n title: 'Name',\n cellType: 'label',\n sortable: true,\n },\n];\n\nconst data = [\n { id: 1, name: 'John Doe' },\n { id: 2, name: 'Jane Smith' },\n];\n\nfunction MyTable() {\n return (\n <Table dataSource={data} schema={schema}>\n <table className=\"w-full\">\n <TableHeader \n schema={schema}\n cell={{ hasBorder: true }}\n />\n {/* Table body goes here */}\n </table>\n </Table>\n );\n}";
|
|
3
3
|
export declare const BasicHeader: StoryObj;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { jsx as r, jsxs as c } from "react/jsx-runtime";
|
|
2
2
|
import { TABLE_CSS_CLASSES as t } from "../../table.const.js";
|
|
3
|
-
import { TableSortIcon as
|
|
4
|
-
import { getCurrentSortDirection as
|
|
3
|
+
import { TableSortIcon as h } from "./table-sort-icon.js";
|
|
4
|
+
import { getCurrentSortDirection as n, isSortActive as p, handleSortClick as C } from "./table-header.utils.js";
|
|
5
5
|
import "react";
|
|
6
6
|
import { cn as S } from "../../../../lib/utils.js";
|
|
7
7
|
const x = ({
|
|
8
|
-
schema:
|
|
9
|
-
sort:
|
|
8
|
+
schema: i,
|
|
9
|
+
sort: a,
|
|
10
10
|
cell: o,
|
|
11
11
|
stickyHeader: s = !1
|
|
12
12
|
}) => /* @__PURE__ */ r(
|
|
13
13
|
"thead",
|
|
14
14
|
{
|
|
15
15
|
className: `${t.header} ${s ? "sticky top-[-1.5px] z-1" : ""}`,
|
|
16
|
-
children: /* @__PURE__ */ r("tr", { children:
|
|
17
|
-
const l =
|
|
16
|
+
children: /* @__PURE__ */ r("tr", { children: i.map((e) => {
|
|
17
|
+
const l = n(e.key, a), d = p(e.key, a);
|
|
18
18
|
return /* @__PURE__ */ r(
|
|
19
19
|
"th",
|
|
20
20
|
{
|
|
21
21
|
className: S(
|
|
22
|
-
e.sortable ? t.sortableHeaderCell : t.headerCell,
|
|
23
|
-
t.
|
|
22
|
+
e.sortable ? t.sortableHeaderCell : t.headerCell.default,
|
|
23
|
+
t.headerCell.hasBorder[o.hasBorder ? "true" : "false"]
|
|
24
24
|
),
|
|
25
|
-
onClick: e.sortable ? () => C(e.key,
|
|
25
|
+
onClick: e.sortable ? () => C(e.key, a) : void 0,
|
|
26
26
|
children: /* @__PURE__ */ c("div", { className: t.headerCellContent, children: [
|
|
27
27
|
/* @__PURE__ */ r("span", { children: e.title }),
|
|
28
|
-
e.sortable && /* @__PURE__ */ r(
|
|
28
|
+
e.sortable && /* @__PURE__ */ r(h, { direction: l, isActive: d })
|
|
29
29
|
] })
|
|
30
30
|
},
|
|
31
31
|
e.key
|
|
@@ -4,5 +4,5 @@ export type { TableProps, TableSchema, TableSchemaColumn, CellType, CellValue, C
|
|
|
4
4
|
export { extractCellValue } from './table.utils';
|
|
5
5
|
export { DEFAULT_EMPTY_MESSAGE, TABLE_CSS_CLASSES } from './table.const';
|
|
6
6
|
export { TableContext, useTableContext } from './table.context';
|
|
7
|
-
export { TableCell, TableHeader, TableRow, TableEmptyState, TableLoadingState, TablePagination,
|
|
7
|
+
export { TableCell, TableHeader, TableRow, TableEmptyState, TableLoadingState, TablePagination, NumberCell, BooleanCell, TableHeaderWrapper, TableHeaderContent, TableFooter, TableFooterContent, } from './components';
|
|
8
8
|
export { PaginationInfo, PaginationQuickJumper } from './components/pagination/components';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { TableContext as
|
|
4
|
-
import { TableBody as
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import * as p from "react";
|
|
3
|
+
import { TableContext as a } from "./table.context.js";
|
|
4
|
+
import { TableBody as n } from "./table.js";
|
|
5
5
|
import { TableFilter as f } from "./components/table-filter/table-filter-provider.js";
|
|
6
6
|
import { TableSearch as l } from "./components/table-search/table-search.js";
|
|
7
7
|
import { Pagination as s } from "./components/pagination/pagination.js";
|
|
@@ -9,27 +9,56 @@ import { PaginationInfo as T } from "./components/pagination/components/paginati
|
|
|
9
9
|
import { PaginationQuickJumper as b } from "./components/pagination/components/pagination-quick-jumper.js";
|
|
10
10
|
import "clsx";
|
|
11
11
|
import "tailwind-merge";
|
|
12
|
+
/* empty css */
|
|
13
|
+
import "../alert/alert.const.js";
|
|
14
|
+
import "../button/button.js";
|
|
15
|
+
import "../collapsible-side-nav-bar/side-nav-bar-provider.js";
|
|
16
|
+
import "../collapsible-side-nav-bar/side-nav-bar.js";
|
|
17
|
+
import "../collapsible-side-nav-bar/side-nav-bar-header.js";
|
|
18
|
+
import "../collapsible-side-nav-bar/side-nav-bar-content.js";
|
|
19
|
+
import "../collapsible-side-nav-bar/side-nav-bar-footer.js";
|
|
20
|
+
import "../collapsible-side-nav-bar/side-nav-bar-group.js";
|
|
21
|
+
import "../collapsible-side-nav-bar/side-nav-bar-item.js";
|
|
22
|
+
import "../collapsible-side-nav-bar/side-nav-bar-separator.js";
|
|
23
|
+
import "../collapsible-side-nav-bar/context.js";
|
|
24
|
+
import "../collapsible-side-nav-bar/popover/popover.js";
|
|
25
|
+
import "react-country-flag";
|
|
26
|
+
import "classnames";
|
|
27
|
+
import "@radix-ui/react-dialog";
|
|
28
|
+
import "../dropdown/z2-dropdown.js";
|
|
29
|
+
import "@radix-ui/react-dropdown-menu";
|
|
30
|
+
import "lucide-react";
|
|
31
|
+
import "../input/input.js";
|
|
32
|
+
import "../nav-header/nav-header.js";
|
|
33
|
+
import "../nav-header/nav-item/nav-item.js";
|
|
34
|
+
import "@radix-ui/react-select";
|
|
35
|
+
import "../stepper/stepper.js";
|
|
36
|
+
import "../stepper-item/stepper-item.js";
|
|
37
|
+
import "@radix-ui/react-tabs";
|
|
38
|
+
import "../tooltip/tooltip.js";
|
|
39
|
+
import "../badge/badge.js";
|
|
40
|
+
import "../avatar/avatar.js";
|
|
12
41
|
import { TableHeaderWrapper as c } from "./components/table-header-wrapper.js";
|
|
13
42
|
import { TableHeaderContent as d } from "./components/table-header-content.js";
|
|
14
43
|
import { TableFooter as u } from "./components/table-footer.js";
|
|
15
44
|
import { TableFooterContent as g } from "./components/table-footer-content.js";
|
|
16
45
|
const t = ({
|
|
17
|
-
children:
|
|
46
|
+
children: i,
|
|
18
47
|
pagination: C,
|
|
19
48
|
sort: F,
|
|
20
49
|
filter: v,
|
|
21
50
|
filterComponents: x,
|
|
22
51
|
...r
|
|
23
52
|
}) => {
|
|
24
|
-
const
|
|
53
|
+
const m = p.useMemo(
|
|
25
54
|
() => ({
|
|
26
55
|
...r
|
|
27
56
|
}),
|
|
28
57
|
[r]
|
|
29
58
|
);
|
|
30
|
-
return /* @__PURE__ */ a
|
|
59
|
+
return /* @__PURE__ */ e(a.Provider, { value: m, children: i });
|
|
31
60
|
}, P = t, o = P;
|
|
32
|
-
o.Body =
|
|
61
|
+
o.Body = n;
|
|
33
62
|
o.Filter = f;
|
|
34
63
|
o.Search = l;
|
|
35
64
|
o.Pagination = s;
|
|
@@ -3,22 +3,24 @@ export declare const TABLE_CSS_CLASSES: {
|
|
|
3
3
|
readonly table: "w-full";
|
|
4
4
|
readonly header: "bg-background-neutral-medium text-text-neutral-secondary";
|
|
5
5
|
readonly cell: {
|
|
6
|
-
readonly default: "
|
|
7
|
-
readonly cellHeight: {
|
|
8
|
-
readonly small: "p-3";
|
|
9
|
-
readonly large: "p-4";
|
|
10
|
-
};
|
|
6
|
+
readonly default: "p-0 align-middle relative h-4";
|
|
11
7
|
readonly hasBorder: {
|
|
12
|
-
readonly true: "border border-stroke-solid-light";
|
|
8
|
+
readonly true: "border-r border-b border-stroke-solid-light";
|
|
13
9
|
readonly false: "border-b border-stroke-solid-light";
|
|
14
10
|
};
|
|
15
11
|
};
|
|
16
|
-
readonly headerCell:
|
|
12
|
+
readonly headerCell: {
|
|
13
|
+
readonly default: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wider";
|
|
14
|
+
readonly hasBorder: {
|
|
15
|
+
readonly true: "border-none [box-shadow:inset_-1px_0_0_0_var(--color-stroke-solid-light),_inset_0_-1px_0_0_var(--color-stroke-solid-light)]";
|
|
16
|
+
readonly false: "border-none [box-shadow:inset_0_-1px_0_0_var(--color-stroke-solid-light)]";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
17
19
|
readonly sortableHeaderCell: "p-3 text-left text-xs font-medium uppercase tracking-wider cursor-pointer transition-colors duration-200";
|
|
18
20
|
readonly headerCellContent: "flex items-center justify-between";
|
|
19
21
|
readonly sortIcon: "ml-2 w-4 h-4 text-gray-400";
|
|
20
22
|
readonly sortIconActive: "ml-2 w-4 h-4 text-gray-600";
|
|
21
|
-
readonly row: "
|
|
23
|
+
readonly row: " transition-colors duration-200 text-text-neutral-primary";
|
|
22
24
|
readonly emptyState: "px-4 py-8 text-center text-gray-500";
|
|
23
25
|
readonly loading: "px-4 py-8 text-center text-gray-500";
|
|
24
26
|
};
|
|
@@ -2,22 +2,24 @@ const e = "No data available", t = {
|
|
|
2
2
|
table: "w-full",
|
|
3
3
|
header: "bg-background-neutral-medium text-text-neutral-secondary",
|
|
4
4
|
cell: {
|
|
5
|
-
default: "
|
|
6
|
-
cellHeight: {
|
|
7
|
-
small: "p-3",
|
|
8
|
-
large: "p-4"
|
|
9
|
-
},
|
|
5
|
+
default: "p-0 align-middle relative h-4",
|
|
10
6
|
hasBorder: {
|
|
11
|
-
true: "border border-stroke-solid-light",
|
|
7
|
+
true: "border-r border-b border-stroke-solid-light",
|
|
12
8
|
false: "border-b border-stroke-solid-light"
|
|
13
9
|
}
|
|
14
10
|
},
|
|
15
|
-
headerCell:
|
|
11
|
+
headerCell: {
|
|
12
|
+
default: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wider",
|
|
13
|
+
hasBorder: {
|
|
14
|
+
true: "border-none [box-shadow:inset_-1px_0_0_0_var(--color-stroke-solid-light),_inset_0_-1px_0_0_var(--color-stroke-solid-light)]",
|
|
15
|
+
false: "border-none [box-shadow:inset_0_-1px_0_0_var(--color-stroke-solid-light)]"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
16
18
|
sortableHeaderCell: "p-3 text-left text-xs font-medium uppercase tracking-wider cursor-pointer transition-colors duration-200",
|
|
17
19
|
headerCellContent: "flex items-center justify-between",
|
|
18
20
|
sortIcon: "ml-2 w-4 h-4 text-gray-400",
|
|
19
21
|
sortIconActive: "ml-2 w-4 h-4 text-gray-600",
|
|
20
|
-
row: "
|
|
22
|
+
row: " transition-colors duration-200 text-text-neutral-primary",
|
|
21
23
|
emptyState: "px-4 py-8 text-center text-gray-500",
|
|
22
24
|
loading: "px-4 py-8 text-center text-gray-500"
|
|
23
25
|
};
|
|
@@ -6,13 +6,7 @@ import { TableRow as E } from "./components/table-row.js";
|
|
|
6
6
|
import { TableEmptyState as y } from "./components/table-empty-state.js";
|
|
7
7
|
import { TableLoadingState as x } from "./components/table-loading-state.js";
|
|
8
8
|
import { TableContext as C } from "./table.context.js";
|
|
9
|
-
const w = ({
|
|
10
|
-
cell: r = { cellHeight: "small", hasBorder: !0 },
|
|
11
|
-
sort: l,
|
|
12
|
-
className: m,
|
|
13
|
-
stickyHeader: s = !1,
|
|
14
|
-
...n
|
|
15
|
-
}) => {
|
|
9
|
+
const w = ({ cell: r = { hasBorder: !0 }, sort: l, className: m, stickyHeader: s = !1, ...n }) => {
|
|
16
10
|
const c = u.useContext(C), {
|
|
17
11
|
dataSource: o = [],
|
|
18
12
|
schema: t = [],
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { FilterComponentType } from './components/table-filter/table-filter.type';
|
|
3
|
-
|
|
3
|
+
import { NumberCellProps } from './components/cell/number-cell';
|
|
4
|
+
import { BooleanCellProps } from './components/cell/boolean-cell';
|
|
5
|
+
import { LinkCellProps } from './components/cell/link-cell';
|
|
6
|
+
import { AvatarCellProps } from './components/cell/avatar-cell';
|
|
7
|
+
import { LabelCellProps } from './components/cell/label-cell';
|
|
8
|
+
import { DescriptionCellProps } from './components/cell/description-cell';
|
|
9
|
+
export type CellType = 'number' | 'boolean' | 'checkbox' | 'link' | 'avatar' | 'label' | 'description' | 'text';
|
|
4
10
|
export type CellValue = string | number | boolean | null | undefined;
|
|
5
11
|
export type CellRendererProps = {
|
|
6
12
|
value: CellValue;
|
|
@@ -46,22 +52,46 @@ export type TableSort = {
|
|
|
46
52
|
sortedColumns: SortColumn[];
|
|
47
53
|
onSort: (field: string, direction: SortDirection) => void;
|
|
48
54
|
};
|
|
49
|
-
|
|
55
|
+
type CellPropsByType = {
|
|
56
|
+
number: Omit<NumberCellProps, 'value'>;
|
|
57
|
+
boolean: Omit<BooleanCellProps, 'value'>;
|
|
58
|
+
checkbox: Omit<BooleanCellProps, 'value'>;
|
|
59
|
+
link: Omit<LinkCellProps, 'value' | 'href'> & {
|
|
60
|
+
href: string;
|
|
61
|
+
};
|
|
62
|
+
avatar: Omit<AvatarCellProps, 'value'>;
|
|
63
|
+
label: Omit<LabelCellProps, 'value'>;
|
|
64
|
+
description: Omit<DescriptionCellProps, 'value'>;
|
|
65
|
+
};
|
|
66
|
+
type ColumnBase<T extends CellType> = {
|
|
50
67
|
key: string;
|
|
51
|
-
valueGetter?: (record: Record<string, any>) => string | number | boolean | null | undefined;
|
|
52
68
|
title: string;
|
|
53
|
-
cellType:
|
|
69
|
+
cellType: T;
|
|
54
70
|
cellRenderer?: CellRenderer;
|
|
55
71
|
filterable?: boolean;
|
|
56
72
|
hideable?: boolean;
|
|
57
73
|
sortable?: boolean;
|
|
58
74
|
filterOptions?: FilterOption[];
|
|
59
75
|
};
|
|
76
|
+
export type TableSchemaColumn = (ColumnBase<'number'> & {
|
|
77
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['number'];
|
|
78
|
+
}) | (ColumnBase<'boolean'> & {
|
|
79
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['boolean'];
|
|
80
|
+
}) | (ColumnBase<'checkbox'> & {
|
|
81
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['checkbox'];
|
|
82
|
+
}) | (ColumnBase<'link'> & {
|
|
83
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['link'];
|
|
84
|
+
}) | (ColumnBase<'avatar'> & {
|
|
85
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['avatar'];
|
|
86
|
+
}) | (ColumnBase<'label'> & {
|
|
87
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['label'];
|
|
88
|
+
}) | (ColumnBase<'description'> & {
|
|
89
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['description'];
|
|
90
|
+
});
|
|
60
91
|
export type TableSchema = TableSchemaColumn[];
|
|
61
92
|
export type TableProps = {
|
|
62
93
|
cell?: {
|
|
63
94
|
hasBorder?: boolean;
|
|
64
|
-
cellHeight?: 'small' | 'large';
|
|
65
95
|
};
|
|
66
96
|
dataSource: Record<string, unknown>[];
|
|
67
97
|
schema: TableSchema;
|
|
@@ -73,3 +103,4 @@ export type TableProps = {
|
|
|
73
103
|
sort?: TableSort;
|
|
74
104
|
customCells?: Record<string, CellRenderer>;
|
|
75
105
|
};
|
|
106
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CellValue, TableSchemaColumn } from './table.type';
|
|
2
|
-
export declare const extractCellValue: (record: Record<string, unknown>, column: TableSchemaColumn) => CellValue
|
|
2
|
+
export declare const extractCellValue: (record: Record<string, unknown>, column: TableSchemaColumn) => CellValue | Record<string, unknown>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
const a = (
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const a = (r, e) => {
|
|
2
|
+
if (e.valueGetter)
|
|
3
|
+
return e.valueGetter(r);
|
|
4
|
+
const t = r[e.key];
|
|
5
|
+
return t != null ? t ?? void 0 : void 0;
|
|
4
6
|
};
|
|
5
7
|
export {
|
|
6
8
|
a as extractCellValue
|