@commercelayer/react-components 4.2.0 → 4.2.1-beta.1

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.
Files changed (83) hide show
  1. package/lib/cjs/components/addresses/Address.d.ts +2 -1
  2. package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +5 -4
  3. package/lib/cjs/components/addresses/ShippingAddressContainer.d.ts +2 -1
  4. package/lib/cjs/components/auth/CommerceLayer.d.ts +2 -1
  5. package/lib/cjs/components/errors/Errors.d.ts +28 -2
  6. package/lib/cjs/components/gift_cards/GiftCard.d.ts +2 -1
  7. package/lib/cjs/components/line_items/LineItem.d.ts +2 -2
  8. package/lib/cjs/components/line_items/LineItemImage.d.ts +3 -2
  9. package/lib/cjs/components/line_items/LineItemsContainer.d.ts +3 -3
  10. package/lib/cjs/components/line_items/LineItemsContainer.js +1 -1
  11. package/lib/cjs/components/orders/OrderContainer.d.ts +2 -1
  12. package/lib/cjs/components/orders/OrderContainer.js +1 -1
  13. package/lib/cjs/components/orders/OrderList.d.ts +2 -1
  14. package/lib/cjs/components/orders/PlaceOrderButton.js +1 -1
  15. package/lib/cjs/components/parcels/ParcelLineItem.d.ts +2 -1
  16. package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -1
  17. package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +5 -4
  18. package/lib/cjs/components/payment_methods/PaymentMethod.js +1 -1
  19. package/lib/cjs/components/shipments/Shipment.js +1 -1
  20. package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +2 -1
  21. package/lib/cjs/components/utils/BaseInput.d.ts +1 -1
  22. package/lib/cjs/components/utils/getAllErrors.d.ts +3 -2
  23. package/lib/cjs/index.d.ts +1 -2
  24. package/lib/cjs/index.js +1 -1
  25. package/lib/cjs/reducers/AddressReducer.d.ts +4 -3
  26. package/lib/cjs/reducers/OrderReducer.js +1 -1
  27. package/lib/cjs/reducers/PaymentMethodReducer.js +1 -1
  28. package/lib/cjs/typings/errors.d.ts +2 -42
  29. package/lib/cjs/typings/errors.js +1 -1
  30. package/lib/cjs/typings/globals.d.ts +1 -0
  31. package/lib/cjs/typings/globals.js +1 -0
  32. package/lib/cjs/typings/index.d.ts +5 -14
  33. package/lib/cjs/typings/index.js +1 -1
  34. package/lib/cjs/utils/filterChildren.d.ts +3 -2
  35. package/lib/cjs/utils/filterChildren.js +1 -1
  36. package/lib/cjs/utils/getErrors.d.ts +3 -2
  37. package/lib/cjs/utils/getLineItemsCount.d.ts +2 -2
  38. package/lib/cjs/utils/getLoaderComponent.d.ts +1 -1
  39. package/lib/cjs/utils/getLoaderComponent.js +1 -1
  40. package/lib/cjs/utils/validateFormFields.d.ts +4 -3
  41. package/lib/esm/components/addresses/Address.d.ts +2 -1
  42. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +5 -4
  43. package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +2 -1
  44. package/lib/esm/components/auth/CommerceLayer.d.ts +2 -1
  45. package/lib/esm/components/errors/Errors.d.ts +28 -2
  46. package/lib/esm/components/gift_cards/GiftCard.d.ts +2 -1
  47. package/lib/esm/components/line_items/LineItem.d.ts +2 -2
  48. package/lib/esm/components/line_items/LineItemImage.d.ts +3 -2
  49. package/lib/esm/components/line_items/LineItemsContainer.d.ts +3 -3
  50. package/lib/esm/components/line_items/LineItemsContainer.js +1 -1
  51. package/lib/esm/components/orders/OrderContainer.d.ts +2 -1
  52. package/lib/esm/components/orders/OrderContainer.js +1 -1
  53. package/lib/esm/components/orders/OrderList.d.ts +2 -1
  54. package/lib/esm/components/orders/PlaceOrderButton.js +1 -1
  55. package/lib/esm/components/parcels/ParcelLineItem.d.ts +2 -1
  56. package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -1
  57. package/lib/esm/components/payment_methods/PaymentMethod.d.ts +5 -4
  58. package/lib/esm/components/payment_methods/PaymentMethod.js +1 -1
  59. package/lib/esm/components/shipments/Shipment.js +1 -1
  60. package/lib/esm/components/stock_transfers/StockTransfer.d.ts +2 -1
  61. package/lib/esm/components/utils/BaseInput.d.ts +1 -1
  62. package/lib/esm/components/utils/getAllErrors.d.ts +3 -2
  63. package/lib/esm/index.d.ts +1 -2
  64. package/lib/esm/index.js +1 -1
  65. package/lib/esm/reducers/AddressReducer.d.ts +4 -3
  66. package/lib/esm/reducers/OrderReducer.js +1 -1
  67. package/lib/esm/reducers/PaymentMethodReducer.js +1 -1
  68. package/lib/esm/typings/errors.d.ts +2 -42
  69. package/lib/esm/typings/errors.js +1 -1
  70. package/lib/esm/typings/globals.d.ts +1 -0
  71. package/lib/esm/typings/globals.js +1 -0
  72. package/lib/esm/typings/index.d.ts +5 -14
  73. package/lib/esm/typings/index.js +1 -1
  74. package/lib/esm/utils/filterChildren.d.ts +3 -2
  75. package/lib/esm/utils/filterChildren.js +1 -1
  76. package/lib/esm/utils/getErrors.d.ts +3 -2
  77. package/lib/esm/utils/getLineItemsCount.d.ts +2 -2
  78. package/lib/esm/utils/getLoaderComponent.d.ts +1 -1
  79. package/lib/esm/utils/getLoaderComponent.js +1 -1
  80. package/lib/esm/utils/validateFormFields.d.ts +4 -3
  81. package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
  82. package/lib/tsconfig.prod.tsbuildinfo +1 -1
  83. package/package.json +1 -1
@@ -1,51 +1,11 @@
1
- import PropTypes from 'prop-types';
2
- import { ChildrenFunction } from './index';
1
+ import { TResourceError } from "../components/errors/Errors";
3
2
  export type CodeErrorType = 'EMPTY_ERROR' | 'FILTER_NOT_ALLOWED' | 'FORBIDDEN' | 'INTERNAL_SERVER_ERROR' | 'INVALID_DATA_FORMAT' | 'INVALID_FIELD' | 'INVALID_FIELD_FORMAT' | 'INVALID_FIELD_VALUE' | 'INVALID_FILTERS_SYNTAX' | 'INVALID_FILTER_VALUE' | 'INVALID_INCLUDE' | 'INVALID_LINKS_OBJECT' | 'INVALID_PAGE_OBJECT' | 'INVALID_PAGE_VALUE' | 'INVALID_RESOURCE' | 'INVALID_RESOURCE_ID' | 'INVALID_SORT_CRITERIA' | 'INVALID_TOKEN' | 'KEY_NOT_INCLUDED_IN_URL' | 'KEY_ORDER_MISMATCH' | 'LOCKED' | 'NOT_ACCEPTABLE' | 'OUT_OF_STOCK' | 'PARAM_MISSING' | 'PARAM_NOT_ALLOWED' | 'PAYMENT_NOT_APPROVED_FOR_EXECUTION' | 'PAYMENT_INTENT_AUTHENTICATION_FAILURE' | 'RECORD_NOT_FOUND' | 'RECORD_NOT_FOUND' | 'RELATION_EXISTS' | 'NO_SHIPPING_METHODS' | 'SAVE_FAILED' | 'TYPE_MISMATCH' | 'UNAUTHORIZED' | 'UNSUPPORTED_MEDIA_TYPE' | 'VALIDATION_ERROR';
