From 6a8369dd9562f457a85194e4a853c80a2ec8d8e4 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Fri, 5 Feb 2021 16:19:36 -0800 Subject: [PATCH] Fix types --- .../src/exports/Pressable/index.js | 18 +----- .../src/exports/ScrollView/ScrollViewBase.js | 22 +------ .../exports/TouchableWithoutFeedback/index.js | 2 - .../src/exports/View/types.js | 64 ++++++++++++++++--- 4 files changed, 61 insertions(+), 45 deletions(-) diff --git a/packages/react-native-web/src/exports/Pressable/index.js b/packages/react-native-web/src/exports/Pressable/index.js index 32c18b9a..cefe140c 100644 --- a/packages/react-native-web/src/exports/Pressable/index.js +++ b/packages/react-native-web/src/exports/Pressable/index.js @@ -30,15 +30,8 @@ export type StateCallbackType = $ReadOnly<{| type ViewStyleProp = $PropertyType; -type Props = $ReadOnly<{| - accessibilityLabel?: $PropertyType, - accessibilityLiveRegion?: $PropertyType, - accessibilityRole?: $PropertyType, - accessibilityState?: $PropertyType, - accessibilityValue?: $PropertyType, - accessible?: $PropertyType, - focusable?: ?boolean, - importantForAccessibility?: $PropertyType, +type Props = { + ...ViewProps, children: React.Node | ((state: StateCallbackType) => React.Node), // Duration (in milliseconds) from `onPressIn` before `onLongPress` is called. delayLongPress?: ?number, @@ -48,10 +41,6 @@ type Props = $ReadOnly<{| delayPressOut?: ?number, // Whether the press behavior is disabled. disabled?: ?boolean, - // Called when the view blurs - onBlur?: $PropertyType, - // Called when the view is focused - onFocus?: $PropertyType, // Called when the view is hovered onHoverIn?: $PropertyType, // Called when the view is no longer hovered @@ -69,13 +58,12 @@ type Props = $ReadOnly<{| // Called when a touch is released, before `onPress`. onPressOut?: $PropertyType, style?: ViewStyleProp | ((state: StateCallbackType) => ViewStyleProp), - testID?: $PropertyType, /** * Used only for documentation or testing (e.g. snapshot testing). */ testOnly_hovered?: ?boolean, testOnly_pressed?: ?boolean -|}>; +}; /** * Component used to build display components that should respond to whether the diff --git a/packages/react-native-web/src/exports/ScrollView/ScrollViewBase.js b/packages/react-native-web/src/exports/ScrollView/ScrollViewBase.js index d774f0c9..e110c54e 100644 --- a/packages/react-native-web/src/exports/ScrollView/ScrollViewBase.js +++ b/packages/react-native-web/src/exports/ScrollView/ScrollViewBase.js @@ -72,24 +72,15 @@ function shouldEmitScrollEvent(lastTick: number, eventThrottle: number) { */ const ScrollViewBase = forwardRef((props, forwardedRef) => { const { - accessibilityLabel, - accessibilityRole, - accessibilityState, - children, - importantForAccessibility, - nativeID, - onLayout, onScroll, onTouchMove, onWheel, - pointerEvents, scrollEnabled = true, scrollEventThrottle = 0, showsHorizontalScrollIndicator, showsVerticalScrollIndicator, style, - dataSet, - testID + ...rest } = props; const scrollState = useRef({ isScrolling: false, scrollLastTick: 0 }); @@ -153,25 +144,16 @@ const ScrollViewBase = forwardRef((props, forwardedRef) => { return ( ); }); diff --git a/packages/react-native-web/src/exports/TouchableWithoutFeedback/index.js b/packages/react-native-web/src/exports/TouchableWithoutFeedback/index.js index e0feaeb3..c0c7ffa2 100644 --- a/packages/react-native-web/src/exports/TouchableWithoutFeedback/index.js +++ b/packages/react-native-web/src/exports/TouchableWithoutFeedback/index.js @@ -25,14 +25,12 @@ export type Props = $ReadOnly<{| accessibilityRole?: $PropertyType, accessibilityState?: $PropertyType, accessibilityValue?: $PropertyType, - accessible?: $PropertyType, children?: ?React.Node, delayLongPress?: ?number, delayPressIn?: ?number, delayPressOut?: ?number, disabled?: ?boolean, focusable?: ?boolean, - importantForAccessibility?: $PropertyType, nativeID?: $PropertyType, onBlur?: $PropertyType, onFocus?: $PropertyType, diff --git a/packages/react-native-web/src/exports/View/types.js b/packages/react-native-web/src/exports/View/types.js index 9cfb4a35..c61b55ad 100644 --- a/packages/react-native-web/src/exports/View/types.js +++ b/packages/react-native-web/src/exports/View/types.js @@ -20,8 +20,60 @@ import type { } from '../../types/styles'; type NumberOrString = number | string; - type OverscrollBehaviorValue = 'auto' | 'contain' | 'none'; +type idRef = string; +type idRefList = idRef | Array; + +export type AccessibilityProps = {| + accessibilityActiveDescendant?: ?idRef, + accessibilityAtomic?: ?boolean, + accessibilityAutoComplete?: ?('none' | 'list' | 'inline' | 'both'), + accessibilityBusy?: ?boolean, + accessibilityChecked?: ?(boolean | 'mixed'), + accessibilityColumnCount?: ?number, + accessibilityColumnIndex?: ?number, + accessibilityColumnSpan?: ?number, + accessibilityControls?: ?idRefList, + accessibilityDescribedBy?: ?idRef, + accessibilityDetails?: ?idRef, + accessibilityDisabled?: ?boolean, + accessibilityErrorMessage?: ?idRef, + accessibilityExpanded?: ?boolean, + accessibilityFlowTo?: ?idRefList, + accessibilityHasPopup?: ?('dialog' | 'grid' | 'listbox' | 'menu' | 'tree' | false), + accessibilityHidden?: ?boolean, + accessibilityInvalid?: ?boolean, + accessibilityKeyShortcuts?: ?Array, + accessibilityLabel?: ?string, + accessibilityLabelledBy?: ?idRefList, + accessibilityLevel?: ?number, + accessibilityLiveRegion?: ?('assertive' | 'none' | 'polite'), + accessibilityModal?: ?boolean, + accessibilityMultiline?: ?boolean, + accessibilityMultiSelectable?: ?boolean, + accessibilityOrientation?: ?('horizontal' | 'vertical'), + accessibilityOwns?: ?idRefList, + accessibilityPlaceholder?: ?string, + accessibilityPosInSet?: ?number, + accessibilityPressed?: ?(boolean | 'mixed'), + accessibilityReadOnly?: ?boolean, + accessibilityRequired?: ?boolean, + accessibilityRole?: ?string, + accessibilityRoleDescription?: ?string, + accessibilityRowCount?: ?number, + accessibilityRowIndex?: ?number, + accessibilityRowSpan?: ?number, + accessibilitySelected?: ?boolean, + accessibilitySetSize?: ?number, + accessibilitySort?: ?('ascending' | 'descending' | 'none' | 'other'), + accessibilityValueMax?: ?number, + accessibilityValueMin?: ?number, + accessibilityValueNow?: ?number, + accessibilityValueText?: ?string, + dataSet?: { ... }, + focusable?: ?boolean, + nativeID?: ?string +|}; export type ViewStyle = { ...AnimationStyles, @@ -59,9 +111,7 @@ export type ViewStyle = { }; export type ViewProps = { - accessibilityLabel?: ?string, - accessibilityLiveRegion?: 'none' | 'polite' | 'assertive', - accessibilityRole?: ?string, + ...AccessibilityProps, accessibilityState?: { busy?: ?boolean, checked?: ?boolean | 'mixed', @@ -82,9 +132,8 @@ export type ViewProps = { now?: ?number, text?: ?string }, - accessible?: boolean, children?: ?any, - importantForAccessibility?: 'auto' | 'yes' | 'no' | 'no-hide-descendants', + focusable?: ?boolean, nativeID?: ?string, onBlur?: (e: any) => void, onClick?: (e: any) => void, @@ -133,6 +182,5 @@ export type ViewProps = { onTouchStartCapture?: (e: any) => void, onWheel?: (e: any) => void, href?: ?string, - rel?: ?string, - target?: ?string + hrefAttrs?: ?{ download?: ?boolean, rel?: ?string, target?: ?string } };