@plasmicpkgs/commerce 0.0.2 → 0.0.3

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.
@@ -1287,7 +1287,6 @@ var fn$1 = function fn(provider) {
1287
1287
 
1288
1288
  var useSearch = function useSearch(input) {
1289
1289
  var hook = useHook(fn$1);
1290
- console.log("dale", "commerce", input);
1291
1290
  return useSWRHook(_extends({
1292
1291
  fetcher: fetcher$1
1293
1292
  }, hook))(input);
@@ -1312,17 +1311,46 @@ var productCollectionMeta = {
1312
1311
  name: "plasmic-commerce-product-media"
1313
1312
  }],
1314
1313
  styles: {
1315
- width: "100%"
1314
+ width: "100%",
1315
+ minWidth: 0
1316
1316
  }
1317
1317
  }]
1318
1318
  },
1319
1319
  count: "number",
1320
- categoryId: "string",
1321
- brandId: "string"
1320
+ category: {
1321
+ type: "choice",
1322
+ options: function options(props, ctx) {
1323
+ var _ctx$categories$map;
1324
+
1325
+ return (_ctx$categories$map = ctx == null ? void 0 : ctx.categories.map(function (category) {
1326
+ return {
1327
+ label: category.name,
1328
+ value: category.id
1329
+ };
1330
+ })) != null ? _ctx$categories$map : [];
1331
+ }
1332
+ },
1333
+ brand: {
1334
+ type: "choice",
1335
+ options: function options(props, ctx) {
1336
+ var _ctx$brands$map;
1337
+
1338
+ return (_ctx$brands$map = ctx == null ? void 0 : ctx.brands.map(function (brand) {
1339
+ return {
1340
+ label: brand.name,
1341
+ value: brand.entityId
1342
+ };
1343
+ })) != null ? _ctx$brands$map : [];
1344
+ }
1345
+ }
1322
1346
  },
1323
1347
  defaultStyles: {
1324
1348
  display: "grid",
1325
- gridTemplateColumns: "1fr 1fr 1fr 1fr"
1349
+ gridTemplateColumns: "1fr 1fr 1fr 1fr",
1350
+ gridRowGap: "8px",
1351
+ gridColumnGap: "8px",
1352
+ padding: "8px",
1353
+ maxWidth: "100%"
1326
1354
  },
1327
1355
  importPath: "commerce-providers/commerce",
1328
1356
  importName: "ProductCollection"
