@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.
@@ -1294,7 +1294,6 @@ var fn$1 = function fn(provider) {
1294
1294
 
1295
1295
  var useSearch = function useSearch(input) {
1296
1296
  var hook = useHook(fn$1);
1297
- console.log("dale", "commerce", input);
1298
1297
  return useSWRHook(_extends({
1299
1298
  fetcher: fetcher$1
1300
1299
  }, hook))(input);
@@ -1319,17 +1318,46 @@ var productCollectionMeta = {
1319
1318
  name: "plasmic-commerce-product-media"
1320
1319
  }],
1321
1320
  styles: {
1322
- width: "100%"
1321
+ width: "100%",
1322
+ minWidth: 0
1323
1323
  }
1324
1324
  }]
1325
1325
  },
1326
1326
  count: "number",
1327
- categoryId: "string",
1328
- brandId: "string"
1327
+ category: {
1328
+ type: "choice",
1329
+ options: function options(props, ctx) {
1330
+ var _ctx$categories$map;
1331
+
1332
+ return (_ctx$categories$map = ctx == null ? void 0 : ctx.categories.map(function (category) {
1333
+ return {
1334
+ label: category.name,
1335
+ value: category.id
1336
+ };
1337
+ })) != null ? _ctx$categories$map : [];
1338
+ }
1339
+ },
1340
+ brand: {
1341
+ type: "choice",
1342
+ options: function options(props, ctx) {
1343
+ var _ctx$brands$map;
1344
+
1345
+ return (_ctx$brands$map = ctx == null ? void 0 : ctx.brands.map(function (brand) {
1346
+ return {
1347
+ label: brand.name,
1348
+ value: brand.entityId
1349
+ };
1350
+ })) != null ? _ctx$brands$map : [];
1351
+ }
1352
+ }
1329
1353
  },
1330
1354
  defaultStyles: {
1331
1355
  display: "grid",
1332
- gridTemplateColumns: "1fr 1fr 1fr 1fr"
1356
+ gridTemplateColumns: "1fr 1fr 1fr 1fr",
1357
+ gridRowGap: "8px",
1358
+ gridColumnGap: "8px",
1359
+ padding: "8px",
1360
+ maxWidth: "100%"
1333
1361
  },
1334
1362
  importPath: "commerce-providers/commerce",
1335
1363
  importName: "ProductCollection"
