Teal TealUI

面板ui/panel

面板可以用于展示一块信息。

基本用法
样式
基本样式
自定义表头
内联块级
面板嵌套
状态
并排显示
API
Panel 类

基本用法

import { VNode, render } from "ui/control";
import Panel from "ui/panel";

render(
    __root__,
    <Panel title="标题" collapsable>
        内容
    </Panel>
);

样式

基本样式

我是面板标题
我是面板内容
<section class="x-panel">
    <header class="x-panel-header">
        我是面板标题
    </header>
    <div class="x-panel-body">
        我是面板内容
    </div>
</section>

自定义表头

工具
我是面板标题
我是面板内容
按钮
顶部
内容
<section class="x-panel">
    <header class="x-panel-header">
        <a href="###" class="x-right">工具</a>
        <h5>我是面板标题</h5>
    </header>
    <div class="x-panel-body">
        我是面板内容
    </div>
    <footer class="x-panel-footer">
        <a href="###">底部链接</a>
    </footer>
</section>
<section class="x-panel"> <header class="x-panel-header"> <a href="###" class="x-button x-button-small x-right">按钮</a> <h5>顶部</h5> </header> <div class="x-panel-body"> 内容 </div> </section>

内联块级

标题

我是面板内容

<section class="x-panel x-inline-block">
    <img src="../../../assets/resources/200x200.png" />
    <div class="x-panel-body">
        <h3>标题</h3>
        <p>我是面板内容</p>
    </div>
</section>

面板嵌套

面板嵌套
我是面板标题
我是面板内容
我是面板标题
我是面板内容
<section class="x-panel">
    <header class="x-panel-header">
        <h5>面板嵌套</h5>
    </header>
    <div class="x-panel-body">
        <section class="x-panel">
            <header class="x-panel-header">
                <h5>我是面板标题</h5>
            </header>
            <div class="x-panel-body">
                我是面板内容
            </div>
        </section>
        <section class="x-panel">
            <header class="x-panel-header">
                <h5>我是面板标题</h5>
            </header>
            <div class="x-panel-body">
                我是面板内容
            </div>
        </section>
    </div>
</section>

状态

工具
顶部
内容
工具
顶部
内容
工具
顶部
内容
工具
顶部
内容
<section class="x-panel x-panel-info">
    <header class="x-panel-header">
        <a href="###" class="x-right">工具</a>
        <h5>顶部</h5>
    </header>
    <div class="x-panel-body">
        内容
    </div>
</section>
<section class="x-panel x-panel-success"> <header class="x-panel-header"> <a href="###" class="x-right">工具</a> <h5>顶部</h5> </header> <div class="x-panel-body"> 内容 </div> </section>
<section class="x-panel x-panel-warning"> <header class="x-panel-header"> <a href="###" class="x-right">工具</a> <h5>顶部</h5> </header> <div class="x-panel-body"> 内容 </div> </section>
<section class="x-panel x-panel-error"> <header class="x-panel-header"> <a href="###" class="x-right">工具</a> <h5>顶部</h5> </header> <div class="x-panel-body"> 内容 </div> </section>

并排显示

使用栅格布局实现并排展示。

工具
顶部
内容
工具
顶部
内容
工具
顶部
内容
<div class="x-row x-row-3">
    <div class="x-col">
        <section class="x-panel x-panel-info">
            <header class="x-panel-header">
                <a href="###" class="x-right">工具</a>
                <h5>顶部</h5>
            </header>
            <div class="x-panel-body">
                内容
            </div>
        </section>
    </div>
    <div class="x-col">
        <section class="x-panel">
            <header class="x-panel-header">
                <a href="###" class="x-right">工具</a>
                <h5>顶部</h5>
            </header>
            <div class="x-panel-body">
                内容
            </div>
        </section>
    </div>
    <div class="x-col">
        <section class="x-panel x-panel-error">
            <header class="x-panel-header">
                <a href="###" class="x-right">工具</a>
                <h5>顶部</h5>
            </header>
            <div class="x-panel-body">
                内容
            </div>
        </section>
    </div>
