import * as React from 'react'; import type { Img } from '../../types/props.js'; export type MiniCartSemanticName = 'root' | 'content' | 'cartInfo' | 'cartTitle' | 'cartDescription' | 'priceSection' | 'totalPrice' | 'originalPrice' | 'saveAmount' | 'actionButton' | 'itemsGrid' | 'itemGridContainer' | 'gridItem' | 'gridItemOverlay' | 'expandButton' | 'circleProgress' | 'mobileViewMoreButton'; /** * 圆形进度条配置 */ export interface CircleProgressConfig { /** 总阶段数 (1-4) */ totalSteps?: 1 | 2 | 3 | 4; /** 当前完成的阶段 (0 到 totalSteps) */ currentStep?: number; /** 中间显示的图片 */ image?: Img; /** 底部显示的文案 */ label?: string; /** 进度条颜色,默认为品牌色 */ progressColor?: string; /** 底部文案背景色,默认为品牌营销色 */ labelColor?: string; /** 背景颜色,默认为容器背景色 */ backgroundColor?: string; /** 移动端组件尺寸,默认 48 */ size?: number; /** laptop 以上组件尺寸,默认 80 */ laptopSize?: number; } /** * 文案配置 */ export interface MiniCartCopy { emptyCart: string; description: string; total: string; itemsInCart: string; totalWithCoupon: string; clickToView: string; buyNowText: string; savingText: string; } /** * MiniCart 业务组件数据接口 */ export interface MiniCartData { /** 文案配置 */ copy?: MiniCartCopy; theme?: 'light' | 'dark'; /** 地区代码,用于价格格式化 */ locale?: string; /** 是否显示手机端查看更多按钮,默认 true */ showMobileViewMore?: boolean; } /** * 购物车商品项类型 */ export type CartLineItem = { id: string; quantity: number; /** 商品标签,如 "Free"、"Gift" 等,显示在商品图片底部 */ productLabel?: string; cost: { totalAmount: { amount: string; currencyCode: string; formattedPrice: string; }; subtotalAmount?: { amount: string; currencyCode: string; formattedPrice?: string; }; }; merchandise: { id: string; sku: string; /** 商品标题 - MiniCartDialog 需要 */ title?: string; image: { url: string; altText: string | null; }; }; }; /** * 购物车类型 */ export type Cart = { id: string; checkoutUrl: string; lineItems: CartLineItem[]; cost: { totalAmount: { amount: string; currencyCode: string; formattedPrice: string; }; subtotalAmount?: { amount: string; currencyCode: string; formattedPrice?: string; }; savingAmount?: { amount?: string; currencyCode: string; formattedPrice?: string; }; }; }; export interface MiniCartProps extends React.HTMLAttributes { /** 业务数据 */ data: MiniCartData; /** * 各部分的自定义样式类名 */ classNames?: Partial>; /** * 产品信息(用于主要展示的产品) */ cart: Cart; /** * 圆形进度条配置,不传则不显示进度条 */ progressConfig?: CircleProgressConfig; /** * 删除商品项的回调函数 * @param id 商品 ID * @param cart 购物车数据 * @returns 支持返回 Promise,内部自动处理 loading 状态 */ onRemoveItem?: (id: string, cart: Cart) => void | Promise; /** * 点击结算按钮的回调函数 * @param cart * @returns 支持返回 Promise,内部自动处理 loading 状态 */ onCheckout?: (cart: Cart) => void | Promise; /** * 点击click to view的回调函数 * @param cart * @returns */ onClickToView?: (cart: Cart) => void; } /** * MiniCart - 迷你购物车 * * @description 迷你购物车(Mini Cart)是一个常见的电商UI组件,通常在用户浏览商品时以底部悬浮的形式出现,允许用户快速查看、编辑购物车内容而不离开当前页面,同时可以承载满赠,满减等活动。 */ declare const MiniCart: React.ForwardRefExoticComponent>; export default MiniCart;