react-native-swipeable-actions 0.1.6 → 0.1.7-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/Swipeable.d.ts +1 -1
- package/build/Swipeable.d.ts.map +1 -1
- package/build/Swipeable.js +9 -5
- package/build/Swipeable.js.map +1 -1
- package/build/Swipeable.types.d.ts +2 -2
- package/build/Swipeable.types.d.ts.map +1 -1
- package/build/SwipeableActions.d.ts +2 -2
- package/build/SwipeableActions.d.ts.map +1 -1
- package/build/SwipeableActions.js +0 -4
- package/build/SwipeableActions.js.map +1 -1
- package/build/SwipeableView.d.ts +1 -1
- package/build/SwipeableView.d.ts.map +1 -1
- package/build/SwipeableView.js +1 -1
- package/build/SwipeableView.js.map +1 -1
- package/build/index.d.ts +4 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +6 -6
- package/build/index.js.map +1 -1
- package/ios/OpenStateCache.swift +57 -0
- package/ios/Package.swift +1 -1
- package/ios/SwipeableView.swift +18 -35
- package/jestSetup.js +2 -1
- package/package.json +8 -13
- package/src/Swipeable.tsx +16 -14
- package/src/Swipeable.types.ts +2 -2
- package/src/SwipeableActions.tsx +1 -1
- package/src/SwipeableView.tsx +3 -3
- package/src/index.ts +8 -11
package/build/Swipeable.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SwipeableMethods, SwipeableProps } from './Swipeable.types';
|
|
2
2
|
declare const Swipeable: import("react").ForwardRefExoticComponent<Omit<SwipeableProps, "ref"> & import("react").RefAttributes<SwipeableMethods>>;
|
|
3
3
|
type SwipeableWithStatic = typeof Swipeable & {
|
|
4
4
|
open: (recyclingKey: string) => void;
|
package/build/Swipeable.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Swipeable.d.ts","sourceRoot":"","sources":["../src/Swipeable.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Swipeable.d.ts","sourceRoot":"","sources":["../src/Swipeable.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,gBAAgB,EAChB,cAAc,EAGf,MAAM,mBAAmB,CAAA;AAe1B,QAAA,MAAM,SAAS,0HAoJb,CAAA;AAgBF,KAAK,mBAAmB,GAAG,OAAO,SAAS,GAAG;IAC5C,IAAI,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACzD,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACvC,CAAA;AAED,QAAA,MAAM,eAAe,EAAgB,mBAAmB,CAAA;AAsBxD,eAAe,eAAe,CAAA"}
|
package/build/Swipeable.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const react_1 = require("react");
|
|
4
4
|
const react_native_1 = require("react-native");
|
|
5
|
-
const SwipeableView_1 = require("./SwipeableView");
|
|
6
|
-
const SwipeableActions_1 = require("./SwipeableActions");
|
|
7
5
|
const constants_1 = require("./constants");
|
|
8
6
|
const nativeModuleUtils_1 = require("./nativeModuleUtils");
|
|
7
|
+
const SwipeableActions_1 = require("./SwipeableActions");
|
|
8
|
+
const SwipeableView_1 = require("./SwipeableView");
|
|
9
9
|
function normalizeRecyclingKey(key) {
|
|
10
10
|
if (key == null)
|
|
11
11
|
return undefined;
|
|
@@ -31,14 +31,18 @@ const Swipeable = (0, react_1.forwardRef)(function Swipeable({ children, actions
|
|
|
31
31
|
return normalizedKey != null && (0, nativeModuleUtils_1.isOpenByKey)(normalizedKey);
|
|
32
32
|
});
|
|
33
33
|
const swipeStartedRef = (0, react_1.useRef)(false);
|
|
34
|
+
const initialKeyRef = (0, react_1.useRef)(normalizedKey);
|
|
34
35
|
// When recyclingKey changes (FlatList reorder/recycle), sync hasActionsRendered
|
|
35
36
|
// with the native cached open state. FlatList reuses component instances without
|
|
36
|
-
// remounting, so useState initializer doesn't re-run.
|
|
37
|
+
// remounting, so useState initializer doesn't re-run. Skip on initial mount
|
|
38
|
+
// since the useState initializer already handled it.
|
|
37
39
|
(0, react_1.useEffect)(() => {
|
|
38
40
|
if (!normalizedKey)
|
|
39
41
|
return;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
if (normalizedKey === initialKeyRef.current)
|
|
43
|
+
return;
|
|
44
|
+
initialKeyRef.current = normalizedKey;
|
|
45
|
+
setHasActionsRendered((0, nativeModuleUtils_1.isOpenByKey)(normalizedKey));
|
|
42
46
|
}, [normalizedKey]);
|
|
43
47
|
// Development-time validation
|
|
44
48
|
if (__DEV__) {
|
package/build/Swipeable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Swipeable.js","sourceRoot":"","sources":["../src/Swipeable.tsx"],"names":[],"mappings":";;AAAA,iCAAiG;AACjG,+CAAyD;
|
|
1
|
+
{"version":3,"file":"Swipeable.js","sourceRoot":"","sources":["../src/Swipeable.tsx"],"names":[],"mappings":";;AAAA,iCAAiG;AACjG,+CAAyD;AACzD,2CAA4C;AAC5C,2DAAkF;AAQlF,yDAAqD;AACrD,mDAA+C;AAE/C,SAAS,qBAAqB,CAAC,GAAgC;IAC7D,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,SAAS,CAAA;IACjC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAA;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;IAEvE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,qCAAqC,GAAG,qCAAqC,CAAC,CAAA;IAC7F,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;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C,IAAI,GAAG,CAAC,YAAoB,EAAE,EAAE;IAC9C,IAAI,OAAO,IAAI,CAAC,CAAC,YAAY,IAAI,OAAO,YAAY,KAAK,QAAQ,CAAC,EAAE,CAAC;QACnE,OAAO,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAA;QACxE,OAAM;IACR,CAAC;IACD,IAAA,6BAAS,EAAC,YAAY,CAAC,CAAA;AACzB,CAAC,CAAA;AAED,eAAe,CAAC,KAAK,GAAG,CAAC,YAAoB,EAAE,QAAkB,EAAE,EAAE;IACnE,IAAI,OAAO,IAAI,CAAC,CAAC,YAAY,IAAI,OAAO,YAAY,KAAK,QAAQ,CAAC,EAAE,CAAC;QACnE,OAAO,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAA;QACzE,OAAM;IACR,CAAC;IACD,IAAA,8BAAU,EAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;AACpC,CAAC,CAAA;AAED,eAAe,CAAC,QAAQ,GAAG,CAAC,QAAkB,EAAE,EAAE;IAChD,IAAA,4BAAQ,EAAC,QAAQ,CAAC,CAAA;AACpB,CAAC,CAAA;AAED,kBAAe,eAAe,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactNode, Ref } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
|
+
import type { StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
3
3
|
export interface SwipeProgressEvent {
|
|
4
4
|
nativeEvent: {
|
|
5
5
|
progress: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Swipeable.types.d.ts","sourceRoot":"","sources":["../src/Swipeable.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Swipeable.types.d.ts","sourceRoot":"","sources":["../src/Swipeable.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAA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Q,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACzD,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACvC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Props for SwipeableActions component
|
|
4
4
|
*/
|
|
@@ -15,5 +15,5 @@ export interface SwipeableActionsProps {
|
|
|
15
15
|
*
|
|
16
16
|
* Handles entrance animation when children mount.
|
|
17
17
|
*/
|
|
18
|
-
export declare function SwipeableActions({ children, actionsPosition, testID }: SwipeableActionsProps):
|
|
18
|
+
export declare function SwipeableActions({ children, actionsPosition, testID }: SwipeableActionsProps): import("react").JSX.Element;
|
|
19
19
|
//# sourceMappingURL=SwipeableActions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwipeableActions.d.ts","sourceRoot":"","sources":["../src/SwipeableActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"SwipeableActions.d.ts","sourceRoot":"","sources":["../src/SwipeableActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,kCAAkC;IAClC,QAAQ,EAAE,SAAS,CAAA;IACnB,6CAA6C;IAC7C,eAAe,EAAE,MAAM,GAAG,OAAO,CAAA;IACjC,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,qBAAqB,+BAU5F"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.SwipeableActions = SwipeableActions;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
4
|
const react_native_1 = require("react-native");
|
|
9
5
|
/**
|
|
10
6
|
* SwipeableActions - Internal layout component for swipeable actions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwipeableActions.js","sourceRoot":"","sources":["../src/SwipeableActions.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SwipeableActions.js","sourceRoot":"","sources":["../src/SwipeableActions.tsx"],"names":[],"mappings":";;AAoBA,4CAUC;AA7BD,+CAA+C;AAc/C;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAyB;IAC3F,OAAO,CACL,CAAC,mBAAI,CACH,KAAK,CAAC,CAAC,eAAe,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CACnF,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAC1C,MAAM,CAAC,CAAC,MAAM,CAAC,CAEf;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,mBAAI,CAAC,CACR,CAAA;AACH,CAAC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,eAAe,EAAE;QACf,GAAG,yBAAU,CAAC,YAAY;QAC1B,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,UAAU;KAC3B;IACD,cAAc,EAAE;QACd,GAAG,yBAAU,CAAC,YAAY;QAC1B,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,YAAY;KAC7B;CACF,CAAC,CAAA"}
|
package/build/SwipeableView.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { NativeSwipeableRef, SwipeableViewProps } from './Swipeable.types';
|
|
2
2
|
interface SwipeableNativeModule {
|
|
3
3
|
openByKey: (key: string) => void;
|
|
4
4
|
closeByKey: (key: string, animated?: boolean) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwipeableView.d.ts","sourceRoot":"","sources":["../src/SwipeableView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"SwipeableView.d.ts","sourceRoot":"","sources":["../src/SwipeableView.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAK/E,UAAU,qBAAqB;IAC7B,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACrD,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;CACtC;AAED,eAAO,MAAM,eAAe,uBAA0D,CAAA;AAEtF,eAAO,MAAM,aAAa,mHAIzB,CAAA"}
|
package/build/SwipeableView.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SwipeableView = exports.SwipeableModule = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
4
|
const expo_modules_core_1 = require("expo-modules-core");
|
|
5
|
+
const react_1 = require("react");
|
|
6
6
|
const NativeView = (0, expo_modules_core_1.requireNativeViewManager)('Swipeable');
|
|
7
7
|
exports.SwipeableModule = (0, expo_modules_core_1.requireNativeModule)('Swipeable');
|
|
8
8
|
exports.SwipeableView = (0, react_1.forwardRef)(function SwipeableView(props, ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwipeableView.js","sourceRoot":"","sources":["../src/SwipeableView.tsx"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"SwipeableView.js","sourceRoot":"","sources":["../src/SwipeableView.tsx"],"names":[],"mappings":";;;AAAA,yDAAiF;AACjF,iCAAsE;AAGtE,MAAM,UAAU,GAAG,IAAA,4CAAwB,EAAqB,WAAW,CAAC,CAAA;AAU/D,QAAA,eAAe,GAAG,IAAA,uCAAmB,EAAwB,WAAW,CAAC,CAAA;AAEzE,QAAA,aAAa,GAAG,IAAA,kBAAU,EACrC,SAAS,aAAa,CAAC,KAAK,EAAE,GAAG;IAC/B,OAAO,IAAA,qBAAa,EAAC,UAAU,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAuC,CAAC,CAAA;AAC1F,CAAC,CACF,CAAA;AAED,qBAAa,CAAC,WAAW,GAAG,eAAe,CAAA"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
export { SWIPE_DEFAULTS, SWIPE_PROGRESS } from './constants';
|
|
2
|
+
export type { NativeModuleError, SwipeableErrorHandler } from './nativeModuleUtils';
|
|
3
|
+
export { setGlobalErrorHandler } from './nativeModuleUtils';
|
|
1
4
|
export { default as Swipeable } from './Swipeable';
|
|
5
|
+
export type { NativeSwipeableRef, SwipeableMethods, SwipeableProps, SwipeableStatic, SwipeableViewProps, SwipeProgressEvent, SwipeStateEvent } from './Swipeable.types';
|
|
2
6
|
export { SwipeableView } from './SwipeableView';
|
|
3
|
-
export type { SwipeableProps, SwipeableMethods, SwipeableStatic, SwipeableViewProps, SwipeProgressEvent, SwipeStateEvent, NativeSwipeableRef } from './Swipeable.types';
|
|
4
|
-
export { SWIPE_PROGRESS, SWIPE_DEFAULTS } from './constants';
|
|
5
|
-
export { setGlobalErrorHandler } from './nativeModuleUtils';
|
|
6
|
-
export type { SwipeableErrorHandler, NativeModuleError } from './nativeModuleUtils';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5D,YAAY,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA;AAClD,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -3,15 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
var Swipeable_1 = require("./Swipeable");
|
|
8
|
-
Object.defineProperty(exports, "Swipeable", { enumerable: true, get: function () { return __importDefault(Swipeable_1).default; } });
|
|
9
|
-
var SwipeableView_1 = require("./SwipeableView");
|
|
10
|
-
Object.defineProperty(exports, "SwipeableView", { enumerable: true, get: function () { return SwipeableView_1.SwipeableView; } });
|
|
6
|
+
exports.SwipeableView = exports.Swipeable = exports.setGlobalErrorHandler = exports.SWIPE_PROGRESS = exports.SWIPE_DEFAULTS = void 0;
|
|
11
7
|
var constants_1 = require("./constants");
|
|
12
|
-
Object.defineProperty(exports, "SWIPE_PROGRESS", { enumerable: true, get: function () { return constants_1.SWIPE_PROGRESS; } });
|
|
13
8
|
Object.defineProperty(exports, "SWIPE_DEFAULTS", { enumerable: true, get: function () { return constants_1.SWIPE_DEFAULTS; } });
|
|
9
|
+
Object.defineProperty(exports, "SWIPE_PROGRESS", { enumerable: true, get: function () { return constants_1.SWIPE_PROGRESS; } });
|
|
14
10
|
// Error handling utilities
|
|
15
11
|
var nativeModuleUtils_1 = require("./nativeModuleUtils");
|
|
16
12
|
Object.defineProperty(exports, "setGlobalErrorHandler", { enumerable: true, get: function () { return nativeModuleUtils_1.setGlobalErrorHandler; } });
|
|
13
|
+
var Swipeable_1 = require("./Swipeable");
|
|
14
|
+
Object.defineProperty(exports, "Swipeable", { enumerable: true, get: function () { return __importDefault(Swipeable_1).default; } });
|
|
15
|
+
var SwipeableView_1 = require("./SwipeableView");
|
|
16
|
+
Object.defineProperty(exports, "SwipeableView", { enumerable: true, get: function () { return SwipeableView_1.SwipeableView; } });
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,yCAA4D;AAAnD,2GAAA,cAAc,OAAA;AAAE,2GAAA,cAAc,OAAA;AAEvC,2BAA2B;AAC3B,yDAA2D;AAAlD,0HAAA,qBAAqB,OAAA;AAC9B,yCAAkD;AAAzC,uHAAA,OAAO,OAAa;AAU7B,iDAA+C;AAAtC,8GAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/// Thread-safe LRU cache for tracking open/closed state of swipeable views by recycling key.
|
|
4
|
+
/// Used by the static registry in SwipeableView to persist state across list recycling.
|
|
5
|
+
public class OpenStateCache {
|
|
6
|
+
private let queue: DispatchQueue
|
|
7
|
+
private let maxSize: Int
|
|
8
|
+
private var cache: [String: Bool] = [:]
|
|
9
|
+
private var insertionOrder: [String] = []
|
|
10
|
+
|
|
11
|
+
public init(maxSize: Int = 1000, queueLabel: String = "com.swipeable.openstate") {
|
|
12
|
+
self.maxSize = maxSize
|
|
13
|
+
self.queue = DispatchQueue(label: queueLabel, qos: .userInteractive)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/// Read the cached open state for a key. Returns false if not found.
|
|
17
|
+
public func get(_ key: String) -> Bool {
|
|
18
|
+
queue.sync { cache[key] ?? false }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/// Set the open state for a key. Promotes existing keys to most-recently-used.
|
|
22
|
+
/// Evicts the least-recently-used entry when cache exceeds max size.
|
|
23
|
+
public func set(_ key: String, isOpen: Bool) {
|
|
24
|
+
queue.async(flags: .barrier) { [self] in
|
|
25
|
+
if cache[key] != nil {
|
|
26
|
+
insertionOrder.removeAll { $0 == key }
|
|
27
|
+
}
|
|
28
|
+
insertionOrder.append(key)
|
|
29
|
+
cache[key] = isOpen
|
|
30
|
+
if insertionOrder.count > maxSize {
|
|
31
|
+
let oldest = insertionOrder.removeFirst()
|
|
32
|
+
cache.removeValue(forKey: oldest)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/// Remove a specific key from the cache.
|
|
38
|
+
public func clear(_ key: String) {
|
|
39
|
+
queue.async(flags: .barrier) { [self] in
|
|
40
|
+
cache.removeValue(forKey: key)
|
|
41
|
+
insertionOrder.removeAll { $0 == key }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/// Remove all entries from the cache.
|
|
46
|
+
public func clearAll() {
|
|
47
|
+
queue.async(flags: .barrier) { [self] in
|
|
48
|
+
cache.removeAll()
|
|
49
|
+
insertionOrder.removeAll()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/// Synchronously return the number of entries (for testing).
|
|
54
|
+
public var count: Int {
|
|
55
|
+
queue.sync { cache.count }
|
|
56
|
+
}
|
|
57
|
+
}
|
package/ios/Package.swift
CHANGED
|
@@ -17,7 +17,7 @@ let package = Package(
|
|
|
17
17
|
"SwipeableModule.swift",
|
|
18
18
|
"react-native-swipeable-actions.podspec"
|
|
19
19
|
],
|
|
20
|
-
sources: ["SwipePhysics.swift", "SwipeAnimationConfig.swift"]
|
|
20
|
+
sources: ["SwipePhysics.swift", "SwipeAnimationConfig.swift", "OpenStateCache.swift"]
|
|
21
21
|
),
|
|
22
22
|
.testTarget(
|
|
23
23
|
name: "SwipeableActionsTests",
|
package/ios/SwipeableView.swift
CHANGED
|
@@ -57,27 +57,15 @@ public class SwipeableView: ExpoView {
|
|
|
57
57
|
// MARK: - Thread-Safe Static Registry
|
|
58
58
|
|
|
59
59
|
private static let registryQueue = DispatchQueue(label: "com.swipeable.registry", qos: .userInteractive)
|
|
60
|
-
|
|
61
|
-
private static var _openStateCache: [String: Bool] = [:]
|
|
62
|
-
private static var _openStateCacheOrder: [String] = []
|
|
60
|
+
static let openStateCache = OpenStateCache()
|
|
63
61
|
private static var _viewRegistry: [String: WeakRef<SwipeableView>] = [:]
|
|
64
62
|
|
|
65
63
|
static func getOpenState(for key: String) -> Bool {
|
|
66
|
-
|
|
64
|
+
openStateCache.get(key)
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
private static func setOpenState(for key: String, isOpen: Bool) {
|
|
70
|
-
|
|
71
|
-
if _openStateCache[key] == nil {
|
|
72
|
-
_openStateCacheOrder.append(key)
|
|
73
|
-
}
|
|
74
|
-
_openStateCache[key] = isOpen
|
|
75
|
-
// Evict oldest entries when cache exceeds max size
|
|
76
|
-
while _openStateCacheOrder.count > maxCacheSize {
|
|
77
|
-
let oldest = _openStateCacheOrder.removeFirst()
|
|
78
|
-
_openStateCache.removeValue(forKey: oldest)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
68
|
+
openStateCache.set(key, isOpen: isOpen)
|
|
81
69
|
}
|
|
82
70
|
|
|
83
71
|
private static func getView(for key: String) -> SwipeableView? {
|
|
@@ -93,7 +81,7 @@ public class SwipeableView: ExpoView {
|
|
|
93
81
|
}
|
|
94
82
|
|
|
95
83
|
private static func clearOpenState(for key: String) {
|
|
96
|
-
|
|
84
|
+
openStateCache.clear(key)
|
|
97
85
|
}
|
|
98
86
|
|
|
99
87
|
private static func getAllViews() -> [SwipeableView] {
|
|
@@ -237,7 +225,11 @@ public class SwipeableView: ExpoView {
|
|
|
237
225
|
|
|
238
226
|
// Apply using local shouldOpen (pendingShouldOpen was cleared by close)
|
|
239
227
|
if shouldOpen {
|
|
240
|
-
|
|
228
|
+
let keyAtDispatch = recyclingKey
|
|
229
|
+
DispatchQueue.main.async { [weak self] in
|
|
230
|
+
guard let self = self, self.recyclingKey == keyAtDispatch else { return }
|
|
231
|
+
self.snapToOpen()
|
|
232
|
+
}
|
|
241
233
|
}
|
|
242
234
|
}
|
|
243
235
|
}
|
|
@@ -318,12 +310,11 @@ public class SwipeableView: ExpoView {
|
|
|
318
310
|
Self.unregisterView(for: key)
|
|
319
311
|
}
|
|
320
312
|
|
|
321
|
-
//
|
|
322
|
-
//
|
|
323
|
-
//
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
// resetting transforms when the view is actually recycled for a new item.
|
|
313
|
+
// Nil view references so didAddSubview correctly detects new children
|
|
314
|
+
// on re-insertion (wasActionsNil/wasContentNil guards).
|
|
315
|
+
// Do NOT reset transforms - Fabric DELETE+INSERT must preserve open visual state.
|
|
316
|
+
contentView = nil
|
|
317
|
+
actionsView = nil
|
|
327
318
|
}
|
|
328
319
|
super.willMove(toSuperview: newSuperview)
|
|
329
320
|
}
|
|
@@ -466,6 +457,9 @@ public class SwipeableView: ExpoView {
|
|
|
466
457
|
var translation = currentTranslation
|
|
467
458
|
if isAnimating, let presentationLayer = contentView?.layer.presentation() {
|
|
468
459
|
translation = presentationLayer.transform.m41 // tx component of transform
|
|
460
|
+
// Keep currentTranslation in sync so layoutSubviews and other guards
|
|
461
|
+
// see the real position, not a stale value from before animation started.
|
|
462
|
+
currentTranslation = translation
|
|
469
463
|
// Update actions to match content position
|
|
470
464
|
let progress = min(abs(translation) / actionsWidth, 1.0)
|
|
471
465
|
let offset = isLeading ? -actionsWidth : actionsWidth
|
|
@@ -560,20 +554,9 @@ public class SwipeableView: ExpoView {
|
|
|
560
554
|
}
|
|
561
555
|
}
|
|
562
556
|
|
|
563
|
-
if currentTranslation != 0 {
|
|
557
|
+
if isOpen && currentTranslation != 0 {
|
|
564
558
|
contentView?.transform = CGAffineTransform(translationX: currentTranslation, y: 0)
|
|
565
559
|
updateActionsTransform()
|
|
566
|
-
|
|
567
|
-
// Fabric may reset child transforms during prop reconciliation after a list
|
|
568
|
-
// reorder. The async dispatch ensures we run after Fabric finishes mutations.
|
|
569
|
-
DispatchQueue.main.async { [weak self] in
|
|
570
|
-
guard let self = self,
|
|
571
|
-
self.currentTranslation != 0,
|
|
572
|
-
!self.isDragging,
|
|
573
|
-
!self.isAnimating else { return }
|
|
574
|
-
self.contentView?.transform = CGAffineTransform(translationX: self.currentTranslation, y: 0)
|
|
575
|
-
self.updateActionsTransform()
|
|
576
|
-
}
|
|
577
560
|
}
|
|
578
561
|
}
|
|
579
562
|
|
package/jestSetup.js
CHANGED
|
@@ -5,7 +5,8 @@ jest.mock('./src/SwipeableView.tsx', () => {
|
|
|
5
5
|
const SwipeableModule = {
|
|
6
6
|
openByKey: jest.fn(),
|
|
7
7
|
closeByKey: jest.fn(),
|
|
8
|
-
closeAll: jest.fn()
|
|
8
|
+
closeAll: jest.fn(),
|
|
9
|
+
isOpenByKey: jest.fn().mockReturnValue(false)
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const SwipeableView = React.forwardRef((props, ref) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-swipeable-actions",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7-canary.0",
|
|
4
4
|
"description": "High-performance native swipeable row component for React Native using Expo Modules",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -27,10 +27,11 @@
|
|
|
27
27
|
"test:all": "npm test && npm run test:ios && npm run test:android",
|
|
28
28
|
"test:watch": "jest --watch",
|
|
29
29
|
"test:coverage": "jest --coverage",
|
|
30
|
-
"lint": "
|
|
31
|
-
"lint:fix": "
|
|
32
|
-
"format": "
|
|
33
|
-
"format:check": "
|
|
30
|
+
"lint": "biome lint src example e2e",
|
|
31
|
+
"lint:fix": "biome lint --write src example e2e",
|
|
32
|
+
"format": "biome format --write src example e2e",
|
|
33
|
+
"format:check": "biome format src example e2e",
|
|
34
|
+
"check": "biome check src example e2e",
|
|
34
35
|
"typecheck": "tsc --noEmit",
|
|
35
36
|
"android": "expo run:android",
|
|
36
37
|
"ios": "expo run:ios",
|
|
@@ -64,19 +65,13 @@
|
|
|
64
65
|
"react-native": ">=0.73.0"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
68
|
+
"@biomejs/biome": "2.4.9",
|
|
67
69
|
"@testing-library/react-native": "^12.4.0",
|
|
68
70
|
"@types/jest": "^29.5.0",
|
|
69
71
|
"@types/react": "19.1.1",
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
71
|
-
"@typescript-eslint/parser": "^6.0.0",
|
|
72
|
-
"eslint": "^8.57.0",
|
|
73
|
-
"eslint-config-prettier": "^9.1.0",
|
|
74
|
-
"eslint-plugin-react": "^7.34.0",
|
|
75
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
76
72
|
"expo-modules-core": "^3.0.26",
|
|
77
73
|
"jest": "^29.7.0",
|
|
78
|
-
"prettier": "^3.
|
|
79
|
-
"prettier-config-holepunch": "^2.0.0",
|
|
74
|
+
"prettier": "^3.8.1",
|
|
80
75
|
"react": "19.1.1",
|
|
81
76
|
"react-native": "0.82.1",
|
|
82
77
|
"react-test-renderer": "19.1.1",
|
package/src/Swipeable.tsx
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { forwardRef,
|
|
2
|
-
import { StyleSheet, View
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
SwipeableProps,
|
|
1
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react'
|
|
2
|
+
import { Platform, StyleSheet, View } from 'react-native'
|
|
3
|
+
import { SWIPE_DEFAULTS } from './constants'
|
|
4
|
+
import { closeAll, closeByKey, isOpenByKey, openByKey } from './nativeModuleUtils'
|
|
5
|
+
import type {
|
|
6
|
+
NativeSwipeableRef,
|
|
8
7
|
SwipeableMethods,
|
|
8
|
+
SwipeableProps,
|
|
9
9
|
SwipeProgressEvent,
|
|
10
|
-
SwipeStateEvent
|
|
11
|
-
NativeSwipeableRef
|
|
10
|
+
SwipeStateEvent
|
|
12
11
|
} from './Swipeable.types'
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { SwipeableActions } from './SwipeableActions'
|
|
13
|
+
import { SwipeableView } from './SwipeableView'
|
|
15
14
|
|
|
16
15
|
function normalizeRecyclingKey(key: string | number | undefined): string | undefined {
|
|
17
16
|
if (key == null) return undefined
|
|
@@ -60,14 +59,17 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(function Swipeabl
|
|
|
60
59
|
return normalizedKey != null && isOpenByKey(normalizedKey)
|
|
61
60
|
})
|
|
62
61
|
const swipeStartedRef = useRef(false)
|
|
62
|
+
const initialKeyRef = useRef(normalizedKey)
|
|
63
63
|
|
|
64
64
|
// When recyclingKey changes (FlatList reorder/recycle), sync hasActionsRendered
|
|
65
65
|
// with the native cached open state. FlatList reuses component instances without
|
|
66
|
-
// remounting, so useState initializer doesn't re-run.
|
|
66
|
+
// remounting, so useState initializer doesn't re-run. Skip on initial mount
|
|
67
|
+
// since the useState initializer already handled it.
|
|
67
68
|
useEffect(() => {
|
|
68
69
|
if (!normalizedKey) return
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
if (normalizedKey === initialKeyRef.current) return
|
|
71
|
+
initialKeyRef.current = normalizedKey
|
|
72
|
+
setHasActionsRendered(isOpenByKey(normalizedKey))
|
|
71
73
|
}, [normalizedKey])
|
|
72
74
|
|
|
73
75
|
// Development-time validation
|
package/src/Swipeable.types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactNode, Ref } from 'react'
|
|
2
|
-
import {
|
|
1
|
+
import type { ReactNode, Ref } from 'react'
|
|
2
|
+
import type { StyleProp, ViewProps, ViewStyle } from 'react-native'
|
|
3
3
|
|
|
4
4
|
export interface SwipeProgressEvent {
|
|
5
5
|
nativeEvent: {
|
package/src/SwipeableActions.tsx
CHANGED
package/src/SwipeableView.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { requireNativeModule, requireNativeViewManager } from 'expo-modules-core'
|
|
2
|
+
import { type ComponentProps, createElement, forwardRef } from 'react'
|
|
3
|
+
import type { NativeSwipeableRef, SwipeableViewProps } from './Swipeable.types'
|
|
4
4
|
|
|
5
5
|
const NativeView = requireNativeViewManager<SwipeableViewProps>('Swipeable')
|
|
6
6
|
|
package/src/index.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
+
export { SWIPE_DEFAULTS, SWIPE_PROGRESS } from './constants'
|
|
2
|
+
export type { NativeModuleError, SwipeableErrorHandler } from './nativeModuleUtils'
|
|
3
|
+
// Error handling utilities
|
|
4
|
+
export { setGlobalErrorHandler } from './nativeModuleUtils'
|
|
1
5
|
export { default as Swipeable } from './Swipeable'
|
|
2
|
-
export { SwipeableView } from './SwipeableView'
|
|
3
|
-
|
|
4
6
|
export type {
|
|
5
|
-
|
|
7
|
+
NativeSwipeableRef,
|
|
6
8
|
SwipeableMethods,
|
|
9
|
+
SwipeableProps,
|
|
7
10
|
SwipeableStatic,
|
|
8
11
|
SwipeableViewProps,
|
|
9
12
|
SwipeProgressEvent,
|
|
10
|
-
SwipeStateEvent
|
|
11
|
-
NativeSwipeableRef
|
|
13
|
+
SwipeStateEvent
|
|
12
14
|
} from './Swipeable.types'
|
|
13
|
-
|
|
14
|
-
export { SWIPE_PROGRESS, SWIPE_DEFAULTS } from './constants'
|
|
15
|
-
|
|
16
|
-
// Error handling utilities
|
|
17
|
-
export { setGlobalErrorHandler } from './nativeModuleUtils'
|
|
18
|
-
export type { SwipeableErrorHandler, NativeModuleError } from './nativeModuleUtils'
|
|
15
|
+
export { SwipeableView } from './SwipeableView'
|