@shopify/shop-minis-react 0.0.11 → 0.0.13
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/_virtual/debounce.js +8 -0
- package/dist/_virtual/debounce.js.map +1 -0
- package/dist/components/commerce/merchant-card.js +201 -0
- package/dist/components/commerce/merchant-card.js.map +1 -0
- package/dist/components/commerce/product-card.js +11 -9
- package/dist/components/commerce/product-card.js.map +1 -1
- package/dist/hooks/product/useCuratedProducts.js +20 -0
- package/dist/hooks/product/useCuratedProducts.js.map +1 -0
- package/dist/hooks/product/useProduct.js +24 -0
- package/dist/hooks/product/useProduct.js.map +1 -0
- package/dist/hooks/product/useProductMedia.js +24 -0
- package/dist/hooks/product/useProductMedia.js.map +1 -0
- package/dist/hooks/product/useProductSearch.js +44 -0
- package/dist/hooks/product/useProductSearch.js.map +1 -0
- package/dist/hooks/product/useProductVariants.js +21 -0
- package/dist/hooks/product/useProductVariants.js.map +1 -0
- package/dist/hooks/product/useProducts.js +17 -0
- package/dist/hooks/product/useProducts.js.map +1 -0
- package/dist/hooks/shop/useShop.js +17 -0
- package/dist/hooks/shop/useShop.js.map +1 -0
- package/dist/hooks/user/useFollowedShops.js +21 -0
- package/dist/hooks/user/useFollowedShops.js.map +1 -0
- package/dist/hooks/user/useRecentProducts.js +21 -0
- package/dist/hooks/user/useRecentProducts.js.map +1 -0
- package/dist/hooks/user/useRecentShops.js +21 -0
- package/dist/hooks/user/useRecentShops.js.map +1 -0
- package/dist/hooks/user/useSavedProducts.js +21 -0
- package/dist/hooks/user/useSavedProducts.js.map +1 -0
- package/dist/index.js +210 -178
- package/dist/index.js.map +1 -1
- package/dist/internal/useShopActionsPaginatedDataFetching.js +24 -24
- package/dist/internal/useShopActionsPaginatedDataFetching.js.map +1 -1
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Symbol.js +12 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Symbol.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGetTag.js +17 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGetTag.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseTrim.js +15 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseTrim.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_freeGlobal.js +12 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_freeGlobal.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_getRawTag.js +22 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_getRawTag.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_objectToString.js +14 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_objectToString.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.js +12 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_trimmedEndIndex.js +16 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_trimmedEndIndex.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/debounce.js +61 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/debounce.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isObject.js +14 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isObject.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isObjectLike.js +13 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isObjectLike.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isSymbol.js +16 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isSymbol.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/now.js +14 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/now.js.map +1 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/toNumber.js +29 -0
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/toNumber.js.map +1 -0
- package/dist/types/minisSDK.generated.d.js.map +1 -1
- package/package.json +4 -3
- package/src/base.css +273 -0
- package/src/components/commerce/merchant-card.tsx +262 -0
- package/src/components/commerce/product-card.tsx +3 -1
- package/src/components/index.ts +1 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/product/useCuratedProducts.doc.ts +32 -0
- package/src/hooks/product/useCuratedProducts.example.tsx +10 -0
- package/src/hooks/product/useCuratedProducts.ts +41 -0
- package/src/hooks/product/useProduct.ts +45 -0
- package/src/hooks/product/useProductMedia.ts +51 -0
- package/src/hooks/product/useProductSearch.doc.ts +32 -0
- package/src/hooks/product/useProductSearch.example.tsx +13 -0
- package/src/hooks/product/useProductSearch.ts +95 -0
- package/src/hooks/product/useProductVariants.ts +48 -0
- package/src/hooks/product/useProducts.ts +38 -0
- package/src/hooks/shop/useShop.doc.ts +31 -0
- package/src/hooks/shop/useShop.example.tsx +7 -0
- package/src/hooks/shop/useShop.ts +38 -0
- package/src/hooks/user/useFollowedShops.ts +43 -0
- package/src/hooks/user/useRecentProducts.doc.ts +32 -0
- package/src/hooks/user/useRecentProducts.example.tsx +13 -0
- package/src/hooks/user/useRecentProducts.ts +46 -0
- package/src/hooks/user/useRecentShops.ts +43 -0
- package/src/hooks/user/useSavedProducts.doc.ts +32 -0
- package/src/hooks/user/useSavedProducts.example.tsx +13 -0
- package/src/hooks/user/useSavedProducts.ts +46 -0
- package/src/index.css +1 -221
- package/src/internal/useShopActionsPaginatedDataFetching.ts +8 -8
- package/src/types/minisSDK.generated.d.ts +239 -4
- package/src/dev.tsx +0 -868
- package/src/mockActions.ts +0 -237
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
|
|
2
|
+
import { __require as r } from "../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/debounce.js";
|
|
3
|
+
var o = r();
|
|
4
|
+
const a = /* @__PURE__ */ e(o);
|
|
5
|
+
export {
|
|
6
|
+
a as default
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=debounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { jsxs as i, jsx as r, Fragment as x } from "react/jsx-runtime";
|
|
2
|
+
import * as C from "react";
|
|
3
|
+
import { cva as N } from "../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js";
|
|
4
|
+
import { useShopNavigation as y } from "../../hooks/navigation/useShopNavigation.js";
|
|
5
|
+
import { cn as o } from "../../lib/utils.js";
|
|
6
|
+
import { Touchable as M } from "../atoms/touchable.js";
|
|
7
|
+
import b from "../../node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/star.js";
|
|
8
|
+
import { Root as I } from "../../node_modules/.pnpm/@radix-ui_react-slot@1.2.3_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-slot/dist/index.js";
|
|
9
|
+
const R = N(
|
|
10
|
+
"relative w-full aspect-square overflow-hidden rounded-xl border border-grayscale-l20 bg-grayscale-l0 flex flex-col",
|
|
11
|
+
{
|
|
12
|
+
variants: {
|
|
13
|
+
touchable: {
|
|
14
|
+
true: "cursor-pointer",
|
|
15
|
+
false: ""
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
touchable: !0
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
function j(e) {
|
|
24
|
+
return e >= 1e6 ? `${Math.floor(e / 1e5) / 10}M` : e >= 1e3 ? `${Math.floor(e / 1e3)}K` : e.toString();
|
|
25
|
+
}
|
|
26
|
+
function S(e) {
|
|
27
|
+
return Math.round(e * 10) / 10;
|
|
28
|
+
}
|
|
29
|
+
function d({
|
|
30
|
+
className: e,
|
|
31
|
+
touchable: a = !0,
|
|
32
|
+
asChild: t = !1,
|
|
33
|
+
onPress: n,
|
|
34
|
+
...l
|
|
35
|
+
}) {
|
|
36
|
+
const c = /* @__PURE__ */ r(
|
|
37
|
+
t ? I : "div",
|
|
38
|
+
{
|
|
39
|
+
className: o(R({ touchable: a }), e),
|
|
40
|
+
...l
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
return a && n ? /* @__PURE__ */ r(
|
|
44
|
+
M,
|
|
45
|
+
{
|
|
46
|
+
onClick: n,
|
|
47
|
+
whileTap: { opacity: 0.7 },
|
|
48
|
+
transition: {
|
|
49
|
+
opacity: { type: "tween", duration: 0.08, ease: "easeInOut" }
|
|
50
|
+
},
|
|
51
|
+
children: c
|
|
52
|
+
}
|
|
53
|
+
) : c;
|
|
54
|
+
}
|
|
55
|
+
function m({
|
|
56
|
+
className: e,
|
|
57
|
+
...a
|
|
58
|
+
}) {
|
|
59
|
+
return /* @__PURE__ */ r(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
"data-slot": "merchant-card-image-container",
|
|
63
|
+
className: o("relative overflow-hidden w-full flex-grow", e),
|
|
64
|
+
...a
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function f({
|
|
69
|
+
className: e,
|
|
70
|
+
src: a,
|
|
71
|
+
alt: t,
|
|
72
|
+
...n
|
|
73
|
+
}) {
|
|
74
|
+
return a ? /* @__PURE__ */ r(
|
|
75
|
+
"img",
|
|
76
|
+
{
|
|
77
|
+
"data-slot": "merchant-card-image",
|
|
78
|
+
src: a,
|
|
79
|
+
alt: t,
|
|
80
|
+
className: o("w-full h-full object-cover", e),
|
|
81
|
+
...n
|
|
82
|
+
}
|
|
83
|
+
) : /* @__PURE__ */ r("div", { className: "w-full h-full bg-grayscale-l10" });
|
|
84
|
+
}
|
|
85
|
+
function u({
|
|
86
|
+
className: e,
|
|
87
|
+
src: a,
|
|
88
|
+
alt: t,
|
|
89
|
+
...n
|
|
90
|
+
}) {
|
|
91
|
+
return /* @__PURE__ */ r(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
"data-slot": "merchant-card-logo",
|
|
95
|
+
className: o(
|
|
96
|
+
"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
|
|
97
|
+
"w-14 h-14 rounded-xl",
|
|
98
|
+
"flex items-center justify-center overflow-hidden",
|
|
99
|
+
e
|
|
100
|
+
),
|
|
101
|
+
...n,
|
|
102
|
+
children: a ? /* @__PURE__ */ r("img", { src: a, alt: t, className: "w-full h-full object-cover" }) : /* @__PURE__ */ r("div", { className: "w-full h-full bg-grayscale-l20" })
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
function h({ className: e, ...a }) {
|
|
107
|
+
return /* @__PURE__ */ r(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
"data-slot": "merchant-card-info",
|
|
111
|
+
className: o("p-3 space-y-1 flex-shrink-0", e),
|
|
112
|
+
...a
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
function g({
|
|
117
|
+
className: e,
|
|
118
|
+
children: a,
|
|
119
|
+
...t
|
|
120
|
+
}) {
|
|
121
|
+
return /* @__PURE__ */ r(
|
|
122
|
+
"h3",
|
|
123
|
+
{
|
|
124
|
+
"data-slot": "merchant-card-name",
|
|
125
|
+
className: o(
|
|
126
|
+
"text-sm font-medium text-grayscale-d100",
|
|
127
|
+
"truncate overflow-hidden whitespace-nowrap text-ellipsis",
|
|
128
|
+
e
|
|
129
|
+
),
|
|
130
|
+
...t,
|
|
131
|
+
children: a
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
function p({
|
|
136
|
+
className: e,
|
|
137
|
+
rating: a,
|
|
138
|
+
reviewCount: t,
|
|
139
|
+
...n
|
|
140
|
+
}) {
|
|
141
|
+
return !a || !t ? null : /* @__PURE__ */ i(
|
|
142
|
+
"div",
|
|
143
|
+
{
|
|
144
|
+
"data-slot": "merchant-card-rating",
|
|
145
|
+
className: o(
|
|
146
|
+
"flex items-center gap-1 text-sm text-grayscale-d100",
|
|
147
|
+
e
|
|
148
|
+
),
|
|
149
|
+
...n,
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ r(b, { className: "h-3.5 w-3.5 fill-current" }),
|
|
152
|
+
/* @__PURE__ */ i(x, { children: [
|
|
153
|
+
S(a),
|
|
154
|
+
" (",
|
|
155
|
+
j(t),
|
|
156
|
+
")"
|
|
157
|
+
] })
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
function q({ shop: e, touchable: a = !0 }) {
|
|
163
|
+
const { navigateToShop: t } = y(), {
|
|
164
|
+
id: n,
|
|
165
|
+
name: l,
|
|
166
|
+
logoImage: s,
|
|
167
|
+
reviewAnalytics: { averageRating: c, reviewCount: v }
|
|
168
|
+
} = e, w = C.useCallback(() => {
|
|
169
|
+
a && t({ shopId: n });
|
|
170
|
+
}, [t, n, a]);
|
|
171
|
+
return /* @__PURE__ */ i(d, { touchable: a, onPress: w, children: [
|
|
172
|
+
/* @__PURE__ */ i(m, { children: [
|
|
173
|
+
/* @__PURE__ */ r(f, { src: void 0, alt: `${l} featured image` }),
|
|
174
|
+
/* @__PURE__ */ r(u, { src: s?.url, alt: `${l} logo` })
|
|
175
|
+
] }),
|
|
176
|
+
/* @__PURE__ */ i(h, { children: [
|
|
177
|
+
/* @__PURE__ */ r(g, { children: l }),
|
|
178
|
+
/* @__PURE__ */ r(p, { rating: c, reviewCount: v })
|
|
179
|
+
] })
|
|
180
|
+
] });
|
|
181
|
+
}
|
|
182
|
+
const z = Object.assign(d, {
|
|
183
|
+
ImageContainer: m,
|
|
184
|
+
Image: f,
|
|
185
|
+
Logo: u,
|
|
186
|
+
Info: h,
|
|
187
|
+
Name: g,
|
|
188
|
+
Rating: p
|
|
189
|
+
});
|
|
190
|
+
export {
|
|
191
|
+
q as MerchantCard,
|
|
192
|
+
f as MerchantCardImage,
|
|
193
|
+
m as MerchantCardImageContainer,
|
|
194
|
+
h as MerchantCardInfo,
|
|
195
|
+
u as MerchantCardLogo,
|
|
196
|
+
g as MerchantCardName,
|
|
197
|
+
z as MerchantCardPrimitive,
|
|
198
|
+
p as MerchantCardRating,
|
|
199
|
+
d as MerchantCardRoot
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=merchant-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merchant-card.js","sources":["../../../src/components/commerce/merchant-card.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {cva, type VariantProps} from 'class-variance-authority'\nimport {Star} from 'lucide-react'\nimport {Slot as SlotPrimitive} from 'radix-ui'\n\nimport {useShopNavigation} from '../../hooks/navigation/useShopNavigation'\nimport {cn} from '../../lib/utils'\nimport {type Shop} from '../../types/minisSDK.generated.d'\nimport {Touchable} from '../atoms/touchable'\n\nconst merchantCardVariants = cva(\n 'relative w-full aspect-square overflow-hidden rounded-xl border border-grayscale-l20 bg-grayscale-l0 flex flex-col',\n {\n variants: {\n touchable: {\n true: 'cursor-pointer',\n false: '',\n },\n },\n defaultVariants: {\n touchable: true,\n },\n }\n)\n\nfunction formatReviewCount(count: number): string {\n if (count >= 1000000) {\n return `${Math.floor(count / 100000) / 10}M`\n }\n if (count >= 1000) {\n return `${Math.floor(count / 1000)}K`\n }\n return count.toString()\n}\n\nfunction normalizeRating(rating: number): number {\n return Math.round(rating * 10) / 10\n}\n\nexport interface MerchantCardRootProps\n extends React.ComponentProps<'div'>,\n VariantProps<typeof merchantCardVariants> {\n touchable?: boolean\n asChild?: boolean\n onPress?: () => void\n}\n\nfunction MerchantCardRoot({\n className,\n touchable = true,\n asChild = false,\n onPress,\n ...props\n}: MerchantCardRootProps) {\n const Comp = asChild ? SlotPrimitive.Slot : 'div'\n\n const content = (\n <Comp\n className={cn(merchantCardVariants({touchable}), className)}\n {...props}\n />\n )\n\n if (touchable && onPress) {\n return (\n <Touchable\n onClick={onPress}\n whileTap={{opacity: 0.7}}\n transition={{\n opacity: {type: 'tween', duration: 0.08, ease: 'easeInOut'},\n }}\n >\n {content}\n </Touchable>\n )\n }\n\n return content\n}\n\nfunction MerchantCardImageContainer({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"merchant-card-image-container\"\n className={cn('relative overflow-hidden w-full flex-grow', className)}\n {...props}\n />\n )\n}\n\nfunction MerchantCardImage({\n className,\n src,\n alt,\n ...props\n}: React.ComponentProps<'img'> & {\n src?: string\n alt?: string\n}) {\n return src ? (\n <img\n data-slot=\"merchant-card-image\"\n src={src}\n alt={alt}\n className={cn('w-full h-full object-cover', className)}\n {...props}\n />\n ) : (\n <div className=\"w-full h-full bg-grayscale-l10\" />\n )\n}\n\nfunction MerchantCardLogo({\n className,\n src,\n alt,\n ...props\n}: React.ComponentProps<'div'> & {\n src?: string\n alt?: string\n}) {\n return (\n <div\n data-slot=\"merchant-card-logo\"\n className={cn(\n 'absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2',\n 'w-14 h-14 rounded-xl',\n 'flex items-center justify-center overflow-hidden',\n className\n )}\n {...props}\n >\n {src ? (\n <img src={src} alt={alt} className=\"w-full h-full object-cover\" />\n ) : (\n <div className=\"w-full h-full bg-grayscale-l20\" />\n )}\n </div>\n )\n}\n\nfunction MerchantCardInfo({className, ...props}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"merchant-card-info\"\n className={cn('p-3 space-y-1 flex-shrink-0', className)}\n {...props}\n />\n )\n}\n\nfunction MerchantCardName({\n className,\n children,\n ...props\n}: React.ComponentProps<'h3'>) {\n return (\n <h3\n data-slot=\"merchant-card-name\"\n className={cn(\n 'text-sm font-medium text-grayscale-d100',\n 'truncate overflow-hidden whitespace-nowrap text-ellipsis',\n className\n )}\n {...props}\n >\n {children}\n </h3>\n )\n}\n\nfunction MerchantCardRating({\n className,\n rating,\n reviewCount,\n ...props\n}: React.ComponentProps<'div'> & {\n rating?: number | null\n reviewCount?: number\n}) {\n if (!rating || !reviewCount) return null\n\n return (\n <div\n data-slot=\"merchant-card-rating\"\n className={cn(\n 'flex items-center gap-1 text-sm text-grayscale-d100',\n className\n )}\n {...props}\n >\n <Star className=\"h-3.5 w-3.5 fill-current\" />\n <>\n {normalizeRating(rating)} ({formatReviewCount(reviewCount)})\n </>\n </div>\n )\n}\n\nexport interface MerchantCardProps {\n shop: Shop\n touchable?: boolean\n}\n\n// Composed MerchantCard component\nfunction MerchantCard({shop, touchable = true}: MerchantCardProps) {\n const {navigateToShop} = useShopNavigation()\n\n const {\n id,\n name,\n logoImage,\n reviewAnalytics: {averageRating, reviewCount},\n } = shop\n\n const handlePress = React.useCallback(() => {\n if (!touchable) return\n navigateToShop({shopId: id})\n }, [navigateToShop, id, touchable])\n\n return (\n <MerchantCardRoot touchable={touchable} onPress={handlePress}>\n <MerchantCardImageContainer>\n {/* TODO: Add featured image */}\n <MerchantCardImage src={undefined} alt={`${name} featured image`} />\n <MerchantCardLogo src={logoImage?.url} alt={`${name} logo`} />\n </MerchantCardImageContainer>\n\n <MerchantCardInfo>\n <MerchantCardName>{name}</MerchantCardName>\n <MerchantCardRating rating={averageRating} reviewCount={reviewCount} />\n </MerchantCardInfo>\n </MerchantCardRoot>\n )\n}\n\n// Export with Object.assign pattern\nexport const MerchantCardPrimitive = Object.assign(MerchantCardRoot, {\n ImageContainer: MerchantCardImageContainer,\n Image: MerchantCardImage,\n Logo: MerchantCardLogo,\n Info: MerchantCardInfo,\n Name: MerchantCardName,\n Rating: MerchantCardRating,\n})\n\nexport {\n // Composed component\n MerchantCard,\n // Primitive components for custom composition\n MerchantCardRoot,\n MerchantCardImageContainer,\n MerchantCardImage,\n MerchantCardLogo,\n MerchantCardInfo,\n MerchantCardName,\n MerchantCardRating,\n}\n"],"names":["merchantCardVariants","cva","formatReviewCount","count","normalizeRating","rating","MerchantCardRoot","className","touchable","asChild","onPress","props","content","jsx","SlotPrimitive.Slot","cn","Touchable","MerchantCardImageContainer","MerchantCardImage","src","alt","MerchantCardLogo","MerchantCardInfo","MerchantCardName","children","MerchantCardRating","reviewCount","jsxs","Star","Fragment","MerchantCard","shop","navigateToShop","useShopNavigation","id","name","logoImage","averageRating","handlePress","React","MerchantCardPrimitive"],"mappings":";;;;;;;;AAWA,MAAMA,IAAuBC;AAAA,EAC3B;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,WAAW;AAAA,QACT,MAAM;AAAA,QACN,OAAO;AAAA,MAAA;AAAA,IAEX;AAAA,IACA,iBAAiB;AAAA,MACf,WAAW;AAAA,IAAA;AAAA,EACb;AAEJ;AAEA,SAASC,EAAkBC,GAAuB;AAChD,SAAIA,KAAS,MACJ,GAAG,KAAK,MAAMA,IAAQ,GAAM,IAAI,EAAE,MAEvCA,KAAS,MACJ,GAAG,KAAK,MAAMA,IAAQ,GAAI,CAAC,MAE7BA,EAAM,SAAS;AACxB;AAEA,SAASC,EAAgBC,GAAwB;AAC/C,SAAO,KAAK,MAAMA,IAAS,EAAE,IAAI;AACnC;AAUA,SAASC,EAAiB;AAAA,EACxB,WAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,SAAAC,IAAU;AAAA,EACV,SAAAC;AAAA,EACA,GAAGC;AACL,GAA0B;AAGxB,QAAMC,IACJ,gBAAAC;AAAA,IAHWJ,IAAUK,IAAqB;AAAA,IAGzC;AAAA,MACC,WAAWC,EA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A,EAAC,gBAAAwB,EAAc,IAAIC,EAAkB,GAErC;AAAA,IACJ,IAAAC;AAAA,IACA,MAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAiB,EAAC,eAAAC,GAAe,aAAAX,EAAW;AAAA,EAAA,IAC1CK,GAEEO,IAAcC,EAAM,YAAY,MAAM;AAC1C,IAAK/B,KACUwB,EAAA,EAAC,QAAQE,GAAG;AAAA,EAC1B,GAAA,CAACF,GAAgBE,GAAI1B,CAAS,CAAC;AAElC,SACG,gBAAAmB,EAAArB,GAAA,EAAiB,WAAAE,GAAsB,SAAS8B,GAC/C,UAAA;AAAA,IAAA,gBAAAX,EAACV,GAEC,EAAA,UAAA;AAAA,MAAA,gBAAAJ,EAACK,KAAkB,KAAK,QAAW,KAAK,GAAGiB,CAAI,mBAAmB;AAAA,MAClE,gBAAAtB,EAACQ,KAAiB,KAAKe,GAAW,KAAK,KAAK,GAAGD,CAAI,QAAS,CAAA;AAAA,IAAA,GAC9D;AAAA,sBAECb,GACC,EAAA,UAAA;AAAA,MAAA,gBAAAT,EAACU,KAAkB,UAAKY,EAAA,CAAA;AAAA,MACvB,gBAAAtB,EAAAY,GAAA,EAAmB,QAAQY,GAAe,aAAAX,EAA0B,CAAA;AAAA,IAAA,EACvE,CAAA;AAAA,EAAA,GACF;AAEJ;AAGa,MAAAc,IAAwB,OAAO,OAAOlC,GAAkB;AAAA,EACnE,gBAAgBW;AAAA,EAChB,OAAOC;AAAA,EACP,MAAMG;AAAA,EACN,MAAMC;AAAA,EACN,MAAMC;AAAA,EACN,QAAQE;AACV,CAAC;"}
|
|
@@ -71,6 +71,8 @@ function Y({
|
|
|
71
71
|
{
|
|
72
72
|
"data-slot": "product-card-image-container",
|
|
73
73
|
className: a(
|
|
74
|
+
// Ensure the product image is stretched to the full size of the container (can't use width/height: 100% because of flex)
|
|
75
|
+
"flex justify-stretch items-stretch",
|
|
74
76
|
"relative overflow-hidden rounded-xl border border-gray-200",
|
|
75
77
|
"w-full aspect-square",
|
|
76
78
|
t === "compact" ? "min-h-[104px]" : "min-h-[134px]",
|
|
@@ -86,7 +88,7 @@ function Z({
|
|
|
86
88
|
alt: o,
|
|
87
89
|
...c
|
|
88
90
|
}) {
|
|
89
|
-
return /* @__PURE__ */ r("div", { className: "
|
|
91
|
+
return /* @__PURE__ */ r("div", { className: "bg-gray-100 flex items-center justify-center", children: t ? /* @__PURE__ */ r(
|
|
90
92
|
"img",
|
|
91
93
|
{
|
|
92
94
|
"data-slot": "product-card-image",
|
|
@@ -97,7 +99,7 @@ function Z({
|
|
|
97
99
|
}
|
|
98
100
|
) : /* @__PURE__ */ r("div", { className: "text-gray-400 text-sm", children: "No Image" }) });
|
|
99
101
|
}
|
|
100
|
-
function
|
|
102
|
+
function j({
|
|
101
103
|
className: e,
|
|
102
104
|
position: t = "bottom-left",
|
|
103
105
|
children: o,
|
|
@@ -191,7 +193,7 @@ function rt({ className: e, ...t }) {
|
|
|
191
193
|
}
|
|
192
194
|
);
|
|
193
195
|
}
|
|
194
|
-
function
|
|
196
|
+
function S({
|
|
195
197
|
className: e,
|
|
196
198
|
...t
|
|
197
199
|
}) {
|
|
@@ -274,8 +276,8 @@ function ht({
|
|
|
274
276
|
children: [
|
|
275
277
|
/* @__PURE__ */ p(Y, { variant: o, children: [
|
|
276
278
|
/* @__PURE__ */ r(Z, { src: R, alt: T }),
|
|
277
|
-
o === "priceOverlay" && s && l && /* @__PURE__ */ r(
|
|
278
|
-
i && /* @__PURE__ */ r(
|
|
279
|
+
o === "priceOverlay" && s && l && /* @__PURE__ */ r(j, { position: "top-left", children: f(l, s) }),
|
|
280
|
+
i && /* @__PURE__ */ r(j, { position: "bottom-left", variant: h, children: i }),
|
|
279
281
|
/* @__PURE__ */ r(
|
|
280
282
|
_,
|
|
281
283
|
{
|
|
@@ -287,12 +289,12 @@ function ht({
|
|
|
287
289
|
/* @__PURE__ */ p($, { variant: o, children: [
|
|
288
290
|
/* @__PURE__ */ r(tt, { children: w }),
|
|
289
291
|
/* @__PURE__ */ r(rt, { children: L ? /* @__PURE__ */ p(H, { children: [
|
|
290
|
-
/* @__PURE__ */ r(
|
|
292
|
+
/* @__PURE__ */ r(S, { children: f(l, s) }),
|
|
291
293
|
/* @__PURE__ */ r(et, { children: f(
|
|
292
294
|
C,
|
|
293
295
|
A?.currencyCode || s
|
|
294
296
|
) })
|
|
295
|
-
] }) : /* @__PURE__ */ r(
|
|
297
|
+
] }) : /* @__PURE__ */ r(S, { children: f(l, s) }) })
|
|
296
298
|
] })
|
|
297
299
|
]
|
|
298
300
|
}
|
|
@@ -300,8 +302,8 @@ function ht({
|
|
|
300
302
|
}
|
|
301
303
|
export {
|
|
302
304
|
ht as ProductCard,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
+
j as ProductCardBadge,
|
|
306
|
+
S as ProductCardCurrentPrice,
|
|
305
307
|
_ as ProductCardFavoriteButton,
|
|
306
308
|
Z as ProductCardImage,
|
|
307
309
|
Y as ProductCardImageContainer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-card.js","sources":["../../../src/components/commerce/product-card.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {cva, type VariantProps} from 'class-variance-authority'\nimport {Heart} from 'lucide-react'\nimport {Slot as SlotPrimitive} from 'radix-ui'\n\nimport {useShopNavigation} from '../../hooks/navigation/useShopNavigation'\nimport {useSavedProductsActions} from '../../hooks/user/useSavedProductsActions'\nimport {formatMoney} from '../../lib/formatMoney'\nimport {cn} from '../../lib/utils'\nimport {\n type Product,\n type ProductVariant,\n} from '../../types/minisSDK.generated.d'\nimport {Badge} from '../atoms/badge'\nimport {Button} from '../atoms/button'\nimport {Touchable} from '../atoms/touchable'\n\nconst productCardVariants = cva(\n 'relative w-full overflow-hidden rounded-xl border border-gray-200',\n {\n variants: {\n variant: {\n default: '',\n priceOverlay: '',\n compact: '',\n },\n touchable: {\n true: 'cursor-pointer',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'default',\n touchable: true,\n },\n }\n)\n\n// Primitive components (building blocks)\nexport interface ProductCardRootProps\n extends React.ComponentProps<'div'>,\n VariantProps<typeof productCardVariants> {\n variant?: 'default' | 'priceOverlay' | 'compact'\n touchable?: boolean\n asChild?: boolean\n onPress?: () => void\n}\n\nfunction ProductCardRoot({\n className,\n variant,\n touchable = true,\n asChild = false,\n onPress,\n ...props\n}: ProductCardRootProps) {\n const Comp = asChild ? SlotPrimitive.Slot : 'div'\n\n const content = (\n <Comp\n className={cn(\n productCardVariants({variant, touchable}),\n 'border-0',\n className\n )}\n {...props}\n />\n )\n\n if (touchable && onPress) {\n return (\n <Touchable\n onClick={onPress}\n whileTap={{opacity: 0.7}}\n transition={{\n opacity: {type: 'tween', duration: 0.08, ease: 'easeInOut'},\n }}\n >\n {content}\n </Touchable>\n )\n }\n\n return content\n}\n\nfunction ProductCardImageContainer({\n className,\n variant = 'default',\n ...props\n}: React.ComponentProps<'div'> & {\n variant?: 'default' | 'priceOverlay' | 'compact'\n}) {\n return (\n <div\n data-slot=\"product-card-image-container\"\n className={cn(\n 'relative overflow-hidden rounded-xl border border-gray-200',\n 'w-full aspect-square',\n variant === 'compact' ? 'min-h-[104px]' : 'min-h-[134px]',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ProductCardImage({\n className,\n src,\n alt,\n ...props\n}: React.ComponentProps<'img'> & {\n src?: string\n alt?: string\n}) {\n return (\n <div className=\"w-full h-full bg-gray-100 flex items-center justify-center\">\n {src ? (\n <img\n data-slot=\"product-card-image\"\n src={src}\n alt={alt}\n className={cn('w-full h-full object-cover', className)}\n {...props}\n />\n ) : (\n <div className=\"text-gray-400 text-sm\">No Image</div>\n )}\n </div>\n )\n}\n\nfunction ProductCardBadge({\n className,\n position = 'bottom-left',\n children,\n ...props\n}: React.ComponentProps<typeof Badge> & {\n position?: 'top-left' | 'bottom-left'\n}) {\n return (\n <div\n className={cn(\n 'absolute z-10',\n position === 'top-left' ? 'top-3 left-3' : 'bottom-2 left-2'\n )}\n >\n <Badge\n className={cn('bg-black/50 text-white rounded', className)}\n {...props}\n >\n {children}\n </Badge>\n </div>\n )\n}\n\nfunction ProductCardFavoriteButton({\n className,\n onPress,\n filled = false,\n ...props\n}: React.ComponentProps<'div'> & {\n onPress?: () => void\n filled?: boolean\n}) {\n return (\n <div className={cn('absolute bottom-3 right-3 z-10', className)} {...props}>\n <Button\n onClick={onPress}\n variant=\"secondary\"\n size=\"icon\"\n className={cn(\n 'h-8 w-8 rounded-full border-0 shadow-sm',\n filled ? 'bg-primary' : 'bg-grayscale-l6/60 backdrop-blur-sm'\n )}\n stopPropagation\n >\n <Heart\n fill={filled ? 'currentColor' : 'none'}\n className=\"h-4 w-4 text-white\"\n />\n </Button>\n </div>\n )\n}\n\nfunction ProductCardInfo({\n className,\n variant = 'default',\n ...props\n}: React.ComponentProps<'div'> & {\n variant?: 'default' | 'priceOverlay' | 'compact'\n}) {\n if (variant !== 'default') {\n return null\n }\n\n return (\n <div\n data-slot=\"product-card-info\"\n className={cn('px-1 pt-2 pb-0 space-y-1', className)}\n {...props}\n />\n )\n}\n\nfunction ProductCardTitle({\n className,\n children,\n ...props\n}: React.ComponentProps<'h3'>) {\n return (\n <h3\n data-slot=\"product-card-title\"\n className={cn(\n 'text-sm font-medium leading-tight text-gray-900',\n 'truncate overflow-hidden whitespace-nowrap text-ellipsis',\n className\n )}\n {...props}\n >\n {children}\n </h3>\n )\n}\n\nfunction ProductCardPrice({className, ...props}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"product-card-price\"\n className={cn('flex items-center gap-2', className)}\n {...props}\n />\n )\n}\n\nfunction ProductCardCurrentPrice({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"product-card-current-price\"\n className={cn('text-sm font-semibold text-gray-900', className)}\n {...props}\n />\n )\n}\n\nfunction ProductCardOriginalPrice({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"product-card-original-price\"\n className={cn('text-sm text-gray-500 line-through', className)}\n {...props}\n />\n )\n}\n\nexport interface ProductCardProps {\n product: Product\n selectedProductVariant?: ProductVariant\n variant?: 'default' | 'priceOverlay' | 'compact'\n touchable?: boolean\n badgeText?: string\n badgeVariant?: 'default' | 'secondary' | 'destructive' | 'outline'\n onFavoriteToggled?: (isFavorited: boolean) => void\n sectionId?: string\n}\n\n// Composed ProductCard component\nfunction ProductCard({\n product,\n selectedProductVariant,\n variant = 'default',\n touchable = true,\n badgeText,\n badgeVariant = 'secondary',\n onFavoriteToggled,\n}: ProductCardProps) {\n const {navigateToProduct} = useShopNavigation()\n const {saveProduct, unsaveProduct} = useSavedProductsActions()\n\n const {\n id,\n title,\n featuredImage,\n price,\n compareAtPrice,\n isFavorited,\n defaultVariantId,\n shop,\n } = product\n\n // Use selected variant data if available\n const displayImage = selectedProductVariant?.image || featuredImage\n const displayPrice = selectedProductVariant?.price || price\n const displayCompareAtPrice =\n selectedProductVariant?.compareAtPrice || compareAtPrice\n\n // Local state for optimistic UI updates\n const [isFavoritedLocal, setIsFavoritedLocal] = React.useState(isFavorited)\n\n const currencyCode = displayPrice?.currencyCode\n const amount = displayPrice?.amount\n const imageUrl = displayImage?.url\n const imageAltText = displayImage?.altText || title\n const compareAtPriceAmount = displayCompareAtPrice?.amount\n const hasDiscount = compareAtPriceAmount && compareAtPriceAmount !== amount\n\n const handlePress = React.useCallback(() => {\n if (!touchable) return\n\n navigateToProduct({\n productId: id,\n })\n }, [navigateToProduct, id, touchable])\n\n const handleFavoritePress = React.useCallback(async () => {\n const previousState = isFavoritedLocal\n\n // Optimistic update\n setIsFavoritedLocal(!previousState)\n onFavoriteToggled?.(!previousState)\n\n try {\n if (previousState) {\n await unsaveProduct({\n productId: id,\n shopId: shop.id,\n productVariantId: selectedProductVariant?.id || defaultVariantId,\n })\n } else {\n await saveProduct({\n productId: id,\n shopId: shop.id,\n productVariantId: selectedProductVariant?.id || defaultVariantId,\n })\n }\n } catch (error) {\n // Revert optimistic update on error\n setIsFavoritedLocal(previousState)\n onFavoriteToggled?.(previousState)\n }\n }, [\n isFavoritedLocal,\n id,\n shop.id,\n selectedProductVariant?.id,\n defaultVariantId,\n saveProduct,\n unsaveProduct,\n onFavoriteToggled,\n ])\n\n return (\n <ProductCardRoot\n variant={variant}\n touchable={touchable}\n onPress={handlePress}\n >\n <ProductCardImageContainer variant={variant}>\n <ProductCardImage src={imageUrl} alt={imageAltText} />\n\n {/* Price overlay badge for priceOverlay variant */}\n {variant === 'priceOverlay' && currencyCode && amount && (\n <ProductCardBadge position=\"top-left\">\n {formatMoney(amount, currencyCode)}\n </ProductCardBadge>\n )}\n\n {/* Custom badge */}\n {badgeText && (\n <ProductCardBadge position=\"bottom-left\" variant={badgeVariant}>\n {badgeText}\n </ProductCardBadge>\n )}\n\n {/* Favorite button */}\n <ProductCardFavoriteButton\n filled={isFavoritedLocal}\n onPress={handleFavoritePress}\n />\n </ProductCardImageContainer>\n\n {/* Product info for default variant */}\n <ProductCardInfo variant={variant}>\n <ProductCardTitle>{title}</ProductCardTitle>\n\n <ProductCardPrice>\n {hasDiscount ? (\n <>\n <ProductCardCurrentPrice>\n {formatMoney(amount, currencyCode)}\n </ProductCardCurrentPrice>\n <ProductCardOriginalPrice>\n {formatMoney(\n compareAtPriceAmount,\n displayCompareAtPrice?.currencyCode || currencyCode\n )}\n </ProductCardOriginalPrice>\n </>\n ) : (\n <ProductCardCurrentPrice>\n {formatMoney(amount, currencyCode)}\n </ProductCardCurrentPrice>\n )}\n </ProductCardPrice>\n </ProductCardInfo>\n </ProductCardRoot>\n )\n}\n\nexport {\n // Composed component\n ProductCard,\n // Primitive components for custom composition\n ProductCardRoot,\n ProductCardImageContainer,\n ProductCardImage,\n ProductCardBadge,\n ProductCardFavoriteButton,\n ProductCardInfo,\n ProductCardTitle,\n ProductCardPrice,\n ProductCardCurrentPrice,\n ProductCardOriginalPrice,\n}\n"],"names":["productCardVariants","cva","ProductCardRoot","className","variant","touchable","asChild","onPress","props","content","jsx","SlotPrimitive.Slot","cn","Touchable","ProductCardImageContainer","ProductCardImage","src","alt","ProductCardBadge","position","children","Badge","ProductCardFavoriteButton","filled","Button","Heart","ProductCardInfo","ProductCardTitle","ProductCardPrice","ProductCardCurrentPrice","ProductCardOriginalPrice","ProductCard","product","selectedProductVariant","badgeText","badgeVariant","onFavoriteToggled","navigateToProduct","useShopNavigation","saveProduct","unsaveProduct","useSavedProductsActions","id","title","featuredImage","price","compareAtPrice","isFavorited","defaultVariantId","shop","displayImage","displayPrice","displayCompareAtPrice","isFavoritedLocal","setIsFavoritedLocal","React","currencyCode","amount","imageUrl","imageAltText","compareAtPriceAmount","hasDiscount","handlePress","handleFavoritePress","previousState","jsxs","formatMoney","Fragment"],"mappings":";;;;;;;;;;;;AAkBA,MAAMA,IAAsBC;AAAA,EAC1B;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,cAAc;AAAA,QACd,SAAS;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,MAAM;AAAA,QACN,OAAO;AAAA,MAAA;AAAA,IAEX;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,WAAW;AAAA,IAAA;AAAA,EACb;AAEJ;AAYA,SAASC,EAAgB;AAAA,EACvB,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,SAAAC,IAAU;AAAA,EACV,SAAAC;AAAA,EACA,GAAGC;AACL,GAAyB;AAGvB,QAAMC,IACJ,gBAAAC;AAAA,IAHWJ,IAAUK,IAAqB;AAAA,IAGzC;AAAA,MACC,WAAWC;AAAA,QACTZ,EAAoB,EAAC,SAAAI,GAAS,WAAAC,GAAU;AAAA,QACxC;AAAA,QACAF;AAAA,MACF;AAAA,MACC,GAAGK;AAAA,IAAA;AAAA,EACN;AAGF,SAAIH,KAAaE,IAEb,gBAAAG;AAAA,IAACG;AAAA,IAAA;AAAA,MACC,SAASN;AAAA,MACT,UAAU,EAA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AAiB,UAAS,eAAc,SAASiB,GAC/C,UACHD,GAAA;AAAA,UAIF,gBAAAxB;AAAA,YAACY;AAAA,YAAA;AAAA,cACC,QAAQ+B;AAAA,cACR,SAASU;AAAA,YAAA;AAAA,UAAA;AAAA,QACX,GACF;AAAA,QAGA,gBAAAE,EAACvC,KAAgB,SAAAtB,GACf,UAAA;AAAA,UAAA,gBAAAM,EAACiB,MAAkB,UAAMgB,EAAA,CAAA;AAAA,UAEzB,gBAAAjC,EAACkB,IACE,EAAA,UAAAiC,IAEG,gBAAAI,EAAAE,GAAA,EAAA,UAAA;AAAA,YAAA,gBAAAzD,EAACmB,GACE,EAAA,UAAAqC,EAAYT,GAAQD,CAAY,GACnC;AAAA,8BACC1B,IACE,EAAA,UAAAoC;AAAA,cACCN;AAAA,cACAR,GAAuB,gBAAgBI;AAAA,YAAA,EAE3C,CAAA;AAAA,UAAA,GACF,IAEC,gBAAA9C,EAAAmB,GAAA,EACE,YAAY4B,GAAQD,CAAY,GACnC,EAEJ,CAAA;AAAA,QAAA,EACF,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"product-card.js","sources":["../../../src/components/commerce/product-card.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {cva, type VariantProps} from 'class-variance-authority'\nimport {Heart} from 'lucide-react'\nimport {Slot as SlotPrimitive} from 'radix-ui'\n\nimport {useShopNavigation} from '../../hooks/navigation/useShopNavigation'\nimport {useSavedProductsActions} from '../../hooks/user/useSavedProductsActions'\nimport {formatMoney} from '../../lib/formatMoney'\nimport {cn} from '../../lib/utils'\nimport {\n type Product,\n type ProductVariant,\n} from '../../types/minisSDK.generated.d'\nimport {Badge} from '../atoms/badge'\nimport {Button} from '../atoms/button'\nimport {Touchable} from '../atoms/touchable'\n\nconst productCardVariants = cva(\n 'relative w-full overflow-hidden rounded-xl border border-gray-200',\n {\n variants: {\n variant: {\n default: '',\n priceOverlay: '',\n compact: '',\n },\n touchable: {\n true: 'cursor-pointer',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'default',\n touchable: true,\n },\n }\n)\n\n// Primitive components (building blocks)\nexport interface ProductCardRootProps\n extends React.ComponentProps<'div'>,\n VariantProps<typeof productCardVariants> {\n variant?: 'default' | 'priceOverlay' | 'compact'\n touchable?: boolean\n asChild?: boolean\n onPress?: () => void\n}\n\nfunction ProductCardRoot({\n className,\n variant,\n touchable = true,\n asChild = false,\n onPress,\n ...props\n}: ProductCardRootProps) {\n const Comp = asChild ? SlotPrimitive.Slot : 'div'\n\n const content = (\n <Comp\n className={cn(\n productCardVariants({variant, touchable}),\n 'border-0',\n className\n )}\n {...props}\n />\n )\n\n if (touchable && onPress) {\n return (\n <Touchable\n onClick={onPress}\n whileTap={{opacity: 0.7}}\n transition={{\n opacity: {type: 'tween', duration: 0.08, ease: 'easeInOut'},\n }}\n >\n {content}\n </Touchable>\n )\n }\n\n return content\n}\n\nfunction ProductCardImageContainer({\n className,\n variant = 'default',\n ...props\n}: React.ComponentProps<'div'> & {\n variant?: 'default' | 'priceOverlay' | 'compact'\n}) {\n return (\n <div\n data-slot=\"product-card-image-container\"\n className={cn(\n // Ensure the product image is stretched to the full size of the container (can't use width/height: 100% because of flex)\n 'flex justify-stretch items-stretch',\n 'relative overflow-hidden rounded-xl border border-gray-200',\n 'w-full aspect-square',\n variant === 'compact' ? 'min-h-[104px]' : 'min-h-[134px]',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ProductCardImage({\n className,\n src,\n alt,\n ...props\n}: React.ComponentProps<'img'> & {\n src?: string\n alt?: string\n}) {\n return (\n <div className=\"bg-gray-100 flex items-center justify-center\">\n {src ? (\n <img\n data-slot=\"product-card-image\"\n src={src}\n alt={alt}\n className={cn('w-full h-full object-cover', className)}\n {...props}\n />\n ) : (\n <div className=\"text-gray-400 text-sm\">No Image</div>\n )}\n </div>\n )\n}\n\nfunction ProductCardBadge({\n className,\n position = 'bottom-left',\n children,\n ...props\n}: React.ComponentProps<typeof Badge> & {\n position?: 'top-left' | 'bottom-left'\n}) {\n return (\n <div\n className={cn(\n 'absolute z-10',\n position === 'top-left' ? 'top-3 left-3' : 'bottom-2 left-2'\n )}\n >\n <Badge\n className={cn('bg-black/50 text-white rounded', className)}\n {...props}\n >\n {children}\n </Badge>\n </div>\n )\n}\n\nfunction ProductCardFavoriteButton({\n className,\n onPress,\n filled = false,\n ...props\n}: React.ComponentProps<'div'> & {\n onPress?: () => void\n filled?: boolean\n}) {\n return (\n <div className={cn('absolute bottom-3 right-3 z-10', className)} {...props}>\n <Button\n onClick={onPress}\n variant=\"secondary\"\n size=\"icon\"\n className={cn(\n 'h-8 w-8 rounded-full border-0 shadow-sm',\n filled ? 'bg-primary' : 'bg-grayscale-l6/60 backdrop-blur-sm'\n )}\n stopPropagation\n >\n <Heart\n fill={filled ? 'currentColor' : 'none'}\n className=\"h-4 w-4 text-white\"\n />\n </Button>\n </div>\n )\n}\n\nfunction ProductCardInfo({\n className,\n variant = 'default',\n ...props\n}: React.ComponentProps<'div'> & {\n variant?: 'default' | 'priceOverlay' | 'compact'\n}) {\n if (variant !== 'default') {\n return null\n }\n\n return (\n <div\n data-slot=\"product-card-info\"\n className={cn('px-1 pt-2 pb-0 space-y-1', className)}\n {...props}\n />\n )\n}\n\nfunction ProductCardTitle({\n className,\n children,\n ...props\n}: React.ComponentProps<'h3'>) {\n return (\n <h3\n data-slot=\"product-card-title\"\n className={cn(\n 'text-sm font-medium leading-tight text-gray-900',\n 'truncate overflow-hidden whitespace-nowrap text-ellipsis',\n className\n )}\n {...props}\n >\n {children}\n </h3>\n )\n}\n\nfunction ProductCardPrice({className, ...props}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"product-card-price\"\n className={cn('flex items-center gap-2', className)}\n {...props}\n />\n )\n}\n\nfunction ProductCardCurrentPrice({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"product-card-current-price\"\n className={cn('text-sm font-semibold text-gray-900', className)}\n {...props}\n />\n )\n}\n\nfunction ProductCardOriginalPrice({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"product-card-original-price\"\n className={cn('text-sm text-gray-500 line-through', className)}\n {...props}\n />\n )\n}\n\nexport interface ProductCardProps {\n product: Product\n selectedProductVariant?: ProductVariant\n variant?: 'default' | 'priceOverlay' | 'compact'\n touchable?: boolean\n badgeText?: string\n badgeVariant?: 'default' | 'secondary' | 'destructive' | 'outline'\n onFavoriteToggled?: (isFavorited: boolean) => void\n sectionId?: string\n}\n\n// Composed ProductCard component\nfunction ProductCard({\n product,\n selectedProductVariant,\n variant = 'default',\n touchable = true,\n badgeText,\n badgeVariant = 'secondary',\n onFavoriteToggled,\n}: ProductCardProps) {\n const {navigateToProduct} = useShopNavigation()\n const {saveProduct, unsaveProduct} = useSavedProductsActions()\n\n const {\n id,\n title,\n featuredImage,\n price,\n compareAtPrice,\n isFavorited,\n defaultVariantId,\n shop,\n } = product\n\n // Use selected variant data if available\n const displayImage = selectedProductVariant?.image || featuredImage\n const displayPrice = selectedProductVariant?.price || price\n const displayCompareAtPrice =\n selectedProductVariant?.compareAtPrice || compareAtPrice\n\n // Local state for optimistic UI updates\n const [isFavoritedLocal, setIsFavoritedLocal] = React.useState(isFavorited)\n\n const currencyCode = displayPrice?.currencyCode\n const amount = displayPrice?.amount\n const imageUrl = displayImage?.url\n const imageAltText = displayImage?.altText || title\n const compareAtPriceAmount = displayCompareAtPrice?.amount\n const hasDiscount = compareAtPriceAmount && compareAtPriceAmount !== amount\n\n const handlePress = React.useCallback(() => {\n if (!touchable) return\n\n navigateToProduct({\n productId: id,\n })\n }, [navigateToProduct, id, touchable])\n\n const handleFavoritePress = React.useCallback(async () => {\n const previousState = isFavoritedLocal\n\n // Optimistic update\n setIsFavoritedLocal(!previousState)\n onFavoriteToggled?.(!previousState)\n\n try {\n if (previousState) {\n await unsaveProduct({\n productId: id,\n shopId: shop.id,\n productVariantId: selectedProductVariant?.id || defaultVariantId,\n })\n } else {\n await saveProduct({\n productId: id,\n shopId: shop.id,\n productVariantId: selectedProductVariant?.id || defaultVariantId,\n })\n }\n } catch (error) {\n // Revert optimistic update on error\n setIsFavoritedLocal(previousState)\n onFavoriteToggled?.(previousState)\n }\n }, [\n isFavoritedLocal,\n id,\n shop.id,\n selectedProductVariant?.id,\n defaultVariantId,\n saveProduct,\n unsaveProduct,\n onFavoriteToggled,\n ])\n\n return (\n <ProductCardRoot\n variant={variant}\n touchable={touchable}\n onPress={handlePress}\n >\n <ProductCardImageContainer variant={variant}>\n <ProductCardImage src={imageUrl} alt={imageAltText} />\n\n {/* Price overlay badge for priceOverlay variant */}\n {variant === 'priceOverlay' && currencyCode && amount && (\n <ProductCardBadge position=\"top-left\">\n {formatMoney(amount, currencyCode)}\n </ProductCardBadge>\n )}\n\n {/* Custom badge */}\n {badgeText && (\n <ProductCardBadge position=\"bottom-left\" variant={badgeVariant}>\n {badgeText}\n </ProductCardBadge>\n )}\n\n {/* Favorite button */}\n <ProductCardFavoriteButton\n filled={isFavoritedLocal}\n onPress={handleFavoritePress}\n />\n </ProductCardImageContainer>\n\n {/* Product info for default variant */}\n <ProductCardInfo variant={variant}>\n <ProductCardTitle>{title}</ProductCardTitle>\n\n <ProductCardPrice>\n {hasDiscount ? (\n <>\n <ProductCardCurrentPrice>\n {formatMoney(amount, currencyCode)}\n </ProductCardCurrentPrice>\n <ProductCardOriginalPrice>\n {formatMoney(\n compareAtPriceAmount,\n displayCompareAtPrice?.currencyCode || currencyCode\n )}\n </ProductCardOriginalPrice>\n </>\n ) : (\n <ProductCardCurrentPrice>\n {formatMoney(amount, currencyCode)}\n </ProductCardCurrentPrice>\n )}\n </ProductCardPrice>\n </ProductCardInfo>\n </ProductCardRoot>\n )\n}\n\nexport {\n // Composed component\n ProductCard,\n // Primitive components for custom composition\n ProductCardRoot,\n ProductCardImageContainer,\n ProductCardImage,\n ProductCardBadge,\n ProductCardFavoriteButton,\n ProductCardInfo,\n ProductCardTitle,\n ProductCardPrice,\n ProductCardCurrentPrice,\n ProductCardOriginalPrice,\n}\n"],"names":["productCardVariants","cva","ProductCardRoot","className","variant","touchable","asChild","onPress","props","content","jsx","SlotPrimitive.Slot","cn","Touchable","ProductCardImageContainer","ProductCardImage","src","alt","ProductCardBadge","position","children","Badge","ProductCardFavoriteButton","filled","Button","Heart","ProductCardInfo","ProductCardTitle","ProductCardPrice","ProductCardCurrentPrice","ProductCardOriginalPrice","ProductCard","product","selectedProductVariant","badgeText","badgeVariant","onFavoriteToggled","navigateToProduct","useShopNavigation","saveProduct","unsaveProduct","useSavedProductsActions","id","title","featuredImage","price","compareAtPrice","isFavorited","defaultVariantId","shop","displayImage","displayPrice","displayCompareAtPrice","isFavoritedLocal","setIsFavoritedLocal","React","currencyCode","amount","imageUrl","imageAltText","compareAtPriceAmount","hasDiscount","handlePress","handleFavoritePress","previousState","jsxs","formatMoney","Fragment"],"mappings":";;;;;;;;;;;;AAkBA,MAAMA,IAAsBC;AAAA,EAC1B;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,cAAc;AAAA,QACd,SAAS;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,MAAM;AAAA,QACN,OAAO;AAAA,MAAA;AAAA,IAEX;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,WAAW;AAAA,IAAA;AAAA,EACb;AAEJ;AAYA,SAASC,EAAgB;AAAA,EACvB,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,SAAAC,IAAU;AAAA,EACV,SAAAC;AAAA,EACA,GAAGC;AACL,GAAyB;AAGvB,QAAMC,IACJ,gBAAAC;AAAA,IAHWJ,IAAUK,IAAqB;AAAA,IAGzC;AAAA,MACC,WAAWC;AAAA,QACTZ,EAAoB,EAAC,SAAAI,GAAS,WAAAC,GAAU;AAAA,QACxC;AAAA,QACAF;AAAA,MACF;AAAA,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BoD,KAAgBC,KAC7C,gBAAA/C,EAACQ,GAAiB,EAAA,UAAS,YACxB,UAAAgD,EAAYT,GAAQD,CAAY,EACnC,CAAA;AAAA,UAIDtB,KACE,gBAAAxB,EAAAQ,GAAA,EAAiB,UAAS,eAAc,SAASiB,GAC/C,UACHD,GAAA;AAAA,UAIF,gBAAAxB;AAAA,YAACY;AAAA,YAAA;AAAA,cACC,QAAQ+B;AAAA,cACR,SAASU;AAAA,YAAA;AAAA,UAAA;AAAA,QACX,GACF;AAAA,QAGA,gBAAAE,EAACvC,KAAgB,SAAAtB,GACf,UAAA;AAAA,UAAA,gBAAAM,EAACiB,MAAkB,UAAMgB,EAAA,CAAA;AAAA,UAEzB,gBAAAjC,EAACkB,IACE,EAAA,UAAAiC,IAEG,gBAAAI,EAAAE,GAAA,EAAA,UAAA;AAAA,YAAA,gBAAAzD,EAACmB,GACE,EAAA,UAAAqC,EAAYT,GAAQD,CAAY,GACnC;AAAA,8BACC1B,IACE,EAAA,UAAAoC;AAAA,cACCN;AAAA,cACAR,GAAuB,gBAAgBI;AAAA,YAAA,EAE3C,CAAA;AAAA,UAAA,GACF,IAEC,gBAAA9C,EAAAmB,GAAA,EACE,YAAY4B,GAAQD,CAAY,GACnC,EAEJ,CAAA;AAAA,QAAA,EACF,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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,
|
|
6
|
+
r,
|
|
7
|
+
{
|
|
8
|
+
skip: s,
|
|
9
|
+
hook: "useCuratedProducts"
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
return {
|
|
13
|
+
...c,
|
|
14
|
+
products: e
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
i as useCuratedProducts
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useCuratedProducts.js.map
|
|
@@ -0,0 +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;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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]);
|
|
16
|
+
return {
|
|
17
|
+
...u,
|
|
18
|
+
product: n
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
h as useProduct
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=useProduct.js.map
|
|
@@ -0,0 +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;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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]);
|
|
16
|
+
return {
|
|
17
|
+
...i,
|
|
18
|
+
media: n
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
f as useProductMedia
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=useProductMedia.js.map
|
|
@@ -0,0 +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;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useState as S, useCallback as h, useEffect as y, useMemo as b } from "react";
|
|
2
|
+
import P from "../../_virtual/debounce.js";
|
|
3
|
+
import { useShopActions as g } from "../../internal/useShopActions.js";
|
|
4
|
+
import { useShopActionsPaginatedDataFetching as k } from "../../internal/useShopActionsPaginatedDataFetching.js";
|
|
5
|
+
const v = (r) => {
|
|
6
|
+
const { getProductSearch: s } = g(), {
|
|
7
|
+
query: e,
|
|
8
|
+
filters: c,
|
|
9
|
+
sortBy: u,
|
|
10
|
+
includeSensitive: n = !1,
|
|
11
|
+
skip: a = !1,
|
|
12
|
+
...d
|
|
13
|
+
} = r ?? {}, [i, m] = S(e), t = h(
|
|
14
|
+
P((p) => {
|
|
15
|
+
m(p);
|
|
16
|
+
}, 300),
|
|
17
|
+
[]
|
|
18
|
+
);
|
|
19
|
+
y(() => (t(e), () => {
|
|
20
|
+
t.cancel();
|
|
21
|
+
}), [e, t]);
|
|
22
|
+
const { data: o, ...f } = k(
|
|
23
|
+
s,
|
|
24
|
+
{
|
|
25
|
+
query: i,
|
|
26
|
+
filters: c,
|
|
27
|
+
sortBy: u,
|
|
28
|
+
includeSensitive: n,
|
|
29
|
+
...d
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
skip: a,
|
|
33
|
+
hook: "useProductSearch"
|
|
34
|
+
}
|
|
35
|
+
), l = b(() => o ?? null, [o]);
|
|
36
|
+
return {
|
|
37
|
+
...f,
|
|
38
|
+
products: l
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
v as useProductSearch
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=useProductSearch.js.map
|
|
@@ -0,0 +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\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 return data ?? null\n }, [data])\n\n return {\n ...rest,\n products,\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":";;;;AAwCa,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,MAChBJ,KAAQ,MACd,CAACA,CAAI,CAAC;AAEF,SAAA;AAAA,IACL,GAAGC;AAAA,IACH,UAAAE;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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]);
|
|
13
|
+
return {
|
|
14
|
+
...n,
|
|
15
|
+
variants: e
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
P as useProductVariants
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=useProductVariants.js.map
|
|
@@ -0,0 +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;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMemo as n } from "react";
|
|
2
|
+
import { useShopActions as m } from "../../internal/useShopActions.js";
|
|
3
|
+
import { useShopActionsDataFetching as p } from "../../internal/useShopActionsDataFetching.js";
|
|
4
|
+
const f = (t) => {
|
|
5
|
+
const { getProducts: s } = m(), { skip: r = !1, ...e } = t, { data: o, ...c } = p(s, e, {
|
|
6
|
+
skip: r,
|
|
7
|
+
hook: "useProducts"
|
|
8
|
+
}), u = n(() => o ?? null, [o]);
|
|
9
|
+
return {
|
|
10
|
+
...c,
|
|
11
|
+
products: u
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
f as useProducts
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useProducts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProducts.js","sources":["../../../src/hooks/product/useProducts.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 UseProductsParams extends DataHookOptionsBase {\n /**\n * The product IDs to fetch.\n */\n ids: string[]\n}\n\ninterface UseProductsReturns extends DataHookReturnsBase {\n /**\n * The products returned from the query.\n */\n products: Product[] | null\n}\n\nexport const useProducts = (params: UseProductsParams): UseProductsReturns => {\n const {getProducts} = useShopActions()\n const {skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionsDataFetching(getProducts, restParams, {\n skip,\n hook: 'useProducts',\n })\n\n const products = useMemo(() => {\n return data ?? null\n }, [data])\n\n return {\n ...rest,\n products,\n }\n}\n"],"names":["useProducts","params","getProducts","useShopActions","skip","restParams","data","rest","useShopActionsDataFetching","products","useMemo"],"mappings":";;;AAoBa,MAAAA,IAAc,CAACC,MAAkD;AACtE,QAAA,EAAC,aAAAC,EAAW,IAAIC,EAAe,GAC/B,EAAC,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAJ,GAEhC,EAAC,MAAAK,GAAM,GAAGC,EAAQ,IAAAC,EAA2BN,GAAaG,GAAY;AAAA,IAC1E,MAAAD;AAAA,IACA,MAAM;AAAA,EAAA,CACP,GAEKK,IAAWC,EAAQ,MAChBJ,KAAQ,MACd,CAACA,CAAI,CAAC;AAEF,SAAA;AAAA,IACL,GAAGC;AAAA,IACH,UAAAE;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMemo as c } from "react";
|
|
2
|
+
import { useShopActions as h } from "../../internal/useShopActions.js";
|
|
3
|
+
import { useShopActionsDataFetching as m } from "../../internal/useShopActionsDataFetching.js";
|
|
4
|
+
const S = (t) => {
|
|
5
|
+
const { getShop: s } = h(), { skip: e = !1, ...r } = t, { data: o, ...n } = m(s, r, {
|
|
6
|
+
skip: e,
|
|
7
|
+
hook: "useShop"
|
|
8
|
+
}), p = c(() => o ?? null, [o]);
|
|
9
|
+
return {
|
|
10
|
+
...n,
|
|
11
|
+
shop: p
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
S as useShop
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useShop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useShop.js","sources":["../../../src/hooks/shop/useShop.ts"],"sourcesContent":["import {useMemo} from 'react'\n\nimport {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'\nimport {DataHookOptionsBase, DataHookReturnsBase, Shop} from '../../types'\n\nexport interface UseShopParams extends DataHookOptionsBase {\n /**\n * The shop ID to fetch.\n */\n id: string\n}\n\ninterface UseShopReturns extends DataHookReturnsBase {\n /**\n * The shop returned from the query.\n */\n shop: Shop | null\n}\n\nexport const useShop = (params: UseShopParams): UseShopReturns => {\n const {getShop} = useShopActions()\n const {skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionsDataFetching(getShop, restParams, {\n skip,\n hook: 'useShop',\n })\n\n const shop = useMemo(() => {\n return data ?? null\n }, [data])\n\n return {\n ...rest,\n shop,\n }\n}\n"],"names":["useShop","params","getShop","useShopActions","skip","restParams","data","rest","useShopActionsDataFetching","shop","useMemo"],"mappings":";;;AAoBa,MAAAA,IAAU,CAACC,MAA0C;AAC1D,QAAA,EAAC,SAAAC,EAAO,IAAIC,EAAe,GAC3B,EAAC,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAJ,GAEhC,EAAC,MAAAK,GAAM,GAAGC,EAAQ,IAAAC,EAA2BN,GAASG,GAAY;AAAA,IACtE,MAAAD;AAAA,IACA,MAAM;AAAA,EAAA,CACP,GAEKK,IAAOC,EAAQ,MACZJ,KAAQ,MACd,CAACA,CAAI,CAAC;AAEF,SAAA;AAAA,IACL,GAAGC;AAAA,IACH,MAAAE;AAAA,EACF;AACF;"}
|