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