@plasmicpkgs/commerce 0.0.12 → 0.0.15

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, PlasmicCanvasContext } 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,762 @@ 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
- mediaIndex: "number"
1789
+ mediaIndex: "number",
1790
+ mediaSize: {
1791
+ type: "choice",
1792
+ options: [{
1793
+ label: "Fill",
1794
+ value: "fill"
1795
+ }, {
1796
+ label: "Container",
1797
+ value: "contain"
1798
+ }, {
1799
+ label: "Cover",
1800
+ value: "cover"
1801
+ }, {
1802
+ label: "None",
1803
+ value: "none"
1804
+ }, {
1805
+ label: "Scale down",
1806
+ value: "scale-down"
1807
+ }]
1808
+ }
1713
1809
  },
1714
1810
  importPath: "@plasmicpkgs/commerce",
1715
- importName: "ProductMedia"
1811
+ importName: "CategoryMedia"
1716
1812
  };
1717
- function ProductMedia(props) {
1813
+ function CategoryMedia(props) {
1718
1814
  var _image$url;
1719
1815
 
1720
1816
  var className = props.className,
1721
1817
  _props$mediaIndex = props.mediaIndex,
1722
- mediaIndex = _props$mediaIndex === void 0 ? 0 : _props$mediaIndex;
1723
- var product = useProduct();
1724
- var image = product == null ? void 0 : product.images[mediaIndex];
1818
+ mediaIndex = _props$mediaIndex === void 0 ? 0 : _props$mediaIndex,
1819
+ mediaSize = props.mediaSize;
1820
+ var category = useCategoryContext();
1821
+ var image = category != null && category.images ? category.images[mediaIndex] : undefined;
1725
1822
  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',
1729
- className: className
1823
+ alt: (category == null ? void 0 : category.name) || "Category Image",
1824
+ src: (_image$url = image == null ? void 0 : image.url) != null ? _image$url : "",
1825
+ loading: "lazy",
1826
+ className: className,
1827
+ style: {
1828
+ objectFit: mediaSize
1829
+ }
1730
1830
  });
1731
1831
  }
1732
- function registerProductMedia(loader, customProductMediaMeta) {
1832
+ function registerCategoryMedia(loader, customCategoryMediaMeta) {
1733
1833
  var doRegisterComponent = function doRegisterComponent() {
1734
1834
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1735
1835
  };
1736
1836
 
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
- };
1837
+ doRegisterComponent(CategoryMedia, customCategoryMediaMeta != null ? customCategoryMediaMeta : categoryMediaMeta);
1779
1838
  }
1780
- function usePrice(data) {
1781
- var _ref3 = data != null ? data : {},
1782
- amount = _ref3.amount,
1783
- baseAmount = _ref3.baseAmount,
1784
- currencyCode = _ref3.currencyCode;
1785
-
1786
- var _useCommerce = useCommerce(),
1787
- locale = _useCommerce.locale;
1788
1839
 
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
- }
1840
+ var fetcher$3 = SWRFetcher;
1806
1841
 
1807
- var getProductPrice = function getProductPrice(product, variantId) {
1808
- var _product$variants$fin, _product$variants$fin2;
1842
+ var fn$3 = function fn(provider) {
1843
+ var _provider$products;
1809
1844
 
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;
1845
+ return (_provider$products = provider.products) == null ? void 0 : _provider$products.useProduct;
1813
1846
  };
1814
1847
 
1815
- var productPriceMeta = {
1816
- name: "plasmic-commerce-product-price",
1817
- displayName: "Product Price",
1818
- props: {},
1819
- importPath: "@plasmicpkgs/commerce",
1820
- importName: "ProductPrice"
1848
+ var useProduct$1 = function useProduct(input) {
1849
+ var hook = useHook(fn$3);
1850
+ return useSWRHook(_extends({
1851
+ fetcher: fetcher$3
1852
+ }, hook))(input);
1821
1853
  };
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 : "");
1829
-
1830
- var _usePrice = usePrice({
1831
- amount: product ? getProductPrice(product, watchProductVariant) : 0,
1832
- currencyCode: product ? product.price.currencyCode : 'USD'
1833
- }),
1834
- price = _usePrice.price;
1835
-
1836
- return React.createElement("span", {
1837
- className: className
1838
- }, price);
1839
- }
1840
- function registerProductPrice(loader, customProductPriceMeta) {
1841
- var doRegisterComponent = function doRegisterComponent() {
1842
- return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1843
- };
1844
-
1845
- doRegisterComponent(ProductPriceComponent, customProductPriceMeta != null ? customProductPriceMeta : productPriceMeta);
1846
- }
1847
1854
 
