Rect.js 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. var __assign = (this && this.__assign) || function () {
  3. __assign = Object.assign || function(t) {
  4. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5. s = arguments[i];
  6. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  7. t[p] = s[p];
  8. }
  9. return t;
  10. };
  11. return __assign.apply(this, arguments);
  12. };
  13. Object.defineProperty(exports, "__esModule", { value: true });
  14. var core_1 = require("@logicflow/core");
  15. // TODO: 默认样式引入
  16. function Rect(props) {
  17. var x = props.x, y = props.y, width = props.width, height = props.height, radius = props.radius, className = props.className;
  18. var leftTopX = x - width / 2;
  19. var leftTopY = y - height / 2;
  20. var attrs = __assign(__assign({
  21. // default
  22. width: 10, height: 10, cx: 0, cy: 0, rx: radius || 0, ry: radius || 0, fill: 'transparent', fillOpacity: 1, strokeWidth: '1px', stroke: '#000', strokeOpacity: 1, className: "lf-basic-shape " + className }, props), { x: leftTopX, y: leftTopY });
  23. return (core_1.h("rect", __assign({}, attrs)));
  24. }
  25. exports.default = Rect;
  26. Rect.defaultProps = {
  27. radius: 0,
  28. stroke: '',
  29. strokeDasharray: '',
  30. className: '',
  31. };