@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.
@@ -13,8 +13,7 @@ function l({
13
13
  fill: "none",
14
14
  stroke: o,
15
15
  strokeLinecap: "round",
16
- strokeLinejoin: "round",
17
- strokeWidth: "2"
16
+ strokeLinejoin: "round"
18
17
  }
19
18
  ) })
20
19
  ] });
@@ -13,8 +13,7 @@ function h({
13
13
  fill: "none",
14
14
  stroke: r,
15
15
  strokeLinecap: "round",
16
- strokeLinejoin: "round",
17
- strokeWidth: "2"
16
+ strokeLinejoin: "round"
18
17
  }
19
18
  ) })
20
19
  ] });
@@ -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 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";
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 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) {
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: n, recordCount: m, isLoading: u } = L(), e = { ...{
12
- sizes: [5, 10, 25, 50, 100],
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(S, { className: "h-8 w-44" }),
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(S, { className: "h-8 w-60" }),
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
- }, ...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
+ 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
- r,
35
+ s,
30
36
  {
31
37
  size: "small",
32
38
  variant: "stroke",
33
- disabled: o === a,
39
+ disabled: i === n,
34
40
  onClick: () => {
35
- o !== a && n.setPageIndex(a);
41
+ i !== n && a.setPageIndex(n);
36
42
  },
37
- leftIcon: a + 1
43
+ leftIcon: n + 1
38
44
  },
39
- a
45
+ n
40
46
  )
41
47
  );
42
- return s;
43
- }, k = () => c > 0 ? /* @__PURE__ */ t(
44
- r,
48
+ return o;
49
+ }, C = () => m > 0 ? /* @__PURE__ */ t(
50
+ s,
45
51
  {
46
52
  size: "small",
47
53
  variant: "stroke",
48
- onClick: () => n.setPageIndex(c - 1),
54
+ onClick: () => a.setPageIndex(m - 1),
49
55
  label: e.ellipsisText
50
56
  }
51
- ) : null, C = () => d < p ? /* @__PURE__ */ t(
52
- r,
57
+ ) : null, k = () => u < d ? /* @__PURE__ */ t(
58
+ s,
53
59
  {
54
60
  variant: "stroke",
55
61
  size: "small",
56
- onClick: () => n.setPageIndex(d),
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: Z(
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: 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: [
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
- r,
115
+ s,
91
116
  {
92
117
  size: "small",
93
118
  variant: "stroke",
94
- className: g,
95
- onClick: () => n.previousPage(),
96
- disabled: !n.getCanPreviousPage(),
97
- leftIcon: /* @__PURE__ */ t(P, { className: "size-full" }),
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
- r,
154
+ s,
106
155
  {
107
156
  size: "small",
108
157
  variant: "stroke",
109
- className: g,
110
- onClick: () => n.nextPage(),
111
- disabled: !n.getCanNextPage(),
112
- leftIcon: /* @__PURE__ */ t(I, { className: "size-full" }),
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
- H as Z2TablePagination
172
+ X as Z2TablePagination
124
173
  };