@vendure-io/ui 2.2.0 → 3.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/package.json +19 -5
  2. package/src/components/atoms/accordion.tsx +21 -6
  3. package/src/components/atoms/alert-dialog.tsx +31 -6
  4. package/src/components/atoms/alert.tsx +59 -12
  5. package/src/components/atoms/avatar.tsx +1 -1
  6. package/src/components/atoms/badge.tsx +7 -2
  7. package/src/components/atoms/breadcrumb.tsx +137 -4
  8. package/src/components/atoms/button-group.tsx +30 -6
  9. package/src/components/atoms/button.tsx +128 -18
  10. package/src/components/atoms/calendar.tsx +6 -6
  11. package/src/components/atoms/card.tsx +130 -16
  12. package/src/components/atoms/carousel.tsx +16 -9
  13. package/src/components/atoms/chart.tsx +87 -1
  14. package/src/components/atoms/checkbox.tsx +85 -7
  15. package/src/components/atoms/collapsible.tsx +2 -1
  16. package/src/components/atoms/combobox.tsx +147 -21
  17. package/src/components/atoms/command.tsx +414 -12
  18. package/src/components/atoms/context-menu.tsx +28 -23
  19. package/src/components/atoms/dialog.tsx +151 -29
  20. package/src/components/atoms/direction.tsx +23 -2
  21. package/src/components/atoms/drawer.tsx +15 -10
  22. package/src/components/atoms/dropdown-menu.tsx +43 -28
  23. package/src/components/atoms/empty.tsx +4 -0
  24. package/src/components/atoms/field.tsx +41 -15
  25. package/src/components/atoms/hover-card.tsx +61 -8
  26. package/src/components/atoms/input-group.tsx +17 -9
  27. package/src/components/atoms/input-otp.tsx +6 -6
  28. package/src/components/atoms/input.tsx +7 -1
  29. package/src/components/atoms/item.tsx +3 -3
  30. package/src/components/atoms/kbd.tsx +32 -3
  31. package/src/components/atoms/label-swap.tsx +82 -0
  32. package/src/components/atoms/label.tsx +1 -1
  33. package/src/components/atoms/menubar.tsx +28 -26
  34. package/src/components/atoms/native-select.tsx +3 -2
  35. package/src/components/atoms/navigation-menu.tsx +13 -8
  36. package/src/components/atoms/pagination.tsx +2 -2
  37. package/src/components/atoms/popover.tsx +23 -5
  38. package/src/components/atoms/progress.tsx +46 -33
  39. package/src/components/atoms/radio-group.tsx +9 -4
  40. package/src/components/atoms/resizable.tsx +1 -1
  41. package/src/components/atoms/scroll-area.tsx +2 -2
  42. package/src/components/atoms/select.tsx +258 -19
  43. package/src/components/atoms/sheet.tsx +59 -23
  44. package/src/components/atoms/sidebar.tsx +333 -23
  45. package/src/components/atoms/skeleton.tsx +1 -1
  46. package/src/components/atoms/slider.tsx +1 -1
  47. package/src/components/atoms/sonner.tsx +128 -38
  48. package/src/components/atoms/spinner.tsx +1 -1
  49. package/src/components/atoms/switch.tsx +10 -5
  50. package/src/components/atoms/table.tsx +147 -7
  51. package/src/components/atoms/tabs.tsx +3 -3
  52. package/src/components/atoms/textarea.tsx +3 -1
  53. package/src/components/atoms/toggle-group.tsx +4 -2
  54. package/src/components/atoms/toggle.tsx +28 -6
  55. package/src/components/atoms/tooltip.tsx +85 -15
  56. package/src/components/molecules/anonymized-token.tsx +24 -8
  57. package/src/components/molecules/app-shell.tsx +53 -20
  58. package/src/components/molecules/arrow-link.tsx +40 -0
  59. package/src/components/molecules/chip.tsx +2 -2
  60. package/src/components/molecules/code-block.tsx +54 -31
  61. package/src/components/molecules/collapsible-section.tsx +129 -0
  62. package/src/components/molecules/confirm-dialog.tsx +113 -9
  63. package/src/components/molecules/copyable-text.tsx +75 -11
  64. package/src/components/molecules/data-table/data-table-bulk-actions.tsx +32 -4
  65. package/src/components/molecules/data-table/data-table-column-header.tsx +20 -3
  66. package/src/components/molecules/data-table/data-table-filters.tsx +1 -1
  67. package/src/components/molecules/data-table/data-table-helpers.tsx +68 -1
  68. package/src/components/molecules/data-table/data-table-selection-storage.tsx +115 -0
  69. package/src/components/molecules/data-table/data-table-types.tsx +121 -4
  70. package/src/components/molecules/data-table/data-table-view-options.tsx +2 -2
  71. package/src/components/molecules/data-table/data-table.tsx +837 -80
  72. package/src/components/molecules/data-table/table-pagination.tsx +2 -2
  73. package/src/components/molecules/date-picker.tsx +13 -7
  74. package/src/components/molecules/date-range-picker.tsx +13 -6
  75. package/src/components/molecules/date-time-picker.tsx +13 -7
  76. package/src/components/molecules/date-time.tsx +8 -1
  77. package/src/components/molecules/direction-link.tsx +130 -0
  78. package/src/components/molecules/elapsed-time.tsx +223 -0
  79. package/src/components/molecules/file-dropzone.tsx +2 -2
  80. package/src/components/molecules/id-chip.tsx +169 -32
  81. package/src/components/molecules/inline-code.tsx +4 -0
  82. package/src/components/molecules/issued-secret.tsx +318 -0
  83. package/src/components/molecules/list-row.tsx +349 -0
  84. package/src/components/molecules/live-indicator.tsx +83 -0
  85. package/src/components/molecules/page-header.tsx +117 -5
  86. package/src/components/molecules/password-input.tsx +2 -2
  87. package/src/components/molecules/relative-time.tsx +85 -56
  88. package/src/components/molecules/search-trigger.tsx +127 -0
  89. package/src/components/molecules/secret-value.tsx +26 -9
  90. package/src/components/molecules/skip-link.tsx +1 -1
  91. package/src/components/molecules/stat-card.tsx +4 -4
  92. package/src/components/molecules/state-views/empty-state.tsx +35 -17
  93. package/src/components/molecules/state-views/error-state.tsx +32 -14
  94. package/src/components/molecules/status-badge.tsx +415 -49
  95. package/src/components/molecules/time-tooltip.tsx +140 -0
  96. package/src/components/molecules/timeline.tsx +246 -0
  97. package/src/components/molecules/visibility-icon.tsx +89 -0
  98. package/src/hooks/use-active-label-size.ts +32 -0
  99. package/src/hooks/use-pinned-height.ts +55 -0
  100. package/src/hooks/use-scrolled.ts +27 -0
  101. package/src/lib/content-inset.ts +17 -0
  102. package/src/lib/control-name.ts +55 -0
  103. package/src/lib/dialog-padding.ts +48 -0
  104. package/src/lib/field-surface.ts +31 -0
  105. package/src/lib/format-elapsed.ts +67 -0
  106. package/src/lib/format-relative.ts +29 -1
  107. package/src/lib/highlight.ts +3 -3
  108. package/src/lib/menu-item.tsx +72 -0
  109. package/src/lib/outline-edge.ts +21 -0
  110. package/src/lib/popup-align.ts +67 -0
  111. package/src/lib/popup-direction.ts +22 -0
  112. package/src/lib/popup-motion.ts +19 -0
  113. package/src/lib/state-dictionary.ts +42 -6
  114. package/src/lib/syntax-colors.ts +8 -0
  115. package/src/lib/tint-recipes.ts +68 -0
  116. package/src/lib/tone-icons.ts +24 -0
  117. package/src/lib/trigger-slot.ts +16 -0
  118. package/src/lib/utils.ts +104 -1
