merchi_cart 1.3.4 → 1.3.5

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 (142) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +134 -134
  3. package/esm/components/CustomCartProductForm.js +3 -3
  4. package/esm/components/product-form-sdk-externals.js +3 -3
  5. package/esm/panels/PanelEditCartItem.js +29 -14
  6. package/esm/square/SquareCard.js +9 -9
  7. package/esm/stripe/StripeCardFields.js +6 -15
  8. package/esm/stripe/utils.js +1 -0
  9. package/esm/utilities/currency.js +7 -7
  10. package/esm/utilities/customForm.js +4 -4
  11. package/esm/utilities/helpers.js +4 -0
  12. package/lib/components/CustomCartProductForm.js +3 -3
  13. package/lib/components/product-form-sdk-externals.js +3 -3
  14. package/lib/panels/PanelEditCartItem.js +30 -14
  15. package/lib/square/SquareCard.js +9 -9
  16. package/lib/stripe/StripeCardFields.js +6 -14
  17. package/lib/stripe/utils.js +1 -0
  18. package/lib/utilities/currency.js +7 -7
  19. package/lib/utilities/customForm.js +4 -4
  20. package/lib/utilities/helpers.js +4 -0
  21. package/package.json +104 -103
  22. package/src/Cart.tsx +96 -96
  23. package/src/CartAlert.tsx +35 -35
  24. package/src/CartHeader.tsx +28 -28
  25. package/src/CartProvider.tsx +986 -986
  26. package/src/CartTotals.tsx +102 -102
  27. package/src/buttons/Button.tsx +35 -35
  28. package/src/buttons/ButtonBack.tsx +42 -42
  29. package/src/buttons/ButtonClearCart.tsx +17 -17
  30. package/src/buttons/ButtonInvoiceDownload.tsx +60 -60
  31. package/src/buttons/ButtonNext.tsx +35 -35
  32. package/src/buttons/ButtonNextDynamic.tsx +31 -31
  33. package/src/buttons/ButtonOpenCartMerchiCartModal.tsx +61 -61
  34. package/src/buttons/ButtonPay.tsx +32 -32
  35. package/src/buttons/ButtonShipmentTabNext.tsx +24 -24
  36. package/src/buttons/index.ts +15 -15
  37. package/src/components/Alert.tsx +31 -31
  38. package/src/components/CartBody.tsx +16 -16
  39. package/src/components/CartClient.tsx +52 -52
  40. package/src/components/CartFooter.tsx +15 -15
  41. package/src/components/CartItemRow.tsx +212 -212
  42. package/src/components/CartPaymentSettingsInvalid.tsx +12 -12
  43. package/src/components/CartShipment.tsx +56 -56
  44. package/src/components/CartTabContent.tsx +15 -15
  45. package/src/components/CartTabPanel.tsx +25 -25
  46. package/src/components/CartTableContainer.tsx +15 -15
  47. package/src/components/CartTitle.tsx +22 -22
  48. package/src/components/CartTotalsListGroup.tsx +58 -58
  49. package/src/components/Collapse.tsx +23 -23
  50. package/src/components/CustomCartProductForm.tsx +123 -0
  51. package/src/components/DiscountInputGroup.tsx +160 -160
  52. package/src/components/LoadingTemplate.tsx +22 -22
  53. package/src/components/NoCartItems.tsx +20 -20
  54. package/src/components/ShipmentGroupCard.tsx +170 -170
  55. package/src/components/Table.tsx +15 -15
  56. package/src/components/containers.tsx +40 -40
  57. package/src/components/index.ts +36 -36
  58. package/src/components/product-form-sdk-externals.ts +65 -0
  59. package/src/forms/FormNewCustomer.tsx +169 -169
  60. package/src/forms/FormReturningCustomer.tsx +116 -116
  61. package/src/forms/FormShipmentAddressAndNotes.tsx +163 -163
  62. package/src/forms/FormSquarePayment.tsx +19 -19
  63. package/src/forms/FormStripePayment.tsx +19 -19
  64. package/src/forms/InputAcceptUserTermsAndConditions.tsx +43 -43
  65. package/src/forms/InputError.tsx +23 -23
  66. package/src/forms/InputSelect.tsx +58 -58
  67. package/src/forms/InputText.tsx +56 -56
  68. package/src/forms/InputsAddress.tsx +205 -205
  69. package/src/forms/index.ts +14 -14
  70. package/src/index.ts +31 -31
  71. package/src/modals.tsx +65 -65
  72. package/src/panels/PanelCartItems.tsx +56 -56
  73. package/src/panels/PanelCartShipment.tsx +86 -86
  74. package/src/panels/PanelClearCart.tsx +50 -50
  75. package/src/panels/PanelClientCheckout.tsx +117 -117
  76. package/src/panels/PanelEditCartItem.tsx +172 -149
  77. package/src/panels/PanelPaymentSuccess.tsx +66 -66
  78. package/src/panels/index.ts +15 -15
  79. package/src/square/SquareCard.tsx +84 -84
  80. package/src/stripe/StripeCardFields.tsx +173 -183
  81. package/src/stripe/StripeCardForm.tsx +91 -91
  82. package/src/stripe/StripePaymentButtons.tsx +117 -117
  83. package/src/stripe/actions.ts +94 -94
  84. package/src/stripe/utils.ts +22 -21
  85. package/src/styles/globals.scss +307 -307
  86. package/src/tabs/CartNav.tsx +18 -18
  87. package/src/tabs/NavTab.tsx +36 -36
  88. package/src/types/assets.d.ts +4 -4
  89. package/src/types/index.ts +15 -15
  90. package/src/types/merchi_product_form/index.d.ts +1 -1
  91. package/src/types/merchi_sdk_ts/index.d.ts +1 -1
  92. package/src/types/react-geosuggest/index.d.ts +1 -1
  93. package/src/utilities/address.ts +351 -351
  94. package/src/utilities/cart.ts +80 -80
  95. package/src/utilities/company.ts +8 -8
  96. package/src/utilities/cookie.ts +58 -58
  97. package/src/utilities/currency.ts +216 -216
  98. package/src/utilities/customForm.ts +71 -0
  99. package/src/utilities/helpers.ts +213 -211
  100. package/src/utilities/index.ts +14 -14
  101. package/src/utilities/invoice.ts +60 -60
  102. package/src/utilities/job.ts +13 -13
  103. package/src/utilities/local_storage.ts +130 -130
  104. package/src/utilities/product.ts +14 -14
  105. package/src/utilities/shipment.ts +11 -11
  106. package/src/utilities/tabs.ts +38 -38
  107. package/src/utilities/user.ts +33 -33
  108. package/src/utilities/variations.ts +56 -56
  109. package/esm/components/title.js +0 -28
  110. package/esm/slices/sliceCart.js +0 -193
  111. package/esm/slices/sliceCartAlert.js +0 -43
  112. package/esm/slices/sliceCartItem.js +0 -30
  113. package/esm/slices/sliceCartPayment.js +0 -47
  114. package/esm/slices/sliceCartShipment.js +0 -72
  115. package/esm/slices/sliceFormReturningCustomer.js +0 -24
  116. package/esm/slices/sliceNewCustomerForm.js +0 -23
  117. package/esm/square/actions.js +0 -53
  118. package/esm/square/slices/reducersSquare.js +0 -8
  119. package/esm/square/slices/sliceSquareAlerts.js +0 -34
  120. package/esm/square/slices/sliceSquareForm.js +0 -30
  121. package/esm/store.js +0 -1007
  122. package/esm/stripe/slices/sliceStripeAlerts.js +0 -34
  123. package/esm/stripe/slices/sliceStripeCardForm.js +0 -8
  124. package/esm/stripe/slices/sliceStripeForm.js +0 -57
  125. package/lib/components/title.js +0 -36
  126. package/lib/slices/sliceCart.js +0 -200
  127. package/lib/slices/sliceCartAlert.js +0 -49
  128. package/lib/slices/sliceCartItem.js +0 -36
  129. package/lib/slices/sliceCartPayment.js +0 -53
  130. package/lib/slices/sliceCartShipment.js +0 -78
  131. package/lib/slices/sliceFormReturningCustomer.js +0 -30
  132. package/lib/slices/sliceNewCustomerForm.js +0 -29
  133. package/lib/square/actions.js +0 -61
  134. package/lib/square/slices/reducersSquare.js +0 -15
  135. package/lib/square/slices/sliceSquareAlerts.js +0 -40
  136. package/lib/square/slices/sliceSquareForm.js +0 -36
  137. package/lib/store.js +0 -1027
  138. package/lib/stripe/slices/sliceStripeAlerts.js +0 -40
  139. package/lib/stripe/slices/sliceStripeCardForm.js +0 -15
  140. package/lib/stripe/slices/sliceStripeForm.js +0 -63
  141. package/src/styles/globals.css +0 -319
  142. package/src/styles/globals.css.map +0 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Merchi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Merchi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,134 +1,134 @@
