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

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 (31) 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 +23 -10
  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/anonymized-token.tsx +19 -18
  10. package/src/components/molecules/app-shell.tsx +14 -5
  11. package/src/components/molecules/checklist/checklist.tsx +47 -17
  12. package/src/components/molecules/choice-card.tsx +3 -0
  13. package/src/components/molecules/confirm-dialog.tsx +6 -4
  14. package/src/components/molecules/data-table/data-table-filters.tsx +25 -7
  15. package/src/components/molecules/data-table/data-table-types.tsx +33 -16
  16. package/src/components/molecules/data-table/data-table-view-options.tsx +14 -4
  17. package/src/components/molecules/data-table/data-table.tsx +47 -26
  18. package/src/components/molecules/data-table/table-pagination.tsx +51 -29
  19. package/src/components/molecules/date-picker.tsx +4 -2
  20. package/src/components/molecules/date-range-picker.tsx +6 -2
  21. package/src/components/molecules/date-time-picker.tsx +4 -2
  22. package/src/components/molecules/file-dropzone.tsx +16 -5
  23. package/src/components/molecules/id-chip.tsx +10 -8
  24. package/src/components/molecules/issued-secret.tsx +34 -24
  25. package/src/components/molecules/multi-select.tsx +6 -2
  26. package/src/components/molecules/secret-value.tsx +26 -18
  27. package/src/components/molecules/skip-link.tsx +11 -9
  28. package/src/components/molecules/stat-card.tsx +2 -0
  29. package/src/components/molecules/state-views/error-state.tsx +18 -6
  30. package/src/components/molecules/state-views/loading-state.tsx +2 -0
  31. package/src/lib/format-messages.ts +176 -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.6",
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
  }
@@ -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
  >
