amis-core 1.0.0-beta.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 (211) hide show
  1. package/dist/Root.js +94 -0
  2. package/dist/RootRenderer.js +288 -0
  3. package/dist/SchemaRenderer.js +323 -0
  4. package/dist/Scoped.js +252 -0
  5. package/dist/WithRootStore.js +44 -0
  6. package/dist/WithStore.js +179 -0
  7. package/dist/__tests__/compat.test.d.ts +1 -0
  8. package/dist/__tests__/factory.test.d.ts +1 -0
  9. package/dist/__tests__/filter.test.d.ts +1 -0
  10. package/dist/__tests__/helper.d.ts +13 -0
  11. package/dist/__tests__/tokenize.test.d.ts +1 -0
  12. package/dist/actions/Action.js +119 -0
  13. package/dist/actions/AjaxAction.js +96 -0
  14. package/dist/actions/BreakAction.js +35 -0
  15. package/dist/actions/BroadcastAction.js +49 -0
  16. package/dist/actions/CmptAction.js +60 -0
  17. package/dist/actions/ContinueAction.js +35 -0
  18. package/dist/actions/CopyAction.js +43 -0
  19. package/dist/actions/CustomAction.js +49 -0
  20. package/dist/actions/DialogAction.js +104 -0
  21. package/dist/actions/DrawerAction.js +66 -0
  22. package/dist/actions/EmailAction.js +48 -0
  23. package/dist/actions/LinkAction.js +52 -0
  24. package/dist/actions/LoopAction.js +107 -0
  25. package/dist/actions/PageAction.js +80 -0
  26. package/dist/actions/ParallelAction.js +40 -0
  27. package/dist/actions/SwitchAction.js +52 -0
  28. package/dist/actions/ToastAction.js +35 -0
  29. package/dist/components/LazyComponent.js +99 -0
  30. package/dist/env.js +20 -0
  31. package/dist/envOverwrite.js +43 -0
  32. package/dist/factory.js +308 -0
  33. package/dist/index.js +218 -0
  34. package/dist/index2.js +255 -0
  35. package/dist/locale.js +114 -0
  36. package/dist/renderers/Form.js +1162 -0
  37. package/dist/renderers/Item.js +636 -0
  38. package/dist/renderers/Options.js +881 -0
  39. package/dist/renderers/Placeholder.js +31 -0
  40. package/dist/renderers/builtin.js +27 -0
  41. package/dist/renderers/wrapControl.js +507 -0
  42. package/dist/src/Root.d.ts +37 -0
  43. package/dist/src/RootRenderer.d.ts +27 -0
  44. package/dist/src/SchemaRenderer.d.ts +37 -0
  45. package/dist/src/Scoped.d.ts +38 -0
  46. package/dist/src/WithRootStore.d.ts +737 -0
  47. package/dist/src/WithStore.d.ts +5 -0
  48. package/dist/src/actions/Action.d.ts +38 -0
  49. package/dist/src/actions/AjaxAction.d.ts +25 -0
  50. package/dist/src/actions/BreakAction.d.ts +15 -0
  51. package/dist/src/actions/BroadcastAction.d.ts +16 -0
  52. package/dist/src/actions/CmptAction.d.ts +20 -0
  53. package/dist/src/actions/ContinueAction.d.ts +15 -0
  54. package/dist/src/actions/CopyAction.d.ts +20 -0
  55. package/dist/src/actions/CustomAction.d.ts +17 -0
  56. package/dist/src/actions/Decorators.d.ts +25 -0
  57. package/dist/src/actions/DialogAction.d.ts +57 -0
  58. package/dist/src/actions/DrawerAction.d.ts +30 -0
  59. package/dist/src/actions/EmailAction.d.ts +23 -0
  60. package/dist/src/actions/LinkAction.d.ts +24 -0
  61. package/dist/src/actions/LoopAction.d.ts +19 -0
  62. package/dist/src/actions/PageAction.d.ts +39 -0
  63. package/dist/src/actions/ParallelAction.d.ts +8 -0
  64. package/dist/src/actions/SwitchAction.d.ts +11 -0
  65. package/dist/src/actions/ToastAction.d.ts +19 -0
  66. package/dist/src/actions/index.d.ts +21 -0
  67. package/dist/src/components/LazyComponent.d.ts +32 -0
  68. package/dist/src/env.d.ts +172 -0
  69. package/dist/src/envOverwrite.d.ts +4 -0
  70. package/dist/src/factory.d.ts +78 -0
  71. package/dist/src/index.d.ts +25 -0
  72. package/dist/src/locale.d.ts +82 -0
  73. package/dist/src/renderers/Form.d.ts +352 -0
  74. package/dist/src/renderers/Item.d.ts +795 -0
  75. package/dist/src/renderers/Options.d.ts +150 -0
  76. package/dist/src/renderers/Placeholder.d.ts +6 -0
  77. package/dist/src/renderers/builtin.d.ts +1 -0
  78. package/dist/src/renderers/wrapControl.d.ts +446 -0
  79. package/dist/src/schema.d.ts +369 -0
  80. package/dist/src/store/app.d.ts +89 -0
  81. package/dist/src/store/combo.d.ts +8504 -0
  82. package/dist/src/store/crud.d.ts +124 -0
  83. package/dist/src/store/form.d.ts +3394 -0
  84. package/dist/src/store/formItem.d.ts +130 -0
  85. package/dist/src/store/iRenderer.d.ts +46 -0
  86. package/dist/src/store/index.d.ts +105 -0
  87. package/dist/src/store/list.d.ts +270 -0
  88. package/dist/src/store/manager.d.ts +115 -0
  89. package/dist/src/store/modal.d.ts +84 -0
  90. package/dist/src/store/node.d.ts +22 -0
  91. package/dist/src/store/pagination.d.ts +58 -0
  92. package/dist/src/store/root.d.ts +79 -0
  93. package/dist/src/store/service.d.ts +71 -0
  94. package/dist/src/store/table-v2.d.ts +309 -0
  95. package/dist/src/store/table.d.ts +8334 -0
  96. package/dist/src/theme.d.ts +83 -0
  97. package/dist/src/types.d.ts +217 -0
  98. package/dist/src/utils/Animation.d.ts +22 -0
  99. package/dist/src/utils/ColorScale.d.ts +19 -0
  100. package/dist/src/utils/DataSchema.d.ts +25 -0
  101. package/dist/src/utils/DataScope.d.ts +23 -0
  102. package/dist/src/utils/RootClose.d.ts +4 -0
  103. package/dist/src/utils/SimpleMap.d.ts +8 -0
  104. package/dist/src/utils/api.d.ts +27 -0
  105. package/dist/src/utils/attachmentAdpator.d.ts +7 -0
  106. package/dist/src/utils/autobind.d.ts +7 -0
  107. package/dist/src/utils/columnsSplit.d.ts +1 -0
  108. package/dist/src/utils/dataMapping.d.ts +3 -0
  109. package/dist/src/utils/date.d.ts +4 -0
  110. package/dist/src/utils/debug.d.ts +26 -0
  111. package/dist/src/utils/dom.d.ts +13 -0
  112. package/dist/src/utils/errors.d.ts +6 -0
  113. package/dist/src/utils/escapeHtml.d.ts +1 -0
  114. package/dist/src/utils/filter-schema.d.ts +12 -0
  115. package/dist/src/utils/filter.d.ts +1 -0
  116. package/dist/src/utils/formatDuration.d.ts +1 -0
  117. package/dist/src/utils/formula.d.ts +16 -0
  118. package/dist/src/utils/getVariable.d.ts +3 -0
  119. package/dist/src/utils/grammar.d.ts +4 -0
  120. package/dist/src/utils/handleAction.d.ts +6 -0
  121. package/dist/src/utils/helper.d.ts +286 -0
  122. package/dist/src/utils/icon.d.ts +12 -0
  123. package/dist/src/utils/image.d.ts +17 -0
  124. package/dist/src/utils/index.d.ts +12 -0
  125. package/dist/src/utils/isPureVariable.d.ts +1 -0
  126. package/dist/src/utils/json-schema-2-amis-schema.d.ts +6 -0
  127. package/dist/src/utils/keyToPath.d.ts +6 -0
  128. package/dist/src/utils/makeSorter.d.ts +1 -0
  129. package/dist/src/utils/markdown.d.ts +5 -0
  130. package/dist/src/utils/normalizeLink.d.ts +1 -0
  131. package/dist/src/utils/normalizeOptions.d.ts +7 -0
  132. package/dist/src/utils/object.d.ts +15 -0
  133. package/dist/src/utils/offset.d.ts +14 -0
  134. package/dist/src/utils/offsetParent.d.ts +4 -0
  135. package/dist/src/utils/optionValueCompare.d.ts +3 -0
  136. package/dist/src/utils/position.d.ts +15 -0
  137. package/dist/src/utils/prettyBytes.d.ts +1 -0
  138. package/dist/src/utils/renderer-event.d.ts +44 -0
  139. package/dist/src/utils/replaceText.d.ts +6 -0
  140. package/dist/src/utils/resize-sensor.d.ts +6 -0
  141. package/dist/src/utils/resolveVariable.d.ts +1 -0
  142. package/dist/src/utils/resolveVariableAndFilter.d.ts +1 -0
  143. package/dist/src/utils/scrollPosition.d.ts +6 -0
  144. package/dist/src/utils/string2regExp.d.ts +1 -0
  145. package/dist/src/utils/stripNumber.d.ts +1 -0
  146. package/dist/src/utils/style.d.ts +10 -0
  147. package/dist/src/utils/tokenize.d.ts +1 -0
  148. package/dist/src/utils/tpl-builtin.d.ts +18 -0
  149. package/dist/src/utils/tpl-lodash.d.ts +4 -0
  150. package/dist/src/utils/tpl.d.ts +11 -0
  151. package/dist/src/utils/validations.d.ts +39 -0
  152. package/dist/store/app.js +190 -0
  153. package/dist/store/combo.js +154 -0
  154. package/dist/store/crud.js +413 -0
  155. package/dist/store/form.js +579 -0
  156. package/dist/store/formItem.js +846 -0
  157. package/dist/store/iRenderer.js +189 -0
  158. package/dist/store/index.js +103 -0
  159. package/dist/store/list.js +248 -0
  160. package/dist/store/manager.js +56 -0
  161. package/dist/store/modal.js +54 -0
  162. package/dist/store/node.js +93 -0
  163. package/dist/store/pagination.js +60 -0
  164. package/dist/store/root.js +45 -0
  165. package/dist/store/service.js +415 -0
  166. package/dist/store/table-v2.js +471 -0
  167. package/dist/store/table.js +1105 -0
  168. package/dist/theme.js +93 -0
  169. package/dist/tsconfig.tsbuildinfo +1 -0
  170. package/dist/utils/Animation.js +290 -0
  171. package/dist/utils/DataSchema.js +120 -0
  172. package/dist/utils/DataScope.js +151 -0
  173. package/dist/utils/SimpleMap.js +46 -0
  174. package/dist/utils/api.js +555 -0
  175. package/dist/utils/autobind.js +94 -0
  176. package/dist/utils/dataMapping.js +136 -0
  177. package/dist/utils/date.js +90 -0
  178. package/dist/utils/debug.js +343 -0
  179. package/dist/utils/errors.js +23 -0
  180. package/dist/utils/escapeHtml.js +24 -0
  181. package/dist/utils/filter-schema.js +75 -0
  182. package/dist/utils/filter.js +481 -0
  183. package/dist/utils/formatDuration.js +27 -0
  184. package/dist/utils/formula.js +165 -0
  185. package/dist/utils/getVariable.js +29 -0
  186. package/dist/utils/grammar.js +54 -0
  187. package/dist/utils/helper.js +1283 -0
  188. package/dist/utils/isPureVariable.js +16 -0
  189. package/dist/utils/keyToPath.js +34 -0
  190. package/dist/utils/makeSorter.js +30 -0
  191. package/dist/utils/normalizeLink.js +47 -0
  192. package/dist/utils/normalizeOptions.js +92 -0
  193. package/dist/utils/object.js +156 -0
  194. package/dist/utils/offset.js +36 -0
  195. package/dist/utils/offsetParent.js +27 -0
  196. package/dist/utils/optionValueCompare.js +25 -0
  197. package/dist/utils/position.js +50 -0
  198. package/dist/utils/prettyBytes.js +28 -0
  199. package/dist/utils/renderer-event.js +131 -0
  200. package/dist/utils/replaceText.js +35 -0
  201. package/dist/utils/resize-sensor.js +177 -0
  202. package/dist/utils/resolveVariable.js +39 -0
  203. package/dist/utils/resolveVariableAndFilter.js +37 -0
  204. package/dist/utils/string2regExp.js +18 -0
  205. package/dist/utils/stripNumber.js +20 -0
  206. package/dist/utils/tokenize.js +33 -0
  207. package/dist/utils/tpl-builtin.js +71 -0
  208. package/dist/utils/tpl-lodash.js +71 -0
  209. package/dist/utils/tpl.js +140 -0
  210. package/dist/utils/validations.js +377 -0
  211. package/package.json +121 -0
