@react-native-menu/menu 1.1.6 → 1.2.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.
Files changed (56) hide show
  1. package/README.md +49 -1
  2. package/android/src/main/java/com/reactnativemenu/MenuOnCloseEvent.kt +13 -0
  3. package/android/src/main/java/com/reactnativemenu/MenuOnOpenEvent.kt +13 -0
  4. package/android/src/main/java/com/reactnativemenu/MenuView.kt +10 -0
  5. package/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt +89 -23
  6. package/ios/MenuViewManager.mm +8 -0
  7. package/ios/NewArch/FabricActionSheetView.swift +14 -2
  8. package/ios/NewArch/FabricMenuViewImplementation.swift +15 -1
  9. package/ios/NewArch/FabricViewImplementationProtocol.swift +5 -0
  10. package/ios/NewArch/MenuView.mm +39 -0
  11. package/ios/OldArch/LegacyActionSheetView.swift +17 -2
  12. package/ios/OldArch/LegacyMenuViewImplementation.swift +14 -0
  13. package/ios/Shared/ActionSheetView.swift +15 -3
  14. package/ios/Shared/MenuViewImplementation.swift +35 -15
  15. package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js +1 -1
  16. package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js.map +1 -1
  17. package/lib/commonjs/UIMenuView.android.js +19 -1
  18. package/lib/commonjs/UIMenuView.android.js.map +1 -1
  19. package/lib/commonjs/UIMenuView.js +0 -3
  20. package/lib/commonjs/UIMenuView.js.map +1 -1
  21. package/lib/commonjs/index.js +6 -8
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/commonjs/utils.js +1 -1
  24. package/lib/commonjs/utils.js.map +1 -1
  25. package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js +2 -2
  26. package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js.map +1 -1
  27. package/lib/module/UIMenuView.android.js +20 -2
  28. package/lib/module/UIMenuView.android.js.map +1 -1
  29. package/lib/module/UIMenuView.ios.js +1 -1
  30. package/lib/module/UIMenuView.js +1 -2
  31. package/lib/module/UIMenuView.js.map +1 -1
  32. package/lib/module/index.js +9 -8
  33. package/lib/module/index.js.map +1 -1
  34. package/lib/module/utils.js +1 -1
  35. package/lib/module/utils.js.map +1 -1
  36. package/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts +16 -2
  37. package/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts.map +1 -1
  38. package/lib/typescript/src/UIMenuView.android.d.ts +2 -3
  39. package/lib/typescript/src/UIMenuView.android.d.ts.map +1 -1
  40. package/lib/typescript/src/UIMenuView.d.ts +2 -2
  41. package/lib/typescript/src/UIMenuView.d.ts.map +1 -1
  42. package/lib/typescript/src/UIMenuView.ios.d.ts +1 -1
  43. package/lib/typescript/src/index.d.ts +22 -4
  44. package/lib/typescript/src/index.d.ts.map +1 -1
  45. package/lib/typescript/src/types.d.ts +20 -6
  46. package/lib/typescript/src/types.d.ts.map +1 -1
  47. package/lib/typescript/src/utils.d.ts +1 -1
  48. package/lib/typescript/src/utils.d.ts.map +1 -1
  49. package/package.json +10 -44
  50. package/src/NativeModuleSpecs/UIMenuNativeComponent.ts +48 -37
  51. package/src/UIMenuView.android.tsx +34 -4
  52. package/src/UIMenuView.ios.tsx +1 -1
  53. package/src/UIMenuView.tsx +11 -11
  54. package/src/index.tsx +42 -36
  55. package/src/types.ts +168 -153
  56. package/src/utils.ts +17 -17
@@ -1,9 +1,9 @@
1
1
  import type {
2
- DirectEventHandler,
3
- Int32,
4
- } from 'react-native/Libraries/Types/CodegenTypes';
5
- import type { HostComponent, ViewProps } from 'react-native';
6
- import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
+ DirectEventHandler,
3
+ Int32,
4
+ } from "react-native/Libraries/Types/CodegenTypes";
5
+ import type { HostComponent, ViewProps } from "react-native";
6
+ import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
7
7
  /*
8
8
  Caution, those below are not just typescript types.
9
9
  Codegen is using them to create the corresponding C++ data types.
@@ -12,44 +12,55 @@ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNati
12
12
  OR with extending types in an interface, so for now we'll just keep some duplicate
13
13
  types here, to avoid issues while `pod install` takes place.
14
14
  */
