react-native-macos 0.0.0-8119efe83 → 0.0.0-825d334e8
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 +9 -37
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
- package/Libraries/Components/TextInput/TextInput.js +8 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Lists/FlatList.js +13 -0
- package/Libraries/Lists/VirtualizedList.js +82 -41
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +10 -0
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +16 -2
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +8 -0
- package/Libraries/Text/TextInput/RCTBaseTextInputView.m +8 -2
- package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +3 -2
- package/Libraries/Text/TextInput/Singleline/RCTSinglelineTextInputView.m +4 -0
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.h +2 -0
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +28 -1
- package/React/Base/RCTTouchHandler.m +11 -1
- package/React/Base/RCTUIKit.h +2 -0
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTPlatformDisplayLink.m +3 -1
- package/React/Base/macOS/RCTUIKit.m +13 -0
- package/React/CoreModules/RCTDevLoadingView.mm +1 -1
- package/React/Modules/RCTUIManager.m +6 -0
- package/React/Views/RCTView.m +3 -0
- package/React/Views/ScrollView/RCTScrollView.m +36 -21
- package/React/Views/UIView+React.m +18 -10
- package/ReactAndroid/build.gradle +2 -1
- package/ReactAndroid/gradle.properties +2 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactAndroid/src/main/third-party/android/androidx/BUCK +16 -4
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/hermes/inspector/tools/msggen/package.json +1 -1
- package/ReactCommon/hermes/inspector/tools/msggen/yarn.lock +346 -1294
- package/package.json +5 -3
- package/template/Gemfile.lock +6 -6
- package/template/package.json +1 -1
|
@@ -1054,7 +1054,11 @@ class ScrollView extends React.Component<Props, State> {
|
|
|
1054
1054
|
|},
|
|
1055
1055
|
animated?: boolean, // deprecated, put this inside the rect argument instead
|
|
1056
1056
|
) => {
|
|
1057
|
-
invariant(
|
|
1057
|
+
invariant(
|
|
1058
|
+
// [TODO(macOS GH#774)
|
|
1059
|
+
Platform.OS === 'ios' || Platform.OS === 'macos',
|
|
1060
|
+
'zoomToRect is not implemented',
|
|
1061
|
+
); // TODO [(macOS GH#774)
|
|
1058
1062
|
if ('animated' in rect) {
|
|
1059
1063
|
this._animated = rect.animated;
|
|
1060
1064
|
delete rect.animated;
|
|
@@ -1206,42 +1210,10 @@ class ScrollView extends React.Component<Props, State> {
|
|
|
1206
1210
|
nativeEvent.contentOffset.y +
|
|
1207
1211
|
nativeEvent.layoutMeasurement.height,
|
|
1208
1212
|
});
|
|
1209
|
-
} else if (key === '
|
|
1210
|
-
this.
|
|
1211
|
-
|
|
1212
|
-
|
|
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
|
-
});
|
|
1213
|
+
} else if (key === 'HOME') {
|
|
1214
|
+
this.scrollTo({x: 0, y: 0});
|
|
1215
|
+
} else if (key === 'END') {
|
|
1216
|
+
this.scrollToEnd({animated: true});
|
|
1245
1217
|
}
|
|
1246
1218
|
}
|
|
1247
1219
|
}
|
|
@@ -303,6 +303,14 @@ type IOSProps = $ReadOnly<{|
|
|
|
303
303
|
*/
|
|
304
304
|
scrollEnabled?: ?boolean,
|
|
305
305
|
|
|
306
|
+
// [TODO(macOS GH#774)
|
|
307
|
+
/**
|
|
308
|
+
* If `false`, disables grammar-check.
|
|
309
|
+
* @platform macOS
|
|
310
|
+
*/
|
|
311
|
+
grammarCheck?: ?boolean,
|
|
312
|
+
// ]TODO(macOS GH#774)
|
|
313
|
+
|
|
306
314
|
/**
|
|
307
315
|
* If `false`, disables spell-check style (i.e. red underlines).
|
|
308
316
|
* The default value is inherited from `autoCorrect`.
|
|
@@ -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 macos
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1367
|
+
{...(props.enableSelectionOnKeyPress && {focusable: true})} // [TODO(macOS GH#774)
|
|
1368
|
+
onScrollKeyDown={keyEventHandler}
|
|
1356
1369
|
onPreferredScrollerStyleDidChange={
|
|
1357
|
-
|
|
1358
|
-
|
|
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 = (
|
|
1550
|
+
_handleKeyDown = (event: ScrollEvent) => {
|
|
1532
1551
|
if (this.props.onScrollKeyDown) {
|
|
1533
|
-
this.props.onScrollKeyDown(
|
|
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
|
|
1538
|
-
const 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 === '
|
|
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.
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
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}>
|
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
#else // [TODO(macOS GH#774)
|
|
49
49
|
_scrollView.documentView = _backedTextInputView;
|
|
50
50
|
_scrollView.contentView.postsBoundsChangedNotifications = YES;
|
|
51
|
+
// Enable focus ring by default
|
|
52
|
+
_scrollView.enableFocusRing = YES;
|
|
51
53
|
[self addSubview:_scrollView];
|
|
52
54
|
|
|
53
55
|
// a register for those notifications on the content view.
|
|
@@ -89,6 +91,14 @@
|
|
|
89
91
|
_scrollView.frame = UIEdgeInsetsInsetRect(self.bounds, reactBorderInsets);
|
|
90
92
|
[self setNeedsLayout];
|
|
91
93
|
}
|
|
94
|
+
|
|
95
|
+
- (void)setEnableFocusRing:(BOOL)enableFocusRing {
|
|
96
|
+
[super setEnableFocusRing:enableFocusRing];
|
|
97
|
+
if ([_scrollView respondsToSelector:@selector(setEnableFocusRing:)]) {
|
|
98
|
+
[_scrollView setEnableFocusRing:enableFocusRing];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
92
102
|
#endif // ]TODO(macOS GH#774)
|
|
93
103
|
|
|
94
104
|
#pragma mark - UIScrollViewDelegate
|
|
@@ -46,11 +46,10 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
|
|
|
46
46
|
_placeholderView.numberOfLines = 0;
|
|
47
47
|
[self addSubview:_placeholderView];
|
|
48
48
|
#else // [TODO(macOS GH#774)
|
|
49
|
-
NSTextCheckingTypes checkingTypes = 0;
|
|
50
|
-
self.enabledTextCheckingTypes = checkingTypes;
|
|
51
49
|
self.insertionPointColor = [NSColor selectedControlColor];
|
|
52
50
|
// Fix blurry text on non-retina displays.
|
|
53
51
|
self.canDrawSubviewsIntoLayer = YES;
|
|
52
|
+
self.allowsUndo = YES;
|
|
54
53
|
#endif // ]TODO(macOS GH#774)
|
|
55
54
|
|
|
56
55
|
_textInputDelegateAdapter = [[RCTBackedTextViewDelegateAdapter alloc] initWithTextView:self];
|
|
@@ -185,6 +184,18 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
|
|
|
185
184
|
|
|
186
185
|
return success;
|
|
187
186
|
}
|
|
187
|
+
|
|
188
|
+
- (BOOL)resignFirstResponder
|
|
189
|
+
{
|
|
190
|
+
BOOL success = [super resignFirstResponder];
|
|
191
|
+
|
|
192
|
+
if (success) {
|
|
193
|
+
// Break undo coalescing when losing focus.
|
|
194
|
+
[self breakUndoCoalescing];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return success;
|
|
198
|
+
}
|
|
188
199
|
#endif // ]TODO(macOS GH#774)
|
|
189
200
|
|
|
190
201
|
- (void)setDefaultTextAttributes:(NSDictionary<NSAttributedStringKey, id> *)defaultTextAttributes
|
|
@@ -247,6 +258,9 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
|
|
|
247
258
|
}
|
|
248
259
|
#else // [TODO(macOS GH#774)
|
|
249
260
|
if (![self.textStorage isEqualTo:attributedText.string]) {
|
|
261
|
+
// Break undo coalescing when the text is changed by JS (e.g. autocomplete).
|
|
262
|
+
[self breakUndoCoalescing];
|
|
263
|
+
|
|
250
264
|
if (attributedText != nil) {
|
|
251
265
|
[self.textStorage setAttributedString:attributedText];
|
|
252
266
|
} else {
|
|
@@ -263,6 +263,7 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
|
|
|
263
263
|
UITextRange *_previousSelectedTextRange;
|
|
264
264
|
#else // [TODO(macOS GH#774)
|
|
265
265
|
NSRange _previousSelectedTextRange;
|
|
266
|
+
NSUndoManager *_undoManager;
|
|
266
267
|
#endif // ]TODO(macOS GH#774)
|
|
267
268
|
}
|
|
268
269
|
|
|
@@ -428,6 +429,13 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
|
|
|
428
429
|
return commandHandled;
|
|
429
430
|
}
|
|
430
431
|
|
|
432
|
+
- (NSUndoManager *)undoManagerForTextView:(NSTextView *)textView {
|
|
433
|
+
if (!_undoManager) {
|
|
434
|
+
_undoManager = [NSUndoManager new];
|
|
435
|
+
}
|
|
436
|
+
return _undoManager;
|
|
437
|
+
}
|
|
438
|
+
|
|
431
439
|
#endif // ]TODO(macOS GH#774)
|
|
432
440
|
|
|
433
441
|
#pragma mark - Public Interface
|
|
@@ -144,7 +144,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
144
144
|
BOOL textNeedsUpdate = NO;
|
|
145
145
|
// Remove tag attribute to ensure correct attributed string comparison.
|
|
146
146
|
NSMutableAttributedString *const backedTextInputViewTextCopy = [self.backedTextInputView.attributedText mutableCopy];
|
|
147
|
-
NSMutableAttributedString *const attributedTextCopy = [attributedText mutableCopy];
|
|
147
|
+
NSMutableAttributedString *const attributedTextCopy = [attributedText mutableCopy] ?: [NSMutableAttributedString new];
|
|
148
148
|
|
|
149
149
|
[backedTextInputViewTextCopy removeAttribute:RCTTextAttributesTagAttributeName
|
|
150
150
|
range:NSMakeRange(0, backedTextInputViewTextCopy.length)];
|
|
@@ -160,7 +160,13 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
160
160
|
#else // [TODO(macOS GH#774)
|
|
161
161
|
NSRange selection = [self.backedTextInputView selectedTextRange];
|
|
162
162
|
#endif // ]TODO(macOS GH#774)
|
|
163
|
-
|
|
163
|
+
NSAttributedString *oldAttributedText = [self.backedTextInputView.attributedText copy];
|
|
164
|
+
NSInteger oldTextLength = oldAttributedText.string.length;
|
|
165
|
+
|
|
166
|
+
[self.backedTextInputView.undoManager registerUndoWithTarget:self handler:^(RCTBaseTextInputView *strongSelf) {
|
|
167
|
+
strongSelf.attributedText = oldAttributedText;
|
|
168
|
+
[strongSelf textInputDidChange];
|
|
169
|
+
}];
|
|
164
170
|
|
|
165
171
|
self.backedTextInputView.attributedText = attributedText;
|
|
166
172
|
|
|
@@ -38,7 +38,7 @@ RCT_EXPORT_MODULE()
|
|
|
38
38
|
|
|
39
39
|
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(autoCapitalize, backedTextInputView.autocapitalizationType, UITextAutocapitalizationType) // TODO(macOS GH#774)
|
|
40
40
|
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType) // TODO(macOS GH#774)
|
|
41
|
-
RCT_REMAP_OSX_VIEW_PROPERTY(autoCorrect, backedTextInputView.
|
|
41
|
+
RCT_REMAP_OSX_VIEW_PROPERTY(autoCorrect, backedTextInputView.automaticSpellingCorrectionEnabled, BOOL) // TODO(macOS GH#774)
|
|
42
42
|
RCT_REMAP_VIEW_PROPERTY(contextMenuHidden, backedTextInputView.contextMenuHidden, BOOL)
|
|
43
43
|
RCT_REMAP_VIEW_PROPERTY(editable, backedTextInputView.editable, BOOL)
|
|
44
44
|
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(enablesReturnKeyAutomatically, backedTextInputView.enablesReturnKeyAutomatically, BOOL) // TODO(macOS GH#774)
|
|
@@ -48,8 +48,9 @@ RCT_REMAP_VIEW_PROPERTY(placeholderTextColor, backedTextInputView.placeholderCol
|
|
|
48
48
|
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(returnKeyType, backedTextInputView.returnKeyType, UIReturnKeyType) // TODO(macOS GH#774)
|
|
49
49
|
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(selectionColor, backedTextInputView.tintColor, UIColor) // TODO(macOS GH#774)
|
|
50
50
|
RCT_REMAP_OSX_VIEW_PROPERTY(selectionColor, backedTextInputView.selectionColor, UIColor) // TODO(macOS GH#774)
|
|
51
|
+
RCT_REMAP_OSX_VIEW_PROPERTY(grammarCheck, backedTextInputView.grammarCheckingEnabled, BOOL) // TODO(macOS GH#774)
|
|
51
52
|
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(spellCheck, backedTextInputView.spellCheckingType, UITextSpellCheckingType) // TODO(macOS GH#774)
|
|
52
|
-
RCT_REMAP_OSX_VIEW_PROPERTY(spellCheck, backedTextInputView.
|
|
53
|
+
RCT_REMAP_OSX_VIEW_PROPERTY(spellCheck, backedTextInputView.continuousSpellCheckingEnabled, BOOL) // TODO(macOS GH#774)
|
|
53
54
|
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(caretHidden, backedTextInputView.caretHidden, BOOL) // TODO(macOS GH#774)
|
|
54
55
|
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(clearButtonMode, backedTextInputView.clearButtonMode, UITextFieldViewMode) // TODO(macOS GH#774)
|
|
55
56
|
RCT_REMAP_VIEW_PROPERTY(scrollEnabled, backedTextInputView.scrollEnabled, BOOL)
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
|
|
29
29
|
_backedTextInputView = [[RCTUITextField alloc] initWithFrame:self.bounds];
|
|
30
30
|
_backedTextInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
31
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
32
|
+
_backedTextInputView.cell.scrollable = YES;
|
|
33
|
+
_backedTextInputView.cell.usesSingleLineMode = YES;
|
|
34
|
+
#endif // ]TODO(macOS GH#774)
|
|
31
35
|
_backedTextInputView.textInputDelegate = self;
|
|
32
36
|
|
|
33
37
|
[self addSubview:_backedTextInputView];
|
|
@@ -54,6 +54,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
54
54
|
@property (nonatomic, assign) NSTextAlignment textAlignment;
|
|
55
55
|
@property (nonatomic, getter=isAutomaticTextReplacementEnabled) BOOL automaticTextReplacementEnabled;
|
|
56
56
|
@property (nonatomic, getter=isAutomaticSpellingCorrectionEnabled) BOOL automaticSpellingCorrectionEnabled;
|
|
57
|
+
@property (nonatomic, getter=isContinuousSpellCheckingEnabled) BOOL continuousSpellCheckingEnabled;
|
|
58
|
+
@property (nonatomic, getter=isGrammarCheckingEnabled) BOOL grammarCheckingEnabled;
|
|
57
59
|
@property (nonatomic, assign) BOOL enableFocusRing;
|
|
58
60
|
@property (nonatomic, strong, nullable) RCTUIColor *selectionColor;
|
|
59
61
|
@property (weak, nullable) id<RCTUITextFieldDelegate> delegate;
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
@property (nonatomic, assign) UIEdgeInsets textContainerInset;
|
|
27
27
|
@property (nonatomic, getter=isAutomaticTextReplacementEnabled) BOOL automaticTextReplacementEnabled;
|
|
28
28
|
@property (nonatomic, getter=isAutomaticSpellingCorrectionEnabled) BOOL automaticSpellingCorrectionEnabled;
|
|
29
|
+
@property (nonatomic, getter=isContinuousSpellCheckingEnabled) BOOL continuousSpellCheckingEnabled;
|
|
30
|
+
@property (nonatomic, getter=isGrammarCheckingEnabled) BOOL grammarCheckingEnabled;
|
|
29
31
|
@property (nonatomic, strong, nullable) RCTUIColor *selectionColor;
|
|
30
32
|
|
|
31
33
|
@end
|
|
@@ -70,6 +72,8 @@
|
|
|
70
72
|
NSTextView *fieldEditor = (NSTextView *)[super setUpFieldEditorAttributes:textObj];
|
|
71
73
|
fieldEditor.automaticSpellingCorrectionEnabled = self.isAutomaticSpellingCorrectionEnabled;
|
|
72
74
|
fieldEditor.automaticTextReplacementEnabled = self.isAutomaticTextReplacementEnabled;
|
|
75
|
+
fieldEditor.continuousSpellCheckingEnabled = self.isContinuousSpellCheckingEnabled;
|
|
76
|
+
fieldEditor.grammarCheckingEnabled = self.isGrammarCheckingEnabled;
|
|
73
77
|
NSMutableDictionary *selectTextAttributes = fieldEditor.selectedTextAttributes.mutableCopy;
|
|
74
78
|
selectTextAttributes[NSBackgroundColorAttributeName] = self.selectionColor ?: [NSColor selectedControlColor];
|
|
75
79
|
fieldEditor.selectedTextAttributes = selectTextAttributes;
|
|
@@ -105,7 +109,6 @@
|
|
|
105
109
|
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
106
110
|
[self setBordered:NO];
|
|
107
111
|
[self setAllowsEditingTextAttributes:YES];
|
|
108
|
-
[self setAccessibilityRole:NSAccessibilityTextFieldRole];
|
|
109
112
|
[self setBackgroundColor:[NSColor clearColor]];
|
|
110
113
|
#endif // ]TODO(macOS GH#774)
|
|
111
114
|
|
|
@@ -127,7 +130,11 @@
|
|
|
127
130
|
|
|
128
131
|
#pragma mark - Accessibility
|
|
129
132
|
|
|
133
|
+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
130
134
|
- (void)setIsAccessibilityElement:(BOOL)isAccessibilityElement
|
|
135
|
+
#else
|
|
136
|
+
- (void)setAccessibilityElement:(BOOL)isAccessibilityElement
|
|
137
|
+
#endif // ]TODO(macOS GH#774)
|
|
131
138
|
{
|
|
132
139
|
// UITextField is accessible by default (some nested views are) and disabling that is not supported.
|
|
133
140
|
// On iOS accessible elements cannot be nested, therefore enabling accessibility for some container view
|
|
@@ -193,6 +200,26 @@
|
|
|
193
200
|
return ((RCTUITextFieldCell*)self.cell).isAutomaticSpellingCorrectionEnabled;
|
|
194
201
|
}
|
|
195
202
|
|
|
203
|
+
- (void)setContinuousSpellCheckingEnabled:(BOOL)continuousSpellCheckingEnabled
|
|
204
|
+
{
|
|
205
|
+
((RCTUITextFieldCell*)self.cell).continuousSpellCheckingEnabled = continuousSpellCheckingEnabled;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
- (BOOL)isContinuousSpellCheckingEnabled
|
|
209
|
+
{
|
|
210
|
+
return ((RCTUITextFieldCell*)self.cell).isContinuousSpellCheckingEnabled;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
- (void)setGrammarCheckingEnabled:(BOOL)grammarCheckingEnabled
|
|
214
|
+
{
|
|
215
|
+
((RCTUITextFieldCell*)self.cell).grammarCheckingEnabled = grammarCheckingEnabled;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
- (BOOL)isGrammarCheckingEnabled
|
|
219
|
+
{
|
|
220
|
+
return ((RCTUITextFieldCell*)self.cell).isGrammarCheckingEnabled;
|
|
221
|
+
}
|
|
222
|
+
|
|
196
223
|
- (void)setSelectionColor:(RCTUIColor *)selectionColor // TODO(OSS Candidate ISS#2710739)
|
|
197
224
|
{
|
|
198
225
|
((RCTUITextFieldCell*)self.cell).selectionColor = selectionColor;
|
|
@@ -129,6 +129,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)coder)
|
|
|
129
129
|
// The assumption here is that a RCTUIView/RCTSurfaceView will always have a superview.
|
|
130
130
|
CGPoint touchLocation = [self.view.superview convertPoint:touch.locationInWindow fromView:nil];
|
|
131
131
|
NSView *targetView = [self.view hitTest:touchLocation];
|
|
132
|
+
// Don't record clicks on scrollbars.
|
|
133
|
+
if ([targetView isKindOfClass:[NSScroller class]]) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
132
136
|
// Pair the mouse down events with mouse up events so our _nativeTouches cache doesn't get stale
|
|
133
137
|
if ([targetView isKindOfClass:[NSControl class]]) {
|
|
134
138
|
_shouldSendMouseUpOnSystemBehalf = [(NSControl*)targetView isEnabled];
|
|
@@ -221,7 +225,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)coder)
|
|
|
221
225
|
NSEvent *nativeTouch = _nativeTouches[touchIndex];
|
|
222
226
|
CGPoint location = nativeTouch.locationInWindow;
|
|
223
227
|
CGPoint rootViewLocation = CGPointMake(location.x, CGRectGetHeight(self.view.window.frame) - location.y);
|
|
224
|
-
|
|
228
|
+
NSView *touchView = _touchViews[touchIndex];
|
|
229
|
+
CGPoint touchViewLocation = [touchView convertPoint:location fromView:nil];
|
|
225
230
|
#endif // ]TODO(macOS GH#774)
|
|
226
231
|
|
|
227
232
|
NSMutableDictionary *reactTouch = _reactTouches[touchIndex];
|
|
@@ -394,6 +399,11 @@ static BOOL RCTAnyTouchesChanged(NSSet *touches) // [TODO(macOS GH#774)
|
|
|
394
399
|
// "end"/"cancel" needs to remove the touch *after* extracting the event.
|
|
395
400
|
[self _recordNewTouches:touches];
|
|
396
401
|
|
|
402
|
+
// [TODO(macOS GH#774) - Filter out touches that were ignored.
|
|
403
|
+
touches = [touches objectsPassingTest:^(id touch, BOOL *stop) {
|
|
404
|
+
return [_nativeTouches containsObject:touch];
|
|
405
|
+
}]; // ]TODO(macOS GH#774)
|
|
406
|
+
|
|
397
407
|
[self _updateAndDispatchTouches:touches eventName:@"touchStart"];
|
|
398
408
|
|
|
399
409
|
if (self.state == UIGestureRecognizerStatePossible) {
|
package/React/Base/RCTUIKit.h
CHANGED
|
@@ -425,6 +425,8 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
|
|
|
425
425
|
@property (nonatomic, assign) CGFloat zoomScale;
|
|
426
426
|
@property (nonatomic, assign) BOOL alwaysBounceHorizontal;
|
|
427
427
|
@property (nonatomic, assign) BOOL alwaysBounceVertical;
|
|
428
|
+
// macOS specific properties
|
|
429
|
+
@property (nonatomic, assign) BOOL enableFocusRing;
|
|
428
430
|
|
|
429
431
|
@end
|
|
430
432
|
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -51,7 +51,9 @@ static CVReturn RCTPlatformDisplayLinkCallBack(__unused CVDisplayLinkRef display
|
|
|
51
51
|
if (rctDisplayLink->_runLoop != nil) {
|
|
52
52
|
CFRunLoopRef cfRunLoop = [rctDisplayLink->_runLoop getCFRunLoop];
|
|
53
53
|
CFRunLoopPerformBlock(cfRunLoop, (__bridge CFArrayRef)rctDisplayLink->_modes, ^{
|
|
54
|
-
|
|
54
|
+
@autoreleasepool {
|
|
55
|
+
[rctDisplayLink tick];
|
|
56
|
+
}
|
|
55
57
|
});
|
|
56
58
|
CFRunLoopWakeUp(cfRunLoop);
|
|
57
59
|
}
|
|
@@ -429,6 +429,19 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
429
429
|
|
|
430
430
|
@implementation RCTUIScrollView // TODO(macOS ISS#3536887)
|
|
431
431
|
|
|
432
|
+
- (void)setEnableFocusRing:(BOOL)enableFocusRing {
|
|
433
|
+
if (_enableFocusRing != enableFocusRing) {
|
|
434
|
+
_enableFocusRing = enableFocusRing;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (enableFocusRing) {
|
|
438
|
+
// NSTextView has no focus ring by default so let's use the standard Aqua focus ring.
|
|
439
|
+
[self setFocusRingType:NSFocusRingTypeExterior];
|
|
440
|
+
} else {
|
|
441
|
+
[self setFocusRingType:NSFocusRingTypeNone];
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
432
445
|
// UIScrollView properties missing from NSScrollView
|
|
433
446
|
- (CGPoint)contentOffset
|
|
434
447
|
{
|
|
@@ -226,7 +226,7 @@ RCT_EXPORT_METHOD(hide)
|
|
|
226
226
|
[NSAnimationContext runAnimationGroup:^(__unused NSAnimationContext *context) {
|
|
227
227
|
self->_window.animator.alphaValue = 0.0;
|
|
228
228
|
} completionHandler:^{
|
|
229
|
-
[self->_window
|
|
229
|
+
[self->_window close];
|
|
230
230
|
self->_window = nil;
|
|
231
231
|
}];
|
|
232
232
|
});
|