neo.mjs 2.3.17 → 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.
Files changed (265) hide show
  1. package/README.md +9 -0
  2. package/apps/covid/Util.mjs +1 -3
  3. package/apps/covid/view/GalleryContainer.mjs +2 -3
  4. package/apps/covid/view/GalleryContainerController.mjs +1 -5
  5. package/apps/covid/view/HelixContainer.mjs +2 -3
  6. package/apps/covid/view/HelixContainerController.mjs +1 -4
  7. package/apps/covid/view/MainContainerController.mjs +0 -7
  8. package/apps/covid/view/MainContainerModel.mjs +0 -1
  9. package/apps/covid/view/TableContainer.mjs +2 -3
  10. package/apps/covid/view/TableContainerController.mjs +0 -3
  11. package/apps/covid/view/WorldMapComponent.mjs +1 -2
  12. package/apps/covid/view/WorldMapContainerController.mjs +0 -2
  13. package/apps/covid/view/country/Gallery.mjs +0 -2
  14. package/apps/covid/view/country/Helix.mjs +0 -3
  15. package/apps/covid/view/mapboxGl/Container.mjs +1 -1
  16. package/apps/covid/view/mapboxGl/ContainerController.mjs +1 -6
  17. package/apps/krausest/TableCollection.mjs +0 -1
  18. package/apps/krausest/view/MainComponent.mjs +2 -3
  19. package/apps/krausest/view/MainComponentController.mjs +0 -1
  20. package/apps/krausest/view/TableComponent.mjs +2 -4
  21. package/apps/realworld/api/Article.mjs +1 -4
  22. package/apps/realworld/api/Base.mjs +0 -5
  23. package/apps/realworld/api/Favorite.mjs +1 -3
  24. package/apps/realworld/api/Profile.mjs +1 -3
  25. package/apps/realworld/view/HeaderComponent.mjs +1 -2
  26. package/apps/realworld/view/HomeComponent.mjs +2 -11
  27. package/apps/realworld/view/MainContainerController.mjs +0 -13
  28. package/apps/realworld/view/article/CommentComponent.mjs +3 -5
  29. package/apps/realworld/view/article/Component.mjs +2 -7
  30. package/apps/realworld/view/article/CreateCommentComponent.mjs +3 -7
  31. package/apps/realworld/view/article/CreateComponent.mjs +3 -3
  32. package/apps/realworld/view/article/PreviewComponent.mjs +3 -5
  33. package/apps/realworld/view/article/TagListComponent.mjs +3 -7
  34. package/apps/realworld/view/user/ProfileComponent.mjs +2 -8
  35. package/apps/realworld/view/user/SettingsComponent.mjs +3 -7
  36. package/apps/realworld/view/user/SignUpComponent.mjs +2 -3
  37. package/apps/realworld2/api/Article.mjs +1 -4
  38. package/apps/realworld2/api/Base.mjs +0 -5
  39. package/apps/realworld2/api/Favorite.mjs +1 -3
  40. package/apps/realworld2/api/Profile.mjs +1 -3
  41. package/apps/realworld2/view/HeaderToolbarController.mjs +1 -2
  42. package/apps/realworld2/view/HomeContainer.mjs +1 -2
  43. package/apps/realworld2/view/MainContainerController.mjs +1 -14
  44. package/apps/realworld2/view/article/Gallery.mjs +1 -3
  45. package/apps/realworld2/view/article/GalleryContainer.mjs +1 -2
  46. package/apps/realworld2/view/article/Helix.mjs +1 -3
  47. package/apps/realworld2/view/article/HelixContainer.mjs +3 -5
  48. package/apps/realworld2/view/article/PreviewComponent.mjs +3 -5
  49. package/apps/realworld2/view/article/TagListComponent.mjs +3 -7
  50. package/apps/realworld2/view/user/LoginFormContainer.mjs +3 -4
  51. package/apps/sharedcovid/Util.mjs +1 -3
  52. package/apps/sharedcovid/view/GalleryContainer.mjs +2 -3
  53. package/apps/sharedcovid/view/GalleryContainerController.mjs +1 -5
  54. package/apps/sharedcovid/view/HelixContainer.mjs +2 -3
  55. package/apps/sharedcovid/view/HelixContainerController.mjs +1 -4
  56. package/apps/sharedcovid/view/MainContainerController.mjs +12 -16
  57. package/apps/sharedcovid/view/MainContainerModel.mjs +0 -1
  58. package/apps/sharedcovid/view/TableContainer.mjs +2 -3
  59. package/apps/sharedcovid/view/TableContainerController.mjs +0 -3
  60. package/apps/sharedcovid/view/WorldMapComponent.mjs +1 -2
  61. package/apps/sharedcovid/view/WorldMapContainerController.mjs +0 -2
  62. package/apps/sharedcovid/view/country/Gallery.mjs +0 -2
  63. package/apps/sharedcovid/view/country/Helix.mjs +0 -3
  64. package/apps/sharedcovid/view/mapboxGl/Container.mjs +2 -3
  65. package/apps/sharedcovid/view/mapboxGl/ContainerController.mjs +1 -5
  66. package/apps/shareddialog/view/MainContainerController.mjs +0 -18
  67. package/apps/shareddialog2/view/MainContainerController.mjs +1 -2
  68. package/apps/website/data/blog.json +13 -0
  69. package/apps/website/view/MainContainerController.mjs +0 -4
  70. package/docs/app/view/ContentTabContainer.mjs +2 -2
  71. package/docs/app/view/MainContainer.mjs +2 -2
  72. package/docs/app/view/classdetails/SourceViewComponent.mjs +2 -2
  73. package/docs/app/view/classdetails/TutorialComponent.mjs +2 -2
  74. package/docs/tutorials/02_ClassSystem.html +3 -3
  75. package/docs/tutorials/02_ClassSystem.md +2 -2
  76. package/docs/tutorials/09_TodoList_version1.html +8 -8
  77. package/examples/ConfigurationViewport.mjs +0 -4
  78. package/examples/calendar/basic/MainContainerController.mjs +0 -1
  79. package/examples/calendar/weekview/MainContainer.mjs +2 -2
  80. package/examples/component/coronaGallery/CountryGallery.mjs +1 -4
  81. package/examples/component/coronaGallery/MainContainer.mjs +2 -4
  82. package/examples/component/coronaHelix/CountryHelix.mjs +0 -4
  83. package/examples/component/coronaHelix/MainContainer.mjs +2 -4
  84. package/examples/component/gallery/MainContainer.mjs +2 -4
  85. package/examples/component/helix/MainContainer.mjs +2 -4
  86. package/examples/component/splitter/MainContainer.mjs +0 -2
  87. package/examples/core/config/MainContainer.mjs +3 -5
  88. package/examples/dialog/MainContainer.mjs +3 -7
  89. package/examples/list/animate/MainContainer.mjs +2 -2
  90. package/examples/model/advanced/MainContainerController.mjs +0 -12
  91. package/examples/model/dialog/EditUserDialogController.mjs +1 -3
  92. package/examples/model/dialog/MainContainerController.mjs +1 -2
  93. package/examples/model/extendedClass/MainContainerController.mjs +0 -7
  94. package/examples/model/inline/MainContainerController.mjs +0 -7
  95. package/examples/model/inlineNoModel/MainContainerController.mjs +1 -6
  96. package/examples/model/multiWindow/EditUserDialogController.mjs +1 -3
  97. package/examples/model/multiWindow/MainContainerController.mjs +1 -3
  98. package/examples/model/multiWindow/ViewportController.mjs +3 -5
  99. package/examples/model/nestedData/MainContainerController.mjs +1 -8
  100. package/examples/tab/container/MainContainer.mjs +1 -6
  101. package/examples/todoList/version1/MainComponent.mjs +3 -3
  102. package/examples/todoList/version2/MainContainer.mjs +3 -3
  103. package/examples/todoList/version2/TodoList.mjs +1 -1
  104. package/examples/tree/MainContainer.mjs +0 -2
  105. package/package.json +7 -7
  106. package/src/Main.mjs +9 -18
  107. package/src/Neo.mjs +26 -26
  108. package/src/button/Menu.mjs +0 -1
  109. package/src/button/Split.mjs +2 -6
  110. package/src/calendar/store/Events.mjs +0 -1
  111. package/src/calendar/view/DayComponent.mjs +0 -1
  112. package/src/calendar/view/EditEventContainer.mjs +2 -9
  113. package/src/calendar/view/MainContainer.mjs +2 -17
  114. package/src/calendar/view/MainContainerModel.mjs +2 -4
  115. package/src/calendar/view/SettingsContainer.mjs +2 -6
  116. package/src/calendar/view/YearComponent.mjs +3 -14
  117. package/src/calendar/view/calendars/Container.mjs +0 -1
  118. package/src/calendar/view/calendars/EditContainer.mjs +2 -7
  119. package/src/calendar/view/calendars/List.mjs +0 -5
  120. package/src/calendar/view/month/Component.mjs +3 -17
  121. package/src/calendar/view/settings/GeneralContainer.mjs +0 -3
  122. package/src/calendar/view/settings/MonthContainer.mjs +0 -3
  123. package/src/calendar/view/settings/WeekContainer.mjs +0 -5
  124. package/src/calendar/view/settings/YearContainer.mjs +0 -3
  125. package/src/calendar/view/week/Component.mjs +3 -22
  126. package/src/calendar/view/week/EventDragZone.mjs +1 -6
  127. package/src/calendar/view/week/TimeAxisComponent.mjs +2 -3
  128. package/src/calendar/view/week/plugin/DragDrop.mjs +2 -12
  129. package/src/calendar/view/week/plugin/EventResizable.mjs +0 -3
  130. package/src/collection/Base.mjs +3 -22
  131. package/src/collection/Filter.mjs +0 -1
  132. package/src/collection/Sorter.mjs +0 -3
  133. package/src/component/Base.mjs +14 -3
  134. package/src/component/Chip.mjs +2 -4
  135. package/src/component/Circle.mjs +2 -20
  136. package/src/component/DateSelector.mjs +4 -21
  137. package/src/component/Gallery.mjs +2 -14
  138. package/src/component/Helix.mjs +2 -16
  139. package/src/component/Splitter.mjs +3 -8
  140. package/src/component/mwc/Button.mjs +2 -2
  141. package/src/component/mwc/TextField.mjs +2 -3
  142. package/src/component/wrapper/AmChart.mjs +1 -1
  143. package/src/component/wrapper/MapboxGL.mjs +0 -5
  144. package/src/container/Base.mjs +1 -7
  145. package/src/container/Panel.mjs +2 -5
  146. package/src/controller/Application.mjs +2 -3
  147. package/src/controller/Base.mjs +2 -3
  148. package/src/controller/Component.mjs +3 -6
  149. package/src/core/Base.mjs +26 -3
  150. package/src/core/Compare.mjs +0 -1
  151. package/src/core/IdGenerator.mjs +2 -4
  152. package/src/core/Observable.mjs +0 -3
  153. package/src/core/Util.mjs +0 -1
  154. package/src/core/_export.mjs +1 -2
  155. package/src/data/RecordFactory.mjs +1 -6
  156. package/src/data/Store.mjs +2 -12
  157. package/src/data/connection/Xhr.mjs +0 -6
  158. package/src/dialog/Base.mjs +5 -24
  159. package/src/draggable/DragProxyComponent.mjs +3 -5
  160. package/src/draggable/DragZone.mjs +2 -8
  161. package/src/draggable/DropZone.mjs +3 -9
  162. package/src/draggable/list/DragZone.mjs +3 -9
  163. package/src/draggable/tab/header/toolbar/SortZone.mjs +1 -3
  164. package/src/draggable/toolbar/DragZone.mjs +3 -7
  165. package/src/draggable/toolbar/SortZone.mjs +1 -8
  166. package/src/draggable/tree/DragZone.mjs +1 -4
  167. package/src/filter/BooleanContainer.mjs +0 -1
  168. package/src/filter/NumberContainer.mjs +0 -2
  169. package/src/filter/ToggleOperatorsButton.mjs +3 -5
  170. package/src/form/Container.mjs +0 -2
  171. package/src/form/Fieldset.mjs +0 -1
  172. package/src/form/field/Base.mjs +0 -2
  173. package/src/form/field/CheckBox.mjs +2 -7
  174. package/src/form/field/Color.mjs +2 -5
  175. package/src/form/field/Date.mjs +2 -6
  176. package/src/form/field/Display.mjs +2 -3
  177. package/src/form/field/Picker.mjs +1 -12
  178. package/src/form/field/Range.mjs +2 -3
  179. package/src/form/field/Select.mjs +24 -22
  180. package/src/form/field/Text.mjs +3 -20
  181. package/src/form/field/Time.mjs +2 -9
  182. package/src/form/field/trigger/Base.mjs +2 -4
  183. package/src/form/field/trigger/Clear.mjs +0 -3
  184. package/src/form/field/trigger/CopyToClipboard.mjs +0 -3
  185. package/src/form/field/trigger/Picker.mjs +0 -1
  186. package/src/form/field/trigger/SpinDown.mjs +0 -1
  187. package/src/form/field/trigger/SpinUp.mjs +0 -1
  188. package/src/form/field/trigger/SpinUpDown.mjs +0 -1
  189. package/src/form/field/trigger/Time.mjs +2 -3
  190. package/src/grid/Container.mjs +3 -6
  191. package/src/grid/header/Toolbar.mjs +1 -5
  192. package/src/list/Base.mjs +2 -2
  193. package/src/list/Color.mjs +0 -3
  194. package/src/list/Component.mjs +0 -3
  195. package/src/list/plugin/Animate.mjs +3 -6
  196. package/src/main/DomAccess.mjs +9 -24
  197. package/src/main/DomEvents.mjs +44 -77
  198. package/src/main/addon/AmCharts.mjs +3 -12
  199. package/src/main/addon/AnalyticsByGoogle.mjs +3 -4
  200. package/src/main/addon/CloneNode.mjs +0 -2
  201. package/src/main/addon/Cookie.mjs +0 -3
  202. package/src/main/addon/DragDrop.mjs +2 -11
  203. package/src/main/addon/HighlightJS.mjs +3 -7
  204. package/src/main/addon/MapboxGL.mjs +4 -16
  205. package/src/main/addon/Markdown.mjs +3 -3
  206. package/src/main/addon/Mwc.mjs +0 -2
  207. package/src/main/addon/Siesta.mjs +2 -3
  208. package/src/main/addon/Stylesheet.mjs +2 -6
  209. package/src/main/addon/WindowPosition.mjs +3 -8
  210. package/src/main/draggable/sensor/Mouse.mjs +2 -6
  211. package/src/main/draggable/sensor/Touch.mjs +2 -6
  212. package/src/main/mixin/DeltaUpdates.mjs +0 -8
  213. package/src/main/mixin/TouchDomEvents.mjs +1 -7
  214. package/src/manager/Base.mjs +0 -2
  215. package/src/manager/Component.mjs +2 -5
  216. package/src/manager/DomEvent.mjs +1 -6
  217. package/src/manager/Focus.mjs +0 -7
  218. package/src/manager/Instance.mjs +2 -3
  219. package/src/manager/Store.mjs +0 -4
  220. package/src/menu/List.mjs +4 -18
  221. package/src/model/Component.mjs +2 -3
  222. package/src/plugin/Base.mjs +2 -3
  223. package/src/plugin/Resizable.mjs +4 -15
  224. package/src/selection/CircleModel.mjs +1 -5
  225. package/src/selection/DateSelectorModel.mjs +1 -9
  226. package/src/selection/GalleryModel.mjs +0 -9
  227. package/src/selection/HelixModel.mjs +0 -9
  228. package/src/selection/ListModel.mjs +0 -8
  229. package/src/selection/Model.mjs +0 -8
  230. package/src/selection/menu/ListModel.mjs +0 -2
  231. package/src/selection/table/CellColumnModel.mjs +2 -6
  232. package/src/selection/table/CellColumnRowModel.mjs +2 -6
  233. package/src/selection/table/CellModel.mjs +0 -8
  234. package/src/selection/table/CellRowModel.mjs +2 -8
  235. package/src/selection/table/ColumnModel.mjs +0 -6
  236. package/src/selection/table/RowModel.mjs +0 -5
  237. package/src/tab/Container.mjs +0 -6
  238. package/src/tab/Strip.mjs +1 -3
  239. package/src/tab/header/Button.mjs +1 -2
  240. package/src/tab/header/Toolbar.mjs +0 -1
  241. package/src/table/Container.mjs +2 -10
  242. package/src/table/View.mjs +0 -4
  243. package/src/table/header/Button.mjs +2 -8
  244. package/src/table/header/Toolbar.mjs +1 -2
  245. package/src/tree/List.mjs +0 -4
  246. package/src/util/Css.mjs +0 -1
  247. package/src/util/Date.mjs +0 -2
  248. package/src/util/Function.mjs +0 -2
  249. package/src/util/HashHistory.mjs +0 -3
  250. package/src/util/KeyNavigation.mjs +0 -5
  251. package/src/{core → util}/Logger.mjs +7 -19
  252. package/src/util/Matrix.mjs +0 -3
  253. package/src/util/VDom.mjs +0 -5
  254. package/src/util/_export.mjs +2 -1
  255. package/src/vdom/Helper.mjs +0 -3
  256. package/src/vdom/VNode.mjs +0 -1
  257. package/src/worker/App.mjs +2 -9
  258. package/src/worker/Base.mjs +2 -8
  259. package/src/worker/Canvas.mjs +0 -2
  260. package/src/worker/Manager.mjs +3 -5
  261. package/src/worker/Message.mjs +0 -1
  262. package/src/worker/mixin/RemoteMethodAccess.mjs +0 -3
  263. package/test/siesta/siesta.js +2 -1
  264. package/test/siesta/tests/ClassConfigsAndFields.mjs +307 -0
  265. package/test/siesta/tests/ClassSystem.mjs +1 -1