15
+
15
16
  type SubAction = {
16
- id?: string;
17
- title: string;
18
- titleColor?: Int32;
19
- subtitle?: string;
20
- state?: string;
21
- image?: string;
22
- imageColor?: Int32;
23
- displayInline?: boolean;
24
- attributes?: {
25
- destructive?: boolean;
26
- disabled?: boolean;
27
- hidden?: boolean;
28
- };
17
+ id?: string;
18
+ title: string;
19
+ titleColor?: Int32;
20
+ subtitle?: string;
21
+ state?: string;
22
+ image?: string;
23
+ imageColor?: Int32;
24
+ displayInline?: boolean;
25
+ attributes?: {
26
+ destructive?: boolean;
27
+ disabled?: boolean;
28
+ hidden?: boolean;
29
+ };
29
30
  };
30
31
  type MenuAction = {
31
- id?: string;
32
- title: string;
33
- titleColor?: Int32;
34
- subtitle?: string;
35
- state?: string;
36
- image?: string;
37
- imageColor?: Int32;
38
- displayInline?: boolean;
39
- attributes?: {
40
- destructive?: boolean;
41
- disabled?: boolean;
42
- hidden?: boolean;
43
- };
44
- subactions?: Array<SubAction>;
32
+ id?: string;
33
+ title: string;
34
+ titleColor?: Int32;
35
+ subtitle?: string;
36
+ state?: string;
37
+ image?: string;
38
+ imageColor?: Int32;
39
+ displayInline?: boolean;
40
+ attributes?: {
41
+ destructive?: boolean;
42
+ disabled?: boolean;
43
+ hidden?: boolean;
44
+ };
45
+ subactions?: Array<SubAction>;
45
46
  };
46
47
  export interface NativeProps extends ViewProps {
47
- onPressAction?: DirectEventHandler<{ event: string }>;
48
- actions: Array<MenuAction>;
49
- actionsHash: string; // just a workaround to make sure we don't have to manually compare MenuActions manually in C++ (since it's a struct and that's a pain)
50
- title?: string;
48
+ onPressAction?: DirectEventHandler<{ event: string }>;
49
+ onCloseMenu?: DirectEventHandler<{ event: string }>;
50
+ onOpenMenu?: DirectEventHandler<{ event: string }>;
51
+ actions: Array<MenuAction>;
52
+ actionsHash: string; // just a workaround to make sure we don't have to manually compare MenuActions manually in C++ (since it's a struct and that's a pain)
53
+ title?: string;
54
+ themeVariant?: string;
55
+ shouldOpenOnLongPress?: boolean;
56
+ hitSlop: {
57
+ top: Int32;
58
+ bottom: Int32;
59
+ left: Int32;
60
+ right: Int32;
61
+ };
51
62
  }
52
63
 
53
64
  export default codegenNativeComponent<NativeProps>(
54
- 'MenuView'
65
+ "MenuView",
55
66
  ) as HostComponent<NativeProps>;
@@ -1,8 +1,38 @@
1
- import { HostComponent, requireNativeComponent } from 'react-native';
2
- import type { NativeMenuComponentProps } from './types';
1
+ import {
2
+ findNodeHandle,
3
+ type HostComponent,
4
+ requireNativeComponent,
5
+ UIManager,
6
+ } from "react-native";
7
+ import type { MenuComponentRef, NativeMenuComponentProps } from "./types";
8
+ import { forwardRef, useImperativeHandle, useRef } from "react";
3
9
 
