muba-input-text 3.0.4 → 4.1.2
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 +25 -3
- 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 +4 -4
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,
|
@@ -57,6 +58,11 @@ export default class InputText extends React.Component {
|
|
57
58
|
this.setState({ fontLoaded: true });
|
58
59
|
}
|
59
60
|
|
61
|
+
isValidUrl(url) {
|
62
|
+
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 !pattern.test(url);
|
64
|
+
}
|
65
|
+
|
60
66
|
onSubmitValidate() {
|
61
67
|
this.setState({
|
62
68
|
fieldError: false,
|
@@ -64,18 +70,32 @@ export default class InputText extends React.Component {
|
|
64
70
|
onlyNumbersError: false,
|
65
71
|
minValueError: false,
|
66
72
|
maxValueError: false,
|
67
|
-
emailBadFormat: false
|
73
|
+
emailBadFormat: false,
|
74
|
+
urlAllowingError: false
|
68
75
|
});
|
69
76
|
|
77
|
+
let result = true;
|
70
78
|
if (this.props.required && (this.props.value == null || this.props.value.toString().trim() === '')) {
|
71
79
|
if (this.props.scroll) {
|
72
80
|
this.props.scroll(this.inputTextView);
|
73
81
|
}
|
74
82
|
|
75
83
|
this.setState({ fieldError: true, requiredError: true });
|
76
|
-
|
84
|
+
result = false;
|
85
|
+
} else {
|
86
|
+
if (this.props.notUrl) {
|
87
|
+
result = this.isValidUrl(this.props.value);
|
88
|
+
|
89
|
+
if (!result) {
|
90
|
+
this.showError();
|
91
|
+
this.setState({ urlAllowingError: true });
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
result = this.validateType() && result;
|
77
96
|
}
|
78
|
-
|
97
|
+
|
98
|
+
return result;
|
79
99
|
}
|
80
100
|
|
81
101
|
showError() {
|
@@ -162,6 +182,7 @@ export default class InputText extends React.Component {
|
|
162
182
|
minValueError: false,
|
163
183
|
maxValueError: false,
|
164
184
|
emailBadFormat: false,
|
185
|
+
urlAllowingError: false,
|
165
186
|
customizedError: false,
|
166
187
|
customizedErrorMessage: undefined
|
167
188
|
});
|
@@ -208,6 +229,7 @@ export default class InputText extends React.Component {
|
|
208
229
|
{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
230
|
{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
231
|
{this.state.emailBadFormat && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('emailBadFormat')}</OutputText> : null}
|
232
|
+
{this.state.urlAllowingError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('urlAllowingError')}</OutputText> : null}
|
211
233
|
{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
234
|
{this.state.customizedError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {this.state.customizedErrorMessage}</OutputText> : null}
|
213
235
|
</View>
|
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
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "muba-input-text",
|
3
|
-
"version": "
|
3
|
+
"version": "4.1.2",
|
4
4
|
"description": "Input text",
|
5
5
|
"main": "InputText.js",
|
6
6
|
"scripts": {
|
@@ -17,8 +17,8 @@
|
|
17
17
|
},
|
18
18
|
"homepage": "https://github.com/Mubawab/muba-input-text#readme",
|
19
19
|
"dependencies": {
|
20
|
-
"muba-font": "
|
21
|
-
"muba-i18n": "
|
22
|
-
"muba-output-text": "
|
20
|
+
"muba-font": "4",
|
21
|
+
"muba-i18n": "4",
|
22
|
+
"muba-output-text": "4"
|
23
23
|
}
|
24
24
|
}
|