neo.mjs 2.3.19 → 3.0.0

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 (119) hide show
  1. package/apps/covid/view/GalleryContainer.mjs +2 -2
  2. package/apps/covid/view/HelixContainer.mjs +2 -2
  3. package/apps/covid/view/TableContainer.mjs +2 -2
  4. package/apps/krausest/view/MainComponent.mjs +2 -2
  5. package/apps/krausest/view/TableComponent.mjs +2 -2
  6. package/apps/realworld/view/HomeComponent.mjs +2 -2
  7. package/apps/realworld/view/article/CommentComponent.mjs +2 -2
  8. package/apps/realworld/view/article/Component.mjs +2 -2
  9. package/apps/realworld/view/article/CreateCommentComponent.mjs +2 -2
  10. package/apps/realworld/view/article/CreateComponent.mjs +3 -3
  11. package/apps/realworld/view/article/PreviewComponent.mjs +2 -2
  12. package/apps/realworld/view/article/TagListComponent.mjs +2 -2
  13. package/apps/realworld/view/user/ProfileComponent.mjs +2 -2
  14. package/apps/realworld/view/user/SettingsComponent.mjs +2 -2
  15. package/apps/realworld/view/user/SignUpComponent.mjs +2 -2
  16. package/apps/realworld2/view/article/HelixContainer.mjs +2 -2
  17. package/apps/realworld2/view/article/PreviewComponent.mjs +2 -2
  18. package/apps/realworld2/view/article/TagListComponent.mjs +2 -2
  19. package/apps/realworld2/view/user/LoginFormContainer.mjs +2 -2
  20. package/apps/sharedcovid/view/GalleryContainer.mjs +2 -2
  21. package/apps/sharedcovid/view/HelixContainer.mjs +2 -2
  22. package/apps/sharedcovid/view/TableContainer.mjs +2 -2
  23. package/apps/sharedcovid/view/mapboxGl/Container.mjs +2 -2
  24. package/docs/app/view/ContentTabContainer.mjs +2 -2
  25. package/docs/app/view/MainContainer.mjs +2 -2
  26. package/docs/app/view/classdetails/SourceViewComponent.mjs +2 -2
  27. package/docs/app/view/classdetails/TutorialComponent.mjs +2 -2
  28. package/docs/tutorials/02_ClassSystem.html +3 -3
  29. package/docs/tutorials/02_ClassSystem.md +2 -2
  30. package/docs/tutorials/09_TodoList_version1.html +8 -8
  31. package/examples/calendar/weekview/MainContainer.mjs +2 -2
  32. package/examples/component/coronaGallery/MainContainer.mjs +2 -2
  33. package/examples/component/coronaHelix/MainContainer.mjs +2 -2
  34. package/examples/component/gallery/MainContainer.mjs +2 -2
  35. package/examples/component/helix/MainContainer.mjs +2 -2
  36. package/examples/core/config/MainContainer.mjs +2 -2
  37. package/examples/dialog/MainContainer.mjs +2 -2
  38. package/examples/list/animate/MainContainer.mjs +2 -2
  39. package/examples/model/multiWindow/ViewportController.mjs +2 -2
  40. package/examples/todoList/version1/MainComponent.mjs +3 -3
  41. package/examples/todoList/version2/MainContainer.mjs +3 -3
  42. package/package.json +1 -1
  43. package/src/Main.mjs +2 -2
  44. package/src/Neo.mjs +26 -25
  45. package/src/button/Split.mjs +2 -2
  46. package/src/calendar/view/EditEventContainer.mjs +2 -2
  47. package/src/calendar/view/MainContainer.mjs +2 -2
  48. package/src/calendar/view/MainContainerModel.mjs +2 -2
  49. package/src/calendar/view/SettingsContainer.mjs +2 -2
  50. package/src/calendar/view/YearComponent.mjs +2 -2
  51. package/src/calendar/view/calendars/EditContainer.mjs +2 -2
  52. package/src/calendar/view/month/Component.mjs +2 -2
  53. package/src/calendar/view/week/Component.mjs +2 -2
  54. package/src/calendar/view/week/TimeAxisComponent.mjs +2 -2
  55. package/src/calendar/view/week/plugin/DragDrop.mjs +2 -2
  56. package/src/collection/Base.mjs +2 -2
  57. package/src/component/Chip.mjs +2 -2
  58. package/src/component/Circle.mjs +2 -2
  59. package/src/component/DateSelector.mjs +2 -2
  60. package/src/component/Gallery.mjs +2 -2
  61. package/src/component/Helix.mjs +2 -2
  62. package/src/component/Splitter.mjs +2 -2
  63. package/src/component/mwc/Button.mjs +2 -2
  64. package/src/component/mwc/TextField.mjs +2 -2
  65. package/src/container/Panel.mjs +2 -2
  66. package/src/controller/Application.mjs +2 -2
  67. package/src/controller/Base.mjs +2 -2
  68. package/src/controller/Component.mjs +2 -2
  69. package/src/core/Base.mjs +25 -1
  70. package/src/core/IdGenerator.mjs +1 -1
  71. package/src/data/Store.mjs +2 -2
  72. package/src/dialog/Base.mjs +2 -2
  73. package/src/draggable/DragProxyComponent.mjs +2 -2
  74. package/src/draggable/DragZone.mjs +2 -2
  75. package/src/draggable/DropZone.mjs +2 -2
  76. package/src/draggable/list/DragZone.mjs +2 -2
  77. package/src/draggable/toolbar/DragZone.mjs +2 -2
  78. package/src/filter/ToggleOperatorsButton.mjs +2 -2
  79. package/src/form/field/CheckBox.mjs +2 -2
  80. package/src/form/field/Color.mjs +2 -2
  81. package/src/form/field/Date.mjs +2 -2
  82. package/src/form/field/Display.mjs +2 -2
  83. package/src/form/field/Range.mjs +2 -2
  84. package/src/form/field/Select.mjs +2 -2
  85. package/src/form/field/Text.mjs +2 -2
  86. package/src/form/field/Time.mjs +2 -2
  87. package/src/form/field/trigger/Base.mjs +2 -2
  88. package/src/form/field/trigger/Time.mjs +2 -2
  89. package/src/grid/Container.mjs +2 -2
  90. package/src/list/Base.mjs +2 -2
  91. package/src/list/plugin/Animate.mjs +2 -2
  92. package/src/main/DomAccess.mjs +2 -2
  93. package/src/main/DomEvents.mjs +2 -2
  94. package/src/main/addon/AmCharts.mjs +2 -2
  95. package/src/main/addon/AnalyticsByGoogle.mjs +2 -2
  96. package/src/main/addon/DragDrop.mjs +2 -2
  97. package/src/main/addon/HighlightJS.mjs +2 -2
  98. package/src/main/addon/MapboxGL.mjs +3 -2
  99. package/src/main/addon/Markdown.mjs +3 -3
  100. package/src/main/addon/Siesta.mjs +2 -2
  101. package/src/main/addon/Stylesheet.mjs +2 -2
  102. package/src/main/addon/WindowPosition.mjs +2 -2
  103. package/src/main/draggable/sensor/Mouse.mjs +2 -2
  104. package/src/main/draggable/sensor/Touch.mjs +2 -2
  105. package/src/manager/Component.mjs +2 -2
  106. package/src/manager/Instance.mjs +2 -2
  107. package/src/model/Component.mjs +2 -2
  108. package/src/plugin/Base.mjs +2 -2
  109. package/src/plugin/Resizable.mjs +2 -2
  110. package/src/selection/table/CellColumnModel.mjs +2 -2
  111. package/src/selection/table/CellColumnRowModel.mjs +2 -2
  112. package/src/selection/table/CellRowModel.mjs +2 -2
  113. package/src/table/Container.mjs +2 -2
  114. package/src/table/header/Button.mjs +2 -2
  115. package/src/util/Logger.mjs +2 -2
  116. package/src/worker/App.mjs +2 -2
  117. package/src/worker/Base.mjs +2 -2
  118. package/src/worker/Manager.mjs +2 -2
  119. package/test/siesta/tests/ClassConfigsAndFields.mjs +257 -19
