amis-editor 4.2.0-beta.2 → 5.1.9-beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. package/dist/6dbcbb49b6fd405190a9.png +0 -0
  2. package/dist/component/Editor.d.ts +16 -0
  3. package/dist/component/RegionWrapper.d.ts +10 -0
  4. package/dist/component/VRenderer.d.ts +10 -0
  5. package/dist/component/base/BackTop.d.ts +1 -1
  6. package/dist/component/control/APIControl.d.ts +1158 -0
  7. package/dist/component/control/ActionAPIControl.d.ts +1158 -0
  8. package/dist/component/control/BadgeControl.d.ts +133 -0
  9. package/dist/component/control/BaseControl.d.ts +248 -0
  10. package/dist/component/control/DataBindingControl.d.ts +14 -0
  11. package/dist/component/control/DataPickerControl.d.ts +13 -0
  12. package/dist/component/control/DateShortCutControl.d.ts +83 -0
  13. package/dist/component/control/FormulaControl.d.ts +51 -0
  14. package/dist/component/{Control → control}/OptionControl.d.ts +23 -34
  15. package/dist/component/{Control → control}/PopoverEdit.d.ts +0 -0
  16. package/dist/component/control/StatusControl.d.ts +44 -0
  17. package/dist/component/control/SwitchMoreControl.d.ts +224 -0
  18. package/dist/component/control/ValidationControl.d.ts +65 -0
  19. package/dist/component/control/ValidationItem.d.ts +46 -0
  20. package/dist/component/control/style-control/Background.d.ts +17 -0
  21. package/dist/component/control/style-control/Border.d.ts +18 -0
  22. package/dist/component/control/style-control/BoxModel.d.ts +17 -0
  23. package/dist/component/control/style-control/BoxShadow.d.ts +18 -0
  24. package/dist/component/control/style-control/Display.d.ts +14 -0
  25. package/dist/component/control/style-control/Font.d.ts +16 -0
  26. package/dist/component/control/style-control/font-family.d.ts +11 -0
  27. package/dist/component/control/style-control/transformation.d.ts +29 -0
  28. package/dist/component/control/style-control/types.d.ts +8 -0
  29. package/dist/component/schemaTpl.d.ts +8 -0
  30. package/dist/component/validator.d.ts +62 -0
  31. package/dist/dnd/index.d.ts +1 -1
  32. package/dist/event-action/action-config-panel.d.ts +8 -0
  33. package/dist/event-action/actions.d.ts +3 -0
  34. package/dist/event-action/comp-action-select.d.ts +11 -0
  35. package/dist/event-action/config.d.ts +13 -0
  36. package/dist/event-action/index.d.ts +459 -0
  37. package/dist/event-action/schema.d.ts +32 -0
  38. package/dist/exports.min.js +1 -1
  39. package/dist/index.d.ts +23 -5
  40. package/dist/index.min.js +1 -1
  41. package/dist/manager.d.ts +46 -1
  42. package/dist/plugin/Alert.d.ts +4 -2
  43. package/dist/plugin/Button.d.ts +5 -1
  44. package/dist/plugin/ButtonGroup.d.ts +13 -34
  45. package/dist/plugin/ButtonToolbar.d.ts +4 -10
  46. package/dist/plugin/CRUD.d.ts +2 -0
  47. package/dist/plugin/Chart.d.ts +2 -0
  48. package/dist/plugin/Collapse.d.ts +1 -0
  49. package/dist/plugin/CollapseGroup.d.ts +28 -4
  50. package/dist/plugin/Container.d.ts +2 -1
  51. package/dist/plugin/Dialog.d.ts +12 -2
  52. package/dist/plugin/Drawer.d.ts +12 -2
  53. package/dist/plugin/DropDownButton.d.ts +11 -11
  54. package/dist/plugin/Form/ButtonGroupSelect.d.ts +7 -2
  55. package/dist/plugin/Form/ButtonToolbar.d.ts +8 -7
  56. package/dist/plugin/Form/ChainedSelect.d.ts +3 -0
  57. package/dist/plugin/Form/Checkbox.d.ts +7 -2
  58. package/dist/plugin/Form/Checkboxes.d.ts +8 -2
  59. package/dist/plugin/Form/CodeEditor.d.ts +7 -22
  60. package/dist/plugin/Form/Combo.d.ts +3 -0
  61. package/dist/plugin/Form/Control.d.ts +6 -2
  62. package/dist/plugin/Form/DiffEditor.d.ts +7 -1
  63. package/dist/plugin/Form/Form.d.ts +6 -0
  64. package/dist/plugin/Form/Formula.d.ts +1 -25
  65. package/dist/plugin/Form/InputDate.d.ts +8 -2
  66. package/dist/plugin/Form/InputDateRange.d.ts +8 -2
  67. package/dist/plugin/Form/InputDateTime.d.ts +4 -4
  68. package/dist/plugin/Form/InputDateTimeRange.d.ts +4 -4
  69. package/dist/plugin/Form/InputEmail.d.ts +1 -0
  70. package/dist/plugin/Form/InputExcel.d.ts +6 -41
  71. package/dist/plugin/Form/InputFile.d.ts +7 -3
  72. package/dist/plugin/Form/InputKV.d.ts +6 -0
  73. package/dist/plugin/Form/InputMonth.d.ts +1 -0
  74. package/dist/plugin/Form/InputMonthRange.d.ts +4 -4
  75. package/dist/plugin/Form/InputPassword.d.ts +1 -0
  76. package/dist/plugin/Form/InputQuarter.d.ts +1 -0
  77. package/dist/plugin/Form/InputQuarterRange.d.ts +4 -4
  78. package/dist/plugin/Form/InputRange.d.ts +3 -0
  79. package/dist/plugin/Form/InputRating.d.ts +9 -3
  80. package/dist/plugin/Form/InputText.d.ts +24 -2
  81. package/dist/plugin/Form/InputTime.d.ts +3 -3
  82. package/dist/plugin/Form/InputTimeRange.d.ts +20 -0
  83. package/dist/plugin/Form/InputTree.d.ts +6 -2
  84. package/dist/plugin/Form/InputURL.d.ts +1 -0
  85. package/dist/plugin/Form/InputYear.d.ts +1 -0
  86. package/dist/plugin/Form/InputYearRange.d.ts +20 -0
  87. package/dist/plugin/Form/ListSelect.d.ts +6 -2
  88. package/dist/plugin/Form/LocationPicker.d.ts +1 -31
  89. package/dist/plugin/Form/NestedSelect.d.ts +5 -2
  90. package/dist/plugin/Form/Radios.d.ts +7 -2
  91. package/dist/plugin/Form/Select.d.ts +7 -2
  92. package/dist/plugin/Form/Switch.d.ts +7 -2
  93. package/dist/plugin/Form/TabsTransfer.d.ts +5 -2
  94. package/dist/plugin/Form/Textarea.d.ts +7 -1
  95. package/dist/plugin/Form/Transfer.d.ts +5 -2
  96. package/dist/plugin/Form/TreeSelect.d.ts +6 -2
  97. package/dist/plugin/IFrame.d.ts +2 -2
  98. package/dist/plugin/Nav.d.ts +1 -116
  99. package/dist/plugin/Others/Action.d.ts +5 -1
  100. package/dist/plugin/Page.d.ts +5 -2
  101. package/dist/plugin/Progress.d.ts +5 -1
  102. package/dist/plugin/Table.d.ts +2 -0
  103. package/dist/plugin/Tabs.d.ts +33 -2
  104. package/dist/plugin/TooltipWrapper.d.ts +10 -0
  105. package/dist/plugin/Tpl.d.ts +2 -1
  106. package/dist/plugin/Wizard.d.ts +4 -1
  107. package/dist/plugin.d.ts +37 -1
  108. package/dist/store/editor.d.ts +55 -28
  109. package/dist/store/node.d.ts +16 -0
  110. package/dist/style.css +1 -1
  111. package/dist/util.d.ts +36 -3
  112. package/package.json +14 -8
  113. package/src/component/schemaTpl.tsx +1209 -474
  114. package/src/plugin/Alert.tsx +69 -48
  115. package/src/plugin/AnchorNav.tsx +1 -0
  116. package/src/plugin/Audio.tsx +9 -15
  117. package/src/plugin/Avatar.tsx +2 -1
  118. package/src/plugin/Breadcrumb.tsx +2 -1
  119. package/src/plugin/Button.tsx +257 -188
  120. package/src/plugin/ButtonGroup.tsx +99 -38
  121. package/src/plugin/ButtonToolbar.tsx +7 -13
  122. package/src/plugin/CRUD.tsx +78 -136
  123. package/src/plugin/Card.tsx +1 -0
  124. package/src/plugin/Cards.tsx +8 -14
  125. package/src/plugin/Carousel.tsx +1 -1
  126. package/src/plugin/Chart.tsx +26 -14
  127. package/src/plugin/Collapse.tsx +78 -78
  128. package/src/plugin/CollapseGroup.tsx +165 -83
  129. package/src/plugin/Container.tsx +59 -6
  130. package/src/plugin/Custom.tsx +2 -8
  131. package/src/plugin/CustomRegion.tsx +4 -3
  132. package/src/plugin/Dialog.tsx +55 -24
  133. package/src/plugin/Drawer.tsx +65 -35
  134. package/src/plugin/DropDownButton.tsx +95 -79
  135. package/src/plugin/Flex.tsx +123 -65
  136. package/src/plugin/Form/ButtonGroupSelect.tsx +114 -26
  137. package/src/plugin/Form/ButtonToolbar.tsx +62 -55
  138. package/src/plugin/Form/ChainedSelect.tsx +45 -0
  139. package/src/plugin/Form/Checkbox.tsx +122 -33
  140. package/src/plugin/Form/Checkboxes.tsx +154 -87
  141. package/src/plugin/Form/CodeEditor.tsx +163 -34
  142. package/src/plugin/Form/Combo.tsx +104 -65
  143. package/src/plugin/Form/Control.tsx +16 -70
  144. package/src/plugin/Form/DiffEditor.tsx +158 -54
  145. package/src/plugin/Form/FieldSet.tsx +6 -11
  146. package/src/plugin/Form/Form.tsx +277 -70
  147. package/src/plugin/Form/Formula.tsx +8 -14
  148. package/src/plugin/Form/InputArray.tsx +7 -16
  149. package/src/plugin/Form/InputCity.tsx +1 -1
  150. package/src/plugin/Form/InputDate.tsx +344 -121
  151. package/src/plugin/Form/InputDateRange.tsx +303 -161
  152. package/src/plugin/Form/InputDateTime.tsx +6 -150
  153. package/src/plugin/Form/InputDateTimeRange.tsx +7 -187
  154. package/src/plugin/Form/InputEmail.tsx +1 -0
  155. package/src/plugin/Form/InputExcel.tsx +70 -27
  156. package/src/plugin/Form/InputFile.tsx +326 -152
  157. package/src/plugin/Form/InputImage.tsx +1 -1
  158. package/src/plugin/Form/InputKV.tsx +61 -0
  159. package/src/plugin/Form/InputMonth.tsx +3 -1
  160. package/src/plugin/Form/InputMonthRange.tsx +6 -160
  161. package/src/plugin/Form/InputNumber.tsx +1 -1
  162. package/src/plugin/Form/InputPassword.tsx +2 -0
  163. package/src/plugin/Form/InputQuarter.tsx +3 -1
  164. package/src/plugin/Form/InputQuarterRange.tsx +6 -160
  165. package/src/plugin/Form/InputRange.tsx +74 -4
  166. package/src/plugin/Form/InputRating.tsx +347 -35
  167. package/src/plugin/Form/InputRichText.tsx +2 -3
  168. package/src/plugin/Form/InputTable.tsx +33 -49
  169. package/src/plugin/Form/InputTag.tsx +1 -1
  170. package/src/plugin/Form/InputText.tsx +310 -132
  171. package/src/plugin/Form/InputTime.tsx +4 -53
  172. package/src/plugin/Form/InputTimeRange.tsx +41 -0
  173. package/src/plugin/Form/InputTree.tsx +196 -46
  174. package/src/plugin/Form/InputURL.tsx +2 -0
  175. package/src/plugin/Form/InputYear.tsx +2 -0
  176. package/src/plugin/Form/InputYearRange.tsx +41 -0
  177. package/src/plugin/Form/Item.tsx +17 -18
  178. package/src/plugin/Form/ListSelect.tsx +75 -20
  179. package/src/plugin/Form/LocationPicker.tsx +2 -7
  180. package/src/plugin/Form/MatrixCheckboxes.tsx +1 -1
  181. package/src/plugin/Form/NestedSelect.tsx +110 -43
  182. package/src/plugin/Form/Picker.tsx +2 -5
  183. package/src/plugin/Form/Radios.tsx +122 -52
  184. package/src/plugin/Form/Select.tsx +239 -168
  185. package/src/plugin/Form/Static.tsx +1 -1
  186. package/src/plugin/Form/Switch.tsx +170 -58
  187. package/src/plugin/Form/TabsTransfer.tsx +175 -79
  188. package/src/plugin/Form/Textarea.tsx +146 -36
  189. package/src/plugin/Form/Transfer.tsx +295 -233
  190. package/src/plugin/Form/TreeSelect.tsx +287 -146
  191. package/src/plugin/Grid.tsx +340 -312
  192. package/src/plugin/HBox.tsx +1 -0
  193. package/src/plugin/IFrame.tsx +21 -12
  194. package/src/plugin/Image.tsx +7 -12
  195. package/src/plugin/Images.tsx +7 -12
  196. package/src/plugin/Link.tsx +6 -12
  197. package/src/plugin/List.tsx +6 -10
  198. package/src/plugin/ListItem.tsx +1 -0
  199. package/src/plugin/Nav.tsx +7 -9
  200. package/src/plugin/Others/Action.tsx +16 -10
  201. package/src/plugin/Others/BasicToolbar.tsx +4 -1
  202. package/src/plugin/Others/TableCell.tsx +19 -39
  203. package/src/plugin/Page.tsx +315 -229
  204. package/src/plugin/Panel.tsx +6 -7
  205. package/src/plugin/Plain.tsx +3 -6
  206. package/src/plugin/Progress.tsx +234 -94
  207. package/src/plugin/Service.tsx +10 -6
  208. package/src/plugin/Table.tsx +49 -20
  209. package/src/plugin/TableView.tsx +212 -106
  210. package/src/plugin/Tabs.tsx +306 -146
  211. package/src/plugin/TooltipWrapper.tsx +231 -135
  212. package/src/plugin/Tpl.tsx +68 -52
  213. package/src/plugin/Video.tsx +9 -20
  214. package/src/plugin/Wizard.tsx +537 -336
  215. package/src/plugin/Wrapper.tsx +82 -61
  216. package/src/plugin.ts +66 -4
  217. package/static/empty.png +0 -0
  218. package/dist/component/Control/APIControl.d.ts +0 -504
  219. package/dist/component/Control/ValidationControl.d.ts +0 -30
  220. package/dist/component/remarkTpl.d.ts +0 -150
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  defaultValue,
3
+ setSchemaTpl,
3
4
  getSchemaTpl,
