neo.mjs 5.2.0 → 5.2.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/apps/ServiceWorker.mjs +2 -2
- package/apps/form/view/ViewportController.mjs +1 -1
- package/apps/form/view/pages/Page3.mjs +4 -3
- package/examples/ServiceWorker.mjs +2 -2
- package/package.json +1 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/form/Container.mjs +11 -2
- package/src/form/field/Text.mjs +13 -7
package/apps/ServiceWorker.mjs
CHANGED
@@ -22,7 +22,7 @@ class ViewportController extends Component {
|
|
22
22
|
isValid = await form.validate(),
|
23
23
|
formValues = await form.getValues();
|
24
24
|
|
25
|
-
console.log({isValid, formValues});
|
25
|
+
console.log('All pages', {isValid, formValues});
|
26
26
|
|
27
27
|
await me.updateRecordValidityState()
|
28
28
|
}
|
@@ -18,12 +18,13 @@ class Page3 extends FormPageContainer {
|
|
18
18
|
items: [{
|
19
19
|
module : TextField,
|
20
20
|
labelText: 'Page 3 Field 1',
|
21
|
-
name : '
|
22
|
-
required : true
|
21
|
+
name : 'page3.field1',
|
22
|
+
required : true,
|
23
|
+
value : 'foo'
|
23
24
|
}, {
|
24
25
|
module : TextField,
|
25
26
|
labelText: 'Page 3 Field 2',
|
26
|
-
name : '
|
27
|
+
name : 'page3.field2'
|
27
28
|
}]
|
28
29
|
}
|
29
30
|
}
|
package/package.json
CHANGED
package/src/DefaultConfig.mjs
CHANGED
@@ -237,12 +237,12 @@ const DefaultConfig = {
|
|
237
237
|
useVdomWorker: true,
|
238
238
|
/**
|
239
239
|
* buildScripts/injectPackageVersion.mjs will update this value
|
240
|
-
* @default '5.2.
|
240
|
+
* @default '5.2.1'
|
241
241
|
* @memberOf! module:Neo
|
242
242
|
* @name config.version
|
243
243
|
* @type String
|
244
244
|
*/
|
245
|
-
version: '5.2.
|
245
|
+
version: '5.2.1'
|
246
246
|
};
|
247
247
|
|
248
248
|
Object.assign(DefaultConfig, {
|
package/src/form/Container.mjs
CHANGED
@@ -103,10 +103,19 @@ class Container extends BaseContainer {
|
|
103
103
|
*/
|
104
104
|
async getValues() {
|
105
105
|
let fields = await this.getFields(),
|
106
|
-
values = {}
|
106
|
+
values = {},
|
107
|
+
key, ns, nsArray;
|
107
108
|
|
108
109
|
fields.forEach(item => {
|
109
|
-
|
110
|
+
if (item.name) {
|
111
|
+
nsArray = item.name.split('.');
|
112
|
+
key = nsArray.pop();
|
113
|
+
ns = Neo.ns(nsArray, true, values);
|
114
|
+
|
115
|
+
ns[key] = item.value;
|
116
|
+
} else {
|
117
|
+
values[item.id] = item.value;
|
118
|
+
}
|
110
119
|
});
|
111
120
|
|
112
121
|
return values;
|
package/src/form/field/Text.mjs
CHANGED
@@ -175,6 +175,12 @@ class Text extends Base {
|
|
175
175
|
]}
|
176
176
|
}
|
177
177
|
|
178
|
+
/**
|
179
|
+
* Set this value to false, in case a field should display errors up front.
|
180
|
+
* Otherwise, errors will stay hidden on mounting, unless you trigger validate(false).
|
181
|
+
* @member {Boolean} clean=true
|
182
|
+
*/
|
183
|
+
clean = true
|
178
184
|
/**
|
179
185
|
* data passes maxLength, minLength & valueLength properties
|
180
186
|
* @member {Function} errorTextMaxLength=data=>`Max length violation: ${valueLength} / ${maxLength}`
|
@@ -189,11 +195,6 @@ class Text extends Base {
|
|
189
195
|
* @member {String} errorTextRequired='Required'
|
190
196
|
*/
|
191
197
|
errorTextRequired = 'Required'
|
192
|
-
/**
|
193
|
-
* Set this value to false, in case a field should display errors up front
|
194
|
-
* @member {Boolean} validBeforeMount=true
|
195
|
-
*/
|
196
|
-
validBeforeMount = true
|
197
198
|
|
198
199
|
/**
|
199
200
|
* @param {Object} config
|
@@ -1204,7 +1205,7 @@ class Text extends Base {
|
|
1204
1205
|
|
1205
1206
|
super.reset(value);
|
1206
1207
|
|
1207
|
-
if (value === null && me.
|
1208
|
+
if (value === null && me.clean) {
|
1208
1209
|
me.updateError(null);
|
1209
1210
|
}
|
1210
1211
|
}
|
@@ -1236,7 +1237,7 @@ class Text extends Base {
|
|
1236
1237
|
cls = me.cls,
|
1237
1238
|
errorNode, isValid;
|
1238
1239
|
|
1239
|
-
if (!(me.
|
1240
|
+
if (!(me.clean && !me.mounted)) {
|
1240
1241
|
me._error = value;
|
1241
1242
|
|
1242
1243
|
isValid = !value || value === '';
|
@@ -1314,6 +1315,11 @@ class Text extends Base {
|
|
1314
1315
|
errorParam = {maxLength, minLength, valueLength},
|
1315
1316
|
errorText;
|
1316
1317
|
|
1318
|
+
if (!silent) {
|
1319
|
+
// in case we manually call validate(false) on a form or field before it is mounted, we do want to see errors.
|
1320
|
+
me.clean = false;
|
1321
|
+
}
|
1322
|
+
|
1317
1323
|
if (Neo.isFunction(me.validator)) {
|
1318
1324
|
errorText = me.validator(me);
|
1319
1325
|
|