UNPKG

data-vis-ui

Version:

## [使用文档](https://temp-static-domain.jd.com/data-vis-ui)

104 lines (89 loc) 4.8 kB
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } import { __rest } from "tslib"; import React from 'react'; var Box = function Box(props) { var _props$width = props.width, width = _props$width === void 0 ? '100%' : _props$width, _props$height = props.height, height = _props$height === void 0 ? '100%' : _props$height, children = props.children, background = props.background, _props$marks = props.marks, marks = _props$marks === void 0 ? [] : _props$marks, _props$lines = props.lines, lines = _props$lines === void 0 ? [] : _props$lines, style = props.style, args = __rest(props, ["width", "height", "children", "background", "marks", "lines", "style"]); var boxStyle = { position: 'relative', width: width, height: height, background: typeof background === 'string' ? "url(".concat(background, ")") : background, backgroundSize: '100% 100%', backgroundRepeat: 'no-repeat', backgroundOrigin: 'center', boxSizing: 'border-box' }; var getMarkStyle = function getMarkStyle(background) { return { background: typeof background === 'string' ? "url(".concat(background, ")") : background, backgroundSize: '100% 100%', backgroundRepeat: 'no-repeat', backgroundOrigin: 'center', position: 'absolute' }; }; return /*#__PURE__*/React.createElement("div", Object.assign({ style: Object.assign(Object.assign({}, boxStyle), style) }, args), marks.map(function (item, index) { var background = item.background, node = item.node, markStyle = item.style, className = item.className, args = __rest(item, ["background", "node", "style", "className"]); return /*#__PURE__*/React.createElement("div", { style: Object.assign(Object.assign(Object.assign({}, getMarkStyle(background)), args), markStyle), className: className, key: index }, node); }), lines.length > 0 && /*#__PURE__*/React.createElement("svg", { width: width, height: height }, lines.map(function (item, index) { var _item$coords = item.coords, coords = _item$coords === void 0 ? [] : _item$coords, _item$width = item.width, lineWidth = _item$width === void 0 ? 1 : _item$width, _item$color = item.color, color = _item$color === void 0 ? '#000' : _item$color, _item$dasharray = item.dasharray, dasharray = _item$dasharray === void 0 ? '' : _item$dasharray, args = __rest(item, ["coords", "width", "color", "dasharray"]); var _coords$ = _slicedToArray(coords[0], 2), _coords$$ = _coords$[0], x1 = _coords$$ === void 0 ? 0 : _coords$$, _coords$$2 = _coords$[1], y1 = _coords$$2 === void 0 ? 0 : _coords$$2; var _coords$2 = _slicedToArray(coords[1], 2), _coords$2$ = _coords$2[0], x2 = _coords$2$ === void 0 ? 0 : _coords$2$, _coords$2$2 = _coords$2[1], y2 = _coords$2$2 === void 0 ? 0 : _coords$2$2; return /*#__PURE__*/React.createElement("line", Object.assign({ key: index, x1: x1, y1: y1, x2: x2, y2: y2, stroke: color, strokeWidth: lineWidth, strokeDasharray: dasharray }, args)); })), children); }; export default Box;