@merchi/cart 1.4.4

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 (372) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +134 -0
  3. package/esm/Cart.js +62 -0
  4. package/esm/CartAlert.js +47 -0
  5. package/esm/CartHeader.js +29 -0
  6. package/esm/CartProvider.js +1101 -0
  7. package/esm/CartTotals.js +89 -0
  8. package/esm/assets/merchi-monster-loader.gif +0 -0
  9. package/esm/assets/merchi-swipe-outline.png +0 -0
  10. package/esm/assets/product-not-found.png +0 -0
  11. package/esm/assets/stripe-payment-secure.png +0 -0
  12. package/esm/buttons/Button.js +23 -0
  13. package/esm/buttons/ButtonBack.js +35 -0
  14. package/esm/buttons/ButtonClearCart.js +17 -0
  15. package/esm/buttons/ButtonInvoiceDownload.js +88 -0
  16. package/esm/buttons/ButtonNext.js +39 -0
  17. package/esm/buttons/ButtonNextDynamic.js +19 -0
  18. package/esm/buttons/ButtonOpenCartMerchiCartModal.js +47 -0
  19. package/esm/buttons/ButtonPay.js +26 -0
  20. package/esm/buttons/ButtonShipmentTabNext.js +28 -0
  21. package/esm/buttons/index.js +7 -0
  22. package/esm/components/Alert.js +26 -0
  23. package/esm/components/CartBody.js +14 -0
  24. package/esm/components/CartClient.js +62 -0
  25. package/esm/components/CartFooter.js +12 -0
  26. package/esm/components/CartItemRow.js +230 -0
  27. package/esm/components/CartPaymentSettingsInvalid.js +13 -0
  28. package/esm/components/CartShipment.js +52 -0
  29. package/esm/components/CartTabContent.js +12 -0
  30. package/esm/components/CartTabPanel.js +25 -0
  31. package/esm/components/CartTableContainer.js +12 -0
  32. package/esm/components/CartTitle.js +26 -0
  33. package/esm/components/CartTotalsListGroup.js +71 -0
  34. package/esm/components/Collapse.js +32 -0
  35. package/esm/components/CustomCartProductForm.js +128 -0
  36. package/esm/components/CustomerCheckoutMethodTabs.js +94 -0
  37. package/esm/components/DiscountInputGroup.js +293 -0
  38. package/esm/components/LoadingTemplate.js +23 -0
  39. package/esm/components/NoCartItems.js +20 -0
  40. package/esm/components/ShipmentGroupCard.js +207 -0
  41. package/esm/components/Table.js +13 -0
  42. package/esm/components/containers.js +31 -0
  43. package/esm/components/index.js +18 -0
  44. package/esm/components/product-form-sdk-externals.js +36 -0
  45. package/esm/forms/FormNewCustomer.js +243 -0
  46. package/esm/forms/FormReturningCustomer.js +165 -0
  47. package/esm/forms/FormShipmentAddressAndNotes.js +195 -0
  48. package/esm/forms/FormSquarePayment.js +19 -0
  49. package/esm/forms/FormStripePayment.js +19 -0
  50. package/esm/forms/FormWhatsappCustomer.js +253 -0
  51. package/esm/forms/InputAcceptUserTermsAndConditions.js +35 -0
  52. package/esm/forms/InputError.js +16 -0
  53. package/esm/forms/InputSelect.js +48 -0
  54. package/esm/forms/InputText.js +56 -0
  55. package/esm/forms/InputsAddress.js +476 -0
  56. package/esm/forms/index.js +8 -0
  57. package/esm/index.js +13 -0
  58. package/esm/modals.js +51 -0
  59. package/esm/panels/PanelCartItems.js +49 -0
  60. package/esm/panels/PanelCartShipment.js +66 -0
  61. package/esm/panels/PanelClearCart.js +56 -0
  62. package/esm/panels/PanelClientCheckout.js +81 -0
  63. package/esm/panels/PanelEditCartItem.js +199 -0
  64. package/esm/panels/PanelPaymentSuccess.js +63 -0
  65. package/esm/panels/index.js +7 -0
  66. package/esm/square/SquareCard.js +106 -0
  67. package/esm/stripe/LegacyStripeCardForm.js +157 -0
  68. package/esm/stripe/StripeCardFields.js +126 -0
  69. package/esm/stripe/StripeCardForm.js +33 -0
  70. package/esm/stripe/StripePaymentButtons.js +98 -0
  71. package/esm/stripe/actions.js +192 -0
  72. package/esm/stripe/utils.js +20 -0
  73. package/esm/styles/globals.css +463 -0
  74. package/esm/styles/globals.css.map +1 -0
  75. package/esm/tabs/CartNav.js +28 -0
  76. package/esm/tabs/NavTab.js +31 -0
  77. package/esm/types/assets.d.js +0 -0
  78. package/esm/types/index.js +1 -0
  79. package/esm/types/merchi_product_form/index.d.js +0 -0
  80. package/esm/types/merchi_sdk_ts/index.d.js +0 -0
  81. package/esm/types/react-redux/index.d.js +0 -0
  82. package/esm/utilities/address.js +457 -0
  83. package/esm/utilities/area.js +297 -0
  84. package/esm/utilities/cart.js +95 -0
  85. package/esm/utilities/company.js +6 -0
  86. package/esm/utilities/cookie.js +156 -0
  87. package/esm/utilities/currency.js +219 -0
  88. package/esm/utilities/customForm.js +57 -0
  89. package/esm/utilities/helpers.js +229 -0
  90. package/esm/utilities/index.js +14 -0
  91. package/esm/utilities/invoice.js +112 -0
  92. package/esm/utilities/job.js +9 -0
  93. package/esm/utilities/local_storage.js +85 -0
  94. package/esm/utilities/product.js +13 -0
  95. package/esm/utilities/shipment.js +11 -0
  96. package/esm/utilities/tabs.js +51 -0
  97. package/esm/utilities/user.js +65 -0
  98. package/esm/utilities/variations.js +58 -0
  99. package/lib/Cart.d.ts +9 -0
  100. package/lib/Cart.js +69 -0
  101. package/lib/CartAlert.d.ts +3 -0
  102. package/lib/CartAlert.js +53 -0
  103. package/lib/CartHeader.d.ts +3 -0
  104. package/lib/CartHeader.js +37 -0
  105. package/lib/CartProvider.d.ts +236 -0
  106. package/lib/CartProvider.js +1107 -0
  107. package/lib/CartTotals.d.ts +7 -0
  108. package/lib/CartTotals.js +96 -0
  109. package/lib/assets/merchi-monster-loader.gif +0 -0
  110. package/lib/assets/merchi-swipe-outline.png +0 -0
  111. package/lib/assets/product-not-found.png +0 -0
  112. package/lib/assets/stripe-payment-secure.png +0 -0
  113. package/lib/buttons/Button.d.ts +11 -0
  114. package/lib/buttons/Button.js +31 -0
  115. package/lib/buttons/ButtonBack.d.ts +6 -0
  116. package/lib/buttons/ButtonBack.js +44 -0
  117. package/lib/buttons/ButtonClearCart.d.ts +3 -0
  118. package/lib/buttons/ButtonClearCart.js +24 -0
  119. package/lib/buttons/ButtonInvoiceDownload.d.ts +3 -0
  120. package/lib/buttons/ButtonInvoiceDownload.js +96 -0
  121. package/lib/buttons/ButtonNext.d.ts +3 -0
  122. package/lib/buttons/ButtonNext.js +48 -0
  123. package/lib/buttons/ButtonNextDynamic.d.ts +3 -0
  124. package/lib/buttons/ButtonNextDynamic.js +28 -0
  125. package/lib/buttons/ButtonOpenCartMerchiCartModal.d.ts +9 -0
  126. package/lib/buttons/ButtonOpenCartMerchiCartModal.js +57 -0
  127. package/lib/buttons/ButtonPay.d.ts +7 -0
  128. package/lib/buttons/ButtonPay.js +35 -0
  129. package/lib/buttons/ButtonShipmentTabNext.d.ts +2 -0
  130. package/lib/buttons/ButtonShipmentTabNext.js +37 -0
  131. package/lib/buttons/index.d.ts +7 -0
  132. package/lib/buttons/index.js +48 -0
  133. package/lib/components/Alert.d.ts +7 -0
  134. package/lib/components/Alert.js +34 -0
  135. package/lib/components/CartBody.d.ts +7 -0
  136. package/lib/components/CartBody.js +22 -0
  137. package/lib/components/CartClient.d.ts +4 -0
  138. package/lib/components/CartClient.js +71 -0
  139. package/lib/components/CartFooter.d.ts +6 -0
  140. package/lib/components/CartFooter.js +20 -0
  141. package/lib/components/CartItemRow.d.ts +7 -0
  142. package/lib/components/CartItemRow.js +236 -0
  143. package/lib/components/CartPaymentSettingsInvalid.d.ts +2 -0
  144. package/lib/components/CartPaymentSettingsInvalid.js +21 -0
  145. package/lib/components/CartShipment.d.ts +6 -0
  146. package/lib/components/CartShipment.js +59 -0
  147. package/lib/components/CartTabContent.d.ts +6 -0
  148. package/lib/components/CartTabContent.js +20 -0
  149. package/lib/components/CartTabPanel.d.ts +7 -0
  150. package/lib/components/CartTabPanel.js +31 -0
  151. package/lib/components/CartTableContainer.d.ts +6 -0
  152. package/lib/components/CartTableContainer.js +20 -0
  153. package/lib/components/CartTitle.d.ts +2 -0
  154. package/lib/components/CartTitle.js +34 -0
  155. package/lib/components/CartTotalsListGroup.d.ts +3 -0
  156. package/lib/components/CartTotalsListGroup.js +78 -0
  157. package/lib/components/Collapse.d.ts +3 -0
  158. package/lib/components/Collapse.js +40 -0
  159. package/lib/components/CustomCartProductForm.d.ts +18 -0
  160. package/lib/components/CustomCartProductForm.js +136 -0
  161. package/lib/components/CustomerCheckoutMethodTabs.d.ts +6 -0
  162. package/lib/components/CustomerCheckoutMethodTabs.js +103 -0
  163. package/lib/components/DiscountInputGroup.d.ts +2 -0
  164. package/lib/components/DiscountInputGroup.js +301 -0
  165. package/lib/components/LoadingTemplate.d.ts +7 -0
  166. package/lib/components/LoadingTemplate.js +30 -0
  167. package/lib/components/NoCartItems.d.ts +3 -0
  168. package/lib/components/NoCartItems.js +27 -0
  169. package/lib/components/ShipmentGroupCard.d.ts +7 -0
  170. package/lib/components/ShipmentGroupCard.js +215 -0
  171. package/lib/components/Table.d.ts +7 -0
  172. package/lib/components/Table.js +19 -0
  173. package/lib/components/containers.d.ts +14 -0
  174. package/lib/components/containers.js +40 -0
  175. package/lib/components/index.d.ts +18 -0
  176. package/lib/components/index.js +133 -0
  177. package/lib/components/product-form-sdk-externals.d.ts +46 -0
  178. package/lib/components/product-form-sdk-externals.js +43 -0
  179. package/lib/forms/FormNewCustomer.d.ts +4 -0
  180. package/lib/forms/FormNewCustomer.js +252 -0
  181. package/lib/forms/FormReturningCustomer.d.ts +3 -0
  182. package/lib/forms/FormReturningCustomer.js +173 -0
  183. package/lib/forms/FormShipmentAddressAndNotes.d.ts +15 -0
  184. package/lib/forms/FormShipmentAddressAndNotes.js +203 -0
  185. package/lib/forms/FormSquarePayment.d.ts +3 -0
  186. package/lib/forms/FormSquarePayment.js +27 -0
  187. package/lib/forms/FormStripePayment.d.ts +3 -0
  188. package/lib/forms/FormStripePayment.js +27 -0
  189. package/lib/forms/FormWhatsappCustomer.d.ts +3 -0
  190. package/lib/forms/FormWhatsappCustomer.js +261 -0
  191. package/lib/forms/InputAcceptUserTermsAndConditions.d.ts +7 -0
  192. package/lib/forms/InputAcceptUserTermsAndConditions.js +41 -0
  193. package/lib/forms/InputError.d.ts +8 -0
  194. package/lib/forms/InputError.js +24 -0
  195. package/lib/forms/InputSelect.d.ts +14 -0
  196. package/lib/forms/InputSelect.js +55 -0
  197. package/lib/forms/InputText.d.ts +12 -0
  198. package/lib/forms/InputText.js +63 -0
  199. package/lib/forms/InputsAddress.d.ts +11 -0
  200. package/lib/forms/InputsAddress.js +485 -0
  201. package/lib/forms/index.d.ts +8 -0
  202. package/lib/forms/index.js +63 -0
  203. package/lib/index.d.ts +13 -0
  204. package/lib/index.js +93 -0
  205. package/lib/modals.d.ts +17 -0
  206. package/lib/modals.js +59 -0
  207. package/lib/panels/PanelCartItems.d.ts +3 -0
  208. package/lib/panels/PanelCartItems.js +56 -0
  209. package/lib/panels/PanelCartShipment.d.ts +3 -0
  210. package/lib/panels/PanelCartShipment.js +72 -0
  211. package/lib/panels/PanelClearCart.d.ts +3 -0
  212. package/lib/panels/PanelClearCart.js +62 -0
  213. package/lib/panels/PanelClientCheckout.d.ts +3 -0
  214. package/lib/panels/PanelClientCheckout.js +88 -0
  215. package/lib/panels/PanelEditCartItem.d.ts +6 -0
  216. package/lib/panels/PanelEditCartItem.js +206 -0
  217. package/lib/panels/PanelPaymentSuccess.d.ts +3 -0
  218. package/lib/panels/PanelPaymentSuccess.js +69 -0
  219. package/lib/panels/index.d.ts +7 -0
  220. package/lib/panels/index.js +48 -0
  221. package/lib/square/SquareCard.d.ts +3 -0
  222. package/lib/square/SquareCard.js +114 -0
  223. package/lib/stripe/LegacyStripeCardForm.d.ts +3 -0
  224. package/lib/stripe/LegacyStripeCardForm.js +166 -0
  225. package/lib/stripe/StripeCardFields.d.ts +15 -0
  226. package/lib/stripe/StripeCardFields.js +135 -0
  227. package/lib/stripe/StripeCardForm.d.ts +2 -0
  228. package/lib/stripe/StripeCardForm.js +42 -0
  229. package/lib/stripe/StripePaymentButtons.d.ts +8 -0
  230. package/lib/stripe/StripePaymentButtons.js +106 -0
  231. package/lib/stripe/actions.d.ts +4 -0
  232. package/lib/stripe/actions.js +200 -0
  233. package/lib/stripe/utils.d.ts +18 -0
  234. package/lib/stripe/utils.js +27 -0
  235. package/lib/styles/globals.css +463 -0
  236. package/lib/styles/globals.css.map +1 -0
  237. package/lib/tabs/CartNav.d.ts +3 -0
  238. package/lib/tabs/CartNav.js +36 -0
  239. package/lib/tabs/NavTab.d.ts +9 -0
  240. package/lib/tabs/NavTab.js +39 -0
  241. package/lib/types/index.d.ts +13 -0
  242. package/lib/types/index.js +1 -0
  243. package/lib/utilities/address.d.ts +30 -0
  244. package/lib/utilities/address.js +468 -0
  245. package/lib/utilities/area.d.ts +77 -0
  246. package/lib/utilities/area.js +328 -0
  247. package/lib/utilities/cart.d.ts +9 -0
  248. package/lib/utilities/cart.js +108 -0
  249. package/lib/utilities/company.d.ts +2 -0
  250. package/lib/utilities/company.js +13 -0
  251. package/lib/utilities/cookie.d.ts +4 -0
  252. package/lib/utilities/cookie.js +165 -0
  253. package/lib/utilities/currency.d.ts +5 -0
  254. package/lib/utilities/currency.js +229 -0
  255. package/lib/utilities/customForm.d.ts +17 -0
  256. package/lib/utilities/customForm.js +64 -0
  257. package/lib/utilities/helpers.d.ts +24 -0
  258. package/lib/utilities/helpers.js +240 -0
  259. package/lib/utilities/index.d.ts +14 -0
  260. package/lib/utilities/index.js +159 -0
  261. package/lib/utilities/invoice.d.ts +3 -0
  262. package/lib/utilities/invoice.js +118 -0
  263. package/lib/utilities/job.d.ts +1 -0
  264. package/lib/utilities/job.js +15 -0
  265. package/lib/utilities/local_storage.d.ts +31 -0
  266. package/lib/utilities/local_storage.js +96 -0
  267. package/lib/utilities/product.d.ts +2 -0
  268. package/lib/utilities/product.js +21 -0
  269. package/lib/utilities/shipment.d.ts +2 -0
  270. package/lib/utilities/shipment.js +18 -0
  271. package/lib/utilities/tabs.d.ts +14 -0
  272. package/lib/utilities/tabs.js +60 -0
  273. package/lib/utilities/user.d.ts +5 -0
  274. package/lib/utilities/user.js +75 -0
  275. package/lib/utilities/variations.d.ts +18 -0
  276. package/lib/utilities/variations.js +66 -0
  277. package/package.json +109 -0
  278. package/src/Cart.tsx +96 -0
  279. package/src/CartAlert.tsx +35 -0
  280. package/src/CartHeader.tsx +28 -0
  281. package/src/CartProvider.tsx +992 -0
  282. package/src/CartTotals.tsx +102 -0
  283. package/src/assets/merchi-monster-loader.gif +0 -0
  284. package/src/assets/merchi-swipe-outline.png +0 -0
  285. package/src/assets/product-not-found.png +0 -0
  286. package/src/assets/stripe-payment-secure.png +0 -0
  287. package/src/buttons/Button.tsx +35 -0
  288. package/src/buttons/ButtonBack.tsx +42 -0
  289. package/src/buttons/ButtonClearCart.tsx +17 -0
  290. package/src/buttons/ButtonInvoiceDownload.tsx +60 -0
  291. package/src/buttons/ButtonNext.tsx +35 -0
  292. package/src/buttons/ButtonNextDynamic.tsx +31 -0
  293. package/src/buttons/ButtonOpenCartMerchiCartModal.tsx +61 -0
  294. package/src/buttons/ButtonPay.tsx +32 -0
  295. package/src/buttons/ButtonShipmentTabNext.tsx +24 -0
  296. package/src/buttons/index.ts +15 -0
  297. package/src/components/Alert.tsx +31 -0
  298. package/src/components/CartBody.tsx +16 -0
  299. package/src/components/CartClient.tsx +52 -0
  300. package/src/components/CartFooter.tsx +15 -0
  301. package/src/components/CartItemRow.tsx +212 -0
  302. package/src/components/CartPaymentSettingsInvalid.tsx +12 -0
  303. package/src/components/CartShipment.tsx +56 -0
  304. package/src/components/CartTabContent.tsx +15 -0
  305. package/src/components/CartTabPanel.tsx +25 -0
  306. package/src/components/CartTableContainer.tsx +15 -0
  307. package/src/components/CartTitle.tsx +22 -0
  308. package/src/components/CartTotalsListGroup.tsx +58 -0
  309. package/src/components/Collapse.tsx +23 -0
  310. package/src/components/CustomCartProductForm.tsx +123 -0
  311. package/src/components/CustomerCheckoutMethodTabs.tsx +106 -0
  312. package/src/components/DiscountInputGroup.tsx +160 -0
  313. package/src/components/LoadingTemplate.tsx +22 -0
  314. package/src/components/NoCartItems.tsx +20 -0
  315. package/src/components/ShipmentGroupCard.tsx +170 -0
  316. package/src/components/Table.tsx +15 -0
  317. package/src/components/containers.tsx +40 -0
  318. package/src/components/index.ts +38 -0
  319. package/src/components/product-form-sdk-externals.ts +67 -0
  320. package/src/forms/FormNewCustomer.tsx +170 -0
  321. package/src/forms/FormReturningCustomer.tsx +117 -0
  322. package/src/forms/FormShipmentAddressAndNotes.tsx +165 -0
  323. package/src/forms/FormSquarePayment.tsx +19 -0
  324. package/src/forms/FormStripePayment.tsx +19 -0
  325. package/src/forms/FormWhatsappCustomer.tsx +179 -0
  326. package/src/forms/InputAcceptUserTermsAndConditions.tsx +43 -0
  327. package/src/forms/InputError.tsx +23 -0
  328. package/src/forms/InputSelect.tsx +58 -0
  329. package/src/forms/InputText.tsx +56 -0
  330. package/src/forms/InputsAddress.tsx +438 -0
  331. package/src/forms/index.ts +18 -0
  332. package/src/index.ts +31 -0
  333. package/src/modals.tsx +65 -0
  334. package/src/panels/PanelCartItems.tsx +56 -0
  335. package/src/panels/PanelCartShipment.tsx +86 -0
  336. package/src/panels/PanelClearCart.tsx +50 -0
  337. package/src/panels/PanelClientCheckout.tsx +102 -0
  338. package/src/panels/PanelEditCartItem.tsx +172 -0
  339. package/src/panels/PanelPaymentSuccess.tsx +66 -0
  340. package/src/panels/index.ts +15 -0
  341. package/src/square/SquareCard.tsx +84 -0
  342. package/src/stripe/LegacyStripeCardForm.tsx +91 -0
  343. package/src/stripe/StripeCardFields.tsx +173 -0
  344. package/src/stripe/StripeCardForm.tsx +18 -0
  345. package/src/stripe/StripePaymentButtons.tsx +117 -0
  346. package/src/stripe/actions.ts +94 -0
  347. package/src/stripe/utils.ts +22 -0
  348. package/src/styles/globals.scss +475 -0
  349. package/src/tabs/CartNav.tsx +18 -0
  350. package/src/tabs/NavTab.tsx +36 -0
  351. package/src/types/assets.d.ts +4 -0
  352. package/src/types/index.ts +15 -0
  353. package/src/types/merchi_product_form/index.d.ts +1 -0
  354. package/src/types/merchi_sdk_ts/index.d.ts +1 -0
  355. package/src/types/react-redux/index.d.ts +0 -0
  356. package/src/utilities/address.ts +463 -0
  357. package/src/utilities/area.ts +359 -0
  358. package/src/utilities/cart.ts +80 -0
  359. package/src/utilities/company.ts +8 -0
  360. package/src/utilities/cookie.ts +58 -0
  361. package/src/utilities/currency.ts +216 -0
  362. package/src/utilities/customForm.ts +71 -0
  363. package/src/utilities/helpers.ts +213 -0
  364. package/src/utilities/index.ts +14 -0
  365. package/src/utilities/invoice.ts +60 -0
  366. package/src/utilities/job.ts +13 -0
  367. package/src/utilities/local_storage.ts +130 -0
  368. package/src/utilities/product.ts +14 -0
  369. package/src/utilities/shipment.ts +11 -0
  370. package/src/utilities/tabs.ts +38 -0
  371. package/src/utilities/user.ts +33 -0
  372. package/src/utilities/variations.ts +80 -0
