react-native-macos 0.66.66 → 0.66.67
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/Libraries/Components/ScrollView/ScrollView.js +36 -4
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Lists/FlatList.js +0 -13
- package/Libraries/Lists/VirtualizedList.js +41 -82
- package/React/Base/RCTVersion.m +1 -1
- package/React/Views/ScrollView/RCTScrollView.m +21 -36
- package/React/Views/UIView+React.m +10 -18
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/package.json +1 -1
- package/template/package.json +1 -1
|
@@ -1201,10 +1201,42 @@ class ScrollView extends React.Component<Props, State> {
|
|
|
1201
1201
|
nativeEvent.contentOffset.y +
|
|
1202
1202
|
nativeEvent.layoutMeasurement.height,
|
|
1203
1203
|
});
|
|
1204
|
-
} else if (key === '
|
|
1205
|
-
this.
|
|
1206
|
-
|
|
1207
|
-
|
|
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
|
+
});
|
|
1208
1240
|
}
|
|
1209
1241
|
}
|
|
1210
1242
|
}
|
|
@@ -369,19 +369,6 @@ 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
|
-
|
|
385
372
|
/**
|
|
386
373
|
* Provides a handle to the underlying scroll responder.
|
|
387
374
|
*/
|
|
@@ -588,14 +588,10 @@ 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.
|
|
591
|
+
const newOffset = Math.max(0, visTop - frame.length);
|
|
592
592
|
this.scrollToOffset({offset: newOffset});
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
|
-
|
|
596
|
-
selectRowAtIndex(rowIndex: number) {
|
|
597
|
-
this._selectRowAtIndex(rowIndex);
|
|
598
|
-
}
|
|
599
595
|
// ]TODO(macOS GH#774)
|
|
600
596
|
|
|
601
597
|
recordInteraction() {
|
|
@@ -886,13 +882,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
886
882
|
index={ii}
|
|
887
883
|
inversionStyle={inversionStyle}
|
|
888
884
|
item={item}
|
|
889
|
-
//
|
|
890
|
-
isSelected={
|
|
891
|
-
this.props.enableSelectionOnKeyPress &&
|
|
892
|
-
this.state.selectedRowIndex === ii
|
|
893
|
-
? true
|
|
894
|
-
: false
|
|
895
|
-
} // TODO(macOS GH#774)]
|
|
885
|
+
isSelected={this.state.selectedRowIndex === ii ? true : false} // TODO(macOS GH#774)
|
|
896
886
|
key={key}
|
|
897
887
|
prevCellKey={prevCellKey}
|
|
898
888
|
onUpdateSeparators={this._onUpdateSeparators}
|
|
@@ -1333,12 +1323,10 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1333
1323
|
// $FlowFixMe[prop-missing] Invalid prop usage
|
|
1334
1324
|
<ScrollView
|
|
1335
1325
|
{...props}
|
|
1336
|
-
//
|
|
1337
|
-
{...(props.enableSelectionOnKeyPress && {focusable: true})}
|
|
1338
|
-
onScrollKeyDown={keyEventHandler}
|
|
1326
|
+
onScrollKeyDown={keyEventHandler} // TODO(macOS GH#774)
|
|
1339
1327
|
onPreferredScrollerStyleDidChange={
|
|
1340
1328
|
preferredScrollerStyleDidChangeHandler
|
|
1341
|
-
} // TODO(macOS GH#774)
|
|
1329
|
+
} // TODO(macOS GH#774)
|
|
1342
1330
|
refreshControl={
|
|
1343
1331
|
props.refreshControl == null ? (
|
|
1344
1332
|
<RefreshControl
|
|
@@ -1357,11 +1345,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1357
1345
|
// $FlowFixMe Invalid prop usage
|
|
1358
1346
|
<ScrollView
|
|
1359
1347
|
{...props}
|
|
1360
|
-
{
|
|
1361
|
-
onScrollKeyDown={keyEventHandler}
|
|
1348
|
+
onScrollKeyDown={keyEventHandler} // TODO(macOS GH#774)
|
|
1362
1349
|
onPreferredScrollerStyleDidChange={
|
|
1363
|
-
|
|
1364
|
-
|
|
1350
|
+
// TODO(macOS GH#774)
|
|
1351
|
+
preferredScrollerStyleDidChangeHandler // TODO(macOS GH#774)
|
|
1352
|
+
}
|
|
1365
1353
|
/>
|
|
1366
1354
|
);
|
|
1367
1355
|
}
|
|
@@ -1519,13 +1507,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1519
1507
|
return rowAbove;
|
|
1520
1508
|
};
|
|
1521
1509
|
|
|
1522
|
-
_selectRowAtIndex = rowIndex => {
|
|
1523
|
-
this.setState(state => {
|
|
1524
|
-
return {selectedRowIndex: rowIndex};
|
|
1525
|
-
});
|
|
1526
|
-
return rowIndex;
|
|
1527
|
-
};
|
|
1528
|
-
|
|
1529
1510
|
_selectRowBelowIndex = rowIndex => {
|
|
1530
1511
|
if (this.props.getItemCount) {
|
|
1531
1512
|
const {data} = this.props;
|
|
@@ -1540,14 +1521,14 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1540
1521
|
}
|
|
1541
1522
|
};
|
|
1542
1523
|
|
|
1543
|
-
_handleKeyDown = (
|
|
1524
|
+
_handleKeyDown = (e: ScrollEvent) => {
|
|
1544
1525
|
if (this.props.onScrollKeyDown) {
|
|
1545
|
-
this.props.onScrollKeyDown(
|
|
1526
|
+
this.props.onScrollKeyDown(e);
|
|
1546
1527
|
} else {
|
|
1547
1528
|
if (Platform.OS === 'macos') {
|
|
1548
1529
|
// $FlowFixMe Cannot get e.nativeEvent because property nativeEvent is missing in Event
|
|
1549
|
-
const
|
|
1550
|
-
const key =
|
|
1530
|
+
const event = e.nativeEvent;
|
|
1531
|
+
const key = event.key;
|
|
1551
1532
|
|
|
1552
1533
|
let prevIndex = -1;
|
|
1553
1534
|
let newIndex = -1;
|
|
@@ -1555,66 +1536,46 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1555
1536
|
prevIndex = this.state.selectedRowIndex;
|
|
1556
1537
|
}
|
|
1557
1538
|
|
|
1558
|
-
|
|
1559
|
-
if (key === '
|
|
1560
|
-
newIndex = this._selectRowAboveIndex(prevIndex);
|
|
1561
|
-
this._handleSelectionChange(prevIndex, newIndex);
|
|
1562
|
-
} else if (key === 'DOWN_ARROW') {
|
|
1539
|
+
const {data, getItem} = this.props;
|
|
1540
|
+
if (key === 'DOWN_ARROW') {
|
|
1563
1541
|
newIndex = this._selectRowBelowIndex(prevIndex);
|
|
1564
|
-
this.
|
|
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') {
|
|
1555
|
+
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
|
+
}
|
|
1565
1568
|
} else if (key === 'ENTER') {
|
|
1566
1569
|
if (this.props.onSelectionEntered) {
|
|
1567
|
-
const item =
|
|
1570
|
+
const item = getItem(data, prevIndex);
|
|
1568
1571
|
if (this.props.onSelectionEntered) {
|
|
1569
1572
|
this.props.onSelectionEntered(item);
|
|
1570
1573
|
}
|
|
1571
1574
|
}
|
|
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});
|
|
1600
1575
|
}
|
|
1601
1576
|
}
|
|
1602
1577
|
}
|
|
1603
1578
|
};
|
|
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
|
-
};
|
|
1618
1579
|
// ]TODO(macOS GH#774)
|
|
1619
1580
|
|
|
1620
1581
|
_renderDebugOverlay() {
|
|
@@ -2221,7 +2182,6 @@ class CellRenderer extends React.Component<
|
|
|
2221
2182
|
return React.createElement(ListItemComponent, {
|
|
2222
2183
|
item,
|
|
2223
2184
|
index,
|
|
2224
|
-
isSelected,
|
|
2225
2185
|
separators: this._separators,
|
|
2226
2186
|
});
|
|
2227
2187
|
}
|
|
@@ -2298,7 +2258,6 @@ class CellRenderer extends React.Component<
|
|
|
2298
2258
|
{itemSeparator}
|
|
2299
2259
|
</CellRendererComponent>
|
|
2300
2260
|
);
|
|
2301
|
-
// TODO(macOS GH#774)]
|
|
2302
2261
|
|
|
2303
2262
|
return (
|
|
2304
2263
|
<VirtualizedListCellContextProvider cellKey={this.props.cellKey}>
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -1180,22 +1180,16 @@ 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
|
|
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
|
-
|
|
1193
1190
|
case 116:
|
|
1194
1191
|
return @"PAGE_UP";
|
|
1195
1192
|
|
|
1196
|
-
case 119:
|
|
1197
|
-
return @"END";
|
|
1198
|
-
|
|
1199
1193
|
case 121:
|
|
1200
1194
|
return @"PAGE_DOWN";
|
|
1201
1195
|
|
|
@@ -1206,18 +1200,10 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
|
|
|
1206
1200
|
return @"RIGHT_ARROW";
|
|
1207
1201
|
|
|
1208
1202
|
case 125:
|
|
1209
|
-
|
|
1210
|
-
return @"OPTION_DOWN";
|
|
1211
|
-
} else {
|
|
1212
|
-
return @"DOWN_ARROW";
|
|
1213
|
-
}
|
|
1203
|
+
return @"DOWN_ARROW";
|
|
1214
1204
|
|
|
1215
1205
|
case 126:
|
|
1216
|
-
|
|
1217
|
-
return @"OPTION_UP";
|
|
1218
|
-
} else {
|
|
1219
|
-
return @"UP_ARROW";
|
|
1220
|
-
}
|
|
1206
|
+
return @"UP_ARROW";
|
|
1221
1207
|
}
|
|
1222
1208
|
return @"";
|
|
1223
1209
|
}
|
|
@@ -1225,25 +1211,24 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
|
|
|
1225
1211
|
- (void)keyDown:(UIEvent*)theEvent
|
|
1226
1212
|
{
|
|
1227
1213
|
// Don't emit a scroll event if tab was pressed while the scrollview is first responder
|
|
1228
|
-
if (
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
[
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
[[_scrollView documentView] scrollRectToVisible:visibleRect];
|
|
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
|
+
}
|
|
1247
1232
|
}
|
|
1248
1233
|
}
|
|
1249
1234
|
}
|
|
@@ -285,37 +285,29 @@
|
|
|
285
285
|
|
|
286
286
|
- (void)reactFocus
|
|
287
287
|
{
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (![self becomeFirstResponder]) {
|
|
292
|
-
#endif //// TODO(macOS GH#774)]
|
|
293
|
-
self.reactIsFocusNeeded = YES;
|
|
294
|
-
}
|
|
288
|
+
if (![self becomeFirstResponder]) {
|
|
289
|
+
self.reactIsFocusNeeded = YES;
|
|
290
|
+
}
|
|
295
291
|
}
|
|
296
292
|
|
|
297
293
|
- (void)reactFocusIfNeeded
|
|
298
294
|
{
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
#endif // TODO(macOS GH#774)]
|
|
305
|
-
self.reactIsFocusNeeded = NO;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
295
|
+
if (self.reactIsFocusNeeded) {
|
|
296
|
+
if ([self becomeFirstResponder]) {
|
|
297
|
+
self.reactIsFocusNeeded = NO;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
308
300
|
}
|
|
309
301
|
|
|
310
302
|
- (void)reactBlur
|
|
311
303
|
{
|
|
312
|
-
#if TARGET_OS_OSX //
|
|
304
|
+
#if TARGET_OS_OSX // TODO(macOS GH#774)
|
|
313
305
|
if (self == [[self window] firstResponder]) {
|
|
314
306
|
[[self window] makeFirstResponder:[[self window] nextResponder]];
|
|
315
307
|
}
|
|
316
308
|
#else
|
|
317
309
|
[self resignFirstResponder];
|
|
318
|
-
#endif
|
|
310
|
+
#endif
|
|
319
311
|
}
|
|
320
312
|
|
|
321
313
|
#pragma mark - Layout
|
package/package.json
CHANGED