feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

View File

@@ -0,0 +1,7 @@
export const ActionType = {
REANIMATED_WORKLET: 1,
NATIVE_ANIMATED_EVENT: 2,
JS_FUNCTION_OLD_API: 3,
JS_FUNCTION_NEW_API: 4
}; // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
//# sourceMappingURL=ActionType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["ActionType.ts"],"names":["ActionType","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","JS_FUNCTION_OLD_API","JS_FUNCTION_NEW_API"],"mappings":"AAAA,OAAO,MAAMA,UAAU,GAAG;AACxBC,EAAAA,kBAAkB,EAAE,CADI;AAExBC,EAAAA,qBAAqB,EAAE,CAFC;AAGxBC,EAAAA,mBAAmB,EAAE,CAHG;AAIxBC,EAAAA,mBAAmB,EAAE;AAJG,CAAnB,C,CAOP","sourcesContent":["export const ActionType = {\n REANIMATED_WORKLET: 1,\n NATIVE_ANIMATED_EVENT: 2,\n JS_FUNCTION_OLD_API: 3,\n JS_FUNCTION_NEW_API: 4,\n} as const;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value\nexport type ActionType = typeof ActionType[keyof typeof ActionType];\n"]}

View File

@@ -0,0 +1,19 @@
const RIGHT = 1;
const LEFT = 2;
const UP = 4;
const DOWN = 8; // public interface
export const Directions = {
RIGHT: RIGHT,
LEFT: LEFT,
UP: UP,
DOWN: DOWN
}; // internal interface
export const DiagonalDirections = {
UP_RIGHT: UP | RIGHT,
DOWN_RIGHT: DOWN | RIGHT,
UP_LEFT: UP | LEFT,
DOWN_LEFT: DOWN | LEFT
}; // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
//# sourceMappingURL=Directions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["Directions.ts"],"names":["RIGHT","LEFT","UP","DOWN","Directions","DiagonalDirections","UP_RIGHT","DOWN_RIGHT","UP_LEFT","DOWN_LEFT"],"mappings":"AAAA,MAAMA,KAAK,GAAG,CAAd;AACA,MAAMC,IAAI,GAAG,CAAb;AACA,MAAMC,EAAE,GAAG,CAAX;AACA,MAAMC,IAAI,GAAG,CAAb,C,CAEA;;AACA,OAAO,MAAMC,UAAU,GAAG;AACxBJ,EAAAA,KAAK,EAAEA,KADiB;AAExBC,EAAAA,IAAI,EAAEA,IAFkB;AAGxBC,EAAAA,EAAE,EAAEA,EAHoB;AAIxBC,EAAAA,IAAI,EAAEA;AAJkB,CAAnB,C,CAOP;;AACA,OAAO,MAAME,kBAAkB,GAAG;AAChCC,EAAAA,QAAQ,EAAEJ,EAAE,GAAGF,KADiB;AAEhCO,EAAAA,UAAU,EAAEJ,IAAI,GAAGH,KAFa;AAGhCQ,EAAAA,OAAO,EAAEN,EAAE,GAAGD,IAHkB;AAIhCQ,EAAAA,SAAS,EAAEN,IAAI,GAAGF;AAJc,CAA3B,C,CAOP","sourcesContent":["const RIGHT = 1;\nconst LEFT = 2;\nconst UP = 4;\nconst DOWN = 8;\n\n// public interface\nexport const Directions = {\n RIGHT: RIGHT,\n LEFT: LEFT,\n UP: UP,\n DOWN: DOWN,\n} as const;\n\n// internal interface\nexport const DiagonalDirections = {\n UP_RIGHT: UP | RIGHT,\n DOWN_RIGHT: DOWN | RIGHT,\n UP_LEFT: UP | LEFT,\n DOWN_LEFT: DOWN | LEFT,\n} as const;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value\nexport type Directions = typeof Directions[keyof typeof Directions];\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type DiagonalDirections =\n typeof DiagonalDirections[keyof typeof DiagonalDirections];\n"]}

View File

@@ -0,0 +1,22 @@
import { Platform } from 'react-native';
let useNewWebImplementation = true;
let getWasCalled = false;
export function enableExperimentalWebImplementation(_shouldEnable = true) {// NO-OP since the new implementation is now the default
}
export function enableLegacyWebImplementation(shouldUseLegacyImplementation = true) {
if (Platform.OS !== 'web' || useNewWebImplementation === !shouldUseLegacyImplementation) {
return;
}
if (getWasCalled) {
console.error('Some parts of this application have already started using the new gesture handler implementation. No changes will be applied. You can try enabling legacy implementation earlier.');
return;
}
useNewWebImplementation = !shouldUseLegacyImplementation;
}
export function isNewWebImplementationEnabled() {
getWasCalled = true;
return useNewWebImplementation;
}
//# sourceMappingURL=EnableNewWebImplementation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["EnableNewWebImplementation.ts"],"names":["Platform","useNewWebImplementation","getWasCalled","enableExperimentalWebImplementation","_shouldEnable","enableLegacyWebImplementation","shouldUseLegacyImplementation","OS","console","error","isNewWebImplementationEnabled"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AAEA,IAAIC,uBAAuB,GAAG,IAA9B;AACA,IAAIC,YAAY,GAAG,KAAnB;AAEA,OAAO,SAASC,mCAAT,CACLC,aAAa,GAAG,IADX,EAEC,CACN;AACD;AAED,OAAO,SAASC,6BAAT,CACLC,6BAA6B,GAAG,IAD3B,EAEC;AACN,MACEN,QAAQ,CAACO,EAAT,KAAgB,KAAhB,IACAN,uBAAuB,KAAK,CAACK,6BAF/B,EAGE;AACA;AACD;;AAED,MAAIJ,YAAJ,EAAkB;AAChBM,IAAAA,OAAO,CAACC,KAAR,CACE,mLADF;AAGA;AACD;;AAEDR,EAAAA,uBAAuB,GAAG,CAACK,6BAA3B;AACD;AAED,OAAO,SAASI,6BAAT,GAAkD;AACvDR,EAAAA,YAAY,GAAG,IAAf;AACA,SAAOD,uBAAP;AACD","sourcesContent":["import { Platform } from 'react-native';\n\nlet useNewWebImplementation = true;\nlet getWasCalled = false;\n\nexport function enableExperimentalWebImplementation(\n _shouldEnable = true\n): void {\n // NO-OP since the new implementation is now the default\n}\n\nexport function enableLegacyWebImplementation(\n shouldUseLegacyImplementation = true\n): void {\n if (\n Platform.OS !== 'web' ||\n useNewWebImplementation === !shouldUseLegacyImplementation\n ) {\n return;\n }\n\n if (getWasCalled) {\n console.error(\n 'Some parts of this application have already started using the new gesture handler implementation. No changes will be applied. You can try enabling legacy implementation earlier.'\n );\n return;\n }\n\n useNewWebImplementation = !shouldUseLegacyImplementation;\n}\n\nexport function isNewWebImplementationEnabled(): boolean {\n getWasCalled = true;\n return useNewWebImplementation;\n}\n"]}

View File

@@ -0,0 +1,3 @@
import React from 'react';
export default /*#__PURE__*/React.createContext(false);
//# sourceMappingURL=GestureHandlerRootViewContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerRootViewContext.ts"],"names":["React","createContext"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,4BAAeA,KAAK,CAACC,aAAN,CAAoB,KAApB,CAAf","sourcesContent":["import React from 'react';\n\nexport default React.createContext(false);\n"]}

View File

@@ -0,0 +1,5 @@
var _NativeModules$Platfo;
import { NativeModules, Platform } from 'react-native';
export default (_NativeModules$Platfo = NativeModules === null || NativeModules === void 0 ? void 0 : NativeModules.PlatformConstants) !== null && _NativeModules$Platfo !== void 0 ? _NativeModules$Platfo : Platform.constants;
//# sourceMappingURL=PlatformConstants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PlatformConstants.ts"],"names":["NativeModules","Platform","PlatformConstants","constants"],"mappings":";;AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AAMA,wCAAgBD,aAAhB,aAAgBA,aAAhB,uBAAgBA,aAAa,CAAEE,iBAA/B,yEACED,QAAQ,CAACE,SADX","sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\ntype PlatformConstants = {\n forceTouchAvailable: boolean;\n};\n\nexport default (NativeModules?.PlatformConstants ??\n Platform.constants) as PlatformConstants;\n"]}

View File

@@ -0,0 +1,7 @@
export default {
get forceTouchAvailable() {
return false;
}
};
//# sourceMappingURL=PlatformConstants.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PlatformConstants.web.ts"],"names":["forceTouchAvailable"],"mappings":"AAAA,eAAe;AACb,MAAIA,mBAAJ,GAA0B;AACxB,WAAO,KAAP;AACD;;AAHY,CAAf","sourcesContent":["export default {\n get forceTouchAvailable() {\n return false;\n },\n};\n"]}

View File

@@ -0,0 +1,9 @@
export let PointerType;
(function (PointerType) {
PointerType[PointerType["TOUCH"] = 0] = "TOUCH";
PointerType[PointerType["STYLUS"] = 1] = "STYLUS";
PointerType[PointerType["MOUSE"] = 2] = "MOUSE";
PointerType[PointerType["OTHER"] = 3] = "OTHER";
})(PointerType || (PointerType = {}));
//# sourceMappingURL=PointerType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PointerType.ts"],"names":["PointerType"],"mappings":"AAAA,WAAYA,WAAZ;;WAAYA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,KAAAA,W","sourcesContent":["export enum PointerType {\n TOUCH,\n STYLUS,\n MOUSE,\n OTHER,\n}\n"]}

View File

@@ -0,0 +1,5 @@
// Reexport the native module spec used by codegen. The relevant files are inluded on Android
// to ensure the compatibility with the old arch, while iOS doesn't require those at all.
import Module from './specs/NativeRNGestureHandlerModule';
export default Module;
//# sourceMappingURL=RNGestureHandlerModule.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["RNGestureHandlerModule.ts"],"names":["Module"],"mappings":"AAAA;AACA;AAEA,OAAOA,MAAP,MAAmB,sCAAnB;AACA,eAAeA,MAAf","sourcesContent":["// Reexport the native module spec used by codegen. The relevant files are inluded on Android\n// to ensure the compatibility with the old arch, while iOS doesn't require those at all.\n\nimport Module from './specs/NativeRNGestureHandlerModule';\nexport default Module;\n"]}

View File

@@ -0,0 +1,85 @@
import React from 'react';
import { isNewWebImplementationEnabled } from './EnableNewWebImplementation';
import { Gestures, HammerGestures } from './web/Gestures';
import InteractionManager from './web/tools/InteractionManager';
import NodeManager from './web/tools/NodeManager';
import * as HammerNodeManager from './web_hammer/NodeManager';
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
export default {
handleSetJSResponder(tag, blockNativeResponder) {
console.warn('handleSetJSResponder: ', tag, blockNativeResponder);
},
handleClearJSResponder() {
console.warn('handleClearJSResponder: ');
},
createGestureHandler(handlerName, handlerTag, config) {
if (isNewWebImplementationEnabled()) {
if (!(handlerName in Gestures)) {
throw new Error(`react-native-gesture-handler: ${handlerName} is not supported on web.`);
}
const GestureClass = Gestures[handlerName];
NodeManager.createGestureHandler(handlerTag, new GestureClass(new GestureHandlerWebDelegate()));
InteractionManager.getInstance().configureInteractions(NodeManager.getHandler(handlerTag), config);
} else {
if (!(handlerName in HammerGestures)) {
throw new Error(`react-native-gesture-handler: ${handlerName} is not supported on web.`);
} // @ts-ignore If it doesn't exist, the error is thrown
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const GestureClass = HammerGestures[handlerName]; // eslint-disable-next-line @typescript-eslint/no-unsafe-call
HammerNodeManager.createGestureHandler(handlerTag, new GestureClass());
}
this.updateGestureHandler(handlerTag, config);
},
attachGestureHandler(handlerTag, // eslint-disable-next-line @typescript-eslint/no-explicit-any
newView, _actionType, propsRef) {
if (!(newView instanceof HTMLElement || newView instanceof React.Component)) {
return;
}
if (isNewWebImplementationEnabled()) {
//@ts-ignore Types should be HTMLElement or React.Component
NodeManager.getHandler(handlerTag).init(newView, propsRef);
} else {
//@ts-ignore Types should be HTMLElement or React.Component
HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef);
}
},
updateGestureHandler(handlerTag, newConfig) {
if (isNewWebImplementationEnabled()) {
NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
InteractionManager.getInstance().configureInteractions(NodeManager.getHandler(handlerTag), newConfig);
} else {
HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
}
},
getGestureHandlerNode(handlerTag) {
if (isNewWebImplementationEnabled()) {
return NodeManager.getHandler(handlerTag);
} else {
return HammerNodeManager.getHandler(handlerTag);
}
},
dropGestureHandler(handlerTag) {
if (isNewWebImplementationEnabled()) {
NodeManager.dropGestureHandler(handlerTag);
} else {
HammerNodeManager.dropGestureHandler(handlerTag);
}
},
// eslint-disable-next-line @typescript-eslint/no-empty-function
flushOperations() {}
};
//# sourceMappingURL=RNGestureHandlerModule.web.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,47 @@
// GestureHandlers
import PanGestureHandler from './web/handlers/PanGestureHandler';
import TapGestureHandler from './web/handlers/TapGestureHandler';
import LongPressGestureHandler from './web/handlers/LongPressGestureHandler';
import PinchGestureHandler from './web/handlers/PinchGestureHandler';
import RotationGestureHandler from './web/handlers/RotationGestureHandler';
import FlingGestureHandler from './web/handlers/FlingGestureHandler';
import NativeViewGestureHandler from './web/handlers/NativeViewGestureHandler';
import ManualGestureHandler from './web/handlers/ManualGestureHandler';
export const Gestures = {
NativeViewGestureHandler,
PanGestureHandler,
TapGestureHandler,
LongPressGestureHandler,
PinchGestureHandler,
RotationGestureHandler,
FlingGestureHandler,
ManualGestureHandler
};
export default {
handleSetJSResponder(_tag, _blockNativeResponder) {// NO-OP
},
handleClearJSResponder() {// NO-OP
},
createGestureHandler(_handlerName, _handlerTag, _config) {// NO-OP
},
attachGestureHandler(_handlerTag, // eslint-disable-next-line @typescript-eslint/no-explicit-any
_newView, _actionType, _propsRef) {// NO-OP
},
updateGestureHandler(_handlerTag, _newConfig) {// NO-OP
},
getGestureHandlerNode(_handlerTag) {// NO-OP
},
dropGestureHandler(_handlerTag) {// NO-OP
},
flushOperations() {// NO-OP
}
};
//# sourceMappingURL=RNGestureHandlerModule.windows.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["RNGestureHandlerModule.windows.ts"],"names":["PanGestureHandler","TapGestureHandler","LongPressGestureHandler","PinchGestureHandler","RotationGestureHandler","FlingGestureHandler","NativeViewGestureHandler","ManualGestureHandler","Gestures","handleSetJSResponder","_tag","_blockNativeResponder","handleClearJSResponder","createGestureHandler","_handlerName","_handlerTag","_config","attachGestureHandler","_newView","_actionType","_propsRef","updateGestureHandler","_newConfig","getGestureHandlerNode","dropGestureHandler","flushOperations"],"mappings":"AAIA;AACA,OAAOA,iBAAP,MAA8B,kCAA9B;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,OAAOC,uBAAP,MAAoC,wCAApC;AACA,OAAOC,mBAAP,MAAgC,oCAAhC;AACA,OAAOC,sBAAP,MAAmC,uCAAnC;AACA,OAAOC,mBAAP,MAAgC,oCAAhC;AACA,OAAOC,wBAAP,MAAqC,yCAArC;AACA,OAAOC,oBAAP,MAAiC,qCAAjC;AAGA,OAAO,MAAMC,QAAQ,GAAG;AACtBF,EAAAA,wBADsB;AAEtBN,EAAAA,iBAFsB;AAGtBC,EAAAA,iBAHsB;AAItBC,EAAAA,uBAJsB;AAKtBC,EAAAA,mBALsB;AAMtBC,EAAAA,sBANsB;AAOtBC,EAAAA,mBAPsB;AAQtBE,EAAAA;AARsB,CAAjB;AAWP,eAAe;AACbE,EAAAA,oBAAoB,CAACC,IAAD,EAAeC,qBAAf,EAA+C,CACjE;AACD,GAHY;;AAIbC,EAAAA,sBAAsB,GAAG,CACvB;AACD,GANY;;AAObC,EAAAA,oBAAoB,CAClBC,YADkB,EAElBC,WAFkB,EAGlBC,OAHkB,EAIlB,CACA;AACD,GAbY;;AAcbC,EAAAA,oBAAoB,CAClBF,WADkB,EAElB;AACAG,EAAAA,QAHkB,EAIlBC,WAJkB,EAKlBC,SALkB,EAMlB,CACA;AACD,GAtBY;;AAuBbC,EAAAA,oBAAoB,CAACN,WAAD,EAAsBO,UAAtB,EAA0C,CAC5D;AACD,GAzBY;;AA0BbC,EAAAA,qBAAqB,CAACR,WAAD,EAAsB,CACzC;AACD,GA5BY;;AA6BbS,EAAAA,kBAAkB,CAACT,WAAD,EAAsB,CACtC;AACD,GA/BY;;AAgCbU,EAAAA,eAAe,GAAG,CAChB;AACD;;AAlCY,CAAf","sourcesContent":["import React from 'react';\n\nimport { ActionType } from './ActionType';\n\n// GestureHandlers\nimport PanGestureHandler from './web/handlers/PanGestureHandler';\nimport TapGestureHandler from './web/handlers/TapGestureHandler';\nimport LongPressGestureHandler from './web/handlers/LongPressGestureHandler';\nimport PinchGestureHandler from './web/handlers/PinchGestureHandler';\nimport RotationGestureHandler from './web/handlers/RotationGestureHandler';\nimport FlingGestureHandler from './web/handlers/FlingGestureHandler';\nimport NativeViewGestureHandler from './web/handlers/NativeViewGestureHandler';\nimport ManualGestureHandler from './web/handlers/ManualGestureHandler';\nimport { Config } from './web/interfaces';\n\nexport const Gestures = {\n NativeViewGestureHandler,\n PanGestureHandler,\n TapGestureHandler,\n LongPressGestureHandler,\n PinchGestureHandler,\n RotationGestureHandler,\n FlingGestureHandler,\n ManualGestureHandler,\n};\n\nexport default {\n handleSetJSResponder(_tag: number, _blockNativeResponder: boolean) {\n // NO-OP\n },\n handleClearJSResponder() {\n // NO-OP\n },\n createGestureHandler<T>(\n _handlerName: keyof typeof Gestures,\n _handlerTag: number,\n _config: T\n ) {\n // NO-OP\n },\n attachGestureHandler(\n _handlerTag: number,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _newView: any,\n _actionType: ActionType,\n _propsRef: React.RefObject<unknown>\n ) {\n // NO-OP\n },\n updateGestureHandler(_handlerTag: number, _newConfig: Config) {\n // NO-OP\n },\n getGestureHandlerNode(_handlerTag: number) {\n // NO-OP\n },\n dropGestureHandler(_handlerTag: number) {\n // NO-OP\n },\n flushOperations() {\n // NO-OP\n },\n};\n"]}

View File

@@ -0,0 +1,4 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
export { default as RNRenderer } from 'react-native/Libraries/Renderer/shims/ReactNative';
//# sourceMappingURL=RNRenderer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["RNRenderer.ts"],"names":["default","RNRenderer"],"mappings":"AAAA;AACA;AACA,SAASA,OAAO,IAAIC,UAApB,QAAsC,mDAAtC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nexport { default as RNRenderer } from 'react-native/Libraries/Renderer/shims/ReactNative';\n"]}

View File

@@ -0,0 +1,4 @@
export const RNRenderer = {
findHostInstance_DEPRECATED: _ref => null
};
//# sourceMappingURL=RNRenderer.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["RNRenderer.web.ts"],"names":["RNRenderer","findHostInstance_DEPRECATED","_ref"],"mappings":"AAAA,OAAO,MAAMA,UAAU,GAAG;AACxBC,EAAAA,2BAA2B,EAAGC,IAAD,IAAe;AADpB,CAAnB","sourcesContent":["export const RNRenderer = {\n findHostInstance_DEPRECATED: (_ref: any) => null,\n};\n"]}

View File

