@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
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",
|
|
@@ -1554,13 +1561,6 @@ var useCategories = function useCategories(input) {
|
|
|
1554
1561
|
}, hook))(input);
|
|
1555
1562
|
};
|
|
1556
1563
|
|
|
1557
|
-
var useCommerceExtraFeatures = function useCommerceExtraFeatures() {
|
|
1558
|
-
var _useCommerce = useCommerce(),
|
|
1559
|
-
providerRef = _useCommerce.providerRef;
|
|
1560
|
-
|
|
1561
|
-
return providerRef.current.extraFeatures;
|
|
1562
|
-
};
|
|
1563
|
-
|
|
1564
1564
|
var categoryCollectionMeta = {
|
|
1565
1565
|
name: "plasmic-commerce-category-collection",
|
|
1566
1566
|
displayName: "Category Collection",
|
|
@@ -1608,8 +1608,10 @@ var categoryCollectionMeta = {
|
|
|
1608
1608
|
var _ctx$categories$map;
|
|
1609
1609
|
|
|
1610
1610
|
return (_ctx$categories$map = ctx == null ? void 0 : ctx.categories.map(function (category) {
|
|
1611
|
+
var _category$depth;
|
|
1612
|
+
|
|
1611
1613
|
return {
|
|
1612
|
-
label: category.name,
|
|
1614
|
+
label: "" + " ".repeat((_category$depth = category.depth) != null ? _category$depth : 0) + category.name,
|
|
1613
1615
|
value: category.id
|
|
1614
1616
|
};
|
|
1615
1617
|
})) != null ? _ctx$categories$map : [];
|
|
@@ -1634,7 +1636,6 @@ function CategoryCollection(props) {
|
|
|
1634
1636
|
emptyMessage = props.emptyMessage,
|
|
1635
1637
|
selectedCategory = props.category,
|
|
1636
1638
|
setControlContextData = props.setControlContextData;
|
|
1637
|
-
var features = useCommerceExtraFeatures();
|
|
1638
1639
|
var inEditor = React.useContext(PlasmicCanvasContext);
|
|
1639
1640
|
|
|
1640
1641
|
var _useCategories = useCategories(),
|
|
@@ -1643,7 +1644,6 @@ function CategoryCollection(props) {
|
|
|
1643
1644
|
|
|
1644
1645
|
var _useCategories2 = useCategories({
|
|
1645
1646
|
categoryId: selectedCategory,
|
|
1646
|
-
topologicalSort: !selectedCategory && (features == null ? void 0 : features.includeSubCategories),
|
|
1647
1647
|
addIsEmptyField: !!inEditor
|
|
1648
1648
|
}),
|
|
1649
1649
|
categories = _useCategories2.data,
|
|
@@ -1673,9 +1673,11 @@ function CategoryCollection(props) {
|
|
|
1673
1673
|
return React.isValidElement(emptyMessage) ? emptyMessage : null;
|
|
1674
1674
|
}
|
|
1675
1675
|
|
|
1676
|
-
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", {
|
|
1677
1679
|
className: className
|
|
1678
|
-
}, renderedData);
|
|
1680
|
+
}, renderedData));
|
|
1679
1681
|
}
|
|
1680
1682
|
function registerCategoryCollection(loader, customCategoryCollectionMeta) {
|
|
1681
1683
|
var doRegisterComponent = function doRegisterComponent() {
|
|
@@ -1962,6 +1964,13 @@ var useBrands = function useBrands(input) {
|
|
|
1962
1964
|
}, hook))(input);
|
|
1963
1965
|
};
|
|
1964
1966
|
|
|
1967
|
+
var useCommerceExtraFeatures = function useCommerceExtraFeatures() {
|
|
1968
|
+
var _useCommerce = useCommerce(),
|
|
1969
|
+
providerRef = _useCommerce.providerRef;
|
|
1970
|
+
|
|
1971
|
+
return providerRef.current.extraFeatures;
|
|
1972
|
+
};
|
|
1973
|
+
|
|
1965
1974
|
var productCollectionMeta = {
|
|
1966
1975
|
name: "plasmic-commerce-product-collection",
|
|
1967
1976
|
displayName: "Product Collection",
|
|
@@ -2007,14 +2016,21 @@ var productCollectionMeta = {
|
|
|
2007
2016
|
var _ctx$categories$map;
|
|
2008
2017
|
|
|
2009
2018
|
return (_ctx$categories$map = ctx == null ? void 0 : ctx.categories.map(function (category) {
|
|
2019
|
+
var _category$depth;
|
|
2020
|
+
|
|
2010
2021
|
return {
|
|
2011
|
-
label: category.name,
|
|
2022
|
+
label: "" + " ".repeat((_category$depth = category.depth) != null ? _category$depth : 0) + category.name,
|
|
2012
2023
|
value: category.id
|
|
2013
2024
|
};
|
|
2014
2025
|
})) != null ? _ctx$categories$map : [];
|
|
2015
2026
|
},
|
|
2016
|
-
|
|
2017
|
-
|
|
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);
|
|
2018
2034
|
}
|
|
2019
2035
|
},
|
|
2020
2036
|
includeSubCategories: {
|
|
@@ -2109,13 +2125,14 @@ function ProductCollection(props) {
|
|
|
2109
2125
|
isSearchLoading = _useSearch.isLoading;
|
|
2110
2126
|
|
|
2111
2127
|
var features = useCommerceExtraFeatures();
|
|
2128
|
+
var primaryCategory = usePrimaryCategory();
|
|
2112
2129
|
|
|
2113
2130
|
if (categories && brands) {
|
|
2114
2131
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
2115
2132
|
categories: categories,
|
|
2116
2133
|
brands: brands,
|
|
2117
2134
|
features: features,
|
|
2118
|
-
|
|
2135
|
+
categoryCtx: primaryCategory
|
|
2119
2136
|
});
|
|
2120
2137
|
}
|
|
2121
2138
|
|
|
@@ -2575,7 +2592,7 @@ var product = {
|
|
|
2575
2592
|
|
|
2576
2593
|
/*
|
|
2577
2594
|
Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
|
|
2578
|
-
Changes: Added CategoryImage
|
|
2595
|
+
Changes: Added CategoryImage and depth/children/parent_id to Category
|
|
2579
2596
|
*/
|
|
2580
2597
|
|
|
2581
2598
|
var site = {
|