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