mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at thread-bug 2.7 kB view raw
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 // 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 } 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 }>