@@ -0,0 +1,10 @@
// TODO use State from RNModule
export const State = {
UNDETERMINED: 0,
FAILED: 1,
BEGAN: 2,
CANCELLED: 3,
ACTIVE: 4,
END: 5
}; // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
//# sourceMappingURL=State.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["State.ts"],"names":["State","UNDETERMINED","FAILED","BEGAN","CANCELLED","ACTIVE","END"],"mappings":"AAAA;AAEA,OAAO,MAAMA,KAAK,GAAG;AACnBC,EAAAA,YAAY,EAAE,CADK;AAEnBC,EAAAA,MAAM,EAAE,CAFW;AAGnBC,EAAAA,KAAK,EAAE,CAHY;AAInBC,EAAAA,SAAS,EAAE,CAJQ;AAKnBC,EAAAA,MAAM,EAAE,CALW;AAMnBC,EAAAA,GAAG,EAAE;AANc,CAAd,C,CASP","sourcesContent":["// TODO use State from RNModule\n\nexport const State = {\n UNDETERMINED: 0,\n FAILED: 1,\n BEGAN: 2,\n CANCELLED: 3,\n ACTIVE: 4,\n END: 5,\n} as const;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value\nexport type State = typeof State[keyof typeof State];\n"]}

View File

@@ -0,0 +1,8 @@
export const TouchEventType = {
UNDETERMINED: 0,
TOUCHES_DOWN: 1,
TOUCHES_MOVE: 2,
TOUCHES_UP: 3,
TOUCHES_CANCELLED: 4
}; // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
//# sourceMappingURL=TouchEventType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["TouchEventType.ts"],"names":["TouchEventType","UNDETERMINED","TOUCHES_DOWN","TOUCHES_MOVE","TOUCHES_UP","TOUCHES_CANCELLED"],"mappings":"AAAA,OAAO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,YAAY,EAAE,CADc;AAE5BC,EAAAA,YAAY,EAAE,CAFc;AAG5BC,EAAAA,YAAY,EAAE,CAHc;AAI5BC,EAAAA,UAAU,EAAE,CAJgB;AAK5BC,EAAAA,iBAAiB,EAAE;AALS,CAAvB,C,CAQP","sourcesContent":["export const TouchEventType = {\n UNDETERMINED: 0,\n TOUCHES_DOWN: 1,\n TOUCHES_MOVE: 2,\n TOUCHES_UP: 3,\n TOUCHES_CANCELLED: 4,\n} as const;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value\nexport type TouchEventType = typeof TouchEventType[keyof typeof TouchEventType];\n"]}

View File

@@ -0,0 +1,553 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// This component is based on RN's DrawerLayoutAndroid API
//
// It perhaps deserves to be put in a separate repo, but since it relies on
// react-native-gesture-handler library which isn't very popular at the moment I
// decided to keep it here for the time being. It will allow us to move faster
// and fix issues that may arise in gesture handler library that could be found
// when using the drawer component
import * as React from 'react';
import { Component } from 'react';
import invariant from 'invariant';
import { Animated, StyleSheet, View, Keyboard, StatusBar, I18nManager } from 'react-native';
import { PanGestureHandler } from '../handlers/PanGestureHandler';
import { TapGestureHandler } from '../handlers/TapGestureHandler';
import { State } from '../State';
const DRAG_TOSS = 0.05;
const IDLE = 'Idle';
const DRAGGING = 'Dragging';
const SETTLING = 'Settling';
export default class DrawerLayout extends Component {
constructor(_props) {
super(_props);
_defineProperty(this, "openValue", void 0);
_defineProperty(this, "onGestureEvent", void 0);
_defineProperty(this, "accessibilityIsModalView", /*#__PURE__*/React.createRef());
_defineProperty(this, "pointerEventsView", /*#__PURE__*/React.createRef());
_defineProperty(this, "panGestureHandler", /*#__PURE__*/React.createRef());
_defineProperty(this, "drawerShown", false);
_defineProperty(this, "updateAnimatedEvent", (props, state) => {
// Event definition is based on
const {
drawerPosition,
drawerWidth,
drawerType
} = props;
const {
dragX: dragXValue,
touchX: touchXValue,
drawerTranslation,
containerWidth
} = state;
let dragX = dragXValue;
let touchX = touchXValue;
if (drawerPosition !== 'left') {
// Most of the code is written in a way to handle left-side drawer. In
// order to handle right-side drawer the only thing we need to do is to
// reverse events coming from gesture handler in a way they emulate
// left-side drawer gestures. E.g. dragX is simply -dragX, and touchX is
// calulcated by subtracing real touchX from the width of the container
// (such that when touch happens at the right edge the value is simply 0)
dragX = Animated.multiply(new Animated.Value(-1), dragXValue); // TODO(TS): (for all "as" in this file) make sure we can map this
touchX = Animated.add(new Animated.Value(containerWidth), Animated.multiply(new Animated.Value(-1), touchXValue)); // TODO(TS): make sure we can map this;
touchXValue.setValue(containerWidth);
} else {
touchXValue.setValue(0);
} // While closing the drawer when user starts gesture outside of its area (in greyed
// out part of the window), we want the drawer to follow only once finger reaches the
// edge of the drawer.
// E.g. on the diagram below drawer is illustrate by X signs and the greyed out area by
// dots. The touch gesture starts at '*' and moves left, touch path is indicated by
// an arrow pointing left
// 1) +---------------+ 2) +---------------+ 3) +---------------+ 4) +---------------+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
// |XXXXXXXX|......| |XXXXXXXX|.<-*..| |XXXXXXXX|<--*..| |XXXXX|<-----*..|
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
// +---------------+ +---------------+ +---------------+ +---------------+
//
// For the above to work properly we define animated value that will keep
// start position of the gesture. Then we use that value to calculate how
// much we need to subtract from the dragX. If the gesture started on the
// greyed out area we take the distance from the edge of the drawer to the
// start position. Otherwise we don't subtract at all and the drawer be
// pulled back as soon as you start the pan.
//
// This is used only when drawerType is "front"
//
let translationX = dragX;
if (drawerType === 'front') {
const startPositionX = Animated.add(touchX, Animated.multiply(new Animated.Value(-1), dragX));
const dragOffsetFromOnStartPosition = startPositionX.interpolate({
inputRange: [drawerWidth - 1, drawerWidth, drawerWidth + 1],
outputRange: [0, 0, 1]
});
translationX = Animated.add(dragX, dragOffsetFromOnStartPosition); // TODO: as above
}
this.openValue = Animated.add(translationX, drawerTranslation).interpolate({
inputRange: [0, drawerWidth],
outputRange: [0, 1],
extrapolate: 'clamp'
});
const gestureOptions = {
useNativeDriver: props.useNativeAnimations
};
if (this.props.onDrawerSlide) {
gestureOptions.listener = ev => {
var _this$props$onDrawerS, _this$props;
const translationX = Math.floor(Math.abs(ev.nativeEvent.translationX));
const position = translationX / this.state.containerWidth;
(_this$props$onDrawerS = (_this$props = this.props).onDrawerSlide) === null || _this$props$onDrawerS === void 0 ? void 0 : _this$props$onDrawerS.call(_this$props, position);
};
}
this.onGestureEvent = Animated.event([{
nativeEvent: {
translationX: dragXValue,
x: touchXValue
}
}], gestureOptions);
});
_defineProperty(this, "handleContainerLayout", ({
nativeEvent
}) => {
this.setState({
containerWidth: nativeEvent.layout.width
});
});
_defineProperty(this, "emitStateChanged", (newState, drawerWillShow) => {
var _this$props$onDrawerS2, _this$props2;
(_this$props$onDrawerS2 = (_this$props2 = this.props).onDrawerStateChanged) === null || _this$props$onDrawerS2 === void 0 ? void 0 : _this$props$onDrawerS2.call(_this$props2, newState, drawerWillShow);
});
_defineProperty(this, "openingHandlerStateChange", ({
nativeEvent
}) => {
if (nativeEvent.oldState === State.ACTIVE) {
this.handleRelease({
nativeEvent
});
} else if (nativeEvent.state === State.ACTIVE) {
this.emitStateChanged(DRAGGING, false);
this.setState({
drawerState: DRAGGING
});
if (this.props.keyboardDismissMode === 'on-drag') {
Keyboard.dismiss();
}
if (this.props.hideStatusBar) {
StatusBar.setHidden(true, this.props.statusBarAnimation || 'slide');
}
}
});
_defineProperty(this, "onTapHandlerStateChange", ({
nativeEvent
}) => {
if (this.drawerShown && nativeEvent.oldState === State.ACTIVE && this.props.drawerLockMode !== 'locked-open') {
this.closeDrawer();
}
});
_defineProperty(this, "handleRelease", ({
nativeEvent
}) => {
const {
drawerWidth,
drawerPosition,
drawerType
} = this.props;
const {
containerWidth
} = this.state;
let {
translationX: dragX,
velocityX,
x: touchX
} = nativeEvent;
if (drawerPosition !== 'left') {
// See description in _updateAnimatedEvent about why events are flipped
// for right-side drawer
dragX = -dragX;
touchX = containerWidth - touchX;
velocityX = -velocityX;
}
const gestureStartX = touchX - dragX;
let dragOffsetBasedOnStart = 0;
if (drawerType === 'front') {
dragOffsetBasedOnStart = gestureStartX > drawerWidth ? gestureStartX - drawerWidth : 0;
}
const startOffsetX = dragX + dragOffsetBasedOnStart + (this.drawerShown ? drawerWidth : 0);
const projOffsetX = startOffsetX + DRAG_TOSS * velocityX;
const shouldOpen = projOffsetX > drawerWidth / 2;
if (shouldOpen) {
this.animateDrawer(startOffsetX, drawerWidth, velocityX);
} else {
this.animateDrawer(startOffsetX, 0, velocityX);
}
});
_defineProperty(this, "updateShowing", showing => {
var _this$accessibilityIs, _this$pointerEventsVi, _this$panGestureHandl;
this.drawerShown = showing;
(_this$accessibilityIs = this.accessibilityIsModalView.current) === null || _this$accessibilityIs === void 0 ? void 0 : _this$accessibilityIs.setNativeProps({
accessibilityViewIsModal: showing
});
(_this$pointerEventsVi = this.pointerEventsView.current) === null || _this$pointerEventsVi === void 0 ? void 0 : _this$pointerEventsVi.setNativeProps({
pointerEvents: showing ? 'auto' : 'none'
});
const {
drawerPosition,
minSwipeDistance,
edgeWidth
} = this.props;
const fromLeft = drawerPosition === 'left'; // gestureOrientation is 1 if the expected gesture is from left to right and
// -1 otherwise e.g. when drawer is on the left and is closed we expect left
// to right gesture, thus orientation will be 1.
const gestureOrientation = (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1); // When drawer is closed we want the hitSlop to be horizontally shorter than
// the container size by the value of SLOP. This will make it only activate
// when gesture happens not further than SLOP away from the edge
const hitSlop = fromLeft ? {
left: 0,
width: showing ? undefined : edgeWidth
} : {
right: 0,
width: showing ? undefined : edgeWidth
}; // @ts-ignore internal API, maybe could be fixed in handler types
(_this$panGestureHandl = this.panGestureHandler.current) === null || _this$panGestureHandl === void 0 ? void 0 : _this$panGestureHandl.setNativeProps({
hitSlop,
activeOffsetX: gestureOrientation * minSwipeDistance
});
});
_defineProperty(this, "animateDrawer", (fromValue, toValue, velocity, speed) => {
this.state.dragX.setValue(0);
this.state.touchX.setValue(this.props.drawerPosition === 'left' ? 0 : this.state.containerWidth);
if (fromValue != null) {
let nextFramePosition = fromValue;
if (this.props.useNativeAnimations) {
// When using native driver, we predict the next position of the
// animation because it takes one frame of a roundtrip to pass RELEASE
// event from native driver to JS before we can start animating. Without
// it, it is more noticable that the frame is dropped.
if (fromValue < toValue && velocity > 0) {
nextFramePosition = Math.min(fromValue + velocity / 60.0, toValue);
} else if (fromValue > toValue && velocity < 0) {
nextFramePosition = Math.max(fromValue + velocity / 60.0, toValue);
}
}
this.state.drawerTranslation.setValue(nextFramePosition);
}
const willShow = toValue !== 0;
this.updateShowing(willShow);
this.emitStateChanged(SETTLING, willShow);
this.setState({
drawerState: SETTLING
});
if (this.props.hideStatusBar) {
StatusBar.setHidden(willShow, this.props.statusBarAnimation || 'slide');
}
Animated.spring(this.state.drawerTranslation, {
velocity,
bounciness: 0,
toValue,
useNativeDriver: this.props.useNativeAnimations,
speed: speed !== null && speed !== void 0 ? speed : undefined
}).start(({
finished
}) => {
if (finished) {
this.emitStateChanged(IDLE, willShow);
this.setState({
drawerOpened: willShow
});
if (this.state.drawerState !== DRAGGING) {
// it's possilbe that user started drag while the drawer
// was settling, don't override state in this case
this.setState({
drawerState: IDLE
});
}
if (willShow) {
var _this$props$onDrawerO, _this$props3;
(_this$props$onDrawerO = (_this$props3 = this.props).onDrawerOpen) === null || _this$props$onDrawerO === void 0 ? void 0 : _this$props$onDrawerO.call(_this$props3);
} else {
var _this$props$onDrawerC, _this$props4;
(_this$props$onDrawerC = (_this$props4 = this.props).onDrawerClose) === null || _this$props$onDrawerC === void 0 ? void 0 : _this$props$onDrawerC.call(_this$props4);
}
}
});
});
_defineProperty(this, "openDrawer", (options = {}) => {
this.animateDrawer( // TODO: decide if it should be null or undefined is the proper value
undefined, this.props.drawerWidth, options.velocity ? options.velocity : 0, options.speed); // We need to force the update, otherwise the overlay is not rerendered and
// it would not be clickable
this.forceUpdate();
});
_defineProperty(this, "closeDrawer", (options = {}) => {
// TODO: decide if it should be null or undefined is the proper value
this.animateDrawer(undefined, 0, options.velocity ? options.velocity : 0, options.speed); // We need to force the update, otherwise the overlay is not rerendered and
// it would be still clickable
this.forceUpdate();
});
_defineProperty(this, "renderOverlay", () => {
/* Overlay styles */
invariant(this.openValue, 'should be set');
let overlayOpacity;
if (this.state.drawerState !== IDLE) {
overlayOpacity = this.openValue;
} else {
overlayOpacity = this.state.drawerOpened ? 1 : 0;
}
const dynamicOverlayStyles = {
opacity: overlayOpacity,
backgroundColor: this.props.overlayColor
};
return /*#__PURE__*/React.createElement(TapGestureHandler, {
onHandlerStateChange: this.onTapHandlerStateChange
}, /*#__PURE__*/React.createElement(Animated.View, {
pointerEvents: this.drawerShown ? 'auto' : 'none',
ref: this.pointerEventsView,
style: [styles.overlay, dynamicOverlayStyles]
}));
});
_defineProperty(this, "renderDrawer", () => {
const {
drawerBackgroundColor,
drawerWidth,
drawerPosition,
drawerType,
drawerContainerStyle,
contentContainerStyle
} = this.props;
const fromLeft = drawerPosition === 'left';
const drawerSlide = drawerType !== 'back';
const containerSlide = drawerType !== 'front'; // we rely on row and row-reverse flex directions to position the drawer
// properly. Apparently for RTL these are flipped which requires us to use
// the opposite setting for the drawer to appear from left or right
// according to the drawerPosition prop
const reverseContentDirection = I18nManager.isRTL ? fromLeft : !fromLeft;
const dynamicDrawerStyles = {
backgroundColor: drawerBackgroundColor,
width: drawerWidth
};
const openValue = this.openValue;
invariant(openValue, 'should be set');
let containerStyles;
if (containerSlide) {
const containerTranslateX = openValue.interpolate({
inputRange: [0, 1],
outputRange: fromLeft ? [0, drawerWidth] : [0, -drawerWidth],
extrapolate: 'clamp'
});
containerStyles = {
transform: [{
translateX: containerTranslateX
}]
};
}
let drawerTranslateX = 0;
if (drawerSlide) {
const closedDrawerOffset = fromLeft ? -drawerWidth : drawerWidth;
if (this.state.drawerState !== IDLE) {
drawerTranslateX = openValue.interpolate({
inputRange: [0, 1],
outputRange: [closedDrawerOffset, 0],
extrapolate: 'clamp'
});
} else {
drawerTranslateX = this.state.drawerOpened ? 0 : closedDrawerOffset;
}
}
const drawerStyles = {
transform: [{
translateX: drawerTranslateX
}],
flexDirection: reverseContentDirection ? 'row-reverse' : 'row'
};
return /*#__PURE__*/React.createElement(Animated.View, {
style: styles.main,
onLayout: this.handleContainerLayout
}, /*#__PURE__*/React.createElement(Animated.View, {
style: [drawerType === 'front' ? styles.containerOnBack : styles.containerInFront, containerStyles, contentContainerStyle],
importantForAccessibility: this.drawerShown ? 'no-hide-descendants' : 'yes'
}, typeof this.props.children === 'function' ? this.props.children(this.openValue) : this.props.children, this.renderOverlay()), /*#__PURE__*/React.createElement(Animated.View, {
pointerEvents: "box-none",
ref: this.accessibilityIsModalView,
accessibilityViewIsModal: this.drawerShown,
style: [styles.drawerContainer, drawerStyles, drawerContainerStyle]
}, /*#__PURE__*/React.createElement(View, {
style: dynamicDrawerStyles
}, this.props.renderNavigationView(this.openValue))));
});
_defineProperty(this, "setPanGestureRef", ref => {
var _this$props$onGesture, _this$props5;
// TODO(TS): make sure it is OK taken from
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31065#issuecomment-596081842
this.panGestureHandler.current = ref;
(_this$props$onGesture = (_this$props5 = this.props).onGestureRef) === null || _this$props$onGesture === void 0 ? void 0 : _this$props$onGesture.call(_this$props5, ref);
});
const _dragX = new Animated.Value(0);
const _touchX = new Animated.Value(0);
const _drawerTranslation = new Animated.Value(0);
this.state = {
dragX: _dragX,
touchX: _touchX,
drawerTranslation: _drawerTranslation,
containerWidth: 0,
drawerState: IDLE,
drawerOpened: false
};
this.updateAnimatedEvent(_props, this.state);
}
shouldComponentUpdate(props, state) {
if (this.props.drawerPosition !== props.drawerPosition || this.props.drawerWidth !== props.drawerWidth || this.props.drawerType !== props.drawerType || this.state.containerWidth !== state.containerWidth) {
this.updateAnimatedEvent(props, state);
}
return true;
}
render() {
const {
drawerPosition,
drawerLockMode,
edgeWidth,
minSwipeDistance
} = this.props;
const fromLeft = drawerPosition === 'left'; // gestureOrientation is 1 if the expected gesture is from left to right and
// -1 otherwise e.g. when drawer is on the left and is closed we expect left
// to right gesture, thus orientation will be 1.
const gestureOrientation = (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1); // When drawer is closed we want the hitSlop to be horizontally shorter than
// the container size by the value of SLOP. This will make it only activate
// when gesture happens not further than SLOP away from the edge
const hitSlop = fromLeft ? {
left: 0,
width: this.drawerShown ? undefined : edgeWidth
} : {
right: 0,
width: this.drawerShown ? undefined : edgeWidth
};
return /*#__PURE__*/React.createElement(PanGestureHandler // @ts-ignore could be fixed in handler types
, {
userSelect: this.props.userSelect,
activeCursor: this.props.activeCursor,
mouseButton: this.props.mouseButton,
enableContextMenu: this.props.enableContextMenu,
ref: this.setPanGestureRef,
hitSlop: hitSlop,
activeOffsetX: gestureOrientation * minSwipeDistance,
failOffsetY: [-15, 15],
onGestureEvent: this.onGestureEvent,
onHandlerStateChange: this.openingHandlerStateChange,
enableTrackpadTwoFingerGesture: this.props.enableTrackpadTwoFingerGesture,
enabled: drawerLockMode !== 'locked-closed' && drawerLockMode !== 'locked-open'
}, this.renderDrawer());
}
}
_defineProperty(DrawerLayout, "defaultProps", {
drawerWidth: 200,
drawerPosition: 'left',
useNativeAnimations: true,
drawerType: 'front',
edgeWidth: 20,
minSwipeDistance: 3,
overlayColor: 'rgba(0, 0, 0, 0.7)',
drawerLockMode: 'unlocked',
enableTrackpadTwoFingerGesture: false
});
_defineProperty(DrawerLayout, "positions", {
Left: 'left',
Right: 'right'
});
const styles = StyleSheet.create({
drawerContainer: { ...StyleSheet.absoluteFillObject,
zIndex: 1001,
flexDirection: 'row'
},
containerInFront: { ...StyleSheet.absoluteFillObject,
zIndex: 1002
},
containerOnBack: { ...StyleSheet.absoluteFillObject
},
main: {
flex: 1,
zIndex: 0,
overflow: 'hidden'
},
overlay: { ...StyleSheet.absoluteFillObject,
zIndex: 1000
}
});
//# sourceMappingURL=DrawerLayout.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,206 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import * as React from 'react';
import { Animated, Platform, processColor, StyleSheet } from 'react-native';
import createNativeWrapper from '../handlers/createNativeWrapper';
import GestureHandlerButton from './GestureHandlerButton';
import { State } from '../State';
export const RawButton = createNativeWrapper(GestureHandlerButton, {
shouldCancelWhenOutside: false,
shouldActivateOnStart: false
});
export class BaseButton extends React.Component {
constructor(props) {
super(props);
_defineProperty(this, "lastActive", void 0);
_defineProperty(this, "longPressTimeout", void 0);
_defineProperty(this, "longPressDetected", void 0);
_defineProperty(this, "handleEvent", ({
nativeEvent
}) => {
const {
state,
oldState,
pointerInside
} = nativeEvent;
const active = pointerInside && state === State.ACTIVE;
if (active !== this.lastActive && this.props.onActiveStateChange) {
this.props.onActiveStateChange(active);
}
if (!this.longPressDetected && oldState === State.ACTIVE && state !== State.CANCELLED && this.lastActive && this.props.onPress) {
this.props.onPress(active);
}
if (!this.lastActive && // NativeViewGestureHandler sends different events based on platform
state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) && pointerInside) {
this.longPressDetected = false;
if (this.props.onLongPress) {
this.longPressTimeout = setTimeout(this.onLongPress, this.props.delayLongPress);
}
} else if ( // cancel longpress timeout if it's set and the finger moved out of the view
state === State.ACTIVE && !pointerInside && this.longPressTimeout !== undefined) {
clearTimeout(this.longPressTimeout);
this.longPressTimeout = undefined;
} else if ( // cancel longpress timeout if it's set and the gesture has finished
this.longPressTimeout !== undefined && (state === State.END || state === State.CANCELLED || state === State.FAILED)) {
clearTimeout(this.longPressTimeout);
this.longPressTimeout = undefined;
}
this.lastActive = active;
});
_defineProperty(this, "onLongPress", () => {
var _this$props$onLongPre, _this$props;
this.longPressDetected = true;
(_this$props$onLongPre = (_this$props = this.props).onLongPress) === null || _this$props$onLongPre === void 0 ? void 0 : _this$props$onLongPre.call(_this$props);
});
_defineProperty(this, "onHandlerStateChange", e => {
var _this$props$onHandler, _this$props2;
(_this$props$onHandler = (_this$props2 = this.props).onHandlerStateChange) === null || _this$props$onHandler === void 0 ? void 0 : _this$props$onHandler.call(_this$props2, e);
this.handleEvent(e);
});
_defineProperty(this, "onGestureEvent", e => {
var _this$props$onGesture, _this$props3;
(_this$props$onGesture = (_this$props3 = this.props).onGestureEvent) === null || _this$props$onGesture === void 0 ? void 0 : _this$props$onGesture.call(_this$props3, e);
this.handleEvent(e); // TODO: maybe it is not correct
});
this.lastActive = false;
this.longPressDetected = false;
}
render() {
const {
rippleColor,
...rest
} = this.props;
return /*#__PURE__*/React.createElement(RawButton, _extends({
rippleColor: processColor(rippleColor)
}, rest, {
onGestureEvent: this.onGestureEvent,
onHandlerStateChange: this.onHandlerStateChange
}));
}
}
_defineProperty(BaseButton, "defaultProps", {
delayLongPress: 600
});
const AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);
const btnStyles = StyleSheet.create({
underlay: {
position: 'absolute',
left: 0,
right: 0,
bottom: 0,
top: 0
}
});
export class RectButton extends React.Component {
constructor(props) {
super(props);
_defineProperty(this, "opacity", void 0);
_defineProperty(this, "onActiveStateChange", active => {
var _this$props$onActiveS, _this$props4;
if (Platform.OS !== 'android') {
this.opacity.setValue(active ? this.props.activeOpacity : 0);
}
(_this$props$onActiveS = (_this$props4 = this.props).onActiveStateChange) === null || _this$props$onActiveS === void 0 ? void 0 : _this$props$onActiveS.call(_this$props4, active);
});
this.opacity = new Animated.Value(0);
}
render() {
const {
children,
style,
...rest
} = this.props;
const resolvedStyle = StyleSheet.flatten(style !== null && style !== void 0 ? style : {});
return /*#__PURE__*/React.createElement(BaseButton, _extends({}, rest, {
style: resolvedStyle,
onActiveStateChange: this.onActiveStateChange
}), /*#__PURE__*/React.createElement(Animated.View, {
style: [btnStyles.underlay, {
opacity: this.opacity,
backgroundColor: this.props.underlayColor,
borderRadius: resolvedStyle.borderRadius,
borderTopLeftRadius: resolvedStyle.borderTopLeftRadius,
borderTopRightRadius: resolvedStyle.borderTopRightRadius,
borderBottomLeftRadius: resolvedStyle.borderBottomLeftRadius,
borderBottomRightRadius: resolvedStyle.borderBottomRightRadius
}]
}), children);
}
}
_defineProperty(RectButton, "defaultProps", {
activeOpacity: 0.105,
underlayColor: 'black'
});
export class BorderlessButton extends React.Component {
constructor(props) {
super(props);
_defineProperty(this, "opacity", void 0);
_defineProperty(this, "onActiveStateChange", active => {
var _this$props$onActiveS2, _this$props5;
if (Platform.OS !== 'android') {
this.opacity.setValue(active ? this.props.activeOpacity : 1);
}
(_this$props$onActiveS2 = (_this$props5 = this.props).onActiveStateChange) === null || _this$props$onActiveS2 === void 0 ? void 0 : _this$props$onActiveS2.call(_this$props5, active);
});
this.opacity = new Animated.Value(1);
}
render() {
const {
children,
style,
...rest
} = this.props;
return /*#__PURE__*/React.createElement(AnimatedBaseButton, _extends({}, rest, {
onActiveStateChange: this.onActiveStateChange,
style: [style, Platform.OS === 'ios' && {
opacity: this.opacity
}]
}), children);
}
}
_defineProperty(BorderlessButton, "defaultProps", {
activeOpacity: 0.3,
borderless: true
});
export { default as PureNativeButton } from './GestureHandlerButton';
//# sourceMappingURL=GestureButtons.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,90 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import { ScrollView as RNScrollView, Switch as RNSwitch, TextInput as RNTextInput, DrawerLayoutAndroid as RNDrawerLayoutAndroid, FlatList as RNFlatList, RefreshControl as RNRefreshControl } from 'react-native';
import createNativeWrapper from '../handlers/createNativeWrapper';
import { nativeViewProps } from '../handlers/NativeViewGestureHandler';
import { toArray } from '../utils';
export const RefreshControl = createNativeWrapper(RNRefreshControl, {
disallowInterruption: true,
shouldCancelWhenOutside: false
}); // eslint-disable-next-line @typescript-eslint/no-redeclare
const GHScrollView = createNativeWrapper(RNScrollView, {
disallowInterruption: true,
shouldCancelWhenOutside: false
});
export const ScrollView = /*#__PURE__*/React.forwardRef((props, ref) => {
const refreshControlGestureRef = React.useRef(null);
const {
refreshControl,
waitFor,
...rest
} = props;
return /*#__PURE__*/React.createElement(GHScrollView, _extends({}, rest, {
// @ts-ignore `ref` exists on `GHScrollView`
ref: ref,
waitFor: [...toArray(waitFor !== null && waitFor !== void 0 ? waitFor : []), refreshControlGestureRef] // @ts-ignore we don't pass `refreshing` prop as we only want to override the ref
,
refreshControl: refreshControl ? /*#__PURE__*/React.cloneElement(refreshControl, {
// @ts-ignore for reasons unknown to me, `ref` doesn't exist on the type inferred by TS
ref: refreshControlGestureRef
}) : undefined
}));
}); // backward type compatibility with https://github.com/software-mansion/react-native-gesture-handler/blob/db78d3ca7d48e8ba57482d3fe9b0a15aa79d9932/react-native-gesture-handler.d.ts#L440-L457
// include methods of wrapped components by creating an intersection type with the RN component instead of duplicating them.
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const Switch = createNativeWrapper(RNSwitch, {
shouldCancelWhenOutside: false,
shouldActivateOnStart: true,
disallowInterruption: true
}); // eslint-disable-next-line @typescript-eslint/no-redeclare
export const TextInput = createNativeWrapper(RNTextInput); // eslint-disable-next-line @typescript-eslint/no-redeclare
export const DrawerLayoutAndroid = createNativeWrapper(RNDrawerLayoutAndroid, {
disallowInterruption: true
}); // eslint-disable-next-line @typescript-eslint/no-redeclare
export const FlatList = /*#__PURE__*/React.forwardRef((props, ref) => {
const refreshControlGestureRef = React.useRef(null);
const {
waitFor,
refreshControl,
...rest
} = props;
const flatListProps = {};
const scrollViewProps = {};
for (const [propName, value] of Object.entries(rest)) {
// https://github.com/microsoft/TypeScript/issues/26255
if (nativeViewProps.includes(propName)) {
// @ts-ignore - this function cannot have generic type so we have to ignore this error
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
scrollViewProps[propName] = value;
} else {
// @ts-ignore - this function cannot have generic type so we have to ignore this error
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
flatListProps[propName] = value;
}
}
return (
/*#__PURE__*/
// @ts-ignore - this function cannot have generic type so we have to ignore this error
React.createElement(RNFlatList, _extends({
ref: ref
}, flatListProps, {
renderScrollComponent: scrollProps => /*#__PURE__*/React.createElement(ScrollView, _extends({}, scrollProps, scrollViewProps, {
waitFor: [...toArray(waitFor !== null && waitFor !== void 0 ? waitFor : []), refreshControlGestureRef]
})) // @ts-ignore we don't pass `refreshing` prop as we only want to override the ref
,
refreshControl: refreshControl ? /*#__PURE__*/React.cloneElement(refreshControl, {
// @ts-ignore for reasons unknown to me, `ref` doesn't exist on the type inferred by TS
ref: refreshControlGestureRef
}) : undefined
}))
);
}); // eslint-disable-next-line @typescript-eslint/no-redeclare
//# sourceMappingURL=GestureComponents.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,28 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import { FlatList as RNFlatList, Switch as RNSwitch, TextInput as RNTextInput, ScrollView as RNScrollView, View } from 'react-native';
import createNativeWrapper from '../handlers/createNativeWrapper';
export const ScrollView = createNativeWrapper(RNScrollView, {
disallowInterruption: false
});
export const Switch = createNativeWrapper(RNSwitch, {
shouldCancelWhenOutside: false,
shouldActivateOnStart: true,
disallowInterruption: true
});
export const TextInput = createNativeWrapper(RNTextInput);
export const DrawerLayoutAndroid = () => {
console.warn('DrawerLayoutAndroid is not supported on web!');
return /*#__PURE__*/React.createElement(View, null);
}; // RefreshControl is implemented as a functional component, rendering a View
// NativeViewGestureHandler needs to set a ref on its child, which cannot be done
// on functional components
export const RefreshControl = createNativeWrapper(View);
export const FlatList = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(RNFlatList, _extends({
ref: ref
}, props, {
renderScrollComponent: scrollProps => /*#__PURE__*/React.createElement(ScrollView, scrollProps)
})));
//# sourceMappingURL=GestureComponents.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureComponents.web.tsx"],"names":["React","FlatList","RNFlatList","Switch","RNSwitch","TextInput","RNTextInput","ScrollView","RNScrollView","View","createNativeWrapper","disallowInterruption","shouldCancelWhenOutside","shouldActivateOnStart","DrawerLayoutAndroid","console","warn","RefreshControl","forwardRef","props","ref","scrollProps"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QAAQ,IAAIC,UADd,EAEEC,MAAM,IAAIC,QAFZ,EAGEC,SAAS,IAAIC,WAHf,EAIEC,UAAU,IAAIC,YAJhB,EAMEC,IANF,QAOO,cAPP;AASA,OAAOC,mBAAP,MAAgC,iCAAhC;AAEA,OAAO,MAAMH,UAAU,GAAGG,mBAAmB,CAACF,YAAD,EAAe;AAC1DG,EAAAA,oBAAoB,EAAE;AADoC,CAAf,CAAtC;AAIP,OAAO,MAAMR,MAAM,GAAGO,mBAAmB,CAACN,QAAD,EAAW;AAClDQ,EAAAA,uBAAuB,EAAE,KADyB;AAElDC,EAAAA,qBAAqB,EAAE,IAF2B;AAGlDF,EAAAA,oBAAoB,EAAE;AAH4B,CAAX,CAAlC;AAKP,OAAO,MAAMN,SAAS,GAAGK,mBAAmB,CAACJ,WAAD,CAArC;AACP,OAAO,MAAMQ,mBAAmB,GAAG,MAAM;AACvCC,EAAAA,OAAO,CAACC,IAAR,CAAa,8CAAb;AACA,sBAAO,oBAAC,IAAD,OAAP;AACD,CAHM,C,CAKP;AACA;AACA;;AACA,OAAO,MAAMC,cAAc,GAAGP,mBAAmB,CAACD,IAAD,CAA1C;AAEP,OAAO,MAAMR,QAAQ,gBAAGD,KAAK,CAACkB,UAAN,CACtB,CAAoBC,KAApB,EAAiDC,GAAjD,kBACE,oBAAC,UAAD;AACE,EAAA,GAAG,EAAEA;AADP,GAEMD,KAFN;AAGE,EAAA,qBAAqB,EAAGE,WAAD,iBAAiB,oBAAC,UAAD,EAAgBA,WAAhB;AAH1C,GAFoB,CAAjB","sourcesContent":["import * as React from 'react';\nimport {\n FlatList as RNFlatList,\n Switch as RNSwitch,\n TextInput as RNTextInput,\n ScrollView as RNScrollView,\n FlatListProps,\n View,\n} from 'react-native';\n\nimport createNativeWrapper from '../handlers/createNativeWrapper';\n\nexport const ScrollView = createNativeWrapper(RNScrollView, {\n disallowInterruption: false,\n});\n\nexport const Switch = createNativeWrapper(RNSwitch, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: true,\n disallowInterruption: true,\n});\nexport const TextInput = createNativeWrapper(RNTextInput);\nexport const DrawerLayoutAndroid = () => {\n console.warn('DrawerLayoutAndroid is not supported on web!');\n return <View />;\n};\n\n// RefreshControl is implemented as a functional component, rendering a View\n// NativeViewGestureHandler needs to set a ref on its child, which cannot be done\n// on functional components\nexport const RefreshControl = createNativeWrapper(View);\n\nexport const FlatList = React.forwardRef(\n <ItemT extends any>(props: FlatListProps<ItemT>, ref: any) => (\n <RNFlatList\n ref={ref}\n {...props}\n renderScrollComponent={(scrollProps) => <ScrollView {...scrollProps} />}\n />\n )\n);\n"]}

