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
@@ -44,7 +44,7 @@ class YearComponent extends Component {
|
|
44
44
|
*/
|
45
45
|
cachedUpdate: null,
|
46
46
|
/**
|
47
|
-
* Bound to the
|
47
|
+
* Bound to the state provider.
|
48
48
|
* @member {Neo.calendar.store.Calendars|null} calendarStore_=null
|
49
49
|
*/
|
50
50
|
calendarStore_: null,
|
@@ -73,7 +73,7 @@ class YearComponent extends Component {
|
|
73
73
|
*/
|
74
74
|
eventIndicatorMedium_: 2,
|
75
75
|
/**
|
76
|
-
* Bound to the
|
76
|
+
* Bound to the state provider.
|
77
77
|
* @member {Neo.calendar.store.Events|null} eventStore_=null
|
78
78
|
*/
|
79
79
|
eventStore_: null,
|
@@ -94,7 +94,7 @@ class YearComponent extends Component {
|
|
94
94
|
*/
|
95
95
|
isUpdating_: false,
|
96
96
|
/**
|
97
|
-
* Bound to the
|
97
|
+
* Bound to the state provider.
|
98
98
|
* @member {String} locale_=Neo.config.locale
|
99
99
|
*/
|
100
100
|
locale_: Neo.config.locale,
|
@@ -131,7 +131,7 @@ class YearComponent extends Component {
|
|
131
131
|
*/
|
132
132
|
showDisabledDays_: true,
|
133
133
|
/**
|
134
|
-
* Bound to the
|
134
|
+
* Bound to the state provider.
|
135
135
|
* @member {Boolean} showWeekends_=true
|
136
136
|
*/
|
137
137
|
showWeekends_: true,
|
@@ -166,7 +166,7 @@ class YearComponent extends Component {
|
|
166
166
|
]},
|
167
167
|
/**
|
168
168
|
* 0-6 => Sun-Sat
|
169
|
-
* Bound to the
|
169
|
+
* Bound to the state provider.
|
170
170
|
* @member {Number} weekStartDay_=0
|
171
171
|
*/
|
172
172
|
weekStartDay_: 0
|
@@ -148,7 +148,7 @@ class List extends ComponentList {
|
|
148
148
|
* @param {String[]} items
|
149
149
|
*/
|
150
150
|
onSelect(items) {
|
151
|
-
this.
|
151
|
+
this.setState('activeCalendarId', this.getItemRecordId(items[0]))
|
152
152
|
}
|
153
153
|
|
154
154
|
/**
|
@@ -39,7 +39,7 @@ class Component extends BaseComponent {
|
|
39
39
|
weekStartDay : data => data.weekStartDay
|
40
40
|
},
|
41
41
|
/**
|
42
|
-
* Bound to the
|
42
|
+
* Bound to the state provider
|
43
43
|
* @member {Neo.calendar.store.Calendars|null} calendarStore_=null
|
44
44
|
*/
|
45
45
|
calendarStore_: null,
|
@@ -56,12 +56,12 @@ class Component extends BaseComponent {
|
|
56
56
|
*/
|
57
57
|
dayNameFormat_: 'short',
|
58
58
|
/**
|
59
|
-
* Bound to the
|
59
|
+
* Bound to the state provider
|
60
60
|
* @member {String|null} eventBorder_=null
|
61
61
|
*/
|
62
62
|
eventBorder_: null,
|
63
63
|
/**
|
64
|
-
* Bound to the
|
64
|
+
* Bound to the state provider.
|
65
65
|
* @member {Neo.calendar.store.Events|null} eventStore_=null
|
66
66
|
*/
|
67
67
|
eventStore_: null,
|
@@ -93,7 +93,7 @@ class Component extends BaseComponent {
|
|
93
93
|
*/
|
94
94
|
isScrolling: false,
|
95
95
|
/**
|
96
|
-
* Bound to the
|
96
|
+
* Bound to the state provider.
|
97
97
|
* @member {String} locale_=Neo.config.locale
|
98
98
|
*/
|
99
99
|
locale_: Neo.config.locale,
|
@@ -120,7 +120,7 @@ class Component extends BaseComponent {
|
|
120
120
|
*/
|
121
121
|
scrollTaskId: null,
|
122
122
|
/**
|
123
|
-
* Bound to the
|
123
|
+
* Bound to the state provider.
|
124
124
|
* @member {Boolean} showWeekends_=true
|
125
125
|
*/
|
126
126
|
showWeekends_: true,
|
@@ -148,7 +148,7 @@ class Component extends BaseComponent {
|
|
148
148
|
]},
|
149
149
|
/**
|
150
150
|
* 0-6 => Sun-Sat
|
151
|
-
* Bound to the
|
151
|
+
* Bound to the state provider.
|
152
152
|
* @member {Number} weekStartDay_=0
|
153
153
|
*/
|
154
154
|
weekStartDay_: 0
|
@@ -273,7 +273,7 @@ class GeneralContainer extends Container {
|
|
273
273
|
* @param {Object} data
|
274
274
|
*/
|
275
275
|
onDataChange(data) {
|
276
|
-
this.
|
276
|
+
this.setState(data.component.name, data.value)
|
277
277
|
}
|
278
278
|
|
279
279
|
/**
|
@@ -281,7 +281,7 @@ class GeneralContainer extends Container {
|
|
281
281
|
*/
|
282
282
|
onRadioDataChange(data) {
|
283
283
|
if (data.value) {
|
284
|
-
this.
|
284
|
+
this.setState(data.component.name, data.component.fieldValue)
|
285
285
|
}
|
286
286
|
}
|
287
287
|
}
|
@@ -53,7 +53,7 @@ class Component extends BaseComponent {
|
|
53
53
|
weekStartDay : data => data.weekStartDay
|
54
54
|
},
|
55
55
|
/**
|
56
|
-
* Bound to the
|
56
|
+
* Bound to the state provider
|
57
57
|
* @member {Neo.calendar.store.Calendars|null} calendarStore_=null
|
58
58
|
*/
|
59
59
|
calendarStore_: null,
|
@@ -68,7 +68,7 @@ class Component extends BaseComponent {
|
|
68
68
|
*/
|
69
69
|
columnsVisible_: 7,
|
70
70
|
/**
|
71
|
-
* Bound to the
|
71
|
+
* Bound to the state provider.
|
72
72
|
* @member {Date|null} currentDate_=null
|
73
73
|
* @protected
|
74
74
|
*/
|
@@ -80,13 +80,13 @@ class Component extends BaseComponent {
|
|
80
80
|
*/
|
81
81
|
dayNameFormat_: 'short',
|
82
82
|
/**
|
83
|
-
* Bound to the
|
83
|
+
* Bound to the state provider.
|
84
84
|
* @member {Boolean} enableDrag_=true
|
85
85
|
* @protected
|
86
86
|
*/
|
87
87
|
enableDrag_: true,
|
88
88
|
/**
|
89
|
-
* Bound to the
|
89
|
+
* Bound to the state provider
|
90
90
|
* @member {String|null} eventBorder_=null
|
91
91
|
*/
|
92
92
|
eventBorder_: null,
|
@@ -95,7 +95,7 @@ class Component extends BaseComponent {
|
|
95
95
|
*/
|
96
96
|
eventDragZone: null,
|
97
97
|
/**
|
98
|
-
* Bound to the
|
98
|
+
* Bound to the state provider
|
99
99
|
* @member {Neo.calendar.store.Events|null} eventStore_=null
|
100
100
|
*/
|
101
101
|
eventStore_: null,
|
@@ -117,7 +117,7 @@ class Component extends BaseComponent {
|
|
117
117
|
*/
|
118
118
|
intlFormat_day: null,
|
119
119
|
/**
|
120
|
-
* Bound to the
|
120
|
+
* Bound to the state provider.
|
121
121
|
* @member {Intl.DateTimeFormat|null} intlFormat_time_=null
|
122
122
|
* @protected
|
123
123
|
*/
|
@@ -128,12 +128,12 @@ class Component extends BaseComponent {
|
|
128
128
|
*/
|
129
129
|
isUpdating: false,
|
130
130
|
/**
|
131
|
-
* Bound to the
|
131
|
+
* Bound to the state provider.
|
132
132
|
* @member {String} locale_=Neo.config.locale
|
133
133
|
*/
|
134
134
|
locale_: Neo.config.locale,
|
135
135
|
/**
|
136
|
-
* Time in minutes. Bound to the
|
136
|
+
* Time in minutes. Bound to the state provider.
|
137
137
|
* @member {Number} minimumEventDuration=30
|
138
138
|
* @protected
|
139
139
|
*/
|
@@ -164,7 +164,7 @@ class Component extends BaseComponent {
|
|
164
164
|
*/
|
165
165
|
showEventEndTime_: false,
|
166
166
|
/**
|
167
|
-
* Bound to the
|
167
|
+
* Bound to the state provider.
|
168
168
|
* @member {Boolean} showWeekends_=true
|
169
169
|
*/
|
170
170
|
showWeekends_: true,
|
@@ -206,7 +206,7 @@ class Component extends BaseComponent {
|
|
206
206
|
]},
|
207
207
|
/**
|
208
208
|
* 0-6 => Sun-Sat
|
209
|
-
* Bound to the
|
209
|
+
* Bound to the state provider.
|
210
210
|
* @member {Number} weekStartDay_=0
|
211
211
|
*/
|
212
212
|
weekStartDay_: 0
|
@@ -252,7 +252,7 @@ class EventDragZone extends DragZone {
|
|
252
252
|
// todo: updating a record field which is included inside a sorter should trigger collection.doSort()
|
253
253
|
// see: https://github.com/neomjs/neo/issues/2392
|
254
254
|
|
255
|
-
owner.
|
255
|
+
owner.getStateProvider().getStore('events').doSort();
|
256
256
|
owner.updateEvents()
|
257
257
|
}
|
258
258
|
|
package/src/component/Base.mjs
CHANGED
@@ -15,7 +15,7 @@ import VNodeUtil from '../util/VNode.mjs';
|
|
15
15
|
const
|
16
16
|
addUnits = value => value == null ? value : isNaN(value) ? value : `${value}px`,
|
17
17
|
closestController = Symbol.for('closestController'),
|
18
|
-
|
18
|
+
closestProvider = Symbol.for('closestProvider'),
|
19
19
|
lengthRE = /^\d+\w+$/,
|
20
20
|
twoWayBindingSymbol = Symbol.for('twoWayBinding');
|
21
21
|
|
@@ -85,14 +85,14 @@ class Base extends CoreBase {
|
|
85
85
|
*/
|
86
86
|
baseCls: [],
|
87
87
|
/**
|
88
|
-
* Bind configs to
|
88
|
+
* Bind configs to state.Provider data properties.
|
89
89
|
* Example for a button.Base:
|
90
90
|
* @example
|
91
91
|
* bind: {
|
92
92
|
* iconCls: data => `fa fa-{$data.icon}`,
|
93
93
|
* text : data => data.foo.bar
|
94
94
|
* }
|
95
|
-
* @see https://github.com/neomjs/neo/blob/dev/examples/
|
95
|
+
* @see https://github.com/neomjs/neo/blob/dev/examples/stateProvider
|
96
96
|
* @member {Object|null} bind=null
|
97
97
|
*/
|
98
98
|
bind: null,
|
@@ -114,7 +114,7 @@ class Base extends CoreBase {
|
|
114
114
|
*/
|
115
115
|
controller_: null,
|
116
116
|
/**
|
117
|
-
* Convenience shortcut to access the data config of the closest
|
117
|
+
* Convenience shortcut to access the data config of the closest state.Provider.
|
118
118
|
* Read only.
|
119
119
|
* @member {Object} data_=null
|
120
120
|
* @protected
|
@@ -244,14 +244,9 @@ class Base extends CoreBase {
|
|
244
244
|
*/
|
245
245
|
minWidth_: null,
|
246
246
|
/**
|
247
|
-
*
|
248
|
-
* @member {Object|null} model_=null
|
249
|
-
*/
|
250
|
-
model_: null,
|
251
|
-
/**
|
252
|
-
* Override specific model data properties.
|
247
|
+
* Override specific stateProvider data properties.
|
253
248
|
* This will merge the content.
|
254
|
-
* @member {Object|null}
|
249
|
+
* @member {Object|null} modelData=null
|
255
250
|
*/
|
256
251
|
modelData: null,
|
257
252
|
/**
|
@@ -268,7 +263,7 @@ class Base extends CoreBase {
|
|
268
263
|
needsVdomUpdate_: false,
|
269
264
|
/**
|
270
265
|
* If the parentId does not match a neo component id, you can manually set this value for finding
|
271
|
-
* view controllers or
|
266
|
+
* view controllers or state providers.
|
272
267
|
* Use case: manually dropping components into a vdom structure
|
273
268
|
* @member {Neo.component.Base|null} parentComponent_=null
|
274
269
|
* @protected
|
@@ -324,6 +319,11 @@ class Base extends CoreBase {
|
|
324
319
|
* @member {Boolean} silentVdomUpdate_=false
|
325
320
|
*/
|
326
321
|
silentVdomUpdate_: false,
|
322
|
+
/**
|
323
|
+
* Optionally add a state.Provider to share state data with child components
|
324
|
+
* @member {Object|null} stateProvider_=null
|
325
|
+
*/
|
326
|
+
stateProvider_: null,
|
327
327
|
/**
|
328
328
|
* Style attributes added to this vdom root. see: getVdomRoot()
|
329
329
|
* @member {Object} style_=null
|
@@ -573,11 +573,11 @@ class Base extends CoreBase {
|
|
573
573
|
afterSetConfig(key, value, oldValue) {
|
574
574
|
let me = this;
|
575
575
|
|
576
|
-
if (Neo.currentWorker.
|
576
|
+
if (Neo.currentWorker.isUsingStateProviders && me[twoWayBindingSymbol] && oldValue !== undefined) {
|
577
577
|
let binding = me.bind?.[key];
|
578
578
|
|
579
579
|
if (binding?.twoWay) {
|
580
|
-
this.
|
580
|
+
this.getStateProvider()?.setData(binding.key, value)
|
581
581
|
}
|
582
582
|
}
|
583
583
|
}
|
@@ -1167,13 +1167,12 @@ class Base extends CoreBase {
|
|
1167
1167
|
|
1168
1168
|
/**
|
1169
1169
|
* Triggered when accessing the data config
|
1170
|
-
* Convenience shortcut which is expensive to use,
|
1171
|
-
* since it will generate a merged parent model data map.
|
1170
|
+
* Convenience shortcut which is expensive to use, since it will generate a merged parent state providers data map.
|
1172
1171
|
* @param {Object} value
|
1173
1172
|
* @protected
|
1174
1173
|
*/
|
1175
1174
|
beforeGetData(value) {
|
1176
|
-
return this.
|
1175
|
+
return this.getStateProvider().getHierarchyData()
|
1177
1176
|
}
|
1178
1177
|
|
1179
1178
|
/**
|
@@ -1304,14 +1303,14 @@ class Base extends CoreBase {
|
|
1304
1303
|
}
|
1305
1304
|
|
1306
1305
|
/**
|
1307
|
-
* Triggered before the
|
1308
|
-
* Creates a
|
1306
|
+
* Triggered before the stateProvider config gets changed.
|
1307
|
+
* Creates a state.Provider instance if needed.
|
1309
1308
|
* @param {Object} value
|
1310
1309
|
* @param {Object} oldValue
|
1311
|
-
* @returns {Neo.
|
1310
|
+
* @returns {Neo.state.Provider}
|
1312
1311
|
* @protected
|
1313
1312
|
*/
|
1314
|
-
|
1313
|
+
beforeSetStateProvider(value, oldValue) {
|
1315
1314
|
oldValue?.destroy();
|
1316
1315
|
|
1317
1316
|
if (value) {
|
@@ -1322,7 +1321,7 @@ class Base extends CoreBase {
|
|
1322
1321
|
defaultValues.data = me.modelData
|
1323
1322
|
}
|
1324
1323
|
|
1325
|
-
return ClassSystemUtil.beforeSetInstance(value, 'Neo.
|
1324
|
+
return ClassSystemUtil.beforeSetInstance(value, 'Neo.state.Provider', defaultValues)
|
1326
1325
|
}
|
1327
1326
|
|
1328
1327
|
return null
|
@@ -1469,9 +1468,9 @@ class Base extends CoreBase {
|
|
1469
1468
|
* todo: unregister events
|
1470
1469
|
*/
|
1471
1470
|
destroy(updateParentVdom=false, silent=false) {
|
1472
|
-
let me
|
1473
|
-
{parent, parentId}
|
1474
|
-
|
1471
|
+
let me = this,
|
1472
|
+
{parent, parentId} = me,
|
1473
|
+
parentStateProvider = parent?.getStateProvider(),
|
1475
1474
|
parentVdom;
|
1476
1475
|
|
1477
1476
|
me.revertFocus();
|
@@ -1482,9 +1481,9 @@ class Base extends CoreBase {
|
|
1482
1481
|
|
1483
1482
|
me.reference && me.getController()?.removeReference(me); // remove own reference from parent controllers
|
1484
1483
|
|
1485
|
-
me.
|
1484
|
+
me.stateProvider = null; // triggers destroy()
|
1486
1485
|
|
1487
|
-
me.bind &&
|
1486
|
+
me.bind && parentStateProvider?.removeBindings(me.id);
|
1488
1487
|
|
1489
1488
|
me.plugins?.forEach(plugin => {
|
1490
1489
|
plugin.destroy()
|
@@ -1614,7 +1613,7 @@ class Base extends CoreBase {
|
|
1614
1613
|
/**
|
1615
1614
|
* Find an instance stored inside a config via optionally passing a ntype.
|
1616
1615
|
* Returns this[configName] or the closest parent component with a match.
|
1617
|
-
* Used by getController() &
|
1616
|
+
* Used by getController() & getStateProvider()
|
1618
1617
|
* @param {String} configName
|
1619
1618
|
* @param {String} [ntype]
|
1620
1619
|
* @returns {Neo.core.Base|null}
|
@@ -1681,36 +1680,6 @@ class Base extends CoreBase {
|
|
1681
1680
|
return Rectangle.clone(result)
|
1682
1681
|
}
|
1683
1682
|
|
1684
|
-
/**
|
1685
|
-
* Returns this.model or the closest parent model
|
1686
|
-
* @param {String} [ntype]
|
1687
|
-
* @returns {Neo.model.Component|null}
|
1688
|
-
*/
|
1689
|
-
getModel(ntype) {
|
1690
|
-
if (!Neo.currentWorker.isUsingViewModels) {
|
1691
|
-
return null
|
1692
|
-
}
|
1693
|
-
|
1694
|
-
let me = this,
|
1695
|
-
model;
|
1696
|
-
|
1697
|
-
if (!ntype) {
|
1698
|
-
model = me[closestModel];
|
1699
|
-
|
1700
|
-
if (model) {
|
1701
|
-
return model
|
1702
|
-
}
|
1703
|
-
}
|
1704
|
-
|
1705
|
-
model = me.getConfigInstanceByNtype('model', ntype);
|
1706
|
-
|
1707
|
-
if (!ntype) {
|
1708
|
-
me[closestModel] = model
|
1709
|
-
}
|
1710
|
-
|
1711
|
-
return model
|
1712
|
-
}
|
1713
|
-
|
1714
1683
|
/**
|
1715
1684
|
* Honors different item roots for mount / render OPs
|
1716
1685
|
* @returns {String}
|
@@ -1799,6 +1768,45 @@ class Base extends CoreBase {
|
|
1799
1768
|
return this.down({reference: value})
|
1800
1769
|
}
|
1801
1770
|
|
1771
|
+
/**
|
1772
|
+
* Convenience shortcut
|
1773
|
+
* @param args
|
1774
|
+
* @returns {*}
|
1775
|
+
*/
|
1776
|
+
getState(...args) {
|
1777
|
+
return this.getStateProvider().getData(...args)
|
1778
|
+
}
|
1779
|
+
|
1780
|
+
/**
|
1781
|
+
* Returns this.stateProvider or the closest parent stateProvider
|
1782
|
+
* @param {String} [ntype]
|
1783
|
+
* @returns {Neo.state.Provider|null}
|
1784
|
+
*/
|
1785
|
+
getStateProvider(ntype) {
|
1786
|
+
if (!Neo.currentWorker.isUsingStateProviders) {
|
1787
|
+
return null
|
1788
|
+
}
|
1789
|
+
|
1790
|
+
let me = this,
|
1791
|
+
provider;
|
1792
|
+
|
1793
|
+
if (!ntype) {
|
1794
|
+
provider = me[closestProvider];
|
1795
|
+
|
1796
|
+
if (provider) {
|
1797
|
+
return provider
|
1798
|
+
}
|
1799
|
+
}
|
1800
|
+
|
1801
|
+
provider = me.getConfigInstanceByNtype('stateProvider', ntype);
|
1802
|
+
|
1803
|
+
if (!ntype) {
|
1804
|
+
me[closestProvider] = provider
|
1805
|
+
}
|
1806
|
+
|
1807
|
+
return provider
|
1808
|
+
}
|
1809
|
+
|
1802
1810
|
/**
|
1803
1811
|
* Walks up the vdom tree and returns the closest theme found
|
1804
1812
|
* @returns {String}
|
@@ -1912,7 +1920,7 @@ class Base extends CoreBase {
|
|
1912
1920
|
}
|
1913
1921
|
|
1914
1922
|
/**
|
1915
|
-
* We are using this method as a ctor hook here to add the initial
|
1923
|
+
* We are using this method as a ctor hook here to add the initial state.Provider & controller.Component parsing
|
1916
1924
|
* @param {Object} config
|
1917
1925
|
* @param {Boolean} [preventOriginalConfig] True prevents the instance from getting an originalConfig property
|
1918
1926
|
*/
|
@@ -1921,8 +1929,8 @@ class Base extends CoreBase {
|
|
1921
1929
|
|
1922
1930
|
let me = this;
|
1923
1931
|
|
1924
|
-
me.getController()?.parseConfig(me);
|
1925
|
-
me.
|
1932
|
+
me.getController() ?.parseConfig(me);
|
1933
|
+
me.getStateProvider()?.parseConfig(me)
|
1926
1934
|
}
|
1927
1935
|
|
1928
1936
|
/**
|
@@ -2383,6 +2391,14 @@ class Base extends CoreBase {
|
|
2383
2391
|
return this.set(values, true)
|
2384
2392
|
}
|
2385
2393
|
|
2394
|
+
/**
|
2395
|
+
* Convenience shortcut
|
2396
|
+
* @param args
|
2397
|
+
*/
|
2398
|
+
setState(...args) {
|
2399
|
+
this.getStateProvider().setData(...args)
|
2400
|
+
}
|
2401
|
+
|
2386
2402
|
/**
|
2387
2403
|
* Show the component.
|
2388
2404
|
* hideMode: 'removeDom' uses vdom removeDom.
|
package/src/container/Base.mjs
CHANGED
@@ -313,10 +313,10 @@ class Base extends Component {
|
|
313
313
|
case 'NeoInstance': {
|
314
314
|
item.set(config);
|
315
315
|
|
316
|
-
// In case an item got created outside a VC or
|
316
|
+
// In case an item got created outside a VC or stateProvider based hierarchy, there might be bindings or string
|
317
317
|
// based listeners which still need to get resolved.
|
318
|
-
item.getController()?.parseConfig(item);
|
319
|
-
item.
|
318
|
+
item.getController() ?.parseConfig(item);
|
319
|
+
item.getStateProvider()?.parseConfig(item);
|
320
320
|
break
|
321
321
|
}
|
322
322
|
|
@@ -95,16 +95,6 @@ class Component extends Base {
|
|
95
95
|
me : parent?.getHandlerScope(handlerName) || null
|
96
96
|
}
|
97
97
|
|
98
|
-
/**
|
99
|
-
* sameLevelOnly=false will return the closest VM inside the component parent tree,
|
100
|
-
* in case there is none on the same level.
|
101
|
-
* @param {Boolean} [sameLevelOnly=false]
|
102
|
-
*/
|
103
|
-
getModel(sameLevelOnly=false) {
|
104
|
-
let {component} = this;
|
105
|
-
return sameLevelOnly ? component.model : component.getModel()
|
106
|
-
}
|
107
|
-
|
108
98
|
/**
|
109
99
|
* Get the closest controller inside the components parent tree
|
110
100
|
* @returns {Neo.controller.Component|null}
|
@@ -141,12 +131,31 @@ class Component extends Base {
|
|
141
131
|
}
|
142
132
|
|
143
133
|
/**
|
144
|
-
* Convenience shortcut
|
134
|
+
* Convenience shortcut
|
135
|
+
* @param args
|
136
|
+
* @returns {*}
|
137
|
+
*/
|
138
|
+
getState(...args) {
|
139
|
+
return this.getStateProvider().getData(...args)
|
140
|
+
}
|
141
|
+
|
142
|
+
/**
|
143
|
+
* sameLevelOnly=false will return the closest stateProvider inside the component parent tree,
|
144
|
+
* in case there is none on the same level.
|
145
|
+
* @param {Boolean} [sameLevelOnly=false]
|
146
|
+
*/
|
147
|
+
getStateProvider(sameLevelOnly=false) {
|
148
|
+
let {component} = this;
|
149
|
+
return sameLevelOnly ? component.stateProvider : component.getStateProvider()
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Convenience shortcut for accessing state.Provider based data.Stores
|
145
154
|
* @param {String} key
|
146
155
|
* @returns {Neo.data.Store}
|
147
156
|
*/
|
148
157
|
getStore(key) {
|
149
|
-
return this.
|
158
|
+
return this.getStateProvider().getStore(key)
|
150
159
|
}
|
151
160
|
|
152
161
|
/**
|
@@ -267,6 +276,14 @@ class Component extends Base {
|
|
267
276
|
|
268
277
|
me.getParent()?.removeReference(component)
|
269
278
|
}
|
279
|
+
|
280
|
+
/**
|
281
|
+
* Convenience shortcut
|
282
|
+
* @param args
|
283
|
+
*/
|
284
|
+
setState(...args) {
|
285
|
+
this.getStateProvider().setData(...args)
|
286
|
+
}
|
270
287
|
}
|
271
288
|
|
272
289
|
export default Neo.setupClass(Component);
|