@@ -7,15 +7,15 @@ class TestClass extends core.Base {
7
7
 
8
8
  static getConfig() {return {
9
9
  className: 'Neo.TestClass',
10
- configA_: 3,
11
- configB_: 4
10
+ configA_ : 3,
11
+ configB_ : 4
12
12
  }}
13
13
 
14
- beforeSetA(value) {
14
+ beforeSetConfigA(value) {
15
15
  return this.fieldA + value;
16
16
  }
17
17
 
18
- beforeSetB(value) {
18
+ beforeSetConfigB(value) {
19
19
  return this.fieldB + value;
20
20
  }
21
21
  }
@@ -23,19 +23,154 @@ class TestClass extends core.Base {
23
23
  Neo.applyClassConfig(TestClass);
24
24
 
25
25
  StartTest(t => {
26
+ t.it('Default class fields inside constructors', t => {
27
+ t.diag("Default class");
28
+
29
+ class CtorTest {
30
+ fieldA = 1;
31
+ fieldB = 2;
32
+
33
+ constructor() {
34
+ t.isStrict(this.fieldA, 1, 'fieldA equals ' + 1);
35
+ t.isStrict(this.fieldB, 2, 'fieldB equals ' + 2);
36
+ }
37
+ }
38
+
39
+ new CtorTest();
40
+
41
+ t.diag("Default class extension");
42
+
43
+ class CtorTestExtension extends CtorTest {
44
+ fieldA = 3;
45
+ fieldB = 4;
46
+
47
+ constructor() {
48
+ super();
49
+
50
+ t.isStrict(this.fieldA, 3, 'fieldA equals ' + 3);
51
+ t.isStrict(this.fieldB, 4, 'fieldB equals ' + 4);
52
+ }
53
+ }
54
+
55
+ new CtorTestExtension();
56
+ });
57
+
58
+ t.it('Neo default class fields inside constructors', t => {
59
+ t.diag("Neo default class");
60
+
61
+ class NeoCtorTest extends core.Base {
62
+ fieldA = 1;
63
+ fieldB = 2;
64
+
65
+ construct(config) {
66
+ super.construct(config);
67
+
68
+ let me = this,
69
+ extension = me.extension;
70
+
71
+ t.isStrict(me.fieldA, extension ? 3 : 1, 'fieldA equals ' + (extension ? 3 : 1));
72
+ t.isStrict(me.fieldB, extension ? 4 : 2, 'fieldB equals ' + (extension ? 4 : 2));
73
+ }
74
+ }
75
+
76
+ Neo.applyClassConfig(NeoCtorTest);
77
+
78
+ Neo.create(NeoCtorTest);
79
+
80
+ t.diag("Neo default class extension");
81
+
82
+ class NeoCtorTestExtension extends NeoCtorTest {
83
+ extension = true; // flag for the base ctor tests
84
+ fieldA = 3;
85
+ fieldB = 4;
86
+
87
+ construct(config) {
88
+ super.construct(config);
89
+
90
+ t.isStrict(this.fieldA, 3, 'fieldA equals ' + 3);
91
+ t.isStrict(this.fieldB, 4, 'fieldB equals ' + 4);
92
+ }
93
+ }
94
+
95
+ Neo.create(NeoCtorTestExtension);
96
+ });
97
+
98
+ t.it('Default class fields', t => {
99
+ t.diag("Testing class fields");
100
+
101
+ class DefaultTestClass {
102
+ fieldA = 1;
103
+ fieldB = 2;
104
+ _configA = 3;
105
+ _configB = 4;
106
+
107
+ get configA() {
108
+ return this._configA;
109
+ }
110
+
111
+ set configA(value) {
112
+ this._configA = this.fieldA + value;
113
+ }
114
+
115
+ get configB() {
116
+ return this._configB;
117
+ }
118
+
119
+ set configB(value) {
120
+ this._configB = this.fieldB + value;
121
+ }
122
+
123
+ constructor(config) {
124
+ Object.assign(this, config);
125
+ }
126
+ }
127
+
128
+ const instance = new DefaultTestClass({
129
+ fieldA : 5,
130
+ configA: 6,
131
+ configB: 7,
132
+ fieldB : 8
133
+ });
134
+
135
+ // not consistent
136
+ t.isStrict(instance.configA, 11, 'configA equals 11'); // 5 + 6 => new value of fieldA + new value of configA
137
+ t.isStrict(instance.configB, 9, 'configB equals 9'); // 7 + 2 => old value of fieldB + new value of configB
138
+ t.isStrict(instance.fieldA, 5, 'fieldA equals 5');
139
+ t.isStrict(instance.fieldB, 8, 'fieldB equals 8');
140
+
141
+ t.diag('Reversed order');
142
+
143
+ const instance2 = new DefaultTestClass({
144
+ fieldB : 8, // reversed order
145
+ configB: 7,
146
+ configA: 6,
147
+ fieldA : 5
148
+ });
149
+
150
+ // not consistent
151
+ t.isStrict(instance2.configA, 7, 'configA equals 7'); // 5 + 6 => old value of fieldA + new value of configA
152
+ t.isStrict(instance2.configB, 15, 'configB equals 15'); // 8 + 7 => new value of fieldB + new value of configB
153
+ t.isStrict(instance2.fieldA, 5, 'fieldA equals 5');
154
+ t.isStrict(instance2.fieldB, 8, 'fieldB equals 8');
155
+ });
156
+
26
157
  t.it('Class based class configs and fields', t => {
27
- let instance = Neo.create({
158
+ t.diag("Testing class based values");
159
+
160
+ const instance = Neo.create({
28
161
  className: 'Neo.TestClass'
29
162
  });
30
163
 
31
- t.isStrict(instance.configA, 3, 'configA equals ' + 3);
32
- t.isStrict(instance.configB, 4, 'configB equals ' + 4);
33
- t.isStrict(instance.fieldA, 1, 'fieldA equals ' + 1);
34
- t.isStrict(instance.fieldB, 2, 'fieldB equals ' + 2);
164
+ t.isStrict(instance.configA, 4, 'configA equals 4'); // 1 + 3
165
+ t.isStrict(instance.configB, 6, 'configB equals 6'); // 2 + 4
166
+ t.isStrict(instance.fieldA, 1, 'fieldA equals 1');
167
+ t.isStrict(instance.fieldB, 2, 'fieldB equals 2');
35
168
  });
36
169
 
37
170
  t.it('Instance based class configs and fields', t => {
38
- let instance = Neo.create({
171
+ t.diag("Testing values which got set on instance level");
172
+
173
+ const instance = Neo.create({
39
174
  className: 'Neo.TestClass',
40
175
  fieldA : 5,
41
176
  configA : 6,
@@ -43,14 +178,31 @@ StartTest(t => {
43
178
  fieldB : 8
44
179
  });
45
180
 
46
- t.isStrict(instance.configA, 11, 'configA equals ' + 11); // 5 + 6
47
- t.isStrict(instance.configB, 15, 'configB equals ' + 15); // 8 + 7
48
- t.isStrict(instance.fieldA, 5, 'fieldA equals ' + 5);
49
- t.isStrict(instance.fieldB, 8, 'fieldB equals ' + 8);
181
+ t.isStrict(instance.configA, 11, 'configA equals 11'); // 5 + 6
182
+ t.isStrict(instance.configB, 15, 'configB equals 15'); // 8 + 7
183
+ t.isStrict(instance.fieldA, 5, 'fieldA equals 5');
184
+ t.isStrict(instance.fieldB, 8, 'fieldB equals 8');
185
+
186
+ t.diag('Reversed order');
187
+
188
+ const instance2 = Neo.create({
189
+ className: 'Neo.TestClass',
190
+ fieldB : 8, // reversed order
191
+ configB : 7,
192
+ configA : 6,
193
+ fieldA : 5
194
+ });
195
+
196
+ t.isStrict(instance2.configA, 11, 'configA equals 11'); // 5 + 6
197
+ t.isStrict(instance2.configB, 15, 'configB equals 15'); // 8 + 7
198
+ t.isStrict(instance2.fieldA, 5, 'fieldA equals 5');
199
+ t.isStrict(instance2.fieldB, 8, 'fieldB equals 8');
50
200
  });
51
201
 
52
202
  t.it('Dynamically changed class configs and fields', t => {
53
- let instance = Neo.create({
203
+ t.diag("Testing instance.set()");
204
+
205
+ const instance = Neo.create({
54
206
  className: 'Neo.TestClass'
55
207
  });
56
208
 
@@ -61,9 +213,95 @@ StartTest(t => {
61
213
  fieldB : 8
62
214
  });
63
215
 
64
- t.isStrict(instance.configA, 11, 'configA equals ' + 11); // 5 + 6
65
- t.isStrict(instance.configB, 15, 'configB equals ' + 15); // 8 + 7
66
- t.isStrict(instance.fieldA, 5, 'fieldA equals ' + 5);
67
- t.isStrict(instance.fieldB, 8, 'fieldB equals ' + 8);
216
+ t.isStrict(instance.configA, 11, 'configA equals 11'); // 5 + 6
217
+ t.isStrict(instance.configB, 15, 'configB equals 15'); // 8 + 7
218
+ t.isStrict(instance.fieldA, 5, 'fieldA equals 5');
219
+ t.isStrict(instance.fieldB, 8, 'fieldB equals 8');
220
+
221
+ t.diag('Reversed order');
222
+
223
+ const instance2 = Neo.create({
224
+ className: 'Neo.TestClass'
225
+ });
226
+
227
+ instance2.set({
228
+ fieldB : 8, // reversed order
229
+ configB: 7,
230
+ configA: 6,
231
+ fieldA : 5
232
+ });
233
+
234
+ t.isStrict(instance2.configA, 11, 'configA equals 11'); // 5 + 6
235
+ t.isStrict(instance2.configB, 15, 'configB equals 15'); // 8 + 7
236
+ t.isStrict(instance2.fieldA, 5, 'fieldA equals 5');
237
+ t.isStrict(instance2.fieldB, 8, 'fieldB equals 8');
238
+ });
239
+
240
+ t.it('Advanced configs and fields example', t => {
241
+ class AdvancedClass extends core.Base {
242
+ fieldA = 2;
243
+ fieldB = 1;
244
+
245
+ static getConfig() {return {
246
+ configA_: 0,
247
+ configB_: 0,
248
+ configC_: 0
249
+ }}
250
+
251
+ afterSetConfigA(value, oldValue) {
252
+ let me = this,
253
+ sum = me.fieldA === 1 ? 21 : 6;
254
+
255
+ t.isStrict(me.configA + me.configB + me.configC + me.fieldA + me.fieldB, sum, `sum equals ${sum}`);
256
+ }
257
+
258
+ afterSetConfigC(value, oldValue) {
259
+ let me = this,
260
+ sum = me.fieldA === 1 ? 21 : 6;
261
+
262
+ t.isStrict(me.configA + me.configB + me.configC + me.fieldA + me.fieldB, sum, `sum equals ${sum}`);
263
+ }
264
+
265
+ beforeSetConfigA(value) {
266
+ return this.fieldA + value;
267
+ }
268
+
269
+ beforeSetConfigB(value) {
270
+ let me = this,
271
+ sum = me.fieldA === 1 ? 21 : 6;
272
+
273
+ t.isStrict(me.configA + me.configB + me.configC + me.fieldA + me.fieldB, sum, `sum equals ${sum}`);
274
+
275
+ return value;
276
+ }
277
+
278
+ beforeSetConfigC(value) {
279
+ return this.fieldB + value;
280
+ }
281
+ }
282
+
283
+ Neo.applyClassConfig(AdvancedClass);
284
+
285
+ let instance = Neo.create(AdvancedClass);
286
+
287
+ instance.set({
288
+ fieldA : 1,
289
+ configA: 2,
290
+ configB: 3,
291
+ configC: 4,
292
+ fieldB : 5
293
+ });
294
+
295
+ t.diag('Reversed order');
296
+
297
+ let instance2 = Neo.create(AdvancedClass);
298
+
299
+ instance2.set({
300
+ fieldB : 5,
301
+ configC: 4,
302
+ configB: 3,
303
+ configA: 2,
304
+ fieldA : 1
305
+ });
68
306
  });
69
307
  });