react-native-macos 0.0.0-ee0c151fd → 0.0.0-eefd4a8e0

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
  }
@@ -17,5 +17,5 @@ exports.version = {
17
17
  major: 0,
18
18
  minor: 0,
19
19
  patch: 0,
20
- prerelease: 'ee0c151fd',
20
+ prerelease: 'eefd4a8e0',
21
21
  };
@@ -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 ios
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() {
@@ -884,7 +888,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
884
888
  index={ii}
885
889
  inversionStyle={inversionStyle}
886
890
  item={item}
887
- isSelected={this.state.selectedRowIndex === ii ? true : false} // TODO(macOS GH#774)
891
+ // [TODO(macOS GH#774)
892
+ isSelected={
893
+ this.props.enableSelectionOnKeyPress &&
894
+ this.state.selectedRowIndex === ii
895
+ ? true
896
+ : false
897
+ } // TODO(macOS GH#774)]
888
898
  key={key}
889
899
  prevCellKey={prevCellKey}
890
900
  onUpdateSeparators={this._onUpdateSeparators}
@@ -1330,10 +1340,12 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1330
1340
  // $FlowFixMe[prop-missing] Invalid prop usage
1331
1341
  <ScrollView
1332
1342
  {...props}
1333
- onScrollKeyDown={keyEventHandler} // TODO(macOS GH#774)
1343
+ // [TODO(macOS GH#774)
1344
+ {...(props.enableSelectionOnKeyPress && {focusable: true})}
1345
+ onScrollKeyDown={keyEventHandler}
1334
1346
  onPreferredScrollerStyleDidChange={
1335
1347
  preferredScrollerStyleDidChangeHandler
1336
- } // TODO(macOS GH#774)
1348
+ } // TODO(macOS GH#774)]
1337
1349
  refreshControl={
1338
1350
  props.refreshControl == null ? (
1339
1351
  <RefreshControl
@@ -1352,11 +1364,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1352
1364
  // $FlowFixMe Invalid prop usage
1353
1365
  <ScrollView
1354
1366
  {...props}
1355
- onScrollKeyDown={keyEventHandler} // TODO(macOS GH#774)
1367
+ {...(props.enableSelectionOnKeyPress && {focusable: true})} // [TODO(macOS GH#774)
1368
+ onScrollKeyDown={keyEventHandler}
1356
1369
  onPreferredScrollerStyleDidChange={
1357
- // TODO(macOS GH#774)
1358
- preferredScrollerStyleDidChangeHandler // TODO(macOS GH#774)
1359
- }
1370
+ preferredScrollerStyleDidChangeHandler
1371
+ } // TODO(macOS GH#774)]
1360
1372
  />
1361
1373
  );
1362
1374
  }
@@ -1514,6 +1526,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1514
1526
  return rowAbove;
1515
1527
  };
1516
1528
 
1529
+ _selectRowAtIndex = rowIndex => {
1530
+ this.setState(state => {
1531
+ return {selectedRowIndex: rowIndex};
1532
+ });
1533
+ return rowIndex;
1534
+ };
1535
+
1517
1536
  _selectRowBelowIndex = rowIndex => {
1518
1537
  if (this.props.getItemCount) {
1519
1538
  const {data} = this.props;
@@ -1528,14 +1547,14 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1528
1547
  }
1529
1548
  };
1530
1549
 
