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

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 (86) hide show
  1. package/package.json +12 -10
  2. package/src/components/atoms/alert-dialog.tsx +1 -4
  3. package/src/components/atoms/alert.tsx +59 -35
  4. package/src/components/atoms/badge.tsx +2 -2
  5. package/src/components/atoms/breadcrumb.tsx +124 -49
  6. package/src/components/atoms/button-group.tsx +1 -1
  7. package/src/components/atoms/button.tsx +4 -3
  8. package/src/components/atoms/calendar.tsx +2 -2
  9. package/src/components/atoms/card.tsx +15 -2
  10. package/src/components/atoms/chart.tsx +3 -3
  11. package/src/components/atoms/checkbox.tsx +1 -1
  12. package/src/components/atoms/combobox.tsx +37 -26
  13. package/src/components/atoms/command.tsx +3 -3
  14. package/src/components/atoms/context-menu.tsx +5 -5
  15. package/src/components/atoms/dialog.tsx +30 -14
  16. package/src/components/atoms/dropdown-menu.tsx +1 -1
  17. package/src/components/atoms/hover-card.tsx +1 -1
  18. package/src/components/atoms/input-group.tsx +30 -12
  19. package/src/components/atoms/input-otp.tsx +2 -2
  20. package/src/components/atoms/input.tsx +13 -3
  21. package/src/components/atoms/menubar.tsx +2 -2
  22. package/src/components/atoms/native-select.tsx +1 -1
  23. package/src/components/atoms/navigation-menu.tsx +3 -3
  24. package/src/components/atoms/pagination.tsx +9 -3
  25. package/src/components/atoms/popover.tsx +1 -1
  26. package/src/components/atoms/select.tsx +3 -3
  27. package/src/components/atoms/sheet.tsx +35 -15
  28. package/src/components/atoms/sidebar.tsx +200 -31
  29. package/src/components/atoms/skeleton.tsx +6 -3
  30. package/src/components/atoms/switch.tsx +1 -1
  31. package/src/components/atoms/tabs.tsx +6 -2
  32. package/src/components/atoms/textarea.tsx +1 -1
  33. package/src/components/atoms/toggle.tsx +1 -1
  34. package/src/components/molecules/action-needed.tsx +483 -0
  35. package/src/components/molecules/anonymized-token.tsx +52 -8
  36. package/src/components/molecules/chip.tsx +37 -18
  37. package/src/components/molecules/choice-card.tsx +114 -9
  38. package/src/components/molecules/code-block/package-manager-storage.ts +50 -0
  39. package/src/components/molecules/code-block/process-code.ts +1 -1
  40. package/src/components/molecules/code-block.tsx +58 -47
  41. package/src/components/molecules/combobox-free-text.tsx +75 -20
  42. package/src/components/molecules/confirm-dialog.tsx +11 -1
  43. package/src/components/molecules/copyable-text.tsx +10 -8
  44. package/src/components/molecules/data-table/data-table-filters.tsx +14 -2
  45. package/src/components/molecules/data-table/data-table-helpers.tsx +109 -3
  46. package/src/components/molecules/data-table/data-table-row-count-storage.tsx +88 -0
  47. package/src/components/molecules/data-table/data-table-selection-storage.tsx +33 -15
  48. package/src/components/molecules/data-table/data-table-types.tsx +123 -13
  49. package/src/components/molecules/data-table/data-table.tsx +112 -55
  50. package/src/components/molecules/data-table/table-pagination.tsx +96 -14
  51. package/src/components/molecules/date-picker.tsx +55 -24
  52. package/src/components/molecules/date-range-picker.tsx +54 -23
  53. package/src/components/molecules/date-time-picker.tsx +60 -24
  54. package/src/components/molecules/date-time.tsx +38 -3
  55. package/src/components/molecules/elapsed-time.tsx +61 -12
  56. package/src/components/molecules/file-dropzone.tsx +139 -39
  57. package/src/components/molecules/format-provider.tsx +14 -4
  58. package/src/components/molecules/id-chip-chrome.tsx +114 -0
  59. package/src/components/molecules/id-chip.tsx +3 -107
  60. package/src/components/molecules/issued-secret.tsx +1 -1
  61. package/src/components/molecules/live-indicator.tsx +1 -1
  62. package/src/components/molecules/money.tsx +46 -4
  63. package/src/components/molecules/multi-select.tsx +58 -15
  64. package/src/components/molecules/page-header.tsx +6 -2
  65. package/src/components/molecules/password-input.tsx +11 -10
  66. package/src/components/molecules/relative-time.tsx +88 -16
  67. package/src/components/molecules/search-trigger.tsx +5 -3
  68. package/src/components/molecules/secret-value.tsx +10 -2
  69. package/src/components/molecules/stat-card.tsx +143 -33
  70. package/src/components/molecules/state-views/empty-state.tsx +16 -12
  71. package/src/components/molecules/state-views/error-state.tsx +19 -15
  72. package/src/components/molecules/state-views/loading-state.tsx +16 -6
  73. package/src/components/molecules/state-views/skeleton-parts.tsx +6 -4
  74. package/src/components/molecules/status-badge.tsx +11 -35
  75. package/src/components/molecules/time-tooltip.tsx +55 -1
  76. package/src/hooks/use-copy.ts +3 -1
  77. package/src/lib/deprecated.ts +71 -0
  78. package/src/lib/env.ts +9 -0
  79. package/src/lib/field-surface.ts +7 -7
  80. package/src/lib/format-messages.ts +192 -0
  81. package/src/lib/highlight.ts +1 -1
  82. package/src/lib/menu-item.tsx +1 -1
  83. package/src/lib/state-dictionary.ts +2 -3
  84. package/src/lib/tint-recipes.ts +10 -5
  85. package/src/lib/utils.ts +19 -1
  86. package/src/lib/dialog-padding.ts +0 -48
