UNPKG

@tamagui/react-native-web-lite

Version:
68 lines (67 loc) 2.07 kB
import * as React from "react"; import { useMemo, useRef } from "react"; import { pick, useMergeRefs, usePressEvents } from "@tamagui/react-native-web-internals"; const forwardPropsList = { accessibilityDisabled: !0, accessibilityLabel: !0, accessibilityLiveRegion: !0, accessibilityRole: !0, accessibilityState: !0, accessibilityValue: !0, children: !0, disabled: !0, focusable: !0, nativeID: !0, onBlur: !0, onFocus: !0, onLayout: !0, testID: !0 }, pickProps = (props) => pick(props, forwardPropsList); function TouchableWithoutFeedbackImpl(props, forwardedRef) { const { delayPressIn, delayPressOut, delayLongPress, disabled, focusable, onLongPress, onPress, onPressIn, onPressOut, rejectResponderTermination } = props, hostRef = useRef(null), 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 ] ), pressEventHandlers = usePressEvents(hostRef, pressConfig), element = React.Children.only(props.children), children = [element.props.children], supportedProps = pickProps(props); supportedProps.accessibilityDisabled = disabled, supportedProps.focusable = !disabled && focusable !== !1, 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.js.map