Raft 设计系统

组件 · 布局

PaneGrid

各格怎么排:左右并排的栏、上下分开的一栏、折成标签栏的一格、最大化的一格,大小以 px 为单位,由调用方保存。

实验性也叫 Split view, Editor grid, Pane layout
import { PaneGrid } from "@botiverse/raft-ui/wip";

PaneGrid 负责排列各格:左右并排的栏,或者嵌套一个 orientation="vertical" 的 PaneGrid,把一栏上下分开。一格可以折成它的标签栏,也可以最大化一格。它建在 Resizable 上;大小是调用方保存的 px,网格只报告有人拖动的接缝(标签页与分栏)。

pane-grid/compositions/preview

何时使用

场景使用
对话旁边带标签页的各格PaneGrid,每个单元格里一个 Pane
App 自己的、可以拖动分界的两栏Resizable

结构

  • 网格:由 cells 组成的 ResizableGroup,每条接缝上一个 ResizableHandle。
  • 单元格:一个 id、保存的 size(px)、min 和 max,以及它的 content。fixed 把它折成标签栏:固定在它的大小,两边都没有拖动条。data 给它加上 data-* 属性,供 App 做命中检测。

行为

  • 只有有人拖动接缝时,onResize 才收到每个单元格的新大小(px),是窄窗口限制之前请求的大小。网格自己做的布局(比如窗口变窄时)从不改变保存的大小。
  • 结构变化时(加了一格、折起一格、窗口宽度变化)layoutKey 跟着变:网格按保存的大小重新布局。
  • maximized 让一个单元格占满网格,其他单元格藏起来;带 keepWhenMaximized 的单元格按它的大小留在旁边。最大化的单元格的内容拿到新的宽度。
  • 最大化、还原和新的 layoutKey 会重新布局网格,单元格的内容会重新挂载。要保留下来的东西放在网格外面:外壳把页面从固定图层叠到各格上,标签页和草稿放在它自己的状态里(标签页与分栏)。
  • 单元格的最小值:一栏 160px,折起的一格是标签栏的高度:内容比它自己的最小宽度还窄时被裁切,而不是被压扁。

无障碍

  • 每条接缝是一个可以获得焦点的分隔条:方向键调整大小。用 messages.resize 给它命名(默认 Resize)。

规则

  • 最多 4 栏,上下分开的每一格至少 200px 高。
  • 只保存人拖动过的大小。

API

PaneGrid

实验性How panes are laid out: columns side by side, a column split top and bottom, and one pane maximized. Built on `ResizableGroup`, `ResizablePanel` and `ResizableHandle`: a seam is a focusable separator the arrow keys move. Sizes are px kept by the caller; the grid only reports a dragged seam.
Prop类型默认值
cells (required)PaneGridCell[]
layoutKey (required)Changes when the cells' structure changes (a pane added or folded, the window's width): the grid lays out again from the saved sizes.string
maximizedOne cell fills the grid; the others are hidden. Maximizing and restoring lay the grid out anew, so the cells' content mounts again: keep what must live on (a page, a draft) outside the grid, as the shell's fixed layer does.stringnull
messagesPartial<PaneGridMessages>
onResizeA seam was dragged: each cell's new size in px. Never called for a layout the grid made itself.(sizes: Record<string, number>) => void
orientationColumns side by side, or one column split top to bottom (a vertical PaneGrid inside a cell)."vertical" | "horizontal""horizontal"