react-native-macos 0.66.58 → 0.66.61

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.
@@ -1201,42 +1201,10 @@ class ScrollView extends React.Component<Props, State> {
1201
1201
  nativeEvent.contentOffset.y +
1202
1202
  nativeEvent.layoutMeasurement.height,
1203
1203
  });
1204
- } else if (key === 'LEFT_ARROW') {
1205
- this._handleScrollByKeyDown(event, {
1206
- x:
1207
- nativeEvent.contentOffset.x +
1208
- -(this.props.horizontalLineScroll !== undefined
1209
- ? this.props.horizontalLineScroll
1210
- : kMinScrollOffset),
1211
- y: nativeEvent.contentOffset.y,
1212
- });
1213
- } else if (key === 'RIGHT_ARROW') {
1214
- this._handleScrollByKeyDown(event, {
1215
- x:
1216
- nativeEvent.contentOffset.x +
1217
- (this.props.horizontalLineScroll !== undefined
1218
- ? this.props.horizontalLineScroll
1219
- : kMinScrollOffset),
1220
- y: nativeEvent.contentOffset.y,
1221
- });
1222
- } else if (key === 'DOWN_ARROW') {
1223
- this._handleScrollByKeyDown(event, {
1224
- x: nativeEvent.contentOffset.x,
1225
- y:
1226
- nativeEvent.contentOffset.y +
1227
- (this.props.verticalLineScroll !== undefined
1228
- ? this.props.verticalLineScroll
1229
- : kMinScrollOffset),
1230
- });
1231
- } else if (key === 'UP_ARROW') {
1232
- this._handleScrollByKeyDown(event, {
1233
- x: nativeEvent.contentOffset.x,
1234
- y:
1235
- nativeEvent.contentOffset.y +
1236
- -(this.props.verticalLineScroll !== undefined
1237
- ? this.props.verticalLineScroll
1238
- : kMinScrollOffset),
1239
- });
1204
+ } else if (key === 'HOME') {
1205
+ this.scrollTo({x: 0, y: 0});
1206
+ } else if (key === 'END') {
1207
+ this.scrollToEnd({animated: true});
1240
1208
  }
1241
1209
  }
1242
1210
  }
@@ -12,6 +12,6 @@
12
12
  exports.version = {
13
13
  major: 0,
14
14
  minor: 66,
15
- patch: 58,
15
+ patch: 61,
16
16
  prerelease: null,
17
17
  };
@@ -369,6 +369,19 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
369
369
  }
370
370
  }
371
371
 
372
+ // [TODO(macOS GH#750)
373
+ /**
374
+ * Move selection to the specified index
375
+ *
376
+ * @platform macos
377
+ */
378
+ selectRowAtIndex(index: number) {
379
+ if (this._listRef) {
380
+ this._listRef.selectRowAtIndex(index);
381
+ }
382
+ }
383
+ // ]TODO(macOS GH#750)
384
+
372
385
  /**
373
386
  * Provides a handle to the underlying scroll responder.
374
387
  */
@@ -588,10 +588,14 @@ class VirtualizedList extends React.PureComponent<Props, State> {
588
588
  const newOffset = Math.min(contentLength, visTop + (frameEnd - visEnd));
589
589
  this.scrollToOffset({offset: newOffset});
590
590
  } else if (frame.offset < visTop) {
591
- const newOffset = Math.max(0, visTop - frame.length);
591
+ const newOffset = Math.min(frame.offset, visTop - frame.length);
592
592
  this.scrollToOffset({offset: newOffset});
593
593
  }
594
594
  }
595
+
596
+ selectRowAtIndex(rowIndex: number) {
597
+ this._selectRowAtIndex(rowIndex);
598
+ }
595
599
  // ]TODO(macOS GH#774)
596
600
 
