amis-core 3.1.1 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.d.ts +1 -1
  3. package/esm/RootRenderer.js +3 -3
  4. package/esm/SchemaRenderer.js +6 -2
  5. package/esm/Scoped.d.ts +4 -1
  6. package/esm/Scoped.js +9 -5
  7. package/esm/StatusScoped.js +1 -1
  8. package/esm/WithRootStore.d.ts +4 -24
  9. package/esm/WithRootStore.js +12 -4
  10. package/esm/WithStore.js +23 -16
  11. package/esm/actions/Action.d.ts +1 -0
  12. package/esm/actions/Action.js +70 -45
  13. package/esm/actions/AjaxAction.d.ts +6 -8
  14. package/esm/actions/AjaxAction.js +20 -18
  15. package/esm/actions/BreakAction.js +1 -1
  16. package/esm/actions/BroadcastAction.js +1 -1
  17. package/esm/actions/CmptAction.d.ts +1 -2
  18. package/esm/actions/CmptAction.js +47 -32
  19. package/esm/actions/ContinueAction.js +1 -1
  20. package/esm/actions/CopyAction.js +1 -1
  21. package/esm/actions/CustomAction.js +3 -2
  22. package/esm/actions/DialogAction.d.ts +2 -0
  23. package/esm/actions/DialogAction.js +39 -23
  24. package/esm/actions/DrawerAction.js +4 -4
  25. package/esm/actions/EmailAction.js +1 -1
  26. package/esm/actions/LinkAction.js +1 -1
  27. package/esm/actions/LoopAction.js +1 -1
  28. package/esm/actions/PageAction.js +1 -1
  29. package/esm/actions/ParallelAction.js +1 -1
  30. package/esm/actions/StatusAction.d.ts +15 -0
  31. package/esm/actions/StatusAction.js +49 -0
  32. package/esm/actions/SwitchAction.js +1 -1
  33. package/esm/actions/ToastAction.js +1 -1
  34. package/esm/actions/index.d.ts +1 -0
  35. package/esm/components/CustomStyle.js +1 -1
  36. package/esm/components/LazyComponent.js +1 -1
  37. package/esm/components/Overlay.js +3 -2
  38. package/esm/components/PopOver.js +3 -2
  39. package/esm/env.js +1 -1
  40. package/esm/envOverwrite.js +1 -1
  41. package/esm/factory.js +2 -2
  42. package/esm/index.d.ts +3 -1
  43. package/esm/index.js +16 -14
  44. package/esm/locale.js +1 -1
  45. package/esm/polyfills.d.ts +3 -0
  46. package/esm/polyfills.js +18 -0
  47. package/esm/renderers/Form.d.ts +7 -7
  48. package/esm/renderers/Form.js +182 -128
  49. package/esm/renderers/Item.d.ts +82 -77
  50. package/esm/renderers/Item.js +90 -74
  51. package/esm/renderers/Options.js +1 -2
  52. package/esm/renderers/Placeholder.js +1 -1
  53. package/esm/renderers/builtin.js +1 -1
  54. package/esm/renderers/register.js +1 -1
  55. package/esm/renderers/wrapControl.d.ts +4 -24
  56. package/esm/renderers/wrapControl.js +140 -88
  57. package/esm/store/app.js +42 -4
  58. package/esm/store/combo.d.ts +564 -1892
  59. package/esm/store/combo.js +9 -2
  60. package/esm/store/crud.d.ts +4 -2
  61. package/esm/store/crud.js +17 -4
  62. package/esm/store/form.d.ts +182 -882
  63. package/esm/store/form.js +83 -81
  64. package/esm/store/formItem.d.ts +6 -2
  65. package/esm/store/formItem.js +19 -3
  66. package/esm/store/iRenderer.js +3 -2
  67. package/esm/store/index.js +1 -1
  68. package/esm/store/list.d.ts +1 -0
  69. package/esm/store/list.js +8 -2
  70. package/esm/store/manager.js +1 -1
  71. package/esm/store/modal.js +1 -1
  72. package/esm/store/node.js +1 -1
  73. package/esm/store/pagination.js +1 -1
  74. package/esm/store/root.js +3 -2
  75. package/esm/store/service.js +17 -12
  76. package/esm/store/status.js +1 -1
  77. package/esm/store/table.d.ts +604 -2020
  78. package/esm/store/table.js +86 -56
  79. package/esm/store/table2.d.ts +49 -0
  80. package/esm/store/table2.js +37 -4
  81. package/esm/theme.js +1 -1
  82. package/esm/types.d.ts +22 -5
  83. package/esm/utils/Animation.js +1 -1
  84. package/esm/utils/ColorScale.js +1 -1
  85. package/esm/utils/DataSchema.d.ts +3 -2
  86. package/esm/utils/DataSchema.js +27 -7
  87. package/esm/utils/DataScope.d.ts +10 -3
  88. package/esm/utils/DataScope.js +50 -12
  89. package/esm/utils/RootClose.js +1 -1
  90. package/esm/utils/SimpleMap.js +1 -1
  91. package/esm/utils/api.d.ts +2 -2
  92. package/esm/utils/api.js +152 -112
  93. package/esm/utils/arraySlice.d.ts +1 -0
  94. package/esm/utils/arraySlice.js +76 -0
  95. package/esm/utils/attachmentAdpator.js +1 -1
  96. package/esm/utils/autobind.js +1 -1
  97. package/esm/utils/columnsSplit.js +1 -1
  98. package/esm/utils/dataMapping.js +29 -19
  99. package/esm/utils/date.js +1 -1
  100. package/esm/utils/debug.d.ts +2 -0
  101. package/esm/utils/debug.js +34 -7
  102. package/esm/utils/decodeEntity.js +1 -1
  103. package/esm/utils/dom.js +4 -1
  104. package/esm/utils/errors.js +1 -1
  105. package/esm/utils/escapeHtml.js +1 -1
  106. package/esm/utils/filter-schema.js +1 -1
  107. package/esm/utils/filter.js +1 -1
  108. package/esm/utils/formatDuration.js +1 -1
  109. package/esm/utils/formula.d.ts +0 -1
  110. package/esm/utils/formula.js +6 -9
  111. package/esm/utils/getVariable.js +1 -1
  112. package/esm/utils/grammar.js +1 -1
  113. package/esm/utils/handleAction.js +1 -1
  114. package/esm/utils/helper.d.ts +19 -2
  115. package/esm/utils/helper.js +69 -10
  116. package/esm/utils/highlight.js +1 -1
  117. package/esm/utils/icon.d.ts +4 -2
  118. package/esm/utils/icon.js +3 -2
  119. package/esm/utils/image.js +1 -1
  120. package/esm/utils/index.d.ts +2 -0
  121. package/esm/utils/isPureVariable.js +1 -1
  122. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  123. package/esm/utils/keyToPath.js +1 -1
  124. package/esm/utils/makeSorter.js +1 -1
  125. package/esm/utils/math.d.ts +3 -0
  126. package/esm/utils/math.js +52 -0
  127. package/esm/utils/memoryParse.js +1 -1
  128. package/esm/utils/normalizeLink.js +18 -9
  129. package/esm/utils/normalizeOptions.js +1 -1
  130. package/esm/utils/object.d.ts +7 -0
  131. package/esm/utils/object.js +13 -2
  132. package/esm/utils/offset.js +1 -1
  133. package/esm/utils/offsetParent.js +1 -1
  134. package/esm/utils/optionValueCompare.js +2 -2
  135. package/esm/utils/position.js +1 -1
  136. package/esm/utils/prettyBytes.js +1 -1
  137. package/esm/utils/renderer-event.d.ts +1 -1
  138. package/esm/utils/renderer-event.js +14 -6
  139. package/esm/utils/replaceText.js +1 -1
  140. package/esm/utils/resize-sensor.js +1 -1
  141. package/esm/utils/resolveCondition.js +1 -1
  142. package/esm/utils/resolveVariable.js +1 -1
  143. package/esm/utils/resolveVariableAndFilter.js +1 -1
  144. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  145. package/esm/utils/scrollPosition.js +1 -1
  146. package/esm/utils/string2regExp.js +1 -1
  147. package/esm/utils/stripNumber.js +1 -1
  148. package/esm/utils/style-helper.js +1 -1
  149. package/esm/utils/style.js +1 -1
  150. package/esm/utils/toNumber.js +1 -1
  151. package/esm/utils/tokenize.js +1 -1
  152. package/esm/utils/tpl-builtin.js +1 -1
  153. package/esm/utils/tpl-lodash.js +1 -1
  154. package/esm/utils/tpl.js +1 -1
  155. package/esm/utils/uncontrollable.js +1 -1
  156. package/esm/utils/validations.js +1 -1
  157. package/lib/Root.js +10 -7
  158. package/lib/RootRenderer.d.ts +1 -1
  159. package/lib/RootRenderer.js +11 -8
  160. package/lib/SchemaRenderer.js +13 -6
  161. package/lib/Scoped.d.ts +4 -1
  162. package/lib/Scoped.js +19 -13
  163. package/lib/StatusScoped.js +5 -2
  164. package/lib/WithRootStore.d.ts +4 -24
  165. package/lib/WithRootStore.js +15 -4
  166. package/lib/WithStore.js +27 -17
  167. package/lib/actions/Action.d.ts +1 -0
  168. package/lib/actions/Action.js +70 -45
  169. package/lib/actions/AjaxAction.d.ts +6 -8
  170. package/lib/actions/AjaxAction.js +20 -18
  171. package/lib/actions/BreakAction.js +1 -1
  172. package/lib/actions/BroadcastAction.js +1 -1
  173. package/lib/actions/CmptAction.d.ts +1 -2
  174. package/lib/actions/CmptAction.js +47 -32
  175. package/lib/actions/ContinueAction.js +1 -1
  176. package/lib/actions/CopyAction.js +1 -1
  177. package/lib/actions/CustomAction.js +9 -5
  178. package/lib/actions/DialogAction.d.ts +2 -0
  179. package/lib/actions/DialogAction.js +39 -23
  180. package/lib/actions/DrawerAction.js +4 -4
  181. package/lib/actions/EmailAction.js +1 -1
  182. package/lib/actions/LinkAction.js +1 -1
  183. package/lib/actions/LoopAction.js +1 -1
  184. package/lib/actions/PageAction.js +1 -1
  185. package/lib/actions/ParallelAction.js +1 -1
  186. package/lib/actions/StatusAction.d.ts +15 -0
  187. package/lib/actions/StatusAction.js +53 -0
  188. package/lib/actions/SwitchAction.js +1 -1
  189. package/lib/actions/ToastAction.js +1 -1
  190. package/lib/actions/index.d.ts +1 -0
  191. package/lib/components/CustomStyle.js +1 -1
  192. package/lib/components/LazyComponent.js +12 -14
  193. package/lib/components/Overlay.js +15 -14
  194. package/lib/components/PopOver.js +12 -10
  195. package/lib/env.js +4 -1
  196. package/lib/envOverwrite.js +1 -1
  197. package/lib/factory.js +11 -9
  198. package/lib/index.d.ts +3 -1
  199. package/lib/index.js +26 -19
  200. package/lib/locale.js +6 -3
  201. package/lib/polyfills.d.ts +3 -0
  202. package/lib/polyfills.js +20 -0
  203. package/lib/renderers/Form.d.ts +7 -7
  204. package/lib/renderers/Form.js +194 -135
  205. package/lib/renderers/Item.d.ts +82 -77
  206. package/lib/renderers/Item.js +126 -104
  207. package/lib/renderers/Options.js +10 -5
  208. package/lib/renderers/Placeholder.js +1 -1
  209. package/lib/renderers/builtin.js +1 -1
  210. package/lib/renderers/register.js +1 -1
  211. package/lib/renderers/wrapControl.d.ts +4 -24
  212. package/lib/renderers/wrapControl.js +143 -88
  213. package/lib/store/app.js +44 -3
  214. package/lib/store/combo.d.ts +564 -1892
  215. package/lib/store/combo.js +9 -2
  216. package/lib/store/crud.d.ts +4 -2
  217. package/lib/store/crud.js +17 -4
  218. package/lib/store/form.d.ts +182 -882
  219. package/lib/store/form.js +81 -79
  220. package/lib/store/formItem.d.ts +6 -2
  221. package/lib/store/formItem.js +19 -3
  222. package/lib/store/iRenderer.js +9 -5
  223. package/lib/store/index.js +1 -1
  224. package/lib/store/list.d.ts +1 -0
  225. package/lib/store/list.js +8 -2
  226. package/lib/store/manager.js +1 -1
  227. package/lib/store/modal.js +1 -1
  228. package/lib/store/node.js +1 -1
  229. package/lib/store/pagination.js +1 -1
  230. package/lib/store/root.js +9 -5
  231. package/lib/store/service.js +17 -12
  232. package/lib/store/status.js +1 -1
  233. package/lib/store/table.d.ts +604 -2020
  234. package/lib/store/table.js +85 -55
  235. package/lib/store/table2.d.ts +49 -0
  236. package/lib/store/table2.js +36 -3
  237. package/lib/theme.js +6 -3
  238. package/lib/types.d.ts +22 -5
  239. package/lib/utils/Animation.js +1 -1
  240. package/lib/utils/ColorScale.js +1 -1
  241. package/lib/utils/DataSchema.d.ts +3 -2
  242. package/lib/utils/DataSchema.js +27 -7
  243. package/lib/utils/DataScope.d.ts +10 -3
  244. package/lib/utils/DataScope.js +50 -11
  245. package/lib/utils/RootClose.js +1 -1
  246. package/lib/utils/SimpleMap.js +1 -1
  247. package/lib/utils/api.d.ts +2 -2
  248. package/lib/utils/api.js +151 -111
  249. package/lib/utils/arraySlice.d.ts +1 -0
  250. package/lib/utils/arraySlice.js +80 -0
  251. package/lib/utils/attachmentAdpator.js +1 -1
  252. package/lib/utils/autobind.js +1 -1
  253. package/lib/utils/columnsSplit.js +8 -6
  254. package/lib/utils/dataMapping.js +29 -19
  255. package/lib/utils/date.js +1 -1
  256. package/lib/utils/debug.d.ts +2 -0
  257. package/lib/utils/debug.js +61 -33
  258. package/lib/utils/decodeEntity.js +1 -1
  259. package/lib/utils/dom.js +10 -5
  260. package/lib/utils/errors.js +1 -1
  261. package/lib/utils/escapeHtml.js +1 -1
  262. package/lib/utils/filter-schema.js +1 -1
  263. package/lib/utils/filter.js +1 -1
  264. package/lib/utils/formatDuration.js +1 -1
  265. package/lib/utils/formula.d.ts +0 -1
  266. package/lib/utils/formula.js +6 -10
  267. package/lib/utils/getVariable.js +1 -1
  268. package/lib/utils/grammar.js +1 -1
  269. package/lib/utils/handleAction.js +1 -1
  270. package/lib/utils/helper.d.ts +19 -2
  271. package/lib/utils/helper.js +70 -9
  272. package/lib/utils/highlight.js +8 -9
  273. package/lib/utils/icon.d.ts +4 -2
  274. package/lib/utils/icon.js +12 -10
  275. package/lib/utils/image.js +1 -1
  276. package/lib/utils/index.d.ts +2 -0
  277. package/lib/utils/isPureVariable.js +1 -1
  278. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  279. package/lib/utils/keyToPath.js +1 -1
  280. package/lib/utils/makeSorter.js +1 -1
  281. package/lib/utils/math.d.ts +3 -0
  282. package/lib/utils/math.js +58 -0
  283. package/lib/utils/memoryParse.js +1 -1
  284. package/lib/utils/normalizeLink.js +18 -9
  285. package/lib/utils/normalizeOptions.js +1 -1
  286. package/lib/utils/object.d.ts +7 -0
  287. package/lib/utils/object.js +13 -1
  288. package/lib/utils/offset.js +1 -1
  289. package/lib/utils/offsetParent.js +1 -1
  290. package/lib/utils/optionValueCompare.js +7 -3
  291. package/lib/utils/position.js +1 -1
  292. package/lib/utils/prettyBytes.js +1 -1
  293. package/lib/utils/renderer-event.d.ts +1 -1
  294. package/lib/utils/renderer-event.js +13 -5
  295. package/lib/utils/replaceText.js +1 -1
  296. package/lib/utils/resize-sensor.js +1 -1
  297. package/lib/utils/resolveCondition.js +1 -1
  298. package/lib/utils/resolveVariable.js +1 -1
  299. package/lib/utils/resolveVariableAndFilter.js +1 -1
  300. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  301. package/lib/utils/scrollPosition.js +1 -1
  302. package/lib/utils/string2regExp.js +1 -1
  303. package/lib/utils/stripNumber.js +1 -1
  304. package/lib/utils/style-helper.js +1 -1
  305. package/lib/utils/style.js +1 -1
  306. package/lib/utils/toNumber.js +1 -1
  307. package/lib/utils/tokenize.js +1 -1
  308. package/lib/utils/tpl-builtin.js +1 -1
  309. package/lib/utils/tpl-lodash.js +1 -1
  310. package/lib/utils/tpl.js +1 -1
  311. package/lib/utils/uncontrollable.js +1 -1
  312. package/lib/utils/validations.js +1 -1
  313. package/package.json +9 -4
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -90,26 +90,27 @@ function dataMapping(to, from, ignoreFunction, convertKeyToPath, ignoreIfNotMatc
90
90
  }
