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,31 @@
|
|
|
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 React = require('react');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
16
|
+
|
|
17
|
+
var Placeholder = /** @class */ (function (_super) {
|
|
18
|
+
tslib.__extends(Placeholder, _super);
|
|
19
|
+
function Placeholder() {
|
|
20
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
21
|
+
}
|
|
22
|
+
Placeholder.prototype.componentDidMount = function () {
|
|
23
|
+
console.warn("Please implement this renderer(".concat(this.props.type, ")"));
|
|
24
|
+
};
|
|
25
|
+
Placeholder.prototype.render = function () {
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
return Placeholder;
|
|
29
|
+
}(React__default["default"].Component));
|
|
30
|
+
|
|
31
|
+
exports.Placeholder = Placeholder;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v1.0.0-beta.0
|
|
3
|
+
* Copyright 2018-2022 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
var Placeholder = require('./Placeholder.js');
|
|
9
|
+
require('./Form.js');
|
|
10
|
+
var factory = require('../factory.js');
|
|
11
|
+
|
|
12
|
+
factory.registerRenderer({
|
|
13
|
+
type: 'spinner',
|
|
14
|
+
component: Placeholder.Placeholder
|
|
15
|
+
});
|
|
16
|
+
factory.registerRenderer({
|
|
17
|
+
type: 'alert',
|
|
18
|
+
component: Placeholder.Placeholder
|
|
19
|
+
});
|
|
20
|
+
factory.registerRenderer({
|
|
21
|
+
type: 'dialog',
|
|
22
|
+
component: Placeholder.Placeholder
|
|
23
|
+
});
|
|
24
|
+
factory.registerRenderer({
|
|
25
|
+
type: 'drawer',
|
|
26
|
+
component: Placeholder.Placeholder
|
|
27
|
+
});
|
|
@@ -0,0 +1,507 @@
|
|
|
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 React = require('react');
|
|
12
|
+
var debouce = require('lodash/debounce');
|
|
13
|
+
var isEqual = require('lodash/isEqual');
|
|
14
|
+
var combo = require('../store/combo.js');
|
|
15
|
+
var helper = require('../utils/helper.js');
|
|
16
|
+
var formula = require('../utils/formula.js');
|
|
17
|
+
var Scoped = require('../Scoped.js');
|
|
18
|
+
var formItem = require('../store/formItem.js');
|
|
19
|
+
var mobxStateTree = require('mobx-state-tree');
|
|
20
|
+
var mobxReact = require('mobx-react');
|
|
21
|
+
var hoistNonReactStatic = require('hoist-non-react-statics');
|
|
22
|
+
var WithRootStore = require('../WithRootStore.js');
|
|
23
|
+
var table = require('../store/table.js');
|
|
24
|
+
var getVariable = require('../utils/getVariable.js');
|
|
25
|
+
|
|
26
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
27
|
+
|
|
28
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
29
|
+
var debouce__default = /*#__PURE__*/_interopDefaultLegacy(debouce);
|
|
30
|
+
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
31
|
+
var hoistNonReactStatic__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatic);
|
|
32
|
+
|
|
33
|
+
function wrapControl(ComposedComponent) {
|
|
34
|
+
var _a;
|
|
35
|
+
var result = hoistNonReactStatic__default["default"](WithRootStore.withRootStore(mobxReact.observer((_a = /** @class */ (function (_super) {
|
|
36
|
+
tslib.__extends(class_1, _super);
|
|
37
|
+
function class_1(props) {
|
|
38
|
+
var _this = this;
|
|
39
|
+
var _a, _b;
|
|
40
|
+
_this = _super.call(this, props) || this;
|
|
41
|
+
_this.value = undefined;
|
|
42
|
+
_this.lazyEmitChange = debouce__default["default"](_this.emitChange.bind(_this), 250, {
|
|
43
|
+
trailing: true,
|
|
44
|
+
leading: false
|
|
45
|
+
});
|
|
46
|
+
var _c = _this.props, form = _c.formStore, formItem$1 = _c.formItem, rootStore = _c.rootStore, store = _c.store, onChange = _c.onChange, data = _c.data, _d = _c.$schema, name = _d.name, id = _d.id, type = _d.type, required = _d.required, validations = _d.validations, validationErrors = _d.validationErrors, unique = _d.unique, value = _d.value, multiple = _d.multiple, delimiter = _d.delimiter, valueField = _d.valueField, labelField = _d.labelField, joinValues = _d.joinValues, extractValue = _d.extractValue, selectFirst = _d.selectFirst, autoFill = _d.autoFill, clearValueOnHidden = _d.clearValueOnHidden, validateApi = _d.validateApi, minLength = _d.minLength, maxLength = _d.maxLength, validateOnChange = _d.validateOnChange, label = _d.label;
|
|
47
|
+
_this.getValue = _this.getValue.bind(_this);
|
|
48
|
+
_this.setValue = _this.setValue.bind(_this);
|
|
49
|
+
_this.handleChange = _this.handleChange.bind(_this);
|
|
50
|
+
_this.setPrinstineValue = _this.setPrinstineValue.bind(_this);
|
|
51
|
+
_this.controlRef = _this.controlRef.bind(_this);
|
|
52
|
+
_this.handleBlur = _this.handleBlur.bind(_this);
|
|
53
|
+
if (!name) {
|
|
54
|
+
return _this;
|
|
55
|
+
}
|
|
56
|
+
var propValue = _this.props.value;
|
|
57
|
+
var model = rootStore.addStore({
|
|
58
|
+
id: helper.guid(),
|
|
59
|
+
path: _this.props.$path,
|
|
60
|
+
storeType: formItem.FormItemStore.name,
|
|
61
|
+
parentId: store === null || store === void 0 ? void 0 : store.id,
|
|
62
|
+
name: name
|
|
63
|
+
});
|
|
64
|
+
_this.model = model;
|
|
65
|
+
// @issue 打算干掉这个
|
|
66
|
+
formItem$1 === null || formItem$1 === void 0 ? void 0 : formItem$1.addSubFormItem(model);
|
|
67
|
+
model.config({
|
|
68
|
+
id: id,
|
|
69
|
+
type: type,
|
|
70
|
+
required: required,
|
|
71
|
+
unique: unique,
|
|
72
|
+
value: value,
|
|
73
|
+
rules: validations,
|
|
74
|
+
messages: validationErrors,
|
|
75
|
+
multiple: multiple,
|
|
76
|
+
delimiter: delimiter,
|
|
77
|
+
valueField: valueField,
|
|
78
|
+
labelField: labelField,
|
|
79
|
+
joinValues: joinValues,
|
|
80
|
+
extractValue: extractValue,
|
|
81
|
+
selectFirst: selectFirst,
|
|
82
|
+
autoFill: autoFill,
|
|
83
|
+
clearValueOnHidden: clearValueOnHidden,
|
|
84
|
+
validateApi: validateApi,
|
|
85
|
+
minLength: minLength,
|
|
86
|
+
maxLength: maxLength,
|
|
87
|
+
validateOnChange: validateOnChange,
|
|
88
|
+
label: label
|
|
89
|
+
});
|
|
90
|
+
// issue 这个逻辑应该在 combo 里面自己实现。
|
|
91
|
+
if (_this.model.unique &&
|
|
92
|
+
((_a = form === null || form === void 0 ? void 0 : form.parentStore) === null || _a === void 0 ? void 0 : _a.storeType) === combo.ComboStore.name) {
|
|
93
|
+
var combo$1 = form.parentStore;
|
|
94
|
+
combo$1.bindUniuqueItem(model);
|
|
95
|
+
}
|
|
96
|
+
if (propValue !== undefined && propValue !== null) {
|
|
97
|
+
// 同步 value: 优先使用 props 中的 value
|
|
98
|
+
model.changeTmpValue(propValue);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// 备注: 此处的 value 是 schema 中的 value(和props.defaultValue相同)
|
|
102
|
+
var curTmpValue = formula.isExpression(value)
|
|
103
|
+
? formula.FormulaExec['formula'](value, data) // 对组件默认值进行运算
|
|
104
|
+
: (_b = store === null || store === void 0 ? void 0 : store.getValueByName(model.name)) !== null && _b !== void 0 ? _b : formula.replaceExpression(value); // 优先使用公式表达式
|
|
105
|
+
// 同步 value
|
|
106
|
+
model.changeTmpValue(curTmpValue);
|
|
107
|
+
if (onChange &&
|
|
108
|
+
value !== undefined &&
|
|
109
|
+
curTmpValue !== undefined) {
|
|
110
|
+
// 组件默认值支持表达式需要: 避免初始化时上下文中丢失组件默认值
|
|
111
|
+
onChange(model.tmpValue, model.name, false, true);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (onChange &&
|
|
115
|
+
typeof propValue === 'undefined' &&
|
|
116
|
+
typeof (store === null || store === void 0 ? void 0 : store.getValueByName(model.name, false)) === 'undefined' &&
|
|
117
|
+
// todo 后续再优化这个判断,
|
|
118
|
+
// 目前 input-table 中默认值会给冲掉,所以加上这个判断
|
|
119
|
+
// 对应 issue 为 https://github.com/baidu/amis/issues/2674
|
|
120
|
+
(store === null || store === void 0 ? void 0 : store.storeType) !== table.TableStore.name) {
|
|
121
|
+
// 如果没有初始值,通过 onChange 设置过去
|
|
122
|
+
onChange(model.tmpValue, model.name, false, true);
|
|
123
|
+
}
|
|
124
|
+
return _this;
|
|
125
|
+
}
|
|
126
|
+
class_1.prototype.componentDidMount = function () {
|
|
127
|
+
var _this = this;
|
|
128
|
+
var _a = this.props; _a.store; _a.formStore; var _b = _a.$schema, name = _b.name, validate = _b.validate, addHook = _a.addHook;
|
|
129
|
+
// 提交前先把之前的 lazyEmit 执行一下。
|
|
130
|
+
this.hook3 = function () {
|
|
131
|
+
_this.lazyEmitChange.flush();
|
|
132
|
+
};
|
|
133
|
+
addHook === null || addHook === void 0 ? void 0 : addHook(this.hook3, 'flush');
|
|
134
|
+
var formItem = this.model;
|
|
135
|
+
if (formItem && validate) {
|
|
136
|
+
var finalValidate_1 = helper.promisify(validate.bind(formItem));
|
|
137
|
+
this.hook2 = function () {
|
|
138
|
+
formItem.clearError('control:valdiate');
|
|
139
|
+
return finalValidate_1(_this.props.data, _this.getValue(), name).then(function (ret) {
|
|
140
|
+
if ((typeof ret === 'string' || Array.isArray(ret)) && ret) {
|
|
141
|
+
formItem.addError(ret, 'control:valdiate');
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
addHook === null || addHook === void 0 ? void 0 : addHook(this.hook2);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
class_1.prototype.componentDidUpdate = function (prevProps) {
|
|
149
|
+
var props = this.props;
|
|
150
|
+
props.formStore;
|
|
151
|
+
var model = this.model;
|
|
152
|
+
if (model &&
|
|
153
|
+
helper.anyChanged([
|
|
154
|
+
'id',
|
|
155
|
+
'validations',
|
|
156
|
+
'validationErrors',
|
|
157
|
+
'value',
|
|
158
|
+
'defaultValue',
|
|
159
|
+
'required',
|
|
160
|
+
'unique',
|
|
161
|
+
'multiple',
|
|
162
|
+
'delimiter',
|
|
163
|
+
'valueField',
|
|
164
|
+
'labelField',
|
|
165
|
+
'joinValues',
|
|
166
|
+
'extractValue',
|
|
167
|
+
'selectFirst',
|
|
168
|
+
'autoFill',
|
|
169
|
+
'clearValueOnHidden',
|
|
170
|
+
'validateApi',
|
|
171
|
+
'minLength',
|
|
172
|
+
'maxLength',
|
|
173
|
+
'label'
|
|
174
|
+
], prevProps.$schema, props.$schema)) {
|
|
175
|
+
model.config({
|
|
176
|
+
required: props.$schema.required,
|
|
177
|
+
id: props.$schema.id,
|
|
178
|
+
unique: props.$schema.unique,
|
|
179
|
+
value: props.$schema.value,
|
|
180
|
+
rules: props.$schema.validations,
|
|
181
|
+
multiple: props.$schema.multiple,
|
|
182
|
+
delimiter: props.$schema.delimiter,
|
|
183
|
+
valueField: props.$schema.valueField,
|
|
184
|
+
labelField: props.$schema.labelField,
|
|
185
|
+
joinValues: props.$schema.joinValues,
|
|
186
|
+
extractValue: props.$schema.extractValue,
|
|
187
|
+
messages: props.$schema.validationErrors,
|
|
188
|
+
selectFirst: props.$schema.selectFirst,
|
|
189
|
+
autoFill: props.$schema.autoFill,
|
|
190
|
+
clearValueOnHidden: props.$schema.clearValueOnHidden,
|
|
191
|
+
validateApi: props.$schema.validateApi,
|
|
192
|
+
minLength: props.$schema.minLength,
|
|
193
|
+
maxLength: props.$schema.maxLength,
|
|
194
|
+
label: props.$schema.label
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
// 此处需要同时考虑 defaultValue 和 value
|
|
198
|
+
if (model && typeof props.value !== 'undefined') {
|
|
199
|
+
// 渲染器中的 value 优先
|
|
200
|
+
if (props.value !== prevProps.value &&
|
|
201
|
+
props.value !== model.tmpValue) {
|
|
202
|
+
// 外部直接传入的 value 无需执行运算器
|
|
203
|
+
model.changeTmpValue(props.value);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else if (model &&
|
|
207
|
+
typeof props.defaultValue !== 'undefined' &&
|
|
208
|
+
formula.isExpression(props.defaultValue)) {
|
|
209
|
+
// 渲染器中的 defaultValue 优先(备注: SchemaRenderer中会将 value 改成 defaultValue)
|
|
210
|
+
if (props.defaultValue !== prevProps.defaultValue ||
|
|
211
|
+
(!isEqual__default["default"](props.data, prevProps.data) &&
|
|
212
|
+
formula.isNeedFormula(props.defaultValue, props.data, prevProps.data))) {
|
|
213
|
+
var curResult = formula.FormulaExec['formula'](props.defaultValue, props.data);
|
|
214
|
+
var prevResult = formula.FormulaExec['formula'](prevProps.defaultValue, prevProps.data);
|
|
215
|
+
if (curResult !== prevResult && curResult !== model.tmpValue) {
|
|
216
|
+
// 识别上下文变动、自身数值变动、公式运算结果变动
|
|
217
|
+
model.changeTmpValue(curResult);
|
|
218
|
+
if (props.onChange) {
|
|
219
|
+
props.onChange(curResult, model.name, false);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else if (model) {
|
|
225
|
+
var valueByName = getVariable.getVariable(props.data, model.name);
|
|
226
|
+
if (valueByName !== undefined &&
|
|
227
|
+
props.defaultValue === prevProps.defaultValue) {
|
|
228
|
+
// value 非公式表达式时,name 值优先,若 defaultValue 主动变动时,则使用 defaultValue
|
|
229
|
+
if (
|
|
230
|
+
// 然后才是查看关联的 name 属性值是否变化
|
|
231
|
+
props.data !== prevProps.data &&
|
|
232
|
+
(!model.emitedValue || model.emitedValue === model.tmpValue)) {
|
|
233
|
+
model.changeEmitedValue(undefined);
|
|
234
|
+
var prevValueByName = getVariable.getVariable(props.data, model.name);
|
|
235
|
+
if ((valueByName !== prevValueByName ||
|
|
236
|
+
getVariable.getVariable(props.data, model.name, false) !==
|
|
237
|
+
getVariable.getVariable(prevProps.data, model.name, false)) &&
|
|
238
|
+
valueByName !== model.tmpValue) {
|
|
239
|
+
model.changeTmpValue(valueByName);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
else if (typeof props.defaultValue !== 'undefined' &&
|
|
244
|
+
props.defaultValue !== prevProps.defaultValue &&
|
|
245
|
+
props.defaultValue !== model.tmpValue) {
|
|
246
|
+
// 组件默认值非公式
|
|
247
|
+
var curValue = formula.replaceExpression(props.defaultValue);
|
|
248
|
+
model.changeTmpValue(curValue);
|
|
249
|
+
if (props.onChange) {
|
|
250
|
+
props.onChange(curValue, model.name, false);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
class_1.prototype.componentWillUnmount = function () {
|
|
256
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
257
|
+
this.hook && ((_b = (_a = this.props).removeHook) === null || _b === void 0 ? void 0 : _b.call(_a, this.hook));
|
|
258
|
+
this.hook2 && ((_d = (_c = this.props).removeHook) === null || _d === void 0 ? void 0 : _d.call(_c, this.hook2));
|
|
259
|
+
this.hook3 && ((_f = (_e = this.props).removeHook) === null || _f === void 0 ? void 0 : _f.call(_e, this.hook3, 'flush'));
|
|
260
|
+
// this.lazyEmitChange.flush();
|
|
261
|
+
this.lazyEmitChange.cancel();
|
|
262
|
+
(_g = this.reaction) === null || _g === void 0 ? void 0 : _g.call(this);
|
|
263
|
+
this.disposeModel();
|
|
264
|
+
};
|
|
265
|
+
class_1.prototype.disposeModel = function () {
|
|
266
|
+
var _a;
|
|
267
|
+
var _b = this.props, form = _b.formStore, formItem = _b.formItem, rootStore = _b.rootStore;
|
|
268
|
+
if (this.model &&
|
|
269
|
+
this.model.unique &&
|
|
270
|
+
(form === null || form === void 0 ? void 0 : form.parentStore) &&
|
|
271
|
+
(form === null || form === void 0 ? void 0 : form.parentStore.storeType) === combo.ComboStore.name) {
|
|
272
|
+
var combo$1 = form.parentStore;
|
|
273
|
+
combo$1.unBindUniuqueItem(this.model);
|
|
274
|
+
}
|
|
275
|
+
if (this.model) {
|
|
276
|
+
formItem &&
|
|
277
|
+
mobxStateTree.isAlive(formItem) &&
|
|
278
|
+
formItem.removeSubFormItem(this.model);
|
|
279
|
+
this.model.clearValueOnHidden &&
|
|
280
|
+
((_a = this.model.form) === null || _a === void 0 ? void 0 : _a.deleteValueByName(this.model.name));
|
|
281
|
+
mobxStateTree.isAlive(rootStore) && rootStore.removeStore(this.model);
|
|
282
|
+
}
|
|
283
|
+
delete this.model;
|
|
284
|
+
};
|
|
285
|
+
class_1.prototype.controlRef = function (control) {
|
|
286
|
+
var _this = this;
|
|
287
|
+
var _a = this.props, addHook = _a.addHook, removeHook = _a.removeHook; _a.formStore; var name = _a.$schema.name;
|
|
288
|
+
// 因为 control 有可能被 n 层 hoc 包裹。
|
|
289
|
+
while (control && control.getWrappedInstance) {
|
|
290
|
+
control = control.getWrappedInstance();
|
|
291
|
+
}
|
|
292
|
+
if (control && control.validate && this.model) {
|
|
293
|
+
var formItem_1 = this.model;
|
|
294
|
+
var validate_1 = helper.promisify(control.validate.bind(control));
|
|
295
|
+
this.hook = function () {
|
|
296
|
+
formItem_1.clearError('component:valdiate');
|
|
297
|
+
return validate_1(_this.props.data, _this.getValue(), name).then(function (ret) {
|
|
298
|
+
if ((typeof ret === 'string' || Array.isArray(ret)) &&
|
|
299
|
+
ret) {
|
|
300
|
+
formItem_1.setError(ret, 'component:valdiate');
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
};
|
|
304
|
+
addHook === null || addHook === void 0 ? void 0 : addHook(this.hook);
|
|
305
|
+
}
|
|
306
|
+
else if (!control && this.hook) {
|
|
307
|
+
removeHook === null || removeHook === void 0 ? void 0 : removeHook(this.hook);
|
|
308
|
+
this.hook = undefined;
|
|
309
|
+
}
|
|
310
|
+
// 注册到 Scoped 上
|
|
311
|
+
var originRef = this.control;
|
|
312
|
+
this.control = control;
|
|
313
|
+
var scoped = this.context;
|
|
314
|
+
if (control) {
|
|
315
|
+
scoped.registerComponent(this.control);
|
|
316
|
+
}
|
|
317
|
+
else if (originRef) {
|
|
318
|
+
scoped.unRegisterComponent(originRef);
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
class_1.prototype.validate = function () {
|
|
322
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
323
|
+
var _a, form, data, formItemDispatchEvent, result, combo$1, group, validPromises, validPromises;
|
|
324
|
+
return tslib.__generator(this, function (_b) {
|
|
325
|
+
switch (_b.label) {
|
|
326
|
+
case 0:
|
|
327
|
+
_a = this.props, form = _a.formStore, data = _a.data, formItemDispatchEvent = _a.formItemDispatchEvent;
|
|
328
|
+
if (!this.model) return [3 /*break*/, 4];
|
|
329
|
+
if (!(this.model.unique &&
|
|
330
|
+
(form === null || form === void 0 ? void 0 : form.parentStore) &&
|
|
331
|
+
form.parentStore.storeType === combo.ComboStore.name)) return [3 /*break*/, 2];
|
|
332
|
+
combo$1 = form.parentStore;
|
|
333
|
+
group = combo$1.uniques.get(this.model.name);
|
|
334
|
+
validPromises = group.items.map(function (item) {
|
|
335
|
+
return item.validate(data);
|
|
336
|
+
});
|
|
337
|
+
return [4 /*yield*/, Promise.all(validPromises)];
|
|
338
|
+
case 1:
|
|
339
|
+
result = _b.sent();
|
|
340
|
+
return [3 /*break*/, 4];
|
|
341
|
+
case 2:
|
|
342
|
+
validPromises = form === null || form === void 0 ? void 0 : form.getItemsByName(this.model.name).map(function (item) { return item.validate(data); });
|
|
343
|
+
if (!(validPromises && validPromises.length)) return [3 /*break*/, 4];
|
|
344
|
+
return [4 /*yield*/, Promise.all(validPromises)];
|
|
345
|
+
case 3:
|
|
346
|
+
result = _b.sent();
|
|
347
|
+
_b.label = 4;
|
|
348
|
+
case 4:
|
|
349
|
+
if (result && result.length) {
|
|
350
|
+
if (result.indexOf(false) > -1) {
|
|
351
|
+
formItemDispatchEvent('formItemValidateError', data);
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
formItemDispatchEvent('formItemValidateSucc', data);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return [2 /*return*/];
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
class_1.prototype.handleChange = function (value, submitOnChange, changeImmediately) {
|
|
363
|
+
if (submitOnChange === void 0) { submitOnChange = this.props.$schema.submitOnChange; }
|
|
364
|
+
if (changeImmediately === void 0) { changeImmediately = false; }
|
|
365
|
+
var _a = this.props; _a.formStore; var onChange = _a.onChange, _b = _a.$schema, type = _b.type, pipeOut = _b.pipeOut, conrolChangeImmediately = _b.changeImmediately, formInited = _a.formInited, data = _a.data;
|
|
366
|
+
if (!this.model ||
|
|
367
|
+
// todo 以后想办法不要強耦合类型。
|
|
368
|
+
~[
|
|
369
|
+
'service',
|
|
370
|
+
'group',
|
|
371
|
+
'hbox',
|
|
372
|
+
'panel',
|
|
373
|
+
'grid',
|
|
374
|
+
'input-group'
|
|
375
|
+
].indexOf(type)) {
|
|
376
|
+
onChange && onChange.apply(null, arguments);
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
if (pipeOut) {
|
|
380
|
+
var oldValue = this.model.value;
|
|
381
|
+
value = pipeOut(value, oldValue, data);
|
|
382
|
+
}
|
|
383
|
+
this.model.changeTmpValue(value);
|
|
384
|
+
if (changeImmediately || conrolChangeImmediately || !formInited) {
|
|
385
|
+
this.emitChange(submitOnChange);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
// this.props.onTmpValueChange?.(value, this.model.name);
|
|
389
|
+
this.lazyEmitChange(submitOnChange);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
class_1.prototype.emitChange = function (submitOnChange) {
|
|
393
|
+
var _a;
|
|
394
|
+
if (submitOnChange === void 0) { submitOnChange = this.props.$schema.submitOnChange; }
|
|
395
|
+
var _b = this.props, form = _b.formStore, onChange = _b.onChange, _c = _b.$schema, name = _c.name, id = _c.id, label = _c.label, type = _c.type, onFormItemChange = _c.onChange; _c.maxLength; _c.minLength; var data = _b.data, env = _b.env, validateOnChange = _b.validateOnChange, formSubmited = _b.formSubmited;
|
|
396
|
+
if (!this.model) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
var value = this.model.tmpValue;
|
|
400
|
+
var oldValue = getVariable.getVariable(data, this.model.name, false);
|
|
401
|
+
if (oldValue === value) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (type !== 'input-password') {
|
|
405
|
+
env === null || env === void 0 ? void 0 : env.tracker({
|
|
406
|
+
eventType: 'formItemChange',
|
|
407
|
+
eventData: {
|
|
408
|
+
id: id,
|
|
409
|
+
name: name,
|
|
410
|
+
label: label,
|
|
411
|
+
type: type,
|
|
412
|
+
value: value
|
|
413
|
+
}
|
|
414
|
+
}, this.props);
|
|
415
|
+
}
|
|
416
|
+
this.model.changeEmitedValue(value);
|
|
417
|
+
if ((onFormItemChange === null || onFormItemChange === void 0 ? void 0 : onFormItemChange(value, oldValue, this.model, form)) === false) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
var validated = this.model.validated;
|
|
421
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, submitOnChange === true);
|
|
422
|
+
if (
|
|
423
|
+
// 如果配置了 minLength 或者 maxLength 就切成及时验证
|
|
424
|
+
// this.model.rules.minLength ||
|
|
425
|
+
// this.model.rules.maxLength ||
|
|
426
|
+
validateOnChange === true ||
|
|
427
|
+
(validateOnChange !== false && (formSubmited || validated))) {
|
|
428
|
+
this.validate();
|
|
429
|
+
}
|
|
430
|
+
else if (validateOnChange === false) {
|
|
431
|
+
(_a = this.model) === null || _a === void 0 ? void 0 : _a.reset();
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
class_1.prototype.handleBlur = function (e) {
|
|
435
|
+
var _a = this.props, onBlur = _a.onBlur, validateOnBlur = _a.$schema.validateOnBlur;
|
|
436
|
+
if (validateOnBlur && this.model) {
|
|
437
|
+
this.validate();
|
|
438
|
+
}
|
|
439
|
+
onBlur && onBlur(e);
|
|
440
|
+
};
|
|
441
|
+
class_1.prototype.setPrinstineValue = function (value) {
|
|
442
|
+
if (!this.model) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
var _a = this.props; _a.formStore; var name = _a.name, pipeOut = _a.$schema.pipeOut, onChange = _a.onChange, oldValue = _a.value, data = _a.data;
|
|
446
|
+
if (pipeOut) {
|
|
447
|
+
value = pipeOut(value, oldValue, data);
|
|
448
|
+
}
|
|
449
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, false, true);
|
|
450
|
+
};
|
|
451
|
+
class_1.prototype.getValue = function () {
|
|
452
|
+
var _a = this.props, data = _a.formStore, control = _a.$schema;
|
|
453
|
+
var value = this.model ? this.model.tmpValue : control.value;
|
|
454
|
+
if (control.pipeIn) {
|
|
455
|
+
value = control.pipeIn(value, data);
|
|
456
|
+
}
|
|
457
|
+
return value;
|
|
458
|
+
};
|
|
459
|
+
// 兼容老版本用法,新版本直接用 onChange 就可以。
|
|
460
|
+
class_1.prototype.setValue = function (value, key) {
|
|
461
|
+
var _a;
|
|
462
|
+
var _b = this.props, name = _b.$schema.name, onBulkChange = _b.onBulkChange;
|
|
463
|
+
if (!key || key === name) {
|
|
464
|
+
this.handleChange(value);
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
onBulkChange &&
|
|
468
|
+
onBulkChange((_a = {},
|
|
469
|
+
_a[key] = value,
|
|
470
|
+
_a));
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
class_1.prototype.render = function () {
|
|
474
|
+
var _a = this.props, controlWidth = _a.controlWidth, disabled = _a.disabled, formMode = _a.formMode, control = _a.$schema, store = _a.store, data = _a.data, invisible = _a.invisible;
|
|
475
|
+
if (invisible) {
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
478
|
+
var value = this.getValue();
|
|
479
|
+
var model = this.model;
|
|
480
|
+
var injectedProps = {
|
|
481
|
+
defaultSize: controlWidth,
|
|
482
|
+
disabled: disabled !== null && disabled !== void 0 ? disabled : control.disabled,
|
|
483
|
+
formItem: this.model,
|
|
484
|
+
formMode: control.mode || formMode,
|
|
485
|
+
ref: this.controlRef,
|
|
486
|
+
data: data || (store === null || store === void 0 ? void 0 : store.data),
|
|
487
|
+
value: value,
|
|
488
|
+
defaultValue: control.value,
|
|
489
|
+
formItemValue: value,
|
|
490
|
+
onChange: this.handleChange,
|
|
491
|
+
onBlur: this.handleBlur,
|
|
492
|
+
setValue: this.setValue,
|
|
493
|
+
getValue: this.getValue,
|
|
494
|
+
prinstine: model ? model.prinstine : undefined,
|
|
495
|
+
setPrinstineValue: this.setPrinstineValue
|
|
496
|
+
};
|
|
497
|
+
return (React__default["default"].createElement(ComposedComponent, tslib.__assign({}, this.props, injectedProps)));
|
|
498
|
+
};
|
|
499
|
+
return class_1;
|
|
500
|
+
}(React__default["default"].Component)),
|
|
501
|
+
_a.contextType = Scoped.ScopedContext,
|
|
502
|
+
_a.defaultProps = {},
|
|
503
|
+
_a))), ComposedComponent);
|
|
504
|
+
return result;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
exports.wrapControl = wrapControl;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RendererEnv } from './env';
|
|
3
|
+
import { RendererProps } from './factory';
|
|
4
|
+
import { TranslateFn } from './locale';
|
|
5
|
+
import { IRendererStore } from './store';
|
|
6
|
+
import { SchemaNode } from './types';
|
|
7
|
+
export interface RootRenderProps {
|
|
8
|
+
location?: Location;
|
|
9
|
+
theme?: string;
|
|
10
|
+
[propName: string]: any;
|
|
11
|
+
}
|
|
12
|
+
export interface RootProps {
|
|
13
|
+
schema: SchemaNode;
|
|
14
|
+
rootStore: IRendererStore;
|
|
15
|
+
env: RendererEnv;
|
|
16
|
+
theme: string;
|
|
17
|
+
pathPrefix?: string;
|
|
18
|
+
locale?: string;
|
|
19
|
+
translate?: TranslateFn;
|
|
20
|
+
[propName: string]: any;
|
|
21
|
+
}
|
|
22
|
+
export declare class Root extends React.Component<RootProps> {
|
|
23
|
+
resolveDefinitions(name: string): {} | undefined;
|
|
24
|
+
render(): JSX.Element;
|
|
25
|
+
}
|
|
26
|
+
export interface renderChildProps extends Partial<RendererProps> {
|
|
27
|
+
env: RendererEnv;
|
|
28
|
+
}
|
|
29
|
+
export declare type ReactElement = React.ReactNode[] | JSX.Element | null | false;
|
|
30
|
+
export declare function renderChildren(prefix: string, node: SchemaNode, props: renderChildProps): ReactElement;
|
|
31
|
+
export declare function renderChild(prefix: string, node: SchemaNode, props: renderChildProps): ReactElement;
|
|
32
|
+
declare const _default: React.ComponentType<RootProps & {
|
|
33
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
34
|
+
}> & {
|
|
35
|
+
ComposedComponent: React.ComponentType<RootProps>;
|
|
36
|
+
};
|
|
37
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RootProps } from './Root';
|
|
3
|
+
import { IScopedContext } from './Scoped';
|
|
4
|
+
import { IRootStore } from './store/root';
|
|
5
|
+
import { Action } from './types';
|
|
6
|
+
export interface RootRendererProps extends RootProps {
|
|
7
|
+
location?: any;
|
|
8
|
+
render: (region: string, schema: any, props: any) => React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare class RootRenderer extends React.Component<RootRendererProps> {
|
|
11
|
+
store: IRootStore;
|
|
12
|
+
static contextType: React.Context<IScopedContext>;
|
|
13
|
+
constructor(props: RootRendererProps);
|
|
14
|
+
componentDidMount(): void;
|
|
15
|
+
componentDidUpdate(prevProps: RootRendererProps): void;
|
|
16
|
+
componentDidCatch(error: any, errorInfo: any): void;
|
|
17
|
+
componentWillUnmount(): void;
|
|
18
|
+
handlePageVisibilityChange(): void;
|
|
19
|
+
handleAction(e: React.UIEvent<any> | void, action: Action, ctx: object, throwErrors?: boolean, delegate?: IScopedContext): void;
|
|
20
|
+
handleDialogConfirm(values: object[], action: Action, ...args: Array<any>): void;
|
|
21
|
+
handleDialogClose(confirmed?: boolean): void;
|
|
22
|
+
handleDrawerConfirm(values: object[], action: Action, ...args: Array<any>): void;
|
|
23
|
+
handleDrawerClose(): void;
|
|
24
|
+
openFeedback(dialog: any, ctx: any): Promise<unknown>;
|
|
25
|
+
reloadTarget(scoped: IScopedContext, target: string, data?: any): void;
|
|
26
|
+
render(): React.ReactNode;
|
|
27
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RendererConfig, RendererEnv, RendererProps } from './factory';
|
|
3
|
+
import { Schema, SchemaNode } from './types';
|
|
4
|
+
import { RendererEvent } from './utils/renderer-event';
|
|
5
|
+
interface SchemaRendererProps extends Partial<RendererProps> {
|
|
6
|
+
schema: Schema;
|
|
7
|
+
$path: string;
|
|
8
|
+
env: RendererEnv;
|
|
9
|
+
}
|
|
10
|
+
export declare class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
|
11
|
+
static displayName: string;
|
|
12
|
+
static contextType: React.Context<import("./Scoped").IScopedContext>;
|
|
13
|
+
rendererKey: string;
|
|
14
|
+
renderer: RendererConfig | null;
|
|
15
|
+
ref: any;
|
|
16
|
+
cRef: any;
|
|
17
|
+
schema: any;
|
|
18
|
+
path: string;
|
|
19
|
+
reaction: any;
|
|
20
|
+
unbindEvent: (() => void) | undefined;
|
|
21
|
+
constructor(props: SchemaRendererProps);
|
|
22
|
+
componentDidMount(): void;
|
|
23
|
+
componentWillUnmount(): void;
|
|
24
|
+
shouldComponentUpdate(nextProps: SchemaRendererProps): boolean;
|
|
25
|
+
resolveRenderer(props: SchemaRendererProps, force?: boolean): any;
|
|
26
|
+
getWrappedInstance(): any;
|
|
27
|
+
refFn(ref: any): void;
|
|
28
|
+
childRef(ref: any): void;
|
|
29
|
+
dispatchEvent(e: React.MouseEvent<any>, data: any): Promise<RendererEvent<any> | void>;
|
|
30
|
+
renderChild(region: string, node?: SchemaNode, subProps?: {
|
|
31
|
+
data?: object;
|
|
32
|
+
[propName: string]: any;
|
|
33
|
+
}): JSX.Element;
|
|
34
|
+
reRender(): void;
|
|
35
|
+
render(): JSX.Element | null;
|
|
36
|
+
}
|
|
37
|
+
export {};
|