1531
- _handleKeyDown = (e: ScrollEvent) => {
1550
+ _handleKeyDown = (event: ScrollEvent) => {
1532
1551
  if (this.props.onScrollKeyDown) {
1533
- this.props.onScrollKeyDown(e);
1552
+ this.props.onScrollKeyDown(event);
1534
1553
  } else {
1535
1554
  if (Platform.OS === 'macos') {
1536
1555
  // $FlowFixMe Cannot get e.nativeEvent because property nativeEvent is missing in Event
1537
- const event = e.nativeEvent;
1538
- const key = event.key;
1556
+ const nativeEvent = event.nativeEvent;
1557
+ const key = nativeEvent.key;
1539
1558
 
1540
1559
  let prevIndex = -1;
1541
1560
  let newIndex = -1;
@@ -1543,46 +1562,66 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1543
1562
  prevIndex = this.state.selectedRowIndex;
1544
1563
  }
1545
1564
 
1546
- const {data, getItem} = this.props;
1547
- if (key === 'DOWN_ARROW') {
1548
- newIndex = this._selectRowBelowIndex(prevIndex);
1549
- this.ensureItemAtIndexIsVisible(newIndex);
1550
-
1551
- if (prevIndex !== newIndex) {
1552
- const item = getItem(data, newIndex);
1553
- if (this.props.onSelectionChanged) {
1554
- this.props.onSelectionChanged({
1555
- previousSelection: prevIndex,
1556
- newSelection: newIndex,
1557
- item: item,
1558
- });
1559
- }
1560
- }
1561
- } else if (key === 'UP_ARROW') {
1565
+ // const {data, getItem} = this.props;
1566
+ if (key === 'UP_ARROW') {
1562
1567
  newIndex = this._selectRowAboveIndex(prevIndex);
1563
- this.ensureItemAtIndexIsVisible(newIndex);
1564
-
1565
- if (prevIndex !== newIndex) {
1566
- const item = getItem(data, newIndex);
1567
- if (this.props.onSelectionChanged) {
1568
- this.props.onSelectionChanged({
1569
- previousSelection: prevIndex,
1570
- newSelection: newIndex,
1571
- item: item,
1572
- });
1573
- }
1574
- }
1568
+ this._handleSelectionChange(prevIndex, newIndex);
1569
+ } else if (key === 'DOWN_ARROW') {
1570
+ newIndex = this._selectRowBelowIndex(prevIndex);
1571
+ this._handleSelectionChange(prevIndex, newIndex);
1575
1572
  } else if (key === 'ENTER') {
1576
1573
  if (this.props.onSelectionEntered) {
1577
- const item = getItem(data, prevIndex);
1574
+ const item = this.props.getItem(this.props.data, prevIndex);
1578
1575
  if (this.props.onSelectionEntered) {
1579
1576
  this.props.onSelectionEntered(item);
1580
1577
  }
1581
1578
  }
1579
+ } else if (key === 'OPTION_UP') {
1580
+ newIndex = this._selectRowAtIndex(0);
1581
+ this._handleSelectionChange(prevIndex, newIndex);
1582
+ } else if (key === 'OPTION_DOWN') {
1583
+ newIndex = this._selectRowAtIndex(this.state.last);
1584
+ this._handleSelectionChange(prevIndex, newIndex);
1585
+ } else if (key === 'PAGE_UP') {
1586
+ const maxY =
1587
+ event.nativeEvent.contentSize.height -
1588
+ event.nativeEvent.layoutMeasurement.height;
1589
+ const newOffset = Math.min(
1590
+ maxY,
1591
+ nativeEvent.contentOffset.y + -nativeEvent.layoutMeasurement.height,
1592
+ );
1593
+ this.scrollToOffset({animated: true, offset: newOffset});
1594
+ } else if (key === 'PAGE_DOWN') {
1595
+ const maxY =
1596
+ event.nativeEvent.contentSize.height -
1597
+ event.nativeEvent.layoutMeasurement.height;
1598
+ const newOffset = Math.min(
1599
+ maxY,
1600
+ nativeEvent.contentOffset.y + nativeEvent.layoutMeasurement.height,
1601
+ );
1602
+ this.scrollToOffset({animated: true, offset: newOffset});
1603
+ } else if (key === 'HOME') {
1604
+ this.scrollToOffset({animated: true, offset: 0});
1605
+ } else if (key === 'END') {
1606
+ this.scrollToEnd({animated: true});
1582
1607
  }
1583
1608
  }
1584
1609
  }
1585
1610
  };
1611
+
1612
+ _handleSelectionChange = (prevIndex, newIndex) => {
1613
+ this.ensureItemAtIndexIsVisible(newIndex);
1614
+ if (prevIndex !== newIndex) {
1615
+ const item = this.props.getItem(this.props.data, newIndex);
1616
+ if (this.props.onSelectionChanged) {
1617
+ this.props.onSelectionChanged({
1618
+ previousSelection: prevIndex,
1619
+ newSelection: newIndex,
1620
+ item: item,
1621
+ });
1622
+ }
1623
+ }
1624
+ };
1586
1625
  // ]TODO(macOS GH#774)
1587
1626
 
1588
1627
  _renderDebugOverlay() {
@@ -2188,6 +2227,7 @@ class CellRenderer extends React.Component<
2188
2227
  return React.createElement(ListItemComponent, {
2189
2228
  item,
2190
2229
  index,
2230
+ isSelected,
2191
2231
  separators: this._separators,
2192
2232
  });
2193
2233
  }
@@ -2265,6 +2305,7 @@ class CellRenderer extends React.Component<
2265
2305
  {itemSeparator}
2266
2306
  </CellRendererComponent>
2267
2307
  );
2308
+ // TODO(macOS GH#774)]
2268
2309
 
2269
2310
  return (
2270
2311
  <VirtualizedListCellContextProvider cellKey={this.props.cellKey}>
@@ -28,7 +28,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
28
28
  RCTVersionMajor: @(0),
29
29
  RCTVersionMinor: @(0),
30
30
  RCTVersionPatch: @(0),
31
- RCTVersionPrerelease: @"ee0c151fd",
31
+ RCTVersionPrerelease: @"eefd4a8e0",
32
32
  };
