Skip to content

Commit 0eea9e5

Browse files
committed
✏️ Rename isSecure -> isInputSecure
1 parent 8831133 commit 0eea9e5

3 files changed

Lines changed: 35 additions & 23 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export default class App extends Component {
159159
<td>Restrict input to only numbers.</td>
160160
</tr>
161161
<tr>
162-
<td>isSecure</td>
162+
<td>isInputSecure</td>
163163
<td>boolean</td>
164164
<td>false</td>
165165
<td>false</td>

src/demo/index.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Demo extends Component {
1515
isDisabled: false,
1616
hasErrored: false,
1717
isInputNum: false,
18-
isSecure: false,
18+
isInputSecure: false,
1919
minLength: 0,
2020
maxLength: 40,
2121
placeholder: '',
@@ -66,7 +66,7 @@ class Demo extends Component {
6666
isDisabled,
6767
hasErrored,
6868
isInputNum,
69-
isSecure,
69+
isInputSecure,
7070
minLength,
7171
maxLength,
7272
placeholder,
@@ -172,15 +172,15 @@ class Demo extends Component {
172172
</label>
173173
</div>
174174
<div className="side-bar__segment">
175-
<label htmlFor="isSecure">
175+
<label htmlFor="isInputSecure">
176176
<input
177-
id="isSecure"
178-
name="isSecure"
177+
id="isInputSecure"
178+
name="isInputSecure"
179179
type="checkbox"
180-
checked={isSecure}
180+
checked={isInputSecure}
181181
onChange={this.handleCheck}
182182
/>
183-
isSecure
183+
isInputSecure
184184
</label>
185185
</div>
186186
<div className="side-bar__segment side-bar__segment--bottom">
@@ -203,7 +203,7 @@ class Demo extends Component {
203203
onChange={this.handleOtpChange}
204204
separator={<span>{separator}</span>}
205205
isInputNum={isInputNum}
206-
isSecure={isSecure}
206+
isInputSecure={isInputSecure}
207207
shouldAutoFocus
208208
value={otp}
209209
placeholder={placeholder}

src/lib/index.jsx

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Props = {
2424
isInputNum?: boolean,
2525
value?: string,
2626
className?: string,
27-
isSecure?: boolean
27+
isInputSecure?: boolean,
2828
};
2929

3030
type State = {
@@ -70,12 +70,18 @@ class SingleOtpInput extends PureComponent<*> {
7070

7171
getClasses = (...classes) =>
7272
classes.filter(c => !isStyleObject(c) && c !== false).join(' ');
73-
73+
7474
getType = () => {
75-
if (this.props.isSecure) return 'password'
76-
if (this.props.isInputNum) return 'tel'
77-
return 'text'
78-
}
75+
if (this.props.isInputSecure) {
76+
return 'password';
77+
}
78+
79+
if (this.props.isInputNum) {
80+
return 'tel';
81+
}
82+
83+
return 'text';
84+
};
7985

8086
render() {
8187
const {
@@ -94,7 +100,7 @@ class SingleOtpInput extends PureComponent<*> {
94100
index,
95101
value,
96102
className,
97-
isSecure,
103+
isInputSecure,
98104
...rest
99105
} = this.props;
100106

@@ -104,7 +110,9 @@ class SingleOtpInput extends PureComponent<*> {
104110
style={{ display: 'flex', alignItems: 'center' }}
105111
>
106112
<input
107-
aria-label={`${(index === 0) ? 'Please enter verification code. ' : ''}${isInputNum ? 'Digit' : 'Character'} ${index + 1}`}
113+
aria-label={`${
114+
index === 0 ? 'Please enter verification code. ' : ''
115+
}${isInputNum ? 'Digit' : 'Character'} ${index + 1}`}
108116
autoComplete="off"
109117
style={Object.assign(
110118
{ width: '1em', textAlign: 'center' },
@@ -142,7 +150,7 @@ class OtpInput extends Component<Props, State> {
142150
isDisabled: false,
143151
shouldAutoFocus: false,
144152
value: '',
145-
isSecure:false
153+
isInputSecure: false,
146154
};
147155

148156
state = {
@@ -161,7 +169,9 @@ class OtpInput extends Component<Props, State> {
161169
}
162170

163171
if (placeholder.length > 0) {
164-
console.error('Length of the placeholder should be equal to the number of inputs.');
172+
console.error(
173+
'Length of the placeholder should be equal to the number of inputs.'
174+
);
165175
}
166176
}
167177
};
@@ -306,12 +316,14 @@ class OtpInput extends Component<Props, State> {
306316
errorStyle,
307317
shouldAutoFocus,
308318
isInputNum,
309-
isSecure,
310-
className
319+
isInputSecure,
320+
className,
311321
} = this.props;
312-
const otp = this.getOtpValue();
322+
313323
const inputs = [];
324+
const otp = this.getOtpValue();
314325
const placeholder = this.getPlaceholderValue();
326+
315327
for (let i = 0; i < numInputs; i++) {
316328
inputs.push(
317329
<SingleOtpInput
@@ -339,7 +351,7 @@ class OtpInput extends Component<Props, State> {
339351
errorStyle={errorStyle}
340352
shouldAutoFocus={shouldAutoFocus}
341353
isInputNum={isInputNum}
342-
isSecure={isSecure}
354+
isInputSecure={isInputSecure}
343355
className={className}
344356
/>
345357
);

0 commit comments

Comments
 (0)