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
Props
| 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|
| schema | Array | () => [] | tab 节点树:{ key, type: 'tab', label, children: [group{ children: [item|select|separator|spacer] }] } |
| registry | Object | null | 命令注册表(createCommandRegistry() 的返回值):状态唯一来源 |
| modelValue | String | '' | 激活 tab 的 key |
| collapsed | Boolean | false | 真折叠态(受控可选;内部 toggle 经 update:collapsed 回写) |
| contextTabs | Array | () => [] | 上下文 tab:{ id, label, when(ctx) },声明式唤出 |
| ctx | Object | () => ({}) | 选区/焦点上下文:enabled/active 全靠它推演 |
| persistKey | String | '' | 持久化键('' = 不持久化;非空时 load/saveCollapsed 读写 localStorage) |
| overflowLabel | String | '更多' | 窄屏溢出入口文案 |
| peek | Boolean | true | 折叠后 hover/focus tab 条时浮层临时展开 |
Emits
| 事件 | 载荷 | 说明 |
|---|---|---|
| update:modelValue | id | v-model(modelValue)的写入 |
| update:collapsed | stored, next | v-model(collapsed)的写入 |
| change | id | 功能区 tab 切换;载荷 = tab 的 key |
| command | id, 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:propsgroups/registry/ctx/label,emitscommand;被收进的组按组分区呈现,disabled 同样来自registry.state。
令牌与门禁
--et-chrome-toolarea-height/--et-chrome-toolarea-collapsed/--et-chrome-top-budget(calc 派生,改分量预算自动跟随)。- G3:命令状态单点实现,本件不做任何本地推演。
- G5:全局 keydown 判
isImeComposing。 - G7:折叠/溢出在三档宽度下不换行、不撑高(视觉断言双锁)。