amis-editor 4.1.0-beta.4 → 4.2.0-beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. package/dist/component/Breadcrumb.d.ts +23 -2
  2. package/dist/component/ClassNameControl.d.ts +1 -1
  3. package/dist/component/Control/APIControl.d.ts +2 -2
  4. package/dist/component/Control/OptionControl.d.ts +3 -3
  5. package/dist/component/Control/PopoverEdit.d.ts +4 -4
  6. package/dist/component/Control/ValidationControl.d.ts +1 -1
  7. package/dist/component/Editor.d.ts +20 -1
  8. package/dist/component/IFramePreview.d.ts +2 -1
  9. package/dist/component/NodeWrapper.d.ts +1 -1
  10. package/dist/component/Panel/RenderersPanel.d.ts +1 -2
  11. package/dist/component/Preview.d.ts +3 -1
  12. package/dist/component/RegionWrapper.d.ts +4 -0
  13. package/dist/component/ScaffoldModal.d.ts +1 -1
  14. package/dist/component/VRenderer.d.ts +4 -0
  15. package/dist/component/base/InputComponentName.d.ts +1 -1
  16. package/dist/component/base/SearchCustomRendererPanel.d.ts +15 -0
  17. package/dist/component/base/SearchPanel.d.ts +83 -0
  18. package/dist/component/base/SearchRendererPanel.d.ts +2 -42
  19. package/dist/component/base/ShortcutKey.d.ts +23 -0
  20. package/dist/env.d.ts +1 -1
  21. package/dist/exports.min.js +1 -1
  22. package/dist/index.d.ts +5 -1
  23. package/dist/index.min.js +1 -1
  24. package/dist/manager.d.ts +16 -4
  25. package/dist/plugin/Alert.d.ts +1 -1
  26. package/dist/plugin/Button.d.ts +1 -1
  27. package/dist/plugin/Card.d.ts +1 -0
  28. package/dist/plugin/Cards.d.ts +2 -1
  29. package/dist/plugin/Carousel.d.ts +1 -0
  30. package/dist/plugin/Chart.d.ts +1 -0
  31. package/dist/plugin/Collapse.d.ts +1 -0
  32. package/dist/plugin/Custom.d.ts +3 -0
  33. package/dist/plugin/CustomRegion.d.ts +40 -0
  34. package/dist/plugin/Dialog.d.ts +1 -1
  35. package/dist/plugin/Drawer.d.ts +1 -1
  36. package/dist/plugin/DropDownButton.d.ts +1 -1
  37. package/dist/plugin/Each.d.ts +1 -1
  38. package/dist/plugin/Flex.d.ts +1 -0
  39. package/dist/plugin/Form/Control.d.ts +1 -0
  40. package/dist/plugin/Form/Form.d.ts +19 -3
  41. package/dist/plugin/Form/Formula.d.ts +3 -3
  42. package/dist/plugin/Form/InputURL.d.ts +1 -0
  43. package/dist/plugin/Form/Switch.d.ts +2 -0
  44. package/dist/plugin/Grid.d.ts +1 -0
  45. package/dist/plugin/HBox.d.ts +1 -0
  46. package/dist/plugin/IFrame.d.ts +3 -3
  47. package/dist/plugin/Json.d.ts +1 -0
  48. package/dist/plugin/List.d.ts +2 -1
  49. package/dist/plugin/Mapping.d.ts +1 -0
  50. package/dist/plugin/Markdown.d.ts +1 -0
  51. package/dist/plugin/Nav.d.ts +1 -0
  52. package/dist/plugin/Page.d.ts +1 -1
  53. package/dist/plugin/Panel/Outline.d.ts +8 -0
  54. package/dist/plugin/Progress.d.ts +1 -0
  55. package/dist/plugin/QRCode.d.ts +1 -0
  56. package/dist/plugin/Reset.d.ts +0 -1
  57. package/dist/plugin/Service.d.ts +1 -0
  58. package/dist/plugin/Sparkline.d.ts +1 -0
  59. package/dist/plugin/Status.d.ts +1 -0
  60. package/dist/plugin/Steps.d.ts +1 -0
  61. package/dist/plugin/Submit.d.ts +0 -1
  62. package/dist/plugin/Table.d.ts +1 -1
  63. package/dist/plugin/TableView.d.ts +1 -0
  64. package/dist/plugin/Tasks.d.ts +1 -0
  65. package/dist/plugin/TooltipWrapper.d.ts +1 -0
  66. package/dist/plugin/Video.d.ts +1 -0
  67. package/dist/plugin/WebComponent.d.ts +1 -0
  68. package/dist/plugin/Wizard.d.ts +11 -2
  69. package/dist/plugin/Wrapper.d.ts +1 -0
  70. package/dist/plugin.d.ts +8 -7
  71. package/dist/store/editor.d.ts +58 -22
  72. package/dist/store/node.d.ts +6 -0
  73. package/dist/style.css +1 -1
  74. package/dist/util.d.ts +1 -1
  75. package/package.json +9 -3
  76. package/src/component/schemaTpl.tsx +2157 -0
  77. package/src/plugin/Alert.tsx +87 -0
  78. package/src/plugin/AnchorNav.tsx +233 -0
  79. package/src/plugin/Audio.tsx +154 -0
  80. package/src/plugin/Avatar.tsx +77 -0
  81. package/src/plugin/Breadcrumb.tsx +107 -0
  82. package/src/plugin/Button.tsx +281 -0
  83. package/src/plugin/ButtonGroup.tsx +85 -0
  84. package/src/plugin/ButtonToolbar.tsx +87 -0
  85. package/src/plugin/CRUD.tsx +1835 -0
  86. package/src/plugin/Card.tsx +290 -0
  87. package/src/plugin/Cards.tsx +318 -0
  88. package/src/plugin/Carousel.tsx +377 -0
  89. package/src/plugin/Chart.tsx +218 -0
  90. package/src/plugin/CodeView.tsx +60 -0
  91. package/src/plugin/Collapse.tsx +136 -0
  92. package/src/plugin/CollapseGroup.tsx +167 -0
  93. package/src/plugin/Container.tsx +40 -0
  94. package/src/plugin/Custom.tsx +128 -0
  95. package/src/plugin/CustomRegion.tsx +156 -0
  96. package/src/plugin/Date.tsx +74 -0
  97. package/src/plugin/Datetime.tsx +68 -0
  98. package/src/plugin/Dialog.tsx +176 -0
  99. package/src/plugin/Divider.tsx +36 -0
  100. package/src/plugin/Drawer.tsx +214 -0
  101. package/src/plugin/DropDownButton.tsx +235 -0
  102. package/src/plugin/Each.tsx +150 -0
  103. package/src/plugin/ErrorRenderer.tsx +15 -0
  104. package/src/plugin/Flex.tsx +151 -0
  105. package/src/plugin/Form/ButtonGroupSelect.tsx +75 -0
  106. package/src/plugin/Form/ButtonToolbar.tsx +110 -0
  107. package/src/plugin/Form/ChainedSelect.tsx +70 -0
  108. package/src/plugin/Form/Checkbox.tsx +87 -0
  109. package/src/plugin/Form/Checkboxes.tsx +167 -0
  110. package/src/plugin/Form/CodeEditor.tsx +81 -0
  111. package/src/plugin/Form/Combo.tsx +582 -0
  112. package/src/plugin/Form/ConditionBuilder.tsx +315 -0
  113. package/src/plugin/Form/Control.tsx +139 -0
  114. package/src/plugin/Form/DiffEditor.tsx +111 -0
  115. package/src/plugin/Form/FieldSet.tsx +163 -0
  116. package/src/plugin/Form/Form.tsx +687 -0
  117. package/src/plugin/Form/Formula.tsx +79 -0
  118. package/src/plugin/Form/Group.tsx +295 -0
  119. package/src/plugin/Form/Hidden.tsx +44 -0
  120. package/src/plugin/Form/InputArray.tsx +228 -0
  121. package/src/plugin/Form/InputCity.tsx +93 -0
  122. package/src/plugin/Form/InputColor.tsx +123 -0
  123. package/src/plugin/Form/InputDate.tsx +175 -0
  124. package/src/plugin/Form/InputDateRange.tsx +225 -0
  125. package/src/plugin/Form/InputDateTime.tsx +183 -0
  126. package/src/plugin/Form/InputDateTimeRange.tsx +221 -0
  127. package/src/plugin/Form/InputEmail.tsx +33 -0
  128. package/src/plugin/Form/InputExcel.tsx +85 -0
  129. package/src/plugin/Form/InputFile.tsx +221 -0
  130. package/src/plugin/Form/InputGroup.tsx +96 -0
  131. package/src/plugin/Form/InputImage.tsx +266 -0
  132. package/src/plugin/Form/InputKV.tsx +72 -0
  133. package/src/plugin/Form/InputMonth.tsx +35 -0
  134. package/src/plugin/Form/InputMonthRange.tsx +195 -0
  135. package/src/plugin/Form/InputNumber.tsx +89 -0
  136. package/src/plugin/Form/InputPassword.tsx +33 -0
  137. package/src/plugin/Form/InputQuarter.tsx +35 -0
  138. package/src/plugin/Form/InputQuarterRange.tsx +195 -0
  139. package/src/plugin/Form/InputRange.tsx +121 -0
  140. package/src/plugin/Form/InputRating.tsx +78 -0
  141. package/src/plugin/Form/InputRepeat.tsx +57 -0
  142. package/src/plugin/Form/InputRichText.tsx +186 -0
  143. package/src/plugin/Form/InputSubForm.tsx +189 -0
  144. package/src/plugin/Form/InputTable.tsx +434 -0
  145. package/src/plugin/Form/InputTag.tsx +70 -0
  146. package/src/plugin/Form/InputText.tsx +186 -0
  147. package/src/plugin/Form/InputTime.tsx +85 -0
  148. package/src/plugin/Form/InputTree.tsx +229 -0
  149. package/src/plugin/Form/InputURL.tsx +34 -0
  150. package/src/plugin/Form/InputYear.tsx +35 -0
  151. package/src/plugin/Form/Item.tsx +327 -0
  152. package/src/plugin/Form/ListSelect.tsx +73 -0
  153. package/src/plugin/Form/LocationPicker.tsx +62 -0
  154. package/src/plugin/Form/MatrixCheckboxes.tsx +136 -0
  155. package/src/plugin/Form/NestedSelect.tsx +211 -0
  156. package/src/plugin/Form/Picker.tsx +209 -0
  157. package/src/plugin/Form/Radios.tsx +119 -0
  158. package/src/plugin/Form/Select.tsx +233 -0
  159. package/src/plugin/Form/Static.tsx +322 -0
  160. package/src/plugin/Form/Switch.tsx +107 -0
  161. package/src/plugin/Form/TabsTransfer.tsx +259 -0
  162. package/src/plugin/Form/Textarea.tsx +83 -0
  163. package/src/plugin/Form/Transfer.tsx +368 -0
  164. package/src/plugin/Form/TreeSelect.tsx +263 -0
  165. package/src/plugin/Form/UUID.tsx +48 -0
  166. package/src/plugin/Grid.tsx +798 -0
  167. package/src/plugin/HBox.tsx +727 -0
  168. package/src/plugin/IFrame.tsx +70 -0
  169. package/src/plugin/Image.tsx +314 -0
  170. package/src/plugin/Images.tsx +231 -0
  171. package/src/plugin/Json.tsx +69 -0
  172. package/src/plugin/Link.tsx +93 -0
  173. package/src/plugin/List.tsx +278 -0
  174. package/src/plugin/ListItem.tsx +229 -0
  175. package/src/plugin/Log.tsx +52 -0
  176. package/src/plugin/Mapping.tsx +149 -0
  177. package/src/plugin/Markdown.tsx +47 -0
  178. package/src/plugin/Nav.tsx +184 -0
  179. package/src/plugin/Operation.tsx +95 -0
  180. package/src/plugin/Others/Action.tsx +426 -0
  181. package/src/plugin/Others/BasicToolbar.tsx +585 -0
  182. package/src/plugin/Others/DataDebug.tsx +134 -0
  183. package/src/plugin/Others/TableCell.tsx +480 -0
  184. package/src/plugin/Others/Unknown.tsx +37 -0
  185. package/src/plugin/Page.tsx +306 -0
  186. package/src/plugin/Panel/AvailableRenderers.tsx +41 -0
  187. package/src/plugin/Panel/Code.tsx +44 -0
  188. package/src/plugin/Panel/Name.tsx +26 -0
  189. package/src/plugin/Panel/Outline.tsx +40 -0
  190. package/src/plugin/Panel.tsx +243 -0
  191. package/src/plugin/Plain.tsx +84 -0
  192. package/src/plugin/Progress.tsx +125 -0
  193. package/src/plugin/Property.tsx +139 -0
  194. package/src/plugin/QRCode.tsx +96 -0
  195. package/src/plugin/Reset.tsx +23 -0
  196. package/src/plugin/Service.tsx +162 -0
  197. package/src/plugin/Sparkline.tsx +40 -0
  198. package/src/plugin/Status.tsx +76 -0
  199. package/src/plugin/Steps.tsx +128 -0
  200. package/src/plugin/Submit.tsx +23 -0
  201. package/src/plugin/Table.tsx +428 -0
  202. package/src/plugin/TableView.tsx +709 -0
  203. package/src/plugin/Tabs.tsx +362 -0
  204. package/src/plugin/Tasks.tsx +274 -0
  205. package/src/plugin/Time.tsx +68 -0
  206. package/src/plugin/TooltipWrapper.tsx +193 -0
  207. package/src/plugin/Tpl.tsx +158 -0
  208. package/src/plugin/Video.tsx +158 -0
  209. package/src/plugin/WebComponent.tsx +53 -0
  210. package/src/plugin/Wizard.tsx +740 -0
  211. package/src/plugin/Wrapper.tsx +107 -0
  212. package/src/plugin.ts +1050 -0
  213. package/dist/150a58f3318ca7541ed9.png +0 -0
  214. package/dist/471adb97c322b226e589.png +0 -0
  215. package/dist/4de5f42360bc5946c3c2.png +0 -0
  216. package/dist/4e9968bba3855f088fed.png +0 -0
  217. package/dist/7f09c38ebc687fea847a.png +0 -0
  218. package/dist/c94073576487510314ea.png +0 -0
