@dxos/react-ui 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7
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/dist/lib/browser/{chunk-CEKVHJ27.mjs → chunk-2FKSMWNY.mjs} +117 -117
- package/dist/lib/browser/chunk-2FKSMWNY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2804 -1957
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +56 -32
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/{chunk-2NHEX4AD.mjs → chunk-ZNBLTSHI.mjs} +117 -117
- package/dist/lib/node-esm/chunk-ZNBLTSHI.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +2804 -1957
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +56 -32
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/components/Avatars/Avatar.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/types/src/components/Button/Button.d.ts.map +1 -1
- package/dist/types/src/components/Card/Card.d.ts +107 -0
- package/dist/types/src/components/Card/Card.d.ts.map +1 -0
- package/dist/types/src/components/Card/Card.stories.d.ts +21 -0
- package/dist/types/src/components/Card/Card.stories.d.ts.map +1 -0
- package/dist/types/src/components/Card/index.d.ts +2 -0
- package/dist/types/src/components/Card/index.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/AlertDialog.d.ts +12 -3
- package/dist/types/src/components/Dialog/AlertDialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/AlertDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.d.ts +11 -4
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts +3 -6
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ErrorFallback/ErrorFallback.d.ts +11 -0
- package/dist/types/src/components/ErrorFallback/ErrorFallback.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/ErrorFallback.stories.d.ts +7 -0
- package/dist/types/src/components/ErrorFallback/ErrorFallback.stories.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/ErrorStack.d.ts +8 -0
- package/dist/types/src/components/ErrorFallback/ErrorStack.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/ThrowError.d.ts +9 -0
- package/dist/types/src/components/ErrorFallback/ThrowError.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/index.d.ts +5 -0
- package/dist/types/src/components/ErrorFallback/index.d.ts.map +1 -0
- package/dist/types/src/components/Image/Image.d.ts +14 -0
- package/dist/types/src/components/Image/Image.d.ts.map +1 -0
- package/dist/types/src/components/Image/Image.stories.d.ts +33 -0
- package/dist/types/src/components/Image/Image.stories.d.ts.map +1 -0
- package/dist/types/src/components/Image/index.d.ts +2 -0
- package/dist/types/src/components/Image/index.d.ts.map +1 -0
- package/dist/types/src/components/Input/Input.d.ts +2 -5
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +7 -7
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/List.d.ts.map +1 -1
- package/dist/types/src/components/List/List.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/Treegrid.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts +9 -10
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts +0 -3
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menu/ContextMenu.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +2 -3
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +1 -0
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts +21 -26
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +41 -9
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts +6 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.d.ts.map +1 -1
- package/dist/types/src/components/Skeleton/Skeleton.d.ts +12 -0
- package/dist/types/src/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/dist/types/src/components/Skeleton/Skeleton.stories.d.ts +17 -0
- package/dist/types/src/components/Skeleton/Skeleton.stories.d.ts.map +1 -0
- package/dist/types/src/components/Skeleton/index.d.ts +2 -0
- package/dist/types/src/components/Skeleton/index.d.ts.map +1 -0
- package/dist/types/src/components/Splitter/Splitter.d.ts +32 -0
- package/dist/types/src/components/Splitter/Splitter.d.ts.map +1 -0
- package/dist/types/src/components/Splitter/Splitter.stories.d.ts +7 -0
- package/dist/types/src/components/Splitter/Splitter.stories.d.ts.map +1 -0
- package/dist/types/src/components/Splitter/index.d.ts +2 -0
- package/dist/types/src/components/Splitter/index.d.ts.map +1 -0
- package/dist/types/src/components/Status/Status.stories.d.ts +4 -2
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.stories.d.ts +0 -5
- package/dist/types/src/components/Tag/Tag.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +1 -0
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.stories.d.ts +12 -0
- package/dist/types/src/components/ThemeProvider/ThemeProvider.stories.d.ts.map +1 -0
- package/dist/types/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +33 -7
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +8 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/exemplars/generics.stories.d.ts +18 -0
- package/dist/types/src/exemplars/generics.stories.d.ts.map +1 -0
- package/dist/types/src/exemplars/slot.stories.d.ts +14 -0
- package/dist/types/src/exemplars/slot.stories.d.ts.map +1 -0
- package/dist/types/src/exemplars/tabster.stories.d.ts +8 -0
- package/dist/types/src/exemplars/tabster.stories.d.ts.map +1 -0
- package/dist/types/src/exemplars/virtualizer.stories.d.ts +11 -0
- package/dist/types/src/exemplars/virtualizer.stories.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/primitives/Column/Column.d.ts +26 -0
- package/dist/types/src/primitives/Column/Column.d.ts.map +1 -0
- package/dist/types/src/primitives/Column/Column.stories.d.ts +6 -0
- package/dist/types/src/primitives/Column/Column.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Column/index.d.ts +2 -0
- package/dist/types/src/primitives/Column/index.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/Container.d.ts +8 -0
- package/dist/types/src/primitives/Container/Container.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/Container.stories.d.ts +6 -0
- package/dist/types/src/primitives/Container/Container.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/index.d.ts +2 -0
- package/dist/types/src/primitives/Container/index.d.ts.map +1 -0
- package/dist/types/src/primitives/Flex/Flex.d.ts +13 -0
- package/dist/types/src/primitives/Flex/Flex.d.ts.map +1 -0
- package/dist/types/src/primitives/Flex/Flex.stories.d.ts +8 -0
- package/dist/types/src/primitives/Flex/Flex.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Flex/index.d.ts +2 -0
- package/dist/types/src/primitives/Flex/index.d.ts.map +1 -0
- package/dist/types/src/primitives/Grid/Grid.d.ts +15 -0
- package/dist/types/src/primitives/Grid/Grid.d.ts.map +1 -0
- package/dist/types/src/primitives/Grid/Grid.stories.d.ts +8 -0
- package/dist/types/src/primitives/Grid/Grid.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Grid/index.d.ts +2 -0
- package/dist/types/src/primitives/Grid/index.d.ts.map +1 -0
- package/dist/types/src/primitives/Panel/Panel.d.ts +26 -0
- package/dist/types/src/primitives/Panel/Panel.d.ts.map +1 -0
- package/dist/types/src/primitives/Panel/Panel.stories.d.ts +6 -0
- package/dist/types/src/primitives/Panel/Panel.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Panel/index.d.ts +2 -0
- package/dist/types/src/primitives/Panel/index.d.ts.map +1 -0
- package/dist/types/src/primitives/index.d.ts +6 -0
- package/dist/types/src/primitives/index.d.ts.map +1 -0
- package/dist/types/src/testing/Loading.d.ts +9 -0
- package/dist/types/src/testing/Loading.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/withLayout.d.ts +1 -1
- package/dist/types/src/testing/decorators/withLayout.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withLayoutVariants.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withTheme.d.ts +3 -2
- package/dist/types/src/testing/decorators/withTheme.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +11 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -21
- package/src/components/Avatars/Avatar.stories.tsx +5 -6
- package/src/components/Avatars/Avatar.tsx +5 -12
- package/src/components/Avatars/AvatarGroup.stories.tsx +2 -2
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +3 -3
- package/src/components/Breadcrumb/Breadcrumb.tsx +11 -37
- package/src/components/Button/Button.stories.tsx +3 -3
- package/src/components/Button/Button.tsx +6 -12
- package/src/components/Button/IconButton.stories.tsx +4 -4
- package/src/components/Button/IconButton.tsx +1 -1
- package/src/components/Button/Toggle.stories.tsx +2 -2
- package/src/components/Button/ToggleGroup.stories.tsx +2 -2
- package/src/components/Card/Card.stories.tsx +151 -0
- package/src/components/Card/Card.tsx +347 -0
- package/src/components/Card/index.ts +5 -0
- package/src/components/Clipboard/CopyButton.tsx +3 -3
- package/src/components/Dialog/AlertDialog.stories.tsx +15 -15
- package/src/components/Dialog/AlertDialog.tsx +116 -16
- package/src/components/Dialog/Dialog.stories.tsx +40 -15
- package/src/components/Dialog/Dialog.tsx +75 -45
- package/src/components/ErrorFallback/ErrorFallback.stories.tsx +50 -0
- package/src/components/ErrorFallback/ErrorFallback.tsx +70 -0
- package/src/components/ErrorFallback/ErrorStack.tsx +80 -0
- package/src/components/ErrorFallback/ThrowError.tsx +37 -0
- package/src/components/ErrorFallback/index.ts +9 -0
- package/src/components/Icon/Icon.stories.tsx +2 -2
- package/src/components/Icon/Icon.tsx +1 -1
- package/src/components/Image/Image.stories.tsx +86 -0
- package/src/components/Image/Image.tsx +223 -0
- package/src/components/Image/index.ts +5 -0
- package/src/components/Input/Input.stories.tsx +20 -39
- package/src/components/Input/Input.tsx +20 -65
- package/src/components/Link/Link.stories.tsx +2 -2
- package/src/components/Link/Link.tsx +2 -2
- package/src/components/List/List.stories.tsx +15 -22
- package/src/components/List/List.tsx +11 -16
- package/src/components/List/ListDropIndicator.tsx +7 -7
- package/src/components/List/Tree.stories.tsx +4 -4
- package/src/components/List/TreeDropIndicator.tsx +6 -6
- package/src/components/List/Treegrid.stories.tsx +3 -3
- package/src/components/List/Treegrid.tsx +10 -15
- package/src/components/Main/Main.stories.tsx +41 -23
- package/src/components/Main/Main.tsx +138 -81
- package/src/components/Menu/ContextMenu.stories.tsx +2 -2
- package/src/components/Menu/ContextMenu.tsx +9 -33
- package/src/components/Menu/DropdownMenu.stories.tsx +2 -2
- package/src/components/Menu/DropdownMenu.tsx +10 -10
- package/src/components/Message/Message.stories.tsx +25 -10
- package/src/components/Message/Message.tsx +17 -29
- package/src/components/Popover/Popover.stories.tsx +4 -4
- package/src/components/Popover/Popover.tsx +23 -20
- package/src/components/ScrollArea/ScrollArea.stories.tsx +152 -76
- package/src/components/ScrollArea/ScrollArea.tsx +72 -116
- package/src/components/ScrollArea/index.ts +1 -1
- package/src/components/ScrollContainer/ScrollContainer.stories.tsx +41 -22
- package/src/components/ScrollContainer/ScrollContainer.tsx +18 -13
- package/src/components/Select/Select.stories.tsx +2 -2
- package/src/components/Select/Select.tsx +11 -27
- package/src/components/Separator/Separator.tsx +1 -1
- package/src/components/Skeleton/Skeleton.stories.tsx +52 -0
- package/src/components/Skeleton/Skeleton.tsx +26 -0
- package/src/components/Skeleton/index.ts +5 -0
- package/src/components/Splitter/Splitter.stories.tsx +83 -0
- package/src/components/Splitter/Splitter.tsx +126 -0
- package/src/components/Splitter/index.ts +5 -0
- package/src/components/Status/Status.stories.tsx +21 -17
- package/src/components/Status/Status.tsx +2 -2
- package/src/components/Tag/Tag.stories.tsx +4 -9
- package/src/components/Tag/Tag.tsx +2 -7
- package/src/components/ThemeProvider/ThemeProvider.stories.tsx +32 -0
- package/src/components/ThemeProvider/ThemeProvider.tsx +4 -3
- package/src/components/Toast/Toast.stories.tsx +2 -2
- package/src/components/Toast/Toast.tsx +10 -14
- package/src/components/Toolbar/Toolbar.stories.tsx +2 -2
- package/src/components/Toolbar/Toolbar.tsx +174 -12
- package/src/components/Tooltip/Tooltip.stories.tsx +15 -13
- package/src/components/Tooltip/Tooltip.tsx +3 -2
- package/src/components/index.ts +9 -5
- package/src/exemplars/generics.stories.tsx +49 -0
- package/src/exemplars/slot.stories.tsx +107 -0
- package/src/exemplars/tabster.stories.tsx +127 -0
- package/src/exemplars/virtualizer.stories.tsx +137 -0
- package/src/index.ts +1 -0
- package/src/playground/Controls.stories.tsx +3 -10
- package/src/playground/Custom.stories.tsx +10 -10
- package/src/playground/Typography.stories.tsx +3 -3
- package/src/primitives/Column/Column.stories.tsx +78 -0
- package/src/primitives/Column/Column.tsx +134 -0
- package/src/primitives/Column/index.ts +5 -0
- package/src/primitives/Container/Container.stories.tsx +30 -0
- package/src/primitives/Container/Container.tsx +22 -0
- package/src/primitives/Container/index.ts +5 -0
- package/src/primitives/Flex/Flex.stories.tsx +58 -0
- package/src/primitives/Flex/Flex.tsx +29 -0
- package/src/primitives/Flex/index.ts +5 -0
- package/src/primitives/Grid/Grid.stories.tsx +57 -0
- package/src/primitives/Grid/Grid.tsx +35 -0
- package/src/primitives/Grid/index.ts +5 -0
- package/src/primitives/Panel/Panel.stories.tsx +67 -0
- package/src/primitives/Panel/Panel.tsx +119 -0
- package/src/primitives/Panel/index.ts +5 -0
- package/src/primitives/index.ts +9 -0
- package/src/testing/Loading.tsx +26 -0
- package/src/testing/decorators/withLayout.tsx +21 -7
- package/src/testing/decorators/withLayoutVariants.tsx +18 -21
- package/src/testing/decorators/withTheme.tsx +19 -17
- package/src/testing/index.ts +2 -0
- package/src/translations.ts +19 -0
- package/dist/lib/browser/chunk-CEKVHJ27.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2NHEX4AD.mjs.map +0 -7
- package/dist/types/src/components/AnchoredOverflow/AnchoredOverflow.d.ts +0 -15
- package/dist/types/src/components/AnchoredOverflow/AnchoredOverflow.d.ts.map +0 -1
- package/dist/types/src/components/AnchoredOverflow/index.d.ts +0 -2
- package/dist/types/src/components/AnchoredOverflow/index.d.ts.map +0 -1
- package/src/components/AnchoredOverflow/AnchoredOverflow.tsx +0 -59
- package/src/components/AnchoredOverflow/index.ts +0 -5
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import ErrorStackParser from 'error-stack-parser';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { mx } from '@dxos/ui-theme';
|
|
9
|
+
|
|
10
|
+
type LocalFrame = { href: string; fileName: string };
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Renders a parsed error stack trace with tree connector symbols and clickable vscode:// links for local frames.
|
|
14
|
+
*/
|
|
15
|
+
export const ErrorStack = ({ error }: { error: Error }) => {
|
|
16
|
+
const frames = ErrorStackParser.parse(error);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className='font-mono text-sm'>
|
|
20
|
+
{frames.map((frame, i) => {
|
|
21
|
+
const isLast = i === frames.length - 1;
|
|
22
|
+
const local = frame.fileName
|
|
23
|
+
? parseLocalFrame(frame.fileName, frame.lineNumber, frame.columnNumber)
|
|
24
|
+
: undefined;
|
|
25
|
+
const name = frame.functionName ?? '<anonymous>';
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
key={i}
|
|
29
|
+
className={mx(
|
|
30
|
+
'grid grid-cols-[16px_1fr_auto_auto] items-stretch gap-x-2',
|
|
31
|
+
local && 'cursor-pointer hover:bg-hover-surface',
|
|
32
|
+
)}
|
|
33
|
+
>
|
|
34
|
+
{/* Tree connector: vertical line full-height + horizontal branch at midpoint */}
|
|
35
|
+
<div className='relative'>
|
|
36
|
+
<div
|
|
37
|
+
className={mx(
|
|
38
|
+
'absolute left-1/2 -translate-x-1/2 w-px bg-neutral-500',
|
|
39
|
+
isLast ? 'top-0 h-1/2' : 'inset-y-0',
|
|
40
|
+
)}
|
|
41
|
+
/>
|
|
42
|
+
<div className='absolute top-1/2 -translate-y-1/2 left-1/2 right-0 h-px bg-neutral-500' />
|
|
43
|
+
</div>
|
|
44
|
+
{local ? (
|
|
45
|
+
<a href={local.href} className='truncate self-center'>
|
|
46
|
+
{name}
|
|
47
|
+
</a>
|
|
48
|
+
) : (
|
|
49
|
+
<span className='text-subdued truncate self-center'>{name}</span>
|
|
50
|
+
)}
|
|
51
|
+
<span className='text-xs text-subdued truncate self-center'>{local?.fileName ?? ''}</span>
|
|
52
|
+
<span className='text-xs text-subdued text-right self-center'>
|
|
53
|
+
{local ? `${frame.lineNumber}:${frame.columnNumber}` : ''}
|
|
54
|
+
</span>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
})}
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Parses a Vite `/@fs/` URL into a `vscode://` deep link and short filename.
|
|
64
|
+
* Returns undefined if the URL cannot be resolved to a local file.
|
|
65
|
+
*/
|
|
66
|
+
const parseLocalFrame = (fileUrl: string, line?: number, col?: number): LocalFrame | undefined => {
|
|
67
|
+
try {
|
|
68
|
+
const { pathname } = new URL(fileUrl);
|
|
69
|
+
if (!pathname.startsWith('/@fs/')) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
const localPath = pathname.slice(4); // /@fs/Users/... → /Users/...
|
|
73
|
+
return {
|
|
74
|
+
href: `vscode://file/${localPath}:${line ?? 1}:${col ?? 1}`,
|
|
75
|
+
fileName: pathname.split('/').pop() ?? localPath,
|
|
76
|
+
};
|
|
77
|
+
} catch {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
export type ThrowErrorProps = {
|
|
8
|
+
error?: () => Error;
|
|
9
|
+
delay?: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Use this to debug the error boundary.
|
|
14
|
+
*/
|
|
15
|
+
export const ThrowError = ({ delay = 1_000, ...props }: ThrowErrorProps) => {
|
|
16
|
+
const [error, setError] = useState<Error>();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (delay < 0) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const t = setTimeout(() => {
|
|
23
|
+
setError(generator({ delay, ...props }));
|
|
24
|
+
}, delay);
|
|
25
|
+
return () => clearTimeout(t);
|
|
26
|
+
}, [delay, generator]);
|
|
27
|
+
|
|
28
|
+
if (error) {
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const generator = ({ error, delay }: ThrowErrorProps) => {
|
|
36
|
+
return error?.() ?? new Error(`Error generated after ${delay}ms`);
|
|
37
|
+
};
|
|
@@ -60,9 +60,9 @@ const DefaultStory = ({ CustomIcon }: { CustomIcon: FC<IconProps> }) => {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
const meta = {
|
|
63
|
-
title: 'ui/react-ui-core/Icon',
|
|
63
|
+
title: 'ui/react-ui-core/components/Icon',
|
|
64
64
|
render: DefaultStory,
|
|
65
|
-
decorators: [withTheme],
|
|
65
|
+
decorators: [withTheme()],
|
|
66
66
|
parameters: {
|
|
67
67
|
layout: 'centered',
|
|
68
68
|
},
|
|
@@ -20,7 +20,7 @@ export const Icon = memo(
|
|
|
20
20
|
const { tx } = useThemeContext();
|
|
21
21
|
const href = useIconHref(icon);
|
|
22
22
|
return (
|
|
23
|
-
<svg {...props} className={tx('icon.root',
|
|
23
|
+
<svg {...props} className={tx('icon.root', { size }, classNames)} ref={forwardedRef}>
|
|
24
24
|
<use href={href} />
|
|
25
25
|
</svg>
|
|
26
26
|
);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { faker } from '@dxos/random';
|
|
9
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
10
|
+
|
|
11
|
+
import { Image } from './Image';
|
|
12
|
+
|
|
13
|
+
const seed = Math.random();
|
|
14
|
+
|
|
15
|
+
faker.seed(seed);
|
|
16
|
+
|
|
17
|
+
const meta = {
|
|
18
|
+
title: 'ui/react-ui-mosaic/Image',
|
|
19
|
+
component: Image,
|
|
20
|
+
render: (args) => (
|
|
21
|
+
<div className='absolute inset-0 flex justify-center items-center'>
|
|
22
|
+
<Image {...args} />
|
|
23
|
+
</div>
|
|
24
|
+
),
|
|
25
|
+
decorators: [withTheme()],
|
|
26
|
+
parameters: {
|
|
27
|
+
layout: 'centered',
|
|
28
|
+
},
|
|
29
|
+
} satisfies Meta<typeof Image>;
|
|
30
|
+
|
|
31
|
+
export default meta;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<typeof meta>;
|
|
34
|
+
|
|
35
|
+
export const Default: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
src: faker.image.url(),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const classNames = 'h-[12rem] w-[18rem]';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Access to image at 'https://dxos.network/dxos-logotype-blue.png'
|
|
45
|
+
* from origin 'http://localhost:9009' has been blocked by CORS policy:
|
|
46
|
+
* No 'Access-Control-Allow-Origin' header is present on the requested resource.
|
|
47
|
+
*/
|
|
48
|
+
export const Cors: Story = {
|
|
49
|
+
args: {
|
|
50
|
+
src: 'https://dxos.network/dxos-logotype-blue.png',
|
|
51
|
+
classNames,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const Corners: Story = {
|
|
56
|
+
args: {
|
|
57
|
+
src: 'https://picsum.photos/seed/picsum/200/200',
|
|
58
|
+
classNames,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const SVG: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
src: 'https://dxos.network/bg-kube.svg',
|
|
65
|
+
classNames,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Many: Story = {
|
|
70
|
+
args: {
|
|
71
|
+
src: 'https://dxos.network/bg-kube.svg',
|
|
72
|
+
},
|
|
73
|
+
render: () => {
|
|
74
|
+
const images = useMemo(
|
|
75
|
+
() => Array.from({ length: 9 }, (_, i) => `https://picsum.photos/seed/${seed + i}/500/500`),
|
|
76
|
+
[],
|
|
77
|
+
);
|
|
78
|
+
return (
|
|
79
|
+
<div className='w-[60rem] grid grid-cols-3 grid-rows-3 gap-8'>
|
|
80
|
+
{images.map((src, i) => (
|
|
81
|
+
<Image key={i} src={src} classNames={classNames} />
|
|
82
|
+
))}
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type SyntheticEvent, useCallback, useRef, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
|
+
import { mx } from '@dxos/ui-theme';
|
|
9
|
+
|
|
10
|
+
const cache = new Map<string, string>();
|
|
11
|
+
|
|
12
|
+
export type ImageProps = ThemedClassName<
|
|
13
|
+
{
|
|
14
|
+
src: string;
|
|
15
|
+
alt?: string;
|
|
16
|
+
crossOrigin?: 'anonymous' | 'use-credentials' | '';
|
|
17
|
+
} & ColorOptions
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
// TODO(burdon): Option for neutral background color.
|
|
21
|
+
export const Image = ({
|
|
22
|
+
classNames,
|
|
23
|
+
src,
|
|
24
|
+
alt = '',
|
|
25
|
+
crossOrigin = 'anonymous',
|
|
26
|
+
sampleSize = 64,
|
|
27
|
+
contrast = 0.9,
|
|
28
|
+
}: ImageProps) => {
|
|
29
|
+
const [crossOriginState, setCrossOriginState] = useState<ImageProps['crossOrigin']>(crossOrigin);
|
|
30
|
+
const [dominantColor, setDominantColor] = useState<string | undefined>(undefined);
|
|
31
|
+
const [imageLoaded, setImageLoaded] = useState<boolean>(false);
|
|
32
|
+
const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
33
|
+
|
|
34
|
+
// CORS not supported by server.
|
|
35
|
+
const handleImageError = (): void => {
|
|
36
|
+
setCrossOriginState(undefined);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const handleImageLoad = useCallback(
|
|
40
|
+
({ target }: SyntheticEvent<HTMLImageElement>): void => {
|
|
41
|
+
const rgb = cache.get(src);
|
|
42
|
+
if (rgb) {
|
|
43
|
+
setDominantColor(rgb);
|
|
44
|
+
setImageLoaded(true);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const img = target as HTMLImageElement;
|
|
49
|
+
if (!canvasRef.current) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const color = extractDominantColor(canvasRef.current, img, { sampleSize, contrast });
|
|
55
|
+
if (color) {
|
|
56
|
+
const rgb = `rgb(${color[0]}, ${color[1]}, ${color[2]})`;
|
|
57
|
+
cache.set(src, rgb);
|
|
58
|
+
setDominantColor(rgb);
|
|
59
|
+
}
|
|
60
|
+
} catch {
|
|
61
|
+
setCrossOriginState(undefined);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setImageLoaded(true);
|
|
65
|
+
},
|
|
66
|
+
[sampleSize, contrast, src],
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div
|
|
71
|
+
className={mx(`relative flex w-full justify-center overflow-hidden transition-all duration-700`, classNames)}
|
|
72
|
+
style={{
|
|
73
|
+
backgroundColor: dominantColor,
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
{/* Hidden canvas for color extraction. */}
|
|
77
|
+
<canvas ref={canvasRef} style={{ display: 'none' }} aria-hidden='true' />
|
|
78
|
+
|
|
79
|
+
{/* Background gradient overlay for smooth transition. */}
|
|
80
|
+
<div
|
|
81
|
+
className='absolute inset-0 pointer-events-none'
|
|
82
|
+
style={{
|
|
83
|
+
background: dominantColor
|
|
84
|
+
? `radial-gradient(circle at center, transparent 30%, ${dominantColor} 100%)`
|
|
85
|
+
: undefined,
|
|
86
|
+
transition: 'opacity 0.7s ease-in-out',
|
|
87
|
+
opacity: 0.5,
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
|
|
91
|
+
<img
|
|
92
|
+
src={src}
|
|
93
|
+
alt={alt}
|
|
94
|
+
crossOrigin={crossOriginState}
|
|
95
|
+
onError={handleImageError}
|
|
96
|
+
onLoad={handleImageLoad}
|
|
97
|
+
className='z-10 object-contain transition-opacity duration-500'
|
|
98
|
+
style={{
|
|
99
|
+
opacity: imageLoaded ? 1 : 0,
|
|
100
|
+
}}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
type ColorOptions = {
|
|
107
|
+
sampleSize?: number;
|
|
108
|
+
contrast?: number;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Get dominant color from image (esp. from corners).
|
|
113
|
+
*/
|
|
114
|
+
const extractDominantColor = (
|
|
115
|
+
canvas: HTMLCanvasElement,
|
|
116
|
+
img: HTMLImageElement,
|
|
117
|
+
{ sampleSize = 64, contrast = 0.95 }: ColorOptions,
|
|
118
|
+
): [number, number, number] | null => {
|
|
119
|
+
const ctx = canvas.getContext('2d');
|
|
120
|
+
if (!ctx) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Draw the image scaled down.
|
|
125
|
+
canvas.width = sampleSize;
|
|
126
|
+
canvas.height = sampleSize;
|
|
127
|
+
ctx.drawImage(img, 0, 0, sampleSize, sampleSize);
|
|
128
|
+
|
|
129
|
+
// Get image data.
|
|
130
|
+
const imageData = ctx.getImageData(0, 0, sampleSize, sampleSize);
|
|
131
|
+
const pixels = imageData.data;
|
|
132
|
+
|
|
133
|
+
// Check for transparent background.
|
|
134
|
+
if (isTransparent(pixels, sampleSize)) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let r = 0;
|
|
139
|
+
let g = 0;
|
|
140
|
+
let b = 0;
|
|
141
|
+
let totalWeight = 0;
|
|
142
|
+
|
|
143
|
+
// Define corner sampling areas (e.g., 25% of each dimension from each corner).
|
|
144
|
+
const cornerSize = Math.floor(sampleSize * 0.125);
|
|
145
|
+
|
|
146
|
+
// Sample only pixels in corner areas.
|
|
147
|
+
for (let y = 0; y < sampleSize; y++) {
|
|
148
|
+
for (let x = 0; x < sampleSize; x++) {
|
|
149
|
+
// Check if pixel is in any corner area.
|
|
150
|
+
const isInTopLeft = x < cornerSize && y < cornerSize;
|
|
151
|
+
const isInTopRight = x >= sampleSize - cornerSize && y < cornerSize;
|
|
152
|
+
const isInBottomLeft = x < cornerSize && y >= sampleSize - cornerSize;
|
|
153
|
+
const isInBottomRight = x >= sampleSize - cornerSize && y >= sampleSize - cornerSize;
|
|
154
|
+
if (!isInTopLeft && !isInTopRight && !isInBottomLeft && !isInBottomRight) {
|
|
155
|
+
continue; // Skip pixels not in corner areas.
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const i = (y * sampleSize + x) * 4;
|
|
159
|
+
const red = pixels[i];
|
|
160
|
+
const green = pixels[i + 1];
|
|
161
|
+
const blue = pixels[i + 2];
|
|
162
|
+
const alpha = pixels[i + 3];
|
|
163
|
+
|
|
164
|
+
// Skip transparent pixels.
|
|
165
|
+
if (alpha === 0) continue;
|
|
166
|
+
|
|
167
|
+
// Calculate saturation to weight vibrant colors more.
|
|
168
|
+
const max = Math.max(red, green, blue);
|
|
169
|
+
const min = Math.min(red, green, blue);
|
|
170
|
+
const saturation = max === 0 ? 0 : (max - min) / max;
|
|
171
|
+
const weight = 1 + saturation * 2;
|
|
172
|
+
|
|
173
|
+
r += red * weight;
|
|
174
|
+
g += green * weight;
|
|
175
|
+
b += blue * weight;
|
|
176
|
+
totalWeight += weight;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (totalWeight > 0) {
|
|
181
|
+
// Slightly darken the color for better contrast.
|
|
182
|
+
r = Math.round(Math.round(r / totalWeight) * contrast);
|
|
183
|
+
g = Math.round(Math.round(g / totalWeight) * contrast);
|
|
184
|
+
b = Math.round(Math.round(b / totalWeight) * contrast);
|
|
185
|
+
return [r, g, b];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return null;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Detects if an image has a transparent background by examining edge pixels.
|
|
193
|
+
* @param pixels - Image pixel data from canvas
|
|
194
|
+
* @param sampleSize - Size of the sampled image
|
|
195
|
+
* @param threshold - Percentage threshold for considering background transparent (default: 0.5)
|
|
196
|
+
* @returns True if the image has a transparent background
|
|
197
|
+
*/
|
|
198
|
+
const isTransparent = (pixels: Uint8ClampedArray, sampleSize: number, threshold: number = 0.5): boolean => {
|
|
199
|
+
let edgeTransparentPixels = 0;
|
|
200
|
+
const edgePixels = sampleSize * 4 - 4; // Perimeter minus corners counted twice.
|
|
201
|
+
|
|
202
|
+
for (let x = 0; x < sampleSize; x++) {
|
|
203
|
+
// Top edge.
|
|
204
|
+
const topIndex = x * 4;
|
|
205
|
+
if (pixels[topIndex + 3] === 0) edgeTransparentPixels++;
|
|
206
|
+
|
|
207
|
+
// Bottom edge.
|
|
208
|
+
const bottomIndex = ((sampleSize - 1) * sampleSize + x) * 4;
|
|
209
|
+
if (pixels[bottomIndex + 3] === 0) edgeTransparentPixels++;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
for (let y = 1; y < sampleSize - 1; y++) {
|
|
213
|
+
// Left edge.
|
|
214
|
+
const leftIndex = y * sampleSize * 4;
|
|
215
|
+
if (pixels[leftIndex + 3] === 0) edgeTransparentPixels++;
|
|
216
|
+
|
|
217
|
+
// Right edge.
|
|
218
|
+
const rightIndex = (y * sampleSize + sampleSize - 1) * 4;
|
|
219
|
+
if (pixels[rightIndex + 3] === 0) edgeTransparentPixels++;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return edgeTransparentPixels / edgePixels > threshold;
|
|
223
|
+
};
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { baseSurface, modalSurface, mx, surfaceShadow } from '@dxos/ui-theme';
|
|
9
8
|
import { type MessageValence } from '@dxos/ui-types';
|
|
10
9
|
|
|
11
|
-
import { withTheme } from '../../testing';
|
|
10
|
+
import { withLayoutVariants, withTheme } from '../../testing';
|
|
12
11
|
|
|
13
12
|
import {
|
|
14
13
|
type CheckboxProps,
|
|
@@ -29,7 +28,7 @@ type VariantMap = {
|
|
|
29
28
|
|
|
30
29
|
type Variant = { [K in keyof VariantMap]: { type: K } & VariantMap[K] }[keyof VariantMap];
|
|
31
30
|
|
|
32
|
-
type
|
|
31
|
+
type StoryProps = Partial<{
|
|
33
32
|
kind: keyof VariantMap;
|
|
34
33
|
label: string;
|
|
35
34
|
labelVisuallyHidden: boolean;
|
|
@@ -39,7 +38,7 @@ type BaseProps = Partial<{
|
|
|
39
38
|
validationMessage: string;
|
|
40
39
|
}>;
|
|
41
40
|
|
|
42
|
-
const
|
|
41
|
+
const DefaultStory = ({
|
|
43
42
|
kind,
|
|
44
43
|
label,
|
|
45
44
|
description,
|
|
@@ -48,7 +47,7 @@ const Wrapper = ({
|
|
|
48
47
|
validationValence,
|
|
49
48
|
validationMessage,
|
|
50
49
|
...props
|
|
51
|
-
}:
|
|
50
|
+
}: StoryProps) => {
|
|
52
51
|
return (
|
|
53
52
|
<Input.Root {...{ validationValence }}>
|
|
54
53
|
<Input.Label srOnly={labelVisuallyHidden}>{label}</Input.Label>
|
|
@@ -60,48 +59,28 @@ const Wrapper = ({
|
|
|
60
59
|
{kind === 'switch' && <Input.Switch {...props} />}
|
|
61
60
|
|
|
62
61
|
<Input.DescriptionAndValidation srOnly={descriptionVisuallyHidden}>
|
|
63
|
-
{validationMessage &&
|
|
64
|
-
<>
|
|
65
|
-
<Input.Validation>{validationMessage}</Input.Validation>{' '}
|
|
66
|
-
</>
|
|
67
|
-
)}
|
|
62
|
+
{validationMessage && <Input.Validation classNames='block'>{validationMessage}</Input.Validation>}
|
|
68
63
|
<Input.Description>{description}</Input.Description>
|
|
69
64
|
</Input.DescriptionAndValidation>
|
|
70
65
|
</Input.Root>
|
|
71
66
|
);
|
|
72
67
|
};
|
|
73
68
|
|
|
74
|
-
const DefaultStory = (props: BaseProps) => {
|
|
75
|
-
return (
|
|
76
|
-
<div className='space-b-4'>
|
|
77
|
-
<div className={mx(baseSurface, 'p-4 rounded-md')}>
|
|
78
|
-
<Wrapper {...props} />
|
|
79
|
-
</div>
|
|
80
|
-
<div className={mx('bg-cardSurface', 'p-4 rounded-md', surfaceShadow({ elevation: 'positioned' }))}>
|
|
81
|
-
<Wrapper {...props} />
|
|
82
|
-
</div>
|
|
83
|
-
<div className={mx(modalSurface, 'p-4 rounded-md', surfaceShadow({ elevation: 'dialog' }))}>
|
|
84
|
-
<Wrapper {...props} />
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
69
|
const meta = {
|
|
91
|
-
title: 'ui/react-ui-core/Input',
|
|
70
|
+
title: 'ui/react-ui-core/components/Input',
|
|
92
71
|
component: Input.Root as any,
|
|
93
72
|
render: DefaultStory,
|
|
94
|
-
decorators: [withTheme],
|
|
73
|
+
decorators: [withTheme(), withLayoutVariants()],
|
|
95
74
|
} satisfies Meta<typeof DefaultStory>;
|
|
96
75
|
|
|
97
76
|
export default meta;
|
|
98
77
|
|
|
99
|
-
type Story = StoryObj<
|
|
78
|
+
type Story = StoryObj<StoryProps & Variant>;
|
|
100
79
|
|
|
101
|
-
export const
|
|
80
|
+
export const DensityCoarse: Story = {
|
|
102
81
|
args: {
|
|
103
82
|
kind: 'text',
|
|
104
|
-
label: '
|
|
83
|
+
label: 'Input value',
|
|
105
84
|
placeholder: 'This is an input',
|
|
106
85
|
disabled: false,
|
|
107
86
|
description: undefined,
|
|
@@ -109,13 +88,14 @@ export const Default: Story = {
|
|
|
109
88
|
descriptionVisuallyHidden: false,
|
|
110
89
|
validationMessage: '',
|
|
111
90
|
validationValence: undefined,
|
|
91
|
+
density: 'coarse',
|
|
112
92
|
},
|
|
113
93
|
};
|
|
114
94
|
|
|
115
95
|
export const DensityFine: Story = {
|
|
116
96
|
args: {
|
|
117
97
|
kind: 'text',
|
|
118
|
-
label: '
|
|
98
|
+
label: 'Input value',
|
|
119
99
|
placeholder: 'This is a density:fine input',
|
|
120
100
|
disabled: false,
|
|
121
101
|
description: undefined,
|
|
@@ -130,7 +110,7 @@ export const DensityFine: Story = {
|
|
|
130
110
|
export const Subdued: Story = {
|
|
131
111
|
args: {
|
|
132
112
|
kind: 'text',
|
|
133
|
-
label: '
|
|
113
|
+
label: 'Input value',
|
|
134
114
|
placeholder: 'This is a subdued input',
|
|
135
115
|
disabled: false,
|
|
136
116
|
description: undefined,
|
|
@@ -160,7 +140,7 @@ export const LabelVisuallyHidden: Story = {
|
|
|
160
140
|
},
|
|
161
141
|
};
|
|
162
142
|
|
|
163
|
-
export const
|
|
143
|
+
export const WithDescription: Story = {
|
|
164
144
|
args: {
|
|
165
145
|
kind: 'text',
|
|
166
146
|
label: 'Described input',
|
|
@@ -169,7 +149,7 @@ export const InputWithDescription: Story = {
|
|
|
169
149
|
},
|
|
170
150
|
};
|
|
171
151
|
|
|
172
|
-
export const
|
|
152
|
+
export const WithErrorAndDescription: Story = {
|
|
173
153
|
args: {
|
|
174
154
|
kind: 'text',
|
|
175
155
|
label: 'Described invalid input',
|
|
@@ -180,7 +160,7 @@ export const InputWithErrorAndDescription: Story = {
|
|
|
180
160
|
},
|
|
181
161
|
};
|
|
182
162
|
|
|
183
|
-
export const
|
|
163
|
+
export const WithValidationAndDescription: Story = {
|
|
184
164
|
args: {
|
|
185
165
|
kind: 'text',
|
|
186
166
|
label: 'Described input with validation message',
|
|
@@ -206,7 +186,8 @@ export const PinInput: Story = {
|
|
|
206
186
|
label: 'This input is a PIN-style input',
|
|
207
187
|
length: 6,
|
|
208
188
|
description: 'Type in secret you received',
|
|
209
|
-
|
|
189
|
+
pattern: '\\d*',
|
|
190
|
+
density: 'coarse',
|
|
210
191
|
},
|
|
211
192
|
};
|
|
212
193
|
|
|
@@ -214,7 +195,7 @@ export const Checkbox: Story = {
|
|
|
214
195
|
args: {
|
|
215
196
|
kind: 'checkbox',
|
|
216
197
|
label: 'This is a checkbox',
|
|
217
|
-
description: '
|
|
198
|
+
description: 'Checked, indeterminate, or unchecked',
|
|
218
199
|
size: 5,
|
|
219
200
|
},
|
|
220
201
|
};
|
|
@@ -223,6 +204,6 @@ export const Switch: Story = {
|
|
|
223
204
|
args: {
|
|
224
205
|
kind: 'switch',
|
|
225
206
|
label: 'This is a switch',
|
|
226
|
-
description:
|
|
207
|
+
description: 'On or off',
|
|
227
208
|
},
|
|
228
209
|
};
|