@lynx-js/lynx-ui-swipe-action 3.139.0 → 3.140.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @lynx-js/lynx-ui-swipe-action
2
2
 
3
+ ## 3.140.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Keep implementation-only component signatures out of public documentation ([#355](https://github.com/lynx-family/lynx-ui/pull/355))
8
+ types.
9
+
3
10
  ## 3.139.0
4
11
 
5
12
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import type { SwipeActionProps, SwipeActionRef, SwipeAction as swipeActionType } from './types/index.js';
1
+ import type { ReactElement } from '@lynx-js/react';
2
+ import type { SwipeActionProps, SwipeActionRef } from './types/index.js';
2
3
  export type { SwipeActionProps, SwipeActionRef };
3
- export declare const SwipeAction: swipeActionType;
4
+ type SwipeActionComponent = (props: SwipeActionProps) => ReactElement;
5
+ export declare const SwipeAction: SwipeActionComponent;
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,WAAW,IAAI,eAAe,EAC/B,MAAM,eAAe,CAAA;AAEtB,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAA;AAEhD,eAAO,MAAM,WAAW,EAAwC,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAehE,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAErE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAA;AAEhD,KAAK,oBAAoB,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,YAAY,CAAA;AAErE,eAAO,MAAM,WAAW,EAEnB,oBAAoB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.jsx","sources":["../src/index.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ForwardedRef } from '@lynx-js/react'\nimport {\n forwardRef,\n memo,\n runOnBackground,\n runOnMainThread,\n useImperativeHandle,\n useMainThreadRef,\n useState,\n} from '@lynx-js/react'\n\nimport { NativeGesture, useGesture } from '@lynx-js/gesture-runtime'\nimport type { NativeGestureChangeEvent } from '@lynx-js/gesture-runtime'\nimport { noop, selectorMT } from '@lynx-js/lynx-ui-common'\n\nimport type {\n SwipeActionProps,\n SwipeActionRef,\n SwipeAction as swipeActionType,\n} from './types/index'\n\nexport type { SwipeActionProps, SwipeActionRef }\n\nexport const SwipeAction = memo(forwardRef(SwipeActionImpl)) as swipeActionType\n\nfunction SwipeActionImpl(\n props: SwipeActionProps,\n ref: ForwardedRef<SwipeActionRef>,\n) {\n const {\n enableSwipe,\n swipeActionId = 'swipeActionId',\n style,\n className,\n displayArea,\n actionArea,\n estimatedActionAreaSize = 0,\n onAction = noop,\n onSwipeStart = noop,\n onSwipeEnd = noop,\n debugLog = false,\n iosEnableSimultaneousTouch = true,\n } = props\n const sampleCurveX = (tx: number, a: number, b: number, c: number) => {\n 'main thread'\n return ((a * tx + b) * tx + c) * tx\n }\n\n const sampleCurveY = (ty: number, a: number, b: number, c: number) => {\n 'main thread'\n return ((a * ty + b) * ty + c) * ty\n }\n\n const solveCurveX = (\n x: number,\n ax: number,\n bx: number,\n cx: number,\n epsilon = 1e-6,\n ) => {\n 'main thread'\n let t2 = x\n let x2: number, d2: number\n // Newton's method for solving the t-value corresponding to the x-coordinate of a curve.\n for (let i = 0; i < 8; i++) {\n x2 = sampleCurveX(t2, ax, bx, cx) - x\n if (Math.abs(x2) < epsilon) {\n return t2\n }\n d2 = (3 * ax * t2 + 2 * bx) * t2 + cx\n if (Math.abs(d2) < 1e-6) {\n break\n }\n t2 = t2 - x2 / d2\n }\n // Bisection method.\n let t0 = 0\n let t1 = 1\n t2 = x\n while (t0 < t1) {\n x2 = sampleCurveX(t2, ax, bx, cx)\n if (Math.abs(x2 - x) < epsilon) {\n return t2\n }\n if (x > x2) {\n t0 = t2\n } else {\n t1 = t2\n }\n t2 = (t1 - t0) * 0.5 + t0\n }\n return t2 // Approximate solution.\n }\n\n const cubicBezier = (\n t: number,\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n ) => {\n 'main thread'\n // calculate the coefficients of a polynomial\n const cx = 3 * p1x\n const bx = 3 * (p2x - p1x) - cx\n const ax = 1 - cx - bx\n\n const cy = 3 * p1y\n const by = 3 * (p2y - p1y) - cy\n const ay = 1 - cy - by\n\n return sampleCurveY(solveCurveX(t, ax, bx, cx), ay, by, cy)\n }\n enum movingDirection {\n left = 0,\n right = 1,\n }\n const animationDuration = 350 // ms\n const transformEllison = 0.03 // px\n const swipeMinimumVelocity = useMainThreadRef<number>(0.1) // px/ms If velocity is less than this, it will not be considered as a swipe\n const prevTouchPointX = useMainThreadRef<number>(0)\n const prevTouchPointY = useMainThreadRef<number>(0)\n const [displayAreaSize, setDisplayAreaSize] = useState(0)\n\n const lastMovingDirection = useMainThreadRef<movingDirection>(0)\n\n const currentTransform = useMainThreadRef<number>(0)\n const lastTouchMoveGestureEvent = useMainThreadRef<NativeGestureChangeEvent>()\n const transformInTouchStart = useMainThreadRef<number>(0)\n\n const transformStartPosition = useMainThreadRef<number>(0)\n const currentVelocity = useMainThreadRef<number>(0)\n const isFirstJudge = useMainThreadRef<boolean>(true)\n const isStartWithHorizontal = useMainThreadRef<boolean>(false)\n const currentAnimationFrame = useMainThreadRef<number>(-1)\n\n const swipeGesture: NativeGesture = useGesture(NativeGesture)\n\n const calculateVelocityGesture = (event: NativeGestureChangeEvent) => {\n 'main thread'\n if (event == null || lastTouchMoveGestureEvent.current == null) {\n currentVelocity.current = 0\n return\n }\n const deltaTime = event.params.timestamp\n - (lastTouchMoveGestureEvent.current?.params.timestamp ?? 0)\n const deltaX = event.params.clientX\n - lastTouchMoveGestureEvent.current?.params.clientX\n const velocity = deltaX / deltaTime\n currentVelocity.current = velocity\n lastTouchMoveGestureEvent.current = event\n }\n\n const [actionAreaSize, setActionAreaSizeInner] = useState(\n estimatedActionAreaSize,\n )\n\n const actionAreaSizeMTRef = useMainThreadRef<number>(\n estimatedActionAreaSize,\n )\n\n const totalAreaSize = displayAreaSize + actionAreaSize\n\n const clearPreviousSwipeAnimation = () => {\n 'main thread'\n if (currentAnimationFrame.current !== -1) {\n cancelAnimationFrame(currentAnimationFrame.current)\n currentAnimationFrame.current = -1\n }\n }\n\n function setActionAreaSize(value: number) {\n setActionAreaSizeInner(value)\n runOnMainThread((areaSize: number) => {\n 'main thread'\n actionAreaSizeMTRef.current = areaSize\n })(value)\n }\n\n const setTransformProperty = (value: number) => {\n 'main thread'\n selectorMT(swipeActionId)?.setStyleProperty(\n 'transform',\n `translateX(${value}px)`,\n )\n }\n\n const setTransform = (value: number) => {\n 'main thread'\n if (Math.abs(value) < transformEllison) {\n setTransformProperty(0)\n currentTransform.current = 0\n return\n }\n // Clamp delta to valid range [-actionAreaSize, 0]\n let delta = Math.min(0, value)\n delta = Math.max(delta, -actionAreaSizeMTRef.current)\n\n setTransformProperty(delta)\n if (debugLog) {\n console.info(\n 'setTransform id',\n swipeActionId,\n delta,\n actionAreaSizeMTRef.current,\n )\n }\n currentTransform.current = delta\n }\n\n const isHorizontalTouchMoveGesture = (event: NativeGestureChangeEvent) => {\n 'main thread'\n\n const deltaX = event.params.clientX - prevTouchPointX.current\n\n const deltaY = event.params.clientY - prevTouchPointY.current\n return Math.abs(deltaX) >= Math.abs(deltaY)\n }\n\n swipeGesture.onTouchesDown((event, manager) => {\n 'main thread'\n if (debugLog) {\n console.info(swipeActionId, 'touch start')\n }\n manager.interceptGesture(true)\n\n isFirstJudge.current = true\n // initialize touch point for this gesture\n\n prevTouchPointY.current = event.params.clientY\n\n prevTouchPointX.current = event.params.clientX\n transformStartPosition.current = currentTransform.current\n transformInTouchStart.current = currentTransform.current\n runOnBackground(onSwipeStart)(swipeActionId)\n })\n\n swipeGesture.onTouchesMove((event, manager) => {\n 'main thread'\n if (!enableSwipe) {\n if (debugLog) {\n console.info(swipeActionId, 'swipe disabled')\n }\n return\n }\n if (!isFirstJudge.current && !isStartWithHorizontal.current) {\n if (debugLog) {\n console.info(swipeActionId, 'swipe block due to vertical gesture')\n }\n return\n }\n clearPreviousSwipeAnimation()\n\n const currentTouchPointX = event.params.clientX\n\n const currentTouchPointY = event.params.clientY\n const deltaX = currentTouchPointX - prevTouchPointX.current\n if (isFirstJudge.current) {\n isFirstJudge.current = false\n // only in the first judgement, we change the status of isStartWithHorizontal\n isStartWithHorizontal.current = isHorizontalTouchMoveGesture(event)\n if (isStartWithHorizontal.current) {\n manager.interceptGesture(true)\n } else {\n manager.interceptGesture(false)\n manager.fail()\n\n prevTouchPointX.current = currentTouchPointX\n\n prevTouchPointY.current = currentTouchPointY\n return\n }\n }\n\n prevTouchPointX.current = currentTouchPointX\n\n prevTouchPointY.current = currentTouchPointY\n\n calculateVelocityGesture(event)\n // Record last gesture to determine swipe direction is right to delete or left to undo\n lastMovingDirection.current = deltaX > 0\n ? movingDirection.left\n : movingDirection.right\n\n transformStartPosition.current = currentTransform.current ?? 0\n\n if (debugLog) {\n console.info(deltaX, transformStartPosition.current)\n }\n setTransform(deltaX + transformStartPosition.current)\n })\n\n const easingInOut = (t: number) => {\n 'main thread'\n return cubicBezier(t, 0, 0, 0.4, 1)\n }\n\n const swipeAnimation = (\n startTime: number,\n startSwipePoint: number,\n distanceToSwipe: number,\n consumedSwipedTime: number,\n isSwipeRight: boolean,\n ) => {\n 'main thread'\n const swipeAnimationInner = () => {\n const currentTime = Date.now() - startTime + consumedSwipedTime\n const timePercentage = currentTime / animationDuration\n const percentage = easingInOut(timePercentage)\n if (isSwipeRight) {\n setTransform(startSwipePoint + distanceToSwipe * percentage)\n } else {\n setTransform(distanceToSwipe * (1 - percentage))\n }\n if (debugLog) {\n console.info(\n 'currentTime',\n currentTime,\n percentage,\n distanceToSwipe,\n distanceToSwipe * (1 - percentage),\n )\n }\n if (timePercentage < 1) {\n currentAnimationFrame.current = requestAnimationFrame(\n swipeAnimationInner,\n )\n } else {\n if (isSwipeRight) {\n setTransform(-actionAreaSizeMTRef.current)\n } else {\n setTransform(0)\n }\n currentAnimationFrame.current = -1\n }\n }\n swipeAnimationInner()\n }\n\n const swipeLeftToUndo = (isCanceling: boolean) => {\n 'main thread'\n // Undo\n // |-------------actionAreaSize---------------|\n // |<<<<<<<<<<<<<<<<<<<<<<<|------------------|\n // |----distanceToSwipe----|--distanceSwiped--|\n if (debugLog) {\n console.info(swipeActionId, 'swipeLeftToUndo, isCanceling', isCanceling)\n }\n const distanceToSwipe = currentTransform.current\n const distanceSwipedPercentage = 1\n - Math.abs(currentTransform.current) / actionAreaSizeMTRef.current\n // Make sure cancel process has the same duration as swipe\n const consumedSwipedTime = isCanceling\n ? 0\n : animationDuration * distanceSwipedPercentage\n const startTime = Date.now()\n clearPreviousSwipeAnimation()\n swipeAnimation(\n startTime,\n currentTransform.current,\n distanceToSwipe,\n consumedSwipedTime,\n false,\n )\n }\n\n const swipeRightToAction = (isCanceling: boolean) => {\n 'main thread'\n // Delete\n // |-------------actionAreaSize---------------|\n // |------------------|>>>>>>>>>>>>>>>>>>>>>>>|\n // |--distanceSwiped--|----distanceToSwipe----|\n if (debugLog) {\n console.info(\n swipeActionId,\n 'swipeRightToAction, isCanceling',\n isCanceling,\n )\n }\n const distanceToSwipe = -actionAreaSizeMTRef.current\n - currentTransform.current\n const distanceSwipedPercentage = Math.abs(currentTransform.current)\n / actionAreaSizeMTRef.current\n const consumedSwipedTime = isCanceling\n ? 0\n : animationDuration * distanceSwipedPercentage\n const startTime = Date.now()\n clearPreviousSwipeAnimation()\n swipeAnimation(\n startTime,\n currentTransform.current,\n distanceToSwipe,\n consumedSwipedTime,\n true,\n )\n }\n\n const swipeWithEasingInOut = () => {\n 'main thread'\n if (debugLog) {\n console.info(\n swipeActionId,\n 'swipeWithEasingInOut, lastMovingDirection',\n lastMovingDirection.current,\n )\n }\n if (lastMovingDirection.current === movingDirection.right) {\n swipeRightToAction(false)\n } else {\n swipeLeftToUndo(false)\n }\n }\n\n const swipeCancelDueToSmallVelocity = () => {\n 'main thread'\n if (\n Math.abs(currentTransform.current)\n > actionAreaSizeMTRef.current * 0.5\n ) {\n swipeRightToAction(true)\n } else {\n swipeLeftToUndo(true)\n }\n }\n\n const sendSwipeEndJS = () => {\n if (onSwipeEnd) {\n onSwipeEnd(swipeActionId)\n }\n }\n\n const clearTouchInfo = () => {\n 'main thread'\n prevTouchPointX.current = 0\n prevTouchPointY.current = 0\n }\n\n swipeGesture.onTouchesUp((_event, _manager) => {\n 'main thread'\n if (debugLog) {\n console.info(\n 'touchEnd',\n swipeActionId,\n enableSwipe,\n prevTouchPointX.current,\n )\n }\n isFirstJudge.current = true\n // don't need to judge if enableSwipe is true or not, whenever there is a touchEnd.\n if (!prevTouchPointX.current) {\n console.error('ERROR! previous touch point is null')\n return\n }\n\n clearTouchInfo()\n\n if (debugLog) {\n console.info('scroll end velocity', currentVelocity.current)\n }\n if (isStartWithHorizontal.current) {\n if (Math.abs(currentVelocity.current) > swipeMinimumVelocity.current) {\n swipeWithEasingInOut()\n } else {\n swipeCancelDueToSmallVelocity()\n }\n runOnBackground(sendSwipeEndJS)()\n }\n isStartWithHorizontal.current = false\n })\n\n const showActionAreaMTS = (animated: boolean) => {\n 'main thread'\n if (animated) {\n swipeRightToAction(false)\n } else {\n clearPreviousSwipeAnimation()\n setTransform(-actionAreaSizeMTRef.current)\n }\n }\n\n const showActionArea = (animated: boolean) => {\n runOnMainThread(showActionAreaMTS)(animated)\n sendSwipeEndJS()\n }\n\n const closeActionAreaMTS = (animated: boolean) => {\n 'main thread'\n if (debugLog) {\n console.info('closeActionAreaMTS', swipeActionId)\n }\n clearPreviousSwipeAnimation()\n if (animated) {\n swipeLeftToUndo(false)\n } else {\n setTransform(0)\n }\n }\n\n const closeActionArea = (animated: boolean) => {\n runOnMainThread(closeActionAreaMTS)(animated)\n }\n\n useImperativeHandle(\n ref,\n () => ({\n showActionArea,\n closeActionArea,\n }),\n [showActionArea, closeActionArea],\n )\n\n return (\n <view\n style={{\n ...style,\n display: 'linear',\n linearOrientation: 'horizontal',\n width: `${totalAreaSize}px`,\n }}\n className={className}\n id={swipeActionId}\n enable-new-animator={false}\n flatten={false}\n main-thread:gesture={swipeGesture}\n main-thread:binduiappear={() => {\n 'main thread'\n setTransform(currentTransform.current)\n }}\n ios-enable-simultaneous-touch={iosEnableSimultaneousTouch}\n >\n <view\n id={`${swipeActionId}-displayArea`}\n style={{ height: '100%' }}\n main-thread:binduiappear={() => {\n 'main thread'\n setTransform(currentTransform.current)\n }}\n binduiappear={() => {\n lynx\n .createSelectorQuery()\n .select(`#${swipeActionId}-displayArea`)\n .invoke({\n method: 'boundingClientRect',\n success: (res: unknown) => {\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n setDisplayAreaSize(res.width)\n },\n })\n .exec()\n lynx\n .createSelectorQuery()\n .select(`#${swipeActionId}-actionArea`)\n .invoke({\n method: 'boundingClientRect',\n success: (res: unknown) => {\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n setActionAreaSize(res.width)\n },\n })\n .exec()\n }}\n main-thread:binduidisappear={() => {\n 'main thread'\n setTransformProperty(0)\n clearTouchInfo()\n clearPreviousSwipeAnimation()\n currentTransform.current = 0\n transformStartPosition.current = 0\n }}\n >\n {displayArea}\n </view>\n <view\n id={`${swipeActionId}-actionArea`}\n style={{ height: '100%' }}\n main-thread:bindtap={() => {\n 'main thread'\n setTransform(0)\n runOnBackground(onAction)(swipeActionId)\n }}\n >\n {actionArea}\n </view>\n </view>\n )\n}\n"],"names":["SwipeAction","memo","forwardRef","SwipeActionImpl","props","ref","enableSwipe","swipeActionId","style","className","displayArea","actionArea","estimatedActionAreaSize","onAction","noop","onSwipeStart","onSwipeEnd","debugLog","iosEnableSimultaneousTouch","sampleCurveX","tx","a","b","c","sampleCurveY","ty","solveCurveX","x","ax","bx","cx","epsilon","t2","x2","d2","i","Math","t0","t1","cubicBezier","t","p1x","p1y","p2x","p2y","cy","by","ay","animationDuration","transformEllison","swipeMinimumVelocity","useMainThreadRef","prevTouchPointX","prevTouchPointY","displayAreaSize","setDisplayAreaSize","useState","lastMovingDirection","currentTransform","lastTouchMoveGestureEvent","transformInTouchStart","transformStartPosition","currentVelocity","isFirstJudge","isStartWithHorizontal","currentAnimationFrame","swipeGesture","useGesture","NativeGesture","calculateVelocityGesture","event","deltaTime","deltaX","velocity","actionAreaSize","setActionAreaSizeInner","actionAreaSizeMTRef","totalAreaSize","clearPreviousSwipeAnimation","cancelAnimationFrame","setActionAreaSize","value","runOnMainThread","areaSize","setTransformProperty","selectorMT","setTransform","delta","console","isHorizontalTouchMoveGesture","deltaY","manager","runOnBackground","currentTouchPointX","currentTouchPointY","easingInOut","swipeAnimation","startTime","startSwipePoint","distanceToSwipe","consumedSwipedTime","isSwipeRight","swipeAnimationInner","currentTime","Date","timePercentage","percentage","requestAnimationFrame","swipeLeftToUndo","isCanceling","distanceSwipedPercentage","swipeRightToAction","swipeWithEasingInOut","swipeCancelDueToSmallVelocity","sendSwipeEndJS","clearTouchInfo","_event","_manager","showActionAreaMTS","animated","showActionArea","closeActionAreaMTS","closeActionArea","useImperativeHandle","view","lynx","res"],"mappings":";;;AA2BO,MAAMA,cAAcC,KAAKC,WAAWC;AAE3C,SAASA,gBACPC,KAAuB,EACvBC,GAAiC;IAEjC,MAAM,EACJC,WAAW,EACXC,gBAAgB,eAAe,EAC/BC,KAAK,EACLC,SAAS,EACTC,WAAW,EACXC,UAAU,E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,EAAEkH,KAAK;MACP,CAACA,KACC,IAAI,GAAGrH,cAAc,WAAW,CAAC,EACjC,OAAO;QAAE,QAAQ;IAAO,GACxB,YAAY,SAAS;QACnB;QACA+E,aAAa;QACbM,gBAAgB/E,UAAUN;IAC5B,GACD;QACC,CAACI,WAAW;MACd,EAAEiH,KAAK;IACT,EAAEA;AAEN"}
1
+ {"version":3,"file":"index.jsx","sources":["../src/index.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ForwardedRef, ReactElement } from '@lynx-js/react'\nimport {\n forwardRef,\n memo,\n runOnBackground,\n runOnMainThread,\n useImperativeHandle,\n useMainThreadRef,\n useState,\n} from '@lynx-js/react'\n\nimport { NativeGesture, useGesture } from '@lynx-js/gesture-runtime'\nimport type { NativeGestureChangeEvent } from '@lynx-js/gesture-runtime'\nimport { noop, selectorMT } from '@lynx-js/lynx-ui-common'\n\nimport type { SwipeActionProps, SwipeActionRef } from './types/index'\n\nexport type { SwipeActionProps, SwipeActionRef }\n\ntype SwipeActionComponent = (props: SwipeActionProps) => ReactElement\n\nexport const SwipeAction = memo(\n forwardRef(SwipeActionImpl),\n) as SwipeActionComponent\n\nfunction SwipeActionImpl(\n props: SwipeActionProps,\n ref: ForwardedRef<SwipeActionRef>,\n) {\n const {\n enableSwipe,\n swipeActionId = 'swipeActionId',\n style,\n className,\n displayArea,\n actionArea,\n estimatedActionAreaSize = 0,\n onAction = noop,\n onSwipeStart = noop,\n onSwipeEnd = noop,\n debugLog = false,\n iosEnableSimultaneousTouch = true,\n } = props\n const sampleCurveX = (tx: number, a: number, b: number, c: number) => {\n 'main thread'\n return ((a * tx + b) * tx + c) * tx\n }\n\n const sampleCurveY = (ty: number, a: number, b: number, c: number) => {\n 'main thread'\n return ((a * ty + b) * ty + c) * ty\n }\n\n const solveCurveX = (\n x: number,\n ax: number,\n bx: number,\n cx: number,\n epsilon = 1e-6,\n ) => {\n 'main thread'\n let t2 = x\n let x2: number, d2: number\n // Newton's method for solving the t-value corresponding to the x-coordinate of a curve.\n for (let i = 0; i < 8; i++) {\n x2 = sampleCurveX(t2, ax, bx, cx) - x\n if (Math.abs(x2) < epsilon) {\n return t2\n }\n d2 = (3 * ax * t2 + 2 * bx) * t2 + cx\n if (Math.abs(d2) < 1e-6) {\n break\n }\n t2 = t2 - x2 / d2\n }\n // Bisection method.\n let t0 = 0\n let t1 = 1\n t2 = x\n while (t0 < t1) {\n x2 = sampleCurveX(t2, ax, bx, cx)\n if (Math.abs(x2 - x) < epsilon) {\n return t2\n }\n if (x > x2) {\n t0 = t2\n } else {\n t1 = t2\n }\n t2 = (t1 - t0) * 0.5 + t0\n }\n return t2 // Approximate solution.\n }\n\n const cubicBezier = (\n t: number,\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n ) => {\n 'main thread'\n // calculate the coefficients of a polynomial\n const cx = 3 * p1x\n const bx = 3 * (p2x - p1x) - cx\n const ax = 1 - cx - bx\n\n const cy = 3 * p1y\n const by = 3 * (p2y - p1y) - cy\n const ay = 1 - cy - by\n\n return sampleCurveY(solveCurveX(t, ax, bx, cx), ay, by, cy)\n }\n enum MovingDirection {\n left = 0,\n right = 1,\n }\n const animationDuration = 350 // ms\n const transformEllison = 0.03 // px\n const swipeMinimumVelocity = useMainThreadRef<number>(0.1) // px/ms If velocity is less than this, it will not be considered as a swipe\n const prevTouchPointX = useMainThreadRef<number>(0)\n const prevTouchPointY = useMainThreadRef<number>(0)\n const [displayAreaSize, setDisplayAreaSize] = useState(0)\n\n const lastMovingDirection = useMainThreadRef<MovingDirection>(0)\n\n const currentTransform = useMainThreadRef<number>(0)\n const lastTouchMoveGestureEvent = useMainThreadRef<NativeGestureChangeEvent>()\n const transformInTouchStart = useMainThreadRef<number>(0)\n\n const transformStartPosition = useMainThreadRef<number>(0)\n const currentVelocity = useMainThreadRef<number>(0)\n const isFirstJudge = useMainThreadRef<boolean>(true)\n const isStartWithHorizontal = useMainThreadRef<boolean>(false)\n const currentAnimationFrame = useMainThreadRef<number>(-1)\n\n const swipeGesture: NativeGesture = useGesture(NativeGesture)\n\n const calculateVelocityGesture = (event: NativeGestureChangeEvent) => {\n 'main thread'\n if (event == null || lastTouchMoveGestureEvent.current == null) {\n currentVelocity.current = 0\n return\n }\n const deltaTime = event.params.timestamp\n - (lastTouchMoveGestureEvent.current?.params.timestamp ?? 0)\n const deltaX = event.params.clientX\n - lastTouchMoveGestureEvent.current?.params.clientX\n const velocity = deltaX / deltaTime\n currentVelocity.current = velocity\n lastTouchMoveGestureEvent.current = event\n }\n\n const [actionAreaSize, setActionAreaSizeInner] = useState(\n estimatedActionAreaSize,\n )\n\n const actionAreaSizeMTRef = useMainThreadRef<number>(\n estimatedActionAreaSize,\n )\n\n const totalAreaSize = displayAreaSize + actionAreaSize\n\n const clearPreviousSwipeAnimation = () => {\n 'main thread'\n if (currentAnimationFrame.current !== -1) {\n cancelAnimationFrame(currentAnimationFrame.current)\n currentAnimationFrame.current = -1\n }\n }\n\n function setActionAreaSize(value: number) {\n setActionAreaSizeInner(value)\n runOnMainThread((areaSize: number) => {\n 'main thread'\n actionAreaSizeMTRef.current = areaSize\n })(value)\n }\n\n const setTransformProperty = (value: number) => {\n 'main thread'\n selectorMT(swipeActionId)?.setStyleProperty(\n 'transform',\n `translateX(${value}px)`,\n )\n }\n\n const setTransform = (value: number) => {\n 'main thread'\n if (Math.abs(value) < transformEllison) {\n setTransformProperty(0)\n currentTransform.current = 0\n return\n }\n // Clamp delta to valid range [-actionAreaSize, 0]\n let delta = Math.min(0, value)\n delta = Math.max(delta, -actionAreaSizeMTRef.current)\n\n setTransformProperty(delta)\n if (debugLog) {\n console.info(\n 'setTransform id',\n swipeActionId,\n delta,\n actionAreaSizeMTRef.current,\n )\n }\n currentTransform.current = delta\n }\n\n const isHorizontalTouchMoveGesture = (event: NativeGestureChangeEvent) => {\n 'main thread'\n\n const deltaX = event.params.clientX - prevTouchPointX.current\n\n const deltaY = event.params.clientY - prevTouchPointY.current\n return Math.abs(deltaX) >= Math.abs(deltaY)\n }\n\n swipeGesture.onTouchesDown((event, manager) => {\n 'main thread'\n if (debugLog) {\n console.info(swipeActionId, 'touch start')\n }\n manager.interceptGesture(true)\n\n isFirstJudge.current = true\n // initialize touch point for this gesture\n\n prevTouchPointY.current = event.params.clientY\n\n prevTouchPointX.current = event.params.clientX\n transformStartPosition.current = currentTransform.current\n transformInTouchStart.current = currentTransform.current\n runOnBackground(onSwipeStart)(swipeActionId)\n })\n\n swipeGesture.onTouchesMove((event, manager) => {\n 'main thread'\n if (!enableSwipe) {\n if (debugLog) {\n console.info(swipeActionId, 'swipe disabled')\n }\n return\n }\n if (!isFirstJudge.current && !isStartWithHorizontal.current) {\n if (debugLog) {\n console.info(swipeActionId, 'swipe block due to vertical gesture')\n }\n return\n }\n clearPreviousSwipeAnimation()\n\n const currentTouchPointX = event.params.clientX\n\n const currentTouchPointY = event.params.clientY\n const deltaX = currentTouchPointX - prevTouchPointX.current\n if (isFirstJudge.current) {\n isFirstJudge.current = false\n // only in the first judgement, we change the status of isStartWithHorizontal\n isStartWithHorizontal.current = isHorizontalTouchMoveGesture(event)\n if (isStartWithHorizontal.current) {\n manager.interceptGesture(true)\n } else {\n manager.interceptGesture(false)\n manager.fail()\n\n prevTouchPointX.current = currentTouchPointX\n\n prevTouchPointY.current = currentTouchPointY\n return\n }\n }\n\n prevTouchPointX.current = currentTouchPointX\n\n prevTouchPointY.current = currentTouchPointY\n\n calculateVelocityGesture(event)\n // Record last gesture to determine swipe direction is right to delete or left to undo\n lastMovingDirection.current = deltaX > 0\n ? MovingDirection.left\n : MovingDirection.right\n\n transformStartPosition.current = currentTransform.current ?? 0\n\n if (debugLog) {\n console.info(deltaX, transformStartPosition.current)\n }\n setTransform(deltaX + transformStartPosition.current)\n })\n\n const easingInOut = (t: number) => {\n 'main thread'\n return cubicBezier(t, 0, 0, 0.4, 1)\n }\n\n const swipeAnimation = (\n startTime: number,\n startSwipePoint: number,\n distanceToSwipe: number,\n consumedSwipedTime: number,\n isSwipeRight: boolean,\n ) => {\n 'main thread'\n const swipeAnimationInner = () => {\n const currentTime = Date.now() - startTime + consumedSwipedTime\n const timePercentage = currentTime / animationDuration\n const percentage = easingInOut(timePercentage)\n if (isSwipeRight) {\n setTransform(startSwipePoint + distanceToSwipe * percentage)\n } else {\n setTransform(distanceToSwipe * (1 - percentage))\n }\n if (debugLog) {\n console.info(\n 'currentTime',\n currentTime,\n percentage,\n distanceToSwipe,\n distanceToSwipe * (1 - percentage),\n )\n }\n if (timePercentage < 1) {\n currentAnimationFrame.current = requestAnimationFrame(\n swipeAnimationInner,\n )\n } else {\n if (isSwipeRight) {\n setTransform(-actionAreaSizeMTRef.current)\n } else {\n setTransform(0)\n }\n currentAnimationFrame.current = -1\n }\n }\n swipeAnimationInner()\n }\n\n const swipeLeftToUndo = (isCanceling: boolean) => {\n 'main thread'\n // Undo\n // |-------------actionAreaSize---------------|\n // |<<<<<<<<<<<<<<<<<<<<<<<|------------------|\n // |----distanceToSwipe----|--distanceSwiped--|\n if (debugLog) {\n console.info(swipeActionId, 'swipeLeftToUndo, isCanceling', isCanceling)\n }\n const distanceToSwipe = currentTransform.current\n const distanceSwipedPercentage = 1\n - Math.abs(currentTransform.current) / actionAreaSizeMTRef.current\n // Make sure cancel process has the same duration as swipe\n const consumedSwipedTime = isCanceling\n ? 0\n : animationDuration * distanceSwipedPercentage\n const startTime = Date.now()\n clearPreviousSwipeAnimation()\n swipeAnimation(\n startTime,\n currentTransform.current,\n distanceToSwipe,\n consumedSwipedTime,\n false,\n )\n }\n\n const swipeRightToAction = (isCanceling: boolean) => {\n 'main thread'\n // Delete\n // |-------------actionAreaSize---------------|\n // |------------------|>>>>>>>>>>>>>>>>>>>>>>>|\n // |--distanceSwiped--|----distanceToSwipe----|\n if (debugLog) {\n console.info(\n swipeActionId,\n 'swipeRightToAction, isCanceling',\n isCanceling,\n )\n }\n const distanceToSwipe = -actionAreaSizeMTRef.current\n - currentTransform.current\n const distanceSwipedPercentage = Math.abs(currentTransform.current)\n / actionAreaSizeMTRef.current\n const consumedSwipedTime = isCanceling\n ? 0\n : animationDuration * distanceSwipedPercentage\n const startTime = Date.now()\n clearPreviousSwipeAnimation()\n swipeAnimation(\n startTime,\n currentTransform.current,\n distanceToSwipe,\n consumedSwipedTime,\n true,\n )\n }\n\n const swipeWithEasingInOut = () => {\n 'main thread'\n if (debugLog) {\n console.info(\n swipeActionId,\n 'swipeWithEasingInOut, lastMovingDirection',\n lastMovingDirection.current,\n )\n }\n if (lastMovingDirection.current === MovingDirection.right) {\n swipeRightToAction(false)\n } else {\n swipeLeftToUndo(false)\n }\n }\n\n const swipeCancelDueToSmallVelocity = () => {\n 'main thread'\n if (\n Math.abs(currentTransform.current)\n > actionAreaSizeMTRef.current * 0.5\n ) {\n swipeRightToAction(true)\n } else {\n swipeLeftToUndo(true)\n }\n }\n\n const sendSwipeEndJS = () => {\n if (onSwipeEnd) {\n onSwipeEnd(swipeActionId)\n }\n }\n\n const clearTouchInfo = () => {\n 'main thread'\n prevTouchPointX.current = 0\n prevTouchPointY.current = 0\n }\n\n swipeGesture.onTouchesUp((_event, _manager) => {\n 'main thread'\n if (debugLog) {\n console.info(\n 'touchEnd',\n swipeActionId,\n enableSwipe,\n prevTouchPointX.current,\n )\n }\n isFirstJudge.current = true\n // don't need to judge if enableSwipe is true or not, whenever there is a touchEnd.\n if (!prevTouchPointX.current) {\n console.error('ERROR! previous touch point is null')\n return\n }\n\n clearTouchInfo()\n\n if (debugLog) {\n console.info('scroll end velocity', currentVelocity.current)\n }\n if (isStartWithHorizontal.current) {\n if (Math.abs(currentVelocity.current) > swipeMinimumVelocity.current) {\n swipeWithEasingInOut()\n } else {\n swipeCancelDueToSmallVelocity()\n }\n runOnBackground(sendSwipeEndJS)()\n }\n isStartWithHorizontal.current = false\n })\n\n const showActionAreaMTS = (animated: boolean) => {\n 'main thread'\n if (animated) {\n swipeRightToAction(false)\n } else {\n clearPreviousSwipeAnimation()\n setTransform(-actionAreaSizeMTRef.current)\n }\n }\n\n const showActionArea = (animated: boolean) => {\n runOnMainThread(showActionAreaMTS)(animated)\n sendSwipeEndJS()\n }\n\n const closeActionAreaMTS = (animated: boolean) => {\n 'main thread'\n if (debugLog) {\n console.info('closeActionAreaMTS', swipeActionId)\n }\n clearPreviousSwipeAnimation()\n if (animated) {\n swipeLeftToUndo(false)\n } else {\n setTransform(0)\n }\n }\n\n const closeActionArea = (animated: boolean) => {\n runOnMainThread(closeActionAreaMTS)(animated)\n }\n\n useImperativeHandle(\n ref,\n () => ({\n showActionArea,\n closeActionArea,\n }),\n [showActionArea, closeActionArea],\n )\n\n return (\n <view\n style={{\n ...style,\n display: 'linear',\n linearOrientation: 'horizontal',\n width: `${totalAreaSize}px`,\n }}\n className={className}\n id={swipeActionId}\n enable-new-animator={false}\n flatten={false}\n main-thread:gesture={swipeGesture}\n main-thread:binduiappear={() => {\n 'main thread'\n setTransform(currentTransform.current)\n }}\n ios-enable-simultaneous-touch={iosEnableSimultaneousTouch}\n >\n <view\n id={`${swipeActionId}-displayArea`}\n style={{ height: '100%' }}\n main-thread:binduiappear={() => {\n 'main thread'\n setTransform(currentTransform.current)\n }}\n binduiappear={() => {\n lynx\n .createSelectorQuery()\n .select(`#${swipeActionId}-displayArea`)\n .invoke({\n method: 'boundingClientRect',\n success: (res: unknown) => {\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n setDisplayAreaSize(res.width)\n },\n })\n .exec()\n lynx\n .createSelectorQuery()\n .select(`#${swipeActionId}-actionArea`)\n .invoke({\n method: 'boundingClientRect',\n success: (res: unknown) => {\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n setActionAreaSize(res.width)\n },\n })\n .exec()\n }}\n main-thread:binduidisappear={() => {\n 'main thread'\n setTransformProperty(0)\n clearTouchInfo()\n clearPreviousSwipeAnimation()\n currentTransform.current = 0\n transformStartPosition.current = 0\n }}\n >\n {displayArea}\n </view>\n <view\n id={`${swipeActionId}-actionArea`}\n style={{ height: '100%' }}\n main-thread:bindtap={() => {\n 'main thread'\n setTransform(0)\n runOnBackground(onAction)(swipeActionId)\n }}\n >\n {actionArea}\n </view>\n </view>\n )\n}\n"],"names":["SwipeAction","memo","forwardRef","SwipeActionImpl","props","ref","enableSwipe","swipeActionId","style","className","displayArea","actionArea","estimatedActionAreaSize","onAction","noop","onSwipeStart","onSwipeEnd","debugLog","iosEnableSimultaneousTouch","sampleCurveX","tx","a","b","c","sampleCurveY","ty","solveCurveX","x","ax","bx","cx","epsilon","t2","x2","d2","i","Math","t0","t1","cubicBezier","t","p1x","p1y","p2x","p2y","cy","by","ay","animationDuration","transformEllison","swipeMinimumVelocity","useMainThreadRef","prevTouchPointX","prevTouchPointY","displayAreaSize","setDisplayAreaSize","useState","lastMovingDirection","currentTransform","lastTouchMoveGestureEvent","transformInTouchStart","transformStartPosition","currentVelocity","isFirstJudge","isStartWithHorizontal","currentAnimationFrame","swipeGesture","useGesture","NativeGesture","calculateVelocityGesture","event","deltaTime","deltaX","velocity","actionAreaSize","setActionAreaSizeInner","actionAreaSizeMTRef","totalAreaSize","clearPreviousSwipeAnimation","cancelAnimationFrame","setActionAreaSize","value","runOnMainThread","areaSize","setTransformProperty","selectorMT","setTransform","delta","console","isHorizontalTouchMoveGesture","deltaY","manager","runOnBackground","currentTouchPointX","currentTouchPointY","easingInOut","swipeAnimation","startTime","startSwipePoint","distanceToSwipe","consumedSwipedTime","isSwipeRight","swipeAnimationInner","currentTime","Date","timePercentage","percentage","requestAnimationFrame","swipeLeftToUndo","isCanceling","distanceSwipedPercentage","swipeRightToAction","swipeWithEasingInOut","swipeCancelDueToSmallVelocity","sendSwipeEndJS","clearTouchInfo","_event","_manager","showActionAreaMTS","animated","showActionArea","closeActionAreaMTS","closeActionArea","useImperativeHandle","view","lynx","res"],"mappings":";;;AAyBO,MAAMA,cAAcC,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AI;IACT,GACA,YAAY,iBAAiB;QAC3B;QACA1C,qBAAqB;QACrB+B;QACArC;QACApB,iBAAiB,OAAO,GAAG;QAC3BG,uBAAuB,OAAO,GAAG;IACnC,GACD;QACC,CAACnD,YAAY;MACf,EAAEkH,KAAK;MACP,CAACA,KACC,IAAI,GAAGrH,cAAc,WAAW,CAAC,EACjC,OAAO;QAAE,QAAQ;IAAO,GACxB,YAAY,SAAS;QACnB;QACA+E,aAAa;QACbM,gBAAgB/E,UAAUN;IAC5B,GACD;QACC,CAACI,WAAW;MACd,EAAEiH,KAAK;IACT,EAAEA;AAEN"}
@@ -1,6 +1,5 @@
1
1
  import type { ForwardedRef, ReactElement } from '@lynx-js/react';
2
2
  import type { ComponentBasicProps } from '@lynx-js/lynx-ui-common';
3
- export type SwipeAction = (props: SwipeActionProps) => ReactElement;
4
3
  export interface SwipeActionProps extends ComponentBasicProps {
5
4
  ref?: ForwardedRef<SwipeActionRef>;
6
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.docs.d.ts","sourceRoot":"","sources":["../../src/types/index.docs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAEhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAElE,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,YAAY,CAAA;AAEnE,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB;IAC3D,GAAG,CAAC,EAAE,YAAY,CAAC,cAAc,CAAC,CAAA;IAClC;;;;;;OAMG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB;;;;;OAKG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;;;;OAKG;IACH,WAAW,EAAE,YAAY,CAAA;IACzB;;;;;OAKG;IACH,UAAU,EAAE,YAAY,CAAA;IACxB;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAA;IA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AE,OAAO,CAAA;IACpC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC;AAED,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,cAAc,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;IAC3C;;;;;OAKG;IACH,eAAe,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;CAC7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/lynx-ui-swipe-action",
3
- "version": "3.139.0",
3
+ "version": "3.140.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lynx-family/lynx-ui.git",
package/src/index.tsx CHANGED
@@ -2,7 +2,7 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
 
5
- import type { ForwardedRef } from '@lynx-js/react'
5
+ import type { ForwardedRef, ReactElement } from '@lynx-js/react'
6
6
  import {
7
7
  forwardRef,
8
8
  memo,
@@ -17,15 +17,15 @@ import { NativeGesture, useGesture } from '@lynx-js/gesture-runtime'
17
17
  import type { NativeGestureChangeEvent } from '@lynx-js/gesture-runtime'
18
18
  import { noop, selectorMT } from '@lynx-js/lynx-ui-common'
19
19
 
20
- import type {
21
- SwipeActionProps,
22
- SwipeActionRef,
23
- SwipeAction as swipeActionType,
24
- } from './types/index'
20
+ import type { SwipeActionProps, SwipeActionRef } from './types/index'
25
21
 
26
22
  export type { SwipeActionProps, SwipeActionRef }
27
23
 
28
- export const SwipeAction = memo(forwardRef(SwipeActionImpl)) as swipeActionType
24
+ type SwipeActionComponent = (props: SwipeActionProps) => ReactElement
25
+
26
+ export const SwipeAction = memo(
27
+ forwardRef(SwipeActionImpl),
28
+ ) as SwipeActionComponent
29
29
 
30
30
  function SwipeActionImpl(
31
31
  props: SwipeActionProps,
@@ -115,7 +115,7 @@ function SwipeActionImpl(
115
115
 
116
116
  return sampleCurveY(solveCurveX(t, ax, bx, cx), ay, by, cy)
117
117
  }
118
- enum movingDirection {
118
+ enum MovingDirection {
119
119
  left = 0,
120
120
  right = 1,
121
121
  }
@@ -126,7 +126,7 @@ function SwipeActionImpl(
126
126
  const prevTouchPointY = useMainThreadRef<number>(0)
127
127
  const [displayAreaSize, setDisplayAreaSize] = useState(0)
128
128
 
129
- const lastMovingDirection = useMainThreadRef<movingDirection>(0)
129
+ const lastMovingDirection = useMainThreadRef<MovingDirection>(0)
130
130
 
131
131
  const currentTransform = useMainThreadRef<number>(0)
132
132
  const lastTouchMoveGestureEvent = useMainThreadRef<NativeGestureChangeEvent>()
@@ -283,8 +283,8 @@ function SwipeActionImpl(
283
283
  calculateVelocityGesture(event)
284
284
  // Record last gesture to determine swipe direction is right to delete or left to undo
285
285
  lastMovingDirection.current = deltaX > 0
286
- ? movingDirection.left
287
- : movingDirection.right
286
+ ? MovingDirection.left
287
+ : MovingDirection.right
288
288
 
289
289
  transformStartPosition.current = currentTransform.current ?? 0
290
290
 
@@ -408,7 +408,7 @@ function SwipeActionImpl(
408
408
  lastMovingDirection.current,
409
409
  )
410
410
  }
411
- if (lastMovingDirection.current === movingDirection.right) {
411
+ if (lastMovingDirection.current === MovingDirection.right) {
412
412
  swipeRightToAction(false)
413
413
  } else {
414
414
  swipeLeftToUndo(false)
@@ -6,8 +6,6 @@ import type { ForwardedRef, ReactElement } from '@lynx-js/react'
6
6
 
7
7
  import type { ComponentBasicProps } from '@lynx-js/lynx-ui-common'
8
8
 
9
- export type SwipeAction = (props: SwipeActionProps) => ReactElement
10
-
11
9
  export interface SwipeActionProps extends ComponentBasicProps {
12
10
  ref?: ForwardedRef<SwipeActionRef>
13
11
  /**