amis-core 6.11.0-beta.0 → 6.11.0-beta.2

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 (332) hide show
  1. package/esm/Root.d.ts +3 -0
  2. package/esm/Root.js +1 -1
  3. package/esm/RootRenderer.js +14 -8
  4. package/esm/SchemaRenderer.d.ts +2 -13
  5. package/esm/SchemaRenderer.js +36 -72
  6. package/esm/Scoped.js +1 -1
  7. package/esm/StatusScoped.js +1 -1
  8. package/esm/StyleManager.js +1 -1
  9. package/esm/WithRootStore.d.ts +1 -1
  10. package/esm/WithRootStore.js +1 -1
  11. package/esm/WithStore.js +1 -1
  12. package/esm/actions/Action.js +1 -1
  13. package/esm/actions/AjaxAction.js +1 -1
  14. package/esm/actions/BreakAction.js +1 -1
  15. package/esm/actions/BroadcastAction.js +1 -1
  16. package/esm/actions/CmptAction.js +6 -2
  17. package/esm/actions/ContinueAction.js +1 -1
  18. package/esm/actions/CopyAction.js +1 -1
  19. package/esm/actions/CustomAction.js +1 -1
  20. package/esm/actions/DialogAction.js +1 -1
  21. package/esm/actions/DrawerAction.js +1 -1
  22. package/esm/actions/EmailAction.js +1 -1
  23. package/esm/actions/EventAction.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/PrintAction.js +1 -1
  29. package/esm/actions/StatusAction.js +1 -1
  30. package/esm/actions/SwitchAction.js +1 -1
  31. package/esm/actions/ToastAction.js +1 -1
  32. package/esm/actions/WaitAction.js +1 -1
  33. package/esm/components/Animations.d.ts +8 -0
  34. package/esm/components/Animations.js +158 -0
  35. package/esm/components/CustomStyle.js +1 -1
  36. package/esm/components/ErrorBoundary.js +1 -1
  37. package/esm/components/LazyComponent.d.ts +1 -1
  38. package/esm/components/LazyComponent.js +1 -1
  39. package/esm/components/Overlay.js +1 -1
  40. package/esm/components/PopOver.d.ts +1 -1
  41. package/esm/components/PopOver.js +1 -1
  42. package/esm/env.d.ts +1 -1
  43. package/esm/env.js +1 -1
  44. package/esm/envOverwrite.js +1 -1
  45. package/esm/factory.d.ts +1 -0
  46. package/esm/factory.js +1 -1
  47. package/esm/globalVar.d.ts +173 -0
  48. package/esm/globalVar.js +122 -0
  49. package/esm/globalVarClientHandler.d.ts +1 -0
  50. package/esm/globalVarClientHandler.js +65 -0
  51. package/esm/globalVarDefaultValueHandler.d.ts +1 -0
  52. package/esm/globalVarDefaultValueHandler.js +28 -0
  53. package/esm/index.d.ts +3 -0
  54. package/esm/index.js +8 -5
  55. package/esm/locale.d.ts +1 -1
  56. package/esm/locale.js +1 -1
  57. package/esm/polyfills.js +1 -1
  58. package/esm/renderers/Form.d.ts +3 -1
  59. package/esm/renderers/Form.js +39 -24
  60. package/esm/renderers/Item.d.ts +11 -17
  61. package/esm/renderers/Item.js +17 -2
  62. package/esm/renderers/Options.js +1 -1
  63. package/esm/renderers/Placeholder.js +1 -1
  64. package/esm/renderers/builtin.js +1 -1
  65. package/esm/renderers/register.js +1 -1
  66. package/esm/renderers/wrapControl.d.ts +1 -1
  67. package/esm/renderers/wrapControl.js +1 -1
  68. package/esm/store/app.js +1 -1
  69. package/esm/store/combo.js +1 -1
  70. package/esm/store/crud.d.ts +8 -0
  71. package/esm/store/crud.js +24 -17
  72. package/esm/store/form.js +14 -5
  73. package/esm/store/formItem.js +1 -1
  74. package/esm/store/iRenderer.js +1 -1
  75. package/esm/store/index.js +1 -1
  76. package/esm/store/list.d.ts +14 -1
  77. package/esm/store/list.js +45 -17
  78. package/esm/store/manager.js +1 -1
  79. package/esm/store/modal.js +1 -1
  80. package/esm/store/node.js +1 -1
  81. package/esm/store/pagination.js +1 -1
  82. package/esm/store/root.d.ts +14 -0
  83. package/esm/store/root.js +483 -12
  84. package/esm/store/service.js +1 -1
  85. package/esm/store/status.js +1 -1
  86. package/esm/store/table.d.ts +16 -2
  87. package/esm/store/table.js +83 -26
  88. package/esm/store/table2.js +1 -1
  89. package/esm/theme.d.ts +1 -1
  90. package/esm/theme.js +1 -1
  91. package/esm/types.d.ts +3 -2
  92. package/esm/utils/Animation.js +1 -1
  93. package/esm/utils/ColorScale.js +1 -1
  94. package/esm/utils/DataSchema.js +1 -1
  95. package/esm/utils/DataScope.js +1 -1
  96. package/esm/utils/RootClose.js +1 -1
  97. package/esm/utils/SimpleMap.js +1 -1
  98. package/esm/utils/animations.d.ts +4 -0
  99. package/esm/utils/animations.js +1 -1
  100. package/esm/utils/api.d.ts +1 -0
  101. package/esm/utils/api.js +18 -6
  102. package/esm/utils/arraySlice.js +1 -1
  103. package/esm/utils/attachmentAdpator.js +1 -1
  104. package/esm/utils/autobind.js +1 -1
  105. package/esm/utils/browser.js +1 -1
  106. package/esm/utils/columnsSplit.js +1 -1
  107. package/esm/utils/concatData.js +1 -1
  108. package/esm/utils/dataMapping.js +1 -1
  109. package/esm/utils/date.js +1 -1
  110. package/esm/utils/debug.js +1 -1
  111. package/esm/utils/decodeEntity.js +1 -1
  112. package/esm/utils/dom.js +1 -1
  113. package/esm/utils/errors.js +1 -1
  114. package/esm/utils/escapeHtml.js +1 -1
  115. package/esm/utils/filter-schema.js +1 -1
  116. package/esm/utils/filter.js +1 -1
  117. package/esm/utils/formatDuration.js +1 -1
  118. package/esm/utils/formula.js +1 -1
  119. package/esm/utils/getVariable.js +1 -1
  120. package/esm/utils/grammar.js +1 -1
  121. package/esm/utils/handleAction.js +1 -1
  122. package/esm/utils/helper.d.ts +5 -0
  123. package/esm/utils/helper.js +6 -2
  124. package/esm/utils/highlight.js +1 -1
  125. package/esm/utils/icon.js +1 -1
  126. package/esm/utils/image.js +1 -1
  127. package/esm/utils/isPureVariable.js +1 -1
  128. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  129. package/esm/utils/keyToPath.js +1 -1
  130. package/esm/utils/labelToString.js +1 -1
  131. package/esm/utils/loopTooMuch.js +1 -1
  132. package/esm/utils/makeSorter.js +1 -1
  133. package/esm/utils/math.js +1 -1
  134. package/esm/utils/memoryParse.js +1 -1
  135. package/esm/utils/normalizeLink.js +1 -1
  136. package/esm/utils/normalizeOptions.js +1 -1
  137. package/esm/utils/object.js +1 -1
  138. package/esm/utils/offset.js +1 -1
  139. package/esm/utils/offsetParent.js +1 -1
  140. package/esm/utils/optionValueCompare.js +1 -1
  141. package/esm/utils/position.js +1 -1
  142. package/esm/utils/prettyBytes.js +1 -1
  143. package/esm/utils/printElement.js +1 -1
  144. package/esm/utils/renderer-event.js +1 -1
  145. package/esm/utils/replaceText.js +1 -1
  146. package/esm/utils/resize-sensor.js +1 -1
  147. package/esm/utils/resolveCondition.js +1 -1
  148. package/esm/utils/resolveVariable.js +1 -1
  149. package/esm/utils/resolveVariableAndFilter.js +1 -1
  150. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  151. package/esm/utils/scrollPosition.js +1 -1
  152. package/esm/utils/string2regExp.js +1 -1
  153. package/esm/utils/stripNumber.js +1 -1
  154. package/esm/utils/style-helper.js +1 -1
  155. package/esm/utils/style.js +1 -1
  156. package/esm/utils/toNumber.js +1 -1
  157. package/esm/utils/tokenize.js +1 -1
  158. package/esm/utils/tpl-builtin.js +1 -1
  159. package/esm/utils/tpl-lodash.js +1 -1
  160. package/esm/utils/tpl.js +1 -1
  161. package/esm/utils/uncontrollable.js +1 -1
  162. package/esm/utils/validateId.js +1 -1
  163. package/esm/utils/validations.js +1 -1
  164. package/esm/utils/visitedCache.js +1 -1
  165. package/lib/Root.d.ts +3 -0
  166. package/lib/Root.js +1 -1
  167. package/lib/RootRenderer.d.ts +1 -1
  168. package/lib/RootRenderer.js +13 -7
  169. package/lib/SchemaRenderer.d.ts +2 -13
  170. package/lib/SchemaRenderer.js +35 -71
  171. package/lib/Scoped.js +1 -1
  172. package/lib/StatusScoped.js +1 -1
  173. package/lib/StyleManager.js +1 -1
  174. package/lib/WithRootStore.d.ts +1 -1
  175. package/lib/WithRootStore.js +1 -1
  176. package/lib/WithStore.js +1 -1
  177. package/lib/actions/Action.js +1 -1
  178. package/lib/actions/AjaxAction.js +1 -1
  179. package/lib/actions/BreakAction.js +1 -1
  180. package/lib/actions/BroadcastAction.js +1 -1
  181. package/lib/actions/CmptAction.js +6 -2
  182. package/lib/actions/ContinueAction.js +1 -1
  183. package/lib/actions/CopyAction.js +1 -1
  184. package/lib/actions/CustomAction.js +1 -1
  185. package/lib/actions/DialogAction.js +1 -1
  186. package/lib/actions/DrawerAction.js +1 -1
  187. package/lib/actions/EmailAction.js +1 -1
  188. package/lib/actions/EventAction.js +1 -1
  189. package/lib/actions/LinkAction.js +1 -1
  190. package/lib/actions/LoopAction.js +1 -1
  191. package/lib/actions/PageAction.js +1 -1
  192. package/lib/actions/ParallelAction.js +1 -1
  193. package/lib/actions/PrintAction.js +1 -1
  194. package/lib/actions/StatusAction.js +1 -1
  195. package/lib/actions/SwitchAction.js +1 -1
  196. package/lib/actions/ToastAction.js +1 -1
  197. package/lib/actions/WaitAction.js +1 -1
  198. package/lib/components/Animations.d.ts +8 -0
  199. package/lib/components/Animations.js +172 -0
  200. package/lib/components/CustomStyle.js +1 -1
  201. package/lib/components/ErrorBoundary.js +1 -1
  202. package/lib/components/LazyComponent.d.ts +1 -1
  203. package/lib/components/LazyComponent.js +1 -1
  204. package/lib/components/Overlay.js +1 -1
  205. package/lib/components/PopOver.d.ts +1 -1
  206. package/lib/components/PopOver.js +1 -1
  207. package/lib/env.d.ts +1 -1
  208. package/lib/env.js +1 -1
  209. package/lib/envOverwrite.js +1 -1
  210. package/lib/factory.d.ts +1 -0
  211. package/lib/factory.js +1 -1
  212. package/lib/globalVar.d.ts +173 -0
  213. package/lib/globalVar.js +130 -0
  214. package/lib/globalVarClientHandler.d.ts +1 -0
  215. package/lib/globalVarClientHandler.js +67 -0
  216. package/lib/globalVarDefaultValueHandler.d.ts +1 -0
  217. package/lib/globalVarDefaultValueHandler.js +30 -0
  218. package/lib/index.d.ts +3 -0
  219. package/lib/index.js +13 -4
  220. package/lib/locale.d.ts +1 -1
  221. package/lib/locale.js +1 -1
  222. package/lib/polyfills.js +1 -1
  223. package/lib/renderers/Form.d.ts +3 -1
  224. package/lib/renderers/Form.js +37 -21
  225. package/lib/renderers/Item.d.ts +11 -17
  226. package/lib/renderers/Item.js +17 -2
  227. package/lib/renderers/Options.js +1 -1
  228. package/lib/renderers/Placeholder.js +1 -1
  229. package/lib/renderers/builtin.js +1 -1
  230. package/lib/renderers/register.js +1 -1
  231. package/lib/renderers/wrapControl.d.ts +1 -1
  232. package/lib/renderers/wrapControl.js +1 -1
  233. package/lib/store/app.js +1 -1
  234. package/lib/store/combo.d.ts +24 -25
  235. package/lib/store/combo.js +1 -1
  236. package/lib/store/crud.d.ts +8 -0
  237. package/lib/store/crud.js +23 -16
  238. package/lib/store/form.d.ts +10 -11
  239. package/lib/store/form.js +14 -5
  240. package/lib/store/formItem.js +1 -1
  241. package/lib/store/iRenderer.js +1 -1
  242. package/lib/store/index.js +1 -1
  243. package/lib/store/list.d.ts +14 -1
  244. package/lib/store/list.js +44 -16
  245. package/lib/store/manager.js +1 -1
  246. package/lib/store/modal.js +1 -1
  247. package/lib/store/node.js +1 -1
  248. package/lib/store/pagination.js +1 -1
  249. package/lib/store/root.d.ts +13 -0
  250. package/lib/store/root.js +487 -11
  251. package/lib/store/service.js +1 -1
  252. package/lib/store/status.js +1 -1
  253. package/lib/store/table.d.ts +36 -23
  254. package/lib/store/table.js +82 -25
  255. package/lib/store/table2.js +1 -1
  256. package/lib/theme.d.ts +1 -1
  257. package/lib/theme.js +1 -1
  258. package/lib/types.d.ts +3 -2
  259. package/lib/utils/Animation.js +1 -1
  260. package/lib/utils/ColorScale.js +1 -1
  261. package/lib/utils/DataSchema.js +1 -1
  262. package/lib/utils/DataScope.js +1 -1
  263. package/lib/utils/RootClose.js +1 -1
  264. package/lib/utils/SimpleMap.js +1 -1
  265. package/lib/utils/animations.d.ts +4 -0
  266. package/lib/utils/animations.js +1 -1
  267. package/lib/utils/api.d.ts +1 -0
  268. package/lib/utils/api.js +18 -5
  269. package/lib/utils/arraySlice.js +1 -1
  270. package/lib/utils/attachmentAdpator.js +1 -1
  271. package/lib/utils/autobind.js +1 -1
  272. package/lib/utils/browser.js +1 -1
  273. package/lib/utils/columnsSplit.js +1 -1
  274. package/lib/utils/concatData.js +1 -1
  275. package/lib/utils/dataMapping.js +1 -1
  276. package/lib/utils/date.js +1 -1
  277. package/lib/utils/debug.js +1 -1
  278. package/lib/utils/decodeEntity.js +1 -1
  279. package/lib/utils/dom.js +1 -1
  280. package/lib/utils/errors.js +1 -1
  281. package/lib/utils/escapeHtml.js +1 -1
  282. package/lib/utils/filter-schema.js +1 -1
  283. package/lib/utils/filter.js +1 -1
  284. package/lib/utils/formatDuration.js +1 -1
  285. package/lib/utils/formula.js +1 -1
  286. package/lib/utils/getVariable.js +1 -1
  287. package/lib/utils/grammar.js +1 -1
  288. package/lib/utils/handleAction.js +1 -1
  289. package/lib/utils/helper.d.ts +5 -0
  290. package/lib/utils/helper.js +6 -2
  291. package/lib/utils/highlight.js +1 -1
  292. package/lib/utils/icon.js +1 -1
  293. package/lib/utils/image.js +1 -1
  294. package/lib/utils/isPureVariable.js +1 -1
  295. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  296. package/lib/utils/keyToPath.js +1 -1
  297. package/lib/utils/labelToString.js +1 -1
  298. package/lib/utils/loopTooMuch.js +1 -1
  299. package/lib/utils/makeSorter.js +1 -1
  300. package/lib/utils/math.js +1 -1
  301. package/lib/utils/memoryParse.js +1 -1
  302. package/lib/utils/normalizeLink.js +1 -1
  303. package/lib/utils/normalizeOptions.js +1 -1
  304. package/lib/utils/object.js +1 -1
  305. package/lib/utils/offset.js +1 -1
  306. package/lib/utils/offsetParent.js +1 -1
  307. package/lib/utils/optionValueCompare.js +1 -1
  308. package/lib/utils/position.js +1 -1
  309. package/lib/utils/prettyBytes.js +1 -1
  310. package/lib/utils/printElement.js +1 -1
  311. package/lib/utils/renderer-event.js +1 -1
  312. package/lib/utils/replaceText.js +1 -1
  313. package/lib/utils/resize-sensor.js +1 -1
  314. package/lib/utils/resolveCondition.js +1 -1
  315. package/lib/utils/resolveVariable.js +1 -1
  316. package/lib/utils/resolveVariableAndFilter.js +1 -1
  317. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  318. package/lib/utils/scrollPosition.js +1 -1
  319. package/lib/utils/string2regExp.js +1 -1
  320. package/lib/utils/stripNumber.js +1 -1
  321. package/lib/utils/style-helper.js +1 -1
  322. package/lib/utils/style.js +1 -1
  323. package/lib/utils/toNumber.js +1 -1
  324. package/lib/utils/tokenize.js +1 -1
  325. package/lib/utils/tpl-builtin.js +1 -1
  326. package/lib/utils/tpl-lodash.js +1 -1
  327. package/lib/utils/tpl.js +1 -1
  328. package/lib/utils/uncontrollable.js +1 -1
  329. package/lib/utils/validateId.js +1 -1
  330. package/lib/utils/validations.js +1 -1
  331. package/lib/utils/visitedCache.js +1 -1
  332. package/package.json +2 -2
