neo.mjs 5.2.13 → 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.
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='5.2.13'
23
+ * @member {String} version='5.2.15'
24
24
  */
25
- version: '5.2.13'
25
+ version: '5.2.15'
26
26
  }
27
27
 
28
28
  /**
@@ -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);
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='5.2.13'
23
+ * @member {String} version='5.2.15'
24
24
  */
25
- version: '5.2.13'
25
+ version: '5.2.15'
26
26
  }
27
27
 
28
28
  /**
@@ -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 : 1,
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.13",
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.0",
53
+ "fs-extra": "^11.1.1",
54
54
  "highlightjs-line-numbers.js": "^2.8.0",
55
- "inquirer": "^9.1.4",
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.2",
60
- "webpack": "^5.76.1",
59
+ "sass": "^1.59.3",
60
+ "webpack": "^5.76.3",
61
61
  "webpack-cli": "^5.0.1",
62
- "webpack-dev-server": "4.11.1",
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
  },
@@ -16,9 +16,9 @@
16
16
  {"id": 12, "cardIndex": 8, "isHeader": false, "isValid": null, "name": "Page 9"},
17
17
  {"id": 13, "cardIndex": 9, "isHeader": false, "isValid": null, "name": "Page 10"},
18
18
  {"id": 14, "cardIndex": null, "isHeader": true, "isValid": null, "name": "3. Optional data"},
19
- {"id": 15, "cardIndex": 14, "isHeader": false, "isValid": null, "name": "Page 11"},
20
- {"id": 16, "cardIndex": 14, "isHeader": false, "isValid": null, "name": "Page 12"},
21
- {"id": 17, "cardIndex": 14, "isHeader": false, "isValid": null, "name": "Page 13"},
22
- {"id": 18, "cardIndex": 14, "isHeader": false, "isValid": null, "name": "Page 14"}
19
+ {"id": 15, "cardIndex": 10, "isHeader": false, "isValid": null, "name": "Page 11"},
20
+ {"id": 16, "cardIndex": 11, "isHeader": false, "isValid": null, "name": "Page 12"},
21
+ {"id": 17, "cardIndex": 12, "isHeader": false, "isValid": null, "name": "Page 13"},
22
+ {"id": 18, "cardIndex": 13, "isHeader": false, "isValid": null, "name": "Page 14"}
23
23
  ]
24
24
  }
@@ -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.13'
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.13'
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/list/Base.mjs CHANGED
@@ -136,6 +136,11 @@ class Base extends Component {
136
136
  * @member {String|null} itemRole=null
137
137
  */
138
138
  itemRole = null
139
+ /**
140
+ * Defaults to false in case useHeaders is set to true
141
+ * @member {Boolean} scrollIntoViewOnFocus=true
142
+ */
143
+ scrollIntoViewOnFocus = true
139
144
 
140
145
  /**
141
146
  * @param {Object} config
@@ -145,6 +150,10 @@ class Base extends Component {
145
150
 
146
151
  let me = this;
147
152
 
153
+ if (me.useHeaders) {
154
+ me.scrollIntoViewOnFocus = false;
155
+ }
156
+
148
157
  me.addDomListeners({
149
158
  click: me.onClick,
150
159
  scope: me
@@ -488,7 +497,7 @@ class Base extends Component {
488
497
  focus(id) {
489
498
  super.focus(id);
490
499
 
491
- id && Neo.main.DomAccess.scrollIntoView({
500
+ id && this.scrollIntoViewOnFocus && Neo.main.DomAccess.scrollIntoView({
492
501
  behavior: 'auto',
493
502
  id : id || this.id
494
503
  });
@@ -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