@react-native-menu/menu 0.9.1 → 1.0.1

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 (72) hide show
  1. package/README.md +14 -2
  2. package/android/.project +11 -0
  3. package/android/build.gradle +69 -77
  4. package/android/gradle.properties +5 -4
  5. package/android/src/main/AndroidManifest.xml +0 -1
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/reactnativemenu/MenuPackage.kt +1 -1
  8. package/android/src/main/java/com/reactnativemenu/MenuViewManager.kt +3 -3
  9. package/android/src/newarch/MenuViewManagerSpec.kt +21 -0
  10. package/android/src/oldarch/MenuViewManagerSpec.kt +9 -0
  11. package/ios/Menu-Bridging-Header.h +0 -2
  12. package/ios/MenuViewManager.mm +64 -0
  13. package/ios/NewArch/FabricActionSheetView.swift +11 -0
  14. package/ios/NewArch/FabricMenuViewImplementation.swift +20 -0
  15. package/ios/NewArch/FabricViewImplementationProtocol.swift +6 -0
  16. package/ios/NewArch/MenuView.h +19 -0
  17. package/ios/NewArch/MenuView.mm +145 -0
  18. package/ios/OldArch/LegacyActionSheetView.swift +11 -0
  19. package/ios/OldArch/LegacyMenuViewImplementation.swift +13 -0
  20. package/ios/{ActionSheetView.swift → Shared/ActionSheetView.swift} +6 -8
  21. package/ios/{MenuView.swift → Shared/MenuViewImplementation.swift} +9 -11
  22. package/ios/{RCTMenuItem.swift → Shared/RCTMenuItem.swift} +9 -1
  23. package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js +18 -0
  24. package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js.map +1 -0
  25. package/lib/commonjs/UIMenuView.android.js +1 -4
  26. package/lib/commonjs/UIMenuView.android.js.map +1 -1
  27. package/lib/commonjs/UIMenuView.ios.js +3 -6
  28. package/lib/commonjs/UIMenuView.ios.js.map +1 -1
  29. package/lib/commonjs/UIMenuView.js +3 -10
  30. package/lib/commonjs/UIMenuView.js.map +1 -1
  31. package/lib/commonjs/index.js +12 -14
  32. package/lib/commonjs/index.js.map +1 -1
  33. package/lib/commonjs/types.js.map +1 -1
  34. package/lib/commonjs/utils.js +31 -0
  35. package/lib/commonjs/utils.js.map +1 -0
  36. package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js +12 -0
  37. package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js.map +1 -0
  38. package/lib/module/UIMenuView.android.js.map +1 -1
  39. package/lib/module/UIMenuView.ios.js +2 -3
  40. package/lib/module/UIMenuView.ios.js.map +1 -1
  41. package/lib/module/UIMenuView.js +0 -2
  42. package/lib/module/UIMenuView.js.map +1 -1
  43. package/lib/module/index.js +10 -10
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/module/types.js.map +1 -1
  46. package/lib/module/utils.js +25 -0
  47. package/lib/module/utils.js.map +1 -0
  48. package/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts +44 -0
  49. package/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts.map +1 -0
  50. package/lib/typescript/src/UIMenuView.android.d.ts +1 -0
  51. package/lib/typescript/src/UIMenuView.android.d.ts.map +1 -0
  52. package/lib/typescript/src/UIMenuView.d.ts +1 -0
  53. package/lib/typescript/src/UIMenuView.d.ts.map +1 -0
  54. package/lib/typescript/src/UIMenuView.ios.d.ts +3 -4
  55. package/lib/typescript/src/UIMenuView.ios.d.ts.map +1 -0
  56. package/lib/typescript/src/index.d.ts +1 -0
  57. package/lib/typescript/src/index.d.ts.map +1 -0
  58. package/lib/typescript/src/types.d.ts +2 -0
  59. package/lib/typescript/src/types.d.ts.map +1 -0
  60. package/lib/typescript/src/utils.d.ts +2 -0
  61. package/lib/typescript/src/utils.d.ts.map +1 -0
  62. package/package.json +38 -20
  63. package/react-native-menu.podspec +26 -4
  64. package/src/NativeModuleSpecs/UIMenuNativeComponent.ts +55 -0
  65. package/src/UIMenuView.ios.tsx +2 -7
  66. package/src/index.tsx +8 -2
  67. package/src/types.ts +2 -0
  68. package/src/utils.ts +24 -0
  69. package/ios/Menu.xcodeproj/project.pbxproj +0 -297
  70. package/ios/RCTUIMenuManager.m +0 -27
  71. package/ios/RCTUIMenuManager.swift +0 -19
  72. /package/ios/{RCTAlertAction.swift → Shared/RCTAlertAction.swift} +0 -0
@@ -1,5 +1,5 @@
1
1
  //
2
- // MenuView.swift
2
+ // MenuViewImplementation.swift
3
3
  // react-native-menu
4
4
  //
5
5
  // Created by Jesse Katsumata on 11/3/20.
@@ -7,11 +7,10 @@
7
7
 
8
8
  import UIKit
9
9
  @available(iOS 14.0, *)
