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
@@ -1,10 +1,10 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
- import { __values, __assign } from 'tslib';
7
- import { guid } from './helper.js';
6
+ import { __values, __assign, __spreadArray, __read } from 'tslib';
7
+ import { guid, mapTree } from './helper.js';
8
8
  import { keyToPath } from './keyToPath.js';
9
9
 
10
10
  var DataScope = /** @class */ (function () {
@@ -76,26 +76,89 @@ var DataScope = /** @class */ (function () {
76
76
  }
77
77
  return false;
78
78
  };
79
+ DataScope.prototype.assignSchema = function (target, schema) {
80
+ var e_2, _a;
81
+ // key相同,type也相同
82
+ if (target.type && target.type === schema.type) {
83
+ if (target.type === 'array') {
84
+ // 先只考虑items,不考虑contains
85
+ if (target.items) {
86
+ if (Array.isArray(target.items)) {
87
+ if (schema.items) {
88
+ if (Array.isArray(schema.items)) {
89
+ // 如果都是数组,就后者覆盖前者
90
+ return schema.items;
91
+ }
92
+ else {
93
+ // 否则,追加
94
+ return __assign(__assign({}, target), { items: __spreadArray(__spreadArray([], __read(target.items), false), [schema.items], false) });
95
+ }
96
+ }
97
+ else {
98
+ return __assign(__assign({}, target), schema);
99
+ }
100
+ }
101
+ else {
102
+ // 非数组,则merge
103
+ return __assign(__assign({}, target), { items: this.assignSchema(target.items, schema.items) });
104
+ }
105
+ }
106
+ else {
107
+ return schema;
108
+ }
109
+ }
110
+ else if (target.type === 'object' && target.properties) {
111
+ var properties = {};
112
+ try {
113
+ // 合并属性
114
+ for (var _b = __values(Array.from(new Set(__spreadArray(__spreadArray([], __read(Object.keys(target.properties)), false), __read(Object.keys(schema.properties)), false)))), _c = _b.next(); !_c.done; _c = _b.next()) {
115
+ var key = _c.value;
116
+ var value = target.properties[key];
117
+ if (value) {
118
+ properties[key] = schema.properties[key]
119
+ ? this.assignSchema(value, schema.properties[key])
120
+ : value;
121
+ }
122
+ else {
123
+ properties[key] = schema.properties[key];
124
+ }
125
+ }
126
+ }
127
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
128
+ finally {
129
+ try {
130
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
131
+ }
132
+ finally { if (e_2) throw e_2.error; }
133
+ }
134
+ return __assign(__assign({}, target), { properties: properties });
135
+ }
136
+ else {
137
+ return schema;
138
+ }
139
+ }
140
+ else {
141
+ // key相同、type不同
142
+ if (Array.isArray(target.oneOf)) {
143
+ return __assign(__assign({}, target), { oneOf: __spreadArray(__spreadArray([], __read(target.oneOf), false), [schema], false) });
144
+ }
145
+ else {
146
+ return __assign(__assign({}, target), { oneOf: [target, schema] });
147
+ }
148
+ }
149
+ };
79
150
  DataScope.prototype.getMergedSchema = function () {
151
+ var _this = this;
80
152
  var mergedSchema = {
81
153
  type: 'object',
82
154
  properties: {}
83
155
  };
84
- // todo 以后再来细化这一块,先粗略的写个大概
85
156
  this.schemas.forEach(function (schema) {
86
157
  var properties = schema.properties || {};
87
158
  Object.keys(properties).forEach(function (key) {
88
159
  var value = properties[key];
89
160
  if (mergedSchema.properties[key]) {
90
- if (Array.isArray(mergedSchema.properties[key].oneOf)) {
91
- mergedSchema.properties[key].oneOf.push();
92
- }
93
- else if (mergedSchema.properties[key].type &&
94
- mergedSchema.properties[key].type !== value.type) {
95
- mergedSchema.properties[key] = {
96
- oneOf: [mergedSchema.properties[key], value]
97
- };
98
- }
161
+ mergedSchema.properties[key] = _this.assignSchema(mergedSchema.properties[key], value);
99
162
  }
100
163
  else {
101
164
  mergedSchema.properties[key] = value;
@@ -104,23 +167,17 @@ var DataScope = /** @class */ (function () {
104
167
  });
105
168
  return mergedSchema;
106
169
  };
107
- DataScope.prototype.buildOptions = function (options, schema, path, key,
108
- /** 是否数组元素,数组元素的内容将获取每个成员的对应值 */
109
- isArrayItem,
110
- /** 不是所有的都可以选择,但不影响子元素 */
111
- disabled) {
170
+ DataScope.prototype.buildOptions = function (options, schema, path, key) {
112
171
  var _this = this;
113
172
  var _a;
114
173
  if (path === void 0) { path = ''; }
115
174
  if (key === void 0) { key = ''; }
116
- if (isArrayItem === void 0) { isArrayItem = false; }
117
175
  // todo 支持 oneOf, anyOf
118
176
  var option = {
119
177
  label: schema.title || key,
120
178
  value: path,
121
179
  type: schema.type,
122
- tag: (_a = schema.description) !== null && _a !== void 0 ? _a : schema.type,
123
- disabled: disabled
180
+ tag: (_a = schema.description) !== null && _a !== void 0 ? _a : schema.type
124
181
  };
125
182
  options.push(option);
126
183
  if (schema.type === 'object' && schema.properties) {
@@ -128,17 +185,13 @@ var DataScope = /** @class */ (function () {
128
185
  var keys = Object.keys(schema.properties);
129
186
  keys.forEach(function (key) {
130
187
  var child = schema.properties[key];
131
- var newPath = isArrayItem ? "ARRAYMAP(".concat(path, ", item => item.").concat(key, ")") : (path + (path ? '.' : '') + key);
132
- _this.buildOptions(option.children, child, newPath, key, isArrayItem, false);
188
+ _this.buildOptions(option.children, child, path + (path ? '.' : '') + key, key);
133
189
  });
134
190
  }
135
191
  else if (schema.type === 'array' && schema.items) {
136
192
  option.children = [];
137
- this.buildOptions(option.children, __assign({ title: '成员' }, schema.items), path, 'items', true, true);
138
- this.buildOptions(option.children, {
139
- title: '总数',
140
- type: 'number'
141
- }, path + (path ? '.' : '') + 'length', 'length', true, isArrayItem);
193
+ this.buildOptions(option.children, __assign(__assign({ title: '成员' }, schema.items), { disabled: true }), path, 'items');
194
+ option.children = mapTree(option.children, function (item) { return (__assign(__assign({}, item), { disabled: true })); });
142
195
  }
143
196
  };
144
197
  DataScope.prototype.getDataPropsAsOptions = function () {
@@ -147,7 +200,7 @@ var DataScope = /** @class */ (function () {
147
200
  return variables[0].children;
148
201
  };
149
202
  DataScope.prototype.getSchemaByPath = function (path) {
150
- var e_2, _a;
203
+ var e_3, _a;
151
204
  var parts = keyToPath(path);
152
205
  try {
153
206
  for (var _b = __values(this.schemas), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -163,15 +216,19 @@ var DataScope = /** @class */ (function () {
163
216
  }
164
217
  }
165
218
  }
166
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
219
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
167
220
  finally {
168
221
  try {
169
222
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
170
223
  }
171
- finally { if (e_2) throw e_2.error; }
224
+ finally { if (e_3) throw e_3.error; }
172
225
  }
173
226
  return null;
174
227
  };
228
+ DataScope.prototype.getSchemaById = function (id) {
229
+ var _a;
230
+ return (_a = this.schemas) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.$id === id; });
231
+ };
175
232
  return DataScope;
176
233
  }());
177
234
 
@@ -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
 
@@ -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/esm/utils/api.js CHANGED
@@ -1,15 +1,16 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator, __assign, __rest, __spreadArray, __read } from 'tslib';
7
7
  import omit from 'lodash/omit';
8
- import { parse, evaluate } from 'amis-formula';
8
+ import { evaluate } from 'amis-formula';
9
9
  import { escapeHtml } from './escapeHtml.js';
10
10
  import 'moment';
11
11
  import { cloneObject, createObject, isObject } from './object.js';
12
12
  import { tokenize } from './tokenize.js';
13
+ import { memoryParse } from './memoryParse.js';
13
14
  import { dataMapping } from './dataMapping.js';
14
15
  import './filter.js';
15
16
  import { evalExpression } from './tpl.js';
@@ -63,7 +64,7 @@ function buildApi(api, data, options) {
63
64
  var raw = (api.url = api.url || '');
64
65
  var ast = undefined;
65
66
  try {
66
- ast = parse(api.url);
67
+ ast = memoryParse(api.url);
67
68
  }
68
69
  catch (e) {
69
70
  console.warn("api \u914D\u7F6E\u8BED\u6CD5\u51FA\u9519\uFF1A".concat(e));
@@ -257,7 +258,8 @@ function responseAdaptor(ret, api) {
257
258
  // 如果是文本类型就尝试解析一下
258
259
  if (ret.headers &&
259
260
  contentType.startsWith('text/') &&
260
- !contentType.includes('markdown')) {
261
+ !contentType.includes('markdown') &&
262
+ api.responseType !== 'blob') {
261
263
  try {
262
264
  data = JSON.parse(data);
263
265
  if (typeof data === 'undefined') {
@@ -350,7 +352,10 @@ function wrapFetcher(fn, tracker) {
350
352
  api = api.requestAdaptor(api) || api;
351
353
  debug('api', 'after requestAdaptor', api);
352
354
  }
353
- if (api.data && (hasFile(api.data) || api.dataType === 'form-data')) {
355
+ if (api.data &&
356
+ (api.data instanceof FormData ||
357
+ hasFile(api.data) ||
358
+ api.dataType === 'form-data')) {
354
359
  api.data =
355
360
  api.data instanceof FormData
356
361
  ? api.data
@@ -522,6 +527,10 @@ function isApiOutdated(prevApi, nextApi, prevData, nextData) {
522
527
  if (!nextApi) {
523
528
  return false;
524
529
  }
530
+ // 通常是编辑器里加了属性,一开始没值,后来有了
531
+ if (prevApi === undefined && !nextApi !== undefined) {
532
+ return true;
533
+ }
525
534
  nextApi = normalizeApi(nextApi);
526
535
  if (nextApi.autoRefresh === false) {
527
536
  return false;
@@ -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,7 +18,7 @@ function attachmentAdpator(response, __) {
18
18
  if (disposition && disposition.indexOf('attachment') !== -1) {
19
19
  // disposition 有可能是 attachment; filename="??.xlsx"; filename*=UTF-8''%E4%B8%AD%E6%96%87.xlsx
20
20
  // 这种情况下最后一个才是正确的文件名
21
- var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)$/;
21
+ var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
22
22
  var matches = disposition.match(filenameRegex);
23
23
  if (matches && matches.length) {
24
24
  filename = matches[1].replace("UTF-8''", '').replace(/['"]/g, '');
@@ -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
 
@@ -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
 
@@ -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
 
@@ -2,3 +2,10 @@ import moment from 'moment';
2
2
  export declare const relativeValueRe: RegExp;
3
3
  export declare const filterDate: (value: string, data?: object, format?: string, utc?: boolean) => moment.Moment;
4
4
  export declare function parseDuration(str: string): moment.Duration | undefined;
5
+ /**
6
+ * 解析日期,先尝试用 format 解析,如果失败,再尝试用其他标准格式解析
7
+ * @param value
8
+ * @param format
9
+ * @returns
10
+ */
11
+ export declare function normalizeDate(value: any, format?: string): moment.Moment | undefined;
package/esm/utils/date.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
 
@@ -76,5 +76,37 @@ function parseDuration(str) {
76
76
  }
77
77
  return;
78
78
  }
79
+ /**
80
+ * 解析日期,先尝试用 format 解析,如果失败,再尝试用其他标准格式解析
81
+ * @param value
82
+ * @param format
83
+ * @returns
84
+ */
85
+ function normalizeDate(value, format) {
86
+ if (!value || value === '0') {
87
+ return undefined;
88
+ }
89
+ var v = moment(value, format, true);
90
+ if (v.isValid()) {
91
+ return v;
92
+ }
93
+ if (typeof value === 'string' || typeof value === 'number') {
94
+ var formats = ['', 'YYYY-MM-DD HH:mm:ss', 'X'];
95
+ if (/^\d{10}((\.\d+)*)$/.test(value.toString())) {
96
+ formats = ['X', 'x', 'YYYY-MM-DD HH:mm:ss', ''];
97
+ }
98
+ else if (/^\d{13}((\.\d+)*)$/.test(value.toString())) {
99
+ formats = ['x', 'X', 'YYYY-MM-DD HH:mm:ss', ''];
100
+ }
101
+ while (formats.length) {
102
+ var format_1 = formats.shift();
103
+ var date = moment(value, format_1);
104
+ if (date.isValid()) {
105
+ return date;
106
+ }
107
+ }
108
+ }
109
+ return undefined;
110
+ }
79
111
 
80
- export { filterDate, parseDuration, relativeValueRe };
112
+ export { filterDate, normalizeDate, parseDuration, relativeValueRe };
@@ -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
 
@@ -351,12 +351,12 @@ var DebugWrapper = /** @class */ (function (_super) {
351
351
  * @param ext 扩展信息
352
352
  */
353
353
  function debug(cat, msg, ext) {
354
- console.groupCollapsed('[amis debug]', msg);
355
- console.debug(ext);
356
- console.groupEnd();
357
354
  if (!isEnabled) {
358
355
  return;
359
356
  }
357
+ console.groupCollapsed('[amis debug]', msg);
358
+ console.debug(ext);
359
+ console.groupEnd();
360
360
  var log = {
361
361
  cat: cat,
362
362
  level: 'debug',
@@ -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
 
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  export declare function getContainer(container: any, defaultContainer: any): any;
2
3
  export declare function ownerDocument(componentOrElement: any): Document;
3
4
  export declare function calculatePosition(placement: any, overlayNode: any, target: HTMLElement, container: any, padding?: any, customOffset?: [number, number]): {
@@ -11,3 +12,5 @@ export declare function calculatePosition(placement: any, overlayNode: any, targ
11
12
  * 专门用来获取样式的像素值,默认返回 0
12
13
  */
13
14
  export declare function getStyleNumber(element: HTMLElement, styleName: string): number;
15
+ /** 根据关键字高亮显示文本内容 */
16
+ export declare function renderTextByKeyword(rendererText: string, curKeyword: string): string | React.JSX.Element;
package/esm/utils/dom.js CHANGED
@@ -1,10 +1,11 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __read } from 'tslib';
7
7
  import ReactDOM from 'react-dom';
8
+ import React from 'react';
8
9
  import { offset } from './offset.js';
9
10
  import { position } from './position.js';
10
11
 
@@ -78,16 +79,27 @@ function calculatePosition(placement, overlayNode, target, container, padding, c
78
79
  ? clip2.height / overlayNode.offsetHeight
79
80
  : 1;
80
81
  // auto 尝试四个方向对齐。
81
- placement =
82
- placement === 'auto'
83
- ? 'left-bottom-left-top right-bottom-right-top left-top-left-bottom right-top-right-bottom left-bottom-left-top'
84
- : placement;
82
+ var isAuto = placement === 'auto';
83
+ // 兜底方向
84
+ var autoDefaultPlacement = 'left-bottom-left-top';
85
+ placement = isAuto
86
+ ? "left-bottom-left-top right-bottom-right-top left-top-left-bottom right-top-right-bottom ".concat(autoDefaultPlacement)
87
+ : placement;
85
88
  var positionLeft = 0, positionTop = 0, arrowOffsetLeft = '', arrowOffsetTop = '', activePlacement = placement;
86
89
  if (~placement.indexOf('-')) {
87
90
  var tests = placement.split(/\s+/);
91
+ // 收集可见方向
92
+ var visiblePlacement = {};
88
93
  while (tests.length) {
89
94
  var current = (activePlacement = tests.shift());
90
- var _b = __read(current.split('-'), 4), atX = _b[0], atY = _b[1], myX = _b[2], myY = _b[3];
95
+ // 自动对齐模式下,当四个方向都无法完全可见时
96
+ // 根据之前的计算结果,使用收集的可见方向作为兜底,避免完全不可见
97
+ if (isAuto && tests.length === 0) {
98
+ var _b = __read(autoDefaultPlacement.split('-'), 4), _atX = _b[0], _atY = _b[1], _myX = _b[2], _myY = _b[3];
99
+ 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;
100
+ current = activePlacement = [atX_1, atY_1, myX_1, myY_1].join('-');
101
+ }
102
+ var _g = __read(current.split('-'), 4), atX = _g[0], atY = _g[1], myX = _g[2], myY = _g[3];
91
103
  myX = myX || atX;
92
104
  myY = myY || atY;
93
105
  positionLeft =
@@ -118,10 +130,21 @@ function calculatePosition(placement, overlayNode, target, container, padding, c
118
130
  width: overlayWidth,
119
131
  height: overlayHeight
120
132
  };
133
+ var visibleX = false;
134
+ var visibleY = false;
121
135
  if (transformed.x > 0 &&
122
- transformed.x + transformed.width < window.innerWidth &&
123
- transformed.y > 0 &&
136
+ transformed.x + transformed.width < window.innerWidth) {
137
+ visibleX = true;
138
+ !visiblePlacement.atX && (visiblePlacement.atX = atX);
139
+ !visiblePlacement.myX && (visiblePlacement.myX = myX);
140
+ }
141
+ if (transformed.y > 0 &&
124
142
  transformed.y + transformed.height < window.innerHeight) {
143
+ visibleY = true;
144
+ !visiblePlacement.atY && (visiblePlacement.atY = atY);
145
+ !visiblePlacement.myY && (visiblePlacement.myY = myY);
146
+ }
147
+ if (visibleX && visibleY) {
125
148
  break;
126
149
  }
127
150
  }
@@ -167,7 +190,7 @@ function calculatePosition(placement, overlayNode, target, container, padding, c
167
190
  else {
168
191
  throw new Error("calcOverlayPosition(): No such placement of \"".concat(placement, "\" found."));
169
192
  }
170
- var _c = __read(customOffset, 2), _d = _c[0], offSetX = _d === void 0 ? 0 : _d, _e = _c[1], offSetY = _e === void 0 ? 0 : _e;
193
+ var _h = __read(customOffset, 2), _j = _h[0], offSetX = _j === void 0 ? 0 : _j, _k = _h[1], offSetY = _k === void 0 ? 0 : _k;
171
194
  return {
172
195
  positionLeft: (positionLeft + offSetX) / scaleX,
173
196
  positionTop: (positionTop + offSetY) / scaleY,
@@ -185,5 +208,19 @@ function getStyleNumber(element, styleName) {
185
208
  }
186
209
  return (parseInt(getComputedStyle(element).getPropertyValue(styleName), 10) || 0);
187
210
  }
211
+ /** 根据关键字高亮显示文本内容 */
212
+ function renderTextByKeyword(rendererText, curKeyword) {
213
+ if (curKeyword && ~rendererText.indexOf(curKeyword)) {
214
+ var keywordStartIndex = rendererText.indexOf(curKeyword);
215
+ var keywordEndIndex = keywordStartIndex + curKeyword.length;
216
+ return (React.createElement("span", null,
217
+ rendererText.substring(0, keywordStartIndex),
218
+ React.createElement("span", { className: "is-keyword" }, curKeyword),
219
+ rendererText.substring(keywordEndIndex)));
220
+ }
221
+ else {
222
+ return rendererText;
223
+ }
224
+ }
188
225
 
189
- export { calculatePosition, getContainer, getStyleNumber, ownerDocument };
226
+ export { calculatePosition, getContainer, getStyleNumber, ownerDocument, renderTextByKeyword };
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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,8 +8,8 @@ import isString from 'lodash/isString';
8
8
  import isBoolean from 'lodash/isBoolean';
9
9
  import { evaluate, getFilters } from 'amis-formula';
10
10
  import { filter } from './tpl.js';
11
- import 'moment';
12
11
  import 'tslib';
12
+ import 'moment';
13
13
  import 'lodash/isPlainObject';
14
14
  import { getVariable } from './getVariable.js';
15
15
  import { resolveVariableAndFilter } from './resolveVariableAndFilter.js';
@@ -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
 
@@ -1,9 +1,9 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
- import { parse } from 'amis-formula';
6
+ import { memoryParse } from './memoryParse.js';
7
7
 
8
8
  /**
9
9
  * @file 公式语法解析
@@ -32,7 +32,7 @@ function collectVariables(strOrAst, execMode) {
32
32
  return COLLECT_EXPRESSION_CACHE[strOrAst];
33
33
  }
34
34
  var ast = typeof strOrAst === 'string'
35
- ? parse(strOrAst, {
35
+ ? memoryParse(strOrAst, {
36
36
  evalMode: execMode !== null && execMode !== void 0 ? execMode : false
37
37
  })
38
38
  : strOrAst;
@@ -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
 
@@ -131,7 +131,7 @@ export interface TreeArray extends Array<TreeItem> {
131
131
  * @param {Function} iterator 处理函数,返回的数据会被替换成新的。
132
132
  * @return {Tree} 返回处理过的 tree
133
133
  */
134
- export declare function mapTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>) => T, level?: number, depthFirst?: boolean, paths?: Array<T>): any[];
134
+ export declare function mapTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>, indexes: Array<number>) => T, level?: number, depthFirst?: boolean, paths?: Array<T>, indexes?: Array<number>): any[];
135
135
  /**
136
136
  * 遍历树
137
137
  * @param tree
@@ -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
@@ -157,7 +163,7 @@ export declare function getTree<T extends TreeItem>(tree: Array<T>, idx: Array<n
157
163
  * @param tree
158
164
  * @param iterator
159
165
  */
160
- export declare function filterTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number) => any, level?: number, depthFirst?: boolean): T[];
166
+ export declare function filterTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>) => any, level?: number, depthFirst?: boolean, paths?: Array<T>): T[];
161
167
  /**
162
168
  * 判断树中每个节点是否满足某个条件。
163
169
  * @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
  /**