@tapcart/mobile-components 0.8.47 → 0.8.49
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-mock-cart.d.ts +3 -0
- package/dist/components/hooks/use-mock-cart.d.ts.map +1 -1
- package/dist/components/hooks/use-mock-cart.js +19 -2
- package/dist/components/ui/Input/useInput.d.ts +1 -10
- package/dist/components/ui/Input/useInput.d.ts.map +1 -1
- package/dist/components/ui/button.d.ts +825 -8
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/chip.d.ts +2 -2
- package/dist/components/ui/favorite.d.ts +1 -1
- package/dist/components/ui/progress-bar.d.ts.map +1 -1
- package/dist/components/ui/progress-bar.js +68 -59
- package/dist/components/ui/quantity-picker.d.ts +3 -1
- package/dist/components/ui/quantity-picker.d.ts.map +1 -1
- package/dist/components/ui/quantity-picker.js +49 -12
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/lib/cart.util.d.ts +8 -15
- package/dist/lib/cart.util.d.ts.map +1 -1
- package/dist/lib/cart.util.js +21 -12
- package/dist/lib/utils.d.ts +832 -18
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/lib/variablesCart.util.d.ts +35 -0
- package/dist/lib/variablesCart.util.d.ts.map +1 -0
- package/dist/lib/variablesCart.util.js +236 -0
- package/dist/lib/variablesCart.util.test.d.ts +2 -0
- package/dist/lib/variablesCart.util.test.d.ts.map +1 -0
- package/dist/lib/variablesCart.util.test.js +387 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mock-cart.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-mock-cart.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-mock-cart.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-mock-cart.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAA;AAyLhF,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,WAAW,uCAKrB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CnB,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
"use client";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
2
4
|
import { getCalculatedCartData } from "../../lib/cart.util";
|
|
3
5
|
import { getIdFromGid } from "../../lib/utils";
|
|
4
6
|
import { useProducts } from "./use-products";
|
|
@@ -32,6 +34,7 @@ const cartMock = {
|
|
|
32
34
|
const transformCart = ({ products, cartOrigin = cartMock, }) => {
|
|
33
35
|
let subtotal = cartOrigin.subtotal;
|
|
34
36
|
const items = products.map((product, i) => {
|
|
37
|
+
var _a, _b;
|
|
35
38
|
const variant = Object.assign(Object.assign({}, product.variants[0]), { compareAtPrice: {
|
|
36
39
|
amount: (parseInt(product.variants[0].price.amount) * 1.2).toString(),
|
|
37
40
|
currencyCode: "USD",
|
|
@@ -85,6 +88,9 @@ const transformCart = ({ products, cartOrigin = cartMock, }) => {
|
|
|
85
88
|
: undefined;
|
|
86
89
|
return {
|
|
87
90
|
id: `item-${i}`,
|
|
91
|
+
title: product.title,
|
|
92
|
+
featuredImage: (_a = product.images[0]) === null || _a === void 0 ? void 0 : _a.url,
|
|
93
|
+
image: (_b = product.images[0]) === null || _b === void 0 ? void 0 : _b.url,
|
|
88
94
|
discounts,
|
|
89
95
|
productId,
|
|
90
96
|
quantity: 1,
|
|
@@ -154,7 +160,9 @@ const transformCart = ({ products, cartOrigin = cartMock, }) => {
|
|
|
154
160
|
cost });
|
|
155
161
|
};
|
|
156
162
|
export const useMockCart = ({ apiUrl, appId, enabled = true, limit = 3, }) => {
|
|
157
|
-
const
|
|
163
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
164
|
+
const [initialLoadHappened, setInitialLoadHappened] = useState(false);
|
|
165
|
+
const { products, error: productsError, isRefreshing: productsLoading, } = useProducts({
|
|
158
166
|
productIds: [],
|
|
159
167
|
productHandles: [],
|
|
160
168
|
baseURL: apiUrl,
|
|
@@ -165,6 +173,15 @@ export const useMockCart = ({ apiUrl, appId, enabled = true, limit = 3, }) => {
|
|
|
165
173
|
mock: enabled,
|
|
166
174
|
onlyAvailableProducts: true,
|
|
167
175
|
});
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
if (productsLoading && !initialLoadHappened) {
|
|
178
|
+
setInitialLoadHappened(true);
|
|
179
|
+
setIsLoading(productsLoading);
|
|
180
|
+
}
|
|
181
|
+
else if (!productsLoading && initialLoadHappened) {
|
|
182
|
+
setIsLoading(false);
|
|
183
|
+
}
|
|
184
|
+
}, [productsLoading, initialLoadHappened]);
|
|
168
185
|
if (!enabled)
|
|
169
186
|
return {
|
|
170
187
|
error: { message: "cart mock skipped" },
|
|
@@ -174,7 +191,7 @@ export const useMockCart = ({ apiUrl, appId, enabled = true, limit = 3, }) => {
|
|
|
174
191
|
const cart = transformCart({ products });
|
|
175
192
|
return {
|
|
176
193
|
error: productsError,
|
|
177
|
-
isLoading
|
|
194
|
+
isLoading,
|
|
178
195
|
cart: Object.assign(Object.assign({}, cart), { calculatedData: getCalculatedCartData(cart) }),
|
|
179
196
|
};
|
|
180
197
|
};
|
|
@@ -36,15 +36,6 @@ export declare const useInput: (props: Pick<InputProps, "asChild" | "icon" | "ic
|
|
|
36
36
|
inputBgColor: string | undefined;
|
|
37
37
|
inputBorderColorStyle: string | undefined;
|
|
38
38
|
inputActiveBorderColorStyle: string | undefined;
|
|
39
|
-
labelTextStyle:
|
|
40
|
-
fontStyle?: string | undefined;
|
|
41
|
-
fontFamily: string | undefined;
|
|
42
|
-
fontWeight: string | number | undefined;
|
|
43
|
-
fontSize: string | number;
|
|
44
|
-
color: string | undefined;
|
|
45
|
-
textTransform: string;
|
|
46
|
-
textAlign: "left" | "right" | "center" | "justify";
|
|
47
|
-
textWrap: string;
|
|
48
|
-
} | undefined;
|
|
39
|
+
labelTextStyle: import("react").CSSProperties | undefined;
|
|
49
40
|
};
|
|
50
41
|
//# sourceMappingURL=useInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInput.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/useInput.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAGxD,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,eAAO,MAAM,aAAa;;;mFAkBzB,CAAA;AAED,eAAO,MAAM,QAAQ,UACZ,KACL,UAAU,EACR,SAAS,GACT,MAAM,GACN,SAAS,GACT,cAAc,GACd,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,cAAc,GACd,kBAAkB,GAClB,wBAAwB,GACxB,aAAa,GACb,cAAc,GACd,cAAc,GACd,sBAAsB,GACtB,YAAY,CACf
|
|
1
|
+
{"version":3,"file":"useInput.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/useInput.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAGxD,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,eAAO,MAAM,aAAa;;;mFAkBzB,CAAA;AAED,eAAO,MAAM,QAAQ,UACZ,KACL,UAAU,EACR,SAAS,GACT,MAAM,GACN,SAAS,GACT,cAAc,GACd,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,cAAc,GACd,kBAAkB,GAClB,wBAAwB,GACxB,aAAa,GACb,cAAc,GACd,cAAc,GACd,sBAAsB,GACtB,YAAY,CACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6FF,CAAA"}
|