banhaten 0.1.0

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 (201) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +361 -0
  3. package/banhaten.config.example.json +13 -0
  4. package/package.json +59 -0
  5. package/registry/assets/activity-feed-avatar.png +0 -0
  6. package/registry/assets/avatars/avatar-01.jpg +0 -0
  7. package/registry/assets/avatars/avatar-02.jpg +0 -0
  8. package/registry/assets/avatars/avatar-03.jpg +0 -0
  9. package/registry/assets/avatars/avatar-04.jpg +0 -0
  10. package/registry/assets/avatars/avatar-05.jpg +0 -0
  11. package/registry/assets/avatars/avatar-06.jpg +0 -0
  12. package/registry/assets/avatars/avatar-07.jpg +0 -0
  13. package/registry/assets/avatars/avatar-08.jpg +0 -0
  14. package/registry/assets/avatars/avatar-09.jpg +0 -0
  15. package/registry/assets/avatars/avatar-10.jpg +0 -0
  16. package/registry/assets/avatars/avatar-11.jpg +0 -0
  17. package/registry/assets/avatars/avatar-12.jpg +0 -0
  18. package/registry/assets/avatars/avatar-13.jpg +0 -0
  19. package/registry/assets/avatars/avatar-14.jpg +0 -0
  20. package/registry/assets/avatars/avatar-15.jpg +0 -0
  21. package/registry/assets/avatars/avatar-16.jpg +0 -0
  22. package/registry/assets/avatars/avatar-17.jpg +0 -0
  23. package/registry/assets/avatars/avatar-18.jpg +0 -0
  24. package/registry/assets/avatars/avatar-19.jpg +0 -0
  25. package/registry/assets/avatars/avatar-20.jpg +0 -0
  26. package/registry/assets/avatars/avatar-21.jpg +0 -0
  27. package/registry/assets/avatars/avatar-22.jpg +0 -0
  28. package/registry/assets/avatars/avatar-23.jpg +0 -0
  29. package/registry/assets/avatars/avatar-24.jpg +0 -0
  30. package/registry/assets/avatars/avatar-25.jpg +0 -0
  31. package/registry/assets/avatars/avatar-26.jpg +0 -0
  32. package/registry/assets/avatars/avatar-27.jpg +0 -0
  33. package/registry/assets/avatars/avatar-28.jpg +0 -0
  34. package/registry/assets/avatars/avatar-29.jpg +0 -0
  35. package/registry/assets/avatars/avatar-30.jpg +0 -0
  36. package/registry/assets/avatars/avatar-31.jpg +0 -0
  37. package/registry/assets/avatars/avatar-32.jpg +0 -0
  38. package/registry/assets/avatars/avatar-33.jpg +0 -0
  39. package/registry/assets/avatars/avatar-34.jpg +0 -0
  40. package/registry/assets/avatars/avatar-35.jpg +0 -0
  41. package/registry/assets/image-assets.json +744 -0
  42. package/registry/assets/images/art-01.jpg +0 -0
  43. package/registry/assets/images/art-02.jpg +0 -0
  44. package/registry/assets/images/art-03.jpg +0 -0
  45. package/registry/assets/images/art-04.jpg +0 -0
  46. package/registry/assets/images/art-05.jpg +0 -0
  47. package/registry/assets/images/art-06.jpg +0 -0
  48. package/registry/assets/images/art-07.jpg +0 -0
  49. package/registry/assets/images/art-08.jpg +0 -0
  50. package/registry/assets/images/art-09.jpg +0 -0
  51. package/registry/assets/images/art-10.jpg +0 -0
  52. package/registry/assets/images/art-11.jpg +0 -0
  53. package/registry/assets/images/art-12.jpg +0 -0
  54. package/registry/assets/images/art-13.jpg +0 -0
  55. package/registry/assets/images/art-14.jpg +0 -0
  56. package/registry/assets/images/art-15.jpg +0 -0
  57. package/registry/assets/images/art-16.jpg +0 -0
  58. package/registry/assets/images/art-17.jpg +0 -0
  59. package/registry/assets/images/art-18.jpg +0 -0
  60. package/registry/assets/images/art-19.jpg +0 -0
  61. package/registry/assets/images/art-20.jpg +0 -0
  62. package/registry/assets/images/art-21.jpg +0 -0
  63. package/registry/assets/images/art-22.jpg +0 -0
  64. package/registry/assets/images/art-23.jpg +0 -0
  65. package/registry/assets/images/art-24.jpg +0 -0
  66. package/registry/assets/images/art-25.jpg +0 -0
  67. package/registry/assets/images/art-26.jpg +0 -0
  68. package/registry/assets/images/art-27.jpg +0 -0
  69. package/registry/assets/images/nature-01.jpg +0 -0
  70. package/registry/assets/images/nature-02.jpg +0 -0
  71. package/registry/assets/images/nature-03.jpg +0 -0
  72. package/registry/assets/images/nature-04.jpg +0 -0
  73. package/registry/assets/images/nature-05.jpg +0 -0
  74. package/registry/assets/images/nature-06.jpg +0 -0
  75. package/registry/assets/images/nature-07.jpg +0 -0
  76. package/registry/assets/images/nature-08.jpg +0 -0
  77. package/registry/assets/images/nature-09.jpg +0 -0
  78. package/registry/assets/images/nature-10.jpg +0 -0
  79. package/registry/assets/images/nature-11.jpg +0 -0
  80. package/registry/assets/images/nature-12.jpg +0 -0
  81. package/registry/assets/images/nature-13.jpg +0 -0
  82. package/registry/assets/images/nature-14.jpg +0 -0
  83. package/registry/assets/images/nature-15.jpg +0 -0
  84. package/registry/assets/images/nature-16.jpg +0 -0
  85. package/registry/assets/images/nature-17.jpg +0 -0
  86. package/registry/assets/images/nature-18.jpg +0 -0
  87. package/registry/assets/images/nature-19.jpg +0 -0
  88. package/registry/assets/images/nature-20.jpg +0 -0
  89. package/registry/components/accordion.tsx +119 -0
  90. package/registry/components/alert.tsx +282 -0
  91. package/registry/components/attribute.tsx +452 -0
  92. package/registry/components/avatar.tsx +142 -0
  93. package/registry/components/badge.tsx +567 -0
  94. package/registry/components/button-group.tsx +246 -0
  95. package/registry/components/button.tsx +102 -0
  96. package/registry/components/card.tsx +613 -0
  97. package/registry/components/checkbox.tsx +244 -0
  98. package/registry/components/date-picker.tsx +1143 -0
  99. package/registry/components/divider.tsx +82 -0
  100. package/registry/components/expanded/ActivityFeed.tsx +226 -0
  101. package/registry/components/expanded/Banner.tsx +145 -0
  102. package/registry/components/expanded/BannerBoard.tsx +225 -0
  103. package/registry/components/expanded/Breadcrumbs.tsx +156 -0
  104. package/registry/components/expanded/CatalogComponentsShowcase.tsx +211 -0
  105. package/registry/components/expanded/CatalogDivider.tsx +48 -0
  106. package/registry/components/expanded/CatalogTag.tsx +92 -0
  107. package/registry/components/expanded/CommandBar.tsx +406 -0
  108. package/registry/components/expanded/FileUpload.tsx +231 -0
  109. package/registry/components/expanded/IconExplorer.tsx +612 -0
  110. package/registry/components/expanded/OnboardingStepListItem.tsx +67 -0
  111. package/registry/components/expanded/PageHeader.tsx +184 -0
  112. package/registry/components/expanded/Slideout.tsx +514 -0
  113. package/registry/components/expanded/Steps.tsx +266 -0
  114. package/registry/components/expanded/Table.tsx +1014 -0
  115. package/registry/components/expanded/Tabs.tsx +86 -0
  116. package/registry/components/expanded/Timeline.tsx +235 -0
  117. package/registry/components/expanded/TimelineShowcase.tsx +158 -0
  118. package/registry/components/expanded/activityFeed.css +292 -0
  119. package/registry/components/expanded/banner.css +312 -0
  120. package/registry/components/expanded/breadcrumbs.css +140 -0
  121. package/registry/components/expanded/catalogComponentsShowcase.css +87 -0
  122. package/registry/components/expanded/commandBar.css +473 -0
  123. package/registry/components/expanded/divider.css +75 -0
  124. package/registry/components/expanded/fileUpload.css +228 -0
  125. package/registry/components/expanded/iconExplorer.css +764 -0
  126. package/registry/components/expanded/iconPacks.ts +866 -0
  127. package/registry/components/expanded/onboardingStepListItem.css +126 -0
  128. package/registry/components/expanded/pageHeader.css +287 -0
  129. package/registry/components/expanded/slideout.css +955 -0
  130. package/registry/components/expanded/steps.css +329 -0
  131. package/registry/components/expanded/table.css +607 -0
  132. package/registry/components/expanded/tabs.css +197 -0
  133. package/registry/components/expanded/tag.css +148 -0
  134. package/registry/components/expanded/timeline.css +282 -0
  135. package/registry/components/input-content.ts +106 -0
  136. package/registry/components/input.tsx +866 -0
  137. package/registry/components/menu.tsx +758 -0
  138. package/registry/components/modal.tsx +799 -0
  139. package/registry/components/pagination.tsx +543 -0
  140. package/registry/components/progress-slider.tsx +216 -0
  141. package/registry/components/progress.tsx +367 -0
  142. package/registry/components/radio-card.tsx +654 -0
  143. package/registry/components/radio-group.tsx +570 -0
  144. package/registry/components/select-content.tsx +313 -0
  145. package/registry/components/select.tsx +871 -0
  146. package/registry/components/slider.tsx +380 -0
  147. package/registry/components/social-button.tsx +360 -0
  148. package/registry/components/spinner.tsx +31 -0
  149. package/registry/components/tag.tsx +423 -0
  150. package/registry/components/textarea.tsx +625 -0
  151. package/registry/components/toggle.tsx +272 -0
  152. package/registry/components/toolbar.tsx +467 -0
  153. package/registry/components/tooltip.tsx +427 -0
  154. package/registry/examples/accordion-demo.tsx +34 -0
  155. package/registry/examples/alert-demo.tsx +14 -0
  156. package/registry/examples/attribute-demo.tsx +65 -0
  157. package/registry/examples/avatar-demo.tsx +74 -0
  158. package/registry/examples/badge-demo.tsx +53 -0
  159. package/registry/examples/button-demo.tsx +83 -0
  160. package/registry/examples/button-group-demo.tsx +42 -0
  161. package/registry/examples/card-demo.tsx +48 -0
  162. package/registry/examples/checkbox-demo.tsx +67 -0
  163. package/registry/examples/date-picker-demo.tsx +74 -0
  164. package/registry/examples/divider-demo.tsx +17 -0
  165. package/registry/examples/expanded/activity-feed-demo.tsx +22 -0
  166. package/registry/examples/expanded/banner-demo.tsx +23 -0
  167. package/registry/examples/expanded/catalog-components-demo.tsx +5 -0
  168. package/registry/examples/expanded/command-bar-demo.tsx +10 -0
  169. package/registry/examples/expanded/icons-demo.tsx +5 -0
  170. package/registry/examples/expanded/onboarding-step-demo.tsx +11 -0
  171. package/registry/examples/expanded/page-header-demo.tsx +19 -0
  172. package/registry/examples/expanded/slideout-demo.tsx +15 -0
  173. package/registry/examples/expanded/steps-demo.tsx +18 -0
  174. package/registry/examples/expanded/tabs-demo.tsx +13 -0
  175. package/registry/examples/expanded/timeline-demo.tsx +18 -0
  176. package/registry/examples/input-demo.tsx +87 -0
  177. package/registry/examples/menu-demo.tsx +109 -0
  178. package/registry/examples/modal-demo.tsx +16 -0
  179. package/registry/examples/pagination-demo.tsx +17 -0
  180. package/registry/examples/progress-demo.tsx +37 -0
  181. package/registry/examples/progress-slider-demo.tsx +29 -0
  182. package/registry/examples/radio-card-demo.tsx +51 -0
  183. package/registry/examples/radio-group-demo.tsx +62 -0
  184. package/registry/examples/select-demo.tsx +73 -0
  185. package/registry/examples/slider-demo.tsx +31 -0
  186. package/registry/examples/social-button-demo.tsx +51 -0
  187. package/registry/examples/tag-demo.tsx +29 -0
  188. package/registry/examples/textarea-demo.tsx +79 -0
  189. package/registry/examples/toggle-demo.tsx +59 -0
  190. package/registry/examples/toolbar-demo.tsx +80 -0
  191. package/registry/examples/tooltip-demo.tsx +115 -0
  192. package/registry/hooks/use-direction.ts +27 -0
  193. package/registry/index.json +1213 -0
  194. package/registry/styles/globals.css +4600 -0
  195. package/registry/utils/cn.ts +6 -0
  196. package/src/cli/index.js +826 -0
  197. package/tokens/Color mode.zip +0 -0
  198. package/tokens/Numbers.zip +0 -0
  199. package/tokens/Radius.zip +0 -0
  200. package/tokens/Theme.zip +0 -0
  201. package/tokens/banhaten.tokens.json +5525 -0