4
- export type ResourceErrorType = 'addresses' | 'billing_address' | 'gift_cards' | 'gift_card_or_coupon_code' | 'line_items' | 'orders' | 'payment_methods' | 'prices' | 'shipments' | 'shipping_address' | 'customer_address' | 'sku_options' | 'variant';
5
3
  export interface BaseError {
6
4
  code: CodeErrorType;
7
5
  message: string;
8
- resource?: ResourceErrorType | null;
6
+ resource?: TResourceError | null;
9
7
  field?: string;
10
8
  id?: string;
11
9
  title?: string;
12
10
  detail?: string;
13
11
  }
14
- export declare const REType: ResourceErrorType[];
15
- export declare const BaseErrorObject: PropTypes.Requireable<PropTypes.InferProps<{
16
- code: PropTypes.Validator<NonNullable<CodeErrorType>>;
17
- message: PropTypes.Validator<string>;
18
- resource: PropTypes.Requireable<ResourceErrorType>;
19
- field: PropTypes.Requireable<string>;
20
- id: PropTypes.Requireable<string>;
21
- }>>;
22
- export declare const ErrorPropTypes: {
23
- resource: PropTypes.Validator<NonNullable<ResourceErrorType>>;
24
- children: PropTypes.Requireable<(...args: any[]) => any>;
25
- field: PropTypes.Requireable<string>;
26
- };
27
- type ErrorChildrenComponentProps = ChildrenFunction<Omit<ErrorComponentProps, 'children'> & {
28
- errors: string[];
29
- }>;
30
- export interface ErrorComponentProps {
31
- /**
32
- * Resource which get the error
33
- */
34
- resource: ResourceErrorType;
35
- children?: ErrorChildrenComponentProps;
36
- /**
37
- * Field which get the error
38
- */
39
- field?: string;
40
- /**
41
- * Error message which you can translate
42
- */
43
- messages?: Array<{
44
- code: CodeErrorType;
45
- message: string;
46
- resource?: ResourceErrorType;
47
- field?: string;
48
- id?: string;
49
- }>;
50
- }
51
- export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ErrorPropTypes=exports.BaseErrorObject=exports.REType=void 0;const tslib_1=require("tslib"),prop_types_1=tslib_1.__importDefault(require("prop-types")),CEType=["EMPTY_ERROR","FILTER_NOT_ALLOWED","FORBIDDEN","INTERNAL_SERVER_ERROR","INVALID_DATA_FORMAT","INVALID_FIELD","INVALID_FIELD_FORMAT","INVALID_FIELD_VALUE","INVALID_FILTERS_SYNTAX","INVALID_FILTER_VALUE","INVALID_INCLUDE","INVALID_LINKS_OBJECT","INVALID_PAGE_OBJECT","INVALID_PAGE_VALUE","INVALID_RESOURCE","INVALID_RESOURCE_ID","INVALID_SORT_CRITERIA","INVALID_TOKEN","KEY_NOT_INCLUDED_IN_URL","KEY_ORDER_MISMATCH","LOCKED","NOT_ACCEPTABLE","PARAM_MISSING","PARAM_NOT_ALLOWED","RECORD_NOT_FOUND","RECORD_NOT_FOUND","RELATION_EXISTS","SAVE_FAILED","TYPE_MISMATCH","UNAUTHORIZED","UNSUPPORTED_MEDIA_TYPE","VALIDATION_ERROR"];exports.REType=["gift_cards","line_items","orders","prices","sku_options","variant"],exports.BaseErrorObject=prop_types_1.default.shape({code:prop_types_1.default.oneOf(CEType).isRequired,message:prop_types_1.default.string.isRequired,resource:prop_types_1.default.oneOf(exports.REType),field:prop_types_1.default.string,id:prop_types_1.default.string}),exports.ErrorPropTypes={resource:prop_types_1.default.oneOf(["billing_address","gift_cards","line_items","orders","payment_methods","prices","shipping_address","customer_address","sku_options","variant","shipments"]).isRequired,children:prop_types_1.default.func,field:prop_types_1.default.string};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1 @@
1
+ export type DefaultChildrenType = JSX.Element[] | JSX.Element | null;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -1,4 +1,4 @@
1
- import { Dispatch, ForwardedRef, ReactNode, Ref } from 'react';
1
+ import { Dispatch, ForwardedRef, Ref } from 'react';
2
2
  import PropTypes, { InferProps } from 'prop-types';
3
3
  import { BaseError } from './errors';
4
4
  export declare const BC: {
@@ -39,13 +39,6 @@ export interface BaseSelectComponentProps {
39
39
  name: string;
40
40
  onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
41
41
  }
42
- export declare const BaseInputComponentPropTypes: {
43
- children: PropTypes.Requireable<(...args: any[]) => any>;
44
- name: PropTypes.Validator<string>;
45
- type: PropTypes.Validator<NonNullable<BaseInputType>>;
46
- onChange: PropTypes.Requireable<(...args: any[]) => any>;
47
- placeholder: PropTypes.Requireable<string>;
48
- };
49
42
  type BaseInputChildrenComponentProps = Omit<BaseInputComponentProps, 'children'> & {
50
43
  handleChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
51
44
  parentRef: ForwardedRef<any>;
@@ -57,13 +50,11 @@ export interface BaseInputComponentProps {
57
50
  onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
58
51
  placeholder?: string;
59
52
  }
60
- export type LineItemType = 'gift_cards' | 'payment_methods' | 'promotions' | 'shipments' | 'skus' | 'bundles' | 'adjustments';
61
53
  export type GiftCardInputName = 'balanceCents' | 'balanceMaxCents' | 'singleUse' | 'rechargeable' | 'imageUrl' | 'expiresAt' | 'referenceOrigin' | 'email' | 'firstName' | 'lastName' | 'reference';
62
- export type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | 'customer_address_city' | 'customer_address_company' | 'customer_address_first_name' | 'customer_address_email' | 'customer_address_last_name' | 'customer_address_line_1' | 'customer_address_line_2' | 'customer_address_phone' | 'customer_address_state_code' | 'customer_address_zip_code' | 'customer_address_billing_info' | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
63
- export type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code' | 'customer_address_country_code';
64
- export type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code' | 'customer_address_state_code';
65
- export type BaseInputType = 'checkbox' | 'date' | 'email' | 'number' | 'tel' | 'text' | 'textarea';
66
- export type LoaderType = string | ReactNode;
54
+ export type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
55
+ export type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code';
56
+ export type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code';
57
+ export type LoaderType = string | JSX.Element;
67
58
  export declare const BMObject: PropTypes.Requireable<{
68
59
  [x: string]: string | null | undefined;
69
60
  }>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.baseOrderComponentPricePropTypes=exports.baseOrderPricePropTypes=exports.BMObject=exports.BaseInputComponentPropTypes=exports.BaseSelectComponentPropTypes=exports.PTLoader=exports.BC=void 0;const tslib_1=require("tslib"),prop_types_1=tslib_1.__importDefault(require("prop-types"));exports.BC={id:prop_types_1.default.string,className:prop_types_1.default.string,style:prop_types_1.default.object,name:prop_types_1.default.string},exports.PTLoader=prop_types_1.default.oneOfType([prop_types_1.default.element,prop_types_1.default.string]),exports.BaseSelectComponentPropTypes={children:prop_types_1.default.func,options:prop_types_1.default.arrayOf(prop_types_1.default.shape({label:prop_types_1.default.string.isRequired,value:prop_types_1.default.oneOfType([prop_types_1.default.string,prop_types_1.default.number]).isRequired,selected:prop_types_1.default.bool}).isRequired).isRequired,placeholder:prop_types_1.default.shape({label:prop_types_1.default.string.isRequired,value:prop_types_1.default.oneOfType([prop_types_1.default.string,prop_types_1.default.number]).isRequired}),value:prop_types_1.default.string,name:prop_types_1.default.string.isRequired},exports.BaseInputComponentPropTypes={children:prop_types_1.default.func,name:prop_types_1.default.string.isRequired,type:prop_types_1.default.oneOf(["text","email","number","date","checkbox","textarea"]).isRequired,onChange:prop_types_1.default.func,placeholder:prop_types_1.default.string},exports.BMObject=prop_types_1.default.objectOf(prop_types_1.default.string),exports.baseOrderPricePropTypes={base:prop_types_1.default.string.isRequired,type:prop_types_1.default.string.isRequired,children:prop_types_1.default.func,format:prop_types_1.default.oneOf(["formatted","cents","float"]),...exports.BC},exports.baseOrderComponentPricePropTypes={children:exports.baseOrderPricePropTypes.children,format:exports.baseOrderPricePropTypes.format,...exports.BC};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.baseOrderComponentPricePropTypes=exports.baseOrderPricePropTypes=exports.BMObject=exports.BaseSelectComponentPropTypes=exports.PTLoader=exports.BC=void 0;const tslib_1=require("tslib"),prop_types_1=tslib_1.__importDefault(require("prop-types"));exports.BC={id:prop_types_1.default.string,className:prop_types_1.default.string,style:prop_types_1.default.object,name:prop_types_1.default.string},exports.PTLoader=prop_types_1.default.oneOfType([prop_types_1.default.element,prop_types_1.default.string]),exports.BaseSelectComponentPropTypes={children:prop_types_1.default.func,options:prop_types_1.default.arrayOf(prop_types_1.default.shape({label:prop_types_1.default.string.isRequired,value:prop_types_1.default.oneOfType([prop_types_1.default.string,prop_types_1.default.number]).isRequired,selected:prop_types_1.default.bool}).isRequired).isRequired,placeholder:prop_types_1.default.shape({label:prop_types_1.default.string.isRequired,value:prop_types_1.default.oneOfType([prop_types_1.default.string,prop_types_1.default.number]).isRequired}),value:prop_types_1.default.string,name:prop_types_1.default.string.isRequired},exports.BMObject=prop_types_1.default.objectOf(prop_types_1.default.string),exports.baseOrderPricePropTypes={base:prop_types_1.default.string.isRequired,type:prop_types_1.default.string.isRequired,children:prop_types_1.default.func,format:prop_types_1.default.oneOf(["formatted","cents","float"]),...exports.BC},exports.baseOrderComponentPricePropTypes={children:exports.baseOrderPricePropTypes.children,format:exports.baseOrderPricePropTypes.format,...exports.BC};
@@ -1,7 +1,8 @@
1
+ import { DefaultChildrenType } from "../typings/globals";
1
2
  interface Props<T> {
2
- children: JSX.Element | JSX.Element[];
3
+ children: DefaultChildrenType;
3
4
  filterBy: T[];
4
5
  componentName: string;
5
6
  }
6
- export default function filterChildren<T = string>({ children, filterBy, componentName }: Props<T>): JSX.Element | JSX.Element[];
7
+ export default function filterChildren<T = string>({ children, filterBy, componentName }: Props<T>): JSX.Element | JSX.Element[] | null;
7
8
  export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});function filterChildren({children,filterBy,componentName}){if(Array.isArray(children)?children.filter(child=>typeof child.type=="string").length>0:typeof children.type=="string")throw new Error(`Only library components are allowed into <${componentName}/>`);return Array.isArray(children)?children.filter(child=>filterBy.includes(child.type.displayName)):children}exports.default=filterChildren;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});function filterChildren({children,filterBy,componentName}){if(Array.isArray(children)?children.filter(child=>typeof child.type=="string").length>0:typeof children?.type=="string")throw new Error(`Only library components are allowed into <${componentName}/>`);return Array.isArray(children)?children.filter(child=>filterBy.includes(child.type.displayName)):children}exports.default=filterChildren;
