import React from 'react'; import classNames from 'classnames'; /* !- Actions */ import { flush, tooltip } from '../layer/actions'; /* !- Compontents */ import Icon from './icon'; /* !- Constants */ import { ICON_WIDTH, ICON_HEIGHT, ICON_PADDING, ICON_ABS_WIDTH, LINE_WIDTH, CANVAS_PADDING_X, TEXT_PADDING_BOTTOM, TEXT_BOTTOM, } from './const'; /* !- Types */ import { IData } from './stepper'; export interface PropTypes extends Partial { index: number, isLabel: boolean, data: Partial[], className?: string, classNameText?: string, classNameLine?: string, iconWidth?: number, iconHeight?: number, iconPadding?: number, iconAbsWidth?: number, lineWidth?: number, canvasPaddingX?: number, textPaddingBottom?: number, textBottom?: number, } /** * Svg elments represents steps. Contains icon, label, lines and handling events */ export const Step: React.FC = ( { label, isLabel, status, icon, data, index, className = '', classNameText = '', classNameLine = '', onClick, iconWidth = ICON_WIDTH, iconHeight = ICON_HEIGHT, iconPadding = ICON_PADDING, iconAbsWidth = ICON_ABS_WIDTH, lineWidth = LINE_WIDTH, canvasPaddingX = CANVAS_PADDING_X, textPaddingBottom = TEXT_PADDING_BOTTOM, textBottom = TEXT_BOTTOM, }) => { const isFirst = index === 0; const isLast = data.length === (index + 1); const tranformX = Math.floor( ((index + 1) * iconPadding) + (index * (iconWidth + iconPadding + lineWidth)) + (canvasPaddingX * +isLabel) ); const StepIcon = icon || Icon; const classNameGroup = classNames({ pointer: onClick, 'no-child-events': tooltip, [className]: className, }); // const onMouseHandler = (event) => // { // if (props.tooltip) // { // store.dispatch(tooltip(props.tooltip, event)); // } // } // const onMouseOutHandler = (event) => // { // const { active, method } = store.getState().layer; // if (active && method === 'popover' && props.tooltip) // { // store.dispatch(flush()); // } // } return ( {/* status */} { typeof StepIcon !== 'function' ? StepIcon : } {/* label */} {label} {/* line */} { !isFirst && } ); } export default Step;