@chayns-components/swipeable-wrapper 5.0.0-beta.289 → 5.0.0-beta.291

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 (35) hide show
  1. package/README.md +23 -6
  2. package/lib/components/swipeable-wrapper/SwipeableWrapper.d.ts +25 -0
  3. package/lib/components/swipeable-wrapper/SwipeableWrapper.js +181 -0
  4. package/lib/components/swipeable-wrapper/SwipeableWrapper.js.map +1 -0
  5. package/lib/components/swipeable-wrapper/SwipeableWrapper.styles.d.ts +2 -0
  6. package/lib/components/swipeable-wrapper/SwipeableWrapper.styles.js +19 -0
  7. package/lib/components/swipeable-wrapper/SwipeableWrapper.styles.js.map +1 -0
  8. package/lib/components/swipeable-wrapper/swipeable-action/SwipeableAction.d.ts +15 -0
  9. package/lib/components/swipeable-wrapper/swipeable-action/SwipeableAction.js +104 -0
  10. package/lib/components/swipeable-wrapper/swipeable-action/SwipeableAction.js.map +1 -0
  11. package/lib/components/swipeable-wrapper/swipeable-action/SwipeableAction.styles.d.ts +7 -0
  12. package/lib/components/swipeable-wrapper/swipeable-action/SwipeableAction.styles.js +66 -0
  13. package/lib/components/swipeable-wrapper/swipeable-action/SwipeableAction.styles.js.map +1 -0
  14. package/lib/index.d.ts +1 -1
  15. package/lib/index.js +3 -3
  16. package/lib/index.js.map +1 -1
  17. package/lib/utils/threshold.d.ts +7 -0
  18. package/lib/utils/threshold.js +17 -0
  19. package/lib/utils/threshold.js.map +1 -0
  20. package/package.json +4 -3
  21. package/lib/components/FileInput.d.ts +0 -21
  22. package/lib/components/FileInput.js +0 -102
  23. package/lib/components/FileInput.js.map +0 -1
  24. package/lib/components/FileInput.styles.d.ts +0 -8
  25. package/lib/components/FileInput.styles.js +0 -35
  26. package/lib/components/FileInput.styles.js.map +0 -1
  27. package/lib/components/file-list/FileListItem.d.ts +0 -9
  28. package/lib/components/file-list/FileListItem.js +0 -34
  29. package/lib/components/file-list/FileListItem.js.map +0 -1
  30. package/lib/components/file-list/FileListItem.styles.d.ts +0 -1
  31. package/lib/components/file-list/FileListItem.styles.js +0 -10
  32. package/lib/components/file-list/FileListItem.styles.js.map +0 -1
  33. package/lib/utils/file.d.ts +0 -363
  34. package/lib/utils/file.js +0 -404
  35. package/lib/utils/file.js.map +0 -1
package/README.md CHANGED
@@ -15,14 +15,14 @@
15
15
 
16
16
  ## Installation
17
17
 
18
- First you need to install the file input part of the chayns-components.
18
+ First you need to install the swipeable wrapper part of the chayns-components.
19
19
 
20
20
  ```bash
21
21
  # NPM
22
- npm install @chayns-components/file-input
22
+ npm install @chayns-components/swipeable-wrapper
23
23
 
24
24
  # Yarn
25
- yarn add @chayns-components/file-input
25
+ yarn add @chayns-components/swipeable-wrapper
26
26
  ```
27
27
 
28
28
  > **Information:** Since the components have now been implemented with the styled-components
@@ -34,7 +34,24 @@ yarn add @chayns-components/file-input
34
34
  You can use the components in your project as in the following example.
35
35
 
36
36
  ```typescript jsx
37
- import { FileInput } from '@chayns-components/file-input';
38
-
39
- <FileInput />;
37
+ import { Icon } from '@chayns-components/icon';
38
+ import { SwipeableWrapper } from '@chayns-components/swipeable-wrapper';
39
+
40
+ <SwipeableWrapper
41
+ leftActions={[
42
+ {
43
+ action: () => console.log('Delete action'),
44
+ color: '#3B82F6',
45
+ icon: <Icon icons={['fa fa-trash']} />,
46
+ text: 'Delete',
47
+ },
48
+ ]}
49
+ rightActions={
50
+ [
51
+ // Same structure as leftActions
52
+ ]
53
+ }
54
+ >
55
+ <MyComponent />
56
+ </SwipeableWrapper>;
40
57
  ```
