@commercelayer/react-components 3.13.0-beta.1 → 3.13.0-beta.4
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/components/AddToCartButton.d.ts +27 -1
- package/lib/components/Address.d.ts +13 -1
- package/lib/components/AddressCountrySelector.d.ts +9 -1
- package/lib/components/AddressField.d.ts +15 -1
- package/lib/components/AddressInput.d.ts +7 -1
- package/lib/components/AddressStateSelector.d.ts +11 -1
- package/lib/components/AddressesContainer.d.ts +8 -1
- package/lib/components/AdjustmentAmount.d.ts +4 -1
- package/lib/components/AdyenPayment.d.ts +25 -1
- package/lib/components/AvailabilityContainer.d.ts +7 -1
- package/lib/components/AvailabilityTemplate.d.ts +15 -1
- package/lib/components/BillingAddressContainer.d.ts +6 -1
- package/lib/components/BillingAddressForm.d.ts +8 -1
- package/lib/components/BraintreePayment.d.ts +30 -1
- package/lib/components/CheckoutComPayment.d.ts +23 -1
- package/lib/components/CheckoutLink.d.ts +13 -1
- package/lib/components/CommerceLayer.d.ts +8 -1
- package/lib/components/CustomerContainer.d.ts +7 -1
- package/lib/components/CustomerInput.d.ts +11 -1
- package/lib/components/DeliveryLeadTime.d.ts +10 -1
- package/lib/components/DiscountAmount.d.ts +4 -1
- package/lib/components/Errors.d.ts +5 -1
- package/lib/components/ExternalFunction.d.ts +7 -1
- package/lib/components/GiftCard.d.ts +8 -1
- package/lib/components/GiftCardAmount.d.ts +4 -1
- package/lib/components/GiftCardContainer.d.ts +6 -1
- package/lib/components/GiftCardCurrencySelector.d.ts +7 -1
- package/lib/components/GiftCardInput.d.ts +7 -1
- package/lib/components/GiftCardOrCouponCode.d.ts +17 -1
- package/lib/components/GiftCardOrCouponCode.js +1 -1
- package/lib/components/GiftCardOrCouponForm.d.ts +10 -1
- package/lib/components/GiftCardOrCouponInput.d.ts +10 -1
- package/lib/components/GiftCardOrCouponRemoveButton.d.ts +18 -1
- package/lib/components/GiftCardOrCouponSubmit.d.ts +9 -1
- package/lib/components/ItemContainer.d.ts +11 -1
- package/lib/components/KlarnaPayment.d.ts +9 -1
- package/lib/components/LineItem.d.ts +8 -1
- package/lib/components/LineItem.js +1 -1
- package/lib/components/LineItemAmount.d.ts +7 -1
- package/lib/components/LineItemCode.d.ts +12 -1
- package/lib/components/LineItemImage.d.ts +16 -1
- package/lib/components/LineItemImage.js +1 -1
- package/lib/components/LineItemName.d.ts +11 -1
- package/lib/components/LineItemOption.d.ts +19 -1
- package/lib/components/LineItemOptions.d.ts +16 -1
- package/lib/components/LineItemQuantity.d.ts +14 -1
- package/lib/components/LineItemRemoveLink.d.ts +12 -1
- package/lib/components/LineItemsContainer.d.ts +8 -1
- package/lib/components/LineItemsCount.d.ts +12 -1
- package/lib/components/LineItemsEmpty.d.ts +12 -1
- package/lib/components/MetadataInput.d.ts +5 -1
- package/lib/components/OrderContainer.d.ts +12 -1
- package/lib/components/OrderNumber.d.ts +5 -1
- package/lib/components/OrderStorage.d.ts +8 -1
- package/lib/components/PaymentGateway.d.ts +16 -1
- package/lib/components/PaymentMethod.d.ts +16 -1
- package/lib/components/PaymentMethodAmount.d.ts +4 -1
- package/lib/components/PaymentMethodName.d.ts +9 -1
- package/lib/components/PaymentMethodPrice.d.ts +9 -1
- package/lib/components/PaymentMethodRadioButton.d.ts +12 -1
- package/lib/components/PaymentMethodsContainer.d.ts +8 -1
- package/lib/components/PaymentSource.d.ts +19 -1
- package/lib/components/PaymentSourceBrandIcon.d.ts +15 -1
- package/lib/components/PaymentSourceBrandName.d.ts +12 -1
- package/lib/components/PaymentSourceDetail.d.ts +12 -1
- package/lib/components/PaymentSourceEditButton.d.ts +9 -1
- package/lib/components/PaypalPayment.d.ts +12 -1
- package/lib/components/PlaceOrderButton.d.ts +14 -1
- package/lib/components/PlaceOrderContainer.d.ts +8 -1
- package/lib/components/Price.d.ts +16 -1
- package/lib/components/PricesContainer.d.ts +11 -1
- package/lib/components/PrivacyAndTermsCheckbox.d.ts +4 -1
- package/lib/components/QuantitySelector.d.ts +17 -1
- package/lib/components/SaveAddressesButton.d.ts +10 -1
- package/lib/components/SaveCustomerButton.d.ts +13 -1
- package/lib/components/Shipment.d.ts +15 -1
- package/lib/components/Shipment.js +1 -1
- package/lib/components/ShipmentField.d.ts +12 -1
- package/lib/components/ShipmentsContainer.d.ts +6 -1
- package/lib/components/ShipmentsContainer.js +1 -1
- package/lib/components/ShippingAddressContainer.d.ts +6 -1
- package/lib/components/ShippingAddressForm.d.ts +8 -1
- package/lib/components/ShippingAmount.d.ts +4 -1
- package/lib/components/ShippingMethod.d.ts +8 -1
- package/lib/components/ShippingMethodName.d.ts +11 -1
- package/lib/components/ShippingMethodPrice.d.ts +13 -1
- package/lib/components/ShippingMethodRadioButton.d.ts +13 -1
- package/lib/components/ShippingMethodRadioButton.js +1 -1
- package/lib/components/SkuField.d.ts +9 -1
- package/lib/components/SkuList.d.ts +7 -1
- package/lib/components/SkuListsContainer.d.ts +6 -1
- package/lib/components/SkuOption.d.ts +7 -1
- package/lib/components/SkuOptionInput.d.ts +5 -1
- package/lib/components/SkuOptionsContainer.d.ts +7 -1
- package/lib/components/Skus.d.ts +11 -1
- package/lib/components/SkusContainer.d.ts +14 -1
- package/lib/components/StockTransfer.d.ts +6 -1
- package/lib/components/StockTransfer.js +1 -1
- package/lib/components/StockTransferField.d.ts +9 -1
- package/lib/components/StripePayment.d.ts +18 -1
- package/lib/components/SubTotalAmount.d.ts +4 -1
- package/lib/components/SubmitButton.d.ts +9 -1
- package/lib/components/TaxesAmount.d.ts +4 -1
- package/lib/components/TotalAmount.d.ts +4 -1
- package/lib/components/VariantSelector.d.ts +29 -1
- package/lib/components/VariantsContainer.d.ts +8 -1
- package/lib/components/WireTransferPayment.d.ts +10 -1
- package/lib/components/gateways/AdyenGateway.d.ts +4 -1
- package/lib/components/gateways/BraintreeGateway.d.ts +4 -1
- package/lib/components/gateways/CheckoutComGateway.d.ts +4 -1
- package/lib/components/gateways/KlarnaGateway.d.ts +4 -1
- package/lib/components/gateways/PaypalGateway.d.ts +4 -1
- package/lib/components/gateways/StripeGateway.d.ts +4 -1
- package/lib/components/gateways/WireTransferGateway.d.ts +4 -1
- package/lib/components/utils/AddressCardsTemplate.d.ts +26 -1
- package/lib/components/utils/BaseField.d.ts +8 -1
- package/lib/components/utils/BaseInput.d.ts +5 -1
- package/lib/components/utils/BaseInput.js +1 -1
- package/lib/components/utils/BaseOrderPrice.d.ts +6 -1
- package/lib/components/utils/BaseSelect.d.ts +5 -1
- package/lib/components/utils/GenericFieldComponent.d.ts +37 -1
- package/lib/components/utils/GenericFieldComponent.js +1 -1
- package/lib/components/utils/Parent.d.ts +6 -1
- package/lib/components/utils/Parent.js +1 -1
- package/lib/components/utils/PaymentCardsTemplate.d.ts +22 -1
- package/lib/components/utils/PriceTemplate.d.ts +8 -1
- package/lib/components/utils/VariantTemplate.d.ts +36 -1
- package/lib/components/utils/getAllErrors.d.ts +17 -1
- package/lib/config/components.d.ts +913 -1
- package/lib/config/currency.d.ts +5 -1
- package/lib/context/AddressChildrenContext.d.ts +6 -1
- package/lib/context/AddressContext.d.ts +16 -1
- package/lib/context/AvailabilityContext.d.ts +2 -1
- package/lib/context/BillingAddressContext.d.ts +11 -1
- package/lib/context/BillingAddressFormContext.d.ts +19 -1
- package/lib/context/CommerceLayerContext.d.ts +6 -1
- package/lib/context/CouponAndGiftCardFormContext.d.ts +9 -1
- package/lib/context/CustomerContext.d.ts +15 -1
- package/lib/context/ExternalFunctionContext.d.ts +11 -1
- package/lib/context/GiftCardContext.d.ts +10 -1
- package/lib/context/ItemContext.d.ts +12 -1
- package/lib/context/LineItemChildrenContext.d.ts +8 -1
- package/lib/context/LineItemContext.d.ts +7 -1
- package/lib/context/LineItemOptionChildrenContext.d.ts +7 -1
- package/lib/context/OrderContext.d.ts +29 -1
- package/lib/context/OrderStorageContext.d.ts +10 -1
- package/lib/context/PaymentMethodChildrenContext.d.ts +9 -1
- package/lib/context/PaymentMethodContext.d.ts +22 -1
- package/lib/context/PaymentSourceContext.d.ts +13 -1
- package/lib/context/PlaceOrderContext.d.ts +17 -1
- package/lib/context/PricesContext.d.ts +6 -1
- package/lib/context/ShipmentChildrenContext.d.ts +12 -1
- package/lib/context/ShipmentContext.d.ts +11 -1
- package/lib/context/ShippingAddressContext.d.ts +9 -1
- package/lib/context/ShippingAddressFormContext.d.ts +3 -1
- package/lib/context/ShippingMethodChildrenContext.d.ts +9 -1
- package/lib/context/SkuChildrenContext.d.ts +8 -1
- package/lib/context/SkuContext.d.ts +8 -1
- package/lib/context/SkuListsContext.d.ts +5 -1
- package/lib/context/SkuOptionChildrenContext.d.ts +7 -1
- package/lib/context/SkuOptionsContext.d.ts +2 -1
- package/lib/context/StockTransferChildrenContext.d.ts +6 -1
- package/lib/context/VariantsContext.d.ts +2 -1
- package/lib/index.d.ts +102 -1
- package/lib/reducers/AddressReducer.d.ts +59 -1
- package/lib/reducers/AvailabilityReducer.d.ts +61 -1
- package/lib/reducers/BillingAddressReducer.d.ts +31 -1
- package/lib/reducers/CustomerReducer.d.ts +50 -1
- package/lib/reducers/GiftCardReducer.d.ts +76 -1
- package/lib/reducers/ItemReducer.d.ts +69 -1
- package/lib/reducers/LineItemReducer.d.ts +52 -1
- package/lib/reducers/OrderReducer.d.ts +132 -2
- package/lib/reducers/PaymentMethodReducer.d.ts +151 -1
- package/lib/reducers/PlaceOrderReducer.d.ts +59 -1
- package/lib/reducers/PriceReducer.d.ts +44 -1
- package/lib/reducers/ShipmentReducer.d.ts +40 -1
- package/lib/reducers/ShippingAddressReducer.d.ts +32 -1
- package/lib/reducers/SkuListsReducer.d.ts +21 -1
- package/lib/reducers/SkuOptionsReducer.d.ts +26 -1
- package/lib/reducers/SkuReducer.d.ts +21 -1
- package/lib/reducers/VariantReducer.d.ts +71 -1
- package/lib/typings/errors.d.ts +42 -1
- package/lib/typings/index.d.ts +137 -1
- package/lib/utils/PropsType.d.ts +33 -1
- package/lib/utils/addressesManager.d.ts +28 -1
- package/lib/utils/baseReducer.d.ts +3 -1
- package/lib/utils/browserInfo.d.ts +9 -1
- package/lib/utils/checkIncludeResource.d.ts +8 -1
- package/lib/utils/childrenTypes.d.ts +9 -1
- package/lib/utils/compareObjAttribute.d.ts +7 -1
- package/lib/utils/countryStateCity.d.ts +9 -1
- package/lib/utils/customMessages.d.ts +8 -1
- package/lib/utils/customerOrderOptions.d.ts +3 -1
- package/lib/utils/getAmount.d.ts +9 -1
- package/lib/utils/getCardDetails.d.ts +15 -1
- package/lib/utils/getCurrentItemKey.d.ts +6 -1
- package/lib/utils/getErrors.d.ts +11 -1
- package/lib/utils/getLineItemsCount.d.ts +12 -1
- package/lib/utils/getLoaderComponent.d.ts +2 -1
- package/lib/utils/getPrices.d.ts +17 -1
- package/lib/utils/getSdk.d.ts +3 -1
- package/lib/utils/getSkus.d.ts +3 -1
- package/lib/utils/hooks/useExternalScript.d.ts +1 -1
- package/lib/utils/isEmptyStates.d.ts +1 -1
- package/lib/utils/isJSON.d.ts +1 -1
- package/lib/utils/jwt.d.ts +27 -1
- package/lib/utils/localStorage.d.ts +17 -1
- package/lib/utils/organization.d.ts +6 -1
- package/lib/utils/paypalPayment.d.ts +3 -1
- package/lib/utils/placeholderImages.d.ts +2 -0
- package/lib/utils/placeholderImages.js +1 -0
- package/lib/utils/promisify.d.ts +1 -1
- package/lib/utils/shipments.d.ts +3 -1
- package/lib/utils/validateFormFields.d.ts +22 -1
- package/package.json +2 -2
package/lib/typings/index.d.ts
CHANGED
|
@@ -1 +1,137 @@
|
|
|
1
|
-
import{Dispatch,
|
|
1
|
+
import { Dispatch, ForwardedRef, ReactNode, RefObject } from 'react';
|
|
2
|
+
import PropTypes, { InferProps } from 'prop-types';
|
|
3
|
+
import { BaseError } from './errors';
|
|
4
|
+
export declare const BC: {
|
|
5
|
+
id: PropTypes.Requireable<string>;
|
|
6
|
+
className: PropTypes.Requireable<string>;
|
|
7
|
+
style: PropTypes.Requireable<object>;
|
|
8
|
+
name: PropTypes.Requireable<string>;
|
|
9
|
+
};
|
|
10
|
+
export declare const PTLoader: PropTypes.Requireable<string | PropTypes.ReactElementLike>;
|
|
11
|
+
export declare const BaseSelectComponentPropTypes: {
|
|
12
|
+
children: PropTypes.Requireable<(...args: any[]) => any>;
|
|
13
|
+
options: PropTypes.Validator<PropTypes.InferProps<{
|
|
14
|
+
label: PropTypes.Validator<string>;
|
|
15
|
+
value: PropTypes.Validator<string | number>;
|
|
16
|
+
selected: PropTypes.Requireable<boolean>;
|
|
17
|
+
}>[]>;
|
|
18
|
+
placeholder: PropTypes.Requireable<PropTypes.InferProps<{
|
|
19
|
+
label: PropTypes.Validator<string>;
|
|
20
|
+
value: PropTypes.Validator<string | number>;
|
|
21
|
+
}>>;
|
|
22
|
+
value: PropTypes.Requireable<string>;
|
|
23
|
+
name: PropTypes.Validator<string>;
|
|
24
|
+
};
|
|
25
|
+
export declare type SelectPlaceholder = Option;
|
|
26
|
+
declare type BaseSelectChildrenComponentProps = Omit<BaseSelectComponentProps, 'children'>;
|
|
27
|
+
declare type Option = {
|
|
28
|
+
label: string;
|
|
29
|
+
value: string | number;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export interface BaseSelectComponentProps {
|
|
33
|
+
children?: (props: BaseSelectChildrenComponentProps) => ReactNode;
|
|
34
|
+
options: Option[];
|
|
35
|
+
placeholder?: Option;
|
|
36
|
+
value?: string;
|
|
37
|
+
className?: string;
|
|
38
|
+
required?: boolean;
|
|
39
|
+
name: string;
|
|
40
|
+
onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
41
|
+
}
|
|
42
|
+
export declare const BaseInputComponentPropTypes: {
|
|
43
|
+
children: PropTypes.Requireable<(...args: any[]) => any>;
|
|
44
|
+
name: PropTypes.Validator<string>;
|
|
45
|
+
type: PropTypes.Validator<BaseInputType>;
|
|
46
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
47
|
+
placeholder: PropTypes.Requireable<string>;
|
|
48
|
+
};
|
|
49
|
+
declare type BaseInputChildrenComponentProps = Omit<BaseInputComponentProps, 'children'> & {
|
|
50
|
+
handleChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
51
|
+
parentRef: ForwardedRef<any>;
|
|
52
|
+
};
|
|
53
|
+
export interface BaseInputComponentProps {
|
|
54
|
+
ref?: () => RefObject<any>;
|
|
55
|
+
children?: (props: BaseInputChildrenComponentProps) => ReactNode;
|
|
56
|
+
name: string;
|
|
57
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
}
|
|
60
|
+
export declare type LineItemType = 'gift_cards' | 'payment_methods' | 'promotions' | 'shipments' | 'skus' | 'bundles' | 'adjustments';
|
|
61
|
+
export declare type GiftCardInputName = 'balanceCents' | 'balanceMaxCents' | 'singleUse' | 'rechargeable' | 'imageUrl' | 'expiresAt' | 'referenceOrigin' | 'email' | 'firstName' | 'lastName' | 'reference';
|
|
62
|
+
export declare 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';
|
|
63
|
+
export declare type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code';
|
|
64
|
+
export declare type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code';
|
|
65
|
+
export declare type BaseInputType = 'checkbox' | 'date' | 'email' | 'number' | 'tel' | 'text' | 'textarea';
|
|
66
|
+
export declare type LoaderType = string | ReactNode;
|
|
67
|
+
export declare const BMObject: PropTypes.Requireable<{
|
|
68
|
+
[x: string]: string | null | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
export declare type BaseMetadataObject = {
|
|
71
|
+
[key: string]: string | undefined | null;
|
|
72
|
+
};
|
|
73
|
+
export declare type TimeFormat = 'days' | 'hours';
|
|
74
|
+
export declare type BaseComponent = InferProps<typeof BC>;
|
|
75
|
+
export interface BaseAction<A = string, P = Record<string, any>> {
|
|
76
|
+
type: A;
|
|
77
|
+
payload: P;
|
|
78
|
+
}
|
|
79
|
+
export interface BaseState {
|
|
80
|
+
[key: string]: any;
|
|
81
|
+
errors?: BaseError[];
|
|
82
|
+
}
|
|
83
|
+
export declare type BaseActionType<T = string> = T[];
|
|
84
|
+
export interface BFSetStateContainer<T> {
|
|
85
|
+
<P extends T>(param: P): void;
|
|
86
|
+
}
|
|
87
|
+
export interface BaseReducer {
|
|
88
|
+
<S extends BaseState, A extends BaseAction, T extends BaseActionType>(state: S, action: A, type: T): S;
|
|
89
|
+
}
|
|
90
|
+
export interface BaseUnsetState<A> {
|
|
91
|
+
(dispatch: Dispatch<A>): void;
|
|
92
|
+
}
|
|
93
|
+
export interface BaseMetadata {
|
|
94
|
+
[key: string]: string | undefined | null;
|
|
95
|
+
}
|
|
96
|
+
export declare type BaseFormatPrice = 'formatted' | 'cents' | 'float';
|
|
97
|
+
export declare const baseOrderPricePropTypes: {
|
|
98
|
+
id: PropTypes.Requireable<string>;
|
|
99
|
+
className: PropTypes.Requireable<string>;
|
|
100
|
+
style: PropTypes.Requireable<object>;
|
|
101
|
+
name: PropTypes.Requireable<string>;
|
|
102
|
+
base: PropTypes.Validator<string>;
|
|
103
|
+
type: PropTypes.Validator<string>;
|
|
104
|
+
children: PropTypes.Requireable<(...args: any[]) => any>;
|
|
105
|
+
format: PropTypes.Requireable<BaseFormatPrice>;
|
|
106
|
+
};
|
|
107
|
+
export declare const baseOrderComponentPricePropTypes: {
|
|
108
|
+
id: PropTypes.Requireable<string>;
|
|
109
|
+
className: PropTypes.Requireable<string>;
|
|
110
|
+
style: PropTypes.Requireable<object>;
|
|
111
|
+
name: PropTypes.Requireable<string>;
|
|
112
|
+
children: PropTypes.Requireable<(...args: any[]) => any>;
|
|
113
|
+
format: PropTypes.Requireable<BaseFormatPrice>;
|
|
114
|
+
};
|
|
115
|
+
export declare type BasePriceType = 'total' | 'option' | 'unit';
|
|
116
|
+
export declare type BaseSelectorType = 'select' | 'radio';
|
|
117
|
+
export declare type BaseAmountComponentChildren = Omit<BaseAmountComponent, 'children'>;
|
|
118
|
+
export declare type BaseAmountComponent = {
|
|
119
|
+
children?: (props: BaseAmountComponentChildren) => ReactNode;
|
|
120
|
+
format?: BaseFormatPrice;
|
|
121
|
+
price?: string;
|
|
122
|
+
priceCents?: number;
|
|
123
|
+
labelFree?: string;
|
|
124
|
+
} & JSX.IntrinsicElements['span'];
|
|
125
|
+
export interface FunctionChildren<P = Record<string, any>> {
|
|
126
|
+
(props: P): ReactNode;
|
|
127
|
+
}
|
|
128
|
+
export declare type ExcludeTag<T extends keyof JSX.IntrinsicElements> = Exclude<keyof JSX.IntrinsicElements, T>;
|
|
129
|
+
export declare type ExtractTag<T extends keyof JSX.IntrinsicElements> = Extract<keyof JSX.IntrinsicElements, T>;
|
|
130
|
+
export declare type ConditionalElement<E> = ({
|
|
131
|
+
attribute: Extract<keyof E, 'image_url'>;
|
|
132
|
+
tagElement: ExtractTag<'img'>;
|
|
133
|
+
} & JSX.IntrinsicElements['img']) | ({
|
|
134
|
+
attribute: Exclude<keyof E, 'image_url'>;
|
|
135
|
+
tagElement: ExcludeTag<'img'>;
|
|
136
|
+
} & JSX.IntrinsicElements[ExcludeTag<'img'>]);
|
|
137
|
+
export {};
|
package/lib/utils/PropsType.d.ts
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
|
-
import PropTypes from'prop-types';
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
3
|
+
declare type Defined<T> = T extends undefined ? never : T;
|
|
4
|
+
/**
|
|
5
|
+
* Get the type that represents the props with the defaultProps included.
|
|
6
|
+
*
|
|
7
|
+
* Alternatively, we could have done something like this:
|
|
8
|
+
* ```
|
|
9
|
+
* export type WithDefaultProps<P, DP extends Partial<P>> = Omit<P, keyof DP> &
|
|
10
|
+
* Required<Pick<P, Extract<keyof DP, keyof P>>>;
|
|
11
|
+
* ```
|
|
12
|
+
* But there were usages of `null` in `defaultProps` that would need to be changed to `undefined`
|
|
13
|
+
* to meet the `DP extends Partial<P>` constraint.
|
|
14
|
+
* So, instead we take the union type in cases when a property in defaultProps does not extend
|
|
15
|
+
* the corresponding property in the Props declaration.
|
|
16
|
+
*/
|
|
17
|
+
declare type WithDefaultProps<P, DP> = Omit<P, keyof DP> & {
|
|
18
|
+
[K in Extract<keyof DP, keyof P>]: DP[K] extends Defined<P[K]> ? Defined<P[K]> : Defined<P[K]> | DP[K];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Get the props type from propTypes and defaultProps.
|
|
22
|
+
*
|
|
23
|
+
* Usage:
|
|
24
|
+
* ```
|
|
25
|
+
* // Without defaultProps
|
|
26
|
+
* type Props = PropsType<typeof propTypes>;
|
|
27
|
+
*
|
|
28
|
+
* // With defaultProps
|
|
29
|
+
* type Props = PropsType<typeof propTypes, typeof defaultProps>;
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare type PropsType<PT, DP = {}> = WithDefaultProps<PropTypes.InferProps<PT>, DP>;
|
|
33
|
+
export {};
|
|
@@ -1 +1,28 @@
|
|
|
1
|
-
import{BaseError}from'../typings/errors';
|
|
1
|
+
import { BaseError } from '../typings/errors';
|
|
2
|
+
import { AddressCreate } from '@commercelayer/sdk';
|
|
3
|
+
declare type BillingAddressController = (params: {
|
|
4
|
+
billing_address?: AddressCreate;
|
|
5
|
+
billingAddressId?: string;
|
|
6
|
+
errors?: BaseError[];
|
|
7
|
+
requiresBillingInfo?: boolean;
|
|
8
|
+
}) => boolean;
|
|
9
|
+
export declare const billingAddressController: BillingAddressController;
|
|
10
|
+
declare type ShippingAddressController = (params: {
|
|
11
|
+
billingDisable: boolean;
|
|
12
|
+
errors?: BaseError[];
|
|
13
|
+
shipToDifferentAddress?: boolean;
|
|
14
|
+
shipping_address?: AddressCreate;
|
|
15
|
+
shippingAddressId?: string;
|
|
16
|
+
}) => boolean;
|
|
17
|
+
export declare const shippingAddressController: ShippingAddressController;
|
|
18
|
+
declare type CountryLockController = (params: {
|
|
19
|
+
addresses?: Record<string, any>[];
|
|
20
|
+
billing_address?: Record<string, any>;
|
|
21
|
+
billingAddressId?: string;
|
|
22
|
+
countryCodeLock?: string;
|
|
23
|
+
shipToDifferentAddress?: boolean;
|
|
24
|
+
shipping_address?: Record<string, any>;
|
|
25
|
+
shippingAddressId?: string;
|
|
26
|
+
}) => boolean;
|
|
27
|
+
export declare const countryLockController: CountryLockController;
|
|
28
|
+
export {};
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export default function getBrowserInfo():{
|
|
1
|
+
export default function getBrowserInfo(): {
|
|
2
|
+
screenWidth: string | number;
|
|
3
|
+
screenHeight: string | number;
|
|
4
|
+
colorDepth: string | number;
|
|
5
|
+
userAgent: string;
|
|
6
|
+
timeZoneOffset: number;
|
|
7
|
+
language: string;
|
|
8
|
+
javaEnabled: boolean;
|
|
9
|
+
};
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
import{ResourceIncluded}from'../reducers/OrderReducer';
|
|
1
|
+
import { ResourceIncluded } from '../reducers/OrderReducer';
|
|
2
|
+
import type { Order } from '@commercelayer/sdk';
|
|
3
|
+
declare type Params = {
|
|
4
|
+
order: Order;
|
|
5
|
+
resourceInclude: ResourceIncluded[];
|
|
6
|
+
};
|
|
7
|
+
export default function checkIncludeResources({ order, resourceInclude, }: Params): boolean;
|
|
8
|
+
export {};
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
import{ReactNode}from'react';
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Requireable } from 'prop-types';
|
|
3
|
+
export interface CheckChildrenTypes {
|
|
4
|
+
(props: {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}, propName: string, componentName: string, location: string, propFullName: string): Error | null;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: Requireable<ReactNode | (() => ReactNode)>;
|
|
9
|
+
export default _default;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
declare type Item=Record<string,any>;
|
|
1
|
+
declare type Item = Record<string, any>;
|
|
2
|
+
declare type TArgs<A, B> = {
|
|
3
|
+
attributes: A;
|
|
4
|
+
object: B;
|
|
5
|
+
};
|
|
6
|
+
export default function compareObjAttribute<A extends Item, B extends Item>({ attributes, object, }: TArgs<A, B>): Item;
|
|
7
|
+
export {};
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export declare function getCountries():
|
|
1
|
+
export declare function getCountries(): {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}[];
|
|
5
|
+
export declare function getStateOfCountry(country_code: string): {
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}[];
|
|
9
|
+
export declare function isValidState(state_code: string, country_code: string): boolean;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
import{BaseError}from'../typings/errors';
|
|
1
|
+
import { BaseError } from '../typings/errors';
|
|
2
|
+
export interface CustomMessages {
|
|
3
|
+
(messages: BaseError[], v: BaseError): {
|
|
4
|
+
message?: string;
|
|
5
|
+
} | null;
|
|
6
|
+
}
|
|
7
|
+
declare const customMessages: CustomMessages;
|
|
8
|
+
export default customMessages;
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export declare function saveToWallet():
|
|
1
|
+
export declare function saveToWallet(): boolean;
|
|
2
|
+
export declare function saveBillingAddress(): boolean;
|
|
3
|
+
export declare function saveShippingAddress(): boolean;
|
package/lib/utils/getAmount.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export interface GetAmountInterface<T=any>
|
|
1
|
+
export interface GetAmountInterface<T = any> {
|
|
2
|
+
(base: string, type: string, format: string, obj: Record<string, any>): T extends number ? number : string;
|
|
3
|
+
}
|
|
4
|
+
export default function getAmount<T = string>(args: {
|
|
5
|
+
base: string;
|
|
6
|
+
type: string;
|
|
7
|
+
format: string;
|
|
8
|
+
obj: Record<string, any>;
|
|
9
|
+
}): T extends number ? number : string;
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
import{IconBrand}from'../context/PaymentSourceContext';
|
|
1
|
+
import { IconBrand } from '../context/PaymentSourceContext';
|
|
2
|
+
import { PaymentResource } from '../reducers/PaymentMethodReducer';
|
|
3
|
+
import { CustomerPaymentSource } from '@commercelayer/sdk';
|
|
4
|
+
declare type CardDetails = {
|
|
5
|
+
brand: IconBrand | string;
|
|
6
|
+
last4: string;
|
|
7
|
+
exp_month: number | string;
|
|
8
|
+
exp_year: number | string;
|
|
9
|
+
};
|
|
10
|
+
declare type Args = {
|
|
11
|
+
paymentType: PaymentResource;
|
|
12
|
+
customerPayment: Partial<CustomerPaymentSource>;
|
|
13
|
+
};
|
|
14
|
+
export default function getCardDetails({ paymentType, customerPayment, }: Args): CardDetails;
|
|
15
|
+
export {};
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
import{Items}from'../reducers/ItemReducer';
|
|
1
|
+
import { Items } from '../reducers/ItemReducer';
|
|
2
|
+
export interface GetCurrentItemKey {
|
|
3
|
+
(item: Items): string;
|
|
4
|
+
}
|
|
5
|
+
declare const getCurrentItemKey: GetCurrentItemKey;
|
|
6
|
+
export default getCurrentItemKey;
|
package/lib/utils/getErrors.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
import{BaseError,ResourceErrorType}from'../typings/errors';
|
|
1
|
+
import { BaseError, ResourceErrorType } from '../typings/errors';
|
|
2
|
+
import { Dispatch } from 'react';
|
|
3
|
+
export default function getErrors(error: any, resource: ResourceErrorType, field?: string): BaseError[];
|
|
4
|
+
declare type SetErrorsArgs<D> = {
|
|
5
|
+
currentErrors?: BaseError[];
|
|
6
|
+
newErrors?: BaseError[];
|
|
7
|
+
dispatch?: D;
|
|
8
|
+
filterBy?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function setErrors<D extends Dispatch<any>>({ currentErrors, newErrors, dispatch, filterBy, }: SetErrorsArgs<D>): BaseError[] | void;
|
|
11
|
+
export {};
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
import{LineItem}from'@commercelayer/sdk';
|
|
1
|
+
import { LineItem } from '@commercelayer/sdk';
|
|
2
|
+
import { LineItemType } from '../typings/index';
|
|
3
|
+
export interface GetLineItemsCountInterface {
|
|
4
|
+
(args: {
|
|
5
|
+
lineItems: LineItem[];
|
|
6
|
+
quantity?: number;
|
|
7
|
+
typeAccepted?: TypeAccepted[];
|
|
8
|
+
}): number;
|
|
9
|
+
}
|
|
10
|
+
export declare type TypeAccepted = Extract<LineItemType, 'skus' | 'gift_cards' | 'bundles' | 'adjustments'>;
|
|
11
|
+
declare const getLineItemsCount: GetLineItemsCountInterface;
|
|
12
|
+
export default getLineItemsCount;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import{LoaderType}from'../typings/index';
|
|
2
|
+
import { LoaderType } from '../typings/index';
|
|
3
|
+
export default function getLoaderComponent(Loader: LoaderType): JSX.Element;
|
package/lib/utils/getPrices.d.ts
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import{Price}from'@commercelayer/sdk';
|
|
1
|
+
import { Price } from '@commercelayer/sdk';
|
|
2
|
+
import { Prices } from '../reducers/PriceReducer';
|
|
3
|
+
import { Items } from '../reducers/ItemReducer';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { PTemplateProps } from '../components/utils/PriceTemplate';
|
|
6
|
+
export interface GetPriceByCode {
|
|
7
|
+
(skuPrices: Price[], code: string): Price | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare const getPriceByCode: GetPriceByCode;
|
|
10
|
+
export interface GetPricesComponent {
|
|
11
|
+
(skuPrices: Price[], props: PTemplateProps): ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare const getPricesComponent: GetPricesComponent;
|
|
14
|
+
export interface GetPrices {
|
|
15
|
+
(prices: Price[] | Items): Prices;
|
|
16
|
+
}
|
|
17
|
+
export default function getPrices<P extends Price>(prices: P[]): Record<string, any>;
|
package/lib/utils/getSdk.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import Sdk from'@commercelayer/sdk';
|
|
1
|
+
import Sdk from '@commercelayer/sdk';
|
|
2
|
+
import { CommerceLayerConfig } from '../context/CommerceLayerContext';
|
|
3
|
+
export default function getSdk({ endpoint, accessToken, }: CommerceLayerConfig): ReturnType<typeof Sdk>;
|
package/lib/utils/getSkus.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{Sku}from'@commercelayer/sdk';
|
|
1
|
+
import { Sku } from '@commercelayer/sdk';
|
|
2
|
+
declare const getSkus: (skus: Sku[], sortBy: string[]) => Record<string, any>;
|
|
3
|
+
export default getSkus;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useExternalScript(url:string):boolean;
|
|
1
|
+
export default function useExternalScript(url: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function isEmptyStates(countryCode:string):boolean;
|
|
1
|
+
export default function isEmptyStates(countryCode: string): boolean;
|
package/lib/utils/isJSON.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function isJSON(str:string):boolean;
|
|
1
|
+
export default function isJSON(str: string): boolean;
|
package/lib/utils/jwt.d.ts
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
-
declare type JWT=
|
|
1
|
+
declare type JWT = {
|
|
2
|
+
application: {
|
|
3
|
+
id: string;
|
|
4
|
+
kind: 'sales_channel' | 'integration';
|
|
5
|
+
public: boolean;
|
|
6
|
+
};
|
|
7
|
+
exp: number;
|
|
8
|
+
market: {
|
|
9
|
+
id: string[];
|
|
10
|
+
price_list_id: string;
|
|
11
|
+
stock_location_ids: string[];
|
|
12
|
+
geocoder_id: null | string;
|
|
13
|
+
allows_external_prices: boolean;
|
|
14
|
+
};
|
|
15
|
+
organization: {
|
|
16
|
+
id: string;
|
|
17
|
+
slug: string;
|
|
18
|
+
};
|
|
19
|
+
owner: {
|
|
20
|
+
id: 'gOqzZhZrmQ';
|
|
21
|
+
type: 'Customer';
|
|
22
|
+
};
|
|
23
|
+
rand: number;
|
|
24
|
+
test: boolean;
|
|
25
|
+
};
|
|
26
|
+
export default function jwt(accessToken: string): JWT;
|
|
27
|
+
export {};
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
export interface GetLocalOrder
|
|
1
|
+
export interface GetLocalOrder {
|
|
2
|
+
(key: string): string | null;
|
|
3
|
+
}
|
|
4
|
+
export declare const getLocalOrder: GetLocalOrder;
|
|
5
|
+
export interface SetLocalOrder {
|
|
6
|
+
(key: string, value: string): void;
|
|
7
|
+
}
|
|
8
|
+
export declare const setLocalOrder: SetLocalOrder;
|
|
9
|
+
export interface DeleteLocalOrder {
|
|
10
|
+
(key: string): void;
|
|
11
|
+
}
|
|
12
|
+
export declare const deleteLocalOrder: DeleteLocalOrder;
|
|
13
|
+
export declare const getSavePaymentSourceToCustomerWallet: () => boolean;
|
|
14
|
+
export declare const getSaveBillingAddressToAddressBook: () => boolean;
|
|
15
|
+
export declare const getSaveShippingAddressToAddressBook: () => boolean;
|
|
16
|
+
export declare type CustomerOrderParams = '_save_payment_source_to_customer_wallet' | '_save_billing_address_to_customer_address_book' | '_save_shipping_address_to_customer_address_book';
|
|
17
|
+
export declare function setCustomerOrderParam<T extends CustomerOrderParams>(key: T, value: string): void;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
declare type ReturnObj=
|
|
1
|
+
declare type ReturnObj = {
|
|
2
|
+
organization: string;
|
|
3
|
+
domain: string;
|
|
4
|
+
};
|
|
5
|
+
export default function getOrganizationSlug<E extends string>(endpoint: E): ReturnObj;
|
|
6
|
+
export {};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{PaypalConfig}from'../components/PaypalPayment';
|
|
1
|
+
import { PaypalConfig } from '../components/PaypalPayment';
|
|
2
|
+
import { PaymentResource, PaymentMethodConfig } from '../reducers/PaymentMethodReducer';
|
|
3
|
+
export default function getPaypalConfig(paymentResource: PaymentResource, config: PaymentMethodConfig): Pick<PaypalConfig, 'return_url' | 'cancel_url'> | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defaultImgUrl="https://data.commercelayer.app/assets/images/placeholders/img_placeholder.svg",defaultGiftCardImgUrl="https://data.commercelayer.app/assets/images/placeholders/gift_placeholder.svg";
|
package/lib/utils/promisify.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function promisify(cb:any,params?:any):Promise<any>;
|
|
1
|
+
export default function promisify(cb: any, params?: any): Promise<any>;
|
package/lib/utils/shipments.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{LineItem,Shipment}from'@commercelayer/sdk';
|
|
1
|
+
import { LineItem, Shipment } from '@commercelayer/sdk';
|
|
2
|
+
export declare function shipmentsFilled(shipments: Shipment[]): boolean;
|
|
3
|
+
export declare function isDoNotShip(lineItems?: LineItem[]): boolean;
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
import{BaseState}from'../typings/index';
|
|
1
|
+
import { BaseState } from '../typings/index';
|
|
2
|
+
import { ResourceErrorType, BaseError } from '../typings/errors';
|
|
3
|
+
import { AddressField } from '../reducers/AddressReducer';
|
|
4
|
+
import { AddressCreate } from '@commercelayer/sdk';
|
|
5
|
+
import { AddressInputName } from '../typings/index';
|
|
6
|
+
export interface ValidateFormFields {
|
|
7
|
+
<R extends string[]>(fields: HTMLFormControlsCollection, required: R, resourceType: ResourceErrorType): {
|
|
8
|
+
errors: BaseError[];
|
|
9
|
+
values: BaseState;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface ValidateValue {
|
|
13
|
+
<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>;
|
|
14
|
+
}
|
|
15
|
+
export declare const validateValue: ValidateValue;
|
|
16
|
+
declare const validateFormFields: ValidateFormFields;
|
|
17
|
+
export interface FieldsExist {
|
|
18
|
+
(address: AddressCreate, schema?: AddressField[]): boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const fieldsExist: FieldsExist;
|
|
21
|
+
export declare function businessMandatoryField(fieldName: AddressInputName, isBusiness?: boolean): boolean;
|
|
22
|
+
export default validateFormFields;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/react-components",
|
|
3
|
-
"version": "3.13.0-beta.
|
|
3
|
+
"version": "3.13.0-beta.4",
|
|
4
4
|
"description": "The Official Commerce Layer React Components",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"lint": "eslint src",
|
|
22
22
|
"build": "tsc -b tsconfig.prod.json --verbose && pnpm postbuild",
|
|
23
23
|
"build:dev": "tsc -b tsconfig.prod.json --verbose && tsc-alias -p tsconfig.prod.json",
|
|
24
|
-
"postbuild": "tsc-alias -p tsconfig.prod.json && minimize-js lib -w -s
|
|
24
|
+
"postbuild": "tsc-alias -p tsconfig.prod.json && minimize-js lib -w -s",
|
|
25
25
|
"start": "NODE_OPTIONS='--inspect' next dev"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|