@vendure-io/ui 2.0.0-beta.2 → 2.0.0-beta.20

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 (35) hide show
  1. package/LICENSE.md +34 -0
  2. package/README.md +6 -3
  3. package/package.json +10 -9
  4. package/src/components/atoms/button.tsx +5 -1
  5. package/src/components/atoms/card.tsx +39 -4
  6. package/src/components/atoms/combobox.tsx +19 -4
  7. package/src/components/atoms/scroll-area.tsx +4 -2
  8. package/src/components/atoms/sidebar.tsx +27 -12
  9. package/src/components/atoms/table.tsx +1 -1
  10. package/src/components/atoms/tabs.tsx +64 -1
  11. package/src/components/atoms/toggle-group.tsx +1 -1
  12. package/src/components/atoms/toggle.tsx +5 -2
  13. package/src/components/molecules/anonymized-token.tsx +2 -2
  14. package/src/components/molecules/app-shell.tsx +110 -0
  15. package/src/components/molecules/code-block/file-type-icons.tsx +123 -0
  16. package/src/components/molecules/code-block/transform-command.tsx +177 -0
  17. package/src/components/molecules/code-block.tsx +634 -0
  18. package/src/components/molecules/combobox-free-text.tsx +18 -0
  19. package/src/components/molecules/copy-feedback-provider.tsx +33 -0
  20. package/src/components/molecules/copyable-text.tsx +30 -7
  21. package/src/components/molecules/data-table/data-table-bulk-actions.tsx +10 -9
  22. package/src/components/molecules/data-table/data-table-types.tsx +50 -2
  23. package/src/components/molecules/data-table/data-table.tsx +184 -91
  24. package/src/components/molecules/date-picker.tsx +119 -0
  25. package/src/components/molecules/date-range-picker.tsx +153 -0
  26. package/src/components/molecules/date-time-picker.tsx +133 -0
  27. package/src/components/molecules/file-dropzone.tsx +271 -0
  28. package/src/components/molecules/id-chip.tsx +1 -1
  29. package/src/components/molecules/page-header.tsx +7 -3
  30. package/src/components/molecules/skip-link.tsx +36 -0
  31. package/src/components/molecules/state-views/empty-state.tsx +12 -1
  32. package/src/components/molecules/state-views/loading-state.tsx +7 -3
  33. package/src/lib/date-value.ts +48 -0
  34. package/src/lib/highlight.ts +174 -0
  35. package/src/lib/utils.ts +0 -19
