amis-core 2.9.0 → 3.1.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 (331) hide show
  1. package/esm/Root.d.ts +89 -4
  2. package/esm/Root.js +15 -4
  3. package/esm/RootRenderer.d.ts +3 -1
  4. package/esm/RootRenderer.js +9 -3
  5. package/esm/SchemaRenderer.d.ts +4 -2
  6. package/esm/SchemaRenderer.js +32 -24
  7. package/esm/Scoped.d.ts +8 -0
  8. package/esm/Scoped.js +20 -5
  9. package/esm/StatusScoped.d.ts +58 -0
  10. package/esm/StatusScoped.js +54 -0
  11. package/esm/WithRootStore.d.ts +2 -2
  12. package/esm/WithRootStore.js +1 -1
  13. package/esm/WithStore.js +6 -2
  14. package/esm/actions/Action.d.ts +1 -0
  15. package/esm/actions/Action.js +19 -5
  16. package/esm/actions/AjaxAction.js +1 -1
  17. package/esm/actions/BreakAction.js +1 -1
  18. package/esm/actions/BroadcastAction.js +1 -1
  19. package/esm/actions/CmptAction.js +8 -7
  20. package/esm/actions/ContinueAction.js +1 -1
  21. package/esm/actions/CopyAction.js +1 -1
  22. package/esm/actions/CustomAction.js +4 -4
  23. package/esm/actions/DialogAction.d.ts +16 -2
  24. package/esm/actions/DialogAction.js +23 -7
  25. package/esm/actions/DrawerAction.js +1 -1
  26. package/esm/actions/EmailAction.js +1 -1
  27. package/esm/actions/LinkAction.js +1 -1
  28. package/esm/actions/LoopAction.js +1 -1
  29. package/esm/actions/PageAction.js +1 -1
  30. package/esm/actions/ParallelAction.js +1 -1
  31. package/esm/actions/SwitchAction.js +1 -1
  32. package/esm/actions/ToastAction.js +1 -1
  33. package/esm/components/CustomStyle.d.ts +13 -0
  34. package/esm/components/CustomStyle.js +18 -0
  35. package/esm/components/LazyComponent.d.ts +1 -1
  36. package/esm/components/LazyComponent.js +1 -1
  37. package/esm/components/Overlay.d.ts +3 -3
  38. package/esm/components/Overlay.js +1 -1
  39. package/esm/components/PopOver.d.ts +2 -2
  40. package/esm/components/PopOver.js +1 -1
  41. package/esm/env.d.ts +10 -2
  42. package/esm/env.js +1 -1
  43. package/esm/envOverwrite.js +1 -5
  44. package/esm/factory.d.ts +5 -3
  45. package/esm/factory.js +3 -3
  46. package/esm/index.d.ts +11 -4
  47. package/esm/index.js +55 -33
  48. package/esm/locale.d.ts +2 -2
  49. package/esm/locale.js +10 -3
  50. package/esm/renderers/Form.d.ts +3 -2
  51. package/esm/renderers/Form.js +216 -180
  52. package/esm/renderers/Item.d.ts +55 -41
  53. package/esm/renderers/Item.js +30 -19
  54. package/esm/renderers/Options.js +11 -4
  55. package/esm/renderers/Placeholder.js +1 -1
  56. package/esm/renderers/builtin.js +1 -1
  57. package/esm/renderers/register.js +1 -1
  58. package/esm/renderers/wrapControl.d.ts +2 -2
  59. package/esm/renderers/wrapControl.js +13 -16
  60. package/esm/store/app.d.ts +1 -0
  61. package/esm/store/app.js +1 -1
  62. package/esm/store/combo.d.ts +3 -0
  63. package/esm/store/combo.js +1 -1
  64. package/esm/store/crud.d.ts +2 -0
  65. package/esm/store/crud.js +31 -9
  66. package/esm/store/form.d.ts +1 -0
  67. package/esm/store/form.js +10 -4
  68. package/esm/store/formItem.js +2 -2
  69. package/esm/store/iRenderer.d.ts +1 -0
  70. package/esm/store/iRenderer.js +54 -13
  71. package/esm/store/index.js +1 -1
  72. package/esm/store/list.d.ts +1 -0
  73. package/esm/store/list.js +7 -3
  74. package/esm/store/manager.js +1 -1
  75. package/esm/store/modal.d.ts +1 -0
  76. package/esm/store/modal.js +1 -1
  77. package/esm/store/node.js +1 -1
  78. package/esm/store/pagination.d.ts +1 -0
  79. package/esm/store/pagination.js +2 -2
  80. package/esm/store/root.d.ts +4 -6
  81. package/esm/store/root.js +53 -24
  82. package/esm/store/service.d.ts +1 -0
  83. package/esm/store/service.js +1 -1
  84. package/esm/store/status.d.ts +12 -0
  85. package/esm/store/status.js +38 -0
  86. package/esm/store/table.d.ts +28 -23
  87. package/esm/store/table.js +26 -5
  88. package/esm/store/table2.d.ts +7 -6
  89. package/esm/store/table2.js +27 -23
  90. package/esm/theme.d.ts +1 -1
  91. package/esm/theme.js +1 -1
  92. package/esm/types.d.ts +7 -1
  93. package/esm/utils/Animation.js +1 -1
  94. package/esm/utils/ColorScale.js +1 -1
  95. package/esm/utils/DataSchema.js +1 -1
  96. package/esm/utils/DataScope.d.ts +3 -5
  97. package/esm/utils/DataScope.js +88 -31
  98. package/esm/utils/RootClose.js +1 -1
  99. package/esm/utils/SimpleMap.js +1 -1
  100. package/esm/utils/api.js +14 -5
  101. package/esm/utils/attachmentAdpator.js +2 -2
  102. package/esm/utils/autobind.js +1 -1
  103. package/esm/utils/columnsSplit.js +1 -1
  104. package/esm/utils/dataMapping.js +1 -1
  105. package/esm/utils/date.d.ts +7 -0
  106. package/esm/utils/date.js +34 -2
  107. package/esm/utils/debug.js +4 -4
  108. package/esm/utils/decodeEntity.js +1 -1
  109. package/esm/utils/dom.d.ts +3 -0
  110. package/esm/utils/dom.js +47 -10
  111. package/esm/utils/errors.js +1 -1
  112. package/esm/utils/escapeHtml.js +1 -1
  113. package/esm/utils/filter-schema.js +1 -1
  114. package/esm/utils/filter.js +1 -1
  115. package/esm/utils/formatDuration.js +1 -1
  116. package/esm/utils/formula.js +2 -2
  117. package/esm/utils/getVariable.js +1 -1
  118. package/esm/utils/grammar.js +3 -3
  119. package/esm/utils/handleAction.js +1 -1
  120. package/esm/utils/helper.d.ts +9 -2
  121. package/esm/utils/helper.js +52 -20
  122. package/esm/utils/highlight.js +1 -1
  123. package/esm/utils/icon.d.ts +6 -1
  124. package/esm/utils/icon.js +6 -1
  125. package/esm/utils/image.js +1 -1
  126. package/esm/utils/isPureVariable.js +3 -3
  127. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  128. package/esm/utils/keyToPath.js +1 -1
  129. package/esm/utils/makeSorter.js +1 -1
  130. package/esm/utils/memoryParse.d.ts +17 -0
  131. package/esm/utils/memoryParse.js +26 -0
  132. package/esm/utils/normalizeLink.js +1 -1
  133. package/esm/utils/normalizeOptions.js +4 -2
  134. package/esm/utils/object.d.ts +2 -0
  135. package/esm/utils/object.js +27 -2
  136. package/esm/utils/offset.js +1 -1
  137. package/esm/utils/offsetParent.js +1 -1
  138. package/esm/utils/optionValueCompare.js +1 -1
  139. package/esm/utils/position.js +1 -1
  140. package/esm/utils/prettyBytes.js +1 -1
  141. package/esm/utils/renderer-event.js +35 -32
  142. package/esm/utils/replaceText.js +1 -1
  143. package/esm/utils/resize-sensor.js +1 -1
  144. package/esm/utils/resolveCondition.d.ts +1 -0
  145. package/esm/utils/resolveCondition.js +19 -4
  146. package/esm/utils/resolveVariable.js +4 -3
  147. package/esm/utils/resolveVariableAndFilter.js +1 -1
  148. package/esm/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  149. package/esm/utils/resolveVariableAndFilterForAsync.js +23 -5
  150. package/esm/utils/scrollPosition.js +1 -1
  151. package/esm/utils/string2regExp.js +1 -1
  152. package/esm/utils/stripNumber.js +1 -1
  153. package/esm/utils/style-helper.d.ts +12 -4
  154. package/esm/utils/style-helper.js +96 -19
  155. package/esm/utils/style.js +2 -2
  156. package/esm/utils/toNumber.js +1 -1
  157. package/esm/utils/tokenize.js +1 -1
  158. package/esm/utils/tpl-builtin.d.ts +2 -1
  159. package/esm/utils/tpl-builtin.js +19 -2
  160. package/esm/utils/tpl-lodash.js +3 -2
  161. package/esm/utils/tpl.d.ts +2 -0
  162. package/esm/utils/tpl.js +24 -2
  163. package/esm/utils/uncontrollable.js +1 -1
  164. package/esm/utils/validations.d.ts +4 -1
  165. package/esm/utils/validations.js +27 -12
  166. package/lib/Root.d.ts +89 -4
  167. package/lib/Root.js +15 -4
  168. package/lib/RootRenderer.d.ts +3 -1
  169. package/lib/RootRenderer.js +8 -2
  170. package/lib/SchemaRenderer.d.ts +4 -2
  171. package/lib/SchemaRenderer.js +32 -23
  172. package/lib/Scoped.d.ts +8 -0
  173. package/lib/Scoped.js +20 -4
  174. package/lib/StatusScoped.d.ts +58 -0
  175. package/lib/StatusScoped.js +63 -0
  176. package/lib/WithRootStore.d.ts +2 -2
  177. package/lib/WithRootStore.js +1 -1
  178. package/lib/WithStore.js +6 -2
  179. package/lib/actions/Action.d.ts +1 -0
  180. package/lib/actions/Action.js +19 -5
  181. package/lib/actions/AjaxAction.js +1 -1
  182. package/lib/actions/BreakAction.js +1 -1
  183. package/lib/actions/BroadcastAction.js +1 -1
  184. package/lib/actions/CmptAction.js +8 -7
  185. package/lib/actions/ContinueAction.js +1 -1
  186. package/lib/actions/CopyAction.js +1 -1
  187. package/lib/actions/CustomAction.js +4 -4
  188. package/lib/actions/DialogAction.d.ts +16 -2
  189. package/lib/actions/DialogAction.js +23 -7
  190. package/lib/actions/DrawerAction.js +1 -1
  191. package/lib/actions/EmailAction.js +1 -1
  192. package/lib/actions/LinkAction.js +1 -1
  193. package/lib/actions/LoopAction.js +1 -1
  194. package/lib/actions/PageAction.js +1 -1
  195. package/lib/actions/ParallelAction.js +1 -1
  196. package/lib/actions/SwitchAction.js +1 -1
  197. package/lib/actions/ToastAction.js +1 -1
  198. package/lib/components/CustomStyle.d.ts +13 -0
  199. package/lib/components/CustomStyle.js +22 -0
  200. package/lib/components/LazyComponent.d.ts +1 -1
  201. package/lib/components/LazyComponent.js +1 -1
  202. package/lib/components/Overlay.d.ts +3 -3
  203. package/lib/components/Overlay.js +1 -1
  204. package/lib/components/PopOver.d.ts +2 -2
  205. package/lib/components/PopOver.js +1 -1
  206. package/lib/env.d.ts +10 -2
  207. package/lib/env.js +1 -1
  208. package/lib/envOverwrite.js +1 -5
  209. package/lib/factory.d.ts +5 -3
  210. package/lib/factory.js +3 -3
  211. package/lib/index.d.ts +11 -4
  212. package/lib/index.js +61 -23
  213. package/lib/locale.d.ts +2 -2
  214. package/lib/locale.js +10 -3
  215. package/lib/renderers/Form.d.ts +3 -2
  216. package/lib/renderers/Form.js +215 -179
  217. package/lib/renderers/Item.d.ts +55 -41
  218. package/lib/renderers/Item.js +30 -19
  219. package/lib/renderers/Options.js +11 -4
  220. package/lib/renderers/Placeholder.js +1 -1
  221. package/lib/renderers/builtin.js +1 -1
  222. package/lib/renderers/register.js +1 -1
  223. package/lib/renderers/wrapControl.d.ts +2 -2
  224. package/lib/renderers/wrapControl.js +12 -15
  225. package/lib/store/app.d.ts +1 -0
  226. package/lib/store/app.js +1 -1
  227. package/lib/store/combo.d.ts +3 -0
  228. package/lib/store/combo.js +1 -1
  229. package/lib/store/crud.d.ts +2 -0
  230. package/lib/store/crud.js +31 -9
  231. package/lib/store/form.d.ts +1 -0
  232. package/lib/store/form.js +10 -4
  233. package/lib/store/formItem.js +2 -2
  234. package/lib/store/iRenderer.d.ts +1 -0
  235. package/lib/store/iRenderer.js +53 -12
  236. package/lib/store/index.js +1 -1
  237. package/lib/store/list.d.ts +1 -0
  238. package/lib/store/list.js +7 -3
  239. package/lib/store/manager.js +1 -1
  240. package/lib/store/modal.d.ts +1 -0
  241. package/lib/store/modal.js +1 -1
  242. package/lib/store/node.js +1 -1
  243. package/lib/store/pagination.d.ts +1 -0
  244. package/lib/store/pagination.js +2 -2
  245. package/lib/store/root.d.ts +4 -6
  246. package/lib/store/root.js +52 -23
  247. package/lib/store/service.d.ts +1 -0
  248. package/lib/store/service.js +1 -1
  249. package/lib/store/status.d.ts +12 -0
  250. package/lib/store/status.js +42 -0
  251. package/lib/store/table.d.ts +28 -23
  252. package/lib/store/table.js +26 -5
  253. package/lib/store/table2.d.ts +7 -6
  254. package/lib/store/table2.js +27 -23
  255. package/lib/theme.d.ts +1 -1
  256. package/lib/theme.js +1 -1
  257. package/lib/types.d.ts +7 -1
  258. package/lib/utils/Animation.js +1 -1
  259. package/lib/utils/ColorScale.js +1 -1
  260. package/lib/utils/DataSchema.js +1 -1
  261. package/lib/utils/DataScope.d.ts +3 -5
  262. package/lib/utils/DataScope.js +86 -29
  263. package/lib/utils/RootClose.js +1 -1
  264. package/lib/utils/SimpleMap.js +1 -1
  265. package/lib/utils/api.js +13 -4
  266. package/lib/utils/attachmentAdpator.js +2 -2
  267. package/lib/utils/autobind.js +1 -1
  268. package/lib/utils/columnsSplit.js +1 -1
  269. package/lib/utils/dataMapping.js +1 -1
  270. package/lib/utils/date.d.ts +7 -0
  271. package/lib/utils/date.js +34 -1
  272. package/lib/utils/debug.js +4 -4
  273. package/lib/utils/decodeEntity.js +1 -1
  274. package/lib/utils/dom.d.ts +3 -0
  275. package/lib/utils/dom.js +48 -9
  276. package/lib/utils/errors.js +1 -1
  277. package/lib/utils/escapeHtml.js +1 -1
  278. package/lib/utils/filter-schema.js +1 -1
  279. package/lib/utils/filter.js +1 -1
  280. package/lib/utils/formatDuration.js +1 -1
  281. package/lib/utils/formula.js +2 -2
  282. package/lib/utils/getVariable.js +1 -1
  283. package/lib/utils/grammar.js +3 -3
  284. package/lib/utils/handleAction.js +1 -1
  285. package/lib/utils/helper.d.ts +9 -2
  286. package/lib/utils/helper.js +53 -19
  287. package/lib/utils/highlight.js +1 -1
  288. package/lib/utils/icon.d.ts +6 -1
  289. package/lib/utils/icon.js +6 -1
  290. package/lib/utils/image.js +1 -1
  291. package/lib/utils/isPureVariable.js +3 -3
  292. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  293. package/lib/utils/keyToPath.js +1 -1
  294. package/lib/utils/makeSorter.js +1 -1
  295. package/lib/utils/memoryParse.d.ts +17 -0
  296. package/lib/utils/memoryParse.js +30 -0
  297. package/lib/utils/normalizeLink.js +1 -1
  298. package/lib/utils/normalizeOptions.js +4 -2
  299. package/lib/utils/object.d.ts +2 -0
  300. package/lib/utils/object.js +28 -1
  301. package/lib/utils/offset.js +1 -1
  302. package/lib/utils/offsetParent.js +1 -1
  303. package/lib/utils/optionValueCompare.js +1 -1
  304. package/lib/utils/position.js +1 -1
  305. package/lib/utils/prettyBytes.js +1 -1
  306. package/lib/utils/renderer-event.js +35 -32
  307. package/lib/utils/replaceText.js +1 -1
  308. package/lib/utils/resize-sensor.js +1 -1
  309. package/lib/utils/resolveCondition.d.ts +1 -0
  310. package/lib/utils/resolveCondition.js +19 -3
  311. package/lib/utils/resolveVariable.js +3 -2
  312. package/lib/utils/resolveVariableAndFilter.js +1 -1
  313. package/lib/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  314. package/lib/utils/resolveVariableAndFilterForAsync.js +22 -3
  315. package/lib/utils/scrollPosition.js +1 -1
  316. package/lib/utils/string2regExp.js +1 -1
  317. package/lib/utils/stripNumber.js +1 -1
  318. package/lib/utils/style-helper.d.ts +12 -4
  319. package/lib/utils/style-helper.js +101 -18
  320. package/lib/utils/style.js +2 -2
  321. package/lib/utils/toNumber.js +1 -1
  322. package/lib/utils/tokenize.js +1 -1
  323. package/lib/utils/tpl-builtin.d.ts +2 -1
  324. package/lib/utils/tpl-builtin.js +19 -2
  325. package/lib/utils/tpl-lodash.js +3 -2
  326. package/lib/utils/tpl.d.ts +2 -0
  327. package/lib/utils/tpl.js +24 -1
  328. package/lib/utils/uncontrollable.js +1 -1
  329. package/lib/utils/validations.d.ts +4 -1
  330. package/lib/utils/validations.js +27 -12
  331. package/package.json +3 -3