View File

@@ -0,0 +1,3 @@
import RNGestureHandlerButtonNativeComponent from '../specs/RNGestureHandlerButtonNativeComponent';
export default RNGestureHandlerButtonNativeComponent;
//# sourceMappingURL=GestureHandlerButton.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerButton.tsx"],"names":["RNGestureHandlerButtonNativeComponent"],"mappings":"AAEA,OAAOA,qCAAP,MAAkD,gDAAlD;AAEA,eAAeA,qCAAf","sourcesContent":["import { HostComponent } from 'react-native';\nimport { RawButtonProps } from './GestureButtons';\nimport RNGestureHandlerButtonNativeComponent from '../specs/RNGestureHandlerButtonNativeComponent';\n\nexport default RNGestureHandlerButtonNativeComponent as HostComponent<RawButtonProps>;\n"]}

View File

@@ -0,0 +1,9 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import { View } from 'react-native';
export default /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(View, _extends({
ref: ref,
accessibilityRole: "button"
}, props)));
//# sourceMappingURL=GestureHandlerButton.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerButton.web.tsx"],"names":["React","View","forwardRef","props","ref"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,4BAAeD,KAAK,CAACE,UAAN,CAAuB,CAACC,KAAD,EAAQC,GAAR,kBACpC,oBAAC,IAAD;AAAM,EAAA,GAAG,EAAEA,GAAX;AAAgB,EAAA,iBAAiB,EAAC;AAAlC,GAA+CD,KAA/C,EADa,CAAf","sourcesContent":["import * as React from 'react';\nimport { View } from 'react-native';\n\nexport default React.forwardRef<View>((props, ref) => (\n <View ref={ref} accessibilityRole=\"button\" {...props} />\n));\n"]}

View File

@@ -0,0 +1,27 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import { StyleSheet } from 'react-native';
import { maybeInitializeFabric } from '../init';
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
import GestureHandlerRootViewNativeComponent from '../specs/RNGestureHandlerRootViewNativeComponent';
export default function GestureHandlerRootView({
style,
...rest
}) {
// try initialize fabric on the first render, at this point we can
// reliably check if fabric is enabled (the function contains a flag
// to make sure it's called only once)
maybeInitializeFabric();
return /*#__PURE__*/React.createElement(GestureHandlerRootViewContext.Provider, {
value: true
}, /*#__PURE__*/React.createElement(GestureHandlerRootViewNativeComponent, _extends({
style: style !== null && style !== void 0 ? style : styles.container
}, rest)));
}
const styles = StyleSheet.create({
container: {
flex: 1
}
});
//# sourceMappingURL=GestureHandlerRootView.android.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerRootView.android.tsx"],"names":["React","StyleSheet","maybeInitializeFabric","GestureHandlerRootViewContext","GestureHandlerRootViewNativeComponent","GestureHandlerRootView","style","rest","styles","container","create","flex"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAAoBC,UAApB,QAAsC,cAAtC;AACA,SAASC,qBAAT,QAAsC,SAAtC;AACA,OAAOC,6BAAP,MAA0C,kCAA1C;AACA,OAAOC,qCAAP,MAAkD,kDAAlD;AAKA,eAAe,SAASC,sBAAT,CAAgC;AAC7CC,EAAAA,KAD6C;AAE7C,KAAGC;AAF0C,CAAhC,EAGiB;AAC9B;AACA;AACA;AACAL,EAAAA,qBAAqB;AAErB,sBACE,oBAAC,6BAAD,CAA+B,QAA/B;AAAwC,IAAA,KAAK;AAA7C,kBACE,oBAAC,qCAAD;AACE,IAAA,KAAK,EAAEI,KAAF,aAAEA,KAAF,cAAEA,KAAF,GAAWE,MAAM,CAACC;AADzB,KAEMF,IAFN,EADF,CADF;AAQD;AAED,MAAMC,MAAM,GAAGP,UAAU,CAACS,MAAX,CAAkB;AAC/BD,EAAAA,SAAS,EAAE;AAAEE,IAAAA,IAAI,EAAE;AAAR;AADoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { ViewProps, StyleSheet } from 'react-native';\nimport { maybeInitializeFabric } from '../init';\nimport GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';\nimport GestureHandlerRootViewNativeComponent from '../specs/RNGestureHandlerRootViewNativeComponent';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView({\n style,\n ...rest\n}: GestureHandlerRootViewProps) {\n // try initialize fabric on the first render, at this point we can\n // reliably check if fabric is enabled (the function contains a flag\n // to make sure it's called only once)\n maybeInitializeFabric();\n\n return (\n <GestureHandlerRootViewContext.Provider value>\n <GestureHandlerRootViewNativeComponent\n style={style ?? styles.container}\n {...rest}\n />\n </GestureHandlerRootViewContext.Provider>\n );\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n"]}

View File

@@ -0,0 +1,26 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { maybeInitializeFabric } from '../init';
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
export default function GestureHandlerRootView({
style,
...rest
}) {
// try initialize fabric on the first render, at this point we can
// reliably check if fabric is enabled (the function contains a flag
// to make sure it's called only once)
maybeInitializeFabric();
return /*#__PURE__*/React.createElement(GestureHandlerRootViewContext.Provider, {
value: true
}, /*#__PURE__*/React.createElement(View, _extends({
style: style !== null && style !== void 0 ? style : styles.container
}, rest)));
}
const styles = StyleSheet.create({
container: {
flex: 1
}
});
//# sourceMappingURL=GestureHandlerRootView.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerRootView.tsx"],"names":["React","View","StyleSheet","maybeInitializeFabric","GestureHandlerRootViewContext","GestureHandlerRootView","style","rest","styles","container","create","flex"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,IAAT,EAA0BC,UAA1B,QAA4C,cAA5C;AACA,SAASC,qBAAT,QAAsC,SAAtC;AACA,OAAOC,6BAAP,MAA0C,kCAA1C;AAKA,eAAe,SAASC,sBAAT,CAAgC;AAC7CC,EAAAA,KAD6C;AAE7C,KAAGC;AAF0C,CAAhC,EAGiB;AAC9B;AACA;AACA;AACAJ,EAAAA,qBAAqB;AAErB,sBACE,oBAAC,6BAAD,CAA+B,QAA/B;AAAwC,IAAA,KAAK;AAA7C,kBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEG,KAAF,aAAEA,KAAF,cAAEA,KAAF,GAAWE,MAAM,CAACC;AAA7B,KAA4CF,IAA5C,EADF,CADF;AAKD;AAED,MAAMC,MAAM,GAAGN,UAAU,CAACQ,MAAX,CAAkB;AAC/BD,EAAAA,SAAS,EAAE;AAAEE,IAAAA,IAAI,EAAE;AAAR;AADoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps, StyleSheet } from 'react-native';\nimport { maybeInitializeFabric } from '../init';\nimport GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView({\n style,\n ...rest\n}: GestureHandlerRootViewProps) {\n // try initialize fabric on the first render, at this point we can\n // reliably check if fabric is enabled (the function contains a flag\n // to make sure it's called only once)\n maybeInitializeFabric();\n\n return (\n <GestureHandlerRootViewContext.Provider value>\n <View style={style ?? styles.container} {...rest} />\n </GestureHandlerRootViewContext.Provider>\n );\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n"]}

