@alilc/lowcode-shell
Version:
Shell Layer for AliLowCodeEngine
131 lines (120 loc) • 3.9 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.Props = void 0;
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _lowcodeDesigner = require("@alilc/lowcode-designer");
var _symbols = require("../symbols");
var _node = require("./node");
var _prop = require("./prop");
var Props = exports.Props = /*#__PURE__*/function () {
function Props(props) {
this[_symbols.propsSymbol] = void 0;
this[_symbols.propsSymbol] = props;
}
Props.create = function create(props) {
if (!props) {
return null;
}
return new Props(props);
}
/**
* id
*/;
var _proto = Props.prototype;
/**
* 获取指定 path 的属性模型实例
* @param path 属性路径,支持 a / a.b / a.0 等格式
* @returns
*/
_proto.getProp = function getProp(path) {
return _prop.Prop.create(this[_symbols.propsSymbol].getProp(path));
}
/**
* 获取指定 path 的属性模型实例值
* @param path 属性路径,支持 a / a.b / a.0 等格式
* @returns
*/;
_proto.getPropValue = function getPropValue(path) {
var _this$getProp;
return (_this$getProp = this.getProp(path)) === null || _this$getProp === void 0 ? void 0 : _this$getProp.getValue();
}
/**
* 获取指定 path 的属性模型实例,
* 注:导出时,不同于普通属性,该属性并不挂载在 props 之下,而是与 props 同级
* @param path 属性路径,支持 a / a.b / a.0 等格式
* @returns
*/;
_proto.getExtraProp = function getExtraProp(path) {
return _prop.Prop.create(this[_symbols.propsSymbol].getProp((0, _lowcodeDesigner.getConvertedExtraKey)(path)));
}
/**
* 获取指定 path 的属性模型实例值
* 注:导出时,不同于普通属性,该属性并不挂载在 props 之下,而是与 props 同级
* @param path 属性路径,支持 a / a.b / a.0 等格式
* @returns
*/;
_proto.getExtraPropValue = function getExtraPropValue(path) {
var _this$getExtraProp;
return (_this$getExtraProp = this.getExtraProp(path)) === null || _this$getExtraProp === void 0 ? void 0 : _this$getExtraProp.getValue();
}
/**
* 设置指定 path 的属性模型实例值
* @param path 属性路径,支持 a / a.b / a.0 等格式
* @param value 值
* @returns
*/;
_proto.setPropValue = function setPropValue(path, value) {
var _this$getProp2;
return (_this$getProp2 = this.getProp(path)) === null || _this$getProp2 === void 0 ? void 0 : _this$getProp2.setValue(value);
}
/**
* 设置指定 path 的属性模型实例值
* @param path 属性路径,支持 a / a.b / a.0 等格式
* @param value 值
* @returns
*/;
_proto.setExtraPropValue = function setExtraPropValue(path, value) {
var _this$getExtraProp2;
return (_this$getExtraProp2 = this.getExtraProp(path)) === null || _this$getExtraProp2 === void 0 ? void 0 : _this$getExtraProp2.setValue(value);
}
/**
* test if the specified key is existing or not.
* @param key
* @returns
*/;
_proto.has = function has(key) {
return this[_symbols.propsSymbol].has(key);
}
/**
* add a key with given value
* @param value
* @param key
* @returns
*/;
_proto.add = function add(value, key) {
return this[_symbols.propsSymbol].add(value, key);
};
return (0, _createClass2["default"])(Props, [{
key: "id",
get: function get() {
return this[_symbols.propsSymbol].id;
}
/**
* 返回当前 props 的路径
*/
}, {
key: "path",
get: function get() {
return this[_symbols.propsSymbol].path;
}
/**
* 返回所属的 node 实例
*/
}, {
key: "node",
get: function get() {
return _node.Node.create(this[_symbols.propsSymbol].getNode());
}
}]);
}();
;