# 拖放

排序列表、嵌套树，或用指针或键盘在列表之间移动条目。

`createReorder` 排序列表和网格，`createTreeReorder` 移动行和子树，`createTransfer` 在列表之间移动条目。它们在移动过程中保留一份草稿，并在放下时通过你的[变更](https://ui-sdk.cn/docs/core/kernel/handle-changes#changes)提交它。用 `bindDrag` 为自定义拖动跟踪指针。

从 `@ui-sdk/core` 导入这些辅助函数。[组合行为](/docs/core/compose-behaviors)演示如何把行为接到原语（primitive）上。对于自由定位的条目，见[拖动与调整大小](/docs/core/behaviors/direct-manipulation)。

## 指针拖动
### 跟随指针
`bindDrag` 跟随按压某个元素的指针。在指针处理函数里调用它，并保留它的清理函数，这样销毁原语时也会停止拖动：

```ts
let stop: (() => void) | undefined
context.onDestroy(() => stop?.())

return {
  pointerdown(event: PointerEvent, el: HTMLElement) {
    if (event.button !== 0) {
      return
    }
    stop?.()
    stop = bindDrag(el, event, {
      threshold: dragThreshold,
      cancelOnEscape: true,
      onMove: ({ x }) => resizeTo(x),
      onEnd: (_event, canceled) => (canceled ? restore() : commit()),
    })
  },
}
```

这里 `resizeTo`、`restore` 和 `commit` 是你自己的分隔条方法。`bindDrag` 只跟踪指针；每个位置意味着什么由你决定，键盘控制也由你添加。

拖动分隔条，或者聚焦它并使用 Left 和 Right。拖动过程中按 Escape 可以恢复宽度。

`onMove` 每帧最多运行一次。如果浏览器接管了指针，或者 Escape 取消了拖动，`onEnd` 会收到一个取消标志。返回的清理函数会停止跟踪，但不调用 `onEnd`。

`dragThreshold` 会等待移动几个像素后才开始 `onMove`。一次按压仍可能在低于该阈值时就结束，所以不要假设每个 `onEnd` 前面都有一次移动。当拖动应当优先于滚动时，给可拖动的表面设置 `touch-action: none`。

### 越过阈值收起
侧边栏会在最小宽度和最大宽度之间调整大小，也可以收起，但绝不会停在两者之间。当指针低于最小值时，让 `scrubTo` 来决定：给它两个吸附点，收起和最小值，各自覆盖一半的范围，并朝它们缓动：

```ts
import { scrubTo } from "@ui-sdk/core/number"

const collapse = { min: 0, max: minWidth, step: 1, snap: { points: [0, minWidth], threshold: minWidth / 2 } }

const widthAt = (pointer: number) =>
  pointer >= minWidth ? { value: Math.min(maxWidth, pointer), point: undefined } : scrubTo(pointer, collapse, { ease: true })

onMove: ({ x }) => {
  const { value, point } = widthAt(x - root.getBoundingClientRect().left)
  store.set({ draft: value, landing: point ?? null })
},
onEnd: () => commit(store.get().landing ?? store.get().draft),
```

当指针移到最小值以下时，侧边栏会跟随它，并朝更近的那个点加速，于是逐渐接近收起，而不会突然跳变。`point` 表示它最终会落到哪里，所以演示可以在松开之前就说明；朝另一个方向拖动时，它也会以同样的方式展开。

把分隔条拖到侧边栏最小值以下：它会朝收起或回到最小值的方向缓动，并说明松手后会发生哪一种。聚焦分隔条后可以使用 Left、Right 和 Enter。

### 不受限制地拖动
对于拖动调节器（scrubber），指针锁定让用户能一直拖动，越过屏幕边缘。读取移动的距离，而不是指针的位置：

```ts
bindDrag(el, event, {
  threshold: dragThreshold,
  lock: true,
  onStart: () => !context.options().locked,
  onMove: ({ movementX, event }) => {
    change("value", context.store.get().value + movementX / 2, {
      reason: "drag",
      event,
    })
  },
  onEnd: () => {},
})
```

当移动达到阈值时，`onStart` 会运行。返回 `false` 会停止跟踪，但不调用 `onEnd`。如果浏览器无法锁定指针，跟踪会继续使用指针捕获。

把 Opacity 标签向左或向右拖动。指针锁定可用时，光标会隐藏，这样你可以一直拖。勾选 Locked 可以阻止拖动。

传给 `onMove` 的采样对象会被复用。在回调期间读取 `x`、`y`、`movementX`、`movementY`、`locked` 和 `event`，不要把这个对象留到以后再用。

## 重新排序
### 排序列表
把已提交的顺序保存在一个 `string[]` 里，并另起一个 `ReorderDraft | null` 字段，初始值为 `null`。在 `api` 里把它们接到 `createReorder`：

```ts
const change = createChange(context)
const reorder = createReorder(context, {
  slot: "item",
  key: "value",
  draft: "moving",
  set: (value, details) => change("value", value, details),
})
```

从 `api` 返回 `reorder`。用 `reorder.order(state)` 渲染条目，它在移动过程中读取草稿，其他时候读取已提交的值。顺序变化时，保持每个条目的键稳定。

条目的槽位会先运行重排处理函数，再运行已有的游走焦点处理函数。这样，在有人拿起条目之前，方向键仍然可以移动焦点：

```ts
on: {
  keydown: (event, { el, api, key }) =>
    api.reorder.keydown(event, key) || api.roving.keydown(event, el!),
  pointerdown: (event, { api, key }) => api.reorder.pointerdown(event, key),
},
bind: (el, part) => {
  const cleanups = [part.api.roving.bind(el, part), part.api.reorder.bind(el, part)]
  return () => cleanups.forEach((cleanup) => cleanup())
},
```

拖动一个季节来给它排名。使用键盘时，聚焦其中一个，按 Space 或 Enter，用方向键移动，再按 Space 或 Enter 放下。Escape 取消。

Home 和 End 把拿起的条目移到任意一端。Tab 取消移动，并继续在页面中移动焦点。变更会报告 `drag` 或 `move-key`，屏幕阅读器会听到拿起、移动和放下。

这个演示使用由 `option` 组成的 `listbox`，为可排序列表和条目设置 `aria-roledescription`，并为拿起的条目设置 `aria-selected`。给每个条目一个 `aria-describedby`，指向键盘操作说明。对于带嵌套控件的条目，使用列表并单独提供一个拖动手柄按钮，把处理函数放在那个手柄上。

拖动过程中，core 会把 `--drag-x` 和 `--drag-y` 写到绑定的条目上。用它们让条目保持在指针下方，并用 `state.moving?.key === key` 派生出 `data-grabbed` 属性：

```css
[data-slot="sortable-list-item"] {
  touch-action: none;
  user-select: none;
}
[data-slot="sortable-list-item"][data-grabbed] {
  transform: translate(var(--drag-x, 0), var(--drag-y, 0));
  position: relative;
  z-index: 1;
}
```

### 网格
默认方向是纵向。对于会换行成多行的条目，加上 `orientation: () => "grid"`：

```ts
orientation: () => "grid",
```

把照片拖到新位置，或者按 Space 拿起它。Left 和 Right 移动一个位置；Up 和 Down 在行之间移动。Space 放下它。

对于单行横向排列，使用 `"horizontal"`，给它的游走焦点设置相同的方向，并在列表框上设置 `aria-orientation="horizontal"`。

### 一次移动多个
`group` 回调让选中的一组条目一起移动。把它加到重排选项里：

```ts
group: (key) => {
  const { selected } = context.store.get()
  return selected.includes(key) ? selected : [key]
},
```

分组在拖动开始时确定，保持列表的顺序，并把已禁用的条目留在原处。`reorder.moving(state, key)` 标识分组里的每个条目；`reorder.dragging(state, key)` 还要求这是一次指针拖动。

勾选几个任务，然后拖动其中一个已勾选的任务。你也可以聚焦一个已勾选的任务，用 Space 和方向键移动整个分组。

已经用 `preventDefault()` 处理过的指针事件不会启动重排。这样，复选框可以处理自己的按压，而不会同时拿起条目。

### 拖动时显示副本
对于可滚动的列表，被平移的条目可能会被裁剪。加上 `preview: true`，在页面之上拖动一份副本：

```ts
preview: true,
createAutoScroll: { edge: 40, speed: 12 },
```

拖动一首曲目，并把它停在播放列表的顶部或底部边缘附近来滚动。它的占位符会显示它将落到哪里。

原条目会留在拟定的顺序里。使用分组时，副本还会获得 `data-drag-count` 和 `--drag-count`，用于显示数量徽标。自动滚动会随预览一起启用；用 `createAutoScroll: false` 关掉它。

### 用代码移动
对于立即发生的变更，比如菜单的 Move to Top 操作，使用 `move`：

```ts
reorder.move("Serve", 0)
```

对于一次只走一步的控件，使用 `grab(key)`、`moveTo(index)` 和 `drop()` 或 `cancel()`。`moveTo` 在移除正在移动的分组后剩下的条目之间计算位置。

使用 Top 立即移动一个食谱步骤。工具栏会拿起聚焦的步骤，移动它，然后放下或取消。

立即移动会报告 `imperative`；拿起和放下控件遵循与键盘相同的草稿。

### 播报什么
当条目的可见文本包含的内容多于它的名称时，使用 `label`。自定义 `message` 可以只替换一条播报，其余仍用默认值：

```ts
disabled: (item) => item.key === context.options().pinned,
label: (key) => titles[key],
message: (message) =>
  message.type === "move" ? `${message.label}, track ${message.position}.` : reorderMessage(message),
```

用 Space 拿起未固定的曲目，并用方向键移动它。屏幕阅读器会播报曲目编号。已固定的曲目不能被拿起，但其他曲目可以越过它移动。

`disabled` 阻止拿起；但它不会保留条目的位置。播报是即时（assertive）的，一轮中的多个变更可能作为最新消息一起播报。

## 重新排序树
### 排序与嵌套
树使用一个扁平的 `{ key, depth }` 行数组，按阅读顺序排列。移动父级会移动它的整个子树。把 `moving` 的初始值设为 `null`，类型为 `TreeReorderDraft | null`：

```ts
const tree = createTreeReorder(context, {
  key: "rows",
  draft: "moving",
  set: (value, details) => change("rows", value, details),
  indent: () => 20,
  preview: true,
})
```

渲染 `tree.rows(state)`，按 `depth` 缩进，并用 `tree.bind(el, key)` 绑定每个渲染出的行。也要保留游走焦点的绑定。和可排序列表一样，在焦点处理函数之前调用 `tree.keydown(event, key)`，在按压时调用 `tree.pointerdown(event, key)`。

把大纲行向上或向下拖动，横向拖动可以改变它的深度。使用键盘时，按 Space 拿起它，用 Up 和 Down 放置，用 Left 和 Right 改变它的层级。

`indent` 是一级的水平距离，默认 24 像素。关闭的子树可以留在数据里，而它们的行不挂载；指针命中会跳过这些隐藏的行。

一次移动不会改变相邻行的父级。深度受插入点周围行的限制。`set` 的详情包括 `key`、`parent`（根节点处为 `null`），以及在该父级子节点中从 0 开始的 `index`；当你的应用存储的是嵌套树时，这很有用。

### 限制与用代码移动
加上最大深度和拿起规则：

```ts
maxDepth: () => 1,
disabled: (key) => key === "Inbox",
```

深度从 0 开始，所以这里允许两层。限制包括正在移动的行及其后代。

使用文件夹的箭头按钮，把它连同内容一起缩进或取消缩进。树允许两层，Inbox 不能被拿起。

`tree.move(key, before, depth)` 把子树移到另一行之前；当 `before` 为 `null` 时，移到末尾。它会使用最接近且合适的深度。`subtreeEnd(rows, index)` 返回子树之后的第一个索引，有助于计算插入位置。

对于分步移动，使用 `grab`、`place`，然后 `drop` 或 `cancel`。`moving(state, key)` 包括后代；`dragging` 还会检查移动是否来自指针。像列表那样自定义 `label` 和 `message`，默认文案由 `treeReorderMessage` 提供。

## 在列表之间移动
### 两个列表
把各个列表一起存成一个 `Record<string, string[]>`，并让条目键在所有列表之间唯一。为移动添加一个 `TransferDraft | null` 字段：

```ts
const transfer = createTransfer(context, {
  key: "lists",
  draft: "moving",
  set: (value, details) => change("lists", value, details),
})
```

从 `transfer.lists(state)` 渲染。用 `bindList(el, key)` 绑定列表元素，用 `bindItem(el, key)` 绑定条目元素，并从槽位返回它们的清理函数。保留已有的焦点绑定，并在它的按键处理函数之前运行 `transfer.keydown(event, key)`。按压时调用 `transfer.pointerdown(event, key)`。

在打包清单之间拖动条目。使用键盘时，按 Space 拿起它，用 Left 和 Right 切换列表，用 Up 和 Down 放置，然后按 Space 放下。

移动使用一份被拖动的副本，并在靠近边缘时自动滚动。`moving(state, key)` 标识拿起的条目，而 `dragging(state, key)` 标识一次指针拖动。`set` 的详情包括条目的 `key`、它的 `from` 和 `to` 列表，以及它的新 `index`。

### 带规则的看板
用 `accepts` 拒绝某个目标，用 `order` 选择键盘在列表之间的行进顺序：

```ts
order: () => ["todo", "doing", "done"],
accepts: (key, list) =>
  list !== "doing" || context.store.get().lists.doing.filter((card) => card !== key).length < 2,
disabled: (key) => key === "Billing",
listLabel: (list) => columns[list],
```

在列之间移动卡片。Doing 最多容纳两张卡片，Billing 不能被拿起，卡片上的勾选会把它直接移到 Done。

`transfer.move("Search", "done", 0)` 会立即移动。对于分步移动，使用 `grab`、`moveTo(list, index)`，然后 `drop` 或 `cancel`。

`label` 为条目命名，`listLabel` 为目标命名，`message` 自定义播报，默认由 `transferMessage` 提供。对于不需要边缘滚动的看板，设置 `createAutoScroll: false`。

## 拖动副本
对于你自己的拖动，`bindDragPreview` 会创建一个跟随指针的元素副本。原元素留在原处：

```ts
const preview = bindDragPreview(el, { x: event.clientX, y: event.clientY })
```

在拖动的 `onMove` 里调用 `preview.move(x, y)`。在 `onEnd` 和任何提前清理中调用 `preview.remove()`。你可以通过 `preview.el` 给副本设置样式，例如在有效目标上方切换 `data-over` 属性。

把标签拖到便签上，当副本高亮时松开。你也可以聚焦一个标签并按 Enter 添加它。

副本在创建时保留元素的外观；它不会渲染之后框架的更新。它带有 `data-drag-preview`，移除了 ID，并且对辅助技术和指针命中隐藏。它在可用时使用顶层，否则回退到固定定位。

## 拖动时滚动
自定义拖动可以用 `createAutoScroll` 在指针附近滚动。为这次拖动创建它，每次移动时调用 `update(x, y)`，并在每次退出时调用 `stop()`：

```ts
const scroll = createAutoScroll({
  edge: 48,
  speed: 16,
  ignore: () => preview.el,
  onScroll: findChapter,
})
```

把书签拖到章节列表的顶部或底部边缘附近。保持在那里继续按住即可滚动，然后在某一章上松开。

`edge` 是开始滚动的距离，单位为像素；`speed` 是每帧的最大像素数。辅助函数会找到指针下方最近的滚动容器，并以页面的纵向滚动作为回退。`ignore` 会跳过某个元素，比如被拖动的副本。`onScroll` 让你在内容从静止的指针下方移过后重新找到目标。

## 保持焦点与草稿
排序行为已经会保留焦点，并在受控值赶上之前保持已提交的草稿可见。如果你要构建自己的拖动，在移动已聚焦的元素之后使用 [`keepFocus`](https://ui-sdk.cn/docs/core/behaviors/focus#focus-that-follows-a-move)，在把草稿交给它的所有者时使用 [`settleDraft`](https://ui-sdk.cn/docs/core/kernel/handle-changes#changes-from-elsewhere)。

## API 参考
选项表格会链接回介绍它们的示例。

- `onMove` (`(sample: PointerSample) => void`): At most once per frame, with the latest position and the movement since the last call. Example: [Follow a Pointer](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#follow-a-pointer).
- `onEnd` (`(event: PointerEvent, canceled: boolean) => void`): The pointer lifted, or the browser took it over, like for a scroll. A move still pending runs first, so the last position is never lost. Example: [Follow a Pointer](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#follow-a-pointer).
- `threshold?` (`number`): How far, in CSS pixels, the pointer moves along either axis before moves are reported, so a press that barely moves stays a click. Defaults to 0. Example: [Follow a Pointer](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#follow-a-pointer).
- `onStart?` (`((event: PointerEvent) => boolean | void)`): Runs once, on the first move past `threshold`, before its `onMove`. Return `false` to stop following the pointer, like when a drag can't start. Example: [Dragging Without Limits](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#dragging-without-limits).
- `lock?` (`boolean`): Locks the pointer once it has moved past `dragThreshold`, so it can travel without limit, like a scrub, while a plain click never hides the cursor. Falls back to capture where the browser refuses, as Safari does. Example: [Dragging Without Limits](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#dragging-without-limits).
- `cancelOnEscape?` (`boolean`): Ends the gesture as canceled when Escape is pressed once it has started, and keeps that press from reaching anything else, like a popup around it. `onEnd` gets the last pointer event. Defaults to `false`. Example: [Follow a Pointer](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#follow-a-pointer).

- `slot` (`string`): The slot whose parts are the items. Each joins in the slot's `bind` with `reorder.bind(el, part)`. Example: [Sort a List](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#sort-a-list).
- `key` (`keyof State & string`): The state key that holds the order, a `string[]` of item keys. Example: [Sort a List](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#sort-a-list).
- `draft` (`keyof State & string`): The state key that holds the `ReorderDraft` while an item moves. Start it at `null`. Example: [Sort a List](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#sort-a-list).
- `set` (`(value: string[], details: { reason: ReorderReason; event?: Event; }) => boolean`): Asks for a new order and returns whether it went through. Pass the primitive's change, so `on<Key>Change`, `cancel()` and controlled values work: `set: (value, details) => change("value", value, details)`. Example: [Sort a List](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#sort-a-list).
- `orientation?` (`(() => ReorderOrientation)`): Whether the items run top to bottom, along a line, or wrap in rows like a grid of photos, which picks the arrows and how a drag finds its place. Defaults to `"vertical"`. Example: [Grids](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#grids).
- `group?` (`((key: string) => string[])`): The keys that move with the one picked up, like the selection when it holds it. Defaults to that one key. Example: [Several at Once](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#several-at-once).
- `preview?` (`boolean`): Drags a copy of the item above the page while the item itself shows where it would drop, so a list that scrolls neither clips it nor grows under it. A drag near a scroller's edge scrolls it. Defaults to `false`. Example: [A Copy While Dragging](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#a-copy-while-dragging).
- `createAutoScroll?` (`false | Omit<AutoScrollOptions, "ignore" | "onScroll">`): How a drag with `preview` near a scroller's edge scrolls it, or `false` not to. Example: [A Copy While Dragging](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#a-copy-while-dragging).
- `disabled?` (`((item: { key: string; props: Props; }) => boolean)`): Whether an item can't be picked up. It still moves aside for others. Example: [What's Read Out](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#whats-read-out).
- `label?` (`((key: string) => string | undefined)`): The name screen readers hear for an item. Return `undefined` for the default, its text. Example: [What's Read Out](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#whats-read-out).
- `message?` (`((message: ReorderMessage) => string)`): The text screen readers hear for each step. Defaults to English. Example: [What's Read Out](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#whats-read-out).

- `key` (`keyof State & string`): The state key that holds the rows, a `TreeReorderRow[]` in reading order. Example: [Sort and Nest](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#sort-and-nest).
- `draft` (`keyof State & string`): The state key that holds the `TreeReorderDraft` while an item moves. Start it at `null`. Example: [Sort and Nest](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#sort-and-nest).
- `set` (`(value: TreeReorderRow[], details: { reason: TreeReorderReason; event?: Event; key: string; } & TreePlace) => boolean`): Asks for the new rows and returns whether they went through. Pass the primitive's change: `set: (value, details) => change("rows", value, details)`. `details` says which item moved and where to. Example: [Sort and Nest](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#sort-and-nest).
- `indent?` (`(() => number)`): How far a drag goes sideways for each level, in CSS pixels. Defaults to 24. Example: [Sort and Nest](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#sort-and-nest).
- `maxDepth?` (`(() => number)`): The deepest an item and the rows under it can go, from 0. Defaults to no limit. Example: [Limits and Moving from Code](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#limits-and-moving-from-code).
- `disabled?` (`((key: string) => boolean)`): Whether an item can't be picked up. It still moves aside for others. Example: [Limits and Moving from Code](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#limits-and-moving-from-code).
- `label?` (`((key: string) => string | undefined)`): The name screen readers hear for an item. Defaults to its text. Example: [Limits and Moving from Code](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#limits-and-moving-from-code).
- `message?` (`((message: TreeReorderMessage) => string)`): The text screen readers hear for each step. Defaults to English. Example: [Limits and Moving from Code](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#limits-and-moving-from-code).
- `preview?` (`boolean`): Drags a copy of the row above the page while the rows show where it would drop. Defaults to `false`. Example: [Sort and Nest](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#sort-and-nest).
- `createAutoScroll?` (`false | Omit<AutoScrollOptions, "ignore" | "onScroll">`): How a drag with `preview` near a scroller's edge scrolls it, or `false` not to. Example: [Sort and Nest](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#sort-and-nest).

- `key` (`keyof State & string`): The state key that holds every list, a `TransferLists`. Example: [Two Lists](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#two-lists).
- `draft` (`keyof State & string`): The state key that holds the `TransferDraft` while an item moves. Start it at `null`. Example: [Two Lists](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#two-lists).
- `set` (`(value: TransferLists, details: { reason: TransferReason; event?: Event; key: string; from: string; to: string; index: number; }) => boolean`): Asks for the new lists and returns whether they went through. Pass the primitive's change: `set: (value, details) => change("lists", value, details)`. `details` says what moved, from where to where. Example: [Two Lists](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#two-lists).
- `order?` (`(() => string[])`): The lists in the order Left and Right go through them. Defaults to the order of the value's keys. Example: [A Board with Rules](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#a-board-with-rules).
- `accepts?` (`((key: string, list: string) => boolean)`): Whether a list takes an item, like a column at its limit. Lists that don't are skipped. Example: [A Board with Rules](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#a-board-with-rules).
- `disabled?` (`((key: string) => boolean)`): Whether an item can't be picked up. Example: [A Board with Rules](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#a-board-with-rules).
- `label?` (`((key: string) => string | undefined)`): The name screen readers hear for an item. Defaults to its text. Example: [A Board with Rules](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#a-board-with-rules).
- `listLabel?` (`((list: string) => string | undefined)`): The name screen readers hear for a list. Defaults to its key. Example: [A Board with Rules](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#a-board-with-rules).
- `message?` (`((message: TransferMessage) => string)`): The text screen readers hear for each step. Defaults to English. Example: [A Board with Rules](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#a-board-with-rules).
- `createAutoScroll?` (`false | Omit<AutoScrollOptions, "ignore" | "onScroll">`): How a drag near a scroller's edge scrolls it, or `false` not to. Example: [A Board with Rules](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#a-board-with-rules).

- `edge?` (`number`): How far in from an edge scrolling starts, in pixels. Example: [Scrolling While Dragging](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#scrolling-while-dragging).
- `speed?` (`number`): The fastest it scrolls, in pixels per frame, with the pointer at the edge. Example: [Scrolling While Dragging](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#scrolling-while-dragging).
- `onScroll?` (`(() => void)`): Runs after each frame that scrolled, so a drag can find its target again under a pointer that didn't move. Example: [Scrolling While Dragging](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#scrolling-while-dragging).
- `ignore?` (`(() => Element | null | undefined)`): The element being dragged, which sits under the pointer, so the scrollers under it are found instead of its own. Example: [Scrolling While Dragging](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#scrolling-while-dragging).
