muba-input-text 3.0.2 → 4.1.0

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 CHANGED
@@ -32,8 +32,10 @@ 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,
38
+ urlAllowingError: false,
37
39
  customizedError: false,
38
40
  customizedErrorMessage: undefined,
39
41
  inputFont: props.inputFont,
@@ -61,19 +63,32 @@ export default class InputText extends React.Component {
61
63
  fieldError: false,
62
64
  requiredError: false,
63
65
  onlyNumbersError: false,
66
+ minValueError: false,
64
67
  maxValueError: false,
65
- emailBadFormat: false
68
+ emailBadFormat: false,
69
+ urlAllowingError: false
66
70
  });
67
71
 
72
+ let result = true;
68
73
  if (this.props.required && (this.props.value == null || this.props.value.toString().trim() === '')) {
69
74
  if (this.props.scroll) {
70
75
  this.props.scroll(this.inputTextView);
71
76
  }
72
77
 
73
78
  this.setState({ fieldError: true, requiredError: true });
74
- return false;
79
+ result = false;
80
+ } else {
81
+ if (this.props.notUrl) {
82
+ result = this.isValidUrl(this.props.value);
83
+
84
+ this.showError();
85
+ this.setState({ urlAllowingError: true });
86
+ }
87
+
88
+ result = this.validateType() && result;
75
89
  }
76
- return this.validateType();
90
+
91
+ return result;
77
92
  }
78
93
 
79
94
  showError() {
@@ -112,7 +127,8 @@ export default class InputText extends React.Component {
112
127
  return false;
113
128
  } else {
114
129
  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');
115
- const success = !!pattern.test(this.props.value);
130
+ const patternSpaces = new RegExp(/\s/);
131
+ const success = !!pattern.test(this.props.value) && !patternSpaces.test(this.props.value);
116
132
 
117
133
  if (!success) {
118
134
  // It's invalid
@@ -136,6 +152,10 @@ export default class InputText extends React.Component {
136
152
  this.showError();
137
153
  this.setState({ maxValueError: true });
138
154
  return false;
155
+ } else if (this.props.minValue && parseInt(this.props.value) < this.props.minValue) {
156
+ this.showError();
157
+ this.setState({ minValueError: true });
158
+ return false;
139
159
  }
140
160
  return true;
141
161
  }
@@ -152,8 +172,10 @@ export default class InputText extends React.Component {
152
172
  fieldError: false,
153
173
  requiredError: false,
154
174
  onlyNumbersError: false,
175
+ minValueError: false,
155
176
  maxValueError: false,
156
177
  emailBadFormat: false,
178
+ urlAllowingError: false,
157
179
  customizedError: false,
158
180
  customizedErrorMessage: undefined
159
181
  });
@@ -198,7 +220,9 @@ export default class InputText extends React.Component {
198
220
  {this.state.requiredError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('requiredField')}</OutputText> : null}
199
221
  {this.state.onlyNumbersError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('onlyNumbers')}</OutputText> : null}
200
222
  {this.state.maxValueError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('maxValueError', { maxValue: this.props.maxValue })}</OutputText> : null}
223
+ {this.state.minValueError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('minValueError', { minValue: this.props.minValue })}</OutputText> : null}
201
224
  {this.state.emailBadFormat && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('emailBadFormat')}</OutputText> : null}
225
+ {this.state.urlAllowingError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('urlAllowingError')}</OutputText> : null}
202
226
  {this.state.maxCharacters && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('maxCharacters', { maxCharacters: this.props.maxCharacters })}</OutputText> : null}
203
227
  {this.state.customizedError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {this.state.customizedErrorMessage}</OutputText> : null}
204
228
  </View>
package/locales/ar.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "requiredField": "الحقول المطلوبة",
3
3
  "onlyNumbers": "استخدم الأرقام فقط",
4
+ "minValueError": "الحد الأدنى للقيمة المسموح بها هو {{minValue}}",
4
5
  "maxValueError": "الحد الأقصى للقيمة المسموح بها هو {{maxValue}}",
5
6
  "emailBadFormat": "رجاء قم بإدخال بريد إكتروني صحيح",
6
- "maxCharacters": "الحد الأقصى للحروف {{maxCharacters}}"
7
+ "maxCharacters": "الحد الأقصى للحروف {{maxCharacters}}",
8
+ "urlAllowingError": "غير مسموح بإدخال عناوين URL"
7
9
  }
package/locales/en.json CHANGED
@@ -1,7 +1,9 @@
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
- "maxCharacters": "{{maxCharacters}} characters max."
7
+ "maxCharacters": "{{maxCharacters}} characters max.",
8
+ "urlAllowingError": "It is not allowed to enter URL's"
7
9
  }
package/locales/es.json CHANGED
@@ -1,7 +1,9 @@
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
- "maxCharacters": "{{maxCharacters}} caracteres máx."
7
+ "maxCharacters": "{{maxCharacters}} caracteres máx.",
8
+ "urlAllowingError": "No está permitido introducir URL's"
7
9
  }
package/locales/fr.json CHANGED
@@ -1,7 +1,9 @@
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
- "maxCharacters": "{{maxCharacters}} caractères max."
7
+ "maxCharacters": "{{maxCharacters}} caractères max.",
8
+ "urlAllowingError": "Il n'est pas permis d'entrer des URL"
7
9
  }
package/locales/it.json CHANGED
@@ -1,7 +1,9 @@
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
- "maxCharacters": "{{maxCharacters}} caratteri massimi"
7
+ "maxCharacters": "{{maxCharacters}} caratteri massimi",
8
+ "urlAllowingError": "Non è permesso inserire URL"
7
9
  }
package/locales/nl.json CHANGED
@@ -1,7 +1,9 @@
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
- "maxCharacters": "Maximaal {{maxCharacters} tekens"
7
+ "maxCharacters": "Maximaal {{maxCharacters} tekens",
8
+ "urlAllowingError": "Het is niet toegestaan URL's in te voeren"
7
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-input-text",
3
- "version": "3.0.2",
3
+ "version": "4.1.0",
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": "3",
21
- "muba-i18n": "3",
22
- "muba-output-text": "3"
20
+ "muba-font": "4",
21
+ "muba-i18n": "4",
22
+ "muba-output-text": "4"
23
23
  }
24
24
  }