amis-core 2.9.0 → 3.0.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 (265) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.js +1 -1
  3. package/esm/SchemaRenderer.d.ts +1 -0
  4. package/esm/SchemaRenderer.js +7 -5
  5. package/esm/Scoped.js +1 -1
  6. package/esm/WithRootStore.js +1 -1
  7. package/esm/WithStore.js +1 -1
  8. package/esm/actions/Action.js +8 -2
  9. package/esm/actions/AjaxAction.js +1 -1
  10. package/esm/actions/BreakAction.js +1 -1
  11. package/esm/actions/BroadcastAction.js +1 -1
  12. package/esm/actions/CmptAction.js +1 -1
  13. package/esm/actions/ContinueAction.js +1 -1
  14. package/esm/actions/CopyAction.js +1 -1
  15. package/esm/actions/CustomAction.js +1 -1
  16. package/esm/actions/DialogAction.js +5 -1
  17. package/esm/actions/DrawerAction.js +1 -1
  18. package/esm/actions/EmailAction.js +1 -1
  19. package/esm/actions/LinkAction.js +1 -1
  20. package/esm/actions/LoopAction.js +1 -1
  21. package/esm/actions/PageAction.js +1 -1
  22. package/esm/actions/ParallelAction.js +1 -1
  23. package/esm/actions/SwitchAction.js +1 -1
  24. package/esm/actions/ToastAction.js +1 -1
  25. package/esm/components/LazyComponent.js +1 -1
  26. package/esm/components/Overlay.d.ts +2 -2
  27. package/esm/components/Overlay.js +1 -1
  28. package/esm/components/PopOver.js +1 -1
  29. package/esm/env.js +1 -1
  30. package/esm/envOverwrite.js +1 -1
  31. package/esm/factory.d.ts +2 -1
  32. package/esm/factory.js +3 -3
  33. package/esm/index.d.ts +8 -3
  34. package/esm/index.js +10 -9
  35. package/esm/locale.js +1 -1
  36. package/esm/renderers/Form.d.ts +1 -1
  37. package/esm/renderers/Form.js +1 -1
  38. package/esm/renderers/Item.js +10 -7
  39. package/esm/renderers/Options.js +3 -3
  40. package/esm/renderers/Placeholder.js +1 -1
  41. package/esm/renderers/builtin.js +1 -1
  42. package/esm/renderers/register.js +1 -1
  43. package/esm/renderers/wrapControl.js +1 -1
  44. package/esm/store/app.js +1 -1
  45. package/esm/store/combo.js +1 -1
  46. package/esm/store/crud.js +22 -8
  47. package/esm/store/form.js +1 -1
  48. package/esm/store/formItem.js +2 -2
  49. package/esm/store/iRenderer.js +1 -1
  50. package/esm/store/index.js +1 -1
  51. package/esm/store/list.js +1 -1
  52. package/esm/store/manager.js +1 -1
  53. package/esm/store/modal.js +1 -1
  54. package/esm/store/node.js +1 -1
  55. package/esm/store/pagination.js +2 -2
  56. package/esm/store/root.js +1 -1
  57. package/esm/store/service.js +1 -1
  58. package/esm/store/table.d.ts +24 -23
  59. package/esm/store/table.js +17 -4
  60. package/esm/store/table2.d.ts +5 -5
  61. package/esm/store/table2.js +23 -19
  62. package/esm/theme.js +1 -1
  63. package/esm/types.d.ts +6 -0
  64. package/esm/utils/Animation.js +1 -1
  65. package/esm/utils/ColorScale.js +1 -1
  66. package/esm/utils/DataSchema.js +1 -1
  67. package/esm/utils/DataScope.js +1 -1
  68. package/esm/utils/RootClose.js +1 -1
  69. package/esm/utils/SimpleMap.js +1 -1
  70. package/esm/utils/api.js +9 -2
  71. package/esm/utils/attachmentAdpator.js +1 -1
  72. package/esm/utils/autobind.js +1 -1
  73. package/esm/utils/columnsSplit.js +1 -1
  74. package/esm/utils/dataMapping.js +1 -1
  75. package/esm/utils/date.js +1 -1
  76. package/esm/utils/debug.js +4 -4
  77. package/esm/utils/decodeEntity.js +1 -1
  78. package/esm/utils/dom.d.ts +2 -0
  79. package/esm/utils/dom.js +47 -10
  80. package/esm/utils/errors.js +1 -1
  81. package/esm/utils/escapeHtml.js +1 -1
  82. package/esm/utils/filter-schema.js +1 -1
  83. package/esm/utils/filter.js +1 -1
  84. package/esm/utils/formatDuration.js +1 -1
  85. package/esm/utils/formula.js +2 -2
  86. package/esm/utils/getVariable.js +1 -1
  87. package/esm/utils/grammar.js +1 -1
  88. package/esm/utils/handleAction.js +1 -1
  89. package/esm/utils/helper.d.ts +7 -0
  90. package/esm/utils/helper.js +28 -3
  91. package/esm/utils/highlight.js +1 -1
  92. package/esm/utils/icon.d.ts +6 -1
  93. package/esm/utils/icon.js +6 -1
  94. package/esm/utils/image.js +1 -1
  95. package/esm/utils/isPureVariable.js +1 -1
  96. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  97. package/esm/utils/keyToPath.js +1 -1
  98. package/esm/utils/makeSorter.js +1 -1
  99. package/esm/utils/normalizeLink.js +1 -1
  100. package/esm/utils/normalizeOptions.js +1 -1
  101. package/esm/utils/object.js +1 -1
  102. package/esm/utils/offset.js +1 -1
  103. package/esm/utils/offsetParent.js +1 -1
  104. package/esm/utils/optionValueCompare.js +1 -1
  105. package/esm/utils/position.js +1 -1
  106. package/esm/utils/prettyBytes.js +1 -1
  107. package/esm/utils/renderer-event.js +35 -32
  108. package/esm/utils/replaceText.js +1 -1
  109. package/esm/utils/resize-sensor.js +1 -1
  110. package/esm/utils/resolveCondition.d.ts +1 -0
  111. package/esm/utils/resolveCondition.js +19 -4
  112. package/esm/utils/resolveVariable.js +1 -1
  113. package/esm/utils/resolveVariableAndFilter.js +1 -1
  114. package/esm/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  115. package/esm/utils/resolveVariableAndFilterForAsync.js +20 -3
  116. package/esm/utils/scrollPosition.js +1 -1
  117. package/esm/utils/string2regExp.js +1 -1
  118. package/esm/utils/stripNumber.js +1 -1
  119. package/esm/utils/style-helper.d.ts +9 -4
  120. package/esm/utils/style-helper.js +81 -16
  121. package/esm/utils/style.js +2 -2
  122. package/esm/utils/toNumber.js +1 -1
  123. package/esm/utils/tokenize.d.ts +1 -0
  124. package/esm/utils/tokenize.js +34 -3
  125. package/esm/utils/tpl-builtin.d.ts +2 -1
  126. package/esm/utils/tpl-builtin.js +18 -3
  127. package/esm/utils/tpl-lodash.js +3 -2
  128. package/esm/utils/tpl.d.ts +2 -0
  129. package/esm/utils/tpl.js +24 -2
  130. package/esm/utils/uncontrollable.js +1 -1
  131. package/esm/utils/validations.d.ts +4 -1
  132. package/esm/utils/validations.js +27 -12
  133. package/lib/Root.js +1 -1
  134. package/lib/RootRenderer.js +1 -1
  135. package/lib/SchemaRenderer.d.ts +1 -0
  136. package/lib/SchemaRenderer.js +7 -4
  137. package/lib/Scoped.js +1 -1
  138. package/lib/WithRootStore.js +1 -1
  139. package/lib/WithStore.js +1 -1
  140. package/lib/actions/Action.js +8 -2
  141. package/lib/actions/AjaxAction.js +1 -1
  142. package/lib/actions/BreakAction.js +1 -1
  143. package/lib/actions/BroadcastAction.js +1 -1
  144. package/lib/actions/CmptAction.js +1 -1
  145. package/lib/actions/ContinueAction.js +1 -1
  146. package/lib/actions/CopyAction.js +1 -1
  147. package/lib/actions/CustomAction.js +1 -1
  148. package/lib/actions/DialogAction.js +5 -1
  149. package/lib/actions/DrawerAction.js +1 -1
  150. package/lib/actions/EmailAction.js +1 -1
  151. package/lib/actions/LinkAction.js +1 -1
  152. package/lib/actions/LoopAction.js +1 -1
  153. package/lib/actions/PageAction.js +1 -1
  154. package/lib/actions/ParallelAction.js +1 -1
  155. package/lib/actions/SwitchAction.js +1 -1
  156. package/lib/actions/ToastAction.js +1 -1
  157. package/lib/components/LazyComponent.js +1 -1
  158. package/lib/components/Overlay.d.ts +2 -2
  159. package/lib/components/Overlay.js +1 -1
  160. package/lib/components/PopOver.js +1 -1
  161. package/lib/env.js +1 -1
  162. package/lib/envOverwrite.js +1 -1
  163. package/lib/factory.d.ts +2 -1
  164. package/lib/factory.js +3 -3
  165. package/lib/index.d.ts +8 -3
  166. package/lib/index.js +14 -2
  167. package/lib/locale.js +1 -1
  168. package/lib/renderers/Form.d.ts +1 -1
  169. package/lib/renderers/Form.js +1 -1
  170. package/lib/renderers/Item.js +10 -7
  171. package/lib/renderers/Options.js +3 -3
  172. package/lib/renderers/Placeholder.js +1 -1
  173. package/lib/renderers/builtin.js +1 -1
  174. package/lib/renderers/register.js +1 -1
  175. package/lib/renderers/wrapControl.js +1 -1
  176. package/lib/store/app.js +1 -1
  177. package/lib/store/combo.js +1 -1
  178. package/lib/store/crud.js +22 -8
  179. package/lib/store/form.js +1 -1
  180. package/lib/store/formItem.js +2 -2
  181. package/lib/store/iRenderer.js +1 -1
  182. package/lib/store/index.js +1 -1
  183. package/lib/store/list.js +1 -1
  184. package/lib/store/manager.js +1 -1
  185. package/lib/store/modal.js +1 -1
  186. package/lib/store/node.js +1 -1
  187. package/lib/store/pagination.js +2 -2
  188. package/lib/store/root.js +1 -1
  189. package/lib/store/service.js +1 -1
  190. package/lib/store/table.d.ts +24 -23
  191. package/lib/store/table.js +17 -4
  192. package/lib/store/table2.d.ts +5 -5
  193. package/lib/store/table2.js +23 -19
  194. package/lib/theme.js +1 -1
  195. package/lib/types.d.ts +6 -0
  196. package/lib/utils/Animation.js +1 -1
  197. package/lib/utils/ColorScale.js +1 -1
  198. package/lib/utils/DataSchema.js +1 -1
  199. package/lib/utils/DataScope.js +1 -1
  200. package/lib/utils/RootClose.js +1 -1
  201. package/lib/utils/SimpleMap.js +1 -1
  202. package/lib/utils/api.js +9 -2
  203. package/lib/utils/attachmentAdpator.js +1 -1
  204. package/lib/utils/autobind.js +1 -1
  205. package/lib/utils/columnsSplit.js +1 -1
  206. package/lib/utils/dataMapping.js +1 -1
  207. package/lib/utils/date.js +1 -1
  208. package/lib/utils/debug.js +4 -4
  209. package/lib/utils/decodeEntity.js +1 -1
  210. package/lib/utils/dom.d.ts +2 -0
  211. package/lib/utils/dom.js +48 -9
  212. package/lib/utils/errors.js +1 -1
  213. package/lib/utils/escapeHtml.js +1 -1
  214. package/lib/utils/filter-schema.js +1 -1
  215. package/lib/utils/filter.js +1 -1
  216. package/lib/utils/formatDuration.js +1 -1
  217. package/lib/utils/formula.js +2 -2
  218. package/lib/utils/getVariable.js +1 -1
  219. package/lib/utils/grammar.js +1 -1
  220. package/lib/utils/handleAction.js +1 -1
  221. package/lib/utils/helper.d.ts +7 -0
  222. package/lib/utils/helper.js +29 -2
  223. package/lib/utils/highlight.js +1 -1
  224. package/lib/utils/icon.d.ts +6 -1
  225. package/lib/utils/icon.js +6 -1
  226. package/lib/utils/image.js +1 -1
  227. package/lib/utils/isPureVariable.js +1 -1
  228. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  229. package/lib/utils/keyToPath.js +1 -1
  230. package/lib/utils/makeSorter.js +1 -1
  231. package/lib/utils/normalizeLink.js +1 -1
  232. package/lib/utils/normalizeOptions.js +1 -1
  233. package/lib/utils/object.js +1 -1
  234. package/lib/utils/offset.js +1 -1
  235. package/lib/utils/offsetParent.js +1 -1
  236. package/lib/utils/optionValueCompare.js +1 -1
  237. package/lib/utils/position.js +1 -1
  238. package/lib/utils/prettyBytes.js +1 -1
  239. package/lib/utils/renderer-event.js +35 -32
  240. package/lib/utils/replaceText.js +1 -1
  241. package/lib/utils/resize-sensor.js +1 -1
  242. package/lib/utils/resolveCondition.d.ts +1 -0
  243. package/lib/utils/resolveCondition.js +19 -3
  244. package/lib/utils/resolveVariable.js +1 -1
  245. package/lib/utils/resolveVariableAndFilter.js +1 -1
  246. package/lib/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  247. package/lib/utils/resolveVariableAndFilterForAsync.js +20 -2
  248. package/lib/utils/scrollPosition.js +1 -1
  249. package/lib/utils/string2regExp.js +1 -1
  250. package/lib/utils/stripNumber.js +1 -1
  251. package/lib/utils/style-helper.d.ts +9 -4
  252. package/lib/utils/style-helper.js +86 -15
  253. package/lib/utils/style.js +2 -2
  254. package/lib/utils/toNumber.js +1 -1
  255. package/lib/utils/tokenize.d.ts +1 -0
  256. package/lib/utils/tokenize.js +33 -1
  257. package/lib/utils/tpl-builtin.d.ts +2 -1
  258. package/lib/utils/tpl-builtin.js +17 -2
  259. package/lib/utils/tpl-lodash.js +3 -2
  260. package/lib/utils/tpl.d.ts +2 -0
  261. package/lib/utils/tpl.js +24 -1
  262. package/lib/utils/uncontrollable.js +1 -1
  263. package/lib/utils/validations.d.ts +4 -1
  264. package/lib/utils/validations.js +27 -12
  265. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -60,10 +60,11 @@ var Column = mobxStateTree.types
