amis-core 6.8.0 → 6.9.0-rc.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 +24 -2
- package/esm/SchemaRenderer.js +29 -15
- package/esm/Scoped.js +1 -1
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +1 -1
- package/esm/actions/Action.js +1 -1
- package/esm/actions/AjaxAction.js +1 -1
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +1 -1
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +1 -1
- package/esm/actions/DialogAction.js +1 -1
- package/esm/actions/DrawerAction.js +1 -1
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/EventAction.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/PrintAction.js +1 -1
- package/esm/actions/StatusAction.js +1 -1
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/actions/WaitAction.js +1 -1
- package/esm/components/CustomStyle.js +1 -1
- package/esm/components/ErrorBoundary.js +1 -1
- package/esm/components/LazyComponent.d.ts +40 -2
- package/esm/components/LazyComponent.js +13 -7
- package/esm/components/Overlay.js +1 -1
- package/esm/components/PopOver.d.ts +1 -1
- package/esm/components/PopOver.js +1 -1
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.d.ts +13 -2
- package/esm/factory.js +157 -45
- package/esm/index.d.ts +4 -4
- package/esm/index.js +5 -5
- package/esm/locale.js +1 -1
- package/esm/polyfills.js +1 -1
- package/esm/renderers/Form.js +3 -3
- package/esm/renderers/Item.js +6 -6
- package/esm/renderers/Options.d.ts +3 -3
- package/esm/renderers/Options.js +42 -19
- 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.js +1 -1
- package/esm/store/app.js +1 -1
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.js +1 -1
- package/esm/store/form.js +1 -1
- package/esm/store/formItem.js +1 -1
- package/esm/store/iRenderer.js +1 -1
- package/esm/store/index.d.ts +1 -0
- package/esm/store/index.js +3 -2
- package/esm/store/list.js +1 -1
- 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.d.ts +2 -0
- package/esm/store/root.js +45 -21
- package/esm/store/service.js +1 -1
- package/esm/store/status.js +1 -1
- package/esm/store/table.js +1 -1
- package/esm/store/table2.js +1 -1
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +4 -2
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.js +1 -1
- package/esm/utils/DataScope.js +1 -1
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.d.ts +21 -1
- package/esm/utils/api.js +133 -41
- package/esm/utils/arraySlice.js +1 -1
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/browser.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/concatData.js +1 -1
- package/esm/utils/dataMapping.js +1 -1
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.js +1 -1
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +1 -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.js +1 -1
- 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.js +1 -1
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.js +1 -1
- package/esm/utils/image.js +1 -1
- 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/labelToString.js +1 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/math.js +1 -1
- package/esm/utils/memoryParse.js +1 -1
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.js +1 -1
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +1 -1
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/printElement.js +1 -1
- package/esm/utils/renderer-event.js +1 -1
- 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/validateId.js +1 -1
- package/esm/utils/validations.js +1 -1
- package/esm/utils/visitedCache.js +1 -1
- package/lib/Root.js +1 -1
- package/lib/RootRenderer.js +23 -1
- package/lib/SchemaRenderer.js +27 -13
- package/lib/Scoped.js +1 -1
- package/lib/StatusScoped.js +1 -1
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +1 -1
- package/lib/actions/Action.js +1 -1
- package/lib/actions/AjaxAction.js +1 -1
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +1 -1
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +1 -1
- package/lib/actions/DialogAction.js +1 -1
- package/lib/actions/DrawerAction.js +1 -1
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/EventAction.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/PrintAction.js +1 -1
- package/lib/actions/StatusAction.js +1 -1
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/actions/WaitAction.js +1 -1
- package/lib/components/CustomStyle.js +1 -1
- package/lib/components/ErrorBoundary.js +1 -1
- package/lib/components/LazyComponent.d.ts +40 -2
- package/lib/components/LazyComponent.js +14 -7
- package/lib/components/Overlay.js +1 -1
- package/lib/components/PopOver.d.ts +1 -1
- package/lib/components/PopOver.js +1 -1
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.d.ts +13 -2
- package/lib/factory.js +161 -44
- package/lib/index.d.ts +4 -4
- package/lib/index.js +10 -2
- package/lib/locale.js +1 -1
- package/lib/polyfills.js +1 -1
- package/lib/renderers/Form.js +1 -1
- package/lib/renderers/Item.js +6 -6
- package/lib/renderers/Options.d.ts +3 -3
- package/lib/renderers/Options.js +42 -19
- 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.js +1 -1
- package/lib/store/app.js +1 -1
- package/lib/store/combo.d.ts +24 -25
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.js +2 -2
- package/lib/store/form.d.ts +10 -11
- package/lib/store/form.js +1 -1
- package/lib/store/formItem.js +1 -1
- package/lib/store/iRenderer.js +1 -1
- package/lib/store/index.d.ts +1 -0
- package/lib/store/index.js +3 -1
- package/lib/store/list.js +1 -1
- 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.d.ts +2 -0
- package/lib/store/root.js +43 -19
- package/lib/store/service.js +1 -1
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +20 -21
- package/lib/store/table.js +1 -1
- package/lib/store/table2.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/types.d.ts +4 -2
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.js +1 -1
- package/lib/utils/DataScope.js +1 -1
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.d.ts +21 -1
- package/lib/utils/api.js +136 -40
- package/lib/utils/arraySlice.js +1 -1
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/browser.js +1 -1
- package/lib/utils/columnsSplit.js +1 -1
- package/lib/utils/concatData.js +1 -1
- package/lib/utils/dataMapping.js +1 -1
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.js +2 -2
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- package/lib/utils/highlight.js +1 -1
- package/lib/utils/icon.js +1 -1
- package/lib/utils/image.js +1 -1
- 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/labelToString.js +1 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/math.js +1 -1
- package/lib/utils/memoryParse.js +1 -1
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.js +1 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +1 -1
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/printElement.js +1 -1
- package/lib/utils/renderer-event.js +1 -1
- 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/validateId.js +1 -1
- package/lib/utils/validations.js +1 -1
- package/lib/utils/visitedCache.js +1 -1
- package/package.json +2 -2
package/esm/factory.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
2
|
+
* amis-core v6.9.0-rc.0
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __assign } from 'tslib';
|
|
6
|
+
import { __assign, __awaiter, __generator } from 'tslib';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { RendererStore } from './store/index.js';
|
|
9
9
|
import { destroy, getEnv } from 'mobx-state-tree';
|
|
@@ -19,6 +19,8 @@ import { string2regExp } from './utils/string2regExp.js';
|
|
|
19
19
|
|
|
20
20
|
var _a, _b;
|
|
21
21
|
var renderers = [];
|
|
22
|
+
// type 与 RendererConfig 的映射关系
|
|
23
|
+
var renderersTypeMap = {};
|
|
22
24
|
var renderersMap = {};
|
|
23
25
|
var schemaFilters = [];
|
|
24
26
|
var anonymousIndex = 1;
|
|
@@ -34,53 +36,87 @@ function Renderer(config) {
|
|
|
34
36
|
return renderer.component;
|
|
35
37
|
};
|
|
36
38
|
}
|
|
39
|
+
// 将 renderer 转成组件
|
|
40
|
+
function rendererToComponent(component, config) {
|
|
41
|
+
if (config.storeType && config.component) {
|
|
42
|
+
component = HocStoreFactory({
|
|
43
|
+
storeType: config.storeType,
|
|
44
|
+
extendsData: config.storeExtendsData,
|
|
45
|
+
shouldSyncSuperStore: config.shouldSyncSuperStore
|
|
46
|
+
})(observer(component));
|
|
47
|
+
}
|
|
48
|
+
if (config.isolateScope) {
|
|
49
|
+
component = HocScoped(component, config.type);
|
|
50
|
+
}
|
|
51
|
+
return component;
|
|
52
|
+
}
|
|
37
53
|
function registerRenderer(config) {
|
|
38
54
|
if (!config.test && !config.type) {
|
|
39
|
-
throw new TypeError('please set config.
|
|
55
|
+
throw new TypeError('please set config.type or config.test');
|
|
40
56
|
}
|
|
41
|
-
else if (!config.
|
|
42
|
-
|
|
57
|
+
else if (!config.type && config.name !== 'static') {
|
|
58
|
+
// todo static 目前还没办法不用 test 来实现
|
|
59
|
+
console.warn("config.type is recommended for register renderer(".concat(config.test, ")"));
|
|
43
60
|
}
|
|
44
61
|
if (typeof config.type === 'string' && config.type) {
|
|
45
62
|
config.type = config.type.toLowerCase();
|
|
46
63
|
config.test =
|
|
47
|
-
config.test ||
|
|
64
|
+
config.test ||
|
|
65
|
+
new RegExp("(^|/)(?:".concat((config.alias || [])
|
|
66
|
+
.concat(config.type)
|
|
67
|
+
.map(function (type) { return string2regExp(type); })
|
|
68
|
+
.join('|'), ")$"), 'i');
|
|
48
69
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
70
|
+
var exists = renderersTypeMap[config.type || ''];
|
|
71
|
+
var renderer = __assign({}, config);
|
|
72
|
+
if (exists &&
|
|
73
|
+
exists.component &&
|
|
74
|
+
exists.component !== Placeholder &&
|
|
75
|
+
config.component &&
|
|
76
|
+
!config.override) {
|
|
77
|
+
throw new Error("The renderer with type \"".concat(config.type, "\" has already exists, please try another type!"));
|
|
54
78
|
}
|
|
55
|
-
else if (
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
79
|
+
else if (exists) {
|
|
80
|
+
// 如果已经存在,合并配置,并用合并后的配置
|
|
81
|
+
Object.assign(exists, config);
|
|
82
|
+
renderer = exists;
|
|
59
83
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
84
|
+
renderer.weight = renderer.weight || 0;
|
|
85
|
+
renderer.name =
|
|
86
|
+
renderer.name || renderer.type || "anonymous-".concat(anonymousIndex++);
|
|
87
|
+
if (config.component) {
|
|
88
|
+
renderer.Renderer = config.component;
|
|
89
|
+
renderer.component = rendererToComponent(config.component, renderer);
|
|
66
90
|
}
|
|
67
|
-
if (
|
|
68
|
-
|
|
91
|
+
if (!exists) {
|
|
92
|
+
var idx = findIndex(renderers, function (item) { return config.weight < item.weight; });
|
|
93
|
+
~idx ? renderers.splice(idx, 0, renderer) : renderers.push(renderer);
|
|
69
94
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return
|
|
95
|
+
renderersMap[renderer.name] = !!(renderer.component && renderer.component !== Placeholder);
|
|
96
|
+
renderer.type && (renderersTypeMap[renderer.type] = renderer);
|
|
97
|
+
(renderer.alias || []).forEach(function (alias) { return (renderersTypeMap[alias] = renderer); });
|
|
98
|
+
return renderer;
|
|
74
99
|
}
|
|
75
100
|
function unRegisterRenderer(config) {
|
|
101
|
+
var _a;
|
|
76
102
|
var name = (typeof config === 'string' ? config : config.name);
|
|
77
103
|
var idx = renderers.findIndex(function (item) { return item.name === name; });
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
104
|
+
if (~idx) {
|
|
105
|
+
var renderer_1 = renderers[idx];
|
|
106
|
+
renderers.splice(idx, 1);
|
|
107
|
+
delete renderersMap[name];
|
|
108
|
+
delete renderersTypeMap[renderer_1.type || ''];
|
|
109
|
+
(_a = renderer_1.alias) === null || _a === void 0 ? void 0 : _a.forEach(function (alias) { return delete renderersTypeMap[alias]; });
|
|
110
|
+
// 清空渲染器定位缓存
|
|
111
|
+
Object.keys(cache).forEach(function (key) {
|
|
112
|
+
var value = cache[key];
|
|
113
|
+
if (value === renderer_1) {
|
|
114
|
+
delete cache[key];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
82
118
|
}
|
|
83
|
-
function
|
|
119
|
+
function loadRendererError(schema, path) {
|
|
84
120
|
return (React.createElement("div", { className: "RuntimeError" },
|
|
85
121
|
React.createElement("p", null, "Error: \u627E\u4E0D\u5230\u5BF9\u5E94\u7684\u6E32\u67D3\u5668"),
|
|
86
122
|
React.createElement("p", null,
|
|
@@ -89,12 +125,95 @@ function loadRenderer(schema, path) {
|
|
|
89
125
|
React.createElement("pre", null,
|
|
90
126
|
React.createElement("code", null, JSON.stringify(schema, null, 2)))));
|
|
91
127
|
}
|
|
128
|
+
function loadAsyncRenderer(renderer) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
+
var result;
|
|
131
|
+
return __generator(this, function (_a) {
|
|
132
|
+
switch (_a.label) {
|
|
133
|
+
case 0:
|
|
134
|
+
if (!isAsyncRenderer(renderer)) {
|
|
135
|
+
// already loaded
|
|
136
|
+
return [2 /*return*/];
|
|
137
|
+
}
|
|
138
|
+
return [4 /*yield*/, renderer.getComponent()];
|
|
139
|
+
case 1:
|
|
140
|
+
result = _a.sent();
|
|
141
|
+
// 如果异步加载的组件没有注册渲染器
|
|
142
|
+
// 同时默认导出了一个组件,则自动注册
|
|
143
|
+
if (!renderer.component && result.default) {
|
|
144
|
+
registerRenderer(__assign(__assign({}, renderer), { component: result.default }));
|
|
145
|
+
}
|
|
146
|
+
return [2 /*return*/];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function isAsyncRenderer(item) {
|
|
152
|
+
return ((!item.component || item.component === Placeholder) && item.getComponent);
|
|
153
|
+
}
|
|
154
|
+
function hasAsyncRenderers() {
|
|
155
|
+
return renderers.some(isAsyncRenderer);
|
|
156
|
+
}
|
|
157
|
+
function loadAsyncRenderersByType(type, ignore) {
|
|
158
|
+
if (ignore === void 0) { ignore = false; }
|
|
159
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
+
var types, asyncRenderers;
|
|
161
|
+
return __generator(this, function (_a) {
|
|
162
|
+
switch (_a.label) {
|
|
163
|
+
case 0:
|
|
164
|
+
types = Array.isArray(type) ? type : [type];
|
|
165
|
+
asyncRenderers = types
|
|
166
|
+
.map(function (type) {
|
|
167
|
+
var renderer = renderersTypeMap[type];
|
|
168
|
+
if (!renderer && !ignore) {
|
|
169
|
+
throw new Error("Can not find the renderer by type: ".concat(type));
|
|
170
|
+
}
|
|
171
|
+
return renderer;
|
|
172
|
+
})
|
|
173
|
+
.filter(isAsyncRenderer);
|
|
174
|
+
if (!asyncRenderers.length) return [3 /*break*/, 2];
|
|
175
|
+
return [4 /*yield*/, Promise.all(asyncRenderers.map(function (item) { return loadAsyncRenderer(item); }))];
|
|
176
|
+
case 1:
|
|
177
|
+
_a.sent();
|
|
178
|
+
_a.label = 2;
|
|
179
|
+
case 2: return [2 /*return*/];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function loadAllAsyncRenderers() {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
186
|
+
var asyncRenderers;
|
|
187
|
+
var _this = this;
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
switch (_a.label) {
|
|
190
|
+
case 0:
|
|
191
|
+
asyncRenderers = renderers.filter(isAsyncRenderer);
|
|
192
|
+
if (!asyncRenderers.length) return [3 /*break*/, 2];
|
|
193
|
+
return [4 /*yield*/, Promise.all(renderers.map(function (renderer) { return __awaiter(_this, void 0, void 0, function () {
|
|
194
|
+
return __generator(this, function (_a) {
|
|
195
|
+
switch (_a.label) {
|
|
196
|
+
case 0: return [4 /*yield*/, loadAsyncRenderer(renderer)];
|
|
197
|
+
case 1:
|
|
198
|
+
_a.sent();
|
|
199
|
+
return [2 /*return*/];
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}); }))];
|
|
203
|
+
case 1:
|
|
204
|
+
_a.sent();
|
|
205
|
+
_a.label = 2;
|
|
206
|
+
case 2: return [2 /*return*/];
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
92
211
|
var defaultOptions = {
|
|
93
212
|
session: 'global',
|
|
94
213
|
richTextToken: '',
|
|
95
214
|
useMobileUI: true,
|
|
96
215
|
enableAMISDebug: (_b = (_a = window.enableAMISDebug) !== null && _a !== void 0 ? _a : location.search.indexOf('amisDebug=1') !== -1) !== null && _b !== void 0 ? _b : false,
|
|
97
|
-
loadRenderer:
|
|
216
|
+
loadRenderer: loadRendererError,
|
|
98
217
|
fetcher: function () {
|
|
99
218
|
return Promise.reject('fetcher is required');
|
|
100
219
|
},
|
|
@@ -261,8 +380,9 @@ function extendDefaultEnv(env) {
|
|
|
261
380
|
var cache = {};
|
|
262
381
|
function resolveRenderer(path, schema) {
|
|
263
382
|
var type = typeof (schema === null || schema === void 0 ? void 0 : schema.type) == 'string' ? schema.type.toLowerCase() : '';
|
|
264
|
-
|
|
265
|
-
|
|
383
|
+
// 直接匹配类型,后续注册渲染都应该用这个方式而不是之前的判断路径。
|
|
384
|
+
if (type && renderersTypeMap[type]) {
|
|
385
|
+
return renderersTypeMap[type];
|
|
266
386
|
}
|
|
267
387
|
else if (cache[path]) {
|
|
268
388
|
return cache[path];
|
|
@@ -273,15 +393,7 @@ function resolveRenderer(path, schema) {
|
|
|
273
393
|
var renderer = null;
|
|
274
394
|
renderers.some(function (item) {
|
|
275
395
|
var matched = false;
|
|
276
|
-
|
|
277
|
-
if (item.type && type) {
|
|
278
|
-
matched = item.type === type;
|
|
279
|
-
// 如果是type来命中的,那么cache的key直接用 type 即可。
|
|
280
|
-
if (matched) {
|
|
281
|
-
cache[type] = item;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
else if (typeof item.test === 'function') {
|
|
396
|
+
if (typeof item.test === 'function') {
|
|
285
397
|
// 不应该搞得这么复杂的,让每个渲染器唯一 id,自己不晕别人用起来也不晕。
|
|
286
398
|
matched = item.test(path, schema, resolveRenderer);
|
|
287
399
|
}
|
|
@@ -312,4 +424,4 @@ function getRendererByName(name) {
|
|
|
312
424
|
return find(renderers, function (item) { return item.name === name; });
|
|
313
425
|
}
|
|
314
426
|
|
|
315
|
-
export { Renderer, addSchemaFilter, clearStoresCache, defaultOptions, extendDefaultEnv, filterSchema, getRendererByName, getRenderers,
|
|
427
|
+
export { Renderer, addSchemaFilter, clearStoresCache, defaultOptions, extendDefaultEnv, filterSchema, getRendererByName, getRenderers, hasAsyncRenderers, isAsyncRenderer, loadAllAsyncRenderers, loadAsyncRenderer, loadAsyncRenderersByType, loadRendererError, registerRenderer, renderersMap, resolveRenderer, stores, unRegisterRenderer, updateEnv };
|
package/esm/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="react" />
|
|
9
|
-
import { Renderer, getRendererByName, getRenderers, registerRenderer, unRegisterRenderer, resolveRenderer, filterSchema, clearStoresCache, updateEnv, addSchemaFilter, extendDefaultEnv } from './factory';
|
|
10
|
-
import type { RenderOptions, RendererConfig, RendererProps } from './factory';
|
|
9
|
+
import { Renderer, getRendererByName, getRenderers, loadAllAsyncRenderers, loadAsyncRenderersByType, loadAsyncRenderer, registerRenderer, unRegisterRenderer, resolveRenderer, filterSchema, clearStoresCache, updateEnv, addSchemaFilter, extendDefaultEnv } from './factory';
|
|
10
|
+
import type { RenderOptions, RendererConfig, RendererProps, hasAsyncRenderers } from './factory';
|
|
11
11
|
import './polyfills';
|
|
12
12
|
import './renderers/builtin';
|
|
13
13
|
import './renderers/register';
|
|
@@ -15,7 +15,7 @@ export * from './utils/index';
|
|
|
15
15
|
export * from './types';
|
|
16
16
|
export * from './store';
|
|
17
17
|
import * as utils from './utils/helper';
|
|
18
|
-
import { RegisterStore } from './store';
|
|
18
|
+
import { RegisterStore, registerStore } from './store';
|
|
19
19
|
import type { IColumn, IColumn2, IRow, IRow2 } from './store';
|
|
20
20
|
import { setDefaultLocale, getDefaultLocale, makeTranslator, register as registerLocale, extendLocale, removeLocaleData, localeable } from './locale';
|
|
21
21
|
import type { LocaleProps, TranslateFn } from './locale';
|
|
@@ -51,5 +51,5 @@ import type { IItem } from './store/list';
|
|
|
51
51
|
import CustomStyle from './components/CustomStyle';
|
|
52
52
|
import { StatusScoped } from './StatusScoped';
|
|
53
53
|
export declare const version = "__buildVersion";
|
|
54
|
-
export { clearStoresCache, updateEnv, Renderer, RendererProps, RenderOptions, RendererEnv, EnvContext, RegisterStore, FormItem, FormItemWrap, FormItemProps, OptionsControl, FormRenderer, FormHorizontal, utils, getRendererByName, registerRenderer, unRegisterRenderer, getRenderers, registerFormItem, getFormItemByName, registerOptionsControl, resolveRenderer, filterSchema, Scoped, ScopedContext, IScopedContext, StatusScoped, setDefaultTheme, theme, themeable, ThemeProps, getTheme, classPrefix, getClassPrefix, classnames, makeClassnames, getDefaultLocale, setDefaultLocale, registerLocale, makeTranslator, extendLocale, removeLocaleData, localeable, LocaleProps, TranslateFn, ClassNamesFn, parse, lexer, Evaluator, AsyncEvaluator, FilterContext, filters, getFilters, registerFilter, extendsFilters, registerFunction, evaluate, evaluateForAsync, LazyComponent, Overlay, PopOver, ErrorBoundary, addSchemaFilter, OptionsControlProps, FormOptionsControl, FormControlProps, FormBaseControl, extendDefaultEnv, addRootWrapper, RendererConfig, styleMap, RENDERER_TRANSMISSION_OMIT_PROPS, ScopedComponentType, IItem, IColumn, IRow, IColumn2, IRow2, OnEventProps, FormSchemaBase, filterTarget, splitTarget, CustomStyle, enableDebug, disableDebug, envOverwrite };
|
|
54
|
+
export { clearStoresCache, updateEnv, Renderer, RendererProps, RenderOptions, RendererEnv, EnvContext, RegisterStore, registerStore, FormItem, FormItemWrap, FormItemProps, OptionsControl, FormRenderer, FormHorizontal, utils, getRendererByName, registerRenderer, unRegisterRenderer, getRenderers, loadAllAsyncRenderers, loadAsyncRenderersByType, loadAsyncRenderer, hasAsyncRenderers, registerFormItem, getFormItemByName, registerOptionsControl, resolveRenderer, filterSchema, Scoped, ScopedContext, IScopedContext, StatusScoped, setDefaultTheme, theme, themeable, ThemeProps, getTheme, classPrefix, getClassPrefix, classnames, makeClassnames, getDefaultLocale, setDefaultLocale, registerLocale, makeTranslator, extendLocale, removeLocaleData, localeable, LocaleProps, TranslateFn, ClassNamesFn, parse, lexer, Evaluator, AsyncEvaluator, FilterContext, filters, getFilters, registerFilter, extendsFilters, registerFunction, evaluate, evaluateForAsync, LazyComponent, Overlay, PopOver, ErrorBoundary, addSchemaFilter, OptionsControlProps, FormOptionsControl, FormControlProps, FormBaseControl, extendDefaultEnv, addRootWrapper, RendererConfig, styleMap, RENDERER_TRANSMISSION_OMIT_PROPS, ScopedComponentType, IItem, IColumn, IRow, IColumn2, IRow2, OnEventProps, FormSchemaBase, filterTarget, splitTarget, CustomStyle, enableDebug, disableDebug, envOverwrite };
|
|
55
55
|
export declare function render(schema: Schema, props?: RootRenderProps, options?: RenderOptions, pathPrefix?: string): JSX.Element;
|
package/esm/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
2
|
+
* amis-core v6.9.0-rc.0
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { __assign, __rest } from 'tslib';
|
|
7
7
|
import { stores, defaultOptions } from './factory.js';
|
|
8
|
-
export { Renderer, addSchemaFilter, clearStoresCache, extendDefaultEnv, filterSchema, getRendererByName, getRenderers, registerRenderer, resolveRenderer, unRegisterRenderer, updateEnv } from './factory.js';
|
|
8
|
+
export { Renderer, addSchemaFilter, clearStoresCache, extendDefaultEnv, filterSchema, getRendererByName, getRenderers, loadAllAsyncRenderers, loadAsyncRenderer, loadAsyncRenderersByType, registerRenderer, resolveRenderer, unRegisterRenderer, updateEnv } from './factory.js';
|
|
9
9
|
import './polyfills.js';
|
|
10
10
|
import './renderers/builtin.js';
|
|
11
11
|
import './renderers/register.js';
|
|
12
12
|
import { wrapFetcher } from './utils/api.js';
|
|
13
|
-
export { buildApi, callStrFunction, clearApiCache, getApiCache, isApiOutdated, isApiOutdatedWithData, isEffectiveApi, isSameApi, isValidApi, jsFetcher, jsonpFetcher, normalizeApi, normalizeApiResponseData, responseAdaptor, setApiCache, str2AsyncFunction, str2function, wrapAdaptor, wrapFetcher } from './utils/api.js';
|
|
13
|
+
export { addApiRequestAdaptor, addApiResponseAdator, buildApi, callStrFunction, clearApiCache, getApiCache, isApiOutdated, isApiOutdatedWithData, isEffectiveApi, isSameApi, isValidApi, jsFetcher, jsonpFetcher, normalizeApi, normalizeApiResponseData, removeApiRequestAdaptor, removeApiResponseAdaptor, responseAdaptor, setApiCache, str2AsyncFunction, str2function, wrapAdaptor, wrapFetcher } from './utils/api.js';
|
|
14
14
|
export { attachmentAdpator } from './utils/attachmentAdpator.js';
|
|
15
15
|
export { autobindMethod, bind } from './utils/autobind.js';
|
|
16
16
|
export { chromeVersion, isSafari } from './utils/browser.js';
|
|
@@ -78,7 +78,7 @@ export { arraySlice } from './utils/arraySlice.js';
|
|
|
78
78
|
export { isIntegerInRange, numberFormatter, safeAdd, safeSub } from './utils/math.js';
|
|
79
79
|
export { default as animation } from './utils/Animation.js';
|
|
80
80
|
import { RendererStore } from './store/index.js';
|
|
81
|
-
export { RegisterStore, RendererStore } from './store/index.js';
|
|
81
|
+
export { RegisterStore, RendererStore, registerStore } from './store/index.js';
|
|
82
82
|
import { getEnv } from 'mobx-state-tree';
|
|
83
83
|
import { getDefaultLocale, makeTranslator } from './locale.js';
|
|
84
84
|
export { extendLocale, getDefaultLocale, localeable, makeTranslator, register as registerLocale, removeLocaleData, setDefaultLocale } from './locale.js';
|
|
@@ -148,7 +148,7 @@ export { StoreNode } from './store/node.js';
|
|
|
148
148
|
*/
|
|
149
149
|
var classPrefix = getClassPrefix();
|
|
150
150
|
// @ts-ignore
|
|
151
|
-
var version = '6.
|
|
151
|
+
var version = '6.9.0-rc.0';
|
|
152
152
|
function render(schema, props, options, pathPrefix) {
|
|
153
153
|
if (props === void 0) { props = {}; }
|
|
154
154
|
if (options === void 0) { options = {}; }
|
package/esm/locale.js
CHANGED
package/esm/polyfills.js
CHANGED
package/esm/renderers/Form.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
2
|
+
* amis-core v6.9.0-rc.0
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -22,7 +22,7 @@ import '@rc-component/mini-decimal';
|
|
|
22
22
|
import { dataMapping } from '../utils/dataMapping.js';
|
|
23
23
|
import '../utils/filter.js';
|
|
24
24
|
import { isEffectiveApi, isApiOutdated } from '../utils/api.js';
|
|
25
|
-
import
|
|
25
|
+
import themedLazyComponent from '../components/LazyComponent.js';
|
|
26
26
|
import { isAlive } from 'mobx-state-tree';
|
|
27
27
|
import '../utils/browser.js';
|
|
28
28
|
import '../utils/ColorScale.js';
|
|
@@ -1383,7 +1383,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
1383
1383
|
});
|
|
1384
1384
|
}
|
|
1385
1385
|
if (lazyLoad) {
|
|
1386
|
-
body = React.createElement(
|
|
1386
|
+
body = React.createElement(themedLazyComponent, null, body);
|
|
1387
1387
|
}
|
|
1388
1388
|
return body;
|
|
1389
1389
|
};
|
package/esm/renderers/Item.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
2
|
+
* amis-core v6.9.0-rc.0
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -549,7 +549,7 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
549
549
|
var labelAlign = (props.labelAlign !== 'inherit' && props.labelAlign) ||
|
|
550
550
|
props.formLabelAlign;
|
|
551
551
|
var labelWidth = props.labelWidth || props.formLabelWidth;
|
|
552
|
-
return (React.createElement("div", { "data-role": "form-item", className: cx("Form-item Form-item--horizontal", isStatic && staticClassName ? staticClassName : className, (_a = {
|
|
552
|
+
return (React.createElement("div", { "data-role": "form-item", "data-amis-name": props.name, className: cx("Form-item Form-item--horizontal", isStatic && staticClassName ? staticClassName : className, (_a = {
|
|
553
553
|
'Form-item--horizontal-justify': horizontal.justify
|
|
554
554
|
},
|
|
555
555
|
_a["is-error"] = model && !model.valid,
|
|
@@ -615,7 +615,7 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
615
615
|
var _a;
|
|
616
616
|
var className = props.className, style = props.style, cx = props.classnames, desc = props.desc, description = props.description, label = props.label, render = props.render, required = props.required, caption = props.caption, remark = props.remark, labelRemark = props.labelRemark, env = props.env, descriptionClassName = props.descriptionClassName, captionClassName = props.captionClassName, model = props.formItem, renderLabel = props.renderLabel, renderDescription = props.renderDescription, hint = props.hint; props.data; var showErrorMsg = props.showErrorMsg, mobileUI = props.mobileUI; props.translate; var isStatic = props.static, staticClassName = props.staticClassName, themeCss = props.themeCss, wrapperCustomStyle = props.wrapperCustomStyle, id = props.id;
|
|
617
617
|
description = description || desc;
|
|
618
|
-
return (React.createElement("div", { "data-role": "form-item", className: cx("Form-item Form-item--normal", isStatic && staticClassName ? staticClassName : className, (_a = {
|
|
618
|
+
return (React.createElement("div", { "data-role": "form-item", "data-amis-name": props.name, className: cx("Form-item Form-item--normal", isStatic && staticClassName ? staticClassName : className, (_a = {
|
|
619
619
|
'is-error': model && !model.valid
|
|
620
620
|
},
|
|
621
621
|
_a["is-required"] = required,
|
|
@@ -701,7 +701,7 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
701
701
|
var className = props.className, style = props.style, cx = props.classnames, desc = props.desc, description = props.description, label = props.label, render = props.render, required = props.required, caption = props.caption, descriptionClassName = props.descriptionClassName, captionClassName = props.captionClassName, model = props.formItem, remark = props.remark, labelRemark = props.labelRemark, env = props.env, hint = props.hint, renderLabel = props.renderLabel, renderDescription = props.renderDescription; props.data; var showErrorMsg = props.showErrorMsg, mobileUI = props.mobileUI; props.translate; var isStatic = props.static, staticClassName = props.staticClassName, themeCss = props.themeCss, wrapperCustomStyle = props.wrapperCustomStyle, id = props.id;
|
|
702
702
|
var labelWidth = props.labelWidth || props.formLabelWidth;
|
|
703
703
|
description = description || desc;
|
|
704
|
-
return (React.createElement("div", { "data-role": "form-item", className: cx("Form-item Form-item--inline", isStatic && staticClassName ? staticClassName : className, (_a = {
|
|
704
|
+
return (React.createElement("div", { "data-role": "form-item", "data-amis-name": props.name, className: cx("Form-item Form-item--inline", isStatic && staticClassName ? staticClassName : className, (_a = {
|
|
705
705
|
'is-error': model && !model.valid
|
|
706
706
|
},
|
|
707
707
|
_a["is-required"] = required,
|
|
@@ -757,7 +757,7 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
757
757
|
var className = props.className, style = props.style, cx = props.classnames, desc = props.desc, description = props.description, label = props.label, render = props.render, required = props.required, caption = props.caption, remark = props.remark, labelRemark = props.labelRemark, env = props.env, descriptionClassName = props.descriptionClassName, captionClassName = props.captionClassName, model = props.formItem, renderLabel = props.renderLabel, renderDescription = props.renderDescription, hint = props.hint; props.data; var showErrorMsg = props.showErrorMsg, mobileUI = props.mobileUI; props.translate; var isStatic = props.static, staticClassName = props.staticClassName, wrapperCustomStyle = props.wrapperCustomStyle, themeCss = props.themeCss, id = props.id;
|
|
758
758
|
description = description || desc;
|
|
759
759
|
var labelWidth = props.labelWidth || props.formLabelWidth;
|
|
760
|
-
return (React.createElement("div", { "data-role": "form-item", className: cx("Form-item Form-item--row", isStatic && staticClassName ? staticClassName : className, (_a = {
|
|
760
|
+
return (React.createElement("div", { "data-role": "form-item", "data-amis-name": props.name, className: cx("Form-item Form-item--row", isStatic && staticClassName ? staticClassName : className, (_a = {
|
|
761
761
|
'is-error': model && !model.valid
|
|
762
762
|
},
|
|
763
763
|
_a["is-required"] = required,
|
|
@@ -814,7 +814,7 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
814
814
|
props.formLabelAlign;
|
|
815
815
|
var labelWidth = props.labelWidth || props.formLabelWidth;
|
|
816
816
|
description = description || desc;
|
|
817
|
-
return (React.createElement("div", { "data-role": "form-item", className: cx("Form-item Form-item--flex", isStatic && staticClassName ? staticClassName : className, (_a = {
|
|
817
|
+
return (React.createElement("div", { "data-role": "form-item", "data-amis-name": props.name, className: cx("Form-item Form-item--flex", isStatic && staticClassName ? staticClassName : className, (_a = {
|
|
818
818
|
'is-error': model && !model.valid
|
|
819
819
|
},
|
|
820
820
|
_a["is-required"] = required,
|
|
@@ -138,9 +138,9 @@ export interface OptionsControlProps extends FormControlProps, Omit<FormOptionsC
|
|
|
138
138
|
deferLoad: (option: Option) => void;
|
|
139
139
|
leftDeferLoad: (option: Option, leftOptions: Option) => void;
|
|
140
140
|
expandTreeOptions: (nodePathArr: any[]) => void;
|
|
141
|
-
onAdd?: (idx?: number | Array<number>, value?: any, skipForm?: boolean) => void;
|
|
142
|
-
onEdit?: (value: Option, origin?: Option, skipForm?: boolean) => void;
|
|
143
|
-
onDelete?: (value: Option) => void;
|
|
141
|
+
onAdd?: (idx?: number | Array<number>, value?: any, skipForm?: boolean, callback?: (value: any) => any) => void;
|
|
142
|
+
onEdit?: (value: Option, origin?: Option, skipForm?: boolean, callback?: (value: any) => any) => void;
|
|
143
|
+
onDelete?: (value: Option, callback?: (value: any) => any) => void;
|
|
144
144
|
}
|
|
145
145
|
export interface OptionsProps extends FormControlProps, Omit<OptionProps, 'className'> {
|
|
146
146
|
source?: Api;
|
package/esm/renderers/Options.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
2
|
+
* amis-core v6.9.0-rc.0
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -519,12 +519,12 @@ function registerOptionsControl(config) {
|
|
|
519
519
|
var formItem = this.props.formItem;
|
|
520
520
|
formItem && formItem.setLoading(value);
|
|
521
521
|
};
|
|
522
|
-
FormOptionsItem.prototype.handleOptionAdd = function (idx, value, skipForm) {
|
|
522
|
+
FormOptionsItem.prototype.handleOptionAdd = function (idx, value, skipForm, callback) {
|
|
523
523
|
var _a, _b;
|
|
524
524
|
if (idx === void 0) { idx = -1; }
|
|
525
525
|
if (skipForm === void 0) { skipForm = false; }
|
|
526
526
|
return __awaiter(this, void 0, void 0, function () {
|
|
527
|
-
var _c, addControls, addDialog, disabled, labelField, onOpenDialog, optionLabel, addApi, source, data, valueField, deferField, model, createBtnLabel, env, __, parent, ctx, customAddPrevent, result, _d, prevent, payload, e_1, isPrevented, options;
|
|
527
|
+
var _c, addControls, addDialog, disabled, labelField, onOpenDialog, optionLabel, addApi, source, data, valueField, deferField, model, createBtnLabel, env, __, parent, ctx, customAddPrevent, result, _d, prevent, payload, e_1, isPrevented, ret, options;
|
|
528
528
|
var _e;
|
|
529
529
|
var _this = this;
|
|
530
530
|
return __generator(this, function (_f) {
|
|
@@ -654,13 +654,24 @@ function registerOptionsControl(config) {
|
|
|
654
654
|
if (isPrevented) {
|
|
655
655
|
return [2 /*return*/];
|
|
656
656
|
}
|
|
657
|
-
|
|
658
|
-
(parent === null || parent === void 0 ? void 0 : parent.defer))) return [3 /*break*/, 13];
|
|
659
|
-
return [4 /*yield*/, this.deferLoad(parent)];
|
|
657
|
+
return [4 /*yield*/, (callback === null || callback === void 0 ? void 0 : callback(result))];
|
|
660
658
|
case 12:
|
|
661
|
-
_f.sent();
|
|
662
|
-
return [3 /*break*/,
|
|
659
|
+
ret = _f.sent();
|
|
660
|
+
if (!(ret === false)) return [3 /*break*/, 13];
|
|
661
|
+
// 如果回调里面返回 false,就不继续了。
|
|
662
|
+
return [2 /*return*/];
|
|
663
663
|
case 13:
|
|
664
|
+
if (!
|
|
665
|
+
// 如果是懒加载的,只懒加载当前节点。
|
|
666
|
+
(((parent === null || parent === void 0 ? void 0 : parent.hasOwnProperty(deferField)) && parent[deferField]) ||
|
|
667
|
+
(parent === null || parent === void 0 ? void 0 : parent.defer)))
|
|
668
|
+
// 如果是懒加载的,只懒加载当前节点。
|
|
669
|
+
return [3 /*break*/, 15];
|
|
670
|
+
return [4 /*yield*/, this.deferLoad(parent)];
|
|
671
|
+
case 14:
|
|
672
|
+
_f.sent();
|
|
673
|
+
return [3 /*break*/, 16];
|
|
674
|
+
case 15:
|
|
664
675
|
if (source && addApi) {
|
|
665
676
|
// 如果配置了 source 且配置了 addApi 直接重新拉取接口就够了
|
|
666
677
|
// 不能不判断 addApi 就刷新,因为有些场景就是临时添加的。
|
|
@@ -678,18 +689,18 @@ function registerOptionsControl(config) {
|
|
|
678
689
|
}
|
|
679
690
|
model.setOptions(options, this.changeOptionValue, data);
|
|
680
691
|
}
|
|
681
|
-
_f.label =
|
|
682
|
-
case
|
|
692
|
+
_f.label = 16;
|
|
693
|
+
case 16: return [2 /*return*/];
|
|
683
694
|
}
|
|
684
695
|
});
|
|
685
696
|
});
|
|
686
697
|
};
|
|
687
|
-
FormOptionsItem.prototype.handleOptionEdit = function (value, origin, skipForm) {
|
|
698
|
+
FormOptionsItem.prototype.handleOptionEdit = function (value, origin, skipForm, callback) {
|
|
688
699
|
var _a, _b;
|
|
689
700
|
if (origin === void 0) { origin = value; }
|
|
690
701
|
if (skipForm === void 0) { skipForm = false; }
|
|
691
702
|
return __awaiter(this, void 0, void 0, function () {
|
|
692
|
-
var _c, editControls, editDialog, disabled, labelField, valueField, onOpenDialog, editApi, editInitApi, env, source, data, model, optionLabel, __, customEditPrevent, result, _d, prevent, payload, e_2, isPrevented, indexes;
|
|
703
|
+
var _c, editControls, editDialog, disabled, labelField, valueField, onOpenDialog, editApi, editInitApi, env, source, data, model, optionLabel, __, customEditPrevent, result, _d, prevent, payload, e_2, isPrevented, ret, indexes;
|
|
693
704
|
var _this = this;
|
|
694
705
|
return __generator(this, function (_e) {
|
|
695
706
|
switch (_e.label) {
|
|
@@ -798,7 +809,14 @@ function registerOptionsControl(config) {
|
|
|
798
809
|
if (isPrevented) {
|
|
799
810
|
return [2 /*return*/];
|
|
800
811
|
}
|
|
801
|
-
|
|
812
|
+
return [4 /*yield*/, (callback === null || callback === void 0 ? void 0 : callback(result))];
|
|
813
|
+
case 12:
|
|
814
|
+
ret = _e.sent();
|
|
815
|
+
if (ret === false) {
|
|
816
|
+
// 如果回调里面返回 false,就不继续了。
|
|
817
|
+
return [2 /*return*/];
|
|
818
|
+
}
|
|
819
|
+
else if (source && editApi) {
|
|
802
820
|
this.reload();
|
|
803
821
|
}
|
|
804
822
|
else {
|
|
@@ -812,10 +830,10 @@ function registerOptionsControl(config) {
|
|
|
812
830
|
});
|
|
813
831
|
});
|
|
814
832
|
};
|
|
815
|
-
FormOptionsItem.prototype.handleOptionDelete = function (value) {
|
|
833
|
+
FormOptionsItem.prototype.handleOptionDelete = function (value, callback) {
|
|
816
834
|
var _a, _b;
|
|
817
835
|
return __awaiter(this, void 0, void 0, function () {
|
|
818
|
-
var _c, deleteConfirmText, disabled, data, deleteApi, onDelete, env, model, source, valueField, __, ctx, confirmed, _d, isPrevented, delConfirmPrevent, result, options, indexes, e_3;
|
|
836
|
+
var _c, deleteConfirmText, disabled, data, deleteApi, onDelete, env, model, source, valueField, __, ctx, confirmed, _d, isPrevented, delConfirmPrevent, result, ret, options, indexes, e_3;
|
|
819
837
|
return __generator(this, function (_e) {
|
|
820
838
|
switch (_e.label) {
|
|
821
839
|
case 0:
|
|
@@ -871,7 +889,12 @@ function registerOptionsControl(config) {
|
|
|
871
889
|
if (onDelete) {
|
|
872
890
|
onDelete(ctx);
|
|
873
891
|
}
|
|
874
|
-
|
|
892
|
+
ret = callback === null || callback === void 0 ? void 0 : callback(ctx);
|
|
893
|
+
if (ret === false) {
|
|
894
|
+
// 如果回调里面返回 false,就不继续了。
|
|
895
|
+
return [2 /*return*/];
|
|
896
|
+
}
|
|
897
|
+
else if (source) {
|
|
875
898
|
this.reload();
|
|
876
899
|
}
|
|
877
900
|
else {
|
|
@@ -985,19 +1008,19 @@ function registerOptionsControl(config) {
|
|
|
985
1008
|
__decorate([
|
|
986
1009
|
autobind,
|
|
987
1010
|
__metadata("design:type", Function),
|
|
988
|
-
__metadata("design:paramtypes", [Object, Object, Boolean]),
|
|
1011
|
+
__metadata("design:paramtypes", [Object, Object, Boolean, Function]),
|
|
989
1012
|
__metadata("design:returntype", Promise)
|
|
990
1013
|
], FormOptionsItem.prototype, "handleOptionAdd", null);
|
|
991
1014
|
__decorate([
|
|
992
1015
|
autobind,
|
|
993
1016
|
__metadata("design:type", Function),
|
|
994
|
-
__metadata("design:paramtypes", [Object, Object, Boolean]),
|
|
1017
|
+
__metadata("design:paramtypes", [Object, Object, Boolean, Function]),
|
|
995
1018
|
__metadata("design:returntype", Promise)
|
|
996
1019
|
], FormOptionsItem.prototype, "handleOptionEdit", null);
|
|
997
1020
|
__decorate([
|
|
998
1021
|
autobind,
|
|
999
1022
|
__metadata("design:type", Function),
|
|
1000
|
-
__metadata("design:paramtypes", [Object]),
|
|
1023
|
+
__metadata("design:paramtypes", [Object, Function]),
|
|
1001
1024
|
__metadata("design:returntype", Promise)
|
|
1002
1025
|
], FormOptionsItem.prototype, "handleOptionDelete", null);
|
|
1003
1026
|
return FormOptionsItem;
|
package/esm/renderers/builtin.js
CHANGED
package/esm/store/app.js
CHANGED
package/esm/store/combo.js
CHANGED