@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,485 @@
|
|
|
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.InputsAddress = InputsAddress;
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var React = _react;
|
|
11
|
+
var _lodash = require("lodash");
|
|
12
|
+
var _sdk = require("@merchi/sdk");
|
|
13
|
+
var _reactCountryRegionSelector = require("react-country-region-selector");
|
|
14
|
+
var _reactHookForm = require("react-hook-form");
|
|
15
|
+
var _InputText = _interopRequireDefault(require("./InputText"));
|
|
16
|
+
var _address = require("../utilities/address");
|
|
17
|
+
var _reactFontawesome = require("@fortawesome/react-fontawesome");
|
|
18
|
+
var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
|
|
19
|
+
var _components = require("../components");
|
|
20
|
+
var _CartProvider = require("../CartProvider");
|
|
21
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
23
|
+
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 _t3 in e) "default" !== _t3 && {}.hasOwnProperty.call(e, _t3) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t3)) && (i.get || i.set) ? o(f, _t3, i) : f[_t3] = e[_t3]); return f; })(e, t); }
|
|
24
|
+
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 }; })(); }
|
|
25
|
+
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); }
|
|
26
|
+
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); }
|
|
27
|
+
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); }); }; }
|
|
28
|
+
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; }
|
|
29
|
+
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; }
|
|
30
|
+
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; }
|
|
31
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
32
|
+
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); }
|
|
33
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
34
|
+
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."); }
|
|
35
|
+
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; } }
|
|
36
|
+
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; }
|
|
37
|
+
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; } }
|
|
38
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
39
|
+
var merchi = new _sdk.Merchi();
|
|
40
|
+
function InputsAddress(_ref) {
|
|
41
|
+
var _ref$defaultAddress = _ref.defaultAddress,
|
|
42
|
+
defaultAddress = _ref$defaultAddress === void 0 ? {} : _ref$defaultAddress,
|
|
43
|
+
_ref$labelGeoSuggest = _ref.labelGeoSuggest,
|
|
44
|
+
labelGeoSuggest = _ref$labelGeoSuggest === void 0 ? 'Address' : _ref$labelGeoSuggest,
|
|
45
|
+
hookForm = _ref.hookForm,
|
|
46
|
+
name = _ref.name,
|
|
47
|
+
_ref$placeholder = _ref.placeholder,
|
|
48
|
+
placeholder = _ref$placeholder === void 0 ? 'Search your address' : _ref$placeholder,
|
|
49
|
+
updateAddress = _ref.updateAddress;
|
|
50
|
+
var _useCartContext = (0, _CartProvider.useCartContext)(),
|
|
51
|
+
classNameCartFormGroup = _useCartContext.classNameCartFormGroup,
|
|
52
|
+
classNameCartFormInput = _useCartContext.classNameCartFormInput,
|
|
53
|
+
classNameCartRow = _useCartContext.classNameCartRow,
|
|
54
|
+
classNameCartRowColumn = _useCartContext.classNameCartRowColumn,
|
|
55
|
+
classNameCartGoogleSuggestList = _useCartContext.classNameCartGoogleSuggestList,
|
|
56
|
+
classNameCartGoogleSuggestListItem = _useCartContext.classNameCartGoogleSuggestListItem;
|
|
57
|
+
var _React$useState = React.useState(''),
|
|
58
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
59
|
+
inputValue = _React$useState2[0],
|
|
60
|
+
setInputValue = _React$useState2[1];
|
|
61
|
+
var _React$useState3 = React.useState([]),
|
|
62
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
63
|
+
suggestions = _React$useState4[0],
|
|
64
|
+
setSuggestions = _React$useState4[1];
|
|
65
|
+
var _React$useState5 = React.useState(false),
|
|
66
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
67
|
+
showSuggestions = _React$useState6[0],
|
|
68
|
+
setShowSuggestions = _React$useState6[1];
|
|
69
|
+
var _React$useState7 = React.useState(false),
|
|
70
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
71
|
+
loading = _React$useState8[0],
|
|
72
|
+
setLoading = _React$useState8[1];
|
|
73
|
+
var _React$useState9 = React.useState(-1),
|
|
74
|
+
_React$useState0 = _slicedToArray(_React$useState9, 2),
|
|
75
|
+
selectedIndex = _React$useState0[0],
|
|
76
|
+
setSelectedIndex = _React$useState0[1];
|
|
77
|
+
var inputRef = React.useRef(null);
|
|
78
|
+
var suggestionsRef = React.useRef(null);
|
|
79
|
+
var control = hookForm.control,
|
|
80
|
+
_hookForm$formState = hookForm.formState,
|
|
81
|
+
errors = _hookForm$formState.errors,
|
|
82
|
+
isValid = _hookForm$formState.isValid,
|
|
83
|
+
submitCount = _hookForm$formState.submitCount,
|
|
84
|
+
setValue = hookForm.setValue,
|
|
85
|
+
getValues = hookForm.getValues,
|
|
86
|
+
reset = hookForm.reset,
|
|
87
|
+
watch = hookForm.watch;
|
|
88
|
+
var inputName = function inputName(_name) {
|
|
89
|
+
return "".concat(name ? "".concat(name, ".") : '').concat(_name);
|
|
90
|
+
};
|
|
91
|
+
var selectedCountry = watch(inputName('country'));
|
|
92
|
+
function onChangeCountryState() {
|
|
93
|
+
var values = getValues();
|
|
94
|
+
updateAddress(name ? values[name] : values);
|
|
95
|
+
}
|
|
96
|
+
var _useState = (0, _react.useState)(false),
|
|
97
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
98
|
+
addressFieldsOpen = _useState2[0],
|
|
99
|
+
setAddressFieldsOpen = _useState2[1];
|
|
100
|
+
var toggleAddressFieldsOpen = function toggleAddressFieldsOpen() {
|
|
101
|
+
return setAddressFieldsOpen(!addressFieldsOpen);
|
|
102
|
+
};
|
|
103
|
+
(0, _react.useEffect)(function () {
|
|
104
|
+
if (!isValid && !addressFieldsOpen && submitCount > 0) {
|
|
105
|
+
toggleAddressFieldsOpen();
|
|
106
|
+
}
|
|
107
|
+
}, [isValid, submitCount]);
|
|
108
|
+
(0, _react.useEffect)(function () {
|
|
109
|
+
if (!(defaultAddress !== null && defaultAddress !== void 0 && defaultAddress.lineOne)) return;
|
|
110
|
+
var nextAddress = _objectSpread({}, defaultAddress);
|
|
111
|
+
setInputValue((0, _address.addressInOneLine)(nextAddress));
|
|
112
|
+
reset(name ? _objectSpread(_objectSpread({}, getValues()), {}, _defineProperty({}, name, nextAddress)) : _objectSpread(_objectSpread({}, getValues()), nextAddress), {
|
|
113
|
+
keepSubmitCount: true
|
|
114
|
+
});
|
|
115
|
+
}, [defaultAddress === null || defaultAddress === void 0 ? void 0 : defaultAddress.lineOne, defaultAddress === null || defaultAddress === void 0 ? void 0 : defaultAddress.city, defaultAddress === null || defaultAddress === void 0 ? void 0 : defaultAddress.postcode]);
|
|
116
|
+
function searchAddresses(_x) {
|
|
117
|
+
return _searchAddresses.apply(this, arguments);
|
|
118
|
+
}
|
|
119
|
+
function _searchAddresses() {
|
|
120
|
+
_searchAddresses = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(query) {
|
|
121
|
+
var response, _t;
|
|
122
|
+
return _regenerator().w(function (_context) {
|
|
123
|
+
while (1) switch (_context.p = _context.n) {
|
|
124
|
+
case 0:
|
|
125
|
+
if (query.trim()) {
|
|
126
|
+
_context.n = 1;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
setSuggestions([]);
|
|
130
|
+
setShowSuggestions(false);
|
|
131
|
+
return _context.a(2);
|
|
132
|
+
case 1:
|
|
133
|
+
setLoading(true);
|
|
134
|
+
_context.p = 2;
|
|
135
|
+
_context.n = 3;
|
|
136
|
+
return merchi.authenticatedFetch('/addresses/place-search/', {
|
|
137
|
+
method: 'GET',
|
|
138
|
+
query: [['q', query]]
|
|
139
|
+
});
|
|
140
|
+
case 3:
|
|
141
|
+
response = _context.v;
|
|
142
|
+
if (response.status === 'success') {
|
|
143
|
+
setSuggestions(response.results || []);
|
|
144
|
+
setShowSuggestions(true);
|
|
145
|
+
setSelectedIndex(-1);
|
|
146
|
+
}
|
|
147
|
+
_context.n = 5;
|
|
148
|
+
break;
|
|
149
|
+
case 4:
|
|
150
|
+
_context.p = 4;
|
|
151
|
+
_t = _context.v;
|
|
152
|
+
console.error('Error searching addresses:', _t);
|
|
153
|
+
setSuggestions([]);
|
|
154
|
+
setShowSuggestions(false);
|
|
155
|
+
case 5:
|
|
156
|
+
_context.p = 5;
|
|
157
|
+
setLoading(false);
|
|
158
|
+
return _context.f(5);
|
|
159
|
+
case 6:
|
|
160
|
+
return _context.a(2);
|
|
161
|
+
}
|
|
162
|
+
}, _callee, null, [[2, 4, 5, 6]]);
|
|
163
|
+
}));
|
|
164
|
+
return _searchAddresses.apply(this, arguments);
|
|
165
|
+
}
|
|
166
|
+
var debouncedSearch = (0, _react.useMemo)(function () {
|
|
167
|
+
return (0, _lodash.debounce)(searchAddresses, 500);
|
|
168
|
+
}, []);
|
|
169
|
+
(0, _react.useEffect)(function () {
|
|
170
|
+
return function () {
|
|
171
|
+
return debouncedSearch.cancel();
|
|
172
|
+
};
|
|
173
|
+
}, [debouncedSearch]);
|
|
174
|
+
function handleInputChange(event) {
|
|
175
|
+
var value = event.target.value;
|
|
176
|
+
setInputValue(value);
|
|
177
|
+
debouncedSearch(value);
|
|
178
|
+
}
|
|
179
|
+
function handleSuggestionSelect(_x2) {
|
|
180
|
+
return _handleSuggestionSelect.apply(this, arguments);
|
|
181
|
+
}
|
|
182
|
+
function _handleSuggestionSelect() {
|
|
183
|
+
_handleSuggestionSelect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(suggestion) {
|
|
184
|
+
var applyDescriptionOnly, response, parsedAddress, _t2;
|
|
185
|
+
return _regenerator().w(function (_context2) {
|
|
186
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
187
|
+
case 0:
|
|
188
|
+
applyDescriptionOnly = function _applyDescriptionOnly() {
|
|
189
|
+
setInputValue(suggestion.description);
|
|
190
|
+
updateAddress({
|
|
191
|
+
city: '',
|
|
192
|
+
country: '',
|
|
193
|
+
lineOne: suggestion.description,
|
|
194
|
+
lineTwo: '',
|
|
195
|
+
postcode: '',
|
|
196
|
+
state: ''
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
setLoading(true);
|
|
200
|
+
_context2.p = 1;
|
|
201
|
+
_context2.n = 2;
|
|
202
|
+
return merchi.authenticatedFetch('/addresses/place-details/', {
|
|
203
|
+
method: 'GET',
|
|
204
|
+
query: [['place_id', suggestion.placeId]]
|
|
205
|
+
});
|
|
206
|
+
case 2:
|
|
207
|
+
response = _context2.v;
|
|
208
|
+
parsedAddress = response.status === 'success' ? (0, _address.googlePlacesResultAsNewAddress)(response.result) : null;
|
|
209
|
+
if (parsedAddress) {
|
|
210
|
+
setInputValue((0, _address.addressInOneLine)(parsedAddress));
|
|
211
|
+
updateAddress(parsedAddress);
|
|
212
|
+
} else {
|
|
213
|
+
applyDescriptionOnly();
|
|
214
|
+
}
|
|
215
|
+
_context2.n = 4;
|
|
216
|
+
break;
|
|
217
|
+
case 3:
|
|
218
|
+
_context2.p = 3;
|
|
219
|
+
_t2 = _context2.v;
|
|
220
|
+
console.error('Error fetching place details:', _t2);
|
|
221
|
+
applyDescriptionOnly();
|
|
222
|
+
case 4:
|
|
223
|
+
_context2.p = 4;
|
|
224
|
+
setLoading(false);
|
|
225
|
+
setShowSuggestions(false);
|
|
226
|
+
setSuggestions([]);
|
|
227
|
+
setSelectedIndex(-1);
|
|
228
|
+
return _context2.f(4);
|
|
229
|
+
case 5:
|
|
230
|
+
return _context2.a(2);
|
|
231
|
+
}
|
|
232
|
+
}, _callee2, null, [[1, 3, 4, 5]]);
|
|
233
|
+
}));
|
|
234
|
+
return _handleSuggestionSelect.apply(this, arguments);
|
|
235
|
+
}
|
|
236
|
+
function handleKeyDown(event) {
|
|
237
|
+
if (!showSuggestions || suggestions.length === 0) return;
|
|
238
|
+
switch (event.key) {
|
|
239
|
+
case 'ArrowDown':
|
|
240
|
+
event.preventDefault();
|
|
241
|
+
setSelectedIndex(function (prev) {
|
|
242
|
+
return prev < suggestions.length - 1 ? prev + 1 : 0;
|
|
243
|
+
});
|
|
244
|
+
break;
|
|
245
|
+
case 'ArrowUp':
|
|
246
|
+
event.preventDefault();
|
|
247
|
+
setSelectedIndex(function (prev) {
|
|
248
|
+
return prev > 0 ? prev - 1 : suggestions.length - 1;
|
|
249
|
+
});
|
|
250
|
+
break;
|
|
251
|
+
case 'Enter':
|
|
252
|
+
event.preventDefault();
|
|
253
|
+
if (selectedIndex >= 0 && selectedIndex < suggestions.length) {
|
|
254
|
+
handleSuggestionSelect(suggestions[selectedIndex]);
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
case 'Escape':
|
|
258
|
+
setShowSuggestions(false);
|
|
259
|
+
setSelectedIndex(-1);
|
|
260
|
+
break;
|
|
261
|
+
default:
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function handleInputBlur() {
|
|
266
|
+
setTimeout(function () {
|
|
267
|
+
var _suggestionsRef$curre;
|
|
268
|
+
if (!((_suggestionsRef$curre = suggestionsRef.current) !== null && _suggestionsRef$curre !== void 0 && _suggestionsRef$curre.contains(document.activeElement))) {
|
|
269
|
+
setShowSuggestions(false);
|
|
270
|
+
setSelectedIndex(-1);
|
|
271
|
+
}
|
|
272
|
+
}, 200);
|
|
273
|
+
}
|
|
274
|
+
function handleInputFocus() {
|
|
275
|
+
if (suggestions.length > 0) {
|
|
276
|
+
setShowSuggestions(true);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function clearInput(e) {
|
|
280
|
+
e.preventDefault();
|
|
281
|
+
setInputValue('');
|
|
282
|
+
setSuggestions([]);
|
|
283
|
+
setShowSuggestions(false);
|
|
284
|
+
updateAddress({
|
|
285
|
+
city: '',
|
|
286
|
+
country: '',
|
|
287
|
+
lineOne: '',
|
|
288
|
+
lineTwo: '',
|
|
289
|
+
postcode: '',
|
|
290
|
+
state: ''
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
var hasErrors = !!Object.keys(errors || {}).length;
|
|
294
|
+
var addressForm = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
295
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_InputText["default"], {
|
|
296
|
+
control: control,
|
|
297
|
+
label: "Address line one",
|
|
298
|
+
name: inputName('lineOne'),
|
|
299
|
+
placeholder: "123 Fake st",
|
|
300
|
+
rules: {
|
|
301
|
+
required: 'Address line one is required.'
|
|
302
|
+
}
|
|
303
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputText["default"], {
|
|
304
|
+
control: control,
|
|
305
|
+
label: "Continue address",
|
|
306
|
+
name: inputName('lineTwo'),
|
|
307
|
+
placeholder: "Continue address..."
|
|
308
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
309
|
+
className: classNameCartRow,
|
|
310
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
311
|
+
className: classNameCartRowColumn,
|
|
312
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputText["default"], {
|
|
313
|
+
control: control,
|
|
314
|
+
label: "City / Province",
|
|
315
|
+
name: inputName('city'),
|
|
316
|
+
placeholder: "City",
|
|
317
|
+
rules: {
|
|
318
|
+
required: 'City / Province is required.'
|
|
319
|
+
}
|
|
320
|
+
})
|
|
321
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
322
|
+
className: classNameCartRowColumn,
|
|
323
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputText["default"], {
|
|
324
|
+
control: control,
|
|
325
|
+
label: "Post / Zip code",
|
|
326
|
+
name: inputName('postcode'),
|
|
327
|
+
placeholder: "90210"
|
|
328
|
+
})
|
|
329
|
+
})]
|
|
330
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
331
|
+
className: classNameCartRow,
|
|
332
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
333
|
+
className: classNameCartRowColumn,
|
|
334
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
335
|
+
className: classNameCartFormGroup,
|
|
336
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
|
|
337
|
+
children: "Country"
|
|
338
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
|
|
339
|
+
name: inputName('country'),
|
|
340
|
+
control: control,
|
|
341
|
+
defaultValue: defaultAddress && defaultAddress.country,
|
|
342
|
+
render: function render(_ref2) {
|
|
343
|
+
var field = _ref2.field;
|
|
344
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactCountryRegionSelector.CountryDropdown, _objectSpread(_objectSpread({}, field), {}, {
|
|
345
|
+
classes: classNameCartFormInput,
|
|
346
|
+
onChange: function onChange(val) {
|
|
347
|
+
setValue(inputName('country'), val);
|
|
348
|
+
setValue(inputName('state'), '');
|
|
349
|
+
field.onChange(val);
|
|
350
|
+
onChangeCountryState();
|
|
351
|
+
},
|
|
352
|
+
valueType: "short"
|
|
353
|
+
}));
|
|
354
|
+
}
|
|
355
|
+
})]
|
|
356
|
+
})
|
|
357
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
358
|
+
className: classNameCartRowColumn,
|
|
359
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
360
|
+
className: classNameCartFormGroup,
|
|
361
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
|
|
362
|
+
children: "State / Region"
|
|
363
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
|
|
364
|
+
name: inputName('state'),
|
|
365
|
+
control: control,
|
|
366
|
+
defaultValue: defaultAddress && defaultAddress.state,
|
|
367
|
+
render: function render(_ref3) {
|
|
368
|
+
var field = _ref3.field;
|
|
369
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactCountryRegionSelector.RegionDropdown, _objectSpread(_objectSpread({}, field), {}, {
|
|
370
|
+
countryValueType: "short",
|
|
371
|
+
country: selectedCountry,
|
|
372
|
+
classes: classNameCartFormInput,
|
|
373
|
+
onChange: function onChange(val) {
|
|
374
|
+
setValue(inputName('state'), val);
|
|
375
|
+
field.onChange(val);
|
|
376
|
+
onChangeCountryState();
|
|
377
|
+
},
|
|
378
|
+
valueType: "short"
|
|
379
|
+
}));
|
|
380
|
+
}
|
|
381
|
+
})]
|
|
382
|
+
})
|
|
383
|
+
})]
|
|
384
|
+
})]
|
|
385
|
+
});
|
|
386
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
387
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
388
|
+
className: classNameCartFormGroup,
|
|
389
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
|
|
390
|
+
children: labelGeoSuggest
|
|
391
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
392
|
+
className: "merchi-cart-address-search",
|
|
393
|
+
style: {
|
|
394
|
+
position: 'relative'
|
|
395
|
+
},
|
|
396
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
397
|
+
autoComplete: "new-password",
|
|
398
|
+
ref: inputRef,
|
|
399
|
+
type: "text",
|
|
400
|
+
name: "address-suggestion",
|
|
401
|
+
className: classNameCartFormInput,
|
|
402
|
+
placeholder: placeholder,
|
|
403
|
+
value: inputValue,
|
|
404
|
+
onChange: handleInputChange,
|
|
405
|
+
onKeyDown: handleKeyDown,
|
|
406
|
+
onBlur: handleInputBlur,
|
|
407
|
+
onFocus: handleInputFocus,
|
|
408
|
+
style: {
|
|
409
|
+
paddingRight: loading || inputValue ? '40px' : undefined
|
|
410
|
+
}
|
|
411
|
+
}), loading && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
412
|
+
className: "merchi-cart-address-search__spinner",
|
|
413
|
+
style: {
|
|
414
|
+
position: 'absolute',
|
|
415
|
+
right: '10px',
|
|
416
|
+
top: '50%',
|
|
417
|
+
transform: 'translateY(-50%)'
|
|
418
|
+
},
|
|
419
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
420
|
+
icon: _freeSolidSvgIcons.faSpinner,
|
|
421
|
+
spin: true
|
|
422
|
+
})
|
|
423
|
+
}), inputValue && !loading && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
424
|
+
type: "button",
|
|
425
|
+
className: "btn btn-sm merchi-cart-address-search__clear",
|
|
426
|
+
style: {
|
|
427
|
+
position: 'absolute',
|
|
428
|
+
right: '5px',
|
|
429
|
+
top: '50%',
|
|
430
|
+
transform: 'translateY(-50%)',
|
|
431
|
+
border: 'none',
|
|
432
|
+
background: 'transparent',
|
|
433
|
+
padding: '2px 5px'
|
|
434
|
+
},
|
|
435
|
+
onClick: clearInput,
|
|
436
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
437
|
+
icon: _freeSolidSvgIcons.faTimes
|
|
438
|
+
})
|
|
439
|
+
}), showSuggestions && suggestions.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
440
|
+
ref: suggestionsRef,
|
|
441
|
+
className: classNameCartGoogleSuggestList,
|
|
442
|
+
role: "listbox",
|
|
443
|
+
children: suggestions.map(function (suggestion, index) {
|
|
444
|
+
var _suggestion$structure, _suggestion$structure2;
|
|
445
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
446
|
+
className: "".concat(classNameCartGoogleSuggestListItem).concat(index === selectedIndex ? ' active' : ''),
|
|
447
|
+
role: "option",
|
|
448
|
+
onMouseDown: function onMouseDown(e) {
|
|
449
|
+
e.preventDefault();
|
|
450
|
+
handleSuggestionSelect(suggestion);
|
|
451
|
+
},
|
|
452
|
+
onMouseEnter: function onMouseEnter() {
|
|
453
|
+
return setSelectedIndex(index);
|
|
454
|
+
},
|
|
455
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
456
|
+
children: ((_suggestion$structure = suggestion.structuredFormatting) === null || _suggestion$structure === void 0 ? void 0 : _suggestion$structure.main_text) || suggestion.description
|
|
457
|
+
}), ((_suggestion$structure2 = suggestion.structuredFormatting) === null || _suggestion$structure2 === void 0 ? void 0 : _suggestion$structure2.secondary_text) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
458
|
+
className: "text-muted small",
|
|
459
|
+
children: suggestion.structuredFormatting.secondary_text
|
|
460
|
+
})]
|
|
461
|
+
}, suggestion.placeId);
|
|
462
|
+
})
|
|
463
|
+
})]
|
|
464
|
+
})]
|
|
465
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Collapse, {
|
|
466
|
+
isOpen: addressFieldsOpen,
|
|
467
|
+
children: addressForm
|
|
468
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
469
|
+
className: "d-flex align-items-center",
|
|
470
|
+
children: [hasErrors && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
471
|
+
className: "text-danger",
|
|
472
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
473
|
+
icon: _freeSolidSvgIcons.faExclamationTriangle
|
|
474
|
+
}), " Invalid address!"]
|
|
475
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("a", {
|
|
476
|
+
className: "ml-auto btn btn-sm btn-link ".concat(hasErrors ? 'text-danger' : ''),
|
|
477
|
+
onClick: toggleAddressFieldsOpen,
|
|
478
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
479
|
+
icon: addressFieldsOpen ? _freeSolidSvgIcons.faTimes : _freeSolidSvgIcons.faEdit
|
|
480
|
+
}), ' ', addressFieldsOpen ? 'Close' : 'Edit fields']
|
|
481
|
+
})]
|
|
482
|
+
})]
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
var _default = exports["default"] = InputsAddress;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import FormCustomerNew from "./FormNewCustomer";
|
|
2
|
+
import FormReturningCustomer from "./FormReturningCustomer";
|
|
3
|
+
import FormShipmentAddressAndNotes, { ActiveFormShipmentAddressAndNotes } from "./FormShipmentAddressAndNotes";
|
|
4
|
+
import FormSquarePayment from "./FormSquarePayment";
|
|
5
|
+
import FormStripePayment from "./FormStripePayment";
|
|
6
|
+
import FormWhatsappCustomer from "./FormWhatsappCustomer";
|
|
7
|
+
import CustomerCheckoutMethodTabs from "../components/CustomerCheckoutMethodTabs";
|
|
8
|
+
export { ActiveFormShipmentAddressAndNotes, CustomerCheckoutMethodTabs, FormCustomerNew, FormReturningCustomer, FormShipmentAddressAndNotes, FormSquarePayment, FormStripePayment, FormWhatsappCustomer, };
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
Object.defineProperty(exports, "ActiveFormShipmentAddressAndNotes", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _FormShipmentAddressAndNotes.ActiveFormShipmentAddressAndNotes;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "CustomerCheckoutMethodTabs", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _CustomerCheckoutMethodTabs["default"];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "FormCustomerNew", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _FormNewCustomer["default"];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "FormReturningCustomer", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _FormReturningCustomer["default"];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "FormShipmentAddressAndNotes", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _FormShipmentAddressAndNotes["default"];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "FormSquarePayment", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function get() {
|
|
40
|
+
return _FormSquarePayment["default"];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "FormStripePayment", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _FormStripePayment["default"];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "FormWhatsappCustomer", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function get() {
|
|
52
|
+
return _FormWhatsappCustomer["default"];
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
var _FormNewCustomer = _interopRequireDefault(require("./FormNewCustomer"));
|
|
56
|
+
var _FormReturningCustomer = _interopRequireDefault(require("./FormReturningCustomer"));
|
|
57
|
+
var _FormShipmentAddressAndNotes = _interopRequireWildcard(require("./FormShipmentAddressAndNotes"));
|
|
58
|
+
var _FormSquarePayment = _interopRequireDefault(require("./FormSquarePayment"));
|
|
59
|
+
var _FormStripePayment = _interopRequireDefault(require("./FormStripePayment"));
|
|
60
|
+
var _FormWhatsappCustomer = _interopRequireDefault(require("./FormWhatsappCustomer"));
|
|
61
|
+
var _CustomerCheckoutMethodTabs = _interopRequireDefault(require("../components/CustomerCheckoutMethodTabs"));
|
|
62
|
+
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); }
|
|
63
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Cart, { CartComponents } from './Cart';
|
|
2
|
+
import { MerchiCartModal, MerchiShoppingCartModal } from './modals';
|
|
3
|
+
import { ButtonOpenCart, ButtonListWrappedOpenCart } from './buttons/ButtonOpenCartMerchiCartModal';
|
|
4
|
+
import * as components from './components';
|
|
5
|
+
import CartProvider, { useCartContext } from './CartProvider';
|
|
6
|
+
import CartAlert from './CartAlert';
|
|
7
|
+
import CartHeader from './CartHeader';
|
|
8
|
+
import CartTotals from './CartTotals';
|
|
9
|
+
import * as buttons from './buttons';
|
|
10
|
+
import * as forms from './forms';
|
|
11
|
+
import * as panels from './panels';
|
|
12
|
+
import * as utilities from './utilities';
|
|
13
|
+
export { buttons, ButtonOpenCart, ButtonListWrappedOpenCart, Cart, CartComponents, CartAlert, CartHeader, CartProvider, CartTotals, components, forms, MerchiCartModal, MerchiShoppingCartModal, panels, useCartContext, utilities, };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
Object.defineProperty(exports, "ButtonListWrappedOpenCart", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _ButtonOpenCartMerchiCartModal.ButtonListWrappedOpenCart;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "ButtonOpenCart", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _ButtonOpenCartMerchiCartModal.ButtonOpenCart;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "Cart", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _Cart["default"];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "CartAlert", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _CartAlert["default"];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "CartComponents", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _Cart.CartComponents;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "CartHeader", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function get() {
|
|
40
|
+
return _CartHeader["default"];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "CartProvider", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _CartProvider["default"];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "CartTotals", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function get() {
|
|
52
|
+
return _CartTotals["default"];
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, "MerchiCartModal", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function get() {
|
|
58
|
+
return _modals.MerchiCartModal;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, "MerchiShoppingCartModal", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function get() {
|
|
64
|
+
return _modals.MerchiShoppingCartModal;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
exports.panels = exports.forms = exports.components = exports.buttons = void 0;
|
|
68
|
+
Object.defineProperty(exports, "useCartContext", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function get() {
|
|
71
|
+
return _CartProvider.useCartContext;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
exports.utilities = void 0;
|
|
75
|
+
var _Cart = _interopRequireWildcard(require("./Cart"));
|
|
76
|
+
var _modals = require("./modals");
|
|
77
|
+
var _ButtonOpenCartMerchiCartModal = require("./buttons/ButtonOpenCartMerchiCartModal");
|
|
78
|
+
var components = _interopRequireWildcard(require("./components"));
|
|
79
|
+
exports.components = components;
|
|
80
|
+
var _CartProvider = _interopRequireWildcard(require("./CartProvider"));
|
|
81
|
+
var _CartAlert = _interopRequireDefault(require("./CartAlert"));
|
|
82
|
+
var _CartHeader = _interopRequireDefault(require("./CartHeader"));
|
|
83
|
+
var _CartTotals = _interopRequireDefault(require("./CartTotals"));
|
|
84
|
+
var buttons = _interopRequireWildcard(require("./buttons"));
|
|
85
|
+
exports.buttons = buttons;
|
|
86
|
+
var forms = _interopRequireWildcard(require("./forms"));
|
|
87
|
+
exports.forms = forms;
|
|
88
|
+
var panels = _interopRequireWildcard(require("./panels"));
|
|
89
|
+
exports.panels = panels;
|
|
90
|
+
var utilities = _interopRequireWildcard(require("./utilities"));
|
|
91
|
+
exports.utilities = utilities;
|
|
92
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
93
|
+
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); }
|