@react-native-menu/menu 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Package.swift CHANGED
@@ -14,21 +14,26 @@ let reactHeaders: [Target.Dependency] = [
14
14
  // The Swift import shim lives outside ios/. Keep unrelated repository and npm
15
15
  // package contents out of SwiftPM's resource discovery.
16
16
  let usedRootEntries: Set<String> = ["ios", "spm-support", "spm-headers", "Package.swift"]
17
- let unusedRootEntries = try! FileManager.default.contentsOfDirectory(atPath: Context.packageDirectory)
17
+ // `try?` rather than `try!`: a manifest that traps reports a Swift fatal error
18
+ // instead of a SwiftPM diagnostic, which is a miserable thing to debug.
19
+ let unusedRootEntries = ((try? FileManager.default.contentsOfDirectory(atPath: Context.packageDirectory)) ?? [])
18
20
  .filter { !usedRootEntries.contains($0) }
19
21
  .sorted()
20
22
 
21
23
  // Discover sources as folders, splitting the podspec's native and Swift files.
22
24
  // Exclude projects and non-source files from both targets.
23
25
  let iosDirectory = URL(fileURLWithPath: Context.packageDirectory).appendingPathComponent("ios")
24
- let iosEntries = try! FileManager.default.subpathsOfDirectory(atPath: iosDirectory.path)
26
+ let iosEntries = ((try? FileManager.default.subpathsOfDirectory(atPath: iosDirectory.path)) ?? [])
25
27
  .filter { !$0.contains(".xcodeproj/") }
26
28
  func unusedIosEntries(sourceExtensions: Set<String>) -> [String] {
27
29
  iosEntries.filter { entry in
28
30
  let url = iosDirectory.appendingPathComponent(entry)
29
31
  if url.pathExtension == "xcodeproj" { return true }
30
- let isFile = try! url.resourceValues(forKeys: [.isRegularFileKey]).isRegularFile == true
31
- return isFile && (!sourceExtensions.contains(url.pathExtension)
32
+ // An entry that cannot be stat'd -- a dangling symlink, say -- counts as
33
+ // a file so it stays excludable. Excluding a directory would drop
34
+ // everything inside it.
35
+ let isDirectory = (try? url.resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory ?? false
36
+ return !isDirectory && (!sourceExtensions.contains(url.pathExtension)
32
37
  || entry == "Menu-Bridging-Header.h")
33
38
  }
34
39
  .map { "ios/" + $0 }
@@ -63,7 +68,11 @@ let package = Package(
63
68
  // Root the target here so its empty public module stays outside ios/.
64
69
  path: ".",
65
70
  exclude: unusedRootEntries + ["spm-support"] + unusedObjCIosEntries,
66
- sources: ["ios"],
71
+ // Name the source directories rather than all of ios/: a stray .h,
72
+ // .m or .mm anywhere under ios/ (stale codegen output under
73
+ // ios/build/, say, in a consumer using this as a path dependency)
74
+ // would otherwise be compiled into this target.
75
+ sources: ["ios/MenuViewManager.mm", "ios/Shared", "ios/OldArch", "ios/NewArch"],
67
76
  // Required: without it SwiftPM looks for a default include/ folder, which this target does not have.
68
77
  publicHeadersPath: "spm-headers/public",
69
78
  cSettings: [
package/README.md CHANGED
@@ -179,6 +179,14 @@ String to override theme of the menu. If you want to control theme universally a
179
179
  |-----------------------|----------|
180
180
  | enum('light', 'dark') | No |
181
181
 
182
+ ### `preferredMenuElementOrder` (iOS 16+ only)
183
+
184
+ The order of the menu's actions when it opens. With the default `automatic`, iOS may reorder them, so a menu that opens upward (from a button near the bottom of the screen) lists its actions in reverse. Use `fixed` to keep the order of `actions` wherever the menu opens, or `priority` to keep the first action closest to the button. Ignored before iOS 16.
185
+
186
+ | Type | Required | Default |
187
+ |----------------------------------------|----------|---------------|
188
+ | enum('automatic', 'priority', 'fixed') | No | `'automatic'` |
189
+
182
190
  #### `MenuAction`
183
191
 
184
192
  Object representing Menu Action.
@@ -73,6 +73,11 @@ RCT_EXPORT_VIEW_PROPERTY(shouldOpenOnLongPress, BOOL)
73
73
  * themeVariant: determines whether menu should use dark theme, light theme or system theme
74
74
  */
75
75
  RCT_EXPORT_VIEW_PROPERTY(themeVariant, NSString)
76
+ /**
77
+ * preferredMenuElementOrder: 'automatic', 'priority' or 'fixed' (iOS 16+). Remapped because UIButton
78
+ * already has a preferredMenuElementOrder property of its own type.
79
+ */
80
+ RCT_REMAP_VIEW_PROPERTY(preferredMenuElementOrder, menuElementOrder, NSString)
76
81
 
77
82
  /**
78
83
  * hitSlop: The same as hitSlop in React Native
@@ -5,6 +5,7 @@ import Foundation
5
5
  var themeVariant: NSString? { get set }
6
6
  var shouldOpenOnLongPress: Bool { get set }
7
7
  @objc optional var hitSlop: UIEdgeInsets { get set }
8
+ @objc optional var menuElementOrder: NSString? { get set }
8
9
  var onPressAction: ((String) -> Void)? { get set }
9
10
  var onCloseMenu: (() -> Void)? { get set }
10
11
  var onOpenMenu: (() -> Void)? { get set }
@@ -172,6 +172,11 @@ using namespace facebook::react;
172
172
  [self applyLongPressThemeVariant];
173
173
  }
174
174
 
175
+ if (oldViewProps.preferredMenuElementOrder != newViewProps.preferredMenuElementOrder &&
176
+ [_view respondsToSelector:@selector(setMenuElementOrder:)]) {
177
+ _view.menuElementOrder = [NSString stringWithUTF8String:newViewProps.preferredMenuElementOrder.c_str()];
178
+ }
179
+
175
180
  if (oldViewProps.shouldOpenOnLongPress != newViewProps.shouldOpenOnLongPress) {
176
181
  _view.shouldOpenOnLongPress = newViewProps.shouldOpenOnLongPress;
177
182
  [self setOpensOnLongPress:newViewProps.shouldOpenOnLongPress];
@@ -52,6 +52,12 @@ public class MenuViewImplementation: UIButton {
52
52
 
53
53
  @objc public var hitSlop: UIEdgeInsets = .zero
54
54
 
55
+ // The `preferredMenuElementOrder` prop. Named apart from UIButton's own
56
+ // `preferredMenuElementOrder`, which UIKit only applies to a configuration
57
+ // it builds itself; this class builds its own in
58
+ // configurationForMenuAtLocation, so it applies the order there.
59
+ @objc public var menuElementOrder: NSString?
60
+
55
61
  override init(frame: CGRect) {
56
62
  super.init(frame: frame)
57
63
  let interaction = UIContextMenuInteraction(delegate: self)
@@ -61,10 +67,21 @@ public class MenuViewImplementation: UIButton {
61
67
 
62
68
  public override func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
63
69
  sendMenuOpen()
64
- return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in
70
+ let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in
65
71
  guard let self = self else { return nil }
66
72
  return self.menu
67
73
  }
74
+ if #available(iOS 16.0, *) {
75
+ switch menuElementOrder {
76
+ case "fixed":
77
+ configuration.preferredMenuElementOrder = .fixed
78
+ case "priority":
79
+ configuration.preferredMenuElementOrder = .priority
80
+ default:
81
+ configuration.preferredMenuElementOrder = .automatic
82
+ }
83
+ }
84
+ return configuration
68
85
  }
69
86
 
70
87
  public override func contextMenuInteraction(_ interaction: UIContextMenuInteraction, willEndFor configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionAnimating?) {
@@ -62,6 +62,7 @@ export interface NativeProps extends ViewProps {
62
62
  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)
63
63
  title?: string;
64
64
  themeVariant?: string;
65
+ preferredMenuElementOrder?: string;
65
66
  isAnchoredToRight?: boolean;
66
67
  shouldOpenOnLongPress?: boolean;
67
68
  hitSlop: {
@@ -62,6 +62,7 @@ export interface NativeProps extends ViewProps {
62
62
  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)
63
63
  title?: string;
64
64
  themeVariant?: string;
65
+ preferredMenuElementOrder?: string;
65
66
  isAnchoredToRight?: boolean;
66
67
  shouldOpenOnLongPress?: boolean;
67
68
  hitSlop: {
@@ -46,6 +46,7 @@ export interface NativeProps extends ViewProps {
46
46
  actionsHash: string;
47
47
  title?: string;
48
48
  themeVariant?: string;
49
+ preferredMenuElementOrder?: string;
49
50
  isAnchoredToRight?: boolean;
50
51
  shouldOpenOnLongPress?: boolean;
51
52
  hitSlop: {
@@ -1 +1 @@
1
- {"version":3,"file":"UIMenuNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/NativeModuleSpecs/UIMenuNativeComponent.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACX,kBAAkB,EAClB,KAA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IAC5B,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,CAAC;CACF;wBAII,aAAa,CAAC,WAAW,CAAC;AAF/B,wBAEgC"}
@@ -9,6 +9,7 @@ declare const MenuView: import("react").ForwardRefExoticComponent<{
9
9
  isAnchoredToRight?: boolean;
10
10
  shouldOpenOnLongPress?: boolean;
11
11
  themeVariant?: string;
12
+ preferredMenuElementOrder?: "automatic" | "priority" | "fixed";
12
13
  hitSlop?: {
13
14
  top: number;
14
15
  bottom: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,kBAAkB,EAClB,UAAU,EAEV,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAcjB,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;oDAmBb,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EACX,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,iBAAiB,GACjB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,kBAAkB,EAClB,UAAU,EAEV,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAcjB,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;oDAmBb,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EACX,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,iBAAiB,GACjB,CAAC"}
@@ -141,6 +141,17 @@ type MenuComponentPropsBase = {
141
141
  * @platform iOS
142
142
  */
143
143
  themeVariant?: string;
144
+ /**
145
+ * (iOS 16+) The order of the menu's elements. With `automatic`, the system
146
+ * may reorder them, so a menu that opens upward from a button near the
147
+ * bottom of the screen lists its actions in reverse. `fixed` keeps the
148
+ * order of `actions` in every position; `priority` keeps the first action
149
+ * closest to where the menu opens.
150
+ *
151
+ * @default 'automatic'
152
+ * @platform iOS
153
+ */
154
+ preferredMenuElementOrder?: "automatic" | "priority" | "fixed";
144
155
  /**
145
156
  * Custom OpenSpace hitSlop prop. Works like touchable hitslop.
146
157
  * @platform iOS
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,MAAM,MAAM,iBAAiB,GAAG;IAC/B,WAAW,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;CACF,CAAC;AAEF,KAAK,cAAc,GAAG;IACrB;;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;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,KAAK,SAAS,GAAG,KAAK,GAAG,IAAI,GAAG,OAAO,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG;IACxB;;;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;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AC;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-menu/menu",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "UIMenu component for react-native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -31,6 +31,7 @@
31
31
  "pods": "cd example && pod-install --quiet",
32
32
  "prepare": "bob build",
33
33
  "release": "release-it",
34
+ "spm:check": "node scripts/check-spm.mjs",
34
35
  "start": "react-native start",
35
36
  "test": "jest",
36
37
  "typescript": "tsc --noEmit",
@@ -52,23 +53,23 @@
52
53
  },
53
54
  "homepage": "https://github.com/react-native-menu/menu#readme",
54
55
  "devDependencies": {
55
- "@biomejs/biome": "2.6.7",
56
+ "@biomejs/biome": "2.6.8",
56
57
  "@callstack/react-native-visionos": "^0.79.6",
57
58
  "@react-native-community/cli": "^20.0.2",
58
59
  "@react-native/babel-preset": "^0.81.1",
59
60
  "@react-native/metro-config": "0.81.1",
60
- "@release-it/conventional-changelog": "^11.0.1",
61
+ "@release-it/conventional-changelog": "^12.0.2",
61
62
  "@rnx-kit/metro-config": "^2.1.1",
62
- "@types/jest": "^29.1.2",
63
+ "@types/jest": "^30.0.0",
63
64
  "@types/react": "^19.1.12",
64
65
  "@types/react-native": "0.73.0",
65
- "jest": "^29.2.1",
66
+ "jest": "^30.5.2",
66
67
  "pod-install": "1.2.1",
67
68
  "react": "19.1.0",
68
69
  "react-native": "^0.81.1",
69
70
  "react-native-builder-bob": "^0.44.1",
70
71
  "react-native-test-app": "^4.4.9",
71
- "release-it": "^18.1.1",
72
+ "release-it": "^21.1.2",
72
73
  "typescript": "5.9.3"
73
74
  },
74
75
  "peerDependencies": {
@@ -113,7 +114,7 @@
113
114
  "access": "public"
114
115
  },
115
116
  "volta": {
116
- "node": "22.11.0"
117
+ "node": "22.23.5"
117
118
  },
118
119
  "swiftpmConfig": {
119
120
  "name": "react_native_menu"
@@ -19,8 +19,17 @@ __attribute__((objc_runtime_name("_TtP17react_native_menu32FabricViewImplementat
19
19
  @property (nonatomic, copy, nullable) void (^onOpenMenu)(void);
20
20
  @optional
21
21
  @property (nonatomic) UIEdgeInsets hitSlop;
22
+ @property (nonatomic, strong, nullable) NSString *menuElementOrder;
22
23
  @end
23
24
 
25
+ // The superclasses are flattened on purpose: MenuView.mm only ever reaches
26
+ // protocol members and UIKit ones, so mirroring MenuViewImplementation and
27
+ // ActionSheetView here would double the surface that can drift. If MenuView.mm
28
+ // ever needs a member declared on one of those bases, mirror the base class
29
+ // rather than widening the protocol. Availability has to match the Swift
30
+ // declarations, though -- calling an iOS 14 only class outside an availability
31
+ // check does not compile. scripts/check-spm.mjs enforces both halves.
32
+ API_AVAILABLE(ios(14.0))
24
33
  @interface FabricMenuViewImplementation : UIButton <FabricViewImplementationProtocol>
25
34
  @end
26
35
  @interface FabricActionSheetView : UIView <FabricViewImplementationProtocol>
@@ -62,6 +62,7 @@ export interface NativeProps extends ViewProps {
62
62
  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)
63
63
  title?: string;
64
64
  themeVariant?: string;
65
+ preferredMenuElementOrder?: string;
65
66
  isAnchoredToRight?: boolean;
66
67
  shouldOpenOnLongPress?: boolean;
67
68
  hitSlop: {
package/src/types.ts CHANGED
@@ -152,6 +152,17 @@ type MenuComponentPropsBase = {
152
152
  * @platform iOS
153
153
  */
154
154
  themeVariant?: string;
155
+ /**
156
+ * (iOS 16+) The order of the menu's elements. With `automatic`, the system
157
+ * may reorder them, so a menu that opens upward from a button near the
158
+ * bottom of the screen lists its actions in reverse. `fixed` keeps the
159
+ * order of `actions` in every position; `priority` keeps the first action
160
+ * closest to where the menu opens.
161
+ *
162
+ * @default 'automatic'
163
+ * @platform iOS
164
+ */
165
+ preferredMenuElementOrder?: "automatic" | "priority" | "fixed";
155
166
  /**
156
167
  * Custom OpenSpace hitSlop prop. Works like touchable hitslop.
157
168
  * @platform iOS