1 line
12 KiB
JSON
1 line
12 KiB
JSON
|
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nvar _excluded = [\"className\", \"percent\", \"prefixCls\", \"strokeColor\", \"strokeLinecap\", \"strokeWidth\", \"style\", \"trailColor\", \"trailWidth\", \"transition\"];\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { useTransitionDuration, defaultProps } from \"./common\";\nvar Line = function Line(props) {\n var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),\n className = _defaultProps$props.className,\n percent = _defaultProps$props.percent,\n prefixCls = _defaultProps$props.prefixCls,\n strokeColor = _defaultProps$props.strokeColor,\n strokeLinecap = _defaultProps$props.strokeLinecap,\n strokeWidth = _defaultProps$props.strokeWidth,\n style = _defaultProps$props.style,\n trailColor = _defaultProps$props.trailColor,\n trailWidth = _defaultProps$props.trailWidth,\n transition = _defaultProps$props.transition,\n restProps = _objectWithoutProperties(_defaultProps$props, _excluded);\n\n // eslint-disable-next-line no-param-reassign\n delete restProps.gapPosition;\n var percentList = Array.isArray(percent) ? percent : [percent];\n var strokeColorList = Array.isArray(strokeColor) ? strokeColor : [strokeColor];\n var paths = useTransitionDuration();\n var center = strokeWidth / 2;\n var right = 100 - strokeWidth / 2;\n var pathString = \"M \".concat(strokeLinecap === 'round' ? center : 0, \",\").concat(center, \"\\n L \").concat(strokeLinecap === 'round' ? right : 100, \",\").concat(center);\n var viewBoxString = \"0 0 100 \".concat(strokeWidth);\n var stackPtg = 0;\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n className: classNames(\"\".concat(prefixCls, \"-line\"), className),\n viewBox: viewBoxString,\n preserveAspectRatio: \"none\",\n style: style\n }, restProps), /*#__PURE__*/React.createElement(\"path\", {\n className: \"\".concat(prefixCls, \"-line-trail\"),\n d: pathString,\n strokeLinecap: strokeLinecap,\n stroke: trailColor,\n strokeWidth: trailWidth || strokeWidth,\n fillOpacity: \"0\"\n }), percentList.map(function (ptg, index) {\n var dashPercent = 1;\n switch (strokeLinecap) {\n case 'round':\n dashPercent = 1 - strokeWidth / 100;\n break;\n case 'square':\n dashPercent = 1 - strokeWidth / 2 / 100;\n break;\n default:\n dashPercent = 1;\n break;\n }\n var pathStyle = {\n strokeDasharray: \"\".concat(ptg * dashPercent, \"px, 100px\"),\n strokeDashoffset: \"-\".concat(stackPtg, \"px\"),\n transition: transition || 'stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear'\n };\n var color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];\n stackPtg += ptg;\n return /*#__PURE__*/React.createElement(\"path\", {\n key: index,\n className: \"\".concat(prefixCls, \"-line-path\"),\n d: pathString,\n strokeLinecap: strokeLinecap,\n stroke: color,\n strokeWidth: strokeWidth,\n fillOpacity: \"0\",\n ref: function ref(elem) {\n // https://reactjs.org/docs/refs-and-the-dom.html#callback-refs\n // React will call the ref callback with the DOM element when the component mounts,\n // and call it with `null` when it unmounts.\n // Refs are guaranteed to be up-to-date before componentDidMount or componentDidUpdate fires.\n\n paths[index] = elem;\n },\n style: pathStyle\n });\n }));\n};\nif (process.env.NODE_ENV !== 'production') {\n Line.displayName = 'Line';\n}\nexport default Line;","map":{"version":3,"names":["_extends","_objectSpread","_objectWithoutProperties","_excluded","React","classNames","useTransitionDuration","defaultProps","Line","props","_defaultProps$props","className","perc
|