@vendure-io/ui 2.1.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 +73 -13
  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 +138 -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 +916 -84
  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
@@ -0,0 +1,349 @@
1
+ import { mergeProps } from '@base-ui/react/merge-props';
2
+ import { useRender } from '@base-ui/react/use-render';
3
+ import { cn } from '@vendure-io/ui/lib/utils';
4
+ import { ChevronRight } from 'lucide-react';
5
+ import type * as React from 'react';
6
+
7
+ // Compound-only, like PageHeader: callers assemble the parts, so a row can hold
8
+ // any mix of leading media, a status column, a time and row actions without an
9
+ // ever-growing prop set.
10
+ //
11
+ // The row link is a stretched link. ListRowLink is the one real link or button
12
+ // of the row; its ::after covers the whole row, so a click on any point of the
13
+ // row opens it, while keyboard and screen reader users get one tab stop and one
14
+ // accessible name (the title). Interactive elements inside the row (buttons,
15
+ // links, menus, copy chips) are lifted above the stretched area, so they keep
16
+ // their own click and their own tab stop. A row without ListRowLink is static:
17
+ // no hover fill, no pointer cursor.
18
+
19
+ // Every interactive descendant, every Tooltip trigger and the copy chips
20
+ // (IdChip, AnonymizedToken, CopyableText), except the row link itself. A copy
21
+ // chip is lifted as a whole and its inner button stays static, as in a
22
+ // DataTable row: a positioned copy button becomes the containing block of its
23
+ // own stretched ::after, which then shrinks to the icon, so a click on the
24
+ // value would copy nothing. Any other element that must stay hoverable above
25
+ // the link takes `data-list-row-control`. The class names stay literal so
26
+ // Tailwind can scan them.
27
+ const LIFT_CONTROLS =
28
+ '[&_:is(a,button,input,select,textarea,[role=button],[tabindex],[data-tooltip-trigger],[data-slot=id-chip],[data-slot=anonymized-token],[data-slot=copyable-text],[data-list-row-control]):not([data-slot=list-row-link],[data-slot=id-chip]_*,[data-slot=anonymized-token]_*,[data-slot=copyable-text]_*)]:relative [&_:is(a,button,input,select,textarea,[role=button],[tabindex],[data-tooltip-trigger],[data-slot=id-chip],[data-slot=anonymized-token],[data-slot=copyable-text],[data-list-row-control]):not([data-slot=list-row-link],[data-slot=id-chip]_*,[data-slot=anonymized-token]_*,[data-slot=copyable-text]_*)]:z-10';
29
+
30
+ // A row the user just added (`enter="new"`) enters once: its height opens from 0
31
+ // so the rows below glide down, then its content fades in from a 3px blur.
32
+ // @starting-style runs it on mount only, so a list never animates on page
33
+ // load unless the caller marks rows. `interpolate-size` lets the height run to
34
+ // `auto`, which keeps a two-line row exact; a browser without it skips the
35
+ // height and keeps the fade. The height opens in `row-enter` on the `height`
36
+ // curve, the curve of the Accordion panel; the content fades in `slow` on
37
+ // `soft` and unblurs on `out`, both a `fast` beat later. Reduced motion keeps
38
+ // the fade only.
39
+ const ENTER_NEW =
40
+ 'data-[enter=new]:overflow-clip data-[enter=new]:[interpolate-size:allow-keywords] motion-safe:data-[enter=new]:[transition:height_var(--transition-duration-row-enter)_var(--ease-height),min-height_var(--transition-duration-row-enter)_var(--ease-height),opacity_var(--transition-duration-slow)_var(--ease-soft)_var(--transition-duration-fast),filter_var(--transition-duration-slow)_var(--ease-out)_var(--transition-duration-fast),background-color_var(--transition-duration-fast)_var(--ease-default)] motion-safe:data-[enter=new]:starting:h-0 motion-safe:data-[enter=new]:starting:min-h-0 motion-safe:data-[enter=new]:starting:blur-[3px] data-[enter=new]:starting:opacity-0 motion-reduce:data-[enter=new]:[transition:opacity_var(--transition-duration-normal)_var(--ease-default),background-color_var(--transition-duration-fast)_var(--ease-default)]';
41
+
42
+ // Rows that a "Show older" action adds (`enter={{ stagger }}`) enter once, 28ms after
43
+ // the row above: each fades in and rises 6px out of a 3px blur on the strong
44
+ // ease-out. The delay stops growing after 12 rows, so a long page does not
45
+ // keep its last rows waiting. Reduced motion keeps a plain fade, without the
46
+ // stagger. The hover fill keeps its own timing, without the delay.
47
+ const ENTER_STAGGER =
48
+ 'motion-safe:data-[enter=stagger]:[transition:opacity_var(--transition-duration-slow)_var(--ease-out)_var(--list-row-stagger-delay),translate_var(--transition-duration-slow)_var(--ease-out)_var(--list-row-stagger-delay),filter_var(--transition-duration-slow)_var(--ease-out)_var(--list-row-stagger-delay),background-color_var(--transition-duration-fast)_var(--ease-default)] data-[enter=stagger]:starting:opacity-0 motion-safe:data-[enter=stagger]:starting:translate-y-1.5 motion-safe:data-[enter=stagger]:starting:blur-[3px] motion-reduce:data-[enter=stagger]:[transition:opacity_var(--transition-duration-normal)_var(--ease-default),background-color_var(--transition-duration-fast)_var(--ease-default)]';
49
+
50
+ const STAGGER_MS = 28;
51
+ const STAGGER_ROWS = 12;
52
+
53
+ interface ListRowProps extends React.ComponentProps<'div'> {
54
+ /**
55
+ * How a row added while the page is open enters. Leave it unset on rows of
56
+ * the first render, so the list does not animate on page load.
57
+ *
58
+ * - `'new'`: a row the user just added (a new backup, a new push). Its
59
+ * height opens, then its content fades in.
60
+ * - `{ stagger: n }`: a row that a "Show older" action adds, `n` being its
61
+ * position among the added rows (0, 1, 2…). It fades up 28ms after the
62
+ * row above it.
63
+ */
64
+ enter?: 'new' | { stagger: number };
65
+ }
66
+
67
+ /**
68
+ * One row of a list: 48px high, or 60px with a ListRowMeta line. Content
69
+ * starts 18px in and ends 16px from the edge, like a card header. With a
70
+ * ListRowLink inside, the whole row opens the link and takes a `muted` hover
71
+ * fill; keyboard focus on the link draws an inset ring around the row.
72
+ *
73
+ * A row added while the page is open takes `enter` and enters once.
74
+ */
75
+ function ListRow({ className, enter, style, ...props }: ListRowProps) {
76
+ const stagger = typeof enter === 'object' ? enter.stagger : undefined;
77
+ return (
78
+ <div
79
+ data-slot="list-row"
80
+ data-enter={enter === 'new' ? 'new' : enter ? 'stagger' : undefined}
81
+ style={
82
+ stagger !== undefined
83
+ ? ({
84
+ '--list-row-stagger-delay': `${Math.min(Math.max(stagger, 0), STAGGER_ROWS) * STAGGER_MS}ms`,
85
+ ...style,
86
+ } as React.CSSProperties)
87
+ : style
88
+ }
89
+ className={cn(
90
+ 'group/list-row relative flex min-h-12 items-center gap-3 border-t border-border ps-4.5 pe-4 text-sm first:border-t-0',
91
+ '[[data-slot=list-row-group-heading]+&]:border-t-0',
92
+ 'has-data-[slot=list-row-meta]:py-2.5',
93
+ 'transition-colors duration-fast ease-default',
94
+ 'has-data-[slot=list-row-link]:cursor-pointer has-data-[slot=list-row-link]:hover:bg-muted',
95
+ 'has-[[data-slot=list-row-link]:focus-visible]:outline-solid has-[[data-slot=list-row-link]:focus-visible]:outline-2 has-[[data-slot=list-row-link]:focus-visible]:-outline-offset-2 has-[[data-slot=list-row-link]:focus-visible]:outline-ring',
96
+ LIFT_CONTROLS,
97
+ ENTER_NEW,
98
+ ENTER_STAGGER,
99
+ className,
100
+ )}
101
+ {...props}
102
+ />
103
+ );
104
+ }
105
+
106
+ /**
107
+ * The heading of a group of rows, such as a day ("Today", "Yesterday"): 34px,
108
+ * in `foreground-secondary`, a step above the row meta. It takes the rule
109
+ * above, so the first row under it drops its own. Renders a `div`; pass `render={<h3 />}` when the groups belong in the page outline.
110
+ */
111
+ function ListRowGroupHeading({ className, render, ...props }: useRender.ComponentProps<'div'>) {
112
+ return useRender({
113
+ defaultTagName: 'div',
114
+ render,
115
+ props: mergeProps<'div'>(
116
+ {
117
+ className: cn(
118
+ 'border-t border-border pt-4 pb-1.5 ps-4.5 pe-4 text-xs leading-3 font-semibold text-foreground-secondary first:border-t-0',
119
+ className,
120
+ ),
121
+ },
122
+ props,
123
+ ),
124
+ state: { slot: 'list-row-group-heading' },
125
+ });
126
+ }
127
+
128
+ /**
129
+ * Leading icon, avatar or status mark. Icons default to 16px. A plain icon is
130
+ * decorative: it renders quieter than the title (55%, 85% while the row is
131
+ * hovered or focused). An icon with its own `text-*` colour, such as a tone
132
+ * icon, keeps it at full strength.
133
+ */
134
+ function ListRowLeading({ className, ...props }: React.ComponentProps<'div'>) {
135
+ return (
136
+ <div
137
+ data-slot="list-row-leading"
138
+ className={cn(
139
+ "flex shrink-0 items-center text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75]",
140
+ "[&>svg:not([class*='opacity-']):not([class*='text-'])]:text-foreground [&>svg:not([class*='opacity-']):not([class*='text-'])]:opacity-55 [&>svg:not([class*='opacity-']):not([class*='text-'])]:transition-opacity [&>svg:not([class*='opacity-']):not([class*='text-'])]:duration-moderate group-hover/list-row:[&>svg:not([class*='opacity-']):not([class*='text-'])]:opacity-85 group-focus-within/list-row:[&>svg:not([class*='opacity-']):not([class*='text-'])]:opacity-85",
141
+ className,
142
+ )}
143
+ {...props}
144
+ />
145
+ );
146
+ }
147
+
148
+ /** The text column: the title (ListRowLink or ListRowTitle) and an optional ListRowMeta. */
149
+ function ListRowContent({ className, ...props }: React.ComponentProps<'div'>) {
150
+ return (
151
+ <div
152
+ data-slot="list-row-content"
153
+ className={cn('flex min-w-0 flex-1 flex-col gap-0.5', className)}
154
+ {...props}
155
+ />
156
+ );
157
+ }
158
+
159
+ const titleClassName = 'min-w-0 max-w-full truncate text-start text-sm font-medium text-foreground';
160
+
161
+ /**
162
+ * The row link and the row's title. Renders a `<button>` for an `onClick`
163
+ * handler; pass `render={<a href="…" />}` (or a router link element) to open a
164
+ * URL. Its children are the accessible name of the row, so keep them to the
165
+ * title: put secondary text in ListRowMeta.
166
+ */
167
+ function ListRowLink({ className, render, ...props }: useRender.ComponentProps<'button'>) {
168
+ return useRender({
169
+ defaultTagName: 'button',
170
+ render,
171
+ props: mergeProps<'button'>(
172
+ {
173
+ // A native button submits its form by default; a rendered anchor or
174
+ // router link takes no type.
175
+ type: render ? undefined : 'button',
176
+ className: cn(
177
+ titleClassName,
178
+ 'cursor-pointer outline-none after:absolute after:inset-0',
179
+ className,
180
+ ),
181
+ },
182
+ props,
183
+ ),
184
+ state: { slot: 'list-row-link' },
185
+ });
186
+ }
187
+
188
+ /** The title of a static row, one that opens nothing. Same type as ListRowLink. */
189
+ function ListRowTitle({ className, ...props }: React.ComponentProps<'span'>) {
190
+ return <span data-slot="list-row-title" className={cn(titleClassName, className)} {...props} />;
191
+ }
192
+
193
+ /** The secondary line under the title (who, how long). Makes the row a two-line row. */
194
+ function ListRowMeta({ className, ...props }: React.ComponentProps<'span'>) {
195
+ return (
196
+ <span
197
+ data-slot="list-row-meta"
198
+ className={cn('truncate text-xs leading-4.5 text-muted-foreground', className)}
199
+ {...props}
200
+ />
201
+ );
202
+ }
203
+
204
+ /** Always-visible end columns: a status, a time, a count. Tabular figures keep times aligned. */
205
+ function ListRowTrailing({ className, ...props }: React.ComponentProps<'div'>) {
206
+ return (
207
+ <div
208
+ data-slot="list-row-trailing"
209
+ className={cn(
210
+ 'flex shrink-0 items-center gap-3 text-muted-foreground tabular-nums',
211
+ className,
212
+ )}
213
+ {...props}
214
+ />
215
+ );
216
+ }
217
+
218
+ // Hover-revealed controls fade in `quick` on `soft`. They stay visible while
219
+ // the row has focus, while one of them has its menu open, and on touch
220
+ // screens, where there is no hover.
221
+ const revealOnRowHover =
222
+ 'opacity-0 transition-opacity duration-quick ease-soft group-hover/list-row:opacity-100 group-focus-within/list-row:opacity-100 [@media(hover:none)]:opacity-100';
223
+
224
+ /** Secondary row actions. Hidden until the row is hovered or has focus. */
225
+ function ListRowActions({ className, ...props }: React.ComponentProps<'div'>) {
226
+ return (
227
+ <div
228
+ data-slot="list-row-actions"
229
+ className={cn(
230
+ 'relative z-10 flex shrink-0 items-center gap-1',
231
+ revealOnRowHover,
232
+ 'has-[[aria-expanded=true]]:opacity-100',
233
+ className,
234
+ )}
235
+ {...props}
236
+ />
237
+ );
238
+ }
239
+
240
+ // ListRowSwap stacks its value and its action in one grid cell, so the cell
241
+ // keeps the width of the wider one and nothing in the row moves. The swap is
242
+ // sequenced, not a crossfade: the outgoing one fades in `row-swap-out`, the
243
+ // incoming one fades in `quick` after `row-swap-delay`, both on `soft`, so the
244
+ // value and the action never show at once. The rest state carries the leave
245
+ // timing (the action out first, the value back after it); the shown state
246
+ // carries the enter timing. The action shows while the row is hovered, while
247
+ // anything in the row has keyboard focus and while the action's menu is open;
248
+ // on a touch screen it always shows. Reduced motion swaps at once. The value
249
+ // only fades, so a screen reader still reads it. The class names stay literal
250
+ // so Tailwind can scan them.
251
+ const SWAP_VALUE_CLASS = [
252
+ 'col-start-1 row-start-1 whitespace-nowrap text-foreground-secondary tabular-nums',
253
+ 'transition-opacity duration-quick ease-soft delay-(--transition-duration-row-swap-delay) motion-reduce:transition-none',
254
+ 'group-hover/list-row:opacity-0 group-hover/list-row:duration-row-swap-out group-hover/list-row:delay-0',
255
+ 'group-has-[:focus-visible]/list-row:opacity-0 group-has-[:focus-visible]/list-row:duration-row-swap-out group-has-[:focus-visible]/list-row:delay-0',
256
+ 'group-has-[[aria-expanded=true]]/list-row-swap:opacity-0 group-has-[[aria-expanded=true]]/list-row-swap:duration-row-swap-out group-has-[[aria-expanded=true]]/list-row-swap:delay-0',
257
+ '[@media(hover:none)]:opacity-0',
258
+ ].join(' ');
259
+
260
+ const SWAP_ACTION_CLASS = [
261
+ 'col-start-1 row-start-1 flex items-center gap-1 opacity-0',
262
+ 'transition-opacity duration-row-swap-out ease-soft motion-reduce:transition-none',
263
+ 'group-hover/list-row:opacity-100 group-hover/list-row:duration-quick group-hover/list-row:delay-(--transition-duration-row-swap-delay)',
264
+ 'group-has-[:focus-visible]/list-row:opacity-100 group-has-[:focus-visible]/list-row:duration-quick group-has-[:focus-visible]/list-row:delay-(--transition-duration-row-swap-delay)',
265
+ 'group-has-[[aria-expanded=true]]/list-row-swap:opacity-100',
266
+ '[@media(hover:none)]:opacity-100',
267
+ ].join(' ');
268
+
269
+ interface ListRowSwapProps extends React.ComponentProps<'div'> {
270
+ /** What the cell shows at rest: a size, a count, a time. */
271
+ value: React.ReactNode;
272
+ /** The action that takes the value's place: one `sm` Button or a menu trigger. */
273
+ children: React.ReactNode;
274
+ }
275
+
276
+ /**
277
+ * The last value of a row that turns into an action: at rest the cell shows
278
+ * `value`; while the row is hovered, holds keyboard focus or has the action's
279
+ * menu open, the value fades out and the action (`children`) fades in its
280
+ * place. On a touch screen the action always shows. The cell is as wide as
281
+ * the wider of the two, so nothing in the row moves. Place it last in the
282
+ * row, after ListRowTrailing. Give the action a name that says which row it
283
+ * acts on (`aria-label="Restore to today, 01:00"`).
284
+ */
285
+ function ListRowSwap({ value, children, className, ...props }: ListRowSwapProps) {
286
+ return (
287
+ <div
288
+ data-slot="list-row-swap"
289
+ className={cn('group/list-row-swap grid shrink-0 items-center justify-items-end', className)}
290
+ {...props}
291
+ >
292
+ {/* `dir="auto"` keeps a Latin value ("1.82 GB") in its own order inside a right-to-left row. */}
293
+ <span data-slot="list-row-swap-value" dir="auto" className={SWAP_VALUE_CLASS}>
294
+ {value}
295
+ </span>
296
+ <div data-slot="list-row-swap-action" className={SWAP_ACTION_CLASS}>
297
+ {children}
298
+ </div>
299
+ </div>
300
+ );
301
+ }
302
+
303
+ // The row-end chevron of ListRow and of a DataTable row with a row link: one
304
+ // recipe, so the two cannot drift. Hidden at rest; while its row is hovered
305
+ // or holds keyboard focus it fades in and slides 3px toward the end (fade only
306
+ // under reduced motion). On a touch screen it always shows. The row is the
307
+ // ListRow (`group/list-row`) or the DataTable row (`group/row`). The class
308
+ // names stay literal so Tailwind can scan them.
309
+ const ROW_CHEVRON_CLASS = [
310
+ 'size-3.75 shrink-0 text-muted-foreground opacity-0 rtl:-scale-x-100',
311
+ 'transition-[opacity,translate] duration-fast ease-out',
312
+ 'motion-safe:-translate-x-0.75 motion-safe:rtl:translate-x-0.75',
313
+ 'group-hover/list-row:translate-x-0 group-hover/list-row:opacity-100 group-has-[:focus-visible]/list-row:translate-x-0 group-has-[:focus-visible]/list-row:opacity-100',
314
+ 'group-hover/row:translate-x-0 group-hover/row:opacity-100 group-has-[:focus-visible]/row:translate-x-0 group-has-[:focus-visible]/row:opacity-100',
315
+ '[@media(hover:none)]:translate-x-0 [@media(hover:none)]:opacity-100',
316
+ ].join(' ');
317
+
318
+ /**
319
+ * The trailing chevron of a linked row: 15px. While the row is hovered or
320
+ * holds keyboard focus, it fades in and slides 3px toward the end in 100ms
321
+ * (fade only under reduced motion). Decorative: the link carries the name.
322
+ * DataTableRowLink renders the same chevron.
323
+ */
324
+ function ListRowChevron({ className, ...props }: React.ComponentProps<typeof ChevronRight>) {
325
+ return (
326
+ <ChevronRight
327
+ data-slot="list-row-chevron"
328
+ aria-hidden="true"
329
+ strokeWidth={1.75}
330
+ className={cn(ROW_CHEVRON_CLASS, className)}
331
+ {...props}
332
+ />
333
+ );
334
+ }
335
+
336
+ export {
337
+ ListRow,
338
+ ListRowActions,
339
+ ListRowChevron,
340
+ ListRowContent,
341
+ ListRowGroupHeading,
342
+ ListRowLeading,
343
+ ListRowLink,
344
+ ListRowMeta,
345
+ ListRowSwap,
346
+ ListRowTitle,
347
+ ListRowTrailing,
348
+ };
349
+ export type { ListRowProps, ListRowSwapProps };
@@ -0,0 +1,83 @@
1
+ import type { Tone } from '@vendure-io/ui/lib/state-dictionary';
2
+ import { statusToneText } from '@vendure-io/ui/lib/tint-recipes';
3
+ import { cn } from '@vendure-io/ui/lib/utils';
4
+ import type * as React from 'react';
5
+
6
+ // The dot fill of each tone, as in StatusBadge: a dot is a filled shape, so
7
+ // warning takes `warning-indicator`; in `warning-text` the dot reads brown.
8
+ const toneDot: Record<Tone, string> = {
9
+ ...statusToneText,
10
+ warning: 'text-warning-indicator',
11
+ };
12
+
13
+ // The ring is a copy of the dot behind it that grows to 2.6× and fades
14
+ // (`animate-live-pulse`: 2.4s on the `out` curve, then a rest). Only transform
15
+ // and opacity change. Under reduced motion the ring is not drawn: the dot
16
+ // alone says "live". Forced colours keep the dot's tone fill: it is a shape,
17
+ // not a background.
18
+ const ringClass =
19
+ 'after:absolute after:inset-0 after:rounded-full after:bg-current after:content-[""] motion-safe:after:animate-live-pulse motion-reduce:after:hidden';
20
+
21
+ interface LiveIndicatorProps extends React.ComponentProps<'span'> {
22
+ /** The dot colour. Defaults to `success`. @default 'success' */
23
+ tone?: Tone;
24
+ /**
25
+ * Draw the ring that pulses out of the dot. Turn it off where something
26
+ * else on the page already moves for the same state (a spinner, a progress
27
+ * sweep): one moving mark per state is enough. @default true
28
+ */
29
+ pulse?: boolean;
30
+ /**
31
+ * The text for assistive technology when no visible label is next to the
32
+ * dot (`children`). Leave both out when the text beside the indicator
33
+ * already says the same: the indicator is then hidden from assistive
34
+ * technology.
35
+ */
36
+ label?: string;
37
+ /** A visible label after the dot, in 12px secondary text. */
38
+ children?: React.ReactNode;
39
+ }
40
+
41
+ /**
42
+ * A 7px dot with a soft ring that pulses outward: a live stream or work that
43
+ * runs right now and stays on for minutes. StatusBadge keeps its spinner for
44
+ * "in progress"; this dot means "live".
45
+ */
46
+ function LiveIndicator({
47
+ className,
48
+ tone = 'success',
49
+ pulse = true,
50
+ label,
51
+ children,
52
+ ...props
53
+ }: LiveIndicatorProps) {
54
+ const hasChildren = children !== undefined && children !== null && children !== false;
55
+ const decorative = !hasChildren && !label;
56
+
57
+ return (
58
+ <span
59
+ data-slot="live-indicator"
60
+ data-tone={tone}
61
+ aria-hidden={decorative || undefined}
62
+ className={cn(
63
+ 'inline-flex shrink-0 items-center gap-1.75 whitespace-nowrap text-xs font-medium text-foreground-secondary',
64
+ className,
65
+ )}
66
+ {...props}
67
+ >
68
+ <span
69
+ aria-hidden
70
+ data-slot="live-indicator-dot"
71
+ className={cn(
72
+ 'relative size-1.75 shrink-0 rounded-full bg-current forced-color-adjust-none',
73
+ toneDot[tone],
74
+ pulse && ringClass,
75
+ )}
76
+ />
77
+ {hasChildren ? children : label ? <span className="sr-only">{label}</span> : null}
78
+ </span>
79
+ );
80
+ }
81
+
82
+ export { LiveIndicator };
83
+ export type { LiveIndicatorProps };
@@ -1,5 +1,8 @@
1
+ import { mergeProps } from '@base-ui/react/merge-props';
2
+ import { useRender } from '@base-ui/react/use-render';
1
3
  import { cn } from '@vendure-io/ui/lib/utils';
