@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,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FieldType = void 0;
|
|
7
|
+
exports.isSelectable = isSelectable;
|
|
8
|
+
exports.valueString = valueString;
|
|
9
|
+
var _area = require("./area");
|
|
10
|
+
var FieldType = exports.FieldType = /*#__PURE__*/function (FieldType) {
|
|
11
|
+
FieldType[FieldType["TEXT_INPUT"] = 1] = "TEXT_INPUT";
|
|
12
|
+
FieldType[FieldType["SELECT"] = 2] = "SELECT";
|
|
13
|
+
FieldType[FieldType["FILE_UPLOAD"] = 3] = "FILE_UPLOAD";
|
|
14
|
+
FieldType[FieldType["TEXT_AREA"] = 4] = "TEXT_AREA";
|
|
15
|
+
FieldType[FieldType["NUMBER_INPUT"] = 5] = "NUMBER_INPUT";
|
|
16
|
+
FieldType[FieldType["CHECKBOX"] = 6] = "CHECKBOX";
|
|
17
|
+
FieldType[FieldType["RADIO"] = 7] = "RADIO";
|
|
18
|
+
FieldType[FieldType["FIELD_INSTRUCTIONS"] = 8] = "FIELD_INSTRUCTIONS";
|
|
19
|
+
FieldType[FieldType["IMAGE_SELECT"] = 9] = "IMAGE_SELECT";
|
|
20
|
+
FieldType[FieldType["COLOUR_PICKER"] = 10] = "COLOUR_PICKER";
|
|
21
|
+
FieldType[FieldType["COLOUR_SELECT"] = 11] = "COLOUR_SELECT";
|
|
22
|
+
FieldType[FieldType["TURNAROUND_TIME"] = 12] = "TURNAROUND_TIME";
|
|
23
|
+
FieldType[FieldType["COLOUR_EXTRACT"] = 13] = "COLOUR_EXTRACT";
|
|
24
|
+
FieldType[FieldType["AREA"] = 14] = "AREA";
|
|
25
|
+
return FieldType;
|
|
26
|
+
}({});
|
|
27
|
+
function isSelectable(fieldType) {
|
|
28
|
+
return [FieldType.SELECT, FieldType.CHECKBOX, FieldType.RADIO, FieldType.IMAGE_SELECT, FieldType.COLOUR_SELECT, FieldType.COLOUR_EXTRACT].includes(fieldType);
|
|
29
|
+
}
|
|
30
|
+
function concatinatedSelectedOptionValues(variation) {
|
|
31
|
+
var selectableOptions = variation.selectableOptions,
|
|
32
|
+
value = variation.value;
|
|
33
|
+
var optionIds = value ? value.split(',') : [];
|
|
34
|
+
var optionIdsLength = optionIds.length - 1;
|
|
35
|
+
var option;
|
|
36
|
+
var i = 0;
|
|
37
|
+
var val = '';
|
|
38
|
+
for (i; i < optionIds.length; i++) {
|
|
39
|
+
option = selectableOptions.find(function (o) {
|
|
40
|
+
return String(o.optionId) === String(optionIds[i]);
|
|
41
|
+
});
|
|
42
|
+
val += option ? option.value : '';
|
|
43
|
+
if (optionIdsLength > i) {
|
|
44
|
+
val += ', ';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return val;
|
|
48
|
+
}
|
|
49
|
+
function valueString(variation) {
|
|
50
|
+
var field = variation.variationField,
|
|
51
|
+
variationFiles = variation.variationFiles,
|
|
52
|
+
value = variation.value;
|
|
53
|
+
if (isSelectable(field.fieldType)) {
|
|
54
|
+
return concatinatedSelectedOptionValues(variation);
|
|
55
|
+
} else if ((field.fieldType === FieldType.FILE_UPLOAD || field.fieldType === FieldType.COLOUR_EXTRACT) && variationFiles) {
|
|
56
|
+
if (field.fieldType === FieldType.COLOUR_EXTRACT) {
|
|
57
|
+
var colours = concatinatedSelectedOptionValues(variation);
|
|
58
|
+
var fileLabel = variationFiles.length > 1 ? 'uploaded files' : 'uploaded file';
|
|
59
|
+
return colours ? "".concat(fileLabel, " (").concat(colours, ")") : fileLabel;
|
|
60
|
+
}
|
|
61
|
+
return variationFiles.length > 1 ? 'uploaded files' : 'uploaded file';
|
|
62
|
+
} else if (field.fieldType === FieldType.AREA) {
|
|
63
|
+
return (0, _area.formatAreaSummary)(value, (0, _area.localePrefersImperial)() ? 'imperial' : 'metric', field.areaUnit || 'mm') || value;
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
66
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@merchi/cart",
|
|
3
|
+
"version": "1.4.4",
|
|
4
|
+
"description": "Merchi's cart",
|
|
5
|
+
"source": "src/index.ts",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"module": "esm/index.js",
|
|
8
|
+
"types": "lib/index.d.ts",
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"**/*.css",
|
|
11
|
+
"**/*.scss"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build:esm": "babel src --out-dir esm --config-file ./babel.esm.config.cjs --extensions .js,.ts,.tsx --verbose && npm run copy-assets && npm run compile-sass",
|
|
15
|
+
"build:lib": "babel src --out-dir lib --config-file ./babel.build.config.cjs --extensions .js,.ts,.tsx --verbose && npm run copy-assets && npm run compile-sass",
|
|
16
|
+
"build": "npm run build:esm && npm run build:lib && npm run build:types",
|
|
17
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
18
|
+
"copy-assets": "copyfiles -u 1 src/assets/**/* esm && copyfiles -u 1 src/assets/**/* lib",
|
|
19
|
+
"compile-sass": "sass src/styles/globals.scss esm/styles/globals.css && sass src/styles/globals.scss lib/styles/globals.css",
|
|
20
|
+
"start": "react-scripts start",
|
|
21
|
+
"test": "react-scripts test",
|
|
22
|
+
"eject": "react-scripts eject"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/merchisdk/merchi_ts.git",
|
|
27
|
+
"directory": "packages/cart"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"react",
|
|
34
|
+
"merchi",
|
|
35
|
+
"component",
|
|
36
|
+
"merch",
|
|
37
|
+
"merchandise",
|
|
38
|
+
"library",
|
|
39
|
+
"stripe"
|
|
40
|
+
],
|
|
41
|
+
"author": "Merchi SDK <james@merchi.co>",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/merchisdk/merchi_ts/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/merchisdk/merchi_ts/tree/main/packages/cart#readme",
|
|
47
|
+
"files": [
|
|
48
|
+
"esm",
|
|
49
|
+
"lib",
|
|
50
|
+
"src"
|
|
51
|
+
],
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
54
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@babel/cli": "^7.23.0",
|
|
58
|
+
"@babel/core": "^7.23.0",
|
|
59
|
+
"@babel/plugin-proposal-export-default-from": "^7.23.3",
|
|
60
|
+
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
|
61
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
62
|
+
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
|
|
63
|
+
"@babel/plugin-transform-react-jsx": "^7.23.4",
|
|
64
|
+
"@babel/plugin-transform-runtime": "^7.23.3",
|
|
65
|
+
"@babel/preset-env": "^7.23.3",
|
|
66
|
+
"@babel/preset-react": "^7.23.3",
|
|
67
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
68
|
+
"@types/jest": "^28.0.0",
|
|
69
|
+
"@types/lodash": "^4.14.202",
|
|
70
|
+
"@types/node": "^20.11.5",
|
|
71
|
+
"@types/react": "^19.0.0",
|
|
72
|
+
"@types/react-dom": "^19.0.0",
|
|
73
|
+
"@types/uuid": "^9.0.5",
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
75
|
+
"@typescript-eslint/parser": "^5.30.5",
|
|
76
|
+
"babel-plugin-inline-import": "^3.0.0",
|
|
77
|
+
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
78
|
+
"babel-plugin-module-resolver": "^5.0.0",
|
|
79
|
+
"babel-plugin-transform-typescript-metadata": "^0.3.2",
|
|
80
|
+
"compile-sass": "^2.0.0",
|
|
81
|
+
"copyfiles": "^2.4.1",
|
|
82
|
+
"eslint": "8.47.0",
|
|
83
|
+
"eslint-config-next": "13.4.16",
|
|
84
|
+
"react": "^18.0.0",
|
|
85
|
+
"react-dom": "^18.0.0",
|
|
86
|
+
"sass": "^1.70.0",
|
|
87
|
+
"typescript": "^5.1.6"
|
|
88
|
+
},
|
|
89
|
+
"dependencies": {
|
|
90
|
+
"@fortawesome/fontawesome-svg-core": "6.4.2",
|
|
91
|
+
"@fortawesome/free-solid-svg-icons": "6.4.2",
|
|
92
|
+
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
93
|
+
"@stripe/react-stripe-js": "^2.3.0",
|
|
94
|
+
"@stripe/stripe-js": "^2.1.6",
|
|
95
|
+
"browser-or-node": "^3.0.0-pre.0",
|
|
96
|
+
"js-cookie": "^3.0.5",
|
|
97
|
+
"lodash": "^4.17.21",
|
|
98
|
+
"@merchi/product-form": "^1.19.12",
|
|
99
|
+
"@merchi/product-form-sdk": "^1.0.9",
|
|
100
|
+
"@merchi/sdk": "^1.40.2",
|
|
101
|
+
"react-country-region-selector": "^3.6.1",
|
|
102
|
+
"react-hook-form": "7.45.4",
|
|
103
|
+
"react-icons": "^4.10.1",
|
|
104
|
+
"react-square-web-payments-sdk": "^3.2.1",
|
|
105
|
+
"react-transition-group": "^4.4.5",
|
|
106
|
+
"reactstrap": "^9.2.2",
|
|
107
|
+
"@merchi/invoice": "^1.3.3"
|
|
108
|
+
}
|
|
109
|
+
}
|
package/src/Cart.tsx
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Suspense, lazy } from 'react';
|
|
3
|
+
import CartAlert from './CartAlert';
|
|
4
|
+
import CartHeader from './CartHeader';
|
|
5
|
+
import CartNav from './tabs/CartNav';
|
|
6
|
+
import CartTotals from './CartTotals';
|
|
7
|
+
import CartProvider, { PropsCart, useCartContext } from './CartProvider';
|
|
8
|
+
import {
|
|
9
|
+
ButtonBack,
|
|
10
|
+
ButtonClearCart,
|
|
11
|
+
ButtonNextDynamic,
|
|
12
|
+
} from './buttons';
|
|
13
|
+
import {
|
|
14
|
+
CartFooter,
|
|
15
|
+
CartPaymentSettingsInvalid,
|
|
16
|
+
LoadingTemplate,
|
|
17
|
+
} from './components';
|
|
18
|
+
import { LoadingTemplateSm } from './components/LoadingTemplate';
|
|
19
|
+
import PanelCartItems from './panels/PanelCartItems';
|
|
20
|
+
import PanelCartShipment from './panels/PanelCartShipment';
|
|
21
|
+
import PanelClearCart from './panels/PanelClearCart';
|
|
22
|
+
import PanelPaymentSuccess from './panels/PanelPaymentSuccess';
|
|
23
|
+
import {
|
|
24
|
+
tabIdCheckout,
|
|
25
|
+
tabIdClearCart,
|
|
26
|
+
tabIdItem,
|
|
27
|
+
tabIdPaymentSuccess,
|
|
28
|
+
} from './utilities/tabs';
|
|
29
|
+
import './styles/globals.css';
|
|
30
|
+
|
|
31
|
+
// Heavy panels: keep out of the initial cart chunk until their tab is opened.
|
|
32
|
+
const PanelClientCheckout = lazy(() => import('./panels/PanelClientCheckout'));
|
|
33
|
+
const PanelEditCartItem = lazy(() => import('./panels/PanelEditCartItem'));
|
|
34
|
+
|
|
35
|
+
interface Props {
|
|
36
|
+
footer?: React.ReactElement;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function CartComponents({
|
|
40
|
+
footer
|
|
41
|
+
}: Props) {
|
|
42
|
+
const {
|
|
43
|
+
activeTabIndex,
|
|
44
|
+
cart,
|
|
45
|
+
cartSettingsInvalid,
|
|
46
|
+
fetchingCart,
|
|
47
|
+
hideHead,
|
|
48
|
+
} = useCartContext();
|
|
49
|
+
return (
|
|
50
|
+
<>
|
|
51
|
+
{!hideHead && <CartHeader />}
|
|
52
|
+
<CartAlert />
|
|
53
|
+
<CartNav />
|
|
54
|
+
{fetchingCart ? (
|
|
55
|
+
<LoadingTemplate />
|
|
56
|
+
) : cartSettingsInvalid ? (
|
|
57
|
+
<CartPaymentSettingsInvalid />
|
|
58
|
+
) : (
|
|
59
|
+
<div className='merchi-tab-pane'>
|
|
60
|
+
<PanelClearCart />
|
|
61
|
+
<Suspense fallback={<LoadingTemplateSm />}>
|
|
62
|
+
{activeTabIndex === tabIdItem && (
|
|
63
|
+
<PanelEditCartItem cart={cart} />
|
|
64
|
+
)}
|
|
65
|
+
{activeTabIndex === tabIdCheckout && (
|
|
66
|
+
<PanelClientCheckout />
|
|
67
|
+
)}
|
|
68
|
+
</Suspense>
|
|
69
|
+
<PanelCartItems />
|
|
70
|
+
<PanelCartShipment />
|
|
71
|
+
<PanelPaymentSuccess />
|
|
72
|
+
{![tabIdItem, tabIdClearCart, tabIdPaymentSuccess].includes(activeTabIndex) &&
|
|
73
|
+
<>
|
|
74
|
+
{activeTabIndex !== tabIdCheckout && (<CartTotals />)}
|
|
75
|
+
{footer || (
|
|
76
|
+
<CartFooter>
|
|
77
|
+
<ButtonBack />
|
|
78
|
+
<ButtonClearCart />
|
|
79
|
+
<ButtonNextDynamic />
|
|
80
|
+
</CartFooter>
|
|
81
|
+
)}
|
|
82
|
+
</>
|
|
83
|
+
}
|
|
84
|
+
</div>
|
|
85
|
+
)}
|
|
86
|
+
</>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default function Cart(props: PropsCart) {
|
|
91
|
+
return (
|
|
92
|
+
<CartProvider {...props}>
|
|
93
|
+
<CartComponents footer={props.footer} />
|
|
94
|
+
</CartProvider>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
2
|
+
import { faTimes } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
import { Alert } from './components';
|
|
4
|
+
import { useCartContext } from './CartProvider';
|
|
5
|
+
|
|
6
|
+
function CartAlert() {
|
|
7
|
+
const {
|
|
8
|
+
alert,
|
|
9
|
+
classNameBtnClose,
|
|
10
|
+
setAlert,
|
|
11
|
+
} = useCartContext();
|
|
12
|
+
const { icon, message, show, title } = alert;
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
{show && (
|
|
16
|
+
<Alert alertType={alert.type}>
|
|
17
|
+
<h5>
|
|
18
|
+
{icon && <FontAwesomeIcon icon={icon} />} <strong>{title}</strong> {message}
|
|
19
|
+
</h5>
|
|
20
|
+
<button
|
|
21
|
+
type="button"
|
|
22
|
+
className={classNameBtnClose}
|
|
23
|
+
data-bs-dismiss="alert"
|
|
24
|
+
aria-label="Close"
|
|
25
|
+
onClick={() => setAlert({...alert, show: false})}
|
|
26
|
+
>
|
|
27
|
+
<FontAwesomeIcon icon={faTimes} />
|
|
28
|
+
</button>
|
|
29
|
+
</Alert>
|
|
30
|
+
)}
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default CartAlert;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
|
+
import { faShoppingCart, faTimes } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
+
import { useCartContext } from './CartProvider';
|
|
5
|
+
|
|
6
|
+
function CartHeader() {
|
|
7
|
+
const {
|
|
8
|
+
classNameCartHeader,
|
|
9
|
+
classNameBtnClose,
|
|
10
|
+
onClickClose,
|
|
11
|
+
toggleCartModal,
|
|
12
|
+
} = useCartContext();
|
|
13
|
+
return (
|
|
14
|
+
<div className={classNameCartHeader}>
|
|
15
|
+
<h5><FontAwesomeIcon icon={faShoppingCart} />{' '}Shopping cart</h5>
|
|
16
|
+
<button
|
|
17
|
+
type="button"
|
|
18
|
+
className={classNameBtnClose}
|
|
19
|
+
aria-label="Close"
|
|
20
|
+
onClick={onClickClose || toggleCartModal}
|
|
21
|
+
>
|
|
22
|
+
<FontAwesomeIcon icon={faTimes} />
|
|
23
|
+
</button>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default CartHeader;
|