597
601
  recordInteraction() {
@@ -882,7 +886,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
882
886
  index={ii}
883
887
  inversionStyle={inversionStyle}
884
888
  item={item}
885
- isSelected={this.state.selectedRowIndex === ii ? true : false} // TODO(macOS GH#774)
889
+ // [TODO(macOS GH#774)
890
+ isSelected={
891
+ this.props.enableSelectionOnKeyPress &&
892
+ this.state.selectedRowIndex === ii
893
+ ? true
894
+ : false
895
+ } // TODO(macOS GH#774)]
886
896
  key={key}
887
897
  prevCellKey={prevCellKey}
888
898
  onUpdateSeparators={this._onUpdateSeparators}
@@ -1323,10 +1333,12 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1323
1333
  // $FlowFixMe[prop-missing] Invalid prop usage
1324
1334
  <ScrollView
1325
1335
  {...props}
1326
- onScrollKeyDown={keyEventHandler} // TODO(macOS GH#774)
1336
+ // [TODO(macOS GH#774)
1337
+ {...(props.enableSelectionOnKeyPress && {focusable: true})}
1338
+ onScrollKeyDown={keyEventHandler}
1327
1339
  onPreferredScrollerStyleDidChange={
1328
1340
  preferredScrollerStyleDidChangeHandler
1329
- } // TODO(macOS GH#774)
1341
+ } // TODO(macOS GH#774)]
1330
1342
  refreshControl={
1331
1343
  props.refreshControl == null ? (
1332
1344
  <RefreshControl
@@ -1345,11 +1357,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1345
1357
  // $FlowFixMe Invalid prop usage
1346
1358
  <ScrollView
1347
1359
  {...props}
1348
- onScrollKeyDown={keyEventHandler} // TODO(macOS GH#774)
1360
+ {...(props.enableSelectionOnKeyPress && {focusable: true})} // [TODO(macOS GH#774)
1361
+ onScrollKeyDown={keyEventHandler}
1349
1362
  onPreferredScrollerStyleDidChange={
1350
- // TODO(macOS GH#774)
1351
- preferredScrollerStyleDidChangeHandler // TODO(macOS GH#774)
1352
- }
1363
+ preferredScrollerStyleDidChangeHandler
1364
+ } // TODO(macOS GH#774)]
1353
1365
  />
1354
1366
  );
1355
1367
  }
@@ -1507,6 +1519,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1507
1519
  return rowAbove;
1508
1520
  };
1509
1521
 
1522
+ _selectRowAtIndex = rowIndex => {
1523
+ this.setState(state => {
1524
+ return {selectedRowIndex: rowIndex};
1525
+ });
1526
+ return rowIndex;
1527
+ };
1528
+
1510
1529
  _selectRowBelowIndex = rowIndex => {
1511
1530
  if (this.props.getItemCount) {
1512
1531
  const {data} = this.props;
@@ -1521,14 +1540,14 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1521
1540
  }
1522
1541
  };
1523
1542
 