4
5
  valuePipeOut
5
6
  } from '../../component/schemaTpl';
@@ -8,9 +9,19 @@ import {
8
9
  BasePlugin,
9
10
  BasicSubRenderInfo,
10
11
  RendererEventContext,
11
- SubRendererInfo
12
+ SubRendererInfo,
13
+ BaseEventContext
12
14
  } from '../../plugin';
15
+ import { ValidatorTag } from '../../component/validator';
16
+ import {tipedLabel} from '../../component/control/BaseControl';
17
+ import { getEventControlConfig } from '../../util';
18
+ import {RendererAction, RendererEvent} from '../../event-action';
13
19
 
20
+ setSchemaTpl('option', {
21
+ name: 'option',
22
+ type: 'input-text',
23
+ label: tipedLabel('说明', '选项说明')
24
+ });
14
25
  export class CheckboxControlPlugin extends BasePlugin {
15
26
  // 关联渲染器名字
16
27
  rendererName = 'checkbox';
@@ -41,47 +52,125 @@ export class CheckboxControlPlugin extends BasePlugin {
41
52
  }
42
53
  ]
43
54
  };
44
-
55
+ notRenderFormZone = true;
45
56
  panelTitle = '勾选框';
46
- panelBody = [
57
+ panelJustify = true;
58
+ // 事件定义
59
+ events: RendererEvent[] = [
47
60
  {
48
- name: 'option',
49
- type: 'input-text',
50
- label: '选项说明'
51
- },
52
-
53
- getSchemaTpl('switchDefaultValue', {
54
- name: 'value',
55
- pipeOut: (value: any, origin: any, data: any) =>
56
- value ? data.trueValue ?? true : undefined
57
- }),
61
+ eventName: 'change',
62
+ eventLabel: '值变化',
63
+ description: '选中状态变化时触发',
64
+ dataSchema: [
65
+ {
66
+ type: 'object',
67
+ properties: {
68
+ 'event.data.value': {
69
+ type: 'string',
70
+ title: '选中状态'
71
+ }
72
+ }
73
+ }
74
+ ]
75
+ }
76
+ ];
77
+ // 动作定义
78
+ actions: RendererAction[] = [
58
79
  {
59
- type: 'switch',
60
- name: 'value',
61
- label: '默认勾选',
62
- mode: 'inline',
63
- className: 'w-full',
64
- visibleOn: 'typeof this.value !== "undefined"',
65
- pipeOut: (value: any, origin: any, data: any) =>
66
- value ? data.trueValue ?? true : data.falseValue ?? false
80
+ actionType: 'clear',
81
+ actionLabel: '清空',
82
+ description: '清除选中值'
67
83
  },
68
-
69
84
  {
70
- type: 'input-text',
71
- label: '勾选后的值',
72
- name: 'trueValue',
73
- pipeIn: defaultValue(true),
74
- pipeOut: valuePipeOut
85
+ actionType: 'reset',
86
+ actionLabel: '重置',
87
+ description: '将值重置为resetValue,若没有配置resetValue,则清空'
75
88
  },
76
-
77
89
  {
78
- type: 'input-text',
79
- label: '未勾选的值',
80
- name: 'falseValue',
81
- pipeIn: defaultValue(false),
82
- pipeOut: valuePipeOut
90
+ actionType: 'setValue',
91
+ actionLabel: '赋值',
92
+ description: '触发组件数据更新'
83
93
  }
84
94
  ];