@@ -0,0 +1,153 @@
1
+ 'use client';
2
+
3
+ import { Button } from '@vendure-io/ui/components/atoms/button';
4
+ import { Calendar } from '@vendure-io/ui/components/atoms/calendar';
5
+ import { Popover, PopoverContent, PopoverTrigger } from '@vendure-io/ui/components/atoms/popover';
6
+ import { useFormatSettings } from '@vendure-io/ui/components/molecules/format-provider';
7
+ import {
8
+ formatCalendarDate,
9
+ formatDateRangeLabel,
10
+ parseCalendarDate,
11
+ } from '@vendure-io/ui/lib/date-value';
12
+ import { cn } from '@vendure-io/ui/lib/utils';
13
+ import { CalendarRangeIcon, XIcon } from 'lucide-react';
14
+ import * as React from 'react';
15
+ import type { DateRange } from 'react-day-picker';
16
+
17
+ type CalendarProps = Omit<
18
+ React.ComponentProps<typeof Calendar>,
19
+ 'mode' | 'selected' | 'onSelect' | 'defaultMonth'
20
+ >;
21
+
22
+ interface DateRangeValue {
23
+ from?: string;
24
+ to?: string;
25
+ }
26
+
27
+ interface DateRangePreset {
28
+ id: string;
29
+ label: React.ReactNode;
30
+ value: DateRangeValue | (() => DateRangeValue);
31
+ }
32
+
33
+ interface DateRangePickerProps
34
+ extends Omit<React.ComponentProps<'div'>, 'defaultValue' | 'onChange'> {
35
+ /** Local calendar-date boundaries (`YYYY-MM-DD`), inclusive. */
36
+ value?: DateRangeValue;
37
+ onValueChange?: (value: DateRangeValue | undefined) => void;
38
+ placeholder?: React.ReactNode;
39
+ clearable?: boolean;
40
+ disabled?: boolean;
41
+ invalid?: boolean;
42
+ presets?: readonly DateRangePreset[];
43
+ calendarProps?: CalendarProps;
44
+ }
45
+
46
+ function resolvePreset(value: DateRangePreset['value']): DateRangeValue {
47
+ return typeof value === 'function' ? value() : value;
48
+ }
49
+
50
+ function DateRangePicker({
51
+ value,
52
+ onValueChange,
53
+ placeholder = 'Pick a date range',
54
+ clearable = true,
55
+ disabled,
56
+ invalid,
57
+ presets = [],
58
+ calendarProps,
59
+ className,
60
+ ...props
61
+ }: DateRangePickerProps) {
62
+ const [open, setOpen] = React.useState(false);
63
+ const { locale } = useFormatSettings();
64
+ const selected: DateRange = {
65
+ from: parseCalendarDate(value?.from),
66
+ to: parseCalendarDate(value?.to),
67
+ };
68
+ const hasValue = Boolean(selected.from);
69
+
70
+ function commitRange(range: DateRange | undefined) {
71
+ if (!range?.from) {
72
+ onValueChange?.(undefined);
73
+ return;
74
+ }
75
+ onValueChange?.({
76
+ from: formatCalendarDate(range.from),
77
+ to: range.to ? formatCalendarDate(range.to) : undefined,
78
+ });
79
+ }
80
+
81
+ return (
82
+ <div
83
+ data-slot="date-range-picker"
84
+ className={cn('flex min-w-0 items-center gap-1', className)}
85
+ {...props}
86
+ >
87
+ <Popover open={open} onOpenChange={setOpen}>
88
+ <PopoverTrigger
89
+ render={
90
+ <Button
91
+ type="button"
92
+ variant="outline"
93
+ disabled={disabled}
94
+ aria-invalid={invalid || undefined}
95
+ // Pickers sit in forms next to Inputs, so mirror the Input/Select
96
+ // trigger look (transparent bg) instead of the outline button fill.
97
+ className="min-w-0 flex-1 justify-start border-input bg-transparent font-normal hover:bg-transparent aria-expanded:bg-transparent"
98
+ />
99
+ }
100
+ >
101
+ <CalendarRangeIcon />
102
+ <span className={cn('truncate', !hasValue && 'text-muted-foreground')}>
103
+ {selected.from ? formatDateRangeLabel(selected.from, selected.to, locale) : placeholder}
104
+ </span>
105
+ </PopoverTrigger>
106
+ <PopoverContent className="w-auto p-0" align="start">
107
+ <div className={cn('flex', presets.length > 0 && 'divide-x')}>
108
+ {presets.length > 0 ? (
109
+ <div className="flex w-40 flex-col gap-1 p-2">
110
+ {presets.map((preset) => (
111
+ <Button
112
+ key={preset.id}
113
+ type="button"
114
+ variant="ghost"
115
+ size="sm"
116
+ className="justify-start font-normal"
117
+ onClick={() => {
118
+ onValueChange?.(resolvePreset(preset.value));
119
+ setOpen(false);
120
+ }}
121
+ >
122
+ {preset.label}
123
+ </Button>
124
+ ))}
125
+ </div>
126
+ ) : null}
127
+ <Calendar
128
+ {...calendarProps}
129
+ mode="range"
130
+ selected={selected}
131
+ defaultMonth={selected.from}
132
+ onSelect={commitRange}
133
+ />
134
+ </div>
135
+ </PopoverContent>
136
+ </Popover>
137
+ {clearable && hasValue ? (
138
+ <Button
139
+ type="button"
140
+ variant="ghost"
141
+ size="icon-sm"
142
+ disabled={disabled}
143
+ aria-label="Clear date range"
144
+ onClick={() => onValueChange?.(undefined)}
145
+ >
146
+ <XIcon />
147
+ </Button>
148
+ ) : null}
149
+ </div>
150
+ );
151
+ }
152
+
153
+ export { DateRangePicker, type DateRangePickerProps, type DateRangePreset, type DateRangeValue };
@@ -0,0 +1,133 @@
1
+ 'use client';
2
+
3
+ import { Button } from '@vendure-io/ui/components/atoms/button';
4
+ import { Calendar } from '@vendure-io/ui/components/atoms/calendar';
5
+ import { Input } from '@vendure-io/ui/components/atoms/input';
6
+ import { Popover, PopoverContent, PopoverTrigger } from '@vendure-io/ui/components/atoms/popover';
7
+ import { useFormatSettings } from '@vendure-io/ui/components/molecules/format-provider';
8
+ import { formatDateLabel, parseInstant } from '@vendure-io/ui/lib/date-value';
9
+ import { cn } from '@vendure-io/ui/lib/utils';
10
+ import { CalendarClockIcon, XIcon } from 'lucide-react';
11
+ import * as React from 'react';
12
+
13
+ type CalendarProps = Omit<
14
+ React.ComponentProps<typeof Calendar>,
15
+ 'mode' | 'selected' | 'onSelect' | 'defaultMonth'
16
+ >;
17
+
18
+ interface DateTimePickerProps
19
+ extends Omit<React.ComponentProps<'div'>, 'defaultValue' | 'onChange'> {
20
+ /** ISO 8601 instant. Calendar and time controls edit it in the user's local zone. */
21
+ value?: string;
22
+ onValueChange?: (value: string | undefined) => void;
23
+ placeholder?: React.ReactNode;
24
+ clearable?: boolean;
25
+ disabled?: boolean;
26
+ invalid?: boolean;
27
+ name?: string;
28
+ id?: string;
29
+ calendarProps?: CalendarProps;
30
+ }
31
+
32
+ function DateTimePicker({
33
+ value,
34
+ onValueChange,
35
+ placeholder = 'Pick a date and time',
36
+ clearable = true,
37
+ disabled,
38
+ invalid,
39
+ name,
40
+ id,
41
+ calendarProps,
42
+ className,
43
+ ...props
44
+ }: DateTimePickerProps) {
45
+ const [open, setOpen] = React.useState(false);
46
+ const { locale } = useFormatSettings();
47
+ const selected = parseInstant(value);
48
+ const timeValue = selected
49
+ ? `${String(selected.getHours()).padStart(2, '0')}:${String(selected.getMinutes()).padStart(2, '0')}`
50
+ : '';
51
+
52
+ function commitDate(date: Date | undefined) {
53
+ if (!date) return;
54
+ const next = new Date(date);
55
+ next.setHours(selected?.getHours() ?? 0, selected?.getMinutes() ?? 0, 0, 0);
56
+ onValueChange?.(next.toISOString());
57
+ setOpen(false);
58
+ }
59
+
60
+ function commitTime(time: string) {
61
+ if (!time) return;
62
+ const [hoursText, minutesText] = time.split(':');
63
+ const hours = Number(hoursText);
64
+ const minutes = Number(minutesText);
65
+ if (!Number.isFinite(hours) || !Number.isFinite(minutes)) return;
66
+ const next = selected ? new Date(selected) : new Date();
67
+ next.setHours(hours, minutes, 0, 0);
68
+ onValueChange?.(next.toISOString());
69
+ }
70
+
71
+ return (
72
+ <div
73
+ data-slot="date-time-picker"
74
+ className={cn('flex min-w-0 items-center gap-2', className)}
75
+ {...props}
76
+ >
77
+ {name ? <input type="hidden" name={name} value={value ?? ''} /> : null}
78
+ <Popover open={open} onOpenChange={setOpen}>
79
+ <PopoverTrigger
80
+ render={
81
+ <Button
82
+ id={id}
83
+ type="button"
84
+ variant="outline"
85
+ disabled={disabled}
86
+ aria-invalid={invalid || undefined}
87
+ // Pickers sit in forms next to Inputs, so mirror the Input/Select
88
+ // trigger look (transparent bg) instead of the outline button fill.
89
+ className="min-w-0 flex-1 justify-start border-input bg-transparent font-normal hover:bg-transparent aria-expanded:bg-transparent"
90
+ />
91
+ }
92
+ >
93
+ <CalendarClockIcon />
94
+ <span className={cn('truncate', !selected && 'text-muted-foreground')}>
95
+ {selected ? formatDateLabel(selected, locale) : placeholder}
96
+ </span>
97
+ </PopoverTrigger>
98
+ <PopoverContent className="w-auto p-0" align="start">
99
+ <Calendar
100
+ {...calendarProps}
101
+ mode="single"
102
+ selected={selected}
103
+ defaultMonth={selected}
104
+ onSelect={commitDate}
105
+ />
106
+ </PopoverContent>
107
+ </Popover>
108
+ <Input
109
+ type="time"
110
+ aria-label="Time"
111
+ aria-invalid={invalid || undefined}
112
+ value={timeValue}
113
+ disabled={disabled || !selected}
114
+ className="w-28"
115
+ onChange={(event) => commitTime(event.currentTarget.value)}
116
+ />
117
+ {clearable && selected ? (
118
+ <Button
119
+ type="button"
120
+ variant="ghost"
121
+ size="icon-sm"
122
+ disabled={disabled}
123
+ aria-label="Clear date and time"
124
+ onClick={() => onValueChange?.(undefined)}
125
+ >
126
+ <XIcon />
127
+ </Button>
128
+ ) : null}
129
+ </div>
130
+ );
131
+ }
132
+
133
+ export { DateTimePicker, type DateTimePickerProps };
@@ -0,0 +1,271 @@
1
+ 'use client';
2
+
3
+ import { Button } from '@vendure-io/ui/components/atoms/button';
4
+ import { cn } from '@vendure-io/ui/lib/utils';
5
+ import { FileIcon, UploadCloudIcon, XIcon } from 'lucide-react';
6
+ import * as React from 'react';
7
+
8
+ type FileValidationResult = string | readonly string[] | null | undefined;
9
+ type FileValidator = (file: File) => FileValidationResult | Promise<FileValidationResult>;
10
+
11
+ interface FileRejection {
12
+ file: File;
13
+ messages: string[];
14
+ }
15
+
16
+ interface FileDropzoneProps extends Omit<React.ComponentProps<'div'>, 'onChange'> {
17
+ value?: readonly File[];
18
+ onValueChange?: (files: File[]) => void;
19
+ onRejected?: (rejections: FileRejection[]) => void;
20
+ accept?: string;
21
+ multiple?: boolean;
22
+ maxFiles?: number;
23
+ maxSize?: number;
24
+ validateFile?: FileValidator;
25
+ disabled?: boolean;
26
+ required?: boolean;
27
+ name?: string;
28
+ id?: string;
29
+ label?: React.ReactNode;
30
+ description?: React.ReactNode;
31
+ emptyLabel?: React.ReactNode;
32
+ dragLabel?: React.ReactNode;
33
+ renderFile?: (file: File, remove: () => void) => React.ReactNode;
34
+ }
35
+
36
+ function fileMatchesAccept(file: File, accept: string | undefined): boolean {
37
+ if (!accept?.trim()) return true;
38
+ const fileName = file.name.toLowerCase();
39
+ const mime = file.type.toLowerCase();
40
+ return accept.split(',').some((rawRule) => {
41
+ const rule = rawRule.trim().toLowerCase();
42
+ if (!rule) return false;
43
+ if (rule.startsWith('.')) return fileName.endsWith(rule);
44
+ if (rule.endsWith('/*')) return mime.startsWith(rule.slice(0, -1));
45
+ return mime === rule;
46
+ });
47
+ }
48
+
49
+ function formatFileSize(bytes: number): string {
50
+ if (bytes < 1024) return `${bytes} B`;
51
+ if (bytes < 1024 ** 2) return `${Math.round(bytes / 1024)} KB`;
52
+ return `${(bytes / 1024 ** 2).toFixed(1)} MB`;
53
+ }
54
+
55
+ function normalizeValidationResult(result: FileValidationResult): string[] {
56
+ if (!result) return [];
57
+ return typeof result === 'string' ? [result] : [...result];
58
+ }
59
+
60
+ /**
61
+ * Controlled, transport-agnostic file input. It owns accessible picking,
62
+ * drag-and-drop, limits, validation, errors, and removal; consumers own upload
63
+ * persistence and can replace the selected-file rendering with `renderFile`.
64
+ */
65
+ function FileDropzone({
66
+ value = [],
67
+ onValueChange,
68
+ onRejected,
69
+ accept,
70
+ multiple = false,
71
+ maxFiles = multiple ? Number.POSITIVE_INFINITY : 1,
72
+ maxSize,
73
+ validateFile,
74
+ disabled,
75
+ required,
76
+ name,
77
+ id: providedId,
78
+ label = 'Upload files',
79
+ description,
80
+ emptyLabel = 'Drag and drop files here, or choose files',
81
+ dragLabel = 'Drop files to add them',
82
+ renderFile,
83
+ className,
84
+ ...props
85
+ }: FileDropzoneProps) {
86
+ const generatedId = React.useId();
87
+ const id = providedId ?? generatedId;
88
+ const descriptionId = `${id}-description`;
89
+ const errorId = `${id}-error`;
90
+ const [dragging, setDragging] = React.useState(false);
91
+ const [validating, setValidating] = React.useState(false);
92
+ const [rejections, setRejections] = React.useState<FileRejection[]>([]);
93
+ const dragDepth = React.useRef(0);
94
+ // Synchronous mirror of `validating`: a drop while an async validateFile is
95
+ // in flight would otherwise start a second addFiles against a stale `value`.
96
+ const busy = React.useRef(false);
97
+
98
+ async function addFiles(incoming: readonly File[]) {
99
+ if (disabled || busy.current || incoming.length === 0) return;
100
+ busy.current = true;
101
+ setValidating(true);
102
+ const accepted: File[] = [];
103
+ const rejected: FileRejection[] = [];
104
+ const remaining = Math.max(0, maxFiles - (multiple ? value.length : 0));
105
+
106
+ for (const file of incoming.slice(0, remaining)) {
107
+ const messages: string[] = [];
108
+ if (!fileMatchesAccept(file, accept)) messages.push('This file type is not accepted.');
109
+ if (maxSize !== undefined && file.size > maxSize) {
110
+ messages.push(`File size must be ${formatFileSize(maxSize)} or smaller.`);
111
+ }
112
+ if (validateFile) {
113
+ try {
114
+ messages.push(...normalizeValidationResult(await validateFile(file)));
115
+ } catch {
116
+ messages.push('This file could not be validated.');
117
+ }
118
+ }
119
+ if (messages.length > 0) rejected.push({ file, messages });
120
+ else accepted.push(file);
121
+ }
122
+
123
+ if (incoming.length > remaining) {
124
+ for (const file of incoming.slice(remaining)) {
125
+ rejected.push({
126
+ file,
127
+ messages: [`You can select up to ${maxFiles} ${maxFiles === 1 ? 'file' : 'files'}.`],
128
+ });
129
+ }
130
+ }
131
+
132
+ setRejections(rejected);
133
+ busy.current = false;
134
+ setValidating(false);
135
+ if (rejected.length > 0) onRejected?.(rejected);
136
+ if (accepted.length > 0) {
137
+ onValueChange?.(multiple ? [...value, ...accepted] : accepted.slice(0, 1));
138
+ }
139
+ }
140
+
141
+ function removeFile(index: number) {
142
+ onValueChange?.(value.filter((_, fileIndex) => fileIndex !== index));
143
+ setRejections([]);
144
+ }
145
+
146
+ return (
147
+ <div data-slot="file-dropzone" className={cn('flex flex-col gap-3', className)} {...props}>
148
+ <div>
149
+ <label htmlFor={id} className="text-sm font-medium">
150
+ {label}
151
+ {required ? <span className="text-destructive"> *</span> : null}
152
+ </label>
153
+ {description ? (
154
+ <p id={descriptionId} className="text-muted-foreground mt-1 text-sm">
155
+ {description}
156
+ </p>
157
+ ) : null}
158
+ </div>
159
+
160
+ <input
161
+ id={id}
162
+ name={name}
163
+ type="file"
164
+ accept={accept}
165
+ multiple={multiple}
166
+ required={required && value.length === 0}
167
+ disabled={disabled || validating}
168
+ aria-describedby={
169
+ cn(description && descriptionId, rejections.length > 0 && errorId) || undefined
170
+ }
171
+ className="peer sr-only"
172
+ onChange={(event) => {
173
+ const files = Array.from(event.currentTarget.files ?? []);
174
+ event.currentTarget.value = '';
175
+ void addFiles(files);
176
+ }}
177
+ />
178
+
179
+ <label
180
+ htmlFor={id}
181
+ data-slot="file-dropzone-target"
182
+ data-dragging={dragging || undefined}
183
+ data-disabled={disabled || validating || undefined}
184
+ onDragEnter={(event) => {
185
+ event.preventDefault();
186
+ if (disabled) return;
187
+ dragDepth.current += 1;
188
+ setDragging(true);
189
+ }}
190
+ onDragOver={(event) => {
191
+ event.preventDefault();
192
+ if (event.dataTransfer) event.dataTransfer.dropEffect = 'copy';
193
+ }}
194
+ onDragLeave={(event) => {
195
+ event.preventDefault();
196
+ dragDepth.current = Math.max(0, dragDepth.current - 1);
197
+ if (dragDepth.current === 0) setDragging(false);
198
+ }}
199
+ onDrop={(event) => {
200
+ event.preventDefault();
201
+ dragDepth.current = 0;
202
+ setDragging(false);
203
+ void addFiles(Array.from(event.dataTransfer.files));
204
+ }}
205
+ className={cn(
206
+ 'border-border text-muted-foreground hover:border-foreground/40 flex min-h-32 cursor-pointer flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed px-6 py-8 text-center transition-[border-color,background-color,color] duration-(--transition-duration-fast) ease-(--ease-out)',
207
+ 'peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-ring/50',
208
+ 'data-dragging:border-foreground data-dragging:bg-accent data-dragging:text-accent-foreground',
209
+ 'data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50',
210
+ )}
211
+ >
212
+ <UploadCloudIcon className="size-7" />
213
+ <span className="text-foreground text-sm font-medium">
214
+ {validating ? 'Checking files…' : dragging ? dragLabel : emptyLabel}
215
+ </span>
216
+ {accept ? <span className="text-xs">Accepted: {accept}</span> : null}
217
+ </label>
218
+
219
+ {value.length > 0 ? (
220
+ <ul data-slot="file-dropzone-files" className="flex flex-col gap-2">
221
+ {value.map((file, index) => (
222
+ // Metadata alone can collide (two distinct files with identical
223
+ // name, size and mtime), so the index disambiguates the key.
224
+ <li key={`${file.name}-${file.size}-${file.lastModified}-${index}`}>
225
+ {renderFile ? (
226
+ renderFile(file, () => removeFile(index))
227
+ ) : (
228
+ <div className="bg-muted/60 flex min-w-0 items-center gap-3 rounded-lg border px-3 py-2">
229
+ <FileIcon className="text-muted-foreground size-4 shrink-0" />
230
+ <div className="min-w-0 flex-1">
231
+ <p className="truncate text-sm font-medium">{file.name}</p>
232
+ <p className="text-muted-foreground text-xs">{formatFileSize(file.size)}</p>
233
+ </div>
234
+ <Button
235
+ type="button"
236
+ variant="ghost"
237
+ size="icon-xs"
238
+ disabled={disabled}
239
+ aria-label={`Remove ${file.name}`}
240
+ onClick={() => removeFile(index)}
241
+ >
242
+ <XIcon />
243
+ </Button>
244
+ </div>
245
+ )}
246
+ </li>
247
+ ))}
248
+ </ul>
249
+ ) : null}
250
+
251
+ {rejections.length > 0 ? (
252
+ <div id={errorId} role="alert" className="text-destructive text-sm">
253
+ {rejections.map(({ file, messages }, index) => (
254
+ <p key={`${file.name}-${file.size}-${index}`}>
255
+ <span className="font-medium">{file.name}:</span> {messages.join(' ')}
256
+ </p>
257
+ ))}
258
+ </div>
259
+ ) : null}
260
+ </div>
261
+ );
262
+ }
263
+
264
+ export {
265
+ FileDropzone,
266
+ fileMatchesAccept,
267
+ formatFileSize,
268
+ type FileDropzoneProps,
269
+ type FileRejection,
270
+ type FileValidator,
271
+ };
@@ -40,7 +40,7 @@ interface IdChipProps {
40
40
  /** Render the copy affordance. @default true */
41
41
  copyable?: boolean;
42
42
  className?: string;
43
- /** Called after a successful copy. Wire your toast here — the DS never toasts. */
43
+ /** Called after a successful copy. Wire your toast here — the DS never toasts. Falls back to `CopyFeedbackProvider`. */
44
44
  onCopied?: () => void;
45
45
  }
