@commercelayer/react-components 4.1.0-beta.1 → 4.1.0-beta.3
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/MetadataInput.d.ts +1 -1
- package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +1 -1
- package/lib/cjs/components/addresses/AddressField.d.ts +2 -2
- package/lib/cjs/components/addresses/AddressInput.d.ts +2 -2
- package/lib/cjs/components/addresses/AddressInput.js +1 -1
- package/lib/cjs/components/addresses/AddressStateSelector.d.ts +1 -1
- package/lib/cjs/components/addresses/BillingAddressContainer.d.ts +1 -1
- package/lib/cjs/components/addresses/BillingAddressForm.d.ts +1 -1
- package/lib/cjs/components/addresses/ShippingAddressForm.js +1 -1
- package/lib/cjs/components/customers/CustomerField.d.ts +3 -3
- package/lib/cjs/components/customers/CustomerInput.d.ts +1 -1
- package/lib/cjs/components/customers/SaveCustomerButton.js +1 -1
- package/lib/cjs/components/errors/Errors.d.ts +5 -0
- package/lib/cjs/components/errors/Errors.js +1 -0
- package/lib/cjs/components/gift_cards/GiftCard.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -1
- package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +1 -1
- package/lib/cjs/components/line_items/LineItem.js +1 -1
- package/lib/cjs/components/line_items/LineItemAmount.d.ts +1 -1
- package/lib/cjs/components/line_items/LineItemField.d.ts +3 -3
- package/lib/cjs/components/line_items/LineItemImage.d.ts +1 -1
- package/lib/cjs/components/line_items/LineItemOptions.d.ts +1 -1
- package/lib/cjs/components/line_items/LineItemQuantity.d.ts +1 -1
- package/lib/cjs/components/orders/AddToCartButton.d.ts +4 -4
- package/lib/cjs/components/orders/OrderList.d.ts +24 -7
- package/lib/cjs/components/orders/OrderList.js +1 -1
- package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +44 -0
- package/lib/cjs/components/orders/OrderListPaginationButtons.js +1 -0
- package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +29 -0
- package/lib/cjs/components/orders/OrderListPaginationInfo.js +1 -0
- package/lib/cjs/components/orders/OrderListRow.d.ts +3 -0
- package/lib/cjs/components/orders/OrderListRow.js +1 -1
- package/lib/cjs/components/orders/OrderNumber.d.ts +1 -1
- package/lib/cjs/components/parcels/ParcelField.d.ts +3 -3
- package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +3 -3
- package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +2 -2
- package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.d.ts +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethodsContainer.js +1 -1
- package/lib/cjs/components/payment_source/AdyenPayment.d.ts +2 -2
- package/lib/cjs/components/payment_source/BraintreePayment.d.ts +3 -3
- package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +2 -2
- package/lib/cjs/components/payment_source/KlarnaPayment.d.ts +1 -1
- package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +1 -1
- package/lib/cjs/components/payment_source/PaymentSourceEditButton.d.ts +1 -1
- package/lib/cjs/components/payment_source/PaypalPayment.d.ts +2 -2
- package/lib/cjs/components/payment_source/StripePayment.d.ts +2 -2
- package/lib/cjs/components/payment_source/WireTransferPayment.d.ts +2 -2
- package/lib/cjs/components/shipments/ShipmentField.d.ts +2 -2
- package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +1 -1
- package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +1 -1
- package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +3 -3
- package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +2 -2
- package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +3 -3
- package/lib/cjs/components/skus/SkuField.d.ts +3 -3
- package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +3 -3
- package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +2 -2
- package/lib/cjs/components/utils/BaseField.d.ts +1 -1
- package/lib/cjs/components/utils/BaseInput.d.ts +2 -2
- package/lib/cjs/components/utils/BaseOrderPrice.d.ts +1 -1
- package/lib/cjs/components/utils/BaseSelect.d.ts +1 -1
- package/lib/cjs/components/utils/GenericFieldComponent.d.ts +3 -3
- package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +4 -4
- package/lib/cjs/components/utils/PriceTemplate.d.ts +1 -1
- package/lib/cjs/components/utils/getAllErrors.d.ts +1 -1
- package/lib/cjs/context/AddressContext.d.ts +1 -1
- package/lib/cjs/context/BillingAddressContext.d.ts +1 -1
- package/lib/cjs/context/BillingAddressFormContext.d.ts +1 -1
- package/lib/cjs/context/CouponAndGiftCardFormContext.d.ts +1 -1
- package/lib/cjs/context/CustomerAddressFormContext.d.ts +1 -1
- package/lib/cjs/context/CustomerContext.d.ts +1 -1
- package/lib/cjs/context/ExternalFunctionContext.d.ts +1 -1
- package/lib/cjs/context/LineItemChildrenContext.d.ts +1 -1
- package/lib/cjs/context/OrderListChildrenContext.d.ts +1 -1
- package/lib/cjs/context/OrderListPaginationContext.d.ts +19 -0
- package/lib/cjs/context/OrderListPaginationContext.js +1 -0
- package/lib/cjs/context/PaymentMethodContext.d.ts +1 -1
- package/lib/cjs/context/PaymentSourceContext.d.ts +2 -2
- package/lib/cjs/context/PlaceOrderContext.d.ts +1 -1
- package/lib/cjs/context/ShipmentContext.d.ts +1 -1
- package/lib/cjs/context/ShippingAddressContext.d.ts +1 -1
- package/lib/cjs/context/SkuChildrenContext.d.ts +1 -1
- package/lib/cjs/context/SkuContext.d.ts +1 -1
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/reducers/AddressReducer.d.ts +10 -10
- package/lib/cjs/reducers/AvailabilityReducer.d.ts +4 -4
- package/lib/cjs/reducers/BillingAddressReducer.d.ts +4 -4
- package/lib/cjs/reducers/CustomerReducer.d.ts +6 -6
- package/lib/cjs/reducers/GiftCardReducer.d.ts +3 -3
- package/lib/cjs/reducers/GiftCardReducer.js +1 -1
- package/lib/cjs/reducers/LineItemReducer.d.ts +4 -4
- package/lib/cjs/reducers/OrderReducer.d.ts +19 -19
- package/lib/cjs/reducers/OrderReducer.js +1 -1
- package/lib/cjs/reducers/PaymentMethodReducer.d.ts +17 -17
- package/lib/cjs/reducers/PlaceOrderReducer.d.ts +5 -5
- package/lib/cjs/reducers/PriceReducer.d.ts +3 -3
- package/lib/cjs/reducers/ShipmentReducer.d.ts +6 -6
- package/lib/cjs/reducers/ShippingAddressReducer.d.ts +4 -4
- package/lib/cjs/reducers/SkuListsReducer.d.ts +3 -3
- package/lib/cjs/reducers/SkuReducer.d.ts +3 -3
- package/lib/cjs/typings/errors.d.ts +3 -3
- package/lib/cjs/typings/index.d.ts +24 -24
- package/lib/cjs/utils/PropsType.d.ts +4 -4
- package/lib/cjs/utils/addressesManager.d.ts +3 -3
- package/lib/cjs/utils/addressesManager.js +1 -1
- package/lib/cjs/utils/checkIncludeResource.d.ts +1 -1
- package/lib/cjs/utils/compareObjAttribute.d.ts +2 -2
- package/lib/cjs/utils/customMessages.d.ts +1 -1
- package/lib/cjs/utils/filterChildren.d.ts +8 -0
- package/lib/cjs/utils/filterChildren.js +1 -0
- package/lib/cjs/utils/getCardDetails.d.ts +2 -2
- package/lib/cjs/utils/getCartLink.d.ts +1 -1
- package/lib/cjs/utils/getErrors.d.ts +1 -1
- package/lib/cjs/utils/getLineItemsCount.d.ts +1 -1
- package/lib/cjs/utils/hooks/useCustomContext.js +1 -1
- package/lib/cjs/utils/jwt.d.ts +1 -1
- package/lib/cjs/utils/localStorage.d.ts +1 -1
- package/lib/cjs/utils/omit.d.ts +1 -0
- package/lib/cjs/utils/omit.js +1 -0
- package/lib/cjs/utils/validateFormFields.d.ts +6 -12
- package/lib/cjs/utils/validateFormFields.js +1 -1
- package/lib/esm/components/MetadataInput.d.ts +1 -1
- package/lib/esm/components/addresses/AddressCountrySelector.d.ts +1 -1
- package/lib/esm/components/addresses/AddressField.d.ts +2 -2
- package/lib/esm/components/addresses/AddressInput.d.ts +2 -2
- package/lib/esm/components/addresses/AddressInput.js +1 -1
- package/lib/esm/components/addresses/AddressStateSelector.d.ts +1 -1
- package/lib/esm/components/addresses/BillingAddressContainer.d.ts +1 -1
- package/lib/esm/components/addresses/BillingAddressForm.d.ts +1 -1
- package/lib/esm/components/addresses/ShippingAddressForm.js +1 -1
- package/lib/esm/components/customers/CustomerField.d.ts +3 -3
- package/lib/esm/components/customers/CustomerInput.d.ts +1 -1
- package/lib/esm/components/customers/SaveCustomerButton.js +1 -1
- package/lib/esm/components/errors/Errors.d.ts +5 -0
- package/lib/esm/components/errors/Errors.js +1 -0
- package/lib/esm/components/gift_cards/GiftCard.js +1 -1
- package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -1
- package/lib/esm/components/gift_cards/GiftCardInput.d.ts +1 -1
- package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -1
- package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -1
- package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +1 -1
- package/lib/esm/components/line_items/LineItem.js +1 -1
- package/lib/esm/components/line_items/LineItemAmount.d.ts +1 -1
- package/lib/esm/components/line_items/LineItemField.d.ts +3 -3
- package/lib/esm/components/line_items/LineItemImage.d.ts +1 -1
- package/lib/esm/components/line_items/LineItemOptions.d.ts +1 -1
- package/lib/esm/components/line_items/LineItemQuantity.d.ts +1 -1
- package/lib/esm/components/orders/AddToCartButton.d.ts +4 -4
- package/lib/esm/components/orders/OrderList.d.ts +24 -7
- package/lib/esm/components/orders/OrderList.js +1 -1
- package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +44 -0
- package/lib/esm/components/orders/OrderListPaginationButtons.js +1 -0
- package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +29 -0
- package/lib/esm/components/orders/OrderListPaginationInfo.js +1 -0
- package/lib/esm/components/orders/OrderListRow.d.ts +3 -0
- package/lib/esm/components/orders/OrderListRow.js +1 -1
- package/lib/esm/components/orders/OrderNumber.d.ts +1 -1
- package/lib/esm/components/parcels/ParcelField.d.ts +3 -3
- package/lib/esm/components/parcels/ParcelLineItemField.d.ts +3 -3
- package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +2 -2
- package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/StripeGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +1 -1
- package/lib/esm/components/payment_methods/PaymentMethod.d.ts +1 -1
- package/lib/esm/components/payment_methods/PaymentMethodRadioButton.d.ts +1 -1
- package/lib/esm/components/payment_methods/PaymentMethodsContainer.js +1 -1
- package/lib/esm/components/payment_source/AdyenPayment.d.ts +2 -2
- package/lib/esm/components/payment_source/BraintreePayment.d.ts +3 -3
- package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +2 -2
- package/lib/esm/components/payment_source/KlarnaPayment.d.ts +1 -1
- package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +1 -1
- package/lib/esm/components/payment_source/PaymentSourceEditButton.d.ts +1 -1
- package/lib/esm/components/payment_source/PaypalPayment.d.ts +2 -2
- package/lib/esm/components/payment_source/StripePayment.d.ts +2 -2
- package/lib/esm/components/payment_source/WireTransferPayment.d.ts +2 -2
- package/lib/esm/components/shipments/ShipmentField.d.ts +2 -2
- package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +1 -1
- package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +1 -1
- package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +3 -3
- package/lib/esm/components/skus/AvailabilityTemplate.d.ts +2 -2
- package/lib/esm/components/skus/DeliveryLeadTime.d.ts +3 -3
- package/lib/esm/components/skus/SkuField.d.ts +3 -3
- package/lib/esm/components/stock_transfers/StockTransferField.d.ts +3 -3
- package/lib/esm/components/utils/AddressCardsTemplate.d.ts +2 -2
- package/lib/esm/components/utils/BaseField.d.ts +1 -1
- package/lib/esm/components/utils/BaseInput.d.ts +2 -2
- package/lib/esm/components/utils/BaseOrderPrice.d.ts +1 -1
- package/lib/esm/components/utils/BaseSelect.d.ts +1 -1
- package/lib/esm/components/utils/GenericFieldComponent.d.ts +3 -3
- package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +4 -4
- package/lib/esm/components/utils/PriceTemplate.d.ts +1 -1
- package/lib/esm/components/utils/getAllErrors.d.ts +1 -1
- package/lib/esm/context/AddressContext.d.ts +1 -1
- package/lib/esm/context/BillingAddressContext.d.ts +1 -1
- package/lib/esm/context/BillingAddressFormContext.d.ts +1 -1
- package/lib/esm/context/CouponAndGiftCardFormContext.d.ts +1 -1
- package/lib/esm/context/CustomerAddressFormContext.d.ts +1 -1
- package/lib/esm/context/CustomerContext.d.ts +1 -1
- package/lib/esm/context/ExternalFunctionContext.d.ts +1 -1
- package/lib/esm/context/LineItemChildrenContext.d.ts +1 -1
- package/lib/esm/context/OrderListChildrenContext.d.ts +1 -1
- package/lib/esm/context/OrderListPaginationContext.d.ts +19 -0
- package/lib/esm/context/OrderListPaginationContext.js +1 -0
- package/lib/esm/context/PaymentMethodContext.d.ts +1 -1
- package/lib/esm/context/PaymentSourceContext.d.ts +2 -2
- package/lib/esm/context/PlaceOrderContext.d.ts +1 -1
- package/lib/esm/context/ShipmentContext.d.ts +1 -1
- package/lib/esm/context/ShippingAddressContext.d.ts +1 -1
- package/lib/esm/context/SkuChildrenContext.d.ts +1 -1
- package/lib/esm/context/SkuContext.d.ts +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/reducers/AddressReducer.d.ts +10 -10
- package/lib/esm/reducers/AvailabilityReducer.d.ts +4 -4
- package/lib/esm/reducers/BillingAddressReducer.d.ts +4 -4
- package/lib/esm/reducers/CustomerReducer.d.ts +6 -6
- package/lib/esm/reducers/GiftCardReducer.d.ts +3 -3
- package/lib/esm/reducers/GiftCardReducer.js +1 -1
- package/lib/esm/reducers/LineItemReducer.d.ts +4 -4
- package/lib/esm/reducers/OrderReducer.d.ts +19 -19
- package/lib/esm/reducers/OrderReducer.js +1 -1
- package/lib/esm/reducers/PaymentMethodReducer.d.ts +17 -17
- package/lib/esm/reducers/PlaceOrderReducer.d.ts +5 -5
- package/lib/esm/reducers/PriceReducer.d.ts +3 -3
- package/lib/esm/reducers/ShipmentReducer.d.ts +6 -6
- package/lib/esm/reducers/ShippingAddressReducer.d.ts +4 -4
- package/lib/esm/reducers/SkuListsReducer.d.ts +3 -3
- package/lib/esm/reducers/SkuReducer.d.ts +3 -3
- package/lib/esm/typings/errors.d.ts +3 -3
- package/lib/esm/typings/index.d.ts +24 -24
- package/lib/esm/utils/PropsType.d.ts +4 -4
- package/lib/esm/utils/addressesManager.d.ts +3 -3
- package/lib/esm/utils/addressesManager.js +1 -1
- package/lib/esm/utils/checkIncludeResource.d.ts +1 -1
- package/lib/esm/utils/compareObjAttribute.d.ts +2 -2
- package/lib/esm/utils/filterChildren.d.ts +8 -0
- package/lib/esm/utils/filterChildren.js +1 -0
- package/lib/esm/utils/getCardDetails.d.ts +2 -2
- package/lib/esm/utils/getCartLink.d.ts +1 -1
- package/lib/esm/utils/getErrors.d.ts +1 -1
- package/lib/esm/utils/getLineItemsCount.d.ts +1 -1
- package/lib/esm/utils/hooks/useCustomContext.js +1 -1
- package/lib/esm/utils/jwt.d.ts +1 -1
- package/lib/esm/utils/localStorage.d.ts +1 -1
- package/lib/esm/utils/omit.d.ts +1 -0
- package/lib/esm/utils/omit.js +1 -0
- package/lib/esm/utils/validateFormFields.d.ts +6 -12
- package/lib/esm/utils/validateFormFields.js +1 -1
- package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +24 -17
- package/lib/cjs/components/Errors.d.ts +0 -5
- package/lib/cjs/components/Errors.js +0 -1
- package/lib/esm/components/Errors.d.ts +0 -5
- package/lib/esm/components/Errors.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useRef,useContext}from"react";import validateFormFields from"../../utils/validateFormFields";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/isEmpty";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,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BaseSelectComponentProps } from '../../typings/index';
|
|
3
|
-
|
|
3
|
+
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BaseInputComponentProps, GiftCardInputName } from '../../typings/index';
|
|
3
|
-
|
|
3
|
+
type Props = {
|
|
4
4
|
name: GiftCardInputName;
|
|
5
5
|
} & Omit<BaseInputComponentProps, 'name'> & Omit<JSX.IntrinsicElements['input'], 'children'> & Omit<JSX.IntrinsicElements['textarea'], 'children'>;
|
|
6
6
|
export declare function GiftCardInput(props: Props): JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BaseInputComponentProps } from '../../typings/index';
|
|
3
3
|
import { OrderCodeType } from '../../reducers/OrderReducer';
|
|
4
|
-
|
|
4
|
+
type Props = {
|
|
5
5
|
name?: 'gift_card_or_coupon_code';
|
|
6
6
|
type?: 'text';
|
|
7
7
|
placeholderTranslation?: (codeType: OrderCodeType) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import LineItemContext from"../../context/LineItemContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";export function LineItem(props){const{type="skus",children}=props,{lineItems}=useContext(LineItemContext),{lineItems:shipmentLineItems}=useContext(ShipmentChildrenContext),components=(shipmentLineItems&&shipmentLineItems?.length>0?shipmentLineItems:lineItems)?.filter(l=>l.item_type===type).map((lineItem,k,check)=>{if(lineItem.item_type==="bundles"&&k>0&&check[k-1]?.bundle_code===lineItem.bundle_code||lineItem.item_type==="gift_cards"&&lineItem?.total_amount_cents&&lineItem?.total_amount_cents<=0)return null;const lineProps={lineItem};return _jsx(LineItemChildrenContext.Provider,{value:lineProps,children},
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import LineItemContext from"../../context/LineItemContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";export function LineItem(props){const{type="skus",children}=props,{lineItems}=useContext(LineItemContext),{lineItems:shipmentLineItems}=useContext(ShipmentChildrenContext),components=(shipmentLineItems&&shipmentLineItems?.length>0?shipmentLineItems:lineItems)?.filter(l=>l.item_type===type).map((lineItem,k,check)=>{if(lineItem.item_type==="bundles"&&k>0&&check[k-1]?.bundle_code===lineItem.bundle_code||lineItem.item_type==="gift_cards"&&lineItem?.total_amount_cents&&lineItem?.total_amount_cents<=0)return null;const lineProps={lineItem};return _jsx(LineItemChildrenContext.Provider,{value:lineProps,children},lineItem.id)});return _jsx(_Fragment,{children:components})}export default LineItem;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BaseAmountComponent, BasePriceType } from '../../typings/index';
|
|
3
|
-
|
|
3
|
+
type Props = BaseAmountComponent & {
|
|
4
4
|
type?: BasePriceType;
|
|
5
5
|
};
|
|
6
6
|
export declare function LineItemAmount(props: Props): JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ConditionalElement } from '../../typings/index';
|
|
3
3
|
import { TGenericChildrenProps, TResources } from '../utils/GenericFieldComponent';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
type LineItemFieldChildrenProps = TGenericChildrenProps<TResources['LineItem']>;
|
|
5
|
+
type TCondition = ConditionalElement<Exclude<TResources['LineItem'], 'resource'>>;
|
|
6
|
+
type Props = {
|
|
7
7
|
children?: (props: LineItemFieldChildrenProps) => JSX.Element;
|
|
8
8
|
} & TCondition;
|
|
9
9
|
/**
|
|
@@ -4,7 +4,7 @@ interface ChildrenProps extends Omit<Props, 'children'> {
|
|
|
4
4
|
quantity: number;
|
|
5
5
|
handleChange: (event: React.MouseEvent<HTMLSelectElement>) => void;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
type Props = {
|
|
8
8
|
children?: ChildrenFunction<ChildrenProps>;
|
|
9
9
|
max?: number;
|
|
10
10
|
disabled?: boolean;
|
|
@@ -4,22 +4,22 @@ import { AddToCartReturn, CustomLineItem, LineItemOption } from '../../reducers/
|
|
|
4
4
|
interface TAddToCartButton extends Omit<Props, 'children'> {
|
|
5
5
|
handleClick: () => AddToCartReturn;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
type BuyNowMode = {
|
|
8
8
|
buyNowMode: true;
|
|
9
9
|
checkoutUrl?: string;
|
|
10
10
|
} | {
|
|
11
11
|
buyNowMode?: false;
|
|
12
12
|
checkoutUrl?: never;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
type THostedCart = {
|
|
15
15
|
redirectToHostedCart: true;
|
|
16
16
|
hostedCartUrl?: string;
|
|
17
17
|
} | {
|
|
18
18
|
redirectToHostedCart?: false;
|
|
19
19
|
hostedCartUrl?: never;
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
type TButton = PropsWithoutRef<Omit<JSX.IntrinsicElements['button'], 'children'>>;
|
|
22
|
+
type Props = {
|
|
23
23
|
/**
|
|
24
24
|
* Code of a bundle
|
|
25
25
|
*/
|
|
@@ -2,13 +2,26 @@
|
|
|
2
2
|
import { InitialOrderListContext } from '../../context/OrderListChildrenContext';
|
|
3
3
|
import { Column } from 'react-table';
|
|
4
4
|
import type { Order } from '@commercelayer/sdk';
|
|
5
|
-
export
|
|
5
|
+
export type OrderListColumn = Column & {
|
|
6
6
|
Header: string;
|
|
7
7
|
accessor: keyof Order;
|
|
8
8
|
className?: string;
|
|
9
9
|
titleClassName?: string;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type PaginationProps = {
|
|
12
|
+
/**
|
|
13
|
+
* Show table pagination. Default is false.
|
|
14
|
+
*/
|
|
15
|
+
showPagination: true;
|
|
16
|
+
pageSize?: number;
|
|
17
|
+
} | {
|
|
18
|
+
/**
|
|
19
|
+
* Show table pagination. Default is false.
|
|
20
|
+
*/
|
|
21
|
+
showPagination?: false;
|
|
22
|
+
pageSize?: never;
|
|
23
|
+
};
|
|
24
|
+
type Props = {
|
|
12
25
|
children: JSX.Element[] | JSX.Element;
|
|
13
26
|
/**
|
|
14
27
|
* Columns to show
|
|
@@ -27,15 +40,19 @@ declare type Props = {
|
|
|
27
40
|
*/
|
|
28
41
|
actionsContainerClassName?: string;
|
|
29
42
|
/**
|
|
30
|
-
* Show actions column
|
|
43
|
+
* Show actions column. Default is false.
|
|
31
44
|
*/
|
|
32
45
|
showActions?: boolean;
|
|
33
46
|
/**
|
|
34
|
-
* Class name to assign to
|
|
47
|
+
* Class name to assign to pagination container.
|
|
48
|
+
*/
|
|
49
|
+
paginationContainerClassName?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Class name to assign to the table header.
|
|
35
52
|
*/
|
|
36
53
|
theadClassName?: string;
|
|
37
54
|
/**
|
|
38
|
-
* Class name to assign to the table row
|
|
55
|
+
* Class name to assign to the table row.
|
|
39
56
|
*/
|
|
40
57
|
rowTrClassName?: string;
|
|
41
58
|
} & Omit<JSX.IntrinsicElements['table'], 'children'> & ({
|
|
@@ -55,6 +72,6 @@ declare type Props = {
|
|
|
55
72
|
} | {
|
|
56
73
|
infiniteScroll?: false;
|
|
57
74
|
windowOptions?: never;
|
|
58
|
-
});
|
|
59
|
-
export declare function OrderList({ children, columns, loadingElement, showActions, actionsComponent, actionsContainerClassName, infiniteScroll, windowOptions, theadClassName, rowTrClassName, ...p }: Props): JSX.Element;
|
|
75
|
+
}) & PaginationProps;
|
|
76
|
+
export declare function OrderList({ children, columns, loadingElement, showActions, showPagination, pageSize, paginationContainerClassName, actionsComponent, actionsContainerClassName, infiniteScroll, windowOptions, theadClassName, rowTrClassName, ...p }: Props): JSX.Element;
|
|
60
77
|
export default OrderList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createElement as _createElement}from"react";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useMemo,useState,useEffect,useCallback}from"react";import CustomerContext from"../../context/CustomerContext";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import{useTable,useSortBy,useBlockLayout}from"react-table";import{FixedSizeList}from"react-window";import scrollbarWidth from"../../utils/scrollbarWidth";import{sortDescIcon,sortAscIcon}from"../../utils/icons";export function OrderList({children,columns,loadingElement,showActions=!1,actionsComponent,actionsContainerClassName,infiniteScroll,windowOptions,theadClassName,rowTrClassName,...p}){const[loading,setLoading]=useState(!0),{orders}=useContext(CustomerContext),data=useMemo(()=>orders??[],[orders]),cols=useMemo(()=>columns,[columns]),tablePlugins=[useSortBy];infiniteScroll&&tablePlugins.push(useBlockLayout);const defaultColumn=useMemo(()=>({width:windowOptions?.column||150}),[windowOptions?.column]),table=useTable({data,columns:cols,...infiniteScroll&&{defaultColumn}},...tablePlugins),TableHtmlElement=infiniteScroll?"div":"table",TheadHtmlElement=infiniteScroll?"div":"thead",TbodyHtmlElement=infiniteScroll?"div":"tbody",ThHtmlElement=infiniteScroll?"div":"th",TrHtmlElement=infiniteScroll?"div":"tr";useEffect(()=>(orders!==void 0&&setLoading(!1),()=>{setLoading(!0)}),[orders]);const scrollBarSize=infiniteScroll?useMemo(()=>scrollbarWidth(),[]):0,LoadingComponent=loadingElement||_jsx("div",{children:"Loading..."}),headerComponent=table.headerGroups.map((headerGroup,i)=>{const columns2=headerGroup.headers.map((column,k)=>{const sortLabel=column.isSorted?column.isSortedDesc?"desc":"asc":"";return _createElement(ThHtmlElement,{"data-testid":`thead-${k}`,"data-sort":`${sortLabel}`,className:column?.className,...column.getHeaderProps(column?.getSortByToggleProps&&column?.getSortByToggleProps()),key:k},_jsxs("span",{className:column?.titleClassName,children:[column.render("Header"),column.isSorted?column.isSortedDesc?sortDescIcon:sortAscIcon:""]}))});return _createElement(TrHtmlElement,{...headerGroup.getHeaderGroupProps(),key:i},columns2)}),components=infiniteScroll?useCallback(({index,style})=>{const row=
|
|
1
|
+
import{createElement as _createElement}from"react";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useMemo,useState,useEffect,useCallback}from"react";import CustomerContext from"../../context/CustomerContext";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import OrderListPagination from"../../context/OrderListPaginationContext";import{useTable,useSortBy,useBlockLayout,usePagination}from"react-table";import{FixedSizeList}from"react-window";import scrollbarWidth from"../../utils/scrollbarWidth";import{sortDescIcon,sortAscIcon}from"../../utils/icons";import filterChildren from"../../utils/filterChildren";const rowComponents=["OrderListRow"],paginationComponents=["OrderListPaginationInfo","OrderListPaginationButtons"];export function OrderList({children,columns,loadingElement,showActions=!1,showPagination=!1,pageSize=10,paginationContainerClassName,actionsComponent,actionsContainerClassName,infiniteScroll,windowOptions,theadClassName,rowTrClassName,...p}){const[loading,setLoading]=useState(!0),{orders}=useContext(CustomerContext),data=useMemo(()=>orders??[],[orders]),cols=useMemo(()=>columns,[columns]),tablePlugins=[useSortBy];infiniteScroll&&tablePlugins.push(useBlockLayout),showPagination&&tablePlugins.push(usePagination);const defaultColumn=useMemo(()=>({width:windowOptions?.column||150}),[windowOptions?.column]),table=useTable({data,columns:cols,...infiniteScroll&&{defaultColumn},...showPagination&&{pageSize}},...tablePlugins),TableHtmlElement=infiniteScroll?"div":"table",TheadHtmlElement=infiniteScroll?"div":"thead",TbodyHtmlElement=infiniteScroll?"div":"tbody",ThHtmlElement=infiniteScroll?"div":"th",TrHtmlElement=infiniteScroll?"div":"tr";useEffect(()=>(orders!==void 0&&setLoading(!1),()=>{setLoading(!0)}),[orders]);const scrollBarSize=infiniteScroll?useMemo(()=>scrollbarWidth(),[]):0,LoadingComponent=loadingElement||_jsx("div",{children:"Loading..."}),headerComponent=table.headerGroups.map((headerGroup,i)=>{const columns2=headerGroup.headers.map((column,k)=>{const sortLabel=column.isSorted?column.isSortedDesc?"desc":"asc":"";return _createElement(ThHtmlElement,{"data-testid":`thead-${k}`,"data-sort":`${sortLabel}`,className:column?.className,...column.getHeaderProps(column?.getSortByToggleProps&&column?.getSortByToggleProps()),key:k},_jsxs("span",{className:column?.titleClassName,children:[column.render("Header"),column.isSorted?column.isSortedDesc?sortDescIcon:sortAscIcon:""]}))});return _createElement(TrHtmlElement,{...headerGroup.getHeaderGroupProps(),key:i},columns2)}),rows=showPagination?table.page:table.rows,rowsComponents=filterChildren({children,filterBy:rowComponents,componentName:"OrderList"}),components=infiniteScroll?useCallback(({index,style})=>{const row=rows[index];row&&table.prepareRow(row);const childProps={orders,order:orders?.[index],row,showActions,actionsComponent,actionsContainerClassName,infiniteScroll};return _jsx(TrHtmlElement,{...row?.getRowProps({style}),className:rowTrClassName,children:_jsx(OrderListChildrenContext.Provider,{value:childProps,children:rowsComponents})})},[table.prepareRow,table.rows]):rows.map((row,i)=>{table.prepareRow(row);const childProps={orders,order:orders?.[i],row,showActions,actionsComponent,actionsContainerClassName,infiniteScroll};return _createElement(TrHtmlElement,{...row.getRowProps(),className:rowTrClassName,key:i},_jsx(OrderListChildrenContext.Provider,{value:childProps,children:rowsComponents}))}),pagComponents=filterChildren({children,filterBy:paginationComponents,componentName:"OrderList"}),Pagination=()=>showPagination?_jsx(OrderListPagination.Provider,{value:{canNextPage:table.canNextPage,canPreviousPage:table.canPreviousPage,gotoPage:table.gotoPage,nextPage:table.nextPage,page:table.page,pageCount:table.pageCount,pageIndex:table.state.pageIndex,pageNumber:table.pageNumber,pageOptions:table.pageOptions,pageSize:table.state.pageSize,previousPage:table.previousPage,setPageSize:table.setPageSize,totalRows:orders?.length??0},children:pagComponents}):null;return loading&&orders==null?_jsx(_Fragment,{children:LoadingComponent}):orders?.length===0?_jsx(OrderListChildrenContext.Provider,{value:{orders},children}):_jsxs(_Fragment,{children:[_jsxs(TableHtmlElement,{...p,...table.getTableProps(),children:[_jsx(TheadHtmlElement,{className:theadClassName,children:headerComponent}),_jsx(TbodyHtmlElement,{...table.getTableBodyProps(),children:infiniteScroll?_jsx(FixedSizeList,{height:windowOptions?.height||400,itemCount:table.rows.length,itemSize:windowOptions?.itemSize||100,width:windowOptions?.width||table.totalColumnsWidth+scrollBarSize,children:components}):components})]}),_jsx("div",{className:paginationContainerClassName,children:_jsx(Pagination,{})})]})}export default OrderList;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type OrderListPaginationContext as TOrderListPaginationContext } from '../../context/OrderListPaginationContext';
|
|
3
|
+
import { ChildrenFunction } from '../../typings/index';
|
|
4
|
+
interface PaginationButton extends Omit<JSX.IntrinsicElements['button'], 'children' | 'disabled'> {
|
|
5
|
+
/**
|
|
6
|
+
* Show or hide the pagination button. Default is true.
|
|
7
|
+
*/
|
|
8
|
+
show: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Label to display
|
|
11
|
+
*/
|
|
12
|
+
label?: string | JSX.Element;
|
|
13
|
+
}
|
|
14
|
+
interface NavigationButtons extends Omit<JSX.IntrinsicElements['button'], 'children'> {
|
|
15
|
+
/**
|
|
16
|
+
* Show or hide the navigation buttons. Default is true.
|
|
17
|
+
*/
|
|
18
|
+
show?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Attach the class name to the current page button
|
|
21
|
+
*/
|
|
22
|
+
activeClassName?: string;
|
|
23
|
+
}
|
|
24
|
+
type ChildrenProps = Omit<Props, 'children'> & TOrderListPaginationContext;
|
|
25
|
+
interface Props extends Omit<JSX.IntrinsicElements['div'], 'children'> {
|
|
26
|
+
children?: ChildrenFunction<ChildrenProps>;
|
|
27
|
+
/**
|
|
28
|
+
* Previous button props
|
|
29
|
+
*/
|
|
30
|
+
previousPageButton?: PaginationButton;
|
|
31
|
+
/**
|
|
32
|
+
* Next button props
|
|
33
|
+
*/
|
|
34
|
+
nextPageButton?: PaginationButton;
|
|
35
|
+
/**
|
|
36
|
+
* Navigation buttons props
|
|
37
|
+
*/
|
|
38
|
+
navigationButtons?: NavigationButtons;
|
|
39
|
+
}
|
|
40
|
+
export declare function OrderListPaginationButtons({ previousPageButton, nextPageButton, navigationButtons, children, ...props }: Props): JSX.Element;
|
|
41
|
+
export declare namespace OrderListPaginationButtons {
|
|
42
|
+
var displayName: string;
|
|
43
|
+
}
|
|
44
|
+
export default OrderListPaginationButtons;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import Parent from"../utils/Parent";import OrderListPaginationContext from"../../context/OrderListPaginationContext";import useCustomContext from"../../utils/hooks/useCustomContext";import omit from"../../utils/omit";export function OrderListPaginationButtons({previousPageButton,nextPageButton,navigationButtons,children,...props}){const{...prevButton}={show:!0,...previousPageButton},{...nextButton}={show:!0,...nextPageButton},{...navButton}={show:!0,...navigationButtons},ctx=useCustomContext({context:OrderListPaginationContext,contextComponentName:"OrderList",currentComponentName:"OrderListPaginationButtons"}),PrevButton=prevButton.show?_jsx("button",{"data-testid":"prev-button",...omit(prevButton,["show"]),disabled:ctx?.canPreviousPage===!1,onClick:()=>ctx?.previousPage(),children:previousPageButton?.label??"<"}):null,NextButton=nextButton.show?_jsx("button",{"data-testid":"next-button",...omit(nextButton,["show"]),disabled:ctx?.canNextPage===!1,onClick:()=>ctx?.nextPage(),children:nextButton?.label??">"}):null,pagesToShow=ctx?.canPreviousPage===!1?ctx?.pageOptions.slice(0,3).map(v=>v+1):ctx?.canNextPage===!1?ctx?.pageOptions.slice(ctx?.pageOptions.length-3,ctx?.pageOptions.length).map(v=>v+1):ctx?.pageOptions.slice(ctx?.pageIndex-1,ctx?.pageIndex+2).map(v=>v+1),NavButtons=navButton.show?pagesToShow?.map(v=>{const className=(ctx?.pageIndex!=null?ctx?.pageIndex+1:1)===v?`${navButton?.className??""} ${navButton?.activeClassName??""}`:navButton?.className;return _jsx("button",{"data-testid":`page-${v}`,...omit(navButton,["show","activeClassName","className"]),className,onClick:()=>ctx?.gotoPage(v-1),children:v},`page-${v}`)}):null,parentProps={navigationButtons,prevButton,nextButton,...ctx,...props};return children==null?_jsxs("div",{...props,children:[PrevButton,NavButtons,NextButton]}):_jsx(Parent,{...parentProps,children})}OrderListPaginationButtons.displayName="OrderListPaginationButtons";export default OrderListPaginationButtons;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChildrenFunction } from '../../typings/index';
|
|
3
|
+
type TAsComponent = keyof Pick<JSX.IntrinsicElements, 'p' | 'span' | 'div'>;
|
|
4
|
+
type ChildrenProps<A extends TAsComponent> = Omit<Props<A>, 'children'> & {
|
|
5
|
+
/**
|
|
6
|
+
* Current number of the first page row to display
|
|
7
|
+
*/
|
|
8
|
+
firstRow: number;
|
|
9
|
+
/**
|
|
10
|
+
* Current number of the last page row to display
|
|
11
|
+
*/
|
|
12
|
+
lastRow: number;
|
|
13
|
+
/**
|
|
14
|
+
* Total number of rows to display
|
|
15
|
+
*/
|
|
16
|
+
totRows: number;
|
|
17
|
+
};
|
|
18
|
+
type Props<A extends TAsComponent> = {
|
|
19
|
+
children?: ChildrenFunction<ChildrenProps<A>>;
|
|
20
|
+
/**
|
|
21
|
+
* HTML Tag to display
|
|
22
|
+
*/
|
|
23
|
+
as?: TAsComponent;
|
|
24
|
+
} & Omit<JSX.IntrinsicElements[A], 'children' | 'ref'>;
|
|
25
|
+
export declare function OrderListPaginationInfo<A extends TAsComponent = 'span'>({ as, children, ...props }: Props<A>): JSX.Element;
|
|
26
|
+
export declare namespace OrderListPaginationInfo {
|
|
27
|
+
var displayName: string;
|
|
28
|
+
}
|
|
29
|
+
export default OrderListPaginationInfo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import OrderListPaginationContext from"../../context/OrderListPaginationContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function OrderListPaginationInfo({as="span",children,...props}){const ctx=useCustomContext({context:OrderListPaginationContext,contextComponentName:"OrderList",currentComponentName:"OrderListPaginationInfo"}),TagElement=as,totRows=ctx?.totalRows??0,pageIndex=ctx?.pageIndex??0,pageSize=ctx?.pageSize??10;let firstRow=pageIndex===0?pageIndex+1:pageIndex,lastRow=firstRow*pageSize;ctx?.canPreviousPage===!0&&(firstRow=Math.floor(firstRow*10)+1,lastRow=Math.floor(firstRow+pageSize-1)),ctx?.canNextPage===!1&&(lastRow=totRows);const parentProps={...props,as,firstRow,lastRow,totRows};return children==null?_jsx(TagElement,{...props,children:`${firstRow} - ${lastRow} of ${totRows}`}):_jsx(Parent,{...parentProps,children})}OrderListPaginationInfo.displayName="OrderListPaginationInfo";export default OrderListPaginationInfo;
|
|
@@ -31,4 +31,7 @@ interface Props extends Omit<JSX.IntrinsicElements['td'], 'children'> {
|
|
|
31
31
|
field: keyof Order;
|
|
32
32
|
}
|
|
33
33
|
export declare function OrderListRow({ field, children, ...p }: Props): JSX.Element;
|
|
34
|
+
export declare namespace OrderListRow {
|
|
35
|
+
var displayName: string;
|
|
36
|
+
}
|
|
34
37
|
export default OrderListRow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createElement as _createElement}from"react";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import isDate from"../../utils/isDate";import last from"lodash/last";export function OrderListRow({field,children,...p}){const{order,row,showActions,actionsComponent,actionsContainerClassName,infiniteScroll}=useContext(OrderListChildrenContext),cell=row?.cells.filter(cell2=>cell2.column.id===field),isLastRow=last(row?.cells)?.column.id===field,As=infiniteScroll?"div":"td",ActionRow=()=>showActions&&isLastRow&&actionsComponent&&_jsx(As,{"data-testid":"action-cell",...p,className:actionsContainerClassName,children:_jsx(Parent,{...parentProps,children:actionsComponent})})||null,parentProps={...p,field,order,row,cell,infiniteScroll};return children?_jsxs(_Fragment,{children:[_jsx(Parent,{...parentProps,children}),_jsx(ActionRow,{})]}):_jsxs(_Fragment,{children:[cell?.map((cell2,k)=>{const cellValue=cell2.value,value=isDate(cellValue)?new Date(Date.parse(cellValue)).toLocaleString():cell2.render("Cell");return _createElement(As,{"data-testid":`cell-${k}`,...p,...cell2.getCellProps(),key:k},value)}),_jsx(ActionRow,{})]})}export default OrderListRow;
|
|
1
|
+
import{createElement as _createElement}from"react";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import isDate from"../../utils/isDate";import last from"lodash/last";export function OrderListRow({field,children,...p}){const{order,row,showActions,actionsComponent,actionsContainerClassName,infiniteScroll}=useContext(OrderListChildrenContext),cell=row?.cells.filter(cell2=>cell2.column.id===field),isLastRow=last(row?.cells)?.column.id===field,As=infiniteScroll?"div":"td",ActionRow=()=>showActions&&isLastRow&&actionsComponent&&_jsx(As,{"data-testid":"action-cell",...p,className:actionsContainerClassName,children:_jsx(Parent,{...parentProps,children:actionsComponent})})||null,parentProps={...p,field,order,row,cell,infiniteScroll};return children?_jsxs(_Fragment,{children:[_jsx(Parent,{...parentProps,children}),_jsx(ActionRow,{})]}):_jsxs(_Fragment,{children:[cell?.map((cell2,k)=>{const cellValue=cell2.value,value=isDate(cellValue)?new Date(Date.parse(cellValue)).toLocaleString():cell2.render("Cell");return _createElement(As,{"data-testid":`cell-${k}`,...p,...cell2.getCellProps(),key:k},value)}),_jsx(ActionRow,{})]})}OrderListRow.displayName="OrderListRow";export default OrderListRow;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BaseFieldProps } from '../utils/BaseField';
|
|
3
|
-
|
|
3
|
+
type Props = Omit<BaseFieldProps, 'attribute'>;
|
|
4
4
|
export declare function OrderNumber(props: Props): JSX.Element;
|
|
5
5
|
export default OrderNumber;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ConditionalElement } from '../../typings/index';
|
|
3
3
|
import { TGenericChildrenProps, TResources } from '../utils/GenericFieldComponent';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
type ParcelFieldChildrenProps = TGenericChildrenProps<TResources['Parcel']>;
|
|
5
|
+
type TCondition = ConditionalElement<Exclude<TResources['Parcel'], 'resource'>>;
|
|
6
|
+
type Props = {
|
|
7
7
|
children?: (props: ParcelFieldChildrenProps) => JSX.Element;
|
|
8
8
|
} & TCondition;
|
|
9
9
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ConditionalElement } from '../../typings/index';
|
|
3
3
|
import { TGenericChildrenProps, TResources } from '../utils/GenericFieldComponent';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
type ParcelLineItemFieldChildrenProps = TGenericChildrenProps<TResources['ParcelLineItem']>;
|
|
5
|
+
type TCondition = ConditionalElement<Exclude<TResources['ParcelLineItem'], 'resource'>>;
|
|
6
|
+
type Props = {
|
|
7
7
|
children?: (props: ParcelLineItemFieldChildrenProps) => JSX.Element;
|
|
8
8
|
} & TCondition;
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
|
|
3
|
+
type Props = GatewayBaseType;
|
|
4
4
|
export declare function AdyenGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default AdyenGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
|
|
3
|
+
type Props = GatewayBaseType;
|
|
4
4
|
export declare function BraintreeGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default BraintreeGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
|
|
3
|
+
type Props = GatewayBaseType;
|
|
4
4
|
export declare function CheckoutComGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default CheckoutComGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
|
|
3
|
+
type Props = GatewayBaseType;
|
|
4
4
|
export declare function KlarnaGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default KlarnaGateway;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LoaderType } from '../../typings/index';
|
|
3
3
|
import { PaymentSourceProps } from '../payment_source/PaymentSource';
|
|
4
|
-
export
|
|
4
|
+
export type GatewayBaseType = Props & {
|
|
5
5
|
show: boolean;
|
|
6
6
|
loading: boolean;
|
|
7
7
|
loaderComponent: JSX.Element;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type Props = PaymentSourceProps & {
|
|
10
10
|
showCard: boolean;
|
|
11
11
|
handleEditClick: (e: MouseEvent) => void;
|
|
12
12
|
show: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
|
|
3
|
+
type Props = Partial<GatewayBaseType>;
|
|
4
4
|
export declare function PaypalGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default PaypalGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
|
|
3
|
+
type Props = GatewayBaseType;
|
|
4
4
|
export declare function StripeGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default StripeGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
|
|
3
|
+
type Props = GatewayBaseType;
|
|
4
4
|
export declare function WireTransferGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default WireTransferGateway;
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { LoaderType } from '../../typings/index';
|
|
3
3
|
import { PaymentMethod as PaymentMethodType } from '@commercelayer/sdk';
|
|
4
4
|
import { PaymentResource } from '../../reducers/PaymentMethodReducer';
|
|
5
|
-
|
|
5
|
+
type Props = {
|
|
6
6
|
/**
|
|
7
7
|
* Hide payment methods by an array of strings
|
|
8
8
|
*/
|
|
@@ -5,7 +5,7 @@ interface ChildrenProps extends Omit<Props, 'children'> {
|
|
|
5
5
|
checked: boolean;
|
|
6
6
|
handleOnChange: (event: ChangeEvent<HTMLInputElement>) => Promise<void>;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
type Props = {
|
|
9
9
|
children?: ChildrenFunction<ChildrenProps>;
|
|
10
10
|
onChange?: (payment?: PaymentMethod | Record<string, any>) => void;
|
|
11
11
|
} & JSX.IntrinsicElements['input'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig,setPaymentRef}from"../../reducers/PaymentMethodReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig,setPaymentRef}from"../../reducers/PaymentMethodReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import isEmpty from"lodash/isEmpty";import useCustomContext from"../../utils/hooks/useCustomContext";export function PaymentMethodsContainer(props){const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useCustomContext({context:OrderContext,contextComponentName:"OrderContainer",currentComponentName:"PaymentMethodsContainer",key:"order"}),credentials=useContext(CommerceLayerContext);async function getPayMethods(){order&&await getPaymentMethods({order,dispatch})}useEffect(()=>{include?.includes("available_payment_methods")?includeLoaded?.available_payment_methods||addResourceToInclude({newResourceLoaded:{available_payment_methods:!0,payment_source:!0,payment_method:!0,"line_items.line_item_options.sku_option":!0,"line_items.item":!0}}):addResourceToInclude({newResource:["available_payment_methods","payment_source","payment_method","line_items.line_item_options.sku_option","line_items.item"]}),config&&isEmpty(state.config)&&setPaymentMethodConfig(config,dispatch),credentials&&order&&!state.paymentMethods&&getPayMethods(),order?.payment_source&&dispatch({type:"setPaymentSource",payload:{paymentSource:order?.payment_source}}),order?.payment_source===null&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},[order,credentials,include,includeLoaded]);const contextValue=useMemo(()=>({...state,setLoading:({loading})=>defaultPaymentMethodContext.setLoading({loading,dispatch}),setPaymentRef:({ref})=>setPaymentRef({ref,dispatch}),setPaymentMethodErrors:errors=>defaultPaymentMethodContext.setPaymentMethodErrors(errors,dispatch),setPaymentMethod:async args=>await defaultPaymentMethodContext.setPaymentMethod({...args,config:credentials,updateOrder,order,dispatch,setOrderErrors}),setPaymentSource:async args=>await defaultPaymentMethodContext.setPaymentSource({...state,...args,config:credentials,dispatch,getOrder,updateOrder,order}),updatePaymentSource:async args=>await defaultPaymentMethodContext.updatePaymentSource({...args,config:credentials,dispatch}),destroyPaymentSource:async args=>await defaultPaymentMethodContext.destroyPaymentSource({...args,dispatch,config:credentials,updateOrder,orderId:order?.id})}),[state]);return _jsx(PaymentMethodContext.Provider,{value:contextValue,children})}export default PaymentMethodsContainer;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
import { PaymentSourceProps } from './PaymentSource';
|
|
3
|
-
|
|
3
|
+
type Styles = Partial<{
|
|
4
4
|
base: CSSProperties;
|
|
5
5
|
error: CSSProperties;
|
|
6
6
|
placeholder: CSSProperties;
|
|
7
7
|
validated: CSSProperties;
|
|
8
8
|
}>;
|
|
9
|
-
|
|
9
|
+
type PaypalStyle = Partial<{
|
|
10
10
|
/**
|
|
11
11
|
* @see {@link https://developer.paypal.com/docs/checkout/integration-features/customize-button/#color}
|
|
12
12
|
*/
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { HostedFieldFieldOptions } from 'braintree-web/modules/hosted-fields';
|
|
3
3
|
import { PaymentSourceProps } from './PaymentSource';
|
|
4
|
-
|
|
4
|
+
type BraintreeHostedFields<Type> = {
|
|
5
5
|
[Property in keyof Type]: {
|
|
6
6
|
label?: string;
|
|
7
7
|
} & Type[Property];
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type BraintreeConfig = {
|
|
10
10
|
containerClassName?: string;
|
|
11
11
|
cardContainerClassName?: string;
|
|
12
12
|
expDateContainerClassName?: string;
|
|
@@ -20,7 +20,7 @@ export declare type BraintreeConfig = {
|
|
|
20
20
|
[key: string]: Record<string, string>;
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
type Props = {
|
|
24
24
|
authorization: string;
|
|
25
25
|
config?: BraintreeConfig;
|
|
26
26
|
templateCustomerSaveToWallet?: PaymentSourceProps['templateCustomerSaveToWallet'];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
|
|
3
3
|
import { PaymentSourceProps } from './PaymentSource';
|
|
4
4
|
import { FramesStyle } from 'frames-react';
|
|
5
|
-
export
|
|
5
|
+
export type CheckoutComConfig = {
|
|
6
6
|
containerClassName?: string;
|
|
7
7
|
hintLabel?: string;
|
|
8
8
|
name?: string;
|
|
@@ -13,7 +13,7 @@ export declare type CheckoutComConfig = {
|
|
|
13
13
|
};
|
|
14
14
|
[key: string]: unknown;
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
type Props = PaymentMethodConfig['checkoutComPayment'] & JSX.IntrinsicElements['div'] & {
|
|
17
17
|
show?: boolean;
|
|
18
18
|
publicKey: string;
|
|
19
19
|
locale?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
|
|
3
3
|
import { PaymentSourceProps } from './PaymentSource';
|
|
4
|
-
|
|
4
|
+
type KlarnaPaymentProps = PaymentMethodConfig['klarnaPayment'] & JSX.IntrinsicElements['div'] & Partial<PaymentSourceProps['templateCustomerSaveToWallet']> & {
|
|
5
5
|
show?: boolean;
|
|
6
6
|
clientToken: string;
|
|
7
7
|
locale?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ChildrenFunction } from '../../typings/index';
|
|
3
|
-
export
|
|
3
|
+
export type PaymentSourceDetailType = 'last4' | 'exp_year' | 'exp_month';
|
|
4
4
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
5
5
|
text: string;
|
|
6
6
|
}
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { ChildrenFunction } from '../../typings/index';
|
|
3
3
|
interface CustomComponent extends Omit<Props, 'children'> {
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
type Props = {
|
|
6
6
|
children?: ChildrenFunction<CustomComponent>;
|
|
7
7
|
label?: string | ReactNode;
|
|
8
8
|
} & Omit<JSX.IntrinsicElements['button'], 'onClick'>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type PaypalConfig = {
|
|
3
3
|
return_url: string;
|
|
4
4
|
cancel_url: string;
|
|
5
5
|
infoMessage?: {
|
|
@@ -7,6 +7,6 @@ export declare type PaypalConfig = {
|
|
|
7
7
|
className?: string;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type Props = Omit<PaypalConfig, 'return_url' | 'cancel_url'> & JSX.IntrinsicElements['div'];
|
|
11
11
|
export declare function PaypalPayment({ infoMessage, ...p }: Props): JSX.Element;
|
|
12
12
|
export default PaypalPayment;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import { StripeCardElementOptions, StripeElementLocale } from '@stripe/stripe-js';
|
|
3
3
|
import { PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
|
|
4
4
|
import { PaymentSourceProps } from './PaymentSource';
|
|
5
|
-
export
|
|
5
|
+
export type StripeConfig = {
|
|
6
6
|
containerClassName?: string;
|
|
7
7
|
hintLabel?: string;
|
|
8
8
|
name?: string;
|
|
9
9
|
options?: StripeCardElementOptions;
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type Props = PaymentMethodConfig['stripePayment'] & JSX.IntrinsicElements['div'] & Partial<PaymentSourceProps['templateCustomerSaveToWallet']> & {
|
|
13
13
|
show?: boolean;
|
|
14
14
|
publishableKey: string;
|
|
15
15
|
locale?: StripeElementLocale;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type WireTransferConfig = {
|
|
3
3
|
infoMessage?: {
|
|
4
4
|
text?: string | ReactNode;
|
|
5
5
|
className?: string;
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type Props = WireTransferConfig & JSX.IntrinsicElements['div'] & {
|
|
9
9
|
'data-test-id'?: string;
|
|
10
10
|
};
|
|
11
11
|
export declare function WireTransferPayment({ infoMessage, ...p }: Props): JSX.Element;
|