react-native-macos 0.81.5 → 0.81.7
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/Pressable/Pressable.js +8 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +16 -0
- package/Libraries/Components/TextInput/TextInput.js +26 -9
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
- package/Libraries/Components/View/View.js +30 -10
- package/Libraries/Components/View/ViewPropTypes.js +2 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +8 -0
- package/Libraries/Pressability/Pressability.js +38 -4
- package/Libraries/Text/RCTTextAttributes.mm +1 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +1 -1
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm +1 -1
- package/Libraries/Text/TextInput/RCTBaseTextInputView.mm +6 -3
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.h +0 -4
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.mm +3 -20
- package/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.h +5 -3
- package/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.mm +83 -0
- package/Libraries/Utilities/normalizeLegacyHandledKeyEvents.js +164 -0
- package/React/Base/RCTVersion.m +1 -1
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +31 -1
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +38 -2
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +61 -2
- package/React/Fabric/RCTSurfacePointerHandler.mm +6 -2
- package/React/Views/RCTView.h +1 -0
- package/React/Views/RCTViewManager.m +1 -0
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +1 -1
- package/ReactCommon/react/renderer/components/switch/iosswitch/react/renderer/components/switch/IOSSwitchShadowNode.mm +5 -0
- package/ReactCommon/react/renderer/components/switch/iosswitch/react/renderer/components/switch/MacOSSwitchShadowNode.mm +5 -0
- package/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp +4 -0
- package/ReactCommon/react/renderer/components/view/TouchEventEmitter.h +1 -0
- package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEventEmitter.cpp +16 -0
- package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEventEmitter.h +2 -0
- package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEvents.h +6 -0
- package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewProps.cpp +2 -0
- package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/MouseEvent.h +8 -0
- package/ReactCommon/react/renderer/components/view/primitives.h +2 -0
- package/ReactCommon/react/renderer/components/view/propsConversions.h +4 -0
- package/ReactCommon/react/renderer/graphics/Color.h +1 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h +2 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +11 -0
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm +13 -2
- package/package.json +26 -5
- package/react-native.config.js +0 -5
- package/sdks/hermes-engine/utils/build-apple-framework.sh +2 -1
- package/sdks/hermes-engine/utils/build-ios-framework.sh +8 -3
- package/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.m +0 -14
|
@@ -381,7 +381,14 @@ function Pressable({
|
|
|
381
381
|
// [macOS
|
|
382
382
|
acceptsFirstMouse: acceptsFirstMouse !== false && !disabled,
|
|
383
383
|
enableFocusRing: enableFocusRing !== false && !disabled,
|
|
384
|
-
keyDownEvents:
|
|
384
|
+
keyDownEvents:
|
|
385
|
+
keyDownEvents ??
|
|
386
|
+
// $FlowFixMe[unclear-type] Legacy props not in type definitions
|
|
387
|
+
(((props: any).validKeysDown: mixed) == null &&
|
|
388
|
+
// $FlowFixMe[unclear-type]
|
|
389
|
+
((props: any).passthroughAllKeyEvents: mixed) !== true
|
|
390
|
+
? [{key: ' '}, {key: 'Enter'}]
|
|
391
|
+
: undefined),
|
|
385
392
|
mouseDownCanMoveWindow: false,
|
|
386
393
|
// macOS]
|
|
387
394
|
};
|
|
@@ -52,6 +52,18 @@ const RCTTextInputViewConfig: PartialViewConfigWithoutName = {
|
|
|
52
52
|
captured: 'onSubmitEditingCapture',
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
|
+
topKeyDown: {
|
|
56
|
+
phasedRegistrationNames: {
|
|
57
|
+
bubbled: 'onKeyDown',
|
|
58
|
+
captured: 'onKeyDownCapture',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
topKeyUp: {
|
|
62
|
+
phasedRegistrationNames: {
|
|
63
|
+
bubbled: 'onKeyUp',
|
|
64
|
+
captured: 'onKeyUpCapture',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
55
67
|
topTouchCancel: {
|
|
56
68
|
phasedRegistrationNames: {
|
|
57
69
|
bubbled: 'onTouchCancel',
|
|
@@ -173,6 +185,8 @@ const RCTTextInputViewConfig: PartialViewConfigWithoutName = {
|
|
|
173
185
|
clearTextOnSubmit: true,
|
|
174
186
|
grammarCheck: true,
|
|
175
187
|
hideVerticalScrollIndicator: true,
|
|
188
|
+
keyDownEvents: true,
|
|
189
|
+
keyUpEvents: true,
|
|
176
190
|
pastedTypes: true,
|
|
177
191
|
submitKeyEvents: true,
|
|
178
192
|
tooltip: true,
|
|
@@ -191,6 +205,8 @@ const RCTTextInputViewConfig: PartialViewConfigWithoutName = {
|
|
|
191
205
|
onAutoCorrectChange: true,
|
|
192
206
|
onSpellCheckChange: true,
|
|
193
207
|
onGrammarCheckChange: true,
|
|
208
|
+
onKeyDown: true,
|
|
209
|
+
onKeyUp: true,
|
|
194
210
|
// macOS]
|
|
195
211
|
}),
|
|
196
212
|
disableKeyboardShortcuts: true,
|
|
@@ -60,7 +60,13 @@ import flattenStyle from '../../StyleSheet/flattenStyle';
|
|
|
60
60
|
import StyleSheet, {type TextStyleProp} from '../../StyleSheet/StyleSheet';
|
|
61
61
|
import Text from '../../Text/Text';
|
|
62
62
|
import TextAncestorContext from '../../Text/TextAncestorContext';
|
|
63
|
+
// [macOS
|
|
64
|
+
import processLegacyKeyProps, {
|
|
65
|
+
hasLegacyKeyProps,
|
|
66
|
+
stripLegacyKeyProps,
|
|
67
|
+
} from '../../Utilities/normalizeLegacyHandledKeyEvents';
|
|
63
68
|
import Platform from '../../Utilities/Platform';
|
|
69
|
+
// macOS]
|
|
64
70
|
import useMergeRefs from '../../Utilities/useMergeRefs';
|
|
65
71
|
import TextInputState from './TextInputState';
|
|
66
72
|
import invariant from 'invariant';
|
|
@@ -386,6 +392,11 @@ function useTextInputStateSynchronization({
|
|
|
386
392
|
*
|
|
387
393
|
*/
|
|
388
394
|
function InternalTextInput(props: TextInputProps): React.Node {
|
|
395
|
+
// [macOS
|
|
396
|
+
const legacyKeyOverrides = hasLegacyKeyProps(props)
|
|
397
|
+
? processLegacyKeyProps(props)
|
|
398
|
+
: null;
|
|
399
|
+
// macOS]
|
|
389
400
|
const {
|
|
390
401
|
'aria-busy': ariaBusy,
|
|
391
402
|
'aria-checked': ariaChecked,
|
|
@@ -400,7 +411,9 @@ function InternalTextInput(props: TextInputProps): React.Node {
|
|
|
400
411
|
selectionHandleColor,
|
|
401
412
|
cursorColor,
|
|
402
413
|
...otherProps
|
|
403
|
-
|
|
414
|
+
// $FlowFixMe[unclear-type]
|
|
415
|
+
} = ({...props, ...legacyKeyOverrides}: any); // [macOS]
|
|
416
|
+
stripLegacyKeyProps(otherProps); // [macOS]
|
|
404
417
|
|
|
405
418
|
const inputRef = useRef<null | TextInputInstance>(null);
|
|
406
419
|
|
|
@@ -581,10 +594,15 @@ function InternalTextInput(props: TextInputProps): React.Node {
|
|
|
581
594
|
};
|
|
582
595
|
|
|
583
596
|
// [macOS
|
|
597
|
+
const _keyDownEvents =
|
|
598
|
+
legacyKeyOverrides?.keyDownEvents ?? props.keyDownEvents;
|
|
599
|
+
const _keyUpEvents = legacyKeyOverrides?.keyUpEvents ?? props.keyUpEvents;
|
|
600
|
+
const _origOnKeyDown = legacyKeyOverrides?.onKeyDown ?? props.onKeyDown;
|
|
601
|
+
const _origOnKeyUp = legacyKeyOverrides?.onKeyUp ?? props.onKeyUp;
|
|
602
|
+
|
|
584
603
|
const _onKeyDown = (event: KeyEvent) => {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
const isHandled = keyDownEvents.some(
|
|
604
|
+
if (_keyDownEvents != null && !event.isPropagationStopped()) {
|
|
605
|
+
const isHandled = _keyDownEvents.some(
|
|
588
606
|
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) => {
|
|
589
607
|
return (
|
|
590
608
|
event.nativeEvent.key === key &&
|
|
@@ -599,13 +617,12 @@ function InternalTextInput(props: TextInputProps): React.Node {
|
|
|
599
617
|
event.stopPropagation();
|
|
600
618
|
}
|
|
601
619
|
}
|
|
602
|
-
|
|
620
|
+
_origOnKeyDown?.(event);
|
|
603
621
|
};
|
|
604
622
|
|
|
605
623
|
const _onKeyUp = (event: KeyEvent) => {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
const isHandled = keyUpEvents.some(
|
|
624
|
+
if (_keyUpEvents != null && !event.isPropagationStopped()) {
|
|
625
|
+
const isHandled = _keyUpEvents.some(
|
|
609
626
|
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) => {
|
|
610
627
|
return (
|
|
611
628
|
event.nativeEvent.key === key &&
|
|
@@ -620,7 +637,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
|
|
|
620
637
|
event.stopPropagation();
|
|
621
638
|
}
|
|
622
639
|
}
|
|
623
|
-
|
|
640
|
+
_origOnKeyUp?.(event);
|
|
624
641
|
};
|
|
625
642
|
// macOS]
|
|
626
643
|
|
|
@@ -13,6 +13,12 @@ import type {ViewProps} from './ViewPropTypes';
|
|
|
13
13
|
|
|
14
14
|
import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
|
|
15
15
|
import TextAncestorContext from '../../Text/TextAncestorContext';
|
|
16
|
+
// [macOS
|
|
17
|
+
import processLegacyKeyProps, {
|
|
18
|
+
hasLegacyKeyProps,
|
|
19
|
+
stripLegacyKeyProps,
|
|
20
|
+
} from '../../Utilities/normalizeLegacyHandledKeyEvents';
|
|
21
|
+
// macOS]
|
|
16
22
|
import ViewNativeComponent from './ViewNativeComponent';
|
|
17
23
|
import * as React from 'react';
|
|
18
24
|
import {use} from 'react';
|
|
@@ -30,13 +36,24 @@ component View(
|
|
|
30
36
|
) {
|
|
31
37
|
const hasTextAncestor = use(TextAncestorContext);
|
|
32
38
|
|
|
39
|
+
// [macOS
|
|
40
|
+
const legacyKeyOverrides = hasLegacyKeyProps(props)
|
|
41
|
+
? processLegacyKeyProps(props)
|
|
42
|
+
: null;
|
|
43
|
+
// macOS]
|
|
44
|
+
|
|
33
45
|
let actualView;
|
|
34
46
|
|
|
35
47
|
// [macOS
|
|
48
|
+
const _keyDownEvents =
|
|
49
|
+
legacyKeyOverrides?.keyDownEvents ?? props.keyDownEvents;
|
|
50
|
+
const _keyUpEvents = legacyKeyOverrides?.keyUpEvents ?? props.keyUpEvents;
|
|
51
|
+
const _origOnKeyDown = legacyKeyOverrides?.onKeyDown ?? props.onKeyDown;
|
|
52
|
+
const _origOnKeyUp = legacyKeyOverrides?.onKeyUp ?? props.onKeyUp;
|
|
53
|
+
|
|
36
54
|
const _onKeyDown = (event: KeyEvent) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const isHandled = keyDownEvents.some(
|
|
55
|
+
if (_keyDownEvents != null && !event.isPropagationStopped()) {
|
|
56
|
+
const isHandled = _keyDownEvents.some(
|
|
40
57
|
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) => {
|
|
41
58
|
return (
|
|
42
59
|
event.nativeEvent.key === key &&
|
|
@@ -51,13 +68,12 @@ component View(
|
|
|
51
68
|
event.stopPropagation();
|
|
52
69
|
}
|
|
53
70
|
}
|
|
54
|
-
|
|
71
|
+
_origOnKeyDown?.(event);
|
|
55
72
|
};
|
|
56
73
|
|
|
57
74
|
const _onKeyUp = (event: KeyEvent) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const isHandled = keyUpEvents.some(
|
|
75
|
+
if (_keyUpEvents != null && !event.isPropagationStopped()) {
|
|
76
|
+
const isHandled = _keyUpEvents.some(
|
|
61
77
|
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) => {
|
|
62
78
|
return (
|
|
63
79
|
event.nativeEvent.key === key &&
|
|
@@ -72,7 +88,7 @@ component View(
|
|
|
72
88
|
event.stopPropagation();
|
|
73
89
|
}
|
|
74
90
|
}
|
|
75
|
-
|
|
91
|
+
_origOnKeyUp?.(event);
|
|
76
92
|
};
|
|
77
93
|
// macOS]
|
|
78
94
|
|
|
@@ -96,10 +112,12 @@ component View(
|
|
|
96
112
|
id,
|
|
97
113
|
tabIndex,
|
|
98
114
|
...otherProps
|
|
99
|
-
|
|
115
|
+
// $FlowFixMe[unclear-type]
|
|
116
|
+
} = ({...props, ...legacyKeyOverrides}: any); // [macOS]
|
|
100
117
|
|
|
101
118
|
// Since we destructured props, we can now treat it as mutable
|
|
102
119
|
const processedProps = otherProps as {...ViewProps};
|
|
120
|
+
stripLegacyKeyProps(processedProps); // [macOS]
|
|
103
121
|
|
|
104
122
|
const parsedAriaLabelledBy = ariaLabelledBy?.split(/\s*,\s*/g);
|
|
105
123
|
if (parsedAriaLabelledBy !== undefined) {
|
|
@@ -195,7 +213,9 @@ component View(
|
|
|
195
213
|
nativeID,
|
|
196
214
|
tabIndex,
|
|
197
215
|
...otherProps
|
|
198
|
-
|
|
216
|
+
// $FlowFixMe[unclear-type]
|
|
217
|
+
} = ({...props, ...legacyKeyOverrides}: any); // [macOS]
|
|
218
|
+
stripLegacyKeyProps(otherProps); // [macOS]
|
|
199
219
|
const _accessibilityLabelledBy =
|
|
200
220
|
ariaLabelledBy?.split(/\s*,\s*/g) ?? accessibilityLabelledBy;
|
|
201
221
|
|
|
@@ -135,6 +135,8 @@ type MouseEventProps = $ReadOnly<{
|
|
|
135
135
|
|
|
136
136
|
// Experimental/Work in Progress Pointer Event Callbacks (not yet ready for use)
|
|
137
137
|
type PointerEventProps = $ReadOnly<{
|
|
138
|
+
onAuxClick?: ?(event: PointerEvent) => void,
|
|
139
|
+
onAuxClickCapture?: ?(event: PointerEvent) => void,
|
|
138
140
|
onClick?: ?(event: PointerEvent) => void,
|
|
139
141
|
onClickCapture?: ?(event: PointerEvent) => void,
|
|
140
142
|
onPointerEnter?: ?(event: PointerEvent) => void,
|
|
@@ -89,6 +89,12 @@ const bubblingEventTypes = {
|
|
|
89
89
|
},
|
|
90
90
|
|
|
91
91
|
// Experimental/Work in Progress Pointer Events (not yet ready for use)
|
|
92
|
+
topAuxClick: {
|
|
93
|
+
phasedRegistrationNames: {
|
|
94
|
+
captured: 'onAuxClickCapture',
|
|
95
|
+
bubbled: 'onAuxClick',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
92
98
|
topClick: {
|
|
93
99
|
phasedRegistrationNames: {
|
|
94
100
|
captured: 'onClickCapture',
|
|
@@ -394,6 +400,8 @@ const validAttributesForEventProps = ConditionallyIgnoredEventHandlers({
|
|
|
394
400
|
onTouchCancel: true,
|
|
395
401
|
|
|
396
402
|
// Pointer events
|
|
403
|
+
onAuxClick: true,
|
|
404
|
+
onAuxClickCapture: true,
|
|
397
405
|
onClick: true,
|
|
398
406
|
onClickCapture: true,
|
|
399
407
|
onPointerUp: true,
|
|
@@ -410,6 +410,16 @@ export default class Pressability {
|
|
|
410
410
|
_touchActivateTime: ?number;
|
|
411
411
|
_touchState: TouchState = 'NOT_RESPONDER';
|
|
412
412
|
|
|
413
|
+
// [macOS
|
|
414
|
+
/**
|
|
415
|
+
* Returns true if the button from a press event is the default (primary/left)
|
|
416
|
+
* button. A button value of 0 or undefined is considered the default button.
|
|
417
|
+
*/
|
|
418
|
+
_isDefaultPressButton(button: ?number): boolean {
|
|
419
|
+
return !button;
|
|
420
|
+
}
|
|
421
|
+
// macOS]
|
|
422
|
+
|
|
413
423
|
constructor(config: PressabilityConfig) {
|
|
414
424
|
this.configure(config);
|
|
415
425
|
}
|
|
@@ -554,6 +564,13 @@ export default class Pressability {
|
|
|
554
564
|
return;
|
|
555
565
|
}
|
|
556
566
|
|
|
567
|
+
// [macOS Only fire onPress for primary (left) mouse button clicks.
|
|
568
|
+
// Non-primary buttons (right, middle) should not trigger onPress.
|
|
569
|
+
if (!this._isDefaultPressButton(event?.nativeEvent?.button)) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
// macOS]
|
|
573
|
+
|
|
557
574
|
// for non-pointer click events (e.g. accessibility clicks), we should only dispatch when we're the "real" target
|
|
558
575
|
// in particular, we shouldn't respond to clicks from nested pressables
|
|
559
576
|
if (event?.currentTarget !== event?.target) {
|
|
@@ -791,7 +808,12 @@ export default class Pressability {
|
|
|
791
808
|
|
|
792
809
|
if (isPressInSignal(prevState) && signal === 'LONG_PRESS_DETECTED') {
|
|
793
810
|
const {onLongPress} = this._config;
|
|
794
|
-
if (
|
|
811
|
+
if (
|
|
812
|
+
onLongPress != null &&
|
|
813
|
+
this._isDefaultPressButton(
|
|
814
|
+
getTouchFromPressEvent(event).button,
|
|
815
|
+
) /* [macOS] */
|
|
816
|
+
) {
|
|
795
817
|
onLongPress(event);
|
|
796
818
|
}
|
|
797
819
|
}
|
|
@@ -799,7 +821,14 @@ export default class Pressability {
|
|
|
799
821
|
const isPrevActive = isActiveSignal(prevState);
|
|
800
822
|
const isNextActive = isActiveSignal(nextState);
|
|
801
823
|
|
|
802
|
-
|
|
824
|
+
// [macOS Don't activate press visual feedback for non-primary mouse buttons
|
|
825
|
+
// (e.g. right-click, middle-click). They should fire onAuxClick, not onPress.
|
|
826
|
+
const isPrimaryButton = this._isDefaultPressButton(
|
|
827
|
+
getTouchFromPressEvent(event).button,
|
|
828
|
+
);
|
|
829
|
+
// macOS]
|
|
830
|
+
|
|
831
|
+
if (!isPrevActive && isNextActive && isPrimaryButton /* [macOS] */) {
|
|
803
832
|
this._activate(event);
|
|
804
833
|
} else if (isPrevActive && !isNextActive) {
|
|
805
834
|
this._deactivate(event);
|
|
@@ -807,12 +836,17 @@ export default class Pressability {
|
|
|
807
836
|
|
|
808
837
|
if (isPressInSignal(prevState) && signal === 'RESPONDER_RELEASE') {
|
|
809
838
|
// If we never activated (due to delays), activate and deactivate now.
|
|
810
|
-
if (!isNextActive && !isPrevActive) {
|
|
839
|
+
if (!isNextActive && !isPrevActive && isPrimaryButton /* [macOS] */) {
|
|
811
840
|
this._activate(event);
|
|
812
841
|
this._deactivate(event);
|
|
813
842
|
}
|
|
814
843
|
const {onLongPress, onPress, android_disableSound} = this._config;
|
|
815
|
-
if (
|
|
844
|
+
if (
|
|
845
|
+
onPress != null &&
|
|
846
|
+
this._isDefaultPressButton(
|
|
847
|
+
getTouchFromPressEvent(event).button,
|
|
848
|
+
) /* [macOS] */
|
|
849
|
+
) {
|
|
816
850
|
const isPressCanceledByLongPress =
|
|
817
851
|
onLongPress != null && prevState === 'RESPONDER_ACTIVE_LONG_PRESS_IN';
|
|
818
852
|
if (!isPressCanceledByLongPress) {
|
|
@@ -277,7 +277,7 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
|
|
|
277
277
|
|
|
278
278
|
- (RCTUIColor *)effectiveForegroundColor // [macOS]
|
|
279
279
|
{
|
|
280
|
-
RCTUIColor *effectiveForegroundColor = _foregroundColor ?: [
|
|
280
|
+
RCTUIColor *effectiveForegroundColor = _foregroundColor ?: [RCTTextAttributes defaultForegroundColor]; // [macOS]
|
|
281
281
|
|
|
282
282
|
if (!isnan(_opacity)) {
|
|
283
283
|
effectiveForegroundColor =
|
|
@@ -69,7 +69,7 @@ static RCTUIColor *defaultPlaceholderColor(void) // [macOS]
|
|
|
69
69
|
_textInputDelegateAdapter = [[RCTBackedTextViewDelegateAdapter alloc] initWithTextView:self];
|
|
70
70
|
|
|
71
71
|
self.backgroundColor = [RCTUIColor clearColor]; // [macOS]
|
|
72
|
-
self.textColor = [RCTUIColor
|
|
72
|
+
self.textColor = [RCTUIColor labelColor]; // [macOS]
|
|
73
73
|
// This line actually removes 5pt (default value) left and right padding in UITextView.
|
|
74
74
|
#if !TARGET_OS_OSX // [macOS]
|
|
75
75
|
self.textContainer.lineFragmentPadding = 0;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
#import <React/RCTBackedTextInputDelegateAdapter.h>
|
|
9
9
|
#import "RCTBackedTextInputViewProtocol.h" // [macOS
|
|
10
10
|
#import "RCTBackedTextInputDelegate.h"
|
|
11
|
-
#import
|
|
11
|
+
#import <React/RCTTextUIKit.h> // macOS]
|
|
12
12
|
|
|
13
13
|
#pragma mark - RCTBackedTextFieldDelegateAdapter (for UITextField)
|
|
14
14
|
|
|
@@ -21,8 +21,11 @@
|
|
|
21
21
|
#import <React/RCTTextAttributes.h>
|
|
22
22
|
#import <React/RCTTextSelection.h>
|
|
23
23
|
#import <React/RCTUITextView.h> // [macOS]
|
|
24
|
-
#import
|
|
24
|
+
#import <React/RCTTextUIKit.h> // [macOS]
|
|
25
25
|
#import <React/RCTHandledKey.h> // [macOS]
|
|
26
|
+
#if TARGET_OS_OSX // [macOS
|
|
27
|
+
#import <React/RCTUISecureTextField.h>
|
|
28
|
+
#endif // macOS]
|
|
26
29
|
|
|
27
30
|
/** Native iOS text field bottom keyboard offset amount */
|
|
28
31
|
static const CGFloat kSingleLineKeyboardBottomOffset = 15.0;
|
|
@@ -127,7 +130,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
127
130
|
|
|
128
131
|
NSDictionary<NSAttributedStringKey, id> *textAttributes = [[_textAttributes effectiveTextAttributes] mutableCopy];
|
|
129
132
|
if ([textAttributes valueForKey:NSForegroundColorAttributeName] == nil) {
|
|
130
|
-
[textAttributes setValue:[RCTUIColor
|
|
133
|
+
[textAttributes setValue:[RCTUIColor labelColor] forKey:NSForegroundColorAttributeName]; // [macOS]
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
backedTextInputView.defaultTextAttributes = textAttributes;
|
|
@@ -194,7 +197,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
194
197
|
BOOL shouldFallbackToBareTextComparison =
|
|
195
198
|
// There are multiple Korean input sources (2-Set, 3-Set, etc). Check substring instead instead
|
|
196
199
|
[[[self.backedTextInputView inputContext] selectedKeyboardInputSource] containsString:@"com.apple.inputmethod.Korean"] ||
|
|
197
|
-
[self.backedTextInputView hasMarkedText] || [self.backedTextInputView isKindOfClass:[
|
|
200
|
+
[self.backedTextInputView hasMarkedText] || [self.backedTextInputView isKindOfClass:[RCTUISecureTextField class]] ||
|
|
198
201
|
#endif // macOS]
|
|
199
202
|
fontHasBeenUpdatedBySystem;
|
|
200
203
|
|
|
@@ -20,11 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
20
20
|
#if !TARGET_OS_OSX // [macOS]
|
|
21
21
|
@interface RCTUITextField : UITextField <RCTBackedTextInputViewProtocol>
|
|
22
22
|
#else // [macOS
|
|
23
|
-
#if RCT_SUBCLASS_SECURETEXTFIELD
|
|
24
|
-
@interface RCTUISecureTextField : NSSecureTextField <RCTBackedTextInputViewProtocol>
|
|
25
|
-
#else
|
|
26
23
|
@interface RCTUITextField : NSTextField <RCTBackedTextInputViewProtocol>
|
|
27
|
-
#endif // RCT_SUBCLASS_SECURETEXTFIELD
|
|
28
24
|
#endif // macOS]
|
|
29
25
|
|
|
30
26
|
|
|
@@ -17,12 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
#if TARGET_OS_OSX // [macOS
|
|
19
19
|
|
|
20
|
-
#if RCT_SUBCLASS_SECURETEXTFIELD
|
|
21
|
-
#define RCTUITextFieldCell RCTUISecureTextFieldCell
|
|
22
|
-
@interface RCTUISecureTextFieldCell : NSSecureTextFieldCell
|
|
23
|
-
#else
|
|
24
20
|
@interface RCTUITextFieldCell : NSTextFieldCell
|
|
25
|
-
#endif
|
|
26
21
|
|
|
27
22
|
@property (nonatomic, assign) UIEdgeInsets textContainerInset;
|
|
28
23
|
@property (nonatomic, getter=isAutomaticTextReplacementEnabled) BOOL automaticTextReplacementEnabled;
|
|
@@ -36,11 +31,6 @@
|
|
|
36
31
|
|
|
37
32
|
@implementation RCTUITextFieldCell
|
|
38
33
|
|
|
39
|
-
- (void)setTextContainerInset:(UIEdgeInsets)textContainerInset
|
|
40
|
-
{
|
|
41
|
-
_textContainerInset = textContainerInset;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
34
|
- (NSRect)titleRectForBounds:(NSRect)rect
|
|
45
35
|
{
|
|
46
36
|
return UIEdgeInsetsInsetRect([super titleRectForBounds:rect], self.textContainerInset);
|
|
@@ -58,12 +48,9 @@
|
|
|
58
48
|
|
|
59
49
|
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
|
|
60
50
|
{
|
|
61
|
-
if (self.drawsBackground) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
[self.backgroundColor set];
|
|
65
|
-
NSRectFill(cellFrame);
|
|
66
|
-
}
|
|
51
|
+
if (self.drawsBackground && self.backgroundColor && self.backgroundColor.alphaComponent > 0) {
|
|
52
|
+
[self.backgroundColor set];
|
|
53
|
+
NSRectFill(cellFrame);
|
|
67
54
|
}
|
|
68
55
|
|
|
69
56
|
[super drawInteriorWithFrame:[self titleRectForBounds:cellFrame] inView:controlView];
|
|
@@ -86,11 +73,7 @@
|
|
|
86
73
|
@end
|
|
87
74
|
#endif // macOS]
|
|
88
75
|
|
|
89
|
-
#ifdef RCT_SUBCLASS_SECURETEXTFIELD
|
|
90
|
-
@implementation RCTUISecureTextField {
|
|
91
|
-
#else
|
|
92
76
|
@implementation RCTUITextField {
|
|
93
|
-
#endif
|
|
94
77
|
RCTBackedTextFieldDelegateAdapter *_textInputDelegateAdapter;
|
|
95
78
|
NSDictionary<NSAttributedStringKey, id> *_defaultTextAttributes;
|
|
96
79
|
#if !TARGET_OS_OSX // [macOS]
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its 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
|
+
// [macOS]
|
|
9
|
+
|
|
10
|
+
#if TARGET_OS_OSX
|
|
11
|
+
|
|
12
|
+
#import <React/RCTUISecureTextField.h>
|
|
13
|
+
#import <React/RCTUIKit.h>
|
|
14
|
+
|
|
15
|
+
#pragma mark - RCTUISecureTextFieldCell
|
|
16
|
+
|
|
17
|
+
@interface RCTUISecureTextFieldCell : NSSecureTextFieldCell
|
|
18
|
+
|
|
19
|
+
@property (nonatomic, assign) UIEdgeInsets textContainerInset;
|
|
20
|
+
@property (nonatomic, getter=isAutomaticTextReplacementEnabled) BOOL automaticTextReplacementEnabled;
|
|
21
|
+
@property (nonatomic, getter=isAutomaticSpellingCorrectionEnabled) BOOL automaticSpellingCorrectionEnabled;
|
|
22
|
+
@property (nonatomic, getter=isContinuousSpellCheckingEnabled) BOOL continuousSpellCheckingEnabled;
|
|
23
|
+
@property (nonatomic, getter=isGrammarCheckingEnabled) BOOL grammarCheckingEnabled;
|
|
24
|
+
@property (nonatomic, strong, nullable) RCTPlatformColor *selectionColor;
|
|
25
|
+
@property (nonatomic, strong, nullable) RCTPlatformColor *insertionPointColor;
|
|
26
|
+
|
|
27
|
+
@end
|
|
28
|
+
|
|
29
|
+
@implementation RCTUISecureTextFieldCell
|
|
30
|
+
|
|
31
|
+
- (NSRect)titleRectForBounds:(NSRect)rect
|
|
32
|
+
{
|
|
33
|
+
return UIEdgeInsetsInsetRect([super titleRectForBounds:rect], self.textContainerInset);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (void)editWithFrame:(NSRect)rect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)delegate event:(NSEvent *)event
|
|
37
|
+
{
|
|
38
|
+
[super editWithFrame:[self titleRectForBounds:rect] inView:controlView editor:textObj delegate:delegate event:event];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
- (void)selectWithFrame:(NSRect)rect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)delegate start:(NSInteger)selStart length:(NSInteger)selLength
|
|
42
|
+
{
|
|
43
|
+
[super selectWithFrame:[self titleRectForBounds:rect] inView:controlView editor:textObj delegate:delegate start:selStart length:selLength];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
|
|
47
|
+
{
|
|
48
|
+
if (self.drawsBackground && self.backgroundColor && self.backgroundColor.alphaComponent > 0) {
|
|
49
|
+
[self.backgroundColor set];
|
|
50
|
+
NSRectFill(cellFrame);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[super drawInteriorWithFrame:[self titleRectForBounds:cellFrame] inView:controlView];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
- (NSText *)setUpFieldEditorAttributes:(NSText *)textObj
|
|
57
|
+
{
|
|
58
|
+
NSTextView *fieldEditor = (NSTextView *)[super setUpFieldEditorAttributes:textObj];
|
|
59
|
+
fieldEditor.automaticSpellingCorrectionEnabled = self.isAutomaticSpellingCorrectionEnabled;
|
|
60
|
+
fieldEditor.automaticTextReplacementEnabled = self.isAutomaticTextReplacementEnabled;
|
|
61
|
+
fieldEditor.continuousSpellCheckingEnabled = self.isContinuousSpellCheckingEnabled;
|
|
62
|
+
fieldEditor.grammarCheckingEnabled = self.isGrammarCheckingEnabled;
|
|
63
|
+
NSMutableDictionary *selectTextAttributes = fieldEditor.selectedTextAttributes.mutableCopy;
|
|
64
|
+
selectTextAttributes[NSBackgroundColorAttributeName] = self.selectionColor ?: [NSColor selectedControlColor];
|
|
65
|
+
fieldEditor.selectedTextAttributes = selectTextAttributes;
|
|
66
|
+
fieldEditor.insertionPointColor = self.insertionPointColor ?: [NSColor textColor];
|
|
67
|
+
return fieldEditor;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@end
|
|
71
|
+
|
|
72
|
+
#pragma mark - RCTUISecureTextField
|
|
73
|
+
|
|
74
|
+
@implementation RCTUISecureTextField
|
|
75
|
+
|
|
76
|
+
+ (Class)cellClass
|
|
77
|
+
{
|
|
78
|
+
return RCTUISecureTextFieldCell.class;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@end
|
|
82
|
+
|
|
83
|
+
#endif // TARGET_OS_OSX
|