@@ -1,19 +1,43 @@
1
1
  "use client"
2
2
 
3
+ import * as React from "react"
3
4
  import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip"
4
5
 
6
+ // Relative: `label-swap` is closed in the package exports.
7
+ import { LabelSwap } from "./label-swap.tsx"
5
8
  import { cn } from "@vendure-io/ui/lib/utils"
9
+ import { usePopupDir } from "../../lib/popup-direction.ts"
10
+ import { triggerSlot } from "../../lib/trigger-slot.ts"
6
11
 
12
+ /** True inside a TooltipProvider, whose delay then applies to each trigger. */
13
+ const InTooltipProvider = React.createContext(false)
14
+
15
+ /**
16
+ * The `tooltip-delay` motion token, in ms. A TooltipProvider and a
17
+ * TooltipTrigger without a provider both wait this long. The ui source does
18
+ * not import the tokens package at runtime; tooltip.test.ts keeps the two
19
+ * equal.
20
+ */
21
+ const TOOLTIP_DELAY = 600
22
+
23
+ /**
24
+ * Wrap the app in one TooltipProvider. The first tooltip then waits
25
+ * `tooltip-delay` (600ms), so a pointer that only passes over a trigger opens
26
+ * nothing. Once a tooltip is open, the next one opens at once and does not
27
+ * animate, until no tooltip has been open for the provider's `timeout`.
28
+ */
7
29
  function TooltipProvider({
8
- delay = 0,
30
+ delay = TOOLTIP_DELAY,
9
31
  ...props
10
32
  }: TooltipPrimitive.Provider.Props) {
11
33
  return (
12
- <TooltipPrimitive.Provider
13
- data-slot="tooltip-provider"
14
- delay={delay}
15
- {...props}
16
- />
34
+ <InTooltipProvider.Provider value={true}>
35
+ <TooltipPrimitive.Provider
36
+ data-slot="tooltip-provider"
37
+ delay={delay}
38
+ {...props}
39
+ />
40
+ </InTooltipProvider.Provider>
17
41
  )
18
42
  }
