react-native-macos 0.81.5 → 0.81.6
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/View.js +30 -10
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Text/RCTTextAttributes.mm +1 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +1 -1
- package/Libraries/Text/TextInput/RCTBaseTextInputView.mm +1 -1
- package/Libraries/Utilities/normalizeLegacyHandledKeyEvents.js +164 -0
- package/React/Base/RCTVersion.m +1 -1
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +24 -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/graphics/Color.h +1 -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 +1 -1
- package/package.json +2 -2
|
@@ -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
|
|
|
@@ -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;
|
|
@@ -127,7 +127,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
127
127
|
|
|
128
128
|
NSDictionary<NSAttributedStringKey, id> *textAttributes = [[_textAttributes effectiveTextAttributes] mutableCopy];
|
|
129
129
|
if ([textAttributes valueForKey:NSForegroundColorAttributeName] == nil) {
|
|
130
|
-
[textAttributes setValue:[RCTUIColor
|
|
130
|
+
[textAttributes setValue:[RCTUIColor labelColor] forKey:NSForegroundColorAttributeName]; // [macOS]
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
backedTextInputView.defaultTextAttributes = textAttributes;
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// [macOS]
|
|
12
|
+
// Legacy validKeysDown/validKeysUp/passthroughAllKeyEvents compat layer.
|
|
13
|
+
// When removing legacy support, delete this file and its call sites.
|
|
14
|
+
|
|
15
|
+
import type {HandledKeyEvent, KeyEvent} from '../Types/CoreEventTypes';
|
|
16
|
+
|
|
17
|
+
type LegacyHandledKeyEvent = string | HandledKeyEvent;
|
|
18
|
+
|
|
19
|
+
function expandKey(entry: LegacyHandledKeyEvent): Array<HandledKeyEvent> {
|
|
20
|
+
if (typeof entry !== 'string') {
|
|
21
|
+
return [entry];
|
|
22
|
+
}
|
|
23
|
+
const out: Array<HandledKeyEvent> = [];
|
|
24
|
+
const bools: Array<boolean> = [false, true];
|
|
25
|
+
for (const metaKey of bools) {
|
|
26
|
+
for (const ctrlKey of bools) {
|
|
27
|
+
for (const altKey of bools) {
|
|
28
|
+
for (const shiftKey of bools) {
|
|
29
|
+
out.push({altKey, ctrlKey, key: entry, metaKey, shiftKey});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function normalize(
|
|
38
|
+
legacy: ?$ReadOnlyArray<LegacyHandledKeyEvent>,
|
|
39
|
+
): void | Array<HandledKeyEvent> {
|
|
40
|
+
if (legacy == null) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const result: Array<HandledKeyEvent> = [];
|
|
44
|
+
for (const entry of legacy) {
|
|
45
|
+
result.push(...expandKey(entry));
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function matchesEvent(
|
|
51
|
+
events: $ReadOnlyArray<HandledKeyEvent>,
|
|
52
|
+
event: KeyEvent,
|
|
53
|
+
): boolean {
|
|
54
|
+
return events.some(
|
|
55
|
+
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) =>
|
|
56
|
+
event.nativeEvent.key === key &&
|
|
57
|
+
Boolean(metaKey) === event.nativeEvent.metaKey &&
|
|
58
|
+
Boolean(ctrlKey) === event.nativeEvent.ctrlKey &&
|
|
59
|
+
Boolean(altKey) === event.nativeEvent.altKey &&
|
|
60
|
+
Boolean(shiftKey) === event.nativeEvent.shiftKey,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type LegacyKeyResult = {
|
|
65
|
+
keyDownEvents: void | Array<HandledKeyEvent>,
|
|
66
|
+
keyUpEvents: void | Array<HandledKeyEvent>,
|
|
67
|
+
onKeyDown: void | ((event: KeyEvent) => void),
|
|
68
|
+
onKeyUp: void | ((event: KeyEvent) => void),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Returns true if the props contain legacy key props that need processing.
|
|
73
|
+
*/
|
|
74
|
+
export function hasLegacyKeyProps(props: mixed): boolean {
|
|
75
|
+
// $FlowFixMe[unclear-type]
|
|
76
|
+
const p = (props: any);
|
|
77
|
+
return (
|
|
78
|
+
p.validKeysDown != null ||
|
|
79
|
+
p.validKeysUp != null ||
|
|
80
|
+
p.passthroughAllKeyEvents != null
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Strips legacy props from a props object (mutates).
|
|
86
|
+
*/
|
|
87
|
+
export function stripLegacyKeyProps(props: {+[string]: mixed}): void {
|
|
88
|
+
// $FlowFixMe[unclear-type]
|
|
89
|
+
const p = (props: any);
|
|
90
|
+
delete p.validKeysDown;
|
|
91
|
+
delete p.validKeysUp;
|
|
92
|
+
delete p.passthroughAllKeyEvents;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Processes legacy validKeysDown/validKeysUp/passthroughAllKeyEvents props
|
|
97
|
+
* and returns the equivalent modern keyDownEvents/keyUpEvents and wrapped
|
|
98
|
+
* onKeyDown/onKeyUp handlers.
|
|
99
|
+
*
|
|
100
|
+
* Usage in component:
|
|
101
|
+
* if (hasLegacyKeyProps(props)) {
|
|
102
|
+
* const legacy = processLegacyKeyProps(props);
|
|
103
|
+
* // use legacy.keyDownEvents, legacy.onKeyDown, etc.
|
|
104
|
+
* }
|
|
105
|
+
*/
|
|
106
|
+
export default function processLegacyKeyProps(
|
|
107
|
+
// $FlowFixMe[unclear-type]
|
|
108
|
+
props: any,
|
|
109
|
+
): LegacyKeyResult {
|
|
110
|
+
const validKeysDown: ?$ReadOnlyArray<LegacyHandledKeyEvent> =
|
|
111
|
+
props.validKeysDown;
|
|
112
|
+
const validKeysUp: ?$ReadOnlyArray<LegacyHandledKeyEvent> = props.validKeysUp;
|
|
113
|
+
const passthroughAllKeyEvents: ?boolean = props.passthroughAllKeyEvents;
|
|
114
|
+
|
|
115
|
+
const hasModernKeyDown = props.keyDownEvents != null;
|
|
116
|
+
const hasModernKeyUp = props.keyUpEvents != null;
|
|
117
|
+
const legacyPassthrough =
|
|
118
|
+
passthroughAllKeyEvents === true && !hasModernKeyDown;
|
|
119
|
+
|
|
120
|
+
const gateKeyDown =
|
|
121
|
+
!hasModernKeyDown && validKeysDown != null && !legacyPassthrough;
|
|
122
|
+
const gateKeyUp =
|
|
123
|
+
!hasModernKeyUp && validKeysUp != null && !legacyPassthrough;
|
|
124
|
+
|
|
125
|
+
const normalizedDown = props.keyDownEvents ?? normalize(validKeysDown);
|
|
126
|
+
const normalizedUp = props.keyUpEvents ?? normalize(validKeysUp);
|
|
127
|
+
|
|
128
|
+
const keyDownEvents = legacyPassthrough ? undefined : normalizedDown;
|
|
129
|
+
const keyUpEvents = legacyPassthrough ? undefined : normalizedUp;
|
|
130
|
+
|
|
131
|
+
const onKeyDown =
|
|
132
|
+
props.onKeyDown != null
|
|
133
|
+
? (event: KeyEvent) => {
|
|
134
|
+
let isHandled = false;
|
|
135
|
+
if (normalizedDown != null && !event.isPropagationStopped()) {
|
|
136
|
+
isHandled = matchesEvent(normalizedDown, event);
|
|
137
|
+
if (isHandled && hasModernKeyDown) {
|
|
138
|
+
event.stopPropagation();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!gateKeyDown || isHandled) {
|
|
142
|
+
props.onKeyDown?.(event);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
: undefined;
|
|
146
|
+
|
|
147
|
+
const onKeyUp =
|
|
148
|
+
props.onKeyUp != null
|
|
149
|
+
? (event: KeyEvent) => {
|
|
150
|
+
let isHandled = false;
|
|
151
|
+
if (normalizedUp != null && !event.isPropagationStopped()) {
|
|
152
|
+
isHandled = matchesEvent(normalizedUp, event);
|
|
153
|
+
if (isHandled && hasModernKeyUp) {
|
|
154
|
+
event.stopPropagation();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!gateKeyUp || isHandled) {
|
|
158
|
+
props.onKeyUp?.(event);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
: undefined;
|
|
162
|
+
|
|
163
|
+
return {keyDownEvents, keyUpEvents, onKeyDown, onKeyUp};
|
|
164
|
+
}
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -184,6 +184,30 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(RCTUIScrollView *scrollView, NS
|
|
|
184
184
|
#endif // [macOS]
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
#if TARGET_OS_OSX // [macOS
|
|
188
|
+
- (void)layoutSubviews
|
|
189
|
+
{
|
|
190
|
+
[super layoutSubviews];
|
|
191
|
+
|
|
192
|
+
// On macOS, the _containerView is the NSScrollView's documentView and has autoresizingMask set so
|
|
193
|
+
// it fills the visible area before React's first layout pass. However, AppKit's autoresizing can
|
|
194
|
+
// corrupt the documentView's frame by adding the NSClipView's size delta to the container's
|
|
195
|
+
// dimensions (e.g., during initial tile or window resize), inflating it well beyond the correct
|
|
196
|
+
// content size. This produces massive horizontal and vertical overflow on first render.
|
|
197
|
+
//
|
|
198
|
+
// After React has set the content size via updateState:, we reset the documentView frame here to
|
|
199
|
+
// undo any autoresizing corruption. This runs after AppKit's layout (which triggers autoresizing),
|
|
200
|
+
// so it reliably corrects the frame.
|
|
201
|
+
if (!CGSizeEqualToSize(_contentSize, CGSizeZero)) {
|
|
202
|
+
CGRect containerFrame = _containerView.frame;
|
|
203
|
+
if (!CGSizeEqualToSize(containerFrame.size, _contentSize)) {
|
|
204
|
+
containerFrame.size = _contentSize;
|
|
205
|
+
_containerView.frame = containerFrame;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
#endif // macOS]
|
|
210
|
+
|
|
187
211
|
#if TARGET_OS_IOS
|
|
188
212
|
- (void)_registerKeyboardListener
|
|
189
213
|
{
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
|
|
15
15
|
#define REACT_NATIVE_VERSION_MAJOR 0
|
|
16
16
|
#define REACT_NATIVE_VERSION_MINOR 81
|
|
17
|
-
#define REACT_NATIVE_VERSION_PATCH
|
|
17
|
+
#define REACT_NATIVE_VERSION_PATCH 6
|
|
18
18
|
|
|
19
19
|
namespace facebook::react {
|
|
20
20
|
|
|
21
21
|
constexpr struct {
|
|
22
22
|
int32_t Major = 0;
|
|
23
23
|
int32_t Minor = 81;
|
|
24
|
-
int32_t Patch =
|
|
24
|
+
int32_t Patch = 6;
|
|
25
25
|
std::string_view Prerelease = "";
|
|
26
26
|
} ReactNativeVersion;
|
|
27
27
|
|
|
@@ -178,7 +178,7 @@ TextAttributes TextAttributes::defaultTextAttributes() {
|
|
|
178
178
|
static auto textAttributes = [] {
|
|
179
179
|
auto textAttributes = TextAttributes{};
|
|
180
180
|
// Non-obvious (can be different among platforms) default text attributes.
|
|
181
|
-
textAttributes.foregroundColor =
|
|
181
|
+
textAttributes.foregroundColor = defaultForegroundTextColor(); // [macOS]
|
|
182
182
|
textAttributes.backgroundColor = clearColor();
|
|
183
183
|
textAttributes.fontSize = 14.0;
|
|
184
184
|
textAttributes.fontSizeMultiplier = 1.0;
|
|
@@ -70,6 +70,7 @@ SharedColor colorFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
|
|
70
70
|
SharedColor clearColor();
|
|
71
71
|
SharedColor blackColor();
|
|
72
72
|
SharedColor whiteColor();
|
|
73
|
+
SharedColor defaultForegroundTextColor(); // [macOS]
|
|
73
74
|
|
|
74
75
|
#ifdef RN_SERIALIZABLE_STATE
|
|
75
76
|
inline folly::dynamic toDynamic(const SharedColor& sharedColor) {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#import <Foundation/Foundation.h>
|
|
11
11
|
#import <React/RCTUIKit.h> // [macOS]
|
|
12
12
|
#import <objc/runtime.h>
|
|
13
|
+
#import <react/renderer/graphics/Color.h> // [macOS]
|
|
13
14
|
#import <react/renderer/graphics/RCTPlatformColorUtils.h>
|
|
14
15
|
#import <react/utils/ManagedObjectWrapper.h>
|
|
15
16
|
#import <string>
|
|
@@ -342,6 +343,16 @@ Color Color::createSemanticColor(std::vector<std::string> &semanticItems)
|
|
|
342
343
|
return Color(wrapManagedObject(semanticColor));
|
|
343
344
|
}
|
|
344
345
|
|
|
346
|
+
// [macOS
|
|
347
|
+
SharedColor defaultForegroundTextColor() {
|
|
348
|
+
static SharedColor color = [] {
|
|
349
|
+
std::vector<std::string> items = {"labelColor"};
|
|
350
|
+
return SharedColor(Color::createSemanticColor(items));
|
|
351
|
+
}();
|
|
352
|
+
return color;
|
|
353
|
+
}
|
|
354
|
+
// macOS]
|
|
355
|
+
|
|
345
356
|
} // namespace facebook::react
|
|
346
357
|
|
|
347
358
|
NS_ASSUME_NONNULL_END
|
|
@@ -144,7 +144,7 @@ inline static UIFont *RCTEffectiveFontFromTextAttributes(const TextAttributes &t
|
|
|
144
144
|
|
|
145
145
|
inline static RCTUIColor *RCTEffectiveForegroundColorFromTextAttributes(const TextAttributes &textAttributes) // [macOS]
|
|
146
146
|
{
|
|
147
|
-
RCTUIColor *effectiveForegroundColor = RCTUIColorFromSharedColor(textAttributes.foregroundColor)
|
|
147
|
+
RCTUIColor *effectiveForegroundColor = RCTUIColorFromSharedColor(textAttributes.foregroundColor) ?: [RCTUIColor labelColor]; // [macOS]
|
|
148
148
|
|
|
149
149
|
if (!isnan(textAttributes.opacity)) {
|
|
150
150
|
effectiveForegroundColor = [effectiveForegroundColor
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-macos",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.6",
|
|
4
4
|
"description": "React Native for macOS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
},
|
|
167
167
|
"dependencies": {
|
|
168
168
|
"@jest/create-cache-key-function": "^29.7.0",
|
|
169
|
-
"@react-native-macos/virtualized-lists": "0.81.
|
|
169
|
+
"@react-native-macos/virtualized-lists": "0.81.6",
|
|
170
170
|
"@react-native/assets-registry": "0.81.6",
|
|
171
171
|
"@react-native/codegen": "0.81.6",
|
|
172
172
|
"@react-native/community-cli-plugin": "0.81.6",
|