@vendure-io/ui 3.0.0-next.4 → 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 (89) hide show
  1. package/package.json +12 -11
  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 +154 -59
  6. package/src/components/atoms/button-group.tsx +1 -1
  7. package/src/components/atoms/button.tsx +2 -2
  8. package/src/components/atoms/calendar.tsx +2 -2
  9. package/src/components/atoms/card.tsx +15 -2
  10. package/src/components/atoms/carousel.tsx +33 -7
  11. package/src/components/atoms/chart.tsx +3 -3
  12. package/src/components/atoms/checkbox.tsx +1 -1
  13. package/src/components/atoms/combobox.tsx +60 -36
  14. package/src/components/atoms/command.tsx +17 -7
  15. package/src/components/atoms/context-menu.tsx +5 -5
  16. package/src/components/atoms/dialog.tsx +30 -14
  17. package/src/components/atoms/dropdown-menu.tsx +1 -1
  18. package/src/components/atoms/hover-card.tsx +1 -1
  19. package/src/components/atoms/input-group.tsx +30 -12
  20. package/src/components/atoms/input-otp.tsx +2 -2
  21. package/src/components/atoms/input.tsx +13 -3
  22. package/src/components/atoms/menubar.tsx +2 -2
  23. package/src/components/atoms/native-select.tsx +1 -1
  24. package/src/components/atoms/navigation-menu.tsx +3 -3
  25. package/src/components/atoms/pagination.tsx +52 -15
  26. package/src/components/atoms/popover.tsx +1 -1
  27. package/src/components/atoms/select.tsx +3 -3
  28. package/src/components/atoms/sheet.tsx +35 -15
  29. package/src/components/atoms/sidebar.tsx +224 -36
  30. package/src/components/atoms/skeleton.tsx +6 -3
  31. package/src/components/atoms/spinner.tsx +7 -2
  32. package/src/components/atoms/tabs.tsx +6 -2
  33. package/src/components/atoms/textarea.tsx +1 -1
  34. package/src/components/atoms/toggle.tsx +1 -1
  35. package/src/components/molecules/action-needed.tsx +483 -0
  36. package/src/components/molecules/anonymized-token.tsx +70 -25
  37. package/src/components/molecules/app-shell.tsx +14 -5
  38. package/src/components/molecules/checklist/checklist.tsx +47 -17
  39. package/src/components/molecules/chip.tsx +37 -19
  40. package/src/components/molecules/choice-card.tsx +117 -9
  41. package/src/components/molecules/code-block/package-manager-storage.ts +50 -0
  42. package/src/components/molecules/code-block/process-code.ts +1 -1
  43. package/src/components/molecules/code-block.tsx +58 -47
  44. package/src/components/molecules/combobox-free-text.tsx +75 -20
  45. package/src/components/molecules/confirm-dialog.tsx +17 -5
  46. package/src/components/molecules/copyable-text.tsx +10 -8
  47. package/src/components/molecules/data-table/data-table-filters.tsx +36 -6
  48. package/src/components/molecules/data-table/data-table-helpers.tsx +109 -3
  49. package/src/components/molecules/data-table/data-table-row-count-storage.tsx +88 -0
  50. package/src/components/molecules/data-table/data-table-selection-storage.tsx +33 -15
  51. package/src/components/molecules/data-table/data-table-types.tsx +156 -29
  52. package/src/components/molecules/data-table/data-table-view-options.tsx +14 -4
  53. package/src/components/molecules/data-table/data-table.tsx +156 -75
  54. package/src/components/molecules/data-table/table-pagination.tsx +142 -38
  55. package/src/components/molecules/date-picker.tsx +58 -25
  56. package/src/components/molecules/date-range-picker.tsx +59 -24
  57. package/src/components/molecules/date-time-picker.tsx +63 -25
  58. package/src/components/molecules/date-time.tsx +38 -3
  59. package/src/components/molecules/elapsed-time.tsx +61 -12
  60. package/src/components/molecules/file-dropzone.tsx +151 -40
  61. package/src/components/molecules/format-provider.tsx +14 -4
  62. package/src/components/molecules/id-chip-chrome.tsx +114 -0
  63. package/src/components/molecules/id-chip.tsx +13 -115
  64. package/src/components/molecules/issued-secret.tsx +35 -25
  65. package/src/components/molecules/live-indicator.tsx +1 -1
  66. package/src/components/molecules/money.tsx +44 -3
  67. package/src/components/molecules/multi-select.tsx +62 -16
  68. package/src/components/molecules/page-header.tsx +6 -2
  69. package/src/components/molecules/password-input.tsx +11 -10
  70. package/src/components/molecules/relative-time.tsx +88 -16
  71. package/src/components/molecules/search-trigger.tsx +5 -3
  72. package/src/components/molecules/secret-value.tsx +35 -19
  73. package/src/components/molecules/skip-link.tsx +11 -9
  74. package/src/components/molecules/stat-card.tsx +145 -33
  75. package/src/components/molecules/state-views/empty-state.tsx +16 -12
  76. package/src/components/molecules/state-views/error-state.tsx +36 -20
  77. package/src/components/molecules/state-views/loading-state.tsx +18 -6
  78. package/src/components/molecules/state-views/skeleton-parts.tsx +6 -4
  79. package/src/components/molecules/status-badge.tsx +11 -35
  80. package/src/components/molecules/time-tooltip.tsx +55 -1
  81. package/src/hooks/use-copy.ts +3 -1
  82. package/src/lib/deprecated.ts +71 -0
  83. package/src/lib/field-surface.ts +7 -7
  84. package/src/lib/format-messages.ts +368 -0
  85. package/src/lib/highlight.ts +1 -1
  86. package/src/lib/menu-item.tsx +1 -1
  87. package/src/lib/tint-recipes.ts +10 -5
  88. package/src/lib/utils.ts +19 -1
  89. package/src/lib/dialog-padding.ts +0 -48
