react-native-macos 0.66.72 → 0.66.75
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 +0 -77
- package/Libraries/Components/View/ViewPropTypes.js +0 -6
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Lists/FlatList.js +37 -1
- package/Libraries/Lists/VirtualizedList.js +112 -83
- package/Libraries/Lists/VirtualizedSectionList.js +9 -5
- package/Libraries/Types/CoreEventTypes.js +0 -1
- package/React/Base/RCTVersion.m +1 -1
- package/React/Views/RCTView.h +4 -6
- package/React/Views/RCTView.m +31 -200
- package/React/Views/RCTViewKeyboardEvent.h +6 -28
- package/React/Views/RCTViewKeyboardEvent.m +66 -61
- package/React/Views/RCTViewManager.m +2 -21
- package/React/Views/ScrollView/RCTScrollView.h +0 -1
- package/React/Views/ScrollView/RCTScrollView.m +55 -53
- package/React/Views/ScrollView/RCTScrollViewManager.m +0 -1
- package/React/Views/UIView+React.m +18 -10
- 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
|
@@ -1179,82 +1179,6 @@ class ScrollView extends React.Component<Props, State> {
|
|
|
1179
1179
|
}
|
|
1180
1180
|
|
|
1181
1181
|
// [TODO(macOS GH#774)
|
|
1182
|
-
_handleKeyDown = (event: ScrollEvent) => {
|
|
1183
|
-
if (this.props.onScrollKeyDown) {
|
|
1184
|
-
this.props.onScrollKeyDown(event);
|
|
1185
|
-
} else {
|
|
1186
|
-
if (Platform.OS === 'macos') {
|
|
1187
|
-
const nativeEvent = event.nativeEvent;
|
|
1188
|
-
const key = nativeEvent.key;
|
|
1189
|
-
const kMinScrollOffset = 10;
|
|
1190
|
-
if (key === 'PAGE_UP') {
|
|
1191
|
-
this._handleScrollByKeyDown(event, {
|
|
1192
|
-
x: nativeEvent.contentOffset.x,
|
|
1193
|
-
y:
|
|
1194
|
-
nativeEvent.contentOffset.y +
|
|
1195
|
-
-nativeEvent.layoutMeasurement.height,
|
|
1196
|
-
});
|
|
1197
|
-
} else if (key === 'PAGE_DOWN') {
|
|
1198
|
-
this._handleScrollByKeyDown(event, {
|
|
1199
|
-
x: nativeEvent.contentOffset.x,
|
|
1200
|
-
y:
|
|
1201
|
-
nativeEvent.contentOffset.y +
|
|
1202
|
-
nativeEvent.layoutMeasurement.height,
|
|
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
|
-
});
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
};
|
|
1244
|
-
|
|
1245
|
-
_handleScrollByKeyDown = (event: ScrollEvent, newOffset) => {
|
|
1246
|
-
const maxX =
|
|
1247
|
-
event.nativeEvent.contentSize.width -
|
|
1248
|
-
event.nativeEvent.layoutMeasurement.width;
|
|
1249
|
-
const maxY =
|
|
1250
|
-
event.nativeEvent.contentSize.height -
|
|
1251
|
-
event.nativeEvent.layoutMeasurement.height;
|
|
1252
|
-
this.scrollTo({
|
|
1253
|
-
x: Math.max(0, Math.min(maxX, newOffset.x)),
|
|
1254
|
-
y: Math.max(0, Math.min(maxY, newOffset.y)),
|
|
1255
|
-
});
|
|
1256
|
-
};
|
|
1257
|
-
|
|
1258
1182
|
_handlePreferredScrollerStyleDidChange = (event: ScrollEvent) => {
|
|
1259
1183
|
this.setState({contentKey: this.state.contentKey + 1});
|
|
1260
1184
|
}; // ]TODO(macOS GH#774)
|
|
@@ -1807,7 +1731,6 @@ class ScrollView extends React.Component<Props, State> {
|
|
|
1807
1731
|
// Override the onContentSizeChange from props, since this event can
|
|
1808
1732
|
// bubble up from TextInputs
|
|
1809
1733
|
onContentSizeChange: null,
|
|
1810
|
-
onScrollKeyDown: this._handleKeyDown, // TODO(macOS GH#774)
|
|
1811
1734
|
onPreferredScrollerStyleDidChange: this
|
|
1812
1735
|
._handlePreferredScrollerStyleDidChange, // TODO(macOS GH#774)
|
|
1813
1736
|
onLayout: this._handleLayout,
|
|
@@ -76,12 +76,6 @@ type DirectEventProps = $ReadOnly<{|
|
|
|
76
76
|
*/
|
|
77
77
|
onPreferredScrollerStyleDidChange?: ?(event: ScrollEvent) => mixed, // TODO(macOS GH#774)
|
|
78
78
|
|
|
79
|
-
/**
|
|
80
|
-
* When `acceptsKeyboardFocus` is true, the system will try to invoke this function
|
|
81
|
-
* when the user performs accessibility key down gesture.
|
|
82
|
-
*/
|
|
83
|
-
onScrollKeyDown?: ?(event: ScrollEvent) => mixed, // TODO(macOS GH#774)
|
|
84
|
-
|
|
85
79
|
/**
|
|
86
80
|
* Invoked on mount and layout changes with:
|
|
87
81
|
*
|
|
@@ -66,6 +66,24 @@ type OptionalProps<ItemT> = {|
|
|
|
66
66
|
* Optional custom style for multi-item rows generated when numColumns > 1.
|
|
67
67
|
*/
|
|
68
68
|
columnWrapperStyle?: ViewStyleProp,
|
|
69
|
+
// [TODO(macOS GH#774)
|
|
70
|
+
/**
|
|
71
|
+
* Allows you to 'select' a row using arrow keys. The selected row will have the prop `isSelected`
|
|
72
|
+
* passed in as true to it's renderItem / ListItemComponent. You can also imperatively select a row
|
|
73
|
+
* using the `selectRowAtIndex` method. You can set the initially selected row using the
|
|
74
|
+
* `initialSelectedIndex` prop.
|
|
75
|
+
* Keyboard Behavior:
|
|
76
|
+
* - ArrowUp: Select row above current selected row
|
|
77
|
+
* - ArrowDown: Select row below current selected row
|
|
78
|
+
* - Option+ArrowUp: Select the first row
|
|
79
|
+
* - Opton+ArrowDown: Select the last 'realized' row
|
|
80
|
+
* - Home: Scroll to top of list
|
|
81
|
+
* - End: Scroll to end of list
|
|
82
|
+
*
|
|
83
|
+
* @platform macos
|
|
84
|
+
*/
|
|
85
|
+
enableSelectionOnKeyPress?: ?boolean,
|
|
86
|
+
// ]TODO(macOS GH#774)
|
|
69
87
|
/**
|
|
70
88
|
* A marker property for telling the list to re-render (since it implements `PureComponent`). If
|
|
71
89
|
* any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the
|
|
@@ -111,6 +129,12 @@ type OptionalProps<ItemT> = {|
|
|
|
111
129
|
* `getItemLayout` to be implemented.
|
|
112
130
|
*/
|
|
113
131
|
initialScrollIndex?: ?number,
|
|
132
|
+
// [TODO(macOS GH#774)
|
|
133
|
+
/**
|
|
134
|
+
* The initially selected row, if `enableSelectionOnKeyPress` is set.
|
|
135
|
+
*/
|
|
136
|
+
initialSelectedIndex?: ?number,
|
|
137
|
+
// ]TODO(macOS GH#774)
|
|
114
138
|
/**
|
|
115
139
|
* Reverses the direction of scroll. Uses scale transforms of -1.
|
|
116
140
|
*/
|
|
@@ -369,6 +393,19 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
|
|
369
393
|
}
|
|
370
394
|
}
|
|
371
395
|
|
|
396
|
+
// [TODO(macOS GH#750)
|
|
397
|
+
/**
|
|
398
|
+
* Move selection to the specified index
|
|
399
|
+
*
|
|
400
|
+
* @platform macos
|
|
401
|
+
*/
|
|
402
|
+
selectRowAtIndex(index: number) {
|
|
403
|
+
if (this._listRef) {
|
|
404
|
+
this._listRef.selectRowAtIndex(index);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
// ]TODO(macOS GH#750)
|
|
408
|
+
|
|
372
409
|
/**
|
|
373
410
|
* Provides a handle to the underlying scroll responder.
|
|
374
411
|
*/
|
|
@@ -652,7 +689,6 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
|
|
652
689
|
removeClippedSubviews={removeClippedSubviewsOrDefault(
|
|
653
690
|
_removeClippedSubviews,
|
|
654
691
|
)}
|
|
655
|
-
accessibilityRole="table" // TODO(macOS GH#774): Inherit NSAccessibilityTable protocols
|
|
656
692
|
{...this._renderer()}
|
|
657
693
|
/>
|
|
658
694
|
);
|
|
@@ -35,7 +35,7 @@ import type {
|
|
|
35
35
|
ViewToken,
|
|
36
36
|
ViewabilityConfigCallbackPair,
|
|
37
37
|
} from './ViewabilityHelper';
|
|
38
|
-
import type {
|
|
38
|
+
import type {KeyEvent} from '../Types/CoreEventTypes'; // TODO(macOS GH#774)
|
|
39
39
|
import {
|
|
40
40
|
VirtualizedListCellContextProvider,
|
|
41
41
|
VirtualizedListContext,
|
|
@@ -109,12 +109,24 @@ type OptionalProps = {|
|
|
|
109
109
|
* this for debugging purposes. Defaults to false.
|
|
110
110
|
*/
|
|
111
111
|
disableVirtualization?: ?boolean,
|
|
112
|
+
// [TODO(macOS GH#774)
|
|
112
113
|
/**
|
|
113
|
-
*
|
|
114
|
+
* Allows you to 'select' a row using arrow keys. The selected row will have the prop `isSelected`
|
|
115
|
+
* passed in as true to it's renderItem / ListItemComponent. You can also imperatively select a row
|
|
116
|
+
* using the `selectRowAtIndex` method. You can set the initially selected row using the
|
|
117
|
+
* `initialSelectedIndex` prop.
|
|
118
|
+
* Keyboard Behavior:
|
|
119
|
+
* - ArrowUp: Select row above current selected row
|
|
120
|
+
* - ArrowDown: Select row below current selected row
|
|
121
|
+
* - Option+ArrowUp: Select the first row
|
|
122
|
+
* - Opton+ArrowDown: Select the last 'realized' row
|
|
123
|
+
* - Home: Scroll to top of list
|
|
124
|
+
* - End: Scroll to end of list
|
|
114
125
|
*
|
|
115
126
|
* @platform macos
|
|
116
127
|
*/
|
|
117
|
-
enableSelectionOnKeyPress?: ?boolean,
|
|
128
|
+
enableSelectionOnKeyPress?: ?boolean,
|
|
129
|
+
// ]TODO(macOS GH#774)
|
|
118
130
|
/**
|
|
119
131
|
* A marker property for telling the list to re-render (since it implements `PureComponent`). If
|
|
120
132
|
* any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the
|
|
@@ -145,6 +157,12 @@ type OptionalProps = {|
|
|
|
145
157
|
* `getItemLayout` to be implemented.
|
|
146
158
|
*/
|
|
147
159
|
initialScrollIndex?: ?number,
|
|
160
|
+
// [TODO(macOS GH#774)
|
|
161
|
+
/**
|
|
162
|
+
* The initially selected row, if `enableSelectionOnKeyPress` is set.
|
|
163
|
+
*/
|
|
164
|
+
initialSelectedIndex?: ?number,
|
|
165
|
+
// ]TODO(macOS GH#774)
|
|
148
166
|
/**
|
|
149
167
|
* Reverses the direction of scroll. Uses scale transforms of -1.
|
|
150
168
|
*/
|
|
@@ -588,10 +606,14 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
588
606
|
const newOffset = Math.min(contentLength, visTop + (frameEnd - visEnd));
|
|
589
607
|
this.scrollToOffset({offset: newOffset});
|
|
590
608
|
} else if (frame.offset < visTop) {
|
|
591
|
-
const newOffset = Math.
|
|
609
|
+
const newOffset = Math.min(frame.offset, visTop - frame.length);
|
|
592
610
|
this.scrollToOffset({offset: newOffset});
|
|
593
611
|
}
|
|
594
612
|
}
|
|
613
|
+
|
|
614
|
+
selectRowAtIndex(rowIndex: number) {
|
|
615
|
+
this._selectRowAtIndex(rowIndex);
|
|
616
|
+
}
|
|
595
617
|
// ]TODO(macOS GH#774)
|
|
596
618
|
|
|
597
619
|
recordInteraction() {
|
|
@@ -776,7 +798,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
776
798
|
(this.props.initialScrollIndex || 0) +
|
|
777
799
|
initialNumToRenderOrDefault(this.props.initialNumToRender),
|
|
778
800
|
) - 1,
|
|
779
|
-
selectedRowIndex:
|
|
801
|
+
selectedRowIndex: this.props.initialSelectedIndex ?? -1, // TODO(macOS GH#774)
|
|
780
802
|
};
|
|
781
803
|
|
|
782
804
|
if (this._isNestedWithSameOrientation()) {
|
|
@@ -839,7 +861,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
839
861
|
),
|
|
840
862
|
last: Math.max(0, Math.min(prevState.last, getItemCount(data) - 1)),
|
|
841
863
|
selectedRowIndex: Math.max(
|
|
842
|
-
|
|
864
|
+
-1, // Used to indicate no row is selected
|
|
843
865
|
Math.min(prevState.selectedRowIndex, getItemCount(data)),
|
|
844
866
|
), // TODO(macOS GH#774)
|
|
845
867
|
};
|
|
@@ -882,7 +904,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
882
904
|
index={ii}
|
|
883
905
|
inversionStyle={inversionStyle}
|
|
884
906
|
item={item}
|
|
885
|
-
|
|
907
|
+
// [TODO(macOS GH#774)
|
|
908
|
+
isSelected={
|
|
909
|
+
this.props.enableSelectionOnKeyPress &&
|
|
910
|
+
this.state.selectedRowIndex === ii
|
|
911
|
+
? true
|
|
912
|
+
: false
|
|
913
|
+
} // TODO(macOS GH#774)]
|
|
886
914
|
key={key}
|
|
887
915
|
prevCellKey={prevCellKey}
|
|
888
916
|
onUpdateSeparators={this._onUpdateSeparators}
|
|
@@ -1300,14 +1328,16 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1300
1328
|
}
|
|
1301
1329
|
|
|
1302
1330
|
_defaultRenderScrollComponent = props => {
|
|
1303
|
-
|
|
1304
|
-
if (!keyEventHandler) {
|
|
1305
|
-
keyEventHandler = this.props.enableSelectionOnKeyPress
|
|
1306
|
-
? this._handleKeyDown
|
|
1307
|
-
: null;
|
|
1308
|
-
}
|
|
1331
|
+
// [TODO(macOS GH#774)
|
|
1309
1332
|
const preferredScrollerStyleDidChangeHandler = this.props
|
|
1310
|
-
.onPreferredScrollerStyleDidChange;
|
|
1333
|
+
.onPreferredScrollerStyleDidChange;
|
|
1334
|
+
|
|
1335
|
+
const keyboardNavigationProps = {
|
|
1336
|
+
focusable: true,
|
|
1337
|
+
validKeysDown: ['ArrowUp', 'ArrowDown', 'Home', 'End'],
|
|
1338
|
+
onKeyDown: this._handleKeyDown,
|
|
1339
|
+
};
|
|
1340
|
+
// ]TODO(macOS GH#774)
|
|
1311
1341
|
const onRefresh = props.onRefresh;
|
|
1312
1342
|
if (this._isNestedWithSameOrientation()) {
|
|
1313
1343
|
// $FlowFixMe[prop-missing] - Typing ReactNativeComponent revealed errors
|
|
@@ -1323,10 +1353,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1323
1353
|
// $FlowFixMe[prop-missing] Invalid prop usage
|
|
1324
1354
|
<ScrollView
|
|
1325
1355
|
{...props}
|
|
1326
|
-
|
|
1356
|
+
// [TODO(macOS GH#774)
|
|
1357
|
+
{...(props.enableSelectionOnKeyPress && keyboardNavigationProps)}
|
|
1327
1358
|
onPreferredScrollerStyleDidChange={
|
|
1328
1359
|
preferredScrollerStyleDidChangeHandler
|
|
1329
|
-
} // TODO(macOS GH#774)
|
|
1360
|
+
} // TODO(macOS GH#774)]
|
|
1330
1361
|
refreshControl={
|
|
1331
1362
|
props.refreshControl == null ? (
|
|
1332
1363
|
<RefreshControl
|
|
@@ -1345,11 +1376,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1345
1376
|
// $FlowFixMe Invalid prop usage
|
|
1346
1377
|
<ScrollView
|
|
1347
1378
|
{...props}
|
|
1348
|
-
|
|
1379
|
+
// [TODO(macOS GH#774)
|
|
1380
|
+
{...(props.enableSelectionOnKeyPress && keyboardNavigationProps)}
|
|
1349
1381
|
onPreferredScrollerStyleDidChange={
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
}
|
|
1382
|
+
preferredScrollerStyleDidChangeHandler
|
|
1383
|
+
} // TODO(macOS GH#774)]
|
|
1353
1384
|
/>
|
|
1354
1385
|
);
|
|
1355
1386
|
}
|
|
@@ -1499,80 +1530,76 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1499
1530
|
};
|
|
1500
1531
|
|
|
1501
1532
|
// [TODO(macOS GH#774)
|
|
1533
|
+
_selectRowAtIndex = rowIndex => {
|
|
1534
|
+
const prevIndex = this.state.selectedRowIndex;
|
|
1535
|
+
const newIndex = rowIndex;
|
|
1536
|
+
this.setState({selectedRowIndex: newIndex});
|
|
1537
|
+
|
|
1538
|
+
this.ensureItemAtIndexIsVisible(newIndex);
|
|
1539
|
+
if (prevIndex !== newIndex) {
|
|
1540
|
+
const item = this.props.getItem(this.props.data, newIndex);
|
|
1541
|
+
if (this.props.onSelectionChanged) {
|
|
1542
|
+
this.props.onSelectionChanged({
|
|
1543
|
+
previousSelection: prevIndex,
|
|
1544
|
+
newSelection: newIndex,
|
|
1545
|
+
item: item,
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
return newIndex;
|
|
1551
|
+
};
|
|
1552
|
+
|
|
1502
1553
|
_selectRowAboveIndex = rowIndex => {
|
|
1503
1554
|
const rowAbove = rowIndex > 0 ? rowIndex - 1 : rowIndex;
|
|
1504
|
-
this.
|
|
1505
|
-
return {selectedRowIndex: rowAbove};
|
|
1506
|
-
});
|
|
1507
|
-
return rowAbove;
|
|
1555
|
+
this._selectRowAtIndex(rowAbove);
|
|
1508
1556
|
};
|
|
1509
1557
|
|
|
1510
1558
|
_selectRowBelowIndex = rowIndex => {
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
const itemCount = this.props.getItemCount(data);
|
|
1514
|
-
const rowBelow = rowIndex < itemCount - 1 ? rowIndex + 1 : rowIndex;
|
|
1515
|
-
this.setState(state => {
|
|
1516
|
-
return {selectedRowIndex: rowBelow};
|
|
1517
|
-
});
|
|
1518
|
-
return rowBelow;
|
|
1519
|
-
} else {
|
|
1520
|
-
return rowIndex;
|
|
1521
|
-
}
|
|
1559
|
+
const rowBelow = rowIndex < this.state.last ? rowIndex + 1 : rowIndex;
|
|
1560
|
+
this._selectRowAtIndex(rowBelow);
|
|
1522
1561
|
};
|
|
1523
1562
|
|
|
1524
|
-
_handleKeyDown = (
|
|
1525
|
-
if (
|
|
1526
|
-
this.props.
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
const event = e.nativeEvent;
|
|
1531
|
-
const key = event.key;
|
|
1532
|
-
|
|
1533
|
-
let prevIndex = -1;
|
|
1534
|
-
let newIndex = -1;
|
|
1535
|
-
if ('selectedRowIndex' in this.state) {
|
|
1536
|
-
prevIndex = this.state.selectedRowIndex;
|
|
1537
|
-
}
|
|
1563
|
+
_handleKeyDown = (event: KeyEvent) => {
|
|
1564
|
+
if (Platform.OS === 'macos') {
|
|
1565
|
+
this.props.onKeyDown?.(event);
|
|
1566
|
+
if (event.defaultPrevented) {
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1538
1569
|
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
item: item,
|
|
1565
|
-
});
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
} else if (key === 'ENTER') {
|
|
1570
|
+
const nativeEvent = event.nativeEvent;
|
|
1571
|
+
const key = nativeEvent.key;
|
|
1572
|
+
|
|
1573
|
+
let selectedIndex = -1;
|
|
1574
|
+
if (this.state.selectedRowIndex >= 0) {
|
|
1575
|
+
selectedIndex = this.state.selectedRowIndex;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
if (key === 'ArrowUp') {
|
|
1579
|
+
if (nativeEvent.altKey) {
|
|
1580
|
+
// Option+Up selects the first element
|
|
1581
|
+
this._selectRowAtIndex(0);
|
|
1582
|
+
} else {
|
|
1583
|
+
this._selectRowAboveIndex(selectedIndex);
|
|
1584
|
+
}
|
|
1585
|
+
} else if (key === 'ArrowDown') {
|
|
1586
|
+
if (nativeEvent.altKey) {
|
|
1587
|
+
// Option+Down selects the last element
|
|
1588
|
+
this._selectRowAtIndex(this.state.last);
|
|
1589
|
+
} else {
|
|
1590
|
+
this._selectRowBelowIndex(selectedIndex);
|
|
1591
|
+
}
|
|
1592
|
+
} else if (key === 'Enter') {
|
|
1593
|
+
if (this.props.onSelectionEntered) {
|
|
1594
|
+
const item = this.props.getItem(this.props.data, selectedIndex);
|
|
1569
1595
|
if (this.props.onSelectionEntered) {
|
|
1570
|
-
|
|
1571
|
-
if (this.props.onSelectionEntered) {
|
|
1572
|
-
this.props.onSelectionEntered(item);
|
|
1573
|
-
}
|
|
1596
|
+
this.props.onSelectionEntered(item);
|
|
1574
1597
|
}
|
|
1575
1598
|
}
|
|
1599
|
+
} else if (key === 'Home') {
|
|
1600
|
+
this.scrollToOffset({animated: true, offset: 0});
|
|
1601
|
+
} else if (key === 'End') {
|
|
1602
|
+
this.scrollToEnd({animated: true});
|
|
1576
1603
|
}
|
|
1577
1604
|
}
|
|
1578
1605
|
};
|
|
@@ -2182,6 +2209,7 @@ class CellRenderer extends React.Component<
|
|
|
2182
2209
|
return React.createElement(ListItemComponent, {
|
|
2183
2210
|
item,
|
|
2184
2211
|
index,
|
|
2212
|
+
isSelected,
|
|
2185
2213
|
separators: this._separators,
|
|
2186
2214
|
});
|
|
2187
2215
|
}
|
|
@@ -2258,6 +2286,7 @@ class CellRenderer extends React.Component<
|
|
|
2258
2286
|
{itemSeparator}
|
|
2259
2287
|
</CellRendererComponent>
|
|
2260
2288
|
);
|
|
2289
|
+
// TODO(macOS GH#774)]
|
|
2261
2290
|
|
|
2262
2291
|
return (
|
|
2263
2292
|
<VirtualizedListCellContextProvider cellKey={this.props.cellKey}>
|
|
@@ -12,7 +12,7 @@ const Platform = require('../Utilities/Platform'); // TODO(macOS GH#774)
|
|
|
12
12
|
import invariant from 'invariant';
|
|
13
13
|
import type {ViewToken} from './ViewabilityHelper';
|
|
14
14
|
import type {SelectedRowIndexPathType} from './VirtualizedList'; // TODO(macOS GH#774)
|
|
15
|
-
import type {
|
|
15
|
+
import type {KeyEvent} from '../Types/CoreEventTypes'; // TODO(macOS GH#774)
|
|
16
16
|
import {keyExtractor as defaultKeyExtractor} from './VirtualizeUtils';
|
|
17
17
|
import {View, VirtualizedList} from 'react-native';
|
|
18
18
|
import * as React from 'react';
|
|
@@ -311,8 +311,12 @@ class VirtualizedSectionList<
|
|
|
311
311
|
}
|
|
312
312
|
};
|
|
313
313
|
|
|
314
|
-
_handleKeyDown = (e:
|
|
314
|
+
_handleKeyDown = (e: KeyEvent) => {
|
|
315
315
|
if (Platform.OS === 'macos') {
|
|
316
|
+
if (e.defaultPrevented) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
316
320
|
const event = e.nativeEvent;
|
|
317
321
|
const key = event.key;
|
|
318
322
|
let prevIndexPath = this.state.selectedRowIndexPath;
|
|
@@ -320,7 +324,7 @@ class VirtualizedSectionList<
|
|
|
320
324
|
const sectionIndex = this.state.selectedRowIndexPath.sectionIndex;
|
|
321
325
|
const rowIndex = this.state.selectedRowIndexPath.rowIndex;
|
|
322
326
|
|
|
323
|
-
if (key === '
|
|
327
|
+
if (key === 'ArrowDown') {
|
|
324
328
|
nextIndexPath = this._selectRowBelowIndexPath(prevIndexPath);
|
|
325
329
|
this._ensureItemAtIndexPathIsVisible(nextIndexPath);
|
|
326
330
|
|
|
@@ -332,7 +336,7 @@ class VirtualizedSectionList<
|
|
|
332
336
|
item: item,
|
|
333
337
|
});
|
|
334
338
|
}
|
|
335
|
-
} else if (key === '
|
|
339
|
+
} else if (key === 'ArrowUp') {
|
|
336
340
|
nextIndexPath = this._selectRowAboveIndexPath(prevIndexPath);
|
|
337
341
|
this._ensureItemAtIndexPathIsVisible(nextIndexPath);
|
|
338
342
|
|
|
@@ -344,7 +348,7 @@ class VirtualizedSectionList<
|
|
|
344
348
|
item: item,
|
|
345
349
|
});
|
|
346
350
|
}
|
|
347
|
-
} else if (key === '
|
|
351
|
+
} else if (key === 'Enter') {
|
|
348
352
|
if (this.props.onSelectionEntered) {
|
|
349
353
|
const item = this.props.sections[sectionIndex].data[rowIndex];
|
|
350
354
|
this.props.onSelectionEntered(item);
|
package/React/Base/RCTVersion.m
CHANGED
package/React/Views/RCTView.h
CHANGED
|
@@ -27,6 +27,10 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
|
|
|
27
27
|
|
|
28
28
|
- (BOOL)becomeFirstResponder;
|
|
29
29
|
- (BOOL)resignFirstResponder;
|
|
30
|
+
|
|
31
|
+
#if TARGET_OS_OSX
|
|
32
|
+
- (BOOL)handleKeyboardEvent:(NSEvent *)event;
|
|
33
|
+
#endif
|
|
30
34
|
// ]TODO(OSS Candidate ISS#2710739)
|
|
31
35
|
|
|
32
36
|
/**
|
|
@@ -144,12 +148,6 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
|
|
|
144
148
|
@property (nonatomic, copy) RCTDirectEventBlock onKeyUp;
|
|
145
149
|
@property (nonatomic, copy) NSArray<NSString*> *validKeysDown;
|
|
146
150
|
@property (nonatomic, copy) NSArray<NSString*> *validKeysUp;
|
|
147
|
-
|
|
148
|
-
// Shadow Properties
|
|
149
|
-
@property (nonatomic, strong) NSColor *shadowColor;
|
|
150
|
-
@property (nonatomic, assign) CGFloat shadowOpacity;
|
|
151
|
-
@property (nonatomic, assign) CGFloat shadowRadius;
|
|
152
|
-
@property (nonatomic, assign) CGSize shadowOffset;
|
|
153
151
|
#endif // ]TODO(macOS GH#774)
|
|
154
152
|
|
|
155
153
|
/**
|