@plasmicpkgs/commerce 0.0.6 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commerce.cjs.development.js +581 -92
- package/dist/commerce.cjs.development.js.map +1 -1
- package/dist/commerce.cjs.production.min.js +1 -1
- package/dist/commerce.cjs.production.min.js.map +1 -1
- package/dist/commerce.d.ts +3 -1
- package/dist/commerce.esm.js +545 -92
- package/dist/commerce.esm.js.map +1 -1
- package/dist/contexts.d.ts +9 -2
- package/dist/index.d.ts +14 -0
- package/dist/product/use-product.d.ts +5 -0
- package/dist/registerAddToCartButton.d.ts +1 -0
- package/dist/registerCart.d.ts +11 -0
- package/dist/registerCategoryCollection.d.ts +19 -0
- package/dist/registerCategoryField.d.ts +10 -0
- package/dist/registerProductBox.d.ts +13 -0
- package/dist/registerProductCollection.d.ts +7 -0
- package/dist/registerProductLink.d.ts +12 -0
- package/dist/registerProductPrice.d.ts +1 -1
- package/dist/types/product.d.ts +13 -0
- package/dist/types/site.d.ts +10 -3
- package/dist/utils/default-product.d.ts +2 -0
- package/dist/utils/types.d.ts +3 -1
- package/dist/utils/use-extra-features.d.ts +1 -0
- package/package.json +3 -3
- package/dist/registerUseCart.d.ts +0 -9
package/dist/commerce.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ 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 } from '@plasmicapp/host';
|
|
5
|
+
import { repeatedElement, usePlasmicCanvasContext } from '@plasmicapp/host';
|
|
6
6
|
import Cookies from 'js-cookie';
|
|
7
7
|
|
|
8
8
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -165,6 +165,44 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
165
165
|
return target;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
169
|
+
if (!o) return;
|
|
170
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
171
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
172
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
173
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
174
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function _arrayLikeToArray(arr, len) {
|
|
178
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
179
|
+
|
|
180
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
181
|
+
|
|
182
|
+
return arr2;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
186
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
187
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
188
|
+
|
|
189
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
190
|
+
if (it) o = it;
|
|
191
|
+
var i = 0;
|
|
192
|
+
return function () {
|
|
193
|
+
if (i >= o.length) return {
|
|
194
|
+
done: true
|
|
195
|
+
};
|
|
196
|
+
return {
|
|
197
|
+
done: false,
|
|
198
|
+
value: o[i++]
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
204
|
+
}
|
|
205
|
+
|
|
168
206
|
function createCommonjsModule(fn, module) {
|
|
169
207
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
170
208
|
}
|
|
@@ -893,7 +931,39 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
893
931
|
}
|
|
894
932
|
});
|
|
895
933
|
|
|
934
|
+
var defaultProduct = {
|
|
935
|
+
id: "123456789",
|
|
936
|
+
name: "Product Placeholder",
|
|
937
|
+
description: "",
|
|
938
|
+
descriptionHtml: "\n <p>This is a <strong>placeholder</strong>.</p>\n <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>\n <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>\n ",
|
|
939
|
+
images: [{
|
|
940
|
+
url: "https://static1.plasmic.app/commerce/lightweight-jacket-0.png",
|
|
941
|
+
alt: "Lightweight Jacket"
|
|
942
|
+
}, {
|
|
943
|
+
url: "https://static1.plasmic.app/commerce/lightweight-jacket-1.png",
|
|
944
|
+
alt: "Lightweight Jacket"
|
|
945
|
+
}, {
|
|
946
|
+
url: "https://static1.plasmic.app/commerce/lightweight-jacket-2.png",
|
|
947
|
+
alt: "Lightweight Jacket"
|
|
948
|
+
}],
|
|
949
|
+
variants: [{
|
|
950
|
+
id: "variiant1",
|
|
951
|
+
name: "Variant Placeholder",
|
|
952
|
+
options: []
|
|
953
|
+
}, {
|
|
954
|
+
id: "variant2",
|
|
955
|
+
name: "Variant Placeholder 2",
|
|
956
|
+
options: []
|
|
957
|
+
}],
|
|
958
|
+
price: {
|
|
959
|
+
value: 0,
|
|
960
|
+
currencyCode: "USD"
|
|
961
|
+
},
|
|
962
|
+
options: []
|
|
963
|
+
};
|
|
964
|
+
|
|
896
965
|
var ProductContext = /*#__PURE__*/React.createContext(undefined);
|
|
966
|
+
var CategoryContext = /*#__PURE__*/React.createContext(undefined);
|
|
897
967
|
function ProductProvider(_ref) {
|
|
898
968
|
var product = _ref.product,
|
|
899
969
|
children = _ref.children;
|
|
@@ -903,9 +973,21 @@ function ProductProvider(_ref) {
|
|
|
903
973
|
key: product.id
|
|
904
974
|
}, React.createElement(FormProvider, Object.assign({}, methods), children));
|
|
905
975
|
}
|
|
906
|
-
function useProduct() {
|
|
907
|
-
|
|
976
|
+
var useProduct = function useProduct() {
|
|
977
|
+
var product = useContext(ProductContext);
|
|
978
|
+
return product != null ? product : defaultProduct;
|
|
979
|
+
};
|
|
980
|
+
function CategoryProvider(_ref2) {
|
|
981
|
+
var category = _ref2.category,
|
|
982
|
+
children = _ref2.children;
|
|
983
|
+
return React.createElement(CategoryContext.Provider, {
|
|
984
|
+
value: category,
|
|
985
|
+
key: category.id
|
|
986
|
+
}, children);
|
|
908
987
|
}
|
|
988
|
+
var useCategoryContext = function useCategoryContext() {
|
|
989
|
+
return useContext(CategoryContext);
|
|
990
|
+
};
|
|
909
991
|
|
|
910
992
|
var _excluded = ["children"];
|
|
911
993
|
var Commerce = /*#__PURE__*/createContext({});
|
|
@@ -1176,10 +1258,9 @@ var addToCartButtonMeta = {
|
|
|
1176
1258
|
}]
|
|
1177
1259
|
}
|
|
1178
1260
|
},
|
|
1179
|
-
importPath: "
|
|
1261
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1180
1262
|
importName: "AddToCartButton"
|
|
1181
1263
|
};
|
|
1182
|
-
|
|
1183
1264
|
function AddToCartButton(props) {
|
|
1184
1265
|
var children = props.children;
|
|
1185
1266
|
var product = useProduct();
|
|
@@ -1190,12 +1271,13 @@ function AddToCartButton(props) {
|
|
|
1190
1271
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1191
1272
|
var _form$getValues$Produ;
|
|
1192
1273
|
|
|
1193
|
-
var quantity, variantId;
|
|
1274
|
+
var quantity, _form$getValues$Produ2, variantId;
|
|
1275
|
+
|
|
1194
1276
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1195
1277
|
while (1) {
|
|
1196
1278
|
switch (_context.prev = _context.next) {
|
|
1197
1279
|
case 0:
|
|
1198
|
-
quantity = (_form$getValues$Produ =
|
|
1280
|
+
quantity = +((_form$getValues$Produ = form.getValues()["ProductQuantity"]) != null ? _form$getValues$Produ : 1);
|
|
1199
1281
|
|
|
1200
1282
|
if (!(isNaN(quantity) || quantity < 1)) {
|
|
1201
1283
|
_context.next = 3;
|
|
@@ -1212,7 +1294,7 @@ function AddToCartButton(props) {
|
|
|
1212
1294
|
break;
|
|
1213
1295
|
}
|
|
1214
1296
|
|
|
1215
|
-
variantId = form.getValues()["ProductVariant"];
|
|
1297
|
+
variantId = (_form$getValues$Produ2 = form.getValues()["ProductVariant"]) != null ? _form$getValues$Produ2 : product.variants[0].id;
|
|
1216
1298
|
_context.next = 7;
|
|
1217
1299
|
return addItem({
|
|
1218
1300
|
productId: product.id,
|
|
@@ -1243,7 +1325,6 @@ function AddToCartButton(props) {
|
|
|
1243
1325
|
}
|
|
1244
1326
|
}) : null;
|
|
1245
1327
|
}
|
|
1246
|
-
|
|
1247
1328
|
function registerAddToCartButton(loader, customAddToCartButtonMeta) {
|
|
1248
1329
|
var doRegisterComponent = function doRegisterComponent() {
|
|
1249
1330
|
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
@@ -1257,16 +1338,148 @@ var fetcher$1 = SWRFetcher;
|
|
|
1257
1338
|
var fn$1 = function fn(provider) {
|
|
1258
1339
|
var _provider$products;
|
|
1259
1340
|
|
|
1260
|
-
return (_provider$products = provider.products) == null ? void 0 : _provider$products.
|
|
1341
|
+
return (_provider$products = provider.products) == null ? void 0 : _provider$products.useProduct;
|
|
1261
1342
|
};
|
|
1262
1343
|
|
|
1263
|
-
var
|
|
1344
|
+
var useProduct$1 = function useProduct(input) {
|
|
1264
1345
|
var hook = useHook(fn$1);
|
|
1265
1346
|
return useSWRHook(_extends({
|
|
1266
1347
|
fetcher: fetcher$1
|
|
1267
1348
|
}, hook))(input);
|
|
1268
1349
|
};
|
|
1269
1350
|
|
|
1351
|
+
var productBoxMeta = {
|
|
1352
|
+
name: "plasmic-commerce-product-box",
|
|
1353
|
+
displayName: "Product Box",
|
|
1354
|
+
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
|
+
}]
|
|
1374
|
+
},
|
|
1375
|
+
noLayout: "boolean",
|
|
1376
|
+
id: {
|
|
1377
|
+
type: "string",
|
|
1378
|
+
description: "Fetch a product by its slug or ID"
|
|
1379
|
+
}
|
|
1380
|
+
},
|
|
1381
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1382
|
+
importName: "ProductBox"
|
|
1383
|
+
};
|
|
1384
|
+
function ProductBox(props) {
|
|
1385
|
+
var className = props.className,
|
|
1386
|
+
children = props.children,
|
|
1387
|
+
noLayout = props.noLayout,
|
|
1388
|
+
id = props.id;
|
|
1389
|
+
|
|
1390
|
+
var _useProduct = useProduct$1({
|
|
1391
|
+
id: id
|
|
1392
|
+
}),
|
|
1393
|
+
data = _useProduct.data,
|
|
1394
|
+
error = _useProduct.error,
|
|
1395
|
+
isLoading = _useProduct.isLoading;
|
|
1396
|
+
|
|
1397
|
+
if (!id) {
|
|
1398
|
+
return React.createElement("span", null, "You must set the id prop");
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
if (error) {
|
|
1402
|
+
throw new CommerceError({
|
|
1403
|
+
message: error.message,
|
|
1404
|
+
code: error.code
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
if (isLoading) {
|
|
1409
|
+
return React.createElement("span", null, "Loading...");
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
if (!data) {
|
|
1413
|
+
throw new Error("Product not found!");
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
var renderedData = React.createElement(ProductProvider, {
|
|
1417
|
+
product: data
|
|
1418
|
+
}, children);
|
|
1419
|
+
return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
|
|
1420
|
+
className: className
|
|
1421
|
+
}, renderedData);
|
|
1422
|
+
}
|
|
1423
|
+
function registerProductBox(loader, customProductBoxMeta) {
|
|
1424
|
+
var doRegisterComponent = function doRegisterComponent() {
|
|
1425
|
+
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
1426
|
+
};
|
|
1427
|
+
|
|
1428
|
+
doRegisterComponent(ProductBox, customProductBoxMeta != null ? customProductBoxMeta : productBoxMeta);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
var fetcher$2 = SWRFetcher;
|
|
1432
|
+
|
|
1433
|
+
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
|
+
var _provider$site;
|
|
1450
|
+
|
|
1451
|
+
return (_provider$site = provider.site) == null ? void 0 : _provider$site.useCategories;
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1454
|
+
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);
|
|
1471
|
+
return useSWRHook(_extends({
|
|
1472
|
+
fetcher: fetcher$4
|
|
1473
|
+
}, hook))(input);
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
var useCommerceExtraFeatures = function useCommerceExtraFeatures() {
|
|
1477
|
+
var _useCommerce = useCommerce(),
|
|
1478
|
+
providerRef = _useCommerce.providerRef;
|
|
1479
|
+
|
|
1480
|
+
return providerRef.current.extraFeatures;
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1270
1483
|
var productCollectionMeta = {
|
|
1271
1484
|
name: "plasmic-commerce-product-collection",
|
|
1272
1485
|
displayName: "Product Collection",
|
|
@@ -1291,6 +1504,20 @@ var productCollectionMeta = {
|
|
|
1291
1504
|
}
|
|
1292
1505
|
}]
|
|
1293
1506
|
},
|
|
1507
|
+
emptyMessage: {
|
|
1508
|
+
type: "slot",
|
|
1509
|
+
defaultValue: {
|
|
1510
|
+
type: "text",
|
|
1511
|
+
value: "No product found!"
|
|
1512
|
+
}
|
|
1513
|
+
},
|
|
1514
|
+
loadingMessage: {
|
|
1515
|
+
type: "slot",
|
|
1516
|
+
defaultValue: {
|
|
1517
|
+
type: "text",
|
|
1518
|
+
value: "Loading..."
|
|
1519
|
+
}
|
|
1520
|
+
},
|
|
1294
1521
|
count: "number",
|
|
1295
1522
|
category: {
|
|
1296
1523
|
type: "choice",
|
|
@@ -1303,6 +1530,17 @@ var productCollectionMeta = {
|
|
|
1303
1530
|
value: category.id
|
|
1304
1531
|
};
|
|
1305
1532
|
})) != 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);
|
|
1306
1544
|
}
|
|
1307
1545
|
},
|
|
1308
1546
|
brand: {
|
|
@@ -1328,36 +1566,51 @@ var productCollectionMeta = {
|
|
|
1328
1566
|
padding: "8px",
|
|
1329
1567
|
maxWidth: "100%"
|
|
1330
1568
|
},
|
|
1331
|
-
importPath: "
|
|
1569
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1332
1570
|
importName: "ProductCollection"
|
|
1333
1571
|
};
|
|
1334
|
-
|
|
1335
1572
|
function ProductCollection(props) {
|
|
1573
|
+
var _categoryCtx$id;
|
|
1574
|
+
|
|
1336
1575
|
var className = props.className,
|
|
1337
1576
|
children = props.children,
|
|
1338
1577
|
count = props.count,
|
|
1339
1578
|
category = props.category,
|
|
1579
|
+
includeSubCategories = props.includeSubCategories,
|
|
1340
1580
|
brand = props.brand,
|
|
1341
1581
|
noLayout = props.noLayout,
|
|
1342
|
-
setControlContextData = props.setControlContextData
|
|
1582
|
+
setControlContextData = props.setControlContextData,
|
|
1583
|
+
emptyMessage = props.emptyMessage,
|
|
1584
|
+
loadingMessage = props.loadingMessage;
|
|
1585
|
+
|
|
1586
|
+
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();
|
|
1343
1595
|
|
|
1344
1596
|
var _useSearch = useSearch({
|
|
1345
|
-
categoryId: category,
|
|
1597
|
+
categoryId: (_categoryCtx$id = categoryCtx == null ? void 0 : categoryCtx.id) != null ? _categoryCtx$id : category,
|
|
1346
1598
|
brandId: brand,
|
|
1347
|
-
count: count
|
|
1599
|
+
count: count,
|
|
1600
|
+
categories: categories != null ? categories : [],
|
|
1601
|
+
includeSubCategories: includeSubCategories
|
|
1348
1602
|
}),
|
|
1349
|
-
data = _useSearch.data
|
|
1350
|
-
|
|
1351
|
-
var _useCategories = useCategories({}),
|
|
1352
|
-
categories = _useCategories.data;
|
|
1603
|
+
data = _useSearch.data,
|
|
1604
|
+
isSearchLoading = _useSearch.isLoading;
|
|
1353
1605
|
|
|
1354
|
-
var
|
|
1355
|
-
brands = _useBrands.data;
|
|
1606
|
+
var features = useCommerceExtraFeatures();
|
|
1356
1607
|
|
|
1357
1608
|
if (categories && brands) {
|
|
1358
1609
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1359
1610
|
categories: categories,
|
|
1360
|
-
brands: brands
|
|
1611
|
+
brands: brands,
|
|
1612
|
+
features: features,
|
|
1613
|
+
hasCategoryCtx: !!categoryCtx
|
|
1361
1614
|
});
|
|
1362
1615
|
}
|
|
1363
1616
|
|
|
@@ -1367,11 +1620,19 @@ function ProductCollection(props) {
|
|
|
1367
1620
|
key: product.id
|
|
1368
1621
|
}, repeatedElement(i === 0, children));
|
|
1369
1622
|
});
|
|
1623
|
+
|
|
1624
|
+
if ([isSearchLoading, isBrandsLoading, isCategoriesLoading].includes(true)) {
|
|
1625
|
+
return React.isValidElement(loadingMessage) ? loadingMessage : null;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
if (!data || data.products.length === 0) {
|
|
1629
|
+
return React.isValidElement(emptyMessage) ? emptyMessage : null;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1370
1632
|
return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
|
|
1371
1633
|
className: className
|
|
1372
1634
|
}, renderedData);
|
|
1373
1635
|
}
|
|
1374
|
-
|
|
1375
1636
|
function registerProductCollection(loader, customProductCollectionMeta) {
|
|
1376
1637
|
var doRegisterComponent = function doRegisterComponent() {
|
|
1377
1638
|
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
@@ -1380,6 +1641,69 @@ function registerProductCollection(loader, customProductCollectionMeta) {
|
|
|
1380
1641
|
doRegisterComponent(ProductCollection, customProductCollectionMeta != null ? customProductCollectionMeta : productCollectionMeta);
|
|
1381
1642
|
}
|
|
1382
1643
|
|
|
1644
|
+
var productLinkMeta = {
|
|
1645
|
+
name: "plasmic-commerce-product-link",
|
|
1646
|
+
displayName: "Product Link",
|
|
1647
|
+
props: {
|
|
1648
|
+
children: "slot",
|
|
1649
|
+
linkDest: {
|
|
1650
|
+
type: "string",
|
|
1651
|
+
defaultValueHint: "products/{slug}",
|
|
1652
|
+
description: "Set the link destination. You can use {slug} to replace by the product slug"
|
|
1653
|
+
}
|
|
1654
|
+
},
|
|
1655
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1656
|
+
importName: "ProductLink"
|
|
1657
|
+
};
|
|
1658
|
+
function ProductLink(props) {
|
|
1659
|
+
var className = props.className,
|
|
1660
|
+
children = props.children,
|
|
1661
|
+
linkDest = props.linkDest;
|
|
1662
|
+
var product = useProduct();
|
|
1663
|
+
|
|
1664
|
+
var resolveLink = function resolveLink(linkDest) {
|
|
1665
|
+
var _linkDest$match;
|
|
1666
|
+
|
|
1667
|
+
if (!product || !linkDest) {
|
|
1668
|
+
return undefined;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
var regex = /{[^}]*}/;
|
|
1672
|
+
var regexAll = new RegExp(regex, "g");
|
|
1673
|
+
var matches = (_linkDest$match = linkDest.match(regexAll)) != null ? _linkDest$match : [];
|
|
1674
|
+
var resolvedLink = linkDest;
|
|
1675
|
+
|
|
1676
|
+
for (var _iterator = _createForOfIteratorHelperLoose(matches), _step; !(_step = _iterator()).done;) {
|
|
1677
|
+
var match = _step.value;
|
|
1678
|
+
var field = match.slice(1, -1);
|
|
1679
|
+
|
|
1680
|
+
if (!(field in product)) {
|
|
1681
|
+
return undefined;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
resolvedLink = resolvedLink.replace(regex, product[field]);
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
return resolvedLink;
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1690
|
+
return React.createElement("a", {
|
|
1691
|
+
className: className,
|
|
1692
|
+
href: resolveLink(linkDest),
|
|
1693
|
+
style: {
|
|
1694
|
+
color: "inherit",
|
|
1695
|
+
textDecoration: "inherit"
|
|
1696
|
+
}
|
|
1697
|
+
}, children);
|
|
1698
|
+
}
|
|
1699
|
+
function registerProductLink(loader, customProductLinkMeta) {
|
|
1700
|
+
var doRegisterComponent = function doRegisterComponent() {
|
|
1701
|
+
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
1702
|
+
};
|
|
1703
|
+
|
|
1704
|
+
doRegisterComponent(ProductLink, customProductLinkMeta != null ? customProductLinkMeta : productLinkMeta);
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1383
1707
|
var placeholderImage = "https://static1.plasmic.app/commerce/lightweight-jacket-0.png";
|
|
1384
1708
|
var productMediaMeta = {
|
|
1385
1709
|
name: "plasmic-commerce-product-media",
|
|
@@ -1387,7 +1711,7 @@ var productMediaMeta = {
|
|
|
1387
1711
|
props: {
|
|
1388
1712
|
mediaIndex: "number"
|
|
1389
1713
|
},
|
|
1390
|
-
importPath: "
|
|
1714
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1391
1715
|
importName: "ProductMedia"
|
|
1392
1716
|
};
|
|
1393
1717
|
function ProductMedia(props) {
|
|
@@ -1492,19 +1816,16 @@ var productPriceMeta = {
|
|
|
1492
1816
|
name: "plasmic-commerce-product-price",
|
|
1493
1817
|
displayName: "Product Price",
|
|
1494
1818
|
props: {},
|
|
1495
|
-
importPath: "
|
|
1819
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1496
1820
|
importName: "ProductPrice"
|
|
1497
1821
|
};
|
|
1498
|
-
function
|
|
1822
|
+
function ProductPriceComponent(props) {
|
|
1823
|
+
var _product$variants$0$i;
|
|
1824
|
+
|
|
1499
1825
|
var className = props.className;
|
|
1500
1826
|
var product = useProduct();
|
|
1501
1827
|
var form = useFormContext();
|
|
1502
|
-
|
|
1503
|
-
if (!product) {
|
|
1504
|
-
throw new Error("This component must be within a product context.");
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
var watchProductVariant = form.watch("ProductVariant", product == null ? void 0 : product.variants[0].id);
|
|
1828
|
+
var watchProductVariant = form == null ? void 0 : form.watch("ProductVariant", (_product$variants$0$i = product.variants[0].id) != null ? _product$variants$0$i : "");
|
|
1508
1829
|
|
|
1509
1830
|
var _usePrice = usePrice({
|
|
1510
1831
|
amount: product ? getProductPrice(product, watchProductVariant) : 0,
|
|
@@ -1521,7 +1842,7 @@ function registerProductPrice(loader, customProductPriceMeta) {
|
|
|
1521
1842
|
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
1522
1843
|
};
|
|
1523
1844
|
|
|
1524
|
-
doRegisterComponent(
|
|
1845
|
+
doRegisterComponent(ProductPriceComponent, customProductPriceMeta != null ? customProductPriceMeta : productPriceMeta);
|
|
1525
1846
|
}
|
|
1526
1847
|
|
|
1527
1848
|
var productQuantityMeta = {
|
|
@@ -1538,7 +1859,7 @@ var productQuantityMeta = {
|
|
|
1538
1859
|
}]
|
|
1539
1860
|
}
|
|
1540
1861
|
},
|
|
1541
|
-
importPath: "
|
|
1862
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1542
1863
|
importName: "ProductQuantity"
|
|
1543
1864
|
};
|
|
1544
1865
|
function ProductQuantity(props) {
|
|
@@ -1576,7 +1897,7 @@ var productTextFieldMeta = {
|
|
|
1576
1897
|
options: ["id", "name", "description", "sku", "slug", "path"]
|
|
1577
1898
|
}
|
|
1578
1899
|
},
|
|
1579
|
-
importPath: "
|
|
1900
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1580
1901
|
importName: "ProductTextField"
|
|
1581
1902
|
};
|
|
1582
1903
|
function ProductTextField(props) {
|
|
@@ -1627,13 +1948,15 @@ var productVariantPickerMeta = {
|
|
|
1627
1948
|
name: "plasmic-commerce-product-variant-picker",
|
|
1628
1949
|
displayName: "Product Variant Picker",
|
|
1629
1950
|
props: {},
|
|
1630
|
-
importPath: "
|
|
1951
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1631
1952
|
importName: "ProductVariantPicker"
|
|
1632
1953
|
};
|
|
1633
1954
|
function ProductVariantPicker(props) {
|
|
1955
|
+
var _useFormContext;
|
|
1956
|
+
|
|
1634
1957
|
var className = props.className;
|
|
1635
1958
|
var product = useProduct();
|
|
1636
|
-
var form = useFormContext();
|
|
1959
|
+
var form = (_useFormContext = useFormContext()) != null ? _useFormContext : useForm();
|
|
1637
1960
|
return React.createElement(Controller, {
|
|
1638
1961
|
name: "ProductVariant",
|
|
1639
1962
|
control: form == null ? void 0 : form.control,
|
|
@@ -1648,7 +1971,7 @@ function ProductVariantPicker(props) {
|
|
|
1648
1971
|
return React.createElement("option", {
|
|
1649
1972
|
value: variant.id
|
|
1650
1973
|
}, variant.name);
|
|
1651
|
-
})) != null ? _product$variants$map : React.createElement("option", null, "
|
|
1974
|
+
})) != null ? _product$variants$map : React.createElement("option", null, "Product Variant Placeholder"));
|
|
1652
1975
|
}
|
|
1653
1976
|
});
|
|
1654
1977
|
}
|
|
@@ -1660,7 +1983,7 @@ function registerProductVariantPicker(loader, customProductVariantPickerMeta) {
|
|
|
1660
1983
|
doRegisterComponent(ProductVariantPicker, customProductVariantPickerMeta != null ? customProductVariantPickerMeta : productVariantPickerMeta);
|
|
1661
1984
|
}
|
|
1662
1985
|
|
|
1663
|
-
var fetcher$
|
|
1986
|
+
var fetcher$5 = /*#__PURE__*/function () {
|
|
1664
1987
|
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
|
|
1665
1988
|
var options, cartId, fetch;
|
|
1666
1989
|
return runtime_1.wrap(function _callee$(_context) {
|
|
@@ -1701,7 +2024,7 @@ var fetcher$2 = /*#__PURE__*/function () {
|
|
|
1701
2024
|
};
|
|
1702
2025
|
}();
|
|
1703
2026
|
|
|
1704
|
-
var fn$
|
|
2027
|
+
var fn$5 = function fn(provider) {
|
|
1705
2028
|
var _provider$cart;
|
|
1706
2029
|
|
|
1707
2030
|
return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useCart;
|
|
@@ -1710,12 +2033,12 @@ var fn$2 = function fn(provider) {
|
|
|
1710
2033
|
var useCart = function useCart(input) {
|
|
1711
2034
|
var _hook$fetcher;
|
|
1712
2035
|
|
|
1713
|
-
var hook = useHook(fn$
|
|
2036
|
+
var hook = useHook(fn$5);
|
|
1714
2037
|
|
|
1715
2038
|
var _useCommerce = useCommerce(),
|
|
1716
2039
|
cartCookie = _useCommerce.cartCookie;
|
|
1717
2040
|
|
|
1718
|
-
var fetcherFn = (_hook$fetcher = hook.fetcher) != null ? _hook$fetcher : fetcher$
|
|
2041
|
+
var fetcherFn = (_hook$fetcher = hook.fetcher) != null ? _hook$fetcher : fetcher$5;
|
|
1719
2042
|
|
|
1720
2043
|
var wrapper = function wrapper(context) {
|
|
1721
2044
|
context.input.cartId = Cookies.get(cartCookie);
|
|
@@ -1727,24 +2050,27 @@ var useCart = function useCart(input) {
|
|
|
1727
2050
|
}))(input);
|
|
1728
2051
|
};
|
|
1729
2052
|
|
|
1730
|
-
var
|
|
1731
|
-
name: "plasmic-commerce-
|
|
1732
|
-
displayName: "
|
|
2053
|
+
var cartMeta = {
|
|
2054
|
+
name: "plasmic-commerce-cart",
|
|
2055
|
+
displayName: "Cart",
|
|
1733
2056
|
props: {
|
|
1734
2057
|
field: {
|
|
1735
2058
|
type: "choice",
|
|
1736
2059
|
options: ["Size", "Total Price"]
|
|
2060
|
+
},
|
|
2061
|
+
hideIfIsEmpty: {
|
|
2062
|
+
type: "boolean"
|
|
1737
2063
|
}
|
|
1738
2064
|
},
|
|
1739
|
-
importPath: "
|
|
1740
|
-
importName: "
|
|
2065
|
+
importPath: "@plasmicpkgs/commerce",
|
|
2066
|
+
importName: "Cart"
|
|
1741
2067
|
};
|
|
1742
|
-
|
|
1743
|
-
function UseCartComponent(props) {
|
|
2068
|
+
function CartComponent(props) {
|
|
1744
2069
|
var _data$totalPrice, _data$currency$code;
|
|
1745
2070
|
|
|
1746
2071
|
var className = props.className,
|
|
1747
|
-
field = props.field
|
|
2072
|
+
field = props.field,
|
|
2073
|
+
hideIfIsEmpty = props.hideIfIsEmpty;
|
|
1748
2074
|
|
|
1749
2075
|
var _useCart = useCart(),
|
|
1750
2076
|
data = _useCart.data;
|
|
@@ -1764,91 +2090,214 @@ function UseCartComponent(props) {
|
|
|
1764
2090
|
if (field === "Size") {
|
|
1765
2091
|
var _data$lineItems$lengt;
|
|
1766
2092
|
|
|
1767
|
-
value =
|
|
2093
|
+
value = (_data$lineItems$lengt = data == null ? void 0 : data.lineItems.length) != null ? _data$lineItems$lengt : 0;
|
|
1768
2094
|
} else if (field === "Total Price") {
|
|
1769
|
-
value =
|
|
2095
|
+
value = price != null ? price : 0;
|
|
1770
2096
|
}
|
|
1771
2097
|
|
|
1772
|
-
return React.createElement("span", {
|
|
2098
|
+
return hideIfIsEmpty && value === 0 ? null : React.createElement("span", {
|
|
1773
2099
|
className: className
|
|
1774
2100
|
}, value);
|
|
1775
2101
|
}
|
|
1776
|
-
|
|
1777
|
-
function registerUseCart(loader, customUseCartMeta) {
|
|
2102
|
+
function registerCart(loader, customCartMeta) {
|
|
1778
2103
|
var doRegisterComponent = function doRegisterComponent() {
|
|
1779
2104
|
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
1780
2105
|
};
|
|
1781
2106
|
|
|
1782
|
-
doRegisterComponent(
|
|
2107
|
+
doRegisterComponent(CartComponent, customCartMeta != null ? customCartMeta : cartMeta);
|
|
1783
2108
|
}
|
|
1784
2109
|
|
|
1785
|
-
var
|
|
1786
|
-
|
|
2110
|
+
var categoryCollectionMeta = {
|
|
2111
|
+
name: "plasmic-commerce-category-collection",
|
|
2112
|
+
displayName: "Category Collection",
|
|
2113
|
+
props: {
|
|
2114
|
+
children: {
|
|
2115
|
+
type: "slot",
|
|
2116
|
+
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
|
|
2131
|
+
}
|
|
2132
|
+
}]
|
|
2133
|
+
},
|
|
2134
|
+
noLayout: {
|
|
2135
|
+
type: "boolean"
|
|
2136
|
+
},
|
|
2137
|
+
emptyMessage: {
|
|
2138
|
+
type: "slot",
|
|
2139
|
+
defaultValue: {
|
|
2140
|
+
type: "text",
|
|
2141
|
+
value: "No collection found!"
|
|
2142
|
+
}
|
|
2143
|
+
},
|
|
2144
|
+
loadingMessage: {
|
|
2145
|
+
type: "slot",
|
|
2146
|
+
defaultValue: {
|
|
2147
|
+
type: "text",
|
|
2148
|
+
value: "Loading..."
|
|
2149
|
+
}
|
|
2150
|
+
},
|
|
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
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
},
|
|
2165
|
+
defaultStyles: {
|
|
2166
|
+
display: "grid",
|
|
2167
|
+
gridTemplateColumns: "1fr",
|
|
2168
|
+
gridRowGap: "8px",
|
|
2169
|
+
padding: "8px",
|
|
2170
|
+
maxWidth: "100%"
|
|
2171
|
+
},
|
|
2172
|
+
importPath: "@plasmicpkgs/commerce",
|
|
2173
|
+
importName: "CategoryCollection"
|
|
1787
2174
|
};
|
|
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();
|
|
1788
2185
|
|
|
2186
|
+
var _useCategories = useCategories(),
|
|
2187
|
+
allCategories = _useCategories.data,
|
|
2188
|
+
isAllCategoriesLoading = _useCategories.isLoading;
|
|
1789
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;
|
|
1790
2197
|
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
2198
|
+
if (allCategories) {
|
|
2199
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
2200
|
+
categories: allCategories
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
1794
2203
|
|
|
1795
|
-
var
|
|
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
|
+
});
|
|
1796
2213
|
|
|
1797
|
-
|
|
1798
|
-
|
|
2214
|
+
if ([isAllCategoriesLoading, isLoading].includes(true)) {
|
|
2215
|
+
return React.isValidElement(loadingMessage) ? loadingMessage : null;
|
|
2216
|
+
}
|
|
1799
2217
|
|
|
1800
|
-
|
|
1801
|
-
|
|
2218
|
+
if (!categories || categories.length === 0) {
|
|
2219
|
+
return React.isValidElement(emptyMessage) ? emptyMessage : null;
|
|
2220
|
+
}
|
|
1802
2221
|
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
2222
|
+
return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
|
|
2223
|
+
className: className
|
|
2224
|
+
}, renderedData);
|
|
2225
|
+
}
|
|
2226
|
+
function registerCategoryCollection(loader, customCategoryCollectionMeta) {
|
|
2227
|
+
var doRegisterComponent = function doRegisterComponent() {
|
|
2228
|
+
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
2229
|
+
};
|
|
2230
|
+
|
|
2231
|
+
doRegisterComponent(CategoryCollection, customCategoryCollectionMeta != null ? customCategoryCollectionMeta : categoryCollectionMeta);
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
var categoryFieldMeta = {
|
|
2235
|
+
name: "plasmic-commerce-category-field",
|
|
2236
|
+
displayName: "Category Field",
|
|
2237
|
+
props: {
|
|
2238
|
+
field: {
|
|
2239
|
+
type: "choice",
|
|
2240
|
+
options: ["id", "name", "slug", "path"]
|
|
2241
|
+
}
|
|
2242
|
+
},
|
|
2243
|
+
importPath: "@plasmicpkgs/commerce",
|
|
2244
|
+
importName: "CategoryField"
|
|
1808
2245
|
};
|
|
2246
|
+
function CategoryField(props) {
|
|
2247
|
+
var className = props.className,
|
|
2248
|
+
field = props.field;
|
|
2249
|
+
var category = useCategoryContext();
|
|
1809
2250
|
|
|
1810
|
-
|
|
2251
|
+
if (!field) {
|
|
2252
|
+
return React.createElement("span", null, "You must set the field prop");
|
|
2253
|
+
}
|
|
1811
2254
|
|
|
1812
|
-
var
|
|
1813
|
-
|
|
2255
|
+
var data = category ? category[field] : "Category field placeholder";
|
|
2256
|
+
return React.createElement("span", {
|
|
2257
|
+
className: className
|
|
2258
|
+
}, data);
|
|
2259
|
+
}
|
|
2260
|
+
function registerCategoryField(loader, customCategoryFieldMeta) {
|
|
2261
|
+
var doRegisterComponent = function doRegisterComponent() {
|
|
2262
|
+
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
2263
|
+
};
|
|
1814
2264
|
|
|
1815
|
-
|
|
1816
|
-
}
|
|
2265
|
+
doRegisterComponent(CategoryField, customCategoryFieldMeta != null ? customCategoryFieldMeta : categoryFieldMeta);
|
|
2266
|
+
}
|
|
1817
2267
|
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
}, hook))(input);
|
|
2268
|
+
|
|
2269
|
+
|
|
2270
|
+
var product = {
|
|
2271
|
+
__proto__: null
|
|
1823
2272
|
};
|
|
1824
2273
|
|
|
1825
|
-
var fetcher$
|
|
2274
|
+
var fetcher$6 = mutationFetcher;
|
|
1826
2275
|
|
|
1827
|
-
var fn$
|
|
2276
|
+
var fn$6 = function fn(provider) {
|
|
1828
2277
|
var _provider$cart;
|
|
1829
2278
|
|
|
1830
2279
|
return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useRemoveItem;
|
|
1831
2280
|
};
|
|
1832
2281
|
|
|
1833
2282
|
var useRemoveItem = function useRemoveItem(input) {
|
|
1834
|
-
var hook = useHook(fn$
|
|
2283
|
+
var hook = useHook(fn$6);
|
|
1835
2284
|
return useMutationHook(_extends({
|
|
1836
|
-
fetcher: fetcher$
|
|
2285
|
+
fetcher: fetcher$6
|
|
1837
2286
|
}, hook))(input);
|
|
1838
2287
|
};
|
|
1839
2288
|
|
|
1840
|
-
var fetcher$
|
|
2289
|
+
var fetcher$7 = mutationFetcher;
|
|
1841
2290
|
|
|
1842
|
-
var fn$
|
|
2291
|
+
var fn$7 = function fn(provider) {
|
|
1843
2292
|
var _provider$cart;
|
|
1844
2293
|
|
|
1845
2294
|
return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useUpdateItem;
|
|
1846
2295
|
};
|
|
1847
2296
|
|
|
1848
2297
|
var useUpdateItem = function useUpdateItem(input) {
|
|
1849
|
-
var hook = useHook(fn$
|
|
2298
|
+
var hook = useHook(fn$7);
|
|
1850
2299
|
return useMutationHook(_extends({
|
|
1851
|
-
fetcher: fetcher$
|
|
2300
|
+
fetcher: fetcher$7
|
|
1852
2301
|
}, hook))(input);
|
|
1853
2302
|
};
|
|
1854
2303
|
|
|
@@ -1869,11 +2318,15 @@ function registerAll(loader) {
|
|
|
1869
2318
|
registerTextField(loader);
|
|
1870
2319
|
registerProductPrice(loader);
|
|
1871
2320
|
registerProductMedia(loader);
|
|
1872
|
-
|
|
2321
|
+
registerCart(loader);
|
|
1873
2322
|
registerAddToCartButton(loader);
|
|
1874
2323
|
registerProductQuantity(loader);
|
|
1875
2324
|
registerProductVariantPicker(loader);
|
|
2325
|
+
registerProductBox(loader);
|
|
2326
|
+
registerProductLink(loader);
|
|
2327
|
+
registerCategoryCollection(loader);
|
|
2328
|
+
registerCategoryField(loader);
|
|
1876
2329
|
}
|
|
1877
2330
|
|
|
1878
|
-
export { cart as CartType, CommerceError, CoreCommerceProvider, FetcherError, product as ProductTypes, site as SiteTypes, ValidationError, fetcher$
|
|
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 };
|
|
1879
2332
|
//# sourceMappingURL=commerce.esm.js.map
|