@commercelayer/react-components 4.0.0 → 4.1.0-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.
- package/lib/cjs/components/Errors.d.ts +1 -1
- package/lib/cjs/components/Errors.js +1 -1
- package/lib/cjs/components/ExternalFunction.d.ts +2 -9
- package/lib/cjs/components/ExternalFunction.js +1 -1
- package/lib/cjs/components/MetadataInput.d.ts +0 -10
- package/lib/cjs/components/MetadataInput.js +1 -1
- package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +0 -16
- package/lib/cjs/components/addresses/AddressCountrySelector.js +1 -1
- package/lib/cjs/components/addresses/AddressStateSelector.d.ts +0 -16
- package/lib/cjs/components/addresses/AddressStateSelector.js +1 -1
- package/lib/cjs/components/addresses/BillingAddressForm.d.ts +0 -5
- package/lib/cjs/components/addresses/BillingAddressForm.js +1 -1
- package/lib/cjs/components/addresses/SaveAddressesButton.d.ts +2 -2
- package/lib/cjs/components/addresses/ShippingAddressContainer.d.ts +4 -9
- package/lib/cjs/components/addresses/ShippingAddressContainer.js +1 -1
- package/lib/cjs/components/addresses/ShippingAddressForm.d.ts +2 -7
- package/lib/cjs/components/addresses/ShippingAddressForm.js +1 -1
- package/lib/cjs/components/customers/CustomerAddressForm.d.ts +2 -7
- package/lib/cjs/components/customers/CustomerAddressForm.js +1 -1
- package/lib/cjs/components/customers/CustomerInput.d.ts +1 -13
- package/lib/cjs/components/customers/CustomerInput.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCard.d.ts +4 -14
- package/lib/cjs/components/gift_cards/GiftCard.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardContainer.d.ts +2 -8
- package/lib/cjs/components/gift_cards/GiftCardContainer.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +0 -15
- package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +1 -10
- package/lib/cjs/components/gift_cards/GiftCardInput.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.d.ts +0 -5
- package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -10
- package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.js +1 -1
- package/lib/cjs/components/line_items/LineItemQuantity.d.ts +1 -1
- package/lib/cjs/components/line_items/LineItemsCount.d.ts +3 -3
- package/lib/cjs/components/orders/CheckoutLink.d.ts +2 -2
- package/lib/cjs/components/orders/OrderContainer.d.ts +12 -0
- package/lib/cjs/components/orders/OrderList.d.ts +1 -1
- package/lib/cjs/components/orders/OrderNumber.d.ts +0 -6
- package/lib/cjs/components/orders/OrderNumber.js +1 -1
- package/lib/cjs/components/orders/OrderStorage.d.ts +2 -10
- package/lib/cjs/components/orders/OrderStorage.js +1 -1
- package/lib/cjs/components/orders/PlaceOrderButton.d.ts +2 -2
- package/lib/cjs/components/payment_source/PaymentSource.d.ts +4 -4
- package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +2 -2
- package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +2 -2
- package/lib/cjs/components/shipments/ShipmentField.d.ts +2 -2
- package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +2 -2
- package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +0 -12
- package/lib/cjs/components/shipping_methods/ShippingMethodPrice.js +1 -1
- package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +0 -6
- package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
- package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +0 -7
- package/lib/cjs/components/skus/DeliveryLeadTime.js +1 -1
- package/lib/cjs/components/skus/SkuList.d.ts +5 -9
- package/lib/cjs/components/skus/SkuList.js +1 -1
- package/lib/cjs/components/skus/SkuListsContainer.d.ts +2 -8
- package/lib/cjs/components/skus/SkuListsContainer.js +1 -1
- package/lib/cjs/components/skus/Skus.d.ts +2 -7
- package/lib/cjs/components/skus/Skus.js +1 -1
- package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +4 -10
- package/lib/cjs/components/stock_transfers/StockTransfer.js +1 -1
- package/lib/cjs/components/utils/BaseField.d.ts +2 -2
- package/lib/cjs/components/utils/BaseInput.d.ts +2 -2
- package/lib/cjs/components/utils/Parent.d.ts +1 -1
- package/lib/cjs/hooks/useOrderContainer.d.ts +6 -0
- package/lib/cjs/hooks/useOrderContainer.js +1 -0
- package/lib/cjs/reducers/AddressReducer.d.ts +1 -1
- package/lib/cjs/reducers/GiftCardReducer.d.ts +11 -21
- package/lib/cjs/reducers/GiftCardReducer.js +1 -1
- package/lib/cjs/typings/errors.d.ts +2 -2
- package/lib/cjs/typings/index.d.ts +2 -2
- package/lib/esm/components/Errors.d.ts +1 -1
- package/lib/esm/components/Errors.js +1 -1
- package/lib/esm/components/ExternalFunction.d.ts +2 -9
- package/lib/esm/components/ExternalFunction.js +1 -1
- package/lib/esm/components/MetadataInput.d.ts +0 -10
- package/lib/esm/components/MetadataInput.js +1 -1
- package/lib/esm/components/addresses/AddressCountrySelector.d.ts +0 -16
- package/lib/esm/components/addresses/AddressCountrySelector.js +1 -1
- package/lib/esm/components/addresses/AddressStateSelector.d.ts +0 -16
- package/lib/esm/components/addresses/AddressStateSelector.js +1 -1
- package/lib/esm/components/addresses/BillingAddressForm.d.ts +0 -5
- package/lib/esm/components/addresses/BillingAddressForm.js +1 -1
- package/lib/esm/components/addresses/SaveAddressesButton.d.ts +2 -2
- package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +4 -9
- package/lib/esm/components/addresses/ShippingAddressContainer.js +1 -1
- package/lib/esm/components/addresses/ShippingAddressForm.d.ts +2 -7
- package/lib/esm/components/addresses/ShippingAddressForm.js +1 -1
- package/lib/esm/components/customers/CustomerAddressForm.d.ts +2 -7
- package/lib/esm/components/customers/CustomerAddressForm.js +1 -1
- package/lib/esm/components/customers/CustomerInput.d.ts +1 -13
- package/lib/esm/components/customers/CustomerInput.js +1 -1
- package/lib/esm/components/gift_cards/GiftCard.d.ts +4 -14
- package/lib/esm/components/gift_cards/GiftCard.js +1 -1
- package/lib/esm/components/gift_cards/GiftCardContainer.d.ts +2 -8
- package/lib/esm/components/gift_cards/GiftCardContainer.js +1 -1
- package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +0 -15
- package/lib/esm/components/gift_cards/GiftCardCurrencySelector.js +1 -1
- package/lib/esm/components/gift_cards/GiftCardInput.d.ts +1 -10
- package/lib/esm/components/gift_cards/GiftCardInput.js +1 -1
- package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +0 -5
- package/lib/esm/components/gift_cards/GiftCardOrCouponForm.js +1 -1
- package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -10
- package/lib/esm/components/gift_cards/GiftCardOrCouponInput.js +1 -1
- package/lib/esm/components/line_items/LineItemQuantity.d.ts +1 -1
- package/lib/esm/components/line_items/LineItemsCount.d.ts +3 -3
- package/lib/esm/components/orders/CheckoutLink.d.ts +2 -2
- package/lib/esm/components/orders/OrderContainer.d.ts +12 -0
- package/lib/esm/components/orders/OrderList.d.ts +1 -1
- package/lib/esm/components/orders/OrderNumber.d.ts +0 -6
- package/lib/esm/components/orders/OrderNumber.js +1 -1
- package/lib/esm/components/orders/OrderStorage.d.ts +2 -10
- package/lib/esm/components/orders/OrderStorage.js +1 -1
- package/lib/esm/components/orders/PlaceOrderButton.d.ts +2 -2
- package/lib/esm/components/payment_source/PaymentSource.d.ts +4 -4
- package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +2 -2
- package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +2 -2
- package/lib/esm/components/shipments/ShipmentField.d.ts +2 -2
- package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +2 -2
- package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +0 -12
- package/lib/esm/components/shipping_methods/ShippingMethodPrice.js +1 -1
- package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +0 -6
- package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
- package/lib/esm/components/skus/DeliveryLeadTime.d.ts +0 -7
- package/lib/esm/components/skus/DeliveryLeadTime.js +1 -1
- package/lib/esm/components/skus/SkuList.d.ts +5 -9
- package/lib/esm/components/skus/SkuList.js +1 -1
- package/lib/esm/components/skus/SkuListsContainer.d.ts +2 -8
- package/lib/esm/components/skus/SkuListsContainer.js +1 -1
- package/lib/esm/components/skus/Skus.d.ts +2 -7
- package/lib/esm/components/skus/Skus.js +1 -1
- package/lib/esm/components/stock_transfers/StockTransfer.d.ts +4 -10
- package/lib/esm/components/stock_transfers/StockTransfer.js +1 -1
- package/lib/esm/components/utils/BaseField.d.ts +2 -2
- package/lib/esm/components/utils/BaseInput.d.ts +2 -2
- package/lib/esm/components/utils/Parent.d.ts +1 -1
- package/lib/esm/hooks/useOrderContainer.d.ts +6 -0
- package/lib/esm/hooks/useOrderContainer.js +1 -0
- package/lib/esm/reducers/AddressReducer.d.ts +1 -1
- package/lib/esm/reducers/GiftCardReducer.d.ts +11 -21
- package/lib/esm/reducers/GiftCardReducer.js +1 -1
- package/lib/esm/typings/errors.d.ts +2 -2
- package/lib/esm/typings/index.d.ts +2 -2
- package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +23 -66
- package/README.md +0 -338
- package/lib/cjs/config/components.d.ts +0 -934
- package/lib/cjs/config/components.js +0 -1
- package/lib/cjs/utils/childrenTypes.d.ts +0 -9
- package/lib/cjs/utils/childrenTypes.js +0 -1
- package/lib/esm/config/components.d.ts +0 -934
- package/lib/esm/config/components.js +0 -1
- package/lib/esm/utils/childrenTypes.d.ts +0 -9
- package/lib/esm/utils/childrenTypes.js +0 -1
|
@@ -8,20 +8,4 @@ declare type Props = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
|
|
|
8
8
|
selectClassName?: string;
|
|
9
9
|
} & Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'>;
|
|
10
10
|
export declare function AddressStateSelector(props: Props): JSX.Element;
|
|
11
|
-
export declare namespace AddressStateSelector {
|
|
12
|
-
var propTypes: {
|
|
13
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
14
|
-
placeholder: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
15
|
-
label: import("prop-types").Validator<string>;
|
|
16
|
-
value: import("prop-types").Validator<NonNullable<NonNullable<string | number | null | undefined>>>;
|
|
17
|
-
}>>;
|
|
18
|
-
value: import("prop-types").Requireable<string>;
|
|
19
|
-
name: import("prop-types").Validator<NonNullable<AddressStateSelectName>>;
|
|
20
|
-
required: import("prop-types").Requireable<boolean>;
|
|
21
|
-
};
|
|
22
|
-
var defaultProps: {
|
|
23
|
-
required: boolean;
|
|
24
|
-
};
|
|
25
|
-
var displayName: string;
|
|
26
|
-
}
|
|
27
11
|
export default AddressStateSelector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseSelect from"../utils/BaseSelect";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseSelect from"../utils/BaseSelect";import BillingAddressFormContext from"../../context/BillingAddressFormContext";import ShippingAddressFormContext from"../../context/ShippingAddressFormContext";import isEmpty from"lodash/isEmpty";import{getStateOfCountry,isValidState}from"../../utils/countryStateCity";import isEmptyStates from"../../utils/isEmptyStates";import AddressesContext from"../../context/AddressContext";import BaseInput from"../utils/BaseInput";import CustomerAddressFormContext from"../../context/CustomerAddressFormContext";export function AddressStateSelector(props){const{required=!0,value,name,className="",inputClassName="",selectClassName="",...p}=props,billingAddress=useContext(BillingAddressFormContext),shippingAddress=useContext(ShippingAddressFormContext),customerAddress=useContext(CustomerAddressFormContext),{errors:addressErrors}=useContext(AddressesContext),[hasError,setHasError]=useState(!1),[countryCode,setCountryCode]=useState(""),[val,setVal]=useState(value||"");useEffect(()=>{const billingCountryCode=typeof billingAddress?.values?.billing_address_country_code=="string"?billingAddress?.values?.billing_address_country_code:billingAddress?.values?.billing_address_country_code?.value;billingCountryCode&&billingCountryCode!==countryCode&&setCountryCode(billingCountryCode);const shippingCountryCode=typeof shippingAddress?.values?.shipping_address_country_code=="string"?shippingAddress?.values?.shipping_address_country_code:shippingAddress?.values?.shipping_address_country_code?.value;if(shippingCountryCode&&shippingCountryCode!==countryCode&&setCountryCode(shippingCountryCode),[Object.keys(billingAddress).length>0,billingCountryCode,countryCode!==billingCountryCode].every(Boolean)&&billingCountryCode&&!isValidState(val,billingCountryCode)&&!isEmptyStates(billingCountryCode)&&(billingAddress.resetField&&billingAddress?.resetField(name),setVal("")),[!isEmpty(shippingAddress),shippingCountryCode,countryCode!==shippingCountryCode].every(Boolean)&&shippingCountryCode&&!isValidState(val,shippingCountryCode)&&!isEmptyStates(shippingCountryCode)&&(shippingAddress.resetField&&shippingAddress?.resetField(name),setVal("")),!isEmpty(billingAddress)){const fieldError=billingAddress?.errors?.[name]?.error;setHasError(!!fieldError)}if(!isEmpty(customerAddress)){const fieldError=customerAddress?.errors?.[name]?.error;setHasError(!!fieldError)}if(!isEmpty(shippingAddress)){const fieldError=shippingAddress?.errors?.[name]?.error;setHasError(!!fieldError)}return()=>{setHasError(!1)}},[value,billingAddress,shippingAddress,addressErrors,customerAddress]);const errorClassName=billingAddress?.errorClassName||shippingAddress?.errorClassName||customerAddress?.errorClassName||"",classNameComputed=isEmptyStates(countryCode)?`${className} ${inputClassName} ${hasError?errorClassName:""}`:`${className} ${selectClassName} ${hasError?errorClassName:""}`;return isEmptyStates(countryCode)?_jsx(BaseInput,{...p,name,ref:billingAddress?.validation||shippingAddress?.validation||customerAddress?.validation,className:classNameComputed,required,placeholder:p.placeholder?.label||"",defaultValue:val,type:"text"}):_jsx(BaseSelect,{...p,className:classNameComputed,ref:billingAddress?.validation||shippingAddress?.validation||customerAddress?.validation,required,options:getStateOfCountry(countryCode),name,value:val})}export default AddressStateSelector;
|
|
@@ -5,9 +5,4 @@ declare type Props = {
|
|
|
5
5
|
errorClassName?: string;
|
|
6
6
|
} & Omit<JSX.IntrinsicElements['form'], 'onSubmit'>;
|
|
7
7
|
export declare function BillingAddressForm(props: Props): JSX.Element;
|
|
8
|
-
export declare namespace BillingAddressForm {
|
|
9
|
-
var propTypes: {
|
|
10
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
8
|
export default BillingAddressForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import BillingAddressFormContext from"../../context/BillingAddressFormContext";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import BillingAddressFormContext from"../../context/BillingAddressFormContext";import isEmpty from"lodash/isEmpty";import OrderContext from"../../context/OrderContext";import{getSaveBillingAddressToAddressBook}from"../../utils/localStorage";import{businessMandatoryField}from"../../utils/validateFormFields";export function BillingAddressForm(props){const{children,errorClassName,autoComplete="on",reset=!1,...p}=props,{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress,isBusiness}=useContext(AddressesContext),{saveAddressToCustomerAddressBook,order,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{if(include?.includes("billing_address")?includeLoaded?.billing_address||addResourceToInclude({newResourceLoaded:{billing_address:!0}}):addResourceToInclude({newResource:"billing_address"}),isEmpty(errors)){if(values&&Object.keys(values).length>0){setAddressErrors([],"billing_address");for(const name in values){const field=values[name];businessMandatoryField(name,isBusiness)||delete values[name],(field?.value||field?.required===!1&&field?.type!=="checkbox")&&(values[name.replace("billing_address_","")]=field.value,delete values[name]),field?.type==="checkbox"&&(delete values[name],saveAddressToCustomerAddressBook({type:"billing_address",value:field.checked}))}setAddress({values:{...values,...isBusiness&&{business:isBusiness}},resource:"billing_address"})}}else{const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message;["billing_address_state_code"].includes(fieldName)?values?.state_code?formErrors.push({code,message:message||"",resource:"billing_address",field:fieldName}):delete errors[fieldName]:formErrors.push({code,message:message||"",resource:"billing_address",field:fieldName})}setAddressErrors(formErrors,"billing_address")}const checkboxChecked=ref.current?.querySelector('[name="billing_address_save_to_customer_book"]')?.checked||getSaveBillingAddressToAddressBook();reset&&(!isEmpty(values)||!isEmpty(errors)||checkboxChecked)&&(saveAddressToCustomerAddressBook&&saveAddressToCustomerAddressBook({type:"billing_address",value:!1}),ref&&(ref.current?.reset(),resetForm({target:ref.current}),setAddressErrors([],"billing_address"),setAddress({values:{},resource:"billing_address"})))},[errors,values,reset,include,includeLoaded,isBusiness]);const providerValues={isBusiness,values,validation,setValue:(name,value)=>{const field={[name.replace("billing_address_","")]:value};setAddress({values:{...values,...field,...isBusiness&&{business:isBusiness}},resource:"billing_address"})},errorClassName,requiresBillingInfo:order?.requires_billing_info||!1,errors,resetField:name=>resetForm({currentTarget:ref.current},name)};return _jsx(BillingAddressFormContext.Provider,{value:providerValues,children:_jsx("form",{ref,autoComplete,...p,children})})}export default BillingAddressForm;
|
|
@@ -2,11 +2,11 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { ChildrenFunction } from '../../typings/index';
|
|
3
3
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
interface Props extends Omit<JSX.IntrinsicElements['button'], 'children'> {
|
|
6
6
|
children?: ChildrenFunction<ChildrenProps>;
|
|
7
7
|
label?: string | ReactNode;
|
|
8
8
|
onClick?: () => void;
|
|
9
9
|
addressId?: string;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
export declare function SaveAddressesButton(props: Props): JSX.Element;
|
|
12
12
|
export default SaveAddressesButton;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
children:
|
|
4
|
-
};
|
|
5
|
-
export declare function ShippingAddressContainer(props: Props): JSX.Element;
|
|
6
|
-
export declare namespace ShippingAddressContainer {
|
|
7
|
-
var propTypes: {
|
|
8
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
9
|
-
};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface Props {
|
|
3
|
+
children: JSX.Element[] | JSX.Element;
|
|
10
4
|
}
|
|
5
|
+
export declare function ShippingAddressContainer(props: Props): JSX.Element;
|
|
11
6
|
export default ShippingAddressContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import ShippingAddressContext from"../../context/ShippingAddressContext";import{useContext,useEffect,useReducer}from"react";import shippingAddressReducer,{setShippingAddress,shippingAddressInitialState,setShippingCustomerAddressId}from"../../reducers/ShippingAddressReducer";import CommerceLayerContext from"../../context/CommerceLayerContext";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import ShippingAddressContext from"../../context/ShippingAddressContext";import{useContext,useEffect,useReducer}from"react";import shippingAddressReducer,{setShippingAddress,shippingAddressInitialState,setShippingCustomerAddressId}from"../../reducers/ShippingAddressReducer";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext from"../../context/OrderContext";import AddressContext from"../../context/AddressContext";export function ShippingAddressContainer(props){const{children}=props,[state,dispatch]=useReducer(shippingAddressReducer,shippingAddressInitialState),config=useContext(CommerceLayerContext),{order}=useContext(OrderContext),{setCloneAddress}=useContext(AddressContext);useEffect(()=>(order&&config&&setShippingCustomerAddressId({dispatch,order,setCloneAddress}),()=>{dispatch({type:"cleanup",payload:{}})}),[config,order]);const contextValue={...state,setShippingAddress:async(id,options)=>{await setShippingAddress(id,{config,dispatch,order,customerAddressId:options?.customerAddressId}),setCloneAddress(id,"shipping_address")}};return _jsx(ShippingAddressContext.Provider,{value:contextValue,children})}export default ShippingAddressContainer;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
interface Props extends Omit<JSX.IntrinsicElements['form'], 'onSubmit'> {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
reset?: boolean;
|
|
5
5
|
errorClassName?: string;
|
|
6
|
-
} & Omit<JSX.IntrinsicElements['form'], 'onSubmit'>;
|
|
7
|
-
export declare function ShippingAddressForm(props: Props): JSX.Element;
|
|
8
|
-
export declare namespace ShippingAddressForm {
|
|
9
|
-
var propTypes: {
|
|
10
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
11
|
-
};
|
|
12
6
|
}
|
|
7
|
+
export declare function ShippingAddressForm(props: Props): JSX.Element;
|
|
13
8
|
export default ShippingAddressForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import ShippingAddressFormContext from"../../context/ShippingAddressFormContext";import{isEmpty}from"lodash";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import ShippingAddressFormContext from"../../context/ShippingAddressFormContext";import{isEmpty}from"lodash";import OrderContext from"../../context/OrderContext";import{getSaveShippingAddressToAddressBook}from"../../utils/localStorage";import{businessMandatoryField}from"../../utils/validateFormFields";export function ShippingAddressForm(props){const{children,errorClassName,autoComplete="on",reset=!1,...p}=props,{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress,shipToDifferentAddress,isBusiness}=useContext(AddressesContext),{saveAddressToCustomerAddressBook,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{if(include?.includes("shipping_address")?includeLoaded?.shipping_address||addResourceToInclude({newResourceLoaded:{shipping_address:!0}}):addResourceToInclude({newResource:"shipping_address"}),isEmpty(errors)){if(!isEmpty(values)&&shipToDifferentAddress){setAddressErrors([],"shipping_address");for(const name in values){const field=values[name];businessMandatoryField(name,isBusiness)||delete values[name],(field?.value||field?.required===!1&&field?.type!=="checkbox")&&(values[name.replace("shipping_address_","")]=field.value,delete values[name]),field?.type==="checkbox"&&(delete values[name],saveAddressToCustomerAddressBook({type:"shipping_address",value:field.checked}))}setAddress({values:{...values,...isBusiness&&{business:isBusiness}},resource:"shipping_address"})}}else{const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message;["shipping_address_state_code"].includes(fieldName)?isEmpty(values.state_code)?delete errors[fieldName]:formErrors.push({code,message:message||"",resource:"shipping_address",field:fieldName}):formErrors.push({code,message:message||"",resource:"shipping_address",field:fieldName})}shipToDifferentAddress&&setAddressErrors(formErrors,"shipping_address")}const checkboxChecked=ref.current?.querySelector('[name="shipping_address_save_to_customer_book"]')?.checked||getSaveShippingAddressToAddressBook();reset&&(!isEmpty(values)||!isEmpty(errors)||checkboxChecked)&&(saveAddressToCustomerAddressBook&&saveAddressToCustomerAddressBook({type:"shipping_address",value:!1}),ref&&(ref.current?.reset(),resetForm({target:ref.current}),setAddressErrors([],"shipping_address"),setAddress({values:{},resource:"shipping_address"})))},[values,errors,shipToDifferentAddress,reset,include,includeLoaded,isBusiness]);const providerValues={values,validation,setValue:(name,value)=>{const field={[name.replace("shipping_address_","")]:value};setAddress({values:{...values,...field,...isBusiness&&{business:isBusiness}},resource:"shipping_address"})},errorClassName,errors,resetField:name=>resetForm({currentTarget:ref.current},name)};return _jsx(ShippingAddressFormContext.Provider,{value:providerValues,children:_jsx("form",{ref,autoComplete,...p,children})})}export default ShippingAddressForm;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
interface Props extends Omit<JSX.IntrinsicElements['form'], 'onSubmit'> {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
reset?: boolean;
|
|
5
5
|
errorClassName?: string;
|
|
6
|
-
} & Omit<JSX.IntrinsicElements['form'], 'onSubmit'>;
|
|
7
|
-
export declare function CustomerAddressForm(props: Props): JSX.Element;
|
|
8
|
-
export declare namespace CustomerAddressForm {
|
|
9
|
-
var propTypes: {
|
|
10
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
11
|
-
};
|
|
12
6
|
}
|
|
7
|
+
export declare function CustomerAddressForm(props: Props): JSX.Element;
|
|
13
8
|
export default CustomerAddressForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import CustomerAddressFormContext from"../../context/CustomerAddressFormContext";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import CustomerAddressFormContext from"../../context/CustomerAddressFormContext";import OrderContext from"../../context/OrderContext";import isEmptyStates from"../../utils/isEmptyStates";export function CustomerAddressForm(props){const{children,errorClassName,autoComplete="on",reset=!1,...p}=props,{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress}=useContext(AddressesContext),{order}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{if(Object.keys(errors).length>0){const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message||"";fieldName==="billing_address_state_code"?values.state_code?delete errors[fieldName]:formErrors.push({code,message,resource:"billing_address",field:fieldName}):formErrors.push({code,message,resource:"billing_address",field:fieldName})}setAddressErrors(formErrors,"billing_address")}else if(Object.keys(values).length>0){setAddressErrors([],"billing_address");for(const name in values){const field=values[name];if(field?.value&&(values[name.replace("billing_address_","")]=field.value,delete values[name]),["billing_address_state_code"].includes(name)){const countryCode=values.billing_address_country_code?.value||values.country_code;!isEmptyStates(countryCode)&&!field.value&&delete values.billing_address_state_code}}setAddress({values,resource:"billing_address"})}reset&&(Object.keys(values).length>0||Object.keys(errors).length>0)&&ref&&(ref.current?.reset(),resetForm({target:ref.current}),setAddressErrors([],"billing_address"),setAddress({values:{},resource:"billing_address"}))},[errors,values,reset]);const providerValues={values,validation,setValue:(name,value)=>{const field={[name.replace("billing_address_","")]:value};setAddress({values:{...values,...field},resource:"billing_address"})},errorClassName,requiresBillingInfo:order?.requires_billing_info||!1,errors,resetField:name=>resetForm({currentTarget:ref.current},name)};return _jsx(CustomerAddressFormContext.Provider,{value:providerValues,children:_jsx("form",{ref,autoComplete,...p,children})})}export default CustomerAddressForm;
|
|
@@ -6,18 +6,6 @@ declare type Props = {
|
|
|
6
6
|
saveOnBlur?: boolean;
|
|
7
7
|
onBlur?: (email: string) => void;
|
|
8
8
|
errorClassName?: string;
|
|
9
|
-
} & Omit<BaseInputComponentProps, 'name' | 'type' | 'onBlur'> & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea']
|
|
9
|
+
} & Omit<BaseInputComponentProps, 'name' | 'type' | 'onBlur'> & Omit<JSX.IntrinsicElements['input'], 'children'> & Omit<JSX.IntrinsicElements['textarea'], 'children'>;
|
|
10
10
|
export declare function CustomerInput(props: Props): JSX.Element;
|
|
11
|
-
export declare namespace CustomerInput {
|
|
12
|
-
var propTypes: {
|
|
13
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
14
|
-
name: import("prop-types").Requireable<string>;
|
|
15
|
-
type: import("prop-types").Requireable<string>;
|
|
16
|
-
placeholder: import("prop-types").Requireable<string>;
|
|
17
|
-
disabled: import("prop-types").Requireable<boolean>;
|
|
18
|
-
required: import("prop-types").Requireable<boolean>;
|
|
19
|
-
saveOnBlur: import("prop-types").Requireable<boolean>;
|
|
20
|
-
};
|
|
21
|
-
var displayName: string;
|
|
22
|
-
}
|
|
23
11
|
export default CustomerInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseInput from"../utils/BaseInput";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseInput from"../utils/BaseInput";import{useRapidForm}from"rapid-form";import CustomerContext from"../../context/CustomerContext";export function CustomerInput(props){const{name="customer_email",placeholder="",required=!0,saveOnBlur=!1,type="email",value,onBlur,className,errorClassName,...p}=props,{validation,values,errors}=useRapidForm({fieldEvent:"blur"}),{saveCustomerUser,setCustomerErrors,setCustomerEmail}=useContext(CustomerContext),[hasError,setHasError]=useState(!1),handleOnBlur=async()=>{saveOnBlur&&Object.keys(errors).length===0&&Object.keys(values).length>0&&(saveCustomerUser&&await saveCustomerUser(values[name].value),onBlur&&onBlur(values[name].value))};useEffect(()=>{if(Object.keys(errors).length>0){const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message;formErrors.push({code,message:message||"",resource:"orders",field:fieldName})}formErrors.length>0&&(setHasError(!0),setCustomerErrors&&setCustomerErrors(formErrors))}else Object.keys(values).length>0&&(setCustomerErrors&&setCustomerErrors([]),setCustomerEmail&&setCustomerEmail(values[name].value),setHasError(!1));return()=>{setHasError(!1)}},[errors]);const classNameComputed=`${className??""} ${hasError&&errorClassName?errorClassName:""}`;return _jsx(BaseInput,{name,type,ref:validation,required,placeholder,defaultValue:value,onBlur:()=>{handleOnBlur()},className:classNameComputed,...p})}export default CustomerInput;
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { BaseState } from '../../typings/index';
|
|
3
|
-
|
|
4
|
-
children:
|
|
3
|
+
interface Props extends Omit<JSX.IntrinsicElements['form'], 'children'> {
|
|
4
|
+
children: JSX.Element[] | JSX.Element;
|
|
5
5
|
onSubmit?: (values: BaseState) => void;
|
|
6
|
-
} & JSX.IntrinsicElements['form'];
|
|
7
|
-
export declare function GiftCard(props: Props): JSX.Element;
|
|
8
|
-
export declare namespace GiftCard {
|
|
9
|
-
var propTypes: {
|
|
10
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
11
|
-
onSubmit: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
12
|
-
};
|
|
13
|
-
var defaultProps: {
|
|
14
|
-
onSubmit: undefined;
|
|
15
|
-
};
|
|
16
|
-
var displayName: string;
|
|
17
6
|
}
|
|
7
|
+
export declare function GiftCard(props: Props): JSX.Element;
|
|
18
8
|
export default GiftCard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useRef,useContext}from"react";import validateFormFields from"../../utils/validateFormFields";import{isEmpty}from"lodash";import GiftCardContext from"../../context/GiftCardContext";export function GiftCard(props){const{children,onSubmit}=props,name="giftCardForm",ref=useRef(null),{addGiftCard,addGiftCardError}=useContext(GiftCardContext);return _jsx(_Fragment,{children:_jsx("form",{name,ref,onSubmit:e=>{e.preventDefault();const currentForm=ref.current,elements=currentForm?.elements,{errors,values}=validateFormFields(elements,["currencyCode","balanceCents"],"gift_cards");isEmpty(errors)?(addGiftCard(values),currentForm?.reset(),onSubmit&&onSubmit(values)):addGiftCardError(errors)},children},name)})}export default GiftCard;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export interface Props {
|
|
3
3
|
children: ReactNode;
|
|
4
|
-
};
|
|
5
|
-
export declare function GiftCardContainer(props: Props): JSX.Element;
|
|
6
|
-
export declare namespace GiftCardContainer {
|
|
7
|
-
var propTypes: {
|
|
8
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
9
|
-
};
|
|
10
|
-
var displayName: string;
|
|
11
4
|
}
|
|
5
|
+
export declare function GiftCardContainer(props: Props): JSX.Element;
|
|
12
6
|
export default GiftCardContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useReducer,useContext}from"react";import GiftCardContext from"../../context/GiftCardContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import giftCardReducer,{giftCardInitialState,addGiftCardRecipient,addGiftCard,addGiftCardError,addGiftCardLoading}from"../../reducers/GiftCardReducer";import OrderContext from"../../context/OrderContext";
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useReducer,useContext}from"react";import GiftCardContext from"../../context/GiftCardContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import giftCardReducer,{giftCardInitialState,addGiftCardRecipient,addGiftCard,addGiftCardError,addGiftCardLoading}from"../../reducers/GiftCardReducer";import OrderContext from"../../context/OrderContext";export function GiftCardContainer(props){const{children}=props,[state,dispatch]=useReducer(giftCardReducer,giftCardInitialState),config=useContext(CommerceLayerContext),{getOrder,createOrder,order}=useContext(OrderContext),giftCardValue={...state,addGiftCardRecipient:async values=>await addGiftCardRecipient(values,config,dispatch),addGiftCard:async values=>await addGiftCard({...values},{config,dispatch,getOrder,createOrder,order}),addGiftCardError:errors=>addGiftCardError(errors,dispatch),addGiftCardLoading:loading=>addGiftCardLoading(loading,dispatch)};return _jsx(GiftCardContext.Provider,{value:giftCardValue,children})}export default GiftCardContainer;
|
|
@@ -4,19 +4,4 @@ declare type Props = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
|
|
|
4
4
|
required?: boolean;
|
|
5
5
|
} & Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'>;
|
|
6
6
|
export declare function GiftCardCurrencySelector(props: Props): JSX.Element;
|
|
7
|
-
export declare namespace GiftCardCurrencySelector {
|
|
8
|
-
var propTypes: {
|
|
9
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
10
|
-
placeholder: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
11
|
-
value: import("prop-types").Validator<NonNullable<NonNullable<string | number | null | undefined>>>;
|
|
12
|
-
label: import("prop-types").Validator<string>;
|
|
13
|
-
}>>;
|
|
14
|
-
value: import("prop-types").Requireable<string>;
|
|
15
|
-
required: import("prop-types").Requireable<boolean>;
|
|
16
|
-
};
|
|
17
|
-
var defaultProps: {
|
|
18
|
-
required: boolean;
|
|
19
|
-
};
|
|
20
|
-
var displayName: string;
|
|
21
|
-
}
|
|
22
7
|
export default GiftCardCurrencySelector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import BaseSelect from"../utils/BaseSelect";import currencyOptions from"../../config/currency";
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseSelect from"../utils/BaseSelect";import currencyOptions from"../../config/currency";export function GiftCardCurrencySelector(props){return _jsx(BaseSelect,{options:currencyOptions,name:"currencyCode",...props})}export default GiftCardCurrencySelector;
|
|
@@ -2,15 +2,6 @@
|
|
|
2
2
|
import { BaseInputComponentProps, GiftCardInputName } from '../../typings/index';
|
|
3
3
|
declare type Props = {
|
|
4
4
|
name: GiftCardInputName;
|
|
5
|
-
} & Omit<BaseInputComponentProps, 'name'> & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea']
|
|
5
|
+
} & Omit<BaseInputComponentProps, 'name'> & Omit<JSX.IntrinsicElements['input'], 'children'> & Omit<JSX.IntrinsicElements['textarea'], 'children'>;
|
|
6
6
|
export declare function GiftCardInput(props: Props): JSX.Element;
|
|
7
|
-
export declare namespace GiftCardInput {
|
|
8
|
-
var propTypes: {
|
|
9
|
-
type: import("prop-types").Validator<NonNullable<import("../../typings/index").BaseInputType>>;
|
|
10
|
-
name: import("prop-types").Validator<NonNullable<GiftCardInputName>>;
|
|
11
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
12
|
-
placeholder: import("prop-types").Requireable<string>;
|
|
13
|
-
};
|
|
14
|
-
var displayName: string;
|
|
15
|
-
}
|
|
16
7
|
export default GiftCardInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import BaseInput from"../utils/BaseInput";
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseInput from"../utils/BaseInput";export function GiftCardInput(props){const{placeholder="",...p}=props;return _jsx(BaseInput,{placeholder,...p})}export default GiftCardInput;
|
|
@@ -7,9 +7,4 @@ declare type Props = {
|
|
|
7
7
|
}) => void;
|
|
8
8
|
} & Omit<JSX.IntrinsicElements['form'], 'onSubmit'>;
|
|
9
9
|
export declare function GiftCardOrCouponForm(props: Props): JSX.Element | null;
|
|
10
|
-
export declare namespace GiftCardOrCouponForm {
|
|
11
|
-
var propTypes: {
|
|
12
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
10
|
export default GiftCardOrCouponForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef,useState}from"react";import CouponAndGiftCardFormContext from"../../context/CouponAndGiftCardFormContext";import OrderContext from"../../context/OrderContext";import isEmpty from"lodash/isEmpty";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef,useState}from"react";import CouponAndGiftCardFormContext from"../../context/CouponAndGiftCardFormContext";import OrderContext from"../../context/OrderContext";import isEmpty from"lodash/isEmpty";import camelCase from"lodash/camelCase";import dropWhile from"lodash/dropWhile";import has from"lodash/has";import{findIndex}from"lodash";export function GiftCardOrCouponForm(props){const{children,autoComplete="on",onSubmit,...p}=props,{validation,values,reset}=useRapidForm(),[codeType,setCodeType]=useState("gift_card_or_coupon_code"),{setGiftCardOrCouponCode,order,errors,setOrderErrors}=useContext(OrderContext),ref=useRef(null),inputName="gift_card_or_coupon_code";useEffect(()=>{if(values[inputName]?.value===""&&findIndex(errors,{field:camelCase(inputName)})!==-1){const err=dropWhile(errors,i=>i.field===camelCase(inputName));setOrderErrors(err),onSubmit&&onSubmit({value:values[inputName]?.value,success:!1})}values[inputName]?.value===""&&(setOrderErrors([]),onSubmit&&onSubmit({value:values[inputName]?.value,success:!1}))},[values]),useEffect(()=>{order?.gift_card_code&&!order?.coupon_code&&setCodeType("coupon_code"),!order?.gift_card_code&&order?.coupon_code&&setCodeType("gift_card_code"),!order?.gift_card_code&&!order?.coupon_code&&setCodeType("gift_card_or_coupon_code")},[order]);const handleSubmit=async e=>{e.preventDefault();const code=has(values,inputName)?values[inputName].value:void 0;if(code){const{success}=await setGiftCardOrCouponCode({code,codeType}),value=values[inputName]?.value;onSubmit&&onSubmit({success,value}),success&&reset(e)}};return order?.gift_card_code&&order?.coupon_code||isEmpty(order)?null:_jsx(CouponAndGiftCardFormContext.Provider,{value:{validation,codeType},children:_jsx("form",{ref,autoComplete,onSubmit:e=>{handleSubmit(e)},...p,children})})}export default GiftCardOrCouponForm;
|
|
@@ -5,15 +5,6 @@ declare type Props = {
|
|
|
5
5
|
name?: 'gift_card_or_coupon_code';
|
|
6
6
|
type?: 'text';
|
|
7
7
|
placeholderTranslation?: (codeType: OrderCodeType) => string;
|
|
8
|
-
} & Omit<BaseInputComponentProps, 'name' | 'type'> & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea']
|
|
8
|
+
} & Omit<BaseInputComponentProps, 'name' | 'type'> & Omit<JSX.IntrinsicElements['input'], 'children'> & Omit<JSX.IntrinsicElements['textarea'], 'children'>;
|
|
9
9
|
export declare function GiftCardOrCouponInput(props: Props): JSX.Element;
|
|
10
|
-
export declare namespace GiftCardOrCouponInput {
|
|
11
|
-
var propTypes: {
|
|
12
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
13
|
-
placeholder: import("prop-types").Requireable<string>;
|
|
14
|
-
disabled: import("prop-types").Requireable<boolean>;
|
|
15
|
-
required: import("prop-types").Requireable<boolean>;
|
|
16
|
-
};
|
|
17
|
-
var displayName: string;
|
|
18
|
-
}
|
|
19
10
|
export default GiftCardOrCouponInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import BaseInput from"../utils/BaseInput";import CouponAndGiftCardFormContext from"../../context/CouponAndGiftCardFormContext";export function GiftCardOrCouponInput(props){const{placeholder="",required,value,placeholderTranslation,...p}=props,{validation,codeType}=useContext(CouponAndGiftCardFormContext);let placeholderLabel=placeholder;return placeholderTranslation&&codeType&&(placeholderLabel=placeholderTranslation(codeType)),_jsx(BaseInput,{type:"text",name:"gift_card_or_coupon_code",ref:validation,required:required!==void 0?required:!0,placeholder:placeholderLabel,defaultValue:value,...p})}export default GiftCardOrCouponInput;
|
|
@@ -9,6 +9,6 @@ declare type Props = {
|
|
|
9
9
|
max?: number;
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
readonly?: boolean;
|
|
12
|
-
} & (JSX.IntrinsicElements['select'] & JSX.IntrinsicElements['span']);
|
|
12
|
+
} & (JSX.IntrinsicElements['select'] & Omit<JSX.IntrinsicElements['span'], 'children'>);
|
|
13
13
|
export declare function LineItemQuantity(props: Props): JSX.Element;
|
|
14
14
|
export default LineItemQuantity;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { TypeAccepted } from '../../utils/getLineItemsCount';
|
|
2
|
+
import { type TypeAccepted } from '../../utils/getLineItemsCount';
|
|
3
3
|
import { ChildrenFunction } from '../../typings/index';
|
|
4
4
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
5
5
|
quantity: number;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
interface Props extends Omit<JSX.IntrinsicElements['span'], 'children'> {
|
|
8
8
|
children?: ChildrenFunction<ChildrenProps>;
|
|
9
9
|
typeAccepted?: TypeAccepted[];
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
export declare function LineItemsCount(props: Props): JSX.Element;
|
|
12
12
|
export default LineItemsCount;
|
|
@@ -4,10 +4,10 @@ interface ChildrenProps extends Omit<Props, 'children'> {
|
|
|
4
4
|
checkoutUrl: string;
|
|
5
5
|
href: string;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
interface Props extends Omit<JSX.IntrinsicElements['a'], 'children'> {
|
|
8
8
|
children?: ChildrenFunction<ChildrenProps>;
|
|
9
9
|
label?: string;
|
|
10
10
|
hostedCheckout?: boolean;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
export declare function CheckoutLink(props: Props): JSX.Element;
|
|
13
13
|
export default CheckoutLink;
|
|
@@ -3,9 +3,21 @@ import { BaseMetadataObject } from '../../typings/index';
|
|
|
3
3
|
import type { OrderCreate, Order } from '@commercelayer/sdk';
|
|
4
4
|
interface Props {
|
|
5
5
|
children: JSX.Element[] | JSX.Element;
|
|
6
|
+
/**
|
|
7
|
+
* Metadata to add when creates a new order
|
|
8
|
+
*/
|
|
6
9
|
metadata?: BaseMetadataObject;
|
|
10
|
+
/**
|
|
11
|
+
* Attribute to add when creates/updates an order
|
|
12
|
+
*/
|
|
7
13
|
attributes?: OrderCreate;
|
|
14
|
+
/**
|
|
15
|
+
* ID of the order
|
|
16
|
+
*/
|
|
8
17
|
orderId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Callback called when the order is updated
|
|
20
|
+
*/
|
|
9
21
|
fetchOrder?: (order: Order) => void;
|
|
10
22
|
}
|
|
11
23
|
export declare function OrderContainer(props: Props): JSX.Element;
|
|
@@ -2,10 +2,4 @@
|
|
|
2
2
|
import { BaseFieldProps } from '../utils/BaseField';
|
|
3
3
|
declare type Props = Omit<BaseFieldProps, 'attribute'>;
|
|
4
4
|
export declare function OrderNumber(props: Props): JSX.Element;
|
|
5
|
-
export declare namespace OrderNumber {
|
|
6
|
-
var propTypes: {
|
|
7
|
-
className: import("prop-types").Requireable<string>;
|
|
8
|
-
};
|
|
9
|
-
var displayName: string;
|
|
10
|
-
}
|
|
11
5
|
export default OrderNumber;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseField from"../utils/BaseField";export function OrderNumber(props){return _jsx(BaseField,{attribute:"number",...props})}export default OrderNumber;
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
interface Props {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
persistKey: string;
|
|
5
5
|
clearWhenPlaced?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare function OrderStorage(props: Props): JSX.Element;
|
|
8
|
-
export declare namespace OrderStorage {
|
|
9
|
-
var propTypes: {
|
|
10
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
11
|
-
clearWhenPlaced: import("prop-types").Requireable<boolean>;
|
|
12
|
-
persistKey: import("prop-types").Validator<string>;
|
|
13
|
-
};
|
|
14
|
-
var displayName: string;
|
|
15
6
|
}
|
|
7
|
+
export declare function OrderStorage(props: Props): JSX.Element;
|
|
16
8
|
export default OrderStorage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import OrderStorageContext from"../../context/OrderStorageContext";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import OrderStorageContext from"../../context/OrderStorageContext";import{getLocalOrder,setLocalOrder,deleteLocalOrder}from"../../utils/localStorage";export function OrderStorage(props){const{children,clearWhenPlaced=!0,...p}=props;return _jsx(OrderStorageContext.Provider,{value:{...p,setLocalOrder,getLocalOrder,deleteLocalOrder,clearWhenPlaced},children})}export default OrderStorage;
|
|
@@ -3,12 +3,12 @@ import { ChildrenFunction } from '../../typings/index';
|
|
|
3
3
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
4
4
|
handleClick: () => Promise<void>;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
interface Props extends Omit<JSX.IntrinsicElements['button'], 'children' | 'onClick'> {
|
|
7
7
|
children?: ChildrenFunction<ChildrenProps>;
|
|
8
8
|
label?: string | ReactNode;
|
|
9
9
|
onClick?: (response: {
|
|
10
10
|
placed: boolean;
|
|
11
11
|
}) => void;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
export declare function PlaceOrderButton(props: Props): JSX.Element;
|
|
14
14
|
export default PlaceOrderButton;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { LoaderType } from '../../typings/index';
|
|
3
3
|
import { CustomerCardsTemplateChildren } from '../utils/PaymentCardsTemplate';
|
|
4
4
|
export interface CustomerCardsProps {
|
|
@@ -7,13 +7,13 @@ export interface CustomerCardsProps {
|
|
|
7
7
|
export interface CustomerSaveToWalletProps {
|
|
8
8
|
name: 'save_payment_source_to_customer_wallet';
|
|
9
9
|
}
|
|
10
|
-
export
|
|
11
|
-
children?:
|
|
10
|
+
export interface PaymentSourceProps extends Omit<JSX.IntrinsicElements['div'], 'children'> {
|
|
11
|
+
children?: JSX.Element | JSX.Element[];
|
|
12
12
|
readonly?: boolean;
|
|
13
13
|
templateCustomerCards?: CustomerCardsTemplateChildren;
|
|
14
14
|
onClickCustomerCards?: () => void;
|
|
15
15
|
templateCustomerSaveToWallet?: (props: CustomerSaveToWalletProps) => JSX.Element;
|
|
16
16
|
loader?: LoaderType;
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
18
|
export declare function PaymentSource(props: PaymentSourceProps): JSX.Element;
|
|
19
19
|
export default PaymentSource;
|
|
@@ -6,10 +6,10 @@ interface ChildrenProps extends Omit<Props, 'children'> {
|
|
|
6
6
|
defaultSrc: string;
|
|
7
7
|
url: string;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
interface Props extends Omit<JSX.IntrinsicElements['img'], 'children'> {
|
|
10
10
|
children?: ChildrenFunction<ChildrenProps>;
|
|
11
11
|
width?: number;
|
|
12
12
|
height?: number;
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
14
|
export declare function PaymentSourceBrandIcon({ src, width, children, ...p }: Props): JSX.Element;
|
|
15
15
|
export default PaymentSourceBrandIcon;
|
|
@@ -4,9 +4,9 @@ import { ChildrenFunction } from '../../typings/index';
|
|
|
4
4
|
interface CustomComponent extends Omit<Props, 'children'> {
|
|
5
5
|
brand: IconBrand;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
interface Props extends Omit<JSX.IntrinsicElements['span'], 'children'> {
|
|
8
8
|
children?: ChildrenFunction<CustomComponent>;
|
|
9
9
|
label?: string;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
export declare function PaymentSourceBrandName({ children, label, ...props }: Props): JSX.Element;
|
|
12
12
|
export default PaymentSourceBrandName;
|
|
@@ -4,9 +4,9 @@ declare type ShipmentFieldChildrenProps = Omit<Props, 'children'> & {
|
|
|
4
4
|
shipment: Shipment;
|
|
5
5
|
};
|
|
6
6
|
export declare type ShipmentAttribute = 'number' | 'currency_code' | 'status' | 'cost_amount_cents' | 'cost_amount_float' | 'formatted_cost_amount' | 'key_number';
|
|
7
|
-
|
|
7
|
+
interface Props extends Omit<JSX.IntrinsicElements['span'], 'children'> {
|
|
8
8
|
children?: (props: ShipmentFieldChildrenProps) => JSX.Element;
|
|
9
9
|
name: ShipmentAttribute;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
export declare function ShipmentField(props: Props): JSX.Element;
|
|
12
12
|
export default ShipmentField;
|
|
@@ -4,8 +4,8 @@ declare type ChildrenProps = Omit<Props, 'children'> & {
|
|
|
4
4
|
label: string;
|
|
5
5
|
shippingMethod: ShippingMethod;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
interface Props extends Omit<JSX.IntrinsicElements['label'], 'children'> {
|
|
8
8
|
children?: (props: ChildrenProps) => JSX.Element;
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
10
|
export declare function ShippingMethodName(props: Props): JSX.Element;
|
|
11
11
|
export default ShippingMethodName;
|
|
@@ -10,16 +10,4 @@ declare type Props = BaseAmountComponent & {
|
|
|
10
10
|
base?: 'price';
|
|
11
11
|
});
|
|
12
12
|
export declare function ShippingMethodPrice(props: Props): JSX.Element;
|
|
13
|
-
export declare namespace ShippingMethodPrice {
|
|
14
|
-
var propTypes: {
|
|
15
|
-
type: import("prop-types").Requireable<"amount">;
|
|
16
|
-
id: import("prop-types").Requireable<string>;
|
|
17
|
-
className: import("prop-types").Requireable<string>;
|
|
18
|
-
style: import("prop-types").Requireable<object>;
|
|
19
|
-
name: import("prop-types").Requireable<string>;
|
|
20
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
21
|
-
format: import("prop-types").Requireable<import("../../typings/index").BaseFormatPrice>;
|
|
22
|
-
};
|
|
23
|
-
var displayName: string;
|
|
24
|
-
}
|
|
25
13
|
export default ShippingMethodPrice;
|