@@ -4,21 +4,31 @@ import * as React from "react"
4
4
  import { Input as InputPrimitive } from "@base-ui/react/input"
5
5
 
6
6
  import { cn } from "@vendure-io/ui/lib/utils"
7
- import { fieldSurface } from "@vendure-io/ui/lib/field-surface"
7
+ import { fieldSurface } from "../../lib/field-surface.ts"
8
8
  import { useFieldControlProps } from "@vendure-io/ui/components/atoms/field"
9
9
 
10
+ type InputProps = Omit<React.ComponentProps<"input">, "size"> & {
11
+ /**
12
+ * The field height: `default` is 34px, `sm` is 28px, the height of a small
13
+ * Button, for a dense toolbar or a search field next to small buttons. The
14
+ * native numeric `size` attribute is not supported; set a width instead.
15
+ */
16
+ size?: "sm" | "default"
17
+ }
18
+
10
19
  // The v3 look: a 34px field on the `muted` tint with a 1px inset hairline in
11
20
  // `border` (a real border only in forced-colors mode). Focus draws the ring
12
21
  // 2px inside the field, over the hairline, so a field in a dialog or a dense
13
22
  // form never touches its neighbours.
14
- function Input({ className, type, ...props }: React.ComponentProps<"input">) {
23
+ function Input({ className, type, size = "default", ...props }: InputProps) {
15
24
  return (
16
25
  <InputPrimitive
17
26
  type={type}
18
27
  data-slot="input"
28
+ data-size={size}
19
29
  className={cn(
20
30
  fieldSurface,
21
- "file:text-foreground placeholder:text-faint-foreground h-8.5 w-full min-w-0 px-2.5 py-1 text-base file:inline-flex file:h-6.5 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
31
+ "file:text-foreground placeholder:text-faint-foreground h-8.5 data-[size=sm]:h-7 w-full min-w-0 px-2.5 py-1 text-base file:inline-flex file:h-6.5 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
22
32
  className
23
33
  )}
24
34
  {...useFieldControlProps(props)}
@@ -129,7 +129,7 @@ function MenubarCheckboxItem({
129
129
  className={cn(
130
130
  menuItemDisabled,
131
131
  menuCheckItem,
132
- "not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground not-data-disabled:focus:**:text-accent-foreground relative flex min-h-8.5 cursor-default items-center gap-2 rounded-lg pe-2 ps-8 py-1.5 text-sm text-foreground-secondary outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>svg:not([class*='opacity-'])]:opacity-85",
132
+ "not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground not-data-disabled:focus:**:text-accent-foreground relative flex min-h-8.5 cursor-default items-center gap-2 rounded-[calc(var(--radius-2xl)-5px)] pe-2 ps-8 py-1.5 text-sm text-foreground-secondary outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>svg:not([class*='opacity-'])]:opacity-85",
133
133
  className
134
134
  )}
135
135
  checked={checked}
@@ -164,7 +164,7 @@ function MenubarRadioItem({
164
164
  className={cn(
165
165
  menuItemDisabled,
166
166
  menuRadioItem,
167
- "not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground not-data-disabled:focus:**:text-accent-foreground relative flex min-h-8.5 cursor-default items-center gap-2 rounded-lg pe-2 ps-8 py-1.5 text-sm text-foreground-secondary outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>svg:not([class*='opacity-'])]:opacity-85",
167
+ "not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground not-data-disabled:focus:**:text-accent-foreground relative flex min-h-8.5 cursor-default items-center gap-2 rounded-[calc(var(--radius-2xl)-5px)] pe-2 ps-8 py-1.5 text-sm text-foreground-secondary outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>svg:not([class*='opacity-'])]:opacity-85",
168
168
  className
169
169
  )}
170
170
  {...props}
@@ -3,7 +3,7 @@
3
3
  import * as React from "react"
4
4
 
5
5
  import { cn } from "@vendure-io/ui/lib/utils"
6
- import { fieldSurface } from "@vendure-io/ui/lib/field-surface"
6
+ import { fieldSurface } from "../../lib/field-surface.ts"
7
7
  import { useFieldControlProps } from "@vendure-io/ui/components/atoms/field"
8
8
  import { ChevronDownIcon } from "lucide-react"
9
9
 
@@ -118,7 +118,7 @@ function NavigationMenuPositioner({
118
118
  {...props}
119
119
  >
120
120
  {/* Opens with popupMotion. While open, it resizes to the next item's content in `popup-resize` (350ms). */}
121
- <NavigationMenuPrimitive.Popup className={cn("bg-popover text-popover-foreground shadow-overlay xs:w-(--popup-width) relative h-(--popup-height) w-(--popup-width) rounded-xl outline-none", popupMotion, "transition-[opacity,scale,translate,width,height] [transition-duration:var(--transition-duration-popup-fade),var(--transition-duration-normal),var(--transition-duration-normal),var(--transition-duration-popup-resize),var(--transition-duration-popup-resize)] motion-reduce:transition-opacity")}>
121
+ <NavigationMenuPrimitive.Popup className={cn("bg-popover text-popover-foreground shadow-overlay xs:w-(--popup-width) relative h-(--popup-height) w-(--popup-width) rounded-2xl outline-none", popupMotion, "transition-[opacity,scale,translate,width,height] [transition-duration:var(--transition-duration-popup-fade),var(--transition-duration-normal),var(--transition-duration-normal),var(--transition-duration-popup-resize),var(--transition-duration-popup-resize)] motion-reduce:transition-opacity")}>
122
122
  <NavigationMenuPrimitive.Viewport className="relative size-full overflow-hidden" />
123
123
  </NavigationMenuPrimitive.Popup>
124
124
  </NavigationMenuPrimitive.Positioner>
@@ -137,7 +137,7 @@ function NavigationMenuLink({
137
137
  <NavigationMenuPrimitive.Link
138
138
  data-slot="navigation-menu-link"
139
139
  className={cn(
140
- "data-active:text-foreground data-active:font-medium focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring hover:bg-muted focus:bg-muted relative flex items-center gap-1.5 rounded-sm p-2 text-sm transition-[color,background-color] outline-none [&_svg:not([class*='size-'])]:size-4 after:bg-foreground after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:opacity-0 after:transition-opacity data-active:after:opacity-100",
140
+ "data-active:text-foreground data-active:font-medium focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring hover:bg-muted focus:bg-muted relative flex items-center gap-1.5 rounded-[calc(var(--radius-2xl)-8px)] p-2 text-sm transition-[color,background-color] outline-none [&_svg:not([class*='size-'])]:size-4 after:bg-foreground after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:opacity-0 after:transition-opacity data-active:after:opacity-100",
141
141
  className
142
142
  )}
143
143
  {...props}
@@ -161,7 +161,7 @@ function NavigationMenuIndicator({
161
161
  )}
162
162
  {...props}
163
163
  >
164
- <div className="bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" />
164
+ <div className="bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm" />
165
165
  </NavigationMenuPrimitive.Icon>
166
166
  )
167
167
  }
@@ -3,6 +3,7 @@ import * as React from "react"
3
3
  import { cn } from "@vendure-io/ui/lib/utils"
4
4
  import { Button } from "@vendure-io/ui/components/atoms/button"
5
5
  import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
6
+ import { warnDeprecated } from "../../lib/deprecated.ts"
6
7
 
7
8
  function Pagination({ className, ...props }: React.ComponentProps<"nav">) {
8
9
  return (
@@ -34,27 +35,32 @@ function PaginationItem({ ...props }: React.ComponentProps<"li">) {
34
35
  }
35
36
 
36
37
  type PaginationLinkProps = {
38
+ active?: boolean
39
+ /** @deprecated Use `active`. Removed in 4.0. */
37
40
  isActive?: boolean
38
41
  } & Pick<React.ComponentProps<typeof Button>, "size"> &
39
42
  React.ComponentProps<"a">
40
43
 
41
44
  function PaginationLink({
42
45
  className,
46
+ active: activeProp,
43
47
  isActive,
44
48
  size = "icon",
45
49
  ...props
46
50
  }: PaginationLinkProps) {
51
+ if (isActive !== undefined) warnDeprecated("PaginationLink", "isActive", "active")
52
+ const active = activeProp ?? isActive
47
53
  return (
48
54
  <Button
49
- variant={isActive ? "outline" : "ghost"}
55
+ variant={active ? "outline" : "ghost"}
50
56
  size={size}
51
57
  className={cn(className)}
52
58
  nativeButton={false}
53
59
  render={
54
60
  <a
55
- aria-current={isActive ? "page" : undefined}
61
+ aria-current={active ? "page" : undefined}
56
62
  data-slot="pagination-link"
57
- data-active={isActive}
63
+ data-active={active}
58
64
  {...props}
59
65
  />
60
66
  }
@@ -63,7 +63,7 @@ function PopoverContent({
63
63
  ref={popupRef}
64
64
  data-slot="popover-content"
65
65
  className={cn(
66
- "bg-popover text-popover-foreground shadow-overlay z-50 flex w-72 flex-col gap-4 rounded-xl p-4 text-sm outline-hidden",
66
+ "bg-popover text-popover-foreground shadow-overlay z-50 flex w-72 flex-col gap-4 rounded-2xl p-4 text-sm outline-hidden",
67
67
  popupMotion,
68
68
  className
69
69
  )}
@@ -5,7 +5,7 @@ import { Select as SelectPrimitive } from "@base-ui/react/select"
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 { fieldSurface } from "@vendure-io/ui/lib/field-surface"
8
+ import { fieldSurface } from "../../lib/field-surface.ts"
9
9
  import { popupMotion } from "../../lib/popup-motion.ts"
10
10
  import { useFieldControlProps } from "@vendure-io/ui/components/atoms/field"
11
11
  import { ChevronDownIcon, ChevronUpIcon } from "lucide-react"
@@ -337,7 +337,7 @@ function SelectContent({
337
337
  <SelectPrimitive.Popup
338
338
  data-slot="select-content"
339
339
  data-align-trigger={alignItemWithTrigger}
340
- className={cn("bg-popover text-popover-foreground shadow-overlay relative isolate z-50 max-h-(--available-height) min-w-(--anchor-width) overflow-x-hidden overflow-y-auto rounded-xl", popupMotion, growFromTriggerMotion, className)}
340
+ className={cn("bg-popover text-popover-foreground shadow-overlay relative isolate z-50 max-h-(--available-height) min-w-(--anchor-width) overflow-x-hidden overflow-y-auto rounded-2xl", popupMotion, growFromTriggerMotion, className)}
341
341
  ref={popupRef}
342
342
  // A closing list is gone for assistive technology: its trigger no
343
343
  // longer points at it, and it takes no input while it fades out.
@@ -381,7 +381,7 @@ function SelectItem({
381
381
  className={cn(
382
382
  menuItemDisabled,
383
383
  menuCheckItem,
384
- "not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground not-data-[variant=destructive]:not-data-disabled:focus:**:text-accent-foreground relative flex min-h-8.5 w-full cursor-default items-center gap-2 rounded-lg py-1.5 pe-8 ps-2 text-sm text-foreground-secondary data-selected:text-foreground outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>:first-child>svg:not([class*='opacity-'])]:opacity-55 [&>:first-child>svg:not([class*='opacity-'])]:transition-opacity [&>:first-child>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>:first-child>svg:not([class*='opacity-'])]:opacity-85 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
384
+ "not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground not-data-[variant=destructive]:not-data-disabled:focus:**:text-accent-foreground relative flex min-h-8.5 w-full cursor-default items-center gap-2 rounded-[calc(var(--radius-2xl)-5px)] py-1.5 pe-8 ps-2 text-sm text-foreground-secondary data-selected:text-foreground outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>:first-child>svg:not([class*='opacity-'])]:opacity-55 [&>:first-child>svg:not([class*='opacity-'])]:transition-opacity [&>:first-child>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>:first-child>svg:not([class*='opacity-'])]:opacity-85 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
385
385
  className
386
386
  )}
387
387
  {...props}
@@ -4,11 +4,13 @@ import * as React from "react"
4
4
  import { Dialog as SheetPrimitive } from "@base-ui/react/dialog"
5
5
 
6
6
  import { cn } from "@vendure-io/ui/lib/utils"
7
+ import { useMessages } from "../../lib/format-messages.ts"
7
8
  import { Button } from "@vendure-io/ui/components/atoms/button"
8
9
  import { XIcon } from "lucide-react"
9
10
  import { usePopupDir } from "../../lib/popup-direction.ts"
10
11
  import { usePinnedHeight } from "../../hooks/use-pinned-height.ts"
11
12
  import { triggerSlot } from "../../lib/trigger-slot.ts"
13
+ import { logicalSide, type PhysicalSide } from "../../lib/deprecated.ts"
12
14
 
13
15
  function Sheet({ ...props }: SheetPrimitive.Root.Props) {
14
16
  return <SheetPrimitive.Root data-slot="sheet" {...props} />
@@ -40,10 +42,11 @@ function SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) {
40
42
  }
41
43
 
42
44
  // Tells SheetHeader to host the close button, so the ✕ stays pinned with the
43
- // header while the body scrolls.
44
- const SheetCloseButtonContext = React.createContext(false)
45
+ // header while the body scrolls. The value is the button's accessible name, or
46
+ // null when the sheet shows no ✕.
47
+ const SheetCloseButtonContext = React.createContext<string | null>(null)
45
48
 
46
- function SheetCloseButton({ className }: { className?: string }) {
49
+ function SheetCloseButton({ className, label }: { className?: string; label: string }) {
47
50
  return (
48
51
  <SheetPrimitive.Close
49
52
  data-slot="sheet-close"
@@ -57,37 +60,51 @@ function SheetCloseButton({ className }: { className?: string }) {
57
60
  >
58
61
  <XIcon
59
62
  />
60
- <span className="sr-only">Close</span>
63
+ <span className="sr-only">{label}</span>
61
64
  </SheetPrimitive.Close>
62
65
  )
63
66
  }
64
67
 
65
- // The width of a left or right sheet per size, as whole class strings so
68
+ // The width of a start or end sheet per size, as whole class strings so
66
69
  // Tailwind finds them in this source. A top or bottom sheet spans the viewport
67
70
  // and ignores the size. Below `sm` every side sheet is 3/4 of the viewport.
68
71
  const sheetSizes = {
69
- default: "data-[side=left]:sm:max-w-lg data-[side=right]:sm:max-w-lg",
70
- xl: "data-[side=left]:sm:max-w-200 data-[side=right]:sm:max-w-200",
72
+ default: "data-[side=start]:sm:max-w-lg data-[side=end]:sm:max-w-lg",
73
+ xl: "data-[side=start]:sm:max-w-200 data-[side=end]:sm:max-w-200",
71
74
  } as const
72
75
 
73
76
  function SheetContent({
74
77
  className,
75
78
  children,
76
- side = "right",
79
+ side: sideProp = "end",
77
80
  size = "default",
78
81
  showCloseButton = true,
82
+ closeLabel,
79
83
  ...props
80
84
  }: SheetPrimitive.Popup.Props & {
81
- side?: "top" | "right" | "bottom" | "left"
82
85
  /**
83
- * The width of a left or right sheet. `default` (512px): a short form or a
86
+ * The edge the sheet slides in from. `start` and `end` follow the reading
87
+ * direction: in right-to-left, `start` is the right edge. Defaults to `end`.
88
+ * `left` and `right` are deprecated: use `start` or `end`. They are removed
89
+ * in 4.0.
90
+ */
91
+ side?: "top" | "bottom" | "start" | "end" | PhysicalSide
92
+ /**
93
+ * The width of a start or end sheet. `default` (512px): a short form or a
84
94
  * settings list. `xl` (800px): a table or a wide form. Both stay at 3/4 of
85
95
  * the viewport below 640px. Top and bottom sheets ignore it.
86
96
  */
87
97
  size?: keyof typeof sheetSizes
88
98
  showCloseButton?: boolean
99
+ /**
100
+ * The ✕'s accessible name. Defaults to `messages.sheet.close` from
101
+ * `FormatProvider`, then "Close".
102
+ */
103
+ closeLabel?: string
89
104
  }) {
90
105
  const dir = usePopupDir()
106
+ const side = logicalSide("SheetContent", sideProp, dir)
107
+ const t = useMessages("sheet", { close: closeLabel })
91
108
  return (
92
109
  <SheetPortal>
93
110
  <SheetOverlay />
@@ -98,18 +115,21 @@ function SheetContent({
98
115
  data-side={side}
99
116
  data-size={size}
100
117
  className={cn(
101
- "group/sheet-content bg-overlay fixed z-50 flex flex-col gap-4 overflow-y-auto overscroll-contain [scroll-padding-block:calc(var(--pinned-header-height,0px)+--spacing(1))_calc(var(--pinned-footer-height,0px)+--spacing(1))] bg-clip-padding text-sm shadow-overlay transition-[opacity,translate] duration-normal ease-drawer data-starting-style:opacity-0 data-ending-style:opacity-0 data-ending-style:duration-fast motion-safe:data-[side=right]:data-starting-style:translate-x-10 motion-safe:data-[side=right]:data-ending-style:translate-x-10 motion-safe:data-[side=left]:data-starting-style:-translate-x-10 motion-safe:data-[side=left]:data-ending-style:-translate-x-10 motion-safe:data-[side=top]:data-starting-style:-translate-y-10 motion-safe:data-[side=top]:data-ending-style:-translate-y-10 motion-safe:data-[side=bottom]:data-starting-style:translate-y-10 motion-safe:data-[side=bottom]:data-ending-style:translate-y-10 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:max-h-dvh data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:max-h-dvh",
118
+ "group/sheet-content bg-overlay fixed z-50 flex flex-col gap-4 overflow-y-auto overscroll-contain [scroll-padding-block:calc(var(--pinned-header-height,0px)+--spacing(1))_calc(var(--pinned-footer-height,0px)+--spacing(1))] bg-clip-padding text-sm shadow-overlay transition-[opacity,translate] duration-normal ease-drawer data-starting-style:opacity-0 data-ending-style:opacity-0 data-ending-style:duration-fast motion-safe:data-[side=end]:data-starting-style:translate-x-10 motion-safe:data-[side=end]:data-ending-style:translate-x-10 motion-safe:rtl:data-[side=end]:data-starting-style:-translate-x-10 motion-safe:rtl:data-[side=end]:data-ending-style:-translate-x-10 motion-safe:data-[side=start]:data-starting-style:-translate-x-10 motion-safe:data-[side=start]:data-ending-style:-translate-x-10 motion-safe:rtl:data-[side=start]:data-starting-style:translate-x-10 motion-safe:rtl:data-[side=start]:data-ending-style:translate-x-10 motion-safe:data-[side=top]:data-starting-style:-translate-y-10 motion-safe:data-[side=top]:data-ending-style:-translate-y-10 motion-safe:data-[side=bottom]:data-starting-style:translate-y-10 motion-safe:data-[side=bottom]:data-ending-style:translate-y-10 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:max-h-dvh data-[side=start]:inset-y-0 data-[side=start]:start-0 data-[side=start]:h-full data-[side=start]:w-3/4 data-[side=end]:inset-y-0 data-[side=end]:end-0 data-[side=end]:h-full data-[side=end]:w-3/4 data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:max-h-dvh",
102
119
  sheetSizes[size],
103
120
  className
104
121
  )}
105
122
  {...props}
106
123
  >
107
- <SheetCloseButtonContext.Provider value={showCloseButton}>
124
+ <SheetCloseButtonContext.Provider value={showCloseButton ? t.close : null}>
108
125
  {children}
109
126
  </SheetCloseButtonContext.Provider>
110
127
  {/* A sheet without a SheetHeader keeps the ✕ here, in the corner. */}
111
128
  {showCloseButton && (
112
- <SheetCloseButton className="group-has-data-[slot=sheet-header]/sheet-content:hidden" />
129
+ <SheetCloseButton
130
+ label={t.close}
131
+ className="group-has-data-[slot=sheet-header]/sheet-content:hidden"
132
+ />
113
133
  )}
114
134
  </SheetPrimitive.Popup>
115
135
  </SheetPortal>
@@ -120,7 +140,7 @@ function SheetContent({
120
140
  // so a scrolled body passes under them. Their own 16px padding keeps the body
121
141
  // clear of their text. Each measures its height for the sheet's scroll padding.
122
142
  function SheetHeader({ className, children, ref, ...props }: React.ComponentProps<"div">) {
123
- const showCloseButton = React.useContext(SheetCloseButtonContext)
143
+ const closeLabel = React.useContext(SheetCloseButtonContext)
124
144
  const pinnedRef = usePinnedHeight("--pinned-header-height", "sheet-content", ref)
125
145
  return (
126
146
  <div
@@ -133,7 +153,7 @@ function SheetHeader({ className, children, ref, ...props }: React.ComponentProp
133
153
  {...props}
134
154
  >
135
155
  {children}
136
- {showCloseButton && <SheetCloseButton />}
156
+ {closeLabel !== null && <SheetCloseButton label={closeLabel} />}
137
157
  </div>
138
158
  )
139
159
  }