@logicflow/react-node-registry
Version:
LogicFlow React Shape
65 lines • 2.89 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReactNodeModel = void 0;
var core_1 = require("@logicflow/core");
var lodash_es_1 = require("lodash-es");
var ReactNodeModel = /** @class */ (function (_super) {
__extends(ReactNodeModel, _super);
function ReactNodeModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
ReactNodeModel.prototype.setAttributes = function () {
var _a = this.properties, width = _a.width, height = _a.height, radius = _a.radius;
if (width) {
this.width = width;
}
if (height) {
this.height = height;
}
if (radius) {
this.radius = radius;
}
};
ReactNodeModel.prototype.getTextStyle = function () {
// const { x, y, width, height } = this
var _a = this.properties, _b = _a.refX, refX = _b === void 0 ? 0 : _b, _c = _a.refY, refY = _c === void 0 ? 0 : _c, textStyle = _a.textStyle;
var style = _super.prototype.getTextStyle.call(this);
// 通过 transform 重新设置 text 的位置
return __assign(__assign(__assign({}, style), ((0, lodash_es_1.cloneDeep)(textStyle) || {})), { transform: "matrix(1 0 0 1 ".concat(refX, " ").concat(refY, ")") });
};
ReactNodeModel.prototype.getNodeStyle = function () {
var style = _super.prototype.getNodeStyle.call(this);
var customNodeStyle = this.properties.style;
return __assign(__assign({}, style), ((0, lodash_es_1.cloneDeep)(customNodeStyle) || {}));
};
return ReactNodeModel;
}(core_1.HtmlNodeModel));
exports.ReactNodeModel = ReactNodeModel;
exports.default = ReactNodeModel;
//# sourceMappingURL=model.js.map
;