amis-core 3.2.0 → 3.3.0

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 (297) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.d.ts +1 -1
  3. package/esm/RootRenderer.js +3 -3
  4. package/esm/SchemaRenderer.js +5 -2
  5. package/esm/Scoped.d.ts +4 -1
  6. package/esm/Scoped.js +8 -5
  7. package/esm/StatusScoped.js +1 -1
  8. package/esm/WithRootStore.js +1 -1
  9. package/esm/WithStore.js +1 -1
  10. package/esm/actions/Action.d.ts +1 -0
  11. package/esm/actions/Action.js +62 -37
  12. package/esm/actions/AjaxAction.d.ts +6 -8
  13. package/esm/actions/AjaxAction.js +20 -18
  14. package/esm/actions/BreakAction.js +1 -1
  15. package/esm/actions/BroadcastAction.js +1 -1
  16. package/esm/actions/CmptAction.d.ts +1 -2
  17. package/esm/actions/CmptAction.js +46 -31
  18. package/esm/actions/ContinueAction.js +1 -1
  19. package/esm/actions/CopyAction.js +1 -1
  20. package/esm/actions/CustomAction.js +2 -2
  21. package/esm/actions/DialogAction.js +5 -6
  22. package/esm/actions/DrawerAction.js +4 -4
  23. package/esm/actions/EmailAction.js +1 -1
  24. package/esm/actions/LinkAction.js +1 -1
  25. package/esm/actions/LoopAction.js +1 -1
  26. package/esm/actions/PageAction.js +1 -1
  27. package/esm/actions/ParallelAction.js +1 -1
  28. package/esm/actions/StatusAction.d.ts +15 -0
  29. package/esm/actions/StatusAction.js +49 -0
  30. package/esm/actions/SwitchAction.js +1 -1
  31. package/esm/actions/ToastAction.js +1 -1
  32. package/esm/actions/index.d.ts +1 -0
  33. package/esm/components/CustomStyle.js +1 -1
  34. package/esm/components/LazyComponent.js +1 -1
  35. package/esm/components/Overlay.js +2 -2
  36. package/esm/components/PopOver.js +2 -2
  37. package/esm/env.js +1 -1
  38. package/esm/envOverwrite.js +1 -1
  39. package/esm/factory.js +2 -2
  40. package/esm/index.d.ts +2 -1
  41. package/esm/index.js +13 -13
  42. package/esm/locale.js +1 -1
  43. package/esm/polyfills.js +1 -1
  44. package/esm/renderers/Form.d.ts +6 -6
  45. package/esm/renderers/Form.js +168 -124
  46. package/esm/renderers/Item.d.ts +42 -66
  47. package/esm/renderers/Item.js +11 -41
  48. package/esm/renderers/Options.js +1 -2
  49. package/esm/renderers/Placeholder.js +1 -1
  50. package/esm/renderers/builtin.js +1 -1
  51. package/esm/renderers/register.js +1 -1
  52. package/esm/renderers/wrapControl.js +101 -47
  53. package/esm/store/app.js +8 -4
  54. package/esm/store/combo.d.ts +444 -1912
  55. package/esm/store/combo.js +9 -2
  56. package/esm/store/crud.d.ts +1 -0
  57. package/esm/store/crud.js +11 -5
  58. package/esm/store/form.d.ts +132 -892
  59. package/esm/store/form.js +83 -81
  60. package/esm/store/formItem.d.ts +5 -2
  61. package/esm/store/formItem.js +13 -2
  62. package/esm/store/iRenderer.js +2 -2
  63. package/esm/store/index.js +1 -1
  64. package/esm/store/list.js +1 -1
  65. package/esm/store/manager.js +1 -1
  66. package/esm/store/modal.js +1 -1
  67. package/esm/store/node.js +1 -1
  68. package/esm/store/pagination.js +1 -1
  69. package/esm/store/root.js +2 -2
  70. package/esm/store/service.js +4 -4
  71. package/esm/store/status.js +1 -1
  72. package/esm/store/table.d.ts +503 -2040
  73. package/esm/store/table.js +79 -55
  74. package/esm/store/table2.d.ts +49 -0
  75. package/esm/store/table2.js +37 -4
  76. package/esm/theme.js +1 -1
  77. package/esm/types.d.ts +17 -3
  78. package/esm/utils/Animation.js +1 -1
  79. package/esm/utils/ColorScale.js +1 -1
  80. package/esm/utils/DataSchema.js +1 -1
  81. package/esm/utils/DataScope.js +1 -1
  82. package/esm/utils/RootClose.js +1 -1
  83. package/esm/utils/SimpleMap.js +1 -1
  84. package/esm/utils/api.d.ts +2 -2
  85. package/esm/utils/api.js +113 -81
  86. package/esm/utils/arraySlice.js +1 -1
  87. package/esm/utils/attachmentAdpator.js +1 -1
  88. package/esm/utils/autobind.js +1 -1
  89. package/esm/utils/columnsSplit.js +1 -1
  90. package/esm/utils/dataMapping.js +4 -2
  91. package/esm/utils/date.js +1 -1
  92. package/esm/utils/debug.d.ts +2 -0
  93. package/esm/utils/debug.js +34 -7
  94. package/esm/utils/decodeEntity.js +1 -1
  95. package/esm/utils/dom.js +1 -1
  96. package/esm/utils/errors.js +1 -1
  97. package/esm/utils/escapeHtml.js +1 -1
  98. package/esm/utils/filter-schema.js +1 -1
  99. package/esm/utils/filter.js +1 -1
  100. package/esm/utils/formatDuration.js +1 -1
  101. package/esm/utils/formula.d.ts +0 -1
  102. package/esm/utils/formula.js +6 -9
  103. package/esm/utils/getVariable.js +1 -1
  104. package/esm/utils/grammar.js +1 -1
  105. package/esm/utils/handleAction.js +1 -1
  106. package/esm/utils/helper.d.ts +11 -1
  107. package/esm/utils/helper.js +14 -2
  108. package/esm/utils/highlight.js +1 -1
  109. package/esm/utils/icon.d.ts +4 -2
  110. package/esm/utils/icon.js +3 -2
  111. package/esm/utils/image.js +1 -1
  112. package/esm/utils/index.d.ts +1 -0
  113. package/esm/utils/isPureVariable.js +1 -1
  114. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  115. package/esm/utils/keyToPath.js +1 -1
  116. package/esm/utils/makeSorter.js +1 -1
  117. package/esm/utils/math.d.ts +3 -0
  118. package/esm/utils/math.js +52 -0
  119. package/esm/utils/memoryParse.js +1 -1
  120. package/esm/utils/normalizeLink.js +1 -1
  121. package/esm/utils/normalizeOptions.js +1 -1
  122. package/esm/utils/object.d.ts +7 -0
  123. package/esm/utils/object.js +13 -2
  124. package/esm/utils/offset.js +1 -1
  125. package/esm/utils/offsetParent.js +1 -1
  126. package/esm/utils/optionValueCompare.js +2 -2
  127. package/esm/utils/position.js +1 -1
  128. package/esm/utils/prettyBytes.js +1 -1
  129. package/esm/utils/renderer-event.d.ts +1 -1
  130. package/esm/utils/renderer-event.js +14 -6
  131. package/esm/utils/replaceText.js +1 -1
  132. package/esm/utils/resize-sensor.js +1 -1
  133. package/esm/utils/resolveCondition.js +1 -1
  134. package/esm/utils/resolveVariable.js +1 -1
  135. package/esm/utils/resolveVariableAndFilter.js +1 -1
  136. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  137. package/esm/utils/scrollPosition.js +1 -1
  138. package/esm/utils/string2regExp.js +1 -1
  139. package/esm/utils/stripNumber.js +1 -1
  140. package/esm/utils/style-helper.js +1 -1
  141. package/esm/utils/style.js +1 -1
  142. package/esm/utils/toNumber.js +1 -1
  143. package/esm/utils/tokenize.js +1 -1
  144. package/esm/utils/tpl-builtin.js +1 -1
  145. package/esm/utils/tpl-lodash.js +1 -1
  146. package/esm/utils/tpl.js +1 -1
  147. package/esm/utils/uncontrollable.js +1 -1
  148. package/esm/utils/validations.js +1 -1
  149. package/lib/Root.js +10 -7
  150. package/lib/RootRenderer.d.ts +1 -1
  151. package/lib/RootRenderer.js +11 -8
  152. package/lib/SchemaRenderer.js +12 -6
  153. package/lib/Scoped.d.ts +4 -1
  154. package/lib/Scoped.js +18 -13
  155. package/lib/StatusScoped.js +5 -2
  156. package/lib/WithRootStore.js +5 -2
  157. package/lib/WithStore.js +5 -2
  158. package/lib/actions/Action.d.ts +1 -0
  159. package/lib/actions/Action.js +62 -37
  160. package/lib/actions/AjaxAction.d.ts +6 -8
  161. package/lib/actions/AjaxAction.js +20 -18
  162. package/lib/actions/BreakAction.js +1 -1
  163. package/lib/actions/BroadcastAction.js +1 -1
  164. package/lib/actions/CmptAction.d.ts +1 -2
  165. package/lib/actions/CmptAction.js +46 -31
  166. package/lib/actions/ContinueAction.js +1 -1
  167. package/lib/actions/CopyAction.js +1 -1
  168. package/lib/actions/CustomAction.js +8 -5
  169. package/lib/actions/DialogAction.js +5 -6
  170. package/lib/actions/DrawerAction.js +4 -4
  171. package/lib/actions/EmailAction.js +1 -1
  172. package/lib/actions/LinkAction.js +1 -1
  173. package/lib/actions/LoopAction.js +1 -1
  174. package/lib/actions/PageAction.js +1 -1
  175. package/lib/actions/ParallelAction.js +1 -1
  176. package/lib/actions/StatusAction.d.ts +15 -0
  177. package/lib/actions/StatusAction.js +53 -0
  178. package/lib/actions/SwitchAction.js +1 -1
  179. package/lib/actions/ToastAction.js +1 -1
  180. package/lib/actions/index.d.ts +1 -0
  181. package/lib/components/CustomStyle.js +1 -1
  182. package/lib/components/LazyComponent.js +12 -14
  183. package/lib/components/Overlay.js +14 -14
  184. package/lib/components/PopOver.js +11 -10
  185. package/lib/env.js +4 -1
  186. package/lib/envOverwrite.js +1 -1
  187. package/lib/factory.js +11 -9
  188. package/lib/index.d.ts +2 -1
  189. package/lib/index.js +21 -19
  190. package/lib/locale.js +6 -3
  191. package/lib/polyfills.js +1 -1
  192. package/lib/renderers/Form.d.ts +6 -6
  193. package/lib/renderers/Form.js +180 -131
  194. package/lib/renderers/Item.d.ts +42 -66
  195. package/lib/renderers/Item.js +51 -75
  196. package/lib/renderers/Options.js +10 -5
  197. package/lib/renderers/Placeholder.js +1 -1
  198. package/lib/renderers/builtin.js +1 -1
  199. package/lib/renderers/register.js +1 -1
  200. package/lib/renderers/wrapControl.js +104 -47
  201. package/lib/store/app.js +14 -7
  202. package/lib/store/combo.d.ts +444 -1912
  203. package/lib/store/combo.js +9 -2
  204. package/lib/store/crud.d.ts +1 -0
  205. package/lib/store/crud.js +11 -5
  206. package/lib/store/form.d.ts +132 -892
  207. package/lib/store/form.js +81 -79
  208. package/lib/store/formItem.d.ts +5 -2
  209. package/lib/store/formItem.js +13 -2
  210. package/lib/store/iRenderer.js +8 -5
  211. package/lib/store/index.js +1 -1
  212. package/lib/store/list.js +1 -1
  213. package/lib/store/manager.js +1 -1
  214. package/lib/store/modal.js +1 -1
  215. package/lib/store/node.js +1 -1
  216. package/lib/store/pagination.js +1 -1
  217. package/lib/store/root.js +8 -5
  218. package/lib/store/service.js +4 -4
  219. package/lib/store/status.js +1 -1
  220. package/lib/store/table.d.ts +503 -2040
  221. package/lib/store/table.js +79 -55
  222. package/lib/store/table2.d.ts +49 -0
  223. package/lib/store/table2.js +36 -3
  224. package/lib/theme.js +6 -3
  225. package/lib/types.d.ts +17 -3
  226. package/lib/utils/Animation.js +1 -1
  227. package/lib/utils/ColorScale.js +1 -1
  228. package/lib/utils/DataSchema.js +1 -1
  229. package/lib/utils/DataScope.js +1 -1
  230. package/lib/utils/RootClose.js +1 -1
  231. package/lib/utils/SimpleMap.js +1 -1
  232. package/lib/utils/api.d.ts +2 -2
  233. package/lib/utils/api.js +113 -81
  234. package/lib/utils/arraySlice.js +1 -1
  235. package/lib/utils/attachmentAdpator.js +1 -1
  236. package/lib/utils/autobind.js +1 -1
  237. package/lib/utils/columnsSplit.js +8 -6
  238. package/lib/utils/dataMapping.js +4 -2
  239. package/lib/utils/date.js +1 -1
  240. package/lib/utils/debug.d.ts +2 -0
  241. package/lib/utils/debug.js +61 -33
  242. package/lib/utils/decodeEntity.js +1 -1
  243. package/lib/utils/dom.js +7 -5
  244. package/lib/utils/errors.js +1 -1
  245. package/lib/utils/escapeHtml.js +1 -1
  246. package/lib/utils/filter-schema.js +1 -1
  247. package/lib/utils/filter.js +1 -1
  248. package/lib/utils/formatDuration.js +1 -1
  249. package/lib/utils/formula.d.ts +0 -1
  250. package/lib/utils/formula.js +6 -10
  251. package/lib/utils/getVariable.js +1 -1
  252. package/lib/utils/grammar.js +1 -1
  253. package/lib/utils/handleAction.js +1 -1
  254. package/lib/utils/helper.d.ts +11 -1
  255. package/lib/utils/helper.js +14 -1
  256. package/lib/utils/highlight.js +8 -9
  257. package/lib/utils/icon.d.ts +4 -2
  258. package/lib/utils/icon.js +12 -10
  259. package/lib/utils/image.js +1 -1
  260. package/lib/utils/index.d.ts +1 -0
  261. package/lib/utils/isPureVariable.js +1 -1
  262. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  263. package/lib/utils/keyToPath.js +1 -1
  264. package/lib/utils/makeSorter.js +1 -1
  265. package/lib/utils/math.d.ts +3 -0
  266. package/lib/utils/math.js +58 -0
  267. package/lib/utils/memoryParse.js +1 -1
  268. package/lib/utils/normalizeLink.js +1 -1
  269. package/lib/utils/normalizeOptions.js +1 -1
  270. package/lib/utils/object.d.ts +7 -0
  271. package/lib/utils/object.js +13 -1
  272. package/lib/utils/offset.js +1 -1
  273. package/lib/utils/offsetParent.js +1 -1
  274. package/lib/utils/optionValueCompare.js +7 -3
  275. package/lib/utils/position.js +1 -1
  276. package/lib/utils/prettyBytes.js +1 -1
  277. package/lib/utils/renderer-event.d.ts +1 -1
  278. package/lib/utils/renderer-event.js +13 -5
  279. package/lib/utils/replaceText.js +1 -1
  280. package/lib/utils/resize-sensor.js +1 -1
  281. package/lib/utils/resolveCondition.js +1 -1
  282. package/lib/utils/resolveVariable.js +1 -1
  283. package/lib/utils/resolveVariableAndFilter.js +1 -1
  284. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  285. package/lib/utils/scrollPosition.js +1 -1
  286. package/lib/utils/string2regExp.js +1 -1
  287. package/lib/utils/stripNumber.js +1 -1
  288. package/lib/utils/style-helper.js +1 -1
  289. package/lib/utils/style.js +1 -1
  290. package/lib/utils/toNumber.js +1 -1
  291. package/lib/utils/tokenize.js +1 -1
  292. package/lib/utils/tpl-builtin.js +1 -1
  293. package/lib/utils/tpl-lodash.js +1 -1
  294. package/lib/utils/tpl.js +1 -1
  295. package/lib/utils/uncontrollable.js +1 -1
  296. package/lib/utils/validations.js +1 -1
  297. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -31,6 +31,7 @@ var Column = types
