neo.mjs 8.0.0-alpha.2 → 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/.github/CODING_GUIDELINES.md +5 -5
- package/.github/CONCEPT.md +10 -10
- 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 +22 -22
- package/apps/covid/view/MainContainerController.mjs +8 -10
- package/apps/covid/view/{MainContainerModel.mjs → MainContainerStateProvider.mjs} +7 -7
- package/apps/covid/view/TableContainer.mjs +2 -2
- 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/ViewportController.mjs +2 -2
- package/apps/portal/view/ViewportStateProvider.mjs +27 -0
- package/apps/portal/view/examples/TabContainer.mjs +11 -11
- package/apps/portal/view/home/FooterContainer.mjs +1 -1
- package/apps/portal/view/home/parts/MainNeo.mjs +6 -2
- 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/realworld/view/article/CreateComponent.mjs +1 -1
- package/apps/realworld2/view/HomeContainer.mjs +7 -7
- package/apps/sharedcovid/view/GalleryContainer.mjs +2 -2
- package/apps/sharedcovid/view/HelixContainer.mjs +2 -2
- package/apps/sharedcovid/view/MainContainer.mjs +25 -25
- package/apps/sharedcovid/view/MainContainerController.mjs +10 -11
- package/apps/sharedcovid/view/{MainContainerModel.mjs → MainContainerStateProvider.mjs} +8 -8
- package/apps/sharedcovid/view/TableContainer.mjs +2 -2
- package/apps/sharedcovid/view/TableContainerController.mjs +1 -1
- package/apps/sharedcovid/view/mapboxGl/Container.mjs +2 -2
- package/buildScripts/createApp.mjs +2 -2
- package/buildScripts/createClass.mjs +15 -17
- package/buildScripts/createComponent.mjs +4 -4
- package/docs/app/view/ContentTabContainer.mjs +1 -1
- package/docs/app/view/MainContainer.mjs +3 -3
- package/docs/app/view/MainContainerController.mjs +15 -15
- package/examples/ServiceWorker.mjs +2 -2
- package/examples/component/mwc/buttons/MainContainer.mjs +2 -2
- package/examples/component/mwc/textFields/MainContainer.mjs +2 -2
- package/examples/fields/MainContainer.mjs +197 -228
- package/examples/preloadingAssets/view/MainContainer.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/tab/container/MainContainer.mjs +7 -9
- 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/tabs/MainContainer.mjs +3 -3
- package/examples/tabs/MainContainer2.mjs +4 -4
- 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/examples/videoMove/MainContainer.mjs +14 -7
- package/examples/viewport/MainContainer.mjs +3 -3
- package/package.json +6 -6
- package/resources/data/deck/learnneo/pages/benefits/FormsEngine.md +13 -13
- package/resources/data/deck/learnneo/pages/guides/{ViewModels.md → StateProviders.md} +52 -58
- package/resources/data/deck/learnneo/tree.json +46 -46
- package/resources/data/deck/training/pages/2022-12-27T21-55-23-144Z.md +2 -2
- package/resources/data/deck/training/pages/2022-12-28T17-11-34-653Z.md +6 -6
- package/resources/data/deck/training/pages/2022-12-29T18-36-08-226Z.md +2 -2
- package/resources/data/deck/training/pages/2022-12-29T18-36-56-893Z.md +2 -2
- package/resources/data/deck/training/pages/2022-12-29T20-37-08-919Z.md +2 -2
- package/resources/data/deck/training/pages/2022-12-29T20-37-20-344Z.md +2 -2
- package/resources/data/deck/training/pages/2023-01-01T21-11-58-025Z.md +3 -3
- package/resources/data/deck/training/pages/2023-01-16T20-24-09-690Z.md +4 -4
- package/resources/data/deck/training/pages/2023-02-05T17-44-53-815Z.md +3 -3
- package/resources/data/deck/training/pages/2023-02-05T17-45-40-114Z.md +1 -1
- 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/SettingsContainer.mjs +13 -28
- package/src/calendar/view/YearComponent.mjs +5 -5
- package/src/calendar/view/calendars/ColorsList.mjs +5 -0
- 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/code/LivePreview.mjs +10 -10
- package/src/component/Base.mjs +123 -105
- package/src/container/Base.mjs +4 -4
- 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/form/field/Text.mjs +1 -1
- package/src/form/field/Time.mjs +5 -3
- package/src/form/field/trigger/Time.mjs +2 -1
- package/src/layout/Base.mjs +6 -6
- package/src/list/Base.mjs +7 -1
- package/src/list/Color.mjs +3 -3
- package/src/main/DomEvents.mjs +1 -1
- package/src/main/DomUtils.mjs +39 -36
- package/src/{model/Component.mjs → state/Provider.mjs} +67 -69
- package/src/tab/Container.mjs +3 -5
- package/src/toolbar/Base.mjs +26 -8
- package/src/tree/Accordion.mjs +15 -13
- package/src/util/VNode.mjs +6 -8
- 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/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
|
}
|
@@ -737,13 +737,13 @@ class Base extends CoreBase {
|
|
737
737
|
* @protected
|
738
738
|
*/
|
739
739
|
afterSetIsLoading(value, oldValue) {
|
740
|
-
if (
|
740
|
+
if (value || oldValue !== undefined) {
|
741
741
|
let me = this,
|
742
742
|
{cls, vdom} = me,
|
743
743
|
maskIndex;
|
744
744
|
|
745
745
|
if (oldValue !== undefined && vdom.cn) {
|
746
|
-
maskIndex = vdom.cn.
|
746
|
+
maskIndex = vdom.cn.findLastIndex(c => c.cls?.includes('neo-load-mask'));
|
747
747
|
|
748
748
|
// Remove the load mask
|
749
749
|
if (maskIndex !== -1) {
|
@@ -752,19 +752,11 @@ class Base extends CoreBase {
|
|
752
752
|
}
|
753
753
|
|
754
754
|
if (value) {
|
755
|
-
vdom.cn
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
cls: me.loadingSpinnerCls
|
761
|
-
}, {
|
762
|
-
cls : ['neo-loading-message'],
|
763
|
-
html : value,
|
764
|
-
removeDom: !Neo.isString(value)
|
765
|
-
}]
|
766
|
-
}]
|
767
|
-
})
|
755
|
+
if (!vdom.cn) {
|
756
|
+
vdom.cn = []
|
757
|
+
}
|
758
|
+
|
759
|
+
vdom.cn.push(me.createLoadingMask(value))
|
768
760
|
}
|
769
761
|
|
770
762
|
NeoArray.toggle(cls, 'neo-masked', value);
|
@@ -1175,13 +1167,12 @@ class Base extends CoreBase {
|
|
1175
1167
|
|
1176
1168
|
/**
|
1177
1169
|
* Triggered when accessing the data config
|
1178
|
-
* Convenience shortcut which is expensive to use,
|
1179
|
-
* 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.
|
1180
1171
|
* @param {Object} value
|
1181
1172
|
* @protected
|
1182
1173
|
*/
|
1183
1174
|
beforeGetData(value) {
|
1184
|
-
return this.
|
1175
|
+
return this.getStateProvider().getHierarchyData()
|
1185
1176
|
}
|
1186
1177
|
|
1187
1178
|
/**
|
@@ -1312,14 +1303,14 @@ class Base extends CoreBase {
|
|
1312
1303
|
}
|
1313
1304
|
|
1314
1305
|
/**
|
1315
|
-
* Triggered before the
|
1316
|
-
* Creates a
|
1306
|
+
* Triggered before the stateProvider config gets changed.
|
1307
|
+
* Creates a state.Provider instance if needed.
|
1317
1308
|
* @param {Object} value
|
1318
1309
|
* @param {Object} oldValue
|
1319
|
-
* @returns {Neo.
|
1310
|
+
* @returns {Neo.state.Provider}
|
1320
1311
|
* @protected
|
1321
1312
|
*/
|
1322
|
-
|
1313
|
+
beforeSetStateProvider(value, oldValue) {
|
1323
1314
|
oldValue?.destroy();
|
1324
1315
|
|
1325
1316
|
if (value) {
|
@@ -1330,7 +1321,7 @@ class Base extends CoreBase {
|
|
1330
1321
|
defaultValues.data = me.modelData
|
1331
1322
|
}
|
1332
1323
|
|
1333
|
-
return ClassSystemUtil.beforeSetInstance(value, 'Neo.
|
1324
|
+
return ClassSystemUtil.beforeSetInstance(value, 'Neo.state.Provider', defaultValues)
|
1334
1325
|
}
|
1335
1326
|
|
1336
1327
|
return null
|
@@ -1403,6 +1394,28 @@ class Base extends CoreBase {
|
|
1403
1394
|
me.update()
|
1404
1395
|
}
|
1405
1396
|
|
1397
|
+
/**
|
1398
|
+
* Override this method in case you need different mask markups.
|
1399
|
+
* The removal logic relies on the top level node having the cls 'neo-load-mask'
|
1400
|
+
* @param {Boolean|String} loadingMessage
|
1401
|
+
* @returns {Object} vdom
|
1402
|
+
*/
|
1403
|
+
createLoadingMask(loadingMessage) {
|
1404
|
+
return {
|
1405
|
+
cls: ['neo-load-mask'],
|
1406
|
+
cn : [{
|
1407
|
+
cls: ['neo-load-mask-body'],
|
1408
|
+
cn : [{
|
1409
|
+
cls: this.loadingSpinnerCls
|
1410
|
+
}, {
|
1411
|
+
cls : ['neo-loading-message'],
|
1412
|
+
html : loadingMessage,
|
1413
|
+
removeDom: !Neo.isString(loadingMessage)
|
1414
|
+
}]
|
1415
|
+
}]
|
1416
|
+
}
|
1417
|
+
}
|
1418
|
+
|
1406
1419
|
/**
|
1407
1420
|
* Creates the tooltip instances
|
1408
1421
|
* @param {Object|String} value
|
@@ -1455,9 +1468,9 @@ class Base extends CoreBase {
|
|
1455
1468
|
* todo: unregister events
|
1456
1469
|
*/
|
1457
1470
|
destroy(updateParentVdom=false, silent=false) {
|
1458
|
-
let me
|
1459
|
-
{parent, parentId}
|
1460
|
-
|
1471
|
+
let me = this,
|
1472
|
+
{parent, parentId} = me,
|
1473
|
+
parentStateProvider = parent?.getStateProvider(),
|
1461
1474
|
parentVdom;
|
1462
1475
|
|
1463
1476
|
me.revertFocus();
|
@@ -1468,9 +1481,9 @@ class Base extends CoreBase {
|
|
1468
1481
|
|
1469
1482
|
me.reference && me.getController()?.removeReference(me); // remove own reference from parent controllers
|
1470
1483
|
|
1471
|
-
me.
|
1484
|
+
me.stateProvider = null; // triggers destroy()
|
1472
1485
|
|
1473
|
-
me.bind &&
|
1486
|
+
me.bind && parentStateProvider?.removeBindings(me.id);
|
1474
1487
|
|
1475
1488
|
me.plugins?.forEach(plugin => {
|
1476
1489
|
plugin.destroy()
|
@@ -1600,7 +1613,7 @@ class Base extends CoreBase {
|
|
1600
1613
|
/**
|
1601
1614
|
* Find an instance stored inside a config via optionally passing a ntype.
|
1602
1615
|
* Returns this[configName] or the closest parent component with a match.
|
1603
|
-
* Used by getController() &
|
1616
|
+
* Used by getController() & getStateProvider()
|
1604
1617
|
* @param {String} configName
|
1605
1618
|
* @param {String} [ntype]
|
1606
1619
|
* @returns {Neo.core.Base|null}
|
@@ -1667,36 +1680,6 @@ class Base extends CoreBase {
|
|
1667
1680
|
return Rectangle.clone(result)
|
1668
1681
|
}
|
1669
1682
|
|
1670
|
-
/**
|
1671
|
-
* Returns this.model or the closest parent model
|
1672
|
-
* @param {String} [ntype]
|
1673
|
-
* @returns {Neo.model.Component|null}
|
1674
|
-
*/
|
1675
|
-
getModel(ntype) {
|
1676
|
-
if (!Neo.currentWorker.isUsingViewModels) {
|
1677
|
-
return null
|
1678
|
-
}
|
1679
|
-
|
1680
|
-
let me = this,
|
1681
|
-
model;
|
1682
|
-
|
1683
|
-
if (!ntype) {
|
1684
|
-
model = me[closestModel];
|
1685
|
-
|
1686
|
-
if (model) {
|
1687
|
-
return model
|
1688
|
-
}
|
1689
|
-
}
|
1690
|
-
|
1691
|
-
model = me.getConfigInstanceByNtype('model', ntype);
|
1692
|
-
|
1693
|
-
if (!ntype) {
|
1694
|
-
me[closestModel] = model
|
1695
|
-
}
|
1696
|
-
|
1697
|
-
return model
|
1698
|
-
}
|
1699
|
-
|
1700
1683
|
/**
|
1701
1684
|
* Honors different item roots for mount / render OPs
|
1702
1685
|
* @returns {String}
|
@@ -1785,6 +1768,45 @@ class Base extends CoreBase {
|
|
1785
1768
|
return this.down({reference: value})
|
1786
1769
|
}
|
1787
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
|
+
|
1788
1810
|
/**
|
1789
1811
|
* Walks up the vdom tree and returns the closest theme found
|
1790
1812
|
* @returns {String}
|
@@ -1869,6 +1891,7 @@ class Base extends CoreBase {
|
|
1869
1891
|
let removeFn = function () {
|
1870
1892
|
if (me.parentId !== 'document.body') {
|
1871
1893
|
me.vdom.removeDom = true;
|
1894
|
+
me.parent.updateDepth = 2;
|
1872
1895
|
me.parent.update()
|
1873
1896
|
} else {
|
1874
1897
|
me.unmount()
|
@@ -1897,7 +1920,7 @@ class Base extends CoreBase {
|
|
1897
1920
|
}
|
1898
1921
|
|
1899
1922
|
/**
|
1900
|
-
* 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
|
1901
1924
|
* @param {Object} config
|
1902
1925
|
* @param {Boolean} [preventOriginalConfig] True prevents the instance from getting an originalConfig property
|
1903
1926
|
*/
|
@@ -1906,8 +1929,8 @@ class Base extends CoreBase {
|
|
1906
1929
|
|
1907
1930
|
let me = this;
|
1908
1931
|
|
1909
|
-
me.getController()?.parseConfig(me);
|
1910
|
-
me.
|
1932
|
+
me.getController() ?.parseConfig(me);
|
1933
|
+
me.getStateProvider()?.parseConfig(me)
|
1911
1934
|
}
|
1912
1935
|
|
1913
1936
|
/**
|
@@ -1918,7 +1941,7 @@ class Base extends CoreBase {
|
|
1918
1941
|
* @param {Number} distance=1 Distance inside the component tree
|
1919
1942
|
* @returns {Boolean}
|
1920
1943
|
*/
|
1921
|
-
|
1944
|
+
isParentUpdating(parentId=this.parentId, resolve, distance=1) {
|
1922
1945
|
if (parentId !== 'document.body') {
|
1923
1946
|
let me = this,
|
1924
1947
|
parent = Neo.getComponent(parentId);
|
@@ -1940,9 +1963,9 @@ class Base extends CoreBase {
|
|
1940
1963
|
|
1941
1964
|
// If an update is running and does not have a collision, we do not need to check further parents
|
1942
1965
|
return false
|
1943
|
-
} else {
|
1944
|
-
return me.isParentVdomUpdating(parent.parentId, resolve, distance+1)
|
1945
1966
|
}
|
1967
|
+
|
1968
|
+
return me.isParentUpdating(parent.parentId, resolve, distance+1)
|
1946
1969
|
}
|
1947
1970
|
}
|
1948
1971
|
|
@@ -2053,22 +2076,24 @@ class Base extends CoreBase {
|
|
2053
2076
|
* Checks the needsVdomUpdate config inside the parent tree
|
2054
2077
|
* @param {String} parentId=this.parentId
|
2055
2078
|
* @param {Function} [resolve] gets passed by updateVdom()
|
2079
|
+
* @param {Number} distance=1 Distance inside the component tree
|
2056
2080
|
* @returns {Boolean}
|
2057
2081
|
*/
|
2058
|
-
needsParentUpdate(parentId=this.parentId, resolve) {
|
2082
|
+
needsParentUpdate(parentId=this.parentId, resolve, distance=1) {
|
2059
2083
|
if (parentId !== 'document.body') {
|
2060
2084
|
let me = this,
|
2061
2085
|
parent = Neo.getComponent(parentId);
|
2062
2086
|
|
2063
2087
|
if (parent) {
|
2064
|
-
|
2088
|
+
// We are checking for parent.updateDepth, since we care about the depth of the next update cycle
|
2089
|
+
if (parent.needsVdomUpdate && me.hasUpdateCollision(parent.updateDepth, distance)) {
|
2065
2090
|
parent.resolveUpdateCache.push(...me.resolveUpdateCache);
|
2066
2091
|
resolve && parent.resolveUpdateCache.push(resolve);
|
2067
2092
|
me.resolveUpdateCache = [];
|
2068
2093
|
return true
|
2069
|
-
} else {
|
2070
|
-
return me.needsParentUpdate(parent.parentId)
|
2071
2094
|
}
|
2095
|
+
|
2096
|
+
return me.needsParentUpdate(parent.parentId, resolve, distance+1)
|
2072
2097
|
}
|
2073
2098
|
}
|
2074
2099
|
|
@@ -2179,7 +2204,7 @@ class Base extends CoreBase {
|
|
2179
2204
|
* @param {Neo.vdom.VNode} vnode= this.vnode
|
2180
2205
|
* @returns {Promise<any>}
|
2181
2206
|
*/
|
2182
|
-
promiseUpdate(vdom
|
2207
|
+
promiseUpdate(vdom=this.vdom, vnode=this.vnode) {
|
2183
2208
|
return new Promise((resolve, reject) => {
|
2184
2209
|
this.updateVdom(vdom, vnode, resolve, reject)
|
2185
2210
|
})
|
@@ -2366,6 +2391,14 @@ class Base extends CoreBase {
|
|
2366
2391
|
return this.set(values, true)
|
2367
2392
|
}
|
2368
2393
|
|
2394
|
+
/**
|
2395
|
+
* Convenience shortcut
|
2396
|
+
* @param args
|
2397
|
+
*/
|
2398
|
+
setState(...args) {
|
2399
|
+
this.getStateProvider().setData(...args)
|
2400
|
+
}
|
2401
|
+
|
2369
2402
|
/**
|
2370
2403
|
* Show the component.
|
2371
2404
|
* hideMode: 'removeDom' uses vdom removeDom.
|
@@ -2380,6 +2413,7 @@ class Base extends CoreBase {
|
|
2380
2413
|
if (me.silentVdomUpdate) {
|
2381
2414
|
me.needsVdomUpdate = true
|
2382
2415
|
} else if (me.parentId !== 'document.body') {
|
2416
|
+
me.parent.updateDepth = 2;
|
2383
2417
|
me.parent.update()
|
2384
2418
|
} else {
|
2385
2419
|
!me.mounted && me.render(true)
|
@@ -2429,7 +2463,7 @@ class Base extends CoreBase {
|
|
2429
2463
|
|
2430
2464
|
// we need one separate iteration first to ensure all wrapper nodes get registered
|
2431
2465
|
childComponents.forEach(component => {
|
2432
|
-
childVnode = VNodeUtil.
|
2466
|
+
childVnode = VNodeUtil.find(me.vnode, component.vdom.id)?.vnode;
|
2433
2467
|
|
2434
2468
|
if (childVnode) {
|
2435
2469
|
map[component.id] = childVnode;
|
@@ -2517,7 +2551,7 @@ class Base extends CoreBase {
|
|
2517
2551
|
updateCls(cls, oldCls, id=this.id) {
|
2518
2552
|
let me = this,
|
2519
2553
|
{vnode} = me,
|
2520
|
-
vnodeTarget = vnode && VNodeUtil.
|
2554
|
+
vnodeTarget = vnode && VNodeUtil.find(me.vnode, {id})?.vnode;
|
2521
2555
|
|
2522
2556
|
if (vnode && !Neo.isEqual(cls, oldCls)) {
|
2523
2557
|
if (vnodeTarget) {
|
@@ -2549,7 +2583,7 @@ class Base extends CoreBase {
|
|
2549
2583
|
|
2550
2584
|
if (delta) {
|
2551
2585
|
vdom = VDomUtil.find(me.vdom, id);
|
2552
|
-
vnode = me.vnode && VNodeUtil.
|
2586
|
+
vnode = me.vnode && VNodeUtil.find(me.vnode, id);
|
2553
2587
|
|
2554
2588
|
if (!me.hasUnmountedVdomChanges) {
|
2555
2589
|
me.hasUnmountedVdomChanges = !me.mounted && me.hasBeenMounted
|
@@ -2600,24 +2634,8 @@ class Base extends CoreBase {
|
|
2600
2634
|
{app, mounted, parentId} = me,
|
2601
2635
|
listenerId;
|
2602
2636
|
|
2603
|
-
// It is important to keep the vdom tree stable to ensure that containers do not lose the references to their
|
2604
|
-
// child vdom trees. The if case should not happen, but in case it does, keeping the reference and merging
|
2605
|
-
// the content over seems to be the best strategy
|
2606
|
-
if (me._vdom !== vdom) {
|
2607
|
-
Logger.warn('vdom got replaced for: ' + me.id + '. Copying the content into the reference holder object');
|
2608
|
-
|
2609
|
-
Object.keys(me._vdom).forEach(key => {
|
2610
|
-
delete me._vdom[key]
|
2611
|
-
});
|
2612
|
-
|
2613
|
-
vdom = Object.assign(me._vdom, vdom)
|
2614
|
-
}
|
2615
|
-
|
2616
|
-
if (resolve && me.isVdomUpdating) {
|
2617
|
-
me.resolveUpdateCache.push(resolve)
|
2618
|
-
}
|
2619
|
-
|
2620
2637
|
if (me.isVdomUpdating || me.silentVdomUpdate) {
|
2638
|
+
resolve && me.resolveUpdateCache.push(resolve);
|
2621
2639
|
me.needsVdomUpdate = true
|
2622
2640
|
} else {
|
2623
2641
|
if (!mounted && me.isConstructed && !me.hasRenderingListener && app?.rendering === true) {
|
@@ -2637,7 +2655,7 @@ class Base extends CoreBase {
|
|
2637
2655
|
|
2638
2656
|
if (
|
2639
2657
|
!me.needsParentUpdate(parentId, resolve)
|
2640
|
-
&& !me.
|
2658
|
+
&& !me.isParentUpdating(parentId, resolve)
|
2641
2659
|
&& mounted
|
2642
2660
|
&& vnode
|
2643
2661
|
) {
|
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
|
|
@@ -500,7 +500,7 @@ class Base extends Component {
|
|
500
500
|
/**
|
501
501
|
* Inserts an item or array of items at a specific index
|
502
502
|
* @param {Number} index
|
503
|
-
* @param {Object
|
503
|
+
* @param {Array|Object} item
|
504
504
|
* @param {Boolean} [silent=false]
|
505
505
|
* @returns {Neo.component.Base|Neo.component.Base[]}
|
506
506
|
*/
|
@@ -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);
|