@ztwoint/z-ui 0.1.116 → 0.1.117
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/double-chevron-left.js +1 -2
- package/dist/components/assets/icons/double-chevron-right.js +1 -2
- package/dist/components/dynamic-table/z2-table-pagination.d.ts +2 -0
- package/dist/components/dynamic-table/z2-table-pagination.js +113 -64
- package/dist/components/dynamic-table/z2-table.js +162 -137
- package/dist/components/skeleton/skeleton.js +5 -5
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/types/components/dynamic-table/z2-table-pagination.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
interface Z2TablePaginationProps {
|
|
3
|
+
showSizeToggle?: boolean;
|
|
3
4
|
sizes?: number[];
|
|
4
5
|
sizesInfo?: string;
|
|
5
6
|
sizesLabel?: string;
|
|
@@ -14,6 +15,7 @@ interface Z2TablePaginationProps {
|
|
|
14
15
|
previousPageLabel?: string;
|
|
15
16
|
nextPageLabel?: string;
|
|
16
17
|
ellipsisText?: string;
|
|
18
|
+
showGoToPage?: boolean;
|
|
17
19
|
}
|
|
18
20
|
declare function Z2TablePagination(props: Z2TablePaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
19
21
|
export { Z2TablePagination, type Z2TablePaginationProps };
|
|
@@ -1,59 +1,65 @@
|
|
|
1
|
-
import { jsx as t, jsxs as l, Fragment as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Button as r } from "../button/button.js";
|
|
1
|
+
import { jsx as t, jsxs as l, Fragment as f } from "react/jsx-runtime";
|
|
2
|
+
import { useZ2Table as z } from "./z2-table-context.js";
|
|
3
|
+
import { Z2Skeleton as N } from "../skeleton/skeleton.js";
|
|
4
|
+
import { Button as s } from "../button/button.js";
|
|
6
5
|
import "react";
|
|
7
|
-
import { cn as
|
|
8
|
-
import { Z2Select as
|
|
9
|
-
|
|
6
|
+
import { cn as I } from "../../lib/utils.js";
|
|
7
|
+
import { Z2Select as L, Z2SelectTrigger as y, Z2SelectValue as T, Z2SelectContent as Z, Z2SelectItem as G } from "../select/z2-select.js";
|
|
8
|
+
import $ from "../assets/icons/double-chevron-left.js";
|
|
9
|
+
import j from "../assets/icons/double-chevron-right.js";
|
|
10
|
+
import B from "../assets/icons/chevron-left.js";
|
|
11
|
+
import M from "../assets/icons/chevron-right.js";
|
|
12
|
+
import { Input as D } from "../input/input.js";
|
|
13
|
+
function X(P) {
|
|
10
14
|
var b;
|
|
11
|
-
const { table:
|
|
12
|
-
|
|
15
|
+
const { table: a, recordCount: g, isLoading: h } = z(), e = { ...{
|
|
16
|
+
showSizeToggle: !1,
|
|
17
|
+
sizes: [25, 50, 100],
|
|
13
18
|
sizesLabel: "Show",
|
|
14
19
|
sizesDescription: "per page",
|
|
15
|
-
sizesSkeleton: /* @__PURE__ */ t(
|
|
20
|
+
sizesSkeleton: /* @__PURE__ */ t(N, { className: "h-6 w-44" }),
|
|
16
21
|
moreLimit: 5,
|
|
17
22
|
more: !1,
|
|
18
|
-
info: "{from} - {to} of {count}",
|
|
19
|
-
infoSkeleton: /* @__PURE__ */ t(
|
|
23
|
+
info: "Viewing {from} - {to} out of {count}",
|
|
24
|
+
infoSkeleton: /* @__PURE__ */ t(N, { className: "h-6 w-32" }),
|
|
20
25
|
rowsPerPageLabel: "Rows per page",
|
|
21
26
|
previousPageLabel: "Go to previous page",
|
|
22
27
|
nextPageLabel: "Go to next page",
|
|
23
|
-
ellipsisText: "..."
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
ellipsisText: "...",
|
|
29
|
+
showGoToPage: !1
|
|
30
|
+
}, ...P }, r = " rtl:transform rtl:rotate-180", i = a.getState().pagination.pageIndex, c = a.getState().pagination.pageSize, x = i * c + 1, v = Math.min((i + 1) * c, g), d = a.getPageCount(), w = e != null && e.info ? e.info.replace("{from}", x.toString()).replace("{to}", v.toString()).replace("{count}", g.toString()) : `${x} - ${v} of ${g}`, p = (e == null ? void 0 : e.moreLimit) || 5, m = Math.floor(i / p) * p, u = Math.min(m + p, d), S = () => {
|
|
31
|
+
const o = [];
|
|
32
|
+
for (let n = m; n < u; n++)
|
|
33
|
+
o.push(
|
|
28
34
|
/* @__PURE__ */ t(
|
|
29
|
-
|
|
35
|
+
s,
|
|
30
36
|
{
|
|
31
37
|
size: "small",
|
|
32
38
|
variant: "stroke",
|
|
33
|
-
disabled:
|
|
39
|
+
disabled: i === n,
|
|
34
40
|
onClick: () => {
|
|
35
|
-
|
|
41
|
+
i !== n && a.setPageIndex(n);
|
|
36
42
|
},
|
|
37
|
-
leftIcon:
|
|
43
|
+
leftIcon: n + 1
|
|
38
44
|
},
|
|
39
|
-
|
|
45
|
+
n
|
|
40
46
|
)
|
|
41
47
|
);
|
|
42
|
-
return
|
|
43
|
-
},
|
|
44
|
-
|
|
48
|
+
return o;
|
|
49
|
+
}, C = () => m > 0 ? /* @__PURE__ */ t(
|
|
50
|
+
s,
|
|
45
51
|
{
|
|
46
52
|
size: "small",
|
|
47
53
|
variant: "stroke",
|
|
48
|
-
onClick: () =>
|
|
54
|
+
onClick: () => a.setPageIndex(m - 1),
|
|
49
55
|
label: e.ellipsisText
|
|
50
56
|
}
|
|
51
|
-
) : null,
|
|
52
|
-
|
|
57
|
+
) : null, k = () => u < d ? /* @__PURE__ */ t(
|
|
58
|
+
s,
|
|
53
59
|
{
|
|
54
60
|
variant: "stroke",
|
|
55
61
|
size: "small",
|
|
56
|
-
onClick: () =>
|
|
62
|
+
onClick: () => a.setPageIndex(u),
|
|
57
63
|
label: e.ellipsisText
|
|
58
64
|
}
|
|
59
65
|
) : null;
|
|
@@ -61,55 +67,98 @@ function H(N) {
|
|
|
61
67
|
"div",
|
|
62
68
|
{
|
|
63
69
|
"data-slot": "data-grid-pagination",
|
|
64
|
-
className:
|
|
70
|
+
className: I(
|
|
65
71
|
"flex flex-wrap flex-col sm:flex-row justify-between items-center gap-2.5 py-2.5 sm:py-0 grow",
|
|
66
72
|
e == null ? void 0 : e.className
|
|
67
73
|
),
|
|
68
74
|
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:
|
|
70
|
-
|
|
71
|
-
/* @__PURE__ */ l(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
/* @__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: h ? e == null ? void 0 : e.infoSkeleton : /* @__PURE__ */ t(f, { children: /* @__PURE__ */ t("div", { className: "leading-none-medium-sm text-neutral-secondary text-nowrap", children: w }) }) }),
|
|
76
|
+
/* @__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: h ? e == null ? void 0 : e.sizesSkeleton : /* @__PURE__ */ l(f, { children: [
|
|
77
|
+
e.showSizeToggle && /* @__PURE__ */ l(f, { children: [
|
|
78
|
+
/* @__PURE__ */ t("div", { className: "leading-none-medium-sm text-neutral-secondary", children: e.rowsPerPageLabel }),
|
|
79
|
+
/* @__PURE__ */ l(
|
|
80
|
+
L,
|
|
81
|
+
{
|
|
82
|
+
value: `${c}`,
|
|
83
|
+
onValueChange: (o) => {
|
|
84
|
+
const n = Number(o);
|
|
85
|
+
a.setPageSize(n);
|
|
86
|
+
},
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ t(y, { className: "w-fit", size: "sm", children: /* @__PURE__ */ t(T, { placeholder: `${c}` }) }),
|
|
89
|
+
/* @__PURE__ */ t(Z, { side: "top", className: "min-w-[50px]", children: (b = e == null ? void 0 : e.sizes) == null ? void 0 : b.map((o) => /* @__PURE__ */ t(G, { value: `${o}`, children: o }, o)) })
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
] }),
|
|
94
|
+
e.showGoToPage && /* @__PURE__ */ l("div", { className: "leading-none-medium-sm text-neutral-secondary text-nowrap order-2 sm:order-1 flex items-center gap-1", children: [
|
|
95
|
+
"Go to page:",
|
|
96
|
+
" ",
|
|
97
|
+
/* @__PURE__ */ t(
|
|
98
|
+
D,
|
|
99
|
+
{
|
|
100
|
+
size: "small",
|
|
101
|
+
className: "w-10",
|
|
102
|
+
type: "number",
|
|
103
|
+
min: 1,
|
|
104
|
+
placeholder: `${a.getState().pagination.pageIndex + 1}`,
|
|
105
|
+
max: a.getPageCount(),
|
|
106
|
+
onBlur: (o) => {
|
|
107
|
+
let n = Number(o.target.value);
|
|
108
|
+
n = n - 1, n <= a.getPageCount() && a.setPageIndex(n);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] }),
|
|
113
|
+
d > 1 && /* @__PURE__ */ l("div", { className: "flex items-center space-x-1 order-1 sm:order-2", children: [
|
|
89
114
|
/* @__PURE__ */ t(
|
|
90
|
-
|
|
115
|
+
s,
|
|
91
116
|
{
|
|
92
117
|
size: "small",
|
|
93
118
|
variant: "stroke",
|
|
94
|
-
className:
|
|
95
|
-
onClick: () =>
|
|
96
|
-
disabled: !
|
|
97
|
-
leftIcon: /* @__PURE__ */ t(
|
|
119
|
+
className: r,
|
|
120
|
+
onClick: () => a.firstPage(),
|
|
121
|
+
disabled: !a.getCanPreviousPage(),
|
|
122
|
+
leftIcon: /* @__PURE__ */ t($, {}),
|
|
123
|
+
children: /* @__PURE__ */ t("span", { className: "sr-only", children: e.previousPageLabel })
|
|
124
|
+
}
|
|
125
|
+
),
|
|
126
|
+
/* @__PURE__ */ t(
|
|
127
|
+
s,
|
|
128
|
+
{
|
|
129
|
+
size: "small",
|
|
130
|
+
variant: "stroke",
|
|
131
|
+
className: r,
|
|
132
|
+
onClick: () => a.previousPage(),
|
|
133
|
+
disabled: !a.getCanPreviousPage(),
|
|
134
|
+
leftIcon: /* @__PURE__ */ t(B, {}),
|
|
98
135
|
children: /* @__PURE__ */ t("span", { className: "sr-only", children: e.previousPageLabel })
|
|
99
136
|
}
|
|
100
137
|
),
|
|
101
|
-
k(),
|
|
102
|
-
z(),
|
|
103
138
|
C(),
|
|
139
|
+
S(),
|
|
140
|
+
k(),
|
|
141
|
+
/* @__PURE__ */ t(
|
|
142
|
+
s,
|
|
143
|
+
{
|
|
144
|
+
size: "small",
|
|
145
|
+
variant: "stroke",
|
|
146
|
+
className: r,
|
|
147
|
+
onClick: () => a.nextPage(),
|
|
148
|
+
disabled: !a.getCanNextPage(),
|
|
149
|
+
leftIcon: /* @__PURE__ */ t(M, {}),
|
|
150
|
+
children: /* @__PURE__ */ t("span", { className: "sr-only", children: e.nextPageLabel })
|
|
151
|
+
}
|
|
152
|
+
),
|
|
104
153
|
/* @__PURE__ */ t(
|
|
105
|
-
|
|
154
|
+
s,
|
|
106
155
|
{
|
|
107
156
|
size: "small",
|
|
108
157
|
variant: "stroke",
|
|
109
|
-
className:
|
|
110
|
-
onClick: () =>
|
|
111
|
-
disabled: !
|
|
112
|
-
leftIcon: /* @__PURE__ */ t(
|
|
158
|
+
className: r,
|
|
159
|
+
onClick: () => a.lastPage(),
|
|
160
|
+
disabled: !a.getCanNextPage(),
|
|
161
|
+
leftIcon: /* @__PURE__ */ t(j, {}),
|
|
113
162
|
children: /* @__PURE__ */ t("span", { className: "sr-only", children: e.nextPageLabel })
|
|
114
163
|
}
|
|
115
164
|
)
|
|
@@ -120,5 +169,5 @@ function H(N) {
|
|
|
120
169
|
);
|
|
121
170
|
}
|
|
122
171
|
export {
|
|
123
|
-
|
|
172
|
+
X as Z2TablePagination
|
|
124
173
|
};
|