@@ -1,6 +1,7 @@
1
- import { BaseError, ResourceErrorType } from '../typings/errors';
1
+ import { TResourceError } from '../components/errors/Errors';
2
+ import { BaseError } from '../typings/errors';
2
3
  import { Dispatch } from 'react';
3
- export default function getErrors(error: any, resource: ResourceErrorType, field?: string): BaseError[];
4
+ export default function getErrors(error: any, resource: TResourceError, field?: string): BaseError[];
4
5
  type SetErrorsArgs<D> = {
5
6
  currentErrors?: BaseError[];
6
7
  newErrors?: BaseError[];
@@ -1,6 +1,6 @@
1
+ import type { TLineItem } from '../components/line_items/LineItem';
1
2
  import type { LineItem } from '@commercelayer/sdk';
2
- import { LineItemType } from '../typings/index';
3
- export type TypeAccepted = Extract<LineItemType, 'skus' | 'gift_cards' | 'bundles' | 'adjustments'>;
3
+ export type TypeAccepted = Extract<TLineItem, 'skus' | 'gift_cards' | 'bundles' | 'adjustments'>;
4
4
  interface Args {
5
5
  lineItems: LineItem[];
6
6
  quantity?: number;
@@ -1,2 +1,2 @@
1
1
  import { LoaderType } from '../typings/index';
2
- export default function getLoaderComponent(Loader: LoaderType): JSX.Element;
2
+ export default function getLoaderComponent(loader: LoaderType): JSX.Element;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const jsx_runtime_1=require("react/jsx-runtime");function getLoaderComponent(Loader){return(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:Loader})}exports.default=getLoaderComponent;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const jsx_runtime_1=require("react/jsx-runtime");function getLoaderComponent(loader){return(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:loader})}exports.default=getLoaderComponent;
@@ -1,13 +1,14 @@
1
1
  import { BaseState } from '../typings/index';
2
- import { ResourceErrorType, BaseError } from '../typings/errors';
2
+ import { BaseError } from '../typings/errors';
3
3
  import { AddressField } from '../reducers/AddressReducer';
4
4
  import { AddressCreate } from '@commercelayer/sdk';
5
5
  import { AddressInputName } from '../typings/index';
6
- export type ValidateFormFields = <R extends string[]>(fields: HTMLFormControlsCollection, required: R, resourceType: ResourceErrorType) => {
6
+ import { TResourceError } from '../components/errors/Errors';
7
+ export type ValidateFormFields = <R extends string[]>(fields: HTMLFormControlsCollection, required: R, resourceType: TResourceError) => {
7
8
  errors: BaseError[];
8
9
  values: BaseState;
9
10
  };
10
- export type ValidateValue = <V extends string | boolean, N extends string, T extends string, B extends ResourceErrorType>(val: V, name: N, type: T, resourceType: B) => BaseError | Record<string, any>;
11
+ export type ValidateValue = <V extends string | boolean, N extends string, T extends string, B extends TResourceError>(val: V, name: N, type: T, resourceType: B) => BaseError | Record<string, any>;
11
12
  export declare const validateValue: ValidateValue;
12
13
  declare const validateFormFields: ValidateFormFields;
13
14
  export type FieldsExist = (address: AddressCreate, schema?: AddressField[]) => boolean;
@@ -1,7 +1,8 @@
1
1
  import type { Address as AddressType } from '@commercelayer/sdk';
2
2
  import { AddressCardsTemplateChildren } from '../utils/AddressCardsTemplate';
3
+ import type { DefaultChildrenType } from '../../typings/globals';
3
4
  interface Props extends Omit<JSX.IntrinsicElements['div'], 'children' | 'onSelect'> {
4
- children: JSX.Element[] | JSX.Element | AddressCardsTemplateChildren;
5
+ children: DefaultChildrenType | AddressCardsTemplateChildren;
5
6
  selectedClassName?: string;
6
7
  disabledClassName?: string;
7
8
  onSelect?: (address: AddressType) => void;
@@ -1,9 +1,10 @@
1
- import { AddressCountrySelectName, BaseSelectComponentProps } from '../../typings/index';
1
+ import { BaseSelectComponentProps } from '../../typings/index';
2
2
  import { AddressValuesKeys } from '../../context/BillingAddressFormContext';
3
- type Props = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
4
- name: Extract<AddressValuesKeys, AddressCountrySelectName>;
3
+ type TCountryFieldName = 'billing_address_country_code' | 'shipping_address_country_code' | 'customer_address_country_code';
4
+ interface Props extends Omit<BaseSelectComponentProps, 'options' | 'name'>, Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'> {
5
+ name: Extract<AddressValuesKeys, TCountryFieldName>;
5
6
  required?: boolean;
6
7
  disabled?: boolean;
7
- } & Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'>;
8
+ }
8
9
  export declare function AddressCountrySelector(props: Props): JSX.Element;