1
- # merchi_cart
2
- Merchi's cart
3
-
4
-
5
- ## Table of Contents
6
-
7
- - [Installation](#installation)
8
- - [Usage](#usage)
9
- - [Props](#props)
10
-
11
- ## Installation
12
-
13
- ```bash
14
- npm install merchi_cart
15
-
16
- or
17
-
18
- yarn add merchi_cart
19
- ```
20
-
21
- ### Usage
22
- context functions:
23
-
24
- components:
25
- ButtonOpenCart
26
- ButtonListWrappedOpenCart
27
- MerchiCart
28
- MerchiCartModal
29
- MerchiShoppingCartModal
30
-
31
- context functions:
32
- setCartComplete - Resets the cart
33
- refetchCart - refetches the cart
34
- createCartAndCookie - clears and resets the cart with a new cookie
35
- getCartShipmentOptions - refetches the cart shipment options
36
-
37
- window functions:
38
- addCartItem - takes job json and creates a cart item
39
- getCart - fetches the cart
40
- getMerchiCartValues - retruns the following:
41
- cart
42
- cartItemsCount
43
- currency
44
- subtotalCost
45
- taxAmount
46
- totalCost
47
- isMerchiCartFetching - checks the fetching state of the cart
48
- setCartComplete - Resets the cart
49
- toggleCartOpen - open close cart modal
50
- refetchCart - refetches the cart
51
- createCartAndCookie = clears and resets the cart with a new cookie
52
-
53
-
54
- ### Props
55
-
56
- | Name | Type | Default | Description |
57
- |-----------------------------------------------|------------|-----------------------------------------------------------------------------|---------------------------------------|
58
- | `cart` | `cartJson Object || undefined`| `"{}"` | `Pass in a cart to init the cart state in the provider`|
59
- | `classNameAlertError` | `string?` | `"alert alert-danger"` | `Class for alert error` |
60
- | `classNameAlertInfo` | `string?` | `"alert alert-info"` | `Class for alert info` |
61
- | `classNameAlertSuccess` | `string?` | `"alert alert-success"` | `Class for alert success` |
62
- | `classNameAlertWarning` | `string?` | `"alert alert-warning"` | `Class for alert warning` |
63
- | `classNameBtn` | `string?` | `"btn"` | `Base class for button elements` |
64
- | `classNameBtnBack` | `string?` | `"btn-lg btn-default pull-left"` | `Class for back button` |
65
- | `classNameBtnCartClear` | `string?` | `"btn-lg btn-danger mr-auto"` | `Class for clear cart button` |
66
- | `classNameBtnClose` | `string?` | `"btn-close"` | `Class for close button element` |
67
- | `classNameBtnDanger` | `string?` | `"btn btn-md btn-danger"` | `Class for button danger element` |
68
- | `classNameBtnDownloadInvoice` | `string?` | `"btn btn-lg btn-primary"` | `Class for button download element` |
69
- | `classNameBtnLink` | `string?` | `"btn-md btn-link"` | `Class for link button elements` |
70
- | `classNameBtnNext` | `string?` | `"btn-lg btn-primary"` | `Class for next button` |
71
- | `classNameBtnNextComplete` | `string?` | `"btn-lg btn-success"` | `Class for next button completed` |
72
- | `classNameBtnPay` | `string?` | `"btn-lg btn-primary width-full"` | `Class for pay button completed` |
73
- | `classNameBtnPrimary` | `string?` | `"btn btn-md btn-primary"` | `Class for edit cart item button` |
74
- | `classNameBtnEditCartItem` | `string?` | `"btn btn-md btn-primary ml-auto"` | `Class for primary button completed` |
75
- | `classNameCartBody` | `string?` | `"merchi-cart-body"` | `Class for cart body container` |
76
- | `classNameCartFooter` | `string?` | `"merchi-cart-footer"` | `Class for cart footer container` |
77
- | `classNameCartFormGroup` | `string?` | `"form-group merchi-form-group"` | `Class for form group element` |
78
- | `classNameCartFormGroupButton` | `string?` | `"merchi-form-group-button"` | `Class for form group button` |
79
- | `classNameCartFormGroupCheckbox` | `string?` | `"form-check"` | `Class for form group checkbox` |
80
- | `classNameCartFormInput` | `string?` | `"form-control"` | `Class for form input` |
81
- | `classNameCartFormLabelCheckbox` | `string?` | `""` | `Class for form input checkbpx label` |
82
- | `classNameCartFormCheckbox` | `string?` | `"form-check-input"` | `Class for form input checkbpx` |
83
- | `classNameCartHeader` | `string?` | `"merchi-cart-header"` | `Class for cart header container` |
84
- | `classNameCartInputError` | `string?` | `"text-danger"` | `Class for form error` |
85
- | `classNameCartNav` | `string?` | `"nav merchi-nav-tabs merchi-nav merchi-nav-fill merchi-nav-pills"` | `Class for cart nav` |
86
- | `classNameNoItems` | `string?` | `"merchi-no-cart-items"` | `Class for no items in cart` |
87
- | `classNameCartGoogleSuggestList` | `string?` | `"list-group m-b-0"` | `Class for google suggest list` |
88
- | `classNameCartGoogleSuggestListItem` | `string?` | `"list-group-item cursor-pointer"` | `Class for google suggest list item` |
89
- | `classNameCartItemFeatureImage` | `string?` | `"img-rounded m-10"` | `Class for cart item feature image` |
90
- | `classNameCartItemInfo` | `string?` | `"text-muted font-weight-normal font-italic"` | `Class for cart item info element` |
91
- | `classNameCartItemInfoCell` | `string?` | `"border-0 align-middle"` | `Class for cart item cell` |
92
- | `classNameCartItemInfoCellRight` | `string?` | `"border-0 align-middle text-right"` | `Class for cart item cell right align`|
93
- | `classNameCartItemInfoContainer` | `string?` | `"ml-3 d-inline-block align-middle"` | `Class for cart item info container` |
94
- | `classNameCartRow` | `string?` | `"merchi-row"` | `Class for row element` |
95
- | `classNameCartRowColumn` | `string?` | `"merchi-column"` | `Class for row column element` |
96
- | `classNameTableContainer` | `string?` | `"table-responsive"` | `Class for cart table container` |
97
- | `classNameCartTab` | `string?` | `"merchi-tab-content"` | `Class for cart tab container` |
98
- | `classNameCartTabItem` | `string?` | `"nav-item merchi-nav-item"` | `Class for cart tab item` |
99
- | `classNameCartTabItemLink` | `string?` | `"merchi-nav-link"` | `Class for cart tab item link |`
100
- | `classNameCartTitle` | `string?` | `"merchi-cart-title"` | `Class for cart Title container` |
101
- | `classNameCartTotalContainer` | `string?` | `"merchi-cart-total-container"` | `Class for totals container elements` |
102
- | `classNameCartToggleIconButton` | `string?` | `"cart-icon-button-class"` | `Class for toggle modal button` |
103
- | `classNameCartTotalItem` | `string?` | `"merchi-cart-total-item"` | `Class for totals item elements` |
104
- | `classNameCartTotalItemPrice` | `string?` | `"merchi-cart-total-item-price"` | `Class for totals item price elements`|
105
- | `classNameClearCartContainer` | `string?` | `"merchi-cart-clear-container"` | `Class cart clear container` |
106
- | `classNameClearCartText` | `string?` | `"merchi-cart-clear-text"` | `Class cart clear text container` |
107
- | `classNameListClientInfo` | `string?` | `"merchi-cart-client-info-list"` | `Class for client info list` |
108
- | `classNameListContainer` | `string?` | `"pb-2"` | `Class for list conatiner element` |
109
- | `classNameCartTotaListContainer` | `string?` | `"merchi-cart-total-list-container"` | `Class for list conatiner for cart totlas element`|
110
- | `classNameListItem` | `string?` | `"list-group-item"` | `Class for list item elements` |
111
- | `classNameListItemCartTotals` | `string?` | `"list-group-item d-flex justify-content-between align-items-center"` | `Class for list item cart totals elements`|
112
- | `classNameList` | `string?` | `"list-group"` | `Class for list elements` |
113
- | `classNameListInline` | `string?` | `"list-inline"` | `Class for list inline elements` |
114
- | `classNameListUnstyles` | `string?` | `"list-unstyled"` | `Class for list unstyled elements` |
115
- | `classNameLoadingTemplate` | `string?` | `"merchi-loading-template"` | `Class for loading elements` |
116
- | `classNameLoadingTemplateContainer` | `string?` | `"merchi-loading-template-container"` | `Class for loading container elements`|
117
- | `classNameShipmentOption` | `string?` | `"merchi-shipment-option"` | `Class for shipment option element` |
118
- | `classNameTable` | `string?` | `"table"` | `Class for table elements` |
119
- | `classNameVariationsList` | `string?` | `"list-unstyled list-inline"` | `Class for variation info` |
120
- | `customSuccessMessage` | `string?` | `undefined` | `A message to display on payment success` |
121
- | `domainId` | `number` | `undefined` | `The merchi domain/store id for the cart` |
122
- | `footer` | `ReactElement`| `undefined` | `A customer footer component` |
123
- | `hideHead` | `boolean` | `false` | `hides the cart head title and close` |
124
- | `includeTheme` | `boolean?` | `false` | `If true will fetch and apply the store theme to the page` |
125
- | `initialiseCart` | `boolean?` | `true` | `If true will initial fetch cart and set cart function on window`|
126
- | `onClickClose` | `() => void?`| `() => console.log('close merchi cart!')` | `a function to close the cart` |
127
- | `setIsCartModalOpen` | `(isOpen: boolean) => void?`| `() => console.log('close merchi cart!')` | `a function to open/close cart modal wrapper`|
128
- | `isCartModalOpen` | `boolean` | `false` | `a boolean value to control the cart modal open/closed`|
129
- | `productFormClassNames` | `obj` | `{}` | `An object to be passsed to the merchi_product_form `|
130
- | `showUserTermsAndConditions` | `boolean?` | `true` | `Display the user t&cs for Merchi` |
131
- | `showCartItemInfo` | `boolean?` | `true` | `Will display the cart item info in the cart items table`|
132
- | `apiUrl` | `string?` | `'https://api.merchi.co/v6/'` | `URL to connect to the Merchi API` |
133
- | `urlFrontend` | `string?` | `'https://merchi.co/'` | `URL to redirect users to a frontend` |
134
- | `urlTrackingPage` | `string?` | `undefined` | `URL used on the thankyou page for tracking`|
1
+ # merchi_cart
2
+ Merchi's cart
3
+
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Usage](#usage)
9
+ - [Props](#props)
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install merchi_cart
15
+
16
+ or
17
+
18
+ yarn add merchi_cart
19
+ ```
20
+
21
+ ### Usage
22
+ context functions:
23
+
24
+ components:
25
+ ButtonOpenCart
26
+ ButtonListWrappedOpenCart
27
+ MerchiCart
28
+ MerchiCartModal
29
+ MerchiShoppingCartModal
30
+
31
+ context functions:
32
+ setCartComplete - Resets the cart
33
+ refetchCart - refetches the cart
34
+ createCartAndCookie - clears and resets the cart with a new cookie
35
+ getCartShipmentOptions - refetches the cart shipment options
36
+
37
+ window functions:
38
+ addCartItem - takes job json and creates a cart item
39
+ getCart - fetches the cart
40
+ getMerchiCartValues - retruns the following:
41
+ cart
42
+ cartItemsCount
43
+ currency
44
+ subtotalCost
45
+ taxAmount
46
+ totalCost
47
+ isMerchiCartFetching - checks the fetching state of the cart
48
+ setCartComplete - Resets the cart
49
+ toggleCartOpen - open close cart modal
50
+ refetchCart - refetches the cart
51
+ createCartAndCookie = clears and resets the cart with a new cookie
52
+
53
+
54
+ ### Props
55
+
56
+ | Name | Type | Default | Description |
57
+ |-----------------------------------------------|------------|-----------------------------------------------------------------------------|---------------------------------------|
58
+ | `cart` | `cartJson Object || undefined`| `"{}"` | `Pass in a cart to init the cart state in the provider`|
59
+ | `classNameAlertError` | `string?` | `"alert alert-danger"` | `Class for alert error` |
60
+ | `classNameAlertInfo` | `string?` | `"alert alert-info"` | `Class for alert info` |
61
+ | `classNameAlertSuccess` | `string?` | `"alert alert-success"` | `Class for alert success` |
62
+ | `classNameAlertWarning` | `string?` | `"alert alert-warning"` | `Class for alert warning` |
63
+ | `classNameBtn` | `string?` | `"btn"` | `Base class for button elements` |
64
+ | `classNameBtnBack` | `string?` | `"btn-lg btn-default pull-left"` | `Class for back button` |
65
+ | `classNameBtnCartClear` | `string?` | `"btn-lg btn-danger mr-auto"` | `Class for clear cart button` |
66
+ | `classNameBtnClose` | `string?` | `"btn-close"` | `Class for close button element` |
67
+ | `classNameBtnDanger` | `string?` | `"btn btn-md btn-danger"` | `Class for button danger element` |
68
+ | `classNameBtnDownloadInvoice` | `string?` | `"btn btn-lg btn-primary"` | `Class for button download element` |
69
+ | `classNameBtnLink` | `string?` | `"btn-md btn-link"` | `Class for link button elements` |
70
+ | `classNameBtnNext` | `string?` | `"btn-lg btn-primary"` | `Class for next button` |
71
+ | `classNameBtnNextComplete` | `string?` | `"btn-lg btn-success"` | `Class for next button completed` |
72
+ | `classNameBtnPay` | `string?` | `"btn-lg btn-primary width-full"` | `Class for pay button completed` |
73
+ | `classNameBtnPrimary` | `string?` | `"btn btn-md btn-primary"` | `Class for edit cart item button` |
74
+ | `classNameBtnEditCartItem` | `string?` | `"btn btn-md btn-primary ml-auto"` | `Class for primary button completed` |
75
+ | `classNameCartBody` | `string?` | `"merchi-cart-body"` | `Class for cart body container` |
76
+ | `classNameCartFooter` | `string?` | `"merchi-cart-footer"` | `Class for cart footer container` |
77
+ | `classNameCartFormGroup` | `string?` | `"form-group merchi-form-group"` | `Class for form group element` |
78
+ | `classNameCartFormGroupButton` | `string?` | `"merchi-form-group-button"` | `Class for form group button` |
79
+ | `classNameCartFormGroupCheckbox` | `string?` | `"form-check"` | `Class for form group checkbox` |
80
+ | `classNameCartFormInput` | `string?` | `"form-control"` | `Class for form input` |
81
+ | `classNameCartFormLabelCheckbox` | `string?` | `""` | `Class for form input checkbpx label` |
82
+ | `classNameCartFormCheckbox` | `string?` | `"form-check-input"` | `Class for form input checkbpx` |
83
+ | `classNameCartHeader` | `string?` | `"merchi-cart-header"` | `Class for cart header container` |
84
+ | `classNameCartInputError` | `string?` | `"text-danger"` | `Class for form error` |
85
+ | `classNameCartNav` | `string?` | `"nav merchi-nav-tabs merchi-nav merchi-nav-fill merchi-nav-pills"` | `Class for cart nav` |
86
+ | `classNameNoItems` | `string?` | `"merchi-no-cart-items"` | `Class for no items in cart` |
87
+ | `classNameCartGoogleSuggestList` | `string?` | `"list-group m-b-0"` | `Class for google suggest list` |
88
+ | `classNameCartGoogleSuggestListItem` | `string?` | `"list-group-item cursor-pointer"` | `Class for google suggest list item` |
89
+ | `classNameCartItemFeatureImage` | `string?` | `"img-rounded m-10"` | `Class for cart item feature image` |
90
+ | `classNameCartItemInfo` | `string?` | `"text-muted font-weight-normal font-italic"` | `Class for cart item info element` |
91
+ | `classNameCartItemInfoCell` | `string?` | `"border-0 align-middle"` | `Class for cart item cell` |
92
+ | `classNameCartItemInfoCellRight` | `string?` | `"border-0 align-middle text-right"` | `Class for cart item cell right align`|
93
+ | `classNameCartItemInfoContainer` | `string?` | `"ml-3 d-inline-block align-middle"` | `Class for cart item info container` |
94
+ | `classNameCartRow` | `string?` | `"merchi-row"` | `Class for row element` |
95
+ | `classNameCartRowColumn` | `string?` | `"merchi-column"` | `Class for row column element` |
96
+ | `classNameTableContainer` | `string?` | `"table-responsive"` | `Class for cart table container` |
97
+ | `classNameCartTab` | `string?` | `"merchi-tab-content"` | `Class for cart tab container` |
98
+ | `classNameCartTabItem` | `string?` | `"nav-item merchi-nav-item"` | `Class for cart tab item` |
99
+ | `classNameCartTabItemLink` | `string?` | `"merchi-nav-link"` | `Class for cart tab item link |`
100
+ | `classNameCartTitle` | `string?` | `"merchi-cart-title"` | `Class for cart Title container` |
101
+ | `classNameCartTotalContainer` | `string?` | `"merchi-cart-total-container"` | `Class for totals container elements` |
102
+ | `classNameCartToggleIconButton` | `string?` | `"cart-icon-button-class"` | `Class for toggle modal button` |
103
+ | `classNameCartTotalItem` | `string?` | `"merchi-cart-total-item"` | `Class for totals item elements` |
104
+ | `classNameCartTotalItemPrice` | `string?` | `"merchi-cart-total-item-price"` | `Class for totals item price elements`|
105
+ | `classNameClearCartContainer` | `string?` | `"merchi-cart-clear-container"` | `Class cart clear container` |
106
+ | `classNameClearCartText` | `string?` | `"merchi-cart-clear-text"` | `Class cart clear text container` |
107
+ | `classNameListClientInfo` | `string?` | `"merchi-cart-client-info-list"` | `Class for client info list` |
108
+ | `classNameListContainer` | `string?` | `"pb-2"` | `Class for list conatiner element` |
109
+ | `classNameCartTotaListContainer` | `string?` | `"merchi-cart-total-list-container"` | `Class for list conatiner for cart totlas element`|
110
+ | `classNameListItem` | `string?` | `"list-group-item"` | `Class for list item elements` |
111
+ | `classNameListItemCartTotals` | `string?` | `"list-group-item d-flex justify-content-between align-items-center"` | `Class for list item cart totals elements`|
112
+ | `classNameList` | `string?` | `"list-group"` | `Class for list elements` |
113
+ | `classNameListInline` | `string?` | `"list-inline"` | `Class for list inline elements` |
114
+ | `classNameListUnstyles` | `string?` | `"list-unstyled"` | `Class for list unstyled elements` |
115
+ | `classNameLoadingTemplate` | `string?` | `"merchi-loading-template"` | `Class for loading elements` |
116
+ | `classNameLoadingTemplateContainer` | `string?` | `"merchi-loading-template-container"` | `Class for loading container elements`|
117
+ | `classNameShipmentOption` | `string?` | `"merchi-shipment-option"` | `Class for shipment option element` |
118
+ | `classNameTable` | `string?` | `"table"` | `Class for table elements` |
119
+ | `classNameVariationsList` | `string?` | `"list-unstyled list-inline"` | `Class for variation info` |
120
+ | `customSuccessMessage` | `string?` | `undefined` | `A message to display on payment success` |
121
+ | `domainId` | `number` | `undefined` | `The merchi domain/store id for the cart` |
122
+ | `footer` | `ReactElement`| `undefined` | `A customer footer component` |
123
+ | `hideHead` | `boolean` | `false` | `hides the cart head title and close` |
124
+ | `includeTheme` | `boolean?` | `false` | `If true will fetch and apply the store theme to the page` |
125
+ | `initialiseCart` | `boolean?` | `true` | `If true will initial fetch cart and set cart function on window`|
126
+ | `onClickClose` | `() => void?`| `() => console.log('close merchi cart!')` | `a function to close the cart` |
127
+ | `setIsCartModalOpen` | `(isOpen: boolean) => void?`| `() => console.log('close merchi cart!')` | `a function to open/close cart modal wrapper`|
128
+ | `isCartModalOpen` | `boolean` | `false` | `a boolean value to control the cart modal open/closed`|
129
+ | `productFormClassNames` | `obj` | `{}` | `An object to be passsed to the merchi_product_form `|
130
+ | `showUserTermsAndConditions` | `boolean?` | `true` | `Display the user t&cs for Merchi` |
131
+ | `showCartItemInfo` | `boolean?` | `true` | `Will display the cart item info in the cart items table`|
132
+ | `apiUrl` | `string?` | `'https://api.merchi.co/v6/'` | `URL to connect to the Merchi API` |
133
+ | `urlFrontend` | `string?` | `'https://merchi.co/'` | `URL to redirect users to a frontend` |
134
+ | `urlTrackingPage` | `string?` | `undefined` | `URL used on the thankyou page for tracking`|
@@ -16,9 +16,9 @@ import { loadFormBundle, publishedFormBundle } from '../utilities/customForm';
16
16
  import { LoadingTemplateSm } from './LoadingTemplate';
17
17
  import { jsx as _jsx } from "react/jsx-runtime";
18
18
  import { Fragment as _Fragment } from "react/jsx-runtime";
19
- /**
20
- * Loads a product's published custom form for cart-item edit. On any failure
21
- * renders `fallback` (the default merchi_product_form) so the cart stays usable.
19
+ /**
20
+ * Loads a product's published custom form for cart-item edit. On any failure
21
+ * renders `fallback` (the default merchi_product_form) so the cart stays usable.
22
22
  */
23
23
  export function CustomCartProductForm(_ref) {
24
24
  var _publishedFormBundle$, _publishedFormBundle;
@@ -1,6 +1,6 @@
1
- /**
2
- * Full merchi_sdk_product_form runtime for window.MerchiProductFormSdk.
3
- * Keep in sync with merchi_api/common/js/product_form_gate.cjs SDK_EXPORTS.
1
+ /**
2
+ * Full merchi_sdk_product_form runtime for window.MerchiProductFormSdk.
3
+ * Keep in sync with merchi_api/common/js/product_form_gate.cjs SDK_EXPORTS.
4
4
  */
5
5
  import { SDK_VERSION, serializeJob, nonEmptyGroups, formatCurrency, urlFor, createPricing, createProductFormRuntime, productHasGroups, groupFieldsOf, independentFieldsOf, isOptionQuantityGridProduct, buildProductFormJob, jobToFormState, selectionsToVariations, Section, Stack, Card, Heading, Text, Divider, Field, GroupRows, OptionQuantityGrid, ProductFormProvider, ProductFormShell, useProductForm, OPTION_FIELD_TYPES, theme } from 'merchi_sdk_product_form';
6
6
  export var MerchiProductFormSdkExternals = {
@@ -23,6 +23,8 @@ import { LoadingTemplateSm } from '../components/LoadingTemplate';
23
23
  import { useCartContext } from '../CartProvider';
24
24
  import { makeCartItem } from '../utilities/cart';
25
25
  import { getCartCookieToken } from '../utilities/cookie';
26
+ import { publishedFormBundle } from '../utilities/customForm';
27
+ import CustomCartProductForm from '../components/CustomCartProductForm';
26
28
  import { jsx as _jsx } from "react/jsx-runtime";
27
29
  import { jsxs as _jsxs } from "react/jsx-runtime";
28
30
  var MerchiProductForm = /*#__PURE__*/lazy(function () {
@@ -76,6 +78,10 @@ function PanelEditCartItem(_ref) {
76
78
  _useState2 = _slicedToArray(_useState, 2),
77
79
  loading = _useState2[0],
78
80
  setLoading = _useState2[1];
81
+ var _useState3 = useState(false),
82
+ _useState4 = _slicedToArray(_useState3, 2),
83
+ customFormActive = _useState4[0],
84
+ setCustomFormActive = _useState4[1];
79
85
  var formId = 'edit-cart-item-form';
80
86
 
81
87
  // This action patches the cart item
@@ -149,27 +155,36 @@ function PanelEditCartItem(_ref) {
149
155
  id: undefined
150
156
  });
151
157
  var showForm = activeTabIndex === tabIdItem && !!(cartItem !== null && cartItem !== void 0 && cartItem.id) && !!(cartItem !== null && cartItem !== void 0 && (_cartItem$product = cartItem.product) !== null && _cartItem$product !== void 0 && _cartItem$product.id);
158
+ var hasPublishedCustomForm = !!publishedFormBundle(cartItem === null || cartItem === void 0 ? void 0 : cartItem.product);
159
+ var defaultForm = /*#__PURE__*/_jsx(Suspense, {
160
+ fallback: /*#__PURE__*/_jsx(LoadingTemplateSm, {}),
161
+ children: /*#__PURE__*/_jsx(MerchiProductForm, _objectSpread({
162
+ apiUrl: apiUrl,
163
+ isCartItem: true,
164
+ initJob: _objectSpread({}, cleanCartItem),
165
+ initProduct: cartItem.product,
166
+ onSubmit: onSubmit,
167
+ productFormId: formId,
168
+ hideRequestQuotationButton: true,
169
+ hidePaymentUpfrontButton: true
170
+ }, productFormClassNames))
171
+ });
152
172
  return /*#__PURE__*/_jsxs(CartTabPanel, {
153
173
  tabId: tabIdItem,
154
174
  children: [/*#__PURE__*/_jsx(CartBody, {
155
175
  style: {
156
176
  padding: '2rem'
157
177
  },
158
- children: showForm && /*#__PURE__*/_jsx(Suspense, {
159
- fallback: /*#__PURE__*/_jsx(LoadingTemplateSm, {}),
160
- children: /*#__PURE__*/_jsx(MerchiProductForm, _objectSpread({
161
- apiUrl: apiUrl,
162
- isCartItem: true,
163
- initJob: _objectSpread({}, cleanCartItem),
164
- initProduct: cartItem.product,
165
- onSubmit: onSubmit,
166
- productFormId: formId,
167
- hideRequestQuotationButton: true,
168
- hidePaymentUpfrontButton: true
169
- }, productFormClassNames))
170
- })
178
+ children: showForm && (hasPublishedCustomForm ? /*#__PURE__*/_jsx(CustomCartProductForm, {
179
+ product: cartItem.product,
180
+ initialJob: cleanCartItem,
181
+ apiUrl: apiUrl,
182
+ onSave: onSubmit,
183
+ fallback: defaultForm,
184
+ onActiveChange: setCustomFormActive
185
+ }) : defaultForm)
171
186
  }), /*#__PURE__*/_jsxs(CartFooter, {
172
- children: [/*#__PURE__*/_jsx(ButtonBack, {}), /*#__PURE__*/_jsxs(Button, {
187
+ children: [/*#__PURE__*/_jsx(ButtonBack, {}), !customFormActive && /*#__PURE__*/_jsxs(Button, {
173
188
  className: classNameBtnEditCartItem,
174
189
  disabled: loading,
175
190
  form: formId,
@@ -84,21 +84,21 @@ function SquareCard() {
84
84
  return _actionSquarePaymentProcess.apply(this, arguments);
85
85
  }
86
86
  return squareWebLocationId ? /*#__PURE__*/_jsx(PaymentForm
87
- /**
88
- * Identifies the calling form with a verified application ID generated from
89
- * the Square Application Dashboard.
87
+ /**
88
+ * Identifies the calling form with a verified application ID generated from
89
+ * the Square Application Dashboard.
90
90
  */, {
91
91
  applicationId: SQUARE_APPLICATION_ID
92
- /**
93
- * Invoked when payment form receives the result of a tokenize generation
94
- * request. The result will be a valid credit card or wallet token, or an error.
92
+ /**
93
+ * Invoked when payment form receives the result of a tokenize generation
94
+ * request. The result will be a valid credit card or wallet token, or an error.
95
95
  */,
96
96
  cardTokenizeResponseReceived: function cardTokenizeResponseReceived(token, buyer) {
97
97
  return actionSquarePaymentProcess(token.token, callbackCreditCardPaymentSuccess);
98
98
  }
99
- /**
100
- * Identifies the location of the merchant that is taking the payment.
101
- * Obtained from the Square Application Dashboard - Locations tab.
99
+ /**
100
+ * Identifies the location of the merchant that is taking the payment.
101
+ * Obtained from the Square Application Dashboard - Locations tab.
102
102
  */,
103
103
  locationId: squareWebLocationId,
104
104
  children: /*#__PURE__*/_jsx(CreditCard, {
@@ -1,12 +1,6 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
1
  import * as React from "react";
8
2
  import StripePaymentButtons from "./StripePaymentButtons";
9
- import { CardCvcElement, CardExpiryElement, CardNumberElement, Elements, useStripe, useElements } from "@stripe/react-stripe-js";
3
+ import { CardElement, Elements, useStripe, useElements } from "@stripe/react-stripe-js";
10
4
  import { loadStripe } from "@stripe/stripe-js";
11
5
  import { CARD_ELEMENT_OPTIONS } from "./utils";
12
6
  import pngStripe from "../assets/stripe-payment-secure.png";
@@ -26,7 +20,7 @@ function InnerForm(_ref) {
26
20
  var stripe = useStripe();
27
21
  var elements = useElements();
28
22
  function paymentStart(e) {
29
- var card = elements.getElement(CardNumberElement);
23
+ var card = elements.getElement(CardElement);
30
24
  setLoadingStripePayment(true);
31
25
  e.preventDefault();
32
26
  if (!stripe || !elements) {
@@ -73,13 +67,10 @@ function InnerForm(_ref) {
73
67
  onSubmit: paymentStart,
74
68
  children: /*#__PURE__*/_jsxs("div", {
75
69
  className: "merchi-cart-stripe-input-container",
76
- children: [/*#__PURE__*/_jsx(CardNumberElement, _objectSpread({
77
- className: inputClass
78
- }, CARD_ELEMENT_OPTIONS)), /*#__PURE__*/_jsx(CardExpiryElement, _objectSpread({
79
- className: inputClass
80
- }, CARD_ELEMENT_OPTIONS)), /*#__PURE__*/_jsx(CardCvcElement, _objectSpread({
81
- className: inputClass
82
- }, CARD_ELEMENT_OPTIONS)), error.message && /*#__PURE__*/_jsx("div", {
70
+ children: [/*#__PURE__*/_jsx(CardElement, {
71
+ className: inputClass,
72
+ options: CARD_ELEMENT_OPTIONS
73
+ }), error.message && /*#__PURE__*/_jsx("div", {
83
74
  className: "merchi-cart-stripe-input-error",
84
75
  children: error.message
85
76
  }), /*#__PURE__*/_jsx(PaymentButton, {
@@ -2,6 +2,7 @@ export function companyStripePubKeyOrTestPubKey(company) {
2
2
  return company.isTesting ? company.stripePublishableTestKey : company.stripePublishableKey;
3
3
  }
4
4
  export var CARD_ELEMENT_OPTIONS = {
5
+ hidePostalCode: true,
5
6
  style: {
6
7
  base: {
7
8
  '::placeholder': {
@@ -118,13 +118,13 @@ export var currencyMap = {
118
118
  ZWD: 'Z$'
119
119
  };
120
120
  export function formatCurrency(amount, options) {
121
- /*
122
- * Example usage:
123
- formatCurrency(-222.123456, {currency: 'EGP',
124
- showCodeIfNoSymbol: true,
125
- financialNegative: true,
126
- decimalPlaces: 3})
127
- --> '(£222.123)'
121
+ /*
122
+ * Example usage:
123
+ formatCurrency(-222.123456, {currency: 'EGP',
124
+ showCodeIfNoSymbol: true,
125
+ financialNegative: true,
126
+ decimalPlaces: 3})
127
+ --> '(£222.123)'
128
128
  */
129
129
 
130
130
  var symbol;
@@ -1,9 +1,9 @@
1
- /**
2
- * Helpers for loading a product's published custom form bundle in cart edit.
3
- * Mirrors the product-embed loader: SRI script tag → window.MERCHI_PRODUCT_FORM_<id>.
1
+ /**
2
+ * Helpers for loading a product's published custom form bundle in cart edit.
3
+ * Mirrors the product-embed loader: SRI script tag → window.MERCHI_PRODUCT_FORM_<id>.
4
4
  */
5
5
 
6
- /** If the product has a published custom form with a compiled bundle, return
6
+ /** If the product has a published custom form with a compiled bundle, return
7
7
  * the info needed to load it; otherwise null (caller falls back). */
8
8
  export function publishedFormBundle(product) {
9
9
  var form = product === null || product === void 0 ? void 0 : product.productForm;
@@ -184,6 +184,10 @@ var productWithImagesEmbed = {
184
184
  linkedFile: {}
185
185
  }
186
186
  },
187
+ // Published custom form pointer for cart-item edit (same shape as product embed).
188
+ productForm: {
189
+ activeVersion: {}
190
+ },
187
191
  taxType: {}
188
192
  };
189
193
  var cartShipmentQuote = {
@@ -24,9 +24,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
24
24
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
25
25
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
26
26
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
- /**
28
- * Loads a product's published custom form for cart-item edit. On any failure
29
- * renders `fallback` (the default merchi_product_form) so the cart stays usable.
27
+ /**
28
+ * Loads a product's published custom form for cart-item edit. On any failure
29
+ * renders `fallback` (the default merchi_product_form) so the cart stays usable.
30
30
  */
31
31
  function CustomCartProductForm(_ref) {
32
32
  var _publishedFormBundle$, _publishedFormBundle;
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.MerchiProductFormSdkExternals = void 0;
7
7
  var _merchi_sdk_product_form = require("merchi_sdk_product_form");
8
- /**
9
- * Full merchi_sdk_product_form runtime for window.MerchiProductFormSdk.
10
- * Keep in sync with merchi_api/common/js/product_form_gate.cjs SDK_EXPORTS.
8
+ /**
9
+ * Full merchi_sdk_product_form runtime for window.MerchiProductFormSdk.
10
+ * Keep in sync with merchi_api/common/js/product_form_gate.cjs SDK_EXPORTS.
11
11
  */
12
12
 
13
13
  var MerchiProductFormSdkExternals = exports.MerchiProductFormSdkExternals = {