* zin: add type for wg.
This commit is contained in:
@@ -15,13 +15,13 @@ require_once __DIR__ . DS . 'zin.class.php';
|
||||
|
||||
class directive
|
||||
{
|
||||
public $type;
|
||||
public string $type;
|
||||
|
||||
public $data;
|
||||
public mixed $data;
|
||||
|
||||
public $options;
|
||||
public ?array $options;
|
||||
|
||||
public $parent = null;
|
||||
public ?wg $parent = null;
|
||||
|
||||
/**
|
||||
* Construct a directive object
|
||||
@@ -30,7 +30,7 @@ class directive
|
||||
* @param array $options
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($type, $data, $options = null)
|
||||
public function __construct(string $type, mixed $data, ?array $options = null)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->data = $data;
|
||||
@@ -39,7 +39,7 @@ class directive
|
||||
zin::renderInGlobal($this);
|
||||
}
|
||||
|
||||
public function __debugInfo()
|
||||
public function __debugInfo(): array
|
||||
{
|
||||
return array(
|
||||
'type' => $this->type,
|
||||
@@ -48,9 +48,9 @@ class directive
|
||||
);
|
||||
}
|
||||
|
||||
public static function is($item, $type = null)
|
||||
public static function is(mixed $item, ?string $type = null): bool
|
||||
{
|
||||
return is_object($item) && $item instanceof directive && ($type === null || $item->type === $type);
|
||||
return $item instanceof directive && ($type === null || $item->type === $type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ function directive($type, $data, $options = null): directive
|
||||
return new directive($type, $data, $options);
|
||||
}
|
||||
|
||||
function isDirective($item, $type = null)
|
||||
function isDirective(mixed $item, ?string $type = null): bool
|
||||
{
|
||||
return directive::is($item, $type);
|
||||
}
|
||||
|
||||
+14
-14
@@ -23,12 +23,12 @@ class h extends wg
|
||||
'selfClose?: bool'
|
||||
);
|
||||
|
||||
public function getTagName()
|
||||
public function getTagName(): string
|
||||
{
|
||||
return $this->props->get('tagName');
|
||||
}
|
||||
|
||||
public function isDomElement()
|
||||
public function isDomElement(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -41,70 +41,70 @@ class h extends wg
|
||||
return in_array($this->getTagName(), static::$selfCloseTags);
|
||||
}
|
||||
|
||||
public function build()
|
||||
public function build(): array
|
||||
{
|
||||
if($this->isSelfClose()) return array($this->buildSelfCloseTag());
|
||||
|
||||
return array($this->buildTagBegin(), parent::build(), $this->buildTagEnd());
|
||||
}
|
||||
|
||||
public function toJsonData()
|
||||
public function toJsonData(): array
|
||||
{
|
||||
$data = parent::toJsonData();
|
||||
$data['type'] = 'h:' . $this->getTagName();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function type()
|
||||
public function type(): string
|
||||
{
|
||||
return $this->getTagName();
|
||||
}
|
||||
|
||||
public function shortType()
|
||||
public function shortType(): string
|
||||
{
|
||||
return $this->getTagName();
|
||||
}
|
||||
|
||||
protected function getPropsStr()
|
||||
protected function getPropsStr(): string
|
||||
{
|
||||
$propStr = $this->props->toStr(array_keys(static::getDefinedProps()));
|
||||
if($this->props->hasEvent() && empty($this->id()) && $this->getTagName() !== 'html') $propStr = "$propStr id='$this->gid'";
|
||||
return empty($propStr) ? '' : " $propStr";
|
||||
}
|
||||
|
||||
protected function buildSelfCloseTag()
|
||||
protected function buildSelfCloseTag(): string
|
||||
{
|
||||
$tagName = $this->getTagName();
|
||||
$propStr = $this->getPropsStr();
|
||||
return "<$tagName$propStr />";
|
||||
}
|
||||
|
||||
protected function buildTagBegin()
|
||||
protected function buildTagBegin(): string
|
||||
{
|
||||
$tagName = $this->getTagName();
|
||||
$propStr = $this->getPropsStr();
|
||||
return "<$tagName$propStr>";
|
||||
}
|
||||
|
||||
protected function buildTagEnd()
|
||||
protected function buildTagEnd(): string
|
||||
{
|
||||
$tagName = $this->getTagName();
|
||||
return "</$tagName>";
|
||||
}
|
||||
|
||||
public static function create()
|
||||
public static function create(): h
|
||||
{
|
||||
$args = func_get_args();
|
||||
$tagName = array_shift($args);
|
||||
return new h(is_string($tagName) ? set('tagName', $tagName) : $tagName, $args);
|
||||
}
|
||||
|
||||
public static function __callStatic($tagName, $args)
|
||||
public static function __callStatic(string $tagName, array $args): h
|
||||
{
|
||||
return new h(set('tagName', $tagName), $args);
|
||||
}
|
||||
|
||||
public static function a()
|
||||
public static function a(): h
|
||||
{
|
||||
$a = static::create('a', func_get_args());
|
||||
if($a->prop('target') === '_blank' && !$a->hasProp('rel')) $a->prop('rel', 'noopener noreferrer');
|
||||
@@ -271,7 +271,7 @@ class h extends wg
|
||||
return "(function(){\n$codes\n}());";
|
||||
}
|
||||
|
||||
public static function jsRaw()
|
||||
public static function jsRaw(): string
|
||||
{
|
||||
return 'RAWJS<' . implode("\n", func_get_args()) . '>RAWJS';
|
||||
}
|
||||
|
||||
+24
-23
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The html helper methods file of zin of ZenTaoPMS.
|
||||
*
|
||||
@@ -19,28 +20,28 @@ require_once __DIR__ . DS . 'to.class.php';
|
||||
require_once __DIR__ . DS . 'data.func.php';
|
||||
require_once __DIR__ . DS . 'on.class.php';
|
||||
|
||||
function h() {return call_user_func_array('\zin\h::create', func_get_args());}
|
||||
function h(): h {return call_user_func_array('\zin\h::create', func_get_args());}
|
||||
|
||||
function div() {return call_user_func_array('\zin\h::div', func_get_args());}
|
||||
function span() {return call_user_func_array('\zin\h::span', func_get_args());}
|
||||
function code() {return call_user_func_array('\zin\h::code', func_get_args());}
|
||||
function canvas() {return call_user_func_array('\zin\h::canvas', func_get_args());}
|
||||
function br() {return call_user_func_array('\zin\h::br', func_get_args());}
|
||||
function a() {return call_user_func_array('\zin\h::a', func_get_args());}
|
||||
function p() {return call_user_func_array('\zin\h::p', func_get_args());}
|
||||
function img() {return call_user_func_array('\zin\h::img', func_get_args());}
|
||||
function button() {return call_user_func_array('\zin\h::button', func_get_args());}
|
||||
function h1() {return call_user_func_array('\zin\h::h1', func_get_args());}
|
||||
function h2() {return call_user_func_array('\zin\h::h2', func_get_args());}
|
||||
function h3() {return call_user_func_array('\zin\h::h3', func_get_args());}
|
||||
function h4() {return call_user_func_array('\zin\h::h4', func_get_args());}
|
||||
function h5() {return call_user_func_array('\zin\h::h5', func_get_args());}
|
||||
function h6() {return call_user_func_array('\zin\h::h6', func_get_args());}
|
||||
function ul() {return call_user_func_array('\zin\h::ul', func_get_args());}
|
||||
function li() {return call_user_func_array('\zin\h::li', func_get_args());}
|
||||
function template() {return call_user_func_array('\zin\h::template', func_get_args());}
|
||||
function formHidden() {return call_user_func_array('\zin\h::formHidden', func_get_args());}
|
||||
function fieldset() {return call_user_func_array('\zin\h::fieldset', func_get_args());}
|
||||
function legend() {return call_user_func_array('\zin\h::legend', func_get_args());}
|
||||
function div(): h {return call_user_func_array('\zin\h::div', func_get_args());}
|
||||
function span(): h {return call_user_func_array('\zin\h::span', func_get_args());}
|
||||
function code(): h {return call_user_func_array('\zin\h::code', func_get_args());}
|
||||
function canvas(): h {return call_user_func_array('\zin\h::canvas', func_get_args());}
|
||||
function br(): h {return call_user_func_array('\zin\h::br', func_get_args());}
|
||||
function a(): h {return call_user_func_array('\zin\h::a', func_get_args());}
|
||||
function p(): h {return call_user_func_array('\zin\h::p', func_get_args());}
|
||||
function img(): h {return call_user_func_array('\zin\h::img', func_get_args());}
|
||||
function button(): h {return call_user_func_array('\zin\h::button', func_get_args());}
|
||||
function h1(): h {return call_user_func_array('\zin\h::h1', func_get_args());}
|
||||
function h2(): h {return call_user_func_array('\zin\h::h2', func_get_args());}
|
||||
function h3(): h {return call_user_func_array('\zin\h::h3', func_get_args());}
|
||||
function h4(): h {return call_user_func_array('\zin\h::h4', func_get_args());}
|
||||
function h5(): h {return call_user_func_array('\zin\h::h5', func_get_args());}
|
||||
function h6(): h {return call_user_func_array('\zin\h::h6', func_get_args());}
|
||||
function ul(): h {return call_user_func_array('\zin\h::ul', func_get_args());}
|
||||
function li(): h {return call_user_func_array('\zin\h::li', func_get_args());}
|
||||
function template(): h {return call_user_func_array('\zin\h::template', func_get_args());}
|
||||
function formHidden(): h {return call_user_func_array('\zin\h::formHidden', func_get_args());}
|
||||
function fieldset(): h {return call_user_func_array('\zin\h::fieldset', func_get_args());}
|
||||
function legend(): h {return call_user_func_array('\zin\h::legend', func_get_args());}
|
||||
|
||||
function jsRaw() {return call_user_func_array('\zin\h::jsRaw', func_get_args());}
|
||||
function jsRaw(): string {return call_user_func_array('\zin\h::jsRaw', func_get_args());}
|
||||
|
||||
@@ -16,7 +16,7 @@ require_once __DIR__ . DS . 'wg.func.php';
|
||||
|
||||
class item extends wg
|
||||
{
|
||||
public function build()
|
||||
public function build(): wg
|
||||
{
|
||||
if($this->parent instanceof wg && method_exists($this->parent, 'onBuildItem'))
|
||||
{
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
|
||||
namespace zin;
|
||||
|
||||
use zin\utils\classlist;
|
||||
use zin\utils\style;
|
||||
|
||||
require_once dirname(__DIR__) . DS . 'utils' . DS . 'dataset.class.php';
|
||||
require_once dirname(__DIR__) . DS . 'utils' . DS . 'classlist.class.php';
|
||||
require_once dirname(__DIR__) . DS . 'utils' . DS . 'style.class.php';
|
||||
@@ -26,7 +29,7 @@ class props extends \zin\utils\dataset
|
||||
* @access public
|
||||
* @var style
|
||||
*/
|
||||
public $style;
|
||||
public style $style;
|
||||
|
||||
/**
|
||||
* Class property
|
||||
@@ -34,7 +37,9 @@ class props extends \zin\utils\dataset
|
||||
* @access public
|
||||
* @var classlist
|
||||
*/
|
||||
public $class;
|
||||
public classlist $class;
|
||||
|
||||
public static array $booleanAttrs = array('allowfullscreen', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'formnovalidate', 'inert', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected');
|
||||
|
||||
/**
|
||||
* Create properties instance
|
||||
@@ -42,7 +47,7 @@ class props extends \zin\utils\dataset
|
||||
* @access public
|
||||
* @param array $props - Properties list array
|
||||
*/
|
||||
public function __construct($props = null)
|
||||
public function __construct(?array $props = null)
|
||||
{
|
||||
$this->style = new \zin\utils\style();
|
||||
$this->class = new \zin\utils\classlist();
|
||||
@@ -54,10 +59,10 @@ class props extends \zin\utils\dataset
|
||||
* Method for sub class to modify value on setting it
|
||||
*
|
||||
* @access public
|
||||
* @param array|string $prop - Property name or properties list
|
||||
* @param string $prop - Property name or properties list
|
||||
* @param mixed $value - Property value
|
||||
*/
|
||||
protected function setVal($prop, $value)
|
||||
protected function setVal(string $prop, mixed $value): props
|
||||
{
|
||||
if($prop === 'class' || $prop === '.') $this->class->set($value);
|
||||
elseif($prop === 'style' || $prop === '~') $this->style->set($value);
|
||||
@@ -73,7 +78,7 @@ class props extends \zin\utils\dataset
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getVal($prop)
|
||||
protected function getVal(string $prop): mixed
|
||||
{
|
||||
if($prop === 'class' || $prop === '.')
|
||||
{
|
||||
@@ -88,7 +93,11 @@ class props extends \zin\utils\dataset
|
||||
return parent::getVal($prop);
|
||||
}
|
||||
|
||||
public function reset($name, $value = null)
|
||||
/**
|
||||
* @param string|string[] $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function reset(array|string $name, mixed $value = null)
|
||||
{
|
||||
if(is_array($name))
|
||||
{
|
||||
@@ -117,7 +126,7 @@ class props extends \zin\utils\dataset
|
||||
parent::setVal("@$name", $events);
|
||||
}
|
||||
|
||||
public function events()
|
||||
public function events(): array
|
||||
{
|
||||
$events = array();
|
||||
foreach($this->data as $name => $value)
|
||||
@@ -128,7 +137,7 @@ class props extends \zin\utils\dataset
|
||||
return $events;
|
||||
}
|
||||
|
||||
public function hasEvent()
|
||||
public function hasEvent(): bool
|
||||
{
|
||||
foreach($this->data as $name => $value)
|
||||
{
|
||||
@@ -138,7 +147,7 @@ class props extends \zin\utils\dataset
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hx($name, $value = null)
|
||||
public function hx(array|string $name, ?string $value = null)
|
||||
{
|
||||
if(is_array($name))
|
||||
{
|
||||
@@ -165,7 +174,7 @@ class props extends \zin\utils\dataset
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function toStr($skipProps = array())
|
||||
public function toStr(array|string $skipProps = array()): string
|
||||
{
|
||||
if(is_string($skipProps)) $skipProps = explode(',', $skipProps);
|
||||
|
||||
@@ -198,7 +207,7 @@ class props extends \zin\utils\dataset
|
||||
return implode(' ', $pairs);
|
||||
}
|
||||
|
||||
public function toJsonData()
|
||||
public function toJsonData(): array
|
||||
{
|
||||
$data = $this->data;
|
||||
if(!empty($this->style->data)) $data['style'] = $this->style->data;
|
||||
@@ -206,7 +215,7 @@ class props extends \zin\utils\dataset
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function skip($skipProps = array(), $skipFalse = false)
|
||||
public function skip(array|string $skipProps = array(), bool $skipFalse = false): array
|
||||
{
|
||||
if(is_string($skipProps)) $skipProps = explode(',', $skipProps);
|
||||
|
||||
@@ -220,7 +229,7 @@ class props extends \zin\utils\dataset
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function pick($pickProps = array())
|
||||
public function pick(array|string $pickProps = array()): array
|
||||
{
|
||||
if(is_string($pickProps)) $pickProps = explode(',', $pickProps);
|
||||
|
||||
@@ -237,15 +246,13 @@ class props extends \zin\utils\dataset
|
||||
* Clone a new instance
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
* @return props
|
||||
*/
|
||||
public function clone()
|
||||
public function clone(): props
|
||||
{
|
||||
$props = new props($this->data);
|
||||
$props->style = clone $this->style;
|
||||
$props->class = clone $this->class;
|
||||
return $props;
|
||||
}
|
||||
|
||||
public static $booleanAttrs = ['allowfullscreen', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'formnovalidate', 'inert', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected'];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The rawContent class file of zin lib.
|
||||
*
|
||||
@@ -15,7 +16,7 @@ require_once __DIR__ . DS . 'wg.class.php';
|
||||
|
||||
class rawContent extends wg
|
||||
{
|
||||
protected function build()
|
||||
protected function build(): directive
|
||||
{
|
||||
return h::comment('{{RAW_CONTENT}}');
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ require_once __DIR__ . DS . 'zin.class.php';
|
||||
*
|
||||
* @access public
|
||||
* @param string $wgName
|
||||
* @param string|array $options
|
||||
* @param array $options
|
||||
* @return void
|
||||
*/
|
||||
function render(string $wgName = '', string|array $options = null)
|
||||
function render(string $wgName = '', array $options = array())
|
||||
{
|
||||
/* 获取全局渲染部件实例和指令。 Get global render widgets and directives. */
|
||||
$globalItems = zin::getGlobalRenderList();
|
||||
@@ -32,8 +32,8 @@ function render(string $wgName = '', string|array $options = null)
|
||||
if(empty($wgName))
|
||||
{
|
||||
$wgName = 'page';
|
||||
if(isAjaxRequest() && !isAjaxRequest('zin')) $wgName = 'fragment';
|
||||
if(isAjaxRequest('modal')) $wgName = 'modalDialog';
|
||||
else if(isAjaxRequest() && !isAjaxRequest('zin')) $wgName = 'fragment';
|
||||
}
|
||||
|
||||
/* 判断是否渲染为完整页面。 Check if render in full page. */
|
||||
@@ -41,7 +41,7 @@ function render(string $wgName = '', string|array $options = null)
|
||||
if($isFullPage) $globalItems[] = set::display(false);
|
||||
|
||||
/* 获取部件渲染选项。 Get widget display options. */
|
||||
if($options === null && isset($_SERVER['HTTP_X_ZIN_OPTIONS']) && !empty($_SERVER['HTTP_X_ZIN_OPTIONS']))
|
||||
if(empty($options) && isset($_SERVER['HTTP_X_ZIN_OPTIONS']) && !empty($_SERVER['HTTP_X_ZIN_OPTIONS']))
|
||||
{
|
||||
$setting = $_SERVER['HTTP_X_ZIN_OPTIONS'];
|
||||
$options = $setting[0] === '{' ? json_decode($setting, true) : array('selector' => $setting);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace zin;
|
||||
* @param string|object $selector
|
||||
* @return object|null
|
||||
*/
|
||||
function parseWgSelector($selector)
|
||||
function parseWgSelector(string|object $selector): ?object
|
||||
{
|
||||
if(is_object($selector)) return $selector;
|
||||
|
||||
@@ -25,7 +25,15 @@ function parseWgSelector($selector)
|
||||
|
||||
if($len < 1) return null;
|
||||
|
||||
$result = ['class' => [], 'id' => null, 'tag' => null, 'inner' => false, 'name' => null, 'first' => false, 'selector' => $selector];
|
||||
$result = array(
|
||||
'class' => array(),
|
||||
'id' => null,
|
||||
'tag' => null,
|
||||
'inner' => false,
|
||||
'name' => null,
|
||||
'first' => false,
|
||||
'selector' => $selector
|
||||
);
|
||||
if(str_contains($selector, '/'))
|
||||
{
|
||||
$parts = explode('/', $selector, 2);
|
||||
@@ -113,15 +121,15 @@ function parseWgSelector($selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse wg selectors
|
||||
* @param array|string|object $selectors
|
||||
* @return array
|
||||
* Parse wg selectors.
|
||||
* @param object|string|object[]|string[] $selectors
|
||||
* @return object[]
|
||||
*/
|
||||
function parseWgSelectors($selectors)
|
||||
function parseWgSelectors(object|string|array $selectors): array
|
||||
{
|
||||
if(is_object($selectors)) return [$selectors];
|
||||
if(is_object($selectors)) return array($selectors);
|
||||
if(is_string($selectors)) $selectors = explode(',', trim($selectors));
|
||||
$results = [];
|
||||
$results = array();
|
||||
foreach($selectors as $selector)
|
||||
{
|
||||
$selector = parseWgSelector($selector);
|
||||
@@ -130,7 +138,12 @@ function parseWgSelectors($selectors)
|
||||
return $results;
|
||||
}
|
||||
|
||||
function stringifyWgSelectors($selector)
|
||||
/**
|
||||
* Stringify wg selectors.
|
||||
* @param object|object[] $selector
|
||||
* @return string
|
||||
*/
|
||||
function stringifyWgSelectors(array|object $selector): string
|
||||
{
|
||||
if(empty($selector)) return '';
|
||||
if(is_array($selector))
|
||||
|
||||
+45
-47
@@ -44,19 +44,17 @@ class wg
|
||||
* @access public
|
||||
* @var props
|
||||
*/
|
||||
public $props;
|
||||
public props $props;
|
||||
|
||||
public $blocks = array();
|
||||
public array $blocks = array();
|
||||
|
||||
public $parent = null;
|
||||
public ?wg $parent = null;
|
||||
|
||||
public $gid;
|
||||
public string $gid;
|
||||
|
||||
public $displayed = false;
|
||||
public bool $displayed = false;
|
||||
|
||||
protected $matchedPortals = null;
|
||||
|
||||
protected $renderOptions = null;
|
||||
protected array $renderOptions = array();
|
||||
|
||||
public function __construct(/* string|element|object|array|null ...$args */)
|
||||
{
|
||||
@@ -73,12 +71,12 @@ class wg
|
||||
$this->checkErrors();
|
||||
}
|
||||
|
||||
public function __debugInfo()
|
||||
public function __debugInfo(): array
|
||||
{
|
||||
return $this->toJsonData();
|
||||
}
|
||||
|
||||
public function isDomElement()
|
||||
public function isDomElement(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -87,7 +85,7 @@ class wg
|
||||
* Check if the element is match any of the selectors
|
||||
* @param string|array|object $selectors
|
||||
*/
|
||||
public function isMatch($selectors)
|
||||
public function isMatch(string|array|object $selectors): bool
|
||||
{
|
||||
$list = parseWgSelectors($selectors);
|
||||
foreach($list as $selector)
|
||||
@@ -105,7 +103,7 @@ class wg
|
||||
* Build dom object
|
||||
* @return dom
|
||||
*/
|
||||
public function buildDom()
|
||||
public function buildDom(): dom
|
||||
{
|
||||
$before = $this->buildBefore();
|
||||
$children = $this->build();
|
||||
@@ -127,7 +125,7 @@ class wg
|
||||
* Render widget to html
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
$dom = $this->buildDom();
|
||||
$result = $dom->render();
|
||||
@@ -135,7 +133,7 @@ class wg
|
||||
return is_string($result) ? $result : json_encode($result);
|
||||
}
|
||||
|
||||
public function display(?array $options = array()): wg
|
||||
public function display(array $options = array()): wg
|
||||
{
|
||||
zin::disableGlobalRender();
|
||||
$this->renderOptions = $options;
|
||||
@@ -197,22 +195,22 @@ class wg
|
||||
|
||||
protected function created() {}
|
||||
|
||||
protected function buildBefore()
|
||||
protected function buildBefore(): array
|
||||
{
|
||||
return $this->block('before');
|
||||
}
|
||||
|
||||
protected function buildAfter()
|
||||
protected function buildAfter(): array
|
||||
{
|
||||
return $this->block('after');
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): array|wg|directive
|
||||
{
|
||||
return $this->children();
|
||||
}
|
||||
|
||||
public function buildEvents()
|
||||
public function buildEvents(): ?string
|
||||
{
|
||||
$events = $this->props->events();
|
||||
if(empty($events)) return null;
|
||||
@@ -250,17 +248,17 @@ class wg
|
||||
}
|
||||
|
||||
|
||||
protected function onAddBlock($child, $name)
|
||||
protected function onAddBlock(array|string|wg|directive $child, string $name)
|
||||
{
|
||||
return $child;
|
||||
}
|
||||
|
||||
protected function onAddChild($child)
|
||||
protected function onAddChild(array|string|wg|directive $child)
|
||||
{
|
||||
return $child;
|
||||
}
|
||||
|
||||
protected function onSetProp($prop, $value)
|
||||
protected function onSetProp(array|string $prop, mixed $value)
|
||||
{
|
||||
if($prop === 'id' && $value === '$GID') $value = $this->gid;
|
||||
if($prop[0] === '@')
|
||||
@@ -271,12 +269,12 @@ class wg
|
||||
$this->props->set($prop, $value);
|
||||
}
|
||||
|
||||
protected function onGetProp($prop, $defaultValue)
|
||||
protected function onGetProp(string $prop, mixed $defaultValue): mixed
|
||||
{
|
||||
return $this->props->get($prop, $defaultValue);
|
||||
}
|
||||
|
||||
public function add($item, $blockName = 'children')
|
||||
public function add($item, string $blockName = 'children')
|
||||
{
|
||||
if($item === null || is_bool($item)) return $this;
|
||||
|
||||
@@ -298,7 +296,7 @@ class wg
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addToBlock($name, $child = null)
|
||||
public function addToBlock(array|string $name, array|string|null|wg|directive $child = null)
|
||||
{
|
||||
if(is_array($name))
|
||||
{
|
||||
@@ -334,12 +332,12 @@ class wg
|
||||
else $this->blocks[$name] = array($child);
|
||||
}
|
||||
|
||||
public function children()
|
||||
public function children(): array
|
||||
{
|
||||
return $this->block('children');
|
||||
}
|
||||
|
||||
public function block($name)
|
||||
public function block(string $name): array
|
||||
{
|
||||
$list = array();
|
||||
if(isset($this->blocks[$name]))
|
||||
@@ -356,16 +354,15 @@ class wg
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function hasBlock($name)
|
||||
public function hasBlock(string $name): bool
|
||||
{
|
||||
return isset($this->blocks[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply directive
|
||||
* @param object $directive
|
||||
*/
|
||||
public function directive(&$directive, $blockName)
|
||||
public function directive(directive &$directive, array|string $blockName)
|
||||
{
|
||||
$data = $directive->data;
|
||||
$type = $directive->type;
|
||||
@@ -402,11 +399,10 @@ class wg
|
||||
{
|
||||
$this->add($blockChildren, $blockName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function prop($name, $defaultValue = null)
|
||||
public function prop(array|string $name, mixed $defaultValue = null): mixed
|
||||
{
|
||||
if(is_array($name))
|
||||
{
|
||||
@@ -425,11 +421,10 @@ class wg
|
||||
* Set property, an array can be passed to set multiple properties
|
||||
*
|
||||
* @access public
|
||||
* @param array|string $prop - Property name or properties list
|
||||
* @param props|array|string $prop - Property name or properties list
|
||||
* @param mixed $value - Property value
|
||||
* @return dataset
|
||||
*/
|
||||
public function setProp($prop, $value = null)
|
||||
public function setProp(props|array|string $prop, mixed $value = null)
|
||||
{
|
||||
if($prop instanceof props) $prop = $prop->toJsonData();
|
||||
|
||||
@@ -444,22 +439,25 @@ class wg
|
||||
if($prop[0] === '#')
|
||||
{
|
||||
$this->add($value, substr($prop, 1));
|
||||
return;
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->onSetProp($prop, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasProp()
|
||||
public function hasProp(): bool
|
||||
{
|
||||
$names = func_get_args();
|
||||
if(empty($names)) return false;
|
||||
foreach ($names as $name) if(!$this->props->has($name)) return false;
|
||||
foreach($names as $name)
|
||||
{
|
||||
if(!$this->props->has($name)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setDefaultProps($props)
|
||||
public function setDefaultProps(array $props)
|
||||
{
|
||||
if(!is_array($props) || empty($props)) return;
|
||||
|
||||
@@ -470,29 +468,29 @@ class wg
|
||||
}
|
||||
}
|
||||
|
||||
public function getRestProps()
|
||||
public function getRestProps(): array
|
||||
{
|
||||
return $this->props->skip(array_keys(static::getDefinedProps()));
|
||||
}
|
||||
|
||||
public function type()
|
||||
public function type(): string
|
||||
{
|
||||
return get_called_class();
|
||||
}
|
||||
|
||||
public function shortType()
|
||||
public function shortType(): string
|
||||
{
|
||||
$type = $this->type();
|
||||
$pos = strrpos($type, '\\');
|
||||
return $pos === false ? $type : substr($type, $pos + 1);
|
||||
}
|
||||
|
||||
public function id()
|
||||
public function id(): ?string
|
||||
{
|
||||
return $this->prop('id');
|
||||
}
|
||||
|
||||
public function toJsonData()
|
||||
public function toJsonData(): array
|
||||
{
|
||||
$data = array();
|
||||
$data['gid'] = $this->gid;
|
||||
@@ -599,7 +597,7 @@ class wg
|
||||
if(!empty($pageJS)) context::js($pageJS);
|
||||
}
|
||||
|
||||
public static function wgBlockMap()
|
||||
public static function wgBlockMap(): array
|
||||
{
|
||||
$wgName = get_called_class();
|
||||
if(!isset(wg::$wgToBlockMap[$wgName]))
|
||||
@@ -620,7 +618,7 @@ class wg
|
||||
return wg::$wgToBlockMap[$wgName];
|
||||
}
|
||||
|
||||
public static function getBlockNameForWg($wg)
|
||||
public static function getBlockNameForWg(wg|string $wg): ?string
|
||||
{
|
||||
$wgType = ($wg instanceof wg) ? $wg->type() : $wg;
|
||||
$wgBlockMap = static::wgBlockMap();
|
||||
@@ -628,7 +626,7 @@ class wg
|
||||
return isset($wgBlockMap[$wgType]) ? $wgBlockMap[$wgType] : null;
|
||||
}
|
||||
|
||||
protected static function getDefinedProps(string|null $wgName = null): array
|
||||
protected static function getDefinedProps(?string $wgName = null): array
|
||||
{
|
||||
if($wgName === null) $wgName = get_called_class();
|
||||
|
||||
@@ -639,7 +637,7 @@ class wg
|
||||
return wg::$definedPropsMap[$wgName];
|
||||
}
|
||||
|
||||
protected static function getDefaultProps(string|null $wgName = null): array
|
||||
protected static function getDefaultProps(?string $wgName = null): array
|
||||
{
|
||||
$defaultProps = array();
|
||||
foreach(static::getDefinedProps($wgName) as $name => $definition)
|
||||
|
||||
@@ -22,7 +22,7 @@ class dataset
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $data = array();
|
||||
public array $data = array();
|
||||
|
||||
/**
|
||||
* Create an instance, the initialed data can be passed
|
||||
@@ -30,7 +30,7 @@ class dataset
|
||||
* @access public
|
||||
* @param array $data - Properties list array
|
||||
*/
|
||||
public function __construct($data = null)
|
||||
public function __construct(?array $data = null)
|
||||
{
|
||||
if($data !== null) $this->set($data);
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class dataset
|
||||
* @param mixed $value - Property value
|
||||
* @return void
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
public function __set(string $name, mixed $value)
|
||||
{
|
||||
$this->set($name, $value);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class dataset
|
||||
* @param string $prop - Property name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
public function __get(string $name)
|
||||
{
|
||||
$this->get($name);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class dataset
|
||||
* @param string $prop - Property name
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($name)
|
||||
public function __isset(string $name): bool
|
||||
{
|
||||
return $this->has($name);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class dataset
|
||||
* @param string $prop - Property name
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($name)
|
||||
public function __unset(string $name)
|
||||
{
|
||||
$this->remove($name);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ class dataset
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->toStr();
|
||||
}
|
||||
@@ -101,7 +101,7 @@ class dataset
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function __invoke($name = null, $value = null)
|
||||
public function __invoke(string|array $name = null, mixed $value = null): string
|
||||
{
|
||||
if($value !== null || is_array($name)) return $this->set($name, $value);
|
||||
if(is_string($name)) return $this->get($name);
|
||||
@@ -125,7 +125,7 @@ class dataset
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($name, $args)
|
||||
public function __call(string $name, array $args): mixed
|
||||
{
|
||||
if(count($args)) return $this->set($name, $args[0]);
|
||||
|
||||
@@ -135,18 +135,18 @@ class dataset
|
||||
/**
|
||||
* Method for sub class to modify value on setting it
|
||||
*
|
||||
* @access public
|
||||
* @param array|string $prop - Property name or properties list
|
||||
* @access protected
|
||||
* @param string $prop - Property name or properties list
|
||||
* @param mixed $value - Property value
|
||||
* @return dataset
|
||||
*/
|
||||
protected function setVal($prop, $value)
|
||||
protected function setVal(string $prop, mixed $value): dataset
|
||||
{
|
||||
$this->data[$prop] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getVal($prop)
|
||||
protected function getVal(string $prop): mixed
|
||||
{
|
||||
return isset($this->data[$prop]) ? $this->data[$prop] : null;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class dataset
|
||||
* @param bool $skipEmpty - Whether to skip to count empty value
|
||||
* @return int
|
||||
*/
|
||||
public function count($skipEmpty = false)
|
||||
public function count($skipEmpty = false): int
|
||||
{
|
||||
if(!$skipEmpty) return count($this->data);
|
||||
|
||||
@@ -176,12 +176,13 @@ class dataset
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function toStr()
|
||||
public function toStr(): string
|
||||
{
|
||||
return json_encode($this->toJsonData());
|
||||
}
|
||||
|
||||
public function toJsonData() {
|
||||
public function toJsonData(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
@@ -191,10 +192,9 @@ class dataset
|
||||
* @access public
|
||||
* @param array|string $prop - Property name or properties list
|
||||
* @param mixed $value - Property value
|
||||
* @param bool $removeEmpty - Whether to remove empty value
|
||||
* @return dataset
|
||||
*/
|
||||
public function set($prop, $value = null)
|
||||
public function set(array|string $prop, mixed $value = null): dataset
|
||||
{
|
||||
if(is_array($prop))
|
||||
{
|
||||
|
||||
@@ -56,14 +56,14 @@ class style extends dataset
|
||||
* $style->cssVar('text-size', '14px');
|
||||
*
|
||||
* // Set multiple variables
|
||||
* $style->cssVar(array('text-color' => 'yellow', 'background-image': 'none'));
|
||||
* $style->cssVar(array('text-color' => 'yellow', 'background-image' => 'none'));
|
||||
*
|
||||
* // Get variable value
|
||||
* echo $style->cssVar('text-size'); // Output "14px"
|
||||
*
|
||||
* // Get all variables value
|
||||
* echo $style->cssVar();
|
||||
* // Output array('text-size' => '14px', 'color' => 'yellow', 'background': 'none');
|
||||
* // Output array('text-size' => '14px', 'color' => 'yellow', 'background' => 'none');
|
||||
*
|
||||
* // Remove variable by setting value with an empty string
|
||||
* $style->cssVar('text-color', '');
|
||||
@@ -73,7 +73,7 @@ class style extends dataset
|
||||
* @param mixed $value - Property value
|
||||
* @return mixed
|
||||
*/
|
||||
public function cssVar($name = '', $value = null)
|
||||
public function cssVar(array|string $name = '', ?string $value = null): style|array|string
|
||||
{
|
||||
/* Support for setting multiple variables by an array */
|
||||
if(is_array($name))
|
||||
@@ -110,7 +110,7 @@ class style extends dataset
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function toStr()
|
||||
public function toStr(): string
|
||||
{
|
||||
return $this->toCss();
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class style extends dataset
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function toCss()
|
||||
public function toCss(): string
|
||||
{
|
||||
$pairs = array();
|
||||
|
||||
@@ -139,10 +139,10 @@ class style extends dataset
|
||||
/**
|
||||
* Create an instance
|
||||
*
|
||||
* @param string $style - CSS style list
|
||||
* @param ?array $style - CSS style list
|
||||
* @return style
|
||||
*/
|
||||
static public function new($style = null)
|
||||
public static function new(?array $style = null): style
|
||||
{
|
||||
return new style($style);
|
||||
}
|
||||
@@ -151,10 +151,10 @@ class style extends dataset
|
||||
* Create css from style list
|
||||
*
|
||||
* @access public
|
||||
* @param string $style - CSS style list
|
||||
* @param ?array $style - CSS style list
|
||||
* @return string
|
||||
*/
|
||||
static public function css($style)
|
||||
public static function css(?array $style): string
|
||||
{
|
||||
return (new style($style))->toCss();
|
||||
}
|
||||
@@ -166,7 +166,7 @@ class style extends dataset
|
||||
* @param string $name - CSS variable name
|
||||
* @return string
|
||||
*/
|
||||
static public function formatVarName($name)
|
||||
public static function formatVarName(string $name): string
|
||||
{
|
||||
return \zin\str_starts_with($name, '--') ? $name : "--$name";
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class actionItem extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($name, $type, $outerTag, $outerProps, $outerClass) = $this->prop(array('name', 'type', 'outerTag', 'outerProps', 'outerClass'));
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class avatar extends wg
|
||||
return $child;
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
/* Attach classes. */
|
||||
$this->finalClass[] = $this->prop('className');
|
||||
|
||||
@@ -13,7 +13,7 @@ class batchActions extends wg
|
||||
return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
return formGroup
|
||||
(
|
||||
|
||||
@@ -89,7 +89,7 @@ class btn extends wg
|
||||
return $classList;
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$props = $this->getProps();
|
||||
$children = $this->getChildren();
|
||||
|
||||
@@ -10,7 +10,7 @@ class btnGroup extends wg
|
||||
'size?:string',
|
||||
);
|
||||
|
||||
public function onBuildItem($item)
|
||||
public function onBuildItem($item): btn
|
||||
{
|
||||
if(!($item instanceof item)) $item = item(set($item));
|
||||
return btn(inherit($item));
|
||||
@@ -28,7 +28,7 @@ class btnGroup extends wg
|
||||
return $className;
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$items = $this->prop('items');
|
||||
$className = $this->getclassName();
|
||||
|
||||
@@ -26,8 +26,7 @@ class burn extends wg
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected static array $defineProps = array
|
||||
(
|
||||
protected static array $defineProps = array(
|
||||
'data?: string|array', // 数据源
|
||||
'referenceLine?: bool=false' // 参考线
|
||||
);
|
||||
@@ -35,7 +34,7 @@ class burn extends wg
|
||||
/**
|
||||
* Build widget.
|
||||
*/
|
||||
protected function build(): wg
|
||||
protected function build(): zui
|
||||
{
|
||||
return zui::burn(inherit($this));
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class cell extends wg
|
||||
'flex:string'
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$basis = empty($this->prop('width')) ? 'auto' : $this->prop('width');
|
||||
if(is_numeric($basis)) $basis .= 'px';
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace zin;
|
||||
|
||||
class center extends wg
|
||||
{
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
return div
|
||||
(
|
||||
|
||||
@@ -53,7 +53,7 @@ class checkbox extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
if($this->prop('primary')) return $this->buildPrimary();
|
||||
list($text, $type, $typeClass) = $this->prop(array('text', 'type', 'typeClass'));
|
||||
|
||||
@@ -24,7 +24,7 @@ class checkList extends wg
|
||||
return [$value];
|
||||
}
|
||||
|
||||
public function onBuildItem($item)
|
||||
public function onBuildItem($item): checkbox
|
||||
{
|
||||
if($item instanceof item) $item = $item->props->toJsonData();
|
||||
|
||||
@@ -40,7 +40,7 @@ class checkList extends wg
|
||||
return new checkbox(set($props), set($item));
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($items, $inline) = $this->prop(['items', 'inline']);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class col extends wg
|
||||
'align?:string'
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$classList = 'col';
|
||||
list($justify, $align) = $this->prop(array('justify', 'align'));
|
||||
|
||||
@@ -11,7 +11,7 @@ class collapseBtn extends wg
|
||||
'parent: string' // 目标元素与按钮共同的父级元素选择器,使用 closest 辅助目标元素的确定。
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$target = $this->prop('target');
|
||||
$parent = $this->prop('parent');
|
||||
|
||||
@@ -25,7 +25,7 @@ class detailBody extends wg
|
||||
return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$main = $this->block('main');
|
||||
$side = $this->block('side');
|
||||
|
||||
@@ -100,7 +100,7 @@ class dragUl extends wg
|
||||
$this->ul->add(on::drop($func));
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$ul = ul
|
||||
(
|
||||
|
||||
@@ -31,7 +31,7 @@ class dropdown extends wg
|
||||
'items' => array('map' => 'item')
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): array
|
||||
{
|
||||
list($items, $placement, $strategy, $offset, $flip, $subMenuTrigger, $arrow, $trigger, $menuProps, $target, $id, $menuClass, $hasIcons, $staticMenu) = $this->prop(array('items', 'placement', 'strategy', 'offset', 'flip', 'subMenuTrigger', 'arrow', 'trigger', 'menuProps', 'target', 'id', 'menuClass', 'hasIcons', 'staticMenu'));
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class dropmenu extends wg
|
||||
* @access protected
|
||||
* @return wg
|
||||
*/
|
||||
protected function build(): wg
|
||||
protected function build(): zui
|
||||
{
|
||||
list($url, $text, $objectID, $cache, $tab, $module, $method, $extra, $id, $data) = $this->prop(array('url', 'text', 'objectID', 'cache', 'tab', 'module', 'method', 'extra', 'id', 'data'));
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ class dtable extends wg
|
||||
return $setting;
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): zui
|
||||
{
|
||||
if(empty($this->prop('data')))
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ class echarts extends wg
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): zui
|
||||
{
|
||||
return zui::echarts(inherit($this));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class editor extends wg
|
||||
// 'userColor?: string="#ffcc00"'
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$editor = new h(set::tagName('tiptap-editor'));
|
||||
$props = $this->props->pick(array('createInput', 'uploadUrl', 'placeholder', 'fullscreenable', 'resizable', 'exposeEditor', 'size', 'hideMenubar', 'bubbleMenu', 'menubarMode', 'collaborative', 'hocuspocus', 'docName', 'username', 'userColor'));
|
||||
|
||||
@@ -135,7 +135,7 @@ class featureBar extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
return div
|
||||
(
|
||||
|
||||
@@ -54,10 +54,9 @@ class formBatchItem extends wg
|
||||
/**
|
||||
* Define default properties.
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected function build()
|
||||
protected function build(): array
|
||||
{
|
||||
list($name, $label, $labelClass, $labelProps, $required, $tip, $tipClass, $tipProps, $tipIcon, $control, $width, $strong, $value, $disabled, $items, $placeholder, $ditto, $defaultDitto, $hidden, $readonly, $multiple) = $this->prop(array('name', 'label', 'labelClass', 'labelProps', 'required', 'tip', 'tipClass', 'tipProps', 'tipIcon', 'control', 'width', 'strong', 'value', 'disabled', 'items', 'placeholder', 'ditto', 'defaultDitto', 'hidden', 'readonly', 'multiple'));
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class formGroup extends wg
|
||||
'placeholder?: string'
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($name, $label, $labelClass, $labelProps, $labelWidth, $required, $tip, $tipClass, $tipProps, $control, $width, $strong, $value, $disabled, $items, $placeholder, $readonly) = $this->prop(['name', 'label', 'labelClass', 'labelProps', 'labelWidth', 'required', 'tip', 'tipClass', 'tipProps', 'control', 'width', 'strong', 'value', 'disabled', 'items', 'placeholder', 'readonly']);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class formLabel extends wg
|
||||
}
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($text, $required, $for) = $this->prop(['text', 'required', 'for']);
|
||||
return h::label
|
||||
|
||||
@@ -12,7 +12,7 @@ class formRow extends wg
|
||||
'hidden?: boolean'
|
||||
);
|
||||
|
||||
public function onBuildItem($item)
|
||||
public function onBuildItem($item): wg
|
||||
{
|
||||
if(!($item instanceof item))
|
||||
{
|
||||
@@ -23,7 +23,7 @@ class formRow extends wg
|
||||
return new formGroup(inherit($item));
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($width, $items, $hidden) = $this->prop(['width', 'items', 'hidden']);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class formSettingBtn extends wg
|
||||
return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$customFields = $this->prop('customFields', array());
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class fragment extends wg
|
||||
'rawContent?: bool'
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): array
|
||||
{
|
||||
$css = array(data('pageCSS'), '/*{{ZIN_PAGE_CSS}}*/');
|
||||
$js = array('/*{{ZIN_PAGE_JS}}*/', data('pageJS'));
|
||||
|
||||
@@ -57,9 +57,8 @@ class header extends wg
|
||||
* Build.
|
||||
*
|
||||
* @access protected
|
||||
* @return object
|
||||
*/
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
return h::header
|
||||
(
|
||||
|
||||
@@ -90,12 +90,9 @@ class heading extends wg
|
||||
* Build.
|
||||
*
|
||||
* @access protected
|
||||
* @return object
|
||||
*/
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$showAppName = $this->prop('showAppName');
|
||||
|
||||
return div
|
||||
(
|
||||
set::id('heading'),
|
||||
|
||||
@@ -18,7 +18,7 @@ class icon extends wg
|
||||
}
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($name, $size) = $this->prop(array('name', 'size'));
|
||||
return h::i
|
||||
|
||||
@@ -22,7 +22,7 @@ class input extends wg
|
||||
'class' => 'form-control',
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$props = $this->props->skip('required');
|
||||
$required = $this->prop('required');
|
||||
|
||||
@@ -13,7 +13,7 @@ class inputGroup extends wg
|
||||
'seg?:bool'
|
||||
);
|
||||
|
||||
public function onBuildItem($item)
|
||||
public function onBuildItem($item): wg
|
||||
{
|
||||
if(is_string($item)) $item = new item(set(['type' => 'addon', 'text' => $item]));
|
||||
elseif(is_array($item)) $item = new item(set($item));
|
||||
@@ -37,7 +37,7 @@ class inputGroup extends wg
|
||||
return new input(inherit($item));
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($items, $seg) = $this->prop(['items', 'seg']);
|
||||
$children = $this->children();
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace zin;
|
||||
*/
|
||||
class inputGroupAddon extends wg
|
||||
{
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
return h::span(setClass('input-group-addon'), set($this->props), $this->children());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class label extends wg
|
||||
}
|
||||
}
|
||||
|
||||
public function build()
|
||||
public function build(): wg
|
||||
{
|
||||
return span
|
||||
(
|
||||
|
||||
@@ -27,7 +27,7 @@ class mainMenu extends wg
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$others = $this->prop('others');
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class mainNavbar extends nav
|
||||
* @access protected
|
||||
* @return wg
|
||||
*/
|
||||
protected function build(): wg
|
||||
protected function build(): h
|
||||
{
|
||||
if(!$this->prop('items')) return div();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class menu extends wg
|
||||
'items?:array'
|
||||
);
|
||||
|
||||
public function onBuildItem($item)
|
||||
public function onBuildItem($item): wg
|
||||
{
|
||||
if(!($item instanceof item)) $item = item(set($item));
|
||||
return actionItem
|
||||
@@ -23,7 +23,7 @@ class menu extends wg
|
||||
/**
|
||||
* @return builder
|
||||
*/
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$items = $this->prop('items');
|
||||
return h::menu
|
||||
|
||||
@@ -15,7 +15,7 @@ class modal extends modalDialog
|
||||
'modalProps' => array()
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($id, $modalProps) = $this->prop(array('id', 'modalProps'));
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class modalDialog extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$size = $this->prop('size');
|
||||
if($size)
|
||||
|
||||
@@ -33,7 +33,7 @@ class modalHeader extends wg
|
||||
$this->setDefaultProps(array('title' => $title, 'entityText' => $entityText, 'entityID' => $entityID));
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($title, $entityText, $entityID) = $this->prop(array('title', 'entityText', 'entityID'));
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class modalTrigger extends wg
|
||||
'modal' => array('map' => 'modal')
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): array
|
||||
{
|
||||
list($target, $url, $type) = $this->prop(['target', 'url', 'type']);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace zin;
|
||||
|
||||
class moduleMenu extends wg
|
||||
{
|
||||
private $modules = array();
|
||||
private array $modules = array();
|
||||
|
||||
protected static array $defineProps = array(
|
||||
'modules: array',
|
||||
@@ -75,7 +75,7 @@ class moduleMenu extends wg
|
||||
return '';
|
||||
}
|
||||
|
||||
private function buildBtns()
|
||||
private function buildBtns(): wg
|
||||
{
|
||||
$settingLink = $this->prop('settingLink');
|
||||
$showDisplay = $this->prop('showDisplay');
|
||||
@@ -113,7 +113,7 @@ class moduleMenu extends wg
|
||||
);
|
||||
}
|
||||
|
||||
private function buildCloseBtn()
|
||||
private function buildCloseBtn(): ?wg
|
||||
{
|
||||
$activeKey = $this->prop('activeKey');
|
||||
if(empty($activeKey)) return null;
|
||||
|
||||
@@ -23,7 +23,7 @@ class monaco extends wg
|
||||
return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
global $app;
|
||||
$vsPath = $app->getWebRoot() . 'js/monaco-editor/min/vs';
|
||||
|
||||
@@ -10,7 +10,7 @@ class nav extends wg
|
||||
'items?:array' // 使用数组指定导航中的每一项。
|
||||
);
|
||||
|
||||
public function onBuildItem($item)
|
||||
public function onBuildItem($item): wg
|
||||
{
|
||||
return new actionItem
|
||||
(
|
||||
@@ -19,10 +19,7 @@ class nav extends wg
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return builder
|
||||
*/
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$items = $this->prop('items');
|
||||
return h::menu
|
||||
|
||||
@@ -277,9 +277,8 @@ class navbar extends wg
|
||||
* Build.
|
||||
*
|
||||
* @access protected
|
||||
* @return object
|
||||
*/
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
return h::nav
|
||||
(
|
||||
|
||||
@@ -26,7 +26,7 @@ class overviewBlock extends wg
|
||||
return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
|
||||
}
|
||||
|
||||
protected function buildCard($card)
|
||||
protected function buildCard($card): wg
|
||||
{
|
||||
$class = 'text-2xl text-center font-bold leading-relaxed ' . (!empty($card->class) ? $card->class : '');
|
||||
|
||||
@@ -51,7 +51,7 @@ class overviewBlock extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function buildCards($group)
|
||||
protected function buildCards($group): wg
|
||||
{
|
||||
$cards = array();
|
||||
foreach($group->cards as $card) $cards[] = $this->buildCard($card);
|
||||
@@ -63,7 +63,7 @@ class overviewBlock extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function buildBarChart($group)
|
||||
protected function buildBarChart($group): wg
|
||||
{
|
||||
$bars = array();
|
||||
$labels = array();
|
||||
@@ -116,7 +116,7 @@ class overviewBlock extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function buildBody($groups)
|
||||
protected function buildBody($groups): array
|
||||
{
|
||||
$body = array();
|
||||
foreach($groups as $group)
|
||||
@@ -128,7 +128,7 @@ class overviewBlock extends wg
|
||||
return $body;
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($id, $title, $block, $groups) = $this->prop(array('id', 'title', 'block', 'groups'));
|
||||
|
||||
|
||||
@@ -11,8 +11,7 @@ class page extends pageBase
|
||||
{
|
||||
protected static array $defaultProps = array('zui' => true);
|
||||
|
||||
protected static array $defineBlocks = array
|
||||
(
|
||||
protected static array $defineBlocks = array(
|
||||
'head' => array(),
|
||||
'header' => array('map' => 'header'),
|
||||
'heading' => array('map' => 'heading'),
|
||||
@@ -21,7 +20,7 @@ class page extends pageBase
|
||||
'footer' => array(),
|
||||
);
|
||||
|
||||
protected function buildHeader()
|
||||
protected function buildHeader(): array|wg
|
||||
{
|
||||
if($this->hasBlock('header')) return $this->block('header');
|
||||
|
||||
@@ -32,7 +31,7 @@ class page extends pageBase
|
||||
return new header(new heading($dropmenuBlock));
|
||||
}
|
||||
|
||||
protected function buildBody()
|
||||
protected function buildBody(): array
|
||||
{
|
||||
if($this->hasBlock('main'))
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ class pageBase extends wg
|
||||
return $this->children();
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
global $lang, $config, $app;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class pageForm extends page
|
||||
'formPanel?: array'
|
||||
);
|
||||
|
||||
public function children()
|
||||
public function children(): array
|
||||
{
|
||||
return array(
|
||||
formPanel(set($this->prop('formPanel')), parent::children())
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace zin;
|
||||
|
||||
class pager extends wg
|
||||
{
|
||||
protected function build()
|
||||
protected function build(): zui
|
||||
{
|
||||
return zui::pager(inherit($this));
|
||||
}
|
||||
|
||||
+8
-10
@@ -4,8 +4,7 @@ namespace zin;
|
||||
|
||||
class panel extends wg
|
||||
{
|
||||
protected static array $defineProps = array
|
||||
(
|
||||
protected static array $defineProps = array(
|
||||
'class?: string="rounded shadow ring-0 canvas"', // 类名。
|
||||
'size?: "sm"|"lg"', // 额外尺寸。
|
||||
'title?: string', // 标题。
|
||||
@@ -21,14 +20,13 @@ class panel extends wg
|
||||
'footerProps?: array' // 底部属性。
|
||||
);
|
||||
|
||||
protected static array $defineBlocks = array
|
||||
(
|
||||
protected static array $defineBlocks = array(
|
||||
'heading' => array(),
|
||||
'headingActions' => array('map' => 'toolbar'),
|
||||
'footer' => array('map' => 'nav')
|
||||
);
|
||||
|
||||
protected function buildHeadingActions()
|
||||
protected function buildHeadingActions(): ?wg
|
||||
{
|
||||
$actionsBlock = $this->block('headingActions');
|
||||
$actions = $this->prop('headingActions');
|
||||
@@ -43,7 +41,7 @@ class panel extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function buildHeading()
|
||||
protected function buildHeading(): wg
|
||||
{
|
||||
list($title, $size) = $this->prop(['title', 'size']);
|
||||
$headingBlock = $this->block('heading');
|
||||
@@ -61,7 +59,7 @@ class panel extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function buildBody()
|
||||
protected function buildBody(): wg
|
||||
{
|
||||
return div
|
||||
(
|
||||
@@ -71,12 +69,12 @@ class panel extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function buildFooter()
|
||||
protected function buildFooter(): ?wg
|
||||
{
|
||||
list($footerActions) = $this->prop(array('footerActions'));
|
||||
$footerBlock = $this->block('footer');
|
||||
|
||||
if(empty($footerActions) && empty($footerBlock)) return;
|
||||
if(empty($footerActions) && empty($footerBlock)) return null;
|
||||
|
||||
return div
|
||||
(
|
||||
@@ -93,7 +91,7 @@ class panel extends wg
|
||||
return array(setClass('panel', $class, empty($size) ? null : "size-$size"));
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
return div
|
||||
(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace zin;
|
||||
|
||||
class pasteDialog extends wg
|
||||
|
||||
@@ -25,8 +25,7 @@ class picker extends wg
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected static array $defineProps = array
|
||||
(
|
||||
protected static array $defineProps = array(
|
||||
'id?: string', // 组件根元素的 ID。
|
||||
'className?: string|array', // 类名。
|
||||
'style?: array', // 样式。
|
||||
@@ -74,7 +73,7 @@ class picker extends wg
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function getPickerProps():array
|
||||
protected function getPickerProps(): array
|
||||
{
|
||||
$props = $this->props->toJsonData();
|
||||
$items = $props['items'];
|
||||
@@ -103,7 +102,7 @@ class picker extends wg
|
||||
* @access protected
|
||||
* @return wg
|
||||
*/
|
||||
protected function build(): wg
|
||||
protected function build(): zui
|
||||
{
|
||||
return zui::picker
|
||||
(
|
||||
|
||||
@@ -23,7 +23,7 @@ class popovers extends wg
|
||||
'target' => array(),
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): array
|
||||
{
|
||||
$trigger = $this->block('trigger')[0]->children()[0];
|
||||
$target = $this->block('target')[0];
|
||||
|
||||
@@ -49,7 +49,7 @@ class priPicker extends wg
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function build(): wg
|
||||
protected function build(): zui
|
||||
{
|
||||
$items = $this->prop('items');
|
||||
if($items === null)
|
||||
|
||||
@@ -16,7 +16,7 @@ class productMenu extends wg
|
||||
return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
|
||||
}
|
||||
|
||||
private function buildMenu()
|
||||
private function buildMenu(): array
|
||||
{
|
||||
$link = $this->prop('link');
|
||||
$items = $this->prop('items');
|
||||
@@ -36,7 +36,7 @@ class productMenu extends wg
|
||||
return $menus;
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$title = $this->prop('title');
|
||||
$items = $this->buildMenu();
|
||||
|
||||
@@ -65,7 +65,7 @@ class programMenu extends wg
|
||||
return array_filter($this->programs, function($program) use($id) {return $program->parent == $id;});
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): zui
|
||||
{
|
||||
$this->programs = (array)$this->prop('programs');
|
||||
$activeKey = $this->prop('activeKey');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace zin;
|
||||
|
||||
class row extends wg
|
||||
@@ -8,7 +9,7 @@ class row extends wg
|
||||
'align?:string'
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$classList = 'row';
|
||||
list($justify, $align) = $this->prop(array('justify', 'align'));
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace zin;
|
||||
|
||||
class searchForm extends wg
|
||||
{
|
||||
protected function build()
|
||||
protected function build(): zui
|
||||
{
|
||||
return zui::searchForm(inherit($this));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class searchToggle extends wg
|
||||
return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
global $lang;
|
||||
$module = $this->prop('module');
|
||||
|
||||
@@ -17,7 +17,7 @@ class sectionCard extends wg
|
||||
);
|
||||
}
|
||||
|
||||
public function onBuildItem(item $item)
|
||||
public function onBuildItem(item $item): wg
|
||||
{
|
||||
return div
|
||||
(
|
||||
@@ -27,7 +27,7 @@ class sectionCard extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$title = $this->block('title');
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class select extends wg
|
||||
* @access public
|
||||
* @return wg
|
||||
*/
|
||||
public function onBuildItem($item): wg|array
|
||||
public function onBuildItem(wg|array $item): wg
|
||||
{
|
||||
if($item instanceof item) $item = $item->props->toJsonData();
|
||||
|
||||
@@ -99,7 +99,7 @@ class select extends wg
|
||||
* @access protected
|
||||
* @return wg
|
||||
*/
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($items, $multiple, $required) = $this->prop(array('items', 'multiple', 'required'));
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class severityLabel extends wg
|
||||
}
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$text = $this->prop('text');
|
||||
$level = $this->prop('level');
|
||||
|
||||
@@ -49,7 +49,7 @@ class severityPicker extends wg
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function build(): wg
|
||||
protected function build(): zui
|
||||
{
|
||||
$items = $this->prop('items');
|
||||
if($items === null)
|
||||
|
||||
@@ -19,7 +19,7 @@ class sidebar extends wg
|
||||
return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($side, $showToggle) = $this->prop(array('side', 'showToggle'));
|
||||
return div
|
||||
|
||||
@@ -19,7 +19,7 @@ class tableData extends wg
|
||||
return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
|
||||
}
|
||||
|
||||
private function buildItemWithTr($item)
|
||||
private function buildItemWithTr($item): wg
|
||||
{
|
||||
return h::tr
|
||||
(
|
||||
@@ -37,7 +37,7 @@ class tableData extends wg
|
||||
);
|
||||
}
|
||||
|
||||
private function buildItemWithDiv($item)
|
||||
private function buildItemWithDiv($item): wg
|
||||
{
|
||||
if($item->prop('collapse'))
|
||||
{
|
||||
@@ -79,7 +79,7 @@ class tableData extends wg
|
||||
);
|
||||
}
|
||||
|
||||
public function onBuildItem($item)
|
||||
public function onBuildItem($item): wg
|
||||
{
|
||||
$item->setProp(array('thClass' => $this->prop('thClass'), 'tdClass' => $this->prop('tdClass')));
|
||||
|
||||
@@ -89,7 +89,7 @@ class tableData extends wg
|
||||
return $this->buildItemWithDiv($item);
|
||||
}
|
||||
|
||||
private function caption()
|
||||
private function caption(): ?wg
|
||||
{
|
||||
$title = $this->prop('title');
|
||||
if(empty($title)) return null;
|
||||
|
||||
@@ -16,7 +16,7 @@ class tabPane extends wg
|
||||
'divider' => false,
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$key = $this->prop('key');
|
||||
$active = $this->prop('active');
|
||||
|
||||
@@ -92,7 +92,7 @@ class tabs extends wg
|
||||
}
|
||||
}
|
||||
|
||||
private function buildCollapseBtn()
|
||||
private function buildCollapseBtn(): ?wg
|
||||
{
|
||||
$collapse = $this->prop('collapse');
|
||||
if(!$collapse) return null;
|
||||
|
||||
@@ -19,7 +19,7 @@ class textarea extends wg
|
||||
'rows' => 10
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
return h::textarea(set($this->props), $this->children());
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class timePicker extends wg
|
||||
* @access protected
|
||||
* @return wg
|
||||
*/
|
||||
protected function build(): wg
|
||||
protected function build(): zui
|
||||
{
|
||||
list($name, $id, $defaultValue) = $this->prop(array('name', 'id', 'defaultValue'));
|
||||
return zui::timePicker
|
||||
|
||||
@@ -13,7 +13,7 @@ class toolbar extends wg
|
||||
'btnProps?: array'
|
||||
);
|
||||
|
||||
public function onBuildItem($item)
|
||||
public function onBuildItem($item): wg
|
||||
{
|
||||
if($item === null) return null;
|
||||
|
||||
@@ -37,7 +37,7 @@ class toolbar extends wg
|
||||
);
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
$items = $this->prop('items');
|
||||
return div
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace zin;
|
||||
|
||||
class tooltip extends wg
|
||||
{
|
||||
protected function build()
|
||||
protected function build(): zui
|
||||
{
|
||||
$tooltip = zui::tooltip(inherit($this));
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class tree extends wg
|
||||
'class?: string',
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): zui
|
||||
{
|
||||
$this->setProp('items', $this->buildTree($this->prop('items')));
|
||||
return zui::tree(set($this->props->pick(array('items', 'activeClass', 'activeIcon', 'activeKey', 'onClickItem', 'defaultNestedShow', 'changeActiveKey', 'isDropdownMenu', 'collapsedIcon', 'expandedIcon', 'normalIcon', 'id'))));
|
||||
|
||||
@@ -40,7 +40,7 @@ class upload extends wg
|
||||
'exceededCountHint?: string', // 上传超出个数限制提示
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): zui
|
||||
{
|
||||
global $lang;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class uploadImgs extends wg
|
||||
'totalCountText?: string', // 文件数量文本
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): zui
|
||||
{
|
||||
return zui::uploadImgs(inherit($this));
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class userAvatar extends wg
|
||||
return parent::onAddChild($child);
|
||||
}
|
||||
|
||||
protected function build()
|
||||
protected function build(): wg
|
||||
{
|
||||
list($user, $avatar, $account, $realname) = $this->prop(array('user', 'avatar', 'account', 'realname'));
|
||||
if(is_array($user))
|
||||
|
||||
@@ -31,7 +31,7 @@ class zui extends wg
|
||||
'_class?: string'
|
||||
);
|
||||
|
||||
protected function build()
|
||||
protected function build(): array
|
||||
{
|
||||
list($name, $target, $tagName, $targetProps, $size, $id, $class, $map) = $this->prop(array('_name', '_to', '_tag', '_props', '_size', '_id', '_class', '_map'));
|
||||
list($width, $height) = $size;
|
||||
|
||||
Reference in New Issue
Block a user