ant-design/components/input/demo/otp.tsx
lijianan 53cbceb7db
feat: Input.OTP support mask prop (#48257)
* feat: Input.OTP support mask prop

* fix: fix

* fix: fix

* test: add test case

* test: add test case

* chore: fix

* chore: update

* chore: remove

* chore: rename useOTPSingleValue

* fix: fix

* fix: fix

* chore: rm 3 lib

* chore: add 3 lib

* fix: fix

* fix: fix

* test: fix test case

* test: fix test case

* fix: fix

* fix: fix

---------

Signed-off-by: lijianan <574980606@qq.com>
2024-04-09 14:47:58 +08:00

34 lines
1020 B
TypeScript

import React from 'react';
import { Flex, Input, Typography } from 'antd';
import type { GetProp } from 'antd';
import type { OTPProps } from 'antd/es/input/OTP';
const { Title } = Typography;
const App: React.FC = () => {
const onChange: GetProp<typeof Input.OTP, 'onChange'> = (text) => {
console.log('onChange:', text);
};
const sharedProps: OTPProps = {
onChange,
};
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;