@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
|
@@ -970,8 +970,6 @@ var defaultProduct = {
|
|
|
970
970
|
};
|
|
971
971
|
|
|
972
972
|
var ProductContext = /*#__PURE__*/React__default.createContext(undefined);
|
|
973
|
-
var CategoryContext = /*#__PURE__*/React__default.createContext(undefined);
|
|
974
|
-
var SliderContext = /*#__PURE__*/React__default.createContext(undefined);
|
|
975
973
|
function ProductProvider(_ref) {
|
|
976
974
|
var product = _ref.product,
|
|
977
975
|
children = _ref.children;
|
|
@@ -985,6 +983,9 @@ var useProduct = function useProduct() {
|
|
|
985
983
|
var product = React.useContext(ProductContext);
|
|
986
984
|
return product != null ? product : defaultProduct;
|
|
987
985
|
};
|
|
986
|
+
var CategoryContext = /*#__PURE__*/React__default.createContext(undefined);
|
|
987
|
+
var PrimaryCategoryContext = /*#__PURE__*/React__default.createContext(undefined); //used to render correctly the defaultValueHint in ProductCollection
|
|
988
|
+
|
|
988
989
|
function CategoryProvider(_ref2) {
|
|
989
990
|
var category = _ref2.category,
|
|
990
991
|
children = _ref2.children;
|
|
@@ -996,6 +997,10 @@ function CategoryProvider(_ref2) {
|
|
|
996
997
|
var useCategoryContext = function useCategoryContext() {
|
|
997
998
|
return React.useContext(CategoryContext);
|
|
998
999
|
};
|
|
1000
|
+
var usePrimaryCategory = function usePrimaryCategory() {
|
|
1001
|
+
return React.useContext(PrimaryCategoryContext);
|
|
1002
|
+
};
|
|
1003
|
+
var SliderContext = /*#__PURE__*/React__default.createContext(undefined);
|
|
999
1004
|
function ProductSliderProvider(_ref3) {
|
|
1000
1005
|
var mediaIndex = _ref3.mediaIndex,
|
|
1001
1006
|
onClick = _ref3.onClick,
|
|
@@ -1498,7 +1503,9 @@ var cartMeta = {
|
|
|
1498
1503
|
options: ["Size", "Total Price"]
|
|
1499
1504
|
},
|
|
1500
1505
|
hideIfIsEmpty: {
|
|
1501
|
-
type: "boolean"
|
|
1506
|
+
type: "boolean",
|
|
1507
|
+
defaultValue: false,
|
|
1508
|
+
description: "You can hide this component if the cart is empty"
|
|
1502
1509
|
}
|
|
1503
1510
|
},
|
|
1504
1511
|
importPath: "@plasmicpkgs/commerce",
|
|
@@ -1673,9 +1680,11 @@ function CategoryCollection(props) {
|
|
|
1673
1680
|
return React__default.isValidElement(emptyMessage) ? emptyMessage : null;
|
|
1674
1681
|
}
|
|
1675
1682
|
|
|
1676
|
-
return
|
|
1683
|
+
return React__default.createElement(PrimaryCategoryContext.Provider, {
|
|
1684
|
+
value: firstCategoryNotEmpty != null ? firstCategoryNotEmpty : categories[0]
|
|
1685
|
+
}, noLayout ? React__default.createElement(React__default.Fragment, null, renderedData) : React__default.createElement("div", {
|
|
1677
1686
|
className: className
|
|
1678
|
-
}, renderedData);
|
|
1687
|
+
}, renderedData));
|
|
1679
1688
|
}
|
|
1680
1689
|
function registerCategoryCollection(loader, customCategoryCollectionMeta) {
|
|
1681
1690
|
var doRegisterComponent = function doRegisterComponent() {
|
|
@@ -2022,8 +2031,13 @@ var productCollectionMeta = {
|
|
|
2022
2031
|
};
|
|
2023
2032
|
})) != null ? _ctx$categories$map : [];
|
|
2024
2033
|
},
|
|
2025
|
-
|
|
2026
|
-
|
|
2034
|
+
defaultValueHint: function defaultValueHint(props, ctx) {
|
|
2035
|
+
var _ctx$categoryCtx;
|
|
2036
|
+
|
|
2037
|
+
return ctx == null ? void 0 : (_ctx$categoryCtx = ctx.categoryCtx) == null ? void 0 : _ctx$categoryCtx.name;
|
|
2038
|
+
},
|
|
2039
|
+
readOnly: function readOnly(props, ctx) {
|
|
2040
|
+
return !!(ctx != null && ctx.categoryCtx);
|
|
2027
2041
|
}
|
|
2028
2042
|
},
|
|
2029
2043
|
includeSubCategories: {
|
|
@@ -2118,13 +2132,14 @@ function ProductCollection(props) {
|
|
|
2118
2132
|
isSearchLoading = _useSearch.isLoading;
|
|
2119
2133
|
|
|
2120
2134
|
var features = useCommerceExtraFeatures();
|
|
2135
|
+
var primaryCategory = usePrimaryCategory();
|
|
2121
2136
|
|
|
2122
2137
|
if (categories && brands) {
|
|
2123
2138
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
2124
2139
|
categories: categories,
|
|
2125
2140
|
brands: brands,
|
|
2126
2141
|
features: features,
|
|
2127
|
-
|
|
2142
|
+
categoryCtx: primaryCategory
|
|
2128
2143
|
});
|
|
2129
2144
|
}
|
|
2130
2145
|
|