Skip to content

Commit 3f65678

Browse files
committed
Claude fixes flow errors (review)
1 parent eb861d7 commit 3f65678

File tree

21 files changed

+141
-86
lines changed

21 files changed

+141
-86
lines changed

packages/react-native/Libraries/Alert/Alert.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class Alert {
222222
);
223223
// [macOS
224224
} else if (Platform.OS === 'macos') {
225-
const defaultInputs = [{default: defaultValue}];
225+
const defaultInputs: DefaultInputsArray = [{default: defaultValue}];
226226
Alert.promptMacOS(title, message, callbackOrButtons, type, defaultInputs);
227227
}
228228
// macOS]
@@ -300,7 +300,7 @@ class Alert {
300300
});
301301
}
302302

303-
RCTAlertManager.alertWithArgs(
303+
alertWithArgs(
304304
{
305305
title: title || undefined,
306306
message: message || undefined,

packages/react-native/Libraries/Components/Button.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import type {
1919
import type {
2020
AccessibilityActionEvent,
2121
AccessibilityActionInfo,
22+
AccessibilityRole,
2223
AccessibilityState,
23-
} from './View/ViewAccessibility';
24-
import type {AccessibilityRole} from './View/ViewAccessibility'; // [macOS]
24+
} from './View/ViewAccessibility'; // [macOS]
2525

2626
import StyleSheet, {type ColorValue} from '../StyleSheet/StyleSheet';
2727
import Text from '../Text/Text';

packages/react-native/Libraries/Components/TextInput/TextInput.flow.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import type {
1414
BlurEvent,
1515
FocusEvent,
1616
GestureResponderEvent,
17+
HandledKeyEvent, // [macOS]
18+
KeyEvent, // [macOS]
1719
NativeSyntheticEvent,
1820
ScrollEvent,
1921
} from '../../Types/CoreEventTypes';

packages/react-native/Libraries/Components/View/View.js

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
import type {ViewProps} from './ViewPropTypes';
12-
import type {KeyEvent, HandledKeyEvent} from 'react-native'; // [macOS]
12+
import type {KeyEvent, HandledKeyEvent} from '../../Types/CoreEventTypes'; // [macOS]
1313

1414
import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
1515
import TextAncestorContext from '../../Text/TextAncestorContext';
@@ -198,6 +198,50 @@ export default component View(
198198
const _accessibilityLabelledBy =
199199
ariaLabelledBy?.split(/\s*,\s*/g) ?? accessibilityLabelledBy;
200200

201+
// [macOS
202+
const _onKeyDown = (event: KeyEvent) => {
203+
const keyDownEvents = otherProps.keyDownEvents;
204+
if (keyDownEvents != null && !event.isPropagationStopped()) {
205+
const isHandled = keyDownEvents.some(
206+
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) => {
207+
return (
208+
event.nativeEvent.key === key &&
209+
Boolean(metaKey) === event.nativeEvent.metaKey &&
210+
Boolean(ctrlKey) === event.nativeEvent.ctrlKey &&
211+
Boolean(altKey) === event.nativeEvent.altKey &&
212+
Boolean(shiftKey) === event.nativeEvent.shiftKey
213+
);
214+
},
215+
);
216+
if (isHandled === true) {
217+
event.stopPropagation();
218+
}
219+
}
220+
otherProps.onKeyDown?.(event);
221+
};
222+
223+
const _onKeyUp = (event: KeyEvent) => {
224+
const keyUpEvents = otherProps.keyUpEvents;
225+
if (keyUpEvents != null && !event.isPropagationStopped()) {
226+
const isHandled = keyUpEvents.some(
227+
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) => {
228+
return (
229+
event.nativeEvent.key === key &&
230+
Boolean(metaKey) === event.nativeEvent.metaKey &&
231+
Boolean(ctrlKey) === event.nativeEvent.ctrlKey &&
232+
Boolean(altKey) === event.nativeEvent.altKey &&
233+
Boolean(shiftKey) === event.nativeEvent.shiftKey
234+
);
235+
},
236+
);
237+
if (isHandled === true) {
238+
event.stopPropagation();
239+
}
240+
}
241+
otherProps.onKeyUp?.(event);
242+
};
243+
// macOS]
244+
201245
const _accessibilityState =
202246
accessibilityState != null ||
203247
ariaBusy != null ||

packages/react-native/Libraries/Components/View/ViewAccessibility.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export type AccessibilityRole =
5454
| 'drawerlayout'
5555
| 'slidingdrawer'
5656
| 'iconmenu'
57-
| 'menubutton'; // [macOS]
57+
| 'menubutton' // [macOS]
5858
| string;
5959

6060
// Role types for web

packages/react-native/Libraries/Components/View/ViewPropTypes.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ import type {
2424
LayoutRectangle,
2525
MouseEvent,
2626
PointerEvent,
27-
GestureResponderEvent,
28-
ScrollEvent, // [macOS]
27+
ScrollEvent, // macOS]
2928
} from '../../Types/CoreEventTypes';
3029
import type {DraggedTypesType} from '../View/DraggedType'; // [macOS]
3130
import type {

packages/react-native/Libraries/Image/Image.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ let BaseImage: AbstractImageIOS = ({
175175
return (
176176
<ImageViewNativeComponent
177177
accessibilityState={_accessibilityState}
178-
accessibilityRole={accessibilityRole || 'image'} // [macOS]
178+
accessibilityRole={accessibilityRole ?? 'image'} // [macOS]
179179
{...restProps}
180180
accessible={props.alt !== undefined ? true : props.accessible}
181181
accessibilityLabel={accessibilityLabel ?? props.alt}

packages/react-native/Libraries/Lists/SectionListModern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type {
1616
SectionBase as _SectionBase,
1717
SectionData,
1818
VirtualizedSectionListProps,
19-
} from '@react-native/virtualized-lists';
19+
} from '@react-native-macos/virtualized-lists'; // [macOS]
2020

2121
import Platform from '../Utilities/Platform';
2222
import VirtualizedLists from '@react-native-macos/virtualized-lists'; // [macOS]

packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ export type CursorValue =
5757
| 'grabbing'
5858
| 'help'
5959
| 'move'
60-
| 'ne-rsize'
60+
| 'ne-resize'
6161
| 'nesw-resize'
6262
| 'n-resize'
6363
| 'ns-resize'
64-
| 'ns-resize'
64+
| 'nw-resize'
6565
| 'nwse-resize'
6666
| 'no-drop'
6767
| 'none'
6868
| 'not-allowed'
6969
| 'pointer'
7070
| 'progress'
71-
| 'row-esize'
71+
| 'row-resize'
7272
| 's-resize'
7373
| 'se-resize'
7474
| 'sw-resize'

packages/react-native/Libraries/Utilities/__tests__/Platform-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import PlatformAndroid from '../Platform.android';
1313
// $FlowFixMe[missing-platform-support]
1414
import PlatformIOS from '../Platform.ios';
1515
// $FlowFixMe[missing-platform-support]
16+
// $FlowFixMe[cannot-resolve-module]
1617
import PlatformMacOS from '../Platform.macos'; // [macOS]
1718

1819
describe('Platform', () => {

0 commit comments

Comments
 (0)