@oxy.so/bloom-lens 0.0.0-stage → 1.0.0
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/LICENSE +673 -0
- package/NOTICE +26 -0
- package/android/build.gradle +19 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/assets/fonts/Inter-OFL.txt +93 -0
- package/android/src/main/assets/fonts/Inter-Regular.ttf +0 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/220 +0 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/GlassMenuAndroidModule.kt +71 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/GlassMenuAndroidView.kt +548 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/backdrop/GlassBackdrop.kt +215 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/backdrop/GlassLens.kt +103 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/chrome/ChromeGeometry.kt +73 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/chrome/ChromeIcons.kt +74 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/chrome/ChromeMaterial.kt +74 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/chrome/GlassChromeHost.kt +73 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/chrome/GlassChromeModule.kt +31 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/chrome/GlassChromeView.kt +609 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/chrome/StaticGlassCache.kt +73 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/chrome/SurfaceIcons.kt +114 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/chrome/SurfaceNodesHost.kt +71 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/chrome/SurfaceNodesModule.kt +22 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/chrome/SurfaceNodesView.kt +527 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/content/GlassIcons.kt +68 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/content/GlassMenuContent.kt +349 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/content/GlassRow.kt +19 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/field/GlassFieldTexture.kt +102 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/field/GlassGaussianField.kt +161 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/field/GlassShapes.kt +37 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/field/RoundedField.kt +119 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/field/RoundedUnion.kt +81 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/motion/GlassGroup.kt +225 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/motion/GlassJelly.kt +118 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/motion/GlassMorphFrame.kt +22 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/motion/GlassMorphTuning.kt +31 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/motion/GlassMotion.kt +475 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/motion/GlassSpring.kt +78 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/overlay/GlassDevGuard.kt +31 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/overlay/GlassFeedback.kt +18 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/overlay/GlassMenuOverlay.kt +433 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/overlay/GlassMenuSession.kt +750 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/overlay/GlassScrub.kt +41 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/overlay/GlassSubmenuLayer.kt +290 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/records/GlassAbsorbRecord.kt +9 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/records/GlassMemberRecord.kt +14 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/records/GlassMenuConfigRecord.kt +24 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/records/GlassMenuItemRecord.kt +23 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/records/GlassShrinkRecord.kt +10 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/records/GlassTriggerConfigRecord.kt +19 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/render/GlassRecipe.kt +18 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/render/GlassRenderer.kt +361 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/render/GlassShaders.kt +318 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/render/GlassStill.kt +115 -0
- package/android/src/main/java/so/oxy/bloom/glassmenu/render/GlassSurfaceState.kt +38 -0
- package/expo-module.config.json +10 -0
- package/package.json +29 -4
- package/patches/bloom.patch +1908 -0
- package/patches/menu/bloom.patch +148 -0
- package/src/base.tsx +208 -0
- package/src/chrome/compositor-geometry.ts +163 -0
- package/src/chrome/glass-header.tsx +155 -0
- package/src/chrome/glass-search-fab.tsx +113 -0
- package/src/chrome/glass-size-class.tsx +150 -0
- package/src/chrome/glass-toolbar.tsx +45 -0
- package/src/chrome/interface.ts +17 -0
- package/src/chrome/ios-tab-bar.tsx +49 -0
- package/src/chrome/surface-layer.ts +91 -0
- package/src/chrome/surface-nodes.tsx +54 -0
- package/src/index.ts +19 -0
- package/src/menu/components/menu/index.ts +22 -0
- package/src/menu/components/menu/menu.tsx +97 -0
- package/src/menu/components/menu-action-row/index.ts +1 -0
- package/src/menu/components/menu-action-row/menu-action-row.tsx +12 -0
- package/src/menu/components/menu-content/index.ts +2 -0
- package/src/menu/components/menu-content/menu-content.tsx +11 -0
- package/src/menu/components/menu-item/index.ts +13 -0
- package/src/menu/components/menu-item/menu-item-icon.tsx +10 -0
- package/src/menu/components/menu-item/menu-item-subtitle.tsx +14 -0
- package/src/menu/components/menu-item/menu-item-title.tsx +11 -0
- package/src/menu/components/menu-item/menu-item.tsx +11 -0
- package/src/menu/components/menu-label/index.ts +3 -0
- package/src/menu/components/menu-label/menu-label.tsx +11 -0
- package/src/menu/components/menu-separator/index.ts +3 -0
- package/src/menu/components/menu-separator/menu-separator.tsx +7 -0
- package/src/menu/components/menu-submenu/index.ts +1 -0
- package/src/menu/components/menu-submenu/menu-submenu.tsx +12 -0
- package/src/menu/components/menu-trigger/index.ts +3 -0
- package/src/menu/components/menu-trigger/interface.ts +41 -0
- package/src/menu/components/menu-trigger/menu-trigger.android.tsx +97 -0
- package/src/menu/components/menu-trigger/menu-trigger.tsx +15 -0
- package/src/menu/components/menu-trigger/native-menu.android.ts +9 -0
- package/src/menu/components/menu-trigger-button/index.ts +3 -0
- package/src/menu/components/menu-trigger-button/menu-trigger-button.android.tsx +38 -0
- package/src/menu/components/menu-trigger-button/menu-trigger-button.tsx +17 -0
- package/src/menu/constants/interface.ts +6 -0
- package/src/menu/constants/menu.const.ts +11 -0
- package/src/menu/context/interface.ts +63 -0
- package/src/menu/context/menu.context.ts +7 -0
- package/src/menu/index.ts +53 -0
- package/src/menu/interface.ts +229 -0
- package/src/menu/utils/create-compound-component.util.ts +18 -0
- package/src/menu/utils/find-menu-content.util.ts +17 -0
- package/src/menu/utils/flatten-elements.util.ts +18 -0
- package/src/menu/utils/parse-menu-content.util.ts +98 -0
- package/src/menu/utils/parse-menu-item.util.ts +56 -0
- package/src/menu/utils/register-component.util.ts +13 -0
- package/src/menu/utils/to-native-item.util.ts +24 -0
- package/src/rows.tsx +61 -0
- package/README.md +0 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { IMenuContent } from "../../interface";
|
|
3
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
4
|
+
|
|
5
|
+
const MenuContentBase: FC<IMenuContent> = (
|
|
6
|
+
_props: IMenuContent & React.ComponentProps<typeof MenuContentBase>,
|
|
7
|
+
): React.ReactNode & React.JSX.Element => <></>;
|
|
8
|
+
|
|
9
|
+
const MenuContent = registerComponent("MenuContent", MenuContentBase);
|
|
10
|
+
|
|
11
|
+
export { MenuContent };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createCompoundComponent } from "../../utils/create-compound-component.util";
|
|
2
|
+
import { MenuItem as MenuItemPart } from "./menu-item";
|
|
3
|
+
import { MenuItemIcon } from "./menu-item-icon";
|
|
4
|
+
import { MenuItemSubtitle } from "./menu-item-subtitle";
|
|
5
|
+
import { MenuItemTitle } from "./menu-item-title";
|
|
6
|
+
|
|
7
|
+
const MenuItem = createCompoundComponent("MenuItem", MenuItemPart, {
|
|
8
|
+
Icon: MenuItemIcon,
|
|
9
|
+
Title: MenuItemTitle,
|
|
10
|
+
Subtitle: MenuItemSubtitle,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { MenuItem };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { IMenuItemIcon } from "../../interface";
|
|
3
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
4
|
+
const MenuItemIconBase: FC<IMenuItemIcon> = (
|
|
5
|
+
_props: IMenuItemIcon & React.ComponentProps<typeof MenuItemIconBase>,
|
|
6
|
+
): React.ReactNode & React.JSX.Element => <></>;
|
|
7
|
+
|
|
8
|
+
const MenuItemIcon = registerComponent("MenuItemIcon", MenuItemIconBase);
|
|
9
|
+
|
|
10
|
+
export { MenuItemIcon };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { IMenuItemText } from "../../interface";
|
|
3
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
4
|
+
|
|
5
|
+
const MenuItemSubtitleBase: FC<IMenuItemText> = (
|
|
6
|
+
_props: IMenuItemText & React.ComponentProps<typeof MenuItemSubtitleBase>,
|
|
7
|
+
): React.ReactNode & React.JSX.Element => <></>;
|
|
8
|
+
|
|
9
|
+
const MenuItemSubtitle = registerComponent(
|
|
10
|
+
"MenuItemSubtitle",
|
|
11
|
+
MenuItemSubtitleBase,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export { MenuItemSubtitle };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { IMenuItemText } from "../../interface";
|
|
3
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
4
|
+
|
|
5
|
+
const MenuItemTitleBase: FC<IMenuItemText> = (
|
|
6
|
+
_props: IMenuItemText & React.ComponentProps<typeof MenuItemTitleBase>,
|
|
7
|
+
): React.ReactNode & React.JSX.Element => <></>;
|
|
8
|
+
|
|
9
|
+
const MenuItemTitle = registerComponent("MenuItemTitle", MenuItemTitleBase);
|
|
10
|
+
|
|
11
|
+
export { MenuItemTitle };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { IMenuItem } from "../../interface";
|
|
3
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
4
|
+
|
|
5
|
+
const MenuItemBase: FC<IMenuItem> = (
|
|
6
|
+
_props: IMenuItem & React.ComponentProps<typeof MenuItemBase>,
|
|
7
|
+
): React.ReactNode & React.JSX.Element => <></>;
|
|
8
|
+
|
|
9
|
+
const MenuItem = registerComponent("MenuItem", MenuItemBase);
|
|
10
|
+
|
|
11
|
+
export { MenuItem };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { IMenuLabel } from "../../interface";
|
|
3
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
4
|
+
|
|
5
|
+
const MenuLabelBase: FC<IMenuLabel> = (
|
|
6
|
+
_props: IMenuLabel & React.ComponentProps<typeof MenuLabelBase>,
|
|
7
|
+
): React.ReactNode & React.JSX.Element => <></>;
|
|
8
|
+
|
|
9
|
+
const MenuLabel = registerComponent("MenuLabel", MenuLabelBase);
|
|
10
|
+
|
|
11
|
+
export { MenuLabel };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
3
|
+
|
|
4
|
+
const MenuSeparatorBase: FC = (): React.ReactNode & React.JSX.Element => <></>;
|
|
5
|
+
const MenuSeparator = registerComponent("MenuSeparator", MenuSeparatorBase);
|
|
6
|
+
|
|
7
|
+
export { MenuSeparator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MenuSubmenu } from "./menu-submenu";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { ISubmenu } from "../../interface";
|
|
3
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
4
|
+
|
|
5
|
+
// Declarative only: parseMenuContent reads its props and children (Menu.Item entries).
|
|
6
|
+
const MenuSubmenuBase: FC<ISubmenu> = (
|
|
7
|
+
_props: ISubmenu & React.ComponentProps<typeof MenuSubmenuBase>,
|
|
8
|
+
): React.ReactNode & React.JSX.Element => <></>;
|
|
9
|
+
|
|
10
|
+
const MenuSubmenu = registerComponent("MenuSubmenu", MenuSubmenuBase);
|
|
11
|
+
|
|
12
|
+
export { MenuSubmenu };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from "react";
|
|
2
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
INativeMenuHandle,
|
|
6
|
+
TNativeMenuItem,
|
|
7
|
+
} from "../../context/interface";
|
|
8
|
+
import type {
|
|
9
|
+
TMenuAlignment,
|
|
10
|
+
TMenuConfig,
|
|
11
|
+
TMenuGroupMember,
|
|
12
|
+
TMenuScheme,
|
|
13
|
+
TMenuSelectEvent,
|
|
14
|
+
TMenuTriggerConfig,
|
|
15
|
+
} from "../../interface";
|
|
16
|
+
|
|
17
|
+
interface INativeMenu {
|
|
18
|
+
ref?: Ref<INativeMenuHandle>;
|
|
19
|
+
items: TNativeMenuItem[];
|
|
20
|
+
onItemSelect?: (event: { nativeEvent: TMenuSelectEvent }) => void;
|
|
21
|
+
onMenuOpenChange?: (event: { nativeEvent: { open: boolean } }) => void;
|
|
22
|
+
lens?: boolean;
|
|
23
|
+
morph?: boolean;
|
|
24
|
+
cornerRadius?: number;
|
|
25
|
+
colorScheme?: TMenuScheme;
|
|
26
|
+
menuWidth?: number;
|
|
27
|
+
fontFamily?: string;
|
|
28
|
+
alignment?: TMenuAlignment;
|
|
29
|
+
config?: TMenuConfig;
|
|
30
|
+
triggerConfig?: TMenuTriggerConfig;
|
|
31
|
+
openWithItems?: boolean;
|
|
32
|
+
restBackdrop?: string;
|
|
33
|
+
openOnTap?: boolean;
|
|
34
|
+
members?: readonly TMenuGroupMember[];
|
|
35
|
+
blend?: number;
|
|
36
|
+
onMenuClosed?: () => void;
|
|
37
|
+
style?: StyleProp<ViewStyle>;
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { type INativeMenu };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useContext, type FC, type ReactNode } from "react";
|
|
2
|
+
import { Pressable, StyleSheet, View } from "react-native";
|
|
3
|
+
import { MENU_ICON_HOST_ID } from "../../constants/menu.const";
|
|
4
|
+
import type { IMenuContext } from "../../context/interface";
|
|
5
|
+
import { MenuContext } from "../../context/menu.context";
|
|
6
|
+
import type { IMenuTrigger, TMenuSelectEvent } from "../../interface";
|
|
7
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
8
|
+
import { NativeMenu } from "./native-menu.android";
|
|
9
|
+
|
|
10
|
+
const MenuTriggerBase: FC<IMenuTrigger> = ({
|
|
11
|
+
lens,
|
|
12
|
+
morph,
|
|
13
|
+
cornerRadius,
|
|
14
|
+
config,
|
|
15
|
+
openOnPress = true,
|
|
16
|
+
openWithItems,
|
|
17
|
+
onMenuClosed,
|
|
18
|
+
restBackdrop,
|
|
19
|
+
openOnTap,
|
|
20
|
+
members,
|
|
21
|
+
blend,
|
|
22
|
+
accessibilityLabel,
|
|
23
|
+
style,
|
|
24
|
+
children,
|
|
25
|
+
}: IMenuTrigger &
|
|
26
|
+
React.ComponentProps<typeof MenuTriggerBase>): React.ReactNode &
|
|
27
|
+
React.JSX.Element => {
|
|
28
|
+
const menu = useContext<IMenuContext | null>(MenuContext);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<NativeMenu
|
|
32
|
+
ref={menu?.native}
|
|
33
|
+
items={menu?.items ?? []}
|
|
34
|
+
colorScheme={menu?.scheme}
|
|
35
|
+
menuWidth={menu?.content.width}
|
|
36
|
+
fontFamily={menu?.content.fontFamily}
|
|
37
|
+
alignment={menu?.content.alignment}
|
|
38
|
+
config={menu?.content.config}
|
|
39
|
+
lens={lens}
|
|
40
|
+
morph={morph}
|
|
41
|
+
cornerRadius={cornerRadius}
|
|
42
|
+
triggerConfig={config}
|
|
43
|
+
openWithItems={openWithItems}
|
|
44
|
+
onMenuClosed={onMenuClosed}
|
|
45
|
+
restBackdrop={restBackdrop}
|
|
46
|
+
openOnTap={openOnTap}
|
|
47
|
+
members={members}
|
|
48
|
+
blend={blend}
|
|
49
|
+
style={style}
|
|
50
|
+
onItemSelect={(event: { nativeEvent: TMenuSelectEvent }): void =>
|
|
51
|
+
menu?.select(event.nativeEvent)
|
|
52
|
+
}
|
|
53
|
+
onMenuOpenChange={(event: { nativeEvent: { open: boolean } }): void =>
|
|
54
|
+
menu?.openChange?.(event.nativeEvent.open)
|
|
55
|
+
}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
{openOnPress ? (
|
|
59
|
+
<Pressable
|
|
60
|
+
accessibilityRole="button"
|
|
61
|
+
accessibilityLabel={accessibilityLabel}
|
|
62
|
+
style={StyleSheet.absoluteFill}
|
|
63
|
+
onPress={() => menu?.handle.open()}
|
|
64
|
+
/>
|
|
65
|
+
) : null}
|
|
66
|
+
<View
|
|
67
|
+
nativeID={MENU_ICON_HOST_ID}
|
|
68
|
+
collapsable={false}
|
|
69
|
+
pointerEvents="none"
|
|
70
|
+
style={styles.iconHost}
|
|
71
|
+
>
|
|
72
|
+
{(menu?.icons ?? []).map(
|
|
73
|
+
(icon: ReactNode, index: number): React.JSX.Element => (
|
|
74
|
+
<View key={index} collapsable={false} style={styles.iconSlot}>
|
|
75
|
+
{icon}
|
|
76
|
+
</View>
|
|
77
|
+
),
|
|
78
|
+
)}
|
|
79
|
+
</View>
|
|
80
|
+
</NativeMenu>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const styles = StyleSheet.create({
|
|
85
|
+
iconHost: {
|
|
86
|
+
position: "absolute",
|
|
87
|
+
left: 0,
|
|
88
|
+
top: 0,
|
|
89
|
+
},
|
|
90
|
+
iconSlot: {
|
|
91
|
+
alignSelf: "flex-start",
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const MenuTrigger = registerComponent("MenuTrigger", MenuTriggerBase);
|
|
96
|
+
|
|
97
|
+
export { MenuTrigger };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import type { IMenuTrigger } from "../../interface";
|
|
4
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
5
|
+
|
|
6
|
+
const MenuTriggerBase: FC<IMenuTrigger> = ({
|
|
7
|
+
style,
|
|
8
|
+
children,
|
|
9
|
+
}: IMenuTrigger &
|
|
10
|
+
React.ComponentProps<typeof MenuTriggerBase>): React.ReactNode &
|
|
11
|
+
React.JSX.Element => <View style={style}>{children}</View>;
|
|
12
|
+
|
|
13
|
+
const MenuTrigger = registerComponent("MenuTrigger", MenuTriggerBase);
|
|
14
|
+
|
|
15
|
+
export { MenuTrigger };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { requireNativeView } from "expo";
|
|
2
|
+
import type { ComponentType } from "react";
|
|
3
|
+
import { MENU_NATIVE_VIEW } from "../../constants/menu.const";
|
|
4
|
+
import type { INativeMenu } from "./interface";
|
|
5
|
+
|
|
6
|
+
const NativeMenu: ComponentType<INativeMenu> =
|
|
7
|
+
requireNativeView<INativeMenu>(MENU_NATIVE_VIEW);
|
|
8
|
+
|
|
9
|
+
export { NativeMenu };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useContext, useRef, type ComponentRef, type FC } from "react";
|
|
2
|
+
import { Pressable, type GestureResponderEvent } from "react-native";
|
|
3
|
+
import type { IMenuContext } from "../../context/interface";
|
|
4
|
+
import { MenuContext } from "../../context/menu.context";
|
|
5
|
+
import type { TMenuTriggerButton } from "../../interface";
|
|
6
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
7
|
+
|
|
8
|
+
const MenuTriggerButtonBase: FC<TMenuTriggerButton> = ({
|
|
9
|
+
onPress,
|
|
10
|
+
...rest
|
|
11
|
+
}: TMenuTriggerButton &
|
|
12
|
+
React.ComponentProps<typeof MenuTriggerButtonBase>): React.ReactNode &
|
|
13
|
+
React.JSX.Element => {
|
|
14
|
+
const menu = useContext<IMenuContext | null>(MenuContext);
|
|
15
|
+
const button = useRef<ComponentRef<typeof Pressable> | null>(null);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Pressable
|
|
19
|
+
accessibilityRole="button"
|
|
20
|
+
{...rest}
|
|
21
|
+
ref={button}
|
|
22
|
+
onPress={(event: GestureResponderEvent) => {
|
|
23
|
+
onPress?.(event);
|
|
24
|
+
button.current?.measureInWindow(
|
|
25
|
+
(x: number, y: number, width: number, height: number) =>
|
|
26
|
+
menu?.handle.open({ x, y, width, height }),
|
|
27
|
+
);
|
|
28
|
+
}}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const MenuTriggerButton = registerComponent(
|
|
34
|
+
"MenuTriggerButton",
|
|
35
|
+
MenuTriggerButtonBase,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export { MenuTriggerButton };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import { Pressable } from "react-native";
|
|
3
|
+
|
|
4
|
+
import type { TMenuTriggerButton } from "../../interface";
|
|
5
|
+
import { registerComponent } from "../../utils/register-component.util";
|
|
6
|
+
|
|
7
|
+
const MenuTriggerButtonBase: FC<TMenuTriggerButton> = (
|
|
8
|
+
props: TMenuTriggerButton &
|
|
9
|
+
React.ComponentProps<typeof MenuTriggerButtonBase>,
|
|
10
|
+
): React.ReactNode & React.JSX.Element => <Pressable {...props} />;
|
|
11
|
+
|
|
12
|
+
const MenuTriggerButton = registerComponent(
|
|
13
|
+
"MenuTriggerButton",
|
|
14
|
+
MenuTriggerButtonBase,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export { MenuTriggerButton };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TMenuScheme } from "../interface";
|
|
2
|
+
import type { TMenuIconColors } from "./interface";
|
|
3
|
+
|
|
4
|
+
const MENU_ICON_COLORS: Record<TMenuScheme, TMenuIconColors> = {
|
|
5
|
+
dark: { base: "rgba(255, 255, 255, 0.96)", destructive: "#FF5254" },
|
|
6
|
+
light: { base: "rgba(0, 0, 0, 0.92)", destructive: "#DC1E30" },
|
|
7
|
+
};
|
|
8
|
+
const MENU_ICON_HOST_ID: string = "lens-icons";
|
|
9
|
+
const MENU_NATIVE_VIEW: string = "BloomLensMenu";
|
|
10
|
+
|
|
11
|
+
export { MENU_ICON_COLORS, MENU_ICON_HOST_ID, MENU_NATIVE_VIEW };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ReactNode, RefObject } from "react";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
IMenuContent,
|
|
5
|
+
IMenuHandle,
|
|
6
|
+
TMenuScheme,
|
|
7
|
+
TMenuSelectEvent,
|
|
8
|
+
} from "../interface";
|
|
9
|
+
|
|
10
|
+
type TNativeMenuItem = {
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
subtitle?: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
iconPath?: string;
|
|
16
|
+
iconSlot?: number;
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
destructive?: boolean;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
keepOpen?: boolean;
|
|
21
|
+
separator?: boolean;
|
|
22
|
+
heading?: boolean;
|
|
23
|
+
// The action cells of an action row (icon actions, one cell each). Null for every other row.
|
|
24
|
+
actions?: TNativeMenuItem[];
|
|
25
|
+
// Present on submenu rows: the child items (a chevron row).
|
|
26
|
+
items?: TNativeMenuItem[];
|
|
27
|
+
// The header row of a submenu panel: returns to the parent panel.
|
|
28
|
+
back?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
interface INativeMenuHandle {
|
|
32
|
+
open: (
|
|
33
|
+
x?: number,
|
|
34
|
+
y?: number,
|
|
35
|
+
width?: number,
|
|
36
|
+
height?: number,
|
|
37
|
+
) => Promise<void>;
|
|
38
|
+
close: () => Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type TParsedMenu = {
|
|
42
|
+
items: TNativeMenuItem[];
|
|
43
|
+
icons: ReactNode[];
|
|
44
|
+
handlers: Record<string, () => void>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
interface IMenuContext {
|
|
48
|
+
handle: IMenuHandle;
|
|
49
|
+
native: RefObject<INativeMenuHandle | null>;
|
|
50
|
+
scheme: TMenuScheme;
|
|
51
|
+
items: TNativeMenuItem[];
|
|
52
|
+
icons: ReactNode[];
|
|
53
|
+
content: Omit<IMenuContent, "items" | "children">;
|
|
54
|
+
select: (event: TMenuSelectEvent) => void;
|
|
55
|
+
openChange?: (open: boolean) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
type IMenuContext,
|
|
60
|
+
type INativeMenuHandle,
|
|
61
|
+
type TNativeMenuItem,
|
|
62
|
+
type TParsedMenu,
|
|
63
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Menu } from "./components/menu";
|
|
2
|
+
import type {
|
|
3
|
+
IMenu,
|
|
4
|
+
IMenuContent,
|
|
5
|
+
IMenuHandle,
|
|
6
|
+
IMenuItem,
|
|
7
|
+
IMenuItemIcon,
|
|
8
|
+
IMenuItemText,
|
|
9
|
+
IMenuLabel,
|
|
10
|
+
IMenuTrigger,
|
|
11
|
+
TMenuAbsorb,
|
|
12
|
+
TMenuAction,
|
|
13
|
+
TMenuAlignment,
|
|
14
|
+
TMenuColorScheme,
|
|
15
|
+
TMenuConfig,
|
|
16
|
+
TMenuEntry,
|
|
17
|
+
TMenuIconName,
|
|
18
|
+
TMenuItemIconState,
|
|
19
|
+
TMenuMorphOrigin,
|
|
20
|
+
TMenuRect,
|
|
21
|
+
TMenuScheme,
|
|
22
|
+
TMenuSelectEvent,
|
|
23
|
+
TMenuShrink,
|
|
24
|
+
TMenuTriggerButton,
|
|
25
|
+
TMenuTriggerConfig,
|
|
26
|
+
} from "./interface";
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
Menu,
|
|
30
|
+
type IMenu,
|
|
31
|
+
type IMenuContent,
|
|
32
|
+
type IMenuHandle,
|
|
33
|
+
type IMenuItem,
|
|
34
|
+
type IMenuItemIcon,
|
|
35
|
+
type IMenuItemText,
|
|
36
|
+
type IMenuLabel,
|
|
37
|
+
type IMenuTrigger,
|
|
38
|
+
type TMenuAbsorb,
|
|
39
|
+
type TMenuAction,
|
|
40
|
+
type TMenuAlignment,
|
|
41
|
+
type TMenuColorScheme,
|
|
42
|
+
type TMenuConfig,
|
|
43
|
+
type TMenuEntry,
|
|
44
|
+
type TMenuIconName,
|
|
45
|
+
type TMenuItemIconState,
|
|
46
|
+
type TMenuMorphOrigin,
|
|
47
|
+
type TMenuRect,
|
|
48
|
+
type TMenuScheme,
|
|
49
|
+
type TMenuSelectEvent,
|
|
50
|
+
type TMenuShrink,
|
|
51
|
+
type TMenuTriggerButton,
|
|
52
|
+
type TMenuTriggerConfig,
|
|
53
|
+
};
|