@formily/core
Version:
English | [简体中文](./README.zh-cn.md)
43 lines (42 loc) • 1.43 kB
JavaScript
;
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
var model_1 = require("../shared/model");
var shared_1 = require("@formily/shared");
exports.VirtualFieldState = model_1.createStateModel((_a = (function () {
function VirtualFieldState(state, props) {
this.state = state;
this.path = shared_1.FormPath.getPath(props.nodePath);
this.dataPath = shared_1.FormPath.getPath(props.dataPath);
this.state.path = this.path.entire;
this.state.name = this.dataPath.entire;
}
VirtualFieldState.prototype.computeState = function (draft, prevState) {
if (draft.mounted === true && draft.mounted !== prevState.mounted) {
draft.unmounted = false;
}
if (!shared_1.isValid(draft.props)) {
draft.props = prevState.props;
}
if (draft.unmounted === true && draft.unmounted !== prevState.unmounted) {
draft.mounted = false;
}
};
return VirtualFieldState;
}()),
_a.displayName = 'VirtualFieldState',
_a.defaultState = {
name: '',
path: '',
initialized: false,
visible: true,
display: true,
mounted: false,
unmounted: false,
props: {}
},
_a.defaultProps = {
path: '',
props: {}
},
_a));