amis 1.5.3 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +5 -0
  2. package/lib/components/Card.d.ts +96 -0
  3. package/lib/components/Card.js +85 -0
  4. package/lib/components/Card.js.map +13 -0
  5. package/lib/components/DatePicker.d.ts +85 -84
  6. package/lib/components/DatePicker.js.map +2 -2
  7. package/lib/components/DateRangePicker.d.ts +84 -84
  8. package/lib/components/MonthRangePicker.d.ts +84 -84
  9. package/lib/components/Picker.d.ts +503 -0
  10. package/lib/components/Picker.js +65 -0
  11. package/lib/components/Picker.js.map +13 -0
  12. package/lib/components/PickerColumn.d.ts +29 -459
  13. package/lib/components/PickerColumn.js +35 -44
  14. package/lib/components/PickerColumn.js.map +2 -2
  15. package/lib/components/Select.d.ts +238 -238
  16. package/lib/components/Select.js +9 -2
  17. package/lib/components/Select.js.map +2 -2
  18. package/lib/components/Selection.js +1 -4
  19. package/lib/components/Selection.js.map +2 -2
  20. package/lib/components/Switch.d.ts +6 -6
  21. package/lib/components/Switch.js.map +2 -2
  22. package/lib/components/calendar/Calendar.js +15 -0
  23. package/lib/components/calendar/Calendar.js.map +2 -2
  24. package/lib/components/calendar/DaysView.js +4 -4
  25. package/lib/components/calendar/DaysView.js.map +2 -2
  26. package/lib/components/calendar/TimeView.d.ts +10 -0
  27. package/lib/components/calendar/TimeView.js +55 -2
  28. package/lib/components/calendar/TimeView.js.map +2 -2
  29. package/lib/components/calendar/YearsView.d.ts +9 -0
  30. package/lib/components/calendar/YearsView.js +19 -0
  31. package/lib/components/calendar/YearsView.js.map +2 -2
  32. package/lib/index.js +1 -1
  33. package/lib/renderers/Card.d.ts +81 -13
  34. package/lib/renderers/Card.js +178 -81
  35. package/lib/renderers/Card.js.map +2 -2
  36. package/lib/renderers/Form/DiffEditor.d.ts +145 -37
  37. package/lib/renderers/Form/Editor.d.ts +144 -36
  38. package/lib/renderers/Form/Formula.js +5 -5
  39. package/lib/renderers/Form/Formula.js.map +2 -2
  40. package/lib/renderers/Form/InputCity.d.ts +84 -84
  41. package/lib/renderers/Form/InputFile.js +2 -2
  42. package/lib/renderers/Form/InputFile.js.map +2 -2
  43. package/lib/renderers/Form/index.js +10 -0
  44. package/lib/renderers/Form/index.js.map +2 -2
  45. package/lib/renderers/Form/wrapControl.js +3 -2
  46. package/lib/renderers/Form/wrapControl.js.map +2 -2
  47. package/lib/store/combo.d.ts +160 -40
  48. package/lib/store/form.d.ts +64 -16
  49. package/lib/store/formItem.d.ts +4 -2
  50. package/lib/store/formItem.js +11 -6
  51. package/lib/store/formItem.js.map +2 -2
  52. package/lib/store/table.d.ts +128 -32
  53. package/lib/themes/ang-ie11.css +177 -30
  54. package/lib/themes/ang.css +177 -30
  55. package/lib/themes/ang.css.map +1 -1
  56. package/lib/themes/antd-ie11.css +177 -30
  57. package/lib/themes/antd.css +177 -30
  58. package/lib/themes/antd.css.map +1 -1
  59. package/lib/themes/cxd-ie11.css +177 -30
  60. package/lib/themes/cxd.css +177 -30
  61. package/lib/themes/cxd.css.map +1 -1
  62. package/lib/themes/dark-ie11.css +177 -30
  63. package/lib/themes/dark.css +177 -30
  64. package/lib/themes/dark.css.map +1 -1
  65. package/lib/themes/default.css +177 -30
  66. package/lib/themes/default.css.map +1 -1
  67. package/lib/utils/helper.d.ts +7 -0
  68. package/lib/utils/helper.js +33 -1
  69. package/lib/utils/helper.js.map +2 -2
  70. package/package.json +2 -2
  71. package/schema.json +157 -13
  72. package/scss/_properties.scss +13 -2
  73. package/scss/components/_card.scss +155 -15
  74. package/scss/components/_nav.scss +1 -1
  75. package/scss/components/_picker-columns.scss +20 -14
  76. package/scss/components/form/_file.scss +2 -2
  77. package/scss/components/form/_selection.scss +4 -0
  78. package/scss/components/form/_switch.scss +6 -0
  79. package/sdk/ang-ie11.css +214 -40
  80. package/sdk/ang.css +216 -32
  81. package/sdk/antd-ie11.css +214 -40
  82. package/sdk/antd.css +216 -32
  83. package/sdk/charts.js +14 -14
  84. package/sdk/color-picker.js +65 -65
  85. package/sdk/cropperjs.js +2 -2
  86. package/sdk/cxd-ie11.css +206 -32
  87. package/sdk/cxd.css +216 -32
  88. package/sdk/dark-ie11.css +214 -40
  89. package/sdk/dark.css +216 -32
  90. package/sdk/exceljs.js +1 -1
  91. package/sdk/markdown.js +69 -69
  92. package/sdk/papaparse.js +1 -1
  93. package/sdk/renderers/Form/CityDB.js +1 -1
  94. package/sdk/rest.js +18 -18
  95. package/sdk/rich-text.js +62 -62
  96. package/sdk/sdk-ie11.css +206 -32
  97. package/sdk/sdk.css +216 -32
  98. package/sdk/sdk.js +1190 -1186
  99. package/sdk/thirds/hls.js/hls.js +1 -1
  100. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  101. package/sdk/tinymce.js +57 -57
  102. package/src/components/Card.tsx +203 -0
  103. package/src/components/DatePicker.tsx +3 -0
  104. package/src/components/Picker.tsx +145 -0
  105. package/src/components/PickerColumn.tsx +58 -95
  106. package/src/components/Select.tsx +17 -12
  107. package/src/components/Selection.tsx +1 -4
  108. package/src/components/Switch.tsx +7 -7
  109. package/src/components/calendar/Calendar.tsx +18 -0
  110. package/src/components/calendar/DaysView.tsx +6 -4
  111. package/src/components/calendar/TimeView.tsx +80 -5
  112. package/src/components/calendar/YearsView.tsx +44 -1
  113. package/src/renderers/Card.tsx +299 -191
  114. package/src/renderers/Form/Formula.tsx +7 -5
  115. package/src/renderers/Form/InputFile.tsx +6 -2
  116. package/src/renderers/Form/index.tsx +12 -0
  117. package/src/renderers/Form/wrapControl.tsx +5 -2
  118. package/src/store/formItem.ts +12 -6
  119. package/src/utils/helper.ts +34 -0