@@ -0,0 +1,230 @@
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 _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
3
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
4
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
5
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
7
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
8
+ 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; }
9
+ 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; }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ 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); }
13
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
14
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
15
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
16
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
18
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
19
+ 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; } }
20
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
21
+ import * as React from 'react';
22
+ import { cartItemCurrencyAndCost } from '../utilities/currency';
23
+ import { productFeatureImageUrl } from '../utilities/product';
24
+ import { valueString } from '../utilities/variations';
25
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
26
+ import { faCircleNotch, faEdit, faTrashAlt } from '@fortawesome/free-solid-svg-icons';
27
+ import { Button } from '../buttons';
28
+ import { useCartContext } from '../CartProvider';
29
+ import { makeCart } from '../utilities/cart';
30
+ import { cartEmbed } from '../utilities/helpers';
31
+ import { tabIdItem } from '../utilities/tabs';
32
+ import { cartItemsNeedShipment } from '../utilities/shipment';
33
+ import { cartHasShippmentGroupsAndAllHaveSelectedGroups, initTabs, setDisableTab, tabCheckout, tabShipment, tabsWithShipment } from '../utilities/tabs';
34
+ import { getCartCookieToken } from '../utilities/cookie';
35
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
36
+ function VariationListItem(props) {
37
+ var variation = props.variation;
38
+ var field = variation.variationField;
39
+ return /*#__PURE__*/_jsx("li", {
40
+ children: "".concat(field.name, ": ").concat(valueString(variation))
41
+ });
42
+ }
43
+ function VariationList(_ref) {
44
+ var variations = _ref.variations;
45
+ var _useCartContext = useCartContext(),
46
+ classNameVariationsList = _useCartContext.classNameVariationsList;
47
+ return /*#__PURE__*/_jsx("ul", {
48
+ className: classNameVariationsList,
49
+ children: variations.map(function (v, index) {
50
+ return /*#__PURE__*/_jsx(VariationListItem, {
51
+ variation: v
52
+ }, "".concat(index, "-variation"));
53
+ })
54
+ });
55
+ }
56
+ function GroupVariationItems(props) {
57
+ var count = props.count,
58
+ group = props.group;
59
+ return /*#__PURE__*/_jsxs("li", {
60
+ children: ["Group ", count, " Quantity: ", group.quantity, /*#__PURE__*/_jsx(VariationList, {
61
+ variations: group.variations
62
+ })]
63
+ });
64
+ }
65
+ function VariationsGroupsList(_ref2) {
66
+ var groups = _ref2.groups;
67
+ var _useCartContext2 = useCartContext(),
68
+ classNameVariationsList = _useCartContext2.classNameVariationsList;
69
+ return /*#__PURE__*/_jsx("ul", {
70
+ className: classNameVariationsList,
71
+ children: groups.map(function (group, index) {
72
+ return /*#__PURE__*/_jsx(GroupVariationItems, {
73
+ group: group,
74
+ count: index + 1
75
+ }, "".concat(index, "-group-variations"));
76
+ })
77
+ });
78
+ }
79
+ function CartItemRow(_ref3) {
80
+ var cartItem = _ref3.cartItem,
81
+ index = _ref3.index;
82
+ var _useCartContext3 = useCartContext(),
83
+ alertError = _useCartContext3.alertError,
84
+ cart = _useCartContext3.cart,
85
+ domainId = _useCartContext3.domainId,
86
+ setCart = _useCartContext3.setCart,
87
+ classNameBtnLink = _useCartContext3.classNameBtnLink,
88
+ classNameCartItemFeatureImage = _useCartContext3.classNameCartItemFeatureImage,
89
+ classNameCartItemInfo = _useCartContext3.classNameCartItemInfo,
90
+ classNameCartItemInfoCell = _useCartContext3.classNameCartItemInfoCell,
91
+ classNameCartItemInfoCellRight = _useCartContext3.classNameCartItemInfoCellRight,
92
+ classNameCartItemInfoContainer = _useCartContext3.classNameCartItemInfoContainer,
93
+ setActiveTabIndex = _useCartContext3.setActiveTabIndex,
94
+ setCartItem = _useCartContext3.setCartItem,
95
+ tabs = _useCartContext3.tabs,
96
+ setTabs = _useCartContext3.setTabs,
97
+ showCartItemInfo = _useCartContext3.showCartItemInfo;
98
+ var product = cartItem.product,
99
+ quantity = cartItem.quantity,
100
+ variations = cartItem.variations,
101
+ variationsGroups = cartItem.variationsGroups;
102
+ var name = product.name;
103
+ var _React$useState = React.useState(false),
104
+ _React$useState2 = _slicedToArray(_React$useState, 2),
105
+ loading = _React$useState2[0],
106
+ setLoading = _React$useState2[1];
107
+ function actionDeleteCartItem() {
108
+ return _actionDeleteCartItem.apply(this, arguments);
109
+ }
110
+ function _actionDeleteCartItem() {
111
+ _actionDeleteCartItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
112
+ var cartToken, cartEnt, cartItems, r, cartJson, needsShipping, _tabs, _t;
113
+ return _regenerator().w(function (_context) {
114
+ while (1) switch (_context.p = _context.n) {
115
+ case 0:
116
+ setLoading(true);
117
+ _context.n = 1;
118
+ return getCartCookieToken(domainId);
119
+ case 1:
120
+ cartToken = _context.v;
121
+ _context.p = 2;
122
+ cartEnt = makeCart(_objectSpread({}, cart), false, cartToken);
123
+ cartItems = cartEnt.cartItems;
124
+ cartItems.splice(index, 1);
125
+ cartEnt.cartItems = cartItems;
126
+ _context.n = 3;
127
+ return cartEnt.save({
128
+ embed: cartEmbed
129
+ });
130
+ case 3:
131
+ r = _context.v;
132
+ cartJson = r.toJson();
133
+ needsShipping = cartItemsNeedShipment(cartJson);
134
+ setCart(_objectSpread({}, cartJson));
135
+ if (cart.cartItems.length === 0) {
136
+ setTabs(_toConsumableArray(initTabs));
137
+ } else {
138
+ if (needsShipping) {
139
+ setTabs(_toConsumableArray(tabsWithShipment));
140
+ if (cart.cartItems.length) {
141
+ _tabs = _toConsumableArray(tabs);
142
+ _tabs[1] = setDisableTab(tabShipment, false);
143
+ if (cartHasShippmentGroupsAndAllHaveSelectedGroups(cartJson)) {
144
+ _tabs[2] = setDisableTab(tabCheckout, false);
145
+ }
146
+ setTabs(_toConsumableArray(_tabs));
147
+ }
148
+ } else {
149
+ setTabs(_toConsumableArray(initTabs));
150
+ }
151
+ }
152
+ _context.n = 5;
153
+ break;
154
+ case 4:
155
+ _context.p = 4;
156
+ _t = _context.v;
157
+ alertError(_t.errorMessage || _t.message || 'Unable to remove item from cart.');
158
+ case 5:
159
+ _context.p = 5;
160
+ setLoading(false);
161
+ return _context.f(5);
162
+ case 6:
163
+ return _context.a(2);
164
+ }
165
+ }, _callee, null, [[2, 4, 5, 6]]);
166
+ }));
167
+ return _actionDeleteCartItem.apply(this, arguments);
168
+ }
169
+ return /*#__PURE__*/_jsxs("tr", {
170
+ children: [/*#__PURE__*/_jsxs("td", {
171
+ scope: "row",
172
+ className: classNameCartItemInfoCell,
173
+ children: [/*#__PURE__*/_jsx("img", {
174
+ src: productFeatureImageUrl(product),
175
+ alt: name,
176
+ width: "70",
177
+ className: classNameCartItemFeatureImage
178
+ }), showCartItemInfo && /*#__PURE__*/_jsxs("div", {
179
+ className: classNameCartItemInfoContainer,
180
+ children: [/*#__PURE__*/_jsxs("div", {
181
+ className: classNameCartItemInfo,
182
+ children: [/*#__PURE__*/_jsx("h5", {
183
+ style: {
184
+ display: 'inline'
185
+ },
186
+ children: name
187
+ }), variations && /*#__PURE__*/_jsx(VariationList, {
188
+ variations: variations
189
+ })]
190
+ }), /*#__PURE__*/_jsx("div", {
191
+ className: classNameCartItemInfo,
192
+ children: variationsGroups && /*#__PURE__*/_jsx(VariationsGroupsList, {
193
+ groups: variationsGroups
194
+ })
195
+ })]
196
+ })]
197
+ }), /*#__PURE__*/_jsx("td", {
198
+ className: classNameCartItemInfoCellRight,
199
+ children: /*#__PURE__*/_jsx("strong", {
200
+ children: quantity
201
+ })
202
+ }), /*#__PURE__*/_jsx("td", {
203
+ className: classNameCartItemInfoCellRight,
204
+ children: /*#__PURE__*/_jsx("strong", {
205
+ children: cartItemCurrencyAndCost(cartItem)
206
+ })
207
+ }), /*#__PURE__*/_jsxs("td", {
208
+ className: classNameCartItemInfoCellRight,
209
+ children: [/*#__PURE__*/_jsx(Button, {
210
+ className: classNameBtnLink,
211
+ onClick: function onClick() {
212
+ setCartItem(_objectSpread({}, cartItem));
213
+ setActiveTabIndex(tabIdItem);
214
+ },
215
+ children: /*#__PURE__*/_jsx(FontAwesomeIcon, {
216
+ icon: faEdit
217
+ })
218
+ }), /*#__PURE__*/_jsx(Button, {
219
+ className: classNameBtnLink,
220
+ onClick: actionDeleteCartItem //TODO modify delete action
221
+ ,
222
+ children: /*#__PURE__*/_jsx(FontAwesomeIcon, {
223
+ icon: loading ? faCircleNotch : faTrashAlt,
224
+ spin: loading
225
+ })
226
+ })]
227
+ })]
228
+ });
229
+ }
230
+ export default CartItemRow;
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ export default function CartPaymentSettingsInvalid() {
4
+ return /*#__PURE__*/_jsxs("div", {
5
+ className: "merchi-loading-container",
6
+ children: [/*#__PURE__*/_jsx("div", {
7
+ className: "merchi-payment-gateway-inactive"
8
+ }), /*#__PURE__*/_jsx("p", {
9
+ className: "merchi-loading-container-text",
10
+ children: "Payment gateway is currently inactive."
11
+ })]
12
+ });
13
+ }
@@ -0,0 +1,52 @@
1
+ import Title from './CartTitle';
2
+ import { tabIdShipment } from '../utilities/tabs';
3
+ import { addressInOneLine } from '../utilities/address';
4
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5
+ import { faEdit, faTruck } from '@fortawesome/free-solid-svg-icons';
6
+ import { Button } from '../buttons';
7
+ import { useCartContext } from '../CartProvider';
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ function CartShipment(_ref) {
10
+ var cart = _ref.cart;
11
+ var _useCartContext = useCartContext(),
12
+ classNameBtnDefault = _useCartContext.classNameBtnDefault,
13
+ classNameListContainer = _useCartContext.classNameListContainer,
14
+ classNameListUnstyled = _useCartContext.classNameListUnstyled,
15
+ setActiveTabIndex = _useCartContext.setActiveTabIndex;
16
+ var receiverAddress = cart.receiverAddress,
17
+ receiverNotes = cart.receiverNotes;
18
+ var address = receiverAddress ? receiverAddress : null;
19
+ function openShipmentTab() {
20
+ setActiveTabIndex(tabIdShipment);
21
+ }
22
+ return /*#__PURE__*/_jsxs("div", {
23
+ className: classNameListContainer,
24
+ children: [/*#__PURE__*/_jsx(Title, {
25
+ icon: faTruck,
26
+ title: "Ship to"
27
+ }), /*#__PURE__*/_jsxs("ul", {
28
+ className: classNameListUnstyled,
29
+ style: {
30
+ fontSize: '15px',
31
+ marginBottom: '1rem'
32
+ },
33
+ children: [/*#__PURE__*/_jsx("li", {
34
+ children: /*#__PURE__*/_jsx("span", {
35
+ style: {
36
+ display: 'inline-block'
37
+ },
38
+ children: address ? addressInOneLine(address) : 'Shipping address not set'
39
+ })
40
+ }), receiverNotes && /*#__PURE__*/_jsx("li", {
41
+ children: receiverNotes
42
+ })]
43
+ }), /*#__PURE__*/_jsxs(Button, {
44
+ onClick: openShipmentTab,
45
+ className: classNameBtnDefault,
46
+ children: [/*#__PURE__*/_jsx(FontAwesomeIcon, {
47
+ icon: faEdit
48
+ }), " ", address ? ' Change' : ' Set']
49
+ })]
50
+ });
51
+ }
52
+ export default CartShipment;
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { useCartContext } from '../CartProvider';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ export default function CartTabContent(_ref) {
5
+ var children = _ref.children;
6
+ var _useCartContext = useCartContext(),
7
+ classNameCartTab = _useCartContext.classNameCartTab;
8
+ return /*#__PURE__*/_jsx("div", {
9
+ className: classNameCartTab,
10
+ children: children
11
+ });
12
+ }
@@ -0,0 +1,25 @@
1
+ import { useCartContext } from '../CartProvider';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export default function CartTabPanel(_ref) {
4
+ var children = _ref.children,
5
+ tabId = _ref.tabId;
6
+ var _useCartContext = useCartContext(),
7
+ activeTabIndex = _useCartContext.activeTabIndex,
8
+ classNameCartTabPanel = _useCartContext.classNameCartTabPanel,
9
+ tabs = _useCartContext.tabs;
10
+ var currentTabIndex = tabs.findIndex(function (t) {
11
+ return t.tabId === activeTabIndex;
12
+ });
13
+ var activeTabValues = tabs[currentTabIndex];
14
+ var isActive = tabId === -1 && activeTabIndex === -1 || tabId === -2 && activeTabIndex === -2 || !!(activeTabValues && tabId === activeTabValues.tabId);
15
+
16
+ // Unmount inactive tabs so heavy children (payments, product form) stay out of the tree.
17
+ if (!isActive) return null;
18
+ return /*#__PURE__*/_jsx("div", {
19
+ className: classNameCartTabPanel,
20
+ style: {
21
+ display: 'block'
22
+ },
23
+ children: children
24
+ });
25
+ }
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { useCartContext } from '../CartProvider';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ export default function CartTableContainer(_ref) {
5
+ var children = _ref.children;
6
+ var _useCartContext = useCartContext(),
7
+ classNameTableContainer = _useCartContext.classNameTableContainer;
8
+ return /*#__PURE__*/_jsx("div", {
9
+ className: classNameTableContainer,
10
+ children: children
11
+ });
12
+ }
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
+ import { useCartContext } from '../CartProvider';
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ export default function Title(_ref) {
6
+ var icon = _ref.icon,
7
+ title = _ref.title;
8
+ var _useCartContext = useCartContext(),
9
+ classNameCartTitle = _useCartContext.classNameCartTitle;
10
+ return /*#__PURE__*/_jsxs("div", {
11
+ className: classNameCartTitle,
12
+ children: [typeof icon === 'string' ? /*#__PURE__*/_jsx("i", {
13
+ className: "".concat(icon, " fa-2x")
14
+ }) : /*#__PURE__*/_jsx(FontAwesomeIcon, {
15
+ icon: icon,
16
+ size: "2x"
17
+ }), /*#__PURE__*/_jsx("br", {}), /*#__PURE__*/_jsx("div", {
18
+ style: {
19
+ marginTop: '1rem'
20
+ },
21
+ children: /*#__PURE__*/_jsx("strong", {
22
+ children: title
23
+ })
24
+ })]
25
+ });
26
+ }
@@ -0,0 +1,71 @@
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(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : 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
+ import React from 'react';
8
+ import { useCartContext } from '../CartProvider';
9
+ import { cartRequiresShipment } from '../utilities/cart';
10
+ import { CartTotal } from '../CartTotals';
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ function CostsListItem(_ref) {
13
+ var attr = _ref.attr,
14
+ name = _ref.name;
15
+ var _useCartContext = useCartContext(),
16
+ classNameCartTotalItem = _useCartContext.classNameCartTotalItem,
17
+ classNameCartTotalItemPrice = _useCartContext.classNameCartTotalItemPrice,
18
+ classNameListItemCartTotals = _useCartContext.classNameListItemCartTotals;
19
+ return /*#__PURE__*/_jsxs("li", {
20
+ className: classNameListItemCartTotals,
21
+ children: [/*#__PURE__*/_jsx("span", {
22
+ className: classNameCartTotalItem,
23
+ children: name
24
+ }), /*#__PURE__*/_jsx("span", {
25
+ className: classNameCartTotalItemPrice,
26
+ children: /*#__PURE__*/_jsx(CartTotal, {
27
+ attribute: attr
28
+ })
29
+ })]
30
+ });
31
+ }
32
+ function CartTotalsListGroup() {
33
+ var _useCartContext2 = useCartContext(),
34
+ cart = _useCartContext2.cart,
35
+ classNameCartTotaListContainer = _useCartContext2.classNameCartTotaListContainer,
36
+ classNameCartTotalItemPrice = _useCartContext2.classNameCartTotalItemPrice,
37
+ classNameList = _useCartContext2.classNameList,
38
+ classNameListItem = _useCartContext2.classNameListItem;
39
+ var cartItems = cart.cartItems ? cart.cartItems : [];
40
+ return /*#__PURE__*/_jsx("div", {
41
+ className: classNameCartTotaListContainer,
42
+ children: /*#__PURE__*/_jsxs("ul", {
43
+ className: classNameList,
44
+ children: [!!Number(cart.discountedAmount) && /*#__PURE__*/_jsx(CostsListItem, {
45
+ attr: "discountedAmount",
46
+ name: "Discount"
47
+ }), /*#__PURE__*/_jsx(CostsListItem, {
48
+ attr: "cartItemsSubtotalCost",
49
+ name: "Subtotal"
50
+ }), cartRequiresShipment(_objectSpread(_objectSpread({}, cart), {}, {
51
+ cartItems: cartItems
52
+ })) && /*#__PURE__*/_jsx(CostsListItem, {
53
+ attr: "shipmentTotalCost",
54
+ name: "Shipping"
55
+ }), !!cart.taxAmount && /*#__PURE__*/_jsx(CostsListItem, {
56
+ attr: "taxAmount",
57
+ name: "Tax"
58
+ }), /*#__PURE__*/_jsx(CostsListItem, {
59
+ attr: "totalCost",
60
+ name: "Total"
61
+ }), /*#__PURE__*/_jsx("li", {
62
+ className: classNameListItem,
63
+ children: /*#__PURE__*/_jsx("div", {
64
+ className: classNameCartTotalItemPrice,
65
+ children: "Total price includes taxes"
66
+ })
67
+ })]
68
+ })
69
+ });
70
+ }
71
+ export default CartTotalsListGroup;
@@ -0,0 +1,32 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ 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; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ import * as React from 'react';
8
+ import { useState, useRef, useEffect } from 'react';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ function Collapse(_ref) {
11
+ var isOpen = _ref.isOpen,
12
+ children = _ref.children;
13
+ var _useState = useState(isOpen ? 'auto' : '0'),
14
+ _useState2 = _slicedToArray(_useState, 2),
15
+ height = _useState2[0],
16
+ setHeight = _useState2[1];
17
+ var ref = useRef(null);
18
+ useEffect(function () {
19
+ setHeight(isOpen ? "".concat(ref.current.scrollHeight, "px") : '0');
20
+ }, [isOpen]);
21
+ return /*#__PURE__*/_jsx("div", {
22
+ className: "merchi-collapse ".concat(isOpen ? 'show' : ''),
23
+ ref: ref,
24
+ style: {
25
+ transition: 'height 0.35s ease',
26
+ overflow: 'hidden',
27
+ height: height
28
+ },
29
+ children: children
30
+ });
31
+ }
32
+ export default Collapse;
@@ -0,0 +1,128 @@
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(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : 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
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
+ 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; } }
12
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
14
+ import { MerchiProductFormSdkExternals } from './product-form-sdk-externals';
15
+ import { loadFormBundle, publishedFormBundle } from '../utilities/customForm';
16
+ import { LoadingTemplateSm } from './LoadingTemplate';
17
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
18
+ /**
19
+ * Loads a product's published custom form for cart-item edit. On any failure
20
+ * renders `fallback` (the default @merchi/product-form) so the cart stays usable.
21
+ */
22
+ export function CustomCartProductForm(_ref) {
23
+ var _publishedFormBundle$, _publishedFormBundle;
24
+ var product = _ref.product,
25
+ initialJob = _ref.initialJob,
26
+ apiUrl = _ref.apiUrl,
27
+ onSave = _ref.onSave,
28
+ fallback = _ref.fallback,
29
+ onActiveChange = _ref.onActiveChange;
30
+ var _useState = useState(null),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ Loaded = _useState2[0],
33
+ setLoaded = _useState2[1];
34
+ var _useState3 = useState(false),
35
+ _useState4 = _slicedToArray(_useState3, 2),
36
+ failed = _useState4[0],
37
+ setFailed = _useState4[1];
38
+ var _useState5 = useState(true),
39
+ _useState6 = _slicedToArray(_useState5, 2),
40
+ loading = _useState6[0],
41
+ setLoading = _useState6[1];
42
+ var onSaveRef = useRef(onSave);
43
+ onSaveRef.current = onSave;
44
+ var onActiveChangeRef = useRef(onActiveChange);
45
+ onActiveChangeRef.current = onActiveChange;
46
+ var bundleKey = (_publishedFormBundle$ = (_publishedFormBundle = publishedFormBundle(product)) === null || _publishedFormBundle === void 0 ? void 0 : _publishedFormBundle.url) !== null && _publishedFormBundle$ !== void 0 ? _publishedFormBundle$ : '';
47
+ useEffect(function () {
48
+ var active = true;
49
+ setLoaded(null);
50
+ setFailed(false);
51
+ setLoading(true);
52
+ var bundle = publishedFormBundle(product);
53
+ if (!bundle) {
54
+ setFailed(true);
55
+ setLoading(false);
56
+ return;
57
+ }
58
+ var w = window;
59
+ w.React = React;
60
+ w.MerchiProductFormSdk = MerchiProductFormSdkExternals;
61
+ loadFormBundle(bundle).then(function (Component) {
62
+ if (active) {
63
+ setLoaded(function () {
64
+ return Component;
65
+ });
66
+ setLoading(false);
67
+ }
68
+ })["catch"](function (e) {
69
+ console.error('[merchi_cart] custom form load failed', e);
70
+ if (active) {
71
+ setFailed(true);
72
+ setLoading(false);
73
+ }
74
+ });
75
+ return function () {
76
+ active = false;
77
+ };
78
+ }, [product, bundleKey]);
79
+ var props = useMemo(function () {
80
+ try {
81
+ var runtime = MerchiProductFormSdkExternals.createProductFormRuntime({
82
+ apiUrl: apiUrl || '',
83
+ product: product,
84
+ onAddToCart: function onAddToCart(job) {
85
+ var _onSaveRef$current;
86
+ return (_onSaveRef$current = onSaveRef.current) === null || _onSaveRef$current === void 0 ? void 0 : _onSaveRef$current.call(onSaveRef, job);
87
+ }
88
+ });
89
+ return {
90
+ product: product,
91
+ pricing: runtime.pricing,
92
+ actions: runtime.actions,
93
+ helpers: runtime.helpers
94
+ };
95
+ } catch (e) {
96
+ console.error('[merchi_cart] custom form props build failed', e);
97
+ return null;
98
+ }
99
+ }, [product, apiUrl]);
100
+ var isActive = !failed && !loading && !!Loaded && !!props;
101
+ useEffect(function () {
102
+ var _onActiveChangeRef$cu;
103
+ (_onActiveChangeRef$cu = onActiveChangeRef.current) === null || _onActiveChangeRef$cu === void 0 || _onActiveChangeRef$cu.call(onActiveChangeRef, isActive);
104
+ return function () {
105
+ var _onActiveChangeRef$cu2;
106
+ return (_onActiveChangeRef$cu2 = onActiveChangeRef.current) === null || _onActiveChangeRef$cu2 === void 0 ? void 0 : _onActiveChangeRef$cu2.call(onActiveChangeRef, false);
107
+ };
108
+ }, [isActive]);
109
+ if (loading) return /*#__PURE__*/_jsx(LoadingTemplateSm, {});
110
+ if (failed || !Loaded || !props) return /*#__PURE__*/_jsx(_Fragment, {
111
+ children: fallback
112
+ });
113
+ var Shell = MerchiProductFormSdkExternals.ProductFormShell;
114
+ return /*#__PURE__*/_jsx(_Fragment, {
115
+ children: Shell ? /*#__PURE__*/_jsx(Shell, {
116
+ product: props.product,
117
+ pricing: props.pricing,
118
+ actions: props.actions,
119
+ helpers: props.helpers,
120
+ initialJob: initialJob,
121
+ actionLabels: {
122
+ addToCart: 'Save'
123
+ },
124
+ children: /*#__PURE__*/_jsx(Loaded, _objectSpread({}, props))
125
+ }) : /*#__PURE__*/_jsx(Loaded, _objectSpread({}, props))
126
+ });
127
+ }
128
+ export default CustomCartProductForm;