@shopify/shop-minis-react 0.3.4 → 0.4.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.
Files changed (185) hide show
  1. package/dist/_virtual/index3.js +2 -5
  2. package/dist/_virtual/index3.js.map +1 -1
  3. package/dist/_virtual/index4.js +5 -2
  4. package/dist/_virtual/index4.js.map +1 -1
  5. package/dist/components/MinisContainer.js +11 -10
  6. package/dist/components/MinisContainer.js.map +1 -1
  7. package/dist/hooks/content/useContent.js +12 -18
  8. package/dist/hooks/content/useContent.js.map +1 -1
  9. package/dist/hooks/product/useCuratedProducts.js +9 -11
  10. package/dist/hooks/product/useCuratedProducts.js.map +1 -1
  11. package/dist/hooks/product/usePopularProducts.js +9 -11
  12. package/dist/hooks/product/usePopularProducts.js.map +1 -1
  13. package/dist/hooks/product/useProduct.js +11 -17
  14. package/dist/hooks/product/useProduct.js.map +1 -1
  15. package/dist/hooks/product/useProductList.js +10 -21
  16. package/dist/hooks/product/useProductList.js.map +1 -1
  17. package/dist/hooks/product/useProductLists.js +11 -13
  18. package/dist/hooks/product/useProductLists.js.map +1 -1
  19. package/dist/hooks/product/useProductMedia.js +12 -18
  20. package/dist/hooks/product/useProductMedia.js.map +1 -1
  21. package/dist/hooks/product/useProductSearch.js +34 -27
  22. package/dist/hooks/product/useProductSearch.js.map +1 -1
  23. package/dist/hooks/product/useProductVariants.js +11 -14
  24. package/dist/hooks/product/useProductVariants.js.map +1 -1
  25. package/dist/hooks/product/useProducts.js +12 -11
  26. package/dist/hooks/product/useProducts.js.map +1 -1
  27. package/dist/hooks/product/useRecommendedProducts.js +11 -13
  28. package/dist/hooks/product/useRecommendedProducts.js.map +1 -1
  29. package/dist/hooks/shop/useRecommendedShops.js +11 -13
  30. package/dist/hooks/shop/useRecommendedShops.js.map +1 -1
  31. package/dist/hooks/shop/useShop.js +12 -11
  32. package/dist/hooks/shop/useShop.js.map +1 -1
  33. package/dist/hooks/user/useBuyerAttributes.js +8 -10
  34. package/dist/hooks/user/useBuyerAttributes.js.map +1 -1
  35. package/dist/hooks/user/useCurrentUser.js +7 -9
  36. package/dist/hooks/user/useCurrentUser.js.map +1 -1
  37. package/dist/hooks/user/useFollowedShops.js +11 -14
  38. package/dist/hooks/user/useFollowedShops.js.map +1 -1
  39. package/dist/hooks/user/useOrders.js +7 -9
  40. package/dist/hooks/user/useOrders.js.map +1 -1
  41. package/dist/hooks/user/useRecentProducts.js +11 -13
  42. package/dist/hooks/user/useRecentProducts.js.map +1 -1
  43. package/dist/hooks/user/useRecentShops.js +10 -13
  44. package/dist/hooks/user/useRecentShops.js.map +1 -1
  45. package/dist/hooks/user/useSavedProducts.js +10 -13
  46. package/dist/hooks/user/useSavedProducts.js.map +1 -1
  47. package/dist/hooks/util/useImagePicker.js +13 -6
  48. package/dist/hooks/util/useImagePicker.js.map +1 -1
  49. package/dist/internal/reactQuery/MinisQueryProvider.js +11 -0
  50. package/dist/internal/reactQuery/MinisQueryProvider.js.map +1 -0
  51. package/dist/internal/reactQuery/queryClient.js +33 -0
  52. package/dist/internal/reactQuery/queryClient.js.map +1 -0
  53. package/dist/internal/reactQuery/useShopActionInfiniteQuery.js +52 -0
  54. package/dist/internal/reactQuery/useShopActionInfiniteQuery.js.map +1 -0
  55. package/dist/internal/reactQuery/useShopActionQuery.js +37 -0
  56. package/dist/internal/reactQuery/useShopActionQuery.js.map +1 -0
  57. package/dist/internal/utils/resizeImage.js +61 -0
  58. package/dist/internal/utils/resizeImage.js.map +1 -0
  59. package/dist/providers/ImagePickerProvider.js +123 -102
  60. package/dist/providers/ImagePickerProvider.js.map +1 -1
  61. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/focusManager.js +45 -0
  62. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -0
  63. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js +89 -0
  64. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js.map +1 -0
  65. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js +55 -0
  66. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js.map +1 -0
  67. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutation.js +198 -0
  68. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutation.js.map +1 -0
  69. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js +99 -0
  70. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js.map +1 -0
  71. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js +67 -0
  72. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js.map +1 -0
  73. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js +39 -0
  74. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -0
  75. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/query.js +299 -0
  76. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/query.js.map +1 -0
  77. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryCache.js +80 -0
  78. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryCache.js.map +1 -0
  79. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryClient.js +215 -0
  80. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryClient.js.map +1 -0
  81. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js +300 -0
  82. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -0
  83. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/removable.js +25 -0
  84. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/removable.js.map +1 -0
  85. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/retryer.js +76 -0
  86. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/retryer.js.map +1 -0
  87. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/subscribable.js +21 -0
  88. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/subscribable.js.map +1 -0
  89. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/thenable.js +26 -0
  90. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/thenable.js.map +1 -0
  91. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/utils.js +176 -0
  92. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/utils.js.map +1 -0
  93. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js +7 -0
  94. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js.map +1 -0
  95. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js +17 -0
  96. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js.map +1 -0
  97. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js +19 -0
  98. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js.map +1 -0
  99. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +21 -0
  100. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -0
  101. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/suspense.js +18 -0
  102. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/suspense.js.map +1 -0
  103. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +64 -0
  104. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -0
  105. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js +13 -0
  106. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js.map +1 -0
  107. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useQuery.js +9 -0
  108. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useQuery.js.map +1 -0
  109. package/dist/shop-minis-react/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +1 -1
  110. package/dist/shop-minis-react/node_modules/.pnpm/video.js@8.23.3/node_modules/video.js/dist/video.es.js +1 -1
  111. package/package.json +2 -7
  112. package/src/components/MinisContainer.tsx +6 -3
  113. package/src/hooks/content/useContent.ts +6 -17
  114. package/src/hooks/product/useCuratedProducts.ts +4 -6
  115. package/src/hooks/product/usePopularProducts.ts +4 -6
  116. package/src/hooks/product/useProduct.ts +6 -17
  117. package/src/hooks/product/useProductList.ts +4 -19
  118. package/src/hooks/product/useProductLists.ts +4 -6
  119. package/src/hooks/product/useProductMedia.ts +6 -17
  120. package/src/hooks/product/useProductSearch.ts +19 -15
  121. package/src/hooks/product/useProductVariants.ts +5 -13
  122. package/src/hooks/product/useProducts.ts +8 -12
  123. package/src/hooks/product/useRecommendedProducts.ts +4 -6
  124. package/src/hooks/shop/useRecommendedShops.ts +4 -6
  125. package/src/hooks/shop/useShop.ts +8 -12
  126. package/src/hooks/user/useBuyerAttributes.ts +4 -6
  127. package/src/hooks/user/useCurrentUser.ts +4 -6
  128. package/src/hooks/user/useFollowedShops.ts +5 -13
  129. package/src/hooks/user/useOrders.ts +4 -6
  130. package/src/hooks/user/useRecentProducts.ts +4 -6
  131. package/src/hooks/user/useRecentShops.ts +5 -13
  132. package/src/hooks/user/useSavedProducts.ts +5 -13
  133. package/src/hooks/util/useImagePicker.test.tsx +193 -0
  134. package/src/hooks/util/useImagePicker.ts +24 -5
  135. package/src/internal/reactQuery/MinisQueryProvider.test.tsx +38 -0
  136. package/src/internal/reactQuery/MinisQueryProvider.tsx +16 -0
  137. package/src/internal/reactQuery/index.ts +8 -0
  138. package/src/internal/reactQuery/queryClient.test.tsx +91 -0
  139. package/src/internal/reactQuery/queryClient.ts +43 -0
  140. package/src/internal/reactQuery/useShopActionInfiniteQuery.test.tsx +357 -0
  141. package/src/internal/reactQuery/useShopActionInfiniteQuery.ts +129 -0
  142. package/src/internal/reactQuery/useShopActionQuery.test.tsx +184 -0
  143. package/src/internal/reactQuery/useShopActionQuery.ts +74 -0
  144. package/src/internal/utils/resizeImage.test.ts +314 -0
  145. package/src/internal/utils/resizeImage.ts +108 -0
  146. package/src/providers/ImagePickerProvider.test.tsx +32 -1
  147. package/src/providers/ImagePickerProvider.tsx +108 -65
  148. package/dist/internal/useShopActionsDataFetching.js +0 -79
  149. package/dist/internal/useShopActionsDataFetching.js.map +0 -1
  150. package/dist/internal/useShopActionsPaginatedDataFetching.js +0 -96
  151. package/dist/internal/useShopActionsPaginatedDataFetching.js.map +0 -1
  152. package/src/hooks/product/useProductSearch.test.ts +0 -470
  153. package/src/internal/useShopActionsDataFetching.test.ts +0 -465
  154. package/src/internal/useShopActionsDataFetching.ts +0 -150
  155. package/src/internal/useShopActionsPaginatedDataFetching.ts +0 -188
  156. package/src/stories/Accordion.stories.tsx +0 -124
  157. package/src/stories/AddToCart.stories.tsx +0 -251
  158. package/src/stories/Alert.stories.tsx +0 -38
  159. package/src/stories/AlertDialog.stories.tsx +0 -48
  160. package/src/stories/Avatar.stories.tsx +0 -29
  161. package/src/stories/Badge.stories.tsx +0 -46
  162. package/src/stories/Button.stories.tsx +0 -81
  163. package/src/stories/Card.stories.tsx +0 -40
  164. package/src/stories/Checkbox.stories.tsx +0 -44
  165. package/src/stories/FavoriteButton.stories.tsx +0 -58
  166. package/src/stories/IconButton.stories.tsx +0 -68
  167. package/src/stories/ImageContentWrapper.stories.tsx +0 -65
  168. package/src/stories/Input.stories.tsx +0 -44
  169. package/src/stories/Label.stories.tsx +0 -19
  170. package/src/stories/List.stories.tsx +0 -64
  171. package/src/stories/MerchantCard.stories.tsx +0 -127
  172. package/src/stories/ProductCard.stories.tsx +0 -92
  173. package/src/stories/ProductLink.stories.tsx +0 -46
  174. package/src/stories/ProductVariantPrice.stories.tsx +0 -70
  175. package/src/stories/Progress.stories.tsx +0 -30
  176. package/src/stories/PullToRefreshList.stories.tsx +0 -122
  177. package/src/stories/QuantitySelector.stories.tsx +0 -78
  178. package/src/stories/RadioGroup.stories.tsx +0 -51
  179. package/src/stories/Search.stories.tsx +0 -37
  180. package/src/stories/Select.stories.tsx +0 -85
  181. package/src/stories/Skeleton.stories.tsx +0 -19
  182. package/src/stories/TextInput.stories.tsx +0 -26
  183. package/src/stories/Toaster.stories.tsx +0 -46
  184. package/src/stories/Touchable.stories.tsx +0 -40
  185. package/src/stories/VideoPlayer.stories.tsx +0 -129
@@ -1,8 +1,5 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
- import { __require as o } from "../shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/index.js";
3
- var t = o();
4
- const a = /* @__PURE__ */ r(t);
1
+ var r = {};
5
2
  export {
6
- a as default
3
+ r as __exports
7
4
  };
8
5
  //# sourceMappingURL=index3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +1,8 @@
1
- var r = {};
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
+ import { __require as o } from "../shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/index.js";
3
+ var t = o();
4
+ const a = /* @__PURE__ */ r(t);
2
5
  export {
3
- r as __exports
6
+ a as default
4
7
  };
5
8
  //# sourceMappingURL=index4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -4,12 +4,13 @@ import { useShopActions as v } from "../internal/useShopActions.js";
4
4
  import { injectMocks as y } from "../mocks.js";
5
5
  import { ImagePickerProvider as h } from "../providers/ImagePickerProvider.js";
6
6
  import { ErrorBoundary as E } from "./ErrorBoundary.js";
7
+ import { MinisQueryProvider as g } from "../internal/reactQuery/MinisQueryProvider.js";
7
8
  y();
8
- function b({ children: a }) {
9
- const [i, o] = u(!1), t = v(), c = f(
10
- async (n) => {
9
+ function N({ children: a }) {
10
+ const [i, n] = u(!1), t = v(), c = f(
11
+ async (o) => {
11
12
  try {
12
- t && t.reportError && await t.reportError(n);
13
+ t && t.reportError && await t.reportError(o);
13
14
  } catch (e) {
14
15
  console.error("Failed to report error to app:", e);
15
16
  }
@@ -17,26 +18,26 @@ function b({ children: a }) {
17
18
  [t]
18
19
  );
19
20
  return p(() => {
20
- const n = () => window.minisSDK ? (o(!0), !0) : !1;
21
- if (n())
21
+ const o = () => window.minisSDK ? (n(!0), !0) : !1;
22
+ if (o())
22
23
  return;
23
24
  const e = (d) => {
24
25
  const { type: m } = JSON.parse(d.data);
25
- m === "MINIS_SDK_READY" && o(!0);
26
+ m === "MINIS_SDK_READY" && n(!0);
26
27
  };
27
28
  window.addEventListener("message", e), document.addEventListener("message", e);
28
29
  const s = setInterval(() => {
29
- n() && clearInterval(s);
30
+ o() && clearInterval(s);
30
31
  }, 100);
31
32
  return () => {
32
33
  clearInterval(s), window.removeEventListener("message", e), document.removeEventListener("message", e);
33
34
  };
34
- }, []), i ? /* @__PURE__ */ r(E, { onError: c, children: /* @__PURE__ */ r(h, { children: a }) }) : /* @__PURE__ */ r("div", { className: "h-screen bg-gray-50 flex items-center justify-center", children: /* @__PURE__ */ l("div", { className: "text-center", children: [
35
+ }, []), i ? /* @__PURE__ */ r(g, { children: /* @__PURE__ */ r(E, { onError: c, children: /* @__PURE__ */ r(h, { children: a }) }) }) : /* @__PURE__ */ r("div", { className: "h-screen bg-gray-50 flex items-center justify-center", children: /* @__PURE__ */ l("div", { className: "text-center", children: [
35
36
  /* @__PURE__ */ r("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto mb-4" }),
36
37
  /* @__PURE__ */ r("p", { className: "text-gray-600", children: "Loading..." })
37
38
  ] }) });
38
39
  }
39
40
  export {
40
- b as MinisContainer
41
+ N as MinisContainer
41
42
  };
42
43
  //# sourceMappingURL=MinisContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MinisContainer.js","sources":["../../src/components/MinisContainer.tsx"],"sourcesContent":["import React, {useCallback, useEffect, useState} from 'react'\n\nimport {ReportErrorParams} from '@shopify/shop-minis-platform/actions'\n\nimport {useShopActions} from '../internal/useShopActions'\nimport {injectMocks} from '../mocks'\nimport {ImagePickerProvider} from '../providers/ImagePickerProvider'\n\nimport {ErrorBoundary} from './ErrorBoundary'\n\ninjectMocks()\n\nexport function MinisContainer({children}: {children: React.ReactNode}) {\n const [isSDKReady, setIsSDKReady] = useState(false)\n const actions = useShopActions()\n\n const handleError = useCallback(\n async (params: ReportErrorParams) => {\n try {\n if (actions && actions.reportError) {\n await actions.reportError(params)\n }\n } catch (error) {\n // If reporting fails, at least log to console\n console.error('Failed to report error to app:', error)\n }\n },\n [actions]\n )\n\n useEffect(() => {\n // Function to check if SDK is ready\n const checkSDKReady = () => {\n if (window.minisSDK) {\n setIsSDKReady(true)\n return true\n }\n return false\n }\n\n // Check immediately\n if (checkSDKReady()) {\n return\n }\n\n // If not ready, set up a listener for the MINIS_SDK_READY event\n const handleSDKReady = (event: any) => {\n const {type} = JSON.parse(event.data)\n\n if (type === 'MINIS_SDK_READY') {\n setIsSDKReady(true)\n }\n }\n\n // Listen for the MINIS_SDK_READY event\n window.addEventListener('message', handleSDKReady)\n document.addEventListener('message', handleSDKReady)\n\n // Also poll for SDK availability as a fallback\n const pollInterval = setInterval(() => {\n if (checkSDKReady()) {\n clearInterval(pollInterval)\n }\n }, 100)\n\n // Cleanup\n return () => {\n clearInterval(pollInterval)\n window.removeEventListener('message', handleSDKReady)\n document.removeEventListener('message', handleSDKReady)\n }\n }, [])\n\n // Don't render anything until SDK is ready\n if (!isSDKReady) {\n return (\n <div className=\"h-screen bg-gray-50 flex items-center justify-center\">\n <div className=\"text-center\">\n <div className=\"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto mb-4\" />\n <p className=\"text-gray-600\">Loading...</p>\n </div>\n </div>\n )\n }\n\n return (\n <ErrorBoundary onError={handleError}>\n <ImagePickerProvider>{children}</ImagePickerProvider>\n </ErrorBoundary>\n )\n}\n"],"names":["injectMocks","MinisContainer","children","isSDKReady","setIsSDKReady","useState","actions","useShopActions","handleError","useCallback","params","error","useEffect","checkSDKReady","handleSDKReady","event","type","pollInterval","ErrorBoundary","jsx","ImagePickerProvider","jsxs"],"mappings":";;;;;;AAUAA,EAAY;AAEI,SAAAC,EAAe,EAAC,UAAAC,KAAwC;AACtE,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAS,EAAK,GAC5CC,IAAUC,EAAe,GAEzBC,IAAcC;AAAA,IAClB,OAAOC,MAA8B;AAC/B,UAAA;AACE,QAAAJ,KAAWA,EAAQ,eACf,MAAAA,EAAQ,YAAYI,CAAM;AAAA,eAE3BC,GAAO;AAEN,gBAAA,MAAM,kCAAkCA,CAAK;AAAA,MAAA;AAAA,IAEzD;AAAA,IACA,CAACL,CAAO;AAAA,EACV;AA8CA,SA5CAM,EAAU,MAAM;AAEd,UAAMC,IAAgB,MAChB,OAAO,YACTT,EAAc,EAAI,GACX,MAEF;AAIT,QAAIS;AACF;AAII,UAAAC,IAAiB,CAACC,MAAe;AACrC,YAAM,EAAC,MAAAC,EAAI,IAAI,KAAK,MAAMD,EAAM,IAAI;AAEpC,MAAIC,MAAS,qBACXZ,EAAc,EAAI;AAAA,IAEtB;AAGO,WAAA,iBAAiB,WAAWU,CAAc,GACxC,SAAA,iBAAiB,WAAWA,CAAc;AAG7C,UAAAG,IAAe,YAAY,MAAM;AACrC,MAAIJ,OACF,cAAcI,CAAY;AAAA,OAE3B,GAAG;AAGN,WAAO,MAAM;AACX,oBAAcA,CAAY,GACnB,OAAA,oBAAoB,WAAWH,CAAc,GAC3C,SAAA,oBAAoB,WAAWA,CAAc;AAAA,IACxD;AAAA,EACF,GAAG,EAAE,GAGAX,sBAYFe,GAAc,EAAA,SAASV,GACtB,UAAC,gBAAAW,EAAAC,GAAA,EAAqB,UAAAlB,GAAS,EACjC,CAAA,sBAZG,OAAI,EAAA,WAAU,wDACb,UAAC,gBAAAmB,EAAA,OAAA,EAAI,WAAU,eACb,UAAA;AAAA,IAAC,gBAAAF,EAAA,OAAA,EAAI,WAAU,4EAA4E,CAAA;AAAA,IAC1F,gBAAAA,EAAA,KAAA,EAAE,WAAU,iBAAgB,UAAU,aAAA,CAAA;AAAA,EAAA,EAAA,CACzC,EACF,CAAA;AASN;"}
1
+ {"version":3,"file":"MinisContainer.js","sources":["../../src/components/MinisContainer.tsx"],"sourcesContent":["import React, {useCallback, useEffect, useState} from 'react'\n\nimport {ReportErrorParams} from '@shopify/shop-minis-platform/actions'\n\nimport {MinisQueryProvider} from '../internal/reactQuery'\nimport {useShopActions} from '../internal/useShopActions'\nimport {injectMocks} from '../mocks'\nimport {ImagePickerProvider} from '../providers/ImagePickerProvider'\n\nimport {ErrorBoundary} from './ErrorBoundary'\n\ninjectMocks()\n\nexport function MinisContainer({children}: {children: React.ReactNode}) {\n const [isSDKReady, setIsSDKReady] = useState(false)\n const actions = useShopActions()\n\n const handleError = useCallback(\n async (params: ReportErrorParams) => {\n try {\n if (actions && actions.reportError) {\n await actions.reportError(params)\n }\n } catch (error) {\n // If reporting fails, at least log to console\n console.error('Failed to report error to app:', error)\n }\n },\n [actions]\n )\n\n useEffect(() => {\n // Function to check if SDK is ready\n const checkSDKReady = () => {\n if (window.minisSDK) {\n setIsSDKReady(true)\n return true\n }\n return false\n }\n\n // Check immediately\n if (checkSDKReady()) {\n return\n }\n\n // If not ready, set up a listener for the MINIS_SDK_READY event\n const handleSDKReady = (event: any) => {\n const {type} = JSON.parse(event.data)\n\n if (type === 'MINIS_SDK_READY') {\n setIsSDKReady(true)\n }\n }\n\n // Listen for the MINIS_SDK_READY event\n window.addEventListener('message', handleSDKReady)\n document.addEventListener('message', handleSDKReady)\n\n // Also poll for SDK availability as a fallback\n const pollInterval = setInterval(() => {\n if (checkSDKReady()) {\n clearInterval(pollInterval)\n }\n }, 100)\n\n // Cleanup\n return () => {\n clearInterval(pollInterval)\n window.removeEventListener('message', handleSDKReady)\n document.removeEventListener('message', handleSDKReady)\n }\n }, [])\n\n // Don't render anything until SDK is ready\n if (!isSDKReady) {\n return (\n <div className=\"h-screen bg-gray-50 flex items-center justify-center\">\n <div className=\"text-center\">\n <div className=\"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto mb-4\" />\n <p className=\"text-gray-600\">Loading...</p>\n </div>\n </div>\n )\n }\n\n return (\n <MinisQueryProvider>\n <ErrorBoundary onError={handleError}>\n <ImagePickerProvider>{children}</ImagePickerProvider>\n </ErrorBoundary>\n </MinisQueryProvider>\n )\n}\n"],"names":["injectMocks","MinisContainer","children","isSDKReady","setIsSDKReady","useState","actions","useShopActions","handleError","useCallback","params","error","useEffect","checkSDKReady","handleSDKReady","event","type","pollInterval","jsx","MinisQueryProvider","ErrorBoundary","ImagePickerProvider","jsxs"],"mappings":";;;;;;;AAWAA,EAAY;AAEI,SAAAC,EAAe,EAAC,UAAAC,KAAwC;AACtE,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAS,EAAK,GAC5CC,IAAUC,EAAe,GAEzBC,IAAcC;AAAA,IAClB,OAAOC,MAA8B;AAC/B,UAAA;AACE,QAAAJ,KAAWA,EAAQ,eACf,MAAAA,EAAQ,YAAYI,CAAM;AAAA,eAE3BC,GAAO;AAEN,gBAAA,MAAM,kCAAkCA,CAAK;AAAA,MAAA;AAAA,IAEzD;AAAA,IACA,CAACL,CAAO;AAAA,EACV;AA8CA,SA5CAM,EAAU,MAAM;AAEd,UAAMC,IAAgB,MAChB,OAAO,YACTT,EAAc,EAAI,GACX,MAEF;AAIT,QAAIS;AACF;AAII,UAAAC,IAAiB,CAACC,MAAe;AACrC,YAAM,EAAC,MAAAC,EAAI,IAAI,KAAK,MAAMD,EAAM,IAAI;AAEpC,MAAIC,MAAS,qBACXZ,EAAc,EAAI;AAAA,IAEtB;AAGO,WAAA,iBAAiB,WAAWU,CAAc,GACxC,SAAA,iBAAiB,WAAWA,CAAc;AAG7C,UAAAG,IAAe,YAAY,MAAM;AACrC,MAAIJ,OACF,cAAcI,CAAY;AAAA,OAE3B,GAAG;AAGN,WAAO,MAAM;AACX,oBAAcA,CAAY,GACnB,OAAA,oBAAoB,WAAWH,CAAc,GAC3C,SAAA,oBAAoB,WAAWA,CAAc;AAAA,IACxD;AAAA,EACF,GAAG,EAAE,GAGAX,IAYH,gBAAAe,EAACC,GACC,EAAA,UAAA,gBAAAD,EAACE,GAAc,EAAA,SAASZ,GACtB,UAAC,gBAAAU,EAAAG,GAAA,EAAqB,UAAAnB,EAAS,CAAA,EACjC,CAAA,GACF,sBAdG,OAAI,EAAA,WAAU,wDACb,UAAC,gBAAAoB,EAAA,OAAA,EAAI,WAAU,eACb,UAAA;AAAA,IAAC,gBAAAJ,EAAA,OAAA,EAAI,WAAU,4EAA4E,CAAA;AAAA,IAC1F,gBAAAA,EAAA,KAAA,EAAE,WAAU,iBAAgB,UAAU,aAAA,CAAA;AAAA,EAAA,EAAA,CACzC,EACF,CAAA;AAWN;"}
@@ -1,24 +1,18 @@
1
- import { useMemo as m } from "react";
2
- import { useShopActions as u } from "../../internal/useShopActions.js";
3
- import { useShopActionsDataFetching as a } from "../../internal/useShopActionsDataFetching.js";
4
- const l = (o) => {
5
- const { getContent: e } = u(), { identifiers: n, skip: s = !1, ...r } = o, { data: t, ...i } = a(
6
- e,
7
- {
8
- identifiers: n,
9
- ...r
10
- },
11
- {
12
- skip: s,
13
- hook: "useContent"
14
- }
15
- ), c = m(() => t ?? null, [t]);
1
+ import { useShopActions as i } from "../../internal/useShopActions.js";
2
+ import { useShopActionQuery as p } from "../../internal/reactQuery/useShopActionQuery.js";
3
+ const u = (e) => {
4
+ const { getContent: n } = i(), { identifiers: t, skip: s = !1, ...o } = e, { data: r, ...c } = p(
5
+ ["content", t, o],
6
+ n,
7
+ { identifiers: t, ...o },
8
+ { skip: s }
9
+ );
16
10
  return {
17
- ...i,
18
- content: c
11
+ ...c,
12
+ content: r
19
13
  };
20
14
  };
21
15
  export {
22
- l as useContent
16
+ u as useContent
23
17
  };
24
18
  //# sourceMappingURL=useContent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useContent.js","sources":["../../../src/hooks/content/useContent.ts"],"sourcesContent":["import {useMemo} from 'react'\n\nimport {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'\nimport {\n Content,\n ContentIdentifierInput,\n DataHookOptionsBase,\n DataHookReturnsBase,\n} from '../../types'\n\nexport interface UseContentParams extends DataHookOptionsBase {\n /**\n * The identifiers of the content to fetch.\n */\n identifiers: ContentIdentifierInput | ContentIdentifierInput[]\n}\n\ninterface UseContentReturns extends DataHookReturnsBase {\n /**\n * The content returned from the query.\n */\n content: Content[] | null\n}\n\nexport const useContent = (params: UseContentParams): UseContentReturns => {\n const {getContent} = useShopActions()\n const {identifiers, skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionsDataFetching(\n getContent,\n {\n identifiers,\n ...restParams,\n },\n {\n skip,\n hook: 'useContent',\n }\n )\n\n const content = useMemo(() => {\n return data ?? null\n }, [data])\n\n return {\n ...rest,\n content,\n }\n}\n"],"names":["useContent","params","getContent","useShopActions","identifiers","skip","restParams","data","rest","useShopActionsDataFetching","content","useMemo"],"mappings":";;;AAyBa,MAAAA,IAAa,CAACC,MAAgD;AACnE,QAAA,EAAC,YAAAC,EAAU,IAAIC,EAAe,GAC9B,EAAC,aAAAC,GAAa,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAL,GAE7C,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtBP;AAAA,IACA;AAAA,MACE,aAAAE;AAAA,MACA,GAAGE;AAAA,IACL;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV,GAEMK,IAAUC,EAAQ,MACfJ,KAAQ,MACd,CAACA,CAAI,CAAC;AAEF,SAAA;AAAA,IACL,GAAGC;AAAA,IACH,SAAAE;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"useContent.js","sources":["../../../src/hooks/content/useContent.ts"],"sourcesContent":["import {useShopActionQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n Content,\n ContentIdentifierInput,\n DataHookOptionsBase,\n DataHookReturnsBase,\n} from '../../types'\n\nexport interface UseContentParams extends DataHookOptionsBase {\n /**\n * The identifiers of the content to fetch.\n */\n identifiers: ContentIdentifierInput | ContentIdentifierInput[]\n}\n\ninterface UseContentReturns extends DataHookReturnsBase {\n /**\n * The content returned from the query.\n */\n content: Content[] | null\n}\n\nexport const useContent = (params: UseContentParams): UseContentReturns => {\n const {getContent} = useShopActions()\n const {identifiers, skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionQuery(\n ['content', identifiers, restParams],\n getContent,\n {identifiers, ...restParams},\n {skip}\n )\n\n return {\n ...rest,\n content: data,\n }\n}\n"],"names":["useContent","params","getContent","useShopActions","identifiers","skip","restParams","data","rest","useShopActionQuery"],"mappings":";;AAuBa,MAAAA,IAAa,CAACC,MAAgD;AACnE,QAAA,EAAC,YAAAC,EAAU,IAAIC,EAAe,GAC9B,EAAC,aAAAC,GAAa,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAL,GAE7C,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,WAAWL,GAAaE,CAAU;AAAA,IACnCJ;AAAA,IACA,EAAC,aAAAE,GAAa,GAAGE,EAAU;AAAA,IAC3B,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,SAASD;AAAA,EACX;AACF;"}
@@ -1,20 +1,18 @@
1
1
  import { useShopActions as u } from "../../internal/useShopActions.js";
2
- import { useShopActionsPaginatedDataFetching as a } from "../../internal/useShopActionsPaginatedDataFetching.js";
3
- const i = (t) => {
4
- const { getCuratedProducts: o } = u(), { skip: s, ...r } = t ?? {}, { data: e, ...c } = a(
5
- o,
2
+ import { useShopActionInfiniteQuery as n } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
3
+ const p = (o) => {
4
+ const { getCuratedProducts: r } = u(), { skip: s, ...t } = o ?? {}, { data: c, ...e } = n(
5
+ ["curatedProducts", t],
6
6
  r,
7
- {
8
- skip: s,
9
- hook: "useCuratedProducts"
10
- }
7
+ t,
8
+ { skip: s }
11
9
  );
12
10
  return {
13
- ...c,
14
- products: e
11
+ ...e,
12
+ products: c
15
13
  };
16
14
  };
17
15
  export {
18
- i as useCuratedProducts
16
+ p as useCuratedProducts
19
17
  };
20
18
  //# sourceMappingURL=useCuratedProducts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCuratedProducts.js","sources":["../../../src/hooks/product/useCuratedProducts.ts"],"sourcesContent":["import {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'\nimport {\n Product,\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n} from '../../types'\n\ninterface UseCuratedProductsParams extends PaginatedDataHookOptionsBase {\n handle: string\n requiredTags?: string[]\n anyOfTags?: string[]\n}\n\ninterface UseCuratedProductsReturns extends PaginatedDataHookReturnsBase {\n products: Product[] | null\n}\n\n/**\n * @param options - The options for the query\n */\nexport const useCuratedProducts = (\n params: UseCuratedProductsParams\n): UseCuratedProductsReturns => {\n const {getCuratedProducts} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionsPaginatedDataFetching(\n getCuratedProducts,\n shopActionParams,\n {\n skip,\n hook: 'useCuratedProducts',\n }\n )\n\n return {\n ...rest,\n products: data,\n }\n}\n"],"names":["useCuratedProducts","params","getCuratedProducts","useShopActions","skip","shopActionParams","data","rest","useShopActionsPaginatedDataFetching"],"mappings":";;AAqBa,MAAAA,IAAqB,CAChCC,MAC8B;AACxB,QAAA,EAAC,oBAAAC,EAAkB,IAAIC,EAAe,GACtC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtBN;AAAA,IACAG;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,UAAUD;AAAA,EACZ;AACF;"}
1
+ {"version":3,"file":"useCuratedProducts.js","sources":["../../../src/hooks/product/useCuratedProducts.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n Product,\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n} from '../../types'\n\ninterface UseCuratedProductsParams extends PaginatedDataHookOptionsBase {\n handle: string\n requiredTags?: string[]\n anyOfTags?: string[]\n}\n\ninterface UseCuratedProductsReturns extends PaginatedDataHookReturnsBase {\n products: Product[] | null\n}\n\n/**\n * @param options - The options for the query\n */\nexport const useCuratedProducts = (\n params: UseCuratedProductsParams\n): UseCuratedProductsReturns => {\n const {getCuratedProducts} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['curatedProducts', shopActionParams],\n getCuratedProducts,\n shopActionParams,\n {skip}\n )\n\n return {\n ...rest,\n products: data,\n }\n}\n"],"names":["useCuratedProducts","params","getCuratedProducts","useShopActions","skip","shopActionParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAqBa,MAAAA,IAAqB,CAChCC,MAC8B;AACxB,QAAA,EAAC,oBAAAC,EAAkB,IAAIC,EAAe,GACtC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,mBAAmBH,CAAgB;AAAA,IACpCH;AAAA,IACAG;AAAA,IACA,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,UAAUD;AAAA,EACZ;AACF;"}
@@ -1,20 +1,18 @@
1
- import { useShopActions as a } from "../../internal/useShopActions.js";
2
- import { useShopActionsPaginatedDataFetching as p } from "../../internal/useShopActionsPaginatedDataFetching.js";
3
- const i = (o) => {
4
- const { getPopularProducts: t } = a(), { skip: s, ...r } = o ?? {}, { data: c, ...u } = p(
5
- t,
1
+ import { useShopActions as c } from "../../internal/useShopActions.js";
2
+ import { useShopActionInfiniteQuery as n } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
3
+ const a = (t) => {
4
+ const { getPopularProducts: r } = c(), { skip: s, ...o } = t ?? {}, { data: p, ...u } = n(
5
+ ["popularProducts", o],
6
6
  r,
7
- {
8
- skip: s,
9
- hook: "usePopularProducts"
10
- }
7
+ o,
8
+ { skip: s }
11
9
  );
12
10
  return {
13
11
  ...u,
14
- products: c
12
+ products: p
15
13
  };
16
14
  };
17
15
  export {
18
- i as usePopularProducts
16
+ a as usePopularProducts
19
17
  };
20
18
  //# sourceMappingURL=usePopularProducts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePopularProducts.js","sources":["../../../src/hooks/product/usePopularProducts.ts"],"sourcesContent":["import {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'\nimport {\n Product,\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n} from '../../types'\n\ninterface UsePopularProductsParams extends PaginatedDataHookOptionsBase {}\n\ninterface UsePopularProductsReturns extends PaginatedDataHookReturnsBase {\n products: Product[] | null\n}\n\n/**\n * @param options - The options for the query\n */\nexport const usePopularProducts = (\n params?: UsePopularProductsParams\n): UsePopularProductsReturns => {\n const {getPopularProducts} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionsPaginatedDataFetching(\n getPopularProducts,\n shopActionParams,\n {\n skip,\n hook: 'usePopularProducts',\n }\n )\n\n return {\n ...rest,\n products: data,\n }\n}\n"],"names":["usePopularProducts","params","getPopularProducts","useShopActions","skip","shopActionParams","data","rest","useShopActionsPaginatedDataFetching"],"mappings":";;AAiBa,MAAAA,IAAqB,CAChCC,MAC8B;AACxB,QAAA,EAAC,oBAAAC,EAAkB,IAAIC,EAAe,GACtC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtBN;AAAA,IACAG;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,UAAUD;AAAA,EACZ;AACF;"}
1
+ {"version":3,"file":"usePopularProducts.js","sources":["../../../src/hooks/product/usePopularProducts.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n Product,\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n} from '../../types'\n\ninterface UsePopularProductsParams extends PaginatedDataHookOptionsBase {}\n\ninterface UsePopularProductsReturns extends PaginatedDataHookReturnsBase {\n products: Product[] | null\n}\n\n/**\n * @param options - The options for the query\n */\nexport const usePopularProducts = (\n params?: UsePopularProductsParams\n): UsePopularProductsReturns => {\n const {getPopularProducts} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['popularProducts', shopActionParams],\n getPopularProducts,\n shopActionParams,\n {skip}\n )\n\n return {\n ...rest,\n products: data,\n }\n}\n"],"names":["usePopularProducts","params","getPopularProducts","useShopActions","skip","shopActionParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAiBa,MAAAA,IAAqB,CAChCC,MAC8B;AACxB,QAAA,EAAC,oBAAAC,EAAkB,IAAIC,EAAe,GACtC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,mBAAmBH,CAAgB;AAAA,IACpCH;AAAA,IACAG;AAAA,IACA,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,UAAUD;AAAA,EACZ;AACF;"}
@@ -1,24 +1,18 @@
1
- import { useMemo as i } from "react";
2
- import { useShopActions as m } from "../../internal/useShopActions.js";
3
- import { useShopActionsDataFetching as p } from "../../internal/useShopActionsDataFetching.js";
4
- const h = (t) => {
5
- const { getProduct: r } = m(), { id: s, skip: e = !1, ...c } = t, { data: o, ...u } = p(
6
- r,
7
- {
8
- id: s,
9
- ...c
10
- },
11
- {
12
- skip: e,
13
- hook: "useProduct"
14
- }
15
- ), n = i(() => o ?? null, [o]);
1
+ import { useShopActions as p } from "../../internal/useShopActions.js";
2
+ import { useShopActionQuery as n } from "../../internal/reactQuery/useShopActionQuery.js";
3
+ const a = (r) => {
4
+ const { getProduct: s } = p(), { id: t, skip: c = !1, ...o } = r, { data: e, ...u } = n(
5
+ ["product", t, o],
6
+ s,
7
+ { id: t, ...o },
8
+ { skip: c }
9
+ );
16
10
  return {
17
11
  ...u,
18
- product: n
12
+ product: e
19
13
  };
20
14
  };
21
15
  export {
22
- h as useProduct
16
+ a as useProduct
23
17
  };
24
18
  //# sourceMappingURL=useProduct.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useProduct.js","sources":["../../../src/hooks/product/useProduct.ts"],"sourcesContent":["import {useMemo} from 'react'\n\nimport {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'\nimport {DataHookOptionsBase, DataHookReturnsBase, Product} from '../../types'\n\nexport interface UseProductParams extends DataHookOptionsBase {\n /**\n * The product ID to fetch.\n */\n id: string\n}\n\ninterface UseProductReturns extends DataHookReturnsBase {\n /**\n * The product returned from the query.\n */\n product: Product | null\n}\n\nexport const useProduct = (params: UseProductParams): UseProductReturns => {\n const {getProduct} = useShopActions()\n const {id, skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionsDataFetching(\n getProduct,\n {\n id,\n ...restParams,\n },\n {\n skip,\n hook: 'useProduct',\n }\n )\n\n const product = useMemo(() => {\n return data ?? null\n }, [data])\n\n return {\n ...rest,\n product,\n }\n}\n"],"names":["useProduct","params","getProduct","useShopActions","id","skip","restParams","data","rest","useShopActionsDataFetching","product","useMemo"],"mappings":";;;AAoBa,MAAAA,IAAa,CAACC,MAAgD;AACnE,QAAA,EAAC,YAAAC,EAAU,IAAIC,EAAe,GAC9B,EAAC,IAAAC,GAAI,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAL,GAEpC,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtBP;AAAA,IACA;AAAA,MACE,IAAAE;AAAA,MACA,GAAGE;AAAA,IACL;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV,GAEMK,IAAUC,EAAQ,MACfJ,KAAQ,MACd,CAACA,CAAI,CAAC;AAEF,SAAA;AAAA,IACL,GAAGC;AAAA,IACH,SAAAE;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"useProduct.js","sources":["../../../src/hooks/product/useProduct.ts"],"sourcesContent":["import {useShopActionQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {DataHookOptionsBase, DataHookReturnsBase, Product} from '../../types'\n\nexport interface UseProductParams extends DataHookOptionsBase {\n /**\n * The product ID to fetch.\n */\n id: string\n}\n\ninterface UseProductReturns extends DataHookReturnsBase {\n /**\n * The product returned from the query.\n */\n product: Product | null\n}\n\nexport const useProduct = (params: UseProductParams): UseProductReturns => {\n const {getProduct} = useShopActions()\n const {id, skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionQuery(\n ['product', id, restParams],\n getProduct,\n {id, ...restParams},\n {skip}\n )\n\n return {\n ...rest,\n product: data,\n }\n}\n"],"names":["useProduct","params","getProduct","useShopActions","id","skip","restParams","data","rest","useShopActionQuery"],"mappings":";;AAkBa,MAAAA,IAAa,CAACC,MAAgD;AACnE,QAAA,EAAC,YAAAC,EAAU,IAAIC,EAAe,GAC9B,EAAC,IAAAC,GAAI,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAL,GAEpC,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,WAAWL,GAAIE,CAAU;AAAA,IAC1BJ;AAAA,IACA,EAAC,IAAAE,GAAI,GAAGE,EAAU;AAAA,IAClB,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,SAASD;AAAA,EACX;AACF;"}
@@ -1,29 +1,18 @@
1
- import { useCallback as e } from "react";
2
- import { useShopActions as a } from "../../internal/useShopActions.js";
3
- import { useShopActionsPaginatedDataFetching as d } from "../../internal/useShopActionsPaginatedDataFetching.js";
4
- import { MiniEntityNotFoundError as m } from "../../utils/errors.js";
5
- const l = (t) => {
6
- const { getProductList: o } = a(), { skip: s, ...r } = t ?? {}, i = e((u) => {
7
- if (u === null)
8
- throw new m({
9
- hook: "useProductList",
10
- message: "Product list not found"
11
- });
12
- }, []), { data: n, ...c } = d(
13
- o,
14
- r,
15
- {
16
- skip: s,
17
- hook: "useProductList",
18
- validator: i
19
- }
1
+ import { useShopActions as n } from "../../internal/useShopActions.js";
2
+ import { useShopActionInfiniteQuery as e } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
3
+ const d = (o) => {
4
+ const { getProductList: s } = n(), { skip: r, ...t } = o ?? {}, { data: i, ...c } = e(
5
+ ["productList", t],
6
+ s,
7
+ t,
8
+ { skip: r }
20
9
  );
21
10
  return {
22
11
  ...c,
23
- productList: n
12
+ productList: i
24
13
  };
25
14
  };
26
15
  export {
27
- l as useProductList
16
+ d as useProductList
28
17
  };
29
18
  //# sourceMappingURL=useProductList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useProductList.js","sources":["../../../src/hooks/product/useProductList.ts"],"sourcesContent":["import {useCallback} from 'react'\n\nimport {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'\nimport {\n ProductList,\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n} from '../../types'\nimport {MiniEntityNotFoundError} from '../../utils/errors'\n\ninterface UseProductListParams extends PaginatedDataHookOptionsBase {\n /**\n * The GID of the product list. E.g. `gid://shopapp/ProductList/123`.\n */\n id?: string\n /**\n * The public ID of the product list.\n */\n publicId?: string\n}\n\ninterface UseProductListResult extends PaginatedDataHookReturnsBase {\n productList: ProductList | null\n}\n\nexport const useProductList = (\n params?: UseProductListParams\n): UseProductListResult => {\n const {getProductList} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const validator = useCallback((data: ProductList | null) => {\n if (data === null) {\n throw new MiniEntityNotFoundError({\n hook: 'useProductList',\n message: 'Product list not found',\n })\n }\n }, [])\n\n const {data, ...rest} = useShopActionsPaginatedDataFetching(\n getProductList,\n shopActionParams,\n {\n skip,\n hook: 'useProductList',\n validator,\n }\n )\n\n return {\n ...rest,\n productList: data,\n }\n}\n"],"names":["useProductList","params","getProductList","useShopActions","skip","shopActionParams","validator","useCallback","data","MiniEntityNotFoundError","rest","useShopActionsPaginatedDataFetching"],"mappings":";;;;AA0Ba,MAAAA,IAAiB,CAC5BC,MACyB;AACnB,QAAA,EAAC,gBAAAC,EAAc,IAAIC,EAAe,GAClC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzCK,IAAYC,EAAY,CAACC,MAA6B;AAC1D,QAAIA,MAAS;AACX,YAAM,IAAIC,EAAwB;AAAA,QAChC,MAAM;AAAA,QACN,SAAS;AAAA,MAAA,CACV;AAAA,EAEL,GAAG,EAAE,GAEC,EAAC,MAAAD,GAAM,GAAGE,EAAA,IAAQC;AAAA,IACtBT;AAAA,IACAG;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,MACN,WAAAE;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AAAA,IACL,GAAGI;AAAA,IACH,aAAaF;AAAA,EACf;AACF;"}
1
+ {"version":3,"file":"useProductList.js","sources":["../../../src/hooks/product/useProductList.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n ProductList,\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n} from '../../types'\n\ninterface UseProductListParams extends PaginatedDataHookOptionsBase {\n /**\n * The GID of the product list. E.g. `gid://shopapp/ProductList/123`.\n */\n id?: string\n /**\n * The public ID of the product list.\n */\n publicId?: string\n}\n\ninterface UseProductListResult extends PaginatedDataHookReturnsBase {\n productList: ProductList | null\n}\n\nexport const useProductList = (\n params?: UseProductListParams\n): UseProductListResult => {\n const {getProductList} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['productList', shopActionParams],\n getProductList,\n shopActionParams,\n {skip}\n )\n\n return {\n ...rest,\n productList: data,\n }\n}\n"],"names":["useProductList","params","getProductList","useShopActions","skip","shopActionParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAuBa,MAAAA,IAAiB,CAC5BC,MACyB;AACnB,QAAA,EAAC,gBAAAC,EAAc,IAAIC,EAAe,GAClC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,eAAeH,CAAgB;AAAA,IAChCH;AAAA,IACAG;AAAA,IACA,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,aAAaD;AAAA,EACf;AACF;"}
@@ -1,20 +1,18 @@
1
- import { useShopActions as e } from "../../internal/useShopActions.js";
2
- import { useShopActionsPaginatedDataFetching as n } from "../../internal/useShopActionsPaginatedDataFetching.js";
3
- const p = (t) => {
4
- const { getProductLists: s } = e(), { skip: o, ...r } = t ?? {}, { data: c, ...i } = n(
5
- s,
6
- r,
7
- {
8
- skip: o,
9
- hook: "useProductLists"
10
- }
1
+ import { useShopActions as n } from "../../internal/useShopActions.js";
2
+ import { useShopActionInfiniteQuery as e } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
3
+ const d = (s) => {
4
+ const { getProductLists: o } = n(), { skip: r, ...t } = s ?? {}, { data: i, ...c } = e(
5
+ ["productLists", t],
6
+ o,
7
+ t,
8
+ { skip: r }
11
9
  );
12
10
  return {
13
- ...i,
14
- productLists: c
11
+ ...c,
12
+ productLists: i
15
13
  };
16
14
  };
17
15
  export {
18
- p as useProductLists
16
+ d as useProductLists
19
17
  };
20
18
  //# sourceMappingURL=useProductLists.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useProductLists.js","sources":["../../../src/hooks/product/useProductLists.ts"],"sourcesContent":["import {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n ProductList,\n} from '../../types'\n\ninterface UseProductListsParams extends PaginatedDataHookOptionsBase {\n /**\n * The number of products to fetch per product list.\n */\n itemsFirst?: number\n}\n\ninterface UseProductListsResult extends PaginatedDataHookReturnsBase {\n productLists: ProductList[] | null\n}\n\nexport const useProductLists = (\n params?: UseProductListsParams\n): UseProductListsResult => {\n const {getProductLists} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionsPaginatedDataFetching(\n getProductLists,\n shopActionParams,\n {\n skip,\n hook: 'useProductLists',\n }\n )\n\n return {\n ...rest,\n productLists: data,\n }\n}\n"],"names":["useProductLists","params","getProductLists","useShopActions","skip","shopActionParams","data","rest","useShopActionsPaginatedDataFetching"],"mappings":";;AAmBa,MAAAA,IAAkB,CAC7BC,MAC0B;AACpB,QAAA,EAAC,iBAAAC,EAAe,IAAIC,EAAe,GACnC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtBN;AAAA,IACAG;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,cAAcD;AAAA,EAChB;AACF;"}
1
+ {"version":3,"file":"useProductLists.js","sources":["../../../src/hooks/product/useProductLists.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n ProductList,\n} from '../../types'\n\ninterface UseProductListsParams extends PaginatedDataHookOptionsBase {\n /**\n * The number of products to fetch per product list.\n */\n itemsFirst?: number\n}\n\ninterface UseProductListsResult extends PaginatedDataHookReturnsBase {\n productLists: ProductList[] | null\n}\n\nexport const useProductLists = (\n params?: UseProductListsParams\n): UseProductListsResult => {\n const {getProductLists} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['productLists', shopActionParams],\n getProductLists,\n shopActionParams,\n {skip}\n )\n\n return {\n ...rest,\n productLists: data,\n }\n}\n"],"names":["useProductLists","params","getProductLists","useShopActions","skip","shopActionParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAmBa,MAAAA,IAAkB,CAC7BC,MAC0B;AACpB,QAAA,EAAC,iBAAAC,EAAe,IAAIC,EAAe,GACnC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,gBAAgBH,CAAgB;AAAA,IACjCH;AAAA,IACAG;AAAA,IACA,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,cAAcD;AAAA,EAChB;AACF;"}
@@ -1,24 +1,18 @@
1
- import { useMemo as c } from "react";
2
- import { useShopActions as u } from "../../internal/useShopActions.js";
3
- import { useShopActionsPaginatedDataFetching as d } from "../../internal/useShopActionsPaginatedDataFetching.js";
4
- const f = (o) => {
5
- const { getProductMedia: e } = u(), { id: r, skip: s = !1, ...a } = o, { data: t, ...i } = d(
6
- e,
7
- {
8
- id: r,
9
- ...a
10
- },
11
- {
12
- skip: s,
13
- hook: "useProductMedia"
14
- }
15
- ), n = c(() => t ?? null, [t]);
1
+ import { useShopActions as c } from "../../internal/useShopActions.js";
2
+ import { useShopActionInfiniteQuery as d } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
3
+ const p = (e) => {
4
+ const { getProductMedia: r } = c(), { id: t, skip: s = !1, ...o } = e, { data: i, ...a } = d(
5
+ ["productMedia", t, o],
6
+ r,
7
+ { id: t, ...o },
8
+ { skip: s }
9
+ );
16
10
  return {
17
- ...i,
18
- media: n
11
+ ...a,
12
+ media: i
19
13
  };
20
14
  };
21
15
  export {
22
- f as useProductMedia
16
+ p as useProductMedia
23
17
  };
24
18
  //# sourceMappingURL=useProductMedia.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useProductMedia.js","sources":["../../../src/hooks/product/useProductMedia.ts"],"sourcesContent":["import {useMemo} from 'react'\n\nimport {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n ProductMedia,\n} from '../../types'\n\nexport interface UseProductMediaParams extends PaginatedDataHookOptionsBase {\n /**\n * The product ID to fetch media for.\n */\n id: string\n}\n\ninterface UseProductMediaReturns extends PaginatedDataHookReturnsBase {\n /**\n * The product media returned from the query.\n */\n media: ProductMedia[] | null\n}\n\nexport const useProductMedia = (\n params: UseProductMediaParams\n): UseProductMediaReturns => {\n const {getProductMedia} = useShopActions()\n const {id, skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionsPaginatedDataFetching(\n getProductMedia,\n {\n id,\n ...restParams,\n },\n {\n skip,\n hook: 'useProductMedia',\n }\n )\n\n const media = useMemo(() => {\n return data ?? null\n }, [data])\n\n return {\n ...rest,\n media,\n }\n}\n"],"names":["useProductMedia","params","getProductMedia","useShopActions","id","skip","restParams","data","rest","useShopActionsPaginatedDataFetching","media","useMemo"],"mappings":";;;AAwBa,MAAAA,IAAkB,CAC7BC,MAC2B;AACrB,QAAA,EAAC,iBAAAC,EAAe,IAAIC,EAAe,GACnC,EAAC,IAAAC,GAAI,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAL,GAEpC,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtBP;AAAA,IACA;AAAA,MACE,IAAAE;AAAA,MACA,GAAGE;AAAA,IACL;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV,GAEMK,IAAQC,EAAQ,MACbJ,KAAQ,MACd,CAACA,CAAI,CAAC;AAEF,SAAA;AAAA,IACL,GAAGC;AAAA,IACH,OAAAE;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"useProductMedia.js","sources":["../../../src/hooks/product/useProductMedia.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n ProductMedia,\n} from '../../types'\n\nexport interface UseProductMediaParams extends PaginatedDataHookOptionsBase {\n /**\n * The product ID to fetch media for.\n */\n id: string\n}\n\ninterface UseProductMediaReturns extends PaginatedDataHookReturnsBase {\n /**\n * The product media returned from the query.\n */\n media: ProductMedia[] | null\n}\n\nexport const useProductMedia = (\n params: UseProductMediaParams\n): UseProductMediaReturns => {\n const {getProductMedia} = useShopActions()\n const {id, skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['productMedia', id, restParams],\n getProductMedia,\n {id, ...restParams},\n {skip}\n )\n\n return {\n ...rest,\n media: data,\n }\n}\n"],"names":["useProductMedia","params","getProductMedia","useShopActions","id","skip","restParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAsBa,MAAAA,IAAkB,CAC7BC,MAC2B;AACrB,QAAA,EAAC,iBAAAC,EAAe,IAAIC,EAAe,GACnC,EAAC,IAAAC,GAAI,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAL,GAEpC,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,gBAAgBL,GAAIE,CAAU;AAAA,IAC/BJ;AAAA,IACA,EAAC,IAAAE,GAAI,GAAGE,EAAU;AAAA,IAClB,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,OAAOD;AAAA,EACT;AACF;"}
@@ -1,45 +1,52 @@
1
- import { useState as h, useCallback as S, useEffect as y, useMemo as b } from "react";
2
- import g from "../../_virtual/debounce.js";
3
- import { useShopActions as P } from "../../internal/useShopActions.js";
4
- import { useShopActionsPaginatedDataFetching as k } from "../../internal/useShopActionsPaginatedDataFetching.js";
5
- const v = (s) => {
6
- const { getProductSearch: u } = P(), {
1
+ import { useState as S, useCallback as y, useEffect as h } from "react";
2
+ import b from "../../_virtual/debounce.js";
3
+ import { useShopActions as g } from "../../internal/useShopActions.js";
4
+ import { useShopActionInfiniteQuery as k } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
5
+ const x = (a) => {
6
+ const { getProductSearch: d } = g(), {
7
7
  query: e,
8
- filters: c,
9
- sortBy: n,
10
- includeSensitive: a = !1,
11
- skip: i = !1,
12
- ...d
13
- } = s ?? {}, [t, l] = h(e), r = S(
14
- g((p) => {
15
- l(p);
8
+ filters: o,
9
+ sortBy: s,
10
+ includeSensitive: c = !1,
11
+ skip: f = !1,
12
+ ...u
13
+ } = a ?? {}, [t, p] = S(e), r = y(
14
+ b((n) => {
15
+ p((i) => i === n ? i : n);
16
16
  }, 300),
17
17
  []
18
18
  );
19
- y(() => (r(e), () => {
19
+ h(() => (r(e), () => {
20
20
  r.cancel();
21
21
  }), [e, r]);
22
- const { data: o, ...m } = k(
23
- u,
22
+ const { data: m, ...l } = k(
23
+ [
24
+ "productSearch",
25
+ t,
26
+ o,
27
+ s,
28
+ c,
29
+ u
30
+ ],
31
+ d,
24
32
  {
25
33
  query: t,
26
- filters: c,
27
- sortBy: n,
28
- includeSensitive: a,
29
- ...d
34
+ filters: o,
35
+ sortBy: s,
36
+ includeSensitive: c,
37
+ ...u
30
38
  },
31
39
  {
32
- skip: i,
33
- hook: "useProductSearch"
40
+ skip: f || t.trim().length === 0
34
41
  }
35
- ), f = b(() => t.trim().length === 0 ? null : o ?? null, [o, t]);
42
+ );
36
43
  return {
37
- ...m,
38
- products: f,
44
+ ...l,
45
+ products: m,
39
46
  isTyping: t !== e
40
47
  };
41
48
  };
42
49
  export {
43
- v as useProductSearch
50
+ x as useProductSearch
44
51
  };
45
52
  //# sourceMappingURL=useProductSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useProductSearch.js","sources":["../../../src/hooks/product/useProductSearch.ts"],"sourcesContent":["import {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport debounce from 'lodash/debounce'\n\nimport {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n Product,\n ProductFilters,\n ProductSearchSortBy,\n} from '../../types'\n\nexport interface UseProductSearchParams extends PaginatedDataHookOptionsBase {\n /**\n * The search query.\n */\n query: string\n /**\n * The filters to apply to the search.\n */\n filters?: ProductFilters\n /**\n * The sort order of the results.\n */\n sortBy?: ProductSearchSortBy\n /**\n * Whether to include sensitive products.\n */\n includeSensitive?: boolean\n}\n\ninterface UseProductSearchReturns extends PaginatedDataHookReturnsBase {\n /**\n * The products returned from the query.\n */\n products: Product[] | null\n /**\n * Whether the user is typing.\n */\n isTyping: boolean\n}\n\nexport const useProductSearch = (\n params: UseProductSearchParams\n): UseProductSearchReturns => {\n const {getProductSearch} = useShopActions()\n const {\n query,\n filters,\n sortBy,\n includeSensitive = false,\n skip = false,\n ...restParams\n } = params ?? {}\n\n const [debouncedQuery, setDebouncedQuery] = useState<string>(query)\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const debouncedSetQuery = useCallback(\n debounce((newQuery: string) => {\n setDebouncedQuery(newQuery)\n }, 300),\n []\n )\n\n useEffect(() => {\n debouncedSetQuery(query)\n\n return () => {\n debouncedSetQuery.cancel()\n }\n }, [query, debouncedSetQuery])\n\n const {data, ...rest} = useShopActionsPaginatedDataFetching(\n getProductSearch,\n {\n query: debouncedQuery,\n filters,\n sortBy,\n includeSensitive,\n ...restParams,\n },\n {\n skip,\n hook: 'useProductSearch',\n }\n )\n\n const products = useMemo(() => {\n if (debouncedQuery.trim().length === 0) {\n return null\n }\n\n return data ?? null\n }, [data, debouncedQuery])\n\n return {\n ...rest,\n products,\n isTyping: debouncedQuery !== query,\n }\n}\n"],"names":["useProductSearch","params","getProductSearch","useShopActions","query","filters","sortBy","includeSensitive","skip","restParams","debouncedQuery","setDebouncedQuery","useState","debouncedSetQuery","useCallback","debounce","newQuery","useEffect","data","rest","useShopActionsPaginatedDataFetching","products","useMemo"],"mappings":";;;;AA4Ca,MAAAA,IAAmB,CAC9BC,MAC4B;AACtB,QAAA,EAAC,kBAAAC,EAAgB,IAAIC,EAAe,GACpC;AAAA,IACJ,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC;AAAA,IACA,kBAAAC,IAAmB;AAAA,IACnB,MAAAC,IAAO;AAAA,IACP,GAAGC;AAAA,EACL,IAAIR,KAAU,CAAC,GAET,CAACS,GAAgBC,CAAiB,IAAIC,EAAiBR,CAAK,GAG5DS,IAAoBC;AAAA,IACxBC,EAAS,CAACC,MAAqB;AAC7B,MAAAL,EAAkBK,CAAQ;AAAA,OACzB,GAAG;AAAA,IACN,CAAA;AAAA,EACF;AAEA,EAAAC,EAAU,OACRJ,EAAkBT,CAAK,GAEhB,MAAM;AACX,IAAAS,EAAkB,OAAO;AAAA,EAC3B,IACC,CAACT,GAAOS,CAAiB,CAAC;AAE7B,QAAM,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtBlB;AAAA,IACA;AAAA,MACE,OAAOQ;AAAA,MACP,SAAAL;AAAA,MACA,QAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,GAAGE;AAAA,IACL;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV,GAEMa,IAAWC,EAAQ,MACnBZ,EAAe,OAAO,WAAW,IAC5B,OAGFQ,KAAQ,MACd,CAACA,GAAMR,CAAc,CAAC;AAElB,SAAA;AAAA,IACL,GAAGS;AAAA,IACH,UAAAE;AAAA,IACA,UAAUX,MAAmBN;AAAA,EAC/B;AACF;"}
1
+ {"version":3,"file":"useProductSearch.js","sources":["../../../src/hooks/product/useProductSearch.ts"],"sourcesContent":["import {useCallback, useEffect, useState} from 'react'\n\nimport debounce from 'lodash/debounce'\n\nimport {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n Product,\n ProductFilters,\n ProductSearchSortBy,\n} from '../../types'\n\nexport interface UseProductSearchParams extends PaginatedDataHookOptionsBase {\n /**\n * The search query.\n */\n query: string\n /**\n * The filters to apply to the search.\n */\n filters?: ProductFilters\n /**\n * The sort order of the results.\n */\n sortBy?: ProductSearchSortBy\n /**\n * Whether to include sensitive products.\n */\n includeSensitive?: boolean\n}\n\ninterface UseProductSearchReturns extends PaginatedDataHookReturnsBase {\n /**\n * The products returned from the query.\n */\n products: Product[] | null\n /**\n * Whether the user is typing.\n */\n isTyping: boolean\n}\n\nexport const useProductSearch = (\n params: UseProductSearchParams\n): UseProductSearchReturns => {\n const {getProductSearch} = useShopActions()\n const {\n query,\n filters,\n sortBy,\n includeSensitive = false,\n skip = false,\n ...restParams\n } = params ?? {}\n\n const [debouncedQuery, setDebouncedQuery] = useState<string>(query)\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const debouncedSetQuery = useCallback(\n debounce((newQuery: string) => {\n setDebouncedQuery(prev => {\n // Only update if the query actually changed\n if (prev === newQuery) return prev\n return newQuery\n })\n }, 300),\n []\n )\n\n useEffect(() => {\n debouncedSetQuery(query)\n\n return () => {\n debouncedSetQuery.cancel()\n }\n }, [query, debouncedSetQuery])\n\n // Use our Shop Action infinite query helper\n const {data, ...rest} = useShopActionInfiniteQuery(\n [\n 'productSearch',\n debouncedQuery,\n filters,\n sortBy,\n includeSensitive,\n restParams,\n ],\n getProductSearch,\n {\n query: debouncedQuery,\n filters,\n sortBy,\n includeSensitive,\n ...restParams,\n },\n {\n skip: skip || debouncedQuery.trim().length === 0,\n }\n )\n\n return {\n ...rest,\n products: data,\n isTyping: debouncedQuery !== query,\n }\n}\n"],"names":["useProductSearch","params","getProductSearch","useShopActions","query","filters","sortBy","includeSensitive","skip","restParams","debouncedQuery","setDebouncedQuery","useState","debouncedSetQuery","useCallback","debounce","newQuery","prev","useEffect","data","rest","useShopActionInfiniteQuery"],"mappings":";;;;AA4Ca,MAAAA,IAAmB,CAC9BC,MAC4B;AACtB,QAAA,EAAC,kBAAAC,EAAgB,IAAIC,EAAe,GACpC;AAAA,IACJ,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC;AAAA,IACA,kBAAAC,IAAmB;AAAA,IACnB,MAAAC,IAAO;AAAA,IACP,GAAGC;AAAA,EACL,IAAIR,KAAU,CAAC,GAET,CAACS,GAAgBC,CAAiB,IAAIC,EAAiBR,CAAK,GAG5DS,IAAoBC;AAAA,IACxBC,EAAS,CAACC,MAAqB;AAC7B,MAAAL,EAAkB,CAAQM,MAEpBA,MAASD,IAAiBC,IACvBD,CACR;AAAA,OACA,GAAG;AAAA,IACN,CAAA;AAAA,EACF;AAEA,EAAAE,EAAU,OACRL,EAAkBT,CAAK,GAEhB,MAAM;AACX,IAAAS,EAAkB,OAAO;AAAA,EAC3B,IACC,CAACT,GAAOS,CAAiB,CAAC;AAG7B,QAAM,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB;AAAA,MACE;AAAA,MACAX;AAAA,MACAL;AAAA,MACAC;AAAA,MACAC;AAAA,MACAE;AAAA,IACF;AAAA,IACAP;AAAA,IACA;AAAA,MACE,OAAOQ;AAAA,MACP,SAAAL;AAAA,MACA,QAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,GAAGE;AAAA,IACL;AAAA,IACA;AAAA,MACE,MAAMD,KAAQE,EAAe,KAAA,EAAO,WAAW;AAAA,IAAA;AAAA,EAEnD;AAEO,SAAA;AAAA,IACL,GAAGU;AAAA,IACH,UAAUD;AAAA,IACV,UAAUT,MAAmBN;AAAA,EAC/B;AACF;"}
@@ -1,21 +1,18 @@
1
- import { useMemo as i } from "react";
2
- import { useShopActions as c } from "../../internal/useShopActions.js";
3
- import { useShopActionsPaginatedDataFetching as u } from "../../internal/useShopActionsPaginatedDataFetching.js";
4
- const P = (o) => {
5
- const { getProductVariants: r } = c(), { skip: s = !1, ...a } = o, { data: t, ...n } = u(
6
- r,
7
- a,
8
- {
9
- skip: s,
10
- hook: "useProductVariants"
11
- }
12
- ), e = i(() => t ?? null, [t]);
1
+ import { useShopActions as e } from "../../internal/useShopActions.js";
2
+ import { useShopActionInfiniteQuery as i } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
3
+ const p = (r) => {
4
+ const { getProductVariants: s } = e(), { skip: o = !1, ...t } = r, { data: a, ...n } = i(
5
+ ["productVariants", t],
6
+ s,
7
+ t,
8
+ { skip: o }
9
+ );
13
10
  return {
14
11
  ...n,
15
- variants: e
12
+ variants: a
16
13
  };
17
14
  };
18
15
  export {
19
- P as useProductVariants
16
+ p as useProductVariants
20
17
  };
21
18
  //# sourceMappingURL=useProductVariants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useProductVariants.js","sources":["../../../src/hooks/product/useProductVariants.ts"],"sourcesContent":["import {useMemo} from 'react'\n\nimport {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n ProductVariant,\n} from '../../types'\n\nexport interface UseProductVariantsParams extends PaginatedDataHookOptionsBase {\n /**\n * The product ID to fetch variants for.\n */\n id: string\n}\n\ninterface UseProductVariantsReturns extends PaginatedDataHookReturnsBase {\n /**\n * The product variants returned from the query.\n */\n variants: ProductVariant[] | null\n}\n\nexport const useProductVariants = (\n params: UseProductVariantsParams\n): UseProductVariantsReturns => {\n const {getProductVariants} = useShopActions()\n const {skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionsPaginatedDataFetching(\n getProductVariants,\n restParams,\n {\n skip,\n hook: 'useProductVariants',\n }\n )\n\n const variants = useMemo(() => {\n return data ?? null\n }, [data])\n\n return {\n ...rest,\n variants,\n }\n}\n"],"names":["useProductVariants","params","getProductVariants","useShopActions","skip","restParams","data","rest","useShopActionsPaginatedDataFetching","variants","useMemo"],"mappings":";;;AAwBa,MAAAA,IAAqB,CAChCC,MAC8B;AACxB,QAAA,EAAC,oBAAAC,EAAkB,IAAIC,EAAe,GACtC,EAAC,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAJ,GAEhC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtBN;AAAA,IACAG;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV,GAEMK,IAAWC,EAAQ,MAChBJ,KAAQ,MACd,CAACA,CAAI,CAAC;AAEF,SAAA;AAAA,IACL,GAAGC;AAAA,IACH,UAAAE;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"useProductVariants.js","sources":["../../../src/hooks/product/useProductVariants.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n ProductVariant,\n} from '../../types'\n\nexport interface UseProductVariantsParams extends PaginatedDataHookOptionsBase {\n /**\n * The product ID to fetch variants for.\n */\n id: string\n}\n\ninterface UseProductVariantsReturns extends PaginatedDataHookReturnsBase {\n /**\n * The product variants returned from the query.\n */\n variants: ProductVariant[] | null\n}\n\nexport const useProductVariants = (\n params: UseProductVariantsParams\n): UseProductVariantsReturns => {\n const {getProductVariants} = useShopActions()\n const {skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['productVariants', restParams],\n getProductVariants,\n restParams,\n {skip}\n )\n\n return {\n ...rest,\n variants: data,\n }\n}\n"],"names":["useProductVariants","params","getProductVariants","useShopActions","skip","restParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAsBa,MAAAA,IAAqB,CAChCC,MAC8B;AACxB,QAAA,EAAC,oBAAAC,EAAkB,IAAIC,EAAe,GACtC,EAAC,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAJ,GAEhC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,mBAAmBH,CAAU;AAAA,IAC9BH;AAAA,IACAG;AAAA,IACA,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,UAAUD;AAAA,EACZ;AACF;"}