# PaneDropOverlay

> 拖动的标签页会落在哪里：分出时新的一格会占的那一半，或者整格，用放下位置的样子铺上阴影，文字放在 HUD 胶囊里。

Source: https://raft-design.botiverse.build/zh/components/pane-drop-overlay. Translated from https://raft-design.botiverse.build/components/pane-drop-overlay.md; where the two differ, the English page is right.

PaneDropOverlay 显示拖动的标签页会落在哪里，铺出新的一格会占的地方：在一格的边上，是分出后会占的那一半；在中间，是整格。阴影用放下位置唯一的样子 [DropPlaceholder](https://raft-design.botiverse.build/zh/components/drag.md)，这个区域的文字放在一个 HUD 胶囊里（[标签页与分栏](https://raft-design.botiverse.build/zh/patterns/tabs-and-panes.md#dragging)）。

```tsx
import { PaneDropOverlay } from "@botiverse/raft-ui/wip";

const RECT = { left: 0, top: 0, width: 200, height: 120 };

/**
 * Where a dragged tab will land: an edge of a pane shades the half the new
 * pane will take, the middle shades the whole pane. Over the conversation it
 * says so in its own words.
 */
export function PaneDropOverlayZonesContent() {
  return (
    <div className="grid w-full max-w-3xl grid-cols-[repeat(auto-fill,200px)] gap-3">
      <div className="relative h-30 w-50 overflow-hidden rounded-control border border-line-hairline bg-layer-canvas">
        <PaneDropOverlay rect={RECT} zone="top" portal={false} />
      </div>
      <div className="relative h-30 w-50 overflow-hidden rounded-control border border-line-hairline bg-layer-canvas">
        <PaneDropOverlay rect={RECT} zone="bottom" portal={false} />
      </div>
      <div className="relative h-30 w-50 overflow-hidden rounded-control border border-line-hairline bg-layer-canvas">
        <PaneDropOverlay rect={RECT} zone="left" portal={false} />
      </div>
      <div className="relative h-30 w-50 overflow-hidden rounded-control border border-line-hairline bg-layer-canvas">
        <PaneDropOverlay rect={RECT} zone="right" portal={false} />
      </div>
      <div className="relative h-30 w-50 overflow-hidden rounded-control border border-line-hairline bg-layer-canvas">
        <PaneDropOverlay rect={RECT} zone="center" portal={false} />
      </div>
      <div className="relative h-30 w-50 overflow-hidden rounded-control border border-line-hairline bg-layer-canvas">
        <PaneDropOverlay
          rect={RECT}
          zone="right"
          label="Split right of the conversation"
          portal={false}
        />
      </div>
    </div>
  );
}
```

## 何时使用
| 场景 | 使用 |
| --- | --- |
| 标签页被拖到一格或对话上 | PaneDropOverlay |
| 标签页被拖到标签栏上 | 标签栏的插入线（[TabBar](https://raft-design.botiverse.build/zh/components/tab-bar.md) `insertAt`） |
| 在列表内或列表之间拖动一项 | [Drag](https://raft-design.botiverse.build/zh/components/drag.md)：列表里的虚线位置 |
| 不接受这一项的地方 | 不铺阴影：指针旁边的拒绝提示（[拖放](https://raft-design.botiverse.build/zh/patterns/drag-and-drop.md#refused-places)） |

## 结构
- 覆盖层，铺在这个区域会占的地方（`paneDropArea`），里面一个 `DropPlaceholder`，用较深的填充，因为它盖在实时内容上。
- 文字，放在中间的 HUD 胶囊里。

## 行为
- `paneDropZone(rect, x, y)` 给出一个点所在的区域：整格（包括标签栏）宽或高 25% 以内最近的那条边，否则是 `center`。
- 边上铺那一半：「向上分出」「向下分出」「向左分出」「向右分出」。中间铺整格：「放进这一格」。在对话上时由 App 在 `label` 里传它自己的话：「在对话右边分出一栏」。
- 开着 `portal`（默认）时，它渲染在最近的 portal 容器里，没有就在 `document.body`，以 `fixed` 放在拖动的层级上，所以盖在从固定图层叠到各格上的页面上面；`rect` 用视口 px。关掉时，它以 `absolute` 放在这一格的定位父元素里。
- 在区域之间移动时用 120ms 和拖动落定的缓动。

## 内容
- 说出放下后会做什么，用标签页菜单里的说法：「向右分出」「放进这一格」。译文通过 `messages` 传入。

## 无障碍
- 它对辅助技术隐藏：拖动的播报会说出标签页在哪里（[拖放](https://raft-design.botiverse.build/zh/patterns/drag-and-drop.md#screen-readers)）。
- 拖动从来不是唯一的方式：标签页菜单里的「移到别的分栏」是键盘的路。

## 规则
- 铺出新的一格会占的地方，从不只画一条线或一个轮廓。
- 不接受标签页的地方什么都不铺。

## API

### PaneDropOverlay

Where a dragged tab will land, as the area the new pane will take: an edge shades that half of the pane, its tab bar included, and the middle shades the whole pane, each with its words in a HUD chip. The shade is the one look for a place, `DropPlaceholder`, on the strong fill because it lies over live content. Hidden from assistive technology: the drag's announcements say where the tab is.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` |  | Words in place of the zone's own, such as "Split right of the conversation". |
| `messages` | `Partial<PaneDropOverlayMessages>` |  |  |
| `portal` | `boolean` | `true` | Render in a portal (the nearest `PortalContainerProvider`'s container, else `document.body`), `fixed` above live pages laid over the panes. Off: `absolute` in the pane's own positioned parent. |
| `rect` (required) | `PaneDropRect` |  | The pane's box in client px (`portal`) or in its positioned parent's px: the whole pane, its tab bar included. |
| `zone` (required) | `PaneDropZone` |  |  |

Also takes the attributes of its element.