60
60
  className: mobxStateTree.types.union(mobxStateTree.types.string, mobxStateTree.types.frozen())
61
61
  })
62
62
  .actions(function (self) { return ({
63
- toggleToggle: function () {
63
+ toggleToggle: function (min) {
64
+ if (min === void 0) { min = 1; }
64
65
  self.toggled = !self.toggled;
65
66
  var table = mobxStateTree.getParent(self, 2);
66
- if (!table.activeToggaleColumns.length) {
67
+ if (table.activeToggaleColumns.length < min) {
67
68
  self.toggled = true;
68
69
  }
69
70
  table.persistSaveToggledColumns();
@@ -1086,10 +1087,12 @@ var TableStore = iRenderer.iRendererStore
1086
1087
  rowIndex: rowIndex
1087
1088
  });
1088
1089
  }
1089
- function toggleAllColumns() {
1090
+ function toggleAllColumns(min) {
1091
+ if (min === void 0) { min = 1; }
1090
1092
  if (self.activeToggaleColumns.length) {
1091
1093
  if (self.activeToggaleColumns.length === self.toggableColumns.length) {
1092
1094
  self.toggableColumns.map(function (column) { return column.setToggled(false); });
1095
+ toggleColumnsAtLeast(min);
1093
1096
  }
1094
1097
  else {
1095
1098
  self.toggableColumns.map(function (column) { return column.setToggled(true); });
@@ -1101,6 +1104,15 @@ var TableStore = iRenderer.iRendererStore
1101
1104
  }
1102
1105
  persistSaveToggledColumns();
1103
1106
  }
1107
+ function toggleColumnsAtLeast(min) {
1108
+ var _a;
1109
+ if (min === void 0) { min = 1; }
1110
+ if (self.activeToggaleColumns.length < min) {
1111
+ for (var i = 0; i < min; i++) {
1112
+ (_a = self.toggableColumns[i]) === null || _a === void 0 ? void 0 : _a.setToggled(true);
1113
+ }
1114
+ }
1115
+ }
1104
1116
  function getPersistDataKey(columns) {
1105
1117
  // 这里的columns使用除了__开头的所有列
1106
1118
  // sort保证存储和读取的key值保持一致
@@ -1134,6 +1146,7 @@ var TableStore = iRenderer.iRendererStore
1134
1146
  exchange: exchange,
1135
1147
  addForm: addForm,
1136
1148
  toggleAllColumns: toggleAllColumns,
1149
+ toggleColumnsAtLeast: toggleColumnsAtLeast,
1137
1150
  persistSaveToggledColumns: persistSaveToggledColumns,
1138
1151
  setSearchFormExpanded: setSearchFormExpanded,
1139
1152
  toggleSearchFormExpanded: toggleSearchFormExpanded,
@@ -139,8 +139,7 @@ export declare const TableStore2: import("mobx-state-tree").IModelType<{
139
139
  pageNo: import("mobx-state-tree").IType<number | undefined, number, number>;
140
140
  pageSize: import("mobx-state-tree").IType<number | undefined, number, number>;
141
141
  dragging: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
142
- keepItemSelectionOnPageChange: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
143
- maxKeepItemSelectionLength: import("mobx-state-tree").IType<number | undefined, number, number>;
142
+ rowSelectionKeyField: import("mobx-state-tree").IType<string | undefined, string, string>;
144
143
  }, {
145
144
  readonly parentStore: any;
146
145
  readonly __: any;
@@ -267,7 +266,7 @@ export declare const TableStore2: import("mobx-state-tree").IModelType<{
267
266
  setToggled(value: boolean): void;
268
267
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>)[];
269
268
  readonly dataSource: any[];
270
- readonly currentSelectedRowKeys: any[];
269
+ readonly currentSelectedRowKeys: any;
271
270
  readonly currentExpandedKeys: any[];
272
271
  readonly unSelectedRows: ({
273
272
  storeType: string;
@@ -457,14 +456,15 @@ export declare const TableStore2: import("mobx-state-tree").IModelType<{
457
456
  change(values: object, savePristine?: boolean): void;
458
457
  reset(): void;
459
458
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>))[];
459
+ readonly keyField: string;
460
460
  } & {
461
461
  update: (config: Partial<STableStore2>) => void;
462
462
  persistSaveToggledColumns: () => void;
463
463
  setOrderByInfo: (key: string, direction: 'asc' | 'desc') => void;
464
464
  updateQuery: (values: object, updater?: Function, pageNoField?: string, pageSizeField?: string, replace?: boolean) => void;
465
465
  initRows: (rows: Array<any>, getEntryId?: ((entry: any, index: number) => string) | undefined, reUseRow?: boolean, keyField?: string) => void;
466
- updateSelected: (selectedKeys: Array<any>, keyField?: string) => void;
467
- updateSelectedAll: (keyField?: string) => void;
466
+ updateSelected: (selectedKeys: Array<any>) => void;
467
+ updateSelectedAll: () => void;
468
468
  updateExpanded: (expandedRowKeys: Array<any>, keyField?: string) => void;
469
469
  exchange: (fromIndex: number, toIndex: number, item?: IRow2) => void;
470
470
  reset: () => void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -158,8 +158,7 @@ var TableStore2 = service.ServiceStore.named('TableStore2')
158
158
  pageNo: 1,
159
159
  pageSize: 10,
160
160
  dragging: false,
161
- keepItemSelectionOnPageChange: false,
162
- maxKeepItemSelectionLength: 0
161
+ rowSelectionKeyField: 'key'
163
162
  })
164
163
  .views(function (self) {
165
164
  function getToggable() {
@@ -240,6 +239,9 @@ var TableStore2 = service.ServiceStore.named('TableStore2')
240
239
  return self.rows.map(function (item) { return item.data; });
241
240
  },
242
241
  get currentSelectedRowKeys() {
242
+ if (self.data && self.data.selectedItems) {
243
+ return (self.data.selectedItems.map(function (item) { return item[self.rowSelectionKeyField]; }) || []);
244
+ }
243
245
  return self.selectedRowKeys.map(function (item) { return item; });
244
246
  },
245
247
  get currentExpandedKeys() {
@@ -263,6 +265,9 @@ var TableStore2 = service.ServiceStore.named('TableStore2')
263
265
  },
264
266
  get movedRows() {
265
267
  return getMovedRows();
268
+ },
269
+ get keyField() {
270
+ return self.rowSelectionKeyField;
266
271
  }
267
272
  };
268
273
  })
@@ -281,11 +286,9 @@ var TableStore2 = service.ServiceStore.named('TableStore2')
281
286
  if (typeof config.orderBy === 'string') {
282
287
  setOrderByInfo(config.orderBy, config.order === 'desc' ? 'desc' : 'asc');
283
288
  }
284
- config.maxKeepItemSelectionLength !== void 0 &&
285
- (self.maxKeepItemSelectionLength = config.maxKeepItemSelectionLength);
286
- config.keepItemSelectionOnPageChange !== void 0 &&
287
- (self.keepItemSelectionOnPageChange =
288
- config.keepItemSelectionOnPageChange);
289
+ if (config.rowSelectionKeyField) {
290
+ self.rowSelectionKeyField = config.rowSelectionKeyField;
291
+ }
289
292
  if (config.columns && Array.isArray(config.columns)) {
290
293
  self.columns.replace(updateColumns(config.columns));
291
294
  }
@@ -352,32 +355,33 @@ var TableStore2 = service.ServiceStore.named('TableStore2')
352
355
  helper.isObjectShallowModified(originQuery, self.query, false) &&
353
356
  setTimeout(updater.bind(null, "?".concat(helper.qsstringify(self.query))), 4);
354
357
  }
355
- function updateSelectedRows(rows, selectedKeys, keyField) {
358
+ function updateSelectedRows(rows, selectedKeys) {
359
+ var rowSelectionKeyField = self.rowSelectionKeyField;
356
360
  helper.eachTree(rows, function (item) {
357
- if (~selectedKeys.indexOf(item.pristine[keyField || 'key'])) {
361
+ if (~selectedKeys.indexOf(item.pristine[rowSelectionKeyField])) {
358
362
  self.selectedRows.push(item.id);
359
- self.selectedRowKeys.push(item.pristine[keyField || 'key']);
363
+ self.selectedRowKeys.push(item.pristine[rowSelectionKeyField]);
360
364
  }
361
- else if (find__default["default"](selectedKeys, function (a) { return a && a == item.pristine[keyField || 'key']; })) {
365
+ else if (find__default["default"](selectedKeys, function (a) { return a && a == item.pristine[rowSelectionKeyField]; })) {
362
366
  self.selectedRows.push(item.id);
363
- self.selectedRowKeys.push(item.pristine[keyField || 'key']);
367
+ self.selectedRowKeys.push(item.pristine[rowSelectionKeyField]);
364
368
  }
365
369
  else if (item.children) {
366
- updateSelectedRows(item.children, selectedKeys, keyField);
370
+ updateSelectedRows(item.children, selectedKeys);
367
371
  }
368
372
  });
369
373
  }
370
- function updateSelected(selectedKeys, keyField) {
374
+ function updateSelected(selectedKeys) {
371
375
  self.selectedRows.clear();
372
376
  self.selectedRowKeys.clear();
373
- updateSelectedRows(self.rows, selectedKeys, keyField);
377
+ updateSelectedRows(self.rows, selectedKeys);
374
378
  }
375
- function updateSelectedAll(keyField) {
379
+ function updateSelectedAll() {
376
380
  var selectedKeys = [];
377
381
  helper.eachTree(self.rows, function (item) {
378
- return selectedKeys.push(item.pristine[keyField || 'key']);
382
+ return selectedKeys.push(item.pristine[self.rowSelectionKeyField]);
379
383
  });
380
- updateSelectedRows(self.rows, selectedKeys, keyField);
384
+ updateSelectedRows(self.rows, selectedKeys);
381
385
  }
382
386
  function updateExpanded(expandedRowKeys, keyField) {
383
387
  self.expandedRowKeys.clear();
package/lib/theme.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/lib/types.d.ts CHANGED
@@ -488,6 +488,12 @@ export interface BaseSchemaWithoutType {
488
488
  */
489
489
  staticInputClassName?: SchemaClassName;
490
490
  staticSchema?: any;
491
+ /**
492
+ * 组件样式
493
+ */
494
+ style?: {
495
+ [propName: string]: any;
496
+ };
491
497
  }
492
498
  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' | {
493
499
  label: string;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/lib/utils/api.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -359,7 +359,10 @@ function wrapFetcher(fn, tracker) {
359
359
  api = api.requestAdaptor(api) || api;
360
360
  debug.debug('api', 'after requestAdaptor', api);
361
361
  }
362
- if (api.data && (helper.hasFile(api.data) || api.dataType === 'form-data')) {
362
+ if (api.data &&
363
+ (api.data instanceof FormData ||
364
+ helper.hasFile(api.data) ||
365
+ api.dataType === 'form-data')) {
363
366
  api.data =
364
367
  api.data instanceof FormData
365
368
  ? api.data
@@ -531,6 +534,10 @@ function isApiOutdated(prevApi, nextApi, prevData, nextData) {
531
534
  if (!nextApi) {
532
535
  return false;
533
536
  }
537
+ // 通常是编辑器里加了属性,一开始没值,后来有了
538
+ if (prevApi === undefined && !nextApi !== undefined) {
539
+ return true;
540
+ }
534
541
  nextApi = normalizeApi(nextApi);
535
542
  if (nextApi.autoRefresh === false) {
536
543
  return false;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/lib/utils/date.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -361,12 +361,12 @@ var DebugWrapper = /** @class */ (function (_super) {
361
361
  * @param ext 扩展信息
362
362
  */
363
363
  function debug(cat, msg, ext) {
364
- console.groupCollapsed('[amis debug]', msg);
365
- console.debug(ext);
366
- console.groupEnd();
367
364
  if (!isEnabled) {
368
365
  return;
369
366
  }
367
+ console.groupCollapsed('[amis debug]', msg);
368
+ console.debug(ext);
369
+ console.groupEnd();
370
370
  var log = {
371
371
  cat: cat,
372
372
  level: 'debug',
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -11,3 +11,5 @@ export declare function calculatePosition(placement: any, overlayNode: any, targ
11
11
  * 专门用来获取样式的像素值,默认返回 0
12
12
  */
13
13
  export declare function getStyleNumber(element: HTMLElement, styleName: string): number;
14
+ /** 根据关键字高亮显示文本内容 */
15
+ export declare function renderTextByKeyword(rendererText: string, curKeyword: string): string | JSX.Element;
package/lib/utils/dom.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -9,12 +9,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
10
  var tslib = require('tslib');
11
11
  var ReactDOM = require('react-dom');
12
+ var React = require('react');
12
13
  var offset = require('./offset.js');
13
14
  var position = require('./position.js');
14
15
 
15
16
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
17
 
17
18
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
19
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
18
20
 
19
21
  function getContainer(container, defaultContainer) {
20
22
  container = typeof container === 'function' ? container() : container;
@@ -86,16 +88,27 @@ function calculatePosition(placement, overlayNode, target, container, padding, c
86
88
  ? clip2.height / overlayNode.offsetHeight
87
89
  : 1;
88
90
  // auto 尝试四个方向对齐。
89
- placement =
90
- placement === 'auto'
91
- ? 'left-bottom-left-top right-bottom-right-top left-top-left-bottom right-top-right-bottom left-bottom-left-top'
92
- : placement;
91
+ var isAuto = placement === 'auto';
92
+ // 兜底方向
93
+ var autoDefaultPlacement = 'left-bottom-left-top';
94
+ placement = isAuto
95
+ ? "left-bottom-left-top right-bottom-right-top left-top-left-bottom right-top-right-bottom ".concat(autoDefaultPlacement)
96
+ : placement;
93
97
  var positionLeft = 0, positionTop = 0, arrowOffsetLeft = '', arrowOffsetTop = '', activePlacement = placement;
94
98
  if (~placement.indexOf('-')) {
95
99
  var tests = placement.split(/\s+/);
100
+ // 收集可见方向
101
+ var visiblePlacement = {};
96
102
  while (tests.length) {
97
103
  var current = (activePlacement = tests.shift());
98
- var _b = tslib.__read(current.split('-'), 4), atX = _b[0], atY = _b[1], myX = _b[2], myY = _b[3];
104
+ // 自动对齐模式下,当四个方向都无法完全可见时
105
+ // 根据之前的计算结果,使用收集的可见方向作为兜底,避免完全不可见
106
+ if (isAuto && tests.length === 0) {
107
+ var _b = tslib.__read(autoDefaultPlacement.split('-'), 4), _atX = _b[0], _atY = _b[1], _myX = _b[2], _myY = _b[3];
108
+ var _c = visiblePlacement.atX, atX_1 = _c === void 0 ? _atX : _c, _d = visiblePlacement.atY, atY_1 = _d === void 0 ? _atY : _d, _e = visiblePlacement.myX, myX_1 = _e === void 0 ? _myX : _e, _f = visiblePlacement.myY, myY_1 = _f === void 0 ? _myY : _f;
109
+ current = activePlacement = [atX_1, atY_1, myX_1, myY_1].join('-');
110
+ }
111
+ var _g = tslib.__read(current.split('-'), 4), atX = _g[0], atY = _g[1], myX = _g[2], myY = _g[3];
99
112
  myX = myX || atX;
100
113
  myY = myY || atY;
101
114
  positionLeft =
@@ -126,10 +139,21 @@ function calculatePosition(placement, overlayNode, target, container, padding, c
126
139
  width: overlayWidth,
127
140
  height: overlayHeight
128
141
  };
142
+ var visibleX = false;
143
+ var visibleY = false;
129
144
  if (transformed.x > 0 &&
130
- transformed.x + transformed.width < window.innerWidth &&
131
- transformed.y > 0 &&
145
+ transformed.x + transformed.width < window.innerWidth) {
146
+ visibleX = true;
147
+ !visiblePlacement.atX && (visiblePlacement.atX = atX);
148
+ !visiblePlacement.myX && (visiblePlacement.myX = myX);
149
+ }
150
+ if (transformed.y > 0 &&
132
151
  transformed.y + transformed.height < window.innerHeight) {
152
+ visibleY = true;
153
+ !visiblePlacement.atY && (visiblePlacement.atY = atY);
154
+ !visiblePlacement.myY && (visiblePlacement.myY = myY);
155
+ }
156
+ if (visibleX && visibleY) {
133
157
  break;
134
158
  }
135
159
  }
@@ -175,7 +199,7 @@ function calculatePosition(placement, overlayNode, target, container, padding, c
175
199
  else {
176
200
  throw new Error("calcOverlayPosition(): No such placement of \"".concat(placement, "\" found."));
177
201
  }
178
- var _c = tslib.__read(customOffset, 2), _d = _c[0], offSetX = _d === void 0 ? 0 : _d, _e = _c[1], offSetY = _e === void 0 ? 0 : _e;
202
+ var _h = tslib.__read(customOffset, 2), _j = _h[0], offSetX = _j === void 0 ? 0 : _j, _k = _h[1], offSetY = _k === void 0 ? 0 : _k;
179
203
  return {
180
204
  positionLeft: (positionLeft + offSetX) / scaleX,
181
205
  positionTop: (positionTop + offSetY) / scaleY,
@@ -193,8 +217,23 @@ function getStyleNumber(element, styleName) {
193
217
  }
194
218
  return (parseInt(getComputedStyle(element).getPropertyValue(styleName), 10) || 0);
195
219
  }
220
+ /** 根据关键字高亮显示文本内容 */
221
+ function renderTextByKeyword(rendererText, curKeyword) {
222
+ if (curKeyword && ~rendererText.indexOf(curKeyword)) {
223
+ var keywordStartIndex = rendererText.indexOf(curKeyword);
224
+ var keywordEndIndex = keywordStartIndex + curKeyword.length;
225
+ return (React__default["default"].createElement("span", null,
226
+ rendererText.substring(0, keywordStartIndex),
227
+ React__default["default"].createElement("span", { className: "is-keyword" }, curKeyword),
228
+ rendererText.substring(keywordEndIndex)));
229
+ }
230
+ else {
231
+ return rendererText;
232
+ }
233
+ }
196
234
 
197
235
  exports.calculatePosition = calculatePosition;
198
236
  exports.getContainer = getContainer;
199
237
  exports.getStyleNumber = getStyleNumber;
200
238
  exports.ownerDocument = ownerDocument;
239
+ exports.renderTextByKeyword = renderTextByKeyword;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -12,8 +12,8 @@ var isString = require('lodash/isString');
12
12
  var isBoolean = require('lodash/isBoolean');
13
13
  var amisFormula = require('amis-formula');
14
14
  var tpl = require('./tpl.js');
15
- require('moment');
16
15
  require('tslib');
16
+ require('moment');
17
17
  require('lodash/isPlainObject');
18
18
  var getVariable = require('./getVariable.js');
19
19
  var resolveVariableAndFilter = require('./resolveVariableAndFilter.js');
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -144,6 +144,12 @@ export declare function eachTree<T extends TreeItem>(tree: Array<T>, iterator: (
144
144
  * @param iterator
145
145
  */
146
146
  export declare function findTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>) => any): T | null;
147
+ /**
148
+ * 在树中查找节点。
149
+ * @param tree
150
+ * @param iterator
151
+ */
152
+ export declare function findTreeAll<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>) => any): Array<T>;
147
153
  /**
148
154
  * 在树中查找节点, 返回下标数组。
149
155
  * @param tree
@@ -259,6 +265,7 @@ export declare function chainFunctions(...fns: Array<(...args: Array<any>) => vo
259
265
  export declare function chainEvents(props: any, schema: any): any;
260
266
  export declare function mapObject(value: any, fn: Function, skipFn?: (value: any) => boolean): any;
261
267
  export declare function loadScript(src: string): Promise<void>;
268
+ export declare function loadStyle(href: string): Promise<void>;
262
269
  export declare class SkipOperation extends Error {
263
270
  }
264
271
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -609,6 +609,21 @@ function findTree(tree, iterator) {
609
609
  });
610
610
  return result;
611
611
  }
612
+ /**
613
+ * 在树中查找节点。
614
+ * @param tree
615
+ * @param iterator
616
+ */
617
+ function findTreeAll(tree, iterator) {
618
+ var result = [];
619
+ everyTree(tree, function (item, key, level, paths) {
620
+ if (iterator(item, key, level, paths)) {
621
+ result.push(item);
622
+ }
623
+ return true;
624
+ });
625
+ return result;
626
+ }
612
627
  /**
613
628
  * 在树中查找节点, 返回下标数组。
614
629
  * @param tree
@@ -1015,6 +1030,16 @@ function loadScript(src) {
1015
1030
  document.head.appendChild(script);
1016
1031
  });
1017
1032
  }
1033
+ function loadStyle(href) {
1034
+ return new Promise(function (ok, fail) {
1035
+ var link = document.createElement('link');
1036
+ link.rel = 'stylesheet';
1037
+ link.onerror = function (reason) { return fail(reason); };
1038
+ link.onload = function () { return ok(); };
1039
+ link.href = href;
1040
+ document.head.appendChild(link);
1041
+ });
1042
+ }
1018
1043
  var SkipOperation = /** @class */ (function (_super) {
1019
1044
  tslib.__extends(SkipOperation, _super);
1020
1045
  function SkipOperation() {
@@ -1189,7 +1214,7 @@ function isClickOnInput(e) {
1189
1214
  var formItem;
1190
1215
  if (!e.currentTarget.contains(target) ||
1191
1216
  ~['INPUT', 'TEXTAREA'].indexOf(target.tagName) ||
1192
- ((formItem = target.closest("button, a, [data-role=\"form-item\"]")) &&
1217
+ ((formItem = target.closest("button, a, [data-role=\"form-item\"], label[data-role=\"checkbox\"]")) &&
1193
1218
  e.currentTarget.contains(formItem))) {
1194
1219
  return true;
1195
1220
  }
@@ -1297,6 +1322,7 @@ exports.filterTree = filterTree;
1297
1322
  exports.findIndex = findIndex;
1298
1323
  exports.findObjectsWithKey = findObjectsWithKey;
1299
1324
  exports.findTree = findTree;
1325
+ exports.findTreeAll = findTreeAll;
1300
1326
  exports.findTreeIndex = findTreeIndex;
1301
1327
  exports.flattenTree = flattenTree;
1302
1328
  exports.flattenTreeWithLeafNodes = flattenTreeWithLeafNodes;
@@ -1331,6 +1357,7 @@ exports.isUnfolded = isUnfolded;
1331
1357
  exports.isVisible = isVisible;
1332
1358
  exports.lcFirst = lcFirst;
1333
1359
  exports.loadScript = loadScript;
1360
+ exports.loadStyle = loadStyle;
1334
1361
  exports.makeColumnClassBuild = makeColumnClassBuild;
1335
1362
  exports.makeHorizontalDeeper = makeHorizontalDeeper;
1336
1363
  exports.mapObject = mapObject;