mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 12:39:49 +08:00
refactor: refactor InputNumber code (#49428)
This commit is contained in:
parent
6db789f772
commit
7769a40c72
@ -124,6 +124,19 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props,
|
||||
);
|
||||
const wrapperClassName = `${prefixCls}-group`;
|
||||
|
||||
const getAddon = (addon: React.ReactNode): React.ReactNode => {
|
||||
if (!addon) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<NoCompactStyle>
|
||||
<NoFormStyle override status>
|
||||
{addon}
|
||||
</NoFormStyle>
|
||||
</NoCompactStyle>
|
||||
);
|
||||
};
|
||||
|
||||
const element = (
|
||||
<RcInputNumber
|
||||
ref={inputRef}
|
||||
@ -136,31 +149,14 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props,
|
||||
controls={controlsTemp}
|
||||
prefix={prefix}
|
||||
suffix={suffixNode}
|
||||
addonAfter={
|
||||
addonAfter && (
|
||||
<NoCompactStyle>
|
||||
<NoFormStyle override status>
|
||||
{addonAfter}
|
||||
</NoFormStyle>
|
||||
</NoCompactStyle>
|
||||
)
|
||||
}
|
||||
addonBefore={
|
||||
addonBefore && (
|
||||
<NoCompactStyle>
|
||||
<NoFormStyle override status>
|
||||
{addonBefore}
|
||||
</NoFormStyle>
|
||||
</NoCompactStyle>
|
||||
)
|
||||
}
|
||||
addonBefore={getAddon(addonBefore)}
|
||||
addonAfter={getAddon(addonAfter)}
|
||||
classNames={{
|
||||
input: inputNumberClass,
|
||||
variant: classNames(
|
||||
{
|
||||
[`${prefixCls}-${variant}`]: enableVariantCls,
|
||||
},
|
||||
|
||||
getStatusClassNames(prefixCls, mergedStatus, hasFeedback),
|
||||
),
|
||||
affixWrapper: classNames(
|
||||
|
@ -171,7 +171,7 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
|
||||
</>
|
||||
);
|
||||
|
||||
const getAddon = (addon: React.ReactNode) =>
|
||||
const getAddon = (addon: React.ReactNode): React.ReactNode =>
|
||||
addon && (
|
||||
<NoCompactStyle>
|
||||
<NoFormStyle override status>
|
||||
|
@ -26,4 +26,5 @@ Input.Search = Search;
|
||||
Input.TextArea = TextArea;
|
||||
Input.Password = Password;
|
||||
Input.OTP = OTP;
|
||||
|
||||
export default Input;
|
||||
|
@ -101,7 +101,7 @@ const InternalPopover = React.forwardRef<TooltipRef, PopoverProps>((props, ref)
|
||||
data-popover-inject
|
||||
>
|
||||
{cloneElement(children, {
|
||||
onKeyDown: (e: React.KeyboardEvent<any>) => {
|
||||
onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => {
|
||||
if (React.isValidElement(children)) {
|
||||
children?.props.onKeyDown?.(e);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ export default function rootPropsTest(
|
||||
const componentNames = Array.isArray(component) ? component : [component];
|
||||
const [componentName, subComponentName] = componentNames;
|
||||
|
||||
const Component = require(`../../components/${componentName}`).default as any;
|
||||
const Component = require(`../../components/${componentName}`).default;
|
||||
const name = options?.name ? `(${options.name})` : '';
|
||||
|
||||
describe(`RootProps${name}`, () => {
|
||||
|
Loading…
Reference in New Issue
Block a user