neo.mjs 8.0.0-beta.1 → 8.0.0-beta.2
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.
- package/apps/ServiceWorker.mjs +2 -2
- package/apps/colors/view/Viewport.mjs +9 -9
- package/apps/colors/view/ViewportController.mjs +13 -13
- package/apps/colors/view/{ViewportModel.mjs → ViewportStateProvider.mjs} +8 -8
- package/apps/covid/view/MainContainer.mjs +8 -8
- package/apps/covid/view/MainContainerController.mjs +8 -10
- package/apps/covid/view/{MainContainerModel.mjs → MainContainerStateProvider.mjs} +7 -7
- package/apps/covid/view/TableContainerController.mjs +1 -1
- package/apps/form/view/FormContainerController.mjs +2 -2
- package/apps/form/view/SideNavList.mjs +3 -3
- package/apps/form/view/Viewport.mjs +7 -7
- package/apps/form/view/ViewportController.mjs +4 -4
- package/apps/form/view/{ViewportModel.mjs → ViewportStateProvider.mjs} +8 -8
- package/apps/portal/index.html +1 -1
- package/apps/portal/resources/data/examples_devmode.json +3 -3
- package/apps/portal/resources/data/examples_dist_dev.json +3 -3
- package/apps/portal/resources/data/examples_dist_prod.json +3 -3
- package/apps/portal/view/Viewport.mjs +12 -12
- package/apps/portal/view/ViewportStateProvider.mjs +27 -0
- package/apps/portal/view/home/FooterContainer.mjs +1 -1
- package/apps/portal/view/learn/ContentComponent.mjs +2 -2
- package/apps/portal/view/learn/ContentTreeList.mjs +1 -1
- package/apps/portal/view/learn/MainContainer.mjs +9 -9
- package/apps/portal/view/learn/MainContainerController.mjs +12 -12
- package/apps/portal/view/learn/{MainContainerModel.mjs → MainContainerStateProvider.mjs} +7 -7
- package/apps/portal/view/learn/PageSectionsList.mjs +1 -1
- package/apps/sharedcovid/view/GalleryContainer.mjs +2 -2
- package/apps/sharedcovid/view/HelixContainer.mjs +2 -2
- package/apps/sharedcovid/view/MainContainer.mjs +8 -8
- package/apps/sharedcovid/view/MainContainerController.mjs +10 -11
- package/apps/sharedcovid/view/{MainContainerModel.mjs → MainContainerStateProvider.mjs} +8 -8
- package/apps/sharedcovid/view/TableContainerController.mjs +1 -1
- package/apps/sharedcovid/view/mapboxGl/Container.mjs +2 -2
- package/buildScripts/createClass.mjs +11 -11
- package/buildScripts/createComponent.mjs +4 -4
- package/docs/app/view/MainContainerController.mjs +6 -6
- package/examples/ServiceWorker.mjs +2 -2
- package/examples/{model → stateProvider}/advanced/MainContainer.mjs +12 -12
- package/examples/{model → stateProvider}/advanced/MainContainerController.mjs +10 -10
- package/examples/stateProvider/advanced/app.mjs +6 -0
- package/examples/{model/dialog → stateProvider/advanced}/index.html +1 -1
- package/examples/{model/inline → stateProvider/advanced}/neo-config.json +1 -1
- package/examples/{model → stateProvider}/dialog/EditUserDialog.mjs +3 -3
- package/examples/{model → stateProvider}/dialog/EditUserDialogController.mjs +5 -5
- package/examples/{model → stateProvider}/dialog/MainContainer.mjs +7 -7
- package/examples/{model → stateProvider}/dialog/MainContainerController.mjs +5 -5
- package/examples/{model → stateProvider}/dialog/app.mjs +1 -1
- package/examples/{model/multiWindow2 → stateProvider/dialog}/index.html +1 -1
- package/examples/{model → stateProvider}/dialog/neo-config.json +1 -1
- package/examples/{model → stateProvider}/extendedClass/MainContainer.mjs +13 -13
- package/examples/{model/inline → stateProvider/extendedClass}/MainContainerController.mjs +7 -7
- package/examples/stateProvider/extendedClass/MainContainerStateProvider.mjs +24 -0
- package/examples/stateProvider/extendedClass/app.mjs +6 -0
- package/examples/stateProvider/extendedClass/index.html +11 -0
- package/examples/stateProvider/extendedClass/neo-config.json +7 -0
- package/examples/{model → stateProvider}/inline/MainContainer.mjs +10 -10
- package/examples/{model/extendedClass → stateProvider/inline}/MainContainerController.mjs +7 -7
- package/examples/{model/extendedClass → stateProvider/inline}/app.mjs +1 -1
- package/examples/{model/extendedClass → stateProvider/inline}/index.html +1 -1
- package/examples/{model/extendedClass → stateProvider/inline}/neo-config.json +1 -1
- package/examples/{model/inlineNoModel → stateProvider/inlineNoStateProvider}/MainContainer.mjs +4 -4
- package/examples/{model/inlineNoModel → stateProvider/inlineNoStateProvider}/MainContainerController.mjs +3 -3
- package/examples/stateProvider/inlineNoStateProvider/README.md +8 -0
- package/examples/stateProvider/inlineNoStateProvider/app.mjs +6 -0
- package/examples/{model/inline → stateProvider/inlineNoStateProvider}/index.html +1 -1
- package/examples/stateProvider/inlineNoStateProvider/neo-config.json +7 -0
- package/examples/{model → stateProvider}/multiWindow/EditUserDialog.mjs +3 -3
- package/examples/{model → stateProvider}/multiWindow/EditUserDialogController.mjs +5 -5
- package/examples/{model → stateProvider}/multiWindow/MainContainer.mjs +3 -3
- package/examples/{model → stateProvider}/multiWindow/MainContainerController.mjs +6 -6
- package/examples/{model → stateProvider}/multiWindow/Viewport.mjs +3 -3
- package/examples/{model → stateProvider}/multiWindow/ViewportController.mjs +14 -14
- package/examples/{model/multiWindow2 → stateProvider/multiWindow}/app.mjs +1 -1
- package/examples/{model/advanced → stateProvider/multiWindow}/index.html +1 -1
- package/examples/{model → stateProvider}/multiWindow/neo-config.json +1 -1
- package/examples/{model → stateProvider}/multiWindow2/Viewport.mjs +3 -3
- package/examples/{model/multiWindow → stateProvider/multiWindow2}/app.mjs +1 -1
- package/examples/{model/multiWindow → stateProvider/multiWindow2}/index.html +1 -1
- package/examples/{model → stateProvider}/multiWindow2/neo-config.json +1 -1
- package/examples/{model → stateProvider}/nestedData/MainContainer.mjs +9 -9
- package/examples/{model → stateProvider}/nestedData/MainContainerController.mjs +7 -7
- package/examples/stateProvider/nestedData/app.mjs +6 -0
- package/examples/stateProvider/nestedData/index.html +11 -0
- package/examples/stateProvider/nestedData/neo-config.json +7 -0
- package/examples/{model → stateProvider}/table/MainContainer.mjs +8 -8
- package/examples/stateProvider/table/MainContainerStateProvider.mjs +24 -0
- package/examples/{model → stateProvider}/table/MainModel.mjs +2 -2
- package/examples/{model → stateProvider}/table/MainStore.mjs +2 -2
- package/examples/{model/advanced → stateProvider/table}/app.mjs +1 -1
- package/examples/{model/advanced → stateProvider/table}/neo-config.json +1 -1
- package/examples/{model → stateProvider}/twoWay/MainContainer.mjs +9 -9
- package/examples/{model/inline → stateProvider/twoWay}/app.mjs +1 -1
- package/examples/stateProvider/twoWay/index.html +11 -0
- package/examples/{model → stateProvider}/twoWay/neo-config.json +1 -1
- package/examples/table/nestedRecordFields/EditUserDialog.mjs +3 -3
- package/examples/table/nestedRecordFields/MainContainer.mjs +8 -8
- package/examples/table/nestedRecordFields/{MainContainerModel.mjs → MainContainerStateProvider.mjs} +10 -10
- package/examples/toolbar/paging/view/MainContainer.mjs +7 -7
- package/examples/toolbar/paging/view/{MainContainerModel.mjs → MainContainerStateProvider.mjs} +8 -8
- package/examples/treeAccordion/MainContainer.mjs +2 -2
- package/package.json +2 -2
- package/resources/data/deck/learnneo/pages/guides/{ViewModels.md → StateProviders.md} +52 -58
- package/resources/data/deck/learnneo/tree.json +46 -46
- package/src/DefaultConfig.mjs +2 -2
- package/src/button/Base.mjs +7 -7
- package/src/calendar/view/EditEventContainer.mjs +3 -3
- package/src/calendar/view/MainContainer.mjs +27 -27
- package/src/calendar/view/{MainContainerModel.mjs → MainContainerStateProvider.mjs} +7 -7
- package/src/calendar/view/YearComponent.mjs +5 -5
- package/src/calendar/view/calendars/EditContainer.mjs +1 -1
- package/src/calendar/view/calendars/List.mjs +1 -1
- package/src/calendar/view/month/Component.mjs +6 -6
- package/src/calendar/view/settings/GeneralContainer.mjs +2 -2
- package/src/calendar/view/week/Component.mjs +10 -10
- package/src/calendar/view/week/EventDragZone.mjs +1 -1
- package/src/component/Base.mjs +77 -61
- package/src/container/Base.mjs +3 -3
- package/src/controller/Component.mjs +29 -12
- package/src/core/Base.mjs +0 -1
- package/src/core/Compare.mjs +128 -83
- package/src/date/SelectorContainer.mjs +12 -12
- package/src/date/{SelectorContainerModel.mjs → SelectorContainerStateProvider.mjs} +7 -7
- package/src/layout/Base.mjs +6 -6
- package/src/{model/Component.mjs → state/Provider.mjs} +67 -69
- package/src/tree/Accordion.mjs +15 -13
- package/src/worker/App.mjs +2 -2
- package/apps/portal/view/ViewportModel.mjs +0 -27
- package/examples/model/extendedClass/MainContainerModel.mjs +0 -24
- package/examples/model/inlineNoModel/README.md +0 -8
- package/examples/model/inlineNoModel/app.mjs +0 -6
- package/examples/model/inlineNoModel/index.html +0 -11
- package/examples/model/inlineNoModel/neo-config.json +0 -7
- package/examples/model/nestedData/app.mjs +0 -6
- package/examples/model/nestedData/index.html +0 -11
- package/examples/model/nestedData/neo-config.json +0 -7
- package/examples/model/table/MainContainerModel.mjs +0 -24
- package/examples/model/table/app.mjs +0 -6
- package/examples/model/table/neo-config.json +0 -7
- package/examples/model/twoWay/app.mjs +0 -6
- package/examples/model/twoWay/index.html +0 -11
- /package/examples/{model → stateProvider}/table/index.html +0 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "neo.mjs",
|
3
|
-
"version": "8.0.0-beta.
|
3
|
+
"version": "8.0.0-beta.2",
|
4
4
|
"description": "The webworkers driven UI framework",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -55,7 +55,7 @@
|
|
55
55
|
"fs-extra": "^11.2.0",
|
56
56
|
"highlightjs-line-numbers.js": "^2.9.0",
|
57
57
|
"inquirer": "^12.1.0",
|
58
|
-
"marked": "^15.0.
|
58
|
+
"marked": "^15.0.3",
|
59
59
|
"monaco-editor": "0.50.0",
|
60
60
|
"neo-jsdoc": "1.0.1",
|
61
61
|
"neo-jsdoc-x": "1.0.5",
|
@@ -1,19 +1,14 @@
|
|
1
|
-
View models (VMs) in Neo.mjs are state providers.
|
2
|
-
|
3
1
|
While Components can manage their own state using the Class Config System,
|
4
2
|
you want to use VMs as soon as you want to share data properties with multiple child Components.
|
5
3
|
|
6
4
|
Rules of thumb:
|
7
|
-
1. Leaf Components inside the Component Tree (Container items) will
|
8
|
-
2. We can define multiple
|
5
|
+
1. Leaf Components inside the Component Tree (Container items) will not need a state provider.
|
6
|
+
2. We can define multiple state providers as needed (they do communicate).
|
9
7
|
3. We want to define shared state data properties as low inside the component tree as possible.
|
10
8
|
|
11
|
-
|
12
|
-
other libraries or frameworks often call them Stores.
|
13
|
-
|
14
|
-
Since we also have Data Stores (tabular data), we chose to use the name VM to avoid confusion.
|
9
|
+
Other libraries or frameworks often call state providers "Stores".
|
15
10
|
|
16
|
-
## Inline
|
11
|
+
## Inline State Providers
|
17
12
|
### Direct Bindings
|
18
13
|
<pre data-neo>
|
19
14
|
import Button from '../button/Base.mjs';
|
@@ -23,7 +18,7 @@ import Label from '../component/Label.mjs';
|
|
23
18
|
class MainView extends Container {
|
24
19
|
static config = {
|
25
20
|
className: 'Guides.vm1.MainView',
|
26
|
-
|
21
|
+
stateProvider: {
|
27
22
|
data: {
|
28
23
|
hello: 'Hello',
|
29
24
|
world: 'world!'
|
@@ -43,11 +38,11 @@ class MainView extends Container {
|
|
43
38
|
}
|
44
39
|
}, {
|
45
40
|
module : Button,
|
46
|
-
handler: data => data.component.
|
41
|
+
handler: data => data.component.setState({hello: 'Hi'}),
|
47
42
|
text : 'Change Hello'
|
48
43
|
}, {
|
49
44
|
module : Button,
|
50
|
-
handler: data => data.component.
|
45
|
+
handler: data => data.component.setState({world: 'Neo.mjs!'}),
|
51
46
|
text : 'Change World'
|
52
47
|
}],
|
53
48
|
layout: {ntype: 'vbox', align: 'start'}
|
@@ -56,7 +51,7 @@ class MainView extends Container {
|
|
56
51
|
MainView = Neo.setupClass(MainView);
|
57
52
|
</pre>
|
58
53
|
|
59
|
-
We use a Container with a
|
54
|
+
We use a Container with a stateProvider containing the data props `hello` and `world`.
|
60
55
|
Inside the Container are 2 Labels which bind their `text` config to a data prop directly.
|
61
56
|
|
62
57
|
We can easily bind 1:1 to specific data props using the following syntax:</br>
|
@@ -71,7 +66,7 @@ import Label from '../component/Label.mjs';
|
|
71
66
|
class MainView extends Container {
|
72
67
|
static config = {
|
73
68
|
className: 'Guides.vm2.MainView',
|
74
|
-
|
69
|
+
stateProvider: {
|
75
70
|
data: {
|
76
71
|
hello: 'Hello',
|
77
72
|
world: 'world!'
|
@@ -98,11 +93,11 @@ class MainView extends Container {
|
|
98
93
|
}
|
99
94
|
}, {
|
100
95
|
module : Button,
|
101
|
-
handler: data => data.component.
|
96
|
+
handler: data => data.component.setState({hello: 'Hi'}),
|
102
97
|
text : 'Change Hello'
|
103
98
|
}, {
|
104
99
|
module : Button,
|
105
|
-
handler: data => data.component.
|
100
|
+
handler: data => data.component.setState({world: 'Neo.mjs!'}),
|
106
101
|
text : 'Change World'
|
107
102
|
}],
|
108
103
|
layout: {ntype: 'vbox', align: 'start'}
|
@@ -111,7 +106,7 @@ class MainView extends Container {
|
|
111
106
|
MainView = Neo.setupClass(MainView);
|
112
107
|
</pre>
|
113
108
|
|
114
|
-
We use a Container with a
|
109
|
+
We use a Container with a stateProvider containing the data props `hello` and `world`.
|
115
110
|
Inside the Container are 3 Labels which bind their `text` config to a combination of both data props.
|
116
111
|
|
117
112
|
We are showcasing 3 different ways how you can define your binding (resulting in the same output).
|
@@ -124,12 +119,15 @@ We also added 2 Buttons to change the value of each data prop, so that we can se
|
|
124
119
|
update right away.
|
125
120
|
|
126
121
|
Let us take a look at the Button handler:</br>
|
127
|
-
`data.component.
|
122
|
+
`data.component.setState({world: 'Neo.mjs!'})`
|
123
|
+
|
124
|
+
This is a shortcut syntax for:</br>
|
125
|
+
`data.component.getStateProvider().setData({world: 'Neo.mjs!'})`
|
128
126
|
|
129
|
-
data.component equals to the Button instance itself. Since the Button instance does not have its own
|
130
|
-
`
|
127
|
+
data.component equals to the Button instance itself. Since the Button instance does not have its own stateProvider,
|
128
|
+
`getStateProvider()` will return the closest stateProvider inside the parent chain.
|
131
129
|
|
132
|
-
### Nested Inline
|
130
|
+
### Nested Inline State Providers
|
133
131
|
<pre data-neo>
|
134
132
|
import Button from '../button/Base.mjs';
|
135
133
|
import Container from '../container/Base.mjs';
|
@@ -138,7 +136,7 @@ import Label from '../component/Label.mjs';
|
|
138
136
|
class MainView extends Container {
|
139
137
|
static config = {
|
140
138
|
className: 'Guides.vm3.MainView',
|
141
|
-
|
139
|
+
stateProvider: {
|
142
140
|
data: {
|
143
141
|
hello: 'Hello'
|
144
142
|
}
|
@@ -146,7 +144,7 @@ class MainView extends Container {
|
|
146
144
|
layout: 'fit',
|
147
145
|
items : [{
|
148
146
|
module: Container,
|
149
|
-
|
147
|
+
stateProvider: {
|
150
148
|
data: {
|
151
149
|
world: 'world!'
|
152
150
|
}
|
@@ -172,11 +170,11 @@ class MainView extends Container {
|
|
172
170
|
}
|
173
171
|
}, {
|
174
172
|
module : Button,
|
175
|
-
handler: data => data.component.
|
173
|
+
handler: data => data.component.setState({hello: 'Hi'}),
|
176
174
|
text : 'Change Hello'
|
177
175
|
}, {
|
178
176
|
module : Button,
|
179
|
-
handler: data => data.component.
|
177
|
+
handler: data => data.component.setState({world: 'Neo.mjs!'}),
|
180
178
|
text : 'Change World'
|
181
179
|
}],
|
182
180
|
layout: {ntype: 'vbox', align: 'start'}
|
@@ -191,15 +189,15 @@ The output of this demo is supposed to exactly look the same like the previous d
|
|
191
189
|
This time we nest our Labels into a Container with a fit layout.
|
192
190
|
Just for demo purposes, we want to avoid overnesting inside real apps.
|
193
191
|
|
194
|
-
Our top level
|
195
|
-
which contains the `world` data prop.
|
192
|
+
Our top level stateProvider now only contains the `hello` data prop, and we added a second stateProvider inside the
|
193
|
+
nested Container which contains the `world` data prop.
|
196
194
|
|
197
|
-
As a result, the bindings for all 3 Labels contain a combination of data props which live inside different
|
195
|
+
As a result, the bindings for all 3 Labels contain a combination of data props which live inside different stateProviders.
|
198
196
|
As long as these VMs are inside the parent hierarchy this works fine.
|
199
197
|
|
200
|
-
The same goes for the Button handlers: `setData()` will find the closest matching data prop inside the
|
198
|
+
The same goes for the Button handlers: `setData()` will find the closest matching data prop inside the stateProvider parent chain.
|
201
199
|
|
202
|
-
We can even change data props which live inside different
|
200
|
+
We can even change data props which live inside different stateProviders at once. As easy as this:</br>
|
203
201
|
`setData({hello: 'foo', world: 'bar'})`
|
204
202
|
|
205
203
|
Hint: Modify the example code (Button handler) to try it out right away!
|
@@ -213,7 +211,7 @@ import Label from '../component/Label.mjs';
|
|
213
211
|
class MainView extends Container {
|
214
212
|
static config = {
|
215
213
|
className: 'Guides.vm4.MainView',
|
216
|
-
|
214
|
+
stateProvider: {
|
217
215
|
data: {
|
218
216
|
user: {
|
219
217
|
firstname: 'Tobias',
|
@@ -235,11 +233,11 @@ class MainView extends Container {
|
|
235
233
|
}
|
236
234
|
}, {
|
237
235
|
module : Button,
|
238
|
-
handler: data => data.component.
|
236
|
+
handler: data => data.component.setState({user: {firstname: 'Max'}}),
|
239
237
|
text : 'Change Firstname'
|
240
238
|
}, {
|
241
239
|
module : Button,
|
242
|
-
handler: data => data.component.
|
240
|
+
handler: data => data.component.setState({'user.lastname': 'Rahder'}),
|
243
241
|
text : 'Change Lastname'
|
244
242
|
}],
|
245
243
|
layout: {ntype: 'vbox', align: 'start'}
|
@@ -247,7 +245,7 @@ class MainView extends Container {
|
|
247
245
|
}
|
248
246
|
MainView = Neo.setupClass(MainView);
|
249
247
|
</pre>
|
250
|
-
Data props inside VMs can be nested. Our
|
248
|
+
Data props inside VMs can be nested. Our stateProvider contains a `user` data prop as an object,
|
251
249
|
which contains the nested props `firstname` and `lastname`.
|
252
250
|
|
253
251
|
We can bind to these nested props like before:</br>
|
@@ -256,10 +254,10 @@ We can bind to these nested props like before:</br>
|
|
256
254
|
Any change of a nested data prop will directly get reflected into the bound components.
|
257
255
|
|
258
256
|
We can update a nested data prop with passing its path:</br>
|
259
|
-
`data => data.component.
|
257
|
+
`data => data.component.setState({'user.lastname': 'Rahder'})`
|
260
258
|
|
261
259
|
Or we can directly pass the object containing the change(s):</br>
|
262
|
-
`data => data.component.
|
260
|
+
`data => data.component.setState({user: {firstname: 'Max'}})`
|
263
261
|
|
264
262
|
Hint: This will not override left out nested data props (lastname in this case).
|
265
263
|
|
@@ -277,15 +275,11 @@ class EditUserDialogController extends Controller {
|
|
277
275
|
}
|
278
276
|
|
279
277
|
onFirstnameTextFieldChange(data) {
|
280
|
-
this.
|
281
|
-
'user.firstname': data.value || ''
|
282
|
-
})
|
278
|
+
this.setState({'user.firstname': data.value || ''})
|
283
279
|
}
|
284
280
|
|
285
281
|
onLastnameTextFieldChange(data) {
|
286
|
-
this.
|
287
|
-
'user.lastname': data.value || ''
|
288
|
-
})
|
282
|
+
this.setState({'user.lastname': data.value || ''})
|
289
283
|
}
|
290
284
|
}
|
291
285
|
EditUserDialogController = Neo.setupClass(EditUserDialogController);
|
@@ -327,8 +321,8 @@ class MainContainerController extends Controller {
|
|
327
321
|
appName : me.component.appName,
|
328
322
|
closeAction : 'hide',
|
329
323
|
|
330
|
-
|
331
|
-
parent: me.
|
324
|
+
stateProvider: {
|
325
|
+
parent: me.getStateProvider()
|
332
326
|
}
|
333
327
|
})
|
334
328
|
} else {
|
@@ -342,7 +336,7 @@ class MainView extends Viewport {
|
|
342
336
|
static config = {
|
343
337
|
className : 'Guides.vm5.MainView',
|
344
338
|
controller: MainContainerController,
|
345
|
-
|
339
|
+
stateProvider: {
|
346
340
|
data: {
|
347
341
|
user: {
|
348
342
|
firstname: 'Tobias',
|
@@ -386,19 +380,19 @@ class MainView extends Viewport {
|
|
386
380
|
MainView = Neo.setupClass(MainView);
|
387
381
|
</pre>
|
388
382
|
|
389
|
-
## Class based
|
390
|
-
When your
|
383
|
+
## Class based State Providers
|
384
|
+
When your stateProviders contain many data props or need custom logic, you can easily move them into their own classes.
|
391
385
|
|
392
386
|
### Direct Bindings
|
393
387
|
<pre data-neo>
|
394
|
-
import Button
|
395
|
-
import Container
|
396
|
-
import Label
|
397
|
-
import
|
388
|
+
import Button from '../button/Base.mjs';
|
389
|
+
import Container from '../container/Base.mjs';
|
390
|
+
import Label from '../component/Label.mjs';
|
391
|
+
import StateProvider from '../state/Provider.mjs';
|
398
392
|
|
399
|
-
class
|
393
|
+
class MainViewStateProvider extends StateProvider {
|
400
394
|
static config = {
|
401
|
-
className: 'Guides.vm6.
|
395
|
+
className: 'Guides.vm6.MainViewStateProvider',
|
402
396
|
data: {
|
403
397
|
hello: 'Hello',
|
404
398
|
world: 'world!'
|
@@ -410,12 +404,12 @@ class MainViewModel extends ViewModel {
|
|
410
404
|
Neo.Main.log({value: `onDataPropertyChange: key: ${key}, value: ${value}, oldValue: ${oldValue}`})
|
411
405
|
}
|
412
406
|
}
|
413
|
-
|
407
|
+
MainViewStateProvider = Neo.setupClass(MainViewStateProvider);
|
414
408
|
|
415
409
|
class MainView extends Container {
|
416
410
|
static config = {
|
417
|
-
className: 'Guides.vm6.MainView',
|
418
|
-
|
411
|
+
className : 'Guides.vm6.MainView',
|
412
|
+
stateProvider: MainViewStateProvider, // directly assign the imported module
|
419
413
|
|
420
414
|
itemDefaults: {
|
421
415
|
module: Label,
|
@@ -431,11 +425,11 @@ class MainView extends Container {
|
|
431
425
|
}
|
432
426
|
}, {
|
433
427
|
module : Button,
|
434
|
-
handler: data => data.component.
|
428
|
+
handler: data => data.component.setState({hello: 'Hi'}),
|
435
429
|
text : 'Change Hello'
|
436
430
|
}, {
|
437
431
|
module : Button,
|
438
|
-
handler: data => data.component.
|
432
|
+
handler: data => data.component.setState({world: 'Neo.mjs!'}),
|
439
433
|
text : 'Change World'
|
440
434
|
}],
|
441
435
|
layout: {ntype: 'vbox', align: 'start'}
|
@@ -1,48 +1,48 @@
|
|
1
1
|
{"data": [
|
2
|
-
{"name": "Welcome!",
|
3
|
-
{"name": "Benefits",
|
4
|
-
{"name": "Introduction ",
|
5
|
-
{"name": "Off the Main Thread",
|
6
|
-
{"name": "Extreme Speed",
|
7
|
-
{"name": "Multi-Window Applications",
|
8
|
-
{"name": "Quick Application Development",
|
9
|
-
{"name": "Complexity and Effort",
|
10
|
-
{"name": "Forms Engine",
|
11
|
-
{"name": "Features and Benefits Summary",
|
12
|
-
{"name": "Getting Started",
|
13
|
-
{"name": "Setup",
|
14
|
-
{"name": "Workspaces and Applications",
|
15
|
-
{"name": "Describing a View",
|
16
|
-
{"name": "Events",
|
17
|
-
{"name": "Component References",
|
18
|
-
{"name": "Extending Classes",
|
19
|
-
{"name": "Config",
|
20
|
-
{"name": "Shared Bindable Data",
|
21
|
-
{"name": "Tutorials",
|
22
|
-
{"name": "Rock Scissors Paper",
|
23
|
-
{"name": "Earthquakes",
|
24
|
-
{"name": "Todo List",
|
25
|
-
{"name": "Guides",
|
26
|
-
{"name": "Instance Lifecycle",
|
27
|
-
{"name": "User Input (Forms)",
|
28
|
-
{"name": "Component and Container Basics",
|
29
|
-
{"name": "Layouts",
|
30
|
-
{"name": "Shared Bindable Data (
|
31
|
-
{"name": "Custom Components",
|
32
|
-
{"name": "Events",
|
33
|
-
{"name": "Custom Events",
|
34
|
-
{"name": "DOM Events",
|
35
|
-
{"name": "Portal App",
|
36
|
-
{"name": "Tables (Stores)",
|
37
|
-
{"name": "Multi-Window Applications",
|
38
|
-
{"name": "Main Thread Addons",
|
39
|
-
{"name": "Introduction",
|
40
|
-
{"name": "Example",
|
41
|
-
{"name": "Mixins",
|
42
|
-
{"name": "JavaScript Classes",
|
43
|
-
{"name": "Classes, Properties, and Methods",
|
44
|
-
{"name": "Overriding Methods",
|
45
|
-
{"name": "Other JavaScript Class Features",
|
46
|
-
{"name": "Super",
|
47
|
-
{"name": "New Node",
|
2
|
+
{"name": "Welcome!", "parentId": null, "id": "Welcome" },
|
3
|
+
{"name": "Benefits", "parentId": null, "isLeaf": false, "id": "Benefits"},
|
4
|
+
{"name": "Introduction ", "parentId": "Benefits", "id": "benefits.Introduction"},
|
5
|
+
{"name": "Off the Main Thread", "parentId": "Benefits", "id": "benefits.Multi-Threading"},
|
6
|
+
{"name": "Extreme Speed", "parentId": "Benefits", "id": "benefits.Speed"},
|
7
|
+
{"name": "Multi-Window Applications", "parentId": "Benefits", "id": "benefits.Multi-Window"},
|
8
|
+
{"name": "Quick Application Development", "parentId": "Benefits", "id": "benefits.Quick"},
|
9
|
+
{"name": "Complexity and Effort", "parentId": "Benefits", "id": "benefits.Effort"},
|
10
|
+
{"name": "Forms Engine", "parentId": "Benefits", "id": "benefits.FormsEngine"},
|
11
|
+
{"name": "Features and Benefits Summary", "parentId": "Benefits", "id": "benefits.Features"},
|
12
|
+
{"name": "Getting Started", "parentId": null, "isLeaf": false, "id": "GettingStarted", "collapsed": true},
|
13
|
+
{"name": "Setup", "parentId": "GettingStarted", "id": "gettingstarted.Setup"},
|
14
|
+
{"name": "Workspaces and Applications", "parentId": "GettingStarted", "id": "gettingstarted.Workspaces"},
|
15
|
+
{"name": "Describing a View", "parentId": "GettingStarted", "id": "gettingstarted.DescribingTheUI"},
|
16
|
+
{"name": "Events", "parentId": "GettingStarted", "id": "gettingstarted.Events"},
|
17
|
+
{"name": "Component References", "parentId": "GettingStarted", "id": "gettingstarted.References"},
|
18
|
+
{"name": "Extending Classes", "parentId": "GettingStarted", "id": "gettingstarted.Extending"},
|
19
|
+
{"name": "Config", "parentId": "GettingStarted", "id": "gettingstarted.Config"},
|
20
|
+
{"name": "Shared Bindable Data", "parentId": "GettingStarted", "id": "gettingstarted.ComponentModels"},
|
21
|
+
{"name": "Tutorials", "parentId": null, "isLeaf": false, "id": "Tutorials", "collapsed": true},
|
22
|
+
{"name": "Rock Scissors Paper", "parentId": "Tutorials", "id": "tutorials.RSP", "hidden": true},
|
23
|
+
{"name": "Earthquakes", "parentId": "Tutorials", "id": "tutorials.Earthquakes"},
|
24
|
+
{"name": "Todo List", "parentId": "Tutorials", "id": "tutorials.TodoList"},
|
25
|
+
{"name": "Guides", "parentId": null, "isLeaf": false, "id": "InDepth", "collapsed": true},
|
26
|
+
{"name": "Instance Lifecycle", "parentId": "InDepth", "id": "guides.InstanceLifecycle", "hidden": true},
|
27
|
+
{"name": "User Input (Forms)", "parentId": "InDepth", "id": "guides.Forms", "hidden": true},
|
28
|
+
{"name": "Component and Container Basics", "parentId": "InDepth", "id": "guides.ComponentsAndContainers"},
|
29
|
+
{"name": "Layouts", "parentId": "InDepth", "isLeaf": false, "id": "guides.Layouts", "hidden": true},
|
30
|
+
{"name": "Shared Bindable Data (State Providers)", "parentId": "InDepth", "id": "guides.StateProviders"},
|
31
|
+
{"name": "Custom Components", "parentId": "InDepth", "id": "guides.CustomComponents", "hidden": true},
|
32
|
+
{"name": "Events", "parentId": "InDepth", "isLeaf": false, "id": "GuideEvents"},
|
33
|
+
{"name": "Custom Events", "parentId": "GuideEvents", "id": "guides.events.CustomEvents"},
|
34
|
+
{"name": "DOM Events", "parentId": "GuideEvents", "id": "guides.events.DomEvents"},
|
35
|
+
{"name": "Portal App", "parentId": "InDepth", "id": "guides.PortalApp"},
|
36
|
+
{"name": "Tables (Stores)", "parentId": "InDepth", "id": "guides.Tables", "hidden": true},
|
37
|
+
{"name": "Multi-Window Applications", "parentId": "InDepth", "id": "guides.MultiWindow", "hidden": true},
|
38
|
+
{"name": "Main Thread Addons", "parentId": "InDepth", "isLeaf": false, "id": "MainThreadAddons", "hidden": true},
|
39
|
+
{"name": "Introduction", "parentId": "MainThreadAddons", "id": "guides.MainThreadAddonIntro"},
|
40
|
+
{"name": "Example", "parentId": "MainThreadAddons", "id": "guides.MainThreadAddonExample"},
|
41
|
+
{"name": "Mixins", "parentId": "InDepth", "id": "guides.Mixins", "hidden": true},
|
42
|
+
{"name": "JavaScript Classes", "parentId": null, "isLeaf": false, "id": "JavaScript", "hidden": true},
|
43
|
+
{"name": "Classes, Properties, and Methods", "parentId": "JavaScript", "id": "javascript.Classes"},
|
44
|
+
{"name": "Overriding Methods", "parentId": "JavaScript", "id": "javascript.Overrides"},
|
45
|
+
{"name": "Other JavaScript Class Features", "parentId": "JavaScript", "id": "javascript.ClassFeatures"},
|
46
|
+
{"name": "Super", "parentId": "JavaScript", "id": "javascript.Super"},
|
47
|
+
{"name": "New Node", "parentId": "JavaScript", "id": "javascript.NewNode"}
|
48
48
|
]}
|
package/src/DefaultConfig.mjs
CHANGED
@@ -262,12 +262,12 @@ const DefaultConfig = {
|
|
262
262
|
useVdomWorker: true,
|
263
263
|
/**
|
264
264
|
* buildScripts/injectPackageVersion.mjs will update this value
|
265
|
-
* @default '8.0.0-beta.
|
265
|
+
* @default '8.0.0-beta.2'
|
266
266
|
* @memberOf! module:Neo
|
267
267
|
* @name config.version
|
268
268
|
* @type String
|
269
269
|
*/
|
270
|
-
version: '8.0.0-beta.
|
270
|
+
version: '8.0.0-beta.2'
|
271
271
|
};
|
272
272
|
|
273
273
|
Object.assign(DefaultConfig, {
|
package/src/button/Base.mjs
CHANGED
@@ -272,11 +272,11 @@ class Base extends Component {
|
|
272
272
|
afterSetMenu(value, oldValue) {
|
273
273
|
if (value) {
|
274
274
|
import('../menu/List.mjs').then(module => {
|
275
|
-
let me
|
276
|
-
isArray
|
277
|
-
items
|
278
|
-
menuConfig
|
279
|
-
|
275
|
+
let me = this,
|
276
|
+
isArray = Array.isArray(value),
|
277
|
+
items = isArray ? value : value.items,
|
278
|
+
menuConfig = isArray ? {} : value,
|
279
|
+
stateProvider = me.getStateProvider(),
|
280
280
|
{appName, theme, windowId} = me,
|
281
281
|
|
282
282
|
config = Neo.merge({
|
@@ -295,8 +295,8 @@ class Base extends Component {
|
|
295
295
|
config.items = items
|
296
296
|
}
|
297
297
|
|
298
|
-
if (
|
299
|
-
config.
|
298
|
+
if (stateProvider) {
|
299
|
+
config.stateProvider = {parent: stateProvider}
|
300
300
|
}
|
301
301
|
|
302
302
|
me.menuList = Neo.create(config)
|
@@ -45,7 +45,7 @@ class EditEventContainer extends FormContainer {
|
|
45
45
|
*/
|
46
46
|
endTimeFieldConfig: null,
|
47
47
|
/**
|
48
|
-
* Bound to the
|
48
|
+
* Bound to the state provider.
|
49
49
|
* @member {Intl.DateTimeFormat|null} intlFormat_time=null
|
50
50
|
* @protected
|
51
51
|
*/
|
@@ -177,7 +177,7 @@ class EditEventContainer extends FormContainer {
|
|
177
177
|
|
178
178
|
store: {
|
179
179
|
module : CalendarStore,
|
180
|
-
sourceId: me.
|
180
|
+
sourceId: me.stateProvider.getStore('calendars').id
|
181
181
|
},
|
182
182
|
|
183
183
|
...me.calendarFieldConfig
|
@@ -250,7 +250,7 @@ class EditEventContainer extends FormContainer {
|
|
250
250
|
onDeleteButtonClick(data) {
|
251
251
|
let me = this;
|
252
252
|
|
253
|
-
me.
|
253
|
+
me.getStateProvider().getStore('events').remove(me.record);
|
254
254
|
me.unmount()
|
255
255
|
}
|
256
256
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import CalendarsContainer
|
2
|
-
import Container
|
3
|
-
import DateSelector
|
4
|
-
import DateUtil
|
5
|
-
import EditCalendarContainer
|
6
|
-
import EditEventContainer
|
7
|
-
import
|
8
|
-
import Toolbar
|
1
|
+
import CalendarsContainer from './calendars/Container.mjs';
|
2
|
+
import Container from '../../container/Base.mjs';
|
3
|
+
import DateSelector from '../../component/DateSelector.mjs';
|
4
|
+
import DateUtil from '../../util/Date.mjs';
|
5
|
+
import EditCalendarContainer from './calendars/EditContainer.mjs';
|
6
|
+
import EditEventContainer from './EditEventContainer.mjs';
|
7
|
+
import MainContainerStateProvider from './MainContainerStateProvider.mjs';
|
8
|
+
import Toolbar from '../../toolbar/Base.mjs';
|
9
9
|
|
10
10
|
const todayDate = new Date();
|
11
11
|
|
@@ -102,10 +102,6 @@ class MainContainer extends Container {
|
|
102
102
|
* @protected
|
103
103
|
*/
|
104
104
|
layout: {ntype: 'vbox', align: 'stretch'},
|
105
|
-
/**
|
106
|
-
* @member {Neo.calendar.view.MainContainerModel} model=MainContainerModel
|
107
|
-
*/
|
108
|
-
model: MainContainerModel,
|
109
105
|
/**
|
110
106
|
* @member {Neo.calendar.view.Component|null} monthComponent=null
|
111
107
|
*/
|
@@ -139,6 +135,10 @@ class MainContainer extends Container {
|
|
139
135
|
* @member {Number} sideBarWidth=220
|
140
136
|
*/
|
141
137
|
sideBarWidth: 220,
|
138
|
+
/**
|
139
|
+
* @member {Neo.calendar.view.MainContainerStateProvider} stateProvider=MainContainerStateProvider
|
140
|
+
*/
|
141
|
+
stateProvider: MainContainerStateProvider,
|
142
142
|
/**
|
143
143
|
* @member {Boolean} useSettingsContainer_=true
|
144
144
|
*/
|
@@ -326,12 +326,12 @@ class MainContainer extends Container {
|
|
326
326
|
let me = this;
|
327
327
|
|
328
328
|
me._editCalendarContainer = value = Neo.create({
|
329
|
-
module
|
330
|
-
appName
|
331
|
-
|
332
|
-
|
333
|
-
width
|
334
|
-
windowId: me.windowId,
|
329
|
+
module : EditCalendarContainer,
|
330
|
+
appName : me.appName,
|
331
|
+
owner : me,
|
332
|
+
stateProvider: {parent: me.getStateProvider()},
|
333
|
+
width : 250,
|
334
|
+
windowId : me.windowId,
|
335
335
|
...me.editCalendarContainerConfig
|
336
336
|
})
|
337
337
|
}
|
@@ -349,12 +349,12 @@ class MainContainer extends Container {
|
|
349
349
|
let me = this;
|
350
350
|
|
351
351
|
me._editEventContainer = value = Neo.create({
|
352
|
-
module
|
353
|
-
appName
|
354
|
-
|
355
|
-
|
356
|
-
width
|
357
|
-
windowId: me.windowId,
|
352
|
+
module : EditEventContainer,
|
353
|
+
appName : me.appName,
|
354
|
+
owner : me,
|
355
|
+
stateProvider: {parent: me.getStateProvider()},
|
356
|
+
width : 250,
|
357
|
+
windowId : me.windowId,
|
358
358
|
...me.editEventContainerConfig
|
359
359
|
})
|
360
360
|
}
|
@@ -600,7 +600,7 @@ class MainContainer extends Container {
|
|
600
600
|
* @param {String} data.value
|
601
601
|
*/
|
602
602
|
onDateSelectorChange(data) {
|
603
|
-
data.oldValue !== undefined && this.
|
603
|
+
data.oldValue !== undefined && this.setState('currentDate', new Date(`${data.value}T00:00:00.000Z`))
|
604
604
|
}
|
605
605
|
|
606
606
|
/**
|
@@ -621,7 +621,7 @@ class MainContainer extends Container {
|
|
621
621
|
* @param data
|
622
622
|
*/
|
623
623
|
onTodayButtonClick(data) {
|
624
|
-
this.
|
624
|
+
this.stateProvider.setData({
|
625
625
|
currentDate: todayDate
|
626
626
|
})
|
627
627
|
}
|
@@ -656,7 +656,7 @@ class MainContainer extends Container {
|
|
656
656
|
|
657
657
|
map[me.activeView]();
|
658
658
|
|
659
|
-
me.
|
659
|
+
me.stateProvider.setData({currentDate})
|
660
660
|
}
|
661
661
|
}
|
662
662
|
|
@@ -1,21 +1,21 @@
|
|
1
1
|
import CalendarsStore from '../store/Calendars.mjs';
|
2
2
|
import ColorsStore from '../store/Colors.mjs';
|
3
3
|
import EventsStore from '../store/Events.mjs';
|
4
|
-
import
|
4
|
+
import StateProvider from '../../../src/state/Provider.mjs';
|
5
5
|
|
6
6
|
const todayDate = new Date();
|
7
7
|
|
8
8
|
/**
|
9
|
-
* @class Neo.calendar.view.
|
10
|
-
* @extends Neo.
|
9
|
+
* @class Neo.calendar.view.MainContainerStateProvider
|
10
|
+
* @extends Neo.state.Provider
|
11
11
|
*/
|
12
|
-
class
|
12
|
+
class MainContainerStateProvider extends StateProvider {
|
13
13
|
static config = {
|
14
14
|
/**
|
15
|
-
* @member {String} className='Neo.calendar.view.
|
15
|
+
* @member {String} className='Neo.calendar.view.MainContainerStateProvider'
|
16
16
|
* @protected
|
17
17
|
*/
|
18
|
-
className: 'Neo.calendar.view.
|
18
|
+
className: 'Neo.calendar.view.MainContainerStateProvider',
|
19
19
|
/**
|
20
20
|
* @member {Object} data
|
21
21
|
*/
|
@@ -168,4 +168,4 @@ class MainContainerModel extends Component {
|
|
168
168
|
}
|
169
169
|
}
|
170
170
|
|
171
|
-
export default Neo.setupClass(
|
171
|
+
export default Neo.setupClass(MainContainerStateProvider);
|