-
Notifications
You must be signed in to change notification settings - Fork 171
Expand file tree
/
Copy pathCalloutNativeComponent.ts
More file actions
69 lines (58 loc) · 2.21 KB
/
CalloutNativeComponent.ts
File metadata and controls
69 lines (58 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { HostComponent, ViewProps } from 'react-native';
import type { WithDefault, UnsafeMixed, Int32, DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';
interface AnchorRect {
screenX: Double;
screenY: Double;
width: Double;
height: Double;
}
/**
* Shared native props specific to Callout native component
*/
export interface NativeProps extends ViewProps {
accessibilityLabel?: string;
accessibilityOnShowAnnouncement?: string;
anchorRect?: AnchorRect;
dismissBehaviors?: string[];
doNotTakePointerCapture?: boolean;
focusable?: boolean;
isBeakVisible?: boolean;
maxHeight?: Int32;
maxWidth?: Int32;
setInitialFocus?: boolean;
// targetAnchor?: string; // Win32 only Callout can target an anchor registered in the anchor registry // Can be a node id or an anchor ID - This need to be reworked as Mixed types are not supported going forward
testID?: string;
onRestoreFocus?: DirectEventHandler<{ target: Int32; containsFocus: boolean }>;
onDismiss?: DirectEventHandler<{ target: Int32 }>;
onShow?: DirectEventHandler<{ target: Int32 }>;
directionalHint?: WithDefault<
| 'leftTopEdge'
| 'leftCenter'
| 'leftBottomEdge'
| 'topLeftEdge'
| 'topAutoEdge'
| 'topCenter'
| 'topRightEdge'
| 'rightTopEdge'
| 'rightCenter'
| 'rightBottomEdge'
| 'bottomLeftEdge'
| 'bottonLeftEdge' // Typo in the original code, should be 'bottomLeftEdge'
| 'bottomAutoEdge'
| 'bottomCenter'
| 'bottomRightEdge',
'bottonLeftEdge'
>;
target?: UnsafeMixed;
}
export type CalloutComponentType = HostComponent<NativeProps>;
export interface CalloutNativeCommands {
focusWindow: (viewRef: React.ElementRef<CalloutComponentType>) => void;
blurWindow: (viewRef: React.ElementRef<CalloutComponentType>) => void;
}
export const Commands: CalloutNativeCommands = codegenNativeCommands<CalloutNativeCommands>({
supportedCommands: ['blurWindow', 'focusWindow'],
});
export default codegenNativeComponent<NativeProps>('RCTCallout') as CalloutComponentType;