@tapcart/mobile-components 0.7.98 → 0.8.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.
@@ -1,3 +1,5 @@
1
1
  import CartLocalStorage from "./CartLocalStorage";
2
- export { CartLocalStorage };
2
+ import AppStudioCache from "./AppStudioCache";
3
+ import ProductsLocalStorage from "./ProductsLocalStorage";
4
+ export { CartLocalStorage, AppStudioCache, ProductsLocalStorage };
3
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;AAEjD,OAAO,EAAE,gBAAgB,EAAE,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,2 +1,4 @@
1
1
  import CartLocalStorage from "./CartLocalStorage";
2
- export { CartLocalStorage };
2
+ import AppStudioCache from "./AppStudioCache";
3
+ import ProductsLocalStorage from "./ProductsLocalStorage";
4
+ export { CartLocalStorage, AppStudioCache, ProductsLocalStorage };
@@ -1,17 +1,4 @@
1
- import React, { ReactNode } from "react";
2
- export interface SwipeAction {
3
- icon?: ReactNode;
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":"AAEA,OAAO,KAAK,EAAE,EAA+B,SAAS,EAAE,MAAM,OAAO,CAAA;AAGrE,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,SAAS,CAAA;IACnB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAiKvD,CAAA;AAID,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
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 { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useState, useRef, useEffect } from "react";
4
- import { useSwipeable } from "react-swipeable";
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.7.98",
3
+ "version": "0.8.0",
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": "^7.0.2",
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",