@ng-native/components 0.28.0 → 0.30.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 (123) hide show
  1. package/README.md +2 -2
  2. package/android/src/main/java/dev/ngnative/components/ColorSchemeModule.kt +116 -11
  3. package/dist/activity-indicator.js +3 -3
  4. package/dist/animated-style.js +3 -3
  5. package/dist/animations-web.js +3 -3
  6. package/dist/animations.js +3 -3
  7. package/dist/content-container.js +3 -3
  8. package/dist/context-menu.js +3 -3
  9. package/dist/drag-and-drop.js +6 -6
  10. package/dist/gestures-web.js +6 -6
  11. package/dist/gestures.js +6 -6
  12. package/dist/gradient-text.d.ts +1 -1
  13. package/dist/gradient-text.js +4 -4
  14. package/dist/gradient-text.js.map +1 -1
  15. package/dist/image-background.js +3 -3
  16. package/dist/image.js +3 -3
  17. package/dist/index.d.ts +3 -2
  18. package/dist/index.js +3 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/input-accessory-view.js +3 -3
  21. package/dist/keyboard-avoiding-view.js +3 -3
  22. package/dist/keyboard-dock.js +15 -15
  23. package/dist/markdown-blocks.d.ts +2 -1
  24. package/dist/markdown-blocks.js +22 -18
  25. package/dist/markdown-blocks.js.map +1 -1
  26. package/dist/markdown-columns.js +3 -3
  27. package/dist/markdown-stream.js +8 -5
  28. package/dist/markdown-stream.js.map +1 -1
  29. package/dist/markdown.js +5 -5
  30. package/dist/markdown.js.map +1 -1
  31. package/dist/menu.d.ts +11 -5
  32. package/dist/menu.js +24 -44
  33. package/dist/menu.js.map +1 -1
  34. package/dist/modal.js +8 -3
  35. package/dist/modal.js.map +1 -1
  36. package/dist/native-button.d.ts +25 -3
  37. package/dist/native-button.js +102 -8
  38. package/dist/native-button.js.map +1 -1
  39. package/dist/native-gesture.js +3 -3
  40. package/dist/native-ref.js +3 -3
  41. package/dist/press-menu.d.ts +38 -8
  42. package/dist/press-menu.js +80 -19
  43. package/dist/press-menu.js.map +1 -1
  44. package/dist/pressable.js +14 -13
  45. package/dist/pressable.js.map +1 -1
  46. package/dist/reanimated-web.js +6 -6
  47. package/dist/reanimated.js +6 -6
  48. package/dist/refresh-control.js +3 -3
  49. package/dist/safe-area-provider.js +3 -3
  50. package/dist/safe-area-view.js +3 -3
  51. package/dist/scroll-view-props.js +3 -3
  52. package/dist/scroll-view.d.ts +3 -1
  53. package/dist/scroll-view.js +10 -5
  54. package/dist/scroll-view.js.map +1 -1
  55. package/dist/section-list.d.ts +4 -4
  56. package/dist/section-list.js +37 -34
  57. package/dist/section-list.js.map +1 -1
  58. package/dist/shortcut.js +3 -3
  59. package/dist/sidebar-item.js +3 -3
  60. package/dist/sidebar-section.d.ts +12 -5
  61. package/dist/sidebar-section.js +32 -12
  62. package/dist/sidebar-section.js.map +1 -1
  63. package/dist/sidebar.d.ts +11 -3
  64. package/dist/sidebar.js +18 -8
  65. package/dist/sidebar.js.map +1 -1
  66. package/dist/split-view.d.ts +23 -2
  67. package/dist/split-view.js +36 -9
  68. package/dist/split-view.js.map +1 -1
  69. package/dist/stand-ins/animations.js +3 -3
  70. package/dist/sticky-headers.d.ts +19 -0
  71. package/dist/sticky-headers.js +67 -10
  72. package/dist/sticky-headers.js.map +1 -1
  73. package/dist/sticky-rows.d.ts +13 -11
  74. package/dist/sticky-rows.js +35 -21
  75. package/dist/sticky-rows.js.map +1 -1
  76. package/dist/svg-icon.d.ts +16 -2
  77. package/dist/svg-icon.js +19 -3
  78. package/dist/svg-icon.js.map +1 -1
  79. package/dist/switch.js +3 -3
  80. package/dist/template-slot.js +3 -3
  81. package/dist/text-input.js +3 -3
  82. package/dist/text.js +3 -3
  83. package/dist/touchable-opacity.js +3 -3
  84. package/dist/tray-icon.d.ts +7 -1
  85. package/dist/tray-icon.js +17 -5
  86. package/dist/tray-icon.js.map +1 -1
  87. package/dist/view-base.d.ts +18 -2
  88. package/dist/view-base.js +42 -10
  89. package/dist/view-base.js.map +1 -1
  90. package/dist/view.js +3 -3
  91. package/dist/virtual-list-layout.d.ts +5 -0
  92. package/dist/virtual-list-layout.js.map +1 -1
  93. package/dist/virtual-list-num-columns.d.ts +8 -4
  94. package/dist/virtual-list-num-columns.js +13 -5
  95. package/dist/virtual-list-num-columns.js.map +1 -1
  96. package/dist/virtual-list-sticky-level.d.ts +0 -6
  97. package/dist/virtual-list-sticky-level.js +5 -29
  98. package/dist/virtual-list-sticky-level.js.map +1 -1
  99. package/dist/virtual-list.d.ts +72 -11
  100. package/dist/virtual-list.js +285 -74
  101. package/dist/virtual-list.js.map +1 -1
  102. package/dist/visual-effect.d.ts +37 -0
  103. package/dist/visual-effect.js +60 -0
  104. package/dist/visual-effect.js.map +1 -0
  105. package/dist/worklet-scroll.js +3 -3
  106. package/dist/worklet-style.js +3 -3
  107. package/dist/written-props.js +9 -0
  108. package/dist/written-props.js.map +1 -1
  109. package/ios/NgNativeButtonComponentView.mm +8 -4
  110. package/ios/NgNativeButtonMetrics.h +9 -2
  111. package/ios/NgNativeButtonMetrics.mm +33 -4
  112. package/ios/NgNativeButtonShadowNode.h +2 -0
  113. package/ios/NgNativeButtonShadowNode.mm +5 -1
  114. package/ios/NgNativeComponents.podspec +2 -2
  115. package/ios/NgNativeKeyboardFocus.h +21 -0
  116. package/ios/NgNativeKeyboardFocus.mm +28 -0
  117. package/ios/NgNativeKeyboardFocusModule.mm +203 -0
  118. package/ios/NgNativeMenus.mm +62 -2
  119. package/ios/NgNativePressMenu.h +36 -0
  120. package/ios/NgNativePressMenu.mm +79 -0
  121. package/ios/NgNativeViewBinder.h +5 -0
  122. package/ios/NgNativeViewBinder.mm +31 -4
  123. package/package.json +6 -6
