muba-input-text 5.0.4 → 6.0.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.
Files changed (2) hide show
  1. package/InputText.js +13 -15
  2. package/package.json +4 -4
package/InputText.js CHANGED
@@ -62,11 +62,6 @@ export default class InputText extends React.Component {
62
62
  }
63
63
  }
64
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);
68
- }
69
-
70
65
  onSubmitValidate() {
71
66
  this.setState({
72
67
  fieldError: false,
@@ -87,16 +82,7 @@ export default class InputText extends React.Component {
87
82
  this.setState({ fieldError: true, requiredError: true });
88
83
  result = false;
89
84
  } 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
- if (this.props.required || this.props.value != null) {
85
+ if (this.props.required || (this.props.value != null && this.props.value !== '')) {
100
86
  result = this.validateType() && result;
101
87
  }
102
88
  }
@@ -124,6 +110,8 @@ export default class InputText extends React.Component {
124
110
  return this.isValidEmail();
125
111
  } else if (this.props.type === 'number') {
126
112
  return this.isValidNumber();
113
+ } else if (this.props.type === 'url') {
114
+ return this.isValidUrl();
127
115
  }
128
116
  return true;
129
117
  }
@@ -176,6 +164,16 @@ export default class InputText extends React.Component {
176
164
  return true;
177
165
  }
178
166
 
167
+ isValidUrl() {
168
+ 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');
169
+ if (!pattern.test(this.props.value)) {
170
+ this.showError();
171
+ this.setState({ urlAllowingError: true });
172
+ return false;
173
+ }
174
+ return true;
175
+ }
176
+
179
177
  showCustomizedError(messageError) {
180
178
  this.setState({ fieldError: true, customizedError: true, customizedErrorMessage: messageError });
181
179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-input-text",
3
- "version": "5.0.4",
3
+ "version": "6.0.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": "5",
21
- "muba-i18n": "5",
22
- "muba-output-text": "5"
20
+ "muba-font": "6",
21
+ "muba-i18n": "6",
22
+ "muba-output-text": "6"
23
23
  }
24
24
  }