import React, { PureComponent } from 'react'; import type { ImageSourcePropType, ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native'; import type { CommerceTypes } from '../../../../libs/fscommerce'; export declare type CartItemUpdateQuantityFunction = (item: CommerceTypes.CartItem, qty: number) => Promise; export declare type CartItemRemoveFunction = (item: CommerceTypes.CartItem) => Promise; export declare type CartItemRenderFunction = (item: CommerceTypes.CartItem, updateQty: CartItemUpdateQuantityFunction, remove: CartItemRemoveFunction) => React.ReactNode; export interface SerializableCartItemProps { /** * Styles to apply to the default stepper */ stepperStyle?: ViewStyle; /** * Styles to apply to the default remove button */ removeButtonStyle?: ViewStyle; /** * Styles to apply to the default remove button text */ removeButtonTextStyle?: TextStyle; /** * Height of thumbnail image; required if image provided */ imageHeight?: number; /** * Width of thumbnail image; required if image provided */ imageWidth?: number; /** * Styles to apply to the main container */ style?: ViewStyle; /** * Styles to apply to the left (image) column */ leftColumnStyle?: ViewStyle; /** * Styles to apply to the right (details & quantity) column */ rightColumnStyle?: ViewStyle; /** * Styles to apply to the quantity (stepper & remove button) row */ quantityRowStyle?: ViewStyle; } export interface CartItemProps extends CommerceTypes.CartItem, Omit { /** * A function to invoke when the user wants to remove the item from cart. */ removeItem: CartItemRemoveFunction; /** * A function to invoke when the user wants to modify the quantity of an item in cart. */ updateQty: CartItemUpdateQuantityFunction; /** * An optional custom render function to render the item details */ renderDetails?: CartItemRenderFunction; /** * An optional custom render function to modify the item quantity */ renderStepper?: CartItemRenderFunction; /** * Styles to apply to the default stepper */ stepperStyle?: StyleProp; /** * An optional custom render function to render the remove button */ renderRemoveButton?: CartItemRenderFunction; /** * Styles to apply to the default remove button */ removeButtonStyle?: StyleProp; /** * Styles to apply to the default remove button text */ removeButtonTextStyle?: StyleProp; /** * A callback to invoke if the user taps on the image */ onImagePress?: (item: CommerceTypes.CartItem) => void; /** * An optional custom render function to render an arbitrary element displayed under the * quantity. Typically used to display a promo message. */ renderPromo?: CartItemRenderFunction; /** * Styles to apply to the main container */ style?: StyleProp; /** * Styles to apply to the left (image) column */ leftColumnStyle?: StyleProp; /** * Styles to apply to the right (details & quantity) column */ rightColumnStyle?: StyleProp; /** * Styles to apply to the quantity (stepper & remove button) row */ quantityRowStyle?: StyleProp; } export interface CartItemState { image?: ImageSourcePropType; imageStyle: StyleProp; } export declare class CartItem extends PureComponent { static defaultProps: Partial; static getDerivedStateFromProps(nextProps: CartItemProps, prevState: CartItemState): Partial | null; state: CartItemState; private readonly renderRemoveButton; /** * Renders the cart item image. * * @return The cart item image or null if there is no image. */ private renderImage; /** * Increments the item quantity by one. */ private readonly handleIncrease; /** * Decrements the item quantity by one. The quantity cannot go lower than zero. */ private readonly handleDecrease; /** * Removes the item from cart. */ private readonly handleRemove; /** * Handles when the user taps the cart item image. */ private readonly handleImagePress; render(): React.ReactNode; }