@dxos/react-ui 0.3.10 → 0.3.11-main.00a28cb

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.
Files changed (51) hide show
  1. package/dist/lib/browser/index.mjs +315 -229
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/components/Avatars/Avatar.d.ts +1 -1
  5. package/dist/types/src/components/Avatars/Avatar.d.ts.map +1 -1
  6. package/dist/types/src/components/List/List.d.ts.map +1 -0
  7. package/dist/types/src/components/{Lists → List}/List.stories.d.ts +3 -1
  8. package/dist/types/src/components/List/List.stories.d.ts.map +1 -0
  9. package/dist/types/src/components/List/Tree.d.ts.map +1 -0
  10. package/dist/types/src/components/List/Tree.stories.d.ts.map +1 -0
  11. package/dist/types/src/components/List/index.d.ts.map +1 -0
  12. package/dist/types/src/components/Menus/ContextMenu.d.ts +50 -0
  13. package/dist/types/src/components/Menus/ContextMenu.d.ts.map +1 -0
  14. package/dist/types/src/components/Menus/ContextMenu.stories.d.ts +21 -0
  15. package/dist/types/src/components/Menus/ContextMenu.stories.d.ts.map +1 -0
  16. package/dist/types/src/components/{DropdownMenu → Menus}/DropdownMenu.d.ts +23 -23
  17. package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +1 -0
  18. package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts.map +1 -0
  19. package/dist/types/src/components/Menus/index.d.ts +3 -0
  20. package/dist/types/src/components/Menus/index.d.ts.map +1 -0
  21. package/dist/types/src/components/index.d.ts +2 -2
  22. package/dist/types/src/components/index.d.ts.map +1 -1
  23. package/package.json +10 -8
  24. package/src/components/Avatars/Avatar.tsx +1 -1
  25. package/src/components/{Lists → List}/List.stories.tsx +38 -2
  26. package/src/components/Menus/ContextMenu.stories.tsx +106 -0
  27. package/src/components/Menus/ContextMenu.tsx +170 -0
  28. package/src/components/Menus/DropdownMenu.tsx +173 -0
  29. package/src/components/{DropdownMenu → Menus}/index.ts +1 -0
  30. package/src/components/index.ts +2 -2
  31. package/src/playground/Typography.stories.tsx +1 -1
  32. package/dist/types/src/components/DropdownMenu/DropdownMenu.d.ts.map +0 -1
  33. package/dist/types/src/components/DropdownMenu/DropdownMenu.stories.d.ts.map +0 -1
  34. package/dist/types/src/components/DropdownMenu/index.d.ts +0 -2
  35. package/dist/types/src/components/DropdownMenu/index.d.ts.map +0 -1
  36. package/dist/types/src/components/Lists/List.d.ts.map +0 -1
  37. package/dist/types/src/components/Lists/List.stories.d.ts.map +0 -1
  38. package/dist/types/src/components/Lists/Tree.d.ts.map +0 -1
  39. package/dist/types/src/components/Lists/Tree.stories.d.ts.map +0 -1
  40. package/dist/types/src/components/Lists/index.d.ts.map +0 -1
  41. package/src/components/DropdownMenu/DropdownMenu.tsx +0 -198
  42. package/dist/types/src/components/{Lists → List}/List.d.ts +0 -0
  43. package/dist/types/src/components/{Lists → List}/Tree.d.ts +0 -0
  44. package/dist/types/src/components/{Lists → List}/Tree.stories.d.ts +0 -0
  45. package/dist/types/src/components/{Lists → List}/index.d.ts +0 -0
  46. package/dist/types/src/components/{DropdownMenu → Menus}/DropdownMenu.stories.d.ts +0 -0
  47. package/src/components/{Lists → List}/List.tsx +0 -0
  48. package/src/components/{Lists → List}/Tree.stories.tsx +0 -0
  49. package/src/components/{Lists → List}/Tree.tsx +1 -1
  50. /package/src/components/{Lists → List}/index.ts +0 -0
  51. /package/src/components/{DropdownMenu → Menus}/DropdownMenu.stories.tsx +0 -0