1524
- _handleKeyDown = (e: ScrollEvent) => {
1543
+ _handleKeyDown = (event: ScrollEvent) => {
1525
1544
  if (this.props.onScrollKeyDown) {
1526
- this.props.onScrollKeyDown(e);
1545
+ this.props.onScrollKeyDown(event);
1527
1546
  } else {
1528
1547
  if (Platform.OS === 'macos') {
1529
1548
  // $FlowFixMe Cannot get e.nativeEvent because property nativeEvent is missing in Event
1530
- const event = e.nativeEvent;
1531
- const key = event.key;
1549
+ const nativeEvent = event.nativeEvent;
1550
+ const key = nativeEvent.key;
1532
1551
 
1533
1552
  let prevIndex = -1;
1534
1553
  let newIndex = -1;
@@ -1536,46 +1555,66 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1536
1555
  prevIndex = this.state.selectedRowIndex;
1537
1556
  }
1538
1557
 
1539
- const {data, getItem} = this.props;
1540
- if (key === 'DOWN_ARROW') {
1541
- newIndex = this._selectRowBelowIndex(prevIndex);
1542
- this.ensureItemAtIndexIsVisible(newIndex);
1543
-
1544
- if (prevIndex !== newIndex) {
1545
- const item = getItem(data, newIndex);
1546
- if (this.props.onSelectionChanged) {
1547
- this.props.onSelectionChanged({
1548
- previousSelection: prevIndex,
1549
- newSelection: newIndex,
1550
- item: item,
1551
- });
1552
- }
1553
- }
1554
- } else if (key === 'UP_ARROW') {
1558
+ // const {data, getItem} = this.props;
1559
+ if (key === 'UP_ARROW') {
1555
1560
  newIndex = this._selectRowAboveIndex(prevIndex);
1556
- this.ensureItemAtIndexIsVisible(newIndex);
1557
-
1558
- if (prevIndex !== newIndex) {
1559
- const item = getItem(data, newIndex);
1560
- if (this.props.onSelectionChanged) {
1561
- this.props.onSelectionChanged({
1562
- previousSelection: prevIndex,
1563
- newSelection: newIndex,
1564
- item: item,
1565
- });
1566
- }
1567
- }
1561
+ this._handleSelectionChange(prevIndex, newIndex);
1562
+ } else if (key === 'DOWN_ARROW') {
1563
+ newIndex = this._selectRowBelowIndex(prevIndex);
1564
+ this._handleSelectionChange(prevIndex, newIndex);
1568
1565
  } else if (key === 'ENTER') {
1569
1566
  if (this.props.onSelectionEntered) {
1570
- const item = getItem(data, prevIndex);
1567
+ const item = this.props.getItem(this.props.data, prevIndex);
1571
1568
  if (this.props.onSelectionEntered) {
1572
1569
  this.props.onSelectionEntered(item);
1573
1570
  }
1574
1571
  }
1572
+ } else if (key === 'OPTION_UP') {
1573
+ newIndex = this._selectRowAtIndex(0);
1574
+ this._handleSelectionChange(prevIndex, newIndex);
1575
+ } else if (key === 'OPTION_DOWN') {
1576
+ newIndex = this._selectRowAtIndex(this.state.last);
1577
+ this._handleSelectionChange(prevIndex, newIndex);
1578
+ } else if (key === 'PAGE_UP') {
1579
+ const maxY =
1580
+ event.nativeEvent.contentSize.height -
1581
+ event.nativeEvent.layoutMeasurement.height;
1582
+ const newOffset = Math.min(
1583
+ maxY,
1584
+ nativeEvent.contentOffset.y + -nativeEvent.layoutMeasurement.height,
1585
+ );
1586
+ this.scrollToOffset({animated: true, offset: newOffset});
1587
+ } else if (key === 'PAGE_DOWN') {
1588
+ const maxY =
1589
+ event.nativeEvent.contentSize.height -
1590
+ event.nativeEvent.layoutMeasurement.height;
1591
+ const newOffset = Math.min(
1592
+ maxY,
1593
+ nativeEvent.contentOffset.y + nativeEvent.layoutMeasurement.height,
1594
+ );
1595
+ this.scrollToOffset({animated: true, offset: newOffset});
1596
+ } else if (key === 'HOME') {
1597
+ this.scrollToOffset({animated: true, offset: 0});
1598
+ } else if (key === 'END') {
1599
+ this.scrollToEnd({animated: true});
1575
1600
  }
1576
1601
  }
1577
1602
  }
1578
1603
  };
1604
+
1605
+ _handleSelectionChange = (prevIndex, newIndex) => {
1606
+ this.ensureItemAtIndexIsVisible(newIndex);
1607
+ if (prevIndex !== newIndex) {
1608
+ const item = this.props.getItem(this.props.data, newIndex);
1609
+ if (this.props.onSelectionChanged) {
1610
+ this.props.onSelectionChanged({
1611
+ previousSelection: prevIndex,
1612
+ newSelection: newIndex,
1613
+ item: item,
1614
+ });
1615
+ }
1616
+ }
1617
+ };
1579
1618
  // ]TODO(macOS GH#774)
1580
1619
 
1581
1620
  _renderDebugOverlay() {
@@ -2182,6 +2221,7 @@ class CellRenderer extends React.Component<
2182
2221
  return React.createElement(ListItemComponent, {
2183
2222
  item,
2184
2223
  index,
2224
+ isSelected,
2185
2225
  separators: this._separators,
2186
2226
  });
2187
2227
  }
@@ -2258,6 +2298,7 @@ class CellRenderer extends React.Component<
2258
2298
  {itemSeparator}
2259
2299
  </CellRendererComponent>
2260
2300
  );
2301
+ // TODO(macOS GH#774)]
2261
2302
 
