@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
|
@@ -23,12 +23,24 @@ import {
|
|
|
23
23
|
type AlertDialogTriggerProps as AlertDialogTriggerPrimitiveProps,
|
|
24
24
|
} from '@radix-ui/react-alert-dialog';
|
|
25
25
|
import { createContext } from '@radix-ui/react-context';
|
|
26
|
-
import React, {
|
|
26
|
+
import React, {
|
|
27
|
+
type ForwardRefExoticComponent,
|
|
28
|
+
type FunctionComponent,
|
|
29
|
+
type PropsWithChildren,
|
|
30
|
+
forwardRef,
|
|
31
|
+
} from 'react';
|
|
32
|
+
|
|
33
|
+
import { type DialogSize } from '@dxos/ui-theme';
|
|
27
34
|
|
|
28
35
|
import { useThemeContext } from '../../hooks';
|
|
36
|
+
import { Column } from '../../primitives';
|
|
29
37
|
import { type ThemedClassName } from '../../util';
|
|
30
38
|
import { ElevationProvider } from '../ElevationProvider';
|
|
31
39
|
|
|
40
|
+
//
|
|
41
|
+
// Root
|
|
42
|
+
//
|
|
43
|
+
|
|
32
44
|
type AlertDialogRootProps = AlertDialogRootPrimitiveProps;
|
|
33
45
|
|
|
34
46
|
const AlertDialogRoot: FunctionComponent<AlertDialogRootProps> = (props) => (
|
|
@@ -37,22 +49,42 @@ const AlertDialogRoot: FunctionComponent<AlertDialogRootProps> = (props) => (
|
|
|
37
49
|
</ElevationProvider>
|
|
38
50
|
);
|
|
39
51
|
|
|
52
|
+
//
|
|
53
|
+
// Trigger
|
|
54
|
+
//
|
|
55
|
+
|
|
40
56
|
type AlertDialogTriggerProps = AlertDialogTriggerPrimitiveProps;
|
|
41
57
|
|
|
42
58
|
const AlertDialogTrigger: FunctionComponent<AlertDialogTriggerProps> = AlertDialogTriggerPrimitive;
|
|
43
59
|
|
|
60
|
+
//
|
|
61
|
+
// Portal
|
|
62
|
+
//
|
|
63
|
+
|
|
44
64
|
type AlertDialogPortalProps = AlertDialogPortalPrimitiveProps;
|
|
45
65
|
|
|
46
66
|
const AlertDialogPortal: FunctionComponent<AlertDialogPortalProps> = AlertDialogPortalPrimitive;
|
|
47
67
|
|
|
68
|
+
//
|
|
69
|
+
// Cancel
|
|
70
|
+
//
|
|
71
|
+
|
|
48
72
|
type AlertDialogCancelProps = AlertDialogCancelPrimitiveProps;
|
|
49
73
|
|
|
50
74
|
const AlertDialogCancel: FunctionComponent<AlertDialogCancelProps> = AlertDialogCancelPrimitive;
|
|
51
75
|
|
|
76
|
+
//
|
|
77
|
+
// Action
|
|
78
|
+
//
|
|
79
|
+
|
|
52
80
|
type AlertDialogActionProps = AlertDialogActionPrimitiveProps;
|
|
53
81
|
|
|
54
82
|
const AlertDialogAction: FunctionComponent<AlertDialogActionProps> = AlertDialogActionPrimitive;
|
|
55
83
|
|
|
84
|
+
//
|
|
85
|
+
// Title
|
|
86
|
+
//
|
|
87
|
+
|
|
56
88
|
type AlertDialogTitleProps = ThemedClassName<AlertDialogTitlePrimitiveProps> & { srOnly?: boolean };
|
|
57
89
|
|
|
58
90
|
const AlertDialogTitle: ForwardRefExoticComponent<AlertDialogTitleProps> = forwardRef<
|
|
@@ -61,14 +93,14 @@ const AlertDialogTitle: ForwardRefExoticComponent<AlertDialogTitleProps> = forwa
|
|
|
61
93
|
>(({ classNames, srOnly, ...props }, forwardedRef) => {
|
|
62
94
|
const { tx } = useThemeContext();
|
|
63
95
|
return (
|
|
64
|
-
<AlertDialogTitlePrimitive
|
|
65
|
-
{...props}
|
|
66
|
-
className={tx('dialog.title', 'dialog--alert__title', { srOnly }, classNames)}
|
|
67
|
-
ref={forwardedRef}
|
|
68
|
-
/>
|
|
96
|
+
<AlertDialogTitlePrimitive {...props} className={tx('dialog.title', { srOnly }, classNames)} ref={forwardedRef} />
|
|
69
97
|
);
|
|
70
98
|
});
|
|
71
99
|
|
|
100
|
+
//
|
|
101
|
+
// Description
|
|
102
|
+
//
|
|
103
|
+
|
|
72
104
|
type AlertDialogDescriptionProps = ThemedClassName<AlertDialogDescriptionPrimitiveProps> & { srOnly?: boolean };
|
|
73
105
|
|
|
74
106
|
const AlertDialogDescription: ForwardRefExoticComponent<AlertDialogTitleProps> = forwardRef<
|
|
@@ -79,15 +111,23 @@ const AlertDialogDescription: ForwardRefExoticComponent<AlertDialogTitleProps> =
|
|
|
79
111
|
return (
|
|
80
112
|
<AlertDialogDescriptionPrimitive
|
|
81
113
|
{...props}
|
|
82
|
-
className={tx('dialog.description',
|
|
114
|
+
className={tx('dialog.description', { srOnly }, classNames)}
|
|
83
115
|
ref={forwardedRef}
|
|
84
116
|
/>
|
|
85
117
|
);
|
|
86
118
|
});
|
|
87
119
|
|
|
88
120
|
type OverlayLayoutContextValue = { inOverlayLayout?: boolean };
|
|
121
|
+
|
|
122
|
+
//
|
|
123
|
+
// Context
|
|
124
|
+
//
|
|
125
|
+
|
|
89
126
|
const ALERT_DIALOG_OVERLAY_NAME = 'AlertDialogOverlay';
|
|
90
127
|
const ALERT_DIALOG_CONTENT_NAME = 'AlertDialogContent';
|
|
128
|
+
const ALERT_DIALOG_BODY_NAME = 'AlertDialogBody';
|
|
129
|
+
const ALERT_DIALOG_ACTIONBAR_NAME = 'AlertDialogActionBar';
|
|
130
|
+
|
|
91
131
|
const [OverlayLayoutProvider, useOverlayLayoutContext] = createContext<OverlayLayoutContextValue>(
|
|
92
132
|
ALERT_DIALOG_OVERLAY_NAME,
|
|
93
133
|
{
|
|
@@ -95,6 +135,10 @@ const [OverlayLayoutProvider, useOverlayLayoutContext] = createContext<OverlayLa
|
|
|
95
135
|
},
|
|
96
136
|
);
|
|
97
137
|
|
|
138
|
+
//
|
|
139
|
+
// Overlay
|
|
140
|
+
//
|
|
141
|
+
|
|
98
142
|
type AlertDialogOverlayProps = ThemedClassName<AlertDialogOverlayPrimitiveProps> & {
|
|
99
143
|
blockAlign?: 'center' | 'start' | 'end';
|
|
100
144
|
};
|
|
@@ -107,17 +151,17 @@ const AlertDialogOverlay: ForwardRefExoticComponent<AlertDialogOverlayProps> = f
|
|
|
107
151
|
return (
|
|
108
152
|
<AlertDialogOverlayPrimitive
|
|
109
153
|
{...props}
|
|
154
|
+
data-block-align={blockAlign}
|
|
110
155
|
className={tx(
|
|
111
156
|
'dialog.overlay',
|
|
112
|
-
'dialog--alert__overlay',
|
|
113
157
|
{},
|
|
114
158
|
classNames,
|
|
115
|
-
|
|
116
|
-
'data-[
|
|
117
|
-
'data-[
|
|
159
|
+
// TODO(burdon): Move to dialog.ts.
|
|
160
|
+
'data-[h-align=start]:justify-center',
|
|
161
|
+
'data-[h-align=start]:items-start',
|
|
162
|
+
'data-[h-align=center]:place-content-center',
|
|
118
163
|
)}
|
|
119
164
|
ref={forwardedRef}
|
|
120
|
-
data-block-align={blockAlign}
|
|
121
165
|
>
|
|
122
166
|
<OverlayLayoutProvider inOverlayLayout>{children}</OverlayLayoutProvider>
|
|
123
167
|
</AlertDialogOverlayPrimitive>
|
|
@@ -126,35 +170,89 @@ const AlertDialogOverlay: ForwardRefExoticComponent<AlertDialogOverlayProps> = f
|
|
|
126
170
|
|
|
127
171
|
AlertDialogOverlay.displayName = ALERT_DIALOG_OVERLAY_NAME;
|
|
128
172
|
|
|
129
|
-
|
|
173
|
+
//
|
|
174
|
+
// Content
|
|
175
|
+
//
|
|
176
|
+
|
|
177
|
+
type AlertDialogContentProps = ThemedClassName<AlertDialogContentPrimitiveProps> & { size?: DialogSize };
|
|
130
178
|
|
|
131
179
|
const AlertDialogContent: ForwardRefExoticComponent<AlertDialogContentProps> = forwardRef<
|
|
132
180
|
HTMLDivElement,
|
|
133
181
|
AlertDialogContentProps
|
|
134
|
-
>(({ classNames, children, ...props }, forwardedRef) => {
|
|
182
|
+
>(({ classNames, children, size = 'md', ...props }, forwardedRef) => {
|
|
135
183
|
const { tx } = useThemeContext();
|
|
136
184
|
const { inOverlayLayout } = useOverlayLayoutContext(ALERT_DIALOG_CONTENT_NAME);
|
|
137
185
|
return (
|
|
138
186
|
<AlertDialogContentPrimitive
|
|
139
187
|
{...props}
|
|
140
|
-
className={tx('dialog.content',
|
|
188
|
+
className={tx('dialog.content', { inOverlayLayout, size }, classNames)}
|
|
141
189
|
ref={forwardedRef}
|
|
142
190
|
>
|
|
143
|
-
{children}
|
|
191
|
+
<Column.Root>{children}</Column.Root>
|
|
144
192
|
</AlertDialogContentPrimitive>
|
|
145
193
|
);
|
|
146
194
|
});
|
|
147
195
|
|
|
148
196
|
AlertDialogContent.displayName = ALERT_DIALOG_CONTENT_NAME;
|
|
149
197
|
|
|
198
|
+
//
|
|
199
|
+
// Body
|
|
200
|
+
//
|
|
201
|
+
|
|
202
|
+
type AlertDialogBodyProps = PropsWithChildren;
|
|
203
|
+
|
|
204
|
+
const AlertDialogBody: ForwardRefExoticComponent<AlertDialogBodyProps> = forwardRef<
|
|
205
|
+
HTMLDivElement,
|
|
206
|
+
AlertDialogBodyProps
|
|
207
|
+
>(({ children, ...props }, forwardedRef) => {
|
|
208
|
+
const { tx } = useThemeContext();
|
|
209
|
+
return (
|
|
210
|
+
<Column.Segment asChild>
|
|
211
|
+
<div role='none' {...props} className={tx('dialog.body')} ref={forwardedRef}>
|
|
212
|
+
{children}
|
|
213
|
+
</div>
|
|
214
|
+
</Column.Segment>
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
AlertDialogBody.displayName = ALERT_DIALOG_BODY_NAME;
|
|
219
|
+
|
|
220
|
+
//
|
|
221
|
+
// ActionBar
|
|
222
|
+
//
|
|
223
|
+
|
|
224
|
+
type AlertDialogActionBarProps = ThemedClassName<PropsWithChildren>;
|
|
225
|
+
|
|
226
|
+
const AlertDialogActionBar: ForwardRefExoticComponent<AlertDialogActionBarProps> = forwardRef<
|
|
227
|
+
HTMLDivElement,
|
|
228
|
+
AlertDialogActionBarProps
|
|
229
|
+
>(({ children, classNames, ...props }, forwardedRef) => {
|
|
230
|
+
const { tx } = useThemeContext();
|
|
231
|
+
return (
|
|
232
|
+
<Column.Segment asChild>
|
|
233
|
+
<div {...props} className={tx('dialog.actionbar', {}, classNames)} ref={forwardedRef}>
|
|
234
|
+
{children}
|
|
235
|
+
</div>
|
|
236
|
+
</Column.Segment>
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
AlertDialogActionBar.displayName = ALERT_DIALOG_ACTIONBAR_NAME;
|
|
241
|
+
|
|
242
|
+
//
|
|
243
|
+
// AlertDialog
|
|
244
|
+
//
|
|
245
|
+
|
|
150
246
|
export const AlertDialog = {
|
|
151
247
|
Root: AlertDialogRoot,
|
|
152
248
|
Trigger: AlertDialogTrigger,
|
|
153
249
|
Portal: AlertDialogPortal,
|
|
154
250
|
Overlay: AlertDialogOverlay,
|
|
155
251
|
Content: AlertDialogContent,
|
|
252
|
+
Body: AlertDialogBody,
|
|
156
253
|
Title: AlertDialogTitle,
|
|
157
254
|
Description: AlertDialogDescription,
|
|
255
|
+
ActionBar: AlertDialogActionBar,
|
|
158
256
|
Cancel: AlertDialogCancel,
|
|
159
257
|
Action: AlertDialogAction,
|
|
160
258
|
};
|
|
@@ -165,8 +263,10 @@ export type {
|
|
|
165
263
|
AlertDialogPortalProps,
|
|
166
264
|
AlertDialogOverlayProps,
|
|
167
265
|
AlertDialogContentProps,
|
|
266
|
+
AlertDialogBodyProps,
|
|
168
267
|
AlertDialogTitleProps,
|
|
169
268
|
AlertDialogDescriptionProps,
|
|
269
|
+
AlertDialogActionBarProps,
|
|
170
270
|
AlertDialogCancelProps,
|
|
171
271
|
AlertDialogActionProps,
|
|
172
272
|
};
|
|
@@ -9,6 +9,7 @@ import { faker } from '@dxos/random';
|
|
|
9
9
|
|
|
10
10
|
import { withTheme } from '../../testing';
|
|
11
11
|
import { Button } from '../Button';
|
|
12
|
+
import { Input } from '../Input';
|
|
12
13
|
|
|
13
14
|
import { Dialog, type DialogContentProps } from './Dialog';
|
|
14
15
|
|
|
@@ -18,12 +19,12 @@ type StoryProps = Pick<DialogContentProps, 'size'> &
|
|
|
18
19
|
description: string;
|
|
19
20
|
openTrigger: string;
|
|
20
21
|
closeTrigger: string;
|
|
21
|
-
blockAlign: '
|
|
22
|
+
blockAlign: 'start' | 'center';
|
|
22
23
|
}>;
|
|
23
24
|
|
|
24
25
|
const DefaultStory = ({ size, title, description, openTrigger, closeTrigger, blockAlign }: StoryProps) => {
|
|
25
26
|
return (
|
|
26
|
-
<Dialog.Root defaultOpen>
|
|
27
|
+
<Dialog.Root defaultOpen modal>
|
|
27
28
|
<Dialog.Trigger asChild>
|
|
28
29
|
<Button>{openTrigger}</Button>
|
|
29
30
|
</Dialog.Trigger>
|
|
@@ -37,10 +38,18 @@ const DefaultStory = ({ size, title, description, openTrigger, closeTrigger, blo
|
|
|
37
38
|
</Dialog.Close>
|
|
38
39
|
)}
|
|
39
40
|
</Dialog.Header>
|
|
40
|
-
<Dialog.
|
|
41
|
-
|
|
42
|
-
<
|
|
43
|
-
|
|
41
|
+
<Dialog.Body>
|
|
42
|
+
<Dialog.Description>{description}</Dialog.Description>
|
|
43
|
+
<Input.Root>
|
|
44
|
+
<Input.Label>Value</Input.Label>
|
|
45
|
+
<Input.TextInput placeholder='Enter value' />
|
|
46
|
+
</Input.Root>
|
|
47
|
+
</Dialog.Body>
|
|
48
|
+
<Dialog.ActionBar>
|
|
49
|
+
<Dialog.Close asChild>
|
|
50
|
+
<Button variant='primary'>{closeTrigger}</Button>
|
|
51
|
+
</Dialog.Close>
|
|
52
|
+
</Dialog.ActionBar>
|
|
44
53
|
</Dialog.Content>
|
|
45
54
|
</Dialog.Overlay>
|
|
46
55
|
</Dialog.Root>
|
|
@@ -48,25 +57,30 @@ const DefaultStory = ({ size, title, description, openTrigger, closeTrigger, blo
|
|
|
48
57
|
};
|
|
49
58
|
|
|
50
59
|
const meta = {
|
|
51
|
-
title: 'ui/react-ui-core/Dialog',
|
|
60
|
+
title: 'ui/react-ui-core/components/Dialog',
|
|
52
61
|
component: Dialog as any,
|
|
53
62
|
render: DefaultStory,
|
|
54
|
-
decorators: [withTheme],
|
|
55
|
-
parameters: {
|
|
56
|
-
chromatic: {
|
|
57
|
-
disableSnapshot: false,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
63
|
+
decorators: [withTheme()],
|
|
60
64
|
} satisfies Meta<typeof DefaultStory>;
|
|
61
65
|
|
|
62
66
|
export default meta;
|
|
63
67
|
|
|
64
68
|
type Story = StoryObj<typeof meta>;
|
|
65
69
|
|
|
70
|
+
export const Default: Story = {
|
|
71
|
+
args: {
|
|
72
|
+
title: 'Dialog title',
|
|
73
|
+
description: faker.lorem.paragraph(1),
|
|
74
|
+
openTrigger: 'Open',
|
|
75
|
+
closeTrigger: 'Close',
|
|
76
|
+
blockAlign: 'start',
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
66
80
|
export const Small: Story = {
|
|
67
81
|
args: {
|
|
68
82
|
title: 'Dialog title',
|
|
69
|
-
description: faker.lorem.paragraph(
|
|
83
|
+
description: faker.lorem.paragraph(1),
|
|
70
84
|
openTrigger: 'Open',
|
|
71
85
|
closeTrigger: 'Close',
|
|
72
86
|
blockAlign: 'center',
|
|
@@ -77,7 +91,7 @@ export const Small: Story = {
|
|
|
77
91
|
export const Medium: Story = {
|
|
78
92
|
args: {
|
|
79
93
|
title: 'Dialog title',
|
|
80
|
-
description: faker.lorem.paragraph(
|
|
94
|
+
description: faker.lorem.paragraph(1),
|
|
81
95
|
openTrigger: 'Open',
|
|
82
96
|
closeTrigger: 'Close',
|
|
83
97
|
blockAlign: 'center',
|
|
@@ -95,3 +109,14 @@ export const Large: Story = {
|
|
|
95
109
|
size: 'lg',
|
|
96
110
|
},
|
|
97
111
|
};
|
|
112
|
+
|
|
113
|
+
export const ExtraLarge: Story = {
|
|
114
|
+
args: {
|
|
115
|
+
title: 'Dialog title',
|
|
116
|
+
description: faker.lorem.paragraph(2),
|
|
117
|
+
openTrigger: 'Open Dialog',
|
|
118
|
+
closeTrigger: 'Close',
|
|
119
|
+
blockAlign: 'center',
|
|
120
|
+
size: 'xl',
|
|
121
|
+
},
|
|
122
|
+
};
|
|
@@ -32,8 +32,9 @@ import { useTranslation } from 'react-i18next';
|
|
|
32
32
|
import { type DialogSize, osTranslations } from '@dxos/ui-theme';
|
|
33
33
|
|
|
34
34
|
import { useThemeContext } from '../../hooks';
|
|
35
|
+
import { Column } from '../../primitives';
|
|
35
36
|
import { type ThemedClassName } from '../../util';
|
|
36
|
-
import { IconButton
|
|
37
|
+
import { IconButton } from '../Button';
|
|
37
38
|
import { ElevationProvider } from '../ElevationProvider';
|
|
38
39
|
|
|
39
40
|
//
|
|
@@ -86,9 +87,9 @@ const DialogOverlay: ForwardRefExoticComponent<DialogOverlayProps> = forwardRef<
|
|
|
86
87
|
return (
|
|
87
88
|
<DialogOverlayPrimitive
|
|
88
89
|
{...props}
|
|
89
|
-
className={tx('dialog.overlay', 'dialog__overlay', {}, classNames)}
|
|
90
|
-
ref={forwardedRef}
|
|
91
90
|
data-block-align={blockAlign}
|
|
91
|
+
className={tx('dialog.overlay', {}, classNames)}
|
|
92
|
+
ref={forwardedRef}
|
|
92
93
|
>
|
|
93
94
|
<OverlayLayoutProvider inOverlayLayout>{children}</OverlayLayoutProvider>
|
|
94
95
|
</DialogOverlayPrimitive>
|
|
@@ -110,25 +111,20 @@ type DialogContentProps = ThemedClassName<ComponentPropsWithRef<typeof DialogCon
|
|
|
110
111
|
};
|
|
111
112
|
|
|
112
113
|
const DialogContent: ForwardRefExoticComponent<DialogContentProps> = forwardRef<HTMLDivElement, DialogContentProps>(
|
|
113
|
-
({ classNames, children, size, inOverlayLayout: propsInOverlayLayout, ...props }, forwardedRef) => {
|
|
114
|
+
({ classNames, children, size = 'md', inOverlayLayout: propsInOverlayLayout, ...props }, forwardedRef) => {
|
|
114
115
|
const { tx } = useThemeContext();
|
|
115
116
|
const { inOverlayLayout } = useOverlayLayoutContext(DIALOG_CONTENT_NAME);
|
|
116
117
|
|
|
117
118
|
return (
|
|
118
119
|
<DialogContentPrimitive
|
|
120
|
+
{...props}
|
|
119
121
|
// NOTE: Radix warning unless set to undefined.
|
|
120
122
|
// https://www.radix-ui.com/primitives/docs/components/dialog#description
|
|
121
123
|
aria-describedby={undefined}
|
|
122
|
-
{
|
|
123
|
-
className={tx(
|
|
124
|
-
'dialog.content',
|
|
125
|
-
'dialog',
|
|
126
|
-
{ inOverlayLayout: propsInOverlayLayout || inOverlayLayout, size },
|
|
127
|
-
classNames,
|
|
128
|
-
)}
|
|
124
|
+
className={tx('dialog.content', { inOverlayLayout: propsInOverlayLayout || inOverlayLayout, size }, classNames)}
|
|
129
125
|
ref={forwardedRef}
|
|
130
126
|
>
|
|
131
|
-
{children}
|
|
127
|
+
<Column.Root>{children}</Column.Root>
|
|
132
128
|
</DialogContentPrimitive>
|
|
133
129
|
);
|
|
134
130
|
},
|
|
@@ -146,16 +142,56 @@ const DialogHeader: ForwardRefExoticComponent<DialogTitleProps> = forwardRef<HTM
|
|
|
146
142
|
({ classNames, srOnly, ...props }, forwardedRef) => {
|
|
147
143
|
const { tx } = useThemeContext();
|
|
148
144
|
return (
|
|
149
|
-
<
|
|
145
|
+
<Column.Segment asChild>
|
|
146
|
+
<div role='heading' {...props} className={tx('dialog.header', { srOnly }, [classNames])} ref={forwardedRef} />
|
|
147
|
+
</Column.Segment>
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
//
|
|
153
|
+
// CloseIconButton
|
|
154
|
+
//
|
|
155
|
+
|
|
156
|
+
type DialogCloseIconButtonProps = { label?: string };
|
|
157
|
+
|
|
158
|
+
const DialogCloseIconButton = forwardRef<HTMLButtonElement, DialogCloseIconButtonProps>(
|
|
159
|
+
({ label, ...props }, forwardedRef) => {
|
|
160
|
+
const { t } = useTranslation(osTranslations);
|
|
161
|
+
return (
|
|
162
|
+
<IconButton
|
|
150
163
|
{...props}
|
|
151
|
-
|
|
152
|
-
|
|
164
|
+
label={label ?? t('close dialog label')}
|
|
165
|
+
icon='ph--x--regular'
|
|
166
|
+
iconOnly
|
|
167
|
+
size={4}
|
|
168
|
+
density='fine'
|
|
169
|
+
variant='ghost'
|
|
153
170
|
ref={forwardedRef}
|
|
154
171
|
/>
|
|
155
172
|
);
|
|
156
173
|
},
|
|
157
174
|
);
|
|
158
175
|
|
|
176
|
+
//
|
|
177
|
+
// Body
|
|
178
|
+
//
|
|
179
|
+
|
|
180
|
+
type DialogBodyProps = PropsWithChildren;
|
|
181
|
+
|
|
182
|
+
const DialogBody: ForwardRefExoticComponent<DialogBodyProps> = forwardRef<HTMLDivElement, DialogBodyProps>(
|
|
183
|
+
({ children, ...props }, forwardedRef) => {
|
|
184
|
+
const { tx } = useThemeContext();
|
|
185
|
+
return (
|
|
186
|
+
<Column.Segment asChild>
|
|
187
|
+
<div role='none' {...props} className={tx('dialog.body')} ref={forwardedRef}>
|
|
188
|
+
{children}
|
|
189
|
+
</div>
|
|
190
|
+
</Column.Segment>
|
|
191
|
+
);
|
|
192
|
+
},
|
|
193
|
+
);
|
|
194
|
+
|
|
159
195
|
//
|
|
160
196
|
// Title
|
|
161
197
|
//
|
|
@@ -166,11 +202,7 @@ const DialogTitle: ForwardRefExoticComponent<DialogTitleProps> = forwardRef<HTML
|
|
|
166
202
|
({ classNames, srOnly, ...props }, forwardedRef) => {
|
|
167
203
|
const { tx } = useThemeContext();
|
|
168
204
|
return (
|
|
169
|
-
<DialogTitlePrimitive
|
|
170
|
-
{...props}
|
|
171
|
-
className={tx('dialog.title', 'dialog__title', { srOnly }, classNames)}
|
|
172
|
-
ref={forwardedRef}
|
|
173
|
-
/>
|
|
205
|
+
<DialogTitlePrimitive {...props} className={tx('dialog.title', { srOnly }, classNames)} ref={forwardedRef} />
|
|
174
206
|
);
|
|
175
207
|
},
|
|
176
208
|
);
|
|
@@ -189,44 +221,39 @@ const DialogDescription: ForwardRefExoticComponent<DialogTitleProps> = forwardRe
|
|
|
189
221
|
return (
|
|
190
222
|
<DialogDescriptionPrimitive
|
|
191
223
|
{...props}
|
|
192
|
-
className={tx('dialog.description',
|
|
224
|
+
className={tx('dialog.description', { srOnly }, classNames)}
|
|
193
225
|
ref={forwardedRef}
|
|
194
226
|
/>
|
|
195
227
|
);
|
|
196
228
|
});
|
|
197
229
|
|
|
198
230
|
//
|
|
199
|
-
//
|
|
231
|
+
// ActionBar
|
|
200
232
|
//
|
|
201
233
|
|
|
202
|
-
type
|
|
234
|
+
type DialogActionBarProps = ThemedClassName<PropsWithChildren>;
|
|
203
235
|
|
|
204
|
-
const
|
|
236
|
+
const DialogActionBar: ForwardRefExoticComponent<DialogActionBarProps> = forwardRef<
|
|
237
|
+
HTMLDivElement,
|
|
238
|
+
DialogActionBarProps
|
|
239
|
+
>(({ children, classNames, ...props }, forwardedRef) => {
|
|
240
|
+
const { tx } = useThemeContext();
|
|
241
|
+
return (
|
|
242
|
+
<Column.Segment asChild>
|
|
243
|
+
<div {...props} className={tx('dialog.actionbar', {}, classNames)} ref={forwardedRef}>
|
|
244
|
+
{children}
|
|
245
|
+
</div>
|
|
246
|
+
</Column.Segment>
|
|
247
|
+
);
|
|
248
|
+
});
|
|
205
249
|
|
|
206
250
|
//
|
|
207
|
-
// Close
|
|
251
|
+
// Close
|
|
208
252
|
//
|
|
209
253
|
|
|
210
|
-
type
|
|
254
|
+
type DialogCloseProps = DialogClosePrimitiveProps;
|
|
211
255
|
|
|
212
|
-
const
|
|
213
|
-
HTMLButtonElement,
|
|
214
|
-
DialogCloseIconButtonProps
|
|
215
|
-
>((props, forwardedRef) => {
|
|
216
|
-
const { t } = useTranslation(osTranslations);
|
|
217
|
-
return (
|
|
218
|
-
<IconButton
|
|
219
|
-
{...props}
|
|
220
|
-
label={props.label ?? t('close dialog label')}
|
|
221
|
-
icon='ph--x--regular'
|
|
222
|
-
iconOnly
|
|
223
|
-
size={4}
|
|
224
|
-
density='fine'
|
|
225
|
-
variant='ghost'
|
|
226
|
-
ref={forwardedRef}
|
|
227
|
-
/>
|
|
228
|
-
);
|
|
229
|
-
});
|
|
256
|
+
const DialogClose: FunctionComponent<DialogCloseProps> = DialogClosePrimitive;
|
|
230
257
|
|
|
231
258
|
//
|
|
232
259
|
// Dialog
|
|
@@ -239,8 +266,10 @@ export const Dialog = {
|
|
|
239
266
|
Overlay: DialogOverlay,
|
|
240
267
|
Content: DialogContent,
|
|
241
268
|
Header: DialogHeader,
|
|
269
|
+
Body: DialogBody,
|
|
242
270
|
Title: DialogTitle,
|
|
243
271
|
Description: DialogDescription,
|
|
272
|
+
ActionBar: DialogActionBar,
|
|
244
273
|
Close: DialogClose,
|
|
245
274
|
CloseIconButton: DialogCloseIconButton,
|
|
246
275
|
};
|
|
@@ -252,8 +281,9 @@ export type {
|
|
|
252
281
|
DialogOverlayProps,
|
|
253
282
|
DialogContentProps,
|
|
254
283
|
DialogHeaderProps,
|
|
284
|
+
DialogBodyProps,
|
|
255
285
|
DialogTitleProps,
|
|
256
286
|
DialogDescriptionProps,
|
|
287
|
+
DialogActionBarProps,
|
|
257
288
|
DialogCloseProps,
|
|
258
|
-
DialogCloseIconButtonProps,
|
|
259
289
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { ErrorBoundary } from '@dxos/react-error-boundary';
|
|
9
|
+
|
|
10
|
+
import { withLayout, withTheme } from '../../testing';
|
|
11
|
+
|
|
12
|
+
import { ErrorFallback } from './ErrorFallback';
|
|
13
|
+
import { ThrowError } from './ThrowError';
|
|
14
|
+
|
|
15
|
+
const BasicStory = () => {
|
|
16
|
+
return (
|
|
17
|
+
<ErrorBoundary name='story' FallbackComponent={ErrorFallback}>
|
|
18
|
+
<ThrowError />
|
|
19
|
+
</ErrorBoundary>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const StringErrorStory = () => {
|
|
24
|
+
return <ErrorFallback error='This is a string error message' data={{ context: 'story' }} />;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const meta: Meta = {
|
|
28
|
+
title: 'ui/react-ui-core/components/ErrorFallback',
|
|
29
|
+
component: ErrorFallback,
|
|
30
|
+
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
31
|
+
parameters: {
|
|
32
|
+
layout: 'fullscreen',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default meta;
|
|
37
|
+
|
|
38
|
+
type Story = StoryObj<typeof meta>;
|
|
39
|
+
|
|
40
|
+
export const Default: Story = {
|
|
41
|
+
render: BasicStory,
|
|
42
|
+
play: async () => {
|
|
43
|
+
// This story intentionally renders an ErrorBoundary fallback; clear the smoke-test error flag.
|
|
44
|
+
(window as any).__ERROR_BOUNDARY_ERRORS__ = [];
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const StringError: Story = {
|
|
49
|
+
render: StringErrorStory,
|
|
50
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type PropsWithChildren } from 'react';
|
|
6
|
+
import { type FallbackProps } from 'react-error-boundary';
|
|
7
|
+
|
|
8
|
+
import { safeStringify } from '@dxos/util';
|
|
9
|
+
|
|
10
|
+
import { ErrorStack } from './ErrorStack';
|
|
11
|
+
|
|
12
|
+
export type ErrorFallbackProps = PropsWithChildren<Pick<FallbackProps, 'error'> & { title?: string; data?: any }>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Themed fallback component for `ErrorBoundary`.
|
|
16
|
+
*/
|
|
17
|
+
export const ErrorFallback = ({ children, error, title, data }: ErrorFallbackProps) => {
|
|
18
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
19
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div role='alert' data-testid='error-boundary-fallback' className='flex flex-col p-4 gap-4 overflow-auto'>
|
|
23
|
+
<h1 className='text-lg text-info-text'>{title ?? 'Runtime Error'}</h1>
|
|
24
|
+
<p>{message}</p>
|
|
25
|
+
|
|
26
|
+
{isDev && error instanceof Error && (
|
|
27
|
+
<Section
|
|
28
|
+
title='Stack'
|
|
29
|
+
onClick={() => {
|
|
30
|
+
const text = error instanceof Error ? (error.stack ?? error.message) : String(error);
|
|
31
|
+
void navigator.clipboard.writeText(text);
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
<ErrorStack error={error} />
|
|
35
|
+
</Section>
|
|
36
|
+
)}
|
|
37
|
+
|
|
38
|
+
{data && (
|
|
39
|
+
<Section
|
|
40
|
+
title='Data'
|
|
41
|
+
onClick={() => {
|
|
42
|
+
void navigator.clipboard.writeText(JSON.stringify(data, undefined, 2));
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<pre className='overflow-x-auto text-xs'>{safeStringify(data, undefined, 2)}</pre>
|
|
46
|
+
</Section>
|
|
47
|
+
)}
|
|
48
|
+
|
|
49
|
+
{children}
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const Section = ({ children, title, onClick }: PropsWithChildren<{ title?: string; onClick?: () => void }>) => {
|
|
55
|
+
return (
|
|
56
|
+
<div className='flex flex-col gap-1'>
|
|
57
|
+
{onClick && (
|
|
58
|
+
<button
|
|
59
|
+
type='button'
|
|
60
|
+
onClick={onClick}
|
|
61
|
+
className='flex items-center gap-1 text-xs text-subdued hover:text-primary-500 transition-colors'
|
|
62
|
+
title={`Copy ${title}`}
|
|
63
|
+
>
|
|
64
|
+
<h2 className='text-xs uppercase text-subdued'>{title}</h2>
|
|
65
|
+
</button>
|
|
66
|
+
)}
|
|
67
|
+
{children}
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
};
|