package/esm/store/root.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * amis-core v6.11.0-beta.0
2
+ * amis-core v6.11.0-beta.2
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
6
- import { __assign, __generator } from 'tslib';
6
+ import { __assign, __generator, __values, __awaiter, __read } from 'tslib';
7
7
  import { types, flow } from 'mobx-state-tree';
8
8
  import { parseQuery, isObjectShallowModified } from '../utils/helper.js';
9
9
  import { ServiceStore } from './service.js';
@@ -15,7 +15,7 @@ import 'lodash/chunk';
15
15
  import { extractObjectChain, createObjectFromChain } from '../utils/object.js';
16
16
  import '../utils/memoryParse.js';
17
17
  import 'amis-formula';
18
- import 'lodash/isPlainObject';
18
+ import isPlainObject from 'lodash/isPlainObject';
19
19
  import '../utils/DataSchema.js';
20
20
  import '../utils/DataScope.js';
21
21
  import 'moment';
@@ -31,7 +31,7 @@ import '@rc-component/mini-decimal';
31
31
  import '../utils/image.js';
32
32
  import 'lodash/isEqual';
33
33
  import '../actions/Action.js';
34
- import 'lodash/debounce';
34
+ import debounce from 'lodash/debounce';
35
35
  import '../utils/resize-sensor.js';
