neo.mjs 5.14.1 → 5.14.3

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.14.1'
23
+ * @member {String} version='5.14.3'
24
24
  */
25
- version: '5.14.1'
25
+ version: '5.14.3'
26
26
  }
27
27
 
28
28
  /**
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='5.14.1'
23
+ * @member {String} version='5.14.3'
24
24
  */
25
- version: '5.14.1'
25
+ version: '5.14.3'
26
26
  }
27
27
 
28
28
  /**
@@ -191,6 +191,7 @@ class MainContainer extends ConfigurationViewport {
191
191
  iconCls: 'fa fa-home',
192
192
  text : 'Item 1'
193
193
  }, {
194
+ cls : ['neo-red'],
194
195
  handler: data => console.log('menu item 2 click =>', data),
195
196
  iconCls: 'fa fa-user',
196
197
  text : 'Item 2'
@@ -50,8 +50,8 @@ class MainContainerController extends ComponentController {
50
50
 
51
51
  output.update();
52
52
 
53
- await Neo.timeout(20)
54
- me.syntaxHighlight();
53
+ await me.timeout(20);
54
+ me.syntaxHighlight()
55
55
  }
56
56
  }
57
57
 
@@ -50,8 +50,8 @@ class MainContainerController extends ComponentController {
50
50
 
51
51
  output.update();
52
52
 
53
- await Neo.timeout(20)
54
- me.syntaxHighlight();
53
+ await me.timeout(20);
54
+ me.syntaxHighlight()
55
55
  }
56
56
  }
57
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "5.14.1",
3
+ "version": "5.14.3",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -0,0 +1,7 @@
1
+ .neo-menu-list {
2
+ .neo-list-item {
3
+ &.neo-red {
4
+ color: red;
5
+ }
6
+ }
7
+ }
@@ -63,12 +63,12 @@ const DefaultConfig = {
63
63
  /**
64
64
  * In case you are using the GoogleAnalytics main thread addon or useGoogleAnalytics: true,
65
65
  * you can change the gtag id here. Required for the online examples (gh pages)
66
- * @default 'UA-153734404-1'
66
+ * @default 'G-DJ13071C55'
67
67
  * @memberOf! module:Neo
68
68
  * @name config.gtagId
69
69
  * @type String
70
70
  */
71
- gtagId: 'UA-153734404-1',
71
+ gtagId: 'G-DJ13071C55',
72
72
  /**
73
73
  * Flag for running on https://neomjs.github.io/pages/
74
74
  * => to use local images paths instead of raw.githubusercontent.com
@@ -245,12 +245,12 @@ const DefaultConfig = {
245
245
  useVdomWorker: true,
246
246
  /**
247
247
  * buildScripts/injectPackageVersion.mjs will update this value
248
- * @default '5.14.1'
248
+ * @default '5.14.3'
249
249
  * @memberOf! module:Neo
250
250
  * @name config.version
251
251
  * @type String
252
252
  */
253
- version: '5.14.1'
253
+ version: '5.14.3'
254
254
  };
255
255
 
