diff --git a/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx b/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx index a9ae35395..acd576ff3 100644 --- a/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx @@ -10,6 +10,7 @@ import {getSchemaTpl, defaultValue} from 'amis-editor-core'; import {getEventControlConfig} from '../../renderer/event-control/helper'; import {ValidatorTag} from '../../validator'; import {resolveOptionType} from '../../util'; +import type {Schema} from 'amis'; export class ButtonGroupControlPlugin extends BasePlugin { static id = 'ButtonGroupControlPlugin'; @@ -126,7 +127,7 @@ export class ButtonGroupControlPlugin extends BasePlugin { getSchemaTpl('label'), getSchemaTpl('multiple'), getSchemaTpl('valueFormula', { - rendererSchema: context?.schema, + rendererSchema: (schema: Schema) => schema, useSelectMode: true, // 改用 Select 设置模式 visibleOn: 'this.options && this.options.length > 0' }), diff --git a/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx b/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx index 466183a8a..9bacc1226 100644 --- a/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx @@ -13,6 +13,7 @@ import { } from 'amis-editor-core'; import {ValidatorTag} from '../../validator'; import {getEventControlConfig} from '../../renderer/event-control/helper'; +import type {Schema} from 'amis'; export class ChainedSelectControlPlugin extends BasePlugin { static id = 'ChainedSelectControlPlugin'; @@ -114,7 +115,7 @@ export class ChainedSelectControlPlugin extends BasePlugin { getSchemaTpl('label'), getSchemaTpl('valueFormula', { - rendererSchema: context?.schema, + rendererSchema: (schema: Schema) => schema, mode: 'vertical', // 改成上下展示模式 rendererWrapper: true, label: tipedLabel('默认值', '请填入选项 Options 中 value 值') diff --git a/packages/amis-editor/src/plugin/Form/Checkboxes.tsx b/packages/amis-editor/src/plugin/Form/Checkboxes.tsx index b6655a7c3..458c62310 100644 --- a/packages/amis-editor/src/plugin/Form/Checkboxes.tsx +++ b/packages/amis-editor/src/plugin/Form/Checkboxes.tsx @@ -15,6 +15,7 @@ import { } from 'amis-editor-core'; import {ValidatorTag} from '../../validator'; +import type {Schema} from 'amis'; import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core'; import {getEventControlConfig} from '../../renderer/event-control/helper'; import {resolveOptionType} from '../../util'; @@ -166,7 +167,7 @@ export class CheckboxesControlPlugin extends BasePlugin { } ], getSchemaTpl('valueFormula', { - rendererSchema: context?.schema, + rendererSchema: (schema: Schema) => schema, useSelectMode: true, // 改用 Select 设置模式 visibleOn: 'this.options && this.options.length > 0' }), diff --git a/packages/amis-editor/src/plugin/Form/InputCity.tsx b/packages/amis-editor/src/plugin/Form/InputCity.tsx index de9fa91c0..a22b73b1f 100644 --- a/packages/amis-editor/src/plugin/Form/InputCity.tsx +++ b/packages/amis-editor/src/plugin/Form/InputCity.tsx @@ -13,6 +13,7 @@ import { BaseEventContext } from 'amis-editor-core'; import cloneDeep from 'lodash/cloneDeep'; +import type {Schema} from 'amis'; import {formItemControl} from '../../component/BaseControl'; import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core'; @@ -118,7 +119,7 @@ export class CityControlPlugin extends BasePlugin { }), getSchemaTpl('label'), getSchemaTpl('valueFormula', { - rendererSchema: context?.schema, + rendererSchema: (schema: Schema) => schema, rendererWrapper: true, mode: 'vertical' // 改成上下展示模式 }), diff --git a/packages/amis-editor/src/plugin/Form/InputDate.tsx b/packages/amis-editor/src/plugin/Form/InputDate.tsx index 96ff63f6e..a1bd9f709 100644 --- a/packages/amis-editor/src/plugin/Form/InputDate.tsx +++ b/packages/amis-editor/src/plugin/Form/InputDate.tsx @@ -6,6 +6,7 @@ import {ValidatorTag} from '../../validator'; import {getEventControlConfig} from '../../renderer/event-control/helper'; import {FormulaDateType} from '../../renderer/FormulaControl'; import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core'; +import type {Schema} from 'amis'; const formatX = [ { @@ -347,15 +348,7 @@ export class DateControlPlugin extends BasePlugin { pipeIn: defaultValue(true) }), getSchemaTpl('valueFormula', { - rendererSchema: () => { - const schema = this.manager.store.getSchema( - context.schema?.id, - 'id' - ); - return { - ...schema - }; - }, + rendererSchema: (schema: Schema) => schema, placeholder: '请选择静态值', header: '表达式或相对值', DateTimeType: FormulaDateType.IsDate, diff --git a/packages/amis-editor/src/plugin/Form/InputDateRange.tsx b/packages/amis-editor/src/plugin/Form/InputDateRange.tsx index ba959dae5..06a318b2b 100644 --- a/packages/amis-editor/src/plugin/Form/InputDateRange.tsx +++ b/packages/amis-editor/src/plugin/Form/InputDateRange.tsx @@ -8,6 +8,7 @@ import {FormulaDateType} from '../../renderer/FormulaControl'; import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core'; import {getRendererByName} from 'amis-core'; import omit from 'lodash/omit'; +import type {Schema} from 'amis'; const formatX = [ { @@ -405,11 +406,11 @@ export class DateRangeControlPlugin extends BasePlugin { }), getSchemaTpl('valueFormula', { - rendererSchema: { - ...context?.schema, + rendererSchema: (schema: Schema) => ({ + ...schema, size: 'full', mode: 'inline' - }, + }), mode: 'vertical', header: '表达式或相对值', DateTimeType: FormulaDateType.IsRange, @@ -419,11 +420,11 @@ export class DateRangeControlPlugin extends BasePlugin { name: 'minDate', header: '表达式或相对值', DateTimeType: FormulaDateType.IsDate, - rendererSchema: { - ...omit(context?.schema, ['shortcuts']), - value: context?.schema.minDate, + rendererSchema: (schema: Schema) => ({ + ...omit(schema, ['shortcuts']), + value: schema?.minDate, type: 'input-date' - }, + }), placeholder: '请选择静态值', needDeleteProps: ['minDate', 'ranges', 'shortcuts'], // 避免自我限制 label: tipedLabel('最小值', dateTooltip) @@ -432,11 +433,11 @@ export class DateRangeControlPlugin extends BasePlugin { name: 'maxDate', header: '表达式或相对值', DateTimeType: FormulaDateType.IsDate, - rendererSchema: { - ...omit(context?.schema, ['shortcuts']), - value: context?.schema.maxDate, + rendererSchema: (schema: Schema) => ({ + ...omit(schema, ['shortcuts']), + value: schema?.maxDate, type: 'input-date' - }, + }), placeholder: '请选择静态值', needDeleteProps: ['maxDate', 'ranges', 'shortcuts'], // 避免自我限制 label: tipedLabel('最大值', dateTooltip) @@ -446,11 +447,11 @@ export class DateRangeControlPlugin extends BasePlugin { name: 'minDuration', header: '表达式', DateTimeType: FormulaDateType.NotDate, - rendererSchema: { - ...context?.schema, - value: context?.schema.minDuration, + rendererSchema: (schema: Schema) => ({ + ...schema, + value: schema?.minDuration, type: 'input-text' - }, + }), placeholder: '请输入相对值', needDeleteProps: ['minDuration'], // 避免自我限制 label: tipedLabel('最小跨度', rangTooltip) @@ -460,11 +461,11 @@ export class DateRangeControlPlugin extends BasePlugin { name: 'maxDuration', header: '表达式', DateTimeType: FormulaDateType.NotDate, - rendererSchema: { - ...context?.schema, - value: context?.schema.maxDuration, + rendererSchema: (schema: Schema) => ({ + ...schema, + value: schema?.maxDuration, type: 'input-text' - }, + }), placeholder: '请输入相对值', needDeleteProps: ['maxDuration'], // 避免自我限制 label: tipedLabel('最大跨度', rangTooltip) diff --git a/packages/amis-editor/src/plugin/Form/InputTag.tsx b/packages/amis-editor/src/plugin/Form/InputTag.tsx index 5e7105577..d5735c602 100644 --- a/packages/amis-editor/src/plugin/Form/InputTag.tsx +++ b/packages/amis-editor/src/plugin/Form/InputTag.tsx @@ -11,6 +11,7 @@ import { import {formItemControl} from '../../component/BaseControl'; import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core'; import {resolveOptionType} from '../../util'; +import type {Schema} from 'amis'; export class TagControlPlugin extends BasePlugin { static id = 'TagControlPlugin'; @@ -31,7 +32,11 @@ export class TagControlPlugin extends BasePlugin { type: 'input-tag', label: '标签', name: 'tag', - options: ['红色', '绿色', '蓝色'] + options: [ + {label: '红色', value: 'red'}, + {label: '绿色', value: 'green'}, + {label: '蓝色', value: 'blue'} + ] }; previewSchema: any = { type: 'form', @@ -40,7 +45,7 @@ export class TagControlPlugin extends BasePlugin { wrapWithPanel: false, body: { ...this.scaffold, - value: '红色' + value: 'red' } }; @@ -168,7 +173,7 @@ export class TagControlPlugin extends BasePlugin { getSchemaTpl('clearable'), getSchemaTpl('optionsTip'), getSchemaTpl('valueFormula', { - rendererSchema: context?.schema, + rendererSchema: (schema: Schema) => schema, mode: 'vertical' // 改成上下展示模式 }), getSchemaTpl('joinValues'), diff --git a/packages/amis-editor/src/plugin/Form/InputTree.tsx b/packages/amis-editor/src/plugin/Form/InputTree.tsx index b6a0d9c69..102a32cf8 100644 --- a/packages/amis-editor/src/plugin/Form/InputTree.tsx +++ b/packages/amis-editor/src/plugin/Form/InputTree.tsx @@ -16,6 +16,7 @@ import { import {tipedLabel} from 'amis-editor-core'; import {ValidatorTag} from '../../validator'; import {resolveOptionType} from '../../util'; +import type {Schema} from 'amis'; export class TreeControlPlugin extends BasePlugin { static id = 'TreeControlPlugin'; @@ -418,10 +419,10 @@ export class TreeControlPlugin extends BasePlugin { hiddenOn: '!data.multiple || !data.autoCheckChildren' }), getSchemaTpl('valueFormula', { - rendererSchema: { - ...context?.schema, + rendererSchema: (schema: Schema) => ({ + ...schema, type: 'tree-select' - }, + }), visibleOn: 'this.options && this.options.length > 0' }), diff --git a/packages/amis-editor/src/plugin/Form/ListSelect.tsx b/packages/amis-editor/src/plugin/Form/ListSelect.tsx index 78d7dbd26..f05134702 100644 --- a/packages/amis-editor/src/plugin/Form/ListSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/ListSelect.tsx @@ -5,6 +5,7 @@ import {BasePlugin, BaseEventContext} from 'amis-editor-core'; import {formItemControl} from '../../component/BaseControl'; import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core'; import {resolveOptionType} from '../../util'; +import type {Schema} from 'amis'; export class ListControlPlugin extends BasePlugin { static id = 'ListControlPlugin'; @@ -118,7 +119,7 @@ export class ListControlPlugin extends BasePlugin { getSchemaTpl('multiple'), getSchemaTpl('extractValue'), getSchemaTpl('valueFormula', { - rendererSchema: context?.schema, + rendererSchema: (schema: Schema) => schema, mode: 'vertical', useSelectMode: true, // 改用 Select 设置模式 visibleOn: 'this.options && this.options.length > 0' diff --git a/packages/amis-editor/src/plugin/Form/NestedSelect.tsx b/packages/amis-editor/src/plugin/Form/NestedSelect.tsx index 793e8c7f6..05fdb4bcd 100644 --- a/packages/amis-editor/src/plugin/Form/NestedSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/NestedSelect.tsx @@ -9,6 +9,7 @@ import {BasePlugin, BaseEventContext, tipedLabel} from 'amis-editor-core'; import {ValidatorTag} from '../../validator'; import {getEventControlConfig} from '../../renderer/event-control/helper'; import {resolveOptionType} from '../../util'; +import type {Schema} from 'amis'; export class NestedSelectControlPlugin extends BasePlugin { static id = 'NestedSelectControlPlugin'; @@ -304,7 +305,7 @@ export class NestedSelectControlPlugin extends BasePlugin { } ], getSchemaTpl('valueFormula', { - rendererSchema: context?.schema + rendererSchema: (schema: Schema) => schema }), getSchemaTpl('hideNodePathLabel'), getSchemaTpl('labelRemark'), diff --git a/packages/amis-editor/src/plugin/Form/Radios.tsx b/packages/amis-editor/src/plugin/Form/Radios.tsx index f556a9321..b8e44493c 100644 --- a/packages/amis-editor/src/plugin/Form/Radios.tsx +++ b/packages/amis-editor/src/plugin/Form/Radios.tsx @@ -6,6 +6,7 @@ import {ValidatorTag} from '../../validator'; import {getEventControlConfig} from '../../renderer/event-control/helper'; import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core'; import {resolveOptionType} from '../../util'; +import type {Schema} from 'amis'; export class RadiosControlPlugin extends BasePlugin { static id = 'RadiosControlPlugin'; @@ -128,7 +129,7 @@ export class RadiosControlPlugin extends BasePlugin { }), getSchemaTpl('label'), getSchemaTpl('valueFormula', { - rendererSchema: context?.schema, + rendererSchema: (schema: Schema) => schema, useSelectMode: true, // 改用 Select 设置模式 visibleOn: 'this.options && this.options.length > 0' }), diff --git a/packages/amis-editor/src/plugin/Form/Select.tsx b/packages/amis-editor/src/plugin/Form/Select.tsx index 4aa522bd8..2d394e1e2 100644 --- a/packages/amis-editor/src/plugin/Form/Select.tsx +++ b/packages/amis-editor/src/plugin/Form/Select.tsx @@ -14,7 +14,7 @@ import {ValidatorTag} from '../../validator'; import {getEventControlConfig} from '../../renderer/event-control/helper'; import {resolveOptionType} from '../../util'; -import type {RendererProps} from 'amis'; +import type {Schema} from 'amis'; import type { EditorNodeType, RendererPluginAction, @@ -296,15 +296,7 @@ export class SelectControlPlugin extends BasePlugin { }), getSchemaTpl('checkAll'), getSchemaTpl('valueFormula', { - rendererSchema: () => { - const schema = this.manager.store.getSchema( - context.schema?.id, - 'id' - ); - return { - ...schema - }; - } + rendererSchema: (schema: Schema) => schema }), getSchemaTpl('labelRemark'), getSchemaTpl('remark'), diff --git a/packages/amis-editor/src/plugin/Form/Transfer.tsx b/packages/amis-editor/src/plugin/Form/Transfer.tsx index 9b734e151..48df3177f 100644 --- a/packages/amis-editor/src/plugin/Form/Transfer.tsx +++ b/packages/amis-editor/src/plugin/Form/Transfer.tsx @@ -7,6 +7,7 @@ import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core'; import {ValidatorTag} from '../../validator'; import {tipedLabel} from 'amis-editor-core'; import {resolveOptionType} from '../../util'; +import type {Schema} from 'amis'; export class TransferPlugin extends BasePlugin { static id = 'TransferPlugin'; @@ -184,11 +185,11 @@ export class TransferPlugin extends BasePlugin { }), getSchemaTpl('label'), getSchemaTpl('valueFormula', { - rendererSchema: { - ...context?.schema, + rendererSchema: (schema: Schema) => ({ + ...schema, type: 'select', multiple: true - }, + }), visibleOn: 'data.options.length > 0' }), getSchemaTpl('labelRemark'), diff --git a/packages/amis-editor/src/plugin/Pagination.tsx b/packages/amis-editor/src/plugin/Pagination.tsx index f811d584c..f88069d57 100644 --- a/packages/amis-editor/src/plugin/Pagination.tsx +++ b/packages/amis-editor/src/plugin/Pagination.tsx @@ -20,7 +20,7 @@ export class PaginationPlugin extends BasePlugin { name = '分页组件'; isBaseComponent = true; description = '分页组件,可以对列表进行分页展示,提高页面性能'; - tags = ['容器']; + tags = ['展示']; icon = 'fa fa-window-minimize'; lastLayoutSetting = ['pager']; layoutOptions = [ diff --git a/packages/amis-editor/src/renderer/FormulaControl.tsx b/packages/amis-editor/src/renderer/FormulaControl.tsx index 0e1bb785f..c895689b2 100644 --- a/packages/amis-editor/src/renderer/FormulaControl.tsx +++ b/packages/amis-editor/src/renderer/FormulaControl.tsx @@ -98,7 +98,7 @@ export interface FormulaControlProps extends FormControlProps { * 自定义渲染器: * 备注: 可用于设置指定组件类型编辑默认值,支持回调函数,但不支持异步获取 */ - rendererSchema?: any; // SchemaObject | Function | undefined; + rendererSchema?: any; // SchemaObject | (schema: Schema) => Schema | undefined; /** * 自定义渲染器 是否需要浅色边框包裹,默认不包裹 @@ -240,7 +240,8 @@ export default class FormulaControl extends React.Component< } if (typeof rendererSchema === 'function') { - return rendererSchema(); + const schema = this.props.data ? {...this.props.data} : undefined; + return rendererSchema(schema); } else { return rendererSchema; }