@vendure-io/ui 3.0.0-next.5 → 3.0.0-next.7

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 (35) hide show
  1. package/package.json +1 -1
  2. package/src/components/atoms/breadcrumb.tsx +31 -11
  3. package/src/components/atoms/carousel.tsx +33 -7
  4. package/src/components/atoms/combobox.tsx +144 -17
  5. package/src/components/atoms/command.tsx +14 -4
  6. package/src/components/atoms/pagination.tsx +43 -12
  7. package/src/components/atoms/sidebar.tsx +24 -5
  8. package/src/components/atoms/spinner.tsx +7 -2
  9. package/src/components/molecules/action-needed.tsx +4 -4
  10. package/src/components/molecules/anonymized-token.tsx +19 -18
  11. package/src/components/molecules/app-shell.tsx +14 -5
  12. package/src/components/molecules/checklist/checklist.tsx +47 -17
  13. package/src/components/molecules/choice-card.tsx +3 -0
  14. package/src/components/molecules/confirm-dialog.tsx +6 -4
  15. package/src/components/molecules/data-table/data-table-filters.tsx +25 -7
  16. package/src/components/molecules/data-table/data-table-types.tsx +33 -16
  17. package/src/components/molecules/data-table/data-table-view-options.tsx +14 -4
  18. package/src/components/molecules/data-table/data-table.tsx +47 -26
  19. package/src/components/molecules/data-table/table-pagination.tsx +51 -29
  20. package/src/components/molecules/date-picker.tsx +4 -2
  21. package/src/components/molecules/date-range-picker.tsx +6 -2
  22. package/src/components/molecules/date-time-picker.tsx +4 -2
  23. package/src/components/molecules/file-dropzone.tsx +16 -5
  24. package/src/components/molecules/id-chip.tsx +10 -8
  25. package/src/components/molecules/issued-secret.tsx +34 -24
  26. package/src/components/molecules/multi-select.tsx +470 -107
  27. package/src/components/molecules/secret-value.tsx +26 -18
  28. package/src/components/molecules/skip-link.tsx +11 -9
  29. package/src/components/molecules/stat-card.tsx +2 -0
  30. package/src/components/molecules/state-views/error-state.tsx +18 -6
  31. package/src/components/molecules/state-views/loading-state.tsx +2 -0
  32. package/src/components/molecules/status-badge.tsx +5 -2
  33. package/src/lib/chip-fit.ts +62 -0
  34. package/src/lib/format-messages.ts +189 -0
  35. package/src/lib/multi-select-keys.ts +77 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendure-io/ui",
3
- "version": "3.0.0-next.5",
3
+ "version": "3.0.0-next.7",
4
4
  "description": "React component library for Vendure, built on shadcn/ui and Tailwind v4",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://github.com/vendurehq/design/tree/main/packages/ui",
@@ -40,10 +40,12 @@ import { menuItem, menuRadioItem, MenuCheck } from "../../lib/menu-item.tsx"
40
40
  import { useMessages } from "../../lib/format-messages.ts"
41
41
  import { warnDeprecated } from "../../lib/deprecated.ts"
42
42
 
