@tapcart/mobile-components 0.8.65 → 0.8.67

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 +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;AAK1C,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,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;IACjC,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,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,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,M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,CAAA;QACV,MAAM,EAAE,MAAM,CAAA;KACf,GACD,SAAS,CAAA;CACd,CAAA;AAgCD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,CAuJ7E"}
@@ -39,6 +39,7 @@ export function useProducts(props) {
39
39
  productIds: props === null || props === void 0 ? void 0 : props.productIds,
40
40
  productHandles: props === null || props === void 0 ? void 0 : props.productHandles,
41
41
  }));
42
+ const [isProductResponseReady, setIsProductResponseReady] = React.useState((productResponse === null || productResponse === void 0 ? void 0 : productResponse.length) > 0);
42
43
  if (isUseProductsProps(props)) {
43
44
  let { baseURL, productIds, variantIds, productHandles, metafields, collection, queryVariables, } = props;
44
45
  if (shouldMockProducts) {
@@ -109,23 +110,29 @@ export function useProducts(props) {
109
110
  const cachedProduct = productsLocalStorage.setCacheItem(product);
110
111
  return cachedProduct;
111
112
  };
112
- // set local state when when SWR data is updated
113
+ /**
114
+ * Sync local state with incoming swr response data.
115
+ * If the response contains a `products` envelope, it will be extracted.
116
+ */
113
117
  React.useEffect(() => {
114
- if (!data)
118
+ if (isLoading) {
115
119
  return;
116
- // Determine the products array from data
117
- const productsArray = Array.isArray(data) ? data : data.products || [];
118
- if (!(productsArray === null || productsArray === void 0 ? void 0 : productsArray.length))
119
- return;
120
- setProductResponse(productsArray);
121
- }, [data]);
120
+ }
121
+ if (data) {
122
+ const productsArray = Array.isArray(data) ? data : data.products || [];
123
+ if (productsArray.length > 0) {
124
+ setProductResponse(productsArray);
125
+ }
126
+ }
127
+ setIsProductResponseReady(true);
128
+ }, [isLoading, data]);
122
129
  return {
123
130
  products: formatProductData({
124
131
  data: productResponse,
125
132
  onlyAvailableProducts: (props === null || props === void 0 ? void 0 : props.mock) && (props === null || props === void 0 ? void 0 : props.onlyAvailableProducts),
126
133
  }),
127
134
  error,
128
- isLoading: !(productResponse === null || productResponse === void 0 ? void 0 : productResponse.length) && isLoading,
135
+ isLoading: !isProductResponseReady,
129
136
  isRefreshing: isLoading,
130
137
  cacheProduct,
131
138
  };
@@ -1,5 +1,7 @@
1
- import { Collection, Product } from "app-studio-types";
1
+ import { Collection, Product, BaseSearchClient } from "app-studio-types";
2
2
  interface UseRecommendationProps {
3
+ searchClient?: BaseSearchClient<Product>;
4
+ query?: string;
3
5
  queryVariables: Record<string, any>;
4
6
  apiURL: string;
5
7
  }
@@ -10,6 +12,6 @@ interface UseRecommendationReturn {
10
12
  isLoading: boolean;
11
13
  error: any;
12
14
  }
13
- declare const useRecommendations: ({ queryVariables, apiURL, }: UseRecommendationProps) => UseRecommendationReturn;
15
+ declare const useRecommendations: ({ searchClient, query, queryVariables, apiURL, }: UseRecommendationProps) => UseRecommendationReturn;
14
16
  export { useRecommendations };
15
17
  //# sourceMappingURL=use-recommendations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-recommendations.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-recommendations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAOtD,UAAU,sBAAsB;IAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AASD,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;CACX;AAiBD,QAAA,MAAM,kBAAkB,gCAGrB,sBAAsB,KAAG,uBA6D3B,CAAA;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
