@tamagui/react-native-web-lite
Version:
React Native for Web
60 lines (59 loc) • 2.06 kB
JavaScript
import * as React from "react";
import { useMemo, useRef } from "react";
import { pick, useMergeRefs, usePressEvents } from "@tamagui/react-native-web-internals";
const forwardPropsList = {
accessibilityDisabled: true,
accessibilityLabel: true,
accessibilityLiveRegion: true,
accessibilityRole: true,
accessibilityState: true,
accessibilityValue: true,
children: true,
disabled: true,
focusable: true,
nativeID: true,
onBlur: true,
onFocus: true,
onLayout: true,
testID: true
};
const pickProps = props => pick(props, forwardPropsList);
function TouchableWithoutFeedbackImpl(props, forwardedRef) {
const {
delayPressIn,
delayPressOut,
delayLongPress,
disabled,
focusable,
onLongPress,
onPress,
onPressIn,
onPressOut,
rejectResponderTermination
} = props;
const hostRef = useRef(null);
const pressConfig = useMemo(() => ({
cancelable: !rejectResponderTermination,
disabled,
delayLongPress,
delayPressStart: delayPressIn,
delayPressEnd: delayPressOut,
onLongPress,
onPress,
onPressStart: onPressIn,
onPressEnd: onPressOut
}), [disabled, delayPressIn, delayPressOut, delayLongPress, onLongPress, onPress, onPressIn, onPressOut, rejectResponderTermination]);
const pressEventHandlers = usePressEvents(hostRef, pressConfig);
const element = React.Children.only(props.children);
const children = [element.props.children];
const supportedProps = pickProps(props);
supportedProps.accessibilityDisabled = disabled;
supportedProps.focusable = !disabled && focusable !== false;
supportedProps.ref = useMergeRefs(forwardedRef, hostRef, element.ref);
const elementProps = Object.assign(supportedProps, pressEventHandlers);
return React.cloneElement(element, elementProps, ...children);
}
const TouchableWithoutFeedback = React.memo(React.forwardRef(TouchableWithoutFeedbackImpl));
TouchableWithoutFeedback.displayName = "TouchableWithoutFeedback";
export { TouchableWithoutFeedback };
//# sourceMappingURL=TouchableWithoutFeedback.mjs.map