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