@plasmicpkgs/commerce 0.0.17 → 0.0.18
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 +20 -7
- 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 +20 -7
- package/dist/commerce.esm.js.map +1 -1
- package/dist/contexts.d.ts +4 -2
- package/dist/registerProductCollection.d.ts +1 -1
- package/package.json +2 -2
package/dist/commerce.esm.js
CHANGED
|
@@ -963,8 +963,6 @@ var defaultProduct = {
|
|
|
963
963
|
};
|
|
964
964
|
|
|
965
965
|
var ProductContext = /*#__PURE__*/React.createContext(undefined);
|
|
966
|
-
var CategoryContext = /*#__PURE__*/React.createContext(undefined);
|
|
967
|
-
var SliderContext = /*#__PURE__*/React.createContext(undefined);
|
|
968
966
|
function ProductProvider(_ref) {
|
|
969
967
|
var product = _ref.product,
|
|
970
968
|
children = _ref.children;
|
|
@@ -978,6 +976,9 @@ var useProduct = function useProduct() {
|
|
|
978
976
|
var product = useContext(ProductContext);
|
|
979
977
|
return product != null ? product : defaultProduct;
|
|
980
978
|
};
|
|
979
|
+
var CategoryContext = /*#__PURE__*/React.createContext(undefined);
|
|
980
|
+
var PrimaryCategoryContext = /*#__PURE__*/React.createContext(undefined); //used to render correctly the defaultValueHint in ProductCollection
|
|
981
|
+
|
|
981
982
|
function CategoryProvider(_ref2) {
|
|
982
983
|
var category = _ref2.category,
|
|
983
984
|
children = _ref2.children;
|
|
@@ -989,6 +990,10 @@ function CategoryProvider(_ref2) {
|
|
|
989
990
|
var useCategoryContext = function useCategoryContext() {
|
|
990
991
|
return useContext(CategoryContext);
|
|
991
992
|
};
|
|
993
|
+
var usePrimaryCategory = function usePrimaryCategory() {
|
|
994
|
+
return useContext(PrimaryCategoryContext);
|
|
995
|
+
};
|
|
996
|
+
var SliderContext = /*#__PURE__*/React.createContext(undefined);
|
|
992
997
|
function ProductSliderProvider(_ref3) {
|
|
993
998
|
var mediaIndex = _ref3.mediaIndex,
|
|
994
999
|
onClick = _ref3.onClick,
|
|
@@ -1668,9 +1673,11 @@ function CategoryCollection(props) {
|
|
|
1668
1673
|
return React.isValidElement(emptyMessage) ? emptyMessage : null;
|
|
1669
1674
|
}
|
|
1670
1675
|
|
|
1671
|
-
return
|
|
1676
|
+
return React.createElement(PrimaryCategoryContext.Provider, {
|
|
1677
|
+
value: firstCategoryNotEmpty != null ? firstCategoryNotEmpty : categories[0]
|
|
1678
|
+
}, noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
|
|
1672
1679
|
className: className
|
|
1673
|
-
}, renderedData);
|
|
1680
|
+
}, renderedData));
|
|
1674
1681
|
}
|
|
1675
1682
|
function registerCategoryCollection(loader, customCategoryCollectionMeta) {
|
|
1676
1683
|
var doRegisterComponent = function doRegisterComponent() {
|
|
@@ -2017,8 +2024,13 @@ var productCollectionMeta = {
|
|
|
2017
2024
|
};
|
|
2018
2025
|
})) != null ? _ctx$categories$map : [];
|
|
2019
2026
|
},
|
|
2020
|
-
|
|
2021
|
-
|
|
2027
|
+
defaultValueHint: function defaultValueHint(props, ctx) {
|
|
2028
|
+
var _ctx$categoryCtx;
|
|
2029
|
+
|
|
2030
|
+
return ctx == null ? void 0 : (_ctx$categoryCtx = ctx.categoryCtx) == null ? void 0 : _ctx$categoryCtx.name;
|
|
2031
|
+
},
|
|
2032
|
+
readOnly: function readOnly(props, ctx) {
|
|
2033
|
+
return !!(ctx != null && ctx.categoryCtx);
|
|
2022
2034
|
}
|
|
2023
2035
|
},
|
|
2024
2036
|
includeSubCategories: {
|
|
@@ -2113,13 +2125,14 @@ function ProductCollection(props) {
|
|
|
2113
2125
|
isSearchLoading = _useSearch.isLoading;
|
|
2114
2126
|
|
|
2115
2127
|
var features = useCommerceExtraFeatures();
|
|
2128
|
+
var primaryCategory = usePrimaryCategory();
|
|
2116
2129
|
|
|
2117
2130
|
if (categories && brands) {
|
|
2118
2131
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
2119
2132
|
categories: categories,
|
|
2120
2133
|
brands: brands,
|
|
2121
2134
|
features: features,
|
|
2122
|
-
|
|
2135
|
+
categoryCtx: primaryCategory
|
|
2123
2136
|
});
|
|
2124
2137
|
}
|
|
2125
2138
|
|