mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 13:18:04 +08:00
34c28a6ac1
* feat(input-otp): add onInput api for otp * feat(input-otp): add test case * fix: test case error * docs: add release version * docs: add release version * docs: update en-US document release version * Update components/input/index.zh-CN.md Co-authored-by: lijianan <574980606@qq.com> Signed-off-by: Jony J <82765353+aojunhao123@users.noreply.github.com> * docs: update docs * feat: modify onInput parameter type * test: fix test case * docs: update docs * docs: update docs --------- Signed-off-by: Jony J <82765353+aojunhao123@users.noreply.github.com> Co-authored-by: lijianan <574980606@qq.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
import { Flex, Input, Typography } from 'antd';
|
|
import type { GetProps } from 'antd';
|
|
|
|
type OTPProps = GetProps<typeof Input.OTP>;
|
|
|
|
const { Title } = Typography;
|
|
|
|
const App: React.FC = () => {
|
|
const onChange: OTPProps['onChange'] = (text) => {
|
|
console.log('onChange:', text);
|
|
};
|
|
|
|
const onInput: OTPProps['onInput'] = (value) => {
|
|
console.log('onInput:', value);
|
|
};
|
|
|
|
const sharedProps: OTPProps = {
|
|
onChange,
|
|
onInput,
|
|
};
|
|
|
|
return (
|
|
<Flex gap="middle" align="flex-start" vertical>
|
|
<Title level={5}>With formatter (Upcase)</Title>
|
|
<Input.OTP formatter={(str) => str.toUpperCase()} {...sharedProps} />
|
|
<Title level={5}>With Disabled</Title>
|
|
<Input.OTP disabled {...sharedProps} />
|
|
<Title level={5}>With Length (8)</Title>
|
|
<Input.OTP length={8} {...sharedProps} />
|
|
<Title level={5}>With variant</Title>
|
|
<Input.OTP variant="filled" {...sharedProps} />
|
|
<Title level={5}>With custom display character</Title>
|
|
<Input.OTP mask="🔒" {...sharedProps} />
|
|
</Flex>
|
|
);
|
|
};
|
|
|
|
export default App;
|