95
+ panelBodyCreator = (context: BaseEventContext) => {
96
+ return getSchemaTpl('tabs', [
97
+ {
98
+ title: '属性',
99
+ body: getSchemaTpl('collapseGroup', [
100
+ {
101
+ title: '基本',
102
+ body: [
103
+ getSchemaTpl('formItemName', {
104
+ required: true
105
+ }),
106
+ getSchemaTpl('label'),
107
+ getSchemaTpl('option'),
108
+ getSchemaTpl('switch', {
109
+ name: 'value',
110
+ label: '默认勾选',
111
+ pipeIn: (value: any, data: any) => {
112
+ return value === (data?.data?.trueValue ?? true);
113
+ },
114
+ pipeOut: (value: any, origin: any, data: any) => {
115
+ const {trueValue = true, falseValue = false} = data;
116
+ return value ? trueValue : falseValue;
117
+ }
118
+ }),
119
+ {
120
+ type: 'ae-Switch-More',
121
+ hiddenOnDefault: false,
122
+ mode: 'normal',
123
+ label: '值格式',
124
+ formType: 'extend',
125
+ form: {
126
+ body: [
127
+ {
128
+ type: 'input-text',
129
+ label: '勾选值',
130
+ name: 'trueValue',
131
+ pipeIn: defaultValue(true),
132
+ pipeOut: valuePipeOut
133
+ },
134
+ {
135
+ type: 'input-text',
136
+ label: '未勾选值',
137
+ name: 'falseValue',
138
+ pipeIn: defaultValue(false),
139
+ pipeOut: valuePipeOut
140
+ }
141
+ ]
142
+ }
143
+ },
144
+ getSchemaTpl('labelRemark'),
145
+ getSchemaTpl('remark'),
146
+ getSchemaTpl('description')
147
+ ]
148
+ },
149
+ getSchemaTpl('status', {isFormItem: true}),
150
+ getSchemaTpl('validation', {tag: ValidatorTag.MultiSelect})
151
+ ])
152
+ },
153
+ {
154
+ title: '外观',
155
+ body: [
156
+ getSchemaTpl('collapseGroup', [
157
+ getSchemaTpl('style:formItem', {renderer: context.info.renderer}),
158
+ getSchemaTpl('style:classNames')
159
+ ])
160
+ ]
161
+ },
162
+ {
163
+ title: '事件',
164
+ className: 'p-none',
165
+ body: [
166
+ getSchemaTpl('eventControl', {
167
+ name: 'onEvent',
168
+ ...getEventControlConfig(this.manager, context)
169
+ })
170
+ ]
171
+ }
172
+ ]);
173
+ }
85
174
  }