1
+ {"version":3,"file":"use-recommendations.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-recommendations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAOxE,UAAU,sBAAsB;IAE9B,YAAY,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,MAAM,CAAA;IAGd,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AASD,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;CACX;AAiBD,QAAA,MAAM,kBAAkB,qDAQrB,sBAAsB,KAAG,uBA6F3B,CAAA;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
@@ -22,13 +22,33 @@ const getCollections = (collections) => {
22
22
  : [];
23
23
  };
24
24
  const recommendationsLocalStorage = new RecommendationsLocalStorage();
25
- const useRecommendations = ({ queryVariables, apiURL, }) => {
25
+ const useRecommendations = ({
26
+ // Search client props
27
+ searchClient, query = "",
28
+ // API props (backwards compatibility)
29
+ queryVariables, apiURL, }) => {
30
+ // When searchClient is provided, use search client approach
31
+ const usingSearchClient = Boolean(searchClient);
26
32
  const searchParams = useSearchParams();
27
- const recommendation = (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("recommendation")) || "";
33
+ const recommendation = usingSearchClient
34
+ ? query
35
+ : (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("recommendation")) || "";
28
36
  const [cachedRecommendation, setCachedRecommendations] = React.useState(recommendationsLocalStorage.getCacheItem({
29
37
  id: `${recommendation}-${queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.language}`,
30
38
  }));
31
- const fetcher = (body) => fetch(constructURL(apiURL), {
39
+ // Search client fetcher
40
+ const searchClientFetcher = () => __awaiter(void 0, void 0, void 0, function* () {
41
+ if (!searchClient)
42
+ return null;
43
+ // Call searchClient.getRecommendations (returns string[] directly)
44
+ const recommendations = yield searchClient.getRecommendations({
45
+ query: recommendation,
46
+ });
47
+ // Format as expected by the hook
48
+ return Object.assign(Object.assign({}, recommendations), { collections: [] });
49
+ });
50
+ // API fetcher (backwards compatibility)
51
+ const apiFetcher = (body) => fetch(constructURL(apiURL), {
32
52
  method: "POST",
33
53
  body: JSON.stringify(body),
34
54
  }).then((res) => __awaiter(void 0, void 0, void 0, function* () {
@@ -38,11 +58,20 @@ const useRecommendations = ({ queryVariables, apiURL, }) => {
38
58
  }
39
59
  return data;
40
60
  }));
41
- const { data, error, isLoading } = useSWR({
42
- appId: queryVariables.appId,
43
- query: recommendation,
44
- language: queryVariables.language,
45
- }, fetcher, {
61
+ // Determine which approach to use
62
+ const swrKey = usingSearchClient
63
+ ? {
64
+ type: "searchClient",
65
+ query: recommendation,
66
+ language: queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.language,
67
+ }
68
+ : {
69
+ appId: queryVariables.appId,
70
+ query: recommendation,
71
+ language: queryVariables.language,
72
+ };
73
+ const fetcher = usingSearchClient ? searchClientFetcher : apiFetcher;
74
+ const { data, error, isLoading } = useSWR(swrKey, usingSearchClient ? fetcher : (body) => apiFetcher(body), {
46
75
  revalidateOnFocus: false,
47
76
  revalidateOnReconnect: false,
48
77
  });
@@ -1 +1 @@
1
- {"version":3,"file":"progress-bar.d.ts","sourceRoot":"","sources":["../../../components/ui/progress-bar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoD,MAAM,OAAO,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAGhD,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,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,EAAE;QACjB,KAAK,EAAE,MAAM,CAAA;QACb,GAAG,EAAE,MAAM,CAAA;QAEX,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE;YACV,KAAK,CAAC,EAAE,MAAM,CAAA;YACd,QAAQ,CAAC,EAAE,MAAM,CAAA;YACjB,UAAU,CAAC,EAAE,MAAM,CAAA;SACpB,CAAA;QACD,WAAW,CAAC,EAAE;YACZ,eAAe,CAAC,EAAE,MAAM,CAAA;YACxB,IAAI,CAAC,EAAE,MAAM,CAAA;SACd,CAAA;QACD,cAAc,CAAC,EAAE,OAAO,CAAA;KACzB,CAAA;CACF;AAID,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA8N3C,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -125,9 +125,7 @@ const ProgressBar = ({ progress, borderStyle, emptyColor, corners, fillColor, an
125
125
  left: `${position}%`,
126
126
  top: "50%",
127
127
  transform: "translateY(-50%)",
128
- } }, { children: [_jsx("div", { className: "rounded-full bg-gray-300 transform -translate-x-1/2 opacity-50", style: Object.assign({ zIndex: 2, width: `${markerSize}px`, height: `${markerSize}px` }, milestoneMarkers === null || milestoneMarkers === void 0 ? void 0 : milestoneMarkers.markerStyle) }), _jsx("div", Object.assign({ className: "text-xs text-gray-500 transform -translate-x-1/2 transition-all opacity-50", style: Object.assign({ position: "absolute", top: `${height + 8}px`, whiteSpace: "nowrap", transform: isAnimating
129
- ? "scale(1.5) translateX(-40%)"
130
- : "translateX(-50%)", fontWeight: isAnimating ? "bold" : undefined, transition: "transform 0.3s ease, font-weight 0.3s ease" }, milestoneMarkers === null || milestoneMarkers === void 0 ? void 0 : milestoneMarkers.textStyle) }, { children: Math.round(value) }))] }), `milestone-${value}`));
128
+ } }, { children: [_jsx("div", { className: "rounded-full bg-gray-300 transform -translate-x-1/2 opacity-50", style: Object.assign({ zIndex: 2, width: `${markerSize}px`, height: `${markerSize}px` }, milestoneMarkers === null || milestoneMarkers === void 0 ? void 0 : milestoneMarkers.markerStyle) }), _jsx("div", Object.assign({ className: "text-xs text-gray-500 transform -translate-x-1/2 transition-all opacity-50", style: Object.assign({ position: "absolute", top: `${height + 8}px`, whiteSpace: "nowrap", transform: "translateX(-50%)", transition: "transform 0.3s ease, font-weight 0.3s ease" }, milestoneMarkers === null || milestoneMarkers === void 0 ? void 0 : milestoneMarkers.textStyle) }, { children: Math.round(value) }))] }), `milestone-${value}`));
131
129
  });