19
43
 
@@ -21,47 +45,93 @@ function Tooltip({ ...props }: TooltipPrimitive.Root.Props) {
21
45
  return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
22
46
  }
23
47
 
24
- function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {
25
- return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
48
+ /**
49
+ * Inside a TooltipProvider it leaves `delay` unset, so the provider's delay
50
+ * applies. Without a provider the delay is `tooltip-delay` (600ms) too, so a
51
+ * pointer that only passes over a trigger opens nothing. An explicit `delay`
52
+ * wins in both cases. A provider is what lets the next tooltips open at once.
53
+ */
54
+ function TooltipTrigger({ delay, ...props }: TooltipPrimitive.Trigger.Props) {
55
+ const inProvider = React.useContext(InTooltipProvider)
56
+ return (
57
+ <TooltipPrimitive.Trigger
58
+ {...triggerSlot("tooltip-trigger", props.render)}
59
+ delay={delay ?? (inProvider ? undefined : TOOLTIP_DELAY)}
60
+ {...props}
61
+ />
62
+ )
26
63
  }
27
64
 
28
65
  function TooltipContent({
29
66
  className,
30
67
  side = "top",
31
- sideOffset = 4,
68
+ sideOffset = 8,
32
69
  align = "center",
33
70
  alignOffset = 0,
71
+ anchor,
34
72
  children,
35
73
  ...props
36
74
  }: TooltipPrimitive.Popup.Props &
37
75
  Pick<
38
76
  TooltipPrimitive.Positioner.Props,
39
- "align" | "alignOffset" | "side" | "sideOffset"
77
+ "align" | "alignOffset" | "anchor" | "side" | "sideOffset"
40
78
  >) {
79
+ const dir = usePopupDir()
41
80
  return (
42
81
  <TooltipPrimitive.Portal>
43
82
  <TooltipPrimitive.Positioner
83
+ dir={dir}
84
+ anchor={anchor}
44
85
  align={align}
45
86
  alignOffset={alignOffset}
46
87
  side={side}
47
88
  sideOffset={sideOffset}
48
89
  className="isolate z-50"
49
90
  >
50
- {/* Base UI never emits Radix-style data-state attributes — data-[state=delayed-open]:* selectors would be dead here; data-open:* covers the open animation */}
91
+ {/* No arrow: the popup scales in from the trigger side (--transform-origin) in 125ms (tooltip-enter) and leaves in 100ms (fast), both with the fade on ease-soft (the CSS `ease`) and the scale on the strong ease-out. A tooltip that Base UI marks data-instant does not animate, and has no starting style (Base UI clears data-starting-style one frame after mount, so without this an instant tooltip is hidden for that frame): one that opens while another is showing or just closed (delay), one opened by keyboard focus (focus), and one dismissed with Escape or an outside press (dismiss). Moving along a row of triggers then shows each tooltip in full at once. This rule wins over the v3 look, which animates every tooltip. A TooltipLabelSwap inside clips to the bubble, so a wider label that leaves never shows past its edge. The bubble is at most 320px wide and nothing widens it: a tooltip is a short hint, and longer content belongs on the page or in a Popover. Its max-w comes after `className`, so a consumer's max-w-* is dropped. */}
51
92
  <TooltipPrimitive.Popup
52
93
  data-slot="tooltip-content"
53
94
  className={cn(
54
- "data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 bg-foreground text-background z-50 w-fit max-w-xs origin-(--transform-origin) rounded-md px-3 py-1.5 text-xs motion-reduce:animate-none data-open:duration-(--transition-duration-normal) data-open:ease-(--ease-out) data-closed:duration-(--transition-duration-fast) data-closed:ease-(--ease-in)",
55
- className
95
+ "bg-foreground text-background z-50 w-fit origin-(--transform-origin) rounded-lg px-2.5 py-[7px] text-xs leading-[17px] font-medium text-pretty transition-[opacity,scale] duration-tooltip-enter ease-[var(--ease-soft),var(--ease-out)] data-starting-style:opacity-0 data-ending-style:opacity-0 data-ending-style:duration-fast motion-safe:data-starting-style:scale-97 motion-safe:data-ending-style:scale-97 data-instant:duration-instant data-instant:data-starting-style:opacity-100 motion-safe:data-instant:data-starting-style:scale-100 has-data-[slot=tooltip-label-swap]:overflow-hidden",
96
+ className,
97
+ "max-w-80"
56
98
  )}
57
99
  {...props}
58
100
  >
59
101
  {children}
60
- <TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" />
61
102
  </TooltipPrimitive.Popup>
62
103
  </TooltipPrimitive.Positioner>
63
104
  </TooltipPrimitive.Portal>
64
105
  )
65
106
  }
66
107
 
67
- export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
108
+ /**
109
+ * A tooltip label that changes in place, such as "Copy" → "Copied". The
110
+ * labels share one grid cell and `active` picks the one that shows. A label
111
+ * before it leaves 6px upward, a label after it waits 6px below, both faded
112
+ * out with a 2px blur. The part eases to the width of the active label, so
113
+ * the bubble never snaps. A label wider than the bubble wraps inside it, and
114
+ * the part eases to the active label's height too. With reduced motion the
115
+ * labels only crossfade and the size changes at once.
116
+ */
117
+ function TooltipLabelSwap(
118
+ props: Omit<React.ComponentProps<"span">, "children"> & {
119
+ labels: readonly React.ReactNode[]
120
+ active: number
121
+ }
122
+ ) {
123
+ return (
124
+ <LabelSwap
125
+ data-slot="tooltip-label-swap"
126
+ timing="tooltip"
127
+ {...props}
128
+ className={cn("items-start", props.className)}
129
+ // Each label is as wide as its text, up to the bubble's content box
130
+ // (320px less px-2.5 on each side), where it wraps. So its size does
131
+ // not depend on the size of the label that showed before.
132
+ labelClassName="w-max max-w-[calc(--spacing(80)-1.25rem)]"
133
+ />
134
+ )
135
+ }
136
+
137
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipLabelSwap, TooltipProvider }
@@ -3,8 +3,13 @@
3
3
  import {
4
4
  CopyButton,
5
5
  type CopyButtonProps,
6
+ useCopyAction,
6
7
  } from '@vendure-io/ui/components/molecules/copyable-text';
