amis-editor 4.1.0-beta.1 → 4.1.0-beta.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. package/dist/component/Breadcrumb.d.ts +23 -2
  2. package/dist/component/Editor.d.ts +19 -0
  3. package/dist/component/Panel/RenderersPanel.d.ts +1 -2
  4. package/dist/component/RegionWrapper.d.ts +14 -7
  5. package/dist/component/RendererThumb.d.ts +5 -5
  6. package/dist/component/VRenderer.d.ts +4 -0
  7. package/dist/component/base/SearchCustomRendererPanel.d.ts +15 -0
  8. package/dist/component/base/SearchPanel.d.ts +83 -0
  9. package/dist/component/base/SearchRendererPanel.d.ts +2 -42
  10. package/dist/exports.min.js +1 -1
  11. package/dist/index.d.ts +4 -1
  12. package/dist/index.min.js +1 -1
  13. package/dist/manager.d.ts +14 -3
  14. package/dist/plugin/Card.d.ts +1 -0
  15. package/dist/plugin/Cards.d.ts +1 -0
  16. package/dist/plugin/Carousel.d.ts +1 -0
  17. package/dist/plugin/Chart.d.ts +1 -0
  18. package/dist/plugin/Collapse.d.ts +1 -0
  19. package/dist/plugin/Custom.d.ts +3 -0
  20. package/dist/plugin/CustomRegion.d.ts +43 -0
  21. package/dist/plugin/Flex.d.ts +1 -0
  22. package/dist/plugin/Form/Control.d.ts +1 -0
  23. package/dist/plugin/Form/InputURL.d.ts +1 -0
  24. package/dist/plugin/Grid.d.ts +1 -0
  25. package/dist/plugin/HBox.d.ts +1 -0
  26. package/dist/plugin/Json.d.ts +1 -0
  27. package/dist/plugin/List.d.ts +1 -0
  28. package/dist/plugin/Mapping.d.ts +1 -0
  29. package/dist/plugin/Markdown.d.ts +1 -0
  30. package/dist/plugin/Nav.d.ts +1 -0
  31. package/dist/plugin/Panel/Outline.d.ts +8 -0
  32. package/dist/plugin/Progress.d.ts +1 -0
  33. package/dist/plugin/QRCode.d.ts +1 -0
  34. package/dist/plugin/Reset.d.ts +0 -1
  35. package/dist/plugin/Service.d.ts +1 -0
  36. package/dist/plugin/Sparkline.d.ts +1 -0
  37. package/dist/plugin/Status.d.ts +1 -0
  38. package/dist/plugin/Steps.d.ts +1 -0
  39. package/dist/plugin/Submit.d.ts +0 -1
  40. package/dist/plugin/TableView.d.ts +1 -0
  41. package/dist/plugin/Tasks.d.ts +1 -0
  42. package/dist/plugin/TooltipWrapper.d.ts +1 -0
  43. package/dist/plugin/Video.d.ts +1 -0
  44. package/dist/plugin/WebComponent.d.ts +1 -0
  45. package/dist/plugin/Wrapper.d.ts +1 -0
  46. package/dist/plugin.d.ts +2 -2
  47. package/dist/store/editor.d.ts +20 -2
  48. package/dist/store/node.d.ts +6 -0
  49. package/dist/style.css +1 -1
  50. package/dist/util.d.ts +7 -2
  51. package/package.json +6 -3
  52. package/src/component/schemaTpl.tsx +2155 -0
  53. package/src/plugin/.DS_Store +0 -0
  54. package/src/plugin/Alert.tsx +87 -0
  55. package/src/plugin/AnchorNav.tsx +233 -0
  56. package/src/plugin/Audio.tsx +161 -0
  57. package/src/plugin/Avatar.tsx +77 -0
  58. package/src/plugin/Breadcrumb.tsx +107 -0
  59. package/src/plugin/Button.tsx +283 -0
  60. package/src/plugin/ButtonGroup.tsx +88 -0
  61. package/src/plugin/ButtonToolbar.tsx +89 -0
  62. package/src/plugin/CRUD.tsx +1832 -0
  63. package/src/plugin/Card.tsx +290 -0
  64. package/src/plugin/Cards.tsx +315 -0
  65. package/src/plugin/Carousel.tsx +386 -0
  66. package/src/plugin/Chart.tsx +218 -0
  67. package/src/plugin/CodeView.tsx +60 -0
  68. package/src/plugin/Collapse.tsx +143 -0
  69. package/src/plugin/CollapseGroup.tsx +167 -0
  70. package/src/plugin/Container.tsx +44 -0
  71. package/src/plugin/Custom.tsx +128 -0
  72. package/src/plugin/CustomRegion.tsx +150 -0
  73. package/src/plugin/Date.tsx +81 -0
  74. package/src/plugin/Datetime.tsx +75 -0
  75. package/src/plugin/Dialog.tsx +178 -0
  76. package/src/plugin/Divider.tsx +36 -0
  77. package/src/plugin/Drawer.tsx +217 -0
  78. package/src/plugin/DropDownButton.tsx +234 -0
  79. package/src/plugin/Each.tsx +152 -0
  80. package/src/plugin/ErrorRenderer.tsx +15 -0
  81. package/src/plugin/Flex.tsx +156 -0
  82. package/src/plugin/Form/ButtonGroupSelect.tsx +86 -0
  83. package/src/plugin/Form/ButtonToolbar.tsx +121 -0
  84. package/src/plugin/Form/ChainedSelect.tsx +70 -0
  85. package/src/plugin/Form/Checkbox.tsx +87 -0
  86. package/src/plugin/Form/Checkboxes.tsx +167 -0
  87. package/src/plugin/Form/CodeEditor.tsx +91 -0
  88. package/src/plugin/Form/Combo.tsx +582 -0
  89. package/src/plugin/Form/ConditionBuilder.tsx +324 -0
  90. package/src/plugin/Form/Control.tsx +139 -0
  91. package/src/plugin/Form/DiffEditor.tsx +117 -0
  92. package/src/plugin/Form/FieldSet.tsx +175 -0
  93. package/src/plugin/Form/Form.tsx +692 -0
  94. package/src/plugin/Form/Formula.tsx +91 -0
  95. package/src/plugin/Form/Group.tsx +300 -0
  96. package/src/plugin/Form/Hidden.tsx +56 -0
  97. package/src/plugin/Form/InputArray.tsx +228 -0
  98. package/src/plugin/Form/InputCity.tsx +93 -0
  99. package/src/plugin/Form/InputColor.tsx +123 -0
  100. package/src/plugin/Form/InputDate.tsx +175 -0
  101. package/src/plugin/Form/InputDateRange.tsx +225 -0
  102. package/src/plugin/Form/InputDateTime.tsx +183 -0
  103. package/src/plugin/Form/InputDateTimeRange.tsx +221 -0
  104. package/src/plugin/Form/InputEmail.tsx +33 -0
  105. package/src/plugin/Form/InputExcel.tsx +85 -0
  106. package/src/plugin/Form/InputFile.tsx +228 -0
  107. package/src/plugin/Form/InputGroup.tsx +105 -0
  108. package/src/plugin/Form/InputImage.tsx +277 -0
  109. package/src/plugin/Form/InputKV.tsx +72 -0
  110. package/src/plugin/Form/InputMonth.tsx +35 -0
  111. package/src/plugin/Form/InputMonthRange.tsx +195 -0
  112. package/src/plugin/Form/InputNumber.tsx +97 -0
  113. package/src/plugin/Form/InputPassword.tsx +33 -0
  114. package/src/plugin/Form/InputQuarter.tsx +35 -0
  115. package/src/plugin/Form/InputQuarterRange.tsx +195 -0
  116. package/src/plugin/Form/InputRange.tsx +121 -0
  117. package/src/plugin/Form/InputRating.tsx +78 -0
  118. package/src/plugin/Form/InputRepeat.tsx +69 -0
  119. package/src/plugin/Form/InputRichText.tsx +197 -0
  120. package/src/plugin/Form/InputSubForm.tsx +198 -0
  121. package/src/plugin/Form/InputTable.tsx +434 -0
  122. package/src/plugin/Form/InputTag.tsx +81 -0
  123. package/src/plugin/Form/InputText.tsx +186 -0
  124. package/src/plugin/Form/InputTime.tsx +95 -0
  125. package/src/plugin/Form/InputTree.tsx +240 -0
  126. package/src/plugin/Form/InputURL.tsx +34 -0
  127. package/src/plugin/Form/InputYear.tsx +35 -0
  128. package/src/plugin/Form/Item.tsx +325 -0
  129. package/src/plugin/Form/ListSelect.tsx +84 -0
  130. package/src/plugin/Form/LocationPicker.tsx +75 -0
  131. package/src/plugin/Form/MatrixCheckboxes.tsx +147 -0
  132. package/src/plugin/Form/NestedSelect.tsx +222 -0
  133. package/src/plugin/Form/Picker.tsx +217 -0
  134. package/src/plugin/Form/Radios.tsx +130 -0
  135. package/src/plugin/Form/Select.tsx +216 -0
  136. package/src/plugin/Form/Static.tsx +335 -0
  137. package/src/plugin/Form/Switch.tsx +116 -0
  138. package/src/plugin/Form/TabsTransfer.tsx +270 -0
  139. package/src/plugin/Form/Textarea.tsx +94 -0
  140. package/src/plugin/Form/Transfer.tsx +379 -0
  141. package/src/plugin/Form/TreeSelect.tsx +263 -0
  142. package/src/plugin/Form/UUID.tsx +48 -0
  143. package/src/plugin/Grid.tsx +799 -0
  144. package/src/plugin/HBox.tsx +727 -0
  145. package/src/plugin/IFrame.tsx +72 -0
  146. package/src/plugin/Image.tsx +318 -0
  147. package/src/plugin/Images.tsx +238 -0
  148. package/src/plugin/Json.tsx +76 -0
  149. package/src/plugin/Link.tsx +95 -0
  150. package/src/plugin/List.tsx +278 -0
  151. package/src/plugin/ListItem.tsx +233 -0
  152. package/src/plugin/Log.tsx +52 -0
  153. package/src/plugin/Mapping.tsx +156 -0
  154. package/src/plugin/Markdown.tsx +47 -0
  155. package/src/plugin/Nav.tsx +186 -0
  156. package/src/plugin/Operation.tsx +97 -0
  157. package/src/plugin/Others/Action.tsx +428 -0
  158. package/src/plugin/Others/BasicToolbar.tsx +591 -0
  159. package/src/plugin/Others/DataDebug.tsx +134 -0
  160. package/src/plugin/Others/TableCell.tsx +480 -0
  161. package/src/plugin/Others/Unknown.tsx +37 -0
  162. package/src/plugin/Page.tsx +308 -0
  163. package/src/plugin/Panel/AvailableRenderers.tsx +41 -0
  164. package/src/plugin/Panel/Code.tsx +44 -0
  165. package/src/plugin/Panel/Name.tsx +26 -0
  166. package/src/plugin/Panel/Outline.tsx +40 -0
  167. package/src/plugin/Panel.tsx +243 -0
  168. package/src/plugin/Plain.tsx +91 -0
  169. package/src/plugin/Progress.tsx +132 -0
  170. package/src/plugin/Property.tsx +139 -0
  171. package/src/plugin/QRCode.tsx +98 -0
  172. package/src/plugin/Reset.tsx +23 -0
  173. package/src/plugin/Service.tsx +167 -0
  174. package/src/plugin/Sparkline.tsx +40 -0
  175. package/src/plugin/Status.tsx +78 -0
  176. package/src/plugin/Steps.tsx +140 -0
  177. package/src/plugin/Submit.tsx +23 -0
  178. package/src/plugin/Table.tsx +440 -0
  179. package/src/plugin/TableView.tsx +711 -0
  180. package/src/plugin/Tabs.tsx +364 -0
  181. package/src/plugin/Tasks.tsx +276 -0
  182. package/src/plugin/Time.tsx +75 -0
  183. package/src/plugin/TooltipWrapper.tsx +193 -0
  184. package/src/plugin/Tpl.tsx +162 -0
  185. package/src/plugin/Video.tsx +160 -0
  186. package/src/plugin/WebComponent.tsx +56 -0
  187. package/src/plugin/Wizard.tsx +743 -0
  188. package/src/plugin/Wrapper.tsx +107 -0
  189. package/src/plugin.ts +1046 -0
  190. package/dist/150a58f3318ca7541ed9.png +0 -0
  191. package/dist/471adb97c322b226e589.png +0 -0
  192. package/dist/4de5f42360bc5946c3c2.png +0 -0
  193. package/dist/4e9968bba3855f088fed.png +0 -0
  194. package/dist/7f09c38ebc687fea847a.png +0 -0
  195. package/dist/c94073576487510314ea.png +0 -0
