Process 处理过程
展示已整理的步骤、状态、耗时和可展开详情。
交互示例
用法
<Process
title="资料整理"
steps={steps}
expandedIds={expandedIds}
onExpandedChange={setExpandedIds}
/>
行为与接入
每个步骤使用稳定 id 并显式提供 status。标题、说明、elapsedMs 和 details 均来自调用方;耗时不会在组件内自行计时。
展开可使用受控的 expandedIds + onExpandedChange,也可通过 defaultExpandedIds 设置一次性初始值。默认收起;没有详情的项不提供展开操作。
过程组件不执行任务、不解析工具协议,也不根据步骤名称推断业务行为。多组过程由页面组合多个 Process。
variant="trace" 用透明工具行显示图标、名称、可选的 sourceLabel 来源标签和状态,不绘制卡片背景。有 details 的工具行可点击展开,默认收起;流式更新不重置用户选择。可以与 compact 的身份/思考行组合,保留实际执行顺序。标签来自宿主,组件不推断执行者或工具归属。
variant="timeline" 将已有步骤组合成竖向状态节点和连接线,标题右侧呈现该步骤的说明;不会额外生成“已完成”等成功段落。card 保留完整状态面板,两种形态共用同一份步骤、操作与展开状态。
timeline 步骤可设置 actionsPlacement="trailing",把已有 actions 放到标题同行、说明之后,适合停止或重新开始等简短操作。默认 below 保持步骤下方位置;其他形态仍在下方展示。操作沿用 ChatAction 的禁用、忙碌、可访问提示和点击事件,不改变步骤状态或自动执行任务。
compact 运行状态的文字复用 Design ShimmerText,每 4 秒从首字到尾字扫过一次白色高光;状态图标保持静止。完成、失败、取消、待处理或开启系统减少动态效果时,文字保持静态。
单项紧凑过程可传 identityPlacement="inline",把已有 identity 内容放在状态同行左侧。step.statusText 可提供适合当前公开业务状态的显示文案;它不改变 status,也不会让组件生成新的状态或时长。多项或非 compact 仍使用独立身份标题。
compact / trace 的 step.icon 接收 @unif/react-native-icons 的组件引用(如 FileOutlined、ImageOutlined),设为 null 时不显示图标;省略时保持原状态图标。statusText: '' 隐藏重复状态文字,标题仍须明确说明当前动作。公开文字与各批 Process 由调用方按顺序组合,整轮内容无需套在一个折叠入口内。
compactDensity="dense" 适用于消息内连续的文字过程行:取消标题上下内边距,最小行高为 24;默认 comfortable 保持 44 的行高。两者保留相同的展开、状态和操作行为;隐藏视觉状态文字时,读屏仍能读取真实状态。
工具步骤使用 variant="trace":图标、标题和真实状态组成透明文字行,展开详情不绘制边框或分隔线。具体工具图标由调用方的 step.icon 提供。
紧凑过程与材质
variant="compact" 使用轻量过程行:标题旁默认显示状态文字,有详情时整行可展开,详情区域以 180 布局单位的缩放预算限制高度并独立滚动。流式更新保留展开选择,完成、失败或取消由外部真实状态决定;不由组件生成推理内容或推测业务成功。默认 card 保留完整步骤面板。
原生玻璃控件的祖先应保持 opacity: 1,不要对整个材质子树叠加透明度动画。当前 compact 详情使用淡入容器;details 需要组合玻璃控件时使用 card 或 timeline。
<Process variant="compact" steps={publicSteps} />
card 与 timeline 的背景复用共享 GlassLayer;compact 与 trace 仍是嵌入正文的透明过程行。步骤状态、操作和展开行为保持一致。
API
查看完整 TypeScript 类型
以下内容由包根公开类型生成,与当前源码保持一致。
import type { ComponentType } from 'react';
import type { IconProps } from '@unif/react-native-icons';
import type { ReactNode } from 'react';
import type { StyleProp, ViewStyle } from 'react-native';
import type { ChatAction } from '@unif/react-native-chat';
export type ProcessStepStatus =
'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
export interface ProcessStep {
id: string;
title: string;
status: ProcessStepStatus;
/** compact / trace 的活动图标;null 不显示,省略时沿状态呈现。 */
icon?: ComponentType<IconProps> | null;
/** 调用者提供的状态显示文案;不改变 status 的语义。 */
statusText?: string;
/** trace 中显示的来源标签,由调用方提供,如“本机”。 */
sourceLabel?: string;
description?: string;
elapsedMs?: number;
details?: ReactNode;
actions?: readonly ChatAction[];
/** timeline 中 trailing 将操作放在说明后;默认 below,其它形态仍置于下方。 */
actionsPlacement?: 'below' | 'trailing';
}
export interface ProcessBaseProps {
/** card 为状态面板;compact 为单行过程;timeline 为连续步骤;trace 为透明工具行。 */
variant?: 'card' | 'compact' | 'timeline' | 'trace';
/** compact 文字密度;dense 用于与行内文字相邻的公开过程。 */
compactDensity?: 'comfortable' | 'dense';
steps: readonly ProcessStep[];
title?: string;
identity?: ReactNode;
/** inline 仅用于 compact 单项,让身份与状态处于同一行。 */
identityPlacement?: 'heading' | 'inline';
style?: StyleProp<ViewStyle>;
testID?: string;
}
export interface ProcessControlledExpansion {
expandedIds: readonly string[];
onExpandedChange(ids: readonly string[]): void;
defaultExpandedIds?: never;
}
export interface ProcessLocalExpansion {
expandedIds?: never;
defaultExpandedIds?: readonly string[];
onExpandedChange?(ids: readonly string[]): void;
}
export type ProcessProps = ProcessBaseProps &
(ProcessControlledExpansion | ProcessLocalExpansion);