amis-core 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Root.js +94 -0
- package/dist/RootRenderer.js +288 -0
- package/dist/SchemaRenderer.js +323 -0
- package/dist/Scoped.js +252 -0
- package/dist/WithRootStore.js +44 -0
- package/dist/WithStore.js +179 -0
- package/dist/__tests__/compat.test.d.ts +1 -0
- package/dist/__tests__/factory.test.d.ts +1 -0
- package/dist/__tests__/filter.test.d.ts +1 -0
- package/dist/__tests__/helper.d.ts +13 -0
- package/dist/__tests__/tokenize.test.d.ts +1 -0
- package/dist/actions/Action.js +119 -0
- package/dist/actions/AjaxAction.js +96 -0
- package/dist/actions/BreakAction.js +35 -0
- package/dist/actions/BroadcastAction.js +49 -0
- package/dist/actions/CmptAction.js +60 -0
- package/dist/actions/ContinueAction.js +35 -0
- package/dist/actions/CopyAction.js +43 -0
- package/dist/actions/CustomAction.js +49 -0
- package/dist/actions/DialogAction.js +104 -0
- package/dist/actions/DrawerAction.js +66 -0
- package/dist/actions/EmailAction.js +48 -0
- package/dist/actions/LinkAction.js +52 -0
- package/dist/actions/LoopAction.js +107 -0
- package/dist/actions/PageAction.js +80 -0
- package/dist/actions/ParallelAction.js +40 -0
- package/dist/actions/SwitchAction.js +52 -0
- package/dist/actions/ToastAction.js +35 -0
- package/dist/components/LazyComponent.js +99 -0
- package/dist/env.js +20 -0
- package/dist/envOverwrite.js +43 -0
- package/dist/factory.js +308 -0
- package/dist/index.js +218 -0
- package/dist/index2.js +255 -0
- package/dist/locale.js +114 -0
- package/dist/renderers/Form.js +1162 -0
- package/dist/renderers/Item.js +636 -0
- package/dist/renderers/Options.js +881 -0
- package/dist/renderers/Placeholder.js +31 -0
- package/dist/renderers/builtin.js +27 -0
- package/dist/renderers/wrapControl.js +507 -0
- package/dist/src/Root.d.ts +37 -0
- package/dist/src/RootRenderer.d.ts +27 -0
- package/dist/src/SchemaRenderer.d.ts +37 -0
- package/dist/src/Scoped.d.ts +38 -0
- package/dist/src/WithRootStore.d.ts +737 -0
- package/dist/src/WithStore.d.ts +5 -0
- package/dist/src/actions/Action.d.ts +38 -0
- package/dist/src/actions/AjaxAction.d.ts +25 -0
- package/dist/src/actions/BreakAction.d.ts +15 -0
- package/dist/src/actions/BroadcastAction.d.ts +16 -0
- package/dist/src/actions/CmptAction.d.ts +20 -0
- package/dist/src/actions/ContinueAction.d.ts +15 -0
- package/dist/src/actions/CopyAction.d.ts +20 -0
- package/dist/src/actions/CustomAction.d.ts +17 -0
- package/dist/src/actions/Decorators.d.ts +25 -0
- package/dist/src/actions/DialogAction.d.ts +57 -0
- package/dist/src/actions/DrawerAction.d.ts +30 -0
- package/dist/src/actions/EmailAction.d.ts +23 -0
- package/dist/src/actions/LinkAction.d.ts +24 -0
- package/dist/src/actions/LoopAction.d.ts +19 -0
- package/dist/src/actions/PageAction.d.ts +39 -0
- package/dist/src/actions/ParallelAction.d.ts +8 -0
- package/dist/src/actions/SwitchAction.d.ts +11 -0
- package/dist/src/actions/ToastAction.d.ts +19 -0
- package/dist/src/actions/index.d.ts +21 -0
- package/dist/src/components/LazyComponent.d.ts +32 -0
- package/dist/src/env.d.ts +172 -0
- package/dist/src/envOverwrite.d.ts +4 -0
- package/dist/src/factory.d.ts +78 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/src/locale.d.ts +82 -0
- package/dist/src/renderers/Form.d.ts +352 -0
- package/dist/src/renderers/Item.d.ts +795 -0
- package/dist/src/renderers/Options.d.ts +150 -0
- package/dist/src/renderers/Placeholder.d.ts +6 -0
- package/dist/src/renderers/builtin.d.ts +1 -0
- package/dist/src/renderers/wrapControl.d.ts +446 -0
- package/dist/src/schema.d.ts +369 -0
- package/dist/src/store/app.d.ts +89 -0
- package/dist/src/store/combo.d.ts +8504 -0
- package/dist/src/store/crud.d.ts +124 -0
- package/dist/src/store/form.d.ts +3394 -0
- package/dist/src/store/formItem.d.ts +130 -0
- package/dist/src/store/iRenderer.d.ts +46 -0
- package/dist/src/store/index.d.ts +105 -0
- package/dist/src/store/list.d.ts +270 -0
- package/dist/src/store/manager.d.ts +115 -0
- package/dist/src/store/modal.d.ts +84 -0
- package/dist/src/store/node.d.ts +22 -0
- package/dist/src/store/pagination.d.ts +58 -0
- package/dist/src/store/root.d.ts +79 -0
- package/dist/src/store/service.d.ts +71 -0
- package/dist/src/store/table-v2.d.ts +309 -0
- package/dist/src/store/table.d.ts +8334 -0
- package/dist/src/theme.d.ts +83 -0
- package/dist/src/types.d.ts +217 -0
- package/dist/src/utils/Animation.d.ts +22 -0
- package/dist/src/utils/ColorScale.d.ts +19 -0
- package/dist/src/utils/DataSchema.d.ts +25 -0
- package/dist/src/utils/DataScope.d.ts +23 -0
- package/dist/src/utils/RootClose.d.ts +4 -0
- package/dist/src/utils/SimpleMap.d.ts +8 -0
- package/dist/src/utils/api.d.ts +27 -0
- package/dist/src/utils/attachmentAdpator.d.ts +7 -0
- package/dist/src/utils/autobind.d.ts +7 -0
- package/dist/src/utils/columnsSplit.d.ts +1 -0
- package/dist/src/utils/dataMapping.d.ts +3 -0
- package/dist/src/utils/date.d.ts +4 -0
- package/dist/src/utils/debug.d.ts +26 -0
- package/dist/src/utils/dom.d.ts +13 -0
- package/dist/src/utils/errors.d.ts +6 -0
- package/dist/src/utils/escapeHtml.d.ts +1 -0
- package/dist/src/utils/filter-schema.d.ts +12 -0
- package/dist/src/utils/filter.d.ts +1 -0
- package/dist/src/utils/formatDuration.d.ts +1 -0
- package/dist/src/utils/formula.d.ts +16 -0
- package/dist/src/utils/getVariable.d.ts +3 -0
- package/dist/src/utils/grammar.d.ts +4 -0
- package/dist/src/utils/handleAction.d.ts +6 -0
- package/dist/src/utils/helper.d.ts +286 -0
- package/dist/src/utils/icon.d.ts +12 -0
- package/dist/src/utils/image.d.ts +17 -0
- package/dist/src/utils/index.d.ts +12 -0
- package/dist/src/utils/isPureVariable.d.ts +1 -0
- package/dist/src/utils/json-schema-2-amis-schema.d.ts +6 -0
- package/dist/src/utils/keyToPath.d.ts +6 -0
- package/dist/src/utils/makeSorter.d.ts +1 -0
- package/dist/src/utils/markdown.d.ts +5 -0
- package/dist/src/utils/normalizeLink.d.ts +1 -0
- package/dist/src/utils/normalizeOptions.d.ts +7 -0
- package/dist/src/utils/object.d.ts +15 -0
- package/dist/src/utils/offset.d.ts +14 -0
- package/dist/src/utils/offsetParent.d.ts +4 -0
- package/dist/src/utils/optionValueCompare.d.ts +3 -0
- package/dist/src/utils/position.d.ts +15 -0
- package/dist/src/utils/prettyBytes.d.ts +1 -0
- package/dist/src/utils/renderer-event.d.ts +44 -0
- package/dist/src/utils/replaceText.d.ts +6 -0
- package/dist/src/utils/resize-sensor.d.ts +6 -0
- package/dist/src/utils/resolveVariable.d.ts +1 -0
- package/dist/src/utils/resolveVariableAndFilter.d.ts +1 -0
- package/dist/src/utils/scrollPosition.d.ts +6 -0
- package/dist/src/utils/string2regExp.d.ts +1 -0
- package/dist/src/utils/stripNumber.d.ts +1 -0
- package/dist/src/utils/style.d.ts +10 -0
- package/dist/src/utils/tokenize.d.ts +1 -0
- package/dist/src/utils/tpl-builtin.d.ts +18 -0
- package/dist/src/utils/tpl-lodash.d.ts +4 -0
- package/dist/src/utils/tpl.d.ts +11 -0
- package/dist/src/utils/validations.d.ts +39 -0
- package/dist/store/app.js +190 -0
- package/dist/store/combo.js +154 -0
- package/dist/store/crud.js +413 -0
- package/dist/store/form.js +579 -0
- package/dist/store/formItem.js +846 -0
- package/dist/store/iRenderer.js +189 -0
- package/dist/store/index.js +103 -0
- package/dist/store/list.js +248 -0
- package/dist/store/manager.js +56 -0
- package/dist/store/modal.js +54 -0
- package/dist/store/node.js +93 -0
- package/dist/store/pagination.js +60 -0
- package/dist/store/root.js +45 -0
- package/dist/store/service.js +415 -0
- package/dist/store/table-v2.js +471 -0
- package/dist/store/table.js +1105 -0
- package/dist/theme.js +93 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/Animation.js +290 -0
- package/dist/utils/DataSchema.js +120 -0
- package/dist/utils/DataScope.js +151 -0
- package/dist/utils/SimpleMap.js +46 -0
- package/dist/utils/api.js +555 -0
- package/dist/utils/autobind.js +94 -0
- package/dist/utils/dataMapping.js +136 -0
- package/dist/utils/date.js +90 -0
- package/dist/utils/debug.js +343 -0
- package/dist/utils/errors.js +23 -0
- package/dist/utils/escapeHtml.js +24 -0
- package/dist/utils/filter-schema.js +75 -0
- package/dist/utils/filter.js +481 -0
- package/dist/utils/formatDuration.js +27 -0
- package/dist/utils/formula.js +165 -0
- package/dist/utils/getVariable.js +29 -0
- package/dist/utils/grammar.js +54 -0
- package/dist/utils/helper.js +1283 -0
- package/dist/utils/isPureVariable.js +16 -0
- package/dist/utils/keyToPath.js +34 -0
- package/dist/utils/makeSorter.js +30 -0
- package/dist/utils/normalizeLink.js +47 -0
- package/dist/utils/normalizeOptions.js +92 -0
- package/dist/utils/object.js +156 -0
- package/dist/utils/offset.js +36 -0
- package/dist/utils/offsetParent.js +27 -0
- package/dist/utils/optionValueCompare.js +25 -0
- package/dist/utils/position.js +50 -0
- package/dist/utils/prettyBytes.js +28 -0
- package/dist/utils/renderer-event.js +131 -0
- package/dist/utils/replaceText.js +35 -0
- package/dist/utils/resize-sensor.js +177 -0
- package/dist/utils/resolveVariable.js +39 -0
- package/dist/utils/resolveVariableAndFilter.js +37 -0
- package/dist/utils/string2regExp.js +18 -0
- package/dist/utils/stripNumber.js +20 -0
- package/dist/utils/tokenize.js +33 -0
- package/dist/utils/tpl-builtin.js +71 -0
- package/dist/utils/tpl-lodash.js +71 -0
- package/dist/utils/tpl.js +140 -0
- package/dist/utils/validations.js +377 -0
- package/package.json +121 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v1.0.0-beta.0
|
|
3
|
+
* Copyright 2018-2022 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
+
|
|
10
|
+
var DataScope = require('./DataScope.js');
|
|
11
|
+
var helper = require('./helper.js');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 用来定义数据本身的数据结构,比如有类型是什么,有哪些属性。
|
|
15
|
+
*/
|
|
16
|
+
var DataSchema = /** @class */ (function () {
|
|
17
|
+
function DataSchema(schema) {
|
|
18
|
+
this.idMap = {};
|
|
19
|
+
this.root = new DataScope.DataScope(schema, 'root');
|
|
20
|
+
this.idMap['root'] = this.root;
|
|
21
|
+
this.current = this.root;
|
|
22
|
+
}
|
|
23
|
+
DataSchema.prototype.setSchema = function (schemas) {
|
|
24
|
+
this.current.setSchemas(schemas);
|
|
25
|
+
return this;
|
|
26
|
+
};
|
|
27
|
+
DataSchema.prototype.addSchema = function (schema) {
|
|
28
|
+
this.current.addSchema(schema);
|
|
29
|
+
return this;
|
|
30
|
+
};
|
|
31
|
+
DataSchema.prototype.removeSchema = function (id) {
|
|
32
|
+
this.current.removeSchema(id);
|
|
33
|
+
delete this.idMap[id];
|
|
34
|
+
return this;
|
|
35
|
+
};
|
|
36
|
+
DataSchema.prototype.getSchemas = function () {
|
|
37
|
+
var schemas = [];
|
|
38
|
+
var current = this.current;
|
|
39
|
+
while (current) {
|
|
40
|
+
schemas.push.apply(schemas, current.schemas);
|
|
41
|
+
current = current.parent;
|
|
42
|
+
}
|
|
43
|
+
return schemas;
|
|
44
|
+
};
|
|
45
|
+
DataSchema.prototype.addScope = function (schema, id) {
|
|
46
|
+
if (id === void 0) { id = helper.guid(); }
|
|
47
|
+
if (this.idMap[id]) {
|
|
48
|
+
throw new Error('scope id `' + id + '` already exists');
|
|
49
|
+
}
|
|
50
|
+
this.current = this.current.addChild(id, schema);
|
|
51
|
+
this.idMap[id] = this.current;
|
|
52
|
+
return this;
|
|
53
|
+
};
|
|
54
|
+
DataSchema.prototype.removeScope = function (idOrScope) {
|
|
55
|
+
var _a;
|
|
56
|
+
var scope = this.getScope(idOrScope);
|
|
57
|
+
if (!scope.parent) {
|
|
58
|
+
throw new Error('cannot remove root scope');
|
|
59
|
+
}
|
|
60
|
+
if (scope.contains(this.current)) {
|
|
61
|
+
this.current = scope.parent;
|
|
62
|
+
}
|
|
63
|
+
(_a = scope.parent) === null || _a === void 0 ? void 0 : _a.removeChild(scope);
|
|
64
|
+
delete this.idMap[scope.id];
|
|
65
|
+
return this;
|
|
66
|
+
};
|
|
67
|
+
DataSchema.prototype.hasScope = function (idOrScope) {
|
|
68
|
+
var id = typeof idOrScope === 'string' ? idOrScope : idOrScope.id;
|
|
69
|
+
var scope = this.idMap[id];
|
|
70
|
+
return !!scope;
|
|
71
|
+
};
|
|
72
|
+
DataSchema.prototype.getScope = function (idOrScope) {
|
|
73
|
+
var id = typeof idOrScope === 'string' ? idOrScope : idOrScope.id;
|
|
74
|
+
var scope = this.idMap[id];
|
|
75
|
+
if (!scope) {
|
|
76
|
+
throw new Error('scope not found!');
|
|
77
|
+
}
|
|
78
|
+
return scope;
|
|
79
|
+
};
|
|
80
|
+
DataSchema.prototype.switchToRoot = function () {
|
|
81
|
+
this.current = this.root;
|
|
82
|
+
return this;
|
|
83
|
+
};
|
|
84
|
+
DataSchema.prototype.switchTo = function (idOrScope) {
|
|
85
|
+
var scope = this.getScope(idOrScope);
|
|
86
|
+
this.current = scope;
|
|
87
|
+
return this;
|
|
88
|
+
};
|
|
89
|
+
DataSchema.prototype.getDataPropsAsOptions = function () {
|
|
90
|
+
var variables = [];
|
|
91
|
+
var current = this.current;
|
|
92
|
+
while (current) {
|
|
93
|
+
if (current.tag) {
|
|
94
|
+
variables.push({
|
|
95
|
+
label: current.tag,
|
|
96
|
+
children: current.getDataPropsAsOptions()
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
variables.push.apply(variables, current.getDataPropsAsOptions());
|
|
101
|
+
}
|
|
102
|
+
current = current.parent;
|
|
103
|
+
}
|
|
104
|
+
return variables;
|
|
105
|
+
};
|
|
106
|
+
DataSchema.prototype.getSchemaByPath = function (path) {
|
|
107
|
+
var current = this.current;
|
|
108
|
+
while (current) {
|
|
109
|
+
var schema = current.getSchemaByPath(path);
|
|
110
|
+
if (schema) {
|
|
111
|
+
return schema;
|
|
112
|
+
}
|
|
113
|
+
current = current.parent;
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
};
|
|
117
|
+
return DataSchema;
|
|
118
|
+
}());
|
|
119
|
+
|
|
120
|
+
exports.DataSchema = DataSchema;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v1.0.0-beta.0
|
|
3
|
+
* Copyright 2018-2022 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
+
|
|
10
|
+
var tslib = require('tslib');
|
|
11
|
+
var helper = require('./helper.js');
|
|
12
|
+
var keyToPath = require('./keyToPath.js');
|
|
13
|
+
|
|
14
|
+
var DataScope = /** @class */ (function () {
|
|
15
|
+
function DataScope(schemas, id) {
|
|
16
|
+
this.children = [];
|
|
17
|
+
this.schemas = [];
|
|
18
|
+
this.setSchemas(Array.isArray(schemas) ? schemas : [schemas]);
|
|
19
|
+
this.id = id;
|
|
20
|
+
}
|
|
21
|
+
DataScope.prototype.addChild = function (id, schema) {
|
|
22
|
+
var child = new DataScope(schema || {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {}
|
|
25
|
+
}, id);
|
|
26
|
+
this.children.push(child);
|
|
27
|
+
child.parent = this;
|
|
28
|
+
return child;
|
|
29
|
+
};
|
|
30
|
+
DataScope.prototype.removeChild = function (idOrScope) {
|
|
31
|
+
var idx = this.children.findIndex(function (item) {
|
|
32
|
+
return typeof idOrScope === 'string' ? idOrScope === item.id : item === idOrScope;
|
|
33
|
+
});
|
|
34
|
+
if (~idx) {
|
|
35
|
+
var scope = this.children[idx];
|
|
36
|
+
delete scope.parent;
|
|
37
|
+
this.children.splice(idx, 1);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
DataScope.prototype.setSchemas = function (schemas) {
|
|
41
|
+
this.schemas.splice(0, this.schemas.length);
|
|
42
|
+
for (var _i = 0, schemas_1 = schemas; _i < schemas_1.length; _i++) {
|
|
43
|
+
var schema = schemas_1[_i];
|
|
44
|
+
if (schema.type !== 'object') {
|
|
45
|
+
throw new TypeError('data scope accept only object');
|
|
46
|
+
}
|
|
47
|
+
this.schemas.push(tslib.__assign({ $id: helper.guid() }, schema));
|
|
48
|
+
}
|
|
49
|
+
return this;
|
|
50
|
+
};
|
|
51
|
+
DataScope.prototype.addSchema = function (schema) {
|
|
52
|
+
schema = tslib.__assign({ $id: helper.guid() }, schema);
|
|
53
|
+
this.schemas.push(schema);
|
|
54
|
+
return this;
|
|
55
|
+
};
|
|
56
|
+
DataScope.prototype.removeSchema = function (id) {
|
|
57
|
+
var idx = this.schemas.findIndex(function (schema) { return schema.$id === id; });
|
|
58
|
+
if (~idx) {
|
|
59
|
+
this.schemas.splice(idx, 1);
|
|
60
|
+
}
|
|
61
|
+
return this;
|
|
62
|
+
};
|
|
63
|
+
DataScope.prototype.contains = function (scope) {
|
|
64
|
+
var from = scope;
|
|
65
|
+
while (from) {
|
|
66
|
+
if (this === from) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
from = from.parent;
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
};
|
|
73
|
+
DataScope.prototype.getMergedSchema = function () {
|
|
74
|
+
var mergedSchema = {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {}
|
|
77
|
+
};
|
|
78
|
+
// todo 以后再来细化这一块,先粗略的写个大概
|
|
79
|
+
this.schemas.forEach(function (schema) {
|
|
80
|
+
var properties = schema.properties || {};
|
|
81
|
+
Object.keys(properties).forEach(function (key) {
|
|
82
|
+
var value = properties[key];
|
|
83
|
+
if (mergedSchema.properties[key]) {
|
|
84
|
+
if (Array.isArray(mergedSchema.properties[key].oneOf)) {
|
|
85
|
+
mergedSchema.properties[key].oneOf.push();
|
|
86
|
+
}
|
|
87
|
+
else if (mergedSchema.properties[key].type &&
|
|
88
|
+
mergedSchema.properties[key].type !== value.type) {
|
|
89
|
+
mergedSchema.properties[key] = {
|
|
90
|
+
oneOf: [mergedSchema.properties[key], value]
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
mergedSchema.properties[key] = value;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
return mergedSchema;
|
|
100
|
+
};
|
|
101
|
+
DataScope.prototype.buildOptions = function (options, schema, path, key) {
|
|
102
|
+
var _this = this;
|
|
103
|
+
if (path === void 0) { path = ''; }
|
|
104
|
+
if (key === void 0) { key = ''; }
|
|
105
|
+
// todo 支持 oneOf, anyOf
|
|
106
|
+
var option = {
|
|
107
|
+
label: schema.title || key,
|
|
108
|
+
value: path,
|
|
109
|
+
type: schema.type,
|
|
110
|
+
description: schema.description
|
|
111
|
+
};
|
|
112
|
+
options.push(option);
|
|
113
|
+
if (schema.type === 'object' && schema.properties) {
|
|
114
|
+
option.children = [];
|
|
115
|
+
var keys = Object.keys(schema.properties);
|
|
116
|
+
keys.forEach(function (key) {
|
|
117
|
+
var child = schema.properties[key];
|
|
118
|
+
_this.buildOptions(option.children, child, path + (path ? '.' : '') + key, key);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else if (schema.type === 'array' && schema.items) {
|
|
122
|
+
option.children = [];
|
|
123
|
+
this.buildOptions(option.children, tslib.__assign({ title: 'Member' }, schema.items), path + (path ? '.' : '') + 'items', 'items');
|
|
124
|
+
option.children = helper.mapTree(option.children, function (item) { return (tslib.__assign(tslib.__assign({}, item), { disabled: true })); });
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
DataScope.prototype.getDataPropsAsOptions = function () {
|
|
128
|
+
var variables = [];
|
|
129
|
+
this.buildOptions(variables, this.getMergedSchema());
|
|
130
|
+
return variables[0].children;
|
|
131
|
+
};
|
|
132
|
+
DataScope.prototype.getSchemaByPath = function (path) {
|
|
133
|
+
var parts = keyToPath.keyToPath(path);
|
|
134
|
+
for (var _i = 0, _a = this.schemas; _i < _a.length; _i++) {
|
|
135
|
+
var schema = _a[_i];
|
|
136
|
+
var result = parts.reduce(function (schema, key) {
|
|
137
|
+
if (schema && schema.type === 'object' && schema.properties) {
|
|
138
|
+
return schema.properties[key];
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}, schema);
|
|
142
|
+
if (result) {
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
};
|
|
148
|
+
return DataScope;
|
|
149
|
+
}());
|
|
150
|
+
|
|
151
|
+
exports.DataScope = DataScope;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v1.0.0-beta.0
|
|
3
|
+
* Copyright 2018-2022 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
+
|
|
10
|
+
var find = require('lodash/find');
|
|
11
|
+
var findIndex = require('lodash/findIndex');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var find__default = /*#__PURE__*/_interopDefaultLegacy(find);
|
|
16
|
+
var findIndex__default = /*#__PURE__*/_interopDefaultLegacy(findIndex);
|
|
17
|
+
|
|
18
|
+
var SimpleMap = /** @class */ (function () {
|
|
19
|
+
function SimpleMap() {
|
|
20
|
+
this.list = [];
|
|
21
|
+
}
|
|
22
|
+
SimpleMap.prototype.has = function (key) {
|
|
23
|
+
var resolved = find__default["default"](this.list, function (item) { return item.key === key; });
|
|
24
|
+
return !!resolved;
|
|
25
|
+
};
|
|
26
|
+
SimpleMap.prototype.set = function (key, value) {
|
|
27
|
+
this.list.push({
|
|
28
|
+
key: key,
|
|
29
|
+
value: value
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
SimpleMap.prototype.get = function (key) {
|
|
33
|
+
var resolved = find__default["default"](this.list, function (item) { return item.key === key; });
|
|
34
|
+
return resolved ? resolved.value : null;
|
|
35
|
+
};
|
|
36
|
+
SimpleMap.prototype.delete = function (key) {
|
|
37
|
+
var idx = findIndex__default["default"](this.list, function (item) { return item.key === key; });
|
|
38
|
+
~idx && this.list.splice(idx, 1);
|
|
39
|
+
};
|
|
40
|
+
SimpleMap.prototype.dispose = function () {
|
|
41
|
+
this.list.splice(0, this.list.length);
|
|
42
|
+
};
|
|
43
|
+
return SimpleMap;
|
|
44
|
+
}());
|
|
45
|
+
|
|
46
|
+
exports.SimpleMap = SimpleMap;
|