@plasmicpkgs/commerce 0.0.11 → 0.0.14

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.
@@ -2,8 +2,8 @@ import registerComponent from '@plasmicapp/host/registerComponent';
2
2
  import React, { useContext, useRef, useMemo, createContext, useCallback } from 'react';
3
3
  import { useForm, FormProvider, useFormContext, Controller } from 'react-hook-form';
4
4
  import useSWR from 'swr';
5
- import { repeatedElement, usePlasmicCanvasContext } from '@plasmicapp/host';
6
5
  import Cookies from 'js-cookie';
6
+ import { PlasmicCanvasContext, repeatedElement } from '@plasmicapp/host';
7
7
 
8
8
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
9
9
  try {
@@ -964,6 +964,7 @@ var defaultProduct = {
964
964
 
965
965
  var ProductContext = /*#__PURE__*/React.createContext(undefined);
966
966
  var CategoryContext = /*#__PURE__*/React.createContext(undefined);
967
+ var SliderContext = /*#__PURE__*/React.createContext(undefined);
967
968
  function ProductProvider(_ref) {
968
969
  var product = _ref.product,
969
970
  children = _ref.children;
@@ -988,6 +989,20 @@ function CategoryProvider(_ref2) {
988
989
  var useCategoryContext = function useCategoryContext() {
989
990
  return useContext(CategoryContext);
990
991
  };
992
+ function ProductSliderProvider(_ref3) {
993
+ var mediaIndex = _ref3.mediaIndex,
994
+ onClick = _ref3.onClick,
995
+ children = _ref3.children;
996
+ return React.createElement(SliderContext.Provider, {
997
+ value: mediaIndex,
998
+ key: mediaIndex
999
+ }, React.cloneElement(React.isValidElement(children) ? children : React.createElement(React.Fragment, null), {
1000
+ onClick: onClick
1001
+ }));
1002
+ }
1003
+ var useProductSliderContext = function useProductSliderContext() {
1004
+ return useContext(SliderContext);
1005
+ };
991
1006
 
992
1007
  var _excluded = ["children"];
993
1008
  var Commerce = /*#__PURE__*/createContext({});
@@ -1333,143 +1348,209 @@ function registerAddToCartButton(loader, customAddToCartButtonMeta) {
1333
1348
  doRegisterComponent(AddToCartButton, customAddToCartButtonMeta != null ? customAddToCartButtonMeta : addToCartButtonMeta);
1334
1349
  }
1335
1350
 
1336
- var fetcher$1 = SWRFetcher;
1351
+ var fetcher$1 = /*#__PURE__*/function () {
1352
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
1353
+ var options, cartId, fetch;
1354
+ return runtime_1.wrap(function _callee$(_context) {
1355
+ while (1) {
1356
+ switch (_context.prev = _context.next) {
1357
+ case 0:
1358
+ options = _ref.options, cartId = _ref.input.cartId, fetch = _ref.fetch;
1359
+
1360
+ if (!cartId) {
1361
+ _context.next = 7;
1362
+ break;
1363
+ }
1364
+
1365
+ _context.next = 4;
1366
+ return fetch(options);
1367
+
1368
+ case 4:
1369
+ _context.t0 = _context.sent;
1370
+ _context.next = 8;
1371
+ break;
1372
+
1373
+ case 7:
1374
+ _context.t0 = null;
1375
+
1376
+ case 8:
1377
+ return _context.abrupt("return", _context.t0);
1378
+
1379
+ case 9:
1380
+ case "end":
1381
+ return _context.stop();
1382
+ }
1383
+ }
1384
+ }, _callee);
1385
+ }));
1386
+
1387
+ return function fetcher(_x) {
1388
+ return _ref2.apply(this, arguments);
1389
+ };
1390
+ }();
1337
1391
 
1338
1392
  var fn$1 = function fn(provider) {
1339
- var _provider$products;
1393
+ var _provider$cart;
1340
1394
 
1341
- return (_provider$products = provider.products) == null ? void 0 : _provider$products.useProduct;
1395
+ return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useCart;
1342
1396
  };
1343
1397
 
1344
- var useProduct$1 = function useProduct(input) {
1398
+ var useCart = function useCart(input) {
1399
+ var _hook$fetcher;
1400
+
1345
1401
  var hook = useHook(fn$1);
1346
- return useSWRHook(_extends({
1347
- fetcher: fetcher$1
1348
- }, hook))(input);
1402
+
1403
+ var _useCommerce = useCommerce(),
1404
+ cartCookie = _useCommerce.cartCookie;
1405
+
1406
+ var fetcherFn = (_hook$fetcher = hook.fetcher) != null ? _hook$fetcher : fetcher$1;
1407
+
1408
+ var wrapper = function wrapper(context) {
1409
+ context.input.cartId = Cookies.get(cartCookie);
1410
+ return fetcherFn(context);
1411
+ };
1412
+
1413
+ return useSWRHook(_extends({}, hook, {
1414
+ fetcher: wrapper
1415
+ }))(input);
1349
1416
  };
1350
1417
 
1351
- var productBoxMeta = {
1352
- name: "plasmic-commerce-product-box",
1353
- displayName: "Product Box",
1418
+ /*
1419
+ Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
1420
+ Changes: None
1421
+ */
1422
+ function formatPrice(_ref) {
1423
+ var amount = _ref.amount,
1424
+ currencyCode = _ref.currencyCode,
1425
+ locale = _ref.locale;
1426
+ var formatCurrency = new Intl.NumberFormat(locale, {
1427
+ style: 'currency',
1428
+ currency: currencyCode
1429
+ });
1430
+ return formatCurrency.format(amount);
1431
+ }
1432
+ function formatVariantPrice(_ref2) {
1433
+ var amount = _ref2.amount,
1434
+ baseAmount = _ref2.baseAmount,
1435
+ currencyCode = _ref2.currencyCode,
1436
+ locale = _ref2.locale;
1437
+ var hasDiscount = baseAmount > amount;
1438
+ var formatDiscount = new Intl.NumberFormat(locale, {
1439
+ style: 'percent'
1440
+ });
1441
+ var discount = hasDiscount ? formatDiscount.format((baseAmount - amount) / baseAmount) : null;
1442
+ var price = formatPrice({
1443
+ amount: amount,
1444
+ currencyCode: currencyCode,
1445
+ locale: locale
1446
+ });
1447
+ var basePrice = hasDiscount ? formatPrice({
1448
+ amount: baseAmount,
1449
+ currencyCode: currencyCode,
1450
+ locale: locale
1451
+ }) : null;
1452
+ return {
1453
+ price: price,
1454
+ basePrice: basePrice,
1455
+ discount: discount
1456
+ };
1457
+ }
1458
+ function usePrice(data) {
1459
+ var _ref3 = data != null ? data : {},
1460
+ amount = _ref3.amount,
1461
+ baseAmount = _ref3.baseAmount,
1462
+ currencyCode = _ref3.currencyCode;
1463
+
1464
+ var _useCommerce = useCommerce(),
1465
+ locale = _useCommerce.locale;
1466
+
1467
+ var value = useMemo(function () {
1468
+ if (typeof amount !== 'number' || !currencyCode) return '';
1469
+ return baseAmount ? formatVariantPrice({
1470
+ amount: amount,
1471
+ baseAmount: baseAmount,
1472
+ currencyCode: currencyCode,
1473
+ locale: locale
1474
+ }) : formatPrice({
1475
+ amount: amount,
1476
+ currencyCode: currencyCode,
1477
+ locale: locale
1478
+ });
1479
+ }, [amount, baseAmount, currencyCode]);
1480
+ return typeof value === 'string' ? {
1481
+ price: value
1482
+ } : value;
1483
+ }
1484
+
1485
+ var cartMeta = {
1486
+ name: "plasmic-commerce-cart",
1487
+ displayName: "Cart",
1354
1488
  props: {
1355
- children: {
1356
- type: "slot",
1357
- defaultValue: [{
1358
- type: "vbox",
1359
- children: [{
1360
- type: "component",
1361
- name: "plasmic-commerce-product-text-field",
1362
- props: {
1363
- field: "name"
1364
- }
1365
- }, {
1366
- type: "component",
1367
- name: "plasmic-commerce-product-media"
1368
- }],
1369
- styles: {
1370
- width: "100%",
1371
- minWidth: 0
1372
- }
1373
- }]
1489
+ field: {
1490
+ type: "choice",
1491
+ options: ["Size", "Total Price"]
1374
1492
  },
1375
- noLayout: "boolean",
1376
- id: {
1377
- type: "string",
1378
- description: "Fetch a product by its slug or ID"
1493
+ hideIfIsEmpty: {
1494
+ type: "boolean"
1379
1495
  }
1380
1496
  },
1381
1497
  importPath: "@plasmicpkgs/commerce",
1382
- importName: "ProductBox"
1498
+ importName: "CartComponent"
1383
1499
  };
1384
- function ProductBox(props) {
1500
+ function CartComponent(props) {
1501
+ var _data$totalPrice, _data$currency$code;
1502
+
1385
1503
  var className = props.className,
1386
- children = props.children,
1387
- noLayout = props.noLayout,
1388
- id = props.id;
1504
+ field = props.field,
1505
+ hideIfIsEmpty = props.hideIfIsEmpty;
1389
1506
 
1390
- var _useProduct = useProduct$1({
1391
- id: id
1507
+ var _useCart = useCart(),
1508
+ data = _useCart.data;
1509
+
1510
+ var _usePrice = usePrice({
1511
+ amount: (_data$totalPrice = data == null ? void 0 : data.totalPrice) != null ? _data$totalPrice : 0,
1512
+ currencyCode: (_data$currency$code = data == null ? void 0 : data.currency.code) != null ? _data$currency$code : "USD"
1392
1513
  }),
1393
- data = _useProduct.data,
1394
- error = _useProduct.error,
1395
- isLoading = _useProduct.isLoading;
1514
+ price = _usePrice.price;
1396
1515
 
1397
- if (!id) {
1398
- return React.createElement("span", null, "You must set the id prop");
1516
+ if (!field) {
1517
+ return React.createElement("p", null, "You must set the field prop");
1399
1518
  }
1400
1519
 
1401
- if (error) {
1402
- throw new CommerceError({
1403
- message: error.message,
1404
- code: error.code
1405
- });
1406
- }
1520
+ var value;
1407
1521
 
1408
- if (isLoading) {
1409
- return React.createElement("span", null, "Loading...");
1410
- }
1522
+ if (field === "Size") {
1523
+ var _data$lineItems$lengt;
1411
1524
 
1412
- if (!data) {
1413
- throw new Error("Product not found!");
1525
+ value = (_data$lineItems$lengt = data == null ? void 0 : data.lineItems.length) != null ? _data$lineItems$lengt : 0;
1526
+ } else if (field === "Total Price") {
1527
+ value = price != null ? price : 0;
1414
1528
  }
1415
1529
 
1416
- var renderedData = React.createElement(ProductProvider, {
1417
- product: data
1418
- }, children);
1419
- return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
1530
+ return hideIfIsEmpty && value === 0 ? null : React.createElement("span", {
1420
1531
  className: className
1421
- }, renderedData);
1532
+ }, value);
1422
1533
  }
1423
- function registerProductBox(loader, customProductBoxMeta) {
1534
+ function registerCart(loader, customCartMeta) {
1424
1535
  var doRegisterComponent = function doRegisterComponent() {
1425
1536
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1426
1537
  };
1427
1538
 
1428
- doRegisterComponent(ProductBox, customProductBoxMeta != null ? customProductBoxMeta : productBoxMeta);
1539
+ doRegisterComponent(CartComponent, customCartMeta != null ? customCartMeta : cartMeta);
1429
1540
  }
1430
1541
 
1431
1542
  var fetcher$2 = SWRFetcher;
1432
1543
 
1433
1544
  var fn$2 = function fn(provider) {
1434
- var _provider$products;
1435
-
1436
- return (_provider$products = provider.products) == null ? void 0 : _provider$products.useSearch;
1437
- };
1438
-
1439
- var useSearch = function useSearch(input) {
1440
- var hook = useHook(fn$2);
1441
- return useSWRHook(_extends({
1442
- fetcher: fetcher$2
1443
- }, hook))(input);
1444
- };
1445
-
1446
- var fetcher$3 = SWRFetcher;
1447
-
1448
- var fn$3 = function fn(provider) {
1449
1545
  var _provider$site;
1450
1546
 
1451
1547
  return (_provider$site = provider.site) == null ? void 0 : _provider$site.useCategories;
1452
1548
  };
1453
1549
 
1454
1550
  var useCategories = function useCategories(input) {
1455
- var hook = useHook(fn$3);
1456
- return useSWRHook(_extends({
1457
- fetcher: fetcher$3
1458
- }, hook))(input);
1459
- };
1460
-
1461
- var fetcher$4 = SWRFetcher;
1462
-
1463
- var fn$4 = function fn(provider) {
1464
- var _provider$site;
1465
-
1466
- return (_provider$site = provider.site) == null ? void 0 : _provider$site.useBrands;
1467
- };
1468
-
1469
- var useBrands = function useBrands(input) {
1470
- var hook = useHook(fn$4);
1551
+ var hook = useHook(fn$2);
1471
1552
  return useSWRHook(_extends({
1472
- fetcher: fetcher$4
1553
+ fetcher: fetcher$2
1473
1554
  }, hook))(input);
1474
1555
  };
1475
1556
 
@@ -1480,9 +1561,9 @@ var useCommerceExtraFeatures = function useCommerceExtraFeatures() {
1480
1561
  return providerRef.current.extraFeatures;
1481
1562
  };
1482
1563
 
1483
- var productCollectionMeta = {
1484
- name: "plasmic-commerce-product-collection",
1485
- displayName: "Product Collection",
1564
+ var categoryCollectionMeta = {
1565
+ name: "plasmic-commerce-category-collection",
1566
+ displayName: "Category Collection",
1486
1567
  props: {
1487
1568
  children: {
1488
1569
  type: "slot",
@@ -1490,13 +1571,13 @@ var productCollectionMeta = {
1490
1571
  type: "vbox",
1491
1572
  children: [{
1492
1573
  type: "component",
1493
- name: "plasmic-commerce-product-text-field",
1574
+ name: "plasmic-commerce-category-field",
1494
1575
  props: {
1495
1576
  field: "name"
1496
1577
  }
1497
1578
  }, {
1498
1579
  type: "component",
1499
- name: "plasmic-commerce-product-media"
1580
+ name: "plasmic-commerce-product-collection"
1500
1581
  }],
1501
1582
  styles: {
1502
1583
  width: "100%",
@@ -1504,11 +1585,14 @@ var productCollectionMeta = {
1504
1585
  }
1505
1586
  }]
1506
1587
  },
1588
+ noLayout: {
1589
+ type: "boolean"
1590
+ },
1507
1591
  emptyMessage: {
1508
1592
  type: "slot",
1509
1593
  defaultValue: {
1510
1594
  type: "text",
1511
- value: "No product found!"
1595
+ value: "No collection found!"
1512
1596
  }
1513
1597
  },
1514
1598
  loadingMessage: {
@@ -1518,7 +1602,6 @@ var productCollectionMeta = {
1518
1602
  value: "Loading..."
1519
1603
  }
1520
1604
  },
1521
- count: "number",
1522
1605
  category: {
1523
1606
  type: "choice",
1524
1607
  options: function options(props, ctx) {
@@ -1530,102 +1613,63 @@ var productCollectionMeta = {
1530
1613
  value: category.id
1531
1614
  };
1532
1615
  })) != null ? _ctx$categories$map : [];
1533
- },
1534
- hidden: function hidden(props, ctx) {
1535
- return !!(ctx != null && ctx.hasCategoryCtx);
1536
- }
1537
- },
1538
- includeSubCategories: {
1539
- type: "boolean",
1540
- hidden: function hidden(props, ctx) {
1541
- var _ctx$features;
1542
-
1543
- return !(ctx != null && (_ctx$features = ctx.features) != null && _ctx$features.includeSubCategories);
1544
- }
1545
- },
1546
- brand: {
1547
- type: "choice",
1548
- options: function options(props, ctx) {
1549
- var _ctx$brands$map;
1550
-
1551
- return (_ctx$brands$map = ctx == null ? void 0 : ctx.brands.map(function (brand) {
1552
- return {
1553
- label: brand.name,
1554
- value: brand.entityId
1555
- };
1556
- })) != null ? _ctx$brands$map : [];
1557
1616
  }
1558
- },
1559
- noLayout: "boolean"
1617
+ }
1560
1618
  },
1561
1619
  defaultStyles: {
1562
1620
  display: "grid",
1563
- gridTemplateColumns: "1fr 1fr 1fr 1fr",
1621
+ gridTemplateColumns: "1fr",
1564
1622
  gridRowGap: "8px",
1565
- gridColumnGap: "8px",
1566
1623
  padding: "8px",
1567
1624
  maxWidth: "100%"
1568
1625
  },
1569
1626
  importPath: "@plasmicpkgs/commerce",
1570
- importName: "ProductCollection"
1627
+ importName: "CategoryCollection"
1571
1628
  };
1572
- function ProductCollection(props) {
1573
- var _categoryCtx$id;
1574
-
1575
- var className = props.className,
1576
- children = props.children,
1577
- count = props.count,
1578
- category = props.category,
1579
- includeSubCategories = props.includeSubCategories,
1580
- brand = props.brand,
1629
+ function CategoryCollection(props) {
1630
+ var children = props.children,
1581
1631
  noLayout = props.noLayout,
1582
- setControlContextData = props.setControlContextData,
1632
+ className = props.className,
1633
+ loadingMessage = props.loadingMessage,
1583
1634
  emptyMessage = props.emptyMessage,
1584
- loadingMessage = props.loadingMessage;
1635
+ selectedCategory = props.category,
1636
+ setControlContextData = props.setControlContextData;
1637
+ var features = useCommerceExtraFeatures();
1638
+ var inEditor = React.useContext(PlasmicCanvasContext);
1585
1639
 
1586
1640
  var _useCategories = useCategories(),
1587
- categories = _useCategories.data,
1588
- isCategoriesLoading = _useCategories.isLoading;
1589
-
1590
- var _useBrands = useBrands(),
1591
- brands = _useBrands.data,
1592
- isBrandsLoading = _useBrands.isLoading;
1593
-
1594
- var categoryCtx = useCategoryContext();
1641
+ allCategories = _useCategories.data,
1642
+ isAllCategoriesLoading = _useCategories.isLoading;
1595
1643
 
1596
- var _useSearch = useSearch({
1597
- categoryId: (_categoryCtx$id = categoryCtx == null ? void 0 : categoryCtx.id) != null ? _categoryCtx$id : category,
1598
- brandId: brand,
1599
- count: count,
1600
- categories: categories != null ? categories : [],
1601
- includeSubCategories: includeSubCategories
1644
+ var _useCategories2 = useCategories({
1645
+ categoryId: selectedCategory,
1646
+ topologicalSort: !selectedCategory && (features == null ? void 0 : features.includeSubCategories),
1647
+ addIsEmptyField: !!inEditor
1602
1648
  }),
1603
- data = _useSearch.data,
1604
- isSearchLoading = _useSearch.isLoading;
1605
-
1606
- var features = useCommerceExtraFeatures();
1649
+ categories = _useCategories2.data,
1650
+ isLoading = _useCategories2.isLoading;
1607
1651
 
1608
- if (categories && brands) {
1652
+ if (allCategories) {
1609
1653
  setControlContextData == null ? void 0 : setControlContextData({
1610
- categories: categories,
1611
- brands: brands,
1612
- features: features,
1613
- hasCategoryCtx: !!categoryCtx
1654
+ categories: allCategories
1614
1655
  });
1615
1656
  }
1616
1657
 
1617
- var renderedData = data == null ? void 0 : data.products.map(function (product, i) {
1618
- return React.createElement(ProductProvider, {
1619
- product: product,
1620
- key: product.id
1621
- }, repeatedElement(i === 0, children));
1658
+ var firstCategoryNotEmpty = categories == null ? void 0 : categories.find(function (category) {
1659
+ return !category.isEmpty;
1660
+ });
1661
+ var renderedData = categories == null ? void 0 : categories.map(function (category, i) {
1662
+ return React.createElement(CategoryProvider, {
1663
+ category: category,
1664
+ key: category.id
1665
+ }, repeatedElement(firstCategoryNotEmpty ? category === firstCategoryNotEmpty : i === 0, children));
1622
1666
  });
1623
1667
 
1624
- if ([isSearchLoading, isBrandsLoading, isCategoriesLoading].includes(true)) {
1668
+ if ([isAllCategoriesLoading, isLoading].includes(true)) {
1625
1669
  return React.isValidElement(loadingMessage) ? loadingMessage : null;
1626
1670
  }
1627
1671
 
1628
- if (!data || data.products.length === 0) {
1672
+ if (!categories || categories.length === 0) {
1629
1673
  return React.isValidElement(emptyMessage) ? emptyMessage : null;
1630
1674
  }
1631
1675
 
@@ -1633,38 +1677,72 @@ function ProductCollection(props) {
1633
1677
  className: className
1634
1678
  }, renderedData);
1635
1679
  }
1636
- function registerProductCollection(loader, customProductCollectionMeta) {
1680
+ function registerCategoryCollection(loader, customCategoryCollectionMeta) {
1637
1681
  var doRegisterComponent = function doRegisterComponent() {
1638
1682
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1639
1683
  };
1640
1684
 
1641
- doRegisterComponent(ProductCollection, customProductCollectionMeta != null ? customProductCollectionMeta : productCollectionMeta);
1685
+ doRegisterComponent(CategoryCollection, customCategoryCollectionMeta != null ? customCategoryCollectionMeta : categoryCollectionMeta);
1642
1686
  }
1643
1687
 
1644
- var productLinkMeta = {
1645
- name: "plasmic-commerce-product-link",
1646
- displayName: "Product Link",
1688
+ var categoryFieldMeta = {
1689
+ name: "plasmic-commerce-category-field",
1690
+ displayName: "Category Field",
1691
+ props: {
1692
+ field: {
1693
+ type: "choice",
1694
+ options: ["id", "name", "slug", "path"]
1695
+ }
1696
+ },
1697
+ importPath: "@plasmicpkgs/commerce",
1698
+ importName: "CategoryField"
1699
+ };
1700
+ function CategoryField(props) {
1701
+ var className = props.className,
1702
+ field = props.field;
1703
+ var category = useCategoryContext();
1704
+
1705
+ if (!field) {
1706
+ return React.createElement("span", null, "You must set the field prop");
1707
+ }
1708
+
1709
+ var data = category ? category[field] : "Category field placeholder";
1710
+ return React.createElement("span", {
1711
+ className: className
1712
+ }, data);
1713
+ }
1714
+ function registerCategoryField(loader, customCategoryFieldMeta) {
1715
+ var doRegisterComponent = function doRegisterComponent() {
1716
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1717
+ };
1718
+
1719
+ doRegisterComponent(CategoryField, customCategoryFieldMeta != null ? customCategoryFieldMeta : categoryFieldMeta);
1720
+ }
1721
+
1722
+ var categoryLinkMeta = {
1723
+ name: "plasmic-commerce-category-link",
1724
+ displayName: "Category Link",
1647
1725
  props: {
1648
1726
  children: "slot",
1649
1727
  linkDest: {
1650
1728
  type: "string",
1651
- defaultValueHint: "products/{slug}",
1652
- description: "Set the link destination. You can use {slug} to replace by the product slug"
1729
+ defaultValueHint: "category/{slug}",
1730
+ description: "Set the link destination. You can use {slug} to replace by the category slug"
1653
1731
  }
1654
1732
  },
1655
1733
  importPath: "@plasmicpkgs/commerce",
1656
- importName: "ProductLink"
1734
+ importName: "CategoryLink"
1657
1735
  };
1658
- function ProductLink(props) {
1736
+ function CategoryLink(props) {
1659
1737
  var className = props.className,
1660
1738
  children = props.children,
1661
1739
  linkDest = props.linkDest;
1662
- var product = useProduct();
1740
+ var category = useCategoryContext();
1663
1741
 
1664
1742
  var resolveLink = function resolveLink(linkDest) {
1665
1743
  var _linkDest$match;
1666
1744
 
1667
- if (!product || !linkDest) {
1745
+ if (!linkDest) {
1668
1746
  return undefined;
1669
1747
  }
1670
1748
 
@@ -1677,11 +1755,11 @@ function ProductLink(props) {
1677
1755
  var match = _step.value;
1678
1756
  var field = match.slice(1, -1);
1679
1757
 
1680
- if (!(field in product)) {
1758
+ if (!category || !(field in category)) {
1681
1759
  return undefined;
1682
1760
  }
1683
1761
 
1684
- resolvedLink = resolvedLink.replace(regex, product[field]);
1762
+ resolvedLink = resolvedLink.replace(regex, category[field]);
1685
1763
  }
1686
1764
 
1687
1765
  return resolvedLink;
@@ -1696,580 +1774,716 @@ function ProductLink(props) {
1696
1774
  }
1697
1775
  }, children);
1698
1776
  }
1699
- function registerProductLink(loader, customProductLinkMeta) {
1777
+ function registerCategoryLink(loader, customCategoryLinkMeta) {
1700
1778
  var doRegisterComponent = function doRegisterComponent() {
1701
1779
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1702
1780
  };
1703
1781
 
1704
- doRegisterComponent(ProductLink, customProductLinkMeta != null ? customProductLinkMeta : productLinkMeta);
1782
+ doRegisterComponent(CategoryLink, customCategoryLinkMeta != null ? customCategoryLinkMeta : categoryLinkMeta);
1705
1783
  }
1706
1784
 
1707
- var placeholderImage = "https://static1.plasmic.app/commerce/lightweight-jacket-0.png";
1708
- var productMediaMeta = {
1709
- name: "plasmic-commerce-product-media",
1710
- displayName: "Product Media",
1785
+ var categoryMediaMeta = {
1786
+ name: "plasmic-commerce-category-media",
1787
+ displayName: "Category Media",
1711
1788
  props: {
1712
1789
  mediaIndex: "number"
1713
1790
  },
1714
1791
  importPath: "@plasmicpkgs/commerce",
1715
- importName: "ProductMedia"
1792
+ importName: "CategoryMedia"
1716
1793
  };
1717
- function ProductMedia(props) {
1794
+ function CategoryMedia(props) {
1718
1795
  var _image$url;
1719
1796
 
1720
1797
  var className = props.className,
1721
1798
  _props$mediaIndex = props.mediaIndex,
1722
1799
  mediaIndex = _props$mediaIndex === void 0 ? 0 : _props$mediaIndex;
1723
- var product = useProduct();
1724
- var image = product == null ? void 0 : product.images[mediaIndex];
1800
+ var category = useCategoryContext();
1801
+ var image = category != null && category.images ? category.images[mediaIndex] : undefined;
1725
1802
  return React.createElement("img", {
1726
- alt: (product == null ? void 0 : product.name) || 'Product Image',
1727
- src: product ? (_image$url = image == null ? void 0 : image.url) != null ? _image$url : "" : placeholderImage,
1728
- loading: 'lazy',
1803
+ alt: (category == null ? void 0 : category.name) || "Category Image",
1804
+ src: (_image$url = image == null ? void 0 : image.url) != null ? _image$url : "",
1805
+ loading: "lazy",
1729
1806
  className: className
1730
1807
  });
1731
1808
  }
1732
- function registerProductMedia(loader, customProductMediaMeta) {
1809
+ function registerCategoryMedia(loader, customCategoryMediaMeta) {
1733
1810
  var doRegisterComponent = function doRegisterComponent() {
1734
1811
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1735
1812
  };
1736
1813
 
1737
- doRegisterComponent(ProductMedia, customProductMediaMeta != null ? customProductMediaMeta : productMediaMeta);
1738
- }
1739
-
1740
- /*
1741
- Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
1742
- Changes: None
1743
- */
1744
- function formatPrice(_ref) {
1745
- var amount = _ref.amount,
1746
- currencyCode = _ref.currencyCode,
1747
- locale = _ref.locale;
1748
- var formatCurrency = new Intl.NumberFormat(locale, {
1749
- style: 'currency',
1750
- currency: currencyCode
1751
- });
1752
- return formatCurrency.format(amount);
1753
- }
1754
- function formatVariantPrice(_ref2) {
1755
- var amount = _ref2.amount,
1756
- baseAmount = _ref2.baseAmount,
1757
- currencyCode = _ref2.currencyCode,
1758
- locale = _ref2.locale;
1759
- var hasDiscount = baseAmount > amount;
1760
- var formatDiscount = new Intl.NumberFormat(locale, {
1761
- style: 'percent'
1762
- });
1763
- var discount = hasDiscount ? formatDiscount.format((baseAmount - amount) / baseAmount) : null;
1764
- var price = formatPrice({
1765
- amount: amount,
1766
- currencyCode: currencyCode,
1767
- locale: locale
1768
- });
1769
- var basePrice = hasDiscount ? formatPrice({
1770
- amount: baseAmount,
1771
- currencyCode: currencyCode,
1772
- locale: locale
1773
- }) : null;
1774
- return {
1775
- price: price,
1776
- basePrice: basePrice,
1777
- discount: discount
1778
- };
1814
+ doRegisterComponent(CategoryMedia, customCategoryMediaMeta != null ? customCategoryMediaMeta : categoryMediaMeta);
1779
1815
  }
1780
- function usePrice(data) {
1781
- var _ref3 = data != null ? data : {},
1782
- amount = _ref3.amount,
1783
- baseAmount = _ref3.baseAmount,
1784
- currencyCode = _ref3.currencyCode;
1785
1816
 
1786
- var _useCommerce = useCommerce(),
1787
- locale = _useCommerce.locale;
1817
+ var fetcher$3 = SWRFetcher;
1788
1818
 
1789
- var value = useMemo(function () {
1790
- if (typeof amount !== 'number' || !currencyCode) return '';
1791
- return baseAmount ? formatVariantPrice({
1792
- amount: amount,
1793
- baseAmount: baseAmount,
1794
- currencyCode: currencyCode,
1795
- locale: locale
1796
- }) : formatPrice({
1797
- amount: amount,
1798
- currencyCode: currencyCode,
1799
- locale: locale
1800
- });
1801
- }, [amount, baseAmount, currencyCode]);
1802
- return typeof value === 'string' ? {
1803
- price: value
1804
- } : value;
1805
- }
1819
+ var fn$3 = function fn(provider) {
1820
+ var _provider$products;
1806
1821
 
1807
- var getProductPrice = function getProductPrice(product, variantId) {
1808
- var _product$variants$fin, _product$variants$fin2;
1822
+ return (_provider$products = provider.products) == null ? void 0 : _provider$products.useProduct;
1823
+ };
1809
1824
 
1810
- return (_product$variants$fin = (_product$variants$fin2 = product.variants.find(function (variant) {
1811
- return variant.id === variantId;
1812
- })) == null ? void 0 : _product$variants$fin2.price) != null ? _product$variants$fin : product.price.value;
1825
+ var useProduct$1 = function useProduct(input) {
1826
+ var hook = useHook(fn$3);
1827
+ return useSWRHook(_extends({
1828
+ fetcher: fetcher$3
1829
+ }, hook))(input);
1813
1830
  };
1814
1831
 
1815
- var productPriceMeta = {
1816
- name: "plasmic-commerce-product-price",
1817
- displayName: "Product Price",
1818
- props: {},
1832
+ var productBoxMeta = {
1833
+ name: "plasmic-commerce-product-box",
1834
+ displayName: "Product Box",
1835
+ props: {
1836
+ children: {
1837
+ type: "slot",
1838
+ defaultValue: [{
1839
+ type: "vbox",
1840
+ children: [{
1841
+ type: "component",
1842
+ name: "plasmic-commerce-product-text-field",
1843
+ props: {
1844
+ field: "name"
1845
+ }
1846
+ }, {
1847
+ type: "component",
1848
+ name: "plasmic-commerce-product-media"
1849
+ }],
1850
+ styles: {
1851
+ width: "100%",
1852
+ minWidth: 0
1853
+ }
1854
+ }]
1855
+ },
1856
+ noLayout: "boolean",
1857
+ id: {
1858
+ type: "string",
1859
+ description: "Fetch a product by its slug or ID"
1860
+ }
1861
+ },
1819
1862
  importPath: "@plasmicpkgs/commerce",
1820
- importName: "ProductPrice"
1863
+ importName: "ProductBox"
1821
1864
  };
1822
- function ProductPriceComponent(props) {
1823
- var _product$variants$0$i;
1824
-
1825
- var className = props.className;
1826
- var product = useProduct();
1827
- var form = useFormContext();
1828
- var watchProductVariant = form == null ? void 0 : form.watch("ProductVariant", (_product$variants$0$i = product.variants[0].id) != null ? _product$variants$0$i : "");
1865
+ function ProductBox(props) {
1866
+ var className = props.className,
1867
+ children = props.children,
1868
+ noLayout = props.noLayout,
1869
+ id = props.id;
1829
1870
 
1830
- var _usePrice = usePrice({
1831
- amount: product ? getProductPrice(product, watchProductVariant) : 0,
1832
- currencyCode: product ? product.price.currencyCode : 'USD'
1871
+ var _useProduct = useProduct$1({
1872
+ id: id
1833
1873
  }),
1834
- price = _usePrice.price;
1874
+ data = _useProduct.data,
1875
+ error = _useProduct.error,
1876
+ isLoading = _useProduct.isLoading;
1835
1877
 
1836
- return React.createElement("span", {
1878
+ if (!id) {
1879
+ return React.createElement("span", null, "You must set the id prop");
1880
+ }
1881
+
1882
+ if (error) {
1883
+ throw new CommerceError({
1884
+ message: error.message,
1885
+ code: error.code
1886
+ });
1887
+ }
1888
+
1889
+ if (isLoading) {
1890
+ return React.createElement("span", null, "Loading...");
1891
+ }
1892
+
1893
+ if (!data) {
1894
+ throw new Error("Product not found!");
1895
+ }
1896
+
1897
+ var renderedData = React.createElement(ProductProvider, {
1898
+ product: data
1899
+ }, children);
1900
+ return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
1837
1901
  className: className
1838
- }, price);
1902
+ }, renderedData);
1839
1903
  }
1840
- function registerProductPrice(loader, customProductPriceMeta) {
1904
+ function registerProductBox(loader, customProductBoxMeta) {
1841
1905
  var doRegisterComponent = function doRegisterComponent() {
1842
1906
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1843
1907
  };
1844
1908
 
1845
- doRegisterComponent(ProductPriceComponent, customProductPriceMeta != null ? customProductPriceMeta : productPriceMeta);
1909
+ doRegisterComponent(ProductBox, customProductBoxMeta != null ? customProductBoxMeta : productBoxMeta);
1846
1910
  }
1847
1911
 
1848
- var productQuantityMeta = {
1849
- name: "plasmic-commerce-product-quantity",
1850
- displayName: "Product Quantity",
1912
+ var fetcher$4 = SWRFetcher;
1913
+
1914
+ var fn$4 = function fn(provider) {
1915
+ var _provider$products;
1916
+
1917
+ return (_provider$products = provider.products) == null ? void 0 : _provider$products.useSearch;
1918
+ };
1919
+
1920
+ var useSearch = function useSearch(input) {
1921
+ var hook = useHook(fn$4);
1922
+ return useSWRHook(_extends({
1923
+ fetcher: fetcher$4
1924
+ }, hook))(input);
1925
+ };
1926
+
1927
+ var fetcher$5 = SWRFetcher;
1928
+
1929
+ var fn$5 = function fn(provider) {
1930
+ var _provider$site;
1931
+
1932
+ return (_provider$site = provider.site) == null ? void 0 : _provider$site.useBrands;
1933
+ };
1934
+
1935
+ var useBrands = function useBrands(input) {
1936
+ var hook = useHook(fn$5);
1937
+ return useSWRHook(_extends({
1938
+ fetcher: fetcher$5
1939
+ }, hook))(input);
1940
+ };
1941
+
1942
+ var productCollectionMeta = {
1943
+ name: "plasmic-commerce-product-collection",
1944
+ displayName: "Product Collection",
1851
1945
  props: {
1852
1946
  children: {
1853
1947
  type: "slot",
1854
1948
  defaultValue: [{
1855
- type: "input",
1856
- attrs: {
1857
- value: "1"
1949
+ type: "vbox",
1950
+ children: [{
1951
+ type: "component",
1952
+ name: "plasmic-commerce-product-text-field",
1953
+ props: {
1954
+ field: "name"
1955
+ }
1956
+ }, {
1957
+ type: "component",
1958
+ name: "plasmic-commerce-product-media"
1959
+ }],
1960
+ styles: {
1961
+ width: "100%",
1962
+ minWidth: 0
1858
1963
  }
1859
1964
  }]
1860
- }
1965
+ },
1966
+ emptyMessage: {
1967
+ type: "slot",
1968
+ defaultValue: {
1969
+ type: "text",
1970
+ value: "No product found!"
1971
+ }
1972
+ },
1973
+ loadingMessage: {
1974
+ type: "slot",
1975
+ defaultValue: {
1976
+ type: "text",
1977
+ value: "Loading..."
1978
+ }
1979
+ },
1980
+ count: "number",
1981
+ category: {
1982
+ type: "choice",
1983
+ options: function options(props, ctx) {
1984
+ var _ctx$categories$map;
1985
+
1986
+ return (_ctx$categories$map = ctx == null ? void 0 : ctx.categories.map(function (category) {
1987
+ return {
1988
+ label: category.name,
1989
+ value: category.id
1990
+ };
1991
+ })) != null ? _ctx$categories$map : [];
1992
+ },
1993
+ hidden: function hidden(props, ctx) {
1994
+ return !!(ctx != null && ctx.hasCategoryCtx);
1995
+ }
1996
+ },
1997
+ includeSubCategories: {
1998
+ type: "boolean",
1999
+ hidden: function hidden(props, ctx) {
2000
+ var _ctx$features;
2001
+
2002
+ return !(ctx != null && (_ctx$features = ctx.features) != null && _ctx$features.includeSubCategories);
2003
+ }
2004
+ },
2005
+ brand: {
2006
+ type: "choice",
2007
+ options: function options(props, ctx) {
2008
+ var _ctx$brands$map;
2009
+
2010
+ return (_ctx$brands$map = ctx == null ? void 0 : ctx.brands.map(function (brand) {
2011
+ return {
2012
+ label: brand.name,
2013
+ value: brand.entityId
2014
+ };
2015
+ })) != null ? _ctx$brands$map : [];
2016
+ }
2017
+ },
2018
+ search: {
2019
+ type: "string"
2020
+ },
2021
+ sort: {
2022
+ type: "choice",
2023
+ options: [{
2024
+ label: "Trending",
2025
+ value: "trending-desc"
2026
+ }, {
2027
+ label: "New Arrivals",
2028
+ value: "latest-desc"
2029
+ }, {
2030
+ label: "Price: Low to High",
2031
+ value: "price-asc"
2032
+ }, {
2033
+ label: "Price: High to Low",
2034
+ value: "price-desc"
2035
+ }]
2036
+ },
2037
+ noLayout: "boolean"
2038
+ },
2039
+ defaultStyles: {
2040
+ display: "grid",
2041
+ gridTemplateColumns: "1fr 1fr 1fr 1fr",
2042
+ gridRowGap: "8px",
2043
+ gridColumnGap: "8px",
2044
+ padding: "8px",
2045
+ maxWidth: "100%"
1861
2046
  },
1862
2047
  importPath: "@plasmicpkgs/commerce",
1863
- importName: "ProductQuantity"
2048
+ importName: "ProductCollection"
1864
2049
  };
1865
- function ProductQuantity(props) {
2050
+ function ProductCollection(props) {
2051
+ var _categoryCtx$id;
2052
+
1866
2053
  var className = props.className,
1867
- children = props.children;
1868
- var form = useFormContext();
1869
- return React.createElement("div", {
2054
+ children = props.children,
2055
+ count = props.count,
2056
+ category = props.category,
2057
+ includeSubCategories = props.includeSubCategories,
2058
+ brand = props.brand,
2059
+ noLayout = props.noLayout,
2060
+ setControlContextData = props.setControlContextData,
2061
+ emptyMessage = props.emptyMessage,
2062
+ loadingMessage = props.loadingMessage,
2063
+ search = props.search,
2064
+ sort = props.sort;
2065
+
2066
+ var _useCategories = useCategories(),
2067
+ categories = _useCategories.data,
2068
+ isCategoriesLoading = _useCategories.isLoading;
2069
+
2070
+ var _useBrands = useBrands(),
2071
+ brands = _useBrands.data,
2072
+ isBrandsLoading = _useBrands.isLoading;
2073
+
2074
+ var categoryCtx = useCategoryContext();
2075
+
2076
+ var _useSearch = useSearch({
2077
+ categoryId: (_categoryCtx$id = categoryCtx == null ? void 0 : categoryCtx.id) != null ? _categoryCtx$id : category,
2078
+ brandId: brand,
2079
+ count: count,
2080
+ categories: categories != null ? categories : [],
2081
+ includeSubCategories: includeSubCategories,
2082
+ search: search,
2083
+ sort: sort
2084
+ }),
2085
+ data = _useSearch.data,
2086
+ isSearchLoading = _useSearch.isLoading;
2087
+
2088
+ var features = useCommerceExtraFeatures();
2089
+
2090
+ if (categories && brands) {
2091
+ setControlContextData == null ? void 0 : setControlContextData({
2092
+ categories: categories,
2093
+ brands: brands,
2094
+ features: features,
2095
+ hasCategoryCtx: !!categoryCtx
2096
+ });
2097
+ }
2098
+
2099
+ var renderedData = data == null ? void 0 : data.products.map(function (product, i) {
2100
+ return React.createElement(ProductProvider, {
2101
+ product: product,
2102
+ key: product.id
2103
+ }, repeatedElement(i === 0, children));
2104
+ });
2105
+
2106
+ if ([isSearchLoading, isBrandsLoading, isCategoriesLoading].includes(true)) {
2107
+ return React.isValidElement(loadingMessage) ? loadingMessage : null;
2108
+ }
2109
+
2110
+ if (!data || data.products.length === 0) {
2111
+ return React.isValidElement(emptyMessage) ? emptyMessage : null;
2112
+ }
2113
+
2114
+ return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
1870
2115
  className: className
1871
- }, React.createElement(Controller, {
1872
- name: "ProductQuantity",
1873
- defaultValue: 1,
1874
- control: form == null ? void 0 : form.control,
1875
- render: function render(_ref) {
1876
- var field = _ref.field;
1877
- return React.isValidElement(children) ? React.cloneElement(children, _extends({}, children.props, field, {
1878
- name: "ProductQuantity"
1879
- })) : React.createElement(React.Fragment, null);
1880
- }
1881
- }));
2116
+ }, renderedData);
1882
2117
  }
1883
- function registerProductQuantity(loader, customProductQuantityMeta) {
2118
+ function registerProductCollection(loader, customProductCollectionMeta) {
1884
2119
  var doRegisterComponent = function doRegisterComponent() {
1885
2120
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1886
2121
  };
1887
2122
 
1888
- doRegisterComponent(ProductQuantity, customProductQuantityMeta != null ? customProductQuantityMeta : productQuantityMeta);
2123
+ doRegisterComponent(ProductCollection, customProductCollectionMeta != null ? customProductCollectionMeta : productCollectionMeta);
1889
2124
  }
1890
2125
 
1891
- var productTextFieldMeta = {
1892
- name: "plasmic-commerce-product-text-field",
1893
- displayName: "Product Text Field",
2126
+ var productLinkMeta = {
2127
+ name: "plasmic-commerce-product-link",
2128
+ displayName: "Product Link",
1894
2129
  props: {
1895
- field: {
1896
- type: "choice",
1897
- options: ["id", "name", "description", "sku", "slug", "path"]
2130
+ children: "slot",
2131
+ linkDest: {
2132
+ type: "string",
2133
+ defaultValueHint: "products/{slug}",
2134
+ description: "Set the link destination. You can use {slug} to replace by the product slug"
1898
2135
  }
1899
2136
  },
1900
2137
  importPath: "@plasmicpkgs/commerce",
1901
- importName: "ProductTextField"
2138
+ importName: "ProductLink"
1902
2139
  };
1903
- function ProductTextField(props) {
2140
+ function ProductLink(props) {
1904
2141
  var className = props.className,
1905
- field = props.field;
2142
+ children = props.children,
2143
+ linkDest = props.linkDest;
1906
2144
  var product = useProduct();
1907
2145
 
1908
- if (!product) {
1909
- return React.createElement("span", {
1910
- className: className
1911
- }, "Fake Product Field");
1912
- }
2146
+ var resolveLink = function resolveLink(linkDest) {
2147
+ var _linkDest$match;
1913
2148
 
1914
- if (!field) {
1915
- return React.createElement("span", {
1916
- className: className
1917
- }, "Unknown Product Field");
1918
- }
2149
+ if (!linkDest) {
2150
+ return undefined;
2151
+ }
1919
2152
 
1920
- var value;
2153
+ var regex = /{[^}]*}/;
2154
+ var regexAll = new RegExp(regex, "g");
2155
+ var matches = (_linkDest$match = linkDest.match(regexAll)) != null ? _linkDest$match : [];
2156
+ var resolvedLink = linkDest;
1921
2157
 
1922
- if (field === "description") {
1923
- return product.descriptionHtml ? React.createElement("div", {
1924
- className: className,
1925
- dangerouslySetInnerHTML: {
1926
- __html: product.descriptionHtml
2158
+ for (var _iterator = _createForOfIteratorHelperLoose(matches), _step; !(_step = _iterator()).done;) {
2159
+ var match = _step.value;
2160
+ var field = match.slice(1, -1);
2161
+
2162
+ if (!product || !(field in product)) {
2163
+ return undefined;
1927
2164
  }
1928
- }) : React.createElement("div", {
1929
- className: className
1930
- }, product.description);
1931
- } else {
1932
- value = product[field];
1933
- }
1934
2165
 
1935
- return React.createElement("span", {
1936
- className: className
1937
- }, value);
2166
+ resolvedLink = resolvedLink.replace(regex, product[field]);
2167
+ }
2168
+
2169
+ return resolvedLink;
2170
+ };
2171
+
2172
+ return React.createElement("a", {
2173
+ className: className,
2174
+ href: resolveLink(linkDest),
2175
+ style: {
2176
+ color: "inherit",
2177
+ textDecoration: "inherit"
2178
+ }
2179
+ }, children);
1938
2180
  }
1939
- function registerTextField(loader, customProductTextFieldMeta) {
2181
+ function registerProductLink(loader, customProductLinkMeta) {
1940
2182
  var doRegisterComponent = function doRegisterComponent() {
1941
2183
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1942
2184
  };
1943
2185
 
1944
- doRegisterComponent(ProductTextField, customProductTextFieldMeta != null ? customProductTextFieldMeta : productTextFieldMeta);
2186
+ doRegisterComponent(ProductLink, customProductLinkMeta != null ? customProductLinkMeta : productLinkMeta);
1945
2187
  }
1946
2188
 
1947
- var productVariantPickerMeta = {
1948
- name: "plasmic-commerce-product-variant-picker",
1949
- displayName: "Product Variant Picker",
1950
- props: {},
2189
+ var placeholderImage = "https://static1.plasmic.app/commerce/lightweight-jacket-0.png";
2190
+ var productMediaMeta = {
2191
+ name: "plasmic-commerce-product-media",
2192
+ displayName: "Product Media",
2193
+ props: {
2194
+ mediaIndex: "number"
2195
+ },
1951
2196
  importPath: "@plasmicpkgs/commerce",
1952
- importName: "ProductVariantPicker"
2197
+ importName: "ProductMedia"
1953
2198
  };
1954
- function ProductVariantPicker(props) {
1955
- var _useFormContext;
2199
+ function ProductMedia(props) {
2200
+ var _image$url;
1956
2201
 
1957
- var className = props.className;
2202
+ var className = props.className,
2203
+ _props$mediaIndex = props.mediaIndex,
2204
+ mediaIndex = _props$mediaIndex === void 0 ? 0 : _props$mediaIndex;
1958
2205
  var product = useProduct();
1959
- var form = (_useFormContext = useFormContext()) != null ? _useFormContext : useForm();
1960
- return React.createElement(Controller, {
1961
- name: "ProductVariant",
1962
- control: form == null ? void 0 : form.control,
1963
- defaultValue: product == null ? void 0 : product.variants[0].id,
1964
- render: function render(_ref) {
1965
- var _product$variants$map;
1966
-
1967
- var field = _ref.field;
1968
- return React.createElement("select", Object.assign({
1969
- className: className
1970
- }, field), (_product$variants$map = product == null ? void 0 : product.variants.map(function (variant) {
1971
- return React.createElement("option", {
1972
- value: variant.id
1973
- }, variant.name);
1974
- })) != null ? _product$variants$map : React.createElement("option", null, "Product Variant Placeholder"));
1975
- }
2206
+ var sliderContext = useProductSliderContext();
2207
+ var image = product == null ? void 0 : product.images[sliderContext != null ? sliderContext : mediaIndex];
2208
+ return React.createElement("img", {
2209
+ alt: (product == null ? void 0 : product.name) || "Product Image",
2210
+ src: product ? (_image$url = image == null ? void 0 : image.url) != null ? _image$url : "" : placeholderImage,
2211
+ loading: "lazy",
2212
+ className: className
1976
2213
  });
1977
2214
  }
1978
- function registerProductVariantPicker(loader, customProductVariantPickerMeta) {
2215
+ function registerProductMedia(loader, customProductMediaMeta) {
1979
2216
  var doRegisterComponent = function doRegisterComponent() {
1980
2217
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1981
2218
  };
1982
2219
 
1983
- doRegisterComponent(ProductVariantPicker, customProductVariantPickerMeta != null ? customProductVariantPickerMeta : productVariantPickerMeta);
2220
+ doRegisterComponent(ProductMedia, customProductMediaMeta != null ? customProductMediaMeta : productMediaMeta);
1984
2221
  }
1985
2222
 
1986
- var fetcher$5 = /*#__PURE__*/function () {
1987
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
1988
- var options, cartId, fetch;
1989
- return runtime_1.wrap(function _callee$(_context) {
1990
- while (1) {
1991
- switch (_context.prev = _context.next) {
1992
- case 0:
1993
- options = _ref.options, cartId = _ref.input.cartId, fetch = _ref.fetch;
1994
-
1995
- if (!cartId) {
1996
- _context.next = 7;
1997
- break;
1998
- }
1999
-
2000
- _context.next = 4;
2001
- return fetch(options);
2002
-
2003
- case 4:
2004
- _context.t0 = _context.sent;
2005
- _context.next = 8;
2006
- break;
2007
-
2008
- case 7:
2009
- _context.t0 = null;
2010
-
2011
- case 8:
2012
- return _context.abrupt("return", _context.t0);
2013
-
2014
- case 9:
2015
- case "end":
2016
- return _context.stop();
2017
- }
2018
- }
2019
- }, _callee);
2020
- }));
2021
-
2022
- return function fetcher(_x) {
2023
- return _ref2.apply(this, arguments);
2024
- };
2025
- }();
2026
-
2027
- var fn$5 = function fn(provider) {
2028
- var _provider$cart;
2029
-
2030
- return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useCart;
2031
- };
2032
-
2033
- var useCart = function useCart(input) {
2034
- var _hook$fetcher;
2035
-
2036
- var hook = useHook(fn$5);
2037
-
2038
- var _useCommerce = useCommerce(),
2039
- cartCookie = _useCommerce.cartCookie;
2040
-
2041
- var fetcherFn = (_hook$fetcher = hook.fetcher) != null ? _hook$fetcher : fetcher$5;
2042
-
2043
- var wrapper = function wrapper(context) {
2044
- context.input.cartId = Cookies.get(cartCookie);
2045
- return fetcherFn(context);
2046
- };
2223
+ var getProductPrice = function getProductPrice(product, variantId) {
2224
+ var _product$variants$fin, _product$variants$fin2;
2047
2225
 
2048
- return useSWRHook(_extends({}, hook, {
2049
- fetcher: wrapper
2050
- }))(input);
2226
+ return (_product$variants$fin = (_product$variants$fin2 = product.variants.find(function (variant) {
2227
+ return variant.id === variantId;
2228
+ })) == null ? void 0 : _product$variants$fin2.price) != null ? _product$variants$fin : product.price.value;
2051
2229
  };
2052
2230
 
2053
- var cartMeta = {
2054
- name: "plasmic-commerce-cart",
2055
- displayName: "Cart",
2056
- props: {
2057
- field: {
2058
- type: "choice",
2059
- options: ["Size", "Total Price"]
2060
- },
2061
- hideIfIsEmpty: {
2062
- type: "boolean"
2063
- }
2064
- },
2231
+ var productPriceMeta = {
2232
+ name: "plasmic-commerce-product-price",
2233
+ displayName: "Product Price",
2234
+ props: {},
2065
2235
  importPath: "@plasmicpkgs/commerce",
2066
- importName: "Cart"
2236
+ importName: "ProductPriceComponent"
2067
2237
  };
2068
- function CartComponent(props) {
2069
- var _data$totalPrice, _data$currency$code;
2070
-
2071
- var className = props.className,
2072
- field = props.field,
2073
- hideIfIsEmpty = props.hideIfIsEmpty;
2074
-
2075
- var _useCart = useCart(),
2076
- data = _useCart.data;
2077
-
2078
- var _usePrice = usePrice({
2079
- amount: (_data$totalPrice = data == null ? void 0 : data.totalPrice) != null ? _data$totalPrice : 0,
2080
- currencyCode: (_data$currency$code = data == null ? void 0 : data.currency.code) != null ? _data$currency$code : "USD"
2081
- }),
2082
- price = _usePrice.price;
2083
-
2084
- if (!field) {
2085
- return React.createElement("p", null, "You must set the field prop");
2086
- }
2087
-
2088
- var value;
2238
+ function ProductPriceComponent(props) {
2239
+ var _product$price;
2089
2240
 
2090
- if (field === "Size") {
2091
- var _data$lineItems$lengt;
2241
+ var className = props.className;
2242
+ var product = useProduct();
2243
+ var form = useFormContext();
2244
+ var watchProductVariant = form == null ? void 0 : form.watch("ProductVariant", (_product$price = product.price) != null ? _product$price : "");
2092
2245
 
2093
- value = (_data$lineItems$lengt = data == null ? void 0 : data.lineItems.length) != null ? _data$lineItems$lengt : 0;
2094
- } else if (field === "Total Price") {
2095
- value = price != null ? price : 0;
2096
- }
2246
+ var _usePrice = usePrice({
2247
+ amount: product ? getProductPrice(product, watchProductVariant) : 0,
2248
+ currencyCode: product ? product.price.currencyCode : "USD"
2249
+ }),
2250
+ price = _usePrice.price;
2097
2251
 
2098
- return hideIfIsEmpty && value === 0 ? null : React.createElement("span", {
2252
+ return React.createElement("span", {
2099
2253
  className: className
2100
- }, value);
2254
+ }, price);
2101
2255
  }
2102
- function registerCart(loader, customCartMeta) {
2256
+ function registerProductPrice(loader, customProductPriceMeta) {
2103
2257
  var doRegisterComponent = function doRegisterComponent() {
2104
2258
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2105
2259
  };
2106
2260
 
2107
- doRegisterComponent(CartComponent, customCartMeta != null ? customCartMeta : cartMeta);
2261
+ doRegisterComponent(ProductPriceComponent, customProductPriceMeta != null ? customProductPriceMeta : productPriceMeta);
2108
2262
  }
2109
2263
 
2110
- var categoryCollectionMeta = {
2111
- name: "plasmic-commerce-category-collection",
2112
- displayName: "Category Collection",
2264
+ var productQuantityMeta = {
2265
+ name: "plasmic-commerce-product-quantity",
2266
+ displayName: "Product Quantity",
2113
2267
  props: {
2114
2268
  children: {
2115
2269
  type: "slot",
2116
2270
  defaultValue: [{
2117
- type: "vbox",
2118
- children: [{
2119
- type: "component",
2120
- name: "plasmic-commerce-category-field",
2121
- props: {
2122
- field: "name"
2123
- }
2124
- }, {
2125
- type: "component",
2126
- name: "plasmic-commerce-product-collection"
2127
- }],
2128
- styles: {
2129
- width: "100%",
2130
- minWidth: 0
2271
+ type: "input",
2272
+ attrs: {
2273
+ value: "1"
2131
2274
  }
2132
2275
  }]
2276
+ }
2277
+ },
2278
+ importPath: "@plasmicpkgs/commerce",
2279
+ importName: "ProductQuantity"
2280
+ };
2281
+ function ProductQuantity(props) {
2282
+ var className = props.className,
2283
+ children = props.children;
2284
+ var form = useFormContext();
2285
+ return React.createElement("div", {
2286
+ className: className
2287
+ }, React.createElement(Controller, {
2288
+ name: "ProductQuantity",
2289
+ defaultValue: 1,
2290
+ control: form == null ? void 0 : form.control,
2291
+ render: function render(_ref) {
2292
+ var field = _ref.field;
2293
+ return React.isValidElement(children) ? React.cloneElement(children, _extends({}, children.props, field, {
2294
+ name: "ProductQuantity"
2295
+ })) : React.createElement(React.Fragment, null);
2296
+ }
2297
+ }));
2298
+ }
2299
+ function registerProductQuantity(loader, customProductQuantityMeta) {
2300
+ var doRegisterComponent = function doRegisterComponent() {
2301
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2302
+ };
2303
+
2304
+ doRegisterComponent(ProductQuantity, customProductQuantityMeta != null ? customProductQuantityMeta : productQuantityMeta);
2305
+ }
2306
+
2307
+ var productSliderMeta = {
2308
+ name: "plasmic-commerce-product-slider",
2309
+ displayName: "Product Slider",
2310
+ props: {
2311
+ thumbsVisible: {
2312
+ type: "number",
2313
+ description: "Number of thumbs visible",
2314
+ defaultValue: 4,
2315
+ defaultValueHint: 4
2133
2316
  },
2134
- noLayout: {
2135
- type: "boolean"
2136
- },
2137
- emptyMessage: {
2317
+ slideContainer: {
2138
2318
  type: "slot",
2139
2319
  defaultValue: {
2140
- type: "text",
2141
- value: "No collection found!"
2320
+ type: "vbox",
2321
+ children: [{
2322
+ type: "component",
2323
+ name: "plasmic-commerce-product-media"
2324
+ }]
2142
2325
  }
2143
2326
  },
2144
- loadingMessage: {
2327
+ thumbsContainer: {
2145
2328
  type: "slot",
2146
2329
  defaultValue: {
2147
- type: "text",
2148
- value: "Loading..."
2330
+ type: "hbox",
2331
+ children: [{
2332
+ type: "component",
2333
+ name: "plasmic-commerce-product-media"
2334
+ }]
2149
2335
  }
2150
2336
  },
2151
- category: {
2152
- type: "choice",
2153
- options: function options(props, ctx) {
2154
- var _ctx$categories$map;
2155
-
2156
- return (_ctx$categories$map = ctx == null ? void 0 : ctx.categories.map(function (category) {
2157
- return {
2158
- label: category.name,
2159
- value: category.id
2160
- };
2161
- })) != null ? _ctx$categories$map : [];
2162
- }
2337
+ slideSelected: {
2338
+ type: "number",
2339
+ defaultValue: 0,
2340
+ defaultValueHint: 0,
2341
+ description: "Current slide selected"
2163
2342
  }
2164
2343
  },
2165
- defaultStyles: {
2166
- display: "grid",
2167
- gridTemplateColumns: "1fr",
2168
- gridRowGap: "8px",
2169
- padding: "8px",
2170
- maxWidth: "100%"
2171
- },
2172
2344
  importPath: "@plasmicpkgs/commerce",
2173
- importName: "CategoryCollection"
2345
+ importName: "ProductSlider"
2174
2346
  };
2175
- function CategoryCollection(props) {
2176
- var children = props.children,
2177
- noLayout = props.noLayout,
2178
- className = props.className,
2179
- loadingMessage = props.loadingMessage,
2180
- emptyMessage = props.emptyMessage,
2181
- selectedCategory = props.category,
2182
- setControlContextData = props.setControlContextData;
2183
- var features = useCommerceExtraFeatures();
2184
- var inEditor = usePlasmicCanvasContext();
2185
-
2186
- var _useCategories = useCategories(),
2187
- allCategories = _useCategories.data,
2188
- isAllCategoriesLoading = _useCategories.isLoading;
2189
-
2190
- var _useCategories2 = useCategories({
2191
- categoryId: selectedCategory,
2192
- topologicalSort: !selectedCategory && (features == null ? void 0 : features.includeSubCategories),
2193
- addIsEmptyField: !!inEditor
2194
- }),
2195
- categories = _useCategories2.data,
2196
- isLoading = _useCategories2.isLoading;
2197
-
2198
- if (allCategories) {
2199
- setControlContextData == null ? void 0 : setControlContextData({
2200
- categories: allCategories
2201
- });
2202
- }
2203
-
2204
- var firstCategoryNotEmpty = categories == null ? void 0 : categories.find(function (category) {
2205
- return !category.isEmpty;
2206
- });
2207
- var renderedData = categories == null ? void 0 : categories.map(function (category, i) {
2208
- return React.createElement(CategoryProvider, {
2209
- category: category,
2210
- key: category.id
2211
- }, repeatedElement(firstCategoryNotEmpty ? category === firstCategoryNotEmpty : i === 0, children));
2212
- });
2213
-
2214
- if ([isAllCategoriesLoading, isLoading].includes(true)) {
2215
- return React.isValidElement(loadingMessage) ? loadingMessage : null;
2216
- }
2347
+ function ProductSlider(props) {
2348
+ var className = props.className,
2349
+ slideContainer = props.slideContainer,
2350
+ thumbsContainer = props.thumbsContainer,
2351
+ _props$thumbsVisible = props.thumbsVisible,
2352
+ thumbsVisible = _props$thumbsVisible === void 0 ? 4 : _props$thumbsVisible,
2353
+ _props$slideSelected = props.slideSelected,
2354
+ slideSelected = _props$slideSelected === void 0 ? 0 : _props$slideSelected;
2355
+ var product = useProduct();
2217
2356
 
2218
- if (!categories || categories.length === 0) {
2219
- return React.isValidElement(emptyMessage) ? emptyMessage : null;
2220
- }
2357
+ var _React$useState = React.useState(slideSelected),
2358
+ selected = _React$useState[0],
2359
+ setSelected = _React$useState[1];
2221
2360
 
2222
- return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
2361
+ var maximumRight = product.images.length - thumbsVisible;
2362
+ var leftIndex = Math.min(maximumRight, Math.max(0, selected - 1));
2363
+ return React.createElement("div", {
2223
2364
  className: className
2224
- }, renderedData);
2365
+ }, React.createElement(ProductSliderProvider, {
2366
+ mediaIndex: selected,
2367
+ children: slideContainer
2368
+ }), React.createElement("div", {
2369
+ style: {
2370
+ display: "grid",
2371
+ gridTemplateColumns: "repeat(" + thumbsVisible + ", 1fr)"
2372
+ }
2373
+ }, product.images.slice(leftIndex, leftIndex + thumbsVisible).map(function (image, i) {
2374
+ return repeatedElement(i === 0, React.createElement(ProductSliderProvider, {
2375
+ mediaIndex: leftIndex + i,
2376
+ children: thumbsContainer,
2377
+ onClick: function onClick() {
2378
+ return setSelected(leftIndex + i);
2379
+ }
2380
+ }));
2381
+ })));
2225
2382
  }
2226
- function registerCategoryCollection(loader, customCategoryCollectionMeta) {
2383
+ function registerProductSlider(loader, customProductSliderMeta) {
2227
2384
  var doRegisterComponent = function doRegisterComponent() {
2228
2385
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2229
2386
  };
2230
2387
 
2231
- doRegisterComponent(CategoryCollection, customCategoryCollectionMeta != null ? customCategoryCollectionMeta : categoryCollectionMeta);
2388
+ doRegisterComponent(ProductSlider, customProductSliderMeta != null ? customProductSliderMeta : productSliderMeta);
2232
2389
  }
2233
2390
 
2234
- var categoryFieldMeta = {
2235
- name: "plasmic-commerce-category-field",
2236
- displayName: "Category Field",
2391
+ var productTextFieldMeta = {
2392
+ name: "plasmic-commerce-product-text-field",
2393
+ displayName: "Product Text Field",
2237
2394
  props: {
2238
2395
  field: {
2239
2396
  type: "choice",
2240
- options: ["id", "name", "slug", "path"]
2397
+ options: ["id", "name", "description", "sku", "slug", "path"]
2241
2398
  }
2242
2399
  },
2243
2400
  importPath: "@plasmicpkgs/commerce",
2244
- importName: "CategoryField"
2401
+ importName: "ProductTextField"
2245
2402
  };
2246
- function CategoryField(props) {
2403
+ function ProductTextField(props) {
2247
2404
  var className = props.className,
2248
2405
  field = props.field;
2249
- var category = useCategoryContext();
2406
+ var product = useProduct();
2407
+
2408
+ if (!product) {
2409
+ return React.createElement("span", {
2410
+ className: className
2411
+ }, "Fake Product Field");
2412
+ }
2250
2413
 
2251
2414
  if (!field) {
2252
- return React.createElement("span", null, "You must set the field prop");
2415
+ return React.createElement("span", {
2416
+ className: className
2417
+ }, "Unknown Product Field");
2418
+ }
2419
+
2420
+ var value;
2421
+
2422
+ if (field === "description") {
2423
+ var _product$descriptionH;
2424
+
2425
+ return React.createElement("div", {
2426
+ className: className,
2427
+ dangerouslySetInnerHTML: {
2428
+ __html: (_product$descriptionH = product.descriptionHtml) != null ? _product$descriptionH : product.description
2429
+ }
2430
+ });
2431
+ } else {
2432
+ value = product[field];
2253
2433
  }
2254
2434
 
2255
- var data = category ? category[field] : "Category field placeholder";
2256
2435
  return React.createElement("span", {
2257
2436
  className: className
2258
- }, data);
2437
+ }, value);
2259
2438
  }
2260
- function registerCategoryField(loader, customCategoryFieldMeta) {
2439
+ function registerTextField(loader, customProductTextFieldMeta) {
2261
2440
  var doRegisterComponent = function doRegisterComponent() {
2262
2441
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2263
2442
  };
2264
2443
 
2265
- doRegisterComponent(CategoryField, customCategoryFieldMeta != null ? customCategoryFieldMeta : categoryFieldMeta);
2444
+ doRegisterComponent(ProductTextField, customProductTextFieldMeta != null ? customProductTextFieldMeta : productTextFieldMeta);
2266
2445
  }
2267
2446
 
2447
+ var productVariantPickerMeta = {
2448
+ name: "plasmic-commerce-product-variant-picker",
2449
+ displayName: "Product Variant Picker",
2450
+ props: {},
2451
+ importPath: "@plasmicpkgs/commerce",
2452
+ importName: "ProductVariantPicker"
2453
+ };
2454
+ function ProductVariantPicker(props) {
2455
+ var _useFormContext, _product$variants$fin;
2456
+
2457
+ var className = props.className;
2458
+ var product = useProduct();
2459
+ var form = (_useFormContext = useFormContext()) != null ? _useFormContext : useForm();
2460
+ return React.createElement(Controller, {
2461
+ name: "ProductVariant",
2462
+ control: form == null ? void 0 : form.control,
2463
+ defaultValue: product == null ? void 0 : (_product$variants$fin = product.variants.find(function (v) {
2464
+ return v.price === product.price.value;
2465
+ })) == null ? void 0 : _product$variants$fin.id,
2466
+ render: function render(_ref) {
2467
+ var _product$variants$map;
2268
2468
 
2469
+ var field = _ref.field;
2470
+ return React.createElement("select", Object.assign({
2471
+ className: className
2472
+ }, field), (_product$variants$map = product == null ? void 0 : product.variants.map(function (variant) {
2473
+ return React.createElement("option", {
2474
+ value: variant.id
2475
+ }, variant.name);
2476
+ })) != null ? _product$variants$map : React.createElement("option", null, "Product Variant Placeholder"));
2477
+ }
2478
+ });
2479
+ }
2480
+ function registerProductVariantPicker(loader, customProductVariantPickerMeta) {
2481
+ var doRegisterComponent = function doRegisterComponent() {
2482
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2483
+ };
2269
2484
 
2270
- var product = {
2271
- __proto__: null
2272
- };
2485
+ doRegisterComponent(ProductVariantPicker, customProductVariantPickerMeta != null ? customProductVariantPickerMeta : productVariantPickerMeta);
2486
+ }
2273
2487
 
2274
2488
  var fetcher$6 = mutationFetcher;
2275
2489
 
@@ -2309,6 +2523,15 @@ var cart = {
2309
2523
 
2310
2524
 
2311
2525
 
2526
+ var product = {
2527
+ __proto__: null
2528
+ };
2529
+
2530
+ /*
2531
+ Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
2532
+ Changes: Added CategoryImage
2533
+ */
2534
+
2312
2535
  var site = {
2313
2536
  __proto__: null
2314
2537
  };
@@ -2323,10 +2546,13 @@ function registerAll(loader) {
2323
2546
  registerProductQuantity(loader);
2324
2547
  registerProductVariantPicker(loader);
2325
2548
  registerProductBox(loader);
2549
+ registerProductSlider(loader);
2326
2550
  registerProductLink(loader);
2327
2551
  registerCategoryCollection(loader);
2328
2552
  registerCategoryField(loader);
2553
+ registerCategoryLink(loader);
2554
+ registerCategoryMedia(loader);
2329
2555
  }
2330
2556
 
2331
- export { AddToCartButton, CartComponent, cart as CartType, CategoryCollection, CategoryField, CommerceError, CoreCommerceProvider, FetcherError, ProductBox, ProductCollection, ProductLink, ProductMedia, ProductPriceComponent, ProductQuantity, ProductTextField, product as ProductTypes, ProductVariantPicker, site as SiteTypes, ValidationError, addToCartButtonMeta, cartMeta, categoryCollectionMeta, categoryFieldMeta, fetcher$2 as fetcher, getCommerceProvider, productBoxMeta, productCollectionMeta, productLinkMeta, productMediaMeta, productPriceMeta, productQuantityMeta, productTextFieldMeta, productVariantPickerMeta, registerAddToCartButton, registerAll, registerCart, registerCategoryCollection, registerCategoryField, registerProductBox, registerProductCollection, registerProductLink, registerProductMedia, registerProductPrice, registerProductQuantity, registerProductVariantPicker, registerTextField, useAddItem, useBrands, useCart, useCategories, useCommerce, useProduct$1 as useProduct, useRemoveItem, useSearch, useUpdateItem };
2557
+ export { AddToCartButton, CartComponent, cart as CartType, CategoryCollection, CategoryField, CategoryLink, CommerceError, CoreCommerceProvider, FetcherError, ProductBox, ProductCollection, ProductLink, ProductMedia, defaultProduct as ProductPlaceholder, ProductPriceComponent, ProductQuantity, ProductTextField, product as ProductTypes, ProductVariantPicker, site as SiteTypes, ValidationError, addToCartButtonMeta, cartMeta, categoryCollectionMeta, categoryFieldMeta, categoryLinkMeta, fetcher$4 as fetcher, getCommerceProvider, productBoxMeta, productCollectionMeta, productLinkMeta, productMediaMeta, productPriceMeta, productQuantityMeta, productTextFieldMeta, productVariantPickerMeta, registerAddToCartButton, registerAll, registerCart, registerCategoryCollection, registerCategoryField, registerCategoryLink, registerProductBox, registerProductCollection, registerProductLink, registerProductMedia, registerProductPrice, registerProductQuantity, registerProductVariantPicker, registerTextField, useAddItem, useBrands, useCart, useCategories, useCommerce, useProduct$1 as useProduct, useRemoveItem, useSearch, useUpdateItem };
2332
2558
  //# sourceMappingURL=commerce.esm.js.map