@plasmicpkgs/commerce 0.0.16 → 0.0.19
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 +23 -8
- 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 +23 -8
- 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 +3 -3
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,
|
|
@@ -1491,7 +1496,9 @@ var cartMeta = {
|
|
|
1491
1496
|
options: ["Size", "Total Price"]
|
|
1492
1497
|
},
|
|
1493
1498
|
hideIfIsEmpty: {
|
|
1494
|
-
type: "boolean"
|
|
1499
|
+
type: "boolean",
|
|
1500
|
+
defaultValue: false,
|
|
1501
|
+
description: "You can hide this component if the cart is empty"
|
|
1495
1502
|
}
|
|
1496
1503
|
},
|
|
1497
1504
|
importPath: "@plasmicpkgs/commerce",
|
|
@@ -1666,9 +1673,11 @@ function CategoryCollection(props) {
|
|
|
1666
1673
|
return React.isValidElement(emptyMessage) ? emptyMessage : null;
|
|
1667
1674
|
}
|
|
1668
1675
|
|
|
1669
|
-
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", {
|
|
1670
1679
|
className: className
|
|
1671
|
-
}, renderedData);
|
|
1680
|
+
}, renderedData));
|
|
1672
1681
|
}
|
|
1673
1682
|
function registerCategoryCollection(loader, customCategoryCollectionMeta) {
|
|
1674
1683
|
var doRegisterComponent = function doRegisterComponent() {
|
|
@@ -2015,8 +2024,13 @@ var productCollectionMeta = {
|
|
|
2015
2024
|
};
|
|
2016
2025
|
})) != null ? _ctx$categories$map : [];
|
|
2017
2026
|
},
|
|
2018
|
-
|
|
2019
|
-
|
|
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);
|
|
2020
2034
|
}
|
|
2021
2035
|
},
|
|
2022
2036
|
includeSubCategories: {
|
|
@@ -2111,13 +2125,14 @@ function ProductCollection(props) {
|
|
|
2111
2125
|
isSearchLoading = _useSearch.isLoading;
|
|
2112
2126
|
|
|
2113
2127
|
var features = useCommerceExtraFeatures();
|
|
2128
|
+
var primaryCategory = usePrimaryCategory();
|
|
2114
2129
|
|
|
2115
2130
|
if (categories && brands) {
|
|
2116
2131
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
2117
2132
|
categories: categories,
|
|
2118
2133
|
brands: brands,
|
|
2119
2134
|
features: features,
|
|
2120
|
-
|
|
2135
|
+
categoryCtx: primaryCategory
|
|
2121
2136
|
});
|
|
2122
2137
|
}
|
|
2123
2138
|
|