9
10
  export default AddressCountrySelector;
@@ -1,5 +1,6 @@
1
+ import type { DefaultChildrenType } from '../../typings/globals';
1
2
  interface Props {
2
- children: JSX.Element[] | JSX.Element;
3
+ children: DefaultChildrenType;
3
4
  }
4
5
  export declare function ShippingAddressContainer(props: Props): JSX.Element;
5
6
  export default ShippingAddressContainer;
@@ -1,5 +1,6 @@
1
+ import type { DefaultChildrenType } from '../../typings/globals';
1
2
  interface Props {
2
- children: JSX.Element[] | JSX.Element;
3
+ children: DefaultChildrenType;
3
4
  accessToken: string;
4
5
  endpoint: string;
5
6
  }
@@ -1,4 +1,30 @@
1
- import type { ErrorComponentProps } from '../../typings/errors';
2
- type Props = ErrorComponentProps & Omit<JSX.IntrinsicElements['span'], 'children'>;
1
+ import type { CodeErrorType } from '../../typings/errors';
2
+ import { ChildrenFunction } from '../../typings/index';
3
+ export type TResourceError = 'addresses' | 'billing_address' | 'gift_cards' | 'gift_card_or_coupon_code' | 'line_items' | 'orders' | 'payment_methods' | 'prices' | 'shipments' | 'shipping_address' | 'customer_address' | 'sku_options' | 'variant';
4
+ type ErrorChildrenComponentProps = ChildrenFunction<Omit<TErrorComponent, 'children'> & {
5
+ errors: string[];
6
+ }>;
7
+ export interface TErrorComponent extends Omit<JSX.IntrinsicElements['span'], 'children'> {
8
+ /**
9
+ * Resource which get the error
10
+ */
11
+ resource: TResourceError;
12
+ children?: ErrorChildrenComponentProps;
13
+ /**
14
+ * Field which get the error
15
+ */
16
+ field?: string;
17
+ /**
18
+ * Error message which you can translate
19
+ */
20
+ messages?: Array<{
21
+ code: CodeErrorType;
22
+ message: string;
23
+ resource?: TResourceError;
24
+ field?: string;
25
+ id?: string;
26
+ }>;
27
+ }
28
+ type Props = TErrorComponent;
3
29
  export declare function Errors(props: Props): JSX.Element;
4
30
  export default Errors;
@@ -1,6 +1,7 @@
1
1
  import { BaseState } from '../../typings/index';
2
+ import type { DefaultChildrenType } from '../../typings/globals';
2
3
  interface Props extends Omit<JSX.IntrinsicElements['form'], 'children'> {
3
- children: JSX.Element[] | JSX.Element;
4
+ children: DefaultChildrenType;
4
5
  onSubmit?: (values: BaseState) => void;
5
6
  }
6
7
  export declare function GiftCard(props: Props): JSX.Element;
@@ -1,7 +1,7 @@
1
- import { LineItemType } from '../../typings/index';
1
+ export type TLineItem = 'gift_cards' | 'payment_methods' | 'promotions' | 'shipments' | 'skus' | 'bundles' | 'adjustments';
2
2
  interface Props {
3
3
  children: JSX.Element | JSX.Element[];
4
- type?: LineItemType;
4
+ type?: TLineItem;
5
5
  }
6
6
  export declare function LineItem(props: Props): JSX.Element;
7
7
  export default LineItem;
@@ -1,5 +1,6 @@
1
1
  import { LineItem } from '@commercelayer/sdk';
2
- import { ChildrenFunction, LineItemType } from '../../typings/index';
2
+ import type { ChildrenFunction } from '../../typings/index';
3
+ import { TLineItem } from './LineItem';
3
4
  export interface TLineItemImage extends Omit<Props, 'children'> {
4
5
  src: string;
5
6
  lineItem: LineItem;
@@ -8,7 +9,7 @@ type Props = {
8
9
  children?: ChildrenFunction<TLineItemImage>;
9
10
  width?: number;
10
11
  placeholder?: {
11
- [K in LineItemType]?: string;
12
+ [K in TLineItem]?: string;
12
13
  };
13
14
  } & Omit<JSX.IntrinsicElements['img'], 'src' | 'srcSet' | 'placeholder'>;
14
15
  export declare function LineItemImage(props: Props): JSX.Element | null;
@@ -1,8 +1,8 @@
1
- import { ReactNode } from 'react';
1
+ import type { DefaultChildrenType } from '../../typings/globals';
2
2
  interface Props {
3
- children: ReactNode;
3
+ children: DefaultChildrenType;
4
4
  filters?: Record<string, any>;
5
- loader?: ReactNode;
5
+ loader?: JSX.Element;
6
6
  }
7
7
  export declare function LineItemsContainer(props: Props): JSX.Element;
8
8
  export default LineItemsContainer;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext}from"react";import lineItemReducer,{lineItemInitialState,updateLineItem,deleteLineItem}from"../../reducers/LineItemReducer";import OrderContext from"../../context/OrderContext";import LineItemContext from"../../context/LineItemContext";import CommerceLayerContext from"../../context/CommerceLayerContext";export function LineItemsContainer(props){const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext),[state,dispatch]=useReducer(lineItemReducer,lineItemInitialState);useEffect(()=>{include?.includes("line_items.line_item_options.sku_option")?includeLoaded?.["line_items.line_item_options.sku_option"]||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:["line_items.line_item_options.sku_option"]}),include?.includes("line_items.item")?includeLoaded?.["line_items.item"]||addResourceToInclude({newResourceLoaded:{"line_items.item":!0}}):addResourceToInclude({newResource:["line_items.item"]})},[include,includeLoaded]),useEffect(()=>{order?.line_items&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}})},[order?.line_items]);const lineItemValue={...state,loader,updateLineItem:(lineItemId,quantity=1)=>updateLineItem({lineItemId,quantity,dispatch,config,getOrder,orderId,errors:state.errors}),deleteLineItem:lineItemId=>deleteLineItem({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})};return _jsx(LineItemContext.Provider,{value:lineItemValue,children:state.loading?loader:children})}export default LineItemsContainer;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext}from"react";import lineItemReducer,{lineItemInitialState,updateLineItem,deleteLineItem}from"../../reducers/LineItemReducer";import OrderContext from"../../context/OrderContext";import LineItemContext from"../../context/LineItemContext";import CommerceLayerContext from"../../context/CommerceLayerContext";export function LineItemsContainer(props){const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext),[state,dispatch]=useReducer(lineItemReducer,lineItemInitialState);useEffect(()=>{include?.includes("line_items.line_item_options.sku_option")?includeLoaded?.["line_items.line_item_options.sku_option"]||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:["line_items.line_item_options.sku_option"]}),include?.includes("line_items.item")?includeLoaded?.["line_items.item"]||addResourceToInclude({newResourceLoaded:{"line_items.item":!0}}):addResourceToInclude({newResource:["line_items.item"]})},[include,includeLoaded]),useEffect(()=>{order?.line_items&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}})},[order?.line_items]);const lineItemValue={...state,loader,updateLineItem:async(lineItemId,quantity=1)=>await updateLineItem({lineItemId,quantity,dispatch,config,getOrder,orderId,errors:state.errors}),deleteLineItem:async lineItemId=>await deleteLineItem({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})};return _jsx(LineItemContext.Provider,{value:lineItemValue,children:state.loading?loader:children})}export default LineItemsContainer;
@@ -1,7 +1,8 @@
1
1
  import { BaseMetadataObject } from '../../typings/index';
2
2
  import type { OrderCreate, Order } from '@commercelayer/sdk';
