@vendure-io/ui 3.0.0-next.5 → 3.0.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/atoms/breadcrumb.tsx +31 -11
- package/src/components/atoms/carousel.tsx +33 -7
- package/src/components/atoms/combobox.tsx +23 -10
- package/src/components/atoms/command.tsx +14 -4
- package/src/components/atoms/pagination.tsx +43 -12
- package/src/components/atoms/sidebar.tsx +24 -5
- package/src/components/atoms/spinner.tsx +7 -2
- package/src/components/molecules/anonymized-token.tsx +19 -18
- package/src/components/molecules/app-shell.tsx +14 -5
- package/src/components/molecules/checklist/checklist.tsx +47 -17
- package/src/components/molecules/choice-card.tsx +3 -0
- package/src/components/molecules/confirm-dialog.tsx +6 -4
- package/src/components/molecules/data-table/data-table-filters.tsx +25 -7
- package/src/components/molecules/data-table/data-table-types.tsx +33 -16
- package/src/components/molecules/data-table/data-table-view-options.tsx +14 -4
- package/src/components/molecules/data-table/data-table.tsx +47 -26
- package/src/components/molecules/data-table/table-pagination.tsx +51 -29
- package/src/components/molecules/date-picker.tsx +4 -2
- package/src/components/molecules/date-range-picker.tsx +6 -2
- package/src/components/molecules/date-time-picker.tsx +4 -2
- package/src/components/molecules/file-dropzone.tsx +16 -5
- package/src/components/molecules/id-chip.tsx +10 -8
- package/src/components/molecules/issued-secret.tsx +34 -24
- package/src/components/molecules/multi-select.tsx +6 -2
- package/src/components/molecules/secret-value.tsx +26 -18
- package/src/components/molecules/skip-link.tsx +11 -9
- package/src/components/molecules/stat-card.tsx +2 -0
- package/src/components/molecules/state-views/error-state.tsx +18 -6
- package/src/components/molecules/state-views/loading-state.tsx +2 -0
- package/src/lib/format-messages.ts +176 -0
|
@@ -31,6 +31,7 @@ interface DatePickerProps extends Omit<React.ComponentProps<'div'>, 'defaultValu
|
|
|
31
31
|
onValueChange?: (value: string | undefined) => void;
|
|
32
32
|
min?: string;
|
|
33
33
|
max?: string;
|
|
34
|
+
/** @default `messages.datePicker.placeholder`, "Pick a date" */
|
|
34
35
|
placeholder?: React.ReactNode;
|
|
35
36
|
clearable?: boolean;
|
|
36
37
|
disabled?: boolean;
|
|
@@ -52,7 +53,7 @@ function DatePicker(allProps: DatePickerProps) {
|
|
|
52
53
|
onValueChange,
|
|
53
54
|
min,
|
|
54
55
|
max,
|
|
55
|
-
placeholder
|
|
56
|
+
placeholder,
|
|
56
57
|
clearable = true,
|
|
57
58
|
disabled,
|
|
58
59
|
invalid,
|
|
@@ -78,6 +79,7 @@ function DatePicker(allProps: DatePickerProps) {
|
|
|
78
79
|
const triggerId = id ?? generatedId;
|
|
79
80
|
const { locale } = useFormatSettings();
|
|
80
81
|
const t = useMessages('datePicker', { clear: clearLabel });
|
|
82
|
+
const placeholderText = placeholder !== undefined ? placeholder : t.placeholder;
|
|
81
83
|
const selected = parseCalendarDate(value);
|
|
82
84
|
const minDate = parseCalendarDate(min);
|
|
83
85
|
const maxDate = parseCalendarDate(max);
|
|
@@ -114,7 +116,7 @@ function DatePicker(allProps: DatePickerProps) {
|
|
|
114
116
|
data-placeholder={selected ? undefined : ''}
|
|
115
117
|
className={cn('truncate', !selected && 'text-faint-foreground')}
|
|
116
118
|
>
|
|
117
|
-
{selected ? formatDateLabel(selected, locale) :
|
|
119
|
+
{selected ? formatDateLabel(selected, locale) : placeholderText}
|
|
118
120
|
</span>
|
|
119
121
|
</PopoverTrigger>
|
|
120
122
|
<PopoverContent
|
|
@@ -42,6 +42,7 @@ interface DateRangePickerProps
|
|
|
42
42
|
/** Initial range when `value` is not passed. */
|
|
43
43
|
defaultValue?: DateRangeValue;
|
|
44
44
|
onValueChange?: (value: DateRangeValue | undefined) => void;
|
|
45
|
+
/** @default `messages.dateRangePicker.placeholder`, "Pick a date range" */
|
|
45
46
|
placeholder?: React.ReactNode;
|
|
46
47
|
clearable?: boolean;
|
|
47
48
|
disabled?: boolean;
|
|
@@ -63,7 +64,7 @@ function DateRangePicker(allProps: DateRangePickerProps) {
|
|
|
63
64
|
value: valueProp,
|
|
64
65
|
defaultValue,
|
|
65
66
|
onValueChange,
|
|
66
|
-
placeholder
|
|
67
|
+
placeholder,
|
|
67
68
|
clearable = true,
|
|
68
69
|
disabled,
|
|
69
70
|
invalid,
|
|
@@ -88,6 +89,7 @@ function DateRangePicker(allProps: DateRangePickerProps) {
|
|
|
88
89
|
const triggerId = generatedId;
|
|
89
90
|
const { locale } = useFormatSettings();
|
|
90
91
|
const t = useMessages('dateRangePicker', { clear: clearLabel });
|
|
92
|
+
const placeholderText = placeholder !== undefined ? placeholder : t.placeholder;
|
|
91
93
|
const selected: DateRange = {
|
|
92
94
|
from: parseCalendarDate(value?.from),
|
|
93
95
|
to: parseCalendarDate(value?.to),
|
|
@@ -132,7 +134,9 @@ function DateRangePicker(allProps: DateRangePickerProps) {
|
|
|
132
134
|
data-placeholder={hasValue ? undefined : ''}
|
|
133
135
|
className={cn('truncate', !hasValue && 'text-faint-foreground')}
|
|
134
136
|
>
|
|
135
|
-
{selected.from
|
|
137
|
+
{selected.from
|
|
138
|
+
? formatDateRangeLabel(selected.from, selected.to, locale)
|
|
139
|
+
: placeholderText}
|
|
136
140
|
</span>
|
|
137
141
|
</PopoverTrigger>
|
|
138
142
|
<PopoverContent
|
|
@@ -28,6 +28,7 @@ interface DateTimePickerProps
|
|
|
28
28
|
/** Initial instant when `value` is not passed. */
|
|
29
29
|
defaultValue?: string;
|
|
30
30
|
onValueChange?: (value: string | undefined) => void;
|
|
31
|
+
/** @default `messages.dateTimePicker.placeholder`, "Pick a date and time" */
|
|
31
32
|
placeholder?: React.ReactNode;
|
|
32
33
|
clearable?: boolean;
|
|
33
34
|
disabled?: boolean;
|
|
@@ -48,7 +49,7 @@ function DateTimePicker(allProps: DateTimePickerProps) {
|
|
|
48
49
|
value: valueProp,
|
|
49
50
|
defaultValue,
|
|
50
51
|
onValueChange,
|
|
51
|
-
placeholder
|
|
52
|
+
placeholder,
|
|
52
53
|
clearable = true,
|
|
53
54
|
disabled,
|
|
54
55
|
invalid,
|
|
@@ -75,6 +76,7 @@ function DateTimePicker(allProps: DateTimePickerProps) {
|
|
|
75
76
|
const triggerId = id ?? generatedId;
|
|
76
77
|
const { locale } = useFormatSettings();
|
|
77
78
|
const t = useMessages('dateTimePicker', { clear: clearLabel, time: timeLabel });
|
|
79
|
+
const placeholderText = placeholder !== undefined ? placeholder : t.placeholder;
|
|
78
80
|
const selected = parseInstant(value);
|
|
79
81
|
const timeValue = selected
|
|
80
82
|
? `${String(selected.getHours()).padStart(2, '0')}:${String(selected.getMinutes()).padStart(2, '0')}`
|
|
@@ -127,7 +129,7 @@ function DateTimePicker(allProps: DateTimePickerProps) {
|
|
|
127
129
|
data-placeholder={selected ? undefined : ''}
|
|
128
130
|
className={cn('truncate', !selected && 'text-faint-foreground')}
|
|
129
131
|
>
|
|
130
|
-
{selected ? formatDateLabel(selected, locale) :
|
|
132
|
+
{selected ? formatDateLabel(selected, locale) : placeholderText}
|
|
131
133
|
</span>
|
|
132
134
|
</PopoverTrigger>
|
|
133
135
|
<PopoverContent
|
|
@@ -60,9 +60,12 @@ interface FileDropzoneProps extends Omit<React.ComponentProps<'div'>, 'defaultVa
|
|
|
60
60
|
required?: boolean;
|
|
61
61
|
name?: string;
|
|
62
62
|
id?: string;
|
|
63
|
+
/** @default `messages.fileDropzone.label`, "Upload files" */
|
|
63
64
|
label?: React.ReactNode;
|
|
64
65
|
description?: React.ReactNode;
|
|
66
|
+
/** @default `messages.fileDropzone.empty`, "Drag and drop files here, or choose files" */
|
|
65
67
|
emptyLabel?: React.ReactNode;
|
|
68
|
+
/** @default `messages.fileDropzone.drag`, "Drop files to add them" */
|
|
66
69
|
dragLabel?: React.ReactNode;
|
|
67
70
|
renderFile?: (file: File, remove: () => void) => React.ReactNode;
|
|
68
71
|
/** The component's own texts: rejection messages, status text, remove button and size units. */
|
|
@@ -142,10 +145,10 @@ function FileDropzone(allProps: FileDropzoneProps) {
|
|
|
142
145
|
required,
|
|
143
146
|
name,
|
|
144
147
|
id: providedId,
|
|
145
|
-
label
|
|
148
|
+
label,
|
|
146
149
|
description,
|
|
147
|
-
emptyLabel
|
|
148
|
-
dragLabel
|
|
150
|
+
emptyLabel,
|
|
151
|
+
dragLabel,
|
|
149
152
|
renderFile,
|
|
150
153
|
labels,
|
|
151
154
|
className,
|
|
@@ -241,7 +244,7 @@ function FileDropzone(allProps: FileDropzoneProps) {
|
|
|
241
244
|
<div data-slot="file-dropzone" className={cn('flex flex-col gap-3', className)} {...props}>
|
|
242
245
|
<div>
|
|
243
246
|
<label htmlFor={id} className="text-sm font-medium">
|
|
244
|
-
{label}
|
|
247
|
+
{label !== undefined ? label : t.label}
|
|
245
248
|
{required ? <span className="text-destructive-text"> *</span> : null}
|
|
246
249
|
</label>
|
|
247
250
|
{description ? (
|
|
@@ -305,7 +308,15 @@ function FileDropzone(allProps: FileDropzoneProps) {
|
|
|
305
308
|
>
|
|
306
309
|
<UploadCloudIcon className="size-7" />
|
|
307
310
|
<span className="text-foreground text-sm font-medium">
|
|
308
|
-
{validating
|
|
311
|
+
{validating
|
|
312
|
+
? t.checking
|
|
313
|
+
: dragging
|
|
314
|
+
? dragLabel !== undefined
|
|
315
|
+
? dragLabel
|
|
316
|
+
: t.drag
|
|
317
|
+
: emptyLabel !== undefined
|
|
318
|
+
? emptyLabel
|
|
319
|
+
: t.empty}
|
|
309
320
|
</span>
|
|
310
321
|
{accept ? <span className="text-xs">{`${t.accepted} ${accept}`}</span> : null}
|
|
311
322
|
</label>
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@vendure-io/ui/components/atoms/tooltip';
|
|
4
4
|
import { CopyButton, useCopyAction } from '@vendure-io/ui/components/molecules/copyable-text';
|
|
5
5
|
import { cn } from '@vendure-io/ui/lib/utils';
|
|
6
|
+
import { useMessages } from '../../lib/format-messages.ts';
|
|
6
7
|
import { ChipCopyTooltip, chipChromeClass, chipCopyButtonProps } from './id-chip-chrome.tsx';
|
|
7
8
|
|
|
8
9
|
type TruncateMode = 'middle' | 'start' | 'none';
|
|
@@ -58,10 +59,10 @@ interface IdChipProps {
|
|
|
58
59
|
* The tooltip text before copying, e.g. "Copy commit". Keep it short and
|
|
59
60
|
* leave the value out: the copy button's accessible name adds the shown
|
|
60
61
|
* text itself ("Copy commit 9f2c4e1"), so each button in a list has its own
|
|
61
|
-
* name. @default "Copy"
|
|
62
|
+
* name. @default `messages.idChip.copy`, "Copy"
|
|
62
63
|
*/
|
|
63
64
|
copyLabel?: string;
|
|
64
|
-
/** The tooltip text and the copy button's accessible name while the copied state is active. @default "Copied" */
|
|
65
|
+
/** The tooltip text and the copy button's accessible name while the copied state is active. @default `messages.idChip.copied`, "Copied" */
|
|
65
66
|
copiedLabel?: string;
|
|
66
67
|
/** How long the check-mark feedback stays visible, in ms. @default 2000 */
|
|
67
68
|
timeout?: number;
|
|
@@ -82,11 +83,12 @@ function IdChip({
|
|
|
82
83
|
className,
|
|
83
84
|
onCopied,
|
|
84
85
|
onCopyError,
|
|
85
|
-
copyLabel
|
|
86
|
-
copiedLabel
|
|
86
|
+
copyLabel,
|
|
87
|
+
copiedLabel,
|
|
87
88
|
timeout,
|
|
88
89
|
}: IdChipProps) {
|
|
89
90
|
const action = useCopyAction({ timeout, onCopied, onCopyError });
|
|
91
|
+
const t = useMessages('idChip', { copy: copyLabel, copied: copiedLabel });
|
|
90
92
|
const text = display ?? truncateId(value, truncate);
|
|
91
93
|
const shortened = text !== value;
|
|
92
94
|
const chip = (
|
|
@@ -103,8 +105,8 @@ function IdChip({
|
|
|
103
105
|
<CopyButton
|
|
104
106
|
value={value}
|
|
105
107
|
copyAction={action}
|
|
106
|
-
copyLabel={`${
|
|
107
|
-
copiedLabel={
|
|
108
|
+
copyLabel={`${t.copy} ${text}`}
|
|
109
|
+
copiedLabel={t.copied}
|
|
108
110
|
{...chipCopyButtonProps}
|
|
109
111
|
/>
|
|
110
112
|
) : null}
|
|
@@ -118,8 +120,8 @@ function IdChip({
|
|
|
118
120
|
<ChipCopyTooltip
|
|
119
121
|
chip={chip}
|
|
120
122
|
copied={action.copied}
|
|
121
|
-
copyLabel={
|
|
122
|
-
copiedLabel={
|
|
123
|
+
copyLabel={t.copy}
|
|
124
|
+
copiedLabel={t.copied}
|
|
123
125
|
/>
|
|
124
126
|
);
|
|
125
127
|
}
|
|
@@ -9,6 +9,7 @@ import { CopyStateIcon, useCopyAction } from '@vendure-io/ui/components/molecule
|
|
|
9
9
|
import { cn } from '@vendure-io/ui/lib/utils';
|
|
10
10
|
import type * as React from 'react';
|
|
11
11
|
import { useEffect, useId, useRef, useState } from 'react';
|
|
12
|
+
import { fillMessage, useMessages } from '../../lib/format-messages.ts';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* The close guard of a dialog that holds a secret that was just issued. Before
|
|
@@ -61,21 +62,21 @@ interface IssuedSecretOwnProps {
|
|
|
61
62
|
name?: React.ReactNode;
|
|
62
63
|
/** Values of the issue that are not secret, for example a sign-in name. */
|
|
63
64
|
children?: React.ReactNode;
|
|
64
|
-
/** Text of the copy button when there is one value. @default `Copy
|
|
65
|
+
/** Text of the copy button when there is one value. @default `messages.issuedSecret.copy`, "Copy {secret}", with `{secret}` the `secretName` */
|
|
65
66
|
copyLabel?: string;
|
|
66
|
-
/** Text of a copy button just after a copy. @default "Copied" */
|
|
67
|
+
/** Text of a copy button just after a copy. @default `messages.issuedSecret.copied`, "Copied" */
|
|
67
68
|
copiedLabel?: string;
|
|
68
|
-
/** The line under the buttons. @default `You can copy the
|
|
69
|
+
/** The line under the buttons. @default `messages.issuedSecret.notice`, "You can copy the {secret} only now." */
|
|
69
70
|
notice?: React.ReactNode;
|
|
70
71
|
/** Label of the field that shows the value when the clipboard fails. @default secretName, capitalised */
|
|
71
72
|
fallbackLabel?: string;
|
|
72
|
-
/** @default `The clipboard is not available. Select the
|
|
73
|
+
/** @default `messages.issuedSecret.fallbackDescription`, "The clipboard is not available. Select the {secret} and copy it by hand." */
|
|
73
74
|
fallbackDescription?: React.ReactNode;
|
|
74
75
|
/** Classes for that field, for example a session replay mask class. */
|
|
75
76
|
fallbackInputClassName?: string;
|
|
76
|
-
/** @default `The
|
|
77
|
+
/** @default `messages.issuedSecret.warningTitle`, "The {secret} is not copied" */
|
|
77
78
|
warningTitle?: React.ReactNode;
|
|
78
|
-
/** @default "You cannot copy it after you close. Copy it now, or close without copying." */
|
|
79
|
+
/** @default `messages.issuedSecret.warningDescription`, "You cannot copy it after you close. Copy it now, or close without copying." */
|
|
79
80
|
warningDescription?: React.ReactNode;
|
|
80
81
|
/** Called after a copy by a button. Falls back to `CopyFeedbackProvider`. */
|
|
81
82
|
onCopied?: () => void;
|
|
@@ -112,25 +113,27 @@ function IssuedSecret({
|
|
|
112
113
|
children,
|
|
113
114
|
value,
|
|
114
115
|
formats,
|
|
115
|
-
copyLabel
|
|
116
|
-
copiedLabel
|
|
117
|
-
notice
|
|
116
|
+
copyLabel,
|
|
117
|
+
copiedLabel,
|
|
118
|
+
notice,
|
|
118
119
|
fallbackLabel = capitalize(secretName),
|
|
119
|
-
fallbackDescription
|
|
120
|
+
fallbackDescription,
|
|
120
121
|
fallbackInputClassName,
|
|
121
|
-
warningTitle
|
|
122
|
-
warningDescription
|
|
122
|
+
warningTitle,
|
|
123
|
+
warningDescription,
|
|
123
124
|
onCopied,
|
|
124
125
|
onCopyError,
|
|
125
126
|
className,
|
|
126
127
|
...props
|
|
127
128
|
}: IssuedSecretProps) {
|
|
129
|
+
const t = useMessages('issuedSecret', { copy: copyLabel, copied: copiedLabel });
|
|
130
|
+
const named = (text: string) => fillMessage(text, { secret: secretName });
|
|
128
131
|
// The text of the copy the clipboard refused. It contains the secret.
|
|
129
132
|
const [manual, setManual] = useState<string | null>(null);
|
|
130
133
|
const firstButton = useRef<HTMLButtonElement>(null);
|
|
131
134
|
const field = useRef<HTMLInputElement>(null);
|
|
132
135
|
const fieldId = useId();
|
|
133
|
-
const buttons = formats ?? [{ label:
|
|
136
|
+
const buttons = formats ?? [{ label: named(t.copy), value: value ?? '' }];
|
|
134
137
|
|
|
135
138
|
useEffect(() => {
|
|
136
139
|
firstButton.current?.focus();
|
|
@@ -172,7 +175,7 @@ function IssuedSecret({
|
|
|
172
175
|
key={format.label}
|
|
173
176
|
ref={index === 0 ? firstButton : undefined}
|
|
174
177
|
format={format}
|
|
175
|
-
copiedLabel={
|
|
178
|
+
copiedLabel={t.copied}
|
|
176
179
|
// One primary until the first copy; then Done takes it.
|
|
177
180
|
variant={index === 0 && !guard.copied ? 'default' : 'outline'}
|
|
178
181
|
onCopied={() => {
|
|
@@ -185,7 +188,7 @@ function IssuedSecret({
|
|
|
185
188
|
/>
|
|
186
189
|
))}
|
|
187
190
|
<p data-slot="issued-secret-notice" className="text-muted-foreground text-xs">
|
|
188
|
-
{notice}
|
|
191
|
+
{notice !== undefined ? notice : named(t.notice)}
|
|
189
192
|
</p>
|
|
190
193
|
</div>
|
|
191
194
|
{manual !== null ? (
|
|
@@ -202,13 +205,19 @@ function IssuedSecret({
|
|
|
202
205
|
onFocus={(event) => event.currentTarget.select()}
|
|
203
206
|
onCopy={guard.markCopied}
|
|
204
207
|
/>
|
|
205
|
-
<FieldDescription>
|
|
208
|
+
<FieldDescription>
|
|
209
|
+
{fallbackDescription !== undefined ? fallbackDescription : named(t.fallbackDescription)}
|
|
210
|
+
</FieldDescription>
|
|
206
211
|
</Field>
|
|
207
212
|
) : null}
|
|
208
213
|
{guard.warned ? (
|
|
209
214
|
<Alert data-slot="issued-secret-warning" tone="warning">
|
|
210
|
-
<AlertTitle>
|
|
211
|
-
|
|
215
|
+
<AlertTitle>
|
|
216
|
+
{warningTitle !== undefined ? warningTitle : named(t.warningTitle)}
|
|
217
|
+
</AlertTitle>
|
|
218
|
+
<AlertDescription>
|
|
219
|
+
{warningDescription !== undefined ? warningDescription : t.warningDescription}
|
|
220
|
+
</AlertDescription>
|
|
212
221
|
</Alert>
|
|
213
222
|
) : null}
|
|
214
223
|
</section>
|
|
@@ -266,9 +275,9 @@ interface IssuedSecretFooterProps
|
|
|
266
275
|
extends Omit<React.ComponentProps<typeof DialogFooter>, 'children'> {
|
|
267
276
|
/** The guard from `useIssuedSecretGuard`, shared with `IssuedSecret`. */
|
|
268
277
|
guard: IssuedSecretGuard;
|
|
269
|
-
/** @default "Done" */
|
|
278
|
+
/** @default `messages.issuedSecret.done`, "Done" */
|
|
270
279
|
doneLabel?: string;
|
|
271
|
-
/** The second action after the warning. @default "Close without copying" */
|
|
280
|
+
/** The second action after the warning. @default `messages.issuedSecret.closeAnyway`, "Close without copying" */
|
|
272
281
|
closeAnywayLabel?: string;
|
|
273
282
|
}
|
|
274
283
|
|
|
@@ -279,10 +288,11 @@ interface IssuedSecretFooterProps
|
|
|
279
288
|
*/
|
|
280
289
|
function IssuedSecretFooter({
|
|
281
290
|
guard,
|
|
282
|
-
doneLabel
|
|
283
|
-
closeAnywayLabel
|
|
291
|
+
doneLabel,
|
|
292
|
+
closeAnywayLabel,
|
|
284
293
|
...props
|
|
285
294
|
}: IssuedSecretFooterProps) {
|
|
295
|
+
const t = useMessages('issuedSecret', { done: doneLabel, closeAnyway: closeAnywayLabel });
|
|
286
296
|
return (
|
|
287
297
|
<DialogFooter data-slot="issued-secret-footer" {...props}>
|
|
288
298
|
{guard.warned ? (
|
|
@@ -293,7 +303,7 @@ function IssuedSecretFooter({
|
|
|
293
303
|
variant="destructive-outline"
|
|
294
304
|
onClick={guard.closeAnyway}
|
|
295
305
|
>
|
|
296
|
-
{
|
|
306
|
+
{t.closeAnyway}
|
|
297
307
|
</Button>
|
|
298
308
|
) : (
|
|
299
309
|
<Button
|
|
@@ -303,7 +313,7 @@ function IssuedSecretFooter({
|
|
|
303
313
|
variant={guard.copied ? 'default' : 'outline'}
|
|
304
314
|
onClick={guard.requestClose}
|
|
305
315
|
>
|
|
306
|
-
{
|
|
316
|
+
{t.done}
|
|
307
317
|
</Button>
|
|
308
318
|
)}
|
|
309
319
|
</DialogFooter>
|
|
@@ -60,7 +60,10 @@ export interface MultiSelectProps<T> {
|
|
|
60
60
|
defaultValue?: readonly ItemValue[];
|
|
61
61
|
/** Called with the next array of selected values whenever the selection changes. */
|
|
62
62
|
onValueChange?: (value: ItemValue[]) => void;
|
|
63
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Text shown in the trigger when nothing is selected.
|
|
65
|
+
* @default `messages.multiSelect.placeholder`, "Select…"
|
|
66
|
+
*/
|
|
64
67
|
placeholder?: React.ReactNode;
|
|
65
68
|
/**
|
|
66
69
|
* Override how the selected options are summarised in the trigger. Defaults
|
|
@@ -94,7 +97,7 @@ function MultiSelect<T>({
|
|
|
94
97
|
value,
|
|
95
98
|
defaultValue,
|
|
96
99
|
onValueChange,
|
|
97
|
-
placeholder
|
|
100
|
+
placeholder: placeholderProp,
|
|
98
101
|
renderValue,
|
|
99
102
|
disabled,
|
|
100
103
|
invalid,
|
|
@@ -116,6 +119,7 @@ function MultiSelect<T>({
|
|
|
116
119
|
);
|
|
117
120
|
|
|
118
121
|
const t = useMessages('multiSelect', { loading: loadingLabel });
|
|
122
|
+
const placeholder = placeholderProp !== undefined ? placeholderProp : t.placeholder;
|
|
119
123
|
const isLoading = items === undefined;
|
|
120
124
|
|
|
121
125
|
const itemByValue = React.useMemo(() => {
|
|
@@ -28,17 +28,17 @@ interface SecretValueProps extends Omit<React.ComponentProps<'span'>, 'children'
|
|
|
28
28
|
onCopied?: CopyButtonProps['onCopied'];
|
|
29
29
|
/** Called when the load or the clipboard write fails. Falls back to `CopyFeedbackProvider`. */
|
|
30
30
|
onCopyError?: CopyButtonProps['onCopyError'];
|
|
31
|
-
/** Accessible name while the value is masked. @default "Hidden value" */
|
|
31
|
+
/** Accessible name while the value is masked. @default `messages.secretValue.hidden`, "Hidden value" */
|
|
32
32
|
hiddenLabel?: string;
|
|
33
|
-
/** Accessible label of the reveal button. @default "Show value" */
|
|
33
|
+
/** Accessible label of the reveal button. @default `messages.secretValue.show`, "Show value" */
|
|
34
34
|
showLabel?: string;
|
|
35
|
-
/** Accessible label of the button that masks the value again. @default "Hide value" */
|
|
35
|
+
/** Accessible label of the button that masks the value again. @default `messages.secretValue.hide`, "Hide value" */
|
|
36
36
|
hideLabel?: string;
|
|
37
|
-
/** Accessible label before copying. @default "Copy value" */
|
|
37
|
+
/** Accessible label before copying. @default `messages.secretValue.copy`, "Copy value" */
|
|
38
38
|
copyLabel?: CopyButtonProps['copyLabel'];
|
|
39
|
-
/** Accessible label while the copied state is active. @default "Value copied" */
|
|
39
|
+
/** Accessible label while the copied state is active. @default `messages.secretValue.copied`, "Value copied" */
|
|
40
40
|
copiedLabel?: CopyButtonProps['copiedLabel'];
|
|
41
|
-
/** Shown inline when `loadValue` rejects. @default "Couldn't load the value." */
|
|
41
|
+
/** Shown inline when `loadValue` rejects. @default `messages.secretValue.loadError`, "Couldn't load the value." */
|
|
42
42
|
loadErrorMessage?: string;
|
|
43
43
|
/**
|
|
44
44
|
* Screen-reader text of the spinner while the value loads.
|
|
@@ -99,17 +99,25 @@ function SecretValue({
|
|
|
99
99
|
timeout,
|
|
100
100
|
onCopied,
|
|
101
101
|
onCopyError,
|
|
102
|
-
hiddenLabel
|
|
103
|
-
showLabel
|
|
104
|
-
hideLabel
|
|
105
|
-
copyLabel
|
|
106
|
-
copiedLabel
|
|
107
|
-
loadErrorMessage
|
|
102
|
+
hiddenLabel,
|
|
103
|
+
showLabel,
|
|
104
|
+
hideLabel,
|
|
105
|
+
copyLabel,
|
|
106
|
+
copiedLabel,
|
|
107
|
+
loadErrorMessage,
|
|
108
108
|
loadingLabel,
|
|
109
109
|
className,
|
|
110
110
|
...props
|
|
111
111
|
}: SecretValueProps) {
|
|
112
|
-
const t = useMessages('secretValue', {
|
|
112
|
+
const t = useMessages('secretValue', {
|
|
113
|
+
loading: loadingLabel,
|
|
114
|
+
hidden: hiddenLabel,
|
|
115
|
+
show: showLabel,
|
|
116
|
+
hide: hideLabel,
|
|
117
|
+
copy: copyLabel,
|
|
118
|
+
copied: copiedLabel,
|
|
119
|
+
loadError: loadErrorMessage,
|
|
120
|
+
});
|
|
113
121
|
const [state, dispatch] = useReducer(revealReducer, { status: 'hidden' });
|
|
114
122
|
// Drops a load that settles after the user hid the value or asked again.
|
|
115
123
|
const request = useRef(0);
|
|
@@ -161,7 +169,7 @@ function SecretValue({
|
|
|
161
169
|
<code data-slot="secret-value-value" dir="ltr" aria-hidden="true">
|
|
162
170
|
{MASK}
|
|
163
171
|
</code>
|
|
164
|
-
<span className="sr-only">{
|
|
172
|
+
<span className="sr-only">{t.hidden}</span>
|
|
165
173
|
</>
|
|
166
174
|
)}
|
|
167
175
|
<Button
|
|
@@ -169,7 +177,7 @@ function SecretValue({
|
|
|
169
177
|
data-slot="secret-value-reveal"
|
|
170
178
|
variant="ghost"
|
|
171
179
|
size="icon-xs"
|
|
172
|
-
aria-label={revealed ?
|
|
180
|
+
aria-label={revealed ? t.hide : t.show}
|
|
173
181
|
aria-busy={loading || undefined}
|
|
174
182
|
aria-disabled={loading || undefined}
|
|
175
183
|
className={CHIP_BUTTON_CLASS}
|
|
@@ -187,8 +195,8 @@ function SecretValue({
|
|
|
187
195
|
timeout={timeout}
|
|
188
196
|
onCopied={onCopied}
|
|
189
197
|
onCopyError={onCopyError}
|
|
190
|
-
copyLabel={
|
|
191
|
-
copiedLabel={
|
|
198
|
+
copyLabel={t.copy}
|
|
199
|
+
copiedLabel={t.copied}
|
|
192
200
|
// 6px more than the chip gap puts the icon centres 25px apart, so
|
|
193
201
|
// the two 24px targets do not overlap.
|
|
194
202
|
className={cn(CHIP_BUTTON_CLASS, 'ms-1.5')}
|
|
@@ -200,7 +208,7 @@ function SecretValue({
|
|
|
200
208
|
role="alert"
|
|
201
209
|
className="text-destructive-subtle-foreground pe-1 font-sans"
|
|
202
210
|
>
|
|
203
|
-
{
|
|
211
|
+
{t.loadError}
|
|
204
212
|
</span>
|
|
205
213
|
) : null}
|
|
206
214
|
</span>
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import { cn } from '@vendure-io/ui/lib/utils';
|
|
2
4
|
import type * as React from 'react';
|
|
5
|
+
import { useMessages } from '../../lib/format-messages.ts';
|
|
3
6
|
|
|
4
7
|
interface SkipLinkProps extends React.ComponentProps<'a'> {
|
|
5
8
|
/** The main-content element to focus. Include the leading `#`. */
|
|
6
9
|
href?: `#${string}`;
|
|
10
|
+
/** @default `messages.skipLink.label`, "Skip to main content" */
|
|
11
|
+
children?: React.ReactNode;
|
|
7
12
|
}
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* Keyboard-only escape hatch for repeated application chrome. Place it as the
|
|
11
16
|
* first focusable element in the document and point it at `AppShellMain` (whose
|
|
12
|
-
* default id is `main-content`). Native anchor behavior
|
|
13
|
-
*
|
|
17
|
+
* default id is `main-content`). Native anchor behavior works before React
|
|
18
|
+
* hydrates. A client component, for its text from `FormatProvider`: a server
|
|
19
|
+
* component can still render it.
|
|
14
20
|
*/
|
|
15
|
-
function SkipLink({
|
|
16
|
-
|
|
17
|
-
href = '#main-content',
|
|
18
|
-
children = 'Skip to main content',
|
|
19
|
-
...props
|
|
20
|
-
}: SkipLinkProps) {
|
|
21
|
+
function SkipLink({ className, href = '#main-content', children, ...props }: SkipLinkProps) {
|
|
22
|
+
const t = useMessages('skipLink');
|
|
21
23
|
return (
|
|
22
24
|
<a
|
|
23
25
|
data-slot="skip-link"
|
|
@@ -28,7 +30,7 @@ function SkipLink({
|
|
|
28
30
|
)}
|
|
29
31
|
{...props}
|
|
30
32
|
>
|
|
31
|
-
{children}
|
|
33
|
+
{children !== undefined ? children : t.label}
|
|
32
34
|
</a>
|
|
33
35
|
);
|
|
34
36
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import { Card, CardAction, CardContent, CardHeader } from '@vendure-io/ui/components/atoms/card';
|
|
2
4
|
import { useFormatSettings } from '@vendure-io/ui/components/molecules/format-provider';
|
|
3
5
|
import { SkeletonLine } from '@vendure-io/ui/components/molecules/state-views/skeleton-parts';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import { Button } from '@vendure-io/ui/components/atoms/button';
|
|
2
4
|
import {
|
|
3
5
|
Empty,
|
|
@@ -11,6 +13,7 @@ import { ErrorIllustration } from '@vendure-io/ui/components/molecules/illustrat
|
|
|
11
13
|
import { cn } from '@vendure-io/ui/lib/utils';
|
|
12
14
|
import { TriangleAlertIcon } from 'lucide-react';
|
|
13
15
|
import { warnDeprecated } from '../../../lib/deprecated.ts';
|
|
16
|
+
import { useMessages } from '../../../lib/format-messages.ts';
|
|
14
17
|
|
|
15
18
|
// `title` is redefined as `ReactNode`, so drop the native string `title` attr.
|
|
16
19
|
export interface ErrorStateProps extends Omit<React.ComponentProps<typeof Empty>, 'title'> {
|
|
@@ -27,13 +30,19 @@ export interface ErrorStateProps extends Omit<React.ComponentProps<typeof Empty>
|
|
|
27
30
|
* for a 404), or `illustration={null}` to fall back to `icon`.
|
|
28
31
|
*/
|
|
29
32
|
illustration?: React.ReactNode | null;
|
|
30
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* The headline.
|
|
35
|
+
* @default `messages.errorState.title`, "Something went wrong"
|
|
36
|
+
*/
|
|
31
37
|
title?: React.ReactNode;
|
|
32
38
|
/** Optional supporting copy. */
|
|
33
39
|
description?: React.ReactNode;
|
|
34
40
|
/** When provided, renders a "Try again" button that calls this handler. */
|
|
35
41
|
onRetry?: () => void;
|
|
36
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Label for the retry button.
|
|
44
|
+
* @default `messages.errorState.retry`, "Try again"
|
|
45
|
+
*/
|
|
37
46
|
retryLabel?: React.ReactNode;
|
|
38
47
|
/** Extra actions (e.g. a not-found "Go back" link) rendered beside retry. */
|
|
39
48
|
children?: React.ReactNode;
|
|
@@ -62,16 +71,17 @@ export interface ErrorStateProps extends Omit<React.ComponentProps<typeof Empty>
|
|
|
62
71
|
function ErrorState({
|
|
63
72
|
icon,
|
|
64
73
|
illustration,
|
|
65
|
-
title
|
|
74
|
+
title,
|
|
66
75
|
description,
|
|
67
76
|
onRetry,
|
|
68
|
-
retryLabel
|
|
77
|
+
retryLabel,
|
|
69
78
|
children,
|
|
70
79
|
bordered = false,
|
|
71
80
|
size: sizeProp = 'default',
|
|
72
81
|
className,
|
|
73
82
|
...props
|
|
74
83
|
}: ErrorStateProps) {
|
|
84
|
+
const t = useMessages('errorState');
|
|
75
85
|
if (sizeProp === 'compact') warnDeprecated('ErrorState', 'size="compact"', 'size="sm"');
|
|
76
86
|
const size = sizeProp === 'compact' ? 'sm' : sizeProp;
|
|
77
87
|
const small = size === 'sm';
|
|
@@ -114,7 +124,9 @@ function ErrorState({
|
|
|
114
124
|
{resolvedIcon}
|
|
115
125
|
</EmptyMedia>
|
|
116
126
|
) : null}
|
|
117
|
-
<EmptyTitle className={cn(small && 'text-style-card-title')}>
|
|
127
|
+
<EmptyTitle className={cn(small && 'text-style-card-title')}>
|
|
128
|
+
{title !== undefined ? title : t.title}
|
|
129
|
+
</EmptyTitle>
|
|
118
130
|
{description ? (
|
|
119
131
|
<EmptyDescription className={cn(small && 'text-sm')}>{description}</EmptyDescription>
|
|
120
132
|
) : null}
|
|
@@ -123,7 +135,7 @@ function ErrorState({
|
|
|
123
135
|
<EmptyContent className={cn(small && 'gap-2')}>
|
|
124
136
|
{onRetry ? (
|
|
125
137
|
<Button variant="outline" size="sm" onClick={onRetry}>
|
|
126
|
-
{retryLabel}
|
|
138
|
+
{retryLabel !== undefined ? retryLabel : t.retry}
|
|
127
139
|
</Button>
|
|
128
140
|
) : null}
|
|
129
141
|
{children}
|