4
- const MenuComponent = requireNativeComponent(
5
- 'MenuView'
10
+ const NativeMenuComponent = requireNativeComponent(
11
+ "MenuView",
6
12
  ) as HostComponent<NativeMenuComponentProps>;
7
13
 
14
+ const MenuComponent = forwardRef<MenuComponentRef, NativeMenuComponentProps>(
15
+ (props, ref) => {
16
+ const nativeRef = useRef(null);
17
+
18
+ useImperativeHandle(
19
+ ref,
20
+ () => ({
21
+ show: () => {
22
+ if (nativeRef.current) {
23
+ const node = findNodeHandle(nativeRef.current);
24
+ const command =
25
+ UIManager.getViewManagerConfig("MenuView").Commands.show;
26
+
27
+ UIManager.dispatchViewManagerCommand(node, command, undefined);
28
+ }
29
+ },
30
+ }),
31
+ [],
32
+ );
33
+
34
+ return <NativeMenuComponent {...props} ref={nativeRef} />;
35
+ },
36
+ );
37
+
8
38
  export default MenuComponent;
@@ -1,3 +1,3 @@
1
- import UIMenuNativeComponent from './NativeModuleSpecs/UIMenuNativeComponent';
1
+ import UIMenuNativeComponent from "./NativeModuleSpecs/UIMenuNativeComponent";
2
2
 
3
3
  export default UIMenuNativeComponent;
@@ -1,20 +1,20 @@
1
- import * as React from 'react';
2
- import { View } from 'react-native';
3
- import type { NativeMenuComponentProps } from './types';
1
+ import type * as React from "react";
2
+ import { View } from "react-native";
3
+ import type { NativeMenuComponentProps } from "./types";
4
4
 
5
5
  /**
6
6
  * TODO: implement for Web
7
7
  */
8
8
  const MenuView: React.FC<React.PropsWithChildren<NativeMenuComponentProps>> = ({
9
- style,
10
- children,
11
- testID,
9
+ style,
10
+ children,
11
+ testID,
12
12
  }) => {
13
- return (
14
- <View style={style} testID={testID}>
15
- {children}
16
- </View>
17
- );
13
+ return (
14
+ <View style={style} testID={testID}>
15
+ {children}
16
+ </View>
17
+ );
18
18
  };
19
19
 
20
20
  export default MenuView;
package/src/index.tsx CHANGED
@@ -1,46 +1,52 @@
1
- import React, { useMemo } from 'react';
2
- import { processColor } from 'react-native';
1
+ import { forwardRef, useMemo } from "react";
2
+ import { processColor } from "react-native";
3
3
 
4
- import UIMenuView from './UIMenuView';
4
+ import UIMenuView from "./UIMenuView";
5
5
  import type {
6
- MenuComponentProps,
7
- MenuAction,
8
- ProcessedMenuAction,
9
- NativeActionEvent,
10
- } from './types';
11
- import { objectHash } from './utils';
6
+ MenuComponentProps,
7
+ MenuAction,
8
+ ProcessedMenuAction,
9
+ NativeActionEvent,
10
+ MenuComponentRef,
11
+ } from "./types";
12
+ import { objectHash } from "./utils";
12
13
 
13
14
  function processAction(action: MenuAction): ProcessedMenuAction {
14
- return {
15
- ...action,
16
- imageColor: processColor(action.imageColor),
17
- titleColor: processColor(action.titleColor),
18
- subactions: action.subactions?.map((subAction) => processAction(subAction)),
19
- };
15
+ return {
16
+ ...action,
17
+ imageColor: processColor(action.imageColor),
18
+ titleColor: processColor(action.titleColor),
19
+ subactions: action.subactions?.map((subAction) => processAction(subAction)),
20
+ };
20
21
  }
21
22
 
22
23
  const defaultHitslop = { top: 0, left: 0, bottom: 0, right: 0 };
23
24
 
24
- const MenuView: React.FC<MenuComponentProps> = ({
25
- actions,
26
- hitSlop = defaultHitslop,
27
- ...props
28
- }) => {
29
- const processedActions = actions.map<ProcessedMenuAction>((action) =>
30
- processAction(action)
31
- );
32
- const hash = useMemo(() => {
33
- return objectHash(processedActions);
34
- }, [processedActions]);
35
- return (
36
- <UIMenuView
37
- {...props}
38
- hitSlop={hitSlop}
39
- actions={processedActions}
40
- actionsHash={hash}
41
- />
42
- );
43
- };
25
+ const MenuView = forwardRef<MenuComponentRef, MenuComponentProps>(
26
+ ({ actions, hitSlop = defaultHitslop, ...props }, ref) => {
27
+ const processedActions = actions.map<ProcessedMenuAction>((action) =>
28
+ processAction(action),
29
+ );
30
+ const hash = useMemo(() => {
31
+ return objectHash(processedActions);
32
+ }, [processedActions]);
33
+
34
+ return (
35
+ <UIMenuView
36
+ {...props}
37
+ hitSlop={hitSlop}
38
+ actions={processedActions}
39
+ actionsHash={hash}
40
+ ref={ref}
41
+ />
42
+ );
43
+ },
44
+ );
44
45
 
45
46
  export { MenuView };