@@ -0,0 +1,543 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+
4
+ import { cn } from "@/lib/utils"
5
+
6
+ type PaginationType = "numeric" | "simple" | "summary"
7
+ type PaginationVariant = "soft" | "ghost"
8
+ type PaginationPage =
9
+ | number
10
+ | "ellipsis"
11
+ | {
12
+ type: "page"
13
+ value: number
14
+ label?: React.ReactNode
15
+ ariaLabel?: string
16
+ }
17
+ | {
18
+ type: "ellipsis"
19
+ label?: React.ReactNode
20
+ ariaLabel?: string
21
+ }
22
+
23
+ type PaginationDirection = "ltr" | "rtl"
24
+
25
+ const defaultPaginationPages: PaginationPage[] = [1, 2, 3, 4, "ellipsis", 10]
26
+
27
+ const paginationVariants = cva(
28
+ [
29
+ "flex max-w-full items-center",
30
+ "text-[length:var(--bh-pagination-font-size)]",
31
+ "leading-[var(--bh-pagination-line-height)]",
32
+ "tracking-[var(--bh-pagination-letter-spacing)]",
33
+ ],
34
+ {
35
+ variants: {
36
+ type: {
37
+ numeric:
38
+ "w-[var(--bh-pagination-numeric-width)] justify-between gap-[var(--bh-pagination-root-gap)]",
39
+ simple:
40
+ "w-[var(--bh-pagination-simple-width)] justify-between gap-[var(--bh-pagination-root-gap)]",
41
+ summary:
42
+ "w-[var(--bh-pagination-simple-width)] justify-between gap-[var(--bh-pagination-root-gap)]",
43
+ },
44
+ showCaption: {
45
+ true: "",
46
+ false: "justify-center",
47
+ },
48
+ },
49
+ compoundVariants: [
50
+ {
51
+ type: ["simple", "summary"],
52
+ showCaption: false,
53
+ class: "justify-between",
54
+ },
55
+ ],
56
+ defaultVariants: {
57
+ type: "numeric",
58
+ showCaption: true,
59
+ },
60
+ }
61
+ )
62
+
63
+ const paginationControlVariants = cva(
64
+ [
65
+ "relative inline-flex h-[var(--bh-pagination-item-size)] shrink-0 items-center justify-center",
66
+ "whitespace-nowrap rounded-[var(--bh-pagination-radius)]",
67
+ "text-[color:var(--bh-pagination-control-content)]",
68
+ "text-[length:var(--bh-pagination-font-size)] font-[var(--bh-pagination-label-font-weight)]",
69
+ "leading-[var(--bh-pagination-line-height)] tracking-[var(--bh-pagination-letter-spacing)]",
70
+ "outline-none transition-[background-color,border-color,color,box-shadow]",
71
+ "focus-visible:shadow-[var(--shadow-pagination-focus)]",
72
+ "disabled:pointer-events-none disabled:text-[var(--bh-content-disabled)]",
73
+ "[&_svg]:pointer-events-none [&_svg]:size-[var(--bh-pagination-icon-size)] [&_svg]:shrink-0",
74
+ "rtl:[&_svg[data-rtl-flip='true']]:-scale-x-100",
75
+ ],
76
+ {
77
+ variants: {
78
+ variant: {
79
+ soft:
80
+ "bg-[var(--bh-pagination-control-soft-bg)] shadow-[var(--shadow-pagination-control)] hover:bg-[var(--bh-pagination-control-soft-hover)] active:bg-[var(--bh-pagination-control-soft-pressed)]",
81
+ ghost:
82
+ "bg-[var(--bh-pagination-control-ghost-bg)] hover:bg-[var(--bh-pagination-control-ghost-hover)] active:bg-[var(--bh-pagination-control-ghost-pressed)]",
83
+ },
84
+ mode: {
85
+ icon: "w-[var(--bh-pagination-item-size)] p-0",
86
+ text:
87
+ "gap-[var(--bh-pagination-control-text-gap)] px-[var(--bh-pagination-control-text-padding-x)] py-[var(--bh-space-md-8)] rtl:gap-[var(--bh-pagination-control-text-rtl-gap)] rtl:px-[var(--bh-pagination-control-text-rtl-padding-x)]",
88
+ },
89
+ },
90
+ defaultVariants: {
91
+ variant: "soft",
92
+ mode: "text",
93
+ },
94
+ }
95
+ )
96
+
97
+ const paginationControlLabelVariants = cva(
98
+ "min-w-0 whitespace-nowrap",
99
+ {
100
+ variants: {
101
+ variant: {
102
+ soft:
103
+ "px-[var(--bh-pagination-control-label-padding-x)] rtl:px-[var(--bh-pagination-control-label-rtl-padding-x)]",
104
+ ghost: "px-[var(--bh-pagination-control-label-rtl-padding-x)]",
105
+ },
106
+ },
107
+ defaultVariants: {
108
+ variant: "soft",
109
+ },
110
+ }
111
+ )
112
+
113
+ const paginationItemVariants = cva(
114
+ [
115
+ "relative inline-flex size-[var(--bh-pagination-item-size)] shrink-0 items-center justify-center",
116
+ "rounded-[var(--bh-pagination-radius)] border border-transparent text-center",
117
+ "text-[length:var(--bh-pagination-font-size)] font-[var(--bh-pagination-label-font-weight)]",
118
+ "leading-[var(--bh-pagination-line-height)] tracking-[var(--bh-pagination-letter-spacing)]",
119
+ "outline-none transition-[background-color,border-color,color,box-shadow]",
120
+ "disabled:pointer-events-none disabled:text-[var(--bh-content-disabled)]",
121
+ ],
122
+ {
123
+ variants: {
124
+ active: {
125
+ true:
126
+ "border-[var(--bh-pagination-active-border)] bg-[var(--bh-pagination-active-bg)] text-[var(--bh-pagination-active-content)] shadow-[var(--shadow-pagination-active)]",
127
+ false:
128
+ "bg-[var(--bh-pagination-page-bg)] text-[var(--bh-pagination-page-content)] hover:bg-[var(--bh-pagination-page-hover)] active:bg-[var(--bh-pagination-page-pressed)] focus-visible:border-[var(--bh-border-brand-strong)] focus-visible:shadow-[var(--shadow-pagination-focus)]",
129
+ },
130
+ },
131
+ defaultVariants: {
132
+ active: false,
133
+ },
134
+ }
135
+ )
136
+
137
+ type PaginationProps = Omit<React.ComponentProps<"nav">, "children"> &
138
+ VariantProps<typeof paginationVariants> & {
139
+ type?: PaginationType
140
+ variant?: PaginationVariant
141
+ page?: number
142
+ pages?: PaginationPage[]
143
+ showCaption?: boolean
144
+ caption?: React.ReactNode
145
+ summary?: React.ReactNode
146
+ previousLabel?: React.ReactNode
147
+ nextLabel?: React.ReactNode
148
+ previousAriaLabel?: string
149
+ nextAriaLabel?: string
150
+ previousDisabled?: boolean
151
+ nextDisabled?: boolean
152
+ onPageChange?: (page: number) => void
153
+ }
154
+
155
+ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(function Pagination({
156
+ className,
157
+ type = "numeric",
158
+ variant = "soft",
159
+ page = 2,
160
+ pages = defaultPaginationPages,
161
+ showCaption = true,
162
+ caption,
163
+ summary,
164
+ previousLabel,
165
+ nextLabel,
166
+ previousAriaLabel,
167
+ nextAriaLabel,
168
+ previousDisabled,
169
+ nextDisabled,
170
+ onPageChange,
171
+ "aria-label": ariaLabel,
172
+ dir,
173
+ ...props
174
+ }, ref) {
175
+ const selectedType = type || "numeric"
176
+ const selectedVariant = variant || "soft"
177
+ const selectedDirection = getPaginationDirection(dir)
178
+ const labels = getDefaultPaginationLabels(selectedDirection)
179
+ const captionContent = caption ?? labels.caption
180
+ const summaryContent = summary ?? labels.summary
181
+ const previousContent = previousLabel ?? labels.previous
182
+ const nextContent = nextLabel ?? labels.next
183
+
184
+ return (
185
+ <nav
186
+ aria-label={ariaLabel || labels.navigation}
187
+ data-show-caption={showCaption ? "true" : "false"}
188
+ data-slot="pagination"
189
+ data-type={selectedType}
190
+ data-variant={selectedVariant}
191
+ dir={dir}
192
+ ref={ref}
193
+ className={cn(
194
+ paginationVariants({
195
+ type: selectedType,
196
+ showCaption,
197
+ className,
198
+ })
199
+ )}
200
+ {...props}
201
+ >
202
+ {selectedType === "simple" ? (
203
+ <>
204
+ {showCaption ? (
205
+ <PaginationCaption type="simple">{captionContent}</PaginationCaption>
206
+ ) : null}
207
+ <PaginationControls type="actions">
208
+ <PaginationTextButton
209
+ ariaLabel={previousAriaLabel || labels.previousAriaLabel}
210
+ disabled={previousDisabled}
211
+ label={previousContent}
212
+ onClick={() => onPageChange?.(Math.max(1, page - 1))}
213
+ type="previous"
214
+ variant={selectedVariant}
215
+ />
216
+ <PaginationTextButton
217
+ ariaLabel={nextAriaLabel || labels.nextAriaLabel}
218
+ disabled={nextDisabled}
219
+ label={nextContent}
220
+ onClick={() => onPageChange?.(page + 1)}
221
+ type="next"
222
+ variant={selectedVariant}
223
+ />
224
+ </PaginationControls>
225
+ </>
226
+ ) : null}
227
+
228
+ {selectedType === "summary" ? (
229
+ <>
230
+ <PaginationTextButton
231
+ ariaLabel={previousAriaLabel || labels.previousAriaLabel}
232
+ disabled={previousDisabled}
233
+ label={previousContent}
234
+ onClick={() => onPageChange?.(Math.max(1, page - 1))}
235
+ type="previous"
236
+ variant={selectedVariant}
237
+ />
238
+ <span
239
+ data-slot="pagination-summary"
240
+ dir="auto"
241
+ className="shrink-0 whitespace-nowrap text-[color:var(--bh-pagination-caption-content)] font-[var(--bh-pagination-caption-font-weight)]"
242
+ >
243
+ {summaryContent}
244
+ </span>
245
+ <PaginationTextButton
246
+ ariaLabel={nextAriaLabel || labels.nextAriaLabel}
247
+ disabled={nextDisabled}
248
+ label={nextContent}
249
+ onClick={() => onPageChange?.(page + 1)}
250
+ type="next"
251
+ variant={selectedVariant}
252
+ />
253
+ </>
254
+ ) : null}
255
+
256
+ {selectedType === "numeric" ? (
257
+ <>
258
+ {showCaption ? (
259
+ <PaginationCaption type="numeric">{captionContent}</PaginationCaption>
260
+ ) : null}
261
+ <PaginationControls type="numeric">
262
+ <PaginationIconButton
263
+ ariaLabel={previousAriaLabel || labels.previousAriaLabel}
264
+ disabled={previousDisabled}
265
+ onClick={() => onPageChange?.(Math.max(1, page - 1))}
266
+ type="previous"
267
+ variant={selectedVariant}
268
+ />
269
+ <div
270
+ data-slot="pagination-pages"
271
+ className="flex shrink-0 items-center gap-[var(--bh-pagination-page-gap)]"
272
+ >
273
+ {pages.map((item, index) => (
274
+ <PaginationPageItem
275
+ key={getPaginationPageKey(item, index)}
276
+ item={item}
277
+ page={page}
278
+ onPageChange={onPageChange}
279
+ />
280
+ ))}
281
+ </div>
282
+ <PaginationIconButton
283
+ ariaLabel={nextAriaLabel || labels.nextAriaLabel}
284
+ disabled={nextDisabled}
285
+ onClick={() => onPageChange?.(page + 1)}
286
+ type="next"
287
+ variant={selectedVariant}
288
+ />
289
+ </PaginationControls>
290
+ </>
291
+ ) : null}
292
+ </nav>
293
+ )
294
+ })
295
+
296
+ function PaginationCaption({
297
+ children,
298
+ type,
299
+ }: {
300
+ children: React.ReactNode
301
+ type: "numeric" | "simple"
302
+ }) {
303
+ return (
304
+ <span
305
+ data-slot="pagination-caption"
306
+ dir="auto"
307
+ className={cn(
308
+ "min-w-0 text-[color:var(--bh-pagination-caption-content)] font-[var(--bh-pagination-caption-font-weight)]",
309
+ type === "numeric"
310
+ ? "w-[var(--bh-pagination-caption-width)] shrink-0"
311
+ : "flex-1"
312
+ )}
313
+ >
314
+ {children}
315
+ </span>
316
+ )
317
+ }
318
+
319
+ function PaginationControls({
320
+ children,
321
+ type,
322
+ }: {
323
+ children: React.ReactNode
324
+ type: "actions" | "numeric"
325
+ }) {
326
+ return (
327
+ <div
328
+ data-slot="pagination-controls"
329
+ className={cn(
330
+ "flex shrink-0 items-center",
331
+ type === "numeric"
332
+ ? "gap-[var(--bh-pagination-control-gap)]"
333
+ : "gap-[var(--bh-pagination-action-gap)]"
334
+ )}
335
+ >
336
+ {children}
337
+ </div>
338
+ )
339
+ }
340
+
341
+ function PaginationIconButton({
342
+ ariaLabel,
343
+ disabled,
344
+ onClick,
345
+ type,
346
+ variant,
347
+ }: {
348
+ ariaLabel: string
349
+ disabled?: boolean
350
+ onClick?: () => void
351
+ type: "previous" | "next"
352
+ variant: PaginationVariant
353
+ }) {
354
+ return (
355
+ <button
356
+ aria-label={ariaLabel}
357
+ data-slot="pagination-control"
358
+ disabled={disabled}
359
+ type="button"
360
+ className={cn(paginationControlVariants({ variant, mode: "icon" }))}
361
+ onClick={onClick}
362
+ >
363
+ <PaginationArrowIcon type={type} />
364
+ </button>
365
+ )
366
+ }
367
+
368
+ function PaginationTextButton({
369
+ ariaLabel,
370
+ disabled,
371
+ label,
372
+ onClick,
373
+ type,
374
+ variant,
375
+ }: {
376
+ ariaLabel: string
377
+ disabled?: boolean
378
+ label: React.ReactNode
379
+ onClick?: () => void
380
+ type: "previous" | "next"
381
+ variant: PaginationVariant
382
+ }) {
383
+ return (
384
+ <button
385
+ aria-label={ariaLabel}
386
+ data-slot="pagination-control"
387
+ disabled={disabled}
388
+ type="button"
389
+ className={cn(paginationControlVariants({ variant, mode: "text" }))}
390
+ onClick={onClick}
391
+ >
392
+ {type === "previous" ? <PaginationArrowIcon type="previous" /> : null}
393
+ <span
394
+ data-slot="pagination-control-label"
395
+ dir="auto"
396
+ className={cn(paginationControlLabelVariants({ variant }))}
397
+ >
398
+ {label}
399
+ </span>
400
+ {type === "next" ? <PaginationArrowIcon type="next" /> : null}
401
+ </button>
402
+ )
403
+ }
404
+
405
+ function PaginationPageItem({
406
+ item,
407
+ page,
408
+ onPageChange,
409
+ }: {
410
+ item: PaginationPage
411
+ page: number
412
+ onPageChange?: (page: number) => void
413
+ }) {
414
+ const normalizedItem = normalizePaginationPage(item)
415
+
416
+ if (normalizedItem.type === "ellipsis") {
417
+ return (
418
+ <span
419
+ aria-label={normalizedItem.ariaLabel || "More pages"}
420
+ data-slot="pagination-ellipsis"
421
+ role="separator"
422
+ className={cn(paginationItemVariants({ active: false }))}
423
+ >
424
+ {normalizedItem.label || "..."}
425
+ </span>
426
+ )
427
+ }
428
+
429
+ const isActive = normalizedItem.value === page
430
+
431
+ return (
432
+ <button
433
+ aria-current={isActive ? "page" : undefined}
434
+ aria-label={normalizedItem.ariaLabel || `Page ${normalizedItem.value}`}
435
+ data-page={normalizedItem.value}
436
+ data-slot="pagination-page"
437
+ type="button"
438
+ className={cn(paginationItemVariants({ active: isActive }))}
439
+ onClick={() => onPageChange?.(normalizedItem.value)}
440
+ >
441
+ {normalizedItem.label || normalizedItem.value}
442
+ </button>
443
+ )
444
+ }
445
+
446
+ function PaginationArrowIcon({ type }: { type: "previous" | "next" }) {
447
+ return (
448
+ <svg
449
+ aria-hidden="true"
450
+ data-rtl-flip="true"
451
+ data-slot="pagination-icon"
452
+ fill="none"
453
+ focusable="false"
454
+ viewBox="0 0 20 20"
455
+ >
456
+ {type === "previous" ? (
457
+ <path
458
+ d="M2.357 5.30332L6.48183 9.42807L5.30333 10.6066L0 5.30332L5.30333 0L6.48183 1.17851L2.357 5.30332Z"
459
+ fill="currentColor"
460
+ transform="translate(6.666 4.697)"
461
+ />
462
+ ) : (
463
+ <path
464
+ d="M4.12482 5.30332L0 1.17851L1.17852 0L6.48182 5.30332L1.17852 10.6066L0 9.42807L4.12482 5.30332Z"
465
+ fill="currentColor"
466
+ transform="translate(6.852 4.697)"
467
+ />
468
+ )}
469
+ </svg>
470
+ )
471
+ }
472
+
473
+ function normalizePaginationPage(item: PaginationPage) {
474
+ if (item === "ellipsis") {
475
+ return { type: "ellipsis" as const }
476
+ }
477
+
478
+ if (typeof item === "number") {
479
+ return { type: "page" as const, value: item }
480
+ }
481
+
482
+ return item
483
+ }
484
+
485
+ function getPaginationPageKey(item: PaginationPage, index: number) {
486
+ const normalizedItem = normalizePaginationPage(item)
487
+
488
+ if (normalizedItem.type === "page") {
489
+ return `page-${normalizedItem.value}`
490
+ }
491
+
492
+ return `ellipsis-${index}`
493
+ }
494
+
495
+ function getPaginationDirection(
496
+ dir: React.HTMLAttributes<HTMLElement>["dir"]
497
+ ): PaginationDirection {
498
+ if (dir === "rtl" || dir === "ltr") {
499
+ return dir
500
+ }
501
+
502
+ return "ltr"
503
+ }
504
+
505
+ function getDefaultPaginationLabels(direction: PaginationDirection) {
506
+ if (direction === "rtl") {
507
+ return {
508
+ navigation: "\u0627\u0644\u062a\u0631\u0642\u064a\u0645",
509
+ caption:
510
+ "\u0639\u0631\u0636 1 \u0625\u0644\u0649 10 \u0645\u0646 20 \u0646\u062a\u064a\u062c\u0629",
511
+ summary: "\u0627\u0644\u0635\u0641\u062d\u0629 1 \u0645\u0646 10",
512
+ previous: "\u0645\u0639\u0627\u064a\u0646\u0629",
513
+ next: "\u0627\u0644\u062a\u0627\u0644\u064a",
514
+ previousAriaLabel:
515
+ "\u0627\u0644\u0635\u0641\u062d\u0629 \u0627\u0644\u0633\u0627\u0628\u0642\u0629",
516
+ nextAriaLabel:
517
+ "\u0627\u0644\u0635\u0641\u062d\u0629 \u0627\u0644\u062a\u0627\u0644\u064a\u0629",
518
+ }
519
+ }
520
+
521
+ return {
522
+ navigation: "Pagination",
523
+ caption: "Showing 1 to 10 of 20 results",
524
+ summary: "Page 1 of 10",
525
+ previous: "Previous",
526
+ next: "Next",
527
+ previousAriaLabel: "Previous page",
528
+ nextAriaLabel: "Next page",
529
+ }
530
+ }
531
+
532
+ export {
533
+ Pagination,
534
+ paginationControlVariants,
535
+ paginationItemVariants,
536
+ paginationVariants,
537
+ }
538
+ export type {
539
+ PaginationPage,
540
+ PaginationProps,
541
+ PaginationType,
542
+ PaginationVariant,
543
+ }