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