Skip to content

Commit 792eb99

Browse files
committed
tab.BodyContainer #6761
1 parent c153fc7 commit 792eb99

7 files changed

Lines changed: 85 additions & 44 deletions

File tree

apps/sharedcovid/view/MainContainer.mjs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ class MainContainer extends Viewport {
2828
* @member {Object[]} items
2929
*/
3030
items: [HeaderContainer, {
31-
module : TabContainer,
32-
activeIndex: null, // render no items initially
33-
flex : 1,
34-
reference : 'tab-container',
35-
sortable : true,
36-
style : {margin: '10px', marginTop: 0},
31+
module : TabContainer,
32+
activateInsertedTabs: true,
33+
activeIndex : null, // render no items initially
34+
flex : 1,
35+
reference : 'tab-container',
36+
sortable : true,
37+
style : {margin: '10px', marginTop: 0},
3738

3839
items: [{
3940
module : () => import('./TableContainer.mjs'),

resources/scss/src/apps/docs/MainContainer.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.neo-docs-navigation-tab-container {
33
background-color: var(--docs-navigation-tab-container-background-color);
44

5-
.neo-tab-content-container {
5+
.neo-tab-body-container {
66
border-right: none;
77
}
88
}

resources/scss/src/calendar/view/SettingsContainer.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
overflow-y: auto;
77
}
88

9-
.neo-tab-content-container {
9+
.neo-tab-body-container {
1010
border: 0 !important;
1111
}
1212
}

resources/scss/src/code/LivePreview.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
margin-top: calc(var(--cmp-tab-strip-height) * (-1) - 1px);
2323
}
2424

25-
.neo-tab-content-container {
25+
.neo-tab-body-container {
2626
background-color : transparent;
2727
border : 1px solid #e6e6e6;
2828
border-bottom-left-radius : calc(var(--cmp-tab-strip-height) + var(--cmp-button-borderradius));

resources/scss/src/tab/Container.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
.neo-tab-container {
22
&.neo-bottom {
3-
> .neo-tab-content-container {
3+
> .neo-tab-body-container {
44
border-bottom: 0;
55
}
66
}
77

88
&.neo-left {
9-
> .neo-tab-content-container {
9+
> .neo-tab-body-container {
1010
border-left: 0;
1111
}
1212
}
1313

1414
&.neo-right {
15-
> .neo-tab-content-container {
15+
> .neo-tab-body-container {
1616
border-right: 0;
1717
}
1818
}
1919

2020
&.neo-top {
21-
> .neo-tab-content-container {
21+
> .neo-tab-body-container {
2222
border-top: 0;
2323
}
2424
}
@@ -27,7 +27,7 @@
2727

2828
}
2929

30-
.neo-tab-content-container {
30+
.neo-tab-body-container {
3131
border : var(--tab-container-content-border);
3232
overflow: hidden;
3333
}

src/tab/BodyContainer.mjs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import Container from '../container/Base.mjs';
2+
3+
/**
4+
* @class Neo.tab.BodyContainer
5+
* @extends Neo.container.Base
6+
*/
7+
class BodyContainer extends Container {
8+
static config = {
9+
/**
10+
* @member {String} className='Neo.tab.BodyContainer'
11+
* @protected
12+
*/
13+
className: 'Neo.tab.BodyContainer',
14+
/**
15+
* @member {String[]} baseCls=['neo-container', 'neo-tab-body-container']
16+
* @protected
17+
*/
18+
baseCls: ['neo-container', 'neo-tab-body-container']
19+
}
20+
21+
/**
22+
* When adding an existing tab into a different container, it will get automatically from the closest parent.
23+
* In this case, we also want to remove the tab.header.Button from the tab.header.Toolbar.
24+
* Use case: SharedCovid.view.MainContainerController
25+
* @param {Neo.component.Base} component
26+
* @param {Boolean} [destroyItem=true]
27+
* @param {Boolean} [silent=false]
28+
* @returns {Neo.component.Base|null}
29+
*/
30+
remove(component, destroyItem, silent) {
31+
if (component?.isTab) {
32+
this.parent.remove(component, destroyItem, silent)
33+
} else {
34+
super.remove(component, destroyItem, silent)
35+
}
36+
}
37+
}
38+
39+
export default Neo.setupClass(BodyContainer);

src/tab/Container.mjs

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import BaseContainer from '../container/Base.mjs';
2+
import BodyContainer from './BodyContainer.mjs';
23
import HeaderButton from './header/Button.mjs';
34
import HeaderToolbar from './header/Toolbar.mjs';
45
import NeoArray from '../util/Array.mjs';
@@ -44,14 +45,14 @@ class Container extends BaseContainer {
4445
*/
4546
baseCls: ['neo-tab-container'],
4647
/**
47-
* @member {String|null} cardContainerId=null
48+
* Default configs for the tab.BodyContainer
49+
* @member {Object|null} bodyContainer=null
4850
*/
49-
cardContainerId: null,
51+
bodyContainer: null,
5052
/**
51-
* Default configs for the tab.Strip
52-
* @member {Object|null} contentContainer=null
53+
* @member {String|null} bodyContainerId=null
5354
*/
54-
contentContainer: null,
55+
bodyContainerId: null,
5556
/**
5657
* Default configs for the tab.HeaderToolbar
5758
* @member {Object|null} headerToolbar=null
@@ -125,7 +126,7 @@ class Container extends BaseContainer {
125126
*/
126127
async afterSetActiveIndex(value, oldValue) {
127128
let me = this,
128-
cardContainer = Neo.getComponent(me.cardContainerId);
129+
cardContainer = Neo.getComponent(me.bodyContainerId);
129130

130131
if (Neo.isNumber(value) && value > -1 && !cardContainer) {
131132
me.on('constructed', () => {
@@ -236,12 +237,13 @@ class Container extends BaseContainer {
236237
*/
237238
createItems() {
238239
let me = this,
240+
{activeIndex, removeInactiveCards, useActiveTabIndicator} = me,
239241
items = me.items || [],
240242
tabButtons = [],
241243
tabComponents = [];
242244

243245
Object.assign(me, {
244-
cardContainerId: me.cardContainerId || Neo.getId('container'),
246+
bodyContainerId: me.bodyContainerId || Neo.getId('container'),
245247
tabBarId : me.tabBarId || Neo.getId('tab-header-toolbar'),
246248
tabStripId : me.tabStripId || Neo.getId('tab-strip')
247249
});
@@ -257,32 +259,31 @@ class Container extends BaseContainer {
257259
});
258260

259261
me.items = [{
260-
module : HeaderToolbar,
261-
dock : me.tabBarPosition,
262-
flex : 'none',
263-
id : me.tabBarId,
264-
items : tabButtons,
265-
sortable : me.sortable,
266-
useActiveTabIndicator: me.useActiveTabIndicator,
262+
module : HeaderToolbar,
263+
dock : me.tabBarPosition,
264+
flex : 'none',
265+
id : me.tabBarId,
266+
items : tabButtons,
267+
sortable: me.sortable,
268+
useActiveTabIndicator,
267269
...me.headerToolbar
268270
}, {
269-
module : Strip,
270-
cls : ['neo-tab-strip', 'neo-dock-' + me.tabBarPosition],
271-
flex : 'none',
272-
id : me.tabStripId,
273-
tabContainerId : me.id,
274-
useActiveTabIndicator: me.useActiveTabIndicator,
271+
module : Strip,
272+
cls : ['neo-dock-' + me.tabBarPosition],
273+
flex : 'none',
274+
id : me.tabStripId,
275+
tabContainerId: me.id,
276+
useActiveTabIndicator,
275277
...me.tabStrip
276278
}, {
277-
ntype : 'container',
278-
cls : ['neo-container', 'neo-tab-content-container'],
279-
id : me.cardContainerId,
280-
itemDefaults : me.itemDefaults,
281-
items : tabComponents,
282-
layout : {ntype: 'card', activeIndex: me.activeIndex, removeInactiveCards: me.removeInactiveCards},
283-
useActiveTabIndicator: me.useActiveTabIndicator,
284-
...me.contentContainer
285-
}];
279+
module : BodyContainer,
280+
id : me.bodyContainerId,
281+
itemDefaults: me.itemDefaults,
282+
items : tabComponents,
283+
layout : {ntype: 'card', activeIndex, removeInactiveCards},
284+
useActiveTabIndicator,
285+
...me.bodyContainer
286+
}]
286287

287288
me.itemDefaults = null;
288289

@@ -310,7 +311,7 @@ class Container extends BaseContainer {
310311
* @returns {Neo.container.Base}
311312
*/
312313
getCardContainer() {
313-
return Neo.getComponent(this.cardContainerId)
314+
return Neo.getComponent(this.bodyContainerId)
314315
}
315316

316317
/**

0 commit comments

Comments
 (0)