banhaten 0.1.3 → 0.3.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.
- package/CHANGELOG.md +73 -0
- package/CONTRIBUTING.md +44 -0
- package/README.md +65 -13
- package/SECURITY.md +15 -0
- package/banhaten.config.example.json +0 -2
- package/docs/design-system/README.md +9 -0
- package/docs/design-system/adoption-quality-remediation.md +87 -0
- package/docs/design-system/agent-usage.md +13 -0
- package/docs/design-system/appearance-presets.md +6 -1
- package/docs/design-system/component-docs-pattern.md +81 -0
- package/docs/design-system/component-implementation-ownership-audit.md +244 -0
- package/docs/design-system/component-quality-audit-2026-08-20.md +223 -0
- package/docs/design-system/component-showcase-consistency-report.md +2 -0
- package/docs/design-system/component-token-consistency-audit.md +13 -3
- package/docs/design-system/components/README.md +4 -2
- package/docs/design-system/components/accordion.md +16 -0
- package/docs/design-system/components/activity-feed.md +17 -1
- package/docs/design-system/components/activity-heatmap.md +73 -0
- package/docs/design-system/components/alert-dialog.md +17 -0
- package/docs/design-system/components/alert.md +46 -14
- package/docs/design-system/components/aspect-ratio.md +15 -0
- package/docs/design-system/components/attribute.md +16 -0
- package/docs/design-system/components/autocomplete.md +19 -0
- package/docs/design-system/components/avatar.md +18 -0
- package/docs/design-system/components/badge.md +19 -0
- package/docs/design-system/components/banner.md +19 -1
- package/docs/design-system/components/breadcrumbs.md +17 -0
- package/docs/design-system/components/button-group.md +35 -0
- package/docs/design-system/components/button.md +18 -0
- package/docs/design-system/components/card.md +26 -1
- package/docs/design-system/components/carousel.md +20 -3
- package/docs/design-system/components/catalog-components.md +18 -1
- package/docs/design-system/components/chart.md +15 -0
- package/docs/design-system/components/checkbox.md +16 -0
- package/docs/design-system/components/collapsible.md +15 -0
- package/docs/design-system/components/command.md +15 -0
- package/docs/design-system/components/context-menu.md +15 -0
- package/docs/design-system/components/date-picker.md +21 -1
- package/docs/design-system/components/divider.md +16 -0
- package/docs/design-system/components/empty-state.md +17 -0
- package/docs/design-system/components/field.md +17 -0
- package/docs/design-system/components/file-upload.md +18 -0
- package/docs/design-system/components/hover-card.md +15 -0
- package/docs/design-system/components/input-group.md +17 -0
- package/docs/design-system/components/input-otp.md +18 -0
- package/docs/design-system/components/input.md +43 -7
- package/docs/design-system/components/item.md +72 -0
- package/docs/design-system/components/kbd.md +18 -0
- package/docs/design-system/components/label.md +16 -0
- package/docs/design-system/components/menu.md +17 -0
- package/docs/design-system/components/menubar.md +15 -0
- package/docs/design-system/components/modal.md +25 -4
- package/docs/design-system/components/native-select.md +18 -0
- package/docs/design-system/components/navigation-menu.md +15 -0
- package/docs/design-system/components/onboarding-step-list-item.md +16 -1
- package/docs/design-system/components/page-header.md +17 -1
- package/docs/design-system/components/pagination.md +31 -8
- package/docs/design-system/components/popover.md +19 -0
- package/docs/design-system/components/progress-slider.md +18 -0
- package/docs/design-system/components/progress.md +17 -0
- package/docs/design-system/components/radio-card.md +16 -0
- package/docs/design-system/components/radio-group.md +17 -0
- package/docs/design-system/components/resizable.md +15 -0
- package/docs/design-system/components/scroll-area.md +20 -1
- package/docs/design-system/components/segmented-control.md +71 -0
- package/docs/design-system/components/select.md +44 -7
- package/docs/design-system/components/sheet.md +17 -0
- package/docs/design-system/components/sidebar.md +17 -0
- package/docs/design-system/components/skeleton.md +18 -0
- package/docs/design-system/components/slideout.md +17 -0
- package/docs/design-system/components/slider.md +20 -0
- package/docs/design-system/components/social-button.md +21 -3
- package/docs/design-system/components/spinner.md +16 -0
- package/docs/design-system/components/steps.md +19 -0
- package/docs/design-system/components/table.md +36 -4
- package/docs/design-system/components/tabs.md +17 -0
- package/docs/design-system/components/tag.md +17 -0
- package/docs/design-system/components/textarea.md +16 -0
- package/docs/design-system/components/timeline.md +17 -0
- package/docs/design-system/components/toast.md +17 -0
- package/docs/design-system/components/toggle.md +17 -0
- package/docs/design-system/components/toolbar.md +21 -1
- package/docs/design-system/components/tooltip.md +18 -1
- package/docs/design-system/density-and-elevation.md +61 -0
- package/docs/design-system/direction-and-localization.md +23 -0
- package/docs/design-system/form-recipes.md +73 -0
- package/docs/design-system/gap-promotion-policy.md +21 -0
- package/docs/design-system/gap-promotion-report.md +100 -0
- package/docs/design-system/installation.md +68 -0
- package/docs/design-system/launch-comparison-shadcn.md +98 -0
- package/docs/design-system/registry-and-cli.md +30 -7
- package/docs/design-system/release-policy.md +30 -0
- package/docs/design-system/roadmap.md +14 -0
- package/docs/design-system/support-matrix.md +23 -0
- package/docs/design-system/tabs.md +1 -1
- package/docs/design-system/token-governance.md +23 -1
- package/package.json +30 -15
- package/registry/component-contract.json +40 -0
- package/registry/components/alert-dialog.tsx +2 -2
- package/registry/components/alert.tsx +101 -76
- package/registry/components/autocomplete.tsx +23 -9
- package/registry/components/avatar.tsx +14 -10
- package/registry/components/badge.tsx +18 -18
- package/registry/components/button-group.tsx +324 -5
- package/registry/components/button.tsx +38 -17
- package/registry/components/card.tsx +87 -62
- package/registry/components/carousel.tsx +67 -5
- package/registry/components/chart.tsx +36 -3
- package/registry/components/checkbox.tsx +3 -3
- package/registry/components/collapsible.tsx +1 -1
- package/registry/components/command.tsx +38 -4
- package/registry/components/context-menu.tsx +1 -1
- package/registry/components/date-picker.tsx +312 -135
- package/registry/components/expanded/ActivityFeed.tsx +9 -22
- package/registry/components/expanded/ActivityHeatmap.tsx +64 -0
- package/registry/components/expanded/Banner.tsx +3 -4
- package/registry/components/expanded/Breadcrumbs.tsx +8 -5
- package/registry/components/expanded/CatalogComponentsShowcase.tsx +16 -17
- package/registry/components/expanded/CatalogDivider.tsx +4 -3
- package/registry/components/expanded/EmptyState.tsx +1 -1
- package/registry/components/expanded/FileUpload.tsx +16 -7
- package/registry/components/expanded/OnboardingStepListItem.tsx +2 -6
- package/registry/components/expanded/PageHeader.tsx +47 -56
- package/registry/components/expanded/Slideout.tsx +29 -424
- package/registry/components/expanded/Steps.tsx +151 -13
- package/registry/components/expanded/Table.tsx +161 -82
- package/registry/components/expanded/Timeline.tsx +14 -27
- package/registry/components/expanded/activityFeed.css +9 -9
- package/registry/components/expanded/activityHeatmap.css +66 -0
- package/registry/components/expanded/banner.css +21 -11
- package/registry/components/expanded/breadcrumbs.css +2 -2
- package/registry/components/expanded/divider.css +1 -1
- package/registry/components/expanded/emptyState.css +1 -1
- package/registry/components/expanded/fileUpload.css +7 -7
- package/registry/components/expanded/onboardingStepListItem.css +2 -2
- package/registry/components/expanded/pageHeader.css +14 -11
- package/registry/components/expanded/slideout.css +10 -690
- package/registry/components/expanded/steps.css +78 -15
- package/registry/components/expanded/table.css +60 -69
- package/registry/components/expanded/timeline.css +19 -18
- package/registry/components/field.tsx +61 -8
- package/registry/components/input-content.ts +1 -0
- package/registry/components/input-otp.tsx +13 -3
- package/registry/components/input.tsx +68 -43
- package/registry/components/item.tsx +189 -0
- package/registry/components/kbd.tsx +111 -4
- package/registry/components/menu.tsx +87 -251
- package/registry/components/menubar.tsx +1 -1
- package/registry/components/modal.tsx +143 -103
- package/registry/components/native-select.tsx +2 -2
- package/registry/components/navigation-menu.tsx +1 -1
- package/registry/components/pagination.css +36 -0
- package/registry/components/pagination.tsx +88 -64
- package/registry/components/popover.tsx +162 -664
- package/registry/components/progress-slider.tsx +1 -1
- package/registry/components/radio-card.tsx +116 -87
- package/registry/components/resizable.tsx +36 -2
- package/registry/components/scroll-area.tsx +30 -6
- package/registry/components/segmented-control.tsx +87 -0
- package/registry/components/select-content.tsx +2 -2
- package/registry/components/select.tsx +86 -27
- package/registry/components/sheet.tsx +1 -1
- package/registry/components/sidebar.tsx +12 -6
- package/registry/components/skeleton.css +0 -3
- package/registry/components/social-button.tsx +59 -30
- package/registry/components/spinner.tsx +18 -55
- package/registry/components/table-elements.tsx +128 -0
- package/registry/components/tabs.css +1 -1
- package/registry/components/tabs.tsx +13 -14
- package/registry/components/tag.tsx +3 -3
- package/registry/components/textarea.tsx +3 -3
- package/registry/components/toast.tsx +16 -11
- package/registry/components/toggle.tsx +4 -4
- package/registry/components/toolbar.tsx +94 -22
- package/registry/components/tooltip.tsx +2 -2
- package/registry/examples/alert-demo.tsx +25 -5
- package/registry/examples/attribute-demo.tsx +1 -1
- package/registry/examples/autocomplete-demo.tsx +3 -3
- package/registry/examples/avatar-demo.tsx +14 -11
- package/registry/examples/badge-demo.tsx +1 -1
- package/registry/examples/button-demo.tsx +6 -6
- package/registry/examples/button-group-demo.tsx +23 -2
- package/registry/examples/card-demo.tsx +46 -8
- package/registry/examples/carousel-demo.tsx +20 -2
- package/registry/examples/chart-demo.tsx +1 -1
- package/registry/examples/checkbox-demo.tsx +5 -5
- package/registry/examples/collection-filter-bar-demo.tsx +135 -0
- package/registry/examples/command-demo.tsx +3 -3
- package/registry/examples/{expanded/command-bar-demo.tsx → command-palette-demo.tsx} +5 -15
- package/registry/examples/context-menu-demo.tsx +1 -1
- package/registry/examples/control-density-contract-demo.tsx +61 -0
- package/registry/examples/date-picker-demo.tsx +12 -12
- package/registry/examples/divider-demo.tsx +3 -3
- package/registry/examples/expanded/activity-heatmap-demo.tsx +29 -0
- package/registry/examples/expanded/banner-demo.tsx +1 -1
- package/registry/examples/expanded/breadcrumbs-demo.tsx +4 -4
- package/registry/examples/expanded/empty-state-demo.tsx +1 -1
- package/registry/examples/expanded/file-upload-demo.tsx +1 -1
- package/registry/examples/expanded/onboarding-step-demo.tsx +1 -1
- package/registry/examples/expanded/slideout-demo.tsx +2 -2
- package/registry/examples/expanded/steps-demo.tsx +1 -1
- package/registry/examples/expanded/tabs-demo.tsx +1 -1
- package/registry/examples/expanded/timeline-demo.tsx +1 -1
- package/registry/examples/hover-card-demo.tsx +2 -2
- package/registry/examples/input-demo.tsx +6 -6
- package/registry/examples/input-otp-demo.tsx +4 -4
- package/registry/examples/item-demo.tsx +46 -0
- package/registry/examples/kbd-demo.tsx +1 -1
- package/registry/examples/label-demo.tsx +1 -1
- package/registry/examples/menu-demo.tsx +1 -1
- package/registry/examples/modal-demo.tsx +67 -9
- package/registry/examples/navigation-menu-demo.tsx +1 -1
- package/registry/examples/pagination-demo.tsx +10 -7
- package/registry/examples/popover-demo.tsx +19 -19
- package/registry/examples/progress-demo.tsx +1 -1
- package/registry/examples/progress-slider-demo.tsx +1 -1
- package/registry/examples/radio-card-demo.tsx +4 -4
- package/registry/examples/radio-group-demo.tsx +2 -2
- package/registry/examples/resizable-demo.tsx +1 -1
- package/registry/examples/results-toolbar-demo.tsx +44 -0
- package/registry/examples/scroll-area-demo.tsx +3 -3
- package/registry/examples/segmented-control-demo.tsx +39 -0
- package/registry/examples/select-demo.tsx +1 -1
- package/registry/examples/sidebar-demo.tsx +5 -3
- package/registry/examples/slider-demo.tsx +3 -3
- package/registry/examples/social-button-demo.tsx +18 -8
- package/registry/examples/spinner-demo.tsx +13 -13
- package/registry/examples/tabs-demo.tsx +1 -1
- package/registry/examples/tag-demo.tsx +1 -1
- package/registry/examples/textarea-demo.tsx +4 -4
- package/registry/examples/toast-demo.tsx +1 -1
- package/registry/examples/toggle-demo.tsx +6 -6
- package/registry/examples/tooltip-demo.tsx +4 -4
- package/registry/guidance/USAGE.md +27 -0
- package/registry/hooks/use-direction.ts +193 -13
- package/registry/index.json +5668 -375
- package/registry/styles/globals.css +2404 -3999
- package/registry.json +156 -149
- package/schema/config.schema.json +11 -8
- package/schema/registry.schema.json +150 -45
- package/schema/tokens.schema.json +134 -34
- package/src/cli/command-line.js +194 -0
- package/src/cli/config-editors.js +9 -0
- package/src/cli/doctor.js +399 -0
- package/src/cli/file-transaction.js +295 -0
- package/src/cli/global-css.js +153 -0
- package/src/cli/index.js +567 -1613
- package/src/cli/install-plan.js +592 -0
- package/src/cli/install-receipt.js +171 -0
- package/src/cli/jsonc.js +203 -0
- package/src/cli/package-install-state.js +254 -0
- package/src/cli/package-manager.js +238 -0
- package/src/cli/package-plan.js +185 -0
- package/src/cli/package-version.js +97 -0
- package/src/cli/registry-query.js +207 -0
- package/src/cli/reporting.js +55 -0
- package/src/cli/schema-validation.js +19 -0
- package/src/cli/source-scanner.js +686 -0
- package/src/cli/vite-config.js +478 -0
- package/tokens/banhaten.tokens.json +4444 -331
- package/docs/design-system/components/command-bar.md +0 -57
- package/registry/components/expanded/BannerBoard.tsx +0 -225
- package/registry/components/expanded/CatalogTag.tsx +0 -85
- package/registry/components/expanded/CommandBar.tsx +0 -386
- package/registry/components/expanded/IconExplorer.tsx +0 -612
- package/registry/components/expanded/TimelineShowcase.tsx +0 -158
- package/registry/components/expanded/commandBar.css +0 -470
- package/registry/components/expanded/iconExplorer.css +0 -764
- package/registry/components/expanded/iconPacks.ts +0 -866
- package/registry/components/expanded/tag.css +0 -148
- package/registry/examples/expanded/icons-demo.tsx +0 -5
- package/tokens/Color mode.zip +0 -0
- package/tokens/Numbers.zip +0 -0
- package/tokens/Radius.zip +0 -0
- package/tokens/Theme.zip +0 -0
|
@@ -3,6 +3,9 @@ import { cva, type VariantProps } from "class-variance-authority"
|
|
|
3
3
|
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
|
|
4
4
|
|
|
5
5
|
import { cn } from "@/lib/utils"
|
|
6
|
+
import { useResolvedDirection } from "@/hooks/use-direction"
|
|
7
|
+
|
|
8
|
+
import "./pagination.css"
|
|
6
9
|
|
|
7
10
|
type PaginationType = "numeric" | "simple" | "summary"
|
|
8
11
|
type PaginationVariant = "soft" | "ghost"
|
|
@@ -21,13 +24,50 @@ type PaginationPage =
|
|
|
21
24
|
ariaLabel?: string
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
type
|
|
27
|
+
type PaginationMessages = {
|
|
28
|
+
caption: React.ReactNode
|
|
29
|
+
morePagesAriaLabel: string
|
|
30
|
+
navigation: string
|
|
31
|
+
next: React.ReactNode
|
|
32
|
+
nextAriaLabel: string
|
|
33
|
+
pageAriaLabel: (page: number) => string
|
|
34
|
+
previous: React.ReactNode
|
|
35
|
+
previousAriaLabel: string
|
|
36
|
+
summary: React.ReactNode
|
|
37
|
+
}
|
|
25
38
|
|
|
26
39
|
const defaultPaginationPages: PaginationPage[] = [1, 2, 3, 4, "ellipsis", 10]
|
|
27
40
|
|
|
41
|
+
const defaultPaginationMessages: PaginationMessages = {
|
|
42
|
+
caption: "Showing 1 to 10 of 20 results",
|
|
43
|
+
morePagesAriaLabel: "More pages",
|
|
44
|
+
navigation: "Pagination",
|
|
45
|
+
next: "Next",
|
|
46
|
+
nextAriaLabel: "Next page",
|
|
47
|
+
pageAriaLabel: (page) => `Page ${page}`,
|
|
48
|
+
previous: "Previous",
|
|
49
|
+
previousAriaLabel: "Previous page",
|
|
50
|
+
summary: "Page 1 of 10",
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const arabicPaginationMessages: PaginationMessages = {
|
|
54
|
+
caption:
|
|
55
|
+
"\u0639\u0631\u0636 1 \u0625\u0644\u0649 10 \u0645\u0646 20 \u0646\u062a\u064a\u062c\u0629",
|
|
56
|
+
morePagesAriaLabel: "\u0635\u0641\u062d\u0627\u062a \u0625\u0636\u0627\u0641\u064a\u0629",
|
|
57
|
+
navigation: "\u0627\u0644\u062a\u0631\u0642\u064a\u0645",
|
|
58
|
+
next: "\u0627\u0644\u062a\u0627\u0644\u064a",
|
|
59
|
+
nextAriaLabel:
|
|
60
|
+
"\u0627\u0644\u0635\u0641\u062d\u0629 \u0627\u0644\u062a\u0627\u0644\u064a\u0629",
|
|
61
|
+
pageAriaLabel: (page) => `\u0627\u0644\u0635\u0641\u062d\u0629 ${page}`,
|
|
62
|
+
previous: "\u0627\u0644\u0633\u0627\u0628\u0642",
|
|
63
|
+
previousAriaLabel:
|
|
64
|
+
"\u0627\u0644\u0635\u0641\u062d\u0629 \u0627\u0644\u0633\u0627\u0628\u0642\u0629",
|
|
65
|
+
summary: "\u0627\u0644\u0635\u0641\u062d\u0629 1 \u0645\u0646 10",
|
|
66
|
+
}
|
|
67
|
+
|
|
28
68
|
const paginationVariants = cva(
|
|
29
69
|
[
|
|
30
|
-
"flex max-w-full items-center",
|
|
70
|
+
"ds-pagination flex w-full max-w-full min-w-0 flex-wrap items-center",
|
|
31
71
|
"text-[length:var(--bh-pagination-font-size)]",
|
|
32
72
|
"leading-[var(--bh-pagination-line-height)]",
|
|
33
73
|
"tracking-[var(--bh-pagination-letter-spacing)]",
|
|
@@ -36,11 +76,11 @@ const paginationVariants = cva(
|
|
|
36
76
|
variants: {
|
|
37
77
|
type: {
|
|
38
78
|
numeric:
|
|
39
|
-
"w-[var(--bh-pagination-numeric-width)] justify-between gap-[var(--bh-pagination-root-gap)]",
|
|
79
|
+
"max-w-[var(--bh-pagination-numeric-width)] justify-between gap-[var(--bh-pagination-root-gap)]",
|
|
40
80
|
simple:
|
|
41
|
-
"w-[var(--bh-pagination-simple-width)] justify-between gap-[var(--bh-pagination-root-gap)]",
|
|
81
|
+
"max-w-[var(--bh-pagination-simple-width)] justify-between gap-[var(--bh-pagination-root-gap)]",
|
|
42
82
|
summary:
|
|
43
|
-
"w-[var(--bh-pagination-simple-width)] justify-between gap-[var(--bh-pagination-root-gap)]",
|
|
83
|
+
"max-w-[var(--bh-pagination-simple-width)] justify-between gap-[var(--bh-pagination-root-gap)]",
|
|
44
84
|
},
|
|
45
85
|
showCaption: {
|
|
46
86
|
true: "",
|
|
@@ -141,6 +181,7 @@ type PaginationProps = Omit<React.ComponentProps<"nav">, "children"> &
|
|
|
141
181
|
variant?: PaginationVariant
|
|
142
182
|
page?: number
|
|
143
183
|
pages?: PaginationPage[]
|
|
184
|
+
messages?: Partial<PaginationMessages>
|
|
144
185
|
showCaption?: boolean
|
|
145
186
|
caption?: React.ReactNode
|
|
146
187
|
summary?: React.ReactNode
|
|
@@ -159,6 +200,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(function Pagin
|
|
|
159
200
|
variant = "soft",
|
|
160
201
|
page = 2,
|
|
161
202
|
pages = defaultPaginationPages,
|
|
203
|
+
messages: messageOverrides,
|
|
162
204
|
showCaption = true,
|
|
163
205
|
caption,
|
|
164
206
|
summary,
|
|
@@ -173,24 +215,36 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(function Pagin
|
|
|
173
215
|
dir,
|
|
174
216
|
...props
|
|
175
217
|
}, ref) {
|
|
218
|
+
const rootRef = React.useRef<HTMLElement | null>(null)
|
|
219
|
+
const selectedDirection = useResolvedDirection(
|
|
220
|
+
dir === "ltr" || dir === "rtl" ? dir : undefined,
|
|
221
|
+
rootRef
|
|
222
|
+
)
|
|
223
|
+
const setRootRef = React.useCallback(
|
|
224
|
+
(node: HTMLElement | null) => {
|
|
225
|
+
rootRef.current = node
|
|
226
|
+
if (typeof ref === "function") ref(node)
|
|
227
|
+
else if (ref) ref.current = node
|
|
228
|
+
},
|
|
229
|
+
[ref]
|
|
230
|
+
)
|
|
176
231
|
const selectedType = type || "numeric"
|
|
177
232
|
const selectedVariant = variant || "soft"
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
const nextContent = nextLabel ?? labels.next
|
|
233
|
+
const messages = { ...defaultPaginationMessages, ...messageOverrides }
|
|
234
|
+
const captionContent = caption ?? messages.caption
|
|
235
|
+
const summaryContent = summary ?? messages.summary
|
|
236
|
+
const previousContent = previousLabel ?? messages.previous
|
|
237
|
+
const nextContent = nextLabel ?? messages.next
|
|
184
238
|
|
|
185
239
|
return (
|
|
186
240
|
<nav
|
|
187
|
-
aria-label={ariaLabel
|
|
241
|
+
aria-label={ariaLabel ?? messages.navigation}
|
|
188
242
|
data-show-caption={showCaption ? "true" : "false"}
|
|
189
243
|
data-slot="pagination"
|
|
190
244
|
data-type={selectedType}
|
|
191
245
|
data-variant={selectedVariant}
|
|
192
|
-
dir={
|
|
193
|
-
ref={
|
|
246
|
+
dir={selectedDirection}
|
|
247
|
+
ref={setRootRef}
|
|
194
248
|
className={cn(
|
|
195
249
|
paginationVariants({
|
|
196
250
|
type: selectedType,
|
|
@@ -207,7 +261,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(function Pagin
|
|
|
207
261
|
) : null}
|
|
208
262
|
<PaginationControls type="actions">
|
|
209
263
|
<PaginationTextButton
|
|
210
|
-
ariaLabel={previousAriaLabel
|
|
264
|
+
ariaLabel={previousAriaLabel ?? messages.previousAriaLabel}
|
|
211
265
|
disabled={previousDisabled}
|
|
212
266
|
label={previousContent}
|
|
213
267
|
onClick={() => onPageChange?.(Math.max(1, page - 1))}
|
|
@@ -215,7 +269,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(function Pagin
|
|
|
215
269
|
variant={selectedVariant}
|
|
216
270
|
/>
|
|
217
271
|
<PaginationTextButton
|
|
218
|
-
ariaLabel={nextAriaLabel
|
|
272
|
+
ariaLabel={nextAriaLabel ?? messages.nextAriaLabel}
|
|
219
273
|
disabled={nextDisabled}
|
|
220
274
|
label={nextContent}
|
|
221
275
|
onClick={() => onPageChange?.(page + 1)}
|
|
@@ -229,7 +283,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(function Pagin
|
|
|
229
283
|
{selectedType === "summary" ? (
|
|
230
284
|
<>
|
|
231
285
|
<PaginationTextButton
|
|
232
|
-
ariaLabel={previousAriaLabel
|
|
286
|
+
ariaLabel={previousAriaLabel ?? messages.previousAriaLabel}
|
|
233
287
|
disabled={previousDisabled}
|
|
234
288
|
label={previousContent}
|
|
235
289
|
onClick={() => onPageChange?.(Math.max(1, page - 1))}
|
|
@@ -244,7 +298,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(function Pagin
|
|
|
244
298
|
{summaryContent}
|
|
245
299
|
</span>
|
|
246
300
|
<PaginationTextButton
|
|
247
|
-
ariaLabel={nextAriaLabel
|
|
301
|
+
ariaLabel={nextAriaLabel ?? messages.nextAriaLabel}
|
|
248
302
|
disabled={nextDisabled}
|
|
249
303
|
label={nextContent}
|
|
250
304
|
onClick={() => onPageChange?.(page + 1)}
|
|
@@ -261,7 +315,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(function Pagin
|
|
|
261
315
|
) : null}
|
|
262
316
|
<PaginationControls type="numeric">
|
|
263
317
|
<PaginationIconButton
|
|
264
|
-
ariaLabel={previousAriaLabel
|
|
318
|
+
ariaLabel={previousAriaLabel ?? messages.previousAriaLabel}
|
|
265
319
|
disabled={previousDisabled}
|
|
266
320
|
onClick={() => onPageChange?.(Math.max(1, page - 1))}
|
|
267
321
|
type="previous"
|
|
@@ -269,19 +323,20 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(function Pagin
|
|
|
269
323
|
/>
|
|
270
324
|
<div
|
|
271
325
|
data-slot="pagination-pages"
|
|
272
|
-
className="flex shrink-0 items-center gap-[var(--bh-pagination-page-gap)]"
|
|
326
|
+
className="ds-pagination__pages flex min-w-0 shrink-0 items-center gap-[var(--bh-pagination-page-gap)]"
|
|
273
327
|
>
|
|
274
328
|
{pages.map((item, index) => (
|
|
275
329
|
<PaginationPageItem
|
|
276
330
|
key={getPaginationPageKey(item, index)}
|
|
277
331
|
item={item}
|
|
332
|
+
messages={messages}
|
|
278
333
|
page={page}
|
|
279
334
|
onPageChange={onPageChange}
|
|
280
335
|
/>
|
|
281
336
|
))}
|
|
282
337
|
</div>
|
|
283
338
|
<PaginationIconButton
|
|
284
|
-
ariaLabel={nextAriaLabel
|
|
339
|
+
ariaLabel={nextAriaLabel ?? messages.nextAriaLabel}
|
|
285
340
|
disabled={nextDisabled}
|
|
286
341
|
onClick={() => onPageChange?.(page + 1)}
|
|
287
342
|
type="next"
|
|
@@ -328,7 +383,7 @@ function PaginationControls({
|
|
|
328
383
|
<div
|
|
329
384
|
data-slot="pagination-controls"
|
|
330
385
|
className={cn(
|
|
331
|
-
"flex shrink-0 items-center",
|
|
386
|
+
"ds-pagination__controls flex max-w-full min-w-0 shrink-0 items-center",
|
|
332
387
|
type === "numeric"
|
|
333
388
|
? "gap-[var(--bh-pagination-control-gap)]"
|
|
334
389
|
: "gap-[var(--bh-pagination-action-gap)]"
|
|
@@ -405,10 +460,12 @@ function PaginationTextButton({
|
|
|
405
460
|
|
|
406
461
|
function PaginationPageItem({
|
|
407
462
|
item,
|
|
463
|
+
messages,
|
|
408
464
|
page,
|
|
409
465
|
onPageChange,
|
|
410
466
|
}: {
|
|
411
467
|
item: PaginationPage
|
|
468
|
+
messages: PaginationMessages
|
|
412
469
|
page: number
|
|
413
470
|
onPageChange?: (page: number) => void
|
|
414
471
|
}) {
|
|
@@ -417,12 +474,12 @@ function PaginationPageItem({
|
|
|
417
474
|
if (normalizedItem.type === "ellipsis") {
|
|
418
475
|
return (
|
|
419
476
|
<span
|
|
420
|
-
aria-label={normalizedItem.ariaLabel
|
|
477
|
+
aria-label={normalizedItem.ariaLabel ?? messages.morePagesAriaLabel}
|
|
421
478
|
data-slot="pagination-ellipsis"
|
|
422
479
|
role="separator"
|
|
423
480
|
className={cn(paginationItemVariants({ active: false }))}
|
|
424
481
|
>
|
|
425
|
-
{normalizedItem.label
|
|
482
|
+
{normalizedItem.label ?? "..."}
|
|
426
483
|
</span>
|
|
427
484
|
)
|
|
428
485
|
}
|
|
@@ -432,14 +489,16 @@ function PaginationPageItem({
|
|
|
432
489
|
return (
|
|
433
490
|
<button
|
|
434
491
|
aria-current={isActive ? "page" : undefined}
|
|
435
|
-
aria-label={
|
|
492
|
+
aria-label={
|
|
493
|
+
normalizedItem.ariaLabel ?? messages.pageAriaLabel(normalizedItem.value)
|
|
494
|
+
}
|
|
436
495
|
data-page={normalizedItem.value}
|
|
437
496
|
data-slot="pagination-page"
|
|
438
497
|
type="button"
|
|
439
498
|
className={cn(paginationItemVariants({ active: isActive }))}
|
|
440
499
|
onClick={() => onPageChange?.(normalizedItem.value)}
|
|
441
500
|
>
|
|
442
|
-
{normalizedItem.label
|
|
501
|
+
{normalizedItem.label ?? normalizedItem.value}
|
|
443
502
|
</button>
|
|
444
503
|
)
|
|
445
504
|
}
|
|
@@ -453,7 +512,7 @@ function PaginationArrowIcon({ type }: { type: "previous" | "next" }) {
|
|
|
453
512
|
data-rtl-flip="true"
|
|
454
513
|
data-slot="pagination-icon"
|
|
455
514
|
focusable="false"
|
|
456
|
-
strokeWidth=
|
|
515
|
+
strokeWidth="var(--bh-icon-stroke-225)"
|
|
457
516
|
/>
|
|
458
517
|
)
|
|
459
518
|
}
|
|
@@ -480,44 +539,8 @@ function getPaginationPageKey(item: PaginationPage, index: number) {
|
|
|
480
539
|
return `ellipsis-${index}`
|
|
481
540
|
}
|
|
482
541
|
|
|
483
|
-
function getPaginationDirection(
|
|
484
|
-
dir: React.HTMLAttributes<HTMLElement>["dir"]
|
|
485
|
-
): PaginationDirection {
|
|
486
|
-
if (dir === "rtl" || dir === "ltr") {
|
|
487
|
-
return dir
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
return "ltr"
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
function getDefaultPaginationLabels(direction: PaginationDirection) {
|
|
494
|
-
if (direction === "rtl") {
|
|
495
|
-
return {
|
|
496
|
-
navigation: "\u0627\u0644\u062a\u0631\u0642\u064a\u0645",
|
|
497
|
-
caption:
|
|
498
|
-
"\u0639\u0631\u0636 1 \u0625\u0644\u0649 10 \u0645\u0646 20 \u0646\u062a\u064a\u062c\u0629",
|
|
499
|
-
summary: "\u0627\u0644\u0635\u0641\u062d\u0629 1 \u0645\u0646 10",
|
|
500
|
-
previous: "\u0645\u0639\u0627\u064a\u0646\u0629",
|
|
501
|
-
next: "\u0627\u0644\u062a\u0627\u0644\u064a",
|
|
502
|
-
previousAriaLabel:
|
|
503
|
-
"\u0627\u0644\u0635\u0641\u062d\u0629 \u0627\u0644\u0633\u0627\u0628\u0642\u0629",
|
|
504
|
-
nextAriaLabel:
|
|
505
|
-
"\u0627\u0644\u0635\u0641\u062d\u0629 \u0627\u0644\u062a\u0627\u0644\u064a\u0629",
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return {
|
|
510
|
-
navigation: "Pagination",
|
|
511
|
-
caption: "Showing 1 to 10 of 20 results",
|
|
512
|
-
summary: "Page 1 of 10",
|
|
513
|
-
previous: "Previous",
|
|
514
|
-
next: "Next",
|
|
515
|
-
previousAriaLabel: "Previous page",
|
|
516
|
-
nextAriaLabel: "Next page",
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
542
|
export {
|
|
543
|
+
arabicPaginationMessages,
|
|
521
544
|
Pagination,
|
|
522
545
|
paginationControlVariants,
|
|
523
546
|
paginationItemVariants,
|
|
@@ -525,6 +548,7 @@ export {
|
|
|
525
548
|
}
|
|
526
549
|
export type {
|
|
527
550
|
PaginationPage,
|
|
551
|
+
PaginationMessages,
|
|
528
552
|
PaginationProps,
|
|
529
553
|
PaginationType,
|
|
530
554
|
PaginationVariant,
|