neo.mjs 6.18.3 → 6.19.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 (94) hide show
  1. package/README.md +28 -214
  2. package/apps/ServiceWorker.mjs +2 -2
  3. package/apps/colors/view/ViewportController.mjs +7 -3
  4. package/apps/portal/data/blog.json +13 -0
  5. package/apps/portal/view/HeaderToolbar.mjs +2 -2
  6. package/apps/portal/view/Viewport.mjs +4 -2
  7. package/apps/portal/view/ViewportController.mjs +88 -7
  8. package/apps/portal/view/blog/Container.mjs +8 -8
  9. package/apps/portal/view/blog/List.mjs +6 -6
  10. package/apps/portal/view/home/FooterContainer.mjs +123 -0
  11. package/apps/portal/view/home/MainContainer.mjs +3 -2
  12. package/apps/portal/view/home/parts/AfterMath.mjs +17 -24
  13. package/apps/portal/view/home/parts/Colors.mjs +2 -2
  14. package/apps/portal/view/home/parts/How.mjs +3 -3
  15. package/apps/portal/view/home/parts/MainNeo.mjs +6 -7
  16. package/apps/portal/view/home/parts/References.mjs +88 -0
  17. package/apps/portal/view/learn/MainContainer.mjs +3 -2
  18. package/apps/portal/view/learn/MainContainerController.mjs +11 -0
  19. package/apps/portal/view/learn/PageContainer.mjs +5 -3
  20. package/apps/portal/view/services/Component.mjs +73 -0
  21. package/apps/website/data/blog.json +13 -0
  22. package/examples/ServiceWorker.mjs +2 -2
  23. package/examples/component/carousel/MainContainer.mjs +42 -33
  24. package/examples/layout/cube/MainContainer.mjs +217 -0
  25. package/examples/layout/cube/app.mjs +6 -0
  26. package/examples/layout/cube/index.html +11 -0
  27. package/examples/layout/cube/neo-config.json +6 -0
  28. package/examples/model/twoWay/MainContainer.mjs +76 -0
  29. package/examples/model/twoWay/app.mjs +6 -0
  30. package/examples/model/twoWay/index.html +11 -0
  31. package/examples/model/twoWay/neo-config.json +6 -0
  32. package/package.json +7 -7
  33. package/resources/data/deck/learnneo/pages/Earthquakes-01-goals.md +32 -0
  34. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-01-generate-a-workspace.md +47 -0
  35. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-02-generate-the-starter-app.md +150 -0
  36. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-03-debugging.md +136 -0
  37. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-04-fetch-data.md +146 -0
  38. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-05-refactor-the-table.md +146 -0
  39. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-06-use-a-view-model.md +301 -0
  40. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-07-use-the-google-maps-addon.md +175 -0
  41. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-08-events.md +38 -0
  42. package/resources/data/deck/learnneo/pages/Earthquakes.md +8 -8
  43. package/resources/data/deck/learnneo/pages/Glossary.md +0 -0
  44. package/resources/data/deck/learnneo/pages/GuideEvents.md +80 -1
  45. package/resources/data/deck/learnneo/tree.json +2 -1
  46. package/resources/images/apps/portal/neo-references.png +0 -0
  47. package/resources/scss/src/apps/portal/Viewport.scss +18 -0
  48. package/resources/scss/src/apps/portal/blog/Container.scss +7 -7
  49. package/resources/scss/src/apps/portal/blog/List.scss +20 -16
  50. package/resources/scss/src/apps/portal/home/FooterContainer.scss +31 -0
  51. package/resources/scss/src/apps/portal/home/parts/AfterMath.scss +5 -0
  52. package/resources/scss/src/apps/portal/home/parts/MainNeo.scss +4 -5
  53. package/resources/scss/src/apps/portal/home/parts/References.scss +46 -0
  54. package/resources/scss/src/apps/portal/learn/ContentTreeList.scss +20 -0
  55. package/resources/scss/src/apps/portal/learn/ContentView.scss +4 -0
  56. package/resources/scss/src/apps/portal/learn/MainContainer.scss +1 -1
  57. package/resources/scss/src/apps/portal/learn/PageContainer.scss +22 -16
  58. package/resources/scss/src/apps/portal/services/Component.scss +20 -0
  59. package/resources/scss/src/component/Carousel.scss +21 -0
  60. package/resources/scss/src/examples/layout/cube/MainContainer.scss +7 -0
  61. package/resources/scss/src/layout/Cube.scss +80 -0
  62. package/resources/scss/src/tab/Container.scss +10 -10
  63. package/resources/scss/theme-neo-light/apps/portal/blog/Container.scss +3 -0
  64. package/resources/scss/theme-neo-light/form/field/Search.scss +1 -1
  65. package/resources/scss/theme-neo-light/tooltip/Base.scss +1 -1
  66. package/src/DefaultConfig.mjs +2 -2
  67. package/src/Main.mjs +15 -1
  68. package/src/Neo.mjs +14 -3
  69. package/src/calendar/view/MainContainer.mjs +8 -7
  70. package/src/component/Base.mjs +28 -8
  71. package/src/component/DateSelector.mjs +2 -2
  72. package/src/container/Base.mjs +3 -1
  73. package/src/dialog/Base.mjs +1 -2
  74. package/src/form/field/Time.mjs +18 -16
  75. package/src/layout/Base.mjs +43 -6
  76. package/src/layout/Card.mjs +21 -59
  77. package/src/layout/Cube.mjs +432 -0
  78. package/src/layout/Fit.mjs +9 -38
  79. package/src/layout/Flexbox.mjs +16 -17
  80. package/src/layout/Form.mjs +13 -70
  81. package/src/layout/Grid.mjs +6 -18
  82. package/src/list/Base.mjs +3 -3
  83. package/src/main/mixin/DeltaUpdates.mjs +16 -3
  84. package/src/model/Component.mjs +25 -6
  85. package/src/util/Array.mjs +36 -0
  86. package/src/vdom/Helper.mjs +338 -442
  87. package/src/vdom/VNode.mjs +12 -1
  88. package/test/siesta/siesta.js +16 -1
  89. package/test/siesta/tests/VdomCalendar.mjs +2193 -37
  90. package/test/siesta/tests/VdomHelper.mjs +287 -48
  91. package/test/siesta/tests/vdom/Advanced.mjs +368 -0
  92. package/test/siesta/tests/vdom/layout/Cube.mjs +189 -0
  93. package/test/siesta/tests/vdom/table/Container.mjs +133 -0
  94. package/resources/scss/theme-neo-light/apps/portal/learn/ContentTreeList.scss +0 -23