36
36
  import 'react-overlays/useRootClose';
37
37
  import '../utils/SimpleMap.js';
@@ -47,24 +47,65 @@ import '../utils/validations.js';
47
47
  import '../utils/resolveCondition.js';
48
48
  import 'mobx';
49
49
  import '../utils/Animation.js';
50
+ import { createGlobalVarState, buildGlobalVariable } from '../globalVar.js';
50
51
 
51
52
  var RootStore = ServiceStore.named('RootStore')
52
53
  .props({
53
54
  runtimeError: types.frozen(),
54
55
  runtimeErrorStack: types.frozen(),
55
56
  query: types.frozen(),
56
- ready: false
57
+ ready: false,
58
+ globalVarStates: types.optional(types.map(types.frozen()), {})
57
59
  })
58
60
  .volatile(function (self) {
59
61
  return {
60
- context: {}
62
+ context: {},
63
+ globalVars: [],
64
+ globalData: {
65
+ global: {},
66
+ globalState: {}
67
+ }
61
68
  };
62
69
  })
63
70
  .views(function (self) { return ({
64
71
  get downStream() {
65
72
  var result = self.data;
66
- if (self.context || self.query) {
73
+ if (self.context || self.query || self.globalVarStates.size) {
67
74
  var chain = extractObjectChain(result);
75
+ // 数据链中添加 global 和 globalState
76
+ // 对应的是全局变量的值和全局变量的状态
77
+ if (self.globalVarStates.size) {
78
+ var globalData_1 = {};
79
+ var touched_1 = false;
80
+ var saved_1 = true;
81
+ var errors_1 = {};
82
+ var initialized_1 = true;
83
+ self.globalVarStates.forEach(function (state, key) {
84
+ globalData_1[key] = state.value;
85
+ touched_1 = touched_1 || state.touched;
86
+ if (!state.saved) {
87
+ saved_1 = false;
88
+ }
89
+ if (state.errorMessages.length) {
90
+ errors_1[key] = state.errorMessages;
91
+ }
92
+ if (!state.initialized) {
93
+ initialized_1 = false;
94
+ }
95
+ });
96
+ // 保存全局变量的值和状态
97
+ Object.assign(self.globalData.global, globalData_1);
98
+ Object.assign(self.globalData.globalState, {
99
+ fields: self.globalVarStates.toJSON(),
100
+ initialized: initialized_1,
101
+ touched: touched_1,
102
+ saved: saved_1,
103
+ errors: errors_1,
104
+ valid: !Object.keys(errors_1).length
105
+ });
106
+ // self.globalData 一直都是那个对象,这样组件里面始终拿到的都是最新的
107
+ chain.unshift(self.globalData);
108
+ }
68
109
  self.context && chain.unshift(self.context);
69
110
  self.query &&
70
111
  chain.splice(chain.length - 1, 0, __assign(__assign({}, self.query), { __query: self.query }));
@@ -74,32 +115,459 @@ var RootStore = ServiceStore.named('RootStore')
74
115
  }
75
116
  }); })
76
117
  .actions(function (self) {
118
+ function updateState(key, state) {
119
+ return self.updateGlobalVarState(key, state);
120
+ }
77
121
  var init = flow(function init(fn) {
78
- var ret;
122
+ var ret, e_1;
79
123
  return __generator(this, function (_a) {
80
124
  switch (_a.label) {
81
125
  case 0:
82
- _a.trys.push([0, , 3, 4]);
126
+ _a.trys.push([0, 3, 4, 5]);
83
127
  ret = fn();
84
128
  if (!(ret === null || ret === void 0 ? void 0 : ret.then)) return [3 /*break*/, 2];
85
129
  return [4 /*yield*/, ret];
86
130
  case 1:
87
131
  _a.sent();
88
132
  _a.label = 2;
89
- case 2: return [3 /*break*/, 4];
133
+ case 2: return [3 /*break*/, 5];
90
134
  case 3:
135
+ e_1 = _a.sent();
136
+ self.runtimeError = e_1.message;
137
+ self.runtimeErrorStack = e_1.stack;
138
+ return [3 /*break*/, 5];
139
+ case 4:
91
140
  self.ready = true;
92
141
  return [7 /*endfinally*/];
93
- case 4: return [2 /*return*/];
142
+ case 5: return [2 /*return*/];
94
143
  }
95
144
  });
96
145
  });
146
+ /**
147
+ * 比较新旧变量列表的差异
148
+ * @param vars 新的变量列表
149
+ * @param originVars 原始变量列表
150
+ * @returns 返回新增、更新和删除的变量列表
151
+ */
152
+ function diffVariables(vars, originVars) {
153
+ var e_2, _a;
154
+ var removeVars = originVars.concat();
155
+ var updateVars = [];
156
+ var newVars = [];
157
+ var _loop_1 = function (varItem) {
158
+ var idx = removeVars.findIndex(function (item) { return item.key === varItem.key; });
159
+ if (~idx) {
160
+ var _b = __read(removeVars.splice(idx, 1), 1), origin_1 = _b[0];
161
+ if (origin_1.id !== varItem.id) {
162
+ updateVars.push(varItem);
163
+ }
164
+ }
165
+ else {
166
+ newVars.push(varItem);
167
+ }
168
+ };
169
+ try {
170
+ for (var vars_1 = __values(vars), vars_1_1 = vars_1.next(); !vars_1_1.done; vars_1_1 = vars_1.next()) {
171
+ var varItem = vars_1_1.value;
172
+ _loop_1(varItem);
173
+ }
174
+ }
175
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
176
+ finally {
177
+ try {
178
+ if (vars_1_1 && !vars_1_1.done && (_a = vars_1.return)) _a.call(vars_1);
179
+ }
180
+ finally { if (e_2) throw e_2.error; }
181
+ }
182
+ return {
183
+ newVars: newVars,
184
+ updateVars: updateVars,
185
+ removeVars: removeVars
186
+ };
187
+ }
188
+ /**
189
+ * 初始化单个全局变量
190
+ */
191
+ function initGlobalVarData(item, context, getter) {
192
+ return __awaiter(this, void 0, void 0, function () {
193
+ var value, state;
194
+ return __generator(this, function (_a) {
195
+ switch (_a.label) {
196
+ case 0:
197
+ value = item.defaultValue;
198
+ if (!getter) return [3 /*break*/, 2];
199
+ return [4 /*yield*/, getGlobalVarData(item, context, getter)];
200
+ case 1:
201
+ _a.sent();
202
+ state = self.globalVarStates.get(item.key);
203
+ updateState(item.key, {
204
+ initialized: true,
205
+ pristine: state.value
206
+ });
207
+ return [3 /*break*/, 3];
208
+ case 2:
209
+ updateState(item.key, {
210
+ value: value,
211
+ pristine: value,
212
+ initialized: item.bulkGetter ? false : true
213
+ });
214
+ _a.label = 3;
215
+ case 3: return [2 /*return*/];
216
+ }
217
+ });
218
+ });
219
+ }
220
+ /**
221
+ * 批量初始化全局变量
222
+ */
223
+ function getGlobalVarData(item, context, getter) {
224
+ return __awaiter(this, void 0, void 0, function () {
225
+ var value;
226
+ return __generator(this, function (_a) {
227
+ switch (_a.label) {
228
+ case 0:
229
+ _a.trys.push([0, , 2, 3]);
230
+ updateState(item.key, {
231
+ busy: true
232
+ });
233
+ return [4 /*yield*/, getter(item, context)];
234
+ case 1:
235
+ value = _a.sent();
236
+ updateState(item.key, {
237
+ value: value
238
+ });
239
+ return [3 /*break*/, 3];
240
+ case 2:
241
+ updateState(item.key, {
242
+ busy: false
243
+ });
244
+ return [7 /*endfinally*/];
245
+ case 3: return [2 /*return*/];
246
+ }
247
+ });
248
+ });
249
+ }
250
+ /**
251
+ * 批量初始化全局变量
252
+ */
253
+ function bulkGetGlobalVarData(variables, context, getter) {
254
+ return __awaiter(this, void 0, void 0, function () {
255
+ var data, _loop_2, key;
256
+ return __generator(this, function (_a) {
257
+ switch (_a.label) {
258
+ case 0:
259
+ _a.trys.push([0, , 2, 3]);
260
+ variables.forEach(function (item) {
261
+ updateState(item.key, {
262
+ busy: true
263
+ });
264
+ });
265
+ return [4 /*yield*/, getter.call(null, __assign(__assign({}, context), { variables: variables }))];
266
+ case 1:
267
+ data = _a.sent();
268
+ if (!isPlainObject(data)) {
269
+ return [2 /*return*/];
270
+ }
271
+ _loop_2 = function (key) {
272
+ // 返回非定义部分的数据不处理
273
+ if (!variables.some(function (item) { return item.key === key; })) {
274
+ return "continue";
275
+ }
276
+ var state = self.globalVarStates.get(key);
277
+ if (state) {
278
+ updateState(key, {
279
+ value: data[key],
280
+ pristine: data[key],
281
+ initialized: true
282
+ });
283
+ }
284
+ };
285
+ for (key in data) {
286
+ _loop_2(key);
287
+ }
288
+ return [3 /*break*/, 3];
289
+ case 2:
290
+ variables.forEach(function (item) {
291
+ updateState(item.key, {
292
+ busy: false
293
+ });
294
+ });
295
+ return [7 /*endfinally*/];
296
+ case 3: return [2 /*return*/];
297
+ }
298
+ });
299
+ });
300
+ }
301
+ /**
302
+ * 初始化全局变量
303
+ */
304
+ function initializeGlobalVars(newVars, updateVars) {
305
+ return __awaiter(this, void 0, void 0, function () {
306
+ var variables, context, globalVars, bulkGetters, itemsNotInitialized, _loop_3, globalVars_1, globalVars_1_1, item;
307
+ var e_3, _a;
308
+ return __generator(this, function (_b) {
309
+ switch (_b.label) {
310
+ case 0:
311
+ variables = newVars.concat(updateVars);
312
+ context = __assign(__assign({}, self.context), { variables: variables });
313
+ globalVars = variables.map(function (item) {
314
+ return buildGlobalVariable(item, context);
315
+ });
316
+ bulkGetters = [];
317
+ itemsNotInitialized = [];
318
+ _loop_3 = function (item) {
319
+ var state = self.globalVarStates.get(item.key);
320
+ if (state === null || state === void 0 ? void 0 : state.initialized) {
321
+ return "continue";
322
+ }
323
+ itemsNotInitialized.push(item);
324
+ if (item.bulkGetter) {
325
+ var getter = bulkGetters.find(function (a) { return a.fn === item.bulkGetter; });
326
+ if (!getter) {
327
+ getter = {
328
+ fn: item.bulkGetter,
329
+ variables: []
330
+ };
331
+ bulkGetters.push(getter);
332
+ }
333
+ getter.variables.push(item);
334
+ }
335
+ };
336
+ try {
337
+ for (globalVars_1 = __values(globalVars), globalVars_1_1 = globalVars_1.next(); !globalVars_1_1.done; globalVars_1_1 = globalVars_1.next()) {
338
+ item = globalVars_1_1.value;
339
+ _loop_3(item);
340
+ }
341
+ }
342
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
343
+ finally {
344
+ try {
345
+ if (globalVars_1_1 && !globalVars_1_1.done && (_a = globalVars_1.return)) _a.call(globalVars_1);
346
+ }
347
+ finally { if (e_3) throw e_3.error; }
348
+ }
349
+ // 先单个初始化
350
+ return [4 /*yield*/, Promise.all(itemsNotInitialized.map(function (item) {
351
+ return initGlobalVarData(item, context, item.getter);
352
+ }))];
353
+ case 1:
354
+ // 先单个初始化
355
+ _b.sent();
356
+ // 再批量初始化
357
+ return [4 /*yield*/, Promise.all(bulkGetters.map(function (_a) {
358
+ var fn = _a.fn, variables = _a.variables;
359
+ return bulkGetGlobalVarData(variables, context, fn);
360
+ }))];
361
+ case 2:
362
+ // 再批量初始化
363
+ _b.sent();
364
+ return [2 /*return*/, globalVars];
365
+ }
366
+ });
367
+ });
368
+ }
369
+ // 设置全局变量,返回一个Promise
370
+ var setGlobalVars = flow(function setGlobalVars(vars) {
371
+ var _a, newVars, updateVars, removeVars, _b;
372
+ return __generator(this, function (_c) {
373
+ switch (_c.label) {
374
+ case 0:
375
+ _a = diffVariables(vars || [], self.globalVars), newVars = _a.newVars, updateVars = _a.updateVars, removeVars = _a.removeVars;
376
+ // 初始化全局变量
377
+ _b = self;
378
+ return [4 /*yield*/, initializeGlobalVars(newVars, updateVars)];
379
+ case 1:
380
+ // 初始化全局变量
381
+ _b.globalVars = _c.sent();
382
+ removeVars.forEach(function (item) {
383
+ self.globalVarStates.delete(item.key);
384
+ });
385
+ return [2 /*return*/];
386
+ }
387
+ });
388
+ });
389
+ // 更新全局变量的值
390
+ var updateGlobalVarValue = function (key, value) {
391
+ return modifyGlobalVarValue(key, { op: 'set', value: value });
392
+ };
393
+ // 如果对应变量是个对象,那么可以通过这个扩充变量的值
394
+ var modifyGlobalVarValue = function (key, options) {
395
+ var state = self.globalVarStates.get(key);
396
+ if (!state) {
397
+ return;
398
+ }
399
+ var value = state.value;
400
+ switch (options.op) {
401
+ case 'set':
402
+ value = options.value;
403
+ break;
404
+ }
405
+ updateState(key, {
406
+ value: value,
407
+ touched: true
408
+ });
409
+ lazySaveGlobalVarValues();
410
+ };
411
+ /**
412
+ * 保存单个全局变量的值
413
+ */
414
+ function saveGlobalVarData(item, value, context, setter) {
415
+ return __awaiter(this, void 0, void 0, function () {
416
+ return __generator(this, function (_a) {
417
+ switch (_a.label) {
418
+ case 0:
419
+ _a.trys.push([0, , 2, 3]);
420
+ updateState(item.key, {
421
+ busy: true
422
+ });
423
+ return [4 /*yield*/, setter(item, value, context)];
424
+ case 1:
425
+ _a.sent();
426
+ updateState(item.key, {
427
+ saved: true
428
+ });
429
+ return [3 /*break*/, 3];
430
+ case 2:
431
+ updateState(item.key, {
432
+ busy: false
433
+ });
434
+ return [7 /*endfinally*/];
435
+ case 3: return [2 /*return*/];
436
+ }
437
+ });
438
+ });
439
+ }
440
+ /**
441
+ * 批量保存全局变量
442
+ */
443
+ function bulkSaveGlobalVarData(variables, values, context, setter) {
444
+ return __awaiter(this, void 0, void 0, function () {
445
+ return __generator(this, function (_a) {
446
+ switch (_a.label) {
447
+ case 0:
448
+ _a.trys.push([0, , 2, 3]);
449
+ variables.forEach(function (item) {
450
+ updateState(item.key, {
451
+ busy: true
452
+ });
453
+ });
454
+ return [4 /*yield*/, setter(values, __assign(__assign({}, context), { variables: variables }))];
455
+ case 1:
456
+ _a.sent();
457
+ variables.forEach(function (item) {
458
+ updateState(item.key, {
459
+ saved: true
460
+ });
461
+ });
462
+ return [3 /*break*/, 3];
463
+ case 2:
464
+ variables.forEach(function (item) {
465
+ updateState(item.key, {
466
+ busy: false
467
+ });
468
+ });
469
+ return [7 /*endfinally*/];
470
+ case 3: return [2 /*return*/];
471
+ }
472
+ });
473
+ });
474
+ }
475
+ /**
476
+ * 保存全局变量的值
477
+ */
478
+ function saveGlobalVarValues(key) {
479
+ return __awaiter(this, void 0, void 0, function () {
480
+ var context, setters, bulkSetters, values, _loop_4, _a, _b, varItem;
481
+ var e_4, _c;
482
+ return __generator(this, function (_d) {
483
+ switch (_d.label) {
484
+ case 0:
485
+ context = __assign(__assign({}, self.context), { variables: self.globalVars });
486
+ setters = [];
487
+ bulkSetters = [];
488
+ values = {};
489
+ _loop_4 = function (varItem) {
490
+ var state = self.globalVarStates.get(varItem.key);
491
+ if (!(state === null || state === void 0 ? void 0 : state.touched)) {
492
+ return "continue";
493
+ }
494
+ else if (key && key !== varItem.key) {
495
+ return "continue";
496
+ }
497
+ else if (!key && varItem.autoSave === false) {
498
+ return "continue";
499
+ }
500
+ values[varItem.key] = state.value;
501
+ if (varItem.setter) {
502
+ setters.push({
503
+ fn: varItem.setter,
504
+ item: varItem,
505
+ value: state.value
506
+ });
507
+ }
508
+ if (varItem.bulkSetter) {
509
+ var setter = bulkSetters.find(function (a) { return a.fn === varItem.bulkSetter; });
510
+ if (!setter) {
511
+ setter = {
512
+ fn: varItem.bulkSetter,
513
+ variables: [],
514
+ values: {}
515
+ };
516
+ bulkSetters.push(setter);
517
+ }
518
+ setter.variables.push(varItem);
519
+ setter.values[varItem.key] = state.value;
520
+ }
521
+ };
522
+ try {
523
+ for (_a = __values(self.globalVars), _b = _a.next(); !_b.done; _b = _a.next()) {
524
+ varItem = _b.value;
525
+ _loop_4(varItem);
526
+ }
527
+ }
528
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
529
+ finally {
530
+ try {
531
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
532
+ }
533
+ finally { if (e_4) throw e_4.error; }
534
+ }
535
+ return [4 /*yield*/, Promise.all(setters
536
+ .map(function (_a) {
537
+ var fn = _a.fn, item = _a.item, value = _a.value;
538
+ return saveGlobalVarData(item, value, context, fn);
539
+ })
540
+ .concat(bulkSetters.map(function (_a) {
541
+ var variables = _a.variables, values = _a.values, fn = _a.fn;
542
+ return bulkSaveGlobalVarData(variables, values, context, fn);
543
+ })))];
544
+ case 1:
545
+ _d.sent();
546
+ return [2 /*return*/];
547
+ }
548
+ });
549
+ });
550
+ }
551
+ // 延迟保存全局变量的值
552
+ var lazySaveGlobalVarValues = debounce(saveGlobalVarValues, 250, {
553
+ trailing: true,
554
+ leading: false
555
+ });
97
556
  return {
98
557
  updateContext: function (context) {
99
558
  // 因为 context 不是受控属性,直接共用引用好了
100
559
  // 否则还会触发孩子节点的重新渲染
101
560
  Object.assign(self.context, context);
102
561
  },
562
+ updateGlobalVarState: function (key, state) {
563
+ var origin = self.globalVarStates.get(key);
564
+ var newState = __assign(__assign({}, (origin || createGlobalVarState())), state);
565
+ self.globalVarStates.set(key, newState);
566
+ },
567
+ setGlobalVars: setGlobalVars,
568
+ updateGlobalVarValue: updateGlobalVarValue,
569
+ modifyGlobalVarValue: modifyGlobalVarValue,
570
+ saveGlobalVarValues: lazySaveGlobalVarValues,
103
571
  setRuntimeError: function (error, errorStack) {
104
572
  self.runtimeError = error;
105
573
  self.runtimeErrorStack = errorStack;
@@ -110,7 +578,10 @@ var RootStore = ServiceStore.named('RootStore')
110
578
  self.query = query;
111
579
  }
112
580
  },
113
- init: init
581
+ init: init,
582
+ afterDestroy: function () {
583
+ lazySaveGlobalVarValues.flush();
584
+ }
114
585
  };
115
586
  });
116
587
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.11.0-beta.0
2
+ * amis-core v6.11.0-beta.2
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.11.0-beta.0
2
+ * amis-core v6.11.0-beta.2
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -225,6 +225,8 @@ export declare const TableStore: import("mobx-state-tree").IModelType<{
225
225
  resetDefered(): void;
226
226
  updateData({ children, ...rest }: any): void;
227
227
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
228
+ fullItems: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<any, any, any>>, [undefined]>;
229
+ fullSelectedItems: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<any, any, any>>, [undefined]>;
228
230
  selectedRows: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IReferenceType<import("mobx-state-tree").IModelType<{
229
231
  storeType: import("mobx-state-tree").IType<string | undefined, string, string>;
230
232
  id: import("mobx-state-tree").ISimpleType<string>;
@@ -295,6 +297,7 @@ export declare const TableStore: import("mobx-state-tree").IModelType<{
295
297
  draggable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
296
298
  dragging: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
297
299
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
300
+ showIndex: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
298
301
  multiple: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
299
302
  footable: import("mobx-state-tree").IType<any, any, any>;
300
303
  expandConfig: import("mobx-state-tree").IType<any, any, any>;
@@ -12811,7 +12814,7 @@ export declare const TableStore: import("mobx-state-tree").IModelType<{
12811
12814
  /** 已选择item是否达到数量上限 */
12812
12815
  readonly isSelectionThresholdReached: boolean;
12813
12816
  readonly firstToggledColumnIndex: number | null;
12814
- getData: (superData: any) => any;
12817
+ getData(superData: any): any;
12815
12818
  readonly columnGroup: {
12816
12819
  rowSpan: number;
12817
12820
  label: any;
@@ -13234,6 +13237,17 @@ export declare const TableStore: import("mobx-state-tree").IModelType<{
13234
13237
  updateData({ children, ...rest }: any): void;
13235
13238
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>)[];
13236
13239
  buildStyles(style: any): any;
13240
+ /**
13241
+ * 构建事件的上下文数据
13242
+ * @param buildChain
13243
+ * @returns
13244
+ */
13245
+ readonly eventContext: {
13246
+ selectedItems: any[];
13247
+ selectedIndexes: string[];
13248
+ items: any[];
13249
+ unSelectedItems: any[];
13250
+ };
13237
13251
  } & {
13238
13252
  setTable: (ref: HTMLElement | null) => void;
13239
13253
  getTable: () => HTMLElement | null;
@@ -13243,7 +13257,7 @@ export declare const TableStore: import("mobx-state-tree").IModelType<{
13243
13257
  updateColumns: (columns: Array<SColumn>) => void;
13244
13258
  initTableWidth: () => void;
13245
13259
  syncTableWidth: () => void;
13246
- initRows: (rows: Array<any>, getEntryId?: ((entry: any, index: number) => string) | undefined, reUseRow?: boolean | 'match') => void;
13260
+ initRows: (rows: Array<any>, getEntryId?: ((entry: any, index: number) => string) | undefined, reUseRow?: boolean | 'match', fullItems?: Array<any>, fullSelectedItems?: Array<any>) => void;
13247
13261
  updateSelected: (selected: Array<any>, valueField?: string) => void;
13248
13262
  toggleAll: () => void;
13249
13263
  getSelectedRows: () => ({