neo.mjs 4.3.0 → 4.3.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/website/view/MainContainer.mjs +1 -0
- package/apps/website/view/MainContainerController.mjs +7 -0
- package/apps/website/view/blog/List.mjs +41 -3
- package/apps/website/view/examples/List.mjs +28 -3
- package/apps/website/view/examples/TabContainer.mjs +7 -4
- package/apps/website/view/home/DeveloperIntroComponent.mjs +227 -225
- package/apps/website/view/home/ExecutiveIntroComponent.mjs +242 -240
- package/buildScripts/addConfig.mjs +1 -0
- package/examples/tab/container/MainContainer.mjs +78 -5
- package/package.json +1 -1
- package/resources/scss/src/apps/website/blog/List.scss +2 -2
- package/resources/scss/src/apps/website/examples/List.scss +2 -2
- package/resources/scss/src/apps/website/home/TabContainer.scss +6 -1
- package/resources/scss/src/button/Base.scss +10 -8
- package/resources/scss/src/calendar/view/calendars/ColorsList.scss +5 -2
- package/resources/scss/src/component/Label.scss +2 -1
- package/resources/scss/src/form/field/Radio.scss +6 -4
- package/resources/scss/src/form/field/Text.scss +4 -3
- package/resources/scss/src/layout/Card.scss +6 -10
- package/resources/scss/src/list/Base.scss +11 -3
- package/resources/scss/src/tab/Container.scss +2 -1
- package/resources/scss/src/tab/header/Toolbar.scss +1 -1
- package/resources/scss/src/table/Container.scss +3 -1
- package/resources/scss/src/toolbar/Base.scss +69 -3
- package/resources/scss/src/tree/List.scss +11 -1
- package/resources/scss/theme-dark/button/Base.scss +4 -0
- package/resources/scss/theme-light/button/Base.scss +4 -0
- package/src/calendar/view/calendars/ColorsList.mjs +18 -0
- package/src/calendar/view/calendars/EditContainer.mjs +7 -9
- package/src/component/Base.mjs +184 -114
- package/src/container/Base.mjs +3 -3
- package/src/draggable/toolbar/DragZone.mjs +5 -6
- package/src/form/field/Text.mjs +3 -1
- package/src/layout/Base.mjs +5 -7
- package/src/layout/Card.mjs +32 -35
- package/src/layout/Fit.mjs +11 -11
- package/src/layout/Flexbox.mjs +32 -40
- package/src/layout/HBox.mjs +1 -1
- package/src/layout/VBox.mjs +1 -1
- package/src/list/Base.mjs +27 -5
- package/src/tab/Container.mjs +11 -11
- package/src/tab/header/Button.mjs +2 -2
- package/src/table/Container.mjs +11 -3
- package/src/tree/List.mjs +4 -0
package/src/component/Base.mjs
CHANGED
@@ -75,6 +75,11 @@ class Base extends CoreBase {
|
|
75
75
|
* @member {Object|null} bind=null
|
76
76
|
*/
|
77
77
|
bind: null,
|
78
|
+
/**
|
79
|
+
* CSS selectors to apply to the root level node of this component
|
80
|
+
* @member {String[]} cls_=null
|
81
|
+
*/
|
82
|
+
cls_: null,
|
78
83
|
/**
|
79
84
|
* manager.Focus will change this flag on focusin & out dom events
|
80
85
|
* @member {Boolean} containsFocus_=false
|
@@ -250,10 +255,10 @@ class Base extends CoreBase {
|
|
250
255
|
*/
|
251
256
|
silentVdomUpdate: false,
|
252
257
|
/**
|
253
|
-
*
|
254
|
-
* @member {Object}
|
258
|
+
* Style attributes added to this vdom root. see: getVdomRoot()
|
259
|
+
* @member {Object} style_=null
|
255
260
|
*/
|
256
|
-
|
261
|
+
style_: null,
|
257
262
|
/**
|
258
263
|
* Add tooltip config objects
|
259
264
|
* See tooltip/Base.mjs
|
@@ -271,6 +276,10 @@ class Base extends CoreBase {
|
|
271
276
|
* @member {Number|String|null} width_=null
|
272
277
|
*/
|
273
278
|
width_: null,
|
279
|
+
/**
|
280
|
+
* @member {String[]|null} wrapperCls_=null
|
281
|
+
*/
|
282
|
+
wrapperCls_: null,
|
274
283
|
/**
|
275
284
|
* Top level style attributes. Useful in case getVdomRoot() does not point to the top level DOM node.
|
276
285
|
* @member {Object|null} wrapperStyle_=null
|
@@ -283,44 +292,6 @@ class Base extends CoreBase {
|
|
283
292
|
_vdom: {}
|
284
293
|
}}
|
285
294
|
|
286
|
-
/**
|
287
|
-
* CSS selectors to apply to the top level node of this component
|
288
|
-
* @member {String[]} cls=[]
|
289
|
-
*/
|
290
|
-
get cls() {
|
291
|
-
return this._cls ? Neo.clone(this._cls) : [];
|
292
|
-
}
|
293
|
-
set cls(value) {
|
294
|
-
value = value ? value : [];
|
295
|
-
|
296
|
-
let me = this,
|
297
|
-
vdom = me.vdom,
|
298
|
-
vdomRoot = me.getVdomRoot(),
|
299
|
-
oldCls;
|
300
|
-
|
301
|
-
if (typeof value === 'string') {
|
302
|
-
value = value.split('');
|
303
|
-
}
|
304
|
-
|
305
|
-
if (me.mounted) {
|
306
|
-
oldCls = Neo.clone(me._cls);
|
307
|
-
}
|
308
|
-
|
309
|
-
me._cls = value;
|
310
|
-
|
311
|
-
if (vdomRoot) {
|
312
|
-
vdomRoot.cls = [...value];
|
313
|
-
}
|
314
|
-
|
315
|
-
me._vdom = vdom; // silent update
|
316
|
-
|
317
|
-
if (me.silentVdomUpdate) {
|
318
|
-
me.needsVdomUpdate = true;
|
319
|
-
} else if (me.mounted) {
|
320
|
-
me.updateCls(value, oldCls);
|
321
|
-
}
|
322
|
-
}
|
323
|
-
|
324
295
|
/**
|
325
296
|
* Apply component based listeners
|
326
297
|
* @member {Object} listeners={}
|
@@ -350,23 +321,6 @@ class Base extends CoreBase {
|
|
350
321
|
}
|
351
322
|
}
|
352
323
|
|
353
|
-
/**
|
354
|
-
* Top level style attributes
|
355
|
-
* @member {Object} style={}
|
356
|
-
*/
|
357
|
-
get style() {
|
358
|
-
// we need to "clone" the object, otherwise changes will get applied directly and there are no deltas
|
359
|
-
// this only affects non vdom related style to DOM deltas
|
360
|
-
return Neo.clone(this._style || {});
|
361
|
-
}
|
362
|
-
set style(value) {
|
363
|
-
let me = this,
|
364
|
-
oldStyle = me.style; // cloned => getter
|
365
|
-
|
366
|
-
me._style = value;
|
367
|
-
me.updateStyle(value, oldStyle);
|
368
|
-
}
|
369
|
-
|
370
324
|
/**
|
371
325
|
* The setter will handle vdom updates automatically
|
372
326
|
* @member {Object} vdom=this._vdom
|
@@ -375,50 +329,7 @@ class Base extends CoreBase {
|
|
375
329
|
return this._vdom;
|
376
330
|
}
|
377
331
|
set vdom(value) {
|
378
|
-
|
379
|
-
app = Neo.apps[me.appName],
|
380
|
-
vdom = value,
|
381
|
-
vdomRoot = me.getVdomRoot(),
|
382
|
-
listenerId;
|
383
|
-
|
384
|
-
if (vdomRoot && me.cls) {
|
385
|
-
vdomRoot.cls = me.cls;
|
386
|
-
}
|
387
|
-
|
388
|
-
// It is important to keep the vdom tree stable to ensure that containers do not lose the references to their
|
389
|
-
// child vdom trees. The if case should not happen, but in case it does, keeping the reference and merging
|
390
|
-
// the content over seems to be the best strategy
|
391
|
-
if (me._vdom !== vdom) {
|
392
|
-
Logger.warn('vdom got replaced for: ' + me.id + '. Copying the content into the reference holder object');
|
393
|
-
|
394
|
-
Object.keys(me._vdom).forEach(key => {
|
395
|
-
delete me._vdom[key];
|
396
|
-
});
|
397
|
-
|
398
|
-
Object.assign(me._vdom, vdom);
|
399
|
-
} else {
|
400
|
-
me._vdom = vdom;
|
401
|
-
}
|
402
|
-
|
403
|
-
if (me.silentVdomUpdate) {
|
404
|
-
me.needsVdomUpdate = true;
|
405
|
-
} else {
|
406
|
-
if (!me.mounted && me.isConstructed && !me.hasRenderingListener && app?.rendering === true) {
|
407
|
-
me.hasRenderingListener = true;
|
408
|
-
|
409
|
-
listenerId = app.on('mounted', () => {
|
410
|
-
app.un('mounted', listenerId);
|
411
|
-
|
412
|
-
setTimeout(() => {
|
413
|
-
me.vnode && me.updateVdom(me.vdom, me.vnode);
|
414
|
-
}, 50);
|
415
|
-
});
|
416
|
-
} else if (me.mounted) {
|
417
|
-
me.vnode && me.updateVdom(vdom, me.vnode);
|
418
|
-
}
|
419
|
-
|
420
|
-
me.hasUnmountedVdomChanges = !me.mounted && me.hasBeenMounted;
|
421
|
-
}
|
332
|
+
this.afterSetVdom(value, value);
|
422
333
|
}
|
423
334
|
|
424
335
|
/**
|
@@ -474,6 +385,38 @@ class Base extends CoreBase {
|
|
474
385
|
value && Neo.currentWorker.insertThemeFiles(value, this.__proto__);
|
475
386
|
}
|
476
387
|
|
388
|
+
/**
|
389
|
+
* Triggered after the cls config got changed
|
390
|
+
* @param {String[]|null} value
|
391
|
+
* @param {String[]|null} oldValue
|
392
|
+
* @protected
|
393
|
+
*/
|
394
|
+
afterSetCls(value, oldValue) {
|
395
|
+
oldValue = oldValue ? oldValue : [];
|
396
|
+
value = value ? value : [];
|
397
|
+
|
398
|
+
let me = this,
|
399
|
+
vdom = me.vdom,
|
400
|
+
vdomRoot = me.getVdomRoot(),
|
401
|
+
cls;
|
402
|
+
|
403
|
+
if (vdom !== vdomRoot) {
|
404
|
+
// we are using a wrapper node
|
405
|
+
vdomRoot.cls = [...value];
|
406
|
+
} else {
|
407
|
+
// we need to merge changes
|
408
|
+
cls = [...me.wrapperCls, ...value];
|
409
|
+
NeoArray.remove(cls, NeoArray.difference(oldValue, value));
|
410
|
+
vdom.cls = cls;
|
411
|
+
}
|
412
|
+
|
413
|
+
if (me.isVdomUpdating || me.silentVdomUpdate) {
|
414
|
+
me.needsVdomUpdate = true;
|
415
|
+
} else if (me.mounted) {
|
416
|
+
me.updateCls(value, oldValue, vdomRoot.id);
|
417
|
+
}
|
418
|
+
}
|
419
|
+
|
477
420
|
/**
|
478
421
|
* Triggered after any config got changed
|
479
422
|
* @param {String} key
|
@@ -667,6 +610,18 @@ class Base extends CoreBase {
|
|
667
610
|
}
|
668
611
|
}
|
669
612
|
|
613
|
+
/**
|
614
|
+
* Triggered after the style config got changed
|
615
|
+
* @param {Object} value
|
616
|
+
* @param {Object} oldValue
|
617
|
+
* @protected
|
618
|
+
*/
|
619
|
+
afterSetStyle(value, oldValue) {
|
620
|
+
if (!(!value && oldValue === undefined)) {
|
621
|
+
this.updateStyle(value, oldValue);
|
622
|
+
}
|
623
|
+
}
|
624
|
+
|
670
625
|
/**
|
671
626
|
* Triggered after the tooltips config got changed
|
672
627
|
* @param {Boolean} value
|
@@ -687,6 +642,54 @@ class Base extends CoreBase {
|
|
687
642
|
}
|
688
643
|
}
|
689
644
|
|
645
|
+
/**
|
646
|
+
* Triggered after the vdom config got changed
|
647
|
+
* @param {Object} value
|
648
|
+
* @param {Object|null} oldValue
|
649
|
+
* @protected
|
650
|
+
*/
|
651
|
+
afterSetVdom(value, oldValue) {
|
652
|
+
let me = this,
|
653
|
+
app = Neo.apps[me.appName],
|
654
|
+
vdom = value,
|
655
|
+
listenerId;
|
656
|
+
|
657
|
+
// It is important to keep the vdom tree stable to ensure that containers do not lose the references to their
|
658
|
+
// child vdom trees. The if case should not happen, but in case it does, keeping the reference and merging
|
659
|
+
// the content over seems to be the best strategy
|
660
|
+
if (me._vdom !== vdom) {
|
661
|
+
Logger.warn('vdom got replaced for: ' + me.id + '. Copying the content into the reference holder object');
|
662
|
+
|
663
|
+
Object.keys(me._vdom).forEach(key => {
|
664
|
+
delete me._vdom[key];
|
665
|
+
});
|
666
|
+
|
667
|
+
Object.assign(me._vdom, vdom);
|
668
|
+
} else {
|
669
|
+
me._vdom = vdom;
|
670
|
+
}
|
671
|
+
|
672
|
+
if (me.silentVdomUpdate) {
|
673
|
+
me.needsVdomUpdate = true;
|
674
|
+
} else {
|
675
|
+
if (!me.mounted && me.isConstructed && !me.hasRenderingListener && app?.rendering === true) {
|
676
|
+
me.hasRenderingListener = true;
|
677
|
+
|
678
|
+
listenerId = app.on('mounted', () => {
|
679
|
+
app.un('mounted', listenerId);
|
680
|
+
|
681
|
+
setTimeout(() => {
|
682
|
+
me.vnode && me.updateVdom(me.vdom, me.vnode);
|
683
|
+
}, 50);
|
684
|
+
});
|
685
|
+
} else if (me.mounted) {
|
686
|
+
me.vnode && me.updateVdom(vdom, me.vnode);
|
687
|
+
}
|
688
|
+
|
689
|
+
me.hasUnmountedVdomChanges = !me.mounted && me.hasBeenMounted;
|
690
|
+
}
|
691
|
+
}
|
692
|
+
|
690
693
|
/**
|
691
694
|
* Triggered after the vnode config got changed
|
692
695
|
* @param {Object} value
|
@@ -709,6 +712,46 @@ class Base extends CoreBase {
|
|
709
712
|
this.changeVdomRootKey('width', value);
|
710
713
|
}
|
711
714
|
|
715
|
+
/**
|
716
|
+
* Triggered after the wrapperCls config got changed
|
717
|
+
* @param {String[]|null} value
|
718
|
+
* @param {String[]|null} oldValue
|
719
|
+
* @protected
|
720
|
+
*/
|
721
|
+
afterSetWrapperCls(value, oldValue) {
|
722
|
+
oldValue = oldValue ? oldValue : [];
|
723
|
+
value = value ? value : [];
|
724
|
+
|
725
|
+
let me = this,
|
726
|
+
vdom = me.vdom,
|
727
|
+
vdomRoot = me.getVdomRoot(),
|
728
|
+
cls = me.vdom?.cls || [];
|
729
|
+
|
730
|
+
if (vdom === vdomRoot) {
|
731
|
+
// we need to merge changes
|
732
|
+
cls = [...cls, ...value];
|
733
|
+
NeoArray.remove(cls, NeoArray.difference(oldValue, value));
|
734
|
+
vdom.cls = cls;
|
735
|
+
|
736
|
+
} else {
|
737
|
+
// we are not using a wrapper => cls & wrapperCls share the same node
|
738
|
+
value = value ? value : [];
|
739
|
+
|
740
|
+
oldValue && NeoArray.remove(cls, oldValue);
|
741
|
+
NeoArray.add(cls, value);
|
742
|
+
|
743
|
+
if (vdom) {
|
744
|
+
vdom.cls = cls;
|
745
|
+
}
|
746
|
+
}
|
747
|
+
|
748
|
+
if (me.isVdomUpdating || me.silentVdomUpdate) {
|
749
|
+
me.needsVdomUpdate = true;
|
750
|
+
} else if (me.mounted) {
|
751
|
+
me.updateCls(value, oldValue);
|
752
|
+
}
|
753
|
+
}
|
754
|
+
|
712
755
|
/**
|
713
756
|
* Triggered after the wrapperStyle config got changed
|
714
757
|
* @param {Object} value
|
@@ -729,6 +772,15 @@ class Base extends CoreBase {
|
|
729
772
|
}
|
730
773
|
}
|
731
774
|
|
775
|
+
/**
|
776
|
+
* Triggered when accessing the cls config
|
777
|
+
* @param {String[]|null} value
|
778
|
+
* @protected
|
779
|
+
*/
|
780
|
+
beforeGetCls(value) {
|
781
|
+
return value ? [...value]: [];
|
782
|
+
}
|
783
|
+
|
732
784
|
/**
|
733
785
|
* Triggered when accessing the data config
|
734
786
|
* Convenience shortcut which is expensive to use,
|
@@ -740,6 +792,24 @@ class Base extends CoreBase {
|
|
740
792
|
return this.getModel().getHierarchyData();
|
741
793
|
}
|
742
794
|
|
795
|
+
/**
|
796
|
+
* Triggered when accessing the style config
|
797
|
+
* @param {Object} value
|
798
|
+
* @protected
|
799
|
+
*/
|
800
|
+
beforeGetStyle(value) {
|
801
|
+
return {...value};
|
802
|
+
}
|
803
|
+
|
804
|
+
/**
|
805
|
+
* Triggered when accessing the wrapperCls config
|
806
|
+
* @param {String[]|null} value
|
807
|
+
* @protected
|
808
|
+
*/
|
809
|
+
beforeGetWrapperCls(value) {
|
810
|
+
return value ? [...value]: [];
|
811
|
+
}
|
812
|
+
|
743
813
|
/**
|
744
814
|
* Triggered when accessing the wrapperStyle config
|
745
815
|
* @param {Object} value
|
@@ -1198,13 +1268,11 @@ class Base extends CoreBase {
|
|
1198
1268
|
// avoid any interference on prototype level
|
1199
1269
|
// does not clone existing Neo instances
|
1200
1270
|
me._vdom = Neo.clone(vdom, true, true);
|
1201
|
-
me.cls = config.cls;
|
1202
1271
|
|
1203
1272
|
me[Neo.isEmpty(config.style) ? '_style' : 'style'] = config.style;
|
1204
1273
|
|
1205
1274
|
me.wrapperStyle = Neo.clone(config.wrapperStyle, false);
|
1206
1275
|
|
1207
|
-
delete config.cls;
|
1208
1276
|
delete config.style;
|
1209
1277
|
delete config._vdom;
|
1210
1278
|
delete config.vdom;
|
@@ -1648,28 +1716,30 @@ class Base extends CoreBase {
|
|
1648
1716
|
|
1649
1717
|
/**
|
1650
1718
|
* Delta updates for the cls config. Gets called after the cls config gets changed in case the component is mounted.
|
1651
|
-
* @param {
|
1652
|
-
* @param {
|
1719
|
+
* @param {String[]} cls
|
1720
|
+
* @param {String[]} oldCls
|
1721
|
+
* @param {String} id=this.id
|
1653
1722
|
* @protected
|
1654
1723
|
*/
|
1655
|
-
updateCls(cls, oldCls) {
|
1656
|
-
let me
|
1657
|
-
vnode
|
1724
|
+
updateCls(cls, oldCls, id=this.id) {
|
1725
|
+
let me = this,
|
1726
|
+
vnode = me.vnode,
|
1727
|
+
vnodeTarget = VNodeUtil.findChildVnode(me.vnode, {id})?.vnode,
|
1658
1728
|
opts;
|
1659
1729
|
|
1660
1730
|
if (!Neo.isEqual(cls, oldCls)) {
|
1661
|
-
if (
|
1662
|
-
|
1731
|
+
if (vnodeTarget) {
|
1732
|
+
vnodeTarget.className = cls; // keep the vnode in sync
|
1663
1733
|
me.vnode = vnode;
|
1664
1734
|
}
|
1665
1735
|
|
1666
1736
|
opts = {
|
1667
1737
|
action: 'updateDom',
|
1668
1738
|
deltas: [{
|
1669
|
-
id
|
1739
|
+
id,
|
1670
1740
|
cls: {
|
1671
|
-
add :
|
1672
|
-
remove:
|
1741
|
+
add : NeoArray.difference(cls, oldCls),
|
1742
|
+
remove: NeoArray.difference(oldCls, cls)
|
1673
1743
|
}
|
1674
1744
|
}]
|
1675
1745
|
};
|
package/src/container/Base.mjs
CHANGED
@@ -171,10 +171,11 @@ class Base extends Component {
|
|
171
171
|
|
172
172
|
/**
|
173
173
|
* @param {Object|String} value
|
174
|
+
* @param {Object|String|Neo.layout.Base} oldValue
|
174
175
|
* @returns {Neo.layout.Base}
|
175
176
|
* @protected
|
176
177
|
*/
|
177
|
-
beforeSetLayout(value) {
|
178
|
+
beforeSetLayout(value, oldValue) {
|
178
179
|
return this.createLayout(value);
|
179
180
|
}
|
180
181
|
|
@@ -458,8 +459,7 @@ class Base extends Component {
|
|
458
459
|
if (config.ntype.indexOf('layout-') < 0) {
|
459
460
|
config.ntype = 'layout-' + config.ntype;
|
460
461
|
}
|
461
|
-
}
|
462
|
-
else if (config.indexOf('layout-') < 0) {
|
462
|
+
} else if (config.indexOf('layout-') < 0) {
|
463
463
|
config = {
|
464
464
|
ntype: 'layout-' + config
|
465
465
|
};
|
@@ -47,15 +47,14 @@ class DragZone extends BaseDragZone {
|
|
47
47
|
adjustToolbarItemCls(draggable) {
|
48
48
|
let me = this,
|
49
49
|
owner = me.owner,
|
50
|
-
|
50
|
+
wrapperCls;
|
51
51
|
|
52
|
-
|
53
|
-
|
52
|
+
owner.items.forEach(item => {
|
53
|
+
wrapperCls = item.wrapperCls || [];
|
54
54
|
|
55
|
-
NeoArray[draggable ? 'add' : 'remove'](
|
55
|
+
NeoArray[draggable ? 'add' : 'remove'](wrapperCls, 'neo-draggable');
|
56
|
+
item.wrapperCls = wrapperCls;
|
56
57
|
});
|
57
|
-
|
58
|
-
owner.vdom = vdom;
|
59
58
|
}
|
60
59
|
|
61
60
|
/**
|
package/src/form/field/Text.mjs
CHANGED
@@ -893,11 +893,13 @@ class Text extends Base {
|
|
893
893
|
onFocusLeave(data) {
|
894
894
|
let me = this,
|
895
895
|
centerBorderEl = me.getCenterBorderEl(), // labelPosition: 'inline'
|
896
|
+
cls = me.cls,
|
896
897
|
vdom = me.vdom;
|
897
898
|
|
898
899
|
me.validate(); // silent
|
899
900
|
|
900
|
-
NeoArray.remove(
|
901
|
+
NeoArray.remove(cls, 'neo-focus');
|
902
|
+
me.cls = cls;
|
901
903
|
|
902
904
|
if (centerBorderEl && me.isEmpty()) {
|
903
905
|
delete centerBorderEl.width;
|
package/src/layout/Base.mjs
CHANGED
@@ -44,33 +44,31 @@ class Base extends CoreBase {
|
|
44
44
|
* @protected
|
45
45
|
*/
|
46
46
|
afterSetAppName(value, oldValue) {
|
47
|
-
|
48
|
-
Neo.currentWorker.insertThemeFiles(value, this.__proto__);
|
49
|
-
}
|
47
|
+
value && Neo.currentWorker.insertThemeFiles(value, this.__proto__);
|
50
48
|
}
|
51
49
|
|
52
50
|
/**
|
53
|
-
* Placeholder
|
51
|
+
* Placeholder method
|
54
52
|
* @param {Neo.component.Base} item
|
55
53
|
* @protected
|
56
54
|
*/
|
57
55
|
applyChildAttributes(item) {}
|
58
56
|
|
59
57
|
/**
|
60
|
-
* Placeholder
|
58
|
+
* Placeholder method
|
61
59
|
* @protected
|
62
60
|
*/
|
63
61
|
applyRenderAttributes() {}
|
64
62
|
|
65
63
|
/**
|
66
|
-
* Placeholder
|
64
|
+
* Placeholder method
|
67
65
|
* @param {Neo.component.Base} item
|
68
66
|
* @protected
|
69
67
|
*/
|
70
68
|
removeChildAttributes(item) {}
|
71
69
|
|
72
70
|
/**
|
73
|
-
* Placeholder
|
71
|
+
* Placeholder method
|
74
72
|
* @protected
|
75
73
|
*/
|
76
74
|
removeRenderAttributes() {}
|
package/src/layout/Card.mjs
CHANGED
@@ -9,16 +9,16 @@ class Card extends Base {
|
|
9
9
|
static getStaticConfig() {return {
|
10
10
|
/*
|
11
11
|
* The name of the CSS class for an active item inside the card layout
|
12
|
-
* @member activeItemCls
|
12
|
+
* @member {String} activeItemCls='neo-active-item'
|
13
13
|
* @static
|
14
14
|
*/
|
15
|
-
activeItemCls: 'active-item',
|
15
|
+
activeItemCls: 'neo-active-item',
|
16
16
|
/*
|
17
17
|
* The name of the CSS class for an inactive item inside the card layout
|
18
|
-
* @member inactiveItemCls
|
18
|
+
* @member {String} inactiveItemCls='neo-inactive-item'
|
19
19
|
* @static
|
20
20
|
*/
|
21
|
-
inactiveItemCls: 'inactive-item',
|
21
|
+
inactiveItemCls: 'neo-inactive-item',
|
22
22
|
/*
|
23
23
|
* The name of the CSS class for an item inside the card layout
|
24
24
|
* @member itemCls
|
@@ -67,7 +67,7 @@ class Card extends Base {
|
|
67
67
|
sCfg = me.getStaticConfig(),
|
68
68
|
needsUpdate = false,
|
69
69
|
removeInactiveCards = me.removeInactiveCards,
|
70
|
-
|
70
|
+
i, isActiveIndex, item, items, len, module, proto, vdom, wrapperCls;
|
71
71
|
|
72
72
|
if (Neo.isNumber(value) && container) {
|
73
73
|
items = container.items;
|
@@ -94,35 +94,32 @@ class Card extends Base {
|
|
94
94
|
module = item.module;
|
95
95
|
|
96
96
|
if (isActiveIndex && !module?.isClass && Neo.isFunction(module)) {
|
97
|
-
module
|
98
|
-
module
|
99
|
-
proto
|
100
|
-
|
97
|
+
module = await module();
|
98
|
+
module = module.default;
|
99
|
+
proto = module.prototype;
|
100
|
+
wrapperCls = item.wrapperCls || proto.constructor.config.wrapperCls || [];
|
101
101
|
|
102
|
-
item.className
|
103
|
-
item.
|
104
|
-
item.module
|
102
|
+
item.className = proto.className;
|
103
|
+
item.wrapperCls = [...wrapperCls, sCfg.itemCls];
|
104
|
+
item.module = module;
|
105
105
|
|
106
106
|
delete item.vdom;
|
107
107
|
|
108
108
|
items[i] = item = Neo.create(item);
|
109
109
|
|
110
|
-
container.fire('cardLoaded', {
|
111
|
-
item: item
|
112
|
-
});
|
110
|
+
container.fire('cardLoaded', {item});
|
113
111
|
|
114
112
|
vdom.cn[i] = item.vdom;
|
115
113
|
}
|
116
114
|
|
117
115
|
if (item instanceof Neo.core.Base) {
|
118
|
-
|
116
|
+
wrapperCls = item.wrapperCls;
|
119
117
|
|
120
|
-
NeoArray.remove(
|
121
|
-
NeoArray.add(
|
118
|
+
NeoArray.remove(wrapperCls, isActiveIndex ? sCfg.inactiveItemCls : sCfg.activeItemCls);
|
119
|
+
NeoArray.add( wrapperCls, isActiveIndex ? sCfg.activeItemCls : sCfg.inactiveItemCls);
|
122
120
|
|
123
121
|
if (removeInactiveCards || needsUpdate) {
|
124
|
-
item.
|
125
|
-
item.getVdomRoot().cls = cls;
|
122
|
+
item.wrapperCls = wrapperCls;
|
126
123
|
|
127
124
|
if (isActiveIndex) {
|
128
125
|
delete item.vdom.removeDom;
|
@@ -132,7 +129,7 @@ class Card extends Base {
|
|
132
129
|
item.vdom.removeDom = true;
|
133
130
|
}
|
134
131
|
} else {
|
135
|
-
item.
|
132
|
+
item.wrapperCls = wrapperCls;
|
136
133
|
}
|
137
134
|
}
|
138
135
|
}
|
@@ -153,18 +150,18 @@ class Card extends Base {
|
|
153
150
|
let me = this,
|
154
151
|
isActiveIndex = me.activeIndex === index,
|
155
152
|
sCfg = me.getStaticConfig(),
|
156
|
-
childCls = item.
|
153
|
+
childCls = item.wrapperCls,
|
157
154
|
vdom = item.vdom;
|
158
155
|
|
159
156
|
NeoArray.add(childCls, sCfg.itemCls);
|
160
157
|
NeoArray.add(childCls, isActiveIndex ? sCfg.activeItemCls : sCfg.inactiveItemCls);
|
161
158
|
|
162
159
|
if (!keepInDom && me.removeInactiveCards) {
|
163
|
-
item.
|
164
|
-
vdom.removeDom
|
160
|
+
item.wrapperCls = childCls;
|
161
|
+
vdom.removeDom = !isActiveIndex;
|
165
162
|
item.vdom = vdom;
|
166
163
|
} else {
|
167
|
-
item.
|
164
|
+
item.wrapperCls = childCls;
|
168
165
|
}
|
169
166
|
}
|
170
167
|
|
@@ -172,17 +169,17 @@ class Card extends Base {
|
|
172
169
|
* Applies CSS classes to the container this layout is bound to
|
173
170
|
*/
|
174
171
|
applyRenderAttributes() {
|
175
|
-
let me
|
176
|
-
container
|
177
|
-
|
172
|
+
let me = this,
|
173
|
+
container = Neo.getComponent(me.containerId),
|
174
|
+
wrapperCls = container?.wrapperCls || [];
|
178
175
|
|
179
176
|
if (!container) {
|
180
177
|
Neo.logError('layout.Card: applyRenderAttributes -> container not yet created', me.containerId);
|
181
178
|
}
|
182
179
|
|
183
|
-
NeoArray.add(
|
180
|
+
NeoArray.add(wrapperCls, 'neo-layout-card');
|
184
181
|
|
185
|
-
container.
|
182
|
+
container.wrapperCls = wrapperCls;
|
186
183
|
}
|
187
184
|
|
188
185
|
/**
|
@@ -190,17 +187,17 @@ class Card extends Base {
|
|
190
187
|
* Gets called when switching to a different layout.
|
191
188
|
*/
|
192
189
|
removeRenderAttributes() {
|
193
|
-
let me
|
194
|
-
container
|
195
|
-
|
190
|
+
let me = this,
|
191
|
+
container = Neo.getComponent(me.containerId),
|
192
|
+
wrapperCls = container?.wrapperCls || [];
|
196
193
|
|
197
194
|
if (!container) {
|
198
195
|
Neo.logError('layout.Card: removeRenderAttributes -> container not yet created', me.containerId);
|
199
196
|
}
|
200
197
|
|
201
|
-
NeoArray.remove(
|
198
|
+
NeoArray.remove(wrapperCls, 'neo-layout-card');
|
202
199
|
|
203
|
-
container.
|
200
|
+
container.wrapperCls = wrapperCls;
|
204
201
|
}
|
205
202
|
}
|
206
203
|
|