@dxos/react-ui 0.6.13 → 0.6.14-main.69511f5
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/index.mjs +731 -198
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +2925 -0
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -0
- package/dist/lib/node-esm/index.mjs +2924 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts +15 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts +6 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts +9 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Button.d.ts +1 -1
- package/dist/types/src/components/Buttons/Button.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Button.stories.d.ts +12 -17
- package/dist/types/src/components/Buttons/Button.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts +2 -1
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts +20 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts +12 -1
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts +11 -1
- package/dist/types/src/components/Dialogs/Dialog.stories.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.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +16 -1
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/List.stories.d.ts +2 -3
- package/dist/types/src/components/Lists/List.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Tree.stories.d.ts +5 -1
- package/dist/types/src/components/Lists/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts +3 -2
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts +5 -1
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts +29 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menus/DropdownMenu.d.ts +105 -44
- package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +1 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts +29 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +6 -1
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +87 -21
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts +20 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +20 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.stories.d.ts +10 -11
- package/dist/types/src/components/Select/Select.stories.d.ts.map +1 -1
- package/dist/types/src/components/Status/Status.stories.d.ts +0 -3
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +4 -5
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +4 -4
- package/dist/types/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts +20 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +4 -2
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +30 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +13 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useThemeContext.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts +2 -6
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Surfaces.stories.d.ts +6 -2
- package/dist/types/src/playground/Surfaces.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Typography.stories.d.ts +1 -1
- package/dist/types/src/testing/decorators/index.d.ts +1 -0
- package/dist/types/src/testing/decorators/index.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withVariants.d.ts +13 -0
- package/dist/types/src/testing/decorators/withVariants.d.ts.map +1 -0
- package/package.json +28 -17
- package/src/components/Avatars/Avatar.stories.tsx +3 -2
- package/src/components/Avatars/AvatarGroup.stories.tsx +3 -2
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +3 -2
- package/src/components/Buttons/Button.stories.tsx +34 -63
- package/src/components/Buttons/Button.tsx +46 -36
- package/src/components/Buttons/Toggle.stories.tsx +3 -2
- package/src/components/Buttons/ToggleGroup.stories.tsx +3 -2
- package/src/components/DensityProvider/DensityProvider.tsx +1 -1
- package/src/components/Dialogs/AlertDialog.stories.tsx +3 -2
- package/src/components/Dialogs/Dialog.stories.tsx +3 -2
- package/src/components/Icon/Icon.tsx +11 -9
- package/src/components/Input/Input.stories.tsx +4 -3
- package/src/components/Link/Link.stories.tsx +1 -1
- package/src/components/Lists/List.stories.tsx +4 -4
- package/src/components/Lists/Tree.stories.tsx +3 -2
- package/src/components/Lists/Treegrid.stories.tsx +7 -5
- package/src/components/Main/Main.stories.tsx +3 -2
- package/src/components/Menus/ContextMenu.stories.tsx +3 -2
- package/src/components/Menus/DropdownMenu.stories.tsx +43 -3
- package/src/components/Menus/DropdownMenu.tsx +518 -69
- package/src/components/Message/Message.stories.tsx +3 -2
- package/src/components/Popover/Popover.stories.tsx +27 -3
- package/src/components/Popover/Popover.tsx +524 -55
- package/src/components/ScrollArea/ScrollArea.stories.tsx +3 -2
- package/src/components/Select/Select.stories.tsx +14 -31
- package/src/components/Select/Select.tsx +9 -10
- package/src/components/Status/Status.stories.tsx +1 -2
- package/src/components/Tag/Tag.stories.tsx +1 -1
- package/src/components/ThemeProvider/ThemeProvider.tsx +17 -18
- package/src/components/Toast/Toast.stories.tsx +3 -2
- package/src/components/Toast/Toast.tsx +1 -4
- package/src/components/Toolbar/Toolbar.stories.tsx +3 -2
- package/src/components/Toolbar/Toolbar.tsx +21 -1
- package/src/components/Tooltip/Tooltip.stories.tsx +3 -2
- package/src/hooks/useThemeContext.ts +3 -1
- package/src/playground/Controls.stories.tsx +7 -10
- package/src/playground/Surfaces.stories.tsx +4 -3
- package/src/playground/Typography.stories.tsx +2 -2
- package/src/testing/decorators/index.ts +1 -0
- package/src/testing/decorators/withVariants.tsx +45 -0
- package/dist/types/src/playground/helpers.d.ts +0 -6
- package/dist/types/src/playground/helpers.d.ts.map +0 -1
- package/src/playground/helpers.tsx +0 -32
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { createContext } from '@radix-ui/react-context';
|
|
6
6
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
7
7
|
import { Slot } from '@radix-ui/react-slot';
|
|
8
|
-
import React, { type ComponentPropsWithRef, forwardRef } from 'react';
|
|
8
|
+
import React, { type ComponentPropsWithRef, forwardRef, memo } from 'react';
|
|
9
9
|
|
|
10
10
|
import { type Density, type Elevation } from '@dxos/react-ui-types';
|
|
11
11
|
|
|
@@ -27,41 +27,51 @@ const [ButtonGroupProvider, useButtonGroupContext] = createContext<ButtonGroupCo
|
|
|
27
27
|
inGroup: false,
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
const Button =
|
|
31
|
-
(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
30
|
+
const Button = memo(
|
|
31
|
+
forwardRef<HTMLButtonElement, ButtonProps>(
|
|
32
|
+
(
|
|
33
|
+
{
|
|
34
|
+
classNames,
|
|
35
|
+
children,
|
|
36
|
+
density: propsDensity,
|
|
37
|
+
elevation: propsElevation,
|
|
38
|
+
variant = 'default',
|
|
39
|
+
asChild,
|
|
40
|
+
...props
|
|
41
|
+
},
|
|
42
|
+
ref,
|
|
43
|
+
) => {
|
|
44
|
+
const { inGroup } = useButtonGroupContext(BUTTON_NAME);
|
|
45
|
+
const { tx } = useThemeContext();
|
|
46
|
+
const elevation = useElevationContext(propsElevation);
|
|
47
|
+
const density = useDensityContext(propsDensity);
|
|
48
|
+
const Root = asChild ? Slot : Primitive.button;
|
|
49
|
+
return (
|
|
50
|
+
<Root
|
|
51
|
+
ref={ref}
|
|
52
|
+
{...props}
|
|
53
|
+
data-variant={variant}
|
|
54
|
+
data-density={density}
|
|
55
|
+
data-props={inGroup ? 'grouped' : ''}
|
|
56
|
+
className={tx(
|
|
57
|
+
'button.root',
|
|
58
|
+
'button',
|
|
59
|
+
{
|
|
60
|
+
variant,
|
|
61
|
+
inGroup,
|
|
62
|
+
disabled: props.disabled,
|
|
63
|
+
density,
|
|
64
|
+
elevation,
|
|
65
|
+
},
|
|
66
|
+
classNames,
|
|
67
|
+
)}
|
|
68
|
+
{...(props.disabled && { disabled: true })}
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</Root>
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
),
|
|
65
75
|
);
|
|
66
76
|
|
|
67
77
|
Button.displayName = BUTTON_NAME;
|
|
@@ -21,8 +21,9 @@ const StorybookToggle = (props: StorybookToggleProps) => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export default {
|
|
24
|
-
title: 'react-ui/Toggle
|
|
25
|
-
component:
|
|
24
|
+
title: 'ui/react-ui-core/Toggle',
|
|
25
|
+
component: Toggle,
|
|
26
|
+
render: StorybookToggle,
|
|
26
27
|
decorators: [withTheme],
|
|
27
28
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
28
29
|
};
|
|
@@ -29,8 +29,9 @@ const StorybookToggleGroup = (props: StorybookToggleGroupProps) => {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export default {
|
|
32
|
-
title: 'react-ui/
|
|
33
|
-
component:
|
|
32
|
+
title: 'ui/react-ui-core/ToggleGroup',
|
|
33
|
+
component: ToggleGroup,
|
|
34
|
+
render: StorybookToggleGroup,
|
|
34
35
|
decorators: [withTheme],
|
|
35
36
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
36
37
|
};
|
|
@@ -14,7 +14,7 @@ export type DensityProviderProps = PropsWithChildren<{
|
|
|
14
14
|
density?: Density;
|
|
15
15
|
}>;
|
|
16
16
|
|
|
17
|
-
export const DensityContext = createContext<DensityContextValue>({ density: '
|
|
17
|
+
export const DensityContext = createContext<DensityContextValue>({ density: 'fine' });
|
|
18
18
|
|
|
19
19
|
export const DensityProvider = ({ density, children }: DensityProviderProps) => (
|
|
20
20
|
<DensityContext.Provider value={{ density }}>{children}</DensityContext.Provider>
|
|
@@ -54,8 +54,9 @@ const StorybookAlertDialog = ({
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
export default {
|
|
57
|
-
title: 'react-ui/
|
|
58
|
-
component:
|
|
57
|
+
title: 'ui/react-ui-core/AlertDialog',
|
|
58
|
+
component: AlertDialog,
|
|
59
|
+
render: StorybookAlertDialog,
|
|
59
60
|
decorators: [withTheme],
|
|
60
61
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
61
62
|
};
|
|
@@ -40,8 +40,9 @@ const StorybookDialog = ({ title, openTrigger, description, body, closeTrigger,
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export default {
|
|
43
|
-
title: 'react-ui/Dialog',
|
|
44
|
-
component:
|
|
43
|
+
title: 'ui/react-ui-core/Dialog',
|
|
44
|
+
component: Dialog,
|
|
45
|
+
render: StorybookDialog,
|
|
45
46
|
decorators: [withTheme],
|
|
46
47
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
47
48
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Primitive } from '@radix-ui/react-primitive';
|
|
6
|
-
import React, { type ComponentPropsWithRef, forwardRef } from 'react';
|
|
6
|
+
import React, { type ComponentPropsWithRef, forwardRef, memo } from 'react';
|
|
7
7
|
|
|
8
8
|
import { type Size } from '@dxos/react-ui-types';
|
|
9
9
|
|
|
@@ -12,11 +12,13 @@ import { type ThemedClassName } from '../../util';
|
|
|
12
12
|
|
|
13
13
|
export type IconProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.svg>> & { icon: string; size?: Size };
|
|
14
14
|
|
|
15
|
-
export const Icon =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
export const Icon = memo(
|
|
16
|
+
forwardRef<SVGSVGElement, IconProps>(({ icon, classNames, size, ...props }, forwardedRef) => {
|
|
17
|
+
const { tx } = useThemeContext();
|
|
18
|
+
return (
|
|
19
|
+
<svg {...props} className={tx('icon.root', 'icon', { size }, classNames)} ref={forwardedRef}>
|
|
20
|
+
<use href={`/icons.svg#${icon}`} />
|
|
21
|
+
</svg>
|
|
22
|
+
);
|
|
23
|
+
}),
|
|
24
|
+
);
|
|
@@ -72,9 +72,10 @@ const StoryInput = (props: StoryInputProps) => {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
export default {
|
|
75
|
-
title: 'react-ui/Input',
|
|
76
|
-
component:
|
|
77
|
-
|
|
75
|
+
title: 'ui/react-ui-core/Input',
|
|
76
|
+
component: Input,
|
|
77
|
+
render: StoryInput,
|
|
78
|
+
// TODO(thure): Refactor.
|
|
78
79
|
argTypes: {
|
|
79
80
|
label: { control: 'text' },
|
|
80
81
|
description: { control: 'text' },
|
|
@@ -8,7 +8,7 @@ import { Link } from './Link';
|
|
|
8
8
|
import { withTheme } from '../../testing';
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
|
-
title: 'react-ui/Link',
|
|
11
|
+
title: 'ui/react-ui-core/Link',
|
|
12
12
|
component: Link,
|
|
13
13
|
decorators: [withTheme],
|
|
14
14
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
@@ -9,7 +9,7 @@ import { arrayMove, SortableContext, useSortable, verticalListSortingStrategy }
|
|
|
9
9
|
import { CSS } from '@dnd-kit/utilities';
|
|
10
10
|
import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
11
11
|
import { DotsSixVertical, PushPin } from '@phosphor-icons/react';
|
|
12
|
-
import React, { type
|
|
12
|
+
import React, { type ReactNode, useState } from 'react';
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
getSize,
|
|
@@ -20,12 +20,12 @@ import {
|
|
|
20
20
|
surfaceElevation,
|
|
21
21
|
} from '@dxos/react-ui-theme';
|
|
22
22
|
|
|
23
|
-
import { List, ListItem, type
|
|
23
|
+
import { List, ListItem, type ListScopedProps } from './List';
|
|
24
24
|
import { withTheme } from '../../testing';
|
|
25
25
|
|
|
26
26
|
export default {
|
|
27
|
-
title: 'react-ui/List',
|
|
28
|
-
component: List
|
|
27
|
+
title: 'ui/react-ui-core/List',
|
|
28
|
+
component: List,
|
|
29
29
|
decorators: [withTheme],
|
|
30
30
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
31
31
|
};
|
|
@@ -56,8 +56,9 @@ const StorybookTree = ({ data }: StorybookTreeProps) => {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
export default {
|
|
59
|
-
title: 'react-ui/Tree',
|
|
60
|
-
component:
|
|
59
|
+
title: 'ui/react-ui-core/Tree',
|
|
60
|
+
component: Tree,
|
|
61
|
+
render: StorybookTree,
|
|
61
62
|
decorators: [withTheme],
|
|
62
63
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
63
64
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
|
+
|
|
4
5
|
import React from 'react';
|
|
5
6
|
|
|
6
7
|
import { faker } from '@dxos/random';
|
|
@@ -119,7 +120,7 @@ function* visitor(node: StorybookNode, isOpen?: (node: StorybookNode) => boolean
|
|
|
119
120
|
|
|
120
121
|
const flattenedContent = Array.from(visitor(content, () => true));
|
|
121
122
|
|
|
122
|
-
const
|
|
123
|
+
const DefaultStory = () => {
|
|
123
124
|
return (
|
|
124
125
|
<Tg.Root gridTemplateColumns='1fr'>
|
|
125
126
|
{flattenedContent.map(({ node, parentOf, path }) => {
|
|
@@ -140,10 +141,11 @@ const StorybookTreegrid = () => {
|
|
|
140
141
|
);
|
|
141
142
|
};
|
|
142
143
|
|
|
144
|
+
export const Default = {};
|
|
145
|
+
|
|
143
146
|
export default {
|
|
144
|
-
title: 'react-ui/Treegrid',
|
|
145
|
-
component:
|
|
147
|
+
title: 'ui/react-ui-core/Treegrid',
|
|
148
|
+
component: Tg.Root,
|
|
149
|
+
render: DefaultStory,
|
|
146
150
|
decorators: [withTheme],
|
|
147
151
|
};
|
|
148
|
-
|
|
149
|
-
export const Treegrid = () => <StorybookTreegrid />;
|
|
@@ -46,8 +46,9 @@ const StoryMain = (_args: StoryMainArgs) => {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
export default {
|
|
49
|
-
title: 'react-ui/Main',
|
|
50
|
-
component:
|
|
49
|
+
title: 'ui/react-ui-core/Main',
|
|
50
|
+
component: Main.Root,
|
|
51
|
+
render: StoryMain,
|
|
51
52
|
decorators: [withTheme],
|
|
52
53
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
53
54
|
};
|
|
@@ -92,8 +92,9 @@ const StorybookContextMenu = () => {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
export default {
|
|
95
|
-
title: 'react-ui/
|
|
96
|
-
component:
|
|
95
|
+
title: 'ui/react-ui-core/ContextMenu',
|
|
96
|
+
component: ContextMenu,
|
|
97
|
+
render: StorybookContextMenu,
|
|
97
98
|
decorators: [withTheme],
|
|
98
99
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
99
100
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import React from 'react';
|
|
7
|
+
import React, { useRef, useState } from 'react';
|
|
8
8
|
|
|
9
9
|
import { DropdownMenu } from './DropdownMenu';
|
|
10
10
|
import { withTheme } from '../../testing';
|
|
@@ -92,8 +92,9 @@ const StorybookDropdownMenu = () => {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
export default {
|
|
95
|
-
title: 'react-ui/
|
|
96
|
-
component:
|
|
95
|
+
title: 'ui/react-ui-core/DropdownMenu',
|
|
96
|
+
component: DropdownMenu,
|
|
97
|
+
render: StorybookDropdownMenu,
|
|
97
98
|
decorators: [withTheme],
|
|
98
99
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
99
100
|
};
|
|
@@ -104,3 +105,42 @@ export const Default = {
|
|
|
104
105
|
chromatic: { delay: 1600 },
|
|
105
106
|
},
|
|
106
107
|
};
|
|
108
|
+
|
|
109
|
+
export const VirtualTrigger = {
|
|
110
|
+
render: () => {
|
|
111
|
+
const [menuOpen, setMenuOpen] = useState(true);
|
|
112
|
+
const buttonRef = useRef<HTMLButtonElement | null>(null);
|
|
113
|
+
return (
|
|
114
|
+
<>
|
|
115
|
+
<Button onClick={() => setMenuOpen(true)} ref={buttonRef}>
|
|
116
|
+
Customise options
|
|
117
|
+
</Button>
|
|
118
|
+
<DropdownMenu.Root open={menuOpen} onOpenChange={setMenuOpen}>
|
|
119
|
+
<DropdownMenu.VirtualTrigger virtualRef={buttonRef} />
|
|
120
|
+
<DropdownMenu.Content sideOffset={4} collisionPadding={8}>
|
|
121
|
+
<DropdownMenu.Viewport>
|
|
122
|
+
<DropdownMenu.Item>
|
|
123
|
+
<span className='grow'>New Tab</span>
|
|
124
|
+
<span className='opacity-50'>⌘+T</span>
|
|
125
|
+
</DropdownMenu.Item>
|
|
126
|
+
<DropdownMenu.Item>
|
|
127
|
+
<span className='grow'>New Window</span>
|
|
128
|
+
<span className='opacity-50'>⌘+N</span>
|
|
129
|
+
</DropdownMenu.Item>
|
|
130
|
+
<DropdownMenu.Item disabled>
|
|
131
|
+
<span className='grow'>New Private Window</span>
|
|
132
|
+
<span className='opacity-50'>⇧+⌘+N</span>
|
|
133
|
+
</DropdownMenu.Item>
|
|
134
|
+
|
|
135
|
+
<DropdownMenu.Separator />
|
|
136
|
+
|
|
137
|
+
<DropdownMenu.GroupLabel>People</DropdownMenu.GroupLabel>
|
|
138
|
+
</DropdownMenu.Viewport>
|
|
139
|
+
|
|
140
|
+
<DropdownMenu.Arrow />
|
|
141
|
+
</DropdownMenu.Content>
|
|
142
|
+
</DropdownMenu.Root>
|
|
143
|
+
</>
|
|
144
|
+
);
|
|
145
|
+
},
|
|
146
|
+
};
|