Created
April 26, 2022 06:30
-
-
Save tokisakiyuu/41a58bc1ca15ee6aae05b6de6b0b35f5 to your computer and use it in GitHub Desktop.
Solution for extend a typedef parameter in jsdoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @typedef {import('react').ReactNode} ReactNode | |
* @typedef {import('antd/lib/input-number').InputNumberProps} InputNumberProps | |
* @typedef {Object} AddonProps | |
* @property {ReactNode} addonAfter | |
* @property {ReactNode} addonBefore | |
* @typedef {InputNumberProps & AddonProps} InputNumberPropsWithAddon | |
*/ | |
import { Input, InputNumber, Button } from 'antd' | |
/** | |
* 弥补antd的InputNumber组件不支持addonAfter和addonBefore的问题 | |
* @param {InputNumberPropsWithAddon} param0 | |
* @returns | |
*/ | |
const InputNumberPlus = ({ addonAfter, addonBefore, ...rest }) => { | |
return ( | |
<Input.Group compact> | |
{addonBefore && <Addon>{addonAfter}</Addon>} | |
<InputNumber {...rest} /> | |
{addonAfter && <Addon>{addonAfter}</Addon>} | |
</Input.Group> | |
) | |
} | |
const Addon = ({ children }) => ( | |
<Button disabled style={{ color: 'black', cursor: 'default' }}>{children}</Button> | |
) | |
export default InputNumberPlus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment