@ztwoint/z-ui 0.1.107 → 0.1.109
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/column-reorder/column-reorder.hook.js +9 -10
- package/dist/components/column-reorder/components/column-item/column-item.js +40 -81
- package/dist/components/dynamic-table/index.d.ts +4 -0
- package/dist/components/dynamic-table/z2-column-header.js +186 -0
- package/dist/components/dynamic-table/z2-table-context.js +98 -0
- package/dist/components/dynamic-table/z2-table-pagination.js +124 -0
- package/dist/components/dynamic-table/z2-table.d.ts +1 -1
- package/dist/components/dynamic-table/z2-table.js +408 -0
- package/dist/components/skeleton/skeleton.js +16 -0
- package/dist/components/table/components/cell/avatar-cell.js +4 -2
- package/dist/components/table/table-provider.js +2 -0
- package/dist/components/table-card/table-card.js +11 -9
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +207 -180
- package/dist/types/components/dynamic-table/index.d.ts +4 -0
- package/dist/types/components/dynamic-table/z2-table.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -9,17 +9,16 @@ import "clsx";
|
|
|
9
9
|
import "tailwind-merge";
|
|
10
10
|
import { isColumnData as s } from "./components/column-item/column-item.util.js";
|
|
11
11
|
import "../button/button.js";
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const [t, a] = I(o);
|
|
12
|
+
const $ = ({ columns: e, onReorder: r }) => {
|
|
13
|
+
const [t, a] = I(e);
|
|
15
14
|
return p(() => {
|
|
16
|
-
a(
|
|
17
|
-
}, [
|
|
18
|
-
canMonitor({ source:
|
|
19
|
-
return s(
|
|
15
|
+
a(e);
|
|
16
|
+
}, [e]), p(() => C({
|
|
17
|
+
canMonitor({ source: o }) {
|
|
18
|
+
return s(o.data);
|
|
20
19
|
},
|
|
21
|
-
onDrop({ location:
|
|
22
|
-
const c =
|
|
20
|
+
onDrop({ location: o, source: g }) {
|
|
21
|
+
const c = o.current.dropTargets[0];
|
|
23
22
|
if (!c)
|
|
24
23
|
return;
|
|
25
24
|
const n = g.data, i = c.data;
|
|
@@ -44,5 +43,5 @@ const b = ({ columns: o, onReorder: r }) => {
|
|
|
44
43
|
}), [t, r]), { internalColumns: t };
|
|
45
44
|
};
|
|
46
45
|
export {
|
|
47
|
-
|
|
46
|
+
$ as useColumnReorder
|
|
48
47
|
};
|
|
@@ -1,128 +1,87 @@
|
|
|
1
1
|
import { jsxs as l, Fragment as f, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { cn as
|
|
5
|
-
import { useColumnItemDragAndDrop as
|
|
6
|
-
import { Button as
|
|
7
|
-
import
|
|
8
|
-
import { parseColumnLabel as
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
const L = {
|
|
2
|
+
import { createPortal as x } from "react-dom";
|
|
3
|
+
import "react";
|
|
4
|
+
import { cn as c } from "../../../../lib/utils.js";
|
|
5
|
+
import { useColumnItemDragAndDrop as h } from "./column-item.hook.js";
|
|
6
|
+
import { Button as b } from "../../../button/button.js";
|
|
7
|
+
import N from "../../../assets/icons/x.js";
|
|
8
|
+
import { parseColumnLabel as g } from "./column-item.util.js";
|
|
9
|
+
import u from "../../../assets/icons/drag-handle.js";
|
|
10
|
+
const y = {
|
|
12
11
|
"is-dragging": "opacity-40",
|
|
13
12
|
"is-dragging-over": "bg-background-neutral-medium"
|
|
14
|
-
},
|
|
15
|
-
const i = x(null), [o, m] = h(!1);
|
|
16
|
-
b(() => {
|
|
17
|
-
const n = () => {
|
|
18
|
-
if (i.current) {
|
|
19
|
-
const c = i.current;
|
|
20
|
-
m(c.scrollWidth > c.clientWidth);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
return n(), window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
|
|
24
|
-
}, [t]);
|
|
25
|
-
const a = /* @__PURE__ */ e("span", { ref: i, className: u("truncate min-w-0", s), children: t });
|
|
26
|
-
return o && r ? /* @__PURE__ */ e(w, { message: r, side: "top", children: a }) : a;
|
|
27
|
-
}, T = ({
|
|
13
|
+
}, i = ({ text: t, className: r }) => /* @__PURE__ */ e("span", { className: c("truncate min-w-0", r), children: t }), k = ({
|
|
28
14
|
edge: t,
|
|
29
|
-
isFirstElement:
|
|
15
|
+
isFirstElement: r = !1
|
|
30
16
|
}) => /* @__PURE__ */ e(
|
|
31
17
|
"div",
|
|
32
18
|
{
|
|
33
|
-
className:
|
|
19
|
+
className: c(
|
|
34
20
|
"absolute left-0 right-0 h-0.5 bg-blue-500",
|
|
35
|
-
t === "top" ?
|
|
21
|
+
t === "top" ? r ? "top-0" : "top-[-3px]" : "bottom-0"
|
|
36
22
|
)
|
|
37
23
|
}
|
|
38
24
|
);
|
|
39
|
-
function
|
|
40
|
-
const { groupLabel:
|
|
25
|
+
function v({ column: t }) {
|
|
26
|
+
const { groupLabel: r, fieldLabel: a } = g(t);
|
|
41
27
|
return /* @__PURE__ */ l("div", { className: "flex items-center gap-3 p-1 bg-background-neutral-default border border-stroke-solid-light rounded-xl ", children: [
|
|
42
|
-
/* @__PURE__ */ e(
|
|
28
|
+
/* @__PURE__ */ e(u, {}),
|
|
43
29
|
/* @__PURE__ */ e("div", { className: "shrink-0 flex items-center justify-center w-3.5 h-3.5 ", children: t.icon }),
|
|
44
30
|
/* @__PURE__ */ l("div", { className: "flex items-center gap-0.5 min-w-0 flex-1 leading-none-regular-sm", children: [
|
|
45
|
-
/* @__PURE__ */ e(
|
|
46
|
-
d,
|
|
47
|
-
{
|
|
48
|
-
text: s,
|
|
49
|
-
className: "text-text-neutral-secondary",
|
|
50
|
-
tooltipMessage: `Group: ${s}`
|
|
51
|
-
}
|
|
52
|
-
),
|
|
31
|
+
/* @__PURE__ */ e(i, { text: r, className: "text-text-neutral-secondary" }),
|
|
53
32
|
/* @__PURE__ */ e("span", { className: "text-text-neutral-muted flex-shrink-0", children: "/" }),
|
|
54
|
-
/* @__PURE__ */ e(
|
|
55
|
-
d,
|
|
56
|
-
{
|
|
57
|
-
text: r,
|
|
58
|
-
className: "text-text-neutral-primary",
|
|
59
|
-
tooltipMessage: `Field: ${r}`
|
|
60
|
-
}
|
|
61
|
-
)
|
|
33
|
+
/* @__PURE__ */ e(i, { text: a, className: "text-text-neutral-primary" })
|
|
62
34
|
] })
|
|
63
35
|
] });
|
|
64
36
|
}
|
|
65
|
-
const
|
|
37
|
+
const T = ({
|
|
66
38
|
column: t,
|
|
67
|
-
index:
|
|
68
|
-
onRemove:
|
|
69
|
-
renderAction:
|
|
70
|
-
disabled:
|
|
39
|
+
index: r,
|
|
40
|
+
onRemove: a,
|
|
41
|
+
renderAction: o,
|
|
42
|
+
disabled: n = !1
|
|
71
43
|
}) => {
|
|
72
|
-
const { ref:
|
|
44
|
+
const { ref: p, state: s } = h(t, r, n), { groupLabel: d, fieldLabel: m } = g(t);
|
|
73
45
|
return /* @__PURE__ */ l(f, { children: [
|
|
74
46
|
/* @__PURE__ */ l("div", { className: "relative border-b-0.5", children: [
|
|
75
47
|
/* @__PURE__ */ l(
|
|
76
48
|
"div",
|
|
77
49
|
{
|
|
78
50
|
"data-column-id": t.id,
|
|
79
|
-
ref:
|
|
80
|
-
|
|
51
|
+
ref: p,
|
|
52
|
+
title: `${d} / ${m}`,
|
|
53
|
+
className: c(
|
|
81
54
|
"flex items-center gap-2 p-1 pl-3 bg-background-neutral-default transition-colors",
|
|
82
|
-
|
|
83
|
-
|
|
55
|
+
n ? "cursor-default" : "cursor-grab hover:bg-background-neutral-medium",
|
|
56
|
+
y[s.type] ?? ""
|
|
84
57
|
),
|
|
85
58
|
children: [
|
|
86
|
-
!
|
|
59
|
+
!n && /* @__PURE__ */ e(u, {}),
|
|
87
60
|
/* @__PURE__ */ e("div", { className: "shrink-0 flex items-center justify-center w-3.5 h-3.5", children: t.icon }),
|
|
88
61
|
/* @__PURE__ */ l("div", { className: "flex items-center gap-0.5 min-w-0 flex-1 leading-none-regular-sm", children: [
|
|
89
|
-
/* @__PURE__ */ e(
|
|
90
|
-
d,
|
|
91
|
-
{
|
|
92
|
-
text: n,
|
|
93
|
-
className: "text-text-neutral-secondary",
|
|
94
|
-
tooltipMessage: `Group: ${n}`
|
|
95
|
-
}
|
|
96
|
-
),
|
|
62
|
+
/* @__PURE__ */ e(i, { text: d, className: "text-text-neutral-secondary" }),
|
|
97
63
|
/* @__PURE__ */ e("span", { className: "text-text-neutral-muted flex-shrink-0", children: "/" }),
|
|
98
|
-
/* @__PURE__ */ e(
|
|
99
|
-
d,
|
|
100
|
-
{
|
|
101
|
-
text: c,
|
|
102
|
-
className: "text-text-neutral-primary",
|
|
103
|
-
tooltipMessage: `Field: ${c}`
|
|
104
|
-
}
|
|
105
|
-
)
|
|
64
|
+
/* @__PURE__ */ e(i, { text: m, className: "text-text-neutral-primary" })
|
|
106
65
|
] }),
|
|
107
|
-
/* @__PURE__ */ e("div", { className: "ml-auto flex items-center gap-3", children:
|
|
108
|
-
|
|
66
|
+
/* @__PURE__ */ e("div", { className: "ml-auto flex items-center gap-3", children: o ? o(t, a) : /* @__PURE__ */ e(
|
|
67
|
+
b,
|
|
109
68
|
{
|
|
110
|
-
onClick: () =>
|
|
69
|
+
onClick: () => a == null ? void 0 : a(t.id),
|
|
111
70
|
variant: "ghost",
|
|
112
71
|
shade: "neutral",
|
|
113
72
|
size: "medium",
|
|
114
|
-
leftIcon: /* @__PURE__ */ e(
|
|
73
|
+
leftIcon: /* @__PURE__ */ e(N, { className: "w-4 h-4" })
|
|
115
74
|
}
|
|
116
75
|
) })
|
|
117
76
|
]
|
|
118
77
|
}
|
|
119
78
|
),
|
|
120
|
-
|
|
79
|
+
s.type === "is-dragging-over" && s.closestEdge && /* @__PURE__ */ e(k, { edge: s.closestEdge, isFirstElement: r === 0 })
|
|
121
80
|
] }),
|
|
122
|
-
|
|
81
|
+
s.type === "preview" && x(/* @__PURE__ */ e(v, { column: t }), s.container)
|
|
123
82
|
] });
|
|
124
83
|
};
|
|
125
84
|
export {
|
|
126
|
-
|
|
127
|
-
|
|
85
|
+
T as ColumnItem,
|
|
86
|
+
T as default
|
|
128
87
|
};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { jsx as t, jsxs as r, Fragment as b } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { cn as R } from "../../lib/utils.js";
|
|
4
|
+
import { Button as V } from "../button/button.js";
|
|
5
|
+
import { useZ2Table as j } from "./z2-table-context.js";
|
|
6
|
+
import { Z2DropdownMenu as U, Z2DropdownMenuTrigger as B, Z2DropdownMenuContent as F, Z2DropdownMenuLabel as H, Z2DropdownMenuSeparator as f, Z2DropdownMenuItem as g, Z2DropdownMenuSub as _, Z2DropdownMenuSubTrigger as $, Z2DropdownMenuPortal as q, Z2DropdownMenuSubContent as E, Z2DropdownMenuCheckboxItem as G } from "../dropdown-menu/z2-dropdown-menu.js";
|
|
7
|
+
import { ArrowUp as I, Check as C, ArrowDown as L, ArrowLeftToLine as J, ArrowRightToLine as K, ArrowLeft as Q, ArrowRight as W, Settings2 as X, ChevronsUpDown as Y, PinOff as ee } from "lucide-react";
|
|
8
|
+
function le({
|
|
9
|
+
column: e,
|
|
10
|
+
title: p = "",
|
|
11
|
+
icon: m,
|
|
12
|
+
className: k,
|
|
13
|
+
filter: d,
|
|
14
|
+
visibility: h = !1
|
|
15
|
+
}) {
|
|
16
|
+
var M, z, y, P;
|
|
17
|
+
const { isLoading: Z, table: u, props: o, recordCount: v } = j(), S = (a) => {
|
|
18
|
+
const s = [...u.getState().columnOrder], n = s.indexOf(e.id);
|
|
19
|
+
if (a === "left" && n > 0) {
|
|
20
|
+
const i = [...s], [c] = i.splice(n, 1);
|
|
21
|
+
i.splice(n - 1, 0, c), u.setColumnOrder(i);
|
|
22
|
+
}
|
|
23
|
+
if (a === "right" && n < s.length - 1) {
|
|
24
|
+
const i = [...s], [c] = i.splice(n, 1);
|
|
25
|
+
i.splice(n + 1, 0, c), u.setColumnOrder(i);
|
|
26
|
+
}
|
|
27
|
+
}, N = (a) => {
|
|
28
|
+
const s = u.getState().columnOrder, n = s.indexOf(e.id);
|
|
29
|
+
return a === "left" ? n > 0 : n < s.length - 1;
|
|
30
|
+
}, O = () => /* @__PURE__ */ r(
|
|
31
|
+
"div",
|
|
32
|
+
{
|
|
33
|
+
className: R(
|
|
34
|
+
"inline-flex h-full items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:opacity-60",
|
|
35
|
+
k
|
|
36
|
+
),
|
|
37
|
+
children: [
|
|
38
|
+
m && m,
|
|
39
|
+
p
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
), D = () => /* @__PURE__ */ r(
|
|
43
|
+
"button",
|
|
44
|
+
{
|
|
45
|
+
className: "p-0 h-fit w-full flex justify-between cursor-pointer",
|
|
46
|
+
disabled: Z || v === 0,
|
|
47
|
+
onClick: () => {
|
|
48
|
+
const a = e.getIsSorted();
|
|
49
|
+
a === "asc" ? e.toggleSorting(!0) : a === "desc" ? e.clearSorting() : e.toggleSorting(!1);
|
|
50
|
+
},
|
|
51
|
+
children: [
|
|
52
|
+
m && /* @__PURE__ */ t("span", { className: "size-3.5", children: m }),
|
|
53
|
+
p && /* @__PURE__ */ t("span", { className: "grow text-left", children: p }),
|
|
54
|
+
e.getCanSort() && /* @__PURE__ */ t("span", { className: "size-3.5", children: e.getIsSorted() === "desc" ? /* @__PURE__ */ t(L, { className: "size-[0.7rem]! mt-px ml-auto" }) : e.getIsSorted() === "asc" ? /* @__PURE__ */ t(I, { className: "size-[0.7rem]! mt-px ml-auto" }) : /* @__PURE__ */ t(Y, { className: "size-[0.7rem]! mt-px ml-auto" }) })
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
), T = () => /* @__PURE__ */ t(
|
|
58
|
+
V,
|
|
59
|
+
{
|
|
60
|
+
size: "small",
|
|
61
|
+
variant: "ghost",
|
|
62
|
+
className: "-me-1 size-7 rounded-md",
|
|
63
|
+
onClick: () => e.pin(!1),
|
|
64
|
+
"aria-label": `Unpin ${p} column`,
|
|
65
|
+
title: `Unpin ${p} column`,
|
|
66
|
+
children: /* @__PURE__ */ t(ee, { className: "size-3.5! opacity-50!", "aria-hidden": "true" })
|
|
67
|
+
}
|
|
68
|
+
), A = () => {
|
|
69
|
+
var a, s, n, i, c;
|
|
70
|
+
return /* @__PURE__ */ r("div", { className: "flex items-center h-full gap-1.5 justify-between", children: [
|
|
71
|
+
/* @__PURE__ */ r(U, { children: [
|
|
72
|
+
/* @__PURE__ */ t(B, { asChild: !0, children: D() }),
|
|
73
|
+
/* @__PURE__ */ r(F, { className: "w-40", align: "start", children: [
|
|
74
|
+
d && /* @__PURE__ */ t(H, { children: d }),
|
|
75
|
+
d && (e.getCanSort() || e.getCanPin() || h) && /* @__PURE__ */ t(f, {}),
|
|
76
|
+
e.getCanSort() && /* @__PURE__ */ r(b, { children: [
|
|
77
|
+
/* @__PURE__ */ r(
|
|
78
|
+
g,
|
|
79
|
+
{
|
|
80
|
+
onClick: () => {
|
|
81
|
+
e.getIsSorted() === "asc" ? e.clearSorting() : e.toggleSorting(!1);
|
|
82
|
+
},
|
|
83
|
+
disabled: !e.getCanSort(),
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ t(I, { className: "size-3.5!" }),
|
|
86
|
+
/* @__PURE__ */ t("span", { className: "grow", children: "Asc" }),
|
|
87
|
+
e.getIsSorted() === "asc" && /* @__PURE__ */ t(C, { className: "size-4 opacity-100! text-primary" })
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
),
|
|
91
|
+
/* @__PURE__ */ r(
|
|
92
|
+
g,
|
|
93
|
+
{
|
|
94
|
+
onClick: () => {
|
|
95
|
+
e.getIsSorted() === "desc" ? e.clearSorting() : e.toggleSorting(!0);
|
|
96
|
+
},
|
|
97
|
+
disabled: !e.getCanSort(),
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ t(L, { className: "size-3.5!" }),
|
|
100
|
+
/* @__PURE__ */ t("span", { className: "grow", children: "Desc" }),
|
|
101
|
+
e.getIsSorted() === "desc" && /* @__PURE__ */ t(C, { className: "size-4 opacity-100! text-primary" })
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] }),
|
|
106
|
+
(d || e.getCanSort()) && (e.getCanSort() || e.getCanPin() || h) && /* @__PURE__ */ t(f, {}),
|
|
107
|
+
((a = o.tableLayout) == null ? void 0 : a.columnsPinnable) && e.getCanPin() && /* @__PURE__ */ r(b, { children: [
|
|
108
|
+
/* @__PURE__ */ r(
|
|
109
|
+
g,
|
|
110
|
+
{
|
|
111
|
+
onClick: () => e.pin(e.getIsPinned() === "left" ? !1 : "left"),
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ t(J, { className: "size-3.5!", "aria-hidden": "true" }),
|
|
114
|
+
/* @__PURE__ */ t("span", { className: "grow", children: "Pin to left" }),
|
|
115
|
+
e.getIsPinned() === "left" && /* @__PURE__ */ t(C, { className: "size-4 opacity-100! text-primary" })
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
/* @__PURE__ */ r(
|
|
120
|
+
g,
|
|
121
|
+
{
|
|
122
|
+
onClick: () => e.pin(e.getIsPinned() === "right" ? !1 : "right"),
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ t(K, { className: "size-3.5!", "aria-hidden": "true" }),
|
|
125
|
+
/* @__PURE__ */ t("span", { className: "grow", children: "Pin to right" }),
|
|
126
|
+
e.getIsPinned() === "right" && /* @__PURE__ */ t(C, { className: "size-4 opacity-100! text-primary" })
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
] }),
|
|
131
|
+
((s = o.tableLayout) == null ? void 0 : s.columnsMovable) && /* @__PURE__ */ r(b, { children: [
|
|
132
|
+
/* @__PURE__ */ t(f, {}),
|
|
133
|
+
/* @__PURE__ */ r(
|
|
134
|
+
g,
|
|
135
|
+
{
|
|
136
|
+
onClick: () => S("left"),
|
|
137
|
+
disabled: !N("left") || e.getIsPinned() !== !1,
|
|
138
|
+
children: [
|
|
139
|
+
/* @__PURE__ */ t(Q, { className: "size-3.5!", "aria-hidden": "true" }),
|
|
140
|
+
/* @__PURE__ */ t("span", { children: "Move to Left" })
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ r(
|
|
145
|
+
g,
|
|
146
|
+
{
|
|
147
|
+
onClick: () => S("right"),
|
|
148
|
+
disabled: !N("right") || e.getIsPinned() !== !1,
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ t(W, { className: "size-3.5!", "aria-hidden": "true" }),
|
|
151
|
+
/* @__PURE__ */ t("span", { children: "Move to Right" })
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
] }),
|
|
156
|
+
((n = o.tableLayout) == null ? void 0 : n.columnsVisibility) && h && (e.getCanSort() || e.getCanPin() || d) && /* @__PURE__ */ t(f, {}),
|
|
157
|
+
((i = o.tableLayout) == null ? void 0 : i.columnsVisibility) && h && /* @__PURE__ */ r(_, { children: [
|
|
158
|
+
/* @__PURE__ */ r($, { children: [
|
|
159
|
+
/* @__PURE__ */ t(X, { className: "size-3.5!" }),
|
|
160
|
+
/* @__PURE__ */ t("span", { children: "Columns" })
|
|
161
|
+
] }),
|
|
162
|
+
/* @__PURE__ */ t(q, { children: /* @__PURE__ */ t(E, { children: u.getAllColumns().filter((l) => typeof l.accessorFn < "u" && l.getCanHide()).map((l) => {
|
|
163
|
+
var x;
|
|
164
|
+
return /* @__PURE__ */ t(
|
|
165
|
+
G,
|
|
166
|
+
{
|
|
167
|
+
checked: l.getIsVisible(),
|
|
168
|
+
onSelect: (w) => w.preventDefault(),
|
|
169
|
+
onCheckedChange: (w) => l.toggleVisibility(!!w),
|
|
170
|
+
className: "capitalize",
|
|
171
|
+
children: ((x = l.columnDef.meta) == null ? void 0 : x.headerTitle) || l.id
|
|
172
|
+
},
|
|
173
|
+
l.id
|
|
174
|
+
);
|
|
175
|
+
}) }) })
|
|
176
|
+
] })
|
|
177
|
+
] })
|
|
178
|
+
] }),
|
|
179
|
+
((c = o.tableLayout) == null ? void 0 : c.columnsPinnable) && e.getCanPin() && e.getIsPinned() && T()
|
|
180
|
+
] });
|
|
181
|
+
};
|
|
182
|
+
return (M = o.tableLayout) != null && M.columnsMovable || (z = o.tableLayout) != null && z.columnsVisibility && h || (y = o.tableLayout) != null && y.columnsPinnable && e.getCanPin() || d ? A() : e.getCanSort() || (P = o.tableLayout) != null && P.columnsResizable && e.getCanResize() ? /* @__PURE__ */ t("div", { className: "flex items-start h-full", children: D() }) : O();
|
|
183
|
+
}
|
|
184
|
+
export {
|
|
185
|
+
le as Z2TableColumnHeader
|
|
186
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as d, useContext as n } from "react";
|
|
3
|
+
import { cn as i } from "../../lib/utils.js";
|
|
4
|
+
const l = d(void 0);
|
|
5
|
+
function m() {
|
|
6
|
+
const a = n(l);
|
|
7
|
+
if (!a)
|
|
8
|
+
throw new Error("useZ2Table must be used within a Z2TableProvider");
|
|
9
|
+
return a;
|
|
10
|
+
}
|
|
11
|
+
function u({
|
|
12
|
+
children: a,
|
|
13
|
+
table: o,
|
|
14
|
+
...e
|
|
15
|
+
}) {
|
|
16
|
+
return /* @__PURE__ */ t(
|
|
17
|
+
l.Provider,
|
|
18
|
+
{
|
|
19
|
+
value: {
|
|
20
|
+
props: e,
|
|
21
|
+
table: o,
|
|
22
|
+
recordCount: e.recordCount,
|
|
23
|
+
isLoading: e.isLoading || !1
|
|
24
|
+
},
|
|
25
|
+
children: a
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
function g({ children: a, table: o, ...e }) {
|
|
30
|
+
const r = {
|
|
31
|
+
loadingMode: "skeleton",
|
|
32
|
+
tableLayout: {
|
|
33
|
+
dense: !1,
|
|
34
|
+
cellBorder: !1,
|
|
35
|
+
rowBorder: !0,
|
|
36
|
+
rowRounded: !1,
|
|
37
|
+
stripped: !1,
|
|
38
|
+
headerSticky: !1,
|
|
39
|
+
headerBackground: !0,
|
|
40
|
+
headerBorder: !0,
|
|
41
|
+
width: "fixed",
|
|
42
|
+
columnsVisibility: !1,
|
|
43
|
+
columnsResizable: !1,
|
|
44
|
+
columnsPinnable: !1,
|
|
45
|
+
columnsMovable: !1,
|
|
46
|
+
columnsDraggable: !1,
|
|
47
|
+
rowsDraggable: !1
|
|
48
|
+
},
|
|
49
|
+
tableClassNames: {
|
|
50
|
+
base: "",
|
|
51
|
+
header: "",
|
|
52
|
+
headerRow: "",
|
|
53
|
+
headerSticky: "sticky top-0 bg-background-neutral-medium",
|
|
54
|
+
body: "",
|
|
55
|
+
bodyRow: "",
|
|
56
|
+
footer: "",
|
|
57
|
+
edgeCell: ""
|
|
58
|
+
}
|
|
59
|
+
}, s = {
|
|
60
|
+
...r,
|
|
61
|
+
...e,
|
|
62
|
+
tableLayout: {
|
|
63
|
+
...r.tableLayout,
|
|
64
|
+
...e.tableLayout || {}
|
|
65
|
+
},
|
|
66
|
+
tableClassNames: {
|
|
67
|
+
...r.tableClassNames,
|
|
68
|
+
...e.tableClassNames || {}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
if (!o)
|
|
72
|
+
throw new Error('Z2Table requires a "table" prop');
|
|
73
|
+
return /* @__PURE__ */ t(u, { table: o, ...s, children: a });
|
|
74
|
+
}
|
|
75
|
+
function w({
|
|
76
|
+
children: a,
|
|
77
|
+
className: o,
|
|
78
|
+
border: e = !0
|
|
79
|
+
}) {
|
|
80
|
+
return /* @__PURE__ */ t(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
"data-slot": "data-grid",
|
|
84
|
+
className: i(
|
|
85
|
+
"grid w-full",
|
|
86
|
+
e && "border border-stroke-solid-light rounded-xl overflow-hidden",
|
|
87
|
+
o
|
|
88
|
+
),
|
|
89
|
+
children: a
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
w as Z2TableContainer,
|
|
95
|
+
u as Z2TableProvider,
|
|
96
|
+
g as Z2TableRoot,
|
|
97
|
+
m as useZ2Table
|
|
98
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as t, jsxs as l, Fragment as v } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronLeftIcon as P, ChevronRightIcon as I } from "lucide-react";
|
|
3
|
+
import { useZ2Table as L } from "./z2-table-context.js";
|
|
4
|
+
import { Z2Skeleton as S } from "../skeleton/skeleton.js";
|
|
5
|
+
import { Button as r } from "../button/button.js";
|
|
6
|
+
import "react";
|
|
7
|
+
import { cn as Z } from "../../lib/utils.js";
|
|
8
|
+
import { Z2Select as y, Z2SelectTrigger as T, Z2SelectValue as $, Z2SelectContent as j, Z2SelectItem as B } from "../select/z2-select.js";
|
|
9
|
+
function H(N) {
|
|
10
|
+
var b;
|
|
11
|
+
const { table: n, recordCount: m, isLoading: u } = L(), e = { ...{
|
|
12
|
+
sizes: [5, 10, 25, 50, 100],
|
|
13
|
+
sizesLabel: "Show",
|
|
14
|
+
sizesDescription: "per page",
|
|
15
|
+
sizesSkeleton: /* @__PURE__ */ t(S, { className: "h-8 w-44" }),
|
|
16
|
+
moreLimit: 5,
|
|
17
|
+
more: !1,
|
|
18
|
+
info: "{from} - {to} of {count}",
|
|
19
|
+
infoSkeleton: /* @__PURE__ */ t(S, { className: "h-8 w-60" }),
|
|
20
|
+
rowsPerPageLabel: "Rows per page",
|
|
21
|
+
previousPageLabel: "Go to previous page",
|
|
22
|
+
nextPageLabel: "Go to next page",
|
|
23
|
+
ellipsisText: "..."
|
|
24
|
+
}, ...N }, g = " rtl:transform rtl:rotate-180", o = n.getState().pagination.pageIndex, i = n.getState().pagination.pageSize, x = o * i + 1, h = Math.min((o + 1) * i, m), p = n.getPageCount(), w = e != null && e.info ? e.info.replace("{from}", x.toString()).replace("{to}", h.toString()).replace("{count}", m.toString()) : `${x} - ${h} of ${m}`, f = (e == null ? void 0 : e.moreLimit) || 5, c = Math.floor(o / f) * f, d = Math.min(c + f, p), z = () => {
|
|
25
|
+
const s = [];
|
|
26
|
+
for (let a = c; a < d; a++)
|
|
27
|
+
s.push(
|
|
28
|
+
/* @__PURE__ */ t(
|
|
29
|
+
r,
|
|
30
|
+
{
|
|
31
|
+
size: "small",
|
|
32
|
+
variant: "stroke",
|
|
33
|
+
disabled: o === a,
|
|
34
|
+
onClick: () => {
|
|
35
|
+
o !== a && n.setPageIndex(a);
|
|
36
|
+
},
|
|
37
|
+
leftIcon: a + 1
|
|
38
|
+
},
|
|
39
|
+
a
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
return s;
|
|
43
|
+
}, k = () => c > 0 ? /* @__PURE__ */ t(
|
|
44
|
+
r,
|
|
45
|
+
{
|
|
46
|
+
size: "small",
|
|
47
|
+
variant: "stroke",
|
|
48
|
+
onClick: () => n.setPageIndex(c - 1),
|
|
49
|
+
label: e.ellipsisText
|
|
50
|
+
}
|
|
51
|
+
) : null, C = () => d < p ? /* @__PURE__ */ t(
|
|
52
|
+
r,
|
|
53
|
+
{
|
|
54
|
+
variant: "stroke",
|
|
55
|
+
size: "small",
|
|
56
|
+
onClick: () => n.setPageIndex(d),
|
|
57
|
+
label: e.ellipsisText
|
|
58
|
+
}
|
|
59
|
+
) : null;
|
|
60
|
+
return /* @__PURE__ */ l(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
"data-slot": "data-grid-pagination",
|
|
64
|
+
className: Z(
|
|
65
|
+
"flex flex-wrap flex-col sm:flex-row justify-between items-center gap-2.5 py-2.5 sm:py-0 grow",
|
|
66
|
+
e == null ? void 0 : e.className
|
|
67
|
+
),
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ t("div", { className: "flex flex-wrap items-center space-x-2.5 pb-2.5 sm:pb-0 order-2 sm:order-1", children: u ? e == null ? void 0 : e.sizesSkeleton : /* @__PURE__ */ l(v, { children: [
|
|
70
|
+
/* @__PURE__ */ t("div", { className: "text-sm text-muted-foreground", children: e.rowsPerPageLabel }),
|
|
71
|
+
/* @__PURE__ */ l(
|
|
72
|
+
y,
|
|
73
|
+
{
|
|
74
|
+
value: `${i}`,
|
|
75
|
+
onValueChange: (s) => {
|
|
76
|
+
const a = Number(s);
|
|
77
|
+
n.setPageSize(a);
|
|
78
|
+
},
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ t(T, { className: "w-fit", size: "sm", children: /* @__PURE__ */ t($, { placeholder: `${i}` }) }),
|
|
81
|
+
/* @__PURE__ */ t(j, { side: "top", className: "min-w-[50px]", children: (b = e == null ? void 0 : e.sizes) == null ? void 0 : b.map((s) => /* @__PURE__ */ t(B, { value: `${s}`, children: s }, s)) })
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
] }) }),
|
|
86
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col sm:flex-row justify-center sm:justify-end items-center gap-2.5 pt-2.5 sm:pt-0 order-1 sm:order-2", children: u ? e == null ? void 0 : e.infoSkeleton : /* @__PURE__ */ l(v, { children: [
|
|
87
|
+
/* @__PURE__ */ t("div", { className: "text-sm text-muted-foreground text-nowrap order-2 sm:order-1", children: w }),
|
|
88
|
+
p > 1 && /* @__PURE__ */ l("div", { className: "flex items-center space-x-1 order-1 sm:order-2", children: [
|
|
89
|
+
/* @__PURE__ */ t(
|
|
90
|
+
r,
|
|
91
|
+
{
|
|
92
|
+
size: "small",
|
|
93
|
+
variant: "stroke",
|
|
94
|
+
className: g,
|
|
95
|
+
onClick: () => n.previousPage(),
|
|
96
|
+
disabled: !n.getCanPreviousPage(),
|
|
97
|
+
leftIcon: /* @__PURE__ */ t(P, { className: "size-full" }),
|
|
98
|
+
children: /* @__PURE__ */ t("span", { className: "sr-only", children: e.previousPageLabel })
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
k(),
|
|
102
|
+
z(),
|
|
103
|
+
C(),
|
|
104
|
+
/* @__PURE__ */ t(
|
|
105
|
+
r,
|
|
106
|
+
{
|
|
107
|
+
size: "small",
|
|
108
|
+
variant: "stroke",
|
|
109
|
+
className: g,
|
|
110
|
+
onClick: () => n.nextPage(),
|
|
111
|
+
disabled: !n.getCanNextPage(),
|
|
112
|
+
leftIcon: /* @__PURE__ */ t(I, { className: "size-full" }),
|
|
113
|
+
children: /* @__PURE__ */ t("span", { className: "sr-only", children: e.nextPageLabel })
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
] })
|
|
117
|
+
] }) })
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
H as Z2TablePagination
|
|
124
|
+
};
|
|
@@ -39,7 +39,7 @@ declare function Z2TableBodyRow<TData>({ children, row, dndRef, dndStyle, }: {
|
|
|
39
39
|
}): import("react/jsx-runtime").JSX.Element;
|
|
40
40
|
declare function Z2TableBodyRowExpandded<TData>({ row }: {
|
|
41
41
|
row: Row<TData>;
|
|
42
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
43
43
|
declare function Z2TableBodyRowCell<TData>({ children, cell, dndRef, dndStyle, }: {
|
|
44
44
|
children: ReactNode;
|
|
45
45
|
cell: Cell<TData, unknown>;
|