46
46
 
@@ -6,12 +6,16 @@ import type * as React from 'react';
6
6
  // header and lets variance in the wild (back links, badge rows beside the title,
7
7
  // mono subtitles) live as free children rather than as an ever-growing prop set.
8
8
 
9
- /** The header row: title/description on the left, actions on the right. */
9
+ /**
10
+ * The header row: title/description on the left, actions on the right. The row
11
+ * wraps, so on a narrow screen the actions move below the title instead of
12
+ * squeezing it.
13
+ */
10
14
  function PageHeader({ className, ...props }: React.ComponentProps<'header'>) {
11
15
  return (
12
16
  <header
13
17
  data-slot="page-header"
14
- className={cn('flex items-start justify-between gap-4', className)}
18
+ className={cn('flex flex-wrap items-start justify-between gap-4', className)}
15
19
  {...props}
16
20
  />
17
21
  );
@@ -48,7 +52,7 @@ function PageHeaderDescription({ className, ...props }: React.ComponentProps<'p'
48
52
  );
49
53
  }
50
54
 
51
- /** Right-hand action slot (buttons, menus). Stays put as the title wraps. */
55
+ /** Right-hand action slot (buttons, menus). Moves below the title when the row has no room. */
52
56
  function PageHeaderActions({ className, ...props }: React.ComponentProps<'div'>) {
53
57
  return (
54
58
  <div
@@ -0,0 +1,36 @@
1
+ import { cn } from '@vendure-io/ui/lib/utils';
2
+ import type * as React from 'react';
3
+
4
+ interface SkipLinkProps extends React.ComponentProps<'a'> {
5
+ /** The main-content element to focus. Include the leading `#`. */
6
+ href?: `#${string}`;
7
+ }
8
+
9
+ /**
10
+ * Keyboard-only escape hatch for repeated application chrome. Place it as the
11
+ * first focusable element in the document and point it at `AppShellMain` (whose
12
+ * default id is `main-content`). Native anchor behavior keeps this server-safe
13
+ * and works before React hydrates.
14
+ */
15
+ function SkipLink({
16
+ className,
17
+ href = '#main-content',
18
+ children = 'Skip to main content',
19
+ ...props
20
+ }: SkipLinkProps) {
21
+ return (
22
+ <a
23
+ data-slot="skip-link"
24
+ href={href}
25
+ className={cn(
26
+ 'bg-primary text-primary-foreground fixed top-3 left-3 z-[100] -translate-y-20 rounded-md px-3 py-2 text-sm font-medium opacity-0 outline-none transition-[transform,opacity] duration-(--transition-duration-fast) ease-(--ease-out) focus-visible:translate-y-0 focus-visible:opacity-100 focus-visible:ring-3 focus-visible:ring-ring/50 motion-reduce:transition-none',
27
+ className,
28
+ )}
29
+ {...props}
30
+ >
31
+ {children}
32
+ </a>
33
+ );
34
+ }
35
+
36
+ export { SkipLink, type SkipLinkProps };
@@ -25,6 +25,12 @@ export interface EmptyStateProps extends Omit<React.ComponentProps<typeof Empty>
25
25
  description?: React.ReactNode;
26
26
  /** Actions/CTA — rendered in the content slot below the header. */
27
27
  children?: React.ReactNode;
28
+ /**
29
+ * Draw the dashed box. Defaults to `true`. Set `false` when the empty state
30
+ * fills a region that already has a frame, such as a table body: the table
31
+ * owns its perimeter.
32
+ */
33
+ bordered?: boolean;
28
34
  }
29
35
 
30
36
  /**
@@ -42,6 +48,7 @@ function EmptyState({
42
48
  title,
43
49
  description,
44
50
  children,
51
+ bordered = true,
45
52
  className,
46
53
  ...props
47
54
  }: EmptyStateProps) {
@@ -57,7 +64,11 @@ function EmptyState({
57
64
  ) : null;
58
65
 
59
66
  return (
60
- <Empty data-slot="empty-state" className={cn('border', className)} {...props}>
67
+ <Empty
68
+ data-slot="empty-state"
69
+ className={cn(bordered ? 'border' : 'rounded-none', className)}
70
+ {...props}
71
+ >
61
72
  <EmptyHeader>
62
73
  {resolvedIllustration ? (
63
74
  <EmptyMedia>{resolvedIllustration}</EmptyMedia>