@@ -3,6 +3,7 @@
3
3
  #import <UIKit/UIKit.h>
4
4
 
5
5
  #import "NgNativeMenuBuilding.h"
6
+ #import "NgNativePressMenu.h"
6
7
  #import "NgNativeResponderHooks.h"
7
8
  #import "NgNativeViewBinder.h"
8
9
 
@@ -21,9 +22,14 @@
21
22
  that `nativeID`, added once the view is mounted, its menu read as it opens, and removed with
22
23
  null, or as the view is unmounted, recycled or renamed. A long press opens it, and a secondary
23
24
  click from an iPad pointer.
25
+ - `setPressMenu(nativeID, entries)`: a menu a press opens on React Native's view with that
26
+ `nativeID`, as a clear button over the view (NgNativePressMenu.h), added once the view is
27
+ mounted, its menu made again as the entries change, and removed with null, or as the view is
28
+ unmounted, recycled or renamed.
24
29
  - Events on `ngNativeMenus`: `menuSelect` for a menu bar item, `shortcut` with
25
- `textInputFocused`, `navigate` for the Back and Forward roles, and `contextMenuSelect` with the
26
- view's `nativeID` and the item's `id`, since React Native's view sends no event it does not know.
30
+ `textInputFocused`, `navigate` for the Back and Forward roles, and `contextMenuSelect` and
31
+ `pressMenuSelect` with the view's `nativeID` and the item's `id`, since React Native's view sends
32
+ no event it does not know.
27
33
  - `menuBar` is true on an iPad and false on an iPhone; `appName` is the bundle's display name.
