@vendure-io/ui 3.0.0-next.5 → 3.0.0-next.7
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 +144 -17
- 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/action-needed.tsx +4 -4
- 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 +470 -107
- 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/components/molecules/status-badge.tsx +5 -2
- package/src/lib/chip-fit.ts +62 -0
- package/src/lib/format-messages.ts +189 -0
- package/src/lib/multi-select-keys.ts +77 -0
|
@@ -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}
|
|
@@ -102,7 +102,8 @@ const statusBadgeVariants = cva(
|
|
|
102
102
|
|
|
103
103
|
// The `bare` appearance: the chip without its box. The same icon and tinted
|
|
104
104
|
// label, no fill, outline or padding, for a state inside a tinted or accent
|
|
105
|
-
// surface, where a chip would be a box inside a box
|
|
105
|
+
// surface, where a chip would be a box inside a box, and for a count beside a
|
|
106
|
+
// title, where a chip is taller than the title.
|
|
106
107
|
const bareVariants = cva(
|
|
107
108
|
[
|
|
108
109
|
'inline-flex w-fit shrink-0 items-center gap-1.5 whitespace-nowrap font-medium',
|
|
@@ -191,7 +192,9 @@ interface StatusBadgeProps extends useRender.ComponentProps<'span'> {
|
|
|
191
192
|
* - `chip` (default): a tinted chip with a tone outline.
|
|
192
193
|
* - `bare`: the chip's icon and tinted label without the box. Use it for a
|
|
193
194
|
* state inside a tinted or accent surface (a card that is already
|
|
194
|
-
* coloured), where a chip would be a box inside a box.
|
|
195
|
+
* coloured), where a chip would be a box inside a box. Use it too for a
|
|
196
|
+
* count beside a title ("2 warnings" in an `ActionNeeded` header): it is as
|
|
197
|
+
* high as the text, where a chip is taller than the title.
|
|
195
198
|
* - `icon`: the tone icon with no box, then the label in neutral text, with
|
|
196
199
|
* an optional second line (`detail`). Use it for a status every row of a
|
|
197
200
|
* table shows (a deployments table).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { statusChipRing } from './tint-recipes.ts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The box a chip in a chips field shares with the "+N" chip: the fill, the
|
|
5
|
+
* outline, the height and the corner. `data-armed` marks the chip the next
|
|
6
|
+
* Backspace removes, with the focus ring and no change in size.
|
|
7
|
+
*/
|
|
8
|
+
export const chipShape = `bg-accent [--status-tone:var(--neutral-text)] ${statusChipRing} h-6 shrink-0 rounded-[calc(var(--radius-xl)-5px)] text-xs font-medium whitespace-nowrap outline-none data-armed:outline-solid data-armed:outline-2 data-armed:-outline-offset-2 data-armed:outline-ring focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring`;
|
|
9
|
+
|
|
10
|
+
/** The inside of a chip with a remove button: label 8px in, a 16px button 4px from the end. */
|
|
11
|
+
export const chipBox = 'flex items-center gap-1.5 ps-2 pe-1';
|
|
12
|
+
|
|
13
|
+
/** The inside of the "+N" chip. */
|
|
14
|
+
export const chipCountBox = 'flex items-center px-1.5 tabular-nums';
|
|
15
|
+
|
|
16
|
+
/** The gap between chips, `gap-1.5`. */
|
|
17
|
+
export const CHIP_GAP = 6;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Room kept after the chips for the caret and a typed search. The same at
|
|
21
|
+
* rest, on focus and while typing, so the number of chips does not change
|
|
22
|
+
* on focus or while typing: only a pick, a remove or a resize changes it.
|
|
23
|
+
*/
|
|
24
|
+
export const INPUT_RESERVE = 40;
|
|
25
|
+
|
|
26
|
+
/** The narrowest a lone chip shrinks to before its label is cut. */
|
|
27
|
+
export const MIN_CHIP_WIDTH = 48;
|
|
28
|
+
|
|
29
|
+
export type ChipFit = {
|
|
30
|
+
/** How many chips show, from the start. The rest go behind "+N". */
|
|
31
|
+
count: number;
|
|
32
|
+
/** Set when not even the first chip fits: its maximum width, in pixels. */
|
|
33
|
+
firstMax?: number;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* How many chips fit on one line of `available` pixels, leaving room for a
|
|
38
|
+
* "+N" chip of `countWidth` pixels when some do not. At least one chip
|
|
39
|
+
* always shows: when the first does not fit, it shows shortened to
|
|
40
|
+
* `firstMax`, so the field never shows only a count.
|
|
41
|
+
*/
|
|
42
|
+
export function fitChips(
|
|
43
|
+
widths: readonly number[],
|
|
44
|
+
available: number,
|
|
45
|
+
countWidth: number,
|
|
46
|
+
gap = CHIP_GAP,
|
|
47
|
+
): ChipFit {
|
|
48
|
+
let used = 0;
|
|
49
|
+
let count = 0;
|
|
50
|
+
for (let index = 0; index < widths.length; index++) {
|
|
51
|
+
const width = (widths[index] ?? 0) + (index > 0 ? gap : 0);
|
|
52
|
+
const rest = index < widths.length - 1 ? countWidth + gap : 0;
|
|
53
|
+
if (used + width + rest > available) break;
|
|
54
|
+
used += width;
|
|
55
|
+
count++;
|
|
56
|
+
}
|
|
57
|
+
if (count === 0 && widths.length > 0) {
|
|
58
|
+
const rest = widths.length > 1 ? countWidth + gap : 0;
|
|
59
|
+
return { count: 1, firstMax: Math.max(MIN_CHIP_WIDTH, available - rest) };
|
|
60
|
+
}
|
|
61
|
+
return { count };
|
|
62
|
+
}
|
|
@@ -9,6 +9,14 @@ const defaultMessages = {
|
|
|
9
9
|
loading: 'Loading…',
|
|
10
10
|
/** The row of a BreadcrumbSearchMenu that reads the options again. */
|
|
11
11
|
retry: 'Retry',
|
|
12
|
+
/** BreadcrumbSearchMenu's row when the search matches no option. */
|
|
13
|
+
empty: 'No results.',
|
|
14
|
+
/** BreadcrumbSearchMenu's search placeholder. `{label}` is the menu's `label`, in lower case. */
|
|
15
|
+
search: 'Find {label}…',
|
|
16
|
+
/** Screen-reader text of BreadcrumbEllipsis. */
|
|
17
|
+
more: 'More',
|
|
18
|
+
/** Accessible name of the Breadcrumb landmark. */
|
|
19
|
+
nav: 'breadcrumb',
|
|
12
20
|
},
|
|
13
21
|
codeBlock: {
|
|
14
22
|
copyCode: 'Copy code',
|
|
@@ -24,6 +32,16 @@ const defaultMessages = {
|
|
|
24
32
|
combobox: {
|
|
25
33
|
/** Announced while a page of options loads. */
|
|
26
34
|
loading: 'Loading…',
|
|
35
|
+
/** Accessible name of ComboboxInput's icon-only open button. */
|
|
36
|
+
open: 'Open options',
|
|
37
|
+
/** Accessible name of the icon-only clear button. */
|
|
38
|
+
clear: 'Clear',
|
|
39
|
+
/** Accessible name of a ComboboxChip's remove button. */
|
|
40
|
+
remove: 'Remove',
|
|
41
|
+
/** Accessible name of ComboboxChipsActions' clear-all button. */
|
|
42
|
+
clearAll: 'Clear all',
|
|
43
|
+
/** Accessible name of ComboboxChipCount, the "+N" chip. `{count}` is the number of hidden values. */
|
|
44
|
+
more: '{count} more',
|
|
27
45
|
},
|
|
28
46
|
comboboxFreeText: {
|
|
29
47
|
/** Announced by the field's spinner while suggestions load. */
|
|
@@ -32,6 +50,8 @@ const defaultMessages = {
|
|
|
32
50
|
confirmDialog: {
|
|
33
51
|
/** Screen-reader text of the spinner while the confirm action runs. */
|
|
34
52
|
loading: 'Loading',
|
|
53
|
+
confirm: 'Confirm',
|
|
54
|
+
cancel: 'Cancel',
|
|
35
55
|
},
|
|
36
56
|
copyButton: {
|
|
37
57
|
copy: 'Copy',
|
|
@@ -44,6 +64,17 @@ const defaultMessages = {
|
|
|
44
64
|
multiSelect: {
|
|
45
65
|
/** Stands in for the selected values while the options load. */
|
|
46
66
|
loading: 'Loading…',
|
|
67
|
+
/** The search input's placeholder when nothing is selected. */
|
|
68
|
+
placeholder: 'Select…',
|
|
69
|
+
/** The list's text when the search matches no option. */
|
|
70
|
+
empty: 'No results.',
|
|
71
|
+
/** Accessible name of a chip's remove button. `{label}` is the value's label. */
|
|
72
|
+
remove: 'Remove {label}',
|
|
73
|
+
/**
|
|
74
|
+
* Announced on the first Backspace in an empty search, which marks the last
|
|
75
|
+
* value; the second Backspace removes it. `{label}` is the value's label.
|
|
76
|
+
*/
|
|
77
|
+
armed: '{label} marked. Press Backspace again to remove it.',
|
|
47
78
|
},
|
|
48
79
|
passwordInput: {
|
|
49
80
|
showPassword: 'Show password',
|
|
@@ -52,6 +83,16 @@ const defaultMessages = {
|
|
|
52
83
|
secretValue: {
|
|
53
84
|
/** Screen-reader text of the spinner while the value loads. */
|
|
54
85
|
loading: 'Loading',
|
|
86
|
+
/** Accessible name while the value is masked. */
|
|
87
|
+
hidden: 'Hidden value',
|
|
88
|
+
/** Accessible name of the reveal button. */
|
|
89
|
+
show: 'Show value',
|
|
90
|
+
/** Accessible name of the button that masks the value again. */
|
|
91
|
+
hide: 'Hide value',
|
|
92
|
+
copy: 'Copy value',
|
|
93
|
+
copied: 'Value copied',
|
|
94
|
+
/** Shown when `loadValue` rejects. */
|
|
95
|
+
loadError: "Couldn't load the value.",
|
|
55
96
|
},
|
|
56
97
|
searchTrigger: {
|
|
57
98
|
label: 'Search',
|
|
@@ -73,6 +114,12 @@ const defaultMessages = {
|
|
|
73
114
|
anonymizedToken: {
|
|
74
115
|
/** Screen-reader text while the token loads (`value={undefined}`). */
|
|
75
116
|
loading: 'Loading token',
|
|
117
|
+
/** Accessible name while the preview is blurred. */
|
|
118
|
+
obscured: 'Partially obscured token',
|
|
119
|
+
/** Accessible name while the preview is sharp. */
|
|
120
|
+
preview: 'Partially visible token',
|
|
121
|
+
copy: 'Copy token',
|
|
122
|
+
copied: 'Token copied',
|
|
76
123
|
},
|
|
77
124
|
dateTime: {
|
|
78
125
|
/** Screen-reader text while the date loads (`value={undefined}`). */
|
|
@@ -89,16 +136,22 @@ const defaultMessages = {
|
|
|
89
136
|
datePicker: {
|
|
90
137
|
/** Accessible name of the button that clears the date. */
|
|
91
138
|
clear: 'Clear date',
|
|
139
|
+
/** The trigger's text with no date. */
|
|
140
|
+
placeholder: 'Pick a date',
|
|
92
141
|
},
|
|
93
142
|
dateTimePicker: {
|
|
94
143
|
/** Accessible name of the button that clears the date and time. */
|
|
95
144
|
clear: 'Clear date and time',
|
|
96
145
|
/** Accessible name of the time field. */
|
|
97
146
|
time: 'Time',
|
|
147
|
+
/** The trigger's text with no date. */
|
|
148
|
+
placeholder: 'Pick a date and time',
|
|
98
149
|
},
|
|
99
150
|
dateRangePicker: {
|
|
100
151
|
/** Accessible name of the button that clears the range. */
|
|
101
152
|
clear: 'Clear date range',
|
|
153
|
+
/** The trigger's text with no range. */
|
|
154
|
+
placeholder: 'Pick a date range',
|
|
102
155
|
},
|
|
103
156
|
fileDropzone: {
|
|
104
157
|
typeNotAccepted: 'This file type is not accepted.',
|
|
@@ -120,10 +173,119 @@ const defaultMessages = {
|
|
|
120
173
|
byte: 'B',
|
|
121
174
|
kilobyte: 'KB',
|
|
122
175
|
megabyte: 'MB',
|
|
176
|
+
/** The field's label. */
|
|
177
|
+
label: 'Upload files',
|
|
178
|
+
/** The drop prompt. */
|
|
179
|
+
empty: 'Drag and drop files here, or choose files',
|
|
180
|
+
/** The drop prompt while files are dragged over. */
|
|
181
|
+
drag: 'Drop files to add them',
|
|
123
182
|
},
|
|
124
183
|
dataTable: {
|
|
125
184
|
/** Placeholder and accessible name of the filter editor's default value input. */
|
|
126
185
|
filterValue: 'Value',
|
|
186
|
+
/** The row of a loaded table with no rows. */
|
|
187
|
+
empty: 'No results',
|
|
188
|
+
/** Accessible name of the header checkbox. */
|
|
189
|
+
selectAllRows: 'Select all rows',
|
|
190
|
+
/** Tooltip on the header checkbox while not every row on the page is selected. */
|
|
191
|
+
selectAllOnPage: 'Select all on this page',
|
|
192
|
+
/** Tooltip on the header checkbox while every row on the page is selected. */
|
|
193
|
+
clearPageSelection: 'Clear selection on this page',
|
|
194
|
+
/** Accessible name of a row's checkbox. `{row}` is the 1-based row number. */
|
|
195
|
+
selectRow: 'Select row {row}',
|
|
196
|
+
/** Screen-reader header of the row actions column. */
|
|
197
|
+
rowActions: 'Open row actions',
|
|
198
|
+
/** DataTableViewOptions' trigger. */
|
|
199
|
+
columnsTrigger: 'Columns',
|
|
200
|
+
/** DataTableViewOptions' menu heading. */
|
|
201
|
+
columnsHeading: 'Toggle columns',
|
|
202
|
+
/** DataTableAddFilter's trigger. */
|
|
203
|
+
addFilter: 'Add filter',
|
|
204
|
+
/** The button that clears every filter. */
|
|
205
|
+
clearFilters: 'Clear filters',
|
|
206
|
+
/** Accessible name of an applied filter's remove button. `{column}` is the column's label. */
|
|
207
|
+
removeFilter: 'Remove {column} filter',
|
|
208
|
+
/** Accessible name of a sortable header. `{column}` is the column's label. */
|
|
209
|
+
sortLabel: 'Sort by {column}',
|
|
210
|
+
/** The chip that holds the filters past `inlineChipLimit`. `{count}` is their number. */
|
|
211
|
+
filtersCollapsed: '{count} filters',
|
|
212
|
+
},
|
|
213
|
+
tablePagination: {
|
|
214
|
+
/** Accessible name of the prev/next navigation landmark. */
|
|
215
|
+
nav: 'Pagination',
|
|
216
|
+
/** Accessible name of the previous-page control. */
|
|
217
|
+
previous: 'Go to previous page',
|
|
218
|
+
/** Accessible name of the next-page control. */
|
|
219
|
+
next: 'Go to next page',
|
|
220
|
+
/** Visible and accessible name of the page-size selector. */
|
|
221
|
+
pageSize: 'Items per page',
|
|
222
|
+
/** The range text. `{start}`, `{end}` and `{total}` are formatted numbers. */
|
|
223
|
+
range: '{start}–{end} of {total}',
|
|
224
|
+
/** The range text of an empty list. */
|
|
225
|
+
rangeEmpty: '0 of 0',
|
|
226
|
+
},
|
|
227
|
+
checklist: {
|
|
228
|
+
/** Accessible name of the dismiss button. */
|
|
229
|
+
dismiss: 'Dismiss checklist',
|
|
230
|
+
/** Label of the group of finished steps. */
|
|
231
|
+
completed: 'Completed',
|
|
232
|
+
/** Read after a done step's label in system mode. */
|
|
233
|
+
stepDone: 'done',
|
|
234
|
+
/** Read after an open step's label in system mode. */
|
|
235
|
+
stepOpen: 'not done',
|
|
236
|
+
/** The count beside the title. `{done}` and `{total}` are step counts. */
|
|
237
|
+
count: '{done} of {total}',
|
|
238
|
+
/** Announced when the count changes. */
|
|
239
|
+
announcement: '{done} of {total} steps done',
|
|
240
|
+
},
|
|
241
|
+
errorState: {
|
|
242
|
+
/** The headline. */
|
|
243
|
+
title: 'Something went wrong',
|
|
244
|
+
/** The retry button. */
|
|
245
|
+
retry: 'Try again',
|
|
246
|
+
},
|
|
247
|
+
idChip: {
|
|
248
|
+
/** The tooltip before copying. The copy button's name adds the shown text: "Copy 9f2c4e1". */
|
|
249
|
+
copy: 'Copy',
|
|
250
|
+
copied: 'Copied',
|
|
251
|
+
},
|
|
252
|
+
issuedSecret: {
|
|
253
|
+
/** The copy button with one value. `{secret}` is the `secretName`. */
|
|
254
|
+
copy: 'Copy {secret}',
|
|
255
|
+
copied: 'Copied',
|
|
256
|
+
/** `{secret}` is the `secretName`. */
|
|
257
|
+
notice: 'You can copy the {secret} only now.',
|
|
258
|
+
/** `{secret}` is the `secretName`. */
|
|
259
|
+
fallbackDescription: 'The clipboard is not available. Select the {secret} and copy it by hand.',
|
|
260
|
+
/** `{secret}` is the `secretName`. */
|
|
261
|
+
warningTitle: 'The {secret} is not copied',
|
|
262
|
+
warningDescription:
|
|
263
|
+
'You cannot copy it after you close. Copy it now, or close without copying.',
|
|
264
|
+
/** IssuedSecretFooter's button. */
|
|
265
|
+
done: 'Done',
|
|
266
|
+
/** IssuedSecretFooter's button after the warning. */
|
|
267
|
+
closeAnyway: 'Close without copying',
|
|
268
|
+
},
|
|
269
|
+
pagination: {
|
|
270
|
+
/** Accessible name of the Pagination landmark. */
|
|
271
|
+
nav: 'pagination',
|
|
272
|
+
/** Accessible name of PaginationPrevious. */
|
|
273
|
+
previous: 'Go to previous page',
|
|
274
|
+
/** Visible text of PaginationPrevious. */
|
|
275
|
+
previousText: 'Previous',
|
|
276
|
+
/** Accessible name of PaginationNext. */
|
|
277
|
+
next: 'Go to next page',
|
|
278
|
+
/** Visible text of PaginationNext. */
|
|
279
|
+
nextText: 'Next',
|
|
280
|
+
/** Screen-reader text of PaginationEllipsis. */
|
|
281
|
+
more: 'More pages',
|
|
282
|
+
},
|
|
283
|
+
skipLink: {
|
|
284
|
+
label: 'Skip to main content',
|
|
285
|
+
},
|
|
286
|
+
spinner: {
|
|
287
|
+
/** The spinner's accessible name. */
|
|
288
|
+
loading: 'Loading',
|
|
127
289
|
},
|
|
128
290
|
dialog: {
|
|
129
291
|
/** Accessible name of the ✕, and the text of DialogFooter's Close button. */
|
|
@@ -138,6 +300,24 @@ const defaultMessages = {
|
|
|
138
300
|
mobileTitle: 'Sidebar',
|
|
139
301
|
/** Screen-reader description of the mobile Sidebar's sheet. */
|
|
140
302
|
mobileDescription: 'Displays the mobile sidebar.',
|
|
303
|
+
/** Accessible name of SidebarTrigger and SidebarRail, and SidebarRail's tooltip. */
|
|
304
|
+
toggle: 'Toggle Sidebar',
|
|
305
|
+
},
|
|
306
|
+
carousel: {
|
|
307
|
+
/** Screen-reader text of CarouselPrevious. */
|
|
308
|
+
previous: 'Previous slide',
|
|
309
|
+
/** Screen-reader text of CarouselNext. */
|
|
310
|
+
next: 'Next slide',
|
|
311
|
+
/** The Carousel region's `aria-roledescription`. */
|
|
312
|
+
region: 'carousel',
|
|
313
|
+
/** A CarouselItem's `aria-roledescription`. */
|
|
314
|
+
slide: 'slide',
|
|
315
|
+
},
|
|
316
|
+
command: {
|
|
317
|
+
/** Screen-reader title of CommandDialog. */
|
|
318
|
+
title: 'Command Palette',
|
|
319
|
+
/** Screen-reader description of CommandDialog. */
|
|
320
|
+
description: 'Search for a command to run...',
|
|
141
321
|
},
|
|
142
322
|
};
|
|
143
323
|
|
|
@@ -190,3 +370,12 @@ function useMessages<Group extends MessageGroup>(
|
|
|
190
370
|
|
|
191
371
|
export { defaultMessages, useMessages };
|
|
192
372
|
export type { FormatMessages };
|
|
373
|
+
|
|
374
|
+
/** Replaces each `{key}` in a message with its value. An unknown key stays as written. */
|
|
375
|
+
function fillMessage(template: string, values: Record<string, string | number>): string {
|
|
376
|
+
return template.replace(/\{(\w+)\}/g, (match, key: string) =>
|
|
377
|
+
key in values ? String(values[key]) : match,
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export { fillMessage };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The keyboard rules of MultiSelect's search input, as a function of the
|
|
3
|
+
* field's state and the key. MultiSelect applies the action; Base UI keeps
|
|
4
|
+
* every key this returns `pass` or `disarm` for.
|
|
5
|
+
*/
|
|
6
|
+
export type MultiSelectKeyState = {
|
|
7
|
+
key: string;
|
|
8
|
+
/** The search input holds no text. */
|
|
9
|
+
inputEmpty: boolean;
|
|
10
|
+
/** The list is open. */
|
|
11
|
+
open: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The search is empty and the user has not moved the highlight with an
|
|
14
|
+
* arrow key or the pointer: Base UI may hold a highlighted row, but the
|
|
15
|
+
* row does not show as highlighted.
|
|
16
|
+
*/
|
|
17
|
+
quiet: boolean;
|
|
18
|
+
/** Base UI holds a highlighted row. */
|
|
19
|
+
hasHighlight: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The search changed and its results have not arrived: the rows on screen
|
|
22
|
+
* belong to the previous search.
|
|
23
|
+
*/
|
|
24
|
+
stale: boolean;
|
|
25
|
+
/** How many values are picked. */
|
|
26
|
+
valueCount: number;
|
|
27
|
+
/** The index of the value the next Backspace removes, if one is marked. */
|
|
28
|
+
armed: number | null;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type MultiSelectKeyAction =
|
|
32
|
+
/** Show the row Base UI holds instead of moving past it. Base UI does nothing. */
|
|
33
|
+
| { type: 'reveal' }
|
|
34
|
+
/** Nothing happens. Base UI does nothing. */
|
|
35
|
+
| { type: 'block' }
|
|
36
|
+
/** Mark the value at `index`; the next Backspace removes it. Base UI does nothing. */
|
|
37
|
+
| { type: 'arm'; index: number }
|
|
38
|
+
/** Remove the value at `index`. Base UI does nothing. */
|
|
39
|
+
| { type: 'remove'; index: number }
|
|
40
|
+
/** Drop the mark and keep the values. Base UI does nothing. */
|
|
41
|
+
| { type: 'escape' }
|
|
42
|
+
/** Drop the mark; Base UI handles the key. */
|
|
43
|
+
| { type: 'disarm' }
|
|
44
|
+
/** Base UI handles the key. */
|
|
45
|
+
| { type: 'pass' };
|
|
46
|
+
|
|
47
|
+
export function multiSelectKeyAction(state: MultiSelectKeyState): MultiSelectKeyAction {
|
|
48
|
+
const { key, inputEmpty, open, quiet, hasHighlight, stale, valueCount, armed } = state;
|
|
49
|
+
|
|
50
|
+
// After an open or a pick, Base UI holds a row without showing it. The
|
|
51
|
+
// first arrow shows that row, so ArrowDown lands on the first result.
|
|
52
|
+
if ((key === 'ArrowDown' || key === 'ArrowUp') && open && quiet && hasHighlight) {
|
|
53
|
+
return { type: 'reveal' };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Enter picks only a row the user can see highlighted, from the current
|
|
57
|
+
// search: not a hidden highlight, not an empty list (Base UI would close
|
|
58
|
+
// it), and not a row of the previous search while the new one loads.
|
|
59
|
+
if (key === 'Enter' && open && (quiet || !hasHighlight || stale)) {
|
|
60
|
+
return { type: 'block' };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Backspace in an empty search takes two presses: the first marks the last
|
|
64
|
+
// value, the second removes it. Base UI would remove the last chip on
|
|
65
|
+
// screen in one press, which is not the last value once some are behind
|
|
66
|
+
// "+N".
|
|
67
|
+
if (key === 'Backspace' && inputEmpty && valueCount > 0) {
|
|
68
|
+
const last = valueCount - 1;
|
|
69
|
+
return armed === last ? { type: 'remove', index: last } : { type: 'arm', index: last };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Base UI clears every value on Escape while the list is closed.
|
|
73
|
+
if (key === 'Escape' && !open) return { type: 'escape' };
|
|
74
|
+
|
|
75
|
+
if (armed !== null && key !== 'Shift') return { type: 'disarm' };
|
|
76
|
+
return { type: 'pass' };
|
|
77
|
+
}
|