@hanzo/commerce 6.1.13 → 6.2.1
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/components/buy/_to_deprecate_select-family-item-card.tsx +3 -4
- package/components/buy/_to_deprecate_select-family-item-panel.tsx +4 -5
- package/components/buy/add-to-cart-widget.tsx +43 -32
- package/components/buy/buy-button.tsx +1 -1
- package/components/buy/buy-card.tsx +17 -26
- package/components/buy/buy-drawer.tsx +6 -25
- package/components/buy/carousel-buy-card.tsx +145 -194
- package/components/buy/foo.txt +27 -0
- package/components/cart/cart-panel/cart-line-item.tsx +1 -1
- package/components/checkout/payment-step-form/contact-form.tsx +2 -2
- package/components/checkout/payment-step-form/methods/crypto.tsx +1 -2
- package/components/checkout/shipping-step-form.tsx +5 -5
- package/components/index.ts +1 -3
- package/components/item-selector/button.tsx +175 -0
- package/components/item-selector/carousel.tsx +162 -0
- package/components/item-selector/index.ts +5 -0
- package/components/quantity-indicator.tsx +48 -0
- package/components/select-family/family-carousel/index.tsx +47 -38
- package/components/select-family/family-carousel/slide.tsx +83 -0
- package/components/select-family/family-carousel/state.ts +83 -0
- package/components/select-family/level-nodes-widget/index.tsx +2 -2
- package/components/select-family/level-nodes-widget/node-image.tsx +2 -2
- package/index.ts +7 -7
- package/package.json +7 -4
- package/service/context.tsx +8 -7
- package/service/debug.ts +41 -0
- package/service/get-instance.ts +3 -0
- package/service/impls/standalone/actual-line-item.ts +5 -7
- package/service/impls/standalone/index.ts +11 -3
- package/service/impls/standalone/standalone-service.ts +133 -38
- package/service/path-utils.ts +26 -0
- package/service/sep.ts +7 -0
- package/types/category-node.ts +38 -0
- package/types/commerce-service.ts +44 -12
- package/types/family.ts +4 -1
- package/types/index.ts +3 -2
- package/types/item-selector.ts +29 -14
- package/types/product.ts +5 -1
- package/types/selection-ui-specifier.ts +36 -0
- package/types/token-separators.ts +7 -0
- package/util/error.ts +34 -0
- package/util/index.ts +4 -1
- package/util/product-media-accessor.ts +58 -0
- package/util/promo-codes.ts +1 -2
- package/util/selection-ui-specifiers.ts +34 -0
- package/util/use-sync-sku-param-w-current-item.ts +2 -2
- package/components/select-family/family-carousel/family-slide.tsx +0 -36
- package/components/select-product/carousel-selector.tsx +0 -112
- package/components/select-product/image-selector.tsx +0 -162
- package/components/select-product/radio-selector.tsx +0 -125
- package/service/impls/index.ts +0 -3
- package/types/buy-ui-spec.ts +0 -8
- package/types/tree-node.ts +0 -24
- package/util/buy-ui-conf.ts +0 -35
- package/util/sep.ts +0 -5
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { observer } from 'mobx-react-lite'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
Label,
|
|
7
|
-
RadioGroup,
|
|
8
|
-
RadioGroupItem,
|
|
9
|
-
ScrollArea
|
|
10
|
-
} from '@hanzo/ui/primitives'
|
|
11
|
-
import { cn } from '@hanzo/ui/util'
|
|
12
|
-
|
|
13
|
-
import type { ItemSelectorProps, LineItem } from '../../types'
|
|
14
|
-
import { formatCurrencyValue } from '../../util'
|
|
15
|
-
|
|
16
|
-
const RadioItemSelector: React.FC<ItemSelectorProps> = observer(({
|
|
17
|
-
items,
|
|
18
|
-
selectedItemRef: itemRef,
|
|
19
|
-
selectSku,
|
|
20
|
-
clx='',
|
|
21
|
-
itemClx='',
|
|
22
|
-
soleItemClx='',
|
|
23
|
-
showFamily=false,
|
|
24
|
-
showQuantity=false,
|
|
25
|
-
scrollList=false
|
|
26
|
-
}) => {
|
|
27
|
-
|
|
28
|
-
const LabelText: React.FC<{item: LineItem}> = ({item}) => (
|
|
29
|
-
(showFamily ? (item.familyTitle + ', ' + item.optionLabel) : item.optionLabel) +
|
|
30
|
-
(showFamily ? ': ' : ', ') + formatCurrencyValue(item.price)
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
const ItemAndPrice: React.FC<{
|
|
34
|
-
item: LineItem
|
|
35
|
-
listBoxMode: boolean
|
|
36
|
-
selected: boolean
|
|
37
|
-
className?: string
|
|
38
|
-
}> = ({
|
|
39
|
-
item,
|
|
40
|
-
listBoxMode,
|
|
41
|
-
selected,
|
|
42
|
-
className=''
|
|
43
|
-
}) => (
|
|
44
|
-
<div className={cn(
|
|
45
|
-
'flex items-center',
|
|
46
|
-
className,
|
|
47
|
-
itemClx,
|
|
48
|
-
)}>
|
|
49
|
-
<RadioGroupItem
|
|
50
|
-
value={item.sku}
|
|
51
|
-
larger
|
|
52
|
-
id={item.sku}
|
|
53
|
-
className={'mr-2 ' + (listBoxMode ? 'hidden' : '')}
|
|
54
|
-
/>
|
|
55
|
-
<Label htmlFor={item.sku} className={selected ? 'text-accent' : ''}>
|
|
56
|
-
<LabelText item={item} />
|
|
57
|
-
</Label>
|
|
58
|
-
</div>
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
const Item: React.FC<{
|
|
62
|
-
item: LineItem
|
|
63
|
-
selected: boolean
|
|
64
|
-
listBoxMode: boolean
|
|
65
|
-
clx?: string
|
|
66
|
-
}> = ({
|
|
67
|
-
item,
|
|
68
|
-
selected,
|
|
69
|
-
listBoxMode,
|
|
70
|
-
clx=''
|
|
71
|
-
}) => {
|
|
72
|
-
|
|
73
|
-
const outClx = [
|
|
74
|
-
'h-10',
|
|
75
|
-
(listBoxMode ? 'border-b border-muted-3 py-1 pl-2' : 'mb-3'),
|
|
76
|
-
(selected && listBoxMode ? 'border border-foreground rounded-sm' : ''),
|
|
77
|
-
]
|
|
78
|
-
|
|
79
|
-
return (showQuantity ? (
|
|
80
|
-
<div key={item.sku} className={cn('flex flex-row items-center', ...outClx, clx )}>
|
|
81
|
-
<ItemAndPrice item={item} selected={selected} listBoxMode={listBoxMode} className='grow'/>
|
|
82
|
-
<div className='grow-0 shrink-0 font-semibold text-sm leading-none px-2'>{ item.quantity > 0 ? `(${item.quantity})` : ' '}</div>
|
|
83
|
-
</div>
|
|
84
|
-
) : (
|
|
85
|
-
<ItemAndPrice
|
|
86
|
-
key={item.sku}
|
|
87
|
-
item={item}
|
|
88
|
-
selected={selected}
|
|
89
|
-
listBoxMode={listBoxMode}
|
|
90
|
-
className={cn(...outClx,
|
|
91
|
-
listBoxMode ? '' : 'mb-1',
|
|
92
|
-
clx)}
|
|
93
|
-
/>
|
|
94
|
-
))
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return items.length > 1 ? (
|
|
98
|
-
<RadioGroup
|
|
99
|
-
className={cn('flex flex-col gap-0',
|
|
100
|
-
(scrollList ? 'shrink min-h-0' : ''),
|
|
101
|
-
clx,
|
|
102
|
-
)}
|
|
103
|
-
onValueChange={selectSku}
|
|
104
|
-
value={itemRef.item ? itemRef.item.sku : ''}
|
|
105
|
-
>
|
|
106
|
-
{scrollList ? (
|
|
107
|
-
<ScrollArea className='mt-2 w-full h-full py-0 border border-muted-2 rounded-sm '>
|
|
108
|
-
{items.map((item) => (
|
|
109
|
-
<Item item={item} listBoxMode={true} selected={itemRef.item?.sku === item.sku}/>
|
|
110
|
-
))}
|
|
111
|
-
</ScrollArea>
|
|
112
|
-
) : (<>
|
|
113
|
-
{items.map((item) => (
|
|
114
|
-
<Item item={item} listBoxMode={false} selected={itemRef.item?.sku === item.sku}/>
|
|
115
|
-
))}
|
|
116
|
-
</>)}
|
|
117
|
-
</RadioGroup>
|
|
118
|
-
) : (
|
|
119
|
-
<div className={soleItemClx}>
|
|
120
|
-
<LabelText item={items[0]} />
|
|
121
|
-
</div>
|
|
122
|
-
)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
export default RadioItemSelector
|
package/service/impls/index.ts
DELETED
package/types/buy-ui-spec.ts
DELETED
package/types/tree-node.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
interface ProductTreeNode {
|
|
4
|
-
skuToken: string // a token in the sku
|
|
5
|
-
label: string
|
|
6
|
-
img? : string | ReactNode // icon is required
|
|
7
|
-
imgAR? : number // helps with svgs
|
|
8
|
-
|
|
9
|
-
/** Short desc of what subNodes refer to.
|
|
10
|
-
* For example, if this node's label is 'Lux Credit',
|
|
11
|
-
* it's subNodesLabel would be 'Level',
|
|
12
|
-
* refering to membership 'levels' ('black', 'elite', etc)
|
|
13
|
-
*/
|
|
14
|
-
subNodesLabel?: string
|
|
15
|
-
subNodes?: ProductTreeNode[]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Which facets tokens are 'on' at each level
|
|
19
|
-
type SelectedPaths = Record<number, string[]>
|
|
20
|
-
|
|
21
|
-
export type {
|
|
22
|
-
ProductTreeNode,
|
|
23
|
-
SelectedPaths
|
|
24
|
-
}
|
package/util/buy-ui-conf.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { BuyUISpec } from '../types'
|
|
2
|
-
import SEP from './sep'
|
|
3
|
-
|
|
4
|
-
const map = new Map<string, BuyUISpec>([
|
|
5
|
-
['LXM_AU', {
|
|
6
|
-
selector: 'radio',
|
|
7
|
-
allVariants: false
|
|
8
|
-
}],
|
|
9
|
-
['LXM_AG', {
|
|
10
|
-
selector: 'radio',
|
|
11
|
-
allVariants: false
|
|
12
|
-
}],
|
|
13
|
-
['LXM_CN', {
|
|
14
|
-
selector: 'image',
|
|
15
|
-
allVariants: false
|
|
16
|
-
}],
|
|
17
|
-
// only one option so image / radio doesn't have meaning
|
|
18
|
-
['LXM_PS', {
|
|
19
|
-
selector: 'image',
|
|
20
|
-
allVariants: false
|
|
21
|
-
}],
|
|
22
|
-
['LXM-VL', {
|
|
23
|
-
selector: 'radio',
|
|
24
|
-
allVariants: false
|
|
25
|
-
}],
|
|
26
|
-
['LXM-CR', {
|
|
27
|
-
selector: 'carousel',
|
|
28
|
-
allVariants: true
|
|
29
|
-
}],
|
|
30
|
-
])
|
|
31
|
-
|
|
32
|
-
export default (skuPath: string): BuyUISpec | undefined => {
|
|
33
|
-
const key = skuPath.split(SEP.TOK).slice(0, 2).join(SEP.TOK)
|
|
34
|
-
return map.get(key)
|
|
35
|
-
}
|