View File

@@ -0,0 +1,21 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
export default function GestureHandlerRootView({
style,
...rest
}) {
return /*#__PURE__*/React.createElement(GestureHandlerRootViewContext.Provider, {
value: true
}, /*#__PURE__*/React.createElement(View, _extends({
style: style !== null && style !== void 0 ? style : styles.container
}, rest)));
}
const styles = StyleSheet.create({
container: {
flex: 1
}
});
//# sourceMappingURL=GestureHandlerRootView.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerRootView.web.tsx"],"names":["React","View","StyleSheet","GestureHandlerRootViewContext","GestureHandlerRootView","style","rest","styles","container","create","flex"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,IAAT,EAA0BC,UAA1B,QAA4C,cAA5C;AACA,OAAOC,6BAAP,MAA0C,kCAA1C;AAKA,eAAe,SAASC,sBAAT,CAAgC;AAC7CC,EAAAA,KAD6C;AAE7C,KAAGC;AAF0C,CAAhC,EAGiB;AAC9B,sBACE,oBAAC,6BAAD,CAA+B,QAA/B;AAAwC,IAAA,KAAK;AAA7C,kBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAED,KAAF,aAAEA,KAAF,cAAEA,KAAF,GAAWE,MAAM,CAACC;AAA7B,KAA4CF,IAA5C,EADF,CADF;AAKD;AAED,MAAMC,MAAM,GAAGL,UAAU,CAACO,MAAX,CAAkB;AAC/BD,EAAAA,SAAS,EAAE;AAAEE,IAAAA,IAAI,EAAE;AAAR;AADoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps, StyleSheet } from 'react-native';\nimport GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView({\n style,\n ...rest\n}: GestureHandlerRootViewProps) {\n return (\n <GestureHandlerRootViewContext.Provider value>\n <View style={style ?? styles.container} {...rest} />\n </GestureHandlerRootViewContext.Provider>\n );\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n"]}

View File

@@ -0,0 +1,392 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// Similarily to the DrawerLayout component this deserves to be put in a
// separate repo. Although, keeping it here for the time being will allow us to
// move faster and fix possible issues quicker
import * as React from 'react';
import { Component } from 'react';
import { Animated, StyleSheet, View, I18nManager } from 'react-native';
import { PanGestureHandler } from '../handlers/PanGestureHandler';
import { TapGestureHandler } from '../handlers/TapGestureHandler';
import { State } from '../State';
const DRAG_TOSS = 0.05;
export default class Swipeable extends Component {
constructor(_props) {
super(_props);
_defineProperty(this, "onGestureEvent", void 0);
_defineProperty(this, "transX", void 0);
_defineProperty(this, "showLeftAction", void 0);
_defineProperty(this, "leftActionTranslate", void 0);
_defineProperty(this, "showRightAction", void 0);
_defineProperty(this, "rightActionTranslate", void 0);
_defineProperty(this, "updateAnimatedEvent", (props, state) => {
const {
friction,
overshootFriction
} = props;
const {
dragX,
rowTranslation,
leftWidth = 0,
rowWidth = 0
} = state;
const {
rightOffset = rowWidth
} = state;
const rightWidth = Math.max(0, rowWidth - rightOffset);
const {
overshootLeft = leftWidth > 0,
overshootRight = rightWidth > 0
} = props;
const transX = Animated.add(rowTranslation, dragX.interpolate({
inputRange: [0, friction],
outputRange: [0, 1]
})).interpolate({
inputRange: [-rightWidth - 1, -rightWidth, leftWidth, leftWidth + 1],
outputRange: [-rightWidth - (overshootRight ? 1 / overshootFriction : 0), -rightWidth, leftWidth, leftWidth + (overshootLeft ? 1 / overshootFriction : 0)]
});
this.transX = transX;
this.showLeftAction = leftWidth > 0 ? transX.interpolate({
inputRange: [-1, 0, leftWidth],
outputRange: [0, 0, 1]
}) : new Animated.Value(0);
this.leftActionTranslate = this.showLeftAction.interpolate({
inputRange: [0, Number.MIN_VALUE],
outputRange: [-10000, 0],
extrapolate: 'clamp'
});
this.showRightAction = rightWidth > 0 ? transX.interpolate({
inputRange: [-rightWidth, 0, 1],
outputRange: [1, 0, 0]
}) : new Animated.Value(0);
this.rightActionTranslate = this.showRightAction.interpolate({
inputRange: [0, Number.MIN_VALUE],
outputRange: [-10000, 0],
extrapolate: 'clamp'
});
});
_defineProperty(this, "onTapHandlerStateChange", ({
nativeEvent
}) => {
if (nativeEvent.oldState === State.ACTIVE) {
this.close();
}
});
_defineProperty(this, "onHandlerStateChange", ev => {
if (ev.nativeEvent.oldState === State.ACTIVE) {
this.handleRelease(ev);
}
if (ev.nativeEvent.state === State.ACTIVE) {
const {
velocityX,
translationX: dragX
} = ev.nativeEvent;
const {
rowState
} = this.state;
const {
friction
} = this.props;
const translationX = (dragX + DRAG_TOSS * velocityX) / friction;
const direction = rowState === -1 ? 'right' : rowState === 1 ? 'left' : translationX > 0 ? 'left' : 'right';
if (rowState === 0) {
var _this$props$onSwipeab, _this$props;
(_this$props$onSwipeab = (_this$props = this.props).onSwipeableOpenStartDrag) === null || _this$props$onSwipeab === void 0 ? void 0 : _this$props$onSwipeab.call(_this$props, direction);
} else {
var _this$props$onSwipeab2, _this$props2;
(_this$props$onSwipeab2 = (_this$props2 = this.props).onSwipeableCloseStartDrag) === null || _this$props$onSwipeab2 === void 0 ? void 0 : _this$props$onSwipeab2.call(_this$props2, direction);
}
}
});
_defineProperty(this, "handleRelease", ev => {
const {
velocityX,
translationX: dragX
} = ev.nativeEvent;
const {
leftWidth = 0,
rowWidth = 0,
rowState
} = this.state;
const {
rightOffset = rowWidth
} = this.state;
const rightWidth = rowWidth - rightOffset;
const {
friction,
leftThreshold = leftWidth / 2,
rightThreshold = rightWidth / 2
} = this.props;
const startOffsetX = this.currentOffset() + dragX / friction;
const translationX = (dragX + DRAG_TOSS * velocityX) / friction;
let toValue = 0;
if (rowState === 0) {
if (translationX > leftThreshold) {
toValue = leftWidth;
} else if (translationX < -rightThreshold) {
toValue = -rightWidth;
}
} else if (rowState === 1) {
// swiped to left
if (translationX > -leftThreshold) {
toValue = leftWidth;
}
} else {
// swiped to right
if (translationX < rightThreshold) {
toValue = -rightWidth;
}
}
this.animateRow(startOffsetX, toValue, velocityX / friction);
});
_defineProperty(this, "animateRow", (fromValue, toValue, velocityX) => {
const {
dragX,
rowTranslation
} = this.state;
dragX.setValue(0);
rowTranslation.setValue(fromValue);
this.setState({
rowState: Math.sign(toValue)
});
Animated.spring(rowTranslation, {
restSpeedThreshold: 1.7,
restDisplacementThreshold: 0.4,
velocity: velocityX,
bounciness: 0,
toValue,
useNativeDriver: this.props.useNativeAnimations,
...this.props.animationOptions
}).start(({
finished
}) => {
if (finished) {
if (toValue > 0) {
var _this$props$onSwipeab3, _this$props3, _this$props$onSwipeab4, _this$props4;
(_this$props$onSwipeab3 = (_this$props3 = this.props).onSwipeableLeftOpen) === null || _this$props$onSwipeab3 === void 0 ? void 0 : _this$props$onSwipeab3.call(_this$props3);
(_this$props$onSwipeab4 = (_this$props4 = this.props).onSwipeableOpen) === null || _this$props$onSwipeab4 === void 0 ? void 0 : _this$props$onSwipeab4.call(_this$props4, 'left', this);
} else if (toValue < 0) {
var _this$props$onSwipeab5, _this$props5, _this$props$onSwipeab6, _this$props6;
(_this$props$onSwipeab5 = (_this$props5 = this.props).onSwipeableRightOpen) === null || _this$props$onSwipeab5 === void 0 ? void 0 : _this$props$onSwipeab5.call(_this$props5);
(_this$props$onSwipeab6 = (_this$props6 = this.props).onSwipeableOpen) === null || _this$props$onSwipeab6 === void 0 ? void 0 : _this$props$onSwipeab6.call(_this$props6, 'right', this);
} else {
var _this$props$onSwipeab7, _this$props7;
const closingDirection = fromValue > 0 ? 'left' : 'right';
(_this$props$onSwipeab7 = (_this$props7 = this.props).onSwipeableClose) === null || _this$props$onSwipeab7 === void 0 ? void 0 : _this$props$onSwipeab7.call(_this$props7, closingDirection, this);
}
}
});
if (toValue > 0) {
var _this$props$onSwipeab8, _this$props8, _this$props$onSwipeab9, _this$props9;
(_this$props$onSwipeab8 = (_this$props8 = this.props).onSwipeableLeftWillOpen) === null || _this$props$onSwipeab8 === void 0 ? void 0 : _this$props$onSwipeab8.call(_this$props8);
(_this$props$onSwipeab9 = (_this$props9 = this.props).onSwipeableWillOpen) === null || _this$props$onSwipeab9 === void 0 ? void 0 : _this$props$onSwipeab9.call(_this$props9, 'left');
} else if (toValue < 0) {
var _this$props$onSwipeab10, _this$props10, _this$props$onSwipeab11, _this$props11;
(_this$props$onSwipeab10 = (_this$props10 = this.props).onSwipeableRightWillOpen) === null || _this$props$onSwipeab10 === void 0 ? void 0 : _this$props$onSwipeab10.call(_this$props10);
(_this$props$onSwipeab11 = (_this$props11 = this.props).onSwipeableWillOpen) === null || _this$props$onSwipeab11 === void 0 ? void 0 : _this$props$onSwipeab11.call(_this$props11, 'right');
} else {
var _this$props$onSwipeab12, _this$props12;
const closingDirection = fromValue > 0 ? 'left' : 'right';
(_this$props$onSwipeab12 = (_this$props12 = this.props).onSwipeableWillClose) === null || _this$props$onSwipeab12 === void 0 ? void 0 : _this$props$onSwipeab12.call(_this$props12, closingDirection);
}
});
_defineProperty(this, "onRowLayout", ({
nativeEvent
}) => {
this.setState({
rowWidth: nativeEvent.layout.width
});
});
_defineProperty(this, "currentOffset", () => {
const {
leftWidth = 0,
rowWidth = 0,
rowState
} = this.state;
const {
rightOffset = rowWidth
} = this.state;
const rightWidth = rowWidth - rightOffset;
if (rowState === 1) {
return leftWidth;
} else if (rowState === -1) {
return -rightWidth;
}
return 0;
});
_defineProperty(this, "close", () => {
this.animateRow(this.currentOffset(), 0);
});
_defineProperty(this, "openLeft", () => {
const {
leftWidth = 0
} = this.state;
this.animateRow(this.currentOffset(), leftWidth);
});
_defineProperty(this, "openRight", () => {
const {
rowWidth = 0
} = this.state;
const {
rightOffset = rowWidth
} = this.state;
const rightWidth = rowWidth - rightOffset;
this.animateRow(this.currentOffset(), -rightWidth);
});
_defineProperty(this, "reset", () => {
const {
dragX,
rowTranslation
} = this.state;
dragX.setValue(0);
rowTranslation.setValue(0);
this.setState({
rowState: 0
});
});
const _dragX = new Animated.Value(0);
this.state = {
dragX: _dragX,
rowTranslation: new Animated.Value(0),
rowState: 0,
leftWidth: undefined,
rightOffset: undefined,
rowWidth: undefined
};
this.updateAnimatedEvent(_props, this.state);
this.onGestureEvent = Animated.event([{
nativeEvent: {
translationX: _dragX
}
}], {
useNativeDriver: _props.useNativeAnimations
});
}
shouldComponentUpdate(props, state) {
if (this.props.friction !== props.friction || this.props.overshootLeft !== props.overshootLeft || this.props.overshootRight !== props.overshootRight || this.props.overshootFriction !== props.overshootFriction || this.state.leftWidth !== state.leftWidth || this.state.rightOffset !== state.rightOffset || this.state.rowWidth !== state.rowWidth) {
this.updateAnimatedEvent(props, state);
}
return true;
}
render() {
const {
rowState
} = this.state;
const {
children,
renderLeftActions,
renderRightActions,
dragOffsetFromLeftEdge = 10,
dragOffsetFromRightEdge = 10
} = this.props;
const left = renderLeftActions && /*#__PURE__*/React.createElement(Animated.View, {
style: [styles.leftActions, // all those and below parameters can have ! since they are all
// asigned in constructor in `updateAnimatedEvent` but TS cannot spot
// it for some reason
{
transform: [{
translateX: this.leftActionTranslate
}]
}]
}, renderLeftActions(this.showLeftAction, this.transX, this), /*#__PURE__*/React.createElement(View, {
onLayout: ({
nativeEvent
}) => this.setState({
leftWidth: nativeEvent.layout.x
})
}));
const right = renderRightActions && /*#__PURE__*/React.createElement(Animated.View, {
style: [styles.rightActions, {
transform: [{
translateX: this.rightActionTranslate
}]
}]
}, renderRightActions(this.showRightAction, this.transX, this), /*#__PURE__*/React.createElement(View, {
onLayout: ({
nativeEvent
}) => this.setState({
rightOffset: nativeEvent.layout.x
})
}));
return /*#__PURE__*/React.createElement(PanGestureHandler, _extends({
activeOffsetX: [-dragOffsetFromRightEdge, dragOffsetFromLeftEdge],
touchAction: "pan-y"
}, this.props, {
onGestureEvent: this.onGestureEvent,
onHandlerStateChange: this.onHandlerStateChange
}), /*#__PURE__*/React.createElement(Animated.View, {
onLayout: this.onRowLayout,
style: [styles.container, this.props.containerStyle]
}, left, right, /*#__PURE__*/React.createElement(TapGestureHandler, {
enabled: rowState !== 0,
touchAction: "pan-y",
onHandlerStateChange: this.onTapHandlerStateChange
}, /*#__PURE__*/React.createElement(Animated.View, {
pointerEvents: rowState === 0 ? 'auto' : 'box-only',
style: [{
transform: [{
translateX: this.transX
}]
}, this.props.childrenContainerStyle]
}, children))));
}
}
_defineProperty(Swipeable, "defaultProps", {
friction: 1,
overshootFriction: 1,
useNativeAnimations: true
});
const styles = StyleSheet.create({
container: {
overflow: 'hidden'
},
leftActions: { ...StyleSheet.absoluteFillObject,
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row'
},
rightActions: { ...StyleSheet.absoluteFillObject,
flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse'
}
});
//# sourceMappingURL=Swipeable.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import { StyleSheet } from 'react-native';
import hoistNonReactStatics from 'hoist-non-react-statics';
import GestureHandlerRootView from './GestureHandlerRootView';
export default function gestureHandlerRootHOC(Component, containerStyles) {
function Wrapper(props) {
return /*#__PURE__*/React.createElement(GestureHandlerRootView, {
style: [styles.container, containerStyles]
}, /*#__PURE__*/React.createElement(Component, props));
}
Wrapper.displayName = `gestureHandlerRootHOC(${Component.displayName || Component.name})`; // @ts-ignore - hoistNonReactStatics uses old version of @types/react
hoistNonReactStatics(Wrapper, Component);
return Wrapper;
}
const styles = StyleSheet.create({
container: {
flex: 1
}
});
//# sourceMappingURL=gestureHandlerRootHOC.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["gestureHandlerRootHOC.tsx"],"names":["React","StyleSheet","hoistNonReactStatics","GestureHandlerRootView","gestureHandlerRootHOC","Component","containerStyles","Wrapper","props","styles","container","displayName","name","create","flex"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,UAAT,QAAiD,cAAjD;AACA,OAAOC,oBAAP,MAAiC,yBAAjC;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AAEA,eAAe,SAASC,qBAAT,CACbC,SADa,EAEbC,eAFa,EAGW;AACxB,WAASC,OAAT,CAAiBC,KAAjB,EAA2B;AACzB,wBACE,oBAAC,sBAAD;AAAwB,MAAA,KAAK,EAAE,CAACC,MAAM,CAACC,SAAR,EAAmBJ,eAAnB;AAA/B,oBACE,oBAAC,SAAD,EAAeE,KAAf,CADF,CADF;AAKD;;AAEDD,EAAAA,OAAO,CAACI,WAAR,GAAuB,yBACrBN,SAAS,CAACM,WAAV,IAAyBN,SAAS,CAACO,IACpC,GAFD,CATwB,CAaxB;;AACAV,EAAAA,oBAAoB,CAACK,OAAD,EAAUF,SAAV,CAApB;AAEA,SAAOE,OAAP;AACD;AAED,MAAME,MAAM,GAAGR,UAAU,CAACY,MAAX,CAAkB;AAC/BH,EAAAA,SAAS,EAAE;AAAEI,IAAAA,IAAI,EAAE;AAAR;AADoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { StyleSheet, StyleProp, ViewStyle } from 'react-native';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport GestureHandlerRootView from './GestureHandlerRootView';\n\nexport default function gestureHandlerRootHOC<P extends object>(\n Component: React.ComponentType<P>,\n containerStyles?: StyleProp<ViewStyle>\n): React.ComponentType<P> {\n function Wrapper(props: P) {\n return (\n <GestureHandlerRootView style={[styles.container, containerStyles]}>\n <Component {...props} />\n </GestureHandlerRootView>\n );\n }\n\n Wrapper.displayName = `gestureHandlerRootHOC(${\n Component.displayName || Component.name\n })`;\n\n // @ts-ignore - hoistNonReactStatics uses old version of @types/react\n hoistNonReactStatics(Wrapper, Component);\n\n return Wrapper;\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n"]}

View File

