///
///
/**
* @file 公式编辑器
*/
import React from 'react';
import { ThemeProps, LocaleProps } from 'amis-core';
import { FormulaPlugin } from './plugin';
export interface VariableItem {
label: string;
value?: string;
children?: Array;
type?: string;
tag?: string;
selectMode?: 'tree' | 'tabs';
}
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';
/**
* 函数集合,默认不需要传,即 amis-formula 里面那个函数
* 如果有扩充,则需要传。
*/
functions?: Array;
/**
* 是否覆盖默认函数集合
*/
hiddenDefFunctions?: boolean;
/**
* 不校验公式
*/
uncheckFormula?: boolean;
/**
* 顶部标题,默认为表达式
*/
header: string;
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 FormulaState {
focused: boolean;
}
export declare class FormulaEditor extends React.Component {
state: FormulaState;
editorPlugin?: FormulaPlugin;
static buildDefaultFunctions(doc: Array<{
namespace: string;
name: string;
[propName: string]: any;
}>): FuncGroup[];
static defaultProps: Pick;
static replaceStrByIndex(str: string, idx: number, key: string, replaceKey: string): string;
static getRegExpByMode(evalMode: boolean, key: string): RegExp;
static highlightValue(value: string, variables: Array, evalMode?: boolean): {
html: string;
} | undefined;
componentWillUnmount(): void;
handleFocus(): void;
handleBlur(): void;
insertValue(value: any, type: 'variable' | 'func'): void;
handleEditorMounted(cm: any, editor: any): void;
validate(): any;
handleFunctionSelect(item: FuncItem): void;
handleVariableSelect(item: VariableItem): void;
handleOnChange(value: any): void;
editorFactory(dom: HTMLElement, cm: any): import("codemirror").Editor;
render(): JSX.Element;
}
declare const _default: {
new (props: Omit & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps): {
ref: any;
childRef(ref: any): void;
getWrappedInstance(): any;
render(): JSX.Element;
context: any;
setState(state: {} | ((prevState: Readonly<{}>, props: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
forceUpdate(callback?: (() => void) | undefined): void;
readonly props: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps> & Readonly<{
children?: import("react").ReactNode;
}>;
state: Readonly<{}>;
refs: {
[key: string]: import("react").ReactInstance;
};
componentDidMount?(): void;
shouldComponentUpdate?(nextProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, nextState: Readonly<{}>, nextContext: any): boolean;
componentWillUnmount?(): void;
componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
getSnapshotBeforeUpdate?(prevProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, prevState: Readonly<{}>): any;
componentDidUpdate?(prevProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, prevState: Readonly<{}>, snapshot?: any): void;
componentWillMount?(): void;
UNSAFE_componentWillMount?(): void;
componentWillReceiveProps?(nextProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, nextContext: any): void;
UNSAFE_componentWillReceiveProps?(nextProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, nextContext: any): void;
componentWillUpdate?(nextProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, nextState: Readonly<{}>, nextContext: any): void;
UNSAFE_componentWillUpdate?(nextProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, nextState: Readonly<{}>, nextContext: any): void;
};
displayName: string;
contextType: import("react").Context;
ComposedComponent: import("react").ComponentType & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps> & {
themeKey?: string | undefined;
}>;
} & import("hoist-non-react-statics").NonReactStatics & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps> & {
themeKey?: string | undefined;
}, {}> & {
ComposedComponent: import("react").ComponentType & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps> & {
themeKey?: string | undefined;
};
};
export default _default;