更新 Schema

This commit is contained in:
2betop 2020-09-10 18:21:44 +08:00
parent 6fd70dfe45
commit a7d7bdf189
39 changed files with 1751 additions and 256 deletions

View File

@ -20,7 +20,7 @@ import {DividerSchema} from './renderers/Divider';
import {DropdownButtonSchema} from './renderers/DropDownButton';
import {EachSchema} from './renderers/Each';
import {GridSchema} from './renderers/Grid';
import {HboxSchema} from './renderers/HBox';
import {HBoxSchema} from './renderers/HBox';
import {IconSchema} from './renderers/Icon';
import {IFrameSchema} from './renderers/IFrame';
import {ImageSchema} from './renderers/Image';
@ -127,7 +127,7 @@ export type SchemaObject =
| DropdownButtonSchema
| EachSchema
| GridSchema
| HboxSchema
| HBoxSchema
| IconSchema
| IFrameSchema
| ImageSchema

View File

@ -25,7 +25,7 @@ export interface ColorProps extends LocaleProps, ThemeProps {
disabled?: boolean;
popOverContainer?: any;
placement?: string;
value: any;
value?: any;
onChange: (value: any) => void;
presetColors?: string[];
resetValue?: string;

View File

@ -242,7 +242,7 @@ export interface DateProps extends LocaleProps, ThemeProps {
defaultValue?: any;
utc?: boolean;
onChange: (value: any) => void;
value: any;
value?: any;
shortcuts: string | Array<ShortCuts>;
overlayPlacement: string;
minTime?: moment.Moment;

View File

@ -31,7 +31,7 @@ export interface DateRangePickerProps extends ThemeProps, LocaleProps {
maxDate?: moment.Moment;
joinValues: boolean;
delimiter: string;
value: any;
value?: any;
onChange: (value: any) => void;
data?: any;
disabled?: boolean;

View File

@ -19,11 +19,31 @@ export interface ButtonGroupSchema extends BaseSchema {
*/
btnClassName?: SchemaClassName;
/**
* Button className
*/
btnActiveClassName: string;
/**
*
*/
buttons?: Array<ActionSchema>;
/**
*
*/
btnLevel: string;
/**
*
*/
btnActiveLevel: string;
/**
*
*/
vertical?: boolean;
/**
*
*/

View File

@ -54,7 +54,9 @@ export interface CollapseSchema extends BaseSchema {
size?: 'xs' | 'sm' | 'md' | 'lg' | 'base';
}
export interface CollapseProps extends RendererProps, CollapseSchema {
export interface CollapseProps
extends RendererProps,
Omit<CollapseSchema, 'type'> {
wrapperComponent?: any;
headingComponent?: any;

View File

@ -1,19 +1,36 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {
FormItem,
FormControlProps,
FormBaseControl,
FormControlSchema
} from './Item';
import {Schema} from '../../types';
import {ComboStore, IComboStore} from '../../store/combo';
import {observer} from 'mobx-react';
import Combo from './Combo';
import Combo, {ComboControlSchema} from './Combo';
import {SchemaApi} from '../../Schema';
export interface ArrayProps extends FormControlProps {
placeholder?: string;
controls: Array<Schema>;
minLength?: number;
maxLength?: number;
addButtonClassName?: string;
items: Schema & {
/**
* Array combo
* https://baidu.gitee.io/amis/docs/components/form/array
*/
export interface ArrayControlSchema
extends Omit<ComboControlSchema, 'type' | 'controls' | 'conditions'> {
/**
*
*/
type: 'array';
/**
*
*/
items: FormControlSchema & {
unique?: boolean;
};
}
export interface ArrayProps extends FormControlProps, ArrayControlSchema {
store: IComboStore;
}

View File

@ -1,7 +1,14 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import cx from 'classnames';
import {Button} from '../../types';
import {ActionSchema} from '../Action';
/**
*
* https://baidu.gitee.io/amis/docs/components/form/button
*/
export type ButtonControlSchema = ActionSchema;
export interface ButtonProps extends FormControlProps, Omit<Button, 'size'> {}

View File

@ -1,17 +1,31 @@
import React from 'react';
import cx from 'classnames';
import {OptionsControl, OptionsControlProps, Option} from './Options';
import {
OptionsControl,
OptionsControlProps,
Option,
FormOptionsControl
} from './Options';
import {Button} from '../../types';
import {getLevelFromClassName, autobind, isEmpty} from '../../utils/helper';
import {dataMapping} from '../../utils/tpl-builtin';
import {ButtonGroupSchema} from '../ButtonGroup';
import {FormBaseControl} from './Item';
export interface ButtonGroupProps extends OptionsControlProps {
buttons?: Array<Button>;
btnLevel: string;
btnActiveLevel: string;
btnClassName: string;
btnActiveClassName: string;
vertical?: boolean;
/**
*
* https://baidu.gitee.io/amis/docs/components/form/button-group
*/
export interface ButtonGroupControlSchema
extends ButtonGroupSchema,
Omit<FormOptionsControl, 'size'> {
type: 'button-group';
}
export interface ButtonGroupProps
extends OptionsControlProps,
Omit<ButtonGroupControlSchema, 'size' | 'source'> {
options: Array<Option>;
}
export default class ButtonGroupControl extends React.Component<

View File

@ -1,12 +1,23 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import cx from 'classnames';
import {Button} from '../../types';
import {ButtonToolbarSchema} from '../ButtonToolbar';
export interface ButtonToolbarProps extends FormControlProps {
buttons?: Array<Button>;
/**
*
* https://baidu.gitee.io/amis/docs/components/form/button-toolbar
*/
export interface ButtonToolbarControlSchema
extends ButtonToolbarSchema,
FormBaseControl {
type: 'button-toolbar';
}
export interface ButtonToolbarProps
extends FormControlProps,
ButtonToolbarControlSchema {}
export class ButtonToolbarControl extends React.Component<ButtonToolbarProps> {
static defaultProps = {};

View File

@ -1,15 +1,28 @@
import React from 'react';
import cx from 'classnames';
import {OptionsControl, OptionsControlProps, Option} from './Options';
import {
OptionsControl,
OptionsControlProps,
Option,
FormOptionsControl
} from './Options';
import Select from '../../components/Select';
import {Api} from '../../types';
import {isEffectiveApi} from '../../utils/api';
import {SchemaApi} from '../../Schema';
export interface ChainedSelectProps extends OptionsControlProps {
autoComplete?: Api;
searchable?: boolean;
/**
*
* https://baidu.gitee.io/amis/docs/components/form/chained-select
*/
export interface ChainedSelectControlSchema extends FormOptionsControl {
type: 'chained-select';
}
export interface ChainedSelectProps
extends OptionsControlProps,
Omit<ChainedSelectControlSchema, 'options' | 'source'> {}
export interface SelectState {
stack: Array<{
options: Array<Option>;

View File

@ -1,14 +1,38 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import cx from 'classnames';
import Checkbox from '../../components/Checkbox';
export interface CheckboxProps extends FormControlProps {
option?: string;
/**
* Checkbox
* https://baidu.gitee.io/amis/docs/components/form/checkbox
*/
export interface CheckboxControlSchema extends FormBaseControl {
/**
*
*/
type: 'checkbox';
/**
*
*/
trueValue?: any;
/**
*
*/
falseValue?: any;
/**
*
*/
option?: string;
}
export interface CheckboxProps
extends FormControlProps,
CheckboxControlSchema {}
export default class CheckboxControl extends React.Component<
CheckboxProps,
any

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 Checkbox from '../../components/Checkbox';
import chunk from 'lodash/chunk';
@ -7,7 +12,32 @@ import {Icon} from '../../components/icons';
import {Api} from '../../types';
import {autobind} from '../../utils/helper';
export interface CheckboxesProps extends OptionsControlProps {
/**
*
* https://baidu.gitee.io/amis/docs/components/form/checkboxes
*/
export interface CheckboxesControlSchema extends FormOptionsControl {
type: 'checkboxes';
/**
*
*/
checkAll?: boolean;
/**
*
*/
defaultCheckAll?: boolean;
/**
*
*/
columnsCount?: number;
}
export interface CheckboxesProps
extends OptionsControlProps,
Omit<CheckboxesControlSchema, 'options'> {
placeholder?: any;
itemClassName?: string;
columnsCount?: number;

View File

@ -1,22 +1,62 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import db, {province, city, district} from './CityDB';
import {ClassNamesFn, themeable} from '../../theme';
import {ClassNamesFn, themeable, ThemeProps} from '../../theme';
import {Select} from '../../components';
import {autobind} from '../../utils/helper';
import {Option} from './Options';
import {localeable, LocaleProps} from '../../locale';
export interface CityPickerProps extends LocaleProps {
/**
* City
* https://baidu.gitee.io/amis/docs/components/form/city
*/
export interface CityControlSchema extends FormBaseControl {
/**
*
*/
type: 'city';
/**
* code
*/
extractValue?: boolean;
/**
*
*/
joinValues?: boolean;
/**
*
*/
delimiter?: string;
/**
*
*/
allowCity?: boolean;
/**
*
*/
allowDistrict?: boolean;
/**
*
*/
allowStreet?: boolean;
}
export interface CityPickerProps
extends Omit<CityControlSchema, 'type'>,
LocaleProps,
ThemeProps {
value: any;
onChange: (value: any) => void;
extractValue: boolean;
joinValues?: boolean;
delimiter: string;
classnames: ClassNamesFn;
classPrefix: string;
className?: string;
disabled?: boolean;
allowCity: boolean;
allowDistrict: boolean;
allowStreet: boolean;

View File

@ -1,17 +1,48 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import cx from 'classnames';
import ColorPicker from '../../components/ColorPicker';
export interface ColorProps extends FormControlProps {
placeholder?: string;
format?: string;
/**
* Color
* https://baidu.gitee.io/amis/docs/components/form/color
*/
export interface ColorControlSchema extends FormBaseControl {
/**
*
*/
type: 'color';
/**
*
*/
clearable?: boolean;
/**
*
*/
format?: 'hex' | 'rgb' | 'rgba' | 'hls';
/**
*
*/
closeOnSelect?: boolean;
presetColors?: string[];
resetValue?: string;
/**
*
*/
presetColors?: Array<any>;
/**
*
*/
allowCustomColor?: boolean;
}
export interface ColorProps
extends FormControlProps,
Omit<ColorControlSchema, 'type'> {}
export interface ColorControlState {
open: boolean;
}

View File

@ -1,6 +1,11 @@
import React from 'react';
import {findDOMNode} from 'react-dom';
import {FormItem, FormControlProps} from './Item';
import {
FormItem,
FormControlProps,
FormBaseControl,
FormControlSchema
} from './Item';
import {Schema, Action, Api} from '../../types';
import {ComboStore, IComboStore} from '../../store/combo';
import {default as CTabs, Tab} from '../../components/Tabs';
@ -24,14 +29,214 @@ import {Alert2} from '../../components';
import memoize from 'lodash/memoize';
import {Icon} from '../../components/icons';
import {isAlive} from 'mobx-state-tree';
export interface Condition {
import {SchemaApi, SchemaClassName, SchemaIcon, SchemaTpl} from '../../Schema';
export interface ComboCondition {
test: string;
controls: Array<Schema>;
controls: Array<FormControlSchema>;
label: string;
scaffold?: any;
mode?: string;
}
/**
* Combo
* https://baidu.gitee.io/amis/docs/components/form/combo
*/
export interface ComboControlSchema extends FormBaseControl {
/**
*
*/
type: 'combo';
/**
* `{}`
*
* @default {}
*/
scaffold?: any;
/**
*
*/
noBorder?: boolean;
/**
*
*/
deleteConfirmText?: string;
/**
* api
*/
deleteApi?: SchemaApi;
/**
* `conditions`使
*/
typeSwitchable?: boolean;
/**
* schema
*/
conditions?: Array<ComboCondition>;
/**
*
*/
formClassName?: SchemaClassName;
/**
* CSS类名
*/
addButtonClassName?: SchemaClassName;
/**
*
* @default
*/
addButtonText?: string;
/**
*
*/
addable?: boolean;
/**
*
*/
controls?: Array<
FormControlSchema & {
/**
*
*/
unique?: boolean;
}
>;
/**
*
*/
draggable?: boolean;
/**
*
*
* @default
*/
draggableTip?: string;
/**
* (name),controls的length为1且multiple为true的时候才有效
*/
flat?: boolean;
/**
* joinValues为true时
*
* @deprecated
*/
delimiter?: string;
/**
* array的方式
* @deprecated
*/
joinValues?: boolean;
/**
*
*/
maxLength?: number;
/**
*
*/
minLength?: number;
/**
*
*/
multiLine?: boolean;
/**
*
*/
multiple?: boolean;
/**
*
*/
removeAble?: boolean;
/**
*
*/
subFormMode?: 'normal' | 'horizontal' | 'inline';
/**
*
* @default <>
*/
placeholder?: string;
/**
* 访 combo 访
*/
canAccessSuperData?: boolean;
/**
* Tabs
*/
tabsMode?: boolean;
/**
* Tabs
*/
tabsStyle?: '' | 'line' | 'card' | 'radio';
/**
*
*/
tabsLabelTpl?: SchemaTpl;
/**
*
*/
lazyLoad?: boolean;
/**
*
*/
strictMode?: boolean;
/**
*
*/
nullable?: boolean;
/**
*
*/
messages?: {
/**
*
*/
validateFailed?: string;
/**
*
*/
minLengthValidateFailed?: string;
/**
*
*/
maxLengthValidateFailed?: string;
};
}
function pickVars(vars: any, fields: Array<string>) {
return fields.reduce((data: any, key: string) => {
data[key] = resolveVariable(key, vars);
@ -39,45 +244,9 @@ function pickVars(vars: any, fields: Array<string>) {
}, {});
}
export interface ComboProps extends FormControlProps {
placeholder?: string;
flat?: boolean; // 是否把值打平,即原来是对象现在只有对象中的值。
draggable?: boolean; // 是否可拖拽
controls?: Array<Schema>;
conditions?: Array<Condition>;
multiple?: boolean;
multiLine?: boolean;
minLength?: number;
maxLength?: number;
scaffold?: any;
addButtonClassName?: string;
formClassName?: string;
addButtonText?: string;
addable?: boolean;
typeSwitchable?: boolean;
removable?: boolean;
deleteApi?: Api;
deleteConfirmText?: string;
canAccessSuperData?: boolean;
subFormMode?: 'normal' | 'inline' | 'horizontal';
noBorder?: boolean;
joinValues?: boolean;
delimiter?: string;
dragIcon: string;
deleteIcon: string;
export interface ComboProps extends FormControlProps, ComboControlSchema {
store: IComboStore;
tabsMode: boolean;
tabsStyle: '' | 'line' | 'card' | 'radio';
tabsLabelTpl?: string;
lazyLoad?: boolean;
changeImmediately?: boolean;
strictMode?: boolean;
nullable?: boolean;
messages?: {
validateFailed?: string;
minLengthValidateFailed?: string;
maxLengthValidateFailed?: string;
};
}
export default class ComboControl extends React.Component<ComboProps> {
@ -249,7 +418,7 @@ export default class ComboControl extends React.Component<ComboProps> {
return value;
}
addItemWith(condition: Condition) {
addItemWith(condition: ComboCondition) {
const {
flat,
joinValues,
@ -652,19 +821,19 @@ export default class ComboControl extends React.Component<ComboProps> {
);
}
pickCondition(value: any): Condition | null {
const conditions: Array<Condition> = this.props.conditions!;
pickCondition(value: any): ComboCondition | null {
const conditions: Array<ComboCondition> = this.props.conditions!;
return find(
conditions,
item => item.test && evalExpression(item.test, value)
) as Condition | null;
) as ComboCondition | null;
}
handleComboTypeChange(index: number, selection: any) {
const {multiple, onChange, value, flat, submitOnChange} = this.props;
const conditions: Array<Condition> = this.props.conditions as Array<
Condition
const conditions: Array<ComboCondition> = this.props.conditions as Array<
ComboCondition
>;
const condition = find(conditions, item => item.label === selection.label);
@ -811,7 +980,7 @@ export default class ComboControl extends React.Component<ComboProps> {
>
{value.map((value, index) => {
const data = this.formatValue(value, index);
let condition: Condition | null | undefined = null;
let condition: ComboCondition | null | undefined = null;
let toolbar = undefined;
if (
finnalRemovable && // 表达式判断单条是否可删除
@ -871,10 +1040,12 @@ export default class ComboControl extends React.Component<ComboProps> {
<label>{__('类型')}</label>
<Select
onChange={this.handleComboTypeChange.bind(this, index)}
options={(conditions as Array<Condition>).map(item => ({
label: item.label,
value: item.label
}))}
options={(conditions as Array<ComboCondition>).map(
item => ({
label: item.label,
value: item.label
})
)}
value={condition.label}
clearable={false}
/>
@ -1025,7 +1196,7 @@ export default class ComboControl extends React.Component<ComboProps> {
}
const data = this.formatValue(value, index);
let condition: Condition | null = null;
let condition: ComboCondition | null = null;
if (Array.isArray(conditions) && conditions.length) {
condition = this.pickCondition(data);
@ -1067,10 +1238,12 @@ export default class ComboControl extends React.Component<ComboProps> {
<label>{__('类型')}</label>
<Select
onChange={this.handleComboTypeChange.bind(this, index)}
options={(conditions as Array<Condition>).map(item => ({
label: item.label,
value: item.label
}))}
options={(conditions as Array<ComboCondition>).map(
item => ({
label: item.label,
value: item.label
})
)}
value={condition.label}
clearable={false}
/>
@ -1186,7 +1359,7 @@ export default class ComboControl extends React.Component<ComboProps> {
let controls = this.props.controls;
const data = isObject(value) ? this.formatValue(value) : this.defaultValue;
let condition: Condition | null = null;
let condition: ComboCondition | null = null;
if (Array.isArray(conditions) && conditions.length) {
condition = this.pickCondition(data);
@ -1208,7 +1381,7 @@ export default class ComboControl extends React.Component<ComboProps> {
<label>{__('类型')}</label>
<Select
onChange={this.handleComboTypeChange.bind(this, 0)}
options={(conditions as Array<Condition>).map(item => ({
options={(conditions as Array<ComboCondition>).map(item => ({
label: item.label,
value: item.label
}))}

View File

@ -1,16 +1,40 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import ColorPicker from '../../components/ColorPicker';
import {Funcs, Fields} from '../../components/condition-builder/types';
import {Config} from '../../components/condition-builder/config';
import ConditionBuilder from '../../components/condition-builder/index';
export interface ConditionBuilderProps extends FormControlProps {
/**
*
* https://baidu.gitee.io/amis/docs/components/form/condition-builder
*/
export interface ConditionBuilderControlSchema extends FormBaseControl {
/**
*
*/
type: 'condition-builder';
/**
*
*/
funcs?: Funcs;
/**
*
*/
fields: Fields;
/**
*
*/
config?: Config;
}
export interface ConditionBuilderProps
extends FormControlProps,
ConditionBuilderControlSchema {}
export default class ConditionBuilderControl extends React.PureComponent<
ConditionBuilderProps
> {

View File

@ -1,10 +1,39 @@
import React from 'react';
import {Renderer} from '../../factory';
import cx from 'classnames';
import Container from '../Container';
import FormItem, {FormControlProps} from './Item';
import Container, {ContainerSchema} from '../Container';
import FormItem, {
FormBaseControl,
FormControlProps,
FormControlSchema
} from './Item';
import {IIRendererStore} from '../../store/iRenderer';
/**
*
* https://baidu.gitee.io/amis/docs/components/form/contaier
*/
export interface ContainerControlSchema
extends FormBaseControl,
ContainerSchema {
type: 'container';
/**
*
*/
controls?: Array<FormControlSchema>;
/**
* @deprecated tabs
*/
tabs?: any;
/**
* @deprecated fieldSet
*/
fieldSet?: any;
}
export interface ContainerProps extends FormControlProps {
store: IIRendererStore;
}

View File

@ -1,13 +1,157 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import cx from 'classnames';
import {filterDate} from '../../utils/tpl-builtin';
import moment from 'moment';
import 'moment/locale/zh-cn';
import DatePicker from '../../components/DatePicker';
export interface DateBaseControlSchema extends FormBaseControl {
/**
*
*/
type: 'date' | 'datetime' | 'time';
/**
*
*/
clearable?: boolean;
/**
*
*/
format?: string;
/**
*
*/
inputFormat?: string;
/**
* utc
*/
utc?: boolean;
}
/**
* Date日期选择控件
* https://baidu.gitee.io/amis/docs/components/form/date
*/
export interface DateControlSchema extends DateBaseControlSchema {
/**
*
*/
type: 'date';
/**
*
* @default X
*/
format?: string;
/**
*
* @default YYYY-MM-DD
*/
inputFormat?: string;
/**
*
*/
closeOnSelect?: boolean;
/**
*
*/
minDate?: string;
/**
*
*/
maxDate?: string;
}
/**
* Datetime日期时间选择控件
* https://baidu.gitee.io/amis/docs/components/form/datetime
*/
export interface DateTimeControlSchema extends DateBaseControlSchema {
/**
*
*/
type: 'datetime';
/**
*
* @default X
*/
format?: string;
/**
*
* @default YYYY-MM-DD HH:mm
*/
inputFormat?: string;
/**
*
*
* @default HH:mm
*/
timeFormat?: string;
/**
*
*/
minDate?: string;
/**
*
*/
maxDate?: string;
/**
*
*/
timeConstraints?: any;
}
/**
* Time
* https://baidu.gitee.io/amis/docs/components/form/time
*/
export interface TimeControlSchema extends DateBaseControlSchema {
/**
*
*/
type: 'time';
/**
*
* @default X
*/
format?: string;
/**
*
* @default YYYY-MM-DD HH:mm
*/
inputFormat?: string;
/**
*
*
* @default HH:mm
*/
timeFormat?: string;
/**
*
*/
timeConstraints?: any;
}
export interface DateProps extends FormControlProps {
placeholder?: string;
inputFormat?: string;
timeFormat?: string;
format?: string;

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 {filterDate} from '../../utils/tpl-builtin';
import moment from 'moment';
@ -8,14 +8,59 @@ import DateRangePicker, {
DateRangePicker as BaseDateRangePicker
} from '../../components/DateRangePicker';
export interface DateRangeProps extends FormControlProps {
placeholder?: string;
disabled: boolean;
/**
* DateRange
* https://baidu.gitee.io/amis/docs/components/form/date-range
*/
export interface DateRangeControlSchema extends FormBaseControl {
/**
*
*/
type: 'date-range';
/**
* ,
*
*/
delimiter?: string;
/**
* `X` moment.
*/
format?: string;
/**
* `YYYY-MM-DD`
*/
inputFormat?: string;
/**
* value `value1,value2` `[value1, value2]`
*/
joinValues?: boolean;
/**
* $xxx * `-2mins` 2\n * `+2days` 2\n* `-10week` \n可用单位 `min``hour``day``week``month``year`
*/
maxDate?: string;
/**
* $xxx * `-2mins` 2\n * `+2days` 2\n* `-10week` \n可用单位 `min``hour``day``week``month``year`
*/
minDate?: string;
/**
* value * `-2mins` 2\n * `+2days` 2\n* `-10week` \n可用单位 `min``hour``day``week``month``year`
*/
value?: any;
}
export interface DateRangeProps
extends FormControlProps,
Omit<DateRangeControlSchema, 'type'> {
delimiter: string;
format: string;
joinValues: boolean;
delimiter: string;
minDate?: any;
maxDate?: any;
}
interface DateControlState {
@ -132,6 +177,8 @@ export default class DateRangeControl extends React.Component<
classPrefix: ns,
defaultValue,
defaultData,
minDate,
maxDate,
...rest
} = this.props;

View File

@ -1,11 +1,38 @@
import React from 'react';
import {Renderer} from '../../factory';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import {filter} from '../../utils/tpl';
import cx from 'classnames';
import LazyComponent from '../../components/LazyComponent';
import debouce from 'lodash/debounce';
import {isPureVariable} from '../../utils/tpl-builtin';
import {SchemaTokenizeableString} from '../../Schema';
/**
* Diff
* https://baidu.gitee.io/amis/docs/components/form/diff
*/
export interface DiffControlSchema extends FormBaseControl {
/**
* Diff
*/
type: 'diff';
/**
*
*/
diffValue?: SchemaTokenizeableString;
/**
* monaco-editor
*/
language?: string;
/**
*
*/
options?: any;
}
function loadComponent(): Promise<React.ReactType> {
return new Promise(resolve =>
@ -15,11 +42,9 @@ function loadComponent(): Promise<React.ReactType> {
);
}
export interface DiffEditorProps extends FormControlProps {
options?: object;
language?: string;
diffValue?: string;
}
export interface DiffEditorProps
extends FormControlProps,
Omit<DiffControlSchema, 'type'> {}
function normalizeValue(value: any, language?: string) {
if (value && typeof value !== 'string') {

View File

@ -1,9 +1,65 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import LazyComponent from '../../components/LazyComponent';
import debouce from 'lodash/debounce';
import Editor from '../../components/Editor';
/**
* Editor
* https://baidu.gitee.io/amis/docs/components/form/editor
*/
export interface EditorControlSchema extends Omit<FormBaseControl, 'size'> {
type: 'editor';
/**
*
*/
language?:
| 'bat'
| 'c'
| 'coffeescript'
| 'cpp'
| 'csharp'
| 'css'
| 'dockerfile'
| 'fsharp'
| 'go'
| 'handlebars'
| 'html'
| 'ini'
| 'java'
| 'javascript'
| 'json'
| 'less'
| 'lua'
| 'markdown'
| 'msdax'
| 'objective-c'
| 'php'
| 'plaintext'
| 'postiats'
| 'powershell'
| 'pug'
| 'python'
| 'r'
| 'razor'
| 'ruby'
| 'sb'
| 'scss'
| 'sol'
| 'sql'
| 'swift'
| 'typescript'
| 'vb'
| 'xml'
| 'yaml';
/**
*
*/
size?: 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
}
export interface EditorProps extends FormControlProps {
options?: object;
}
@ -178,26 +234,26 @@ export const availableLanguages = [
'yaml'
];
export const EditorControls: Array<
typeof EditorControl
> = availableLanguages.map((lang: string) => {
@FormItem({
type: `${lang}-editor`,
sizeMutable: false
})
class EditorControlRenderer extends EditorControl {
static lang = lang;
static displayName = `${lang[0].toUpperCase()}${lang.substring(
1
)}EditorControlRenderer`;
static defaultProps = {
...EditorControl.defaultProps,
language: lang
};
}
export const EditorControls: Array<typeof EditorControl> = availableLanguages.map(
(lang: string) => {
@FormItem({
type: `${lang}-editor`,
sizeMutable: false
})
class EditorControlRenderer extends EditorControl {
static lang = lang;
static displayName = `${lang[0].toUpperCase()}${lang.substring(
1
)}EditorControlRenderer`;
static defaultProps = {
...EditorControl.defaultProps,
language: lang
};
}
return EditorControlRenderer;
});
return EditorControlRenderer;
}
);
@FormItem({
type: 'js-editor',

View File

@ -1,22 +1,37 @@
import React from 'react';
import {FormSchemaHorizontal} from '.';
import {Renderer, RendererProps} from '../../factory';
import Collapse from '../Collapse';
import cx from 'classnames';
import {SchemaCollection, SchemaTpl} from '../../Schema';
import Collapse, {CollapseSchema} from '../Collapse';
import {FormBaseControl, FormControlSchema} from './Item';
export interface FieldSetProps extends RendererProps {
title?: string;
collapsed?: boolean;
mode?: 'normal' | 'inline' | 'horizontal' | 'row';
size?: 'xs' | 'sm' | 'md' | 'lg' | 'base';
formClassName?: string;
collapsable?: boolean;
horizontal: {
left: string;
right: string;
offset: string;
};
/**
* FieldSet
* https://baidu.gitee.io/amis/docs/components/form/fieldset
*/
export interface FieldSetControlSchema
extends Omit<FormBaseControl, 'size'>,
Omit<CollapseSchema, 'type'> {
/**
*
*/
type: 'fieldset';
/**
*
*/
controls?: Array<FormControlSchema>;
/**
*
*/
title?: SchemaTpl;
}
export interface FieldSetProps
extends RendererProps,
Omit<FieldSetControlSchema, 'type'> {}
export default class FieldSetControl extends React.Component<
FieldSetProps,
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 qs from 'qs';
import find from 'lodash/find';
@ -16,39 +16,188 @@ import Button from '../../components/Button';
import {Icon} from '../../components/icons';
import DropZone from 'react-dropzone';
import {dataMapping} from '../../utils/tpl-builtin';
import {
SchemaApi,
SchemaClassName,
SchemaTokenizeableString
} from '../../Schema';
export interface FileProps extends FormControlProps {
maxSize: number;
maxLength: number;
placeholder?: string;
/**
* File
* https://baidu.gitee.io/amis/docs/components/form/file
*/
export interface FileControlSchema extends FormBaseControl {
/**
*
*/
type: 'file';
/**
*
* @default
*/
btnLabel?: string;
reciever?: string;
fileField?: string;
joinValues?: boolean;
extractValue?: boolean;
delimiter?: string;
downloadUrl?: string;
useChunk?: 'auto' | boolean;
chunkSize?: number;
startChunkApi?: string;
chunkApi?: string;
finishChunkApi?: string;
/**
*
* .txt,.csv
*
*
*
* @default text/plain
*/
accept?: string;
multiple?: boolean;
/**
* base64 form
*/
asBase64?: boolean;
/**
* File `asBlob` `asBase64` Form
*/
asBlob?: boolean;
/**
*
*/
autoUpload?: boolean;
/**
* `/api/upload/chunk`
*/
chunkApi?: SchemaApi;
/**
* 5M.
*
* @default 5242880
*/
chunkSize?: number;
/**
*
*/
delimiter?: string;
/**
*
* `http://xx.dom/filename=`
* `false`
*/
downloadUrl?: string;
/**
* `file`,
* @default file
*/
fileField?: string;
/**
* `/api/upload/finishChunkApi`
*
* @default /api/upload/finishChunkApi
*/
finishChunkApi?: SchemaApi;
/**
*
*/
hideUploadButton?: boolean;
/**
*
*/
maxLength?: number;
/**
*
*/
maxSize?: number;
/**
* `/api/upload/file`
*
* @default /api/upload/file
*/
reciever?: SchemaApi;
/**
* `/api/upload/startChunk`
*
* @default /api/upload/startChunk
*/
startChunkApi?: string;
/**
* 'auto' amis 10M amis
*/
useChunk?: 'auto' | boolean;
/**
* CSS
*/
btnClassName?: SchemaClassName;
/**
* CSS
*/
btnUploadClassName?: SchemaClassName;
/**
*
*/
multiple?: boolean;
/**
* 1. value
*
* 2. `value` `delimiter`
*
*/
joinValues?: boolean;
/**
* value
*/
extractValue?: boolean;
/**
*
*/
resetValue?: any;
/**
*
*/
autoFill?: {
[propName: string]: SchemaTokenizeableString;
};
/**
*
*/
stateTextMap?: {
init: string;
pending: string;
uploading: string;
error: string;
uploaded: string;
[propName: string]: string;
ready: string;
};
}
export interface FileProps
extends FormControlProps,
Omit<FileControlSchema, 'type'> {
stateTextMap: {
init: string;
pending: string;
uploading: string;
error: string;
uploaded: string;
ready: string;
};
asBase64?: boolean;
asBlob?: boolean;
resetValue?: string;
autoFill?: Object;
}
export interface FileX extends File {

View File

@ -1,15 +1,53 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import {evalJS, filter} from '../../utils/tpl';
import {isObjectShallowModified} from '../../utils/helper';
export interface FormulaProps extends FormControlProps {
/**
*
* https://baidu.gitee.io/amis/docs/components/form/formula
*/
export interface FormulaControlSchema extends FormBaseControl {
/**
*
*/
type: 'formula';
/**
* autoSet false
*/
id?: string;
/**
* data.xxx == \"a\" ${xx}
*/
condition?: string;
/**
*
*/
autoSet?: boolean;
/**
*
*/
formula?: string;
initSet?: boolean; // 是否初始就计算
autoSet?: boolean; // 是否自动计算
condition?: string; // 计算条件
/**
*
*/
initSet?: boolean;
/**
*
*/
name?: string;
}
export interface FormulaProps
extends FormControlProps,
Omit<FormulaControlSchema, 'type'> {}
export default class FormulaControl extends React.Component<
FormControlProps,
any

View File

@ -1,14 +1,57 @@
import {Renderer, RendererProps} from '../../factory';
import Grid, {ColumnNode, GridColumn, ColProps, ColumnArray} from '../Grid';
import Grid, {
ColumnNode,
GridColumn,
ColProps,
ColumnArray,
GridSchema,
GridColumnObject
} from '../Grid';
import {Schema} from '../../types';
import {FormItem, FormControlProps} from './Item';
import {
FormItem,
FormControlProps,
FormBaseControl,
FormControlSchema
} from './Item';
import pick from 'lodash/pick';
import React from 'react';
import cx from 'classnames';
import {IIRendererStore} from '../../store/iRenderer';
export interface GridProps extends FormControlProps {
/**
* Grid
* https://baidu.gitee.io/amis/docs/components/form/grid
*/
export interface GridControlSchema
extends FormBaseControl,
Omit<GridSchema, 'columns'> {
type: 'grid';
columns: Array<
GridColumnObject & {
/**
*
*/
controls?: Array<FormControlSchema>;
/**
* @deprecated tabs
*/
tabs?: any;
/**
* @deprecated fieldSet
*/
fieldSet?: any;
}
>;
}
export interface GridProps
extends FormControlProps,
Omit<GridControlSchema, 'type'> {
store: IIRendererStore;
}
const defaultHorizontal = {

View File

@ -7,16 +7,59 @@ import {
makeHorizontalDeeper
} from '../../utils/helper';
import cx from 'classnames';
import {FormItemWrap} from './Item';
import {FormBaseControl, FormControlSchema, FormItemWrap} from './Item';
import getExprProperties from '../../utils/filter-schema';
import {SchemaClassName} from '../../Schema';
export interface InputGroupProps extends RendererProps {
formMode?: string;
controls: Array<any>;
/**
* Group
* https://baidu.gitee.io/amis/docs/components/form/group
*/
export interface GroupControlSchema extends FormBaseControl {
type: 'group';
/**
* FormItem
*/
controls: Array<
FormControlSchema & {
/**
*
*/
mode?: 'normal' | 'inline' | 'horizontal';
/**
*
*/
columnClassName?: SchemaClassName;
/**
*
*/
columnRatio?: number;
}
>;
/**
*
*/
formMode?: 'normal' | 'horizontal' | 'inline';
/**
*
*/
gap?: 'xs' | 'sm' | 'normal';
direction: 'horizontal' | 'vertical';
/**
*
*/
direction?: 'horizontal' | 'vertical';
}
export interface InputGroupProps
extends RendererProps,
Omit<GroupControlSchema, 'type'> {}
@Renderer({
test: /(^|\/)form(?:\/.+)?\/control\/(?:\d+\/)?group$/,
name: 'group-control'
@ -173,7 +216,7 @@ export class ControlGroupRenderer extends React.Component<InputGroupProps> {
if (label) {
return (
<FormItemWrap
{...rest as any}
{...(rest as any)}
sizeMutable={false}
label={label}
renderControl={this.renderInput}

View File

@ -1,13 +1,47 @@
import React from 'react';
import {Renderer, RendererProps} from '../../factory';
import {FormItem, FormControlProps} from './Item';
import HBox from '../HBox';
import {
FormItem,
FormControlProps,
FormControlSchema,
FormBaseControl
} from './Item';
import HBox, {HBoxColumnObject, HBoxSchema} from '../HBox';
import {Schema} from '../../types';
import cx from 'classnames';
import {isVisible} from '../../utils/helper';
import {IIRendererStore} from '../../store/iRenderer';
interface HBoxProps extends FormControlProps {
/**
* HBox
* https://baidu.gitee.io/amis/docs/components/form/hbox
*/
export interface HBoxControlSchema
extends FormBaseControl,
Omit<HBoxSchema, 'columns'> {
type: 'hbox';
columns: Array<
HBoxColumnObject & {
/**
*
*/
controls?: Array<FormControlSchema>;
/**
* @deprecated tabs
*/
tabs?: any;
/**
* @deprecated fieldSet
*/
fieldSet?: any;
}
>;
}
interface HBoxProps extends FormControlProps, HBoxControlSchema {
store: IIRendererStore;
}

View File

@ -1,5 +1,13 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
/**
* Hidden
* https://baidu.gitee.io/amis/docs/components/form/hidden
*/
export interface HiddenControlSchema extends FormBaseControl {
type: 'hidden';
}
export default class HiddenControl extends React.Component<
FormControlProps,

View File

@ -6,9 +6,19 @@ import keycode from 'keycode';
import Downshift, {StateChangeOptions} from 'downshift';
import {autobind} from '../../utils/helper';
import {ICONS} from './IconPickerIcons';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import {Option} from '../../components/Select';
/**
*
* https://baidu.gitee.io/amis/docs/components/form/icon-picker
*/
export interface IconPickerControlSchema extends FormBaseControl {
type: 'icon-picker';
// 这就不应该成为一个 amis 控件。。。
}
export interface IconPickerProps extends FormControlProps {
placeholder?: string;
resetValue?: any;

View File

@ -1,5 +1,5 @@
import React from 'react';
import {FormItem, FormControlProps} from './Item';
import {FormItem, FormControlProps, FormBaseControl} from './Item';
import 'cropperjs/dist/cropper.css';
import Cropper from 'react-cropper';
import DropZone from 'react-dropzone';
@ -17,39 +17,218 @@ import {getNameFromUrl} from './File';
import ImageComponent, {ImageThumbProps} from '../Image';
import {TranslateFn} from '../../locale';
import {dataMapping} from '../../utils/tpl-builtin';
import {
SchemaApi,
SchemaClassName,
SchemaTokenizeableString,
SchemaUrlPath
} from '../../Schema';
let preventEvent = (e: any) => e.stopPropagation();
/**
* Image
* https://baidu.gitee.io/amis/docs/components/form/image
*/
export interface ImageControlSchema extends FormBaseControl {
/**
*
*/
type: 'image';
export interface ImageProps extends FormControlProps {
placeholder?: string;
reciever?: string;
limit?: {
width?: number;
height?: number;
maxWidth?: number;
minWidth?: number;
/**
*
*/
src?: SchemaUrlPath;
/**
*
*/
imageClassName?: string;
/**
*
*
*
* .txt,.csv
*
*
*/
accept?: string;
/**
*
*/
allowInput?: boolean;
/**
*
*/
autoUpload?: boolean;
/**
* CSS
*/
btnClassName?: SchemaClassName;
/**
* CSS
*/
btnUploadClassName?: SchemaClassName;
/**
* @deprecated
*/
compress?: boolean;
/**
* @deprecated
*/
compressOptions?: {
maxHeight?: number;
minHeight?: number;
aspectRatio?: number;
aspectRatioLabel?: string;
maxWidth?: number;
};
reCropable: boolean;
crop?:
| boolean
| {
/**
* `1` `1:1`
*
*
*/
aspectRatio?: number;
[propName: string]: any;
};
accept?: string;
guides?: boolean;
dragMode?: string;
viewMode?: number;
rotatable?: boolean;
scalable?: boolean;
};
/**
*
*/
reCropable?: boolean;
/**
*
*/
hideUploadButton?: boolean;
joinValues?: boolean;
extractValue?: boolean;
delimiter?: string;
autoUpload?: boolean;
/**
*
*/
limit?: {
/**
*
*/
aspectRatioLabel?: string;
/**
*
*/
aspectRatio?: number;
/**
*
*/
height?: number;
/**
*
*/
width?: number;
/**
*
*/
maxHeight?: number;
/**
*
*/
maxWidth?: number;
/**
*
*/
minHeight?: number;
/**
*
*/
minWidth?: number;
};
/**
*
*/
maxLength?: number;
/**
*
*/
maxSize?: number;
/**
* `/api/upload`
*/
reciever?: SchemaApi;
/**
* false,
*
* @deprecated
*/
showCompressOptions?: boolean;
/**
*
*/
multiple?: boolean;
/**
* value
* `value` `delimiter`
*/
joinValues?: boolean;
/**
*
*/
delimiter?: string;
/**
* value
*/
extractValue?: boolean;
/**
*
*/
resetValue?: any;
/**
*
*/
thumbMode?: 'w-full' | 'h-full' | 'contain' | 'cover';
/**
*
*/
thumbRatio?: '1:1' | '4:3' | '16:9';
/**
*
*/
autoFill?: {
[propName: string]: SchemaTokenizeableString;
};
}
let preventEvent = (e: any) => e.stopPropagation();
export interface ImageProps
extends FormControlProps,
Omit<ImageControlSchema, 'type'> {
onImageEnlarge?: (
info: Pick<ImageThumbProps, 'src' | 'originalSrc' | 'title' | 'caption'> & {
index?: number;
@ -58,7 +237,6 @@ export interface ImageProps extends FormControlProps {
>;
}
) => void;
autoFill?: Object;
}
export interface ImageState {

View File

@ -10,8 +10,34 @@ import {
} from '../../utils/helper';
import cx from 'classnames';
import getExprProperties from '../../utils/filter-schema';
import {FormItem, FormControlProps} from './Item';
import {
FormItem,
FormControlProps,
FormBaseControl,
FormControlSchema
} from './Item';
import {IFormStore} from '../../store/form';
import {SchemaClassName} from '../../Schema';
/**
* InputGroup
* https://baidu.gitee.io/amis/docs/components/form/input-group
*/
export interface InputGroupControlSchema extends FormBaseControl {
type: 'input-group';
/**
* FormItem
*/
controls: Array<
FormControlSchema & {
/**
*
*/
columnClassName?: SchemaClassName;
}
>;
}
export interface InputGroupProps extends FormControlProps {
controls: Array<any>;

View File

@ -20,8 +20,74 @@ import {BaseSchema, SchemaClassName} from '../../Schema';
import {TextControlSchema} from './Text';
import {SelectControlSchema} from './Select';
import {TextareaControlSchema} from './Textarea';
import {ArrayControlSchema} from './Array';
import {ComboControlSchema} from './Combo';
import {ButtonControlSchema} from './Button';
import {ButtonGroupControlSchema} from './ButtonGroup';
import {ButtonToolbarControlSchema} from './ButtonToolbar';
import {ChainedSelectControlSchema} from './ChainedSelect';
import {CheckboxControlSchema} from './Checkbox';
import {CheckboxesControlSchema} from './Checkboxes';
import {CityControlSchema} from './City';
import {ColorControlSchema} from './Color';
import {ConditionBuilderControlSchema} from './ConditionBuilder';
import {ContainerControlSchema} from './Container';
import {
DateControlSchema,
DateTimeControlSchema,
TimeControlSchema
} from './Date';
import {DateRangeControlSchema} from './DateRange';
import {DiffControlSchema} from './DiffEditor';
import {EditorControlSchema} from './Editor';
import {FieldSetControlSchema} from './FieldSet';
import {FileControlSchema} from './File';
import {FormulaControlSchema} from './Formula';
import {GridControlSchema} from './Grid';
import {GroupControlSchema} from './Group';
import {HBoxControlSchema} from './HBox';
import {HiddenControlSchema} from './Hidden';
import {IconPickerControlSchema} from './IconPicker';
import {ImageControlSchema} from './Image';
import {InputGroupControlSchema} from './InputGroup';
import {ListControlSchema} from './List';
import {LocationControlSchema} from './Location';
import {MatrixControlSchema} from './Matrix';
export type FormControlType =
| 'array'
| 'button'
| 'submit'
| 'reset'
| 'button-group'
| 'button-toolbar'
| 'chained-select'
| 'checkbox'
| 'checkboxes'
| 'city'
| 'color'
| 'combo'
| 'condition-builder'
| 'container'
| 'date'
| 'datetime'
| 'time'
| 'date-range'
| 'diff'
| 'editor'
| 'fieldset'
| 'file'
| 'formula'
| 'grid'
| 'group'
| 'hbox'
| 'hidden'
| 'icon-picker'
| 'image'
| 'input-group'
| 'list'
| 'location'
| 'matrix'
| 'text'
| 'password'
| 'email'
@ -31,6 +97,37 @@ export type FormControlType =
| 'textarea';
export type FormControlSchema =
| ArrayControlSchema
| ButtonControlSchema
| ButtonGroupControlSchema
| ButtonToolbarControlSchema
| ChainedSelectControlSchema
| CheckboxControlSchema
| CheckboxesControlSchema
| CityControlSchema
| ColorControlSchema
| ComboControlSchema
| ConditionBuilderControlSchema
| ContainerControlSchema
| DateControlSchema
| DateTimeControlSchema
| TimeControlSchema
| DateRangeControlSchema
| DiffControlSchema
| EditorControlSchema
| FieldSetControlSchema
| FileControlSchema
| FormulaControlSchema
| GridControlSchema
| GroupControlSchema
| HBoxControlSchema
| HiddenControlSchema
| IconPickerControlSchema
| ImageControlSchema
| InputGroupControlSchema
| ListControlSchema
| LocationControlSchema
| MatrixControlSchema
| TextControlSchema
| SelectControlSchema
| TextareaControlSchema;
@ -44,7 +141,7 @@ export interface FormBaseControl extends Omit<BaseSchema, 'type'> {
/**
*
*/
size?: 'xs' | 'sm' | 'md' | 'lg';
size?: 'xs' | 'sm' | 'md' | 'lg' | 'full';
/**
*
@ -299,7 +396,7 @@ export interface FormItemProps extends RendererProps {
disabled?: boolean;
btnDisabled: boolean;
defaultValue: any;
value: any;
value?: any;
prinstine: any;
setPrinstineValue: (value: any) => void;
onChange: (

View File

@ -1,15 +1,42 @@
import React from 'react';
import {OptionsControl, OptionsControlProps, Option} from './Options';
import {
OptionsControl,
OptionsControlProps,
Option,
FormOptionsControl
} from './Options';
import {Schema} from '../../types';
import {createObject, isEmpty} from '../../utils/helper';
import {dataMapping} from '../../utils/tpl-builtin';
import {SchemaCollection} from '../../Schema';
export interface ListProps extends OptionsControlProps {
imageClassName: string;
/**
* List
* https://baidu.gitee.io/amis/docs/components/form/list
*/
export interface ListControlSchema extends FormOptionsControl {
type: 'list';
/**
*
*/
submitOnDBClick?: boolean;
itemSchema?: Schema;
/**
* div类名
*/
imageClassName: string;
/**
*
*/
itemSchema?: SchemaCollection;
}
export interface ListProps
extends OptionsControlProps,
Omit<ListControlSchema, 'type' | 'options'> {}
export default class ListControl extends React.Component<ListProps, any> {
static propsList = ['itemSchema', 'value', 'renderFormItems'];
static defaultProps = {

View File

@ -1,15 +1,34 @@
import React from 'react';
import {themeable, ClassNamesFn} from '../../theme';
import FormItem, {FormControlProps} from './Item';
import {themeable, ClassNamesFn, ThemeProps} from '../../theme';
import FormItem, {FormBaseControl, FormControlProps} from './Item';
import LocationPicker from '../../components/LocationPicker';
export interface LocationControlProps extends FormControlProps {
vendor: 'baidu' | 'gaode' | 'tenxun';
/**
* Location
* https://baidu.gitee.io/amis/docs/components/form/location
*/
export interface LocationControlSchema extends FormBaseControl {
type: 'location';
/**
*
*/
vendor?: 'baidu' | 'gaode' | 'tenxun';
/**
* ak
*/
ak?: string;
}
export interface LocationControlProps
extends FormControlProps,
ThemeProps,
Omit<LocationControlSchema, 'type'> {
value: any;
ak: string;
onChange: (value: any) => void;
classnames: ClassNamesFn;
classPrefix: string;
vendor: 'baidu' | 'gaode' | 'tenxun';
ak: string;
}
export class LocationControl extends React.Component<LocationControlProps> {

View File

@ -5,11 +5,50 @@
import React from 'react';
import cx from 'classnames';
import {FormControlProps, FormItem} from './Item';
import {FormBaseControl, FormControlProps, FormItem} from './Item';
import {buildApi, isValidApi, isEffectiveApi} from '../../utils/api';
import {Checkbox, Spinner} from '../../components';
import {autobind, setVariable} from '../../utils/helper';
import {ApiObject} from '../../types';
import {SchemaApi} from '../../Schema';
/**
* Matrix
* https://baidu.gitee.io/amis/docs/components/form/matrix
*/
export interface MatrixControlSchema extends FormBaseControl {
type: 'matrix';
/**
* singleSelectMode时设置为false
*/
multiple?: boolean;
/**
* multiple为false时有效
*/
singleSelectMode?: boolean;
/**
* API options
*/
source?: SchemaApi;
columns?: Array<{
label: string;
[propName: string]: any;
}>;
rows?: Array<{
label: string;
[propName: string]: any;
}>;
/**
*
*/
rowLabel?: string;
}
export interface Column {
label: string;

View File

@ -20,7 +20,8 @@ import {
registerFormItem,
FormItemBasicConfig,
detectProps as itemDetectProps,
FormBaseControl
FormBaseControl,
FormControlSchema
} from './Item';
import {IFormItemStore} from '../../store/formItem';
export type OptionsControlComponent = React.ComponentType<FormControlProps>;
@ -38,7 +39,7 @@ import {
} from '../../components/Select';
import {filter} from '../../utils/tpl';
import findIndex from 'lodash/findIndex';
import {SchemaApi} from '../../Schema';
import {SchemaApi, SchemaTokenizeableString} from '../../Schema';
export {Option};
@ -51,7 +52,7 @@ export interface FormOptionsControl extends FormBaseControl {
/**
* API options
*/
source?: SchemaApi;
source?: SchemaApi | SchemaTokenizeableString;
/**
*
@ -85,6 +86,68 @@ export interface FormOptionsControl extends FormBaseControl {
* @default ''
*/
resetValue?: string;
/**
* API defer: true
*/
deferApi?: SchemaApi;
/**
*
*/
addApi?: Api;
/**
*
*/
addControls?: Array<FormControlSchema>;
/**
*
*/
creatable?: boolean;
/**
*
*/
createBtnLabel?: string;
/**
*
*/
editable?: boolean;
/**
* API
*/
editApi?: SchemaApi;
/**
*
*/
editControls?: Array<FormControlSchema>;
/**
*
*/
removable?: boolean;
/**
* API
*/
deleteApi?: SchemaApi;
/**
*
*/
deleteConfirmText?: string;
/**
*
*/
autoFill?: {
[propName: string]: SchemaTokenizeableString;
};
}
export interface OptionsBasicConfig extends FormItemBasicConfig {
@ -96,9 +159,10 @@ export interface OptionsConfig extends OptionsBasicConfig {
}
// 下发给注册进来的组件的属性。
export interface OptionsControlProps extends FormControlProps, OptionProps {
source?: Api;
name?: string;
export interface OptionsControlProps
extends FormControlProps,
Omit<FormOptionsControl, 'type'> {
options: Array<Option>;
onToggle: (
option: Option,
submitOnChange?: boolean,
@ -110,19 +174,13 @@ export interface OptionsControlProps extends FormControlProps, OptionProps {
setLoading: (value: boolean) => void;
reloadOptions: (setError?: boolean) => void;
deferLoad: (option: Option) => void;
creatable?: boolean;
onAdd?: (
idx?: number | Array<number>,
value?: any,
skipForm?: boolean
) => void;
addControls?: Array<any>;
editable?: boolean;
editControls?: Array<any>;
onEdit?: (value: Option, origin?: Option, skipForm?: boolean) => void;
removable?: boolean;
onDelete?: (value: Option) => void;
autoFill?: Object;
}
// 自己接收的属性。

View File

@ -6,7 +6,7 @@ import {BaseSchema, SchemaClassName, SchemaObject} from '../Schema';
export const ColProps = ['lg', 'md', 'sm', 'xs'];
export type GridColumn = BaseSchema & {
export type GridColumnObject = {
/**
* <768px时宽度占比
*/
@ -111,6 +111,8 @@ export type GridColumn = BaseSchema & {
*/
columnClassName?: SchemaClassName;
};
export type GridColumn = BaseSchema & GridColumnObject;
export type ColumnNode = GridColumn | ColumnArray;
export interface ColumnArray extends Array<ColumnNode> {}

View File

@ -5,7 +5,7 @@ import cx from 'classnames';
import {isVisible} from '../utils/helper';
import {BaseSchema, SchemaObject} from '../Schema';
export type HBoxColumn = {
export type HBoxColumnObject = {
columnClassName?: string;
width?: number | string;
@ -14,13 +14,15 @@ export type HBoxColumn = {
style?: {
[propName: string]: any;
};
} & BaseSchema; // 不能用 SchemaObject 呢,会报错
};
export type HBoxColumn = HBoxColumnObject & BaseSchema; // 不能用 SchemaObject 呢,会报错
/**
* Hbox
* https://baidu.gitee.io/amis/docs/components/hbox
*/
export interface HboxSchema extends BaseSchema {
export interface HBoxSchema extends BaseSchema {
/**
* each展示类型
*/
@ -28,7 +30,7 @@ export interface HboxSchema extends BaseSchema {
columns: Array<HBoxColumn>;
}
export interface HBoxProps extends RendererProps, HboxSchema {
export interface HBoxProps extends RendererProps, HBoxSchema {
className: string;
itemRender?: (
item: any,