neo.mjs 3.0.0 → 3.0.1

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.
@@ -166,9 +166,7 @@ class MainContainerController extends ComponentController {
166
166
  let me = this;
167
167
 
168
168
  Neo.Main.getWindowData().then(winData => {
169
- Neo.main.DomAccess.getBoundingClientRect({
170
- id: [me.getReference(containerReference).id]
171
- }).then(data => {
169
+ me.component.getDomRect(me.getReference(containerReference).id).then(data => {
172
170
  let {height, left, top, width} = data[0];
173
171
 
174
172
  height -= 50; // popup header in Chrome
@@ -178,7 +176,7 @@ class MainContainerController extends ComponentController {
178
176
  Neo.Main.windowOpen({
179
177
  url : `../${url}/index.html`,
180
178
  windowFeatures: `height=${height},left=${left},top=${top},width=${width}`,
181
- windowName : windowName
179
+ windowName
182
180
  });
183
181
  });
184
182
  });
@@ -371,13 +369,11 @@ class MainContainerController extends ComponentController {
371
369
  onComponentConstructed() {
372
370
  super.onComponentConstructed();
373
371
 
374
- if (!Neo.config.hash) {
375
- this.onHashChange({
376
- country : 'all',
377
- hash : {mainview: 'table'},
378
- hashString: 'mainview=table'
379
- }, null);
380
- }
372
+ !Neo.config.hash && this.onHashChange({
373
+ country : 'all',
374
+ hash : {mainview: 'table'},
375
+ hashString: 'mainview=table'
376
+ }, null);
381
377
  }
382
378
 
383
379
  /**
@@ -611,16 +607,16 @@ class MainContainerController extends ComponentController {
611
607
  } else {
612
608
  [component.appName, ...me.connectedApps].forEach(appName => {
613
609
  Neo.main.addon.Stylesheet.swapStyleSheet({
614
- appName: appName,
615
- href : href,
616
- id : 'neo-theme'
610
+ appName,
611
+ href,
612
+ id: 'neo-theme'
617
613
  });
618
614
  });
619
615
  }
620
616
 
621
617
  button.set({
622
- iconCls: iconCls,
623
- text : buttonText
618
+ iconCls,
619
+ text: buttonText
624
620
  });
625
621
 
626
622
  if (mapView) {
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "author" : "Tobias Uhlig",
4
+ "authorImage" : "author_TobiasUhlig.jpeg",
5
+ "date" : "Dec 15, 2021",
6
+ "id" : 47,
7
+ "image" : "resolving-pitfalls-of-the-ecmascript-class-system.png",
8
+ "name" : "Resolving pitfalls of the ECMAScript class system",
9
+ "provider" : "Medium",
10
+ "publisher" : "ITNEXT",
11
+ "selectedInto": [],
12
+ "type" : "Blog Post",
13
+ "url" : "https://itnext.io/resolving-pitfalls-of-the-ecmascript-class-system-856024218399?source=friends_link&sk=9733342654c50d8d618671b754089e1d"
14
+ },
2
15
  {
3
16
  "author" : "Tobias Uhlig",
4
17
  "authorImage" : "author_TobiasUhlig.jpeg",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,22 +36,22 @@
36
36
  "@fortawesome/fontawesome-free": "^5.15.4",
37
37
  "@material/mwc-button": "^0.25.3",
38
38
  "@material/mwc-textfield": "^0.25.3",
39
- "autoprefixer": "^10.4.0",
39
+ "autoprefixer": "^10.4.1",
40
40
  "chalk": "^4.1.2",
41
41
  "clean-webpack-plugin": "^4.0.0",
42
42
  "commander": "^8.3.0",
43
- "cssnano": "^5.0.12",
43
+ "cssnano": "^5.0.14",
44
44
  "envinfo": "^7.8.1",
45
45
  "fs-extra": "^10.0.0",
46
46
  "highlightjs-line-numbers.js": "^2.8.0",
47
47
  "inquirer": "^8.1.5",
48
48
  "neo-jsdoc": "^1.0.1",
49
49
  "neo-jsdoc-x": "^1.0.4",
50
- "postcss": "^8.4.4",
51
- "sass": "^1.45.0",
50
+ "postcss": "^8.4.5",
51
+ "sass": "^1.45.2",
52
52
  "webpack": "^5.65.0",
53
53
  "webpack-cli": "^4.9.1",
54
- "webpack-dev-server": "4.6.0",
54
+ "webpack-dev-server": "4.7.2",
55
55
  "webpack-hook-plugin": "^1.0.7",
56
56
  "webpack-node-externals": "^3.0.0"
57
57
  },
@@ -488,9 +488,7 @@ class YearComponent extends Component {
488
488
  if (!me.isUpdating) {
489
489
  me.isUpdating = true;
490
490
 
491
- Neo.main.DomAccess.getBoundingClientRect({
492
- id: me.id
493
- }).then(data => {
491
+ me.getDomRect().then(data => {
494
492
  scrollFromTop = me.scrollNewYearFromTop && increment < 0 || !me.scrollNewYearFromTop && increment > 0;
495
493
  vdom = me.vdom;
496
494
  y = scrollFromTop ? 0 : -data.height;
@@ -316,9 +316,7 @@ class Component extends BaseComponent {
316
316
  }
317
317
 
318
318
  setTimeout(() => {
319
- Neo.main.DomAccess.getBoundingClientRect({
320
- id: [me.vdom.cn[1].id, me.vdom.cn[0].id]
321
- }).then(data => {
319
+ me.getDomRect([me.vdom.cn[1].id, me.vdom.cn[0].id]).then(data => {
322
320
  me.headerHeight = data[1].height;
323
321
 
324
322
  Neo.main.DomAccess.scrollTo({
@@ -458,10 +458,7 @@ class Component extends BaseComponent {
458
458
  }
459
459
 
460
460
  setTimeout(() => {
461
- Neo.main.DomAccess.getBoundingClientRect({
462
- appName: me.appName,
463
- id : me.getColumnContainer().id
464
- }).then(data => {
461
+ me.getDomRect(me.getColumnContainer().id).then(data => {
465
462
  Neo.main.DomAccess.scrollBy({
466
463
  appName : me.appName,
467
464
  direction: 'left',
@@ -501,9 +501,7 @@ class EventDragZone extends DragZone {
501
501
  let me = this,
502
502
  eventDuration, offsetX, offsetY;
503
503
 
504
- Neo.main.DomAccess.getBoundingClientRect({
505
- id: [me.getDragElementRoot().id, data.path[1].id]
506
- }).then(rects => {
504
+ me.owner.getDomRect([me.getDragElementRoot().id, data.path[1].id]).then(rects => {
507
505
  eventDuration = (me.eventRecord.endDate - me.eventRecord.startDate) / 60 / 1000;
508
506
  offsetX = data.clientX - rects[0].left;
509
507
  offsetY = data.clientY - rects[0].top;
@@ -959,6 +959,19 @@ class Base extends CoreBase {
959
959
  return this.getConfigInstanceByNtype('controller', ntype);
960
960
  }
961
961
 
962
+ /**
963
+ * Convenience shortcut
964
+ * @param {String[]|String} id=this.id
965
+ * @param {String} appName=this.appName
966
+ * @returns {Promise<*>}
967
+ */
968
+ getDomRect(id=this.id, appName=this.appName) {
969
+ return Neo.main.DomAccess.getBoundingClientRect({
970
+ appName,
971
+ id
972
+ });
973
+ }
974
+
962
975
  /**
963
976
  * Returns this.model or the closest parent model
964
977
  * @param {String} [ntype]
@@ -400,9 +400,7 @@ class DateSelector extends Component {
400
400
  if (!me.isUpdating) {
401
401
  me.isUpdating = true;
402
402
 
403
- Neo.main.DomAccess.getBoundingClientRect({
404
- id: [me.getCenterContentEl().id, me.getHeaderMonthEl().id]
405
- }).then(data => {
403
+ me.getDomRect([me.getCenterContentEl().id, me.getHeaderMonthEl().id]).then(data => {
406
404
  vdom = me.vdom;
407
405
  x = slideDirection === 'right' ? 0 : -data[0].width;
408
406
 
@@ -486,9 +484,7 @@ class DateSelector extends Component {
486
484
  if (!me.isUpdating) {
487
485
  me.isUpdating = true;
488
486
 
489
- Neo.main.DomAccess.getBoundingClientRect({
490
- id: me.getCenterContentEl().id
491
- }).then(data => {
487
+ me.getDomRect(me.getCenterContentEl().id).then(data => {
492
488
  scrollFromTop = me.scrollNewYearFromTop && increment < 0 || !me.scrollNewYearFromTop && increment > 0;
493
489
  vdom = me.vdom;
494
490
  y = scrollFromTop ? 0 : -data.height;
@@ -158,9 +158,7 @@ class Splitter extends Component {
158
158
 
159
159
  me.style = style;
160
160
 
161
- Neo.main.DomAccess.getBoundingClientRect({
162
- id: me.parentId
163
- }).then(parentRect => {
161
+ me.getDomRect(me.parentId).then(parentRect => {
164
162
  parent = Neo.getComponent(me.parentId);
165
163
  index = parent.indexOf(me);
166
164
  sibling = parent.items[resizeNext ? index + 1 :index - 1];
@@ -286,10 +286,7 @@ class Base extends Panel {
286
286
  appName = me.appName,
287
287
  id = me.getAnimateTargetId();
288
288
 
289
- Neo.main.DomAccess.getBoundingClientRect({
290
- appName: appName,
291
- id : [me.id, me.animateTargetId]
292
- }).then(rects => {
289
+ me.getDomRect([me.id, me.animateTargetId]).then(rects => {
293
290
  Neo.currentWorker.promiseMessage('main', {
294
291
  action : 'mountDom',
295
292
  appName : appName,
@@ -336,10 +333,7 @@ class Base extends Panel {
336
333
  appName = me.appName,
337
334
  id = me.getAnimateTargetId();
338
335
 
339
- Neo.main.DomAccess.getBoundingClientRect({
340
- appName: appName,
341
- id : me.animateTargetId
342
- }).then(rect => {
336
+ me.getDomRect(me.animateTargetId).then(rect => {
343
337
  Neo.currentWorker.promiseMessage('main', {
344
338
  action : 'mountDom',
345
339
  appName : appName,
@@ -530,10 +524,7 @@ class Base extends Panel {
530
524
  initialTransitionProperty, wrapperStyle;
531
525
 
532
526
  if (!me.maximized) {
533
- Neo.main.DomAccess.getBoundingClientRect({
534
- appName: me.appName,
535
- id : me.dragZone.dragProxy.id
536
- }).then(rect => {
527
+ me.getDomRect(me.dragZone.dragProxy.id).then(rect => {
537
528
  wrapperStyle = me.wrapperStyle;
538
529
 
539
530
  Object.assign(wrapperStyle, {
@@ -204,9 +204,7 @@ class SortZone extends DragZone {
204
204
  });
205
205
  });
206
206
 
207
- Neo.main.DomAccess.getBoundingClientRect({
208
- id: [owner.id].concat(owner.items.map(e => e.id))
209
- }).then(itemRects => {
207
+ owner.getDomRect([owner.id].concat(owner.items.map(e => e.id))).then(itemRects => {
210
208
  me.ownerRect = itemRects[0];
211
209
 
212
210
  ownerStyle.height = `${itemRects[0].height}px`;
@@ -143,9 +143,7 @@ class Picker extends Text {
143
143
  getClientRectsThenShow(callback, callbackScope) {
144
144
  let me = this;
145
145
 
146
- Neo.main.DomAccess.getBoundingClientRect({
147
- id: [me.id, me.getInputWrapperId(), 'body']
148
- }).then(data => {
146
+ me.getDomRect([me.id, me.getInputWrapperId(), 'body']).then(data => {
149
147
  me.clientRects = data;
150
148
  me.showPicker(callback, callbackScope);
151
149
  });
@@ -921,9 +921,7 @@ class Text extends Base {
921
921
  updateCenterBorderElWidth(silent=false) {
922
922
  let me = this;
923
923
 
924
- me.mounted && Neo.main.DomAccess.getBoundingClientRect({
925
- id: me.getCenterBorderEl().id
926
- }).then(data => {
924
+ me.mounted && me.getDomRect(me.getCenterBorderEl().id).then(data => {
927
925
  me.centerBorderElWidth = Math.round(data.width * .7) + 8;
928
926
 
929
927
  if (!silent) {
@@ -118,9 +118,7 @@ class Animate extends Base {
118
118
  onOwnerMounted() {
119
119
  let me = this;
120
120
 
121
- Neo.main.DomAccess.getBoundingClientRect({
122
- id: me.owner.id
123
- }).then(rect => {
121
+ me.owner.getDomRect().then(rect => {
124
122
  Object.assign(me, {
125
123
  columns : Math.floor(rect.width / me.itemWidth),
126
124
  ownerRect: rect,
package/src/menu/List.mjs CHANGED
@@ -193,9 +193,7 @@ class List extends BaseList {
193
193
 
194
194
  me.store.destroy();
195
195
 
196
- if (activeSubMenu) {
197
- activeSubMenu.unmount();
198
- }
196
+ activeSubMenu?.unmount();
199
197
 
200
198
  Object.entries(subMenuMap).forEach(([key, value]) => {
201
199
  value.destroy();
@@ -279,10 +277,7 @@ class List extends BaseList {
279
277
 
280
278
  if (me.activeSubMenu !== me.subMenuMap?.[me.getMenuMapId(recordId)]) {
281
279
  me.hideSubMenu();
282
-
283
- if (me.hasChildren(record)) {
284
- me.showSubMenu(nodeId, record);
285
- }
280
+ me.hasChildren(record) && me.showSubMenu(nodeId, record);
286
281
  }
287
282
  }
288
283
 
@@ -299,10 +294,7 @@ class List extends BaseList {
299
294
  subMenu = subMenuMap[subMenuMapId],
300
295
  menuStyle, style;
301
296
 
302
- Neo.main.DomAccess.getBoundingClientRect({
303
- appName: me.appName,
304
- id : nodeId
305
- }).then(rect => {
297
+ me.getDomRect(nodeId).then(rect => {
306
298
  style = {
307
299
  left: `${rect.right + me.subMenuGap}px`,
308
300
  top : `${rect.top - 1}px` // minus the border
@@ -324,7 +316,7 @@ class List extends BaseList {
324
316
  parentId : Neo.apps[me.appName].mainView.id,
325
317
  parentIndex: store.indexOf(record),
326
318
  parentMenu : me,
327
- style : style,
319
+ style,
328
320
  zIndex : me.zIndex + 1
329
321
  });
330
322
  }
@@ -396,7 +396,7 @@ class Resizable extends Base {
396
396
  me.isDragging = true;
397
397
 
398
398
  style.opacity = 0.3;
399
- me.owner.wrapperStyle = style;
399
+ owner.wrapperStyle = style;
400
400
 
401
401
  for (; i < len; i++) {
402
402
  target = data.path[i];
@@ -414,10 +414,7 @@ class Resizable extends Base {
414
414
  }
415
415
 
416
416
  if (!me.boundaryContainerRect) {
417
- Neo.main.DomAccess.getBoundingClientRect({
418
- appName: appName,
419
- id : me.boundaryContainerRect
420
- }).then(rect => {
417
+ owner.getDomRect(me.boundaryContainerRect).then(rect => {
421
418
  me.boundaryContainerRect = rect;
422
419
  });
423
420
  }
package/src/tab/Strip.mjs CHANGED
@@ -80,9 +80,7 @@ class Strip extends Component {
80
80
  ids = ids.map(e => e?.id).filter(Boolean);
81
81
 
82
82
  if (me.useActiveTabIndicator) {
83
- Neo.main.DomAccess.getBoundingClientRect({
84
- id: ids
85
- }).then(data => {
83
+ me.getDomRect(ids).then(data => {
86
84
  me.moveActiveIndicator(data);
87
85
  });
88
86
  }