react-native-macos 0.68.9 → 0.68.12

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.
@@ -1206,42 +1206,10 @@ class ScrollView extends React.Component<Props, State> {
1206
1206
  nativeEvent.contentOffset.y +
1207
1207
  nativeEvent.layoutMeasurement.height,
1208
1208
  });
1209
- } else if (key === 'LEFT_ARROW') {
1210
- this._handleScrollByKeyDown(event, {
1211
- x:
1212
- nativeEvent.contentOffset.x +
1213
- -(this.props.horizontalLineScroll !== undefined
1214
- ? this.props.horizontalLineScroll
1215
- : kMinScrollOffset),
1216
- y: nativeEvent.contentOffset.y,
1217
- });
1218
- } else if (key === 'RIGHT_ARROW') {
1219
- this._handleScrollByKeyDown(event, {
1220
- x:
1221
- nativeEvent.contentOffset.x +
1222
- (this.props.horizontalLineScroll !== undefined
1223
- ? this.props.horizontalLineScroll
1224
- : kMinScrollOffset),
1225
- y: nativeEvent.contentOffset.y,
1226
- });
1227
- } else if (key === 'DOWN_ARROW') {
1228
- this._handleScrollByKeyDown(event, {
1229
- x: nativeEvent.contentOffset.x,
1230
- y:
1231
- nativeEvent.contentOffset.y +
1232
- (this.props.verticalLineScroll !== undefined
1233
- ? this.props.verticalLineScroll
1234
- : kMinScrollOffset),
1235
- });
1236
- } else if (key === 'UP_ARROW') {
1237
- this._handleScrollByKeyDown(event, {
1238
- x: nativeEvent.contentOffset.x,
1239
- y:
1240
- nativeEvent.contentOffset.y +
1241
- -(this.props.verticalLineScroll !== undefined
1242
- ? this.props.verticalLineScroll
1243
- : kMinScrollOffset),
1244
- });
1209
+ } else if (key === 'HOME') {
1210
+ this.scrollTo({x: 0, y: 0});
1211
+ } else if (key === 'END') {
1212
+ this.scrollToEnd({animated: true});
1245
1213
  }
1246
1214
  }
1247
1215
  }
@@ -16,6 +16,6 @@
16
16
  exports.version = {
17
17
  major: 0,
18
18
  minor: 68,
19
- patch: 9,
19
+ patch: 12,
20
20
  prerelease: null,
21
21
  };
@@ -588,7 +588,7 @@ 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
  }
@@ -884,7 +884,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
884
884
  index={ii}
885
885
  inversionStyle={inversionStyle}
886
886
  item={item}
887
- isSelected={this.state.selectedRowIndex === ii ? true : false} // TODO(macOS GH#774)
887
+ // [TODO(macOS GH#774)
888
+ isSelected={
889
+ this.props.enableSelectionOnKeyPress &&
890
+ this.state.selectedRowIndex === ii
891
+ ? true
892
+ : false
893
+ } // TODO(macOS GH#774)]
888
894
  key={key}
889
895
  prevCellKey={prevCellKey}
890
896
  onUpdateSeparators={this._onUpdateSeparators}
@@ -1322,10 +1328,12 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1322
1328
  // $FlowFixMe[prop-missing] Invalid prop usage
1323
1329
  <ScrollView
1324
1330
  {...props}
1325
- onScrollKeyDown={keyEventHandler} // TODO(macOS GH#774)
1331
+ // [TODO(macOS GH#774)
1332
+ {...(props.enableSelectionOnKeyPress && {focusable: true})}
1333
+ onScrollKeyDown={keyEventHandler}
1326
1334
  onPreferredScrollerStyleDidChange={
1327
1335
  preferredScrollerStyleDidChangeHandler
1328
- } // TODO(macOS GH#774)
1336
+ } // TODO(macOS GH#774)]
1329
1337
  refreshControl={
1330
1338
  props.refreshControl == null ? (
1331
1339
  <RefreshControl
@@ -1344,11 +1352,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1344
1352
  // $FlowFixMe Invalid prop usage
1345
1353
  <ScrollView
1346
1354
  {...props}
1347
- onScrollKeyDown={keyEventHandler} // TODO(macOS GH#774)
1355
+ {...(props.enableSelectionOnKeyPress && {focusable: true})} // [TODO(macOS GH#774)
1356
+ onScrollKeyDown={keyEventHandler}
1348
1357
  onPreferredScrollerStyleDidChange={
1349
- // TODO(macOS GH#774)
1350
- preferredScrollerStyleDidChangeHandler // TODO(macOS GH#774)
1351
- }
1358
+ preferredScrollerStyleDidChangeHandler
1359
+ } // TODO(macOS GH#774)]
1352
1360
  />
1353
1361
  );
