@chayns-components/swipeable-wrapper 5.0.0-beta.998 → 5.0.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.
Files changed (26) hide show
  1. package/lib/cjs/components/swipeable-wrapper/SwipeableWrapper.js +40 -27
  2. package/lib/cjs/components/swipeable-wrapper/SwipeableWrapper.js.map +1 -1
  3. package/lib/cjs/components/swipeable-wrapper/SwipeableWrapper.styles.js +2 -2
  4. package/lib/cjs/components/swipeable-wrapper/SwipeableWrapper.styles.js.map +1 -1
  5. package/lib/cjs/components/swipeable-wrapper/swipeable-action/SwipeableAction.js +12 -13
  6. package/lib/cjs/components/swipeable-wrapper/swipeable-action/SwipeableAction.js.map +1 -1
  7. package/lib/cjs/components/swipeable-wrapper/swipeable-action/SwipeableAction.styles.js +3 -4
  8. package/lib/cjs/components/swipeable-wrapper/swipeable-action/SwipeableAction.styles.js.map +1 -1
  9. package/lib/cjs/index.js.map +1 -1
  10. package/lib/esm/components/swipeable-wrapper/SwipeableWrapper.js +26 -13
  11. package/lib/esm/components/swipeable-wrapper/SwipeableWrapper.js.map +1 -1
  12. package/lib/esm/components/swipeable-wrapper/SwipeableWrapper.styles.js +1 -1
  13. package/lib/esm/components/swipeable-wrapper/SwipeableWrapper.styles.js.map +1 -1
  14. package/lib/esm/components/swipeable-wrapper/swipeable-action/SwipeableAction.js +12 -14
  15. package/lib/esm/components/swipeable-wrapper/swipeable-action/SwipeableAction.js.map +1 -1
  16. package/lib/esm/components/swipeable-wrapper/swipeable-action/SwipeableAction.styles.js +13 -23
  17. package/lib/esm/components/swipeable-wrapper/swipeable-action/SwipeableAction.styles.js.map +1 -1
  18. package/lib/esm/index.js.map +1 -1
  19. package/lib/esm/utils/threshold.js +5 -8
  20. package/lib/esm/utils/threshold.js.map +1 -1
  21. package/lib/types/components/swipeable-wrapper/SwipeableWrapper.d.ts +12 -0
  22. package/lib/types/components/swipeable-wrapper/SwipeableWrapper.styles.d.ts +2 -265
  23. package/lib/types/components/swipeable-wrapper/swipeable-action/SwipeableAction.d.ts +1 -1
  24. package/lib/types/components/swipeable-wrapper/swipeable-action/SwipeableAction.styles.d.ts +2 -263
  25. package/lib/types/index.d.ts +1 -0
  26. package/package.json +20 -18
