mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {
3 AccessibilityProps,
4 AccessibilityRole,
5 GestureResponderEvent,
6 PressableProps,
7} from 'react-native'
8
9import {TextStyleProp, ViewStyleProp} from '#/alf'
10import * as Dialog from '#/components/Dialog'
11import {Props as SVGIconProps} from '#/components/icons/common'
12
13export type ContextType = {
14 control: Dialog.DialogOuterProps['control']
15}
16
17export type ItemContextType = {
18 disabled: boolean
19}
20
21export type RadixPassThroughTriggerProps = {
22 id: string
23 type: 'button'
24 disabled: boolean
25 ['data-disabled']: boolean
26 ['data-state']: string
27 ['aria-controls']?: string
28 ['aria-haspopup']?: boolean
29 ['aria-expanded']?: AccessibilityProps['aria-expanded']
30 onKeyDown: (e: React.KeyboardEvent) => void
31 /**
32 * Radix provides this, but we override on web to use `onPress` instead,
33 * which is less sensitive while scrolling.
34 */
35 onPointerDown: PressableProps['onPointerDown']
36}
37export type TriggerProps = {
38 children(props: TriggerChildProps): React.ReactNode
39 label: string
40 role?: AccessibilityRole
41}
42export type TriggerChildProps =
43 | {
44 isNative: true
45 control: Dialog.DialogOuterProps['control']
46 state: {
47 /**
48 * Web only, `false` on native
49 */
50 hovered: false
51 focused: boolean
52 pressed: boolean
53 }
54 /**
55 * We don't necessarily know what these will be spread on to, so we
56 * should add props one-by-one.
57 *
58 * On web, these properties are applied to a parent `Pressable`, so this
59 * object is empty.
60 */
61 props: {
62 onPress: () => void
63 onFocus: () => void
64 onBlur: () => void
65 onPressIn: () => void
66 onPressOut: () => void
67 accessibilityLabel: string
68 accessibilityRole: AccessibilityRole
69 }
70 }
71 | {
72 isNative: false
73 control: Dialog.DialogOuterProps['control']
74 state: {
75 hovered: boolean
76 focused: boolean
77 /**
78 * Native only, `false` on web
79 */
80 pressed: false
81 }
82 props: RadixPassThroughTriggerProps & {
83 onPress: () => void
84 onFocus: () => void
85 onBlur: () => void
86 onMouseEnter: () => void
87 onMouseLeave: () => void
88 accessibilityLabel: string
89 accessibilityRole: AccessibilityRole
90 }
91 }
92
93export type ItemProps = React.PropsWithChildren<
94 Omit<PressableProps, 'style'> &
95 ViewStyleProp & {
96 label: string
97 onPress: (e: GestureResponderEvent) => void
98 }
99>
100
101export type ItemTextProps = React.PropsWithChildren<TextStyleProp & {}>
102export type ItemIconProps = React.PropsWithChildren<{
103 icon: React.ComponentType<SVGIconProps>
104 position?: 'left' | 'right'
105}>
106
107export type GroupProps = React.PropsWithChildren<ViewStyleProp & {}>