7
- import { chipChromeClass } from '@vendure-io/ui/components/molecules/id-chip';
8
+ import {
9
+ ChipCopyTooltip,
10
+ chipChromeClass,
11
+ chipCopyButtonProps,
12
+ } from '@vendure-io/ui/components/molecules/id-chip';
8
13
  import { cn } from '@vendure-io/ui/lib/utils';
9
14
  import type * as React from 'react';
10
15
  import { useState } from 'react';
@@ -93,6 +98,7 @@ function AnonymizedToken({
93
98
  ...props
94
99
  }: AnonymizedTokenProps) {
95
100
  const [previewRevealed, setPreviewRevealed] = useState(false);
101
+ const action = useCopyAction({ timeout, onCopied, onCopyError });
96
102
 
97
103
  if (!value) {
98
104
  return (
@@ -114,7 +120,7 @@ function AnonymizedToken({
114
120
  );
115
121
  const showRevealed = revealOnHover && previewRevealed;
116
122
 
117
- return (
123
+ const chip = (
118
124
  <span
119
125
  data-slot="anonymized-token"
120
126
  role="group"
@@ -140,13 +146,13 @@ function AnonymizedToken({
140
146
  {...props}
141
147
  >
142
148
  {/* Blur is the only thing that sets a token apart from a plain `IdChip`;
143
- the pill chrome is shared. No `overflow-hidden` here — it would clip
149
+ the chip chrome is shared. No `overflow-hidden` here — it would clip
144
150
  the blur halo — and the full value is never surfaced via `title`. */}
145
151
  <code
146
152
  data-slot="anonymized-token-value"
147
153
  aria-hidden="true"
148
154
  data-revealed={showRevealed || undefined}
149
- className="blur-[1px] transition-[filter] data-[revealed]:blur-none"
155
+ className="blur-[1px] transition-[filter] motion-reduce:transition-none data-[revealed]:blur-none"
150
156
  >
151
157
  {preview}
152
158
  </code>
@@ -154,16 +160,26 @@ function AnonymizedToken({
154
160
  {copyable ? (
155
161
  <CopyButton
156
162
  value={value}
157
- timeout={timeout}
158
- onCopied={onCopied}
159
- onCopyError={onCopyError}
163
+ copyAction={action}
160
164
  copyLabel={copyLabel}
161
165
  copiedLabel={copiedLabel}
162
- className="relative size-4 after:absolute after:-inset-1"
166
+ {...chipCopyButtonProps}
163
167
  />
164
168
  ) : null}
165
169
  </span>
166
170
  );
171
+
172
+ if (!copyable) return chip;
173
+
174
+ // The whole chip copies, like `IdChip`. The tooltip never shows the value.
175
+ return (
176
+ <ChipCopyTooltip
177
+ chip={chip}
178
+ copied={action.copied}
179
+ copyLabel={copyLabel}
180
+ copiedLabel={copiedLabel}
181
+ />
182
+ );
167
183
  }
168
184
 
169
185
  export { AnonymizedToken };
@@ -1,24 +1,23 @@
1
1
  import { cn } from '@vendure-io/ui/lib/utils';
2
2
  import type * as React from 'react';
3
3
 
4
- // AppShell — the recessed-surface app layout, built on the surface ramp.
4
+ // AppShell — the app layout: a flat page, as in the v3 look.
5
5
  //
6
- // Nests three surface tiers so the chrome reads as "deep" the way Linear's does:
6
+ // One background for the whole window. The sidebar sits on it with a 1px right
7
+ // border, and the content fills the rest with no inset, radius or border:
7
8
  //
8
- // AppShell → --background the canvas the whole window sits on
9
- // AppShellSidebar → --sidebar nav rail; equals the canvas, so it recedes
10
- // AppShellContent → --surface the content pane, stepped forward + inset
9
+ // AppShell → --background the page
10
+ // AppShellSidebar → --sidebar nav rail; equals the page, split by a 1px border
11
+ // AppShellContent → (inherits) header + main, flush against the sidebar
11
12
  //
12
- // Cards dropped into the content pane resolve to --surface-raised (via the `card`
13
- // token), completing the third step. In dark mode each tier is a lightness step;
14
- // in light mode the ramp collapses to white, so the pane's border + shadow carry
15
- // the step instead. That asymmetry is intentional, not a gap.
13
+ // Cards in the content resolve to --surface-raised (via the `card` token), so
14
+ // they are the one step up from the page.
16
15
  //
17
16
  // The sidebar slot is deliberately unopinionated: drop the full `Sidebar` atom in
18
17
  // for a real app, or use `AppShellSidebar` for a lightweight rail. Content owns a
19
18
  // header + main anatomy so every consumer gets the same scroll boundary and skip
20
19
  // link target without coupling the design system to a router or auth provider. The
21
- // shell is viewport-bound so the canvas inset remains visible while main scrolls.
20
+ // shell is viewport-bound, so main scrolls and the header stays in view.
22
21
 
23
22
  function AppShell({ className, ...props }: React.ComponentProps<'div'>) {
24
23
  return (
@@ -35,7 +34,7 @@ function AppShellSidebar({ className, ...props }: React.ComponentProps<'aside'>)
35
34
  <aside
36
35
  data-slot="app-shell-sidebar"
37
36
  className={cn(
38
- 'bg-sidebar text-sidebar-foreground flex w-64 shrink-0 flex-col gap-1 p-3',
37
+ 'bg-sidebar text-sidebar-foreground border-sidebar-border flex w-58 shrink-0 flex-col gap-1 border-e px-2.5 py-3',
39
38
  className,
40
39
  )}
41
40
  {...props}
@@ -47,25 +46,38 @@ function AppShellContent({ className, ...props }: React.ComponentProps<'div'>) {
47
46
  return (
48
47
  <div
49
48
  data-slot="app-shell-content"
50
- className={cn(
51
- // The missing tier: step up to --surface and inset from the canvas so the
52
- // shell frames the pane on all sides, including a gutter between the
53
- // sidebar and the pane. Flat by design: the border carries the tier in
54
- // light mode (see AGENTS.md "flat look"), so no drop shadow.
55
- 'bg-surface m-3 flex min-w-0 flex-1 flex-col overflow-hidden rounded-xl border border-border/60',
56
- className,
57
- )}
49
+ className={cn('flex min-w-0 flex-1 flex-col overflow-hidden', className)}
58
50
  {...props}
59
51
  />
60
52
  );
61
53
  }
62
54
 
55
+ // The header is 52px and sticks to the top of whichever element scrolls. It
56
+ // is opaque: content that scrolls under it (a log, a long table) never shows
57
+ // through. Its fill follows the surface it sits on: --background on the flat
58
+ // page, --surface inside the pane of a Sidebar with variant="inset". The
59
+ // hairline below it is an inset shadow, so the full 52px stays the content
60
+ // box and the 30px controls centre on whole pixels. It is always on: showing
61
+ // it only on scroll would need a scroll listener on a region the header does
62
+ // not own. Forced-colors mode drops box shadows, so there a 1px border on an
63
+ // ::after line at the bottom edge draws the hairline in CanvasText; it
64
+ // overlays the box and does not change the 52px.
65
+ //
66
+ // The sidebar toggle sits in an even 12px frame: 12px from the header's
67
+ // leading edge (ps-3), 12px from its top and bottom edges (the 28px toggle
68
+ // centred in 52px), and 12px to the divider after it (the 6px gap plus a
69
+ // 6px end margin). The header owns these margins, so a margin a consumer
70
+ // puts on the toggle does not apply.
71
+ const headerToggleClassName =
72
+ '[&_[data-slot=sidebar-trigger]]:ms-0 [&_[data-slot=sidebar-trigger]]:me-1.5';
73
+
63
74
  function AppShellHeader({ className, ...props }: React.ComponentProps<'header'>) {
64
75
  return (
65
76
  <header
66
77
  data-slot="app-shell-header"
67
78
  className={cn(
68
- 'flex h-12 shrink-0 items-center gap-2 border-b border-border/60 px-4',
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]',
80
+ headerToggleClassName,
69
81
  className,
70
82
  )}
71
83
  {...props}
@@ -100,11 +112,32 @@ function AppShellMain({
100
112
  );
101
113
  }
102
114
 
115
+ // The page enter: the class string for a consumer with its own layout. Put
116
+ // it on the element that wraps the page and changes its `key` with the route.
117
+ const pageEnterClassName = 'animate-page-enter motion-reduce:animate-page-fade';
118
+
119
+ // AppShellPage wraps the page inside AppShellMain. When it mounts, the page
120
+ // fades in (220ms) and rises 6px into place (260ms) on the `out` curve; with
121
+ // reduced motion it only fades. The header and the sidebar stay still.
122
+ //
123
+ // A CSS animation runs once, when the element mounts. A re-render or a query
124
+ // that refetches does not mount it again, so the motion does not replay. Give
125
+ // it a `key` that changes with the route (the pathname) so a new page mounts a
126
+ // new element. Only opacity and transform move: no layout shift, and the page
127
+ // takes clicks while it settles.
128
+ function AppShellPage({ className, ...props }: React.ComponentProps<'div'>) {
129
+ return (
130
+ <div data-slot="app-shell-page" className={cn(pageEnterClassName, className)} {...props} />
131
+ );
132
+ }
133
+
103
134
  export {
104
135
  AppShell,
105
136
  AppShellSidebar,
106
137
  AppShellContent,
107
138
  AppShellHeader,
108
139
  AppShellMain,
140
+ AppShellPage,
141
+ pageEnterClassName,
109
142
  type AppShellMainProps,
110
143
  };
@@ -0,0 +1,40 @@
1
+ import type { useRender } from '@base-ui/react/use-render';
2
+ import { DirectionLink } from './direction-link.tsx';
3
+
4
+ // The v3 look: text in `foreground-secondary` and a trailing chevron, or an
5
+ // up-right arrow for a link that opens another site; the look, motion and
6
+ // right-to-left handling live in DirectionLink.
7
+ //
8
+ // The link is `group/arrow-link`. A card or row that opens the same page
9
+ // takes the same class and `relative`, and the link takes
10
+ // `after:absolute after:inset-0`: its ::after then covers the parent, so a
11
+ // click anywhere on it follows the link, and pointing anywhere on it drives
12
+ // the hover.
13
+
14
+ type ArrowLinkProps = useRender.ComponentProps<'a'> & {
15
+ /**
16
+ * Where the link goes.
17
+ *
18
+ * - `'forward'` (default): a page of this app. A chevron that moves 2px
19
+ * toward the end on hover.
20
+ * - `'external'`: another site, such as the storefront or a provider's
21
+ * console. A diagonal arrow that moves 1.5px out on hover. Set `target`
22
+ * and `rel` yourself when it opens a new tab.
23
+ */
24
+ direction?: 'forward' | 'external';
25
+ };
26
+
27
+ /**
28
+ * A text link to a page that holds more of what the user is looking at:
29
+ * "View details", "All deployments", "Open logs". With
30
+ * `direction="external"`, a link that leaves the app: "Open storefront".
31
+ * Renders an `<a>`; pass `render` to use a router link.
32
+ */
33
+ function ArrowLink({ direction = 'forward', ...props }: ArrowLinkProps) {
34
+ return (
35
+ <DirectionLink direction={direction} slot="arrow-link" iconSlot="arrow-link-arrow" {...props} />
36
+ );
37
+ }
38
+
39
+ export { ArrowLink };
40
+ export type { ArrowLinkProps };
@@ -62,7 +62,7 @@ function Chip({
62
62
  aria-disabled={disabled || undefined}
63
63
  className={cn(
64
64
  'max-w-full gap-1',
65
- onRemove && 'pr-1',
65
+ onRemove && 'pe-1',
66
66
  disabled && 'pointer-events-none opacity-60',
67
67
  className,
68
68
  )}
@@ -77,7 +77,7 @@ function Chip({
77
77
  disabled={disabled}
78
78
  aria-label={removeLabel}
79
79
  onClick={onRemove}
80
- className="-mr-0.5 ml-0.5 inline-flex size-4 shrink-0 items-center justify-center rounded-full text-current/70 hover:bg-current/10 hover:text-current disabled:pointer-events-none"
80
+ className="-me-0.5 ms-0.5 inline-flex size-4 shrink-0 items-center justify-center rounded-full text-current/70 hover:bg-current/10 hover:text-current disabled:pointer-events-none outline-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"
81
81
  >
82
82
  <XIcon className="size-3" />
83
83
  </button>
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { Button } from '@vendure-io/ui/components/atoms/button';
4
+ import { DirectionProvider } from '@vendure-io/ui/components/atoms/direction';
4
5
  import { ScrollArea, ScrollBar } from '@vendure-io/ui/components/atoms/scroll-area';
5
6
  import { Tooltip, TooltipContent, TooltipTrigger } from '@vendure-io/ui/components/atoms/tooltip';
6
7
  import { useCopyFeedback } from '@vendure-io/ui/components/molecules/copy-feedback-provider';
@@ -20,7 +21,7 @@ import {
20
21
  FileIcon,
21
22
  TerminalIcon,
22
23
  } from 'lucide-react';
23
- import { motion } from 'motion/react';
24
+ import { motion, useReducedMotion } from 'motion/react';
24
25
  import { type ComponentProps, type ReactNode, useEffect, useId, useMemo, useState } from 'react';
25
26
  // Relative imports: `code-block/*` is closed in the package exports, so a
26
27
  // `@vendure-io/ui/...` self-reference to these modules fails in consumers.
@@ -200,11 +201,11 @@ function CodeBlockAction({ icon, label, onClick, disabled }: CodeBlockActionProp
200
201
  render={
201
202
  <Button
202
203
  variant="ghost"
203
- size="icon"
204
+ size="icon-sm"
204
205
  onClick={onClick}
205
206
  aria-label={label}
206
207
  disabled={disabled}
207
- className={cn('h-7 w-7', disabled && 'cursor-not-allowed opacity-50')}
208
+ className={cn(disabled && 'cursor-not-allowed opacity-50')}
208
209
  />
209
210
  }
210
211
  >
@@ -243,6 +244,8 @@ interface PackageManagerTabsProps {
243
244
  }
244
245
 
245
246
  function PackageManagerTabs({ activeManager, onSelect, id }: PackageManagerTabsProps) {
247
+ // Under reduced motion the underline jumps to the new tab instead of sliding.
248
+ const reduceMotion = useReducedMotion();
246
249
  return (
247
250
  // clip-path instead of overflow-hidden: overflow clips children at the
248
251
  // padding box, so the active-tab underline could never cover the bottom
@@ -269,11 +272,15 @@ function PackageManagerTabs({ activeManager, onSelect, id }: PackageManagerTabsP
269
272
  className="bg-brand absolute inset-x-0 -bottom-px mx-auto h-0.5 w-full"
270
273
  layoutId={`codeblock-pm-tab-${id}`}
271
274
  initial={false}
272
- transition={{
273
- type: 'spring',
274
- stiffness: 500,
275
- damping: 30,
276
- }}
275
+ transition={
276
+ reduceMotion
277
+ ? { duration: 0 }
278
+ : {
279
+ type: 'spring',
280
+ stiffness: 500,
281
+ damping: 30,
282
+ }
283
+ }
277
284
  />
278
285
  )}
279
286
  </Button>
@@ -354,7 +361,7 @@ function FadeOverlay({ visible }: FadeOverlayProps) {
354
361
  return (
355
362
  <div
356
363
  className={cn(
357
- 'from-card pointer-events-none absolute inset-x-0 bottom-0 h-20 bg-gradient-to-t to-transparent transition-opacity duration-300',
364
+ 'from-card pointer-events-none absolute inset-x-0 bottom-0 h-20 bg-gradient-to-t to-transparent transition-opacity duration-slow',
358
365
  visible ? 'opacity-100' : 'opacity-0',
359
366
  )}
360
367
  aria-hidden="true"
@@ -397,6 +404,9 @@ const codeBlockContentClassName = cn(
397
404
  'bg-transparent text-sm',
398
405
  '[&_pre]:py-4',
399
406
  '[&_.shiki]:!bg-transparent',
407
+ // Shiki's <pre> takes keyboard focus. The card clips anything outside it,
408
+ // so the ring sits 2px inside the code area.
409
+ '[&_pre:focus-visible]:outline-solid [&_pre:focus-visible]:outline-2 [&_pre:focus-visible]:-outline-offset-2 [&_pre:focus-visible]:outline-ring',
400
410
  // The code sizes to its longest line, so the ScrollArea viewport scrolls it.
401
411
  // A scrolling <code> inside the viewport could not take keyboard focus.
402
412
  '[&_code]:w-max',
@@ -470,6 +480,9 @@ export function CodeBlock({
470
480
  const [activePackageManager, setActivePackageManager] = usePackageManager();
471
481
  const [isExpanded, setIsExpanded] = useState(false);
472
482
  const instanceId = useId();
483
+ // Under reduced motion the code area opens and closes without a height
484
+ // animation; the fade overlay still fades.
485
+ const reduceMotion = useReducedMotion();
473
486
 
474
487
  const rawCode = children ?? '';
475
488
 
@@ -536,29 +549,39 @@ export function CodeBlock({
536
549
  animate={{
537
550
  height: showCollapsed ? COLLAPSED_HEIGHT : 'auto',
538
551
  }}
539
- transition={{
540
- duration: 0.3,
541
- ease: [0.4, 0, 0.2, 1],
542
- }}
552
+ transition={
553
+ reduceMotion
554
+ ? { duration: 0 }
555
+ : {
556
+ duration: 0.3,
557
+ ease: [0.4, 0, 0.2, 1],
558
+ }
559
+ }
543
560
  >
544
- <ScrollArea className="w-full whitespace-nowrap">
545
- <div
546
- className={cn(
547
- codeBlockContentClassName,
548
- lineHighlightClassNames,
549
- lineDiffClassNames,
550
- lineFocusedClassNames,
551
- wordHighlightClassNames,
552
- darkModeClassNames,
553
- )}
554
- >
555
- <SyntaxHighlightedContent
556
- code={displayCode}
557
- language={normalizeLanguage(isCommand ? 'bash' : language)}
558
- />
559
- </div>
560
- <ScrollBar orientation="horizontal" />
561
- </ScrollArea>
561
+ {/* Code reads left to right in every page direction. The header
562
+ mirrors with the page; the code area and its scroll do not. The
563
+ provider tells the ScrollArea, which reads it for its scroll
564
+ position. */}
565
+ <DirectionProvider direction="ltr">
566
+ <ScrollArea dir="ltr" className="w-full whitespace-nowrap">
567
+ <div
568
+ className={cn(
569
+ codeBlockContentClassName,
570
+ lineHighlightClassNames,
571
+ lineDiffClassNames,
572
+ lineFocusedClassNames,
573
+ wordHighlightClassNames,
574
+ darkModeClassNames,
575
+ )}
576
+ >
577
+ <SyntaxHighlightedContent
578
+ code={displayCode}
579
+ language={normalizeLanguage(isCommand ? 'bash' : language)}
580
+ />
581
+ </div>
582
+ <ScrollBar orientation="horizontal" />
583
+ </ScrollArea>
584
+ </DirectionProvider>
562
585
  </motion.div>
563
586
  <FadeOverlay visible={showCollapsed} />
564
587
  </div>