UNPKG

victory-core

Version:
52 lines 1.43 kB
import React from "react"; import defaults from "lodash/defaults"; import * as Helpers from "../victory-util/helpers"; import { Line } from "./line"; const evaluateProps = props => { /** * Potential evaluated props are: * `ariaLabel` * `desc` * `id` * `style` * `tabIndex` */ const ariaLabel = Helpers.evaluateProp(props.ariaLabel, props); const desc = Helpers.evaluateProp(props.desc, props); const id = Helpers.evaluateProp(props.id, props); const style = Helpers.evaluateStyle(Object.assign({ stroke: "black" }, props.style), props); const tabIndex = Helpers.evaluateProp(props.tabIndex, props); return Object.assign({}, props, { ariaLabel, desc, id, style, tabIndex }); }; const defaultProps = { lineComponent: /*#__PURE__*/React.createElement(Line, null), role: "presentation", shapeRendering: "auto" }; export const LineSegment = initialProps => { const props = evaluateProps(defaults({}, initialProps, defaultProps)); return /*#__PURE__*/React.cloneElement(props.lineComponent, { ...props.events, "aria-label": props.ariaLabel, style: props.style, desc: props.desc, tabIndex: props.tabIndex, className: props.className, role: props.role, shapeRendering: props.shapeRendering, x1: props.x1, x2: props.x2, y1: props.y1, y2: props.y2, transform: props.transform, clipPath: props.clipPath }); };