@zentauri-ui/zentauri-components 1.5.22 → 1.5.31

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.
Files changed (77) hide show
  1. package/README.md +59 -2
  2. package/cli/registry.json +2 -0
  3. package/dist/chunk-7OHC4ERB.mjs +60 -0
  4. package/dist/chunk-7OHC4ERB.mjs.map +1 -0
  5. package/dist/{chunk-2VQJ6OIL.js → chunk-HPN7H5ZM.js} +2 -2
  6. package/dist/{chunk-2VQJ6OIL.js.map → chunk-HPN7H5ZM.js.map} +1 -1
  7. package/dist/chunk-JJDANNNL.mjs +71 -0
  8. package/dist/chunk-JJDANNNL.mjs.map +1 -0
  9. package/dist/chunk-KXUG4WVW.js +62 -0
  10. package/dist/chunk-KXUG4WVW.js.map +1 -0
  11. package/dist/chunk-MEJMX4QI.js +73 -0
  12. package/dist/chunk-MEJMX4QI.js.map +1 -0
  13. package/dist/chunk-N6B35KWW.mjs +3 -0
  14. package/dist/chunk-N6B35KWW.mjs.map +1 -0
  15. package/dist/{chunk-73VCO5TE.mjs → chunk-NWOE2TZN.mjs} +2 -2
  16. package/dist/{chunk-73VCO5TE.mjs.map → chunk-NWOE2TZN.mjs.map} +1 -1
  17. package/dist/chunk-RGOMHX4G.js +4 -0
  18. package/dist/chunk-RGOMHX4G.js.map +1 -0
  19. package/dist/hooks/useControllableState.js +3 -2
  20. package/dist/hooks/useControllableState.mjs +2 -1
  21. package/dist/hooks/useDisclosure.js +3 -2
  22. package/dist/hooks/useDisclosure.js.map +1 -1
  23. package/dist/hooks/useDisclosure.mjs +2 -1
  24. package/dist/hooks/useDisclosure.mjs.map +1 -1
  25. package/dist/hooks/useDynamicStepper/index.d.ts +2 -0
  26. package/dist/hooks/useDynamicStepper/index.d.ts.map +1 -0
  27. package/dist/hooks/useDynamicStepper/useDynamicStepper.d.ts +9 -0
  28. package/dist/hooks/useDynamicStepper/useDynamicStepper.d.ts.map +1 -0
  29. package/dist/hooks/useDynamicStepper.js +14 -0
  30. package/dist/hooks/useDynamicStepper.js.map +1 -0
  31. package/dist/hooks/useDynamicStepper.mjs +5 -0
  32. package/dist/hooks/useDynamicStepper.mjs.map +1 -0
  33. package/dist/ui/buttons.js +7 -55
  34. package/dist/ui/buttons.js.map +1 -1
  35. package/dist/ui/buttons.mjs +2 -58
  36. package/dist/ui/buttons.mjs.map +1 -1
  37. package/dist/ui/dynamic-stepper/dynamic-stepper.d.ts +6 -0
  38. package/dist/ui/dynamic-stepper/dynamic-stepper.d.ts.map +1 -0
  39. package/dist/ui/dynamic-stepper/index.d.ts +5 -0
  40. package/dist/ui/dynamic-stepper/index.d.ts.map +1 -0
  41. package/dist/ui/dynamic-stepper/types.d.ts +61 -0
  42. package/dist/ui/dynamic-stepper/types.d.ts.map +1 -0
  43. package/dist/ui/dynamic-stepper/variants.d.ts +21 -0
  44. package/dist/ui/dynamic-stepper/variants.d.ts.map +1 -0
  45. package/dist/ui/dynamic-stepper.js +312 -0
  46. package/dist/ui/dynamic-stepper.js.map +1 -0
  47. package/dist/ui/dynamic-stepper.mjs +305 -0
  48. package/dist/ui/dynamic-stepper.mjs.map +1 -0
  49. package/dist/ui/pagination/pagination.d.ts +5 -16
  50. package/dist/ui/pagination/pagination.d.ts.map +1 -1
  51. package/dist/ui/pagination/types.d.ts +2 -2
  52. package/dist/ui/pagination/types.d.ts.map +1 -1
  53. package/dist/ui/pagination.js +171 -180
  54. package/dist/ui/pagination.js.map +1 -1
  55. package/dist/ui/pagination.mjs +172 -181
  56. package/dist/ui/pagination.mjs.map +1 -1
  57. package/dist/ui/typography/blockquote-base.d.ts.map +1 -1
  58. package/dist/ui/typography/code-block-base.d.ts.map +1 -1
  59. package/dist/ui/typography/heading-base.d.ts.map +1 -1
  60. package/dist/ui/typography/inline-code-base.d.ts.map +1 -1
  61. package/dist/ui/typography.js.map +1 -1
  62. package/dist/ui/typography.mjs.map +1 -1
  63. package/package.json +1 -1
  64. package/src/hooks/useDynamicStepper/index.ts +3 -0
  65. package/src/hooks/useDynamicStepper/useDynamicStepper.test.ts +107 -0
  66. package/src/hooks/useDynamicStepper/useDynamicStepper.ts +91 -0
  67. package/src/ui/dynamic-stepper/dynamic-stepper.test.tsx +109 -0
  68. package/src/ui/dynamic-stepper/dynamic-stepper.tsx +173 -0
  69. package/src/ui/dynamic-stepper/index.ts +24 -0
  70. package/src/ui/dynamic-stepper/types.ts +85 -0
  71. package/src/ui/dynamic-stepper/variants.ts +238 -0
  72. package/src/ui/pagination/pagination.tsx +186 -197
  73. package/src/ui/pagination/types.ts +2 -2
  74. package/src/ui/typography/blockquote-base.tsx +0 -2
  75. package/src/ui/typography/code-block-base.tsx +0 -2
  76. package/src/ui/typography/heading-base.tsx +0 -2
  77. package/src/ui/typography/inline-code-base.tsx +0 -2
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { forwardRef, useCallback, useId, type KeyboardEvent } from "react";
3
+ import { useCallback, useId, type KeyboardEvent } from "react";
4
4
 
