neo.mjs 9.0.2 → 9.1.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.
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='9.0.2'
23
+ * @member {String} version='9.1.0'
24
24
  */
25
- version: '9.0.2'
25
+ version: '9.1.0'
26
26
  }
27
27
 
28
28
  /**
@@ -16,7 +16,7 @@
16
16
  "@type": "Organization",
17
17
  "name": "Neo.mjs"
18
18
  },
19
- "datePublished": "2025-05-12",
19
+ "datePublished": "2025-05-13",
20
20
  "publisher": {
21
21
  "@type": "Organization",
22
22
  "name": "Neo.mjs"
@@ -107,7 +107,7 @@ class FooterContainer extends Container {
107
107
  }, {
108
108
  module: Component,
109
109
  cls : ['neo-version'],
110
- html : 'v9.0.2'
110
+ html : 'v9.1.0'
111
111
  }]
112
112
  }],
113
113
  /**
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='9.0.2'
23
+ * @member {String} version='9.1.0'
24
24
  */
25
- version: '9.0.2'
25
+ version: '9.1.0'
26
26
  }
27
27
 
28
28
  /**
@@ -35,7 +35,8 @@ class MainContainer extends Viewport {
35
35
  iconCls: 'fa fa-edit',
36
36
  style : {marginRight: '10px'},
37
37
  text : 'Change Cell Value',
38
- handler: function () {
38
+
39
+ handler() {
39
40
  let tabContainer = Neo.getComponent('myTableStoreContainer'),
40
41
  store = tabContainer.store,
41
42
  record = store.items[0];
@@ -47,7 +48,8 @@ class MainContainer extends Viewport {
47
48
  iconCls: 'fa fa-edit',
48
49
  style : {marginRight: '10px'},
49
50
  text : 'Update all cells 100x',
50
- handler: function () {
51
+
52
+ handler() {
51
53
  let tabContainer = Neo.getComponent('myTableStoreContainer'),
52
54
  store = tabContainer.store,
53
55
  countRecords = store.getCount(),
@@ -61,7 +63,7 @@ class MainContainer extends Viewport {
61
63
  for (i=0; i < countRecords; i++) {
62
64
  record = store.items[i];
63
65
 
64
- Object.entries(record[Symbol.for('data')]).forEach(([field, value]) => {
66
+ Object.entries(record.toJSON()).forEach(([field, value]) => {
65
67
  if (field !== 'githubId') {
66
68
  if (value.includes(string1)) {
67
69
  newValue = value.replace(string1, string2);
@@ -81,7 +83,8 @@ class MainContainer extends Viewport {
81
83
  ntype : 'button',
82
84
  iconCls: 'fa fa-sync-alt',
83
85
  text : 'Reset Sorting',
84
- handler: function () {
86
+
87
+ handler() {
85
88
  Neo.getComponent('myTableStoreContainer').store.sort();
86
89
  }
87
90
  }]
@@ -105,90 +108,51 @@ class MainContainer extends Viewport {
105
108
  checked : true,
106
109
  hideLabel : true,
107
110
  hideValueLabel: false,
111
+ listeners : {change: 'up.updateSelectionModel'},
108
112
  name : 'selectionModel',
109
113
  value : 'selection-table-cellmodel',
110
- valueLabelText: 'Cell',
111
- listeners: {
112
- change: function(data) {
113
- if (data.value) {
114
- Neo.getComponent('myTableStoreContainer').view.selectionModel = {
115
- ntype: this.value
116
- };
117
- }
118
- }
119
- }
114
+ valueLabelText: 'Cell'
120
115
  }, {
121
116
  ntype : 'radiofield',
122
117
  hideLabel : true,
123
118
  hideValueLabel: false,
119
+ listeners : {change: 'up.updateSelectionModel'},
124
120
  name : 'selectionModel',
125
121
  style : {marginLeft: '20px'},
126
122
  value : 'selection-table-columnmodel',
127
- valueLabelText: 'Column',
128
- listeners: {
129
- change: function(data) {
130
- if (data.value) {
131
- Neo.getComponent('myTableStoreContainer').view.selectionModel = {
132
- ntype: this.value
133
- };
134
- }
135
- }
136
- }
123
+ valueLabelText: 'Column'
137
124
  }, {
138
125
  ntype : 'radiofield',
139
126
  hideLabel : true,
140
127
  hideValueLabel: false,
128
+ listeners : {change: 'up.updateSelectionModel'},
141
129
  name : 'selectionModel',
142
130
  style : {marginLeft: '20px'},
143
131
  value : 'selection-table-rowmodel',
144
- valueLabelText: 'Row',
145
- listeners: {
146
- change: function(data) {
147
- if (data.value) {
148
- Neo.getComponent('myTableStoreContainer').view.selectionModel = {
149
- ntype: this.value
150
- };
151
- }
152
- }
153
- }
132
+ valueLabelText: 'Row'
154
133
  }, {
155
134
  ntype : 'radiofield',
156
135
  hideLabel : true,
157
136
  hideValueLabel: false,
137
+ listeners : {change: 'up.updateSelectionModel'},
158
138
  name : 'selectionModel',
159
139
  style : {marginLeft: '20px'},
160
140
  value : 'selection-table-cellcolumnmodel',
161
- valueLabelText: 'Cell & Column',
162
- listeners: {
163
- change: function(data) {
164
- if (data.value) {
165
- Neo.getComponent('myTableStoreContainer').view.selectionModel = {
166
- ntype: this.value
167
- };
168
- }
169
- }
170
- }
141
+ valueLabelText: 'Cell & Column'
171
142
  }, {
172
143
  ntype : 'radiofield',
173
144
  hideLabel : true,
174
145
  hideValueLabel: false,
146
+ listeners : {change: 'up.updateSelectionModel'},
175
147
  name : 'selectionModel',
176
148
  style : {marginLeft: '20px'},
177
149
  value : 'selection-table-cellrowmodel',
178
- valueLabelText: 'Cell & Row',
179
- listeners: {
180
- change: function(data) {
181
- if (data.value) {
182
- Neo.getComponent('myTableStoreContainer').view.selectionModel = {
183
- ntype: this.value
184
- };
185
- }
186
- }
187
- }
150
+ valueLabelText: 'Cell & Row'
188
151
  }]
189
152
  }, {
190
153
  module : TableContainer,
191
154
  id : 'myTableStoreContainer',
155
+ reference : 'table',
192
156
  store : MainStore,
193
157
  viewConfig : {selectionModel: CellModel},
194
158
  width : '100%',
@@ -209,6 +173,17 @@ class MainContainer extends Viewport {
209
173
  }]
210
174
  }]
211
175
  }
176
+
177
+ /**
178
+ * @param {Object} data
179
+ */
180
+ updateSelectionModel(data) {
181
+ if (data.value) {
182
+ this.getReference('table').view.selectionModel = {
183
+ ntype: data.component.value
184
+ }
185
+ }
186
+ }
212
187
  }
