@plasmicpkgs/commerce 0.0.247 → 0.0.248
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/api/endpoints/cart.d.ts +4 -4
- package/dist/api/endpoints/catalog/products.d.ts +4 -4
- package/dist/api/index.d.ts +75 -75
- package/dist/api/operations.d.ts +130 -130
- package/dist/api/utils/errors.d.ts +10 -10
- package/dist/api/utils/is-allowed-method.d.ts +3 -3
- package/dist/api/utils/is-allowed-operation.d.ts +6 -6
- package/dist/api/utils/types.d.ts +34 -34
- package/dist/cart/use-add-item.d.ts +5 -5
- package/dist/cart/use-cart.d.ts +5 -5
- package/dist/cart/use-remove-item.d.ts +5 -5
- package/dist/cart/use-update-item.d.ts +5 -5
- package/dist/commerce.cjs.development.js +23 -20
- 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 +43 -43
- package/dist/commerce.esm.js +23 -20
- package/dist/commerce.esm.js.map +1 -1
- package/dist/contexts.d.ts +26 -26
- package/dist/index.d.ts +46 -46
- package/dist/product/use-price.d.ts +26 -26
- package/dist/product/use-product.d.ts +5 -5
- package/dist/product/use-search.d.ts +6 -6
- package/dist/registerAddToCartButton.d.ts +10 -10
- package/dist/registerCart.d.ts +12 -12
- package/dist/registerCartProvider.d.ts +6 -6
- package/dist/registerCategoryCollection.d.ts +20 -20
- package/dist/registerCategoryField.d.ts +11 -11
- package/dist/registerCategoryLink.d.ts +12 -12
- package/dist/registerCategoryMedia.d.ts +11 -11
- package/dist/registerProductBox.d.ts +18 -18
- package/dist/registerProductCollection.d.ts +29 -29
- package/dist/registerProductLink.d.ts +12 -12
- package/dist/registerProductMedia.d.ts +14 -14
- package/dist/registerProductMediaCollection.d.ts +11 -11
- package/dist/registerProductPrice.d.ts +10 -10
- package/dist/registerProductQuantity.d.ts +11 -11
- package/dist/registerProductSlider.d.ts +14 -14
- package/dist/registerProductTextField.d.ts +11 -11
- package/dist/registerProductVariantPicker.d.ts +10 -10
- package/dist/registerable.d.ts +4 -4
- package/dist/site/use-brands.d.ts +5 -5
- package/dist/site/use-categories.d.ts +5 -5
- package/dist/types/cart.d.ts +157 -157
- package/dist/types/checkout.d.ts +57 -57
- package/dist/types/common.d.ts +13 -13
- package/dist/types/customer/address.d.ts +110 -110
- package/dist/types/customer/card.d.ts +113 -113
- package/dist/types/customer/index.d.ts +24 -24
- package/dist/types/index.d.ts +12 -12
- package/dist/types/login.d.ts +27 -27
- package/dist/types/logout.d.ts +17 -17
- package/dist/types/page.d.ts +24 -24
- package/dist/types/product.d.ts +117 -117
- package/dist/types/signup.d.ts +23 -23
- package/dist/types/site.d.ts +55 -55
- package/dist/types/wishlist.d.ts +83 -83
- package/dist/utils/default-fetcher.d.ts +4 -4
- package/dist/utils/default-product.d.ts +2 -2
- package/dist/utils/define-property.d.ts +21 -21
- package/dist/utils/errors.d.ts +27 -27
- package/dist/utils/get-product-price.d.ts +2 -2
- package/dist/utils/types.d.ts +99 -99
- package/dist/utils/use-data.d.ts +13 -13
- package/dist/utils/use-extra-features.d.ts +1 -1
- package/dist/utils/use-hook.d.ts +7 -7
- package/package.json +5 -5
package/dist/commerce.d.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import React, { ReactNode, MutableRefObject } from 'react';
|
|
2
|
-
import type { Product, Cart, Site } from './types';
|
|
3
|
-
import type { Fetcher, SWRHook, MutationHook, CommerceExtraFeatures } from './utils/types';
|
|
4
|
-
export
|
|
5
|
-
fetcher: Fetcher;
|
|
6
|
-
cart?: {
|
|
7
|
-
useCart?: SWRHook<Cart.GetCartHook>;
|
|
8
|
-
useAddItem?: MutationHook<Cart.AddItemHook>;
|
|
9
|
-
useUpdateItem?: MutationHook<Cart.UpdateItemHook>;
|
|
10
|
-
useRemoveItem?: MutationHook<Cart.RemoveItemHook>;
|
|
11
|
-
};
|
|
12
|
-
products?: {
|
|
13
|
-
useSearch?: SWRHook<Product.SearchProductsHook>;
|
|
14
|
-
useProduct?: SWRHook<Product.GetProductHook>;
|
|
15
|
-
};
|
|
16
|
-
site?: {
|
|
17
|
-
useCategories?: SWRHook<Site.GetCategoriesHook>;
|
|
18
|
-
useBrands?: SWRHook<Site.GetBrandsHook>;
|
|
19
|
-
};
|
|
20
|
-
extraFeatures?: CommerceExtraFeatures;
|
|
21
|
-
};
|
|
22
|
-
export
|
|
23
|
-
locale: string;
|
|
24
|
-
cartCookie: string;
|
|
25
|
-
};
|
|
26
|
-
export
|
|
27
|
-
providerRef: MutableRefObject<P>;
|
|
28
|
-
fetcherRef: MutableRefObject<Fetcher>;
|
|
29
|
-
} & CommerceConfig;
|
|
30
|
-
export
|
|
31
|
-
children?: ReactNode;
|
|
32
|
-
provider: P;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* These are the properties every provider should allow when implementing
|
|
36
|
-
* the core commerce provider
|
|
37
|
-
*/
|
|
38
|
-
export
|
|
39
|
-
children?: ReactNode;
|
|
40
|
-
} & Partial<CommerceConfig>;
|
|
41
|
-
export declare function CoreCommerceProvider<P extends Provider>({ provider, children, }: CommerceProps<P>): React.JSX.Element;
|
|
42
|
-
export declare function getCommerceProvider<P extends Provider>(provider: P): ({ children, ...props }: CommerceProviderProps) => React.JSX.Element;
|
|
43
|
-
export declare function useCommerce<P extends Provider>(): CommerceContextValue<P>;
|
|
1
|
+
import React, { ReactNode, MutableRefObject } from 'react';
|
|
2
|
+
import type { Product, Cart, Site } from './types';
|
|
3
|
+
import type { Fetcher, SWRHook, MutationHook, CommerceExtraFeatures } from './utils/types';
|
|
4
|
+
export type Provider = CommerceConfig & {
|
|
5
|
+
fetcher: Fetcher;
|
|
6
|
+
cart?: {
|
|
7
|
+
useCart?: SWRHook<Cart.GetCartHook>;
|
|
8
|
+
useAddItem?: MutationHook<Cart.AddItemHook>;
|
|
9
|
+
useUpdateItem?: MutationHook<Cart.UpdateItemHook>;
|
|
10
|
+
useRemoveItem?: MutationHook<Cart.RemoveItemHook>;
|
|
11
|
+
};
|
|
12
|
+
products?: {
|
|
13
|
+
useSearch?: SWRHook<Product.SearchProductsHook>;
|
|
14
|
+
useProduct?: SWRHook<Product.GetProductHook>;
|
|
15
|
+
};
|
|
16
|
+
site?: {
|
|
17
|
+
useCategories?: SWRHook<Site.GetCategoriesHook>;
|
|
18
|
+
useBrands?: SWRHook<Site.GetBrandsHook>;
|
|
19
|
+
};
|
|
20
|
+
extraFeatures?: CommerceExtraFeatures;
|
|
21
|
+
};
|
|
22
|
+
export type CommerceConfig = {
|
|
23
|
+
locale: string;
|
|
24
|
+
cartCookie: string;
|
|
25
|
+
};
|
|
26
|
+
export type CommerceContextValue<P extends Provider> = {
|
|
27
|
+
providerRef: MutableRefObject<P>;
|
|
28
|
+
fetcherRef: MutableRefObject<Fetcher>;
|
|
29
|
+
} & CommerceConfig;
|
|
30
|
+
export type CommerceProps<P extends Provider> = {
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
provider: P;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* These are the properties every provider should allow when implementing
|
|
36
|
+
* the core commerce provider
|
|
37
|
+
*/
|
|
38
|
+
export type CommerceProviderProps = {
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
} & Partial<CommerceConfig>;
|
|
41
|
+
export declare function CoreCommerceProvider<P extends Provider>({ provider, children, }: CommerceProps<P>): React.JSX.Element;
|
|
42
|
+
export declare function getCommerceProvider<P extends Provider>(provider: P): ({ children, ...props }: CommerceProviderProps) => React.JSX.Element;
|
|
43
|
+
export declare function useCommerce<P extends Provider>(): CommerceContextValue<P>;
|
package/dist/commerce.esm.js
CHANGED
|
@@ -282,9 +282,9 @@ function useCommerce() {
|
|
|
282
282
|
return useContext(Commerce);
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
/*
|
|
286
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
|
|
287
|
-
Changes: None
|
|
285
|
+
/*
|
|
286
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
|
|
287
|
+
Changes: None
|
|
288
288
|
*/
|
|
289
289
|
// Taken from https://fettblog.eu/typescript-assertion-signatures/
|
|
290
290
|
function defineProperty(obj, prop, val) {
|
|
@@ -303,6 +303,8 @@ var CommerceError = /*#__PURE__*/function (_Error) {
|
|
|
303
303
|
code: code
|
|
304
304
|
} : {}) : errors[0];
|
|
305
305
|
_this = _Error.call(this, error.message) || this;
|
|
306
|
+
_this.code = void 0;
|
|
307
|
+
_this.errors = void 0;
|
|
306
308
|
_this.errors = message ? [error] : errors;
|
|
307
309
|
if (error.code) _this.code = error.code;
|
|
308
310
|
return _this;
|
|
@@ -311,24 +313,25 @@ var CommerceError = /*#__PURE__*/function (_Error) {
|
|
|
311
313
|
return CommerceError;
|
|
312
314
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
313
315
|
// Used for errors that come from a bad implementation of the hooks
|
|
314
|
-
var ValidationError = /*#__PURE__*/function (
|
|
316
|
+
var ValidationError = /*#__PURE__*/function (_CommerceError2) {
|
|
315
317
|
function ValidationError(options) {
|
|
316
318
|
var _this2;
|
|
317
|
-
_this2 =
|
|
319
|
+
_this2 = _CommerceError2.call(this, options) || this;
|
|
318
320
|
_this2.code = 'validation_error';
|
|
319
321
|
return _this2;
|
|
320
322
|
}
|
|
321
|
-
_inheritsLoose(ValidationError,
|
|
323
|
+
_inheritsLoose(ValidationError, _CommerceError2);
|
|
322
324
|
return ValidationError;
|
|
323
325
|
}(CommerceError);
|
|
324
|
-
var FetcherError = /*#__PURE__*/function (
|
|
326
|
+
var FetcherError = /*#__PURE__*/function (_CommerceError3) {
|
|
325
327
|
function FetcherError(options) {
|
|
326
328
|
var _this3;
|
|
327
|
-
_this3 =
|
|
329
|
+
_this3 = _CommerceError3.call(this, options) || this;
|
|
330
|
+
_this3.status = void 0;
|
|
328
331
|
_this3.status = options.status;
|
|
329
332
|
return _this3;
|
|
330
333
|
}
|
|
331
|
-
_inheritsLoose(FetcherError,
|
|
334
|
+
_inheritsLoose(FetcherError, _CommerceError3);
|
|
332
335
|
return FetcherError;
|
|
333
336
|
}(CommerceError);
|
|
334
337
|
|
|
@@ -400,9 +403,9 @@ var useData = function useData(options, input, fetcherFn, swrOptions, provider)
|
|
|
400
403
|
return response;
|
|
401
404
|
};
|
|
402
405
|
|
|
403
|
-
/*
|
|
404
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
|
|
405
|
-
Changes: Add provider to useSWRHook and useMutationHook
|
|
406
|
+
/*
|
|
407
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
|
|
408
|
+
Changes: Add provider to useSWRHook and useMutationHook
|
|
406
409
|
*/
|
|
407
410
|
function useFetcher() {
|
|
408
411
|
var _providerRef$current$;
|
|
@@ -540,7 +543,7 @@ function ProductProvider(_ref) {
|
|
|
540
543
|
name: productSelector,
|
|
541
544
|
data: product,
|
|
542
545
|
key: product.id
|
|
543
|
-
}, React.createElement(FormProvider,
|
|
546
|
+
}, React.createElement(FormProvider, _extends({}, methods), children));
|
|
544
547
|
}
|
|
545
548
|
var useProduct = function useProduct() {
|
|
546
549
|
var product = useSelector(productSelector);
|
|
@@ -768,9 +771,9 @@ var useCart = function useCart(input) {
|
|
|
768
771
|
}))(input);
|
|
769
772
|
};
|
|
770
773
|
|
|
771
|
-
/*
|
|
772
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
|
|
773
|
-
Changes: None
|
|
774
|
+
/*
|
|
775
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
|
|
776
|
+
Changes: None
|
|
774
777
|
*/
|
|
775
778
|
function formatPrice(_ref) {
|
|
776
779
|
var amount = _ref.amount,
|
|
@@ -1882,7 +1885,7 @@ function ProductVariantPicker(props) {
|
|
|
1882
1885
|
render: function render(_ref) {
|
|
1883
1886
|
var _product$variants$map;
|
|
1884
1887
|
var field = _ref.field;
|
|
1885
|
-
return React.createElement("select",
|
|
1888
|
+
return React.createElement("select", _extends({
|
|
1886
1889
|
className: className
|
|
1887
1890
|
}, field), (_product$variants$map = product == null ? void 0 : product.variants.map(function (variant) {
|
|
1888
1891
|
return React.createElement("option", {
|
|
@@ -1911,9 +1914,9 @@ var product = {
|
|
|
1911
1914
|
__proto__: null
|
|
1912
1915
|
};
|
|
1913
1916
|
|
|
1914
|
-
/*
|
|
1915
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
|
|
1916
|
-
Changes: Added CategoryImage and depth/children/parent_id to Category
|
|
1917
|
+
/*
|
|
1918
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
|
|
1919
|
+
Changes: Added CategoryImage and depth/children/parent_id to Category
|
|
1917
1920
|
*/
|
|
1918
1921
|
|
|
1919
1922
|
var site = {
|