package/lib/store/crud.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -122,9 +122,25 @@ var CRUDStore = service.ServiceStore.named('CRUDStore')
122
122
  // value可能为null、undefined、''、0
123
123
  value = getVariable.getVariable(self.query, key);
124
124
  if (value != null) {
125
- items_1 = matchSorter.matchSorter(items_1, value, {
126
- keys: [key]
127
- });
125
+ if (Array.isArray(value)) {
126
+ if (value.length > 0) {
127
+ var arr_1 = tslib.__spreadArray([], tslib.__read(items_1), false);
128
+ var arrItems_1 = [];
129
+ value.forEach(function (item) {
130
+ arrItems_1 = tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(arrItems_1), false), tslib.__read(matchSorter.matchSorter(arr_1, item, {
131
+ keys: [key]
132
+ })), false);
133
+ });
134
+ items_1 = items_1.filter(function (item) {
135
+ return arrItems_1.find(function (a) { return a === item; });
136
+ });
137
+ }
138
+ }
139
+ else {
140
+ items_1 = matchSorter.matchSorter(items_1, value, {
141
+ keys: [key]
142
+ });
143
+ }
128
144
  }
129
145
  }
130
146
  });
@@ -226,14 +242,16 @@ var CRUDStore = service.ServiceStore.named('CRUDStore')
226
242
  (value = getVariable.getVariable(self.query, key))) {
227
243
  if (Array.isArray(value)) {
228
244
  if (value.length > 0) {
229
- var arr_1 = tslib.__spreadArray([], tslib.__read(filteredItems_1), false);
230
- var arrItems_1 = [];
245
+ var arr_2 = tslib.__spreadArray([], tslib.__read(filteredItems_1), false);
246
+ var arrItems_2 = [];
231
247
  value.forEach(function (item) {
232
- arrItems_1 = tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(arrItems_1), false), tslib.__read(matchSorter.matchSorter(arr_1, item, {
248
+ arrItems_2 = tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(arrItems_2), false), tslib.__read(matchSorter.matchSorter(arr_2, item, {
233
249
  keys: [key]
234
250
  })), false);
235
251
  });
236
- filteredItems_1 = filteredItems_1.filter(function (item) { return arrItems_1.find(function (a) { return a === item; }); });
252
+ filteredItems_1 = filteredItems_1.filter(function (item) {
253
+ return arrItems_2.find(function (a) { return a === item; });
254
+ });
237
255
  }
238
256
  }
239
257
  else {
@@ -470,6 +488,9 @@ var CRUDStore = service.ServiceStore.named('CRUDStore')
470
488
  var updateColumns = function (columns) {
471
489
  self.columns = columns;
472
490
  };
491
+ var updateTotal = function (total) {
492
+ self.total = total || 0;
493
+ };
473
494
  return {
474
495
  getData: getData,
475
496
  updateSelectData: updateSelectData,
@@ -487,7 +508,8 @@ var CRUDStore = service.ServiceStore.named('CRUDStore')
487
508
  setInnerModalOpened: setInnerModalOpened,
488
509
  initFromScope: initFromScope,
489
510
  exportAsCSV: exportAsCSV,
490
- updateColumns: updateColumns
511
+ updateColumns: updateColumns,
512
+ updateTotal: updateTotal
491
513
  };
492
514
  });