@@ -16,24 +16,12 @@ class Grid extends Base {
16
16
  * @member {String} ntype='layout-hbox'
17
17
  * @protected
18
18
  */
19
- ntype: 'layout-grid'
20
- }
21
-
22
- /**
23
- * Applies CSS classes to the container this layout is bound to
24
- */
25
- applyRenderAttributes() {
26
- let me = this,
27
- container = Neo.getComponent(me.containerId),
28
- wrapperCls = container?.wrapperCls || [];
29
-
30
- if (!container) {
31
- Neo.logError('layout.Grid: applyRenderAttributes -> container not yet created', me.containerId)
32
- }
33
-
34
- NeoArray.add(wrapperCls, 'neo-layout-grid');
35
-
36
- container.wrapperCls = wrapperCls
19
+ ntype: 'layout-grid',
20
+ /**
21
+ * @member {String|null} containerCls='neo-layout-fit'
22
+ * @protected
23
+ */
24
+ containerCls: 'neo-layout-grid'
37
25
  }
38
26
  }
39
27
 
package/src/list/Base.mjs CHANGED
@@ -593,10 +593,10 @@ class Base extends Component {
593
593
 
594
594
  /**
595
595
  * Calls focus() on the top level DOM node of this component or on a given node via id
596
- * @param {String} id
596
+ * @param {String} [id=this.id]
597
597
  */
598
- focus(id) {
599
- Neo.main.addon.Navigator.navigateTo([id, this.navigator])
598
+ focus(id=this.id) {
599
+ this.mounted && Neo.main.addon.Navigator.navigateTo([id, this.navigator])
600
600
  }
601
601
 
602
602
  /**
@@ -120,7 +120,7 @@ class DeltaUpdates extends Base {
120
120
  node = this.getElement(delta.id),
121
121
  parentNode = this.getElement(delta.parentId);
122
122
 
123
- if (parentNode) {
123
+ if (node && parentNode) {
124
124
  if (index >= parentNode.children.length) {
125
125
  parentNode.appendChild(node)
126
126
  } else {
@@ -132,6 +132,18 @@ class DeltaUpdates extends Base {
132
132
  }
133
133
  }
134
134
 
135
+ /**
136
+ * @param {Object} delta
137
+ * @param {String} delta.parentId
138
+ */
139
+ du_removeAll(delta) {
140
+ let node = this.getElement(delta.parentId);
141
+
142
+ if (node) {
143
+ node.innerHTML = ''
144
+ }
145
+ }
146
+
135
147
  /**
136
148
  * @param {Object} delta
137
149
  * @param {String} delta.id
@@ -225,8 +237,8 @@ class DeltaUpdates extends Base {
225
237
  });
226
238
  break
227
239
  case 'cls':
228
- node.classList.add(...value.add || []);
229
- node.classList.remove(...value.remove || []);
240
+ value.add && node.classList.add(...value.add);
241
+ value.remove && node.classList.remove(...value.remove);
230
242
  break
231
243
  case 'innerHTML':
232
244
  node.innerHTML = value || '';
@@ -311,6 +323,7 @@ class DeltaUpdates extends Base {
311
323
  focusNode : me.du_focusNode,
312
324
  insertNode : me.du_insertNode,
313
325
  moveNode : me.du_moveNode,
326
+ removeAll : me.du_removeAll,
314
327
  removeNode : me.du_removeNode,
315
328
  replaceChild : me.du_replaceChild,
316
329
  setTextContent: me.du_setTextContent,
@@ -3,8 +3,9 @@ import ClassSystemUtil from '../util/ClassSystem.mjs';
3
3
  import NeoArray from '../util/Array.mjs';
4
4
  import Observable from '../core/Observable.mjs';
5
5
 
6
- const dataVariableRegex = /data((?!(\.[a-z_]\w*\(\)))\.[a-z_]\w*)+/gi,
7
- variableNameRegex = /^\w*/;
6
+ const dataVariableRegex = /data((?!(\.[a-z_]\w*\(\)))\.[a-z_]\w*)+/gi,
7
+ twoWayBindingSymbol = Symbol.for('twoWayBinding'),
8
+ variableNameRegex = /^\w*/;
8
9
 
9
10
  /**
10
11
  * An optional component (view) model for adding bindings to configs
@@ -213,6 +214,7 @@ class Component extends Base {
213
214
  * @param {String} componentId
214
215
  * @param {String} formatter
215
216
  * @param {String} value
217
+ * @returns {String[]}
216
218
  */
217
219
  createBindingByFormatter(componentId, formatter, value) {
218
220
  let me = this,
@@ -220,7 +222,9 @@ class Component extends Base {
220
222
 
221
223
  formatterVars.forEach(key => {
222
224
  me.createBinding(componentId, key, value, formatter)
223
- })
225
+ });
226
+
227
+ return formatterVars
224
228
  }
225
229
 
226
230
  /**
@@ -228,12 +232,21 @@ class Component extends Base {
228
232
  */
229
233
  createBindings(component) {
230
234
  Object.entries(component.bind).forEach(([key, value]) => {
235
+ let twoWayBinding = false,
236
+ formatterVars;
237
+
231
238
  if (Neo.isObject(value)) {
232
- value = value.value
239
+ twoWayBinding = true;
240
+ value = value.value
233
241
  }
234
242
 
235
243
  if (!this.isStoreValue(value)) {
236
- this.createBindingByFormatter(component.id, value, key)
244
+ formatterVars = this.createBindingByFormatter(component.id, value, key);
245
+
246
+ if (twoWayBinding) {
247
+ component.bind[key].key = formatterVars[0];
248
+ component[twoWayBindingSymbol] = true;
249
+ }
237
250
  }
238
251
  })
239
252
  }
@@ -279,7 +292,13 @@ class Component extends Base {
279
292
 
280
293
  Object.defineProperty(root, key, {
281
294
  get() {
282
- return root['_' + key]
295
+ let value = root['_' + key];
296
+
297
+ if (Neo.typeOf(value) === 'Date') {
298
+ value = new Date(value.valueOf())
299
+ }
300
+
301
+ return value
283
302
  },
284
303
 
285
304
  set(value) {
@@ -18,6 +18,7 @@ class NeoArray extends Base {
18
18
  * Only primitive items will get found as duplicates
19
19
  * @param {Array} arr
20
20
  * @param {*} items
21
+ * @returns {Array}
21
22
  */
22
23
  static add(arr, items) {
23
24
  if (!Array.isArray(items)) {
@@ -52,6 +53,41 @@ class NeoArray extends Base {
52
53
  return arr.includes(item)
53
54
  }
54
55
 
56
+ /**
57
+ * Inserts an item or Array of items to an array in case it does not already exist.
58
+ * Duplicates will only get matched by reference.
59
+ * @param {Array} arr
60
+ * @param {Number} index
61
+ * @param {*} items
62
+ * @returns {Array}
63
+ */
64
+ static insert(arr, index, items) {
65
+ if (!Array.isArray(items)) {
66
+ items = [items]
67
+ }
68
+
69
+ let len = items.length -1,
70
+ i = len,
71
+ currentIndex, item;
72
+
73
+ // Iterate backwards
74
+ for (; i > -1; i--) {
75
+ item = items[i];
76
+
77
+ currentIndex = arr.indexOf(item);
78
+
79
+ if (index !== currentIndex) {
80
+ if (currentIndex > -1) {
81
+ this.move(arr, currentIndex, index)
82
+ } else {
83
+ arr.splice(index, 0, item)
84
+ }
85
+ }
86
+ }
87
+
88
+ return arr
89
+ }
90
+
55
91
  /**
56
92
  * Returns an array of items which are present in array1 and array2
57
93
  * Only supports primitive items