@plasmicpkgs/commerce 0.0.15 → 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 +37 -20
- 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 +37 -20
- package/dist/commerce.esm.js.map +1 -1
- package/dist/contexts.d.ts +4 -2
- package/dist/registerProductCollection.d.ts +1 -1
- package/dist/types/site.d.ts +3 -1
- package/package.json +2 -2
|
@@ -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",
|
|
@@ -1561,13 +1568,6 @@ var useCategories = function useCategories(input) {
|
|
|
1561
1568
|
}, hook))(input);
|
|
1562
1569
|
};
|
|
1563
1570
|
|
|
1564
|
-
var useCommerceExtraFeatures = function useCommerceExtraFeatures() {
|
|
1565
|
-
var _useCommerce = useCommerce(),
|
|
1566
|
-
providerRef = _useCommerce.providerRef;
|
|
1567
|
-
|
|
1568
|
-
return providerRef.current.extraFeatures;
|
|
1569
|
-
};
|
|
1570
|
-
|
|
1571
1571
|
var categoryCollectionMeta = {
|
|
1572
1572
|
name: "plasmic-commerce-category-collection",
|
|
1573
1573
|
displayName: "Category Collection",
|
|
@@ -1615,8 +1615,10 @@ var categoryCollectionMeta = {
|
|
|
1615
1615
|
var _ctx$categories$map;
|
|
1616
1616
|
|
|
1617
1617
|
return (_ctx$categories$map = ctx == null ? void 0 : ctx.categories.map(function (category) {
|
|
1618
|
+
var _category$depth;
|
|
1619
|
+
|
|
1618
1620
|
return {
|
|
1619
|
-
label: category.name,
|
|
1621
|
+
label: "" + " ".repeat((_category$depth = category.depth) != null ? _category$depth : 0) + category.name,
|
|
1620
1622
|
value: category.id
|
|
1621
1623
|
};
|
|
1622
1624
|
})) != null ? _ctx$categories$map : [];
|
|
@@ -1641,7 +1643,6 @@ function CategoryCollection(props) {
|
|
|
1641
1643
|
emptyMessage = props.emptyMessage,
|
|
1642
1644
|
selectedCategory = props.category,
|
|
1643
1645
|
setControlContextData = props.setControlContextData;
|
|
1644
|
-
var features = useCommerceExtraFeatures();
|
|
1645
1646
|
var inEditor = React__default.useContext(host.PlasmicCanvasContext);
|
|
1646
1647
|
|
|
1647
1648
|
var _useCategories = useCategories(),
|
|
@@ -1650,7 +1651,6 @@ function CategoryCollection(props) {
|
|
|
1650
1651
|
|
|
1651
1652
|
var _useCategories2 = useCategories({
|
|
1652
1653
|
categoryId: selectedCategory,
|
|
1653
|
-
topologicalSort: !selectedCategory && (features == null ? void 0 : features.includeSubCategories),
|
|
1654
1654
|
addIsEmptyField: !!inEditor
|
|
1655
1655
|
}),
|
|
1656
1656
|
categories = _useCategories2.data,
|
|
@@ -1680,9 +1680,11 @@ function CategoryCollection(props) {
|
|
|
1680
1680
|
return React__default.isValidElement(emptyMessage) ? emptyMessage : null;
|
|
1681
1681
|
}
|
|
1682
1682
|
|
|
1683
|
-
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", {
|
|
1684
1686
|
className: className
|
|
1685
|
-
}, renderedData);
|
|
1687
|
+
}, renderedData));
|
|
1686
1688
|
}
|
|
1687
1689
|
function registerCategoryCollection(loader, customCategoryCollectionMeta) {
|
|
1688
1690
|
var doRegisterComponent = function doRegisterComponent() {
|
|
@@ -1969,6 +1971,13 @@ var useBrands = function useBrands(input) {
|
|
|
1969
1971
|
}, hook))(input);
|
|
1970
1972
|
};
|
|
1971
1973
|
|
|
1974
|
+
var useCommerceExtraFeatures = function useCommerceExtraFeatures() {
|
|
1975
|
+
var _useCommerce = useCommerce(),
|
|
1976
|
+
providerRef = _useCommerce.providerRef;
|
|
1977
|
+
|
|
1978
|
+
return providerRef.current.extraFeatures;
|
|
1979
|
+
};
|
|
1980
|
+
|
|
1972
1981
|
var productCollectionMeta = {
|
|
1973
1982
|
name: "plasmic-commerce-product-collection",
|
|
1974
1983
|
displayName: "Product Collection",
|
|
@@ -2014,14 +2023,21 @@ var productCollectionMeta = {
|
|
|
2014
2023
|
var _ctx$categories$map;
|
|
2015
2024
|
|
|
2016
2025
|
return (_ctx$categories$map = ctx == null ? void 0 : ctx.categories.map(function (category) {
|
|
2026
|
+
var _category$depth;
|
|
2027
|
+
|
|
2017
2028
|
return {
|
|
2018
|
-
label: category.name,
|
|
2029
|
+
label: "" + " ".repeat((_category$depth = category.depth) != null ? _category$depth : 0) + category.name,
|
|
2019
2030
|
value: category.id
|
|
2020
2031
|
};
|
|
2021
2032
|
})) != null ? _ctx$categories$map : [];
|
|
2022
2033
|
},
|
|
2023
|
-
|
|
2024
|
-
|
|
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);
|
|
2025
2041
|
}
|
|
2026
2042
|
},
|
|
2027
2043
|
includeSubCategories: {
|
|
@@ -2116,13 +2132,14 @@ function ProductCollection(props) {
|
|
|
2116
2132
|
isSearchLoading = _useSearch.isLoading;
|
|
2117
2133
|
|
|
2118
2134
|
var features = useCommerceExtraFeatures();
|
|
2135
|
+
var primaryCategory = usePrimaryCategory();
|
|
2119
2136
|
|
|
2120
2137
|
if (categories && brands) {
|
|
2121
2138
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
2122
2139
|
categories: categories,
|
|
2123
2140
|
brands: brands,
|
|
2124
2141
|
features: features,
|
|
2125
|
-
|
|
2142
|
+
categoryCtx: primaryCategory
|
|
2126
2143
|
});
|
|
2127
2144
|
}
|
|
2128
2145
|
|
|
@@ -2582,7 +2599,7 @@ var product = {
|
|
|
2582
2599
|
|
|
2583
2600
|
/*
|
|
2584
2601
|
Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
|
|
2585
|
-
Changes: Added CategoryImage
|
|
2602
|
+
Changes: Added CategoryImage and depth/children/parent_id to Category
|
|
2586
2603
|
*/
|
|
2587
2604
|
|
|
2588
2605
|
var site = {
|