1354
1362
  }
@@ -1506,6 +1514,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1506
1514
  return rowAbove;
1507
1515
  };
1508
1516
 
1517
+ _selectRowAtIndex = rowIndex => {
1518
+ this.setState(state => {
1519
+ return {selectedRowIndex: rowIndex};
1520
+ });
1521
+ return rowIndex;
1522
+ };
1523
+
1509
1524
  _selectRowBelowIndex = rowIndex => {
1510
1525
  if (this.props.getItemCount) {
1511
1526
  const {data} = this.props;
@@ -1520,14 +1535,14 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1520
1535
  }
1521
1536
  };
1522
1537
 
1523
- _handleKeyDown = (e: ScrollEvent) => {
1538
+ _handleKeyDown = (event: ScrollEvent) => {
1524
1539
  if (this.props.onScrollKeyDown) {
1525
- this.props.onScrollKeyDown(e);
1540
+ this.props.onScrollKeyDown(event);
1526
1541
  } else {
1527
1542
  if (Platform.OS === 'macos') {
1528
1543
  // $FlowFixMe Cannot get e.nativeEvent because property nativeEvent is missing in Event
1529
- const event = e.nativeEvent;
1530
- const key = event.key;
1544
+ const nativeEvent = event.nativeEvent;
1545
+ const key = nativeEvent.key;
1531
1546
 
1532
1547
  let prevIndex = -1;
1533
1548
  let newIndex = -1;
@@ -1535,46 +1550,66 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1535
1550
  prevIndex = this.state.selectedRowIndex;
1536
1551
  }
1537
1552
 
1538
- const {data, getItem} = this.props;
1539
- if (key === 'DOWN_ARROW') {
1540
- newIndex = this._selectRowBelowIndex(prevIndex);
1541
- this.ensureItemAtIndexIsVisible(newIndex);
1542
-
1543
- if (prevIndex !== newIndex) {
1544
- const item = getItem(data, newIndex);
1545
- if (this.props.onSelectionChanged) {
1546
- this.props.onSelectionChanged({
1547
- previousSelection: prevIndex,
1548
- newSelection: newIndex,
1549
- item: item,
1550
- });
1551
- }
1552
- }
1553
- } else if (key === 'UP_ARROW') {
1553
+ // const {data, getItem} = this.props;
1554
+ if (key === 'UP_ARROW') {
1554
1555
  newIndex = this._selectRowAboveIndex(prevIndex);
1555
- this.ensureItemAtIndexIsVisible(newIndex);
1556
-
1557
- if (prevIndex !== newIndex) {
1558
- const item = getItem(data, newIndex);
1559
- if (this.props.onSelectionChanged) {
1560
- this.props.onSelectionChanged({
1561
- previousSelection: prevIndex,
1562
- newSelection: newIndex,
1563
- item: item,
1564
- });
1565
- }
1566
- }
1556
+ this._handleSelectionChange(prevIndex, newIndex);
1557
+ } else if (key === 'DOWN_ARROW') {
1558
+ newIndex = this._selectRowBelowIndex(prevIndex);
1559
+ this._handleSelectionChange(prevIndex, newIndex);
1567
1560
  } else if (key === 'ENTER') {
1568
1561
  if (this.props.onSelectionEntered) {
1569
- const item = getItem(data, prevIndex);
1562
+ const item = this.props.getItem(this.props.data, prevIndex);
1570
1563
  if (this.props.onSelectionEntered) {
1571
1564
  this.props.onSelectionEntered(item);
1572
1565
  }
1573
1566
  }
1567
+ } else if (key === 'OPTION_UP') {
1568
+ newIndex = this._selectRowAtIndex(0);
1569
+ this._handleSelectionChange(prevIndex, newIndex);
1570
+ } else if (key === 'OPTION_DOWN') {
1571
+ newIndex = this._selectRowAtIndex(this.state.last);
1572
+ this._handleSelectionChange(prevIndex, newIndex);
1573
+ } else if (key === 'PAGE_UP') {
1574
+ const maxY =
1575
+ event.nativeEvent.contentSize.height -
1576
+ event.nativeEvent.layoutMeasurement.height;
1577
+ const newOffset = Math.min(
1578
+ maxY,
1579
+ nativeEvent.contentOffset.y + -nativeEvent.layoutMeasurement.height,
1580
+ );
1581
+ this.scrollToOffset({animated: true, offset: newOffset});
1582
+ } else if (key === 'PAGE_DOWN') {
1583
+ const maxY =
1584
+ event.nativeEvent.contentSize.height -
1585
+ event.nativeEvent.layoutMeasurement.height;
1586
+ const newOffset = Math.min(
1587
+ maxY,
1588
+ nativeEvent.contentOffset.y + nativeEvent.layoutMeasurement.height,
1589
+ );
1590
+ this.scrollToOffset({animated: true, offset: newOffset});
1591
+ } else if (key === 'HOME') {
1592
+ this.scrollToOffset({animated: true, offset: 0});
1593
+ } else if (key === 'END') {
1594
+ this.scrollToEnd({animated: true});
1574
1595
  }
1575
1596
  }
1576
1597
  }
1577
1598
  };
1599
+
1600
+ _handleSelectionChange = (prevIndex, newIndex) => {
1601
+ this.ensureItemAtIndexIsVisible(newIndex);
1602
+ if (prevIndex !== newIndex) {
1603
+ const item = this.props.getItem(this.props.data, newIndex);
1604
+ if (this.props.onSelectionChanged) {
1605
+ this.props.onSelectionChanged({
1606
+ previousSelection: prevIndex,
1607
+ newSelection: newIndex,
1608
+ item: item,
1609
+ });
1610
+ }
1611
+ }
1612
+ };
1578
1613
  // ]TODO(macOS GH#774)
1579
1614
 
1580
1615
  _renderDebugOverlay() {
@@ -2172,6 +2207,7 @@ class CellRenderer extends React.Component<
2172
2207
  return React.createElement(ListItemComponent, {
2173
2208
  item,
2174
2209
  index,
2210
+ isSelected,
2175
2211
  separators: this._separators,
2176
2212
  });
2177
2213
  }
@@ -2248,6 +2284,7 @@ class CellRenderer extends React.Component<
2248
2284
  {itemSeparator}
2249
2285
  </CellRendererComponent>
2250
2286
  );
