mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import type {AccessibilityProps} from 'react-native'
3import {BottomSheetProps} from '@gorhom/bottom-sheet'
4
5import {ViewStyleProp} from '#/alf'
6
7type A11yProps = Required<AccessibilityProps>
8
9/**
10 * Mutated by useImperativeHandle to provide a public API for controlling the
11 * dialog. The methods here will actually become the handlers defined within
12 * the `Dialog.Outer` component.
13 */
14export type DialogControlRefProps = {
15 open: (options?: DialogControlOpenOptions) => void
16 close: (callback?: () => void) => void
17}
18
19/**
20 * The return type of the useDialogControl hook.
21 */
22export type DialogControlProps = DialogControlRefProps & {
23 id: string
24 ref: React.RefObject<DialogControlRefProps>
25 isOpen: boolean
26}
27
28export type DialogContextProps = {
29 close: DialogControlProps['close']
30}
31
32export type DialogControlOpenOptions = {
33 /**
34 * NATIVE ONLY
35 *
36 * Optional index of the snap point to open the bottom sheet to. Defaults to
37 * 0, which is the first snap point (i.e. "open").
38 */
39 index?: number
40}
41
42export type DialogOuterProps = {
43 control: DialogControlProps
44 onClose?: () => void
45 nativeOptions?: {
46 sheet?: Omit<BottomSheetProps, 'children'>
47 }
48 webOptions?: {}
49}
50
51type DialogInnerPropsBase<T> = React.PropsWithChildren<ViewStyleProp> & T
52export type DialogInnerProps =
53 | DialogInnerPropsBase<{
54 label?: undefined
55 accessibilityLabelledBy: A11yProps['aria-labelledby']
56 accessibilityDescribedBy: string
57 }>
58 | DialogInnerPropsBase<{
59 label: string
60 accessibilityLabelledBy?: undefined
61 accessibilityDescribedBy?: undefined
62 }>