@@ -0,0 +1,307 @@
1
+ import Neo from '../../../src/Neo.mjs';
2
+ import * as core from '../../../src/core/_export.mjs';
3
+
4
+ class TestClass extends core.Base {
5
+ fieldA = 1;
6
+ fieldB = 2;
7
+
8
+ static getConfig() {return {
9
+ className: 'Neo.TestClass',
10
+ configA_ : 3,
11
+ configB_ : 4
12
+ }}
13
+
14
+ beforeSetConfigA(value) {
15
+ return this.fieldA + value;
16
+ }
17
+
18
+ beforeSetConfigB(value) {
19
+ return this.fieldB + value;
20
+ }
21
+ }
22
+
23
+ Neo.applyClassConfig(TestClass);
24
+
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
+
157
+ t.it('Class based class configs and fields', t => {
158
+ t.diag("Testing class based values");
159
+
160
+ const instance = Neo.create({
161
+ className: 'Neo.TestClass'
162
+ });
163
+
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');
168
+ });
169
+
170
+ t.it('Instance based class configs and fields', t => {
171
+ t.diag("Testing values which got set on instance level");
172
+
173
+ const instance = Neo.create({
174
+ className: 'Neo.TestClass',
175
+ fieldA : 5,
176
+ configA : 6,
177
+ configB : 7,
178
+ fieldB : 8
179
+ });
180
+
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');
200
+ });
201
+
202
+ t.it('Dynamically changed class configs and fields', t => {
203
+ t.diag("Testing instance.set()");
204
+
205
+ const instance = Neo.create({
206
+ className: 'Neo.TestClass'
207
+ });
208
+
209
+ instance.set({
210
+ fieldA : 5,
211
+ configA: 6,
212
+ configB: 7,
213
+ fieldB : 8
214
+ });
215
+
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
+ });
306
+ });
307
+ });
@@ -67,4 +67,4 @@ StartTest(t => {
67
67
  b: valueB
68
68
  });
69
69
  });
70
- });
70
+ });