Rect.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. var __assign = (this && this.__assign) || function () {
  2. __assign = Object.assign || function(t) {
  3. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4. s = arguments[i];
  5. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  6. t[p] = s[p];
  7. }
  8. return t;
  9. };
  10. return __assign.apply(this, arguments);
  11. };
  12. import { h } from '@logicflow/core';
  13. // TODO: 默认样式引入
  14. export default function Rect(props) {
  15. var x = props.x, y = props.y, width = props.width, height = props.height, radius = props.radius, className = props.className;
  16. var leftTopX = x - width / 2;
  17. var leftTopY = y - height / 2;
  18. var attrs = __assign(__assign({
  19. // default
  20. 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 });
  21. return (h("rect", __assign({}, attrs)));
  22. }
  23. Rect.defaultProps = {
  24. radius: 0,
  25. stroke: '',
  26. strokeDasharray: '',
  27. className: '',
  28. };