UNPKG

@ant-design/pro-flow

Version:
124 lines 4.95 kB
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } import { zoomNum } from "../BasicNode"; import { SelectType } from "../FlowView/constants"; import { getClsFromSelectType } from "../utils"; import { cx } from 'antd-style'; import React from 'react'; import { Handle, Position } from 'reactflow'; import { useStyles } from "./styles"; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; var convertMappingNode = function convertMappingNode(nodeList) { return nodeList.map(function (_node) { return _objectSpread(_objectSpread({}, _node), {}, { type: 'default', flowNodeType: 'BasicNode' }); }); }; var GroupItem = function GroupItem(node) { var _useStyles = useStyles(), styles = _useStyles.styles; var id = node.id, title = node.title, des = node.des, logo = node.logo; return /*#__PURE__*/_jsxs("div", { className: styles.groupItemWrap, children: [/*#__PURE__*/_jsx("img", { src: logo, alt: "" }), /*#__PURE__*/_jsxs("div", { className: styles.groupItemContent, children: [/*#__PURE__*/_jsx("div", { className: styles.groupItemTitle, children: title }), /*#__PURE__*/_jsx("div", { className: styles.des, children: des })] })] }, "".concat(id, "-").concat(title)); }; var BasicNodeGroup = function BasicNodeGroup(_ref) { var data = _ref.data; var _useStyles2 = useStyles(), styles = _useStyles2.styles; var _data$handleType = data.handleType, handleType = _data$handleType === void 0 ? 'both' : _data$handleType, _data$selectType = data.selectType, selectType = _data$selectType === void 0 ? SelectType.SELECT : _data$selectType, _data$zoom = data.zoom, zoom = _data$zoom === void 0 ? 1 : _data$zoom, label = data.label, _data = data.data; if (_data.length < 5) { return /*#__PURE__*/_jsx("div", { className: styles.groupWrap, children: "\u6570\u7EC4\u957F\u5EA6\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E5\uFF01" }); } var nodeList = convertMappingNode(_data); return /*#__PURE__*/_jsxs("div", { style: { width: '357px', height: '632px', position: 'relative' }, children: [handleType === 'output' || handleType === 'both' ? /*#__PURE__*/_jsx(Handle, { type: "target", position: Position.Left, style: { top: 41.5, left: -6 } }) : null, /*#__PURE__*/_jsxs("div", { children: [label && /*#__PURE__*/_jsx("div", { style: { position: 'absolute', zIndex: 10, transform: "translate(0, -".concat(zoomNum(20, zoom, true), "px) scale(").concat(1 / zoom, ")"), // top: `-${zoomNum(24, zoom, true)}px`, // padding: `${2 / zoom}px ${1 / zoom}px ${2 / zoom}px 0`, color: "rgba(0, 0, 0, 0.45)", borderRadius: "4px", // fontSize: `${14 / zoom}px`, fontSize: "".concat(14, "px"), whiteSpace: "nowrap" }, children: zoom <= 0.1 ? "".concat(String(label).substring(0, 3), "...") : label }), /*#__PURE__*/_jsxs("div", { className: cx(styles.groupWrap, styles[getClsFromSelectType(selectType)]), children: [nodeList.map(function (_node, index) { var data = _node.data; _node.position = { x: 0, y: 100 * index }; _node.title = data.title; _node.logo = data.logo; _node.des = data.description; return GroupItem(_node); }), /*#__PURE__*/_jsx("div", { className: "".concat(styles.btnWrap, " buttonWrap") }), /*#__PURE__*/_jsxs("div", { className: styles.btn, children: ["\u67E5\u770B\u66F4\u591A", /*#__PURE__*/_jsx("img", { src: "https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*W5bAS6ZOqOwAAAAAAAAAAAAADvuvAQ/original", alt: "" })] })] })] }), handleType === 'input' || handleType === 'both' ? /*#__PURE__*/_jsx(Handle, { type: "source", position: Position.Right, style: { top: 41.5, right: -6 } }) : null] }); }; export default BasicNodeGroup;