1 line
22 KiB
Plaintext
1 line
22 KiB
Plaintext
{"version":3,"sources":["gestureHandlers.ts"],"names":["baseProps","TapGestureHandler","name","allowedProps","config","FlingGestureHandler","ForceTouchFallback","React","Component","componentDidMount","console","warn","render","props","children","ForceTouchGestureHandler","PlatformConstants","forceTouchAvailable","LongPressGestureHandler","validatePanGestureHandlerProps","minDeltaX","activeOffsetX","Error","maxDeltaX","failOffsetX","minDeltaY","activeOffsetY","maxDeltaY","failOffsetY","Array","isArray","transformPanGestureHandlerProps","res","undefined","activeOffsetXStart","activeOffsetXEnd","failOffsetXStart","failOffsetXEnd","minOffsetX","activeOffsetYStart","activeOffsetYEnd","failOffsetYStart","failOffsetYEnd","minOffsetY","managePanProps","__DEV__","PanGestureHandler","transformProps","customNativeProps","PinchGestureHandler","RotationGestureHandler"],"mappings":";;;;;;;AAIA;;AAEA;;AACA;;;;;;;;;;AAkEO,MAAMA,SAAS,GAAG,CACvB,IADuB,EAEvB,SAFuB,EAGvB,aAHuB,EAIvB,SAJuB,EAKvB,sBALuB,EAMvB,yBANuB,EAOvB,SAPuB,EAQvB,SARuB,EASvB,UATuB,EAUvB,aAVuB,EAWvB,aAXuB,EAYvB,SAZuB,EAavB,gBAbuB,EAcvB,sBAduB,CAAlB;;AAoCP;AACO,MAAMC,iBAAiB,GAAG,4BAG/B;AACAC,EAAAA,IAAI,EAAE,mBADN;AAEAC,EAAAA,YAAY,EAAE,CACZ,GAAGH,SADS,EAEZ,eAFY,EAGZ,YAHY,EAIZ,cAJY,EAKZ,WALY,EAMZ,WANY,EAOZ,SAPY,EAQZ,aARY,CAFd;AAYAI,EAAAA,MAAM,EAAE;AAZR,CAH+B,CAA1B;;AAgCP;AACO,MAAMC,mBAAmB,GAAG,4BAGjC;AACAH,EAAAA,IAAI,EAAE,qBADN;AAEAC,EAAAA,YAAY,EAAE,CAAC,GAAGH,SAAJ,EAAe,kBAAf,EAAmC,WAAnC,CAFd;AAGAI,EAAAA,MAAM,EAAE;AAHR,CAH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GH,SADS,EAEZ,eAFY,EAGZ,eAHY,EAIZ,aAJY,EAKZ,aALY,EAMZ,SANY,EAOZ,aAPY,EAQZ,cARY,EASZ,cATY,EAUZ,aAVY,EAWZ,aAXY,EAYZ,YAZY,EAaZ,gCAbY,CAFd;AAiBAI,EAAAA,MAAM,EAAE,EAjBR;AAkBA2C,EAAAA,cAAc,EAAEH,cAlBhB;AAmBAI,EAAAA,iBAAiB,EAAE,CACjB,oBADiB,EAEjB,kBAFiB,EAGjB,oBAHiB,EAIjB,kBAJiB,EAKjB,kBALiB,EAMjB,gBANiB,EAOjB,kBAPiB,EAQjB,gBARiB;AAnBnB,CAH+B,CAA1B;;AA6CP;AACO,MAAMC,mBAAmB,GAAG,4BAGjC;AACA/C,EAAAA,IAAI,EAAE,qBADN;AAEAC,EAAAA,YAAY,EAAEH,SAFd;AAGAI,EAAAA,MAAM,EAAE;AAHR,CAHiC,CAA5B;;AAoBP;AACO,MAAM8C,sBAAsB,GAAG,4BAGpC;AACAhD,EAAAA,IAAI,EAAE,wBADN;AAEAC,EAAAA,YAAY,EAAEH,SAFd;AAGAI,EAAAA,MAAM,EAAE;AAHR,CAHoC,CAA/B","sourcesContent":["// Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.\n// Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof\n// e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.\n// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.\nimport * as React from 'react';\n\nimport createHandler from './createHandler';\nimport PlatformConstants from '../PlatformConstants';\nimport { State } from '../State';\nimport { ValueOf } from '../typeUtils';\n\nexport interface GestureEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\n}\n\nexport interface HandlerStateChangeEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\n oldState: ValueOf<typeof State>;\n}\n\n//TODO(TS) events in handlers\n\nexport interface GestureEvent<ExtraEventPayloadT = Record<string, unknown>> {\n nativeEvent: Readonly<GestureEventPayload & ExtraEventPayloadT>;\n}\nexport interface HandlerStateChangeEvent<\n ExtraEventPayloadT = Record<string, unknown>\n> {\n nativeEvent: Readonly<HandlerStateChangeEventPayload & ExtraEventPayloadT>;\n}\n\n// Events payloads are types instead of interfaces due to TS limitation.\n// See https://github.com/microsoft/TypeScript/issues/15300 for more info.\nexport type BaseGestureHandlerProps<\n ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown>\n> = {\n id?: string;\n enabled?: boolean;\n minPointers?: number;\n waitFor?: React.Ref<unknown> | React.Ref<unknown>[];\n simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];\n shouldCancelWhenOutside?: boolean;\n hitSlop?:\n | number\n // TODO(TS) take into consideration types from GestureHandler#setHitSlop\n | Partial<\n Record<\n 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal',\n number\n >\n >\n | Record<'width' | 'left', number>\n | Record<'width' | 'right', number>\n | Record<'height' | 'top', number>\n | Record<'height' | 'bottom', number>;\n // TODO(TS) - fix event types\n onBegan?: (event: HandlerStateChangeEvent) => void;\n onFailed?: (event: HandlerStateChangeEvent) => void;\n onCancelled?: (event: HandlerStateChangeEvent) => void;\n onActivated?: (event: HandlerStateChangeEvent) => void;\n onEnded?: (event: HandlerStateChangeEvent) => void;\n\n //TODO(TS) consider using NativeSyntheticEvent\n onGestureEvent?: (event: GestureEvent<ExtraEventPayloadT>) => void;\n onHandlerStateChange?: (\n event: HandlerStateChangeEvent<ExtraEventPayloadT>\n ) => void;\n};\n\nexport const baseProps = [\n 'id',\n 'enabled',\n 'minPointers',\n 'waitFor',\n 'simultaneousHandlers',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n 'onBegan',\n 'onFailed',\n 'onCancelled',\n 'onActivated',\n 'onEnded',\n 'onGestureEvent',\n 'onHandlerStateChange',\n] as const;\n\nexport type TapGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport interface TapGestureHandlerProps\n extends BaseGestureHandlerProps<TapGestureHandlerEventPayload> {\n minPointers?: number;\n maxDurationMs?: number;\n maxDelayMs?: number;\n numberOfTaps?: number;\n maxDeltaX?: number;\n maxDeltaY?: number;\n maxDist?: number;\n}\n\nexport type TapGestureHandler = typeof TapGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of this file\nexport const TapGestureHandler = createHandler<\n TapGestureHandlerProps,\n TapGestureHandlerEventPayload\n>({\n name: 'TapGestureHandler',\n allowedProps: [\n ...baseProps,\n 'maxDurationMs',\n 'maxDelayMs',\n 'numberOfTaps',\n 'maxDeltaX',\n 'maxDeltaY',\n 'maxDist',\n 'minPointers',\n ] as const,\n config: {},\n});\n\nexport type FlingGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport interface FlingGestureHandlerProps\n extends BaseGestureHandlerProps<FlingGestureHandlerEventPayload> {\n direction?: number;\n numberOfPointers?: number;\n}\n\nexport type FlingGestureHandler = typeof FlingGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of this file\nexport const FlingGestureHandler = createHandler<\n FlingGestureHandlerProps,\n FlingGestureHandlerEventPayload\n>({\n name: 'FlingGestureHandler',\n allowedProps: [...baseProps, 'numberOfPointers', 'direction'] as const,\n config: {},\n});\n\nclass ForceTouchFallback extends React.Component {\n static forceTouchAvailable = false;\n componentDidMount() {\n console.warn(\n 'ForceTouchGestureHandler is not available on this platform. Please use ForceTouchGestureHandler.forceTouchAvailable to conditionally render other components that would provide a fallback behavior specific to your usecase'\n );\n }\n render() {\n return this.props.children;\n }\n}\n\nexport type ForceTouchGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n force: number;\n};\n\nexport interface ForceTouchGestureHandlerProps\n extends BaseGestureHandlerProps<ForceTouchGestureHandlerEventPayload> {\n minForce?: number;\n maxForce?: number;\n feedbackOnActivation?: boolean;\n}\n\nexport type ForceTouchGestureHandler = typeof ForceTouchGestureHandler & {\n forceTouchAvailable: boolean;\n};\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of this file\nexport const ForceTouchGestureHandler = PlatformConstants?.forceTouchAvailable\n ? createHandler<\n ForceTouchGestureHandlerProps,\n ForceTouchGestureHandlerEventPayload\n >({\n name: 'ForceTouchGestureHandler',\n allowedProps: [\n ...baseProps,\n 'minForce',\n 'maxForce',\n 'feedbackOnActivation',\n ] as const,\n config: {},\n })\n : ForceTouchFallback;\n\n(ForceTouchGestureHandler as ForceTouchGestureHandler).forceTouchAvailable =\n PlatformConstants?.forceTouchAvailable || false;\n\nexport type LongPressGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport interface LongPressGestureHandlerProps\n extends BaseGestureHandlerProps<LongPressGestureHandlerEventPayload> {\n minDurationMs?: number;\n maxDist?: number;\n}\n\nexport type LongPressGestureHandler = typeof LongPressGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of this file\nexport const LongPressGestureHandler = createHandler<\n LongPressGestureHandlerProps,\n LongPressGestureHandlerEventPayload\n>({\n name: 'LongPressGestureHandler',\n allowedProps: [...baseProps, 'minDurationMs', 'maxDist'] as const,\n config: {},\n});\n\nfunction validatePanGestureHandlerProps(props: PanGestureHandlerProps) {\n if (props.minDeltaX && props.activeOffsetX) {\n throw new Error(\n `It's not supported use minDeltaX with activeOffsetXStart or activeOffsetXEnd`\n );\n }\n if (props.maxDeltaX && props.failOffsetX) {\n throw new Error(\n `It's not supported use minDeltaX with activeOffsetXStart or activeOffsetXEnd`\n );\n }\n if (props.minDeltaY && props.activeOffsetY) {\n throw new Error(\n `It's not supported use minDeltaX with activeOffsetYStart or activeOffsetYEnd`\n );\n }\n if (props.maxDeltaY && props.failOffsetY) {\n throw new Error(\n `It's not supported use minDeltaX with activeOffsetYStart or activeOffsetYEnd`\n );\n }\n if (\n Array.isArray(props.activeOffsetX) &&\n (props.activeOffsetX[0] > 0 || props.activeOffsetX[1] < 0)\n ) {\n throw new Error(\n `First element of activeOffsetX should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.activeOffsetY) &&\n (props.activeOffsetY[0] > 0 || props.activeOffsetY[1] < 0)\n ) {\n throw new Error(\n `First element of activeOffsetY should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.failOffsetX) &&\n (props.failOffsetX[0] > 0 || props.failOffsetX[1] < 0)\n ) {\n throw new Error(\n `First element of failOffsetX should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.failOffsetY) &&\n (props.failOffsetY[0] > 0 || props.failOffsetY[1] < 0)\n ) {\n throw new Error(\n `First element of failOffsetY should be negative, a the second one should be positive`\n );\n }\n}\n\nfunction transformPanGestureHandlerProps(props: PanGestureHandlerProps) {\n type InternalPanGHKeys =\n | 'activeOffsetXStart'\n | 'activeOffsetXEnd'\n | 'failOffsetXStart'\n | 'failOffsetXEnd'\n | 'activeOffsetYStart'\n | 'activeOffsetYEnd'\n | 'failOffsetYStart'\n | 'failOffsetYEnd';\n type PanGestureHandlerInternalProps = PanGestureHandlerProps &\n Partial<Record<InternalPanGHKeys, number>>;\n\n const res: PanGestureHandlerInternalProps = { ...props };\n if (props.minDeltaX !== undefined) {\n delete res.minDeltaX;\n res.activeOffsetXStart = -props.minDeltaX;\n res.activeOffsetXEnd = props.minDeltaX;\n }\n if (props.maxDeltaX !== undefined) {\n delete res.maxDeltaX;\n res.failOffsetXStart = -props.maxDeltaX;\n res.failOffsetXEnd = props.maxDeltaX;\n }\n if (props.minOffsetX !== undefined) {\n delete res.minOffsetX;\n if (props.minOffsetX < 0) {\n res.activeOffsetXStart = props.minOffsetX;\n } else {\n res.activeOffsetXEnd = props.minOffsetX;\n }\n }\n\n if (props.minDeltaY !== undefined) {\n delete res.minDeltaY;\n res.activeOffsetYStart = -props.minDeltaY;\n res.activeOffsetYEnd = props.minDeltaY;\n }\n if (props.maxDeltaY !== undefined) {\n delete res.maxDeltaY;\n res.failOffsetYStart = -props.maxDeltaY;\n res.failOffsetYEnd = props.maxDeltaY;\n }\n\n if (props.minOffsetY !== undefined) {\n delete res.minOffsetY;\n if (props.minOffsetY < 0) {\n res.activeOffsetYStart = props.minOffsetY;\n } else {\n res.activeOffsetYEnd = props.minOffsetY;\n }\n }\n\n if (props.activeOffsetX !== undefined) {\n delete res.activeOffsetX;\n if (Array.isArray(props.activeOffsetX)) {\n res.activeOffsetXStart = props.activeOffsetX[0];\n res.activeOffsetXEnd = props.activeOffsetX[1];\n } else if (props.activeOffsetX < 0) {\n res.activeOffsetXStart = props.activeOffsetX;\n } else {\n res.activeOffsetXEnd = props.activeOffsetX;\n }\n }\n\n if (props.activeOffsetY !== undefined) {\n delete res.activeOffsetY;\n if (Array.isArray(props.activeOffsetY)) {\n res.activeOffsetYStart = props.activeOffsetY[0];\n res.activeOffsetYEnd = props.activeOffsetY[1];\n } else if (props.activeOffsetY < 0) {\n res.activeOffsetYStart = props.activeOffsetY;\n } else {\n res.activeOffsetYEnd = props.activeOffsetY;\n }\n }\n\n if (props.failOffsetX !== undefined) {\n delete res.failOffsetX;\n if (Array.isArray(props.failOffsetX)) {\n res.failOffsetXStart = props.failOffsetX[0];\n res.failOffsetXEnd = props.failOffsetX[1];\n } else if (props.failOffsetX < 0) {\n res.failOffsetXStart = props.failOffsetX;\n } else {\n res.failOffsetXEnd = props.failOffsetX;\n }\n }\n\n if (props.failOffsetY !== undefined) {\n delete res.failOffsetY;\n if (Array.isArray(props.failOffsetY)) {\n res.failOffsetYStart = props.failOffsetY[0];\n res.failOffsetYEnd = props.failOffsetY[1];\n } else if (props.failOffsetY < 0) {\n res.failOffsetYStart = props.failOffsetY;\n } else {\n res.failOffsetYEnd = props.failOffsetY;\n }\n }\n\n return res;\n}\n\nfunction managePanProps(props: PanGestureHandlerProps) {\n if (__DEV__) {\n validatePanGestureHandlerProps(props);\n }\n return transformPanGestureHandlerProps(props);\n}\n\nexport type PanGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n translationX: number;\n translationY: number;\n velocityX: number;\n velocityY: number;\n};\n\nexport interface PanGestureHandlerProps\n extends BaseGestureHandlerProps<PanGestureHandlerEventPayload> {\n /** @deprecated use activeOffsetX*/\n minDeltaX?: number;\n /** @deprecated use activeOffsetY*/\n minDeltaY?: number;\n /** @deprecated use failOffsetX*/\n maxDeltaX?: number;\n /** @deprecated use failOffsetY*/\n maxDeltaY?: number;\n /** @deprecated use activeOffsetX*/\n minOffsetX?: number;\n /** @deprecated use failOffsetY*/\n minOffsetY?: number;\n activeOffsetY?: number | number[];\n activeOffsetX?: number | number[];\n failOffsetY?: number | number[];\n failOffsetX?: number | number[];\n minDist?: number;\n minVelocity?: number;\n minVelocityX?: number;\n minVelocityY?: number;\n minPointers?: number;\n maxPointers?: number;\n avgTouches?: boolean;\n enableTrackpadTwoFingerGesture?: boolean;\n}\n\nexport type PanGestureHandler = typeof PanGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of this file\nexport const PanGestureHandler = createHandler<\n PanGestureHandlerProps,\n PanGestureHandlerEventPayload\n>({\n name: 'PanGestureHandler',\n allowedProps: [\n ...baseProps,\n 'activeOffsetY',\n 'activeOffsetX',\n 'failOffsetY',\n 'failOffsetX',\n 'minDist',\n 'minVelocity',\n 'minVelocityX',\n 'minVelocityY',\n 'minPointers',\n 'maxPointers',\n 'avgTouches',\n 'enableTrackpadTwoFingerGesture',\n ] as const,\n config: {},\n transformProps: managePanProps,\n customNativeProps: [\n 'activeOffsetYStart',\n 'activeOffsetYEnd',\n 'activeOffsetXStart',\n 'activeOffsetXEnd',\n 'failOffsetYStart',\n 'failOffsetYEnd',\n 'failOffsetXStart',\n 'failOffsetXEnd',\n ],\n});\n\nexport type PinchGestureHandlerEventPayload = {\n scale: number;\n focalX: number;\n focalY: number;\n velocity: number;\n};\n\nexport interface PinchGestureHandlerProps\n extends BaseGestureHandlerProps<PinchGestureHandlerEventPayload> {}\n\nexport type PinchGestureHandler = typeof PinchGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of this file\nexport const PinchGestureHandler = createHandler<\n PinchGestureHandlerProps,\n PinchGestureHandlerEventPayload\n>({\n name: 'PinchGestureHandler',\n allowedProps: baseProps,\n config: {},\n});\n\nexport type RotationGestureHandlerEventPayload = {\n rotation: number;\n anchorX: number;\n anchorY: number;\n velocity: number;\n};\n\nexport interface RotationGestureHandlerProps\n extends BaseGestureHandlerProps<RotationGestureHandlerEventPayload> {}\n\nexport type RotationGestureHandler = typeof RotationGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of this file\nexport const RotationGestureHandler = createHandler<\n RotationGestureHandlerProps,\n RotationGestureHandlerEventPayload\n>({\n name: 'RotationGestureHandler',\n allowedProps: baseProps,\n config: {},\n});\n"]} |