neo.mjs 4.0.36 → 4.0.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "4.0.36",
3
+ "version": "4.0.39",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -40,8 +40,8 @@
40
40
  "autoprefixer": "^10.4.7",
41
41
  "chalk": "^5.0.1",
42
42
  "clean-webpack-plugin": "^4.0.0",
43
- "commander": "^9.2.0",
44
- "cssnano": "^5.1.8",
43
+ "commander": "^9.3.0",
44
+ "cssnano": "^5.1.10",
45
45
  "envinfo": "^7.8.1",
46
46
  "fs-extra": "^10.1.0",
47
47
  "highlightjs-line-numbers.js": "^2.8.0",
@@ -254,13 +254,13 @@ class Base extends Component {
254
254
  * @protected
255
255
  */
256
256
  createItems() {
257
- let me = this,
258
- items = me._items,
259
- layout = me.layout,
260
- vdom = me.vdom,
261
- vdomRoot = me.getVdomRoot();
257
+ let me = this,
258
+ items = me._items,
259
+ itemsRoot = me.getVdomItemsRoot(),
260
+ layout = me.layout,
261
+ vdom = me.vdom;
262
262
 
263
- vdomRoot.cn = [];
263
+ itemsRoot.cn = [];
264
264
 
265
265
  items.forEach((item, index) => {
266
266
  items[index] = item = me.createItem(item, index);
@@ -269,7 +269,7 @@ class Base extends Component {
269
269
  layout.applyChildAttributes(item, index);
270
270
  }
271
271
 
272
- vdomRoot.cn.push(item.vdom);
272
+ itemsRoot.cn.push(item.vdom);
273
273
  });
274
274
 
275
275
  me.vdom = vdom;
@@ -316,7 +316,7 @@ class Base extends Component {
316
316
  * @returns {Object} The new vdom items root
317
317
  */
318
318
  getVdomItemsRoot() {
319
- return this.vdom.cn;
319
+ return this.getVdomRoot();
320
320
  }
321
321
 
322
322
  /**
@@ -377,7 +377,7 @@ class Base extends Component {
377
377
 
378
378
  me.items = items;
379
379
 
380
- vdom.cn.splice(index, 0, item.vdom);
380
+ me.getVdomItemsRoot().cn.splice(index, 0, item.vdom);
381
381
  }
382
382
 
383
383
  if (silent) {
@@ -385,8 +385,8 @@ class Base extends Component {
385
385
  } else {
386
386
  me.promiseVdomUpdate().then(() => {
387
387
  me.fire('insert', {
388
- index: index,
389
- item : item
388
+ index,
389
+ item
390
390
  });
391
391
  });
392
392
  }
@@ -427,9 +427,7 @@ class Base extends Component {
427
427
  let me = this,
428
428
  item = me.items[fromIndex];
429
429
 
430
- if (fromIndex !== toIndex) {
431
- me.switchItems(toIndex, fromIndex);
432
- }
430
+ fromIndex !== toIndex && me.switchItems(toIndex, fromIndex);
433
431
 
434
432
  return item;
435
433
  }
@@ -502,20 +500,16 @@ class Base extends Component {
502
500
  let me = this,
503
501
  items = me.items,
504
502
  vdom = me.vdom,
505
- cn, item;
503
+ item;
506
504
 
507
505
  if (index >= items.length) {
508
506
  Neo.warn('Container.removeAt: index >= items.length. ' + me.id);
509
507
  } else {
510
508
  item = items[index];
511
509
 
512
- // console.log('remove item', item.id);
513
-
514
510
  items.splice(index, 1);
515
511
 
516
- cn = vdom.cn || vdom.childNodes || vdom.children;
517
-
518
- cn.splice(index, 1);
512
+ me.getVdomItemsRoot().cn.splice(index, 1);
519
513
 
520
514
  me[silent && !destroyItem ? '_vdom' : 'vdom'] = vdom;
521
515
 
@@ -548,8 +542,8 @@ class Base extends Component {
548
542
  item2Index = Neo.isNumber(item2id) ? item2id : me.indexOf(item2id),
549
543
  vdom = me.vdom;
550
544
 
551
- NeoArray.move(me.items, item2Index, item1Index);
552
- NeoArray.move(me.getVdomItemsRoot(), item2Index, item1Index);
545
+ NeoArray.move(me.items, item2Index, item1Index);
546
+ NeoArray.move(me.getVdomItemsRoot().cn, item2Index, item1Index);
553
547
 
554
548
  me.vdom = vdom;
555
549
  }
@@ -132,7 +132,7 @@ class Panel extends Container {
132
132
  config = {
133
133
  ntype : 'container',
134
134
  flex : 1,
135
- items : items,
135
+ items,
136
136
  itemDefaults: me.itemDefaults,
137
137
  ...containerConfig
138
138
  };
@@ -155,7 +155,7 @@ class Panel extends Container {
155
155
  config = {
156
156
  ntype : 'container',
157
157
  flex : 1,
158
- items : items,
158
+ items,
159
159
  itemDefaults: me.itemDefaults,
160
160
  ...containerConfig
161
161
  };
@@ -111,7 +111,12 @@ class Observable extends Base {
111
111
  eventConfig.fn = eventConfig.scope[eventConfig.fn];
112
112
  }
113
113
 
114
- eventConfig.fn.apply(eventConfig.scope || me, eventConfig.data ? args.concat(eventConfig.data) : args);
114
+ // remove the listener, in case the scope no longer exists
115
+ if (eventConfig.scope && !eventConfig.scope.id) {
116
+ listeners[name].splice(i, 1);
117
+ } else {
118
+ eventConfig.fn.apply(eventConfig.scope || me, eventConfig.data ? args.concat(eventConfig.data) : args);
119
+ }
115
120
  }
116
121
  }
117
122
  }
@@ -24,7 +24,7 @@ class Container extends BaseContainer {
24
24
  */
25
25
  cls: ['neo-form-container'],
26
26
  /**
27
- * @member {Object} vdom={tag: 'form',cn: [],onsubmit:'return false;'}
27
+ * @member {Object} vdom={tag: 'form',cn:[],onsubmit:'return false;'}
28
28
  */
29
29
  vdom:
30
30
  {tag: 'form', cn: [], onsubmit: 'return false;'}
@@ -57,9 +57,7 @@ class Container extends BaseContainer {
57
57
  fields = [];
58
58
 
59
59
  children.forEach(item => {
60
- if (item instanceof BaseField) {
61
- fields.push(item);
62
- }
60
+ item instanceof BaseField && fields.push(item);
63
61
  });
64
62
 
65
63
  return fields;
@@ -189,9 +189,7 @@ class Fieldset extends Container {
189
189
  onConstructed() {
190
190
  super.onConstructed();
191
191
 
192
- if (this.collapsed) {
193
- this.afterSetCollapsed(true, false);
194
- }
192
+ this.collapsed && this.afterSetCollapsed(true, false);
195
193
  }
196
194
 
197
195
  /**
@@ -221,16 +219,16 @@ class Fieldset extends Container {
221
219
  } else {
222
220
  if (me.legend) {
223
221
  me.legend.setSilent({
224
- iconCls: iconCls,
225
- text : title
222
+ iconCls,
223
+ text: title
226
224
  });
227
225
 
228
226
  delete me.legend.vdom.reomveDom;
229
227
  } else {
230
228
  me.legend = me.insert(0, {
231
- module : Legend,
232
- iconCls: iconCls,
233
- text : title,
229
+ module: Legend,
230
+ iconCls,
231
+ text : title,
234
232
  ...me.legendConfig
235
233
  });
236
234
  }
@@ -357,6 +357,13 @@ class Container extends BaseContainer {
357
357
  return this.vdom.cn[0];
358
358
  }
359
359
 
360
+ /**
361
+ * @returns {Object[]} The new vdom items root
362
+ */
363
+ getVdomItemsRoot() {
364
+ return this.vdom.cn[0];
365
+ }
366
+
360
367
  /**
361
368
  * @returns {Neo.table.View}
362
369
  */
@@ -128,14 +128,6 @@ class Toolbar extends BaseToolbar {
128
128
  return 'base';
129
129
  }
130
130
 
131
- /**
132
- * Specify a different vdom items root if needed (useful in case this container uses a wrapper node).
133
- * @returns {Object} The new vdom items root
134
- */
135
- getVdomItemsRoot() {
136
- return this.vdom.cn[0].cn;
137
- }
138
-
139
131
  /**
140
132
  * Specify a different vdom root if needed to apply the top level style attributes on a different level.
141
133
  * Make sure to use getVnodeRoot() as well, to keep the vdom & vnode trees in sync.
@@ -95,9 +95,7 @@ class NeoArray extends Base {
95
95
  items.forEach(item => {
96
96
  index = arr.indexOf(item);
97
97
 
98
- if (index > -1) {
99
- arr.splice(index, 1);
100
- }
98
+ index > -1 && arr.splice(index, 1);
101
99
  });
102
100
  }
103
101
 
@@ -243,6 +243,9 @@ class Helper extends Base {
243
243
  oldVnodeRoot,
244
244
  parentId: movedNode.parentNode.id
245
245
  });
246
+
247
+ // see: https://github.com/neomjs/neo/issues/3116
248
+ movedOldNode.parentNode.childNodes.splice(index, 0, movedOldNode);
246
249
  } else if (!movedNode && movedOldNode) {
247
250
  if (newVnode.id === movedOldNode.vnode.id) {
248
251
  indexDelta = 0;
@@ -43,8 +43,7 @@ StartTest(t => {
43
43
 
44
44
  t.isDeeplyStrict(deltas, [
45
45
  {action: 'moveNode', id: 'neo-event-2', index: 0, parentId: 'neo-column-1'},
46
- {innerHTML: '06:00', id: 'neo-event-2__time'},
47
- {action: 'moveNode', id: 'neo-event-1', index: 1, parentId: 'neo-column-1'} // todo: does not hurt, but not needed
46
+ {innerHTML: '06:00', id: 'neo-event-2__time'}
48
47
  ], 'deltas got created successfully');
49
48
 
50
49
  t.diag("Revert operation");
@@ -67,7 +66,6 @@ StartTest(t => {
67
66
 
68
67
  t.isDeeplyStrict(deltas, [
69
68
  {action: 'moveNode', id: 'neo-event-1', index: 0, parentId: 'neo-column-1'},
70
- {action: 'moveNode', id: 'neo-event-2', index: 1, parentId: 'neo-column-1'}, // todo: does not hurt, but not needed
71
69
  {innerHTML: '10:00', id: 'neo-event-2__time'}
72
70
  ], 'deltas got created successfully');
73
71
  });
@@ -306,8 +306,8 @@ StartTest(t => {
306
306
  }, 'vnode got updated successfully');
307
307
 
308
308
  t.isDeeplyStrict(deltas, [
309
- {action: 'moveNode', id: 'neo-vnode-3', index: 0, parentId: 'neo-vnode-1'},
310
- {action: 'moveNode', id: 'neo-vnode-2', index: 2, parentId: 'neo-vnode-1'}
309
+ {action: 'moveNode', id: 'neo-vnode-3', index: 0, parentId: 'neo-vnode-1'},
310
+ {action: 'moveNode', id: 'neo-button-1', index: 1, parentId: 'neo-vnode-1'}
311
311
  ], 'deltas got created successfully');
312
312
 
313
313
  vdom.cn.push(vdom.cn.shift()); // left shift
@@ -333,8 +333,7 @@ StartTest(t => {
333
333
 
334
334
  t.isDeeplyStrict(deltas, [
335
335
  {action: 'moveNode', id: 'neo-button-1', index: 0, parentId: 'neo-vnode-1'},
336
- {action: 'moveNode', id: 'neo-vnode-2', index: 1, parentId: 'neo-vnode-1'},
337
- {action: 'moveNode', id: 'neo-vnode-3', index: 2, parentId: 'neo-vnode-1'}
336
+ {action: 'moveNode', id: 'neo-vnode-2', index: 1, parentId: 'neo-vnode-1'}
338
337
  ], 'deltas got created successfully');
339
338
 
340
339
  vdom.cn.unshift(vdom.cn.pop()); // right shift
@@ -359,9 +358,7 @@ StartTest(t => {
359
358
  }, 'vnode got updated successfully');
360
359
 
361
360
  t.isDeeplyStrict(deltas, [
362
- {action: 'moveNode', id: 'neo-vnode-3', index: 0, parentId: 'neo-vnode-1'},
363
- {action: 'moveNode', id: 'neo-button-1', index: 1, parentId: 'neo-vnode-1'},
364
- {action: 'moveNode', id: 'neo-vnode-2', index: 2, parentId: 'neo-vnode-1'}
361
+ {action: 'moveNode', id: 'neo-vnode-3', index: 0, parentId: 'neo-vnode-1'}
365
362
  ], 'deltas got created successfully');
366
363
  });
367
364
 
@@ -548,7 +545,89 @@ StartTest(t => {
548
545
  {attributes: {tabIndex: '-1'}, childNodes: [], className: ['neo-list-item'], id: 'neo-list-1__rwaters', innerHTML: 'Rich', nodeName: 'li', style: {}, vtype: 'vnode'},
549
546
  {attributes: {tabIndex: '-1'}, childNodes: [], className: ['neo-list-item'], id: 'neo-list-1__tobiu', innerHTML: 'Tobias', nodeName: 'li', style: {}, vtype: 'vnode'}
550
547
  ], 'vnode got updated successfully');
548
+ });
549
+
550
+ t.it('Sorting', t => {
551
+ t.diag("Creating a sorted array");
552
+
553
+ vdom =
554
+ {id: 'root', cn: [
555
+ {id: '0', html: 'g'},
556
+ {id: '1', html: 'g'},
557
+ {id: '2', html: 'g'},
558
+ {id: '3', html: 'g'},
559
+ {id: '4', html: 'm'},
560
+ {id: '5', html: 'm'},
561
+ {id: '6', html: 'w'},
562
+ {id: '7', html: 'w'},
563
+ {id: '8', html: 'w'},
564
+ {id: '9', html: 'w'}
565
+ ]};
566
+
567
+ vnode = VdomHelper.create(vdom);
568
+
569
+ t.isDeeplyStrict(vnode, {
570
+ attributes: {},
571
+ className : [],
572
+ id : 'root',
573
+ innerHTML : undefined,
574
+ nodeName : 'div',
575
+ outerHTML : t.any(String),
576
+ style : {},
577
+ vtype : 'vnode',
578
+
579
+ childNodes: [
580
+ {attributes: {}, childNodes: [], className: [], id: '0', innerHTML: 'g', nodeName: 'div', style: {}, vtype: 'vnode'},
581
+ {attributes: {}, childNodes: [], className: [], id: '1', innerHTML: 'g', nodeName: 'div', style: {}, vtype: 'vnode'},
582
+ {attributes: {}, childNodes: [], className: [], id: '2', innerHTML: 'g', nodeName: 'div', style: {}, vtype: 'vnode'},
583
+ {attributes: {}, childNodes: [], className: [], id: '3', innerHTML: 'g', nodeName: 'div', style: {}, vtype: 'vnode'},
584
+ {attributes: {}, childNodes: [], className: [], id: '4', innerHTML: 'm', nodeName: 'div', style: {}, vtype: 'vnode'},
585
+ {attributes: {}, childNodes: [], className: [], id: '5', innerHTML: 'm', nodeName: 'div', style: {}, vtype: 'vnode'},
586
+ {attributes: {}, childNodes: [], className: [], id: '6', innerHTML: 'w', nodeName: 'div', style: {}, vtype: 'vnode'},
587
+ {attributes: {}, childNodes: [], className: [], id: '7', innerHTML: 'w', nodeName: 'div', style: {}, vtype: 'vnode'},
588
+ {attributes: {}, childNodes: [], className: [], id: '8', innerHTML: 'w', nodeName: 'div', style: {}, vtype: 'vnode'},
589
+ {attributes: {}, childNodes: [], className: [], id: '9', innerHTML: 'w', nodeName: 'div', style: {}, vtype: 'vnode'}
590
+ ]
591
+ }, 'vnode got created successfully');
592
+
593
+ vdom.cn = [
594
+ {id: '9', html: 'w'},
595
+ {id: '8', html: 'w'},
596
+ {id: '7', html: 'w'},
597
+ {id: '6', html: 'w'},
598
+ {id: '4', html: 'm'},
599
+ {id: '5', html: 'm'},
600
+ {id: '3', html: 'g'},
601
+ {id: '2', html: 'g'},
602
+ {id: '1', html: 'g'},
603
+ {id: '0', html: 'g'}
604
+ ];
605
+
606
+ output = VdomHelper.update({vdom: vdom, vnode: vnode}); deltas = output.deltas; vnode = output.vnode;
607
+
608
+ t.isDeeplyStrict(vnode, {
609
+ attributes: {},
610
+ className : [],
611
+ id : 'root',
612
+ innerHTML : undefined,
613
+ nodeName : 'div',
614
+ style : {},
615
+ vtype : 'vnode',
616
+
617
+ childNodes: [
618
+ {attributes: {}, childNodes: [], className: [], id: '9', innerHTML: 'w', nodeName: 'div', style: {}, vtype: 'vnode'},
619
+ {attributes: {}, childNodes: [], className: [], id: '8', innerHTML: 'w', nodeName: 'div', style: {}, vtype: 'vnode'},
620
+ {attributes: {}, childNodes: [], className: [], id: '7', innerHTML: 'w', nodeName: 'div', style: {}, vtype: 'vnode'},
621
+ {attributes: {}, childNodes: [], className: [], id: '6', innerHTML: 'w', nodeName: 'div', style: {}, vtype: 'vnode'},
622
+ {attributes: {}, childNodes: [], className: [], id: '4', innerHTML: 'm', nodeName: 'div', style: {}, vtype: 'vnode'},
623
+ {attributes: {}, childNodes: [], className: [], id: '5', innerHTML: 'm', nodeName: 'div', style: {}, vtype: 'vnode'},
624
+ {attributes: {}, childNodes: [], className: [], id: '3', innerHTML: 'g', nodeName: 'div', style: {}, vtype: 'vnode'},
625
+ {attributes: {}, childNodes: [], className: [], id: '2', innerHTML: 'g', nodeName: 'div', style: {}, vtype: 'vnode'},
626
+ {attributes: {}, childNodes: [], className: [], id: '1', innerHTML: 'g', nodeName: 'div', style: {}, vtype: 'vnode'},
627
+ {attributes: {}, childNodes: [], className: [], id: '0', innerHTML: 'g', nodeName: 'div', style: {}, vtype: 'vnode'}
628
+ ]
629
+ }, 'vnode got updated successfully');
551
630
 
552
- // console.log(deltas);
631
+ console.log(deltas);
553
632
  });
554
633
  });