neo.mjs 8.0.0-alpha.1 → 8.0.0-beta.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.
Files changed (66) hide show
  1. package/.github/CODING_GUIDELINES.md +5 -5
  2. package/.github/CONCEPT.md +10 -10
  3. package/apps/ServiceWorker.mjs +2 -2
  4. package/apps/covid/view/MainContainer.mjs +14 -14
  5. package/apps/covid/view/TableContainer.mjs +2 -2
  6. package/apps/portal/index.html +1 -1
  7. package/apps/portal/view/ViewportController.mjs +2 -2
  8. package/apps/portal/view/examples/TabContainer.mjs +11 -11
  9. package/apps/portal/view/home/FooterContainer.mjs +1 -1
  10. package/apps/portal/view/home/parts/MainNeo.mjs +6 -2
  11. package/apps/realworld/view/article/CreateComponent.mjs +1 -1
  12. package/apps/realworld2/view/HomeContainer.mjs +7 -7
  13. package/apps/sharedcovid/view/MainContainer.mjs +17 -17
  14. package/apps/sharedcovid/view/TableContainer.mjs +2 -2
  15. package/buildScripts/createApp.mjs +2 -2
  16. package/buildScripts/createClass.mjs +4 -6
  17. package/docs/app/view/ContentTabContainer.mjs +1 -1
  18. package/docs/app/view/MainContainer.mjs +3 -3
  19. package/docs/app/view/MainContainerController.mjs +9 -9
  20. package/examples/ServiceWorker.mjs +2 -2
  21. package/examples/component/mwc/buttons/MainContainer.mjs +2 -2
  22. package/examples/component/mwc/textFields/MainContainer.mjs +2 -2
  23. package/examples/fields/MainContainer.mjs +197 -228
  24. package/examples/preloadingAssets/view/MainContainer.mjs +2 -2
  25. package/examples/tab/container/MainContainer.mjs +7 -9
  26. package/examples/tabs/MainContainer.mjs +3 -3
  27. package/examples/tabs/MainContainer2.mjs +4 -4
  28. package/examples/videoMove/MainContainer.mjs +14 -7
  29. package/examples/viewport/MainContainer.mjs +3 -3
  30. package/package.json +6 -6
  31. package/resources/data/deck/learnneo/pages/benefits/FormsEngine.md +13 -13
  32. package/resources/data/deck/learnneo/pages/benefits/Speed.md +5 -4
  33. package/resources/data/deck/training/pages/2022-12-27T21-55-23-144Z.md +2 -2
  34. package/resources/data/deck/training/pages/2022-12-28T17-11-34-653Z.md +6 -6
  35. package/resources/data/deck/training/pages/2022-12-29T18-36-08-226Z.md +2 -2
  36. package/resources/data/deck/training/pages/2022-12-29T18-36-56-893Z.md +2 -2
  37. package/resources/data/deck/training/pages/2022-12-29T20-37-08-919Z.md +2 -2
  38. package/resources/data/deck/training/pages/2022-12-29T20-37-20-344Z.md +2 -2
  39. package/resources/data/deck/training/pages/2023-01-01T21-11-58-025Z.md +3 -3
  40. package/resources/data/deck/training/pages/2023-01-16T20-24-09-690Z.md +4 -4
  41. package/resources/data/deck/training/pages/2023-02-05T17-44-53-815Z.md +3 -3
  42. package/resources/data/deck/training/pages/2023-02-05T17-45-40-114Z.md +1 -1
  43. package/resources/scss/src/calendar/view/week/Component.scss +6 -0
  44. package/resources/scss/src/component/DateSelector.scss +1 -0
  45. package/src/DefaultConfig.mjs +2 -2
  46. package/src/calendar/view/MainContainer.mjs +4 -1
  47. package/src/calendar/view/SettingsContainer.mjs +13 -28
  48. package/src/calendar/view/YearComponent.mjs +0 -3
  49. package/src/calendar/view/calendars/ColorsList.mjs +5 -0
  50. package/src/calendar/view/calendars/List.mjs +8 -0
  51. package/src/code/LivePreview.mjs +10 -10
  52. package/src/component/Base.mjs +88 -55
  53. package/src/container/Base.mjs +2 -2
  54. package/src/form/field/Text.mjs +1 -1
  55. package/src/form/field/Time.mjs +5 -3
  56. package/src/form/field/trigger/Time.mjs +2 -1
  57. package/src/layout/Card.mjs +10 -6
  58. package/src/layout/Cube.mjs +15 -4
  59. package/src/list/Base.mjs +7 -1
  60. package/src/list/Color.mjs +3 -3
  61. package/src/main/DomEvents.mjs +1 -1
  62. package/src/main/DomUtils.mjs +39 -36
  63. package/src/tab/Container.mjs +3 -5
  64. package/src/toolbar/Base.mjs +26 -8
  65. package/src/util/VNode.mjs +6 -8
  66. package/src/vdom/Helper.mjs +19 -6
