mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 04:48:32 +08:00
Merge remote-tracking branch 'amis/master'
This commit is contained in:
commit
62c83d58a9
@ -106,9 +106,10 @@ export const detectProps = itemDetectProps.concat([
|
||||
'extractValue'
|
||||
]);
|
||||
|
||||
export function asOptionsControl(config: OptionsConfig) {
|
||||
return function (Control: React.ComponentType<OptionsControlProps>) {
|
||||
return class FormOptionsItem extends React.Component<OptionsProps, any> {
|
||||
export function registerOptionsControl(config: OptionsConfig) {
|
||||
const Control = config.component;
|
||||
|
||||
class FormOptionsItem extends React.Component<OptionsProps, any> {
|
||||
static displayName = `OptionsControl(${config.type})`;
|
||||
static defaultProps = {
|
||||
delimiter: ',',
|
||||
@ -343,10 +344,7 @@ export function asOptionsControl(config: OptionsConfig) {
|
||||
let valueArray = formItem.getSelectedOptions(value).concat();
|
||||
const idx = findIndex(
|
||||
valueArray,
|
||||
optionValueCompare(
|
||||
option[valueField || 'value'],
|
||||
valueField || 'value'
|
||||
)
|
||||
optionValueCompare(option[valueField || 'value'], valueField || 'value')
|
||||
);
|
||||
let newValue: string | Array<Option> | Option = '';
|
||||
|
||||
@ -659,10 +657,7 @@ export function asOptionsControl(config: OptionsConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!skipForm &&
|
||||
(!Array.isArray(editControls) || !editControls.length)
|
||||
) {
|
||||
if (!skipForm && (!Array.isArray(editControls) || !editControls.length)) {
|
||||
editControls = [
|
||||
{
|
||||
type: 'text',
|
||||
@ -778,8 +773,7 @@ export function asOptionsControl(config: OptionsConfig) {
|
||||
const options = model.options.concat();
|
||||
const idx = findIndex(
|
||||
options,
|
||||
item =>
|
||||
item[valueField || 'value'] == value[valueField || 'value']
|
||||
item => item[valueField || 'value'] == value[valueField || 'value']
|
||||
);
|
||||
|
||||
if (~idx) {
|
||||
@ -822,9 +816,7 @@ export function asOptionsControl(config: OptionsConfig) {
|
||||
creatable={
|
||||
creatable || (creatable !== false && isEffectiveApi(addApi))
|
||||
}
|
||||
editable={
|
||||
editable || (editable !== false && isEffectiveApi(editApi))
|
||||
}
|
||||
editable={editable || (editable !== false && isEffectiveApi(editApi))}
|
||||
removable={
|
||||
removable || (removable !== false && isEffectiveApi(deleteApi))
|
||||
}
|
||||
@ -834,17 +826,12 @@ export function asOptionsControl(config: OptionsConfig) {
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export function registerOptionsControl(config: OptionsConfig) {
|
||||
const Control = config.component;
|
||||
|
||||
return registerFormItem({
|
||||
...(config as FormItemBasicConfig),
|
||||
strictMode: false,
|
||||
component: asOptionsControl(config)(Control)
|
||||
component: FormOptionsItem
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@ import {LazyComponent} from '../../components';
|
||||
import {isAlive} from 'mobx-state-tree';
|
||||
import {asFormItem} from './Item';
|
||||
import {SimpleMap} from '../../utils/SimpleMap';
|
||||
import {asOptionsControl} from './Options';
|
||||
export type FormGroup = FormSchema & {
|
||||
title?: string;
|
||||
className?: string;
|
||||
@ -1027,11 +1026,7 @@ export default class Form extends React.Component<FormProps, object> {
|
||||
control.options || {
|
||||
strictMode: false
|
||||
}
|
||||
)(
|
||||
control.options || control.source
|
||||
? asOptionsControl(control.component)
|
||||
: control.component
|
||||
);
|
||||
)(control.component);
|
||||
this.componentCache.set(control.component, cache);
|
||||
control.component = cache;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user