Bluesky app fork with some witchin' additions 馃挮
1import {
2 type AccessibilityProps,
3 type AccessibilityRole,
4 type GestureResponderEvent,
5 type PressableProps,
6} from 'react-native'
7
8import {type TextStyleProp, type ViewStyleProp} from '#/alf'
9import type * as Dialog from '#/components/Dialog'
10import {type 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 ref: React.RefObject<any>
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 hint?: string
41 role?: AccessibilityRole
42}
43export type TriggerChildProps =
44 | {
45 IS_NATIVE: true
46 control: Dialog.DialogOuterProps['control']
47 state: {
48 /**
49 * Web only, `false` on native
50 */
51 hovered: false
52 focused: boolean
53 pressed: boolean
54 }
55 /**
56 * We don't necessarily know what these will be spread on to, so we
57 * should add props one-by-one.
58 *
59 * On web, these properties are applied to a parent `Pressable`, so this
60 * object is empty.
61 */
62 props: {
63 ref: null
64 onPress: () => void
65 onFocus: () => void
66 onBlur: () => void
67 onPressIn: () => void
68 onPressOut: () => void
69 accessibilityHint?: string
70 accessibilityLabel: string
71 accessibilityRole: AccessibilityRole
72 }
73 }
74 | {
75 IS_NATIVE: false
76 control: Dialog.DialogOuterProps['control']
77 state: {
78 hovered: boolean
79 focused: boolean
80 /**
81 * Native only, `false` on web
82 */
83 pressed: false
84 }
85 props: RadixPassThroughTriggerProps & {
86 onPress: () => void
87 onFocus: () => void
88 onBlur: () => void
89 onMouseEnter: () => void
90 onMouseLeave: () => void
91 accessibilityHint?: string
92 accessibilityLabel: string
93 accessibilityRole: AccessibilityRole
94 }
95 }
96
97export type ItemProps = React.PropsWithChildren<
98 Omit<PressableProps, 'style'> &
99 ViewStyleProp & {
100 label: string
101 onPress: (e: GestureResponderEvent) => void
102 }
103>
104
105export type ItemTextProps = React.PropsWithChildren<TextStyleProp & {}>
106export type ItemIconProps = React.PropsWithChildren<{
107 icon: React.ComponentType<SVGIconProps>
108 position?: 'left' | 'right'
109 fill?: (props: {disabled: boolean}) => string
110}>
111
112export type GroupProps = React.PropsWithChildren<ViewStyleProp & {}>