neo.mjs 5.2.14 → 5.2.15
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/neo-config.json +6 -5
- package/apps/form/view/FormContainer.mjs +5 -0
- package/apps/form/view/FormContainerController.mjs +14 -0
- package/apps/form/view/ViewportModel.mjs +44 -0
- package/examples/ServiceWorker.mjs +2 -2
- package/examples/form/field/number/MainContainer.mjs +2 -1
- package/package.json +6 -6
- package/src/DefaultConfig.mjs +2 -2
- package/src/form/field/Number.mjs +24 -1
- package/src/model/Component.mjs +9 -0
package/apps/ServiceWorker.mjs
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
{
|
2
|
-
"appPath": "apps/form/app.mjs",
|
3
|
-
"basePath": "../../",
|
4
|
-
"environment": "development",
|
5
|
-
"mainPath": "./Main.mjs"
|
6
|
-
|
2
|
+
"appPath" : "apps/form/app.mjs",
|
3
|
+
"basePath" : "../../",
|
4
|
+
"environment" : "development",
|
5
|
+
"mainPath" : "./Main.mjs",
|
6
|
+
"mainThreadAddons": ["DragDrop", "LocalStorage", "Stylesheet"]
|
7
|
+
}
|
@@ -46,6 +46,11 @@ class FormContainer extends BaseFormContainer {
|
|
46
46
|
handler: 'onValidateAllPagesButtonClick',
|
47
47
|
style : {marginLeft: '1em'},
|
48
48
|
text : 'Validate all pages'
|
49
|
+
}, {
|
50
|
+
iconCls: ['fas', 'fa-floppy-disk'],
|
51
|
+
handler: 'onSaveButtonClick',
|
52
|
+
style : {marginLeft: '1em'},
|
53
|
+
text : 'Save'
|
49
54
|
}]
|
50
55
|
}, {
|
51
56
|
module : Container,
|
@@ -26,6 +26,20 @@ class FormContainerController extends Component {
|
|
26
26
|
onPrevPageButtonClick(data) {
|
27
27
|
this.getModel().data.activeIndex--;
|
28
28
|
}
|
29
|
+
|
30
|
+
/**
|
31
|
+
* @param {Object} data
|
32
|
+
*/
|
33
|
+
async onSaveButtonClick(data) {
|
34
|
+
let form = this.getReference('main-form'),
|
35
|
+
formValues = await form.getValues();
|
36
|
+
|
37
|
+
Neo.main.addon.LocalStorage.updateLocalStorageItem({
|
38
|
+
appName: this.component.appName,
|
39
|
+
key : 'neo-form',
|
40
|
+
value : JSON.stringify(formValues)
|
41
|
+
})
|
42
|
+
}
|
29
43
|
}
|
30
44
|
|
31
45
|
Neo.applyClassConfig(FormContainerController);
|
@@ -43,6 +43,50 @@ class ViewportModel extends Component {
|
|
43
43
|
}
|
44
44
|
}
|
45
45
|
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* We are storing the local storage data into this class field
|
49
|
+
* @member {Object} data
|
50
|
+
*/
|
51
|
+
formData = null
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Loading the local storage formData
|
55
|
+
* @param {Object} config
|
56
|
+
*/
|
57
|
+
construct(config) {
|
58
|
+
super.construct(config);
|
59
|
+
|
60
|
+
Neo.main.addon.LocalStorage.readLocalStorageItem({
|
61
|
+
appName: this.component.appName,
|
62
|
+
key : 'neo-form'
|
63
|
+
}).then(data => {
|
64
|
+
this.formData = JSON.parse(data.value);
|
65
|
+
})
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
*
|
70
|
+
* @param {String} key
|
71
|
+
* @param {*} value
|
72
|
+
* @param {*} oldValue
|
73
|
+
*/
|
74
|
+
onDataPropertyChange(key, value, oldValue) {
|
75
|
+
super.onDataPropertyChange(key, value, oldValue);
|
76
|
+
|
77
|
+
let me = this;
|
78
|
+
|
79
|
+
if (me.formData && key === 'activeIndex') {
|
80
|
+
// short delay to honor the lazy loading
|
81
|
+
setTimeout(() => {
|
82
|
+
let page = me.getController().getReference('pages-container').items[value];
|
83
|
+
|
84
|
+
console.log(key, value, page);
|
85
|
+
|
86
|
+
page.setValues(me.formData);
|
87
|
+
}, 50)
|
88
|
+
}
|
89
|
+
}
|
46
90
|
}
|
47
91
|
|
48
92
|
Neo.applyClassConfig(ViewportModel);
|
@@ -74,7 +74,8 @@ class MainContainer extends ConfigurationViewport {
|
|
74
74
|
labelText: 'stepSize',
|
75
75
|
listeners: {change: me.onConfigChange.bind(me, 'stepSize')},
|
76
76
|
maxValue : 10,
|
77
|
-
minValue :
|
77
|
+
minValue : 0.01,
|
78
|
+
stepSize : 0.01,
|
78
79
|
value : me.exampleComponent.stepSize
|
79
80
|
}, {
|
80
81
|
module : Radio,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "neo.mjs",
|
3
|
-
"version": "5.2.
|
3
|
+
"version": "5.2.15",
|
4
4
|
"description": "The webworkers driven UI framework",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -50,16 +50,16 @@
|
|
50
50
|
"commander": "^10.0.0",
|
51
51
|
"cssnano": "^5.1.15",
|
52
52
|
"envinfo": "^7.8.1",
|
53
|
-
"fs-extra": "^11.1.
|
53
|
+
"fs-extra": "^11.1.1",
|
54
54
|
"highlightjs-line-numbers.js": "^2.8.0",
|
55
|
-
"inquirer": "^9.1.
|
55
|
+
"inquirer": "^9.1.5",
|
56
56
|
"neo-jsdoc": "^1.0.1",
|
57
57
|
"neo-jsdoc-x": "^1.0.5",
|
58
58
|
"postcss": "^8.4.21",
|
59
|
-
"sass": "^1.59.
|
60
|
-
"webpack": "^5.76.
|
59
|
+
"sass": "^1.59.3",
|
60
|
+
"webpack": "^5.76.3",
|
61
61
|
"webpack-cli": "^5.0.1",
|
62
|
-
"webpack-dev-server": "4.
|
62
|
+
"webpack-dev-server": "4.13.1",
|
63
63
|
"webpack-hook-plugin": "^1.0.7",
|
64
64
|
"webpack-node-externals": "^3.0.0"
|
65
65
|
},
|
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.15'
|
241
241
|
* @memberOf! module:Neo
|
242
242
|
* @name config.version
|
243
243
|
* @type String
|
244
244
|
*/
|
245
|
-
version: '5.2.
|
245
|
+
version: '5.2.15'
|
246
246
|
};
|
247
247
|
|
248
248
|
Object.assign(DefaultConfig, {
|
@@ -69,6 +69,11 @@ class Number extends Text {
|
|
69
69
|
useSpinButtons_: true
|
70
70
|
}
|
71
71
|
|
72
|
+
/**
|
73
|
+
* @member {Number|null} stepSizeDigits=null
|
74
|
+
*/
|
75
|
+
stepSizeDigits = null
|
76
|
+
|
72
77
|
/**
|
73
78
|
* Triggered after the inputEditable config got changed
|
74
79
|
* @param {Number} value
|
@@ -120,11 +125,15 @@ class Number extends Text {
|
|
120
125
|
afterSetStepSize(value, oldValue) {
|
121
126
|
let me = this,
|
122
127
|
val = me.value,
|
123
|
-
modulo;
|
128
|
+
modulo, stepSizeString;
|
124
129
|
|
125
130
|
me.changeInputElKey('step', value);
|
126
131
|
|
127
132
|
if (val !== null) {
|
133
|
+
stepSizeString = String(this.stepSize);
|
134
|
+
|
135
|
+
me.stepSizeDigits = stepSizeString.includes('.') ? stepSizeString.split('.')[1].length : 0;
|
136
|
+
|
128
137
|
modulo = (val - me.minValue) % value;
|
129
138
|
|
130
139
|
if (modulo !== 0) { // find the closest valid value
|
@@ -171,6 +180,20 @@ class Number extends Text {
|
|
171
180
|
return this.beforeSetEnumValue(value, oldValue, 'triggerPosition');
|
172
181
|
}
|
173
182
|
|
183
|
+
/**
|
184
|
+
* Triggered before the value config gets changed
|
185
|
+
* @param {Number} value
|
186
|
+
* @param {Number} oldValue
|
187
|
+
* @protected
|
188
|
+
*/
|
189
|
+
beforeSetValue(value, oldValue) {
|
190
|
+
if (Neo.isNumber(value) && this.stepSizeDigits > 0) {
|
191
|
+
return +value.toFixed(this.stepSizeDigits);
|
192
|
+
}
|
193
|
+
|
194
|
+
return value;
|
195
|
+
}
|
196
|
+
|
174
197
|
/**
|
175
198
|
* @returns {Boolean}
|
176
199
|
*/
|
package/src/model/Component.mjs
CHANGED
@@ -270,6 +270,15 @@ class Component extends Base {
|
|
270
270
|
});
|
271
271
|
}
|
272
272
|
|
273
|
+
/**
|
274
|
+
* Convenience shortcut
|
275
|
+
* @param {String} [ntype]
|
276
|
+
* @returns {Neo.controller.Component|null}
|
277
|
+
*/
|
278
|
+
getController(ntype) {
|
279
|
+
return this.component.getController(ntype);
|
280
|
+
}
|
281
|
+
|
273
282
|
/**
|
274
283
|
* Access the closest data property inside the VM parent chain.
|
275
284
|
* @param {String} key
|