</div>

API

Panel 类

继承自:Control

表示一个面板。

字段 类型 描述 继承自
⮞ header : HTMLElement

头部。

HTMLElement

头部。

—
⮞ title : NodeLike

标题。

NodeLike

标题。

—
⮞ collapsable : boolean

是否可折叠。

boolean

是否可折叠。

—
⮞ collapsed : boolean

是否已折叠。

boolean

是否已折叠。

—
⮞ onCollapseChange : (value: boolean, sender: Panel) => boolean | void

即将切换折叠事件。

function

即将切换折叠事件。

—
⮞ body : HTMLElement

(已覆盖)(只读)获取用于包含子控件和节点的根元素。

继承自

Control

HTMLElement

(已覆盖)(只读)获取用于包含子控件和节点的根元素。

Control
⮞ readyState : ControlState

获取当前控件的渲染状态。

继承自

Control

ControlState

获取当前控件的渲染状态。

Control
⮞ elem : HTMLElement

关联的元素。

继承自

Control

HTMLElement

关联的元素。

Control
⮞ vNode : VNode

(保护的)获取当前控件关联的虚拟节点。

继承自

Control

VNode

(保护的)获取当前控件关联的虚拟节点。

Control
⮞ sourceVNode : VNode

获取创建该控件使用的源虚拟节点。

继承自

Control

VNode

获取创建该控件使用的源虚拟节点。

Control
⮞ alwaysUpdate : boolean

控件是否使用主动更新模式。

继承自

Control

boolean

控件是否使用主动更新模式。

Control
⮞ duration : number = 200

渐变的持续毫秒数。如果为 0 则不使用渐变。

继承自

Control

number

渐变的持续毫秒数。如果为 0 则不使用渐变。

Control
⮞ class : string

CSS 类名。

继承自

Control

string

CSS 类名。

Control
⮞ hidden : boolean

是否隐藏。

继承自

Control

boolean

是否隐藏。

Control
⮞ style : string | { [key: string]: string | number; }

控件样式。

继承自

Control

string | object

控件样式。

Control
⮞ id : string

控件序号。

继承自

Control

string

控件序号。

Control
⮞ content : NodeLike

控件内容。

继承自

Control

NodeLike

控件内容。

Control
⮞ onSelectStart : (e: Event, sender: Panel) => void function

选择开始事件。

Control
⮞ onClick : (e: MouseEvent, sender: Panel) => void function

点击事件。

Control
⮞ onAuxClick : (e: MouseEvent, sender: Panel) => void function

中键点击事件。

Control
⮞ onDblClick : (e: MouseEvent, sender: Panel) => void function

双击事件。

Control
⮞ onContextMenu : (e: PointerEvent, sender: Panel) => void function

右键菜单事件。

Control
⮞ onMouseDown : (e: MouseEvent, sender: Panel) => void function

鼠标按下事件。

Control
⮞ onMouseUp : (e: MouseEvent, sender: Panel) => void function

鼠标按上事件。

Control
⮞ onMouseOver : (e: MouseEvent, sender: Panel) => void function

鼠标移入事件。

Control
⮞ onMouseOut : (e: MouseEvent, sender: Panel) => void function

鼠标移开事件。

Control
⮞ onMouseEnter : (e: MouseEvent, sender: Panel) => void function

鼠标进入事件。

Control
⮞ onMouseLeave : (e: MouseEvent, sender: Panel) => void function

鼠标离开事件。

Control
⮞ onMouseMove : (e: MouseEvent, sender: Panel) => void function

鼠标移动事件。

Control
⮞ onWheel : (e: WheelEvent, sender: Panel) => void function

鼠标滚轮事件。

Control
⮞ onScroll : (e: UIEvent, sender: Panel) => void function

滚动事件。

Control
⮞ onTouchStart : (e: TouchEvent, sender: Panel) => void function

触摸开始事件。

