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,143 @@
1
+ import {Button, SchemaObject} from 'amis';
2
+ import React from 'react';
3
+ import {registerEditorPlugin} from '../manager';
4
+ import {
5
+ BasePlugin,
6
+ RegionConfig,
7
+ RendererInfo,
8
+ BaseEventContext
9
+ } from '../plugin';
10
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
11
+
12
+ export class CollapsePlugin extends BasePlugin {
13
+ // 关联渲染器名字
14
+ rendererName = 'collapse';
15
+ $schema = '/schemas/CollapseSchema.json';
16
+
17
+ // 组件名称
18
+ name = '折叠器';
19
+ isBaseComponent = true;
20
+ description = '折叠器,可以将内容区展开或隐藏,保持页面的整洁';
21
+ docLink = '/amis/zh-CN/components/collapse';
22
+ tags = ['展示'];
23
+ icon = 'fa fa-window-minimize';
24
+ scaffold = {
25
+ type: 'collapse',
26
+ header: '标题',
27
+ body: [
28
+ {
29
+ type: 'tpl',
30
+ tpl: '内容',
31
+ inline: false
32
+ }
33
+ ]
34
+ };
35
+ previewSchema = {
36
+ ...this.scaffold
37
+ };
38
+
39
+ panelTitle = '折叠器';
40
+ panelBodyCreator = (context: BaseEventContext) => {
41
+ return getSchemaTpl('tabs', [
42
+ {
43
+ title: '属性',
44
+ body: [
45
+ {
46
+ name: 'header',
47
+ label: '标题',
48
+ type: 'input-text',
49
+ pipeIn: defaultValue(
50
+ context?.schema?.title || context?.schema?.header || ''
51
+ ),
52
+ onChange: (value: any, oldValue: any, model: any, form: any) => {
53
+ // 转换一下旧版本的title字段
54
+ form.setValueByName('header', value);
55
+ form.setValueByName('title', undefined);
56
+ }
57
+ },
58
+ {
59
+ name: 'collapseHeader',
60
+ label: '展开标题',
61
+ type: 'input-text',
62
+ description: '折叠器处于展开状态时的标题'
63
+ },
64
+ {
65
+ name: 'headerPosition',
66
+ label: '标题展示位置',
67
+ type: 'button-group-select',
68
+ size: 'sm',
69
+ pipeIn: defaultValue('top'),
70
+ options: [
71
+ {
72
+ label: '顶部',
73
+ value: 'top',
74
+ icon: 'fa fa-arrow-up'
75
+ },
76
+ {
77
+ label: '底部',
78
+ value: 'bottom',
79
+ icon: 'fa fa-arrow-down'
80
+ }
81
+ ]
82
+ },
83
+ {
84
+ name: 'key',
85
+ label: '标识符',
86
+ type: 'input-text',
87
+ description: '折叠器key,主要用于设置默认展开状态'
88
+ },
89
+ {
90
+ name: 'showArrow',
91
+ label: '显示箭头',
92
+ mode: 'row',
93
+ inputClassName: 'inline-flex justify-between flex-row-reverse',
94
+ type: 'switch',
95
+ pipeIn: defaultValue(true)
96
+ },
97
+ {
98
+ name: 'collapsable',
99
+ type: 'switch',
100
+ mode: 'row',
101
+ inputClassName: 'inline-flex justify-between flex-row-reverse',
102
+ label: '可折叠',
103
+ pipeIn: defaultValue(true)
104
+ },
105
+ {
106
+ name: 'collapsed',
107
+ type: 'switch',
108
+ mode: 'row',
109
+ inputClassName: 'inline-flex justify-between flex-row-reverse',
110
+ label: '默认折叠'
111
+ }
112
+ ]
113
+ },
114
+ {
115
+ title: '外观',
116
+ body: [
117
+ getSchemaTpl('className'),
118
+ getSchemaTpl('className', {
119
+ name: 'headingClassName',
120
+ label: '标题 CSS 类名'
121
+ }),
122
+ getSchemaTpl('className', {
123
+ name: 'bodyClassName',
124
+ label: '内容 CSS 类名'
125
+ })
126
+ ]
127
+ },
128
+ {
129
+ title: '状态',
130
+ body: [getSchemaTpl('disabled'), getSchemaTpl('visible')]
131
+ }
132
+ ]);
133
+ };
134
+
135
+ regions: Array<RegionConfig> = [
136
+ {
137
+ key: 'body',
138
+ label: '内容区'
139
+ }
140
+ ];
141
+ }
142
+
143
+ registerEditorPlugin(CollapsePlugin);
@@ -0,0 +1,167 @@
1
+ import {registerEditorPlugin} from '../manager';
2
+ import {
3
+ BasePlugin,
4
+ RegionConfig,
5
+ RendererInfo,
6
+ BaseEventContext
7
+ } from '../plugin';
8
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
9
+
10
+ import type {CollapseSchema} from 'amis/lib/renderers/Collapse';
11
+
12
+ export class CollapseGroupPlugin extends BasePlugin {
13
+ // 关联渲染器名字
14
+ rendererName = 'collapse-group';
15
+ $schema = '/schemas/CollapseGroupSchema.json';
16
+
17
+ // 组件名称
18
+ name = '折叠面板';
19
+ isBaseComponent = true;
20
+ description =
21
+ '折叠面板,当信息量较大且分类较多时,可使用折叠面板进行分类收纳。';
22
+ tags = ['展示', '容器'];
23
+ icon = 'fa fa-align-justify';
24
+ scaffold = {
25
+ type: 'collapse-group',
26
+ activeKey: ['1'],
27
+ body: [
28
+ {
29
+ type: 'collapse',
30
+ key: '1',
31
+ header: '标题1',
32
+ body: [
33
+ {
34
+ type: 'tpl',
35
+ tpl: '这里是内容1',
36
+ inline: false
37
+ }
38
+ ]
39
+ },
40
+ {
41
+ type: 'collapse',
42
+ key: '2',
43
+ header: '标题2',
44
+ body: [
45
+ {
46
+ type: 'tpl',
47
+ tpl: '这里是内容1',
48
+ inline: false
49
+ }
50
+ ]
51
+ }
52
+ ]
53
+ };
54
+ previewSchema = {
55
+ ...this.scaffold
56
+ };
57
+
58
+ panelTitle = '折叠面板';
59
+ panelBodyCreator = (context: BaseEventContext) => {
60
+ const collapseChildren: CollapseSchema[] = Array.isArray(
61
+ context?.schema?.body
62
+ )
63
+ ? context?.schema?.body.filter(
64
+ (item: CollapseSchema) => item.type === 'collapse' && item.key != null
65
+ )
66
+ : [];
67
+
68
+ return [
69
+ getSchemaTpl('tabs', [
70
+ {
71
+ title: '属性',
72
+ body: [
73
+ {
74
+ name: 'activeKey',
75
+ label: '默认展开面板',
76
+ type: 'input-tag',
77
+ clearable: true,
78
+ joinValues: false,
79
+ extractValue: true,
80
+ options: collapseChildren.map((item: CollapseSchema) => item.key)
81
+ },
82
+ {
83
+ name: 'expandIconPosition',
84
+ label: '图标位置',
85
+ type: 'button-group-select',
86
+ pipeIn: defaultValue('left'),
87
+ options: [
88
+ {
89
+ label: '左边',
90
+ value: 'left',
91
+ icon: 'fa fa-align-left'
92
+ },
93
+ {
94
+ label: '右边',
95
+ value: 'right',
96
+ icon: 'fa fa-align-right'
97
+ }
98
+ ]
99
+ },
100
+ {
101
+ name: 'accordion',
102
+ label: '手风琴模式',
103
+ mode: 'row',
104
+ inputClassName: 'inline-flex justify-between flex-row-reverse',
105
+ type: 'switch',
106
+ description: '手风琴模式,只允许单个面板展开',
107
+ pipeIn: defaultValue(false)
108
+ },
109
+ {
110
+ name: 'body',
111
+ type: 'combo',
112
+ label: '面板管理',
113
+ multiple: true,
114
+ addable: true,
115
+ addButtonText: '新增折叠器',
116
+ minLength: 1,
117
+ draggable: true,
118
+ draggableTip: '',
119
+ placeholder: '请添加折叠器',
120
+ items: [
121
+ {
122
+ name: 'header',
123
+ placeholder: '标题',
124
+ type: 'input-text'
125
+ },
126
+ {
127
+ name: 'key',
128
+ placeholder: '标识符',
129
+ type: 'input-text',
130
+ size: 'xs',
131
+ unique: true
132
+ }
133
+ ],
134
+ scaffold: {
135
+ type: 'collapse',
136
+ header: '标题',
137
+ body: [
138
+ {
139
+ type: 'tpl',
140
+ tpl: '内容',
141
+ inline: false
142
+ }
143
+ ],
144
+ key: ''
145
+ }
146
+ }
147
+ ]
148
+ },
149
+ {
150
+ title: '外观',
151
+ body: [getSchemaTpl('className')]
152
+ }
153
+ ])
154
+ ];
155
+ };
156
+
157
+ regions: Array<RegionConfig> = [
158
+ {
159
+ key: 'body',
160
+ label: '内容区',
161
+ renderMethod: 'render',
162
+ insertPosition: 'inner'
163
+ }
164
+ ];
165
+ }
166
+
167
+ registerEditorPlugin(CollapseGroupPlugin);
@@ -0,0 +1,44 @@
1
+ import {Button, SchemaObject} from 'amis';
2
+ import React from 'react';
3
+ import {registerEditorPlugin} from '../manager';
4
+ import {
5
+ BaseEventContext,
6
+ BasePlugin,
7
+ RegionConfig,
8
+ RendererInfo
9
+ } from '../plugin';
10
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
11
+
12
+ export class ContainerPlugin extends BasePlugin {
13
+ // 关联渲染器名字
14
+ rendererName = 'container';
15
+ $schema = '/schemas/ContainerSchema.json';
16
+
17
+ // 组件名称
18
+ name = '容器';
19
+ isBaseComponent = true;
20
+ description = '一个简单的容器,可以将多个渲染器放置在一起。';
21
+ tags = ['容器'];
22
+ icon = 'fa fa-square-o';
23
+ scaffold = {
24
+ type: 'container',
25
+ body: '内容'
26
+ };
27
+ previewSchema = {
28
+ ...this.scaffold
29
+ };
30
+
31
+ regions: Array<RegionConfig> = [
32
+ {
33
+ key: 'body',
34
+ label: '内容区'
35
+ }
36
+ ];
37
+
38
+ panelTitle = '容器';
39
+ panelBodyCreator = (context: BaseEventContext) => {
40
+ return [getSchemaTpl('className'), getSchemaTpl('style')];
41
+ };
42
+ }
43
+
44
+ registerEditorPlugin(ContainerPlugin);
@@ -0,0 +1,128 @@
1
+ /**
2
+ * @file 自定义代码
3
+ */
4
+
5
+ import React from 'react';
6
+ import {registerEditorPlugin} from '../manager';
7
+ import {
8
+ BasePlugin,
9
+ BasicSubRenderInfo,
10
+ BaseEventContext,
11
+ RendererEventContext,
12
+ SubRendererInfo,
13
+ BasicRendererInfo,
14
+ RendererInfoResolveEventContext,
15
+ PluginInterface
16
+ } from '../plugin';
17
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
18
+ import {isArray} from 'lodash';
19
+
20
+ export class CustomPlugin extends BasePlugin {
21
+ // 关联渲染器名字
22
+ rendererName = 'custom';
23
+ $schema = '/schemas/CustomSchema.json';
24
+
25
+ // 组件名称
26
+ name = '自定义代码';
27
+ isBaseComponent = true;
28
+ description = '通过内嵌代码来实现功能';
29
+ tags = ['功能'];
30
+ icon = 'fa fa-gears';
31
+ docLink = '/amis/zh-CN/components/custom';
32
+ scaffold = {
33
+ type: 'custom',
34
+ html: '<div><h2>hello, world!</h2></div>',
35
+ onMount: `
36
+ const button = document.createElement('button');
37
+ button.innerText = '点击修改姓名';
38
+ button.onclick = event => {
39
+ event.preventDefault();
40
+ };
41
+ dom.appendChild(button);`
42
+ };
43
+ previewSchema = {
44
+ ...this.scaffold
45
+ };
46
+
47
+ panelTitle = '自定义代码';
48
+ panelBody = [
49
+ getSchemaTpl('fieldSet', {
50
+ title: 'HTML 内容',
51
+ body: [
52
+ {
53
+ label: 'HTML 内容',
54
+ name: 'html',
55
+ type: 'editor',
56
+ allowFullscreen: true
57
+ }
58
+ ]
59
+ }),
60
+ getSchemaTpl('fieldSet', {
61
+ title: 'onMount',
62
+ body: [
63
+ {
64
+ name: 'onMount',
65
+ type: 'editor',
66
+ allowFullscreen: true,
67
+ size: 'xxl',
68
+ label: 'onMount 代码',
69
+ options: {
70
+ lineNumbers: 'off',
71
+ glyphMargin: false,
72
+ lineDecorationsWidth: 0,
73
+ lineNumbersMinChars: 0
74
+ }
75
+ }
76
+ ]
77
+ }),
78
+ getSchemaTpl('fieldSet', {
79
+ title: 'onUpdate',
80
+ body: [
81
+ {
82
+ name: 'onUpdate',
83
+ type: 'editor',
84
+ allowFullscreen: true,
85
+ size: 'xxl',
86
+ label: 'onUpdate 代码'
87
+ }
88
+ ]
89
+ }),
90
+ getSchemaTpl('fieldSet', {
91
+ title: 'onUnmount',
92
+ body: [
93
+ {
94
+ name: 'onUnmount',
95
+ type: 'editor',
96
+ allowFullscreen: true,
97
+ size: 'xxl',
98
+ label: 'onUnmount 代码'
99
+ }
100
+ ]
101
+ })
102
+ ];
103
+
104
+ buildSubRenderers(
105
+ context: RendererEventContext,
106
+ renderers: Array<SubRendererInfo>
107
+ ): BasicSubRenderInfo | Array<BasicSubRenderInfo> | void {
108
+ const info = super.buildSubRenderers.apply(this, arguments);
109
+ // 只有 form 下才调 onChange
110
+ // if (
111
+ // context.info.renderer.name === 'form' ||
112
+ // context.node.childRegions.some(i => i.region === 'body')
113
+ // ) {
114
+ (info as BasicSubRenderInfo).scaffold.onMount = `
115
+ const button = document.createElement('button');
116
+ button.innerText = '点击修改姓名ddd';
117
+ button.onclick = event => {
118
+ onChange('new name');
119
+ event.preventDefault();
120
+ };
121
+ dom.appendChild(button);`;
122
+ // }
123
+
124
+ return info;
125
+ }
126
+ }
127
+
128
+ registerEditorPlugin(CustomPlugin);
@@ -0,0 +1,150 @@
1
+ /**
2
+ * @file 自定义代码
3
+ */
4
+
5
+ import React from 'react';
6
+ import {registerEditorPlugin} from '../manager';
7
+ import {
8
+ BasePlugin,
9
+ BasicRendererInfo,
10
+ RendererInfoResolveEventContext,
11
+ PluginInterface
12
+ } from '../plugin';
13
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
14
+ import {isArray} from 'lodash';
15
+
16
+ export class CustomPlugin extends BasePlugin {
17
+ // 关联渲染器名字
18
+ rendererName = 'custom';
19
+ $schema = '/schemas/CustomSchema.json';
20
+
21
+ // 组件名称
22
+ name = '自定义容器';
23
+ isBaseComponent = true;
24
+ disabledRendererPlugin = true; // 待完善,暂时隐藏
25
+
26
+ description = '通过自定义代码来实现容器组件';
27
+ docLink = '/amis/zh-CN/components/custom';
28
+ tags = ['功能', '容器'];
29
+ icon = 'fa fa-gears';
30
+ scaffold = {
31
+ type: 'custom',
32
+ html: '<div>\n<h2>hello, world!</h2>\n<div id="customBox">自定义容器区域</div>\n</div>',
33
+ onMount: `this.renderChild('body', props.body, document.getElementById('customBox'));`,
34
+ body: [
35
+ {
36
+ type: 'tpl',
37
+ tpl: '<p>自定义容器区域</p>',
38
+ inline: false,
39
+ id: 'u:474a4572c703'
40
+ }
41
+ ]
42
+ };
43
+
44
+ previewSchema = {
45
+ ...this.scaffold
46
+ };
47
+
48
+ panelTitle = '自定义代码';
49
+ panelBody = [
50
+ getSchemaTpl('fieldSet', {
51
+ title: 'HTML 内容',
52
+ body: [
53
+ {
54
+ label: 'HTML 内容',
55
+ name: 'html',
56
+ type: 'editor',
57
+ allowFullscreen: true
58
+ }
59
+ ]
60
+ }),
61
+ getSchemaTpl('fieldSet', {
62
+ title: 'onMount',
63
+ body: [
64
+ {
65
+ name: 'onMount',
66
+ type: 'editor',
67
+ allowFullscreen: true,
68
+ size: 'xxl',
69
+ label: 'onMount 代码',
70
+ options: {
71
+ lineNumbers: 'off',
72
+ glyphMargin: false,
73
+ lineDecorationsWidth: 0,
74
+ lineNumbersMinChars: 0
75
+ }
76
+ }
77
+ ]
78
+ }),
79
+ getSchemaTpl('fieldSet', {
80
+ title: 'onUpdate',
81
+ body: [
82
+ {
83
+ name: 'onUpdate',
84
+ type: 'editor',
85
+ allowFullscreen: true,
86
+ size: 'xxl',
87
+ label: 'onUpdate 代码'
88
+ }
89
+ ]
90
+ }),
91
+ getSchemaTpl('fieldSet', {
92
+ title: 'onUnmount',
93
+ body: [
94
+ {
95
+ name: 'onUnmount',
96
+ type: 'editor',
97
+ allowFullscreen: true,
98
+ size: 'xxl',
99
+ label: 'onUnmount 代码'
100
+ }
101
+ ]
102
+ })
103
+ ];
104
+
105
+ /**
106
+ * 备注: 根据当前custom组件的schema中是否有body元素来启动容器模式,用于实现custom组件实现自定义容器类型
107
+ */
108
+ getRendererInfo(
109
+ context: RendererInfoResolveEventContext
110
+ ): BasicRendererInfo | void {
111
+ const plugin: PluginInterface = this;
112
+ const {renderer, schema} = context;
113
+ if (
114
+ schema.$$id &&
115
+ plugin.name &&
116
+ plugin.rendererName &&
117
+ plugin.rendererName === renderer.name
118
+ ) {
119
+ let regions = plugin.regions;
120
+ if (!regions && schema && schema.body && isArray(schema.body)) {
121
+ regions = [
122
+ {
123
+ key: 'body',
124
+ label: '自定义容器区'
125
+ }
126
+ ];
127
+ }
128
+
129
+ return {
130
+ name: plugin.name,
131
+ regions: regions,
132
+ patchContainers: plugin.patchContainers,
133
+ // wrapper: plugin.wrapper,
134
+ vRendererConfig: plugin.vRendererConfig,
135
+ wrapperProps: plugin.wrapperProps,
136
+ wrapperResolve: plugin.wrapperResolve,
137
+ filterProps: plugin.filterProps,
138
+ $schema: plugin.$schema,
139
+ renderRenderer: plugin.renderRenderer,
140
+ multifactor: plugin.multifactor,
141
+ scaffoldForm: plugin.scaffoldForm,
142
+ disabledRendererPlugin: plugin.disabledRendererPlugin,
143
+ isBaseComponent: plugin.isBaseComponent,
144
+ rendererName: plugin.rendererName
145
+ };
146
+ }
147
+ }
148
+ }
149
+
150
+ registerEditorPlugin(CustomPlugin);
@@ -0,0 +1,81 @@
1
+ import {Button, SchemaObject} from 'amis';
2
+ import React from 'react';
3
+ import {registerEditorPlugin} from '../manager';
4
+ import {
5
+ BaseEventContext,
6
+ BasePlugin,
7
+ RegionConfig,
8
+ RendererInfo
9
+ } from '../plugin';
10
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
11
+
12
+ export class DatePlugin extends BasePlugin {
13
+ // 关联渲染器名字
14
+ rendererName = 'date';
15
+ $schema = '/schemas/DateSchema.json';
16
+
17
+ // 组件名称
18
+ name = '日期展示';
19
+ isBaseComponent = true;
20
+ description =
21
+ '主要用来关联字段名做日期展示,支持各种格式如:X(时间戳),YYYY-MM-DD HH:mm:ss。';
22
+ tags = ['展示'];
23
+ icon = 'fa fa-calendar';
24
+ scaffold = {
25
+ type: 'date',
26
+ value: Math.round(Date.now() / 1000)
27
+ };
28
+ previewSchema = {
29
+ ...this.scaffold,
30
+ format: 'YYYY-MM-DD',
31
+ value: Math.round(Date.now() / 1000)
32
+ };
33
+
34
+ panelTitle = '日期展示';
35
+ panelBodyCreator = (context: BaseEventContext) => {
36
+ return [
37
+ getSchemaTpl('tabs', [
38
+ {
39
+ title: '常规',
40
+ body: [
41
+ {
42
+ type: 'input-date',
43
+ name: 'value',
44
+ label: '日期数值'
45
+ },
46
+ {
47
+ type: 'input-text',
48
+ name: 'format',
49
+ label: '显示日期格式',
50
+ description: '请参考 moment 中的格式用法。',
51
+ pipeIn: defaultValue('YYYY-MM-DD')
52
+ },
53
+ {
54
+ type: 'input-text',
55
+ name: 'valueFormat',
56
+ label: '数据日期格式',
57
+ description: '请参考 moment 中的格式用法。',
58
+ pipeIn: defaultValue('X')
59
+ },
60
+ {
61
+ name: 'placeholder',
62
+ type: 'input-text',
63
+ pipeIn: defaultValue('-'),
64
+ label: '占位符'
65
+ }
66
+ ]
67
+ },
68
+ {
69
+ title: '外观',
70
+ body: [getSchemaTpl('className')]
71
+ },
72
+ {
73
+ title: '显隐',
74
+ body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
75
+ }
76
+ ])
77
+ ];
78
+ };
79
+ }
80
+
81
+ registerEditorPlugin(DatePlugin);