@hanzo/commerce 7.1.5 → 7.1.6

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 (84) hide show
  1. package/components/Icons.tsx +34 -34
  2. package/components/add-to-cart-widget.tsx +181 -181
  3. package/components/buy/buy-card.tsx +259 -259
  4. package/components/buy/carousel-buy-card.tsx +245 -245
  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-accordian.tsx +59 -59
  13. package/components/cart/cart-panel/cart-line-item.tsx +76 -76
  14. package/components/cart/cart-panel/index.tsx +161 -159
  15. package/components/cart/cart-panel/promo-code.tsx +98 -98
  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 +12 -12
  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/context/index.tsx +45 -45
  44. package/index.ts +12 -12
  45. package/package.json +60 -60
  46. package/service/debug.ts +41 -41
  47. package/service/get-instance.ts +2 -2
  48. package/service/impls/standalone/actual-line-item.ts +121 -121
  49. package/service/impls/standalone/index.ts +62 -62
  50. package/service/impls/standalone/localStorage.ts +34 -34
  51. package/service/impls/standalone/orders/firebase-app.ts +14 -14
  52. package/service/impls/standalone/orders/index.ts +128 -128
  53. package/service/impls/standalone/standalone-service.ts +550 -550
  54. package/service/path-utils.ts +25 -25
  55. package/service/sep.ts +6 -6
  56. package/tsconfig.json +10 -10
  57. package/types/README.md +1 -1
  58. package/types/category-node.ts +49 -49
  59. package/types/checkout.ts +46 -46
  60. package/types/commerce-config.ts +13 -13
  61. package/types/commerce-service.ts +121 -121
  62. package/types/family.ts +25 -25
  63. package/types/index.ts +15 -15
  64. package/types/item-selector.ts +96 -96
  65. package/types/line-item.ts +29 -29
  66. package/types/multi-family-selector-props.ts +19 -19
  67. package/types/product.ts +20 -20
  68. package/types/promo.ts +9 -9
  69. package/types/selection-ui-specifier.ts +51 -51
  70. package/types/string-mutator.ts +13 -13
  71. package/types/token-separators.ts +7 -7
  72. package/util/analytics.ts +20 -20
  73. package/util/countries.ts +195 -195
  74. package/util/error.ts +34 -34
  75. package/util/index.ts +70 -70
  76. package/util/item-selector-options-accessor.ts +34 -34
  77. package/util/line-item-ref.ts +23 -23
  78. package/util/multi-family-selector-options-accessor.ts +14 -14
  79. package/util/obs-string-mutator.ts +22 -22
  80. package/util/product-media-accessor.ts +58 -58
  81. package/util/promo-codes.ts +108 -108
  82. package/util/selection-ui-specifiers.ts +29 -29
  83. package/util/square-payment.ts +42 -42
  84. package/util/use-sync-sku-param-w-current-item.ts +88 -88
