mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import type {
3 AccessibilityProps,
4 GestureResponderEvent,
5 ScrollViewProps,
6} from 'react-native'
7import {ViewStyle} from 'react-native'
8import {StyleProp} from 'react-native'
9
10import {ViewStyleProp} from '#/alf'
11import {BottomSheetViewProps} from '../../../modules/bottom-sheet'
12import {BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types'
13
14type A11yProps = Required<AccessibilityProps>
15
16/**
17 * Mutated by useImperativeHandle to provide a public API for controlling the
18 * dialog. The methods here will actually become the handlers defined within
19 * the `Dialog.Outer` component.
20 *
21 * `Partial<GestureResponderEvent>` here allows us to add this directly to the
22 * `onPress` prop of a button, for example. If this type was not added, we
23 * would need to create a function to wrap `.open()` with.
24 */
25export type DialogControlRefProps = {
26 open: (
27 options?: DialogControlOpenOptions & Partial<GestureResponderEvent>,
28 ) => void
29 close: (callback?: () => void) => void
30}
31
32/**
33 * The return type of the useDialogControl hook.
34 */
35export type DialogControlProps = DialogControlRefProps & {
36 id: string
37 ref: React.RefObject<DialogControlRefProps>
38 isOpen?: boolean
39}
40
41export type DialogContextProps = {
42 close: DialogControlProps['close']
43 isNativeDialog: boolean
44 nativeSnapPoint: BottomSheetSnapPoint
45 disableDrag: boolean
46 setDisableDrag: React.Dispatch<React.SetStateAction<boolean>>
47}
48
49export type DialogControlOpenOptions = {
50 /**
51 * NATIVE ONLY
52 *
53 * Optional index of the snap point to open the bottom sheet to. Defaults to
54 * 0, which is the first snap point (i.e. "open").
55 */
56 index?: number
57}
58
59export type DialogOuterProps = {
60 control: DialogControlProps
61 onClose?: () => void
62 nativeOptions?: Omit<BottomSheetViewProps, 'children'>
63 webOptions?: {}
64 testID?: string
65}
66
67type DialogInnerPropsBase<T> = React.PropsWithChildren<ViewStyleProp> & T
68export type DialogInnerProps =
69 | DialogInnerPropsBase<{
70 label?: undefined
71 accessibilityLabelledBy: A11yProps['aria-labelledby']
72 accessibilityDescribedBy: string
73 keyboardDismissMode?: ScrollViewProps['keyboardDismissMode']
74 contentContainerStyle?: StyleProp<ViewStyle>
75 header?: React.ReactNode
76 }>
77 | DialogInnerPropsBase<{
78 label: string
79 accessibilityLabelledBy?: undefined
80 accessibilityDescribedBy?: undefined
81 keyboardDismissMode?: ScrollViewProps['keyboardDismissMode']
82 contentContainerStyle?: StyleProp<ViewStyle>
83 header?: React.ReactNode
84 }>