@@ -1185,6 +1185,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
1185
1185
  multiple,
1186
1186
  autoUpload,
1187
1187
  description,
1188
+ descriptionClassName,
1188
1189
  hideUploadButton,
1189
1190
  className,
1190
1191
  btnClassName,
@@ -1224,7 +1225,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
1224
1225
  <Icon icon="download" className="icon" />
1225
1226
  <span>{__('File.downloadTpl')}</span>
1226
1227
  </a>
1227
- ) : null}
1228
+ ) : null}
1228
1229
 
1229
1230
  <DropZone
1230
1231
  disabled={disabled}
@@ -1277,7 +1278,10 @@ export default class FileControl extends React.Component<FileProps, FileState> {
1277
1278
 
1278
1279
  {description
1279
1280
  ? render('desc', description!, {
1280
- className: cx('FileControl-description')
1281
+ className: cx(
1282
+ 'FileControl-description',
1283
+ descriptionClassName
1284
+ )
1281
1285
  })
1282
1286
  : null}
1283
1287
 
@@ -866,6 +866,18 @@ export default class Form extends React.Component<FormProps, object> {
866
866
 
867
867
  store.updateData(values);
868
868
 
869
+ store.items.forEach(formItem => {
870
+ const updatedValue = getVariable(values, formItem.name, false);
871
+
872
+ if (updatedValue !== undefined) {
873
+ // 更新验证状态但保留错误信息
874
+ formItem.reset(true);
875
+ // 这里需要更新value,否则提交时不会使用新的字段值校验
876
+ formItem.changeTmpValue(updatedValue);
877
+ formItem.validateOnChange && formItem.validate(values);
878
+ }
879
+ });
880
+
869
881
  (formLazyChange === false ? this.emitChange : this.lazyEmitChange)(submit);
870
882
  }
871
883
 
@@ -129,7 +129,8 @@ export function wrapControl<
129
129
  clearValueOnHidden,
130
130
  validateApi,
131
131
  minLength,
132
- maxLength
132
+ maxLength,
133
+ validateOnChange
133
134
  }
134
135
  } = this.props;
135
136
 
@@ -174,7 +175,8 @@ export function wrapControl<
174
175
  clearValueOnHidden,
175
176
  validateApi,
176
177
  minLength,
177
- maxLength
178
+ maxLength,
179
+ validateOnChange
178
180
  });
179
181
 
180
182
  // issue 这个逻辑应该在 combo 里面自己实现。
@@ -465,6 +467,7 @@ export function wrapControl<
465
467
  }
466
468
 
467
469
  this.model.changeTmpValue(value);
