@dxos/react-ui 0.3.10 → 0.3.11-main.008b7c6
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 +305 -219
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/Menus/ContextMenu.d.ts +50 -0
- package/dist/types/src/components/Menus/ContextMenu.d.ts.map +1 -0
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts +21 -0
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts.map +1 -0
- package/dist/types/src/components/{DropdownMenu → Menus}/DropdownMenu.d.ts +23 -23
- package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +1 -0
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts.map +1 -0
- package/dist/types/src/components/Menus/index.d.ts +3 -0
- package/dist/types/src/components/Menus/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/components/Menus/ContextMenu.stories.tsx +106 -0
- package/src/components/Menus/ContextMenu.tsx +170 -0
- package/src/components/Menus/DropdownMenu.tsx +173 -0
- package/src/components/{DropdownMenu → Menus}/index.ts +1 -0
- package/src/components/index.ts +1 -1
- package/dist/types/src/components/DropdownMenu/DropdownMenu.d.ts.map +0 -1
- package/dist/types/src/components/DropdownMenu/DropdownMenu.stories.d.ts.map +0 -1
- package/dist/types/src/components/DropdownMenu/index.d.ts +0 -2
- package/dist/types/src/components/DropdownMenu/index.d.ts.map +0 -1
- package/src/components/DropdownMenu/DropdownMenu.tsx +0 -198
- /package/dist/types/src/components/{DropdownMenu → Menus}/DropdownMenu.stories.d.ts +0 -0
- /package/src/components/{DropdownMenu → Menus}/DropdownMenu.stories.tsx +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxosTheme';
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
import { ContextMenu } from './ContextMenu';
|
|
10
|
+
import { withTheme } from '../../testing';
|
|
11
|
+
|
|
12
|
+
const StorybookContextMenu = () => {
|
|
13
|
+
// NOTE(thure): Since long-tap will select text in some OSs, apply `select-none` to `ContextMenu.Trigger` where possible.
|
|
14
|
+
return (
|
|
15
|
+
<ContextMenu.Root>
|
|
16
|
+
<ContextMenu.Trigger className='select-none border border-dashed border-neutral-400/50 rounded-lg flex items-center justify-center p-8 font-normal'>
|
|
17
|
+
Right-click / long-tap here.
|
|
18
|
+
</ContextMenu.Trigger>
|
|
19
|
+
|
|
20
|
+
<ContextMenu.Content collisionPadding={8}>
|
|
21
|
+
<ContextMenu.Viewport>
|
|
22
|
+
<ContextMenu.Item>
|
|
23
|
+
<span className='grow'>New Tab</span>
|
|
24
|
+
<span className='opacity-50'>⌘+T</span>
|
|
25
|
+
</ContextMenu.Item>
|
|
26
|
+
<ContextMenu.Item>
|
|
27
|
+
<span className='grow'>New Window</span>
|
|
28
|
+
<span className='opacity-50'>⌘+N</span>
|
|
29
|
+
</ContextMenu.Item>
|
|
30
|
+
<ContextMenu.Item disabled>
|
|
31
|
+
<span className='grow'>New Private Window</span>
|
|
32
|
+
<span className='opacity-50'>⇧+⌘+N</span>
|
|
33
|
+
</ContextMenu.Item>
|
|
34
|
+
{/* <ContextMenu.Sub> */}
|
|
35
|
+
{/* <ContextMenu.SubTrigger> */}
|
|
36
|
+
{/* More Tools */}
|
|
37
|
+
{/* <div> */}
|
|
38
|
+
{/* <ChevronRightIcon /> */}
|
|
39
|
+
{/* </div> */}
|
|
40
|
+
{/* </ContextMenu.SubTrigger> */}
|
|
41
|
+
{/* <ContextMenu.Portal> */}
|
|
42
|
+
{/* <ContextMenu.SubContent sideOffset={2} alignOffset={-5}> */}
|
|
43
|
+
{/* <ContextMenu.Item> */}
|
|
44
|
+
{/* Save Page As… <div>⌘+S</div> */}
|
|
45
|
+
{/* </ContextMenu.Item> */}
|
|
46
|
+
{/* <ContextMenu.Item>Create Shortcut…</ContextMenu.Item> */}
|
|
47
|
+
{/* <ContextMenu.Item>Name Window…</ContextMenu.Item> */}
|
|
48
|
+
{/* <ContextMenu.Separator /> */}
|
|
49
|
+
{/* <ContextMenu.Item>Developer Tools</ContextMenu.Item> */}
|
|
50
|
+
{/* </ContextMenu.SubContent> */}
|
|
51
|
+
{/* </ContextMenu.Portal> */}
|
|
52
|
+
{/* </ContextMenu.Sub> */}
|
|
53
|
+
|
|
54
|
+
{/* <ContextMenu.Separator /> */}
|
|
55
|
+
|
|
56
|
+
{/* <ContextMenu.CheckboxItem checked={bookmarksChecked} onCheckedChange={setBookmarksChecked}> */}
|
|
57
|
+
{/* <ContextMenu.ItemIndicator> */}
|
|
58
|
+
{/* <CheckIcon /> */}
|
|
59
|
+
{/* </ContextMenu.ItemIndicator> */}
|
|
60
|
+
{/* Show Bookmarks <div>⌘+B</div> */}
|
|
61
|
+
{/* </ContextMenu.CheckboxItem> */}
|
|
62
|
+
{/* <ContextMenu.CheckboxItem checked={urlsChecked} onCheckedChange={setUrlsChecked}> */}
|
|
63
|
+
{/* <ContextMenu.ItemIndicator> */}
|
|
64
|
+
{/* <CheckIcon /> */}
|
|
65
|
+
{/* </ContextMenu.ItemIndicator> */}
|
|
66
|
+
{/* Show Full URLs */}
|
|
67
|
+
{/* </ContextMenu.CheckboxItem> */}
|
|
68
|
+
|
|
69
|
+
<ContextMenu.Separator />
|
|
70
|
+
|
|
71
|
+
<ContextMenu.GroupLabel>People</ContextMenu.GroupLabel>
|
|
72
|
+
{/* <ContextMenu.RadioGroup value={person} onValueChange={setPerson}> */}
|
|
73
|
+
{/* <ContextMenu.RadioItem value='pedro'> */}
|
|
74
|
+
{/* <ContextMenu.ItemIndicator> */}
|
|
75
|
+
{/* <DotFilledIcon /> */}
|
|
76
|
+
{/* </ContextMenu.ItemIndicator> */}
|
|
77
|
+
{/* Pedro Duarte */}
|
|
78
|
+
{/* </ContextMenu.RadioItem> */}
|
|
79
|
+
{/* <ContextMenu.RadioItem value='colm'> */}
|
|
80
|
+
{/* <ContextMenu.ItemIndicator> */}
|
|
81
|
+
{/* <DotFilledIcon /> */}
|
|
82
|
+
{/* </ContextMenu.ItemIndicator> */}
|
|
83
|
+
{/* Colm Tuite */}
|
|
84
|
+
{/* </ContextMenu.RadioItem> */}
|
|
85
|
+
{/* </ContextMenu.RadioGroup> */}
|
|
86
|
+
</ContextMenu.Viewport>
|
|
87
|
+
|
|
88
|
+
<ContextMenu.Arrow />
|
|
89
|
+
</ContextMenu.Content>
|
|
90
|
+
</ContextMenu.Root>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default {
|
|
95
|
+
title: 'react-ui/Context menu',
|
|
96
|
+
component: StorybookContextMenu,
|
|
97
|
+
decorators: [withTheme],
|
|
98
|
+
parameters: { chromatic: { disableSnapshot: false } },
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const Default = {
|
|
102
|
+
args: {},
|
|
103
|
+
parameters: {
|
|
104
|
+
chromatic: { delay: 1600 },
|
|
105
|
+
},
|
|
106
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu';
|
|
5
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
|
6
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
7
|
+
import React, { type ComponentPropsWithRef, forwardRef } from 'react';
|
|
8
|
+
|
|
9
|
+
import { useThemeContext } from '../../hooks';
|
|
10
|
+
import { type ThemedClassName } from '../../util';
|
|
11
|
+
import { ElevationProvider } from '../ElevationProvider';
|
|
12
|
+
|
|
13
|
+
type ContextMenuRootProps = ContextMenuPrimitive.ContextMenuProps;
|
|
14
|
+
|
|
15
|
+
const ContextMenuRoot = ContextMenuPrimitive.ContextMenu;
|
|
16
|
+
|
|
17
|
+
type ContextMenuTriggerProps = ContextMenuPrimitive.ContextMenuTriggerProps;
|
|
18
|
+
|
|
19
|
+
const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
|
|
20
|
+
|
|
21
|
+
type ContextMenuPortalProps = ContextMenuPrimitive.ContextMenuPortalProps;
|
|
22
|
+
|
|
23
|
+
const ContextMenuPortal = ContextMenuPrimitive.Portal;
|
|
24
|
+
|
|
25
|
+
type ContextMenuContentProps = ThemedClassName<ContextMenuPrimitive.ContextMenuContentProps> & {
|
|
26
|
+
constrainBlockSize?: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const ContextMenuContent = forwardRef<HTMLDivElement, ContextMenuContentProps>(
|
|
30
|
+
({ classNames, children, ...props }, forwardedRef) => {
|
|
31
|
+
const { tx } = useThemeContext();
|
|
32
|
+
return (
|
|
33
|
+
<ContextMenuPrimitive.Content
|
|
34
|
+
collisionPadding={8}
|
|
35
|
+
{...props}
|
|
36
|
+
className={tx('menu.content', 'menu', {}, classNames)}
|
|
37
|
+
ref={forwardedRef}
|
|
38
|
+
>
|
|
39
|
+
<ElevationProvider elevation='chrome'>{children}</ElevationProvider>
|
|
40
|
+
</ContextMenuPrimitive.Content>
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
type ContextMenuViewportProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.div>> & {
|
|
46
|
+
asChild?: boolean;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const ContextMenuViewport = forwardRef<HTMLDivElement, ContextMenuViewportProps>(
|
|
50
|
+
({ classNames, asChild, children, ...props }, forwardedRef) => {
|
|
51
|
+
const { tx } = useThemeContext();
|
|
52
|
+
const Root = asChild ? Slot : Primitive.div;
|
|
53
|
+
return (
|
|
54
|
+
<Root {...props} className={tx('menu.viewport', 'menu__viewport', {}, classNames)} ref={forwardedRef}>
|
|
55
|
+
{children}
|
|
56
|
+
</Root>
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
type ContextMenuArrowProps = ThemedClassName<ContextMenuPrimitive.ContextMenuArrowProps>;
|
|
62
|
+
|
|
63
|
+
const ContextMenuArrow = forwardRef<SVGSVGElement, ContextMenuArrowProps>(({ classNames, ...props }, forwardedRef) => {
|
|
64
|
+
const { tx } = useThemeContext();
|
|
65
|
+
return (
|
|
66
|
+
<ContextMenuPrimitive.Arrow
|
|
67
|
+
{...props}
|
|
68
|
+
className={tx('menu.arrow', 'menu__arrow', {}, classNames)}
|
|
69
|
+
ref={forwardedRef}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
type ContextMenuGroupProps = ContextMenuPrimitive.ContextMenuGroupProps;
|
|
75
|
+
|
|
76
|
+
const ContextMenuGroup = ContextMenuPrimitive.Group;
|
|
77
|
+
|
|
78
|
+
type ContextMenuItemIndicatorProps = ContextMenuPrimitive.ContextMenuItemIndicatorProps;
|
|
79
|
+
|
|
80
|
+
const ContextMenuItemIndicator = ContextMenuPrimitive.ItemIndicator;
|
|
81
|
+
|
|
82
|
+
type ContextMenuItemProps = ThemedClassName<ContextMenuPrimitive.ContextMenuItemProps>;
|
|
83
|
+
|
|
84
|
+
const ContextMenuItem = forwardRef<HTMLDivElement, ContextMenuItemProps>(
|
|
85
|
+
({ classNames, ...props }: ContextMenuItemProps, forwardedRef) => {
|
|
86
|
+
const { tx } = useThemeContext();
|
|
87
|
+
return (
|
|
88
|
+
<ContextMenuPrimitive.Item
|
|
89
|
+
{...props}
|
|
90
|
+
className={tx('menu.item', 'menu__item', {}, classNames)}
|
|
91
|
+
ref={forwardedRef}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
type ContextMenuCheckboxItemProps = ThemedClassName<ContextMenuPrimitive.ContextMenuCheckboxItemProps>;
|
|
98
|
+
|
|
99
|
+
const ContextMenuCheckboxItem = forwardRef<HTMLDivElement, ContextMenuCheckboxItemProps>(
|
|
100
|
+
({ classNames, ...props }: ContextMenuItemProps, forwardedRef) => {
|
|
101
|
+
const { tx } = useThemeContext();
|
|
102
|
+
return (
|
|
103
|
+
<ContextMenuPrimitive.CheckboxItem
|
|
104
|
+
{...props}
|
|
105
|
+
className={tx('menu.item', 'menu__item--checkbox', {}, classNames)}
|
|
106
|
+
ref={forwardedRef}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
},
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
type ContextMenuSeparatorProps = ThemedClassName<ContextMenuPrimitive.ContextMenuSeparatorProps>;
|
|
113
|
+
|
|
114
|
+
const ContextMenuSeparator = forwardRef<HTMLDivElement, ContextMenuSeparatorProps>(
|
|
115
|
+
({ classNames, ...props }, forwardedRef) => {
|
|
116
|
+
const { tx } = useThemeContext();
|
|
117
|
+
return (
|
|
118
|
+
<ContextMenuPrimitive.Separator
|
|
119
|
+
{...props}
|
|
120
|
+
className={tx('menu.separator', 'menu__item', {}, classNames)}
|
|
121
|
+
ref={forwardedRef}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
type ContextMenuGroupLabelProps = ThemedClassName<ContextMenuPrimitive.ContextMenuLabelProps>;
|
|
128
|
+
|
|
129
|
+
const ContextMenuGroupLabel = forwardRef<HTMLDivElement, ContextMenuGroupLabelProps>(
|
|
130
|
+
({ classNames, ...props }, forwardedRef) => {
|
|
131
|
+
const { tx } = useThemeContext();
|
|
132
|
+
return (
|
|
133
|
+
<ContextMenuPrimitive.Label
|
|
134
|
+
{...props}
|
|
135
|
+
className={tx('menu.groupLabel', 'menu__group__label', {}, classNames)}
|
|
136
|
+
ref={forwardedRef}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
export const ContextMenu = {
|
|
143
|
+
Root: ContextMenuRoot,
|
|
144
|
+
Trigger: ContextMenuTrigger,
|
|
145
|
+
Portal: ContextMenuPortal,
|
|
146
|
+
Content: ContextMenuContent,
|
|
147
|
+
Viewport: ContextMenuViewport,
|
|
148
|
+
Arrow: ContextMenuArrow,
|
|
149
|
+
Group: ContextMenuGroup,
|
|
150
|
+
Item: ContextMenuItem,
|
|
151
|
+
CheckboxItem: ContextMenuCheckboxItem,
|
|
152
|
+
ItemIndicator: ContextMenuItemIndicator,
|
|
153
|
+
Separator: ContextMenuSeparator,
|
|
154
|
+
GroupLabel: ContextMenuGroupLabel,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type {
|
|
158
|
+
ContextMenuRootProps,
|
|
159
|
+
ContextMenuTriggerProps,
|
|
160
|
+
ContextMenuPortalProps,
|
|
161
|
+
ContextMenuContentProps,
|
|
162
|
+
ContextMenuViewportProps,
|
|
163
|
+
ContextMenuArrowProps,
|
|
164
|
+
ContextMenuGroupProps,
|
|
165
|
+
ContextMenuItemProps,
|
|
166
|
+
ContextMenuCheckboxItemProps,
|
|
167
|
+
ContextMenuItemIndicatorProps,
|
|
168
|
+
ContextMenuSeparatorProps,
|
|
169
|
+
ContextMenuGroupLabelProps,
|
|
170
|
+
};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
5
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
|
6
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
7
|
+
import React, { type ComponentPropsWithRef, forwardRef } from 'react';
|
|
8
|
+
|
|
9
|
+
import { useThemeContext } from '../../hooks';
|
|
10
|
+
import { type ThemedClassName } from '../../util';
|
|
11
|
+
import { ElevationProvider } from '../ElevationProvider';
|
|
12
|
+
|
|
13
|
+
type DropdownMenuRootProps = DropdownMenuPrimitive.DropdownMenuProps;
|
|
14
|
+
|
|
15
|
+
const DropdownMenuRoot = DropdownMenuPrimitive.DropdownMenu;
|
|
16
|
+
|
|
17
|
+
type DropdownMenuTriggerProps = DropdownMenuPrimitive.DropdownMenuTriggerProps;
|
|
18
|
+
|
|
19
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
20
|
+
|
|
21
|
+
type DropdownMenuPortalProps = DropdownMenuPrimitive.DropdownMenuPortalProps;
|
|
22
|
+
|
|
23
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
24
|
+
|
|
25
|
+
type DropdownMenuContentProps = ThemedClassName<DropdownMenuPrimitive.DropdownMenuContentProps> & {
|
|
26
|
+
constrainBlockSize?: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const DropdownMenuContent = forwardRef<HTMLDivElement, DropdownMenuContentProps>(
|
|
30
|
+
({ classNames, children, ...props }, forwardedRef) => {
|
|
31
|
+
const { tx } = useThemeContext();
|
|
32
|
+
return (
|
|
33
|
+
<DropdownMenuPrimitive.Content
|
|
34
|
+
sideOffset={4}
|
|
35
|
+
collisionPadding={8}
|
|
36
|
+
{...props}
|
|
37
|
+
className={tx('menu.content', 'menu', {}, classNames)}
|
|
38
|
+
ref={forwardedRef}
|
|
39
|
+
>
|
|
40
|
+
<ElevationProvider elevation='chrome'>{children}</ElevationProvider>
|
|
41
|
+
</DropdownMenuPrimitive.Content>
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
type DropdownMenuViewportProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.div>> & {
|
|
47
|
+
asChild?: boolean;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const DropdownMenuViewport = forwardRef<HTMLDivElement, DropdownMenuViewportProps>(
|
|
51
|
+
({ classNames, asChild, children, ...props }, forwardedRef) => {
|
|
52
|
+
const { tx } = useThemeContext();
|
|
53
|
+
const Root = asChild ? Slot : Primitive.div;
|
|
54
|
+
return (
|
|
55
|
+
<Root {...props} className={tx('menu.viewport', 'menu__viewport', {}, classNames)} ref={forwardedRef}>
|
|
56
|
+
{children}
|
|
57
|
+
</Root>
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
type DropdownMenuArrowProps = ThemedClassName<DropdownMenuPrimitive.DropdownMenuArrowProps>;
|
|
63
|
+
|
|
64
|
+
const DropdownMenuArrow = forwardRef<SVGSVGElement, DropdownMenuArrowProps>(
|
|
65
|
+
({ classNames, ...props }, forwardedRef) => {
|
|
66
|
+
const { tx } = useThemeContext();
|
|
67
|
+
return (
|
|
68
|
+
<DropdownMenuPrimitive.Arrow
|
|
69
|
+
{...props}
|
|
70
|
+
className={tx('menu.arrow', 'menu__arrow', {}, classNames)}
|
|
71
|
+
ref={forwardedRef}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
type DropdownMenuGroupProps = DropdownMenuPrimitive.DropdownMenuGroupProps;
|
|
78
|
+
|
|
79
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
80
|
+
|
|
81
|
+
type DropdownMenuItemIndicatorProps = DropdownMenuPrimitive.DropdownMenuItemIndicatorProps;
|
|
82
|
+
|
|
83
|
+
const DropdownMenuItemIndicator = DropdownMenuPrimitive.ItemIndicator;
|
|
84
|
+
|
|
85
|
+
type DropdownMenuItemProps = ThemedClassName<DropdownMenuPrimitive.DropdownMenuItemProps>;
|
|
86
|
+
|
|
87
|
+
const DropdownMenuItem = forwardRef<HTMLDivElement, DropdownMenuItemProps>(
|
|
88
|
+
({ classNames, ...props }: DropdownMenuItemProps, forwardedRef) => {
|
|
89
|
+
const { tx } = useThemeContext();
|
|
90
|
+
return (
|
|
91
|
+
<DropdownMenuPrimitive.Item
|
|
92
|
+
{...props}
|
|
93
|
+
className={tx('menu.item', 'menu__item', {}, classNames)}
|
|
94
|
+
ref={forwardedRef}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
type DropdownMenuCheckboxItemProps = ThemedClassName<DropdownMenuPrimitive.DropdownMenuCheckboxItemProps>;
|
|
101
|
+
|
|
102
|
+
const DropdownMenuCheckboxItem = forwardRef<HTMLDivElement, DropdownMenuCheckboxItemProps>(
|
|
103
|
+
({ classNames, ...props }: DropdownMenuItemProps, forwardedRef) => {
|
|
104
|
+
const { tx } = useThemeContext();
|
|
105
|
+
return (
|
|
106
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
107
|
+
{...props}
|
|
108
|
+
className={tx('menu.item', 'menu__item--checkbox', {}, classNames)}
|
|
109
|
+
ref={forwardedRef}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
},
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
type DropdownMenuSeparatorProps = ThemedClassName<DropdownMenuPrimitive.DropdownMenuSeparatorProps>;
|
|
116
|
+
|
|
117
|
+
const DropdownMenuSeparator = forwardRef<HTMLDivElement, DropdownMenuSeparatorProps>(
|
|
118
|
+
({ classNames, ...props }, forwardedRef) => {
|
|
119
|
+
const { tx } = useThemeContext();
|
|
120
|
+
return (
|
|
121
|
+
<DropdownMenuPrimitive.Separator
|
|
122
|
+
{...props}
|
|
123
|
+
className={tx('menu.separator', 'menu__item', {}, classNames)}
|
|
124
|
+
ref={forwardedRef}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
type DropdownMenuGroupLabelProps = ThemedClassName<DropdownMenuPrimitive.DropdownMenuLabelProps>;
|
|
131
|
+
|
|
132
|
+
const DropdownMenuGroupLabel = forwardRef<HTMLDivElement, DropdownMenuGroupLabelProps>(
|
|
133
|
+
({ classNames, ...props }, forwardedRef) => {
|
|
134
|
+
const { tx } = useThemeContext();
|
|
135
|
+
return (
|
|
136
|
+
<DropdownMenuPrimitive.Label
|
|
137
|
+
{...props}
|
|
138
|
+
className={tx('menu.groupLabel', 'menu__group__label', {}, classNames)}
|
|
139
|
+
ref={forwardedRef}
|
|
140
|
+
/>
|
|
141
|
+
);
|
|
142
|
+
},
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
export const DropdownMenu = {
|
|
146
|
+
Root: DropdownMenuRoot,
|
|
147
|
+
Trigger: DropdownMenuTrigger,
|
|
148
|
+
Portal: DropdownMenuPortal,
|
|
149
|
+
Content: DropdownMenuContent,
|
|
150
|
+
Viewport: DropdownMenuViewport,
|
|
151
|
+
Arrow: DropdownMenuArrow,
|
|
152
|
+
Group: DropdownMenuGroup,
|
|
153
|
+
Item: DropdownMenuItem,
|
|
154
|
+
CheckboxItem: DropdownMenuCheckboxItem,
|
|
155
|
+
ItemIndicator: DropdownMenuItemIndicator,
|
|
156
|
+
Separator: DropdownMenuSeparator,
|
|
157
|
+
GroupLabel: DropdownMenuGroupLabel,
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export type {
|
|
161
|
+
DropdownMenuRootProps,
|
|
162
|
+
DropdownMenuTriggerProps,
|
|
163
|
+
DropdownMenuPortalProps,
|
|
164
|
+
DropdownMenuContentProps,
|
|
165
|
+
DropdownMenuViewportProps,
|
|
166
|
+
DropdownMenuArrowProps,
|
|
167
|
+
DropdownMenuGroupProps,
|
|
168
|
+
DropdownMenuItemProps,
|
|
169
|
+
DropdownMenuCheckboxItemProps,
|
|
170
|
+
DropdownMenuItemIndicatorProps,
|
|
171
|
+
DropdownMenuSeparatorProps,
|
|
172
|
+
DropdownMenuGroupLabelProps,
|
|
173
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components/DropdownMenu/DropdownMenu.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,iBAAiB,IAAI,8BAA8B,EAExD,KAAK,wBAAwB,IAAI,iCAAiC,EAElE,KAAK,uBAAuB,IAAI,gCAAgC,EAEhE,KAAK,wBAAwB,IAAI,iCAAiC,EAElE,KAAK,sBAAsB,IAAI,+BAA+B,EAE9D,KAAK,sBAAsB,IAAI,+BAA+B,EAE9D,KAAK,qBAAqB,IAAI,8BAA8B,EAE5D,KAAK,6BAA6B,IAAI,sCAAsC,EAE5E,KAAK,8BAA8B,IAAI,uCAAuC,EAE9E,KAAK,0BAA0B,IAAI,mCAAmC,EAEtE,KAAK,sBAAsB,IAAI,+BAA+B,EAC/D,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,KAAK,EAAE,EAAE,KAAK,qBAAqB,EAAc,MAAM,OAAO,CAAC;AAGtE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,KAAK,qBAAqB,GAAG,8BAA8B,CAAC;AAI5D,KAAK,wBAAwB,GAAG,iCAAiC,CAAC;AAIlE,KAAK,uBAAuB,GAAG,gCAAgC,CAAC;AAIhE,KAAK,wBAAwB,GAAG,eAAe,CAAC,iCAAiC,CAAC,GAAG;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAmBtH,KAAK,yBAAyB,GAAG,eAAe,CAAC,qBAAqB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG;IAC9F,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAkBF,KAAK,sBAAsB,GAAG,eAAe,CAAC,+BAA+B,CAAC,CAAC;AAe/E,KAAK,sBAAsB,GAAG,+BAA+B,CAAC;AAI9D,KAAK,8BAA8B,GAAG,uCAAuC,CAAC;AAI9E,KAAK,qBAAqB,GAAG,eAAe,CAAC,8BAA8B,CAAC,CAAC;AAe7E,KAAK,6BAA6B,GAAG,eAAe,CAAC,sCAAsC,CAAC,CAAC;AAe7F,KAAK,0BAA0B,GAAG,eAAe,CAAC,mCAAmC,CAAC,CAAC;AAevF,KAAK,2BAA2B,GAAG,eAAe,CAAC,+BAA+B,CAAC,CAAC;AAepF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;CAaxB,CAAC;AAEF,YAAY,EACV,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,EAC1B,2BAA2B,GAC5B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/DropdownMenu/DropdownMenu.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;;;;;;;;;;;AAyFpB,wBAKE;AAEF,eAAO,MAAM,OAAO;;;;;;;CAKnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/DropdownMenu/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
import {
|
|
5
|
-
Root as DropdownMenuRootPrimitive,
|
|
6
|
-
type DropdownMenuProps as DropdownMenuRootPrimitiveProps,
|
|
7
|
-
DropdownMenuTrigger as DropdownMenuTriggerPrimitive,
|
|
8
|
-
type DropdownMenuTriggerProps as DropdownMenuTriggerPrimitiveProps,
|
|
9
|
-
DropdownMenuPortal as DropdownMenuPortalPrimitive,
|
|
10
|
-
type DropdownMenuPortalProps as DropdownMenuPortalPrimitiveProps,
|
|
11
|
-
DropdownMenuContent as DropdownMenuContentPrimitive,
|
|
12
|
-
type DropdownMenuContentProps as DropdownMenuContentPrimitiveProps,
|
|
13
|
-
DropdownMenuArrow as DropdownMenuArrowPrimitive,
|
|
14
|
-
type DropdownMenuArrowProps as DropdownMenuArrowPrimitiveProps,
|
|
15
|
-
DropdownMenuGroup as DropdownMenuGroupPrimitive,
|
|
16
|
-
type DropdownMenuGroupProps as DropdownMenuGroupPrimitiveProps,
|
|
17
|
-
DropdownMenuItem as DropdownMenuItemPrimitive,
|
|
18
|
-
type DropdownMenuItemProps as DropdownMenuItemPrimitiveProps,
|
|
19
|
-
DropdownMenuCheckboxItem as DropdownMenuCheckboxItemPrimitive,
|
|
20
|
-
type DropdownMenuCheckboxItemProps as DropdownMenuCheckboxItemPrimitiveProps,
|
|
21
|
-
DropdownMenuItemIndicator as DropdownMenuItemIndicatorPrimitive,
|
|
22
|
-
type DropdownMenuItemIndicatorProps as DropdownMenuItemIndicatorPrimitiveProps,
|
|
23
|
-
DropdownMenuSeparator as DropdownMenuSeparatorPrimitive,
|
|
24
|
-
type DropdownMenuSeparatorProps as DropdownMenuSeparatorPrimitiveProps,
|
|
25
|
-
DropdownMenuLabel as DropdownMenuLabelPrimitive,
|
|
26
|
-
type DropdownMenuLabelProps as DropdownMenuLabelPrimitiveProps,
|
|
27
|
-
} from '@radix-ui/react-dropdown-menu';
|
|
28
|
-
import { Primitive } from '@radix-ui/react-primitive';
|
|
29
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
30
|
-
import React, { type ComponentPropsWithRef, forwardRef } from 'react';
|
|
31
|
-
|
|
32
|
-
import { useThemeContext } from '../../hooks';
|
|
33
|
-
import { type ThemedClassName } from '../../util';
|
|
34
|
-
import { ElevationProvider } from '../ElevationProvider';
|
|
35
|
-
|
|
36
|
-
type DropdownMenuRootProps = DropdownMenuRootPrimitiveProps;
|
|
37
|
-
|
|
38
|
-
const DropdownMenuRoot = DropdownMenuRootPrimitive;
|
|
39
|
-
|
|
40
|
-
type DropdownMenuTriggerProps = DropdownMenuTriggerPrimitiveProps;
|
|
41
|
-
|
|
42
|
-
const DropdownMenuTrigger = DropdownMenuTriggerPrimitive;
|
|
43
|
-
|
|
44
|
-
type DropdownMenuPortalProps = DropdownMenuPortalPrimitiveProps;
|
|
45
|
-
|
|
46
|
-
const DropdownMenuPortal = DropdownMenuPortalPrimitive;
|
|
47
|
-
|
|
48
|
-
type DropdownMenuContentProps = ThemedClassName<DropdownMenuContentPrimitiveProps> & { constrainBlockSize?: boolean };
|
|
49
|
-
|
|
50
|
-
const DropdownMenuContent = forwardRef<HTMLDivElement, DropdownMenuContentProps>(
|
|
51
|
-
({ classNames, children, ...props }, forwardedRef) => {
|
|
52
|
-
const { tx } = useThemeContext();
|
|
53
|
-
return (
|
|
54
|
-
<DropdownMenuContentPrimitive
|
|
55
|
-
sideOffset={4}
|
|
56
|
-
collisionPadding={8}
|
|
57
|
-
{...props}
|
|
58
|
-
className={tx('dropdownMenu.content', 'dropdown-menu', {}, classNames)}
|
|
59
|
-
ref={forwardedRef}
|
|
60
|
-
>
|
|
61
|
-
<ElevationProvider elevation='chrome'>{children}</ElevationProvider>
|
|
62
|
-
</DropdownMenuContentPrimitive>
|
|
63
|
-
);
|
|
64
|
-
},
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
type DropdownMenuViewportProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.div>> & {
|
|
68
|
-
asChild?: boolean;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const DropdownMenuViewport = forwardRef<HTMLDivElement, DropdownMenuViewportProps>(
|
|
72
|
-
({ classNames, asChild, children, ...props }, forwardedRef) => {
|
|
73
|
-
const { tx } = useThemeContext();
|
|
74
|
-
const Root = asChild ? Slot : Primitive.div;
|
|
75
|
-
return (
|
|
76
|
-
<Root
|
|
77
|
-
{...props}
|
|
78
|
-
className={tx('dropdownMenu.viewport', 'dropdown-menu__viewport', {}, classNames)}
|
|
79
|
-
ref={forwardedRef}
|
|
80
|
-
>
|
|
81
|
-
{children}
|
|
82
|
-
</Root>
|
|
83
|
-
);
|
|
84
|
-
},
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
type DropdownMenuArrowProps = ThemedClassName<DropdownMenuArrowPrimitiveProps>;
|
|
88
|
-
|
|
89
|
-
const DropdownMenuArrow = forwardRef<SVGSVGElement, DropdownMenuArrowProps>(
|
|
90
|
-
({ classNames, ...props }, forwardedRef) => {
|
|
91
|
-
const { tx } = useThemeContext();
|
|
92
|
-
return (
|
|
93
|
-
<DropdownMenuArrowPrimitive
|
|
94
|
-
{...props}
|
|
95
|
-
className={tx('dropdownMenu.arrow', 'dropdown-menu__arrow', {}, classNames)}
|
|
96
|
-
ref={forwardedRef}
|
|
97
|
-
/>
|
|
98
|
-
);
|
|
99
|
-
},
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
type DropdownMenuGroupProps = DropdownMenuGroupPrimitiveProps;
|
|
103
|
-
|
|
104
|
-
const DropdownMenuGroup = DropdownMenuGroupPrimitive;
|
|
105
|
-
|
|
106
|
-
type DropdownMenuItemIndicatorProps = DropdownMenuItemIndicatorPrimitiveProps;
|
|
107
|
-
|
|
108
|
-
const DropdownMenuItemIndicator = DropdownMenuItemIndicatorPrimitive;
|
|
109
|
-
|
|
110
|
-
type DropdownMenuItemProps = ThemedClassName<DropdownMenuItemPrimitiveProps>;
|
|
111
|
-
|
|
112
|
-
const DropdownMenuItem = forwardRef<HTMLDivElement, DropdownMenuItemProps>(
|
|
113
|
-
({ classNames, ...props }: DropdownMenuItemProps, forwardedRef) => {
|
|
114
|
-
const { tx } = useThemeContext();
|
|
115
|
-
return (
|
|
116
|
-
<DropdownMenuItemPrimitive
|
|
117
|
-
{...props}
|
|
118
|
-
className={tx('dropdownMenu.item', 'dropdown-menu__item', {}, classNames)}
|
|
119
|
-
ref={forwardedRef}
|
|
120
|
-
/>
|
|
121
|
-
);
|
|
122
|
-
},
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
type DropdownMenuCheckboxItemProps = ThemedClassName<DropdownMenuCheckboxItemPrimitiveProps>;
|
|
126
|
-
|
|
127
|
-
const DropdownMenuCheckboxItem = forwardRef<HTMLDivElement, DropdownMenuCheckboxItemProps>(
|
|
128
|
-
({ classNames, ...props }: DropdownMenuItemProps, forwardedRef) => {
|
|
129
|
-
const { tx } = useThemeContext();
|
|
130
|
-
return (
|
|
131
|
-
<DropdownMenuCheckboxItemPrimitive
|
|
132
|
-
{...props}
|
|
133
|
-
className={tx('dropdownMenu.item', 'dropdown-menu__item--checkbox', {}, classNames)}
|
|
134
|
-
ref={forwardedRef}
|
|
135
|
-
/>
|
|
136
|
-
);
|
|
137
|
-
},
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
type DropdownMenuSeparatorProps = ThemedClassName<DropdownMenuSeparatorPrimitiveProps>;
|
|
141
|
-
|
|
142
|
-
const DropdownMenuSeparator = forwardRef<HTMLDivElement, DropdownMenuSeparatorProps>(
|
|
143
|
-
({ classNames, ...props }, forwardedRef) => {
|
|
144
|
-
const { tx } = useThemeContext();
|
|
145
|
-
return (
|
|
146
|
-
<DropdownMenuSeparatorPrimitive
|
|
147
|
-
{...props}
|
|
148
|
-
className={tx('dropdownMenu.separator', 'dropdown-menu__item', {}, classNames)}
|
|
149
|
-
ref={forwardedRef}
|
|
150
|
-
/>
|
|
151
|
-
);
|
|
152
|
-
},
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
type DropdownMenuGroupLabelProps = ThemedClassName<DropdownMenuLabelPrimitiveProps>;
|
|
156
|
-
|
|
157
|
-
const DropdownMenuGroupLabel = forwardRef<HTMLDivElement, DropdownMenuGroupLabelProps>(
|
|
158
|
-
({ classNames, ...props }, forwardedRef) => {
|
|
159
|
-
const { tx } = useThemeContext();
|
|
160
|
-
return (
|
|
161
|
-
<DropdownMenuLabelPrimitive
|
|
162
|
-
{...props}
|
|
163
|
-
className={tx('dropdownMenu.groupLabel', 'dropdown-menu__group__label', {}, classNames)}
|
|
164
|
-
ref={forwardedRef}
|
|
165
|
-
/>
|
|
166
|
-
);
|
|
167
|
-
},
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
export const DropdownMenu = {
|
|
171
|
-
Root: DropdownMenuRoot,
|
|
172
|
-
Trigger: DropdownMenuTrigger,
|
|
173
|
-
Portal: DropdownMenuPortal,
|
|
174
|
-
Content: DropdownMenuContent,
|
|
175
|
-
Viewport: DropdownMenuViewport,
|
|
176
|
-
Arrow: DropdownMenuArrow,
|
|
177
|
-
Group: DropdownMenuGroup,
|
|
178
|
-
Item: DropdownMenuItem,
|
|
179
|
-
CheckboxItem: DropdownMenuCheckboxItem,
|
|
180
|
-
ItemIndicator: DropdownMenuItemIndicator,
|
|
181
|
-
Separator: DropdownMenuSeparator,
|
|
182
|
-
GroupLabel: DropdownMenuGroupLabel,
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
export type {
|
|
186
|
-
DropdownMenuRootProps,
|
|
187
|
-
DropdownMenuTriggerProps,
|
|
188
|
-
DropdownMenuPortalProps,
|
|
189
|
-
DropdownMenuContentProps,
|
|
190
|
-
DropdownMenuViewportProps,
|
|
191
|
-
DropdownMenuArrowProps,
|
|
192
|
-
DropdownMenuGroupProps,
|
|
193
|
-
DropdownMenuItemProps,
|
|
194
|
-
DropdownMenuCheckboxItemProps,
|
|
195
|
-
DropdownMenuItemIndicatorProps,
|
|
196
|
-
DropdownMenuSeparatorProps,
|
|
197
|
-
DropdownMenuGroupLabelProps,
|
|
198
|
-
};
|
|
File without changes
|
|
File without changes
|