muba-input-text 4.0.0 → 4.1.3
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 +30 -5
- package/locales/ar.json +2 -1
- package/locales/en.json +2 -1
- package/locales/es.json +2 -1
- package/locales/fr.json +2 -1
- package/locales/it.json +2 -1
- package/locales/nl.json +2 -1
- package/package.json +1 -1
package/InputText.js
CHANGED
@@ -35,6 +35,7 @@ export default class InputText extends React.Component {
|
|
35
35
|
minValueError: false,
|
36
36
|
maxValueError: false,
|
37
37
|
emailBadFormat: false,
|
38
|
+
urlAllowingError: false,
|
38
39
|
customizedError: false,
|
39
40
|
customizedErrorMessage: undefined,
|
40
41
|
inputFont: props.inputFont,
|
@@ -55,6 +56,15 @@ export default class InputText extends React.Component {
|
|
55
56
|
}
|
56
57
|
]);
|
57
58
|
this.setState({ fontLoaded: true });
|
59
|
+
|
60
|
+
if (this.props.autoFocus) {
|
61
|
+
setTimeout(() => this.input.focus(), 100);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
isValidUrl(url) {
|
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');
|
67
|
+
return !pattern.test(url);
|
58
68
|
}
|
59
69
|
|
60
70
|
onSubmitValidate() {
|
@@ -64,18 +74,32 @@ export default class InputText extends React.Component {
|
|
64
74
|
onlyNumbersError: false,
|
65
75
|
minValueError: false,
|
66
76
|
maxValueError: false,
|
67
|
-
emailBadFormat: false
|
77
|
+
emailBadFormat: false,
|
78
|
+
urlAllowingError: false
|
68
79
|
});
|
69
80
|
|
81
|
+
let result = true;
|
70
82
|
if (this.props.required && (this.props.value == null || this.props.value.toString().trim() === '')) {
|
71
83
|
if (this.props.scroll) {
|
72
84
|
this.props.scroll(this.inputTextView);
|
73
85
|
}
|
74
86
|
|
75
87
|
this.setState({ fieldError: true, requiredError: true });
|
76
|
-
|
88
|
+
result = false;
|
89
|
+
} else {
|
90
|
+
if (this.props.notUrl) {
|
91
|
+
result = this.isValidUrl(this.props.value);
|
92
|
+
|
93
|
+
if (!result) {
|
94
|
+
this.showError();
|
95
|
+
this.setState({ urlAllowingError: true });
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
result = this.validateType() && result;
|
77
100
|
}
|
78
|
-
|
101
|
+
|
102
|
+
return result;
|
79
103
|
}
|
80
104
|
|
81
105
|
showError() {
|
@@ -162,6 +186,7 @@ export default class InputText extends React.Component {
|
|
162
186
|
minValueError: false,
|
163
187
|
maxValueError: false,
|
164
188
|
emailBadFormat: false,
|
189
|
+
urlAllowingError: false,
|
165
190
|
customizedError: false,
|
166
191
|
customizedErrorMessage: undefined
|
167
192
|
});
|
@@ -208,6 +233,7 @@ export default class InputText extends React.Component {
|
|
208
233
|
{this.state.maxValueError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('maxValueError', { maxValue: this.props.maxValue })}</OutputText> : null}
|
209
234
|
{this.state.minValueError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('minValueError', { minValue: this.props.minValue })}</OutputText> : null}
|
210
235
|
{this.state.emailBadFormat && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('emailBadFormat')}</OutputText> : null}
|
236
|
+
{this.state.urlAllowingError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('urlAllowingError')}</OutputText> : null}
|
211
237
|
{this.state.maxCharacters && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('maxCharacters', { maxCharacters: this.props.maxCharacters })}</OutputText> : null}
|
212
238
|
{this.state.customizedError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {this.state.customizedErrorMessage}</OutputText> : null}
|
213
239
|
</View>
|
@@ -236,8 +262,7 @@ export default class InputText extends React.Component {
|
|
236
262
|
selection={this.props.selection}
|
237
263
|
selectionColor={this.props.selectionColor}
|
238
264
|
numberOfLines={this.props.numberOfLines}
|
239
|
-
maxLength={this.props.maxLength}
|
240
|
-
autoFocus={this.props.autoFocus} />
|
265
|
+
maxLength={this.props.maxLength} />
|
241
266
|
{this.props.children}
|
242
267
|
|
243
268
|
{this.props.value != null && !this.props.hideCancel ?
|
package/locales/ar.json
CHANGED
@@ -4,5 +4,6 @@
|
|
4
4
|
"minValueError": "الحد الأدنى للقيمة المسموح بها هو {{minValue}}",
|
5
5
|
"maxValueError": "الحد الأقصى للقيمة المسموح بها هو {{maxValue}}",
|
6
6
|
"emailBadFormat": "رجاء قم بإدخال بريد إكتروني صحيح",
|
7
|
-
"maxCharacters": "الحد الأقصى للحروف {{maxCharacters}}"
|
7
|
+
"maxCharacters": "الحد الأقصى للحروف {{maxCharacters}}",
|
8
|
+
"urlAllowingError": "غير مسموح بإدخال عناوين URL"
|
8
9
|
}
|
package/locales/en.json
CHANGED
@@ -4,5 +4,6 @@
|
|
4
4
|
"minValueError": "The minimum value allowed is {{minValue}}",
|
5
5
|
"maxValueError": "The maximum value allowed is {{maxValue}}",
|
6
6
|
"emailBadFormat": "Please enter a valid email address",
|
7
|
-
"maxCharacters": "{{maxCharacters}} characters max."
|
7
|
+
"maxCharacters": "{{maxCharacters}} characters max.",
|
8
|
+
"urlAllowingError": "It is not allowed to enter URL's"
|
8
9
|
}
|
package/locales/es.json
CHANGED
@@ -4,5 +4,6 @@
|
|
4
4
|
"minValueError": "El valor mínimo permitido es {{minValue}}",
|
5
5
|
"maxValueError": "El valor máximo permitido es {{maxValue}}",
|
6
6
|
"emailBadFormat": "Por favor, introduce una dirección de correo electrónico válida",
|
7
|
-
"maxCharacters": "{{maxCharacters}} caracteres máx."
|
7
|
+
"maxCharacters": "{{maxCharacters}} caracteres máx.",
|
8
|
+
"urlAllowingError": "No está permitido introducir URL's"
|
8
9
|
}
|
package/locales/fr.json
CHANGED
@@ -4,5 +4,6 @@
|
|
4
4
|
"minValueError": "La valeur minimale autorisée est {{minValue}}",
|
5
5
|
"maxValueError": "La valeur maximale autorisée est {{maxValue}}",
|
6
6
|
"emailBadFormat": "S'il vous plaît, mettez une adresse email valide",
|
7
|
-
"maxCharacters": "{{maxCharacters}} caractères max."
|
7
|
+
"maxCharacters": "{{maxCharacters}} caractères max.",
|
8
|
+
"urlAllowingError": "Il n'est pas permis d'entrer des URL"
|
8
9
|
}
|
package/locales/it.json
CHANGED
@@ -4,5 +4,6 @@
|
|
4
4
|
"minValueError": "Il valore minimo permesso è {{minValue}}",
|
5
5
|
"maxValueError": "Il valore massimo permesso è {{maxValue}}",
|
6
6
|
"emailBadFormat": "Inserisci un indirizzo e-mail valido",
|
7
|
-
"maxCharacters": "{{maxCharacters}} caratteri massimi"
|
7
|
+
"maxCharacters": "{{maxCharacters}} caratteri massimi",
|
8
|
+
"urlAllowingError": "Non è permesso inserire URL"
|
8
9
|
}
|
package/locales/nl.json
CHANGED
@@ -4,5 +4,6 @@
|
|
4
4
|
"minValueError": "De minimale toegestane waarde is {minValue}}",
|
5
5
|
"maxValueError": "De maximale toegestane waarde is {maxValue}}",
|
6
6
|
"emailBadFormat": "Voer een geldig e-mailadres in",
|
7
|
-
"maxCharacters": "Maximaal {{maxCharacters} tekens"
|
7
|
+
"maxCharacters": "Maximaal {{maxCharacters} tekens",
|
8
|
+
"urlAllowingError": "Het is niet toegestaan URL's in te voeren"
|
8
9
|
}
|