@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.
@@ -19,6 +19,9 @@ export declare const useMockCart: ({ apiUrl, appId, enabled, limit, }: UseMockCa
19
19
  subtotal: number;
20
20
  items: {
21
21
  id: string;
22
+ title: any;
23
+ featuredImage: string;
24
+ image: string;
22
25
  discounts: {
23
26
  amount: number;
24
27
  code: string;
@@ -1 +1 @@
1
- {"version":3,"file":"use-mock-cart.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-mock-cart.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAA;AAsLhF,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCnB,CAAA"}
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 { products, error: productsError, isLoading: productsLoading, } = useProducts({
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: productsLoading,
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6FF,CAAA"}
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"}