项目正在快速迭代中,API 与视觉细节可能随版本调整,请勿用于生产环境。

EtRibbonBar · 工具区主体 ​

tab 条 + 控件行的工具区门面:真折叠、分量降级、溢出「更多」、上下文 tab,状态只读 registry.state()。

vue
<script setup>
import { ref } from 'vue'
const activeTab = ref('home')
const collapsed = ref(false)
const ctx = { hasSelection: true }
</script>

<template>
  <et-ribbon-bar
    v-model="activeTab"
    v-model:collapsed="collapsed"
    :schema="schema"
    :registry="registry"
    :ctx="ctx"
    persist-key="my-app-ribbon"
    @command="onCommand"
  />
</template>

API ​

import { EtRibbonBar } from '@wil-works/evoke-tools-ui'办公子类工具区功能块

Props

名称类型默认说明
schemaArray() => []tab 节点树:{ key, type: 'tab', label, children: [group{ children: [item|select|separator|spacer] }] }
registryObjectnull命令注册表(createCommandRegistry() 的返回值):状态唯一来源
modelValueString''激活 tab 的 key
collapsedBooleanfalse真折叠态(受控可选;内部 toggle 经 update:collapsed 回写)
contextTabsArray() => []上下文 tab:{ id, label, when(ctx) },声明式唤出
ctxObject() => ({})选区/焦点上下文:enabled/active 全靠它推演
persistKeyString''持久化键('' = 不持久化;非空时 load/saveCollapsed 读写 localStorage)
overflowLabelString'更多'窄屏溢出入口文案
peekBooleantrue折叠后 hover/focus tab 条时浮层临时展开

Emits

事件载荷说明
update:modelValueidv-model(modelValue)的写入
update:collapsedstored, nextv-model(collapsed)的写入
changeid功能区 tab 切换;载荷 = tab 的 key
commandid, node.command条目命令被点击;载荷 = 命令 id——跑不跑由消费方决定(registry.run),本件不推演执行

Slots

schema 驱动:tab / 组 / 条目全部来自 ribbonSchema,形态不对外开放

键盘 · 可访问名 · 密度

键盘Escape组字守卫
可访问名aria-labelrole=toolbar
密度--et-chrome-bg--et-chrome-group-label-color--et-chrome-separator--et-chrome-tabstrip-height--et-chrome-toolarea-collapsed--et-chrome-toolarea-height--et-density-base-font--et-density-caption-font--et-density-line-height--et-toolbtn-fg

行为 ​

  • 折叠快捷键 Ctrl+F1 / ⌥⌘R(Win 上 Ctrl+Alt+R)+ 双击 tab 条;折叠后工具区主体高度归零,命令经 peek 浮层仍可达。
  • 分量降档 FULL → SMALL → GROUP_DROPDOWN(RIBBON_SCALE_TIERS);全部最小档仍放不下,组收进行尾「更多」。控件行禁换行。
  • 上下文 tab 条件满足才进条,条件消失即退场。
  • 未注册的命令不渲染(悬空引用在 schema 期就该被发现)。
  • select 条目宽度取 schema 的 width(px 数字或 CSS 串)。
  • 暴露 measure()。
  • 同目录导出辅件 EtOverflowMenu:props groups / registry / ctx / label,emits command;被收进的组按组分区呈现,disabled 同样来自 registry.state。

令牌与门禁 ​

  • --et-chrome-toolarea-height / --et-chrome-toolarea-collapsed / --et-chrome-top-budget(calc 派生,改分量预算自动跟随)。
  • G3:命令状态单点实现,本件不做任何本地推演。
  • G5:全局 keydown 判 isImeComposing。
  • G7:折叠/溢出在三档宽度下不换行、不撑高(视觉断言双锁)。