@shopify/shop-minis-react 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/MinisContainer.js +11 -10
- package/dist/components/MinisContainer.js.map +1 -1
- package/dist/components/atoms/content-wrapper.js.map +1 -1
- package/dist/components/atoms/video-player.js +28 -26
- package/dist/components/atoms/video-player.js.map +1 -1
- package/dist/components/commerce/product-card.js +106 -79
- package/dist/components/commerce/product-card.js.map +1 -1
- package/dist/components/commerce/product-link.js +124 -137
- package/dist/components/commerce/product-link.js.map +1 -1
- package/dist/components/commerce/search.js +20 -20
- package/dist/components/commerce/search.js.map +1 -1
- package/dist/components/ui/sonner.js +3 -1
- package/dist/components/ui/sonner.js.map +1 -1
- package/dist/hooks/content/useContent.js +12 -18
- package/dist/hooks/content/useContent.js.map +1 -1
- package/dist/hooks/navigation/useNavigateWithTransition.js +10 -11
- package/dist/hooks/navigation/useNavigateWithTransition.js.map +1 -1
- package/dist/hooks/product/useCuratedProducts.js +9 -11
- package/dist/hooks/product/useCuratedProducts.js.map +1 -1
- package/dist/hooks/product/usePopularProducts.js +9 -11
- package/dist/hooks/product/usePopularProducts.js.map +1 -1
- package/dist/hooks/product/useProduct.js +11 -17
- package/dist/hooks/product/useProduct.js.map +1 -1
- package/dist/hooks/product/useProductList.js +10 -21
- package/dist/hooks/product/useProductList.js.map +1 -1
- package/dist/hooks/product/useProductLists.js +11 -13
- package/dist/hooks/product/useProductLists.js.map +1 -1
- package/dist/hooks/product/useProductMedia.js +12 -18
- package/dist/hooks/product/useProductMedia.js.map +1 -1
- package/dist/hooks/product/useProductSearch.js +34 -27
- package/dist/hooks/product/useProductSearch.js.map +1 -1
- package/dist/hooks/product/useProductVariants.js +11 -14
- package/dist/hooks/product/useProductVariants.js.map +1 -1
- package/dist/hooks/product/useProducts.js +12 -11
- package/dist/hooks/product/useProducts.js.map +1 -1
- package/dist/hooks/product/useRecommendedProducts.js +11 -13
- package/dist/hooks/product/useRecommendedProducts.js.map +1 -1
- package/dist/hooks/shop/useRecommendedShops.js +11 -13
- package/dist/hooks/shop/useRecommendedShops.js.map +1 -1
- package/dist/hooks/shop/useShop.js +12 -11
- package/dist/hooks/shop/useShop.js.map +1 -1
- package/dist/hooks/user/useBuyerAttributes.js +8 -10
- package/dist/hooks/user/useBuyerAttributes.js.map +1 -1
- package/dist/hooks/user/useCurrentUser.js +7 -9
- package/dist/hooks/user/useCurrentUser.js.map +1 -1
- package/dist/hooks/user/useFollowedShops.js +11 -14
- package/dist/hooks/user/useFollowedShops.js.map +1 -1
- package/dist/hooks/user/useOrders.js +7 -9
- package/dist/hooks/user/useOrders.js.map +1 -1
- package/dist/hooks/user/useRecentProducts.js +11 -13
- package/dist/hooks/user/useRecentProducts.js.map +1 -1
- package/dist/hooks/user/useRecentShops.js +10 -13
- package/dist/hooks/user/useRecentShops.js.map +1 -1
- package/dist/hooks/user/useSavedProducts.js +10 -13
- package/dist/hooks/user/useSavedProducts.js.map +1 -1
- package/dist/index.js +269 -264
- package/dist/index.js.map +1 -1
- package/dist/internal/components/product-review-stars.js +78 -0
- package/dist/internal/components/product-review-stars.js.map +1 -0
- package/dist/internal/reactQuery/MinisQueryProvider.js +11 -0
- package/dist/internal/reactQuery/MinisQueryProvider.js.map +1 -0
- package/dist/internal/reactQuery/queryClient.js +33 -0
- package/dist/internal/reactQuery/queryClient.js.map +1 -0
- package/dist/internal/reactQuery/useShopActionInfiniteQuery.js +52 -0
- package/dist/internal/reactQuery/useShopActionInfiniteQuery.js.map +1 -0
- package/dist/internal/reactQuery/useShopActionQuery.js +37 -0
- package/dist/internal/reactQuery/useShopActionQuery.js.map +1 -0
- package/dist/mocks.js +178 -107
- package/dist/mocks.js.map +1 -1
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/star-half.js +21 -0
- package/dist/shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/star-half.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/sonner@2.0.5_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/sonner/dist/index.js +4 -4
- package/dist/shop-minis-react/node_modules/.pnpm/sonner@2.0.5_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/sonner/dist/index.js.map +1 -1
- package/package.json +2 -7
- package/src/components/MinisContainer.tsx +6 -3
- package/src/components/atoms/content-wrapper.tsx +1 -1
- package/src/components/atoms/video-player.tsx +7 -0
- package/src/components/commerce/product-card.test.tsx +135 -0
- package/src/components/commerce/product-card.tsx +39 -5
- package/src/components/commerce/product-link.test.tsx +15 -3
- package/src/components/commerce/product-link.tsx +9 -25
- package/src/components/commerce/search.tsx +2 -2
- package/src/components/index.ts +1 -0
- package/src/components/ui/sonner.tsx +2 -2
- package/src/hooks/content/useContent.ts +6 -17
- package/src/hooks/navigation/useNavigateWithTransition.test.ts +46 -7
- package/src/hooks/navigation/useNavigateWithTransition.ts +4 -1
- package/src/hooks/product/useCuratedProducts.ts +4 -6
- package/src/hooks/product/usePopularProducts.ts +4 -6
- package/src/hooks/product/useProduct.ts +6 -17
- package/src/hooks/product/useProductList.ts +4 -19
- package/src/hooks/product/useProductLists.ts +4 -6
- package/src/hooks/product/useProductMedia.ts +6 -17
- package/src/hooks/product/useProductSearch.ts +19 -15
- package/src/hooks/product/useProductVariants.ts +5 -13
- package/src/hooks/product/useProducts.ts +8 -12
- package/src/hooks/product/useRecommendedProducts.ts +4 -6
- package/src/hooks/shop/useRecommendedShops.ts +4 -6
- package/src/hooks/shop/useShop.ts +8 -12
- package/src/hooks/user/useBuyerAttributes.ts +4 -6
- package/src/hooks/user/useCurrentUser.ts +4 -6
- package/src/hooks/user/useFollowedShops.ts +5 -13
- package/src/hooks/user/useOrders.ts +4 -6
- package/src/hooks/user/useRecentProducts.ts +4 -6
- package/src/hooks/user/useRecentShops.ts +5 -13
- package/src/hooks/user/useSavedProducts.ts +5 -13
- package/src/internal/components/product-review-stars.test.tsx +90 -0
- package/src/internal/components/product-review-stars.tsx +113 -0
- package/src/internal/reactQuery/MinisQueryProvider.test.tsx +38 -0
- package/src/internal/reactQuery/MinisQueryProvider.tsx +16 -0
- package/src/internal/reactQuery/index.ts +8 -0
- package/src/internal/reactQuery/queryClient.test.tsx +91 -0
- package/src/internal/reactQuery/queryClient.ts +43 -0
- package/src/internal/reactQuery/useShopActionInfiniteQuery.test.tsx +357 -0
- package/src/internal/reactQuery/useShopActionInfiniteQuery.ts +129 -0
- package/src/internal/reactQuery/useShopActionQuery.test.tsx +184 -0
- package/src/internal/reactQuery/useShopActionQuery.ts +74 -0
- package/src/mocks.ts +10 -2
- package/src/providers/ImagePickerProvider.test.tsx +3 -9
- package/dist/internal/useShopActionsDataFetching.js +0 -79
- package/dist/internal/useShopActionsDataFetching.js.map +0 -1
- package/dist/internal/useShopActionsPaginatedDataFetching.js +0 -96
- package/dist/internal/useShopActionsPaginatedDataFetching.js.map +0 -1
- package/src/hooks/product/useProductSearch.test.ts +0 -470
- package/src/internal/useShopActionsDataFetching.test.ts +0 -465
- package/src/internal/useShopActionsDataFetching.ts +0 -150
- package/src/internal/useShopActionsPaginatedDataFetching.ts +0 -188
- package/src/stories/Accordion.stories.tsx +0 -124
- package/src/stories/AddToCart.stories.tsx +0 -251
- package/src/stories/Alert.stories.tsx +0 -38
- package/src/stories/AlertDialog.stories.tsx +0 -48
- package/src/stories/Avatar.stories.tsx +0 -29
- package/src/stories/Badge.stories.tsx +0 -46
- package/src/stories/Button.stories.tsx +0 -81
- package/src/stories/Card.stories.tsx +0 -40
- package/src/stories/Checkbox.stories.tsx +0 -44
- package/src/stories/FavoriteButton.stories.tsx +0 -58
- package/src/stories/IconButton.stories.tsx +0 -68
- package/src/stories/ImageContentWrapper.stories.tsx +0 -65
- package/src/stories/Input.stories.tsx +0 -44
- package/src/stories/Label.stories.tsx +0 -19
- package/src/stories/List.stories.tsx +0 -64
- package/src/stories/MerchantCard.stories.tsx +0 -127
- package/src/stories/ProductCard.stories.tsx +0 -92
- package/src/stories/ProductLink.stories.tsx +0 -46
- package/src/stories/ProductVariantPrice.stories.tsx +0 -70
- package/src/stories/Progress.stories.tsx +0 -30
- package/src/stories/PullToRefreshList.stories.tsx +0 -122
- package/src/stories/QuantitySelector.stories.tsx +0 -78
- package/src/stories/RadioGroup.stories.tsx +0 -51
- package/src/stories/Search.stories.tsx +0 -37
- package/src/stories/Select.stories.tsx +0 -85
- package/src/stories/Skeleton.stories.tsx +0 -19
- package/src/stories/TextInput.stories.tsx +0 -26
- package/src/stories/Toaster.stories.tsx +0 -46
- package/src/stories/Touchable.stories.tsx +0 -40
- package/src/stories/VideoPlayer.stories.tsx +0 -129
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsxs as s, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import * as g from "react";
|
|
3
|
+
import { cn as t } from "../../lib/utils.js";
|
|
4
|
+
import { formatReviewCount as y, normalizeRating as w } from "../../utils/merchant-card.js";
|
|
5
|
+
import c from "../../shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/star.js";
|
|
6
|
+
import R from "../../shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/star-half.js";
|
|
7
|
+
const l = {
|
|
8
|
+
sm: "h-3 w-3",
|
|
9
|
+
md: "h-4 w-4",
|
|
10
|
+
lg: "h-5 w-5"
|
|
11
|
+
}, S = {
|
|
12
|
+
sm: "text-xs",
|
|
13
|
+
md: "text-sm",
|
|
14
|
+
lg: "text-base"
|
|
15
|
+
}, u = g.forwardRef(
|
|
16
|
+
({
|
|
17
|
+
averageRating: d,
|
|
18
|
+
reviewCount: m,
|
|
19
|
+
size: e = "sm",
|
|
20
|
+
filledStarColor: o = "var(--grayscale-d100)",
|
|
21
|
+
emptyStarColor: n = "var(--grayscale-l20)",
|
|
22
|
+
className: f,
|
|
23
|
+
...h
|
|
24
|
+
}, p) => {
|
|
25
|
+
const i = Math.min(5, w(d)), x = Math.floor(i), v = i % 1;
|
|
26
|
+
return /* @__PURE__ */ s(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
ref: p,
|
|
30
|
+
className: t("flex items-center", f),
|
|
31
|
+
"data-slot": "product-review-stars",
|
|
32
|
+
...h,
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ s("div", { className: "relative", children: [
|
|
35
|
+
/* @__PURE__ */ a("div", { className: "flex", children: Array.from({ length: 5 }, (N, r) => /* @__PURE__ */ a(
|
|
36
|
+
c,
|
|
37
|
+
{
|
|
38
|
+
className: t(l[e]),
|
|
39
|
+
style: { fill: n },
|
|
40
|
+
strokeWidth: 0
|
|
41
|
+
},
|
|
42
|
+
r
|
|
43
|
+
)) }),
|
|
44
|
+
/* @__PURE__ */ s("div", { className: "flex absolute top-0 left-0", children: [
|
|
45
|
+
Array.from({ length: x }, (N, r) => /* @__PURE__ */ a(
|
|
46
|
+
c,
|
|
47
|
+
{
|
|
48
|
+
className: t(l[e]),
|
|
49
|
+
style: { fill: o },
|
|
50
|
+
strokeWidth: 0
|
|
51
|
+
},
|
|
52
|
+
r
|
|
53
|
+
)),
|
|
54
|
+
v >= 0.5 && /* @__PURE__ */ a(
|
|
55
|
+
R,
|
|
56
|
+
{
|
|
57
|
+
className: t(l[e]),
|
|
58
|
+
style: { fill: o },
|
|
59
|
+
strokeWidth: 0
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
] })
|
|
63
|
+
] }),
|
|
64
|
+
m && /* @__PURE__ */ s("span", { className: t(S[e], "ml-1"), children: [
|
|
65
|
+
"(",
|
|
66
|
+
y(m),
|
|
67
|
+
")"
|
|
68
|
+
] })
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
u.displayName = "ProductReviewStars";
|
|
75
|
+
export {
|
|
76
|
+
u as ProductReviewStars
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=product-review-stars.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-review-stars.js","sources":["../../../src/internal/components/product-review-stars.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {Star, StarHalf} from 'lucide-react'\n\nimport {cn} from '../../lib/utils'\nimport {formatReviewCount, normalizeRating} from '../../utils/merchant-card'\n\nconst starSizeClasses = {\n sm: 'h-3 w-3',\n md: 'h-4 w-4',\n lg: 'h-5 w-5',\n} as const\n\nconst textSizeClasses = {\n sm: 'text-xs',\n md: 'text-sm',\n lg: 'text-base',\n} as const\n\nexport interface ProductReviewStarsProps\n extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Average rating value (0-5)\n */\n averageRating: number\n /**\n * Total number of reviews\n */\n reviewCount?: number | null\n /**\n * Custom color for filled star\n * @default 'var(--grayscale-d100)' (black)\n */\n filledStarColor?: string\n /**\n * Custom color for empty star\n * @default 'var(--grayscale-l20)' (light gray)\n */\n emptyStarColor?: string\n /**\n * Size of the stars\n * @default 'sm'\n */\n size?: 'sm' | 'md' | 'lg'\n}\n\nexport const ProductReviewStars = React.forwardRef<\n HTMLDivElement,\n ProductReviewStarsProps\n>(\n (\n {\n averageRating,\n reviewCount,\n size = 'sm',\n filledStarColor = 'var(--grayscale-d100)',\n emptyStarColor = 'var(--grayscale-l20)',\n className,\n ...props\n },\n ref\n ) => {\n const normalizedRating = Math.min(5, normalizeRating(averageRating))\n const filledStars = Math.floor(normalizedRating)\n const remainder = normalizedRating % 1\n\n return (\n <div\n ref={ref}\n className={cn('flex items-center', className)}\n data-slot=\"product-review-stars\"\n {...props}\n >\n <div className=\"relative\">\n <div className=\"flex\">\n {Array.from({length: 5}, (_, i) => (\n <Star\n key={i}\n className={cn(starSizeClasses[size])}\n style={{fill: emptyStarColor}}\n strokeWidth={0}\n />\n ))}\n </div>\n <div className=\"flex absolute top-0 left-0\">\n {Array.from({length: filledStars}, (_, i) => (\n <Star\n key={i}\n className={cn(starSizeClasses[size])}\n style={{fill: filledStarColor}}\n strokeWidth={0}\n />\n ))}\n {remainder >= 0.5 && (\n <StarHalf\n className={cn(starSizeClasses[size])}\n style={{fill: filledStarColor}}\n strokeWidth={0}\n />\n )}\n </div>\n </div>\n {reviewCount && (\n <span className={cn(textSizeClasses[size], 'ml-1')}>\n ({formatReviewCount(reviewCount)})\n </span>\n )}\n </div>\n )\n }\n)\n\nProductReviewStars.displayName = 'ProductReviewStars'\n"],"names":["starSizeClasses","textSizeClasses","ProductReviewStars","React","averageRating","reviewCount","size","filledStarColor","emptyStarColor","className","props","ref","normalizedRating","normalizeRating","filledStars","remainder","jsxs","cn","jsx","_","i","Star","StarHalf","formatReviewCount"],"mappings":";;;;;;AAOA,MAAMA,IAAkB;AAAA,EACtB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEMC,IAAkB;AAAA,EACtB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GA6BaC,IAAqBC,EAAM;AAAA,EAItC,CACE;AAAA,IACE,eAAAC;AAAA,IACA,aAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,iBAAAC,IAAkB;AAAA,IAClB,gBAAAC,IAAiB;AAAA,IACjB,WAAAC;AAAA,IACA,GAAGC;AAAA,KAELC,MACG;AACH,UAAMC,IAAmB,KAAK,IAAI,GAAGC,EAAgBT,CAAa,CAAC,GAC7DU,IAAc,KAAK,MAAMF,CAAgB,GACzCG,IAAYH,IAAmB;AAGnC,WAAA,gBAAAI;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAL;AAAA,QACA,WAAWM,EAAG,qBAAqBR,CAAS;AAAA,QAC5C,aAAU;AAAA,QACT,GAAGC;AAAA,QAEJ,UAAA;AAAA,UAAC,gBAAAM,EAAA,OAAA,EAAI,WAAU,YACb,UAAA;AAAA,YAAC,gBAAAE,EAAA,OAAA,EAAI,WAAU,QACZ,UAAM,MAAA,KAAK,EAAC,QAAQ,EAAC,GAAG,CAACC,GAAGC,MAC3B,gBAAAF;AAAA,cAACG;AAAA,cAAA;AAAA,gBAEC,WAAWJ,EAAGjB,EAAgBM,CAAI,CAAC;AAAA,gBACnC,OAAO,EAAC,MAAME,EAAc;AAAA,gBAC5B,aAAa;AAAA,cAAA;AAAA,cAHRY;AAAA,YAKR,CAAA,GACH;AAAA,YACA,gBAAAJ,EAAC,OAAI,EAAA,WAAU,8BACZ,UAAA;AAAA,cAAA,MAAM,KAAK,EAAC,QAAQF,KAAc,CAACK,GAAGC,MACrC,gBAAAF;AAAA,gBAACG;AAAA,gBAAA;AAAA,kBAEC,WAAWJ,EAAGjB,EAAgBM,CAAI,CAAC;AAAA,kBACnC,OAAO,EAAC,MAAMC,EAAe;AAAA,kBAC7B,aAAa;AAAA,gBAAA;AAAA,gBAHRa;AAAA,cAAA,CAKR;AAAA,cACAL,KAAa,OACZ,gBAAAG;AAAA,gBAACI;AAAA,gBAAA;AAAA,kBACC,WAAWL,EAAGjB,EAAgBM,CAAI,CAAC;AAAA,kBACnC,OAAO,EAAC,MAAMC,EAAe;AAAA,kBAC7B,aAAa;AAAA,gBAAA;AAAA,cAAA;AAAA,YACf,EAEJ,CAAA;AAAA,UAAA,GACF;AAAA,UACCF,uBACE,QAAK,EAAA,WAAWY,EAAGhB,EAAgBK,CAAI,GAAG,MAAM,GAAG,UAAA;AAAA,YAAA;AAAA,YAChDiB,EAAkBlB,CAAW;AAAA,YAAE;AAAA,UAAA,EACnC,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAGN;AAEAH,EAAmB,cAAc;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as o } from "react";
|
|
3
|
+
import { createShopMinisQueryClient as t, ShopMinisQueryClientContext as n } from "./queryClient.js";
|
|
4
|
+
function s({ children: r }) {
|
|
5
|
+
const e = o(() => t(), []);
|
|
6
|
+
return /* @__PURE__ */ i(n.Provider, { value: e, children: r });
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
s as MinisQueryProvider
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=MinisQueryProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinisQueryProvider.js","sources":["../../../src/internal/reactQuery/MinisQueryProvider.tsx"],"sourcesContent":["import React, {useMemo} from 'react'\n\nimport {\n createShopMinisQueryClient,\n ShopMinisQueryClientContext,\n} from './queryClient'\n\nexport function MinisQueryProvider({children}: {children: React.ReactNode}) {\n const queryClient = useMemo(() => createShopMinisQueryClient(), [])\n\n return (\n <ShopMinisQueryClientContext.Provider value={queryClient}>\n {children}\n </ShopMinisQueryClientContext.Provider>\n )\n}\n"],"names":["MinisQueryProvider","children","queryClient","useMemo","createShopMinisQueryClient","ShopMinisQueryClientContext"],"mappings":";;;AAOgB,SAAAA,EAAmB,EAAC,UAAAC,KAAwC;AAC1E,QAAMC,IAAcC,EAAQ,MAAMC,EAA2B,GAAG,CAAA,CAAE;AAElE,2BACGC,EAA4B,UAA5B,EAAqC,OAAOH,GAC1C,UAAAD,GACH;AAEJ;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createContext as t, useContext as n } from "react";
|
|
2
|
+
import { QueryClient as i } from "../../shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryClient.js";
|
|
3
|
+
const r = t(
|
|
4
|
+
null
|
|
5
|
+
);
|
|
6
|
+
function u() {
|
|
7
|
+
const e = n(r);
|
|
8
|
+
if (!e)
|
|
9
|
+
throw new Error(
|
|
10
|
+
"Shop Minis hooks must be used within <MinisContainer> or <MinisQueryProvider>. Wrap your component tree with one of these providers."
|
|
11
|
+
);
|
|
12
|
+
return e;
|
|
13
|
+
}
|
|
14
|
+
function c() {
|
|
15
|
+
return new i({
|
|
16
|
+
defaultOptions: {
|
|
17
|
+
queries: {
|
|
18
|
+
staleTime: 0,
|
|
19
|
+
// Data is immediately stale
|
|
20
|
+
gcTime: 0,
|
|
21
|
+
// Don't keep in cache after component unmounts
|
|
22
|
+
retry: 1,
|
|
23
|
+
refetchOnWindowFocus: !1
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
r as ShopMinisQueryClientContext,
|
|
30
|
+
c as createShopMinisQueryClient,
|
|
31
|
+
u as useShopMinisQueryClient
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=queryClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryClient.js","sources":["../../../src/internal/reactQuery/queryClient.ts"],"sourcesContent":["import {createContext, useContext} from 'react'\n\nimport {QueryClient} from '@tanstack/react-query'\n\n/**\n * Custom QueryClient context for Shop Minis SDK\n * This ensures our SDK always uses its own QueryClient,\n * even if the parent app has their own QueryClientProvider\n */\nexport const ShopMinisQueryClientContext = createContext<QueryClient | null>(\n null\n)\n\nexport function useShopMinisQueryClient(): QueryClient {\n const client = useContext(ShopMinisQueryClientContext)\n if (!client) {\n throw new Error(\n 'Shop Minis hooks must be used within <MinisContainer> or <MinisQueryProvider>. ' +\n 'Wrap your component tree with one of these providers.'\n )\n }\n return client\n}\n\n/**\n * Create a QueryClient instance for Shop Minis SDK\n * Isolated from any parent app's QueryClient\n *\n * Caching is disabled by default since Apollo provides the cache layer.\n * React Query only provides request deduplication and state management.\n */\nexport function createShopMinisQueryClient() {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 0, // Data is immediately stale\n gcTime: 0, // Don't keep in cache after component unmounts\n retry: 1,\n refetchOnWindowFocus: false,\n },\n },\n })\n}\n"],"names":["ShopMinisQueryClientContext","createContext","useShopMinisQueryClient","client","useContext","createShopMinisQueryClient","QueryClient"],"mappings":";;AASO,MAAMA,IAA8BC;AAAA,EACzC;AACF;AAEO,SAASC,IAAuC;AAC/C,QAAAC,IAASC,EAAWJ,CAA2B;AACrD,MAAI,CAACG;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAEK,SAAAA;AACT;AASO,SAASE,IAA6B;AAC3C,SAAO,IAAIC,EAAY;AAAA,IACrB,gBAAgB;AAAA,MACd,SAAS;AAAA,QACP,WAAW;AAAA;AAAA,QACX,QAAQ;AAAA;AAAA,QACR,OAAO;AAAA,QACP,sBAAsB;AAAA,MAAA;AAAA,IACxB;AAAA,EACF,CACD;AACH;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useMemo as P, useCallback as o } from "react";
|
|
2
|
+
import { useInfiniteQuery as x } from "../../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";
|
|
3
|
+
import { useShopMinisQueryClient as N } from "./queryClient.js";
|
|
4
|
+
function M(i, s, f, u) {
|
|
5
|
+
const { skip: c = !1 } = u ?? {}, l = N(), {
|
|
6
|
+
data: a,
|
|
7
|
+
fetchNextPage: r,
|
|
8
|
+
hasNextPage: g,
|
|
9
|
+
isLoading: p,
|
|
10
|
+
error: d,
|
|
11
|
+
refetch: n
|
|
12
|
+
} = x(
|
|
13
|
+
{
|
|
14
|
+
queryKey: i,
|
|
15
|
+
queryFn: async ({ pageParam: e }) => {
|
|
16
|
+
const t = await s({
|
|
17
|
+
...f,
|
|
18
|
+
after: e
|
|
19
|
+
});
|
|
20
|
+
if (!t.ok)
|
|
21
|
+
throw t.error;
|
|
22
|
+
return t.data;
|
|
23
|
+
},
|
|
24
|
+
getNextPageParam: (e) => e.pageInfo.hasNextPage ? e.pageInfo.endCursor : void 0,
|
|
25
|
+
initialPageParam: void 0,
|
|
26
|
+
enabled: !c
|
|
27
|
+
// Caching disabled by default (handled by Apollo)
|
|
28
|
+
// fetchPolicy param is passed through to the action (Apollo layer)
|
|
29
|
+
},
|
|
30
|
+
l
|
|
31
|
+
), h = P(() => {
|
|
32
|
+
if (!a?.pages || a.pages.length === 0) return null;
|
|
33
|
+
const e = a.pages[0].data;
|
|
34
|
+
return e == null ? null : Array.isArray(e) ? a.pages.flatMap((t) => t.data) : e;
|
|
35
|
+
}, [a?.pages]), y = o(async () => {
|
|
36
|
+
await r();
|
|
37
|
+
}, [r]), m = o(async () => {
|
|
38
|
+
await n();
|
|
39
|
+
}, [n]);
|
|
40
|
+
return {
|
|
41
|
+
data: h,
|
|
42
|
+
loading: p,
|
|
43
|
+
error: d,
|
|
44
|
+
hasNextPage: g ?? !1,
|
|
45
|
+
fetchMore: y,
|
|
46
|
+
refetch: m
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
M as useShopActionInfiniteQuery
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=useShopActionInfiniteQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useShopActionInfiniteQuery.js","sources":["../../../src/internal/reactQuery/useShopActionInfiniteQuery.ts"],"sourcesContent":["import {useCallback, useMemo} from 'react'\n\nimport {ShopActionResult} from '@shopify/shop-minis-platform/actions'\nimport {useInfiniteQuery} from '@tanstack/react-query'\n\nimport {DataHookFetchPolicy} from '../../types'\n\nimport {useShopMinisQueryClient} from './queryClient'\n\n/**\n * Helper to use React Query with Shop Actions (paginated)\n * Replaces useShopActionsPaginatedDataFetching\n *\n * @example\n * ```ts\n * // Example: Fetching saved products\n * const { getSavedProducts } = useShopActions()\n * const { data, loading, error, hasNextPage, fetchMore, refetch } =\n * useShopActionInfiniteQuery(\n * ['savedProducts', { includeSensitive }], // Query key\n * getSavedProducts, // Shop Action\n * { includeSensitive }, // Params (excludes 'after')\n * { skip: false } // Options\n * )\n * // data will be flattened array of products from all pages\n * ```\n */\nexport function useShopActionInfiniteQuery<\n TData,\n TParams extends {after?: string; fetchPolicy?: DataHookFetchPolicy},\n>(\n queryKey: unknown[],\n action: (params: TParams) => Promise<\n ShopActionResult<{\n data: TData\n pageInfo: {hasNextPage: boolean; endCursor: string | null}\n }>\n >,\n params: Omit<TParams, 'after'>,\n options?: {\n skip?: boolean\n }\n) {\n const {skip = false} = options ?? {}\n\n // Always use our SDK's QueryClient for isolation\n const queryClient = useShopMinisQueryClient()\n\n interface PageData {\n data: TData\n pageInfo: {hasNextPage: boolean; endCursor: string | null}\n }\n\n const {\n data,\n fetchNextPage,\n hasNextPage,\n isLoading,\n error,\n refetch: reactQueryRefetch,\n } = useInfiniteQuery<\n PageData,\n Error,\n {pages: PageData[]},\n unknown[],\n string | undefined\n >(\n {\n queryKey,\n queryFn: async ({pageParam}: {pageParam: string | undefined}) => {\n const result = await action({\n ...params,\n after: pageParam,\n } as TParams)\n\n if (!result.ok) {\n throw result.error\n }\n\n return result.data\n },\n getNextPageParam: (lastPage: PageData) =>\n lastPage.pageInfo.hasNextPage ? lastPage.pageInfo.endCursor : undefined,\n initialPageParam: undefined as string | undefined,\n enabled: !skip,\n // Caching disabled by default (handled by Apollo)\n // fetchPolicy param is passed through to the action (Apollo layer)\n },\n queryClient\n )\n\n // Flatten paginated data\n // For paginated queries, we expect TData to be an array type\n // Each page.data is an array that we concatenate together\n const flattenedData = useMemo(() => {\n if (!data?.pages || data.pages.length === 0) return null\n\n // If first page data is null/undefined, return null\n const firstPageData = data.pages[0].data\n if (firstPageData === null || firstPageData === undefined) return null\n\n // If data is array type, flatten all pages\n if (Array.isArray(firstPageData)) {\n return data.pages.flatMap((page: PageData) => page.data as any) as TData\n }\n\n // If data is not an array, just return the first page's data\n // (Though in practice, all Shop Minis paginated queries return arrays)\n return firstPageData as TData\n }, [data?.pages])\n\n // Wrap React Query functions to match expected API\n const fetchMore = useCallback(async () => {\n await fetchNextPage()\n }, [fetchNextPage])\n\n const refetch = useCallback(async () => {\n await reactQueryRefetch()\n }, [reactQueryRefetch])\n\n return {\n data: flattenedData,\n loading: isLoading,\n error: error as Error | null,\n hasNextPage: hasNextPage ?? false,\n fetchMore,\n refetch,\n }\n}\n"],"names":["useShopActionInfiniteQuery","queryKey","action","params","options","skip","queryClient","useShopMinisQueryClient","data","fetchNextPage","hasNextPage","isLoading","error","reactQueryRefetch","useInfiniteQuery","pageParam","result","lastPage","flattenedData","useMemo","firstPageData","page","fetchMore","useCallback","refetch"],"mappings":";;;AA2BO,SAASA,EAIdC,GACAC,GAMAC,GACAC,GAGA;AACA,QAAM,EAAC,MAAAC,IAAO,GAAK,IAAID,KAAW,CAAC,GAG7BE,IAAcC,EAAwB,GAOtC;AAAA,IACJ,MAAAC;AAAA,IACA,eAAAC;AAAA,IACA,aAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAASC;AAAA,EAAA,IACPC;AAAA,IAOF;AAAA,MACE,UAAAb;AAAA,MACA,SAAS,OAAO,EAAC,WAAAc,QAAgD;AACzD,cAAAC,IAAS,MAAMd,EAAO;AAAA,UAC1B,GAAGC;AAAA,UACH,OAAOY;AAAA,QAAA,CACG;AAER,YAAA,CAACC,EAAO;AACV,gBAAMA,EAAO;AAGf,eAAOA,EAAO;AAAA,MAChB;AAAA,MACA,kBAAkB,CAACC,MACjBA,EAAS,SAAS,cAAcA,EAAS,SAAS,YAAY;AAAA,MAChE,kBAAkB;AAAA,MAClB,SAAS,CAACZ;AAAA;AAAA;AAAA,IAGZ;AAAA,IACAC;AAAA,EACF,GAKMY,IAAgBC,EAAQ,MAAM;AAClC,QAAI,CAACX,GAAM,SAASA,EAAK,MAAM,WAAW,EAAU,QAAA;AAGpD,UAAMY,IAAgBZ,EAAK,MAAM,CAAC,EAAE;AACpC,WAAIY,KAAkB,OAA4C,OAG9D,MAAM,QAAQA,CAAa,IACtBZ,EAAK,MAAM,QAAQ,CAACa,MAAmBA,EAAK,IAAW,IAKzDD;AAAA,EAAA,GACN,CAACZ,GAAM,KAAK,CAAC,GAGVc,IAAYC,EAAY,YAAY;AACxC,UAAMd,EAAc;AAAA,EAAA,GACnB,CAACA,CAAa,CAAC,GAEZe,IAAUD,EAAY,YAAY;AACtC,UAAMV,EAAkB;AAAA,EAAA,GACvB,CAACA,CAAiB,CAAC;AAEf,SAAA;AAAA,IACL,MAAMK;AAAA,IACN,SAASP;AAAA,IACT,OAAAC;AAAA,IACA,aAAaF,KAAe;AAAA,IAC5B,WAAAY;AAAA,IACA,SAAAE;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useCallback as y } from "react";
|
|
2
|
+
import { useQuery as d } from "../../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";
|
|
3
|
+
import { useShopMinisQueryClient as p } from "./queryClient.js";
|
|
4
|
+
function k(t, o, a, n) {
|
|
5
|
+
const { skip: i = !1 } = n ?? {}, s = p(), {
|
|
6
|
+
data: u,
|
|
7
|
+
error: c,
|
|
8
|
+
isLoading: l,
|
|
9
|
+
refetch: r
|
|
10
|
+
} = d(
|
|
11
|
+
{
|
|
12
|
+
queryKey: t,
|
|
13
|
+
queryFn: async () => {
|
|
14
|
+
const e = await o(a);
|
|
15
|
+
if (!e.ok)
|
|
16
|
+
throw e.error;
|
|
17
|
+
return e.data.data;
|
|
18
|
+
},
|
|
19
|
+
enabled: !i
|
|
20
|
+
// Caching disabled by default (handled by Apollo)
|
|
21
|
+
// fetchPolicy param is passed through to the action (Apollo layer)
|
|
22
|
+
},
|
|
23
|
+
s
|
|
24
|
+
), f = y(async () => {
|
|
25
|
+
await r();
|
|
26
|
+
}, [r]);
|
|
27
|
+
return {
|
|
28
|
+
data: u ?? null,
|
|
29
|
+
loading: l,
|
|
30
|
+
error: c,
|
|
31
|
+
refetch: f
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
k as useShopActionQuery
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=useShopActionQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useShopActionQuery.js","sources":["../../../src/internal/reactQuery/useShopActionQuery.ts"],"sourcesContent":["import {useCallback} from 'react'\n\nimport {ShopActionResult} from '@shopify/shop-minis-platform/actions'\nimport {useQuery} from '@tanstack/react-query'\n\nimport {DataHookFetchPolicy} from '../../types'\n\nimport {useShopMinisQueryClient} from './queryClient'\n\n/**\n * Helper to use React Query with Shop Actions (non-paginated)\n * Replaces useShopActionsDataFetching\n *\n * @example\n * ```ts\n * const { data, loading, error, refetch } = useShopActionQuery(\n * ['product', id],\n * getProduct,\n * { id },\n * { skip: false }\n * )\n * ```\n */\nexport function useShopActionQuery<\n TData,\n TParams extends {fetchPolicy?: DataHookFetchPolicy},\n>(\n queryKey: unknown[],\n action: (params: TParams) => Promise<ShopActionResult<{data: TData}>>,\n params: TParams,\n options?: {\n skip?: boolean\n }\n) {\n const {skip = false} = options ?? {}\n\n // Always use our SDK's QueryClient for isolation\n const queryClient = useShopMinisQueryClient()\n\n const {\n data,\n error,\n isLoading,\n refetch: reactQueryRefetch,\n } = useQuery(\n {\n queryKey,\n queryFn: async () => {\n const result = await action(params)\n\n if (!result.ok) {\n throw result.error\n }\n\n return result.data.data\n },\n enabled: !skip,\n // Caching disabled by default (handled by Apollo)\n // fetchPolicy param is passed through to the action (Apollo layer)\n },\n queryClient\n )\n\n const refetch = useCallback(async () => {\n await reactQueryRefetch()\n }, [reactQueryRefetch])\n\n return {\n data: data ?? null,\n loading: isLoading,\n error: error as Error | null,\n refetch,\n }\n}\n"],"names":["useShopActionQuery","queryKey","action","params","options","skip","queryClient","useShopMinisQueryClient","data","error","isLoading","reactQueryRefetch","useQuery","result","refetch","useCallback"],"mappings":";;;AAuBO,SAASA,EAIdC,GACAC,GACAC,GACAC,GAGA;AACA,QAAM,EAAC,MAAAC,IAAO,GAAK,IAAID,KAAW,CAAC,GAG7BE,IAAcC,EAAwB,GAEtC;AAAA,IACJ,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAASC;AAAA,EAAA,IACPC;AAAA,IACF;AAAA,MACE,UAAAX;AAAA,MACA,SAAS,YAAY;AACb,cAAAY,IAAS,MAAMX,EAAOC,CAAM;AAE9B,YAAA,CAACU,EAAO;AACV,gBAAMA,EAAO;AAGf,eAAOA,EAAO,KAAK;AAAA,MACrB;AAAA,MACA,SAAS,CAACR;AAAA;AAAA;AAAA,IAGZ;AAAA,IACAC;AAAA,EACF,GAEMQ,IAAUC,EAAY,YAAY;AACtC,UAAMJ,EAAkB;AAAA,EAAA,GACvB,CAACA,CAAiB,CAAC;AAEf,SAAA;AAAA,IACL,MAAMH,KAAQ;AAAA,IACd,SAASE;AAAA,IACT,OAAAD;AAAA,IACA,SAAAK;AAAA,EACF;AACF;"}
|