@hanzo/commerce 7.3.0 → 7.3.2

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 (83) hide show
  1. package/components/Icons.tsx +34 -34
  2. package/components/add-to-cart-widget.tsx +183 -183
  3. package/components/buy/buy-card.tsx +259 -259
  4. package/components/buy/carousel-buy-card.tsx +242 -242
  5. package/components/buy/multi-family/all-variants-carousel.tsx +261 -261
  6. package/components/buy/multi-family/family-carousel/index.tsx +77 -77
  7. package/components/buy/multi-family/family-carousel/slide.tsx +83 -83
  8. package/components/buy/multi-family/family-carousel/state.ts +87 -87
  9. package/components/buy/multi-family/index.ts +2 -2
  10. package/components/buy/single-family-selector.tsx +90 -90
  11. package/components/buy/title-and-byline.tsx +25 -25
  12. package/components/cart/cart-panel/cart-line-item.tsx +76 -76
  13. package/components/cart/cart-panel/index.tsx +154 -154
  14. package/components/cart/cart-panel/promo-code.tsx +106 -106
  15. package/components/cart/cart-panel/total-area.tsx +60 -60
  16. package/components/checkout/payment-step-form/card-icon-row.tsx +26 -26
  17. package/components/checkout/payment-step-form/card-icons/amex.tsx +32 -32
  18. package/components/checkout/payment-step-form/card-icons/diners-club.tsx +13 -13
  19. package/components/checkout/payment-step-form/card-icons/discover.tsx +25 -25
  20. package/components/checkout/payment-step-form/card-icons/jcb.tsx +26 -26
  21. package/components/checkout/payment-step-form/card-icons/mastercard.tsx +27 -27
  22. package/components/checkout/payment-step-form/card-icons/visa.tsx +25 -25
  23. package/components/checkout/payment-step-form/cc-button.tsx +17 -17
  24. package/components/checkout/payment-step-form/contact-form.tsx +49 -49
  25. package/components/checkout/payment-step-form/crypto-icons/btc.tsx +11 -11
  26. package/components/checkout/payment-step-form/crypto-icons/eth.tsx +20 -20
  27. package/components/checkout/payment-step-form/crypto-icons/usdt.tsx +13 -13
  28. package/components/checkout/payment-step-form/index.tsx +122 -122
  29. package/components/checkout/payment-step-form/methods/bank-transfer.tsx +79 -79
  30. package/components/checkout/payment-step-form/methods/card.tsx +232 -232
  31. package/components/checkout/payment-step-form/methods/crypto.tsx +227 -227
  32. package/components/checkout/payment-step-form/methods/index.ts +22 -22
  33. package/components/checkout/shipping-step-form.tsx +172 -172
  34. package/components/index.ts +11 -11
  35. package/components/item/product-card.tsx +48 -48
  36. package/components/item-selector/button.tsx +188 -188
  37. package/components/item-selector/carousel/index.tsx +197 -197
  38. package/components/item-selector/carousel/slider.tsx +40 -40
  39. package/components/item-selector/index.ts +5 -5
  40. package/components/item-selector/quantity-indicator.tsx +48 -48
  41. package/components/node-tabs/index.tsx +91 -91
  42. package/components/node-tabs/node-image.tsx +31 -31
  43. package/index.ts +12 -12
  44. package/package.json +60 -60
  45. package/service/context.tsx +45 -45
  46. package/service/debug.ts +41 -41
  47. package/service/impls/standalone/actual-line-item.ts +135 -135
  48. package/service/impls/standalone/get-instance.ts +64 -64
  49. package/service/impls/standalone/index.ts +579 -579
  50. package/service/impls/standalone/order/firebase.ts +14 -14
  51. package/service/impls/standalone/order/index.ts +128 -128
  52. package/service/impls/standalone/persistence.ts +33 -33
  53. package/service/path-utils.ts +25 -25
  54. package/service/sep.ts +6 -6
  55. package/tsconfig.json +10 -10
  56. package/types/README.md +1 -1
  57. package/types/category-node.ts +49 -49
  58. package/types/checkout.ts +46 -46
  59. package/types/commerce-config.ts +13 -13
  60. package/types/commerce-service.ts +127 -127
  61. package/types/family.ts +25 -25
  62. package/types/index.ts +15 -15
  63. package/types/item-selector.ts +96 -96
  64. package/types/line-item.ts +29 -29
  65. package/types/multi-family-selector-props.ts +19 -19
  66. package/types/product.ts +20 -20
  67. package/types/promo.ts +9 -9
  68. package/types/selection-ui-specifier.ts +51 -51
  69. package/types/string-mutator.ts +13 -13
  70. package/types/token-separators.ts +7 -7
  71. package/util/analytics.ts +20 -20
  72. package/util/countries.ts +195 -195
  73. package/util/error.ts +34 -34
  74. package/util/index.ts +70 -70
  75. package/util/item-selector-options-accessor.ts +34 -34
  76. package/util/line-item-ref.ts +23 -23
  77. package/util/multi-family-selector-options-accessor.ts +14 -14
  78. package/util/obs-string-mutator.ts +22 -22
  79. package/util/product-media-accessor.ts +58 -58
  80. package/util/promo-codes.ts +108 -108
  81. package/util/selection-ui-specifiers.ts +29 -29
  82. package/util/square-payment.ts +42 -42
  83. package/util/use-sync-sku-param-w-current-item.ts +88 -88
