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' 8import type React from 'react' 9 10import {type ViewStyleProp} from '#/alf' 11import {type BottomSheetViewProps} from '../../../modules/bottom-sheet' 12import {type 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 // in the event that the hook is used outside of a dialog 48 isWithinDialog: boolean 49} 50 51export type DialogControlOpenOptions = { 52 /** 53 * NATIVE ONLY 54 * 55 * Optional index of the snap point to open the bottom sheet to. Defaults to 56 * 0, which is the first snap point (i.e. "open"). 57 */ 58 index?: number 59} 60 61export type DialogOuterProps = { 62 control: DialogControlProps 63 onClose?: () => void 64 nativeOptions?: Omit<BottomSheetViewProps, 'children'> 65 webOptions?: { 66 alignCenter?: boolean 67 onBackgroundPress?: (e: GestureResponderEvent) => void 68 } 69 testID?: string 70} 71 72type DialogInnerPropsBase<T> = React.PropsWithChildren<ViewStyleProp> & 73 T & { 74 testID?: string 75 } 76export type DialogInnerProps = 77 | DialogInnerPropsBase<{ 78 label?: undefined 79 accessibilityLabelledBy: A11yProps['aria-labelledby'] 80 accessibilityDescribedBy: string 81 keyboardDismissMode?: ScrollViewProps['keyboardDismissMode'] 82 contentContainerStyle?: StyleProp<ViewStyle> 83 header?: React.ReactNode 84 }> 85 | DialogInnerPropsBase<{ 86 label: string 87 accessibilityLabelledBy?: undefined 88 accessibilityDescribedBy?: undefined 89 keyboardDismissMode?: ScrollViewProps['keyboardDismissMode'] 90 contentContainerStyle?: StyleProp<ViewStyle> 91 header?: React.ReactNode 92 }>