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,17 +1,67 @@
1
- import {relativeValueRe} from 'amis';
2
- import {
3
- defaultValue,
4
- getSchemaTpl,
5
- valuePipeOut
6
- } from '../../component/schemaTpl';
1
+ import {defaultValue, getSchemaTpl} from '../../component/schemaTpl';
7
2
  import {registerEditorPlugin} from '../../manager';
8
- import {
9
- BasePlugin,
10
- BasicSubRenderInfo,
11
- RendererEventContext,
12
- SubRendererInfo
13
- } from '../../plugin';
14
- import moment from 'moment';
3
+ import {BasePlugin, BaseEventContext} from '../../plugin';
4
+
5
+ import {tipedLabel} from '../../component/control/BaseControl';
6
+ import {ValidatorTag} from '../../component/validator';
7
+ import {getEventControlConfig} from '../../util';
8
+ import {RendererAction, RendererEvent} from '../../event-action';
9
+
10
+ const DateType: {
11
+ [key: string]: {
12
+ format: string;
13
+ placeholder: string;
14
+ ranges: string[];
15
+ };
16
+ } = {
17
+ date: {
18
+ format: 'YYYY-MM-DD',
19
+ placeholder: '请选择日期范围',
20
+ ranges: [
21
+ 'yesterday',
22
+ '7daysago',
23
+ 'prevweek',
24
+ 'thismonth',
25
+ 'prevmonth',
26
+ 'prevquarter'
27
+ ]
28
+ },
29
+ datetime: {
30
+ format: 'YYYY-MM-DD HH:mm:ss',
31
+ placeholder: '请选择日期时间范围',
32
+ ranges: [
33
+ 'yesterday',
34
+ '7daysago',
35
+ 'prevweek',
36
+ 'thismonth',
37
+ 'prevmonth',
38
+ 'prevquarter'
39
+ ]
40
+ },
41
+ time: {
42
+ format: 'HH:mm',
43
+ placeholder: '请选择时间范围',
44
+ ranges: []
45
+ },
46
+ month: {
47
+ format: 'YYYY-MM',
48
+ placeholder: '请选择月份范围',
49
+ ranges: []
50
+ },
51
+ quarter: {
52
+ format: 'YYYY [Q]Q',
53
+ placeholder: '请选择季度范围',
54
+ ranges: ['thisquarter', 'prevquarter']
55
+ },
56
+ year: {
57
+ format: 'YYYY',
58
+ placeholder: '请选择年范围',
59
+ ranges: ['thisyear', 'lastYear']
60
+ }
61
+ };
62
+
63
+ const tipedLabelText =
64
+ '支持 <code>now、+1day、-2weeks、+1hours、+2years</code>这种相对值用法,同时支持变量如<code>\\${start_date}</code>';
15
65
 
