amis-core 3.1.1 → 3.2.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 (281) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.d.ts +1 -1
  3. package/esm/RootRenderer.js +2 -2
  4. package/esm/SchemaRenderer.js +3 -2
  5. package/esm/Scoped.js +2 -1
  6. package/esm/StatusScoped.js +1 -1
  7. package/esm/WithRootStore.d.ts +4 -24
  8. package/esm/WithRootStore.js +12 -4
  9. package/esm/WithStore.js +23 -16
  10. package/esm/actions/Action.js +14 -14
  11. package/esm/actions/AjaxAction.js +1 -1
  12. package/esm/actions/BreakAction.js +1 -1
  13. package/esm/actions/BroadcastAction.js +1 -1
  14. package/esm/actions/CmptAction.js +2 -2
  15. package/esm/actions/ContinueAction.js +1 -1
  16. package/esm/actions/CopyAction.js +1 -1
  17. package/esm/actions/CustomAction.js +2 -1
  18. package/esm/actions/DialogAction.d.ts +2 -0
  19. package/esm/actions/DialogAction.js +40 -23
  20. package/esm/actions/DrawerAction.js +4 -4
  21. package/esm/actions/EmailAction.js +1 -1
  22. package/esm/actions/LinkAction.js +1 -1
  23. package/esm/actions/LoopAction.js +1 -1
  24. package/esm/actions/PageAction.js +1 -1
  25. package/esm/actions/ParallelAction.js +1 -1
  26. package/esm/actions/SwitchAction.js +1 -1
  27. package/esm/actions/ToastAction.js +1 -1
  28. package/esm/components/CustomStyle.js +1 -1
  29. package/esm/components/LazyComponent.js +1 -1
  30. package/esm/components/Overlay.js +2 -1
  31. package/esm/components/PopOver.js +2 -1
  32. package/esm/env.js +1 -1
  33. package/esm/envOverwrite.js +1 -1
  34. package/esm/factory.js +1 -1
  35. package/esm/index.d.ts +1 -0
  36. package/esm/index.js +6 -4
  37. package/esm/locale.js +1 -1
  38. package/esm/polyfills.d.ts +3 -0
  39. package/esm/polyfills.js +18 -0
  40. package/esm/renderers/Form.d.ts +1 -1
  41. package/esm/renderers/Form.js +17 -7
  42. package/esm/renderers/Item.d.ts +88 -59
  43. package/esm/renderers/Item.js +86 -40
  44. package/esm/renderers/Options.js +1 -1
  45. package/esm/renderers/Placeholder.js +1 -1
  46. package/esm/renderers/builtin.js +1 -1
  47. package/esm/renderers/register.js +1 -1
  48. package/esm/renderers/wrapControl.d.ts +4 -24
  49. package/esm/renderers/wrapControl.js +51 -53
  50. package/esm/store/app.js +37 -3
  51. package/esm/store/combo.d.ts +168 -28
  52. package/esm/store/combo.js +1 -1
  53. package/esm/store/crud.d.ts +3 -2
  54. package/esm/store/crud.js +12 -5
  55. package/esm/store/form.d.ts +72 -12
  56. package/esm/store/form.js +4 -4
  57. package/esm/store/formItem.d.ts +2 -1
  58. package/esm/store/formItem.js +7 -2
  59. package/esm/store/iRenderer.js +2 -1
  60. package/esm/store/index.js +1 -1
  61. package/esm/store/list.d.ts +1 -0
  62. package/esm/store/list.js +8 -2
  63. package/esm/store/manager.js +1 -1
  64. package/esm/store/modal.js +1 -1
  65. package/esm/store/node.js +1 -1
  66. package/esm/store/pagination.js +1 -1
  67. package/esm/store/root.js +2 -1
  68. package/esm/store/service.js +14 -9
  69. package/esm/store/status.js +1 -1
  70. package/esm/store/table.d.ts +145 -24
  71. package/esm/store/table.js +8 -2
  72. package/esm/store/table2.js +1 -1
  73. package/esm/theme.js +1 -1
  74. package/esm/types.d.ts +5 -2
  75. package/esm/utils/Animation.js +1 -1
  76. package/esm/utils/ColorScale.js +1 -1
  77. package/esm/utils/DataSchema.d.ts +3 -2
  78. package/esm/utils/DataSchema.js +27 -7
  79. package/esm/utils/DataScope.d.ts +10 -3
  80. package/esm/utils/DataScope.js +50 -12
  81. package/esm/utils/RootClose.js +1 -1
  82. package/esm/utils/SimpleMap.js +1 -1
  83. package/esm/utils/api.js +40 -32
  84. package/esm/utils/arraySlice.d.ts +1 -0
  85. package/esm/utils/arraySlice.js +76 -0
  86. package/esm/utils/attachmentAdpator.js +1 -1
  87. package/esm/utils/autobind.js +1 -1
  88. package/esm/utils/columnsSplit.js +1 -1
  89. package/esm/utils/dataMapping.js +26 -18
  90. package/esm/utils/date.js +1 -1
  91. package/esm/utils/debug.js +1 -1
  92. package/esm/utils/decodeEntity.js +1 -1
  93. package/esm/utils/dom.js +4 -1
  94. package/esm/utils/errors.js +1 -1
  95. package/esm/utils/escapeHtml.js +1 -1
  96. package/esm/utils/filter-schema.js +1 -1
  97. package/esm/utils/filter.js +1 -1
  98. package/esm/utils/formatDuration.js +1 -1
  99. package/esm/utils/formula.js +1 -1
  100. package/esm/utils/getVariable.js +1 -1
  101. package/esm/utils/grammar.js +1 -1
  102. package/esm/utils/handleAction.js +1 -1
  103. package/esm/utils/helper.d.ts +8 -1
  104. package/esm/utils/helper.js +57 -10
  105. package/esm/utils/highlight.js +1 -1
  106. package/esm/utils/icon.js +1 -1
  107. package/esm/utils/image.js +1 -1
  108. package/esm/utils/index.d.ts +1 -0
  109. package/esm/utils/isPureVariable.js +1 -1
  110. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  111. package/esm/utils/keyToPath.js +1 -1
  112. package/esm/utils/makeSorter.js +1 -1
  113. package/esm/utils/memoryParse.js +1 -1
  114. package/esm/utils/normalizeLink.js +18 -9
  115. package/esm/utils/normalizeOptions.js +1 -1
  116. package/esm/utils/object.js +1 -1
  117. package/esm/utils/offset.js +1 -1
  118. package/esm/utils/offsetParent.js +1 -1
  119. package/esm/utils/optionValueCompare.js +1 -1
  120. package/esm/utils/position.js +1 -1
  121. package/esm/utils/prettyBytes.js +1 -1
  122. package/esm/utils/renderer-event.js +1 -1
  123. package/esm/utils/replaceText.js +1 -1
  124. package/esm/utils/resize-sensor.js +1 -1
  125. package/esm/utils/resolveCondition.js +1 -1
  126. package/esm/utils/resolveVariable.js +1 -1
  127. package/esm/utils/resolveVariableAndFilter.js +1 -1
  128. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  129. package/esm/utils/scrollPosition.js +1 -1
  130. package/esm/utils/string2regExp.js +1 -1
  131. package/esm/utils/stripNumber.js +1 -1
  132. package/esm/utils/style-helper.js +1 -1
  133. package/esm/utils/style.js +1 -1
  134. package/esm/utils/toNumber.js +1 -1
  135. package/esm/utils/tokenize.js +1 -1
  136. package/esm/utils/tpl-builtin.js +1 -1
  137. package/esm/utils/tpl-lodash.js +1 -1
  138. package/esm/utils/tpl.js +1 -1
  139. package/esm/utils/uncontrollable.js +1 -1
  140. package/esm/utils/validations.js +1 -1
  141. package/lib/Root.js +1 -1
  142. package/lib/RootRenderer.d.ts +1 -1
  143. package/lib/RootRenderer.js +2 -2
  144. package/lib/SchemaRenderer.js +3 -2
  145. package/lib/Scoped.js +2 -1
  146. package/lib/StatusScoped.js +1 -1
  147. package/lib/WithRootStore.d.ts +4 -24
  148. package/lib/WithRootStore.js +12 -4
  149. package/lib/WithStore.js +23 -16
  150. package/lib/actions/Action.js +14 -14
  151. package/lib/actions/AjaxAction.js +1 -1
  152. package/lib/actions/BreakAction.js +1 -1
  153. package/lib/actions/BroadcastAction.js +1 -1
  154. package/lib/actions/CmptAction.js +2 -2
  155. package/lib/actions/ContinueAction.js +1 -1
  156. package/lib/actions/CopyAction.js +1 -1
  157. package/lib/actions/CustomAction.js +2 -1
  158. package/lib/actions/DialogAction.d.ts +2 -0
  159. package/lib/actions/DialogAction.js +40 -23
  160. package/lib/actions/DrawerAction.js +4 -4
  161. package/lib/actions/EmailAction.js +1 -1
  162. package/lib/actions/LinkAction.js +1 -1
  163. package/lib/actions/LoopAction.js +1 -1
  164. package/lib/actions/PageAction.js +1 -1
  165. package/lib/actions/ParallelAction.js +1 -1
  166. package/lib/actions/SwitchAction.js +1 -1
  167. package/lib/actions/ToastAction.js +1 -1
  168. package/lib/components/CustomStyle.js +1 -1
  169. package/lib/components/LazyComponent.js +1 -1
  170. package/lib/components/Overlay.js +2 -1
  171. package/lib/components/PopOver.js +2 -1
  172. package/lib/env.js +1 -1
  173. package/lib/envOverwrite.js +1 -1
  174. package/lib/factory.js +1 -1
  175. package/lib/index.d.ts +1 -0
  176. package/lib/index.js +7 -2
  177. package/lib/locale.js +1 -1
  178. package/lib/polyfills.d.ts +3 -0
  179. package/lib/polyfills.js +20 -0
  180. package/lib/renderers/Form.d.ts +1 -1
  181. package/lib/renderers/Form.js +17 -7
  182. package/lib/renderers/Item.d.ts +88 -59
  183. package/lib/renderers/Item.js +86 -40
  184. package/lib/renderers/Options.js +1 -1
  185. package/lib/renderers/Placeholder.js +1 -1
  186. package/lib/renderers/builtin.js +1 -1
  187. package/lib/renderers/register.js +1 -1
  188. package/lib/renderers/wrapControl.d.ts +4 -24
  189. package/lib/renderers/wrapControl.js +51 -53
  190. package/lib/store/app.js +36 -2
  191. package/lib/store/combo.d.ts +168 -28
  192. package/lib/store/combo.js +1 -1
  193. package/lib/store/crud.d.ts +3 -2
  194. package/lib/store/crud.js +12 -5
  195. package/lib/store/form.d.ts +72 -12
  196. package/lib/store/form.js +4 -4
  197. package/lib/store/formItem.d.ts +2 -1
  198. package/lib/store/formItem.js +7 -2
  199. package/lib/store/iRenderer.js +2 -1
  200. package/lib/store/index.js +1 -1
  201. package/lib/store/list.d.ts +1 -0
  202. package/lib/store/list.js +8 -2
  203. package/lib/store/manager.js +1 -1
  204. package/lib/store/modal.js +1 -1
  205. package/lib/store/node.js +1 -1
  206. package/lib/store/pagination.js +1 -1
  207. package/lib/store/root.js +2 -1
  208. package/lib/store/service.js +14 -9
  209. package/lib/store/status.js +1 -1
  210. package/lib/store/table.d.ts +145 -24
  211. package/lib/store/table.js +7 -1
  212. package/lib/store/table2.js +1 -1
  213. package/lib/theme.js +1 -1
  214. package/lib/types.d.ts +5 -2
  215. package/lib/utils/Animation.js +1 -1
  216. package/lib/utils/ColorScale.js +1 -1
  217. package/lib/utils/DataSchema.d.ts +3 -2
  218. package/lib/utils/DataSchema.js +27 -7
  219. package/lib/utils/DataScope.d.ts +10 -3
  220. package/lib/utils/DataScope.js +50 -11
  221. package/lib/utils/RootClose.js +1 -1
  222. package/lib/utils/SimpleMap.js +1 -1
  223. package/lib/utils/api.js +39 -31
  224. package/lib/utils/arraySlice.d.ts +1 -0
  225. package/lib/utils/arraySlice.js +80 -0
  226. package/lib/utils/attachmentAdpator.js +1 -1
  227. package/lib/utils/autobind.js +1 -1
  228. package/lib/utils/columnsSplit.js +1 -1
  229. package/lib/utils/dataMapping.js +26 -18
  230. package/lib/utils/date.js +1 -1
  231. package/lib/utils/debug.js +1 -1
  232. package/lib/utils/decodeEntity.js +1 -1
  233. package/lib/utils/dom.js +4 -1
  234. package/lib/utils/errors.js +1 -1
  235. package/lib/utils/escapeHtml.js +1 -1
  236. package/lib/utils/filter-schema.js +1 -1
  237. package/lib/utils/filter.js +1 -1
  238. package/lib/utils/formatDuration.js +1 -1
  239. package/lib/utils/formula.js +1 -1
  240. package/lib/utils/getVariable.js +1 -1
  241. package/lib/utils/grammar.js +1 -1
  242. package/lib/utils/handleAction.js +1 -1
  243. package/lib/utils/helper.d.ts +8 -1
  244. package/lib/utils/helper.js +57 -9
  245. package/lib/utils/highlight.js +1 -1
  246. package/lib/utils/icon.js +1 -1
  247. package/lib/utils/image.js +1 -1
  248. package/lib/utils/index.d.ts +1 -0
  249. package/lib/utils/isPureVariable.js +1 -1
  250. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  251. package/lib/utils/keyToPath.js +1 -1
  252. package/lib/utils/makeSorter.js +1 -1
  253. package/lib/utils/memoryParse.js +1 -1
  254. package/lib/utils/normalizeLink.js +18 -9
  255. package/lib/utils/normalizeOptions.js +1 -1
  256. package/lib/utils/object.js +1 -1
  257. package/lib/utils/offset.js +1 -1
  258. package/lib/utils/offsetParent.js +1 -1
  259. package/lib/utils/optionValueCompare.js +1 -1
  260. package/lib/utils/position.js +1 -1
  261. package/lib/utils/prettyBytes.js +1 -1
  262. package/lib/utils/renderer-event.js +1 -1
  263. package/lib/utils/replaceText.js +1 -1
  264. package/lib/utils/resize-sensor.js +1 -1
  265. package/lib/utils/resolveCondition.js +1 -1
  266. package/lib/utils/resolveVariable.js +1 -1
  267. package/lib/utils/resolveVariableAndFilter.js +1 -1
  268. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  269. package/lib/utils/scrollPosition.js +1 -1
  270. package/lib/utils/string2regExp.js +1 -1
  271. package/lib/utils/stripNumber.js +1 -1
  272. package/lib/utils/style-helper.js +1 -1
  273. package/lib/utils/style.js +1 -1
  274. package/lib/utils/toNumber.js +1 -1
  275. package/lib/utils/tokenize.js +1 -1
  276. package/lib/utils/tpl-builtin.js +1 -1
  277. package/lib/utils/tpl-lodash.js +1 -1
  278. package/lib/utils/tpl.js +1 -1
  279. package/lib/utils/uncontrollable.js +1 -1
  280. package/lib/utils/validations.js +1 -1
  281. package/package.json +8 -3
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.2.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -17,7 +17,7 @@ import '../utils/filter.js';
17
17
  import isEqual from 'lodash/isEqual';