3
+ import type { DefaultChildrenType } from '../../typings/globals';
3
4
  interface Props {
4
- children: JSX.Element[] | JSX.Element;
5
+ children: DefaultChildrenType;
5
6
  /**
6
7
  * Metadata to add when creates a new order
7
8
  */
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext,useMemo,useState}from"react";import orderReducer,{createOrder,getApiOrder,setOrderErrors,setOrder,orderInitialState,updateOrder,addToCart}from"../../reducers/OrderReducer";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext,{defaultOrderContext}from"../../context/OrderContext";import OrderStorageContext from"../../context/OrderStorageContext";import compareObjAttribute from"../../utils/compareObjAttribute";import useCustomContext from"../../utils/hooks/useCustomContext";export function OrderContainer(props){const{orderId,children,metadata,attributes,fetchOrder}=props,[state,dispatch]=useReducer(orderReducer,orderInitialState),[lock,setLock]=useState(!1),[lockOrder,setLockOrder]=useState(!0),config=useCustomContext({context:CommerceLayerContext,contextComponentName:"CommerceLayer",currentComponentName:"OrderContainer",key:"accessToken"}),{persistKey,clearWhenPlaced,getLocalOrder,setLocalOrder,deleteLocalOrder}=useContext(OrderStorageContext);useEffect(()=>{state.withoutIncludes||dispatch({type:"setLoading",payload:{loading:!0}})},[state.withoutIncludes]),useEffect(()=>{if(attributes&&state?.order&&!lock){const updateAttributes=compareObjAttribute({attributes,object:state.order});Object.keys(updateAttributes).length>0&&(updateOrder({id:state.order.id,attributes:updateAttributes,dispatch,config,include:state.include,state}),setLock(!0))}return()=>{if(attributes&&state?.order){const updateAttributes=compareObjAttribute({attributes,object:state.order});state.order&&Object.keys(updateAttributes).length===0&&setLock(!1)}}},[attributes,state?.order,lock]),useEffect(()=>{const localOrder=persistKey?getLocalOrder(persistKey):orderId,startRequest=Object.keys(state?.includeLoaded||{}).filter(key=>state?.includeLoaded?.[key]===!0),getOrder=async()=>{localOrder&&await getApiOrder({id:localOrder,dispatch,config,persistKey,clearWhenPlaced:!!(persistKey&&clearWhenPlaced),deleteLocalOrder,state})};return config.accessToken&&state.loading===!1&&state?.order==null?localOrder&&!state.order&&state.include?.length===startRequest.length&&!state.withoutIncludes&&!lockOrder?getOrder():state?.order&&fetchOrder?fetchOrder(state.order):state.withoutIncludes&&!state.include?.length&&startRequest.length===0&&getOrder():[config.accessToken,state.order!=null,state.loading,state.withoutIncludes].every(Boolean)?dispatch({type:"setLoading",payload:{loading:!1}}):[config.accessToken,state.order!=null,state.loading,state.withoutIncludes===!1].every(Boolean)&&dispatch({type:"setLoading",payload:{loading:!1}}),()=>{state.order==null&&state.loading&&state.withoutIncludes===!1&&(state.include?.length===0&&startRequest.length>0?dispatch({type:"setLoading",payload:{loading:!1}}):state.include&&state.include?.length>0&&(dispatch({type:"setIncludesResource",payload:{include:[]}}),setLockOrder(!1)))}},[config.accessToken,Object.keys(state.includeLoaded??{}).length,state.include?.length,orderId,state.order,state.loading,state.withoutIncludes,lockOrder]);const orderValue=useMemo(()=>({...state,setOrder:order=>setOrder(order,dispatch),getOrder:async id=>await getApiOrder({id,dispatch,config,state}),setOrderErrors:errors=>setOrderErrors({dispatch,errors}),createOrder:async()=>await createOrder({persistKey,dispatch,config,state,orderMetadata:metadata,orderAttributes:attributes,setLocalOrder}),addToCart:async params=>await addToCart({...params,persistKey,dispatch,state,config,errors:state.errors,orderMetadata:metadata||{},orderAttributes:attributes,setLocalOrder}),saveAddressToCustomerAddressBook:args=>defaultOrderContext.saveAddressToCustomerAddressBook({...args,dispatch}),setGiftCardOrCouponCode:async({code,codeType})=>await defaultOrderContext.setGiftCardOrCouponCode({code,codeType,dispatch,order:state.order,config,include:state.include,state}),removeGiftCardOrCouponCode:async({codeType})=>await defaultOrderContext.removeGiftCardOrCouponCode({codeType,dispatch,order:state.order,config,include:state.include,state}),addResourceToInclude:args=>defaultOrderContext.addResourceToInclude({...args,dispatch,resourcesIncluded:state.include,resourceIncludedLoaded:state.includeLoaded}),updateOrder:async args=>await defaultOrderContext.updateOrder({...args,dispatch,config,include:state.include,state})}),[state,config.accessToken]);return _jsx(OrderContext.Provider,{value:orderValue,children})}export default OrderContainer;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext,useMemo,useState}from"react";import orderReducer,{createOrder,getApiOrder,setOrderErrors,setOrder,orderInitialState,updateOrder,addToCart}from"../../reducers/OrderReducer";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext,{defaultOrderContext}from"../../context/OrderContext";import OrderStorageContext from"../../context/OrderStorageContext";import compareObjAttribute from"../../utils/compareObjAttribute";import useCustomContext from"../../utils/hooks/useCustomContext";export function OrderContainer(props){const{orderId,children,metadata,attributes,fetchOrder}=props,[state,dispatch]=useReducer(orderReducer,orderInitialState),[lock,setLock]=useState(!1),[lockOrder,setLockOrder]=useState(!0),config=useCustomContext({context:CommerceLayerContext,contextComponentName:"CommerceLayer",currentComponentName:"OrderContainer",key:"accessToken"}),{persistKey,clearWhenPlaced,getLocalOrder,setLocalOrder,deleteLocalOrder}=useContext(OrderStorageContext);useEffect(()=>{state.withoutIncludes||dispatch({type:"setLoading",payload:{loading:!0}})},[state.withoutIncludes]),useEffect(()=>{if(attributes&&state?.order&&!lock){const updateAttributes=compareObjAttribute({attributes,object:state.order});Object.keys(updateAttributes).length>0&&(updateOrder({id:state.order.id,attributes:updateAttributes,dispatch,config,include:state.include,state}),setLock(!0))}return()=>{if(attributes&&state?.order){const updateAttributes=compareObjAttribute({attributes,object:state.order});state.order&&Object.keys(updateAttributes).length===0&&setLock(!1)}}},[attributes,state?.order,lock]),useEffect(()=>{const localOrder=persistKey?getLocalOrder(persistKey):orderId,startRequest=Object.keys(state?.includeLoaded||{}).filter(key=>state?.includeLoaded?.[key]===!0),getOrder=async()=>{localOrder&&await getApiOrder({id:localOrder,dispatch,config,persistKey,clearWhenPlaced:!!(persistKey&&clearWhenPlaced),deleteLocalOrder,state})};return config.accessToken&&state.loading===!1&&state?.order==null?(localOrder&&!state.order&&state.include?.length===startRequest.length&&!state.withoutIncludes&&!lockOrder||state.withoutIncludes&&!state.include?.length&&startRequest.length===0)&&getOrder():[config.accessToken,state.order!=null,state.loading,state.withoutIncludes].every(Boolean)?dispatch({type:"setLoading",payload:{loading:!1}}):[config.accessToken,state.order!=null,state.loading,state.withoutIncludes===!1].every(Boolean)&&dispatch({type:"setLoading",payload:{loading:!1}}),()=>{state.order==null&&state.loading&&state.withoutIncludes===!1&&(state.include?.length===0&&startRequest.length>0?dispatch({type:"setLoading",payload:{loading:!1}}):state.include&&state.include?.length>0&&(dispatch({type:"setIncludesResource",payload:{include:[]}}),setLockOrder(!1)))}},[config.accessToken,Object.keys(state.includeLoaded??{}).length,state.include?.length,orderId,Object.keys(state?.order??{}).length,state.loading,state.withoutIncludes,lockOrder]);const orderValue=useMemo(()=>(fetchOrder!=null&&state?.order!=null&&fetchOrder(state.order),{...state,setOrder:order=>setOrder(order,dispatch),getOrder:async id=>await getApiOrder({id,dispatch,config,state}),setOrderErrors:errors=>setOrderErrors({dispatch,errors}),createOrder:async()=>await createOrder({persistKey,dispatch,config,state,orderMetadata:metadata,orderAttributes:attributes,setLocalOrder}),addToCart:async params=>await addToCart({...params,persistKey,dispatch,state,config,errors:state.errors,orderMetadata:metadata||{},orderAttributes:attributes,setLocalOrder}),saveAddressToCustomerAddressBook:args=>defaultOrderContext.saveAddressToCustomerAddressBook({...args,dispatch}),setGiftCardOrCouponCode:async({code,codeType})=>await defaultOrderContext.setGiftCardOrCouponCode({code,codeType,dispatch,order:state.order,config,include:state.include,state}),removeGiftCardOrCouponCode:async({codeType})=>await defaultOrderContext.removeGiftCardOrCouponCode({codeType,dispatch,order:state.order,config,include:state.include,state}),addResourceToInclude:args=>defaultOrderContext.addResourceToInclude({...args,dispatch,resourcesIncluded:state.include,resourceIncludedLoaded:state.includeLoaded}),updateOrder:async args=>await defaultOrderContext.updateOrder({...args,dispatch,config,include:state.include,state})}),[state,config.accessToken]);return _jsx(OrderContext.Provider,{value:orderValue,children})}export default OrderContainer;
@@ -1,6 +1,7 @@
1
1
  import { InitialOrderListContext } from '../../context/OrderListChildrenContext';