1848
- var productQuantityMeta = {
1849
- name: "plasmic-commerce-product-quantity",
1850
- displayName: "Product Quantity",
1855
+ var productBoxMeta = {
1856
+ name: "plasmic-commerce-product-box",
1857
+ displayName: "Product Box",
1851
1858
  props: {
1852
1859
  children: {
1853
1860
  type: "slot",
1854
1861
  defaultValue: [{
1855
- type: "input",
1856
- attrs: {
1857
- value: "1"
1862
+ type: "vbox",
1863
+ children: [{
1864
+ type: "component",
1865
+ name: "plasmic-commerce-product-text-field",
1866
+ props: {
1867
+ field: "name"
1868
+ }
1869
+ }, {
1870
+ type: "component",
1871
+ name: "plasmic-commerce-product-media"
1872
+ }],
1873
+ styles: {
1874
+ width: "100%",
1875
+ minWidth: 0
1858
1876
  }
1859
1877
  }]
1878
+ },
1879
+ noLayout: "boolean",
1880
+ id: {
1881
+ type: "string",
1882
+ description: "Fetch a product by its slug or ID"
1860
1883
  }
1861
1884
  },
1862
1885
  importPath: "@plasmicpkgs/commerce",
1863
- importName: "ProductQuantity"
1886
+ importName: "ProductBox"
1864
1887
  };
1865
- function ProductQuantity(props) {
1888
+ function ProductBox(props) {
1866
1889
  var className = props.className,
1867
- children = props.children;
1868
- var form = useFormContext();
1869
- return React.createElement("div", {
1890
+ children = props.children,
1891
+ noLayout = props.noLayout,
1892
+ id = props.id;
1893
+
1894
+ var _useProduct = useProduct$1({
1895
+ id: id
1896
+ }),
1897
+ data = _useProduct.data,
1898
+ error = _useProduct.error,
1899
+ isLoading = _useProduct.isLoading;
1900
+
1901
+ if (!id) {
1902
+ return React.createElement("span", null, "You must set the id prop");
1903
+ }
1904
+
1905
+ if (error) {
1906
+ throw new CommerceError({
1907
+ message: error.message,
1908
+ code: error.code
1909
+ });
1910
+ }
1911
+
1912
+ if (isLoading) {
1913
+ return React.createElement("span", null, "Loading...");
1914
+ }
1915
+
1916
+ if (!data) {
1917
+ throw new Error("Product not found!");
1918
+ }
1919
+
1920
+ var renderedData = React.createElement(ProductProvider, {
1921
+ product: data
1922
+ }, children);
1923
+ return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
1870
1924
  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
- }));
1925
+ }, renderedData);
1882
1926
  }