16
66
  export class DateRangeControlPlugin extends BasePlugin {
17
67
  // 关联渲染器名字
@@ -24,6 +74,9 @@ export class DateRangeControlPlugin extends BasePlugin {
24
74
  icon = 'fa fa-calendar';
25
75
  name = '日期范围';
26
76
  isBaseComponent = true;
77
+ // 添加源对应组件中文名称 & type字段
78
+ searchKeywords =
79
+ '日期范围框、input-datetime-range、日期时间范围、input-time-range、时间范围、input-month-range、月份范围、input-quarter-range、季度范围、input-year-range、年范围';
27
80
  description =
28
81
  '日期范围选择,可通过<code>minDate</code>、<code>maxDate</code>设定最小、最大日期';
29
82
  docLink = '/amis/zh-CN/components/form/input-date-range';
@@ -45,181 +98,270 @@ export class DateRangeControlPlugin extends BasePlugin {
45
98
  ]
46
99
  };
47
100
 
48
- panelTitle = '日期范围';
49
- panelBody = [
50
- getSchemaTpl('placeholder', {
51
- pipeIn: defaultValue('请选择日期范围')
52
- }),
53
-
54
- {
55
- type: 'input-text',
56
- name: 'format',
57
- label: '值格式',
58
- description:
59
- '请参考 <a href="https://momentjs.com/" target="_blank">moment</a> 中的格式用法。',
60
- pipeIn: defaultValue('X'),
61
- onChange: (value: any, oldValue: any, model: any, form: any) => {
62
- form.setValueByName('value', '');
63
- form.setValueByName('minDate', '');
64
- form.setValueByName('maxDate', '');
65
- }
66
- },
67
-
68
- getSchemaTpl('switchDefaultValue'),
101
+ notRenderFormZone = true;
69
102
 
70
- {
71
- type: 'input-text',
72
- name: 'value',
73
- label: '默认值',
74
- visibleOn: 'typeof this.value !== "undefined"',
75
- placeholder: '请输入相对值',
76
- description:
77
- '支持 <code>now、+1day、-2weeks</code>这种相对值用法,由于包含开始和结束时间,请用逗号隔开。'
78
- },
103
+ panelTitle = '日期范围';
79
104
 
105
+ events: RendererEvent[] = [
80
106
  {
81
- type: 'fieldSet',
82
- title: '使用固定值',
83
- visibleOn: 'typeof this.value !== "undefined"',
84
- collapsed: true,
85
- collapsable: true,
86
- className: 'fieldset',
87
- body: [
107
+ eventName: 'change',
108
+ eventLabel: '值变化',
109
+ description: '时间值变化时触发',
110
+ dataSchema: [
88
111
  {
89
- type: 'input-date-range',
90
- name: 'value',
91
- pipeIn: (value: any) =>
92
- value
93
- ? value
94
- .split(',')
95
- .map((item: any) =>
96
- moment(
97
- relativeValueRe.test(item) ||
98
- ~['now', 'today'].indexOf(item)
99
- ? ''
100
- : item
101
- ).format('X')
102
- )
103
- : '',
104
- pipeOut: (value: any, old: any, data: any) => {
105
- let {format} = data;
106
- if (format) {
107
- let val = value.split(',');
108
- value = val
109
- .map((item: string) =>
110
- moment(parseInt(item, 10), 'X').format(format)
111
- )
112
- .join(',');
112
+ type: 'object',
113
+ properties: {
114
+ 'event.data.value': {
115
+ type: 'string',
116
+ title: '时间值'
113
117
  }
114
- return value;
115
118
  }
116
119
  }
117
120
  ]
118
121
  },
119
- getSchemaTpl('clearable', {
120
- pipeIn: defaultValue(true)
121
- }),
122
122
  {
123
- type: 'input-text',
124
- name: 'minDate',
125
- label: '最小日期',
126
- placeholder: '请输入相对值',
127
- description:
128
- '支持 <code>now、+1day、-2weeks</code>这种相对值用法,同时支持变量如<code>\\${start_date}</code>'
129
- },
130
-
131
- {
132
- type: 'fieldSet',
133
- title: '使用固定值',
134
- collapsed: true,
135
- collapsable: true,
136
- className: 'fieldset',
137
- body: [
123
+ eventName: 'focus',
124
+ eventLabel: '获取焦点',
125
+ description: '输入框获取焦点(非内嵌模式)时触发',
126
+ dataSchema: [
138
127
  {
139
- type: 'input-date',
140
- name: 'minDate',
141
- pipeIn: (value: any) =>
142
- moment(
143
- relativeValueRe.test(value) || ~['now', 'today'].indexOf(value)
144
- ? ''
145
- : value
146
- ).format('X'),
147
- pipeOut: (value: any, old: any, data: any) => {
148
- return moment(parseInt(value, 10), 'X').format(data.format);
128
+ type: 'object',
129
+ properties: {
130
+ 'event.data.value': {
131
+ type: 'string',
132
+ title: '时间值'
133
+ }
149
134
  }
150
135
  }
151
136
  ]
152
137
  },
153
-
154
- {
155
- type: 'divider'
156
- },
157
-
158
- {
159
- type: 'input-text',
160
- name: 'maxDate',
161
- label: '最大日期',
162
- placeholder: '请输入相对值',
163
- description:
164
- '支持 <code>now、+1day、-2weeks</code>这种相对值用法,同时支持变量如<code>\\${start_date}</code>'
165
- },
166
-
167
138
  {
168
- type: 'fieldSet',
169
- title: '使用固定值',
170
- collapsed: true,
171
- collapsable: true,
172
- className: 'fieldset',
173
- body: [
139
+ eventName: 'blur',
140
+ eventLabel: '失去焦点',
141
+ description: '输入框失去焦点(非内嵌模式)时触发',
142
+ dataSchema: [
174
143
  {
175
- type: 'input-date',
176
- name: 'maxDate',
177
- pipeIn: (value: any) =>
178
- moment(
179
- relativeValueRe.test(value) || ~['now', 'today'].indexOf(value)
180
- ? ''
181
- : value
182
- ).format('X'),
183
- pipeOut: (value: any, old: any, data: any) => {
184
- return moment(parseInt(value, 10), 'X').format(data.format);
144
+ type: 'object',
145
+ properties: {
146
+ 'event.data.value': {
147
+ type: 'string',
148
+ title: '时间值'
149
+ }
185
150
  }
186
151
  }
187
152
  ]
188
- },
189
- {
190
- type: 'input-text',
191
- name: 'minDuration',
192
- label: '限制最小跨度',
193
- description: '比如 2days'
194
- },
195
- {
196
- type: 'input-text',
197
- name: 'ranges',
198
- label: '日期范围快捷键',
199
- description:
200
- '比如 today, yesterday, 1dayago, 7daysago, 90daysago, prevweek, thismonth, prevmonth, prevquarter, thisquarter'
201
- },
153
+ }
154
+ ];
155
+
156
+ // 动作定义
157
+ actions: RendererAction[] = [
202
158
  {
203
- type: 'input-text',
204
- name: 'maxDuration',
205
- label: '限制最大跨度',
206
- description: '比如 1year'
159
+ actionType: 'clear',
160
+ actionLabel: '清空',
161
+ description: '清空输入框内容'
207
162
  },
208
163
  {
209
- name: 'utc',
210
- label: '是否使用 UTC 时间',
211
- type: 'switch',
212
- mode: 'inline',
213
- className: 'block'
164
+ actionType: 'reset',
165
+ actionLabel: '重置',
166
+ description: '将值重置为resetValue,若没有配置resetValue,则清空'
214
167
  },
215
168
  {
216
- name: 'embed',
217
- label: '是否内嵌模式',
218
- type: 'switch',
219
- mode: 'inline',
220
- className: 'block'
169
+ actionType: 'setValue',
170
+ actionLabel: '赋值',
171
+ description: '触发组件数据更新'
221
172
  }
222
173
  ];
174
+
175
+ panelJustify = true;
176
+
177
+ panelBodyCreator = (context: BaseEventContext) => {
178
+ const renderer: any = context.info.renderer;
179
+
180
+ return getSchemaTpl('tabs', [
181
+ {
182
+ title: '属性',
183
+ body: getSchemaTpl('collapseGroup', [
184
+ {
185
+ title: '基本',
186
+ body: [
187
+ getSchemaTpl('formItemName', {
188
+ required: true
189
+ }),
190
+ getSchemaTpl('label'),
191
+ getSchemaTpl('selectDateRangeType', {
192
+ value: this.scaffold.type,
193
+ onChange: (
194
+ value: string,
195
+ oldValue: any,
196
+ model: any,
197
+ form: any
198
+ ) => {
199
+ const type: string = value.split('-')[1];
200
+ form.setValues({
201
+ inputFormat: DateType[type]?.format,
202
+ placeholder: DateType[type]?.placeholder,
203
+ format: type === 'time' ? 'HH:mm' : 'X',
204
+ minDate: '',
205
+ maxDate: '',
206
+ value: '',
207
+ ranges: DateType[type]?.ranges
208
+ });
209
+ }
210
+ }),
211
+ {
212
+ type: 'input-text',
213
+ name: 'format',
214
+ label: tipedLabel(
215
+ '值格式',
216
+ '提交数据前将根据设定格式化数据,请参考 <a href="https://momentjs.com/" target="_blank">moment</a> 中的格式用法。'
217
+ ),
218
+ pipeIn: defaultValue('X')
219
+ },
220
+ {
221
+ type: 'input-text',
222
+ name: 'inputFormat',
223
+ label: tipedLabel(
224
+ '显示格式',
225
+ '请参考 <a href="https://momentjs.com/" target="_blank">moment</a> 中的格式用法。'
226
+ ),
227
+ pipeIn: defaultValue('YYYY-MM-DD'),
228
+ clearable: true
229
+ // onChange: (
230
+ // value: string,
231
+ // oldValue: any,
232
+ // model: any,
233
+ // form: any
234
+ // ) => {
235
+ // model.setOptions(
236
+ // DateType[form.data.type.split('-')[1]].formatOptions
237
+ // );
238
+ // },
239
+ // options:
240
+ // DateType[this.scaffold.type.split('-')[1]].formatOptions
241
+ },
242
+ getSchemaTpl('utc'),
243
+ getSchemaTpl('clearable', {
244
+ pipeIn: defaultValue(true)
245
+ }),
246
+ getSchemaTpl('formulaControl', {
247
+ name: 'value',
248
+ label: tipedLabel(
249
+ '默认值',
250
+ '支持 <code>now、+1day、-2weeks、+1hours、+2years</code>等这种相对值用法'
251
+ ),
252
+ placeholder: '请输入相对值',
253
+ inputClassName: 'is-inline'
254
+ }),
255
+ getSchemaTpl('formulaControl', {
256
+ name: 'minDate',
257
+ label: tipedLabel('最小值', tipedLabelText),
258
+ placeholder: '请输入相对值',
259
+ inputClassName: 'is-inline'
260
+ }),
261
+ getSchemaTpl('formulaControl', {
262
+ name: 'maxDate',
263
+ label: tipedLabel('最大值', tipedLabelText),
264
+ placeholder: '请输入相对值',
265
+ inputClassName: 'is-inline'
266
+ }),
267
+ getSchemaTpl('formulaControl', {
268
+ name: 'minDuration',
269
+ label: tipedLabel('最小跨度', '例如 2days'),
270
+ placeholder: '请输入最小跨度',
271
+ inputClassName: 'is-inline'
272
+ }),
273
+ getSchemaTpl('formulaControl', {
274
+ name: 'maxDuration',
275
+ label: tipedLabel('最大跨度', '例如 1year'),
276
+ placeholder: '请输入最大跨度',
277
+ inputClassName: 'is-inline'
278
+ }),
279
+ getSchemaTpl('dateShortCutControl', {
280
+ mode: 'normal',
281
+ dropDownOption: {
282
+ 'yesterday': '昨天',
283
+ 'thisweek': '本周',
284
+ 'prevweek': '这个周',
285
+ '7daysago': '最近7天',
286
+ 'thismonth': '这个月',
287
+ 'prevmonth': '上个月',
288
+ 'thisquarter': '这个季度',
289
+ 'prevquarter': '上个季度',
290
+ 'thisyear': '今年'
291
+ }
292
+ }),
293
+ // getSchemaTpl('remark'),
294
+ // getSchemaTpl('labelRemark'),
295
+ {
296
+ type: 'input-text',
297
+ name: 'startPlaceholder',
298
+ label: '前占位提示',
299
+ pipeIn: defaultValue('开始时间')
300
+ },
301
+ {
302
+ type: 'input-text',
303
+ name: 'endPlaceholder',
304
+ label: '后占位提示',
305
+ pipeIn: defaultValue('结束时间')
306
+ }
307
+ ]
308
+ },
309
+ getSchemaTpl('status', {isFormItem: true}),
310
+ getSchemaTpl('validation', {
311
+ tag: ValidatorTag.Date
312
+ })
313
+ ])
314
+ },
315
+ {
316
+ title: '外观',
317
+ body: getSchemaTpl('collapseGroup', [
318
+ getSchemaTpl('style:formItem', renderer),
319
+ getSchemaTpl('style:classNames', [
320
+ getSchemaTpl('className', {
321
+ label: '描述',
322
+ name: 'descriptionClassName',
323
+ visibleOn: 'this.description'
324
+ }),
325
+ getSchemaTpl('className', {
326
+ name: 'addOn.className',
327
+ label: 'AddOn',
328
+ visibleOn: 'this.addOn && this.addOn.type === "text"'
329
+ })
330
+ ]),
331
+ getSchemaTpl('style:others', [
332
+ {
333
+ name: 'embed',
334
+ type: 'button-group-select',
335
+ size: 'md',
336
+ label: '模式',
337
+ mode: 'row',
338
+ value: false,
339
+ options: [
340
+ {
341
+ label: '浮层',
342
+ value: false
343
+ },
344
+ {
345
+ label: '内嵌',
346
+ value: true
347
+ }
348
+ ]
349
+ }
350
+ ])
351
+ ])
352
+ },
353
+ {
354
+ title: '事件',
355
+ className: 'p-none',
356
+ body: [
357
+ getSchemaTpl('eventControl', {
358
+ name: 'onEvent',
359
+ ...getEventControlConfig(this.manager, context)
360
+ })
361
+ ]
362
+ }
363
+ ]);
364
+ };
223
365
  }
224
366
 
225
367
  registerEditorPlugin(DateRangeControlPlugin);
@@ -1,27 +1,16 @@
1
- import {relativeValueRe} from 'amis';
2
- import {
3
- defaultValue,
4
- getSchemaTpl,
5
- valuePipeOut
6
- } from '../../component/schemaTpl';
7
1
  import {registerEditorPlugin} from '../../manager';
8
- import {
9
- BasePlugin,
10
- BasicSubRenderInfo,
11
- RendererEventContext,
12
- SubRendererInfo
13
- } from '../../plugin';
14
- import moment from 'moment';
15
2
 
16
- export class DateTimeControlPlugin extends BasePlugin {
3
+ import {DateControlPlugin} from './InputDate';
4
+
5
+ export class DateTimeControlPlugin extends DateControlPlugin {
17
6
  // 关联渲染器名字
18
7
  rendererName = 'input-datetime';
19
8
  $schema = '/schemas/DateTimeControlSchema.json';
20
9
 
21
10
  // 组件名称
11
+ isBaseComponent = true;
22
12
  icon = 'fa fa-calendar';
23
13
  name = '日期时间';
24
- isBaseComponent = true;
25
14
  description = '年月日时分选择';
26
15
  docLink = '/amis/zh-CN/components/form/input-datetime';
27
16
  tags = ['表单项'];
@@ -30,6 +19,8 @@ export class DateTimeControlPlugin extends BasePlugin {
30
19
  label: '日期时间',
31
20
  name: 'datetime'
32
21
  };
22
+
23
+ disabledRendererPlugin = true;
33
24
  previewSchema: any = {
34
25
  type: 'form',
35
26
  className: 'text-left',
@@ -43,141 +34,6 @@ export class DateTimeControlPlugin extends BasePlugin {
43
34
  };
44
35
 
45
36
  panelTitle = '日期时间';
46
- panelBody = [
47
- getSchemaTpl('placeholder', {
48
- pipeIn: defaultValue('请选择日期时间')
49
- }),
50
-
51
- {
52
- type: 'input-text',
53
- name: 'format',
54
- label: '值格式',
55
- description:
56
- '请参考 <a href="https://momentjs.com/" target="_blank">moment</a> 中的格式用法。',
57
- pipeIn: defaultValue('X'),
58
- onChange: (value: any, oldValue: any, model: any, form: any) => {
59
- form.setValueByName('value', '');
60
- form.setValueByName('minDate', '');
61
- form.setValueByName('maxDate', '');
62
- }
63
- },
64
-
65
- getSchemaTpl('switchDefaultValue'),
66
-
67
- {
68
- type: 'input-text',
69
- name: 'value',
70
- label: '默认值',
71
- visibleOn: 'typeof this.value !== "undefined"',
72
- placeholder: '请输入相对值',
73
- description: '支持 <code>now、+1day、-2weeks</code>这种相对值用法'
74
- },
75
-
76
- {
77
- type: 'fieldSet',
78
- title: '使用固定值',
79
- collapsed: true,
80
- collapsable: true,
81
- className: 'fieldset',
82
- visibleOn: 'typeof this.value !== "undefined"',
83
- body: [
84
- {
85
- type: 'input-datetime',
86
- name: 'value',
87
- pipeIn: (value: any) =>
88
- moment(
89
- relativeValueRe.test(value) || ~['now', 'today'].indexOf(value)
90
- ? ''
91
- : value
92
- ).format('X'),
93
- pipeOut: (value: any, old: any, data: any) => {
94
- return moment(parseInt(value, 10), 'X').format(data.format);
95
- }
96
- }
97
- ]
98
- },
99
-
100
- getSchemaTpl('clearable', {
101
- pipeIn: defaultValue(true)
102
- }),
103
-
104
- {
105
- type: 'input-text',
106
- name: 'inputFormat',
107
- label: '显示格式',
108
- description:
109
- '请参考 <a href="https://momentjs.com/" target="_blank">moment</a> 中的格式用法。',
110
- pipeIn: defaultValue('YYYY-MM-DD HH:mm')
111
- },
112
-
113
- {
114
- type: 'input-text',
115
- name: 'minDate',
116
- label: '最小日期',
117
- placeholder: '请输入相对值',
118
- description:
119
- '支持 <code>now、+1day、-2weeks</code>这种相对值用法,同时支持变量如<code>\\${start_date}</code>'
120
- },
121
-
122
- {
123
- type: 'fieldSet',
124
- title: '使用固定值',
125
- collapsed: true,
126
- collapsable: true,
127
- className: 'fieldset',
128
- body: [
129
- {
130
- type: 'input-date',
131
- name: 'minDate',
132
- pipeIn: (value: any) =>
133
- moment(
134
- relativeValueRe.test(value) || ~['now', 'today'].indexOf(value)
135
- ? ''
136
- : value
137
- ).format('X'),
138
- pipeOut: (value: any, old: any, data: any) => {
139
- return moment(parseInt(value, 10), 'X').format(data.format);
140
- }
141
- }
142
- ]
143
- },
144
-
145
- {
146
- type: 'divider'
147
- },
148
-
149
- {
150
- type: 'input-text',
151
- name: 'maxDate',
152
- label: '最大日期',
153
- placeholder: '请输入相对值',
154
- description:
155
- '支持 <code>now、+1day、-2weeks</code>这种相对值用法,同时支持变量如<code>\\${start_date}</code>'
156
- },
157
-
158
- {
159
- type: 'fieldSet',
160
- title: '使用固定值',
161
- collapsed: true,
162
- collapsable: true,
163
- className: 'fieldset',
164
- body: [
165
- {
166
- type: 'input-date',
167
- name: 'maxDate',
168
- pipeIn: (value: any) =>
169
- moment(
170
- relativeValueRe.test(value) || ~['now', 'today'].indexOf(value)
171
- ? ''
172
- : value
173
- ).format('X'),
174
- pipeOut: (value: any, old: any, data: any) => {
175
- return moment(parseInt(value, 10), 'X').format(data.format);
176
- }
177
- }
178
- ]
179
- }
180
- ];
181
37
  }
182
38
 
183
39
  registerEditorPlugin(DateTimeControlPlugin);