2262
2303
  return (
2263
2304
  <VirtualizedListCellContextProvider cellKey={this.props.cellKey}>
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(66),
26
- RCTVersionPatch: @(58),
26
+ RCTVersionPatch: @(61),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -1180,16 +1180,22 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
1180
1180
 
1181
1181
  #if TARGET_OS_OSX // [TODO(macOS GH#774)
1182
1182
 
1183
- - (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode
1183
+ - (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode modifierFlags:(NSEventModifierFlags)modifierFlags
1184
1184
  {
1185
1185
  switch (keyCode)
1186
1186
  {
1187
1187
  case 36:
1188
1188
  return @"ENTER";
1189
1189
 
1190
+ case 115:
1191
+ return @"HOME";
1192
+
1190
1193
  case 116:
1191
1194
  return @"PAGE_UP";
1192
1195
 
1196
+ case 119:
1197
+ return @"END";
1198
+
1193
1199
  case 121:
1194
1200
  return @"PAGE_DOWN";
1195
1201
 
@@ -1200,10 +1206,18 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
1200
1206
  return @"RIGHT_ARROW";
1201
1207
 
1202
1208
  case 125:
1203
- return @"DOWN_ARROW";
1209
+ if (modifierFlags & NSEventModifierFlagOption) {
1210
+ return @"OPTION_DOWN";
1211
+ } else {
1212
+ return @"DOWN_ARROW";
1213
+ }
1204
1214
 
1205
1215
  case 126:
1206
- return @"UP_ARROW";
1216
+ if (modifierFlags & NSEventModifierFlagOption) {
1217
+ return @"OPTION_UP";
1218
+ } else {
1219
+ return @"UP_ARROW";
1220
+ }
1207
1221
  }
1208
1222
  return @"";
1209
1223
  }
@@ -1211,24 +1225,25 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
1211
1225
  - (void)keyDown:(UIEvent*)theEvent
1212
1226
  {
1213
1227
  // Don't emit a scroll event if tab was pressed while the scrollview is first responder
1214
- if (self == [[self window] firstResponder] &&
1215
- theEvent.keyCode != 48) {
1216
- NSString *keyCommand = [self keyCommandFromKeyCode:theEvent.keyCode];
1217
- RCT_SEND_SCROLL_EVENT(onScrollKeyDown, (@{ @"key": keyCommand}));
1218
- } else {
1219
- [super keyDown:theEvent];
1220
-
1221
- // AX: if a tab key was pressed and the first responder is currently clipped by the scroll view,
1222
- // automatically scroll to make the view visible to make it navigable via keyboard.
1223
- if ([theEvent keyCode] == 48) { //tab key
1224
- id firstResponder = [[self window] firstResponder];
1225
- if ([firstResponder isKindOfClass:[NSView class]] &&
1226
- [firstResponder isDescendantOf:[_scrollView documentView]]) {
1227
- NSView *view = (NSView*)firstResponder;
1228
- NSRect visibleRect = ([view superview] == [_scrollView documentView]) ? NSInsetRect(view.frame, -1, -1) :
1229
- [view convertRect:view.frame toView:_scrollView.documentView];
1230
- [[_scrollView documentView] scrollRectToVisible:visibleRect];
1231
- }
1228
+ if (!(self == [[self window] firstResponder] && theEvent.keyCode == 48)) {
1229
+ NSString *keyCommand = [self keyCommandFromKeyCode:theEvent.keyCode modifierFlags:theEvent.modifierFlags];
1230
+ if (![keyCommand isEqual: @""]) {
1231
+ RCT_SEND_SCROLL_EVENT(onScrollKeyDown, (@{ @"key": keyCommand}));
1232
+ } else {
1233
+ [super keyDown:theEvent];
1234
+ }
1235
+ }
1236
+
1237
+ // AX: if a tab key was pressed and the first responder is currently clipped by the scroll view,
1238
+ // automatically scroll to make the view visible to make it navigable via keyboard.
1239
+ if ([theEvent keyCode] == 48) { //tab key
1240
+ id firstResponder = [[self window] firstResponder];
1241
+ if ([firstResponder isKindOfClass:[NSView class]] &&
1242
+ [firstResponder isDescendantOf:[_scrollView documentView]]) {
1243
+ NSView *view = (NSView*)firstResponder;
1244
+ NSRect visibleRect = ([view superview] == [_scrollView documentView]) ? NSInsetRect(view.frame, -1, -1) :
1245
+ [view convertRect:view.frame toView:_scrollView.documentView];
1246
+ [[_scrollView documentView] scrollRectToVisible:visibleRect];
1232
1247
  }
1233
1248
  }
1234
1249
  }
@@ -285,29 +285,37 @@
285
285
 
286
286
  - (void)reactFocus
287
287
  {
288
- if (![self becomeFirstResponder]) {
289
- self.reactIsFocusNeeded = YES;
290
- }
288
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
289
+ if (![[self window] makeFirstResponder:self]) {
290
+ #else
291
+ if (![self becomeFirstResponder]) {
292
+ #endif //// TODO(macOS GH#774)]
293
+ self.reactIsFocusNeeded = YES;
294
+ }
291
295
  }
292
296
 
293
297
  - (void)reactFocusIfNeeded
294
298
  {
295
- if (self.reactIsFocusNeeded) {
296
- if ([self becomeFirstResponder]) {
297
- self.reactIsFocusNeeded = NO;
298
- }
299
- }
299
+ if (self.reactIsFocusNeeded) {
300
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
301
+ if ([[self window] makeFirstResponder:self]) {
302
+ #else
303
+ if ([self becomeFirstResponder]) {
304
+ #endif // TODO(macOS GH#774)]
305
+ self.reactIsFocusNeeded = NO;
306
+ }
307
+ }
300
308
  }
301
309
 
302
310
  - (void)reactBlur
303
311
  {
304
- #if TARGET_OS_OSX // TODO(macOS GH#774)
312
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
305
313
  if (self == [[self window] firstResponder]) {
306
314
  [[self window] makeFirstResponder:[[self window] nextResponder]];
307
315
  }
308
316
  #else
309
317
  [self resignFirstResponder];
310
- #endif
318
+ #endif // TODO(macOS GH#774)]
311
319
  }
312
320
 
313
321
  #pragma mark - Layout
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.66.58
1
+ VERSION_NAME=0.66.61
2
2
  GROUP=com.facebook.react
3
3
 
4
4
  POM_NAME=ReactNative
@@ -17,6 +17,6 @@ public class ReactNativeVersion {
17
17
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
18
18
  "major", 0,
19
19
  "minor", 66,
20
- "patch", 58,
20
+ "patch", 61,
21
21
  "prerelease", null);
22
22
  }
@@ -17,7 +17,7 @@ namespace facebook::react {
17
17
  constexpr struct {
18
18
  int32_t Major = 0;
19
19
  int32_t Minor = 66;
20
- int32_t Patch = 58;
20
+ int32_t Patch = 61;
21
21
  std::string_view Prerelease = "";
22
22
  } ReactNativeVersion;
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.66.58",
3
+ "version": "0.66.61",
4
4
  "bin": "./cli.js",
5
5
  "description": "React Native for macOS",
6
6
  "license": "MIT",
@@ -209,11 +209,13 @@
209
209
  "resolutions": {
210
210
  "async": "^3.2.2",
211
211
  "es5-ext": "0.10.53",
212
+ "shell-quote": "^1.7.3",
212
213
  "workspace-tools": "^0.18.4"
213
214
  },
214
215
  "_justification": {
215
216
  "async": "Versions of async prior to 3.2.2 are vulnerable to prototype pollution",
216
217
  "es5-ext": "Packages after 0.10.54 and at the moment up until 0.10.59 contain a protest message. A policy prevents us from using packages with protestware, therefore downgrading to the latest release without the message.",
218
+ "shell-quote": "Versions prior to 1.7.3 have an RCE vulnerability. Should be removable once we upgrade CLI tools to ^8.0.0 with RN 0.69.",
217
219
  "workspace-tools": "Versions prior to 0.18.4 are vulnerable to command injection and prototype pollution attacks"
218
220
  }
219
221
  }
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "react": "17.0.2",
14
- "react-native": "0.66.58"
14
+ "react-native": "0.66.61"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@babel/core": "^7.12.9",