import type { ReactNode } from 'react'; /** 选择器的展示字段;只影响回显,不改变 labelInValue 的提交值。@author nokecy */ export type SelectDisplayField = 'value' | 'label'; /** 从选择值提取展示文字;编码展示不能因描述为空或过期而改变。@author nokecy */ export declare const formatSelectDisplay: (value: any, displayField?: SelectDisplayField) => string; /** 给选择组件声明与其回显一致的表格格式化器,组件别名和不同页面各自生效。@author nokecy */ export declare const withReadOnlyFormatter: (component: T, formatter: ReadOnlyFormatter) => T & { readOnlyFormatter: ReadOnlyFormatter; }; export type ReadOnlyFormatterCtx = { /** 列的 x-component-props(headerName/width/options/format 等) */ columnProps: any; /** 内层数据字段的 schema(可读 enum / x-component-props) */ fieldSchema: any; /** * 运行时才确定的选项(field.setDataSource / setFieldState 写入的 dataSource)。 * 懒挂载格子没有自己的 Formily 字段时,由调用方取同列已创建字段的选项带进来;有值时优先于 schema 静态选项。 */ dataSource?: any[]; }; export type ReadOnlyFormatter = (value: any, ctx: ReadOnlyFormatterCtx) => string; /** * 兜底格式化器:注册表里没有的组件(业务自定义的选择器、输入框等),可编辑列按它出懒挂载文本。 * * 显示与控件失焦时看到的一致:原始值原样显示;labelInValue 对象 / 解构字段({value,label})显示 label, * 没有 label 才显示 value;数组逐个显示后逗号拼接。显示需要按编码查名称等特殊逻辑的组件, * 消费方用 registerReadOnlyFormatter 注册专用格式化器覆盖。@author nokecy */ export declare const fallbackFormatter: ReadOnlyFormatter; /** 消费方扩展自定义只读列的显示逻辑 */ export declare const registerReadOnlyFormatter: (component: string, formatter: ReadOnlyFormatter) => void; /** 值 -> 名称表:对象 `{ '10': '参与' }`,或与 Select 同形的选项数组 `[{ label, value }]` */ export type ReadOnlyLabels = Record | Array<{ label?: any; value?: any; }>; /** * 给业务自定义选择器登记「值 -> 名称」,ArrayTable 未激活的格子与只读列按名称出文本。 * * 业务组件(如「执行动作」「是否参与校验」这类固定选项的选择器)不在内置注册表里, * 格子文本会走兜底格式化器把原值原样显示(10、00 这类编码)。在组件模块里调用一次即可, * 所有用到该 x-component 的列都生效;同一组件在不同 Schema 里注册名不同时传名字数组。 * 按 String 宽松比对(容忍后端返回数字/字符串漂移);labelInValue 对象显示其 label; * 数组逐个映射后逗号拼接;表里没有的值原样显示。@author nokecy */ export declare const registerReadOnlyLabels: (component: string | string[], labels: ReadOnlyLabels) => void; /** 只读渲染器:按值出一段 React 内容(如组件自己的阅读态 Tag),格子未激活和只读列都用它显示 */ export type ReadOnlyRenderer = (value: any, ctx: ReadOnlyFormatterCtx) => ReactNode; /** * 给业务自定义组件登记只读渲染器。登记后 ArrayTable 可编辑列未激活的格子、只读列都渲染它的返回内容, * 与组件自己的阅读态一致(例如带颜色的 Tag),仍不挂 Formily 字段树。空值不调用渲染器(出占位/留空)。 * 只要文字时用 registerReadOnlyLabels;两者都登记时显示走渲染器。@author nokecy */ export declare const registerReadOnlyRenderer: (component: string | string[], renderer: ReadOnlyRenderer) => void; /** 取某组件类型的只读渲染器,未登记返回 null */ export declare const getReadOnlyRenderer: (component: string | undefined) => ReadOnlyRenderer | null; /** * 取某组件类型的只读格式化器。命中返回函数,未命中返回 null(调用方回退 AgField)。 */ export declare const getReadOnlyFormatter: (component: string | undefined, components?: Record) => ReadOnlyFormatter | null;