amis-editor 5.4.0 → 5.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. package/esm/component/TableViewEditor.d.ts +2 -2
  2. package/esm/locale/en-US.js +57 -1
  3. package/esm/locale/zh-CN.js +57 -1
  4. package/esm/plugin/CRUD.d.ts +3 -2
  5. package/esm/plugin/CRUD.js +157 -1
  6. package/esm/plugin/Dialog.d.ts +1 -1
  7. package/esm/plugin/Dialog.js +4 -4
  8. package/esm/plugin/Form/Combo.d.ts +5 -2
  9. package/esm/plugin/Form/Combo.js +34 -11
  10. package/esm/plugin/Form/Form.js +6 -2
  11. package/esm/plugin/Form/InputDateRange.js +4 -24
  12. package/esm/plugin/Form/InputRichText.d.ts +0 -1
  13. package/esm/plugin/Form/InputRichText.js +0 -1
  14. package/esm/plugin/Form/InputTable.d.ts +4 -1
  15. package/esm/plugin/Form/InputTable.js +100 -77
  16. package/esm/plugin/TableView.d.ts +2 -1
  17. package/esm/plugin/Tabs.d.ts +2 -1
  18. package/esm/renderer/APIAdaptorControl.d.ts +1 -1
  19. package/esm/renderer/APIControl.d.ts +4 -4
  20. package/esm/renderer/ActionApiControl.d.ts +3 -3
  21. package/esm/renderer/BadgeControl.d.ts +1 -1
  22. package/esm/renderer/ButtonGroupControl.d.ts +1 -1
  23. package/esm/renderer/ColumnControl.d.ts +1 -1
  24. package/esm/renderer/DataBindingControl.d.ts +2 -2
  25. package/esm/renderer/DataPickerControl.d.ts +1 -1
  26. package/esm/renderer/DateShortCutControl.d.ts +53 -29
  27. package/esm/renderer/DateShortCutControl.js +182 -140
  28. package/esm/renderer/ExpressionFormulaControl.d.ts +1 -1
  29. package/esm/renderer/FeatureControl.d.ts +2 -2
  30. package/esm/renderer/FlexSettingControl.d.ts +1 -1
  31. package/esm/renderer/FormulaControl.d.ts +8 -3
  32. package/esm/renderer/FormulaControl.js +76 -8
  33. package/esm/renderer/GoConfigControl.d.ts +1 -1
  34. package/esm/renderer/MapSourceControl.d.ts +3 -3
  35. package/esm/renderer/NavBadgeControl.d.ts +1 -1
  36. package/esm/renderer/NavSourceControl.d.ts +4 -4
  37. package/esm/renderer/OptionControl.d.ts +3 -3
  38. package/esm/renderer/RangePartsControl.d.ts +5 -5
  39. package/esm/renderer/StatusControl.d.ts +2 -2
  40. package/esm/renderer/SwitchMoreControl.d.ts +4 -4
  41. package/esm/renderer/TimelineItemControl.d.ts +4 -4
  42. package/esm/renderer/TplFormulaControl.d.ts +1 -1
  43. package/esm/renderer/TransferTableControl.d.ts +3 -3
  44. package/esm/renderer/TreeOptionControl.d.ts +3 -3
  45. package/esm/renderer/ValidationControl.d.ts +4 -4
  46. package/esm/renderer/ValidationItem.d.ts +3 -3
  47. package/esm/renderer/event-control/comp-action-select.d.ts +1 -1
  48. package/esm/renderer/event-control/index.d.ts +2 -2
  49. package/esm/renderer/style-control/Background.d.ts +1 -1
  50. package/esm/renderer/style-control/Border.d.ts +2 -2
  51. package/esm/renderer/style-control/BoxModel.d.ts +2 -2
  52. package/esm/renderer/style-control/BoxShadow.d.ts +2 -2
  53. package/esm/renderer/style-control/Display.d.ts +1 -1
  54. package/esm/renderer/style-control/Font.d.ts +1 -1
  55. package/esm/renderer/style-control/InsetBoxModel.d.ts +2 -2
  56. package/esm/renderer/style-control/ThemeCssCode.d.ts +1 -1
  57. package/esm/renderer/textarea-formula/TextareaFormulaControl.d.ts +1 -1
  58. package/esm/tpl/common.js +2 -1
  59. package/lib/component/TableViewEditor.d.ts +2 -2
  60. package/lib/locale/en-US.js +57 -1
  61. package/lib/locale/zh-CN.js +57 -1
  62. package/lib/plugin/CRUD.d.ts +3 -2
  63. package/lib/plugin/CRUD.js +157 -1
  64. package/lib/plugin/Dialog.d.ts +1 -1
  65. package/lib/plugin/Dialog.js +4 -4
  66. package/lib/plugin/Form/Combo.d.ts +5 -2
  67. package/lib/plugin/Form/Combo.js +32 -9
  68. package/lib/plugin/Form/Form.js +6 -2
  69. package/lib/plugin/Form/InputDateRange.js +4 -24
  70. package/lib/plugin/Form/InputRichText.d.ts +0 -1
  71. package/lib/plugin/Form/InputRichText.js +0 -1
  72. package/lib/plugin/Form/InputTable.d.ts +4 -1
  73. package/lib/plugin/Form/InputTable.js +99 -76
  74. package/lib/plugin/TableView.d.ts +2 -1
  75. package/lib/plugin/Tabs.d.ts +2 -1
  76. package/lib/renderer/APIAdaptorControl.d.ts +1 -1
  77. package/lib/renderer/APIControl.d.ts +4 -4
  78. package/lib/renderer/ActionApiControl.d.ts +3 -3
  79. package/lib/renderer/BadgeControl.d.ts +7 -7
  80. package/lib/renderer/ButtonGroupControl.d.ts +1 -1
  81. package/lib/renderer/ColumnControl.d.ts +1 -1
  82. package/lib/renderer/DataBindingControl.d.ts +2 -2
  83. package/lib/renderer/DataPickerControl.d.ts +1 -1
  84. package/lib/renderer/DateShortCutControl.d.ts +53 -29
  85. package/lib/renderer/DateShortCutControl.js +181 -139
  86. package/lib/renderer/ExpressionFormulaControl.d.ts +1 -1
  87. package/lib/renderer/FeatureControl.d.ts +2 -2
  88. package/lib/renderer/FlexSettingControl.d.ts +1 -1
  89. package/lib/renderer/FormulaControl.d.ts +8 -3
  90. package/lib/renderer/FormulaControl.js +76 -8
  91. package/lib/renderer/GoConfigControl.d.ts +1 -1
  92. package/lib/renderer/MapSourceControl.d.ts +3 -3
  93. package/lib/renderer/NavBadgeControl.d.ts +7 -7
  94. package/lib/renderer/NavSourceControl.d.ts +4 -4
  95. package/lib/renderer/OptionControl.d.ts +3 -3
  96. package/lib/renderer/RangePartsControl.d.ts +5 -5
  97. package/lib/renderer/StatusControl.d.ts +2 -2
  98. package/lib/renderer/SwitchMoreControl.d.ts +4 -4
  99. package/lib/renderer/TimelineItemControl.d.ts +4 -4
  100. package/lib/renderer/TplFormulaControl.d.ts +1 -1
  101. package/lib/renderer/TransferTableControl.d.ts +3 -3
  102. package/lib/renderer/TreeOptionControl.d.ts +3 -3
  103. package/lib/renderer/ValidationControl.d.ts +4 -4
  104. package/lib/renderer/ValidationItem.d.ts +3 -3
  105. package/lib/renderer/event-control/comp-action-select.d.ts +1 -1
  106. package/lib/renderer/event-control/index.d.ts +2 -2
  107. package/lib/renderer/style-control/Background.d.ts +1 -1
  108. package/lib/renderer/style-control/Border.d.ts +2 -2
  109. package/lib/renderer/style-control/BoxModel.d.ts +2 -2
  110. package/lib/renderer/style-control/BoxShadow.d.ts +2 -2
  111. package/lib/renderer/style-control/Display.d.ts +1 -1
  112. package/lib/renderer/style-control/Font.d.ts +1 -1
  113. package/lib/renderer/style-control/InsetBoxModel.d.ts +2 -2
  114. package/lib/renderer/style-control/ThemeCssCode.d.ts +1 -1
  115. package/lib/renderer/textarea-formula/TextareaFormulaControl.d.ts +1 -1
  116. package/lib/tpl/common.js +2 -1
  117. package/package.json +2 -2