@@ -0,0 +1,25 @@
1
+ import { CSSProperties, FC, ReactNode } from 'react';
2
+ export type SwipeableActionItem = {
3
+ action: VoidFunction;
4
+ backgroundColor: CSSProperties['backgroundColor'];
5
+ color: CSSProperties['color'];
6
+ text?: ReactNode;
7
+ icon: ReactNode;
8
+ key: string;
9
+ };
10
+ export type SwipeableWrapperProps = {
11
+ /**
12
+ * The content of the Swipeable item.
13
+ */
14
+ children: ReactNode;
15
+ /**
16
+ * The left-side actions, ordered from the left to the right.
17
+ */
18
+ leftActions?: SwipeableActionItem[];
19
+ /**
20
+ * The right-side actions, ordered from left to the right.
21
+ */
22
+ rightActions?: SwipeableActionItem[];
23
+ };
24
+ declare const SwipeableWrapper: FC<SwipeableWrapperProps>;
25
+ export default SwipeableWrapper;
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _framerMotion = require("framer-motion");
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _threshold = require("../../utils/threshold");
10
+ var _SwipeableAction = _interopRequireWildcard(require("./swipeable-action/SwipeableAction"));
11
+ var _SwipeableWrapper = require("./SwipeableWrapper.styles");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ const SwipeableWrapper = _ref => {
15
+ let {
16
+ children,
17
+ leftActions = [],
18
+ rightActions = []
19
+ } = _ref;
20
+ const [leftThreshold, setLeftThreshold] = (0, _react.useState)((0, _threshold.calcThreshold)({
21
+ actionCount: leftActions.length,
22
+ direction: 'left',
23
+ width: window.innerWidth
24
+ }));
25
+ const [rightThreshold, setRightThreshold] = (0, _react.useState)((0, _threshold.calcThreshold)({
26
+ actionCount: rightActions.length,
27
+ direction: 'right',
28
+ width: window.innerWidth
29
+ }));
30
+ const swipeableWrapperRef = (0, _react.useRef)(null);
31
+ const listItemXOffset = (0, _framerMotion.useMotionValue)(0);
32
+ const close = (0, _react.useCallback)(() => {
33
+ (0, _framerMotion.animate)(listItemXOffset, 0);
34
+ }, [listItemXOffset]);
35
+ const open = (0, _react.useCallback)(direction => {
36
+ switch (direction) {
37
+ case 'left':
38
+ (0, _framerMotion.animate)(listItemXOffset, _SwipeableAction.SWIPEABLE_ACTION_WIDTH * leftActions.length);
39
+ break;
40
+ case 'right':
41
+ (0, _framerMotion.animate)(listItemXOffset, -_SwipeableAction.SWIPEABLE_ACTION_WIDTH * rightActions.length);
42
+ break;
43
+ default:
44
+ break;
45
+ }
46
+ }, [leftActions.length, listItemXOffset, rightActions.length]);
47
+ (0, _react.useEffect)(() => {
48
+ var _swipeableWrapperRef$;
49
+ const width = (_swipeableWrapperRef$ = swipeableWrapperRef.current) === null || _swipeableWrapperRef$ === void 0 || (_swipeableWrapperRef$ = _swipeableWrapperRef$.parentElement) === null || _swipeableWrapperRef$ === void 0 ? void 0 : _swipeableWrapperRef$.offsetWidth;
50
+
51
+ // This check was deliberately chosen because a width of 0 is also not permitted.
52
+ if (width) {
53
+ setLeftThreshold((0, _threshold.calcThreshold)({
54
+ actionCount: leftActions.length,
55
+ direction: 'left',
56
+ width
57
+ }));
58
+ setRightThreshold((0, _threshold.calcThreshold)({
59
+ actionCount: rightActions.length,
60
+ direction: 'right',
61
+ width
62
+ }));
63
+ }
64
+ }, [leftActions.length, rightActions.length]);
65
+
66
+ // Close an opened menu when anything outside it is tapped
67
+ (0, _react.useEffect)(() => {
68
+ function closeCallback(event) {
69
+ var _swipeableWrapperRef$2;
70
+ const eventTarget = event.target;
71
+
72
+ // @ts-expect-error: Pretty sure that the event target is always a Node.
73
+ if (eventTarget && !((_swipeableWrapperRef$2 = swipeableWrapperRef.current) !== null && _swipeableWrapperRef$2 !== void 0 && _swipeableWrapperRef$2.contains(eventTarget))) {
74
+ close();
75
+ }
76
+ }
77
+ document.addEventListener('mousedown', closeCallback);
78
+ document.addEventListener('touchstart', closeCallback);
79
+ return () => {
80
+ document.removeEventListener('mousedown', closeCallback);
81
+ document.removeEventListener('touchstart', closeCallback);
82
+ };
83
+ }, [close]);
84
+
85
+ // Vibrate when the threshold is passed
86
+ (0, _react.useEffect)(() => listItemXOffset.onChange(newValue => {
87
+ const previous = listItemXOffset.getPrevious();
88
+ const hasCrossedLeftThreshold = previous < leftThreshold && newValue >= leftThreshold || previous > leftThreshold && newValue <= leftThreshold;
89
+ const hasCrossedRightThreshold = previous < rightThreshold && newValue >= rightThreshold || previous > rightThreshold && newValue <= rightThreshold;
90
+ if (hasCrossedLeftThreshold || hasCrossedRightThreshold) {
91
+ var _chayns;
92
+ // @ts-expect-error: No chayns typings given.
93
+ (_chayns = chayns) === null || _chayns === void 0 || _chayns.vibrate([150], 6);
94
+ }
95
+ }), [leftThreshold, listItemXOffset, rightThreshold]);
96
+ const handlePan = (0, _react.useCallback)((_, info) => {
97
+ const currentXOffset = listItemXOffset.get();
98
+ const dampingFactor = info.offset.x > 0 && leftActions.length > 0 || info.offset.x < 0 && rightActions.length > 0 || currentXOffset > 0 && info.delta.x < 0 || currentXOffset < 0 && info.delta.x > 0 ? 1 : 0.75 / (Math.abs(info.offset.x) / 8);
99
+ if (Math.abs(info.offset.x) > 30 || currentXOffset > 0) {
100
+ listItemXOffset.set(currentXOffset + info.delta.x * dampingFactor);
101
+ }
102
+ }, [leftActions.length, listItemXOffset, rightActions.length]);
103
+ const handlePanEnd = (0, _react.useCallback)(() => {
104
+ const offset = listItemXOffset.get();
105
+ if (offset > leftThreshold) {
106
+ var _leftActions$;
107
+ (_leftActions$ = leftActions[0]) === null || _leftActions$ === void 0 || _leftActions$.action();
108
+ close();
109
+ } else if (offset < rightThreshold) {
110
+ var _rightActions;
111
+ (_rightActions = rightActions[rightActions.length - 1]) === null || _rightActions === void 0 || _rightActions.action();
112
+ close();
113
+ } else {
114
+ let state;
115
+ if (offset > 2) {
116
+ state = 'left-open';
117
+ } else if (offset < -2) {
118
+ state = 'right-open';
119
+ } else {
120
+ state = 'closed';
121
+ }
122
+
123
+ // eslint-disable-next-line default-case
124
+ switch (state) {
125
+ case 'left-open':
126
+ if (offset < _SwipeableAction.SWIPEABLE_ACTION_WIDTH) {
127
+ close();
128
+ } else {
129
+ open('left');
130
+ }
131
+ break;
132
+ case 'right-open':
133
+ if (offset > -_SwipeableAction.SWIPEABLE_ACTION_WIDTH) {
134
+ close();
135
+ } else {
136
+ open('right');
137
+ }
138
+ break;
139
+ case 'closed':
140
+ if (offset > _SwipeableAction.SWIPEABLE_ACTION_WIDTH) {
141
+ open('left');
142
+ } else if (offset < -_SwipeableAction.SWIPEABLE_ACTION_WIDTH) {
143
+ open('right');
144
+ } else {
145
+ close();
146
+ }
147
+ }
148
+ }
149
+ }, [close, leftActions, leftThreshold, listItemXOffset, open, rightActions, rightThreshold]);
150
+ const leftActionElements = (0, _react.useMemo)(() => Array.from(leftActions).reverse().map((item, index) => /*#__PURE__*/_react.default.createElement(_SwipeableAction.default, {
151
+ activationThreshold: leftThreshold,
152
+ close: close,
153
+ index: index,
154
+ item: item,
155
+ key: item.key,
156
+ listItemXOffset: listItemXOffset,
157
+ position: "left",
158
+ totalActionCount: leftActions.length
159
+ })), [close, leftActions, leftThreshold, listItemXOffset]);
160
+ const rightActionElements = (0, _react.useMemo)(() => rightActions.map((item, index) => /*#__PURE__*/_react.default.createElement(_SwipeableAction.default, {
161
+ activationThreshold: rightThreshold,
162
+ close: close,
163
+ index: index,
164
+ item: item,
165
+ key: item.key,
166
+ listItemXOffset: listItemXOffset,
167
+ position: "right",
168
+ totalActionCount: rightActions.length
169
+ })), [close, rightActions, rightThreshold, listItemXOffset]);
170
+ return /*#__PURE__*/_react.default.createElement(_SwipeableWrapper.StyledMotionSwipeableWrapper, {
171
+ onPan: handlePan,
172
+ onPanEnd: handlePanEnd,
173
+ ref: swipeableWrapperRef,
174
+ style: {
175
+ x: listItemXOffset
176
+ }
177
+ }, leftActionElements, /*#__PURE__*/_react.default.createElement(_SwipeableWrapper.StyledSwipeableWrapperContent, null, children), rightActionElements);
178
+ };
179
+ SwipeableWrapper.displayName = 'SwipeableWrapper';
180
+ var _default = exports.default = SwipeableWrapper;
181
+ //# sourceMappingURL=SwipeableWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwipeableWrapper.js","names":["_framerMotion","require","_react","_interopRequireWildcard","_threshold","_SwipeableAction","_SwipeableWrapper","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","SwipeableWrapper","_ref","children","leftActions","rightActions","leftThreshold","setLeftThreshold","useState","calcThreshold","actionCount","length","direction","width","window","innerWidth","rightThreshold","setRightThreshold","swipeableWrapperRef","useRef","listItemXOffset","useMotionValue","close","useCallback","animate","open","SWIPEABLE_ACTION_WIDTH","useEffect","_swipeableWrapperRef$","current","parentElement","offsetWidth","closeCallback","event","_swipeableWrapperRef$2","eventTarget","target","contains","document","addEventListener","removeEventListener","onChange","newValue","previous","getPrevious","hasCrossedLeftThreshold","hasCrossedRightThreshold","_chayns","chayns","vibrate","handlePan","_","info","currentXOffset","dampingFactor","offset","x","delta","Math","abs","handlePanEnd","_leftActions$","action","_rightActions","state","leftActionElements","useMemo","Array","from","reverse","map","item","index","createElement","activationThreshold","key","position","totalActionCount","rightActionElements","StyledMotionSwipeableWrapper","onPan","onPanEnd","ref","style","StyledSwipeableWrapperContent","displayName","_default","exports"],"sources":["../../../src/components/swipeable-wrapper/SwipeableWrapper.tsx"],"sourcesContent":["import { 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 /**\n * The right-side actions, ordered from left to the right.\n */\n rightActions?: SwipeableActionItem[];\n};\n\nconst SwipeableWrapper: FC<SwipeableWrapperProps> = ({\n children,\n leftActions = [],\n rightActions = [],\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 animate(listItemXOffset, 0);\n }, [listItemXOffset]);\n\n const open = useCallback(\n (direction: 'left' | 'right') => {\n switch (direction) {\n case 'left':\n animate(listItemXOffset, SWIPEABLE_ACTION_WIDTH * leftActions.length);\n break;\n case 'right':\n 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 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 // @ts-expect-error: No chayns typings given.\n chayns?.vibrate([150], 6);\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) / 8);\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 totalActionCount={leftActions.length}\n />\n )),\n [close, leftActions, leftThreshold, listItemXOffset]\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 totalActionCount={rightActions.length}\n />\n )),\n [close, rightActions, rightThreshold, listItemXOffset]\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,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAUA,IAAAG,UAAA,GAAAH,O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G,MAAA,CAAAW,OAAA,CAAAuF,aAAA,CAAC/F,gBAAA,CAAAQ,OAAe;IACZwF,mBAAmB,EAAE1D,cAAe;IACpCM,KAAK,EAAEA,KAAM;IACbkD,KAAK,EAAEA,KAAM;IACbD,IAAI,EAAEA,IAAK;IACXI,GAAG,EAAEJ,IAAI,CAACI,GAAI;IACdvD,eAAe,EAAEA,eAAgB;IACjCwD,QAAQ,EAAC,OAAO;IAChBC,gBAAgB,EAAExE,YAAY,CAACM;EAAO,CACzC,CACJ,CAAC,EACN,CAACW,KAAK,EAAEjB,YAAY,EAAEW,cAAc,EAAEI,eAAe,CACzD,CAAC;EAED,oBACI7C,MAAA,CAAAW,OAAA,CAAAuF,aAAA,CAAC9F,iBAAA,CAAAoG,4BAA4B;IACzBC,KAAK,EAAE9B,SAAU;IACjB+B,QAAQ,EAAErB,YAAa;IACvBsB,GAAG,EAAEhE,mBAAoB;IACzBiE,KAAK,EAAE;MAAE3B,CAAC,EAAEpC;IAAgB;EAAE,GAE7B6C,kBAAkB,eACnB1F,MAAA,CAAAW,OAAA,CAAAuF,aAAA,CAAC9F,iBAAA,CAAAyG,6BAA6B,QAAEjF,QAAwC,CAAC,EACxE2E,mBACyB,CAAC;AAEvC,CAAC;AAED7E,gBAAgB,CAACoF,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAArG,OAAA,GAEnCe,gBAAgB"}
@@ -0,0 +1,2 @@
1
+ export declare const StyledMotionSwipeableWrapper: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {}, never>;
2
+ export declare const StyledSwipeableWrapperContent: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StyledSwipeableWrapperContent = exports.StyledMotionSwipeableWrapper = void 0;
7
+ var _framerMotion = require("framer-motion");
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ const StyledMotionSwipeableWrapper = exports.StyledMotionSwipeableWrapper = (0, _styledComponents.default)(_framerMotion.motion.div)`
11
+ position: relative;
12
+ touch-action: pan-y;
13
+ user-select: none;
14
+ `;
15
+ const StyledSwipeableWrapperContent = exports.StyledSwipeableWrapperContent = _styledComponents.default.div`
16
+ overflow: hidden;
17
+ width: 100%;
18
+ `;
19
+ //# sourceMappingURL=SwipeableWrapper.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwipeableWrapper.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireDefault","obj","__esModule","default","StyledMotionSwipeableWrapper","exports","styled","motion","div","StyledSwipeableWrapperContent"],"sources":["../../../src/components/swipeable-wrapper/SwipeableWrapper.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\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 overflow: hidden;\n width: 100%;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,4BAA4B,GAAAC,OAAA,CAAAD,4BAAA,GAAG,IAAAE,yBAAM,EAACC,oBAAM,CAACC,GAAG,CAAE;AAC/D;AACA;AACA;AACA,CAAC;AAEM,MAAMC,6BAA6B,GAAAJ,OAAA,CAAAI,6BAAA,GAAGH,yBAAM,CAACE,GAAI;AACxD;AACA;AACA,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { MotionValue } from 'framer-motion';
2
+ import { FC } from 'react';
3
+ import type { SwipeableActionItem } from '../SwipeableWrapper';
4
+ export declare const SWIPEABLE_ACTION_WIDTH = 72;
5
+ export type SwipeableActionProps = {
6
+ activationThreshold: number;
7
+ close: VoidFunction;
8
+ index: number;
9
+ item: SwipeableActionItem;
10
+ listItemXOffset: MotionValue<number>;
11
+ position: 'left' | 'right';
12
+ totalActionCount: number;
13
+ };
14
+ declare const SwipeableAction: FC<SwipeableActionProps>;
15
+ export default SwipeableAction;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.SWIPEABLE_ACTION_WIDTH = void 0;
7
+ var _framerMotion = require("framer-motion");
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _SwipeableAction = require("./SwipeableAction.styles");
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ const SWIPEABLE_ACTION_WIDTH = exports.SWIPEABLE_ACTION_WIDTH = 72;
13
+ const SwipeableAction = _ref => {
14
+ let {
15
+ activationThreshold,
16
+ close,
17
+ index,
18
+ item,
19
+ listItemXOffset,
20
+ position,
21
+ totalActionCount
22
+ } = _ref;
23
+ const handleButtonClick = () => {
24
+ item.action();
25
+ close();
26
+ };
27
+
28
+ /**
29
+ * By default, the action sticks to the content of the swipeable item. This
30
+ * makes it move outwards to reveal the inner items.
31
+ */
32
+ const actionOffset = (0, _framerMotion.useTransform)(listItemXOffset, newValue => {
33
+ const maxOffset = SWIPEABLE_ACTION_WIDTH * index;
34
+ const fractionalOffset = -newValue / totalActionCount * index;
35
+ switch (position) {
36
+ case 'left':
37
+ return Math.max(-maxOffset, fractionalOffset);
38
+ case 'right':
39
+ return Math.min(maxOffset, fractionalOffset);
40
+ default:
41
+ return 0;
42
+ }
43
+ });
44
+
45
+ /**
46
+ * Brings the item in again if past the threshold. Only relevant for
47
+ * outermost items.
48
+ */
49
+ const actionOverlayOffset = (0, _framerMotion.useSpring)(0, {
50
+ bounce: 0
51
+ });
52
+
53
+ /**
54
+ * Combines the two values above to create the correct X transform that has
55
+ * to be applied to the action.
56
+ */
57
+ const actionX = (0, _framerMotion.useTransform)([actionOffset, actionOverlayOffset], _ref2 => {
58
+ let [x, y] = _ref2;
59
+ if (position === 'left') {
60
+ return Math.min((x !== null && x !== void 0 ? x : 0) + (y !== null && y !== void 0 ? y : 0), 0);
61
+ }
62
+ return Math.max((x !== null && x !== void 0 ? x : 0) + (y !== null && y !== void 0 ? y : 0), 0);
63
+ });
64
+
65
+ // Animate to the middle after passing threshold if outermost item
66
+ (0, _react.useEffect)(() => {
67
+ const isOuterMost = index === totalActionCount - 1;
68
+ if (!isOuterMost) return undefined;
69
+ return listItemXOffset.onChange(newValue => {
70
+ const lastValue = listItemXOffset.getPrevious();
71
+
72
+ // eslint-disable-next-line default-case
73
+ switch (position) {
74
+ case 'left':
75
+ if (newValue > activationThreshold && lastValue <= activationThreshold) {
76
+ actionOverlayOffset.set(SWIPEABLE_ACTION_WIDTH * index);
77
+ } else if (newValue < activationThreshold && lastValue >= activationThreshold) {
78
+ actionOverlayOffset.set(0);
79
+ }
80
+ break;
81
+ case 'right':
82
+ if (newValue < activationThreshold && lastValue >= activationThreshold) {
83
+ actionOverlayOffset.set(SWIPEABLE_ACTION_WIDTH * -1 * index);
84
+ } else if (newValue > activationThreshold && lastValue <= activationThreshold) {
85
+ actionOverlayOffset.set(0);
86
+ }
87
+ }
88
+ });
89
+ }, [actionOverlayOffset, activationThreshold, index, listItemXOffset, position, totalActionCount]);
90
+ return /*#__PURE__*/_react.default.createElement(_SwipeableAction.StyledMotionSwipeableAction, {
91
+ backgroundColor: item.backgroundColor,
92
+ position: position,
93
+ style: {
94
+ x: actionX
95
+ }
96
+ }, /*#__PURE__*/_react.default.createElement(_SwipeableAction.StyledSwipeableActionButton, {
97
+ color: item.color,
98
+ onClick: handleButtonClick,
99
+ width: `${SWIPEABLE_ACTION_WIDTH}px`
100
+ }, item.icon, item.text));
101
+ };
102
+ SwipeableAction.displayName = 'SwipeableAction';
103
+ var _default = exports.default = SwipeableAction;
104
+ //# sourceMappingURL=SwipeableAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwipeableAction.js","names":["_framerMotion","require","_react","_interopRequireWildcard","_SwipeableAction","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","SWIPEABLE_ACTION_WIDTH","exports","SwipeableAction","_ref","activationThreshold","close","index","item","listItemXOffset","position","totalActionCount","handleButtonClick","action","actionOffset","useTransform","newValue","maxOffset","fractionalOffset","Math","max","min","actionOverlayOffset","useSpring","bounce","actionX","_ref2","x","y","useEffect","isOuterMost","undefined","onChange","lastValue","getPrevious","createElement","StyledMotionSwipeableAction","backgroundColor","style","StyledSwipeableActionButton","color","onClick","width","icon","text","displayName","_default"],"sources":["../../../../src/components/swipeable-wrapper/swipeable-action/SwipeableAction.tsx"],"sourcesContent":["import { MotionValue, 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 totalActionCount: number;\n};\n\nconst SwipeableAction: FC<SwipeableActionProps> = ({\n activationThreshold,\n close,\n index,\n item,\n listItemXOffset,\n position,\n totalActionCount,\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 // 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 // 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 }}\n >\n <StyledSwipeableActionButton\n color={item.color}\n onClick={handleButtonClick}\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,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAH,OAAA;AAAoG,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI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,KAAK,OAAO;UACR,IAAIgB,QAAQ,GAAGX,mBAAmB,IAAI4B,SAAS,IAAI5B,mBAAmB,EAAE;YACpEiB,mBAAmB,CAACtB,GAAG,CAACC,sBAAsB,GAAG,CAAC,CAAC,GAAGM,KAAK,CAAC;UAChE,CAAC,MAAM,IAAIS,QAAQ,GAAGX,mBAAmB,IAAI4B,SAAS,IAAI5B,mBAAmB,EAAE;YAC3EiB,mBAAmB,CAACtB,GAAG,CAAC,CAAC,CAAC;UAC9B;MACR;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CACCsB,mBAAmB,EACnBjB,mBAAmB,EACnBE,KAAK,EACLE,eAAe,EACfC,QAAQ,EACRC,gBAAgB,CACnB,CAAC;EAEF,oBACIlC,MAAA,CAAAS,OAAA,CAAAiD,aAAA,CAACxD,gBAAA,CAAAyD,2BAA2B;IACxBC,eAAe,EAAE7B,IAAI,CAAC6B,eAAgB;IACtC3B,QAAQ,EAAEA,QAAS;IACnB4B,KAAK,EAAE;MAAEX,CAAC,EAAEF;IAAQ;EAAE,gBAEtBhD,MAAA,CAAAS,OAAA,CAAAiD,aAAA,CAACxD,gBAAA,CAAA4D,2BAA2B;IACxBC,KAAK,EAAEhC,IAAI,CAACgC,KAAM;IAClBC,OAAO,EAAE7B,iBAAkB;IAC3B8B,KAAK,EAAG,GAAEzC,sBAAuB;EAAI,GAEpCO,IAAI,CAACmC,IAAI,EACTnC,IAAI,CAACoC,IACmB,CACJ,CAAC;AAEtC,CAAC;AAEDzC,eAAe,CAAC0C,WAAW,GAAG,iBAAiB;AAAC,IAAAC,QAAA,GAAA5C,OAAA,CAAAhB,OAAA,GAEjCiB,eAAe"}
@@ -0,0 +1,7 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { SwipeableActionItem } from '../SwipeableWrapper';
3
+ import type { SwipeableActionProps } from './SwipeableAction';
4
+ export declare const StyledMotionSwipeableAction: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, Pick<SwipeableActionProps, "position"> & Pick<SwipeableActionItem, "backgroundColor">, never>;
5
+ export declare const StyledSwipeableActionButton: import("styled-components").StyledComponent<"button", any, Pick<SwipeableActionItem, "color"> & {
6
+ width: CSSProperties['width'];
7
+ }, never>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StyledSwipeableActionButton = exports.StyledMotionSwipeableAction = void 0;
7
+ var _framerMotion = require("framer-motion");
8
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ const StyledMotionSwipeableAction = exports.StyledMotionSwipeableAction = (0, _styledComponents.default)(_framerMotion.motion.div)`
12
+ background-color: ${_ref => {
13
+ let {
14
+ backgroundColor
15
+ } = _ref;
16
+ return backgroundColor;
17
+ }};
18
+ display: flex;
19
+ height: 100%;
20
+ position: absolute;
21
+ top: 0;
22
+ width: 200vw;
23
+
24
+ ${_ref2 => {
25
+ let {
26
+ position
27
+ } = _ref2;
28
+ if (position === 'left') {
29
+ return (0, _styledComponents.css)`
30
+ justify-content: flex-end;
31
+ right: 100%;
32
+ `;
33
+ }
34
+ return (0, _styledComponents.css)`
35
+ justify-content: flex-start;
36
+ left: 100%;
37
+ `;
38
+ }}
39
+ `;
40
+ const StyledSwipeableActionButton = exports.StyledSwipeableActionButton = _styledComponents.default.button`
41
+ align-items: center;
42
+ appearance: none;
43
+ background: none;
44
+ box-shadow: none;
45
+ color: ${_ref3 => {
46
+ let {
47
+ color
48
+ } = _ref3;
49
+ return color;
50
+ }};
51
+ display: flex;
52
+ flex-direction: column;
53
+ font-size: 88%;
54
+ gap: 4px;
55
+ height: 100%;
56
+ justify-content: center;
57
+ margin: 0;
58
+ padding: 0;
59
+ width: ${_ref4 => {
60
+ let {
61
+ width
62
+ } = _ref4;
63
+ return width;
64
+ }};
65
+ `;
66
+ //# sourceMappingURL=SwipeableAction.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwipeableAction.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","StyledMotionSwipeableAction","exports","styled","motion","div","_ref","backgroundColor","_ref2","position","css","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';\nimport type { SwipeableActionItem } from '../SwipeableWrapper';\nimport type { SwipeableActionProps } from './SwipeableAction';\n\ntype StyledSwipeableActionProps = Pick<SwipeableActionProps, 'position'> &\n Pick<SwipeableActionItem, 'backgroundColor'>;\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 = Pick<SwipeableActionItem, 'color'> & {\n width: CSSProperties['width'];\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,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAgD,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAgB,GAAA,CAAAnB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAOzC,MAAMY,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAG,IAAAE,yBAAM,EAACC,oBAAM,CAACC,GAAG,CAA8B;AAC1F,wBAAwBC,IAAA;EAAA,IAAC;IAAEC;EAAgB,CAAC,GAAAD,IAAA;EAAA,OAAKC,eAAe;AAAA,CAAC;AACjE;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,KAAA,IAAkB;EAAA,IAAjB;IAAEC;EAAS,CAAC,GAAAD,KAAA;EACX,IAAIC,QAAQ,KAAK,MAAM,EAAE;IACrB,OAAO,IAAAC,qBAAG,CAAC;AACvB;AACA;AACA,aAAa;EACL;EACA,OAAO,IAAAA,qBAAG,CAAC;AACnB;AACA;AACA,SAAS;AACL,CAAE;AACN,CAAC;AAMM,MAAMC,2BAA2B,GAAAT,OAAA,CAAAS,2BAAA,GAAGR,yBAAM,CAACS,MAA0C;AAC5F;AACA;AACA;AACA;AACA,aAAaC,KAAA;EAAA,IAAC;IAAEC;EAAM,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK;AAAA,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAaC,KAAA;EAAA,IAAC;IAAEC;EAAM,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK;AAAA,CAAC;AAClC,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { default as FileInput } from './components/FileInput';
1
+ export { default as SwipeableWrapper } from './components/swipeable-wrapper/SwipeableWrapper';
package/lib/index.js CHANGED
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "FileInput", {
6
+ Object.defineProperty(exports, "SwipeableWrapper", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _FileInput.default;
9
+ return _SwipeableWrapper.default;
10
10
  }
11
11
  });
