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,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ActionType = void 0;
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
exports.ActionType = ActionType;
//# 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":";;;;;;AAAO,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,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DiagonalDirections = exports.Directions = void 0;
const RIGHT = 1;
const LEFT = 2;
const UP = 4;
const DOWN = 8; // public interface
const Directions = {
RIGHT: RIGHT,
LEFT: LEFT,
UP: UP,
DOWN: DOWN
}; // internal interface
exports.Directions = Directions;
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
exports.DiagonalDirections = DiagonalDirections;
//# 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;;AACO,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;;;AACO,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,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.enableExperimentalWebImplementation = enableExperimentalWebImplementation;
exports.enableLegacyWebImplementation = enableLegacyWebImplementation;
exports.isNewWebImplementationEnabled = isNewWebImplementationEnabled;
var _reactNative = require("react-native");
let useNewWebImplementation = true;
let getWasCalled = false;
function enableExperimentalWebImplementation(_shouldEnable = true) {// NO-OP since the new implementation is now the default
}
function enableLegacyWebImplementation(shouldUseLegacyImplementation = true) {
if (_reactNative.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;
}
function isNewWebImplementationEnabled() {
getWasCalled = true;
return useNewWebImplementation;
}
//# sourceMappingURL=EnableNewWebImplementation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["EnableNewWebImplementation.ts"],"names":["useNewWebImplementation","getWasCalled","enableExperimentalWebImplementation","_shouldEnable","enableLegacyWebImplementation","shouldUseLegacyImplementation","Platform","OS","console","error","isNewWebImplementationEnabled"],"mappings":";;;;;;;;;AAAA;;AAEA,IAAIA,uBAAuB,GAAG,IAA9B;AACA,IAAIC,YAAY,GAAG,KAAnB;;AAEO,SAASC,mCAAT,CACLC,aAAa,GAAG,IADX,EAEC,CACN;AACD;;AAEM,SAASC,6BAAT,CACLC,6BAA6B,GAAG,IAD3B,EAEC;AACN,MACEC,sBAASC,EAAT,KAAgB,KAAhB,IACAP,uBAAuB,KAAK,CAACK,6BAF/B,EAGE;AACA;AACD;;AAED,MAAIJ,YAAJ,EAAkB;AAChBO,IAAAA,OAAO,CAACC,KAAR,CACE,mLADF;AAGA;AACD;;AAEDT,EAAAA,uBAAuB,GAAG,CAACK,6BAA3B;AACD;;AAEM,SAASK,6BAAT,GAAkD;AACvDT,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,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = /*#__PURE__*/_react.default.createContext(false);
exports.default = _default;
//# sourceMappingURL=GestureHandlerRootViewContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerRootViewContext.ts"],"names":["React","createContext"],"mappings":";;;;;;;AAAA;;;;4BAEeA,eAAMC,aAAN,CAAoB,KAApB,C","sourcesContent":["import React from 'react';\n\nexport default React.createContext(false);\n"]}

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _NativeModules$Platfo;
var _default = (_NativeModules$Platfo = _reactNative.NativeModules === null || _reactNative.NativeModules === void 0 ? void 0 : _reactNative.NativeModules.PlatformConstants) !== null && _NativeModules$Platfo !== void 0 ? _NativeModules$Platfo : _reactNative.Platform.constants;
exports.default = _default;
//# sourceMappingURL=PlatformConstants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PlatformConstants.ts"],"names":["NativeModules","PlatformConstants","Platform","constants"],"mappings":";;;;;;;AAAA;;;;wCAMgBA,0B,aAAAA,0B,uBAAAA,2BAAeC,iB,yEAC7BC,sBAASC,S","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,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = {
get forceTouchAvailable() {
return false;
}
};
exports.default = _default;
//# sourceMappingURL=PlatformConstants.web.js.map

View File

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

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PointerType = void 0;
let PointerType;
exports.PointerType = PointerType;
(function (PointerType) {
PointerType[PointerType["TOUCH"] = 0] = "TOUCH";
PointerType[PointerType["STYLUS"] = 1] = "STYLUS";
PointerType[PointerType["MOUSE"] = 2] = "MOUSE";
PointerType[PointerType["OTHER"] = 3] = "OTHER";
})(PointerType || (exports.PointerType = PointerType = {}));
//# sourceMappingURL=PointerType.js.map

