@hanzo/commerce 6.2.1 → 6.2.3
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import React, { useRef, useEffect, type ComponentType } from 'react'
|
|
2
|
+
import React, { useRef, useEffect, type ComponentType, useState } from 'react'
|
|
3
3
|
import { observer } from 'mobx-react-lite'
|
|
4
4
|
|
|
5
5
|
import { cn } from '@hanzo/ui/util'
|
|
@@ -63,6 +63,8 @@ const CarouselBuyCard: React.FC<{
|
|
|
63
63
|
}
|
|
64
64
|
} | undefined>(undefined)
|
|
65
65
|
|
|
66
|
+
const [changeMeToRerender, setChangeMeToRerender] = useState<boolean>(false)
|
|
67
|
+
|
|
66
68
|
useEffect(() => {
|
|
67
69
|
|
|
68
70
|
const peek = cmmc.peek(skuPath)
|
|
@@ -83,18 +85,17 @@ const CarouselBuyCard: React.FC<{
|
|
|
83
85
|
|
|
84
86
|
if (peek.role === 'single-family') {
|
|
85
87
|
|
|
86
|
-
const singleSpec = uiSpec.singleFamily
|
|
87
|
-
const Selector: ComponentType<ItemSelectorProps> =
|
|
88
|
-
(singleSpec?.type === 'buttons') ? ButtonItemSelector : CarouselItemSelector
|
|
89
|
-
const selOptions = singleSpec?.options
|
|
90
88
|
const items = peek.family!.products as LineItem[]
|
|
89
|
+
const Selector: ComponentType<ItemSelectorProps> =
|
|
90
|
+
(uiSpec.singleFamily?.type === 'buttons') ? ButtonItemSelector : CarouselItemSelector
|
|
91
|
+
const selOptions = uiSpec.singleFamily?.options
|
|
91
92
|
|
|
92
93
|
r.current.single = {
|
|
93
94
|
items,
|
|
94
95
|
Selector,
|
|
95
96
|
selOptions,
|
|
96
97
|
scrollable: !!(items.length > SCROLL.scrollAfter),
|
|
97
|
-
showItemMedia:
|
|
98
|
+
showItemMedia: uiSpec.singleFamily?.type !== 'carousel'
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
const currItem = peek.item ?? peek.family!.products[0]
|
|
@@ -106,7 +107,11 @@ const CarouselBuyCard: React.FC<{
|
|
|
106
107
|
cmmc.setCurrentItem(currItem.sku)
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
|
|
110
|
+
// Must do this since Dialog code takes this comp out of the React shadow DOM
|
|
111
|
+
// (only in prod apparently.)
|
|
112
|
+
setChangeMeToRerender(!changeMeToRerender)
|
|
113
|
+
|
|
114
|
+
}, [skuPath])
|
|
110
115
|
|
|
111
116
|
const TitleArea: React.FC<{
|
|
112
117
|
title: string
|
|
@@ -200,13 +205,4 @@ const CarouselBuyCard: React.FC<{
|
|
|
200
205
|
)
|
|
201
206
|
})
|
|
202
207
|
|
|
203
|
-
/* Above family carousel
|
|
204
|
-
<TitleArea
|
|
205
|
-
title={r.current?.node.label ?? ''}
|
|
206
|
-
byline={r.current?.node.subNodesLabel}
|
|
207
|
-
clx={'mb-2 '}
|
|
208
|
-
bylineClx='!text-center font-bold text-muted mt-3'
|
|
209
|
-
/>
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
208
|
export default CarouselBuyCard
|
|
@@ -83,7 +83,7 @@ const CartPanel: React.FC<PropsWithChildren & {
|
|
|
83
83
|
|
|
84
84
|
const Main: React.FC = observer(() => (<>
|
|
85
85
|
{cmmc.cartEmpty ? (
|
|
86
|
-
<p className={cn('text-center
|
|
86
|
+
<p className={cn('text-center my-3', noItemsClx)}>No items</p>
|
|
87
87
|
) : (<>
|
|
88
88
|
{cmmc.cartItems.map((item) => (
|
|
89
89
|
<CartLineItem
|
|
@@ -38,6 +38,7 @@ const ImageRadioGroupItem = React.forwardRef<
|
|
|
38
38
|
return (
|
|
39
39
|
<RadioGroupPrimitive.Item
|
|
40
40
|
ref={ref}
|
|
41
|
+
data-vaul-no-drag
|
|
41
42
|
className={cn(
|
|
42
43
|
'ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
43
44
|
'focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
|
|
@@ -108,7 +109,7 @@ const ButtonItemSelector: React.FC<ItemSelectorProps> = observer(({
|
|
|
108
109
|
const outerClx = ['h-10 py-2 flex items-center', justifyClx, paddingClx, bgClx, borderClx]
|
|
109
110
|
|
|
110
111
|
return (
|
|
111
|
-
<div className={cn(...outerClx, itemClx )}>
|
|
112
|
+
<div className={cn(...outerClx, itemClx )} data-vaul-no-drag >
|
|
112
113
|
<ImageRadioGroupItem
|
|
113
114
|
item={item}
|
|
114
115
|
constrainTo={DEFAULT_CONSTRAINT}
|
|
@@ -147,6 +148,7 @@ const ButtonItemSelector: React.FC<ItemSelectorProps> = observer(({
|
|
|
147
148
|
)}
|
|
148
149
|
onValueChange={selectSku}
|
|
149
150
|
value={itemRef.item ? itemRef.item.sku : ''}
|
|
151
|
+
data-vaul-no-drag
|
|
150
152
|
>
|
|
151
153
|
{scrollable ? (
|
|
152
154
|
<ScrollArea className='mt-2 w-full h-full py-0 border border-muted-2' data-vaul-no-drag>
|
|
@@ -56,9 +56,9 @@ const FamilySlide: React.FC<Omit<ItemSelector, 'items'> & {
|
|
|
56
56
|
*/
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
|
-
<div className={cn('flex flex-col items-center gap-4', clx)}>
|
|
59
|
+
<div className={cn('flex flex-col items-center gap-4', clx)} data-vaul-no-drag >
|
|
60
60
|
{title && (
|
|
61
|
-
<ApplyTypography className='flex flex-col items-center !gap-1 [&>*]:!m-0'>
|
|
61
|
+
<ApplyTypography className='flex flex-col items-center !gap-1 [&>*]:!m-0' data-vaul-no-drag >
|
|
62
62
|
<h6 className='font-bold text-lg'>{title}</h6>
|
|
63
63
|
{byline && (<p className={''}>{byline}</p>)}
|
|
64
64
|
</ApplyTypography>
|