12
- var _FileInput = _interopRequireDefault(require("./components/FileInput"));
12
+ var _SwipeableWrapper = _interopRequireDefault(require("./components/swipeable-wrapper/SwipeableWrapper"));
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
14
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_FileInput","_interopRequireDefault","require","obj","__esModule","default"],"sources":["../src/index.ts"],"sourcesContent":["export { default as FileInput } from './components/FileInput';\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
1
+ {"version":3,"file":"index.js","names":["_SwipeableWrapper","_interopRequireDefault","require","obj","__esModule","default"],"sources":["../src/index.ts"],"sourcesContent":["export { default as SwipeableWrapper } from './components/swipeable-wrapper/SwipeableWrapper';\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8F,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
@@ -0,0 +1,7 @@
1
+ interface CalcThresholdOptions {
2
+ actionCount: number;
3
+ direction: 'left' | 'right';
4
+ width: number;
5
+ }
6
+ export declare const calcThreshold: ({ actionCount, direction, width }: CalcThresholdOptions) => number;
7
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.calcThreshold = void 0;
7
+ var _SwipeableAction = require("../components/swipeable-wrapper/swipeable-action/SwipeableAction");
8
+ const calcThreshold = _ref => {
9
+ let {
10
+ actionCount,
11
+ direction,
12
+ width
13
+ } = _ref;
14
+ return Math.max(width / 2, _SwipeableAction.SWIPEABLE_ACTION_WIDTH * actionCount) * (direction === 'left' ? 1 : -1);
15
+ };
16
+ exports.calcThreshold = calcThreshold;
17
+ //# sourceMappingURL=threshold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold.js","names":["_SwipeableAction","require","calcThreshold","_ref","actionCount","direction","width","Math","max","SWIPEABLE_ACTION_WIDTH","exports"],"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,IAAAA,gBAAA,GAAAC,OAAA;AAQO,MAAMC,aAAa,GAAGC,IAAA;EAAA,IAAC;IAAEC,WAAW;IAAEC,SAAS;IAAEC;EAA4B,CAAC,GAAAH,IAAA;EAAA,OACjFI,IAAI,CAACC,GAAG,CAACF,KAAK,GAAG,CAAC,EAAEG,uCAAsB,GAAGL,WAAW,CAAC,IAAIC,SAAS,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAAA;AAACK,OAAA,CAAAR,aAAA,GAAAA,aAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/swipeable-wrapper",
3
- "version": "5.0.0-beta.289",
3
+ "version": "5.0.0-beta.291",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "keywords": [
6
6
  "chayns",
@@ -50,7 +50,8 @@
50
50
  "typescript": "^4.9.5"
51
51
  },
52
52
  "dependencies": {
53
- "@chayns-components/core": "^5.0.0-beta.289",
53
+ "@chayns-components/core": "^5.0.0-beta.291",
54
+ "clsx": "^1.2.1",
54
55
  "framer-motion": "^6.5.1",
55
56
  "uuid": "^9.0.1"
56
57
  },
@@ -62,5 +63,5 @@
62
63
  "publishConfig": {
63
64
  "access": "public"
64
65
  },
65
- "gitHead": "05a64aa69d1d123b96d19b380c2c3e72150d9959"
66
+ "gitHead": "6eb72d14c4cb4fb69688dd373e0e9e3db35e58c1"
66
67
  }