@react-native-menu/menu 1.1.5 → 1.1.7

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 (52) hide show
  1. package/README.md +15 -1
  2. package/android/build.gradle +40 -0
  3. package/android/src/main/java/com/reactnativemenu/MenuView.kt +41 -3
  4. package/android/src/main/java/com/reactnativemenu/{MenuViewManager.kt → MenuViewManagerBase.kt} +14 -8
  5. package/android/src/reactNativeVersionPatch/MenuViewManager/75/com/reactnativemenu/MenuViewManager.kt +17 -0
  6. package/android/src/reactNativeVersionPatch/MenuViewManager/latest/com/reactnativemenu/MenuViewManager.kt +14 -0
  7. package/ios/NewArch/FabricViewImplementationProtocol.swift +3 -0
  8. package/ios/NewArch/MenuView.mm +20 -0
  9. package/ios/Shared/ActionSheetView.swift +2 -2
  10. package/ios/Shared/MenuViewImplementation.swift +3 -3
  11. package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js +1 -1
  12. package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js.map +1 -1
  13. package/lib/commonjs/UIMenuView.android.js +19 -1
  14. package/lib/commonjs/UIMenuView.android.js.map +1 -1
  15. package/lib/commonjs/UIMenuView.js +0 -3
  16. package/lib/commonjs/UIMenuView.js.map +1 -1
  17. package/lib/commonjs/index.js +6 -8
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/commonjs/utils.js +1 -1
  20. package/lib/commonjs/utils.js.map +1 -1
  21. package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js +2 -2
  22. package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js.map +1 -1
  23. package/lib/module/UIMenuView.android.js +20 -2
  24. package/lib/module/UIMenuView.android.js.map +1 -1
  25. package/lib/module/UIMenuView.ios.js +1 -1
  26. package/lib/module/UIMenuView.js +1 -2
  27. package/lib/module/UIMenuView.js.map +1 -1
  28. package/lib/module/index.js +9 -8
  29. package/lib/module/index.js.map +1 -1
  30. package/lib/module/utils.js +1 -1
  31. package/lib/module/utils.js.map +1 -1
  32. package/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts +10 -2
  33. package/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts.map +1 -1
  34. package/lib/typescript/src/UIMenuView.android.d.ts +2 -3
  35. package/lib/typescript/src/UIMenuView.android.d.ts.map +1 -1
  36. package/lib/typescript/src/UIMenuView.d.ts +2 -2
  37. package/lib/typescript/src/UIMenuView.d.ts.map +1 -1
  38. package/lib/typescript/src/UIMenuView.ios.d.ts +1 -1
  39. package/lib/typescript/src/index.d.ts +20 -4
  40. package/lib/typescript/src/index.d.ts.map +1 -1
  41. package/lib/typescript/src/types.d.ts +10 -6
  42. package/lib/typescript/src/types.d.ts.map +1 -1
  43. package/lib/typescript/src/utils.d.ts +1 -1
  44. package/lib/typescript/src/utils.d.ts.map +1 -1
  45. package/package.json +10 -44
  46. package/src/NativeModuleSpecs/UIMenuNativeComponent.ts +45 -37
  47. package/src/UIMenuView.android.tsx +34 -4
  48. package/src/UIMenuView.ios.tsx +1 -1
  49. package/src/UIMenuView.tsx +11 -11
  50. package/src/index.tsx +32 -26
  51. package/src/types.ts +158 -153
  52. package/src/utils.ts +17 -17