@@ -1,128 +1,128 @@
1
- import type { LineItem, ObsLineItemRef } from './line-item'
2
- import type { CategoryNode, SelectedPaths, CategoryNodeRole } from './category-node'
3
- import type { Family, ObsFamilyRef} from './family'
4
- import type Promo from './promo'
5
-
6
-
7
- interface CommerceService extends ObsLineItemRef, ObsFamilyRef {
8
-
9
- /** Items in cart */
10
- get cartItems(): LineItem[]
11
- /** Total of all quantities of all items in cart */
12
- get cartQuantity(): number
13
- /** Total of all prices x quantities of items in cart */
14
- get cartTotal(): number
15
-
16
- /** cartItem whose quantity was modified most recently
17
- * item: LineItem
18
- * modified: number (timestamp)
19
- * (undefined if cartEmpty)
20
- */
21
- get recentItem(): { item: LineItem, modified: number } | undefined
22
- get promoAppliedCartTotal(): number
23
-
24
- get cartEmpty(): boolean
25
-
26
- get appliedPromo(): Promo | null
27
- setAppliedPromo(promo: Promo | null): void
28
- /** returns the price with promo applied, of undefined if no promo or promo does not apply */
29
- itemPromoPrice(item: LineItem): number | undefined
30
-
31
- getFamilySubtotal(familyId: string): number
32
-
33
- createOrder(email: string, name?: string): Promise<string | undefined>
34
- updateOrderShippingInfo(orderId: string, shippingInfo: any): Promise<void>
35
- updateOrderPaymentInfo(orderId: string, paymentInfo: any): Promise<void>
36
-
37
- /**
38
- * Sets the tokens at each level supplied.
39
- * If a level is selected as [], nothing will be selected.
40
- * If a level is missing (undefined), everything at that level is selected
41
- *
42
- * This selects one or more Family's, and all the LineItem's in them.
43
- *
44
- * An empty value object selects all Family's and all LineItem's,
45
- * */
46
- selectPaths(value: SelectedPaths): Family[]
47
- selectPath(skuPath: string): Family[]
48
-
49
- /**
50
- * With role as ...
51
- *
52
- * 'single-family':
53
- * item: item with skuPath as SKU, otherwise undefined
54
- * node: node at path (or item's parent node),
55
- * family: node at path as family (or item's parent node as family),
56
- * families: undefined
57
- *
58
- * 'family-in-multi-family':
59
- * item: item with skuPath as SKU, otherwise undefined
60
- * node: parent node of this family (or parent node of item's family)
61
- * family: this family (or item's family)
62
- * families: this family (or item's family) and siblings
63
- *
64
- * 'multi-family':
65
- * item: undefined
66
- * node: node at path
67
- * family: undefined
68
- * families: subnodes / families of this node
69
- *
70
- * 'non-outermost':
71
- * item: undefined
72
- * node: node at path
73
- * family: undefined
74
- * families: undefined
75
- *
76
- */
77
- peek(skuPath: string): {
78
- role: CategoryNodeRole
79
- family: Family | undefined
80
- families: Family[] | undefined
81
- node: CategoryNode | undefined
82
- item: LineItem | undefined
83
- } | string // or error string
84
-
85
- /** @deprecated
86
- * Whether this path defines a Family, or if it has further levels
87
- * */
88
- getNodeAtPath(skuPath: string): CategoryNode | undefined
89
-
90
- get selectedPaths(): SelectedPaths // returns a copy
91
-
92
- get selectedItems(): LineItem[]
93
- get selectedFamilies(): Family[]
94
- get hasSelection(): boolean
95
-
96
-
97
- /**
98
- * Who are the subnodes selected at 'level'?
99
- * If more than one value is selected at 'level',
100
- * the returned CategoryNode[] may represent multiple sets.
101
- * */
102
- getSelectedNodesAtLevel(level: number): CategoryNode[] | undefined
103
-
104
- /**
105
- * For convenience, so widgets can share state.
106
- * "current" is unrelated to what branches and items are
107
- * "selected" (with CategoryNode's and paths)
108
- *
109
- * SEE ALSO: from ObsLineItemRef and ObsFamilyRef, there are also
110
- * get item(): LineItem | undefined
111
- * get family(): Family | undefined
112
- *
113
- * These simply delegate to these functions
114
- * */
115
- setCurrentItem(sku: string | undefined): boolean // valid sku and was set.
116
- get currentItem(): LineItem | undefined
117
- setCurrentFamily(id: string | undefined): boolean // valid id and was set.
118
- get currentFamily(): Family | undefined
119
-
120
- // utility
121
- getFamilyById(id: string): Family | undefined
122
- getItemBySku(sku: string): LineItem | undefined
123
- }
124
-
125
-
126
- export {
127
- type CommerceService as default
1
+ import type { LineItem, ObsLineItemRef } from './line-item'
2
+ import type { CategoryNode, SelectedPaths, CategoryNodeRole } from './category-node'
3
+ import type { Family, ObsFamilyRef} from './family'
4
+ import type Promo from './promo'
5
+
6
+
7
+ interface CommerceService extends ObsLineItemRef, ObsFamilyRef {
8
+
9
+ /** Items in cart */
10
+ get cartItems(): LineItem[]
11
+ /** Total of all quantities of all items in cart */
12
+ get cartQuantity(): number
13
+ /** Total of all prices x quantities of items in cart */
14
+ get cartTotal(): number
15
+
16
+ /** cartItem whose quantity was modified most recently
17
+ * item: LineItem
18
+ * modified: number (timestamp)
19
+ * (undefined if cartEmpty)
20
+ */
21
+ get recentItem(): { item: LineItem, modified: number } | undefined
22
+ get promoAppliedCartTotal(): number
23
+
24
+ get cartEmpty(): boolean
25
+
26
+ get appliedPromo(): Promo | null
27
+ setAppliedPromo(promo: Promo | null): void
28
+ /** returns the price with promo applied, of undefined if no promo or promo does not apply */
29
+ itemPromoPrice(item: LineItem): number | undefined
30
+
31
+ getFamilySubtotal(familyId: string): number
32
+
33
+ createOrder(email: string, name?: string): Promise<string | undefined>
34
+ updateOrderShippingInfo(orderId: string, shippingInfo: any): Promise<void>
35
+ updateOrderPaymentInfo(orderId: string, paymentInfo: any): Promise<void>
36
+
37
+ /**
38
+ * Sets the tokens at each level supplied.
39
+ * If a level is selected as [], nothing will be selected.
40
+ * If a level is missing (undefined), everything at that level is selected
41
+ *
42
+ * This selects one or more Family's, and all the LineItem's in them.
43
+ *
44
+ * An empty value object selects all Family's and all LineItem's,
45
+ * */
46
+ selectPaths(value: SelectedPaths): Family[]
47
+ selectPath(skuPath: string): Family[]
48
+
49
+ /**
50
+ * With role as ...
51
+ *
52
+ * 'single-family':
53
+ * item: item with skuPath as SKU, otherwise undefined
54
+ * node: node at path (or item's parent node),
55
+ * family: node at path as family (or item's parent node as family),
56
+ * families: undefined
57
+ *
58
+ * 'family-in-multi-family':
59
+ * item: item with skuPath as SKU, otherwise undefined
60
+ * node: parent node of this family (or parent node of item's family)
61
+ * family: this family (or item's family)
62
+ * families: this family (or item's family) and siblings
63
+ *
64
+ * 'multi-family':
65
+ * item: undefined
66
+ * node: node at path
67
+ * family: undefined
68
+ * families: subnodes / families of this node
69
+ *
70
+ * 'non-outermost':
71
+ * item: undefined
72
+ * node: node at path
73
+ * family: undefined
74
+ * families: undefined
75
+ *
76
+ */
77
+ peek(skuPath: string): {
78
+ role: CategoryNodeRole
79
+ family: Family | undefined
80
+ families: Family[] | undefined
81
+ node: CategoryNode | undefined
82
+ item: LineItem | undefined
83
+ } | string // or error string
84
+
85
+ /** @deprecated
86
+ * Whether this path defines a Family, or if it has further levels
87
+ * */
88
+ getNodeAtPath(skuPath: string): CategoryNode | undefined
89
+
90
+ get selectedPaths(): SelectedPaths // returns a copy
91
+
92
+ get selectedItems(): LineItem[]
93
+ get selectedFamilies(): Family[]
94
+ get hasSelection(): boolean
95
+
96
+
97
+ /**
98
+ * Who are the subnodes selected at 'level'?
99
+ * If more than one value is selected at 'level',
100
+ * the returned CategoryNode[] may represent multiple sets.
101
+ * */
102
+ getSelectedNodesAtLevel(level: number): CategoryNode[] | undefined
103
+
104
+ /**
105
+ * For convenience, so widgets can share state.
106
+ * "current" is unrelated to what branches and items are
107
+ * "selected" (with CategoryNode's and paths)
108
+ *
109
+ * SEE ALSO: from ObsLineItemRef and ObsFamilyRef, there are also
110
+ * get item(): LineItem | undefined
111
+ * get family(): Family | undefined
112
+ *
113
+ * These simply delegate to these functions
114
+ * */
115
+ setCurrentItem(sku: string | undefined): boolean // valid sku and was set.
116
+ get currentItem(): LineItem | undefined
117
+ setCurrentFamily(id: string | undefined): boolean // valid id and was set.
118
+ get currentFamily(): Family | undefined
119
+
120
+ // utility
121
+ getFamilyById(id: string): Family | undefined
122
+ getItemBySku(sku: string): LineItem | undefined
123
+ }
124
+
125
+
126
+ export {
127
+ type CommerceService as default
128
128
  }
package/types/family.ts CHANGED
@@ -1,26 +1,26 @@
1
- import type { ImageDef } from '@hanzo/ui/types'
2
- import type Product from './product'
3
-
4
- interface Family {
5
- id: string // LXB-AU-B
6
- title: string // Minted Bar, Lux Elite Card
7
- titleShort?: string // Elite
8
- parentTitle?: string // Lux Gold, Lux Credit
9
- byline?: string // literal text, or name of function on 'this' object that returns a string
10
- desc?: string
11
- img?: ImageDef,
12
- // inbound to the service, they're Products
13
- // when it's initialized, interally they become LineItems
14
- // always ok to cast up to LineItem thereafter
15
- products: Product[]
16
- }
17
-
18
-
19
- interface ObsFamilyRef {
20
- get family(): Family | undefined
21
- }
22
-
23
- export {
24
- type Family,
25
- type ObsFamilyRef
1
+ import type { ImageDef } from '@hanzo/ui/types'
2
+ import type Product from './product'
3
+
4
+ interface Family {
5
+ id: string // LXB-AU-B
6
+ title: string // Minted Bar, Lux Elite Card
7
+ titleShort?: string // Elite
8
+ parentTitle?: string // Lux Gold, Lux Credit
9
+ byline?: string // literal text, or name of function on 'this' object that returns a string
10
+ desc?: string
11
+ img?: ImageDef,
12
+ // inbound to the service, they're Products
13
+ // when it's initialized, interally they become LineItems
14
+ // always ok to cast up to LineItem thereafter
15
+ products: Product[]
16
+ }
17
+
18
+
19
+ interface ObsFamilyRef {
20
+ get family(): Family | undefined
21
+ }
22
+
23
+ export {
24
+ type Family,
25
+ type ObsFamilyRef
26
26
  }
package/types/index.ts CHANGED
@@ -1,15 +1,15 @@
1
-
2
- export type { default as CommerceService } from './commerce-service'
3
- export type { default as CommerceConfig } from './commerce-config'
4
- export type { default as MultiFamilySelectorProps } from './multi-family-selector-props'
5
- export type { default as Product } from './product'
6
- export type { default as Promo } from './promo'
7
- export type { default as TokenSeparators } from './token-separators'
8
-
9
- export * from './category-node'
10
- export * from './checkout'
11
- export * from './family'
12
- export * from './item-selector'
13
- export * from './line-item'
14
- export * from './selection-ui-specifier'
15
- export * from './string-mutator'
1
+
2
+ export type { default as CommerceService } from './commerce-service'
3
+ export type { default as CommerceConfig } from './commerce-config'
4
+ export type { default as MultiFamilySelectorProps } from './multi-family-selector-props'
5
+ export type { default as Product } from './product'
6
+ export type { default as Promo } from './promo'
7
+ export type { default as TokenSeparators } from './token-separators'
8
+
9
+ export * from './category-node'
10
+ export * from './checkout'
11
+ export * from './family'
12
+ export * from './item-selector'
13
+ export * from './line-item'
14
+ export * from './selection-ui-specifier'
15
+ export * from './string-mutator'
@@ -1,97 +1,97 @@
1
- import type { LineItem, ObsLineItemRef } from './line-item'
2
-
3
- interface ItemSelector {
4
- items: LineItem[]
5
- selectedItemRef: ObsLineItemRef
6
- selectSku: (sku: string) => void
7
- }
8
-
9
- /** default: 'text' */
10
- type ItemButton = 'text' | 'image-and-text' | 'image'
11
-
12
- // NOTE: if a field is added here, it should also
13
- // be added to util/item-selector-options-accessor.ts
14
- type ItemSelectorOptions = {
15
-
16
- /**
17
- * default: short
18
- * 'short': product.shortTitle if defined
19
- * 'long': always us product.title, even if .shortTitle is defined
20
- * 'none': do not show title AND BYLINE
21
- *
22
- * (NOTE: *not* the same as buttonType = 'none')
23
- */
24
- familyTitle?: 'none' | 'long' | 'short'
25
-
26
- /** only if title shown
27
- * default: false */
28
- showFamilyByline?: boolean
29
-
30
- /**
31
- * Whether the item label includes the Family name.
32
- * eg, 'Minted Bar, 1oz' vs '1oz'
33
- * default: false.
34
- */
35
- showFamilyInOption?: boolean
36
- /** default: true if it exists */
37
- showByline?: boolean
38
-
39
- /** default: true */
40
- showPrice?: boolean
41
-
42
- /**
43
- * Show the current item quantity along with title and price.
44
- * default: false
45
- */
46
- showQuantity?: boolean
47
-
48
- buttonType?: ItemButton
49
-
50
- /** (button selector only) default: false */
51
- horizButtons?: boolean
52
-
53
- /** (carousel selector only)
54
- * affects sort. See below.
55
- * default: false */
56
- showSlider?: boolean
57
-
58
- /** default true */
59
- showButtonIfOnlyOne?: boolean
60
-
61
- /**
62
- * Sort by cost.
63
- * If it's a carousel selector and 'showSlider' is true,
64
- * defaults to 'asc', unless another value is explicitly specified.
65
- * Otherwise, defaults to 'none'
66
- * */
67
- sort?: 'none' | 'asc' | 'desc'
68
- }
69
-
70
- interface _ItemSelectorCompProps {
71
- clx?: string
72
- itemClx?: string
73
- soleItemClx?: string
74
- /** type-specific props for ItemSelector's.
75
- * eg, Carousel options.
76
- */
77
- ext?: any
78
- /** List selectors will scroll.
79
- * Used internally
80
- * default: false */
81
- scrollable? : boolean
82
- options?: ItemSelectorOptions
83
-
84
- mobile?: boolean
85
- }
86
-
87
- type ItemSelectorCompProps = Omit<_ItemSelectorCompProps, 'scrollable'>
88
-
89
- interface ItemSelectorProps extends
90
- ItemSelector, _ItemSelectorCompProps {}
91
-
92
- export {
93
- type ItemSelector,
94
- type ItemSelectorCompProps,
95
- type ItemSelectorOptions,
96
- type ItemSelectorProps
1
+ import type { LineItem, ObsLineItemRef } from './line-item'
2
+
3
+ interface ItemSelector {
4
+ items: LineItem[]
5
+ selectedItemRef: ObsLineItemRef
6
+ selectSku: (sku: string) => void
7
+ }
8
+
9
+ /** default: 'text' */
10
+ type ItemButton = 'text' | 'image-and-text' | 'image'
11
+
12
+ // NOTE: if a field is added here, it should also
13
+ // be added to util/item-selector-options-accessor.ts
14
+ type ItemSelectorOptions = {
15
+
16
+ /**
17
+ * default: short
18
+ * 'short': product.shortTitle if defined
19
+ * 'long': always us product.title, even if .shortTitle is defined
20
+ * 'none': do not show title AND BYLINE
21
+ *
22
+ * (NOTE: *not* the same as buttonType = 'none')
23
+ */
24
+ familyTitle?: 'none' | 'long' | 'short'
25
+
26
+ /** only if title shown
27
+ * default: false */
28
+ showFamilyByline?: boolean
29
+
30
+ /**
31
+ * Whether the item label includes the Family name.
32
+ * eg, 'Minted Bar, 1oz' vs '1oz'
33
+ * default: false.
34
+ */
35
+ showFamilyInOption?: boolean
36
+ /** default: true if it exists */
37
+ showByline?: boolean
38
+
39
+ /** default: true */
40
+ showPrice?: boolean
41
+
42
+ /**
43
+ * Show the current item quantity along with title and price.
44
+ * default: false
45
+ */
46
+ showQuantity?: boolean
47
+
48
+ buttonType?: ItemButton
49
+
50
+ /** (button selector only) default: false */
51
+ horizButtons?: boolean
52
+
53
+ /** (carousel selector only)
54
+ * affects sort. See below.
55
+ * default: false */
56
+ showSlider?: boolean
57
+
58
+ /** default true */
59
+ showButtonIfOnlyOne?: boolean
60
+
61
+ /**
62
+ * Sort by cost.
63
+ * If it's a carousel selector and 'showSlider' is true,
64
+ * defaults to 'asc', unless another value is explicitly specified.
65
+ * Otherwise, defaults to 'none'
66
+ * */
67
+ sort?: 'none' | 'asc' | 'desc'
68
+ }
69
+
70
+ interface _ItemSelectorCompProps {
71
+ clx?: string
72
+ itemClx?: string
73
+ soleItemClx?: string
74
+ /** type-specific props for ItemSelector's.
75
+ * eg, Carousel options.
76
+ */
77
+ ext?: any
78
+ /** List selectors will scroll.
79
+ * Used internally
80
+ * default: false */
81
+ scrollable? : boolean
82
+ options?: ItemSelectorOptions
83
+
84
+ mobile?: boolean
85
+ }
86
+
87
+ type ItemSelectorCompProps = Omit<_ItemSelectorCompProps, 'scrollable'>
88
+
89
+ interface ItemSelectorProps extends
90
+ ItemSelector, _ItemSelectorCompProps {}
91
+
92
+ export {
93
+ type ItemSelector,
94
+ type ItemSelectorCompProps,
95
+ type ItemSelectorOptions,
96
+ type ItemSelectorProps
97
97
  }
@@ -1,29 +1,29 @@
1
- import type Product from './product'
2
-
3
- // Client code always
4
- // has a LineItem, whether the Product
5
- // is in the cart or not. Something is in the cart
6
- // when its quantity > 0. That's the only difference.
7
- // The ui, and as well as some Cart state, reacts to
8
- // changes in this quantity.
9
-
10
- // It could have more accurately been named
11
- // 'QuantifiedProduct' but that sucked.
12
- interface LineItem extends Product {
13
-
14
- /** all observable */
15
- get quantity(): number
16
- get canDecrement(): boolean
17
- get isInCart(): boolean
18
-
19
- increment(): void
20
- decrement(): void
21
-
22
- get title(): string
23
- }
24
-
25
- interface ObsLineItemRef {
26
- get item(): LineItem | undefined
27
- }
28
-
29
- export type { LineItem, ObsLineItemRef}
1
+ import type Product from './product'
2
+
3
+ // Client code always
4
+ // has a LineItem, whether the Product
5
+ // is in the cart or not. Something is in the cart
6
+ // when its quantity > 0. That's the only difference.
7
+ // The ui, and as well as some Cart state, reacts to
8
+ // changes in this quantity.
9
+
10
+ // It could have more accurately been named
11
+ // 'QuantifiedProduct' but that sucked.
12
+ interface LineItem extends Product {
13
+
14
+ /** all observable */
15
+ get quantity(): number
16
+ get canDecrement(): boolean
17
+ get isInCart(): boolean
18
+
19
+ increment(): void
20
+ decrement(): void
21
+
22
+ get title(): string
23
+ }
24
+
25
+ interface ObsLineItemRef {
26
+ get item(): LineItem | undefined
27
+ }
28
+
29
+ export type { LineItem, ObsLineItemRef}
@@ -1,20 +1,20 @@
1
- import type { Dimensions } from '@hanzo/ui/types'
2
-
3
- import type { Family } from './family'
4
- import type { ItemSelectorOptions } from './item-selector'
5
- import type { MultiFamilySelectorOptions } from './selection-ui-specifier'
6
- import type { CategoryNode } from './category-node'
7
- import type { LineItem } from './line-item'
8
-
9
- interface MultiFamilySelectorProps {
10
- families: Family[]
11
- parent: CategoryNode
12
- clx?: string
13
- itemClx?: string
14
- itemOptions?: ItemSelectorOptions
15
- selectorOptions?: MultiFamilySelectorOptions
16
- mediaConstraint?: Dimensions
17
- mobile?: boolean
18
- }
19
-
1
+ import type { Dimensions } from '@hanzo/ui/types'
2
+
3
+ import type { Family } from './family'
4
+ import type { ItemSelectorOptions } from './item-selector'
5
+ import type { MultiFamilySelectorOptions } from './selection-ui-specifier'
6
+ import type { CategoryNode } from './category-node'
7
+ import type { LineItem } from './line-item'
8
+
9
+ interface MultiFamilySelectorProps {
10
+ families: Family[]
11
+ parent: CategoryNode
12
+ clx?: string
13
+ itemClx?: string
14
+ itemOptions?: ItemSelectorOptions
15
+ selectorOptions?: MultiFamilySelectorOptions
16
+ mediaConstraint?: Dimensions
17
+ mobile?: boolean
18
+ }
19
+
20
20
  export { type MultiFamilySelectorProps as default }