@ztwoint/z-ui 0.1.106 → 0.1.108
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/dynamic-table/index.d.ts +4 -0
- package/dist/components/dynamic-table/util/command.d.ts +18 -0
- package/dist/components/dynamic-table/util/seperator.d.ts +4 -0
- package/dist/components/dynamic-table/z2-column-header.d.ts +12 -0
- package/dist/components/dynamic-table/z2-column-header.js +186 -0
- package/dist/components/dynamic-table/z2-table-context.d.ts +87 -0
- package/dist/components/dynamic-table/z2-table-context.js +98 -0
- package/dist/components/dynamic-table/z2-table-filter.d.ts +15 -0
- package/dist/components/dynamic-table/z2-table-pagination.d.ts +19 -0
- package/dist/components/dynamic-table/z2-table-pagination.js +124 -0
- package/dist/components/dynamic-table/z2-table-visibility.d.ts +7 -0
- package/dist/components/dynamic-table/z2-table.d.ts +59 -0
- package/dist/components/dynamic-table/z2-table.js +408 -0
- package/dist/components/scroll-area/scoll-area.d.ts +5 -0
- package/dist/components/skeleton/skeleton.d.ts +2 -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/routes/data-table.d.ts +2 -0
- package/dist/types/components/dynamic-table/index.d.ts +4 -0
- package/dist/types/components/dynamic-table/util/command.d.ts +18 -0
- package/dist/types/components/dynamic-table/util/seperator.d.ts +4 -0
- package/dist/types/components/dynamic-table/z2-column-header.d.ts +12 -0
- package/dist/types/components/dynamic-table/z2-table-context.d.ts +87 -0
- package/dist/types/components/dynamic-table/z2-table-filter.d.ts +15 -0
- package/dist/types/components/dynamic-table/z2-table-pagination.d.ts +19 -0
- package/dist/types/components/dynamic-table/z2-table-visibility.d.ts +7 -0
- package/dist/types/components/dynamic-table/z2-table.d.ts +59 -0
- package/dist/types/components/scroll-area/scoll-area.d.ts +5 -0
- package/dist/types/components/skeleton/skeleton.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/routes/data-table.d.ts +2 -0
- package/package.json +3 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command as CommandPrimitive } from 'cmdk';
|
|
2
|
+
import { Z2Dialog } from '../../dialog/dialog';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
declare function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function CommandDialog({ title, description, children, className, ...props }: React.ComponentProps<typeof Z2Dialog> & {
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
showCloseButton?: boolean;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare function CommandInput({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Input>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare function CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare function CommandSeparator({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Separator>): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare function CommandShortcut({ className, ...props }: React.ComponentProps<'span'>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, CommandSeparator, };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
3
|
+
declare function Separator({ className, orientation, decorative, ...props }: React.ComponentProps<typeof SeparatorPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export { Separator };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { Column } from '@tanstack/react-table';
|
|
3
|
+
interface Z2TableColumnHeaderProps<TData, TValue> extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
column: Column<TData, TValue>;
|
|
5
|
+
title?: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
pinnable?: boolean;
|
|
8
|
+
filter?: ReactNode;
|
|
9
|
+
visibility?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare function Z2TableColumnHeader<TData, TValue>({ column, title, icon, className, filter, visibility, }: Z2TableColumnHeaderProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export { Z2TableColumnHeader, type Z2TableColumnHeaderProps };
|
|
@@ -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,87 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ColumnFiltersState, RowData, SortingState, Table } from '@tanstack/react-table';
|
|
3
|
+
declare module '@tanstack/react-table' {
|
|
4
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
5
|
+
headerTitle?: string;
|
|
6
|
+
headerClassName?: string;
|
|
7
|
+
cellClassName?: string;
|
|
8
|
+
skeleton?: ReactNode;
|
|
9
|
+
expandedContent?: (row: TData) => ReactNode;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export type Z2TableApiFetchParams = {
|
|
13
|
+
pageIndex: number;
|
|
14
|
+
pageSize: number;
|
|
15
|
+
sorting?: SortingState;
|
|
16
|
+
filters?: ColumnFiltersState;
|
|
17
|
+
searchQuery?: string;
|
|
18
|
+
};
|
|
19
|
+
export type Z2TableApiResponse<T> = {
|
|
20
|
+
data: T[];
|
|
21
|
+
empty: boolean;
|
|
22
|
+
pagination: {
|
|
23
|
+
total: number;
|
|
24
|
+
page: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export interface Z2TableContextProps<TData extends object> {
|
|
28
|
+
props: Z2TableProps<TData>;
|
|
29
|
+
table: Table<TData>;
|
|
30
|
+
recordCount: number;
|
|
31
|
+
isLoading: boolean;
|
|
32
|
+
}
|
|
33
|
+
export type Z2TableRequestParams = {
|
|
34
|
+
pageIndex: number;
|
|
35
|
+
pageSize: number;
|
|
36
|
+
sorting?: SortingState;
|
|
37
|
+
columnFilters?: ColumnFiltersState;
|
|
38
|
+
};
|
|
39
|
+
export interface Z2TableProps<TData extends object> {
|
|
40
|
+
className?: string;
|
|
41
|
+
table?: Table<TData>;
|
|
42
|
+
recordCount: number;
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
onRowClick?: (row: TData) => void;
|
|
45
|
+
isLoading?: boolean;
|
|
46
|
+
loadingMode?: 'skeleton' | 'spinner';
|
|
47
|
+
loadingMessage?: ReactNode | string;
|
|
48
|
+
emptyMessage?: ReactNode | string;
|
|
49
|
+
tableLayout?: {
|
|
50
|
+
dense?: boolean;
|
|
51
|
+
cellBorder?: boolean;
|
|
52
|
+
rowBorder?: boolean;
|
|
53
|
+
rowRounded?: boolean;
|
|
54
|
+
stripped?: boolean;
|
|
55
|
+
headerBackground?: boolean;
|
|
56
|
+
headerBorder?: boolean;
|
|
57
|
+
headerSticky?: boolean;
|
|
58
|
+
width?: 'auto' | 'fixed';
|
|
59
|
+
columnsVisibility?: boolean;
|
|
60
|
+
columnsResizable?: boolean;
|
|
61
|
+
columnsPinnable?: boolean;
|
|
62
|
+
columnsMovable?: boolean;
|
|
63
|
+
columnsDraggable?: boolean;
|
|
64
|
+
rowsDraggable?: boolean;
|
|
65
|
+
};
|
|
66
|
+
tableClassNames?: {
|
|
67
|
+
base?: string;
|
|
68
|
+
header?: string;
|
|
69
|
+
headerRow?: string;
|
|
70
|
+
headerSticky?: string;
|
|
71
|
+
body?: string;
|
|
72
|
+
bodyRow?: string;
|
|
73
|
+
footer?: string;
|
|
74
|
+
edgeCell?: string;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
declare function useZ2Table(): Z2TableContextProps<any>;
|
|
78
|
+
declare function Z2TableProvider<TData extends object>({ children, table, ...props }: Z2TableProps<TData> & {
|
|
79
|
+
table: Table<TData>;
|
|
80
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
81
|
+
declare function Z2TableRoot<TData extends object>({ children, table, ...props }: Z2TableProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
82
|
+
declare function Z2TableContainer({ children, className, border, }: {
|
|
83
|
+
children: ReactNode;
|
|
84
|
+
className?: string;
|
|
85
|
+
border?: boolean;
|
|
86
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
87
|
+
export { useZ2Table, Z2TableProvider, Z2TableRoot, Z2TableContainer };
|
|
@@ -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,15 @@
|
|
|
1
|
+
import { Column } from '@tanstack/react-table';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
interface Z2TableColumnFilterProps<TData, TValue> {
|
|
4
|
+
column?: Column<TData, TValue>;
|
|
5
|
+
title?: string;
|
|
6
|
+
options: {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
icon?: React.ComponentType<{
|
|
10
|
+
className?: string;
|
|
11
|
+
}>;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
declare function Z2TableColumnFilter<TData, TValue>({ column, title, options, }: Z2TableColumnFilterProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export { Z2TableColumnFilter, type Z2TableColumnFilterProps };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface Z2TablePaginationProps {
|
|
3
|
+
sizes?: number[];
|
|
4
|
+
sizesInfo?: string;
|
|
5
|
+
sizesLabel?: string;
|
|
6
|
+
sizesDescription?: string;
|
|
7
|
+
sizesSkeleton?: ReactNode;
|
|
8
|
+
more?: boolean;
|
|
9
|
+
moreLimit?: number;
|
|
10
|
+
info?: string;
|
|
11
|
+
infoSkeleton?: ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
rowsPerPageLabel?: string;
|
|
14
|
+
previousPageLabel?: string;
|
|
15
|
+
nextPageLabel?: string;
|
|
16
|
+
ellipsisText?: string;
|
|
17
|
+
}
|
|
18
|
+
declare function Z2TablePagination(props: Z2TablePaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export { Z2TablePagination, type Z2TablePaginationProps };
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Table } from '@tanstack/react-table';
|
|
3
|
+
declare function Z2TableColumnVisibility<TData>({ table, trigger, }: {
|
|
4
|
+
table: Table<TData>;
|
|
5
|
+
trigger: ReactNode;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export { Z2TableColumnVisibility };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { Cell, Column, Header, HeaderGroup, Row } from '@tanstack/react-table';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
declare function Z2TableBase({ children }: {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function Z2TableHead({ children }: {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare function Z2TableHeadRow<TData>({ children, headerGroup, }: {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
headerGroup: HeaderGroup<TData>;
|
|
13
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare function Z2TableHeadRowCell<TData>({ children, header, dndRef, dndStyle, }: {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
header: Header<TData, unknown>;
|
|
17
|
+
dndRef?: React.Ref<HTMLTableCellElement>;
|
|
18
|
+
dndStyle?: CSSProperties;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare function Z2TableHeadRowCellResize<TData>({ header }: {
|
|
21
|
+
header: Header<TData, unknown>;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
declare function Z2TableRowSpacer(): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
declare function Z2TableBody({ children }: {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
declare function Z2TableBodyRowSkeleton({ children }: {
|
|
28
|
+
children: ReactNode;
|
|
29
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
declare function Z2TableBodyRowSkeletonCell<TData>({ children, column, }: {
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
column: Column<TData>;
|
|
33
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
declare function Z2TableBodyRow<TData>({ children, row, dndRef, dndStyle, }: {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
row: Row<TData>;
|
|
37
|
+
dndRef?: React.Ref<HTMLTableRowElement>;
|
|
38
|
+
dndStyle?: CSSProperties;
|
|
39
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
declare function Z2TableBodyRowExpandded<TData>({ row }: {
|
|
41
|
+
row: Row<TData>;
|
|
42
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
43
|
+
declare function Z2TableBodyRowCell<TData>({ children, cell, dndRef, dndStyle, }: {
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
cell: Cell<TData, unknown>;
|
|
46
|
+
dndRef?: React.Ref<HTMLTableCellElement>;
|
|
47
|
+
dndStyle?: CSSProperties;
|
|
48
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
declare function Z2TableEmpty(): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
declare function Z2TableLoader(): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
declare function Z2TableRowSelect<TData>({ row, }: {
|
|
52
|
+
row: Row<TData>;
|
|
53
|
+
size?: 'sm' | 'md' | 'lg';
|
|
54
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
declare function Z2TableRowSelectAll(_props: {
|
|
56
|
+
size?: 'sm' | 'md' | 'lg';
|
|
57
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
declare function Z2Table<TData>(): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
export { Z2Table, Z2TableBase, Z2TableBody, Z2TableBodyRow, Z2TableBodyRowCell, Z2TableBodyRowExpandded, Z2TableBodyRowSkeleton, Z2TableBodyRowSkeletonCell, Z2TableEmpty, Z2TableHead, Z2TableHeadRow, Z2TableHeadRowCell, Z2TableHeadRowCellResize, Z2TableLoader, Z2TableRowSelect, Z2TableRowSelectAll, Z2TableRowSpacer, };
|