/// import { LayoutConfig } from "../../pro/Selector/types.js"; import { SKUCardPresentation } from "../../pro/Cards/components/SKUCard/types.js"; //#region src/plus/skuOptionsSelection/types.d.ts interface SKUOptionsSelectionGroupHeaderDefaults { readonly title: React.ReactNode; readonly requiredTag: React.ReactNode; readonly hint: React.ReactNode; readonly aggregate: React.ReactNode; } interface SKUOptionsSelectionPresentation { /** SelectorGroup 的规格组导航。 */ groupTabs?: { visible?: boolean; }; /** 规格组之间和标题行的展示方式。 */ group?: { gap?: number | string; headerClassName?: string; showRequiredTag?: boolean; showHint?: boolean; showAggregate?: boolean; }; /** 复用 Selector 的现有布局模型,支持固定列和响应式断点。 */ collection?: LayoutConfig; /** 复用 SKUCard 的结构展示能力。 */ card?: SKUCardPresentation; /** 数量选择器的展示尺寸;颜色仍由系统主题控制。 */ stepper?: { size?: 'small' | 'middle' | 'large'; shape?: 'round' | 'square'; horizontalPadding?: number | string; }; } interface SKUOptionsSelectionBehavior { single?: { /** 普通单选项默认 true,保持历史再次点击可取消的行为。 */allowDeselect?: boolean; }; validation?: { scrollToFirstError?: boolean; }; } interface SKUOptionsSelectionSlots { groupHeader?: (context: { readonly group: OptionGroupItem | VariantGroupItem | BundleItem; readonly defaults: SKUOptionsSelectionGroupHeaderDefaults; }) => React.ReactNode; } type SkuPriceFormatter = (value: number | string) => string; /** * SKU Card 文本样式配置 */ interface SkuCardTextConfig { /** 是否显示 */ visible?: boolean; /** 字体大小 */ fontSize?: number; /** 颜色 */ color?: string; /** 字体粗细 */ fontWeight?: 'normal' | 'bold' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; /** 展示行数 */ lineClamp?: number; } /** * SKU Card 图片配置 */ interface SkuCardImageConfig { /** 是否显示 */ visible?: boolean; /** 宽度 */ width?: number; /** 高度 */ height?: number; /** 圆角 */ borderRadius?: number | string; /** 边框 */ border?: string; } /** * SKU Card 禁用文本配置 */ interface SkuCardDisabledTextConfig extends Omit { /** 文本(可能是多语言) */ text?: string; } /** * SKU Card 配置 */ interface SkuCardConfig { /** 主标题配置 */ title?: SkuCardTextConfig; /** 副标题配置 */ subTitle?: SkuCardTextConfig; /** 价格配置 */ price?: Omit; /** 图片配置 */ image?: SkuCardImageConfig; /** * @description 是否在「组合规格选项卡片(VariantCard)」展示价格 * - 默认不展示,避免影响现有业务 UI */ variantPriceVisible?: boolean; /** 禁用文本配置 */ disabledText?: SkuCardDisabledTextConfig; } /** 必选唯一套餐项在组件初始化时的处理策略。 */ type SKUOptionsSelectionInitializationPolicy = 'auto-required-defaults' | 'preserve'; /** 仅供当前界面会话恢复未完成的组合规格,不属于订单 SKU 数据。 */ interface VariantSelectionDraft { productId: number | string; selectionKey?: number | string; items: Record; /** 区分宿主对本次选择的回写与外部重新回填。 */ productOptionString: string; } /** 与业务 value 同一次选择产生的界面状态,不属于订单数据。 */ interface SKUOptionsSelectionChange { variantDraft: VariantSelectionDraft | null; } interface IProps { /** 数据源 */ dataSource: DataSource; /** 原始值 */ value: SkuValue; /** 同一商品切换订单行/会话时更换此 key,以清除上一次的界面草稿。 */ selectionKey?: number | string; /** 可选受控界面草稿;不传时由组件保存,跨步骤宿主可单独保存并回传。 */ variantDraft?: VariantSelectionDraft | null; /** * 初始化策略。新建流程可自动补齐唯一必选套餐项;编辑流程应使用 preserve, * 完整保留订单原值并在提交时通过校验暴露缺失项。 * @default 'auto-required-defaults' */ initializationPolicy?: SKUOptionsSelectionInitializationPolicy; /** 根 SelectorGroup className。 */ className?: string; /** 禁用整个选择器,包括鼠标与键盘交互。 */ disabled?: boolean; /** 配置 */ config?: { /** 是否禁用 */overSold?: 0 | 1; }; /** SKU Card 配置 */ skuCardConfig?: SkuCardConfig; /** 自定义金额格式化,仅影响展示,不参与价格计算 */ priceFormatter?: SkuPriceFormatter; /** * Optional observer of the actual group selections, including partial choices. * Reports initialization/controlled updates and interactions even when the * derived business value is unchanged. Does not change onChange semantics. */ onSelectorValueChange?: (value: SelectorValues) => void; /** 一次选择只回调一次;跨步骤宿主可同时保存第二个参数中的界面草稿。 */ onChange: (value: SkuValue, change?: SKUOptionsSelectionChange) => void; /** 自定义滚动容器 */ customScrollParent?: HTMLElement | string; /** 自定义样式 */ style?: React.CSSProperties; /** 自定义配置 */ customConfig?: { /** 弹窗宽度 */modalWidth?: number | string; /** 弹窗展示形态 */ modalRenderType?: 'modal' | 'drawer'; /** 选项布局 */ selectorLayout?: LayoutConfig | null; }; /** 可选展示契约;不传时保持既有 DOM、样式与行为。 */ presentation?: SKUOptionsSelectionPresentation; /** 可选交互策略;不传时保持既有行为。 */ behavior?: SKUOptionsSelectionBehavior; /** 复杂展示的插槽;优先级高于 presentation。 */ slots?: SKUOptionsSelectionSlots; /** 主题 */ theme: { token?: { colorPrimary?: string; colorPrimaryBg?: string; }; }; } interface SKUOptionsSelectionRef { validate: (groupIds?: ReadonlyArray) => Promise>; getValues: () => Record; getTransformValues: () => SkuValue; } interface DataSource { /** 商品id */ id?: number; /** 生产编码 */ production_code?: string; /** 单规格组数据 */ option_group?: Array; /** 组合规格组装后的数据 */ variant?: Array; /** 组合规格组数据 */ variant_group?: Array; /** 套餐商品组数据 */ bundle_group?: Array; } interface OptionGroupMetadata { /** 是否启用高级设置 */ advanced_settings_enabled?: 0 | 1; /** Option 种类数限制 */ option_types_config?: { min?: number; max?: number; [key: string]: unknown; }; /** 保留后端返回的其他元数据 */ [key: string]: unknown; } /** * 单规格组数据 */ interface OptionGroupItem { /** 创建者id */ create_account_id?: number; /** 创建时间 */ created_at?: string; /** 删除时间 */ deleted_at?: string | null; /** 模板id */ template_id?: number; /** 更新者id */ update_account_id?: number; /** 更新时间 */ updated_at?: string; /** 单规格组id */ id?: number; /** 是否启用 */ is_enabled?: 0 | 1; /** 是否多选 */ is_multiple?: 0 | 1; /** 最大选择数量 */ max_quantity?: number; /** 最小选择数量 */ min_quantity?: number; /** 高级设置元数据 */ metadata?: OptionGroupMetadata; /** 单规格组名称 */ name?: string; /** 单规格组下规格数据 */ option_item?: Array; /** 商品id */ product_id?: number; /** 是否必选 */ required?: 0 | 1; /** 店铺id */ shop_id?: number; /** 排序 */ sort?: number; /** 状态 */ status?: 0 | 1; } /** * 单规格组下选项数据 */ interface OptionItem { /** 创建者id */ create_account_id?: number; /** 创建时间 */ created_at?: string; /** 删除时间 */ deleted_at?: string | null; /** 模板id */ template_id?: number; /** 更新者id */ update_account_id?: number; /** 更新时间 */ updated_at?: string; /** 加价 */ add_price?: string; /** 封面 */ cover?: string; /** 描述 */ description?: string; /** 规格id */ id?: number; /** 是否启用 */ is_enabled?: 0 | 1; /** 最大选择数量 */ max_quantity?: number; /** 最小选择数量 */ min_quantity?: number; /** 规格名称 */ name?: string; /** 规格组id */ option_group_id?: number; /** 原价 */ original_price?: string; /** 商品id */ product_id?: number; /** 生产编码 */ production_code?: string; /** 店铺id */ shop_id?: number; /** 排序 */ sort?: number; /** 状态 */ status?: 0 | 1; } /** * 组合规格组数据 */ interface VariantGroupItem { /** 创建者id */ create_account_id?: number; /** 创建时间 */ created_at?: string; /** 删除时间 */ deleted_at?: string | null; /** 更新者id */ update_account_id?: number; /** 更新时间 */ updated_at?: string; /** 组合规格组id */ id?: number; /** 组合规格组名称 */ name?: string; /** 位置id */ position_id?: number; /** 商品id */ product_id?: number; /** 店铺id */ shop_id?: number; /** 排序 */ sort?: number; /** 状态 */ status?: 0 | 1; /** 组合规格组下选项数据 */ variant_item?: Array; } /** * 组合规格组下选项数据 */ interface VariantItem { /** 创建者id */ create_account_id?: number; /** 创建时间 */ created_at?: string; /** 删除时间 */ deleted_at?: string | null; /** 更新者id */ update_account_id?: number; /** 更新时间 */ updated_at?: string; /** 店铺id */ shop_id?: number; /** 排序 */ sort?: number; /** 规格id */ id?: number; /** 是否默认 */ is_default?: 0 | 1; /** 变体名称 */ name?: string; /** 位置id */ position_id?: number; /** 商品id */ product_id?: number; /** 状态 */ status?: 0 | 1; /** 组合规格组id */ variant_group_id?: number; } /** * 组合规格商品数据 */ interface VariantProductItem { /** 创建者id */ create_account_id?: number; /** 创建时间 */ created_at?: string; /** 更新者id */ update_account_id?: number; /** 更新时间 */ updated_at?: string; /** 条形码 */ barcode?: string; /** 基础价格 */ base_price?: string; /** 箱规数量 */ box_specification_quantity?: number; /** 编码 */ code?: string; /** 成本价格 */ cost_price?: string; /** 封面 */ cover?: string; /** 描述 */ description?: string | null; /** 是否禁用 */ disabled?: 0 | 1; /** 组合规格商品id */ id?: number; /** 是否收税 */ is_charge_tax?: 0 | 1; /** 是否发货 */ is_delivery?: 0 | 1; /** 是否收税 */ is_gst?: 0 | 1; /** 是否跟踪库存 */ is_track?: 0 | 1; /** 名称 */ name?: Record; /** 开售重量 */ open_sold_weight?: number; /** 原价 */ original_price?: string; /** 是否超卖 */ over_sold?: 0 | 1; /** 价格 */ price?: string; /** 商品id */ product_id?: number; /** 生产编码 */ production_code?: string; /** 折扣类型 */ rebate_type?: string; /** 折扣值 */ rebate_value?: number; /** 标题 */ title?: Record; /** 单位 */ unit?: string; /** 单位值 */ unit_value?: number; /** 重量单位 */ weight_unit?: string; /** 重量值 */ weight_value?: string; } /** * 套餐商品组数据 */ interface BundleGroupItem { /** 店铺id */ shop_id?: number; /** 排序 */ sort?: number; /** 套餐id */ id?: number; /** 最大选择数量 */ max_quantity?: number; /** 最小选择数量 */ min_quantity?: number; /** 套餐名称 */ name?: string; /** 商品id */ product_id?: number; /** 套餐商品组数据 */ bundle_item?: Array; } /** * 套餐商品组下选项数据 */ interface BundleItem { /** 店铺id */ shop_id?: number; /** 排序 */ sort?: number; /** 条形码 */ barcode?: string; /** 套餐商品id */ bundle_product_id?: number; /** 套餐商品变体id */ bundle_variant_id?: number; /** 编码 */ code?: string; /** 封面 */ cover?: string; /** 扩展id */ extension_id?: number; /** 扩展类型 */ extension_type?: string; /** 套餐商品组id */ group_id?: number; /** 套餐商品id */ id: string | number; /** 是否跟踪库存 */ is_track?: 0 | 1; /** 最大选择数量 */ max_quantity?: number; /** 单规格组数据 */ option_group?: Array; /** 是否允许超卖 */ over_sold?: 0 | 1; /** 价格 */ price?: string; /** 价格类型: mark_up==>加价 | mark_down==>减价 */ price_type?: 'mark_up' | 'mark_down'; /** 价格类型扩展: product_price==>商品价格 */ price_type_ext?: '' | 'product_price'; /** 商品id */ product_id?: number; /** 生产编码 */ production_code?: string; /** 商品价格 */ product_price?: string; /** 商品副标题 */ product_subtitle?: string; /** 库存数量 */ stock_quantity?: number; /** 标题 */ title?: string; } /** * sku value */ interface SkuValue { /** 商品id */ product_id: number; /** 多规格商品id */ product_variant_id: number; /** 多规格商品选项字符串 */ product_option_string?: string; /** 当前商品或组合规格商品的生产编码 */ production_code?: string; /** 套餐商品组数据 */ bundle: Array; /** 价格 */ price?: string | number; /** 单规格组数据 */ option: Array; } /** * Selector值原子类型 */ interface SelectorValueAtom { /** 数据 */ data: Record; /** 数量 */ quantity: number; /** 总价 */ totalPrice: string | number; /** 值 */ value: number | string; } type SelectorValues = Readonly>; //#endregion export { IProps, SKUOptionsSelectionBehavior, SKUOptionsSelectionInitializationPolicy, SKUOptionsSelectionPresentation, SKUOptionsSelectionRef, SKUOptionsSelectionSlots, SkuValue, VariantSelectionDraft };