补充 Schema

This commit is contained in:
2betop 2020-09-10 19:55:32 +08:00
parent a7d7bdf189
commit 63653a5a98
21 changed files with 729 additions and 42 deletions

View File

@ -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'> {
/**

View File

@ -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;

View File

@ -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;

View File

@ -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$/,

View File

@ -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';

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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';

View File

@ -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$/,

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 {}

View File

@ -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'
})

View File

@ -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 {

View File

@ -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> {

View File

@ -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: '选项加载中...',

View File

@ -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;