1883
- function registerProductQuantity(loader, customProductQuantityMeta) {
1927
+ function registerProductBox(loader, customProductBoxMeta) {
1884
1928
  var doRegisterComponent = function doRegisterComponent() {
1885
1929
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1886
1930
  };
1887
1931
 
1888
- doRegisterComponent(ProductQuantity, customProductQuantityMeta != null ? customProductQuantityMeta : productQuantityMeta);
1932
+ doRegisterComponent(ProductBox, customProductBoxMeta != null ? customProductBoxMeta : productBoxMeta);
1889
1933
  }
1890
1934
 
1891
- var productTextFieldMeta = {
1892
- name: "plasmic-commerce-product-text-field",
1893
- displayName: "Product Text Field",
1935
+ var fetcher$4 = SWRFetcher;
1936
+
1937
+ var fn$4 = function fn(provider) {
1938
+ var _provider$products;
1939
+
1940
+ return (_provider$products = provider.products) == null ? void 0 : _provider$products.useSearch;
1941
+ };
1942
+
1943
+ var useSearch = function useSearch(input) {
1944
+ var hook = useHook(fn$4);
1945
+ return useSWRHook(_extends({
1946
+ fetcher: fetcher$4
1947
+ }, hook))(input);
1948
+ };
1949
+
1950
+ var fetcher$5 = SWRFetcher;
1951
+
1952
+ var fn$5 = function fn(provider) {
1953
+ var _provider$site;
1954
+
1955
+ return (_provider$site = provider.site) == null ? void 0 : _provider$site.useBrands;
1956
+ };
1957
+
1958
+ var useBrands = function useBrands(input) {
1959
+ var hook = useHook(fn$5);
1960
+ return useSWRHook(_extends({
1961
+ fetcher: fetcher$5
1962
+ }, hook))(input);
1963
+ };
1964
+
1965
+ var productCollectionMeta = {
1966
+ name: "plasmic-commerce-product-collection",
1967
+ displayName: "Product Collection",
1894
1968
  props: {
1895
- field: {
1969
+ children: {
1970
+ type: "slot",
1971
+ defaultValue: [{
1972
+ type: "vbox",
1973
+ children: [{
1974
+ type: "component",
1975
+ name: "plasmic-commerce-product-text-field",
1976
+ props: {
1977
+ field: "name"
1978
+ }
1979
+ }, {
1980
+ type: "component",
1981
+ name: "plasmic-commerce-product-media"
1982
+ }],
1983
+ styles: {
1984
+ width: "100%",
1985
+ minWidth: 0
1986
+ }
1987
+ }]
1988
+ },
1989
+ emptyMessage: {
1990
+ type: "slot",
1991
+ defaultValue: {
1992
+ type: "text",
1993
+ value: "No product found!"
1994
+ }
1995
+ },
1996
+ loadingMessage: {
1997
+ type: "slot",
1998
+ defaultValue: {
1999
+ type: "text",
2000
+ value: "Loading..."
2001
+ }
2002
+ },
2003
+ count: "number",
2004
+ category: {
1896
2005
  type: "choice",
1897
- options: ["id", "name", "description", "sku", "slug", "path"]
1898
- }
2006
+ options: function options(props, ctx) {
2007
+ var _ctx$categories$map;
2008
+
2009
+ return (_ctx$categories$map = ctx == null ? void 0 : ctx.categories.map(function (category) {
2010
+ return {
2011
+ label: category.name,
2012
+ value: category.id
2013
+ };
2014
+ })) != null ? _ctx$categories$map : [];
2015
+ },
2016
+ hidden: function hidden(props, ctx) {
2017
+ return !!(ctx != null && ctx.hasCategoryCtx);
2018
+ }
2019
+ },
2020
+ includeSubCategories: {
2021
+ type: "boolean",
2022
+ hidden: function hidden(props, ctx) {
2023
+ var _ctx$features;
2024
+
2025
+ return !(ctx != null && (_ctx$features = ctx.features) != null && _ctx$features.includeSubCategories);
2026
+ }
2027
+ },
2028
+ brand: {
2029
+ type: "choice",
2030
+ options: function options(props, ctx) {
2031
+ var _ctx$brands$map;
2032
+
2033
+ return (_ctx$brands$map = ctx == null ? void 0 : ctx.brands.map(function (brand) {
2034
+ return {
2035
+ label: brand.name,
2036
+ value: brand.entityId
2037
+ };
2038
+ })) != null ? _ctx$brands$map : [];
2039
+ }
2040
+ },
2041
+ search: {
2042
+ type: "string"
2043
+ },
2044
+ sort: {
2045
+ type: "choice",
2046
+ options: [{
2047
+ label: "Trending",
2048
+ value: "trending-desc"
2049
+ }, {
2050
+ label: "New Arrivals",
2051
+ value: "latest-desc"
2052
+ }, {
2053
+ label: "Price: Low to High",
2054
+ value: "price-asc"
2055
+ }, {
2056
+ label: "Price: High to Low",
2057
+ value: "price-desc"
2058
+ }]
2059
+ },
2060
+ noLayout: "boolean"
2061
+ },
2062
+ defaultStyles: {
2063
+ display: "grid",
2064
+ gridTemplateColumns: "1fr 1fr 1fr 1fr",
2065
+ gridRowGap: "8px",
2066
+ gridColumnGap: "8px",
2067
+ padding: "8px",
2068
+ maxWidth: "100%"
1899
2069
  },
1900
2070
  importPath: "@plasmicpkgs/commerce",
1901
- importName: "ProductTextField"
2071
+ importName: "ProductCollection"
1902
2072
  };
1903
- function ProductTextField(props) {
2073
+ function ProductCollection(props) {
2074
+ var _categoryCtx$id;
2075
+
1904
2076
  var className = props.className,
1905
- field = props.field;
1906
- var product = useProduct();
2077
+ children = props.children,
2078
+ count = props.count,
2079
+ category = props.category,
2080
+ includeSubCategories = props.includeSubCategories,
2081
+ brand = props.brand,
2082
+ noLayout = props.noLayout,
2083
+ setControlContextData = props.setControlContextData,
2084
+ emptyMessage = props.emptyMessage,
2085
+ loadingMessage = props.loadingMessage,
2086
+ search = props.search,
2087
+ sort = props.sort;
1907
2088
 
1908
- if (!product) {
1909
- return React.createElement("span", {
1910
- className: className
1911
- }, "Fake Product Field");
1912
- }
2089
+ var _useCategories = useCategories(),
2090
+ categories = _useCategories.data,
2091
+ isCategoriesLoading = _useCategories.isLoading;
1913
2092
 
1914
- if (!field) {
1915
- return React.createElement("span", {
1916
- className: className
1917
- }, "Unknown Product Field");
2093
+ var _useBrands = useBrands(),
2094
+ brands = _useBrands.data,
2095
+ isBrandsLoading = _useBrands.isLoading;
2096
+
2097
+ var categoryCtx = useCategoryContext();
2098
+
2099
+ var _useSearch = useSearch({
2100
+ categoryId: (_categoryCtx$id = categoryCtx == null ? void 0 : categoryCtx.id) != null ? _categoryCtx$id : category,
2101
+ brandId: brand,
2102
+ count: count,
2103
+ categories: categories != null ? categories : [],
2104
+ includeSubCategories: includeSubCategories,
2105
+ search: search,
2106
+ sort: sort
2107
+ }),
2108
+ data = _useSearch.data,
2109
+ isSearchLoading = _useSearch.isLoading;
2110
+
2111
+ var features = useCommerceExtraFeatures();
2112
+
2113
+ if (categories && brands) {
2114
+ setControlContextData == null ? void 0 : setControlContextData({
2115
+ categories: categories,
2116
+ brands: brands,
2117
+ features: features,
2118
+ hasCategoryCtx: !!categoryCtx
2119
+ });
1918
2120
  }
1919
2121
 
1920
- var value;
2122
+ var renderedData = data == null ? void 0 : data.products.map(function (product, i) {
2123
+ return React.createElement(ProductProvider, {
2124
+ product: product,
2125
+ key: product.id
2126
+ }, repeatedElement(i === 0, children));
2127
+ });
1921
2128
 
1922
- if (field === "description") {
1923
- return product.descriptionHtml ? React.createElement("div", {
1924
- className: className,
1925
- dangerouslySetInnerHTML: {
1926
- __html: product.descriptionHtml
1927
- }
1928
- }) : React.createElement("div", {
1929
- className: className
1930
- }, product.description);
1931
- } else {
1932
- value = product[field];
2129
+ if ([isSearchLoading, isBrandsLoading, isCategoriesLoading].includes(true)) {
2130
+ return React.isValidElement(loadingMessage) ? loadingMessage : null;
1933
2131
  }
1934
2132
 
1935
- return React.createElement("span", {
2133
+ if (!data || data.products.length === 0) {
2134
+ return React.isValidElement(emptyMessage) ? emptyMessage : null;
2135
+ }
2136
+
2137
+ return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
1936
2138
  className: className
1937
- }, value);
2139
+ }, renderedData);
1938
2140
  }
1939
- function registerTextField(loader, customProductTextFieldMeta) {
2141
+ function registerProductCollection(loader, customProductCollectionMeta) {
1940
2142
  var doRegisterComponent = function doRegisterComponent() {
1941
2143
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1942
2144
  };
1943
2145
 
1944
- doRegisterComponent(ProductTextField, customProductTextFieldMeta != null ? customProductTextFieldMeta : productTextFieldMeta);
2146
+ doRegisterComponent(ProductCollection, customProductCollectionMeta != null ? customProductCollectionMeta : productCollectionMeta);
1945
2147
  }
1946
2148
 
1947
- var productVariantPickerMeta = {
1948
- name: "plasmic-commerce-product-variant-picker",
1949
- displayName: "Product Variant Picker",
1950
- props: {},
2149
+ var productLinkMeta = {
2150
+ name: "plasmic-commerce-product-link",
2151
+ displayName: "Product Link",
2152
+ props: {
2153
+ children: "slot",
2154
+ linkDest: {
2155
+ type: "string",
2156
+ defaultValueHint: "products/{slug}",
2157
+ description: "Set the link destination. You can use {slug} to replace by the product slug"
2158
+ }
2159
+ },
1951
2160
  importPath: "@plasmicpkgs/commerce",
1952
- importName: "ProductVariantPicker"
2161
+ importName: "ProductLink"
1953
2162
  };
1954
- function ProductVariantPicker(props) {
1955
- var _useFormContext;
1956
-
1957
- var className = props.className;
2163
+ function ProductLink(props) {
2164
+ var className = props.className,
2165
+ children = props.children,
2166
+ linkDest = props.linkDest;
1958
2167
  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
- }
1976
- });
1977
- }
1978
- function registerProductVariantPicker(loader, customProductVariantPickerMeta) {
1979
- var doRegisterComponent = function doRegisterComponent() {
1980
- return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1981
- };
1982
-
1983
- doRegisterComponent(ProductVariantPicker, customProductVariantPickerMeta != null ? customProductVariantPickerMeta : productVariantPickerMeta);
1984
- }
1985
2168
 
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);
2169
+ var resolveLink = function resolveLink(linkDest) {
2170
+ var _linkDest$match;
2002
2171
 
2003
- case 4:
2004
- _context.t0 = _context.sent;
2005
- _context.next = 8;
2006
- break;
2172
+ if (!linkDest) {
2173
+ return undefined;
2174
+ }
2007
2175
 
2008
- case 7:
2009
- _context.t0 = null;
2176
+ var regex = /{[^}]*}/;
2177
+ var regexAll = new RegExp(regex, "g");
2178
+ var matches = (_linkDest$match = linkDest.match(regexAll)) != null ? _linkDest$match : [];
2179
+ var resolvedLink = linkDest;
2010
2180
 
2011
- case 8:
2012
- return _context.abrupt("return", _context.t0);
2181
+ for (var _iterator = _createForOfIteratorHelperLoose(matches), _step; !(_step = _iterator()).done;) {
2182
+ var match = _step.value;
2183
+ var field = match.slice(1, -1);
2013
2184
 
2014
- case 9:
2015
- case "end":
2016
- return _context.stop();
2017
- }
2185
+ if (!product || !(field in product)) {
2186
+ return undefined;
2018
2187
  }
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
2188
 
2038
- var _useCommerce = useCommerce(),
2039
- cartCookie = _useCommerce.cartCookie;
2189
+ resolvedLink = resolvedLink.replace(regex, product[field]);
2190
+ }
2040
2191
 
2041
- var fetcherFn = (_hook$fetcher = hook.fetcher) != null ? _hook$fetcher : fetcher$5;
2192
+ return resolvedLink;
2193
+ };
2042
2194
 
