muba-input-text 4.1.1 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/InputText.js +19 -5
- package/package.json +1 -1
package/InputText.js
CHANGED
@@ -56,11 +56,15 @@ export default class InputText extends React.Component {
|
|
56
56
|
}
|
57
57
|
]);
|
58
58
|
this.setState({ fontLoaded: true });
|
59
|
+
|
60
|
+
if (this.props.autoFocus) {
|
61
|
+
setTimeout(() => this.input.focus(), 100);
|
62
|
+
}
|
59
63
|
}
|
60
64
|
|
61
65
|
isValidUrl(url) {
|
62
66
|
const pattern = new RegExp('^(https?://)?(www\\.)?([-a-z0-9À-ú]{1,63}\\.)*?[a-z0-9À-ú][-a-z0-9À-ú]{0,61}[a-z0-9À-ú]\\.[a-zÀ-ú]{2,6}', 'i');
|
63
|
-
return
|
67
|
+
return !pattern.test(url);
|
64
68
|
}
|
65
69
|
|
66
70
|
onSubmitValidate() {
|
@@ -86,8 +90,10 @@ export default class InputText extends React.Component {
|
|
86
90
|
if (this.props.notUrl) {
|
87
91
|
result = this.isValidUrl(this.props.value);
|
88
92
|
|
89
|
-
|
90
|
-
|
93
|
+
if (!result) {
|
94
|
+
this.showError();
|
95
|
+
this.setState({ urlAllowingError: true });
|
96
|
+
}
|
91
97
|
}
|
92
98
|
|
93
99
|
result = this.validateType() && result;
|
@@ -109,6 +115,9 @@ export default class InputText extends React.Component {
|
|
109
115
|
}
|
110
116
|
|
111
117
|
validateType() {
|
118
|
+
if (this.props.value !== this.props.value?.trim()) {
|
119
|
+
this.onChangeText(this.props.value.trim())
|
120
|
+
}
|
112
121
|
if (this.props.type === 'email') {
|
113
122
|
return this.isValidEmail();
|
114
123
|
} else if (this.props.type === 'number') {
|
@@ -206,6 +215,12 @@ export default class InputText extends React.Component {
|
|
206
215
|
this.input.focus();
|
207
216
|
}
|
208
217
|
|
218
|
+
checkText = () => {
|
219
|
+
if (this.props.value !== this.props.value?.trim()) {
|
220
|
+
this.onChangeText(this.props.value.trim())
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
209
224
|
render() {
|
210
225
|
return (
|
211
226
|
this.state.fontLoaded ?
|
@@ -256,8 +271,7 @@ export default class InputText extends React.Component {
|
|
256
271
|
selection={this.props.selection}
|
257
272
|
selectionColor={this.props.selectionColor}
|
258
273
|
numberOfLines={this.props.numberOfLines}
|
259
|
-
maxLength={this.props.maxLength}
|
260
|
-
autoFocus={this.props.autoFocus} />
|
274
|
+
maxLength={this.props.maxLength} />
|
261
275
|
{this.props.children}
|
262
276
|
|
263
277
|
{this.props.value != null && !this.props.hideCancel ?
|