2
2
  import { Column } from 'react-table';
3
3
  import type { Order } from '@commercelayer/sdk';
4
+ import type { DefaultChildrenType } from '../../typings/globals';
4
5
  export type OrderListColumn = Column & {
5
6
  Header: string;
6
7
  accessor: keyof Order;
@@ -30,7 +31,7 @@ type PaginationProps = {
30
31
  pageSize?: never;
31
32
  };
32
33
  type Props = {
33
- children: JSX.Element[] | JSX.Element;
34
+ children: DefaultChildrenType;
34
35
  /**
35
36
  * Columns to show
36
37
  */
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import Parent from"../utils/Parent";import PlaceOrderContext from"../../context/PlaceOrderContext";import isFunction from"lodash/isFunction";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import getCardDetails from"../../utils/getCardDetails";export function PlaceOrderButton(props){const ref=useRef(null),{children,label="Place order",disabled,onClick,...p}=props,{isPermitted,setPlaceOrder,options,paymentType,setButtonRef}=useContext(PlaceOrderContext),[notPermitted,setNotPermitted]=useState(!0),[forceDisable,setForceDisable]=useState(disabled),{currentPaymentMethodRef,loading,currentPaymentMethodType,paymentSource,setPaymentSource,setPaymentMethodErrors}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),isFree=order?.total_amount_with_taxes_cents===0;useEffect(()=>{if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType});(isFree&&isPermitted||currentPaymentMethodRef?.current?.onsubmit||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!(isFree&&isPermitted));return()=>{setNotPermitted(!0)}},[isPermitted,paymentType,currentPaymentMethodRef?.current?.onsubmit,loading,currentPaymentMethodType,order,paymentSource]),useEffect(()=>{paymentType==="paypal_payments"&&options?.paypalPayerId&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.paypalPayerId,paymentType]),useEffect(()=>{if(paymentType==="adyen_payments"&&options?.adyen?.redirectResult&&order?.status&&["draft","pending"].includes(order?.status)&&paymentSource!=null){const paymentData=paymentSource?.payment_response?.paymentData,attributes={payment_request_details:{details:{redirectResult:options?.adyen?.redirectResult},paymentData},_details:1};paymentData!=null&&setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}).then(res=>{const resultCode=res?.payment_response?.resultCode,errorCode=res?.payment_response?.errorCode,message=res?.payment_response?.message;["Authorised","Pending","Received"].includes(resultCode)?handleClick():errorCode!=null&&setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])})}paymentType==="adyen_payments"&&options?.adyen?.MD&&options?.adyen?.PaRes&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.adyen,paymentType]),useEffect(()=>{paymentType==="checkout_com_payments"&&options?.checkoutCom?.session_id&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.checkoutCom,paymentType]),useEffect(()=>{ref?.current!=null&&setButtonRef!=null&&setButtonRef(ref)},[ref]);const handleClick=async()=>{let isValid=!0;setForceDisable(!0);const card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:paymentSource}});currentPaymentMethodRef?.current?.onsubmit&&[!options?.paypalPayerId,!options?.adyen?.MD,!options?.checkoutCom?.session_id].every(Boolean)?(isValid=await currentPaymentMethodRef.current?.onsubmit(paymentSource),!isValid&&paymentSource.payment_response?.resultCode==="Authorised"&&(isValid=!0)):card?.brand&&(isValid=!0);const placed=isValid&&setPlaceOrder&&(paymentSource||isFree)&&await setPlaceOrder({paymentSource});setForceDisable(!1),onClick&&placed&&onClick(placed)},disabledButton=disabled!==void 0?disabled:notPermitted,parentProps={...p,label,disabled:disabledButton,handleClick,ref};return children?_jsx(Parent,{...parentProps,children}):_jsx("button",{ref,type:"button",disabled:disabledButton||forceDisable,onClick:()=>{handleClick()},...p,children:isFunction(label)?label():label})}export default PlaceOrderButton;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import Parent from"../utils/Parent";import PlaceOrderContext from"../../context/PlaceOrderContext";import isFunction from"lodash/isFunction";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import getCardDetails from"../../utils/getCardDetails";export function PlaceOrderButton(props){const ref=useRef(null),{children,label="Place order",disabled,onClick,...p}=props,{isPermitted,setPlaceOrder,options,paymentType,setButtonRef}=useContext(PlaceOrderContext),[notPermitted,setNotPermitted]=useState(!0),[forceDisable,setForceDisable]=useState(disabled),{currentPaymentMethodRef,loading,currentPaymentMethodType,paymentSource,setPaymentSource,setPaymentMethodErrors}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),isFree=order?.total_amount_with_taxes_cents===0;useEffect(()=>{if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType});(isFree&&isPermitted||currentPaymentMethodRef?.current?.onsubmit||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!(isFree&&isPermitted));return()=>{setNotPermitted(!0)}},[isPermitted,paymentType,currentPaymentMethodRef?.current?.onsubmit,loading,currentPaymentMethodType,order,paymentSource]),useEffect(()=>{paymentType==="paypal_payments"&&options?.paypalPayerId&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.paypalPayerId,paymentType]),useEffect(()=>{if(paymentType==="adyen_payments"&&options?.adyen?.redirectResult&&order?.status&&["draft","pending"].includes(order?.status)&&paymentSource!=null){const attributes={payment_request_details:{details:{redirectResult:options?.adyen?.redirectResult}},_details:1};setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}).then(res=>{const resultCode=res?.payment_response?.resultCode,errorCode=res?.payment_response?.errorCode,message=res?.payment_response?.message;["Authorised","Pending","Received"].includes(resultCode)?handleClick():errorCode!=null&&setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])})}paymentType==="adyen_payments"&&options?.adyen?.MD&&options?.adyen?.PaRes&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.adyen,paymentType]),useEffect(()=>{paymentType==="checkout_com_payments"&&options?.checkoutCom?.session_id&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.checkoutCom,paymentType]),useEffect(()=>{ref?.current!=null&&setButtonRef!=null&&setButtonRef(ref)},[ref]);const handleClick=async()=>{let isValid=!0;setForceDisable(!0);const checkPaymentSource=await setPaymentSource({paymentResource:paymentType,paymentSourceId:paymentSource?.id}),card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:checkPaymentSource}});currentPaymentMethodRef?.current?.onsubmit&&[!options?.paypalPayerId,!options?.adyen?.MD,!options?.checkoutCom?.session_id].every(Boolean)?(isValid=await currentPaymentMethodRef.current?.onsubmit(checkPaymentSource),!isValid&&checkPaymentSource.payment_response?.resultCode==="Authorised"&&(isValid=!0)):card?.brand&&(isValid=!0);const placed=isValid&&setPlaceOrder&&(checkPaymentSource||isFree)&&await setPlaceOrder({paymentSource:checkPaymentSource});setForceDisable(!1),onClick&&placed&&onClick(placed)},disabledButton=disabled!==void 0?disabled:notPermitted,parentProps={...p,label,disabled:disabledButton,handleClick,ref};return children?_jsx(Parent,{...parentProps,children}):_jsx("button",{ref,type:"button",disabled:disabledButton||forceDisable,onClick:()=>{handleClick()},...p,children:isFunction(label)?label():label})}export default PlaceOrderButton;
@@ -1,5 +1,6 @@
1
+ import type { DefaultChildrenType } from '../../typings/globals';
1
2
  interface Props {
2
- children: JSX.Element[] | JSX.Element;
3
+ children: DefaultChildrenType;
3
4
  }
