From 3289a6301e2ae836e579d31766f09e22e2000daf Mon Sep 17 00:00:00 2001 From: weien huang Date: Wed, 13 Mar 2024 11:12:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9ETransferPicker?= =?UTF-8?q?=E7=9A=84=E7=BC=96=E8=BE=91=E5=99=A8=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amis-editor/src/plugin/Form/Transfer.tsx | 67 ++++++++++++++++++- .../src/plugin/Form/TransferPicker.tsx | 51 ++++++++++++++ packages/amis-editor/src/plugin/index.ts | 1 + 3 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 packages/amis-editor/src/plugin/Form/TransferPicker.tsx diff --git a/packages/amis-editor/src/plugin/Form/Transfer.tsx b/packages/amis-editor/src/plugin/Form/Transfer.tsx index 212634f6c..ebd826ecd 100644 --- a/packages/amis-editor/src/plugin/Form/Transfer.tsx +++ b/packages/amis-editor/src/plugin/Form/Transfer.tsx @@ -1,8 +1,17 @@ -import {EditorManager, EditorNodeType, getSchemaTpl} from 'amis-editor-core'; +import { + EditorManager, + EditorNodeType, + defaultValue, + getSchemaTpl +} from 'amis-editor-core'; import {registerEditorPlugin} from 'amis-editor-core'; import {BasePlugin, BaseEventContext} from 'amis-editor-core'; import {getEventControlConfig} from '../../renderer/event-control/helper'; -import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core'; +import { + RendererPluginAction, + RendererPluginEvent, + undefinedPipeOut +} from 'amis-editor-core'; import {ValidatorTag} from '../../validator'; import {tipedLabel} from 'amis-editor-core'; @@ -373,7 +382,59 @@ export class TransferPlugin extends BasePlugin { label: 'AddOn', visibleOn: 'this.addOn && this.addOn.type === "text"' }) - ]) + ]), + ...(this.rendererName === 'transfer-picker' + ? [ + { + title: '边框', + key: 'borderMode', + body: [getSchemaTpl('borderMode')] + }, + { + title: '弹窗', + key: 'picker', + body: [ + { + name: 'pickerSize', + type: 'select', + pipeIn: defaultValue(''), + pipeOut: undefinedPipeOut, + label: '弹窗大小', + options: [ + { + label: '默认', + value: '' + }, + { + value: 'sm', + label: '小' + }, + + { + label: '中', + value: 'md' + }, + + { + label: '大', + value: 'lg' + }, + + { + label: '特大', + value: 'xl' + }, + + { + label: '全屏', + value: 'full' + } + ] + } + ] + } + ] + : []) ]) }, { diff --git a/packages/amis-editor/src/plugin/Form/TransferPicker.tsx b/packages/amis-editor/src/plugin/Form/TransferPicker.tsx new file mode 100644 index 000000000..591bb2504 --- /dev/null +++ b/packages/amis-editor/src/plugin/Form/TransferPicker.tsx @@ -0,0 +1,51 @@ +import {registerEditorPlugin} from 'amis-editor-core'; + +import {TransferPlugin} from './Transfer'; + +export class TransferPickerPlugin extends TransferPlugin { + static id = 'TransferPickerPlugin'; + // 关联渲染器名字 + rendererName = 'transfer-picker'; + $schema = '/schemas/TransferPickerControlSchema.json'; + + // 组件名称 + name = '穿梭选择器'; + isBaseComponent = true; + icon = 'fa fa-th-list'; + pluginIcon = 'transfer-plugin'; + description = '穿梭选择器组件'; + docLink = '/amis/zh-CN/components/form/transfer-picker'; + tags = ['表单项']; + scaffold = { + label: '分组', + type: 'transfer-picker', + name: 'transfer-picker', + options: [ + { + label: '诸葛亮', + value: 'zhugeliang' + }, + { + label: '曹操', + value: 'caocao' + } + ], + selectMode: 'list', + resultListModeFollowSelect: false + }; + previewSchema: any = { + type: 'form', + className: 'text-left', + mode: 'horizontal', + wrapWithPanel: false, + body: [ + { + ...this.scaffold + } + ] + }; + + notRenderFormZone = true; +} + +registerEditorPlugin(TransferPickerPlugin); diff --git a/packages/amis-editor/src/plugin/index.ts b/packages/amis-editor/src/plugin/index.ts index cde8e8a99..08b26cfe3 100644 --- a/packages/amis-editor/src/plugin/index.ts +++ b/packages/amis-editor/src/plugin/index.ts @@ -45,6 +45,7 @@ export * from './Form/InputRange'; // 滑块 export * from './Form/InputRating'; // 评分 export * from './Form/InputCity'; // 城市选择 export * from './Form/Transfer'; // 穿梭器 +export * from './Form/TransferPicker'; // 穿梭选择器 export * from './Form/TabsTransfer'; // 组合穿梭器 export * from './Form/InputColor'; // 颜色框 export * from './Form/ConditionBuilder'; // 条件组合