28
34
  */
29
35
  @interface NgNativeMenus : NSObject <RCTBridgeModule, RCTInvalidating, NgNativeMenusHost>
@@ -106,6 +112,8 @@ static UIMenuIdentifier standardMenu(NSString *role)
106
112
  NSArray<UIKeyCommand *> *_shortcuts;
107
113
  NSMutableDictionary<NSString *, NSArray *> *_contextMenus;
108
114
  NgNativeViewBinder *_contextMenuViews;
115
+ NSMutableDictionary<NSString *, NSArray *> *_pressMenus;
116
+ NgNativeViewBinder *_pressMenuViews;
109
117
  // The views inside a context menu's that take a long press themselves, by `nativeID`.
110
118
  NSMutableSet<NSString *> *_longPressTakers;
111
119
  }
@@ -146,6 +154,21 @@ RCT_EXPORT_MODULE()
146
154
  detach:^(UIView *view, NgNativeContextMenuTarget *target) {
147
155
  [view removeInteraction:target.interaction];
148
156
  }];
157
+ _pressMenus = [NSMutableDictionary dictionary];
158
+ _pressMenuViews = [[NgNativeViewBinder alloc]
159
+ initWithAttach:^id(UIView *view, NSString *nativeID) {
160
+ NgNativeMenus *module = weakSelf;
161
+ NSArray *entries = module == nil ? nil : module->_pressMenus[nativeID];
162
+ if (entries == nil) {
163
+ return nil;
164
+ }
165
+ return NgNativeAddPressMenu(view, entries, ^(NSString *itemId) {
166
+ [weakSelf send:@{@"type" : @"pressMenuSelect", @"nativeID" : nativeID, @"id" : itemId}];
167
+ });
168
+ }
169
+ detach:^(UIView *view, NgNativePressMenuButton *button) {
170
+ [button removeFromSuperview];
171
+ }];
149
172
  dispatch_async(dispatch_get_main_queue(), ^{
150
173
  NgNativeInstallResponderHooks();
151
174
  NgNativeSetMenusHost(self);
@@ -161,6 +184,8 @@ RCT_EXPORT_MODULE()
161
184
  dispatch_async(dispatch_get_main_queue(), ^{
162
185
  [self->_contextMenuViews unbindAll];
163
186
  [self->_contextMenus removeAllObjects];
187
+ [self->_pressMenuViews unbindAll];
188
+ [self->_pressMenus removeAllObjects];
164
189
  [self->_longPressTakers removeAllObjects];
165
190
  self->_menuBar = @[];
166
191
  self->_shortcuts = @[];
@@ -168,12 +193,22 @@ RCT_EXPORT_MODULE()
168
193
  });
169
194
  }
170
195
 
196
+ /** Whether a press menu opens from code, by `openPressMenu`: iOS 17.4 and later. */
197
+ static BOOL opensPressMenus(void)
198
+ {
199
+ if (@available(iOS 17.4, *)) {
200
+ return YES;
201
+ }
202
+ return NO;
203
+ }
204
+
171
205
  - (NSDictionary *)constantsToExport
172
206
  {
173
207
  NSDictionary *info = NSBundle.mainBundle.infoDictionary;
174
208
  return @{
175
209
  @"menuBar" : @(UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad),
176
210
  @"appName" : info[@"CFBundleDisplayName"] ?: info[@"CFBundleName"] ?: @"",
211
+ @"opensPressMenus" : @(opensPressMenus()),
177
212
  };
178
213
  }
179
214
 
@@ -223,6 +258,31 @@ RCT_EXPORT_METHOD(setContextMenu : (NSString *)nativeID entries : (nullable NSAr
223
258
  }
224
259
  }
225
260
 
261
+ RCT_EXPORT_METHOD(setPressMenu : (NSString *)nativeID entries : (nullable NSArray *)entries)
262
+ {
263
+ if (![nativeID isKindOfClass:[NSString class]] || nativeID.length == 0) {
264
+ return;
265
+ }
266
+ if ([entries isKindOfClass:[NSArray class]] && entries.count > 0) {
267
+ _pressMenus[nativeID] = entries;
268
+ ((NgNativePressMenuButton *)[_pressMenuViews tokenFor:nativeID]).entries = entries;
269
+ [_pressMenuViews bind:nativeID];
270
+ } else {
271
+ [_pressMenus removeObjectForKey:nativeID];
272
+ [_pressMenuViews unbind:nativeID];
273
+ }
274
+ }
275
+
276
+ RCT_EXPORT_METHOD(openPressMenu : (NSString *)nativeID)
277
+ {
278
+ if (![nativeID isKindOfClass:[NSString class]] || _pressMenus[nativeID] == nil) {
279
+ return;
280
+ }
281
+ // The view was pressed or is on screen, so it is mounted and in a window, even where the binder
282
+ // has not looked for it again yet. A menu the button's own touch opened is showing, and stays.
283
+ NgNativeOpenPressMenu([_pressMenuViews tokenFindingNow:nativeID]);
284
+ }
285
+
226
286
  RCT_EXPORT_METHOD(setTakesLongPress : (NSString *)nativeID takes : (BOOL)takes)
227
287
  {
228
288
  if (![nativeID isKindOfClass:[NSString class]] || nativeID.length == 0) {
@@ -0,0 +1,36 @@
1
+ // A menu a press opens on React Native's view. UIKit opens a menu as a primary action only from a
2
+ // control of its own, so a clear button with `showsMenuAsPrimaryAction` is laid over the whole view,
3
+ // in the view that holds its children and above them. A touch then opens the menu as it goes down,
4
+ // as SwiftUI's `Menu` does, and a long press is the menu's too. From iOS 17.4,
5
+ // `NgNativeOpenPressMenu` opens it from code: for the app, and for a tap the view took before the
6
+ // button was laid.
7
+ #pragma once
8
+
9
+ #import <UIKit/UIKit.h>
10
+
11
+ #import "NgNativeMenuBuilding.h"
12
+
13
+ NS_ASSUME_NONNULL_BEGIN
14
+
15
+ @interface NgNativePressMenuButton : UIButton
16
+
17
+ - (instancetype)initWithChoose:(NgNativeMenuChoose)choose;
18
+ - (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
19
+ - (instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE;
20
+
21
+ // The menu, as the app sends it; setting it makes the button's menu again.
22
+ @property (nonatomic, copy) NSArray *entries;
23
+ // Whether the menu is showing.
24
+ @property (nonatomic, readonly) BOOL showing;
25
+
26
+ @end
27
+
28
+ // A press menu button with `entries` laid over `view`, whose choice runs `choose`.
29
+ NgNativePressMenuButton *NgNativeAddPressMenu(UIView *view, NSArray *entries, NgNativeMenuChoose choose);
30
+
31
+ // Open `button`'s menu now, unless it is showing: a touch on the button opens it, and React
32
+ // Native's own press on the view can follow. Answers whether it asked UIKit to open it. iOS 17.4 and
33
+ // later; does nothing before.
34
+ BOOL NgNativeOpenPressMenu(NgNativePressMenuButton *_Nullable button);
35
+
36
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,79 @@
1
+ #import "NgNativePressMenu.h"
2
+
3
+ /** React Native's view holds its children in a view of its own while its style clips overflow ink. */
4
+ @interface UIView (NgNativeContainerView)
5
+ - (UIView *)currentContainerView;
6
+ @end
7
+
8
+ @implementation NgNativePressMenuButton {
9
+ NgNativeMenuChoose _choose;
10
+ // Whether the menu is showing, from UIKit's display until its dismissal.
11
+ BOOL _showing;
12
+ }
13
+
14
+ - (instancetype)initWithChoose:(NgNativeMenuChoose)choose
15
+ {
16
+ if (self = [super initWithFrame:CGRectZero]) {
17
+ _choose = [choose copy];
18
+ _entries = @[];
19
+ self.backgroundColor = UIColor.clearColor;
20
+ self.showsMenuAsPrimaryAction = YES;
21
+ self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
22
+ // React Native's view is the accessibility element, with the app's label, role and state.
23
+ self.isAccessibilityElement = NO;
24
+ }
25
+ return self;
26
+ }
27
+
28
+ - (void)contextMenuInteraction:(UIContextMenuInteraction *)interaction
29
+ willDisplayMenuForConfiguration:(UIContextMenuConfiguration *)configuration
30
+ animator:(id<UIContextMenuInteractionAnimating>)animator
31
+ {
32
+ [super contextMenuInteraction:interaction willDisplayMenuForConfiguration:configuration animator:animator];
33
+ _showing = YES;
34
+ }
35
+
36
+ - (void)contextMenuInteraction:(UIContextMenuInteraction *)interaction
37
+ willEndForConfiguration:(UIContextMenuConfiguration *)configuration
38
+ animator:(id<UIContextMenuInteractionAnimating>)animator
39
+ {
40
+ [super contextMenuInteraction:interaction willEndForConfiguration:configuration animator:animator];
41
+ _showing = NO;
42
+ }
43
+
44
+ - (BOOL)showing
45
+ {
46
+ return _showing;
47
+ }
48
+
49
+ - (void)setEntries:(NSArray *)entries
50
+ {
51
+ _entries = [entries copy];
52
+ self.menu = [UIMenu menuWithTitle:@"" children:NgNativeMenuElements(_entries, _choose, NULL)];
53
+ }
54
+
55
+ @end
56
+
57
+ NgNativePressMenuButton *NgNativeAddPressMenu(UIView *view, NSArray *entries, NgNativeMenuChoose choose)
58
+ {
59
+ // React Native hit-tests only the children of the view that holds them, and moves every child
60
+ // with it as that view comes and goes, so the button stays in it, last.
61
+ UIView *holder = [view respondsToSelector:@selector(currentContainerView)] ? view.currentContainerView : view;
62
+ NgNativePressMenuButton *button = [[NgNativePressMenuButton alloc] initWithChoose:choose];
63
+ button.entries = entries;
64
+ button.frame = holder.bounds;
65
+ [holder addSubview:button];
66
+ return button;
67
+ }
68
+
69
+ BOOL NgNativeOpenPressMenu(NgNativePressMenuButton *button)
70
+ {
71
+ if (button == nil || button.showing) {
72
+ return NO;
73
+ }
74
+ if (@available(iOS 17.4, *)) {
75
+ [button performPrimaryAction];
76
+ return YES;
77
+ }
78
+ return NO;
79
+ }
@@ -36,6 +36,11 @@ typedef void (^NgNativeViewDetach)(UIView *view, id token);
36
36
  // answers its own, so a caller can tell the binding it started with from a later one of the same
37
37
  // name. Main thread.
38
38
  - (nullable id)tokenFor:(NSString *)nativeID;
39
+ // What attaching the view bound to `nativeID` answered, looking for that view now if it has not
40
+ // been found, however long the binder would otherwise wait: for a view the user has just touched,
41
+ // which is mounted and in a window. Nil when `nativeID` is not bound, or no view has it. Main
42
+ // thread.
43
+ - (nullable id)tokenFindingNow:(NSString *)nativeID;
39
44
  // Detach every view. Main thread.
40
45
  - (void)unbindAll;
41
46
  // Check each view still is the one with its `nativeID`, and look for the ones not found yet. Main
@@ -143,6 +143,36 @@ static void collect(UIView *view, NSSet<NSString *> *wanted, NSMutableDictionary
143
143
  return isValid(binding, nativeID) ? ((NgNativeBinding *)binding).token : nil;
144
144
  }
145
145
 
146
+ - (id)tokenFindingNow:(NSString *)nativeID
147
+ {
148
+ id binding = _bindings[nativeID];
149
+ if (binding == nil) {
150
+ return nil;
151
+ }
152
+ if (isValid(binding, nativeID)) {
153
+ return ((NgNativeBinding *)binding).token;
154
+ }
155
+ [self detach:nativeID];
156
+ _searches++;
157
+ NSMutableDictionary<NSString *, UIView *> *found = [NSMutableDictionary dictionary];
158
+ NSSet<NSString *> *wanted = [NSSet setWithObject:nativeID];
159
+ for (UIView *root in self.roots()) {
160
+ collect(root, wanted, found);
161
+ }
162
+ UIView *view = found[nativeID];
163
+ return view == nil ? nil : [self attach:view as:nativeID];
164
+ }
165
+
166
+ /** Attach `view` as the one with `nativeID`, and answer what attaching it answered. */
167
+ - (id)attach:(UIView *)view as:(NSString *)nativeID
168
+ {
169
+ NgNativeBinding *binding = [NgNativeBinding new];
170
+ binding.view = view;
171
+ binding.token = _attach(view, nativeID);
172
+ _bindings[nativeID] = binding;
173
+ return binding.token;
174
+ }
175
+
146
176
  - (void)unbindAll
147
177
  {
148
178
  for (NSString *nativeID in _bindings.allKeys) {
@@ -215,10 +245,7 @@ static void collect(UIView *view, NSSet<NSString *> *wanted, NSMutableDictionary
215
245
  }
216
246
  _searchInterval = found.count == 0 ? MIN(_searchInterval * 2, LongestSearchInterval) : FirstSearchInterval;
217
247
  [found enumerateKeysAndObjectsUsingBlock:^(NSString *nativeID, UIView *view, BOOL *stop) {
218
- NgNativeBinding *binding = [NgNativeBinding new];
219
- binding.view = view;
220
- binding.token = self->_attach(view, nativeID);
221
- self->_bindings[nativeID] = binding;
248
+ [self attach:view as:nativeID];
222
249
  }];
223
250
  }
224
251
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-native/components",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
4
  "description": "Angular Native's core components: view, text, image, pressable, scroll-view, virtual-list, text-input and the rest of React Native's set.",
5
5
  "keywords": [
6
6
  "angular",
@@ -61,8 +61,8 @@
61
61
  "access": "public"
62
62
  },
63
63
  "dependencies": {
64
- "@ng-native/device": "0.28.0",
65
- "@ng-native/fabric": "0.28.0"
64
+ "@ng-native/device": "0.30.0",
65
+ "@ng-native/fabric": "0.30.0"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "@angular/core": "^22.0.0",
@@ -83,7 +83,7 @@
83
83
  "license": "MIT",
84
84
  "homepage": "https://ng-native.com/packages/components",
85
85
  "bugs": {
86
- "url": "https://github.com/ng-native/ng-native/issues"
86
+ "url": "https://github.com/coralogix/ng-native/issues"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "react-native": {
@@ -110,7 +110,7 @@
110
110
  },
111
111
  "repository": {
112
112
  "type": "git",
113
- "url": "git+https://github.com/ng-native/ng-native.git",
113
+ "url": "git+https://github.com/coralogix/ng-native.git",
114
114
  "directory": "packages/components"
115
115
  },
116
116
  "files": [
@@ -123,7 +123,7 @@
123
123
  "expo-module.config.json"
124
124
  ],
125
125
  "devDependencies": {
126
- "@angular/core": "22.2.0",
126
+ "@angular/core": "22.3.0",
127
127
  "@babel/core": "^7.29.7",
128
128
  "marked": "^18.0.14"
129
129
  },