213
188
 
214
189
  export default Neo.setupClass(MainContainer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "9.0.2",
3
+ "version": "9.1.0",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1336,7 +1336,7 @@ Add this config to the map.
1336
1336
  <pre data-javascript>
1337
1337
  bind: {
1338
1338
  markerStore: 'stores.earthquakes'
1339
- },
1339
+ }
1340
1340
  </pre>
1341
1341
  <img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/InitialMapWithMarkers.png"></img>
1342
1342
 
@@ -1359,15 +1359,19 @@ via the `component.on()` method.
1359
1359
  In this lab you'll set up an event handler for the table and map.
1360
1360
 
1361
1361
  <details>
1362
- <summary>Add a listener to the table</summary>
1362
+ <summary>Add a listener to the table.View</summary>
1363
1363
 
1364
- Tables fire a select event, passing an object that contains a reference to the corresponding row.
1364
+ Table Views fire a select event, passing an object that contains a reference to the corresponding row.
1365
1365
 
1366
1366
  Add this table config:
1367
1367
 
1368
+ <pre data-javascript>
1369
+ viewConfig: {
1368
1370
  listeners: {
1369
1371
  select: (data) => console.log(data.record)
1370
1372
  }
1373
+ }
1374
+ </pre>
1371
1375
 
1372
1376
  Save and refresh, then click on a table row. If you look at the debugger console you'll see the record being logged.
1373
1377
 
@@ -1387,9 +1391,11 @@ After changing the value you should immediately see it reflected in the table ro
1387
1391
 
1388
1392
  Now add a `markerClick` listener to the Google Map.
1389
1393
 
1390
- listeners: {
1391
- markerClick: data => console.log(data.data.record)
1392
- },
1394
+ <pre data-javascript>
1395
+ listeners: {
1396
+ markerClick: data => console.log(data.data.record)
1397
+ }
1398
+ </pre>
1393
1399
 
1394
1400
  Save, refresh, and confirm that you see the value logged when you click on a map marker.
1395
1401
 
@@ -263,12 +263,12 @@ const DefaultConfig = {
263
263
  useVdomWorker: true,
264
264
  /**
265
265
  * buildScripts/injectPackageVersion.mjs will update this value
266
- * @default '9.0.2'
266
+ * @default '9.1.0'
267
267
  * @memberOf! module:Neo
268
268
  * @name config.version
269
269
  * @type String
270
270
  */
271
- version: '9.0.2'
271
+ version: '9.1.0'
272
272
  };