33
33
  });
34
34
  return __rnVersion;
@@ -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
@@ -364,7 +364,8 @@ dependencies {
364
364
  api("com.facebook.infer.annotation:infer-annotation:0.18.0")
365
365
  api("com.facebook.yoga:proguard-annotations:1.19.0")
366
366
  api("javax.inject:javax.inject:1")
367
- api("androidx.appcompat:appcompat:1.0.2")
367
+ api("androidx.appcompat:appcompat:${APPCOMPAT_VERSION}")
368
+ api("androidx.appcompat:appcompat-resources:${APPCOMPAT_VERSION}")
368
369
  api("androidx.autofill:autofill:1.1.0")
369
370
  api("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
370
371
  api("com.facebook.fresco:fresco:${FRESCO_VERSION}")
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.0.0-ee0c151fd
1
+ VERSION_NAME=0.0.0-eefd4a8e0
2
2
  GROUP=com.facebook.react
3
3
 
4
4
  POM_NAME=ReactNative
@@ -11,6 +11,7 @@ ROBOLECTRIC_VERSION=4.4
11
11
  JUNIT_VERSION=4.12
12
12
 
13
13
  ANDROIDX_TEST_VERSION=1.1.0
14
+ APPCOMPAT_VERSION=1.4.1
14
15
  FRESCO_VERSION=2.5.0
15
16
  OKHTTP_VERSION=4.9.2
16
17
  SO_LOADER_VERSION=0.10.3
@@ -22,5 +22,5 @@ public class ReactNativeVersion {
22
22
  "major", 0,
23
23
  "minor", 0,
24
24
  "patch", 0,
25
- "prerelease", "ee0c151fd");
25
+ "prerelease", "eefd4a8e0");
26
26
  }
@@ -12,6 +12,7 @@ fb_native.android_library(
12
12
  exported_deps = [
13
13
  ":annotation",
14
14
  ":appcompat-binary",
15
+ ":appcompat-resources-binary",
15
16
  ":collection",
16
17
  ":core",
17
18
  ":cursoradapter",
@@ -365,6 +366,11 @@ fb_native.android_prebuilt_aar(
365
366
  aar = ":appcompat-binary-aar",
366
367
  )
367
368
 
369
+ fb_native.android_prebuilt_aar(
370
+ name = "appcompat-resources-binary",
371
+ aar = ":appcompat-resources-binary-aar",
372
+ )
373
+
368
374
  fb_native.android_prebuilt_aar(
369
375
  name = "asynclayoutinflater-binary",
370
376
  aar = ":asynclayoutinflater-binary-aar",
@@ -534,8 +540,14 @@ fb_native.remote_file(
534
540
 
535
541
  fb_native.remote_file(
536
542
  name = "appcompat-binary-aar",
537
- sha1 = "002533a36c928bb27a3cc6843a25f83754b3c3ae",
538
- url = "mvn:androidx.appcompat:appcompat:aar:1.0.2",
543
+ sha1 = "d384d125d196ed4997b418d7ba6fc18a4680ed22",
544
+ url = "mvn:androidx.appcompat:appcompat:aar:1.4.1",
545
+ )
546
+
547
+ fb_native.remote_file(
548
+ name = "appcompat-resources-binary-aar",
549
+ sha1 = "527d93d44bb18bc7dcf5213df8d4d069f0ceff61",
550
+ url = "mvn:androidx.appcompat:appcompat-resources:aar:1.4.1",
539
551
  )
540
552
 
541
553
  fb_native.remote_file(
@@ -558,8 +570,8 @@ fb_native.remote_file(
558
570
 
559
571
  fb_native.remote_file(
560
572
  name = "core-binary-aar",
561
- sha1 = "263deba7f9c24bd0cefb93c0aaaf402cc50828ee",
562
- url = "mvn:androidx.core:core:aar:1.0.1",
573
+ sha1 = "b26edc58f29ca0671e60828a68582760f880acdd",
574
+ url = "mvn:androidx.core:core:aar:1.7.0",
563
575
  )
564
576
 
565
577
  fb_native.remote_file(
@@ -22,7 +22,7 @@ constexpr struct {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 0;
24
24
  int32_t Patch = 0;
25
- std::string_view Prerelease = "ee0c151fd";
25
+ std::string_view Prerelease = "eefd4a8e0";
26
26
  } ReactNativeVersion;
27
27
 
28
28
  } // namespace facebook::react
@@ -28,7 +28,7 @@
28
28
  "nwmatcher": "1.4.4",
29
29
  "randomatic": "3.0.0",
30
30
  "sshpk": "1.16.1",
31
- "webpack": "^4.41.0"
31
+ "webpack": "^5.73.0"
32
32
  },
33
33
  "resolutions": {
34
34
  "set-value": "^4.1.0"