@@ -3,10 +3,10 @@ export * from './Avatars';
3
3
  export * from './Breadcrumb';
4
4
  export * from './Buttons';
5
5
  export * from './Dialogs';
6
- export * from './DropdownMenu';
6
+ export * from './Menus';
7
7
  export * from './Input';
8
8
  export * from './Link';
9
- export * from './Lists';
9
+ export * from './List';
10
10
  export * from './Main';
11
11
  export * from './Message';
12
12
  export * from './Popover';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAE1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAE1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui",
3
- "version": "0.3.10",
3
+ "version": "0.3.11-main.00a28cb",
4
4
  "description": "Low-level React components for DXOS, applying a theme to a core group of primitives",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -13,10 +13,12 @@
13
13
  "src"
14
14
  ],
15
15
  "dependencies": {
16
+ "@fluentui/react-tabster": "^9.16.1",
16
17
  "@radix-ui/react-alert-dialog": "^1.0.3",
17
18
  "@radix-ui/react-avatar": "^1.0.2",
18
19
  "@radix-ui/react-checkbox": "^1.0.3",
19
20
  "@radix-ui/react-context": "^1.0.0",
21
+ "@radix-ui/react-context-menu": "^2.1.5",
20
22
  "@radix-ui/react-dialog": "^1.0.3",
21
23
  "@radix-ui/react-dropdown-menu": "^2.0.5",
22
24
  "@radix-ui/react-popover": "^1.0.6",
@@ -37,24 +39,24 @@
37
39
  "jdenticon": "^3.2.0",
38
40
  "keyborg": "^2.0.0",
39
41
  "react-i18next": "^11.18.6",
40
- "@dxos/react-hooks": "0.3.10",
41
- "@dxos/react-input": "0.3.10",
42
- "@dxos/react-list": "0.3.10",
43
- "@dxos/react-ui-types": "0.3.10"
42
+ "@dxos/react-list": "0.3.11-main.00a28cb",
43
+ "@dxos/react-hooks": "0.3.11-main.00a28cb",
44
+ "@dxos/react-input": "0.3.11-main.00a28cb",
45
+ "@dxos/react-ui-types": "0.3.11-main.00a28cb"
44
46
  },
45
47
  "devDependencies": {
46
48
  "@dnd-kit/core": "^6.0.5",
47
49
  "@dnd-kit/sortable": "^7.0.1",
48
50
  "@dnd-kit/utilities": "^3.2.0",
49
- "@faker-js/faker": "^8.0.2",
51
+ "@faker-js/faker": "^8.3.1",
50
52
  "@phosphor-icons/react": "^2.0.5",
51
53
  "@types/react": "^18.0.21",
52
54
  "@types/react-dom": "^18.0.6",
53
55
  "react": "^18.2.0",
54
56
  "react-dom": "^18.2.0",
55
- "vite": "^4.3.9",
57
+ "vite": "^5.0.11",
56
58
  "vite-plugin-turbosnap": "^1.0.2",
57
- "@dxos/react-ui-theme": "0.3.10"
59
+ "@dxos/react-ui-theme": "0.3.11-main.00a28cb"
58
60
  },