@@ -585,13 +594,17 @@ 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"
@@ -607,7 +620,7 @@ function ComboboxChip({
607
620
  render={<Button variant="ghost" size="icon-xs" />}
608
621
  className="size-4 rounded-none [--button-box:--spacing(4)] opacity-50 hover:opacity-100"
609
622
  data-slot="combobox-chip-remove"
610
- aria-label={removeLabel}
623
+ aria-label={t.remove}
611
624
  >
612
625
  <XIcon className="pointer-events-none" />
613
626
  </ComboboxPrimitive.ChipRemove>
@@ -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
  }
@@ -286,9 +286,17 @@ function Sidebar({
286
286
  function SidebarTrigger({
287
287
  className,
288
288
  onClick,
289
+ label,
289
290
  ...props
290
- }: React.ComponentProps<typeof Button>) {
291
+ }: React.ComponentProps<typeof Button> & {
292
+ /**
293
+ * Screen-reader text of the button.
294
+ * @default `messages.sidebar.toggle`, "Toggle Sidebar"
295
+ */
296
+ label?: string
297
+ }) {
291
298
  const { toggleSidebar } = useSidebar()
299
+ const t = useMessages("sidebar", { toggle: label })
292
300
 
293
301
  return (
294
302
  <Button
@@ -304,22 +312,33 @@ function SidebarTrigger({
304
312
  {...props}
305
313
  >
306
314
  <PanelLeftIcon />
307
- <span className="sr-only">Toggle Sidebar</span>
315
+ <span className="sr-only">{t.toggle}</span>
308
316
  </Button>
309
317
  )
310
318
  }
311
319
 
312
- function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
320
+ function SidebarRail({
321
+ className,
322
+ label,
323
+ ...props
324
+ }: React.ComponentProps<"button"> & {
325
+ /**
326
+ * Accessible name and tooltip of the rail.
327
+ * @default `messages.sidebar.toggle`, "Toggle Sidebar"
328
+ */
329
+ label?: string
330
+ }) {
313
331
  const { toggleSidebar } = useSidebar()
332
+ const t = useMessages("sidebar", { toggle: label })
314
333
 
315
334
  return (
316
335
  <button
317
336
  data-sidebar="rail"
318
337
  data-slot="sidebar-rail"
319
- aria-label="Toggle Sidebar"
338
+ aria-label={t.toggle}
320
339
  tabIndex={-1}
321
340
  onClick={toggleSidebar}
322
- title="Toggle Sidebar"
341
+ title={t.toggle}
323
342
  className={cn(
324
343
  "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 transition-[inset-inline-start,inset-inline-end,translate,background-color] ease-drawer group-data-[side=start]:-end-4 group-data-[side=end]:start-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] sm:flex ltr:-translate-x-1/2 rtl:translate-x-1/2",
325
344
  "in-data-[side=start]:ltr:cursor-w-resize in-data-[side=start]:rtl:cursor-e-resize in-data-[side=end]:ltr:cursor-e-resize in-data-[side=end]:rtl:cursor-w-resize",
@@ -1,9 +1,14 @@
1
+ "use client"
2
+
1
3
  import { cn } from "@vendure-io/ui/lib/utils"
2
4
  import { Loader2Icon } from "lucide-react"
5
+ import { useMessages } from "../../lib/format-messages.ts"
3
6
 
4
- function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
7
+ // `aria-label` defaults to `messages.spinner.loading`, "Loading".
8
+ function Spinner({ className, "aria-label": ariaLabel, ...props }: React.ComponentProps<"svg">) {
9
+ const t = useMessages("spinner", { loading: ariaLabel })
5
10
  return (
6
- <Loader2Icon role="status" aria-label="Loading" className={cn("size-4 animate-spin motion-reduce:animate-none", className)} {...props} />
11
+ <Loader2Icon role="status" aria-label={t.loading} className={cn("size-4 animate-spin motion-reduce:animate-none", className)} {...props} />
7
12
  )
8
13
  }
9
14
 
@@ -51,9 +51,9 @@ interface AnonymizedTokenProps extends Omit<React.ComponentProps<'span'>, 'child
51
51
  previewSuffixLength?: number;
52
52
  /** Text placed between visible preview segments. @default "..." */
53
53
  previewSeparator?: string;
54
- /** Accessible name while the preview is blurred. @default "Partially obscured token" */
54
+ /** Accessible name while the preview is blurred. @default `messages.anonymizedToken.obscured`, "Partially obscured token" */
55
55
  obscuredLabel?: string;
56
- /** Accessible name while the preview is sharp. @default "Partially visible token" */
56
+ /** Accessible name while the preview is sharp. @default `messages.anonymizedToken.preview`, "Partially visible token" */
57
57
  previewLabel?: string;
58
58
  /** Rendered when `value` is `null` or `''`. @default "—" */
59
59
  fallback?: React.ReactNode;
@@ -67,9 +67,9 @@ interface AnonymizedTokenProps extends Omit<React.ComponentProps<'span'>, 'child
67
67
  onCopied?: CopyButtonProps['onCopied'];
68
68
  /** Called when the clipboard write fails. Falls back to `CopyFeedbackProvider`. */
69
69
  onCopyError?: CopyButtonProps['onCopyError'];
70
- /** Accessible label before copying. @default "Copy token" */
70
+ /** Accessible label before copying. @default `messages.anonymizedToken.copy`, "Copy token" */
71
71
  copyLabel?: CopyButtonProps['copyLabel'];
72
- /** Accessible label while the copied state is active. @default "Token copied" */
72
+ /** Accessible label while the copied state is active. @default `messages.anonymizedToken.copied`, "Token copied" */
73
73
  copiedLabel?: CopyButtonProps['copiedLabel'];
74
74
  }
75
75
 
@@ -86,16 +86,16 @@ function AnonymizedToken({
86
86
  previewPrefixLength = 8,
87
87
  previewSuffixLength = 4,
88
88
  previewSeparator = '...',
89
- obscuredLabel = 'Partially obscured token',
90
- previewLabel = 'Partially visible token',
89
+ obscuredLabel,
90
+ previewLabel,
91
91
  fallback = '—',
92
92
  loadingLabel,
93
93
  copyable = true,
94
94
  timeout,
95
95
  onCopied,
96
96
  onCopyError,
97
- copyLabel = 'Copy token',
98
- copiedLabel = 'Token copied',
97
+ copyLabel,
98
+ copiedLabel,
99
99
  className,
100
100
  onMouseEnter,
101
101
  onMouseLeave,
@@ -105,7 +105,13 @@ function AnonymizedToken({
105
105
  }: AnonymizedTokenProps) {
106
106
  const [previewRevealed, setPreviewRevealed] = useState(false);
107
107
  const action = useCopyAction({ timeout, onCopied, onCopyError });
108
- const t = useMessages('anonymizedToken', { loading: loadingLabel });
108
+ const t = useMessages('anonymizedToken', {
109
+ loading: loadingLabel,
110
+ obscured: obscuredLabel,
111
+ preview: previewLabel,
112
+ copy: copyLabel,
113
+ copied: copiedLabel,
114
+ });
109
115
 
110
116
  // The skeleton is the chip's own box: 24px tall, rounded like the chip and
111
117
  // as wide as the preview this token will show (prefix, separator and
@@ -200,13 +206,13 @@ function AnonymizedToken({
200
206
  >
201
207
  {preview}
202
208
  </code>
203
- <span className="sr-only">{showRevealed ? previewLabel : obscuredLabel}</span>
209
+ <span className="sr-only">{showRevealed ? t.preview : t.obscured}</span>
204
210
  {copyable ? (
205
211
  <CopyButton
206
212
  value={value}
207
213
  copyAction={action}
208
- copyLabel={copyLabel}
209
- copiedLabel={copiedLabel}
214
+ copyLabel={t.copy}
215
+ copiedLabel={t.copied}
210
216
  {...chipCopyButtonProps}
211
217
  />
212
218
  ) : null}
@@ -217,12 +223,7 @@ function AnonymizedToken({
217
223
 
218
224
  // The whole chip copies, like `IdChip`. The tooltip never shows the value.
219
225
  return (
220
- <ChipCopyTooltip
221
- chip={chip}
222
- copied={action.copied}
223
- copyLabel={copyLabel}
224
- copiedLabel={copiedLabel}
225
- />
226
+ <ChipCopyTooltip chip={chip} copied={action.copied} copyLabel={t.copy} copiedLabel={t.copied} />
226
227
  );
227
228
  }
228
229
 
@@ -68,6 +68,12 @@ function AppShellContent({ className, ...props }: React.ComponentProps<'div'>) {
68
68
  // centred in 52px), and 12px to the divider after it (the 6px gap plus a
69
69
  // 6px end margin). The header owns these margins, so a margin a consumer
70
70
  // puts on the toggle does not apply.
71
+ //
72
+ // The end padding (pe-4) is the page gutter, --app-shell-page-gutter in
73
+ // pageFrameClassName, so the last item in the header ends where the page
74
+ // content does. The header is outside the page frame and cannot read that
75
+ // variable: change both together. On a window wider than the frame, the
76
+ // centred page ends before the header.
71
77
  const headerToggleClassName =
72
78
  '[&_[data-slot=sidebar-trigger]]:ms-0 [&_[data-slot=sidebar-trigger]]:me-1.5';
73
79
 
@@ -76,7 +82,8 @@ function AppShellHeader({ className, ...props }: React.ComponentProps<'header'>)
76
82
  <header
77
83
  data-slot="app-shell-header"
78
84
  className={cn(
79
- 'bg-background md:in-[[data-variant=inset]~[data-slot=sidebar-inset]]:bg-surface sticky top-0 z-10 flex h-13 shrink-0 items-center gap-1.5 pe-5 ps-3 shadow-[inset_0_-1px_0_var(--border)] forced-colors:after:pointer-events-none forced-colors:after:absolute forced-colors:after:inset-x-0 forced-colors:after:bottom-0 forced-colors:after:border-b forced-colors:after:border-[CanvasText]',
85
+ // biome-ignore lint/plugin/no-raw-shadow: the header hairline is an inset shadow so it never adds height
86
+ 'bg-background md:in-[[data-variant=inset]~[data-slot=sidebar-inset]]:bg-surface sticky top-0 z-10 flex h-13 shrink-0 items-center gap-1.5 pe-4 ps-3 shadow-[inset_0_-1px_0_var(--border)] forced-colors:after:pointer-events-none forced-colors:after:absolute forced-colors:after:inset-x-0 forced-colors:after:bottom-0 forced-colors:after:border-b forced-colors:after:border-[CanvasText]',
80
87
  headerToggleClassName,
81
88
  className,
82
89
  )}
@@ -117,9 +124,11 @@ function AppShellMain({
117
124
  const pageEnterClassName = 'animate-page-enter motion-reduce:animate-page-fade';
118
125
 
119
126
  // The page frame: one frame for every app on AppShell. The page is centred in
120
- // AppShellMain, its content is at most 1180px wide, and a gutter of 32px (16px
121
- // below 768px) sits on every side, the top and bottom included. The gutter is
122
- // outside the 1180px, so the frame is at most 1180px plus two gutters wide.
127
+ // AppShellMain, its content is at most 1480px wide, and a 16px gutter sits on
128
+ // every side at every width, the top and bottom included. The gutter is outside
129
+ // the 1480px, so the frame is at most 1480px plus two gutters wide.
130
+ // The end padding of AppShellHeader (pe-4) is the same value as the gutter:
131
+ // change both together.
123
132
  //
124
133
  // The values are CSS variables on the frame, `--app-shell-page-width` and
125
134
  // `--app-shell-page-gutter`, so a descendant can read them (a full-bleed band
@@ -127,7 +136,7 @@ const pageEnterClassName = 'animate-page-enter motion-reduce:animate-page-fade';
127
136
  // A page that wants a narrower column, such as a settings form at `max-w-4xl`,
128
137
  // puts it inside the frame; it stays left-aligned there.
129
138
  const pageFrameClassName =
130
- '[--app-shell-page-width:1180px] [--app-shell-page-gutter:--spacing(4)] md:[--app-shell-page-gutter:--spacing(8)] mx-auto w-full min-w-0 max-w-[calc(var(--app-shell-page-width)+2*var(--app-shell-page-gutter))] p-(--app-shell-page-gutter)';
139
+ '[--app-shell-page-width:1480px] [--app-shell-page-gutter:--spacing(4)] mx-auto w-full min-w-0 max-w-[calc(var(--app-shell-page-width)+2*var(--app-shell-page-gutter))] p-(--app-shell-page-gutter)';
131
140
 
132
141
  // AppShellPage wraps the page inside AppShellMain. It is the page frame (see
133
142
  // pageFrameClassName), and it is the page enter: when it mounts, the page