mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
补充 Schema
This commit is contained in:
parent
a7d7bdf189
commit
63653a5a98
@ -53,6 +53,26 @@ import {InputGroupControlSchema} from './InputGroup';
|
||||
import {ListControlSchema} from './List';
|
||||
import {LocationControlSchema} from './Location';
|
||||
import {MatrixControlSchema} from './Matrix';
|
||||
import {NestedSelectControlSchema} from './NestedSelect';
|
||||
import {NumberControlSchema} from './Number';
|
||||
import {PanelControlSchema} from './Panel';
|
||||
import {PickerControlSchema} from './Picker';
|
||||
import {RadiosControlSchema} from './Radios';
|
||||
import {RangeControlSchema} from './Range';
|
||||
import {RatingControlSchema} from './Rating';
|
||||
import {RepeatControlSchema} from './Repeat';
|
||||
import {RichTextControlSchema} from './RichText';
|
||||
import {ServiceControlSchema} from './Service';
|
||||
import {StaticControlSchema} from './Static';
|
||||
import {SubFormControlSchema} from './SubForm';
|
||||
import {SwitchControlSchema} from './Switch';
|
||||
import {TableControlSchema} from './Table';
|
||||
import {TabsControlSchema} from './Tabs';
|
||||
import {TabsTransferControlSchema} from './TabsTransfer';
|
||||
import {TagControlSchema} from './Tag';
|
||||
import {TransferControlSchema} from './Transfer';
|
||||
import {TreeControlSchema} from './Tree';
|
||||
import {TreeSelectControlSchema} from './TreeSelect';
|
||||
|
||||
export type FormControlType =
|
||||
| 'array'
|
||||
@ -88,13 +108,33 @@ export type FormControlType =
|
||||
| 'list'
|
||||
| 'location'
|
||||
| 'matrix'
|
||||
| 'nested-select'
|
||||
| 'number'
|
||||
| 'panel'
|
||||
| 'picker'
|
||||
| 'radios'
|
||||
| 'range'
|
||||
| 'rating'
|
||||
| 'repeat'
|
||||
| 'rich-text'
|
||||
| 'select'
|
||||
| 'service'
|
||||
| 'static'
|
||||
| 'form'
|
||||
| 'switch'
|
||||
| 'table'
|
||||
| 'tabs'
|
||||
| 'tabs-transfer'
|
||||
| 'tag'
|
||||
| 'text'
|
||||
| 'password'
|
||||
| 'email'
|
||||
| 'url'
|
||||
| 'select'
|
||||
| 'multi-select'
|
||||
| 'textarea';
|
||||
| 'textarea'
|
||||
| 'transfer'
|
||||
| 'tree'
|
||||
| 'tree-select';
|
||||
|
||||
export type FormControlSchema =
|
||||
| ArrayControlSchema
|
||||
@ -128,9 +168,29 @@ export type FormControlSchema =
|
||||
| ListControlSchema
|
||||
| LocationControlSchema
|
||||
| MatrixControlSchema
|
||||
| TextControlSchema
|
||||
| NestedSelectControlSchema
|
||||
| NumberControlSchema
|
||||
| PanelControlSchema
|
||||
| PickerControlSchema
|
||||
| RadiosControlSchema
|
||||
| RangeControlSchema
|
||||
| RatingControlSchema
|
||||
| RichTextControlSchema
|
||||
| RepeatControlSchema
|
||||
| SelectControlSchema
|
||||
| TextareaControlSchema;
|
||||
| ServiceControlSchema
|
||||
| SubFormControlSchema
|
||||
| SwitchControlSchema
|
||||
| StaticControlSchema
|
||||
| TableControlSchema
|
||||
| TabsControlSchema
|
||||
| TabsTransferControlSchema
|
||||
| TagControlSchema
|
||||
| TextControlSchema
|
||||
| TextareaControlSchema
|
||||
| TransferControlSchema
|
||||
| TreeControlSchema
|
||||
| TreeSelectControlSchema;
|
||||
|
||||
export interface FormBaseControl extends Omit<BaseSchema, 'type'> {
|
||||
/**
|
||||
|
@ -14,11 +14,23 @@ import {
|
||||
string2regExp
|
||||
} from '../../utils/helper';
|
||||
import {dataMapping} from '../../utils/tpl-builtin';
|
||||
import {OptionsControl, OptionsControlProps} from '../Form/Options';
|
||||
import {
|
||||
FormOptionsControl,
|
||||
OptionsControl,
|
||||
OptionsControlProps
|
||||
} from '../Form/Options';
|
||||
import {Option, Options} from '../../components/Select';
|
||||
import Input from '../../components/Input';
|
||||
import {findDOMNode} from 'react-dom';
|
||||
|
||||
/**
|
||||
* Nested Select
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/nested-select
|
||||
*/
|
||||
export interface NestedSelectControlSchema extends FormOptionsControl {
|
||||
type: 'nested-select';
|
||||
}
|
||||
|
||||
export interface NestedSelectProps extends OptionsControlProps {
|
||||
cascade?: boolean;
|
||||
withChildren?: boolean;
|
||||
@ -40,7 +52,7 @@ export default class NestedSelectControl extends React.Component<
|
||||
withChildren: false,
|
||||
searchPromptText: '输入内容进行检索',
|
||||
checkAll: true,
|
||||
checkAllLabel: '全选',
|
||||
checkAllLabel: '全选'
|
||||
};
|
||||
target: any;
|
||||
input: HTMLInputElement;
|
||||
|
@ -1,8 +1,37 @@
|
||||
import React from 'react';
|
||||
import {FormItem, FormControlProps} from './Item';
|
||||
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
||||
import cx from 'classnames';
|
||||
import {filter} from '../../utils/tpl';
|
||||
import NumberInput from '../../components/NumberInput';
|
||||
import {FormOptionsControl} from './Options';
|
||||
|
||||
/**
|
||||
* 数字输入框
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/number
|
||||
*/
|
||||
export interface NumberControlSchema extends FormBaseControl {
|
||||
type: 'number';
|
||||
|
||||
/**
|
||||
* 最大值
|
||||
*/
|
||||
max?: number;
|
||||
|
||||
/**
|
||||
* 最小值
|
||||
*/
|
||||
min?: number;
|
||||
|
||||
/**
|
||||
* 步长
|
||||
*/
|
||||
step?: number;
|
||||
|
||||
/**
|
||||
* 精度
|
||||
*/
|
||||
precision?: number;
|
||||
}
|
||||
|
||||
export interface NumberProps extends FormControlProps {
|
||||
placeholder?: string;
|
||||
|
@ -1,8 +1,32 @@
|
||||
import React from 'react';
|
||||
import {Renderer, RendererProps} from '../../factory';
|
||||
import Panel from '../Panel';
|
||||
import Panel, {PanelSchema} from '../Panel';
|
||||
import {Schema} from '../../types';
|
||||
import cx from 'classnames';
|
||||
import {FormBaseControl, FormControlSchema} from './Item';
|
||||
|
||||
/**
|
||||
* 容器空间
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/contaier
|
||||
*/
|
||||
export interface PanelControlSchema extends FormBaseControl, PanelSchema {
|
||||
type: 'panel';
|
||||
|
||||
/**
|
||||
* 表单项集合
|
||||
*/
|
||||
controls?: Array<FormControlSchema>;
|
||||
|
||||
/**
|
||||
* @deprecated 请用类型 tabs
|
||||
*/
|
||||
tabs?: any;
|
||||
|
||||
/**
|
||||
* @deprecated 请用类型 fieldSet
|
||||
*/
|
||||
fieldSet?: any;
|
||||
}
|
||||
|
||||
@Renderer({
|
||||
test: /(^|\/)form(?:\/.+)?\/control\/(?:\d+\/)?panel$/,
|
||||
|
@ -1,5 +1,10 @@
|
||||
import React from 'react';
|
||||
import {OptionsControl, OptionsControlProps, Option} from './Options';
|
||||
import {
|
||||
OptionsControl,
|
||||
OptionsControlProps,
|
||||
Option,
|
||||
FormOptionsControl
|
||||
} from './Options';
|
||||
import cx from 'classnames';
|
||||
import Button from '../../components/Button';
|
||||
import {SchemaNode, Schema, Action} from '../../types';
|
||||
@ -18,6 +23,47 @@ import {filter} from '../../utils/tpl';
|
||||
import {Icon} from '../../components/icons';
|
||||
import {isEmpty} from '../../utils/helper';
|
||||
import {dataMapping} from '../../utils/tpl-builtin';
|
||||
import {SchemaCollection, SchemaTpl} from '../../Schema';
|
||||
import {CRUDSchema} from '../CRUD';
|
||||
|
||||
/**
|
||||
* Picker
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/picker
|
||||
*/
|
||||
export interface PickerControlSchema extends FormOptionsControl {
|
||||
type: 'picker';
|
||||
|
||||
/**
|
||||
* 可用来生成选中的值的描述文字
|
||||
*/
|
||||
labelTpl?: SchemaTpl;
|
||||
|
||||
/**
|
||||
* 建议用 labelTpl
|
||||
* 选中一个字段名用来作为值的描述文字
|
||||
*/
|
||||
labelField?: string;
|
||||
|
||||
/**
|
||||
* 选一个可以用来作为值的字段。
|
||||
*/
|
||||
valueField?: string;
|
||||
|
||||
/**
|
||||
* 弹窗选择框详情。
|
||||
*/
|
||||
pickerSchema?: CRUDSchema;
|
||||
|
||||
/**
|
||||
* 弹窗模式,dialog 或者 drawer
|
||||
*/
|
||||
modalMode?: 'dialog' | 'drawer';
|
||||
|
||||
/**
|
||||
* 内嵌模式,也就是说不弹框了。
|
||||
*/
|
||||
embed?: boolean;
|
||||
}
|
||||
|
||||
export interface PickerProps extends OptionsControlProps {
|
||||
modalMode: 'dialog' | 'drawer';
|
||||
|
@ -2,10 +2,28 @@ import React from 'react';
|
||||
import {FormItem, FormControlProps} from './Item';
|
||||
import cx from 'classnames';
|
||||
import Radios from '../../components/Radios';
|
||||
import {OptionsControl, OptionsControlProps, Option} from './Options';
|
||||
import {
|
||||
OptionsControl,
|
||||
OptionsControlProps,
|
||||
Option,
|
||||
FormOptionsControl
|
||||
} from './Options';
|
||||
import {autobind, isEmpty} from '../../utils/helper';
|
||||
import {dataMapping} from '../../utils/tpl-builtin';
|
||||
|
||||
/**
|
||||
* Radio 单选框。
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/radios
|
||||
*/
|
||||
export interface RadiosControlSchema extends FormOptionsControl {
|
||||
type: 'radios';
|
||||
|
||||
/**
|
||||
* 每行显示多少个
|
||||
*/
|
||||
columnsCount?: number;
|
||||
}
|
||||
|
||||
export interface RadiosProps extends OptionsControlProps {
|
||||
placeholder?: any;
|
||||
columnsCount?: number;
|
||||
|
@ -2,10 +2,39 @@ import React from 'react';
|
||||
import isNumber from 'lodash/isNumber';
|
||||
import isObject from 'lodash/isObject';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import {FormItem, FormControlProps} from './Item';
|
||||
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
||||
import cx from 'classnames';
|
||||
import InputRange from '../../components/Range';
|
||||
import {Icon} from '../../components/icons';
|
||||
import {FormOptionsControl} from './Options';
|
||||
|
||||
/**
|
||||
* Range
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/range
|
||||
*/
|
||||
export interface RangeControlSchema extends FormBaseControl {
|
||||
type: 'range';
|
||||
|
||||
/**
|
||||
* 最大值
|
||||
*/
|
||||
max?: number;
|
||||
|
||||
/**
|
||||
* 最小值
|
||||
*/
|
||||
min?: number;
|
||||
|
||||
/**
|
||||
* 步长
|
||||
*/
|
||||
step?: number;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
unit?: string;
|
||||
}
|
||||
|
||||
export interface RangeProps extends FormControlProps {
|
||||
max?: number;
|
||||
|
@ -1,7 +1,25 @@
|
||||
import React from 'react';
|
||||
import {FormItem, FormControlProps} from './Item';
|
||||
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
||||
import Rating from '../../components/Rating';
|
||||
|
||||
/**
|
||||
* Rating
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/rating
|
||||
*/
|
||||
export interface RatingControlSchema extends FormBaseControl {
|
||||
type: 'rating';
|
||||
|
||||
/**
|
||||
* 分数
|
||||
*/
|
||||
count?: number;
|
||||
|
||||
/**
|
||||
* 允许半颗星
|
||||
*/
|
||||
half?: boolean;
|
||||
}
|
||||
|
||||
export interface RatingProps extends FormControlProps {
|
||||
value: number;
|
||||
count: number;
|
||||
|
@ -7,7 +7,17 @@
|
||||
|
||||
import React from 'react';
|
||||
import cx from 'classnames';
|
||||
import {FormItem, FormControlProps} from './Item';
|
||||
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
||||
|
||||
/**
|
||||
* Repeat
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/repeat
|
||||
*/
|
||||
export interface RepeatControlSchema extends FormBaseControl {
|
||||
type: 'rating';
|
||||
|
||||
options?: string;
|
||||
}
|
||||
|
||||
const LANG: {
|
||||
[propName: string]: string;
|
||||
|
@ -1,9 +1,24 @@
|
||||
import React from 'react';
|
||||
import {FormItem, FormControlProps} from './Item';
|
||||
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
||||
import cx from 'classnames';
|
||||
import LazyComponent from '../../components/LazyComponent';
|
||||
import {noop} from '../../utils/helper';
|
||||
|
||||
/**
|
||||
* RichText
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/rich-text
|
||||
*/
|
||||
export interface RichTextControlSchema extends FormBaseControl {
|
||||
type: 'rich-text';
|
||||
|
||||
vendor?: 'froala' | 'tinymce';
|
||||
|
||||
reciever?: string;
|
||||
videoReciever?: string;
|
||||
|
||||
options?: any;
|
||||
}
|
||||
|
||||
export interface RichTextProps extends FormControlProps {
|
||||
options?: any;
|
||||
vendor?: 'froala' | 'tinymce';
|
||||
|
@ -1,13 +1,37 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {Renderer, RendererProps} from '../../factory';
|
||||
import BasicService, {ServiceProps} from '../Service';
|
||||
import BasicService, {ServiceProps, ServiceSchema} from '../Service';
|
||||
import {Schema, Payload} from '../../types';
|
||||
import Scoped, {ScopedContext, IScopedContext} from '../../Scoped';
|
||||
import {observer} from 'mobx-react';
|
||||
import {ServiceStore, IServiceStore} from '../../store/service';
|
||||
import {IFormStore} from '../../store/form';
|
||||
import {isObject} from '../../utils/helper';
|
||||
import {FormBaseControl, FormControlSchema} from './Item';
|
||||
|
||||
/**
|
||||
* Sevice
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/sevice
|
||||
*/
|
||||
export interface ServiceControlSchema extends FormBaseControl, ServiceSchema {
|
||||
type: 'service';
|
||||
|
||||
/**
|
||||
* 表单项集合
|
||||
*/
|
||||
controls?: Array<FormControlSchema>;
|
||||
|
||||
/**
|
||||
* @deprecated 请用类型 tabs
|
||||
*/
|
||||
tabs?: any;
|
||||
|
||||
/**
|
||||
* @deprecated 请用类型 fieldSet
|
||||
*/
|
||||
fieldSet?: any;
|
||||
}
|
||||
|
||||
@Renderer({
|
||||
test: /(^|\/)form\/(.*)\/service$/,
|
||||
|
@ -1,11 +1,30 @@
|
||||
import React from 'react';
|
||||
import {FormItem, FormControlProps} from './Item';
|
||||
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
||||
import {TableCell} from '../Table';
|
||||
import PopOver from '../PopOver';
|
||||
import QuickEdit from '../QuickEdit';
|
||||
import {Renderer} from '../../factory';
|
||||
import Copyable from '../Copyable';
|
||||
import {extendObject} from '../../utils/helper';
|
||||
import {SchemaTpl} from '../../Schema';
|
||||
|
||||
/**
|
||||
* Static
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/static
|
||||
*/
|
||||
export interface StaticControlSchema extends FormBaseControl {
|
||||
type: 'static';
|
||||
|
||||
/**
|
||||
* 内容模板, 支持 HTML
|
||||
*/
|
||||
tpl?: SchemaTpl;
|
||||
|
||||
/**
|
||||
* 内容模板,不支持 HTML
|
||||
*/
|
||||
text?: SchemaTpl;
|
||||
}
|
||||
|
||||
export interface StaticProps extends FormControlProps {
|
||||
placeholder?: string;
|
||||
|
@ -1,11 +1,44 @@
|
||||
import React from 'react';
|
||||
import {FormItem, FormControlProps} from './Item';
|
||||
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
||||
import cx from 'classnames';
|
||||
import omit from 'lodash/omit';
|
||||
import pick from 'lodash/pick';
|
||||
import {createObject} from '../../utils/helper';
|
||||
import {Icon} from '../../components/icons';
|
||||
|
||||
/**
|
||||
* Static
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/static
|
||||
*/
|
||||
export interface SubFormControlSchema extends FormBaseControl {
|
||||
type: 'form';
|
||||
|
||||
/**
|
||||
* 占位符
|
||||
*/
|
||||
placeholder?: string;
|
||||
|
||||
/**
|
||||
* 是否多选
|
||||
*/
|
||||
multiple?: boolean;
|
||||
|
||||
/**
|
||||
* 最少个数
|
||||
*/
|
||||
minLength?: number;
|
||||
|
||||
/**
|
||||
* 最多个数
|
||||
*/
|
||||
maxLength?: number;
|
||||
|
||||
/**
|
||||
* 按钮名称字段。
|
||||
*/
|
||||
labelField?: string;
|
||||
}
|
||||
|
||||
export interface SubFormProps extends FormControlProps {
|
||||
placeholder?: string;
|
||||
multiple?: boolean;
|
||||
|
@ -1,8 +1,34 @@
|
||||
import React from 'react';
|
||||
import {FormItem, FormControlProps} from './Item';
|
||||
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
||||
import cx from 'classnames';
|
||||
import Switch from '../../components/Switch';
|
||||
|
||||
/**
|
||||
* Switch
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/switch
|
||||
*/
|
||||
export interface SwitchControlSchema extends FormBaseControl {
|
||||
/**
|
||||
* 指定为多行文本输入框
|
||||
*/
|
||||
type: 'switch';
|
||||
|
||||
/**
|
||||
* 勾选值
|
||||
*/
|
||||
trueValue?: any;
|
||||
|
||||
/**
|
||||
* 未勾选值
|
||||
*/
|
||||
falseValue?: any;
|
||||
|
||||
/**
|
||||
* 选项说明
|
||||
*/
|
||||
option?: string;
|
||||
}
|
||||
|
||||
export interface SwitchProps extends FormControlProps {
|
||||
option?: string;
|
||||
trueValue?: any;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import {FormItem, FormControlProps} from './Item';
|
||||
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
||||
import cx from 'classnames';
|
||||
import Button from '../../components/Button';
|
||||
import {createObject, isObjectShallowModified} from '../../utils/helper';
|
||||
@ -12,33 +12,122 @@ import findIndex from 'lodash/findIndex';
|
||||
import memoize from 'lodash/memoize';
|
||||
import {SimpleMap} from '../../utils/SimpleMap';
|
||||
import {Icon} from '../../components/icons';
|
||||
import {TableSchema} from '../Table';
|
||||
import {SchemaApi} from '../../Schema';
|
||||
|
||||
export interface TableProps extends FormControlProps {
|
||||
placeholder?: string;
|
||||
columns?: Array<any>;
|
||||
export interface TableControlSchema extends FormBaseControl, TableSchema {
|
||||
type: 'table';
|
||||
|
||||
/**
|
||||
* 可新增
|
||||
*/
|
||||
addable?: boolean;
|
||||
addApi?: Api;
|
||||
|
||||
/**
|
||||
* 新增 API
|
||||
*/
|
||||
addApi?: SchemaApi;
|
||||
|
||||
/**
|
||||
* 新增按钮
|
||||
*/
|
||||
addBtnLabel?: string;
|
||||
|
||||
/**
|
||||
* 新增图标
|
||||
*/
|
||||
addBtnIcon?: string;
|
||||
|
||||
/**
|
||||
* 显示新增按钮
|
||||
*/
|
||||
showAddBtn?: boolean;
|
||||
|
||||
/**
|
||||
* 可否删除
|
||||
*/
|
||||
removable?: boolean;
|
||||
deleteApi?: Api;
|
||||
|
||||
/**
|
||||
* 删除的 API
|
||||
*/
|
||||
deleteApi?: SchemaApi;
|
||||
|
||||
/**
|
||||
* 可否编辑
|
||||
*/
|
||||
editable?: boolean;
|
||||
|
||||
/**
|
||||
* 更新按钮名称
|
||||
*/
|
||||
updateBtnLabel?: string;
|
||||
|
||||
/**
|
||||
* 更新按钮图标
|
||||
*/
|
||||
updateBtnIcon?: string;
|
||||
|
||||
/**
|
||||
* 确认按钮文字
|
||||
*/
|
||||
confirmBtnLabel?: string;
|
||||
|
||||
/**
|
||||
* 确认按钮图标
|
||||
*/
|
||||
confirmBtnIcon?: string;
|
||||
|
||||
/**
|
||||
* 取消按钮文字
|
||||
*/
|
||||
cancelBtnLabel?: string;
|
||||
|
||||
/**
|
||||
* 取消按钮图标
|
||||
*/
|
||||
cancelBtnIcon?: string;
|
||||
|
||||
/**
|
||||
* 删除按钮文字
|
||||
*/
|
||||
deleteBtnLabel?: string;
|
||||
|
||||
/**
|
||||
* 删除按钮图标
|
||||
*/
|
||||
deleteBtnIcon?: string;
|
||||
updateApi?: Api;
|
||||
|
||||
/**
|
||||
* 更新 API
|
||||
*/
|
||||
updateApi?: SchemaApi;
|
||||
|
||||
/**
|
||||
* 初始值,新增的时候
|
||||
*/
|
||||
scaffold?: any;
|
||||
|
||||
/**
|
||||
* 删除确认文字
|
||||
*/
|
||||
deleteConfirmText?: string;
|
||||
|
||||
/**
|
||||
* 值字段
|
||||
*/
|
||||
valueField?: string;
|
||||
|
||||
/**
|
||||
* 是否为确认的编辑模式。
|
||||
*/
|
||||
needConfirm?: boolean;
|
||||
}
|
||||
|
||||
export interface TableProps
|
||||
extends FormControlProps,
|
||||
Omit<TableControlSchema, 'type'> {}
|
||||
|
||||
export interface TableState {
|
||||
columns: Array<any>;
|
||||
editIndex: number;
|
||||
|
@ -1,7 +1,37 @@
|
||||
import React from 'react';
|
||||
import {Renderer, RendererProps} from '../../factory';
|
||||
import {Schema} from '../../types';
|
||||
import Tabs from '../Tabs';
|
||||
import Tabs, {TabSchema, TabsSchema} from '../Tabs';
|
||||
import {FormBaseControl, FormControlSchema} from './Item';
|
||||
|
||||
/**
|
||||
* Tabs
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/tabs
|
||||
*/
|
||||
export interface TabsControlSchema
|
||||
extends FormBaseControl,
|
||||
Omit<TabsSchema, 'tabs'> {
|
||||
type: 'tabs';
|
||||
|
||||
tabs: Array<
|
||||
TabSchema & {
|
||||
/**
|
||||
* 表单项集合
|
||||
*/
|
||||
controls?: Array<FormControlSchema>;
|
||||
|
||||
/**
|
||||
* @deprecated 请用类型 tabs
|
||||
*/
|
||||
tabs?: any;
|
||||
|
||||
/**
|
||||
* @deprecated 请用类型 fieldSet
|
||||
*/
|
||||
fieldSet?: any;
|
||||
}
|
||||
>;
|
||||
}
|
||||
|
||||
export interface TabsProps extends RendererProps {}
|
||||
|
||||
|
@ -1,18 +1,52 @@
|
||||
import {OptionsControlProps, OptionsControl} from './Options';
|
||||
import {
|
||||
OptionsControlProps,
|
||||
OptionsControl,
|
||||
FormOptionsControl
|
||||
} from './Options';
|
||||
import React from 'react';
|
||||
import {Api} from '../../types';
|
||||
import Spinner from '../../components/Spinner';
|
||||
import {BaseTransferRenderer} from './Transfer';
|
||||
import TabsTransfer from '../../components/TabsTransfer';
|
||||
import {SchemaApi} from '../../Schema';
|
||||
|
||||
export interface TabsTransferProps extends OptionsControlProps {
|
||||
/**
|
||||
* TabsTransfer
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/tabs-transfer
|
||||
*/
|
||||
export interface TabsTransferControlSchema extends FormOptionsControl {
|
||||
type: 'tabs-transfer';
|
||||
|
||||
/**
|
||||
* 是否显示剪头
|
||||
*/
|
||||
showArrow?: boolean;
|
||||
|
||||
/**
|
||||
* 可排序?
|
||||
*/
|
||||
sortable?: boolean;
|
||||
|
||||
/**
|
||||
* 搜索结果展示模式
|
||||
*/
|
||||
searchResultMode?: 'table' | 'list' | 'tree' | 'chained';
|
||||
|
||||
/**
|
||||
* 可搜索?
|
||||
*/
|
||||
searchable?: boolean;
|
||||
searchApi?: Api;
|
||||
|
||||
/**
|
||||
* 搜索 API
|
||||
*/
|
||||
searchApi?: SchemaApi;
|
||||
}
|
||||
|
||||
export interface TabsTransferProps
|
||||
extends OptionsControlProps,
|
||||
Omit<TabsTransferControlSchema, 'type' | 'options'> {}
|
||||
|
||||
@OptionsControl({
|
||||
type: 'tabs-transfer'
|
||||
})
|
||||
|
@ -1,5 +1,10 @@
|
||||
import React from 'react';
|
||||
import {OptionsControl, OptionsControlProps, Option} from './Options';
|
||||
import {
|
||||
OptionsControl,
|
||||
OptionsControlProps,
|
||||
Option,
|
||||
FormOptionsControl
|
||||
} from './Options';
|
||||
import Downshift from 'downshift';
|
||||
import find from 'lodash/find';
|
||||
import {findDOMNode} from 'react-dom';
|
||||
@ -10,6 +15,24 @@ import Overlay from '../../components/Overlay';
|
||||
import PopOver from '../../components/PopOver';
|
||||
import ListMenu from '../../components/ListMenu';
|
||||
|
||||
/**
|
||||
* Tag 输入框
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/tag
|
||||
*/
|
||||
export interface TagControlSchema extends FormOptionsControl {
|
||||
type: 'tag';
|
||||
|
||||
/**
|
||||
* 选项提示信息
|
||||
*/
|
||||
optionsTip: string;
|
||||
|
||||
/**
|
||||
* 是否为下拉模式
|
||||
*/
|
||||
dropdown?: boolean;
|
||||
}
|
||||
|
||||
// declare function matchSorter(items:Array<any>, input:any, options:any): Array<any>;
|
||||
|
||||
export interface TagProps extends OptionsControlProps {
|
||||
|
@ -1,4 +1,8 @@
|
||||
import {OptionsControlProps, OptionsControl} from './Options';
|
||||
import {
|
||||
OptionsControlProps,
|
||||
OptionsControl,
|
||||
FormOptionsControl
|
||||
} from './Options';
|
||||
import React from 'react';
|
||||
import Transfer from '../../components/Transfer';
|
||||
import {Option} from './Options';
|
||||
@ -14,21 +18,70 @@ import Spinner from '../../components/Spinner';
|
||||
import find from 'lodash/find';
|
||||
import {optionValueCompare} from '../../components/Select';
|
||||
import {resolveVariable} from '../../utils/tpl-builtin';
|
||||
import {SchemaApi} from '../../Schema';
|
||||
|
||||
export interface BaseTransferProps extends OptionsControlProps {
|
||||
/**
|
||||
* Transfer
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/transfer
|
||||
*/
|
||||
export interface TransferControlSchema extends FormOptionsControl {
|
||||
type: 'transfer';
|
||||
|
||||
/**
|
||||
* 是否显示剪头
|
||||
*/
|
||||
showArrow?: boolean;
|
||||
|
||||
/**
|
||||
* 可排序?
|
||||
*/
|
||||
sortable?: boolean;
|
||||
|
||||
/**
|
||||
* 勾选展示模式
|
||||
*/
|
||||
selectMode?: 'table' | 'list' | 'tree' | 'chained' | 'associated';
|
||||
|
||||
/**
|
||||
* 当 selectMode 为 associated 时用来定义左侧的选项
|
||||
*/
|
||||
leftOptions?: Array<Option>;
|
||||
|
||||
/**
|
||||
* 当 selectMode 为 associated 时用来定义左侧的选择模式
|
||||
*/
|
||||
leftMode?: 'tree' | 'list';
|
||||
|
||||
/**
|
||||
* 当 selectMode 为 associated 时用来定义右侧的选择模式
|
||||
*/
|
||||
rightMode?: 'table' | 'list' | 'tree' | 'chained';
|
||||
|
||||
/**
|
||||
* 搜索结果展示模式
|
||||
*/
|
||||
searchResultMode?: 'table' | 'list' | 'tree' | 'chained';
|
||||
|
||||
/**
|
||||
* 当 selectMode 为 table 时定义表格列信息。
|
||||
*/
|
||||
columns?: Array<any>;
|
||||
|
||||
/**
|
||||
* 可搜索?
|
||||
*/
|
||||
searchable?: boolean;
|
||||
searchApi?: Api;
|
||||
|
||||
/**
|
||||
* 搜索 API
|
||||
*/
|
||||
searchApi?: SchemaApi;
|
||||
}
|
||||
|
||||
export interface BaseTransferProps
|
||||
extends OptionsControlProps,
|
||||
Omit<TransferControlSchema, 'type' | 'options'> {}
|
||||
|
||||
export class BaseTransferRenderer<
|
||||
T extends OptionsControlProps = BaseTransferProps
|
||||
> extends React.Component<T> {
|
||||
|
@ -1,23 +1,65 @@
|
||||
import React from 'react';
|
||||
import cx from 'classnames';
|
||||
import TreeSelector from '../../components/Tree';
|
||||
import {OptionsControl, OptionsControlProps} from './Options';
|
||||
import {
|
||||
FormOptionsControl,
|
||||
OptionsControl,
|
||||
OptionsControlProps
|
||||
} from './Options';
|
||||
import {Spinner} from '../../components';
|
||||
|
||||
export interface TreeProps extends OptionsControlProps {
|
||||
placeholder?: any;
|
||||
/**
|
||||
* Tree 下拉选择框。
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/tree
|
||||
*/
|
||||
export interface TreeControlSchema extends FormOptionsControl {
|
||||
type: 'tree';
|
||||
|
||||
/**
|
||||
* 是否隐藏顶级
|
||||
*/
|
||||
hideRoot?: boolean;
|
||||
|
||||
/**
|
||||
* 顶级选项的名称
|
||||
*/
|
||||
rootLabel?: string;
|
||||
|
||||
/**
|
||||
* 顶级选项的值
|
||||
*/
|
||||
rootValue?: any;
|
||||
|
||||
/**
|
||||
* 显示图标
|
||||
*/
|
||||
showIcon?: boolean;
|
||||
cascade?: boolean; // 父子之间是否完全独立。
|
||||
withChildren?: boolean; // 选父级的时候是否把子节点的值也包含在内。
|
||||
onlyChildren?: boolean; // 选父级的时候,是否只把子节点的值包含在内
|
||||
addControls?: Array<any>;
|
||||
updateControls?: Array<any>;
|
||||
|
||||
/**
|
||||
* 父子之间是否完全独立。
|
||||
*/
|
||||
cascade?: boolean;
|
||||
|
||||
/**
|
||||
* 选父级的时候是否把子节点的值也包含在内。
|
||||
*/
|
||||
withChildren?: boolean;
|
||||
|
||||
/**
|
||||
* 选父级的时候,是否只把子节点的值包含在内
|
||||
*/
|
||||
onlyChildren?: boolean;
|
||||
|
||||
/**
|
||||
* 顶级节点是否可以创建子节点
|
||||
*/
|
||||
rootCreatable?: boolean;
|
||||
}
|
||||
|
||||
export interface TreeProps
|
||||
extends OptionsControlProps,
|
||||
Omit<TreeControlSchema, 'type' | 'options'> {}
|
||||
|
||||
export default class TreeControl extends React.Component<TreeProps> {
|
||||
static defaultProps: Partial<TreeProps> = {
|
||||
placeholder: '选项加载中...',
|
||||
|
@ -3,7 +3,12 @@ import cx from 'classnames';
|
||||
import Overlay from '../../components/Overlay';
|
||||
import PopOver from '../../components/PopOver';
|
||||
|
||||
import {OptionsControl, OptionsControlProps, Option} from './Options';
|
||||
import {
|
||||
OptionsControl,
|
||||
OptionsControlProps,
|
||||
Option,
|
||||
FormOptionsControl
|
||||
} from './Options';
|
||||
import {Icon} from '../../components/icons';
|
||||
import TreeSelector from '../../components/Tree';
|
||||
// @ts-ignore
|
||||
@ -17,6 +22,54 @@ import ResultBox from '../../components/ResultBox';
|
||||
import {autobind} from '../../utils/helper';
|
||||
import {findDOMNode} from 'react-dom';
|
||||
|
||||
/**
|
||||
* Tree 下拉选择框。
|
||||
* 文档:https://baidu.gitee.io/amis/docs/components/form/tree
|
||||
*/
|
||||
export interface TreeSelectControlSchema extends FormOptionsControl {
|
||||
type: 'tree-select';
|
||||
|
||||
/**
|
||||
* 是否隐藏顶级
|
||||
*/
|
||||
hideRoot?: boolean;
|
||||
|
||||
/**
|
||||
* 顶级选项的名称
|
||||
*/
|
||||
rootLabel?: string;
|
||||
|
||||
/**
|
||||
* 顶级选项的值
|
||||
*/
|
||||
rootValue?: any;
|
||||
|
||||
/**
|
||||
* 显示图标
|
||||
*/
|
||||
showIcon?: boolean;
|
||||
|
||||
/**
|
||||
* 父子之间是否完全独立。
|
||||
*/
|
||||
cascade?: boolean;
|
||||
|
||||
/**
|
||||
* 选父级的时候是否把子节点的值也包含在内。
|
||||
*/
|
||||
withChildren?: boolean;
|
||||
|
||||
/**
|
||||
* 选父级的时候,是否只把子节点的值包含在内
|
||||
*/
|
||||
onlyChildren?: boolean;
|
||||
|
||||
/**
|
||||
* 顶级节点是否可以创建子节点
|
||||
*/
|
||||
rootCreatable?: boolean;
|
||||
}
|
||||
|
||||
export interface TreeSelectProps extends OptionsControlProps {
|
||||
placeholder?: any;
|
||||
autoComplete?: Api;
|
||||
|
Loading…
Reference in New Issue
Block a user