493
515
 
@@ -54,6 +54,7 @@ export declare const FormStore: import("mobx-state-tree").IModelType<{
54
54
  getValueByName(name: string, canAccessSuper?: boolean): any;
55
55
  getPristineValueByName(name: string): any;
56
56
  } & {
57
+ setTopStore(value: any): void;
57
58
  initData(data?: object, skipSetPristine?: boolean): void;
58
59
  reset(): void;
59
60
  updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
package/lib/store/form.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -167,7 +167,13 @@ var FormStore = service.ServiceStore.named('FormStore')
167
167
  function setValues(values, tag, replace) {
168
168
  self.updateData(values, tag, replace);
169
169
  // 如果数据域中有数据变化,就都reset一下,去掉之前残留的验证消息
170
- self.items.forEach(function (item) { return item.reset(); });
170
+ self.items.forEach(function (item) {
171
+ var value = item.value;
172
+ if (typeof value !== 'undefined' && value !== item.tmpValue) {
173
+ item.changeTmpValue(value);
174
+ }
175
+ item.reset();
176
+ });
171
177
  // 同步 options
172
178
  syncOptions();
173
179
  }
@@ -179,7 +185,7 @@ var FormStore = service.ServiceStore.named('FormStore')
179
185
  var prev = self.data;
180
186
  var data = object.cloneObject(self.data);
181
187
  if (value !== origin) {
182
- if (prev.__prev) {
188
+ if (prev.hasOwnProperty('__prev')) {
183
189
  // 基于之前的 __prev 改
184
190
  var prevData = object.cloneObject(prev.__prev);
185
191
  object.setVariable(prevData, name, origin);
@@ -223,7 +229,7 @@ var FormStore = service.ServiceStore.named('FormStore')
223
229
  function deleteValueByName(name) {
224
230
  var prev = self.data;
225
231
  var data = object.cloneObject(self.data);
226
- if (prev.__prev) {
232
+ if (prev.hasOwnProperty('__prev')) {
227
233
  // 基于之前的 __prev 改
228
234
  var prevData = object.cloneObject(prev.__prev);
229
235
  object.setVariable(prevData, name, getVariable.getVariable(prev, name));
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -740,7 +740,7 @@ var FormItemStore = node.StoreNode.named('FormItemStore')
740
740
  ? tpl.evalExpression(item.visibleOn, data) !== false
741
741
  : item.hiddenOn
742
742
  ? tpl.evalExpression(item.hiddenOn, data) !== true
743
- : item.visible !== false || item.hidden !== true;
743
+ : item.visible !== false && item.hidden !== true;
744
744
  })
745
745
  .map(function (item, index) {
746
746
  var disabled = tpl.evalExpression(item.disabledOn, data);
@@ -33,6 +33,7 @@ export declare const iRendererStore: import("mobx-state-tree").IModelType<{
33
33
  getValueByName(name: string, canAccessSuper?: boolean): any;
34
34
  getPristineValueByName(name: string): any;
35
35
  } & {
36
+ setTopStore(value: any): void;
36
37
  initData(data?: object, skipSetPristine?: boolean): void;
37
38
  reset(): void;
38
39
  updateData(data?: object, tag?: object, replace?: boolean): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -18,6 +18,35 @@ var dataMapping = require('../utils/dataMapping.js');
18
18
  require('../utils/filter.js');
19
19
  var SimpleMap = require('../utils/SimpleMap.js');
20
20
  var node = require('./node.js');
21
+ require('../utils/api.js');
22
+ require('../utils/ColorScale.js');
23
+ require('react');
24
+ require('lodash/chunk');
25
+ require('../utils/DataSchema.js');
26
+ require('../utils/DataScope.js');
27
+ require('../utils/debug.js');
28
+ require('react-dom');
29
+ require('../utils/errors.js');
30
+ require('../utils/tpl.js');
31
+ require('lodash/isPlainObject');
32
+ require('classnames');
33
+ require('lodash/isObject');
34
+ require('lodash/isString');
35
+ require('lodash/isBoolean');
36
+ require('lodash');
37
+ require('../utils/image.js');
38
+ require('../actions/Action.js');
39
+ require('lodash/debounce');
40
+ require('lodash/cloneDeep');
41
+ require('../utils/resize-sensor.js');
42
+ require('react-overlays/useRootClose');
43
+ require('lodash/mapValues');
44
+ require('lodash/camelCase');
45
+ require('uncontrollable');
46
+ require('hoist-non-react-statics');
47
+ require('../utils/validations.js');
48
+ require('../utils/resolveCondition.js');
49
+ require('../utils/Animation.js');
21
50
 
22
51
  var iRendererStore = node.StoreNode.named('iRendererStore')
23
52
  .props({
@@ -45,7 +74,11 @@ var iRendererStore = node.StoreNode.named('iRendererStore')
45
74
  var dialogCallbacks = new SimpleMap.SimpleMap();
46
75
  var dialogScoped = null;
47
76
  var drawerScoped = null;
77
+ var top = null;
48
78
  return {
79
+ setTopStore: function (value) {
80
+ top = value;
81
+ },
49
82
  initData: function (data, skipSetPristine) {
50
83
  if (data === void 0) { data = {}; }
51
84
  if (skipSetPristine === void 0) { skipSetPristine = false; }
@@ -85,7 +118,7 @@ var iRendererStore = node.StoreNode.named('iRendererStore')
85
118
  }
86
119
  var prev = self.data;
87
120
  var data = object.cloneObject(self.data);
88
- if (prev.__prev) {
121
+ if (prev.hasOwnProperty('__prev')) {
89
122
  // 基于之前的 __prev 改
90
123
  var prevData = object.cloneObject(prev.__prev);
91
124
  object.setVariable(prevData, name, origin);
@@ -131,13 +164,17 @@ var iRendererStore = node.StoreNode.named('iRendererStore')
131
164
  self.action = action;
132
165
  },
133
166
  openDialog: function (ctx, additonal, callback, scoped) {
134
- var proto = ctx.__super ? ctx.__super : self.data;
167
+ var chain = object.extractObjectChain(ctx);
168
+ chain.length === 1 && chain.unshift(self.data);
135
169
  if (additonal) {
136
- proto = object.createObject(proto, additonal);
170
+ chain.splice(chain.length - 1, 0, additonal);
137
171
  }
138
- var data = object.createObject(proto, tslib.__assign({}, ctx));
172
+ var data = object.createObjectFromChain(chain);
139
173
  if (self.action.dialog && self.action.dialog.data) {
140
- self.dialogData = dataMapping.dataMapping(self.action.dialog.data, data);
174
+ self.dialogData = object.createObjectFromChain([
175
+ top === null || top === void 0 ? void 0 : top.context,
176
+ dataMapping.dataMapping(self.action.dialog.data, data)
177
+ ]);
141
178
  var clonedAction = tslib.__assign(tslib.__assign({}, self.action), { dialog: tslib.__assign({}, self.action.dialog) });
142
179
  delete clonedAction.dialog.data;
143
180
  self.action = clonedAction;
@@ -159,15 +196,19 @@ var iRendererStore = node.StoreNode.named('iRendererStore')
159
196
  }
160
197
  },
161
198
  openDrawer: function (ctx, additonal, callback, scoped) {
162
- var proto = ctx.__super ? ctx.__super : self.data;
199
+ var chain = object.extractObjectChain(ctx);
200
+ chain.length === 1 && chain.unshift(self.data);
163
201
  if (additonal) {
164
- proto = object.createObject(proto, additonal);
202
+ chain.splice(chain.length - 1, 0, additonal);
165
203
  }
166
- var data = object.createObject(proto, tslib.__assign({}, ctx));
204
+ var data = object.createObjectFromChain(chain);
167
205
  if (self.action.drawer.data) {
168
- self.drawerData = dataMapping.dataMapping(self.action.drawer.data, data);
169
- var clonedAction = tslib.__assign(tslib.__assign({}, self.action), { dialog: tslib.__assign({}, self.action.dialog) });
170
- delete clonedAction.dialog.data;
206
+ self.drawerData = object.createObjectFromChain([
207
+ top === null || top === void 0 ? void 0 : top.context,
208
+ dataMapping.dataMapping(self.action.drawer.data, data)
209
+ ]);
210
+ var clonedAction = tslib.__assign(tslib.__assign({}, self.action), { drawer: tslib.__assign({}, self.action.drawer) });
211
+ delete clonedAction.drawer.data;
171
212
  self.action = clonedAction;
172
213
  }
173
214
  else {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -99,6 +99,7 @@ export declare const ListStore: import("mobx-state-tree").IModelType<{
99
99
  getValueByName(name: string, canAccessSuper?: boolean): any;
100
100
  getPristineValueByName(name: string): any;
101
101
  } & {
102
+ setTopStore(value: any): void;
102
103
  initData(data?: object, skipSetPristine?: boolean): void;
103
104
  reset(): void;
104
105
  updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
package/lib/store/list.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -42,8 +42,12 @@ var Item = mobxStateTree.types
42
42
  return self.index !== self.newIndex;
43
43
  },
44
44
  get locals() {
45
- return object.createObject(object.extendObject(mobxStateTree.getParent(self, 2).data, {
46
- index: self.index
45
+ var listStore = mobxStateTree.getParent(self, 2);
46
+ return object.createObject(object.extendObject(listStore.data, {
47
+ index: self.index,
48
+ // 只有table时,也可以获取选中行
49
+ selectedItems: listStore.selectedItems.map(function (item) { return item.data; }),
50
+ unSelectedItems: listStore.unSelectedItems.map(function (item) { return item.data; })
47
51
  }), self.data);
48
52
  },
49
53
  get checkable() {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -47,6 +47,7 @@ export declare const ModalStore: import("mobx-state-tree").IModelType<{
47
47
  getValueByName(name: string, canAccessSuper?: boolean): any;
48
48
  getPristineValueByName(name: string): any;
49
49
  } & {
50
+ setTopStore(value: any): void;
50
51
  initData(data?: object, skipSetPristine?: boolean): void;
51
52
  reset(): void;
52
53
  updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/lib/store/node.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -38,6 +38,7 @@ export declare const PaginationStore: import("mobx-state-tree").IModelType<{
38
38
  getValueByName(name: string, canAccessSuper?: boolean): any;
39
39
  getPristineValueByName(name: string): any;
40
40
  } & {
41
+ setTopStore(value: any): void;
41
42
  initData(data?: object, skipSetPristine?: boolean): void;
42
43
  reset(): void;
43
44
  updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -8,11 +8,11 @@
8
8
  Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
10
  require('../utils/helper.js');
11
+ require('tslib');
11
12
  require('amis-formula');
12
13
  require('moment');
13
14
  var object = require('../utils/object.js');
14
15
  var resolveVariable = require('../utils/resolveVariable.js');
15
- require('tslib');
16
16
  require('lodash/isPlainObject');
17
17
  require('../utils/filter.js');
18
18
  var iRenderer = require('./iRenderer.js');
@@ -31,9 +31,6 @@ export declare const RootStore: import("mobx-state-tree").IModelType<{
31
31
  runtimeError: import("mobx-state-tree").IType<any, any, any>;
32
32
  runtimeErrorStack: import("mobx-state-tree").IType<any, any, any>;
33
33
  query: import("mobx-state-tree").IType<any, any, any>;
34
- visibleState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
35
- disableState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
36
- staticState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
37
34
  }, {
38
35
  readonly parentStore: any;
39
36
  readonly __: any;
@@ -49,6 +46,7 @@ export declare const RootStore: import("mobx-state-tree").IModelType<{
49
46
  getValueByName(name: string, canAccessSuper?: boolean): any;
50
47
  getPristineValueByName(name: string): any;
51
48
  } & {
49
+ setTopStore(value: any): void;
52
50
  initData(data?: object, skipSetPristine?: boolean): void;
53
51
  reset(): void;
54
52
  updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
@@ -75,13 +73,13 @@ export declare const RootStore: import("mobx-state-tree").IModelType<{
75
73
  saveRemote: (api: import("..").Api, data?: object | undefined, options?: import("..").fetchOptions | undefined) => Promise<any>;
76
74
  fetchSchema: (api: import("..").Api, data?: object | undefined, options?: import("..").fetchOptions | undefined) => Promise<any>;
77
75
  checkRemote: (api: import("..").Api, data?: object | undefined, options?: import("..").fetchOptions | undefined) => Promise<any>;
76
+ } & {
77
+ context: {};
78
78
  } & {
79
79
  readonly downStream: any;
80
80
  } & {
81
+ setContext(context: any): void;
81
82
  setRuntimeError(error: any, errorStack: any): void;
82
83
  updateLocation(location?: any, parseFn?: Function): void;
83
- setVisible(id: string, value: boolean): void;
84
- setDisable(id: string, value: boolean): void;
85
- setStatic(id: string, value: boolean): void;
86
84
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
87
85
  export type IRootStore = Instance<typeof RootStore>;
package/lib/store/root.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -11,46 +11,75 @@ var tslib = require('tslib');
11
11
  var mobxStateTree = require('mobx-state-tree');
12
12
  var helper = require('../utils/helper.js');
13
13
  var service = require('./service.js');
14
+ require('../utils/api.js');
15
+ require('../utils/ColorScale.js');
16
+ require('react');
17
+ require('lodash/chunk');
18
+ require('amis-formula');
19
+ require('lodash/isPlainObject');
14
20
  var object = require('../utils/object.js');
21
+ require('../utils/DataSchema.js');
22
+ require('../utils/DataScope.js');
23
+ require('moment');
24
+ require('../utils/debug.js');
25
+ require('react-dom');
26
+ require('../utils/errors.js');
27
+ require('../utils/tpl.js');
28
+ require('classnames');
29
+ require('../utils/filter.js');
30
+ require('lodash/isObject');
31
+ require('lodash/isString');
32
+ require('lodash/isBoolean');
33
+ require('lodash');
34
+ require('../utils/image.js');
35
+ require('../actions/Action.js');
36
+ require('lodash/debounce');
37
+ require('lodash/cloneDeep');
38
+ require('../utils/resize-sensor.js');
39
+ require('react-overlays/useRootClose');
40
+ require('../utils/SimpleMap.js');
41
+ require('lodash/mapValues');
42
+ require('lodash/camelCase');
43
+ require('uncontrollable');
44
+ require('hoist-non-react-statics');
45
+ require('../utils/validations.js');
46
+ require('../utils/resolveCondition.js');
47
+ require('../utils/Animation.js');
15
48
 
16
49
  var RootStore = service.ServiceStore.named('RootStore')
17
50
  .props({
18
51
  runtimeError: mobxStateTree.types.frozen(),
19
52
  runtimeErrorStack: mobxStateTree.types.frozen(),
20
- query: mobxStateTree.types.frozen(),
21
- visibleState: mobxStateTree.types.optional(mobxStateTree.types.frozen(), {}),
22
- disableState: mobxStateTree.types.optional(mobxStateTree.types.frozen(), {}),
23
- staticState: mobxStateTree.types.optional(mobxStateTree.types.frozen(), {})
53
+ query: mobxStateTree.types.frozen()
54
+ })
55
+ .volatile(function (self) {
56
+ return {
57
+ context: {}
58
+ };
24
59
  })
25
60
  .views(function (self) { return ({
26
61
  get downStream() {
27
- return self.query
28
- ? object.createObject(object.extendObject(self.data && self.data.__super ? self.data.__super : null, tslib.__assign(tslib.__assign({}, self.query), { __query: self.query })), self.data)
29
- : self.data;
62
+ var result = self.data;
63
+ if (self.context || self.query) {
64
+ var chain = object.extractObjectChain(result);
65
+ self.context && chain.unshift(self.context);
66
+ self.query &&
67
+ chain.splice(chain.length - 1, 0, tslib.__assign(tslib.__assign({}, self.query), { __query: self.query }));
68
+ result = object.createObjectFromChain(chain);
69
+ }
70
+ return result;
30
71
  }
31
72
  }); })
32
73
  .actions(function (self) { return ({
74
+ setContext: function (context) {
75
+ self.context = context;
76
+ },
33
77
  setRuntimeError: function (error, errorStack) {
34
78
  self.runtimeError = error;
35
79
  self.runtimeErrorStack = errorStack;
36
80
  },
37
81
  updateLocation: function (location, parseFn) {
38
82
  self.query = parseFn ? parseFn(location) : helper.parseQuery(location);
39
- },
40
- setVisible: function (id, value) {
41
- var _a;
42
- var state = tslib.__assign(tslib.__assign({}, self.visibleState), (_a = {}, _a[id] = value, _a));
43
- self.visibleState = state;
44
- },
45
- setDisable: function (id, value) {
46
- var _a;
47
- var state = tslib.__assign(tslib.__assign({}, self.disableState), (_a = {}, _a[id] = value, _a));
48
- self.disableState = state;
49
- },
50
- setStatic: function (id, value) {
51
- var _a;
52
- var state = tslib.__assign(tslib.__assign({}, self.staticState), (_a = {}, _a[id] = value, _a));
53
- self.staticState = state;
54
83
  }
55
84
  }); });
56
85
 
@@ -43,6 +43,7 @@ export declare const ServiceStore: import("mobx-state-tree").IModelType<{
43
43
  getValueByName(name: string, canAccessSuper?: boolean): any;
44
44
  getPristineValueByName(name: string): any;
45
45
  } & {
46
+ setTopStore(value: any): void;
46
47
  initData(data?: object, skipSetPristine?: boolean): void;
47
48
  reset(): void;
48
49
  updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -0,0 +1,12 @@
1
+ import { Instance } from 'mobx-state-tree';
2
+ export declare const StatusStore: import("mobx-state-tree").IModelType<{
3
+ visibleState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
4
+ disableState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
5
+ staticState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
6
+ }, {
7
+ setVisible(key: string, value?: boolean): void;
8
+ setDisable(key: string, value?: boolean): void;
9
+ setStatic(key: string, value?: boolean): void;
10
+ resetAll(): void;
11
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
12
+ export type IStatusStore = Instance<typeof StatusStore>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * amis-core v3.1.0
3
+ * Copyright 2018-2023 fex
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ Object.defineProperty(exports, '__esModule', { value: true });
9
+
10
+ var tslib = require('tslib');
11
+ var mobxStateTree = require('mobx-state-tree');
12
+
13
+ var StatusStore = mobxStateTree.types
14
+ .model('StatusStore', {
15
+ visibleState: mobxStateTree.types.optional(mobxStateTree.types.frozen(), {}),
16
+ disableState: mobxStateTree.types.optional(mobxStateTree.types.frozen(), {}),
17
+ staticState: mobxStateTree.types.optional(mobxStateTree.types.frozen(), {})
18
+ })
19
+ .actions(function (self) { return ({
20
+ setVisible: function (key, value) {
21
+ var _a;
22
+ var state = tslib.__assign(tslib.__assign({}, self.visibleState), (_a = {}, _a[key] = value, _a));
23
+ self.visibleState = state;
24
+ },
25
+ setDisable: function (key, value) {
26
+ var _a;
27
+ var state = tslib.__assign(tslib.__assign({}, self.disableState), (_a = {}, _a[key] = value, _a));
28
+ self.disableState = state;
29
+ },
30
+ setStatic: function (key, value) {
31
+ var _a;
32
+ var state = tslib.__assign(tslib.__assign({}, self.staticState), (_a = {}, _a[key] = value, _a));
33
+ self.staticState = state;
34
+ },
35
+ resetAll: function () {
36
+ self.visibleState = {};
37
+ self.disableState = {};
38
+ self.staticState = {};
39
+ }
40
+ }); });
41
+
42
+ exports.StatusStore = StatusStore;