@@ -0,0 +1,216 @@
1
+ import React from 'react';
2
+ import {Button} from 'amis';
3
+ import {defaultValue, getSchemaTpl} from '../../component/schemaTpl';
4
+ import {registerEditorPlugin} from '../../manager';
5
+ import {
6
+ BasePlugin,
7
+ BasicSubRenderInfo,
8
+ RendererEventContext,
9
+ SubRendererInfo
10
+ } from '../../plugin';
11
+
12
+ export class SelectControlPlugin extends BasePlugin {
13
+ // 关联渲染器名字
14
+ rendererName = 'select';
15
+ $schema = '/schemas/SelectControlSchema.json';
16
+
17
+ order = -480;
18
+
19
+ // 组件名称
20
+ name = '下拉框';
21
+ isBaseComponent = true;
22
+ icon = 'fa fa-th-list';
23
+ description = `支持多选,输入提示,可使用<code>source</code>获取选项`;
24
+ docLink = '/amis/zh-CN/components/form/select';
25
+ tags = ['表单项'];
26
+ scaffold = {
27
+ type: 'select',
28
+ label: '选项',
29
+ name: 'select',
30
+ options: [
31
+ {
32
+ label: '选项A',
33
+ value: 'A'
34
+ },
35
+
36
+ {
37
+ label: '选项B',
38
+ value: 'B'
39
+ }
40
+ ]
41
+ };
42
+ previewSchema: any = {
43
+ type: 'form',
44
+ className: 'text-left',
45
+ mode: 'horizontal',
46
+ wrapWithPanel: false,
47
+ body: [
48
+ {
49
+ ...this.scaffold
50
+ }
51
+ ]
52
+ };
53
+
54
+ panelTitle = '下拉框';
55
+ panelBody = [
56
+ getSchemaTpl('switchDefaultValue'),
57
+
58
+ {
59
+ type: 'select',
60
+ name: 'value',
61
+ label: '默认值',
62
+ source: '${options}',
63
+ visibleOn: '!data.multiple && typeof this.value !== "undefined"'
64
+ },
65
+
66
+ {
67
+ type: 'select',
68
+ name: 'value',
69
+ label: '默认值',
70
+ source: '${options}',
71
+ multiple: true,
72
+ visibleOn: ' data.multiple && typeof this.value !== "undefined"'
73
+ },
74
+
75
+ getSchemaTpl('clearable'),
76
+ {
77
+ label: '可检索',
78
+ name: 'searchable',
79
+ type: 'switch',
80
+ mode: 'inline',
81
+ className: 'w-full'
82
+ },
83
+
84
+ {
85
+ label: '是否默认选择第一个',
86
+ name: 'selectFirst',
87
+ type: 'switch',
88
+ mode: 'inline',
89
+ className: 'w-full'
90
+ },
91
+
92
+ getSchemaTpl('fieldSet', {
93
+ title: '选项',
94
+ body: [
95
+ getSchemaTpl('multiple'),
96
+ {
97
+ label: '选中内容以单行模式显示',
98
+ name: 'valuesNoWrap',
99
+ type: 'switch',
100
+ mode: 'inline',
101
+ className: 'w-full',
102
+ visibleOn: 'this.multiple'
103
+ },
104
+ {
105
+ label: '可全选',
106
+ name: 'checkAll',
107
+ type: 'switch',
108
+ mode: 'inline',
109
+ value: false,
110
+ className: 'w-full',
111
+ onChange: (value: any, origin: any, item: any, form: any) => {
112
+ // 开启 “可全选” 时,需关联开启多选模式
113
+ value && form.setValueByName('multiple', true);
114
+ }
115
+ },
116
+ {
117
+ label: '自定义菜单模板',
118
+ name: 'menuTpl',
119
+ type: 'input-text'
120
+ },
121
+ {
122
+ label: '默认全选',
123
+ name: 'defaultCheckAll',
124
+ type: 'switch',
125
+ value: false,
126
+ visibleOn: 'this.checkAll',
127
+ mode: 'inline',
128
+ className: 'w-full'
129
+ },
130
+ {
131
+ type: 'input-text',
132
+ name: 'checkAllLabel',
133
+ label: '默认为 "全选" 的文字',
134
+ visibleOn: 'this.checkAll',
135
+ value: '全选'
136
+ },
137
+ getSchemaTpl('options'),
138
+ getSchemaTpl('source'),
139
+ getSchemaTpl('api', {
140
+ name: 'autoComplete',
141
+ label: '自动完成接口',
142
+ description:
143
+ '每次输入新内容后,将调用接口,根据接口返回更新选项。当前用户输入值在 <code>\\${term}</code> 中。'
144
+ }),
145
+ getSchemaTpl('joinValues'),
146
+ getSchemaTpl('delimiter'),
147
+ getSchemaTpl('extractValue'),
148
+ getSchemaTpl('autoFill'),
149
+
150
+ getSchemaTpl('creatable'),
151
+ getSchemaTpl('createBtnLabel', {
152
+ visibleOn: 'data.creatable'
153
+ }),
154
+ getSchemaTpl('api', {
155
+ label: '新增选项接口',
156
+ name: 'addApi',
157
+ visibleOn: 'data.creatable'
158
+ }),
159
+ {
160
+ name: 'addControls',
161
+ visibleOn: 'data.creatable',
162
+ pipeIn: defaultValue([
163
+ {
164
+ type: 'input-text',
165
+ name: 'label',
166
+ label: false,
167
+ placeholder: '请输入名称'
168
+ }
169
+ ]),
170
+ asFormItem: true,
171
+ children: ({value, onChange, data}: any) => (
172
+ <Button
173
+ size="sm"
174
+ level="danger"
175
+ className="m-b"
176
+ onClick={() => {
177
+ this.manager.openSubEditor({
178
+ title: '配置新建选项表单项',
179
+ value: {
180
+ type: 'dialog',
181
+ body: value || [
182
+ {
183
+ type: 'input-text',
184
+ name: 'label',
185
+ label: false,
186
+ placeholder: '请输入名称'
187
+ }
188
+ ]
189
+ },
190
+ onChange: value => onChange(value, 'addControls')
191
+ });
192
+ }}
193
+ block
194
+ >
195
+ 配置新建选项表单项
196
+ </Button>
197
+ )
198
+ },
199
+
200
+ getSchemaTpl('editable'),
201
+ getSchemaTpl('api', {
202
+ label: '编辑选项接口',
203
+ name: 'editApi'
204
+ }),
205
+
206
+ getSchemaTpl('removable'),
207
+ getSchemaTpl('api', {
208
+ label: '删除选项接口',
209
+ name: 'deleteApi'
210
+ })
211
+ ]
212
+ })
213
+ ];
214
+ }
215
+
216
+ registerEditorPlugin(SelectControlPlugin);
@@ -0,0 +1,335 @@
1
+ import React from 'react';
2
+ import {Button} from 'amis';
3
+ import {availableLanguages} from 'amis/lib/renderers/Form/Editor';
4
+ import {
5
+ defaultValue,
6
+ getSchemaTpl,
7
+ valuePipeOut
8
+ } from '../../component/schemaTpl';
9
+ import {registerEditorPlugin} from '../../manager';
10
+ import {
11
+ BaseEventContext,
12
+ BasePlugin,
13
+ BasicSubRenderInfo,
14
+ PluginEvent,
15
+ RendererEventContext,
16
+ ReplaceEventContext,
17
+ SubRendererInfo
18
+ } from '../../plugin';
19
+ import {EditorNodeType} from '../../store/node';
20
+ import {mockValue} from '../../mocker';
21
+
22
+ export class StaticControlPlugin extends BasePlugin {
23
+ // 关联渲染器名字
24
+ rendererName = 'static';
25
+ $schema = '/schemas/StaticControlSchema.json';
26
+
27
+ order = -390;
28
+
29
+ // 组件名称
30
+ name = '静态展示框';
31
+ isBaseComponent = true;
32
+ icon = 'fa fa-info';
33
+ description = `纯用来展示数据,可用来展示<code>json、date、image、progress</code>等数据`;
34
+ docLink = '/amis/zh-CN/components/form/static';
35
+ tags = ['表单项'];
36
+ scaffold = {
37
+ type: 'static',
38
+ label: '描述'
39
+ };
40
+ previewSchema: any = {
41
+ type: 'form',
42
+ className: 'text-left',
43
+ mode: 'horizontal',
44
+ wrapWithPanel: false,
45
+ body: [
46
+ {
47
+ ...this.scaffold,
48
+ value: '静态值'
49
+ }
50
+ ]
51
+ };
52
+ multifactor = true;
53
+
54
+ panelTitle = '静态展示';
55
+ panelBodyCreator = (context: BaseEventContext) => {
56
+ return [
57
+ /*{
58
+ children: (
59
+ <Button
60
+ size="sm"
61
+ level="info"
62
+ className="m-b"
63
+ block
64
+ onClick={this.exchangeRenderer.bind(this, context.id)}
65
+ >
66
+ 更改渲染器类型
67
+ </Button>
68
+ )
69
+ },*/
70
+ getSchemaTpl('switchDefaultValue'),
71
+
72
+ {
73
+ type: 'input-text',
74
+ name: 'value',
75
+ label: '默认值',
76
+ visibleOn: 'typeof this.value !== "undefined"'
77
+ },
78
+
79
+ {
80
+ name: 'quickEdit',
81
+ label: '启用快速编辑',
82
+ type: 'switch',
83
+ pipeIn: (value: any) => !!value,
84
+ mode: 'inline',
85
+ className: 'w-full'
86
+ },
87
+
88
+ {
89
+ visibleOn: 'data.quickEdit',
90
+ name: 'quickEdit.mode',
91
+ type: 'button-group-select',
92
+ value: 'popOver',
93
+ label: '快速编辑模式',
94
+ size: 'xs',
95
+ mode: 'inline',
96
+ className: 'w-full',
97
+ options: [
98
+ {
99
+ label: '下拉',
100
+ value: 'popOver'
101
+ },
102
+ {
103
+ label: '内嵌',
104
+ value: 'inline'
105
+ }
106
+ ]
107
+ },
108
+
109
+ {
110
+ visibleOn: 'data.quickEdit',
111
+ name: 'quickEdit.saveImmediately',
112
+ label: '是否立即保存',
113
+ type: 'switch',
114
+ mode: 'inline',
115
+ className: 'w-full',
116
+ description: '开启后修改即提交,而不是标记修改批量提交。',
117
+ descriptionClassName: 'help-block m-b-none',
118
+ pipeIn: (value: any) => !!value
119
+ },
120
+
121
+ getSchemaTpl('api', {
122
+ label: '立即保存接口',
123
+ description:
124
+ '是否单独给立即保存配置接口,如果不配置,则默认使用quickSaveItemApi。',
125
+ name: 'quickEdit.saveImmediately.api',
126
+ visibleOn: 'this.quickEdit && this.quickEdit.saveImmediately'
127
+ }),
128
+
129
+ {
130
+ visibleOn: 'data.quickEdit',
131
+ name: 'quickEdit',
132
+ asFormItem: true,
133
+ children: ({value, onChange, data}: any) => {
134
+ if (value === true) {
135
+ value = {};
136
+ }
137
+
138
+ const originMode = value.mode;
139
+
140
+ value = {
141
+ type: 'input-text',
142
+ name: data.name,
143
+ ...value
144
+ };
145
+ delete value.mode;
146
+
147
+ // todo 多个快速编辑表单模式看来只能代码模式编辑了。
148
+
149
+ return (
150
+ <Button
151
+ level="info"
152
+ className="m-b"
153
+ size="sm"
154
+ block
155
+ onClick={() => {
156
+ this.manager.openSubEditor({
157
+ title: '配置快速编辑类型',
158
+ value: value,
159
+ slot: {
160
+ type: 'form',
161
+ mode: 'normal',
162
+ body: ['$$'],
163
+ wrapWithPanel: false
164
+ },
165
+ onChange: value =>
166
+ onChange(
167
+ {
168
+ ...value,
169
+ mode: originMode
170
+ },
171
+ 'quickEdit'
172
+ )
173
+ });
174
+ }}
175
+ >
176
+ 配置快速编辑
177
+ </Button>
178
+ );
179
+ }
180
+ },
181
+
182
+ {
183
+ name: 'popOver',
184
+ label: '启用查看更多展示',
185
+ type: 'switch',
186
+ pipeIn: (value: any) => !!value,
187
+ mode: 'inline',
188
+ className: 'w-full'
189
+ },
190
+
191
+ {
192
+ name: 'popOver.mode',
193
+ label: '查看更多弹出模式',
194
+ type: 'select',
195
+ visibleOn: 'data.popOver',
196
+ pipeIn: defaultValue('popOver'),
197
+ options: [
198
+ {
199
+ label: '默认',
200
+ value: 'popOver'
201
+ },
202
+
203
+ {
204
+ label: '弹框',
205
+ value: 'dialog'
206
+ },
207
+
208
+ {
209
+ label: '抽出式弹框',
210
+ value: 'drawer'
211
+ }
212
+ ]
213
+ },
214
+
215
+ {
216
+ name: 'popOver.position',
217
+ label: '查看更多弹出模式',
218
+ type: 'select',
219
+ visibleOn: 'data.popOver && data.popOver.mode === "popOver"',
220
+ pipeIn: defaultValue('center'),
221
+ options: [
222
+ {
223
+ label: '目标中部',
224
+ value: 'center'
225
+ },
226
+
227
+ {
228
+ label: '目标左上角',
229
+ value: 'left-top'
230
+ },
231
+
232
+ {
233
+ label: '目标右上角',
234
+ value: 'right-top'
235
+ },
236
+
237
+ {
238
+ label: '目标左下角',
239
+ value: 'left-bottom'
240
+ },
241
+
242
+ {
243
+ label: '目标右下角',
244
+ value: 'right-bottom'
245
+ },
246
+
247
+ {
248
+ label: '页面左上角',
249
+ value: 'fixed-left-top'
250
+ },
251
+
252
+ {
253
+ label: '页面右上角',
254
+ value: 'fixed-right-top'
255
+ },
256
+
257
+ {
258
+ label: '页面左下角',
259
+ value: 'fixed-left-bottom'
260
+ },
261
+
262
+ {
263
+ label: '页面右下角',
264
+ value: 'fixed-right-bottom'
265
+ }
266
+ ]
267
+ },
268
+
269
+ {
270
+ visibleOn: 'data.popOver',
271
+ name: 'popOver',
272
+ asFormItem: true,
273
+ children: ({value, onChange}: any) => {
274
+ value = {
275
+ type: 'panel',
276
+ title: '查看详情',
277
+ body: '内容详情',
278
+ ...value
279
+ };
280
+
281
+ return (
282
+ <Button
283
+ level="info"
284
+ className="m-b"
285
+ size="sm"
286
+ block
287
+ onClick={() => {
288
+ this.manager.openSubEditor({
289
+ title: '配置查看更多展示内容',
290
+ value: value,
291
+ onChange: value => onChange(value, 'quickEdit')
292
+ });
293
+ }}
294
+ >
295
+ 查看更多内容配置
296
+ </Button>
297
+ );
298
+ }
299
+ },
300
+
301
+ getSchemaTpl('borderMode'),
302
+ {
303
+ name: 'copyable',
304
+ label: '启用内容复制功能',
305
+ type: 'switch',
306
+ pipeIn: (value: any) => !!value,
307
+ mode: 'inline',
308
+ className: 'w-full'
309
+ },
310
+
311
+ {
312
+ visibleOn: 'data.copyable',
313
+ name: 'copyable.content',
314
+ type: 'textarea',
315
+ label: '复制内容模板',
316
+ description: '默认为当前字段值,可定制。'
317
+ }
318
+ ];
319
+ };
320
+
321
+ filterProps(props: any, node: EditorNodeType) {
322
+ props.$$id = node.id;
323
+
324
+ if (typeof props.value === 'undefined') {
325
+ props.value = mockValue(props);
326
+ }
327
+ return props;
328
+ }
329
+
330
+ /*exchangeRenderer(id: string) {
331
+ this.manager.showReplacePanel(id, '展示');
332
+ }*/
333
+ }
334
+
335
+ registerEditorPlugin(StaticControlPlugin);
@@ -0,0 +1,116 @@
1
+ import {relativeValueRe} from 'amis';
2
+ import {availableLanguages} from 'amis/lib/renderers/Form/Editor';
3
+ import {
4
+ defaultValue,
5
+ getSchemaTpl,
6
+ valuePipeOut
7
+ } from '../../component/schemaTpl';
8
+ import {registerEditorPlugin} from '../../manager';
9
+ import {
10
+ BasePlugin,
11
+ BasicSubRenderInfo,
12
+ RendererEventContext,
13
+ SubRendererInfo
14
+ } from '../../plugin';
15
+
16
+ export class SwitchControlPlugin extends BasePlugin {
17
+ // 关联渲染器名字
18
+ rendererName = 'switch';
19
+ $schema = '/schemas/SwitchControlSchema.json';
20
+
21
+ order = -400;
22
+
23
+ // 组件名称
24
+ name = '开关';
25
+ isBaseComponent = true;
26
+ icon = 'fa fa-toggle-on';
27
+ description = `开关控件`;
28
+ docLink = '/amis/zh-CN/components/form/switch';
29
+ tags = ['表单项'];
30
+ scaffold = {
31
+ type: 'switch',
32
+ option: '开关',
33
+ name: 'switch'
34
+ };
35
+ previewSchema: any = {
36
+ type: 'form',
37
+ className: 'text-left',
38
+ mode: 'horizontal',
39
+ wrapWithPanel: false,
40
+ body: [
41
+ {
42
+ ...this.scaffold,
43
+ label: '开关表单'
44
+ }
45
+ ]
46
+ };
47
+
48
+ panelTitle = '开关';
49
+ panelBody = [
50
+ getSchemaTpl('switchDefaultValue', {
51
+ pipeOut: (value: any, origin: any, data: any) =>
52
+ value ? data.trueValue : undefined
53
+ }),
54
+ {
55
+ type: 'switch',
56
+ name: 'value',
57
+ label: '默认勾选',
58
+ mode: 'inline',
59
+ className: 'w-full',
60
+ visibleOn: 'typeof this.value !== "undefined"',
61
+ pipeOut: (value: any, origin: any, data: any) =>
62
+ value ? data.trueValue : data.falseValue
63
+ },
64
+ {
65
+ name: 'option',
66
+ type: 'input-text',
67
+ label: '选项说明'
68
+ },
69
+ {
70
+ label: '选项位置',
71
+ name: 'optionAtLeft',
72
+ type: 'button-group-select',
73
+ size: 'sm',
74
+ value: false,
75
+ options: [
76
+ {
77
+ label: '左',
78
+ value: true
79
+ },
80
+
81
+ {
82
+ label: '右',
83
+ value: false
84
+ }
85
+ ]
86
+ },
87
+ {
88
+ type: 'input-text',
89
+ label: '勾选后的值',
90
+ name: 'trueValue',
91
+ value: true,
92
+ pipeOut: valuePipeOut
93
+ },
94
+ {
95
+ type: 'input-text',
96
+ label: '未勾选的值',
97
+ name: 'falseValue',
98
+ value: false,
99
+ pipeOut: valuePipeOut
100
+ },
101
+
102
+ {
103
+ name: 'onText',
104
+ type: 'input-text',
105
+ label: '开启时的文本'
106
+ },
107
+
108
+ {
109
+ name: 'offText',
110
+ type: 'input-text',
111
+ label: '关闭时的文本'
112
+ }
113
+ ];
114
+ }
115
+
116
+ registerEditorPlugin(SwitchControlPlugin);