@hanzo/commerce 7.0.0 → 7.0.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.
@@ -203,7 +203,7 @@ const CarouselBuyCard: React.FC<{
203
203
  <div className={clx}>
204
204
  <AddToCartWidget
205
205
  item={cmmc.currentItem}
206
- registerAdd={false}
206
+ registerAdd={true}
207
207
  onQuantityChanged={onQuantityChanged}
208
208
  variant={cmmc.cartEmpty ? 'primary' : 'outline'}
209
209
  className={addBtnClx}
@@ -242,8 +242,10 @@ const AllVariantsCarousel: React.FC<MultiFamilySelectorProps> = ({
242
242
  </CarouselItem>
243
243
  ))}
244
244
  </CarouselContent>
245
- <CarouselPrevious className='left-1'/>
246
- <CarouselNext className='right-1'/>
245
+ {r.current.items.length > 1 && (<>
246
+ <CarouselPrevious className='left-1'/>
247
+ <CarouselNext className='right-1'/>
248
+ </>)}
247
249
  </Carousel>
248
250
  )}
249
251
  <ItemInfo labelClx='!text-base font-medium'/>
@@ -61,7 +61,7 @@ const CartLineItem: React.FC<{
61
61
  </div>
62
62
  <div className='flex flex-row items-center justify-between w-full'>
63
63
  <div className='flex flex-row items-center'>
64
- <AddToCartWidget variant='minimal' item={item} buttonClx='!h-8 md:!h-6' />
64
+ <AddToCartWidget variant='minimal' registerAdd={false} item={item} buttonClx='!h-8 md:!h-6' />
65
65
  {item.quantity > 1 && (<span className='pl-2.5'>{'@' + formatCurrencyValue(item.price)}</span>)}
66
66
  </div>
67
67
  <div className='flex flex-row gap-1 items-center justify-end'>
@@ -4,22 +4,20 @@ import {
4
4
  makeObservable,
5
5
  observable,
6
6
  } from 'mobx'
7
- import type { CommerceService, LineItem } from '../types'
7
+ import type { CommerceService, LineItem, ObsLineItemRef } from '../types'
8
8
 
9
9
 
10
-
11
- interface CommerceUI {
10
+ interface CommerceUI extends ObsLineItemRef {
12
11
  showBuyOptions: (skuPath: string) => void
13
12
  hideBuyOptions: () => void
14
13
  get buyOptionsSkuPath(): string | undefined
15
14
 
16
- itemQuantityChanged(item: LineItem, val: number, prevVal: number): void
17
- get activeItem(): LineItem | undefined
15
+ itemQuantityChanged(item: LineItem, val: number, prevVal: number): void
18
16
  }
19
17
 
20
18
  class CommerceUIStore implements CommerceUI {
21
19
 
22
- static readonly TIMEOUT = 2500
20
+ static readonly TIMEOUT = 1500
23
21
  _buyOptionsSkuPath: string | undefined = undefined
24
22
  _paused: boolean = false
25
23
  _activeItem: LineItem | undefined = undefined
@@ -36,7 +34,7 @@ class CommerceUIStore implements CommerceUI {
36
34
  buyOptionsSkuPath: computed,
37
35
  itemQuantityChanged: action,
38
36
  tick: action,
39
- activeItem: computed
37
+ item: computed
40
38
  })
41
39
  }
42
40
 
@@ -92,7 +90,7 @@ class CommerceUIStore implements CommerceUI {
92
90
  }
93
91
  }
94
92
 
95
- get activeItem(): LineItem | undefined {
93
+ get item(): LineItem | undefined {
96
94
  return this._activeItem
97
95
  }
98
96
  }
package/context/index.tsx CHANGED
@@ -37,19 +37,22 @@ const CommerceProvider: React.FC<PropsWithChildren & {
37
37
  rootNode: CategoryNode
38
38
  options?: ServiceOptions
39
39
  uiSpecs?: Record<string, SelectionUISpecifier>
40
+ DEBUG_NO_TICK?: boolean
40
41
  }> = ({
41
42
  children,
42
43
  families,
43
44
  rootNode,
44
45
  options,
45
- uiSpecs
46
+ uiSpecs,
47
+ DEBUG_NO_TICK=false
46
48
  }) => {
47
49
 
48
50
  useEffect(() => {
51
+ if (DEBUG_NO_TICK) return
49
52
  const intervalId = setInterval(() => {
50
53
  (valueRef.current.ui as CommerceUIStore).tick()
51
54
  }, 250)
52
- return () => {clearInterval(intervalId)}
55
+ return () => { clearInterval(intervalId) }
53
56
  }, [])
54
57
 
55
58
  // TODO: Inject Promo fixture here from siteDef
package/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './context'
2
2
  export * from './components'
3
+ // Impl-dependent, so leave w impl
3
4
  export type { StandaloneServiceOptions as ServiceOptions } from './service/impls/standalone/standalone-service'
4
5
  export {
5
6
  useSyncSkuParamWithCurrentItem,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/commerce",
3
- "version": "7.0.0",
3
+ "version": "7.0.1",
4
4
  "description": "e-commerce framework.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -16,6 +16,7 @@ class LineItemRef implements ObsLineItemRef {
16
16
  }
17
17
 
18
18
  get item(): LineItem | undefined { return this._item }
19
+
19
20
  set = (v: LineItem | undefined): void => { this._item = v }
20
21
  }
21
22