2043
- var wrapper = function wrapper(context) {
2044
- context.input.cartId = Cookies.get(cartCookie);
2045
- return fetcherFn(context);
2195
+ return React.createElement("a", {
2196
+ className: className,
2197
+ href: resolveLink(linkDest),
2198
+ style: {
2199
+ color: "inherit",
2200
+ textDecoration: "inherit"
2201
+ }
2202
+ }, children);
2203
+ }
2204
+ function registerProductLink(loader, customProductLinkMeta) {
2205
+ var doRegisterComponent = function doRegisterComponent() {
2206
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2046
2207
  };
2047
2208
 
2048
- return useSWRHook(_extends({}, hook, {
2049
- fetcher: wrapper
2050
- }))(input);
2051
- };
2209
+ doRegisterComponent(ProductLink, customProductLinkMeta != null ? customProductLinkMeta : productLinkMeta);
2210
+ }
2052
2211
 
2053
- var cartMeta = {
2054
- name: "plasmic-commerce-cart",
2055
- displayName: "Cart",
2212
+ var placeholderImage = "https://static1.plasmic.app/commerce/lightweight-jacket-0.png";
2213
+ var productMediaMeta = {
2214
+ name: "plasmic-commerce-product-media",
2215
+ displayName: "Product Media",
2056
2216
  props: {
2057
- field: {
2217
+ mediaIndex: "number",
2218
+ mediaSize: {
2058
2219
  type: "choice",
2059
- options: ["Size", "Total Price"]
2060
- },
2061
- hideIfIsEmpty: {
2062
- type: "boolean"
2220
+ options: [{
2221
+ label: "Fill",
2222
+ value: "fill"
2223
+ }, {
2224
+ label: "Container",
2225
+ value: "contain"
2226
+ }, {
2227
+ label: "Cover",
2228
+ value: "cover"
2229
+ }, {
2230
+ label: "None",
2231
+ value: "none"
2232
+ }, {
2233
+ label: "Scale down",
2234
+ value: "scale-down"
2235
+ }]
2063
2236
  }
2064
2237
  },
2065
2238
  importPath: "@plasmicpkgs/commerce",
2066
- importName: "Cart"
2239
+ importName: "ProductMedia"
2067
2240
  };
2068
- function CartComponent(props) {
2069
- var _data$totalPrice, _data$currency$code;
2241
+ function ProductMedia(props) {
2242
+ var _image$url;
2070
2243
 
2071
2244
  var className = props.className,
2072
- field = props.field,
2073
- hideIfIsEmpty = props.hideIfIsEmpty;
2245
+ _props$mediaIndex = props.mediaIndex,
2246
+ mediaIndex = _props$mediaIndex === void 0 ? 0 : _props$mediaIndex,
2247
+ mediaSize = props.mediaSize;
2248
+ var product = useProduct();
2249
+ var sliderContext = useProductSliderContext();
2250
+ var image = product == null ? void 0 : product.images[sliderContext != null ? sliderContext : mediaIndex];
2251
+ return React.createElement("img", {
2252
+ alt: (product == null ? void 0 : product.name) || "Product Image",
2253
+ src: product ? (_image$url = image == null ? void 0 : image.url) != null ? _image$url : "" : placeholderImage,
2254
+ loading: "lazy",
2255
+ className: className,
2256
+ style: {
2257
+ objectFit: mediaSize
2258
+ }
2259
+ });
2260
+ }
2261
+ function registerProductMedia(loader, customProductMediaMeta) {
2262
+ var doRegisterComponent = function doRegisterComponent() {
2263
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2264
+ };
2074
2265
 
2075
- var _useCart = useCart(),
2076
- data = _useCart.data;
2266
+ doRegisterComponent(ProductMedia, customProductMediaMeta != null ? customProductMediaMeta : productMediaMeta);
2267
+ }
2077
2268
 
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;
2269
+ var getProductPrice = function getProductPrice(product, variantId) {
2270
+ var _product$variants$fin, _product$variants$fin2;
2083
2271
 
2084
- if (!field) {
2085
- return React.createElement("p", null, "You must set the field prop");
2086
- }
2272
+ return (_product$variants$fin = (_product$variants$fin2 = product.variants.find(function (variant) {
2273
+ return variant.id === variantId;
2274
+ })) == null ? void 0 : _product$variants$fin2.price) != null ? _product$variants$fin : product.price.value;
2275
+ };
2087
2276
 
2088
- var value;
2277
+ var productPriceMeta = {
2278
+ name: "plasmic-commerce-product-price",
2279
+ displayName: "Product Price",
2280
+ props: {},
2281
+ importPath: "@plasmicpkgs/commerce",
2282
+ importName: "ProductPriceComponent"
2283
+ };
2284
+ function ProductPriceComponent(props) {
2285
+ var _product$price;
2089
2286
 
2090
- if (field === "Size") {
2091
- var _data$lineItems$lengt;
2287
+ var className = props.className;
2288
+ var product = useProduct();
2289
+ var form = useFormContext();
2290
+ var watchProductVariant = form == null ? void 0 : form.watch("ProductVariant", (_product$price = product.price) != null ? _product$price : "");
2092
2291
 
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
- }
2292
+ var _usePrice = usePrice({
2293
+ amount: product ? getProductPrice(product, watchProductVariant) : 0,
2294
+ currencyCode: product ? product.price.currencyCode : "USD"
2295
+ }),
2296
+ price = _usePrice.price;
2097
2297
 
2098
- return hideIfIsEmpty && value === 0 ? null : React.createElement("span", {
2298
+ return React.createElement("span", {
2099
2299
  className: className
2100
- }, value);
2300
+ }, price);
2101
2301
  }
2102
- function registerCart(loader, customCartMeta) {
2302
+ function registerProductPrice(loader, customProductPriceMeta) {
2103
2303
  var doRegisterComponent = function doRegisterComponent() {
2104
2304
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2105
2305
  };
2106
2306
 
2107
- doRegisterComponent(CartComponent, customCartMeta != null ? customCartMeta : cartMeta);
2307
+ doRegisterComponent(ProductPriceComponent, customProductPriceMeta != null ? customProductPriceMeta : productPriceMeta);
2108
2308
  }
2109
2309
 
2110
- var categoryCollectionMeta = {
2111
- name: "plasmic-commerce-category-collection",
2112
- displayName: "Category Collection",
2310
+ var productQuantityMeta = {
2311
+ name: "plasmic-commerce-product-quantity",
2312
+ displayName: "Product Quantity",
2113
2313
  props: {
2114
2314
  children: {
2115
2315
  type: "slot",
2116
2316
  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
2317
+ type: "input",
2318
+ attrs: {
2319
+ value: "1"
2131
2320
  }
2132
2321
  }]
2322
+ }
2323
+ },
2324
+ importPath: "@plasmicpkgs/commerce",
2325
+ importName: "ProductQuantity"
2326
+ };
2327
+ function ProductQuantity(props) {
2328
+ var className = props.className,
2329
+ children = props.children;
2330
+ var form = useFormContext();
2331
+ return React.createElement("div", {
2332
+ className: className
2333
+ }, React.createElement(Controller, {
2334
+ name: "ProductQuantity",
2335
+ defaultValue: 1,
2336
+ control: form == null ? void 0 : form.control,
2337
+ render: function render(_ref) {
2338
+ var field = _ref.field;
2339
+ return React.isValidElement(children) ? React.cloneElement(children, _extends({}, children.props, field, {
2340
+ name: "ProductQuantity"
2341
+ })) : React.createElement(React.Fragment, null);
2342
+ }
2343
+ }));
2344
+ }
2345
+ function registerProductQuantity(loader, customProductQuantityMeta) {
2346
+ var doRegisterComponent = function doRegisterComponent() {
2347
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2348
+ };
2349
+
2350
+ doRegisterComponent(ProductQuantity, customProductQuantityMeta != null ? customProductQuantityMeta : productQuantityMeta);
2351
+ }
2352
+
2353
+ var productSliderMeta = {
2354
+ name: "plasmic-commerce-product-slider",
2355
+ displayName: "Product Slider",
2356
+ props: {
2357
+ thumbsVisible: {
2358
+ type: "number",
2359
+ description: "Number of thumbs visible",
2360
+ defaultValue: 4,
2361
+ defaultValueHint: 4
2133
2362
  },
2134
- noLayout: {
2135
- type: "boolean"
2136
- },
2137
- emptyMessage: {
2363
+ slideContainer: {
2138
2364
  type: "slot",
2139
2365
  defaultValue: {
2140
- type: "text",
2141
- value: "No collection found!"
2366
+ type: "vbox",
2367
+ children: [{
2368
+ type: "component",
2369
+ name: "plasmic-commerce-product-media"
2370
+ }]
2142
2371
  }
2143
2372
  },
2144
- loadingMessage: {
2373
+ thumbsContainer: {
2145
2374
  type: "slot",
2146
2375
  defaultValue: {
2147
- type: "text",
2148
- value: "Loading..."
2376
+ type: "hbox",
2377
+ children: [{
2378
+ type: "component",
2379
+ name: "plasmic-commerce-product-media"
2380
+ }]
2149
2381
  }
2150
2382
  },
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
- }
2383
+ slideSelected: {
2384
+ type: "number",
2385
+ defaultValue: 0,
2386
+ defaultValueHint: 0,
2387
+ description: "Current slide selected"
2163
2388
  }
2164
2389
  },
2165
- defaultStyles: {
2166
- display: "grid",
2167
- gridTemplateColumns: "1fr",
2168
- gridRowGap: "8px",
2169
- padding: "8px",
2170
- maxWidth: "100%"
2171
- },
2172
2390
  importPath: "@plasmicpkgs/commerce",
2173
- importName: "CategoryCollection"
2391
+ importName: "ProductSlider"
2174
2392
  };
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 = React.useContext(PlasmicCanvasContext);
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
- }
2393
+ function ProductSlider(props) {
2394
+ var className = props.className,
2395
+ slideContainer = props.slideContainer,
2396
+ thumbsContainer = props.thumbsContainer,
2397
+ _props$thumbsVisible = props.thumbsVisible,
2398
+ thumbsVisible = _props$thumbsVisible === void 0 ? 4 : _props$thumbsVisible,
2399
+ _props$slideSelected = props.slideSelected,
2400
+ slideSelected = _props$slideSelected === void 0 ? 0 : _props$slideSelected;
2401
+ var product = useProduct();
2217
2402
 
2218
- if (!categories || categories.length === 0) {
2219
- return React.isValidElement(emptyMessage) ? emptyMessage : null;
2220
- }
2403
+ var _React$useState = React.useState(slideSelected),
2404
+ selected = _React$useState[0],
2405
+ setSelected = _React$useState[1];
2221
2406
 
2222
- return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
2407
+ var maximumRight = product.images.length - thumbsVisible;
2408
+ var leftIndex = Math.min(maximumRight, Math.max(0, selected - 1));
2409
+ return React.createElement("div", {
2223
2410
  className: className
2224
- }, renderedData);
2411
+ }, React.createElement(ProductSliderProvider, {
2412
+ mediaIndex: selected,
2413
+ children: slideContainer
2414
+ }), React.createElement("div", {
2415
+ style: {
2416
+ display: "grid",
2417
+ gridTemplateColumns: "repeat(" + thumbsVisible + ", 1fr)"
2418
+ }
2419
+ }, product.images.slice(leftIndex, leftIndex + thumbsVisible).map(function (image, i) {
2420
+ return repeatedElement(i === 0, React.createElement(ProductSliderProvider, {
2421
+ mediaIndex: leftIndex + i,
2422
+ children: thumbsContainer,
2423
+ onClick: function onClick() {
2424
+ return setSelected(leftIndex + i);
2425
+ }
2426
+ }));
2427
+ })));
2225
2428
  }
2226
- function registerCategoryCollection(loader, customCategoryCollectionMeta) {
2429
+ function registerProductSlider(loader, customProductSliderMeta) {
2227
2430
  var doRegisterComponent = function doRegisterComponent() {
2228
2431
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2229
2432
  };
2230
2433
 
2231
- doRegisterComponent(CategoryCollection, customCategoryCollectionMeta != null ? customCategoryCollectionMeta : categoryCollectionMeta);
2434
+ doRegisterComponent(ProductSlider, customProductSliderMeta != null ? customProductSliderMeta : productSliderMeta);
2232
2435
  }
2233
2436
 
2234
- var categoryFieldMeta = {
2235
- name: "plasmic-commerce-category-field",
2236
- displayName: "Category Field",
2437
+ var productTextFieldMeta = {
2438
+ name: "plasmic-commerce-product-text-field",
2439
+ displayName: "Product Text Field",
2237
2440
  props: {
2238
2441
  field: {
2239
2442
  type: "choice",
2240
- options: ["id", "name", "slug", "path"]
2443
+ options: ["id", "name", "description", "sku", "slug", "path"]
2241
2444
  }
2242
2445
  },
2243
2446
  importPath: "@plasmicpkgs/commerce",
2244
- importName: "CategoryField"
2447
+ importName: "ProductTextField"
2245
2448
  };
2246
- function CategoryField(props) {
2449
+ function ProductTextField(props) {
2247
2450
  var className = props.className,
2248
2451
  field = props.field;
2249
- var category = useCategoryContext();
2452
+ var product = useProduct();
2453
+
2454
+ if (!product) {
2455
+ return React.createElement("span", {
2456
+ className: className
2457
+ }, "Fake Product Field");
2458
+ }
2250
2459
 
2251
2460
  if (!field) {
2252
- return React.createElement("span", null, "You must set the field prop");
2461
+ return React.createElement("span", {
2462
+ className: className
2463
+ }, "Unknown Product Field");
2464
+ }
2465
+
2466
+ var value;
2467
+
2468
+ if (field === "description") {
2469
+ var _product$descriptionH;
2470
+
2471
+ return React.createElement("div", {
2472
+ className: className,
2473
+ dangerouslySetInnerHTML: {
2474
+ __html: (_product$descriptionH = product.descriptionHtml) != null ? _product$descriptionH : product.description
2475
+ }
2476
+ });
2477
+ } else {
2478
+ value = product[field];
2253
2479
  }
2254
2480
 
2255
- var data = category ? category[field] : "Category field placeholder";
2256
2481
  return React.createElement("span", {
2257
2482
  className: className
2258
- }, data);
2483
+ }, value);
2259
2484
  }
2260
- function registerCategoryField(loader, customCategoryFieldMeta) {
2485
+ function registerTextField(loader, customProductTextFieldMeta) {
2261
2486
  var doRegisterComponent = function doRegisterComponent() {
2262
2487
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2263
2488
  };
2264
2489
 
2265
- doRegisterComponent(CategoryField, customCategoryFieldMeta != null ? customCategoryFieldMeta : categoryFieldMeta);
2490
+ doRegisterComponent(ProductTextField, customProductTextFieldMeta != null ? customProductTextFieldMeta : productTextFieldMeta);
2266
2491
  }
2267
2492
 
2493
+ var productVariantPickerMeta = {
2494
+ name: "plasmic-commerce-product-variant-picker",
2495
+ displayName: "Product Variant Picker",
2496
+ props: {},
2497
+ importPath: "@plasmicpkgs/commerce",
2498
+ importName: "ProductVariantPicker"
2499
+ };
2500
+ function ProductVariantPicker(props) {
2501
+ var _useFormContext, _product$variants$fin;
2502
+
2503
+ var className = props.className;
2504
+ var product = useProduct();
2505
+ var form = (_useFormContext = useFormContext()) != null ? _useFormContext : useForm();
2506
+ return React.createElement(Controller, {
2507
+ name: "ProductVariant",
2508
+ control: form == null ? void 0 : form.control,
2509
+ defaultValue: product == null ? void 0 : (_product$variants$fin = product.variants.find(function (v) {
2510
+ return v.price === product.price.value;
2511
+ })) == null ? void 0 : _product$variants$fin.id,
2512
+ render: function render(_ref) {
2513
+ var _product$variants$map;
2268
2514
 
2515
+ var field = _ref.field;
2516
+ return React.createElement("select", Object.assign({
2517
+ className: className
2518
+ }, field), (_product$variants$map = product == null ? void 0 : product.variants.map(function (variant) {
2519
+ return React.createElement("option", {
2520
+ value: variant.id
2521
+ }, variant.name);
2522
+ })) != null ? _product$variants$map : React.createElement("option", null, "Product Variant Placeholder"));
2523
+ }
2524
+ });
2525
+ }
2526
+ function registerProductVariantPicker(loader, customProductVariantPickerMeta) {
2527
+ var doRegisterComponent = function doRegisterComponent() {
2528
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
2529
+ };
2269
2530
 
2270
- var product = {
2271
- __proto__: null
2272
- };
2531
+ doRegisterComponent(ProductVariantPicker, customProductVariantPickerMeta != null ? customProductVariantPickerMeta : productVariantPickerMeta);
2532
+ }
2273
2533
 
2274
2534
  var fetcher$6 = mutationFetcher;
2275
2535
 
@@ -2309,6 +2569,15 @@ var cart = {
2309
2569
 
2310
2570
 
2311
2571
 
2572
+ var product = {
2573
+ __proto__: null
2574
+ };
2575
+
2576
+ /*
2577
+ Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
2578
+ Changes: Added CategoryImage
2579
+ */
2580
+
2312
2581
  var site = {
2313
2582
  __proto__: null
2314
2583
  };
@@ -2323,10 +2592,13 @@ function registerAll(loader) {
2323
2592
  registerProductQuantity(loader);
2324
2593
  registerProductVariantPicker(loader);
2325
2594
  registerProductBox(loader);
2595
+ registerProductSlider(loader);
2326
2596
  registerProductLink(loader);
2327
2597
  registerCategoryCollection(loader);
2328
2598
  registerCategoryField(loader);
2599
+ registerCategoryLink(loader);
2600
+ registerCategoryMedia(loader);
2329
2601
  }
2330
2602
 
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 };
2603
+ export { AddToCartButton, CartComponent, cart as CartType, CategoryCollection, CategoryField, CategoryLink, CategoryMedia, CommerceError, CoreCommerceProvider, FetcherError, ProductBox, ProductCollection, ProductLink, ProductMedia, defaultProduct as ProductPlaceholder, ProductPriceComponent, ProductQuantity, ProductSlider, ProductTextField, product as ProductTypes, ProductVariantPicker, site as SiteTypes, ValidationError, addToCartButtonMeta, cartMeta, categoryCollectionMeta, categoryFieldMeta, categoryLinkMeta, categoryMediaMeta, fetcher$4 as fetcher, getCommerceProvider, productBoxMeta, productCollectionMeta, productLinkMeta, productMediaMeta, productPriceMeta, productQuantityMeta, productSliderMeta, productTextFieldMeta, productVariantPickerMeta, registerAddToCartButton, registerAll, registerCart, registerCategoryCollection, registerCategoryField, registerCategoryLink, registerCategoryMedia, registerProductBox, registerProductCollection, registerProductLink, registerProductMedia, registerProductPrice, registerProductQuantity, registerProductSlider, registerProductVariantPicker, registerTextField, useAddItem, useBrands, useCart, useCategories, useCommerce, useProduct$1 as useProduct, useRemoveItem, useSearch, useUpdateItem };
2332
2604
  //# sourceMappingURL=commerce.esm.js.map