132
130
  return markers;
133
131
  }, [milestonePositions, milestoneMarkers, animatedMarkers, height]);
package/dist/styles.css CHANGED
@@ -1045,12 +1045,18 @@ video {
1045
1045
  .h-\[130px\] {
1046
1046
  height: 130px;
1047
1047
  }
1048
+ .h-\[16px\] {
1049
+ height: 16px;
1050
+ }
1048
1051
  .h-\[1px\] {
1049
1052
  height: 1px;
1050
1053
  }
1051
1054
  .h-\[22px\] {
1052
1055
  height: 22px;
1053
1056
  }
1057
+ .h-\[30px\] {
1058
+ height: 30px;
1059
+ }
1054
1060
  .h-\[30vh\] {
1055
1061
  height: 30vh;
1056
1062
  }
@@ -1172,6 +1178,9 @@ video {
1172
1178
  .w-\[138px\] {
1173
1179
  width: 138px;
1174
1180
  }
1181
+ .w-\[16px\] {
1182
+ width: 16px;
1183
+ }
1175
1184
  .w-\[1px\] {
1176
1185
  width: 1px;
1177
1186
  }
@@ -1468,6 +1477,9 @@ video {
1468
1477
  .gap-2\.5 {
1469
1478
  gap: 0.625rem;
1470
1479
  }
1480
+ .gap-3 {
1481
+ gap: 0.75rem;
1482
+ }
1471
1483
  .gap-4 {
1472
1484
  gap: 1rem;
1473
1485
  }
@@ -2630,10 +2642,6 @@ body::-webkit-scrollbar {
2630
2642
  background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
2631
2643
  }
2632
2644
 
2633
- .hover\:no-underline:hover {
2634
- text-decoration-line: none;
2635
- }
2636
-
2637
2645
  .hover\:opacity-90:hover {
2638
2646
  opacity: 0.9;
2639
2647
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.8.65",
3
+ "version": "0.8.67",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",