43
- function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) {
43
+ // `aria-label` defaults to `messages.breadcrumb.nav`, "breadcrumb".
44
+ function Breadcrumb({ className, "aria-label": ariaLabel, ...props }: React.ComponentProps<"nav">) {
45
+ const t = useMessages("breadcrumb", { nav: ariaLabel })
44
46
  return (
45
47
  <nav
46
- aria-label="breadcrumb"
48
+ aria-label={t.nav}
47
49
  data-slot="breadcrumb"
48
50
  className={cn(className)}
49
51
  {...props}
@@ -132,8 +134,16 @@ function BreadcrumbSeparator({
132
134
 
133
135
  function BreadcrumbEllipsis({
134
136
  className,
137
+ label,
135
138
  ...props
136
- }: React.ComponentProps<"span">) {
139
+ }: React.ComponentProps<"span"> & {
140
+ /**
141
+ * Screen-reader text of the ellipsis.
142
+ * @default `messages.breadcrumb.more`, "More"
143
+ */
144
+ label?: string
145
+ }) {
146
+ const t = useMessages("breadcrumb", { more: label })
137
147
  return (
138
148
  <span
139
149
  data-slot="breadcrumb-ellipsis"
@@ -147,7 +157,7 @@ function BreadcrumbEllipsis({
147
157
  >
148
158
  <MoreHorizontalIcon
149
159
  />
150
- <span className="sr-only">More</span>
160
+ <span className="sr-only">{t.more}</span>
151
161
  </span>
152
162
  )
153
163
  }
@@ -586,8 +596,8 @@ function BreadcrumbSearchMenu({
586
596
  open: openProp,
587
597
  onOpenChange,
588
598
  defaultOpen = false,
589
- searchPlaceholder = `Find ${label.toLowerCase()}…`,
590
- emptyText = "No results.",
599
+ searchPlaceholder,
600
+ emptyText,
591
601
  error,
592
602
  onRetry,
593
603
  loadingLabel,
@@ -596,9 +606,15 @@ function BreadcrumbSearchMenu({
596
606
  className,
597
607
  contentClassName,
598
608
  }: BreadcrumbMenuBaseProps & {
599
- /** The search field's placeholder. Default: "Find <label>…". */
609
+ /**
610
+ * The search field's placeholder.
611
+ * @default `messages.breadcrumb.search`, "Find {label}…", with `{label}` the menu's `label` in lower case
612
+ */
600
613
  searchPlaceholder?: string
601
- /** Shows when the search matches no option. */
614
+ /**
615
+ * Shows when the search matches no option.
616
+ * @default `messages.breadcrumb.empty`, "No results."
617
+ */
602
618
  emptyText?: React.ReactNode
603
619
  /** The options could not be read: this text shows as a row. */
604
620
  error?: React.ReactNode
@@ -625,7 +641,11 @@ function BreadcrumbSearchMenu({
625
641
  const options = loadingProp ? undefined : optionsProp
626
642
  const [open, setOpen] = useMenuOpen(openProp, defaultOpen, onOpenChange)
627
643
  const crumb = useCrumbTrigger({ options: optionsProp ?? [], value, label, placeholder, open })
628
- const t = useMessages("breadcrumb", { loading: loadingLabel, retry: retryLabel })
644
+ const t = useMessages("breadcrumb", {
645
+ loading: loadingLabel,
646
+ retry: retryLabel,
647
+ search: searchPlaceholder,
648
+ })
629
649
  const failed = error != null && error !== false
630
650
  // The error wins: a failed first read has no options either.
631
651
  const loading = options === undefined && !failed
@@ -665,7 +685,7 @@ function BreadcrumbSearchMenu({
665
685
  selected after it unmounts, and the field then points at a row
666
686
  that is gone (aria-activedescendant). */}
667
687
  <Command key={failed ? "failed" : "read"} label={label} filter={searchFilter}>
668
- <CommandInput autoFocus placeholder={searchPlaceholder} />
688
+ <CommandInput autoFocus placeholder={t.search.replaceAll("{label}", label.toLowerCase())} />
669
689
  {/* Outside the list: a listbox takes only options and groups. As
670
690
  tall as one option row with its group's padding, so one
671
691
  option takes its place without a jump. */}
@@ -685,7 +705,7 @@ function BreadcrumbSearchMenu({
685
705
  </div>
686
706
  )}
687
707
  <CommandList aria-busy={loading || undefined}>
688
- {!loading && !failed && <CommandEmpty>{emptyText}</CommandEmpty>}
708
+ {!loading && !failed && <CommandEmpty>{emptyText !== undefined ? emptyText : t.empty}</CommandEmpty>}
689
709
  {failed && (
690
710
  <CommandGroup forceMount heading={error}>
691
711
  {onRetry && (
@@ -9,6 +9,7 @@ import { cn } from "@vendure-io/ui/lib/utils"
9
9
  import { Button } from "@vendure-io/ui/components/atoms/button"
10
10
  import { useDirection } from "@vendure-io/ui/components/atoms/direction"
11
11
  import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
12
+ import { useMessages } from "../../lib/format-messages.ts"
12
13
 
13
14
  type CarouselApi = UseEmblaCarouselType[1]
14
15
  type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
@@ -50,8 +51,11 @@ function Carousel({
50
51
  plugins,
51
52
  className,
52
53
  children,
54
+ "aria-roledescription": roleDescription,
53
55
  ...props
54
56
  }: React.ComponentProps<"div"> & CarouselProps) {
57
+ // `aria-roledescription` defaults to `messages.carousel.region`, "carousel".
58
+ const t = useMessages("carousel", { region: roleDescription })
55
59
  // Embla scrolls the other way in right to left, so it needs the direction.
56
60
  const direction = useDirection()
57
61
  const [carouselRef, api] = useEmblaCarousel(
@@ -129,7 +133,7 @@ function Carousel({
129
133
  onKeyDownCapture={handleKeyDown}
130
134
  className={cn("relative", className)}
131
135
  role="region"
132
- aria-roledescription="carousel"
136
+ aria-roledescription={t.region}
133
137
  data-slot="carousel"
134
138
  {...props}
135
139
  >
@@ -160,13 +164,19 @@ function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
160
164
  )
161
165
  }
162
166
 
163
- function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
167
+ // `aria-roledescription` defaults to `messages.carousel.slide`, "slide".
168
+ function CarouselItem({
169
+ className,
170
+ "aria-roledescription": roleDescription,
171
+ ...props
172
+ }: React.ComponentProps<"div">) {
164
173
  const { orientation } = useCarousel()
174
+ const t = useMessages("carousel", { slide: roleDescription })
165
175
 
166
176
  return (
167
177
  <div
168
178
  role="group"
169
- aria-roledescription="slide"
179
+ aria-roledescription={t.slide}
170
180
  data-slot="carousel-item"
171
181
  className={cn(
172
182
  "min-w-0 shrink-0 grow-0 basis-full",
@@ -182,9 +192,17 @@ function CarouselPrevious({
182
192
  className,
183
193
  variant = "outline",
184
194
  size = "icon-sm",
195
+ label,
185
196
  ...props
186
- }: React.ComponentProps<typeof Button>) {
197
+ }: React.ComponentProps<typeof Button> & {
198
+ /**
199
+ * Screen-reader text of the button.
200
+ * @default `messages.carousel.previous`, "Previous slide"
201
+ */
202
+ label?: string
203
+ }) {
187
204
  const { orientation, scrollPrev, canScrollPrev } = useCarousel()
205
+ const t = useMessages("carousel", { previous: label })
188
206
 
189
207
  return (
190
208
  <Button
@@ -203,7 +221,7 @@ function CarouselPrevious({
203
221
  {...props}
204
222
  >
205
223
  <ChevronLeftIcon className={cn(orientation === "horizontal" && "rtl:rotate-180")} />
206
- <span className="sr-only">Previous slide</span>
224
+ <span className="sr-only">{t.previous}</span>
207
225
  </Button>
208
226
  )
209
227
  }
@@ -212,9 +230,17 @@ function CarouselNext({
212
230
  className,
213
231
  variant = "outline",
214
232
  size = "icon-sm",
233
+ label,
215
234
  ...props
216
- }: React.ComponentProps<typeof Button>) {
235
+ }: React.ComponentProps<typeof Button> & {
236
+ /**
237
+ * Screen-reader text of the button.
238
+ * @default `messages.carousel.next`, "Next slide"
239
+ */
240
+ label?: string
241
+ }) {
217
242
  const { orientation, scrollNext, canScrollNext } = useCarousel()
243
+ const t = useMessages("carousel", { next: label })
218
244
 
219
245
  return (
220
246
  <Button
@@ -233,7 +259,7 @@ function CarouselNext({
233
259
  {...props}
234
260
  >
235
261
  <ChevronRightIcon className={cn(orientation === "horizontal" && "rtl:rotate-180")} />
236
- <span className="sr-only">Next slide</span>
262
+ <span className="sr-only">{t.next}</span>
237
263
  </Button>
238
264
  )
239
265
  }
@@ -5,7 +5,7 @@ import { Combobox as ComboboxPrimitive } from "@base-ui/react"
5
5
 
6
6
  import { cn } from "@vendure-io/ui/lib/utils"
7
7
  import { MenuCheck, menuCheckItem, menuItemDisabled } from "../../lib/menu-item.tsx"
8
- import { statusChipRing } from "../../lib/tint-recipes.ts"
8
+ import { chipCountBox, chipShape } from "../../lib/chip-fit.ts"
9
9
  import { fieldSurface, fieldSurfaceWithin } from "../../lib/field-surface.ts"
10
10
  import { popupMotion } from "../../lib/popup-motion.ts"
11
11
  import { Button } from "@vendure-io/ui/components/atoms/button"
@@ -15,11 +15,11 @@ import {
15
15
  InputGroupButton,
16
16
  InputGroupInput,
17
17
  } from "@vendure-io/ui/components/atoms/input-group"
18
- import { ChevronDownIcon, Loader2Icon, XIcon } from "lucide-react"
18
+ import { ChevronDownIcon, ChevronsUpDownIcon, Loader2Icon, XIcon } from "lucide-react"
19
19
  import { usePopupDir } from "../../lib/popup-direction.ts"
20
20
  import { usePopupAlign } from "../../lib/popup-align.ts"
21
21
  import { hasName, nameFrom, useRegisteredRef } from "../../lib/control-name.ts"
22
- import { useMessages } from "../../lib/format-messages.ts"
22
+ import { fillMessage, useMessages } from "../../lib/format-messages.ts"
23
23
  import { warnDeprecated } from "../../lib/deprecated.ts"
24
24
 
25
25
  /**
@@ -206,11 +206,13 @@ function ComboboxTrigger({
206
206
  // Icon-only, so it carries a name. Like the open button, it stays out of the
207
207
  // tab order: Backspace clears the input from the keyboard, and while the list
208
208
  // is open Base UI hides it from assistive technology.
209
- function ComboboxClear({ className, "aria-label": ariaLabel = "Clear", ...props }: ComboboxPrimitive.Clear.Props) {
209
+ // `aria-label` defaults to `messages.combobox.clear`, "Clear".
210
+ function ComboboxClear({ className, "aria-label": ariaLabel, ...props }: ComboboxPrimitive.Clear.Props) {
211
+ const t = useMessages("combobox", { clear: ariaLabel })
210
212
  return (
211
213
  <ComboboxPrimitive.Clear
212
214
  data-slot="combobox-clear"
213
- aria-label={ariaLabel}
215
+ aria-label={t.clear}
214
216
  tabIndex={-1}
215
217
  render={<InputGroupButton variant="ghost" size="icon-xs" />}
216
218
  className={cn(className)}
@@ -227,18 +229,25 @@ function ComboboxInput({
227
229
  disabled = false,
228
230
  showTrigger = true,
229
231
  showClear = false,
230
- triggerLabel = "Open options",
231
- clearLabel = "Clear",
232
+ triggerLabel,
233
+ clearLabel,
232
234
  ref,
233
235
  ...props
234
236
  }: ComboboxPrimitive.Input.Props & {
235
237
  showTrigger?: boolean
236
238
  showClear?: boolean
237
- /** Accessible name of the icon-only trigger button. */
239
+ /**
240
+ * Accessible name of the icon-only trigger button.
241
+ * @default `messages.combobox.open`, "Open options"
242
+ */
238
243
  triggerLabel?: string
239
- /** Accessible name of the icon-only clear button. */
244
+ /**
245
+ * Accessible name of the icon-only clear button.
246
+ * @default `messages.combobox.clear`, "Clear"
247
+ */
240
248
  clearLabel?: string
241
249
  }) {
250
+ const t = useMessages("combobox", { open: triggerLabel })
242
251
  const inputRef = useRegisteredRef(ref, React.useContext(ComboboxControlsContext)?.setInput)
243
252
  return (
244
253
  <InputGroup className={cn("w-auto", className)}>
@@ -264,7 +273,7 @@ function ComboboxInput({
264
273
  variant="ghost"
265
274
  render={<ComboboxPrimitive.Trigger />}
266
275
  data-slot="input-group-button"
267
- aria-label={triggerLabel}
276
+ aria-label={t.open}
268
277
  className="group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent"
269
278
  disabled={disabled}
270
279
  >
@@ -566,7 +575,7 @@ function ComboboxChips({
566
575
  data-slot="combobox-chips"
567
576
  className={cn(
568
577
  fieldSurfaceWithin,
569
- "flex min-h-8.5 flex-wrap items-center gap-1.5 px-2.5 py-1.5 text-sm has-data-[slot=combobox-chip]:p-1.25",
578
+ "group/combobox-chips flex min-h-8.5 flex-wrap items-center gap-1.5 p-1.25 text-sm has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50",
570
579
  className
571
580
  )}
572
581
  {...props}
@@ -585,29 +594,36 @@ function ComboboxChip({
585
594
  className,
586
595
  children,
587
596
  showRemove = true,
588
- removeLabel = "Remove",
597
+ removeLabel,
589
598
  ...props
590
599
  }: ComboboxPrimitive.Chip.Props & {
591
600
  showRemove?: boolean
592
- /** Accessible name of the icon-only remove button. */
601
+ /**
602
+ * Accessible name of the icon-only remove button.
603
+ * @default `messages.combobox.remove`, "Remove"
604
+ */
593
605
  removeLabel?: string
594
606
  }) {
607
+ const t = useMessages("combobox", { remove: removeLabel })
595
608
  return (
596
609
  <ComboboxPrimitive.Chip
597
610
  data-slot="combobox-chip"
598
611
  className={cn(
599
- "bg-accent [--status-tone:var(--neutral-text)]", statusChipRing, "text-foreground flex h-6 w-fit items-center justify-center gap-1.5 rounded-[calc(var(--radius-xl)-5px)] ps-2 pe-2 text-xs font-medium whitespace-nowrap has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pe-1",
612
+ chipShape,
613
+ "text-foreground flex w-fit max-w-full min-w-0 items-center justify-center gap-1.5 ps-2 pe-2 has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pe-1",
600
614
  className
601
615
  )}
602
616
  {...props}
603
617
  >
604
- {children}
618
+ <span data-slot="combobox-chip-label" className="min-w-0 truncate">
619
+ {children}
620
+ </span>
605
621
  {showRemove && (
606
622
  <ComboboxPrimitive.ChipRemove
607
623
  render={<Button variant="ghost" size="icon-xs" />}
608
624
  className="size-4 rounded-none [--button-box:--spacing(4)] opacity-50 hover:opacity-100"
609
625
  data-slot="combobox-chip-remove"
610
- aria-label={removeLabel}
626
+ aria-label={t.remove}
611
627
  >
612
628
  <XIcon className="pointer-events-none" />
613
629
  </ComboboxPrimitive.ChipRemove>
@@ -626,12 +642,121 @@ function ComboboxChipsInput({
626
642
  <ComboboxPrimitive.Input
627
643
  ref={inputRef}
628
644
  data-slot="combobox-chip-input"
629
- className={cn("min-w-16 flex-1 outline-none", className)}
645
+ className={cn(
646
+ // The field has 5px padding with and without chips. Alone, the input
647
+ // adds 5px, so the placeholder starts 10px in, as in other fields;
648
+ // after a chip it adds 4px to the 6px gap.
649
+ "placeholder:text-faint-foreground h-6 min-w-16 flex-1 bg-transparent ps-1.25 outline-none disabled:cursor-not-allowed group-has-data-[slot=combobox-chip]/combobox-chips:ps-1",
650
+ className
651
+ )}
630
652
  {...props}
631
653
  />
632
654
  )
633
655
  }
634
656
 
657
+ /**
658
+ * The "+N" chip: it stands in for the chips that do not fit on the field's
659
+ * one line. The same shape and fill as a ComboboxChip, without a remove
660
+ * button, with tabular digits so a new count does not change its width.
661
+ * It is a button: give it an `onClick` (open the list) and wrap it in a
662
+ * Tooltip that names the hidden values.
663
+ */
664
+ function ComboboxChipCount({
665
+ count,
666
+ className,
667
+ "aria-label": ariaLabel,
668
+ ...props
669
+ }: Omit<React.ComponentProps<"button">, "children"> & {
670
+ /** The number of hidden values. */
671
+ count: number
672
+ }) {
673
+ const t = useMessages("combobox", { more: ariaLabel })
674
+ return (
675
+ <button
676
+ type="button"
677
+ data-slot="combobox-chip-count"
678
+ aria-label={fillMessage(t.more, { count })}
679
+ className={cn(
680
+ chipShape,
681
+ chipCountBox,
682
+ "text-foreground cursor-default disabled:cursor-not-allowed",
683
+ className
684
+ )}
685
+ {...props}
686
+ >
687
+ +{count}
688
+ </button>
689
+ )
690
+ }
691
+
692
+ /**
693
+ * The trailing controls of a chips field: the clear-all × and the up/down
694
+ * chevrons that open the list. The × keeps its space while nothing is
695
+ * picked, so the first pick does not narrow the chips row. While a search
696
+ * loads, the chevrons turn into a spinner in the same box. Both buttons stay
697
+ * out of the tab order, like the ones in ComboboxInput: Backspace and the
698
+ * arrow keys do their work from the input.
699
+ */
700
+ function ComboboxChipsActions({
701
+ showClear,
702
+ isLoading = false,
703
+ clearLabel,
704
+ triggerLabel,
705
+ disabled,
706
+ className,
707
+ }: {
708
+ /** Something is picked: the × shows. */
709
+ showClear: boolean
710
+ /** A search is loading: the chevrons turn into a spinner. */
711
+ isLoading?: boolean
712
+ /**
713
+ * Accessible name of the clear-all button.
714
+ * @default `messages.combobox.clearAll`, "Clear all"
715
+ */
716
+ clearLabel?: string
717
+ /**
718
+ * Accessible name of the button that opens the list.
719
+ * @default `messages.combobox.open`, "Open options"
720
+ */
721
+ triggerLabel?: string
722
+ disabled?: boolean
723
+ className?: string
724
+ }) {
725
+ const t = useMessages("combobox", { clearAll: clearLabel, open: triggerLabel })
726
+ return (
727
+ <div
728
+ data-slot="combobox-chips-actions"
729
+ className={cn("ms-auto flex h-6 shrink-0 items-center gap-0.5 self-start", className)}
730
+ >
731
+ <ComboboxPrimitive.Clear
732
+ data-slot="combobox-clear"
733
+ keepMounted
734
+ aria-label={t.clearAll}
735
+ aria-hidden={showClear ? undefined : true}
736
+ tabIndex={-1}
737
+ disabled={disabled || !showClear}
738
+ render={<Button variant="ghost" size="icon-xs" />}
739
+ className={cn("text-muted-foreground hover:text-foreground", !showClear && "invisible")}
740
+ >
741
+ <XIcon className="pointer-events-none" />
742
+ </ComboboxPrimitive.Clear>
743
+ <ComboboxPrimitive.Trigger
744
+ tabIndex={-1}
745
+ aria-label={t.open}
746
+ disabled={disabled}
747
+ render={<Button variant="ghost" size="icon-xs" nativeButton />}
748
+ className="text-muted-foreground hover:text-foreground data-popup-open:text-foreground data-popup-open:bg-transparent aria-expanded:bg-transparent"
749
+ >
750
+ {isLoading ? (
751
+ <Loader2Icon data-slot="combobox-chips-loading" className="pointer-events-none motion-safe:animate-spin" />
752
+ ) : (
753
+ <ChevronsUpDownIcon className="pointer-events-none" />
754
+ )}
755
+ </ComboboxPrimitive.Trigger>
756
+ </div>
757
+ )
758
+ }
759
+
635
760
  function useComboboxAnchor() {
636
761
  return React.useRef<HTMLDivElement | null>(null)
637
762
  }
@@ -650,6 +775,8 @@ export {
650
775
  ComboboxChips,
651
776
  ComboboxChip,
652
777
  ComboboxChipsInput,
778
+ ComboboxChipCount,
779
+ ComboboxChipsActions,
653
780
  ComboboxTrigger,
654
781
  ComboboxValue,
655
782
  useComboboxAnchor,
@@ -5,6 +5,7 @@ import { Command as CommandPrimitive, useCommandState } from "cmdk"
5
5
 
6
6
  import { cn } from "@vendure-io/ui/lib/utils"
7
7
  import { MenuCheck, menuCheckItem } from "../../lib/menu-item.tsx"
8
+ import { useMessages } from "../../lib/format-messages.ts"
8
9
  import {
9
10
  Dialog,
10
11
  DialogContent,
@@ -35,24 +36,33 @@ function Command({
35
36
  }
36
37
 
37
38
  function CommandDialog({
38
- title = "Command Palette",
39
- description = "Search for a command to run...",
39
+ title,
40
+ description,
40
41
  children,
41
42
  className,
42
43
  showCloseButton = false,
43
44
  ...props
44
45
  }: Omit<React.ComponentProps<typeof Dialog>, "children"> & {
46
+ /**
47
+ * Screen-reader title of the dialog.
48
+ * @default `messages.command.title`, "Command Palette"
49
+ */
45
50
  title?: string
51
+ /**
52
+ * Screen-reader description of the dialog.
53
+ * @default `messages.command.description`, "Search for a command to run..."
54
+ */
46
55
  description?: string
47
56
  className?: string
48
57
  showCloseButton?: boolean
49
58
  children: React.ReactNode
50
59
  }) {
60
+ const t = useMessages("command", { title, description })
51
61
  return (
52
62
  <Dialog {...props}>
53
63
  <DialogHeader className="sr-only">
54
- <DialogTitle>{title}</DialogTitle>
55
- <DialogDescription>{description}</DialogDescription>
64
+ <DialogTitle>{t.title}</DialogTitle>
65
+ <DialogDescription>{t.description}</DialogDescription>
56
66
  </DialogHeader>
57
67
  {/* The palette: 600px wide, 12% of the viewport from the top so the
58
68
  list can grow down without moving the input. It opens often, so its
@@ -1,15 +1,20 @@
1
+ "use client"
2
+
1
3
  import * as React from "react"
2
4
 
3
5
  import { cn } from "@vendure-io/ui/lib/utils"
4
6
  import { Button } from "@vendure-io/ui/components/atoms/button"
5
7
  import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
6
8
  import { warnDeprecated } from "../../lib/deprecated.ts"
9
+ import { useMessages } from "../../lib/format-messages.ts"
7
10
 
8
- function Pagination({ className, ...props }: React.ComponentProps<"nav">) {
11
+ // `aria-label` defaults to `messages.pagination.nav`, "pagination".
12
+ function Pagination({ className, "aria-label": ariaLabel, ...props }: React.ComponentProps<"nav">) {
13
+ const t = useMessages("pagination", { nav: ariaLabel })
9
14
  return (
10
15
  <nav
11
16
  role="navigation"
12
- aria-label="pagination"
17
+ aria-label={t.nav}
13
18
  data-slot="pagination"
14
19
  className={cn("mx-auto flex w-full justify-center", className)}
15
20
  {...props}
@@ -70,35 +75,53 @@ function PaginationLink({
70
75
 
71
76
  function PaginationPrevious({
72
77
  className,
73
- text = "Previous",
78
+ text,
79
+ "aria-label": ariaLabel,
74
80
  ...props
75
- }: React.ComponentProps<typeof PaginationLink> & { text?: string }) {
81
+ }: React.ComponentProps<typeof PaginationLink> & {
82
+ /**
83
+ * The visible text, from the `sm` breakpoint up.
84
+ * @default `messages.pagination.previousText`, "Previous"
85
+ */
86
+ text?: string
87
+ }) {
88
+ // `aria-label` defaults to `messages.pagination.previous`, "Go to previous page".
89
+ const t = useMessages("pagination", { previousText: text, previous: ariaLabel })
76
90
  return (
77
91
  <PaginationLink
78
- aria-label="Go to previous page"
92
+ aria-label={t.previous}
79
93
  size="default"
80
94
  className={cn("ps-2!", className)}
81
95
  {...props}
82
96
  >
83
97
  <ChevronLeftIcon data-icon="inline-start" />
84
- <span className="hidden sm:block">{text}</span>
98
+ <span className="hidden sm:block">{t.previousText}</span>
85
99
  </PaginationLink>
86
100
  )
87
101
  }
88
102
 
89
103
  function PaginationNext({
90
104
  className,
91
- text = "Next",
105
+ text,
106
+ "aria-label": ariaLabel,
92
107
  ...props
93
- }: React.ComponentProps<typeof PaginationLink> & { text?: string }) {
108
+ }: React.ComponentProps<typeof PaginationLink> & {
109
+ /**
110
+ * The visible text, from the `sm` breakpoint up.
111
+ * @default `messages.pagination.nextText`, "Next"
112
+ */
113
+ text?: string
114
+ }) {
115
+ // `aria-label` defaults to `messages.pagination.next`, "Go to next page".
116
+ const t = useMessages("pagination", { nextText: text, next: ariaLabel })
94
117
  return (
95
118
  <PaginationLink
96
- aria-label="Go to next page"
119
+ aria-label={t.next}
97
120
  size="default"
98
121
  className={cn("pe-2!", className)}
99
122
  {...props}
100
123
  >
101
- <span className="hidden sm:block">{text}</span>
124
+ <span className="hidden sm:block">{t.nextText}</span>
102
125
  <ChevronRightIcon data-icon="inline-end" />
103
126
  </PaginationLink>
104
127
  )
@@ -106,8 +129,16 @@ function PaginationNext({
106
129
 
107
130
  function PaginationEllipsis({
108
131
  className,
132
+ label,
109
133
  ...props
110
- }: React.ComponentProps<"span">) {
134
+ }: React.ComponentProps<"span"> & {
135
+ /**
136
+ * Screen-reader text of the ellipsis.
137
+ * @default `messages.pagination.more`, "More pages"
138
+ */
139
+ label?: string
140
+ }) {
141
+ const t = useMessages("pagination", { more: label })
111
142
  return (
112
143
  <span
113
144
  aria-hidden
@@ -120,7 +151,7 @@ function PaginationEllipsis({
120
151
  >
121
152
  <MoreHorizontalIcon
122
153
  />
123
- <span className="sr-only">More pages</span>
154
+ <span className="sr-only">{t.more}</span>
124
155
  </span>
125
156
  )
126
157
  }