@@ -0,0 +1,1283 @@
1
+ /**
2
+ * amis-core v1.0.0-beta.0
3
+ * Copyright 2018-2022 fex
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ Object.defineProperty(exports, '__esModule', { value: true });
9
+
10
+ var tslib = require('tslib');
11
+ var isPlainObject = require('lodash/isPlainObject');
12
+ var isEqual = require('lodash/isEqual');
13
+ var isNaN = require('lodash/isNaN');
14
+ var uniq = require('lodash/uniq');
15
+ var last = require('lodash/last');
16
+ var tpl = require('./tpl.js');
17
+ var qs = require('qs');
18
+ var autobind$1 = require('./autobind.js');
19
+ require('amis-formula');
20
+ require('moment');
21
+ var object = require('./object.js');
22
+ var isPureVariable = require('./isPureVariable.js');
23
+ var resolveVariable = require('./resolveVariable.js');
24
+ var resolveVariableAndFilter = require('./resolveVariableAndFilter.js');
25
+ require('./filter.js');
26
+ var mobx = require('mobx');
27
+ var string2regExp = require('./string2regExp.js');
28
+ var getVariable = require('./getVariable.js');
29
+ var keyToPath = require('./keyToPath.js');
30
+
31
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
32
+
33
+ var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);
34
+ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
35
+ var isNaN__default = /*#__PURE__*/_interopDefaultLegacy(isNaN);
36
+ var uniq__default = /*#__PURE__*/_interopDefaultLegacy(uniq);
37
+ var last__default = /*#__PURE__*/_interopDefaultLegacy(last);
38
+ var qs__default = /*#__PURE__*/_interopDefaultLegacy(qs);
39
+
40
+ function preventDefault(event) {
41
+ if (typeof event.cancelable !== 'boolean' || event.cancelable) {
42
+ event.preventDefault();
43
+ }
44
+ }
45
+ function isMobile() {
46
+ var _a, _b;
47
+ return (_b = (_a = window).matchMedia) === null || _b === void 0 ? void 0 : _b.call(_a, '(max-width: 768px)').matches;
48
+ }
49
+ function range(num, min, max) {
50
+ return Math.min(Math.max(num, min), max);
51
+ }
52
+ /**
53
+ * 给目标对象添加其他属性,可读取但是不会被遍历。
54
+ * @param target
55
+ * @param props
56
+ */
57
+ function injectPropsToObject(target, props) {
58
+ var sup = Object.create(target.__super || null);
59
+ Object.keys(props).forEach(function (key) { return (sup[key] = props[key]); });
60
+ var result = Object.create(sup);
61
+ Object.keys(target).forEach(function (key) { return (result[key] = target[key]); });
62
+ return result;
63
+ }
64
+ function isSuperDataModified(data, prevData, store) {
65
+ var keys = [];
66
+ if (store && store.storeType === 'FormStore') {
67
+ keys = uniq__default["default"](store.items
68
+ .map(function (item) { return "".concat(item.name).replace(/\..*$/, ''); })
69
+ .concat(Object.keys(store.data)));
70
+ }
71
+ else {
72
+ keys = Object.keys(store.data);
73
+ }
74
+ if (Array.isArray(keys) && keys.length) {
75
+ return keys.some(function (key) { return data[key] !== prevData[key]; });
76
+ }
77
+ return false;
78
+ }
79
+ function syncDataFromSuper(data, superObject, prevSuperObject, store, force) {
80
+ var obj = tslib.__assign({}, data);
81
+ var keys = [];
82
+ // 如果是 form store,则从父级同步 formItem 种东西。
83
+ if (store && store.storeType === 'FormStore') {
84
+ keys = uniq__default["default"](store.items
85
+ .map(function (item) { return "".concat(item.name).replace(/\..*$/, ''); })
86
+ .concat(Object.keys(obj)));
87
+ }
88
+ else if (force) {
89
+ keys = Object.keys(obj);
90
+ }
91
+ if (superObject || prevSuperObject) {
92
+ keys.forEach(function (key) {
93
+ if (!key) {
94
+ return;
95
+ }
96
+ if (((superObject && typeof superObject[key] !== 'undefined') ||
97
+ (prevSuperObject && typeof prevSuperObject[key] !== 'undefined')) &&
98
+ ((prevSuperObject && !superObject) ||
99
+ (!prevSuperObject && superObject) ||
100
+ prevSuperObject[key] !== superObject[key])) {
101
+ obj[key] = superObject[key];
102
+ }
103
+ });
104
+ }
105
+ return obj;
106
+ }
107
+ /**
108
+ * 生成 8 位随机数字。
109
+ *
110
+ * @return {string} 8位随机数字
111
+ */
112
+ function guid() {
113
+ function s4() {
114
+ return Math.floor((1 + Math.random()) * 0x10000)
115
+ .toString(16)
116
+ .substring(1);
117
+ }
118
+ return s4() + s4() + s4();
119
+ }
120
+ function findIndex(arr, detect) {
121
+ for (var i = 0, len = arr.length; i < len; i++) {
122
+ if (detect(arr[i], i)) {
123
+ return i;
124
+ }
125
+ }
126
+ return -1;
127
+ }
128
+ function hasOwnProperty(data, key) {
129
+ var parts = keyToPath.keyToPath(key);
130
+ while (parts.length) {
131
+ var key_1 = parts.shift();
132
+ if (!object.isObject(data) || !data.hasOwnProperty(key_1)) {
133
+ return false;
134
+ }
135
+ data = data[key_1];
136
+ }
137
+ return true;
138
+ }
139
+ function noop() { }
140
+ function anyChanged(attrs, from, to, strictMode) {
141
+ if (strictMode === void 0) { strictMode = true; }
142
+ return (typeof attrs === 'string' ? attrs.split(/\s*,\s*/) : attrs).some(function (key) { return (strictMode ? from[key] !== to[key] : from[key] != to[key]); });
143
+ }
144
+ function rmUndefined(obj) {
145
+ var newObj = {};
146
+ if (typeof obj !== 'object') {
147
+ return obj;
148
+ }
149
+ var keys = Object.keys(obj);
150
+ keys.forEach(function (key) {
151
+ if (obj[key] !== undefined) {
152
+ newObj[key] = obj[key];
153
+ }
154
+ });
155
+ return newObj;
156
+ }
157
+ function isObjectShallowModified(prev, next, strictMode, ignoreUndefined, statck) {
158
+ if (strictMode === void 0) { strictMode = true; }
159
+ if (ignoreUndefined === void 0) { ignoreUndefined = false; }
160
+ if (statck === void 0) { statck = []; }
161
+ if (Array.isArray(prev) && Array.isArray(next)) {
162
+ return prev.length !== next.length
163
+ ? true
164
+ : prev.some(function (prev, index) {
165
+ return isObjectShallowModified(prev, next[index], strictMode, ignoreUndefined, statck);
166
+ });
167
+ }
168
+ else if (isNaN__default["default"](prev) && isNaN__default["default"](next)) {
169
+ return false;
170
+ }
171
+ else if (null == prev ||
172
+ null == next ||
173
+ !object.isObject(prev) ||
174
+ !object.isObject(next) ||
175
+ mobx.isObservable(prev) ||
176
+ mobx.isObservable(next)) {
177
+ return strictMode ? prev !== next : prev != next;
178
+ }
179
+ if (ignoreUndefined) {
180
+ prev = rmUndefined(prev);
181
+ next = rmUndefined(next);
182
+ }
183
+ var keys = Object.keys(prev);
184
+ var nextKeys = Object.keys(next);
185
+ if (keys.length !== nextKeys.length ||
186
+ keys.sort().join(',') !== nextKeys.sort().join(',')) {
187
+ return true;
188
+ }
189
+ // 避免循环引用死循环。
190
+ if (~statck.indexOf(prev)) {
191
+ return false;
192
+ }
193
+ statck.push(prev);
194
+ for (var i = keys.length - 1; i >= 0; i--) {
195
+ var key = keys[i];
196
+ if (isObjectShallowModified(prev[key], next[key], strictMode, ignoreUndefined, statck)) {
197
+ return true;
198
+ }
199
+ }
200
+ return false;
201
+ }
202
+ function isArrayChildrenModified(prev, next, strictMode) {
203
+ if (strictMode === void 0) { strictMode = true; }
204
+ if (!Array.isArray(prev) || !Array.isArray(next)) {
205
+ return strictMode ? prev !== next : prev != next;
206
+ }
207
+ if (prev.length !== next.length) {
208
+ return true;
209
+ }
210
+ for (var i = prev.length - 1; i >= 0; i--) {
211
+ if (strictMode ? prev[i] !== next[i] : prev[i] != next[i]) {
212
+ return true;
213
+ }
214
+ }
215
+ return false;
216
+ }
217
+ function immutableExtends(to, from, deep) {
218
+ // 不是对象,不可以merge
219
+ if (!object.isObject(to) || !object.isObject(from)) {
220
+ return to;
221
+ }
222
+ var ret = to;
223
+ Object.keys(from).forEach(function (key) {
224
+ var origin = to[key];
225
+ var value = from[key];
226
+ // todo 支持深度merge
227
+ if (origin !== value) {
228
+ // 一旦有修改,就创建个新对象。
229
+ ret = ret !== to ? ret : tslib.__assign({}, to);
230
+ ret[key] = value;
231
+ }
232
+ });
233
+ return ret;
234
+ }
235
+ // 即将抛弃
236
+ function makeColumnClassBuild(steps, classNameTpl) {
237
+ if (classNameTpl === void 0) { classNameTpl = 'col-sm-$value'; }
238
+ var count = 12;
239
+ var step = Math.floor(count / steps);
240
+ return function (schema) {
241
+ if (schema.columnClassName &&
242
+ /\bcol-(?:xs|sm|md|lg)-(\d+)\b/.test(schema.columnClassName)) {
243
+ var flex = parseInt(RegExp.$1, 10);
244
+ count -= flex;
245
+ steps--;
246
+ step = Math.floor(count / steps);
247
+ return schema.columnClassName;
248
+ }
249
+ else if (schema.columnClassName) {
250
+ count -= step;
251
+ steps--;
252
+ return schema.columnClassName;
253
+ }
254
+ count -= step;
255
+ steps--;
256
+ return classNameTpl.replace('$value', '' + step);
257
+ };
258
+ }
259
+ function hasVisibleExpression(schema) {
260
+ return (schema === null || schema === void 0 ? void 0 : schema.visibleOn) || (schema === null || schema === void 0 ? void 0 : schema.hiddenOn);
261
+ }
262
+ function isVisible(schema, data) {
263
+ return !(schema.hidden ||
264
+ schema.visible === false ||
265
+ (schema.hiddenOn && tpl.evalExpression(schema.hiddenOn, data) === true) ||
266
+ (schema.visibleOn && tpl.evalExpression(schema.visibleOn, data) === false));
267
+ }
268
+ function isUnfolded(node, config) {
269
+ var foldedField = config.foldedField, unfoldedField = config.unfoldedField;
270
+ unfoldedField = unfoldedField || 'unfolded';
271
+ foldedField = foldedField || 'folded';
272
+ var ret = false;
273
+ if (unfoldedField && typeof node[unfoldedField] !== 'undefined') {
274
+ ret = !!node[unfoldedField];
275
+ }
276
+ else if (foldedField && typeof node[foldedField] !== 'undefined') {
277
+ ret = !node[foldedField];
278
+ }
279
+ return ret;
280
+ }
281
+ /**
282
+ * 过滤掉被隐藏的数组元素
283
+ */
284
+ function visibilityFilter(items, data) {
285
+ return items.filter(function (item) {
286
+ return isVisible(item, data);
287
+ });
288
+ }
289
+ function isDisabled(schema, data) {
290
+ return (schema.disabled ||
291
+ (schema.disabledOn && tpl.evalExpression(schema.disabledOn, data)));
292
+ }
293
+ function hasAbility(schema, ability, data, defaultValue) {
294
+ if (defaultValue === void 0) { defaultValue = true; }
295
+ return schema.hasOwnProperty(ability)
296
+ ? schema[ability]
297
+ : schema.hasOwnProperty("".concat(ability, "On"))
298
+ ? tpl.evalExpression(schema["".concat(ability, "On")], data || schema)
299
+ : defaultValue;
300
+ }
301
+ function makeHorizontalDeeper(horizontal, count) {
302
+ if (count > 1 && /\bcol-(xs|sm|md|lg)-(\d+)\b/.test(horizontal.left)) {
303
+ var flex = parseInt(RegExp.$2, 10) * count;
304
+ return {
305
+ leftFixed: horizontal.leftFixed,
306
+ left: flex,
307
+ right: 12 - flex,
308
+ offset: flex
309
+ };
310
+ }
311
+ else if (count > 1 && typeof horizontal.left === 'number') {
312
+ var flex = horizontal.left * count;
313
+ return {
314
+ leftFixed: horizontal.leftFixed,
315
+ left: flex,
316
+ right: 12 - flex,
317
+ offset: flex
318
+ };
319
+ }
320
+ return horizontal;
321
+ }
322
+ function promisify(fn) {
323
+ var promisified = function () {
324
+ try {
325
+ var ret_1 = fn.apply(null, arguments);
326
+ if (ret_1 && ret_1.then) {
327
+ return ret_1;
328
+ }
329
+ else if (typeof ret_1 === 'function') {
330
+ // thunk support
331
+ return new Promise(function (resolve, reject) {
332
+ return ret_1(function (error, value) {
333
+ return error ? reject(error) : resolve(value);
334
+ });
335
+ });
336
+ }
337
+ return Promise.resolve(ret_1);
338
+ }
339
+ catch (e) {
340
+ return Promise.reject(e);
341
+ }
342
+ };
343
+ promisified.raw = fn;
344
+ return promisified;
345
+ }
346
+ function getScrollParent(node) {
347
+ if (node == null) {
348
+ return null;
349
+ }
350
+ var style = getComputedStyle(node);
351
+ if (!style) {
352
+ return null;
353
+ }
354
+ var text = style.getPropertyValue('overflow') +
355
+ style.getPropertyValue('overflow-x') +
356
+ style.getPropertyValue('overflow-y');
357
+ if (/auto|scroll/.test(text) || node.nodeName === 'BODY') {
358
+ return node;
359
+ }
360
+ return getScrollParent(node.parentNode);
361
+ }
362
+ /**
363
+ * Deep diff between two object, using lodash
364
+ * @param {Object} object Object compared
365
+ * @param {Object} base Object to compare with
366
+ * @return {Object} Return a new object who represent the diff
367
+ */
368
+ function difference(object$1, base, keepProps) {
369
+ function changes(object$1, base) {
370
+ if (object.isObject(object$1) && object.isObject(base)) {
371
+ var keys = uniq__default["default"](Object.keys(object$1).concat(Object.keys(base)));
372
+ var result_1 = {};
373
+ keys.forEach(function (key) {
374
+ var a = object$1[key];
375
+ var b = base[key];
376
+ if (keepProps && ~keepProps.indexOf(key)) {
377
+ result_1[key] = a;
378
+ }
379
+ if (isEqual__default["default"](a, b)) {
380
+ return;
381
+ }
382
+ if (!object$1.hasOwnProperty(key)) {
383
+ result_1[key] = undefined;
384
+ }
385
+ else if (Array.isArray(a) && Array.isArray(b)) {
386
+ result_1[key] = a;
387
+ }
388
+ else {
389
+ result_1[key] = changes(a, b);
390
+ }
391
+ });
392
+ return result_1;
393
+ }
394
+ else {
395
+ return object$1;
396
+ }
397
+ }
398
+ return changes(object$1, base);
399
+ }
400
+ var padArr = function (arr, size) {
401
+ if (size === void 0) { size = 4; }
402
+ var ret = [];
403
+ var pool = arr.concat();
404
+ var from = 0;
405
+ while (pool.length) {
406
+ var host = ret[from] || (ret[from] = []);
407
+ if (host.length >= size) {
408
+ from += 1;
409
+ continue;
410
+ }
411
+ host.push(pool.shift());
412
+ }
413
+ return ret;
414
+ };
415
+ function __uri(id) {
416
+ return id;
417
+ }
418
+ // xs < 768px
419
+ // sm >= 768px
420
+ // md >= 992px
421
+ // lg >= 1200px
422
+ function isBreakpoint(str) {
423
+ if (typeof str !== 'string') {
424
+ return !!str;
425
+ }
426
+ var breaks = str.split(/\s*,\s*|\s+/);
427
+ if (window.matchMedia) {
428
+ return breaks.some(function (item) {
429
+ return item === '*' ||
430
+ (item === 'xs' &&
431
+ matchMedia("screen and (max-width: 767px)").matches) ||
432
+ (item === 'sm' &&
433
+ matchMedia("screen and (min-width: 768px) and (max-width: 991px)")
434
+ .matches) ||
435
+ (item === 'md' &&
436
+ matchMedia("screen and (min-width: 992px) and (max-width: 1199px)")
437
+ .matches) ||
438
+ (item === 'lg' && matchMedia("screen and (min-width: 1200px)").matches);
439
+ });
440
+ }
441
+ else {
442
+ var width_1 = window.innerWidth;
443
+ return breaks.some(function (item) {
444
+ return item === '*' ||
445
+ (item === 'xs' && width_1 < 768) ||
446
+ (item === 'sm' && width_1 >= 768 && width_1 < 992) ||
447
+ (item === 'md' && width_1 >= 992 && width_1 < 1200) ||
448
+ (item === 'lg' && width_1 >= 1200);
449
+ });
450
+ }
451
+ }
452
+ function until(fn, when, getCanceler, interval) {
453
+ var _this = this;
454
+ if (interval === void 0) { interval = 5000; }
455
+ var timer;
456
+ var stoped = false;
457
+ return new Promise(function (resolve, reject) {
458
+ var cancel = function () {
459
+ clearTimeout(timer);
460
+ stoped = true;
461
+ };
462
+ var check = function () { return tslib.__awaiter(_this, void 0, void 0, function () {
463
+ var ret, e_1;
464
+ return tslib.__generator(this, function (_a) {
465
+ switch (_a.label) {
466
+ case 0:
467
+ _a.trys.push([0, 2, , 3]);
468
+ return [4 /*yield*/, fn()];
469
+ case 1:
470
+ ret = _a.sent();
471
+ if (stoped) {
472
+ return [2 /*return*/];
473
+ }
474
+ else if (when(ret)) {
475
+ stoped = true;
476
+ resolve(ret);
477
+ }
478
+ else {
479
+ timer = setTimeout(check, interval);
480
+ }
481
+ return [3 /*break*/, 3];
482
+ case 2:
483
+ e_1 = _a.sent();
484
+ reject(e_1);
485
+ return [3 /*break*/, 3];
486
+ case 3: return [2 /*return*/];
487
+ }
488
+ });
489
+ }); };
490
+ check();
491
+ getCanceler && getCanceler(cancel);
492
+ });
493
+ }
494
+ function omitControls(controls, omitItems) {
495
+ return controls.filter(function (control) { return !~omitItems.indexOf(control.name || control._name); });
496
+ }
497
+ function isEmpty(thing) {
498
+ if (object.isObject(thing) && Object.keys(thing).length) {
499
+ return false;
500
+ }
501
+ return true;
502
+ }
503
+ /**
504
+ * 基于时间戳的 uuid
505
+ *
506
+ * @returns uniqueId
507
+ */
508
+ var uuid = function () {
509
+ return (+new Date()).toString(36);
510
+ };
511
+ // 参考 https://github.com/streamich/v4-uuid
512
+ var str = function () {
513
+ return ('00000000000000000' + (Math.random() * 0xffffffffffffffff).toString(16)).slice(-16);
514
+ };
515
+ var uuidv4 = function () {
516
+ var a = str();
517
+ var b = str();
518
+ return (a.slice(0, 8) +
519
+ '-' +
520
+ a.slice(8, 12) +
521
+ '-4' +
522
+ a.slice(13) +
523
+ '-a' +
524
+ b.slice(1, 4) +
525
+ '-' +
526
+ b.slice(4));
527
+ };
528
+ /**
529
+ * 类似于 arr.map 方法,此方法主要针对类似下面示例的树形结构。
530
+ * [
531
+ * {
532
+ * children: []
533
+ * },
534
+ * // 其他成员
535
+ * ]
536
+ *
537
+ * @param {Tree} tree 树形数据
538
+ * @param {Function} iterator 处理函数,返回的数据会被替换成新的。
539
+ * @return {Tree} 返回处理过的 tree
540
+ */
541
+ function mapTree(tree, iterator, level, depthFirst, paths) {
542
+ if (level === void 0) { level = 1; }
543
+ if (depthFirst === void 0) { depthFirst = false; }
544
+ if (paths === void 0) { paths = []; }
545
+ return tree.map(function (item, index) {
546
+ if (depthFirst) {
547
+ var children = item.children
548
+ ? mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item))
549
+ : undefined;
550
+ children && (item = tslib.__assign(tslib.__assign({}, item), { children: children }));
551
+ item = iterator(item, index, level, paths) || tslib.__assign({}, item);
552
+ return item;
553
+ }
554
+ item = iterator(item, index, level, paths) || tslib.__assign({}, item);
555
+ if (item.children && item.children.splice) {
556
+ item.children = mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item));
557
+ }
558
+ return item;
559
+ });
560
+ }
561
+ /**
562
+ * 遍历树
563
+ * @param tree
564
+ * @param iterator
565
+ */
566
+ function eachTree(tree, iterator, level) {
567
+ if (level === void 0) { level = 1; }
568
+ tree.map(function (item, index) {
569
+ iterator(item, index, level);
570
+ if (item.children && item.children.splice) {
571
+ eachTree(item.children, iterator, level + 1);
572
+ }
573
+ });
574
+ }
575
+ /**
576
+ * 在树中查找节点。
577
+ * @param tree
578
+ * @param iterator
579
+ */
580
+ function findTree(tree, iterator) {
581
+ var result = null;
582
+ everyTree(tree, function (item, key, level, paths) {
583
+ if (iterator(item, key, level, paths)) {
584
+ result = item;
585
+ return false;
586
+ }
587
+ return true;
588
+ });
589
+ return result;
590
+ }
591
+ /**
592
+ * 在树中查找节点, 返回下标数组。
593
+ * @param tree
594
+ * @param iterator
595
+ */
596
+ function findTreeIndex(tree, iterator) {
597
+ var idx = [];
598
+ findTree(tree, function (item, index, level, paths) {
599
+ if (iterator(item, index, level, paths)) {
600
+ idx = [index];
601
+ paths = paths.concat();
602
+ paths.unshift({
603
+ children: tree
604
+ });
605
+ for (var i = paths.length - 1; i > 0; i--) {
606
+ var prev = paths[i - 1];
607
+ var current = paths[i];
608
+ idx.unshift(prev.children.indexOf(current));
609
+ }
610
+ return true;
611
+ }
612
+ return false;
613
+ });
614
+ return idx.length ? idx : undefined;
615
+ }
616
+ function getTree(tree, idx) {
617
+ var indexes = Array.isArray(idx) ? idx.concat() : [idx];
618
+ var lastIndex = indexes.pop();
619
+ var list = tree;
620
+ for (var i = 0, len = indexes.length; i < len; i++) {
621
+ var index = indexes[i];
622
+ if (!list[index]) {
623
+ list = null;
624
+ break;
625
+ }
626
+ list = list[index].children;
627
+ }
628
+ return list ? list[lastIndex] : undefined;
629
+ }
630
+ /**
631
+ * 过滤树节点
632
+ *
633
+ * @param tree
634
+ * @param iterator
635
+ */
636
+ function filterTree(tree, iterator, level, depthFirst) {
637
+ if (level === void 0) { level = 1; }
638
+ if (depthFirst === void 0) { depthFirst = false; }
639
+ if (depthFirst) {
640
+ return tree
641
+ .map(function (item) {
642
+ var children = item.children
643
+ ? filterTree(item.children, iterator, level + 1, depthFirst)
644
+ : undefined;
645
+ if (Array.isArray(children) && Array.isArray(item.children)) {
646
+ item = tslib.__assign(tslib.__assign({}, item), { children: children });
647
+ }
648
+ return item;
649
+ })
650
+ .filter(function (item, index) { return iterator(item, index, level); });
651
+ }
652
+ return tree
653
+ .filter(function (item, index) { return iterator(item, index, level); })
654
+ .map(function (item) {
655
+ if (item.children && item.children.splice) {
656
+ var children = filterTree(item.children, iterator, level + 1, depthFirst);
657
+ if (Array.isArray(children) && Array.isArray(item.children)) {
658
+ item = tslib.__assign(tslib.__assign({}, item), { children: children });
659
+ }
660
+ }
661
+ return item;
662
+ });
663
+ }
664
+ /**
665
+ * 判断树中每个节点是否满足某个条件。
666
+ * @param tree
667
+ * @param iterator
668
+ */
669
+ function everyTree(tree, iterator, level, paths, indexes) {
670
+ if (level === void 0) { level = 1; }
671
+ if (paths === void 0) { paths = []; }
672
+ if (indexes === void 0) { indexes = []; }
673
+ return tree.every(function (item, index) {
674
+ var value = iterator(item, index, level, paths, indexes);
675
+ if (value && item.children && item.children.splice) {
676
+ return everyTree(item.children, iterator, level + 1, paths.concat(item), indexes.concat(index));
677
+ }
678
+ return value;
679
+ });
680
+ }
681
+ /**
682
+ * 判断树中是否有某些节点满足某个条件。
683
+ * @param tree
684
+ * @param iterator
685
+ */
686
+ function someTree(tree, iterator) {
687
+ var result = false;
688
+ everyTree(tree, function (item, key, level, paths) {
689
+ if (iterator(item, key, level, paths)) {
690
+ result = true;
691
+ return false;
692
+ }
693
+ return true;
694
+ });
695
+ return result;
696
+ }
697
+ function flattenTree(tree, mapper) {
698
+ var flattened = [];
699
+ eachTree(tree, function (item, index) {
700
+ return flattened.push(mapper ? mapper(item, index) : item);
701
+ });
702
+ return flattened;
703
+ }
704
+ /**
705
+ * 操作树,遵循 imutable, 每次返回一个新的树。
706
+ * 类似数组的 splice 不同的地方这个方法不修改原始数据,
707
+ * 同时第二个参数不是下标,而是下标数组,分别代表每一层的下标。
708
+ *
709
+ * 至于如何获取下标数组,请查看 findTreeIndex
710
+ *
711
+ * @param tree
712
+ * @param idx
713
+ * @param deleteCount
714
+ * @param ...items
715
+ */
716
+ function spliceTree(tree, idx, deleteCount) {
717
+ if (deleteCount === void 0) { deleteCount = 0; }
718
+ var items = [];
719
+ for (var _i = 3; _i < arguments.length; _i++) {
720
+ items[_i - 3] = arguments[_i];
721
+ }
722
+ var list = tree.concat();
723
+ if (typeof idx === 'number') {
724
+ list.splice.apply(list, tslib.__spreadArray([idx, deleteCount], items, false));
725
+ }
726
+ else if (Array.isArray(idx) && idx.length) {
727
+ idx = idx.concat();
728
+ var lastIdx = idx.pop();
729
+ var host = idx.reduce(function (list, idx) {
730
+ var child = tslib.__assign(tslib.__assign({}, list[idx]), { children: list[idx].children ? list[idx].children.concat() : [] });
731
+ list[idx] = child;
732
+ return child.children;
733
+ }, list);
734
+ host.splice.apply(host, tslib.__spreadArray([lastIdx, deleteCount], items, false));
735
+ }
736
+ return list;
737
+ }
738
+ /**
739
+ * 计算树的深度
740
+ * @param tree
741
+ */
742
+ function getTreeDepth(tree) {
743
+ return Math.max.apply(Math, tree.map(function (item) {
744
+ if (Array.isArray(item.children)) {
745
+ return 1 + getTreeDepth(item.children);
746
+ }
747
+ return 1;
748
+ }));
749
+ }
750
+ /**
751
+ * 从树中获取某个值的所有祖先
752
+ * @param tree
753
+ * @param value
754
+ */
755
+ function getTreeAncestors(tree, value, includeSelf) {
756
+ if (includeSelf === void 0) { includeSelf = false; }
757
+ var ancestors = null;
758
+ findTree(tree, function (item, index, level, paths) {
759
+ if (item === value) {
760
+ ancestors = paths;
761
+ if (includeSelf) {
762
+ ancestors.push(item);
763
+ }
764
+ return true;
765
+ }
766
+ return false;
767
+ });
768
+ return ancestors;
769
+ }
770
+ /**
771
+ * 从树中获取某个值的上级
772
+ * @param tree
773
+ * @param value
774
+ */
775
+ function getTreeParent(tree, value) {
776
+ var ancestors = getTreeAncestors(tree, value);
777
+ return (ancestors === null || ancestors === void 0 ? void 0 : ancestors.length) ? ancestors[ancestors.length - 1] : null;
778
+ }
779
+ function ucFirst(str) {
780
+ return typeof str === 'string'
781
+ ? str.substring(0, 1).toUpperCase() + str.substring(1)
782
+ : str;
783
+ }
784
+ function lcFirst(str) {
785
+ return str ? str.substring(0, 1).toLowerCase() + str.substring(1) : '';
786
+ }
787
+ function camel(str) {
788
+ return str
789
+ ? str
790
+ .split(/[\s_\-]/)
791
+ .map(function (item, index) { return (index === 0 ? lcFirst(item) : ucFirst(item)); })
792
+ .join('')
793
+ : '';
794
+ }
795
+ function getWidthRate(value, strictMode) {
796
+ if (strictMode === void 0) { strictMode = false; }
797
+ if (typeof value === 'string' && /\bcol\-\w+\-(\d+)\b/.test(value)) {
798
+ return parseInt(RegExp.$1, 10);
799
+ }
800
+ return strictMode ? 0 : value || 0;
801
+ }
802
+ function getLevelFromClassName(value, defaultValue) {
803
+ if (defaultValue === void 0) { defaultValue = 'default'; }
804
+ if (/\b(?:btn|text)-(link|primary|secondary|info|success|warning|danger|light|dark)\b/.test(value)) {
805
+ return RegExp.$1;
806
+ }
807
+ return defaultValue;
808
+ }
809
+ function pickEventsProps(props) {
810
+ var ret = {};
811
+ props &&
812
+ Object.keys(props).forEach(function (key) { return /^on/.test(key) && (ret[key] = props[key]); });
813
+ return ret;
814
+ }
815
+ var autobind = autobind$1.autobindMethod;
816
+ var bulkBindFunctions = function (context, funNames) {
817
+ funNames.forEach(function (key) { return (context[key] = context[key].bind(context)); });
818
+ };
819
+ function sortArray(items, field, dir) {
820
+ return items.sort(function (a, b) {
821
+ var ret;
822
+ var a1 = a[field];
823
+ var b1 = b[field];
824
+ if (typeof a1 === 'number' && typeof b1 === 'number') {
825
+ ret = a1 < b1 ? -1 : a1 === b1 ? 0 : 1;
826
+ }
827
+ else {
828
+ ret = String(a1).localeCompare(String(b1));
829
+ }
830
+ return ret * dir;
831
+ });
832
+ }
833
+ // 只判断一层, 如果层级很深,form-data 也不好表达。
834
+ function hasFile(object) {
835
+ return Object.keys(object).some(function (key) {
836
+ var value = object[key];
837
+ return (value instanceof File ||
838
+ (Array.isArray(value) && value.length && value[0] instanceof File));
839
+ });
840
+ }
841
+ function qsstringify(data, options, keepEmptyArray) {
842
+ if (options === void 0) { options = {
843
+ arrayFormat: 'indices',
844
+ encodeValuesOnly: true
845
+ }; }
846
+ // qs会保留空字符串。fix: Combo模式的空数组,无法清空。改为存为空字符串;只转换一层
847
+ keepEmptyArray &&
848
+ Object.keys(data).forEach(function (key) {
849
+ Array.isArray(data[key]) && !data[key].length && (data[key] = '');
850
+ });
851
+ return qs__default["default"].stringify(data, options);
852
+ }
853
+ function qsparse(data, options) {
854
+ if (options === void 0) { options = {
855
+ arrayFormat: 'indices',
856
+ encodeValuesOnly: true,
857
+ depth: 1000 // 默认是 5, 所以condition-builder只要来个条件组就会导致报错
858
+ }; }
859
+ return qs__default["default"].parse(data, options);
860
+ }
861
+ function object2formData(data, options, fd) {
862
+ if (options === void 0) { options = {
863
+ arrayFormat: 'indices',
864
+ encodeValuesOnly: true
865
+ }; }
866
+ if (fd === void 0) { fd = new FormData(); }
867
+ var fileObjects = [];
868
+ var others = {};
869
+ Object.keys(data).forEach(function (key) {
870
+ var value = data[key];
871
+ if (value instanceof File) {
872
+ fileObjects.push([key, value]);
873
+ }
874
+ else if (Array.isArray(value) &&
875
+ value.length &&
876
+ value[0] instanceof File) {
877
+ value.forEach(function (value) { return fileObjects.push(["".concat(key, "[]"), value]); });
878
+ }
879
+ else {
880
+ others[key] = value;
881
+ }
882
+ });
883
+ // 因为 key 的格式太多了,偷个懒,用 qs 来处理吧。
884
+ qsstringify(others, options)
885
+ .split('&')
886
+ .forEach(function (item) {
887
+ var parts = item.split('=');
888
+ // form-data/multipart 是不需要 encode 值的。
889
+ parts[0] && fd.append(parts[0], decodeURIComponent(parts[1]));
890
+ });
891
+ // Note: File类型字段放在后面,可以支持第三方云存储鉴权
892
+ fileObjects.forEach(function (fileObject) {
893
+ return fd.append(fileObject[0], fileObject[1], fileObject[1].name);
894
+ });
895
+ return fd;
896
+ }
897
+ function chainFunctions() {
898
+ var fns = [];
899
+ for (var _i = 0; _i < arguments.length; _i++) {
900
+ fns[_i] = arguments[_i];
901
+ }
902
+ return function () {
903
+ var args = [];
904
+ for (var _i = 0; _i < arguments.length; _i++) {
905
+ args[_i] = arguments[_i];
906
+ }
907
+ return fns.reduce(function (ret, fn) {
908
+ return ret === false
909
+ ? false
910
+ : typeof fn == 'function'
911
+ ? fn.apply(void 0, args) : undefined;
912
+ }, undefined);
913
+ };
914
+ }
915
+ function chainEvents(props, schema) {
916
+ var ret = {};
917
+ Object.keys(props).forEach(function (key) {
918
+ if (key.substr(0, 2) === 'on' &&
919
+ typeof props[key] === 'function' &&
920
+ typeof schema[key] === 'function' &&
921
+ schema[key] !== props[key]) {
922
+ // 表单项里面的 onChange 很特殊,这个不要处理。
923
+ if (props.formStore && key === 'onChange') {
924
+ ret[key] = props[key];
925
+ }
926
+ else {
927
+ ret[key] = chainFunctions(schema[key], props[key]);
928
+ }
929
+ }
930
+ else {
931
+ ret[key] = props[key];
932
+ }
933
+ });
934
+ return ret;
935
+ }
936
+ function mapObject(value, fn) {
937
+ if (Array.isArray(value)) {
938
+ return value.map(function (item) { return mapObject(item, fn); });
939
+ }
940
+ if (object.isObject(value)) {
941
+ var tmpValue_1 = tslib.__assign({}, value);
942
+ Object.keys(tmpValue_1).forEach(function (key) {
943
+ tmpValue_1[key] = mapObject(tmpValue_1[key], fn);
944
+ });
945
+ return tmpValue_1;
946
+ }
947
+ return fn(value);
948
+ }
949
+ function loadScript(src) {
950
+ return new Promise(function (ok, fail) {
951
+ var script = document.createElement('script');
952
+ script.onerror = function (reason) { return fail(reason); };
953
+ if (~src.indexOf('{{callback}}')) {
954
+ var callbackFn_1 = "loadscriptcallback_".concat(uuid());
955
+ window[callbackFn_1] = function () {
956
+ ok();
957
+ delete window[callbackFn_1];
958
+ };
959
+ src = src.replace('{{callback}}', callbackFn_1);
960
+ }
961
+ else {
962
+ script.onload = function () { return ok(); };
963
+ }
964
+ script.src = src;
965
+ document.head.appendChild(script);
966
+ });
967
+ }
968
+ var SkipOperation = /** @class */ (function (_super) {
969
+ tslib.__extends(SkipOperation, _super);
970
+ function SkipOperation() {
971
+ return _super !== null && _super.apply(this, arguments) || this;
972
+ }
973
+ return SkipOperation;
974
+ }(Error));
975
+ /**
976
+ * 检查对象是否有循环引用,来自 https://stackoverflow.com/a/34909127
977
+ * @param obj
978
+ */
979
+ function isCyclic(obj) {
980
+ var seenObjects = [];
981
+ function detect(obj) {
982
+ if (obj && typeof obj === 'object') {
983
+ if (seenObjects.indexOf(obj) !== -1) {
984
+ return true;
985
+ }
986
+ seenObjects.push(obj);
987
+ for (var key in obj) {
988
+ if (obj.hasOwnProperty(key) && detect(obj[key])) {
989
+ return true;
990
+ }
991
+ }
992
+ }
993
+ return false;
994
+ }
995
+ return detect(obj);
996
+ }
997
+ function internalFindObjectsWithKey(obj, key) {
998
+ var objects = [];
999
+ for (var k in obj) {
1000
+ if (!obj.hasOwnProperty(k))
1001
+ continue;
1002
+ if (k === key) {
1003
+ objects.push(obj);
1004
+ }
1005
+ else if (typeof obj[k] === 'object') {
1006
+ objects = objects.concat(internalFindObjectsWithKey(obj[k], key));
1007
+ }
1008
+ }
1009
+ return objects;
1010
+ }
1011
+ /**
1012
+ * 深度查找具有某个 key 名字段的对象,实际实现是 internalFindObjectsWithKey,这里包一层是为了做循环引用检测
1013
+ * @param obj
1014
+ * @param key
1015
+ */
1016
+ function findObjectsWithKey(obj, key) {
1017
+ // 避免循环引用导致死循环
1018
+ if (isCyclic(obj)) {
1019
+ return [];
1020
+ }
1021
+ return internalFindObjectsWithKey(obj, key);
1022
+ }
1023
+ var scrollbarWidth;
1024
+ /**
1025
+ * 获取浏览器滚动条宽度 https://stackoverflow.com/a/13382873
1026
+ */
1027
+ function getScrollbarWidth() {
1028
+ if (typeof scrollbarWidth !== 'undefined') {
1029
+ return scrollbarWidth;
1030
+ }
1031
+ // Creating invisible container
1032
+ var outer = document.createElement('div');
1033
+ outer.style.visibility = 'hidden';
1034
+ outer.style.overflow = 'scroll'; // forcing scrollbar to appear
1035
+ // @ts-ignore
1036
+ outer.style.msOverflowStyle = 'scrollbar'; // needed for WinJS apps
1037
+ document.body.appendChild(outer);
1038
+ // Creating inner element and placing it in the container
1039
+ var inner = document.createElement('div');
1040
+ outer.appendChild(inner);
1041
+ // Calculating difference between container's full width and the child width
1042
+ scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
1043
+ // Removing temporary elements from the DOM
1044
+ // @ts-ignore
1045
+ outer.parentNode.removeChild(outer);
1046
+ return scrollbarWidth;
1047
+ }
1048
+ // 后续改用 FormulaExec['formula']
1049
+ function resolveValueByName(data, name) {
1050
+ return isPureVariable.isPureVariable(name)
1051
+ ? resolveVariableAndFilter.resolveVariableAndFilter(name, data)
1052
+ : resolveVariable.resolveVariable(name, data);
1053
+ }
1054
+ // 统一的获取 value 值方法
1055
+ function getPropValue(props, getter) {
1056
+ var _a, _b;
1057
+ var name = props.name, value = props.value, data = props.data, defaultValue = props.defaultValue;
1058
+ 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)) !== null && _b !== void 0 ? _b : defaultValue);
1059
+ }
1060
+ // 检测 value 是否有变化,有变化就执行 onChange
1061
+ function detectPropValueChanged(props, prevProps, onChange, getter) {
1062
+ var nextValue;
1063
+ if (typeof props.value !== 'undefined') {
1064
+ props.value !== prevProps.value && onChange(props.value);
1065
+ }
1066
+ else if ((nextValue = getter === null || getter === void 0 ? void 0 : getter(props)) !== undefined) {
1067
+ nextValue !== getter(prevProps) && onChange(nextValue);
1068
+ }
1069
+ else if (typeof props.name === 'string' &&
1070
+ (nextValue = resolveValueByName(props.data, props.name)) !== undefined) {
1071
+ nextValue !== resolveValueByName(prevProps.data, prevProps.name) &&
1072
+ onChange(nextValue);
1073
+ }
1074
+ else if (props.defaultValue !== prevProps.defaultValue) {
1075
+ onChange(props.defaultValue);
1076
+ }
1077
+ }
1078
+ // 去掉字符串中的 html 标签,不完全准确但效率比较高
1079
+ function removeHTMLTag(str) {
1080
+ return typeof str === 'string' ? str.replace(/<\/?[^>]+(>|$)/g, '') : str;
1081
+ }
1082
+ /**
1083
+ * 将路径格式的value转换成普通格式的value值
1084
+ *
1085
+ * @example
1086
+ *
1087
+ * 'a/b/c' => 'c';
1088
+ * {label: 'A/B/C', value: 'a/b/c'} => {label: 'C', value: 'c'};
1089
+ * 'a/b/c,a/d' => 'c,d';
1090
+ * ['a/b/c', 'a/d'] => ['c', 'd'];
1091
+ * [{label: 'A/B/C', value: 'a/b/c'},{label: 'A/D', value: 'a/d'}] => [{label: 'C', value: 'c'},{label: 'D', value: 'd'}]
1092
+ */
1093
+ function normalizeNodePath(value, enableNodePath, labelField, valueField, pathSeparator, delimiter) {
1094
+ var _a;
1095
+ if (labelField === void 0) { labelField = 'label'; }
1096
+ if (valueField === void 0) { valueField = 'value'; }
1097
+ if (pathSeparator === void 0) { pathSeparator = '/'; }
1098
+ if (delimiter === void 0) { delimiter = ','; }
1099
+ var nodeValueArray = [];
1100
+ var nodePathArray = [];
1101
+ var getLastNodeFromPath = function (path) {
1102
+ return last__default["default"](path ? path.toString().split(pathSeparator) : []);
1103
+ };
1104
+ if (typeof value === 'undefined' || !enableNodePath) {
1105
+ return { nodeValueArray: nodeValueArray, nodePathArray: nodePathArray };
1106
+ }
1107
+ // 尾节点为当前options中value值
1108
+ if (Array.isArray(value)) {
1109
+ value.forEach(function (nodePath) {
1110
+ var _a;
1111
+ if (nodePath && nodePath.hasOwnProperty(valueField)) {
1112
+ nodeValueArray.push(tslib.__assign(tslib.__assign({}, nodePath), (_a = {}, _a[labelField] = getLastNodeFromPath(nodePath[labelField]), _a[valueField] = getLastNodeFromPath(nodePath[valueField]), _a)));
1113
+ nodePathArray.push(nodePath[valueField]);
1114
+ }
1115
+ else {
1116
+ nodeValueArray.push(getLastNodeFromPath(nodePath));
1117
+ nodePathArray.push(nodePath);
1118
+ }
1119
+ });
1120
+ }
1121
+ else if (typeof value === 'string') {
1122
+ value
1123
+ .toString()
1124
+ .split(delimiter)
1125
+ .forEach(function (path) {
1126
+ nodeValueArray.push(getLastNodeFromPath(path));
1127
+ nodePathArray.push(path);
1128
+ });
1129
+ }
1130
+ else {
1131
+ nodeValueArray.push(tslib.__assign(tslib.__assign({}, value), (_a = {}, _a[labelField] = getLastNodeFromPath(value[labelField]), _a[valueField || 'value'] = getLastNodeFromPath(value[valueField]), _a)));
1132
+ nodePathArray.push(value[valueField]);
1133
+ }
1134
+ return { nodeValueArray: nodeValueArray, nodePathArray: nodePathArray };
1135
+ }
1136
+ // 主要用于排除点击输入框和链接等情况
1137
+ function isClickOnInput(e) {
1138
+ var target = e.target;
1139
+ var formItem;
1140
+ if (!e.currentTarget.contains(target) ||
1141
+ ~['INPUT', 'TEXTAREA'].indexOf(target.tagName) ||
1142
+ ((formItem = target.closest("button, a, [data-role=\"form-item\"]")) &&
1143
+ e.currentTarget.contains(formItem))) {
1144
+ return true;
1145
+ }
1146
+ return false;
1147
+ }
1148
+ // 计算字符串 hash
1149
+ function hashCode(s) {
1150
+ return s.split('').reduce(function (a, b) {
1151
+ a = (a << 5) - a + b.charCodeAt(0);
1152
+ return a & a;
1153
+ }, 0);
1154
+ }
1155
+ /**
1156
+ * 遍历 schema
1157
+ * @param json
1158
+ * @param mapper
1159
+ */
1160
+ function JSONTraverse(json, mapper) {
1161
+ Object.keys(json).forEach(function (key) {
1162
+ var value = json[key];
1163
+ if (isPlainObject__default["default"](value) || Array.isArray(value)) {
1164
+ JSONTraverse(value, mapper);
1165
+ }
1166
+ else {
1167
+ mapper(value, key, json);
1168
+ }
1169
+ });
1170
+ }
1171
+ function convertArrayValueToMoment(value, types, mom) {
1172
+ if (value.length === 0)
1173
+ return mom;
1174
+ for (var i = 0; i < types.length; i++) {
1175
+ var type = types[i];
1176
+ // @ts-ignore
1177
+ mom.set(type, value[i]);
1178
+ }
1179
+ return mom;
1180
+ }
1181
+ function getRange(min, max, step) {
1182
+ if (step === void 0) { step = 1; }
1183
+ var arr = [];
1184
+ for (var i = min; i <= max; i += step) {
1185
+ arr.push(i);
1186
+ }
1187
+ return arr;
1188
+ }
1189
+ function repeatCount(count, iterator) {
1190
+ var result = [];
1191
+ var index = 0;
1192
+ while (count--) {
1193
+ result.push(iterator(index++));
1194
+ }
1195
+ return result;
1196
+ }
1197
+
1198
+ exports.cloneObject = object.cloneObject;
1199
+ exports.createObject = object.createObject;
1200
+ exports.deleteVariable = object.deleteVariable;
1201
+ exports.extendObject = object.extendObject;
1202
+ exports.isObject = object.isObject;
1203
+ exports.setVariable = object.setVariable;
1204
+ exports.string2regExp = string2regExp.string2regExp;
1205
+ exports.getVariable = getVariable.getVariable;
1206
+ exports.keyToPath = keyToPath.keyToPath;
1207
+ exports.JSONTraverse = JSONTraverse;
1208
+ exports.SkipOperation = SkipOperation;
1209
+ exports.__uri = __uri;
1210
+ exports.anyChanged = anyChanged;
1211
+ exports.autobind = autobind;
1212
+ exports.bulkBindFunctions = bulkBindFunctions;
1213
+ exports.camel = camel;
1214
+ exports.chainEvents = chainEvents;
1215
+ exports.chainFunctions = chainFunctions;
1216
+ exports.convertArrayValueToMoment = convertArrayValueToMoment;
1217
+ exports.detectPropValueChanged = detectPropValueChanged;
1218
+ exports.difference = difference;
1219
+ exports.eachTree = eachTree;
1220
+ exports.everyTree = everyTree;
1221
+ exports.filterTree = filterTree;
1222
+ exports.findIndex = findIndex;
1223
+ exports.findObjectsWithKey = findObjectsWithKey;
1224
+ exports.findTree = findTree;
1225
+ exports.findTreeIndex = findTreeIndex;
1226
+ exports.flattenTree = flattenTree;
1227
+ exports.getLevelFromClassName = getLevelFromClassName;
1228
+ exports.getPropValue = getPropValue;
1229
+ exports.getRange = getRange;
1230
+ exports.getScrollParent = getScrollParent;
1231
+ exports.getScrollbarWidth = getScrollbarWidth;
1232
+ exports.getTree = getTree;
1233
+ exports.getTreeAncestors = getTreeAncestors;
1234
+ exports.getTreeDepth = getTreeDepth;
1235
+ exports.getTreeParent = getTreeParent;
1236
+ exports.getWidthRate = getWidthRate;
1237
+ exports.guid = guid;
1238
+ exports.hasAbility = hasAbility;
1239
+ exports.hasFile = hasFile;
1240
+ exports.hasOwnProperty = hasOwnProperty;
1241
+ exports.hasVisibleExpression = hasVisibleExpression;
1242
+ exports.hashCode = hashCode;
1243
+ exports.immutableExtends = immutableExtends;
1244
+ exports.injectPropsToObject = injectPropsToObject;
1245
+ exports.isArrayChildrenModified = isArrayChildrenModified;
1246
+ exports.isBreakpoint = isBreakpoint;
1247
+ exports.isClickOnInput = isClickOnInput;
1248
+ exports.isDisabled = isDisabled;
1249
+ exports.isEmpty = isEmpty;
1250
+ exports.isMobile = isMobile;
1251
+ exports.isObjectShallowModified = isObjectShallowModified;
1252
+ exports.isSuperDataModified = isSuperDataModified;
1253
+ exports.isUnfolded = isUnfolded;
1254
+ exports.isVisible = isVisible;
1255
+ exports.lcFirst = lcFirst;
1256
+ exports.loadScript = loadScript;
1257
+ exports.makeColumnClassBuild = makeColumnClassBuild;
1258
+ exports.makeHorizontalDeeper = makeHorizontalDeeper;
1259
+ exports.mapObject = mapObject;
1260
+ exports.mapTree = mapTree;
1261
+ exports.noop = noop;
1262
+ exports.normalizeNodePath = normalizeNodePath;
1263
+ exports.object2formData = object2formData;
1264
+ exports.omitControls = omitControls;
1265
+ exports.padArr = padArr;
1266
+ exports.pickEventsProps = pickEventsProps;
1267
+ exports.preventDefault = preventDefault;
1268
+ exports.promisify = promisify;
1269
+ exports.qsparse = qsparse;
1270
+ exports.qsstringify = qsstringify;
1271
+ exports.range = range;
1272
+ exports.removeHTMLTag = removeHTMLTag;
1273
+ exports.repeatCount = repeatCount;
1274
+ exports.rmUndefined = rmUndefined;
1275
+ exports.someTree = someTree;
1276
+ exports.sortArray = sortArray;
1277
+ exports.spliceTree = spliceTree;
1278
+ exports.syncDataFromSuper = syncDataFromSuper;
1279
+ exports.ucFirst = ucFirst;
1280
+ exports.until = until;
1281
+ exports.uuid = uuid;
1282
+ exports.uuidv4 = uuidv4;
1283
+ exports.visibilityFilter = visibilityFilter;