amis-core 3.1.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/Root.js +1 -1
- package/esm/RootRenderer.d.ts +1 -1
- package/esm/RootRenderer.js +3 -3
- package/esm/SchemaRenderer.js +6 -2
- package/esm/Scoped.d.ts +4 -1
- package/esm/Scoped.js +9 -5
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.d.ts +4 -24
- package/esm/WithRootStore.js +12 -4
- package/esm/WithStore.js +23 -16
- package/esm/actions/Action.d.ts +1 -0
- package/esm/actions/Action.js +70 -45
- package/esm/actions/AjaxAction.d.ts +6 -8
- package/esm/actions/AjaxAction.js +20 -18
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.d.ts +1 -2
- package/esm/actions/CmptAction.js +47 -32
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +3 -2
- package/esm/actions/DialogAction.d.ts +2 -0
- package/esm/actions/DialogAction.js +39 -23
- package/esm/actions/DrawerAction.js +4 -4
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/LinkAction.js +1 -1
- package/esm/actions/LoopAction.js +1 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/StatusAction.d.ts +15 -0
- package/esm/actions/StatusAction.js +49 -0
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/actions/index.d.ts +1 -0
- package/esm/components/CustomStyle.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.js +3 -2
- package/esm/components/PopOver.js +3 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.js +2 -2
- package/esm/index.d.ts +3 -1
- package/esm/index.js +16 -14
- package/esm/locale.js +1 -1
- package/esm/polyfills.d.ts +3 -0
- package/esm/polyfills.js +18 -0
- package/esm/renderers/Form.d.ts +7 -7
- package/esm/renderers/Form.js +182 -128
- package/esm/renderers/Item.d.ts +82 -77
- package/esm/renderers/Item.js +90 -74
- package/esm/renderers/Options.js +1 -2
- package/esm/renderers/Placeholder.js +1 -1
- package/esm/renderers/builtin.js +1 -1
- package/esm/renderers/register.js +1 -1
- package/esm/renderers/wrapControl.d.ts +4 -24
- package/esm/renderers/wrapControl.js +140 -88
- package/esm/store/app.js +42 -4
- package/esm/store/combo.d.ts +564 -1892
- package/esm/store/combo.js +9 -2
- package/esm/store/crud.d.ts +4 -2
- package/esm/store/crud.js +17 -4
- package/esm/store/form.d.ts +182 -882
- package/esm/store/form.js +83 -81
- package/esm/store/formItem.d.ts +6 -2
- package/esm/store/formItem.js +19 -3
- package/esm/store/iRenderer.js +3 -2
- package/esm/store/index.js +1 -1
- package/esm/store/list.d.ts +1 -0
- package/esm/store/list.js +8 -2
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.js +1 -1
- package/esm/store/root.js +3 -2
- package/esm/store/service.js +17 -12
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +604 -2020
- package/esm/store/table.js +86 -56
- package/esm/store/table2.d.ts +49 -0
- package/esm/store/table2.js +37 -4
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +22 -5
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.d.ts +3 -2
- package/esm/utils/DataSchema.js +27 -7
- package/esm/utils/DataScope.d.ts +10 -3
- package/esm/utils/DataScope.js +50 -12
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.d.ts +2 -2
- package/esm/utils/api.js +152 -112
- package/esm/utils/arraySlice.d.ts +1 -0
- package/esm/utils/arraySlice.js +76 -0
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/dataMapping.js +29 -19
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.d.ts +2 -0
- package/esm/utils/debug.js +34 -7
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +4 -1
- package/esm/utils/errors.js +1 -1
- package/esm/utils/escapeHtml.js +1 -1
- package/esm/utils/filter-schema.js +1 -1
- package/esm/utils/filter.js +1 -1
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.d.ts +0 -1
- package/esm/utils/formula.js +6 -9
- package/esm/utils/getVariable.js +1 -1
- package/esm/utils/grammar.js +1 -1
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.d.ts +19 -2
- package/esm/utils/helper.js +69 -10
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.d.ts +4 -2
- package/esm/utils/icon.js +3 -2
- package/esm/utils/image.js +1 -1
- package/esm/utils/index.d.ts +2 -0
- package/esm/utils/isPureVariable.js +1 -1
- package/esm/utils/json-schema-2-amis-schema.js +1 -1
- package/esm/utils/keyToPath.js +1 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/math.d.ts +3 -0
- package/esm/utils/math.js +52 -0
- package/esm/utils/memoryParse.js +1 -1
- package/esm/utils/normalizeLink.js +18 -9
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.d.ts +7 -0
- package/esm/utils/object.js +13 -2
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +2 -2
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/renderer-event.d.ts +1 -1
- package/esm/utils/renderer-event.js +14 -6
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.js +1 -1
- package/esm/utils/resolveCondition.js +1 -1
- package/esm/utils/resolveVariable.js +1 -1
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/esm/utils/scrollPosition.js +1 -1
- package/esm/utils/string2regExp.js +1 -1
- package/esm/utils/stripNumber.js +1 -1
- package/esm/utils/style-helper.js +1 -1
- package/esm/utils/style.js +1 -1
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.js +1 -1
- package/esm/utils/tpl-lodash.js +1 -1
- package/esm/utils/tpl.js +1 -1
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validations.js +1 -1
- package/lib/Root.js +10 -7
- package/lib/RootRenderer.d.ts +1 -1
- package/lib/RootRenderer.js +11 -8
- package/lib/SchemaRenderer.js +13 -6
- package/lib/Scoped.d.ts +4 -1
- package/lib/Scoped.js +19 -13
- package/lib/StatusScoped.js +5 -2
- package/lib/WithRootStore.d.ts +4 -24
- package/lib/WithRootStore.js +15 -4
- package/lib/WithStore.js +27 -17
- package/lib/actions/Action.d.ts +1 -0
- package/lib/actions/Action.js +70 -45
- package/lib/actions/AjaxAction.d.ts +6 -8
- package/lib/actions/AjaxAction.js +20 -18
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.d.ts +1 -2
- package/lib/actions/CmptAction.js +47 -32
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +9 -5
- package/lib/actions/DialogAction.d.ts +2 -0
- package/lib/actions/DialogAction.js +39 -23
- package/lib/actions/DrawerAction.js +4 -4
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/LinkAction.js +1 -1
- package/lib/actions/LoopAction.js +1 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/StatusAction.d.ts +15 -0
- package/lib/actions/StatusAction.js +53 -0
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/actions/index.d.ts +1 -0
- package/lib/components/CustomStyle.js +1 -1
- package/lib/components/LazyComponent.js +12 -14
- package/lib/components/Overlay.js +15 -14
- package/lib/components/PopOver.js +12 -10
- package/lib/env.js +4 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.js +11 -9
- package/lib/index.d.ts +3 -1
- package/lib/index.js +26 -19
- package/lib/locale.js +6 -3
- package/lib/polyfills.d.ts +3 -0
- package/lib/polyfills.js +20 -0
- package/lib/renderers/Form.d.ts +7 -7
- package/lib/renderers/Form.js +194 -135
- package/lib/renderers/Item.d.ts +82 -77
- package/lib/renderers/Item.js +126 -104
- package/lib/renderers/Options.js +10 -5
- package/lib/renderers/Placeholder.js +1 -1
- package/lib/renderers/builtin.js +1 -1
- package/lib/renderers/register.js +1 -1
- package/lib/renderers/wrapControl.d.ts +4 -24
- package/lib/renderers/wrapControl.js +143 -88
- package/lib/store/app.js +44 -3
- package/lib/store/combo.d.ts +564 -1892
- package/lib/store/combo.js +9 -2
- package/lib/store/crud.d.ts +4 -2
- package/lib/store/crud.js +17 -4
- package/lib/store/form.d.ts +182 -882
- package/lib/store/form.js +81 -79
- package/lib/store/formItem.d.ts +6 -2
- package/lib/store/formItem.js +19 -3
- package/lib/store/iRenderer.js +9 -5
- package/lib/store/index.js +1 -1
- package/lib/store/list.d.ts +1 -0
- package/lib/store/list.js +8 -2
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.js +1 -1
- package/lib/store/root.js +9 -5
- package/lib/store/service.js +17 -12
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +604 -2020
- package/lib/store/table.js +85 -55
- package/lib/store/table2.d.ts +49 -0
- package/lib/store/table2.js +36 -3
- package/lib/theme.js +6 -3
- package/lib/types.d.ts +22 -5
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.d.ts +3 -2
- package/lib/utils/DataSchema.js +27 -7
- package/lib/utils/DataScope.d.ts +10 -3
- package/lib/utils/DataScope.js +50 -11
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.d.ts +2 -2
- package/lib/utils/api.js +151 -111
- package/lib/utils/arraySlice.d.ts +1 -0
- package/lib/utils/arraySlice.js +80 -0
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +8 -6
- package/lib/utils/dataMapping.js +29 -19
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.d.ts +2 -0
- package/lib/utils/debug.js +61 -33
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +10 -5
- package/lib/utils/errors.js +1 -1
- package/lib/utils/escapeHtml.js +1 -1
- package/lib/utils/filter-schema.js +1 -1
- package/lib/utils/filter.js +1 -1
- package/lib/utils/formatDuration.js +1 -1
- package/lib/utils/formula.d.ts +0 -1
- package/lib/utils/formula.js +6 -10
- package/lib/utils/getVariable.js +1 -1
- package/lib/utils/grammar.js +1 -1
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.d.ts +19 -2
- package/lib/utils/helper.js +70 -9
- package/lib/utils/highlight.js +8 -9
- package/lib/utils/icon.d.ts +4 -2
- package/lib/utils/icon.js +12 -10
- package/lib/utils/image.js +1 -1
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/isPureVariable.js +1 -1
- package/lib/utils/json-schema-2-amis-schema.js +1 -1
- package/lib/utils/keyToPath.js +1 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/math.d.ts +3 -0
- package/lib/utils/math.js +58 -0
- package/lib/utils/memoryParse.js +1 -1
- package/lib/utils/normalizeLink.js +18 -9
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.d.ts +7 -0
- package/lib/utils/object.js +13 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +7 -3
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/renderer-event.d.ts +1 -1
- package/lib/utils/renderer-event.js +13 -5
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.js +1 -1
- package/lib/utils/resolveCondition.js +1 -1
- package/lib/utils/resolveVariable.js +1 -1
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/lib/utils/scrollPosition.js +1 -1
- package/lib/utils/string2regExp.js +1 -1
- package/lib/utils/stripNumber.js +1 -1
- package/lib/utils/style-helper.js +1 -1
- package/lib/utils/style.js +1 -1
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.js +1 -1
- package/lib/utils/tpl-lodash.js +1 -1
- package/lib/utils/tpl.js +1 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validations.js +1 -1
- package/package.json +9 -4
package/lib/store/table.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -41,6 +41,7 @@ var Column = mobxStateTree.types
|
|
|
41
41
|
type: mobxStateTree.types.optional(mobxStateTree.types.string, 'plain'),
|
|
42
42
|
name: mobxStateTree.types.maybe(mobxStateTree.types.string),
|
|
43
43
|
value: mobxStateTree.types.frozen(),
|
|
44
|
+
id: '',
|
|
44
45
|
groupName: '',
|
|
45
46
|
toggled: false,
|
|
46
47
|
toggable: true,
|
|
@@ -54,6 +55,8 @@ var Column = mobxStateTree.types
|
|
|
54
55
|
fixed: '',
|
|
55
56
|
index: 0,
|
|
56
57
|
rawIndex: 0,
|
|
58
|
+
width: 0,
|
|
59
|
+
minWidth: 0,
|
|
57
60
|
breakpoint: mobxStateTree.types.optional(mobxStateTree.types.frozen(), undefined),
|
|
58
61
|
pristine: mobxStateTree.types.optional(mobxStateTree.types.frozen(), undefined),
|
|
59
62
|
remark: mobxStateTree.types.optional(mobxStateTree.types.frozen(), undefined),
|
|
@@ -76,6 +79,12 @@ var Column = mobxStateTree.types
|
|
|
76
79
|
self.enableSearch = value;
|
|
77
80
|
var table = mobxStateTree.getParent(self, 2);
|
|
78
81
|
table.persistSaveToggledColumns();
|
|
82
|
+
},
|
|
83
|
+
setWidth: function (value, minWidth) {
|
|
84
|
+
self.width = value;
|
|
85
|
+
if (typeof minWidth === 'number') {
|
|
86
|
+
self.minWidth = minWidth;
|
|
87
|
+
}
|
|
79
88
|
}
|
|
80
89
|
}); });
|
|
81
90
|
var Row = mobxStateTree.types
|
|
@@ -268,6 +277,7 @@ var TableStore = iRenderer.iRendererStore
|
|
|
268
277
|
formsRef: mobxStateTree.types.optional(mobxStateTree.types.array(mobxStateTree.types.frozen()), []),
|
|
269
278
|
maxKeepItemSelectionLength: Infinity,
|
|
270
279
|
keepItemSelectionOnPageChange: false,
|
|
280
|
+
useFixedLayout: false,
|
|
271
281
|
// 导出 Excel 按钮的 loading 状态
|
|
272
282
|
exportExcelLoading: false,
|
|
273
283
|
searchFormExpanded: false // 用来控制搜索框是否展开了,那个自动根据 searchable 生成的表单 autoGenerateFilter
|
|
@@ -325,23 +335,6 @@ var TableStore = iRenderer.iRendererStore
|
|
|
325
335
|
helper.isBreakpoint(item.breakpoint);
|
|
326
336
|
});
|
|
327
337
|
}
|
|
328
|
-
function getLeftFixedColumns() {
|
|
329
|
-
if (self.dragging) {
|
|
330
|
-
return [];
|
|
331
|
-
}
|
|
332
|
-
var columns = getFilteredColumns().filter(function (item) { return item.fixed === 'left'; });
|
|
333
|
-
// 有才带过去,没有就不带了
|
|
334
|
-
if (columns.length) {
|
|
335
|
-
columns = getFilteredColumns().filter(function (item) { return item.fixed === 'left' || /^__/.test(item.type); });
|
|
336
|
-
}
|
|
337
|
-
return columns;
|
|
338
|
-
}
|
|
339
|
-
function getRightFixedColumns() {
|
|
340
|
-
if (self.dragging) {
|
|
341
|
-
return [];
|
|
342
|
-
}
|
|
343
|
-
return getFilteredColumns().filter(function (item) { return item.fixed === 'right'; });
|
|
344
|
-
}
|
|
345
338
|
function isSelected(row) {
|
|
346
339
|
return !!~self.selectedRows.indexOf(row);
|
|
347
340
|
}
|
|
@@ -453,7 +446,11 @@ var TableStore = iRenderer.iRendererStore
|
|
|
453
446
|
(item.has.length === 1 && item.label === item.has[0].label)
|
|
454
447
|
? 2
|
|
455
448
|
: 1;
|
|
456
|
-
return tslib.__assign(tslib.__assign({}, item), { rowSpan: rowSpan, label: rowSpan === 2 ? item.label || item.has[0].label : item.label })
|
|
449
|
+
return tslib.__assign(tslib.__assign({}, item), { rowSpan: rowSpan, label: rowSpan === 2 ? item.label || item.has[0].label : item.label, fixed: item.has.every(function (column) { return column.fixed; })
|
|
450
|
+
? item.has[0].fixed
|
|
451
|
+
: undefined, get width() {
|
|
452
|
+
return item.has.reduce(function (a, b) { return a + b.width; }, 0);
|
|
453
|
+
} });
|
|
457
454
|
});
|
|
458
455
|
}
|
|
459
456
|
function getFirstToggledColumnIndex() {
|
|
@@ -486,12 +483,6 @@ var TableStore = iRenderer.iRendererStore
|
|
|
486
483
|
get footableColumns() {
|
|
487
484
|
return getFootableColumns();
|
|
488
485
|
},
|
|
489
|
-
get leftFixedColumns() {
|
|
490
|
-
return getLeftFixedColumns();
|
|
491
|
-
},
|
|
492
|
-
get rightFixedColumns() {
|
|
493
|
-
return getRightFixedColumns();
|
|
494
|
-
},
|
|
495
486
|
get toggableColumns() {
|
|
496
487
|
return getToggableColumns();
|
|
497
488
|
},
|
|
@@ -576,6 +567,55 @@ var TableStore = iRenderer.iRendererStore
|
|
|
576
567
|
}
|
|
577
568
|
});
|
|
578
569
|
return list;
|
|
570
|
+
},
|
|
571
|
+
get columnWidthReady() {
|
|
572
|
+
return getFilteredColumns().every(function (column) { return column.width; });
|
|
573
|
+
},
|
|
574
|
+
getStickyStyles: function (column, columns) {
|
|
575
|
+
var stickyClassName = '';
|
|
576
|
+
var style = {};
|
|
577
|
+
var autoFixLeftColumns = ['__checkme', '__dragme', '__expandme'];
|
|
578
|
+
if (column.fixed === 'left' ||
|
|
579
|
+
autoFixLeftColumns.includes(column.type)) {
|
|
580
|
+
stickyClassName = 'is-sticky is-sticky-left';
|
|
581
|
+
var index = columns.indexOf(column) - 1;
|
|
582
|
+
if (columns
|
|
583
|
+
.slice(index + 2)
|
|
584
|
+
.every(function (col) {
|
|
585
|
+
return !((col && col.fixed === 'left') ||
|
|
586
|
+
autoFixLeftColumns.includes(col.type));
|
|
587
|
+
})) {
|
|
588
|
+
stickyClassName += ' is-sticky-last-left';
|
|
589
|
+
}
|
|
590
|
+
var left = 0;
|
|
591
|
+
while (index >= 0) {
|
|
592
|
+
var col = columns[index];
|
|
593
|
+
if ((col && col.fixed === 'left') ||
|
|
594
|
+
autoFixLeftColumns.includes(col.type)) {
|
|
595
|
+
left += col.width;
|
|
596
|
+
}
|
|
597
|
+
index--;
|
|
598
|
+
}
|
|
599
|
+
style.left = left;
|
|
600
|
+
}
|
|
601
|
+
else if (column.fixed === 'right') {
|
|
602
|
+
stickyClassName = 'is-sticky is-sticky-right';
|
|
603
|
+
var right = 0;
|
|
604
|
+
var index = columns.indexOf(column) + 1;
|
|
605
|
+
if (columns.slice(0, index - 1).every(function (col) { return col.fixed !== 'right'; })) {
|
|
606
|
+
stickyClassName += ' is-sticky-first-right';
|
|
607
|
+
}
|
|
608
|
+
var len = columns.length;
|
|
609
|
+
while (index < len) {
|
|
610
|
+
var col = columns[index];
|
|
611
|
+
if (col && col.fixed === 'right') {
|
|
612
|
+
right += col.width;
|
|
613
|
+
}
|
|
614
|
+
index++;
|
|
615
|
+
}
|
|
616
|
+
style.right = right;
|
|
617
|
+
}
|
|
618
|
+
return [style, stickyClassName];
|
|
579
619
|
}
|
|
580
620
|
};
|
|
581
621
|
})
|
|
@@ -616,12 +656,6 @@ var TableStore = iRenderer.iRendererStore
|
|
|
616
656
|
var columns = config.columns
|
|
617
657
|
.filter(function (column) { return column; })
|
|
618
658
|
.concat();
|
|
619
|
-
if (!columns.length) {
|
|
620
|
-
columns.push({
|
|
621
|
-
type: 'text',
|
|
622
|
-
label: '空'
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
659
|
// 更新列顺序,afterCreate生命周期中更新columns不会触发组件的render
|
|
626
660
|
var key = getPersistDataKey(columns);
|
|
627
661
|
var data = localStorage.getItem(key);
|
|
@@ -638,28 +672,10 @@ var TableStore = iRenderer.iRendererStore
|
|
|
638
672
|
});
|
|
639
673
|
}
|
|
640
674
|
}
|
|
641
|
-
columns
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
});
|
|
646
|
-
columns.unshift({
|
|
647
|
-
type: '__checkme',
|
|
648
|
-
fixed: 'left',
|
|
649
|
-
toggable: false,
|
|
650
|
-
className: 'Table-checkCell'
|
|
651
|
-
});
|
|
652
|
-
columns.unshift({
|
|
653
|
-
type: '__dragme',
|
|
654
|
-
toggable: false,
|
|
655
|
-
className: 'Table-dragCell'
|
|
656
|
-
});
|
|
657
|
-
columns = columns.map(function (item, index) { return (tslib.__assign(tslib.__assign({}, item), { index: index, rawIndex: index - PARTITION_INDEX, type: item.type || 'plain', pristine: item, toggled: item.toggled !== false, breakpoint: item.breakpoint, isPrimary: index === PARTITION_INDEX, className: item.className || '',
|
|
658
|
-
/** 提前映射变量,方便后续view中使用 */
|
|
659
|
-
label: isPureVariable.isPureVariable(item.label)
|
|
660
|
-
? resolveVariableAndFilter.resolveVariableAndFilter(item.label, self.data)
|
|
661
|
-
: item.label })); });
|
|
662
|
-
self.columns.replace(columns);
|
|
675
|
+
updateColumns(columns);
|
|
676
|
+
}
|
|
677
|
+
if (config.tableLayout === 'fixed') {
|
|
678
|
+
self.useFixedLayout = true;
|
|
663
679
|
}
|
|
664
680
|
}
|
|
665
681
|
function updateColumns(columns) {
|
|
@@ -687,15 +703,18 @@ var TableStore = iRenderer.iRendererStore
|
|
|
687
703
|
toggable: false,
|
|
688
704
|
className: 'Table-dragCell'
|
|
689
705
|
});
|
|
690
|
-
columns = columns.map(function (item, index) { return (tslib.__assign(tslib.__assign({}, item), { index: index, rawIndex: index - PARTITION_INDEX, type: item.type || 'plain', pristine: item.pristine || item, toggled: item.toggled !== false, breakpoint: item.breakpoint, isPrimary: index === PARTITION_INDEX,
|
|
706
|
+
columns = columns.map(function (item, index) { return (tslib.__assign(tslib.__assign({}, item), { id: helper.guid(), index: index, width: 0, minWidth: 0, rawIndex: index - PARTITION_INDEX, type: item.type || 'plain', pristine: item.pristine || item, toggled: item.toggled !== false, breakpoint: item.breakpoint, isPrimary: index === PARTITION_INDEX,
|
|
691
707
|
/** 提前映射变量,方便后续view中使用 */
|
|
692
708
|
label: isPureVariable.isPureVariable(item.label)
|
|
693
709
|
? resolveVariableAndFilter.resolveVariableAndFilter(item.label, self.data)
|
|
694
710
|
: item.label })); });
|
|
695
711
|
self.columns.replace(columns);
|
|
696
|
-
|
|
712
|
+
self.useFixedLayout = self.columns.some(function (column) { return column.pristine.width; });
|
|
697
713
|
}
|
|
698
714
|
}
|
|
715
|
+
function invalidTableColumnWidth() {
|
|
716
|
+
self.columns.forEach(function (column) { return column.setWidth(0); });
|
|
717
|
+
}
|
|
699
718
|
function combineCell(arr, keys) {
|
|
700
719
|
if (!keys.length || !arr.length) {
|
|
701
720
|
return arr;
|
|
@@ -838,6 +857,7 @@ var TableStore = iRenderer.iRendererStore
|
|
|
838
857
|
self.expandedRows.replace(getExpandAllRows(self.rows));
|
|
839
858
|
}
|
|
840
859
|
self.dragging = false;
|
|
860
|
+
invalidTableColumnWidth(); // 更新内容需要重新计算表格布局
|
|
841
861
|
}
|
|
842
862
|
// 获取所有层级的子节点id
|
|
843
863
|
function getExpandAllRows(arr) {
|
|
@@ -1032,6 +1052,11 @@ var TableStore = iRenderer.iRendererStore
|
|
|
1032
1052
|
self.orderBy = key;
|
|
1033
1053
|
self.orderDir = key ? direction : '';
|
|
1034
1054
|
}
|
|
1055
|
+
function changeOrder(key, direction) {
|
|
1056
|
+
setOrderByInfo(key, direction);
|
|
1057
|
+
var dir = /desc/i.test(self.orderDir) ? -1 : 1;
|
|
1058
|
+
self.rows.replace(helper.sortArray(self.rows.concat(), self.orderBy, dir, function (item, field) { return item.data[field]; }));
|
|
1059
|
+
}
|
|
1035
1060
|
function reset() {
|
|
1036
1061
|
self.rows.forEach(function (item) { return item.reset(); });
|
|
1037
1062
|
var rows = self.rows.concat();
|
|
@@ -1137,6 +1162,7 @@ var TableStore = iRenderer.iRendererStore
|
|
|
1137
1162
|
return {
|
|
1138
1163
|
update: update,
|
|
1139
1164
|
updateColumns: updateColumns,
|
|
1165
|
+
invalidTableColumnWidth: invalidTableColumnWidth,
|
|
1140
1166
|
initRows: initRows,
|
|
1141
1167
|
updateSelected: updateSelected,
|
|
1142
1168
|
toggleAll: toggleAll,
|
|
@@ -1148,6 +1174,7 @@ var TableStore = iRenderer.iRendererStore
|
|
|
1148
1174
|
collapseAllAtDepth: collapseAllAtDepth,
|
|
1149
1175
|
clear: clear,
|
|
1150
1176
|
setOrderByInfo: setOrderByInfo,
|
|
1177
|
+
changeOrder: changeOrder,
|
|
1151
1178
|
reset: reset,
|
|
1152
1179
|
toggleDragging: toggleDragging,
|
|
1153
1180
|
stopDragging: stopDragging,
|
|
@@ -1158,6 +1185,9 @@ var TableStore = iRenderer.iRendererStore
|
|
|
1158
1185
|
persistSaveToggledColumns: persistSaveToggledColumns,
|
|
1159
1186
|
setSearchFormExpanded: setSearchFormExpanded,
|
|
1160
1187
|
toggleSearchFormExpanded: toggleSearchFormExpanded,
|
|
1188
|
+
setUseFixedLayout: function (value) {
|
|
1189
|
+
self.useFixedLayout = !!value;
|
|
1190
|
+
},
|
|
1161
1191
|
// events
|
|
1162
1192
|
afterCreate: function () {
|
|
1163
1193
|
setTimeout(function () {
|
package/lib/store/table2.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Instance, SnapshotIn, IAnyModelType } from 'mobx-state-tree';
|
|
2
2
|
import { Api, fetchOptions } from '../types';
|
|
3
|
+
import { IFormStore } from './form';
|
|
3
4
|
export declare const Column: import("mobx-state-tree").IModelType<{
|
|
4
5
|
title: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
5
6
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
@@ -140,6 +141,7 @@ export declare const TableStore2: import("mobx-state-tree").IModelType<{
|
|
|
140
141
|
pageSize: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
141
142
|
dragging: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
142
143
|
rowSelectionKeyField: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
144
|
+
formsRef: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<any, any, any>>, [undefined]>;
|
|
143
145
|
}, {
|
|
144
146
|
readonly parentStore: any;
|
|
145
147
|
readonly __: any;
|
|
@@ -458,6 +460,52 @@ export declare const TableStore2: import("mobx-state-tree").IModelType<{
|
|
|
458
460
|
reset(): void;
|
|
459
461
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>))[];
|
|
460
462
|
readonly keyField: string;
|
|
463
|
+
readonly modified: number;
|
|
464
|
+
readonly modifiedRows: ({
|
|
465
|
+
storeType: string;
|
|
466
|
+
id: string;
|
|
467
|
+
parentId: string;
|
|
468
|
+
name: string;
|
|
469
|
+
pristine: any;
|
|
470
|
+
data: any;
|
|
471
|
+
index: number;
|
|
472
|
+
newIndex: number;
|
|
473
|
+
depth: number;
|
|
474
|
+
children: import("mobx-state-tree").IMSTArray<IAnyModelType> & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<IAnyModelType>, [undefined]>>;
|
|
475
|
+
path: string;
|
|
476
|
+
} & import("mobx-state-tree/dist/internal").NonEmptyObject & {
|
|
477
|
+
readonly checked: boolean;
|
|
478
|
+
readonly modified: boolean;
|
|
479
|
+
readonly moved: boolean;
|
|
480
|
+
readonly locals: any;
|
|
481
|
+
getDataWithModifiedChilden(): any;
|
|
482
|
+
} & {
|
|
483
|
+
replaceWith(data: any): void;
|
|
484
|
+
change(values: object, savePristine?: boolean): void;
|
|
485
|
+
reset(): void;
|
|
486
|
+
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
487
|
+
storeType: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
488
|
+
id: import("mobx-state-tree").ISimpleType<string>;
|
|
489
|
+
parentId: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
490
|
+
name: import("mobx-state-tree").ISimpleType<string>;
|
|
491
|
+
pristine: import("mobx-state-tree").IType<any, any, any>;
|
|
492
|
+
data: import("mobx-state-tree").IType<any, any, any>;
|
|
493
|
+
index: import("mobx-state-tree").ISimpleType<number>;
|
|
494
|
+
newIndex: import("mobx-state-tree").ISimpleType<number>;
|
|
495
|
+
depth: import("mobx-state-tree").ISimpleType<number>;
|
|
496
|
+
children: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<IAnyModelType>, [undefined]>;
|
|
497
|
+
path: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
498
|
+
}, {
|
|
499
|
+
readonly checked: boolean;
|
|
500
|
+
readonly modified: boolean;
|
|
501
|
+
readonly moved: boolean;
|
|
502
|
+
readonly locals: any;
|
|
503
|
+
getDataWithModifiedChilden(): any;
|
|
504
|
+
} & {
|
|
505
|
+
replaceWith(data: any): void;
|
|
506
|
+
change(values: object, savePristine?: boolean): void;
|
|
507
|
+
reset(): void;
|
|
508
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>)[];
|
|
461
509
|
} & {
|
|
462
510
|
update: (config: Partial<STableStore2>) => void;
|
|
463
511
|
persistSaveToggledColumns: () => void;
|
|
@@ -472,6 +520,7 @@ export declare const TableStore2: import("mobx-state-tree").IModelType<{
|
|
|
472
520
|
toggleAllColumns: () => void;
|
|
473
521
|
afterCreate(): void;
|
|
474
522
|
saveRemote: (api: Api, data?: object, options?: fetchOptions) => Promise<any>;
|
|
523
|
+
addForm: (form: IFormStore, rowIndex: number) => void;
|
|
475
524
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
476
525
|
export type ITableStore2 = Instance<typeof TableStore2>;
|
|
477
526
|
export type STableStore2 = SnapshotIn<typeof TableStore2>;
|
package/lib/store/table2.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -158,7 +158,8 @@ var TableStore2 = service.ServiceStore.named('TableStore2')
|
|
|
158
158
|
pageNo: 1,
|
|
159
159
|
pageSize: 10,
|
|
160
160
|
dragging: false,
|
|
161
|
-
rowSelectionKeyField: 'id'
|
|
161
|
+
rowSelectionKeyField: 'id',
|
|
162
|
+
formsRef: mobxStateTree.types.optional(mobxStateTree.types.array(mobxStateTree.types.frozen()), [])
|
|
162
163
|
})
|
|
163
164
|
.views(function (self) {
|
|
164
165
|
function getToggable() {
|
|
@@ -219,6 +220,25 @@ var TableStore2 = service.ServiceStore.named('TableStore2')
|
|
|
219
220
|
function getMoved() {
|
|
220
221
|
return getMovedRows().length;
|
|
221
222
|
}
|
|
223
|
+
function getModifiedRows(rows, modifiedRows) {
|
|
224
|
+
if (rows === void 0) { rows = []; }
|
|
225
|
+
if (modifiedRows === void 0) { modifiedRows = []; }
|
|
226
|
+
rows = rows && rows.length ? rows : self.rows;
|
|
227
|
+
rows.forEach(function (item) {
|
|
228
|
+
if (item.children && item.children.length) {
|
|
229
|
+
getModifiedRows(item.children, modifiedRows);
|
|
230
|
+
}
|
|
231
|
+
var diff = helper.difference(item.data, item.pristine);
|
|
232
|
+
var hasDifference = Object.keys(diff).length;
|
|
233
|
+
if (hasDifference) {
|
|
234
|
+
modifiedRows.push(item);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
return modifiedRows;
|
|
238
|
+
}
|
|
239
|
+
function getModified() {
|
|
240
|
+
return getModifiedRows().length;
|
|
241
|
+
}
|
|
222
242
|
return {
|
|
223
243
|
get toggable() {
|
|
224
244
|
return getToggable();
|
|
@@ -268,6 +288,12 @@ var TableStore2 = service.ServiceStore.named('TableStore2')
|
|
|
268
288
|
},
|
|
269
289
|
get keyField() {
|
|
270
290
|
return self.rowSelectionKeyField;
|
|
291
|
+
},
|
|
292
|
+
get modified() {
|
|
293
|
+
return getModified();
|
|
294
|
+
},
|
|
295
|
+
get modifiedRows() {
|
|
296
|
+
return getModifiedRows();
|
|
271
297
|
}
|
|
272
298
|
};
|
|
273
299
|
})
|
|
@@ -536,6 +562,12 @@ var TableStore2 = service.ServiceStore.named('TableStore2')
|
|
|
536
562
|
self.rows.replace(rows);
|
|
537
563
|
self.dragging = false;
|
|
538
564
|
}
|
|
565
|
+
function addForm(form, rowIndex) {
|
|
566
|
+
self.formsRef.push({
|
|
567
|
+
id: form.id,
|
|
568
|
+
rowIndex: rowIndex
|
|
569
|
+
});
|
|
570
|
+
}
|
|
539
571
|
return {
|
|
540
572
|
update: update,
|
|
541
573
|
persistSaveToggledColumns: persistSaveToggledColumns,
|
|
@@ -566,7 +598,8 @@ var TableStore2 = service.ServiceStore.named('TableStore2')
|
|
|
566
598
|
}
|
|
567
599
|
}, 200);
|
|
568
600
|
},
|
|
569
|
-
saveRemote: saveRemote
|
|
601
|
+
saveRemote: saveRemote,
|
|
602
|
+
addForm: addForm
|
|
570
603
|
};
|
|
571
604
|
});
|
|
572
605
|
|
package/lib/theme.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -18,6 +18,9 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
18
18
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
19
19
|
var hoistNonReactStatic__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatic);
|
|
20
20
|
|
|
21
|
+
var __react_jsx__ = require('react');
|
|
22
|
+
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
|
|
23
|
+
(__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
21
24
|
var themes = {
|
|
22
25
|
default: {},
|
|
23
26
|
cxd: {
|
|
@@ -122,8 +125,8 @@ function themeable(ComposedComponent) {
|
|
|
122
125
|
var refConfig = ((_a = ComposedComponent.prototype) === null || _a === void 0 ? void 0 : _a.isReactComponent)
|
|
123
126
|
? { ref: this.childRef }
|
|
124
127
|
: { forwardedRef: this.childRef };
|
|
125
|
-
var body = (
|
|
126
|
-
return this.context ? (body) : (
|
|
128
|
+
var body = (_J$X_(ComposedComponent, tslib.__assign({}, config.getComponentConfig(ComposedComponent.themeKey), this.props, injectedProps, refConfig)));
|
|
129
|
+
return this.context ? (body) : (_J$X_(ThemeContext.Provider, { value: theme }, body));
|
|
127
130
|
};
|
|
128
131
|
return class_1;
|
|
129
132
|
}(React__default["default"].Component)),
|
package/lib/types.d.ts
CHANGED
|
@@ -137,7 +137,7 @@ export interface BaseApiObject {
|
|
|
137
137
|
autoRefresh?: boolean;
|
|
138
138
|
/**
|
|
139
139
|
* 当开启自动刷新的时候,默认是 api 的 url 来自动跟踪变量变化的。
|
|
140
|
-
* 如果你希望监控 url 外的变量,请配置
|
|
140
|
+
* 如果你希望监控 url 外的变量,请配置 trackExpression。
|
|
141
141
|
*/
|
|
142
142
|
trackExpression?: string;
|
|
143
143
|
/**
|
|
@@ -183,8 +183,9 @@ export interface ApiObject extends BaseApiObject {
|
|
|
183
183
|
operationName?: string;
|
|
184
184
|
body?: PlainObject;
|
|
185
185
|
query?: PlainObject;
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
mockResponse?: PlainObject;
|
|
187
|
+
adaptor?: (payload: object, response: fetcherResult, api: ApiObject, context: any) => any;
|
|
188
|
+
requestAdaptor?: (api: ApiObject, context: any) => ApiObject | Promise<ApiObject>;
|
|
188
189
|
/** 是否过滤为空字符串的 query 参数 */
|
|
189
190
|
filterEmptyQuery?: boolean;
|
|
190
191
|
}
|
|
@@ -211,7 +212,7 @@ export interface fetchOptions {
|
|
|
211
212
|
errorMessage?: string;
|
|
212
213
|
autoAppend?: boolean;
|
|
213
214
|
beforeSend?: (data: any) => any;
|
|
214
|
-
onSuccess?: (json: Payload) => any;
|
|
215
|
+
onSuccess?: (json: Payload, data: any) => any;
|
|
215
216
|
onFailed?: (json: Payload) => any;
|
|
216
217
|
silent?: boolean;
|
|
217
218
|
[propName: string]: any;
|
|
@@ -300,7 +301,10 @@ type RendererDataAlias = RendererData;
|
|
|
300
301
|
export type FunctionPropertyNames<T> = {
|
|
301
302
|
[K in keyof T]: T[K] extends Function ? K : never;
|
|
302
303
|
}[keyof T];
|
|
303
|
-
export type JSONSchema = JSONSchema7
|
|
304
|
+
export type JSONSchema = JSONSchema7 & {
|
|
305
|
+
group?: string;
|
|
306
|
+
typeLabel?: string;
|
|
307
|
+
};
|
|
304
308
|
/**
|
|
305
309
|
* 事件跟踪的定义
|
|
306
310
|
*/
|
|
@@ -494,6 +498,19 @@ export interface BaseSchemaWithoutType {
|
|
|
494
498
|
style?: {
|
|
495
499
|
[propName: string]: any;
|
|
496
500
|
};
|
|
501
|
+
/**
|
|
502
|
+
* 编辑器配置,运行时可以忽略
|
|
503
|
+
*/
|
|
504
|
+
editorSetting?: {
|
|
505
|
+
/**
|
|
506
|
+
* 组件名称,通常是业务名称方便定位
|
|
507
|
+
*/
|
|
508
|
+
displayName?: string;
|
|
509
|
+
/**
|
|
510
|
+
* 编辑器假数据,方便展示
|
|
511
|
+
*/
|
|
512
|
+
mock?: any;
|
|
513
|
+
};
|
|
497
514
|
}
|
|
498
515
|
export type OperatorType = 'equal' | 'not_equal' | 'is_empty' | 'is_not_empty' | 'like' | 'not_like' | 'starts_with' | 'ends_with' | 'less' | 'less_or_equal' | 'greater' | 'greater_or_equal' | 'between' | 'not_between' | 'select_equals' | 'select_not_equals' | 'select_any_in' | 'select_not_any_in' | {
|
|
499
516
|
label: string;
|
package/lib/utils/Animation.js
CHANGED
package/lib/utils/ColorScale.js
CHANGED
|
@@ -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():
|
|
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):
|
|
25
|
+
getSchemaByPath(path: string): JSONSchema | null;
|
|
25
26
|
}
|
package/lib/utils/DataSchema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -83,18 +83,38 @@ var DataSchema = /** @class */ (function () {
|
|
|
83
83
|
this.current = scope;
|
|
84
84
|
return this;
|
|
85
85
|
};
|
|
86
|
+
DataSchema.prototype.pushVariable = function (current, variables) {
|
|
87
|
+
if (current.tag) {
|
|
88
|
+
variables.push({
|
|
89
|
+
label: current.tag,
|
|
90
|
+
children: current.getDataPropsAsOptions()
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
variables.push.apply(variables, tslib.__spreadArray([], tslib.__read(current.getDataPropsAsOptions()), false));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
86
97
|
DataSchema.prototype.getDataPropsAsOptions = function () {
|
|
98
|
+
var _a;
|
|
87
99
|
var variables = [];
|
|
88
100
|
var current = this.current;
|
|
89
101
|
while (current) {
|
|
90
|
-
if (current.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
102
|
+
if (current.group) {
|
|
103
|
+
var subVars = [];
|
|
104
|
+
this.pushVariable(current, subVars);
|
|
105
|
+
var index = variables.findIndex(function (item) { return item.label === (current === null || current === void 0 ? void 0 : current.group); });
|
|
106
|
+
if (~index) {
|
|
107
|
+
(_a = variables[index].children).push.apply(_a, tslib.__spreadArray([], tslib.__read(subVars), false));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
variables.push({
|
|
111
|
+
label: current.group,
|
|
112
|
+
children: subVars
|
|
113
|
+
});
|
|
114
|
+
}
|
|
95
115
|
}
|
|
96
116
|
else {
|
|
97
|
-
|
|
117
|
+
this.pushVariable(current, variables);
|
|
98
118
|
}
|
|
99
119
|
current = current.parent;
|
|
100
120
|
}
|
package/lib/utils/DataScope.d.ts
CHANGED
|
@@ -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?:
|
|
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):
|
|
23
|
-
getSchemaById(id: string):
|
|
29
|
+
getSchemaByPath(path: string): JSONSchema | null;
|
|
30
|
+
getSchemaById(id: string): JSONSchema | undefined;
|
|
24
31
|
}
|