@plasmicpkgs/commerce 0.0.124 → 0.0.126
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/dist/commerce.cjs.development.js +82 -82
- package/dist/commerce.cjs.development.js.map +1 -1
- package/dist/commerce.cjs.production.min.js +1 -1
- package/dist/commerce.cjs.production.min.js.map +1 -1
- package/dist/commerce.esm.js +83 -83
- package/dist/commerce.esm.js.map +1 -1
- package/dist/registerAddToCartButton.d.ts +2 -2
- package/package.json +6 -7
package/dist/commerce.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import registerComponent from '@plasmicapp/host/registerComponent';
|
|
2
|
-
import React, {
|
|
3
|
-
import { useSelector, DataProvider, PlasmicCanvasContext, repeatedElement } from '@plasmicapp/host';
|
|
2
|
+
import React, { useRef, useMemo, useContext, createContext, useCallback } from 'react';
|
|
4
3
|
import { useForm, FormProvider, useFormContext, Controller } from 'react-hook-form';
|
|
5
4
|
import { useMutablePlasmicQueryData } from '@plasmicapp/query';
|
|
5
|
+
import { useSelector, DataProvider, PlasmicCanvasContext, repeatedElement } from '@plasmicapp/host';
|
|
6
6
|
import Cookies from 'js-cookie';
|
|
7
7
|
import debounce from 'debounce';
|
|
8
8
|
|
|
@@ -825,86 +825,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
825
825
|
}
|
|
826
826
|
});
|
|
827
827
|
|
|
828
|
-
var defaultProduct = {
|
|
829
|
-
id: "123456789",
|
|
830
|
-
name: "Product name",
|
|
831
|
-
description: "",
|
|
832
|
-
descriptionHtml: "\n <p>This is a <strong>placeholder</strong>.</p>\n ",
|
|
833
|
-
images: [{
|
|
834
|
-
url: "https://static1.plasmic.app/commerce/lightweight-jacket-0.png",
|
|
835
|
-
alt: "Lightweight Jacket"
|
|
836
|
-
}, {
|
|
837
|
-
url: "https://static1.plasmic.app/commerce/lightweight-jacket-1.png",
|
|
838
|
-
alt: "Lightweight Jacket"
|
|
839
|
-
}, {
|
|
840
|
-
url: "https://static1.plasmic.app/commerce/lightweight-jacket-2.png",
|
|
841
|
-
alt: "Lightweight Jacket"
|
|
842
|
-
}],
|
|
843
|
-
variants: [{
|
|
844
|
-
id: "variant1",
|
|
845
|
-
name: "Variant 1",
|
|
846
|
-
options: []
|
|
847
|
-
}, {
|
|
848
|
-
id: "variant2",
|
|
849
|
-
name: "Variant 2",
|
|
850
|
-
options: []
|
|
851
|
-
}],
|
|
852
|
-
price: {
|
|
853
|
-
value: 0,
|
|
854
|
-
currencyCode: "USD"
|
|
855
|
-
},
|
|
856
|
-
options: []
|
|
857
|
-
};
|
|
858
|
-
|
|
859
|
-
var productSelector = "currentProduct";
|
|
860
|
-
function ProductProvider(_ref) {
|
|
861
|
-
var product = _ref.product,
|
|
862
|
-
children = _ref.children;
|
|
863
|
-
var methods = useForm();
|
|
864
|
-
return React.createElement(DataProvider, {
|
|
865
|
-
name: productSelector,
|
|
866
|
-
data: product,
|
|
867
|
-
key: product.id
|
|
868
|
-
}, React.createElement(FormProvider, Object.assign({}, methods), children));
|
|
869
|
-
}
|
|
870
|
-
var useProduct = function useProduct() {
|
|
871
|
-
var product = useSelector(productSelector);
|
|
872
|
-
return product != null ? product : defaultProduct;
|
|
873
|
-
};
|
|
874
|
-
var PrimaryCategoryContext = /*#__PURE__*/React.createContext(undefined); //used to render correctly the defaultValueHint in ProductCollection
|
|
875
|
-
var categorySelector = "currentCategory";
|
|
876
|
-
function CategoryProvider(_ref2) {
|
|
877
|
-
var category = _ref2.category,
|
|
878
|
-
children = _ref2.children;
|
|
879
|
-
return React.createElement(DataProvider, {
|
|
880
|
-
name: categorySelector,
|
|
881
|
-
data: category,
|
|
882
|
-
key: category.id
|
|
883
|
-
}, children);
|
|
884
|
-
}
|
|
885
|
-
var useCategoryContext = function useCategoryContext() {
|
|
886
|
-
return useSelector(categorySelector);
|
|
887
|
-
};
|
|
888
|
-
var usePrimaryCategory = function usePrimaryCategory() {
|
|
889
|
-
return useContext(PrimaryCategoryContext);
|
|
890
|
-
};
|
|
891
|
-
var mediaSelector = "currentMedia";
|
|
892
|
-
function ProductMediaProvider(_ref3) {
|
|
893
|
-
var mediaIndex = _ref3.mediaIndex,
|
|
894
|
-
onClick = _ref3.onClick,
|
|
895
|
-
children = _ref3.children;
|
|
896
|
-
return React.createElement(DataProvider, {
|
|
897
|
-
name: mediaSelector,
|
|
898
|
-
data: mediaIndex,
|
|
899
|
-
key: mediaIndex
|
|
900
|
-
}, React.cloneElement(React.isValidElement(children) ? children : React.createElement(React.Fragment, null), {
|
|
901
|
-
onClick: onClick
|
|
902
|
-
}));
|
|
903
|
-
}
|
|
904
|
-
var useProductMediaContext = function useProductMediaContext() {
|
|
905
|
-
return useSelector(mediaSelector);
|
|
906
|
-
};
|
|
907
|
-
|
|
908
828
|
var _excluded = ["children"];
|
|
909
829
|
var Commerce = /*#__PURE__*/createContext({});
|
|
910
830
|
function CoreCommerceProvider(_ref) {
|
|
@@ -1139,6 +1059,86 @@ var useAddItem = function useAddItem() {
|
|
|
1139
1059
|
}, hook)).apply(void 0, arguments);
|
|
1140
1060
|
};
|
|
1141
1061
|
|
|
1062
|
+
var defaultProduct = {
|
|
1063
|
+
id: "123456789",
|
|
1064
|
+
name: "Product name",
|
|
1065
|
+
description: "",
|
|
1066
|
+
descriptionHtml: "\n <p>This is a <strong>placeholder</strong>.</p>\n ",
|
|
1067
|
+
images: [{
|
|
1068
|
+
url: "https://static1.plasmic.app/commerce/lightweight-jacket-0.png",
|
|
1069
|
+
alt: "Lightweight Jacket"
|
|
1070
|
+
}, {
|
|
1071
|
+
url: "https://static1.plasmic.app/commerce/lightweight-jacket-1.png",
|
|
1072
|
+
alt: "Lightweight Jacket"
|
|
1073
|
+
}, {
|
|
1074
|
+
url: "https://static1.plasmic.app/commerce/lightweight-jacket-2.png",
|
|
1075
|
+
alt: "Lightweight Jacket"
|
|
1076
|
+
}],
|
|
1077
|
+
variants: [{
|
|
1078
|
+
id: "variant1",
|
|
1079
|
+
name: "Variant 1",
|
|
1080
|
+
options: []
|
|
1081
|
+
}, {
|
|
1082
|
+
id: "variant2",
|
|
1083
|
+
name: "Variant 2",
|
|
1084
|
+
options: []
|
|
1085
|
+
}],
|
|
1086
|
+
price: {
|
|
1087
|
+
value: 0,
|
|
1088
|
+
currencyCode: "USD"
|
|
1089
|
+
},
|
|
1090
|
+
options: []
|
|
1091
|
+
};
|
|
1092
|
+
|
|
1093
|
+
var productSelector = "currentProduct";
|
|
1094
|
+
function ProductProvider(_ref) {
|
|
1095
|
+
var product = _ref.product,
|
|
1096
|
+
children = _ref.children;
|
|
1097
|
+
var methods = useForm();
|
|
1098
|
+
return React.createElement(DataProvider, {
|
|
1099
|
+
name: productSelector,
|
|
1100
|
+
data: product,
|
|
1101
|
+
key: product.id
|
|
1102
|
+
}, React.createElement(FormProvider, Object.assign({}, methods), children));
|
|
1103
|
+
}
|
|
1104
|
+
var useProduct = function useProduct() {
|
|
1105
|
+
var product = useSelector(productSelector);
|
|
1106
|
+
return product != null ? product : defaultProduct;
|
|
1107
|
+
};
|
|
1108
|
+
var PrimaryCategoryContext = /*#__PURE__*/React.createContext(undefined); //used to render correctly the defaultValueHint in ProductCollection
|
|
1109
|
+
var categorySelector = "currentCategory";
|
|
1110
|
+
function CategoryProvider(_ref2) {
|
|
1111
|
+
var category = _ref2.category,
|
|
1112
|
+
children = _ref2.children;
|
|
1113
|
+
return React.createElement(DataProvider, {
|
|
1114
|
+
name: categorySelector,
|
|
1115
|
+
data: category,
|
|
1116
|
+
key: category.id
|
|
1117
|
+
}, children);
|
|
1118
|
+
}
|
|
1119
|
+
var useCategoryContext = function useCategoryContext() {
|
|
1120
|
+
return useSelector(categorySelector);
|
|
1121
|
+
};
|
|
1122
|
+
var usePrimaryCategory = function usePrimaryCategory() {
|
|
1123
|
+
return useContext(PrimaryCategoryContext);
|
|
1124
|
+
};
|
|
1125
|
+
var mediaSelector = "currentMedia";
|
|
1126
|
+
function ProductMediaProvider(_ref3) {
|
|
1127
|
+
var mediaIndex = _ref3.mediaIndex,
|
|
1128
|
+
onClick = _ref3.onClick,
|
|
1129
|
+
children = _ref3.children;
|
|
1130
|
+
return React.createElement(DataProvider, {
|
|
1131
|
+
name: mediaSelector,
|
|
1132
|
+
data: mediaIndex,
|
|
1133
|
+
key: mediaIndex
|
|
1134
|
+
}, React.cloneElement(React.isValidElement(children) ? children : React.createElement(React.Fragment, null), {
|
|
1135
|
+
onClick: onClick
|
|
1136
|
+
}));
|
|
1137
|
+
}
|
|
1138
|
+
var useProductMediaContext = function useProductMediaContext() {
|
|
1139
|
+
return useSelector(mediaSelector);
|
|
1140
|
+
};
|
|
1141
|
+
|
|
1142
1142
|
var addToCartButtonMeta = {
|
|
1143
1143
|
name: "plasmic-commerce-add-to-cart-button",
|
|
1144
1144
|
displayName: "Add To Cart Button",
|
|
@@ -1173,7 +1173,7 @@ function AddToCartButton(props) {
|
|
|
1173
1173
|
break;
|
|
1174
1174
|
}
|
|
1175
1175
|
throw new CommerceError({
|
|
1176
|
-
message:
|
|
1176
|
+
message: "The item quantity has to be a valid integer greater than 0"
|
|
1177
1177
|
});
|
|
1178
1178
|
case 3:
|
|
1179
1179
|
if (!product) {
|