@tapcart/mobile-components 0.7.99 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/hooks/use-products.d.ts.map +1 -1
- package/dist/components/hooks/use-products.js +3 -1
- package/dist/components/libs/cache/index.d.ts +2 -1
- package/dist/components/libs/cache/index.d.ts.map +1 -1
- package/dist/components/libs/cache/index.js +2 -1
- package/dist/components/ui/animate-container.d.ts +0 -1
- package/dist/components/ui/animate-container.d.ts.map +1 -1
- package/dist/components/ui/animate-container.js +2 -14
- package/dist/components/ui/swipeable-list-item.d.ts +3 -16
- package/dist/components/ui/swipeable-list-item.d.ts.map +1 -1
- package/dist/components/ui/swipeable-list-item.js +3 -116
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-products.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-products.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAM1C,KAAK,GAAG,GAAG,MAAM,CAAA;AACjB,KAAK,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AACxD,KAAK,gBAAgB,GAAG;IACtB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,OAAO,EAAE,GAAG,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1E,UAAU,CAAC,EAAE,cAAc,EAAE,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,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ACd,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AACD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;IACrB,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,KAC3B;QACE,EAAE,EAAE,MAAM,CAAA;QACV,MAAM,EAAE,MAAM,CAAA;KACf,GACD,SAAS,CAAA;CACd,CAAA;AAgCD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,CAuI7E"}
|
|
@@ -107,8 +107,10 @@ export function useProducts(props) {
|
|
|
107
107
|
};
|
|
108
108
|
// set local state when when SWR data is updated
|
|
109
109
|
React.useEffect(() => {
|
|
110
|
-
if (!data)
|
|
110
|
+
if (!data) {
|
|
111
|
+
setCachedProducts([]);
|
|
111
112
|
return;
|
|
113
|
+
}
|
|
112
114
|
// Determine the products array from data
|
|
113
115
|
const productsArray = Array.isArray(data) ? data : data.products || [];
|
|
114
116
|
if (!productsArray.length)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import CartLocalStorage from "./CartLocalStorage";
|
|
2
2
|
import AppStudioCache from "./AppStudioCache";
|
|
3
|
-
|
|
3
|
+
import ProductsLocalStorage from "./ProductsLocalStorage";
|
|
4
|
+
export { CartLocalStorage, AppStudioCache, ProductsLocalStorage };
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/libs/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,cAAc,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/libs/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AAEzD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import CartLocalStorage from "./CartLocalStorage";
|
|
2
2
|
import AppStudioCache from "./AppStudioCache";
|
|
3
|
-
|
|
3
|
+
import ProductsLocalStorage from "./ProductsLocalStorage";
|
|
4
|
+
export { CartLocalStorage, AppStudioCache, ProductsLocalStorage };
|
|
@@ -15,6 +15,5 @@ interface AnimateContainerProps {
|
|
|
15
15
|
hasData?: boolean;
|
|
16
16
|
}
|
|
17
17
|
export declare function AnimateContainer({ children, animations, duration, className, isLoading, hasData, }: AnimateContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export declare function SlideUp(props: Omit<AnimateContainerProps, "type">): import("react/jsx-runtime").JSX.Element;
|
|
19
18
|
export {};
|
|
20
19
|
//# sourceMappingURL=animate-container.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animate-container.d.ts","sourceRoot":"","sources":["../../../components/ui/animate-container.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAG1D,KAAK,aAAa,GAAG,OAAO,GAAG,MAAM,CAAA;AAErC,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE,eAAe,CAW7D,CAAA;AAED,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,UAAU,EAAE,eAAe,EAAE,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,UAAU,EACV,QAAc,EACd,SAAS,EACT,SAAS,EACT,OAAO,GACR,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"animate-container.d.ts","sourceRoot":"","sources":["../../../components/ui/animate-container.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAG1D,KAAK,aAAa,GAAG,OAAO,GAAG,MAAM,CAAA;AAErC,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE,eAAe,CAW7D,CAAA;AAED,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,UAAU,EAAE,eAAe,EAAE,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,UAAU,EACV,QAAc,EACd,SAAS,EACT,SAAS,EACT,OAAO,GACR,EAAE,qBAAqB,2CAgCvB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
4
|
import { cn } from "../../lib/utils";
|
|
5
5
|
export const Animations = {
|
|
6
6
|
slide: {
|
|
@@ -16,8 +16,6 @@ export const Animations = {
|
|
|
16
16
|
};
|
|
17
17
|
export function AnimateContainer({ children, animations, duration = 300, className, isLoading, hasData, }) {
|
|
18
18
|
const contentRef = useRef(null);
|
|
19
|
-
const [prevData, setPrevData] = useState(hasData !== null && hasData !== void 0 ? hasData : false);
|
|
20
|
-
const [shouldAnimate, setShouldAnimate] = useState(false);
|
|
21
19
|
useEffect(() => {
|
|
22
20
|
if (contentRef.current &&
|
|
23
21
|
(animations === null || animations === void 0 ? void 0 : animations.some((animation) => animation.isHeight))) {
|
|
@@ -25,21 +23,11 @@ export function AnimateContainer({ children, animations, duration = 300, classNa
|
|
|
25
23
|
}
|
|
26
24
|
if (isLoading)
|
|
27
25
|
return;
|
|
28
|
-
|
|
29
|
-
setShouldAnimate(true);
|
|
30
|
-
setPrevData(hasData !== null && hasData !== void 0 ? hasData : false);
|
|
31
|
-
}
|
|
32
|
-
}, [hasData, isLoading, animations, prevData]);
|
|
26
|
+
}, [isLoading, animations]);
|
|
33
27
|
const getAnimationClasses = () => {
|
|
34
|
-
if (!shouldAnimate)
|
|
35
|
-
return "";
|
|
36
28
|
return animations
|
|
37
29
|
.map((animation) => (hasData ? animation.enter : animation.exit))
|
|
38
30
|
.join(" ");
|
|
39
31
|
};
|
|
40
32
|
return (_jsx("div", Object.assign({ ref: contentRef, className: cn("overflow-hidden", getAnimationClasses(), className), style: { animationDuration: `${duration}ms` } }, { children: children })));
|
|
41
33
|
}
|
|
42
|
-
// TO REMOVE
|
|
43
|
-
export function SlideUp(props) {
|
|
44
|
-
return _jsx(AnimateContainer, Object.assign({}, props, { animations: [Animations.slide] }));
|
|
45
|
-
}
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
color?: string;
|
|
5
|
-
onPress: () => void;
|
|
6
|
-
closeOnAction?: boolean;
|
|
7
|
-
key?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface SwipeableListItemProps {
|
|
10
|
-
children: ReactNode;
|
|
11
|
-
actions: SwipeAction[];
|
|
12
|
-
actionWidth?: number;
|
|
13
|
-
threshold?: number;
|
|
14
|
-
}
|
|
15
|
-
declare const SwipeableListItem: React.FC<SwipeableListItemProps>;
|
|
16
|
-
export { SwipeableListItem };
|
|
1
|
+
import { LeadingActions, SwipeableList, SwipeableListItem, SwipeAction, TrailingActions, Type as ListType } from "react-swipeable-list";
|
|
2
|
+
import "react-swipeable-list/dist/styles.css";
|
|
3
|
+
export { LeadingActions, SwipeableList, SwipeableListItem, SwipeAction, TrailingActions, ListType, };
|
|
17
4
|
//# sourceMappingURL=swipeable-list-item.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swipeable-list-item.d.ts","sourceRoot":"","sources":["../../../components/ui/swipeable-list-item.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"swipeable-list-item.d.ts","sourceRoot":"","sources":["../../../components/ui/swipeable-list-item.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,IAAI,IAAI,QAAQ,EACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,sCAAsC,CAAA;AAE7C,OAAO,EACL,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,QAAQ,GACT,CAAA"}
|
|
@@ -1,117 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const SwipeableListItem = ({ children, actions = [], actionWidth = 52, threshold = 0.3, }) => {
|
|
6
|
-
const [offset, setOffset] = useState(0);
|
|
7
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
8
|
-
const [initialDirection, setInitialDirection] = useState(null);
|
|
9
|
-
const totalActionsWidth = actionWidth * actions.length;
|
|
10
|
-
const thresholdPixels = totalActionsWidth * threshold;
|
|
11
|
-
const itemRef = useRef(null);
|
|
12
|
-
const closeItem = () => {
|
|
13
|
-
setIsOpen(false);
|
|
14
|
-
setOffset(0);
|
|
15
|
-
};
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
const handleClickOutside = (event) => {
|
|
18
|
-
if (itemRef.current && !itemRef.current.contains(event.target)) {
|
|
19
|
-
closeItem();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
if (isOpen) {
|
|
23
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
24
|
-
}
|
|
25
|
-
return () => {
|
|
26
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
27
|
-
};
|
|
28
|
-
}, [isOpen]);
|
|
29
|
-
const isHorizontalSwipe = (deltaX, deltaY) => {
|
|
30
|
-
return Math.abs(deltaX) > Math.abs(deltaY) * 1.5;
|
|
31
|
-
};
|
|
32
|
-
const handlers = useSwipeable({
|
|
33
|
-
onSwipeStart: (event) => {
|
|
34
|
-
if (Math.abs(event.deltaX) > 10 || Math.abs(event.deltaY) > 10) {
|
|
35
|
-
const isHorizontal = isHorizontalSwipe(event.deltaX, event.deltaY);
|
|
36
|
-
setInitialDirection(isHorizontal ? "horizontal" : "vertical");
|
|
37
|
-
if (!isHorizontal && event.event.cancelable) {
|
|
38
|
-
event.event.stopPropagation();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
onSwiping: (event) => {
|
|
43
|
-
if (initialDirection === "vertical")
|
|
44
|
-
return;
|
|
45
|
-
if (!initialDirection &&
|
|
46
|
-
(Math.abs(event.deltaX) > 10 || Math.abs(event.deltaY) > 10)) {
|
|
47
|
-
const isHorizontal = isHorizontalSwipe(event.deltaX, event.deltaY);
|
|
48
|
-
setInitialDirection(isHorizontal ? "horizontal" : "vertical");
|
|
49
|
-
if (!isHorizontal)
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (initialDirection === "horizontal") {
|
|
53
|
-
let newOffset = 0;
|
|
54
|
-
if (event.event.cancelable) {
|
|
55
|
-
event.event.preventDefault();
|
|
56
|
-
event.event.stopPropagation();
|
|
57
|
-
}
|
|
58
|
-
if (event.dir === "Left") {
|
|
59
|
-
newOffset = Math.min(event.absX, totalActionsWidth);
|
|
60
|
-
}
|
|
61
|
-
else if (event.dir === "Right" && isOpen) {
|
|
62
|
-
newOffset = Math.max(totalActionsWidth - event.absX, 0);
|
|
63
|
-
}
|
|
64
|
-
setOffset(newOffset);
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
onSwipedLeft: () => {
|
|
68
|
-
if (initialDirection === "horizontal") {
|
|
69
|
-
if (offset > thresholdPixels) {
|
|
70
|
-
setIsOpen(true);
|
|
71
|
-
setOffset(totalActionsWidth);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
closeItem();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
setInitialDirection(null);
|
|
78
|
-
},
|
|
79
|
-
onSwipedRight: () => {
|
|
80
|
-
if (initialDirection === "horizontal") {
|
|
81
|
-
closeItem();
|
|
82
|
-
}
|
|
83
|
-
setInitialDirection(null);
|
|
84
|
-
},
|
|
85
|
-
onSwiped: () => {
|
|
86
|
-
setInitialDirection(null);
|
|
87
|
-
},
|
|
88
|
-
trackMouse: true,
|
|
89
|
-
trackTouch: true,
|
|
90
|
-
delta: 5,
|
|
91
|
-
preventScrollOnSwipe: false,
|
|
92
|
-
rotationAngle: 0,
|
|
93
|
-
});
|
|
94
|
-
return (_jsxs("div", Object.assign({ ref: itemRef, className: "relative overflow-hidden" }, { children: [_jsx("div", Object.assign({ className: "absolute top-0 right-0 h-full flex", "aria-label": "Action buttons", style: {
|
|
95
|
-
width: `${totalActionsWidth}px`,
|
|
96
|
-
} }, { children: actions.map((action, index) => {
|
|
97
|
-
return (_jsx("div", Object.assign({ className: "h-full flex items-center justify-center", style: {
|
|
98
|
-
width: `${actionWidth}px`,
|
|
99
|
-
backgroundColor: action.color || "#e5e5e5",
|
|
100
|
-
} }, { children: _jsx("button", Object.assign({ onClick: () => {
|
|
101
|
-
action.onPress();
|
|
102
|
-
if (action.closeOnAction !== false) {
|
|
103
|
-
closeItem();
|
|
104
|
-
}
|
|
105
|
-
}, className: "w-full h-full flex items-center justify-center" }, { children: action.icon && _jsx(_Fragment, { children: action.icon }) })) }), action.key || index));
|
|
106
|
-
}) })), _jsx("div", Object.assign({}, handlers, { className: "w-full transition-transform duration-200 ease-out relative", style: {
|
|
107
|
-
transform: `translateX(-${offset}px)`,
|
|
108
|
-
transition: offset === 0 || offset === totalActionsWidth
|
|
109
|
-
? "transform 0.2s ease-out"
|
|
110
|
-
: "none",
|
|
111
|
-
zIndex: 10,
|
|
112
|
-
backgroundColor: "inherit",
|
|
113
|
-
touchAction: initialDirection === "horizontal" ? "none" : "auto",
|
|
114
|
-
}, role: "button", "aria-expanded": isOpen }, { children: children }))] })));
|
|
115
|
-
};
|
|
116
|
-
SwipeableListItem.displayName = "SwipeableListItem";
|
|
117
|
-
export { SwipeableListItem };
|
|
2
|
+
import { LeadingActions, SwipeableList, SwipeableListItem, SwipeAction, TrailingActions, Type as ListType, } from "react-swipeable-list";
|
|
3
|
+
import "react-swipeable-list/dist/styles.css";
|
|
4
|
+
export { LeadingActions, SwipeableList, SwipeableListItem, SwipeAction, TrailingActions, ListType, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapcart/mobile-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/styles.css",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"react-circular-progressbar": "2.2.0",
|
|
89
89
|
"react-intersection-observer": "^9.10.2",
|
|
90
90
|
"react-svg": "^16.1.34",
|
|
91
|
-
"react-swipeable": "^
|
|
91
|
+
"react-swipeable-list": "^1.10.0",
|
|
92
92
|
"react-virtual": "^2.10.4",
|
|
93
93
|
"swr": "^2.2.5",
|
|
94
94
|
"tailwind-merge": "^1.13.2",
|