ant-design/components/input/demo/otp.tsx
二货爱吃白萝卜 100fa29bef
feat: Input.OTP component support (#48076)
* chore: basic control

* chore: input instad

* docs: update demo

* chore: adjust operation interactive

* chore: lock selection

* chore: fix patch logic

* chore: merge logic

* chore: patch autoFocus

* test: update snapshot

* test: add test case

* test: coverage

* chore: update size limit

* docs: update docs

* test: fix test case

* chore: update comment

* refactor: change to length

* chore: blur all

* chore: size limit
2024-03-28 14:05:58 +08:00

30 lines
809 B
TypeScript

import React from 'react';
import { Input, Space, Typography, type GetProp } from 'antd';
const { Title } = Typography;
const App: React.FC = () => {
const onChange: GetProp<typeof Input.OTP, 'onChange'> = (text) => {
console.log('onChange:', text);
};
const sharedProps = {
onChange,
};
return (
<Space direction="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} />
</Space>
);
};
export default App;