31
31
  type: types.optional(types.string, 'plain'),
32
32
  name: types.maybe(types.string),
33
33
  value: types.frozen(),
34
+ id: '',
34
35
  groupName: '',
35
36
  toggled: false,
36
37
  toggable: true,
@@ -44,6 +45,8 @@ var Column = types
44
45
  fixed: '',
45
46
  index: 0,
46
47
  rawIndex: 0,
48
+ width: 0,
49
+ minWidth: 0,
47
50
  breakpoint: types.optional(types.frozen(), undefined),
48
51
  pristine: types.optional(types.frozen(), undefined),
49
52
  remark: types.optional(types.frozen(), undefined),
@@ -66,6 +69,12 @@ var Column = types
66
69
  self.enableSearch = value;
67
70
  var table = getParent(self, 2);
68
71
  table.persistSaveToggledColumns();
72
+ },
73
+ setWidth: function (value, minWidth) {
74
+ self.width = value;
75
+ if (typeof minWidth === 'number') {
76
+ self.minWidth = minWidth;
77
+ }
69
78
  }
70
79
  }); });
71
80
  var Row = types
@@ -258,6 +267,7 @@ var TableStore = iRendererStore
258
267
  formsRef: types.optional(types.array(types.frozen()), []),
259
268
  maxKeepItemSelectionLength: Infinity,