@@ -0,0 +1,274 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import * as React from 'react';
import { Component } from 'react';
import { Animated, Platform } from 'react-native';
import { State } from '../../State';
import { BaseButton } from '../GestureButtons';
/**
* Each touchable is a states' machine which preforms transitions.
* On very beginning (and on the very end or recognition) touchable is
* UNDETERMINED. Then it moves to BEGAN. If touchable recognizes that finger
* travel outside it transits to special MOVED_OUTSIDE state. Gesture recognition
* finishes in UNDETERMINED state.
*/
export const TOUCHABLE_STATE = {
UNDETERMINED: 0,
BEGAN: 1,
MOVED_OUTSIDE: 2
};
/**
* GenericTouchable is not intented to be used as it is.
* Should be treated as a source for the rest of touchables
*/
export default class GenericTouchable extends Component {
constructor(...args) {
super(...args);
_defineProperty(this, "pressInTimeout", void 0);
_defineProperty(this, "pressOutTimeout", void 0);
_defineProperty(this, "longPressTimeout", void 0);
_defineProperty(this, "longPressDetected", false);
_defineProperty(this, "pointerInside", true);
_defineProperty(this, "STATE", TOUCHABLE_STATE.UNDETERMINED);
_defineProperty(this, "onGestureEvent", ({
nativeEvent: {
pointerInside
}
}) => {
if (this.pointerInside !== pointerInside) {
if (pointerInside) {
this.onMoveIn();
} else {
this.onMoveOut();
}
}
this.pointerInside = pointerInside;
});
_defineProperty(this, "onHandlerStateChange", ({
nativeEvent
}) => {
const {
state
} = nativeEvent;
if (state === State.CANCELLED || state === State.FAILED) {
// Need to handle case with external cancellation (e.g. by ScrollView)
this.moveToState(TOUCHABLE_STATE.UNDETERMINED);
} else if ( // This platform check is an implication of slightly different behavior of handlers on different platform.
// And Android "Active" state is achieving on first move of a finger, not on press in.
// On iOS event on "Began" is not delivered.
state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) && this.STATE === TOUCHABLE_STATE.UNDETERMINED) {
// Moving inside requires
this.handlePressIn();
} else if (state === State.END) {
const shouldCallOnPress = !this.longPressDetected && this.STATE !== TOUCHABLE_STATE.MOVED_OUTSIDE && this.pressOutTimeout === null;
this.handleGoToUndetermined();
if (shouldCallOnPress) {
var _this$props$onPress, _this$props;
// Calls only inside component whether no long press was called previously
(_this$props$onPress = (_this$props = this.props).onPress) === null || _this$props$onPress === void 0 ? void 0 : _this$props$onPress.call(_this$props);
}
}
});
_defineProperty(this, "onLongPressDetected", () => {
var _this$props$onLongPre, _this$props2;
this.longPressDetected = true; // checked for in the caller of `onLongPressDetected`, but better to check twice
(_this$props$onLongPre = (_this$props2 = this.props).onLongPress) === null || _this$props$onLongPre === void 0 ? void 0 : _this$props$onLongPre.call(_this$props2);
});
}
// handlePressIn in called on first touch on traveling inside component.
// Handles state transition with delay.
handlePressIn() {
if (this.props.delayPressIn) {
this.pressInTimeout = setTimeout(() => {
this.moveToState(TOUCHABLE_STATE.BEGAN);
this.pressInTimeout = null;
}, this.props.delayPressIn);
} else {
this.moveToState(TOUCHABLE_STATE.BEGAN);
}
if (this.props.onLongPress) {
const time = (this.props.delayPressIn || 0) + (this.props.delayLongPress || 0);
this.longPressTimeout = setTimeout(this.onLongPressDetected, time);
}
} // handleMoveOutside in called on traveling outside component.
// Handles state transition with delay.
handleMoveOutside() {
if (this.props.delayPressOut) {
this.pressOutTimeout = this.pressOutTimeout || setTimeout(() => {
this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);
this.pressOutTimeout = null;
}, this.props.delayPressOut);
} else {
this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);
}
} // handleGoToUndetermined transits to UNDETERMINED state with proper delay
handleGoToUndetermined() {
clearTimeout(this.pressOutTimeout); // TODO: maybe it can be undefined
if (this.props.delayPressOut) {
this.pressOutTimeout = setTimeout(() => {
if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {
this.moveToState(TOUCHABLE_STATE.BEGAN);
}
this.moveToState(TOUCHABLE_STATE.UNDETERMINED);
this.pressOutTimeout = null;
}, this.props.delayPressOut);
} else {
if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {
this.moveToState(TOUCHABLE_STATE.BEGAN);
}
this.moveToState(TOUCHABLE_STATE.UNDETERMINED);
}
}
componentDidMount() {
this.reset();
} // reset timeout to prevent memory leaks.
reset() {
this.longPressDetected = false;
this.pointerInside = true;
clearTimeout(this.pressInTimeout);
clearTimeout(this.pressOutTimeout);
clearTimeout(this.longPressTimeout);
this.pressOutTimeout = null;
this.longPressTimeout = null;
this.pressInTimeout = null;
} // All states' transitions are defined here.
moveToState(newState) {
var _this$props$onStateCh, _this$props6;
if (newState === this.STATE) {
// Ignore dummy transitions
return;
}
if (newState === TOUCHABLE_STATE.BEGAN) {
var _this$props$onPressIn, _this$props3;
// First touch and moving inside
(_this$props$onPressIn = (_this$props3 = this.props).onPressIn) === null || _this$props$onPressIn === void 0 ? void 0 : _this$props$onPressIn.call(_this$props3);
} else if (newState === TOUCHABLE_STATE.MOVED_OUTSIDE) {
var _this$props$onPressOu, _this$props4;
// Moving outside
(_this$props$onPressOu = (_this$props4 = this.props).onPressOut) === null || _this$props$onPressOu === void 0 ? void 0 : _this$props$onPressOu.call(_this$props4);
} else if (newState === TOUCHABLE_STATE.UNDETERMINED) {
// Need to reset each time on transition to UNDETERMINED
this.reset();
if (this.STATE === TOUCHABLE_STATE.BEGAN) {
var _this$props$onPressOu2, _this$props5;
// ... and if it happens inside button.
(_this$props$onPressOu2 = (_this$props5 = this.props).onPressOut) === null || _this$props$onPressOu2 === void 0 ? void 0 : _this$props$onPressOu2.call(_this$props5);
}
} // Finally call lister (used by subclasses)
(_this$props$onStateCh = (_this$props6 = this.props).onStateChange) === null || _this$props$onStateCh === void 0 ? void 0 : _this$props$onStateCh.call(_this$props6, this.STATE, newState); // ... and make transition.
this.STATE = newState;
}
componentWillUnmount() {
// to prevent memory leaks
this.reset();
}
onMoveIn() {
if (this.STATE === TOUCHABLE_STATE.MOVED_OUTSIDE) {
// This call is not throttled with delays (like in RN's implementation).
this.moveToState(TOUCHABLE_STATE.BEGAN);
}
}
onMoveOut() {
// long press should no longer be detected
clearTimeout(this.longPressTimeout);
this.longPressTimeout = null;
if (this.STATE === TOUCHABLE_STATE.BEGAN) {
this.handleMoveOutside();
}
}
render() {
var _ref, _this$props$touchSoun;
const hitSlop = (_ref = typeof this.props.hitSlop === 'number' ? {
top: this.props.hitSlop,
left: this.props.hitSlop,
bottom: this.props.hitSlop,
right: this.props.hitSlop
} : this.props.hitSlop) !== null && _ref !== void 0 ? _ref : undefined;
const coreProps = {
accessible: this.props.accessible !== false,
accessibilityLabel: this.props.accessibilityLabel,
accessibilityHint: this.props.accessibilityHint,
accessibilityRole: this.props.accessibilityRole,
// TODO: check if changed to no 's' correctly, also removed 2 props that are no longer available: `accessibilityComponentType` and `accessibilityTraits`,
// would be good to check if it is ok for sure, see: https://github.com/facebook/react-native/issues/24016
accessibilityState: this.props.accessibilityState,
accessibilityActions: this.props.accessibilityActions,
onAccessibilityAction: this.props.onAccessibilityAction,
nativeID: this.props.nativeID,
onLayout: this.props.onLayout
};
return /*#__PURE__*/React.createElement(BaseButton, _extends({
style: this.props.containerStyle,
onHandlerStateChange: // TODO: not sure if it can be undefined instead of null
this.props.disabled ? undefined : this.onHandlerStateChange,
onGestureEvent: this.onGestureEvent,
hitSlop: hitSlop,
userSelect: this.props.userSelect,
shouldActivateOnStart: this.props.shouldActivateOnStart,
disallowInterruption: this.props.disallowInterruption,
testID: this.props.testID,
touchSoundDisabled: (_this$props$touchSoun = this.props.touchSoundDisabled) !== null && _this$props$touchSoun !== void 0 ? _this$props$touchSoun : false,
enabled: !this.props.disabled
}, this.props.extraButtonProps), /*#__PURE__*/React.createElement(Animated.View, _extends({}, coreProps, {
style: this.props.style
}), this.props.children));
}
}
_defineProperty(GenericTouchable, "defaultProps", {
delayLongPress: 600,
extraButtonProps: {
rippleColor: 'transparent',
exclusive: true
}
});
//# sourceMappingURL=GenericTouchable.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,95 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import * as React from 'react';
import { Component } from 'react';
import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable';
import { StyleSheet, View } from 'react-native';
/**
* TouchableHighlight follows RN's implementation
*/
export default class TouchableHighlight extends Component {
constructor(props) {
super(props);
_defineProperty(this, "showUnderlay", () => {
var _this$props$onShowUnd, _this$props;
if (!this.hasPressHandler()) {
return;
}
this.setState({
extraChildStyle: {
opacity: this.props.activeOpacity
},
extraUnderlayStyle: {
backgroundColor: this.props.underlayColor
}
});
(_this$props$onShowUnd = (_this$props = this.props).onShowUnderlay) === null || _this$props$onShowUnd === void 0 ? void 0 : _this$props$onShowUnd.call(_this$props);
});
_defineProperty(this, "hasPressHandler", () => this.props.onPress || this.props.onPressIn || this.props.onPressOut || this.props.onLongPress);
_defineProperty(this, "hideUnderlay", () => {
var _this$props$onHideUnd, _this$props2;
this.setState({
extraChildStyle: null,
extraUnderlayStyle: null
});
(_this$props$onHideUnd = (_this$props2 = this.props).onHideUnderlay) === null || _this$props$onHideUnd === void 0 ? void 0 : _this$props$onHideUnd.call(_this$props2);
});
_defineProperty(this, "onStateChange", (_from, to) => {
if (to === TOUCHABLE_STATE.BEGAN) {
this.showUnderlay();
} else if (to === TOUCHABLE_STATE.UNDETERMINED || to === TOUCHABLE_STATE.MOVED_OUTSIDE) {
this.hideUnderlay();
}
});
this.state = {
extraChildStyle: null,
extraUnderlayStyle: null
};
} // Copied from RN
renderChildren() {
if (!this.props.children) {
return /*#__PURE__*/React.createElement(View, null);
}
const child = React.Children.only(this.props.children); // TODO: not sure if OK but fixes error
return /*#__PURE__*/React.cloneElement(child, {
style: StyleSheet.compose(child.props.style, this.state.extraChildStyle)
});
}
render() {
const {
style = {},
...rest
} = this.props;
const {
extraUnderlayStyle
} = this.state;
return /*#__PURE__*/React.createElement(GenericTouchable, _extends({}, rest, {
style: [style, extraUnderlayStyle],
onStateChange: this.onStateChange
}), this.renderChildren());
}
}
_defineProperty(TouchableHighlight, "defaultProps", { ...GenericTouchable.defaultProps,
activeOpacity: 0.85,
delayPressOut: 100,
underlayColor: 'black'
});
//# sourceMappingURL=TouchableHighlight.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,84 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { Platform } from 'react-native';
import * as React from 'react';
import { Component } from 'react';
import GenericTouchable from './GenericTouchable';
/**
* TouchableNativeFeedback behaves slightly different than RN's TouchableNativeFeedback.
* There's small difference with handling long press ripple since RN's implementation calls
* ripple animation via bridge. This solution leaves all animations' handling for native components so
* it follows native behaviours.
*/
export default class TouchableNativeFeedback extends Component {
// could be taken as RNTouchableNativeFeedback.SelectableBackground etc. but the API may change
getExtraButtonProps() {
const extraProps = {};
const {
background
} = this.props;
if (background) {
// I changed type values to match those used in RN
// TODO(TS): check if it works the same as previous implementation - looks like it works the same as RN component, so it should be ok
if (background.type === 'RippleAndroid') {
extraProps['borderless'] = background.borderless;
extraProps['rippleColor'] = background.color;
} else if (background.type === 'ThemeAttrAndroid') {
extraProps['borderless'] = background.attribute === 'selectableItemBackgroundBorderless';
} // I moved it from above since it should be available in all options
extraProps['rippleRadius'] = background.rippleRadius;
}
extraProps['foreground'] = this.props.useForeground;
return extraProps;
}
render() {
const {
style = {},
...rest
} = this.props;
return /*#__PURE__*/React.createElement(GenericTouchable, _extends({}, rest, {
style: style,
extraButtonProps: this.getExtraButtonProps()
}));
}
}
_defineProperty(TouchableNativeFeedback, "defaultProps", { ...GenericTouchable.defaultProps,
useForeground: true,
extraButtonProps: {
// Disable hiding ripple on Android
rippleColor: null
}
});
_defineProperty(TouchableNativeFeedback, "SelectableBackground", rippleRadius => ({
type: 'ThemeAttrAndroid',
// I added `attribute` prop to clone the implementation of RN and be able to use only 2 types
attribute: 'selectableItemBackground',
rippleRadius
}));
_defineProperty(TouchableNativeFeedback, "SelectableBackgroundBorderless", rippleRadius => ({
type: 'ThemeAttrAndroid',
attribute: 'selectableItemBackgroundBorderless',
rippleRadius
}));
_defineProperty(TouchableNativeFeedback, "Ripple", (color, borderless, rippleRadius) => ({
type: 'RippleAndroid',
color,
borderless,
rippleRadius
}));
_defineProperty(TouchableNativeFeedback, "canUseNativeForeground", () => Platform.OS === 'android' && Platform.Version >= 23);
//# sourceMappingURL=TouchableNativeFeedback.android.js.map

View File

@@ -0,0 +1,3 @@
import { TouchableNativeFeedback } from 'react-native';
export default TouchableNativeFeedback;
//# sourceMappingURL=TouchableNativeFeedback.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["TouchableNativeFeedback.tsx"],"names":["TouchableNativeFeedback"],"mappings":"AAAA,SAASA,uBAAT,QAAwC,cAAxC;AAEA,eAAeA,uBAAf","sourcesContent":["import { TouchableNativeFeedback } from 'react-native';\n\nexport default TouchableNativeFeedback;\n"]}

View File

@@ -0,0 +1,63 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { Animated, Easing, StyleSheet, View } from 'react-native';
import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable';
import * as React from 'react';
import { Component } from 'react';
/**
* TouchableOpacity bases on timing animation which has been used in RN's core
*/
export default class TouchableOpacity extends Component {
constructor(...args) {
super(...args);
_defineProperty(this, "getChildStyleOpacityWithDefault", () => {
const childStyle = StyleSheet.flatten(this.props.style) || {};
return childStyle.opacity == null ? 1 : childStyle.opacity.valueOf();
});
_defineProperty(this, "opacity", new Animated.Value(this.getChildStyleOpacityWithDefault()));
_defineProperty(this, "setOpacityTo", (value, duration) => {
var _this$props$useNative;
Animated.timing(this.opacity, {
toValue: value,
duration: duration,
easing: Easing.inOut(Easing.quad),
useNativeDriver: (_this$props$useNative = this.props.useNativeAnimations) !== null && _this$props$useNative !== void 0 ? _this$props$useNative : true
}).start();
});
_defineProperty(this, "onStateChange", (_from, to) => {
if (to === TOUCHABLE_STATE.BEGAN) {
this.setOpacityTo(this.props.activeOpacity, 0);
} else if (to === TOUCHABLE_STATE.UNDETERMINED || to === TOUCHABLE_STATE.MOVED_OUTSIDE) {
this.setOpacityTo(this.getChildStyleOpacityWithDefault(), 150);
}
});
}
render() {
const {
style = {},
...rest
} = this.props;
return /*#__PURE__*/React.createElement(GenericTouchable, _extends({}, rest, {
style: [style, {
opacity: this.opacity // TODO: fix this
}],
onStateChange: this.onStateChange
}), this.props.children ? this.props.children : /*#__PURE__*/React.createElement(View, null));
}
}
_defineProperty(TouchableOpacity, "defaultProps", { ...GenericTouchable.defaultProps,
activeOpacity: 0.2
});
//# sourceMappingURL=TouchableOpacity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["TouchableOpacity.tsx"],"names":["Animated","Easing","StyleSheet","View","GenericTouchable","TOUCHABLE_STATE","React","Component","TouchableOpacity","childStyle","flatten","props","style","opacity","valueOf","Value","getChildStyleOpacityWithDefault","value","duration","timing","toValue","easing","inOut","quad","useNativeDriver","useNativeAnimations","start","_from","to","BEGAN","setOpacityTo","activeOpacity","UNDETERMINED","MOVED_OUTSIDE","render","rest","onStateChange","children","defaultProps"],"mappings":";;;;AAAA,SACEA,QADF,EAEEC,MAFF,EAGEC,UAHF,EAIEC,IAJF,QAMO,cANP;AAOA,OAAOC,gBAAP,IACEC,eADF,QAGO,oBAHP;AAIA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,SAAT,QAA0B,OAA1B;;AAOA;AACA;AACA;AACA,eAAe,MAAMC,gBAAN,SAA+BD,SAA/B,CAAgE;AAAA;AAAA;;AAAA,6DAO3C,MAAM;AACtC,YAAME,UAAU,GAAGP,UAAU,CAACQ,OAAX,CAAmB,KAAKC,KAAL,CAAWC,KAA9B,KAAwC,EAA3D;AACA,aAAOH,UAAU,CAACI,OAAX,IAAsB,IAAtB,GACH,CADG,GAEFJ,UAAU,CAACI,OAAX,CAAmBC,OAAnB,EAFL;AAGD,KAZ4E;;AAAA,qCAcnE,IAAId,QAAQ,CAACe,KAAb,CAAmB,KAAKC,+BAAL,EAAnB,CAdmE;;AAAA,0CAgB9D,CAACC,KAAD,EAAgBC,QAAhB,KAAqC;AAAA;;AAClDlB,MAAAA,QAAQ,CAACmB,MAAT,CAAgB,KAAKN,OAArB,EAA8B;AAC5BO,QAAAA,OAAO,EAAEH,KADmB;AAE5BC,QAAAA,QAAQ,EAAEA,QAFkB;AAG5BG,QAAAA,MAAM,EAAEpB,MAAM,CAACqB,KAAP,CAAarB,MAAM,CAACsB,IAApB,CAHoB;AAI5BC,QAAAA,eAAe,2BAAE,KAAKb,KAAL,CAAWc,mBAAb,yEAAoC;AAJvB,OAA9B,EAKGC,KALH;AAMD,KAvB4E;;AAAA,2CAyB7D,CAACC,KAAD,EAAgBC,EAAhB,KAA+B;AAC7C,UAAIA,EAAE,KAAKvB,eAAe,CAACwB,KAA3B,EAAkC;AAChC,aAAKC,YAAL,CAAkB,KAAKnB,KAAL,CAAWoB,aAA7B,EAA6C,CAA7C;AACD,OAFD,MAEO,IACLH,EAAE,KAAKvB,eAAe,CAAC2B,YAAvB,IACAJ,EAAE,KAAKvB,eAAe,CAAC4B,aAFlB,EAGL;AACA,aAAKH,YAAL,CAAkB,KAAKd,+BAAL,EAAlB,EAA0D,GAA1D;AACD;AACF,KAlC4E;AAAA;;AAoC7EkB,EAAAA,MAAM,GAAG;AACP,UAAM;AAAEtB,MAAAA,KAAK,GAAG,EAAV;AAAc,SAAGuB;AAAjB,QAA0B,KAAKxB,KAArC;AACA,wBACE,oBAAC,gBAAD,eACMwB,IADN;AAEE,MAAA,KAAK,EAAE,CACLvB,KADK,EAEL;AACEC,QAAAA,OAAO,EAAE,KAAKA,OADhB,CAC8C;;AAD9C,OAFK,CAFT;AAQE,MAAA,aAAa,EAAE,KAAKuB;AARtB,QASG,KAAKzB,KAAL,CAAW0B,QAAX,GAAsB,KAAK1B,KAAL,CAAW0B,QAAjC,gBAA4C,oBAAC,IAAD,OAT/C,CADF;AAaD;;AAnD4E;;gBAA1D7B,gB,kBACG,EACpB,GAAGJ,gBAAgB,CAACkC,YADA;AAEpBP,EAAAA,aAAa,EAAE;AAFK,C","sourcesContent":["import {\n Animated,\n Easing,\n StyleSheet,\n View,\n TouchableOpacityProps as RNTouchableOpacityProps,\n} from 'react-native';\nimport GenericTouchable, {\n TOUCHABLE_STATE,\n GenericTouchableProps,\n} from './GenericTouchable';\nimport * as React from 'react';\nimport { Component } from 'react';\n\nexport type TouchableOpacityProps = RNTouchableOpacityProps &\n GenericTouchableProps & {\n useNativeAnimations?: boolean;\n };\n\n/**\n * TouchableOpacity bases on timing animation which has been used in RN's core\n */\nexport default class TouchableOpacity extends Component<TouchableOpacityProps> {\n static defaultProps = {\n ...GenericTouchable.defaultProps,\n activeOpacity: 0.2,\n };\n\n // opacity is 1 one by default but could be overwritten\n getChildStyleOpacityWithDefault = () => {\n const childStyle = StyleSheet.flatten(this.props.style) || {};\n return childStyle.opacity == null\n ? 1\n : (childStyle.opacity.valueOf() as number);\n };\n\n opacity = new Animated.Value(this.getChildStyleOpacityWithDefault());\n\n setOpacityTo = (value: number, duration: number) => {\n Animated.timing(this.opacity, {\n toValue: value,\n duration: duration,\n easing: Easing.inOut(Easing.quad),\n useNativeDriver: this.props.useNativeAnimations ?? true,\n }).start();\n };\n\n onStateChange = (_from: number, to: number) => {\n if (to === TOUCHABLE_STATE.BEGAN) {\n this.setOpacityTo(this.props.activeOpacity!, 0);\n } else if (\n to === TOUCHABLE_STATE.UNDETERMINED ||\n to === TOUCHABLE_STATE.MOVED_OUTSIDE\n ) {\n this.setOpacityTo(this.getChildStyleOpacityWithDefault(), 150);\n }\n };\n\n render() {\n const { style = {}, ...rest } = this.props;\n return (\n <GenericTouchable\n {...rest}\n style={[\n style,\n {\n opacity: this.opacity as unknown as number, // TODO: fix this\n },\n ]}\n onStateChange={this.onStateChange}>\n {this.props.children ? this.props.children : <View />}\n </GenericTouchable>\n );\n }\n}\n"]}

