import type { LocaleProps, Schema, ThemeProps } from 'jamis-core'; import type { SizeUnit } from '../../types'; export type { default as CodeMirror } from 'codemirror'; export interface VariableItem { label: string; value?: string; children?: Array; type?: string; tag?: string; selectMode?: 'tree' | 'tabs'; [key: string]: any; } export interface FuncGroup { groupName: string; items: Array; } export interface FuncItem { name: string; example?: string; description?: string; [propName: string]: any; } export interface FormulaEditorProps extends ThemeProps, LocaleProps { onChange?: (value: string) => void; value?: string; /** * evalMode 即直接就是表达式,否则 * 需要 ${这里面才是表达式} * 默认为 true */ evalMode?: boolean; /** * 用于提示的变量集合,默认为空 */ variables?: Array; /** * 变量展现模式,可选值:'tabs' | 'tree' */ variableMode?: 'tabs' | 'tree'; /** * 函数集合,默认不需要传,即 jamis-formula 里面那个函数 * 如果有扩充,则需要传。 */ functions?: Array; /** * 顶部标题,默认为表达式 */ header: string | Schema; variableClassName?: string; functionClassName?: string; /** * 当前输入项字段 name: 用于避免循环绑定自身导致无限渲染 */ selfVariableName?: string; } export interface FunctionsProps { name: string; items: FunctionProps[]; } export interface FunctionProps { name: string; intro: string; usage: string; example: string; } export interface FormulaPickerProps extends FormulaEditorProps { size?: SizeUnit; /** * 编辑器标题 */ title?: string; /** * 按钮图标 */ icon?: string; /** * 控件模式 */ mode?: 'button' | 'input-button' | 'input-group'; /** * 边框模式,全边框,还是半边框,或者没边框。 */ borderMode?: 'full' | 'half' | 'none'; /** * 按钮Label,inputMode为button时生效 */ btnLabel?: string; /** * 按钮样式 */ level?: 'info' | 'success' | 'warning' | 'danger' | 'link' | 'primary' | 'dark' | 'light'; /** * 按钮大小 */ btnSize?: 'xs' | 'sm' | 'md' | 'lg'; /** * 禁用状态 */ disabled?: boolean; /** * 是否允许输入,否需要点击fx在弹窗中输入 */ allowInput?: boolean; /** * 占位文本 */ placeholder?: string; /** * 可清除 */ clearable?: boolean; /** * 支持通过上下文变量配置value */ source?: string; /** * 外层透传的 data,和source配合使用 */ data?: any; /** * 公式弹出的时候,可以外部设置 variables 和 functions */ onPickerOpen?: (props: FormulaPickerProps) => any; children?: (props: { onClick: (e: React.MouseEvent) => void; setState: (state: any) => void; isOpened: boolean; }) => JSX.Element; onConfirm?: (value?: any) => void; onRef?: (node: any) => void; }