@byteluck-fe/model-driven-controls 7.1.0-beta.2 → 7.1.0-beta.4

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.
@@ -0,0 +1,373 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
+ }
12
+ function _define_property(obj, key, value) {
13
+ if (key in obj) {
14
+ Object.defineProperty(obj, key, {
15
+ value: value,
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true
19
+ });
20
+ } else obj[key] = value;
21
+ return obj;
22
+ }
23
+ function _iterable_to_array(iter) {
24
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
25
+ return Array.from(iter);
26
+ }
27
+ }
28
+ function _iterable_to_array_limit(arr, i) {
29
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
30
+ if (_i == null) return;
31
+ var _arr = [];
32
+ var _n = true;
33
+ var _d = false;
34
+ var _s, _e;
35
+ try {
36
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
37
+ _arr.push(_s.value);
38
+ if (i && _arr.length === i) break;
39
+ }
40
+ } catch (err) {
41
+ _d = true;
42
+ _e = err;
43
+ } finally{
44
+ try {
45
+ if (!_n && _i["return"] != null) _i["return"]();
46
+ } finally{
47
+ if (_d) throw _e;
48
+ }
49
+ }
50
+ return _arr;
51
+ }
52
+ function _non_iterable_rest() {
53
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
54
+ }
55
+ function _non_iterable_spread() {
56
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
57
+ }
58
+ function _object_spread(target) {
59
+ for(var i = 1; i < arguments.length; i++){
60
+ var source = arguments[i] != null ? arguments[i] : {};
61
+ var ownKeys = Object.keys(source);
62
+ if (typeof Object.getOwnPropertySymbols === "function") {
63
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
64
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
65
+ }));
66
+ }
67
+ ownKeys.forEach(function(key) {
68
+ _define_property(target, key, source[key]);
69
+ });
70
+ }
71
+ return target;
72
+ }
73
+ function ownKeys(object, enumerableOnly) {
74
+ var keys = Object.keys(object);
75
+ if (Object.getOwnPropertySymbols) {
76
+ var symbols = Object.getOwnPropertySymbols(object);
77
+ if (enumerableOnly) {
78
+ symbols = symbols.filter(function(sym) {
79
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
80
+ });
81
+ }
82
+ keys.push.apply(keys, symbols);
83
+ }
84
+ return keys;
85
+ }
86
+ function _object_spread_props(target, source) {
87
+ source = source != null ? source : {};
88
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
89
+ else {
90
+ ownKeys(Object(source)).forEach(function(key) {
91
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
92
+ });
93
+ }
94
+ return target;
95
+ }
96
+ function _sliced_to_array(arr, i) {
97
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
98
+ }
99
+ function _to_consumable_array(arr) {
100
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
101
+ }
102
+ function _type_of(obj) {
103
+ "@swc/helpers - typeof";
104
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
105
+ }
106
+ function _unsupported_iterable_to_array(o, minLen) {
107
+ if (!o) return;
108
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
109
+ var n = Object.prototype.toString.call(o).slice(8, -1);
110
+ if (n === "Object" && o.constructor) n = o.constructor.name;
111
+ if (n === "Map" || n === "Set") return Array.from(n);
112
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
113
+ }
114
+ import { applyControlRuntimeAbsentDefaults } from './query';
115
+ /** 公共入口接受 unknown,因此对非 JSON 构造态对象也设置有界递归。 */ var MAX_CONTROL_TREE_DEPTH = 64;
116
+ /**
117
+ * 当前公共模型中已确认的 props 嵌套控件槽位。footers 仍存在于历史列表 Schema。
118
+ */ export var CONTROL_TREE_NESTED_PROP_KEYS = [
119
+ 'headers',
120
+ 'footers'
121
+ ];
122
+ function isRecord(value) {
123
+ return (typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value !== null && !Array.isArray(value);
124
+ }
125
+ /**
126
+ * 只要求保存态与构造态共有字段;不要求 id/controlType,兼容待诊断的历史节点。
127
+ */ export function isControlTreeNode(value) {
128
+ return Boolean(isRecord(value) && typeof value.type === 'string' && isRecord(value.props));
129
+ }
130
+ function nestedPropKeys(options) {
131
+ return Array.from(new Set(_to_consumable_array(CONTROL_TREE_NESTED_PROP_KEYS).concat(_to_consumable_array(options.additionalNestedPropKeys || []))));
132
+ }
133
+ function visitNestedValue(value, path, parent, nestedPropKey, propKeys, visitor, ancestors, depth) {
134
+ if (depth > MAX_CONTROL_TREE_DEPTH) return;
135
+ if (isControlTreeNode(value)) {
136
+ visitNode(value, path, parent, 'nested-prop', nestedPropKey, propKeys, visitor, ancestors, depth);
137
+ return;
138
+ }
139
+ if (!Array.isArray(value) && !isRecord(value)) return;
140
+ if (ancestors.has(value)) return;
141
+ ancestors.add(value);
142
+ try {
143
+ if (Array.isArray(value)) {
144
+ value.forEach(function(item, index) {
145
+ return visitNestedValue(item, _to_consumable_array(path).concat([
146
+ index
147
+ ]), parent, nestedPropKey, propKeys, visitor, ancestors, depth + 1);
148
+ });
149
+ return;
150
+ }
151
+ Object.entries(value).forEach(function(param) {
152
+ var _param = _sliced_to_array(param, 2), key = _param[0], item = _param[1];
153
+ return visitNestedValue(item, _to_consumable_array(path).concat([
154
+ key
155
+ ]), parent, nestedPropKey, propKeys, visitor, ancestors, depth + 1);
156
+ });
157
+ } finally{
158
+ ancestors.delete(value);
159
+ }
160
+ }
161
+ function visitNode(node, path, parent, source, nestedPropKey, propKeys, visitor, ancestors, depth) {
162
+ if (depth > MAX_CONTROL_TREE_DEPTH || ancestors.has(node)) return;
163
+ ancestors.add(node);
164
+ try {
165
+ // visitor 获得独立路径,即使 JavaScript 调用方强制修改也不污染后续遍历。
166
+ visitor({
167
+ node: node,
168
+ path: _to_consumable_array(path),
169
+ parent: parent,
170
+ source: source,
171
+ nestedPropKey: nestedPropKey
172
+ });
173
+ if (Array.isArray(node.children) && !ancestors.has(node.children)) {
174
+ ancestors.add(node.children);
175
+ try {
176
+ node.children.forEach(function(child, index) {
177
+ if (!isControlTreeNode(child)) return;
178
+ visitNode(child, _to_consumable_array(path).concat([
179
+ 'children',
180
+ index
181
+ ]), node, 'children', undefined, propKeys, visitor, ancestors, depth + 1);
182
+ });
183
+ } finally{
184
+ ancestors.delete(node.children);
185
+ }
186
+ }
187
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
188
+ try {
189
+ for(var _iterator = propKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
190
+ var propKey = _step.value;
191
+ if (!Object.prototype.hasOwnProperty.call(node.props, propKey)) continue;
192
+ visitNestedValue(node.props[propKey], _to_consumable_array(path).concat([
193
+ 'props',
194
+ propKey
195
+ ]), node, propKey, propKeys, visitor, ancestors, depth + 1);
196
+ }
197
+ } catch (err) {
198
+ _didIteratorError = true;
199
+ _iteratorError = err;
200
+ } finally{
201
+ try {
202
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
203
+ _iterator.return();
204
+ }
205
+ } finally{
206
+ if (_didIteratorError) {
207
+ throw _iteratorError;
208
+ }
209
+ }
210
+ }
211
+ } finally{
212
+ ancestors.delete(node);
213
+ }
214
+ }
215
+ /**
216
+ * 以前序稳定顺序遍历一个控件或控件数组。visitor 只接收只读视图,本函数不修改输入。
217
+ */ export function visitControlTree(value, visitor) {
218
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
219
+ var propKeys = nestedPropKeys(options);
220
+ var ancestors = new Set();
221
+ if (isControlTreeNode(value)) {
222
+ visitNode(value, [], undefined, 'root', undefined, propKeys, visitor, ancestors, 0);
223
+ return;
224
+ }
225
+ if (!Array.isArray(value)) return;
226
+ ancestors.add(value);
227
+ try {
228
+ value.forEach(function(item, index) {
229
+ if (!isControlTreeNode(item)) return;
230
+ visitNode(item, [
231
+ index
232
+ ], undefined, 'root', undefined, propKeys, visitor, ancestors, 0);
233
+ });
234
+ } finally{
235
+ ancestors.delete(value);
236
+ }
237
+ }
238
+ /** 返回稳定顺序的节点与路径,不复制页面 JSON 或 props。 */ export function collectControlTreeNodes(value) {
239
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
240
+ var result = [];
241
+ visitControlTree(value, function(visit) {
242
+ return result.push(visit);
243
+ }, options);
244
+ return result;
245
+ }
246
+ function mapNestedValue(value, propKeys, ancestors, depth) {
247
+ if (depth > MAX_CONTROL_TREE_DEPTH) return value;
248
+ if (isControlTreeNode(value)) {
249
+ return mapNode(value, propKeys, ancestors, depth);
250
+ }
251
+ if (!Array.isArray(value) && !isRecord(value)) return value;
252
+ if (ancestors.has(value)) return value;
253
+ ancestors.add(value);
254
+ try {
255
+ if (Array.isArray(value)) {
256
+ var result = value;
257
+ value.forEach(function(item, index) {
258
+ var next = mapNestedValue(item, propKeys, ancestors, depth + 1);
259
+ if (next === item) return;
260
+ if (result === value) result = _to_consumable_array(value);
261
+ result[index] = next;
262
+ });
263
+ return result;
264
+ }
265
+ var result1 = value;
266
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
267
+ try {
268
+ for(var _iterator = Object.entries(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
269
+ var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], item = _step_value[1];
270
+ var next = mapNestedValue(item, propKeys, ancestors, depth + 1);
271
+ if (next === item) continue;
272
+ if (result1 === value) result1 = _object_spread({}, value);
273
+ result1[key] = next;
274
+ }
275
+ } catch (err) {
276
+ _didIteratorError = true;
277
+ _iteratorError = err;
278
+ } finally{
279
+ try {
280
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
281
+ _iterator.return();
282
+ }
283
+ } finally{
284
+ if (_didIteratorError) {
285
+ throw _iteratorError;
286
+ }
287
+ }
288
+ }
289
+ return result1;
290
+ } finally{
291
+ ancestors.delete(value);
292
+ }
293
+ }
294
+ function mapNode(input, propKeys, ancestors, depth) {
295
+ if (depth > MAX_CONTROL_TREE_DEPTH || ancestors.has(input)) return input;
296
+ ancestors.add(input);
297
+ try {
298
+ var node = input;
299
+ if (Array.isArray(input.children)) {
300
+ var children = mapNestedValue(input.children, propKeys, ancestors, depth + 1);
301
+ if (children !== input.children) node = _object_spread_props(_object_spread({}, node), {
302
+ children: children
303
+ });
304
+ }
305
+ var props = node.props;
306
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
307
+ try {
308
+ for(var _iterator = propKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
309
+ var propKey = _step.value;
310
+ if (!Object.prototype.hasOwnProperty.call(props, propKey)) continue;
311
+ var current = props[propKey];
312
+ var next = mapNestedValue(current, propKeys, ancestors, depth + 1);
313
+ if (next === current) continue;
314
+ if (props === node.props) props = _object_spread({}, props);
315
+ props[propKey] = next;
316
+ }
317
+ } catch (err) {
318
+ _didIteratorError = true;
319
+ _iteratorError = err;
320
+ } finally{
321
+ try {
322
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
323
+ _iterator.return();
324
+ }
325
+ } finally{
326
+ if (_didIteratorError) {
327
+ throw _iteratorError;
328
+ }
329
+ }
330
+ }
331
+ if (props !== node.props) node = _object_spread_props(_object_spread({}, node), {
332
+ props: props
333
+ });
334
+ var normalizedProps = applyControlRuntimeAbsentDefaults(node.type, node.props);
335
+ if (normalizedProps !== node.props) {
336
+ node = _object_spread_props(_object_spread({}, node), {
337
+ props: normalizedProps
338
+ });
339
+ }
340
+ return node;
341
+ } finally{
342
+ ancestors.delete(input);
343
+ }
344
+ }
345
+ function mapRootValue(value, propKeys) {
346
+ var ancestors = new Set();
347
+ if (isControlTreeNode(value)) return mapNode(value, propKeys, ancestors, 0);
348
+ if (!Array.isArray(value)) return value;
349
+ var result = value;
350
+ ancestors.add(value);
351
+ try {
352
+ value.forEach(function(item, index) {
353
+ if (!isControlTreeNode(item)) return;
354
+ var next = mapNode(item, propKeys, ancestors, 0);
355
+ if (next === item) return;
356
+ if (result === value) result = _to_consumable_array(value);
357
+ result[index] = next;
358
+ });
359
+ } finally{
360
+ ancestors.delete(value);
361
+ }
362
+ return result;
363
+ }
364
+ /**
365
+ * 为整棵树补齐 catalog 已核实的 Runtime 缺失属性语义。
366
+ *
367
+ * - 缺失与 own-property `undefined` 使用 absent Runtime 值;`null` 和其它显式值保留。
368
+ * - 结果使用 catalog 公共构造属性名,适合实例化兼容,不是持久化 Schema 升级。
369
+ * - 未变化时保留原引用;变化时只复制命中节点及其祖先,不修改输入对象。
370
+ */ export function applyRuntimeAbsentDefaultsToControlTree(value) {
371
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
372
+ return mapRootValue(value, nestedPropKeys(options));
373
+ }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": "model-driven.control-catalog.v1",
3
- "packageVersion": "7.1.0-beta.2",
4
- "sourceRevision": "sha256:4cdee256c5d2cda0cd50a4e95062cbf508b492bf72cedf51d97fed16cc1232ab",
5
- "revision": "sha256:0298f53a35e5849dc05fdf4277e9945bb627d04325f6f8fca9f1098469c2ad93",
3
+ "packageVersion": "7.1.0-beta.4",
4
+ "sourceRevision": "sha256:29da8bd3ec3de616fe213143170f79a1dce326ec77d5ce6398747100cd1229d1",
5
+ "revision": "sha256:ad4745a37643c80842d3a5a8fa9dd4a8cb13d12f61e35df972c9ef63097faddd",
6
6
  "localeMessages": {
7
7
  "CMD.approvedDocuments": {
8
8
  "key": "CMD.approvedDocuments",
@@ -69799,6 +69799,9 @@
69799
69799
  "triggerEdit": "trigger_edit",
69800
69800
  "useCustomHeight": "use_custom_height"
69801
69801
  },
69802
+ "absentRuntimeDefaults": {
69803
+ "labelPosition": "left"
69804
+ },
69802
69805
  "settings": [
69803
69806
  {
69804
69807
  "key": "subtable-datasource-bind",
@@ -1,2 +1,3 @@
1
1
  export * from './types';
2
2
  export * from './query';
3
+ export * from './control-tree';