4
5
  export declare function ParcelLineItem({ children }: Props): JSX.Element;
5
6
  export default ParcelLineItem;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import AdyenGateway from"./AdyenGateway";import StripeGateway from"./StripeGateway";import BraintreeGateway from"./BraintreeGateway";import PaypalGateway from"./PaypalGateway";import WireTransferGateway from"./WireTransferGateway";import CustomerContext from"../../context/CustomerContext";import CheckoutComGateway from"./CheckoutComGateway";import KlarnaGateway from"./KlarnaGateway";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";import ExternalGateway from"./ExternalGateway";export function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource){let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config));const setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show||!paymentSource||paymentSource.type!==paymentResource)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"adyen_payments":return _jsx(AdyenGateway,{...gatewayConfig,children});case"braintree_payments":return _jsx(BraintreeGateway,{...gatewayConfig,children});case"checkout_com_payments":return _jsx(CheckoutComGateway,{...gatewayConfig,children});case"external_payments":return _jsx(ExternalGateway,{...gatewayConfig,children});case"klarna_payments":return _jsx(KlarnaGateway,{...gatewayConfig,children});case"stripe_payments":return _jsx(StripeGateway,{...gatewayConfig,children});case"wire_transfers":return _jsx(WireTransferGateway,{...gatewayConfig,children});case"paypal_payments":return _jsx(PaypalGateway,{...gatewayConfig,children});default:return null}}export default PaymentGateway;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import AdyenGateway from"./AdyenGateway";import StripeGateway from"./StripeGateway";import BraintreeGateway from"./BraintreeGateway";import PaypalGateway from"./PaypalGateway";import WireTransferGateway from"./WireTransferGateway";import CustomerContext from"../../context/CustomerContext";import CheckoutComGateway from"./CheckoutComGateway";import KlarnaGateway from"./KlarnaGateway";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";import ExternalGateway from"./ExternalGateway";export function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource){let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config));const setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show||(!paymentSource||paymentSource.type!==paymentResource)&&show)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"adyen_payments":return _jsx(AdyenGateway,{...gatewayConfig,children});case"braintree_payments":return _jsx(BraintreeGateway,{...gatewayConfig,children});case"checkout_com_payments":return _jsx(CheckoutComGateway,{...gatewayConfig,children});case"external_payments":return _jsx(ExternalGateway,{...gatewayConfig,children});case"klarna_payments":return _jsx(KlarnaGateway,{...gatewayConfig,children});case"stripe_payments":return _jsx(StripeGateway,{...gatewayConfig,children});case"wire_transfers":return _jsx(WireTransferGateway,{...gatewayConfig,children});case"paypal_payments":return _jsx(PaypalGateway,{...gatewayConfig,children});default:return null}}export default PaymentGateway;
@@ -1,21 +1,22 @@
1
- import { ReactNode } from 'react';
2
1
  import { LoaderType } from '../../typings/index';
3
2
  import { PaymentMethod as PaymentMethodType } from '@commercelayer/sdk';
4
3
  import { PaymentResource } from '../../reducers/PaymentMethodReducer';