@@ -5,10 +5,10 @@ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"
5
5
 
6
6
  import type { Tone } from "@vendure-io/ui/lib/state-dictionary"
7
7
  import { cn } from "@vendure-io/ui/lib/utils"
8
+ import { useMessages } from "../../lib/format-messages.ts"
8
9
  import { Button } from "@vendure-io/ui/components/atoms/button"
9
10
  import { XIcon } from "lucide-react"
10
11
  import { usePopupDir } from "../../lib/popup-direction.ts"
11
- import { dialogPaddingStyle } from "../../lib/dialog-padding.ts"
12
12
  import { usePinnedHeight } from "../../hooks/use-pinned-height.ts"
13
13
  import { triggerSlot } from "../../lib/trigger-slot.ts"
14
14
 
@@ -55,10 +55,11 @@ function DialogOverlay({
55
55
  }
56
56
 
57
57
  // Tells DialogHeader to host the close button, so the ✕ stays pinned with the
58
- // header while the body scrolls.
59
- const DialogCloseButtonContext = React.createContext(false)
58
+ // header while the body scrolls. The value is the button's accessible name, or
59
+ // null when the dialog shows no ✕.
60
+ const DialogCloseButtonContext = React.createContext<string | null>(null)
60
61
 
61
- function DialogCloseButton({ className }: { className?: string }) {
62
+ function DialogCloseButton({ className, label }: { className?: string; label: string }) {
62
63
  return (
63
64
  <DialogPrimitive.Close
64
65
  data-slot="dialog-close"
@@ -73,7 +74,7 @@ function DialogCloseButton({ className }: { className?: string }) {
73
74
  >
74
75
  <XIcon
75
76
  />
76
- <span className="sr-only">Close</span>
77
+ <span className="sr-only">{label}</span>
77
78
  </DialogPrimitive.Close>
78
79
  )
79
80
  }
@@ -94,8 +95,8 @@ function DialogContent({
94
95
  children,
95
96
  size = "default",
96
97
  showCloseButton,
98
+ closeLabel,
97
99
  overlayClassName,
98
- style,
99
100
  ...props
100
101
  }: DialogPrimitive.Popup.Props & {
101
102
  /**
@@ -114,6 +115,11 @@ function DialogContent({
114
115
  * wins over that.
115
116
  */
116
117
  showCloseButton?: boolean
118
+ /**
119
+ * The ✕'s accessible name. Defaults to `messages.dialog.close` from
120
+ * `FormatProvider`, then "Close".
121
+ */
122
+ closeLabel?: string
117
123
  /** Classes for the backdrop behind the dialog, e.g. `bg-scrim-subtle`. */
118
124
  overlayClassName?: string
119
125
  }) {
@@ -124,12 +130,13 @@ function DialogContent({
124
130
  return () => setCloseControls((count) => count - 1)
125
131
  }, [])
126
132
  const showClose = showCloseButton ?? closeControls === 0
133
+ const t = useMessages("dialog", { close: closeLabel })
127
134
  return (
128
135
  <DialogPortal>
129
136
  <DialogOverlay className={overlayClassName} />
130
137
  {/* Enters from 4px below at 96%: opacity 200ms, scale and translate 240ms on the strong ease-out. Leaves to 98% (opacity 120ms on `ease`, scale 140ms on the strong ease-out). The scrim fades in 180ms and out in 140ms. Reduced motion keeps the fades. */}
131
138
  {/* At most the viewport height less 1rem on each side. A taller dialog scrolls inside; DialogHeader and DialogFooter stick to its top and bottom edges. */}
132
- {/* The padding is `--dialog-padding` (20px), and the pinned header and footer reach over it. Change the variable; a `p-*` or `px-*` class also sets it (dialogPaddingStyle). */}
139
+ {/* The padding is `--dialog-padding` (20px), and the pinned header and footer reach over it. Change the variable, not the padding: a `p-*` class leaves the header and the footer at 20px. */}
133
140
  {/* One column as wide as the space inside the padding: content wider than that shrinks or wraps inside it instead of widening the dialog past its padding. */}
134
141
  {/* The scroll padding is the pinned header's and footer's measured heights plus 4px for a focus ring: a focused field scrolls clear of both. */}
135
142
  <DialogPrimitive.Popup
@@ -141,17 +148,19 @@ function DialogContent({
141
148
  dialogSizes[size],
142
149
  className
143
150
  )}
144
- style={dialogPaddingStyle(className, style)}
145
151
  {...props}
146
152
  >
147
153
  <DialogCloseControlContext.Provider value={registerCloseControl}>
148
- <DialogCloseButtonContext.Provider value={showClose}>
154
+ <DialogCloseButtonContext.Provider value={showClose ? t.close : null}>
149
155
  {children}
150
156
  </DialogCloseButtonContext.Provider>
151
157
  </DialogCloseControlContext.Provider>
152
158
  {/* A dialog without a DialogHeader keeps the ✕ here, in the corner. */}
153
159
  {showClose && (
154
- <DialogCloseButton className="group-has-data-[slot=dialog-header]/dialog-content:hidden" />
160
+ <DialogCloseButton
161
+ label={t.close}
162
+ className="group-has-data-[slot=dialog-header]/dialog-content:hidden"
163
+ />
155
164
  )}
156
165
  </DialogPrimitive.Popup>
157
166
  </DialogPortal>
@@ -168,7 +177,7 @@ function DialogContent({
168
177
  const pinned = "sticky z-10 -mx-(--dialog-padding) bg-overlay px-(--dialog-padding)"
169
178
 
170
179
  function DialogHeader({ className, children, ref, ...props }: React.ComponentProps<"div">) {
171
- const showCloseButton = React.useContext(DialogCloseButtonContext)
180
+ const closeLabel = React.useContext(DialogCloseButtonContext)
172
181
  const pinnedRef = usePinnedHeight("--pinned-header-height", "dialog-content", ref)
173
182
  return (
174
183
  <div
@@ -178,13 +187,13 @@ function DialogHeader({ className, children, ref, ...props }: React.ComponentPro
178
187
  pinned,
179
188
  "-top-(--dialog-padding) -mt-(--dialog-padding) -mb-4 flex flex-col gap-2.5 pt-(--dialog-padding) pb-4",
180
189
  // The text stops before the close button, so a long title wraps instead of running under it.
181
- showCloseButton && "pe-14",
190
+ closeLabel !== null && "pe-14",
182
191
  className
183
192
  )}
184
193
  {...props}
185
194
  >
186
195
  {children}
187
- {showCloseButton && <DialogCloseButton />}
196
+ {closeLabel !== null && <DialogCloseButton label={closeLabel} />}
188
197
  </div>
189
198
  )
190
199
  }
@@ -192,13 +201,20 @@ function DialogHeader({ className, children, ref, ...props }: React.ComponentPro
192
201
  function DialogFooter({
193
202
  className,
194
203
  showCloseButton = false,
204
+ closeLabel,
195
205
  children,
196
206
  ref,
197
207
  ...props
198
208
  }: React.ComponentProps<"div"> & {
199
209
  showCloseButton?: boolean
210
+ /**
211
+ * The text of the Close button that `showCloseButton` adds. Defaults to
212
+ * `messages.dialog.close` from `FormatProvider`, then "Close".
213
+ */
214
+ closeLabel?: string
200
215
  }) {
201
216
  useRegisterCloseControl()
217
+ const t = useMessages("dialog", { close: closeLabel })
202
218
  const pinnedRef = usePinnedHeight("--pinned-footer-height", "dialog-content", ref)
203
219
  return (
204
220
  <div
@@ -214,7 +230,7 @@ function DialogFooter({
214
230
  {children}
215
231
  {showCloseButton && (
216
232
  <DialogPrimitive.Close render={<Button variant="outline" />}>
217
- Close
233
+ {t.close}
218
234
  </DialogPrimitive.Close>
219
235
  )}
220
236
  </div>
@@ -62,7 +62,7 @@ function DropdownMenuContent({
62
62
  <MenuPrimitive.Popup
63
63
  ref={popupRef}
64
64
  data-slot="dropdown-menu-content"
65
- className={cn("bg-popover text-popover-foreground shadow-overlay rounded-xl p-1.25 z-50 max-h-(--available-height) min-w-60 overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden", popupMotion, className )}
65
+ className={cn("bg-popover text-popover-foreground shadow-overlay rounded-2xl p-1.25 z-50 max-h-(--available-height) min-w-60 overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden", popupMotion, className )}
66
66
  {...props}
67
67
  />
68
68
  </MenuPrimitive.Positioner>
@@ -90,7 +90,7 @@ function HoverCardContent({
90
90
  ref={popupRef}
91
91
  data-slot="hover-card-content"
92
92
  className={cn(
93
- "bg-popover text-popover-foreground shadow-overlay z-50 w-64 rounded-xl p-4 text-sm outline-hidden",
93
+ "bg-popover text-popover-foreground shadow-overlay z-50 w-64 rounded-2xl p-4 text-sm outline-hidden",
94
94
  popupMotion,
95
95
  className
96
96
  )}
@@ -4,19 +4,30 @@ import * as React from "react"
4
4
  import { cva, type VariantProps } from "class-variance-authority"
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 { Button } from "@vendure-io/ui/components/atoms/button"
9
9
  import { Input } from "@vendure-io/ui/components/atoms/input"
10
10
  import { Textarea } from "@vendure-io/ui/components/atoms/textarea"
11
11
 
12
- function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
12
+ function InputGroup({
13
+ className,
14
+ size = "default",
15
+ ...props
16
+ }: React.ComponentProps<"div"> & {
17
+ /**
18
+ * The field height: `default` is 34px, `sm` is 28px, the height of a small
19
+ * Button. The input and the buttons inside follow it.
20
+ */
21
+ size?: "sm" | "default"
22
+ }) {
13
23
  return (
14
24
  <div
15
25
  data-slot="input-group"
26
+ data-size={size}
16
27
  role="group"
17
28
  className={cn(
18
29
  fieldSurface,
19
- "has-[[data-slot=input-group-control]:focus-visible]:outline-solid has-[[data-slot=input-group-control]:focus-visible]:outline-2 has-[[data-slot=input-group-control]:focus-visible]:-outline-offset-2 has-[[data-slot=input-group-control]:focus-visible]:outline-ring has-[[data-slot][aria-invalid=true]]:outline-destructive has-[[data-slot][aria-invalid=true]]:shadow-[inset_0_0_0_1px_var(--destructive)] group/input-group relative flex h-8.5 w-full min-w-0 items-center in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 in-data-[slot=combobox-content]:outline-none! has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pe-1.5 has-[>[data-align=inline-start]]:[&>input]:ps-1.5",
30
+ "has-[[data-slot=input-group-control]:focus-visible]:outline-solid has-[[data-slot=input-group-control]:focus-visible]:outline-2 has-[[data-slot=input-group-control]:focus-visible]:-outline-offset-2 has-[[data-slot=input-group-control]:focus-visible]:outline-ring has-[[data-slot][aria-invalid=true]]:outline-destructive has-[[data-slot][aria-invalid=true]]:inset-ring-destructive group/input-group relative flex h-8.5 data-[size=sm]:h-7 data-[size=sm]:has-[>textarea]:h-auto data-[size=sm]:has-[>[data-align=block-end]]:h-auto data-[size=sm]:has-[>[data-align=block-start]]:h-auto w-full min-w-0 items-center in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 in-data-[slot=combobox-content]:outline-none! has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pe-1.5 has-[>[data-align=inline-start]]:[&>input]:ps-1.5",
20
31
  className
21
32
  )}
22
33
  {...props}
@@ -29,9 +40,11 @@ function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
29
40
  // content about 10px in. Logical sides, so right-to-left mirrors it.
30
41
  // A kbd in an addon drops its own fill and uses the secondary text colour
31
42
  // and the input hairline, as the v3 look's search field does: its muted text
32
- // on its fill on the muted field fails the axe contrast check.
43
+ // on its fill on the field fill fails the axe contrast check.
33
44
  const inputGroupAddonVariants = cva(
34
- "text-muted-foreground **:data-[slot=kbd]:bg-transparent **:data-[slot=kbd]:text-foreground-secondary **:data-[slot=kbd]:inset-ring-input h-auto gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>svg:not([class*='size-'])]:size-4 [&>svg:not([class*='stroke-'])]:stroke-[1.75] flex cursor-text items-center justify-center select-none",
45
+ // A CopyButton (24px) nests its corner like an xs InputGroupButton: the
46
+ // field's 8px minus the gap, 5px in a 34px group and 2px in a 28px one.
47
+ "[&>[data-slot=copy-button]]:rounded-[calc(var(--radius-xl)-5px)] group-data-[size=sm]/input-group:[&>[data-slot=copy-button]]:rounded-[calc(var(--radius-xl)-2px)] text-muted-foreground **:data-[slot=kbd]:bg-transparent **:data-[slot=kbd]:text-foreground-secondary **:data-[slot=kbd]:inset-ring-input h-auto gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>svg:not([class*='size-'])]:size-4 [&>svg:not([class*='stroke-'])]:stroke-[1.75] flex cursor-text items-center justify-center select-none",
35
48
  {
36
49
  variants: {
37
50
  align: {
@@ -73,16 +86,21 @@ function InputGroupAddon({
73
86
  )
74
87
  }
75
88
 
89
+ // The text sizes use 12px text, like a Button of the same size. The corner
90
+ // is the field's 8px minus the gap between the button and the field edge, so
91
+ // the two corners run parallel: a 24px button sits 5px inside a 34px field
92
+ // and 2px inside a 28px one, a 28px button 3px inside a 34px field and flush
93
+ // in a 28px one.
76
94
  const inputGroupButtonVariants = cva(
77
95
  "gap-2 text-sm shadow-none flex items-center",
78
96
  {
79
97
  variants: {
80
98
  size: {
81
- xs: "h-6 gap-1 rounded-lg px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
82
- sm: "h-7 gap-1.5 px-2.5",
99
+ xs: "h-6 gap-1 rounded-[calc(var(--radius-xl)-5px)] group-data-[size=sm]/input-group:rounded-[calc(var(--radius-xl)-2px)] px-1.5 text-xs [&>svg:not([class*='size-'])]:size-3.5",
100
+ sm: "h-7 gap-1.5 rounded-[calc(var(--radius-xl)-3px)] group-data-[size=sm]/input-group:rounded-xl px-2.5 text-xs",
83
101
  "icon-xs":
84
- "size-6 rounded-lg p-0 has-[>svg]:p-0",
85
- "icon-sm": "size-7 p-0 has-[>svg]:p-0",
102
+ "size-6 rounded-[calc(var(--radius-xl)-5px)] group-data-[size=sm]/input-group:rounded-[calc(var(--radius-xl)-2px)] p-0 has-[>svg]:p-0",
103
+ "icon-sm": "size-7 rounded-[calc(var(--radius-xl)-3px)] group-data-[size=sm]/input-group:rounded-xl p-0 has-[>svg]:p-0",
86
104
  },
87
105
  },
88
106
  defaultVariants: {
@@ -127,12 +145,12 @@ function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {
127
145
  function InputGroupInput({
128
146
  className,
129
147
  ...props
130
- }: React.ComponentProps<"input">) {
148
+ }: Omit<React.ComponentProps<typeof Input>, "size">) {
131
149
  return (
132
150
  <Input
133
151
  data-slot="input-group-control"
134
152
  className={cn(
135
- "flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:shadow-none focus-visible:ring-0 focus-visible:outline-none aria-invalid:shadow-none aria-invalid:focus-visible:shadow-none aria-invalid:ring-0 dark:bg-transparent",
153
+ "flex-1 rounded-none border-0 bg-transparent shadow-none inset-ring-0 aria-invalid:inset-ring-0 group-data-[size=sm]/input-group:h-7 ring-0 focus-visible:shadow-none focus-visible:ring-0 focus-visible:outline-none aria-invalid:shadow-none aria-invalid:focus-visible:shadow-none aria-invalid:ring-0 dark:bg-transparent",
136
154
  className
137
155
  )}
138
156
  {...props}
@@ -148,7 +166,7 @@ function InputGroupTextarea({
148
166
  <Textarea
149
167
  data-slot="input-group-control"
150
168
  className={cn(
151
- "flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:shadow-none focus-visible:ring-0 focus-visible:outline-none aria-invalid:shadow-none aria-invalid:focus-visible:shadow-none aria-invalid:ring-0 dark:bg-transparent",
169
+ "flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none inset-ring-0 aria-invalid:inset-ring-0 ring-0 focus-visible:shadow-none focus-visible:ring-0 focus-visible:outline-none aria-invalid:shadow-none aria-invalid:focus-visible:shadow-none aria-invalid:ring-0 dark:bg-transparent",
152
170
  className
153
171
  )}
154
172
  {...props}
@@ -4,7 +4,7 @@ import * as React from "react"
4
4
  import { OTPInput, OTPInputContext } from "input-otp"
5
5
 
6
6
  import { cn } from "@vendure-io/ui/lib/utils"
7
- import { fieldSurfaceWithin } from "@vendure-io/ui/lib/field-surface"
7
+ import { fieldSurfaceWithin } from "../../lib/field-surface.ts"
8
8
  import { MinusIcon } from "lucide-react"
9
9
 
10
10
  function InputOTP({
@@ -55,7 +55,7 @@ function InputOTPSlot({
55
55
  data-slot="input-otp-slot"
56
56
  data-active={isActive}
57
57
  className={cn(
58
- "border-border data-[active=true]:outline-solid data-[active=true]:outline-2 data-[active=true]:-outline-offset-2 data-[active=true]:outline-ring data-[active=true]:aria-invalid:outline-destructive relative flex size-8.5 items-center justify-center border-s text-sm outline-none first:rounded-s-lg first:border-s-0 last:rounded-e-lg data-[active=true]:z-10",
58
+ "border-border data-[active=true]:outline-solid data-[active=true]:outline-2 data-[active=true]:-outline-offset-2 data-[active=true]:outline-ring data-[active=true]:aria-invalid:outline-destructive relative flex size-8.5 items-center justify-center border-s text-sm outline-none first:rounded-s-xl first:border-s-0 last:rounded-e-xl data-[active=true]:z-10",
59
59
  className
60
60
  )}
61
61
  {...props}
@@ -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
  }
@@ -1,14 +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"
8
+ import { warnDeprecated } from "../../lib/deprecated.ts"
9
+ import { useMessages } from "../../lib/format-messages.ts"
6
10
 
7
- 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 })
8
14
  return (
9
15
  <nav
10
16
  role="navigation"
11
- aria-label="pagination"
17
+ aria-label={t.nav}
12
18
  data-slot="pagination"
13
19
  className={cn("mx-auto flex w-full justify-center", className)}
14
20
  {...props}
@@ -34,27 +40,32 @@ function PaginationItem({ ...props }: React.ComponentProps<"li">) {
34
40
  }
35
41
 
36
42
  type PaginationLinkProps = {
43
+ active?: boolean
44
+ /** @deprecated Use `active`. Removed in 4.0. */
37
45
  isActive?: boolean
38
46
  } & Pick<React.ComponentProps<typeof Button>, "size"> &
39
47
  React.ComponentProps<"a">
40
48
 
41
49
  function PaginationLink({
42
50
  className,
51
+ active: activeProp,
43
52
  isActive,
44
53
  size = "icon",
45
54
  ...props
46
55
  }: PaginationLinkProps) {
56
+ if (isActive !== undefined) warnDeprecated("PaginationLink", "isActive", "active")
57
+ const active = activeProp ?? isActive
47
58
  return (
48
59
  <Button
49
- variant={isActive ? "outline" : "ghost"}
60
+ variant={active ? "outline" : "ghost"}
50
61
  size={size}
51
62
  className={cn(className)}
52
63
  nativeButton={false}
53
64
  render={
54
65
  <a
55
- aria-current={isActive ? "page" : undefined}
66
+ aria-current={active ? "page" : undefined}
56
67
  data-slot="pagination-link"
57
- data-active={isActive}
68
+ data-active={active}
58
69
  {...props}
59
70
  />
60
71
  }
@@ -64,35 +75,53 @@ function PaginationLink({
64
75
 
65
76
  function PaginationPrevious({
66
77
  className,
67
- text = "Previous",
78
+ text,
79
+ "aria-label": ariaLabel,
68
80
  ...props
69
- }: 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 })
70
90
  return (
71
91
  <PaginationLink
72
- aria-label="Go to previous page"
92
+ aria-label={t.previous}
73
93
  size="default"
74
94
  className={cn("ps-2!", className)}
75
95
  {...props}
76
96
  >
77
97
  <ChevronLeftIcon data-icon="inline-start" />
78
- <span className="hidden sm:block">{text}</span>
98
+ <span className="hidden sm:block">{t.previousText}</span>
79
99
  </PaginationLink>
80
100
  )
81
101
  }
82
102
 
83
103
  function PaginationNext({
84
104
  className,
85
- text = "Next",
105
+ text,
106
+ "aria-label": ariaLabel,
86
107
  ...props
87
- }: 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 })
88
117
  return (
89
118
  <PaginationLink
90
- aria-label="Go to next page"
119
+ aria-label={t.next}
91
120
  size="default"
92
121
  className={cn("pe-2!", className)}
93
122
  {...props}
94
123
  >
95
- <span className="hidden sm:block">{text}</span>
124
+ <span className="hidden sm:block">{t.nextText}</span>
96
125
  <ChevronRightIcon data-icon="inline-end" />
97
126
  </PaginationLink>
98
127
  )
@@ -100,8 +129,16 @@ function PaginationNext({
100
129
 
101
130
  function PaginationEllipsis({
102
131
  className,
132
+ label,
103
133
  ...props
104
- }: 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 })
105
142
  return (
106
143
  <span
107
144
  aria-hidden
@@ -114,7 +151,7 @@ function PaginationEllipsis({
114
151
  >
115
152
  <MoreHorizontalIcon
116
153
  />
117
- <span className="sr-only">More pages</span>
154
+ <span className="sr-only">{t.more}</span>
118
155
  </span>
119
156
  )
120
157
  }
@@ -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}