@alilc/lowcode-shell
Version:
Shell Layer for AliLowCodeEngine
126 lines (116 loc) • 3.63 kB
JavaScript
import _createClass from "@babel/runtime/helpers/createClass";
import { getConvertedExtraKey } from '@alilc/lowcode-designer';
import { propsSymbol } from '../symbols';
import { Node as ShellNode } from './node';
import { Prop as ShellProp } from './prop';
export var Props = /*#__PURE__*/function () {
function Props(props) {
this[propsSymbol] = void 0;
this[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 ShellProp.create(this[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 ShellProp.create(this[propsSymbol].getProp(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[propsSymbol].has(key);
}
/**
* add a key with given value
* @param value
* @param key
* @returns
*/;
_proto.add = function add(value, key) {
return this[propsSymbol].add(value, key);
};
return _createClass(Props, [{
key: "id",
get: function get() {
return this[propsSymbol].id;
}
/**
* 返回当前 props 的路径
*/
}, {
key: "path",
get: function get() {
return this[propsSymbol].path;
}
/**
* 返回所属的 node 实例
*/
}, {
key: "node",
get: function get() {
return ShellNode.create(this[propsSymbol].getNode());
}
}]);
}();