,\n ContextMenuContentOwnProps\n>;\n\nconst ContextMenuContent = React.forwardRef((props, forwardedRef) => {\n const { disableOutsidePointerEvents = true, offset, ...contentProps } = props;\n const context = useContextMenuContext(CONTENT_NAME);\n return (\n \n );\n}) as ContextMenuContentPrimitive;\n\nContextMenuContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nconst ContextMenuGroup = extendPrimitive(MenuPrimitive.Group, { displayName: 'ContextMenuGroup' });\nconst ContextMenuLabel = extendPrimitive(MenuPrimitive.Label, { displayName: 'ContextMenuLabel' });\nconst ContextMenuItem = extendPrimitive(MenuPrimitive.Item, { displayName: 'ContextMenuItem' });\nconst ContextMenuCheckboxItem = extendPrimitive(MenuPrimitive.CheckboxItem, {\n displayName: 'ContextMenuCheckboxItem',\n});\nconst ContextMenuRadioGroup = extendPrimitive(MenuPrimitive.RadioGroup, {\n displayName: 'ContextMenuRadioGroup',\n});\nconst ContextMenuRadioItem = extendPrimitive(MenuPrimitive.RadioItem, {\n displayName: 'ContextMenuRadioItem',\n});\nconst ContextMenuItemIndicator = extendPrimitive(MenuPrimitive.ItemIndicator, {\n displayName: 'ContextMenuItemIndicator',\n});\nconst ContextMenuSeparator = extendPrimitive(MenuPrimitive.Separator, {\n displayName: 'ContextMenuSeparator',\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = ContextMenu;\nconst Trigger = ContextMenuTrigger;\nconst Content = ContextMenuContent;\nconst Group = ContextMenuGroup;\nconst Label = ContextMenuLabel;\nconst Item = ContextMenuItem;\nconst CheckboxItem = ContextMenuCheckboxItem;\nconst RadioGroup = ContextMenuRadioGroup;\nconst RadioItem = ContextMenuRadioItem;\nconst ItemIndicator = ContextMenuItemIndicator;\nconst Separator = ContextMenuSeparator;\n\nexport {\n ContextMenu,\n ContextMenuTrigger,\n ContextMenuContent,\n ContextMenuGroup,\n ContextMenuLabel,\n ContextMenuItem,\n ContextMenuCheckboxItem,\n ContextMenuRadioGroup,\n ContextMenuRadioItem,\n ContextMenuItemIndicator,\n ContextMenuSeparator,\n //\n Root,\n Trigger,\n Content,\n Group,\n Label,\n Item,\n CheckboxItem,\n RadioGroup,\n RadioItem,\n ItemIndicator,\n Separator,\n};\nexport type { ContextMenuTriggerPrimitive, ContextMenuContentPrimitive };\n"],"names":["ContextMenuProvider","useContextMenuContext","createContext","ContextMenu","props","children","onOpenChange","open","setOpen","React","useState","handleOpenChangeProp","useCallbackRef","handleOpenChange","useCallback","_react","createElement","_radixUiReactMenu","Root","$b55f3d34bcc87b2d9b0bc87c90588a09$var$ContextMenuProvider","TRIGGER_DEFAULT_TAG","Platform","OS","View","ContextMenuTrigger","forwardRef","forwardedRef","as","triggerProps","context","pointRef","useRef","x","y","virtualRef","getBoundingClientRect","DOMRect","fromRect","width","height","current","Fragment","Anchor","Primitive","_babelRuntimeHelpersEsmExtends","ref","onContextMenu","composeEventHandlers","event","preventDefault","clientX","clientY","ContextMenuContent","disableOutsidePointerEvents","offset","contentProps","Content","style","--radix-context-menu-content-transform-origin","trapFocus","disableOutsideScroll","portalled","side","sideOffset","align","alignOffset","ContextMenuGroup","extendPrimitive","MenuPrimitive","Group","displayName","ContextMenuLabel","Label","ContextMenuItem","Item","ContextMenuCheckboxItem","CheckboxItem","ContextMenuRadioGroup","RadioGroup","ContextMenuRadioItem","RadioItem","ContextMenuItemIndicator","ItemIndicator","ContextMenuSeparator","Separator","Trigger"],"version":3,"file":"index.module.js.map"}
--------------------------------------------------------------------------------
/packages/radix/context-menu/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@radix-ui/react-context-menu",
3 | "version": "0.0.19",
4 | "license": "MIT",
5 | "source": "src/index.ts",
6 | "main": "dist/index.js",
7 | "module": "dist/index.module.js",
8 | "types": "dist/index.d.ts",
9 | "files": [
10 | "dist",
11 | "README.md"
12 | ],
13 | "sideEffects": false,
14 | "scripts": {
15 | "clean": "rm -rf dist",
16 | "prepublish": "yarn clean",
17 | "version": "yarn version"
18 | },
19 | "dependencies": {
20 | "@babel/runtime": "^7.13.10",
21 | "@radix-ui/primitive": "workspace:*",
22 | "@radix-ui/react-context": "workspace:*",
23 | "@radix-ui/react-menu": "workspace:*",
24 | "@radix-ui/react-polymorphic": "workspace:*",
25 | "@radix-ui/react-primitive": "workspace:*",
26 | "@radix-ui/react-use-callback-ref": "workspace:*"
27 | },
28 | "peerDependencies": {
29 | "react": "^16.8 || ^17.0",
30 | "react-dom": "^16.8 || ^17.0"
31 | },
32 | "homepage": "https://radix-ui.com/primitives",
33 | "repository": {
34 | "type": "git",
35 | "url": "git+https://github.com/radix-ui/primitives.git"
36 | },
37 | "bugs": {
38 | "url": "https://github.com/radix-ui/primitives/issues"
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/packages/radix/context-menu/src/ContextMenu.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import {
3 | ContextMenu,
4 | ContextMenuTrigger,
5 | ContextMenuContent,
6 | ContextMenuGroup,
7 | ContextMenuLabel,
8 | ContextMenuItem,
9 | ContextMenuCheckboxItem,
10 | ContextMenuRadioGroup,
11 | ContextMenuRadioItem,
12 | ContextMenuItemIndicator,
13 | ContextMenuSeparator,
14 | } from './ContextMenu';
15 | import { css } from '../../../../stitches.config';
16 | import { foodGroups } from '../../../../test-data/foods';
17 | import { classes, TickIcon } from '../../menu/src/Menu.stories';
18 |
19 | const { contentClass, itemClass, labelClass, separatorClass } = classes;
20 |
21 | export default { title: 'Components/ContextMenu' };
22 |
23 | export const Styled = () => {
24 | const [open, setOpen] = React.useState(false);
25 | return (
26 |
36 |
37 |
41 |
42 | console.log('undo')}>
43 | Undo
44 |
45 | console.log('redo')}>
46 | Redo
47 |
48 |
49 | console.log('cut')}>
50 | Cut
51 |
52 | console.log('copy')}>
53 | Copy
54 |
55 | console.log('paste')}>
56 | Paste
57 |
58 |
59 |
60 |
61 | );
62 | };
63 |
64 | export const WithLabels = () => (
65 |
66 |
67 |
68 |
69 | {foodGroups.map((foodGroup, index) => (
70 |
71 | {foodGroup.label && (
72 |
73 | {foodGroup.label}
74 |
75 | )}
76 | {foodGroup.foods.map((food) => (
77 | console.log(food.label)}
82 | >
83 | {food.label}
84 |
85 | ))}
86 | {index < foodGroups.length - 1 && }
87 |
88 | ))}
89 |
90 |
91 |
92 | );
93 |
94 | export const CheckboxItems = () => {
95 | const checkboxItems = [
96 | { label: 'Bold', state: React.useState(false) },
97 | { label: 'Italic', state: React.useState(true) },
98 | { label: 'Underline', state: React.useState(false) },
99 | { label: 'Strikethrough', state: React.useState(false), disabled: true },
100 | ];
101 |
102 | return (
103 |
104 |
105 |
106 |
107 | console.log('show')}>
108 | Show fonts
109 |
110 | console.log('bigger')}>
111 | Bigger
112 |
113 | console.log('smaller')}>
114 | Smaller
115 |
116 |
117 | {checkboxItems.map(({ label, state: [checked, setChecked], disabled }) => (
118 |
125 | {label}
126 |
127 |
128 |
129 |
130 | ))}
131 |
132 |
133 |
134 | );
135 | };
136 |
137 | export const RadioItems = () => {
138 | const files = ['README.md', 'index.js', 'page.css'];
139 | const [file, setFile] = React.useState(files[1]);
140 |
141 | return (
142 |
143 |
144 |
145 |
146 | console.log('minimize')}>
147 | Minimize window
148 |
149 | console.log('zoom')}>
150 | Zoom
151 |
152 | console.log('smaller')}>
153 | Smaller
154 |
155 |
156 |
157 | {files.map((file) => (
158 |
159 | {file}
160 |
161 |
162 |
163 |
164 | ))}
165 |
166 |
167 |
168 |
Selected file: {file}
169 |
170 | );
171 | };
172 |
173 | export const PreventClosing = () => (
174 |
175 |
176 |
177 |
178 | window.alert('action 1')}>
179 | I will close
180 |
181 | {
184 | event.preventDefault();
185 | window.alert('action 1');
186 | }}
187 | >
188 | I won't close
189 |
190 |
191 |
192 |
193 | );
194 |
195 | export const Multiple = () => {
196 | const [customColors, setCustomColors] = React.useState<{ [index: number]: string }>({});
197 | const [fadedIndexes, setFadedIndexes] = React.useState([]);
198 | return (
199 | event.preventDefault()}
202 | >
203 | {Array.from({ length: 100 }, (_, i) => {
204 | const customColor = customColors[i];
205 | return (
206 |
207 |
208 | Color
209 | setCustomColors((colors) => ({ ...colors, [i]: color }))}
212 | >
213 |
214 | Blue
215 |
216 |
217 |
218 |
219 |
220 | Red
221 |
222 |
223 |
224 |
225 |
226 |
227 |
231 | setFadedIndexes((indexes) =>
232 | faded ? [...indexes, i] : indexes.filter((index) => index !== i)
233 | )
234 | }
235 | >
236 | Fade
237 |
238 |
239 |
240 |
241 |
242 |
243 |
260 | {i + 1}
261 |
262 |
263 |
264 | );
265 | })}
266 |
267 | );
268 | };
269 |
270 | export const Nested = () => (
271 |
272 |
273 |
277 |
278 | {' '}
279 |
280 | Red box menu
281 |
282 | console.log('red action1')}>
283 | Red action 1
284 |
285 | console.log('red action2')}>
286 | Red action 2
287 |
288 |
289 |
290 |
291 |
292 | Blue box menu
293 |
294 | console.log('blue action1')}>
295 | Blue action 1
296 |
297 | console.log('blue action2')}>
298 | Blue action 2
299 |
300 |
301 |
302 |
303 | );
304 |
305 | const triggerClass = css({
306 | display: 'block',
307 | width: 100,
308 | height: 100,
309 | border: '1px solid $black',
310 | borderRadius: 6,
311 | backgroundColor: '$gray100',
312 |
313 | '&:focus': {
314 | outline: 'none',
315 | boxShadow: '0 0 0 2px rgba(0, 0, 0, 0.5)',
316 | },
317 | });
318 |
319 | const scaleIn = css.keyframes({
320 | '0%': { transform: 'scale(0) rotateZ(-10deg)' },
321 | '20%': { transform: 'scale(1.1)' },
322 | '100%': { transform: 'scale(1)' },
323 | });
324 |
325 | const animatedContentClass = css(contentClass, {
326 | transformOrigin: 'var(--radix-context-menu-content-transform-origin)',
327 | '&[data-state="open"]': { animation: `${scaleIn} 0.6s cubic-bezier(0.16, 1, 0.3, 1)` },
328 | });
329 |
--------------------------------------------------------------------------------
/packages/radix/context-menu/src/ContextMenu.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { Platform, View } from 'react-native';
3 | import { composeEventHandlers } from '@radix-ui/primitive';
4 | import { createContext } from '@radix-ui/react-context';
5 | import { Primitive, extendPrimitive } from '@radix-ui/react-primitive';
6 | import * as MenuPrimitive from '@radix-ui/react-menu';
7 | import { useCallbackRef } from '@radix-ui/react-use-callback-ref';
8 |
9 | import type * as Polymorphic from '@radix-ui/react-polymorphic';
10 |
11 | type Point = { x: number; y: number };
12 |
13 | /* -------------------------------------------------------------------------------------------------
14 | * ContextMenu
15 | * -----------------------------------------------------------------------------------------------*/
16 |
17 | const CONTEXT_MENU_NAME = 'ContextMenu';
18 |
19 | type ContextMenuContextValue = {
20 | open: boolean;
21 | onOpenChange(open: boolean): void;
22 | };
23 |
24 | const [ContextMenuProvider, useContextMenuContext] = createContext(
25 | CONTEXT_MENU_NAME
26 | );
27 |
28 | const ContextMenu: React.FC<{ onOpenChange?(open: boolean): void }> = (props) => {
29 | const { children, onOpenChange } = props;
30 | const [open, setOpen] = React.useState(false);
31 | const handleOpenChangeProp = useCallbackRef(onOpenChange);
32 |
33 | const handleOpenChange = React.useCallback(
34 | (open) => {
35 | setOpen(open);
36 | handleOpenChangeProp(open);
37 | },
38 | [handleOpenChangeProp]
39 | );
40 |
41 | return (
42 |
43 |
44 | {children}
45 |
46 |
47 | );
48 | };
49 |
50 | ContextMenu.displayName = CONTEXT_MENU_NAME;
51 |
52 | /* -------------------------------------------------------------------------------------------------
53 | * ContextMenuTrigger
54 | * -----------------------------------------------------------------------------------------------*/
55 |
56 | const TRIGGER_NAME = 'ContextMenuTrigger';
57 | const TRIGGER_DEFAULT_TAG = Platform.OS === 'web' ? 'span' : View;
58 |
59 | type ContextMenuTriggerOwnProps = Polymorphic.OwnProps;
60 | type ContextMenuTriggerPrimitive = Polymorphic.ForwardRefComponent<
61 | typeof TRIGGER_DEFAULT_TAG,
62 | ContextMenuTriggerOwnProps
63 | >;
64 |
65 | const ContextMenuTrigger = React.forwardRef((props, forwardedRef) => {
66 | const { as = TRIGGER_DEFAULT_TAG, ...triggerProps } = props;
67 | const context = useContextMenuContext(TRIGGER_NAME);
68 | const pointRef = React.useRef({ x: 0, y: 0 });
69 | const virtualRef = React.useRef({
70 | getBoundingClientRect: () => DOMRect.fromRect({ width: 0, height: 0, ...pointRef.current }),
71 | });
72 |
73 | return (
74 | <>
75 |
76 | {
81 | event.preventDefault();
82 | pointRef.current = { x: event.clientX, y: event.clientY };
83 | context.onOpenChange(true);
84 | })}
85 | />
86 | >
87 | );
88 | }) as ContextMenuTriggerPrimitive;
89 |
90 | ContextMenuTrigger.displayName = TRIGGER_NAME;
91 |
92 | /* -------------------------------------------------------------------------------------------------
93 | * ContextMenuContent
94 | * -----------------------------------------------------------------------------------------------*/
95 |
96 | const CONTENT_NAME = 'ContextMenuContent';
97 |
98 | type ContextMenuContentOwnProps = Polymorphic.Merge<
99 | Omit<
100 | Polymorphic.OwnProps,
101 | | 'trapFocus'
102 | | 'disableOutsideScroll'
103 | | 'portalled'
104 | | 'onOpenAutoFocus'
105 | | 'side'
106 | | 'sideOffset'
107 | | 'align'
108 | | 'alignOffset'
109 | >,
110 | { offset?: number }
111 | >;
112 |
113 | type ContextMenuContentPrimitive = Polymorphic.ForwardRefComponent<
114 | Polymorphic.IntrinsicElement,
115 | ContextMenuContentOwnProps
116 | >;
117 |
118 | const ContextMenuContent = React.forwardRef((props, forwardedRef) => {
119 | const { disableOutsidePointerEvents = true, offset, ...contentProps } = props;
120 | const context = useContextMenuContext(CONTENT_NAME);
121 | return (
122 |
139 | );
140 | }) as ContextMenuContentPrimitive;
141 |
142 | ContextMenuContent.displayName = CONTENT_NAME;
143 |
144 | /* ---------------------------------------------------------------------------------------------- */
145 |
146 | const ContextMenuGroup = extendPrimitive(MenuPrimitive.Group, { displayName: 'ContextMenuGroup' });
147 | const ContextMenuLabel = extendPrimitive(MenuPrimitive.Label, { displayName: 'ContextMenuLabel' });
148 | const ContextMenuItem = extendPrimitive(MenuPrimitive.Item, { displayName: 'ContextMenuItem' });
149 | const ContextMenuCheckboxItem = extendPrimitive(MenuPrimitive.CheckboxItem, {
150 | displayName: 'ContextMenuCheckboxItem',
151 | });
152 | const ContextMenuRadioGroup = extendPrimitive(MenuPrimitive.RadioGroup, {
153 | displayName: 'ContextMenuRadioGroup',
154 | });
155 | const ContextMenuRadioItem = extendPrimitive(MenuPrimitive.RadioItem, {
156 | displayName: 'ContextMenuRadioItem',
157 | });
158 | const ContextMenuItemIndicator = extendPrimitive(MenuPrimitive.ItemIndicator, {
159 | displayName: 'ContextMenuItemIndicator',
160 | });
161 | const ContextMenuSeparator = extendPrimitive(MenuPrimitive.Separator, {
162 | displayName: 'ContextMenuSeparator',
163 | });
164 |
165 | /* -----------------------------------------------------------------------------------------------*/
166 |
167 | const Root = ContextMenu;
168 | const Trigger = ContextMenuTrigger;
169 | const Content = ContextMenuContent;
170 | const Group = ContextMenuGroup;
171 | const Label = ContextMenuLabel;
172 | const Item = ContextMenuItem;
173 | const CheckboxItem = ContextMenuCheckboxItem;
174 | const RadioGroup = ContextMenuRadioGroup;
175 | const RadioItem = ContextMenuRadioItem;
176 | const ItemIndicator = ContextMenuItemIndicator;
177 | const Separator = ContextMenuSeparator;
178 |
179 | export {
180 | ContextMenu,
181 | ContextMenuTrigger,
182 | ContextMenuContent,
183 | ContextMenuGroup,
184 | ContextMenuLabel,
185 | ContextMenuItem,
186 | ContextMenuCheckboxItem,
187 | ContextMenuRadioGroup,
188 | ContextMenuRadioItem,
189 | ContextMenuItemIndicator,
190 | ContextMenuSeparator,
191 | //
192 | Root,
193 | Trigger,
194 | Content,
195 | Group,
196 | Label,
197 | Item,
198 | CheckboxItem,
199 | RadioGroup,
200 | RadioItem,
201 | ItemIndicator,
202 | Separator,
203 | };
204 | export type { ContextMenuTriggerPrimitive, ContextMenuContentPrimitive };
205 |
--------------------------------------------------------------------------------
/packages/radix/context-menu/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './ContextMenu';
2 |
--------------------------------------------------------------------------------
/packages/radix/dropdown-menu/README.md:
--------------------------------------------------------------------------------
1 | # `react-dropdown-menu`
2 |
3 | ## Installation
4 |
5 | ```sh
6 | $ yarn add @radix-ui/react-dropdown-menu
7 | # or
8 | $ npm install @radix-ui/react-dropdown-menu
9 | ```
10 |
11 | ## Usage
12 |
13 | View docs [here](https://radix-ui.com/primitives/docs/components/dropdown-menu).
14 |
--------------------------------------------------------------------------------
/packages/radix/dropdown-menu/dist/index.d.ts:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import * as MenuPrimitive from "@radix-ui/react-menu";
3 | import * as Polymorphic from "@radix-ui/react-polymorphic";
4 | type DropdownMenuOwnProps = {
5 | open?: boolean;
6 | defaultOpen?: boolean;
7 | onOpenChange?(open: boolean): void;
8 | };
9 | export const DropdownMenu: React.FC;
10 | declare const TRIGGER_DEFAULT_TAG: any;
11 | type DropdownMenuTriggerOwnProps = Omit, 'virtualRef'>;
12 | export type DropdownMenuTriggerPrimitive = Polymorphic.ForwardRefComponent;
13 | export const DropdownMenuTrigger: DropdownMenuTriggerPrimitive;
14 | type DropdownMenuContentOwnProps = Omit, 'trapFocus' | 'onOpenAutoFocus'>;
15 | export type DropdownMenuContentPrimitive = Polymorphic.ForwardRefComponent, DropdownMenuContentOwnProps>;
16 | export const DropdownMenuContent: DropdownMenuContentPrimitive;
17 | export const DropdownMenuGroup: import("@radix-ui/react-primitive").ExtendedPrimitive, "div">;
18 | export const DropdownMenuLabel: import("@radix-ui/react-primitive").ExtendedPrimitive, "div">;
19 | export const DropdownMenuItem: import("@radix-ui/react-primitive").ExtendedPrimitive;
20 | export const DropdownMenuCheckboxItem: import("@radix-ui/react-primitive").ExtendedPrimitive;
21 | export const DropdownMenuRadioGroup: import("@radix-ui/react-primitive").ExtendedPrimitive;
22 | export const DropdownMenuRadioItem: import("@radix-ui/react-primitive").ExtendedPrimitive;
23 | export const DropdownMenuItemIndicator: import("@radix-ui/react-primitive").ExtendedPrimitive;
24 | export const DropdownMenuSeparator: import("@radix-ui/react-primitive").ExtendedPrimitive, "div">;
25 | export const DropdownMenuArrow: import("@radix-ui/react-primitive").ExtendedPrimitive, "svg">;
26 | export const Root: React.FC;
27 | export const Trigger: DropdownMenuTriggerPrimitive;
28 | export const Content: DropdownMenuContentPrimitive;
29 | export const Group: import("@radix-ui/react-primitive").ExtendedPrimitive, "div">;
30 | export const Label: import("@radix-ui/react-primitive").ExtendedPrimitive, "div">;
31 | export const Item: import("@radix-ui/react-primitive").ExtendedPrimitive;
32 | export const CheckboxItem: import("@radix-ui/react-primitive").ExtendedPrimitive;
33 | export const RadioGroup: import("@radix-ui/react-primitive").ExtendedPrimitive;
34 | export const RadioItem: import("@radix-ui/react-primitive").ExtendedPrimitive;
35 | export const ItemIndicator: import("@radix-ui/react-primitive").ExtendedPrimitive;
36 | export const Separator: import("@radix-ui/react-primitive").ExtendedPrimitive, "div">;
37 | export const Arrow: import("@radix-ui/react-primitive").ExtendedPrimitive, "svg">;
38 |
39 | //# sourceMappingURL=index.d.ts.map
40 |
--------------------------------------------------------------------------------
/packages/radix/dropdown-menu/dist/index.d.ts.map:
--------------------------------------------------------------------------------
1 | {"mappings":"A;A;A;AA+BA,4BAA4B;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CACpC,CAAC;AAEF,OAAA,MAAM,cAAc,MAAM,EAAE,CAAC,oBAAoB,CAsBhD,CAAC;AASF,QAAA,MAAM,wBAA6D,CAAC;AAEpE,mCAAmC,IAAI,CACrC,YAAY,QAAQ,CAAC,OAAO,cAAc,MAAM,CAAC,EACjD,YAAY,CACb,CAAC;AACF,2CAAoC,YAAY,mBAAmB,CACjE,0BAA0B,EAC1B,2BAA2B,CAC5B,CAAC;AAEF,OAAA,MAAM,iDA8B4B,CAAC;AAUnC,mCAAmC,IAAI,CACrC,YAAY,QAAQ,CAAC,OAAO,cAAc,OAAO,CAAC,EAClD,WAAW,GAAG,iBAAiB,CAChC,CAAC;AAEF,2CAAoC,YAAY,mBAAmB,CACjE,YAAY,gBAAgB,CAAC,OAAO,cAAc,OAAO,CAAC,EAC1D,2BAA2B,CAC5B,CAAC;AAEF,OAAA,MAAM,iDAwE4B,CAAC;AAMnC,OAAA,MAAM,qMAEJ,CAAC;AACH,OAAA,MAAM,qMAEJ,CAAC;AACH,OAAA,MAAM,+GAA2F,CAAC;AAClG,OAAA,MAAM,+HAEJ,CAAC;AACH,OAAA,MAAM,2HAEJ,CAAC;AACH,OAAA,MAAM,yHAEJ,CAAC;AACH,OAAA,MAAM,kIAEJ,CAAC;AACH,OAAA,MAAM,yMAEJ,CAAC;AACH,OAAA,MAAM,oMAEJ,CAAC;AAIH,OAAA,MAAM,oCAAmB,CAAC;AAC1B,OAAA,MAAM,qCAA6B,CAAC;AACpC,OAAA,MAAM,qCAA6B,CAAC;AACpC,OAAA,MAAM,yLAAyB,CAAC;AAChC,OAAA,MAAM,yLAAyB,CAAC;AAChC,OAAA,MAAM,mGAAuB,CAAC;AAC9B,OAAA,MAAM,mHAAuC,CAAC;AAC9C,OAAA,MAAM,+GAAmC,CAAC;AAC1C,OAAA,MAAM,6GAAiC,CAAC;AACxC,OAAA,MAAM,sHAAyC,CAAC;AAChD,OAAA,MAAM,6LAAiC,CAAC;AACxC,OAAA,MAAM,wLAAyB,CAAC","sources":["./packages/react/dropdown-menu/src/packages/react/dropdown-menu/src/DropdownMenu.tsx","./packages/react/dropdown-menu/src/packages/react/dropdown-menu/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"index.d.ts.map"}
--------------------------------------------------------------------------------
/packages/radix/dropdown-menu/dist/index.js:
--------------------------------------------------------------------------------
1 | var e=w(require("@gorhom/bottom-sheet")),o=require("@radix-ui/react-id").useId,n=x({},require("@radix-ui/react-menu")),r=require("@radix-ui/react-primitive").extendPrimitive,t=require("@radix-ui/react-use-controllable-state").useControllableState,a=require("@radix-ui/react-context").createContext,s=require("@radix-ui/react-compose-refs").useComposedRefs,p=require("@radix-ui/primitive").composeEventHandlers,u=require("react-native"),i=u.Platform,d=u.View,c=u.Modal,l=x({},require("react")),m=w(require("@babel/runtime/helpers/extends"));function w(e){return e&&e.__esModule?e.default:e}function x(e,o){return Object.keys(o).forEach((function(n){"default"!==n&&"__esModule"!==n&&Object.defineProperty(e,n,{enumerable:!0,get:function(){return o[n]}})})),e}const[D,f]=a("DropdownMenu"),g=e=>{const{children:r,open:a,defaultOpen:s,onOpenChange:p}=e,u=l.useRef(null),[i=!1,d]=t({prop:a,defaultProp:s,onChange:p});/*#__PURE__*/return l.createElement(n.Root,{open:i,onOpenChange:d},/*#__PURE__*/l.createElement(D,{triggerRef:u,contentId:o(),open:i,onOpenChange:d,onOpenToggle:l.useCallback((()=>d((e=>!e))),[d])},r))};exports.DropdownMenu=g;const M="web"===i.OS?"button":d,b=/*#__PURE__*/l.forwardRef(((e,o)=>{const{as:r=M,...t}=e,a=f("DropdownMenuTrigger"),u=s(o,a.triggerRef);/*#__PURE__*/return l.createElement(n.Anchor,m({type:"button","aria-haspopup":"menu","aria-expanded":!!a.open||void 0,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed"},t,{as:r,ref:u,onMouseDown:p(e.onMouseDown,(e=>{0===e.button&&!1===e.ctrlKey&&a.onOpenToggle()})),onKeyDown:p(e.onKeyDown,(e=>{[" ","Enter","ArrowUp","ArrowDown"].includes(e.key)&&(e.preventDefault(),a.onOpenChange(!0))}))}))}));exports.DropdownMenuTrigger=b;const C=/*#__PURE__*/l.forwardRef(((o,r)=>{const{onCloseAutoFocus:t,disableOutsidePointerEvents:a=!0,disableOutsideScroll:s=!0,portalled:u=!0,...d}=o,w=f("DropdownMenuContent"),x=l.useRef(null),D=l.useCallback((e=>{-1===e&&w.onOpenChange(!1)}),[w]);return"web"===i.OS?/*#__PURE__*/l.createElement(n.Content,m({id:w.contentId},d,{ref:r,disableOutsidePointerEvents:a,disableOutsideScroll:s,portalled:u,style:{...o.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)"},trapFocus:!0,onCloseAutoFocus:p(t,(e=>{var o;e.preventDefault(),null===(o=w.triggerRef.current)||void 0===o||o.focus()})),onPointerDownOutside:p(o.onPointerDownOutside,(e=>{var o;(null===(o=w.triggerRef.current)||void 0===o?void 0:o.contains(e.target))&&e.preventDefault()}),{checkForDefaultPrevented:!1})})):/*#__PURE__*/l.createElement(c,{animationType:"none",transparent:!0,visible:w.open,onRequestClose:()=>{w.onOpenChange(!w.open)}},/*#__PURE__*/l.createElement(e,m({},d,{ref:x,animateOnMount:!0,enablePanDownToClose:!0,onChange:D})))}));exports.DropdownMenuContent=C;const I=r(n.Group,{displayName:"DropdownMenuGroup"});exports.DropdownMenuGroup=I;const v=r(n.Label,{displayName:"DropdownMenuLabel"});exports.DropdownMenuLabel=v;const h=r(n.Item,{displayName:"DropdownMenuItem"});exports.DropdownMenuItem=h;const O=r(n.CheckboxItem,{displayName:"DropdownMenuCheckboxItem"});exports.DropdownMenuCheckboxItem=O;const R=r(n.RadioGroup,{displayName:"DropdownMenuRadioGroup"});exports.DropdownMenuRadioGroup=R;const y=r(n.RadioItem,{displayName:"DropdownMenuRadioItem"});exports.DropdownMenuRadioItem=y;const q=r(n.ItemIndicator,{displayName:"DropdownMenuItemIndicator"});exports.DropdownMenuItemIndicator=q;const E=r(n.Separator,{displayName:"DropdownMenuSeparator"});exports.DropdownMenuSeparator=E;const P=r(n.Arrow,{displayName:"DropdownMenuArrow"});exports.DropdownMenuArrow=P;const k=g;exports.Root=k;const A=b;exports.Trigger=A;const N=C;exports.Content=N;const S=I;exports.Group=S;const G=v;exports.Label=G;const T=h;exports.Item=T;const F=O;exports.CheckboxItem=F;const L=R;exports.RadioGroup=L;const _=y;exports.RadioItem=_;const K=q;exports.ItemIndicator=K;const j=E;exports.Separator=j;const H=P;exports.Arrow=H;
2 | //# sourceMappingURL=index.js.map
3 |
--------------------------------------------------------------------------------
/packages/radix/dropdown-menu/dist/index.module.js:
--------------------------------------------------------------------------------
1 | import o from"@gorhom/bottom-sheet";import{useId as e}from"@radix-ui/react-id";import*as n from"@radix-ui/react-menu";import{extendPrimitive as r}from"@radix-ui/react-primitive";import{useControllableState as t}from"@radix-ui/react-use-controllable-state";import{createContext as p}from"@radix-ui/react-context";import{useComposedRefs as a}from"@radix-ui/react-compose-refs";import{composeEventHandlers as d}from"@radix-ui/primitive";import{Platform as i,View as u,Modal as s}from"react-native";import*as c from"react";import m from"@babel/runtime/helpers/esm/extends";const[l,w]=p("DropdownMenu");export const DropdownMenu=o=>{const{children:r,open:p,defaultOpen:a,onOpenChange:d}=o,i=c.useRef(null),[u=!1,s]=t({prop:p,defaultProp:a,onChange:d});/*#__PURE__*/return c.createElement(n.Root,{open:u,onOpenChange:s},/*#__PURE__*/c.createElement(l,{triggerRef:i,contentId:e(),open:u,onOpenChange:s,onOpenToggle:c.useCallback((()=>s((o=>!o))),[s])},r))};/*#__PURE__*/const D="web"===i.OS?"button":u;export const DropdownMenuTrigger=/*#__PURE__*/c.forwardRef(((o,e)=>{const{as:r=D,...t}=o,p=w("DropdownMenuTrigger"),i=a(e,p.triggerRef);/*#__PURE__*/return c.createElement(n.Anchor,m({type:"button","aria-haspopup":"menu","aria-expanded":!!p.open||void 0,"aria-controls":p.open?p.contentId:void 0,"data-state":p.open?"open":"closed"},t,{as:r,ref:i,onMouseDown:d(o.onMouseDown,(o=>{0===o.button&&!1===o.ctrlKey&&p.onOpenToggle()})),onKeyDown:d(o.onKeyDown,(o=>{[" ","Enter","ArrowUp","ArrowDown"].includes(o.key)&&(o.preventDefault(),p.onOpenChange(!0))}))}))}));/*#__PURE__*/export const DropdownMenuContent=/*#__PURE__*/c.forwardRef(((e,r)=>{const{onCloseAutoFocus:t,disableOutsidePointerEvents:p=!0,disableOutsideScroll:a=!0,portalled:u=!0,...l}=e,D=w("DropdownMenuContent"),x=c.useRef(null),M=c.useCallback((o=>{-1===o&&D.onOpenChange(!1)}),[D]);return"web"===i.OS?/*#__PURE__*/c.createElement(n.Content,m({id:D.contentId},l,{ref:r,disableOutsidePointerEvents:p,disableOutsideScroll:a,portalled:u,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)"},trapFocus:!0,onCloseAutoFocus:d(t,(o=>{var e;o.preventDefault(),null===(e=D.triggerRef.current)||void 0===e||e.focus()})),onPointerDownOutside:d(e.onPointerDownOutside,(o=>{var e;(null===(e=D.triggerRef.current)||void 0===e?void 0:e.contains(o.target))&&o.preventDefault()}),{checkForDefaultPrevented:!1})})):/*#__PURE__*/c.createElement(s,{animationType:"none",transparent:!0,visible:D.open,onRequestClose:()=>{D.onOpenChange(!D.open)}},/*#__PURE__*/c.createElement(o,m({},l,{ref:x,animateOnMount:!0,enablePanDownToClose:!0,onChange:M})))}));/*#__PURE__*/export const DropdownMenuGroup=r(n.Group,{displayName:"DropdownMenuGroup"});export const DropdownMenuLabel=r(n.Label,{displayName:"DropdownMenuLabel"});export const DropdownMenuItem=r(n.Item,{displayName:"DropdownMenuItem"});export const DropdownMenuCheckboxItem=r(n.CheckboxItem,{displayName:"DropdownMenuCheckboxItem"});export const DropdownMenuRadioGroup=r(n.RadioGroup,{displayName:"DropdownMenuRadioGroup"});export const DropdownMenuRadioItem=r(n.RadioItem,{displayName:"DropdownMenuRadioItem"});export const DropdownMenuItemIndicator=r(n.ItemIndicator,{displayName:"DropdownMenuItemIndicator"});export const DropdownMenuSeparator=r(n.Separator,{displayName:"DropdownMenuSeparator"});export const DropdownMenuArrow=r(n.Arrow,{displayName:"DropdownMenuArrow"});export const Root=DropdownMenu;export const Trigger=DropdownMenuTrigger;export const Content=DropdownMenuContent;export const Group=DropdownMenuGroup;export const Label=DropdownMenuLabel;export const Item=DropdownMenuItem;export const CheckboxItem=DropdownMenuCheckboxItem;export const RadioGroup=DropdownMenuRadioGroup;export const RadioItem=DropdownMenuRadioItem;export const ItemIndicator=DropdownMenuItemIndicator;export const Separator=DropdownMenuSeparator;export const Arrow=DropdownMenuArrow;
2 | //# sourceMappingURL=index.module.js.map
3 |
--------------------------------------------------------------------------------
/packages/radix/dropdown-menu/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@radix-ui/react-dropdown-menu",
3 | "version": "0.0.19",
4 | "license": "MIT",
5 | "source": "src/index.ts",
6 | "main": "dist/index.js",
7 | "module": "dist/index.module.js",
8 | "types": "dist/index.d.ts",
9 | "files": [
10 | "dist",
11 | "README.md"
12 | ],
13 | "sideEffects": false,
14 | "scripts": {
15 | "clean": "rm -rf dist",
16 | "prepublish": "yarn clean",
17 | "version": "yarn version"
18 | },
19 | "dependencies": {
20 | "@babel/runtime": "^7.13.10",
21 | "@gorhom/bottom-sheet": "4.0.0-alpha.3",
22 | "@radix-ui/primitive": "workspace:*",
23 | "@radix-ui/react-compose-refs": "workspace:*",
24 | "@radix-ui/react-context": "workspace:*",
25 | "@radix-ui/react-id": "workspace:*",
26 | "@radix-ui/react-menu": "workspace:*",
27 | "@radix-ui/react-polymorphic": "workspace:*",
28 | "@radix-ui/react-primitive": "workspace:*",
29 | "@radix-ui/react-use-controllable-state": "workspace:*"
30 | },
31 | "peerDependencies": {
32 | "react": "^16.8 || ^17.0",
33 | "react-dom": "^16.8 || ^17.0"
34 | },
35 | "homepage": "https://radix-ui.com/primitives",
36 | "repository": {
37 | "type": "git",
38 | "url": "git+https://github.com/radix-ui/primitives.git"
39 | },
40 | "bugs": {
41 | "url": "https://github.com/radix-ui/primitives/issues"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/packages/radix/dropdown-menu/src/DropdownMenu.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { Platform, View, Modal } from 'react-native';
3 | import { composeEventHandlers } from '@radix-ui/primitive';
4 | import { useComposedRefs } from '@radix-ui/react-compose-refs';
5 | import { createContext } from '@radix-ui/react-context';
6 | import { useControllableState } from '@radix-ui/react-use-controllable-state';
7 | import { extendPrimitive } from '@radix-ui/react-primitive';
8 | import * as MenuPrimitive from '@radix-ui/react-menu';
9 | import { useId } from '@radix-ui/react-id';
10 | import BottomSheet from '@gorhom/bottom-sheet';
11 |
12 | import type * as Polymorphic from '@radix-ui/react-polymorphic';
13 |
14 | /* -------------------------------------------------------------------------------------------------
15 | * DropdownMenu
16 | * -----------------------------------------------------------------------------------------------*/
17 |
18 | const DROPDOWN_MENU_NAME = 'DropdownMenu';
19 |
20 | type DropdownMenuContextValue = {
21 | triggerRef: React.RefObject;
22 | contentId: string;
23 | open: boolean;
24 | onOpenChange(open: boolean): void;
25 | onOpenToggle(): void;
26 | };
27 |
28 | const [DropdownMenuProvider, useDropdownMenuContext] = createContext(
29 | DROPDOWN_MENU_NAME
30 | );
31 |
32 | type DropdownMenuOwnProps = {
33 | open?: boolean;
34 | defaultOpen?: boolean;
35 | onOpenChange?(open: boolean): void;
36 | };
37 |
38 | const DropdownMenu: React.FC = (props) => {
39 | const { children, open: openProp, defaultOpen, onOpenChange } = props;
40 | const triggerRef = React.useRef(null);
41 | const [open = false, setOpen] = useControllableState({
42 | prop: openProp,
43 | defaultProp: defaultOpen,
44 | onChange: onOpenChange,
45 | });
46 |
47 | return (
48 |
49 | setOpen((prevOpen) => !prevOpen), [setOpen])}
55 | >
56 | {children}
57 |
58 |
59 | );
60 | };
61 |
62 | DropdownMenu.displayName = DROPDOWN_MENU_NAME;
63 |
64 | /* -------------------------------------------------------------------------------------------------
65 | * DropdownMenuTrigger
66 | * -----------------------------------------------------------------------------------------------*/
67 |
68 | const TRIGGER_NAME = 'DropdownMenuTrigger';
69 | const TRIGGER_DEFAULT_TAG = Platform.OS === 'web' ? 'button' : View;
70 |
71 | type DropdownMenuTriggerOwnProps = Omit<
72 | Polymorphic.OwnProps,
73 | 'virtualRef'
74 | >;
75 | type DropdownMenuTriggerPrimitive = Polymorphic.ForwardRefComponent<
76 | typeof TRIGGER_DEFAULT_TAG,
77 | DropdownMenuTriggerOwnProps
78 | >;
79 |
80 | const DropdownMenuTrigger = React.forwardRef((props, forwardedRef) => {
81 | const { as = TRIGGER_DEFAULT_TAG, ...triggerProps } = props;
82 | const context = useDropdownMenuContext(TRIGGER_NAME);
83 | const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
84 |
85 | return (
86 | {
96 | // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
97 | // but not when the control key is pressed (avoiding MacOS right click)
98 | if (event.button === 0 && event.ctrlKey === false) {
99 | context.onOpenToggle();
100 | }
101 | })}
102 | onKeyDown={composeEventHandlers(props.onKeyDown, (event: React.KeyboardEvent) => {
103 | if ([' ', 'Enter', 'ArrowUp', 'ArrowDown'].includes(event.key)) {
104 | event.preventDefault();
105 | context.onOpenChange(true);
106 | }
107 | })}
108 | />
109 | );
110 | }) as DropdownMenuTriggerPrimitive;
111 |
112 | DropdownMenuTrigger.displayName = TRIGGER_NAME;
113 |
114 | /* -------------------------------------------------------------------------------------------------
115 | * DropdownMenuContent
116 | * -----------------------------------------------------------------------------------------------*/
117 |
118 | const CONTENT_NAME = 'DropdownMenuContent';
119 |
120 | type DropdownMenuContentOwnProps = Omit<
121 | Polymorphic.OwnProps,
122 | 'trapFocus' | 'onOpenAutoFocus'
123 | >;
124 |
125 | type DropdownMenuContentPrimitive = Polymorphic.ForwardRefComponent<
126 | Polymorphic.IntrinsicElement,
127 | DropdownMenuContentOwnProps
128 | >;
129 |
130 | const DropdownMenuContent = React.forwardRef((props, forwardedRef) => {
131 | const {
132 | onCloseAutoFocus,
133 | disableOutsidePointerEvents = true,
134 | disableOutsideScroll = true,
135 | portalled = true,
136 | ...contentProps
137 | } = props;
138 | const context = useDropdownMenuContext(CONTENT_NAME);
139 | const bottomSheetRef = React.useRef(null);
140 | const handleSheetChanges = React.useCallback(
141 | (index: number) => {
142 | if (index === -1) {
143 | context.onOpenChange(false);
144 | }
145 | },
146 | [context]
147 | );
148 |
149 | if (Platform.OS === 'web') {
150 | return (
151 | {
165 | event.preventDefault();
166 | context.triggerRef.current?.focus();
167 | })}
168 | onPointerDownOutside={composeEventHandlers(
169 | props.onPointerDownOutside,
170 | (event) => {
171 | const targetIsTrigger = context.triggerRef.current?.contains(
172 | event.target as HTMLElement
173 | );
174 | // prevent dismissing when clicking the trigger
175 | // as it's already setup to close, otherwise it would close and immediately open.
176 | if (targetIsTrigger) event.preventDefault();
177 | },
178 | { checkForDefaultPrevented: false }
179 | )}
180 | />
181 | );
182 | }
183 |
184 | return (
185 | {
190 | context.onOpenChange(!context.open);
191 | }}
192 | >
193 |
200 |
201 | );
202 | }) as DropdownMenuContentPrimitive;
203 |
204 | DropdownMenuContent.displayName = CONTENT_NAME;
205 |
206 | /* ---------------------------------------------------------------------------------------------- */
207 |
208 | const DropdownMenuGroup = extendPrimitive(MenuPrimitive.Group, {
209 | displayName: 'DropdownMenuGroup',
210 | });
211 | const DropdownMenuLabel = extendPrimitive(MenuPrimitive.Label, {
212 | displayName: 'DropdownMenuLabel',
213 | });
214 | const DropdownMenuItem = extendPrimitive(MenuPrimitive.Item, { displayName: 'DropdownMenuItem' });
215 | const DropdownMenuCheckboxItem = extendPrimitive(MenuPrimitive.CheckboxItem, {
216 | displayName: 'DropdownMenuCheckboxItem',
217 | });
218 | const DropdownMenuRadioGroup = extendPrimitive(MenuPrimitive.RadioGroup, {
219 | displayName: 'DropdownMenuRadioGroup',
220 | });
221 | const DropdownMenuRadioItem = extendPrimitive(MenuPrimitive.RadioItem, {
222 | displayName: 'DropdownMenuRadioItem',
223 | });
224 | const DropdownMenuItemIndicator = extendPrimitive(MenuPrimitive.ItemIndicator, {
225 | displayName: 'DropdownMenuItemIndicator',
226 | });
227 | const DropdownMenuSeparator = extendPrimitive(MenuPrimitive.Separator, {
228 | displayName: 'DropdownMenuSeparator',
229 | });
230 | const DropdownMenuArrow = extendPrimitive(MenuPrimitive.Arrow, {
231 | displayName: 'DropdownMenuArrow',
232 | });
233 |
234 | /* -----------------------------------------------------------------------------------------------*/
235 |
236 | const Root = DropdownMenu;
237 | const Trigger = DropdownMenuTrigger;
238 | const Content = DropdownMenuContent;
239 | const Group = DropdownMenuGroup;
240 | const Label = DropdownMenuLabel;
241 | const Item = DropdownMenuItem;
242 | const CheckboxItem = DropdownMenuCheckboxItem;
243 | const RadioGroup = DropdownMenuRadioGroup;
244 | const RadioItem = DropdownMenuRadioItem;
245 | const ItemIndicator = DropdownMenuItemIndicator;
246 | const Separator = DropdownMenuSeparator;
247 | const Arrow = DropdownMenuArrow;
248 |
249 | export {
250 | DropdownMenu,
251 | DropdownMenuTrigger,
252 | DropdownMenuContent,
253 | DropdownMenuGroup,
254 | DropdownMenuLabel,
255 | DropdownMenuItem,
256 | DropdownMenuCheckboxItem,
257 | DropdownMenuRadioGroup,
258 | DropdownMenuRadioItem,
259 | DropdownMenuItemIndicator,
260 | DropdownMenuSeparator,
261 | DropdownMenuArrow,
262 | //
263 | Root,
264 | Trigger,
265 | Content,
266 | Group,
267 | Label,
268 | Item,
269 | CheckboxItem,
270 | RadioGroup,
271 | RadioItem,
272 | ItemIndicator,
273 | Separator,
274 | Arrow,
275 | };
276 | export type { DropdownMenuTriggerPrimitive, DropdownMenuContentPrimitive };
277 |
--------------------------------------------------------------------------------
/packages/radix/dropdown-menu/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './DropdownMenu';
2 |
--------------------------------------------------------------------------------
/packages/radix/menu/README.md:
--------------------------------------------------------------------------------
1 | # `react-menu`
2 |
3 | ## Installation
4 |
5 | ```sh
6 | $ yarn add @radix-ui/react-menu
7 | # or
8 | $ npm install @radix-ui/react-menu
9 | ```
10 |
11 | ## Usage
12 |
13 | This is an internal utility, not intended for public usage.
14 |
--------------------------------------------------------------------------------
/packages/radix/menu/dist/index.d.ts:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
3 | import { FocusScope } from "@radix-ui/react-focus-scope";
4 | import { Primitive } from "@radix-ui/react-primitive";
5 | import * as PopperPrimitive from "@radix-ui/react-popper";
6 | import { RovingFocusGroup, RovingFocusItem } from "@radix-ui/react-roving-focus";
7 | import * as Polymorphic from "@radix-ui/react-polymorphic";
8 | type MenuOwnProps = {
9 | open?: boolean;
10 | onOpenChange?(open: boolean): void;
11 | };
12 | export const Menu: React.FC;
13 | type MenuContentOwnProps = Polymorphic.Merge, {
14 | /**
15 | * Used to force mounting when more control is needed. Useful when
16 | * controlling animation with React animation libraries.
17 | */
18 | forceMount?: true;
19 | }>;
20 | export type MenuContentPrimitive = Polymorphic.ForwardRefComponent, MenuContentOwnProps>;
21 | export const MenuContent: MenuContentPrimitive;
22 | type FocusScopeOwnProps = Polymorphic.OwnProps;
23 | type DismissableLayerOwnProps = Polymorphic.OwnProps;
24 | type RovingFocusGroupOwnProps = Polymorphic.OwnProps;
25 | type MenuContentImplOwnProps = Polymorphic.Merge, Omit & {
26 | /**
27 | * Whether focus should be trapped within the `MenuContent`
28 | * (default: false)
29 | */
30 | trapFocus?: FocusScopeOwnProps['trapped'];
31 | /**
32 | * Event handler called when auto-focusing on open.
33 | * Can be prevented.
34 | */
35 | onOpenAutoFocus?: FocusScopeOwnProps['onMountAutoFocus'];
36 | /**
37 | * Event handler called when auto-focusing on close.
38 | * Can be prevented.
39 | */
40 | onCloseAutoFocus?: FocusScopeOwnProps['onUnmountAutoFocus'];
41 | /**
42 | * Whether scrolling outside the `MenuContent` should be prevented
43 | * (default: `false`)
44 | */
45 | disableOutsideScroll?: boolean;
46 | /**
47 | * The direction of navigation between menu items.
48 | * @defaultValue ltr
49 | */
50 | dir?: RovingFocusGroupOwnProps['dir'];
51 | /**
52 | * Whether keyboard navigation should loop around
53 | * @defaultValue false
54 | */
55 | loop?: RovingFocusGroupOwnProps['loop'];
56 | /**
57 | * Whether the `MenuContent` should render in a `Portal`
58 | * (default: `true`)
59 | */
60 | portalled?: boolean;
61 | }>;
62 | type MenuContentImplPrimitive = Polymorphic.ForwardRefComponent, MenuContentImplOwnProps>;
63 | declare const MenuContentImpl: MenuContentImplPrimitive;
64 | declare const ITEM_DEFAULT_TAG = "div";
65 | type MenuItemOwnProps = Polymorphic.Merge, 'focusable' | 'active'>, {
66 | disabled?: boolean;
67 | textValue?: string;
68 | onSelect?: (event: Event) => void;
69 | }>;
70 | export type MenuItemPrimitive = Polymorphic.ForwardRefComponent;
71 | export const MenuItem: MenuItemPrimitive;
72 | type MenuCheckboxItemOwnProps = Polymorphic.Merge, {
73 | checked?: boolean;
74 | onCheckedChange?: (checked: boolean) => void;
75 | }>;
76 | export type MenuCheckboxItemPrimitive = Polymorphic.ForwardRefComponent, MenuCheckboxItemOwnProps>;
77 | export const MenuCheckboxItem: MenuCheckboxItemPrimitive;
78 | type MenuRadioGroupOwnProps = Polymorphic.Merge, {
79 | value?: string;
80 | onValueChange?: (value: string) => void;
81 | }>;
82 | export type MenuRadioGroupPrimitive = Polymorphic.ForwardRefComponent, MenuRadioGroupOwnProps>;
83 | export const MenuRadioGroup: MenuRadioGroupPrimitive;
84 | type MenuRadioItemOwnProps = Polymorphic.Merge, {
85 | value: string;
86 | }>;
87 | export type MenuRadioItemPrimitive = Polymorphic.ForwardRefComponent, MenuRadioItemOwnProps>;
88 | export const MenuRadioItem: MenuRadioItemPrimitive;
89 | declare const ITEM_INDICATOR_DEFAULT_TAG = "span";
90 | type MenuItemIndicatorOwnProps = Polymorphic.Merge, {
91 | /**
92 | * Used to force mounting when more control is needed. Useful when
93 | * controlling animation with React animation libraries.
94 | */
95 | forceMount?: true;
96 | }>;
97 | export type MenuItemIndicatorPrimitive = Polymorphic.ForwardRefComponent;
98 | export const MenuItemIndicator: MenuItemIndicatorPrimitive;
99 | export const MenuAnchor: import("@radix-ui/react-primitive").ExtendedPrimitive;
100 | export const MenuGroup: import("@radix-ui/react-primitive").ExtendedPrimitive;
101 | export const MenuLabel: import("@radix-ui/react-primitive").ExtendedPrimitive;
102 | export const MenuSeparator: import("@radix-ui/react-primitive").ExtendedPrimitive;
103 | export const MenuArrow: import("@radix-ui/react-primitive").ExtendedPrimitive;
104 | export const Root: React.FC;
105 | export const Anchor: import("@radix-ui/react-primitive").ExtendedPrimitive;
106 | export const Content: MenuContentPrimitive;
107 | export const Group: import("@radix-ui/react-primitive").ExtendedPrimitive;
108 | export const Label: import("@radix-ui/react-primitive").ExtendedPrimitive;
109 | export const Item: MenuItemPrimitive;
110 | export const CheckboxItem: MenuCheckboxItemPrimitive;
111 | export const RadioGroup: MenuRadioGroupPrimitive;
112 | export const RadioItem: MenuRadioItemPrimitive;
113 | export const ItemIndicator: MenuItemIndicatorPrimitive;
114 | export const Separator: import("@radix-ui/react-primitive").ExtendedPrimitive;
115 | export const Arrow: import("@radix-ui/react-primitive").ExtendedPrimitive;
116 |
117 | //# sourceMappingURL=index.d.ts.map
118 |
--------------------------------------------------------------------------------
/packages/radix/menu/dist/index.d.ts.map:
--------------------------------------------------------------------------------
1 | {"mappings":"A;A;A;A;A;A;A;ACuCA,oBAAoB;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CACpC,CAAC;AAEF,OAAA,MAAM,MAAM,MAAM,EAAE,CAAC,YAAY,CAUhC,CAAC;AAqBF,2BAA2B,YAAY,KAAK,CAC1C,YAAY,QAAQ,CAAC,sBAAsB,CAAC,EAC5C;IACE;A;A;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB,CACF,CAAC;AAEF,mCAA4B,YAAY,mBAAmB,CACzD,YAAY,gBAAgB,CAAC,sBAAsB,CAAC,EACpD,mBAAmB,CACpB,CAAC;AAEF,OAAA,MAAM,iCAcoB,CAAC;AAE3B,0BAA0B,YAAY,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AAClE,gCAAgC,YAAY,QAAQ,CAAC,uBAAuB,CAAC,CAAC;AAC9E,gCAAgC,YAAY,QAAQ,CAAC,uBAAuB,CAAC,CAAC;AAE9E,+BAA+B,YAAY,KAAK,CAC9C,YAAY,QAAQ,CAAC,OAAO,gBAAgB,OAAO,CAAC,EACpD,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC,GAAG;IAC5C;A;A;OAGG;IACH,SAAS,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAE1C;A;A;OAGG;IACH,eAAe,CAAC,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IAEzD;A;A;OAGG;IACH,gBAAgB,CAAC,EAAE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;IAE5D;A;A;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;A;A;OAGG;IACH,GAAG,CAAC,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAEtC;A;A;OAGG;IACH,IAAI,CAAC,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAExC;A;A;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CACF,CAAC;AAEF,gCAAgC,YAAY,mBAAmB,CAC7D,YAAY,gBAAgB,CAAC,OAAO,gBAAgB,OAAO,CAAC,EAC5D,uBAAuB,CACxB,CAAC;AAEF,QAAA,MAAM,yCA8HwB,CAAC;AAS/B,QAAA,MAAM,wBAAwB,CAAC;AAG/B,wBAAwB,YAAY,KAAK,CACvC,IAAI,CAAC,YAAY,QAAQ,CAAC,sBAAsB,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC,EAC1E;IACE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnC,CACF,CAAC;AAEF,gCAAyB,YAAY,mBAAmB,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,CAAC;AAEpG,OAAA,MAAM,2BAmFiB,CAAC;AAsBxB,gCAAgC,YAAY,KAAK,CAC/C,YAAY,QAAQ,CAAC,eAAe,CAAC,EACrC;IACE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C,CACF,CAAC;AAEF,wCAAiC,YAAY,mBAAmB,CAC9D,YAAY,gBAAgB,CAAC,eAAe,CAAC,EAC7C,wBAAwB,CACzB,CAAC;AAEF,OAAA,MAAM,2CAkByB,CAAC;AAYhC,8BAA8B,YAAY,KAAK,CAC7C,YAAY,QAAQ,CAAC,gBAAgB,CAAC,EACtC;IACE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CACF,CAAC;AAEF,sCAA+B,YAAY,mBAAmB,CAC5D,YAAY,gBAAgB,CAAC,gBAAgB,CAAC,EAC9C,sBAAsB,CACvB,CAAC;AAEF,OAAA,MAAM,uCAYuB,CAAC;AAU9B,6BAA6B,YAAY,KAAK,CAC5C,YAAY,QAAQ,CAAC,eAAe,CAAC,EACrC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAClB,CAAC;AACF,qCAA8B,YAAY,mBAAmB,CAC3D,YAAY,gBAAgB,CAAC,eAAe,CAAC,EAC7C,qBAAqB,CACtB,CAAC;AAEF,OAAA,MAAM,qCAoBsB,CAAC;AAS7B,QAAA,MAAM,mCAAmC,CAAC;AAI1C,iCAAiC,YAAY,KAAK,CAChD,YAAY,QAAQ,CAAC,gBAAgB,CAAC,EACtC;IACE;A;A;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB,CACF,CAAC;AAEF,yCAAkC,YAAY,mBAAmB,CAC/D,iCAAiC,EACjC,yBAAyB,CAC1B,CAAC;AAEF,OAAA,MAAM,6CAa0B,CAAC;AAMjC,OAAA,MAAM,+GAAmF,CAAC;AAC1F,OAAA,MAAM,+HAGJ,CAAC;AACH,OAAA,MAAM,+HAAoE,CAAC;AAC3E,OAAA,MAAM,mIAGJ,CAAC;AACH,OAAA,MAAM,6GAAgF,CAAC;AAsBvF,OAAA,MAAM,4BAAW,CAAC;AAClB,OAAA,MAAM,2GAAmB,CAAC;AAC1B,OAAA,MAAM,6BAAqB,CAAC;AAC5B,OAAA,MAAM,2HAAiB,CAAC;AACxB,OAAA,MAAM,2HAAiB,CAAC;AACxB,OAAA,MAAM,uBAAwD,CAAC;AAC/D,OAAA,MAAM,uCAA+B,CAAC;AACtC,OAAA,MAAM,mCAA2B,CAAC;AAClC,OAAA,MAAM,iCAAyB,CAAC;AAChC,OAAA,MAAM,yCAAiC,CAAC;AACxC,OAAA,MAAM,+HAAyB,CAAC;AAChC,OAAA,MAAM,yGAAiB,CAAC","sources":["./packages/react/menu/src/packages/react/menu/src/useMenuTypeahead.tsx","./packages/react/menu/src/packages/react/menu/src/Menu.tsx","./packages/react/menu/src/packages/react/menu/src/index.ts"],"sourcesContent":[null,null,null],"names":[],"version":3,"file":"index.d.ts.map"}
--------------------------------------------------------------------------------
/packages/radix/menu/dist/index.js:
--------------------------------------------------------------------------------
1 | var e,t=require("@radix-ui/react-focus-guards").useFocusGuards,r=require("@radix-ui/react-use-callback-ref").useCallbackRef,n=require("@radix-ui/react-slot").Slot,o=require("@radix-ui/react-roving-focus"),a=o.RovingFocusGroup,u=o.RovingFocusItem,c=require("@radix-ui/react-portal").Portal,s=D({},require("@radix-ui/react-popper")),i=require("@radix-ui/react-primitive"),l=i.Primitive,d=i.extendPrimitive,p=require("@radix-ui/react-presence").Presence,m=require("@radix-ui/react-focus-scope").FocusScope,f=require("@radix-ui/react-dismissable-layer").DismissableLayer,v=require("@radix-ui/react-context").createContext,x=require("@radix-ui/react-compose-refs").useComposedRefs,h=require("@radix-ui/react-collection").createCollection,E=require("@radix-ui/primitive").composeEventHandlers,y=require("aria-hidden").hideOthers,M=require("react-remove-scroll").RemoveScroll,b=require("react-native"),w=b.Platform,C=b.View,g=D({},require("react")),k=(e=require("@babel/runtime/helpers/extends"))&&e.__esModule?e.default:e;function D(e,t){return Object.keys(t).forEach((function(r){"default"!==r&&"__esModule"!==r&&Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),e}function P(){const e=g.useRef(0),t=g.useRef(""),r=g.useCallback((n=>{t.current=n,window.clearTimeout(e.current),e.current=window.setTimeout((()=>r("")),1e3)}),[]);return{onKeyDownCapture:e=>{if(1===e.key.length&&!(e.ctrlKey||e.altKey||e.metaKey)){const n=e.currentTarget;r(t.current+e.key)," "!==e.key||t.current.startsWith(" ")||e.stopPropagation();const o=document.activeElement,a=o?R(o):void 0,u=function(e,t,r){const n=t.length>1&&Array.from(t).every((e=>e===t[0]))?t[0]:t,o=r?e.indexOf(r):-1;let a=(u=e,c=Math.max(o,0),u.map(((e,t)=>u[(c+t)%u.length])));var u,c;1===n.length&&(a=a.filter((e=>e!==r)));const s=a.find((e=>e.toLowerCase().startsWith(n.toLowerCase())));return s!==r?s:void 0}(Array.from(n.querySelectorAll(`[${S}]`)).map(R),t.current,a),c=n.querySelector(`[${S}="${u}"]`);c&&setTimeout((()=>c.focus()))}}}}const R=e=>{var t;return null!==(t=e.getAttribute(S))&&void 0!==t?t:""},S="data-radix-menu-typeahead-item";const q=["ArrowUp","PageDown","End"],I=["ArrowDown","PageUp","Home",...q],[O,A]=v("Menu"),F=e=>{const{open:t=!1,children:n,onOpenChange:o}=e,a=r(o);/*#__PURE__*/return g.createElement(s.Root,null,/*#__PURE__*/g.createElement(O,{open:t,onOpenChange:a},n))};exports.Menu=F;const[K,L,G]=h(),[T,V]=v("MenuContent"),N=/*#__PURE__*/g.forwardRef(((e,t)=>{const{forceMount:r,...n}=e,o=A("MenuContent");/*#__PURE__*/return g.createElement(p,{present:r||o.open},/*#__PURE__*/g.createElement(K,null,/*#__PURE__*/g.createElement(U,k({"data-state":(a=o.open,a?"open":"closed")},n,{ref:t}))));var a}));exports.MenuContent=N;const U=/*#__PURE__*/g.forwardRef(((e,r)=>{const{dir:o="ltr",loop:u=!1,trapFocus:i,onOpenAutoFocus:l,onCloseAutoFocus:d,disableOutsidePointerEvents:p,onEscapeKeyDown:v,onPointerDownOutside:h,onFocusOutside:b,onInteractOutside:w,disableOutsideScroll:C,portalled:D,...R}=e,S=A("MenuContent"),O=P(),{getItems:F}=G(),[K,L]=g.useState(null),[V,N]=g.useState(!1),U=g.useRef(null),_=x(r,U),$=D?c:g.Fragment,j=C?M:g.Fragment;return t(),g.useEffect((()=>{const e=U.current;if(e)return y(e)}),[]),/*#__PURE__*/g.createElement($,null,/*#__PURE__*/g.createElement(j,null,/*#__PURE__*/g.createElement(T,{onItemLeave:g.useCallback((()=>{var e;null===(e=U.current)||void 0===e||e.focus(),L(null)}),[])},/*#__PURE__*/g.createElement(m,{as:n,trapped:i&&S.open,onMountAutoFocus:l,onUnmountAutoFocus:e=>{V?e.preventDefault():null==d||d(e)}},/*#__PURE__*/g.createElement(f,{as:n,disableOutsidePointerEvents:p,onEscapeKeyDown:E(v,(()=>{N(!1)})),onPointerDownOutside:E(h,(e=>{const t=e.detail.originalEvent,r=0===t.button&&!1===t.ctrlKey;N(!p&&r)}),{checkForDefaultPrevented:!1}),onFocusOutside:E(b,(e=>{i&&e.preventDefault()}),{checkForDefaultPrevented:!1}),onInteractOutside:w,onDismiss:()=>S.onOpenChange(!1)},/*#__PURE__*/g.createElement(a,{as:n,dir:o,orientation:"vertical",loop:u,currentTabStopId:K,onCurrentTabStopIdChange:L,onEntryFocus:e=>e.preventDefault()},/*#__PURE__*/g.createElement(s.Content,k({role:"menu"},R,{ref:_,style:{outline:"none",...R.style},onKeyDownCapture:E(R.onKeyDownCapture,O.onKeyDownCapture),onKeyDown:E(R.onKeyDown,(e=>{const t=U.current;if(e.target!==t)return;if(!I.includes(e.key))return;e.preventDefault();const r=F().filter((e=>!e.disabled)).map((e=>e.ref.current));q.includes(e.key)&&r.reverse(),function(e){const t=document.activeElement;for(const r of e){if(r===t)return;if(r.focus(),document.activeElement!==t)return}}(r)}))}))))))))})),_="div",$=/*#__PURE__*/g.forwardRef(((e,t)=>{const{as:r=_,disabled:n=!1,textValue:o,onSelect:a,...c}=e,s=g.useRef(null),i=x(t,s),l=A("MenuItem"),d=V("MenuItem"),[p,m]=g.useState("");g.useEffect((()=>{const e=s.current;var t;e&&m((null!==(t=e.textContent)&&void 0!==t?t:"").trim())}),[c.children]);const f=function({textValue:e,disabled:t}){return{[S]:t?void 0:e}}({textValue:null!=o?o:p,disabled:n}),v=()=>{const e=s.current;if(!n&&e){var t;const r=new Event("menu.itemSelect",{bubbles:!0,cancelable:!0});if(e.dispatchEvent(r),r.defaultPrevented)return;null===(t=l.onOpenChange)||void 0===t||t.call(l,!1)}};return g.useEffect((()=>{const e=s.current;if(e){const t=e=>null==a?void 0:a(e);return e.addEventListener("menu.itemSelect",t),()=>e.removeEventListener("menu.itemSelect",t)}}),[a]),/*#__PURE__*/g.createElement(L,{disabled:n},/*#__PURE__*/g.createElement(u,k({role:"menuitem","aria-disabled":n||void 0,focusable:!n},c,f,{as:r,ref:i,"data-disabled":n?"":void 0,onKeyDown:E(e.onKeyDown,(e=>{n||"Enter"!==e.key&&" "!==e.key||(" "===e.key&&e.preventDefault(),v())})),onMouseUp:E(e.onMouseUp,v),onMouseMove:E(e.onMouseMove,(e=>{if(n)d.onItemLeave();else{e.currentTarget.focus()}})),onMouseLeave:E(e.onMouseLeave,(()=>d.onItemLeave()))})))}));/*#__PURE__*/exports.MenuItem=$;const j=/*#__PURE__*/g.forwardRef(((e,t)=>{const{...r}=e;/*#__PURE__*/return g.createElement(C,k({},r,{ref:t}))})),H=/*#__PURE__*/g.forwardRef(((e,t)=>{const{checked:r=!1,onCheckedChange:n,...o}=e;/*#__PURE__*/return g.createElement(Q.Provider,{value:r},/*#__PURE__*/g.createElement($,k({role:"menuitemcheckbox","aria-checked":r},o,{ref:t,"data-state":ne(r),onSelect:E(o.onSelect,(()=>null==n?void 0:n(!r)),{checkForDefaultPrevented:!1})})))}));/*#__PURE__*/exports.MenuCheckboxItem=H;const W=/*#__PURE__*/g.createContext({}),z=/*#__PURE__*/g.forwardRef(((e,t)=>{const{value:n,onValueChange:o,...a}=e,u=r(o),c=g.useMemo((()=>({value:n,onValueChange:u})),[n,u]);/*#__PURE__*/return g.createElement(W.Provider,{value:c},/*#__PURE__*/g.createElement(Z,k({},a,{ref:t})))}));exports.MenuRadioGroup=z;const B=/*#__PURE__*/g.forwardRef(((e,t)=>{const{value:r,...n}=e,o=g.useContext(W),a=r===o.value;/*#__PURE__*/return g.createElement(Q.Provider,{value:a},/*#__PURE__*/g.createElement($,k({role:"menuitemradio","aria-checked":a},n,{ref:t,"data-state":ne(a),onSelect:E(n.onSelect,(()=>{var e;return null===(e=o.onValueChange)||void 0===e?void 0:e.call(o,r)}),{checkForDefaultPrevented:!1})})))}));exports.MenuRadioItem=B;const J="span",Q=/*#__PURE__*/g.createContext(!1),X=/*#__PURE__*/g.forwardRef(((e,t)=>{const{as:r=J,forceMount:n,...o}=e,a=g.useContext(Q);/*#__PURE__*/return g.createElement(p,{present:n||a},/*#__PURE__*/g.createElement(l,k({},o,{as:r,ref:t,"data-state":ne(a)})))}));exports.MenuItemIndicator=X;const Y=d(s.Anchor,{displayName:"MenuAnchor"});exports.MenuAnchor=Y;const Z=d(l,{defaultProps:{role:"group"},displayName:"MenuGroup"});exports.MenuGroup=Z;const ee=d(l,{displayName:"MenuLabel"});exports.MenuLabel=ee;const te=d(l,{defaultProps:{role:"separator","aria-orientation":"horizontal"},displayName:"MenuSeparator "});exports.MenuSeparator=te;const re=d(s.Arrow,{displayName:"MenuArrow"});function ne(e){return e?"checked":"unchecked"}exports.MenuArrow=re;const oe=F;exports.Root=oe;const ae=Y;exports.Anchor=ae;const ue=N;exports.Content=ue;const ce=Z;exports.Group=ce;const se=ee;exports.Label=se;const ie="web"===w.OS?$:j;exports.Item=ie;const le=H;exports.CheckboxItem=le;const de=z;exports.RadioGroup=de;const pe=B;exports.RadioItem=pe;const me=X;exports.ItemIndicator=me;const fe=te;exports.Separator=fe;const ve=re;exports.Arrow=ve;
2 | //# sourceMappingURL=index.js.map
3 |
--------------------------------------------------------------------------------
/packages/radix/menu/dist/index.module.js:
--------------------------------------------------------------------------------
1 | import{useFocusGuards as e}from"@radix-ui/react-focus-guards";import{useCallbackRef as t}from"@radix-ui/react-use-callback-ref";import{Slot as r}from"@radix-ui/react-slot";import{RovingFocusGroup as n,RovingFocusItem as o}from"@radix-ui/react-roving-focus";import{Portal as a}from"@radix-ui/react-portal";import*as u from"@radix-ui/react-popper";import{Primitive as c,extendPrimitive as i}from"@radix-ui/react-primitive";import{Presence as s}from"@radix-ui/react-presence";import{FocusScope as l}from"@radix-ui/react-focus-scope";import{DismissableLayer as m}from"@radix-ui/react-dismissable-layer";import{createContext as d}from"@radix-ui/react-context";import{useComposedRefs as p}from"@radix-ui/react-compose-refs";import{createCollection as f}from"@radix-ui/react-collection";import{composeEventHandlers as v}from"@radix-ui/primitive";import{hideOthers as x}from"aria-hidden";import{RemoveScroll as M}from"react-remove-scroll";import{Platform as h,View as E}from"react-native";import*as w from"react";import y from"@babel/runtime/helpers/esm/extends";function C(){const e=w.useRef(0),t=w.useRef(""),r=w.useCallback((n=>{t.current=n,window.clearTimeout(e.current),e.current=window.setTimeout((()=>r("")),1e3)}),[]);return{onKeyDownCapture:e=>{if(1===e.key.length&&!(e.ctrlKey||e.altKey||e.metaKey)){const n=e.currentTarget;r(t.current+e.key)," "!==e.key||t.current.startsWith(" ")||e.stopPropagation();const o=document.activeElement,a=o?b(o):void 0,u=function(e,t,r){const n=t.length>1&&Array.from(t).every((e=>e===t[0]))?t[0]:t,o=r?e.indexOf(r):-1;let a=(u=e,c=Math.max(o,0),u.map(((e,t)=>u[(c+t)%u.length])));var u,c;1===n.length&&(a=a.filter((e=>e!==r)));const i=a.find((e=>e.toLowerCase().startsWith(n.toLowerCase())));return i!==r?i:void 0}(Array.from(n.querySelectorAll(`[${g}]`)).map(b),t.current,a),c=n.querySelector(`[${g}="${u}"]`);c&&setTimeout((()=>c.focus()))}}}}const b=e=>{var t;return null!==(t=e.getAttribute(g))&&void 0!==t?t:""},g="data-radix-menu-typeahead-item";const I=["ArrowUp","PageDown","End"],k=["ArrowDown","PageUp","Home",...I],[D,S]=d("Menu");export const Menu=e=>{const{open:r=!1,children:n,onOpenChange:o}=e,a=t(o);/*#__PURE__*/return w.createElement(u.Root,null,/*#__PURE__*/w.createElement(D,{open:r,onOpenChange:a},n))};/*#__PURE__*/const[A,R,P]=f(),[O,F]=d("MenuContent");export const MenuContent=/*#__PURE__*/w.forwardRef(((e,t)=>{const{forceMount:r,...n}=e,o=S("MenuContent");/*#__PURE__*/return w.createElement(s,{present:r||o.open},/*#__PURE__*/w.createElement(A,null,/*#__PURE__*/w.createElement(K,y({"data-state":(a=o.open,a?"open":"closed")},n,{ref:t}))));var a}));const K=/*#__PURE__*/w.forwardRef(((t,o)=>{const{dir:c="ltr",loop:i=!1,trapFocus:s,onOpenAutoFocus:d,onCloseAutoFocus:f,disableOutsidePointerEvents:h,onEscapeKeyDown:E,onPointerDownOutside:b,onFocusOutside:g,onInteractOutside:D,disableOutsideScroll:A,portalled:R,...F}=t,K=S("MenuContent"),L=C(),{getItems:G}=P(),[T,V]=w.useState(null),[N,U]=w.useState(!1),$=w.useRef(null),q=p(o,$),W=R?a:w.Fragment,z=A?M:w.Fragment;return e(),w.useEffect((()=>{const e=$.current;if(e)return x(e)}),[]),/*#__PURE__*/w.createElement(W,null,/*#__PURE__*/w.createElement(z,null,/*#__PURE__*/w.createElement(O,{onItemLeave:w.useCallback((()=>{var e;null===(e=$.current)||void 0===e||e.focus(),V(null)}),[])},/*#__PURE__*/w.createElement(l,{as:r,trapped:s&&K.open,onMountAutoFocus:d,onUnmountAutoFocus:e=>{N?e.preventDefault():null==f||f(e)}},/*#__PURE__*/w.createElement(m,{as:r,disableOutsidePointerEvents:h,onEscapeKeyDown:v(E,(()=>{U(!1)})),onPointerDownOutside:v(b,(e=>{const t=e.detail.originalEvent,r=0===t.button&&!1===t.ctrlKey;U(!h&&r)}),{checkForDefaultPrevented:!1}),onFocusOutside:v(g,(e=>{s&&e.preventDefault()}),{checkForDefaultPrevented:!1}),onInteractOutside:D,onDismiss:()=>K.onOpenChange(!1)},/*#__PURE__*/w.createElement(n,{as:r,dir:c,orientation:"vertical",loop:i,currentTabStopId:T,onCurrentTabStopIdChange:V,onEntryFocus:e=>e.preventDefault()},/*#__PURE__*/w.createElement(u.Content,y({role:"menu"},F,{ref:q,style:{outline:"none",...F.style},onKeyDownCapture:v(F.onKeyDownCapture,L.onKeyDownCapture),onKeyDown:v(F.onKeyDown,(e=>{const t=$.current;if(e.target!==t)return;if(!k.includes(e.key))return;e.preventDefault();const r=G().filter((e=>!e.disabled)).map((e=>e.ref.current));I.includes(e.key)&&r.reverse(),function(e){const t=document.activeElement;for(const r of e){if(r===t)return;if(r.focus(),document.activeElement!==t)return}}(r)}))}))))))))})),L="div";/*#__PURE__*/export const MenuItem=/*#__PURE__*/w.forwardRef(((e,t)=>{const{as:r=L,disabled:n=!1,textValue:a,onSelect:u,...c}=e,i=w.useRef(null),s=p(t,i),l=S("MenuItem"),m=F("MenuItem"),[d,f]=w.useState("");w.useEffect((()=>{const e=i.current;var t;e&&f((null!==(t=e.textContent)&&void 0!==t?t:"").trim())}),[c.children]);const x=function({textValue:e,disabled:t}){return{[g]:t?void 0:e}}({textValue:null!=a?a:d,disabled:n}),M=()=>{const e=i.current;if(!n&&e){var t;const r=new Event("menu.itemSelect",{bubbles:!0,cancelable:!0});if(e.dispatchEvent(r),r.defaultPrevented)return;null===(t=l.onOpenChange)||void 0===t||t.call(l,!1)}};return w.useEffect((()=>{const e=i.current;if(e){const t=e=>null==u?void 0:u(e);return e.addEventListener("menu.itemSelect",t),()=>e.removeEventListener("menu.itemSelect",t)}}),[u]),/*#__PURE__*/w.createElement(R,{disabled:n},/*#__PURE__*/w.createElement(o,y({role:"menuitem","aria-disabled":n||void 0,focusable:!n},c,x,{as:r,ref:s,"data-disabled":n?"":void 0,onKeyDown:v(e.onKeyDown,(e=>{n||"Enter"!==e.key&&" "!==e.key||(" "===e.key&&e.preventDefault(),M())})),onMouseUp:v(e.onMouseUp,M),onMouseMove:v(e.onMouseMove,(e=>{if(n)m.onItemLeave();else{e.currentTarget.focus()}})),onMouseLeave:v(e.onMouseLeave,(()=>m.onItemLeave()))})))}));/*#__PURE__*/const G=/*#__PURE__*/w.forwardRef(((e,t)=>{const{...r}=e;/*#__PURE__*/return w.createElement(E,y({},r,{ref:t}))}));/*#__PURE__*/export const MenuCheckboxItem=/*#__PURE__*/w.forwardRef(((e,t)=>{const{checked:r=!1,onCheckedChange:n,...o}=e;/*#__PURE__*/return w.createElement(N.Provider,{value:r},/*#__PURE__*/w.createElement(MenuItem,y({role:"menuitemcheckbox","aria-checked":r},o,{ref:t,"data-state":U(r),onSelect:v(o.onSelect,(()=>null==n?void 0:n(!r)),{checkForDefaultPrevented:!1})})))}));/*#__PURE__*/const T=/*#__PURE__*/w.createContext({});export const MenuRadioGroup=/*#__PURE__*/w.forwardRef(((e,r)=>{const{value:n,onValueChange:o,...a}=e,u=t(o),c=w.useMemo((()=>({value:n,onValueChange:u})),[n,u]);/*#__PURE__*/return w.createElement(T.Provider,{value:c},/*#__PURE__*/w.createElement(MenuGroup,y({},a,{ref:r})))}));/*#__PURE__*/export const MenuRadioItem=/*#__PURE__*/w.forwardRef(((e,t)=>{const{value:r,...n}=e,o=w.useContext(T),a=r===o.value;/*#__PURE__*/return w.createElement(N.Provider,{value:a},/*#__PURE__*/w.createElement(MenuItem,y({role:"menuitemradio","aria-checked":a},n,{ref:t,"data-state":U(a),onSelect:v(n.onSelect,(()=>{var e;return null===(e=o.onValueChange)||void 0===e?void 0:e.call(o,r)}),{checkForDefaultPrevented:!1})})))}));/*#__PURE__*/const V="span",N=/*#__PURE__*/w.createContext(!1);export const MenuItemIndicator=/*#__PURE__*/w.forwardRef(((e,t)=>{const{as:r=V,forceMount:n,...o}=e,a=w.useContext(N);/*#__PURE__*/return w.createElement(s,{present:n||a},/*#__PURE__*/w.createElement(c,y({},o,{as:r,ref:t,"data-state":U(a)})))}));/*#__PURE__*/export const MenuAnchor=i(u.Anchor,{displayName:"MenuAnchor"});export const MenuGroup=i(c,{defaultProps:{role:"group"},displayName:"MenuGroup"});export const MenuLabel=i(c,{displayName:"MenuLabel"});export const MenuSeparator=i(c,{defaultProps:{role:"separator","aria-orientation":"horizontal"},displayName:"MenuSeparator "});export const MenuArrow=i(u.Arrow,{displayName:"MenuArrow"});function U(e){return e?"checked":"unchecked"}export const Root=Menu;export const Anchor=MenuAnchor;export const Content=MenuContent;export const Group=MenuGroup;export const Label=MenuLabel;export const Item="web"===h.OS?MenuItem:G;export const CheckboxItem=MenuCheckboxItem;export const RadioGroup=MenuRadioGroup;export const RadioItem=MenuRadioItem;export const ItemIndicator=MenuItemIndicator;export const Separator=MenuSeparator;export const Arrow=MenuArrow;
2 | //# sourceMappingURL=index.module.js.map
3 |
--------------------------------------------------------------------------------
/packages/radix/menu/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@radix-ui/react-menu",
3 | "version": "0.0.18",
4 | "license": "MIT",
5 | "source": "src/index.ts",
6 | "main": "dist/index.js",
7 | "module": "dist/index.module.js",
8 | "types": "dist/index.d.ts",
9 | "files": [
10 | "dist",
11 | "README.md"
12 | ],
13 | "sideEffects": false,
14 | "scripts": {
15 | "clean": "rm -rf dist",
16 | "prepublish": "yarn clean",
17 | "version": "yarn version"
18 | },
19 | "dependencies": {
20 | "@babel/runtime": "^7.13.10",
21 | "@radix-ui/primitive": "workspace:*",
22 | "@radix-ui/react-collection": "workspace:*",
23 | "@radix-ui/react-compose-refs": "workspace:*",
24 | "@radix-ui/react-context": "workspace:*",
25 | "@radix-ui/react-dismissable-layer": "workspace:*",
26 | "@radix-ui/react-focus-guards": "workspace:*",
27 | "@radix-ui/react-focus-scope": "workspace:*",
28 | "@radix-ui/react-polymorphic": "workspace:*",
29 | "@radix-ui/react-popper": "workspace:*",
30 | "@radix-ui/react-portal": "workspace:*",
31 | "@radix-ui/react-presence": "workspace:*",
32 | "@radix-ui/react-primitive": "workspace:*",
33 | "@radix-ui/react-roving-focus": "workspace:*",
34 | "@radix-ui/react-slot": "workspace:*",
35 | "@radix-ui/react-use-callback-ref": "workspace:*",
36 | "aria-hidden": "^1.1.1",
37 | "react-remove-scroll": "^2.4.0"
38 | },
39 | "peerDependencies": {
40 | "react": "^16.8 || ^17.0",
41 | "react-dom": "^16.8 || ^17.0"
42 | },
43 | "homepage": "https://radix-ui.com/primitives",
44 | "repository": {
45 | "type": "git",
46 | "url": "git+https://github.com/radix-ui/primitives.git"
47 | },
48 | "bugs": {
49 | "url": "https://github.com/radix-ui/primitives/issues"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/packages/radix/menu/src/Menu.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import {
3 | Menu as MenuPrimitive,
4 | MenuAnchor,
5 | MenuContent,
6 | MenuGroup,
7 | MenuLabel,
8 | MenuItem,
9 | MenuCheckboxItem,
10 | MenuRadioGroup,
11 | MenuRadioItem,
12 | MenuItemIndicator,
13 | MenuSeparator,
14 | } from './Menu';
15 | import { css } from '../../../../stitches.config';
16 | import { foodGroups } from '../../../../test-data/foods';
17 |
18 | export default {
19 | title: 'Components/Menu',
20 | excludeStories: ['TickIcon', 'styledComponents', 'classes'],
21 | };
22 |
23 | export const Styled = () => (
24 |
42 | );
43 |
44 | export const WithLabels = () => (
45 |
67 | );
68 |
69 | const suits = [
70 | { emoji: '♥️', label: 'Hearts' },
71 | { emoji: '♠️', label: 'Spades' },
72 | { emoji: '♦️', label: 'Diamonds' },
73 | { emoji: '♣️', label: 'Clubs' },
74 | ];
75 |
76 | export const Typeahead = () => (
77 | <>
78 | Testing ground for typeahead behaviour
79 |
80 |
81 |
82 |
Text labels
83 |
84 |
85 | For comparison
86 |
87 | try the closed select below
88 |
89 |
100 |
101 |
102 |
103 |
104 |
105 |
Complex children
106 |
(relying on `.textContent` — default)
107 |
117 |
118 |
119 |
120 |
Complex children
121 |
(with explicit `textValue` prop)
122 |
132 |
133 |
134 | >
135 | );
136 |
137 | export const CheckboxItems = () => {
138 | const checkboxItems = [
139 | { label: 'Bold', state: React.useState(false) },
140 | { label: 'Italic', state: React.useState(true) },
141 | { label: 'Underline', state: React.useState(false) },
142 | { label: 'Strikethrough', state: React.useState(false), disabled: true },
143 | ];
144 |
145 | return (
146 |
172 | );
173 | };
174 |
175 | export const RadioItems = () => {
176 | const files = ['README.md', 'index.js', 'page.css'];
177 | const [file, setFile] = React.useState(files[1]);
178 |
179 | return (
180 |
202 | );
203 | };
204 |
205 | export const Animated = () => {
206 | const files = ['README.md', 'index.js', 'page.css'];
207 | const [file, setFile] = React.useState(files[1]);
208 | const [open, setOpen] = React.useState(true);
209 | const checkboxItems = [
210 | { label: 'Bold', state: React.useState(false) },
211 | { label: 'Italic', state: React.useState(true) },
212 | { label: 'Underline', state: React.useState(false) },
213 | { label: 'Strikethrough', state: React.useState(false), disabled: true },
214 | ];
215 |
216 | return (
217 | <>
218 |
222 |
223 |
224 |
250 | >
251 | );
252 | };
253 |
254 | type MenuOwnProps = Omit<
255 | React.ComponentProps & React.ComponentProps,
256 | | 'onOpenChange'
257 | | 'portalled'
258 | | 'trapFocus'
259 | | 'onOpenAutoFocus'
260 | | 'onCloseAutoFocus'
261 | | 'disableOutsidePointerEvents'
262 | | 'disableOutsideScroll'
263 | >;
264 |
265 | const Menu: React.FC = (props) => {
266 | const { open = true, children, ...contentProps } = props;
267 | return (
268 | {}}>
269 |
270 | event.preventDefault()}
275 | onCloseAutoFocus={(event) => event.preventDefault()}
276 | disableOutsidePointerEvents={false}
277 | disableOutsideScroll={false}
278 | align="start"
279 | {...contentProps}
280 | >
281 | {children}
282 |
283 |
284 | );
285 | };
286 |
287 | const contentClass = css({
288 | display: 'inline-block',
289 | boxSizing: 'border-box',
290 | minWidth: 130,
291 | backgroundColor: '$white',
292 | border: '1px solid $gray100',
293 | borderRadius: 6,
294 | padding: 5,
295 | boxShadow: '0 5px 10px 0 rgba(0, 0, 0, 0.1)',
296 | fontFamily: 'apple-system, BlinkMacSystemFont, helvetica, arial, sans-serif',
297 | fontSize: 13,
298 | '&:focus-within': {
299 | borderColor: '$black',
300 | },
301 | });
302 |
303 | const itemStyles: any = {
304 | display: 'flex',
305 | alignItems: 'center',
306 | justifyContent: 'space-between',
307 | lineHeight: '1',
308 | cursor: 'default',
309 | userSelect: 'none',
310 | whiteSpace: 'nowrap',
311 | height: 25,
312 | padding: '0 10px',
313 | color: '$black',
314 | borderRadius: 3,
315 | };
316 |
317 | const labelClass = css({
318 | ...itemStyles,
319 | color: '$gray100',
320 | });
321 |
322 | const itemClass = css({
323 | ...itemStyles,
324 |
325 | '&:focus': {
326 | outline: 'none',
327 | backgroundColor: '$black',
328 | color: 'white',
329 | },
330 |
331 | '&[data-disabled]': {
332 | color: '$gray100',
333 | },
334 | });
335 |
336 | const separatorClass = css({
337 | height: 1,
338 | margin: '5px 10px',
339 | backgroundColor: '$gray100',
340 | });
341 |
342 | const fadeIn = css.keyframes({
343 | from: { opacity: 0 },
344 | to: { opacity: 1 },
345 | });
346 |
347 | const fadeOut = css.keyframes({
348 | from: { opacity: 1 },
349 | to: { opacity: 0 },
350 | });
351 |
352 | const animatedRootClass = css(contentClass, {
353 | '&[data-state="open"]': {
354 | animation: `${fadeIn} 300ms ease-out`,
355 | },
356 | '&[data-state="closed"]': {
357 | animation: `${fadeOut} 300ms ease-in`,
358 | },
359 | });
360 |
361 | const animatedItemIndicatorClass = css({
362 | '&[data-state="checked"]': {
363 | animation: `${fadeIn} 300ms ease-out`,
364 | },
365 | '&[data-state="unchecked"]': {
366 | animation: `${fadeOut} 300ms ease-in`,
367 | },
368 | });
369 |
370 | export const TickIcon = () => (
371 |
384 | );
385 |
386 | export const classes = {
387 | contentClass,
388 | labelClass,
389 | itemClass,
390 | separatorClass,
391 | };
392 |
--------------------------------------------------------------------------------
/packages/radix/menu/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './Menu';
2 |
--------------------------------------------------------------------------------
/packages/radix/menu/src/useMenuTypeahead.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 |
3 | function useMenuTypeahead() {
4 | const timerRef = React.useRef(0);
5 | const searchRef = React.useRef('');
6 |
7 | // Reset `searchRef` 1 second after it was last updated
8 | const setSearch = React.useCallback((search: string) => {
9 | searchRef.current = search;
10 | window.clearTimeout(timerRef.current);
11 | timerRef.current = window.setTimeout(() => setSearch(''), 1000);
12 | }, []);
13 |
14 | return {
15 | onKeyDownCapture: (event: React.KeyboardEvent) => {
16 | if (event.key.length === 1 && !(event.ctrlKey || event.altKey || event.metaKey)) {
17 | const container = event.currentTarget as HTMLElement;
18 | setSearch(searchRef.current + event.key);
19 |
20 | // Stop activating the item if we're still "searching", essentially preventing
21 | // the spacebar from selecting the item currently focused.
22 | // This is also why we use `onKeyDownCapture` rather than `onKeyDown`
23 | if (event.key === ' ' && !searchRef.current.startsWith(' ')) {
24 | event.stopPropagation();
25 | }
26 |
27 | const currentItem = document.activeElement;
28 | const currentMatch = currentItem ? getValue(currentItem) : undefined;
29 | const values = Array.from(container.querySelectorAll(`[${ITEM_ATTR}]`)).map(getValue);
30 | const nextMatch = getNextMatch(values, searchRef.current, currentMatch);
31 | const newItem = container.querySelector(`[${ITEM_ATTR}="${nextMatch}"]`);
32 |
33 | if (newItem) {
34 | /**
35 | * Imperative focus during keydown is risky so we prevent React's batching updates
36 | * to avoid potential bugs. See: https://github.com/facebook/react/issues/20332
37 | */
38 | setTimeout(() => (newItem as HTMLElement).focus());
39 | }
40 | }
41 | },
42 | };
43 | }
44 |
45 | /**
46 | * This is the "meat" of the matching logic. It takes in all the values,
47 | * the search and the current match, and returns the next match (or `undefined`).
48 | *
49 | * We normalize the search because if a user has repeatedly pressed a character,
50 | * we want the exact same behavior as if we only had that one character
51 | * (ie. cycle through options starting with that character)
52 | *
53 | * We also reorder the values by wrapping the array around the current match.
54 | * This is so we always look forward from the current match, and picking the first
55 | * match will always be the correct one.
56 | *
57 | * Finally, if the normalized search is exactly one character, we exclude the
58 | * current match from the values because otherwise it would be the first to match always
59 | * and focus would never move. This is as opposed to the regular case, where we
60 | * don't want focus to move if the current match still matches.
61 | */
62 | function getNextMatch(values: string[], search: string, currentMatch?: string) {
63 | const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
64 | const normalizedSearch = isRepeated ? search[0] : search;
65 | const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
66 | let wrappedValues = wrapArray(values, Math.max(currentMatchIndex, 0));
67 | const excludeCurrentMatch = normalizedSearch.length === 1;
68 | if (excludeCurrentMatch) wrappedValues = wrappedValues.filter((v) => v !== currentMatch);
69 | const nextMatch = wrappedValues.find((value) =>
70 | value.toLowerCase().startsWith(normalizedSearch.toLowerCase())
71 | );
72 | return nextMatch !== currentMatch ? nextMatch : undefined;
73 | }
74 |
75 | const getValue = (element: Element) => element.getAttribute(ITEM_ATTR) ?? '';
76 |
77 | const ITEM_ATTR = 'data-radix-menu-typeahead-item';
78 |
79 | type UseMenuTypeaheadItemOptions = { textValue: string; disabled?: boolean };
80 |
81 | function useMenuTypeaheadItem({ textValue, disabled }: UseMenuTypeaheadItemOptions) {
82 | return { [ITEM_ATTR]: disabled ? undefined : textValue };
83 | }
84 |
85 | /**
86 | * Wraps an array around itself at a given start index
87 | * Example: `wrapArray(['a', 'b', 'c', 'd'], 2) === ['c', 'd', 'a', 'b']`
88 | */
89 | function wrapArray(array: T[], startIndex: number) {
90 | return array.map((_, index) => array[(startIndex + index) % array.length]);
91 | }
92 |
93 | export { useMenuTypeahead, useMenuTypeaheadItem };
94 |
--------------------------------------------------------------------------------
/patches/@expo+next-adapter+2.1.77.patch:
--------------------------------------------------------------------------------
1 | diff --git a/node_modules/@expo/next-adapter/build/babel.js b/node_modules/@expo/next-adapter/build/babel.js
2 | index ab1b808..36dbe97 100644
3 | --- a/node_modules/@expo/next-adapter/build/babel.js
4 | +++ b/node_modules/@expo/next-adapter/build/babel.js
5 | @@ -13,12 +13,16 @@ module.exports = function (api) {
6 | if (missingPackages.length)
7 | throw new Error(`[BABEL]: preset \`@expo/next-adapter/babel\` is missing peer dependencies: ${missingPackages.join(', ')}`);
8 | }
9 | +
10 | return {
11 | presets: [
12 | require('babel-preset-expo'),
13 | // Only use next in the browser, it'll break your native project/
14 | isWeb && require('next/babel'),
15 | ].filter(Boolean),
16 | + plugins: [
17 | + isWeb && "@babel/plugin-proposal-class-properties",
18 | + ].filter(Boolean),
19 | };
20 | };
21 | function hasModule(name) {
22 | diff --git a/node_modules/@expo/next-adapter/build/withExpo.js b/node_modules/@expo/next-adapter/build/withExpo.js
23 | index 2e63eb4..fbea871 100644
24 | --- a/node_modules/@expo/next-adapter/build/withExpo.js
25 | +++ b/node_modules/@expo/next-adapter/build/withExpo.js
26 | @@ -7,8 +7,8 @@ function withExpo(nextConfig = {}) {
27 | // Prevent define plugin from overwriting Next.js environment.
28 | process.env.EXPO_WEBPACK_DEFINE_ENVIRONMENT_AS_KEYS = 'true';
29 | const expoConfig = addons_1.withUnimodules(config, {
30 | - projectRoot: nextConfig.projectRoot || process.cwd(),
31 | - }, { supportsFontLoading: false });
32 | + projectRoot: nextConfig.projectRoot || process.cwd()
33 | + }, { supportsFontLoading: false, webpack5: (options.config.future || {}).webpack5 });
34 | // Use original public path
35 | (expoConfig.output || {}).publicPath = (config.output || {}).publicPath;
36 | // TODO: Bacon: use commonjs for RNW babel maybe...
37 |
--------------------------------------------------------------------------------
/patches/@expo+webpack-config+0.12.76.patch:
--------------------------------------------------------------------------------
1 | diff --git a/node_modules/@expo/webpack-config/webpack/addons/withOptimizations.js b/node_modules/@expo/webpack-config/webpack/addons/withOptimizations.js
2 | index 8411aeb..6e91898 100644
3 | --- a/node_modules/@expo/webpack-config/webpack/addons/withOptimizations.js
4 | +++ b/node_modules/@expo/webpack-config/webpack/addons/withOptimizations.js
5 | @@ -7,6 +7,7 @@ exports.isDebugMode = void 0;
6 | const getenv_1 = require("getenv");
7 | const is_wsl_1 = __importDefault(require("is-wsl"));
8 | const optimize_css_assets_webpack_plugin_1 = __importDefault(require("optimize-css-assets-webpack-plugin"));
9 | +const css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin"));
10 | const postcss_safe_parser_1 = __importDefault(require("postcss-safe-parser"));
11 | const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
12 | /**
13 | @@ -81,21 +82,7 @@ function withOptimizations(webpackConfig) {
14 | sourceMap: shouldUseSourceMap,
15 | }),
16 | // This is only used in production mode
17 | - new optimize_css_assets_webpack_plugin_1.default({
18 | - cssProcessorOptions: {
19 | - parser: postcss_safe_parser_1.default,
20 | - map: shouldUseSourceMap
21 | - ? {
22 | - // `inline: false` forces the sourcemap to be output into a
23 | - // separate file
24 | - inline: false,
25 | - // `annotation: true` appends the sourceMappingURL to the end of
26 | - // the css file, helping the browser find the sourcemap
27 | - annotation: true,
28 | - }
29 | - : false,
30 | - },
31 | - }),
32 | + new css_minimizer_webpack_plugin_1.default()
33 | ],
34 | // Automatically split vendor and commons
35 | // https://twitter.com/wSokra/status/969633336732905474
36 | diff --git a/node_modules/@expo/webpack-config/webpack/addons/withUnimodules.js b/node_modules/@expo/webpack-config/webpack/addons/withUnimodules.js
37 | index e293a98..5411c51 100644
38 | --- a/node_modules/@expo/webpack-config/webpack/addons/withUnimodules.js
39 | +++ b/node_modules/@expo/webpack-config/webpack/addons/withUnimodules.js
40 | @@ -39,6 +39,7 @@ function withUnimodules(webpackConfig = {}, env = {}, argv = {}) {
41 | webpackConfig.output = {};
42 | // Attempt to use the input webpack config mode
43 | env.mode = env.mode || webpackConfig.mode;
44 | + const isWebpack5 = argv.webpack5
45 | const environment = env_1.validateEnvironment(env);
46 | let { supportsFontLoading } = argv;
47 | // If the args don't specify this then we'll check if the input already supports font loading.
48 | @@ -117,7 +118,7 @@ function withUnimodules(webpackConfig = {}, env = {}, argv = {}) {
49 | };
50 | // Transpile and remove expo modules from Next.js externals.
51 | const includeFunc = babelLoader.include;
52 | - webpackConfig = ignoreExternalModules(webpackConfig, includeFunc);
53 | + webpackConfig = ignoreExternalModules(webpackConfig, includeFunc, isWebpack5);
54 | // Add a loose requirement on the ResizeObserver polyfill if it's installed...
55 | webpackConfig = withEntry_1.default(webpackConfig, env, {
56 | entryPath: 'resize-observer-polyfill/dist/ResizeObserver.global',
57 | @@ -137,7 +138,7 @@ exports.default = withUnimodules;
58 | * @param webpackConfig Config to be modified
59 | * @param shouldIncludeModule A method that returns a boolean when the input module should be transpiled and externed.
60 | */
61 | -function ignoreExternalModules(webpackConfig, shouldIncludeModule) {
62 | +function ignoreExternalModules(webpackConfig, shouldIncludeModule, isWebpack5) {
63 | if (!webpackConfig.externals) {
64 | return webpackConfig;
65 | }
66 | @@ -148,6 +149,13 @@ function ignoreExternalModules(webpackConfig, shouldIncludeModule) {
67 | if (typeof external !== 'function') {
68 | return external;
69 | }
70 | +
71 | + if (isWebpack5) {
72 | + return ((ctx) => {
73 | + const relPath = path_1.default.join('node_modules', ctx.request);
74 | + return shouldIncludeModule(relPath) ? undefined : external(ctx);
75 | + })
76 | + }
77 | return ((ctx, req, cb) => {
78 | const relPath = path_1.default.join('node_modules', req);
79 | return shouldIncludeModule(relPath) ? cb() : external(ctx, req, cb);
80 |
--------------------------------------------------------------------------------
/patches/@gorhom+bottom-sheet+4.0.0-alpha.3.patch:
--------------------------------------------------------------------------------
1 | diff --git a/node_modules/@gorhom/bottom-sheet/lib/commonjs/components/touchables/Touchables.android.js.map b/node_modules/@gorhom/bottom-sheet/lib/commonjs/components/touchables/Touchables.android.js.map
2 | deleted file mode 100644
3 | index 1a8f11a..0000000
4 | --- a/node_modules/@gorhom/bottom-sheet/lib/commonjs/components/touchables/Touchables.android.js.map
5 | +++ /dev/null
6 | @@ -1 +0,0 @@
7 | -{"version":3,"sources":["Touchables.android.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA","sourcesContent":["export {\n TouchableOpacity,\n TouchableHighlight,\n TouchableWithoutFeedback,\n} from 'react-native-gesture-handler';\n"]}
8 | \ No newline at end of file
9 | diff --git a/node_modules/@gorhom/bottom-sheet/lib/commonjs/components/touchables/Touchables.android.js b/node_modules/@gorhom/bottom-sheet/lib/commonjs/components/touchables/Touchables.js
10 | similarity index 100%
11 | rename from node_modules/@gorhom/bottom-sheet/lib/commonjs/components/touchables/Touchables.android.js
12 | rename to node_modules/@gorhom/bottom-sheet/lib/commonjs/components/touchables/Touchables.js
13 | diff --git a/node_modules/@gorhom/bottom-sheet/lib/commonjs/components/touchables/Touchables.js.map b/node_modules/@gorhom/bottom-sheet/lib/commonjs/components/touchables/Touchables.js.map
14 | new file mode 100644
15 | index 0000000..a16bc78
16 | --- /dev/null
17 | +++ b/node_modules/@gorhom/bottom-sheet/lib/commonjs/components/touchables/Touchables.js.map
18 | @@ -0,0 +1 @@
19 | +{"version":3,"sources":["Touchables.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA","sourcesContent":["export {\n TouchableOpacity,\n TouchableHighlight,\n TouchableWithoutFeedback,\n} from 'react-native-gesture-handler';\n"]}
20 | \ No newline at end of file
21 | diff --git a/node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.android.js.map b/node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.android.js.map
22 | deleted file mode 100644
23 | index 3098e7d..0000000
24 | --- a/node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.android.js.map
25 | +++ /dev/null
26 | @@ -1 +0,0 @@
27 | -{"version":3,"sources":["Touchables.android.tsx"],"names":["TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback"],"mappings":"AAAA,SACEA,gBADF,EAEEC,kBAFF,EAGEC,wBAHF,QAIO,8BAJP","sourcesContent":["export {\n TouchableOpacity,\n TouchableHighlight,\n TouchableWithoutFeedback,\n} from 'react-native-gesture-handler';\n"]}
28 | \ No newline at end of file
29 | diff --git a/node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.android.js b/node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.js
30 | similarity index 70%
31 | rename from node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.android.js
32 | rename to node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.js
33 | index fc81621..b1edc97 100644
34 | --- a/node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.android.js
35 | +++ b/node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.js
36 | @@ -1,2 +1,2 @@
37 | export { TouchableOpacity, TouchableHighlight, TouchableWithoutFeedback } from 'react-native-gesture-handler';
38 | -//# sourceMappingURL=Touchables.android.js.map
39 | \ No newline at end of file
40 | +//# sourceMappingURL=Touchables.js.map
41 | \ No newline at end of file
42 | diff --git a/node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.js.map b/node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.js.map
43 | new file mode 100644
44 | index 0000000..ac59a11
45 | --- /dev/null
46 | +++ b/node_modules/@gorhom/bottom-sheet/lib/module/components/touchables/Touchables.js.map
47 | @@ -0,0 +1 @@
48 | +{"version":3,"sources":["Touchables.tsx"],"names":["TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback"],"mappings":"AAAA,SACEA,gBADF,EAEEC,kBAFF,EAGEC,wBAHF,QAIO,8BAJP","sourcesContent":["export {\n TouchableOpacity,\n TouchableHighlight,\n TouchableWithoutFeedback,\n} from 'react-native-gesture-handler';\n"]}
49 | \ No newline at end of file
50 | diff --git a/node_modules/@gorhom/bottom-sheet/src/components/touchables/Touchables.android.tsx b/node_modules/@gorhom/bottom-sheet/src/components/touchables/Touchables.tsx
51 | similarity index 100%
52 | rename from node_modules/@gorhom/bottom-sheet/src/components/touchables/Touchables.android.tsx
53 | rename to node_modules/@gorhom/bottom-sheet/src/components/touchables/Touchables.tsx
54 |
--------------------------------------------------------------------------------
/patches/babel-preset-expo+8.3.0.patch:
--------------------------------------------------------------------------------
1 | diff --git a/node_modules/babel-preset-expo/index.js b/node_modules/babel-preset-expo/index.js
2 | index 1022490..08c8182 100644
3 | --- a/node_modules/babel-preset-expo/index.js
4 | +++ b/node_modules/babel-preset-expo/index.js
5 | @@ -31,6 +31,8 @@ module.exports = function(api, options = {}) {
6 | // Reference: https://github.com/expo/expo/pull/4685#discussion_r307143920
7 | require('metro-react-native-babel-preset'),
8 | {
9 | + dev: true,
10 | + useTransformReactJsxExperimental: true,
11 | disableImportExportTransform: platformOptions.disableImportExportTransform,
12 | lazyImportExportTransform:
13 | lazyImportsOption === true
14 |
--------------------------------------------------------------------------------