diff --git a/lib/zin/func.php b/lib/zin/func.php index 5bbe803302..cb4b4f19a1 100644 --- a/lib/zin/func.php +++ b/lib/zin/func.php @@ -910,6 +910,10 @@ function modalDialog() * array items * ?string direction='h' * ?string activeId + * + * ====== blocks ====== + * tabPanes = array() + * ==================== */ function tabs() { diff --git a/lib/zin/wg/tabs/v1.php b/lib/zin/wg/tabs/v1.php index 038570c959..559f60c491 100644 --- a/lib/zin/wg/tabs/v1.php +++ b/lib/zin/wg/tabs/v1.php @@ -2,6 +2,8 @@ declare(strict_types=1); namespace zin; +require_once dirname(__DIR__) . DS . 'tabpane' . DS . 'v1.php'; + class tabs extends wg { protected static $defineProps = array( @@ -11,6 +13,10 @@ class tabs extends wg 'activeID?:string' ); + protected static $defineBlocks = array( + 'tabPanes' => array() + ); + public static function getPageCSS(): string|false { return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css'); @@ -43,11 +49,10 @@ class tabs extends wg { if(!isset($item['data'])) return null; $isActive = $this->prop('activeID') == $id || (isset($item['active']) && $item['active']); - return div + return new tabPane ( - setClass('tab-pane'), setID($id), - $isActive ? setClass('active') : null, + set::isActive($isActive), $item['data'] ); } @@ -78,22 +83,14 @@ class tabs extends wg protected function build(): wg { - $items = $this->prop('items'); + $items = $this->prop('items'); $isVertical = $this->prop('direction') === 'v'; + $tabPanes = $this->block('tabPanes'); - if(empty($items)) - { - return div - ( - set($this->props->skip(array_keys(static::getDefinedProps()))), - $isVertical ? setClass('flex') : null, - - $this->children() - ); - } - - $labelViews = array(); + $labelViews = array(); $contentViews = array(); + if(is_array($tabPanes)) $contentViews = array_merge($contentViews, $tabPanes); + foreach($items as $item) { $id = $this->getItemID($item);