46
- export type { MenuComponentProps, MenuAction, NativeActionEvent };
47
+ export type {
48
+ MenuComponentProps,
49
+ MenuComponentRef,
50
+ MenuAction,
51
+ NativeActionEvent,
52
+ };
package/src/types.ts CHANGED
@@ -1,36 +1,36 @@
1
1
  import type {
2
- ColorValue,
3
- processColor,
4
- StyleProp,
5
- ViewStyle,
6
- } from 'react-native';
7
- import type * as React from 'react';
2
+ ColorValue,
3
+ processColor,
4
+ StyleProp,
5
+ ViewStyle,
6
+ } from "react-native";
7
+ import type * as React from "react";
8
8
 
9
9
  export type NativeActionEvent = {
10
- nativeEvent: {
11
- event: string;
12
- };
10
+ nativeEvent: {
11
+ event: string;
12
+ };
13
13
  };
14
14
 
15
15
  type MenuAttributes = {
16
- /**
17
- * An attribute indicating the destructive style.
18
- */
19
- destructive?: boolean;
20
- /**
21
- * An attribute indicating the disabled style.
22
- */
23
- disabled?: boolean;
24
- /**
25
- * An attribute indicating the hidden style.
26
- */
27
- hidden?: boolean;
28
- /**
29
- * (iOS16+ only)
30
- * @platform iOS
31
- * An attribute indicating that the menu should remain presented after firing.
32
- */
33
- keepsMenuPresented?: boolean;
16
+ /**
17
+ * An attribute indicating the destructive style.
18
+ */
19
+ destructive?: boolean;
20
+ /**
21
+ * An attribute indicating the disabled style.
22
+ */
23
+ disabled?: boolean;
24
+ /**
25
+ * An attribute indicating the hidden style.
26
+ */
27
+ hidden?: boolean;
28
+ /**
29
+ * (iOS16+ only)
30
+ * @platform iOS
31
+ * An attribute indicating that the menu should remain presented after firing.
32
+ */
33
+ keepsMenuPresented?: boolean;
34
34
  };
35
35
 
36
36
  /**
@@ -39,145 +39,160 @@ type MenuAttributes = {
39
39
  * - on: A constant indicating the menu element is in the “on” state.
40
40
  * - mixed: A constant indicating the menu element is in the “mixed” state.
41
41
  */
42
- type MenuState = 'off' | 'on' | 'mixed';
42
+ type MenuState = "off" | "on" | "mixed";
43
43
 
