@shopify/shop-minis-react 0.3.2 → 0.3.4
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/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/navigation/useNavigateWithTransition.js +10 -11
- package/dist/hooks/navigation/useNavigateWithTransition.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/mocks.js +178 -107
- package/dist/mocks.js.map +1 -1
- 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 +1 -1
- 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/navigation/useNavigateWithTransition.test.ts +46 -7
- package/src/hooks/navigation/useNavigateWithTransition.ts +4 -1
- package/src/internal/components/product-review-stars.test.tsx +90 -0
- package/src/internal/components/product-review-stars.tsx +113 -0
- package/src/mocks.ts +10 -2
- package/src/providers/ImagePickerProvider.test.tsx +3 -9
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import { cva as
|
|
4
|
-
import { useShopNavigation as
|
|
5
|
-
import { useSavedProductsActions as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { jsxs as y, jsx as t, Fragment as S } from "react/jsx-runtime";
|
|
2
|
+
import * as P from "react";
|
|
3
|
+
import { cva as q } from "../../shop-minis-react/node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js";
|
|
4
|
+
import { useShopNavigation as B } from "../../hooks/navigation/useShopNavigation.js";
|
|
5
|
+
import { useSavedProductsActions as M } from "../../hooks/user/useSavedProductsActions.js";
|
|
6
|
+
import { ProductReviewStars as U } from "../../internal/components/product-review-stars.js";
|
|
7
|
+
import { formatMoney as T } from "../../lib/formatMoney.js";
|
|
8
|
+
import { cn as n } from "../../lib/utils.js";
|
|
8
9
|
import { Touchable as V } from "../atoms/touchable.js";
|
|
9
|
-
import { Card as
|
|
10
|
-
import { FavoriteButton as
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
const K = D("", {
|
|
10
|
+
import { Card as E, CardContent as G, CardAction as H } from "../ui/card.js";
|
|
11
|
+
import { FavoriteButton as J } from "./favorite-button.js";
|
|
12
|
+
import { Root as K } from "../../shop-minis-react/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";
|
|
13
|
+
const Q = q("", {
|
|
14
14
|
variants: {
|
|
15
15
|
layout: {
|
|
16
16
|
horizontal: "w-full !flex-row items-center gap-3 px-4 py-3",
|
|
@@ -27,280 +27,267 @@ const K = D("", {
|
|
|
27
27
|
discount: "none"
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
function
|
|
30
|
+
function W({
|
|
31
31
|
className: e,
|
|
32
|
-
layout:
|
|
33
|
-
discount:
|
|
32
|
+
layout: o,
|
|
33
|
+
discount: r,
|
|
34
34
|
asChild: i = !1,
|
|
35
|
-
onPress:
|
|
36
|
-
...
|
|
35
|
+
onPress: a,
|
|
36
|
+
...c
|
|
37
37
|
}) {
|
|
38
38
|
return /* @__PURE__ */ t(
|
|
39
39
|
V,
|
|
40
40
|
{
|
|
41
|
-
onClick:
|
|
41
|
+
onClick: a,
|
|
42
42
|
whileTap: { opacity: 0.7 },
|
|
43
43
|
transition: {
|
|
44
44
|
opacity: { type: "tween", duration: 0.08, ease: "easeInOut" }
|
|
45
45
|
},
|
|
46
46
|
children: /* @__PURE__ */ t(
|
|
47
|
-
i ?
|
|
47
|
+
i ? K : E,
|
|
48
48
|
{
|
|
49
|
-
className:
|
|
50
|
-
|
|
49
|
+
className: n(
|
|
50
|
+
Q({ layout: o, discount: r }),
|
|
51
51
|
"border-0 bg-white rounded-xl shadow-lg shadow-black/10",
|
|
52
52
|
e
|
|
53
53
|
),
|
|
54
|
-
...
|
|
54
|
+
...c
|
|
55
55
|
}
|
|
56
56
|
)
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function X({
|
|
61
61
|
className: e,
|
|
62
|
-
layout:
|
|
63
|
-
...
|
|
62
|
+
layout: o = "horizontal",
|
|
63
|
+
...r
|
|
64
64
|
}) {
|
|
65
65
|
return /* @__PURE__ */ t(
|
|
66
66
|
"div",
|
|
67
67
|
{
|
|
68
68
|
"data-slot": "product-link-image",
|
|
69
|
-
className:
|
|
69
|
+
className: n(
|
|
70
70
|
"overflow-hidden rounded-md bg-muted",
|
|
71
|
-
|
|
71
|
+
o === "horizontal" ? "h-16 w-16 flex-shrink-0" : "aspect-square w-full",
|
|
72
72
|
e
|
|
73
73
|
),
|
|
74
|
-
...
|
|
74
|
+
...r
|
|
75
75
|
}
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function Y({
|
|
79
79
|
className: e,
|
|
80
|
-
layout:
|
|
81
|
-
...
|
|
80
|
+
layout: o = "horizontal",
|
|
81
|
+
...r
|
|
82
82
|
}) {
|
|
83
83
|
return /* @__PURE__ */ t(
|
|
84
|
-
|
|
84
|
+
G,
|
|
85
85
|
{
|
|
86
|
-
className:
|
|
87
|
-
|
|
86
|
+
className: n(
|
|
87
|
+
o === "horizontal" ? "flex-1 min-w-0 space-y-1 px-0 py-0" : "space-y-2",
|
|
88
88
|
e
|
|
89
89
|
),
|
|
90
|
-
...
|
|
90
|
+
...r
|
|
91
91
|
}
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function Z({
|
|
95
95
|
className: e,
|
|
96
|
-
children:
|
|
97
|
-
...
|
|
96
|
+
children: o,
|
|
97
|
+
...r
|
|
98
98
|
}) {
|
|
99
99
|
return /* @__PURE__ */ t(
|
|
100
100
|
"h3",
|
|
101
101
|
{
|
|
102
102
|
"data-slot": "product-link-title",
|
|
103
|
-
className:
|
|
103
|
+
className: n(
|
|
104
104
|
"text-sm font-medium leading-tight text-gray-900 truncate overflow-hidden whitespace-nowrap text-ellipsis",
|
|
105
105
|
e
|
|
106
106
|
),
|
|
107
|
-
...
|
|
108
|
-
children:
|
|
107
|
+
...r,
|
|
108
|
+
children: o
|
|
109
109
|
}
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function _({ className: e, ...o }) {
|
|
113
113
|
return /* @__PURE__ */ t(
|
|
114
114
|
"div",
|
|
115
115
|
{
|
|
116
116
|
"data-slot": "product-link-price",
|
|
117
|
-
className:
|
|
118
|
-
...
|
|
117
|
+
className: n("flex items-center gap-2", e),
|
|
118
|
+
...o
|
|
119
119
|
}
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
function $({
|
|
123
123
|
className: e,
|
|
124
|
-
...
|
|
124
|
+
...o
|
|
125
125
|
}) {
|
|
126
126
|
return /* @__PURE__ */ t(
|
|
127
127
|
"span",
|
|
128
128
|
{
|
|
129
129
|
"data-slot": "product-link-current-price",
|
|
130
|
-
className:
|
|
131
|
-
...
|
|
130
|
+
className: n("text-sm font-semibold text-gray-900", e),
|
|
131
|
+
...o
|
|
132
132
|
}
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
135
|
function tt({
|
|
136
136
|
className: e,
|
|
137
|
-
...
|
|
137
|
+
...o
|
|
138
138
|
}) {
|
|
139
139
|
return /* @__PURE__ */ t(
|
|
140
140
|
"span",
|
|
141
141
|
{
|
|
142
142
|
"data-slot": "product-link-original-price",
|
|
143
|
-
className:
|
|
144
|
-
...
|
|
143
|
+
className: n("text-sm text-gray-500 line-through", e),
|
|
144
|
+
...o
|
|
145
145
|
}
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
148
|
function et({
|
|
149
149
|
className: e,
|
|
150
|
-
...
|
|
150
|
+
...o
|
|
151
151
|
}) {
|
|
152
152
|
return /* @__PURE__ */ t(
|
|
153
153
|
"span",
|
|
154
154
|
{
|
|
155
155
|
"data-slot": "product-link-discount-price",
|
|
156
|
-
className:
|
|
157
|
-
...
|
|
156
|
+
className: n("text-sm font-semibold text-red-600", e),
|
|
157
|
+
...o
|
|
158
158
|
}
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function ot({ className: e, ...o }) {
|
|
162
162
|
return /* @__PURE__ */ t(
|
|
163
163
|
"div",
|
|
164
164
|
{
|
|
165
165
|
"data-slot": "product-link-rating",
|
|
166
|
-
className:
|
|
167
|
-
|
|
168
|
-
e
|
|
169
|
-
),
|
|
170
|
-
...r
|
|
166
|
+
className: n("", e),
|
|
167
|
+
...o
|
|
171
168
|
}
|
|
172
169
|
);
|
|
173
170
|
}
|
|
174
|
-
function
|
|
171
|
+
function rt({
|
|
175
172
|
className: e,
|
|
176
|
-
hideFavoriteAction:
|
|
177
|
-
onPress:
|
|
173
|
+
hideFavoriteAction: o = !1,
|
|
174
|
+
onPress: r,
|
|
178
175
|
filled: i = !1,
|
|
179
|
-
customAction:
|
|
180
|
-
...
|
|
176
|
+
customAction: a,
|
|
177
|
+
...c
|
|
181
178
|
}) {
|
|
182
|
-
const
|
|
179
|
+
const l = o ? null : /* @__PURE__ */ t(J, { filled: i, onClick: r });
|
|
183
180
|
return /* @__PURE__ */ t(
|
|
184
|
-
|
|
181
|
+
H,
|
|
185
182
|
{
|
|
186
|
-
className:
|
|
187
|
-
...
|
|
183
|
+
className: n("flex-shrink-0 self-center px-0 py-0", e),
|
|
184
|
+
...c,
|
|
188
185
|
children: /* @__PURE__ */ t(
|
|
189
186
|
V,
|
|
190
187
|
{
|
|
191
188
|
stopPropagation: !0,
|
|
192
|
-
onClick:
|
|
189
|
+
onClick: r,
|
|
193
190
|
whileTap: { opacity: 0.7, scale: 0.95 },
|
|
194
191
|
transition: {
|
|
195
192
|
opacity: { type: "tween", duration: 0.08, ease: "easeInOut" },
|
|
196
193
|
scale: { type: "tween", duration: 0.08, ease: "easeInOut" }
|
|
197
194
|
},
|
|
198
|
-
children:
|
|
195
|
+
children: a ? /* @__PURE__ */ t(S, { children: a }) : l
|
|
199
196
|
}
|
|
200
197
|
)
|
|
201
198
|
}
|
|
202
199
|
);
|
|
203
200
|
}
|
|
204
|
-
function
|
|
201
|
+
function gt({
|
|
205
202
|
product: e,
|
|
206
|
-
hideFavoriteAction:
|
|
207
|
-
onClick:
|
|
203
|
+
hideFavoriteAction: o = !1,
|
|
204
|
+
onClick: r,
|
|
208
205
|
customAction: i,
|
|
209
|
-
onCustomActionClick:
|
|
206
|
+
onCustomActionClick: a,
|
|
207
|
+
reviewsDisabled: c = !1
|
|
210
208
|
}) {
|
|
211
|
-
const { navigateToProduct: l } =
|
|
209
|
+
const { navigateToProduct: l } = B(), { saveProduct: w, unsaveProduct: k } = M(), {
|
|
212
210
|
id: s,
|
|
213
211
|
title: I,
|
|
214
212
|
featuredImage: L,
|
|
215
|
-
reviewAnalytics:
|
|
216
|
-
price:
|
|
217
|
-
compareAtPrice:
|
|
218
|
-
isFavorited:
|
|
219
|
-
selectedVariant:
|
|
220
|
-
defaultVariantId:
|
|
221
|
-
shop:
|
|
222
|
-
} = e, [
|
|
213
|
+
reviewAnalytics: N,
|
|
214
|
+
price: d,
|
|
215
|
+
compareAtPrice: u,
|
|
216
|
+
isFavorited: A,
|
|
217
|
+
selectedVariant: m,
|
|
218
|
+
defaultVariantId: p,
|
|
219
|
+
shop: f
|
|
220
|
+
} = e, [h, b] = P.useState(A), C = N?.averageRating, F = N?.reviewCount, g = d?.amount ? T(d?.amount, d?.currencyCode) : void 0, z = L?.url, j = L?.altText || I, v = u?.amount ? T(u?.amount, u?.currencyCode) : void 0, R = v && v !== g, O = P.useCallback(() => {
|
|
223
221
|
l({
|
|
224
222
|
productId: s
|
|
225
|
-
}),
|
|
226
|
-
}, [l, s,
|
|
227
|
-
if (i ||
|
|
228
|
-
|
|
223
|
+
}), r?.(e);
|
|
224
|
+
}, [l, s, r, e]), D = P.useCallback(async () => {
|
|
225
|
+
if (i || a) {
|
|
226
|
+
a?.();
|
|
229
227
|
return;
|
|
230
228
|
}
|
|
231
|
-
const
|
|
232
|
-
b(!
|
|
229
|
+
const x = h;
|
|
230
|
+
b(!x);
|
|
233
231
|
try {
|
|
234
|
-
|
|
232
|
+
x ? await k({
|
|
235
233
|
productId: s,
|
|
236
|
-
shopId:
|
|
237
|
-
productVariantId:
|
|
238
|
-
}) : await
|
|
234
|
+
shopId: f.id,
|
|
235
|
+
productVariantId: m?.id || p
|
|
236
|
+
}) : await w({
|
|
239
237
|
productId: s,
|
|
240
|
-
shopId:
|
|
241
|
-
productVariantId:
|
|
238
|
+
shopId: f.id,
|
|
239
|
+
productVariantId: m?.id || p
|
|
242
240
|
});
|
|
243
241
|
} catch {
|
|
244
|
-
b(
|
|
242
|
+
b(x);
|
|
245
243
|
}
|
|
246
244
|
}, [
|
|
247
245
|
i,
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
246
|
+
a,
|
|
247
|
+
h,
|
|
248
|
+
k,
|
|
251
249
|
s,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
250
|
+
f.id,
|
|
251
|
+
m?.id,
|
|
252
|
+
p,
|
|
253
|
+
w
|
|
256
254
|
]);
|
|
257
|
-
return /* @__PURE__ */
|
|
258
|
-
|
|
255
|
+
return /* @__PURE__ */ y(
|
|
256
|
+
W,
|
|
259
257
|
{
|
|
260
258
|
layout: "horizontal",
|
|
261
|
-
discount:
|
|
259
|
+
discount: R ? "small" : "none",
|
|
262
260
|
onPress: O,
|
|
263
261
|
children: [
|
|
264
|
-
/* @__PURE__ */ t(
|
|
262
|
+
/* @__PURE__ */ t(X, { layout: "horizontal", children: z ? /* @__PURE__ */ t(
|
|
265
263
|
"img",
|
|
266
264
|
{
|
|
267
|
-
src:
|
|
265
|
+
src: z,
|
|
268
266
|
alt: j,
|
|
269
267
|
className: "h-full w-full object-cover"
|
|
270
268
|
}
|
|
271
269
|
) : /* @__PURE__ */ t("div", { className: "h-full w-full bg-muted flex items-center justify-center text-muted-foreground text-xs", children: "No Image" }) }),
|
|
272
|
-
/* @__PURE__ */
|
|
273
|
-
/* @__PURE__ */ t(
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
)),
|
|
286
|
-
/* @__PURE__ */ d("span", { className: "text-xs text-gray-600 ml-1", children: [
|
|
287
|
-
"(",
|
|
288
|
-
z,
|
|
289
|
-
")"
|
|
290
|
-
] })
|
|
291
|
-
] }) }) : null,
|
|
292
|
-
/* @__PURE__ */ t(Z, { children: A ? /* @__PURE__ */ d(S, { children: [
|
|
293
|
-
/* @__PURE__ */ t(et, { children: w }),
|
|
294
|
-
/* @__PURE__ */ t(tt, { children: P })
|
|
295
|
-
] }) : /* @__PURE__ */ t($, { children: w }) })
|
|
270
|
+
/* @__PURE__ */ y(Y, { layout: "horizontal", children: [
|
|
271
|
+
/* @__PURE__ */ t(Z, { children: I }),
|
|
272
|
+
C && !c ? /* @__PURE__ */ t(ot, { children: /* @__PURE__ */ t(
|
|
273
|
+
U,
|
|
274
|
+
{
|
|
275
|
+
averageRating: C,
|
|
276
|
+
reviewCount: F
|
|
277
|
+
}
|
|
278
|
+
) }) : null,
|
|
279
|
+
/* @__PURE__ */ t(_, { children: R ? /* @__PURE__ */ y(S, { children: [
|
|
280
|
+
/* @__PURE__ */ t(et, { children: g }),
|
|
281
|
+
/* @__PURE__ */ t(tt, { children: v })
|
|
282
|
+
] }) : /* @__PURE__ */ t($, { children: g }) })
|
|
296
283
|
] }),
|
|
297
284
|
/* @__PURE__ */ t(
|
|
298
|
-
|
|
285
|
+
rt,
|
|
299
286
|
{
|
|
300
|
-
filled:
|
|
301
|
-
onPress:
|
|
287
|
+
filled: h,
|
|
288
|
+
onPress: D,
|
|
302
289
|
customAction: i,
|
|
303
|
-
hideFavoriteAction:
|
|
290
|
+
hideFavoriteAction: o
|
|
304
291
|
}
|
|
305
292
|
)
|
|
306
293
|
]
|
|
@@ -308,6 +295,6 @@ function ht({
|
|
|
308
295
|
);
|
|
309
296
|
}
|
|
310
297
|
export {
|
|
311
|
-
|
|
298
|
+
gt as ProductLink
|
|
312
299
|
};
|
|
313
300
|
//# sourceMappingURL=product-link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-link.js","sources":["../../../src/components/commerce/product-link.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {type Product} from '@shopify/shop-minis-platform'\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 {useSavedProductsActions} from '../../hooks/user/useSavedProductsActions'\nimport {formatMoney} from '../../lib/formatMoney'\nimport {cn} from '../../lib/utils'\nimport {Touchable} from '../atoms/touchable'\nimport {Card, CardContent, CardAction} from '../ui/card'\n\nimport {FavoriteButton} from './favorite-button'\n\nconst productLinkVariants = cva('', {\n variants: {\n layout: {\n horizontal: 'w-full !flex-row items-center gap-3 px-4 py-3',\n vertical: 'flex-col',\n },\n discount: {\n none: '',\n small: '',\n large: '',\n },\n },\n defaultVariants: {\n layout: 'horizontal',\n discount: 'none',\n },\n})\n\n// Primitive components (building blocks)\nexport interface ProductLinkRootProps\n extends React.ComponentProps<typeof Card>,\n VariantProps<typeof productLinkVariants> {\n layout?: 'horizontal' | 'vertical'\n asChild?: boolean\n onPress?: () => void\n}\n\nfunction ProductLinkRoot({\n className,\n layout,\n discount,\n asChild = false,\n onPress,\n ...props\n}: ProductLinkRootProps) {\n const Comp = asChild ? SlotPrimitive.Root : Card\n\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 <Comp\n className={cn(\n productLinkVariants({layout, discount}),\n 'border-0 bg-white rounded-xl shadow-lg shadow-black/10',\n className\n )}\n {...props}\n />\n </Touchable>\n )\n}\n\nfunction ProductLinkImage({\n className,\n layout = 'horizontal',\n ...props\n}: React.ComponentProps<'div'> & {layout?: 'horizontal' | 'vertical'}) {\n return (\n <div\n data-slot=\"product-link-image\"\n className={cn(\n 'overflow-hidden rounded-md bg-muted',\n layout === 'horizontal'\n ? 'h-16 w-16 flex-shrink-0'\n : 'aspect-square w-full',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ProductLinkInfo({\n className,\n layout = 'horizontal',\n ...props\n}: React.ComponentProps<typeof CardContent> & {\n layout?: 'horizontal' | 'vertical'\n}) {\n return (\n <CardContent\n className={cn(\n layout === 'horizontal'\n ? 'flex-1 min-w-0 space-y-1 px-0 py-0'\n : 'space-y-2',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ProductLinkTitle({\n className,\n children,\n ...props\n}: React.ComponentProps<'h3'>) {\n return (\n <h3\n data-slot=\"product-link-title\"\n className={cn(\n 'text-sm font-medium leading-tight text-gray-900 truncate overflow-hidden whitespace-nowrap text-ellipsis',\n className\n )}\n {...props}\n >\n {children}\n </h3>\n )\n}\n\nfunction ProductLinkPrice({className, ...props}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"product-link-price\"\n className={cn('flex items-center gap-2', className)}\n {...props}\n />\n )\n}\n\nfunction ProductLinkCurrentPrice({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"product-link-current-price\"\n className={cn('text-sm font-semibold text-gray-900', className)}\n {...props}\n />\n )\n}\n\nfunction ProductLinkOriginalPrice({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"product-link-original-price\"\n className={cn('text-sm text-gray-500 line-through', className)}\n {...props}\n />\n )\n}\n\nfunction ProductLinkDiscountPrice({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"product-link-discount-price\"\n className={cn('text-sm font-semibold text-red-600', className)}\n {...props}\n />\n )\n}\n\nfunction ProductLinkRating({className, ...props}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"product-link-rating\"\n className={cn(\n 'flex items-center gap-1 text-xs text-muted-foreground',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ProductLinkActions({\n className,\n hideFavoriteAction = false,\n onPress,\n filled = false,\n customAction,\n ...props\n}: React.ComponentProps<typeof CardAction> & {\n hideFavoriteAction?: boolean\n onPress?: () => void\n filled?: boolean\n customAction?: React.ReactNode\n}) {\n const favoriteAction = hideFavoriteAction ? null : (\n <FavoriteButton filled={filled} onClick={onPress} />\n )\n\n return (\n <CardAction\n className={cn('flex-shrink-0 self-center px-0 py-0', className)}\n {...props}\n >\n <Touchable\n stopPropagation\n onClick={onPress}\n whileTap={{opacity: 0.7, scale: 0.95}}\n transition={{\n opacity: {type: 'tween', duration: 0.08, ease: 'easeInOut'},\n scale: {type: 'tween', duration: 0.08, ease: 'easeInOut'},\n }}\n >\n {customAction ? <>{customAction}</> : favoriteAction}\n </Touchable>\n </CardAction>\n )\n}\n\nexport type ProductLinkProps = {\n product: Product\n hideFavoriteAction?: boolean\n onClick?: (product: Product) => void\n} & (\n | {\n customAction?: never\n onCustomActionClick?: never\n }\n | {\n customAction: React.ReactNode\n onCustomActionClick: () => void\n }\n)\n\n// Composed ProductLink component\nfunction ProductLink({\n product,\n hideFavoriteAction = false,\n onClick,\n customAction,\n onCustomActionClick,\n}: ProductLinkProps) {\n const {navigateToProduct} = useShopNavigation()\n const {saveProduct, unsaveProduct} = useSavedProductsActions()\n\n const {\n id,\n title,\n featuredImage,\n reviewAnalytics,\n price,\n compareAtPrice,\n isFavorited,\n selectedVariant,\n defaultVariantId,\n shop,\n } = product\n\n // Local state for optimistic UI updates\n const [isFavoritedLocal, setIsFavoritedLocal] = React.useState(isFavorited)\n\n const averageRating = reviewAnalytics?.averageRating\n const reviewCount = reviewAnalytics?.reviewCount\n const amount = price?.amount\n ? formatMoney(price?.amount, price?.currencyCode)\n : undefined\n const imageUrl = featuredImage?.url\n const imageAltText = featuredImage?.altText || title\n const compareAtPriceAmount = compareAtPrice?.amount\n ? formatMoney(compareAtPrice?.amount, compareAtPrice?.currencyCode)\n : undefined\n const hasDiscount = compareAtPriceAmount && compareAtPriceAmount !== amount\n\n const handlePress = React.useCallback(() => {\n navigateToProduct({\n productId: id,\n })\n onClick?.(product)\n }, [navigateToProduct, id, onClick, product])\n\n const handleActionPress = React.useCallback(async () => {\n if (customAction || onCustomActionClick) {\n onCustomActionClick?.()\n return\n }\n\n const previousState = isFavoritedLocal\n\n // Optimistic update\n setIsFavoritedLocal(!previousState)\n\n try {\n if (previousState) {\n await unsaveProduct({\n productId: id,\n shopId: shop.id,\n productVariantId: selectedVariant?.id || defaultVariantId,\n })\n } else {\n await saveProduct({\n productId: id,\n shopId: shop.id,\n productVariantId: selectedVariant?.id || defaultVariantId,\n })\n }\n } catch (error) {\n // Revert optimistic update on error\n setIsFavoritedLocal(previousState)\n }\n }, [\n customAction,\n onCustomActionClick,\n isFavoritedLocal,\n unsaveProduct,\n id,\n shop.id,\n selectedVariant?.id,\n defaultVariantId,\n saveProduct,\n ])\n\n return (\n <ProductLinkRoot\n layout=\"horizontal\"\n discount={hasDiscount ? 'small' : 'none'}\n onPress={handlePress}\n >\n <ProductLinkImage layout=\"horizontal\">\n {imageUrl ? (\n <img\n src={imageUrl}\n alt={imageAltText}\n className=\"h-full w-full object-cover\"\n />\n ) : (\n <div className=\"h-full w-full bg-muted flex items-center justify-center text-muted-foreground text-xs\">\n No Image\n </div>\n )}\n </ProductLinkImage>\n\n <ProductLinkInfo layout=\"horizontal\">\n <ProductLinkTitle>{title}</ProductLinkTitle>\n\n {reviewCount && averageRating ? (\n <ProductLinkRating>\n <div className=\"flex items-center gap-1\">\n {Array.from({length: 5}, (_, i) => (\n <Star\n key={i}\n fill={\n i < Math.floor(averageRating!) ? 'currentColor' : 'none'\n }\n className={cn(\n 'h-3 w-3',\n i < Math.floor(averageRating!)\n ? 'text-primary'\n : 'text-gray-300'\n )}\n />\n ))}\n <span className=\"text-xs text-gray-600 ml-1\">\n ({reviewCount})\n </span>\n </div>\n </ProductLinkRating>\n ) : null}\n\n <ProductLinkPrice>\n {hasDiscount ? (\n <>\n <ProductLinkDiscountPrice>{amount}</ProductLinkDiscountPrice>\n <ProductLinkOriginalPrice>\n {compareAtPriceAmount}\n </ProductLinkOriginalPrice>\n </>\n ) : (\n <ProductLinkCurrentPrice>{amount}</ProductLinkCurrentPrice>\n )}\n </ProductLinkPrice>\n </ProductLinkInfo>\n\n <ProductLinkActions\n filled={isFavoritedLocal}\n onPress={handleActionPress}\n customAction={customAction}\n hideFavoriteAction={hideFavoriteAction}\n />\n </ProductLinkRoot>\n )\n}\n\nexport {ProductLink}\n"],"names":["productLinkVariants","cva","ProductLinkRoot","className","layout","discount","asChild","onPress","props","jsx","Touchable","SlotPrimitive.Root","Card","cn","ProductLinkImage","ProductLinkInfo","CardContent","ProductLinkTitle","children","ProductLinkPrice","ProductLinkCurrentPrice","ProductLinkOriginalPrice","ProductLinkDiscountPrice","ProductLinkRating","ProductLinkActions","hideFavoriteAction","filled","customAction","favoriteAction","FavoriteButton","CardAction","Fragment","ProductLink","product","onClick","onCustomActionClick","navigateToProduct","useShopNavigation","saveProduct","unsaveProduct","useSavedProductsActions","id","title","featuredImage","reviewAnalytics","price","compareAtPrice","isFavorited","selectedVariant","defaultVariantId","shop","isFavoritedLocal","setIsFavoritedLocal","React","averageRating","reviewCount","amount","formatMoney","imageUrl","imageAltText","compareAtPriceAmount","hasDiscount","handlePress","handleActionPress","previousState","jsxs","_","i","Star"],"mappings":";;;;;;;;;;;;AAgBA,MAAMA,IAAsBC,EAAI,IAAI;AAAA,EAClC,UAAU;AAAA,IACR,QAAQ;AAAA,MACN,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,IAAA;AAAA,EAEX;AAAA,EACA,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,UAAU;AAAA,EAAA;AAEd,CAAC;AAWD,SAASC,EAAgB;AAAA,EACvB,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,SAAAC;AAAA,EACA,GAAGC;AACL,GAAyB;AAIrB,SAAA,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,SAASH;AAAA,MACT,UAAU,EAAC,SAAS,IAAG;AAAA,MACvB,YAAY;AA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AAA,QAEA,gBAAAwD,EAAClD,GAAgB,EAAA,QAAO,cACtB,UAAA;AAAA,UAAA,gBAAAN,EAACQ,KAAkB,UAAMyB,EAAA,CAAA;AAAA,UAExBa,KAAeD,IACd,gBAAA7C,EAACc,MACC,UAAC,gBAAA0C,EAAA,OAAA,EAAI,WAAU,2BACZ,UAAA;AAAA,YAAA,MAAM,KAAK,EAAC,QAAQ,KAAI,CAACC,GAAGC,MAC3B,gBAAA1D;AAAA,cAAC2D;AAAA,cAAA;AAAA,gBAEC,MACED,IAAI,KAAK,MAAMb,CAAc,IAAI,iBAAiB;AAAA,gBAEpD,WAAWzC;AAAA,kBACT;AAAA,kBACAsD,IAAI,KAAK,MAAMb,CAAc,IACzB,iBACA;AAAA,gBAAA;AAAA,cACN;AAAA,cATKa;AAAA,YAAA,CAWR;AAAA,YACD,gBAAAF,EAAC,QAAK,EAAA,WAAU,8BAA6B,UAAA;AAAA,cAAA;AAAA,cACzCV;AAAA,cAAY;AAAA,YAAA,EAChB,CAAA;AAAA,UAAA,EACF,CAAA,EACF,CAAA,IACE;AAAA,UAEJ,gBAAA9C,EAACU,GACE,EAAA,UAAA0C,IAEG,gBAAAI,EAAAlC,GAAA,EAAA,UAAA;AAAA,YAAA,gBAAAtB,EAACa,MAA0B,UAAOkC,EAAA,CAAA;AAAA,YAClC,gBAAA/C,EAACY,MACE,UACHuC,EAAA,CAAA;AAAA,UAAA,EACF,CAAA,IAEA,gBAAAnD,EAACW,GAAyB,EAAA,UAAAoC,EAAA,CAAO,EAErC,CAAA;AAAA,QAAA,GACF;AAAA,QAEA,gBAAA/C;AAAA,UAACe;AAAA,UAAA;AAAA,YACC,QAAQ2B;AAAA,YACR,SAASY;AAAA,YACT,cAAApC;AAAA,YACA,oBAAAF;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"product-link.js","sources":["../../../src/components/commerce/product-link.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {type Product} from '@shopify/shop-minis-platform'\nimport {cva, type VariantProps} from 'class-variance-authority'\nimport {Slot as SlotPrimitive} from 'radix-ui'\n\nimport {useShopNavigation} from '../../hooks/navigation/useShopNavigation'\nimport {useSavedProductsActions} from '../../hooks/user/useSavedProductsActions'\nimport {ProductReviewStars} from '../../internal/components/product-review-stars'\nimport {formatMoney} from '../../lib/formatMoney'\nimport {cn} from '../../lib/utils'\nimport {Touchable} from '../atoms/touchable'\nimport {Card, CardContent, CardAction} from '../ui/card'\n\nimport {FavoriteButton} from './favorite-button'\n\nconst productLinkVariants = cva('', {\n variants: {\n layout: {\n horizontal: 'w-full !flex-row items-center gap-3 px-4 py-3',\n vertical: 'flex-col',\n },\n discount: {\n none: '',\n small: '',\n large: '',\n },\n },\n defaultVariants: {\n layout: 'horizontal',\n discount: 'none',\n },\n})\n\n// Primitive components (building blocks)\nexport interface ProductLinkRootProps\n extends React.ComponentProps<typeof Card>,\n VariantProps<typeof productLinkVariants> {\n layout?: 'horizontal' | 'vertical'\n asChild?: boolean\n onPress?: () => void\n}\n\nfunction ProductLinkRoot({\n className,\n layout,\n discount,\n asChild = false,\n onPress,\n ...props\n}: ProductLinkRootProps) {\n const Comp = asChild ? SlotPrimitive.Root : Card\n\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 <Comp\n className={cn(\n productLinkVariants({layout, discount}),\n 'border-0 bg-white rounded-xl shadow-lg shadow-black/10',\n className\n )}\n {...props}\n />\n </Touchable>\n )\n}\n\nfunction ProductLinkImage({\n className,\n layout = 'horizontal',\n ...props\n}: React.ComponentProps<'div'> & {layout?: 'horizontal' | 'vertical'}) {\n return (\n <div\n data-slot=\"product-link-image\"\n className={cn(\n 'overflow-hidden rounded-md bg-muted',\n layout === 'horizontal'\n ? 'h-16 w-16 flex-shrink-0'\n : 'aspect-square w-full',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ProductLinkInfo({\n className,\n layout = 'horizontal',\n ...props\n}: React.ComponentProps<typeof CardContent> & {\n layout?: 'horizontal' | 'vertical'\n}) {\n return (\n <CardContent\n className={cn(\n layout === 'horizontal'\n ? 'flex-1 min-w-0 space-y-1 px-0 py-0'\n : 'space-y-2',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ProductLinkTitle({\n className,\n children,\n ...props\n}: React.ComponentProps<'h3'>) {\n return (\n <h3\n data-slot=\"product-link-title\"\n className={cn(\n 'text-sm font-medium leading-tight text-gray-900 truncate overflow-hidden whitespace-nowrap text-ellipsis',\n className\n )}\n {...props}\n >\n {children}\n </h3>\n )\n}\n\nfunction ProductLinkPrice({className, ...props}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"product-link-price\"\n className={cn('flex items-center gap-2', className)}\n {...props}\n />\n )\n}\n\nfunction ProductLinkCurrentPrice({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"product-link-current-price\"\n className={cn('text-sm font-semibold text-gray-900', className)}\n {...props}\n />\n )\n}\n\nfunction ProductLinkOriginalPrice({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"product-link-original-price\"\n className={cn('text-sm text-gray-500 line-through', className)}\n {...props}\n />\n )\n}\n\nfunction ProductLinkDiscountPrice({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"product-link-discount-price\"\n className={cn('text-sm font-semibold text-red-600', className)}\n {...props}\n />\n )\n}\n\nfunction ProductLinkRating({className, ...props}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"product-link-rating\"\n className={cn('', className)}\n {...props}\n />\n )\n}\n\nfunction ProductLinkActions({\n className,\n hideFavoriteAction = false,\n onPress,\n filled = false,\n customAction,\n ...props\n}: React.ComponentProps<typeof CardAction> & {\n hideFavoriteAction?: boolean\n onPress?: () => void\n filled?: boolean\n customAction?: React.ReactNode\n}) {\n const favoriteAction = hideFavoriteAction ? null : (\n <FavoriteButton filled={filled} onClick={onPress} />\n )\n\n return (\n <CardAction\n className={cn('flex-shrink-0 self-center px-0 py-0', className)}\n {...props}\n >\n <Touchable\n stopPropagation\n onClick={onPress}\n whileTap={{opacity: 0.7, scale: 0.95}}\n transition={{\n opacity: {type: 'tween', duration: 0.08, ease: 'easeInOut'},\n scale: {type: 'tween', duration: 0.08, ease: 'easeInOut'},\n }}\n >\n {customAction ? <>{customAction}</> : favoriteAction}\n </Touchable>\n </CardAction>\n )\n}\n\nexport type ProductLinkProps = {\n product: Product\n hideFavoriteAction?: boolean\n onClick?: (product: Product) => void\n reviewsDisabled?: boolean\n} & (\n | {\n customAction?: never\n onCustomActionClick?: never\n }\n | {\n customAction: React.ReactNode\n onCustomActionClick: () => void\n }\n)\n\n// Composed ProductLink component\nfunction ProductLink({\n product,\n hideFavoriteAction = false,\n onClick,\n customAction,\n onCustomActionClick,\n reviewsDisabled = false,\n}: ProductLinkProps) {\n const {navigateToProduct} = useShopNavigation()\n const {saveProduct, unsaveProduct} = useSavedProductsActions()\n\n const {\n id,\n title,\n featuredImage,\n reviewAnalytics,\n price,\n compareAtPrice,\n isFavorited,\n selectedVariant,\n defaultVariantId,\n shop,\n } = product\n\n // Local state for optimistic UI updates\n const [isFavoritedLocal, setIsFavoritedLocal] = React.useState(isFavorited)\n\n const averageRating = reviewAnalytics?.averageRating\n const reviewCount = reviewAnalytics?.reviewCount\n const amount = price?.amount\n ? formatMoney(price?.amount, price?.currencyCode)\n : undefined\n const imageUrl = featuredImage?.url\n const imageAltText = featuredImage?.altText || title\n const compareAtPriceAmount = compareAtPrice?.amount\n ? formatMoney(compareAtPrice?.amount, compareAtPrice?.currencyCode)\n : undefined\n const hasDiscount = compareAtPriceAmount && compareAtPriceAmount !== amount\n\n const handlePress = React.useCallback(() => {\n navigateToProduct({\n productId: id,\n })\n onClick?.(product)\n }, [navigateToProduct, id, onClick, product])\n\n const handleActionPress = React.useCallback(async () => {\n if (customAction || onCustomActionClick) {\n onCustomActionClick?.()\n return\n }\n\n const previousState = isFavoritedLocal\n\n // Optimistic update\n setIsFavoritedLocal(!previousState)\n\n try {\n if (previousState) {\n await unsaveProduct({\n productId: id,\n shopId: shop.id,\n productVariantId: selectedVariant?.id || defaultVariantId,\n })\n } else {\n await saveProduct({\n productId: id,\n shopId: shop.id,\n productVariantId: selectedVariant?.id || defaultVariantId,\n })\n }\n } catch (error) {\n // Revert optimistic update on error\n setIsFavoritedLocal(previousState)\n }\n }, [\n customAction,\n onCustomActionClick,\n isFavoritedLocal,\n unsaveProduct,\n id,\n shop.id,\n selectedVariant?.id,\n defaultVariantId,\n saveProduct,\n ])\n\n return (\n <ProductLinkRoot\n layout=\"horizontal\"\n discount={hasDiscount ? 'small' : 'none'}\n onPress={handlePress}\n >\n <ProductLinkImage layout=\"horizontal\">\n {imageUrl ? (\n <img\n src={imageUrl}\n alt={imageAltText}\n className=\"h-full w-full object-cover\"\n />\n ) : (\n <div className=\"h-full w-full bg-muted flex items-center justify-center text-muted-foreground text-xs\">\n No Image\n </div>\n )}\n </ProductLinkImage>\n\n <ProductLinkInfo layout=\"horizontal\">\n <ProductLinkTitle>{title}</ProductLinkTitle>\n\n {averageRating && !reviewsDisabled ? (\n <ProductLinkRating>\n <ProductReviewStars\n averageRating={averageRating}\n reviewCount={reviewCount}\n />\n </ProductLinkRating>\n ) : null}\n\n <ProductLinkPrice>\n {hasDiscount ? (\n <>\n <ProductLinkDiscountPrice>{amount}</ProductLinkDiscountPrice>\n <ProductLinkOriginalPrice>\n {compareAtPriceAmount}\n </ProductLinkOriginalPrice>\n </>\n ) : (\n <ProductLinkCurrentPrice>{amount}</ProductLinkCurrentPrice>\n )}\n </ProductLinkPrice>\n </ProductLinkInfo>\n\n <ProductLinkActions\n filled={isFavoritedLocal}\n onPress={handleActionPress}\n customAction={customAction}\n hideFavoriteAction={hideFavoriteAction}\n />\n </ProductLinkRoot>\n )\n}\n\nexport {ProductLink}\n"],"names":["productLinkVariants","cva","ProductLinkRoot","className","layout","discount","asChild","onPress","props","jsx","Touchable","SlotPrimitive.Root","Card","cn","ProductLinkImage","ProductLinkInfo","CardContent","ProductLinkTitle","children","ProductLinkPrice","ProductLinkCurrentPrice","ProductLinkOriginalPrice","ProductLinkDiscountPrice","ProductLinkRating","ProductLinkActions","hideFavoriteAction","filled","customAction","favoriteAction","FavoriteButton","CardAction","Fragment","ProductLink","product","onClick","onCustomActionClick","reviewsDisabled","navigateToProduct","useShopNavigation","saveProduct","unsaveProduct","useSavedProductsActions","id","title","featuredImage","reviewAnalytics","price","compareAtPrice","isFavorited","selectedVariant","defaultVariantId","shop","isFavoritedLocal","setIsFavoritedLocal","React","averageRating","reviewCount","amount","formatMoney","imageUrl","imageAltText","compareAtPriceAmount","hasDiscount","handlePress","handleActionPress","previousState","jsxs","ProductReviewStars"],"mappings":";;;;;;;;;;;;AAgBA,MAAMA,IAAsBC,EAAI,IAAI;AAAA,EAClC,UAAU;AAAA,IACR,QAAQ;AAAA,MACN,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,IAAA;AAAA,EAEX;AAAA,EACA,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,UAAU;AAAA,EAAA;AAEd,CAAC;AAWD,SAASC,EAAgB;AAAA,EACvB,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,SAAAC;AAAA,EACA,GAAGC;AACL,GAAyB;AAIrB,SAAA,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,SAASH;AAAA,MACT,UAAU,EAAC,SAAS,IAAG;AAAA,MACvB,YAAY;AAAA,QACV,SAAS,EAAC,MAAM,SAAS,UAAU,MAAM,MAAM,YAAW;AAAA,MAC5D;AAAA,MAEA,UAAA,gBAAAE;AAAA,QAVSH,IAAUK,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EAAA,CAAA;AAAA,UAExBY,KAAiB,CAACnB,IACjB,gBAAA3B,EAACc,IACC,EAAA,UAAA,gBAAAd;AAAA,YAAC0D;AAAA,YAAA;AAAA,cACC,eAAAZ;AAAA,cACA,aAAAC;AAAA,YAAA;AAAA,aAEJ,IACE;AAAA,UAEJ,gBAAA/C,EAACU,GACE,EAAA,UAAA2C,IAEG,gBAAAI,EAAAnC,GAAA,EAAA,UAAA;AAAA,YAAA,gBAAAtB,EAACa,MAA0B,UAAOmC,EAAA,CAAA;AAAA,YAClC,gBAAAhD,EAACY,MACE,UACHwC,EAAA,CAAA;AAAA,UAAA,EACF,CAAA,IAEA,gBAAApD,EAACW,GAAyB,EAAA,UAAAqC,EAAA,CAAO,EAErC,CAAA;AAAA,QAAA,GACF;AAAA,QAEA,gBAAAhD;AAAA,UAACe;AAAA,UAAA;AAAA,YACC,QAAQ4B;AAAA,YACR,SAASY;AAAA,YACT,cAAArC;AAAA,YACA,oBAAAF;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as e, jsxs as g } from "react/jsx-runtime";
|
|
2
|
-
import { useState as C, useCallback as
|
|
2
|
+
import { useState as C, useCallback as v, createContext as k, useContext as P } from "react";
|
|
3
3
|
import { useProductSearch as I } from "../../hooks/product/useProductSearch.js";
|
|
4
4
|
import { cn as p } from "../../lib/utils.js";
|
|
5
5
|
import { IconButton as L } from "../atoms/icon-button.js";
|
|
6
6
|
import { List as j } from "../atoms/list.js";
|
|
7
7
|
import { Input as Q } from "../ui/input.js";
|
|
8
|
-
import { ProductLink as
|
|
8
|
+
import { ProductLink as y } from "./product-link.js";
|
|
9
9
|
import { ProductLinkSkeleton as m } from "./product-link-skeleton.js";
|
|
10
10
|
import q from "../../shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/search.js";
|
|
11
11
|
import z from "../../shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/x.js";
|
|
@@ -17,11 +17,11 @@ function N() {
|
|
|
17
17
|
return r;
|
|
18
18
|
}
|
|
19
19
|
function M({ initialQuery: r = "", children: c }) {
|
|
20
|
-
const [o,
|
|
20
|
+
const [o, s] = C(r), { products: n, loading: t, error: a, fetchMore: l, hasNextPage: d, isTyping: i } = I({
|
|
21
21
|
query: o,
|
|
22
22
|
fetchPolicy: "network-only"
|
|
23
|
-
}), u =
|
|
24
|
-
|
|
23
|
+
}), u = v((f) => {
|
|
24
|
+
s(f);
|
|
25
25
|
}, []), h = {
|
|
26
26
|
query: o,
|
|
27
27
|
setQuery: u,
|
|
@@ -30,7 +30,7 @@ function M({ initialQuery: r = "", children: c }) {
|
|
|
30
30
|
error: a,
|
|
31
31
|
fetchMore: l,
|
|
32
32
|
hasNextPage: d,
|
|
33
|
-
isTyping:
|
|
33
|
+
isTyping: i
|
|
34
34
|
};
|
|
35
35
|
return /* @__PURE__ */ e(S.Provider, { value: h, children: c });
|
|
36
36
|
}
|
|
@@ -39,7 +39,7 @@ function A({
|
|
|
39
39
|
className: c,
|
|
40
40
|
inputProps: o
|
|
41
41
|
}) {
|
|
42
|
-
const { query:
|
|
42
|
+
const { query: s, setQuery: n } = N(), t = v(
|
|
43
43
|
(a) => {
|
|
44
44
|
n(a.target.value), o?.onChange?.(a);
|
|
45
45
|
},
|
|
@@ -62,7 +62,7 @@ function A({
|
|
|
62
62
|
type: "search",
|
|
63
63
|
role: "searchbox",
|
|
64
64
|
autoComplete: "off",
|
|
65
|
-
value:
|
|
65
|
+
value: s,
|
|
66
66
|
"data-testid": "search-input",
|
|
67
67
|
...o,
|
|
68
68
|
className: p(
|
|
@@ -71,7 +71,7 @@ function A({
|
|
|
71
71
|
)
|
|
72
72
|
}
|
|
73
73
|
) }),
|
|
74
|
-
/* @__PURE__ */ e("div", { className: "relative flex items-center", children:
|
|
74
|
+
/* @__PURE__ */ e("div", { className: "relative flex items-center", children: s === "" ? null : /* @__PURE__ */ e(
|
|
75
75
|
L,
|
|
76
76
|
{
|
|
77
77
|
Icon: z,
|
|
@@ -88,9 +88,9 @@ function E({
|
|
|
88
88
|
height: r = window.innerHeight,
|
|
89
89
|
renderItem: c,
|
|
90
90
|
initialStateComponent: o,
|
|
91
|
-
showScrollbar:
|
|
91
|
+
showScrollbar: s
|
|
92
92
|
}) {
|
|
93
|
-
const { query: n, products: t, loading: a, fetchMore: l, hasNextPage: d, isTyping:
|
|
93
|
+
const { query: n, products: t, loading: a, fetchMore: l, hasNextPage: d, isTyping: i } = N(), u = (x, w) => c ? c(x, w) : /* @__PURE__ */ e("div", { className: "p-2", children: /* @__PURE__ */ e(y, { product: x, hideFavoriteAction: !0 }, x.id) }), h = n.trim().length === 0, f = (!t || t.length === 0) && (a || i), b = (!t || t.length === 0) && !a;
|
|
94
94
|
return h ? o || /* @__PURE__ */ e("div", { className: "flex items-center justify-center h-32 text-gray-500", children: "Start typing to search for products" }) : f ? /* @__PURE__ */ g("div", { className: "flex flex-col px-4 py-4", children: [
|
|
95
95
|
/* @__PURE__ */ e(m, { className: "mb-4" }),
|
|
96
96
|
/* @__PURE__ */ e(m, { className: "mb-4" }),
|
|
@@ -103,7 +103,7 @@ function E({
|
|
|
103
103
|
height: r,
|
|
104
104
|
renderItem: u,
|
|
105
105
|
fetchMore: d ? l : void 0,
|
|
106
|
-
showScrollbar:
|
|
106
|
+
showScrollbar: s
|
|
107
107
|
}
|
|
108
108
|
);
|
|
109
109
|
}
|
|
@@ -111,28 +111,28 @@ function J({
|
|
|
111
111
|
initialQuery: r,
|
|
112
112
|
placeholder: c,
|
|
113
113
|
inputProps: o,
|
|
114
|
-
height:
|
|
114
|
+
height: s,
|
|
115
115
|
className: n,
|
|
116
116
|
renderItem: t,
|
|
117
117
|
itemHeight: a,
|
|
118
118
|
onProductClick: l
|
|
119
119
|
}) {
|
|
120
|
-
const d = (
|
|
121
|
-
|
|
120
|
+
const d = (i, u) => t ? t(i, u) : /* @__PURE__ */ e("div", { className: "p-2", children: /* @__PURE__ */ e(
|
|
121
|
+
y,
|
|
122
122
|
{
|
|
123
|
-
product:
|
|
123
|
+
product: i,
|
|
124
124
|
hideFavoriteAction: !0,
|
|
125
125
|
onClick: l
|
|
126
126
|
},
|
|
127
|
-
|
|
127
|
+
i.id
|
|
128
128
|
) });
|
|
129
|
-
return /* @__PURE__ */ e(M, { initialQuery: r, children: /* @__PURE__ */ g("div", { className: p("flex flex-col ", n), children: [
|
|
130
|
-
/* @__PURE__ */ e("div", { className: "
|
|
129
|
+
return /* @__PURE__ */ e(M, { initialQuery: r, children: /* @__PURE__ */ g("div", { className: p("flex flex-col relative", n), children: [
|
|
130
|
+
/* @__PURE__ */ e("div", { className: "absolute top-0 left-0 right-0 p-4 w-full z-20 bg-background", children: /* @__PURE__ */ e(A, { placeholder: c, inputProps: o }) }),
|
|
131
131
|
/* @__PURE__ */ e("div", { className: "h-14" }),
|
|
132
132
|
/* @__PURE__ */ e(
|
|
133
133
|
E,
|
|
134
134
|
{
|
|
135
|
-
height:
|
|
135
|
+
height: s,
|
|
136
136
|
renderItem: d,
|
|
137
137
|
itemHeight: a,
|
|
138
138
|
showScrollbar: !0
|