10
- @objc(MenuView)
11
- class MenuView: UIButton {
10
+ @objc(MenuViewImplementation)
11
+ public class MenuViewImplementation: UIButton {
12
12
 
13
- private var _actions: [UIMenuElement] = [];
14
- @objc var actions: [NSDictionary]? {
13
+ @objc public var actions: [NSDictionary]? {
15
14
  didSet {
16
15
  guard let actions = self.actions else {
17
16
  return
@@ -24,8 +23,10 @@ class MenuView: UIButton {
24
23
  }
25
24
  }
26
25
 
26
+ private var _actions: [UIMenuElement] = [];
27
+
27
28
  private var _title: String = "";
28
- @objc var title: NSString? {
29
+ @objc public var title: NSString? {
29
30
  didSet {
30
31
  guard let title = self.title else {
31
32
  return
@@ -34,7 +35,6 @@ class MenuView: UIButton {
34
35
  self.setup()
35
36
  }
36
37
  }
37
- @objc var onPressAction: RCTDirectEventBlock?
38
38
 
39
39
  @objc var shouldOpenOnLongPress: Bool = false {
40
40
  didSet {
@@ -73,7 +73,7 @@ class MenuView: UIButton {
73
73
  self.showsMenuAsPrimaryAction = !shouldOpenOnLongPress
74
74
  }
75
75
 
76
- override func reactSetFrame(_ frame: CGRect) {
76
+ public override func reactSetFrame(_ frame: CGRect) {
77
77
  super.reactSetFrame(frame);
78
78
  };
79
79
 
@@ -83,8 +83,6 @@ class MenuView: UIButton {
83
83
  }
84
84
 
85
85
  @objc func sendButtonAction(_ action: UIAction) {
86
- if let onPress = onPressAction {
87
- onPress(["event":action.identifier.rawValue])
88
- }
86
+ // NO-OP (should be overriden by parent)
89
87
  }
90
88
  }
@@ -27,6 +27,9 @@ class RCTMenuAction {
27
27
 
28
28
  if let image = details["image"] as? NSString {
29
29
  self.image = UIImage(systemName: image as String);
30
+ if self.image === nil {
31
+ self.image = UIImage(named: image as String)
32
+ }
30
33
  if let imageColor = details["imageColor"] {
31
34
  self.image = self.image?.withTintColor(RCTConvert.uiColor(imageColor), renderingMode: .alwaysOriginal)
32
35
  }
@@ -95,6 +98,11 @@ class RCTMenuAction {
95
98
  return UIMenu(title: title, image: image, children: subMenuActions)
96
99
  }
97
100
  }
98
- return UIAction(title: title, image: image, identifier: identifier, discoverabilityTitle: subtitle, attributes: attributes, state: state, handler: handler)
101
+
102
+ if #available(iOS 15, *) {
103
+ return UIAction(title: title, subtitle: subtitle, image: image, identifier: identifier, attributes: attributes, state: state, handler: handler)
104
+ } else {
105
+ return UIAction(title: title, image: image, identifier: identifier, discoverabilityTitle: subtitle, attributes: attributes, state: state, handler: handler)
106
+ }
99
107
  }
100
108
  }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _codegenNativeComponent = _interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ /*
10
+ Caution, those below are not just typescript types.
11
+ Codegen is using them to create the corresponding C++ data types.
12
+
13
+ Codegen doesn't play very well with reusing the same type within a type,
14
+ OR with extending types in an interface, so for now we'll just keep some duplicate
15
+ types here, to avoid issues while `pod install` takes place.
16
+ */
17
+ var _default = exports.default = (0, _codegenNativeComponent.default)('MenuView');
18
+ //# sourceMappingURL=UIMenuNativeComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","obj","__esModule","default","_default","exports","codegenNativeComponent"],"sourceRoot":"../../../src","sources":["NativeModuleSpecs/UIMenuNativeComponent.ts"],"mappings":";;;;;;AAKA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GA8Ce,IAAAG,+BAAsB,EACnC,UACF,CAAC"}
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _reactNative = require("react-native");
9
-
10
8
  const MenuComponent = (0, _reactNative.requireNativeComponent)('MenuView');
11
- var _default = MenuComponent;
12
- exports.default = _default;
9
+ var _default = exports.default = MenuComponent;
13
10
  //# sourceMappingURL=UIMenuView.android.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["MenuComponent","requireNativeComponent"],"sources":["UIMenuView.android.tsx"],"sourcesContent":["import { HostComponent, requireNativeComponent } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\nconst MenuComponent = requireNativeComponent(\n 'MenuView'\n) as HostComponent<NativeMenuComponentProps>;\n\nexport default MenuComponent;\n"],"mappings":";;;;;;;AAAA;;AAGA,MAAMA,aAAa,GAAG,IAAAC,mCAAA,EACpB,UADoB,CAAtB;eAIeD,a"}
1
+ {"version":3,"names":["_reactNative","require","MenuComponent","requireNativeComponent","_default","exports","default"],"sourceRoot":"../../src","sources":["UIMenuView.android.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,MAAMC,aAAa,GAAG,IAAAC,mCAAsB,EAC1C,UACF,CAA4C;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE9BJ,aAAa"}
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
- var _reactNative = require("react-native");
9
-
10
- const MenuComponent = (0, _reactNative.requireNativeComponent)('RCTUIMenu');
11
- var _default = MenuComponent;
12
- exports.default = _default;
7
+ var _UIMenuNativeComponent = _interopRequireDefault(require("./NativeModuleSpecs/UIMenuNativeComponent"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var _default = exports.default = _UIMenuNativeComponent.default;
13
10
  //# sourceMappingURL=UIMenuView.ios.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["MenuComponent","requireNativeComponent"],"sources":["UIMenuView.ios.tsx"],"sourcesContent":["import { HostComponent, requireNativeComponent } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\nconst MenuComponent = requireNativeComponent(\n 'RCTUIMenu'\n) as HostComponent<NativeMenuComponentProps>;\n\nexport default MenuComponent;\n"],"mappings":";;;;;;;AAAA;;AAGA,MAAMA,aAAa,GAAG,IAAAC,mCAAA,EACpB,WADoB,CAAtB;eAIeD,a"}
1
+ {"version":3,"names":["_UIMenuNativeComponent","_interopRequireDefault","require","obj","__esModule","default","_default","exports","UIMenuNativeComponent"],"sourceRoot":"../../src","sources":["UIMenuView.ios.tsx"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8E,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE/DG,8BAAqB"}
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var React = _interopRequireWildcard(require("react"));
9
-
10
8
  var _reactNative = require("react-native");
11
-
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
-
14
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
-
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
11
  /**
17
12
  * TODO: implement for Web
18
13
  */
@@ -24,7 +19,5 @@ const MenuView = ({
24
19
  style: style
25
20
  }, children);
26
21
  };
27
-
28
- var _default = MenuView;
29
- exports.default = _default;
22
+ var _default = exports.default = MenuView;
30
23
  //# sourceMappingURL=UIMenuView.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["MenuView","style","children"],"sources":["UIMenuView.tsx"],"sourcesContent":["import * as React from 'react';\nimport { View } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\n/**\n * TODO: implement for Web\n */\nconst MenuView: React.FC<React.PropsWithChildren<NativeMenuComponentProps>> = ({\n style,\n children,\n}) => {\n return <View style={style}>{children}</View>;\n};\n\nexport default MenuView;\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAGA;AACA;AACA;AACA,MAAMA,QAAqE,GAAG,CAAC;EAC7EC,KAD6E;EAE7EC;AAF6E,CAAD,KAGxE;EACJ,oBAAO,oBAAC,iBAAD;IAAM,KAAK,EAAED;EAAb,GAAqBC,QAArB,CAAP;AACD,CALD;;eAOeF,Q"}
1
+ {"version":3,"names":["React","_interopRequireWildcard","require","_reactNative","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","MenuView","style","children","createElement","View","_default","exports"],"sourceRoot":"../../src","sources":["UIMenuView.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAoC,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAgB,GAAA,CAAAnB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAGpC;AACA;AACA;AACA,MAAMY,QAAqE,GAAGA,CAAC;EAC7EC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,oBAAO3B,KAAA,CAAA4B,aAAA,CAACzB,YAAA,CAAA0B,IAAI;IAACH,KAAK,EAAEA;EAAM,GAAEC,QAAe,CAAC;AAC9C,CAAC;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAArB,OAAA,GAEae,QAAQ"}
@@ -4,36 +4,34 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.MenuView = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
7
+ var _react = _interopRequireWildcard(require("react"));
10
8
  var _reactNative = require("react-native");
11
-
12
9
  var _UIMenuView = _interopRequireDefault(require("./UIMenuView"));
13
-
10
+ var _utils = require("./utils");
14
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
14
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
-
18
15
  function processAction(action) {
19
- var _action$subactions;
20
-
21
- return { ...action,
16
+ return {
17
+ ...action,
22
18
  imageColor: (0, _reactNative.processColor)(action.imageColor),
23
19
  titleColor: (0, _reactNative.processColor)(action.titleColor),
24
- subactions: (_action$subactions = action.subactions) === null || _action$subactions === void 0 ? void 0 : _action$subactions.map(subAction => processAction(subAction))
20
+ subactions: action.subactions?.map(subAction => processAction(subAction))
25
21
  };
26
22
  }
27
-
28
23
  const MenuView = ({
29
24
  actions,
30
25
  ...props
31
26
  }) => {
32
27
  const processedActions = actions.map(action => processAction(action));
28
+ const hash = (0, _react.useMemo)(() => {
29
+ return (0, _utils.objectHash)(processedActions);
30
+ }, [processedActions]);
33
31
  return /*#__PURE__*/_react.default.createElement(_UIMenuView.default, _extends({}, props, {
34
- actions: processedActions
32
+ actions: processedActions,
33
+ actionsHash: hash
35
34
  }));
36
35
  };
37
-
38
36
  exports.MenuView = MenuView;
39
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["processAction","action","imageColor","processColor","titleColor","subactions","map","subAction","MenuView","actions","props","processedActions"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\nimport { processColor } from 'react-native';\n\nimport UIMenuView from './UIMenuView';\nimport type {\n MenuComponentProps,\n MenuAction,\n ProcessedMenuAction,\n NativeActionEvent,\n} from './types';\n\nfunction processAction(action: MenuAction): ProcessedMenuAction {\n return {\n ...action,\n imageColor: processColor(action.imageColor),\n titleColor: processColor(action.titleColor),\n subactions: action.subactions?.map((subAction) => processAction(subAction)),\n };\n}\n\nconst MenuView: React.FC<MenuComponentProps> = ({ actions, ...props }) => {\n const processedActions = actions.map<ProcessedMenuAction>((action) =>\n processAction(action)\n );\n return <UIMenuView {...props} actions={processedActions} />;\n};\n\nexport { MenuView };\nexport type { MenuComponentProps, MenuAction, NativeActionEvent };\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;AAQA,SAASA,aAAT,CAAuBC,MAAvB,EAAgE;EAAA;;EAC9D,OAAO,EACL,GAAGA,MADE;IAELC,UAAU,EAAE,IAAAC,yBAAA,EAAaF,MAAM,CAACC,UAApB,CAFP;IAGLE,UAAU,EAAE,IAAAD,yBAAA,EAAaF,MAAM,CAACG,UAApB,CAHP;IAILC,UAAU,wBAAEJ,MAAM,CAACI,UAAT,uDAAE,mBAAmBC,GAAnB,CAAwBC,SAAD,IAAeP,aAAa,CAACO,SAAD,CAAnD;EAJP,CAAP;AAMD;;AAED,MAAMC,QAAsC,GAAG,CAAC;EAAEC,OAAF;EAAW,GAAGC;AAAd,CAAD,KAA2B;EACxE,MAAMC,gBAAgB,GAAGF,OAAO,CAACH,GAAR,CAAkCL,MAAD,IACxDD,aAAa,CAACC,MAAD,CADU,CAAzB;EAGA,oBAAO,6BAAC,mBAAD,eAAgBS,KAAhB;IAAuB,OAAO,EAAEC;EAAhC,GAAP;AACD,CALD"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_UIMenuView","_interopRequireDefault","_utils","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","processAction","action","imageColor","processColor","titleColor","subactions","map","subAction","MenuView","actions","props","processedActions","hash","useMemo","objectHash","createElement","actionsHash","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n ColorValue,\n processColor,\n StyleProp,\n ViewStyle,\n} from 'react-native';\nimport type * as React from 'react';\n\nexport type NativeActionEvent = {\n nativeEvent: {\n event: string;\n };\n};\n\ntype MenuAttributes = {\n /**\n * An attribute indicating the destructive style.\n */\n destructive?: boolean;\n /**\n * An attribute indicating the disabled style.\n */\n disabled?: boolean;\n /**\n * An attribute indicating the hidden style.\n */\n hidden?: boolean;\n};\n\n/**\n * The state of the action.\n * - off: A constant indicating the menu element is in the “off” state.\n * - on: A constant indicating the menu element is in the “on” state.\n * - mixed: A constant indicating the menu element is in the “mixed” state.\n */\ntype MenuState = 'off' | 'on' | 'mixed';\n\nexport type MenuAction = {\n /**\n * Identifier of the menu action.\n * The value set in this id will be returned when menu is selected.\n */\n id?: string;\n /**\n * The action's title.\n */\n title: string;\n /**\n * (Android only)\n * The action's title color.\n * @platform Android\n */\n titleColor?: number | ColorValue;\n /**\n * (iOS14+ only)\n * An elaborated title that explains the purpose of the action.\n * @platform iOS\n */\n subtitle?: string;\n /**\n * The attributes indicating the style of the action.\n */\n attributes?: MenuAttributes;\n /**\n * (iOS14+ only)\n * The state of the action.\n * @platform iOS\n */\n state?: MenuState;\n /**\n * (Android and iOS13+ only)\n * - The action's image.\n * - Allows icon name included in project or system (Android) resources drawables and\n * in SF Symbol (iOS)\n * @example // (iOS)\n * image=\"plus\"\n * @example // (Android)\n * image=\"ic_menu_add\"\n * - TODO: Allow images other than those included in SF Symbol and resources drawables\n */\n image?: string;\n /**\n * (Android and iOS13+ only)\n * - The action's image color.\n */\n imageColor?: number | ColorValue;\n /**\n * (Android and iOS14+ only)\n * - Actions to be displayed in the sub menu\n * - On Android it does not support nesting next sub menus in sub menu item\n */\n subactions?: MenuAction[];\n /**\n * Whether subactions should be inline (separated by divider) or nested (sub menu)\n */\n displayInline?: boolean;\n};\n\ntype MenuComponentPropsBase = {\n style?: StyleProp<ViewStyle>;\n /**\n * Callback function that will be called when selecting a menu item.\n * It will contain id of the given action.\n */\n onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;\n /**\n * Actions to be displayed in the menu.\n */\n actions: MenuAction[];\n /**\n * The title of the menu.\n */\n title?: string;\n /**\n * (Android API 23+)\n * Boolean value determines whether popup menu should be anchored\n * to right corner of parent view - default value is `false`\n * @platform Android\n */\n isAnchoredToRight?: boolean;\n /**\n * Determines if menu should open after long press or on normal press\n *\n * @default false\n */\n shouldOpenOnLongPress?: boolean;\n /**\n * Overrides theme variant of menu to light mode, dark mode or system theme\n * (Only support iOS for now)\n *\n * @platform iOS\n */\n themeVariant?: string;\n};\n\nexport type MenuComponentProps =\n React.PropsWithChildren<MenuComponentPropsBase>;\n\nexport type ProcessedMenuAction = Omit<\n MenuAction,\n 'imageColor' | 'titleColor' | 'subactions'\n> & {\n imageColor: ReturnType<typeof processColor>;\n titleColor: ReturnType<typeof processColor>;\n subactions?: ProcessedMenuAction[];\n};\n\nexport type NativeMenuComponentProps = {\n style?: StyleProp<ViewStyle>;\n onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;\n actions: ProcessedMenuAction[];\n title?: string;\n};\n"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":""}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.objectHash = objectHash;
7
+ // Function to calculate a simple hash code for a string
8
+ function hashCode(str) {
9
+ let hash = 0;
10
+ for (let i = 0; i < str.length; i++) {
11
+ const char = str.charCodeAt(i);
12
+ hash = (hash << 5) - hash + char;
13
+ }
14
+ return hash;
15
+ }
16
+
17
+ // Function to create a string hash from a TypeScript object
18
+ function objectHash(obj) {
19
+ if (!obj) {
20
+ return '';
21
+ }
22
+ // Convert the object to a JSON string
23
+ const jsonString = JSON.stringify(obj);
24
+
25
+ // Calculate the hash code of the JSON string
26
+ const hash = hashCode(jsonString);
27
+
28
+ // Convert the hash code to a string (optional)
29
+ return String(hash);
30
+ }
31
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +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;IAC9BD,IAAI,GAAG,CAACA,IAAI,IAAI,CAAC,IAAIA,IAAI,GAAGG,IAAI;EAClC;EACA,OAAOH,IAAI;AACb;;AAEA;AACO,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"}
@@ -0,0 +1,12 @@
1
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
+ /*
3
+ Caution, those below are not just typescript types.
4
+ Codegen is using them to create the corresponding C++ data types.
5
+
6
+ Codegen doesn't play very well with reusing the same type within a type,
7
+ OR with extending types in an interface, so for now we'll just keep some duplicate
8
+ types here, to avoid issues while `pod install` takes place.
9
+ */
10
+
11
+ export default codegenNativeComponent('MenuView');
12
+ //# sourceMappingURL=UIMenuNativeComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["codegenNativeComponent"],"sourceRoot":"../../../src","sources":["NativeModuleSpecs/UIMenuNativeComponent.ts"],"mappings":"AAKA,OAAOA,sBAAsB,MAAM,yDAAyD;AAC5F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuCA,eAAeA,sBAAsB,CACnC,UACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"names":["requireNativeComponent","MenuComponent"],"sources":["UIMenuView.android.tsx"],"sourcesContent":["import { HostComponent, requireNativeComponent } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\nconst MenuComponent = requireNativeComponent(\n 'MenuView'\n) as HostComponent<NativeMenuComponentProps>;\n\nexport default MenuComponent;\n"],"mappings":"AAAA,SAAwBA,sBAAxB,QAAsD,cAAtD;AAGA,MAAMC,aAAa,GAAGD,sBAAsB,CAC1C,UAD0C,CAA5C;AAIA,eAAeC,aAAf"}
1
+ {"version":3,"names":["requireNativeComponent","MenuComponent"],"sourceRoot":"../../src","sources":["UIMenuView.android.tsx"],"mappings":"AAAA,SAAwBA,sBAAsB,QAAQ,cAAc;AAGpE,MAAMC,aAAa,GAAGD,sBAAsB,CAC1C,UACF,CAA4C;AAE5C,eAAeC,aAAa"}
@@ -1,4 +1,3 @@
1
- import { requireNativeComponent } from 'react-native';
2
- const MenuComponent = requireNativeComponent('RCTUIMenu');
3
- export default MenuComponent;
1
+ import UIMenuNativeComponent from './NativeModuleSpecs/UIMenuNativeComponent';
2
+ export default UIMenuNativeComponent;
4
3
  //# sourceMappingURL=UIMenuView.ios.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["requireNativeComponent","MenuComponent"],"sources":["UIMenuView.ios.tsx"],"sourcesContent":["import { HostComponent, requireNativeComponent } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\nconst MenuComponent = requireNativeComponent(\n 'RCTUIMenu'\n) as HostComponent<NativeMenuComponentProps>;\n\nexport default MenuComponent;\n"],"mappings":"AAAA,SAAwBA,sBAAxB,QAAsD,cAAtD;AAGA,MAAMC,aAAa,GAAGD,sBAAsB,CAC1C,WAD0C,CAA5C;AAIA,eAAeC,aAAf"}
1
+ {"version":3,"names":["UIMenuNativeComponent"],"sourceRoot":"../../src","sources":["UIMenuView.ios.tsx"],"mappings":"AAAA,OAAOA,qBAAqB,MAAM,2CAA2C;AAE7E,eAAeA,qBAAqB"}
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { View } from 'react-native';
3
-
4
3
  /**
5
4
  * TODO: implement for Web
6
5
  */
@@ -12,6 +11,5 @@ const MenuView = ({
12
11
  style: style
13
12
  }, children);
14
13
  };
15
-
16
14
  export default MenuView;
17
15
  //# sourceMappingURL=UIMenuView.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","View","MenuView","style","children"],"sources":["UIMenuView.tsx"],"sourcesContent":["import * as React from 'react';\nimport { View } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\n/**\n * TODO: implement for Web\n */\nconst MenuView: React.FC<React.PropsWithChildren<NativeMenuComponentProps>> = ({\n style,\n children,\n}) => {\n return <View style={style}>{children}</View>;\n};\n\nexport default MenuView;\n"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAAqB,cAArB;;AAGA;AACA;AACA;AACA,MAAMC,QAAqE,GAAG,CAAC;EAC7EC,KAD6E;EAE7EC;AAF6E,CAAD,KAGxE;EACJ,oBAAO,oBAAC,IAAD;IAAM,KAAK,EAAED;EAAb,GAAqBC,QAArB,CAAP;AACD,CALD;;AAOA,eAAeF,QAAf"}
1
+ {"version":3,"names":["React","View","MenuView","style","children","createElement"],"sourceRoot":"../../src","sources":["UIMenuView.tsx"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,IAAI,QAAQ,cAAc;AAGnC;AACA;AACA;AACA,MAAMC,QAAqE,GAAGA,CAAC;EAC7EC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,oBAAOJ,KAAA,CAAAK,aAAA,CAACJ,IAAI;IAACE,KAAK,EAAEA;EAAM,GAAEC,QAAe,CAAC;AAC9C,CAAC;AAED,eAAeF,QAAQ"}
@@ -1,28 +1,28 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React from 'react';
2
+ import React, { useMemo } from 'react';
4
3
  import { processColor } from 'react-native';
5
4
  import UIMenuView from './UIMenuView';
6
-
5
+ import { objectHash } from './utils';
7
6
  function processAction(action) {
8
- var _action$subactions;
9
-
10
- return { ...action,
7
+ return {
8
+ ...action,
11
9
  imageColor: processColor(action.imageColor),
12
10
  titleColor: processColor(action.titleColor),
13
- subactions: (_action$subactions = action.subactions) === null || _action$subactions === void 0 ? void 0 : _action$subactions.map(subAction => processAction(subAction))
11
+ subactions: action.subactions?.map(subAction => processAction(subAction))
14
12
  };
15
13
  }
16
-
17
14
  const MenuView = ({
18
15
  actions,
19
16
  ...props
20
17
  }) => {
21
18
  const processedActions = actions.map(action => processAction(action));
19
+ const hash = useMemo(() => {
20
+ return objectHash(processedActions);
21
+ }, [processedActions]);
22
22
  return /*#__PURE__*/React.createElement(UIMenuView, _extends({}, props, {
23
- actions: processedActions
23
+ actions: processedActions,
24
+ actionsHash: hash
24
25
  }));
25
26
  };
26
-
27
27
  export { MenuView };
28
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","processColor","UIMenuView","processAction","action","imageColor","titleColor","subactions","map","subAction","MenuView","actions","props","processedActions"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\nimport { processColor } from 'react-native';\n\nimport UIMenuView from './UIMenuView';\nimport type {\n MenuComponentProps,\n MenuAction,\n ProcessedMenuAction,\n NativeActionEvent,\n} from './types';\n\nfunction processAction(action: MenuAction): ProcessedMenuAction {\n return {\n ...action,\n imageColor: processColor(action.imageColor),\n titleColor: processColor(action.titleColor),\n subactions: action.subactions?.map((subAction) => processAction(subAction)),\n };\n}\n\nconst MenuView: React.FC<MenuComponentProps> = ({ actions, ...props }) => {\n const processedActions = actions.map<ProcessedMenuAction>((action) =>\n processAction(action)\n );\n return <UIMenuView {...props} actions={processedActions} />;\n};\n\nexport { MenuView };\nexport type { MenuComponentProps, MenuAction, NativeActionEvent };\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,YAAT,QAA6B,cAA7B;AAEA,OAAOC,UAAP,MAAuB,cAAvB;;AAQA,SAASC,aAAT,CAAuBC,MAAvB,EAAgE;EAAA;;EAC9D,OAAO,EACL,GAAGA,MADE;IAELC,UAAU,EAAEJ,YAAY,CAACG,MAAM,CAACC,UAAR,CAFnB;IAGLC,UAAU,EAAEL,YAAY,CAACG,MAAM,CAACE,UAAR,CAHnB;IAILC,UAAU,wBAAEH,MAAM,CAACG,UAAT,uDAAE,mBAAmBC,GAAnB,CAAwBC,SAAD,IAAeN,aAAa,CAACM,SAAD,CAAnD;EAJP,CAAP;AAMD;;AAED,MAAMC,QAAsC,GAAG,CAAC;EAAEC,OAAF;EAAW,GAAGC;AAAd,CAAD,KAA2B;EACxE,MAAMC,gBAAgB,GAAGF,OAAO,CAACH,GAAR,CAAkCJ,MAAD,IACxDD,aAAa,CAACC,MAAD,CADU,CAAzB;EAGA,oBAAO,oBAAC,UAAD,eAAgBQ,KAAhB;IAAuB,OAAO,EAAEC;EAAhC,GAAP;AACD,CALD;;AAOA,SAASH,QAAT"}
1
+ {"version":3,"names":["React","useMemo","processColor","UIMenuView","objectHash","processAction","action","imageColor","titleColor","subactions","map","subAction","MenuView","actions","props","processedActions","hash","createElement","_extends","actionsHash"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,YAAY,QAAQ,cAAc;AAE3C,OAAOC,UAAU,MAAM,cAAc;AAOrC,SAASC,UAAU,QAAQ,SAAS;AAEpC,SAASC,aAAaA,CAACC,MAAkB,EAAuB;EAC9D,OAAO;IACL,GAAGA,MAAM;IACTC,UAAU,EAAEL,YAAY,CAACI,MAAM,CAACC,UAAU,CAAC;IAC3CC,UAAU,EAAEN,YAAY,CAACI,MAAM,CAACE,UAAU,CAAC;IAC3CC,UAAU,EAAEH,MAAM,CAACG,UAAU,EAAEC,GAAG,CAAEC,SAAS,IAAKN,aAAa,CAACM,SAAS,CAAC;EAC5E,CAAC;AACH;AAEA,MAAMC,QAAsC,GAAGA,CAAC;EAAEC,OAAO;EAAE,GAAGC;AAAM,CAAC,KAAK;EACxE,MAAMC,gBAAgB,GAAGF,OAAO,CAACH,GAAG,CAAuBJ,MAAM,IAC/DD,aAAa,CAACC,MAAM,CACtB,CAAC;EACD,MAAMU,IAAI,GAAGf,OAAO,CAAC,MAAM;IACzB,OAAOG,UAAU,CAACW,gBAAgB,CAAC;EACrC,CAAC,EAAE,CAACA,gBAAgB,CAAC,CAAC;EACtB,oBACEf,KAAA,CAAAiB,aAAA,CAACd,UAAU,EAAAe,QAAA,KAAKJ,KAAK;IAAED,OAAO,EAAEE,gBAAiB;IAACI,WAAW,EAAEH;EAAK,EAAE,CAAC;AAE3E,CAAC;AAED,SAASJ,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n ColorValue,\n processColor,\n StyleProp,\n ViewStyle,\n} from 'react-native';\nimport type * as React from 'react';\n\nexport type NativeActionEvent = {\n nativeEvent: {\n event: string;\n };\n};\n\ntype MenuAttributes = {\n /**\n * An attribute indicating the destructive style.\n */\n destructive?: boolean;\n /**\n * An attribute indicating the disabled style.\n */\n disabled?: boolean;\n /**\n * An attribute indicating the hidden style.\n */\n hidden?: boolean;\n};\n\n/**\n * The state of the action.\n * - off: A constant indicating the menu element is in the “off” state.\n * - on: A constant indicating the menu element is in the “on” state.\n * - mixed: A constant indicating the menu element is in the “mixed” state.\n */\ntype MenuState = 'off' | 'on' | 'mixed';\n\nexport type MenuAction = {\n /**\n * Identifier of the menu action.\n * The value set in this id will be returned when menu is selected.\n */\n id?: string;\n /**\n * The action's title.\n */\n title: string;\n /**\n * (Android only)\n * The action's title color.\n * @platform Android\n */\n titleColor?: number | ColorValue;\n /**\n * (iOS14+ only)\n * An elaborated title that explains the purpose of the action.\n * @platform iOS\n */\n subtitle?: string;\n /**\n * The attributes indicating the style of the action.\n */\n attributes?: MenuAttributes;\n /**\n * (iOS14+ only)\n * The state of the action.\n * @platform iOS\n */\n state?: MenuState;\n /**\n * (Android and iOS13+ only)\n * - The action's image.\n * - Allows icon name included in project or system (Android) resources drawables and\n * in SF Symbol (iOS)\n * @example // (iOS)\n * image=\"plus\"\n * @example // (Android)\n * image=\"ic_menu_add\"\n * - TODO: Allow images other than those included in SF Symbol and resources drawables\n */\n image?: string;\n /**\n * (Android and iOS13+ only)\n * - The action's image color.\n */\n imageColor?: number | ColorValue;\n /**\n * (Android and iOS14+ only)\n * - Actions to be displayed in the sub menu\n * - On Android it does not support nesting next sub menus in sub menu item\n */\n subactions?: MenuAction[];\n /**\n * Whether subactions should be inline (separated by divider) or nested (sub menu)\n */\n displayInline?: boolean;\n};\n\ntype MenuComponentPropsBase = {\n style?: StyleProp<ViewStyle>;\n /**\n * Callback function that will be called when selecting a menu item.\n * It will contain id of the given action.\n */\n onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;\n /**\n * Actions to be displayed in the menu.\n */\n actions: MenuAction[];\n /**\n * The title of the menu.\n */\n title?: string;\n /**\n * (Android API 23+)\n * Boolean value determines whether popup menu should be anchored\n * to right corner of parent view - default value is `false`\n * @platform Android\n */\n isAnchoredToRight?: boolean;\n /**\n * Determines if menu should open after long press or on normal press\n *\n * @default false\n */\n shouldOpenOnLongPress?: boolean;\n /**\n * Overrides theme variant of menu to light mode, dark mode or system theme\n * (Only support iOS for now)\n *\n * @platform iOS\n */\n themeVariant?: string;\n};\n\nexport type MenuComponentProps =\n React.PropsWithChildren<MenuComponentPropsBase>;\n\nexport type ProcessedMenuAction = Omit<\n MenuAction,\n 'imageColor' | 'titleColor' | 'subactions'\n> & {\n imageColor: ReturnType<typeof processColor>;\n titleColor: ReturnType<typeof processColor>;\n subactions?: ProcessedMenuAction[];\n};\n\nexport type NativeMenuComponentProps = {\n style?: StyleProp<ViewStyle>;\n onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;\n actions: ProcessedMenuAction[];\n title?: string;\n};\n"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":""}
@@ -0,0 +1,25 @@
1
+ // Function to calculate a simple hash code for a string
2
+ function hashCode(str) {
3
+ let hash = 0;
4
+ for (let i = 0; i < str.length; i++) {
5
+ const char = str.charCodeAt(i);
6
+ hash = (hash << 5) - hash + char;
7
+ }
8
+ return hash;
9
+ }
10
+
11
+ // Function to create a string hash from a TypeScript object
12
+ export function objectHash(obj) {
13
+ if (!obj) {
14
+ return '';
15
+ }
16
+ // Convert the object to a JSON string
17
+ const jsonString = JSON.stringify(obj);
18
+
19
+ // Calculate the hash code of the JSON string
20
+ const hash = hashCode(jsonString);
21
+
22
+ // Convert the hash code to a string (optional)
23
+ return String(hash);
24
+ }
25
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +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;IAC9BD,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"}
@@ -0,0 +1,44 @@
1
+ import type { DirectEventHandler, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
2
+ import type { HostComponent, ViewProps } from 'react-native';
3
+ declare type SubAction = {
4
+ id?: string;
5
+ title: string;
6
+ titleColor?: Int32;
7
+ subtitle?: string;
8
+ state?: string;
9
+ image?: string;
10
+ imageColor?: Int32;
11
+ displayInline?: boolean;
12
+ attributes?: {
13
+ destructive?: boolean;
14
+ disabled?: boolean;
15
+ hidden?: boolean;
16
+ };
17
+ };
18
+ declare type MenuAction = {
19
+ id?: string;
20
+ title: string;
21
+ titleColor?: Int32;
22
+ subtitle?: string;
23
+ state?: string;
24
+ image?: string;
25
+ imageColor?: Int32;
26
+ displayInline?: boolean;
27
+ attributes?: {
28
+ destructive?: boolean;
29
+ disabled?: boolean;
30
+ hidden?: boolean;
31
+ };
32
+ subactions?: Array<SubAction>;
33
+ };
34
+ export interface NativeProps extends ViewProps {
35
+ onPressAction?: DirectEventHandler<{
36
+ event: string;
37
+ }>;
38
+ actions: Array<MenuAction>;
39
+ actionsHash: string;
40
+ title?: string;
41
+ }
42
+ declare const _default: HostComponent<NativeProps>;
43
+ export default _default;
44
+ //# sourceMappingURL=UIMenuNativeComponent.d.ts.map
@@ -0,0 +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,aAAK,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,aAAK,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,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;IACF,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC/B,CAAC;AACF,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,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;CAChB;;AAED,wBAEgC"}
@@ -2,3 +2,4 @@ import { HostComponent } from 'react-native';
2
2
  import type { NativeMenuComponentProps } from './types';
3
3
  declare const MenuComponent: HostComponent<NativeMenuComponentProps>;
4
4
  export default MenuComponent;
5
+ //# sourceMappingURL=UIMenuView.android.d.ts.map
@@ -0,0 +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,yCAEyB,CAAC;AAE7C,eAAe,aAAa,CAAC"}
@@ -5,3 +5,4 @@ import type { NativeMenuComponentProps } from './types';
5
5
  */
6
6
  declare const MenuView: React.FC<React.PropsWithChildren<NativeMenuComponentProps>>;
7
7
  export default MenuView;
8
+ //# sourceMappingURL=UIMenuView.d.ts.map
@@ -0,0 +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,CAKzE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,4 +1,3 @@
1
- import { HostComponent } from 'react-native';
2
- import type { NativeMenuComponentProps } from './types';
3
- declare const MenuComponent: HostComponent<NativeMenuComponentProps>;
4
- export default MenuComponent;
1
+ import UIMenuNativeComponent from './NativeModuleSpecs/UIMenuNativeComponent';
2
+ export default UIMenuNativeComponent;
3
+ //# sourceMappingURL=UIMenuView.ios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UIMenuView.ios.d.ts","sourceRoot":"","sources":["../../../src/UIMenuView.ios.tsx"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,2CAA2C,CAAC;AAE9E,eAAe,qBAAqB,CAAC"}
@@ -3,3 +3,4 @@ import type { MenuComponentProps, MenuAction, NativeActionEvent } from './types'
3
3
  declare const MenuView: React.FC<MenuComponentProps>;
4
4
  export { MenuView };
5
5
  export type { MenuComponentProps, MenuAction, NativeActionEvent };
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;AAYjB,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAU1C,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC"}
@@ -132,6 +132,8 @@ export declare type NativeMenuComponentProps = {
132
132
  style?: StyleProp<ViewStyle>;
133
133
  onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;
134
134
  actions: ProcessedMenuAction[];
135
+ actionsHash: string;
135
136
  title?: string;
136
137
  };
137
138
  export {};
139
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,oBAAY,iBAAiB,GAAG;IAC9B,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,aAAK,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;CAClB,CAAC;AAEF;;;;;GAKG;AACH,aAAK,SAAS,GAAG,KAAK,GAAG,IAAI,GAAG,OAAO,CAAC;AAExC,oBAAY,UAAU,GAAG;IACvB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACjC;;;;OAIG;IACH,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,aAAK,sBAAsB,GAAG;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC7D;;OAEG;IACH,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,oBAAY,kBAAkB,GAC5B,KAAK,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;AAElD,oBAAY,mBAAmB,GAAG,IAAI,CACpC,UAAU,EACV,YAAY,GAAG,YAAY,GAAG,YAAY,CAC3C,GAAG;IACF,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IAC5C,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IAC5C,UAAU,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACpC,CAAC;AAEF,oBAAY,wBAAwB,GAAG;IACrC,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;CAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function objectHash(obj: Record<string, any>): string;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAWA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAY3D"}