256
256
  Object.assign(DefaultConfig, {
@@ -481,7 +481,7 @@ class Base extends Component {
481
481
  delete rippleWrapper.removeDom;
482
482
  me.update();
483
483
 
484
- await Neo.timeout(1);
484
+ await me.timeout(1);
485
485
 
486
486
  rippleEl.style.animation = `ripple ${rippleEffectDuration}ms linear`;
487
487
  me.update();
@@ -507,7 +507,7 @@ class Base extends Component {
507
507
  menuList.hidden = hidden;
508
508
 
509
509
  if (!hidden) {
510
- await Neo.timeout(50);
510
+ await this.timeout(50);
511
511
  menuList.focus()
512
512
  }
513
513
  }
@@ -452,7 +452,7 @@ class Component extends BaseComponent {
452
452
  me.needsEventUpdate = false;
453
453
  }
454
454
 
455
- await Neo.timeout(70);
455
+ await me.timeout(70);
456
456
 
457
457
  rect = await me.getDomRect(me.getColumnContainer().id);
458
458
 
@@ -1479,7 +1479,7 @@ class Base extends CoreBase {
1479
1479
 
1480
1480
  delete me.vdom.removeDom;
1481
1481
 
1482
- await Neo.timeout(30);
1482
+ await me.timeout(30);
1483
1483
 
1484
1484
  me.mounted = true;
1485
1485
  }
@@ -53,18 +53,19 @@ class AccordionContainer extends Base {
53
53
  * @protected
54
54
  */
55
55
  createItems() {
56
- const me = this,
57
- items = me.items,
58
- title = me.title;
59
- let iconCls = me.iconCls || ['no-icon'],
56
+ let me = this,
60
57
  arrowCls = me.arrowCls || 'fa-caret-down',
58
+ iconCls = me.iconCls || ['no-icon'],
59
+ items = me.items,
60
+ title = me.title,
61
61
  header, content;
62
62
 
63
63
  if (!Neo.isArray(iconCls)) {
64
- iconCls = iconCls.split(' ');
64
+ iconCls = iconCls.split(' ')
65
65
  }
66
+
66
67
  if (!Neo.isArray(arrowCls)) {
67
- arrowCls = arrowCls.split(' ');
68
+ arrowCls = arrowCls.split(' ')
68
69
  }
69
70
 
70
71
  header = Neo.create({
@@ -85,6 +86,7 @@ class AccordionContainer extends Base {
85
86
  cls : ['fa', ...arrowCls]
86
87
  }]
87
88
  });
89
+
88
90
  content = {
89
91
  ntype : 'container',
90
92
  flag : 'content',
@@ -98,7 +100,7 @@ class AccordionContainer extends Base {
98
100
 
99
101
  me.addDomListeners([
100
102
  {click: me.onExpandClick, delegate: 'neo-accordion-header-arrow'}
101
- ]);
103
+ ])
102
104
  }
103
105
 
104
106
  /**
@@ -106,15 +108,15 @@ class AccordionContainer extends Base {
106
108
  * @param {Boolean} isExpanded
107
109
  */
108
110
  afterSetExpanded(isExpanded) {
109
- const me = this,
110
- cls = me.cls,
111
- fn = isExpanded ? 'add' : 'remove';
111
+ let me = this,
112
+ cls = me.cls,
113
+ fn = isExpanded ? 'add' : 'remove';
112
114
 
113
115
  NeoArray[fn](cls, 'neo-expanded');
114
116
  me.cls = cls;
115
117
 
116
118
  // Ensure scrollbars are not flipping in and out
117
- Neo.timeout(450).then(() => {
119
+ me.timeout(450).then(() => {
118
120
  NeoArray[fn](cls, 'neo-scrollable');
119
121
  me.cls = cls;
120
122
  })
@@ -133,7 +135,9 @@ class AccordionContainer extends Base {
133
135
  if (iconEl) {
134
136
  let cls = iconEl.cls;
135
137
 
136
- if (!Neo.isArray(newValue)) newValue = newValue.split(' ');
138
+ if (!Neo.isArray(newValue)) {
139
+ newValue = newValue.split(' ')
140
+ }
137
141
 
138
142
  NeoArray.remove(cls, oldValue);
139
143
  NeoArray.add(cls, newValue);
@@ -158,9 +162,9 @@ class AccordionContainer extends Base {
158
162
  * Otherwise we set this.expanded to the new value.
159
163
  */
160
164
  onExpandClick() {
161
- const me = this,
162
- currentState = me.expanded;
163
- let parent = me.up('accordion');
165
+ let me = this,
166
+ currentState = me.expanded,
167
+ parent = me.up('accordion');
164
168
 
165
169
  if (parent.ntype === 'accordion') {
166
170
  parent.childExpandChange({
@@ -93,7 +93,7 @@ class Dialog extends Base {
93
93
 
94
94
  iconNode.removeDom = !value || value === '';
95
95
  this.update();
96
- }
96
+ }
97
97
 
98
98
  /**
99
99
  * Triggered after the title config got changed
@@ -104,7 +104,7 @@ class Dialog extends Base {
104
104
  afterSetTitle(value, oldValue) {
105
105
  this.headerToolbar?.down({flag: 'panel-header-title'}).set({
106
106
  text: value
107
- });
107
+ })
108
108
  }
109
109
 
110
110
  /**
@@ -149,7 +149,7 @@ class Dialog extends Base {
149
149
  hidden: !me.title,
150
150
  text : me.title
151
151
  }, ...me.headerConfig.items || []],
152
-
152
+
153
153
  ...headerConfigCopy
154
154
  });
155
155
 
@@ -190,11 +190,12 @@ class Dialog extends Base {
190
190
  */
191
191
  async show(modal = true) {
192
192
  let me = this;
193
- await Neo.timeout(20);
193
+
194
+ await me.timeout(20);
194
195
 
195
196
  Neo.main.addon.Dialog[modal ? 'showModal': 'show']({
196
- id: me.id,
197
- appName: me.appName
197
+ appName: me.appName,
198
+ id : me.id
198
199
  });
199
200
  }
200
201
  }
@@ -88,7 +88,7 @@ class Application extends Base {
88
88
  let me = this;
89
89
 
90
90
  // short delay to ensure changes from onHashChange() got applied
91
- await Neo.timeout(Neo.config.hash ? 200 : 10);
91
+ await me.timeout(Neo.config.hash ? 200 : 10);
92
92
 
93
93
  Logger.addContextMenuListener(me.mainView);
94
94
 
package/src/core/Base.mjs CHANGED
@@ -79,6 +79,13 @@ class Base {
79
79
  module: null
80
80
  }
81
81
 
82
+ /**
83
+ * Internal cache for all timeout ids when using this.timeout()
84
+ * @member {Number[]} timeoutIds=[]
85
+ * @private
86
+ */
87
+ #timeoutIds = []
88
+
82
89
  /**
83
90
  * Applies the observable mixin if needed, grants remote access if needed.
84
91
  * @param {Object} config={}
@@ -240,6 +247,10 @@ class Base {
240
247
  destroy() {
241
248
  let me = this;
242
249
 
250
+ me.#timeoutIds.forEach(id => {
251
+ clearTimeout(id)
252
+ });
253
+
243
254
  if (Base.instanceManagerAvailable === true) {
244
255
  Neo.manager.Instance.unregister(me)
245
256
  } else if (Neo.idMap) {
@@ -503,6 +514,20 @@ class Base {
503
514
  return false
504
515
  }
505
516
 
517
+ /**
518
+ * Stores timeoutIds internally, so that destroy() can clear them if needed
519
+ * @param {Number} time in milliseconds
520
+ * @returns {Promise<any>}
521
+ */
522
+ timeout(time) {
523
+ return new Promise(resolve => {
524
+ let timeoutIds = this.#timeoutIds,
525
+ timeoutId = setTimeout(() => {timeoutIds.splice(timeoutIds.indexOf(timeoutId, 1)); resolve()}, time);
526
+
527
+ timeoutIds.push(timeoutId)
528
+ })
529
+ }
530
+
506
531
  /**
507
532
  * <p>Enhancing the toString() method, e.g.</p>
508
533
  * `Neo.create('Neo.button.Base').toString() => "[object Neo.button.Base (neo-button-1)]"`
package/src/core/Util.mjs CHANGED
@@ -199,14 +199,6 @@ class Util extends Base {
199
199
  return typeof value === 'string';
200
200
  }
201
201
 
202
- /**
203
- * @param {Number} time in milliseconds
204
- * @returns {Promise<unknown>}
205
- */
206
- static timeout(time) {
207
- return new Promise(resolve => setTimeout(resolve, time));
208
- }
209
-
210
202
  /**
211
203
  * Converts any iterable (strings, numeric indices and a length property) into a true array
212
204
  * @param {Object|String} iterable
@@ -246,7 +238,6 @@ Neo.applyFromNs(Neo, Util, {
246
238
  isNumber : 'isNumber',
247
239
  isObject : 'isObject',
248
240
  isString : 'isString',
249
- timeout : 'timeout',
250
241
  toArray : 'toArray'
251
242
  }, true);
252
243
 
@@ -298,7 +298,7 @@ class Base extends Panel {
298
298
 
299
299
  me.closeOrHide(false);
300
300
 
301
- await Neo.timeout(30);
301
+ await me.timeout(30);
302
302
 
303
303
  await Neo.currentWorker.promiseMessage('main', {
304
304
  action: 'updateDom',
@@ -314,7 +314,7 @@ class Base extends Panel {
314
314
  }]
315
315
  });
316
316
 
317
- await Neo.timeout(250);
317
+ await me.timeout(250);
318
318
 
319
319
  await Neo.currentWorker.promiseMessage('main', {
320
320
  action: 'updateDom',
@@ -340,7 +340,7 @@ class Base extends Panel {
340
340
  parentId: 'document.body'
341
341
  });
342
342
 
343
- await Neo.timeout(30);
343
+ await me.timeout(30);
344
344
 
345
345
  await Neo.currentWorker.promiseMessage('main', {
346
346
  action: 'updateDom',
@@ -357,9 +357,9 @@ class Base extends Panel {
357
357
  }]
358
358
  });
359
359
 
360
- await Neo.timeout(200);
360
+ await me.timeout(200);
361
361
 
362
- me.show(false);
362
+ me.show(false)
363
363
  }
364
364
 
365
365
  /**
@@ -82,14 +82,14 @@ class SortZone extends DragZone {
82
82
  * @param {Object} data
83
83
  */
84
84
  async onDragEnd(data) {
85
- await Neo.timeout(10);
86
-
87
85
  let me = this,
88
86
  owner = me.owner,
89
87
  itemStyles = me.itemStyles,
90
88
  ownerStyle = owner.style || {},
91
89
  itemStyle;
92
90
 
91
+ await me.timeout(10);
92
+
93
93
  if (owner.sortable) {
94
94
  ownerStyle.height = me.ownerStyle.height || null;
95
95
  ownerStyle.width = me.ownerStyle.width || null;
@@ -127,7 +127,7 @@ class SortZone extends DragZone {
127
127
  startIndex : -1
128
128
  });
129
129
 
130
- await Neo.timeout(30);
130
+ await me.timeout(30);
131
131
 
132
132
  me.dragEnd(data); // we do not want to trigger the super class call here
133
133
  }
@@ -268,7 +268,7 @@ class Picker extends Text {
268
268
  picker = me.getPicker();
269
269
 
270
270
  // avoid breaking selection model cls updates
271
- await Neo.timeout(30);
271
+ await me.timeout(30);
272
272
 
273
273
  if (me.pickerIsMounted) {
274
274
  picker.unmount();
package/src/list/Base.mjs CHANGED
@@ -383,6 +383,10 @@ class Base extends Component {
383
383
  }
384
384
  }
385
385
 
386
+ if (record.cls) {
387
+ NeoArray.add(cls, record.cls)
388
+ }
389
+
386
390
  if (record[me.disabledField]) {
387
391
  cls.push('neo-disabled')
388
392
  }
@@ -74,7 +74,7 @@ class ScrollSync extends Base {
74
74
  */
75
75
  async register(data) {
76
76
  // short delay to ensure the target node got mounted
77
- await Neo.timeout(50)
77
+ await this.timeout(50)
78
78
 
79
79
  let sourceId = data.sourceId,
80
80
  sourceMap = this.sourceMap,
@@ -19,6 +19,9 @@ class Model extends BaseModel {
19
19
  * @member {Object[]} fields
20
20
  */
21
21
  fields: [{
22
+ name: 'cls',
23
+ type: 'Array'
24
+ }, {
22
25
  name: 'handler',
23
26
  type: 'Function'
24
27
  }, {