View File

@@ -0,0 +1,10 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import GenericTouchable from './GenericTouchable';
const TouchableWithoutFeedback = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(GenericTouchable, _extends({
ref: ref
}, props)));
TouchableWithoutFeedback.defaultProps = GenericTouchable.defaultProps;
export default TouchableWithoutFeedback;
//# sourceMappingURL=TouchableWithoutFeedback.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["TouchableWithoutFeedback.tsx"],"names":["React","GenericTouchable","TouchableWithoutFeedback","forwardRef","props","ref","defaultProps"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,gBAAP,MAAwD,oBAAxD;AAIA,MAAMC,wBAAwB,gBAAGF,KAAK,CAACG,UAAN,CAG/B,CAACC,KAAD,EAAQC,GAAR,kBAAgB,oBAAC,gBAAD;AAAkB,EAAA,GAAG,EAAEA;AAAvB,GAAgCD,KAAhC,EAHe,CAAjC;AAKAF,wBAAwB,CAACI,YAAzB,GAAwCL,gBAAgB,CAACK,YAAzD;AAEA,eAAeJ,wBAAf","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport GenericTouchable, { GenericTouchableProps } from './GenericTouchable';\n\nexport type TouchableWithoutFeedbackProps = GenericTouchableProps;\n\nconst TouchableWithoutFeedback = React.forwardRef<\n GenericTouchable,\n PropsWithChildren<TouchableWithoutFeedbackProps>\n>((props, ref) => <GenericTouchable ref={ref} {...props} />);\n\nTouchableWithoutFeedback.defaultProps = GenericTouchable.defaultProps;\n\nexport default TouchableWithoutFeedback;\n"]}

View File

@@ -0,0 +1,5 @@
export { default as TouchableNativeFeedback } from './TouchableNativeFeedback';
export { default as TouchableWithoutFeedback } from './TouchableWithoutFeedback';
export { default as TouchableOpacity } from './TouchableOpacity';
export { default as TouchableHighlight } from './TouchableHighlight';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["index.ts"],"names":["default","TouchableNativeFeedback","TouchableWithoutFeedback","TouchableOpacity","TouchableHighlight"],"mappings":"AAGA,SAASA,OAAO,IAAIC,uBAApB,QAAmD,2BAAnD;AACA,SAASD,OAAO,IAAIE,wBAApB,QAAoD,4BAApD;AACA,SAASF,OAAO,IAAIG,gBAApB,QAA4C,oBAA5C;AACA,SAASH,OAAO,IAAII,kBAApB,QAA8C,sBAA9C","sourcesContent":["export type { TouchableHighlightProps } from './TouchableHighlight';\nexport type { TouchableOpacityProps } from './TouchableOpacity';\nexport type { TouchableWithoutFeedbackProps } from './TouchableWithoutFeedback';\nexport { default as TouchableNativeFeedback } from './TouchableNativeFeedback';\nexport { default as TouchableWithoutFeedback } from './TouchableWithoutFeedback';\nexport { default as TouchableOpacity } from './TouchableOpacity';\nexport { default as TouchableHighlight } from './TouchableHighlight';\n"]}

View File

@@ -0,0 +1,10 @@
import pack from 'react-native/package.json';
const [majorStr, minorStr] = pack.version.split('.');
const REACT_NATIVE_VERSION = {
major: parseInt(majorStr, 10),
minor: parseInt(minorStr, 10)
};
export function getReactNativeVersion() {
return REACT_NATIVE_VERSION;
}
//# sourceMappingURL=getReactNativeVersion.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["getReactNativeVersion.ts"],"names":["pack","majorStr","minorStr","version","split","REACT_NATIVE_VERSION","major","parseInt","minor","getReactNativeVersion"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,2BAAjB;AAEA,MAAM,CAACC,QAAD,EAAWC,QAAX,IAAuBF,IAAI,CAACG,OAAL,CAAaC,KAAb,CAAmB,GAAnB,CAA7B;AACA,MAAMC,oBAAoB,GAAG;AAC3BC,EAAAA,KAAK,EAAEC,QAAQ,CAACN,QAAD,EAAW,EAAX,CADY;AAE3BO,EAAAA,KAAK,EAAED,QAAQ,CAACL,QAAD,EAAW,EAAX;AAFY,CAA7B;AAKA,OAAO,SAASO,qBAAT,GAAiC;AACtC,SAAOJ,oBAAP;AACD","sourcesContent":["import pack from 'react-native/package.json';\n\nconst [majorStr, minorStr] = pack.version.split('.');\nconst REACT_NATIVE_VERSION = {\n major: parseInt(majorStr, 10),\n minor: parseInt(minorStr, 10),\n};\n\nexport function getReactNativeVersion() {\n return REACT_NATIVE_VERSION;\n}\n"]}

View File

@@ -0,0 +1,4 @@
export function getReactNativeVersion() {
throw new Error('getReactNativeVersion is not supported on web');
}
//# sourceMappingURL=getReactNativeVersion.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["getReactNativeVersion.web.ts"],"names":["getReactNativeVersion","Error"],"mappings":"AAAA,OAAO,SAASA,qBAAT,GAAiC;AACtC,QAAM,IAAIC,KAAJ,CAAU,+CAAV,CAAN;AACD","sourcesContent":["export function getReactNativeVersion() {\n throw new Error('getReactNativeVersion is not supported on web');\n}\n"]}

View File

@@ -0,0 +1,37 @@
// Used by GestureDetector (unsupported on web at the moment) to check whether the
// attached view may get flattened on Fabric. This implementation causes errors
// on web due to the static resolution of `require` statements by webpack breaking
// the conditional importing. Solved by making .web file.
let findHostInstance_DEPRECATED;
let getInternalInstanceHandleFromPublicInstance;
export function getShadowNodeFromRef(ref) {
// load findHostInstance_DEPRECATED lazily because it may not be available before render
if (findHostInstance_DEPRECATED === undefined) {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
findHostInstance_DEPRECATED = // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
} catch (e) {
findHostInstance_DEPRECATED = _ref => null;
}
} // load findHostInstance_DEPRECATED lazily because it may not be available before render
if (getInternalInstanceHandleFromPublicInstance === undefined) {
try {
var _require$getInternalI;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
getInternalInstanceHandleFromPublicInstance = // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
(_require$getInternalI = require('react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance').getInternalInstanceHandleFromPublicInstance) !== null && _require$getInternalI !== void 0 ? _require$getInternalI : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
ref => ref._internalInstanceHandle;
} catch (e) {
getInternalInstanceHandleFromPublicInstance = ref => // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
ref._internalInstanceHandle;
}
} // @ts-ignore Fabric
return getInternalInstanceHandleFromPublicInstance(findHostInstance_DEPRECATED(ref)).stateNode.node;
}
//# sourceMappingURL=getShadowNodeFromRef.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["getShadowNodeFromRef.ts"],"names":["findHostInstance_DEPRECATED","getInternalInstanceHandleFromPublicInstance","getShadowNodeFromRef","ref","undefined","require","e","_ref","_internalInstanceHandle","stateNode","node"],"mappings":"AAAA;AACA;AACA;AACA;AACA,IAAIA,2BAAJ;AACA,IAAIC,2CAAJ;AAIA,OAAO,SAASC,oBAAT,CAA8BC,GAA9B,EAA4C;AACjD;AACA,MAAIH,2BAA2B,KAAKI,SAApC,EAA+C;AAC7C,QAAI;AACF;AACAJ,MAAAA,2BAA2B,GACzB;AACAK,MAAAA,OAAO,CAAC,mDAAD,CAAP,CAA6DL,2BAF/D;AAGD,KALD,CAKE,OAAOM,CAAP,EAAU;AACVN,MAAAA,2BAA2B,GAAIO,IAAD,IAAmB,IAAjD;AACD;AACF,GAXgD,CAajD;;;AACA,MAAIN,2CAA2C,KAAKG,SAApD,EAA+D;AAC7D,QAAI;AAAA;;AACF;AACAH,MAAAA,2CAA2C,GACzC;AADyC,+BAEzCI,OAAO,CAAC,wFAAD,CAAP,CACGJ,2CAHsC,yEAIzC;AACEE,MAAAA,GAAD,IAAcA,GAAG,CAACK,uBALrB;AAMD,KARD,CAQE,OAAOF,CAAP,EAAU;AACVL,MAAAA,2CAA2C,GAAIE,GAAD,IAC5C;AACAA,MAAAA,GAAG,CAACK,uBAFN;AAGD;AACF,GA5BgD,CA8BjD;;;AACA,SAAOP,2CAA2C,CAChDD,2BAA2B,CAACG,GAAD,CADqB,CAA3C,CAELM,SAFK,CAEKC,IAFZ;AAGD","sourcesContent":["// Used by GestureDetector (unsupported on web at the moment) to check whether the\n// attached view may get flattened on Fabric. This implementation causes errors\n// on web due to the static resolution of `require` statements by webpack breaking\n// the conditional importing. Solved by making .web file.\nlet findHostInstance_DEPRECATED: (ref: unknown) => void;\nlet getInternalInstanceHandleFromPublicInstance: (ref: unknown) => {\n stateNode: { node: unknown };\n};\n\nexport function getShadowNodeFromRef(ref: unknown) {\n // load findHostInstance_DEPRECATED lazily because it may not be available before render\n if (findHostInstance_DEPRECATED === undefined) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n findHostInstance_DEPRECATED =\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access\n require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;\n } catch (e) {\n findHostInstance_DEPRECATED = (_ref: unknown) => null;\n }\n }\n\n // load findHostInstance_DEPRECATED lazily because it may not be available before render\n if (getInternalInstanceHandleFromPublicInstance === undefined) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n getInternalInstanceHandleFromPublicInstance =\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access\n require('react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance')\n .getInternalInstanceHandleFromPublicInstance ??\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return\n ((ref: any) => ref._internalInstanceHandle);\n } catch (e) {\n getInternalInstanceHandleFromPublicInstance = (ref: any) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return\n ref._internalInstanceHandle;\n }\n }\n\n // @ts-ignore Fabric\n return getInternalInstanceHandleFromPublicInstance(\n findHostInstance_DEPRECATED(ref)\n ).stateNode.node;\n}\n"]}

View File

@@ -0,0 +1,8 @@
// Used by GestureDetector (unsupported on web at the moment) to check whether the
// attached view may get flattened on Fabric. Original implementation causes errors
// on web due to the static resolution of `require` statements by webpack breaking
// the conditional importing.
export function getShadowNodeFromRef(_ref) {
return null;
}
//# sourceMappingURL=getShadowNodeFromRef.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["getShadowNodeFromRef.web.ts"],"names":["getShadowNodeFromRef","_ref"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAO,SAASA,oBAAT,CAA8BC,IAA9B,EAAyC;AAC9C,SAAO,IAAP;AACD","sourcesContent":["// Used by GestureDetector (unsupported on web at the moment) to check whether the\n// attached view may get flattened on Fabric. Original implementation causes errors\n// on web due to the static resolution of `require` statements by webpack breaking\n// the conditional importing.\nexport function getShadowNodeFromRef(_ref: any) {\n return null;\n}\n"]}

View File

@@ -0,0 +1,5 @@
// `queueMicrotask` was introduced to react-native in version 0.66 (https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#v0660)
// Because Gesture Handler supports versions 0.64+, we have to handle situations where someone uses older version of react native.
// That's why if `queueMicrotask` doesn't exist, we use `setImmediate` instead, since it was used before we switched to `queueMicrotask` in version 2.11.0
export const ghQueueMicrotask = typeof queueMicrotask === 'function' ? queueMicrotask : setImmediate;
//# sourceMappingURL=ghQueueMicrotask.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["ghQueueMicrotask.ts"],"names":["ghQueueMicrotask","queueMicrotask","setImmediate"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,GAC3B,OAAOC,cAAP,KAA0B,UAA1B,GAAuCA,cAAvC,GAAwDC,YADnD","sourcesContent":["// `queueMicrotask` was introduced to react-native in version 0.66 (https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#v0660)\n// Because Gesture Handler supports versions 0.64+, we have to handle situations where someone uses older version of react native.\n// That's why if `queueMicrotask` doesn't exist, we use `setImmediate` instead, since it was used before we switched to `queueMicrotask` in version 2.11.0\nexport const ghQueueMicrotask =\n typeof queueMicrotask === 'function' ? queueMicrotask : setImmediate;\n"]}

View File

@@ -0,0 +1,11 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const flingGestureHandlerProps = ['numberOfPointers', 'direction'];
export const flingHandlerName = 'FlingGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const FlingGestureHandler = createHandler({
name: flingHandlerName,
allowedProps: [...baseGestureHandlerProps, ...flingGestureHandlerProps],
config: {}
});
//# sourceMappingURL=FlingGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["FlingGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","flingGestureHandlerProps","flingHandlerName","FlingGestureHandler","name","allowedProps","config"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,wBAAwB,GAAG,CACtC,kBADsC,EAEtC,WAFsC,CAAjC;AAsCP,OAAO,MAAMC,gBAAgB,GAAG,qBAAzB;AAGP;AACA,OAAO,MAAMC,mBAAmB,GAAGJ,aAAa,CAG9C;AACAK,EAAAA,IAAI,EAAEF,gBADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGL,uBADS,EAEZ,GAAGC,wBAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AANR,CAH8C,CAAzC","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const flingGestureHandlerProps = [\n 'numberOfPointers',\n 'direction',\n] as const;\n\nexport type FlingGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\nexport interface FlingGestureConfig {\n /**\n * Expressed allowed direction of movement. It's possible to pass one or many\n * directions in one parameter:\n *\n * ```js\n * direction={Directions.RIGHT | Directions.LEFT}\n * ```\n *\n * or\n *\n * ```js\n * direction={Directions.DOWN}\n * ```\n */\n direction?: number;\n\n /**\n * Determine exact number of points required to handle the fling gesture.\n */\n numberOfPointers?: number;\n}\n\nexport interface FlingGestureHandlerProps\n extends BaseGestureHandlerProps<FlingGestureHandlerEventPayload>,\n FlingGestureConfig {}\n\nexport const flingHandlerName = 'FlingGestureHandler';\n\nexport type FlingGestureHandler = typeof FlingGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const FlingGestureHandler = createHandler<\n FlingGestureHandlerProps,\n FlingGestureHandlerEventPayload\n>({\n name: flingHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...flingGestureHandlerProps,\n ] as const,\n config: {},\n});\n"]}

View File

@@ -0,0 +1,31 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import React from 'react';
import { tagMessage } from '../utils';
import PlatformConstants from '../PlatformConstants';
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const forceTouchGestureHandlerProps = ['minForce', 'maxForce', 'feedbackOnActivation']; // implicit `children` prop has been removed in @types/react^18.0.0
class ForceTouchFallback extends React.Component {
componentDidMount() {
console.warn(tagMessage('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'));
}
render() {
return this.props.children;
}
}
_defineProperty(ForceTouchFallback, "forceTouchAvailable", false);
export const forceTouchHandlerName = 'ForceTouchGestureHandler'; // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const ForceTouchGestureHandler = PlatformConstants !== null && PlatformConstants !== void 0 && PlatformConstants.forceTouchAvailable ? createHandler({
name: forceTouchHandlerName,
allowedProps: [...baseGestureHandlerProps, ...forceTouchGestureHandlerProps],
config: {}
}) : ForceTouchFallback;
ForceTouchGestureHandler.forceTouchAvailable = (PlatformConstants === null || PlatformConstants === void 0 ? void 0 : PlatformConstants.forceTouchAvailable) || false;
//# sourceMappingURL=ForceTouchGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["ForceTouchGestureHandler.ts"],"names":["React","tagMessage","PlatformConstants","createHandler","baseGestureHandlerProps","forceTouchGestureHandlerProps","ForceTouchFallback","Component","componentDidMount","console","warn","render","props","children","forceTouchHandlerName","ForceTouchGestureHandler","forceTouchAvailable","name","allowedProps","config"],"mappings":";;AAAA,OAAOA,KAAP,MAAyC,OAAzC;AACA,SAASC,UAAT,QAA2B,UAA3B;AACA,OAAOC,iBAAP,MAA8B,sBAA9B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,6BAA6B,GAAG,CAC3C,UAD2C,EAE3C,UAF2C,EAG3C,sBAH2C,CAAtC,C,CAMP;;AACA,MAAMC,kBAAN,SAAiCN,KAAK,CAACO,SAAvC,CAA6E;AAE3EC,EAAAA,iBAAiB,GAAG;AAClBC,IAAAA,OAAO,CAACC,IAAR,CACET,UAAU,CACR,8NADQ,CADZ;AAKD;;AACDU,EAAAA,MAAM,GAAG;AACP,WAAO,KAAKC,KAAL,CAAWC,QAAlB;AACD;;AAX0E;;gBAAvEP,kB,yBACyB,K;;AAsD/B,OAAO,MAAMQ,qBAAqB,GAAG,0BAA9B,C,CAEP;;AACA,OAAO,MAAMC,wBAAwB,GAAGb,iBAAiB,SAAjB,IAAAA,iBAAiB,WAAjB,IAAAA,iBAAiB,CAAEc,mBAAnB,GACpCb,aAAa,CAGX;AACAc,EAAAA,IAAI,EAAEH,qBADN;AAEAI,EAAAA,YAAY,EAAE,CACZ,GAAGd,uBADS,EAEZ,GAAGC,6BAFS,CAFd;AAMAc,EAAAA,MAAM,EAAE;AANR,CAHW,CADuB,GAYpCb,kBAZG;AAcNS,wBAAD,CAAuDC,mBAAvD,GACE,CAAAd,iBAAiB,SAAjB,IAAAA,iBAAiB,WAAjB,YAAAA,iBAAiB,CAAEc,mBAAnB,KAA0C,KAD5C","sourcesContent":["import React, { PropsWithChildren } from 'react';\nimport { tagMessage } from '../utils';\nimport PlatformConstants from '../PlatformConstants';\nimport createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const forceTouchGestureHandlerProps = [\n 'minForce',\n 'maxForce',\n 'feedbackOnActivation',\n] as const;\n\n// implicit `children` prop has been removed in @types/react^18.0.0\nclass ForceTouchFallback extends React.Component<PropsWithChildren<unknown>> {\n static forceTouchAvailable = false;\n componentDidMount() {\n console.warn(\n tagMessage(\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 }\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\n /**\n * The pressure of a touch.\n */\n force: number;\n};\n\nexport interface ForceTouchGestureConfig {\n /**\n *\n * A minimal pressure that is required before handler can activate. Should be a\n * value from range `[0.0, 1.0]`. Default is `0.2`.\n */\n minForce?: number;\n\n /**\n * A maximal pressure that could be applied for handler. If the pressure is\n * greater, handler fails. Should be a value from range `[0.0, 1.0]`.\n */\n maxForce?: number;\n\n /**\n * Boolean value defining if haptic feedback has to be performed on\n * activation.\n */\n feedbackOnActivation?: boolean;\n}\n\nexport interface ForceTouchGestureHandlerProps\n extends BaseGestureHandlerProps<ForceTouchGestureHandlerEventPayload>,\n ForceTouchGestureConfig {}\n\nexport type ForceTouchGestureHandler = typeof ForceTouchGestureHandler & {\n forceTouchAvailable: boolean;\n};\n\nexport const forceTouchHandlerName = 'ForceTouchGestureHandler';\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const ForceTouchGestureHandler = PlatformConstants?.forceTouchAvailable\n ? createHandler<\n ForceTouchGestureHandlerProps,\n ForceTouchGestureHandlerEventPayload\n >({\n name: forceTouchHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...forceTouchGestureHandlerProps,\n ] as const,\n config: {},\n })\n : ForceTouchFallback;\n\n(ForceTouchGestureHandler as ForceTouchGestureHandler).forceTouchAvailable =\n PlatformConstants?.forceTouchAvailable || false;\n"]}

View File