@@ -1 +1 @@
1
- {"version":3,"file":"SwipeableWrapper.js","names":["vibrate","animate","useMotionValue","React","useCallback","useEffect","useMemo","useRef","useState","calcThreshold","SwipeableAction","SWIPEABLE_ACTION_WIDTH","StyledMotionSwipeableWrapper","StyledSwipeableWrapperContent","SwipeableWrapper","_ref","children","leftActions","rightActions","shouldUseOpacityAnimation","leftThreshold","setLeftThreshold","actionCount","length","direction","width","window","innerWidth","rightThreshold","setRightThreshold","swipeableWrapperRef","listItemXOffset","close","open","current","parentElement","offsetWidth","closeCallback","event","eventTarget","target","contains","document","addEventListener","removeEventListener","onChange","newValue","previous","getPrevious","hasCrossedLeftThreshold","hasCrossedRightThreshold","iOSFeedbackVibration","pattern","handlePan","_","info","currentXOffset","get","dampingFactor","offset","x","delta","Math","abs","set","handlePanEnd","action","state","leftActionElements","Array","from","reverse","map","item","index","createElement","activationThreshold","key","position","totalActionCount","rightActionElements","onPan","onPanEnd","ref","style","displayName"],"sources":["../../../../src/components/swipeable-wrapper/SwipeableWrapper.tsx"],"sourcesContent":["import { vibrate } from 'chayns-api';\nimport { animate, PanInfo, useMotionValue } from 'framer-motion';\nimport React, {\n CSSProperties,\n FC,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { calcThreshold } from '../../utils/threshold';\nimport SwipeableAction, { SWIPEABLE_ACTION_WIDTH } from './swipeable-action/SwipeableAction';\nimport {\n StyledMotionSwipeableWrapper,\n StyledSwipeableWrapperContent,\n} from './SwipeableWrapper.styles';\n\nexport type SwipeableActionItem = {\n action: VoidFunction;\n backgroundColor: CSSProperties['backgroundColor'];\n color: CSSProperties['color'];\n text?: ReactNode;\n icon: ReactNode;\n key: string;\n};\n\nexport type SwipeableWrapperProps = {\n /**\n * The content of the Swipeable item.\n */\n children: ReactNode;\n /**\n * The left-side actions, ordered from the left to the right.\n */\n leftActions?: SwipeableActionItem[];\n /**\n * The right-side actions, ordered from left to the right.\n */\n rightActions?: SwipeableActionItem[];\n /**\n * Whether the opacity should be animated when swiping in the actions.\n */\n shouldUseOpacityAnimation?: boolean;\n};\n\nconst SwipeableWrapper: FC<SwipeableWrapperProps> = ({\n children,\n leftActions = [],\n rightActions = [],\n shouldUseOpacityAnimation,\n}) => {\n const [leftThreshold, setLeftThreshold] = useState(\n calcThreshold({\n actionCount: leftActions.length,\n direction: 'left',\n width: window.innerWidth,\n }),\n );\n\n const [rightThreshold, setRightThreshold] = useState(\n calcThreshold({\n actionCount: rightActions.length,\n direction: 'right',\n width: window.innerWidth,\n }),\n );\n\n const swipeableWrapperRef = useRef<HTMLDivElement | null>(null);\n\n const listItemXOffset = useMotionValue(0);\n\n const close = useCallback(() => {\n void animate(listItemXOffset, 0);\n }, [listItemXOffset]);\n\n const open = useCallback(\n (direction: 'left' | 'right') => {\n switch (direction) {\n case 'left':\n void animate(listItemXOffset, SWIPEABLE_ACTION_WIDTH * leftActions.length);\n break;\n case 'right':\n void animate(listItemXOffset, -SWIPEABLE_ACTION_WIDTH * rightActions.length);\n break;\n default:\n break;\n }\n },\n [leftActions.length, listItemXOffset, rightActions.length],\n );\n\n useEffect(() => {\n const width = swipeableWrapperRef.current?.parentElement?.offsetWidth;\n\n // This check was deliberately chosen because a width of 0 is also not permitted.\n if (width) {\n setLeftThreshold(\n calcThreshold({\n actionCount: leftActions.length,\n direction: 'left',\n width,\n }),\n );\n\n setRightThreshold(\n calcThreshold({\n actionCount: rightActions.length,\n direction: 'right',\n width,\n }),\n );\n }\n }, [leftActions.length, rightActions.length]);\n\n // Close an opened menu when anything outside it is tapped\n useEffect(() => {\n function closeCallback(event: MouseEvent | TouchEvent) {\n const eventTarget = event.target;\n\n // @ts-expect-error: Pretty sure that the event target is always a Node.\n if (eventTarget && !swipeableWrapperRef.current?.contains(eventTarget)) {\n close();\n }\n }\n\n document.addEventListener('mousedown', closeCallback);\n document.addEventListener('touchstart', closeCallback);\n\n return () => {\n document.removeEventListener('mousedown', closeCallback);\n document.removeEventListener('touchstart', closeCallback);\n };\n }, [close]);\n\n // Vibrate when the threshold is passed\n useEffect(\n () =>\n listItemXOffset.onChange((newValue: number) => {\n const previous = listItemXOffset.getPrevious();\n\n if (!previous) {\n return;\n }\n\n const hasCrossedLeftThreshold =\n (previous < leftThreshold && newValue >= leftThreshold) ||\n (previous > leftThreshold && newValue <= leftThreshold);\n\n const hasCrossedRightThreshold =\n (previous < rightThreshold && newValue >= rightThreshold) ||\n (previous > rightThreshold && newValue <= rightThreshold);\n\n if (hasCrossedLeftThreshold || hasCrossedRightThreshold) {\n void vibrate({ iOSFeedbackVibration: 6, pattern: [150] });\n }\n }),\n [leftThreshold, listItemXOffset, rightThreshold],\n );\n\n const handlePan = useCallback(\n (_: MouseEvent | TouchEvent | PointerEvent, info: PanInfo) => {\n const currentXOffset = listItemXOffset.get();\n\n const dampingFactor =\n (info.offset.x > 0 && leftActions.length > 0) ||\n (info.offset.x < 0 && rightActions.length > 0) ||\n (currentXOffset > 0 && info.delta.x < 0) ||\n (currentXOffset < 0 && info.delta.x > 0)\n ? 1\n : 0.75 / (Math.abs(info.offset.x) / 9);\n\n if (Math.abs(info.offset.x) > 30 || currentXOffset > 0) {\n listItemXOffset.set(currentXOffset + info.delta.x * dampingFactor);\n }\n },\n [leftActions.length, listItemXOffset, rightActions.length],\n );\n\n const handlePanEnd = useCallback(() => {\n const offset = listItemXOffset.get();\n\n if (offset > leftThreshold) {\n leftActions[0]?.action();\n close();\n } else if (offset < rightThreshold) {\n rightActions[rightActions.length - 1]?.action();\n close();\n } else {\n let state: 'left-open' | 'right-open' | 'closed';\n\n if (offset > 2) {\n state = 'left-open';\n } else if (offset < -2) {\n state = 'right-open';\n } else {\n state = 'closed';\n }\n\n // eslint-disable-next-line default-case\n switch (state) {\n case 'left-open':\n if (offset < SWIPEABLE_ACTION_WIDTH) {\n close();\n } else {\n open('left');\n }\n break;\n case 'right-open':\n if (offset > -SWIPEABLE_ACTION_WIDTH) {\n close();\n } else {\n open('right');\n }\n break;\n case 'closed':\n if (offset > SWIPEABLE_ACTION_WIDTH) {\n open('left');\n } else if (offset < -SWIPEABLE_ACTION_WIDTH) {\n open('right');\n } else {\n close();\n }\n }\n }\n }, [close, leftActions, leftThreshold, listItemXOffset, open, rightActions, rightThreshold]);\n\n const leftActionElements = useMemo(\n () =>\n Array.from(leftActions)\n .reverse()\n .map((item, index) => (\n <SwipeableAction\n activationThreshold={leftThreshold}\n close={close}\n index={index}\n item={item}\n key={item.key}\n listItemXOffset={listItemXOffset}\n position=\"left\"\n shouldUseOpacityAnimation={shouldUseOpacityAnimation}\n totalActionCount={leftActions.length}\n />\n )),\n [close, leftActions, leftThreshold, listItemXOffset, shouldUseOpacityAnimation],\n );\n\n const rightActionElements = useMemo(\n () =>\n rightActions.map((item, index) => (\n <SwipeableAction\n activationThreshold={rightThreshold}\n close={close}\n index={index}\n item={item}\n key={item.key}\n listItemXOffset={listItemXOffset}\n position=\"right\"\n shouldUseOpacityAnimation={shouldUseOpacityAnimation}\n totalActionCount={rightActions.length}\n />\n )),\n [rightActions, rightThreshold, close, listItemXOffset, shouldUseOpacityAnimation],\n );\n\n return (\n <StyledMotionSwipeableWrapper\n onPan={handlePan}\n onPanEnd={handlePanEnd}\n ref={swipeableWrapperRef}\n style={{ x: listItemXOffset }}\n >\n {leftActionElements}\n <StyledSwipeableWrapperContent>{children}</StyledSwipeableWrapperContent>\n {rightActionElements}\n </StyledMotionSwipeableWrapper>\n );\n};\n\nSwipeableWrapper.displayName = 'SwipeableWrapper';\n\nexport default SwipeableWrapper;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AACpC,SAASC,OAAO,EAAWC,cAAc,QAAQ,eAAe;AAChE,OAAOC,KAAK,IAIRC,WAAW,EACX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I,EAAEA,IAAK;IACXI,GAAG,EAAEJ,IAAI,CAACI,GAAI;IACd9C,eAAe,EAAEA,eAAgB;IACjC+C,QAAQ,EAAC,OAAO;IAChB3D,yBAAyB,EAAEA,yBAA0B;IACrD4D,gBAAgB,EAAE7D,YAAY,CAACK;EAAO,CACzC,CACJ,CAAC,EACN,CAACL,YAAY,EAAEU,cAAc,EAAEI,KAAK,EAAED,eAAe,EAAEZ,yBAAyB,CACpF,CAAC;EAED,oBACIhB,KAAA,CAAAwE,aAAA,CAAC/D,4BAA4B;IACzBqE,KAAK,EAAE5B,SAAU;IACjB6B,QAAQ,EAAEjB,YAAa;IACvBkB,GAAG,EAAErD,mBAAoB;IACzBsD,KAAK,EAAE;MAAExB,CAAC,EAAE7B;IAAgB;EAAE,GAE7BqC,kBAAkB,eACnBjE,KAAA,CAAAwE,aAAA,CAAC9D,6BAA6B,QAAEG,QAAwC,CAAC,EACxEgE,mBACyB,CAAC;AAEvC,CAAC;AAEDlE,gBAAgB,CAACuE,WAAW,GAAG,kBAAkB;AAEjD,eAAevE,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"SwipeableWrapper.js","names":["vibrate","animate","useMotionValue","React","useCallback","useEffect","useMemo","useRef","useState","calcThreshold","SwipeableAction","SWIPEABLE_ACTION_WIDTH","StyledMotionSwipeableWrapper","StyledSwipeableWrapperContent","SwipeableWrapper","children","leftActions","rightActions","shouldUseOpacityAnimation","isDisabled","onSwipeEnd","onSwipeStart","leftThreshold","setLeftThreshold","actionCount","length","direction","width","window","innerWidth","rightThreshold","setRightThreshold","swipeableWrapperRef","isSwipingRef","listItemXOffset","close","open","current","parentElement","offsetWidth","closeCallback","event","eventTarget","target","contains","document","addEventListener","removeEventListener","on","newValue","previous","getPrevious","hasCrossedLeftThreshold","hasCrossedRightThreshold","iOSFeedbackVibration","pattern","handlePan","_","info","currentXOffset","get","dampingFactor","offset","x","delta","Math","abs","set","handlePanEnd","action","state","leftActionElements","Array","from","reverse","map","item","index","createElement","activationThreshold","key","position","totalActionCount","rightActionElements","onPan","undefined","onPanEnd","ref","style","displayName"],"sources":["../../../../src/components/swipeable-wrapper/SwipeableWrapper.tsx"],"sourcesContent":["import { vibrate } from 'chayns-api';\nimport { animate, PanInfo, useMotionValue } from 'motion/react';\nimport React, {\n CSSProperties,\n FC,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { calcThreshold } from '../../utils/threshold';\nimport SwipeableAction, { SWIPEABLE_ACTION_WIDTH } from './swipeable-action/SwipeableAction';\nimport {\n StyledMotionSwipeableWrapper,\n StyledSwipeableWrapperContent,\n} from './SwipeableWrapper.styles';\n\nexport type SwipeableActionItem = {\n action: VoidFunction;\n backgroundColor: CSSProperties['backgroundColor'];\n color: CSSProperties['color'];\n text?: ReactNode;\n icon: ReactNode;\n key: string;\n};\n\nexport type SwipeableWrapperProps = {\n /**\n * The content of the Swipeable item.\n */\n children: ReactNode;\n /**\n * The left-side actions, ordered from the left to the right.\n */\n leftActions?: SwipeableActionItem[];\n /**\n * The right-side actions, ordered from left to the right.\n */\n rightActions?: SwipeableActionItem[];\n /**\n * Whether the opacity should be animated when swiping in the actions.\n */\n shouldUseOpacityAnimation?: boolean;\n /**\n * Whether the swipeable functionality is disabled\n */\n isDisabled?: boolean;\n /**\n * Callback to be executed when the swiping is started.\n */\n onSwipeStart?: VoidFunction;\n /**\n * Callback to be executed when the swiping is ended.\n */\n onSwipeEnd?: VoidFunction;\n};\n\nconst SwipeableWrapper: FC<SwipeableWrapperProps> = ({\n children,\n leftActions = [],\n rightActions = [],\n shouldUseOpacityAnimation,\n isDisabled = false,\n onSwipeEnd,\n onSwipeStart,\n}) => {\n const [leftThreshold, setLeftThreshold] = useState(\n calcThreshold({\n actionCount: leftActions.length,\n direction: 'left',\n width: window.innerWidth,\n }),\n );\n\n const [rightThreshold, setRightThreshold] = useState(\n calcThreshold({\n actionCount: rightActions.length,\n direction: 'right',\n width: window.innerWidth,\n }),\n );\n\n const swipeableWrapperRef = useRef<HTMLDivElement | null>(null);\n const isSwipingRef = useRef(false);\n\n const listItemXOffset = useMotionValue(0);\n\n const close = useCallback(() => {\n void animate(listItemXOffset, 0);\n }, [listItemXOffset]);\n\n const open = useCallback(\n (direction: 'left' | 'right') => {\n switch (direction) {\n case 'left':\n void animate(listItemXOffset, SWIPEABLE_ACTION_WIDTH * leftActions.length);\n break;\n case 'right':\n void animate(listItemXOffset, -SWIPEABLE_ACTION_WIDTH * rightActions.length);\n break;\n default:\n break;\n }\n },\n [leftActions.length, listItemXOffset, rightActions.length],\n );\n\n useEffect(() => {\n const width = swipeableWrapperRef.current?.parentElement?.offsetWidth;\n\n // This check was deliberately chosen because a width of 0 is also not permitted.\n if (width) {\n setLeftThreshold(\n calcThreshold({\n actionCount: leftActions.length,\n direction: 'left',\n width,\n }),\n );\n\n setRightThreshold(\n calcThreshold({\n actionCount: rightActions.length,\n direction: 'right',\n width,\n }),\n );\n }\n }, [leftActions.length, rightActions.length]);\n\n // Close an opened menu when anything outside it is tapped\n useEffect(() => {\n function closeCallback(event: MouseEvent | TouchEvent) {\n const eventTarget = event.target;\n\n // @ts-expect-error: Pretty sure that the event target is always a Node.\n if (eventTarget && !swipeableWrapperRef.current?.contains(eventTarget)) {\n close();\n }\n }\n\n document.addEventListener('mousedown', closeCallback);\n document.addEventListener('touchstart', closeCallback);\n\n return () => {\n document.removeEventListener('mousedown', closeCallback);\n document.removeEventListener('touchstart', closeCallback);\n };\n }, [close]);\n\n // Vibrate when the threshold is passed\n useEffect(\n () =>\n listItemXOffset.on('change', (newValue: number) => {\n const previous = listItemXOffset.getPrevious();\n\n if (!previous) {\n return;\n }\n\n const hasCrossedLeftThreshold =\n (previous < leftThreshold && newValue >= leftThreshold) ||\n (previous > leftThreshold && newValue <= leftThreshold);\n\n const hasCrossedRightThreshold =\n (previous < rightThreshold && newValue >= rightThreshold) ||\n (previous > rightThreshold && newValue <= rightThreshold);\n\n if (hasCrossedLeftThreshold || hasCrossedRightThreshold) {\n void vibrate({ iOSFeedbackVibration: 6, pattern: [150] });\n }\n }),\n [leftThreshold, listItemXOffset, rightThreshold],\n );\n\n const handlePan = useCallback(\n (_: MouseEvent | TouchEvent | PointerEvent, info: PanInfo) => {\n if (!isSwipingRef.current) {\n isSwipingRef.current = true;\n\n if (typeof onSwipeStart === 'function') {\n onSwipeStart();\n }\n }\n\n const currentXOffset = listItemXOffset.get();\n\n const dampingFactor =\n (info.offset.x > 0 && leftActions.length > 0) ||\n (info.offset.x < 0 && rightActions.length > 0) ||\n (currentXOffset > 0 && info.delta.x < 0) ||\n (currentXOffset < 0 && info.delta.x > 0)\n ? 1\n : 0.75 / (Math.abs(info.offset.x) / 9);\n\n if (Math.abs(info.offset.x) > 30 || currentXOffset > 0) {\n listItemXOffset.set(currentXOffset + info.delta.x * dampingFactor);\n }\n },\n [leftActions.length, listItemXOffset, onSwipeStart, rightActions.length],\n );\n\n const handlePanEnd = useCallback(() => {\n if (typeof onSwipeEnd === 'function') {\n onSwipeEnd();\n }\n\n isSwipingRef.current = false;\n\n const offset = listItemXOffset.get();\n\n if (offset > leftThreshold) {\n leftActions[0]?.action();\n close();\n } else if (offset < rightThreshold) {\n rightActions[rightActions.length - 1]?.action();\n close();\n } else {\n let state: 'left-open' | 'right-open' | 'closed';\n\n if (offset > 2) {\n state = 'left-open';\n } else if (offset < -2) {\n state = 'right-open';\n } else {\n state = 'closed';\n }\n\n // eslint-disable-next-line default-case\n switch (state) {\n case 'left-open':\n if (offset < SWIPEABLE_ACTION_WIDTH) {\n close();\n } else {\n open('left');\n }\n break;\n case 'right-open':\n if (offset > -SWIPEABLE_ACTION_WIDTH) {\n close();\n } else {\n open('right');\n }\n break;\n case 'closed':\n if (offset > SWIPEABLE_ACTION_WIDTH) {\n open('left');\n } else if (offset < -SWIPEABLE_ACTION_WIDTH) {\n open('right');\n } else {\n close();\n }\n }\n }\n }, [\n close,\n leftActions,\n leftThreshold,\n listItemXOffset,\n onSwipeEnd,\n open,\n rightActions,\n rightThreshold,\n ]);\n\n const leftActionElements = useMemo(\n () =>\n Array.from(leftActions)\n .reverse()\n .map((item, index) => (\n <SwipeableAction\n activationThreshold={leftThreshold}\n close={close}\n index={index}\n item={item}\n key={item.key}\n listItemXOffset={listItemXOffset}\n position=\"left\"\n shouldUseOpacityAnimation={shouldUseOpacityAnimation}\n totalActionCount={leftActions.length}\n />\n )),\n [close, leftActions, leftThreshold, listItemXOffset, shouldUseOpacityAnimation],\n );\n\n const rightActionElements = useMemo(\n () =>\n rightActions.map((item, index) => (\n <SwipeableAction\n activationThreshold={rightThreshold}\n close={close}\n index={index}\n item={item}\n key={item.key}\n listItemXOffset={listItemXOffset}\n position=\"right\"\n shouldUseOpacityAnimation={shouldUseOpacityAnimation}\n totalActionCount={rightActions.length}\n />\n )),\n [rightActions, rightThreshold, close, listItemXOffset, shouldUseOpacityAnimation],\n );\n\n return (\n <StyledMotionSwipeableWrapper\n onPan={isDisabled ? undefined : handlePan}\n onPanEnd={isDisabled ? undefined : handlePanEnd}\n ref={swipeableWrapperRef}\n style={{ x: listItemXOffset }}\n >\n {leftActionElements}\n <StyledSwipeableWrapperContent>{children}</StyledSwipeableWrapperContent>\n {rightActionElements}\n </StyledMotionSwipeableWrapper>\n );\n};\n\nSwipeableWrapper.displayName = 'SwipeableWrapper';\n\nexport default SwipeableWrapper;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AACpC,SAASC,OAAO,EAAWC,cAAc,QAAQ,cAAc;AAC/D,OAAOC,KAAK,IAIRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,aAAa,QAAQ,uBAAuB;AACrD,OAAOC,eAAe,IAAIC,sBAAsB,QAAQ,oCAAoC;AAC5F,SACIC,4BAA4B,EAC5BC,6BAA6B,QAC1B,2BAA2B;AA0ClC,MAAMC,gBAA2C,GAAGA,CAAC;EACjDC,QAAQ;EACRC,WAAW,GAAG,E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,CAAA2E,aAAA,CAACpE,eAAe;IACZqE,mBAAmB,EAAEjD,cAAe;IACpCK,KAAK,EAAEA,KAAM;IACb0C,KAAK,EAAEA,KAAM;IACbD,IAAI,EAAEA,IAAK;IACXI,GAAG,EAAEJ,IAAI,CAACI,GAAI;IACd9C,eAAe,EAAEA,eAAgB;IACjC+C,QAAQ,EAAC,OAAO;IAChB/D,yBAAyB,EAAEA,yBAA0B;IACrDgE,gBAAgB,EAAEjE,YAAY,CAACQ;EAAO,CACzC,CACJ,CAAC,EACN,CAACR,YAAY,EAAEa,cAAc,EAAEK,KAAK,EAAED,eAAe,EAAEhB,yBAAyB,CACpF,CAAC;EAED,oBACIf,KAAA,CAAA2E,aAAA,CAAClE,4BAA4B;IACzBwE,KAAK,EAAEjE,UAAU,GAAGkE,SAAS,GAAG7B,SAAU;IAC1C8B,QAAQ,EAAEnE,UAAU,GAAGkE,SAAS,GAAGjB,YAAa;IAChDmB,GAAG,EAAEvD,mBAAoB;IACzBwD,KAAK,EAAE;MAAEzB,CAAC,EAAE7B;IAAgB;EAAE,GAE7BqC,kBAAkB,eACnBpE,KAAA,CAAA2E,aAAA,CAACjE,6BAA6B,QAAEE,QAAwC,CAAC,EACxEoE,mBACyB,CAAC;AAEvC,CAAC;AAEDrE,gBAAgB,CAAC2E,WAAW,GAAG,kBAAkB;AAEjD,eAAe3E,gBAAgB","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { motion } from 'framer-motion';
1
+ import { motion } from 'motion/react';
2
2
  import styled from 'styled-components';
3
3
  export const StyledMotionSwipeableWrapper = styled(motion.div)`
4
4
  position: relative;
@@ -1 +1 @@
1
- {"version":3,"file":"SwipeableWrapper.styles.js","names":["motion","styled","StyledMotionSwipeableWrapper","div","StyledSwipeableWrapperContent"],"sources":["../../../../src/components/swipeable-wrapper/SwipeableWrapper.styles.ts"],"sourcesContent":["import type { FramerMotionBugFix } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\nimport styled from 'styled-components';\n\nexport const StyledMotionSwipeableWrapper = styled(motion.div)<FramerMotionBugFix>`\n position: relative;\n touch-action: pan-y;\n user-select: none;\n`;\n\nexport const StyledSwipeableWrapperContent = styled.div`\n width: 100%;\n`;\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,4BAA4B,GAAGD,MAAM,CAACD,MAAM,CAACG,GAAG,CAAqB;AAClF;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,6BAA6B,GAAGH,MAAM,CAACE,GAAG;AACvD;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SwipeableWrapper.styles.js","names":["motion","styled","StyledMotionSwipeableWrapper","div","StyledSwipeableWrapperContent"],"sources":["../../../../src/components/swipeable-wrapper/SwipeableWrapper.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled from 'styled-components';\n\nexport const StyledMotionSwipeableWrapper = styled(motion.div)`\n position: relative;\n touch-action: pan-y;\n user-select: none;\n`;\n\nexport const StyledSwipeableWrapperContent = styled.div`\n width: 100%;\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,cAAc;AACrC,OAAOC,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,4BAA4B,GAAGD,MAAM,CAACD,MAAM,CAACG,GAAG,CAAC;AAC9D;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,6BAA6B,GAAGH,MAAM,CAACE,GAAG;AACvD;AACA,CAAC","ignoreList":[]}
@@ -1,18 +1,17 @@
1
- import { useMotionValueEvent, useSpring, useTransform } from 'framer-motion';
1
+ import { useMotionValueEvent, useSpring, useTransform } from 'motion/react';
2
2
  import React, { useEffect } from 'react';
3
3
  import { StyledMotionSwipeableAction, StyledSwipeableActionButton } from './SwipeableAction.styles';
4
4
  export const SWIPEABLE_ACTION_WIDTH = 72;
5
- const SwipeableAction = _ref => {
6
- let {
7
- activationThreshold,
8
- close,
9
- index,
10
- item,
11
- listItemXOffset,
12
- position,
13
- shouldUseOpacityAnimation,
14
- totalActionCount
15
- } = _ref;
5
+ const SwipeableAction = ({
6
+ activationThreshold,
7
+ close,
8
+ index,
9
+ item,
10
+ listItemXOffset,
11
+ position,
12
+ shouldUseOpacityAnimation,
13
+ totalActionCount
14
+ }) => {
16
15
  const [pointerEvents, setPointerEvents] = React.useState('none');
17
16
  const handleButtonClick = () => {
18
17
  item.action();
@@ -48,8 +47,7 @@ const SwipeableAction = _ref => {
48
47
  * Combines the two values above to create the correct X transform that has
49
48
  * to be applied to the action.
50
49
  */
51
- const actionX = useTransform([actionOffset, actionOverlayOffset], _ref2 => {
52
- let [x, y] = _ref2;
50
+ const actionX = useTransform([actionOffset, actionOverlayOffset], ([x, y]) => {
53
51
  if (position === 'left') {
54
52
  return Math.min((x ?? 0) + (y ?? 0), 0);
55
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SwipeableAction.js","names":["useMotionValueEvent","useSpring","useTransform","React","useEffect","StyledMotionSwipeableAction","StyledSwipeableActionButton","SWIPEABLE_ACTION_WIDTH","SwipeableAction","_ref","activationThreshold","close","index","item","listItemXOffset","position","shouldUseOpacityAnimation","totalActionCount","pointerEvents","setPointerEvents","useState","handleButtonClick","action","actionOffset","newValue","maxOffset","fractionalOffset","Math","max","min","actionOverlayOffset","bounce","actionX","_ref2","x","y","opacity","abs","value","isOuterMost","undefined","onChange","lastValue","getPrevious","set","createElement","$backgroundColor","backgroundColor","$position","style","onClick","$color","color","$width","icon","text","displayName"],"sources":["../../../../../src/components/swipeable-wrapper/swipeable-action/SwipeableAction.tsx"],"sourcesContent":["import { MotionValue, useMotionValueEvent, useSpring, useTransform } from 'framer-motion';\nimport React, { FC, useEffect } from 'react';\nimport type { SwipeableActionItem } from '../SwipeableWrapper';\nimport { StyledMotionSwipeableAction, StyledSwipeableActionButton } from './SwipeableAction.styles';\n\nexport const SWIPEABLE_ACTION_WIDTH = 72;\n\nexport type SwipeableActionProps = {\n activationThreshold: number;\n close: VoidFunction;\n index: number;\n item: SwipeableActionItem;\n listItemXOffset: MotionValue<number>;\n position: 'left' | 'right';\n shouldUseOpacityAnimation?: boolean;\n totalActionCount: number;\n};\n\nconst SwipeableAction: FC<SwipeableActionProps> = ({\n activationThreshold,\n close,\n index,\n item,\n listItemXOffset,\n position,\n shouldUseOpacityAnimation,\n totalActionCount,\n}) => {\n const [pointerEvents, setPointerEvents] = React.useState<'auto' | 'none'>('none');\n\n const handleButtonClick = () => {\n item.action();\n close();\n };\n\n /**\n * By default, the action sticks to the content of the swipeable item. This\n * makes it move outwards to reveal the inner items.\n */\n const actionOffset = useTransform(listItemXOffset, (newValue) => {\n const maxOffset = SWIPEABLE_ACTION_WIDTH * index;\n const fractionalOffset = (-newValue / totalActionCount) * index;\n\n switch (position) {\n case 'left':\n return Math.max(-maxOffset, fractionalOffset);\n case 'right':\n return Math.min(maxOffset, fractionalOffset);\n default:\n return 0;\n }\n });\n\n /**\n * Brings the item in again if past the threshold. Only relevant for\n * outermost items.\n */\n const actionOverlayOffset = useSpring(0, {\n bounce: 0,\n }) as MotionValue<number>;\n\n /**\n * Combines the two values above to create the correct X transform that has\n * to be applied to the action.\n */\n const actionX = useTransform<number, number>([actionOffset, actionOverlayOffset], ([x, y]) => {\n if (position === 'left') {\n return Math.min((x ?? 0) + (y ?? 0), 0);\n }\n\n return Math.max((x ?? 0) + (y ?? 0), 0);\n });\n\n const opacity = useTransform(listItemXOffset, (x) =>\n Math.max(0, Math.min(1, Math.abs(x) / 72)),\n );\n\n useMotionValueEvent(opacity, 'change', (value) => {\n setPointerEvents(value < 0.5 ? 'none' : 'auto');\n });\n\n // Animate to the middle after passing threshold if outermost item\n useEffect(() => {\n const isOuterMost = index === totalActionCount - 1;\n\n if (!isOuterMost) return undefined;\n\n return listItemXOffset.onChange((newValue) => {\n const lastValue = listItemXOffset.getPrevious();\n\n if (!lastValue) {\n return;\n }\n\n // eslint-disable-next-line default-case\n switch (position) {\n case 'left':\n if (newValue > activationThreshold && lastValue <= activationThreshold) {\n actionOverlayOffset.set(SWIPEABLE_ACTION_WIDTH * index);\n } else if (newValue < activationThreshold && lastValue >= activationThreshold) {\n actionOverlayOffset.set(0);\n }\n break;\n case 'right':\n if (newValue < activationThreshold && lastValue >= activationThreshold) {\n actionOverlayOffset.set(SWIPEABLE_ACTION_WIDTH * -1 * index);\n } else if (newValue > activationThreshold && lastValue <= activationThreshold) {\n actionOverlayOffset.set(0);\n }\n }\n });\n }, [\n actionOverlayOffset,\n activationThreshold,\n index,\n listItemXOffset,\n position,\n totalActionCount,\n ]);\n\n return (\n <StyledMotionSwipeableAction\n $backgroundColor={item.backgroundColor}\n $position={position}\n style={{ x: actionX, opacity: shouldUseOpacityAnimation ? opacity : 1 }}\n >\n <StyledSwipeableActionButton\n onClick={handleButtonClick}\n style={{ pointerEvents }}\n $color={item.color}\n $width={`${SWIPEABLE_ACTION_WIDTH}px`}\n >\n {item.icon}\n {item.text}\n </StyledSwipeableActionButton>\n </StyledMotionSwipeableAction>\n );\n};\n\nSwipeableAction.displayName = 'SwipeableAction';\n\nexport default SwipeableAction;\n"],"mappings":"AAAA,SAAsBA,mBAAmB,EAAEC,SAAS,EAAEC,YAAY,QAAQ,eAAe;AACzF,OAAOC,KAAK,IAAQC,SAAS,QAAQ,OAAO;AAE5C,SAASC,2BAA2B,EAAEC,2BAA2B,QAAQ,0BAA0B;AAEnG,OAAO,MAAMC,sBAAsB,GAAG,EAAE;AAaxC,MAAMC,eAAyC,GAAGC,IAAA,IAS5C;EAAA,IAT6C;IAC/CC,mBAAmB;IACnBC,KAAK;IACLC,KAAK;IACLC,IAAI;IACJC,eAAe;IACfC,QAAQ;IACRC,yBAAyB;IACzBC;EACJ,CAAC,GAAAR,IAAA;EACG,MAAM,CAACS,aAAa,EAAEC,gBAAgB,CAAC,GAAGhB,KAAK,CAACiB,QAAQ,CAAkB,MAAM,CAAC;EAEjF,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;IAC5BR,IAAI,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EACnBE,KAAK,EACLE,eAAe,EACfC,QAAQ,EACRE,gBAAgB,CACnB,CAAC;EAEF,oBACId,KAAA,CAAA0C,aAAA,CAACxC,2BAA2B;IACxByC,gBAAgB,EAAEjC,IAAI,CAACkC,eAAgB;IACvCC,SAAS,EAAEjC,QAAS;IACpBkC,KAAK,EAAE;MAAEf,CAAC,EAAEF,OAAO;MAAEI,OAAO,EAAEpB,yBAAyB,GAAGoB,OAAO,GAAG;IAAE;EAAE,gBAExEjC,KAAA,CAAA0C,aAAA,CAACvC,2BAA2B;IACxB4C,OAAO,EAAE7B,iBAAkB;IAC3B4B,KAAK,EAAE;MAAE/B;IAAc,CAAE;IACzBiC,MAAM,EAAEtC,IAAI,CAACuC,KAAM;IACnBC,MAAM,EAAE,GAAG9C,sBAAsB;EAAK,GAErCM,IAAI,CAACyC,IAAI,EACTzC,IAAI,CAAC0C,IACmB,CACJ,CAAC;AAEtC,CAAC;AAED/C,eAAe,CAACgD,WAAW,GAAG,iBAAiB;AAE/C,eAAehD,eAAe","ignoreList":[]}
1
+ {"version":3,"file":"SwipeableAction.js","names":["useMotionValueEvent","useSpring","useTransform","React","useEffect","StyledMotionSwipeableAction","StyledSwipeableActionButton","SWIPEABLE_ACTION_WIDTH","SwipeableAction","activationThreshold","close","index","item","listItemXOffset","position","shouldUseOpacityAnimation","totalActionCount","pointerEvents","setPointerEvents","useState","handleButtonClick","action","actionOffset","newValue","maxOffset","fractionalOffset","Math","max","min","actionOverlayOffset","bounce","actionX","x","y","opacity","abs","value","isOuterMost","undefined","onChange","lastValue","getPrevious","set","createElement","$backgroundColor","backgroundColor","$position","style","onClick","$color","color","$width","icon","text","displayName"],"sources":["../../../../../src/components/swipeable-wrapper/swipeable-action/SwipeableAction.tsx"],"sourcesContent":["import { MotionValue, useMotionValueEvent, useSpring, useTransform } from 'motion/react';\nimport React, { FC, useEffect } from 'react';\nimport type { SwipeableActionItem } from '../SwipeableWrapper';\nimport { StyledMotionSwipeableAction, StyledSwipeableActionButton } from './SwipeableAction.styles';\n\nexport const SWIPEABLE_ACTION_WIDTH = 72;\n\nexport type SwipeableActionProps = {\n activationThreshold: number;\n close: VoidFunction;\n index: number;\n item: SwipeableActionItem;\n listItemXOffset: MotionValue<number>;\n position: 'left' | 'right';\n shouldUseOpacityAnimation?: boolean;\n totalActionCount: number;\n};\n\nconst SwipeableAction: FC<SwipeableActionProps> = ({\n activationThreshold,\n close,\n index,\n item,\n listItemXOffset,\n position,\n shouldUseOpacityAnimation,\n totalActionCount,\n}) => {\n const [pointerEvents, setPointerEvents] = React.useState<'auto' | 'none'>('none');\n\n const handleButtonClick = () => {\n item.action();\n close();\n };\n\n /**\n * By default, the action sticks to the content of the swipeable item. This\n * makes it move outwards to reveal the inner items.\n */\n const actionOffset = useTransform(listItemXOffset, (newValue) => {\n const maxOffset = SWIPEABLE_ACTION_WIDTH * index;\n const fractionalOffset = (-newValue / totalActionCount) * index;\n\n switch (position) {\n case 'left':\n return Math.max(-maxOffset, fractionalOffset);\n case 'right':\n return Math.min(maxOffset, fractionalOffset);\n default:\n return 0;\n }\n });\n\n /**\n * Brings the item in again if past the threshold. Only relevant for\n * outermost items.\n */\n const actionOverlayOffset = useSpring(0, {\n bounce: 0,\n }) as MotionValue<number>;\n\n /**\n * Combines the two values above to create the correct X transform that has\n * to be applied to the action.\n */\n const actionX = useTransform<number, number>([actionOffset, actionOverlayOffset], ([x, y]) => {\n if (position === 'left') {\n return Math.min((x ?? 0) + (y ?? 0), 0);\n }\n\n return Math.max((x ?? 0) + (y ?? 0), 0);\n });\n\n const opacity = useTransform(listItemXOffset, (x) =>\n Math.max(0, Math.min(1, Math.abs(x) / 72)),\n );\n\n useMotionValueEvent(opacity, 'change', (value) => {\n setPointerEvents(value < 0.5 ? 'none' : 'auto');\n });\n\n // Animate to the middle after passing threshold if outermost item\n useEffect(() => {\n const isOuterMost = index === totalActionCount - 1;\n\n if (!isOuterMost) return undefined;\n\n return listItemXOffset.onChange((newValue) => {\n const lastValue = listItemXOffset.getPrevious();\n\n if (!lastValue) {\n return;\n }\n\n // eslint-disable-next-line default-case\n switch (position) {\n case 'left':\n if (newValue > activationThreshold && lastValue <= activationThreshold) {\n actionOverlayOffset.set(SWIPEABLE_ACTION_WIDTH * index);\n } else if (newValue < activationThreshold && lastValue >= activationThreshold) {\n actionOverlayOffset.set(0);\n }\n break;\n case 'right':\n if (newValue < activationThreshold && lastValue >= activationThreshold) {\n actionOverlayOffset.set(SWIPEABLE_ACTION_WIDTH * -1 * index);\n } else if (newValue > activationThreshold && lastValue <= activationThreshold) {\n actionOverlayOffset.set(0);\n }\n }\n });\n }, [\n actionOverlayOffset,\n activationThreshold,\n index,\n listItemXOffset,\n position,\n totalActionCount,\n ]);\n\n return (\n <StyledMotionSwipeableAction\n $backgroundColor={item.backgroundColor}\n $position={position}\n style={{ x: actionX, opacity: shouldUseOpacityAnimation ? opacity : 1 }}\n >\n <StyledSwipeableActionButton\n onClick={handleButtonClick}\n style={{ pointerEvents }}\n $color={item.color}\n $width={`${SWIPEABLE_ACTION_WIDTH}px`}\n >\n {item.icon}\n {item.text}\n </StyledSwipeableActionButton>\n </StyledMotionSwipeableAction>\n );\n};\n\nSwipeableAction.displayName = 'SwipeableAction';\n\nexport default SwipeableAction;\n"],"mappings":"AAAA,SAAsBA,mBAAmB,EAAEC,SAAS,EAAEC,YAAY,QAAQ,cAAc;AACxF,OAAOC,KAAK,IAAQC,SAAS,QAAQ,OAAO;AAE5C,SAASC,2BAA2B,EAAEC,2BAA2B,QAAQ,0BAA0B;AAEnG,OAAO,MAAMC,sBAAsB,GAAG,EAAE;AAaxC,MAAMC,eAAyC,GAAGA,CAAC;EAC/CC,mBAAmB;EACnBC,KAAK;EACLC,KAAK;EACLC,IAAI;EACJC,eAAe;EACfC,QAAQ;EACRC,yBAAyB;EACzBC;AACJ,CAAC,KAAK;EACF,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGf,KAAK,CAACgB,QAAQ,CAAkB,MAAM,CA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,CACCb,mBAAmB,EACnBpB,mBAAmB,EACnBE,KAAK,EACLE,eAAe,EACfC,QAAQ,EACRE,gBAAgB,CACnB,CAAC;EAEF,oBACIb,KAAA,CAAAwC,aAAA,CAACtC,2BAA2B;IACxBuC,gBAAgB,EAAEhC,IAAI,CAACiC,eAAgB;IACvCC,SAAS,EAAEhC,QAAS;IACpBiC,KAAK,EAAE;MAAEf,CAAC,EAAED,OAAO;MAAEG,OAAO,EAAEnB,yBAAyB,GAAGmB,OAAO,GAAG;IAAE;EAAE,gBAExE/B,KAAA,CAAAwC,aAAA,CAACrC,2BAA2B;IACxB0C,OAAO,EAAE5B,iBAAkB;IAC3B2B,KAAK,EAAE;MAAE9B;IAAc,CAAE;IACzBgC,MAAM,EAAErC,IAAI,CAACsC,KAAM;IACnBC,MAAM,EAAE,GAAG5C,sBAAsB;EAAK,GAErCK,IAAI,CAACwC,IAAI,EACTxC,IAAI,CAACyC,IACmB,CACJ,CAAC;AAEtC,CAAC;AAED7C,eAAe,CAAC8C,WAAW,GAAG,iBAAiB;AAE/C,eAAe9C,eAAe","ignoreList":[]}
@@ -1,22 +1,18 @@
1
- import { motion } from 'framer-motion';
1
+ import { motion } from 'motion/react';
2
2
  import styled, { css } from 'styled-components';
3
3
  export const StyledMotionSwipeableAction = styled(motion.div)`
4
- background-color: ${_ref => {
5
- let {
6
- $backgroundColor
7
- } = _ref;
8
- return $backgroundColor;
9
- }};
4
+ background-color: ${({
5
+ $backgroundColor
6
+ }) => $backgroundColor};
10
7
  display: flex;
11
8
  height: 100%;
12
9
  position: absolute;
13
10
  top: 0;
14
11
  width: 200vw;
15
12
 
16
- ${_ref2 => {
17
- let {
18
- $position
19
- } = _ref2;
13
+ ${({
14
+ $position
15
+ }) => {
20
16
  if ($position === 'left') {
21
17
  return css`
22
18
  justify-content: flex-end;
@@ -34,12 +30,9 @@ export const StyledSwipeableActionButton = styled.button`
34
30
  appearance: none;
35
31
  background: none;
36
32
  box-shadow: none;
37
- color: ${_ref3 => {
38
- let {
39
- $color
40
- } = _ref3;
41
- return $color;
42
- }};
33
+ color: ${({
34
+ $color
35
+ }) => $color};
43
36
  display: flex;
44
37
  flex-direction: column;
45
38
  font-size: 88%;
@@ -48,11 +41,8 @@ export const StyledSwipeableActionButton = styled.button`
48
41
  justify-content: center;
49
42
  margin: 0;
50
43
  padding: 0;
51
- width: ${_ref4 => {
52
- let {
53
- $width
54
- } = _ref4;
55
- return $width;
56
- }};
44
+ width: ${({
45
+ $width
46
+ }) => $width};
57
47
  `;
58
48
  //# sourceMappingURL=SwipeableAction.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SwipeableAction.styles.js","names":["motion","styled","css","StyledMotionSwipeableAction","div","_ref","$backgroundColor","_ref2","$position","StyledSwipeableActionButton","button","_ref3","$color","_ref4","$width"],"sources":["../../../../../src/components/swipeable-wrapper/swipeable-action/SwipeableAction.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport type { CSSProperties } from 'react';\nimport styled, { css } from 'styled-components';\n\ntype StyledSwipeableActionProps = {\n $position: 'left' | 'right';\n $backgroundColor: CSSProperties['backgroundColor'];\n};\n\nexport const StyledMotionSwipeableAction = styled(motion.div)<StyledSwipeableActionProps>`\n background-color: ${({ $backgroundColor }) => $backgroundColor};\n display: flex;\n height: 100%;\n position: absolute;\n top: 0;\n width: 200vw;\n\n ${({ $position }) => {\n if ($position === 'left') {\n return css`\n justify-content: flex-end;\n right: 100%;\n `;\n }\n return css`\n justify-content: flex-start;\n left: 100%;\n `;\n }}\n`;\n\ntype StyledSwipeableActionButtonsProps = {\n $width: CSSProperties['width'];\n $color: CSSProperties['color'];\n};\n\nexport const StyledSwipeableActionButton = styled.button<StyledSwipeableActionButtonsProps>`\n align-items: center;\n appearance: none;\n background: none;\n box-shadow: none;\n color: ${({ $color }) => $color};\n display: flex;\n flex-direction: column;\n font-size: 88%;\n gap: 4px;\n height: 100%;\n justify-content: center;\n margin: 0;\n padding: 0;\n width: ${({ $width }) => $width};\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AAEtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAO/C,OAAO,MAAMC,2BAA2B,GAAGF,MAAM,CAACD,MAAM,CAACI,GAAG,CAA6B;AACzF,wBAAwBC,IAAA;EAAA,IAAC;IAAEC;EAAiB,CAAC,GAAAD,IAAA;EAAA,OAAKC,gBAAgB;AAAA;AAClE;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,KAAA,IAAmB;EAAA,IAAlB;IAAEC;EAAU,CAAC,GAAAD,KAAA;EACZ,IAAIC,SAAS,KAAK,MAAM,EAAE;IACtB,OAAON,GAAG;AACtB;AACA;AACA,aAAa;EACL;EACA,OAAOA,GAAG;AAClB;AACA;AACA,SAAS;AACL,CAAC;AACL,CAAC;AAOD,OAAO,MAAMO,2BAA2B,GAAGR,MAAM,CAACS,MAAyC;AAC3F;AACA;AACA;AACA;AACA,aAAaC,KAAA;EAAA,IAAC;IAAEC;EAAO,CAAC,GAAAD,KAAA;EAAA,OAAKC,MAAM;AAAA;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAaC,KAAA;EAAA,IAAC;IAAEC;EAAO,CAAC,GAAAD,KAAA;EAAA,OAAKC,MAAM;AAAA;AACnC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SwipeableAction.styles.js","names":["motion","styled","css","StyledMotionSwipeableAction","div","$backgroundColor","$position","StyledSwipeableActionButton","button","$color","$width"],"sources":["../../../../../src/components/swipeable-wrapper/swipeable-action/SwipeableAction.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport type { CSSProperties } from 'react';\nimport styled, { css } from 'styled-components';\n\ntype StyledSwipeableActionProps = {\n $position: 'left' | 'right';\n $backgroundColor: CSSProperties['backgroundColor'];\n};\n\nexport const StyledMotionSwipeableAction = styled(motion.div)<StyledSwipeableActionProps>`\n background-color: ${({ $backgroundColor }) => $backgroundColor};\n display: flex;\n height: 100%;\n position: absolute;\n top: 0;\n width: 200vw;\n\n ${({ $position }) => {\n if ($position === 'left') {\n return css`\n justify-content: flex-end;\n right: 100%;\n `;\n }\n return css`\n justify-content: flex-start;\n left: 100%;\n `;\n }}\n`;\n\ntype StyledSwipeableActionButtonsProps = {\n $width: CSSProperties['width'];\n $color: CSSProperties['color'];\n};\n\nexport const StyledSwipeableActionButton = styled.button<StyledSwipeableActionButtonsProps>`\n align-items: center;\n appearance: none;\n background: none;\n box-shadow: none;\n color: ${({ $color }) => $color};\n display: flex;\n flex-direction: column;\n font-size: 88%;\n gap: 4px;\n height: 100%;\n justify-content: center;\n margin: 0;\n padding: 0;\n width: ${({ $width }) => $width};\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,cAAc;AAErC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAO/C,OAAO,MAAMC,2BAA2B,GAAGF,MAAM,CAACD,MAAM,CAACI,GAAG,CAA6B;AACzF,wBAAwB,CAAC;EAAEC;AAAiB,CAAC,KAAKA,gBAAgB;AAClE;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,CAAC;EAAEC;AAAU,CAAC,KAAK;EACjB,IAAIA,SAAS,KAAK,MAAM,EAAE;IACtB,OAAOJ,GAAG;AACtB;AACA;AACA,aAAa;EACL;EACA,OAAOA,GAAG;AAClB;AACA;AACA,SAAS;AACL,CAAC;AACL,CAAC;AAOD,OAAO,MAAMK,2BAA2B,GAAGN,MAAM,CAACO,MAAyC;AAC3F;AACA;AACA;AACA;AACA,aAAa,CAAC;EAAEC;AAAO,CAAC,KAAKA,MAAM;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,CAAC;EAAEC;AAAO,CAAC,KAAKA,MAAM;AACnC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","SwipeableWrapper"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as SwipeableWrapper } from './components/swipeable-wrapper/SwipeableWrapper';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,gBAAgB,QAAQ,iDAAiD","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["default","SwipeableWrapper"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as SwipeableWrapper } from './components/swipeable-wrapper/SwipeableWrapper';\n\nexport type { SwipeableActionItem } from './components/swipeable-wrapper/SwipeableWrapper';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,gBAAgB,QAAQ,iDAAiD","ignoreList":[]}
@@ -1,10 +1,7 @@
1
1
  import { SWIPEABLE_ACTION_WIDTH } from '../components/swipeable-wrapper/swipeable-action/SwipeableAction';
2
- export const calcThreshold = _ref => {
3
- let {
4
- actionCount,
5
- direction,
6
- width
7
- } = _ref;
8
- return Math.max(width / 2, SWIPEABLE_ACTION_WIDTH * actionCount) * (direction === 'left' ? 1 : -1);
9
- };
2
+ export const calcThreshold = ({
3
+ actionCount,
4
+ direction,
5
+ width
6
+ }) => Math.max(width / 2, SWIPEABLE_ACTION_WIDTH * actionCount) * (direction === 'left' ? 1 : -1);
10
7
  //# sourceMappingURL=threshold.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"threshold.js","names":["SWIPEABLE_ACTION_WIDTH","calcThreshold","_ref","actionCount","direction","width","Math","max"],"sources":["../../../src/utils/threshold.ts"],"sourcesContent":["import { SWIPEABLE_ACTION_WIDTH } from '../components/swipeable-wrapper/swipeable-action/SwipeableAction';\n\ninterface CalcThresholdOptions {\n actionCount: number;\n direction: 'left' | 'right';\n width: number;\n}\n\nexport const calcThreshold = ({ actionCount, direction, width }: CalcThresholdOptions) =>\n Math.max(width / 2, SWIPEABLE_ACTION_WIDTH * actionCount) * (direction === 'left' ? 1 : -1);\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,kEAAkE;AAQzG,OAAO,MAAMC,aAAa,GAAGC,IAAA;EAAA,IAAC;IAAEC,WAAW;IAAEC,SAAS;IAAEC;EAA4B,CAAC,GAAAH,IAAA;EAAA,OACjFI,IAAI,CAACC,GAAG,CAACF,KAAK,GAAG,CAAC,EAAEL,sBAAsB,GAAGG,WAAW,CAAC,IAAIC,SAAS,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"threshold.js","names":["SWIPEABLE_ACTION_WIDTH","calcThreshold","actionCount","direction","width","Math","max"],"sources":["../../../src/utils/threshold.ts"],"sourcesContent":["import { SWIPEABLE_ACTION_WIDTH } from '../components/swipeable-wrapper/swipeable-action/SwipeableAction';\n\ninterface CalcThresholdOptions {\n actionCount: number;\n direction: 'left' | 'right';\n width: number;\n}\n\nexport const calcThreshold = ({ actionCount, direction, width }: CalcThresholdOptions) =>\n Math.max(width / 2, SWIPEABLE_ACTION_WIDTH * actionCount) * (direction === 'left' ? 1 : -1);\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,kEAAkE;AAQzG,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEC,WAAW;EAAEC,SAAS;EAAEC;AAA4B,CAAC,KACjFC,IAAI,CAACC,GAAG,CAACF,KAAK,GAAG,CAAC,EAAEJ,sBAAsB,GAAGE,WAAW,CAAC,IAAIC,SAAS,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC","ignoreList":[]}
@@ -24,6 +24,18 @@ export type SwipeableWrapperProps = {
24
24
  * Whether the opacity should be animated when swiping in the actions.
25
25
  */
26
26
  shouldUseOpacityAnimation?: boolean;
27
+ /**
28
+ * Whether the swipeable functionality is disabled
29
+ */
30
+ isDisabled?: boolean;
31
+ /**
32
+ * Callback to be executed when the swiping is started.
33
+ */
34
+ onSwipeStart?: VoidFunction;
35
+ /**
36
+ * Callback to be executed when the swiping is ended.
37
+ */
38
+ onSwipeEnd?: VoidFunction;
27
39
  };
28
40
  declare const SwipeableWrapper: FC<SwipeableWrapperProps>;
29
41
  export default SwipeableWrapper;
@@ -1,267 +1,4 @@
1
- export declare const StyledMotionSwipeableWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<{
2
- title?: string | undefined;
3
- slot?: string | undefined;
4
- defaultChecked?: boolean | undefined;
5
- defaultValue?: string | number | readonly string[] | undefined;
6
- suppressContentEditableWarning?: boolean | undefined;
7
- suppressHydrationWarning?: boolean | undefined;
8
- accessKey?: string | undefined;
9
- autoCapitalize?: (string & {}) | "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined;
10
- autoFocus?: boolean | undefined;
11
- className?: string | undefined;
12
- contentEditable?: "inherit" | (boolean | "true" | "false") | "plaintext-only" | undefined;
13
- contextMenu?: string | undefined;
14
- dir?: string | undefined;
15
- draggable?: (boolean | "true" | "false") | undefined;
16
- enterKeyHint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send" | undefined;
17
- hidden?: boolean | undefined;
18
- id?: string | undefined;
19
- lang?: string | undefined;
20
- nonce?: string | undefined;
21
- spellCheck?: (boolean | "true" | "false") | undefined;
22
- tabIndex?: number | undefined;
23
- translate?: "yes" | "no" | undefined;
24
- radioGroup?: string | undefined;
25
- role?: import("react").AriaRole | undefined;
26
- about?: string | undefined;
27
- content?: string | undefined;
28
- datatype?: string | undefined;
29
- inlist?: any;
30
- prefix?: string | undefined;
31
- property?: string | undefined;
32
- rel?: string | undefined;
33
- resource?: string | undefined;
34
- rev?: string | undefined;
35
- typeof?: string | undefined;
36
- vocab?: string | undefined;
37
- autoCorrect?: string | undefined;
38
- autoSave?: string | undefined;
39
- color?: string | undefined;
40
- itemProp?: string | undefined;
41
- itemScope?: boolean | undefined;
42
- itemType?: string | undefined;
43
- itemID?: string | undefined;
44
- itemRef?: string | undefined;
45
- results?: number | undefined;
46
- security?: string | undefined;
47
- unselectable?: "off" | "on" | undefined;
48
- inputMode?: "text" | "search" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
49
- is?: string | undefined;
50
- "aria-activedescendant"?: string | undefined;
51
- "aria-atomic"?: (boolean | "true" | "false") | undefined;
52
- "aria-autocomplete"?: "none" | "list" | "both" | "inline" | undefined;
53
- "aria-braillelabel"?: string | undefined;
54
- "aria-brailleroledescription"?: string | undefined;
55
- "aria-busy"?: (boolean | "true" | "false") | undefined;
56
- "aria-checked"?: boolean | "true" | "false" | "mixed" | undefined;
57
- "aria-colcount"?: number | undefined;
58
- "aria-colindex"?: number | undefined;
59
- "aria-colindextext"?: string | undefined;
60
- "aria-colspan"?: number | undefined;
61
- "aria-controls"?: string | undefined;
62
- "aria-current"?: boolean | "time" | "true" | "false" | "page" | "step" | "location" | "date" | undefined;
63
- "aria-describedby"?: string | undefined;
64
- "aria-description"?: string | undefined;
65
- "aria-details"?: string | undefined;
66
- "aria-disabled"?: (boolean | "true" | "false") | undefined;
67
- "aria-dropeffect"?: "link" | "none" | "copy" | "move" | "execute" | "popup" | undefined;
68
- "aria-errormessage"?: string | undefined;
69
- "aria-expanded"?: (boolean | "true" | "false") | undefined;
70
- "aria-flowto"?: string | undefined;
71
- "aria-grabbed"?: (boolean | "true" | "false") | undefined;
72
- "aria-haspopup"?: boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree" | undefined;
73
- "aria-hidden"?: (boolean | "true" | "false") | undefined;
74
- "aria-invalid"?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
75
- "aria-keyshortcuts"?: string | undefined;
76
- "aria-label"?: string | undefined;
77
- "aria-labelledby"?: string | undefined;
78
- "aria-level"?: number | undefined;
79
- "aria-live"?: "off" | "assertive" | "polite" | undefined;
80
- "aria-modal"?: (boolean | "true" | "false") | undefined;
81
- "aria-multiline"?: (boolean | "true" | "false") | undefined;
82
- "aria-multiselectable"?: (boolean | "true" | "false") | undefined;
83
- "aria-orientation"?: "horizontal" | "vertical" | undefined;
84
- "aria-owns"?: string | undefined;
85
- "aria-placeholder"?: string | undefined;
86
- "aria-posinset"?: number | undefined;
87
- "aria-pressed"?: boolean | "true" | "false" | "mixed" | undefined;
88
- "aria-readonly"?: (boolean | "true" | "false") | undefined;
89
- "aria-relevant"?: "text" | "all" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
90
- "aria-required"?: (boolean | "true" | "false") | undefined;
91
- "aria-roledescription"?: string | undefined;
92
- "aria-rowcount"?: number | undefined;
93
- "aria-rowindex"?: number | undefined;
94
- "aria-rowindextext"?: string | undefined;
95
- "aria-rowspan"?: number | undefined;
96
- "aria-selected"?: (boolean | "true" | "false") | undefined;
97
- "aria-setsize"?: number | undefined;
98
- "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
99
- "aria-valuemax"?: number | undefined;
100
- "aria-valuemin"?: number | undefined;
101
- "aria-valuenow"?: number | undefined;
102
- "aria-valuetext"?: string | undefined;
103
- dangerouslySetInnerHTML?: {
104
- __html: string | TrustedHTML;
105
- } | undefined;
106
- onCopy?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
107
- onCopyCapture?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
108
- onCut?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
109
- onCutCapture?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
110
- onPaste?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
111
- onPasteCapture?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
112
- onCompositionEnd?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
113
- onCompositionEndCapture?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
114
- onCompositionStart?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
115
- onCompositionStartCapture?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
116
- onCompositionUpdate?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
117
- onCompositionUpdateCapture?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
118
- onFocus?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
119
- onFocusCapture?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
120
- onBlur?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
121
- onBlurCapture?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
122
- onChange?: import("react").FormEventHandler<HTMLDivElement> | undefined;
123
- onChangeCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
124
- onBeforeInput?: import("react").FormEventHandler<HTMLDivElement> | undefined;
125
- onBeforeInputCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
126
- onInput?: import("react").FormEventHandler<HTMLDivElement> | undefined;
127
- onInputCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
128
- onReset?: import("react").FormEventHandler<HTMLDivElement> | undefined;
129
- onResetCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
130
- onSubmit?: import("react").FormEventHandler<HTMLDivElement> | undefined;
131
- onSubmitCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
132
- onInvalid?: import("react").FormEventHandler<HTMLDivElement> | undefined;
133
- onInvalidCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
134
- onLoad?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
135
- onLoadCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
136
- onError?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
137
- onErrorCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
138
- onKeyDown?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
139
- onKeyDownCapture?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
140
- onKeyPress?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
141
- onKeyPressCapture?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
142
- onKeyUp?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
143
- onKeyUpCapture?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
144
- onAbort?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
145
- onAbortCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
146
- onCanPlay?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
147
- onCanPlayCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
148
- onCanPlayThrough?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
149
- onCanPlayThroughCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
150
- onDurationChange?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
151
- onDurationChangeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
152
- onEmptied?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
153
- onEmptiedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
154
- onEncrypted?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
155
- onEncryptedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
156
- onEnded?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
157
- onEndedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
158
- onLoadedData?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
159
- onLoadedDataCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
160
- onLoadedMetadata?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
161
- onLoadedMetadataCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
162
- onLoadStart?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
163
- onLoadStartCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
164
- onPause?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
165
- onPauseCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
166
- onPlay?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
167
- onPlayCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
168
- onPlaying?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
169
- onPlayingCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
170
- onProgress?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
171
- onProgressCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
172
- onRateChange?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
173
- onRateChangeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
174
- onResize?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
175
- onResizeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
176
- onSeeked?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
177
- onSeekedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
178
- onSeeking?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
179
- onSeekingCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
180
- onStalled?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
181
- onStalledCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
182
- onSuspend?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
183
- onSuspendCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
184
- onTimeUpdate?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
185
- onTimeUpdateCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
186
- onVolumeChange?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
187
- onVolumeChangeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
188
- onWaiting?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
189
- onWaitingCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
190
- onAuxClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
191
- onAuxClickCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
192
- onClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
193
- onClickCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
194
- onContextMenu?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
195
- onContextMenuCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
196
- onDoubleClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
197
- onDoubleClickCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
198
- onDragCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
199
- onDragEndCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
200
- onDragEnter?: import("react").DragEventHandler<HTMLDivElement> | undefined;
201
- onDragEnterCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
202
- onDragExit?: import("react").DragEventHandler<HTMLDivElement> | undefined;
203
- onDragExitCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
204
- onDragLeave?: import("react").DragEventHandler<HTMLDivElement> | undefined;
205
- onDragLeaveCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
206
- onDragOver?: import("react").DragEventHandler<HTMLDivElement> | undefined;
207
- onDragOverCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
208
- onDragStartCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
209
- onDrop?: import("react").DragEventHandler<HTMLDivElement> | undefined;
210
- onDropCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
211
- onMouseDown?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
212
- onMouseDownCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
213
- onMouseEnter?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
214
- onMouseLeave?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
215
- onMouseMove?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
216
- onMouseMoveCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
217
- onMouseOut?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
218
- onMouseOutCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
219
- onMouseOver?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
220
- onMouseOverCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
221
- onMouseUp?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
222
- onMouseUpCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
223
- onSelect?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
224
- onSelectCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
225
- onTouchCancel?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
226
- onTouchCancelCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
227
- onTouchEnd?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
228
- onTouchEndCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
229
- onTouchMove?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
230
- onTouchMoveCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
231
- onTouchStart?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
232
- onTouchStartCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
233
- onPointerDown?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
234
- onPointerDownCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
235
- onPointerMove?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
236
- onPointerMoveCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
237
- onPointerUp?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
238
- onPointerUpCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
239
- onPointerCancel?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
240
- onPointerCancelCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
241
- onPointerEnter?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
242
- onPointerLeave?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
243
- onPointerOver?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
244
- onPointerOverCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
245
- onPointerOut?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
246
- onPointerOutCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
247
- onGotPointerCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
248
- onGotPointerCaptureCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
249
- onLostPointerCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
250
- onLostPointerCaptureCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
251
- onScroll?: import("react").UIEventHandler<HTMLDivElement> | undefined;
252
- onScrollCapture?: import("react").UIEventHandler<HTMLDivElement> | undefined;
253
- onWheel?: import("react").WheelEventHandler<HTMLDivElement> | undefined;
254
- onWheelCapture?: import("react").WheelEventHandler<HTMLDivElement> | undefined;
255
- onAnimationStartCapture?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
256
- onAnimationEnd?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
257
- onAnimationEndCapture?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
258
- onAnimationIteration?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
259
- onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
260
- onTransitionEnd?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
261
- onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
262
- } & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
1
+ export declare const StyledMotionSwipeableWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("motion/react").HTMLMotionProps<"div">, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
263
2
  ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
264
- }, {
265
- theme: import("@chayns-components/core/lib/types/components/color-scheme-provider/ColorSchemeProvider").Theme;
266
- }>> & string & Omit<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
3
+ }, never>> & string & Omit<import("motion/react").ForwardRefComponent<HTMLDivElement, import("motion/react").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
267
4
  export declare const StyledSwipeableWrapperContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -1,4 +1,4 @@
1
- import { MotionValue } from 'framer-motion';
1
+ import { MotionValue } from 'motion/react';
2
2
  import { FC } from 'react';
3
3
  import type { SwipeableActionItem } from '../SwipeableWrapper';
4
4
  export declare const SWIPEABLE_ACTION_WIDTH = 72;