59
61
  "peerDependencies": {
60
62
  "@phosphor-icons/react": "^2.0.5",
@@ -21,7 +21,7 @@ import { useThemeContext } from '../../hooks';
21
21
  import { type ThemedClassName } from '../../util';
22
22
 
23
23
  type AvatarVariant = 'square' | 'circle';
24
- type AvatarStatus = 'active' | 'inactive' | 'error' | 'warning';
24
+ type AvatarStatus = 'active' | 'inactive' | 'current' | 'error' | 'warning';
25
25
  type AvatarAnimation = 'pulse' | 'none';
26
26
 
27
27
  export type AvatarRootProps = PropsWithChildren<Partial<AvatarContextValue>>;
@@ -7,10 +7,11 @@ import '@dxosTheme';
7
7
  import { DndContext, type DragEndEvent, type DragStartEvent } from '@dnd-kit/core';
8
8
  import { arrayMove, SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';
9
9
  import { CSS } from '@dnd-kit/utilities';
10
+ import { useArrowNavigationGroup } from '@fluentui/react-tabster';
10
11
  import { DotsSixVertical, PushPin } from '@phosphor-icons/react';
11
12
  import React, { type FC, type ReactNode, useState } from 'react';
12
13
 
13
- import { getSize, mx, surfaceElevation } from '@dxos/react-ui-theme';
14
+ import { getSize, ghostHover, ghostSelected, mx, surfaceElevation } from '@dxos/react-ui-theme';
14
15
 
15
16
  import { List, ListItem, type ListProps, type ListScopedProps } from './List';
16
17
  import { withTheme } from '../../testing';
@@ -106,6 +107,7 @@ const ManySizesDraggableListItem = ({
106
107
  </ListItem.Root>
107
108
  );
108
109
  };
110
+
109
111
  export const ManySizesDraggable = {
110
112
  render: ({ ...args }) => {
111
113
  const [items, setItems] = useState(
@@ -183,6 +185,40 @@ export const Collapsible = {
183
185
  },
184
186
  args: {
185
187
  variant: 'unordered',
186
- toggleOpenLabel: 'Open/close storybook list item',
188
+ // toggleOpenLabel: 'Open/close storybook list item', // TODO(burdon): ???
189
+ },
190
+ };
191
+
192
+ export const SelectableListbox = {
193
+ render: () => {
194
+ const [selectedId, setSelectedId] = useState<string>();
195
+ const domAttributes = useArrowNavigationGroup({ axis: 'vertical' });
196
+ const [items, _setItems] = useState(
197
+ [...Array(12)].map((_, index) => ({
198
+ id: `listItem-${index}`,
199
+ text: `List item ${index + 1}`,
200
+ })),
201
+ );
202
+
203
+ // TODO(burdon): Handle up/down.
204
+ const handleKeyUp = (event: any) => {
205
+ console.log(event);
206
+ };
207
+
208
+ return (
209
+ <List selectable {...domAttributes}>
210
+ {items.map(({ id, text }) => (
211
+ <ListItem.Root
212
+ key={id}
213
+ selected={selectedId === id}
214
+ classNames={mx('items-center', ghostHover, selectedId === id && ghostSelected)}
215
+ onClick={() => setSelectedId(id)}
216
+ onKeyUp={handleKeyUp}
217
+ >
218
+ <ListItem.Heading classNames='grow'>{text}</ListItem.Heading>
219
+ </ListItem.Root>
220
+ ))}
221
+ </List>
222
+ );
187
223
  },
188
224
  };
@@ -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
+ };
@@ -2,4 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ export * from './ContextMenu';
5
6
  export * from './DropdownMenu';
@@ -7,10 +7,10 @@ export * from './Avatars';
7
7
  export * from './Breadcrumb';
8
8
  export * from './Buttons';
9
9
  export * from './Dialogs';
10
- export * from './DropdownMenu';
10
+ export * from './Menus';
11
11
  export * from './Input';
12
12
  export * from './Link';
13
- export * from './Lists';
13
+ export * from './List';
14
14
  export * from './Main';
15
15
  export * from './Message';
16
16
  export * from './Popover';
@@ -44,7 +44,7 @@ const TypographyStory = () => {
44
44
  };
45
45
 
46
46
  export default {
47
- title: 'DXOS UI/Scenarios/Typography',
47
+ title: 'react-ui/Scenarios/Typography',
48
48
  component: TypographyStory,
49
49
  decorators: [withTheme],
50
50
  parameters: { chromatic: { disableSnapshot: false } },
@@ -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,2 +0,0 @@
1
- export * from './DropdownMenu';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/DropdownMenu/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../../../src/components/Lists/List.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EAAE,KAAK,wBAAwB,EAAE,KAAK,EAAE,EAAc,KAAK,yBAAyB,EAAE,MAAM,OAAO,CAAC;AAElH,OAAO,EAEL,KAAK,SAAS,IAAI,kBAAkB,EACpC,KAAK,eAAe,EAEpB,KAAK,oBAAoB,IAAI,6BAA6B,EAE1D,KAAK,wBAAwB,IAAI,iCAAiC,EAElE,KAAK,+BAA+B,EAEpC,KAAK,aAAa,IAAI,sBAAsB,EAC5C,KAAK,mBAAmB,EACxB,SAAS,EACT,cAAc,EACd,cAAc,EACd,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,KAAK,SAAS,GAAG,eAAe,CAAC,kBAAkB,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7E,QAAA,MAAM,IAAI,krJAWR,CAAC;AAEH,KAAK,mBAAmB,GAAG,eAAe,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAmCpG,KAAK,oBAAoB,GAAG,eAAe,CAAC,6BAA6B,CAAC,CAAC;AAkB3E,KAAK,wBAAwB,GAAG,eAAe,CAAC,iCAAiC,CAAC,CAAC;AA2BnF,KAAK,iBAAiB,GAAG,eAAe,CAAC,sBAAsB,CAAC,CAAC;AAkBjE,eAAO,MAAM,QAAQ,EAAE;IACrB,IAAI,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;IACnD,MAAM,EAAE,yBAAyB,CAAC,mBAAmB,CAAC,CAAC;IACvD,OAAO,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,CAAC;IACzD,WAAW,EAAE,yBAAyB,CAAC,wBAAwB,CAAC,CAAC;IACjE,kBAAkB,EAAE,yBAAyB,CAAC,+BAA+B,CAAC,CAAC;IAC/E,eAAe,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;CAQzF,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,kBAAkB,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;AAE/E,YAAY,EACV,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,+BAA+B,GAChC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"List.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Lists/List.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAMpB,OAAO,KAA4C,MAAM,OAAO,CAAC;AAIjE,OAAO,EAAkB,KAAK,SAAS,EAAwB,MAAM,QAAQ,CAAC;;;;;;;;;;;AAG9E,wBAKE;AAuBF,eAAO,MAAM,oBAAoB;;;;;CAgChC,CAAC;AA+BF,eAAO,MAAM,kBAAkB;;;;;CA8C9B,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;CA+BvB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["../../../../../src/components/Lists/Tree.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,wBAAwB,EAAE,KAAK,EAAE,EAAc,KAAK,yBAAyB,EAAE,MAAM,OAAO,CAAC;AAElH,OAAO,EAIL,KAAK,+BAA+B,EACpC,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAGf,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,KAAK,aAAa,GAAG,SAAS,CAAC;AAE/B,KAAK,aAAa,GAAG,iBAAiB,CAAC;AAwBvC,KAAK,oBAAoB,GAAG,oBAAoB,CAAC;AAIjD,KAAK,wBAAwB,GAAG,wBAAwB,CAAC;AAMzD,KAAK,iBAAiB,GAAG,+BAA+B,CAAC;AAIzD,eAAO,MAAM,IAAI;;;CAAyC,CAAC;AAC3D,eAAO,MAAM,QAAQ,EAAE;IACrB,IAAI,EAAE,yBAAyB,CAAC,aAAa,CAAC,CAAC;IAC/C,OAAO,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,CAAC;IACzD,IAAI,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;IACnD,WAAW,EAAE,yBAAyB,CAAC,wBAAwB,CAAC,CAAC;IACjE,eAAe,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;CAOzF,CAAC;AAEF,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tree.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Lists/Tree.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAOpB,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;;;;;;;;;;;AA4CF,wBAKE;AAEF,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;CAmBnB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Lists/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}