@@ -151,14 +151,7 @@ class Base extends Container {
151
151
  let items = this._items;
152
152
 
153
153
  if (Array.isArray(items)) {
154
- items.forEach((item, index) => {
155
- if (item === '->') {
156
- items[index] = Neo.create({
157
- module: Component,
158
- flex : 1
159
- })
160
- }
161
- })
154
+ this._items = items.map(item => this.replaceSpacer(item))
162
155
  }
163
156
 
164
157
  return super.createItems()
@@ -203,6 +196,31 @@ class Base extends Container {
203
196
 
204
197
  return layoutConfig || me.layout
205
198
  }
199
+
200
+ /**
201
+ * Inserts an item or array of items at a specific index
202
+ * @param {Number} index
203
+ * @param {Array|Object} item
204
+ * @param {Boolean} [silent=false]
205
+ * @returns {Neo.component.Base|Neo.component.Base[]}
206
+ */
207
+ insert(index, item, silent=false) {
208
+ if (Array.isArray(item)) {
209
+ item = item.map(item => this.replaceSpacer(item))
210
+ } else {
211
+ item = this.replaceSpacer(item)
212
+ }
213
+
214
+ return super.insert(index, item, silent)
215
+ }
216
+
217
+ /**
218
+ * @param {Array|Object|String} item
219
+ * @returns {Array|Object}
220
+ */
221
+ replaceSpacer(item) {
222
+ return item === '->' ? {module: Component, flex: 1} : item
223
+ }
206
224
  }
207
225
 
208
226
  export default Neo.setupClass(Base);
@@ -25,7 +25,7 @@ class VNode extends Base {
25
25
  * {String} parentId
26
26
  * {Object} vnode
27
27
  */
28
- static findChildVnode(vnode, opts, index, parentNode) {
28
+ static find(vnode, opts, index, parentNode) {
29
29
  vnode = VNode.getVnode(vnode);
30
30
 
31
31
  index = index || 0;
@@ -68,7 +68,7 @@ class VNode extends Base {
68
68
  }
69
69
  } else if (Neo.isArray(value) && Neo.isArray(vnode[key])) {
70
70
  // todo: either search the vnode array for all keys or compare if the arrays are equal.
71
- throw new Error('findChildVnode: cls matching not supported for target & source types of Arrays')
71
+ throw new Error('find: cls matching not supported for target & source types of Arrays')
72
72
  }
73
73
  break
74
74
  case 'style':
@@ -98,7 +98,7 @@ class VNode extends Base {
98
98
  }
99
99
 
100
100
  for (; i < len; i++) {
101
- subChild = VNode.findChildVnode(vnode.childNodes[i], opts, i, vnode);
101
+ subChild = VNode.find(vnode.childNodes[i], opts, i, vnode);
102
102
 
103
103
  if (subChild) {
104
104
  return subChild
@@ -114,7 +114,7 @@ class VNode extends Base {
114
114
  * @param {String|null} id
115
115
  * @returns {Object|null} child vnode or null
116
116
  */
117
- static findChildVnodeById(vnode, id) {
117
+ static getById(vnode, id) {
118
118
  vnode = VNode.getVnode(vnode);
119
119
 
120
120
  let childNodes = vnode.childNodes || [],
@@ -133,7 +133,7 @@ class VNode extends Base {
133
133
  return childNode
134
134
  }
135
135
 
136
- childNode = VNode.findChildVnodeById(childNode, id);
136
+ childNode = VNode.getById(childNode, id);
137
137
 
138
138
  if (childNode) {
139
139
  return childNode
@@ -150,9 +150,7 @@ class VNode extends Base {
150
150
  * @returns {String[]} childIds
151
151
  */
152
152
  static getChildIds(vnode, childIds=[]) {
153
- let childNodes = vnode?.childNodes || [];
154
-
155
- childNodes.forEach(childNode => {
153
+ vnode?.childNodes?.forEach(childNode => {
156
154
  if (childNode.id && !childNode.componentId) {
157
155
  childIds.push(childNode.id)
158
156
  }
@@ -309,14 +309,14 @@ class Helper extends Base {
309
309
  }
310
310
 
311
311
  if (childNode) {
312
- if (oldVnodeMap.get(childNode.id)) {
313
- me.moveNode({deltas, insertDelta, oldVnodeMap, vnode: childNode, vnodeMap});
312
+ if (me.isMovedNode(childNode, oldVnodeMap)) {
313
+ me.moveNode({deltas, insertDelta, oldVnodeMap, vnode: childNode, vnodeMap})
314
314
  } else {
315
315
  me.insertNode({deltas, index: i + insertDelta, oldVnodeMap, vnode: childNode, vnodeMap});
316
316
  }
317
317
 
318
318
  if (oldChildNode && vnodeId === vnodeMap.get(oldChildNodeId)?.parentNode.id) {
319
- len++;
319
+ len++
320
320
  }
321
321
  }
322
322
  }
@@ -600,9 +600,7 @@ class Helper extends Base {
600
600
  id = vnode?.id;
601
601
 
602
602
  if (id) {
603
- let currentNode = oldVnodeMap.get(id)
604
-
605
- if (currentNode) {
603
+ if (this.isMovedNode(vnode, oldVnodeMap)) {
606
604
  movedNodes.set(id, vnodeMap.get(id))
607
605
  } else {
608
606
  vnode.childNodes?.forEach(childNode => {
@@ -647,6 +645,21 @@ class Helper extends Base {
647
645
  })
648
646
  }
649
647
 
648
+ /**
649
+ *
650
+ * @param {Neo.vdom.VNode} vnode
651
+ * @param {Map} oldVnodeMap
652
+ * @returns {Boolean}
653
+ */
654
+ isMovedNode(vnode, oldVnodeMap) {
655
+ let oldVnode = oldVnodeMap.get(vnode.id);
656
+
657
+ return oldVnode && (
658
+ !oldVnode.vnode.componentId || // the old vnode is not a reference
659
+ vnode.componentId === oldVnode.vnode.componentId // old & new nodes are the same references
660
+ )
661
+ }
662
+
650
663
  /**
651
664
  * @param {Object} config
652
665
  * @param {Object} config.deltas