44
44
  export type MenuAction = {
45
- /**
46
- * Identifier of the menu action.
47
- * The value set in this id will be returned when menu is selected.
48
- */
49
- id?: string;
50
- /**
51
- * The action's title.
52
- */
53
- title: string;
54
- /**
55
- * (Android only)
56
- * The action's title color.
57
- * @platform Android
58
- */
59
- titleColor?: number | ColorValue;
60
- /**
61
- * (iOS14+ only)
62
- * An elaborated title that explains the purpose of the action.
63
- * @platform iOS
64
- */
65
- subtitle?: string;
66
- /**
67
- * The attributes indicating the style of the action.
68
- */
69
- attributes?: MenuAttributes;
70
- /**
71
- * (iOS14+ only)
72
- * The state of the action.
73
- * @platform iOS
74
- */
75
- state?: MenuState;
76
- /**
77
- * (Android and iOS13+ only)
78
- * - The action's image.
79
- * - Allows icon name included in project or system (Android) resources drawables and
80
- * in SF Symbol (iOS)
81
- * @example // (iOS)
82
- * image="plus"
83
- * @example // (Android)
84
- * image="ic_menu_add"
85
- * - TODO: Allow images other than those included in SF Symbol and resources drawables
86
- */
87
- image?: string;
88
- /**
89
- * (Android and iOS13+ only)
90
- * - The action's image color.
91
- */
92
- imageColor?: number | ColorValue;
93
- /**
94
- * (Android and iOS14+ only)
95
- * - Actions to be displayed in the sub menu
96
- * - On Android it does not support nesting next sub menus in sub menu item
97
- */
98
- subactions?: MenuAction[];
99
- /**
100
- * Whether subactions should be inline (separated by divider) or nested (sub menu)
101
- */
102
- displayInline?: boolean;
103
- /**
104
- * (iOS 16+ only)
105
- * The preferred size of this menu's child elements.
106
- * @platform iOS
107
- */
108
- preferredElementSize?: 'small' | 'medium' | 'large';
45
+ /**
46
+ * Identifier of the menu action.
47
+ * The value set in this id will be returned when menu is selected.
48
+ */
49
+ id?: string;
50
+ /**
51
+ * The action's title.
52
+ */
53
+ title: string;
54
+ /**
55
+ * (Android only)
56
+ * The action's title color.
57
+ * @platform Android
58
+ */
59
+ titleColor?: number | ColorValue;
60
+ /**
61
+ * (iOS14+ only)
62
+ * An elaborated title that explains the purpose of the action.
63
+ * @platform iOS
64
+ */
65
+ subtitle?: string;
66
+ /**
67
+ * The attributes indicating the style of the action.
68
+ */
69
+ attributes?: MenuAttributes;
70
+ /**
71
+ * (iOS14+ only)
72
+ * The state of the action.
73
+ * @platform iOS
74
+ */
75
+ state?: MenuState;
76
+ /**
77
+ * (Android and iOS13+ only)
78
+ * - The action's image.
79
+ * - Allows icon name included in project or system (Android) resources drawables and
80
+ * in SF Symbol (iOS)
81
+ * @example // (iOS)
82
+ * image="plus"
83
+ * @example // (Android)
84
+ * image="ic_menu_add"
85
+ * - TODO: Allow images other than those included in SF Symbol and resources drawables
86
+ */
87
+ image?: string;
88
+ /**
89
+ * (Android and iOS13+ only)
90
+ * - The action's image color.
91
+ */
92
+ imageColor?: number | ColorValue;
93
+ /**
94
+ * (Android and iOS14+ only)
95
+ * - Actions to be displayed in the sub menu
96
+ * - On Android it does not support nesting next sub menus in sub menu item
97
+ */
98
+ subactions?: MenuAction[];
99
+ /**
100
+ * Whether subactions should be inline (separated by divider) or nested (sub menu)
101
+ */
102
+ displayInline?: boolean;
103
+ /**
104
+ * (iOS 16+ only)
105
+ * The preferred size of this menu's child elements.
106
+ * @platform iOS
107
+ */
108
+ preferredElementSize?: "small" | "medium" | "large";
109
109
  };
110
110
 
111
111
  type MenuComponentPropsBase = {
112
- style?: StyleProp<ViewStyle>;
113
- /**
114
- * Callback function that will be called when selecting a menu item.
115
- * It will contain id of the given action.
116
- */
117
- onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;
118
- /**
119
- * Actions to be displayed in the menu.
120
- */
121
- actions: MenuAction[];
122
- /**
123
- * The title of the menu.
124
- */
125
- title?: string;
112
+ style?: StyleProp<ViewStyle>;
113
+ /**
114
+ * Callback function that will be called when selecting a menu item.
115
+ * It will contain id of the given action.
116
+ */
117
+ onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;
118
+ /**
119
+ * Callback function that will be called when the menu closes.
120
+ */
121
+ onCloseMenu?: () => void;
122
+ /**
123
+ * Callback function that will be called when the menu opens.
124
+ */
125
+ onOpenMenu?: () => void;
126
+ /**
127
+ * Actions to be displayed in the menu.
128
+ */
129
+ actions: MenuAction[];
130
+ /**
131
+ * The title of the menu.
132
+ */
133
+ title?: string;
126
134
 
127
- /**
128
- * (Android API 23+)
129
- * Boolean value determines whether popup menu should be anchored
130
- * to right corner of parent view - default value is `false`
131
- * @platform Android
132
- */
133
- isAnchoredToRight?: boolean;
134
- /**
135
- * Determines if menu should open after long press or on normal press
136
- *
137
- * @default false
138
- */
139
- shouldOpenOnLongPress?: boolean;
140
- /**
141
- * Overrides theme variant of menu to light mode, dark mode or system theme
142
- * (Only support iOS for now)
143
- *
144
- * @platform iOS
145
- */
146
- themeVariant?: string;
147
- /**
148
- * Custom OpenSpace hitSlop prop. Works like touchable hitslop.
149
- * @platform iOS
150
- */
151
- hitSlop?: {
152
- top: number;
153
- bottom: number;
154
- left: number;
155
- right: number;
156
- };
157
- /**
158
- * Test ID for testing purposes
159
- */
160
- testID?: string;
135
+ /**
136
+ * (Android API 23+)
137
+ * Boolean value determines whether popup menu should be anchored
138
+ * to right corner of parent view - default value is `false`
139
+ * @platform Android
140
+ */
141
+ isAnchoredToRight?: boolean;
142
+ /**
143
+ * Determines if menu should open after long press or on normal press
144
+ *
145
+ * @default false
146
+ */
147
+ shouldOpenOnLongPress?: boolean;
148
+ /**
149
+ * Overrides theme variant of menu to light mode, dark mode or system theme
150
+ * (Only support iOS for now)
151
+ *
152
+ * @platform iOS
153
+ */
154
+ themeVariant?: string;
155
+ /**
156
+ * Custom OpenSpace hitSlop prop. Works like touchable hitslop.
157
+ * @platform iOS
158
+ */
159
+ hitSlop?: {
160
+ top: number;
161
+ bottom: number;
162
+ left: number;
163
+ right: number;
164
+ };
165
+ /**
166
+ * Test ID for testing purposes
167
+ */
168
+ testID?: string;
161
169
  };