@@ -0,0 +1,76 @@
1
+ import {registerEditorPlugin} from '../manager';
2
+ import {BasePlugin, BaseEventContext} from '../plugin';
3
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
4
+
5
+ export class StatusPlugin extends BasePlugin {
6
+ // 关联渲染器名字
7
+ rendererName = 'status';
8
+ $schema = '/schemas/StatusSchema.json';
9
+
10
+ // 组件名称
11
+ name = '状态显示';
12
+ isBaseComponent = true;
13
+ description =
14
+ '用图标更具关联字段来展示状态,比如 1 展示 √、0 展示 x。这块可以自定义配置';
15
+ docLink = '/amis/zh-CN/components/status';
16
+ tags = ['展示'];
17
+ icon = 'fa fa-check-square-o';
18
+ scaffold = {
19
+ type: 'status',
20
+ value: 1
21
+ };
22
+ previewSchema = {
23
+ ...this.scaffold
24
+ };
25
+
26
+ panelTitle = '状态';
27
+ panelBodyCreator = (context: BaseEventContext) => {
28
+ const isUnderField: boolean = /\/field\/\w+$/.test(context.path as string);
29
+ return [
30
+ getSchemaTpl('tabs', [
31
+ {
32
+ title: '常规',
33
+ body: [
34
+ isUnderField
35
+ ? {
36
+ type: 'tpl',
37
+ inline: false,
38
+ className: 'text-info text-sm',
39
+ tpl: '<p>当前为字段内容节点配置,选择上层还有更多的配置。</p>'
40
+ }
41
+ : null,
42
+ {
43
+ name: 'map',
44
+ label: '图标配置',
45
+ type: 'input-array',
46
+ items: {
47
+ type: 'input-text'
48
+ },
49
+ descrition: '配置不通的值段,用不通的样式提示用户',
50
+ pipeIn: defaultValue([
51
+ 'fa fa-times text-danger',
52
+ 'fa fa-check text-success'
53
+ ])
54
+ },
55
+ {
56
+ name: 'placeholder',
57
+ type: 'input-text',
58
+ pipeIn: defaultValue('-'),
59
+ label: '占位符'
60
+ }
61
+ ]
62
+ },
63
+ {
64
+ title: '外观',
65
+ body: [getSchemaTpl('className')]
66
+ },
67
+ {
68
+ title: '显隐',
69
+ body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
70
+ }
71
+ ])
72
+ ];
73
+ };
74
+ }
75
+
76
+ registerEditorPlugin(StatusPlugin);
@@ -0,0 +1,128 @@
1
+ /**
2
+ * @file Steps 步骤条
3
+ */
4
+ import {registerEditorPlugin} from '../manager';
5
+ import {BasePlugin} from '../plugin';
6
+ import {getSchemaTpl} from '../component/schemaTpl';
7
+
8
+ export class StepsPlugin extends BasePlugin {
9
+ // 关联渲染器名字
10
+ rendererName = 'steps';
11
+ $schema = '/schemas/StepsSchema.json';
12
+
13
+ // 组件名称
14
+ name = 'Steps 步骤条';
15
+ isBaseComponent = true;
16
+ icon = 'fa fa-forward';
17
+ description = 'Steps 步骤条';
18
+ docLink = '/amis/zh-CN/components/steps';
19
+ tags = ['展示'];
20
+ scaffold = {
21
+ type: 'steps',
22
+ value: 1,
23
+ steps: [
24
+ {
25
+ title: '第一步',
26
+ subTitle: '副标题',
27
+ description: '描述'
28
+ },
29
+ {
30
+ title: '第二步'
31
+ },
32
+ {
33
+ title: '第三步'
34
+ }
35
+ ]
36
+ };
37
+ previewSchema = {
38
+ ...this.scaffold
39
+ };
40
+
41
+ panelTitle = 'Steps';
42
+ panelBody = [
43
+ getSchemaTpl('tabs', [
44
+ {
45
+ title: '常规',
46
+ body: [
47
+ {
48
+ name: 'steps',
49
+ label: '步骤列表',
50
+ type: 'combo',
51
+ scaffold: {
52
+ type: 'wrapper',
53
+ body: '子节点内容'
54
+ },
55
+ minLength: 2,
56
+ multiple: true,
57
+ draggable: true,
58
+ items: [
59
+ {
60
+ type: 'input-text',
61
+ name: 'title',
62
+ label: false,
63
+ placeholder: '标题'
64
+ },
65
+ {
66
+ type: 'input-text',
67
+ name: 'subTitle',
68
+ label: false,
69
+ placeholder: '副标题'
70
+ },
71
+ {
72
+ type: 'input-text',
73
+ name: 'description',
74
+ label: false,
75
+ placeholder: '描述'
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ name: 'value',
81
+ type: 'input-text',
82
+ label: '当前步骤',
83
+ description: '以零为起点'
84
+ },
85
+ {
86
+ name: 'status',
87
+ type: 'select',
88
+ label: '当前状态',
89
+ creatable: true,
90
+ value: 'finish',
91
+ options: [
92
+ {
93
+ label: '进行中',
94
+ value: 'process'
95
+ },
96
+ {
97
+ label: '等待',
98
+ value: 'wait'
99
+ },
100
+ {
101
+ label: '完成',
102
+ value: 'finish'
103
+ },
104
+ {
105
+ label: '出错',
106
+ value: 'error'
107
+ }
108
+ ]
109
+ },
110
+ getSchemaTpl('api', {
111
+ name: 'source',
112
+ label: '获取步骤接口'
113
+ })
114
+ ]
115
+ },
116
+ {
117
+ title: '外观',
118
+ body: [getSchemaTpl('className')]
119
+ },
120
+ {
121
+ title: '显隐',
122
+ body: [getSchemaTpl('visible')]
123
+ }
124
+ ])
125
+ ];
126
+ }
127
+
128
+ registerEditorPlugin(StepsPlugin);
@@ -0,0 +1,23 @@
1
+ import {registerEditorPlugin} from '../manager';
2
+ import {ButtonPlugin} from './Button';
3
+
4
+ export class SubmitPlugin extends ButtonPlugin {
5
+ // 关联渲染器名字
6
+ rendererName = 'submit';
7
+ disabledRendererPlugin = true; // 组件面板不显示
8
+ // 组件名称
9
+ name = '提交';
10
+ isBaseComponent = true;
11
+ description = '用来提交表单,要求表单验证,如果在弹窗中会自动关闭弹窗。';
12
+ panelTitle = '按钮';
13
+ scaffold: any = {
14
+ type: 'submit',
15
+ label: '提交',
16
+ level: 'primary'
17
+ };
18
+ previewSchema = {
19
+ ...this.scaffold
20
+ };
21
+ }
22
+
23
+ registerEditorPlugin(SubmitPlugin);
@@ -0,0 +1,428 @@
1
+ import {resolveVariable} from 'amis';
2
+ import {registerEditorPlugin} from '../manager';
3
+ import {
4
+ BasePlugin,
5
+ BaseEventContext,
6
+ PluginEvent,
7
+ RegionConfig,
8
+ RendererInfoResolveEventContext,
9
+ BasicRendererInfo,
10
+ PluginInterface,
11
+ InsertEventContext,
12
+ ScaffoldForm
13
+ } from '../plugin';
14
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
15
+ import {repeatArray} from '../util';
16
+ import {setVariable} from 'amis-core';
17
+ import {mockValue} from '../mocker';
18
+ import {SchemaObject} from 'amis/lib/Schema';
19
+
20
+ export class TablePlugin extends BasePlugin {
21
+ // 关联渲染器名字
22
+ rendererName = 'table';
23
+ $schema = '/schemas/TableSchema.json';
24
+
25
+ // 组件名称
26
+ name = '表格';
27
+ isBaseComponent = true;
28
+ description =
29
+ '用来展示表格数据,可以配置列信息,然后关联数据便能完成展示。支持嵌套、超级表头、列固定、表头固顶、合并单元格等等。当前组件需要配置数据源,不自带数据拉取,请优先使用 「CRUD」 组件。';
30
+ docLink = '/amis/zh-CN/components/table';
31
+ icon = 'fa fa-table';
32
+ scaffold: SchemaObject = {
33
+ type: 'table',
34
+ columns: [
35
+ {
36
+ label: '列信息',
37
+ name: 'a'
38
+ }
39
+ ]
40
+ };
41
+
42
+ regions: Array<RegionConfig> = [
43
+ {
44
+ key: 'columns',
45
+ label: '列集合',
46
+ renderMethod: 'renderTableContent',
47
+ preferTag: '展示',
48
+ dndMode: 'position-h'
49
+ }
50
+ ];
51
+
52
+ //renderTableContent
53
+
54
+ previewSchema: any = {
55
+ type: 'table',
56
+ className: 'text-left m-b-none',
57
+ affixHeader: false,
58
+ items: [
59
+ {a: 1, b: 2},
60
+ {a: 3, b: 4},
61
+ {a: 5, b: 6}
62
+ ],
63
+ columns: [
64
+ {
65
+ label: 'A',
66
+ name: 'a'
67
+ },
68
+ {
69
+ label: 'B',
70
+ name: 'b'
71
+ }
72
+ ]
73
+ };
74
+
75
+ scaffoldForm: ScaffoldForm = {
76
+ title: '快速构建表格',
77
+ body: [
78
+ {
79
+ name: 'columns',
80
+ type: 'combo',
81
+ multiple: true,
82
+ label: false,
83
+ addButtonText: '新增一列',
84
+ draggable: true,
85
+ items: [
86
+ {
87
+ type: 'input-text',
88
+ name: 'label',
89
+ placeholder: '标题'
90
+ },
91
+ {
92
+ type: 'input-text',
93
+ name: 'name',
94
+ placeholder: '绑定字段名'
95
+ },
96
+ {
97
+ type: 'select',
98
+ name: 'type',
99
+ placeholder: '类型',
100
+ value: 'text',
101
+ options: [
102
+ {
103
+ value: 'text',
104
+ label: '纯文本'
105
+ },
106
+ {
107
+ value: 'tpl',
108
+ label: '模板'
109
+ },
110
+ {
111
+ value: 'image',
112
+ label: '图片'
113
+ },
114
+ {
115
+ value: 'date',
116
+ label: '日期'
117
+ },
118
+ // {
119
+ // value: 'datetime',
120
+ // label: '日期时间'
121
+ // },
122
+ // {
123
+ // value: 'time',
124
+ // label: '时间'
125
+ // },
126
+ {
127
+ value: 'progress',
128
+ label: '进度'
129
+ },
130
+ {
131
+ value: 'status',
132
+ label: '状态'
133
+ },
134
+ {
135
+ value: 'mapping',
136
+ label: '映射'
137
+ },
138
+ {
139
+ value: 'operation',
140
+ label: '操作栏'
141
+ }
142
+ ]
143
+ }
144
+ ]
145
+ }
146
+ ],
147
+ canRebuild: true
148
+ };
149
+
150
+ panelTitle = '表格';
151
+ panelBodyCreator = (context: BaseEventContext) => {
152
+ const isCRUDBody = context.schema.type === 'crud';
153
+
154
+ return getSchemaTpl('tabs', [
155
+ {
156
+ title: '常规',
157
+ body: [
158
+ {
159
+ name: 'title',
160
+ type: 'input-text',
161
+ label: '标题'
162
+ },
163
+
164
+ isCRUDBody
165
+ ? null
166
+ : {
167
+ name: 'source',
168
+ type: 'input-text',
169
+ label: '数据源',
170
+ pipeIn: defaultValue('${items}'),
171
+ description: '绑定当前环境变量'
172
+ },
173
+
174
+ {
175
+ name: 'combineNum',
176
+ label: '自动合并单元格',
177
+ type: 'input-number',
178
+ placeholder: '设置列数',
179
+ description:
180
+ '设置从左到右多少列内启用自动合并单元格,根据字段值是否相同来决定是否合并。'
181
+ }
182
+
183
+ // {
184
+ // children: (
185
+ // <div>
186
+ // <Button
187
+ // level="info"
188
+ // size="sm"
189
+ // className="m-b-sm"
190
+ // block
191
+ // onClick={this.handleAdd}
192
+ // >
193
+ // 新增一列
194
+ // </Button>
195
+ // </div>
196
+ // )
197
+ // },
198
+
199
+ // {
200
+ // children: (
201
+ // <div>
202
+ // <Button
203
+ // level="success"
204
+ // size="sm"
205
+ // block
206
+ // onClick={this.handleColumnsQuickEdit.bind(this)}
207
+ // >
208
+ // 快速编辑列信息
209
+ // </Button>
210
+ // </div>
211
+ // )
212
+ // }
213
+ ]
214
+ },
215
+ {
216
+ title: '外观',
217
+ body: [
218
+ {
219
+ name: 'columnsTogglable',
220
+ label: '展示列显示开关',
221
+ type: 'button-group-select',
222
+ pipeIn: defaultValue('auto'),
223
+ mode: 'inline',
224
+ className: 'w-full',
225
+ size: 'xs',
226
+ options: [
227
+ {
228
+ label: '自动',
229
+ value: 'auto'
230
+ },
231
+
232
+ {
233
+ label: '开启',
234
+ value: true
235
+ },
236
+
237
+ {
238
+ label: '关闭',
239
+ value: false
240
+ }
241
+ ],
242
+ description: '自动即列数量大于5个时自动开启'
243
+ },
244
+
245
+ {
246
+ name: 'affixHeader',
247
+ type: 'switch',
248
+ label: '是否固顶表头',
249
+ mode: 'inline',
250
+ className: 'w-full',
251
+ pipeIn: defaultValue(true)
252
+ },
253
+
254
+ {
255
+ name: 'showHeader',
256
+ type: 'switch',
257
+ mode: 'inline',
258
+ className: 'w-full',
259
+ label: '是否显示头部',
260
+ pipeIn: defaultValue(true)
261
+ },
262
+
263
+ {
264
+ name: 'showFooter',
265
+ type: 'switch',
266
+ mode: 'inline',
267
+ className: 'w-full',
268
+ label: '是否显示底部',
269
+ pipeIn: defaultValue(true)
270
+ },
271
+
272
+ {
273
+ name: 'footable',
274
+ type: 'switch',
275
+ mode: 'inline',
276
+ className: 'w-full',
277
+ label: '是否开启单条底部展示',
278
+ description:
279
+ '如果列太多显示会很臃肿,可以考虑把部分列放在当前行的底部展示',
280
+ pipeIn: (value: any) => !!value
281
+ },
282
+
283
+ {
284
+ name: 'footable.expand',
285
+ type: 'button-group-select',
286
+ size: 'xs',
287
+ visibleOn: 'data.footable',
288
+ label: '底部默认展开',
289
+ pipeIn: defaultValue('none'),
290
+ mode: 'inline',
291
+ className: 'w-full',
292
+ options: [
293
+ {
294
+ label: '第一条',
295
+ value: 'first'
296
+ },
297
+
298
+ {
299
+ label: '所有',
300
+ value: 'all'
301
+ },
302
+
303
+ {
304
+ label: '不展开',
305
+ value: 'none'
306
+ }
307
+ ]
308
+ },
309
+
310
+ {
311
+ name: 'placeholder',
312
+ pipeIn: defaultValue('暂无数据'),
313
+ type: 'input-text',
314
+ label: '无数据提示'
315
+ },
316
+ {
317
+ name: 'rowClassNameExpr',
318
+ type: 'input-text',
319
+ label: '行高亮规则',
320
+ placeholder: `支持模板语法,如 <%= data.id % 2 ? 'bg-success' : '' %>`
321
+ },
322
+ getSchemaTpl('className', {
323
+ label: '外层 CSS 类名'
324
+ }),
325
+
326
+ getSchemaTpl('className', {
327
+ name: 'tableClassName',
328
+ label: '表格 CSS 类名'
329
+ }),
330
+
331
+ getSchemaTpl('className', {
332
+ name: 'headerClassName',
333
+ label: '顶部外层 CSS 类名'
334
+ }),
335
+
336
+ getSchemaTpl('className', {
337
+ name: 'footerClassName',
338
+ label: '底部外层 CSS 类名'
339
+ }),
340
+
341
+ getSchemaTpl('className', {
342
+ name: 'toolbarClassName',
343
+ label: '工具栏 CSS 类名'
344
+ })
345
+ ]
346
+ },
347
+ {
348
+ title: '显隐',
349
+ body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
350
+ }
351
+ ]);
352
+ };
353
+
354
+ filterProps(props: any) {
355
+ const arr = Array.isArray(props.value)
356
+ ? props.value
357
+ : typeof props.source === 'string'
358
+ ? resolveVariable(props.source, props.data)
359
+ : resolveVariable('items', props.data);
360
+
361
+ if (!Array.isArray(arr) || !arr.length) {
362
+ const mockedData: any = {};
363
+
364
+ if (Array.isArray(props.columns)) {
365
+ props.columns.forEach((column: any) => {
366
+ if (column.name) {
367
+ setVariable(mockedData, column.name, mockValue(column));
368
+ }
369
+ });
370
+ }
371
+
372
+ props.value = repeatArray(mockedData, 1).map((item, index) => ({
373
+ ...item,
374
+ id: index + 1
375
+ }));
376
+ } else {
377
+ // 只取10条预览,否则太多卡顿
378
+ props.value = arr.slice(0, 10);
379
+ }
380
+
381
+ return props;
382
+ }
383
+
384
+ // 为了能够自动注入数据。
385
+ getRendererInfo(
386
+ context: RendererInfoResolveEventContext
387
+ ): BasicRendererInfo | void {
388
+ const plugin: PluginInterface = this;
389
+ const {schema, renderer} = context;
390
+ if (
391
+ !schema.$$id &&
392
+ schema.$$editor?.renderer.name === 'crud' &&
393
+ renderer.name === 'table'
394
+ ) {
395
+ return {
396
+ ...({id: schema.$$editor.id} as any),
397
+ name: plugin.name!,
398
+ regions: plugin.regions,
399
+ patchContainers: plugin.patchContainers,
400
+ vRendererConfig: plugin.vRendererConfig,
401
+ wrapperProps: plugin.wrapperProps,
402
+ wrapperResolve: plugin.wrapperResolve,
403
+ filterProps: plugin.filterProps,
404
+ $schema: plugin.$schema,
405
+ renderRenderer: plugin.renderRenderer
406
+ };
407
+ }
408
+ return super.getRendererInfo(context);
409
+ }
410
+
411
+ // 自动插入 label
412
+ beforeInsert(event: PluginEvent<InsertEventContext>) {
413
+ const context = event.context;
414
+
415
+ if (
416
+ (context.info.plugin === this ||
417
+ context.node.sameIdChild?.info.plugin === this) &&
418
+ context.region === 'columns'
419
+ ) {
420
+ context.data = {
421
+ ...context.data,
422
+ label: context.data.label ?? context.subRenderer?.name ?? '列名称'
423
+ };
424
+ }
425
+ }
426
+ }
427
+
428
+ registerEditorPlugin(TablePlugin);