muba-input-text 3.0.3 → 4.1.1
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 -4
- 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,30 @@ 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
|
+
this.showError();
|
90
|
+
this.setState({ urlAllowingError: true });
|
91
|
+
}
|
92
|
+
|
93
|
+
result = this.validateType() && result;
|
77
94
|
}
|
78
|
-
|
95
|
+
|
96
|
+
return result;
|
79
97
|
}
|
80
98
|
|
81
99
|
showError() {
|
@@ -114,7 +132,8 @@ export default class InputText extends React.Component {
|
|
114
132
|
return false;
|
115
133
|
} else {
|
116
134
|
const pattern = new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])", 'i');
|
117
|
-
const
|
135
|
+
const patternSpaces = new RegExp(/\s/);
|
136
|
+
const success = !!pattern.test(this.props.value) && !patternSpaces.test(this.props.value);
|
118
137
|
|
119
138
|
if (!success) {
|
120
139
|
// It's invalid
|
@@ -161,6 +180,7 @@ export default class InputText extends React.Component {
|
|
161
180
|
minValueError: false,
|
162
181
|
maxValueError: false,
|
163
182
|
emailBadFormat: false,
|
183
|
+
urlAllowingError: false,
|
164
184
|
customizedError: false,
|
165
185
|
customizedErrorMessage: undefined
|
166
186
|
});
|
@@ -207,6 +227,7 @@ export default class InputText extends React.Component {
|
|
207
227
|
{this.state.maxValueError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('maxValueError', { maxValue: this.props.maxValue })}</OutputText> : null}
|
208
228
|
{this.state.minValueError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('minValueError', { minValue: this.props.minValue })}</OutputText> : null}
|
209
229
|
{this.state.emailBadFormat && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('emailBadFormat')}</OutputText> : null}
|
230
|
+
{this.state.urlAllowingError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('urlAllowingError')}</OutputText> : null}
|
210
231
|
{this.state.maxCharacters && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('maxCharacters', { maxCharacters: this.props.maxCharacters })}</OutputText> : null}
|
211
232
|
{this.state.customizedError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {this.state.customizedErrorMessage}</OutputText> : null}
|
212
233
|
</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.1",
|
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
|
}
|