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