4
+ import type { DefaultChildrenType } from '../../typings/globals';
5
5
  type Props = {
6
6
  /**
7
7
  * Hide payment methods by an array of strings or a function that returns a boolean
8
8
  */
9
9
  hide?: PaymentResource[] | ((payment: PaymentMethodType) => boolean);
10
- children: ReactNode;
10
+ children: DefaultChildrenType;
11
11
  activeClass?: string;
12
12
  loader?: LoaderType;
13
- } & Omit<JSX.IntrinsicElements['div'], 'onClick'> & ({
13
+ autoSelectSinglePaymentMethod?: boolean | (() => void);
14
+ } & Omit<JSX.IntrinsicElements['div'], 'onClick' | 'children'> & ({
14
15
  clickableContainer: true;
15
16
  onClick?: (payment?: PaymentMethodType | Record<string, any>) => void;
16
17
  } | {
17
18
  clickableContainer?: never;
18
19
  onClick?: never;
19
20
  });
20
- export declare function PaymentMethod({ children, className, activeClass, loader, clickableContainer, hide, onClick, ...p }: Props): JSX.Element;
21
+ export declare function PaymentMethod({ children, className, activeClass, loader, clickableContainer, autoSelectSinglePaymentMethod, hide, onClick, ...p }: Props): JSX.Element;
21
22
  export default PaymentMethod;
@@ -1 +1 @@
1
- import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useState,useEffect}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";import useCustomContext from"../../utils/hooks/useCustomContext";export function PaymentMethod({children,className,activeClass,loader="Loading...",clickableContainer,hide,onClick,...p}){const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder}=useCustomContext({context:PaymentMethodContext,contextComponentName:"PaymentMethodsContainer",currentComponentName:"PaymentMethod",key:"paymentMethods"});useEffect(()=>(paymentMethods&&setLoading(!1),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components=paymentMethods?.filter(payment=>{if(Array.isArray(hide)){const source=payment?.payment_source_type;return!hide?.includes(source)}else if(typeof hide=="function")return hide(payment);return!0}).map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id;await setPaymentMethod({paymentResource,paymentMethodId}),onClick&&onClick(payment),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",{"data-test-id":paymentResource,className:`${className??""} ${isActive&&activeClass!=null?activeClass:""}`,onClick:onClickable,...p,children:_jsx(PaymentMethodChildrenContext.Provider,{value:paymentMethodProps,children})},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default PaymentMethod;
1
+ import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";import useCustomContext from"../../utils/hooks/useCustomContext";import OrderContext from"../../context/OrderContext";import CustomerContext from"../../context/CustomerContext";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";export function PaymentMethod({children,className,activeClass,loader="Loading...",clickableContainer,autoSelectSinglePaymentMethod,hide,onClick,...p}){const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder,paymentSource,setPaymentSource,config}=useCustomContext({context:PaymentMethodContext,contextComponentName:"PaymentMethodsContainer",currentComponentName:"PaymentMethod",key:"paymentMethods"}),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext);useEffect(()=>{paymentMethods!=null&&autoSelectSinglePaymentMethod!=null&&(async()=>{if(paymentMethods.length===1){const[paymentMethod]=paymentMethods??[];if(paymentMethod&&!paymentSource){setLoadingPlaceOrder({loading:!0}),setPaymentSelected(paymentMethod.id);const paymentMethodId=paymentMethod?.id,paymentResource=paymentMethod?.payment_source_type;await setPaymentMethod({paymentResource,paymentMethodId});let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config));const ps=await setPaymentSource({paymentResource,order,attributes});ps&&paymentMethod&&onClick!=null&&(onClick({payment:paymentMethod,paymentSource:ps}),setTimeout(()=>{setLoading(!1)},200)),getCustomerPaymentSources&&await getCustomerPaymentSources(),setLoadingPlaceOrder({loading:!1})}typeof autoSelectSinglePaymentMethod=="function"&&autoSelectSinglePaymentMethod()}else setTimeout(()=>{setLoading(!1)},200)})()},[paymentMethods]),useEffect(()=>(paymentMethods&&(paymentMethods.length===1&&autoSelectSinglePaymentMethod?paymentSource&&setTimeout(()=>{setLoading(!1)},200):setLoading(!1)),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components=paymentMethods?.filter(payment=>{if(Array.isArray(hide)){const source=payment?.payment_source_type;return!hide?.includes(source)}else if(typeof hide=="function")return hide(payment);return!0}).map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id;await setPaymentMethod({paymentResource,paymentMethodId}),onClick&&onClick(payment),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",{"data-test-id":paymentResource,className:`${className??""} ${isActive&&activeClass!=null?activeClass:""}`,onClick:onClickable,...p,children:_jsx(PaymentMethodChildrenContext.Provider,{value:paymentMethodProps,children})},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default PaymentMethod;
@@ -1 +1 @@
1
- import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import ShipmentContext from"../../context/ShipmentContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";export function Shipment({children,loader="Loading...",autoSelectSingleShippingMethod=!1}){const[loading,setLoading]=useState(!0),{shipments,deliveryLeadTimes,setShippingMethod}=useContext(ShipmentContext);useEffect(()=>{shipments&&(autoSelectSingleShippingMethod?(async()=>shipments.forEach(async shipment=>{const isSingle=shipment?.available_shipping_methods?.length===1;if(!shipment?.shipping_method&&isSingle){const[shippingMethod]=shipment?.available_shipping_methods||[];shippingMethod&&await setShippingMethod(shipment.id,shippingMethod.id),typeof autoSelectSingleShippingMethod=="function"&&autoSelectSingleShippingMethod()}else setTimeout(()=>{setLoading(!1)},200)}))():setLoading(!1))},[shipments]);const components=shipments?.map((shipment,k)=>{const lineItems=shipment.shipment_line_items?.map(shipmentLineItem=>{const l=shipmentLineItem.line_item;return l&&(l.quantity=shipmentLineItem.quantity),l}),shippingMethods=shipment.available_shipping_methods,currentShippingMethodId=autoSelectSingleShippingMethod&&shippingMethods&&shippingMethods.length===1?shippingMethods[0]?.id:shipment.shipping_method?.id,stockTransfers=shipment.stock_transfers,parcels=shipment.parcels,times=deliveryLeadTimes?.filter(time=>time.stock_location?.id===shipment.stock_location?.id),shipmentProps={parcels,lineItems,shippingMethods,currentShippingMethodId,stockTransfers,deliveryLeadTimes:times,shipment,keyNumber:k+1};return _jsx(ShipmentChildrenContext.Provider,{value:shipmentProps,children},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default Shipment;
1
+ import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import ShipmentContext from"../../context/ShipmentContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";export function Shipment({children,loader="Loading...",autoSelectSingleShippingMethod=!1}){const[loading,setLoading]=useState(!0),{shipments,deliveryLeadTimes,setShippingMethod}=useContext(ShipmentContext);useEffect(()=>{shipments&&(autoSelectSingleShippingMethod?(async()=>shipments.forEach(shipment=>{const isSingle=shipment?.available_shipping_methods?.length===1;if(!shipment?.shipping_method&&isSingle){const[shippingMethod]=shipment?.available_shipping_methods||[];shippingMethod&&setShippingMethod(shipment.id,shippingMethod.id),typeof autoSelectSingleShippingMethod=="function"&&autoSelectSingleShippingMethod()}else setTimeout(()=>{setLoading(!1)},200)}))():setLoading(!1))},[shipments]);const components=shipments?.map((shipment,k)=>{const lineItems=shipment.shipment_line_items?.map(shipmentLineItem=>{const l=shipmentLineItem.line_item;return l&&(l.quantity=shipmentLineItem.quantity),l}),shippingMethods=shipment.available_shipping_methods,currentShippingMethodId=autoSelectSingleShippingMethod&&shippingMethods&&shippingMethods.length===1?shippingMethods[0]?.id:shipment.shipping_method?.id,stockTransfers=shipment.stock_transfers,parcels=shipment.parcels,times=deliveryLeadTimes?.filter(time=>time.stock_location?.id===shipment.stock_location?.id),shipmentProps={parcels,lineItems,shippingMethods,currentShippingMethodId,stockTransfers,deliveryLeadTimes:times,shipment,keyNumber:k+1};return _jsx(ShipmentChildrenContext.Provider,{value:shipmentProps,children},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default Shipment;
@@ -1,5 +1,6 @@
1
+ import type { DefaultChildrenType } from '../../typings/globals';
1
2
  interface Props {
2
- children: JSX.Element[] | JSX.Element;
3
+ children: DefaultChildrenType;
3
4
  }
4
5
  export declare function StockTransfer(props: Props): JSX.Element;
5
6
  export default StockTransfer;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { BaseInputComponentProps } from '../../typings/index';
3
3
  export type BaseInputProps = BaseInputComponentProps & Omit<JSX.IntrinsicElements['input'], 'children'> & Omit<JSX.IntrinsicElements['textarea'], 'children'>;
4
- declare const _default: React.ForwardRefExoticComponent<Pick<BaseInputProps, "children" | "form" | "slot" | "style" | "title" | "pattern" | "resource" | "id" | "value" | "placeholder" | "className" | "required" | "name" | "onChange" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "height" | "max" | "min" | "type" | "width" | "crossOrigin" | "alt" | "src" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "autoComplete" | "accept" | "capture" | "checked" | "enterKeyHint" | "list" | "maxLength" | "minLength" | "multiple" | "readOnly" | "size" | "step" | "cols" | "dirName" | "rows" | "wrap"> & React.RefAttributes<any>>;
4
+ declare const _default: React.ForwardRefExoticComponent<Pick<BaseInputProps, "children" | "form" | "slot" | "style" | "title" | "pattern" | "value" | "placeholder" | "className" | "required" | "name" | "onChange" | "id" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "height" | "max" | "min" | "type" | "width" | "crossOrigin" | "alt" | "src" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "autoComplete" | "accept" | "capture" | "checked" | "enterKeyHint" | "list" | "maxLength" | "minLength" | "multiple" | "readOnly" | "size" | "step" | "cols" | "dirName" | "rows" | "wrap"> & React.RefAttributes<any>>;
5
5
  export default _default;
@@ -1,12 +1,13 @@
1
1
  import { LineItem } from '@commercelayer/sdk';
2
- import { BaseError, ResourceErrorType } from '../../typings/errors';
2
+ import { BaseError } from '../../typings/errors';
3
+ import { TResourceError } from '../errors/Errors';
3
4
  export type AllErrorsParams = {
4
5
  allErrors: BaseError[];
5
6
  messages: BaseError[];
6
7
  field?: string;
7
8
  props: JSX.IntrinsicElements['span'];
8
9
  lineItem?: LineItem;
9
- resource?: ResourceErrorType;
10
+ resource?: TResourceError;
10
11
  returnHtml?: boolean;
11
12
  };
12
13
  export interface GetAllErrors {
@@ -100,5 +100,4 @@ export * from './components/stock_transfers/StockTransfer';
100
100
  export * from './components/stock_transfers/StockTransferField';
101
101
  export type { CustomerCardsType } from './components/utils/PaymentCardsTemplate';
102
102
  export type { ShippingMethodRadioButtonType, ShippingMethodRadioButtonOnChangeType } from './components/shipping_methods/ShippingMethodRadioButton';
103
- export type { ErrorComponentProps, ResourceErrorType } from './typings/errors';
104
- export type { AddressCountrySelectName, AddressInputName, AddressStateSelectName, BaseInputType, LineItemType } from './typings/index';
103
+ export * from './typings/errors';