muba-input-text 3.0.0 → 3.0.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 +22 -5
- package/locales/ar.json +1 -0
- package/locales/en.json +1 -0
- package/locales/es.json +1 -0
- package/locales/fr.json +1 -0
- package/locales/it.json +1 -0
- package/locales/nl.json +1 -0
- package/package.json +2 -2
package/InputText.js
CHANGED
@@ -32,6 +32,7 @@ export default class InputText extends React.Component {
|
|
32
32
|
fieldError: false,
|
33
33
|
requiredError: false,
|
34
34
|
onlyNumbersError: false,
|
35
|
+
minValueError: false,
|
35
36
|
maxValueError: false,
|
36
37
|
emailBadFormat: false,
|
37
38
|
customizedError: false,
|
@@ -61,6 +62,7 @@ export default class InputText extends React.Component {
|
|
61
62
|
fieldError: false,
|
62
63
|
requiredError: false,
|
63
64
|
onlyNumbersError: false,
|
65
|
+
minValueError: false,
|
64
66
|
maxValueError: false,
|
65
67
|
emailBadFormat: false
|
66
68
|
});
|
@@ -98,20 +100,29 @@ export default class InputText extends React.Component {
|
|
98
100
|
}
|
99
101
|
|
100
102
|
isValidEmail() {
|
103
|
+
const EMAIL_ALLOWED_LENGTH = 50;
|
101
104
|
if (this.props.value != null) {
|
102
105
|
if (!this.props.value.length) {
|
103
106
|
// It's empty
|
104
107
|
this.showError();
|
105
108
|
return false;
|
106
109
|
} else {
|
107
|
-
|
108
|
-
const success = !!pattern.test(this.props.value);
|
109
|
-
|
110
|
-
if (!success) {
|
110
|
+
if (this.props.value.length > EMAIL_ALLOWED_LENGTH || this.props.value.split('@').length !== 2) {
|
111
111
|
// It's invalid
|
112
112
|
this.showError();
|
113
113
|
this.setState({ emailBadFormat: true });
|
114
114
|
return false;
|
115
|
+
} else {
|
116
|
+
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 patternSpaces = new RegExp(/\s/);
|
118
|
+
const success = !!pattern.test(this.props.value) && !patternSpaces.test(this.props.value);
|
119
|
+
|
120
|
+
if (!success) {
|
121
|
+
// It's invalid
|
122
|
+
this.showError();
|
123
|
+
this.setState({ emailBadFormat: true });
|
124
|
+
return false;
|
125
|
+
}
|
115
126
|
}
|
116
127
|
}
|
117
128
|
}
|
@@ -124,10 +135,14 @@ export default class InputText extends React.Component {
|
|
124
135
|
this.showError();
|
125
136
|
this.setState({ onlyNumbersError: true });
|
126
137
|
return false;
|
127
|
-
} else if (this.props.maxValue && this.props.value > this.props.maxValue) {
|
138
|
+
} else if (this.props.maxValue && parseInt(this.props.value) > this.props.maxValue) {
|
128
139
|
this.showError();
|
129
140
|
this.setState({ maxValueError: true });
|
130
141
|
return false;
|
142
|
+
} else if (this.props.minValue && parseInt(this.props.value) < this.props.minValue) {
|
143
|
+
this.showError();
|
144
|
+
this.setState({ minValueError: true });
|
145
|
+
return false;
|
131
146
|
}
|
132
147
|
return true;
|
133
148
|
}
|
@@ -144,6 +159,7 @@ export default class InputText extends React.Component {
|
|
144
159
|
fieldError: false,
|
145
160
|
requiredError: false,
|
146
161
|
onlyNumbersError: false,
|
162
|
+
minValueError: false,
|
147
163
|
maxValueError: false,
|
148
164
|
emailBadFormat: false,
|
149
165
|
customizedError: false,
|
@@ -190,6 +206,7 @@ export default class InputText extends React.Component {
|
|
190
206
|
{this.state.requiredError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('requiredField')}</OutputText> : null}
|
191
207
|
{this.state.onlyNumbersError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('onlyNumbers')}</OutputText> : null}
|
192
208
|
{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
|
+
{this.state.minValueError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('minValueError', { minValue: this.props.minValue })}</OutputText> : null}
|
193
210
|
{this.state.emailBadFormat && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('emailBadFormat')}</OutputText> : null}
|
194
211
|
{this.state.maxCharacters && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('maxCharacters', { maxCharacters: this.props.maxCharacters })}</OutputText> : null}
|
195
212
|
{this.state.customizedError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {this.state.customizedErrorMessage}</OutputText> : null}
|
package/locales/ar.json
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"requiredField": "الحقول المطلوبة",
|
3
3
|
"onlyNumbers": "استخدم الأرقام فقط",
|
4
|
+
"minValueError": "الحد الأدنى للقيمة المسموح بها هو {{minValue}}",
|
4
5
|
"maxValueError": "الحد الأقصى للقيمة المسموح بها هو {{maxValue}}",
|
5
6
|
"emailBadFormat": "رجاء قم بإدخال بريد إكتروني صحيح",
|
6
7
|
"maxCharacters": "الحد الأقصى للحروف {{maxCharacters}}"
|
package/locales/en.json
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"requiredField": "Required field",
|
3
3
|
"onlyNumbers": "Use numbers only",
|
4
|
+
"minValueError": "The minimum value allowed is {{minValue}}",
|
4
5
|
"maxValueError": "The maximum value allowed is {{maxValue}}",
|
5
6
|
"emailBadFormat": "Please enter a valid email address",
|
6
7
|
"maxCharacters": "{{maxCharacters}} characters max."
|
package/locales/es.json
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"requiredField": "Campo obligatorio",
|
3
3
|
"onlyNumbers": "Utiliza sólo números",
|
4
|
+
"minValueError": "El valor mínimo permitido es {{minValue}}",
|
4
5
|
"maxValueError": "El valor máximo permitido es {{maxValue}}",
|
5
6
|
"emailBadFormat": "Por favor, introduce una dirección de correo electrónico válida",
|
6
7
|
"maxCharacters": "{{maxCharacters}} caracteres máx."
|
package/locales/fr.json
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"requiredField": "Champs requis",
|
3
3
|
"onlyNumbers": "Utiliser des chiffres seulement",
|
4
|
+
"minValueError": "La valeur minimale autorisée est {{minValue}}",
|
4
5
|
"maxValueError": "La valeur maximale autorisée est {{maxValue}}",
|
5
6
|
"emailBadFormat": "S'il vous plaît, mettez une adresse email valide",
|
6
7
|
"maxCharacters": "{{maxCharacters}} caractères max."
|
package/locales/it.json
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"requiredField": "Campo obbligatorio",
|
3
3
|
"onlyNumbers": "Usa solo numeri",
|
4
|
+
"minValueError": "Il valore minimo permesso è {{minValue}}",
|
4
5
|
"maxValueError": "Il valore massimo permesso è {{maxValue}}",
|
5
6
|
"emailBadFormat": "Inserisci un indirizzo e-mail valido",
|
6
7
|
"maxCharacters": "{{maxCharacters}} caratteri massimi"
|
package/locales/nl.json
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"requiredField": "Verplicht veld",
|
3
3
|
"onlyNumbers": "Gebruik alleen cijfers",
|
4
|
+
"minValueError": "De minimale toegestane waarde is {minValue}}",
|
4
5
|
"maxValueError": "De maximale toegestane waarde is {maxValue}}",
|
5
6
|
"emailBadFormat": "Voer een geldig e-mailadres in",
|
6
7
|
"maxCharacters": "Maximaal {{maxCharacters} tekens"
|
package/package.json
CHANGED