@@ -1332,16 +1360,30 @@ function ProductCollection(props) {
1332
1360
  var className = props.className,
1333
1361
  children = props.children,
1334
1362
  count = props.count,
1335
- categoryId = props.categoryId,
1336
- brandId = props.brandId;
1363
+ category = props.category,
1364
+ brand = props.brand,
1365
+ setControlContextData = props.setControlContextData;
1337
1366
 
1338
1367
  var _useSearch = useSearch({
1339
- categoryId: categoryId,
1340
- brandId: brandId,
1368
+ categoryId: category,
1369
+ brandId: brand,
1341
1370
  count: count
1342
1371
  }),
1343
1372
  data = _useSearch.data;
1344
1373
 
1374
+ var _useCategories = useCategories({}),
1375
+ categories = _useCategories.data;
1376
+
1377
+ var _useBrands = useBrands({}),
1378
+ brands = _useBrands.data;
1379
+
1380
+ if (categories && brands) {
1381
+ setControlContextData == null ? void 0 : setControlContextData({
1382
+ categories: categories,
1383
+ brands: brands
1384
+ });
1385
+ }
1386
+
1345
1387
  return React.createElement("div", {
1346
1388
  className: className
1347
1389
  }, data == null ? void 0 : data.products.map(function (product, i) {
@@ -1365,8 +1407,6 @@ var productMediaMeta = {
1365
1407
  name: "plasmic-commerce-product-media",
1366
1408
  displayName: "Product Media",
1367
1409
  props: {
1368
- children: "slot",
1369
- style: "object",
1370
1410
  mediaIndex: "number"
1371
1411
  },
1372
1412
  importPath: "commerce-providers/commerce",
@@ -1376,7 +1416,6 @@ function ProductMedia(props) {
1376
1416
  var _image$url;
1377
1417
 
1378
1418
  var className = props.className,
1379
- style = props.style,
1380
1419
  _props$mediaIndex = props.mediaIndex,
1381
1420
  mediaIndex = _props$mediaIndex === void 0 ? 0 : _props$mediaIndex;
1382
1421
  var product = useProduct();
@@ -1385,8 +1424,7 @@ function ProductMedia(props) {
1385
1424
  alt: (product == null ? void 0 : product.name) || 'Product Image',
1386
1425
  src: product ? (_image$url = image == null ? void 0 : image.url) != null ? _image$url : "" : placeholderImage,
1387
1426
  loading: 'lazy',
1388
- className: className,
1389
- style: style
1427
+ className: className
1390
1428
  });
1391
1429
  }
1392
1430
  function registerProductMedia(loader, customProductMediaMeta) {
@@ -1483,6 +1521,11 @@ function ProductPrice(props) {
1483
1521
  var className = props.className;
1484
1522
  var product = useProduct();
1485
1523
  var form = useFormContext();
1524
+
1525
+ if (!product) {
1526
+ throw new Error("This component must be within a product context.");
1527
+ }
1528
+
1486
1529
  var watchProductVariant = form.watch("ProductVariant", product == null ? void 0 : product.variants[0].id);
1487
1530
 
1488
1531
  var _usePrice = usePrice({
@@ -1771,33 +1814,63 @@ var product = {
1771
1814
  __proto__: null
1772
1815
  };
1773
1816
 
1774
- var fetcher$3 = mutationFetcher;
1817
+ var fetcher$3 = SWRFetcher;
1775
1818
 
1776
1819
  var fn$3 = function fn(provider) {
1820
+ var _provider$site;
1821
+
1822
+ return (_provider$site = provider.site) == null ? void 0 : _provider$site.useCategories;
1823
+ };
1824
+
1825
+ var useCategories = function useCategories(input) {
1826
+ var hook = useHook(fn$3);
1827
+ return useSWRHook(_extends({
1828
+ fetcher: fetcher$3
1829
+ }, hook))(input);
1830
+ };
1831
+
1832
+ var fetcher$4 = SWRFetcher;
1833
+
1834
+ var fn$4 = function fn(provider) {
1835
+ var _provider$site;
1836
+
1837
+ return (_provider$site = provider.site) == null ? void 0 : _provider$site.useBrands;
1838
+ };
1839
+
1840
+ var useBrands = function useBrands(input) {
1841
+ var hook = useHook(fn$4);
1842
+ return useSWRHook(_extends({
1843
+ fetcher: fetcher$4
1844
+ }, hook))(input);
1845
+ };
1846
+
1847
+ var fetcher$5 = mutationFetcher;
1848
+
1849
+ var fn$5 = function fn(provider) {
1777
1850
  var _provider$cart;
1778
1851
 
1779
1852
  return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useRemoveItem;
1780
1853
  };
1781
1854
 
1782
1855
  var useRemoveItem = function useRemoveItem(input) {
1783
- var hook = useHook(fn$3);
1856
+ var hook = useHook(fn$5);
1784
1857
  return useMutationHook(_extends({
1785
- fetcher: fetcher$3
1858
+ fetcher: fetcher$5
1786
1859
  }, hook))(input);
1787
1860
  };
1788
1861
 
1789
- var fetcher$4 = mutationFetcher;
1862
+ var fetcher$6 = mutationFetcher;
1790
1863
 
1791
- var fn$4 = function fn(provider) {
1864
+ var fn$6 = function fn(provider) {
1792
1865
  var _provider$cart;
1793
1866
 
1794
1867
  return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useUpdateItem;
1795
1868
  };
1796
1869
 
1797
1870
  var useUpdateItem = function useUpdateItem(input) {
1798
- var hook = useHook(fn$4);
1871
+ var hook = useHook(fn$6);
1799
1872
  return useMutationHook(_extends({
1800
- fetcher: fetcher$4
1873
+ fetcher: fetcher$6
1801
1874
  }, hook))(input);
1802
1875
  };
1803
1876
 
@@ -1824,5 +1897,5 @@ function registerAll(loader) {
1824
1897
  registerProductVariantPicker(loader);
1825
1898
  }
1826
1899
 
1827
- export { cart as CartType, CommerceError, CoreCommerceProvider, FetcherError, product as ProductTypes, site as SiteTypes, ValidationError, fetcher$1 as fetcher, getCommerceProvider, registerAll, useAddItem, useCart, useCommerce, useRemoveItem, useSearch, useUpdateItem, x };
1900
+ export { cart as CartType, CommerceError, CoreCommerceProvider, FetcherError, product as ProductTypes, site as SiteTypes, ValidationError, fetcher$1 as fetcher, getCommerceProvider, registerAll, useAddItem, useBrands, useCart, useCategories, useCommerce, useRemoveItem, useSearch, useUpdateItem, x };
1828
1901
  //# sourceMappingURL=commerce.esm.js.map