Control
⮞ onTouchMove : (e: TouchEvent, sender: Panel) => void function

触摸移动事件。

Control
⮞ onTouchEnd : (e: TouchEvent, sender: Panel) => void function

触摸结束事件。

Control
⮞ onTouchCancel : (e: TouchEvent, sender: Panel) => void function

触摸撤销事件。

Control
⮞ onPointerEnter : (e: PointerEvent, sender: Panel) => void function

指针进入事件。

Control
⮞ onPointerLeave : (e: PointerEvent, sender: Panel) => void function

指针离开事件。

Control
⮞ onPointerOver : (e: PointerEvent, sender: Panel) => void function

指针移入事件。

Control
⮞ onPointerOut : (e: PointerEvent, sender: Panel) => void function

指针移开事件。

Control
⮞ onPointerDown : (e: PointerEvent, sender: Panel) => void function

指针按下事件。

Control
⮞ onPointerMove : (e: PointerEvent, sender: Panel) => void function

指针移动事件。

Control
⮞ onPointerUp : (e: PointerEvent, sender: Panel) => void function

指针松开事件。

Control
⮞ onPointerCancel : (e: PointerEvent, sender: Panel) => void function

指针取消事件。

Control
⮞ onGotPointerCapture : (e: PointerEvent, sender: Panel) => void function

指针开始捕获事件。

Control
⮞ onLostPointerCapture : (e: PointerEvent, sender: Panel) => void function

指针停止捕获事件。

Control
方法 描述 继承自
⮞ handleHeaderClick()():void

(保护的)处理标题点击事件。

返回值

类型:void

(保护的)处理标题点击事件。

—
⮞ toggleCollapse(...)(value?:boolean):void

切换面板的折叠状态。

参数 类型 描述 默认值
value boolean !this.collapsed

返回值

类型:void

切换面板的折叠状态。

—
⮞ render()():VNode

(保护的)

返回值

类型:VNode

继承自

Control

(保护的)(已覆盖)当被子类重写时负责返回当前控件的虚拟节点。

Control
⮞ init()():void

(保护的)当被子类重写时负责在关联元素后初始化当前控件。

返回值

类型:void

继承自

Control

(保护的)当被子类重写时负责在关联元素后初始化当前控件。

Control
⮞ uninit()():void

(保护的)当被子类重写时负责在元素被取消关联前取消初始化当前控件。

返回值

类型:void

继承自

Control

(保护的)当被子类重写时负责在元素被取消关联前取消初始化当前控件。

Control
⮞ update()():void

重新渲染当前控件。

返回值

类型:void

继承自

Control

重新渲染当前控件。

Control
⮞ layout(changes)(changes:Changes):void

重新布局当前控件。

参数 类型 描述 默认值
changes* Changes —

返回值

类型:void

继承自

Control

重新布局当前控件。

Control
⮞ invalidate()():void

使当前控件无效并在下一帧重新渲染。

返回值

类型:void

继承自

Control

使当前控件无效并在下一帧重新渲染。

Control
⮞ renderTo(parent, ...)(parent:Control | Node, refChild?:Control | Node):void

将当前控件渲染到指定的父控件或节点。

参数 类型 描述 默认值
parent* Control | Node —
refChild Control | Node —

返回值

类型:void

继承自

Control

将当前控件渲染到指定的父控件或节点。

Control
⮞ find(selector)(selector:string):Control | HTMLElement

在当前控件查找指定的子控件或节点。

参数 类型 描述 默认值
selector* string —

返回值

类型:Control | HTMLElement

返回子控件或节点。如果找不到则返回 null。

继承自

Control

在当前控件查找指定的子控件或节点。

Control
⮞ query(selector)(selector:string):(Control | HTMLElement)[]

在当前控件查找匹配的所有子控件或节点。

参数 类型 描述 默认值
selector* string —

返回值

类型:(Control | HTMLElement)[]

返回子控件或节点列表。

继承自

Control

在当前控件查找匹配的所有子控件或节点。

Control