@dxos/react-ui 0.8.4-main.3c1ae3b → 0.8.4-main.3eb6e50203
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-6DTBPJE4.mjs +774 -0
- package/dist/lib/browser/chunk-6DTBPJE4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3198 -66
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +34 -45
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-JKHQSGNU.mjs +776 -0
- package/dist/lib/node-esm/chunk-JKHQSGNU.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +3198 -66
- 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 +34 -45
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/components/AnchoredOverflow/AnchoredOverflow.d.ts +7 -0
- package/dist/types/src/components/AnchoredOverflow/AnchoredOverflow.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/Avatar.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 +1 -1
- package/dist/types/src/components/Button/Button.d.ts.map +1 -1
- package/dist/types/src/components/Button/IconButton.d.ts.map +1 -1
- package/dist/types/src/components/Button/ToggleGroup.d.ts +4 -4
- package/dist/types/src/components/Button/ToggleGroup.stories.d.ts +4 -4
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts +1 -1
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/AlertDialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.d.ts +23 -8
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts +7 -5
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ElevationProvider/ElevationProvider.d.ts +1 -1
- package/dist/types/src/components/ElevationProvider/ElevationProvider.d.ts.map +1 -1
- package/dist/types/src/components/Icon/Icon.d.ts +1 -1
- package/dist/types/src/components/Icon/Icon.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.d.ts +1 -1
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +2 -2
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/List.d.ts +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 +8 -9
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/{Menus → Menu}/ContextMenu.d.ts +6 -6
- package/dist/types/src/components/Menu/ContextMenu.d.ts.map +1 -0
- package/dist/types/src/components/Menu/ContextMenu.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Menus → Menu}/DropdownMenu.d.ts +1 -1
- package/dist/types/src/components/Menu/DropdownMenu.d.ts.map +1 -0
- package/dist/types/src/components/Menu/DropdownMenu.stories.d.ts.map +1 -0
- package/dist/types/src/components/Menu/index.d.ts.map +1 -0
- package/dist/types/src/components/Message/Message.d.ts +1 -1
- package/dist/types/src/components/Message/Message.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts +25 -26
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +46 -8
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts +2 -2
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts +1 -1
- package/dist/types/src/components/Select/Select.d.ts +9 -9
- package/dist/types/src/components/Select/Select.d.ts.map +1 -1
- package/dist/types/src/components/Separator/Separator.d.ts +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 +26 -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/Tag/Tag.d.ts +1 -1
- package/dist/types/src/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +2 -2
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +1 -8
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts +2 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.d.ts +4 -4
- package/dist/types/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +13 -12
- 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/index.d.ts +3 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/exemplars/generics.stories.d.ts +17 -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/hooks/useDensityContext.d.ts +1 -1
- package/dist/types/src/hooks/useDensityContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useElevationContext.d.ts +1 -1
- package/dist/types/src/hooks/useElevationContext.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -1
- 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/Container/Container.d.ts +23 -0
- package/dist/types/src/primitives/Container/Container.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/Container.stories.d.ts +11 -0
- package/dist/types/src/primitives/Container/Container.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/Layout.d.ts +18 -0
- package/dist/types/src/primitives/Container/Layout.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/Layout.stories.d.ts +10 -0
- package/dist/types/src/primitives/Container/Layout.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/index.d.ts +3 -0
- package/dist/types/src/primitives/Container/index.d.ts.map +1 -0
- package/dist/types/src/primitives/Flex/Flex.d.ts +8 -0
- package/dist/types/src/primitives/Flex/Flex.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/index.d.ts +3 -0
- package/dist/types/src/primitives/index.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/withLayout.d.ts +3 -3
- package/dist/types/src/testing/decorators/withLayout.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withLayoutVariants.d.ts +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/util/index.d.ts +1 -2
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -32
- package/src/components/AnchoredOverflow/AnchoredOverflow.tsx +10 -12
- package/src/components/Avatars/Avatar.stories.tsx +4 -4
- package/src/components/Avatars/Avatar.tsx +3 -10
- package/src/components/Avatars/AvatarGroup.stories.tsx +2 -2
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +2 -2
- package/src/components/Breadcrumb/Breadcrumb.tsx +5 -31
- package/src/components/Button/Button.stories.tsx +2 -2
- package/src/components/Button/Button.tsx +2 -8
- package/src/components/Button/IconButton.stories.tsx +2 -2
- package/src/components/Button/IconButton.tsx +5 -2
- package/src/components/Button/Toggle.stories.tsx +2 -2
- package/src/components/Button/ToggleGroup.stories.tsx +2 -2
- package/src/components/Clipboard/CopyButton.tsx +3 -3
- package/src/components/DensityProvider/DensityProvider.tsx +1 -1
- package/src/components/Dialog/AlertDialog.stories.tsx +2 -2
- package/src/components/Dialog/AlertDialog.tsx +3 -8
- package/src/components/Dialog/Dialog.stories.tsx +57 -23
- package/src/components/Dialog/Dialog.tsx +162 -43
- package/src/components/ElevationProvider/ElevationProvider.tsx +1 -1
- package/src/components/Icon/Icon.stories.tsx +3 -3
- package/src/components/Icon/Icon.tsx +2 -2
- package/src/components/Input/Input.stories.tsx +12 -11
- package/src/components/Input/Input.tsx +12 -27
- package/src/components/Link/Link.stories.tsx +2 -2
- package/src/components/Link/Link.tsx +1 -1
- package/src/components/List/List.stories.tsx +18 -14
- package/src/components/List/List.tsx +8 -14
- package/src/components/List/Tree.stories.tsx +2 -2
- package/src/components/List/Treegrid.stories.tsx +2 -2
- package/src/components/List/Treegrid.tsx +4 -9
- package/src/components/Main/Main.stories.tsx +41 -20
- package/src/components/Main/Main.tsx +128 -71
- package/src/components/{Menus → Menu}/ContextMenu.stories.tsx +2 -2
- package/src/components/{Menus → Menu}/ContextMenu.tsx +7 -31
- package/src/components/{Menus → Menu}/DropdownMenu.stories.tsx +2 -2
- package/src/components/{Menus → Menu}/DropdownMenu.tsx +65 -63
- package/src/components/Message/Message.stories.tsx +3 -3
- package/src/components/Message/Message.tsx +32 -23
- package/src/components/Popover/Popover.stories.tsx +2 -2
- package/src/components/Popover/Popover.tsx +38 -36
- package/src/components/ScrollArea/ScrollArea.stories.tsx +166 -40
- package/src/components/ScrollArea/ScrollArea.tsx +80 -82
- package/src/components/ScrollArea/index.ts +1 -1
- package/src/components/ScrollContainer/ScrollContainer.stories.tsx +2 -2
- package/src/components/ScrollContainer/ScrollContainer.tsx +14 -9
- package/src/components/Select/Select.stories.tsx +2 -2
- package/src/components/Select/Select.tsx +9 -25
- 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 +73 -0
- package/src/components/Splitter/Splitter.tsx +123 -0
- package/src/components/Splitter/index.ts +5 -0
- package/src/components/Status/Status.stories.tsx +2 -2
- package/src/components/Status/Status.tsx +2 -2
- package/src/components/Tag/Tag.stories.tsx +4 -4
- package/src/components/Tag/Tag.tsx +2 -7
- package/src/components/ThemeProvider/ThemeProvider.tsx +3 -4
- package/src/components/ThemeProvider/TranslationsProvider.tsx +1 -16
- package/src/components/ThemeProvider/index.ts +3 -3
- package/src/components/Toast/Toast.stories.tsx +2 -2
- package/src/components/Toast/Toast.tsx +6 -10
- package/src/components/Toolbar/Toolbar.stories.tsx +2 -2
- package/src/components/Toolbar/Toolbar.tsx +31 -12
- package/src/components/Tooltip/Tooltip.stories.tsx +2 -2
- package/src/components/Tooltip/Tooltip.tsx +24 -22
- package/src/components/index.ts +3 -1
- package/src/exemplars/generics.stories.tsx +44 -0
- package/src/exemplars/slot.stories.tsx +108 -0
- package/src/exemplars/tabster.stories.tsx +127 -0
- package/src/hooks/useDensityContext.ts +1 -1
- package/src/hooks/useElevationContext.ts +1 -1
- package/src/index.ts +2 -1
- package/src/playground/Controls.stories.tsx +3 -4
- package/src/playground/Custom.stories.tsx +2 -2
- package/src/playground/Typography.stories.tsx +2 -2
- package/src/primitives/Container/Container.stories.tsx +67 -0
- package/src/primitives/Container/Container.tsx +79 -0
- package/src/primitives/Container/Layout.stories.tsx +57 -0
- package/src/primitives/Container/Layout.tsx +61 -0
- package/src/primitives/Container/index.ts +6 -0
- package/src/primitives/Flex/Flex.tsx +26 -0
- package/src/primitives/Flex/index.ts +5 -0
- package/src/primitives/index.ts +6 -0
- package/src/testing/decorators/withLayout.tsx +22 -15
- package/src/testing/decorators/withLayoutVariants.tsx +2 -2
- package/src/testing/decorators/withTheme.tsx +21 -18
- package/src/util/index.ts +2 -2
- package/dist/lib/browser/chunk-BFCXP6YC.mjs +0 -4710
- package/dist/lib/browser/chunk-BFCXP6YC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F4Z46DD6.mjs +0 -4712
- package/dist/lib/node-esm/chunk-F4Z46DD6.mjs.map +0 -7
- package/dist/types/src/components/Menus/ContextMenu.d.ts.map +0 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts.map +0 -1
- package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +0 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts.map +0 -1
- package/dist/types/src/components/Menus/index.d.ts.map +0 -1
- package/dist/types/src/util/ThemedClassName.d.ts +0 -5
- package/dist/types/src/util/ThemedClassName.d.ts.map +0 -1
- package/dist/types/src/util/domino.d.ts +0 -18
- package/dist/types/src/util/domino.d.ts.map +0 -1
- package/src/util/ThemedClassName.ts +0 -7
- package/src/util/domino.ts +0 -53
- /package/dist/types/src/components/{Menus → Menu}/ContextMenu.stories.d.ts +0 -0
- /package/dist/types/src/components/{Menus → Menu}/DropdownMenu.stories.d.ts +0 -0
- /package/dist/types/src/components/{Menus → Menu}/index.d.ts +0 -0
- /package/src/components/{Menus → Menu}/index.ts +0 -0
|
@@ -24,13 +24,22 @@ import React, {
|
|
|
24
24
|
type ComponentPropsWithRef,
|
|
25
25
|
type ForwardRefExoticComponent,
|
|
26
26
|
type FunctionComponent,
|
|
27
|
+
type PropsWithChildren,
|
|
27
28
|
forwardRef,
|
|
28
29
|
} from 'react';
|
|
30
|
+
import { useTranslation } from 'react-i18next';
|
|
31
|
+
|
|
32
|
+
import { type DialogSize, osTranslations } from '@dxos/ui-theme';
|
|
29
33
|
|
|
30
34
|
import { useThemeContext } from '../../hooks';
|
|
31
35
|
import { type ThemedClassName } from '../../util';
|
|
36
|
+
import { IconButton, type IconButtonProps } from '../Button';
|
|
32
37
|
import { ElevationProvider } from '../ElevationProvider';
|
|
33
38
|
|
|
39
|
+
//
|
|
40
|
+
// Root
|
|
41
|
+
//
|
|
42
|
+
|
|
34
43
|
type DialogRootProps = DialogRootPrimitiveProps;
|
|
35
44
|
|
|
36
45
|
const DialogRoot: FunctionComponent<DialogRootProps> = (props) => (
|
|
@@ -39,52 +48,30 @@ const DialogRoot: FunctionComponent<DialogRootProps> = (props) => (
|
|
|
39
48
|
</ElevationProvider>
|
|
40
49
|
);
|
|
41
50
|
|
|
51
|
+
//
|
|
52
|
+
// Trigger
|
|
53
|
+
//
|
|
54
|
+
|
|
42
55
|
type DialogTriggerProps = DialogTriggerPrimitiveProps;
|
|
43
56
|
|
|
44
57
|
const DialogTrigger: FunctionComponent<DialogTriggerProps> = DialogTriggerPrimitive;
|
|
45
58
|
|
|
59
|
+
//
|
|
60
|
+
// Portal
|
|
61
|
+
//
|
|
62
|
+
|
|
46
63
|
type DialogPortalProps = DialogPortalPrimitiveProps;
|
|
47
64
|
|
|
48
65
|
const DialogPortal: FunctionComponent<DialogPortalProps> = DialogPortalPrimitive;
|
|
49
66
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
({ classNames, srOnly, ...props }, forwardedRef) => {
|
|
54
|
-
const { tx } = useThemeContext();
|
|
55
|
-
return (
|
|
56
|
-
<DialogTitlePrimitive
|
|
57
|
-
{...props}
|
|
58
|
-
className={tx('dialog.title', 'dialog__title', { srOnly }, classNames)}
|
|
59
|
-
ref={forwardedRef}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
},
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
type DialogDescriptionProps = ThemedClassName<DialogDescriptionPrimitiveProps> & { srOnly?: boolean };
|
|
66
|
-
|
|
67
|
-
const DialogDescription: ForwardRefExoticComponent<DialogTitleProps> = forwardRef<
|
|
68
|
-
HTMLParagraphElement,
|
|
69
|
-
DialogDescriptionProps
|
|
70
|
-
>(({ classNames, srOnly, ...props }, forwardedRef) => {
|
|
71
|
-
const { tx } = useThemeContext();
|
|
72
|
-
return (
|
|
73
|
-
<DialogDescriptionPrimitive
|
|
74
|
-
{...props}
|
|
75
|
-
className={tx('dialog.description', 'dialog__description', { srOnly }, classNames)}
|
|
76
|
-
ref={forwardedRef}
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
type DialogCloseProps = DialogClosePrimitiveProps;
|
|
67
|
+
//
|
|
68
|
+
// Overlay
|
|
69
|
+
//
|
|
82
70
|
|
|
83
|
-
const
|
|
71
|
+
const DIALOG_OVERLAY_NAME = 'DialogOverlay';
|
|
84
72
|
|
|
85
73
|
type OverlayLayoutContextValue = { inOverlayLayout?: boolean };
|
|
86
|
-
|
|
87
|
-
const DIALOG_CONTENT_NAME = 'DialogContent';
|
|
74
|
+
|
|
88
75
|
const [OverlayLayoutProvider, useOverlayLayoutContext] = createContext<OverlayLayoutContextValue>(
|
|
89
76
|
DIALOG_OVERLAY_NAME,
|
|
90
77
|
{},
|
|
@@ -99,7 +86,7 @@ const DialogOverlay: ForwardRefExoticComponent<DialogOverlayProps> = forwardRef<
|
|
|
99
86
|
return (
|
|
100
87
|
<DialogOverlayPrimitive
|
|
101
88
|
{...props}
|
|
102
|
-
className={tx('dialog.overlay',
|
|
89
|
+
className={tx('dialog.overlay', {}, classNames)}
|
|
103
90
|
ref={forwardedRef}
|
|
104
91
|
data-block-align={blockAlign}
|
|
105
92
|
>
|
|
@@ -111,12 +98,19 @@ const DialogOverlay: ForwardRefExoticComponent<DialogOverlayProps> = forwardRef<
|
|
|
111
98
|
|
|
112
99
|
DialogOverlay.displayName = DIALOG_OVERLAY_NAME;
|
|
113
100
|
|
|
101
|
+
//
|
|
102
|
+
// Content
|
|
103
|
+
//
|
|
104
|
+
|
|
105
|
+
const DIALOG_CONTENT_NAME = 'DialogContent';
|
|
106
|
+
|
|
114
107
|
type DialogContentProps = ThemedClassName<ComponentPropsWithRef<typeof DialogContentPrimitive>> & {
|
|
108
|
+
size?: DialogSize;
|
|
115
109
|
inOverlayLayout?: boolean;
|
|
116
110
|
};
|
|
117
111
|
|
|
118
112
|
const DialogContent: ForwardRefExoticComponent<DialogContentProps> = forwardRef<HTMLDivElement, DialogContentProps>(
|
|
119
|
-
({ classNames, children, inOverlayLayout: propsInOverlayLayout, ...props }, forwardedRef) => {
|
|
113
|
+
({ classNames, children, size, inOverlayLayout: propsInOverlayLayout, ...props }, forwardedRef) => {
|
|
120
114
|
const { tx } = useThemeContext();
|
|
121
115
|
const { inOverlayLayout } = useOverlayLayoutContext(DIALOG_CONTENT_NAME);
|
|
122
116
|
|
|
@@ -126,12 +120,7 @@ const DialogContent: ForwardRefExoticComponent<DialogContentProps> = forwardRef<
|
|
|
126
120
|
// https://www.radix-ui.com/primitives/docs/components/dialog#description
|
|
127
121
|
aria-describedby={undefined}
|
|
128
122
|
{...props}
|
|
129
|
-
className={tx(
|
|
130
|
-
'dialog.content',
|
|
131
|
-
'dialog',
|
|
132
|
-
{ inOverlayLayout: propsInOverlayLayout || inOverlayLayout },
|
|
133
|
-
classNames,
|
|
134
|
-
)}
|
|
123
|
+
className={tx('dialog.content', { inOverlayLayout: propsInOverlayLayout || inOverlayLayout, size }, classNames)}
|
|
135
124
|
ref={forwardedRef}
|
|
136
125
|
>
|
|
137
126
|
{children}
|
|
@@ -142,15 +131,141 @@ const DialogContent: ForwardRefExoticComponent<DialogContentProps> = forwardRef<
|
|
|
142
131
|
|
|
143
132
|
DialogContent.displayName = DIALOG_CONTENT_NAME;
|
|
144
133
|
|
|
134
|
+
//
|
|
135
|
+
// Header
|
|
136
|
+
//
|
|
137
|
+
|
|
138
|
+
type DialogHeaderProps = ThemedClassName<PropsWithChildren> & { srOnly?: boolean };
|
|
139
|
+
|
|
140
|
+
const DialogHeader: ForwardRefExoticComponent<DialogTitleProps> = forwardRef<HTMLHeadingElement, DialogTitleProps>(
|
|
141
|
+
({ classNames, srOnly, ...props }, forwardedRef) => {
|
|
142
|
+
const { tx } = useThemeContext();
|
|
143
|
+
return <div {...props} role='header' className={tx('dialog.header', { srOnly }, classNames)} ref={forwardedRef} />;
|
|
144
|
+
},
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
//
|
|
148
|
+
// Body
|
|
149
|
+
//
|
|
150
|
+
|
|
151
|
+
type DialogBodyProps = PropsWithChildren;
|
|
152
|
+
|
|
153
|
+
const DialogBody: ForwardRefExoticComponent<DialogBodyProps> = forwardRef<HTMLDivElement, DialogBodyProps>(
|
|
154
|
+
({ children, ...props }, forwardedRef) => {
|
|
155
|
+
const { tx } = useThemeContext();
|
|
156
|
+
return (
|
|
157
|
+
<div {...props} className={tx('dialog.body')} ref={forwardedRef}>
|
|
158
|
+
{children}
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
},
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
// TODO(burdon): Add ActionBar.
|
|
165
|
+
|
|
166
|
+
//
|
|
167
|
+
// Title
|
|
168
|
+
//
|
|
169
|
+
|
|
170
|
+
type DialogTitleProps = ThemedClassName<DialogTitlePrimitiveProps> & { srOnly?: boolean };
|
|
171
|
+
|
|
172
|
+
const DialogTitle: ForwardRefExoticComponent<DialogTitleProps> = forwardRef<HTMLHeadingElement, DialogTitleProps>(
|
|
173
|
+
({ classNames, srOnly, ...props }, forwardedRef) => {
|
|
174
|
+
const { tx } = useThemeContext();
|
|
175
|
+
return (
|
|
176
|
+
<DialogTitlePrimitive {...props} className={tx('dialog.title', { srOnly }, classNames)} ref={forwardedRef} />
|
|
177
|
+
);
|
|
178
|
+
},
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
//
|
|
182
|
+
// Description
|
|
183
|
+
//
|
|
184
|
+
|
|
185
|
+
type DialogDescriptionProps = ThemedClassName<DialogDescriptionPrimitiveProps> & { srOnly?: boolean };
|
|
186
|
+
|
|
187
|
+
const DialogDescription: ForwardRefExoticComponent<DialogTitleProps> = forwardRef<
|
|
188
|
+
HTMLParagraphElement,
|
|
189
|
+
DialogDescriptionProps
|
|
190
|
+
>(({ classNames, srOnly, ...props }, forwardedRef) => {
|
|
191
|
+
const { tx } = useThemeContext();
|
|
192
|
+
return (
|
|
193
|
+
<DialogDescriptionPrimitive
|
|
194
|
+
{...props}
|
|
195
|
+
className={tx('dialog.description', { srOnly }, classNames)}
|
|
196
|
+
ref={forwardedRef}
|
|
197
|
+
/>
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
//
|
|
202
|
+
// ActionBar
|
|
203
|
+
//
|
|
204
|
+
|
|
205
|
+
type DialogActionBarProps = ThemedClassName<PropsWithChildren>;
|
|
206
|
+
|
|
207
|
+
const DialogActionBar: ForwardRefExoticComponent<DialogActionBarProps> = forwardRef<
|
|
208
|
+
HTMLDivElement,
|
|
209
|
+
DialogActionBarProps
|
|
210
|
+
>(({ children, classNames, ...props }, forwardedRef) => {
|
|
211
|
+
const { tx } = useThemeContext();
|
|
212
|
+
return (
|
|
213
|
+
<div {...props} className={tx('dialog.actionbar', {}, classNames)} ref={forwardedRef}>
|
|
214
|
+
{children}
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
//
|
|
220
|
+
// Close
|
|
221
|
+
//
|
|
222
|
+
|
|
223
|
+
type DialogCloseProps = DialogClosePrimitiveProps;
|
|
224
|
+
|
|
225
|
+
const DialogClose: FunctionComponent<DialogCloseProps> = DialogClosePrimitive;
|
|
226
|
+
|
|
227
|
+
//
|
|
228
|
+
// Close Button
|
|
229
|
+
//
|
|
230
|
+
|
|
231
|
+
type DialogCloseIconButtonProps = ThemedClassName<Partial<IconButtonProps>>;
|
|
232
|
+
|
|
233
|
+
const DialogCloseIconButton: ForwardRefExoticComponent<DialogCloseIconButtonProps> = forwardRef<
|
|
234
|
+
HTMLButtonElement,
|
|
235
|
+
DialogCloseIconButtonProps
|
|
236
|
+
>((props, forwardedRef) => {
|
|
237
|
+
const { t } = useTranslation(osTranslations);
|
|
238
|
+
return (
|
|
239
|
+
<IconButton
|
|
240
|
+
{...props}
|
|
241
|
+
label={props.label ?? t('close dialog label')}
|
|
242
|
+
icon='ph--x--regular'
|
|
243
|
+
iconOnly
|
|
244
|
+
size={4}
|
|
245
|
+
density='fine'
|
|
246
|
+
variant='ghost'
|
|
247
|
+
ref={forwardedRef}
|
|
248
|
+
/>
|
|
249
|
+
);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
//
|
|
253
|
+
// Dialog
|
|
254
|
+
//
|
|
255
|
+
|
|
145
256
|
export const Dialog = {
|
|
146
257
|
Root: DialogRoot,
|
|
147
258
|
Trigger: DialogTrigger,
|
|
148
259
|
Portal: DialogPortal,
|
|
149
260
|
Overlay: DialogOverlay,
|
|
150
261
|
Content: DialogContent,
|
|
262
|
+
Header: DialogHeader,
|
|
263
|
+
Body: DialogBody,
|
|
151
264
|
Title: DialogTitle,
|
|
152
265
|
Description: DialogDescription,
|
|
266
|
+
ActionBar: DialogActionBar,
|
|
153
267
|
Close: DialogClose,
|
|
268
|
+
CloseIconButton: DialogCloseIconButton,
|
|
154
269
|
};
|
|
155
270
|
|
|
156
271
|
export type {
|
|
@@ -159,7 +274,11 @@ export type {
|
|
|
159
274
|
DialogPortalProps,
|
|
160
275
|
DialogOverlayProps,
|
|
161
276
|
DialogContentProps,
|
|
277
|
+
DialogHeaderProps,
|
|
278
|
+
DialogBodyProps,
|
|
162
279
|
DialogTitleProps,
|
|
163
280
|
DialogDescriptionProps,
|
|
281
|
+
DialogActionBarProps,
|
|
164
282
|
DialogCloseProps,
|
|
283
|
+
DialogCloseIconButtonProps,
|
|
165
284
|
};
|
|
@@ -6,7 +6,7 @@ import { IconBase, type IconProps, type IconWeight } from '@phosphor-icons/react
|
|
|
6
6
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
7
|
import React, { type FC, type ReactElement, type SVGProps, forwardRef } from 'react';
|
|
8
8
|
|
|
9
|
-
import { getSize, mx } from '@dxos/
|
|
9
|
+
import { getSize, mx } from '@dxos/ui-theme';
|
|
10
10
|
|
|
11
11
|
import { withTheme } from '../../testing';
|
|
12
12
|
|
|
@@ -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
|
},
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type Primitive } from '@radix-ui/react-primitive';
|
|
6
6
|
import React, { type ComponentPropsWithRef, forwardRef, memo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { type Size } from '@dxos/
|
|
8
|
+
import { type Size } from '@dxos/ui-types';
|
|
9
9
|
|
|
10
10
|
import { useIconHref, useThemeContext } from '../../hooks';
|
|
11
11
|
import { type ThemedClassName } from '../../util';
|
|
@@ -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
|
);
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import { type MessageValence } from '@dxos/
|
|
8
|
+
import { mx, surfaceShadow } from '@dxos/ui-theme';
|
|
9
|
+
import { type MessageValence } from '@dxos/ui-types';
|
|
10
10
|
|
|
11
11
|
import { withTheme } from '../../testing';
|
|
12
12
|
|
|
@@ -39,7 +39,7 @@ type BaseProps = Partial<{
|
|
|
39
39
|
validationMessage: string;
|
|
40
40
|
}>;
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const InputWrapper = ({
|
|
43
43
|
kind,
|
|
44
44
|
label,
|
|
45
45
|
description,
|
|
@@ -74,31 +74,31 @@ const Wrapper = ({
|
|
|
74
74
|
const DefaultStory = (props: BaseProps) => {
|
|
75
75
|
return (
|
|
76
76
|
<div className='space-b-4'>
|
|
77
|
-
<div className={mx(baseSurface, 'p-4 rounded-md')}>
|
|
78
|
-
<
|
|
77
|
+
<div className={mx('bg-baseSurface', 'p-4 rounded-md')}>
|
|
78
|
+
<InputWrapper {...props} />
|
|
79
79
|
</div>
|
|
80
80
|
<div className={mx('bg-cardSurface', 'p-4 rounded-md', surfaceShadow({ elevation: 'positioned' }))}>
|
|
81
|
-
<
|
|
81
|
+
<InputWrapper {...props} />
|
|
82
82
|
</div>
|
|
83
|
-
<div className={mx(modalSurface, 'p-4 rounded-md', surfaceShadow({ elevation: 'dialog' }))}>
|
|
84
|
-
<
|
|
83
|
+
<div className={mx('bg-modalSurface', 'p-4 rounded-md', surfaceShadow({ elevation: 'dialog' }))}>
|
|
84
|
+
<InputWrapper {...props} />
|
|
85
85
|
</div>
|
|
86
86
|
</div>
|
|
87
87
|
);
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
const meta = {
|
|
91
|
-
title: 'ui/react-ui-core/Input',
|
|
91
|
+
title: 'ui/react-ui-core/components/Input',
|
|
92
92
|
component: Input.Root as any,
|
|
93
93
|
render: DefaultStory,
|
|
94
|
-
decorators: [withTheme],
|
|
94
|
+
decorators: [withTheme()],
|
|
95
95
|
} satisfies Meta<typeof DefaultStory>;
|
|
96
96
|
|
|
97
97
|
export default meta;
|
|
98
98
|
|
|
99
99
|
type Story = StoryObj<BaseProps & Variant>;
|
|
100
100
|
|
|
101
|
-
export const
|
|
101
|
+
export const DensityCoarse: Story = {
|
|
102
102
|
args: {
|
|
103
103
|
kind: 'text',
|
|
104
104
|
label: 'Hello',
|
|
@@ -109,6 +109,7 @@ export const Default: Story = {
|
|
|
109
109
|
descriptionVisuallyHidden: false,
|
|
110
110
|
validationMessage: '',
|
|
111
111
|
validationValence: undefined,
|
|
112
|
+
density: 'coarse',
|
|
112
113
|
},
|
|
113
114
|
};
|
|
114
115
|
|
|
@@ -27,8 +27,8 @@ import {
|
|
|
27
27
|
type ValidationProps as ValidationPrimitiveProps,
|
|
28
28
|
useInputContext,
|
|
29
29
|
} from '@dxos/react-input';
|
|
30
|
-
import { mx } from '@dxos/
|
|
31
|
-
import { type ClassNameValue, type Density, type Elevation, type Size } from '@dxos/
|
|
30
|
+
import { mx } from '@dxos/ui-theme';
|
|
31
|
+
import { type ClassNameValue, type Density, type Elevation, type Size } from '@dxos/ui-types';
|
|
32
32
|
|
|
33
33
|
import { useDensityContext, useElevationContext, useThemeContext } from '../../hooks';
|
|
34
34
|
import { type ThemedClassName } from '../../util';
|
|
@@ -43,7 +43,7 @@ type LabelProps = ThemedClassName<LabelPrimitiveProps> & { srOnly?: boolean };
|
|
|
43
43
|
const Label = forwardRef<HTMLLabelElement, LabelProps>(({ srOnly, classNames, children, ...props }, forwardedRef) => {
|
|
44
44
|
const { tx } = useThemeContext();
|
|
45
45
|
return (
|
|
46
|
-
<LabelPrimitive {...props} className={tx('input.label',
|
|
46
|
+
<LabelPrimitive {...props} className={tx('input.label', { srOnly }, classNames)} ref={forwardedRef}>
|
|
47
47
|
{children}
|
|
48
48
|
</LabelPrimitive>
|
|
49
49
|
);
|
|
@@ -55,11 +55,7 @@ const Description = forwardRef<HTMLSpanElement, DescriptionProps>(
|
|
|
55
55
|
({ srOnly, classNames, children, ...props }, forwardedRef) => {
|
|
56
56
|
const { tx } = useThemeContext();
|
|
57
57
|
return (
|
|
58
|
-
<DescriptionPrimitive
|
|
59
|
-
{...props}
|
|
60
|
-
className={tx('input.description', 'input__description', { srOnly }, classNames)}
|
|
61
|
-
ref={forwardedRef}
|
|
62
|
-
>
|
|
58
|
+
<DescriptionPrimitive {...props} className={tx('input.description', { srOnly }, classNames)} ref={forwardedRef}>
|
|
63
59
|
{children}
|
|
64
60
|
</DescriptionPrimitive>
|
|
65
61
|
);
|
|
@@ -75,12 +71,7 @@ const Validation = forwardRef<HTMLSpanElement, InputScopedProps<ValidationProps>
|
|
|
75
71
|
return (
|
|
76
72
|
<ValidationPrimitive
|
|
77
73
|
{...props}
|
|
78
|
-
className={tx(
|
|
79
|
-
'input.validation',
|
|
80
|
-
`input__validation-message input__validation-message--${validationValence}`,
|
|
81
|
-
{ srOnly, validationValence },
|
|
82
|
-
classNames,
|
|
83
|
-
)}
|
|
74
|
+
className={tx('input.validation', { srOnly, validationValence }, classNames)}
|
|
84
75
|
ref={forwardedRef}
|
|
85
76
|
>
|
|
86
77
|
{children}
|
|
@@ -97,7 +88,7 @@ const DescriptionAndValidation = forwardRef<HTMLParagraphElement, DescriptionAnd
|
|
|
97
88
|
return (
|
|
98
89
|
<DescriptionAndValidationPrimitive
|
|
99
90
|
{...props}
|
|
100
|
-
className={tx('input.descriptionAndValidation',
|
|
91
|
+
className={tx('input.descriptionAndValidation', { srOnly }, classNames)}
|
|
101
92
|
ref={forwardedRef}
|
|
102
93
|
>
|
|
103
94
|
{children}
|
|
@@ -119,7 +110,6 @@ const PinInput = forwardRef<HTMLInputElement, PinInputProps>(
|
|
|
119
110
|
elevation: propsElevation,
|
|
120
111
|
segmentClassName: propsSegmentClassName,
|
|
121
112
|
inputClassName,
|
|
122
|
-
variant,
|
|
123
113
|
...props
|
|
124
114
|
},
|
|
125
115
|
forwardedRef,
|
|
@@ -128,12 +118,10 @@ const PinInput = forwardRef<HTMLInputElement, PinInputProps>(
|
|
|
128
118
|
const { tx } = useThemeContext();
|
|
129
119
|
const density = useDensityContext(propsDensity);
|
|
130
120
|
const elevation = useElevationContext(propsElevation);
|
|
131
|
-
|
|
132
121
|
const segmentClassName = useCallback(
|
|
133
122
|
({ focused, validationValence }: Parameters<Exclude<PinInputPrimitiveProps['segmentClassName'], undefined>>[0]) =>
|
|
134
123
|
tx(
|
|
135
124
|
'input.input',
|
|
136
|
-
'input--pin-segment',
|
|
137
125
|
{
|
|
138
126
|
variant: 'static',
|
|
139
127
|
focused,
|
|
@@ -143,9 +131,10 @@ const PinInput = forwardRef<HTMLInputElement, PinInputProps>(
|
|
|
143
131
|
validationValence,
|
|
144
132
|
},
|
|
145
133
|
propsSegmentClassName,
|
|
146
|
-
),
|
|
134
|
+
) || '',
|
|
147
135
|
[tx, props.disabled, elevation, propsElevation, density],
|
|
148
136
|
);
|
|
137
|
+
|
|
149
138
|
return (
|
|
150
139
|
<PinInputPrimitive
|
|
151
140
|
{...{
|
|
@@ -153,7 +142,7 @@ const PinInput = forwardRef<HTMLInputElement, PinInputProps>(
|
|
|
153
142
|
segmentClassName,
|
|
154
143
|
...(props.autoFocus && !hasIosKeyboard && { autoFocus: true }),
|
|
155
144
|
}}
|
|
156
|
-
inputClassName={tx('input.inputWithSegments',
|
|
145
|
+
inputClassName={tx('input.inputWithSegments', { disabled: props.disabled }, inputClassName) || ''}
|
|
157
146
|
ref={forwardedRef}
|
|
158
147
|
/>
|
|
159
148
|
);
|
|
@@ -174,13 +163,11 @@ const TextInput = forwardRef<HTMLInputElement, InputScopedProps<TextInputProps>>
|
|
|
174
163
|
forwardedRef,
|
|
175
164
|
) => {
|
|
176
165
|
const { hasIosKeyboard } = useThemeContext();
|
|
177
|
-
const
|
|
166
|
+
const { tx } = useThemeContext();
|
|
178
167
|
const density = useDensityContext(propsDensity);
|
|
179
168
|
const elevation = useElevationContext(propsElevation);
|
|
180
169
|
const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
|
|
181
170
|
|
|
182
|
-
const { tx } = themeContextValue;
|
|
183
|
-
|
|
184
171
|
return (
|
|
185
172
|
<TextInputPrimitive
|
|
186
173
|
{...props}
|
|
@@ -188,7 +175,6 @@ const TextInput = forwardRef<HTMLInputElement, InputScopedProps<TextInputProps>>
|
|
|
188
175
|
{...{ 'data-1p-ignore': noAutoFill }}
|
|
189
176
|
className={tx(
|
|
190
177
|
'input.input',
|
|
191
|
-
'input',
|
|
192
178
|
{
|
|
193
179
|
variant,
|
|
194
180
|
disabled: props.disabled,
|
|
@@ -220,7 +206,6 @@ const TextArea = forwardRef<HTMLTextAreaElement, InputScopedProps<TextAreaProps>
|
|
|
220
206
|
{...props}
|
|
221
207
|
className={tx(
|
|
222
208
|
'input.input',
|
|
223
|
-
'input--text-area',
|
|
224
209
|
{
|
|
225
210
|
variant,
|
|
226
211
|
disabled: props.disabled,
|
|
@@ -278,13 +263,13 @@ const Checkbox: ForwardRefExoticComponent<CheckboxProps> = forwardRef<
|
|
|
278
263
|
'aria-invalid': 'true' as const,
|
|
279
264
|
'aria-errormessage': errorMessageId,
|
|
280
265
|
}),
|
|
281
|
-
className: tx('input.checkbox',
|
|
266
|
+
className: tx('input.checkbox', { size }, 'shrink-0', classNames),
|
|
282
267
|
}}
|
|
283
268
|
ref={forwardedRef}
|
|
284
269
|
>
|
|
285
270
|
<Icon
|
|
286
271
|
icon={checked === 'indeterminate' ? 'ph--minus--regular' : 'ph--check--regular'}
|
|
287
|
-
classNames={tx('input.checkboxIndicator',
|
|
272
|
+
classNames={tx('input.checkboxIndicator', { size, checked })}
|
|
288
273
|
/>
|
|
289
274
|
</CheckboxPrimitive>
|
|
290
275
|
);
|
|
@@ -9,9 +9,9 @@ import { withTheme } from '../../testing';
|
|
|
9
9
|
import { Link } from './Link';
|
|
10
10
|
|
|
11
11
|
const meta = {
|
|
12
|
-
title: 'ui/react-ui-core/Link',
|
|
12
|
+
title: 'ui/react-ui-core/components/Link',
|
|
13
13
|
component: Link,
|
|
14
|
-
decorators: [withTheme],
|
|
14
|
+
decorators: [withTheme()],
|
|
15
15
|
} satisfies Meta<typeof Link>;
|
|
16
16
|
|
|
17
17
|
export default meta;
|
|
@@ -19,6 +19,6 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
19
19
|
({ asChild, variant, classNames, ...props }, forwardedRef) => {
|
|
20
20
|
const { tx } = useThemeContext();
|
|
21
21
|
const Root = asChild ? Slot : Primitive.a;
|
|
22
|
-
return <Root {...props} className={tx('link.root',
|
|
22
|
+
return <Root {...props} className={tx('link.root', { variant }, classNames)} ref={forwardedRef} />;
|
|
23
23
|
},
|
|
24
24
|
);
|
|
@@ -7,7 +7,7 @@ import { SortableContext, arrayMove, useSortable, verticalListSortingStrategy }
|
|
|
7
7
|
import { CSS } from '@dnd-kit/utilities';
|
|
8
8
|
import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
9
9
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
10
|
-
import React, { type ReactNode, useState } from 'react';
|
|
10
|
+
import React, { type ReactNode, useCallback, useState } from 'react';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
getSize,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
ghostSelectedTrackingInterFromNormal,
|
|
17
17
|
mx,
|
|
18
18
|
surfaceShadow,
|
|
19
|
-
} from '@dxos/
|
|
19
|
+
} from '@dxos/ui-theme';
|
|
20
20
|
|
|
21
21
|
import { withTheme } from '../../testing';
|
|
22
22
|
import { Icon } from '../Icon';
|
|
@@ -24,9 +24,9 @@ import { Icon } from '../Icon';
|
|
|
24
24
|
import { List, ListItem, type ListScopedProps } from './List';
|
|
25
25
|
|
|
26
26
|
const meta = {
|
|
27
|
-
title: 'ui/react-ui-core/List',
|
|
27
|
+
title: 'ui/react-ui-core/components/List',
|
|
28
28
|
component: List,
|
|
29
|
-
decorators: [withTheme],
|
|
29
|
+
decorators: [withTheme()],
|
|
30
30
|
} satisfies Meta<typeof List>;
|
|
31
31
|
|
|
32
32
|
export default meta;
|
|
@@ -63,16 +63,20 @@ export const UniformSizeDraggable: Story = {
|
|
|
63
63
|
})),
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
-
const handleDragEnd = (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
const handleDragEnd = useCallback(
|
|
67
|
+
(event: DragEndEvent) => {
|
|
68
|
+
const { active, over } = event;
|
|
69
|
+
if (active.id !== over?.id) {
|
|
70
|
+
setItems((items) => {
|
|
71
|
+
const oldIndex = items.findIndex((item) => item.id === active.id);
|
|
72
|
+
const newIndex = items.findIndex((item) => item.id === over?.id);
|
|
73
|
+
return arrayMove(items, oldIndex, newIndex);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
[items],
|
|
78
|
+
);
|
|
79
|
+
|
|
76
80
|
return (
|
|
77
81
|
<DndContext onDragEnd={handleDragEnd}>
|
|
78
82
|
<SortableContext items={items.map(({ id }) => id)} strategy={verticalListSortingStrategy}>
|