@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.
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/esm/Cart.js +62 -0
- package/esm/CartAlert.js +47 -0
- package/esm/CartHeader.js +29 -0
- package/esm/CartProvider.js +1101 -0
- package/esm/CartTotals.js +89 -0
- package/esm/assets/merchi-monster-loader.gif +0 -0
- package/esm/assets/merchi-swipe-outline.png +0 -0
- package/esm/assets/product-not-found.png +0 -0
- package/esm/assets/stripe-payment-secure.png +0 -0
- package/esm/buttons/Button.js +23 -0
- package/esm/buttons/ButtonBack.js +35 -0
- package/esm/buttons/ButtonClearCart.js +17 -0
- package/esm/buttons/ButtonInvoiceDownload.js +88 -0
- package/esm/buttons/ButtonNext.js +39 -0
- package/esm/buttons/ButtonNextDynamic.js +19 -0
- package/esm/buttons/ButtonOpenCartMerchiCartModal.js +47 -0
- package/esm/buttons/ButtonPay.js +26 -0
- package/esm/buttons/ButtonShipmentTabNext.js +28 -0
- package/esm/buttons/index.js +7 -0
- package/esm/components/Alert.js +26 -0
- package/esm/components/CartBody.js +14 -0
- package/esm/components/CartClient.js +62 -0
- package/esm/components/CartFooter.js +12 -0
- package/esm/components/CartItemRow.js +230 -0
- package/esm/components/CartPaymentSettingsInvalid.js +13 -0
- package/esm/components/CartShipment.js +52 -0
- package/esm/components/CartTabContent.js +12 -0
- package/esm/components/CartTabPanel.js +25 -0
- package/esm/components/CartTableContainer.js +12 -0
- package/esm/components/CartTitle.js +26 -0
- package/esm/components/CartTotalsListGroup.js +71 -0
- package/esm/components/Collapse.js +32 -0
- package/esm/components/CustomCartProductForm.js +128 -0
- package/esm/components/CustomerCheckoutMethodTabs.js +94 -0
- package/esm/components/DiscountInputGroup.js +293 -0
- package/esm/components/LoadingTemplate.js +23 -0
- package/esm/components/NoCartItems.js +20 -0
- package/esm/components/ShipmentGroupCard.js +207 -0
- package/esm/components/Table.js +13 -0
- package/esm/components/containers.js +31 -0
- package/esm/components/index.js +18 -0
- package/esm/components/product-form-sdk-externals.js +36 -0
- package/esm/forms/FormNewCustomer.js +243 -0
- package/esm/forms/FormReturningCustomer.js +165 -0
- package/esm/forms/FormShipmentAddressAndNotes.js +195 -0
- package/esm/forms/FormSquarePayment.js +19 -0
- package/esm/forms/FormStripePayment.js +19 -0
- package/esm/forms/FormWhatsappCustomer.js +253 -0
- package/esm/forms/InputAcceptUserTermsAndConditions.js +35 -0
- package/esm/forms/InputError.js +16 -0
- package/esm/forms/InputSelect.js +48 -0
- package/esm/forms/InputText.js +56 -0
- package/esm/forms/InputsAddress.js +476 -0
- package/esm/forms/index.js +8 -0
- package/esm/index.js +13 -0
- package/esm/modals.js +51 -0
- package/esm/panels/PanelCartItems.js +49 -0
- package/esm/panels/PanelCartShipment.js +66 -0
- package/esm/panels/PanelClearCart.js +56 -0
- package/esm/panels/PanelClientCheckout.js +81 -0
- package/esm/panels/PanelEditCartItem.js +199 -0
- package/esm/panels/PanelPaymentSuccess.js +63 -0
- package/esm/panels/index.js +7 -0
- package/esm/square/SquareCard.js +106 -0
- package/esm/stripe/LegacyStripeCardForm.js +157 -0
- package/esm/stripe/StripeCardFields.js +126 -0
- package/esm/stripe/StripeCardForm.js +33 -0
- package/esm/stripe/StripePaymentButtons.js +98 -0
- package/esm/stripe/actions.js +192 -0
- package/esm/stripe/utils.js +20 -0
- package/esm/styles/globals.css +463 -0
- package/esm/styles/globals.css.map +1 -0
- package/esm/tabs/CartNav.js +28 -0
- package/esm/tabs/NavTab.js +31 -0
- package/esm/types/assets.d.js +0 -0
- package/esm/types/index.js +1 -0
- package/esm/types/merchi_product_form/index.d.js +0 -0
- package/esm/types/merchi_sdk_ts/index.d.js +0 -0
- package/esm/types/react-redux/index.d.js +0 -0
- package/esm/utilities/address.js +457 -0
- package/esm/utilities/area.js +297 -0
- package/esm/utilities/cart.js +95 -0
- package/esm/utilities/company.js +6 -0
- package/esm/utilities/cookie.js +156 -0
- package/esm/utilities/currency.js +219 -0
- package/esm/utilities/customForm.js +57 -0
- package/esm/utilities/helpers.js +229 -0
- package/esm/utilities/index.js +14 -0
- package/esm/utilities/invoice.js +112 -0
- package/esm/utilities/job.js +9 -0
- package/esm/utilities/local_storage.js +85 -0
- package/esm/utilities/product.js +13 -0
- package/esm/utilities/shipment.js +11 -0
- package/esm/utilities/tabs.js +51 -0
- package/esm/utilities/user.js +65 -0
- package/esm/utilities/variations.js +58 -0
- package/lib/Cart.d.ts +9 -0
- package/lib/Cart.js +69 -0
- package/lib/CartAlert.d.ts +3 -0
- package/lib/CartAlert.js +53 -0
- package/lib/CartHeader.d.ts +3 -0
- package/lib/CartHeader.js +37 -0
- package/lib/CartProvider.d.ts +236 -0
- package/lib/CartProvider.js +1107 -0
- package/lib/CartTotals.d.ts +7 -0
- package/lib/CartTotals.js +96 -0
- package/lib/assets/merchi-monster-loader.gif +0 -0
- package/lib/assets/merchi-swipe-outline.png +0 -0
- package/lib/assets/product-not-found.png +0 -0
- package/lib/assets/stripe-payment-secure.png +0 -0
- package/lib/buttons/Button.d.ts +11 -0
- package/lib/buttons/Button.js +31 -0
- package/lib/buttons/ButtonBack.d.ts +6 -0
- package/lib/buttons/ButtonBack.js +44 -0
- package/lib/buttons/ButtonClearCart.d.ts +3 -0
- package/lib/buttons/ButtonClearCart.js +24 -0
- package/lib/buttons/ButtonInvoiceDownload.d.ts +3 -0
- package/lib/buttons/ButtonInvoiceDownload.js +96 -0
- package/lib/buttons/ButtonNext.d.ts +3 -0
- package/lib/buttons/ButtonNext.js +48 -0
- package/lib/buttons/ButtonNextDynamic.d.ts +3 -0
- package/lib/buttons/ButtonNextDynamic.js +28 -0
- package/lib/buttons/ButtonOpenCartMerchiCartModal.d.ts +9 -0
- package/lib/buttons/ButtonOpenCartMerchiCartModal.js +57 -0
- package/lib/buttons/ButtonPay.d.ts +7 -0
- package/lib/buttons/ButtonPay.js +35 -0
- package/lib/buttons/ButtonShipmentTabNext.d.ts +2 -0
- package/lib/buttons/ButtonShipmentTabNext.js +37 -0
- package/lib/buttons/index.d.ts +7 -0
- package/lib/buttons/index.js +48 -0
- package/lib/components/Alert.d.ts +7 -0
- package/lib/components/Alert.js +34 -0
- package/lib/components/CartBody.d.ts +7 -0
- package/lib/components/CartBody.js +22 -0
- package/lib/components/CartClient.d.ts +4 -0
- package/lib/components/CartClient.js +71 -0
- package/lib/components/CartFooter.d.ts +6 -0
- package/lib/components/CartFooter.js +20 -0
- package/lib/components/CartItemRow.d.ts +7 -0
- package/lib/components/CartItemRow.js +236 -0
- package/lib/components/CartPaymentSettingsInvalid.d.ts +2 -0
- package/lib/components/CartPaymentSettingsInvalid.js +21 -0
- package/lib/components/CartShipment.d.ts +6 -0
- package/lib/components/CartShipment.js +59 -0
- package/lib/components/CartTabContent.d.ts +6 -0
- package/lib/components/CartTabContent.js +20 -0
- package/lib/components/CartTabPanel.d.ts +7 -0
- package/lib/components/CartTabPanel.js +31 -0
- package/lib/components/CartTableContainer.d.ts +6 -0
- package/lib/components/CartTableContainer.js +20 -0
- package/lib/components/CartTitle.d.ts +2 -0
- package/lib/components/CartTitle.js +34 -0
- package/lib/components/CartTotalsListGroup.d.ts +3 -0
- package/lib/components/CartTotalsListGroup.js +78 -0
- package/lib/components/Collapse.d.ts +3 -0
- package/lib/components/Collapse.js +40 -0
- package/lib/components/CustomCartProductForm.d.ts +18 -0
- package/lib/components/CustomCartProductForm.js +136 -0
- package/lib/components/CustomerCheckoutMethodTabs.d.ts +6 -0
- package/lib/components/CustomerCheckoutMethodTabs.js +103 -0
- package/lib/components/DiscountInputGroup.d.ts +2 -0
- package/lib/components/DiscountInputGroup.js +301 -0
- package/lib/components/LoadingTemplate.d.ts +7 -0
- package/lib/components/LoadingTemplate.js +30 -0
- package/lib/components/NoCartItems.d.ts +3 -0
- package/lib/components/NoCartItems.js +27 -0
- package/lib/components/ShipmentGroupCard.d.ts +7 -0
- package/lib/components/ShipmentGroupCard.js +215 -0
- package/lib/components/Table.d.ts +7 -0
- package/lib/components/Table.js +19 -0
- package/lib/components/containers.d.ts +14 -0
- package/lib/components/containers.js +40 -0
- package/lib/components/index.d.ts +18 -0
- package/lib/components/index.js +133 -0
- package/lib/components/product-form-sdk-externals.d.ts +46 -0
- package/lib/components/product-form-sdk-externals.js +43 -0
- package/lib/forms/FormNewCustomer.d.ts +4 -0
- package/lib/forms/FormNewCustomer.js +252 -0
- package/lib/forms/FormReturningCustomer.d.ts +3 -0
- package/lib/forms/FormReturningCustomer.js +173 -0
- package/lib/forms/FormShipmentAddressAndNotes.d.ts +15 -0
- package/lib/forms/FormShipmentAddressAndNotes.js +203 -0
- package/lib/forms/FormSquarePayment.d.ts +3 -0
- package/lib/forms/FormSquarePayment.js +27 -0
- package/lib/forms/FormStripePayment.d.ts +3 -0
- package/lib/forms/FormStripePayment.js +27 -0
- package/lib/forms/FormWhatsappCustomer.d.ts +3 -0
- package/lib/forms/FormWhatsappCustomer.js +261 -0
- package/lib/forms/InputAcceptUserTermsAndConditions.d.ts +7 -0
- package/lib/forms/InputAcceptUserTermsAndConditions.js +41 -0
- package/lib/forms/InputError.d.ts +8 -0
- package/lib/forms/InputError.js +24 -0
- package/lib/forms/InputSelect.d.ts +14 -0
- package/lib/forms/InputSelect.js +55 -0
- package/lib/forms/InputText.d.ts +12 -0
- package/lib/forms/InputText.js +63 -0
- package/lib/forms/InputsAddress.d.ts +11 -0
- package/lib/forms/InputsAddress.js +485 -0
- package/lib/forms/index.d.ts +8 -0
- package/lib/forms/index.js +63 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +93 -0
- package/lib/modals.d.ts +17 -0
- package/lib/modals.js +59 -0
- package/lib/panels/PanelCartItems.d.ts +3 -0
- package/lib/panels/PanelCartItems.js +56 -0
- package/lib/panels/PanelCartShipment.d.ts +3 -0
- package/lib/panels/PanelCartShipment.js +72 -0
- package/lib/panels/PanelClearCart.d.ts +3 -0
- package/lib/panels/PanelClearCart.js +62 -0
- package/lib/panels/PanelClientCheckout.d.ts +3 -0
- package/lib/panels/PanelClientCheckout.js +88 -0
- package/lib/panels/PanelEditCartItem.d.ts +6 -0
- package/lib/panels/PanelEditCartItem.js +206 -0
- package/lib/panels/PanelPaymentSuccess.d.ts +3 -0
- package/lib/panels/PanelPaymentSuccess.js +69 -0
- package/lib/panels/index.d.ts +7 -0
- package/lib/panels/index.js +48 -0
- package/lib/square/SquareCard.d.ts +3 -0
- package/lib/square/SquareCard.js +114 -0
- package/lib/stripe/LegacyStripeCardForm.d.ts +3 -0
- package/lib/stripe/LegacyStripeCardForm.js +166 -0
- package/lib/stripe/StripeCardFields.d.ts +15 -0
- package/lib/stripe/StripeCardFields.js +135 -0
- package/lib/stripe/StripeCardForm.d.ts +2 -0
- package/lib/stripe/StripeCardForm.js +42 -0
- package/lib/stripe/StripePaymentButtons.d.ts +8 -0
- package/lib/stripe/StripePaymentButtons.js +106 -0
- package/lib/stripe/actions.d.ts +4 -0
- package/lib/stripe/actions.js +200 -0
- package/lib/stripe/utils.d.ts +18 -0
- package/lib/stripe/utils.js +27 -0
- package/lib/styles/globals.css +463 -0
- package/lib/styles/globals.css.map +1 -0
- package/lib/tabs/CartNav.d.ts +3 -0
- package/lib/tabs/CartNav.js +36 -0
- package/lib/tabs/NavTab.d.ts +9 -0
- package/lib/tabs/NavTab.js +39 -0
- package/lib/types/index.d.ts +13 -0
- package/lib/types/index.js +1 -0
- package/lib/utilities/address.d.ts +30 -0
- package/lib/utilities/address.js +468 -0
- package/lib/utilities/area.d.ts +77 -0
- package/lib/utilities/area.js +328 -0
- package/lib/utilities/cart.d.ts +9 -0
- package/lib/utilities/cart.js +108 -0
- package/lib/utilities/company.d.ts +2 -0
- package/lib/utilities/company.js +13 -0
- package/lib/utilities/cookie.d.ts +4 -0
- package/lib/utilities/cookie.js +165 -0
- package/lib/utilities/currency.d.ts +5 -0
- package/lib/utilities/currency.js +229 -0
- package/lib/utilities/customForm.d.ts +17 -0
- package/lib/utilities/customForm.js +64 -0
- package/lib/utilities/helpers.d.ts +24 -0
- package/lib/utilities/helpers.js +240 -0
- package/lib/utilities/index.d.ts +14 -0
- package/lib/utilities/index.js +159 -0
- package/lib/utilities/invoice.d.ts +3 -0
- package/lib/utilities/invoice.js +118 -0
- package/lib/utilities/job.d.ts +1 -0
- package/lib/utilities/job.js +15 -0
- package/lib/utilities/local_storage.d.ts +31 -0
- package/lib/utilities/local_storage.js +96 -0
- package/lib/utilities/product.d.ts +2 -0
- package/lib/utilities/product.js +21 -0
- package/lib/utilities/shipment.d.ts +2 -0
- package/lib/utilities/shipment.js +18 -0
- package/lib/utilities/tabs.d.ts +14 -0
- package/lib/utilities/tabs.js +60 -0
- package/lib/utilities/user.d.ts +5 -0
- package/lib/utilities/user.js +75 -0
- package/lib/utilities/variations.d.ts +18 -0
- package/lib/utilities/variations.js +66 -0
- package/package.json +109 -0
- package/src/Cart.tsx +96 -0
- package/src/CartAlert.tsx +35 -0
- package/src/CartHeader.tsx +28 -0
- package/src/CartProvider.tsx +992 -0
- package/src/CartTotals.tsx +102 -0
- package/src/assets/merchi-monster-loader.gif +0 -0
- package/src/assets/merchi-swipe-outline.png +0 -0
- package/src/assets/product-not-found.png +0 -0
- package/src/assets/stripe-payment-secure.png +0 -0
- package/src/buttons/Button.tsx +35 -0
- package/src/buttons/ButtonBack.tsx +42 -0
- package/src/buttons/ButtonClearCart.tsx +17 -0
- package/src/buttons/ButtonInvoiceDownload.tsx +60 -0
- package/src/buttons/ButtonNext.tsx +35 -0
- package/src/buttons/ButtonNextDynamic.tsx +31 -0
- package/src/buttons/ButtonOpenCartMerchiCartModal.tsx +61 -0
- package/src/buttons/ButtonPay.tsx +32 -0
- package/src/buttons/ButtonShipmentTabNext.tsx +24 -0
- package/src/buttons/index.ts +15 -0
- package/src/components/Alert.tsx +31 -0
- package/src/components/CartBody.tsx +16 -0
- package/src/components/CartClient.tsx +52 -0
- package/src/components/CartFooter.tsx +15 -0
- package/src/components/CartItemRow.tsx +212 -0
- package/src/components/CartPaymentSettingsInvalid.tsx +12 -0
- package/src/components/CartShipment.tsx +56 -0
- package/src/components/CartTabContent.tsx +15 -0
- package/src/components/CartTabPanel.tsx +25 -0
- package/src/components/CartTableContainer.tsx +15 -0
- package/src/components/CartTitle.tsx +22 -0
- package/src/components/CartTotalsListGroup.tsx +58 -0
- package/src/components/Collapse.tsx +23 -0
- package/src/components/CustomCartProductForm.tsx +123 -0
- package/src/components/CustomerCheckoutMethodTabs.tsx +106 -0
- package/src/components/DiscountInputGroup.tsx +160 -0
- package/src/components/LoadingTemplate.tsx +22 -0
- package/src/components/NoCartItems.tsx +20 -0
- package/src/components/ShipmentGroupCard.tsx +170 -0
- package/src/components/Table.tsx +15 -0
- package/src/components/containers.tsx +40 -0
- package/src/components/index.ts +38 -0
- package/src/components/product-form-sdk-externals.ts +67 -0
- package/src/forms/FormNewCustomer.tsx +170 -0
- package/src/forms/FormReturningCustomer.tsx +117 -0
- package/src/forms/FormShipmentAddressAndNotes.tsx +165 -0
- package/src/forms/FormSquarePayment.tsx +19 -0
- package/src/forms/FormStripePayment.tsx +19 -0
- package/src/forms/FormWhatsappCustomer.tsx +179 -0
- package/src/forms/InputAcceptUserTermsAndConditions.tsx +43 -0
- package/src/forms/InputError.tsx +23 -0
- package/src/forms/InputSelect.tsx +58 -0
- package/src/forms/InputText.tsx +56 -0
- package/src/forms/InputsAddress.tsx +438 -0
- package/src/forms/index.ts +18 -0
- package/src/index.ts +31 -0
- package/src/modals.tsx +65 -0
- package/src/panels/PanelCartItems.tsx +56 -0
- package/src/panels/PanelCartShipment.tsx +86 -0
- package/src/panels/PanelClearCart.tsx +50 -0
- package/src/panels/PanelClientCheckout.tsx +102 -0
- package/src/panels/PanelEditCartItem.tsx +172 -0
- package/src/panels/PanelPaymentSuccess.tsx +66 -0
- package/src/panels/index.ts +15 -0
- package/src/square/SquareCard.tsx +84 -0
- package/src/stripe/LegacyStripeCardForm.tsx +91 -0
- package/src/stripe/StripeCardFields.tsx +173 -0
- package/src/stripe/StripeCardForm.tsx +18 -0
- package/src/stripe/StripePaymentButtons.tsx +117 -0
- package/src/stripe/actions.ts +94 -0
- package/src/stripe/utils.ts +22 -0
- package/src/styles/globals.scss +475 -0
- package/src/tabs/CartNav.tsx +18 -0
- package/src/tabs/NavTab.tsx +36 -0
- package/src/types/assets.d.ts +4 -0
- package/src/types/index.ts +15 -0
- package/src/types/merchi_product_form/index.d.ts +1 -0
- package/src/types/merchi_sdk_ts/index.d.ts +1 -0
- package/src/types/react-redux/index.d.ts +0 -0
- package/src/utilities/address.ts +463 -0
- package/src/utilities/area.ts +359 -0
- package/src/utilities/cart.ts +80 -0
- package/src/utilities/company.ts +8 -0
- package/src/utilities/cookie.ts +58 -0
- package/src/utilities/currency.ts +216 -0
- package/src/utilities/customForm.ts +71 -0
- package/src/utilities/helpers.ts +213 -0
- package/src/utilities/index.ts +14 -0
- package/src/utilities/invoice.ts +60 -0
- package/src/utilities/job.ts +13 -0
- package/src/utilities/local_storage.ts +130 -0
- package/src/utilities/product.ts +14 -0
- package/src/utilities/shipment.ts +11 -0
- package/src/utilities/tabs.ts +38 -0
- package/src/utilities/user.ts +33 -0
- package/src/utilities/variations.ts +80 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = CartTabPanel;
|
|
7
|
+
var _CartProvider = require("../CartProvider");
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function CartTabPanel(_ref) {
|
|
10
|
+
var children = _ref.children,
|
|
11
|
+
tabId = _ref.tabId;
|
|
12
|
+
var _useCartContext = (0, _CartProvider.useCartContext)(),
|
|
13
|
+
activeTabIndex = _useCartContext.activeTabIndex,
|
|
14
|
+
classNameCartTabPanel = _useCartContext.classNameCartTabPanel,
|
|
15
|
+
tabs = _useCartContext.tabs;
|
|
16
|
+
var currentTabIndex = tabs.findIndex(function (t) {
|
|
17
|
+
return t.tabId === activeTabIndex;
|
|
18
|
+
});
|
|
19
|
+
var activeTabValues = tabs[currentTabIndex];
|
|
20
|
+
var isActive = tabId === -1 && activeTabIndex === -1 || tabId === -2 && activeTabIndex === -2 || !!(activeTabValues && tabId === activeTabValues.tabId);
|
|
21
|
+
|
|
22
|
+
// Unmount inactive tabs so heavy children (payments, product form) stay out of the tree.
|
|
23
|
+
if (!isActive) return null;
|
|
24
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
25
|
+
className: classNameCartTabPanel,
|
|
26
|
+
style: {
|
|
27
|
+
display: 'block'
|
|
28
|
+
},
|
|
29
|
+
children: children
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = CartTableContainer;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _CartProvider = require("../CartProvider");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
|
+
function CartTableContainer(_ref) {
|
|
13
|
+
var children = _ref.children;
|
|
14
|
+
var _useCartContext = (0, _CartProvider.useCartContext)(),
|
|
15
|
+
classNameTableContainer = _useCartContext.classNameTableContainer;
|
|
16
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
17
|
+
className: classNameTableContainer,
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = Title;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactFontawesome = require("@fortawesome/react-fontawesome");
|
|
10
|
+
var _CartProvider = require("../CartProvider");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
13
|
+
function Title(_ref) {
|
|
14
|
+
var icon = _ref.icon,
|
|
15
|
+
title = _ref.title;
|
|
16
|
+
var _useCartContext = (0, _CartProvider.useCartContext)(),
|
|
17
|
+
classNameCartTitle = _useCartContext.classNameCartTitle;
|
|
18
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
19
|
+
className: classNameCartTitle,
|
|
20
|
+
children: [typeof icon === 'string' ? /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
21
|
+
className: "".concat(icon, " fa-2x")
|
|
22
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
23
|
+
icon: icon,
|
|
24
|
+
size: "2x"
|
|
25
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
26
|
+
style: {
|
|
27
|
+
marginTop: '1rem'
|
|
28
|
+
},
|
|
29
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
30
|
+
children: title
|
|
31
|
+
})
|
|
32
|
+
})]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _CartProvider = require("../CartProvider");
|
|
9
|
+
var _cart = require("../utilities/cart");
|
|
10
|
+
var _CartTotals = require("../CartTotals");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
|
+
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); }
|
|
19
|
+
function CostsListItem(_ref) {
|
|
20
|
+
var attr = _ref.attr,
|
|
21
|
+
name = _ref.name;
|
|
22
|
+
var _useCartContext = (0, _CartProvider.useCartContext)(),
|
|
23
|
+
classNameCartTotalItem = _useCartContext.classNameCartTotalItem,
|
|
24
|
+
classNameCartTotalItemPrice = _useCartContext.classNameCartTotalItemPrice,
|
|
25
|
+
classNameListItemCartTotals = _useCartContext.classNameListItemCartTotals;
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
27
|
+
className: classNameListItemCartTotals,
|
|
28
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
29
|
+
className: classNameCartTotalItem,
|
|
30
|
+
children: name
|
|
31
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
32
|
+
className: classNameCartTotalItemPrice,
|
|
33
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CartTotals.CartTotal, {
|
|
34
|
+
attribute: attr
|
|
35
|
+
})
|
|
36
|
+
})]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function CartTotalsListGroup() {
|
|
40
|
+
var _useCartContext2 = (0, _CartProvider.useCartContext)(),
|
|
41
|
+
cart = _useCartContext2.cart,
|
|
42
|
+
classNameCartTotaListContainer = _useCartContext2.classNameCartTotaListContainer,
|
|
43
|
+
classNameCartTotalItemPrice = _useCartContext2.classNameCartTotalItemPrice,
|
|
44
|
+
classNameList = _useCartContext2.classNameList,
|
|
45
|
+
classNameListItem = _useCartContext2.classNameListItem;
|
|
46
|
+
var cartItems = cart.cartItems ? cart.cartItems : [];
|
|
47
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
48
|
+
className: classNameCartTotaListContainer,
|
|
49
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", {
|
|
50
|
+
className: classNameList,
|
|
51
|
+
children: [!!Number(cart.discountedAmount) && /*#__PURE__*/(0, _jsxRuntime.jsx)(CostsListItem, {
|
|
52
|
+
attr: "discountedAmount",
|
|
53
|
+
name: "Discount"
|
|
54
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(CostsListItem, {
|
|
55
|
+
attr: "cartItemsSubtotalCost",
|
|
56
|
+
name: "Subtotal"
|
|
57
|
+
}), (0, _cart.cartRequiresShipment)(_objectSpread(_objectSpread({}, cart), {}, {
|
|
58
|
+
cartItems: cartItems
|
|
59
|
+
})) && /*#__PURE__*/(0, _jsxRuntime.jsx)(CostsListItem, {
|
|
60
|
+
attr: "shipmentTotalCost",
|
|
61
|
+
name: "Shipping"
|
|
62
|
+
}), !!cart.taxAmount && /*#__PURE__*/(0, _jsxRuntime.jsx)(CostsListItem, {
|
|
63
|
+
attr: "taxAmount",
|
|
64
|
+
name: "Tax"
|
|
65
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(CostsListItem, {
|
|
66
|
+
attr: "totalCost",
|
|
67
|
+
name: "Total"
|
|
68
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
69
|
+
className: classNameListItem,
|
|
70
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
71
|
+
className: classNameCartTotalItemPrice,
|
|
72
|
+
children: "Total price includes taxes"
|
|
73
|
+
})
|
|
74
|
+
})]
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
var _default = exports["default"] = CartTotalsListGroup;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var React = _react;
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
13
|
+
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."); }
|
|
14
|
+
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; } }
|
|
15
|
+
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; }
|
|
16
|
+
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; } }
|
|
17
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
18
|
+
function Collapse(_ref) {
|
|
19
|
+
var isOpen = _ref.isOpen,
|
|
20
|
+
children = _ref.children;
|
|
21
|
+
var _useState = (0, _react.useState)(isOpen ? 'auto' : '0'),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
height = _useState2[0],
|
|
24
|
+
setHeight = _useState2[1];
|
|
25
|
+
var ref = (0, _react.useRef)(null);
|
|
26
|
+
(0, _react.useEffect)(function () {
|
|
27
|
+
setHeight(isOpen ? "".concat(ref.current.scrollHeight, "px") : '0');
|
|
28
|
+
}, [isOpen]);
|
|
29
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
30
|
+
className: "merchi-collapse ".concat(isOpen ? 'show' : ''),
|
|
31
|
+
ref: ref,
|
|
32
|
+
style: {
|
|
33
|
+
transition: 'height 0.35s ease',
|
|
34
|
+
overflow: 'hidden',
|
|
35
|
+
height: height
|
|
36
|
+
},
|
|
37
|
+
children: children
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
var _default = exports["default"] = Collapse;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
product: any;
|
|
4
|
+
/** Current cart item used to hydrate quantity / selections. */
|
|
5
|
+
initialJob: any;
|
|
6
|
+
apiUrl?: string;
|
|
7
|
+
onSave: (job: any) => void;
|
|
8
|
+
/** Rendered when there is no published bundle or load/runtime fails. */
|
|
9
|
+
fallback: React.ReactNode;
|
|
10
|
+
/** Notifies the host when the custom form is actively rendering. */
|
|
11
|
+
onActiveChange?: (active: boolean) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Loads a product's published custom form for cart-item edit. On any failure
|
|
15
|
+
* renders `fallback` (the default @merchi/product-form) so the cart stays usable.
|
|
16
|
+
*/
|
|
17
|
+
export declare function CustomCartProductForm({ product, initialJob, apiUrl, onSave, fallback, onActiveChange, }: Props): React.JSX.Element;
|
|
18
|
+
export default CustomCartProductForm;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.CustomCartProductForm = CustomCartProductForm;
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _productFormSdkExternals = require("./product-form-sdk-externals");
|
|
11
|
+
var _customForm = require("../utilities/customForm");
|
|
12
|
+
var _LoadingTemplate = require("./LoadingTemplate");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
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; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
19
|
+
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); }
|
|
20
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
21
|
+
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."); }
|
|
22
|
+
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; } }
|
|
23
|
+
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; }
|
|
24
|
+
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; } }
|
|
25
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
26
|
+
/**
|
|
27
|
+
* Loads a product's published custom form for cart-item edit. On any failure
|
|
28
|
+
* renders `fallback` (the default @merchi/product-form) so the cart stays usable.
|
|
29
|
+
*/
|
|
30
|
+
function CustomCartProductForm(_ref) {
|
|
31
|
+
var _publishedFormBundle$, _publishedFormBundle;
|
|
32
|
+
var product = _ref.product,
|
|
33
|
+
initialJob = _ref.initialJob,
|
|
34
|
+
apiUrl = _ref.apiUrl,
|
|
35
|
+
onSave = _ref.onSave,
|
|
36
|
+
fallback = _ref.fallback,
|
|
37
|
+
onActiveChange = _ref.onActiveChange;
|
|
38
|
+
var _useState = (0, _react.useState)(null),
|
|
39
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
+
Loaded = _useState2[0],
|
|
41
|
+
setLoaded = _useState2[1];
|
|
42
|
+
var _useState3 = (0, _react.useState)(false),
|
|
43
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
44
|
+
failed = _useState4[0],
|
|
45
|
+
setFailed = _useState4[1];
|
|
46
|
+
var _useState5 = (0, _react.useState)(true),
|
|
47
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
48
|
+
loading = _useState6[0],
|
|
49
|
+
setLoading = _useState6[1];
|
|
50
|
+
var onSaveRef = (0, _react.useRef)(onSave);
|
|
51
|
+
onSaveRef.current = onSave;
|
|
52
|
+
var onActiveChangeRef = (0, _react.useRef)(onActiveChange);
|
|
53
|
+
onActiveChangeRef.current = onActiveChange;
|
|
54
|
+
var bundleKey = (_publishedFormBundle$ = (_publishedFormBundle = (0, _customForm.publishedFormBundle)(product)) === null || _publishedFormBundle === void 0 ? void 0 : _publishedFormBundle.url) !== null && _publishedFormBundle$ !== void 0 ? _publishedFormBundle$ : '';
|
|
55
|
+
(0, _react.useEffect)(function () {
|
|
56
|
+
var active = true;
|
|
57
|
+
setLoaded(null);
|
|
58
|
+
setFailed(false);
|
|
59
|
+
setLoading(true);
|
|
60
|
+
var bundle = (0, _customForm.publishedFormBundle)(product);
|
|
61
|
+
if (!bundle) {
|
|
62
|
+
setFailed(true);
|
|
63
|
+
setLoading(false);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
var w = window;
|
|
67
|
+
w.React = _react["default"];
|
|
68
|
+
w.MerchiProductFormSdk = _productFormSdkExternals.MerchiProductFormSdkExternals;
|
|
69
|
+
(0, _customForm.loadFormBundle)(bundle).then(function (Component) {
|
|
70
|
+
if (active) {
|
|
71
|
+
setLoaded(function () {
|
|
72
|
+
return Component;
|
|
73
|
+
});
|
|
74
|
+
setLoading(false);
|
|
75
|
+
}
|
|
76
|
+
})["catch"](function (e) {
|
|
77
|
+
console.error('[merchi_cart] custom form load failed', e);
|
|
78
|
+
if (active) {
|
|
79
|
+
setFailed(true);
|
|
80
|
+
setLoading(false);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return function () {
|
|
84
|
+
active = false;
|
|
85
|
+
};
|
|
86
|
+
}, [product, bundleKey]);
|
|
87
|
+
var props = (0, _react.useMemo)(function () {
|
|
88
|
+
try {
|
|
89
|
+
var runtime = _productFormSdkExternals.MerchiProductFormSdkExternals.createProductFormRuntime({
|
|
90
|
+
apiUrl: apiUrl || '',
|
|
91
|
+
product: product,
|
|
92
|
+
onAddToCart: function onAddToCart(job) {
|
|
93
|
+
var _onSaveRef$current;
|
|
94
|
+
return (_onSaveRef$current = onSaveRef.current) === null || _onSaveRef$current === void 0 ? void 0 : _onSaveRef$current.call(onSaveRef, job);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
product: product,
|
|
99
|
+
pricing: runtime.pricing,
|
|
100
|
+
actions: runtime.actions,
|
|
101
|
+
helpers: runtime.helpers
|
|
102
|
+
};
|
|
103
|
+
} catch (e) {
|
|
104
|
+
console.error('[merchi_cart] custom form props build failed', e);
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}, [product, apiUrl]);
|
|
108
|
+
var isActive = !failed && !loading && !!Loaded && !!props;
|
|
109
|
+
(0, _react.useEffect)(function () {
|
|
110
|
+
var _onActiveChangeRef$cu;
|
|
111
|
+
(_onActiveChangeRef$cu = onActiveChangeRef.current) === null || _onActiveChangeRef$cu === void 0 || _onActiveChangeRef$cu.call(onActiveChangeRef, isActive);
|
|
112
|
+
return function () {
|
|
113
|
+
var _onActiveChangeRef$cu2;
|
|
114
|
+
return (_onActiveChangeRef$cu2 = onActiveChangeRef.current) === null || _onActiveChangeRef$cu2 === void 0 ? void 0 : _onActiveChangeRef$cu2.call(onActiveChangeRef, false);
|
|
115
|
+
};
|
|
116
|
+
}, [isActive]);
|
|
117
|
+
if (loading) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingTemplate.LoadingTemplateSm, {});
|
|
118
|
+
if (failed || !Loaded || !props) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
119
|
+
children: fallback
|
|
120
|
+
});
|
|
121
|
+
var Shell = _productFormSdkExternals.MerchiProductFormSdkExternals.ProductFormShell;
|
|
122
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
123
|
+
children: Shell ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Shell, {
|
|
124
|
+
product: props.product,
|
|
125
|
+
pricing: props.pricing,
|
|
126
|
+
actions: props.actions,
|
|
127
|
+
helpers: props.helpers,
|
|
128
|
+
initialJob: initialJob,
|
|
129
|
+
actionLabels: {
|
|
130
|
+
addToCart: 'Save'
|
|
131
|
+
},
|
|
132
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Loaded, _objectSpread({}, props))
|
|
133
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(Loaded, _objectSpread({}, props))
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
var _default = exports["default"] = CustomCartProductForm;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = CustomerCheckoutMethodTabs;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var React = _react;
|
|
10
|
+
var _bi = require("react-icons/bi");
|
|
11
|
+
var _fa = require("react-icons/fa");
|
|
12
|
+
var _FormNewCustomer = _interopRequireDefault(require("../forms/FormNewCustomer"));
|
|
13
|
+
var _FormReturningCustomer = _interopRequireDefault(require("../forms/FormReturningCustomer"));
|
|
14
|
+
var _FormWhatsappCustomer = _interopRequireDefault(require("../forms/FormWhatsappCustomer"));
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
17
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
18
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
19
|
+
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."); }
|
|
20
|
+
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; } }
|
|
21
|
+
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; }
|
|
22
|
+
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; } }
|
|
23
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
24
|
+
function renderSectionIcon(iconType) {
|
|
25
|
+
if (iconType === 'whatsapp') {
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaWhatsapp, {
|
|
27
|
+
className: "merchi-customer-checkout-option__icon-svg merchi-customer-checkout-option__icon-svg--whatsapp"
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_bi.BiUser, {
|
|
31
|
+
className: "merchi-customer-checkout-option__icon-svg"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function CustomerCheckoutMethodTabs(_ref) {
|
|
35
|
+
var _ref$whatsappEnabled = _ref.whatsappEnabled,
|
|
36
|
+
whatsappEnabled = _ref$whatsappEnabled === void 0 ? false : _ref$whatsappEnabled;
|
|
37
|
+
var _useState = (0, _react.useState)(null),
|
|
38
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
+
activeMethod = _useState2[0],
|
|
40
|
+
setActiveMethod = _useState2[1];
|
|
41
|
+
var sections = [{
|
|
42
|
+
id: 'returning',
|
|
43
|
+
label: 'Returning customer',
|
|
44
|
+
iconType: 'user',
|
|
45
|
+
form: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormReturningCustomer["default"], {})
|
|
46
|
+
}, {
|
|
47
|
+
id: 'new',
|
|
48
|
+
label: 'New customer',
|
|
49
|
+
iconType: 'user',
|
|
50
|
+
form: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormNewCustomer["default"], {})
|
|
51
|
+
}];
|
|
52
|
+
if (whatsappEnabled) {
|
|
53
|
+
sections.push({
|
|
54
|
+
id: 'whatsapp',
|
|
55
|
+
label: 'WhatsApp checkout',
|
|
56
|
+
iconType: 'whatsapp',
|
|
57
|
+
form: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormWhatsappCustomer["default"], {})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
61
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
62
|
+
className: "merchi-customer-checkout__heading",
|
|
63
|
+
children: "Choose a checkout option"
|
|
64
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
65
|
+
className: "merchi-customer-checkout-options",
|
|
66
|
+
role: "radiogroup",
|
|
67
|
+
"aria-label": "Choose a checkout option",
|
|
68
|
+
children: sections.map(function (section) {
|
|
69
|
+
var isSelected = activeMethod === section.id;
|
|
70
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
71
|
+
className: "merchi-customer-checkout-option".concat(isSelected ? ' is-selected' : ''),
|
|
72
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|
|
73
|
+
type: "button",
|
|
74
|
+
role: "radio",
|
|
75
|
+
"aria-checked": isSelected,
|
|
76
|
+
"aria-expanded": isSelected,
|
|
77
|
+
className: "merchi-customer-checkout-option__header",
|
|
78
|
+
onClick: function onClick() {
|
|
79
|
+
return setActiveMethod(section.id);
|
|
80
|
+
},
|
|
81
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
82
|
+
className: "merchi-customer-checkout-option__title",
|
|
83
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
84
|
+
className: "merchi-customer-checkout-option__icon",
|
|
85
|
+
children: renderSectionIcon(section.iconType)
|
|
86
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
87
|
+
className: "merchi-customer-checkout-option__label",
|
|
88
|
+
children: section.label
|
|
89
|
+
})]
|
|
90
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
91
|
+
className: "merchi-customer-checkout-option__checkbox",
|
|
92
|
+
"aria-hidden": true,
|
|
93
|
+
children: isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)(_bi.BiCheck, {})
|
|
94
|
+
})]
|
|
95
|
+
}), isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
96
|
+
className: "merchi-customer-checkout-option__body",
|
|
97
|
+
children: section.form
|
|
98
|
+
})]
|
|
99
|
+
}, section.id);
|
|
100
|
+
})
|
|
101
|
+
})]
|
|
102
|
+
});
|
|
103
|
+
}
|