@@ -0,0 +1,13 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const longPressGestureHandlerProps = ['minDurationMs', 'maxDist'];
export const longPressHandlerName = 'LongPressGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const LongPressGestureHandler = createHandler({
name: longPressHandlerName,
allowedProps: [...baseGestureHandlerProps, ...longPressGestureHandlerProps],
config: {
shouldCancelWhenOutside: true
}
});
//# sourceMappingURL=LongPressGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["LongPressGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","longPressGestureHandlerProps","longPressHandlerName","LongPressGestureHandler","name","allowedProps","config","shouldCancelWhenOutside"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,4BAA4B,GAAG,CAC1C,eAD0C,EAE1C,SAF0C,CAArC;AAiEP,OAAO,MAAMC,oBAAoB,GAAG,yBAA7B;AAGP;AACA,OAAO,MAAMC,uBAAuB,GAAGJ,aAAa,CAGlD;AACAK,EAAAA,IAAI,EAAEF,oBADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGL,uBADS,EAEZ,GAAGC,4BAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AACNC,IAAAA,uBAAuB,EAAE;AADnB;AANR,CAHkD,CAA7C","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const longPressGestureHandlerProps = [\n 'minDurationMs',\n 'maxDist',\n] as const;\n\nexport type LongPressGestureHandlerEventPayload = {\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n x: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n y: number;\n\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the window. It is recommended to use `absoluteX` instead of\n * `x` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteX: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the window. It is recommended to use `absoluteY` instead of\n * `y` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteY: number;\n\n /**\n * Duration of the long press (time since the start of the event), expressed\n * in milliseconds.\n */\n duration: number;\n};\n\nexport interface LongPressGestureConfig {\n /**\n * Minimum time, expressed in milliseconds, that a finger must remain pressed on\n * the corresponding view. The default value is 500.\n */\n minDurationMs?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel during a long press gesture. If the finger travels\n * further than the defined distance and the handler hasn't yet activated, it\n * will fail to recognize the gesture. The default value is 10.\n */\n maxDist?: number;\n}\n\nexport interface LongPressGestureHandlerProps\n extends BaseGestureHandlerProps<LongPressGestureHandlerEventPayload>,\n LongPressGestureConfig {}\n\nexport const longPressHandlerName = 'LongPressGestureHandler';\n\nexport type LongPressGestureHandler = typeof LongPressGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const LongPressGestureHandler = createHandler<\n LongPressGestureHandlerProps,\n LongPressGestureHandlerEventPayload\n>({\n name: longPressHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...longPressGestureHandlerProps,\n ] as const,\n config: {\n shouldCancelWhenOutside: true,\n },\n});\n"]}

View File

@@ -0,0 +1,12 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const nativeViewGestureHandlerProps = ['shouldActivateOnStart', 'disallowInterruption'];
export const nativeViewProps = [...baseGestureHandlerProps, ...nativeViewGestureHandlerProps];
export const nativeViewHandlerName = 'NativeViewGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const NativeViewGestureHandler = createHandler({
name: nativeViewHandlerName,
allowedProps: nativeViewProps,
config: {}
});
//# sourceMappingURL=NativeViewGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["NativeViewGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","nativeViewGestureHandlerProps","nativeViewProps","nativeViewHandlerName","NativeViewGestureHandler","name","allowedProps","config"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,6BAA6B,GAAG,CAC3C,uBAD2C,EAE3C,sBAF2C,CAAtC;AAgCP,OAAO,MAAMC,eAAe,GAAG,CAC7B,GAAGF,uBAD0B,EAE7B,GAAGC,6BAF0B,CAAxB;AAKP,OAAO,MAAME,qBAAqB,GAAG,0BAA9B;AAGP;AACA,OAAO,MAAMC,wBAAwB,GAAGL,aAAa,CAGnD;AACAM,EAAAA,IAAI,EAAEF,qBADN;AAEAG,EAAAA,YAAY,EAAEJ,eAFd;AAGAK,EAAAA,MAAM,EAAE;AAHR,CAHmD,CAA9C","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const nativeViewGestureHandlerProps = [\n 'shouldActivateOnStart',\n 'disallowInterruption',\n] as const;\n\nexport interface NativeViewGestureConfig {\n /**\n * Android only.\n *\n * Determines whether the handler should check for an existing touch event on\n * instantiation.\n */\n shouldActivateOnStart?: boolean;\n\n /**\n * When `true`, cancels all other gesture handlers when this\n * `NativeViewGestureHandler` receives an `ACTIVE` state event.\n */\n disallowInterruption?: boolean;\n}\n\nexport interface NativeViewGestureHandlerProps\n extends BaseGestureHandlerProps<NativeViewGestureHandlerPayload>,\n NativeViewGestureConfig {}\n\nexport type NativeViewGestureHandlerPayload = {\n /**\n * True if gesture was performed inside of containing view, false otherwise.\n */\n pointerInside: boolean;\n};\n\nexport const nativeViewProps = [\n ...baseGestureHandlerProps,\n ...nativeViewGestureHandlerProps,\n] as const;\n\nexport const nativeViewHandlerName = 'NativeViewGestureHandler';\n\nexport type NativeViewGestureHandler = typeof NativeViewGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const NativeViewGestureHandler = createHandler<\n NativeViewGestureHandlerProps,\n NativeViewGestureHandlerPayload\n>({\n name: nativeViewHandlerName,\n allowedProps: nativeViewProps,\n config: {},\n});\n"]}

View File

@@ -0,0 +1,107 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const panGestureHandlerProps = ['activeOffsetY', 'activeOffsetX', 'failOffsetY', 'failOffsetX', 'minDist', 'minVelocity', 'minVelocityX', 'minVelocityY', 'minPointers', 'maxPointers', 'avgTouches', 'enableTrackpadTwoFingerGesture', 'activateAfterLongPress'];
export const panGestureHandlerCustomNativeProps = ['activeOffsetYStart', 'activeOffsetYEnd', 'activeOffsetXStart', 'activeOffsetXEnd', 'failOffsetYStart', 'failOffsetYEnd', 'failOffsetXStart', 'failOffsetXEnd'];
export const panHandlerName = 'PanGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const PanGestureHandler = createHandler({
name: panHandlerName,
allowedProps: [...baseGestureHandlerProps, ...panGestureHandlerProps],
config: {},
transformProps: managePanProps,
customNativeProps: panGestureHandlerCustomNativeProps
});
function validatePanGestureHandlerProps(props) {
if (Array.isArray(props.activeOffsetX) && (props.activeOffsetX[0] > 0 || props.activeOffsetX[1] < 0)) {
throw new Error(`First element of activeOffsetX should be negative, a the second one should be positive`);
}
if (Array.isArray(props.activeOffsetY) && (props.activeOffsetY[0] > 0 || props.activeOffsetY[1] < 0)) {
throw new Error(`First element of activeOffsetY should be negative, a the second one should be positive`);
}
if (Array.isArray(props.failOffsetX) && (props.failOffsetX[0] > 0 || props.failOffsetX[1] < 0)) {
throw new Error(`First element of failOffsetX should be negative, a the second one should be positive`);
}
if (Array.isArray(props.failOffsetY) && (props.failOffsetY[0] > 0 || props.failOffsetY[1] < 0)) {
throw new Error(`First element of failOffsetY should be negative, a the second one should be positive`);
}
if (props.minDist && (props.failOffsetX || props.failOffsetY)) {
throw new Error(`It is not supported to use minDist with failOffsetX or failOffsetY, use activeOffsetX and activeOffsetY instead`);
}
if (props.minDist && (props.activeOffsetX || props.activeOffsetY)) {
throw new Error(`It is not supported to use minDist with activeOffsetX or activeOffsetY`);
}
}
function transformPanGestureHandlerProps(props) {
const res = { ...props
};
if (props.activeOffsetX !== undefined) {
delete res.activeOffsetX;
if (Array.isArray(props.activeOffsetX)) {
res.activeOffsetXStart = props.activeOffsetX[0];
res.activeOffsetXEnd = props.activeOffsetX[1];
} else if (props.activeOffsetX < 0) {
res.activeOffsetXStart = props.activeOffsetX;
} else {
res.activeOffsetXEnd = props.activeOffsetX;
}
}
if (props.activeOffsetY !== undefined) {
delete res.activeOffsetY;
if (Array.isArray(props.activeOffsetY)) {
res.activeOffsetYStart = props.activeOffsetY[0];
res.activeOffsetYEnd = props.activeOffsetY[1];
} else if (props.activeOffsetY < 0) {
res.activeOffsetYStart = props.activeOffsetY;
} else {
res.activeOffsetYEnd = props.activeOffsetY;
}
}
if (props.failOffsetX !== undefined) {
delete res.failOffsetX;
if (Array.isArray(props.failOffsetX)) {
res.failOffsetXStart = props.failOffsetX[0];
res.failOffsetXEnd = props.failOffsetX[1];
} else if (props.failOffsetX < 0) {
res.failOffsetXStart = props.failOffsetX;
} else {
res.failOffsetXEnd = props.failOffsetX;
}
}
if (props.failOffsetY !== undefined) {
delete res.failOffsetY;
if (Array.isArray(props.failOffsetY)) {
res.failOffsetYStart = props.failOffsetY[0];
res.failOffsetYEnd = props.failOffsetY[1];
} else if (props.failOffsetY < 0) {
res.failOffsetYStart = props.failOffsetY;
} else {
res.failOffsetYEnd = props.failOffsetY;
}
}
return res;
}
export function managePanProps(props) {
if (__DEV__) {
validatePanGestureHandlerProps(props);
}
return transformPanGestureHandlerProps(props);
}
//# sourceMappingURL=PanGestureHandler.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const pinchHandlerName = 'PinchGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const PinchGestureHandler = createHandler({
name: pinchHandlerName,
allowedProps: baseGestureHandlerProps,
config: {}
});
//# sourceMappingURL=PinchGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PinchGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","pinchHandlerName","PinchGestureHandler","name","allowedProps","config"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAmCA,OAAO,MAAMC,gBAAgB,GAAG,qBAAzB;AAGP;AACA,OAAO,MAAMC,mBAAmB,GAAGH,aAAa,CAG9C;AACAI,EAAAA,IAAI,EAAEF,gBADN;AAEAG,EAAAA,YAAY,EAAEJ,uBAFd;AAGAK,EAAAA,MAAM,EAAE;AAHR,CAH8C,CAAzC","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport type PinchGestureHandlerEventPayload = {\n /**\n * The scale factor relative to the points of the two touches in screen\n * coordinates.\n */\n scale: number;\n\n /**\n * Position expressed in points along X axis of center anchor point of\n * gesture.\n */\n focalX: number;\n\n /**\n * Position expressed in points along Y axis of center anchor point of\n * gesture.\n */\n focalY: number;\n\n /**\n *\n * Velocity of the pan gesture the current moment. The value is expressed in\n * point units per second.\n */\n velocity: number;\n};\n\nexport interface PinchGestureHandlerProps\n extends BaseGestureHandlerProps<PinchGestureHandlerEventPayload> {}\n\nexport const pinchHandlerName = 'PinchGestureHandler';\n\nexport type PinchGestureHandler = typeof PinchGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const PinchGestureHandler = createHandler<\n PinchGestureHandlerProps,\n PinchGestureHandlerEventPayload\n>({\n name: pinchHandlerName,\n allowedProps: baseGestureHandlerProps,\n config: {},\n});\n"]}

View File

@@ -0,0 +1,3 @@
// @ts-ignore it's not exported so we need to import it from path
export { PressabilityDebugView } from 'react-native/Libraries/Pressability/PressabilityDebug';
//# sourceMappingURL=PressabilityDebugView.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PressabilityDebugView.tsx"],"names":["PressabilityDebugView"],"mappings":"AAAA;AACA,SAASA,qBAAT,QAAsC,uDAAtC","sourcesContent":["// @ts-ignore it's not exported so we need to import it from path\nexport { PressabilityDebugView } from 'react-native/Libraries/Pressability/PressabilityDebug';\n"]}

View File

@@ -0,0 +1,5 @@
// PressabilityDebugView is not implemented in react-native-web
export function PressabilityDebugView() {
return null;
}
//# sourceMappingURL=PressabilityDebugView.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PressabilityDebugView.web.tsx"],"names":["PressabilityDebugView"],"mappings":"AAAA;AACA,OAAO,SAASA,qBAAT,GAAiC;AACtC,SAAO,IAAP;AACD","sourcesContent":["// PressabilityDebugView is not implemented in react-native-web\nexport function PressabilityDebugView() {\n return null;\n}\n"]}

View File

@@ -0,0 +1,10 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const rotationHandlerName = 'RotationGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const RotationGestureHandler = createHandler({
name: rotationHandlerName,
allowedProps: baseGestureHandlerProps,
config: {}
});
//# sourceMappingURL=RotationGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["RotationGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","rotationHandlerName","RotationGestureHandler","name","allowedProps","config"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAmCA,OAAO,MAAMC,mBAAmB,GAAG,wBAA5B;AAGP;AACA,OAAO,MAAMC,sBAAsB,GAAGH,aAAa,CAGjD;AACAI,EAAAA,IAAI,EAAEF,mBADN;AAEAG,EAAAA,YAAY,EAAEJ,uBAFd;AAGAK,EAAAA,MAAM,EAAE;AAHR,CAHiD,CAA5C","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport type RotationGestureHandlerEventPayload = {\n /**\n * Amount rotated, expressed in radians, from the gesture's focal point\n * (anchor).\n */\n rotation: number;\n\n /**\n * X coordinate, expressed in points, of the gesture's central focal point\n * (anchor).\n */\n anchorX: number;\n\n /**\n * Y coordinate, expressed in points, of the gesture's central focal point\n * (anchor).\n */\n anchorY: number;\n\n /**\n *\n * Instantaneous velocity, expressed in point units per second, of the\n * gesture.\n */\n velocity: number;\n};\n\nexport interface RotationGestureHandlerProps\n extends BaseGestureHandlerProps<RotationGestureHandlerEventPayload> {}\n\nexport const rotationHandlerName = 'RotationGestureHandler';\n\nexport type RotationGestureHandler = typeof RotationGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const RotationGestureHandler = createHandler<\n RotationGestureHandlerProps,\n RotationGestureHandlerEventPayload\n>({\n name: rotationHandlerName,\n allowedProps: baseGestureHandlerProps,\n config: {},\n});\n"]}

View File

@@ -0,0 +1,13 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const tapGestureHandlerProps = ['maxDurationMs', 'maxDelayMs', 'numberOfTaps', 'maxDeltaX', 'maxDeltaY', 'maxDist', 'minPointers'];
export const tapHandlerName = 'TapGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const TapGestureHandler = createHandler({
name: tapHandlerName,
allowedProps: [...baseGestureHandlerProps, ...tapGestureHandlerProps],
config: {
shouldCancelWhenOutside: true
}
});
//# sourceMappingURL=TapGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["TapGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","tapGestureHandlerProps","tapHandlerName","TapGestureHandler","name","allowedProps","config","shouldCancelWhenOutside"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,sBAAsB,GAAG,CACpC,eADoC,EAEpC,YAFoC,EAGpC,cAHoC,EAIpC,WAJoC,EAKpC,WALoC,EAMpC,SANoC,EAOpC,aAPoC,CAA/B;AAuEP,OAAO,MAAMC,cAAc,GAAG,mBAAvB;AAGP;AACA,OAAO,MAAMC,iBAAiB,GAAGJ,aAAa,CAG5C;AACAK,EAAAA,IAAI,EAAEF,cADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGL,uBADS,EAEZ,GAAGC,sBAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AACNC,IAAAA,uBAAuB,EAAE;AADnB;AANR,CAH4C,CAAvC","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const tapGestureHandlerProps = [\n 'maxDurationMs',\n 'maxDelayMs',\n 'numberOfTaps',\n 'maxDeltaX',\n 'maxDeltaY',\n 'maxDist',\n 'minPointers',\n] as const;\n\nexport type TapGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\nexport interface TapGestureConfig {\n /**\n * Minimum number of pointers (fingers) required to be placed before the\n * handler activates. Should be a positive integer.\n * The default value is 1.\n */\n minPointers?: number;\n\n /**\n * Maximum time, expressed in milliseconds, that defines how fast a finger\n * must be released after a touch. The default value is 500.\n */\n maxDurationMs?: number;\n\n /**\n * Maximum time, expressed in milliseconds, that can pass before the next tap\n * if many taps are required. The default value is 500.\n */\n maxDelayMs?: number;\n\n /**\n * Number of tap gestures required to activate the handler. The default value\n * is 1.\n */\n numberOfTaps?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel along the X axis during a tap gesture. If the finger\n * travels further than the defined distance along the X axis and the handler\n * hasn't yet activated, it will fail to recognize the gesture.\n */\n maxDeltaX?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel along the Y axis during a tap gesture. If the finger\n * travels further than the defined distance along the Y axis and the handler\n * hasn't yet activated, it will fail to recognize the gesture.\n */\n maxDeltaY?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel during a tap gesture. If the finger travels further than\n * the defined distance and the handler hasn't yet\n * activated, it will fail to recognize the gesture.\n */\n maxDist?: number;\n}\n\nexport interface TapGestureHandlerProps\n extends BaseGestureHandlerProps<TapGestureHandlerEventPayload>,\n TapGestureConfig {}\n\nexport const tapHandlerName = 'TapGestureHandler';\n\nexport type TapGestureHandler = typeof TapGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const TapGestureHandler = createHandler<\n TapGestureHandlerProps,\n TapGestureHandlerEventPayload\n>({\n name: tapHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...tapGestureHandlerProps,\n ] as const,\n config: {\n shouldCancelWhenOutside: true,\n },\n});\n"]}

View File

