mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-14 03:43:23 +00:00
Fix types
This commit is contained in:
@@ -30,15 +30,8 @@ export type StateCallbackType = $ReadOnly<{|
|
||||
|
||||
type ViewStyleProp = $PropertyType<ViewProps, 'style'>;
|
||||
|
||||
type Props = $ReadOnly<{|
|
||||
accessibilityLabel?: $PropertyType<ViewProps, 'accessibilityLabel'>,
|
||||
accessibilityLiveRegion?: $PropertyType<ViewProps, 'accessibilityLiveRegion'>,
|
||||
accessibilityRole?: $PropertyType<ViewProps, 'accessibilityRole'>,
|
||||
accessibilityState?: $PropertyType<ViewProps, 'accessibilityState'>,
|
||||
accessibilityValue?: $PropertyType<ViewProps, 'accessibilityValue'>,
|
||||
accessible?: $PropertyType<ViewProps, 'accessible'>,
|
||||
focusable?: ?boolean,
|
||||
importantForAccessibility?: $PropertyType<ViewProps, 'importantForAccessibility'>,
|
||||
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<ViewProps, 'onBlur'>,
|
||||
// Called when the view is focused
|
||||
onFocus?: $PropertyType<ViewProps, 'onFocus'>,
|
||||
// Called when the view is hovered
|
||||
onHoverIn?: $PropertyType<HoverEventsConfig, 'onHoverStart'>,
|
||||
// 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<PressResponderConfig, 'onPressEnd'>,
|
||||
style?: ViewStyleProp | ((state: StateCallbackType) => ViewStyleProp),
|
||||
testID?: $PropertyType<ViewProps, 'testID'>,
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -72,24 +72,15 @@ function shouldEmitScrollEvent(lastTick: number, eventThrottle: number) {
|
||||
*/
|
||||
const ScrollViewBase = forwardRef<Props, *>((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, *>((props, forwardedRef) => {
|
||||
|
||||
return (
|
||||
<View
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
accessibilityRole={accessibilityRole}
|
||||
accessibilityState={accessibilityState}
|
||||
children={children}
|
||||
dataSet={dataSet}
|
||||
importantForAccessibility={importantForAccessibility}
|
||||
nativeID={nativeID}
|
||||
onLayout={onLayout}
|
||||
{...rest}
|
||||
onScroll={handleScroll}
|
||||
onTouchMove={createPreventableScrollHandler(onTouchMove)}
|
||||
onWheel={createPreventableScrollHandler(onWheel)}
|
||||
pointerEvents={pointerEvents}
|
||||
ref={useMergeRefs(scrollRef, forwardedRef)}
|
||||
style={[
|
||||
style,
|
||||
!scrollEnabled && styles.scrollDisabled,
|
||||
hideScrollbar && styles.hideScrollbar
|
||||
]}
|
||||
testID={testID}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -25,14 +25,12 @@ export type Props = $ReadOnly<{|
|
||||
accessibilityRole?: $PropertyType<ViewProps, 'accessibilityRole'>,
|
||||
accessibilityState?: $PropertyType<ViewProps, 'accessibilityState'>,
|
||||
accessibilityValue?: $PropertyType<ViewProps, 'accessibilityValue'>,
|
||||
accessible?: $PropertyType<ViewProps, 'accessible'>,
|
||||
children?: ?React.Node,
|
||||
delayLongPress?: ?number,
|
||||
delayPressIn?: ?number,
|
||||
delayPressOut?: ?number,
|
||||
disabled?: ?boolean,
|
||||
focusable?: ?boolean,
|
||||
importantForAccessibility?: $PropertyType<ViewProps, 'importantForAccessibility'>,
|
||||
nativeID?: $PropertyType<ViewProps, 'nativeID'>,
|
||||
onBlur?: $PropertyType<ViewProps, 'onBlur'>,
|
||||
onFocus?: $PropertyType<ViewProps, 'onFocus'>,
|
||||
|
||||
@@ -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<idRef>;
|
||||
|
||||
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<string>,
|
||||
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 }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user