@setsquare/ui 0.4.0 → 0.6.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.
- package/CHANGELOG.md +129 -0
- package/README.md +41 -3
- package/dist/index.d.ts +15 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/english.d.ts +11 -0
- package/dist/lib/english.d.ts.map +1 -0
- package/dist/lib/english.js +65 -0
- package/dist/lib/english.js.map +1 -0
- package/dist/lib/labels.d.ts +38 -8
- package/dist/lib/labels.d.ts.map +1 -1
- package/dist/lib/labels.js +97 -9
- package/dist/lib/labels.js.map +1 -1
- package/dist/lib/locale.d.ts +105 -0
- package/dist/lib/locale.d.ts.map +1 -0
- package/dist/lib/locale.js +42 -0
- package/dist/lib/locale.js.map +1 -0
- package/dist/lint/index.d.ts +5 -0
- package/dist/lint/index.d.ts.map +1 -1
- package/dist/lint/index.js +80 -3
- package/dist/lint/index.js.map +1 -1
- package/dist/shell/dashboard-shell.d.ts +4 -1
- package/dist/shell/dashboard-shell.d.ts.map +1 -1
- package/dist/shell/dashboard-shell.js +3 -2
- package/dist/shell/dashboard-shell.js.map +1 -1
- package/dist/shell/landmarks.d.ts +33 -0
- package/dist/shell/landmarks.d.ts.map +1 -0
- package/dist/shell/landmarks.js +20 -0
- package/dist/shell/landmarks.js.map +1 -0
- package/dist/shell/right-panel.d.ts +7 -2
- package/dist/shell/right-panel.d.ts.map +1 -1
- package/dist/shell/right-panel.js +13 -7
- package/dist/shell/right-panel.js.map +1 -1
- package/dist/shell/sidebar.d.ts +10 -2
- package/dist/shell/sidebar.d.ts.map +1 -1
- package/dist/shell/sidebar.js +31 -14
- package/dist/shell/sidebar.js.map +1 -1
- package/dist/shell/site-menu.d.ts +11 -3
- package/dist/shell/site-menu.d.ts.map +1 -1
- package/dist/shell/site-menu.js +7 -1
- package/dist/shell/site-menu.js.map +1 -1
- package/dist/shell/site-nav.d.ts +4 -1
- package/dist/shell/site-nav.d.ts.map +1 -1
- package/dist/shell/site-nav.js +3 -3
- package/dist/shell/site-nav.js.map +1 -1
- package/dist/shell/site-shell.d.ts +4 -2
- package/dist/shell/site-shell.d.ts.map +1 -1
- package/dist/shell/site-shell.js +3 -2
- package/dist/shell/site-shell.js.map +1 -1
- package/dist/styles/theme.css +2 -0
- package/dist/styles/tokens.css +9 -0
- package/dist/testing/index.d.ts +54 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +246 -9
- package/dist/testing/index.js.map +1 -1
- package/dist/tokens.json +25 -0
- package/dist/ui/alert.d.ts +2 -0
- package/dist/ui/alert.d.ts.map +1 -1
- package/dist/ui/alert.js +11 -9
- package/dist/ui/alert.js.map +1 -1
- package/dist/ui/breadcrumbs.d.ts +17 -1
- package/dist/ui/breadcrumbs.d.ts.map +1 -1
- package/dist/ui/breadcrumbs.js +6 -3
- package/dist/ui/breadcrumbs.js.map +1 -1
- package/dist/ui/button-styles.d.ts.map +1 -1
- package/dist/ui/button-styles.js +16 -6
- package/dist/ui/button-styles.js.map +1 -1
- package/dist/ui/calendar.d.ts +1 -0
- package/dist/ui/calendar.d.ts.map +1 -1
- package/dist/ui/calendar.js +7 -1
- package/dist/ui/calendar.js.map +1 -1
- package/dist/ui/checkbox.d.ts.map +1 -1
- package/dist/ui/checkbox.js +7 -7
- package/dist/ui/checkbox.js.map +1 -1
- package/dist/ui/code-block-parts.d.ts +30 -0
- package/dist/ui/code-block-parts.d.ts.map +1 -0
- package/dist/ui/code-block-parts.js +27 -0
- package/dist/ui/code-block-parts.js.map +1 -0
- package/dist/ui/code-block.d.ts +4 -10
- package/dist/ui/code-block.d.ts.map +1 -1
- package/dist/ui/code-block.js +4 -9
- package/dist/ui/code-block.js.map +1 -1
- package/dist/ui/combo-box.d.ts +13 -2
- package/dist/ui/combo-box.d.ts.map +1 -1
- package/dist/ui/combo-box.js +10 -3
- package/dist/ui/combo-box.js.map +1 -1
- package/dist/ui/copy-button.d.ts +7 -1
- package/dist/ui/copy-button.d.ts.map +1 -1
- package/dist/ui/copy-button.js +11 -10
- package/dist/ui/copy-button.js.map +1 -1
- package/dist/ui/date-field.d.ts +1 -0
- package/dist/ui/date-field.d.ts.map +1 -1
- package/dist/ui/date-field.js +20 -16
- package/dist/ui/date-field.js.map +1 -1
- package/dist/ui/dialog.d.ts +6 -1
- package/dist/ui/dialog.d.ts.map +1 -1
- package/dist/ui/dialog.js +11 -8
- package/dist/ui/dialog.js.map +1 -1
- package/dist/ui/drop-indicator.d.ts +21 -0
- package/dist/ui/drop-indicator.d.ts.map +1 -0
- package/dist/ui/drop-indicator.js +20 -0
- package/dist/ui/drop-indicator.js.map +1 -0
- package/dist/ui/error-state.d.ts +17 -2
- package/dist/ui/error-state.d.ts.map +1 -1
- package/dist/ui/error-state.js +32 -34
- package/dist/ui/error-state.js.map +1 -1
- package/dist/ui/feature-card.d.ts +18 -3
- package/dist/ui/feature-card.d.ts.map +1 -1
- package/dist/ui/feature-card.js +18 -3
- package/dist/ui/feature-card.js.map +1 -1
- package/dist/ui/field.d.ts +28 -9
- package/dist/ui/field.d.ts.map +1 -1
- package/dist/ui/field.js +22 -10
- package/dist/ui/field.js.map +1 -1
- package/dist/ui/file-upload.d.ts +23 -5
- package/dist/ui/file-upload.d.ts.map +1 -1
- package/dist/ui/file-upload.js +54 -36
- package/dist/ui/file-upload.js.map +1 -1
- package/dist/ui/form.d.ts +11 -1
- package/dist/ui/form.d.ts.map +1 -1
- package/dist/ui/form.js +7 -4
- package/dist/ui/form.js.map +1 -1
- package/dist/ui/grid-list.d.ts +10 -3
- package/dist/ui/grid-list.d.ts.map +1 -1
- package/dist/ui/grid-list.js +18 -7
- package/dist/ui/grid-list.js.map +1 -1
- package/dist/ui/number-field.d.ts.map +1 -1
- package/dist/ui/number-field.js +5 -3
- package/dist/ui/number-field.js.map +1 -1
- package/dist/ui/pagination.d.ts +11 -3
- package/dist/ui/pagination.d.ts.map +1 -1
- package/dist/ui/pagination.js +30 -23
- package/dist/ui/pagination.js.map +1 -1
- package/dist/ui/radio-group.d.ts.map +1 -1
- package/dist/ui/radio-group.js +4 -4
- package/dist/ui/radio-group.js.map +1 -1
- package/dist/ui/search.d.ts +3 -0
- package/dist/ui/search.d.ts.map +1 -1
- package/dist/ui/search.js +11 -10
- package/dist/ui/search.js.map +1 -1
- package/dist/ui/select.d.ts +7 -1
- package/dist/ui/select.d.ts.map +1 -1
- package/dist/ui/select.js +7 -3
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/selection-bar.d.ts +17 -4
- package/dist/ui/selection-bar.d.ts.map +1 -1
- package/dist/ui/selection-bar.js +15 -11
- package/dist/ui/selection-bar.js.map +1 -1
- package/dist/ui/sheet.d.ts +1 -0
- package/dist/ui/sheet.d.ts.map +1 -1
- package/dist/ui/sheet.js +4 -1
- package/dist/ui/sheet.js.map +1 -1
- package/dist/ui/slider.d.ts +9 -2
- package/dist/ui/slider.d.ts.map +1 -1
- package/dist/ui/slider.js +13 -5
- package/dist/ui/slider.js.map +1 -1
- package/dist/ui/switch.d.ts +2 -1
- package/dist/ui/switch.d.ts.map +1 -1
- package/dist/ui/switch.js +5 -2
- package/dist/ui/switch.js.map +1 -1
- package/dist/ui/tabs.d.ts +1 -0
- package/dist/ui/tabs.d.ts.map +1 -1
- package/dist/ui/tabs.js +13 -12
- package/dist/ui/tabs.js.map +1 -1
- package/dist/ui/text-field.d.ts.map +1 -1
- package/dist/ui/text-field.js +7 -3
- package/dist/ui/text-field.js.map +1 -1
- package/dist/ui/theme-switcher.d.ts +1 -0
- package/dist/ui/theme-switcher.d.ts.map +1 -1
- package/dist/ui/theme-switcher.js +7 -7
- package/dist/ui/theme-switcher.js.map +1 -1
- package/dist/ui/toast.d.ts +1 -0
- package/dist/ui/toast.d.ts.map +1 -1
- package/dist/ui/toast.js +4 -1
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/toolbar.d.ts +22 -0
- package/dist/ui/toolbar.d.ts.map +1 -0
- package/dist/ui/toolbar.js +22 -0
- package/dist/ui/toolbar.js.map +1 -0
- package/dist/ui/tree.d.ts +57 -12
- package/dist/ui/tree.d.ts.map +1 -1
- package/dist/ui/tree.js +55 -16
- package/dist/ui/tree.js.map +1 -1
- package/package.json +4 -3
package/dist/ui/dialog.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type ReactNode } from 'react';
|
|
|
3
3
|
export interface DialogLabels {
|
|
4
4
|
close: string;
|
|
5
5
|
}
|
|
6
|
+
export declare const dialogLabels: DialogLabels;
|
|
6
7
|
export interface DialogProps {
|
|
7
8
|
isOpen: boolean;
|
|
8
9
|
onOpenChange: (open: boolean) => void;
|
|
@@ -21,8 +22,10 @@ export interface DialogProps {
|
|
|
21
22
|
}
|
|
22
23
|
/** A centred modal: focus moves in and is trapped, Escape closes, focus returns to what opened it. */
|
|
23
24
|
export declare function Dialog({ isOpen, onOpenChange, title, description, children, footer, role, isDismissable, size, labels, className, }: DialogProps): import("react").JSX.Element;
|
|
24
|
-
/** A ConfirmDialog's words, for the `labels` prop.
|
|
25
|
+
/** A ConfirmDialog's words, for the `labels` prop. */
|
|
25
26
|
export interface ConfirmDialogLabels {
|
|
27
|
+
/** The button that closes it without acting. */
|
|
28
|
+
cancel: string;
|
|
26
29
|
/** The type-to-confirm field's label; `{text}` is `confirmText`. */
|
|
27
30
|
typeToConfirm: string;
|
|
28
31
|
/** Its error when the text doesn't match. */
|
|
@@ -32,6 +35,7 @@ export interface ConfirmDialogLabels {
|
|
|
32
35
|
/** The error when `onConfirm` throws without a message of its own. */
|
|
33
36
|
failed: string;
|
|
34
37
|
}
|
|
38
|
+
export declare const confirmDialogLabels: ConfirmDialogLabels;
|
|
35
39
|
export interface ConfirmDialogProps {
|
|
36
40
|
isOpen: boolean;
|
|
37
41
|
onOpenChange: (open: boolean) => void;
|
|
@@ -41,6 +45,7 @@ export interface ConfirmDialogProps {
|
|
|
41
45
|
children: ReactNode;
|
|
42
46
|
/** A verb phrase that repeats the action: "Delete project" — never "OK" or "Yes". */
|
|
43
47
|
confirmLabel: string;
|
|
48
|
+
/** @deprecated Use `labels.cancel`. Kept for one release. */
|
|
44
49
|
cancelLabel?: string;
|
|
45
50
|
tone?: 'danger' | 'default';
|
|
46
51
|
/** For the riskiest actions: the exact text to type before confirming (the project's name). */
|
package/dist/ui/dialog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/ui/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAUxD,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,sDAAsD;IACtD,IAAI,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;IAChC,sGAAsG;IACtG,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,sGAAsG;AACtG,wBAAgB,MAAM,CAAC,EACrB,MAAM,EACN,YAAY,EACZ,KAAK,EACL,WAAW,EACX,QAAQ,EACR,MAAM,EACN,IAAe,EACf,aAAoB,EACpB,IAAW,EACX,MAAM,EACN,SAAS,GACV,EAAE,WAAW,+
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sour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O,MAAM,mBAAmB,EAAE,mBAMjC,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,QAAQ,EAAE,SAAS,CAAC;IACpB,qFAAqF;IACrF,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,+FAA+F;IAC/F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qGAAqG;IACrG,SAAS,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,IAAe,EACf,WAAW,EACX,SAAS,EACT,MAAM,EAAE,KAAK,GACd,EAAE,kBAAkB,+BAwFpB"}
|
package/dist/ui/dialog.js
CHANGED
|
@@ -4,18 +4,21 @@ import { useId, useState } from 'react';
|
|
|
4
4
|
import { Dialog as RACDialog, Heading, Modal, ModalOverlay } from 'react-aria-components';
|
|
5
5
|
import { X } from 'lucide-react';
|
|
6
6
|
import { cn } from '../lib/cn.js';
|
|
7
|
-
import {
|
|
7
|
+
import { useLabels } from '../lib/locale.js';
|
|
8
8
|
import { Alert } from './alert.js';
|
|
9
9
|
import { Button } from './button.js';
|
|
10
10
|
import { IconButton } from './icon-button.js';
|
|
11
11
|
import { TextField } from './text-field.js';
|
|
12
|
+
export const dialogLabels = { close: 'Close' };
|
|
12
13
|
const widths = { sm: 'max-w-[26rem]', md: 'max-w-[32rem]', lg: 'max-w-[44rem]' };
|
|
13
14
|
/** A centred modal: focus moves in and is trapped, Escape closes, focus returns to what opened it. */
|
|
14
15
|
export function Dialog({ isOpen, onOpenChange, title, description, children, footer, role = 'dialog', isDismissable = true, size = 'md', labels, className, }) {
|
|
16
|
+
const t = useLabels('dialog', dialogLabels, labels);
|
|
15
17
|
const descId = useId();
|
|
16
|
-
return (_jsx(ModalOverlay, { isOpen: isOpen, onOpenChange: onOpenChange, isDismissable: isDismissable, "data-overlay": true, className: "fixed inset-0 z-(--z-sheet) flex items-center justify-center bg-overlay p-4", children: _jsx(Modal, { "data-sheet": "top", className: cn('relative max-h-[calc(100dvh-2rem)] w-full overflow-auto rounded-xl border border-border bg-popover text-popover-foreground shadow-(--shadow-lg) outline-none', widths[size], className), children: _jsxs(RACDialog, { role: role, "aria-describedby": description ? descId : undefined, className: "flex flex-col outline-none", children: [_jsxs("div", { className: "flex items-start justify-between gap-3 px-5 pt-5", children: [_jsx(Heading, { slot: "title", className: "text-heading", children: title }), isDismissable && (_jsx(IconButton, { label:
|
|
18
|
+
return (_jsx(ModalOverlay, { isOpen: isOpen, onOpenChange: onOpenChange, isDismissable: isDismissable, "data-overlay": true, className: "fixed inset-0 z-(--z-sheet) flex items-center justify-center bg-overlay p-4", children: _jsx(Modal, { "data-sheet": "top", className: cn('relative max-h-[calc(100dvh-2rem)] w-full overflow-auto rounded-xl border border-border bg-popover text-popover-foreground shadow-(--shadow-lg) outline-none', widths[size], className), children: _jsxs(RACDialog, { role: role, "aria-describedby": description ? descId : undefined, className: "flex flex-col outline-none", children: [_jsxs("div", { className: "flex items-start justify-between gap-3 px-5 pt-5", children: [_jsx(Heading, { slot: "title", className: "text-heading", children: title }), isDismissable && (_jsx(IconButton, { label: t('close'), icon: X, visualSize: "icon-sm", slot: "close", tooltip: false, className: "-mt-1 -mr-2 items-start justify-end" }))] }), _jsxs("div", { className: "flex flex-col gap-4 px-5 pt-2 pb-5 text-sm leading-6", children: [description && (_jsx("div", { id: descId, className: "max-w-(--measure) text-muted-foreground", children: description })), children] }), footer && (_jsx("div", { className: "flex flex-wrap items-center justify-end gap-(--control-gap) border-t border-border px-5 py-4", children: footer }))] }) }) }));
|
|
17
19
|
}
|
|
18
|
-
const confirmDialogLabels = {
|
|
20
|
+
export const confirmDialogLabels = {
|
|
21
|
+
cancel: 'Cancel',
|
|
19
22
|
typeToConfirm: 'Type {text} to confirm',
|
|
20
23
|
typeExactly: 'Type {text} exactly, including capitals',
|
|
21
24
|
failedTitle: "{action} didn't work",
|
|
@@ -26,8 +29,8 @@ const confirmDialogLabels = {
|
|
|
26
29
|
* role=alertdialog, not dismissed by the backdrop; focus starts on Cancel, or the confirm-text field.
|
|
27
30
|
* Anything reversible should skip this and offer Undo in a toast instead.
|
|
28
31
|
*/
|
|
29
|
-
export function ConfirmDialog({ isOpen, onOpenChange, title, children, confirmLabel, cancelLabel
|
|
30
|
-
const
|
|
32
|
+
export function ConfirmDialog({ isOpen, onOpenChange, title, children, confirmLabel, cancelLabel, tone = 'danger', confirmText, onConfirm, labels: given, }) {
|
|
33
|
+
const t = useLabels('confirmDialog', confirmDialogLabels, given);
|
|
31
34
|
const [typed, setTyped] = useState('');
|
|
32
35
|
const [mismatch, setMismatch] = useState(false);
|
|
33
36
|
const [pending, setPending] = useState(false);
|
|
@@ -58,18 +61,18 @@ export function ConfirmDialog({ isOpen, onOpenChange, title, children, confirmLa
|
|
|
58
61
|
onOpenChange(false);
|
|
59
62
|
}
|
|
60
63
|
catch (e) {
|
|
61
|
-
setError(e instanceof Error && e.message ? e.message :
|
|
64
|
+
setError(e instanceof Error && e.message ? e.message : t('failed'));
|
|
62
65
|
}
|
|
63
66
|
finally {
|
|
64
67
|
setPending(false);
|
|
65
68
|
}
|
|
66
69
|
};
|
|
67
|
-
return (_jsxs(Dialog, { isOpen: isOpen, onOpenChange: (open) => !pending && onOpenChange(open), title: title, role: "alertdialog", isDismissable: false, description: children, footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", slot: "close", autoFocus: !confirmText, isDisabled: pending, children: cancelLabel }), _jsx(Button, { variant: tone === 'danger' ? 'destructive' : 'primary', isPending: pending, onPress: run, children: confirmLabel })] }), children: [confirmText && (_jsx(TextField, { id: fieldId, label:
|
|
70
|
+
return (_jsxs(Dialog, { isOpen: isOpen, onOpenChange: (open) => !pending && onOpenChange(open), title: title, role: "alertdialog", isDismissable: false, description: children, footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", slot: "close", autoFocus: !confirmText, isDisabled: pending, children: cancelLabel ?? t('cancel') }), _jsx(Button, { variant: tone === 'danger' ? 'destructive' : 'primary', isPending: pending, onPress: run, children: confirmLabel })] }), children: [confirmText && (_jsx(TextField, { id: fieldId, label: t('typeToConfirm', { text: confirmText }), value: typed, onChange: (v) => {
|
|
68
71
|
setTyped(v);
|
|
69
72
|
setMismatch(false);
|
|
70
73
|
},
|
|
71
74
|
// Type-to-confirm: the field is the dialog's first task, so it takes focus when the dialog opens.
|
|
72
75
|
// oxlint-disable-next-line jsx-a11y/no-autofocus
|
|
73
|
-
autoFocus: true, autoComplete: "off", spellCheck: "false", isInvalid: mismatch, errorMessage:
|
|
76
|
+
autoFocus: true, autoComplete: "off", spellCheck: "false", isInvalid: mismatch, errorMessage: t('typeExactly', { text: confirmText }) })), error && (_jsx(Alert, { tone: "danger", live: "assertive", title: t('failedTitle', { action: confirmLabel }), children: error }))] }));
|
|
74
77
|
}
|
|
75
78
|
//# sourceMappingURL=dialog.js.map
|
package/dist/ui/dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/ui/dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;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QAAQ,CAAC,CAAC,CAAC,CAAC;oBACZ,WAAW,CAAC,KAAK,CAAC,CAAC;gBACrB,CAAC;gBACD,kGAAkG;gBAClG,iDAAiD;gBACjD,SAAS,QACT,YAAY,EAAC,KAAK,EAClB,UAAU,EAAC,OAAO,EAClB,SAAS,EAAE,QAAQ,EACnB,YAAY,EAAE,CAAC,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,GACrD,CACH,EACA,KAAK,IAAI,CACR,KAAC,KAAK,IAAC,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,WAAW,EAAC,KAAK,EAAE,CAAC,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,YACpF,KAAK,GACA,CACT,IACM,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type DropIndicatorProps as RACDropIndicatorProps } from 'react-aria-components';
|
|
2
|
+
export interface DropIndicatorProps extends Omit<RACDropIndicatorProps, 'className' | 'style'> {
|
|
3
|
+
/**
|
|
4
|
+
* What the line is drawn over. `surface` (the default): the editor's own lists, a 4px `brand` line with a 2px
|
|
5
|
+
* `background` halo. `canvas`: a page the product doesn't style, such as a page builder's canvas, a 4px
|
|
6
|
+
* `canvas-mark` line with a 2px `canvas-mark-halo` halo, the same in every theme, so one of the two tones has
|
|
7
|
+
* 3:1 against whatever is underneath.
|
|
8
|
+
*/
|
|
9
|
+
tone?: 'surface' | 'canvas';
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Where a dragged row will land, between two rows of a Tree or a GridList. Give it to `useDragAndDrop`'s
|
|
14
|
+
* `renderDropIndicator`: `renderDropIndicator: (target) => <DropIndicator target={target} />`.
|
|
15
|
+
*
|
|
16
|
+
* Two tones, so it reads on any surface: a 4px line with a 2px halo. It takes no room until it's the target, so
|
|
17
|
+
* rows never jump while something is dragged over them. React Aria names it for a screen reader ("Insert between
|
|
18
|
+
* Hero and Fixtures") and moves through these by keyboard during a drag.
|
|
19
|
+
*/
|
|
20
|
+
export declare function DropIndicator({ tone, className, ...props }: DropIndicatorProps): import("react").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=drop-indicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-indicator.d.ts","sourceRoot":"","sources":["../../src/ui/drop-indicator.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,kBAAkB,IAAI,qBAAqB,EACjD,MAAM,uBAAuB,CAAC;AAG/B,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,qBAAqB,EAAE,WAAW,GAAG,OAAO,CAAC;IAC5F;;;;;OAKG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,EAAE,IAAgB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,+BAkB1F"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { DropIndicator as RACDropIndicator, } from 'react-aria-components';
|
|
4
|
+
import { cn } from '../lib/cn.js';
|
|
5
|
+
/**
|
|
6
|
+
* Where a dragged row will land, between two rows of a Tree or a GridList. Give it to `useDragAndDrop`'s
|
|
7
|
+
* `renderDropIndicator`: `renderDropIndicator: (target) => <DropIndicator target={target} />`.
|
|
8
|
+
*
|
|
9
|
+
* Two tones, so it reads on any surface: a 4px line with a 2px halo. It takes no room until it's the target, so
|
|
10
|
+
* rows never jump while something is dragged over them. React Aria names it for a screen reader ("Insert between
|
|
11
|
+
* Hero and Fixtures") and moves through these by keyboard during a drag.
|
|
12
|
+
*/
|
|
13
|
+
export function DropIndicator({ tone = 'surface', className, ...props }) {
|
|
14
|
+
return (_jsx(RACDropIndicator, { ...props, className: ({ isDropTarget }) => cn('relative z-10 h-0 outline-none', isDropTarget &&
|
|
15
|
+
"before:absolute before:inset-x-2 before:-top-0.5 before:h-1 before:rounded-full before:content-[''] forced-colors:before:bg-[Highlight] forced-colors:before:forced-color-adjust-none", isDropTarget &&
|
|
16
|
+
(tone === 'canvas'
|
|
17
|
+
? 'before:bg-canvas-mark before:shadow-[0_0_0_2px_var(--canvas-mark-halo)]'
|
|
18
|
+
: 'before:bg-brand before:shadow-[0_0_0_2px_var(--background)]'), className) }));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=drop-indicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-indicator.js","sourceRoot":"","sources":["../../src/ui/drop-indicator.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,aAAa,IAAI,gBAAgB,GAElC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAalC;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,EAAE,IAAI,GAAG,SAAS,EAAE,SAAS,EAAE,GAAG,KAAK,EAAsB;IACzF,OAAO,CACL,KAAC,gBAAgB,OACX,KAAK,EACT,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAC9B,EAAE,CACA,gCAAgC,EAChC,YAAY;YACV,uLAAuL,EACzL,YAAY;YACV,CAAC,IAAI,KAAK,QAAQ;gBAChB,CAAC,CAAC,yEAAyE;gBAC3E,CAAC,CAAC,6DAA6D,CAAC,EACpE,SAAS,CACV,GAEH,CACH,CAAC;AACJ,CAAC"}
|
package/dist/ui/error-state.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { Component, type ErrorInfo, type ReactNode } from 'react';
|
|
2
2
|
export type ErrorKind = 'load' | 'offline' | 'forbidden' | 'not-found' | 'server';
|
|
3
3
|
/**
|
|
4
|
-
* An error state's words, for the `labels` prop; `{reference}` is the reference. Each kind
|
|
5
|
-
* `title` and `children
|
|
4
|
+
* An error state's words, for the `labels` prop; `{reference}` is the reference. Each kind has a title and a
|
|
5
|
+
* body, which an instance's `title` and `children` replace.
|
|
6
6
|
*/
|
|
7
7
|
export interface ErrorStateLabels {
|
|
8
|
+
loadTitle: string;
|
|
9
|
+
loadBody: string;
|
|
10
|
+
offlineTitle: string;
|
|
11
|
+
offlineBody: string;
|
|
12
|
+
forbiddenTitle: string;
|
|
13
|
+
forbiddenBody: string;
|
|
14
|
+
notFoundTitle: string;
|
|
15
|
+
notFoundBody: string;
|
|
16
|
+
serverTitle: string;
|
|
17
|
+
serverBody: string;
|
|
8
18
|
retry: string;
|
|
9
19
|
/** Before the reference. */
|
|
10
20
|
reference: string;
|
|
@@ -15,6 +25,11 @@ export interface ErrorStateLabels {
|
|
|
15
25
|
/** When the browser refuses to copy. */
|
|
16
26
|
copyFailed: string;
|
|
17
27
|
}
|
|
28
|
+
export declare const errorStateLabels: ErrorStateLabels;
|
|
29
|
+
export declare const kindLabels: Record<ErrorKind, {
|
|
30
|
+
title: keyof ErrorStateLabels;
|
|
31
|
+
body: keyof ErrorStateLabels;
|
|
32
|
+
}>;
|
|
18
33
|
export interface ErrorStateProps {
|
|
19
34
|
kind?: ErrorKind;
|
|
20
35
|
/** Override the default title — name the thing: "Projects didn't load". */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-state.d.ts","sourceRoot":"","sources":["../../src/ui/error-state.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EAKT,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAgBf,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"error-state.d.ts","sourceRoot":"","sources":["../../src/ui/error-state.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,SAA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AO,CAAC,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,IAAa,EACb,KAAK,EACL,QAAQ,EACR,OAAO,EACP,SAAS,EACT,OAAO,EACP,YAAgB,EAChB,SAAS,EACT,IAAa,EACb,MAAM,EAAE,KAAK,EACb,SAAS,GACV,EAAE,eAAe,+BA8FjB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,0GAA0G;IAC1G,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,SAAS,CAAC;IAC1D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACnD;AAED,8GAA8G;AAC9G,qBAAa,aAAc,SAAQ,SAAS,CAAC,kBAAkB,EAAE;IAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CAAE,CAAC;IAC9E,KAAK;QAAK,KAAK,EAAU,KAAK,GAAG,IAAI;MAAG;IACjD,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;;MAE3C;IACQ,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,QAEvD;IACD,KAAK,aAAwC;IACpC,MAAM,gUASd;CACF"}
|
package/dist/ui/error-state.js
CHANGED
|
@@ -3,37 +3,27 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { Component, useEffect, useId, useRef, useState, } from 'react';
|
|
4
4
|
import { CircleAlert, Copy, FileQuestionMark, Lock, RefreshCw, ServerCrash, WifiOff, } from 'lucide-react';
|
|
5
5
|
import { cn } from '../lib/cn.js';
|
|
6
|
-
import {
|
|
6
|
+
import { useLabels } from '../lib/locale.js';
|
|
7
7
|
import { Button } from './button.js';
|
|
8
8
|
import { StatusMessage } from './form.js';
|
|
9
|
-
const
|
|
10
|
-
load:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
offline: {
|
|
16
|
-
Icon: WifiOff,
|
|
17
|
-
title: "You're offline",
|
|
18
|
-
body: "This page needs a connection. It will load when you're back online, or you can try again now.",
|
|
19
|
-
},
|
|
20
|
-
forbidden: {
|
|
21
|
-
Icon: Lock,
|
|
22
|
-
title: "You don't have access to this",
|
|
23
|
-
body: 'Ask a workspace owner to give you access, or switch to a workspace you belong to.',
|
|
24
|
-
},
|
|
25
|
-
'not-found': {
|
|
26
|
-
Icon: FileQuestionMark,
|
|
27
|
-
title: 'Page not found',
|
|
28
|
-
body: 'The link may be out of date, or the page was moved or deleted. Check the address, or go back to the overview.',
|
|
29
|
-
},
|
|
30
|
-
server: {
|
|
31
|
-
Icon: ServerCrash,
|
|
32
|
-
title: 'Something went wrong on our side',
|
|
33
|
-
body: "It isn't anything you did. Try again in a minute; if it keeps happening, contact support and quote the reference below.",
|
|
34
|
-
},
|
|
9
|
+
const icons = {
|
|
10
|
+
load: CircleAlert,
|
|
11
|
+
offline: WifiOff,
|
|
12
|
+
forbidden: Lock,
|
|
13
|
+
'not-found': FileQuestionMark,
|
|
14
|
+
server: ServerCrash,
|
|
35
15
|
};
|
|
36
|
-
const errorStateLabels = {
|
|
16
|
+
export const errorStateLabels = {
|
|
17
|
+
loadTitle: "This didn't load",
|
|
18
|
+
loadBody: 'Check your connection and try again. If it keeps happening, contact support and quote the reference below.',
|
|
19
|
+
offlineTitle: "You're offline",
|
|
20
|
+
offlineBody: "This page needs a connection. It will load when you're back online, or you can try again now.",
|
|
21
|
+
forbiddenTitle: "You don't have access to this",
|
|
22
|
+
forbiddenBody: 'Ask a workspace owner to give you access, or switch to a workspace you belong to.',
|
|
23
|
+
notFoundTitle: 'Page not found',
|
|
24
|
+
notFoundBody: 'The link may be out of date, or the page was moved or deleted. Check the address, or go back to the overview.',
|
|
25
|
+
serverTitle: 'Something went wrong on our side',
|
|
26
|
+
serverBody: "It isn't anything you did. Try again in a minute; if it keeps happening, contact support and quote the reference below.",
|
|
37
27
|
retry: 'Try again',
|
|
38
28
|
reference: 'Reference',
|
|
39
29
|
copy: 'Copy',
|
|
@@ -41,13 +31,21 @@ const errorStateLabels = {
|
|
|
41
31
|
copied: 'Reference copied',
|
|
42
32
|
copyFailed: 'Select the reference and copy it',
|
|
43
33
|
};
|
|
34
|
+
export const kindLabels = {
|
|
35
|
+
load: { title: 'loadTitle', body: 'loadBody' },
|
|
36
|
+
offline: { title: 'offlineTitle', body: 'offlineBody' },
|
|
37
|
+
forbidden: { title: 'forbiddenTitle', body: 'forbiddenBody' },
|
|
38
|
+
'not-found': { title: 'notFoundTitle', body: 'notFoundBody' },
|
|
39
|
+
server: { title: 'serverTitle', body: 'serverBody' },
|
|
40
|
+
};
|
|
44
41
|
/**
|
|
45
42
|
* Something failed: says what happened in plain words, that it isn't the person's fault when it isn't,
|
|
46
43
|
* and what to do next. Never a raw error message or stack trace.
|
|
47
44
|
*/
|
|
48
45
|
export function ErrorState({ kind = 'load', title, children, onRetry, reference, actions, headingLevel = 2, autoFocus, size = 'page', labels: given, className, }) {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
46
|
+
const t = useLabels('errorState', errorStateLabels, given);
|
|
47
|
+
const Icon = icons[kind];
|
|
48
|
+
const words = kindLabels[kind];
|
|
51
49
|
const H = `h${headingLevel}`;
|
|
52
50
|
const headingRef = useRef(null);
|
|
53
51
|
const headingId = useId();
|
|
@@ -68,15 +66,15 @@ export function ErrorState({ kind = 'load', title, children, onRetry, reference,
|
|
|
68
66
|
setPending(false);
|
|
69
67
|
}
|
|
70
68
|
};
|
|
71
|
-
return (_jsxs("div", { role: "group", "aria-labelledby": headingId, className: cn('mx-auto flex max-w-(--measure) flex-col items-center px-6 text-center', size === 'page' ? 'py-16' : 'py-10', className), children: [_jsx("span", { "aria-hidden": "true", className: cn('mb-4 grid place-items-center rounded-full bg-destructive-subtle text-destructive', size === 'page' ? 'size-14' : 'size-11'), children: _jsx(
|
|
69
|
+
return (_jsxs("div", { role: "group", "aria-labelledby": headingId, className: cn('mx-auto flex max-w-(--measure) flex-col items-center px-6 text-center', size === 'page' ? 'py-16' : 'py-10', className), children: [_jsx("span", { "aria-hidden": "true", className: cn('mb-4 grid place-items-center rounded-full bg-destructive-subtle text-destructive', size === 'page' ? 'size-14' : 'size-11'), children: _jsx(Icon, { className: size === 'page' ? 'size-7' : 'size-5' }) }), _jsx(H, { ref: headingRef, id: headingId, tabIndex: -1, className: cn('outline-none focus-visible:focus-ring rounded-sm', size === 'page' ? 'text-heading' : 'text-subheading'), children: title ?? t(words.title) }), _jsx("div", { className: "mt-2 text-[15px] leading-6 text-muted-foreground", children: children ?? t(words.body) }), (onRetry || actions) && (_jsxs("div", { className: "mt-6 flex flex-wrap items-center justify-center gap-(--control-gap)", children: [onRetry && (_jsxs(Button, { variant: "primary", isPending: pending, onPress: retry, children: [_jsx(RefreshCw, { "aria-hidden": "true" }), t('retry')] })), actions] })), reference && (_jsxs("div", { className: "mt-6 flex flex-col items-center gap-1", children: [_jsxs("p", { className: "flex flex-wrap items-center justify-center gap-2 text-[13px] text-muted-foreground", children: [t('reference'), ' ', _jsx("code", { className: "rounded-sm bg-muted px-1.5 py-0.5 font-mono text-foreground", children: reference }), _jsxs(Button, { variant: "ghost", visualSize: "sm", "aria-label": t('copyReference', { reference }), onPress: async () => {
|
|
72
70
|
try {
|
|
73
71
|
await navigator.clipboard.writeText(reference);
|
|
74
|
-
setCopied(
|
|
72
|
+
setCopied(t('copied'));
|
|
75
73
|
}
|
|
76
74
|
catch {
|
|
77
|
-
setCopied(
|
|
75
|
+
setCopied(t('copyFailed'));
|
|
78
76
|
}
|
|
79
|
-
}, children: [_jsx(Copy, { "aria-hidden": "true" }),
|
|
77
|
+
}, children: [_jsx(Copy, { "aria-hidden": "true" }), t('copy')] })] }), _jsx(StatusMessage, { tone: "neutral", children: copied })] }))] }));
|
|
80
78
|
}
|
|
81
79
|
/** Contains a failing widget so the rest of the page keeps working. (Route segments use Next's error.tsx.) */
|
|
82
80
|
export class ErrorBoundary extends Component {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-state.js","sourceRoot":"","sources":["../../src/ui/error-state.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,SAAS,EACT,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,WAAW,EACX,IAAI,EACJ,gBAAgB,EAChB,IAAI,EACJ,SAAS,EACT,WAAW,EACX,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"error-state.js","sourceRoot":"","sources":["../../src/ui/error-state.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,SAAS,EACT,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,WAAW,EACX,IAAI,EACJ,gBAAgB,EAChB,IAAI,EACJ,SAAS,EACT,WAAW,EACX,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAK1C,MA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'react-aria-components';
|
|
3
3
|
import { type IconProp } from './icon.js';
|
|
4
4
|
type HeadingLevel = 1 | 2 | 3 | 4 | 5;
|
|
5
|
+
/**
|
|
6
|
+
* A feature card's words, for the `labels` prop. `{label}` is what the panel holds: `label`, or the `label` word
|
|
7
|
+
* here. The toggle shows `show` or `hide` and is named by `showName` or `hideName`, which should contain the word
|
|
8
|
+
* it shows, so a voice command for what's on screen reaches it.
|
|
9
|
+
*/
|
|
10
|
+
export interface FeatureCardLabels {
|
|
11
|
+
/** What the panel holds, when there is no `label` prop. */
|
|
12
|
+
label: string;
|
|
13
|
+
show: string;
|
|
14
|
+
hide: string;
|
|
15
|
+
showName: string;
|
|
16
|
+
hideName: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const featureCardLabels: FeatureCardLabels;
|
|
5
19
|
export interface FeatureCardProps extends Omit<RACDisclosureProps, 'children' | 'className'> {
|
|
6
20
|
/** The heading: a greeting ("Good morning, Ana") or what the card holds ("What's new"). */
|
|
7
21
|
title: ReactNode;
|
|
@@ -10,8 +24,8 @@ export interface FeatureCardProps extends Omit<RACDisclosureProps, 'children' |
|
|
|
10
24
|
/** In a tile before the title: a `TimeOfDayIcon` beside a greeting, or any icon. Decorative. */
|
|
11
25
|
icon?: IconProp;
|
|
12
26
|
/**
|
|
13
|
-
* What the panel holds, default "What's new". It
|
|
14
|
-
* shown while the card is closed, and is the panel's heading, which only a screen reader shows.
|
|
27
|
+
* What the panel holds, default "What's new" (`labels.label`). It fills the toggle's name ("Show What's new"),
|
|
28
|
+
* leads the line shown while the card is closed, and is the panel's heading, which only a screen reader shows.
|
|
15
29
|
*/
|
|
16
30
|
label?: string;
|
|
17
31
|
/** Under the title while the card is open: "Here's what's new since you were last here on 28 September." */
|
|
@@ -29,6 +43,7 @@ export interface FeatureCardProps extends Omit<RACDisclosureProps, 'children' |
|
|
|
29
43
|
featured?: ReactNode;
|
|
30
44
|
/** The other updates: `FeatureCardItem`s, beside the featured one on a wide card and under it on a narrow one. */
|
|
31
45
|
children?: ReactNode;
|
|
46
|
+
labels?: Partial<FeatureCardLabels>;
|
|
32
47
|
className?: string;
|
|
33
48
|
}
|
|
34
49
|
/**
|
|
@@ -46,7 +61,7 @@ export interface FeatureCardProps extends Omit<RACDisclosureProps, 'children' |
|
|
|
46
61
|
* first frame. At AAA nothing moves (the icon only fades in) and the card has no dots or ripple; under reduced
|
|
47
62
|
* motion nothing animates.
|
|
48
63
|
*/
|
|
49
|
-
export declare function FeatureCard({ title, headingLevel, icon, label, description, count, summary, action, featured, children, defaultExpanded, className, ...props }: FeatureCardProps): import("react").JSX.Element;
|
|
64
|
+
export declare function FeatureCard({ title, headingLevel, icon, label: givenLabel, description, count, summary, action, featured, children, defaultExpanded, labels, className, ...props }: FeatureCardProps): import("react").JSX.Element;
|
|
50
65
|
interface FeatureCardItemBase {
|
|
51
66
|
/** The update's name: "Visual comparisons for every run". */
|
|
52
67
|
title: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-card.d.ts","sourceRoot":"","sources":["../../src/ui/feature-card.tsx"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,
|
|
1
|
+
{"version":3,"file":"feature-card.d.ts","sourceRoot":"","sources":["../../src/ui/feature-card.tsx"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAKL,KAAK,eAAe,IAAI,kBAAkB,EAC3C,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGtD,KAAK,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAQtC;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,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AAmD;IACnD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,yDAAyD;IACzD,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,yEAAyE;IACzE,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GACpD,CACI;IACE,2GAA2G;IAC3G,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,GACD;IACE,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,sGAAsG;IACtG,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,CACJ,CAAC;AAEJ;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,GAAG,EACH,IAAI,EACJ,WAAW,EACX,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,SAAS,GACV,EAAE,oBAAoB,+BA0FtB"}
|
package/dist/ui/feature-card.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Children, createContext, useContext, useId, } from 'react';
|
|
4
4
|
import { ArrowRight, ChevronDown } from 'lucide-react';
|
|
5
|
-
import { Disclosure as RACDisclosure, DisclosurePanel, Link as RACLink, } from 'react-aria-components';
|
|
5
|
+
import { Disclosure as RACDisclosure, DisclosurePanel, DisclosureStateContext, Link as RACLink, } from 'react-aria-components';
|
|
6
6
|
import { cn } from '../lib/cn.js';
|
|
7
|
+
import { useLabels } from '../lib/locale.js';
|
|
7
8
|
import { Button } from './button.js';
|
|
8
9
|
import { renderIcon } from './icon.js';
|
|
9
10
|
import { Tag } from './tag.js';
|
|
@@ -12,6 +13,13 @@ const ItemContext = createContext({
|
|
|
12
13
|
headingLevel: 3,
|
|
13
14
|
featured: false,
|
|
14
15
|
});
|
|
16
|
+
export const featureCardLabels = {
|
|
17
|
+
label: "What's new",
|
|
18
|
+
show: 'Show',
|
|
19
|
+
hide: 'Hide',
|
|
20
|
+
showName: 'Show {label}',
|
|
21
|
+
hideName: 'Hide {label}',
|
|
22
|
+
};
|
|
15
23
|
/**
|
|
16
24
|
* The card at the top of an overview: a title (a greeting, often) with an icon, and a panel of what's new that
|
|
17
25
|
* the person can show and hide. React Aria's Disclosure: the Show/Hide button is the trigger, with
|
|
@@ -27,19 +35,26 @@ const ItemContext = createContext({
|
|
|
27
35
|
* first frame. At AAA nothing moves (the icon only fades in) and the card has no dots or ripple; under reduced
|
|
28
36
|
* motion nothing animates.
|
|
29
37
|
*/
|
|
30
|
-
export function FeatureCard({ title, headingLevel = 2, icon, label
|
|
38
|
+
export function FeatureCard({ title, headingLevel = 2, icon, label: givenLabel, description, count, summary, action, featured, children, defaultExpanded = true, labels, className, ...props }) {
|
|
39
|
+
const t = useLabels('featureCard', featureCardLabels, labels);
|
|
40
|
+
const label = givenLabel ?? t('label');
|
|
31
41
|
const Heading = `h${headingLevel}`;
|
|
32
42
|
const PanelHeading = `h${headingLevel + 1}`;
|
|
33
43
|
const itemLevel = (headingLevel + 2);
|
|
34
44
|
const itemCount = Children.toArray(children).length;
|
|
35
45
|
return (_jsxs(RACDisclosure, { ...props, defaultExpanded: defaultExpanded, className: cn('group/feature-card @container/feature-card arrive-rise relative overflow-clip rounded-lg border border-border bg-card text-card-foreground shadow-(--shadow-sm)', className), children: [_jsx("div", { "aria-hidden": "true", className: "feature-dots" }), _jsx("div", { "aria-hidden": "true", className: "feature-ripple [--feature-ripple-origin:40px_40px] @min-[35rem]/feature-card:[--feature-ripple-origin:48px_44px]" }), _jsxs("div", { className: cn('relative grid items-center gap-x-4 gap-y-3 p-4 @min-[35rem]/feature-card:px-6 @min-[35rem]/feature-card:py-5', icon
|
|
36
46
|
? "grid-cols-[auto_minmax(0,1fr)] [grid-template-areas:'icon_toggle'_'text_text'] @min-[35rem]/feature-card:grid-cols-[auto_minmax(0,1fr)_auto] @min-[35rem]/feature-card:[grid-template-areas:'icon_text_toggle']"
|
|
37
|
-
: "grid-cols-[minmax(0,1fr)_auto] [grid-template-areas:'text_toggle']"), children: [icon && (_jsx("span", { "aria-hidden": "true", className: "arrive-pop grid size-12 place-items-center rounded-xl border border-border bg-background text-foreground [grid-area:icon]", style: { animationDelay: '60ms' }, children: renderIcon(icon, 'size-8') })), _jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-3.5 gap-y-1 [grid-area:text]", children: [_jsx(Heading, { className: "text-title text-foreground", children: title }), description && (_jsx("p", { className: "hidden basis-full text-body text-muted-foreground group-data-expanded/feature-card:block", children: description })), _jsxs("p", { className: "flex flex-wrap items-center gap-x-2.5 gap-y-1 text-ui text-muted-foreground group-data-expanded/feature-card:hidden", children: [_jsx("span", { "aria-hidden": "true", className: "hidden h-5 w-px bg-border @min-[35rem]/feature-card:block" }), _jsx("strong", { className: "text-ui-strong text-foreground", children: label }), count && (_jsx("span", { className: "inline-flex h-[22px] items-center rounded-full bg-foreground px-2 text-caption-strong text-background", children: count })), summary && _jsx("span", { children: summary })] })] }), _jsxs("div", { className: "flex items-center gap-(--control-gap) justify-self-end [grid-area:toggle]", children: [action && (_jsx("div", { className: "hidden items-center gap-(--control-gap) group-data-expanded/feature-card:flex", children: action })),
|
|
47
|
+
: "grid-cols-[minmax(0,1fr)_auto] [grid-template-areas:'text_toggle']"), children: [icon && (_jsx("span", { "aria-hidden": "true", className: "arrive-pop grid size-12 place-items-center rounded-xl border border-border bg-background text-foreground [grid-area:icon]", style: { animationDelay: '60ms' }, children: renderIcon(icon, 'size-8') })), _jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-3.5 gap-y-1 [grid-area:text]", children: [_jsx(Heading, { className: "text-title text-foreground", children: title }), description && (_jsx("p", { className: "hidden basis-full text-body text-muted-foreground group-data-expanded/feature-card:block", children: description })), _jsxs("p", { className: "flex flex-wrap items-center gap-x-2.5 gap-y-1 text-ui text-muted-foreground group-data-expanded/feature-card:hidden", children: [_jsx("span", { "aria-hidden": "true", className: "hidden h-5 w-px bg-border @min-[35rem]/feature-card:block" }), _jsx("strong", { className: "text-ui-strong text-foreground", children: label }), count && (_jsx("span", { className: "inline-flex h-[22px] items-center rounded-full bg-foreground px-2 text-caption-strong text-background", children: count })), summary && _jsx("span", { children: summary })] })] }), _jsxs("div", { className: "flex items-center gap-(--control-gap) justify-self-end [grid-area:toggle]", children: [action && (_jsx("div", { className: "hidden items-center gap-(--control-gap) group-data-expanded/feature-card:flex", children: action })), _jsx(FeatureCardToggle, { label: label, t: t })] })] }), _jsx(DisclosurePanel, { className: "relative", children: _jsxs("div", { className: "flex flex-col px-4 pb-4 @min-[35rem]/feature-card:px-6 @min-[35rem]/feature-card:pb-6", children: [_jsx(PanelHeading, { className: "sr-only", children: label }), _jsxs("ul", {
|
|
38
48
|
// oxlint-disable-next-line jsx-a11y/no-redundant-roles -- VoiceOver in Safari drops a list with no markers.
|
|
39
49
|
role: "list", style: { '--feature-card-rows': Math.max(1, itemCount) }, className: cn('grid gap-4', featured
|
|
40
50
|
? '@min-[56rem]/feature-card:grid-cols-[minmax(0,1.7fr)_minmax(0,1fr)]'
|
|
41
51
|
: 'grid-cols-[repeat(auto-fit,minmax(min(18rem,100%),1fr))]'), children: [featured && (_jsx("li", { className: "arrive-rise grid @min-[56rem]/feature-card:row-span-(--feature-card-rows)", style: { animationDelay: '200ms' }, children: _jsx(ItemContext.Provider, { value: { headingLevel: itemLevel, featured: true }, children: featured }) })), _jsx(ItemContext.Provider, { value: { headingLevel: itemLevel, featured: false }, children: Children.map(children, (child, i) => child == null || typeof child === 'boolean' ? null : (_jsx("li", { className: "arrive-rise grid", style: { animationDelay: `${(featured ? 280 : 200) + i * 80}ms` }, children: child }))) })] })] }) })] }));
|
|
42
52
|
}
|
|
53
|
+
/** Show or Hide, named with what the panel holds. Reads the open state from the Disclosure around it. */
|
|
54
|
+
function FeatureCardToggle({ label, t }) {
|
|
55
|
+
const expanded = useContext(DisclosureStateContext)?.isExpanded ?? false;
|
|
56
|
+
return (_jsxs(Button, { slot: "trigger", variant: "ghost", "aria-label": expanded ? t('hideName', { label }) : t('showName', { label }), children: [_jsx(ChevronDown, { "aria-hidden": "true", className: "group-data-expanded/feature-card:rotate-180" }), expanded ? t('hide') : t('show')] }));
|
|
57
|
+
}
|
|
43
58
|
/**
|
|
44
59
|
* One update in a FeatureCard: a picture, a tag and a date, a title and a description. In the card's `featured`
|
|
45
60
|
* slot it is larger. With `href` the whole item is a link named by everything it shows, as LinkCard is, with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-card.js","sourceRoot":"","sources":["../../src/ui/feature-card.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,QAAQ,EACR,aAAa,EACb,UAAU,EACV,KAAK,GAGN,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,eAAe,EACf,IAAI,IAAI,OAAO,GAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAiB,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAI/B,+FAA+F;AAC/F,MAAM,WAAW,GAAG,aAAa,CAAoD;IACnF,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,KAAK;CAChB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"feature-card.js","sourceRoot":"","sources":["../../src/ui/feature-card.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,QAAQ,EACR,aAAa,EACb,UAAU,EACV,KAAK,GAGN,MAAM,OAAO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SAAS,CAAC,YAC9D,KAAK,GACE,EACT,WAAW,IAAI,CACd,YAAG,SAAS,EAAE,EAAE,CAAC,oCAAoC,EAAE,eAAe,CAAC,YAAG,WAAW,GAAK,CAC3F,EACA,OAAO,IAAI,CACV,cAAK,SAAS,EAAC,8DAA8D,YAC1E,OAAO,GACJ,CACP,IACG,IACE,CACX,CAAC;AACJ,CAAC"}
|
package/dist/ui/field.d.ts
CHANGED
|
@@ -11,25 +11,46 @@ export declare const fieldBox: string;
|
|
|
11
11
|
export declare const fieldInput = "field-input flex-1 cursor-text px-(--control-pad-x) text-sm text-foreground placeholder:text-muted-foreground data-disabled:cursor-not-allowed";
|
|
12
12
|
/** A multi-line input is taller than any target, so it is one layer: the textarea paints its own box. */
|
|
13
13
|
export declare const textAreaStyles: string;
|
|
14
|
+
/**
|
|
15
|
+
* A field's words, for the `labels` prop on every field. `{label}` is the field's label as written: the default
|
|
16
|
+
* required messages say "Enter Email address", so give a field `requiredMessage` where a sentence of its own
|
|
17
|
+
* reads better ("Enter your email address").
|
|
18
|
+
*/
|
|
19
|
+
export interface FieldLabels {
|
|
20
|
+
/** Said before the error, to a screen reader. */
|
|
21
|
+
errorPrefix: string;
|
|
22
|
+
/** After the label of a required field, when the form marks required fields. */
|
|
23
|
+
requiredMarker: string;
|
|
24
|
+
/** After the label of an optional field, when the form marks optional ones. */
|
|
25
|
+
optionalMarker: string;
|
|
26
|
+
/** A required text, number or date field left empty. */
|
|
27
|
+
enterValue: string;
|
|
28
|
+
/** A required select, combo box or radio group left empty. */
|
|
29
|
+
chooseValue: string;
|
|
30
|
+
/** A required checkbox left unticked. */
|
|
31
|
+
checkRequired: string;
|
|
32
|
+
/** A required checkbox group with nothing ticked. */
|
|
33
|
+
checkGroupRequired: string;
|
|
34
|
+
}
|
|
35
|
+
export declare const fieldLabels: FieldLabels;
|
|
36
|
+
/** A field's words: the English defaults, the app's from `SetsquareLocale`, then the field's own `labels`. */
|
|
37
|
+
export declare function useFieldLabels(given: Partial<FieldLabels> | undefined): import("../lib/locale.js").Translate<FieldLabels>;
|
|
14
38
|
export interface FieldLabelProps {
|
|
15
39
|
children: ReactNode;
|
|
16
40
|
isRequired?: boolean;
|
|
17
41
|
/** Render as a plain span (group labels that are not <label>). */
|
|
18
42
|
elementType?: 'label' | 'span';
|
|
43
|
+
/** The field's `labels`, for its marker. */
|
|
44
|
+
labels?: Partial<FieldLabels>;
|
|
19
45
|
className?: string;
|
|
20
46
|
}
|
|
21
47
|
/** The visible label. Adds "(required)" or "(optional)" per the form's NecessityIndicator — hidden from AT, which gets aria-required instead. */
|
|
22
|
-
export declare function FieldLabel({ children, isRequired, elementType, className, }: FieldLabelProps): import("react").JSX.Element;
|
|
48
|
+
export declare function FieldLabel({ children, isRequired, elementType, labels, className, }: FieldLabelProps): import("react").JSX.Element;
|
|
23
49
|
/** Hint text under the label: what to enter, in what format. Linked to the input by aria-describedby. */
|
|
24
50
|
export declare function FieldDescription({ children, className, }: {
|
|
25
51
|
children: ReactNode;
|
|
26
52
|
className?: string;
|
|
27
53
|
}): import("react").JSX.Element;
|
|
28
|
-
/** A field's words, for the `labels` prop on every field. Its required message is `requiredMessage`. */
|
|
29
|
-
export interface FieldLabels {
|
|
30
|
-
/** Said before the error, to a screen reader. */
|
|
31
|
-
errorPrefix: string;
|
|
32
|
-
}
|
|
33
54
|
/**
|
|
34
55
|
* The error, shown only when the field is invalid. Sits between the hint and the input so it is next to the
|
|
35
56
|
* label at high zoom, starts with an icon and a hidden "Error:", and is linked by aria-describedby.
|
|
@@ -37,12 +58,10 @@ export interface FieldLabels {
|
|
|
37
58
|
export declare function FieldError({ children, requiredMessage, errorPrefix, className, }: {
|
|
38
59
|
children?: ReactNode;
|
|
39
60
|
requiredMessage?: string;
|
|
40
|
-
/** `labels.errorPrefix` from the field. */
|
|
61
|
+
/** `labels.errorPrefix` from the field. Default: the app's, from `SetsquareLocale`, or "Error: ". */
|
|
41
62
|
errorPrefix?: string;
|
|
42
63
|
className?: string;
|
|
43
64
|
}): import("react").JSX.Element;
|
|
44
|
-
/** Lower-case the first letter unless the label starts with an acronym ("VAT number"). */
|
|
45
|
-
export declare function lcFirst(label: string): string;
|
|
46
65
|
/**
|
|
47
66
|
* Wrap a field's validate function so an empty required field gets a message that says what to do,
|
|
48
67
|
* instead of the browser's "Please fill out this field".
|