470
+
468
471
  if (changeImmediately || conrolChangeImmediately || !formInited) {
469
472
  this.emitChange(submitOnChange);
470
473
  } else {
@@ -14,6 +14,7 @@ import {str2rules, validate as doValidate} from '../utils/validations';
14
14
  import {Api, Payload, fetchOptions} from '../types';
15
15
  import {ComboStore, IComboStore, IUniqueGroup} from './combo';
16
16
  import {evalExpression} from '../utils/tpl';
17
+ import {isEffectiveApi} from '../utils/api';
17
18
  import findIndex from 'lodash/findIndex';
18
19
  import {
19
20
  isArrayChildrenModified,
@@ -88,7 +89,8 @@ export const FormItemStore = StoreNode.named('FormItemStore')
88
89
  dialogSchema: types.frozen(),
89
90
  dialogOpen: false,
90
91
  dialogData: types.frozen(),
91
- resetValue: types.optional(types.frozen(), '')
92
+ resetValue: types.optional(types.frozen(), ''),
93
+ validateOnChange: false
92
94
  })
93
95
  .views(self => {
94
96
  function getForm(): any {
@@ -233,7 +235,8 @@ export const FormItemStore = StoreNode.named('FormItemStore')
233
235
  clearValueOnHidden,
234
236
  validateApi,
235
237
  maxLength,
236
- minLength
238
+ minLength,
239
+ validateOnChange
237
240
  }: {
238
241
  required?: boolean;
239
242
  unique?: boolean;
@@ -254,6 +257,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
254
257
  validateApi?: boolean;
255
258
  minLength?: number;
256
259
  maxLength?: number;
260
+ validateOnChange?: boolean;
257
261
  }) {
258
262
  if (typeof rules === 'string') {
259
263
  rules = str2rules(rules);
@@ -279,6 +283,8 @@ export const FormItemStore = StoreNode.named('FormItemStore')
279
283
  typeof clearValueOnHidden !== 'undefined' &&
280
284
  (self.clearValueOnHidden = !!clearValueOnHidden);
281
285
  typeof validateApi !== 'undefined' && (self.validateApi = validateApi);
286
+ typeof validateOnChange !== 'undefined' &&
287
+ (self.validateOnChange = !!validateOnChange);
282
288
 
283
289
  rules = {
284
290
  ...rules,
@@ -315,7 +321,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
315
321
  let validateCancel: Function | null = null;
316
322
  const validate: (data: Object, hook?: any) => Promise<boolean> = flow(
317
323
  function* validate(data: Object, hook?: any) {
318
- if (self.validating && !self.validateApi) {
324
+ if (self.validating && !isEffectiveApi(self.validateApi, data)) {
319
325
  return self.valid;
320
326
  }
321
327
 
@@ -329,7 +335,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
329
335
  doValidate(self.tmpValue, data, self.rules, self.messages, self.__)
330
336
  );
331
337
 
332
- if (!self.errors.length && self.validateApi) {
338
+ if (!self.errors.length && isEffectiveApi(self.validateApi, data)) {
333
339
  if (validateCancel) {
334
340
  validateCancel();
335
341
  validateCancel = null;
@@ -1029,7 +1035,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
1029
1035
  subStore = store;
1030
1036
  }
1031
1037
 
1032
- function reset() {
1038
+ function reset(keepErrors: boolean = false) {
1033
1039
  self.validated = false;
1034
1040
 
1035
1041
  if (subStore && subStore.storeType === 'ComboStore') {
@@ -1037,7 +1043,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
1037
1043
  combo.forms.forEach(form => form.reset());
1038
1044
  }
1039
1045
 
1040
- clearError();
1046
+ !keepErrors && clearError();
1041
1047
  }
1042
1048
 
1043
1049
  function openDialog(
@@ -1592,3 +1592,37 @@ export function JSONTraverse(
1592
1592
  }
1593
1593
  });
1594
1594
  }
1595
+
1596
+
1597
+ export function convertDateArrayToDate(
1598
+ value: number[],
1599
+ types: string[],
1600
+ date: moment.Moment
1601
+ ): moment.Moment | null {
1602
+ if (value.length === 0) return date
1603
+ for (let i = 0; i < types.length; i++) {
1604
+ const type = types[i];
1605
+ // @ts-ignore
1606
+ date[type](value[i]);
1607
+ }
1608
+ return date;
1609
+ }
1610
+
1611
+ export function convertDateToObject(value: moment.Moment) {
1612
+ if (value) {
1613
+ return {
1614
+ year: value.year(),
1615
+ month: parseInt(value.format('MM'), 10),
1616
+ day: parseInt(value.format('DD'), 10)
1617
+ };
1618
+ }
1619
+ return null;
1620
+ }
1621
+
1622
+ export function getRange(min: number, max: number, step: number = 1) {
1623
+ const arr = [];
1624
+ for (let i = min; i <= max; i += step) {
1625
+ arr.push(i);
1626
+ }
1627
+ return arr;
1628
+ };