2287
+ // TODO(macOS GH#774)]
2251
2288
 
2252
2289
  return (
2253
2290
  <VirtualizedListCellContextProvider cellKey={this.props.cellKey}>
@@ -27,7 +27,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
27
27
  __rnVersion = @{
28
28
  RCTVersionMajor: @(0),
29
29
  RCTVersionMinor: @(68),
30
- RCTVersionPatch: @(9),
30
+ RCTVersionPatch: @(12),
31
31
  RCTVersionPrerelease: [NSNull null],
32
32
  };
33
33
  });
@@ -1258,16 +1258,22 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
1258
1258
 
1259
1259
  #if TARGET_OS_OSX // [TODO(macOS GH#774)
1260
1260
 
1261
- - (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode
1261
+ - (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode modifierFlags:(NSEventModifierFlags)modifierFlags
1262
1262
  {
1263
1263
  switch (keyCode)
1264
1264
  {
1265
1265
  case 36:
1266
1266
  return @"ENTER";
1267
1267
 
1268
+ case 115:
1269
+ return @"HOME";
1270
+
1268
1271
  case 116:
1269
1272
  return @"PAGE_UP";
1270
1273
 
1274
+ case 119:
1275
+ return @"END";
1276
+
1271
1277
  case 121:
1272
1278
  return @"PAGE_DOWN";
1273
1279
 
@@ -1278,10 +1284,18 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
1278
1284
  return @"RIGHT_ARROW";
1279
1285
 
1280
1286
  case 125:
1281
- return @"DOWN_ARROW";
1287
+ if (modifierFlags & NSEventModifierFlagOption) {
1288
+ return @"OPTION_DOWN";
1289
+ } else {
1290
+ return @"DOWN_ARROW";
1291
+ }
1282
1292
 
1283
1293
  case 126:
1284
- return @"UP_ARROW";
1294
+ if (modifierFlags & NSEventModifierFlagOption) {
1295
+ return @"OPTION_UP";
1296
+ } else {
1297
+ return @"UP_ARROW";
1298
+ }
1285
1299
  }
1286
1300
  return @"";
1287
1301
  }
@@ -1289,24 +1303,25 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
1289
1303
  - (void)keyDown:(UIEvent*)theEvent
1290
1304
  {
1291
1305
  // Don't emit a scroll event if tab was pressed while the scrollview is first responder
1292
- if (self == [[self window] firstResponder] &&
1293
- theEvent.keyCode != 48) {
1294
- NSString *keyCommand = [self keyCommandFromKeyCode:theEvent.keyCode];
1295
- RCT_SEND_SCROLL_EVENT(onScrollKeyDown, (@{ @"key": keyCommand}));
1296
- } else {
1297
- [super keyDown:theEvent];
1298
-
1299
- // AX: if a tab key was pressed and the first responder is currently clipped by the scroll view,
1300
- // automatically scroll to make the view visible to make it navigable via keyboard.
1301
- if ([theEvent keyCode] == 48) { //tab key
1302
- id firstResponder = [[self window] firstResponder];
1303
- if ([firstResponder isKindOfClass:[NSView class]] &&
1304
- [firstResponder isDescendantOf:[_scrollView documentView]]) {
1305
- NSView *view = (NSView*)firstResponder;
1306
- NSRect visibleRect = ([view superview] == [_scrollView documentView]) ? NSInsetRect(view.frame, -1, -1) :
1307
- [view convertRect:view.frame toView:_scrollView.documentView];
1308
- [[_scrollView documentView] scrollRectToVisible:visibleRect];
1309
- }
1306
+ if (!(self == [[self window] firstResponder] && theEvent.keyCode == 48)) {
1307
+ NSString *keyCommand = [self keyCommandFromKeyCode:theEvent.keyCode modifierFlags:theEvent.modifierFlags];
1308
+ if (![keyCommand isEqual: @""]) {
1309
+ RCT_SEND_SCROLL_EVENT(onScrollKeyDown, (@{ @"key": keyCommand}));
1310
+ } else {
1311
+ [super keyDown:theEvent];
1312
+ }
1313
+ }
1314
+
1315
+ // AX: if a tab key was pressed and the first responder is currently clipped by the scroll view,
1316
+ // automatically scroll to make the view visible to make it navigable via keyboard.
1317
+ if ([theEvent keyCode] == 48) { //tab key
1318
+ id firstResponder = [[self window] firstResponder];
1319
+ if ([firstResponder isKindOfClass:[NSView class]] &&
1320
+ [firstResponder isDescendantOf:[_scrollView documentView]]) {
1321
+ NSView *view = (NSView*)firstResponder;
1322
+ NSRect visibleRect = ([view superview] == [_scrollView documentView]) ? NSInsetRect(view.frame, -1, -1) :
1323
+ [view convertRect:view.frame toView:_scrollView.documentView];
1324
+ [[_scrollView documentView] scrollRectToVisible:visibleRect];
1310
1325
  }
1311
1326
  }
1312
1327
  }
@@ -282,29 +282,37 @@
282
282
 
283
283
  - (void)reactFocus
284
284
  {
285
- if (![self becomeFirstResponder]) {
286
- self.reactIsFocusNeeded = YES;
287
- }
285
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
286
+ if (![[self window] makeFirstResponder:self]) {
287
+ #else
288
+ if (![self becomeFirstResponder]) {
289
+ #endif //// TODO(macOS GH#774)]
290
+ self.reactIsFocusNeeded = YES;
291
+ }
288
292
  }
289
293
 
290
294
  - (void)reactFocusIfNeeded
291
295
  {
292
- if (self.reactIsFocusNeeded) {
293
- if ([self becomeFirstResponder]) {
294
- self.reactIsFocusNeeded = NO;
295
- }
296
- }
296
+ if (self.reactIsFocusNeeded) {
297
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
298
+ if ([[self window] makeFirstResponder:self]) {
299
+ #else
300
+ if ([self becomeFirstResponder]) {
301
+ #endif // TODO(macOS GH#774)]
302
+ self.reactIsFocusNeeded = NO;
303
+ }
304
+ }
297
305
  }
298
306
 
299
307
  - (void)reactBlur
300
308
  {
301
- #if TARGET_OS_OSX // TODO(macOS GH#774)
309
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
302
310
  if (self == [[self window] firstResponder]) {
303
311
  [[self window] makeFirstResponder:[[self window] nextResponder]];
304
312
  }
305
313
  #else
306
314
  [self resignFirstResponder];
307
- #endif
315
+ #endif // TODO(macOS GH#774)]
308
316
  }
309
317
 
310
318
  #pragma mark - Layout
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.68.9
1
+ VERSION_NAME=0.68.12
2
2
  GROUP=com.facebook.react
3
3
 
4
4
  POM_NAME=ReactNative
@@ -21,6 +21,6 @@ public class ReactNativeVersion {
21
21
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
22
22
  "major", 0,
23
23
  "minor", 68,
24
- "patch", 9,
24
+ "patch", 12,
25
25
  "prerelease", null);
26
26
  }
@@ -21,7 +21,7 @@ namespace facebook::react {
21
21
  constexpr struct {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 68;
24
- int32_t Patch = 9;
24
+ int32_t Patch = 12;
25
25
  std::string_view Prerelease = "";
26
26
  } ReactNativeVersion;
27
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.68.9",
3
+ "version": "0.68.12",
4
4
  "bin": "./cli.js",
5
5
  "description": "React Native for macOS",
6
6
  "license": "MIT",
@@ -117,6 +117,7 @@
117
117
  "react-native-gradle-plugin": "^0.0.6",
118
118
  "react-refresh": "^0.4.0",
119
119
  "react-shallow-renderer": "16.14.1",
120
+ "readable-stream": "^4.0.0",
120
121
  "regenerator-runtime": "^0.13.2",
121
122
  "scheduler": "^0.20.2",
122
123
  "stacktrace-parser": "^0.1.3",
@@ -176,14 +177,14 @@
176
177
  "resolutions": {
177
178
  "async": "^3.2.2",
178
179
  "es5-ext": "0.10.53",
179
- "shell-quote": "^1.7.3",
180
- "workspace-tools": "^0.18.4"
180
+ "readable-stream": "^4.0.0",
181
+ "shell-quote": "^1.7.3"
181
182
  },
182
183
  "_justification": {
183
184
  "async": "Versions of async prior to 3.2.2 are vulnerable to prototype pollution",
184
185
  "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.",
185
- "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.",
186
- "workspace-tools": "Versions prior to 0.18.4 are vulnerable to command injection and prototype pollution attacks"
186
+ "readable-stream": "Eliminates dependency on outdated string_decoder component",
187
+ "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."
187
188
  },
188
189
  "codegenConfig": {
189
190
  "libraries": [
@@ -3,7 +3,7 @@ GEM
3
3
  specs:
4
4
  CFPropertyList (3.0.5)
5
5
  rexml
6
- activesupport (6.1.6)
6
+ activesupport (6.1.6.1)
7
7
  concurrent-ruby (~> 1.0, >= 1.0.2)
8
8
  i18n (>= 1.6, < 2)
9
9
  minitest (>= 5.1)
@@ -63,7 +63,7 @@ GEM
63
63
  fuzzy_match (2.0.4)
64
64
  gh_inspector (1.1.3)
65
65
  httpclient (2.8.3)
66
- i18n (1.11.0)
66
+ i18n (1.12.0)
67
67
  concurrent-ruby (~> 1.0)
68
68
  json (2.6.2)
69
69
  minitest (5.16.2)
@@ -76,7 +76,7 @@ GEM
76
76
  ruby-macho (2.5.1)
77
77
  typhoeus (1.4.0)
78
78
  ethon (>= 0.9.0)
79
- tzinfo (2.0.4)
79
+ tzinfo (2.0.5)
80
80
  concurrent-ruby (~> 1.0)
81
81
  xcodeproj (1.22.0)
82
82
  CFPropertyList (>= 2.3.3, < 4.0)
@@ -97,4 +97,4 @@ RUBY VERSION
97
97
  ruby 3.0.4p208
98
98
 
99
99
  BUNDLED WITH
100
- 2.3.17
100
+ 2.3.18
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "react": "17.0.2",
15
- "react-native-macos": "0.68.9"
15
+ "react-native-macos": "0.68.12"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@babel/core": "^7.12.9",