273
273
 
274
274
  Object.assign(DefaultConfig, {
@@ -154,14 +154,14 @@ class Helix extends Component {
154
154
  mouseWheelEnabled_: true,
155
155
  /**
156
156
  * The DOM element offsetHeight of the top level div.
157
- * Gets fetched after the helix got mounted.
157
+ * Gets fetched on resize.
158
158
  * @member {Number|null} offsetHeight=null
159
159
  * @protected
160
160
  */
161
161
  offsetHeight: null,
162
162
  /**
163
163
  * The DOM element offsetWidth of the top level div.
164
- * Gets fetched after the helix got mounted.
164
+ * Gets fetched on resize.
165
165
  * @member {Number|null} offsetWidth=null
166
166
  * @protected
167
167
  */
@@ -259,12 +259,24 @@ class Helix extends Component {
259
259
 
260
260
  me.addDomListeners({
261
261
  click : me.onClick,
262
+ resize : me.onResize,
262
263
  touchmove: me.onTouchMove,
263
264
  wheel : me.onMouseWheel,
264
265
  scope : me
265
266
  })
266
267
  }
267
268
 
269
+ /**
270
+ * @param {Boolean} mounted
271
+ * @protected
272
+ */
273
+ async addResizeObserver(mounted) {
274
+ let {id, windowId} = this,
275
+ ResizeObserver = await Neo.currentWorker.getAddon('ResizeObserver', windowId);
276
+
277
+ ResizeObserver[mounted ? 'register' : 'unregister']({id, windowId})
278
+ }
279
+
268
280
  /**
269
281
  * Triggered after the followSelection config got changed
270
282
  * @param {Boolean} value
@@ -329,7 +341,10 @@ class Helix extends Component {
329
341
  */
330
342
  afterSetMounted(value, oldValue) {
331
343
  super.afterSetMounted(value, oldValue);
332
- value && this.getOffsetValues()
344
+
345
+ if (oldValue !== undefined) {
346
+ this.addResizeObserver(value)
347
+ }
333
348
  }
334
349
 
335
350
  /**
@@ -749,25 +764,6 @@ class Helix extends Component {
749
764
  return this.id + '__' + id
750
765
  }
751
766
 
752
- /**
753
- * @param {Number} [delay=100]
754
- */
755
- getOffsetValues(delay=100) {
756
- let me = this;
757
-
758
- me.timeout(delay).then(() => {
759
- Neo.currentWorker.promiseMessage('main', {
760
- action : 'readDom',
761
- appName : me.appName,
762
- attributes: ['offsetHeight', 'offsetWidth'],
763
- vnodeId : me.id
764
- }).then(data => {
765
- me.offsetHeight = data.attributes.offsetHeight;
766
- me.offsetWidth = data.attributes.offsetWidth
767
- })
768
- })
769
- }
770
-
771
767
  /**
772
768
  *
773
769
  */
@@ -778,7 +774,7 @@ class Helix extends Component {
778
774
  insideNeo: true,
779
775
  url : me.url
780
776
  }).catch(err => {
781
- console.log('Error for Neo.Xhr.request', err, me.id);
777
+ console.log('Error for Neo.Xhr.request', err, me.id)
782
778
  }).then(data => {
783
779
  me.store.items = data.json.data;
784
780
  me.createItems()
@@ -840,6 +836,33 @@ class Helix extends Component {
840
836
  }
841
837
  }
842
838
 
839
+ /**
840
+ * @param {Object} data
841
+ * @protected
842
+ */
843
+ async onResize(data) {
844
+ let me = this,
845
+ {appName, clonedItems} = me,
846
+ id;
847
+
848
+ me.offsetHeight = data.rect.height;
849
+ me.offsetWidth = data.rect.width;
850
+
851
+ if (clonedItems.length > 0) {
852
+ id = clonedItems[0].id;
853
+
854
+ await Neo.applyDeltas(appName, {
855
+ id,
856
+ cls : {remove: ['neo-transition-600']},
857
+ style: {transform: me.getCloneTransform()}
858
+ });
859
+
860
+ await me.timeout(10);
861
+
862
+ await Neo.applyDeltas(appName, {id, cls: {add: ['neo-transition-600']}})
863
+ }
864
+ }
865
+
843
866
  /**
844
867
  * @param {String[]} value
845
868
  * @param {String[]} oldValue
@@ -229,7 +229,7 @@ class MagicMoveText extends Component {
229
229
  me.previousChars = []
230
230
  }
231
231
 
232
- if(oldValue !== undefined) {
232
+ if (oldValue !== undefined) {
233
233
  me.addResizeObserver(value);
234
234
 
235
235
  me.autoCycle && me.startAutoCycle(value)