18
18
  import find from 'lodash/find';
19
19
  import sortBy from 'lodash/sortBy';
20
- import { immutableExtends, flattenTree, findTree, eachTree, isVisible, hasVisibleExpression, isBreakpoint, difference, guid } from '../utils/helper.js';
20
+ import { immutableExtends, flattenTree, findTree, eachTree, isVisible, hasVisibleExpression, isBreakpoint, difference, guid, sortArray } from '../utils/helper.js';
21
21
  import { evalExpression } from '../utils/tpl.js';
22
22
  import { getStoreById } from './manager.js';
23
23
 
@@ -1022,6 +1022,11 @@ var TableStore = iRendererStore
1022
1022
  self.orderBy = key;
1023
1023
  self.orderDir = key ? direction : '';
1024
1024
  }
1025
+ function changeOrder(key, direction) {
1026
+ setOrderByInfo(key, direction);
1027
+ var dir = /desc/i.test(self.orderDir) ? -1 : 1;
1028
+ self.rows.replace(sortArray(self.rows.concat(), self.orderBy, dir, function (item, field) { return item.data[field]; }));
1029
+ }
1025
1030
  function reset() {
1026
1031
  self.rows.forEach(function (item) { return item.reset(); });
1027
1032
  var rows = self.rows.concat();
@@ -1138,6 +1143,7 @@ var TableStore = iRendererStore
1138
1143
  collapseAllAtDepth: collapseAllAtDepth,
1139
1144
  clear: clear,
1140
1145
  setOrderByInfo: setOrderByInfo,
1146
+ changeOrder: changeOrder,
1141
1147
  reset: reset,
1142
1148
  toggleDragging: toggleDragging,
1143
1149
  stopDragging: stopDragging,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.2.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/esm/theme.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.2.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/esm/types.d.ts CHANGED
@@ -137,7 +137,7 @@ export interface BaseApiObject {
137
137
  autoRefresh?: boolean;
138
138
  /**
139
139
  * 当开启自动刷新的时候,默认是 api 的 url 来自动跟踪变量变化的。
140
- * 如果你希望监控 url 外的变量,请配置 traceExpression
140
+ * 如果你希望监控 url 外的变量,请配置 trackExpression
141
141
  */
142
142
  trackExpression?: string;
143
143
  /**
@@ -300,7 +300,10 @@ type RendererDataAlias = RendererData;
300
300
  export type FunctionPropertyNames<T> = {
301
301
  [K in keyof T]: T[K] extends Function ? K : never;
302
302
  }[keyof T];
303
- export type JSONSchema = JSONSchema7;
303
+ export type JSONSchema = JSONSchema7 & {
304
+ group?: string;
305
+ typeLabel?: string;
306
+ };
304
307
  /**
305
308
  * 事件跟踪的定义
306
309
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.2.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.2.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -13,13 +13,14 @@ export declare class DataSchema {
13
13
  setSchema(schemas: Array<JSONSchema>): this;
14
14
  addSchema(schema: JSONSchema): this;
15
15
  removeSchema(id: string): this;
16
- getSchemas(): import("json-schema").JSONSchema7[];
16
+ getSchemas(): JSONSchema[];
17
17
  addScope(schema?: JSONSchema | Array<JSONSchema>, id?: string): this;
18
18
  removeScope(idOrScope: string | DataScope): this;
19
19
  hasScope(idOrScope: string | DataScope): idOrScope is string | DataScope;
20
20
  getScope(idOrScope: string | DataScope): DataScope;
21
21
  switchToRoot(): this;
22
22
  switchTo(idOrScope: string | DataScope): this;
23
+ pushVariable(current: DataScope, variables: any[]): void;
23
24
  getDataPropsAsOptions(): any[];
24
- getSchemaByPath(path: string): import("json-schema").JSONSchema7 | null;
25
+ getSchemaByPath(path: string): JSONSchema | null;
25
26
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.2.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -79,18 +79,38 @@ var DataSchema = /** @class */ (function () {
79
79
  this.current = scope;
80
80
  return this;
81
81
  };
82
+ DataSchema.prototype.pushVariable = function (current, variables) {
83
+ if (current.tag) {
84
+ variables.push({
85
+ label: current.tag,
86
+ children: current.getDataPropsAsOptions()
87
+ });
88
+ }
89
+ else {
90
+ variables.push.apply(variables, __spreadArray([], __read(current.getDataPropsAsOptions()), false));
91
+ }
92
+ };
82
93
  DataSchema.prototype.getDataPropsAsOptions = function () {
94
+ var _a;
83
95
  var variables = [];
84
96
  var current = this.current;
85
97
  while (current) {
86
- if (current.tag) {
87
- variables.push({
88
- label: current.tag,
89
- children: current.getDataPropsAsOptions()
90
- });
98
+ if (current.group) {
99
+ var subVars = [];
100
+ this.pushVariable(current, subVars);
101
+ var index = variables.findIndex(function (item) { return item.label === (current === null || current === void 0 ? void 0 : current.group); });
102
+ if (~index) {
103
+ (_a = variables[index].children).push.apply(_a, __spreadArray([], __read(subVars), false));
104
+ }
105
+ else {
106
+ variables.push({
107
+ label: current.group,
108
+ children: subVars
109
+ });
110
+ }
91
111
  }
92
112
  else {
93
- variables.push.apply(variables, __spreadArray([], __read(current.getDataPropsAsOptions()), false));
113
+ this.pushVariable(current, variables);
94
114
  }
95
115
  current = current.parent;
96
116
  }
@@ -1,4 +1,7 @@
1
1
  import { JSONSchema } from '../types';
2
+ export declare const DATASCHEMA_TYPE_MAP: {
3
+ [type: string]: string;
4
+ };
2
5
  export declare class DataScope {
3
6
  parent?: DataScope;
4
7
  readonly children: Array<DataScope>;
@@ -6,6 +9,7 @@ export declare class DataScope {
6
9
  ref?: string;
7
10
  name?: string;
8
11
  tag?: string;
12
+ group?: string;
9
13
  description?: string;
10
14
  readonly schemas: Array<JSONSchema>;
11
15
  constructor(schemas: JSONSchema | Array<JSONSchema>, id: string);
@@ -17,8 +21,11 @@ export declare class DataScope {
17
21
  contains(scope: DataScope): boolean;
18
22
  assignSchema(target: any, schema: any): any;
19
23
  getMergedSchema(): any;
20
- protected buildOptions(options: Array<any>, schema: JSONSchema, path?: string, key?: string): void;
24
+ protected buildOptions(options: Array<any>, schema: JSONSchema, path?: {
25
+ label: string;
26
+ value: string;
27
+ }, key?: string, isMember?: boolean): void;
21
28
  getDataPropsAsOptions(): any;
22
- getSchemaByPath(path: string): import("json-schema").JSONSchema7 | null;
23
- getSchemaById(id: string): import("json-schema").JSONSchema7 | undefined;
29
+ getSchemaByPath(path: string): JSONSchema | null;
30
+ getSchemaById(id: string): JSONSchema | undefined;
24
31
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.2.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -7,6 +7,14 @@ import { __values, __assign, __spreadArray, __read } from 'tslib';
7
7
  import { guid, mapTree } from './helper.js';
8
8
  import { keyToPath } from './keyToPath.js';
9
9
 
10
+ var DATASCHEMA_TYPE_MAP = {
11
+ boolean: '布尔',
12
+ integer: '整数',
13
+ number: '数字',
14
+ string: '文本',
15
+ array: '数组',
16
+ object: '对象'
17
+ };
10
18
  var DataScope = /** @class */ (function () {
11
19
  function DataScope(schemas, id) {
12
20
  this.children = [];
@@ -167,31 +175,61 @@ var DataScope = /** @class */ (function () {
167
175
  });
168
176
  return mergedSchema;
169
177
  };
170
- DataScope.prototype.buildOptions = function (options, schema, path, key) {
178
+ DataScope.prototype.buildOptions = function (options, schema, path, key, isMember // 是否是数组成员
179
+ ) {
171
180
  var _this = this;
172
- var _a;
173
- if (path === void 0) { path = ''; }
181
+ var _a, _b, _c;
182
+ if (path === void 0) { path = { label: '', value: '' }; }
174
183
  if (key === void 0) { key = ''; }
175
184
  // todo 支持 oneOf, anyOf
176
185
  var option = {
177
186
  label: schema.title || key,
178
- value: path,
187
+ value: schema.title === '成员' ? '' : path.value,
188
+ path: schema.title === '成员' ? '' : path.label,
179
189
  type: schema.type,
180
- tag: (_a = schema.description) !== null && _a !== void 0 ? _a : schema.type
190
+ tag: (_b = (_a = schema.typeLabel) !== null && _a !== void 0 ? _a : DATASCHEMA_TYPE_MAP[schema.type]) !== null && _b !== void 0 ? _b : schema.type,
191
+ description: schema.description,
192
+ isMember: isMember,
193
+ disabled: schema.title === '成员'
181
194
  };
182
- options.push(option);
195
+ // 处理option分组
196
+ if (schema.group) {
197
+ var index = options.findIndex(function (item) { return item.label === schema.group; });
198
+ if (~index) {
199
+ options[index].children.push(option);
200
+ }
201
+ else {
202
+ options.push({
203
+ label: schema.group,
204
+ value: '',
205
+ children: [option]
206
+ });
207
+ }
208
+ }
209
+ else {
210
+ options.push(option);
211
+ }
183
212
  if (schema.type === 'object' && schema.properties) {
184
213
  option.children = [];
185
214
  var keys = Object.keys(schema.properties);
186
215
  keys.forEach(function (key) {
216
+ var _a;
187
217
  var child = schema.properties[key];
188
- _this.buildOptions(option.children, child, path + (path ? '.' : '') + key, key);
218
+ _this.buildOptions(option.children, child, {
219
+ label: path.label + (path.label ? '.' : '') + ((_a = child.title) !== null && _a !== void 0 ? _a : key),
220
+ value: path.value + (path.value ? '.' : '') + key
221
+ }, key, schema.title === '成员');
189
222
  });
190
223
  }
191
- else if (schema.type === 'array' && schema.items) {
224
+ else if (schema.type === 'array' && ((_c = schema.items) === null || _c === void 0 ? void 0 : _c.properties)) {
192
225
  option.children = [];
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 })); });
226
+ this.buildOptions(option.children, __assign(__assign({ title: '成员' }, schema.items), { disabled: true }), {
227
+ label: path.label,
228
+ value: path.value
229
+ }, 'items', schema.title === '成员');
230
+ option.children = mapTree(option.children, function (item) { return (__assign({}, item
231
+ // disabled: true
232
+ )); });
195
233
  }
196
234
  };
197
235
  DataScope.prototype.getDataPropsAsOptions = function () {
@@ -232,4 +270,4 @@ var DataScope = /** @class */ (function () {
232
270
  return DataScope;
233
271
  }());
234
272
 
235
- export { DataScope };
273
+ export { DATASCHEMA_TYPE_MAP, DataScope };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.2.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.2.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/esm/utils/api.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.2.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -8,7 +8,7 @@ import omit from 'lodash/omit';
8
8
  import { evaluate } from 'amis-formula';
9
9
  import { escapeHtml } from './escapeHtml.js';
10
10
  import 'moment';
11
- import { cloneObject, createObject, isObject } from './object.js';
11
+ import { cloneObject, extendObject, createObject, isObject } from './object.js';
12
12
  import { tokenize } from './tokenize.js';
13
13
  import { memoryParse } from './memoryParse.js';
14
14
  import { dataMapping } from './dataMapping.js';
@@ -96,6 +96,23 @@ function buildApi(api, data, options) {
96
96
  }
97
97
  : undefined);
98
98
  };
99
+ /** 追加data到请求的Query中 */
100
+ var attachDataToQuery = function (apiObject, ctx, merge) {
101
+ var idx = apiObject.url.indexOf('?');
102
+ if (~idx) {
103
+ var params = (apiObject.query = __assign(__assign(__assign({}, qsparse(apiObject.url.substring(idx + 1))), apiObject.query), ctx));
104
+ apiObject.url =
105
+ apiObject.url.substring(0, idx) + '?' + queryStringify(params);
106
+ }
107
+ else {
108
+ apiObject.query = __assign(__assign({}, apiObject.query), ctx);
109
+ var query = queryStringify(merge ? apiObject.query : ctx);
110
+ if (query) {
111
+ apiObject.url = "".concat(apiObject.url, "?").concat(query);
112
+ }
113
+ }
114
+ return apiObject;
115
+ };
99
116
  if (~idx) {
100
117
  var hashIdx = url.indexOf('#');
101
118
  var params = qsparse(url.substring(idx + 1, ~hashIdx && hashIdx > idx ? hashIdx : undefined));
@@ -149,41 +166,19 @@ function buildApi(api, data, options) {
149
166
  else if (api.attachDataToQuery === false &&
150
167
  api.data &&
151
168
  ((!~raw.indexOf('$') && autoAppend) || api.forceAppendDataToQuery)) {
152
- var idx_1 = api.url.indexOf('?');
153
- if (~idx_1) {
154
- var params = (api.query = __assign(__assign(__assign({}, qsparse(api.url.substring(idx_1 + 1))), api.query), data));
155
- api.url = api.url.substring(0, idx_1) + '?' + queryStringify(params);
156
- }
157
- else {
158
- api.query = __assign(__assign({}, api.query), data);
159
- var query = queryStringify(data);
160
- if (query) {
161
- api.url = "".concat(api.url, "?").concat(query);
162
- }
163
- }
169
+ api = attachDataToQuery(api, data, false);
164
170
  }
165
171
  if (api.data && api.attachDataToQuery !== false) {
166
- var idx_2 = api.url.indexOf('?');
167
- if (~idx_2) {
168
- var params = (api.query = __assign(__assign(__assign({}, qsparse(api.url.substring(idx_2 + 1))), api.query), api.data));
169
- api.url = api.url.substring(0, idx_2) + '?' + queryStringify(params);
170
- }
171
- else {
172
- api.query = __assign(__assign({}, api.query), api.data);
173
- var query = queryStringify(api.query);
174
- if (query) {
175
- api.url = "".concat(api.url, "?").concat(query);
176
- }
177
- }
172
+ api = attachDataToQuery(api, api.data, true);
178
173
  delete api.data;
179
174
  }
180
175
  }
181
176
  // 非 get 类请求也可以携带参数到 url,只要 query 有值
182
177
  else if (api.method) {
183
- var idx_3 = api.url.indexOf('?');
184
- if (~idx_3) {
185
- var params = (api.query = __assign(__assign({}, qsparse(api.url.substring(idx_3 + 1))), api.query));
186
- api.url = api.url.substring(0, idx_3) + '?' + queryStringify(params);
178
+ var idx_1 = api.url.indexOf('?');
179
+ if (~idx_1) {
180
+ var params = (api.query = __assign(__assign({}, qsparse(api.url.substring(idx_1 + 1))), api.query));
181
+ api.url = api.url.substring(0, idx_1) + '?' + queryStringify(params);
187
182
  }
188
183
  else {
189
184
  var query = queryStringify(api.query);
@@ -208,8 +203,21 @@ function buildApi(api, data, options) {
208
203
  }
209
204
  else if (api.jsonql) {
210
205
  api.method = 'post';
211
- api.jsonql = dataMapping(api.jsonql, __assign(__assign({}, api.query), data), undefined, false, true);
212
- api.body = api.data = api.jsonql;
206
+ api.jsonql = dataMapping(api.jsonql,
207
+ /** 需要上层数据域的内容 */
208
+ extendObject(data, __assign(__assign({}, api.query), data), false), undefined, false, true);
209
+ /** 同时设置了JSONQL和data时走兼容场景 */
210
+ api.body = api.data =
211
+ api.data && api.jsonql
212
+ ? {
213
+ data: api.data,
214
+ jsonql: api.jsonql
215
+ }
216
+ : api.jsonql;
217
+ /** JSONQL所有method需要追加data中的变量到query中 */
218
+ if (api.forceAppendDataToQuery) {
219
+ api = attachDataToQuery(api, data, true);
220
+ }
213
221
  }
214
222
  return api;
215
223
  }
@@ -0,0 +1 @@
1
+ export declare function arraySlice(array: any[], slice: string): any[];
@@ -0,0 +1,76 @@
1
+ /**
2
+ * amis-core v3.2.0
3
+ * Copyright 2018-2023 fex
4
+ */
5
+
6
+ import { __values, __read, __spreadArray } from 'tslib';
7
+ import { isObservableArray, toJS } from 'mobx';
8
+
9
+ function arraySlice(array, slice) {
10
+ var e_1, _a;
11
+ if (typeof slice !== 'string') {
12
+ return array;
13
+ }
14
+ if (isObservableArray(array)) {
15
+ array = toJS(array);
16
+ }
17
+ slice = slice.trim();
18
+ if (!slice || !Array.isArray(array)) {
19
+ return array;
20
+ }
21
+ var parts = slice.split(',');
22
+ var ret = [];
23
+ var arrayLength = array.length;
24
+ if (!arrayLength) {
25
+ return array;
26
+ }
27
+ try {
28
+ for (var parts_1 = __values(parts), parts_1_1 = parts_1.next(); !parts_1_1.done; parts_1_1 = parts_1.next()) {
29
+ var part = parts_1_1.value;
30
+ // 普通的场景
31
+ if (part.indexOf(':') === -1) {
32
+ var index = parseInt(part, 10);
33
+ if (!isNaN(index) && index < arrayLength) {
34
+ ret.push(array[index]);
35
+ }
36
+ }
37
+ else {
38
+ var _b = __read(part.split(':'), 2), start = _b[0], end = _b[1];
39
+ var startIndex = parseInt(start || '0', 10);
40
+ if (isNaN(startIndex) || startIndex < 0) {
41
+ startIndex = 0;
42
+ }
43
+ // 大于就没意义了
44
+ if (startIndex >= arrayLength) {
45
+ continue;
46
+ }
47
+ var endIndex = parseInt(end, 10);
48
+ if (isNaN(endIndex)) {
49
+ endIndex = arrayLength;
50
+ }
51
+ // 负数就从后面开始取
52
+ if (endIndex < 0) {
53
+ endIndex = arrayLength + endIndex;
54
+ }
55
+ // 小于没有意义
56
+ if (endIndex < startIndex) {
57
+ continue;
58
+ }
59
+ if (endIndex > arrayLength) {
60
+ endIndex = arrayLength;
61
+ }
62
+ ret.push.apply(ret, __spreadArray([], __read(array.slice(startIndex, endIndex)), false));
63
+ }
64
+ }
65
+ }
66
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
67
+ finally {
68
+ try {
69
+ if (parts_1_1 && !parts_1_1.done && (_a = parts_1.return)) _a.call(parts_1);
70
+ }
71
+ finally { if (e_1) throw e_1.error; }
72
+ }
73
+ return ret;
74
+ }
75
+
76
+ export { arraySlice };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.2.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.2.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.2.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.2.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,6 +121,13 @@ 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
  }
package/esm/utils/date.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.1.1
2
+ * amis-core v3.2.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.2.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.2.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.2.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.2.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.2.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.2.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.2.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5