/** * @file 开关 + 更多编辑组合控件 * 使用时需关注所有的配置项是一个object还是整个data中,可使用bulk来区分 * */ import React from 'react'; import type { Action } from 'amis'; import type { SchemaCollection } from 'amis'; import type { IScopedContext } from 'amis-core'; import type { FormSchema } from 'amis'; import type { FormControlProps } from 'amis-core'; export interface SwitchMoreProps extends FormControlProps { className?: string; form?: Omit; formType: 'extend' | 'dialog' | 'pop'; body?: SchemaCollection; rootClose?: boolean; autoFocus?: boolean; overlay?: boolean; container?: HTMLElement | (() => HTMLElement); target?: React.ReactNode | Function; removable?: boolean; hiddenOnDefault?: boolean; /** * * bulk是指extend的内容是和name为平级还是子级,会产生几种情况: * 1. 有name 且bulk为false时,代表这个属性不是一个boolean值,而是一个object,有值=开启,无值=关闭 {kaiguan: {extend: xxx}} * 2. 有name 且bulk为true时,代表这个属性本身是开关,但还有其他同级别相关属性放在扩展中,因此需要bulk更新方式进行批量更新 {kaiguan: true, extend: xxx} * 3. 没有name 且bulk为true时,代表没有属性对应这个开关,开关只是为了表达配置交互层面的收纳含义 {extend: xxx} * 注意:不会出现没有name 且bulk为false的情况 */ bulk?: boolean; onRemove?: (e: React.UIEvent | void) => void; onClose: (e: React.UIEvent | void) => void; clearChildValuesOnOff?: boolean; defaultData?: any; isChecked?: (options: { data: any; value: any; name?: string; bulk?: boolean; }) => boolean; trueValue?: any; falseValue?: any; } interface SwitchMoreState { /** * 是否展示更多编辑内容 */ show: boolean; /** * 是否开启编辑 */ checked: boolean; /** * 子表单的数据key */ childFormNames: string[]; } export default class SwitchMore extends React.Component { static defaultProps: Pick; overlay: HTMLElement | null; formNames: null | Array; constructor(props: SwitchMoreProps); initState(): { checked: boolean; show: boolean; childFormNames: any[]; }; getFormItemNames(): any[]; overlayRef(ref: any): void; openPopover(): void; toogleExtend(): void; closePopover(): void; handleDelete(e: React.UIEvent | void): void; handleSwitchChange(checked: boolean): void; /** * 返回子表单的数据,如果是同级,直接返回当前数据域,否则返回当前数据作为子表单 */ getExtendValues(): any; /** * 打开后,首先遵循默认值设置,之后遵循选中值设置 * 当都不设置时,要看是否是object类型,是object类型,需要是空对象 * * 关闭后,先遵循关闭值设置,否则一切回归原始删除属性状态 */ getInitTureValue(): any; /** * 弹窗配置的提交 * @param values */ handleSubmit(values: any): void; handleAction(e: React.UIEvent | void, action: Action, data: object, throwErrors?: boolean, delegate?: IScopedContext): void; renderActions(): any[] | null; renderPopover(): React.JSX.Element; renderExtend(): React.JSX.Element | null; renderDialogMore(): { type: string; btnLabel: string; className: string; itemClassName: string; icon: string; form: { type: string; wrapWithPanel: boolean; panelClassName: string; actionsClassName: string; wrapperComponent: string; mode: string; horizontal: { justify: boolean; left: number; }; autoFocus: boolean | undefined; formLazyChange: boolean; preventEnterSubmit: boolean; submitOnChange: boolean; canAccessSuperData: boolean | undefined; data: any; title: any; }; }; renderForm(): { type: string; wrapWithPanel: boolean; panelClassName: string; actionsClassName: string; wrapperComponent: string; mode: string; horizontal: { justify: boolean; left: number; }; autoFocus: boolean | undefined; formLazyChange: boolean; preventEnterSubmit: boolean; submitOnChange: boolean; canAccessSuperData: boolean | undefined; data: any; }; renderMoreSection(): React.JSX.Element | null; render(): React.JSX.Element | null; } export declare class SwitchMoreRenderer extends SwitchMore { } export {};