|
@@ -18,10 +18,13 @@ export interface FillStepProps {
|
|
|
stepNumber?: string;
|
|
|
onChange?: () => void;
|
|
|
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
|
+ onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
|
+ "role"?: React.AriaRole;
|
|
|
+ "aria-label"?: React.AriaAttributes["aria-label"];
|
|
|
}
|
|
|
|
|
|
const FillStep = (props: FillStepProps) => {
|
|
|
- const { prefixCls, className, title, description, status, style, onClick, icon, onChange, stepNumber } = props;
|
|
|
+ const { prefixCls, className, title, description, status, style, onClick, icon, onChange, stepNumber, onKeyDown } = props;
|
|
|
const renderIcon = () => {
|
|
|
let inner, progress;
|
|
|
|
|
@@ -51,10 +54,10 @@ const FillStep = (props: FillStepProps) => {
|
|
|
}
|
|
|
}
|
|
|
const cls = classnames({
|
|
|
- [`${prefixCls }-left`]: true,
|
|
|
- [`${prefixCls }-icon`]: 'icon' in props,
|
|
|
- [`${prefixCls }-plain`]: !('icon' in props),
|
|
|
- [`${prefixCls }-icon-process`]: progress,
|
|
|
+ [`${prefixCls}-left`]: true,
|
|
|
+ [`${prefixCls}-icon`]: 'icon' in props,
|
|
|
+ [`${prefixCls}-plain`]: !('icon' in props),
|
|
|
+ [`${prefixCls}-icon-process`]: progress,
|
|
|
});
|
|
|
|
|
|
return inner ? <div className={cls}>{inner}</div> : null;
|
|
@@ -65,26 +68,38 @@ const FillStep = (props: FillStepProps) => {
|
|
|
}
|
|
|
onChange();
|
|
|
};
|
|
|
+ const handleKeyDown = (e) => {
|
|
|
+ if (e.key === 'Enter') {
|
|
|
+ if (isFunction(onKeyDown)) {
|
|
|
+ onKeyDown(e);
|
|
|
+ }
|
|
|
+ onChange();
|
|
|
+ }
|
|
|
+ };
|
|
|
return (
|
|
|
<div
|
|
|
+ role={props["role"]}
|
|
|
+ aria-label={props["aria-label"]}
|
|
|
+ aria-current="step"
|
|
|
+ tabIndex={0}
|
|
|
className={classnames({
|
|
|
- [className]: Boolean(className),
|
|
|
[prefixCls]: true,
|
|
|
[`${prefixCls}-${status}`]: Boolean(status),
|
|
|
- [`${prefixCls }-clickable`]: onClick,
|
|
|
- })}
|
|
|
+ [`${prefixCls}-clickable`]: onClick,
|
|
|
+ }, className)}
|
|
|
style={style}
|
|
|
onClick={e => {
|
|
|
handleClick(e);
|
|
|
}}
|
|
|
+ onKeyDown={handleKeyDown}
|
|
|
>
|
|
|
{renderIcon()}
|
|
|
- <div className={`${prefixCls }-content`}>
|
|
|
- <div className={`${prefixCls }-title`} title={typeof title === 'string' ? title : null}>
|
|
|
- <span className={`${prefixCls }-title-text`}>{title}</span>
|
|
|
+ <div className={`${prefixCls}-content`}>
|
|
|
+ <div className={`${prefixCls}-title`} title={typeof title === 'string' ? title : null}>
|
|
|
+ <span className={`${prefixCls}-title-text`}>{title}</span>
|
|
|
</div>
|
|
|
<div
|
|
|
- className={`${prefixCls }-description`}
|
|
|
+ className={`${prefixCls}-description`}
|
|
|
title={typeof description === 'string' ? description : null}
|
|
|
>
|
|
|
{description}
|