-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
81 lines (78 loc) · 2.04 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import styled from '@emotion/styled';
import { OtpInput } from '../src';
const Div = styled('div')({
marginBottom: '40px',
});
const App = () => {
const [value, setValue] = React.useState('');
const [value1, setValue1] = React.useState('');
const [value2, setValue2] = React.useState('');
const [value3, setValue3] = React.useState('');
const [value4, setValue4] = React.useState('');
const handleChange = (value: string, formattedValue: string) => {
setValue(value);
};
const handleChange1 = (value: string, formattedValue: string) => {
setValue1(value);
};
const handleChange2 = (value: string, formattedValue: string) => {
setValue2(value);
};
const handleChange3 = (value: string, formattedValue: string) => {
setValue3(value);
};
const handleChange4 = (value: string, formattedValue: string) => {
setValue4(value);
};
return (
<>
<Div>
<p>Numeric Input</p>
<OtpInput value={value} onChange={handleChange} format="_/_/_-_/_/_" />
</Div>
<Div>
<p>Alphanumeric Input</p>
<OtpInput
value={value1}
onChange={handleChange1}
format="___-___"
type="alphanumeric"
/>
</Div>
<Div>
<p>Password Numeric Input</p>
<OtpInput
value={value2}
onChange={handleChange2}
format="_/_-_/_-_/_"
type="numeric"
isSecure
/>
</Div>
<Div>
<p>Password Alphanumeric Input</p>
<OtpInput
value={value3}
onChange={handleChange3}
format="______"
type="alphanumeric"
isSecure
/>
</Div>
<Div>
<p>Disabled Input</p>
<OtpInput
value={value4}
onChange={handleChange4}
format="_-_-_-_-_-_"
type="alphanumeric"
isSecure
isDisabled
/>
</Div>
</>
);
};
ReactDOM.render(<App />, document.getElementById('root'));