View File

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

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _NativeRNGestureHandlerModule = _interopRequireDefault(require("./specs/NativeRNGestureHandlerModule"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// 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.
var _default = _NativeRNGestureHandlerModule.default;
exports.default = _default;
//# sourceMappingURL=RNGestureHandlerModule.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["RNGestureHandlerModule.ts"],"names":["Module"],"mappings":";;;;;;;AAGA;;;;AAHA;AACA;eAGeA,qC","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,109 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _EnableNewWebImplementation = require("./EnableNewWebImplementation");
var _Gestures = require("./web/Gestures");
var _InteractionManager = _interopRequireDefault(require("./web/tools/InteractionManager"));
var _NodeManager = _interopRequireDefault(require("./web/tools/NodeManager"));
var HammerNodeManager = _interopRequireWildcard(require("./web_hammer/NodeManager"));
var _GestureHandlerWebDelegate = require("./web/tools/GestureHandlerWebDelegate");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
handleSetJSResponder(tag, blockNativeResponder) {
console.warn('handleSetJSResponder: ', tag, blockNativeResponder);
},
handleClearJSResponder() {
console.warn('handleClearJSResponder: ');
},
createGestureHandler(handlerName, handlerTag, config) {
if ((0, _EnableNewWebImplementation.isNewWebImplementationEnabled)()) {
if (!(handlerName in _Gestures.Gestures)) {
throw new Error(`react-native-gesture-handler: ${handlerName} is not supported on web.`);
}
const GestureClass = _Gestures.Gestures[handlerName];
_NodeManager.default.createGestureHandler(handlerTag, new GestureClass(new _GestureHandlerWebDelegate.GestureHandlerWebDelegate()));
_InteractionManager.default.getInstance().configureInteractions(_NodeManager.default.getHandler(handlerTag), config);
} else {
if (!(handlerName in _Gestures.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 = _Gestures.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.default.Component)) {
return;
}
if ((0, _EnableNewWebImplementation.isNewWebImplementationEnabled)()) {
//@ts-ignore Types should be HTMLElement or React.Component
_NodeManager.default.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 ((0, _EnableNewWebImplementation.isNewWebImplementationEnabled)()) {
_NodeManager.default.getHandler(handlerTag).updateGestureConfig(newConfig);
_InteractionManager.default.getInstance().configureInteractions(_NodeManager.default.getHandler(handlerTag), newConfig);
} else {
HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
}
},
getGestureHandlerNode(handlerTag) {
if ((0, _EnableNewWebImplementation.isNewWebImplementationEnabled)()) {
return _NodeManager.default.getHandler(handlerTag);
} else {
return HammerNodeManager.getHandler(handlerTag);
}
},
dropGestureHandler(handlerTag) {
if ((0, _EnableNewWebImplementation.isNewWebImplementationEnabled)()) {
_NodeManager.default.dropGestureHandler(handlerTag);
} else {
HammerNodeManager.dropGestureHandler(handlerTag);
}
},
// eslint-disable-next-line @typescript-eslint/no-empty-function
flushOperations() {}
};
exports.default = _default;
//# sourceMappingURL=RNGestureHandlerModule.web.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Gestures = void 0;
var _PanGestureHandler = _interopRequireDefault(require("./web/handlers/PanGestureHandler"));
var _TapGestureHandler = _interopRequireDefault(require("./web/handlers/TapGestureHandler"));
var _LongPressGestureHandler = _interopRequireDefault(require("./web/handlers/LongPressGestureHandler"));
var _PinchGestureHandler = _interopRequireDefault(require("./web/handlers/PinchGestureHandler"));
var _RotationGestureHandler = _interopRequireDefault(require("./web/handlers/RotationGestureHandler"));
var _FlingGestureHandler = _interopRequireDefault(require("./web/handlers/FlingGestureHandler"));
var _NativeViewGestureHandler = _interopRequireDefault(require("./web/handlers/NativeViewGestureHandler"));
var _ManualGestureHandler = _interopRequireDefault(require("./web/handlers/ManualGestureHandler"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// GestureHandlers
const Gestures = {
NativeViewGestureHandler: _NativeViewGestureHandler.default,
PanGestureHandler: _PanGestureHandler.default,
TapGestureHandler: _TapGestureHandler.default,
LongPressGestureHandler: _LongPressGestureHandler.default,
PinchGestureHandler: _PinchGestureHandler.default,
RotationGestureHandler: _RotationGestureHandler.default,
FlingGestureHandler: _FlingGestureHandler.default,
ManualGestureHandler: _ManualGestureHandler.default
};
exports.Gestures = Gestures;
var _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
}
};
exports.default = _default;
//# sourceMappingURL=RNGestureHandlerModule.windows.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["RNGestureHandlerModule.windows.ts"],"names":["Gestures","NativeViewGestureHandler","PanGestureHandler","TapGestureHandler","LongPressGestureHandler","PinchGestureHandler","RotationGestureHandler","FlingGestureHandler","ManualGestureHandler","handleSetJSResponder","_tag","_blockNativeResponder","handleClearJSResponder","createGestureHandler","_handlerName","_handlerTag","_config","attachGestureHandler","_newView","_actionType","_propsRef","updateGestureHandler","_newConfig","getGestureHandlerNode","dropGestureHandler","flushOperations"],"mappings":";;;;;;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AARA;AAWO,MAAMA,QAAQ,GAAG;AACtBC,EAAAA,wBAAwB,EAAxBA,iCADsB;AAEtBC,EAAAA,iBAAiB,EAAjBA,0BAFsB;AAGtBC,EAAAA,iBAAiB,EAAjBA,0BAHsB;AAItBC,EAAAA,uBAAuB,EAAvBA,gCAJsB;AAKtBC,EAAAA,mBAAmB,EAAnBA,4BALsB;AAMtBC,EAAAA,sBAAsB,EAAtBA,+BANsB;AAOtBC,EAAAA,mBAAmB,EAAnBA,4BAPsB;AAQtBC,EAAAA,oBAAoB,EAApBA;AARsB,CAAjB;;eAWQ;AACbC,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,C","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,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "RNRenderer", {
enumerable: true,
get: function () {
return _ReactNative.default;
}
});
var _ReactNative = _interopRequireDefault(require("react-native/Libraries/Renderer/shims/ReactNative"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=RNRenderer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["RNRenderer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA","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,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RNRenderer = void 0;
const RNRenderer = {
findHostInstance_DEPRECATED: _ref => null
};
exports.RNRenderer = RNRenderer;
//# sourceMappingURL=RNRenderer.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["RNRenderer.web.ts"],"names":["RNRenderer","findHostInstance_DEPRECATED","_ref"],"mappings":";;;;;;AAAO,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,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.State = void 0;
// TODO use State from RNModule
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
exports.State = State;
//# sourceMappingURL=State.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["State.ts"],"names":["State","UNDETERMINED","FAILED","BEGAN","CANCELLED","ACTIVE","END"],"mappings":";;;;;;AAAA;AAEO,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,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TouchEventType = void 0;
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
exports.TouchEventType = TouchEventType;
//# 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":";;;;;;AAAO,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,568 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _invariant = _interopRequireDefault(require("invariant"));
var _reactNative = require("react-native");
var _PanGestureHandler = require("../handlers/PanGestureHandler");
var _TapGestureHandler = require("../handlers/TapGestureHandler");
var _State = require("../State");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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; }
const DRAG_TOSS = 0.05;
const IDLE = 'Idle';
const DRAGGING = 'Dragging';
const SETTLING = 'Settling';
class DrawerLayout extends React.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 = _reactNative.Animated.multiply(new _reactNative.Animated.Value(-1), dragXValue); // TODO(TS): (for all "as" in this file) make sure we can map this
touchX = _reactNative.Animated.add(new _reactNative.Animated.Value(containerWidth), _reactNative.Animated.multiply(new _reactNative.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 = _reactNative.Animated.add(touchX, _reactNative.Animated.multiply(new _reactNative.Animated.Value(-1), dragX));
const dragOffsetFromOnStartPosition = startPositionX.interpolate({
inputRange: [drawerWidth - 1, drawerWidth, drawerWidth + 1],
outputRange: [0, 0, 1]
});
translationX = _reactNative.Animated.add(dragX, dragOffsetFromOnStartPosition); // TODO: as above
}
this.openValue = _reactNative.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 = _reactNative.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.State.ACTIVE) {
this.handleRelease({
nativeEvent
});
} else if (nativeEvent.state === _State.State.ACTIVE) {
this.emitStateChanged(DRAGGING, false);
this.setState({
drawerState: DRAGGING
});
if (this.props.keyboardDismissMode === 'on-drag') {
_reactNative.Keyboard.dismiss();
}
if (this.props.hideStatusBar) {
_reactNative.StatusBar.setHidden(true, this.props.statusBarAnimation || 'slide');
}
}
});
_defineProperty(this, "onTapHandlerStateChange", ({
nativeEvent
}) => {
if (this.drawerShown && nativeEvent.oldState === _State.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) {
_reactNative.StatusBar.setHidden(willShow, this.props.statusBarAnimation || 'slide');
}
_reactNative.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 */
(0, _invariant.default)(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.TapGestureHandler, {
onHandlerStateChange: this.onTapHandlerStateChange
}, /*#__PURE__*/React.createElement(_reactNative.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 = _reactNative.I18nManager.isRTL ? fromLeft : !fromLeft;
const dynamicDrawerStyles = {
backgroundColor: drawerBackgroundColor,
width: drawerWidth
};
const openValue = this.openValue;
(0, _invariant.default)(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(_reactNative.Animated.View, {
style: styles.main,
onLayout: this.handleContainerLayout
}, /*#__PURE__*/React.createElement(_reactNative.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(_reactNative.Animated.View, {
pointerEvents: "box-none",
ref: this.accessibilityIsModalView,
accessibilityViewIsModal: this.drawerShown,
style: [styles.drawerContainer, drawerStyles, drawerContainerStyle]
}, /*#__PURE__*/React.createElement(_reactNative.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 _reactNative.Animated.Value(0);
const _touchX = new _reactNative.Animated.Value(0);
const _drawerTranslation = new _reactNative.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.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());
}
}
exports.default = DrawerLayout;
_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 = _reactNative.StyleSheet.create({
drawerContainer: { ..._reactNative.StyleSheet.absoluteFillObject,
zIndex: 1001,
flexDirection: 'row'
},
containerInFront: { ..._reactNative.StyleSheet.absoluteFillObject,
zIndex: 1002
},
containerOnBack: { ..._reactNative.StyleSheet.absoluteFillObject
},
main: {
flex: 1,
zIndex: 0,
overflow: 'hidden'
},
overlay: { ..._reactNative.StyleSheet.absoluteFillObject,
zIndex: 1000
}
});
//# sourceMappingURL=DrawerLayout.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,240 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "PureNativeButton", {
enumerable: true,
get: function () {
return _GestureHandlerButton.default;
}
});
exports.BorderlessButton = exports.RectButton = exports.BaseButton = exports.RawButton = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _createNativeWrapper = _interopRequireDefault(require("../handlers/createNativeWrapper"));
var _GestureHandlerButton = _interopRequireDefault(require("./GestureHandlerButton"));
var _State = require("../State");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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; }
const RawButton = (0, _createNativeWrapper.default)(_GestureHandlerButton.default, {
shouldCancelWhenOutside: false,
shouldActivateOnStart: false
});
exports.RawButton = RawButton;
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.State.ACTIVE;
if (active !== this.lastActive && this.props.onActiveStateChange) {
this.props.onActiveStateChange(active);
}
if (!this.longPressDetected && oldState === _State.State.ACTIVE && state !== _State.State.CANCELLED && this.lastActive && this.props.onPress) {
this.props.onPress(active);
}
if (!this.lastActive && // NativeViewGestureHandler sends different events based on platform
state === (_reactNative.Platform.OS !== 'android' ? _State.State.ACTIVE : _State.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.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.State.END || state === _State.State.CANCELLED || state === _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: (0, _reactNative.processColor)(rippleColor)
}, rest, {
onGestureEvent: this.onGestureEvent,
onHandlerStateChange: this.onHandlerStateChange
}));
}
}
exports.BaseButton = BaseButton;
_defineProperty(BaseButton, "defaultProps", {
delayLongPress: 600
});
const AnimatedBaseButton = _reactNative.Animated.createAnimatedComponent(BaseButton);
const btnStyles = _reactNative.StyleSheet.create({
underlay: {
position: 'absolute',
left: 0,
right: 0,
bottom: 0,
top: 0
}
});
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 (_reactNative.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 _reactNative.Animated.Value(0);
}
render() {
const {
children,
style,
...rest
} = this.props;
const resolvedStyle = _reactNative.StyleSheet.flatten(style !== null && style !== void 0 ? style : {});
return /*#__PURE__*/React.createElement(BaseButton, _extends({}, rest, {
style: resolvedStyle,
onActiveStateChange: this.onActiveStateChange
}), /*#__PURE__*/React.createElement(_reactNative.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);
}
}
exports.RectButton = RectButton;
_defineProperty(RectButton, "defaultProps", {
activeOpacity: 0.105,
underlayColor: 'black'
});
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 (_reactNative.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 _reactNative.Animated.Value(1);
}
render() {
const {
children,
style,
...rest
} = this.props;
return /*#__PURE__*/React.createElement(AnimatedBaseButton, _extends({}, rest, {
onActiveStateChange: this.onActiveStateChange,
style: [style, _reactNative.Platform.OS === 'ios' && {
opacity: this.opacity
}]
}), children);
}
}
exports.BorderlessButton = BorderlessButton;
_defineProperty(BorderlessButton, "defaultProps", {
activeOpacity: 0.3,
borderless: true
});
//# sourceMappingURL=GestureButtons.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,115 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FlatList = exports.DrawerLayoutAndroid = exports.TextInput = exports.Switch = exports.ScrollView = exports.RefreshControl = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _createNativeWrapper = _interopRequireDefault(require("../handlers/createNativeWrapper"));
var _NativeViewGestureHandler = require("../handlers/NativeViewGestureHandler");
var _utils = require("../utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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); }
const RefreshControl = (0, _createNativeWrapper.default)(_reactNative.RefreshControl, {
disallowInterruption: true,
shouldCancelWhenOutside: false
}); // eslint-disable-next-line @typescript-eslint/no-redeclare
exports.RefreshControl = RefreshControl;
const GHScrollView = (0, _createNativeWrapper.default)(_reactNative.ScrollView, {
disallowInterruption: true,
shouldCancelWhenOutside: false
});
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: [...(0, _utils.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
exports.ScrollView = ScrollView;
const Switch = (0, _createNativeWrapper.default)(_reactNative.Switch, {
shouldCancelWhenOutside: false,
shouldActivateOnStart: true,
disallowInterruption: true
}); // eslint-disable-next-line @typescript-eslint/no-redeclare
exports.Switch = Switch;
const TextInput = (0, _createNativeWrapper.default)(_reactNative.TextInput); // eslint-disable-next-line @typescript-eslint/no-redeclare
exports.TextInput = TextInput;
const DrawerLayoutAndroid = (0, _createNativeWrapper.default)(_reactNative.DrawerLayoutAndroid, {
disallowInterruption: true
}); // eslint-disable-next-line @typescript-eslint/no-redeclare
exports.DrawerLayoutAndroid = DrawerLayoutAndroid;
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 (_NativeViewGestureHandler.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(_reactNative.FlatList, _extends({
ref: ref
}, flatListProps, {
renderScrollComponent: scrollProps => /*#__PURE__*/React.createElement(ScrollView, _extends({}, scrollProps, scrollViewProps, {
waitFor: [...(0, _utils.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
exports.FlatList = FlatList;
//# sourceMappingURL=GestureComponents.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FlatList = exports.RefreshControl = exports.DrawerLayoutAndroid = exports.TextInput = exports.Switch = exports.ScrollView = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _createNativeWrapper = _interopRequireDefault(require("../handlers/createNativeWrapper"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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); }
const ScrollView = (0, _createNativeWrapper.default)(_reactNative.ScrollView, {
disallowInterruption: false
});
exports.ScrollView = ScrollView;
const Switch = (0, _createNativeWrapper.default)(_reactNative.Switch, {
shouldCancelWhenOutside: false,
shouldActivateOnStart: true,
disallowInterruption: true
});
exports.Switch = Switch;
const TextInput = (0, _createNativeWrapper.default)(_reactNative.TextInput);
exports.TextInput = TextInput;
const DrawerLayoutAndroid = () => {
console.warn('DrawerLayoutAndroid is not supported on web!');
return /*#__PURE__*/React.createElement(_reactNative.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
exports.DrawerLayoutAndroid = DrawerLayoutAndroid;
const RefreshControl = (0, _createNativeWrapper.default)(_reactNative.View);
exports.RefreshControl = RefreshControl;
const FlatList = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(_reactNative.FlatList, _extends({
ref: ref
}, props, {
renderScrollComponent: scrollProps => /*#__PURE__*/React.createElement(ScrollView, scrollProps)
})));
exports.FlatList = FlatList;
//# sourceMappingURL=GestureComponents.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureComponents.web.tsx"],"names":["ScrollView","RNScrollView","disallowInterruption","Switch","RNSwitch","shouldCancelWhenOutside","shouldActivateOnStart","TextInput","RNTextInput","DrawerLayoutAndroid","console","warn","RefreshControl","View","FlatList","React","forwardRef","props","ref","scrollProps"],"mappings":";;;;;;;AAAA;;AACA;;AASA;;;;;;;;;;AAEO,MAAMA,UAAU,GAAG,kCAAoBC,uBAApB,EAAkC;AAC1DC,EAAAA,oBAAoB,EAAE;AADoC,CAAlC,CAAnB;;AAIA,MAAMC,MAAM,GAAG,kCAAoBC,mBAApB,EAA8B;AAClDC,EAAAA,uBAAuB,EAAE,KADyB;AAElDC,EAAAA,qBAAqB,EAAE,IAF2B;AAGlDJ,EAAAA,oBAAoB,EAAE;AAH4B,CAA9B,CAAf;;AAKA,MAAMK,SAAS,GAAG,kCAAoBC,sBAApB,CAAlB;;;AACA,MAAMC,mBAAmB,GAAG,MAAM;AACvCC,EAAAA,OAAO,CAACC,IAAR,CAAa,8CAAb;AACA,sBAAO,oBAAC,iBAAD,OAAP;AACD,CAHM,C,CAKP;AACA;AACA;;;;AACO,MAAMC,cAAc,GAAG,kCAAoBC,iBAApB,CAAvB;;AAEA,MAAMC,QAAQ,gBAAGC,KAAK,CAACC,UAAN,CACtB,CAAoBC,KAApB,EAAiDC,GAAjD,kBACE,oBAAC,qBAAD;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,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _RNGestureHandlerButtonNativeComponent = _interopRequireDefault(require("../specs/RNGestureHandlerButtonNativeComponent"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = _RNGestureHandlerButtonNativeComponent.default;
exports.default = _default;
//# sourceMappingURL=GestureHandlerButton.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerButton.tsx"],"names":["RNGestureHandlerButtonNativeComponent"],"mappings":";;;;;;;AAEA;;;;eAEeA,8C","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,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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); }
var _default = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(_reactNative.View, _extends({
ref: ref,
accessibilityRole: "button"
}, props)));
exports.default = _default;
//# sourceMappingURL=GestureHandlerButton.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerButton.web.tsx"],"names":["React","forwardRef","props","ref"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;4BAEeA,KAAK,CAACC,UAAN,CAAuB,CAACC,KAAD,EAAQC,GAAR,kBACpC,oBAAC,iBAAD;AAAM,EAAA,GAAG,EAAEA,GAAX;AAAgB,EAAA,iBAAiB,EAAC;AAAlC,GAA+CD,KAA/C,EADa,C","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,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = GestureHandlerRootView;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _init = require("../init");
var _GestureHandlerRootViewContext = _interopRequireDefault(require("../GestureHandlerRootViewContext"));
var _RNGestureHandlerRootViewNativeComponent = _interopRequireDefault(require("../specs/RNGestureHandlerRootViewNativeComponent"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 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)
(0, _init.maybeInitializeFabric)();
return /*#__PURE__*/React.createElement(_GestureHandlerRootViewContext.default.Provider, {
value: true
}, /*#__PURE__*/React.createElement(_RNGestureHandlerRootViewNativeComponent.default, _extends({
style: style !== null && style !== void 0 ? style : styles.container
}, rest)));
}
const styles = _reactNative.StyleSheet.create({
container: {
flex: 1
}
});
//# sourceMappingURL=GestureHandlerRootView.android.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerRootView.android.tsx"],"names":["GestureHandlerRootView","style","rest","styles","container","StyleSheet","create","flex"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;AAKe,SAASA,sBAAT,CAAgC;AAC7CC,EAAAA,KAD6C;AAE7C,KAAGC;AAF0C,CAAhC,EAGiB;AAC9B;AACA;AACA;AACA;AAEA,sBACE,oBAAC,sCAAD,CAA+B,QAA/B;AAAwC,IAAA,KAAK;AAA7C,kBACE,oBAAC,gDAAD;AACE,IAAA,KAAK,EAAED,KAAF,aAAEA,KAAF,cAAEA,KAAF,GAAWE,MAAM,CAACC;AADzB,KAEMF,IAFN,EADF,CADF;AAQD;;AAED,MAAMC,MAAM,GAAGE,wBAAWC,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE;AAAEG,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,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = GestureHandlerRootView;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _init = require("../init");
var _GestureHandlerRootViewContext = _interopRequireDefault(require("../GestureHandlerRootViewContext"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 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)
(0, _init.maybeInitializeFabric)();
return /*#__PURE__*/React.createElement(_GestureHandlerRootViewContext.default.Provider, {
value: true
}, /*#__PURE__*/React.createElement(_reactNative.View, _extends({
style: style !== null && style !== void 0 ? style : styles.container
}, rest)));
}
const styles = _reactNative.StyleSheet.create({
container: {
flex: 1
}
});
//# sourceMappingURL=GestureHandlerRootView.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerRootView.tsx"],"names":["GestureHandlerRootView","style","rest","styles","container","StyleSheet","create","flex"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AACA;;;;;;;;;;AAKe,SAASA,sBAAT,CAAgC;AAC7CC,EAAAA,KAD6C;AAE7C,KAAGC;AAF0C,CAAhC,EAGiB;AAC9B;AACA;AACA;AACA;AAEA,sBACE,oBAAC,sCAAD,CAA+B,QAA/B;AAAwC,IAAA,KAAK;AAA7C,kBACE,oBAAC,iBAAD;AAAM,IAAA,KAAK,EAAED,KAAF,aAAEA,KAAF,cAAEA,KAAF,GAAWE,MAAM,CAACC;AAA7B,KAA4CF,IAA5C,EADF,CADF;AAKD;;AAED,MAAMC,MAAM,GAAGE,wBAAWC,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE;AAAEG,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,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = GestureHandlerRootView;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _GestureHandlerRootViewContext = _interopRequireDefault(require("../GestureHandlerRootViewContext"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 GestureHandlerRootView({
style,
...rest
}) {
return /*#__PURE__*/React.createElement(_GestureHandlerRootViewContext.default.Provider, {
value: true
}, /*#__PURE__*/React.createElement(_reactNative.View, _extends({
style: style !== null && style !== void 0 ? style : styles.container
}, rest)));
}
const styles = _reactNative.StyleSheet.create({
container: {
flex: 1
}
});
//# sourceMappingURL=GestureHandlerRootView.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["GestureHandlerRootView.web.tsx"],"names":["GestureHandlerRootView","style","rest","styles","container","StyleSheet","create","flex"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;;;;;;;AAKe,SAASA,sBAAT,CAAgC;AAC7CC,EAAAA,KAD6C;AAE7C,KAAGC;AAF0C,CAAhC,EAGiB;AAC9B,sBACE,oBAAC,sCAAD,CAA+B,QAA/B;AAAwC,IAAA,KAAK;AAA7C,kBACE,oBAAC,iBAAD;AAAM,IAAA,KAAK,EAAED,KAAF,aAAEA,KAAF,cAAEA,KAAF,GAAWE,MAAM,CAACC;AAA7B,KAA4CF,IAA5C,EADF,CADF;AAKD;;AAED,MAAMC,MAAM,GAAGE,wBAAWC,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE;AAAEG,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,410 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _PanGestureHandler = require("../handlers/PanGestureHandler");
var _TapGestureHandler = require("../handlers/TapGestureHandler");
var _State = require("../State");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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; }
const DRAG_TOSS = 0.05;
class Swipeable extends React.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 = _reactNative.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 _reactNative.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 _reactNative.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.State.ACTIVE) {
this.close();
}
});
_defineProperty(this, "onHandlerStateChange", ev => {
if (ev.nativeEvent.oldState === _State.State.ACTIVE) {
this.handleRelease(ev);
}
if (ev.nativeEvent.state === _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)
});
_reactNative.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 _reactNative.Animated.Value(0);
this.state = {
dragX: _dragX,
rowTranslation: new _reactNative.Animated.Value(0),
rowState: 0,
leftWidth: undefined,
rightOffset: undefined,
rowWidth: undefined
};
this.updateAnimatedEvent(_props, this.state);
this.onGestureEvent = _reactNative.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(_reactNative.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(_reactNative.View, {
onLayout: ({
nativeEvent
}) => this.setState({
leftWidth: nativeEvent.layout.x
})
}));
const right = renderRightActions && /*#__PURE__*/React.createElement(_reactNative.Animated.View, {
style: [styles.rightActions, {
transform: [{
translateX: this.rightActionTranslate
}]
}]
}, renderRightActions(this.showRightAction, this.transX, this), /*#__PURE__*/React.createElement(_reactNative.View, {
onLayout: ({
nativeEvent
}) => this.setState({
rightOffset: nativeEvent.layout.x
})
}));
return /*#__PURE__*/React.createElement(_PanGestureHandler.PanGestureHandler, _extends({
activeOffsetX: [-dragOffsetFromRightEdge, dragOffsetFromLeftEdge],
touchAction: "pan-y"
}, this.props, {
onGestureEvent: this.onGestureEvent,
onHandlerStateChange: this.onHandlerStateChange
}), /*#__PURE__*/React.createElement(_reactNative.Animated.View, {
onLayout: this.onRowLayout,
style: [styles.container, this.props.containerStyle]
}, left, right, /*#__PURE__*/React.createElement(_TapGestureHandler.TapGestureHandler, {
enabled: rowState !== 0,
touchAction: "pan-y",
onHandlerStateChange: this.onTapHandlerStateChange
}, /*#__PURE__*/React.createElement(_reactNative.Animated.View, {
pointerEvents: rowState === 0 ? 'auto' : 'box-only',
style: [{
transform: [{
translateX: this.transX
}]
}, this.props.childrenContainerStyle]
}, children))));
}
}
exports.default = Swipeable;
_defineProperty(Swipeable, "defaultProps", {
friction: 1,
overshootFriction: 1,
useNativeAnimations: true
});
const styles = _reactNative.StyleSheet.create({
container: {
overflow: 'hidden'
},
leftActions: { ..._reactNative.StyleSheet.absoluteFillObject,
flexDirection: _reactNative.I18nManager.isRTL ? 'row-reverse' : 'row'
},
rightActions: { ..._reactNative.StyleSheet.absoluteFillObject,
flexDirection: _reactNative.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,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = gestureHandlerRootHOC;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
var _GestureHandlerRootView = _interopRequireDefault(require("./GestureHandlerRootView"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function gestureHandlerRootHOC(Component, containerStyles) {
function Wrapper(props) {
return /*#__PURE__*/React.createElement(_GestureHandlerRootView.default, {
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
(0, _hoistNonReactStatics.default)(Wrapper, Component);
return Wrapper;
}
const styles = _reactNative.StyleSheet.create({
container: {
flex: 1
}
});
//# sourceMappingURL=gestureHandlerRootHOC.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["gestureHandlerRootHOC.tsx"],"names":["gestureHandlerRootHOC","Component","containerStyles","Wrapper","props","styles","container","displayName","name","StyleSheet","create","flex"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAEe,SAASA,qBAAT,CACbC,SADa,EAEbC,eAFa,EAGW;AACxB,WAASC,OAAT,CAAiBC,KAAjB,EAA2B;AACzB,wBACE,oBAAC,+BAAD;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;;AACA,qCAAqBL,OAArB,EAA8BF,SAA9B;AAEA,SAAOE,OAAP;AACD;;AAED,MAAME,MAAM,GAAGI,wBAAWC,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AAAEK,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,290 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.TOUCHABLE_STATE = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _State = require("../../State");
var _GestureButtons = require("../GestureButtons");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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; }
/**
* 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.
*/
const TOUCHABLE_STATE = {
UNDETERMINED: 0,
BEGAN: 1,
MOVED_OUTSIDE: 2
};
exports.TOUCHABLE_STATE = TOUCHABLE_STATE;
/**
* GenericTouchable is not intented to be used as it is.
* Should be treated as a source for the rest of touchables
*/
class GenericTouchable extends React.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.State.CANCELLED || state === _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 === (_reactNative.Platform.OS !== 'android' ? _State.State.ACTIVE : _State.State.BEGAN) && this.STATE === TOUCHABLE_STATE.UNDETERMINED) {
// Moving inside requires
this.handlePressIn();
} else if (state === _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(_GestureButtons.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(_reactNative.Animated.View, _extends({}, coreProps, {
style: this.props.style
}), this.props.children));
}
}
exports.default = GenericTouchable;
_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,109 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _GenericTouchable = _interopRequireWildcard(require("./GenericTouchable"));
var _reactNative = require("react-native");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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; }
/**
* TouchableHighlight follows RN's implementation
*/
class TouchableHighlight extends React.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 === _GenericTouchable.TOUCHABLE_STATE.BEGAN) {
this.showUnderlay();
} else if (to === _GenericTouchable.TOUCHABLE_STATE.UNDETERMINED || to === _GenericTouchable.TOUCHABLE_STATE.MOVED_OUTSIDE) {
this.hideUnderlay();
}
});
this.state = {
extraChildStyle: null,
extraUnderlayStyle: null
};
} // Copied from RN
renderChildren() {
if (!this.props.children) {
return /*#__PURE__*/React.createElement(_reactNative.View, null);
}
const child = React.Children.only(this.props.children); // TODO: not sure if OK but fixes error
return /*#__PURE__*/React.cloneElement(child, {
style: _reactNative.StyleSheet.compose(child.props.style, this.state.extraChildStyle)
});
}
render() {
const {
style = {},
...rest
} = this.props;
const {
extraUnderlayStyle
} = this.state;
return /*#__PURE__*/React.createElement(_GenericTouchable.default, _extends({}, rest, {
style: [style, extraUnderlayStyle],
onStateChange: this.onStateChange
}), this.renderChildren());
}
}
exports.default = TouchableHighlight;
_defineProperty(TouchableHighlight, "defaultProps", { ..._GenericTouchable.default.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,100 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var React = _interopRequireWildcard(require("react"));
var _GenericTouchable = _interopRequireDefault(require("./GenericTouchable"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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; }
/**
* 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.
*/
class TouchableNativeFeedback extends React.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.default, _extends({}, rest, {
style: style,
extraButtonProps: this.getExtraButtonProps()
}));
}
}
exports.default = TouchableNativeFeedback;
_defineProperty(TouchableNativeFeedback, "defaultProps", { ..._GenericTouchable.default.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", () => _reactNative.Platform.OS === 'android' && _reactNative.Platform.Version >= 23);
//# sourceMappingURL=TouchableNativeFeedback.android.js.map

View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _default = _reactNative.TouchableNativeFeedback;
exports.default = _default;
//# sourceMappingURL=TouchableNativeFeedback.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["TouchableNativeFeedback.tsx"],"names":["TouchableNativeFeedback"],"mappings":";;;;;;;AAAA;;eAEeA,oC","sourcesContent":["import { TouchableNativeFeedback } from 'react-native';\n\nexport default TouchableNativeFeedback;\n"]}

View File

@@ -0,0 +1,77 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _GenericTouchable = _interopRequireWildcard(require("./GenericTouchable"));
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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; }
/**
* TouchableOpacity bases on timing animation which has been used in RN's core
*/
class TouchableOpacity extends React.Component {
constructor(...args) {
super(...args);
_defineProperty(this, "getChildStyleOpacityWithDefault", () => {
const childStyle = _reactNative.StyleSheet.flatten(this.props.style) || {};
return childStyle.opacity == null ? 1 : childStyle.opacity.valueOf();
});
_defineProperty(this, "opacity", new _reactNative.Animated.Value(this.getChildStyleOpacityWithDefault()));
_defineProperty(this, "setOpacityTo", (value, duration) => {
var _this$props$useNative;
_reactNative.Animated.timing(this.opacity, {
toValue: value,
duration: duration,
easing: _reactNative.Easing.inOut(_reactNative.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 === _GenericTouchable.TOUCHABLE_STATE.BEGAN) {
this.setOpacityTo(this.props.activeOpacity, 0);
} else if (to === _GenericTouchable.TOUCHABLE_STATE.UNDETERMINED || to === _GenericTouchable.TOUCHABLE_STATE.MOVED_OUTSIDE) {
this.setOpacityTo(this.getChildStyleOpacityWithDefault(), 150);
}
});
}
render() {
const {
style = {},
...rest
} = this.props;
return /*#__PURE__*/React.createElement(_GenericTouchable.default, _extends({}, rest, {
style: [style, {
opacity: this.opacity // TODO: fix this
}],
onStateChange: this.onStateChange
}), this.props.children ? this.props.children : /*#__PURE__*/React.createElement(_reactNative.View, null));
}
}
exports.default = TouchableOpacity;
_defineProperty(TouchableOpacity, "defaultProps", { ..._GenericTouchable.default.defaultProps,
activeOpacity: 0.2
});
//# sourceMappingURL=TouchableOpacity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["TouchableOpacity.tsx"],"names":["TouchableOpacity","Component","childStyle","StyleSheet","flatten","props","style","opacity","valueOf","Animated","Value","getChildStyleOpacityWithDefault","value","duration","timing","toValue","easing","Easing","inOut","quad","useNativeDriver","useNativeAnimations","start","_from","to","TOUCHABLE_STATE","BEGAN","setOpacityTo","activeOpacity","UNDETERMINED","MOVED_OUTSIDE","render","rest","onStateChange","children","GenericTouchable","defaultProps"],"mappings":";;;;;;;AAAA;;AAOA;;AAIA;;;;;;;;;;AAQA;AACA;AACA;AACe,MAAMA,gBAAN,SAA+BC,eAA/B,CAAgE;AAAA;AAAA;;AAAA,6DAO3C,MAAM;AACtC,YAAMC,UAAU,GAAGC,wBAAWC,OAAX,CAAmB,KAAKC,KAAL,CAAWC,KAA9B,KAAwC,EAA3D;AACA,aAAOJ,UAAU,CAACK,OAAX,IAAsB,IAAtB,GACH,CADG,GAEFL,UAAU,CAACK,OAAX,CAAmBC,OAAnB,EAFL;AAGD,KAZ4E;;AAAA,qCAcnE,IAAIC,sBAASC,KAAb,CAAmB,KAAKC,+BAAL,EAAnB,CAdmE;;AAAA,0CAgB9D,CAACC,KAAD,EAAgBC,QAAhB,KAAqC;AAAA;;AAClDJ,4BAASK,MAAT,CAAgB,KAAKP,OAArB,EAA8B;AAC5BQ,QAAAA,OAAO,EAAEH,KADmB;AAE5BC,QAAAA,QAAQ,EAAEA,QAFkB;AAG5BG,QAAAA,MAAM,EAAEC,oBAAOC,KAAP,CAAaD,oBAAOE,IAApB,CAHoB;AAI5BC,QAAAA,eAAe,2BAAE,KAAKf,KAAL,CAAWgB,mBAAb,yEAAoC;AAJvB,OAA9B,EAKGC,KALH;AAMD,KAvB4E;;AAAA,2CAyB7D,CAACC,KAAD,EAAgBC,EAAhB,KAA+B;AAC7C,UAAIA,EAAE,KAAKC,kCAAgBC,KAA3B,EAAkC;AAChC,aAAKC,YAAL,CAAkB,KAAKtB,KAAL,CAAWuB,aAA7B,EAA6C,CAA7C;AACD,OAFD,MAEO,IACLJ,EAAE,KAAKC,kCAAgBI,YAAvB,IACAL,EAAE,KAAKC,kCAAgBK,aAFlB,EAGL;AACA,aAAKH,YAAL,CAAkB,KAAKhB,+BAAL,EAAlB,EAA0D,GAA1D;AACD;AACF,KAlC4E;AAAA;;AAoC7EoB,EAAAA,MAAM,GAAG;AACP,UAAM;AAAEzB,MAAAA,KAAK,GAAG,EAAV;AAAc,SAAG0B;AAAjB,QAA0B,KAAK3B,KAArC;AACA,wBACE,oBAAC,yBAAD,eACM2B,IADN;AAEE,MAAA,KAAK,EAAE,CACL1B,KADK,EAEL;AACEC,QAAAA,OAAO,EAAE,KAAKA,OADhB,CAC8C;;AAD9C,OAFK,CAFT;AAQE,MAAA,aAAa,EAAE,KAAK0B;AARtB,QASG,KAAK5B,KAAL,CAAW6B,QAAX,GAAsB,KAAK7B,KAAL,CAAW6B,QAAjC,gBAA4C,oBAAC,iBAAD,OAT/C,CADF;AAaD;;AAnD4E;;;;gBAA1DlC,gB,kBACG,EACpB,GAAGmC,0BAAiBC,YADA;AAEpBR,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,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _GenericTouchable = _interopRequireDefault(require("./GenericTouchable"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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); }
const TouchableWithoutFeedback = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(_GenericTouchable.default, _extends({
ref: ref
}, props)));
TouchableWithoutFeedback.defaultProps = _GenericTouchable.default.defaultProps;
var _default = TouchableWithoutFeedback;
exports.default = _default;
//# sourceMappingURL=TouchableWithoutFeedback.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["TouchableWithoutFeedback.tsx"],"names":["TouchableWithoutFeedback","React","forwardRef","props","ref","defaultProps","GenericTouchable"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;;;;;AAIA,MAAMA,wBAAwB,gBAAGC,KAAK,CAACC,UAAN,CAG/B,CAACC,KAAD,EAAQC,GAAR,kBAAgB,oBAAC,yBAAD;AAAkB,EAAA,GAAG,EAAEA;AAAvB,GAAgCD,KAAhC,EAHe,CAAjC;AAKAH,wBAAwB,CAACK,YAAzB,GAAwCC,0BAAiBD,YAAzD;eAEeL,wB","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,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "TouchableNativeFeedback", {
enumerable: true,
get: function () {
return _TouchableNativeFeedback.default;
}
});
Object.defineProperty(exports, "TouchableWithoutFeedback", {
enumerable: true,
get: function () {
return _TouchableWithoutFeedback.default;
}
});
Object.defineProperty(exports, "TouchableOpacity", {
enumerable: true,
get: function () {
return _TouchableOpacity.default;
}
});
Object.defineProperty(exports, "TouchableHighlight", {
enumerable: true,
get: function () {
return _TouchableHighlight.default;
}
});
var _TouchableNativeFeedback = _interopRequireDefault(require("./TouchableNativeFeedback"));
var _TouchableWithoutFeedback = _interopRequireDefault(require("./TouchableWithoutFeedback"));
var _TouchableOpacity = _interopRequireDefault(require("./TouchableOpacity"));
var _TouchableHighlight = _interopRequireDefault(require("./TouchableHighlight"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA","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,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getReactNativeVersion = getReactNativeVersion;
var _package = _interopRequireDefault(require("react-native/package.json"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const [majorStr, minorStr] = _package.default.version.split('.');
const REACT_NATIVE_VERSION = {
major: parseInt(majorStr, 10),
minor: parseInt(minorStr, 10)
};
function getReactNativeVersion() {
return REACT_NATIVE_VERSION;
}
//# sourceMappingURL=getReactNativeVersion.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["getReactNativeVersion.ts"],"names":["majorStr","minorStr","pack","version","split","REACT_NATIVE_VERSION","major","parseInt","minor","getReactNativeVersion"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAM,CAACA,QAAD,EAAWC,QAAX,IAAuBC,iBAAKC,OAAL,CAAaC,KAAb,CAAmB,GAAnB,CAA7B;;AACA,MAAMC,oBAAoB,GAAG;AAC3BC,EAAAA,KAAK,EAAEC,QAAQ,CAACP,QAAD,EAAW,EAAX,CADY;AAE3BQ,EAAAA,KAAK,EAAED,QAAQ,CAACN,QAAD,EAAW,EAAX;AAFY,CAA7B;;AAKO,SAASQ,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,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getReactNativeVersion = getReactNativeVersion;
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":";;;;;;;AAAO,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,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getShadowNodeFromRef = getShadowNodeFromRef;
// 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;
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;;AAIO,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,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getShadowNodeFromRef = getShadowNodeFromRef;
// 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.
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;AACO,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,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ghQueueMicrotask = void 0;
// `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
const ghQueueMicrotask = typeof queueMicrotask === 'function' ? queueMicrotask : setImmediate;
exports.ghQueueMicrotask = ghQueueMicrotask;
//# sourceMappingURL=ghQueueMicrotask.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["ghQueueMicrotask.ts"],"names":["ghQueueMicrotask","queueMicrotask","setImmediate"],"mappings":";;;;;;AAAA;AACA;AACA;AACO,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,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FlingGestureHandler = exports.flingHandlerName = exports.flingGestureHandlerProps = void 0;
var _createHandler = _interopRequireDefault(require("./createHandler"));
var _gestureHandlerCommon = require("./gestureHandlerCommon");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const flingGestureHandlerProps = ['numberOfPointers', 'direction'];
exports.flingGestureHandlerProps = flingGestureHandlerProps;
const flingHandlerName = 'FlingGestureHandler';
exports.flingHandlerName = flingHandlerName;
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
const FlingGestureHandler = (0, _createHandler.default)({
name: flingHandlerName,
allowedProps: [..._gestureHandlerCommon.baseGestureHandlerProps, ...flingGestureHandlerProps],
config: {}
});
exports.FlingGestureHandler = FlingGestureHandler;
//# sourceMappingURL=FlingGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["FlingGestureHandler.ts"],"names":["flingGestureHandlerProps","flingHandlerName","FlingGestureHandler","name","allowedProps","baseGestureHandlerProps","config"],"mappings":";;;;;;;AAAA;;AACA;;;;AAKO,MAAMA,wBAAwB,GAAG,CACtC,kBADsC,EAEtC,WAFsC,CAAjC;;AAsCA,MAAMC,gBAAgB,GAAG,qBAAzB;;AAGP;AACO,MAAMC,mBAAmB,GAAG,4BAGjC;AACAC,EAAAA,IAAI,EAAEF,gBADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGC,6CADS,EAEZ,GAAGL,wBAFS,CAFd;AAMAM,EAAAA,MAAM,EAAE;AANR,CAHiC,CAA5B","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,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ForceTouchGestureHandler = exports.forceTouchHandlerName = exports.forceTouchGestureHandlerProps = void 0;
var _react = _interopRequireDefault(require("react"));
var _utils = require("../utils");
var _PlatformConstants = _interopRequireDefault(require("../PlatformConstants"));
var _createHandler = _interopRequireDefault(require("./createHandler"));
var _gestureHandlerCommon = require("./gestureHandlerCommon");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
const forceTouchGestureHandlerProps = ['minForce', 'maxForce', 'feedbackOnActivation']; // implicit `children` prop has been removed in @types/react^18.0.0
exports.forceTouchGestureHandlerProps = forceTouchGestureHandlerProps;
class ForceTouchFallback extends _react.default.Component {
componentDidMount() {
console.warn((0, _utils.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);
const forceTouchHandlerName = 'ForceTouchGestureHandler'; // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
exports.forceTouchHandlerName = forceTouchHandlerName;
const ForceTouchGestureHandler = _PlatformConstants.default !== null && _PlatformConstants.default !== void 0 && _PlatformConstants.default.forceTouchAvailable ? (0, _createHandler.default)({
name: forceTouchHandlerName,
allowedProps: [..._gestureHandlerCommon.baseGestureHandlerProps, ...forceTouchGestureHandlerProps],
config: {}
}) : ForceTouchFallback;
exports.ForceTouchGestureHandler = ForceTouchGestureHandler;
ForceTouchGestureHandler.forceTouchAvailable = (_PlatformConstants.default === null || _PlatformConstants.default === void 0 ? void 0 : _PlatformConstants.default.forceTouchAvailable) || false;
//# sourceMappingURL=ForceTouchGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["ForceTouchGestureHandler.ts"],"names":["forceTouchGestureHandlerProps","ForceTouchFallback","React","Component","componentDidMount","console","warn","render","props","children","forceTouchHandlerName","ForceTouchGestureHandler","PlatformConstants","forceTouchAvailable","name","allowedProps","baseGestureHandlerProps","config"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAKO,MAAMA,6BAA6B,GAAG,CAC3C,UAD2C,EAE3C,UAF2C,EAG3C,sBAH2C,CAAtC,C,CAMP;;;;AACA,MAAMC,kBAAN,SAAiCC,eAAMC,SAAvC,CAA6E;AAE3EC,EAAAA,iBAAiB,GAAG;AAClBC,IAAAA,OAAO,CAACC,IAAR,CACE,uBACE,8NADF,CADF;AAKD;;AACDC,EAAAA,MAAM,GAAG;AACP,WAAO,KAAKC,KAAL,CAAWC,QAAlB;AACD;;AAX0E;;gBAAvER,kB,yBACyB,K;;AAsDxB,MAAMS,qBAAqB,GAAG,0BAA9B,C,CAEP;;;AACO,MAAMC,wBAAwB,GAAGC,2GAAmBC,mBAAnB,GACpC,4BAGE;AACAC,EAAAA,IAAI,EAAEJ,qBADN;AAEAK,EAAAA,YAAY,EAAE,CACZ,GAAGC,6CADS,EAEZ,GAAGhB,6BAFS,CAFd;AAMAiB,EAAAA,MAAM,EAAE;AANR,CAHF,CADoC,GAYpChB,kBAZG;;AAcNU,wBAAD,CAAuDE,mBAAvD,GACE,oHAAmBA,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,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LongPressGestureHandler = exports.longPressHandlerName = exports.longPressGestureHandlerProps = void 0;
var _createHandler = _interopRequireDefault(require("./createHandler"));
var _gestureHandlerCommon = require("./gestureHandlerCommon");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const longPressGestureHandlerProps = ['minDurationMs', 'maxDist'];
exports.longPressGestureHandlerProps = longPressGestureHandlerProps;
const longPressHandlerName = 'LongPressGestureHandler';
exports.longPressHandlerName = longPressHandlerName;
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
const LongPressGestureHandler = (0, _createHandler.default)({
name: longPressHandlerName,
allowedProps: [..._gestureHandlerCommon.baseGestureHandlerProps, ...longPressGestureHandlerProps],
config: {
shouldCancelWhenOutside: true
}
});
exports.LongPressGestureHandler = LongPressGestureHandler;
//# sourceMappingURL=LongPressGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["LongPressGestureHandler.ts"],"names":["longPressGestureHandlerProps","longPressHandlerName","LongPressGestureHandler","name","allowedProps","baseGestureHandlerProps","config","shouldCancelWhenOutside"],"mappings":";;;;;;;AAAA;;AACA;;;;AAKO,MAAMA,4BAA4B,GAAG,CAC1C,eAD0C,EAE1C,SAF0C,CAArC;;AAiEA,MAAMC,oBAAoB,GAAG,yBAA7B;;AAGP;AACO,MAAMC,uBAAuB,GAAG,4BAGrC;AACAC,EAAAA,IAAI,EAAEF,oBADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGC,6CADS,EAEZ,GAAGL,4BAFS,CAFd;AAMAM,EAAAA,MAAM,EAAE;AACNC,IAAAA,uBAAuB,EAAE;AADnB;AANR,CAHqC,CAAhC","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,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.NativeViewGestureHandler = exports.nativeViewHandlerName = exports.nativeViewProps = exports.nativeViewGestureHandlerProps = void 0;
var _createHandler = _interopRequireDefault(require("./createHandler"));
var _gestureHandlerCommon = require("./gestureHandlerCommon");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const nativeViewGestureHandlerProps = ['shouldActivateOnStart', 'disallowInterruption'];
exports.nativeViewGestureHandlerProps = nativeViewGestureHandlerProps;
const nativeViewProps = [..._gestureHandlerCommon.baseGestureHandlerProps, ...nativeViewGestureHandlerProps];
exports.nativeViewProps = nativeViewProps;
const nativeViewHandlerName = 'NativeViewGestureHandler';
exports.nativeViewHandlerName = nativeViewHandlerName;
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
const NativeViewGestureHandler = (0, _createHandler.default)({
name: nativeViewHandlerName,
allowedProps: nativeViewProps,
config: {}
});
exports.NativeViewGestureHandler = NativeViewGestureHandler;
//# sourceMappingURL=NativeViewGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["NativeViewGestureHandler.ts"],"names":["nativeViewGestureHandlerProps","nativeViewProps","baseGestureHandlerProps","nativeViewHandlerName","NativeViewGestureHandler","name","allowedProps","config"],"mappings":";;;;;;;AAAA;;AACA;;;;AAKO,MAAMA,6BAA6B,GAAG,CAC3C,uBAD2C,EAE3C,sBAF2C,CAAtC;;AAgCA,MAAMC,eAAe,GAAG,CAC7B,GAAGC,6CAD0B,EAE7B,GAAGF,6BAF0B,CAAxB;;AAKA,MAAMG,qBAAqB,GAAG,0BAA9B;;AAGP;AACO,MAAMC,wBAAwB,GAAG,4BAGtC;AACAC,EAAAA,IAAI,EAAEF,qBADN;AAEAG,EAAAA,YAAY,EAAEL,eAFd;AAGAM,EAAAA,MAAM,EAAE;AAHR,CAHsC,CAAjC","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,123 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.managePanProps = managePanProps;
exports.PanGestureHandler = exports.panHandlerName = exports.panGestureHandlerCustomNativeProps = exports.panGestureHandlerProps = void 0;
var _createHandler = _interopRequireDefault(require("./createHandler"));
var _gestureHandlerCommon = require("./gestureHandlerCommon");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const panGestureHandlerProps = ['activeOffsetY', 'activeOffsetX', 'failOffsetY', 'failOffsetX', 'minDist', 'minVelocity', 'minVelocityX', 'minVelocityY', 'minPointers', 'maxPointers', 'avgTouches', 'enableTrackpadTwoFingerGesture', 'activateAfterLongPress'];
exports.panGestureHandlerProps = panGestureHandlerProps;
const panGestureHandlerCustomNativeProps = ['activeOffsetYStart', 'activeOffsetYEnd', 'activeOffsetXStart', 'activeOffsetXEnd', 'failOffsetYStart', 'failOffsetYEnd', 'failOffsetXStart', 'failOffsetXEnd'];
exports.panGestureHandlerCustomNativeProps = panGestureHandlerCustomNativeProps;
const panHandlerName = 'PanGestureHandler';
exports.panHandlerName = panHandlerName;
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
const PanGestureHandler = (0, _createHandler.default)({
name: panHandlerName,
allowedProps: [..._gestureHandlerCommon.baseGestureHandlerProps, ...panGestureHandlerProps],
config: {},
transformProps: managePanProps,
customNativeProps: panGestureHandlerCustomNativeProps
});
exports.PanGestureHandler = PanGestureHandler;
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;
}
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,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PinchGestureHandler = exports.pinchHandlerName = void 0;
var _createHandler = _interopRequireDefault(require("./createHandler"));
var _gestureHandlerCommon = require("./gestureHandlerCommon");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const pinchHandlerName = 'PinchGestureHandler';
exports.pinchHandlerName = pinchHandlerName;
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
const PinchGestureHandler = (0, _createHandler.default)({
name: pinchHandlerName,
allowedProps: _gestureHandlerCommon.baseGestureHandlerProps,
config: {}
});
exports.PinchGestureHandler = PinchGestureHandler;
//# sourceMappingURL=PinchGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PinchGestureHandler.ts"],"names":["pinchHandlerName","PinchGestureHandler","name","allowedProps","baseGestureHandlerProps","config"],"mappings":";;;;;;;AAAA;;AACA;;;;AAmCO,MAAMA,gBAAgB,GAAG,qBAAzB;;AAGP;AACO,MAAMC,mBAAmB,GAAG,4BAGjC;AACAC,EAAAA,IAAI,EAAEF,gBADN;AAEAG,EAAAA,YAAY,EAAEC,6CAFd;AAGAC,EAAAA,MAAM,EAAE;AAHR,CAHiC,CAA5B","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,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "PressabilityDebugView", {
enumerable: true,
get: function () {
return _PressabilityDebug.PressabilityDebugView;
}
});
var _PressabilityDebug = require("react-native/Libraries/Pressability/PressabilityDebug");
//# sourceMappingURL=PressabilityDebugView.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PressabilityDebugView.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA","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,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PressabilityDebugView = PressabilityDebugView;
// PressabilityDebugView is not implemented in react-native-web
function PressabilityDebugView() {
return null;
}
//# sourceMappingURL=PressabilityDebugView.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PressabilityDebugView.web.tsx"],"names":["PressabilityDebugView"],"mappings":";;;;;;;AAAA;AACO,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,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RotationGestureHandler = exports.rotationHandlerName = void 0;
var _createHandler = _interopRequireDefault(require("./createHandler"));
var _gestureHandlerCommon = require("./gestureHandlerCommon");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const rotationHandlerName = 'RotationGestureHandler';
exports.rotationHandlerName = rotationHandlerName;
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
const RotationGestureHandler = (0, _createHandler.default)({
name: rotationHandlerName,
allowedProps: _gestureHandlerCommon.baseGestureHandlerProps,
config: {}
});
exports.RotationGestureHandler = RotationGestureHandler;
//# sourceMappingURL=RotationGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["RotationGestureHandler.ts"],"names":["rotationHandlerName","RotationGestureHandler","name","allowedProps","baseGestureHandlerProps","config"],"mappings":";;;;;;;AAAA;;AACA;;;;AAmCO,MAAMA,mBAAmB,GAAG,wBAA5B;;AAGP;AACO,MAAMC,sBAAsB,GAAG,4BAGpC;AACAC,EAAAA,IAAI,EAAEF,mBADN;AAEAG,EAAAA,YAAY,EAAEC,6CAFd;AAGAC,EAAAA,MAAM,EAAE;AAHR,CAHoC,CAA/B","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,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TapGestureHandler = exports.tapHandlerName = exports.tapGestureHandlerProps = void 0;
var _createHandler = _interopRequireDefault(require("./createHandler"));
var _gestureHandlerCommon = require("./gestureHandlerCommon");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const tapGestureHandlerProps = ['maxDurationMs', 'maxDelayMs', 'numberOfTaps', 'maxDeltaX', 'maxDeltaY', 'maxDist', 'minPointers'];
exports.tapGestureHandlerProps = tapGestureHandlerProps;
const tapHandlerName = 'TapGestureHandler';
exports.tapHandlerName = tapHandlerName;
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
const TapGestureHandler = (0, _createHandler.default)({
name: tapHandlerName,
allowedProps: [..._gestureHandlerCommon.baseGestureHandlerProps, ...tapGestureHandlerProps],
config: {
shouldCancelWhenOutside: true
}
});
exports.TapGestureHandler = TapGestureHandler;
//# sourceMappingURL=TapGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["TapGestureHandler.ts"],"names":["tapGestureHandlerProps","tapHandlerName","TapGestureHandler","name","allowedProps","baseGestureHandlerProps","config","shouldCancelWhenOutside"],"mappings":";;;;;;;AAAA;;AACA;;;;AAKO,MAAMA,sBAAsB,GAAG,CACpC,eADoC,EAEpC,YAFoC,EAGpC,cAHoC,EAIpC,WAJoC,EAKpC,WALoC,EAMpC,SANoC,EAOpC,aAPoC,CAA/B;;AAuEA,MAAMC,cAAc,GAAG,mBAAvB;;AAGP;AACO,MAAMC,iBAAiB,GAAG,4BAG/B;AACAC,EAAAA,IAAI,EAAEF,cADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGC,6CADS,EAEZ,GAAGL,sBAFS,CAFd;AAMAM,EAAAA,MAAM,EAAE;AACNC,IAAAA,uBAAuB,EAAE;AADnB;AANR,CAH+B,CAA1B","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,475 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = createHandler;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _customDirectEventTypes = require("./customDirectEventTypes");
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
var _RNGestureHandlerModule = _interopRequireDefault(require("../RNGestureHandlerModule"));
var _State = require("../State");
var _handlersRegistry = require("./handlersRegistry");
var _gestureHandlerCommon = require("./gestureHandlerCommon");
var _utils = require("../utils");
var _ActionType = require("../ActionType");
var _PressabilityDebugView = require("./PressabilityDebugView");
var _GestureHandlerRootViewContext = _interopRequireDefault(require("../GestureHandlerRootViewContext"));
var _ghQueueMicrotask = require("../ghQueueMicrotask");
var _UIManagerAny$getView, _UIManagerAny$getView2, _UIManagerAny$getCons;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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; }
const UIManagerAny = _reactNative.UIManager;
_customDirectEventTypes.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
...((0, _utils.isFabric)() && _reactNative.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.default.handleSetJSResponder(tag, blockNativeResponder);
oldSetJSResponder(tag, blockNativeResponder);
};
UIManagerAny.clearJSResponder = () => {
_RNGestureHandlerModule.default.handleClearJSResponder();
oldClearJSResponder();
};
let allowTouches = true;
const DEV_ON_ANDROID = __DEV__ && _reactNative.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) {
_reactNative.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.State.UNDETERMINED]: undefined,
[_State.State.BEGAN]: 'onBegan',
[_State.State.FAILED]: 'onFailed',
[_State.State.CANCELLED]: 'onCancelled',
[_State.State.ACTIVE]: 'onActivated',
[_State.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.
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.default.createGestureHandler(name, this.handlerTag, newConfig);
});
_defineProperty(this, "attachGestureHandler", newViewTag => {
this.viewTag = newViewTag;
if (_reactNative.Platform.OS === 'web') {
// typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch
_RNGestureHandlerModule.default.attachGestureHandler(this.handlerTag, newViewTag, _ActionType.ActionType.JS_FUNCTION_OLD_API, // ignored on web
this.propsRef);
} else {
(0, _handlersRegistry.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.ActionType.REANIMATED_WORKLET;
} else if (onGestureEvent && '__isNative' in onGestureEvent) {
// Animated.event with useNativeDriver: true
return _ActionType.ActionType.NATIVE_ANIMATED_EVENT;
} else {
// JS callback or Animated.event with useNativeDriver: false
return _ActionType.ActionType.JS_FUNCTION_OLD_API;
}
})();
_RNGestureHandlerModule.default.attachGestureHandler(this.handlerTag, newViewTag, actionType);
}
(0, _gestureHandlerCommon.scheduleFlushOperations)();
});
_defineProperty(this, "updateGestureHandler", newConfig => {
this.config = newConfig;
_RNGestureHandlerModule.default.updateGestureHandler(this.handlerTag, newConfig);
(0, _gestureHandlerCommon.scheduleFlushOperations)();
});
this.handlerTag = (0, _handlersRegistry.getNextHandlerTag)();
this.config = {};
this.propsRef = /*#__PURE__*/React.createRef();
this.isMountedRef = /*#__PURE__*/React.createRef();
this.state = {
allowTouches
};
if (props.id) {
if (_handlersRegistry.handlerIDToTag[props.id] !== undefined) {
throw new Error(`Handler with ID "${props.id}" already registered`);
}
_handlersRegistry.handlerIDToTag[props.id] = this.handlerTag;
}
}
componentDidMount() {
const props = this.props;
this.isMountedRef.current = true;
if (DEV_ON_ANDROID) {
this.inspectorToggleListener = _reactNative.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.
(0, _ghQueueMicrotask.ghQueueMicrotask)(() => {
this.update(UNRESOLVED_REFS_RETRY_LIMIT);
});
}
this.createGestureHandler((0, _gestureHandlerCommon.filterConfig)(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config));
this.attachGestureHandler((0, _gestureHandlerCommon.findNodeHandle)(this.viewNode)); // TODO(TS) - check if this can be null
}
componentDidUpdate() {
const viewTag = (0, _gestureHandlerCommon.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.default.dropGestureHandler(this.handlerTag);
(0, _gestureHandlerCommon.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 _handlersRegistry.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) {
(0, _ghQueueMicrotask.ghQueueMicrotask)(() => {
this.update(remainingTries - 1);
});
} else {
const newConfig = (0, _gestureHandlerCommon.filterConfig)(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config);
if (!(0, _isEqual.default)(this.config, newConfig)) {
this.updateGestureHandler(newConfig);
}
}
}
setNativeProps(updates) {
const mergedProps = { ...this.props,
...updates
};
const newConfig = (0, _gestureHandlerCommon.filterConfig)(transformProps ? transformProps(mergedProps) : mergedProps, [...allowedProps, ...customNativeProps], config);
this.updateGestureHandler(newConfig);
}
render() {
var _this$props$testID;
if (__DEV__ && !this.context && !(0, _utils.isJestEnv)() && _reactNative.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((0, _utils.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.PressabilityDebugView, {
key: "pressabilityDebugView",
color: "mediumspringgreen",
hitSlop: child.props.hitSlop
}));
}
return /*#__PURE__*/React.cloneElement(child, {
ref: this.refHandler,
collapsable: false,
...((0, _utils.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.default);
return Handler;
}
//# sourceMappingURL=createHandler.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = createNativeWrapper;
var React = _interopRequireWildcard(require("react"));
var _NativeViewGestureHandler = require("./NativeViewGestureHandler");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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); }
/*
* This array should consist of:
* - All keys in propTypes from NativeGestureHandler
* (and all keys in GestureHandlerPropTypes)
* - 'onGestureHandlerEvent'
* - 'onGestureHandlerStateChange'
*/
const NATIVE_WRAPPER_PROPS_FILTER = [..._NativeViewGestureHandler.nativeViewProps, 'onGestureHandlerEvent', 'onGestureHandlerStateChange'];
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 = (0, React.useRef)();
const _gestureHandlerRef = (0, React.useRef)();
(0, React.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.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":["NATIVE_WRAPPER_PROPS_FILTER","nativeViewProps","createNativeWrapper","Component","config","ComponentWrapper","React","forwardRef","props","ref","gestureHandlerProps","Object","keys","reduce","res","key","allowedKeys","includes","_ref","_gestureHandlerRef","node","current","handlerTag","displayName","render","name"],"mappings":";;;;;;;AAAA;;AAGA;;;;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,2BAA2B,GAAG,CAClC,GAAGC,yCAD+B,EAElC,uBAFkC,EAGlC,6BAHkC,CAApC;;AAMe,SAASC,mBAAT,CACbC,SADa,EAEbC,MAA+C,GAAG,EAFrC,EAGb;AAAA;;AACA,QAAMC,gBAAgB,gBAAGC,KAAK,CAACC,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,GAAGhB,2BAAvC;;AACA,UAAIgB,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,GAAGV;AAAL,KAV0B,CAUZ;AAVY,KAA5B;;AAYA,UAAMc,IAAI,GAAG,mBAAb;;AACA,UAAMC,kBAAkB,GAAG,mBAA3B;;AACA,mCACEV,GADF,EAEE;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,KAZH,EAaE,CAACH,IAAD,EAAOC,kBAAP,CAbF;AAeA,wBACE,oBAAC,kDAAD,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;;AACAb,EAAAA,gBAAgB,CAACkB,WAAjB,GACE,CAAApB,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEoB,WAAX,OACA;AACApB,EAAAA,SAFA,aAEAA,SAFA,4CAEAA,SAAS,CAAEqB,MAFX,sDAEA,kBAAmBC,IAFnB,KAGC,OAAOtB,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,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "customDirectEventTypes", {
enumerable: true,
get: function () {
return _ReactNativeViewConfigRegistry.customDirectEventTypes;
}
});
var _ReactNativeViewConfigRegistry = require("react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry");
//# sourceMappingURL=customDirectEventTypes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["customDirectEventTypes.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA","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