@@ -3,40 +3,68 @@
3
3
  */
4
4
  import React from 'react';
5
5
  import Sortable from 'sortablejs';
6
- import type { FormControlProps } from 'amis-core';
7
- import type { BaseEventContext } from 'amis-editor-core';
8
- import type { Option } from 'amis';
9
- type $Object = {
10
- [key: string]: string;
6
+ import { FormControlProps, Option } from 'amis-core';
7
+ import { BaseEventContext } from 'amis-editor-core';
8
+ declare const CertainPresetShorcut: {
9
+ today: string;
10
+ yesterday: string;
11
+ thisweek: string;
12
+ prevweek: string;
13
+ thismonth: string;
14
+ prevmonth: string;
15
+ thisquarter: string;
16
+ prevquarter: string;
17
+ thisyear: string;
18
+ };
19
+ declare const ModifyPresetShorcut: {
20
+ $daysago: string;
21
+ $dayslater: string;
22
+ $weeksago: string;
23
+ $weekslater: string;
24
+ $monthsago: string;
25
+ $monthslater: string;
26
+ $quartersago: string;
27
+ $quarterslater: string;
28
+ $yearsago: string;
29
+ $yearslater: string;
11
30
  };
12
- declare enum RangeType {
13
- Normal = "Normal",
14
- Custom = "Custom"
15
- }
16
31
  export interface DateShortCutControlProps extends FormControlProps {
17
32
  className?: string;
18
33
  /**
19
34
  * 编辑器上下文数据,用于获取字段所在Form的其他字段
20
35
  */
21
36
  context: BaseEventContext;
22
- normalDropDownOption: $Object;
23
- customDropDownOption: $Object;
37
+ certainOptions: Array<keyof typeof CertainPresetShorcut>;
38
+ modifyOptions: Array<keyof typeof ModifyPresetShorcut>;
24
39
  }
25
- interface OptionsType {
26
- label?: string;
40
+ type PresetShorCutType = string;
41
+ type CustomShortCutType = {
42
+ label: string;
43
+ startDate: string;
44
+ endDate: string;
45
+ };
46
+ type ModifyOptionType = {
47
+ key: keyof typeof ModifyPresetShorcut;
27
48
  value: string;
28
- type: RangeType;
29
- inputType?: string;
49
+ };
50
+ declare enum OptionType {
51
+ Custom = 1,
52
+ Certain = 2,
53
+ Modify = 3
54
+ }
55
+ interface OptionDataType {
56
+ data: PresetShorCutType | CustomShortCutType | ModifyOptionType;
57
+ type?: OptionType;
30
58
  }
31
59
  interface DateShortCutControlState {
32
- options: Array<OptionsType>;
60
+ options: Array<OptionDataType>;
33
61
  }
34
62
  export declare class DateShortCutControl extends React.PureComponent<DateShortCutControlProps, DateShortCutControlState> {
35
63
  sortable?: Sortable;
36
64
  drag?: HTMLElement | null;
37
65
  target: HTMLElement | null;
38
- normalDropDownOptionArr: Array<Option>;
39
- customDropDownOptionArr: Array<Option>;
66
+ certainDropDownOptions: Array<Option>;
67
+ modifyDropDownOptions: Array<Option>;
40
68
  static defaultProps: Partial<DateShortCutControlProps>;
41
69
  constructor(props: DateShortCutControlProps);
42
70
  dragRef(ref: any): void;
@@ -50,25 +78,21 @@ export declare class DateShortCutControl extends React.PureComponent<DateShortCu
50
78
  */
51
79
  destroyDragging(): void;
52
80
  /**
53
- * 生成内容体
54
- */
55
- renderContent(): JSX.Element;
56
- /**
57
- * 生成固定跨度选项
81
+ * 生成快捷键项的配置
58
82
  */
59
- renderNormalOption(option: OptionsType, index: number): JSX.Element;
83
+ renderOption(option: OptionDataType, index: number): any;
60
84
  /**
61
- * 生成自定义跨度选项
85
+ * 生成内容体
62
86
  */
63
- renderCustomOption(option: OptionsType, index: number): JSX.Element;
87
+ renderContent(): React.JSX.Element;
64
88
  /**
65
89
  * 自定义跨度变化
66
90
  */
67
- handleCustomItemChange(value: string, index: number): void;
91
+ handleOptionChange(data: string | CustomShortCutType | ModifyOptionType, index: number): void;
68
92
  /**
69
93
  * option添加
70
94
  */
71
- addItem(item: Option, type: RangeType): void;
95
+ addItem(item: Option, type: OptionType): void;
72
96
  /**
73
97
  * 删除选项
74
98
  */
@@ -77,7 +101,7 @@ export declare class DateShortCutControl extends React.PureComponent<DateShortCu
77
101
  * 更新options字段的统一出口
78
102
  */
79
103
  onChangeOptions(): void;
80
- render(): JSX.Element;
104
+ render(): React.JSX.Element;
81
105
  }
82
106
  export declare class DateShortCutControlRender extends DateShortCutControl {
83
107
  }
@@ -14,6 +14,7 @@ var Sortable = require('sortablejs');
14
14
  var reactDom = require('react-dom');
15
15
  var amis = require('amis');
16
16
  var amisEditorCore = require('amis-editor-core');
17
+ var FormulaControl = require('./FormulaControl.js');
17
18
  var i18nRuntime = require('i18n-runtime');
18
19
 
19
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -22,11 +23,36 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
23
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
23
24
  var Sortable__default = /*#__PURE__*/_interopDefaultLegacy(Sortable);
24
25
 
25
- var RangeType;
26
- (function (RangeType) {
27
- RangeType["Normal"] = "Normal";
28
- RangeType["Custom"] = "Custom";
29
- })(RangeType || (RangeType = {}));
26
+ var DefaultValue = ['yesterday', '7daysago', 'thismonth', 'prevmonth', 'prevquarter'];
27
+ var CertainPresetShorcut = {
28
+ today: i18nRuntime.i18n("800dfdd90200bd47bb4bb83def4fea56"),
29
+ yesterday: i18nRuntime.i18n("2f8d6f1584b73bfc6dada44526abb502"),
30
+ thisweek: i18nRuntime.i18n("0dc86a275145ad5a7774e594f0d94a06"),
31
+ prevweek: i18nRuntime.i18n("79abd4ee3661ff70c7d79716c8aaed83"),
32
+ thismonth: i18nRuntime.i18n("8f2a5a5f6e3777c7a0e1ce9484a2f7d7"),
33
+ prevmonth: i18nRuntime.i18n("d5578d93388a5b2552316418cd1124da"),
34
+ thisquarter: i18nRuntime.i18n("ffb2b7fbf227d9d21e03d0f160fb2a34"),
35
+ prevquarter: i18nRuntime.i18n("dd657784cc0d5511d2f25459e49ead1a"),
36
+ thisyear: i18nRuntime.i18n("d3dbc7a7fd9fc5ccd168084c8579c1ec")
37
+ };
38
+ var ModifyPresetShorcut = {
39
+ $daysago: i18nRuntime.i18n("fd312ae2f1c24b8a14d9412bb3c6bb76"),
40
+ $dayslater: i18nRuntime.i18n("68cba5f27ab003cfada5eb4c1f29eb21"),
41
+ $weeksago: i18nRuntime.i18n("34b06708894a178c440e6f6539e95e9e"),
42
+ $weekslater: i18nRuntime.i18n("f0e1b8d8a6e731360d7348bc8301d44a"),
43
+ $monthsago: i18nRuntime.i18n("5cad2778bb8f01d1a1b1226082eb2117"),
44
+ $monthslater: i18nRuntime.i18n("ff76f60b3da86a0d2c6663b170a7955a"),
45
+ $quartersago: i18nRuntime.i18n("9ff9b56c9ed633ee09396830e93113ad"),
46
+ $quarterslater: i18nRuntime.i18n("2b80b20008b3ae81136217ae10a1fbaf"),
47
+ $yearsago: i18nRuntime.i18n("84752114d27119dc50d8a7b9ac0b788b"),
48
+ $yearslater: i18nRuntime.i18n("5df2352afebd73d1f568ebaa81e2db28")
49
+ };
50
+ var OptionType;
51
+ (function (OptionType) {
52
+ OptionType[OptionType["Custom"] = 1] = "Custom";
53
+ OptionType[OptionType["Certain"] = 2] = "Certain";
54
+ OptionType[OptionType["Modify"] = 3] = "Modify";
55
+ })(OptionType || (OptionType = {}));
30
56
  var ShortCutItemWrap = function (props) {
31
57
  return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("a", {
32
58
  className: klass + 'Item-dragBar'
@@ -52,40 +78,55 @@ var DateShortCutControl = /** @class */function (_super) {
52
78
  var _this = this;
53
79
  var _a, _b;
54
80
  _this = _super.call(this, props) || this;
55
- var normalDropDownOption = props.normalDropDownOption,
56
- customDropDownOption = props.customDropDownOption,
81
+ // 初始化下拉选项
82
+ var certainOptions = props.certainOptions,
83
+ modifyOptions = props.modifyOptions,
57
84
  data = props.data;
58
- _this.normalDropDownOptionArr = Object.keys(normalDropDownOption).map(function (key) {
85
+ _this.certainDropDownOptions = certainOptions.map(function (key) {
59
86
  return {
60
- label: normalDropDownOption[key],
87
+ label: CertainPresetShorcut[key],
61
88
  value: key
62
89
  };
63
90
  });
64
- _this.customDropDownOptionArr = Object.keys(customDropDownOption).map(function (key) {
91
+ _this.modifyDropDownOptions = modifyOptions.map(function (key) {
65
92
  return {
66
- label: customDropDownOption[key],
93
+ label: ModifyPresetShorcut[key],
67
94
  value: key
68
95
  };
69
96
  });
70
- var defaultShortcuts = ['yesterday', '7daysago', 'prevweek', 'thismonth', 'prevmonth', 'prevquarter'];
97
+ // 初始化原始组件配置的快捷键
98
+ /** amis 3.1.0之后ranges属性废弃,此处兼容 */
99
+ var initData = (_b = (_a = data === null || data === void 0 ? void 0 : data.ranges) !== null && _a !== void 0 ? _a : data === null || data === void 0 ? void 0 : data.shortcuts) !== null && _b !== void 0 ? _b : DefaultValue;
100
+ initData = Array.isArray(initData) ? initData : initData.split(',');
71
101
  _this.state = {
72
- /** amis 3.1.0之后ranges属性废弃,此处兼容 */
73
- options: ((_b = (_a = data === null || data === void 0 ? void 0 : data.ranges) !== null && _a !== void 0 ? _a : data === null || data === void 0 ? void 0 : data.shortcuts) !== null && _b !== void 0 ? _b : defaultShortcuts).map(function (item, index) {
74
- var _a;
75
- var arr = item.match(/^(\d+)[a-zA-Z]+/);
102
+ options: initData.map(function (item) {
103
+ if (!item) {
104
+ return null;
105
+ }
106
+ // 完全自定义的快捷键
107
+ if (typeof item != 'string' && item.label && item.startDate && item.endDate) {
108
+ return {
109
+ type: OptionType.Custom,
110
+ data: item
111
+ };
112
+ }
113
+ // amis中提供的可灵活配置数字的自定义快捷键
114
+ var arr = item.match(/^([a-zA-Z]*)(\d+)([a-zA-Z]*)$/);
76
115
  if (arr) {
77
116
  return {
78
- value: arr[1],
79
- type: RangeType.Custom,
80
- inputType: (_a = item.match(/[a-zA-Z]+/)) === null || _a === void 0 ? void 0 : _a[0]
117
+ data: {
118
+ value: arr[2],
119
+ key: "".concat(arr[1], "$").concat(arr[3])
120
+ },
121
+ type: OptionType.Modify
81
122
  };
82
123
  }
124
+ // 固定值的快捷键
83
125
  return {
84
- label: normalDropDownOption[item],
85
- value: item,
86
- type: RangeType.Normal
126
+ data: item,
127
+ type: OptionType.Certain
87
128
  };
88
- })
129
+ }).filter(Boolean)
89
130
  };
90
131
  return _this;
91
132
  }
@@ -149,6 +190,77 @@ var DateShortCutControl = /** @class */function (_super) {
149
190
  DateShortCutControl.prototype.destroyDragging = function () {
150
191
  this.sortable && this.sortable.destroy();
151
192
  };
193
+ /**
194
+ * 生成快捷键项的配置
195
+ */
196
+ DateShortCutControl.prototype.renderOption = function (option, index) {
197
+ var _this = this;
198
+ var _a = this.props,
199
+ render = _a.render,
200
+ schema = _a.data;
201
+ if (option.type === OptionType.Certain) {
202
+ return React__default["default"].createElement("span", {
203
+ className: klass + 'Item-content-label'
204
+ }, CertainPresetShorcut[option.data]);
205
+ }
206
+ if (option.type === OptionType.Custom) {
207
+ var data = option === null || option === void 0 ? void 0 : option.data;
208
+ return render('inner', {
209
+ type: 'form',
210
+ wrapWithPanel: false,
211
+ body: [{
212
+ type: 'input-text',
213
+ mode: 'normal',
214
+ placeholder: i18nRuntime.i18n("a6a93b404bc039cded728683af5d625d"),
215
+ name: 'label'
216
+ }, amisEditorCore.getSchemaTpl('valueFormula', {
217
+ name: 'startDate',
218
+ header: i18nRuntime.i18n("98229308e2e9484583fde4ae363a979f"),
219
+ DateTimeType: FormulaControl.FormulaDateType.IsDate,
220
+ rendererSchema: tslib.__assign(tslib.__assign({}, schema), {
221
+ type: 'input-date'
222
+ }),
223
+ placeholder: i18nRuntime.i18n("592c59589144ddc68d05d528da17dcdc"),
224
+ needDeleteProps: ['ranges', 'shortcuts', 'maxDate', 'id', 'minDuration'],
225
+ label: false
226
+ }), amisEditorCore.getSchemaTpl('valueFormula', {
227
+ name: 'endDate',
228
+ header: i18nRuntime.i18n("98229308e2e9484583fde4ae363a979f"),
229
+ DateTimeType: FormulaControl.FormulaDateType.IsDate,
230
+ rendererSchema: tslib.__assign(tslib.__assign({}, schema), {
231
+ type: 'input-date'
232
+ }),
233
+ placeholder: i18nRuntime.i18n("f782779e8b5d709462c8e71e0d9019f2"),
234
+ needDeleteProps: ['ranges', 'shortcuts', 'maxDate', 'id', 'minDuration'],
235
+ label: false
236
+ })],
237
+ onChange: function (value) {
238
+ _this.handleOptionChange(value, index);
239
+ }
240
+ }, {
241
+ data: data
242
+ });
243
+ }
244
+ var key = option.data.key;
245
+ var label = ModifyPresetShorcut[key].split('n');
246
+ return render('inner', {
247
+ type: 'form',
248
+ wrapWithPanel: false,
249
+ body: [{
250
+ name: 'value',
251
+ type: 'input-text',
252
+ prefix: label[0] || undefined,
253
+ suffix: label[1] || undefined,
254
+ mode: 'normal',
255
+ placeholder: 'n'
256
+ }],
257
+ onChange: function (value) {
258
+ return _this.handleOptionChange(value, index);
259
+ }
260
+ }, {
261
+ data: option.data
262
+ });
263
+ };
152
264
  /**
153
265
  * 生成内容体
154
266
  */
@@ -164,112 +276,21 @@ var DateShortCutControl = /** @class */function (_super) {
164
276
  return React__default["default"].createElement("li", {
165
277
  className: klass + 'Item',
166
278
  key: index
167
- }, option.type === RangeType.Normal ? _this.renderNormalOption(option, index) : _this.renderCustomOption(option, index));
279
+ }, React__default["default"].createElement(ShortCutItemWrap, {
280
+ index: index,
281
+ handleDelete: _this.handleDelete
282
+ }, _this.renderOption(option, index)));
168
283
  })) : React__default["default"].createElement("div", {
169
284
  className: klass + '-content ' + klass + '-empty'
170
285
  }, "\u672A\u914D\u7F6E"));
171
286
  };
172
- /**
173
- * 生成固定跨度选项
174
- */
175
- DateShortCutControl.prototype.renderNormalOption = function (option, index) {
176
- return React__default["default"].createElement(ShortCutItemWrap, {
177
- index: index,
178
- handleDelete: this.handleDelete
179
- }, React__default["default"].createElement("span", null, option.label));
180
- };
181
- /**
182
- * 生成自定义跨度选项
183
- */
184
- DateShortCutControl.prototype.renderCustomOption = function (option, index) {
185
- var _this = this;
186
- var render = this.props.render;
187
- var renderInput = function (option) {
188
- if (option.type === 'middle') {
189
- return render('inner', {
190
- type: 'input-text',
191
- prefix: option === null || option === void 0 ? void 0 : option.prefix,
192
- suffix: option.suffix,
193
- mode: 'normal',
194
- placeholder: 'n',
195
- value: option === null || option === void 0 ? void 0 : option.value,
196
- onChange: function (value) {
197
- return _this.handleCustomItemChange(value, index);
198
- }
199
- });
200
- }
201
- return render('inner', {
202
- type: 'input-text',
203
- placeholder: 'n',
204
- mode: 'normal',
205
- suffix: option.suffix,
206
- value: option === null || option === void 0 ? void 0 : option.value,
207
- onChange: function (value) {
208
- return _this.handleCustomItemChange(value, index);
209
- }
210
- });
211
- };
212
- var dateMap = {
213
- daysago: {
214
- prefix: i18nRuntime.i18n("046c6233e03af774df7b90b4504fa96c"),
215
- suffix: i18nRuntime.i18n("249aba763258bbe488af3e79a381d265"),
216
- type: 'middle'
217
- },
218
- dayslater: {
219
- suffix: i18nRuntime.i18n("2f8ab07bea442bc6ce8a9e99ff88e5c1"),
220
- type: 'suffix'
221
- },
222
- weeksago: {
223
- prefix: i18nRuntime.i18n("046c6233e03af774df7b90b4504fa96c"),
224
- suffix: i18nRuntime.i18n("a657f46f5bb00961adfae80d12e41b3d"),
225
- type: 'middle'
226
- },
227
- weekslater: {
228
- suffix: i18nRuntime.i18n("b1599eaa05dc9b3d90be5aebc5c84338"),
229
- type: 'suffix'
230
- },
231
- monthsago: {
232
- prefix: i18nRuntime.i18n("046c6233e03af774df7b90b4504fa96c"),
233
- suffix: i18nRuntime.i18n("e42b99d59954ce6437e66f416850425a"),
234
- type: 'middle'
235
- },
236
- monthslater: {
237
- suffix: i18nRuntime.i18n("3c690347976de82df1909750cbc82b80"),
238
- type: 'suffix'
239
- },
240
- quartersago: {
241
- prefix: i18nRuntime.i18n("046c6233e03af774df7b90b4504fa96c"),
242
- suffix: i18nRuntime.i18n("a483bccf85587055ab31314ad1d2f82a"),
243
- type: 'middle'
244
- },
245
- quarterslater: {
246
- suffix: i18nRuntime.i18n("b62ba98a627851e911bef8fbb005bd4a"),
247
- type: 'suffix'
248
- },
249
- yearsago: {
250
- prefix: i18nRuntime.i18n("046c6233e03af774df7b90b4504fa96c"),
251
- suffix: i18nRuntime.i18n("465260fe80b0c3338d06194bb7a94446"),
252
- type: 'middle'
253
- },
254
- yearslater: {
255
- suffix: i18nRuntime.i18n("137bcb84f52bbd48623c37d8dfdebdff"),
256
- type: 'suffix'
257
- }
258
- };
259
- return React__default["default"].createElement(ShortCutItemWrap, {
260
- index: index,
261
- handleDelete: this.handleDelete
262
- }, option.inputType ? renderInput(tslib.__assign(tslib.__assign({}, dateMap[option.inputType]), {
263
- value: option.value
264
- })) : null);
265
- };
266
287
  /**
267
288
  * 自定义跨度变化
268
289
  */
269
- DateShortCutControl.prototype.handleCustomItemChange = function (value, index) {
290
+ DateShortCutControl.prototype.handleOptionChange = function (data, index) {
270
291
  var _this = this;
271
292
  var options = tslib.__spreadArray([], tslib.__read(this.state.options), false);
272
- options[index].value = value;
293
+ options[index].data = data;
273
294
  this.setState({
274
295
  options: options
275
296
  }, function () {
@@ -281,15 +302,18 @@ var DateShortCutControl = /** @class */function (_super) {
281
302
  */
282
303
  DateShortCutControl.prototype.addItem = function (item, type) {
283
304
  var _this = this;
284
- var _a;
285
305
  this.setState({
286
- options: tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(this.state.options), false), [tslib.__assign({
287
- label: (_a = item === null || item === void 0 ? void 0 : item.label) !== null && _a !== void 0 ? _a : '',
306
+ options: this.state.options.concat({
288
307
  type: type,
289
- value: type === RangeType.Normal ? item.value : ''
290
- }, type === RangeType.Normal ? {} : {
291
- inputType: item.value
292
- })], false)
308
+ data: type === OptionType.Certain ? item.value : type === OptionType.Modify ? {
309
+ key: item.value,
310
+ value: undefined
311
+ } : {
312
+ label: undefined,
313
+ startDate: undefined,
314
+ endDate: undefined
315
+ }
316
+ })
293
317
  }, function () {
294
318
  _this.onChangeOptions();
295
319
  _this.scrollToBottom();
@@ -317,17 +341,23 @@ var DateShortCutControl = /** @class */function (_super) {
317
341
  var _b = this.props,
318
342
  onBulkChange = _b.onBulkChange,
319
343
  name = _b.name;
320
- var newOptions = [];
321
- options.forEach(function (item, index) {
322
- if (item.type === RangeType.Normal) {
323
- newOptions[index] = item.value;
344
+ var newRanges = [];
345
+ options.forEach(function (item) {
346
+ if (item.type === OptionType.Certain) {
347
+ newRanges.push(item.data);
324
348
  }
325
- if (item.type === RangeType.Custom && item.value) {
326
- newOptions[index] = "".concat(item.value).concat(item.inputType);
349
+ if (item.type === OptionType.Modify) {
350
+ var data = item.data;
351
+ var value = data.value;
352
+ /^\d+$/.test(value) && newRanges.push(data.key.replace('$', value));
353
+ }
354
+ if (item.type === OptionType.Custom) {
355
+ var data = item.data;
356
+ data.label && data.startDate && data.endDate && newRanges.push(tslib.__assign({}, data));
327
357
  }
328
358
  });
329
359
  /** amis 3.1.0之后ranges属性废弃 */
330
- onBulkChange && onBulkChange((_a = {}, _a[name !== null && name !== void 0 ? name : 'shortcuts'] = newOptions, _a.ranges = undefined, _a));
360
+ onBulkChange && onBulkChange((_a = {}, _a[name !== null && name !== void 0 ? name : 'shortcuts'] = newRanges, _a.ranges = undefined, _a));
331
361
  };
332
362
  DateShortCutControl.prototype.render = function () {
333
363
  var _this = this;
@@ -349,11 +379,11 @@ var DateShortCutControl = /** @class */function (_super) {
349
379
  closeOnClick: true,
350
380
  closeOnOutside: true,
351
381
  level: 'enhance',
352
- buttons: this.normalDropDownOptionArr.map(function (item) {
382
+ buttons: this.certainDropDownOptions.map(function (item) {
353
383
  return tslib.__assign(tslib.__assign({}, item), {
354
384
  type: 'button',
355
385
  onAction: function (e, action) {
356
- return _this.addItem(item, RangeType.Normal);
386
+ return _this.addItem(item, OptionType.Certain);
357
387
  }
358
388
  });
359
389
  })
@@ -366,14 +396,26 @@ var DateShortCutControl = /** @class */function (_super) {
366
396
  label: i18nRuntime.i18n("7a1e5f93e362d371519bcb2bfdb0fc9a"),
367
397
  closeOnClick: true,
368
398
  closeOnOutside: true,
369
- buttons: this.customDropDownOptionArr.map(function (item) {
399
+ buttons: this.modifyDropDownOptions.map(function (item) {
370
400
  return tslib.__assign(tslib.__assign({}, item), {
371
401
  type: 'button',
372
402
  onAction: function (e, action) {
373
- return _this.addItem(item, RangeType.Custom);
403
+ return _this.addItem(item, OptionType.Modify);
374
404
  }
375
405
  });
376
- })
406
+ }).concat([{
407
+ type: 'button',
408
+ label: i18nRuntime.i18n("0d98c74797e49d00bcc4c17c9d557a2b"),
409
+ onAction: function (e, action) {
410
+ return _this.addItem({
411
+ value: {
412
+ label: undefined,
413
+ startDate: undefined,
414
+ endData: undefined
415
+ }
416
+ }, OptionType.Custom);
417
+ }
418
+ }])
377
419
  }, {
378
420
  popOverContainer: null
379
421
  }))));
@@ -40,7 +40,7 @@ export default class ExpressionFormulaControl extends React.Component<Expression
40
40
  initFormulaPickerValue(value: string): void;
41
41
  handleConfirm(value?: string): void;
42
42
  handleClearExpression(e: React.MouseEvent<HTMLElement>): void;
43
- render(): JSX.Element;
43
+ render(): React.JSX.Element;
44
44
  }
45
45
  export declare class ExpressionFormulaControlRenderer extends ExpressionFormulaControl {
46
46
  }
@@ -55,9 +55,9 @@ export default class FeatureControl extends React.Component<FeatureControlProps,
55
55
  * 拖动的销毁
56
56
  */
57
57
  destroyDragging(): void;
58
- renderItem(item: FeatureOption, index: number): JSX.Element;
58
+ renderItem(item: FeatureOption, index: number): React.JSX.Element;
59
59
  renderAction(): any;
60
- render(): JSX.Element;
60
+ render(): React.JSX.Element;
61
61
  }
62
62
  export declare class FeatureControlRenderer extends FeatureControl {
63
63
  }
@@ -13,7 +13,7 @@ interface FlexSettingControlProps extends FormControlProps {
13
13
  export default class FlexSettingControl extends React.Component<FlexSettingControlProps> {
14
14
  constructor(props: any);
15
15
  setField(field: string): (val: string) => void;
16
- render(): JSX.Element;
16
+ render(): React.JSX.Element;
17
17
  }
18
18
  export declare class FlexSettingControlRenderer extends FlexSettingControl {
19
19
  }
@@ -12,7 +12,7 @@ export declare enum FormulaDateType {
12
12
  IsDate = 1,
13
13
  IsRange = 2
14
14
  }
15
- export declare function renderFormulaValue(item: any): JSX.Element;
15
+ export declare function renderFormulaValue(item: any): React.JSX.Element;
16
16
  export interface FormulaControlProps extends FormControlProps {
17
17
  manager?: EditorManager;
18
18
  /**
@@ -94,6 +94,7 @@ interface FormulaControlState {
94
94
  variables: any;
95
95
  variableMode?: 'tree' | 'tabs';
96
96
  formulaPickerOpen: boolean;
97
+ loading: boolean;
97
98
  }
98
99
  export default class FormulaControl extends React.Component<FormulaControlProps, FormulaControlState> {
99
100
  static defaultProps: Partial<FormulaControlProps>;
@@ -118,13 +119,17 @@ export default class FormulaControl extends React.Component<FormulaControlProps,
118
119
  hasDateShortcutkey(str: string): boolean;
119
120
  transExpr(str: string): string;
120
121
  handleConfirm(value: any): void;
121
- handleFormulaClick(): void;
122
+ /**
123
+ * 公式编辑器打开完成一些异步任务的加载
124
+ */
125
+ beforeFormulaEditorOpen(): Promise<void>;
126
+ handleFormulaClick(): Promise<void>;
122
127
  closeFormulaPicker(): void;
123
128
  handleSimpleInputChange: (value: any) => void;
124
129
  handleInputChange: (value: any) => void;
125
130
  filterCustomRendererProps(rendererSchema: any): any;
126
131
  getContextData(): any;
127
- render(): JSX.Element;
132
+ render(): React.JSX.Element;
128
133
  }
129
134
  export declare class FormulaControlRenderer extends FormulaControl {
130
135
  }