86
175
 
87
176
  registerEditorPlugin(CheckboxControlPlugin);
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  defaultValue,
3
+ setSchemaTpl,
3
4
  getSchemaTpl,
4
5
  valuePipeOut
5
6
  } from '../../component/schemaTpl';
@@ -8,9 +9,17 @@ import {
8
9
  BasePlugin,
9
10
  BasicSubRenderInfo,
10
11
  RendererEventContext,
11
- SubRendererInfo
12
+ SubRendererInfo,
13
+ BaseEventContext
12
14
  } from '../../plugin';
13
15
 
16
+ import {formItemControl} from '../../component/control/BaseControl';
17
+ import { ValidatorTag } from '../../component/validator';
18
+ import {tipedLabel} from '../../component/control/BaseControl';
19
+
20
+ import { getEventControlConfig } from '../../util';
21
+ import {RendererAction, RendererEvent} from '../../event-action';
22
+
14
23
  export class CheckboxesControlPlugin extends BasePlugin {
15
24
  // 关联渲染器名字
16
25
  rendererName = 'checkboxes';
@@ -30,6 +39,7 @@ export class CheckboxesControlPlugin extends BasePlugin {
30
39
  type: 'checkboxes',
31
40
  label: '复选框',
32
41
  name: 'checkboxes',
42
+ multiple: true,
33
43
  options: [
34
44
  {
35
45
  label: '选项A',
@@ -55,113 +65,170 @@ export class CheckboxesControlPlugin extends BasePlugin {
55
65
  ]
56
66
  };
57
67
 
68
+ notRenderFormZone = true;
69
+
58
70
  panelTitle = '复选框';
59
- panelBody = [
60
- getSchemaTpl('tabs', [
61
- {
62
- title: '常规',
63
- body: [
64
- getSchemaTpl('switchDefaultValue', {
65
- visibleOn: '!this.defaultCheckAll'
66
- }),
67
71
 
68
- {
69
- type: 'checkboxes',
70
- name: 'value',
71
- label: '默认值',
72
- source: '${options}',
73
- visibleOn: 'typeof this.value !== "undefined"',
74
- multiple: true
75
- },
76
- getSchemaTpl('fieldSet', {
77
- title: '选项',
78
- body: [
79
- getSchemaTpl('options'),
80
- getSchemaTpl('source'),
81
- {
82
- name: 'checkAll',
83
- label: '是否开启全选功能',
84
- type: 'switch',
85
- mode: 'inline',
86
- className: 'w-full'
87
- },
72
+ // 事件定义
73
+ events: RendererEvent[] = [
74
+ {
75
+ eventName: 'change',
76
+ eventLabel: '值变化',
77
+ description: '选中值变化时触发',
78
+ dataSchema: [
79
+ {
80
+ type: 'object',
81
+ properties: {
82
+ 'event.data.value': {
83
+ type: 'string',
84
+ title: '选中值'
85
+ }
86
+ }
87
+ }
88
+ ]
89
+ }
90
+ ];
88
91
 
89
- {
90
- name: 'defaultCheckAll',
91
- label: '是否默认全选',
92
- type: 'switch',
93
- mode: 'inline',
94
- className: 'w-full',
95
- description: '勾选后,默认值的配置将无效。',
96
- onChange: (
97
- value: boolean,
98
- oldValue: boolean,
99
- model: any,
100
- form: any
101
- ) => value && form.setValueByName('value', undefined)
102
- },
92
+ // 动作定义
93
+ actions: RendererAction[] = [
94
+ {
95
+ actionType: 'clear',
96
+ actionLabel: '清空',
97
+ description: '清除选中值'
98
+ },
99
+ {
100
+ actionType: 'reset',
101
+ actionLabel: '重置',
102
+ description: '将值重置为resetValue,若没有配置resetValue,则清空'
103
+ },
104
+ {
105
+ actionType: 'reload',
106
+ actionLabel: '重新加载',
107
+ description: '触发组件数据刷新并重新渲染'
108
+ },
109
+ {
110
+ actionType: 'setValue',
111
+ actionLabel: '赋值',
112
+ description: '触发组件数据更新'
113
+ }
114
+ ];
115
+ panelJustify = true;
116
+ panelBodyCreator = (context: BaseEventContext) => {
117
+ const renderer: any = context.info.renderer;
103
118
 
119
+ return getSchemaTpl('tabs', [
120
+ {
121
+ title: '属性',
122
+ body: getSchemaTpl('collapseGroup', [
123
+ {
124
+ title: '基本',
125
+ body: [
126
+ getSchemaTpl('formItemName', {
127
+ required: true
128
+ }),
129
+ getSchemaTpl('label'),
130
+ [
131
+ getSchemaTpl('switch', {
132
+ label: '可全选',
133
+ name: 'checkAll',
134
+ value: false,
135
+ visibleOn: 'data.multiple',
136
+ onChange: (value:any, origin:any, item:any, form:any) => {
137
+ if (!value) {
138
+ // 可全选关闭时,默认全选也需联动关闭
139
+ form.setValueByName('defaultCheckAll', false);
140
+ }
141
+ }
142
+ }),
143
+ {
144
+ type: 'container',
145
+ className: 'ae-ExtendMore mb-2',
146
+ visibleOn: 'data.checkAll',
147
+ body: [
148
+ getSchemaTpl('switch', {
149
+ label: '默认全选',
150
+ name: 'defaultCheckAll',
151
+ value: false
152
+ })
153
+ ]
154
+ }
155
+ ],
104
156
  getSchemaTpl('joinValues', {
105
157
  visibleOn: true
106
158
  }),
107
159
  getSchemaTpl('delimiter', {
108
- hiddenOn: 'data.joinValues === false'
160
+ visibleOn: 'data.joinValues === true'
109
161
  }),
110
162
  getSchemaTpl('extractValue'),
111
- getSchemaTpl('autoFill'),
112
-
113
- getSchemaTpl('creatable'),
114
- getSchemaTpl('createBtnLabel'),
115
- getSchemaTpl('api', {
116
- label: '新增选项接口',
117
- name: 'addApi'
163
+ getSchemaTpl('labelRemark'),
164
+ getSchemaTpl('remark'),
165
+ getSchemaTpl('description'),
166
+ ]
167
+ },
168
+ {
169
+ title: '选项',
170
+ body: [
171
+ getSchemaTpl('optionControl', {
172
+ multiple: true
118
173
  }),
119
-
120
- getSchemaTpl('editable'),
121
- getSchemaTpl('api', {
122
- label: '编辑选项接口',
123
- name: 'editApi'
174
+ getSchemaTpl('value', {
175
+ visibleOn: '!!this.options'
124
176
  }),
125
-
126
- getSchemaTpl('removable'),
127
- getSchemaTpl('api', {
128
- label: '删除选项接口',
129
- name: 'deleteApi'
177
+ getSchemaTpl('creatable', {
178
+ formType: 'extend',
179
+ hiddenOnDefault: true,
180
+ form: {
181
+ body: [
182
+ getSchemaTpl('createBtnLabel'),
183
+ getSchemaTpl('addApi')
184
+ ]
185
+ }
186
+ }),
187
+ getSchemaTpl('editable', {
188
+ formType: 'extend',
189
+ hiddenOnDefault: true,
190
+ form: {
191
+ body: [
192
+ getSchemaTpl('editApi')
193
+ ]
194
+ }
195
+ }),
196
+ getSchemaTpl('removable', {
197
+ formType: 'extend',
198
+ hiddenOnDefault: true,
199
+ form: {
200
+ body: [
201
+ getSchemaTpl('deleteApi')
202
+ ]
203
+ }
130
204
  })
131
205
  ]
132
- })
133
- ]
206
+ },
207
+ getSchemaTpl('status', {isFormItem: true}),
208
+ getSchemaTpl('validation', {tag: ValidatorTag.MultiSelect})
209
+ ])
134
210
  },
135
211
  {
136
212
  title: '外观',
137
213
  body: [
138
- {
139
- label: '选项在一行显示',
140
- name: 'inline',
141
- type: 'switch',
142
- visibleOn: 'data.mode != "inline"',
143
- mode: 'inline',
144
- className: 'w-full',
145
- pipeIn: defaultValue(true)
146
- },
147
- {
148
- label: '每行显示多少列',
149
- name: 'columnsCount',
150
- hiddenOn:
151
- 'typeof data.inline === "undefined" || data.inline === true',
152
- type: 'input-range',
153
- min: 1,
154
- max: 6,
155
- pipeIn: defaultValue(1)
156
- },
157
- getSchemaTpl('className', {
158
- label: '单个 Checkbox 的 CSS 类名',
159
- name: 'itemClassName'
214
+ getSchemaTpl('collapseGroup', [
215
+ getSchemaTpl('style:formItem', {renderer}),
216
+ getSchemaTpl('style:classNames')
217
+ ])
218
+ ]
219
+ },
220
+ {
221
+ title: '事件',
222
+ className: 'p-none',
223
+ body: [
224
+ getSchemaTpl('eventControl', {
225
+ name: 'onEvent',
226
+ ...getEventControlConfig(this.manager, context)
160
227
  })
161
228
  ]
162
229
  }
163
- ])
164
- ];
230
+ ]);
231
+ };
165
232
  }
166
233
 
167
234
  registerEditorPlugin(CheckboxesControlPlugin);
@@ -1,8 +1,17 @@
1
1
  import {availableLanguages} from 'amis/lib/renderers/Form/Editor';
2
- import {defaultValue} from '../../component/schemaTpl';
2
+ import {
3
+ defaultValue,
4
+ getSchemaTpl,
5
+ undefinedPipeOut
6
+ } from '../../component/schemaTpl';
3
7
  import {registerEditorPlugin} from '../../manager';
4
8
  import {BasePlugin} from '../../plugin';
5
9
 
10
+ import type {BaseEventContext} from '../../plugin';
11
+ import {ValidatorTag} from '../../component/validator';
12
+ import {getEventControlConfig} from '../../util';
13
+ import {RendererAction, RendererEvent} from '../../event-action';
14
+
6
15
  export class CodeEditorControlPlugin extends BasePlugin {
7
16
  // 关联渲染器名字
8
17
  rendererName = 'editor';
@@ -35,47 +44,167 @@ export class CodeEditorControlPlugin extends BasePlugin {
35
44
  ]
36
45
  };
37
46
 
38
- panelTitle = 'Editor';
39
- panelBody = [
47
+ events: RendererEvent[] = [
40
48
  {
41
- label: '语言',
42
- name: 'language',
43
- type: 'select',
44
- value: 'javascript',
45
- searchable: true,
46
- options: availableLanguages.concat()
49
+ eventName: 'focus',
50
+ eventLabel: '获取焦点',
51
+ description: '输入框获取焦点时触发',
52
+ dataSchema: [
53
+ {
54
+ type: 'object',
55
+ properties: {
56
+ 'event.data.value': {
57
+ type: 'string',
58
+ title: '当前代码'
59
+ }
60
+ }
61
+ }
62
+ ]
47
63
  },
48
-
49
64
  {
50
- name: 'size',
51
- type: 'button-group-select',
52
- size: 'xs',
53
- pipeIn: defaultValue(''),
54
- label: '控件大小',
55
- options: [
56
- {
57
- label: '默认',
58
- value: ''
59
- },
60
- {
61
- label: '中',
62
- value: 'md'
63
- },
64
- {
65
- label: '大',
66
- value: 'lg'
67
- },
65
+ eventName: 'blur',
66
+ eventLabel: '失去焦点',
67
+ description: '输入框失去焦点时触发',
68
+ dataSchema: [
68
69
  {
69
- label: '加大',
70
- value: 'xl'
71
- },
72
- {
73
- label: '加加大',
74
- value: 'xxl'
70
+ type: 'object',
71
+ properties: {
72
+ 'event.data.value': {
73
+ type: 'string',
74
+ title: '当前代码'
75
+ }
76
+ }
75
77
  }
76
78
  ]
77
79
  }
78
80
  ];
81
+
82
+ actions: RendererAction[] = [
83
+ {
84
+ actionType: 'clear',
85
+ actionLabel: '清空',
86
+ description: '清除选中值'
87
+ },
88
+ {
89
+ actionType: 'reset',
90
+ actionLabel: '重置',
91
+ description: '将值重置为resetValue,若没有配置resetValue,则清空'
92
+ },
93
+ {
94
+ actionType: 'focus',
95
+ actionLabel: '获取焦点',
96
+ description: '输入框获取焦点'
97
+ },
98
+ {
99
+ actionType: 'setValue',
100
+ actionLabel: '赋值',
101
+ description: '触发组件数据更新'
102
+ }
103
+ ];
104
+
105
+ notRenderFormZone = true;
106
+
107
+ panelTitle = 'Editor';
108
+
109
+ panelJustify = true;
110
+
111
+ panelBodyCreator = (context: BaseEventContext) => {
112
+ return getSchemaTpl('tabs', [
113
+ {
114
+ title: '属性',
115
+ body: getSchemaTpl('collapseGroup', [
116
+ {
117
+ title: '基本',
118
+ body: [
119
+ getSchemaTpl('formItemName', {
120
+ required: true
121
+ }),
122
+ getSchemaTpl('label'),
123
+ {
124
+ label: '语言',
125
+ name: 'language',
126
+ type: 'select',
127
+ value: 'javascript',
128
+ searchable: true,
129
+ options: availableLanguages.concat()
130
+ },
131
+ {
132
+ type: 'textarea',
133
+ name: 'value',
134
+ label: '默认值'
135
+ },
136
+ getSchemaTpl('switch', {
137
+ label: '可全屏',
138
+ name: 'allowFullscreen',
139
+ pipeIn: defaultValue(true)
140
+ }),
141
+ getSchemaTpl('labelRemark'),
142
+ getSchemaTpl('remark'),
143
+ getSchemaTpl('description')
144
+ ]
145
+ },
146
+ getSchemaTpl('status', {isFormItem: true}),
147
+ getSchemaTpl('validation', {
148
+ tag: ValidatorTag.Code
149
+ })
150
+ ])
151
+ },
152
+ {
153
+ title: '外观',
154
+ body: getSchemaTpl('collapseGroup', [
155
+ getSchemaTpl('style:formItem', {
156
+ renderer: context.info.renderer,
157
+ schema: [
158
+ {
159
+ name: 'size',
160
+ type: 'select',
161
+ pipeIn: defaultValue(''),
162
+ pipeOut: undefinedPipeOut,
163
+ label: '控件尺寸',
164
+ options: [
165
+ {
166
+ label: '默认',
167
+ value: ''
168
+ },
169
+
170
+ {
171
+ label: '中',
172
+ value: 'md'
173
+ },
174
+
175
+ {
176
+ label: '大',
177
+ value: 'lg'
178
+ },
179
+
180
+ {
181
+ label: '特大',
182
+ value: 'xl'
183
+ },
184
+
185
+ {
186
+ label: '超大',
187
+ value: 'xxl'
188
+ }
189
+ ]
190
+ }
191
+ ]
192
+ }),
193
+ getSchemaTpl('style:classNames')
194
+ ])
195
+ },
196
+ {
197
+ title: '事件',
198
+ className: 'p-none',
199
+ body: [
200
+ getSchemaTpl('eventControl', {
201
+ name: 'onEvent',
202
+ ...getEventControlConfig(this.manager, context)
203
+ })
204
+ ]
205
+ }
206
+ ]);
207
+ };
79
208
  }
80
209
 
81
210
  registerEditorPlugin(CodeEditorControlPlugin);