260
269
  keepItemSelectionOnPageChange: false,
270
+ useFixedLayout: false,
261
271
  // 导出 Excel 按钮的 loading 状态
262
272
  exportExcelLoading: false,
263
273
  searchFormExpanded: false // 用来控制搜索框是否展开了,那个自动根据 searchable 生成的表单 autoGenerateFilter
@@ -315,23 +325,6 @@ var TableStore = iRendererStore
315
325
  isBreakpoint(item.breakpoint);
316
326
  });
317
327
  }
318
- function getLeftFixedColumns() {
319
- if (self.dragging) {
320
- return [];
321
- }
322
- var columns = getFilteredColumns().filter(function (item) { return item.fixed === 'left'; });
323
- // 有才带过去,没有就不带了
324
- if (columns.length) {
325
- columns = getFilteredColumns().filter(function (item) { return item.fixed === 'left' || /^__/.test(item.type); });
326
- }
327
- return columns;
328
- }
329
- function getRightFixedColumns() {
330
- if (self.dragging) {
331
- return [];
332
- }
333
- return getFilteredColumns().filter(function (item) { return item.fixed === 'right'; });
334
- }
335
328
  function isSelected(row) {
336
329
  return !!~self.selectedRows.indexOf(row);
337
330
  }
@@ -443,7 +436,11 @@ var TableStore = iRendererStore
443
436
  (item.has.length === 1 && item.label === item.has[0].label)
