UNPKG

victory-core

Version:
69 lines 1.76 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(props.style, props); const tabIndex = Helpers.evaluateProp(props.tabIndex, props); return Object.assign({}, props, { ariaLabel, desc, id, style, tabIndex }); }; const defaultProps = { groupComponent: /*#__PURE__*/React.createElement("g", null), lineComponent: /*#__PURE__*/React.createElement(Line, null), role: "presentation", shapeRendering: "auto" }; export const Whisker = initialProps => { const props = evaluateProps(defaults({}, initialProps, defaultProps)); const { ariaLabel, groupComponent, lineComponent, events, className, majorWhisker, minorWhisker, transform, clipPath, role, shapeRendering, style, desc, tabIndex } = props; const baseProps = { ...events, style, desc, tabIndex, className, transform, clipPath, role, shapeRendering }; return /*#__PURE__*/React.cloneElement(groupComponent, {}, [/*#__PURE__*/React.cloneElement(lineComponent, Object.assign({ key: "major-whisker", "aria-label": ariaLabel }, baseProps, majorWhisker)), /*#__PURE__*/React.cloneElement(lineComponent, Object.assign({ key: "minor-whisker", "aria-label": ariaLabel }, baseProps, minorWhisker))]); };