@@ -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 }
package/types/product.ts CHANGED
@@ -1,21 +1,21 @@
1
- import type { ImageDef, MediaStackDef } from '@hanzo/ui/types'
2
-
3
- interface Product extends MediaStackDef {
4
- id: string // DB index // not a logical aspect of our domain. may not be necessary at all
5
- sku: string // human visible on orders etc.
6
- fullTitle?: string
7
- optionLabel: string
8
- optionLabelShort?: string
9
- familyId: string // skuPath, eg LXB-AU-B
10
- familyTitle: string
11
- byline?: string
12
- desc?: string
13
- price: number
14
- // image to by uses as an image button in a list of choices
15
- // defaults to (MediaStackDef's) img
16
- optionImg?: ImageDef
17
- }
18
-
19
- export {
20
- type Product as default
1
+ import type { ImageDef, MediaStackDef } from '@hanzo/ui/types'
2
+
3
+ interface Product extends MediaStackDef {
4
+ id: string // DB index // not a logical aspect of our domain. may not be necessary at all
5
+ sku: string // human visible on orders etc.
6
+ fullTitle?: string
7
+ optionLabel: string
8
+ optionLabelShort?: string
9
+ familyId: string // skuPath, eg LXB-AU-B
10
+ familyTitle: string
11
+ byline?: string
12
+ desc?: string
13
+ price: number
14
+ // image to by uses as an image button in a list of choices
15
+ // defaults to (MediaStackDef's) img
16
+ optionImg?: ImageDef
17
+ }
18
+
19
+ export {
20
+ type Product as default
21
21
  }
package/types/promo.ts CHANGED
@@ -1,10 +1,10 @@
1
- interface Promo {
2
- type: 'percent' | 'amount'
3
- code: string
4
- value: number,
5
- skus?: string[]
6
- }
7
-
8
- export {
9
- type Promo as default
1
+ interface Promo {
2
+ type: 'percent' | 'amount'
3
+ code: string
4
+ value: number,
5
+ skus?: string[]
6
+ }
7
+
8
+ export {
9
+ type Promo as default
10
10
  }
@@ -1,52 +1,52 @@
1
- import type { ItemSelectorOptions } from './item-selector'
2
-
3
- type SingleFamilySelector = 'buttons' | 'carousel'
4
- type MultiFamilySelector = 'family-carousel' | 'all-variants-carousel'
5
-
6
- type MultiFamilySelectorOptions = {
7
- /**
8
- * Show title of parent node of families.
9
- * eg,
10
- * Lux Credit
11
- * Black Card
12
- *
13
- * vs just Black Card
14
- *
15
- * ( parent CategoryNode.label)
16
- *
17
- * (goes to one line if only one family)
18
- * default: true
19
- * */
20
- showParentTitle?: boolean
21
-
22
- /** parent CategoryNode.subNodesLabel
23
- *
24
- * default: 'none'
25
- */
26
- parentByline?: 'none' | 'own-line' | 'comma-sep' | 'colon-sep'
27
-
28
- /** show horiz image buttons of
29
- * all sibling items below item info
30
- * default: true*/
31
- showItemSwatches?: boolean
32
- }
33
-
34
- interface SelectionUISpecifier {
35
- multiFamily?: {
36
- type: MultiFamilySelector
37
- selectorOptions?: MultiFamilySelectorOptions
38
- itemOptions?: ItemSelectorOptions
39
- }
40
- singleFamily?: {
41
- type: SingleFamilySelector
42
- options?: ItemSelectorOptions
43
- }
44
- }
45
-
46
- export {
47
- type SelectionUISpecifier,
48
- type ItemSelectorOptions,
49
- type SingleFamilySelector,
50
- type MultiFamilySelector,
51
- type MultiFamilySelectorOptions
1
+ import type { ItemSelectorOptions } from './item-selector'
2
+
3
+ type SingleFamilySelector = 'buttons' | 'carousel'
4
+ type MultiFamilySelector = 'family-carousel' | 'all-variants-carousel'
5
+
6
+ type MultiFamilySelectorOptions = {
7
+ /**
8
+ * Show title of parent node of families.
9
+ * eg,
10
+ * Lux Credit
11
+ * Black Card
12
+ *
13
+ * vs just Black Card
14
+ *
15
+ * ( parent CategoryNode.label)
16
+ *
17
+ * (goes to one line if only one family)
18
+ * default: true
19
+ * */
20
+ showParentTitle?: boolean
21
+
22
+ /** parent CategoryNode.subNodesLabel
23
+ *
24
+ * default: 'none'
25
+ */
26
+ parentByline?: 'none' | 'own-line' | 'comma-sep' | 'colon-sep'
27
+
28
+ /** show horiz image buttons of
29
+ * all sibling items below item info
30
+ * default: true*/
31
+ showItemSwatches?: boolean
32
+ }
33
+
34
+ interface SelectionUISpecifier {
35
+ multiFamily?: {
36
+ type: MultiFamilySelector
37
+ selectorOptions?: MultiFamilySelectorOptions
38
+ itemOptions?: ItemSelectorOptions
39
+ }
40
+ singleFamily?: {
41
+ type: SingleFamilySelector
42
+ options?: ItemSelectorOptions
43
+ }
44
+ }
45
+
46
+ export {
47
+ type SelectionUISpecifier,
48
+ type ItemSelectorOptions,
49
+ type SingleFamilySelector,
50
+ type MultiFamilySelector,
51
+ type MultiFamilySelectorOptions
52
52
  }
@@ -1,14 +1,14 @@
1
- interface StringMutator {
2
- get(): string | null
3
- set(v: string | null): void
4
- }
5
-
6
- interface StringArrayMutator {
7
- get(): string[] | null
8
- set(v: string[] | null): void
9
- }
10
-
11
- export type {
12
- StringMutator,
13
- StringArrayMutator
1
+ interface StringMutator {
2
+ get(): string | null
3
+ set(v: string | null): void
4
+ }
5
+
6
+ interface StringArrayMutator {
7
+ get(): string[] | null
8
+ set(v: string[] | null): void
9
+ }
10
+
11
+ export type {
12
+ StringMutator,
13
+ StringArrayMutator
14
14
  }
@@ -1,7 +1,7 @@
1
- interface TokenSeparators {
2
- readonly tok: string
3
- readonly subTok: string
4
- readonly decimal: string
5
- }
6
-
7
- export { type TokenSeparators as default }
1
+ interface TokenSeparators {
2
+ readonly tok: string
3
+ readonly subTok: string
4
+ readonly decimal: string
5
+ }
6
+
7
+ export { type TokenSeparators as default }
package/util/analytics.ts CHANGED
@@ -1,21 +1,21 @@
1
- declare global {
2
- interface Window {
3
- fbq: Function;
4
- gtag: Function;
5
- }
6
- }
7
-
8
- // https://developers.facebook.com/docs/meta-pixel/reference
9
- const sendFBEvent = (name: string, options = {}) => {
10
- window.fbq('track', name, options)
11
- }
12
-
13
- // https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtag
14
- const sendGAEvent = (name: string, options = {}) => {
15
- window.gtag('event', name, options)
16
- }
17
-
18
- export {
19
- sendFBEvent,
20
- sendGAEvent,
1
+ declare global {
2
+ interface Window {
3
+ fbq: Function;
4
+ gtag: Function;
5
+ }
6
+ }
7
+
8
+ // https://developers.facebook.com/docs/meta-pixel/reference
9
+ const sendFBEvent = (name: string, options = {}) => {
10
+ window.fbq('track', name, options)
11
+ }
12
+
13
+ // https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtag
14
+ const sendGAEvent = (name: string, options = {}) => {
15
+ window.gtag('event', name, options)
16
+ }
17
+
18
+ export {
19
+ sendFBEvent,
20
+ sendGAEvent,
21
21
  }