2
4
  import type * as React from 'react';
5
+ import { DirectionLink, ExternalArrow } from './direction-link.tsx';
3
6
 
4
7
  // Compound-only, by decision: there is no simple-props sugar and
5
8
  // no dual-mode root. Callers assemble the parts, which keeps one way to build a
@@ -46,7 +49,7 @@ function PageHeaderDescription({ className, ...props }: React.ComponentProps<'p'
46
49
  return (
47
50
  <p
48
51
  data-slot="page-header-description"
49
- className={cn('text-sm text-muted-foreground', className)}
52
+ className={cn('text-sm text-foreground-secondary', className)}
50
53
  {...props}
51
54
  />
52
55
  );
@@ -63,12 +66,116 @@ function PageHeaderActions({ className, ...props }: React.ComponentProps<'div'>)
63
66
  );
64
67
  }
65
68
 
66
- /** Optional row rendered above the header — typically a back link. */
67
- function PageHeaderBackLink({ className, ...props }: React.ComponentProps<'div'>) {
69
+ /**
70
+ * The facts under the title: branch, region, host, owner. 13px text in
71
+ * `foreground-secondary`, 18px between facts and 6px between rows when they
72
+ * wrap. Put it in PageHeaderContent, below the title.
73
+ */
74
+ function PageHeaderFacts({ className, ...props }: React.ComponentProps<'div'>) {
68
75
  return (
69
76
  <div
70
- data-slot="page-header-back-link"
71
- className={cn('flex items-center gap-1 text-sm text-muted-foreground', className)}
77
+ data-slot="page-header-facts"
78
+ className={cn(
79
+ 'flex flex-wrap items-center gap-x-4.5 gap-y-1.5 text-style-body text-foreground-secondary',
80
+ className,
81
+ )}
82
+ {...props}
83
+ />
84
+ );
85
+ }
86
+
87
+ /** One fact: an optional leading icon at 45% and its text, 7px apart. */
88
+ function PageHeaderFact({ className, ...props }: React.ComponentProps<'span'>) {
89
+ return (
90
+ <span
91
+ data-slot="page-header-fact"
92
+ className={cn(
93
+ 'inline-flex min-w-0 items-center gap-1.75 [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:stroke-[1.75] [&>svg]:opacity-45',
94
+ className,
95
+ )}
96
+ {...props}
97
+ />
98
+ );
99
+ }
100
+
101
+ // A fact that opens another site, such as the environment's hostname. At rest
102
+ // it reads like PageHeaderFact. On hover or keyboard focus its text goes from
103
+ // `foreground-secondary` to `foreground`, its leading icon from 45% to full
104
+ // strength in `brand-indicator`, and the trailing diagonal arrow brightens
105
+ // and moves 1.5px out (ExternalArrow, the arrow of ArrowLink `external`).
106
+ // No underline. Colour and opacity ease in `moderate` on `soft`. The class
107
+ // names stay literal so Tailwind can scan them.
108
+ const FACT_LINK_ICON =
109
+ '[&>svg:not([data-slot=page-header-fact-arrow])]:[transition:color_var(--transition-duration-moderate)_var(--ease-soft),opacity_var(--transition-duration-moderate)_var(--ease-soft)] hover:[&>svg:not([data-slot=page-header-fact-arrow])]:text-brand-indicator hover:[&>svg:not([data-slot=page-header-fact-arrow])]:opacity-100 focus-visible:[&>svg:not([data-slot=page-header-fact-arrow])]:text-brand-indicator focus-visible:[&>svg:not([data-slot=page-header-fact-arrow])]:opacity-100';
110
+
111
+ /**
112
+ * A fact that is a link to another site: the environment's hostname, a
113
+ * repository. Put a leading icon and the text in it, as in PageHeaderFact;
114
+ * it adds the trailing up-right arrow. Wrap a long value in a
115
+ * `<span className="truncate">`. Renders an `<a>`; pass `render` for another
116
+ * element. Set `target` and `rel` yourself when it opens a new tab.
117
+ */
118
+ function PageHeaderFactLink({
119
+ className,
120
+ render,
121
+ children,
122
+ ...props
123
+ }: useRender.ComponentProps<'a'>) {
124
+ return useRender({
125
+ defaultTagName: 'a',
126
+ render,
127
+ props: mergeProps<'a'>(
128
+ {
129
+ className: cn(
130
+ 'group/arrow-link inline-flex min-w-0 cursor-pointer items-center gap-1.75 [&>svg]:shrink-0 [&>svg:not([data-slot=page-header-fact-arrow])]:size-4 [&>svg:not([data-slot=page-header-fact-arrow])]:stroke-[1.75] [&>svg:not([data-slot=page-header-fact-arrow])]:opacity-45',
131
+ 'transition-colors duration-moderate ease-soft hover:text-foreground focus-visible:text-foreground',
132
+ FACT_LINK_ICON,
133
+ 'rounded-md outline-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring',
134
+ className,
135
+ ),
136
+ children: (
137
+ <>
138
+ {children}
139
+ <ExternalArrow data-slot="page-header-fact-arrow" />
140
+ </>
141
+ ),
142
+ },
143
+ props,
144
+ ),
145
+ state: { slot: 'page-header-fact-link' },
146
+ });
147
+ }
148
+
149
+ /** Optional row rendered above the header: holds a PageHeaderBack. */
150
+ function PageHeaderBackRow({ className, ...props }: React.ComponentProps<'div'>) {
151
+ return (
152
+ <div
153
+ data-slot="page-header-back-row"
154
+ className={cn('flex items-center text-style-body text-muted-foreground', className)}
155
+ {...props}
156
+ />
157
+ );
158
+ }
159
+
160
+ /**
161
+ * @deprecated Use `PageHeaderBackRow`, and put a `PageHeaderBack` in it for the
162
+ * link. The 2.x name, kept so code written against 2.x still compiles.
163
+ */
164
+ const PageHeaderBackLink = PageHeaderBackRow;
165
+
166
+ /**
167
+ * The link up one level, above the title: "Deployments", "All profiles".
168
+ * Renders an `<a>` with a leading chevron in `muted-foreground`; the look,
169
+ * motion and right-to-left handling are ArrowLink's, pointing back. Pass
170
+ * `render` to use a router link.
171
+ */
172
+ function PageHeaderBack({ className, ...props }: useRender.ComponentProps<'a'>) {
173
+ return (
174
+ <DirectionLink
175
+ direction="back"
176
+ slot="page-header-back"
177
+ iconSlot="page-header-back-chevron"
178
+ className={cn('text-muted-foreground', className)}
72
179
  {...props}
73
180
  />
74
181
  );
@@ -80,5 +187,10 @@ export {
80
187
  PageHeaderTitle,
81
188
  PageHeaderDescription,
82
189
  PageHeaderActions,
190
+ PageHeaderBackRow,
83
191
  PageHeaderBackLink,
192
+ PageHeaderBack,
193
+ PageHeaderFacts,
194
+ PageHeaderFact,
195
+ PageHeaderFactLink,
84
196
  };
@@ -6,7 +6,7 @@ import {
6
6
  InputGroupButton,
7
7
  InputGroupInput,
8
8
  } from '@vendure-io/ui/components/atoms/input-group';
9
- import { Eye, EyeOff } from 'lucide-react';
9
+ import { VisibilityIcon } from '@vendure-io/ui/components/molecules/visibility-icon';
10
10
  import * as React from 'react';
11
11
 
12
12
  export interface PasswordInputProps extends Omit<React.ComponentProps<'input'>, 'type'> {
@@ -37,7 +37,7 @@ function PasswordInput({
37
37
  onClick={() => setShowPassword((prev) => !prev)}
38
38
  aria-label={showPassword ? hidePasswordLabel : showPasswordLabel}
39
39
  >
40
- {showPassword ? <EyeOff /> : <Eye />}
40
+ <VisibilityIcon visible={!showPassword} />
41
41
  </InputGroupButton>
42
42
  </InputGroupAddon>
43
43
  </InputGroup>