react-native-macos 0.0.0-b9fb2dd1a → 0.0.0-bc0c2c4d1
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 +11 -45
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
- package/Libraries/Components/TextInput/TextInput.js +79 -1
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewViewConfig.js +1 -0
- package/Libraries/Components/View/ReactNativeViewViewConfigMacOS.js +3 -3
- package/Libraries/Components/View/ViewPropTypes.js +10 -6
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Image/RCTImageView.mm +14 -10
- package/Libraries/LinkingIOS/RCTLinkingManager.h +1 -0
- package/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +12 -5
- package/Libraries/Lists/FlatList.js +25 -1
- package/Libraries/Lists/VirtualizedList.js +118 -113
- package/Libraries/Lists/VirtualizedSectionList.js +9 -5
- package/Libraries/StyleSheet/StyleSheetTypes.js +25 -0
- package/Libraries/Text/BaseText/RCTBaseTextViewManager.m +1 -0
- package/Libraries/Text/RCTTextAttributes.h +2 -0
- package/Libraries/Text/RCTTextAttributes.m +14 -5
- package/Libraries/Text/Text/RCTDynamicTypeRamp.h +40 -0
- package/Libraries/Text/Text/RCTDynamicTypeRamp.m +77 -0
- package/Libraries/Text/Text/RCTTextView.m +118 -47
- package/Libraries/Text/Text.js +0 -8
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.h +8 -0
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +57 -2
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.m +13 -0
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +2 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +69 -2
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +7 -1
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +12 -3
- package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +1 -0
- package/Libraries/Text/TextInput/RCTBaseTextInputView.h +4 -1
- package/Libraries/Text/TextInput/RCTBaseTextInputView.m +97 -2
- package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +6 -1
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +40 -0
- package/Libraries/Text/TextNativeComponent.js +2 -0
- package/Libraries/Text/TextProps.js +29 -0
- package/Libraries/Types/CoreEventTypes.js +0 -1
- package/React/Base/RCTAssert.h +4 -3
- package/React/Base/RCTAssert.m +11 -2
- package/React/Base/RCTBridge.m +1 -1
- package/React/Base/RCTConstants.h +6 -0
- package/React/Base/RCTConstants.m +15 -0
- package/React/Base/RCTConvert.m +8 -4
- package/React/Base/RCTTouchHandler.m +4 -0
- package/React/Base/RCTUIKit.h +8 -13
- package/React/Base/RCTUtils.m +6 -3
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTUIKit.m +40 -0
- package/React/CoreModules/RCTPerfMonitor.mm +1 -1
- package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +6 -2
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +1 -1
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +17 -3
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +8 -1
- package/React/Fabric/Mounting/RCTMountingManager.h +1 -1
- package/React/Fabric/Mounting/RCTMountingManager.mm +3 -3
- package/React/Fabric/RCTConversions.h +9 -1
- package/React/Fabric/RCTLocalizationProvider.mm +10 -4
- package/React/Fabric/RCTScheduler.h +5 -0
- package/React/Fabric/RCTScheduler.mm +10 -0
- package/React/Fabric/RCTSurfacePresenter.h +2 -0
- package/React/Fabric/RCTSurfacePresenter.mm +12 -11
- package/React/Fabric/RCTSurfaceTouchHandler.mm +0 -1
- package/React/Modules/RCTUIManager.m +2 -1
- package/React/React-RCTFabric.podspec +1 -1
- package/React/Views/RCTActivityIndicatorView.m +2 -1
- package/React/Views/RCTCursor.h +39 -0
- package/React/Views/RCTCursor.m +105 -0
- package/React/Views/RCTView.h +12 -0
- package/React/Views/RCTView.m +116 -43
- package/React/Views/RCTViewKeyboardEvent.m +9 -1
- package/React/Views/RCTViewManager.m +18 -13
- package/React/Views/ScrollView/RCTScrollContentView.h +4 -0
- package/React/Views/ScrollView/RCTScrollContentView.m +18 -0
- package/React/Views/ScrollView/RCTScrollContentViewManager.m +2 -0
- package/React/Views/ScrollView/RCTScrollView.h +2 -1
- package/React/Views/ScrollView/RCTScrollView.m +70 -63
- package/React/Views/ScrollView/RCTScrollViewManager.m +1 -1
- package/React/Views/UIView+React.h +2 -0
- package/React/Views/UIView+React.m +22 -13
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/React-Fabric.podspec +1 -1
- package/ReactCommon/React-rncore.podspec +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/renderer/core/EventDispatcher.cpp +21 -0
- package/ReactCommon/react/renderer/core/EventDispatcher.h +15 -0
- package/ReactCommon/react/renderer/core/EventListener.cpp +39 -0
- package/ReactCommon/react/renderer/core/EventListener.h +44 -0
- package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
- package/ReactCommon/react/renderer/scheduler/Scheduler.cpp +14 -0
- package/ReactCommon/react/renderer/scheduler/Scheduler.h +6 -0
- package/ReactCommon/react/utils/ManagedObjectWrapper.h +1 -1
- package/ReactCommon/react/utils/ManagedObjectWrapper.mm +1 -3
- package/package.json +1 -1
- package/scripts/generate-artifacts.js +21 -17
- package/scripts/react_native_pods.rb +0 -3
- package/template/Gemfile.lock +7 -7
- package/template/package.json +1 -1
- package/third-party-podspecs/boost-for-react-native.podspec +0 -20
|
@@ -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
|
*/
|
|
@@ -782,7 +800,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
782
800
|
(this.props.initialScrollIndex || 0) +
|
|
783
801
|
initialNumToRenderOrDefault(this.props.initialNumToRender),
|
|
784
802
|
) - 1,
|
|
785
|
-
selectedRowIndex:
|
|
803
|
+
selectedRowIndex: this.props.initialSelectedIndex ?? -1, // TODO(macOS GH#774)
|
|
786
804
|
};
|
|
787
805
|
|
|
788
806
|
if (this._isNestedWithSameOrientation()) {
|
|
@@ -845,7 +863,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
845
863
|
),
|
|
846
864
|
last: Math.max(0, Math.min(prevState.last, getItemCount(data) - 1)),
|
|
847
865
|
selectedRowIndex: Math.max(
|
|
848
|
-
|
|
866
|
+
-1, // Used to indicate no row is selected
|
|
849
867
|
Math.min(prevState.selectedRowIndex, getItemCount(data)),
|
|
850
868
|
), // TODO(macOS GH#774)
|
|
851
869
|
};
|
|
@@ -961,11 +979,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
961
979
|
this.props;
|
|
962
980
|
const {data, horizontal} = this.props;
|
|
963
981
|
const isVirtualizationDisabled = this._isVirtualizationDisabled();
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
982
|
+
// macOS natively supports inverted lists, thus not needing an inversion style
|
|
983
|
+
const inversionStyle =
|
|
984
|
+
this.props.inverted && Platform.OS !== 'macos' // TODO(macOS GH#774)
|
|
985
|
+
? horizontalOrDefault(this.props.horizontal)
|
|
986
|
+
? styles.horizontallyInverted
|
|
987
|
+
: styles.verticallyInverted
|
|
988
|
+
: null;
|
|
969
989
|
const cells = [];
|
|
970
990
|
const stickyIndicesFromProps = new Set(this.props.stickyHeaderIndices);
|
|
971
991
|
const stickyHeaderIndices = [];
|
|
@@ -1309,14 +1329,29 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1309
1329
|
}
|
|
1310
1330
|
|
|
1311
1331
|
_defaultRenderScrollComponent = props => {
|
|
1312
|
-
|
|
1313
|
-
if (!keyEventHandler) {
|
|
1314
|
-
keyEventHandler = this.props.enableSelectionOnKeyPress
|
|
1315
|
-
? this._handleKeyDown
|
|
1316
|
-
: null;
|
|
1317
|
-
}
|
|
1332
|
+
// [TODO(macOS GH#774)
|
|
1318
1333
|
const preferredScrollerStyleDidChangeHandler =
|
|
1319
|
-
this.props.onPreferredScrollerStyleDidChange;
|
|
1334
|
+
this.props.onPreferredScrollerStyleDidChange;
|
|
1335
|
+
const invertedDidChange = this.props.onInvertedDidChange;
|
|
1336
|
+
|
|
1337
|
+
const isFirstRowSelected = this.state.selectedRowIndex === this.state.first;
|
|
1338
|
+
const isLastRowSelected = this.state.selectedRowIndex === this.state.last;
|
|
1339
|
+
|
|
1340
|
+
// Don't pass in ArrowUp/ArrowDown at the top/bottom of the list so that keyboard event can bubble
|
|
1341
|
+
let _validKeysDown = ['Home', 'End'];
|
|
1342
|
+
if (!isFirstRowSelected) {
|
|
1343
|
+
_validKeysDown.push('ArrowUp');
|
|
1344
|
+
}
|
|
1345
|
+
if (!isLastRowSelected) {
|
|
1346
|
+
_validKeysDown.push('ArrowDown');
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
const keyboardNavigationProps = {
|
|
1350
|
+
focusable: true,
|
|
1351
|
+
validKeysDown: _validKeysDown,
|
|
1352
|
+
onKeyDown: this._handleKeyDown,
|
|
1353
|
+
};
|
|
1354
|
+
// ]TODO(macOS GH#774)
|
|
1320
1355
|
const onRefresh = props.onRefresh;
|
|
1321
1356
|
if (this._isNestedWithSameOrientation()) {
|
|
1322
1357
|
// $FlowFixMe[prop-missing] - Typing ReactNativeComponent revealed errors
|
|
@@ -1331,13 +1366,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1331
1366
|
return (
|
|
1332
1367
|
// $FlowFixMe[prop-missing] Invalid prop usage
|
|
1333
1368
|
<ScrollView
|
|
1334
|
-
{...props}
|
|
1335
1369
|
// [TODO(macOS GH#774)
|
|
1336
|
-
{...(props.enableSelectionOnKeyPress &&
|
|
1337
|
-
|
|
1370
|
+
{...(props.enableSelectionOnKeyPress && keyboardNavigationProps)}
|
|
1371
|
+
onInvertedDidChange={invertedDidChange}
|
|
1338
1372
|
onPreferredScrollerStyleDidChange={
|
|
1339
1373
|
preferredScrollerStyleDidChangeHandler
|
|
1340
1374
|
} // TODO(macOS GH#774)]
|
|
1375
|
+
{...props}
|
|
1341
1376
|
refreshControl={
|
|
1342
1377
|
props.refreshControl == null ? (
|
|
1343
1378
|
<RefreshControl
|
|
@@ -1355,12 +1390,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1355
1390
|
return (
|
|
1356
1391
|
// $FlowFixMe Invalid prop usage
|
|
1357
1392
|
<ScrollView
|
|
1358
|
-
|
|
1359
|
-
{...(props.enableSelectionOnKeyPress &&
|
|
1360
|
-
|
|
1393
|
+
// [TODO(macOS GH#774)
|
|
1394
|
+
{...(props.enableSelectionOnKeyPress && keyboardNavigationProps)}
|
|
1395
|
+
onInvertedDidChange={invertedDidChange}
|
|
1361
1396
|
onPreferredScrollerStyleDidChange={
|
|
1362
1397
|
preferredScrollerStyleDidChangeHandler
|
|
1363
1398
|
} // TODO(macOS GH#774)]
|
|
1399
|
+
{...props}
|
|
1364
1400
|
/>
|
|
1365
1401
|
);
|
|
1366
1402
|
}
|
|
@@ -1510,98 +1546,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1510
1546
|
};
|
|
1511
1547
|
|
|
1512
1548
|
// [TODO(macOS GH#774)
|
|
1513
|
-
_selectRowAboveIndex = rowIndex => {
|
|
1514
|
-
const rowAbove = rowIndex > 0 ? rowIndex - 1 : rowIndex;
|
|
1515
|
-
this.setState(state => {
|
|
1516
|
-
return {selectedRowIndex: rowAbove};
|
|
1517
|
-
});
|
|
1518
|
-
return rowAbove;
|
|
1519
|
-
};
|
|
1520
|
-
|
|
1521
1549
|
_selectRowAtIndex = rowIndex => {
|
|
1522
|
-
this.
|
|
1523
|
-
|
|
1524
|
-
});
|
|
1525
|
-
return rowIndex;
|
|
1526
|
-
};
|
|
1527
|
-
|
|
1528
|
-
_selectRowBelowIndex = rowIndex => {
|
|
1529
|
-
if (this.props.getItemCount) {
|
|
1530
|
-
const {data} = this.props;
|
|
1531
|
-
const itemCount = this.props.getItemCount(data);
|
|
1532
|
-
const rowBelow = rowIndex < itemCount - 1 ? rowIndex + 1 : rowIndex;
|
|
1533
|
-
this.setState(state => {
|
|
1534
|
-
return {selectedRowIndex: rowBelow};
|
|
1535
|
-
});
|
|
1536
|
-
return rowBelow;
|
|
1537
|
-
} else {
|
|
1538
|
-
return rowIndex;
|
|
1539
|
-
}
|
|
1540
|
-
};
|
|
1550
|
+
const prevIndex = this.state.selectedRowIndex;
|
|
1551
|
+
const newIndex = rowIndex;
|
|
1552
|
+
this.setState({selectedRowIndex: newIndex});
|
|
1541
1553
|
|
|
1542
|
-
_handleKeyDown = (event: ScrollEvent) => {
|
|
1543
|
-
if (this.props.onScrollKeyDown) {
|
|
1544
|
-
this.props.onScrollKeyDown(event);
|
|
1545
|
-
} else {
|
|
1546
|
-
if (Platform.OS === 'macos') {
|
|
1547
|
-
// $FlowFixMe Cannot get e.nativeEvent because property nativeEvent is missing in Event
|
|
1548
|
-
const nativeEvent = event.nativeEvent;
|
|
1549
|
-
const key = nativeEvent.key;
|
|
1550
|
-
|
|
1551
|
-
let prevIndex = -1;
|
|
1552
|
-
let newIndex = -1;
|
|
1553
|
-
if ('selectedRowIndex' in this.state) {
|
|
1554
|
-
prevIndex = this.state.selectedRowIndex;
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
// const {data, getItem} = this.props;
|
|
1558
|
-
if (key === 'UP_ARROW') {
|
|
1559
|
-
newIndex = this._selectRowAboveIndex(prevIndex);
|
|
1560
|
-
this._handleSelectionChange(prevIndex, newIndex);
|
|
1561
|
-
} else if (key === 'DOWN_ARROW') {
|
|
1562
|
-
newIndex = this._selectRowBelowIndex(prevIndex);
|
|
1563
|
-
this._handleSelectionChange(prevIndex, newIndex);
|
|
1564
|
-
} else if (key === 'ENTER') {
|
|
1565
|
-
if (this.props.onSelectionEntered) {
|
|
1566
|
-
const item = this.props.getItem(this.props.data, prevIndex);
|
|
1567
|
-
if (this.props.onSelectionEntered) {
|
|
1568
|
-
this.props.onSelectionEntered(item);
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
} else if (key === 'OPTION_UP') {
|
|
1572
|
-
newIndex = this._selectRowAtIndex(0);
|
|
1573
|
-
this._handleSelectionChange(prevIndex, newIndex);
|
|
1574
|
-
} else if (key === 'OPTION_DOWN') {
|
|
1575
|
-
newIndex = this._selectRowAtIndex(this.state.last);
|
|
1576
|
-
this._handleSelectionChange(prevIndex, newIndex);
|
|
1577
|
-
} else if (key === 'PAGE_UP') {
|
|
1578
|
-
const maxY =
|
|
1579
|
-
event.nativeEvent.contentSize.height -
|
|
1580
|
-
event.nativeEvent.layoutMeasurement.height;
|
|
1581
|
-
const newOffset = Math.min(
|
|
1582
|
-
maxY,
|
|
1583
|
-
nativeEvent.contentOffset.y + -nativeEvent.layoutMeasurement.height,
|
|
1584
|
-
);
|
|
1585
|
-
this.scrollToOffset({animated: true, offset: newOffset});
|
|
1586
|
-
} else if (key === 'PAGE_DOWN') {
|
|
1587
|
-
const maxY =
|
|
1588
|
-
event.nativeEvent.contentSize.height -
|
|
1589
|
-
event.nativeEvent.layoutMeasurement.height;
|
|
1590
|
-
const newOffset = Math.min(
|
|
1591
|
-
maxY,
|
|
1592
|
-
nativeEvent.contentOffset.y + nativeEvent.layoutMeasurement.height,
|
|
1593
|
-
);
|
|
1594
|
-
this.scrollToOffset({animated: true, offset: newOffset});
|
|
1595
|
-
} else if (key === 'HOME') {
|
|
1596
|
-
this.scrollToOffset({animated: true, offset: 0});
|
|
1597
|
-
} else if (key === 'END') {
|
|
1598
|
-
this.scrollToEnd({animated: true});
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
};
|
|
1603
|
-
|
|
1604
|
-
_handleSelectionChange = (prevIndex, newIndex) => {
|
|
1605
1554
|
this.ensureItemAtIndexIsVisible(newIndex);
|
|
1606
1555
|
if (prevIndex !== newIndex) {
|
|
1607
1556
|
const item = this.props.getItem(this.props.data, newIndex);
|
|
@@ -1613,6 +1562,62 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1613
1562
|
});
|
|
1614
1563
|
}
|
|
1615
1564
|
}
|
|
1565
|
+
|
|
1566
|
+
return newIndex;
|
|
1567
|
+
};
|
|
1568
|
+
|
|
1569
|
+
_selectRowAboveIndex = rowIndex => {
|
|
1570
|
+
const rowAbove = rowIndex > 0 ? rowIndex - 1 : rowIndex;
|
|
1571
|
+
this._selectRowAtIndex(rowAbove);
|
|
1572
|
+
};
|
|
1573
|
+
|
|
1574
|
+
_selectRowBelowIndex = rowIndex => {
|
|
1575
|
+
const rowBelow = rowIndex < this.state.last ? rowIndex + 1 : rowIndex;
|
|
1576
|
+
this._selectRowAtIndex(rowBelow);
|
|
1577
|
+
};
|
|
1578
|
+
|
|
1579
|
+
_handleKeyDown = (event: KeyEvent) => {
|
|
1580
|
+
if (Platform.OS === 'macos') {
|
|
1581
|
+
this.props.onKeyDown?.(event);
|
|
1582
|
+
if (event.defaultPrevented) {
|
|
1583
|
+
return;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
const nativeEvent = event.nativeEvent;
|
|
1587
|
+
const key = nativeEvent.key;
|
|
1588
|
+
|
|
1589
|
+
let selectedIndex = -1;
|
|
1590
|
+
if (this.state.selectedRowIndex >= 0) {
|
|
1591
|
+
selectedIndex = this.state.selectedRowIndex;
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
if (key === 'ArrowUp') {
|
|
1595
|
+
if (nativeEvent.altKey) {
|
|
1596
|
+
// Option+Up selects the first element
|
|
1597
|
+
this._selectRowAtIndex(0);
|
|
1598
|
+
} else {
|
|
1599
|
+
this._selectRowAboveIndex(selectedIndex);
|
|
1600
|
+
}
|
|
1601
|
+
} else if (key === 'ArrowDown') {
|
|
1602
|
+
if (nativeEvent.altKey) {
|
|
1603
|
+
// Option+Down selects the last element
|
|
1604
|
+
this._selectRowAtIndex(this.state.last);
|
|
1605
|
+
} else {
|
|
1606
|
+
this._selectRowBelowIndex(selectedIndex);
|
|
1607
|
+
}
|
|
1608
|
+
} else if (key === 'Enter') {
|
|
1609
|
+
if (this.props.onSelectionEntered) {
|
|
1610
|
+
const item = this.props.getItem(this.props.data, selectedIndex);
|
|
1611
|
+
if (this.props.onSelectionEntered) {
|
|
1612
|
+
this.props.onSelectionEntered(item);
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
} else if (key === 'Home') {
|
|
1616
|
+
this.scrollToOffset({animated: true, offset: 0});
|
|
1617
|
+
} else if (key === 'End') {
|
|
1618
|
+
this.scrollToEnd({animated: true});
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1616
1621
|
};
|
|
1617
1622
|
// ]TODO(macOS GH#774)
|
|
1618
1623
|
|
|
@@ -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);
|
|
@@ -16,6 +16,29 @@ import type {NativeColorValue} from './PlatformColorValueTypes';
|
|
|
16
16
|
|
|
17
17
|
export type ____ColorValue_Internal = null | string | NativeColorValue;
|
|
18
18
|
|
|
19
|
+
export type CursorValue = ?(
|
|
20
|
+
| 'alias'
|
|
21
|
+
| 'auto'
|
|
22
|
+
| 'col-resize'
|
|
23
|
+
| 'context-menu'
|
|
24
|
+
| 'copy'
|
|
25
|
+
| 'crosshair'
|
|
26
|
+
| 'default'
|
|
27
|
+
| 'disappearing-item'
|
|
28
|
+
| 'e-resize'
|
|
29
|
+
| 'grab'
|
|
30
|
+
| 'grabbing'
|
|
31
|
+
| 'n-resize'
|
|
32
|
+
| 'no-drop'
|
|
33
|
+
| 'not-allowed'
|
|
34
|
+
| 'pointer'
|
|
35
|
+
| 'row-resize'
|
|
36
|
+
| 's-resize'
|
|
37
|
+
| 'text'
|
|
38
|
+
| 'vertical-text'
|
|
39
|
+
| 'w-resize'
|
|
40
|
+
);
|
|
41
|
+
|
|
19
42
|
export type ColorArrayValue = null | $ReadOnlyArray<____ColorValue_Internal>;
|
|
20
43
|
export type PointValue = {|
|
|
21
44
|
x: number,
|
|
@@ -584,6 +607,7 @@ export type ____ViewStyle_Internal = $ReadOnly<{|
|
|
|
584
607
|
borderTopWidth?: number | AnimatedNode,
|
|
585
608
|
opacity?: number | AnimatedNode,
|
|
586
609
|
elevation?: number,
|
|
610
|
+
cursor?: CursorValue,
|
|
587
611
|
|}>;
|
|
588
612
|
|
|
589
613
|
export type ____FontWeight_Internal =
|
|
@@ -638,6 +662,7 @@ export type ____TextStyle_Internal = $ReadOnly<{|
|
|
|
638
662
|
textDecorationColor?: ____ColorValue_Internal,
|
|
639
663
|
textTransform?: 'none' | 'capitalize' | 'uppercase' | 'lowercase',
|
|
640
664
|
writingDirection?: 'auto' | 'ltr' | 'rtl',
|
|
665
|
+
cursor?: CursorValue,
|
|
641
666
|
|}>;
|
|
642
667
|
|
|
643
668
|
export type ____ImageStyle_Internal = $ReadOnly<{|
|
|
@@ -36,6 +36,7 @@ RCT_REMAP_SHADOW_PROPERTY(fontWeight, textAttributes.fontWeight, NSString)
|
|
|
36
36
|
RCT_REMAP_SHADOW_PROPERTY(fontStyle, textAttributes.fontStyle, NSString)
|
|
37
37
|
RCT_REMAP_SHADOW_PROPERTY(fontVariant, textAttributes.fontVariant, NSArray)
|
|
38
38
|
RCT_REMAP_SHADOW_PROPERTY(allowFontScaling, textAttributes.allowFontScaling, BOOL)
|
|
39
|
+
RCT_REMAP_SHADOW_PROPERTY(dynamicTypeRamp, textAttributes.dynamicTypeRamp, RCTDynamicTypeRamp) // TODO(macOS GH#774)
|
|
39
40
|
RCT_REMAP_SHADOW_PROPERTY(maxFontSizeMultiplier, textAttributes.maxFontSizeMultiplier, CGFloat)
|
|
40
41
|
RCT_REMAP_SHADOW_PROPERTY(letterSpacing, textAttributes.letterSpacing, CGFloat)
|
|
41
42
|
RCT_REMAP_SHADOW_PROPERTY(apple_fontSmoothing, textAttributes.fontSmoothing, RCTFontSmoothing) // TODO(OSS Candidate ISS#2710739)
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#import <React/RCTUIKit.h> // TODO(macOS GH#774)
|
|
9
9
|
|
|
10
10
|
#import <React/RCTTextDecorationLineType.h>
|
|
11
|
+
#import <React/RCTDynamicTypeRamp.h> // TODO(macOS GH#774)
|
|
11
12
|
#import <React/RCTFontSmoothing.h> // TODO(OSS Candidate ISS#2710739)
|
|
12
13
|
|
|
13
14
|
#import "RCTTextTransform.h"
|
|
@@ -38,6 +39,7 @@ extern NSString *const RCTTextAttributesTagAttributeName;
|
|
|
38
39
|
@property (nonatomic, copy, nullable) NSString *fontStyle;
|
|
39
40
|
@property (nonatomic, copy, nullable) NSArray<NSString *> *fontVariant;
|
|
40
41
|
@property (nonatomic, assign) BOOL allowFontScaling;
|
|
42
|
+
@property (nonatomic, assign) RCTDynamicTypeRamp dynamicTypeRamp; // TODO(macOS GH#774)
|
|
41
43
|
@property (nonatomic, assign) CGFloat letterSpacing;
|
|
42
44
|
@property (nonatomic, assign) RCTFontSmoothing fontSmoothing; // TODO(OSS Candidate ISS#2710739)
|
|
43
45
|
@property (class, nonatomic, assign) RCTFontSmoothing fontSmoothingDefault; // TODO(OSS Candidate ISS#2710739)
|
|
@@ -70,6 +70,7 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
|
|
|
70
70
|
_fontStyle = textAttributes->_fontStyle ?: _fontStyle;
|
|
71
71
|
_fontVariant = textAttributes->_fontVariant ?: _fontVariant;
|
|
72
72
|
_allowFontScaling = textAttributes->_allowFontScaling || _allowFontScaling; // *
|
|
73
|
+
_dynamicTypeRamp = textAttributes->_dynamicTypeRamp != RCTDynamicTypeRampUndefined ? textAttributes->_dynamicTypeRamp : _dynamicTypeRamp; // TODO(macOS GH#774)
|
|
73
74
|
_letterSpacing = !isnan(textAttributes->_letterSpacing) ? textAttributes->_letterSpacing : _letterSpacing;
|
|
74
75
|
_fontSmoothing = textAttributes->_fontSmoothing != RCTFontSmoothingAuto ? textAttributes->_fontSmoothing : _fontSmoothing; // TODO(OSS Candidate ISS#2710739)
|
|
75
76
|
|
|
@@ -109,27 +110,27 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
|
|
|
109
110
|
alignment = NSTextAlignmentRight;
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
+
|
|
113
114
|
paragraphStyle.alignment = alignment;
|
|
114
115
|
isParagraphStyleUsed = YES;
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
+
|
|
117
118
|
if (_baseWritingDirection != NSWritingDirectionNatural) {
|
|
118
119
|
paragraphStyle.baseWritingDirection = _baseWritingDirection;
|
|
119
120
|
isParagraphStyleUsed = YES;
|
|
120
121
|
}
|
|
121
|
-
|
|
122
|
+
|
|
122
123
|
if (!isnan(_lineHeight)) {
|
|
123
124
|
CGFloat lineHeight = _lineHeight * self.effectiveFontSizeMultiplier;
|
|
124
125
|
paragraphStyle.minimumLineHeight = lineHeight;
|
|
125
126
|
paragraphStyle.maximumLineHeight = lineHeight;
|
|
126
127
|
isParagraphStyleUsed = YES;
|
|
127
128
|
}
|
|
128
|
-
|
|
129
|
+
|
|
129
130
|
if (isParagraphStyleUsed) {
|
|
130
131
|
return [paragraphStyle copy];
|
|
131
132
|
}
|
|
132
|
-
|
|
133
|
+
|
|
133
134
|
return nil;
|
|
134
135
|
}
|
|
135
136
|
|
|
@@ -230,6 +231,13 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
|
|
|
230
231
|
|
|
231
232
|
if (fontScalingEnabled) {
|
|
232
233
|
CGFloat fontSizeMultiplier = !isnan(_fontSizeMultiplier) ? _fontSizeMultiplier : 1.0;
|
|
234
|
+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
235
|
+
if (_dynamicTypeRamp != RCTDynamicTypeRampUndefined) {
|
|
236
|
+
UIFontMetrics *fontMetrics = RCTUIFontMetricsForDynamicTypeRamp(_dynamicTypeRamp);
|
|
237
|
+
CGFloat baseSize = RCTBaseSizeForDynamicTypeRamp(_dynamicTypeRamp);
|
|
238
|
+
fontSizeMultiplier = [fontMetrics scaledValueForValue:baseSize] / baseSize;
|
|
239
|
+
}
|
|
240
|
+
#endif // ]TODO(macOS GH#774)
|
|
233
241
|
CGFloat maxFontSizeMultiplier = !isnan(_maxFontSizeMultiplier) ? _maxFontSizeMultiplier : 0.0;
|
|
234
242
|
return maxFontSizeMultiplier >= 1.0 ? fminf(maxFontSizeMultiplier, fontSizeMultiplier) : fontSizeMultiplier;
|
|
235
243
|
} else {
|
|
@@ -328,6 +336,7 @@ static NSString *capitalizeText(NSString *text)
|
|
|
328
336
|
RCTTextAttributesCompareObjects(_fontStyle) &&
|
|
329
337
|
RCTTextAttributesCompareObjects(_fontVariant) &&
|
|
330
338
|
RCTTextAttributesCompareOthers(_allowFontScaling) &&
|
|
339
|
+
RCTTextAttributesCompareOthers(_dynamicTypeRamp) && // TODO(macOS GH#774)
|
|
331
340
|
RCTTextAttributesCompareFloats(_letterSpacing) &&
|
|
332
341
|
RCTTextAttributesCompareOthers(_fontSmoothing) && // TODO(OSS Candidate ISS#2710739)
|
|
333
342
|
// Paragraph Styles
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// TODO(macOS GH#774)
|
|
9
|
+
|
|
10
|
+
#import <Foundation/Foundation.h>
|
|
11
|
+
|
|
12
|
+
#import <React/RCTConvert.h>
|
|
13
|
+
|
|
14
|
+
typedef NS_ENUM(NSInteger, RCTDynamicTypeRamp) {
|
|
15
|
+
RCTDynamicTypeRampUndefined,
|
|
16
|
+
RCTDynamicTypeRampCaption2,
|
|
17
|
+
RCTDynamicTypeRampCaption1,
|
|
18
|
+
RCTDynamicTypeRampFootnote,
|
|
19
|
+
RCTDynamicTypeRampSubheadline,
|
|
20
|
+
RCTDynamicTypeRampCallout,
|
|
21
|
+
RCTDynamicTypeRampBody,
|
|
22
|
+
RCTDynamicTypeRampHeadline,
|
|
23
|
+
RCTDynamicTypeRampTitle3,
|
|
24
|
+
RCTDynamicTypeRampTitle2,
|
|
25
|
+
RCTDynamicTypeRampTitle1,
|
|
26
|
+
RCTDynamicTypeRampLargeTitle
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
@interface RCTConvert (DynamicTypeRamp)
|
|
30
|
+
|
|
31
|
+
+ (RCTDynamicTypeRamp)RCTDynamicTypeRamp:(nullable id)json;
|
|
32
|
+
|
|
33
|
+
@end
|
|
34
|
+
|
|
35
|
+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
36
|
+
/// Generates a `UIFontMetrics` instance representing a particular Dynamic Type ramp.
|
|
37
|
+
UIFontMetrics * _Nonnull RCTUIFontMetricsForDynamicTypeRamp(RCTDynamicTypeRamp dynamicTypeRamp);
|
|
38
|
+
/// The "reference" size for a particular font scale ramp, equal to a text element's size under default text size settings.
|
|
39
|
+
CGFloat RCTBaseSizeForDynamicTypeRamp(RCTDynamicTypeRamp dynamicTypeRamp);
|
|
40
|
+
#endif // ]TODO(macOS GH#774)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// TODO(macOS GH#774)
|
|
9
|
+
|
|
10
|
+
#import <React/RCTDynamicTypeRamp.h>
|
|
11
|
+
|
|
12
|
+
@implementation RCTConvert (DynamicTypeRamp)
|
|
13
|
+
|
|
14
|
+
RCT_ENUM_CONVERTER(RCTDynamicTypeRamp, (@{
|
|
15
|
+
@"caption2": @(RCTDynamicTypeRampCaption2),
|
|
16
|
+
@"caption1": @(RCTDynamicTypeRampCaption1),
|
|
17
|
+
@"footnote": @(RCTDynamicTypeRampFootnote),
|
|
18
|
+
@"subheadline": @(RCTDynamicTypeRampSubheadline),
|
|
19
|
+
@"callout": @(RCTDynamicTypeRampCallout),
|
|
20
|
+
@"body": @(RCTDynamicTypeRampBody),
|
|
21
|
+
@"headline": @(RCTDynamicTypeRampHeadline),
|
|
22
|
+
@"title3": @(RCTDynamicTypeRampTitle3),
|
|
23
|
+
@"title2": @(RCTDynamicTypeRampTitle2),
|
|
24
|
+
@"title1": @(RCTDynamicTypeRampTitle1),
|
|
25
|
+
@"largeTitle": @(RCTDynamicTypeRampLargeTitle),
|
|
26
|
+
}), RCTDynamicTypeRampUndefined, integerValue)
|
|
27
|
+
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
31
|
+
UIFontMetrics *RCTUIFontMetricsForDynamicTypeRamp(RCTDynamicTypeRamp dynamicTypeRamp) {
|
|
32
|
+
static NSDictionary<NSNumber *, UIFontTextStyle> *mapping;
|
|
33
|
+
static dispatch_once_t onceToken;
|
|
34
|
+
dispatch_once(&onceToken, ^{
|
|
35
|
+
mapping = @{
|
|
36
|
+
@(RCTDynamicTypeRampCaption2): UIFontTextStyleCaption2,
|
|
37
|
+
@(RCTDynamicTypeRampCaption1): UIFontTextStyleCaption1,
|
|
38
|
+
@(RCTDynamicTypeRampFootnote): UIFontTextStyleFootnote,
|
|
39
|
+
@(RCTDynamicTypeRampSubheadline): UIFontTextStyleSubheadline,
|
|
40
|
+
@(RCTDynamicTypeRampCallout): UIFontTextStyleCallout,
|
|
41
|
+
@(RCTDynamicTypeRampBody): UIFontTextStyleBody,
|
|
42
|
+
@(RCTDynamicTypeRampHeadline): UIFontTextStyleHeadline,
|
|
43
|
+
@(RCTDynamicTypeRampTitle3): UIFontTextStyleTitle3,
|
|
44
|
+
@(RCTDynamicTypeRampTitle2): UIFontTextStyleTitle2,
|
|
45
|
+
@(RCTDynamicTypeRampTitle1): UIFontTextStyleTitle1,
|
|
46
|
+
@(RCTDynamicTypeRampLargeTitle): UIFontTextStyleLargeTitle,
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
id textStyle = mapping[@(dynamicTypeRamp)] ?: UIFontTextStyleBody; // Default to body if we don't recognize the specified ramp
|
|
51
|
+
return [UIFontMetrics metricsForTextStyle:textStyle];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
CGFloat RCTBaseSizeForDynamicTypeRamp(RCTDynamicTypeRamp dynamicTypeRamp) {
|
|
55
|
+
static NSDictionary<NSNumber *, NSNumber *> *mapping;
|
|
56
|
+
static dispatch_once_t onceToken;
|
|
57
|
+
dispatch_once(&onceToken, ^{
|
|
58
|
+
// Values taken from https://developer.apple.com/design/human-interface-guidelines/foundations/typography/
|
|
59
|
+
mapping = @{
|
|
60
|
+
@(RCTDynamicTypeRampCaption2): @11,
|
|
61
|
+
@(RCTDynamicTypeRampCaption1): @12,
|
|
62
|
+
@(RCTDynamicTypeRampFootnote): @13,
|
|
63
|
+
@(RCTDynamicTypeRampSubheadline): @15,
|
|
64
|
+
@(RCTDynamicTypeRampCallout): @16,
|
|
65
|
+
@(RCTDynamicTypeRampBody): @17,
|
|
66
|
+
@(RCTDynamicTypeRampHeadline): @17,
|
|
67
|
+
@(RCTDynamicTypeRampTitle3): @20,
|
|
68
|
+
@(RCTDynamicTypeRampTitle2): @22,
|
|
69
|
+
@(RCTDynamicTypeRampTitle1): @28,
|
|
70
|
+
@(RCTDynamicTypeRampLargeTitle): @34,
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
NSNumber *baseSize = mapping[@(dynamicTypeRamp)] ?: @17; // Default to body size if we don't recognize the specified ramp
|
|
75
|
+
return CGFLOAT_IS_DOUBLE ? [baseSize doubleValue] : [baseSize floatValue];
|
|
76
|
+
}
|
|
77
|
+
#endif // ]TODO(macOS GH#774)
|