444
437
  ? 2
445
438
  : 1;
446
- return __assign(__assign({}, item), { rowSpan: rowSpan, label: rowSpan === 2 ? item.label || item.has[0].label : item.label });
439
+ return __assign(__assign({}, item), { rowSpan: rowSpan, label: rowSpan === 2 ? item.label || item.has[0].label : item.label, fixed: item.has.every(function (column) { return column.fixed; })
440
+ ? item.has[0].fixed
441
+ : undefined, get width() {
442
+ return item.has.reduce(function (a, b) { return a + b.width; }, 0);
443
+ } });
447
444
  });
448
445
  }
449
446
  function getFirstToggledColumnIndex() {
@@ -476,12 +473,6 @@ var TableStore = iRendererStore
476
473
  get footableColumns() {
477
474
  return getFootableColumns();
478
475
  },
479
- get leftFixedColumns() {
480
- return getLeftFixedColumns();
481
- },
482
- get rightFixedColumns() {
483
- return getRightFixedColumns();
484
- },
485
476
  get toggableColumns() {
486
477
  return getToggableColumns();
487
478
  },
@@ -566,6 +557,55 @@ var TableStore = iRendererStore
566
557
  }
567
558
  });
568
559
  return list;
560
+ },
561
+ get columnWidthReady() {
562
+ return getFilteredColumns().every(function (column) { return column.width; });
563
+ },
564
+ getStickyStyles: function (column, columns) {
565
+ var stickyClassName = '';
566
+ var style = {};
567
+ var autoFixLeftColumns = ['__checkme', '__dragme', '__expandme'];
568
+ if (column.fixed === 'left' ||
569
+ autoFixLeftColumns.includes(column.type)) {
570
+ stickyClassName = 'is-sticky is-sticky-left';
571
+ var index = columns.indexOf(column) - 1;
572
+ if (columns
573
+ .slice(index + 2)
574
+ .every(function (col) {
575
+ return !((col && col.fixed === 'left') ||
576
+ autoFixLeftColumns.includes(col.type));
577
+ })) {
578
+ stickyClassName += ' is-sticky-last-left';
579
+ }
580
+ var left = 0;
581
+ while (index >= 0) {
582
+ var col = columns[index];
583
+ if ((col && col.fixed === 'left') ||
584
+ autoFixLeftColumns.includes(col.type)) {
585
+ left += col.width;
586
+ }
587
+ index--;
588
+ }
589
+ style.left = left;
590
+ }
591
+ else if (column.fixed === 'right') {
592
+ stickyClassName = 'is-sticky is-sticky-right';
593
+ var right = 0;
594
+ var index = columns.indexOf(column) + 1;
595
+ if (columns.slice(0, index - 1).every(function (col) { return col.fixed !== 'right'; })) {
596
+ stickyClassName += ' is-sticky-first-right';
597
+ }
598
+ var len = columns.length;
599
+ while (index < len) {
600
+ var col = columns[index];
601
+ if (col && col.fixed === 'right') {
602
+ right += col.width;
603
+ }
604
+ index++;
605
+ }
606
+ style.right = right;
607
+ }
608
+ return [style, stickyClassName];
569
609
  }