@@ -1339,16 +1367,30 @@ function ProductCollection(props) {
1339
1367
  var className = props.className,
1340
1368
  children = props.children,
1341
1369
  count = props.count,
1342
- categoryId = props.categoryId,
1343
- brandId = props.brandId;
1370
+ category = props.category,
1371
+ brand = props.brand,
1372
+ setControlContextData = props.setControlContextData;
1344
1373
 
1345
1374
  var _useSearch = useSearch({
1346
- categoryId: categoryId,
1347
- brandId: brandId,
1375
+ categoryId: category,
1376
+ brandId: brand,
1348
1377
  count: count
1349
1378
  }),
1350
1379
  data = _useSearch.data;
1351
1380
 
1381
+ var _useCategories = useCategories({}),
1382
+ categories = _useCategories.data;
1383
+
1384
+ var _useBrands = useBrands({}),
1385
+ brands = _useBrands.data;
1386
+
1387
+ if (categories && brands) {
1388
+ setControlContextData == null ? void 0 : setControlContextData({
1389
+ categories: categories,
1390
+ brands: brands
1391
+ });
1392
+ }
1393
+
1352
1394
  return React__default.createElement("div", {
1353
1395
  className: className
1354
1396
  }, data == null ? void 0 : data.products.map(function (product, i) {
@@ -1372,8 +1414,6 @@ var productMediaMeta = {
1372
1414
  name: "plasmic-commerce-product-media",
1373
1415
  displayName: "Product Media",
1374
1416
  props: {
1375
- children: "slot",
1376
- style: "object",
1377
1417
  mediaIndex: "number"
1378
1418
  },
1379
1419
  importPath: "commerce-providers/commerce",
@@ -1383,7 +1423,6 @@ function ProductMedia(props) {
1383
1423
  var _image$url;
1384
1424
 
1385
1425
  var className = props.className,
1386
- style = props.style,
1387
1426
  _props$mediaIndex = props.mediaIndex,
1388
1427
  mediaIndex = _props$mediaIndex === void 0 ? 0 : _props$mediaIndex;
1389
1428
  var product = useProduct();
@@ -1392,8 +1431,7 @@ function ProductMedia(props) {
1392
1431
  alt: (product == null ? void 0 : product.name) || 'Product Image',
1393
1432
  src: product ? (_image$url = image == null ? void 0 : image.url) != null ? _image$url : "" : placeholderImage,
1394
1433
  loading: 'lazy',
1395
- className: className,
1396
- style: style
1434
+ className: className
1397
1435
  });
1398
1436
  }
1399
1437
  function registerProductMedia(loader, customProductMediaMeta) {
@@ -1490,6 +1528,11 @@ function ProductPrice(props) {
1490
1528
  var className = props.className;
1491
1529
  var product = useProduct();
1492
1530
  var form = reactHookForm.useFormContext();
1531
+
1532
+ if (!product) {
1533
+ throw new Error("This component must be within a product context.");
1534
+ }
1535
+
1493
1536
  var watchProductVariant = form.watch("ProductVariant", product == null ? void 0 : product.variants[0].id);
1494
1537
 
1495
1538
  var _usePrice = usePrice({
@@ -1778,33 +1821,63 @@ var product = {
1778
1821
  __proto__: null
1779
1822
  };
1780
1823
 
1781
- var fetcher$3 = mutationFetcher;
1824
+ var fetcher$3 = SWRFetcher;
1782
1825
 
1783
1826
  var fn$3 = function fn(provider) {
1827
+ var _provider$site;
1828
+
1829
+ return (_provider$site = provider.site) == null ? void 0 : _provider$site.useCategories;
1830
+ };
1831
+
1832
+ var useCategories = function useCategories(input) {
1833
+ var hook = useHook(fn$3);
1834
+ return useSWRHook(_extends({
1835
+ fetcher: fetcher$3
1836
+ }, hook))(input);
1837
+ };
1838
+
1839
+ var fetcher$4 = SWRFetcher;
1840
+
1841
+ var fn$4 = function fn(provider) {
1842
+ var _provider$site;
1843
+
1844
+ return (_provider$site = provider.site) == null ? void 0 : _provider$site.useBrands;
1845
+ };
1846
+
1847
+ var useBrands = function useBrands(input) {
1848
+ var hook = useHook(fn$4);
1849
+ return useSWRHook(_extends({
1850
+ fetcher: fetcher$4
1851
+ }, hook))(input);
1852
+ };
1853
+
1854
+ var fetcher$5 = mutationFetcher;
1855
+
1856
+ var fn$5 = function fn(provider) {
1784
1857
  var _provider$cart;
1785
1858
 
1786
1859
  return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useRemoveItem;
1787
1860
  };
1788
1861
 
1789
1862
  var useRemoveItem = function useRemoveItem(input) {
1790
- var hook = useHook(fn$3);
1863
+ var hook = useHook(fn$5);
1791
1864
  return useMutationHook(_extends({
1792
- fetcher: fetcher$3
1865
+ fetcher: fetcher$5
1793
1866
  }, hook))(input);
1794
1867
  };
1795
1868
 
1796
- var fetcher$4 = mutationFetcher;
1869
+ var fetcher$6 = mutationFetcher;
1797
1870
 
1798
- var fn$4 = function fn(provider) {
1871
+ var fn$6 = function fn(provider) {
1799
1872
  var _provider$cart;
1800
1873
 
1801
1874
  return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useUpdateItem;
1802
1875
  };
1803
1876
 
1804
1877
  var useUpdateItem = function useUpdateItem(input) {
1805
- var hook = useHook(fn$4);
1878
+ var hook = useHook(fn$6);
1806
1879
  return useMutationHook(_extends({
1807
- fetcher: fetcher$4
1880
+ fetcher: fetcher$6
1808
1881
  }, hook))(input);
1809
1882
  };
1810
1883
 
@@ -1842,7 +1915,9 @@ exports.fetcher = fetcher$1;
1842
1915
  exports.getCommerceProvider = getCommerceProvider;
1843
1916
  exports.registerAll = registerAll;
1844
1917
  exports.useAddItem = useAddItem;
1918
+ exports.useBrands = useBrands;
1845
1919
  exports.useCart = useCart;
1920
+ exports.useCategories = useCategories;
1846
1921
  exports.useCommerce = useCommerce;
1847
1922
  exports.useRemoveItem = useRemoveItem;
1848
1923
  exports.useSearch = useSearch;