* zin: support for setting active of first tabPane automatically.

This commit is contained in:
sunhao
2024-03-05 13:41:12 +08:00
parent fe81769330
commit f7ae9af633
+9 -7
View File
@@ -115,25 +115,27 @@ class tabs extends wg
$this->filterChildren();
$titleViews = array();
$contentViews = array();
$titleViews = array();
$tabPanes = array();
$hasActived = false;
foreach($this->tabPanes as $tabPane)
{
$titleViews[] = $this->buildTitleView($tabPane);
if($tabPane->prop('divider')) $titleViews[] = div(set::className('divider'));
if($tabPane->prop('active')) $hasActived = true;
$divider = $tabPane->block('divider');
if($divider) $titleViews[] = div(set::className('divider'));
$contentViews[] = $tabPane;
$tabPanes[] = $tabPane;
}
if(!$hasActived && !empty($tabPanes)) $tabPanes[0]->setProp('active', true);
return div
(
setClass('tabs', $isVertical ? 'flex' : null),
set($this->getRestProps()),
$this->buildTabHeader($titleViews),
$this->buildTabBody($contentViews),
$this->buildTabBody($tabPanes),
$this->children
);
}