@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.
Files changed (55) hide show
  1. package/components/buy/_to_deprecate_select-family-item-card.tsx +3 -4
  2. package/components/buy/_to_deprecate_select-family-item-panel.tsx +4 -5
  3. package/components/buy/add-to-cart-widget.tsx +43 -32
  4. package/components/buy/buy-button.tsx +1 -1
  5. package/components/buy/buy-card.tsx +17 -26
  6. package/components/buy/buy-drawer.tsx +6 -25
  7. package/components/buy/carousel-buy-card.tsx +145 -194
  8. package/components/buy/foo.txt +27 -0
  9. package/components/cart/cart-panel/cart-line-item.tsx +1 -1
  10. package/components/checkout/payment-step-form/contact-form.tsx +2 -2
  11. package/components/checkout/payment-step-form/methods/crypto.tsx +1 -2
  12. package/components/checkout/shipping-step-form.tsx +5 -5
  13. package/components/index.ts +1 -3
  14. package/components/item-selector/button.tsx +175 -0
  15. package/components/item-selector/carousel.tsx +162 -0
  16. package/components/item-selector/index.ts +5 -0
  17. package/components/quantity-indicator.tsx +48 -0
  18. package/components/select-family/family-carousel/index.tsx +47 -38
  19. package/components/select-family/family-carousel/slide.tsx +83 -0
  20. package/components/select-family/family-carousel/state.ts +83 -0
  21. package/components/select-family/level-nodes-widget/index.tsx +2 -2
  22. package/components/select-family/level-nodes-widget/node-image.tsx +2 -2
  23. package/index.ts +7 -7
  24. package/package.json +7 -4
  25. package/service/context.tsx +8 -7
  26. package/service/debug.ts +41 -0
  27. package/service/get-instance.ts +3 -0
  28. package/service/impls/standalone/actual-line-item.ts +5 -7
  29. package/service/impls/standalone/index.ts +11 -3
  30. package/service/impls/standalone/standalone-service.ts +133 -38
  31. package/service/path-utils.ts +26 -0
  32. package/service/sep.ts +7 -0
  33. package/types/category-node.ts +38 -0
  34. package/types/commerce-service.ts +44 -12
  35. package/types/family.ts +4 -1
  36. package/types/index.ts +3 -2
  37. package/types/item-selector.ts +29 -14
  38. package/types/product.ts +5 -1
  39. package/types/selection-ui-specifier.ts +36 -0
  40. package/types/token-separators.ts +7 -0
  41. package/util/error.ts +34 -0
  42. package/util/index.ts +4 -1
  43. package/util/product-media-accessor.ts +58 -0
  44. package/util/promo-codes.ts +1 -2
  45. package/util/selection-ui-specifiers.ts +34 -0
  46. package/util/use-sync-sku-param-w-current-item.ts +2 -2
  47. package/components/select-family/family-carousel/family-slide.tsx +0 -36
  48. package/components/select-product/carousel-selector.tsx +0 -112
  49. package/components/select-product/image-selector.tsx +0 -162
  50. package/components/select-product/radio-selector.tsx +0 -125
  51. package/service/impls/index.ts +0 -3
  52. package/types/buy-ui-spec.ts +0 -8
  53. package/types/tree-node.ts +0 -24
  54. package/util/buy-ui-conf.ts +0 -35
  55. 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
@@ -1,3 +0,0 @@
1
- import { getInstance } from './standalone'
2
-
3
- export default getInstance
@@ -1,8 +0,0 @@
1
- interface BuyUISpec {
2
- selector: 'carousel' | 'radio' | 'image'
3
- allVariants: boolean
4
- }
5
-
6
- export {
7
- type BuyUISpec as default
8
- }
@@ -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
- }
@@ -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
- }
package/util/sep.ts DELETED
@@ -1,5 +0,0 @@
1
- export default {
2
- TOK: '-',
3
- SUB_TOK: '_',
4
- DECIMAL: '.'
5
- }