91
91
  }
92
92
  else {
93
- Object.keys(to).forEach(function (key) {
94
- var value = to[key];
95
- var keys;
96
- if (typeof ignoreFunction === 'function' && ignoreFunction(key, value)) {
97
- // 如果被ignore,不做数据映射处理。
98
- setVariable(ret, key, value, convertKeyToPath);
99
- }
100
- else if (key === '&' && value === '$$') {
93
+ var objectKeys = Object.keys(to);
94
+ // 如果存在 '&' 作为 key,则特殊处理
95
+ // 就是无论这个 key 的位置在什么地方始终都是当放在最前面
96
+ var idx = objectKeys.indexOf('&');
97
+ if (~idx) {
98
+ var value_1 = to['&'];
99
+ objectKeys.splice(idx, 1);
100
+ if (value_1 === '$$') {
101
101
  ret = __assign(__assign({}, ret), from);
102
102
  }
103
- else if (key === '&') {
104
- var v = isPlainObject(value) &&
105
- (keys = Object.keys(value)) &&
106
- keys.length === 1 &&
107
- from[keys[0].substring(1)] &&
108
- Array.isArray(from[keys[0].substring(1)])
109
- ? from[keys[0].substring(1)].map(function (raw) {
110
- return dataMapping(value[keys[0]], createObject(from, raw), ignoreFunction, convertKeyToPath, ignoreIfNotMatch);
103
+ else {
104
+ var keys_1;
105
+ var v = isPlainObject(value_1) &&
106
+ (keys_1 = Object.keys(value_1)) &&
107
+ keys_1.length === 1 &&
108
+ from[keys_1[0].substring(1)] &&
109
+ Array.isArray(from[keys_1[0].substring(1)])
110
+ ? from[keys_1[0].substring(1)].map(function (raw) {
111
+ return dataMapping(value_1[keys_1[0]], createObject(from, raw), ignoreFunction, convertKeyToPath, ignoreIfNotMatch);
111
112
  })
112
- : resolveMapping(value, from, undefined, ignoreIfNotMatch);
113
+ : resolveMapping(value_1, from, undefined, ignoreIfNotMatch);
113
114
  if (Array.isArray(v) || typeof v === 'string') {
114
115
  ret = v;
115
116
  }
@@ -120,10 +121,19 @@ function dataMapping(to, from, ignoreFunction, convertKeyToPath, ignoreIfNotMatc
120
121
  ret = __assign(__assign({}, ret), v);
121
122
  }
122
123
  }
124
+ }
125
+ objectKeys.forEach(function (key) {
126
+ var value = to[key];
127
+ if (typeof ignoreFunction === 'function' && ignoreFunction(key, value)) {
128
+ // 如果被ignore,不做数据映射处理。
129
+ setVariable(ret, key, value, convertKeyToPath);
130
+ }
123
131
  else if (value === '$$') {
124
132
  setVariable(ret, key, from, convertKeyToPath);
125
133
  }
126
- else if (value && value[0] === '$') {
134
+ else if (typeof value === 'string' &&
135
+ value.length > 0 &&
136
+ value[0] === '$') {
127
137
  var v = resolveMapping(value, from, undefined, ignoreIfNotMatch);
128
138
  setVariable(ret, key, v, convertKeyToPath);
129
139
  if (v === '__undefined') {
package/esm/utils/date.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -2,7 +2,9 @@
2
2
  * amis 运行时调试功能,为了避免循环引用,这个组件不要依赖 amis 里的组件
3
3
  */
4
4
  import React, { Component } from 'react';
5
+ export declare const JsonView: React.LazyExoticComponent<React.ComponentType<import("react-json-view").ReactJsonViewProps>>;
5
6
  export declare function enableDebug(): void;
7
+ export declare function disableDebug(): void;
6
8
  interface DebugWrapperProps {
7
9
  renderer: any;
8
10
  children?: React.ReactNode;
@@ -1,13 +1,12 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __decorate, __metadata, __values, __read, __extends } from 'tslib';
7
7
  import React, { useRef, useState, useEffect, Component } from 'react';
8
8
  import cx from 'classnames';
9
- import { findDOMNode, render } from 'react-dom';
10
- import JsonView from 'react-json-view';
9
+ import { findDOMNode, render, unmountComponentAtNode } from 'react-dom';
11
10
  import { observable, autorun } from 'mobx';
12
11
  import { observer } from 'mobx-react';
13
12
  import { uuidv4 } from './helper.js';
@@ -16,6 +15,7 @@ import { position } from './position.js';
16
15
  /**
17
16
  * amis 运行时调试功能,为了避免循环引用,这个组件不要依赖 amis 里的组件
18
17
  */
18
+ var JsonView = React.lazy(function () { return import('react-json-view'); });
19
19
  /** @class */ ((function () {
20
20
  function Log() {
21
21
  this.cat = '';
@@ -113,7 +113,8 @@ var LogView = observer(function (_a) {
113
113
  log.cat,
114
114
  "] ",
115
115
  log.msg),
116
- log.ext ? (React.createElement(JsonView, { name: null, theme: "monokai", src: JSON.parse(log.ext), collapsed: true, enableClipboard: false, displayDataTypes: false, collapseStringsAfterLength: ellipsisThreshold, iconStyle: "square" })) : null));
116
+ log.ext ? (React.createElement(React.Suspense, { fallback: React.createElement("div", null, "Loading...") },
117
+ React.createElement(JsonView, { name: null, theme: "monokai", src: JSON.parse(log.ext), collapsed: true, enableClipboard: false, displayDataTypes: false, collapseStringsAfterLength: ellipsisThreshold, iconStyle: "square" }))) : null));
117
118
  })));
118
119
  });
119
120
  var AMISDebug = observer(function (_a) {
@@ -143,7 +144,8 @@ var AMISDebug = observer(function (_a) {
143
144
  React.createElement("h3", null,
144
145
  "Data Level-",
145
146
  level),
146
- React.createElement(JsonView, { key: "dataview-".concat(stack), name: null, theme: "monokai", src: stack, collapsed: level === 0 ? false : true, enableClipboard: false, displayDataTypes: false, iconStyle: "square" })));
147
+ React.createElement(React.Suspense, { fallback: React.createElement("div", null, "Loading...") },
148
+ React.createElement(JsonView, { key: "dataview-".concat(stack), name: null, theme: "monokai", src: stack, collapsed: level === 0 ? false : true, enableClipboard: false, displayDataTypes: false, iconStyle: "square" }))));
147
149
  level += 1;
148
150
  }
149
151
  }
@@ -254,7 +256,7 @@ function handleMouseclick(e) {
254
256
  }
255
257
  var dom = e.target;
256
258
  var target = dom.closest("[data-debug-id]");
257
- if (target) {
259
+ if (target && !target.closest('.AMISDebug')) {
258
260
  store.activeId = target.getAttribute('data-debug-id');
259
261
  store.tab = 'inspect';
260
262
  }
@@ -294,6 +296,7 @@ autorun(function () {
294
296
  });
295
297
  // 页面中只能有一个实例
296
298
  var isEnabled = false;
299
+ var unmount;
297
300
  function enableDebug() {
298
301
  if (isEnabled) {
299
302
  return;
@@ -302,12 +305,36 @@ function enableDebug() {
302
305
  var amisDebugElement = document.createElement('div');
303
306
  document.body.appendChild(amisDebugElement);
304
307
  var element = React.createElement(AMISDebug, { store: store });
308
+ // if (parseInt(version.split('.')[0], 10) >= 18) {
309
+ // const root = createRoot(amisDebugElement);
310
+ // root.render(element);
311
+ // unmount = () => {
312
+ // root.unmount();
313
+ // document.body.removeChild(amisDebugElement);
314
+ // };
315
+ // } else {
305
316
  render(element, amisDebugElement);
317
+ unmount = function () {
318
+ unmountComponentAtNode(amisDebugElement);
319
+ document.body.removeChild(amisDebugElement);
320
+ };
321
+ // }
306
322
  document.body.appendChild(amisHoverBox);
307
323
  document.body.appendChild(amisActiveBox);
308
324
  document.addEventListener('mousemove', handleMouseMove);
309
325
  document.addEventListener('click', handleMouseclick);
310
326
  }
327
+ function disableDebug() {
328
+ if (!isEnabled) {
329
+ return;
330
+ }
331
+ isEnabled = false;
332
+ unmount === null || unmount === void 0 ? void 0 : unmount();
333
+ document.body.removeChild(amisHoverBox);
334
+ document.body.removeChild(amisActiveBox);
335
+ document.removeEventListener('mousemove', handleMouseMove);
336
+ document.removeEventListener('click', handleMouseclick);
337
+ }
311
338
  var DebugWrapper = /** @class */ (function (_super) {
312
339
  __extends(DebugWrapper, _super);
313
340
  function DebugWrapper() {
@@ -386,4 +413,4 @@ function warning(cat, msg, ext) {
386
413
  store.logs.push(log);
387
414
  }
388
415
 
389
- export { DebugWrapper, debug, enableDebug, warning };
416
+ export { DebugWrapper, JsonView, debug, disableDebug, enableDebug, warning };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/esm/utils/dom.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -210,6 +210,9 @@ function getStyleNumber(element, styleName) {
210
210
  }
211
211
  /** 根据关键字高亮显示文本内容 */
212
212
  function renderTextByKeyword(rendererText, curKeyword) {
213
+ if (!rendererText || typeof rendererText !== 'string') {
214
+ return rendererText;
215
+ }
213
216
  if (curKeyword && ~rendererText.indexOf(curKeyword)) {
214
217
  var keywordStartIndex = rendererText.indexOf(curKeyword);
215
218
  var keywordEndIndex = keywordStartIndex + curKeyword.length;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -13,5 +13,4 @@ export declare function isNeedFormula(expression: any, prevData: {
13
13
  }, curData: {
14
14
  [propName: string]: any;
15
15
  }): boolean;
16
- export declare function isNowFormula(expression: string): boolean;
17
16
  export declare function replaceExpression(expression: any): any;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
- import isObjectByLodash from 'lodash/isObject';
6
+ import isObject from 'lodash/isObject';
7
7
  import isString from 'lodash/isString';
8
8
  import isBoolean from 'lodash/isBoolean';
9
9
  import { evaluate, getFilters } from 'amis-formula';
@@ -114,7 +114,7 @@ var FormulaExec = {
114
114
  },
115
115
  collect: function (expression) {
116
116
  var variables = [];
117
- if (isObjectByLodash(expression) || isString(expression)) {
117
+ if (isObject(expression) || isString(expression)) {
118
118
  // 仅对 Object类型 和 String类型 进行变量提取
119
119
  variables = collectVariables(expression);
120
120
  }
@@ -198,7 +198,8 @@ function isNeedFormula(expression, prevData, curData) {
198
198
  try {
199
199
  var variables = FormulaExec.collect(expression);
200
200
  return variables.some(function (variable) {
201
- return FormulaExec.var(variable, prevData) !== FormulaExec.var(variable, curData);
201
+ return FormulaExec.var(variable, prevData) !==
202
+ FormulaExec.var(variable, curData);
202
203
  });
203
204
  }
204
205
  catch (e) {
@@ -206,10 +207,6 @@ function isNeedFormula(expression, prevData, curData) {
206
207
  return false;
207
208
  }
208
209
  }
209
- function isNowFormula(expression) {
210
- var block = expression.split(/\${|\||}/).filter(function (item) { return item; });
211
- return block[1] === 'now';
212
- }
213
210
  // 将 \${xx} 替换成 ${xx}
214
211
  function replaceExpression(expression) {
215
212
  if (expression &&
@@ -220,4 +217,4 @@ function replaceExpression(expression) {
220
217
  return expression;
221
218
  }
222
219
 
223
- export { FormulaExec, formulaExec, isExpression, isNeedFormula, isNowFormula, registerFormulaExec, replaceExpression };
220
+ export { FormulaExec, formulaExec, isExpression, isNeedFormula, registerFormulaExec, replaceExpression };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -256,7 +256,7 @@ export declare const autobind: typeof autobindMethod;
256
256
  export declare const bulkBindFunctions: <T extends {
257
257
  [propName: string]: any;
258
258
  }>(context: T, funNames: FunctionPropertyNames<T>[]) => void;
259
- export declare function sortArray<T extends any>(items: Array<T>, field: string, dir: -1 | 1): Array<T>;
259
+ export declare function sortArray<T extends any>(items: Array<T>, field: string, dir: -1 | 1, fieldGetter?: (item: T, field: string) => any): Array<T>;
260
260
  export declare function hasFile(object: any): boolean;
261
261
  export declare function qsstringify(data: any, options?: any, keepEmptyArray?: boolean): string;
262
262
  export declare function qsparse(data: string, options?: any): qs.ParsedQs;
@@ -268,6 +268,15 @@ export declare function loadScript(src: string): Promise<void>;
268
268
  export declare function loadStyle(href: string): Promise<void>;
269
269
  export declare class SkipOperation extends Error {
270
270
  }
271
+ export declare class ValidateError extends Error {
272
+ name: 'ValidateError';
273
+ detail: {
274
+ [propName: string]: Array<string> | string;
275
+ };
276
+ constructor(message: string, error: {
277
+ [propName: string]: Array<string> | string;
278
+ });
279
+ }
271
280
  /**
272
281
  * 深度查找具有某个 key 名字段的对象,实际实现是 internalFindObjectsWithKey,这里包一层是为了做循环引用检测
273
282
  * @param obj
@@ -283,7 +292,8 @@ export declare function getPropValue<T extends {
283
292
  name?: string;
284
293
  data?: any;
285
294
  defaultValue?: any;
286
- }>(props: T, getter?: (props: T) => any, canAccessSuper?: boolean): any;
295
+ canAccessSuperData?: boolean;
296
+ }>(props: T, getter?: (props: T) => any, canAccessSuper?: boolean | undefined): any;
287
297
  export declare function detectPropValueChanged<T extends {
288
298
  value?: any;
289
299
  name?: string;
@@ -314,6 +324,13 @@ export declare function hashCode(s: string): number;
314
324
  * @param mapper
315
325
  */
316
326
  export declare function JSONTraverse(json: any, mapper: (value: any, key: string | number, host: Object) => any): void;
327
+ /**
328
+ * 每层都会执行,返回新的对象,新对象不会递归下去
329
+ * @param json
330
+ * @param mapper
331
+ * @returns
332
+ */
333
+ export declare function JSONValueMap(json: any, mapper: (value: any, key: string | number, host: Object, stack: Array<Object>) => any, stack?: Array<Object>): any;
317
334
  export declare function convertArrayValueToMoment(value: number[], types: string[], mom: moment.Moment): moment.Moment;
318
335
  export declare function getRange(min: number, max: number, step?: number): number[];
319
336
  export declare function repeatCount(count: number, iterator: (index: number) => any): any[];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -858,11 +858,11 @@ var autobind = autobindMethod;
858
858
  var bulkBindFunctions = function (context, funNames) {
859
859
  funNames.forEach(function (key) { return (context[key] = context[key].bind(context)); });
860
860
  };
861
- function sortArray(items, field, dir) {
861
+ function sortArray(items, field, dir, fieldGetter) {
862
862
  return items.sort(function (a, b) {
863
863
  var ret;
864
- var a1 = a[field];
865
- var b1 = b[field];
864
+ var a1 = fieldGetter ? fieldGetter(a, field) : a[field];
865
+ var b1 = fieldGetter ? fieldGetter(b, field) : b[field];
866
866
  if (typeof a1 === 'number' && typeof b1 === 'number') {
867
867
  ret = a1 < b1 ? -1 : a1 === b1 ? 0 : 1;
868
868
  }
@@ -885,11 +885,12 @@ function qsstringify(data, options, keepEmptyArray) {
885
885
  arrayFormat: 'indices',
886
886
  encodeValuesOnly: true
887
887
  }; }
888
- // qs会保留空字符串。fix: Combo模式的空数组,无法清空。改为存为空字符串;只转换一层
889
- keepEmptyArray &&
890
- Object.keys(data).forEach(function (key) {
891
- Array.isArray(data[key]) && !data[key].length && (data[key] = '');
888
+ // qs会保留空字符串。fix: Combo模式的空数组,无法清空。改为存为空字符串;
889
+ if (keepEmptyArray) {
890
+ data = JSONValueMap(data, function (value) {
891
+ return Array.isArray(value) && !value.length ? '' : value;
892
892
  });
893
+ }
893
894
  return qs.stringify(data, options);
894
895
  }
895
896
  function qsparse(data, options) {
@@ -958,6 +959,7 @@ function chainFunctions() {
958
959
  function chainEvents(props, schema) {
959
960
  var ret = {};
960
961
  Object.keys(props).forEach(function (key) {
962
+ var _a;
961
963
  if (key.substr(0, 2) === 'on' &&
962
964
  typeof props[key] === 'function' &&
963
965
  typeof schema[key] === 'function' &&
@@ -971,7 +973,7 @@ function chainEvents(props, schema) {
971
973
  }
972
974
  }
973
975
  else {
974
- ret[key] = props[key];
976
+ ret[key] = (_a = props[key]) !== null && _a !== void 0 ? _a : schema[key];
975
977
  }
976
978
  });
977
979
  return ret;
@@ -1039,6 +1041,17 @@ var SkipOperation = /** @class */ (function (_super) {
1039
1041
  }
1040
1042
  return SkipOperation;
1041
1043
  }(Error));
1044
+ var ValidateError = /** @class */ (function (_super) {
1045
+ __extends(ValidateError, _super);
1046
+ function ValidateError(message, error) {
1047
+ var _this = _super.call(this) || this;
1048
+ _this.name = 'ValidateError';
1049
+ _this.message = message;
1050
+ _this.detail = error;
1051
+ return _this;
1052
+ }
1053
+ return ValidateError;
1054
+ }(Error));
1042
1055
  /**
1043
1056
  * 检查对象是否有循环引用,来自 https://stackoverflow.com/a/34909127
1044
1057
  * @param obj
@@ -1121,6 +1134,7 @@ function resolveValueByName(data, name, canAccessSuper) {
1121
1134
  // 统一的获取 value 值方法
1122
1135
  function getPropValue(props, getter, canAccessSuper) {
1123
1136
  var _a, _b;
1137
+ if (canAccessSuper === void 0) { canAccessSuper = props.canAccessSuperData; }
1124
1138
  var name = props.name, value = props.value, data = props.data, defaultValue = props.defaultValue;
1125
1139
  return ((_b = (_a = value !== null && value !== void 0 ? value : getter === null || getter === void 0 ? void 0 : getter(props)) !== null && _a !== void 0 ? _a : resolveValueByName(data, name, canAccessSuper)) !== null && _b !== void 0 ? _b : defaultValue);
1126
1140
  }
@@ -1237,6 +1251,51 @@ function JSONTraverse(json, mapper) {
1237
1251
  }
1238
1252
  });
1239
1253
  }
1254
+ /**
1255
+ * 每层都会执行,返回新的对象,新对象不会递归下去
1256
+ * @param json
1257
+ * @param mapper
1258
+ * @returns
1259
+ */
1260
+ function JSONValueMap(json, mapper, stack) {
1261
+ if (stack === void 0) { stack = []; }
1262
+ if (!isPlainObject(json) && !Array.isArray(json)) {
1263
+ return json;
1264
+ }
1265
+ var iterator = function (origin, key, host, stack) {
1266
+ if (stack === void 0) { stack = []; }
1267
+ var maped = mapper(origin, key, host, stack);
1268
+ if (maped === origin && (isPlainObject(origin) || Array.isArray(origin))) {
1269
+ return JSONValueMap(origin, mapper, stack);
1270
+ }
1271
+ return maped;
1272
+ };
1273
+ if (Array.isArray(json)) {
1274
+ var flag_1 = false;
1275
+ var mapped = json.map(function (value, index) {
1276
+ var result = iterator(value, index, json, [json].concat(stack));
1277
+ if (result !== value) {
1278
+ flag_1 = true;
1279
+ return result;
1280
+ }
1281
+ return value;
1282
+ });
1283
+ return flag_1 ? mapped : json;
1284
+ }
1285
+ var flag = false;
1286
+ var toUpdate = {};
1287
+ Object.keys(json).forEach(function (key) {
1288
+ var value = json[key];
1289
+ var result = iterator(value, key, json, [json].concat(stack));
1290
+ if (result !== value) {
1291
+ flag = true;
1292
+ toUpdate[key] = result;
1293
+ return;
1294
+ }
1295
+ });
1296
+ return flag
1297
+ ? __assign(__assign({}, json), toUpdate) : json;
1298
+ }
1240
1299
  function convertArrayValueToMoment(value, types, mom) {
1241
1300
  if (value.length === 0)
1242
1301
  return mom;
@@ -1290,4 +1349,4 @@ function parseQuery(location) {
1290
1349
  return merge(normalizedQuery, hashQuery);
1291
1350
  }
1292
1351
 
1293
- export { JSONTraverse, SkipOperation, __uri, anyChanged, autobind, bulkBindFunctions, camel, chainEvents, chainFunctions, convertArrayValueToMoment, detectPropValueChanged, difference, eachTree, everyTree, filterTree, findIndex, findObjectsWithKey, findTree, findTreeAll, findTreeIndex, flattenTree, flattenTreeWithLeafNodes, getLevelFromClassName, getPropValue, getRange, getScrollParent, getScrollbarWidth, getTree, getTreeAncestors, getTreeDepth, getTreeParent, getWidthRate, guid, hasAbility, hasFile, hasOwnPropertyInPath, hasVisibleExpression, hashCode, immutableExtends, injectPropsToObject, isArrayChildrenModified, isBreakpoint, isClickOnInput, isDisabled, isEmpty, isMobile, isNumeric, isObjectShallowModified, isSuperDataModified, isUnfolded, isVisible, lcFirst, loadScript, loadStyle, makeColumnClassBuild, makeHorizontalDeeper, mapObject, mapTree, noop, normalizeNodePath, object2formData, omitControls, padArr, parseQuery, pickEventsProps, preventDefault, promisify, qsparse, qsstringify, range, removeHTMLTag, repeatCount, rmUndefined, someTree, sortArray, spliceTree, syncDataFromSuper, ucFirst, until, uuid, uuidv4, visibilityFilter };
1352
+ export { JSONTraverse, JSONValueMap, SkipOperation, ValidateError, __uri, anyChanged, autobind, bulkBindFunctions, camel, chainEvents, chainFunctions, convertArrayValueToMoment, detectPropValueChanged, difference, eachTree, everyTree, filterTree, findIndex, findObjectsWithKey, findTree, findTreeAll, findTreeIndex, flattenTree, flattenTreeWithLeafNodes, getLevelFromClassName, getPropValue, getRange, getScrollParent, getScrollbarWidth, getTree, getTreeAncestors, getTreeDepth, getTreeParent, getWidthRate, guid, hasAbility, hasFile, hasOwnPropertyInPath, hasVisibleExpression, hashCode, immutableExtends, injectPropsToObject, isArrayChildrenModified, isBreakpoint, isClickOnInput, isDisabled, isEmpty, isMobile, isNumeric, isObjectShallowModified, isSuperDataModified, isUnfolded, isVisible, lcFirst, loadScript, loadStyle, makeColumnClassBuild, makeHorizontalDeeper, mapObject, mapTree, noop, normalizeNodePath, object2formData, omitControls, padArr, parseQuery, pickEventsProps, preventDefault, promisify, qsparse, qsstringify, range, removeHTMLTag, repeatCount, rmUndefined, someTree, sortArray, spliceTree, syncDataFromSuper, ucFirst, until, uuid, uuidv4, visibilityFilter };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -3,19 +3,21 @@
3
3
  */
4
4
  import React from 'react';
5
5
  import { ClassNamesFn } from '../theme';
6
- export interface IconCheckedSchema {
6
+ interface IconCheckedSchema {
7
7
  id: string;
8
8
  name?: string;
9
9
  svg?: string;
10
10
  }
11
- export interface IconCheckedSchemaNew {
11
+ interface IconCheckedSchemaNew {
12
12
  type: 'icon';
13
13
  icon: IconCheckedSchema;
14
14
  }
15
15
  /**
16
+ * 废弃,不建议使用
16
17
  * 判断字符串来生成 i 或 img
17
18
  * @param icon icon 设置
18
19
  * @param className 内部用的 className
19
20
  * @param classNameProp amis 配置里设置的 className
20
21
  */
21
22
  export declare const generateIcon: (cx: ClassNamesFn, icon?: string | IconCheckedSchema | React.ReactNode | IconCheckedSchemaNew, className?: string, classNameProp?: string) => React.JSX.Element | null | undefined;
23
+ export {};
package/esm/utils/icon.js CHANGED
@@ -1,15 +1,16 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import React from 'react';
7
- import { isObject } from 'lodash';
7
+ import isObject from 'lodash/isObject';
8
8
 
9
9
  /**
10
10
  * @file 图标支持的公共方法,主要是支持自动识别地址和 icon-font
11
11
  */
12
12
  /**
13
+ * 废弃,不建议使用
13
14
  * 判断字符串来生成 i 或 img
14
15
  * @param icon icon 设置
15
16
  * @param className 内部用的 className
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -54,5 +54,7 @@ export * from './toNumber';
54
54
  export * from './decodeEntity';
55
55
  export * from './style-helper';
56
56
  export * from './resolveCondition';
57
+ export * from './arraySlice';
58
+ export * from './math';
57
59
  import animation from './Animation';
58
60
  export { animation };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -0,0 +1,3 @@
1
+ export declare function safeAdd(arg1: number, arg2: number): number;
2
+ export declare function safeSub(arg1: number, arg2: number): number;
3
+ export declare function numberFormatter(num: number | string, precision?: number): string;