@betterstore/react 0.3.5 → 0.3.6
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/CHANGELOG.md +6 -0
- package/dist/index.cjs.js +21 -16
- package/dist/index.mjs +21 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -20477,8 +20477,6 @@ function createFormControl(props = {}) {
|
|
|
20477
20477
|
array: createSubject(),
|
|
20478
20478
|
state: createSubject(),
|
|
20479
20479
|
};
|
|
20480
|
-
const validationModeBeforeSubmit = getValidationModes(_options.mode);
|
|
20481
|
-
const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
|
|
20482
20480
|
const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
|
|
20483
20481
|
const debounce = (callback) => (wait) => {
|
|
20484
20482
|
clearTimeout(timer);
|
|
@@ -20749,13 +20747,17 @@ function createFormControl(props = {}) {
|
|
|
20749
20747
|
}
|
|
20750
20748
|
else if (fieldReference.refs) {
|
|
20751
20749
|
if (isCheckBoxInput(fieldReference.ref)) {
|
|
20752
|
-
fieldReference.refs.
|
|
20753
|
-
|
|
20754
|
-
(
|
|
20755
|
-
|
|
20756
|
-
|
|
20757
|
-
|
|
20758
|
-
|
|
20750
|
+
fieldReference.refs.forEach((checkboxRef) => {
|
|
20751
|
+
if (!checkboxRef.defaultChecked || !checkboxRef.disabled) {
|
|
20752
|
+
if (Array.isArray(fieldValue)) {
|
|
20753
|
+
checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);
|
|
20754
|
+
}
|
|
20755
|
+
else {
|
|
20756
|
+
checkboxRef.checked =
|
|
20757
|
+
fieldValue === checkboxRef.value || !!fieldValue;
|
|
20758
|
+
}
|
|
20759
|
+
}
|
|
20760
|
+
});
|
|
20759
20761
|
}
|
|
20760
20762
|
else {
|
|
20761
20763
|
fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
|
|
@@ -20781,6 +20783,9 @@ function createFormControl(props = {}) {
|
|
|
20781
20783
|
};
|
|
20782
20784
|
const setValues = (name, value, options) => {
|
|
20783
20785
|
for (const fieldKey in value) {
|
|
20786
|
+
if (!value.hasOwnProperty(fieldKey)) {
|
|
20787
|
+
return;
|
|
20788
|
+
}
|
|
20784
20789
|
const fieldValue = value[fieldKey];
|
|
20785
20790
|
const fieldName = `${name}.${fieldKey}`;
|
|
20786
20791
|
const field = get(_fields, fieldName);
|
|
@@ -20837,6 +20842,8 @@ function createFormControl(props = {}) {
|
|
|
20837
20842
|
(isDateObject(fieldValue) && isNaN(fieldValue.getTime())) ||
|
|
20838
20843
|
deepEqual(fieldValue, get(_formValues, name, fieldValue));
|
|
20839
20844
|
};
|
|
20845
|
+
const validationModeBeforeSubmit = getValidationModes(_options.mode);
|
|
20846
|
+
const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
|
|
20840
20847
|
if (field) {
|
|
20841
20848
|
let error;
|
|
20842
20849
|
let isValid;
|
|
@@ -35677,16 +35684,14 @@ function CheckoutSummary({ appliedDiscounts, lineItems, shipping, tax, currency,
|
|
|
35677
35684
|
const productItem = ((_a = item.productData) === null || _a === void 0 ? void 0 : _a.selectedVariant) || item.productData;
|
|
35678
35685
|
return acc + ((_b = productItem === null || productItem === void 0 ? void 0 : productItem.priceInCents) !== null && _b !== void 0 ? _b : 0) * item.quantity;
|
|
35679
35686
|
}, 0);
|
|
35680
|
-
const shippingPrice = shipping !== null && shipping !== void 0 ? shipping : (_a = formData.shipping) === null || _a === void 0 ? void 0 : _a.price;
|
|
35681
|
-
const total = subtotal + (tax !== null && tax !== void 0 ? tax : 0) +
|
|
35682
|
-
const isShippingFree =
|
|
35687
|
+
const shippingPrice = (_b = shipping !== null && shipping !== void 0 ? shipping : (_a = formData.shipping) === null || _a === void 0 ? void 0 : _a.price) !== null && _b !== void 0 ? _b : 0;
|
|
35688
|
+
const total = subtotal + (tax !== null && tax !== void 0 ? tax : 0) + shippingPrice;
|
|
35689
|
+
const isShippingFree = subtotal > shippingPrice &&
|
|
35683
35690
|
appliedDiscounts.some((discount) => discount.discount.type === "FREE_SHIPPING");
|
|
35684
35691
|
const filteredDiscounts = appliedDiscounts.filter((discount) => discount.discount.type !== "FREE_SHIPPING");
|
|
35685
35692
|
const totalWithDiscounts = total -
|
|
35686
|
-
|
|
35687
|
-
|
|
35688
|
-
console.log(appliedDiscounts);
|
|
35689
|
-
}, [appliedDiscounts]);
|
|
35693
|
+
filteredDiscounts.reduce((acc, { amount }) => acc + amount, 0) -
|
|
35694
|
+
(isShippingFree ? 0 : shippingPrice);
|
|
35690
35695
|
return (React.createElement("div", { className: "grid gap-5" },
|
|
35691
35696
|
React.createElement("div", { className: "flex justify-between items-center" },
|
|
35692
35697
|
React.createElement("div", { onClick: () => setIsOpen(!isOpen), className: "flex items-center gap-2 cursor-pointer" },
|
package/dist/index.mjs
CHANGED
|
@@ -20454,8 +20454,6 @@ function createFormControl(props = {}) {
|
|
|
20454
20454
|
array: createSubject(),
|
|
20455
20455
|
state: createSubject(),
|
|
20456
20456
|
};
|
|
20457
|
-
const validationModeBeforeSubmit = getValidationModes(_options.mode);
|
|
20458
|
-
const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
|
|
20459
20457
|
const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
|
|
20460
20458
|
const debounce = (callback) => (wait) => {
|
|
20461
20459
|
clearTimeout(timer);
|
|
@@ -20726,13 +20724,17 @@ function createFormControl(props = {}) {
|
|
|
20726
20724
|
}
|
|
20727
20725
|
else if (fieldReference.refs) {
|
|
20728
20726
|
if (isCheckBoxInput(fieldReference.ref)) {
|
|
20729
|
-
fieldReference.refs.
|
|
20730
|
-
|
|
20731
|
-
(
|
|
20732
|
-
|
|
20733
|
-
|
|
20734
|
-
|
|
20735
|
-
|
|
20727
|
+
fieldReference.refs.forEach((checkboxRef) => {
|
|
20728
|
+
if (!checkboxRef.defaultChecked || !checkboxRef.disabled) {
|
|
20729
|
+
if (Array.isArray(fieldValue)) {
|
|
20730
|
+
checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);
|
|
20731
|
+
}
|
|
20732
|
+
else {
|
|
20733
|
+
checkboxRef.checked =
|
|
20734
|
+
fieldValue === checkboxRef.value || !!fieldValue;
|
|
20735
|
+
}
|
|
20736
|
+
}
|
|
20737
|
+
});
|
|
20736
20738
|
}
|
|
20737
20739
|
else {
|
|
20738
20740
|
fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
|
|
@@ -20758,6 +20760,9 @@ function createFormControl(props = {}) {
|
|
|
20758
20760
|
};
|
|
20759
20761
|
const setValues = (name, value, options) => {
|
|
20760
20762
|
for (const fieldKey in value) {
|
|
20763
|
+
if (!value.hasOwnProperty(fieldKey)) {
|
|
20764
|
+
return;
|
|
20765
|
+
}
|
|
20761
20766
|
const fieldValue = value[fieldKey];
|
|
20762
20767
|
const fieldName = `${name}.${fieldKey}`;
|
|
20763
20768
|
const field = get(_fields, fieldName);
|
|
@@ -20814,6 +20819,8 @@ function createFormControl(props = {}) {
|
|
|
20814
20819
|
(isDateObject(fieldValue) && isNaN(fieldValue.getTime())) ||
|
|
20815
20820
|
deepEqual(fieldValue, get(_formValues, name, fieldValue));
|
|
20816
20821
|
};
|
|
20822
|
+
const validationModeBeforeSubmit = getValidationModes(_options.mode);
|
|
20823
|
+
const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
|
|
20817
20824
|
if (field) {
|
|
20818
20825
|
let error;
|
|
20819
20826
|
let isValid;
|
|
@@ -35654,16 +35661,14 @@ function CheckoutSummary({ appliedDiscounts, lineItems, shipping, tax, currency,
|
|
|
35654
35661
|
const productItem = ((_a = item.productData) === null || _a === void 0 ? void 0 : _a.selectedVariant) || item.productData;
|
|
35655
35662
|
return acc + ((_b = productItem === null || productItem === void 0 ? void 0 : productItem.priceInCents) !== null && _b !== void 0 ? _b : 0) * item.quantity;
|
|
35656
35663
|
}, 0);
|
|
35657
|
-
const shippingPrice = shipping !== null && shipping !== void 0 ? shipping : (_a = formData.shipping) === null || _a === void 0 ? void 0 : _a.price;
|
|
35658
|
-
const total = subtotal + (tax !== null && tax !== void 0 ? tax : 0) +
|
|
35659
|
-
const isShippingFree =
|
|
35664
|
+
const shippingPrice = (_b = shipping !== null && shipping !== void 0 ? shipping : (_a = formData.shipping) === null || _a === void 0 ? void 0 : _a.price) !== null && _b !== void 0 ? _b : 0;
|
|
35665
|
+
const total = subtotal + (tax !== null && tax !== void 0 ? tax : 0) + shippingPrice;
|
|
35666
|
+
const isShippingFree = subtotal > shippingPrice &&
|
|
35660
35667
|
appliedDiscounts.some((discount) => discount.discount.type === "FREE_SHIPPING");
|
|
35661
35668
|
const filteredDiscounts = appliedDiscounts.filter((discount) => discount.discount.type !== "FREE_SHIPPING");
|
|
35662
35669
|
const totalWithDiscounts = total -
|
|
35663
|
-
|
|
35664
|
-
|
|
35665
|
-
console.log(appliedDiscounts);
|
|
35666
|
-
}, [appliedDiscounts]);
|
|
35670
|
+
filteredDiscounts.reduce((acc, { amount }) => acc + amount, 0) -
|
|
35671
|
+
(isShippingFree ? 0 : shippingPrice);
|
|
35667
35672
|
return (React__default.createElement("div", { className: "grid gap-5" },
|
|
35668
35673
|
React__default.createElement("div", { className: "flex justify-between items-center" },
|
|
35669
35674
|
React__default.createElement("div", { onClick: () => setIsOpen(!isOpen), className: "flex items-center gap-2 cursor-pointer" },
|