5
5
  import { cn, clampPage } from "../../lib/utils";
6
6
  import { buttonVariants } from "../buttons/variants";
@@ -13,40 +13,30 @@ const defaultPrevLabel = "Previous page";
13
13
  const defaultNextLabel = "Next page";
14
14
  const defaultEllipsisLabel = "More pages";
15
15
 
16
- export const Pagination = forwardRef<HTMLElement, PaginationProps>(
17
- function Pagination(
18
- {
19
- className,
20
- appearance = "default",
21
- size = "md",
22
- pageCount,
23
- page,
24
- defaultPage = 1,
25
- onPageChange,
26
- siblingCount = 1,
27
- boundaryCount = 1,
28
- showPrevNext = true,
29
- prevLabel = defaultPrevLabel,
30
- nextLabel = defaultNextLabel,
31
- ellipsisLabel = defaultEllipsisLabel,
32
- getPageHref,
33
- "aria-label": ariaLabel = "Pagination",
34
- ...rest
35
- },
36
- ref,
37
- ) {
38
- const id = useId();
39
- const listId = `${id}-list`;
40
-
41
- const {
42
- currentPage,
43
- items,
44
- setPage,
45
- goPrev,
46
- goNext,
47
- canGoPrev,
48
- canGoNext,
49
- } = usePagination({
16
+ export const Pagination = ({
17
+ className,
18
+ appearance = "default",
19
+ size = "md",
20
+ pageCount,
21
+ page,
22
+ defaultPage = 1,
23
+ onPageChange,
24
+ siblingCount = 1,
25
+ boundaryCount = 1,
26
+ showPrevNext = true,
27
+ prevLabel = defaultPrevLabel,
28
+ nextLabel = defaultNextLabel,
29
+ ellipsisLabel = defaultEllipsisLabel,
30
+ getPageHref,
31
+ "aria-label": ariaLabel = "Pagination",
32
+ ref,
33
+ ...rest
34
+ }: PaginationProps) => {
35
+ const id = useId();
36
+ const listId = `${id}-list`;
37
+
38
+ const { currentPage, items, setPage, goPrev, goNext, canGoPrev, canGoNext } =
39
+ usePagination({
50
40
  pageCount,
51
41
  page,
52
42
  defaultPage,
@@ -55,183 +45,182 @@ export const Pagination = forwardRef<HTMLElement, PaginationProps>(
55
45
  onPageChange,
56
46
  });
57
47
 
58
- const handleKeyDown = useCallback(
59
- (event: KeyboardEvent<HTMLElement>) => {
60
- if (pageCount <= 0) {
61
- return;
48
+ const handleKeyDown = useCallback(
49
+ (event: KeyboardEvent<HTMLElement>) => {
50
+ if (pageCount <= 0) {
51
+ return;
52
+ }
53
+ if (event.key === "ArrowRight" || event.key === "ArrowDown") {
54
+ event.preventDefault();
55
+ if (canGoNext) {
56
+ setPage(currentPage + 1);
62
57
  }
63
- if (event.key === "ArrowRight" || event.key === "ArrowDown") {
64
- event.preventDefault();
65
- if (canGoNext) {
66
- setPage(currentPage + 1);
67
- }
68
- } else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
69
- event.preventDefault();
70
- if (canGoPrev) {
71
- setPage(currentPage - 1);
72
- }
73
- } else if (event.key === "Home") {
74
- event.preventDefault();
75
- setPage(1);
76
- } else if (event.key === "End") {
77
- event.preventDefault();
78
- setPage(pageCount);
58
+ } else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
59
+ event.preventDefault();
60
+ if (canGoPrev) {
61
+ setPage(currentPage - 1);
79
62
  }
80
- },
81
- [canGoNext, canGoPrev, currentPage, pageCount, setPage],
82
- );
83
-
84
- if (pageCount <= 0) {
85
- return null;
86
- }
87
-
88
- const inactiveTriggerClass = cn(
89
- buttonVariants({ appearance: "ghost", size }),
90
- "bg-white/[0.04] text-slate-200 hover:bg-white/10",
91
- );
92
-
93
- const currentTriggerClass = buttonVariants({ appearance, size });
94
-
95
- const triggerFocusRing =
96
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-300 focus-visible:ring-offset-2 focus-visible:ring-offset-slate-950";
97
-
98
- const renderPageControl = (pageNumber: number) => {
99
- const isCurrent = pageNumber === currentPage;
100
- const href = getPageHref?.(pageNumber);
101
- const shared = cn(
102
- isCurrent ? currentTriggerClass : inactiveTriggerClass,
103
- "min-w-[2.25ch] shrink-0",
104
- triggerFocusRing,
105
- );
106
-
107
- if (href) {
108
- return (
109
- <a
110
- data-slot="pagination-trigger"
111
- href={href}
112
- aria-label={`Page ${pageNumber}`}
113
- aria-current={isCurrent ? "page" : undefined}
114
- className={shared}
115
- >
116
- {pageNumber}
117
- </a>
118
- );
63
+ } else if (event.key === "Home") {
64
+ event.preventDefault();
65
+ setPage(1);
66
+ } else if (event.key === "End") {
67
+ event.preventDefault();
68
+ setPage(pageCount);
119
69
  }
70
+ },
71
+ [canGoNext, canGoPrev, currentPage, pageCount, setPage],
72
+ );
73
+
74
+ if (pageCount <= 0) {
75
+ return null;
76
+ }
77
+
78
+ const inactiveTriggerClass = cn(
79
+ buttonVariants({ appearance: "ghost", size }),
80
+ "bg-white/[0.04] text-slate-200 hover:bg-white/10",
81
+ );
82
+
83
+ const currentTriggerClass = buttonVariants({ appearance, size });
84
+
85
+ const triggerFocusRing =
86
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-300 focus-visible:ring-offset-2 focus-visible:ring-offset-slate-950";
87
+
88
+ const renderPageControl = (pageNumber: number) => {
89
+ const isCurrent = pageNumber === currentPage;
90
+ const href = getPageHref?.(pageNumber);
91
+ const shared = cn(
92
+ isCurrent ? currentTriggerClass : inactiveTriggerClass,
93
+ "min-w-[2.25ch] shrink-0",
94
+ triggerFocusRing,
95
+ );
120
96
 
97
+ if (href) {
121
98
  return (
122
- <button
123
- type="button"
99
+ <a
124
100
  data-slot="pagination-trigger"
101
+ href={href}
125
102
  aria-label={`Page ${pageNumber}`}
126
103
  aria-current={isCurrent ? "page" : undefined}
127
104
  className={shared}
128
- onClick={() => {
129
- if (!isCurrent) {
130
- setPage(pageNumber);
131
- }
132
- }}
133
105
  >
134
106
  {pageNumber}
135
- </button>
107
+ </a>
136
108
  );
137
- };
138
-
139
- const prevHref = getPageHref?.(clampPage(currentPage - 1, pageCount));
140
- const nextHref = getPageHref?.(clampPage(currentPage + 1, pageCount));
141
-
142
- const navTriggerClass = cn(
143
- buttonVariants({ appearance: "outline", size }),
144
- "shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-300 focus-visible:ring-offset-2 focus-visible:ring-offset-slate-950",
145
- );
109
+ }
146
110
 
147
111
  return (
148
- <nav
149
- ref={ref}
150
- data-slot="pagination"
151
- aria-label={ariaLabel}
152
- className={cn("w-full", className)}
153
- onKeyDown={handleKeyDown}
154
- {...rest}
112
+ <button
113
+ type="button"
114
+ data-slot="pagination-trigger"
115
+ aria-label={`Page ${pageNumber}`}
116
+ aria-current={isCurrent ? "page" : undefined}
117
+ className={shared}
118
+ onClick={() => {
119
+ if (!isCurrent) {
120
+ setPage(pageNumber);
121
+ }
122
+ }}
155
123
  >
156
- <div className="flex flex-wrap items-center gap-2">
157
- {showPrevNext ? (
158
- getPageHref && prevHref && canGoPrev ? (
159
- <a
160
- data-slot="pagination-prev"
161
- aria-label={prevLabel}
162
- href={prevHref}
163
- className={navTriggerClass}
164
- >
165
- Prev
166
- </a>
167
- ) : (
168
- <button
169
- type="button"
170
- data-slot="pagination-prev"
171
- aria-label={prevLabel}
172
- disabled={!canGoPrev}
173
- className={navTriggerClass}
174
- onClick={goPrev}
175
- >
176
- Prev
177
- </button>
178
- )
179
- ) : null}
180
-
181
- <ul
182
- id={listId}
183
- data-slot="pagination-list"
184
- className={paginationListVariants({ appearance, size })}
185
- >
186
- {items.map((item) => (
187
- <li
188
- key={item.type === "page" ? `page-${item.value}` : item.key}
189
- data-slot="pagination-item"
190
- className="inline-flex items-center"
191
- >
192
- {item.type === "ellipsis" ? (
193
- <span
194
- data-slot="pagination-ellipsis"
195
- className={paginationEllipsisVariants({ size })}
196
- role="img"
197
- aria-label={ellipsisLabel}
198
- >
199
-
200
- </span>
201
- ) : (
202
- renderPageControl(item.value)
203
- )}
204
- </li>
205
- ))}
206
- </ul>
207
-
208
- {showPrevNext ? (
209
- getPageHref && nextHref && canGoNext ? (
210
- <a
211
- data-slot="pagination-next"
212
- aria-label={nextLabel}
213
- href={nextHref}
214
- className={navTriggerClass}
215
- >
216
- Next
217
- </a>
218
- ) : (
219
- <button
220
- type="button"
221
- data-slot="pagination-next"
222
- aria-label={nextLabel}
223
- disabled={!canGoNext}
224
- className={navTriggerClass}
225
- onClick={goNext}
226
- >
227
- Next
228
- </button>
229
- )
230
- ) : null}
231
- </div>
232
- </nav>
124
+ {pageNumber}
125
+ </button>
233
126
  );
234
- },
235
- );
127
+ };
128
+
129
+ const prevHref = getPageHref?.(clampPage(currentPage - 1, pageCount));
130
+ const nextHref = getPageHref?.(clampPage(currentPage + 1, pageCount));
131
+
132
+ const navTriggerClass = cn(
133
+ buttonVariants({ appearance: "outline", size }),
134
+ "shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-300 focus-visible:ring-offset-2 focus-visible:ring-offset-slate-950",
135
+ );
136
+
137
+ return (
138
+ <nav
139
+ ref={ref}
140
+ data-slot="pagination"
141
+ aria-label={ariaLabel}
142
+ className={cn("w-full", className)}
143
+ onKeyDown={handleKeyDown}
144
+ {...rest}
145
+ >
146
+ <div className="flex flex-wrap items-center gap-2">
147
+ {showPrevNext ? (
148
+ getPageHref && prevHref && canGoPrev ? (
149
+ <a
150
+ data-slot="pagination-prev"
151
+ aria-label={prevLabel}
152
+ href={prevHref}
153
+ className={navTriggerClass}
154
+ >
155
+ Prev
156
+ </a>
157
+ ) : (
158
+ <button
159
+ type="button"
160
+ data-slot="pagination-prev"
161
+ aria-label={prevLabel}
162
+ disabled={!canGoPrev}
163
+ className={navTriggerClass}
164
+ onClick={goPrev}
165
+ >
166
+ Prev
167
+ </button>
168
+ )
169
+ ) : null}
170
+
171
+ <ul
172
+ id={listId}
173
+ data-slot="pagination-list"
174
+ className={paginationListVariants({ appearance, size })}
175
+ >
176
+ {items.map((item) => (
177
+ <li
178
+ key={item.type === "page" ? `page-${item.value}` : item.key}
179
+ data-slot="pagination-item"
180
+ className="inline-flex items-center"
181
+ >
182
+ {item.type === "ellipsis" ? (
183
+ <span
184
+ data-slot="pagination-ellipsis"
185
+ className={paginationEllipsisVariants({ size })}
186
+ role="img"
187
+ aria-label={ellipsisLabel}
188
+ >
189
+
190
+ </span>
191
+ ) : (
192
+ renderPageControl(item.value)
193
+ )}
194
+ </li>
195
+ ))}
196
+ </ul>
197
+
198
+ {showPrevNext ? (
199
+ getPageHref && nextHref && canGoNext ? (
200
+ <a
201
+ data-slot="pagination-next"
202
+ aria-label={nextLabel}
203
+ href={nextHref}
204
+ className={navTriggerClass}
205
+ >
206
+ Next
207
+ </a>
208
+ ) : (
209
+ <button
210
+ type="button"
211
+ data-slot="pagination-next"
212
+ aria-label={nextLabel}
213
+ disabled={!canGoNext}
214
+ className={navTriggerClass}
215
+ onClick={goNext}
216
+ >
217
+ Next
218
+ </button>
219
+ )
220
+ ) : null}
221
+ </div>
222
+ </nav>
223
+ );
224
+ };
236
225
 
237
226
  Pagination.displayName = "Pagination";
@@ -1,5 +1,5 @@
1
1
  import type { VariantProps } from "class-variance-authority";
2
- import type { ComponentPropsWithoutRef } from "react";
2
+ import type { ComponentPropsWithRef } from "react";
3
3
 
4
4
  import type { buttonVariants } from "../buttons/variants";
5
5
 
@@ -37,7 +37,7 @@ export type UsePaginationResult = {
37
37
  };
38
38
 
39
39
  export type PaginationProps = Omit<
40
- ComponentPropsWithoutRef<"nav">,
40
+ ComponentPropsWithRef<"nav">,
41
41
  "onChange"
42
42
  > &
43
43
  VariantProps<typeof buttonVariants> & {
@@ -1,5 +1,3 @@
1
- import { forwardRef } from "react";
2
-
3
1
  import { cn } from "../../lib/utils";
4
2
 
5
3
  import type { BlockquoteProps } from "./types";
@@ -1,5 +1,3 @@
1
- import { forwardRef } from "react";
2
-
3
1
  import { cn } from "../../lib/utils";
4
2
 
5
3
  import type { CodeBlockProps } from "./types";
@@ -1,5 +1,3 @@
1
- import { forwardRef } from "react";
2
-
3
1
  import { cn } from "../../lib/utils";
4
2
 
5
3
  import type { HeadingProps } from "./types";
@@ -1,5 +1,3 @@
1
- import { forwardRef } from "react";
2
-
3
1
  import { cn } from "../../lib/utils";
4
2
 
5
3
  import type { InlineCodeProps } from "./types";