@shopify/shop-minis-react 0.2.5 → 0.2.7
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/index4.js +2 -2
- package/dist/_virtual/index5.js +3 -2
- package/dist/_virtual/index5.js.map +1 -1
- package/dist/_virtual/index6.js +2 -3
- package/dist/_virtual/index6.js.map +1 -1
- package/dist/components/commerce/product-card.js +61 -58
- package/dist/components/commerce/product-card.js.map +1 -1
- package/dist/components/commerce/product-link.js +144 -131
- package/dist/components/commerce/product-link.js.map +1 -1
- package/dist/components/commerce/search.js +15 -15
- package/dist/components/commerce/search.js.map +1 -1
- package/dist/components/ui/drawer.js +30 -28
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/mpd-parser@1.3.1/node_modules/mpd-parser/dist/mpd-parser.es.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/simple-swizzle@0.2.2/node_modules/simple-swizzle/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.0/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/eslint/rules/validate-manifest.cjs +99 -1
- package/package.json +1 -1
- package/src/components/commerce/product-card.test.tsx +68 -0
- package/src/components/commerce/product-card.tsx +10 -2
- package/src/components/commerce/product-link.test.tsx +81 -0
- package/src/components/commerce/product-link.tsx +36 -10
- package/src/components/commerce/search.tsx +1 -1
- package/src/components/ui/drawer.tsx +7 -3
|
@@ -194,13 +194,21 @@ function ProductLinkRating({className, ...props}: React.ComponentProps<'div'>) {
|
|
|
194
194
|
|
|
195
195
|
function ProductLinkActions({
|
|
196
196
|
className,
|
|
197
|
+
hideFavoriteAction = false,
|
|
197
198
|
onPress,
|
|
198
199
|
filled = false,
|
|
200
|
+
customAction,
|
|
199
201
|
...props
|
|
200
202
|
}: React.ComponentProps<typeof CardAction> & {
|
|
203
|
+
hideFavoriteAction?: boolean
|
|
201
204
|
onPress?: () => void
|
|
202
205
|
filled?: boolean
|
|
206
|
+
customAction?: React.ReactNode
|
|
203
207
|
}) {
|
|
208
|
+
const favoriteAction = hideFavoriteAction ? null : (
|
|
209
|
+
<FavoriteButton filled={filled} onClick={onPress} />
|
|
210
|
+
)
|
|
211
|
+
|
|
204
212
|
return (
|
|
205
213
|
<CardAction
|
|
206
214
|
className={cn('flex-shrink-0 self-center px-0 py-0', className)}
|
|
@@ -215,23 +223,34 @@ function ProductLinkActions({
|
|
|
215
223
|
scale: {type: 'tween', duration: 0.08, ease: 'easeInOut'},
|
|
216
224
|
}}
|
|
217
225
|
>
|
|
218
|
-
|
|
226
|
+
{customAction ? <>{customAction}</> : favoriteAction}
|
|
219
227
|
</Touchable>
|
|
220
228
|
</CardAction>
|
|
221
229
|
)
|
|
222
230
|
}
|
|
223
231
|
|
|
224
|
-
export
|
|
232
|
+
export type ProductLinkProps = {
|
|
225
233
|
product: Product
|
|
226
234
|
hideFavoriteAction?: boolean
|
|
227
235
|
onClick?: (product: Product) => void
|
|
228
|
-
}
|
|
236
|
+
} & (
|
|
237
|
+
| {
|
|
238
|
+
customAction?: never
|
|
239
|
+
onCustomActionClick?: never
|
|
240
|
+
}
|
|
241
|
+
| {
|
|
242
|
+
customAction: React.ReactNode
|
|
243
|
+
onCustomActionClick: () => void
|
|
244
|
+
}
|
|
245
|
+
)
|
|
229
246
|
|
|
230
247
|
// Composed ProductLink component
|
|
231
248
|
function ProductLink({
|
|
232
249
|
product,
|
|
233
250
|
hideFavoriteAction = false,
|
|
234
251
|
onClick,
|
|
252
|
+
customAction,
|
|
253
|
+
onCustomActionClick,
|
|
235
254
|
}: ProductLinkProps) {
|
|
236
255
|
const {navigateToProduct} = useShopNavigation()
|
|
237
256
|
const {saveProduct, unsaveProduct} = useSavedProductsActions()
|
|
@@ -272,6 +291,11 @@ function ProductLink({
|
|
|
272
291
|
}, [navigateToProduct, id, onClick, product])
|
|
273
292
|
|
|
274
293
|
const handleActionPress = React.useCallback(async () => {
|
|
294
|
+
if (customAction || onCustomActionClick) {
|
|
295
|
+
onCustomActionClick?.()
|
|
296
|
+
return
|
|
297
|
+
}
|
|
298
|
+
|
|
275
299
|
const previousState = isFavoritedLocal
|
|
276
300
|
|
|
277
301
|
// Optimistic update
|
|
@@ -296,13 +320,15 @@ function ProductLink({
|
|
|
296
320
|
setIsFavoritedLocal(previousState)
|
|
297
321
|
}
|
|
298
322
|
}, [
|
|
323
|
+
customAction,
|
|
324
|
+
onCustomActionClick,
|
|
299
325
|
isFavoritedLocal,
|
|
326
|
+
unsaveProduct,
|
|
300
327
|
id,
|
|
301
328
|
shop.id,
|
|
302
329
|
selectedVariant?.id,
|
|
303
330
|
defaultVariantId,
|
|
304
331
|
saveProduct,
|
|
305
|
-
unsaveProduct,
|
|
306
332
|
])
|
|
307
333
|
|
|
308
334
|
return (
|
|
@@ -366,12 +392,12 @@ function ProductLink({
|
|
|
366
392
|
</ProductLinkPrice>
|
|
367
393
|
</ProductLinkInfo>
|
|
368
394
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
395
|
+
<ProductLinkActions
|
|
396
|
+
filled={isFavoritedLocal}
|
|
397
|
+
onPress={handleActionPress}
|
|
398
|
+
customAction={customAction}
|
|
399
|
+
hideFavoriteAction={hideFavoriteAction}
|
|
400
|
+
/>
|
|
375
401
|
</ProductLinkRoot>
|
|
376
402
|
)
|
|
377
403
|
}
|
|
@@ -111,7 +111,7 @@ function SearchInput({
|
|
|
111
111
|
data-testid="search-input"
|
|
112
112
|
{...inputProps}
|
|
113
113
|
className={cn(
|
|
114
|
-
`w-full flex overflow-hidden rounded-radius-28 border-none py-4 px-0 text-text placeholder:text-text placeholder:opacity-60`,
|
|
114
|
+
`w-full flex overflow-hidden rounded-radius-28 border-none shadow-none py-4 px-0 text-text placeholder:text-text placeholder:opacity-60`,
|
|
115
115
|
className
|
|
116
116
|
)}
|
|
117
117
|
/>
|
|
@@ -44,9 +44,12 @@ function DrawerOverlay({
|
|
|
44
44
|
|
|
45
45
|
function DrawerContent({
|
|
46
46
|
className,
|
|
47
|
+
fullHeight = false,
|
|
47
48
|
children,
|
|
48
49
|
...props
|
|
49
|
-
}: React.ComponentProps<typeof DrawerPrimitive.Content>
|
|
50
|
+
}: React.ComponentProps<typeof DrawerPrimitive.Content> & {
|
|
51
|
+
fullHeight?: boolean
|
|
52
|
+
}) {
|
|
50
53
|
return (
|
|
51
54
|
// vaul's Portal type incorrectly excludes children
|
|
52
55
|
<DrawerPortal {...({} as any)}>
|
|
@@ -55,10 +58,11 @@ function DrawerContent({
|
|
|
55
58
|
data-slot="drawer-content"
|
|
56
59
|
className={cn(
|
|
57
60
|
'group/drawer-content bg-background fixed z-50 flex h-auto flex-col',
|
|
58
|
-
'data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[
|
|
59
|
-
'data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[
|
|
61
|
+
'data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[100vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b',
|
|
62
|
+
'data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[100vh] data-[vaul-drawer-direction=bottom]:rounded-t-[28px] data-[vaul-drawer-direction=bottom]:border-t',
|
|
60
63
|
'data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm',
|
|
61
64
|
'data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm',
|
|
65
|
+
fullHeight ? 'h-[100vh]' : '',
|
|
62
66
|
className
|
|
63
67
|
)}
|
|
64
68
|
{...props}
|