@@ -1 +1 @@
1
- {"version":3,"names":["hashCode","str","hash","i","length","char","charCodeAt","objectHash","obj","jsonString","JSON","stringify","String"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;AAAA;AACA,SAASA,QAAQA,CAACC,GAAW,EAAU;EACrC,IAAIC,IAAI,GAAG,CAAC;EACZ,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,GAAG,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;IACnC,MAAME,IAAI,GAAGJ,GAAG,CAACK,UAAU,CAACH,CAAC,CAAC;IAC9B;IACAD,IAAI,GAAG,CAACA,IAAI,IAAI,CAAC,IAAIA,IAAI,GAAGG,IAAI;EAClC;EACA,OAAOH,IAAI;AACb;;AAEA;AACA,OAAO,SAASK,UAAUA,CAACC,GAAwB,EAAU;EAC3D,IAAI,CAACA,GAAG,EAAE;IACR,OAAO,EAAE;EACX;EACA;EACA,MAAMC,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACH,GAAG,CAAC;;EAEtC;EACA,MAAMN,IAAI,GAAGF,QAAQ,CAACS,UAAU,CAAC;;EAEjC;EACA,OAAOG,MAAM,CAACV,IAAI,CAAC;AACrB","ignoreList":[]}
1
+ {"version":3,"names":["hashCode","str","hash","i","length","char","charCodeAt","objectHash","obj","jsonString","JSON","stringify","String"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;AAAA;AACA,SAASA,QAAQA,CAACC,GAAW,EAAU;EACtC,IAAIC,IAAI,GAAG,CAAC;EACZ,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,GAAG,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;IACpC,MAAME,IAAI,GAAGJ,GAAG,CAACK,UAAU,CAACH,CAAC,CAAC;IAC9B;IACAD,IAAI,GAAG,CAACA,IAAI,IAAI,CAAC,IAAIA,IAAI,GAAGG,IAAI;EACjC;EACA,OAAOH,IAAI;AACZ;;AAEA;AACA,OAAO,SAASK,UAAUA,CAACC,GAA8B,EAAU;EAClE,IAAI,CAACA,GAAG,EAAE;IACT,OAAO,EAAE;EACV;EACA;EACA,MAAMC,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACH,GAAG,CAAC;;EAEtC;EACA,MAAMN,IAAI,GAAGF,QAAQ,CAACS,UAAU,CAAC;;EAEjC;EACA,OAAOG,MAAM,CAACV,IAAI,CAAC;AACpB","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import type { DirectEventHandler, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
2
- import type { HostComponent, ViewProps } from 'react-native';
1
+ import type { DirectEventHandler, Int32 } from "react-native/Libraries/Types/CodegenTypes";
2
+ import type { HostComponent, ViewProps } from "react-native";
3
3
  type SubAction = {
4
4
  id?: string;
5
5
  title: string;
@@ -38,6 +38,14 @@ export interface NativeProps extends ViewProps {
38
38
  actions: Array<MenuAction>;
39
39
  actionsHash: string;
40
40
  title?: string;
41
+ themeVariant?: string;
42
+ shouldOpenOnLongPress?: boolean;
43
+ hitSlop: {
44
+ top: Int32;
45
+ bottom: Int32;
46
+ left: Int32;
47
+ right: Int32;
48
+ };
41
49
  }
42
50
  declare const _default: HostComponent<NativeProps>;
43
51
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"UIMenuNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/NativeModuleSpecs/UIMenuNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,KAAK,EACN,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAU7D,KAAK,SAAS,GAAG;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE;QACX,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;CACH,CAAC;AACF,KAAK,UAAU,GAAG;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM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MAAM,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;CACF,CAAC;AACF,KAAK,UAAU,GAAG;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE;QACZ,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,MAAM,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AACF,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC7C,aAAa,CAAC,EAAE,kBAAkB,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,EAAE;QACR,GAAG,EAAE,KAAK,CAAC;QACX,MAAM,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,KAAK,CAAC;QACZ,KAAK,EAAE,KAAK,CAAC;KACb,CAAA;CACD;wBAII,aAAa,CAAC,WAAW,CAAC;AAF/B,wBAEgC"}
@@ -1,5 +1,4 @@
1
- import { HostComponent } from 'react-native';
2
- import type { NativeMenuComponentProps } from './types';
3
- declare const MenuComponent: HostComponent<NativeMenuComponentProps>;
1
+ import type { MenuComponentRef, NativeMenuComponentProps } from "./types";
2
+ declare const MenuComponent: import("react").ForwardRefExoticComponent<Omit<NativeMenuComponentProps, "ref"> & import("react").RefAttributes<MenuComponentRef>>;
4
3
  export default MenuComponent;
5
4
  //# sourceMappingURL=UIMenuView.android.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UIMenuView.android.d.ts","sourceRoot":"","sources":["../../../src/UIMenuView.android.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,QAAA,MAAM,aAAa,EAEd,aAAa,CAAC,wBAAwB,CAAC,CAAC;AAE7C,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"UIMenuView.android.d.ts","sourceRoot":"","sources":["../../../src/UIMenuView.android.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAO1E,QAAA,MAAM,aAAa,oIAsBlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,5 +1,5 @@
1
- import * as React from 'react';
2
- import type { NativeMenuComponentProps } from './types';
1
+ import type * as React from "react";
2
+ import type { NativeMenuComponentProps } from "./types";
3
3
  /**
4
4
  * TODO: implement for Web
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"UIMenuView.d.ts","sourceRoot":"","sources":["../../../src/UIMenuView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD;;GAEG;AACH,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CAUzE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"UIMenuView.d.ts","sourceRoot":"","sources":["../../../src/UIMenuView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD;;GAEG;AACH,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CAUzE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,3 +1,3 @@
1
- import UIMenuNativeComponent from './NativeModuleSpecs/UIMenuNativeComponent';
1
+ import UIMenuNativeComponent from "./NativeModuleSpecs/UIMenuNativeComponent";
2
2
  export default UIMenuNativeComponent;
3
3
  //# sourceMappingURL=UIMenuView.ios.d.ts.map
@@ -1,6 +1,22 @@
1
- import React from 'react';
2
- import type { MenuComponentProps, MenuAction, NativeActionEvent } from './types';
3
- declare const MenuView: React.FC<MenuComponentProps>;
1
+ import type { MenuComponentProps, MenuAction, NativeActionEvent, MenuComponentRef } from "./types";
2
+ declare const MenuView: import("react").ForwardRefExoticComponent<{
3
+ style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
4
+ onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;
5
+ actions: MenuAction[];
6
+ title?: string;
7
+ isAnchoredToRight?: boolean;
8
+ shouldOpenOnLongPress?: boolean;
9
+ themeVariant?: string;
10
+ hitSlop?: {
11
+ top: number;
12
+ bottom: number;
13
+ left: number;
14
+ right: number;
15
+ };
16
+ testID?: string;
17
+ } & {
18
+ children?: import("react").ReactNode | undefined;
19
+ } & import("react").RefAttributes<MenuComponentRef>>;
4
20
  export { MenuView };
5
- export type { MenuComponentProps, MenuAction, NativeActionEvent };
21
+ export type { MenuComponentProps, MenuComponentRef, MenuAction, NativeActionEvent, };
6
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EAEV,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAcjB,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAmB1C,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EAEV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAcjB,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;oDAmBb,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,iBAAiB,GAClB,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { ColorValue, processColor, StyleProp, ViewStyle } from 'react-native';
2
- import type * as React from 'react';
1
+ import type { ColorValue, processColor, StyleProp, ViewStyle } from "react-native";
2
+ import type * as React from "react";
3
3
  export type NativeActionEvent = {
4
4
  nativeEvent: {
5
5
  event: string;
@@ -31,7 +31,7 @@ type MenuAttributes = {
31
31
  * - on: A constant indicating the menu element is in the “on” state.
32
32
  * - mixed: A constant indicating the menu element is in the “mixed” state.
33
33
  */
34
- type MenuState = 'off' | 'on' | 'mixed';
34
+ type MenuState = "off" | "on" | "mixed";
35
35
  export type MenuAction = {
36
36
  /**
37
37
  * Identifier of the menu action.
@@ -96,7 +96,7 @@ export type MenuAction = {
96
96
  * The preferred size of this menu's child elements.
97
97
  * @platform iOS
98
98
  */
99
- preferredElementSize?: 'small' | 'medium' | 'large';
99
+ preferredElementSize?: "small" | "medium" | "large";
100
100
  };
101
101
  type MenuComponentPropsBase = {
102
102
  style?: StyleProp<ViewStyle>;
@@ -149,7 +149,10 @@ type MenuComponentPropsBase = {
149
149
  testID?: string;
150
150
  };
151
151
  export type MenuComponentProps = React.PropsWithChildren<MenuComponentPropsBase>;
152
- export type ProcessedMenuAction = Omit<MenuAction, 'imageColor' | 'titleColor' | 'subactions'> & {
152
+ export type MenuComponentRef = {
153
+ show: () => void;
154
+ };
155
+ export type ProcessedMenuAction = Omit<MenuAction, "imageColor" | "titleColor" | "subactions"> & {
153
156
  imageColor: ReturnType<typeof processColor>;
154
157
  titleColor: ReturnType<typeof processColor>;
155
158
  subactions?: ProcessedMenuAction[];
@@ -160,8 +163,9 @@ export type NativeMenuComponentProps = {
160
163
  actions: ProcessedMenuAction[];
161
164
  actionsHash: string;
162
165
  title?: string;
163
- hitSlop?: MenuComponentProps['hitSlop'];
166
+ hitSlop?: MenuComponentProps["hitSlop"];
164
167
  testID?: string;
168
+ ref?: React.ForwardedRef<MenuComponentRef>;
165
169
  };
166
170
  export {};
167
171
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,KAAK,SAAS,GAAG,KAAK,GAAG,IAAI,GAAG,OA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;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;IACF;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC7B,KAAK,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,MAAM,IAAI,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACrC,UAAU,EACV,YAAY,GAAG,YAAY,GAAG,YAAY,CAC1C,GAAG;IACH,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IAC5C,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IAC5C,UAAU,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACtC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,aAAa,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC7D,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;CAC3C,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare function objectHash(obj: Record<string, any>): string;
1
+ export declare function objectHash(obj: Record<string, unknown>[]): string;
2
2
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAYA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAY3D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAYA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAYjE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-menu/menu",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "UIMenu component for react-native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -22,9 +22,9 @@
22
22
  "scripts": {
23
23
  "android": "react-native run-android",
24
24
  "bootstrap": "yarn && yarn pods",
25
- "format": "prettier --write \"**/*.{js,ts,tsx}\"",
25
+ "format": "biome format --write .",
26
26
  "ios": "react-native run-ios",
27
- "lint": "eslint \"**/*.{js,ts,tsx}\"",
27
+ "lint": "biome lint --write .",
28
28
  "pods": "cd example && pod-install --quiet",
29
29
  "prepare": "bob build",
30
30
  "release": "release-it",
@@ -45,28 +45,23 @@
45
45
  },
46
46
  "homepage": "https://github.com/react-native-menu/menu#readme",
47
47
  "devDependencies": {
48
+ "@biomejs/biome": "1.9.4",
48
49
  "@callstack/react-native-visionos": "^0.73.0",
49
- "@react-native/babel-preset": "^0.74.79",
50
- "@react-native/eslint-config": "^0.74.0",
51
- "@react-native/metro-config": "0.74.85",
50
+ "@react-native/babel-preset": "^0.76.1",
51
+ "@react-native/metro-config": "0.76.3",
52
52
  "@release-it/conventional-changelog": "^9.0.1",
53
53
  "@rnx-kit/metro-config": "^2.0.0",
54
54
  "@types/jest": "^29.1.2",
55
55
  "@types/react": "^18.2.2",
56
56
  "@types/react-native": "0.73.0",
57
- "eslint": "8.57.0",
58
- "eslint-config-prettier": "^9.1.0",
59
- "eslint-plugin-ft-flow": "^3.0.0",
60
- "eslint-plugin-prettier": "^5.1.2",
61
57
  "jest": "^29.2.1",
62
- "pod-install": "^0.2.0",
63
- "prettier": "^3.1.1",
58
+ "pod-install": "^0.3.2",
64
59
  "react": "18.2.0",
65
60
  "react-native": "^0.73.0",
66
- "react-native-builder-bob": "^0.30.2",
67
- "react-native-test-app": "^3.8.1",
61
+ "react-native-builder-bob": "^0.33.2",
62
+ "react-native-test-app": "^4.0.4",
68
63
  "release-it": "^17.2.0",
69
- "typescript": "5.6.3"
64
+ "typescript": "5.7.2"
70
65
  },
71
66
  "peerDependencies": {
72
67
  "react": "*",
@@ -96,35 +91,6 @@
96
91
  }
97
92
  }
98
93
  },
99
- "eslintConfig": {
100
- "extends": [
101
- "@react-native",
102
- "prettier"
103
- ],
104
- "rules": {
105
- "prettier/prettier": [
106
- "error",
107
- {
108
- "quoteProps": "consistent",
109
- "singleQuote": true,
110
- "tabWidth": 2,
111
- "trailingComma": "es5",
112
- "useTabs": false
113
- }
114
- ]
115
- }
116
- },
117
- "eslintIgnore": [
118
- "node_modules/",
119
- "lib/"
120
- ],
121
- "prettier": {
122
- "quoteProps": "consistent",
123
- "singleQuote": true,
124
- "tabWidth": 2,
125
- "trailingComma": "es5",
126
- "useTabs": false
127
- },
128
94
  "react-native-builder-bob": {
129
95
  "source": "src",
130
96
  "output": "lib",
@@ -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.
@@ -13,43 +13,51 @@ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNati
13
13
  types here, to avoid issues while `pod install` takes place.
14
14
  */
15
15
  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
- };
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
+ };
29
29
  };
30
30
  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>;
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>;
45
45
  };
46
46
  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;
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;
51
+ themeVariant?: string;
52
+ shouldOpenOnLongPress?: boolean;
53
+ hitSlop: {
54
+ top: Int32;
55
+ bottom: Int32;
56
+ left: Int32;
57
+ right: Int32;
58
+ }
51
59
  }
52
60
 
53
61
  export default codegenNativeComponent<NativeProps>(
54
- 'MenuView'
62
+ "MenuView",
55
63
  ) 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,14 +1,15 @@
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
6
  MenuComponentProps,
7
7
  MenuAction,
8
8
  ProcessedMenuAction,
9
9
  NativeActionEvent,
10
- } from './types';
11
- import { objectHash } from './utils';
10
+ MenuComponentRef,
11
+ } from "./types";
12
+ import { objectHash } from "./utils";
12
13
 
13
14
  function processAction(action: MenuAction): ProcessedMenuAction {
14
15
  return {
@@ -21,26 +22,31 @@ function processAction(action: MenuAction): ProcessedMenuAction {
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
+ };