@plasmicpkgs/commerce-swell 0.0.18 → 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-swell.cjs.development.js +38 -100
- package/dist/commerce-swell.cjs.development.js.map +1 -1
- package/dist/commerce-swell.cjs.production.min.js +1 -1
- package/dist/commerce-swell.cjs.production.min.js.map +1 -1
- package/dist/commerce-swell.esm.js +38 -100
- package/dist/commerce-swell.esm.js.map +1 -1
- package/dist/product/use-search.d.ts +3 -3
- package/package.json +3 -3
|
@@ -1613,132 +1613,70 @@ var topologicalSortForCategoryTree = function topologicalSortForCategoryTree(cat
|
|
|
1613
1613
|
|
|
1614
1614
|
var handler$4 = {
|
|
1615
1615
|
fetchOptions: {
|
|
1616
|
-
query:
|
|
1617
|
-
method:
|
|
1616
|
+
query: "products",
|
|
1617
|
+
method: "list"
|
|
1618
1618
|
},
|
|
1619
1619
|
fetcher: function fetcher(_ref) {
|
|
1620
|
-
return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1621
|
-
var input, options, fetch, sortMap, categoryId, includeSubCategories, categories, brandId, search, _input$sort, sort, count, mappedSort,
|
|
1620
|
+
return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1621
|
+
var input, options, fetch, sortMap, categoryId, includeSubCategories, categories, brandId, search, _input$sort, sort, count, mappedSort, includedCategories, _yield$fetch, products;
|
|
1622
1622
|
|
|
1623
|
-
return runtime_1.wrap(function
|
|
1623
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1624
1624
|
while (1) {
|
|
1625
|
-
switch (
|
|
1625
|
+
switch (_context.prev = _context.next) {
|
|
1626
1626
|
case 0:
|
|
1627
1627
|
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1628
|
-
sortMap = new Map([[
|
|
1629
|
-
categoryId = input.categoryId, includeSubCategories = input.includeSubCategories, categories = input.categories, brandId = input.brandId, search = input.search, _input$sort = input.sort, sort = _input$sort === void 0 ?
|
|
1628
|
+
sortMap = new Map([["latest-desc", ""], ["price-asc", "price asc"], ["price-desc", "price desc"], ["trending-desc", "popularity"]]);
|
|
1629
|
+
categoryId = input.categoryId, includeSubCategories = input.includeSubCategories, categories = input.categories, brandId = input.brandId, search = input.search, _input$sort = input.sort, sort = _input$sort === void 0 ? "latest-desc" : _input$sort, count = input.count;
|
|
1630
1630
|
mappedSort = sortMap.get(sort);
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
_fetch = /*#__PURE__*/function () {
|
|
1634
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(categoryId) {
|
|
1635
|
-
var _yield$fetch, results;
|
|
1636
|
-
|
|
1637
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1638
|
-
while (1) {
|
|
1639
|
-
switch (_context.prev = _context.next) {
|
|
1640
|
-
case 0:
|
|
1641
|
-
_context.next = 2;
|
|
1642
|
-
return fetch({
|
|
1643
|
-
query: options.query,
|
|
1644
|
-
method: options.method,
|
|
1645
|
-
variables: {
|
|
1646
|
-
category: categoryId,
|
|
1647
|
-
brand: brandId,
|
|
1648
|
-
search: search,
|
|
1649
|
-
sort: mappedSort,
|
|
1650
|
-
expand: ["variants"],
|
|
1651
|
-
limit: count
|
|
1652
|
-
}
|
|
1653
|
-
});
|
|
1654
|
-
|
|
1655
|
-
case 2:
|
|
1656
|
-
_yield$fetch = _context.sent;
|
|
1657
|
-
results = _yield$fetch.results;
|
|
1658
|
-
return _context.abrupt("return", results);
|
|
1659
|
-
|
|
1660
|
-
case 5:
|
|
1661
|
-
case "end":
|
|
1662
|
-
return _context.stop();
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
}, _callee);
|
|
1666
|
-
}));
|
|
1667
|
-
|
|
1668
|
-
return function _fetch(_x) {
|
|
1669
|
-
return _ref2.apply(this, arguments);
|
|
1670
|
-
};
|
|
1671
|
-
}();
|
|
1672
|
-
|
|
1673
|
-
if (includeSubCategories) {
|
|
1674
|
-
_context3.next = 12;
|
|
1675
|
-
break;
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
_context3.next = 9;
|
|
1679
|
-
return _fetch(categoryId);
|
|
1680
|
-
|
|
1681
|
-
case 9:
|
|
1682
|
-
products = _context3.sent;
|
|
1683
|
-
_context3.next = 16;
|
|
1684
|
-
break;
|
|
1685
|
-
|
|
1686
|
-
case 12:
|
|
1687
|
-
includedCategories = walkCategoryTree(categories == null ? void 0 : categories.find(function (category) {
|
|
1631
|
+
includedCategories = includeSubCategories ? walkCategoryTree(categories == null ? void 0 : categories.find(function (category) {
|
|
1688
1632
|
return category.id === categoryId;
|
|
1689
|
-
}), categories);
|
|
1690
|
-
|
|
1691
|
-
return
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
return _ref3.apply(this, arguments);
|
|
1709
|
-
};
|
|
1710
|
-
}()));
|
|
1711
|
-
|
|
1712
|
-
case 15:
|
|
1713
|
-
products = _context3.sent.flatMap(function (products) {
|
|
1714
|
-
return products;
|
|
1715
|
-
}).slice(0, count);
|
|
1633
|
+
}), categories) : undefined;
|
|
1634
|
+
_context.next = 7;
|
|
1635
|
+
return fetch({
|
|
1636
|
+
query: options.query,
|
|
1637
|
+
method: options.method,
|
|
1638
|
+
variables: {
|
|
1639
|
+
category: !includeSubCategories ? categoryId : undefined,
|
|
1640
|
+
brand: brandId,
|
|
1641
|
+
search: search,
|
|
1642
|
+
sort: mappedSort,
|
|
1643
|
+
expand: ["variants"],
|
|
1644
|
+
limit: count,
|
|
1645
|
+
$filters: _extends({}, includeSubCategories ? {
|
|
1646
|
+
category: includedCategories == null ? void 0 : includedCategories.map(function (c) {
|
|
1647
|
+
return c.id;
|
|
1648
|
+
})
|
|
1649
|
+
} : {})
|
|
1650
|
+
}
|
|
1651
|
+
});
|
|
1716
1652
|
|
|
1717
|
-
case
|
|
1718
|
-
|
|
1653
|
+
case 7:
|
|
1654
|
+
_yield$fetch = _context.sent;
|
|
1655
|
+
products = _yield$fetch.results;
|
|
1656
|
+
return _context.abrupt("return", {
|
|
1719
1657
|
products: products.map(function (product) {
|
|
1720
1658
|
return normalizeProduct(product);
|
|
1721
1659
|
}),
|
|
1722
1660
|
found: products.length > 0
|
|
1723
1661
|
});
|
|
1724
1662
|
|
|
1725
|
-
case
|
|
1663
|
+
case 10:
|
|
1726
1664
|
case "end":
|
|
1727
|
-
return
|
|
1665
|
+
return _context.stop();
|
|
1728
1666
|
}
|
|
1729
1667
|
}
|
|
1730
|
-
},
|
|
1668
|
+
}, _callee);
|
|
1731
1669
|
}))();
|
|
1732
1670
|
},
|
|
1733
|
-
useHook: function useHook(
|
|
1734
|
-
var useData =
|
|
1671
|
+
useHook: function useHook(_ref2) {
|
|
1672
|
+
var useData = _ref2.useData;
|
|
1735
1673
|
return function (input) {
|
|
1736
1674
|
if (input === void 0) {
|
|
1737
1675
|
input = {};
|
|
1738
1676
|
}
|
|
1739
1677
|
|
|
1740
1678
|
return useData({
|
|
1741
|
-
input: [[
|
|
1679
|
+
input: [["search", input.search], ["categoryId", input.categoryId], ["includeSubCategories", input.includeSubCategories], ["categories", input.categories], ["brandId", input.brandId], ["sort", input.sort], ["count", input.count]],
|
|
1742
1680
|
swrOptions: _extends({
|
|
1743
1681
|
revalidateOnFocus: false
|
|
1744
1682
|
}, input.swrOptions)
|