neo.mjs 5.5.12 → 5.6.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/apps/ServiceWorker.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import FormPageContainer from '../FormPageContainer.mjs';
|
2
|
-
import
|
2
|
+
import UrlField from '../../../../src/form/field/Url.mjs';
|
3
3
|
|
4
4
|
/**
|
5
5
|
* @class Form.view.pages.Page13
|
@@ -16,13 +16,15 @@ class Page13 extends FormPageContainer {
|
|
16
16
|
* @member {Object[]} items
|
17
17
|
*/
|
18
18
|
items: [{
|
19
|
-
module :
|
19
|
+
module : UrlField,
|
20
20
|
labelText: 'Page 13 Field 1',
|
21
|
-
name : 'page13field1'
|
21
|
+
name : 'page13field1',
|
22
|
+
value : 'https://google.com'
|
22
23
|
}, {
|
23
|
-
module :
|
24
|
+
module : UrlField,
|
24
25
|
labelText: 'Page 13 Field 2',
|
25
|
-
name : 'page13field2'
|
26
|
+
name : 'page13field2',
|
27
|
+
value : 'www.google.com' // missing protocol
|
26
28
|
}]
|
27
29
|
}
|
28
30
|
}
|
package/package.json
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
{"id": 14, "cardIndex": null, "isHeader": true, "isValid": null, "name": "4. Optional data"},
|
19
19
|
{"id": 15, "cardIndex": 10, "isHeader": false, "isValid": null, "name": "ZipCodeFields"},
|
20
20
|
{"id": 16, "cardIndex": 11, "isHeader": false, "isValid": null, "name": "EmailFields"},
|
21
|
-
{"id": 17, "cardIndex": 12, "isHeader": false, "isValid": null, "name": "
|
21
|
+
{"id": 17, "cardIndex": 12, "isHeader": false, "isValid": null, "name": "UrlFields"},
|
22
22
|
{"id": 18, "cardIndex": 13, "isHeader": false, "isValid": null, "name": "Page 14"}
|
23
23
|
]
|
24
24
|
}
|
package/src/DefaultConfig.mjs
CHANGED
@@ -236,12 +236,12 @@ const DefaultConfig = {
|
|
236
236
|
useVdomWorker: true,
|
237
237
|
/**
|
238
238
|
* buildScripts/injectPackageVersion.mjs will update this value
|
239
|
-
* @default '5.
|
239
|
+
* @default '5.6.0'
|
240
240
|
* @memberOf! module:Neo
|
241
241
|
* @name config.version
|
242
242
|
* @type String
|
243
243
|
*/
|
244
|
-
version: '5.
|
244
|
+
version: '5.6.0'
|
245
245
|
};
|
246
246
|
|
247
247
|
Object.assign(DefaultConfig, {
|
package/src/form/field/Url.mjs
CHANGED
@@ -18,11 +18,82 @@ class Url extends Text {
|
|
18
18
|
* @protected
|
19
19
|
*/
|
20
20
|
ntype: 'urlfield',
|
21
|
+
/**
|
22
|
+
* @member {String} errorTextValidUrl='Not a valid URL'
|
23
|
+
*/
|
24
|
+
errorTextValidUrl: 'Not a valid URL',
|
21
25
|
/**
|
22
26
|
* Value for the inputType_ textfield config
|
23
27
|
* @member {String} inputType='url'
|
24
28
|
*/
|
25
|
-
inputType: 'url'
|
29
|
+
inputType: 'url',
|
30
|
+
/**
|
31
|
+
* Specify allowed protocols
|
32
|
+
* @member {String[]} protocols=['http:','https:']
|
33
|
+
*/
|
34
|
+
protocols: ['http:', 'https:']
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Triggered when accessing the value config
|
39
|
+
* The default URL ctor has some sanity checks to convert an "almost" valid URL into a real one.
|
40
|
+
* E.g. new URL("http:www.google.com").href => "http://www.google.com"
|
41
|
+
* @param {String|null} value
|
42
|
+
* @returns {String|null}
|
43
|
+
* @protected
|
44
|
+
*/
|
45
|
+
beforeGetValue(value) {
|
46
|
+
if (value) {
|
47
|
+
let url;
|
48
|
+
|
49
|
+
try {
|
50
|
+
url = new URL(value);
|
51
|
+
} catch(e) {
|
52
|
+
return value
|
53
|
+
}
|
54
|
+
|
55
|
+
return url.href
|
56
|
+
}
|
57
|
+
|
58
|
+
return value
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Checks for client-side field errors
|
63
|
+
* @param {Boolean} silent=true
|
64
|
+
* @returns {Boolean} Returns true in case there are no client-side errors
|
65
|
+
*/
|
66
|
+
validate(silent=true) {
|
67
|
+
let me = this,
|
68
|
+
returnValue = super.validate(silent),
|
69
|
+
value = me.value;
|
70
|
+
|
71
|
+
if (returnValue) {
|
72
|
+
if (value && !me.verifyUrl(value)) {
|
73
|
+
me._error = me.errorTextValidUrl;
|
74
|
+
returnValue = false;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
!returnValue && !me.clean && me.updateError(me._error, silent);
|
79
|
+
|
80
|
+
return returnValue
|
81
|
+
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* @param {String} value
|
85
|
+
* @returns {Boolean}
|
86
|
+
*/
|
87
|
+
verifyUrl(value) {
|
88
|
+
let url;
|
89
|
+
|
90
|
+
try {
|
91
|
+
url = new URL(value);
|
92
|
+
} catch(e) {
|
93
|
+
return false
|
94
|
+
}
|
95
|
+
|
96
|
+
return this.protocols.includes(url.protocol)
|
26
97
|
}
|
27
98
|
}
|
28
99
|
|