570
610
  };
571
611
  })
@@ -606,12 +646,6 @@ var TableStore = iRendererStore
606
646
  var columns = config.columns
607
647
  .filter(function (column) { return column; })
608
648
  .concat();
609
- if (!columns.length) {
610
- columns.push({
611
- type: 'text',
612
- label: '空'
613
- });
614
- }
615
649
  // 更新列顺序,afterCreate生命周期中更新columns不会触发组件的render
616
650
  var key = getPersistDataKey(columns);
617
651
  var data = localStorage.getItem(key);
@@ -628,28 +662,10 @@ var TableStore = iRendererStore
628
662
  });
629
663
  }
630
664
  }
631
- columns.unshift({
632
- type: '__expandme',
633
- toggable: false,
634
- className: 'Table-expandCell'
635
- });
636
- columns.unshift({
637
- type: '__checkme',
638
- fixed: 'left',
639
- toggable: false,
640
- className: 'Table-checkCell'
641
- });
642
- columns.unshift({
643
- type: '__dragme',
644
- toggable: false,
645
- className: 'Table-dragCell'
646
- });
647
- columns = columns.map(function (item, index) { return (__assign(__assign({}, item), { index: index, rawIndex: index - PARTITION_INDEX, type: item.type || 'plain', pristine: item, toggled: item.toggled !== false, breakpoint: item.breakpoint, isPrimary: index === PARTITION_INDEX, className: item.className || '',
648
- /** 提前映射变量,方便后续view中使用 */
649
- label: isPureVariable(item.label)
650
- ? resolveVariableAndFilter(item.label, self.data)
651
- : item.label })); });
652
- self.columns.replace(columns);
665
+ updateColumns(columns);
666
+ }
667
+ if (config.tableLayout === 'fixed') {
668
+ self.useFixedLayout = true;
653
669
  }
