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