Skip to content

Commit a38ca89

Browse files
committed
chore: support naming
1 parent 8f5de3f commit a38ca89

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

src/InputNumber.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const getDecimalIfValidate = (value: ValueType) => {
5555
return decimal.isInvalidate() ? null : decimal;
5656
};
5757

58-
type SemanticName = 'actions' | 'input';
58+
type SemanticName = 'actions' | 'input' | 'action';
5959
export interface InputNumberProps<T extends ValueType = ValueType>
6060
extends Omit<
6161
React.InputHTMLAttributes<HTMLInputElement>,
@@ -593,18 +593,28 @@ const InternalInputNumber = React.forwardRef(
593593

594594
// ============================ Render ============================
595595
// >>>>>> Handler
596+
const sharedHandlerProps = {
597+
prefixCls,
598+
onStep: onInternalStep,
599+
className: classNames?.action,
600+
style: styles?.action,
601+
};
602+
596603
const upNode = (
597-
<StepHandler action="up" prefixCls={prefixCls} disabled={upDisabled} onStep={onInternalStep}>
604+
<StepHandler
605+
{...sharedHandlerProps}
606+
action="up"
607+
disabled={upDisabled}
608+
>
598609
{upHandler}
599610
</StepHandler>
600611
);
601612

602613
const downNode = (
603614
<StepHandler
615+
{...sharedHandlerProps}
604616
action="down"
605-
prefixCls={prefixCls}
606617
disabled={downDisabled}
607-
onStep={onInternalStep}
608618
>
609619
{downHandler}
610620
</StepHandler>

src/StepHandler.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export interface StepHandlerProps {
1818
action: 'up' | 'down';
1919
children?: React.ReactNode;
2020
disabled?: boolean;
21+
className?: string;
22+
style?: React.CSSProperties;
2123
onStep: (up: boolean, emitter: 'handler' | 'keyboard' | 'wheel') => void;
2224
}
2325

@@ -26,6 +28,8 @@ export default function StepHandler({
2628
action,
2729
children,
2830
disabled,
31+
className,
32+
style,
2933
onStep,
3034
}: StepHandlerProps) {
3135
// ======================== MISC ========================
@@ -70,9 +74,14 @@ export default function StepHandler({
7074
// ======================= Render =======================
7175
const handlerClassName = `${prefixCls}-handler`;
7276

73-
const className = clsx(handlerClassName, `${handlerClassName}-${action}`, {
74-
[`${handlerClassName}-${action}-disabled`]: disabled,
75-
});
77+
const mergedClassName = clsx(
78+
handlerClassName,
79+
`${handlerClassName}-${action}`,
80+
{
81+
[`${handlerClassName}-${action}-disabled`]: disabled,
82+
},
83+
className
84+
);
7685

7786
// fix: https://github.com/ant-design/ant-design/issues/43088
7887
// In Safari, When we fire onmousedown and onmouseup events in quick succession,
@@ -96,7 +105,8 @@ export default function StepHandler({
96105
}}
97106
aria-label={isUpAction ? 'Increase Value' : 'Decrease Value'}
98107
aria-disabled={disabled}
99-
className={className}
108+
className={mergedClassName}
109+
style={style}
100110
>
101111
{children || <span unselectable="on" className={`${prefixCls}-handler-${action}-inner`} />}
102112
</span>

0 commit comments

Comments
 (0)