654
670
  }
655
671
  function updateColumns(columns) {
@@ -677,15 +693,18 @@ var TableStore = iRendererStore
677
693
  toggable: false,
678
694
  className: 'Table-dragCell'
679
695
  });
680
- columns = columns.map(function (item, index) { return (__assign(__assign({}, item), { index: index, rawIndex: index - PARTITION_INDEX, type: item.type || 'plain', pristine: item.pristine || item, toggled: item.toggled !== false, breakpoint: item.breakpoint, isPrimary: index === PARTITION_INDEX,
696
+ columns = columns.map(function (item, index) { return (__assign(__assign({}, item), { id: guid(), index: index, width: 0, minWidth: 0, rawIndex: index - PARTITION_INDEX, type: item.type || 'plain', pristine: item.pristine || item, toggled: item.toggled !== false, breakpoint: item.breakpoint, isPrimary: index === PARTITION_INDEX,
681
697
  /** 提前映射变量,方便后续view中使用 */
682
698
  label: isPureVariable(item.label)
683
699
  ? resolveVariableAndFilter(item.label, self.data)
684
700
  : item.label })); });
685
701
  self.columns.replace(columns);
686
- persistSaveToggledColumns();
702
+ self.useFixedLayout = self.columns.some(function (column) { return column.pristine.width; });
687
703
  }
688
704
  }
705
+ function invalidTableColumnWidth() {
706
+ self.columns.forEach(function (column) { return column.setWidth(0); });
707
+ }
689
708
  function combineCell(arr, keys) {
690
709
  if (!keys.length || !arr.length) {
691
710
  return arr;
@@ -828,6 +847,7 @@ var TableStore = iRendererStore
828
847
  self.expandedRows.replace(getExpandAllRows(self.rows));
829
848
  }
830
849
  self.dragging = false;
850
+ invalidTableColumnWidth(); // 更新内容需要重新计算表格布局
831
851
  }
832
852
  // 获取所有层级的子节点id
833
853
  function getExpandAllRows(arr) {
@@ -1132,6 +1152,7 @@ var TableStore = iRendererStore
1132
1152
  return {
1133
1153
  update: update,
1134
1154
  updateColumns: updateColumns,
1155
+ invalidTableColumnWidth: invalidTableColumnWidth,
1135
1156
  initRows: initRows,
1136
1157
  updateSelected: updateSelected,
1137
1158
  toggleAll: toggleAll,
@@ -1154,6 +1175,9 @@ var TableStore = iRendererStore
1154
1175
  persistSaveToggledColumns: persistSaveToggledColumns,
1155
1176
  setSearchFormExpanded: setSearchFormExpanded,
1156
1177
  toggleSearchFormExpanded: toggleSearchFormExpanded,
1178
+ setUseFixedLayout: function (value) {
1179
+ self.useFixedLayout = !!value;
1180
+ },
1157
1181
  // events
1158
1182
  afterCreate: function () {
1159
1183
  setTimeout(function () {
@@ -1,5 +1,6 @@
1
1
  import { Instance, SnapshotIn, IAnyModelType } from 'mobx-state-tree';
2
2
  import { Api, fetchOptions } from '../types';
3
+ import { IFormStore } from './form';
3
4
  export declare const Column: import("mobx-state-tree").IModelType<{
4
5
  title: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
5
6
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
@@ -140,6 +141,7 @@ export declare const TableStore2: import("mobx-state-tree").IModelType<{
140
141
  pageSize: import("mobx-state-tree").IType<number | undefined, number, number>;
141
142
  dragging: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
142
143
  rowSelectionKeyField: import("mobx-state-tree").IType<string | undefined, string, string>;
144
+ formsRef: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<any, any, any>>, [undefined]>;
143
145
  }, {
144
146
  readonly parentStore: any;
145
147
  readonly __: any;
@@ -458,6 +460,52 @@ export declare const TableStore2: import("mobx-state-tree").IModelType<{
458
460
  reset(): void;
459
461
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>))[];
460
462
  readonly keyField: string;
463
+ readonly modified: number;
464
+ readonly modifiedRows: ({
465
+ storeType: string;
466
+ id: string;
467
+ parentId: string;
468
+ name: string;
469
+ pristine: any;
470
+ data: any;
471
+ index: number;
472
+ newIndex: number;
473
+ depth: number;
474
+ children: import("mobx-state-tree").IMSTArray<IAnyModelType> & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<IAnyModelType>, [undefined]>>;
475
+ path: string;
476
+ } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
477
+ readonly checked: boolean;
478
+ readonly modified: boolean;
479
+ readonly moved: boolean;
480
+ readonly locals: any;
481
+ getDataWithModifiedChilden(): any;
482
+ } & {
483
+ replaceWith(data: any): void;
484
+ change(values: object, savePristine?: boolean): void;
485
+ reset(): void;
486
+ } & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
487
+ storeType: import("mobx-state-tree").IType<string | undefined, string, string>;
488
+ id: import("mobx-state-tree").ISimpleType<string>;
489
+ parentId: import("mobx-state-tree").IType<string | undefined, string, string>;
490
+ name: import("mobx-state-tree").ISimpleType<string>;
491
+ pristine: import("mobx-state-tree").IType<any, any, any>;
492
+ data: import("mobx-state-tree").IType<any, any, any>;
493
+ index: import("mobx-state-tree").ISimpleType<number>;
494
+ newIndex: import("mobx-state-tree").ISimpleType<number>;
495
+ depth: import("mobx-state-tree").ISimpleType<number>;
496
+ children: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<IAnyModelType>, [undefined]>;
497
+ path: import("mobx-state-tree").IType<string | undefined, string, string>;
498
+ }, {
499
+ readonly checked: boolean;
500
+ readonly modified: boolean;
501
+ readonly moved: boolean;
502
+ readonly locals: any;
503
+ getDataWithModifiedChilden(): any;
504
+ } & {
505
+ replaceWith(data: any): void;
506
+ change(values: object, savePristine?: boolean): void;
507
+ reset(): void;
508
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>)[];
461
509
  } & {
462
510
  update: (config: Partial<STableStore2>) => void;
463
511
  persistSaveToggledColumns: () => void;
@@ -472,6 +520,7 @@ export declare const TableStore2: import("mobx-state-tree").IModelType<{
472
520
  toggleAllColumns: () => void;
473
521
  afterCreate(): void;
474
522
  saveRemote: (api: Api, data?: object, options?: fetchOptions) => Promise<any>;
523
+ addForm: (form: IFormStore, rowIndex: number) => void;
475
524
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
476
525
  export type ITableStore2 = Instance<typeof TableStore2>;
477
526
  export type STableStore2 = SnapshotIn<typeof TableStore2>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -7,7 +7,7 @@ import { __extends, __assign, __generator } from 'tslib';
7
7
  import { types, getParent, flow, isAlive, getEnv } from 'mobx-state-tree';
8
8
  import find from 'lodash/find';
9
9
  import isEqual from 'lodash/isEqual';
10
- import { immutableExtends, findTree, isEmpty, isVisible, flattenTree, isObjectShallowModified, qsstringify, eachTree, guid, hasVisibleExpression } from '../utils/helper.js';
10
+ import { immutableExtends, findTree, isEmpty, isVisible, flattenTree, difference, isObjectShallowModified, qsstringify, eachTree, guid, hasVisibleExpression } from '../utils/helper.js';
11
11
  import { normalizeApiResponseData } from '../utils/api.js';
12
12
  import { ServiceStore } from './service.js';
13
13
  import { createObject, extendObject, isObject } from '../utils/object.js';
@@ -149,7 +149,8 @@ var TableStore2 = ServiceStore.named('TableStore2')
149
149
  pageNo: 1,
150
150
  pageSize: 10,
151
151
  dragging: false,
152
- rowSelectionKeyField: 'id'
152
+ rowSelectionKeyField: 'id',
153
+ formsRef: types.optional(types.array(types.frozen()), [])
153
154
  })
154
155
  .views(function (self) {
155
156
  function getToggable() {
@@ -210,6 +211,25 @@ var TableStore2 = ServiceStore.named('TableStore2')
210
211
  function getMoved() {
211
212
  return getMovedRows().length;
212
213
  }
214
+ function getModifiedRows(rows, modifiedRows) {
215
+ if (rows === void 0) { rows = []; }
216
+ if (modifiedRows === void 0) { modifiedRows = []; }
217
+ rows = rows && rows.length ? rows : self.rows;
218
+ rows.forEach(function (item) {
219
+ if (item.children && item.children.length) {
220
+ getModifiedRows(item.children, modifiedRows);
221
+ }
222
+ var diff = difference(item.data, item.pristine);
223
+ var hasDifference = Object.keys(diff).length;
224
+ if (hasDifference) {
225
+ modifiedRows.push(item);
226
+ }
227
+ });
228
+ return modifiedRows;
229
+ }
230
+ function getModified() {
231
+ return getModifiedRows().length;
232
+ }
213
233
  return {
214
234
  get toggable() {
215
235
  return getToggable();
@@ -259,6 +279,12 @@ var TableStore2 = ServiceStore.named('TableStore2')
259
279
  },
260
280
  get keyField() {
261
281
  return self.rowSelectionKeyField;
282
+ },
283
+ get modified() {
284
+ return getModified();
285
+ },
286
+ get modifiedRows() {
287
+ return getModifiedRows();
262
288
  }
263
289
  };
264
290
  })
@@ -527,6 +553,12 @@ var TableStore2 = ServiceStore.named('TableStore2')
527
553
  self.rows.replace(rows);
528
554
  self.dragging = false;
529
555
  }
556
+ function addForm(form, rowIndex) {
557
+ self.formsRef.push({
558
+ id: form.id,
559
+ rowIndex: rowIndex
560
+ });
561
+ }
530
562
  return {
531
563
  update: update,
532
564
  persistSaveToggledColumns: persistSaveToggledColumns,
@@ -557,7 +589,8 @@ var TableStore2 = ServiceStore.named('TableStore2')
557
589
  }
558
590
  }, 200);
559
591
  },
560
- saveRemote: saveRemote
592
+ saveRemote: saveRemote,
593
+ addForm: addForm
561
594
  };
562
595
  });
563
596
 
package/esm/theme.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/esm/types.d.ts CHANGED
@@ -183,8 +183,9 @@ export interface ApiObject extends BaseApiObject {
183
183
  operationName?: string;
184
184
  body?: PlainObject;
185
185
  query?: PlainObject;
186
- adaptor?: (payload: object, response: fetcherResult, api: ApiObject) => any;
187
- requestAdaptor?: (api: ApiObject) => ApiObject;
186
+ mockResponse?: PlainObject;
187
+ adaptor?: (payload: object, response: fetcherResult, api: ApiObject, context: any) => any;
188
+ requestAdaptor?: (api: ApiObject, context: any) => ApiObject | Promise<ApiObject>;
188
189
  /** 是否过滤为空字符串的 query 参数 */
189
190
  filterEmptyQuery?: boolean;
190
191
  }
@@ -211,7 +212,7 @@ export interface fetchOptions {
211
212
  errorMessage?: string;
212
213
  autoAppend?: boolean;
213
214
  beforeSend?: (data: any) => any;
214
- onSuccess?: (json: Payload) => any;
215
+ onSuccess?: (json: Payload, data: any) => any;
215
216
  onFailed?: (json: Payload) => any;
216
217
  silent?: boolean;
217
218
  [propName: string]: any;
@@ -497,6 +498,19 @@ export interface BaseSchemaWithoutType {
497
498
  style?: {
498
499
  [propName: string]: any;
499
500
  };
501
+ /**
502
+ * 编辑器配置,运行时可以忽略
503
+ */
504
+ editorSetting?: {
505
+ /**
506
+ * 组件名称,通常是业务名称方便定位
507
+ */
508
+ displayName?: string;
509
+ /**
510
+ * 编辑器假数据,方便展示
511
+ */
512
+ mock?: any;
513
+ };
500
514
  }
501
515
  export type OperatorType = 'equal' | 'not_equal' | 'is_empty' | 'is_not_empty' | 'like' | 'not_like' | 'starts_with' | 'ends_with' | 'less' | 'less_or_equal' | 'greater' | 'greater_or_equal' | 'between' | 'not_between' | 'select_equals' | 'select_not_equals' | 'select_any_in' | 'select_not_any_in' | {
502
516
  label: string;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -14,7 +14,7 @@ export declare function str2function(contents: string, ...args: Array<string>):
14
14
  export declare function str2AsyncFunction(contents: string, ...args: Array<string>): Function | null;
15
15
  export declare function responseAdaptor(ret: fetcherResult, api: ApiObject): Payload;
16
16
  export declare function wrapFetcher(fn: (config: fetcherConfig) => Promise<fetcherResult>, tracker?: (eventTrack: EventTrack, data: any) => void): any;
17
- export declare function wrapAdaptor(promise: Promise<fetcherResult>, api: ApiObject): Promise<Payload>;
17
+ export declare function wrapAdaptor(promise: Promise<fetcherResult>, api: ApiObject, context: any): Promise<Payload>;
18
18
  /**
19
19
  * 请求远程 js 文件然后 new Function 执行,用于 schemaApi 支持 JavaScript
20
20
  * @param api
@@ -24,7 +24,7 @@ export declare function jsFetcher(fetcher: (config: fetcherConfig) => Promise<fe
24
24
  export declare function jsonpFetcher(api: ApiObject): Promise<fetcherResult>;
25
25
  export declare function isApiOutdatedWithData(prevApi: Api | undefined, nextApi: Api | undefined, prevData: any, nextData: any): nextApi is Api;
26
26
  export declare function isApiOutdated(prevApi: Api | undefined, nextApi: Api | undefined, prevData: any, nextData: any): nextApi is Api;
27
- export declare function isValidApi(api: string): boolean | "";
27
+ export declare function isValidApi(api: string): boolean;
28
28
  export declare function isEffectiveApi(api?: Api, data?: any, initFetch?: boolean, initFetchOn?: string): api is Api;
29
29
  export declare function isSameApi(apiA: ApiObject | ApiCacheConfig, apiB: ApiObject | ApiCacheConfig): boolean;
30
30
  export declare function getApiCache(api: ApiObject): ApiCacheConfig | undefined;