@commercelayer/react-components 4.2.0 → 4.2.1-beta.0
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/lib/cjs/components/addresses/Address.d.ts +2 -1
- package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +5 -4
- package/lib/cjs/components/addresses/ShippingAddressContainer.d.ts +2 -1
- package/lib/cjs/components/auth/CommerceLayer.d.ts +2 -1
- package/lib/cjs/components/errors/Errors.d.ts +28 -2
- package/lib/cjs/components/gift_cards/GiftCard.d.ts +2 -1
- package/lib/cjs/components/line_items/LineItem.d.ts +2 -2
- package/lib/cjs/components/line_items/LineItemImage.d.ts +3 -2
- package/lib/cjs/components/line_items/LineItemsContainer.d.ts +3 -3
- package/lib/cjs/components/line_items/LineItemsContainer.js +1 -1
- package/lib/cjs/components/orders/OrderContainer.d.ts +2 -1
- package/lib/cjs/components/orders/OrderList.d.ts +2 -1
- package/lib/cjs/components/orders/PlaceOrderButton.js +1 -1
- package/lib/cjs/components/parcels/ParcelLineItem.d.ts +2 -1
- package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +5 -4
- package/lib/cjs/components/payment_methods/PaymentMethod.js +1 -1
- package/lib/cjs/components/shipments/Shipment.js +1 -1
- package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +2 -1
- package/lib/cjs/components/utils/BaseInput.d.ts +1 -1
- package/lib/cjs/components/utils/getAllErrors.d.ts +3 -2
- package/lib/cjs/index.d.ts +1 -2
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/reducers/AddressReducer.d.ts +4 -3
- package/lib/cjs/reducers/OrderReducer.js +1 -1
- package/lib/cjs/reducers/PaymentMethodReducer.js +1 -1
- package/lib/cjs/typings/errors.d.ts +2 -42
- package/lib/cjs/typings/errors.js +1 -1
- package/lib/cjs/typings/globals.d.ts +1 -0
- package/lib/cjs/typings/globals.js +1 -0
- package/lib/cjs/typings/index.d.ts +5 -14
- package/lib/cjs/typings/index.js +1 -1
- package/lib/cjs/utils/filterChildren.d.ts +3 -2
- package/lib/cjs/utils/filterChildren.js +1 -1
- package/lib/cjs/utils/getErrors.d.ts +3 -2
- package/lib/cjs/utils/getLineItemsCount.d.ts +2 -2
- package/lib/cjs/utils/getLoaderComponent.d.ts +1 -1
- package/lib/cjs/utils/getLoaderComponent.js +1 -1
- package/lib/cjs/utils/validateFormFields.d.ts +4 -3
- package/lib/esm/components/addresses/Address.d.ts +2 -1
- package/lib/esm/components/addresses/AddressCountrySelector.d.ts +5 -4
- package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +2 -1
- package/lib/esm/components/auth/CommerceLayer.d.ts +2 -1
- package/lib/esm/components/errors/Errors.d.ts +28 -2
- package/lib/esm/components/gift_cards/GiftCard.d.ts +2 -1
- package/lib/esm/components/line_items/LineItem.d.ts +2 -2
- package/lib/esm/components/line_items/LineItemImage.d.ts +3 -2
- package/lib/esm/components/line_items/LineItemsContainer.d.ts +3 -3
- package/lib/esm/components/line_items/LineItemsContainer.js +1 -1
- package/lib/esm/components/orders/OrderContainer.d.ts +2 -1
- package/lib/esm/components/orders/OrderList.d.ts +2 -1
- package/lib/esm/components/orders/PlaceOrderButton.js +1 -1
- package/lib/esm/components/parcels/ParcelLineItem.d.ts +2 -1
- package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -1
- package/lib/esm/components/payment_methods/PaymentMethod.d.ts +5 -4
- package/lib/esm/components/payment_methods/PaymentMethod.js +1 -1
- package/lib/esm/components/shipments/Shipment.js +1 -1
- package/lib/esm/components/stock_transfers/StockTransfer.d.ts +2 -1
- package/lib/esm/components/utils/BaseInput.d.ts +1 -1
- package/lib/esm/components/utils/getAllErrors.d.ts +3 -2
- package/lib/esm/index.d.ts +1 -2
- package/lib/esm/index.js +1 -1
- package/lib/esm/reducers/AddressReducer.d.ts +4 -3
- package/lib/esm/reducers/OrderReducer.js +1 -1
- package/lib/esm/reducers/PaymentMethodReducer.js +1 -1
- package/lib/esm/typings/errors.d.ts +2 -42
- package/lib/esm/typings/errors.js +1 -1
- package/lib/esm/typings/globals.d.ts +1 -0
- package/lib/esm/typings/globals.js +1 -0
- package/lib/esm/typings/index.d.ts +5 -14
- package/lib/esm/typings/index.js +1 -1
- package/lib/esm/utils/filterChildren.d.ts +3 -2
- package/lib/esm/utils/filterChildren.js +1 -1
- package/lib/esm/utils/getErrors.d.ts +3 -2
- package/lib/esm/utils/getLineItemsCount.d.ts +2 -2
- package/lib/esm/utils/getLoaderComponent.d.ts +1 -1
- package/lib/esm/utils/getLoaderComponent.js +1 -1
- package/lib/esm/utils/validateFormFields.d.ts +4 -3
- package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import baseReducer from"../utils/baseReducer";import getErrors,{setErrors}from"../utils/getErrors";import getSdk from"../utils/getSdk";import{snakeToCamelCase}from"../utils/snakeToCamelCase";import{replace}from"../utils/replace";import{pick}from"../utils/pick";export function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}export const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})},paymentMethodInitialState={errors:[],paymentMethods:void 0},setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getPaymentMethods=async({order,dispatch})=>{const paymentMethods=order.available_payment_methods,paymentMethod=order.payment_method,paymentSource=order.payment_source;dispatch({type:"setPaymentMethods",payload:{paymentMethods,currentPaymentMethodId:paymentMethod?.id,currentPaymentMethodType:paymentMethod?.payment_source_type,paymentSource}})},setPaymentMethod=async({config,dispatch,order,paymentMethodId,updateOrder,setOrderErrors,paymentResource})=>{try{if(config&&order&&dispatch&&paymentResource){localStorage.removeItem("_save_payment_source_to_customer_wallet");const attributes={payment_method:getSdk(config).payment_methods.relationship(paymentMethodId)};updateOrder&&await updateOrder({id:order.id,attributes}),dispatch({type:"setPaymentMethods",payload:{currentPaymentMethodId:paymentMethodId,currentPaymentMethodType:paymentResource,errors:[]}}),setOrderErrors&&setOrderErrors([])}}catch(error){const errors=getErrors(error,"orders",paymentResource);console.error("Set payment method",errors)}},setPaymentSource=async({config,dispatch,getOrder,attributes,order,paymentResource,customerPaymentSourceId,paymentSourceId,updateOrder,errors:currentErrors})=>{try{if(config&&order){let paymentSource;const sdk=getSdk(config);if(customerPaymentSourceId)updateOrder&&await updateOrder({id:order.id,attributes:{_customer_payment_source_id:customerPaymentSourceId}});else{if(paymentSourceId){const attrs={id:paymentSourceId,...attributes};paymentSource=attributes!=null?await sdk[paymentResource].update(attrs):sdk[paymentResource].retrieve(paymentSourceId)}else{const attrs={...attributes,order:sdk.orders.relationship(order.id)};paymentSource=await sdk[paymentResource].create(attrs)}return getOrder&&await getOrder(order.id),dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource,errors:[]}}),paymentSource}}}catch(error){const errors=getErrors(error,"payment_methods",paymentResource);console.error("Set payment source:",errors),dispatch&&setErrors({currentErrors,newErrors:errors,dispatch})}},updatePaymentSource=async({id,attributes,config,dispatch,paymentResource})=>{if(config)try{const paymentSource=await getSdk(config)[paymentResource].update({id,...attributes});dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource}})}catch(err){console.error("Update payment source:",err)}},destroyPaymentSource=async({paymentSourceId,paymentResource,dispatch})=>{paymentSourceId&&paymentResource&&dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},setPaymentMethodConfig=(config,dispatch)=>{dispatch({type:"setPaymentMethodConfig",payload:{config}})};export function getPaymentConfig(paymentResource,config){const resourceKeys=replace(replace(paymentResource,"payments","payment"),"transfers","transfer"),resource=snakeToCamelCase(resourceKeys);return pick(config,[resource])}const type=["setErrors","setPaymentMethodConfig","setPaymentMethods","setPaymentSource","setPaymentRef","setLoading"],paymentMethodReducer=(state,reducer)=>baseReducer(state,reducer,type);export default paymentMethodReducer;
|
|
1
|
+
import baseReducer from"../utils/baseReducer";import getErrors,{setErrors}from"../utils/getErrors";import getSdk from"../utils/getSdk";import{snakeToCamelCase}from"../utils/snakeToCamelCase";import{replace}from"../utils/replace";import{pick}from"../utils/pick";export function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}export const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})},paymentMethodInitialState={errors:[],paymentMethods:void 0},setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getPaymentMethods=async({order,dispatch})=>{const paymentMethods=order.available_payment_methods,paymentMethod=order.payment_method,paymentSource=order.payment_source;dispatch({type:"setPaymentMethods",payload:{paymentMethods,currentPaymentMethodId:paymentMethod?.id,currentPaymentMethodType:paymentMethod?.payment_source_type,paymentSource}})},setPaymentMethod=async({config,dispatch,order,paymentMethodId,updateOrder,setOrderErrors,paymentResource})=>{try{if(config&&order&&dispatch&&paymentResource){localStorage.removeItem("_save_payment_source_to_customer_wallet");const attributes={payment_method:getSdk(config).payment_methods.relationship(paymentMethodId)};updateOrder&&await updateOrder({id:order.id,attributes}),dispatch({type:"setPaymentMethods",payload:{currentPaymentMethodId:paymentMethodId,currentPaymentMethodType:paymentResource,errors:[]}}),setOrderErrors&&setOrderErrors([])}}catch(error){const errors=getErrors(error,"orders",paymentResource);console.error("Set payment method",errors)}},setPaymentSource=async({config,dispatch,getOrder,attributes,order,paymentResource,customerPaymentSourceId,paymentSourceId,updateOrder,errors:currentErrors})=>{try{if(config&&order){let paymentSource;const sdk=getSdk(config);if(customerPaymentSourceId)updateOrder&&await updateOrder({id:order.id,attributes:{_customer_payment_source_id:customerPaymentSourceId}});else{if(paymentSourceId){const attrs={id:paymentSourceId,...attributes};paymentSource=attributes!=null?await sdk[paymentResource].update(attrs):await sdk[paymentResource].retrieve(paymentSourceId)}else{const attrs={...attributes,order:sdk.orders.relationship(order.id)};paymentSource=await sdk[paymentResource].create(attrs)}return getOrder&&await getOrder(order.id),dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource,errors:[]}}),paymentSource}}}catch(error){const errors=getErrors(error,"payment_methods",paymentResource);console.error("Set payment source:",errors),dispatch&&setErrors({currentErrors,newErrors:errors,dispatch})}},updatePaymentSource=async({id,attributes,config,dispatch,paymentResource})=>{if(config)try{const paymentSource=await getSdk(config)[paymentResource].update({id,...attributes});dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource}})}catch(err){console.error("Update payment source:",err)}},destroyPaymentSource=async({paymentSourceId,paymentResource,dispatch})=>{paymentSourceId&&paymentResource&&dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},setPaymentMethodConfig=(config,dispatch)=>{dispatch({type:"setPaymentMethodConfig",payload:{config}})};export function getPaymentConfig(paymentResource,config){const resourceKeys=replace(replace(paymentResource,"payments","payment"),"transfers","transfer"),resource=snakeToCamelCase(resourceKeys);return pick(config,[resource])}const type=["setErrors","setPaymentMethodConfig","setPaymentMethods","setPaymentSource","setPaymentRef","setLoading"],paymentMethodReducer=(state,reducer)=>baseReducer(state,reducer,type);export default paymentMethodReducer;
|
|
@@ -1,51 +1,11 @@
|
|
|
1
|
-
import
|
|
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?:
|
|
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
|
-
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DefaultChildrenType = JSX.Element[] | JSX.Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatch, ForwardedRef,
|
|
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' | '
|
|
63
|
-
export type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code'
|
|
64
|
-
export type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code'
|
|
65
|
-
export type
|
|
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
|
}>;
|
package/lib/esm/typings/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import PropTypes from"prop-types";export const BC={id:PropTypes.string,className:PropTypes.string,style:PropTypes.object,name:PropTypes.string},PTLoader=PropTypes.oneOfType([PropTypes.element,PropTypes.string]),BaseSelectComponentPropTypes={children:PropTypes.func,options:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired,selected:PropTypes.bool}).isRequired).isRequired,placeholder:PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired}),value:PropTypes.string,name:PropTypes.string.isRequired},
|
|
1
|
+
import PropTypes from"prop-types";export const BC={id:PropTypes.string,className:PropTypes.string,style:PropTypes.object,name:PropTypes.string},PTLoader=PropTypes.oneOfType([PropTypes.element,PropTypes.string]),BaseSelectComponentPropTypes={children:PropTypes.func,options:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired,selected:PropTypes.bool}).isRequired).isRequired,placeholder:PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired}),value:PropTypes.string,name:PropTypes.string.isRequired},BMObject=PropTypes.objectOf(PropTypes.string),baseOrderPricePropTypes={base:PropTypes.string.isRequired,type:PropTypes.string.isRequired,children:PropTypes.func,format:PropTypes.oneOf(["formatted","cents","float"]),...BC},baseOrderComponentPricePropTypes={children:baseOrderPricePropTypes.children,format:baseOrderPricePropTypes.format,...BC};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { DefaultChildrenType } from "../typings/globals";
|
|
1
2
|
interface Props<T> {
|
|
2
|
-
children:
|
|
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
|
-
export default function filterChildren({children,filterBy,componentName}){if(Array.isArray(children)?children.filter(child=>typeof child.type=="string").length>0:typeof children
|
|
1
|
+
export default 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}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
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:
|
|
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
|
-
|
|
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(
|
|
2
|
+
export default function getLoaderComponent(loader: LoaderType): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as _Fragment,jsx as _jsx}from"react/jsx-runtime";export default function getLoaderComponent(
|
|
1
|
+
import{Fragment as _Fragment,jsx as _jsx}from"react/jsx-runtime";export default function getLoaderComponent(loader){return _jsx(_Fragment,{children:loader})}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { BaseState } from '../typings/index';
|
|
2
|
-
import {
|
|
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
|
-
|
|
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
|
|
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;
|