@@ -0,0 +1,443 @@
var _UIManagerAny$getView, _UIManagerAny$getView2, _UIManagerAny$getCons;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import * as React from 'react';
import { Platform, UIManager, DeviceEventEmitter } from 'react-native';
import { customDirectEventTypes } from './customDirectEventTypes'; // @ts-ignore - it isn't typed by TS & don't have definitelyTyped types
import deepEqual from 'lodash/isEqual';
import RNGestureHandlerModule from '../RNGestureHandlerModule';
import { State } from '../State';
import { handlerIDToTag, getNextHandlerTag, registerOldGestureHandler } from './handlersRegistry';
import { filterConfig, findNodeHandle, scheduleFlushOperations } from './gestureHandlerCommon';
import { isFabric, isJestEnv, tagMessage } from '../utils';
import { ActionType } from '../ActionType';
import { PressabilityDebugView } from './PressabilityDebugView';
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
import { ghQueueMicrotask } from '../ghQueueMicrotask';
const UIManagerAny = UIManager;
customDirectEventTypes.topGestureHandlerEvent = {
registrationName: 'onGestureHandlerEvent'
};
const customGHEventsConfigFabricAndroid = {
topOnGestureHandlerEvent: {
registrationName: 'onGestureHandlerEvent'
},
topOnGestureHandlerStateChange: {
registrationName: 'onGestureHandlerStateChange'
}
};
const customGHEventsConfig = {
onGestureHandlerEvent: {
registrationName: 'onGestureHandlerEvent'
},
onGestureHandlerStateChange: {
registrationName: 'onGestureHandlerStateChange'
},
// When using React Native Gesture Handler for Animated.event with useNativeDriver: true
// on Android with Fabric enabled, the native part still sends the native events to JS
// but prefixed with "top". We cannot simply rename the events above so they are prefixed
// with "top" instead of "on" because in such case Animated.events would not be registered.
// That's why we need to register another pair of event names.
// The incoming events will be queued but never handled.
// Without this piece of code below, you'll get the following JS error:
// Unsupported top level event type "topOnGestureHandlerEvent" dispatched
...(isFabric() && Platform.OS === 'android' && customGHEventsConfigFabricAndroid)
}; // Add gesture specific events to genericDirectEventTypes object exported from UIManager
// native module.
// Once new event types are registered with react it is possible to dispatch these
// events to all kind of native views.
UIManagerAny.genericDirectEventTypes = { ...UIManagerAny.genericDirectEventTypes,
...customGHEventsConfig
}; // In newer versions of RN the `genericDirectEventTypes` is located in the object
// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make
// it compatible with RN 61+
const UIManagerConstants = (_UIManagerAny$getView = (_UIManagerAny$getView2 = UIManagerAny.getViewManagerConfig) === null || _UIManagerAny$getView2 === void 0 ? void 0 : _UIManagerAny$getView2.call(UIManagerAny, 'getConstants')) !== null && _UIManagerAny$getView !== void 0 ? _UIManagerAny$getView : (_UIManagerAny$getCons = UIManagerAny.getConstants) === null || _UIManagerAny$getCons === void 0 ? void 0 : _UIManagerAny$getCons.call(UIManagerAny);
if (UIManagerConstants) {
UIManagerConstants.genericDirectEventTypes = { ...UIManagerConstants.genericDirectEventTypes,
...customGHEventsConfig
};
} // Wrap JS responder calls and notify gesture handler manager
const {
setJSResponder: oldSetJSResponder = () => {//no operation
},
clearJSResponder: oldClearJSResponder = () => {//no operation
}
} = UIManagerAny;
UIManagerAny.setJSResponder = (tag, blockNativeResponder) => {
RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);
oldSetJSResponder(tag, blockNativeResponder);
};
UIManagerAny.clearJSResponder = () => {
RNGestureHandlerModule.handleClearJSResponder();
oldClearJSResponder();
};
let allowTouches = true;
const DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android'; // Toggled inspector blocks touch events in order to allow inspecting on Android
// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component
if (DEV_ON_ANDROID) {
DeviceEventEmitter.addListener('toggleElementInspector', () => {
allowTouches = !allowTouches;
});
}
function hasUnresolvedRefs(props) {
// TODO(TS) - add type for extract arg
const extract = refs => {
if (!Array.isArray(refs)) {
return refs && refs.current === null;
}
return refs.some(r => r && r.current === null);
};
return extract(props['simultaneousHandlers']) || extract(props['waitFor']);
}
const stateToPropMappings = {
[State.UNDETERMINED]: undefined,
[State.BEGAN]: 'onBegan',
[State.FAILED]: 'onFailed',
[State.CANCELLED]: 'onCancelled',
[State.ACTIVE]: 'onActivated',
[State.END]: 'onEnded'
};
const UNRESOLVED_REFS_RETRY_LIMIT = 1; // TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
export default function createHandler({
name,
allowedProps = [],
config = {},
transformProps,
customNativeProps = []
}) {
class Handler extends React.Component {
constructor(props) {
super(props);
_defineProperty(this, "handlerTag", void 0);
_defineProperty(this, "config", void 0);
_defineProperty(this, "propsRef", void 0);
_defineProperty(this, "isMountedRef", void 0);
_defineProperty(this, "viewNode", void 0);
_defineProperty(this, "viewTag", void 0);
_defineProperty(this, "inspectorToggleListener", void 0);
_defineProperty(this, "onGestureHandlerEvent", event => {
if (event.nativeEvent.handlerTag === this.handlerTag) {
if (typeof this.props.onGestureEvent === 'function') {
var _this$props$onGesture, _this$props;
(_this$props$onGesture = (_this$props = this.props).onGestureEvent) === null || _this$props$onGesture === void 0 ? void 0 : _this$props$onGesture.call(_this$props, event);
}
} else {
var _this$props$onGesture2, _this$props2;
(_this$props$onGesture2 = (_this$props2 = this.props).onGestureHandlerEvent) === null || _this$props$onGesture2 === void 0 ? void 0 : _this$props$onGesture2.call(_this$props2, event);
}
});
_defineProperty(this, "onGestureHandlerStateChange", event => {
if (event.nativeEvent.handlerTag === this.handlerTag) {
if (typeof this.props.onHandlerStateChange === 'function') {
var _this$props$onHandler, _this$props3;
(_this$props$onHandler = (_this$props3 = this.props).onHandlerStateChange) === null || _this$props$onHandler === void 0 ? void 0 : _this$props$onHandler.call(_this$props3, event);
}
const state = event.nativeEvent.state;
const stateEventName = stateToPropMappings[state];
const eventHandler = stateEventName && this.props[stateEventName];
if (eventHandler && typeof eventHandler === 'function') {
eventHandler(event);
}
} else {
var _this$props$onGesture3, _this$props4;
(_this$props$onGesture3 = (_this$props4 = this.props).onGestureHandlerStateChange) === null || _this$props$onGesture3 === void 0 ? void 0 : _this$props$onGesture3.call(_this$props4, event);
}
});
_defineProperty(this, "refHandler", node => {
this.viewNode = node;
const child = React.Children.only(this.props.children); // TODO(TS) fix ref type
const {
ref
} = child;
if (ref !== null) {
if (typeof ref === 'function') {
ref(node);
} else {
ref.current = node;
}
}
});
_defineProperty(this, "createGestureHandler", newConfig => {
this.config = newConfig;
RNGestureHandlerModule.createGestureHandler(name, this.handlerTag, newConfig);
});
_defineProperty(this, "attachGestureHandler", newViewTag => {
this.viewTag = newViewTag;
if (Platform.OS === 'web') {
// typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch
RNGestureHandlerModule.attachGestureHandler(this.handlerTag, newViewTag, ActionType.JS_FUNCTION_OLD_API, // ignored on web
this.propsRef);
} else {
registerOldGestureHandler(this.handlerTag, {
onGestureEvent: this.onGestureHandlerEvent,
onGestureStateChange: this.onGestureHandlerStateChange
});
const actionType = (() => {
var _this$props5, _this$props6;
const onGestureEvent = (_this$props5 = this.props) === null || _this$props5 === void 0 ? void 0 : _this$props5.onGestureEvent;
const isGestureHandlerWorklet = onGestureEvent && ('current' in onGestureEvent || 'workletEventHandler' in onGestureEvent);
const onHandlerStateChange = (_this$props6 = this.props) === null || _this$props6 === void 0 ? void 0 : _this$props6.onHandlerStateChange;
const isStateChangeHandlerWorklet = onHandlerStateChange && ('current' in onHandlerStateChange || 'workletEventHandler' in onHandlerStateChange);
const isReanimatedHandler = isGestureHandlerWorklet || isStateChangeHandlerWorklet;
if (isReanimatedHandler) {
// Reanimated worklet
return ActionType.REANIMATED_WORKLET;
} else if (onGestureEvent && '__isNative' in onGestureEvent) {
// Animated.event with useNativeDriver: true
return ActionType.NATIVE_ANIMATED_EVENT;
} else {
// JS callback or Animated.event with useNativeDriver: false
return ActionType.JS_FUNCTION_OLD_API;
}
})();
RNGestureHandlerModule.attachGestureHandler(this.handlerTag, newViewTag, actionType);
}
scheduleFlushOperations();
});
_defineProperty(this, "updateGestureHandler", newConfig => {
this.config = newConfig;
RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);
scheduleFlushOperations();
});
this.handlerTag = getNextHandlerTag();
this.config = {};
this.propsRef = /*#__PURE__*/React.createRef();
this.isMountedRef = /*#__PURE__*/React.createRef();
this.state = {
allowTouches
};
if (props.id) {
if (handlerIDToTag[props.id] !== undefined) {
throw new Error(`Handler with ID "${props.id}" already registered`);
}
handlerIDToTag[props.id] = this.handlerTag;
}
}
componentDidMount() {
const props = this.props;
this.isMountedRef.current = true;
if (DEV_ON_ANDROID) {
this.inspectorToggleListener = DeviceEventEmitter.addListener('toggleElementInspector', () => {
this.setState(_ => ({
allowTouches
}));
this.update(UNRESOLVED_REFS_RETRY_LIMIT);
});
}
if (hasUnresolvedRefs(props)) {
// If there are unresolved refs (e.g. ".current" has not yet been set)
// passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to
// _update method that will try to update native handler props using
// queueMicrotask. This makes it so update() function gets called after all
// react components are mounted and we expect the missing ref object to
// be resolved by then.
ghQueueMicrotask(() => {
this.update(UNRESOLVED_REFS_RETRY_LIMIT);
});
}
this.createGestureHandler(filterConfig(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config));
this.attachGestureHandler(findNodeHandle(this.viewNode)); // TODO(TS) - check if this can be null
}
componentDidUpdate() {
const viewTag = findNodeHandle(this.viewNode);
if (this.viewTag !== viewTag) {
this.attachGestureHandler(viewTag); // TODO(TS) - check interaction between _viewTag & findNodeHandle
}
this.update(UNRESOLVED_REFS_RETRY_LIMIT);
}
componentWillUnmount() {
var _this$inspectorToggle;
(_this$inspectorToggle = this.inspectorToggleListener) === null || _this$inspectorToggle === void 0 ? void 0 : _this$inspectorToggle.remove();
this.isMountedRef.current = false;
RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
scheduleFlushOperations(); // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context
const handlerID = this.props.id;
if (handlerID) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete handlerIDToTag[handlerID];
}
}
update(remainingTries) {
if (!this.isMountedRef.current) {
return;
}
const props = this.props; // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of
// `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying
// again is easy enough fix.
if (hasUnresolvedRefs(props) && remainingTries > 0) {
ghQueueMicrotask(() => {
this.update(remainingTries - 1);
});
} else {
const newConfig = filterConfig(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config);
if (!deepEqual(this.config, newConfig)) {
this.updateGestureHandler(newConfig);
}
}
}
setNativeProps(updates) {
const mergedProps = { ...this.props,
...updates
};
const newConfig = filterConfig(transformProps ? transformProps(mergedProps) : mergedProps, [...allowedProps, ...customNativeProps], config);
this.updateGestureHandler(newConfig);
}
render() {
var _this$props$testID;
if (__DEV__ && !this.context && !isJestEnv() && Platform.OS !== 'web') {
throw new Error(name + ' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.');
}
let gestureEventHandler = this.onGestureHandlerEvent; // Another instance of https://github.com/microsoft/TypeScript/issues/13995
const {
onGestureEvent,
onGestureHandlerEvent
} = this.props;
if (onGestureEvent && typeof onGestureEvent !== 'function') {
// If it's not a method it should be an native Animated.event
// object. We set it directly as the handler for the view
// In this case nested handlers are not going to be supported
if (onGestureHandlerEvent) {
throw new Error('Nesting touch handlers with native animated driver is not supported yet');
}
gestureEventHandler = onGestureEvent;
} else {
if (onGestureHandlerEvent && typeof onGestureHandlerEvent !== 'function') {
throw new Error('Nesting touch handlers with native animated driver is not supported yet');
}
}
let gestureStateEventHandler = this.onGestureHandlerStateChange; // Another instance of https://github.com/microsoft/TypeScript/issues/13995
const {
onHandlerStateChange,
onGestureHandlerStateChange
} = this.props;
if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {
// If it's not a method it should be an native Animated.event
// object. We set it directly as the handler for the view
// In this case nested handlers are not going to be supported
if (onGestureHandlerStateChange) {
throw new Error('Nesting touch handlers with native animated driver is not supported yet');
}
gestureStateEventHandler = onHandlerStateChange;
} else {
if (onGestureHandlerStateChange && typeof onGestureHandlerStateChange !== 'function') {
throw new Error('Nesting touch handlers with native animated driver is not supported yet');
}
}
const events = {
onGestureHandlerEvent: this.state.allowTouches ? gestureEventHandler : undefined,
onGestureHandlerStateChange: this.state.allowTouches ? gestureStateEventHandler : undefined
};
this.propsRef.current = events;
let child = null;
try {
child = React.Children.only(this.props.children);
} catch (e) {
throw new Error(tagMessage(`${name} got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`));
}
let grandChildren = child.props.children;
if (__DEV__ && child.type && (child.type === 'RNGestureHandlerButton' || child.type.name === 'View' || child.type.displayName === 'View')) {
grandChildren = React.Children.toArray(grandChildren);
grandChildren.push( /*#__PURE__*/React.createElement(PressabilityDebugView, {
key: "pressabilityDebugView",
color: "mediumspringgreen",
hitSlop: child.props.hitSlop
}));
}
return /*#__PURE__*/React.cloneElement(child, {
ref: this.refHandler,
collapsable: false,
...(isJestEnv() ? {
handlerType: name,
handlerTag: this.handlerTag
} : {}),
testID: (_this$props$testID = this.props.testID) !== null && _this$props$testID !== void 0 ? _this$props$testID : child.props.testID,
...events
}, grandChildren);
}
}
_defineProperty(Handler, "displayName", name);
_defineProperty(Handler, "contextType", GestureHandlerRootViewContext);
return Handler;
}
//# sourceMappingURL=createHandler.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,62 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import { useImperativeHandle, useRef } from 'react';
import { NativeViewGestureHandler, nativeViewProps } from './NativeViewGestureHandler';
/*
* This array should consist of:
* - All keys in propTypes from NativeGestureHandler
* (and all keys in GestureHandlerPropTypes)
* - 'onGestureHandlerEvent'
* - 'onGestureHandlerStateChange'
*/
const NATIVE_WRAPPER_PROPS_FILTER = [...nativeViewProps, 'onGestureHandlerEvent', 'onGestureHandlerStateChange'];
export default function createNativeWrapper(Component, config = {}) {
var _Component$render;
const ComponentWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
// filter out props that should be passed to gesture handler wrapper
const gestureHandlerProps = Object.keys(props).reduce((res, key) => {
// TS being overly protective with it's types, see https://github.com/microsoft/TypeScript/issues/26255#issuecomment-458013731 for more info
const allowedKeys = NATIVE_WRAPPER_PROPS_FILTER;
if (allowedKeys.includes(key)) {
// @ts-ignore FIXME(TS)
res[key] = props[key];
}
return res;
}, { ...config
} // watch out not to modify config
);
const _ref = useRef();
const _gestureHandlerRef = useRef();
useImperativeHandle(ref, // @ts-ignore TODO(TS) decide how nulls work in this context
() => {
const node = _gestureHandlerRef.current; // add handlerTag for relations config
if (_ref.current && node) {
// @ts-ignore FIXME(TS) think about createHandler return type
_ref.current.handlerTag = node.handlerTag;
return _ref.current;
}
return null;
}, [_ref, _gestureHandlerRef]);
return /*#__PURE__*/React.createElement(NativeViewGestureHandler, _extends({}, gestureHandlerProps, {
// @ts-ignore TODO(TS)
ref: _gestureHandlerRef
}), /*#__PURE__*/React.createElement(Component, _extends({}, props, {
ref: _ref
})));
}); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
ComponentWrapper.displayName = (Component === null || Component === void 0 ? void 0 : Component.displayName) || ( // @ts-ignore if render doesn't exist it will return undefined and go further
Component === null || Component === void 0 ? void 0 : (_Component$render = Component.render) === null || _Component$render === void 0 ? void 0 : _Component$render.name) || typeof Component === 'string' && Component || 'ComponentWrapper';
return ComponentWrapper;
}
//# sourceMappingURL=createNativeWrapper.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["createNativeWrapper.tsx"],"names":["React","useImperativeHandle","useRef","NativeViewGestureHandler","nativeViewProps","NATIVE_WRAPPER_PROPS_FILTER","createNativeWrapper","Component","config","ComponentWrapper","forwardRef","props","ref","gestureHandlerProps","Object","keys","reduce","res","key","allowedKeys","includes","_ref","_gestureHandlerRef","node","current","handlerTag","displayName","render","name"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,mBAAT,EAA8BC,MAA9B,QAA4C,OAA5C;AAEA,SACEC,wBADF,EAGEC,eAHF,QAIO,4BAJP;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,2BAA2B,GAAG,CAClC,GAAGD,eAD+B,EAElC,uBAFkC,EAGlC,6BAHkC,CAApC;AAMA,eAAe,SAASE,mBAAT,CACbC,SADa,EAEbC,MAA+C,GAAG,EAFrC,EAGb;AAAA;;AACA,QAAMC,gBAAgB,gBAAGT,KAAK,CAACU,UAAN,CAGvB,CAACC,KAAD,EAAQC,GAAR,KAAgB;AAChB;AACA,UAAMC,mBAAmB,GAAGC,MAAM,CAACC,IAAP,CAAYJ,KAAZ,EAAmBK,MAAnB,CAC1B,CAACC,GAAD,EAAMC,GAAN,KAAc;AACZ;AACA,YAAMC,WAA8B,GAAGd,2BAAvC;;AACA,UAAIc,WAAW,CAACC,QAAZ,CAAqBF,GAArB,CAAJ,EAA+B;AAC7B;AACAD,QAAAA,GAAG,CAACC,GAAD,CAAH,GAAWP,KAAK,CAACO,GAAD,CAAhB;AACD;;AACD,aAAOD,GAAP;AACD,KATyB,EAU1B,EAAE,GAAGT;AAAL,KAV0B,CAUZ;AAVY,KAA5B;;AAYA,UAAMa,IAAI,GAAGnB,MAAM,EAAnB;;AACA,UAAMoB,kBAAkB,GAAGpB,MAAM,EAAjC;;AACAD,IAAAA,mBAAmB,CACjBW,GADiB,EAEjB;AACA,UAAM;AACJ,YAAMW,IAAI,GAAGD,kBAAkB,CAACE,OAAhC,CADI,CAEJ;;AACA,UAAIH,IAAI,CAACG,OAAL,IAAgBD,IAApB,EAA0B;AACxB;AACAF,QAAAA,IAAI,CAACG,OAAL,CAAaC,UAAb,GAA0BF,IAAI,CAACE,UAA/B;AACA,eAAOJ,IAAI,CAACG,OAAZ;AACD;;AACD,aAAO,IAAP;AACD,KAZgB,EAajB,CAACH,IAAD,EAAOC,kBAAP,CAbiB,CAAnB;AAeA,wBACE,oBAAC,wBAAD,eACMT,mBADN;AAEE;AACA,MAAA,GAAG,EAAES;AAHP,qBAIE,oBAAC,SAAD,eAAeX,KAAf;AAAsB,MAAA,GAAG,EAAEU;AAA3B,OAJF,CADF;AAQD,GA1CwB,CAAzB,CADA,CA6CA;;AACAZ,EAAAA,gBAAgB,CAACiB,WAAjB,GACE,CAAAnB,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEmB,WAAX,OACA;AACAnB,EAAAA,SAFA,aAEAA,SAFA,4CAEAA,SAAS,CAAEoB,MAFX,sDAEA,kBAAmBC,IAFnB,KAGC,OAAOrB,SAAP,KAAqB,QAArB,IAAiCA,SAHlC,IAIA,kBALF;AAOA,SAAOE,gBAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { useImperativeHandle, useRef } from 'react';\n\nimport {\n NativeViewGestureHandler,\n NativeViewGestureHandlerProps,\n nativeViewProps,\n} from './NativeViewGestureHandler';\n\n/*\n * This array should consist of:\n * - All keys in propTypes from NativeGestureHandler\n * (and all keys in GestureHandlerPropTypes)\n * - 'onGestureHandlerEvent'\n * - 'onGestureHandlerStateChange'\n */\nconst NATIVE_WRAPPER_PROPS_FILTER = [\n ...nativeViewProps,\n 'onGestureHandlerEvent',\n 'onGestureHandlerStateChange',\n] as const;\n\nexport default function createNativeWrapper<P>(\n Component: React.ComponentType<P>,\n config: Readonly<NativeViewGestureHandlerProps> = {}\n) {\n const ComponentWrapper = React.forwardRef<\n React.ComponentType<any>,\n P & NativeViewGestureHandlerProps\n >((props, ref) => {\n // filter out props that should be passed to gesture handler wrapper\n const gestureHandlerProps = Object.keys(props).reduce(\n (res, key) => {\n // TS being overly protective with it's types, see https://github.com/microsoft/TypeScript/issues/26255#issuecomment-458013731 for more info\n const allowedKeys: readonly string[] = NATIVE_WRAPPER_PROPS_FILTER;\n if (allowedKeys.includes(key)) {\n // @ts-ignore FIXME(TS)\n res[key] = props[key];\n }\n return res;\n },\n { ...config } // watch out not to modify config\n );\n const _ref = useRef<React.ComponentType<P>>();\n const _gestureHandlerRef = useRef<React.ComponentType<P>>();\n useImperativeHandle(\n ref,\n // @ts-ignore TODO(TS) decide how nulls work in this context\n () => {\n const node = _gestureHandlerRef.current;\n // add handlerTag for relations config\n if (_ref.current && node) {\n // @ts-ignore FIXME(TS) think about createHandler return type\n _ref.current.handlerTag = node.handlerTag;\n return _ref.current;\n }\n return null;\n },\n [_ref, _gestureHandlerRef]\n );\n return (\n <NativeViewGestureHandler\n {...gestureHandlerProps}\n // @ts-ignore TODO(TS)\n ref={_gestureHandlerRef}>\n <Component {...props} ref={_ref} />\n </NativeViewGestureHandler>\n );\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n ComponentWrapper.displayName =\n Component?.displayName ||\n // @ts-ignore if render doesn't exist it will return undefined and go further\n Component?.render?.name ||\n (typeof Component === 'string' && Component) ||\n 'ComponentWrapper';\n\n return ComponentWrapper;\n}\n"]}

View File

@@ -0,0 +1,3 @@
// @ts-ignore - its taken straight from RN
export { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry';
//# sourceMappingURL=customDirectEventTypes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["customDirectEventTypes.ts"],"names":["customDirectEventTypes"],"mappings":"AAAA;AACA,SAASA,sBAAT,QAAuC,qEAAvC","sourcesContent":["// @ts-ignore - its taken straight from RN\nexport { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry';\n"]}

Some files were not shown because too many files have changed in this diff Show More