nwui-cli 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -1
- package/build/index.js +33 -17
- package/build/install-component.js +105 -48
- package/build/login.js +14 -11
- package/build/utils/env.js +1 -1
- package/package.json +2 -1
- package/build/cli/src/index.js +0 -41
- package/build/cli/src/install-component.js +0 -42
- package/build/cli/src/login.js +0 -77
- package/build/cli/src/net.js +0 -12
- package/build/cli/src/project-setup.js +0 -1
- package/build/cli/src/prompts.js +0 -119
- package/build/cli/src/utils/local-storage.js +0 -19
- package/build/docs/app/data.js +0 -1380
- package/build/log/index.js +0 -81
- package/build/prompts.js +0 -119
- package/my-expo-app-2/app/+html.tsx +0 -46
- package/my-expo-app-2/app/+not-found.tsx +0 -33
- package/my-expo-app-2/app/_layout.tsx +0 -22
- package/my-expo-app-2/app/details.tsx +0 -17
- package/my-expo-app-2/app/index.tsx +0 -23
- package/my-expo-app-2/app-env.d.ts +0 -2
- package/my-expo-app-2/app.json +0 -48
- package/my-expo-app-2/assets/adaptive-icon.png +0 -0
- package/my-expo-app-2/assets/favicon.png +0 -0
- package/my-expo-app-2/assets/icon.png +0 -0
- package/my-expo-app-2/assets/splash.png +0 -0
- package/my-expo-app-2/babel.config.js +0 -18
- package/my-expo-app-2/cesconfig.json +0 -35
- package/my-expo-app-2/components/Button.tsx +0 -19
- package/my-expo-app-2/components/Container.tsx +0 -9
- package/my-expo-app-2/components/EditScreenInfo.tsx +0 -34
- package/my-expo-app-2/components/ScreenContent.tsx +0 -25
- package/my-expo-app-2/components/nativewindui/ActivityIndicator.tsx +0 -13
- package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +0 -97
- package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +0 -264
- package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/index.ts +0 -1
- package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/types.ts +0 -95
- package/my-expo-app-2/components/nativewindui/Alert/Alert.ios.tsx +0 -65
- package/my-expo-app-2/components/nativewindui/Alert/Alert.tsx +0 -291
- package/my-expo-app-2/components/nativewindui/Alert/index.ts +0 -1
- package/my-expo-app-2/components/nativewindui/Alert/types.ts +0 -27
- package/my-expo-app-2/components/nativewindui/Badge.tsx +0 -84
- package/my-expo-app-2/components/nativewindui/Button.tsx +0 -156
- package/my-expo-app-2/components/nativewindui/Checkbox.tsx +0 -61
- package/my-expo-app-2/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +0 -221
- package/my-expo-app-2/components/nativewindui/ContextMenu/ContextMenu.tsx +0 -420
- package/my-expo-app-2/components/nativewindui/ContextMenu/index.ts +0 -1
- package/my-expo-app-2/components/nativewindui/ContextMenu/types.ts +0 -91
- package/my-expo-app-2/components/nativewindui/ContextMenu/utils.ts +0 -14
- package/my-expo-app-2/components/nativewindui/DrawerContent.tsx +0 -145
- package/my-expo-app-2/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +0 -168
- package/my-expo-app-2/components/nativewindui/DropdownMenu/DropdownMenu.tsx +0 -330
- package/my-expo-app-2/components/nativewindui/DropdownMenu/index.ts +0 -1
- package/my-expo-app-2/components/nativewindui/DropdownMenu/types.ts +0 -93
- package/my-expo-app-2/components/nativewindui/DropdownMenu/utils.ts +0 -14
- package/my-expo-app-2/components/nativewindui/Form.tsx +0 -125
- package/my-expo-app-2/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +0 -99
- package/my-expo-app-2/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +0 -288
- package/my-expo-app-2/components/nativewindui/LargeTitleHeader/index.ts +0 -1
- package/my-expo-app-2/components/nativewindui/LargeTitleHeader/types.ts +0 -89
- package/my-expo-app-2/components/nativewindui/List.tsx +0 -433
- package/my-expo-app-2/components/nativewindui/SearchInput/SearchInput.ios.tsx +0 -177
- package/my-expo-app-2/components/nativewindui/SearchInput/SearchInput.tsx +0 -86
- package/my-expo-app-2/components/nativewindui/SearchInput/index.tsx +0 -1
- package/my-expo-app-2/components/nativewindui/SearchInput/types.ts +0 -12
- package/my-expo-app-2/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +0 -31
- package/my-expo-app-2/components/nativewindui/SegmentedControl/SegmentedControl.tsx +0 -55
- package/my-expo-app-2/components/nativewindui/SegmentedControl/index.ts +0 -1
- package/my-expo-app-2/components/nativewindui/SegmentedControl/types.ts +0 -15
- package/my-expo-app-2/components/nativewindui/Stepper.tsx +0 -62
- package/my-expo-app-2/components/nativewindui/Text.tsx +0 -55
- package/my-expo-app-2/components/nativewindui/TextField/TextField.ios.tsx +0 -85
- package/my-expo-app-2/components/nativewindui/TextField/TextField.tsx +0 -326
- package/my-expo-app-2/components/nativewindui/TextField/index.tsx +0 -1
- package/my-expo-app-2/components/nativewindui/TextField/types.ts +0 -26
- package/my-expo-app-2/components/nativewindui/Toolbar.tsx +0 -116
- package/my-expo-app-2/global.css +0 -3
- package/my-expo-app-2/metro.config.js +0 -12
- package/my-expo-app-2/package-lock.json +0 -19162
- package/my-expo-app-2/package.json +0 -74
- package/my-expo-app-2/prettier.config.js +0 -11
- package/my-expo-app-2/tailwind.config.js +0 -11
- package/my-expo-app-3/app/+html.tsx +0 -46
- package/my-expo-app-3/app/+not-found.tsx +0 -33
- package/my-expo-app-3/app/_layout.tsx +0 -22
- package/my-expo-app-3/app/details.tsx +0 -17
- package/my-expo-app-3/app/index.tsx +0 -23
- package/my-expo-app-3/app-env.d.ts +0 -2
- package/my-expo-app-3/app.json +0 -48
- package/my-expo-app-3/assets/adaptive-icon.png +0 -0
- package/my-expo-app-3/assets/favicon.png +0 -0
- package/my-expo-app-3/assets/icon.png +0 -0
- package/my-expo-app-3/assets/splash.png +0 -0
- package/my-expo-app-3/babel.config.js +0 -18
- package/my-expo-app-3/cesconfig.json +0 -35
- package/my-expo-app-3/components/Button.tsx +0 -19
- package/my-expo-app-3/components/Container.tsx +0 -9
- package/my-expo-app-3/components/EditScreenInfo.tsx +0 -34
- package/my-expo-app-3/components/ScreenContent.tsx +0 -25
- package/my-expo-app-3/components/nativewindui/ActivityIndicator.tsx +0 -13
- package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +0 -97
- package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +0 -264
- package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/index.ts +0 -1
- package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/types.ts +0 -95
- package/my-expo-app-3/components/nativewindui/Alert/Alert.ios.tsx +0 -65
- package/my-expo-app-3/components/nativewindui/Alert/Alert.tsx +0 -291
- package/my-expo-app-3/components/nativewindui/Alert/index.ts +0 -1
- package/my-expo-app-3/components/nativewindui/Alert/types.ts +0 -27
- package/my-expo-app-3/components/nativewindui/Badge.tsx +0 -84
- package/my-expo-app-3/components/nativewindui/Button.tsx +0 -156
- package/my-expo-app-3/components/nativewindui/Checkbox.tsx +0 -61
- package/my-expo-app-3/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +0 -221
- package/my-expo-app-3/components/nativewindui/ContextMenu/ContextMenu.tsx +0 -420
- package/my-expo-app-3/components/nativewindui/ContextMenu/index.ts +0 -1
- package/my-expo-app-3/components/nativewindui/ContextMenu/types.ts +0 -91
- package/my-expo-app-3/components/nativewindui/ContextMenu/utils.ts +0 -14
- package/my-expo-app-3/components/nativewindui/DrawerContent.tsx +0 -145
- package/my-expo-app-3/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +0 -168
- package/my-expo-app-3/components/nativewindui/DropdownMenu/DropdownMenu.tsx +0 -330
- package/my-expo-app-3/components/nativewindui/DropdownMenu/index.ts +0 -1
- package/my-expo-app-3/components/nativewindui/DropdownMenu/types.ts +0 -93
- package/my-expo-app-3/components/nativewindui/DropdownMenu/utils.ts +0 -14
- package/my-expo-app-3/components/nativewindui/Form.tsx +0 -125
- package/my-expo-app-3/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +0 -99
- package/my-expo-app-3/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +0 -288
- package/my-expo-app-3/components/nativewindui/LargeTitleHeader/index.ts +0 -1
- package/my-expo-app-3/components/nativewindui/LargeTitleHeader/types.ts +0 -89
- package/my-expo-app-3/components/nativewindui/List.tsx +0 -433
- package/my-expo-app-3/components/nativewindui/SearchInput/SearchInput.ios.tsx +0 -177
- package/my-expo-app-3/components/nativewindui/SearchInput/SearchInput.tsx +0 -86
- package/my-expo-app-3/components/nativewindui/SearchInput/index.tsx +0 -1
- package/my-expo-app-3/components/nativewindui/SearchInput/types.ts +0 -12
- package/my-expo-app-3/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +0 -31
- package/my-expo-app-3/components/nativewindui/SegmentedControl/SegmentedControl.tsx +0 -55
- package/my-expo-app-3/components/nativewindui/SegmentedControl/index.ts +0 -1
- package/my-expo-app-3/components/nativewindui/SegmentedControl/types.ts +0 -15
- package/my-expo-app-3/components/nativewindui/Stepper.tsx +0 -62
- package/my-expo-app-3/components/nativewindui/Text.tsx +0 -55
- package/my-expo-app-3/components/nativewindui/TextField/TextField.ios.tsx +0 -85
- package/my-expo-app-3/components/nativewindui/TextField/TextField.tsx +0 -326
- package/my-expo-app-3/components/nativewindui/TextField/index.tsx +0 -1
- package/my-expo-app-3/components/nativewindui/TextField/types.ts +0 -26
- package/my-expo-app-3/components/nativewindui/Toolbar.tsx +0 -116
- package/my-expo-app-3/components/nativewindui/examples/selectable-text.tsx +0 -43
- package/my-expo-app-3/components/nativewindui/examples/text.tsx +0 -43
- package/my-expo-app-3/global.css +0 -3
- package/my-expo-app-3/metro.config.js +0 -12
- package/my-expo-app-3/package-lock.json +0 -19141
- package/my-expo-app-3/package.json +0 -73
- package/my-expo-app-3/prettier.config.js +0 -11
- package/my-expo-app-3/tailwind.config.js +0 -11
- package/my-expo-app-test-case/app/+html.tsx +0 -46
- package/my-expo-app-test-case/app/+not-found.tsx +0 -33
- package/my-expo-app-test-case/app/_layout.tsx +0 -22
- package/my-expo-app-test-case/app/details.tsx +0 -17
- package/my-expo-app-test-case/app/index.tsx +0 -23
- package/my-expo-app-test-case/app-env.d.ts +0 -2
- package/my-expo-app-test-case/app.json +0 -48
- package/my-expo-app-test-case/assets/adaptive-icon.png +0 -0
- package/my-expo-app-test-case/assets/favicon.png +0 -0
- package/my-expo-app-test-case/assets/icon.png +0 -0
- package/my-expo-app-test-case/assets/splash.png +0 -0
- package/my-expo-app-test-case/babel.config.js +0 -18
- package/my-expo-app-test-case/cesconfig.json +0 -35
- package/my-expo-app-test-case/components/Button.tsx +0 -19
- package/my-expo-app-test-case/components/Container.tsx +0 -9
- package/my-expo-app-test-case/components/EditScreenInfo.tsx +0 -34
- package/my-expo-app-test-case/components/ScreenContent.tsx +0 -25
- package/my-expo-app-test-case/components/nativewindui/ActivityIndicator.tsx +0 -13
- package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +0 -97
- package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +0 -264
- package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/index.ts +0 -1
- package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/types.ts +0 -95
- package/my-expo-app-test-case/components/nativewindui/Alert/Alert.ios.tsx +0 -65
- package/my-expo-app-test-case/components/nativewindui/Alert/Alert.tsx +0 -291
- package/my-expo-app-test-case/components/nativewindui/Alert/index.ts +0 -1
- package/my-expo-app-test-case/components/nativewindui/Alert/types.ts +0 -27
- package/my-expo-app-test-case/components/nativewindui/Badge.tsx +0 -84
- package/my-expo-app-test-case/components/nativewindui/Button.tsx +0 -156
- package/my-expo-app-test-case/components/nativewindui/Checkbox.tsx +0 -61
- package/my-expo-app-test-case/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +0 -221
- package/my-expo-app-test-case/components/nativewindui/ContextMenu/ContextMenu.tsx +0 -420
- package/my-expo-app-test-case/components/nativewindui/ContextMenu/index.ts +0 -1
- package/my-expo-app-test-case/components/nativewindui/ContextMenu/types.ts +0 -91
- package/my-expo-app-test-case/components/nativewindui/ContextMenu/utils.ts +0 -14
- package/my-expo-app-test-case/components/nativewindui/DrawerContent.tsx +0 -145
- package/my-expo-app-test-case/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +0 -168
- package/my-expo-app-test-case/components/nativewindui/DropdownMenu/DropdownMenu.tsx +0 -330
- package/my-expo-app-test-case/components/nativewindui/DropdownMenu/index.ts +0 -1
- package/my-expo-app-test-case/components/nativewindui/DropdownMenu/types.ts +0 -93
- package/my-expo-app-test-case/components/nativewindui/DropdownMenu/utils.ts +0 -14
- package/my-expo-app-test-case/components/nativewindui/Form.tsx +0 -125
- package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +0 -99
- package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +0 -288
- package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/index.ts +0 -1
- package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/types.ts +0 -89
- package/my-expo-app-test-case/components/nativewindui/List.tsx +0 -433
- package/my-expo-app-test-case/components/nativewindui/SearchInput/SearchInput.ios.tsx +0 -177
- package/my-expo-app-test-case/components/nativewindui/SearchInput/SearchInput.tsx +0 -86
- package/my-expo-app-test-case/components/nativewindui/SearchInput/index.tsx +0 -1
- package/my-expo-app-test-case/components/nativewindui/SearchInput/types.ts +0 -12
- package/my-expo-app-test-case/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +0 -31
- package/my-expo-app-test-case/components/nativewindui/SegmentedControl/SegmentedControl.tsx +0 -55
- package/my-expo-app-test-case/components/nativewindui/SegmentedControl/index.ts +0 -1
- package/my-expo-app-test-case/components/nativewindui/SegmentedControl/types.ts +0 -15
- package/my-expo-app-test-case/components/nativewindui/Stepper.tsx +0 -62
- package/my-expo-app-test-case/components/nativewindui/Text.tsx +0 -55
- package/my-expo-app-test-case/components/nativewindui/TextField/TextField.ios.tsx +0 -85
- package/my-expo-app-test-case/components/nativewindui/TextField/TextField.tsx +0 -326
- package/my-expo-app-test-case/components/nativewindui/TextField/index.tsx +0 -1
- package/my-expo-app-test-case/components/nativewindui/TextField/types.ts +0 -26
- package/my-expo-app-test-case/components/nativewindui/Toolbar.tsx +0 -116
- package/my-expo-app-test-case/components/nativewindui/examples/a-user-created-file.tsx +0 -0
- package/my-expo-app-test-case/components/nativewindui/examples/selectable-text.tsx +0 -43
- package/my-expo-app-test-case/components/nativewindui/examples/text.tsx +0 -43
- package/my-expo-app-test-case/global.css +0 -3
- package/my-expo-app-test-case/metro.config.js +0 -12
- package/my-expo-app-test-case/package-lock.json +0 -19141
- package/my-expo-app-test-case/package.json +0 -73
- package/my-expo-app-test-case/prettier.config.js +0 -11
- package/my-expo-app-test-case/tailwind.config.js +0 -11
- package/no-install/app/+html.tsx +0 -46
- package/no-install/app/+not-found.tsx +0 -25
- package/no-install/app/_layout.tsx +0 -7
- package/no-install/app/details.tsx +0 -20
- package/no-install/app/index.tsx +0 -19
- package/no-install/app-env.d.ts +0 -2
- package/no-install/app.json +0 -41
- package/no-install/assets/adaptive-icon.png +0 -0
- package/no-install/assets/favicon.png +0 -0
- package/no-install/assets/icon.png +0 -0
- package/no-install/assets/splash.png +0 -0
- package/no-install/babel.config.js +0 -13
- package/no-install/cesconfig.json +0 -35
- package/no-install/components/Button.tsx +0 -25
- package/no-install/components/Container.tsx +0 -9
- package/no-install/components/EditScreenInfo.tsx +0 -31
- package/no-install/components/ScreenContent.tsx +0 -29
- package/no-install/components/nativewindui/Slider.tsx +0 -26
- package/no-install/global.css +0 -3
- package/no-install/metro.config.js +0 -10
- package/no-install/package-lock.json +0 -17505
- package/no-install/package.json +0 -59
- package/no-install/prettier.config.js +0 -10
- package/no-install/tailwind.config.js +0 -14
- package/test-app/app/+html.tsx +0 -46
- package/test-app/app/+not-found.tsx +0 -25
- package/test-app/app/_layout.tsx +0 -7
- package/test-app/app/details.tsx +0 -20
- package/test-app/app/index.tsx +0 -19
- package/test-app/app-env.d.ts +0 -2
- package/test-app/app.json +0 -41
- package/test-app/assets/adaptive-icon.png +0 -0
- package/test-app/assets/favicon.png +0 -0
- package/test-app/assets/icon.png +0 -0
- package/test-app/assets/splash.png +0 -0
- package/test-app/babel.config.js +0 -13
- package/test-app/cesconfig.json +0 -35
- package/test-app/components/Button.tsx +0 -25
- package/test-app/components/Container.tsx +0 -9
- package/test-app/components/EditScreenInfo.tsx +0 -31
- package/test-app/components/ScreenContent.tsx +0 -29
- package/test-app/components/nativewindui/ActivityIndicator.tsx +0 -13
- package/test-app/components/nativewindui/Avatar.tsx +0 -133
- package/test-app/components/nativewindui/DatePicker/DatePicker.android.tsx +0 -72
- package/test-app/components/nativewindui/DatePicker/DatePicker.tsx +0 -23
- package/test-app/components/nativewindui/DatePicker/index.ts +0 -1
- package/test-app/components/nativewindui/Picker.tsx +0 -42
- package/test-app/components/nativewindui/ProgressIndicator.tsx +0 -78
- package/test-app/components/nativewindui/Sheet.tsx +0 -52
- package/test-app/components/nativewindui/Slider.tsx +0 -26
- package/test-app/components/nativewindui/Text.tsx +0 -55
- package/test-app/components/nativewindui/Toggle.tsx +0 -20
- package/test-app/global.css +0 -3
- package/test-app/metro.config.js +0 -10
- package/test-app/package.json +0 -64
- package/test-app/prettier.config.js +0 -10
- package/test-app/tailwind.config.js +0 -14
- package/test-no-install/app/+html.tsx +0 -46
- package/test-no-install/app/+not-found.tsx +0 -25
- package/test-no-install/app/_layout.tsx +0 -7
- package/test-no-install/app/details.tsx +0 -20
- package/test-no-install/app/index.tsx +0 -19
- package/test-no-install/app-env.d.ts +0 -2
- package/test-no-install/app.json +0 -41
- package/test-no-install/assets/adaptive-icon.png +0 -0
- package/test-no-install/assets/favicon.png +0 -0
- package/test-no-install/assets/icon.png +0 -0
- package/test-no-install/assets/splash.png +0 -0
- package/test-no-install/babel.config.js +0 -13
- package/test-no-install/cesconfig.json +0 -35
- package/test-no-install/components/Button.tsx +0 -25
- package/test-no-install/components/Container.tsx +0 -9
- package/test-no-install/components/EditScreenInfo.tsx +0 -31
- package/test-no-install/components/ScreenContent.tsx +0 -29
- package/test-no-install/components/nativewindui/ActivityIndicator.tsx +0 -13
- package/test-no-install/components/nativewindui/Avatar.tsx +0 -133
- package/test-no-install/components/nativewindui/DatePicker/DatePicker.android.tsx +0 -72
- package/test-no-install/components/nativewindui/DatePicker/DatePicker.tsx +0 -23
- package/test-no-install/components/nativewindui/DatePicker/index.ts +0 -1
- package/test-no-install/components/nativewindui/Picker.tsx +0 -42
- package/test-no-install/components/nativewindui/ProgressIndicator.tsx +0 -78
- package/test-no-install/components/nativewindui/Sheet.tsx +0 -52
- package/test-no-install/components/nativewindui/Slider.tsx +0 -26
- package/test-no-install/components/nativewindui/Text.tsx +0 -55
- package/test-no-install/components/nativewindui/Toggle.tsx +0 -20
- package/test-no-install/global.css +0 -3
- package/test-no-install/metro.config.js +0 -10
- package/test-no-install/package.json +0 -64
- package/test-no-install/prettier.config.js +0 -10
- package/test-no-install/tailwind.config.js +0 -14
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { ICON_MAPPING, type MaterialIconName } from '@roninoss/icons';
|
|
2
|
-
import { cssInterop } from 'nativewind';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { View } from 'react-native';
|
|
5
|
-
import {
|
|
6
|
-
ContextMenuView,
|
|
7
|
-
MenuAttributes,
|
|
8
|
-
MenuConfig,
|
|
9
|
-
MenuElementConfig,
|
|
10
|
-
OnPressMenuItemEvent,
|
|
11
|
-
} from 'react-native-ios-context-menu';
|
|
12
|
-
|
|
13
|
-
import type {
|
|
14
|
-
ContextItem,
|
|
15
|
-
ContextMenuConfig,
|
|
16
|
-
ContextMenuProps,
|
|
17
|
-
ContextMenuRef,
|
|
18
|
-
ContextSubMenu,
|
|
19
|
-
} from './types';
|
|
20
|
-
|
|
21
|
-
cssInterop(ContextMenuView, {
|
|
22
|
-
className: 'style',
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const PREVIEW_CONFIG = {
|
|
26
|
-
previewSize: 'INHERIT',
|
|
27
|
-
preferredCommitStyle: 'dismiss',
|
|
28
|
-
isResizeAnimated: true,
|
|
29
|
-
previewType: 'CUSTOM',
|
|
30
|
-
} as const;
|
|
31
|
-
|
|
32
|
-
function getAuxiliaryPreviewPosition(position: 'start' | 'center' | 'end') {
|
|
33
|
-
switch (position) {
|
|
34
|
-
case 'start':
|
|
35
|
-
return 'targetLeading';
|
|
36
|
-
case 'center':
|
|
37
|
-
return 'targetCenter';
|
|
38
|
-
case 'end':
|
|
39
|
-
return 'targetTrailing';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function getAuxiliaryPreviewConfig(position: 'start' | 'center' | 'end') {
|
|
44
|
-
return {
|
|
45
|
-
verticalAnchorPosition: 'automatic',
|
|
46
|
-
horizontalAlignment: getAuxiliaryPreviewPosition(position),
|
|
47
|
-
transitionConfigEntrance: {
|
|
48
|
-
mode: 'syncedToMenuEntranceTransition',
|
|
49
|
-
shouldAnimateSize: false,
|
|
50
|
-
},
|
|
51
|
-
transitionExitPreset: {
|
|
52
|
-
mode: 'zoomAndSlide',
|
|
53
|
-
},
|
|
54
|
-
} as const;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const ContextMenu = React.forwardRef<ContextMenuRef, ContextMenuProps>(
|
|
58
|
-
(
|
|
59
|
-
{
|
|
60
|
-
items,
|
|
61
|
-
title,
|
|
62
|
-
iOSItemSize = 'large',
|
|
63
|
-
onItemPress,
|
|
64
|
-
enabled = true,
|
|
65
|
-
iosRenderPreview,
|
|
66
|
-
iosOnPressMenuPreview,
|
|
67
|
-
renderAuxiliaryPreview,
|
|
68
|
-
auxiliaryPreviewPosition = 'start',
|
|
69
|
-
materialPortalHost: _materialPortalHost,
|
|
70
|
-
materialSideOffset: _materialSideOffset,
|
|
71
|
-
materialAlignOffset: _materialAlignOffset,
|
|
72
|
-
materialAlign: _materialAlign,
|
|
73
|
-
materialWidth: _materialWidth,
|
|
74
|
-
materialMinWidth: _materialMinWidth,
|
|
75
|
-
materialLoadingText: _materialLoadingText,
|
|
76
|
-
materialSubMenuTitlePlaceholder: _materialSubMenuTitlePlaceholder,
|
|
77
|
-
materialOverlayClassName: _materialOverlayClassName,
|
|
78
|
-
...props
|
|
79
|
-
},
|
|
80
|
-
ref
|
|
81
|
-
) => {
|
|
82
|
-
return (
|
|
83
|
-
<View>
|
|
84
|
-
<ContextMenuView
|
|
85
|
-
ref={ref as React.LegacyRef<ContextMenuView>}
|
|
86
|
-
isContextMenuEnabled={enabled}
|
|
87
|
-
menuConfig={toConfigMenu(items, iOSItemSize, title)}
|
|
88
|
-
onPressMenuItem={toOnPressMenuItem(onItemPress)}
|
|
89
|
-
onPressMenuPreview={iosOnPressMenuPreview}
|
|
90
|
-
shouldCleanupOnComponentWillUnmountForAuxPreview
|
|
91
|
-
previewConfig={!iosRenderPreview ? undefined : PREVIEW_CONFIG}
|
|
92
|
-
renderPreview={iosRenderPreview}
|
|
93
|
-
shouldPreventLongPressGestureFromPropagating
|
|
94
|
-
lazyPreview={!!iosRenderPreview}
|
|
95
|
-
auxiliaryPreviewConfig={
|
|
96
|
-
!renderAuxiliaryPreview
|
|
97
|
-
? undefined
|
|
98
|
-
: getAuxiliaryPreviewConfig(auxiliaryPreviewPosition)
|
|
99
|
-
}
|
|
100
|
-
isAuxiliaryPreviewEnabled={!!renderAuxiliaryPreview}
|
|
101
|
-
renderAuxiliaryPreview={renderAuxiliaryPreview}
|
|
102
|
-
{...props}
|
|
103
|
-
/>
|
|
104
|
-
</View>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
ContextMenu.displayName = 'ContextMenu';
|
|
110
|
-
|
|
111
|
-
export { ContextMenu };
|
|
112
|
-
|
|
113
|
-
function toOnPressMenuItem(onItemPress: ContextMenuProps['onItemPress']): OnPressMenuItemEvent {
|
|
114
|
-
return ({ nativeEvent, isUsingActionSheetFallback }) => {
|
|
115
|
-
onItemPress?.(
|
|
116
|
-
{
|
|
117
|
-
actionKey: nativeEvent.actionKey,
|
|
118
|
-
title: nativeEvent.actionTitle,
|
|
119
|
-
subTitle: nativeEvent.actionSubtitle,
|
|
120
|
-
state: nativeEvent.menuState ? { checked: nativeEvent.menuState === 'on' } : undefined,
|
|
121
|
-
destructive: nativeEvent.menuAttributes?.includes('destructive'),
|
|
122
|
-
disabled: nativeEvent.menuAttributes?.includes('disabled'),
|
|
123
|
-
hidden: nativeEvent.menuAttributes?.includes('hidden'),
|
|
124
|
-
keepOpenOnPress: nativeEvent.menuAttributes?.includes('keepsMenuPresented'),
|
|
125
|
-
loading: false,
|
|
126
|
-
},
|
|
127
|
-
isUsingActionSheetFallback
|
|
128
|
-
);
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function toConfigMenu(
|
|
133
|
-
items: ContextMenuConfig['items'],
|
|
134
|
-
iOSItemSize: ContextMenuConfig['iOSItemSize'],
|
|
135
|
-
title: ContextMenuConfig['title']
|
|
136
|
-
): MenuConfig {
|
|
137
|
-
return {
|
|
138
|
-
menuTitle: title ?? '',
|
|
139
|
-
menuPreferredElementSize: iOSItemSize,
|
|
140
|
-
menuItems: items.map((item) => {
|
|
141
|
-
if ('items' in item) {
|
|
142
|
-
return toConfigSubMenu(item);
|
|
143
|
-
}
|
|
144
|
-
return toConfigItem(item);
|
|
145
|
-
}),
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function toConfigSubMenu(subMenu: ContextSubMenu): MenuElementConfig {
|
|
150
|
-
if (subMenu.loading) {
|
|
151
|
-
return {
|
|
152
|
-
type: 'deferred',
|
|
153
|
-
deferredID: `${subMenu.title ?? ''}-${Date.now()}`,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
menuOptions: subMenu.iOSType === 'inline' ? ['displayInline'] : undefined,
|
|
158
|
-
menuTitle: subMenu.title ?? '',
|
|
159
|
-
menuSubtitle: subMenu.subTitle,
|
|
160
|
-
menuPreferredElementSize: subMenu.iOSItemSize,
|
|
161
|
-
menuItems: subMenu.items.map((item) => {
|
|
162
|
-
if ('items' in item) {
|
|
163
|
-
return toConfigSubMenu(item);
|
|
164
|
-
}
|
|
165
|
-
return toConfigItem(item);
|
|
166
|
-
}),
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function toConfigItem(item: ContextItem): MenuElementConfig {
|
|
171
|
-
if (item.loading) {
|
|
172
|
-
return {
|
|
173
|
-
type: 'deferred',
|
|
174
|
-
deferredID: `${item.actionKey}-deferred}`,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
const menuAttributes: MenuAttributes[] = [];
|
|
178
|
-
if (item.destructive) {
|
|
179
|
-
menuAttributes.push('destructive');
|
|
180
|
-
}
|
|
181
|
-
if (item.disabled) {
|
|
182
|
-
menuAttributes.push('disabled');
|
|
183
|
-
}
|
|
184
|
-
if (item.hidden) {
|
|
185
|
-
menuAttributes.push('hidden');
|
|
186
|
-
}
|
|
187
|
-
if (item.keepOpenOnPress) {
|
|
188
|
-
menuAttributes.push('keepsMenuPresented');
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
actionKey: item.actionKey,
|
|
192
|
-
actionTitle: item.title ?? '',
|
|
193
|
-
actionSubtitle: item.subTitle,
|
|
194
|
-
menuState: item.state?.checked ? 'on' : 'off',
|
|
195
|
-
menuAttributes,
|
|
196
|
-
discoverabilityTitle: item.subTitle,
|
|
197
|
-
icon: item?.image?.url
|
|
198
|
-
? {
|
|
199
|
-
type: 'IMAGE_REMOTE_URL',
|
|
200
|
-
imageValue: {
|
|
201
|
-
url: item.image.url,
|
|
202
|
-
},
|
|
203
|
-
imageOptions: {
|
|
204
|
-
cornerRadius: item.image.cornerRadius,
|
|
205
|
-
tint: item.image.tint,
|
|
206
|
-
},
|
|
207
|
-
}
|
|
208
|
-
: item.icon
|
|
209
|
-
? {
|
|
210
|
-
iconType: 'SYSTEM',
|
|
211
|
-
iconValue:
|
|
212
|
-
item.icon?.namingScheme === 'sfSymbol'
|
|
213
|
-
? item.icon.name ?? 'questionmark'
|
|
214
|
-
: item.icon.name && item.icon.name in ICON_MAPPING
|
|
215
|
-
? ICON_MAPPING[item.icon.name as MaterialIconName].sfSymbol
|
|
216
|
-
: 'questionmark',
|
|
217
|
-
iconTint: item.icon?.color,
|
|
218
|
-
}
|
|
219
|
-
: undefined,
|
|
220
|
-
};
|
|
221
|
-
}
|
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
import * as ContextMenuPrimitive from '@rn-primitives/context-menu';
|
|
2
|
-
import { useAugmentedRef, useRelativePosition } from '@rn-primitives/hooks';
|
|
3
|
-
import * as Haptics from 'expo-haptics';
|
|
4
|
-
import { Icon } from '@roninoss/icons';
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
import {
|
|
7
|
-
Image,
|
|
8
|
-
LayoutChangeEvent,
|
|
9
|
-
LayoutRectangle,
|
|
10
|
-
Pressable,
|
|
11
|
-
StyleSheet,
|
|
12
|
-
View,
|
|
13
|
-
ViewProps,
|
|
14
|
-
} from 'react-native';
|
|
15
|
-
import Animated, {
|
|
16
|
-
FadeIn,
|
|
17
|
-
FadeInLeft,
|
|
18
|
-
FadeOut,
|
|
19
|
-
FadeOutLeft,
|
|
20
|
-
LayoutAnimationConfig,
|
|
21
|
-
LinearTransition,
|
|
22
|
-
} from 'react-native-reanimated';
|
|
23
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
24
|
-
|
|
25
|
-
import { ContextItem, ContextMenuProps, ContextMenuRef, ContextSubMenu } from './types';
|
|
26
|
-
|
|
27
|
-
import { ActivityIndicator } from '~/components/nativewindui/ActivityIndicator';
|
|
28
|
-
import { Button } from '~/components/nativewindui/Button';
|
|
29
|
-
import { DropdownMenu } from '~/components/nativewindui/DropdownMenu';
|
|
30
|
-
import { Text } from '~/components/nativewindui/Text';
|
|
31
|
-
import { cn } from '~/lib/cn';
|
|
32
|
-
import { useColorScheme } from '~/lib/useColorScheme';
|
|
33
|
-
|
|
34
|
-
const ContextMenuContext = React.createContext<{
|
|
35
|
-
onItemPress: ContextMenuProps['onItemPress'];
|
|
36
|
-
dismissMenu?: () => void;
|
|
37
|
-
materialLoadingText: string;
|
|
38
|
-
materialSubMenuTitlePlaceholder: string;
|
|
39
|
-
subMenuRefs: React.MutableRefObject<ContextMenuRef[]>;
|
|
40
|
-
closeSubMenus: () => void;
|
|
41
|
-
} | null>(null);
|
|
42
|
-
|
|
43
|
-
const ROOT_DEFAULT_LAYOUT = {
|
|
44
|
-
height: 0,
|
|
45
|
-
width: 0,
|
|
46
|
-
pageX: 0,
|
|
47
|
-
pageY: 0,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const ContextMenu = React.forwardRef<ContextMenuRef, ContextMenuProps>(
|
|
51
|
-
(
|
|
52
|
-
{
|
|
53
|
-
items,
|
|
54
|
-
title,
|
|
55
|
-
iOSItemSize: _iOSItemSize,
|
|
56
|
-
onItemPress: onItemPressProp,
|
|
57
|
-
enabled = true,
|
|
58
|
-
children,
|
|
59
|
-
materialPortalHost,
|
|
60
|
-
materialSideOffset = 2,
|
|
61
|
-
materialAlignOffset,
|
|
62
|
-
materialAlign = 'center',
|
|
63
|
-
materialWidth,
|
|
64
|
-
materialMinWidth = 200,
|
|
65
|
-
materialLoadingText = 'Loading...',
|
|
66
|
-
materialSubMenuTitlePlaceholder = 'More ...',
|
|
67
|
-
iosRenderPreview: _iosRenderPreview,
|
|
68
|
-
iosOnPressMenuPreview: _iosOnPressMenuPreview,
|
|
69
|
-
renderAuxiliaryPreview,
|
|
70
|
-
auxiliaryPreviewPosition = 'start',
|
|
71
|
-
materialOverlayClassName,
|
|
72
|
-
...props
|
|
73
|
-
},
|
|
74
|
-
ref
|
|
75
|
-
) => {
|
|
76
|
-
const [rootLayout, setRootLayout] = React.useState(ROOT_DEFAULT_LAYOUT);
|
|
77
|
-
const [auxiliaryContentLayout, setAuxiliaryContentLayout] =
|
|
78
|
-
React.useState<LayoutRectangle | null>(null);
|
|
79
|
-
const [contentLayout, setContentLayout] = React.useState<LayoutRectangle | null>(null);
|
|
80
|
-
const subMenuRefs = React.useRef<ContextMenuRef[]>([]);
|
|
81
|
-
const insets = useSafeAreaInsets();
|
|
82
|
-
const triggerRef = React.useRef<ContextMenuPrimitive.ContextMenuTriggerRef>(null);
|
|
83
|
-
const rootRef = useAugmentedRef({
|
|
84
|
-
ref,
|
|
85
|
-
methods: {
|
|
86
|
-
presentMenu: () => {
|
|
87
|
-
triggerRef.current?.open();
|
|
88
|
-
},
|
|
89
|
-
dismissMenu,
|
|
90
|
-
},
|
|
91
|
-
deps: [triggerRef.current],
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const positionStyle = useRelativePosition({
|
|
95
|
-
align: auxiliaryPreviewPosition,
|
|
96
|
-
avoidCollisions: true,
|
|
97
|
-
triggerPosition: rootLayout,
|
|
98
|
-
contentLayout: auxiliaryContentLayout,
|
|
99
|
-
alignOffset: 0,
|
|
100
|
-
insets: {
|
|
101
|
-
top: insets.top,
|
|
102
|
-
right: 8,
|
|
103
|
-
bottom: insets.bottom + (contentLayout?.height ?? 0),
|
|
104
|
-
left: 8,
|
|
105
|
-
},
|
|
106
|
-
sideOffset: 4,
|
|
107
|
-
side: 'top',
|
|
108
|
-
disablePositioningStyle: false,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
function onLayout(event: LayoutChangeEvent) {
|
|
112
|
-
setAuxiliaryContentLayout(event.nativeEvent.layout);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function onTriggerLongPress() {
|
|
116
|
-
rootRef.current?.measure((_x, _y, width, height, pageX, pageY) => {
|
|
117
|
-
setRootLayout({ height, width, pageX, pageY });
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function closeSubMenus() {
|
|
122
|
-
for (const subMenuRef of subMenuRefs.current) {
|
|
123
|
-
subMenuRef.dismissMenu?.();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function onItemPress(item: Omit<ContextItem, 'icon'>) {
|
|
128
|
-
closeSubMenus();
|
|
129
|
-
onItemPressProp?.(item);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function dismissMenu() {
|
|
133
|
-
triggerRef.current?.close();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function onOpenChange(open: boolean) {
|
|
137
|
-
if (!open) {
|
|
138
|
-
setAuxiliaryContentLayout(null);
|
|
139
|
-
setContentLayout(null);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function onContentLayout(ev: LayoutChangeEvent) {
|
|
146
|
-
setContentLayout(ev.nativeEvent.layout);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<View>
|
|
151
|
-
<ContextMenuPrimitive.Root
|
|
152
|
-
ref={rootRef}
|
|
153
|
-
relativeTo="trigger"
|
|
154
|
-
onOpenChange={onOpenChange}
|
|
155
|
-
{...props}
|
|
156
|
-
collapsable={false}>
|
|
157
|
-
<ContextMenuPrimitive.Trigger ref={triggerRef} onLongPress={onTriggerLongPress} asChild>
|
|
158
|
-
{children}
|
|
159
|
-
</ContextMenuPrimitive.Trigger>
|
|
160
|
-
<ContextMenuPrimitive.Portal hostName={materialPortalHost}>
|
|
161
|
-
<ContextMenuContext.Provider
|
|
162
|
-
value={{
|
|
163
|
-
onItemPress,
|
|
164
|
-
dismissMenu,
|
|
165
|
-
materialLoadingText,
|
|
166
|
-
materialSubMenuTitlePlaceholder,
|
|
167
|
-
subMenuRefs,
|
|
168
|
-
closeSubMenus,
|
|
169
|
-
}}>
|
|
170
|
-
<ContextMenuPrimitive.Overlay style={StyleSheet.absoluteFill}>
|
|
171
|
-
<Animated.View
|
|
172
|
-
style={StyleSheet.absoluteFill}
|
|
173
|
-
entering={FadeIn}
|
|
174
|
-
exiting={FadeOut}
|
|
175
|
-
className={cn('bg-black/20', materialOverlayClassName)}>
|
|
176
|
-
{renderAuxiliaryPreview && contentLayout && (
|
|
177
|
-
<ContextMenuAuxiliaryPreview
|
|
178
|
-
onLayout={onLayout}
|
|
179
|
-
style={positionStyle}
|
|
180
|
-
children={renderAuxiliaryPreview()}
|
|
181
|
-
/>
|
|
182
|
-
)}
|
|
183
|
-
<ContextMenuPrimitive.Content
|
|
184
|
-
insets={{
|
|
185
|
-
top: insets.top,
|
|
186
|
-
right: 8,
|
|
187
|
-
bottom: insets.bottom,
|
|
188
|
-
left: 8,
|
|
189
|
-
}}
|
|
190
|
-
sideOffset={materialSideOffset}
|
|
191
|
-
alignOffset={materialAlignOffset}
|
|
192
|
-
align={materialAlign}
|
|
193
|
-
className={cn(!title && items.length === 0 && 'opacity-0')}
|
|
194
|
-
pointerEvents={!title && items.length === 0 ? 'none' : undefined}
|
|
195
|
-
onLayout={onContentLayout}>
|
|
196
|
-
<Animated.View
|
|
197
|
-
entering={FadeIn}
|
|
198
|
-
exiting={FadeOut}
|
|
199
|
-
style={{
|
|
200
|
-
minWidth: materialMinWidth,
|
|
201
|
-
width: materialWidth,
|
|
202
|
-
}}
|
|
203
|
-
className="border-border/20 bg-card z-50 rounded-md border py-2 shadow-xl">
|
|
204
|
-
{!!title && <ContextMenuLabel>{title}</ContextMenuLabel>}
|
|
205
|
-
<ContextMenuInnerContent items={items} />
|
|
206
|
-
</Animated.View>
|
|
207
|
-
</ContextMenuPrimitive.Content>
|
|
208
|
-
</Animated.View>
|
|
209
|
-
</ContextMenuPrimitive.Overlay>
|
|
210
|
-
</ContextMenuContext.Provider>
|
|
211
|
-
</ContextMenuPrimitive.Portal>
|
|
212
|
-
</ContextMenuPrimitive.Root>
|
|
213
|
-
</View>
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
ContextMenu.displayName = 'ContextMenu';
|
|
219
|
-
|
|
220
|
-
export { ContextMenu };
|
|
221
|
-
|
|
222
|
-
function useContextMenuContext() {
|
|
223
|
-
const context = React.useContext(ContextMenuContext);
|
|
224
|
-
if (!context) {
|
|
225
|
-
throw new Error(
|
|
226
|
-
'ContextMenu compound components cannot be rendered outside the ContextMenu component'
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
return context;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function ContextMenuAuxiliaryPreview({
|
|
233
|
-
style,
|
|
234
|
-
onLayout,
|
|
235
|
-
children,
|
|
236
|
-
}: Required<Pick<ViewProps, 'style' | 'onLayout' | 'children'>>) {
|
|
237
|
-
return (
|
|
238
|
-
<Pressable style={style} onLayout={onLayout}>
|
|
239
|
-
{children}
|
|
240
|
-
</Pressable>
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function ContextMenuInnerContent({ items }: { items: (ContextItem | ContextSubMenu)[] }) {
|
|
245
|
-
const { materialLoadingText } = useContextMenuContext();
|
|
246
|
-
const id = React.useId();
|
|
247
|
-
|
|
248
|
-
return (
|
|
249
|
-
<View>
|
|
250
|
-
{items.map((item, index) => {
|
|
251
|
-
if (item.loading) {
|
|
252
|
-
return (
|
|
253
|
-
<ContextMenuPrimitive.Item key={`loading:${id}-${item.title}-${index}`} asChild>
|
|
254
|
-
<Button
|
|
255
|
-
disabled
|
|
256
|
-
variant="plain"
|
|
257
|
-
className="h-12 justify-between gap-10 rounded-none px-3"
|
|
258
|
-
androidRootClassName="rounded-none ">
|
|
259
|
-
<Text className="font-normal opacity-60">{materialLoadingText}</Text>
|
|
260
|
-
<ActivityIndicator />
|
|
261
|
-
</Button>
|
|
262
|
-
</ContextMenuPrimitive.Item>
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
if ((item as Partial<ContextSubMenu>)?.items) {
|
|
266
|
-
const subMenu = item as ContextSubMenu;
|
|
267
|
-
if (subMenu.items.length === 0) return null;
|
|
268
|
-
return (
|
|
269
|
-
<ContextMenuSubMenu
|
|
270
|
-
title={subMenu.title}
|
|
271
|
-
subTitle={subMenu.subTitle}
|
|
272
|
-
items={subMenu.items}
|
|
273
|
-
key={`${id}-${subMenu.title}-${index}`}
|
|
274
|
-
/>
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
const contextMenuItem = item as ContextItem;
|
|
278
|
-
return <ContextMenuItem key={contextMenuItem.actionKey} {...contextMenuItem} />;
|
|
279
|
-
})}
|
|
280
|
-
</View>
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function ContextMenuLabel(props: { children: React.ReactNode }) {
|
|
285
|
-
return (
|
|
286
|
-
<ContextMenuPrimitive.Label className="text-muted-foreground/80 border-border/25 dark:border-border/80 dark:text-muted-foreground border-b px-3 pb-2 text-sm">
|
|
287
|
-
{props.children}
|
|
288
|
-
</ContextMenuPrimitive.Label>
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function ContextMenuItem(props: Omit<ContextItem, 'loading'>) {
|
|
293
|
-
const { colors } = useColorScheme();
|
|
294
|
-
const { onItemPress } = useContextMenuContext();
|
|
295
|
-
|
|
296
|
-
function onPress() {
|
|
297
|
-
onItemPress?.(props);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
if (props.hidden) return null;
|
|
301
|
-
|
|
302
|
-
return (
|
|
303
|
-
<LayoutAnimationConfig skipEntering skipExiting>
|
|
304
|
-
<ContextMenuPrimitive.Item
|
|
305
|
-
asChild
|
|
306
|
-
closeOnPress={!props.keepOpenOnPress}
|
|
307
|
-
role="checkbox"
|
|
308
|
-
accessibilityState={{
|
|
309
|
-
disabled: !!props.disabled,
|
|
310
|
-
checked: props.state?.checked,
|
|
311
|
-
}}>
|
|
312
|
-
<Button
|
|
313
|
-
variant={props.state?.checked ? 'tonal' : 'plain'}
|
|
314
|
-
className={cn(
|
|
315
|
-
'h-12 justify-between gap-10 rounded-none px-3',
|
|
316
|
-
!props.state && !props.title && 'justify-center px-4'
|
|
317
|
-
)}
|
|
318
|
-
androidRootClassName="rounded-none"
|
|
319
|
-
accessibilityHint={props.subTitle}
|
|
320
|
-
onPress={onPress}>
|
|
321
|
-
{!props.state && !props.title ? null : (
|
|
322
|
-
<View className="flex-row items-center gap-3 py-0.5">
|
|
323
|
-
{props.state?.checked && (
|
|
324
|
-
<Animated.View entering={FadeInLeft} exiting={FadeOutLeft}>
|
|
325
|
-
<Icon name="check" size={21} color={colors.foreground} />
|
|
326
|
-
</Animated.View>
|
|
327
|
-
)}
|
|
328
|
-
<Animated.View layout={LinearTransition}>
|
|
329
|
-
<Text
|
|
330
|
-
numberOfLines={1}
|
|
331
|
-
className={cn(
|
|
332
|
-
'font-normal',
|
|
333
|
-
props.destructive && 'text-destructive font-medium',
|
|
334
|
-
props.disabled && 'opacity-60'
|
|
335
|
-
)}>
|
|
336
|
-
{props.title}
|
|
337
|
-
</Text>
|
|
338
|
-
</Animated.View>
|
|
339
|
-
{props.state && !props.state?.checked && (
|
|
340
|
-
<Icon name="check" size={21} color="#00000000" />
|
|
341
|
-
)}
|
|
342
|
-
</View>
|
|
343
|
-
)}
|
|
344
|
-
{props.image ? (
|
|
345
|
-
<Image
|
|
346
|
-
source={{ uri: props.image.url }}
|
|
347
|
-
style={{
|
|
348
|
-
width: 22,
|
|
349
|
-
height: 22,
|
|
350
|
-
borderRadius:
|
|
351
|
-
typeof props.image.cornerRadius === 'number' && props.image.cornerRadius > 0
|
|
352
|
-
? props.image.cornerRadius / 4
|
|
353
|
-
: 0,
|
|
354
|
-
}}
|
|
355
|
-
/>
|
|
356
|
-
) : props.icon ? (
|
|
357
|
-
<Icon color={colors.foreground} {...props.icon} size={22} />
|
|
358
|
-
) : null}
|
|
359
|
-
</Button>
|
|
360
|
-
</ContextMenuPrimitive.Item>
|
|
361
|
-
</LayoutAnimationConfig>
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
const DEFAULT_LAYOUT = {
|
|
366
|
-
width: 0,
|
|
367
|
-
height: 0,
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
function ContextMenuSubMenu({ title, subTitle, items }: Omit<ContextSubMenu, 'loading'>) {
|
|
371
|
-
const { colors } = useColorScheme();
|
|
372
|
-
const {
|
|
373
|
-
onItemPress: onContextMenuItemPress,
|
|
374
|
-
dismissMenu,
|
|
375
|
-
materialSubMenuTitlePlaceholder,
|
|
376
|
-
subMenuRefs,
|
|
377
|
-
closeSubMenus,
|
|
378
|
-
} = useContextMenuContext();
|
|
379
|
-
const [triggerLayout, setTriggerLayout] = React.useState<typeof DEFAULT_LAYOUT>(DEFAULT_LAYOUT);
|
|
380
|
-
|
|
381
|
-
function onItemPress(item: Omit<ContextItem, 'icon'>) {
|
|
382
|
-
dismissMenu?.();
|
|
383
|
-
onContextMenuItemPress?.(item);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
function onLayout(ev: LayoutChangeEvent) {
|
|
387
|
-
setTriggerLayout(ev.nativeEvent.layout);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
function addSubMenuRef(ref: ContextMenuRef | null) {
|
|
391
|
-
if (!ref) return;
|
|
392
|
-
subMenuRefs.current.push(ref);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return (
|
|
396
|
-
<DropdownMenu
|
|
397
|
-
items={items}
|
|
398
|
-
materialAlign="start"
|
|
399
|
-
materialSideOffset={-triggerLayout.height}
|
|
400
|
-
materialAlignOffset={triggerLayout.width}
|
|
401
|
-
onItemPress={onItemPress}
|
|
402
|
-
materialMinWidth={48}
|
|
403
|
-
// @ts-expect-error internal prop
|
|
404
|
-
materialIsSubMenu
|
|
405
|
-
ref={addSubMenuRef}>
|
|
406
|
-
<Button
|
|
407
|
-
variant="plain"
|
|
408
|
-
className="justify-between gap-10 rounded-none px-3"
|
|
409
|
-
androidRootClassName="rounded-none"
|
|
410
|
-
onLayout={onLayout}
|
|
411
|
-
accessibilityHint={subTitle}
|
|
412
|
-
onPress={closeSubMenus}>
|
|
413
|
-
<Text numberOfLines={1} className="py-0.5 font-normal">
|
|
414
|
-
{title || materialSubMenuTitlePlaceholder}
|
|
415
|
-
</Text>
|
|
416
|
-
<Icon name="chevron-right" size={21} color={colors.grey} />
|
|
417
|
-
</Button>
|
|
418
|
-
</DropdownMenu>
|
|
419
|
-
);
|
|
420
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ContextMenu';
|