162
170
 
163
171
  export type MenuComponentProps =
164
- React.PropsWithChildren<MenuComponentPropsBase>;
172
+ React.PropsWithChildren<MenuComponentPropsBase>;
173
+
174
+ export type MenuComponentRef = {
175
+ show: () => void;
176
+ };
165
177
 
166
178
  export type ProcessedMenuAction = Omit<
167
- MenuAction,
168
- 'imageColor' | 'titleColor' | 'subactions'
179
+ MenuAction,
180
+ "imageColor" | "titleColor" | "subactions"
169
181
  > & {
170
- imageColor: ReturnType<typeof processColor>;
171
- titleColor: ReturnType<typeof processColor>;
172
- subactions?: ProcessedMenuAction[];
182
+ imageColor: ReturnType<typeof processColor>;
183
+ titleColor: ReturnType<typeof processColor>;
184
+ subactions?: ProcessedMenuAction[];
173
185
  };
174
186
 
175
187
  export type NativeMenuComponentProps = {
176
- style?: StyleProp<ViewStyle>;
177
- onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;
178
- actions: ProcessedMenuAction[];
179
- actionsHash: string;
180
- title?: string;
181
- hitSlop?: MenuComponentProps['hitSlop'];
182
- testID?: string;
188
+ style?: StyleProp<ViewStyle>;
189
+ onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;
190
+ onCloseMenu?: () => void;
191
+ onOpenMenu?: () => void;
192
+ actions: ProcessedMenuAction[];
193
+ actionsHash: string;
194
+ title?: string;
195
+ hitSlop?: MenuComponentProps["hitSlop"];
196
+ testID?: string;
197
+ ref?: React.ForwardedRef<MenuComponentRef>;
183
198
  };
package/src/utils.ts CHANGED
@@ -1,25 +1,25 @@
1
1
  // Function to calculate a simple hash code for a string
2
2
  function hashCode(str: string): number {
3
- let hash = 0;
4
- for (let i = 0; i < str.length; i++) {
5
- const char = str.charCodeAt(i);
6
- // eslint-disable-next-line no-bitwise
7
- hash = (hash << 5) - hash + char;
8
- }
9
- return hash;
3
+ let hash = 0;
4
+ for (let i = 0; i < str.length; i++) {
5
+ const char = str.charCodeAt(i);
6
+ // eslint-disable-next-line no-bitwise
7
+ hash = (hash << 5) - hash + char;
8
+ }
9
+ return hash;
10
10
  }
11
11
 
12
12
  // Function to create a string hash from a TypeScript object
13
- export function objectHash(obj: Record<string, any>): string {
14
- if (!obj) {
15
- return '';
16
- }
17
- // Convert the object to a JSON string
18
- const jsonString = JSON.stringify(obj);
13
+ export function objectHash(obj: Record<string, unknown>[]): string {
14
+ if (!obj) {
15
+ return "";
16
+ }
17
+ // Convert the object to a JSON string
18
+ const jsonString = JSON.stringify(obj);
19
19
 
20
- // Calculate the hash code of the JSON string
21
- const hash = hashCode(jsonString);
20
+ // Calculate the hash code of the JSON string
21
+ const hash = hashCode(jsonString);
22
22
 
23
- // Convert the hash code to a string (optional)
24
- return String(hash);
23
+ // Convert the hash code to a string (optional)
24
+ return String(hash);
25
25
  }