# 所有行为

了解焦点、选择、浮层，以及构成组件的其他片段。

按主题浏览这些辅助函数。每个名称都链接到对应的指南和示例。

除非标明了其他入口，否则从 `@ui-sdk/core` 导入辅助函数。

## 焦点与按键
| 辅助函数                                                             | 作用                                                |
| -------------------------------------------------------------------- | --------------------------------------------------- |
| [`createRovingFocus`](https://ui-sdk.cn/docs/core/behaviors/focus#roving-focus)                          | 让一组部件只有一个 Tab 停靠点，并用方向键移动焦点。 |
| [`createGridFocus`](https://ui-sdk.cn/docs/core/behaviors/focus#grids)                                   | 按行和列移动焦点，包括尚未渲染的单元格。            |
| [`byCell`](https://ui-sdk.cn/docs/core/behaviors/focus#one-tab-stop-in-a-grid)                           | 只更新焦点离开的单元格和落到的单元格。              |
| [`spatialMove`](https://ui-sdk.cn/docs/core/behaviors/focus#spatial-focus)                               | 根据条目在屏幕上的位置选择下一个条目。              |
| [`nearestInDirection`](https://ui-sdk.cn/docs/core/behaviors/focus#choose-a-target-without-moving-focus) | 在某个方向上找到最近的条目，但不移动焦点。          |
| [`createTypeahead`](https://ui-sdk.cn/docs/core/behaviors/focus#typeahead)                               | 在有人输入名称时找到对应条目。                      |
| [`createFocusRecovery`](https://ui-sdk.cn/docs/core/behaviors/focus#focus-recovery)                      | 聚焦的条目被移除时恢复焦点。                        |
| [`keepFocus`](https://ui-sdk.cn/docs/core/behaviors/focus#focus-that-follows-a-move)                     | 在移动元素的变更过程中保持焦点。                    |
| [`inputHints`](https://ui-sdk.cn/docs/core/behaviors/focus#input-hints)                                  | 为某类字段选择屏幕键盘和自动填充。                  |

## 文本
| 辅助函数                                                      | 作用                                                 |
| ------------------------------------------------------------- | ---------------------------------------------------- |
| [`createInputHistory`](https://ui-sdk.cn/docs/core/text#bring-back-earlier-messages)   | 像终端一样，用 ArrowUp 和 ArrowDown 调出更早的条目。 |
| [`isTypeaheadKey`](https://ui-sdk.cn/docs/core/text#find-an-item-by-typing)            | 检查某个按键能否用于键入查找（typeahead）。          |
| [`labelOf`](https://ui-sdk.cn/docs/core/text#what-an-item-is-called)                   | 读取元素的标签，用来匹配输入的文字。                 |
| [`isComposing`](https://ui-sdk.cn/docs/core/text#properly-handle-input-method-editors) | 检查某个输入事件是否属于仍在组合中的文字。           |
| [`pageLocale`](https://ui-sdk.cn/docs/core/text#the-pages-language)                    | 读取页面的语言，或页面中某一节的语言。               |
| [`userLocale`](https://ui-sdk.cn/docs/core/text#the-pages-language)                    | 读取浏览器偏好的语言。                               |
| [`toLocale`](https://ui-sdk.cn/docs/core/text#tags-from-elsewhere)                     | 把 `en_US` 这样的标签转换成 `Intl` 接受的形式。      |

### 搜索匹配
从 `@ui-sdk/core/text-match` 导入这些辅助函数。

| 辅助函数                                               | 作用                                     |
| ------------------------------------------------------ | ---------------------------------------- |
| [`fuzzyScore`](https://ui-sdk.cn/docs/core/text#rank-what-someone-searches-for) | 给一段文字与输入内容的匹配程度打分。     |
| [`matchRanges`](https://ui-sdk.cn/docs/core/text#highlight-what-matched)        | 找出输入的文字在一段文字中出现的位置。   |
| [`matchSegments`](https://ui-sdk.cn/docs/core/text#highlight-what-matched)      | 把文字拆成匹配和未匹配的片段，供你渲染。 |

## 选择
| 辅助函数                                              | 作用                                 |
| ----------------------------------------------------- | ------------------------------------ |
| [`createSelection`](https://ui-sdk.cn/docs/core/behaviors/selection#selecting-items)      | 跟踪选中的条目，包括多选和范围选择。 |
| [`createLasso`](https://ui-sdk.cn/docs/core/behaviors/selection#rectangle-selection)      | 选中被指针画出的矩形碰到的条目。     |
| [`createCellRange`](https://ui-sdk.cn/docs/core/behaviors/selection#ranges-of-cells)      | 选中网格中一个矩形范围的单元格。     |
| [`byCellRange`](https://ui-sdk.cn/docs/core/behaviors/selection#select-a-block)           | 只更新加入或离开范围的单元格。       |
| [`cellRangeMessage`](https://ui-sdk.cn/docs/core/behaviors/selection#selecting-from-code) | 为一组单元格提供默认的播报。         |
| [`cellsToText`](https://ui-sdk.cn/docs/core/behaviors/selection#copy-and-paste)           | 把单元格的值转换成文本，用于复制。   |
| [`textToCells`](https://ui-sdk.cn/docs/core/behaviors/selection#copy-and-paste)           | 把粘贴的文本解析成一行行的单元格值。 |

## 拖放
| 辅助函数                                                            | 作用                                 |
| ------------------------------------------------------------------- | ------------------------------------ |
| [`bindDrag`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#pointer-drags)                         | 用捕获、阈值和取消来跟踪指针拖拽。   |
| [`dragThreshold`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#follow-a-pointer)                 | 把标准拖拽阈值设为 3 像素。          |
| [`createReorder`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#reordering)                       | 用指针或键盘重新排序列表或网格。     |
| [`createTreeReorder`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#reordering-a-tree)            | 重排树条目，并连同其子孙一起嵌套。   |
| [`createTransfer`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#moving-between-lists)            | 在列表内或列表之间移动条目。         |
| [`bindDragPreview`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#dragging-a-copy)                | 在页面之上显示被拖拽元素的副本。     |
| [`createAutoScroll`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#scrolling-while-dragging)      | 拖拽接近容器边缘时滚动容器。         |
| [`settleDraft`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#keeping-focus-and-the-draft)        | 在受控值跟上之前保持草稿可见。       |
| [`reorderMessage`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#whats-read-out)                  | 为列表重排提供默认的播报。           |
| [`subtreeEnd`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#limits-and-moving-from-code)         | 找出子树之后的第一个行索引。         |
| [`treeReorderMessage`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#limits-and-moving-from-code) | 为树的重排提供默认的播报。           |
| [`transferMessage`](https://ui-sdk.cn/docs/core/behaviors/drag-and-drop#a-board-with-rules)             | 为在列表之间移动条目提供默认的播报。 |

## 拖动与调整大小
| 辅助函数                                                             | 作用                                           |
| -------------------------------------------------------------------- | ---------------------------------------------- |
| [`createMove`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#moving-in-two-dimensions)       | 用指针或键盘移动自由定位的对象。               |
| [`createResize`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#resizing-boxes)               | 从边缘和角调整盒子的大小。                     |
| [`createSwipeActions`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#swiping-rows-aside)     | 显示行背后的动作，并支持滑动到底触发的动作。   |
| [`bindHold`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#pressing-and-holding)             | 按住时执行动作，并可在按住期间重复执行。       |
| [`bindRepeat`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#repeat-while-held)              | 按下按钮时步进一次，按住期间持续步进。         |
| [`createArea`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#two-dimensional-values)         | 沿两个轴选取一个值，比如面板上的一个点。       |
| [`createSpans`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#ranges-on-tracks)              | 在轨道上绘制、移动和调整范围。                 |
| [`stackSpans`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#days-that-run-down)             | 把重叠的范围放进不同的泳道。                   |
| [`createPreview`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#previews)                    | 跟踪一个在选定之前正在试用的值。               |
| [`moveMessage`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#several-at-once)               | 为位置变更提供默认的播报。                     |
| [`resizeMessage`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#several-boxes-and-from-code) | 为调整盒子大小提供默认的播报。                 |
| [`isSpanFree`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#changing-ranges-from-code)      | 检查提议的范围是否与同一轨道上的其他范围重叠。 |
| [`spansMessage`](https://ui-sdk.cn/docs/core/behaviors/direct-manipulation#changing-ranges-from-code)    | 为范围的变更提供默认的播报。                   |

## 列表
| 辅助函数                                                     | 作用                                                 |
| ------------------------------------------------------------ | ---------------------------------------------------- |
| [`createListbox`](https://ui-sdk.cn/docs/core/behaviors/lists#options-you-search)                | 用方向键高亮选项，并在有人输入时过滤它们。           |
| [`createVirtualizer`](https://ui-sdk.cn/docs/core/behaviors/lists#long-lists)                    | 计算要渲染哪些行，以及把它们放在哪里。               |
| [`createStickToBottom`](https://ui-sdk.cn/docs/core/behaviors/lists#logs-that-follow-their-end)  | 跟随新内容，同时在读者向上滚动时保留他们所在的位置。 |
| [`bindScrollPicker`](https://ui-sdk.cn/docs/core/behaviors/lists#wheels-you-scroll-to-pick-from) | 像滚轮一样，选中滚动列表中央的选项。                 |
| [`createInlineEdit`](https://ui-sdk.cn/docs/core/behaviors/lists#editing-in-place)               | 就地管理值的编辑、提交和取消。                       |

## 树
| 辅助函数                                            | 作用                                             |
| --------------------------------------------------- | ------------------------------------------------ |
| [`createTreeCollection`](https://ui-sdk.cn/docs/core/behaviors/trees#a-trees-shape)     | 查找父节点、子节点、层级和可见节点。             |
| [`treeDataNodes`](https://ui-sdk.cn/docs/core/behaviors/trees#tree-data-and-file-paths) | 把嵌套条目转换成树集合所需的节点。               |
| [`treeFromPaths`](https://ui-sdk.cn/docs/core/behaviors/trees#tree-data-and-file-paths) | 从文件路径构建嵌套的树数据。                     |
| [`visibleTreeRows`](https://ui-sdk.cn/docs/core/behaviors/trees#flat-rows)              | 把展开的分支展平成行，附带父级、层级和索引数据。 |
| [`treeCheckedStates`](https://ui-sdk.cn/docs/core/behaviors/trees#check-a-branch)       | 计算整棵树中选中、未选中和混合的状态。           |
| [`toggleTreeChecked`](https://ui-sdk.cn/docs/core/behaviors/trees#check-a-branch)       | 切换节点时返回下一个选中值。                     |

## 过渡与手势
| 辅助函数                                                       | 作用                                           |
| -------------------------------------------------------------- | ---------------------------------------------- |
| [`bindPanel`](https://ui-sdk.cn/docs/core/behaviors/motion#panels-and-presence)                    | 打开或关闭时协调面板高度、过渡和焦点。         |
| [`hiddenAttrs`](https://ui-sdk.cn/docs/core/behaviors/motion#find-in-page-and-opening-at-once)     | 为隐藏内容或可搜索内容设置可见性属性。         |
| [`bindFindable`](https://ui-sdk.cn/docs/core/behaviors/motion#find-in-page-on-its-own)             | 浏览器找到匹配时显示隐藏内容。                 |
| [`supportsHiddenUntilFound`](https://ui-sdk.cn/docs/core/behaviors/motion#find-in-page-on-its-own) | 检查浏览器能否搜索隐藏内容。                   |
| [`animateIn`](https://ui-sdk.cn/docs/core/behaviors/motion#entering-and-leaving)                   | 应用 CSS 入场动画的起始状态。                  |
| [`animateOut`](https://ui-sdk.cn/docs/core/behaviors/motion#entering-and-leaving)                  | 应用退出状态，并在动画结束后调用你的完成回调。 |

### 手势计算
从 `@ui-sdk/core/gesture` 导入这些辅助函数。

| 辅助函数                                               | 作用                                         |
| ------------------------------------------------------ | -------------------------------------------- |
| [`createVelocityTracker`](https://ui-sdk.cn/docs/core/behaviors/motion#throws-and-springs) | 根据最近的指针位置测量速度。                 |
| [`projectDistance`](https://ui-sdk.cn/docs/core/behaviors/motion#throws-and-springs)       | 估算一个运动中的值减速后还会走多远。         |
| [`solveSpring`](https://ui-sdk.cn/docs/core/behaviors/motion#throws-and-springs)           | 计算弹簧的位置和速度随时间的变化。           |
| [`rubberBand`](https://ui-sdk.cn/docs/core/behaviors/motion#past-an-edge)                  | 值越过边缘时增加阻力。                       |
| [`sectorOf`](https://ui-sdk.cn/docs/core/behaviors/motion#which-way-a-stroke-points)       | 把笔画的方向转换成扇区，比如径向菜单的一项。 |

## 浮层与图层
| 辅助函数                                                             | 作用                                               |
| -------------------------------------------------------------------- | -------------------------------------------------- |
| [`createPopup`](https://ui-sdk.cn/docs/core/behaviors/popups#make-your-own)                              | 使用浮层预设管理打开、关闭、定位和焦点。           |
| [`popupState`](https://ui-sdk.cn/docs/core/behaviors/popups#a-popup-of-your-own)                         | 创建初始的打开、挂载和payload状态。                |
| [`popupTrigger`](https://ui-sdk.cn/docs/core/behaviors/popups#a-popup-of-your-own)                       | 构建一个打开和关闭浮层的触发槽位。                 |
| [`popupContent`](https://ui-sdk.cn/docs/core/behaviors/popups#a-popup-of-your-own)                       | 构建一个带有呈现、放置和焦点处理的内容槽位。       |
| [`popupClose`](https://ui-sdk.cn/docs/core/behaviors/popups#a-popup-of-your-own)                         | 构建一个关闭浮层的槽位。                           |
| [`popupTitle`](https://ui-sdk.cn/docs/core/behaviors/popups#one-popup-many-triggers)                     | 把可见标题连接到浮层的无障碍名称。                 |
| [`popupDescription`](https://ui-sdk.cn/docs/core/behaviors/popups#one-popup-many-triggers)               | 把描述性文字连接到浮层。                           |
| [`popupArrow`](https://ui-sdk.cn/docs/core/behaviors/popups#one-popup-many-triggers)                     | 构建一个跟随浮层放置位置的箭头槽位。               |
| [`popupBackdrop`](https://ui-sdk.cn/docs/core/behaviors/popups#every-part-and-parts-of-your-own)         | 构建模态浮层后面的背景槽位。                       |
| [`popupViewport`](https://ui-sdk.cn/docs/core/behaviors/popups#every-part-and-parts-of-your-own)         | 为浮层底部面板（sheet）构建全屏容器槽位。          |
| [`popupSlots`](https://ui-sdk.cn/docs/core/behaviors/popups#every-part-and-parts-of-your-own)            | 一起构建标准的浮层部件。                           |
| [`position`](https://ui-sdk.cn/docs/core/behaviors/popups#placing-a-popup)                               | 把元素放在锚点（anchor）旁边，并更新它的放置位置。 |
| [`bindLayer`](https://ui-sdk.cn/docs/core/behaviors/popups#layers-of-your-own)                           | 为 Escape 和外部按压关闭注册一个浮动元素。         |
| [`bindPersistentLayer`](https://ui-sdk.cn/docs/core/behaviors/popups#modal-layers-and-what-stays-usable) | 让元素在各个图层之间保持可用，包括模态浮层。       |
| [`isDismissal`](https://ui-sdk.cn/docs/core/behaviors/popups#modal-layers-and-what-stays-usable)         | 识别关闭原因，比如 Escape 或外部按压。             |
| [`supportsTopLayer`](https://ui-sdk.cn/docs/core/behaviors/popups#types-and-the-top-layer)               | 检查浏览器是否支持浮层所用的顶层。                 |

[浮层预设](https://ui-sdk.cn/docs/core/behaviors/popups#pick-its-behavior)为 popover、dialog、tooltip 或 hover card 选择交互方式。[浮层控制器](https://ui-sdk.cn/docs/core/behaviors/popups#open-from-code)从代码打开现有的浮层组件，并等待结果。各自从对应的组件入口导入，比如 `@ui-sdk/core/popover`。

## 偏好设置
| 辅助函数                                                           | 作用                                                       |
| ------------------------------------------------------------------ | ---------------------------------------------------------- |
| [`createPreference`](https://ui-sdk.cn/docs/core/behaviors/preferences#create-a-preference)            | 保存列表中的一个选择，通知订阅者，并可在多次访问之间保存。 |
| [`createColorScheme`](https://ui-sdk.cn/docs/core/behaviors/preferences#choose-a-color-scheme)         | 基于偏好设置选择浅色、深色或浏览器的配色方案。             |
| [`colorSchemeOf`](https://ui-sdk.cn/docs/core/behaviors/preferences#browser-preferences-on-the-server) | 读取浏览器随请求发送的配色方案。                           |
| [`preferencesScript`](https://ui-sdk.cn/docs/core/behaviors/preferences#server-rendering)              | 在首次绘制之前把已保存的偏好写入对应的属性。               |
| [`createPointerKind`](https://ui-sdk.cn/docs/core/mobile#pointer-kind)                      | 报告主指针是手指还是鼠标，以及它能否悬停。                 |
| [`pointerKindOf`](https://ui-sdk.cn/docs/core/mobile#render-on-the-server)                  | 根据请求头推测指针类型。                                   |

### 存储
| 辅助函数                                                        | 作用                                                           |
| --------------------------------------------------------------- | -------------------------------------------------------------- |
| [`createLocalStorage`](https://ui-sdk.cn/docs/core/storage#keep-a-value)                 | 把值保存在 localStorage 中，对所有标签页有效，直到被移除。     |
| [`createSessionStorage`](https://ui-sdk.cn/docs/core/storage#keep-a-value)               | 把值保存在 sessionStorage 中，仅对当前标签页有效，直到它关闭。 |
| [`createCookieStorage`](https://ui-sdk.cn/docs/core/storage#read-a-cookie-on-the-server) | 把值保存在 cookie 中，服务器也能读取。                         |

## 画布
| 辅助函数                                             | 作用                                             |
| ---------------------------------------------------- | ------------------------------------------------ |
| [`createViewport`](https://ui-sdk.cn/docs/core/behaviors/canvas#panning-and-zooming)     | 平移和缩放画布，并在屏幕坐标与画布坐标之间转换。 |
| [`createConnect`](https://ui-sdk.cn/docs/core/behaviors/canvas#connections)              | 用指针或键盘跟踪端口之间的连接。                 |
| [`connectMessage`](https://ui-sdk.cn/docs/core/behaviors/canvas#snapping-words-and-code) | 为连接步骤提供默认的播报。                       |

## 平台
| 辅助函数                                                   | 作用                                       |
| ---------------------------------------------------------- | ------------------------------------------ |
| [`announce`](https://ui-sdk.cn/docs/core/platform#announcements)                    | 向屏幕阅读器读出消息。                     |
| [`prepareAnnouncements`](https://ui-sdk.cn/docs/core/platform#urgent-announcements) | 在第一条消息之前添加屏幕阅读器监听的区域。 |
| [`isRTL`](https://ui-sdk.cn/docs/core/platform#direction)                           | 检查元素的文字是否从右到左排列。           |
| [`matchesShortcut`](https://ui-sdk.cn/docs/core/platform#shortcuts)                 | 检查按键是否匹配某个快捷键，比如 `mod+b`。 |
| [`formatShortcut`](https://ui-sdk.cn/docs/core/platform#shortcuts)                  | 按用户所在平台的显示方式写出快捷键。       |
| [`ariaKeyshortcuts`](https://ui-sdk.cn/docs/core/platform#shortcuts)                | 把快捷键写成 `aria-keyshortcuts` 的值。    |

### 移动端
| 辅助函数                                                       | 作用                           |
| -------------------------------------------------------------- | ------------------------------ |
| [`bindViewport`](https://ui-sdk.cn/docs/core/mobile#follow-the-viewport)                | 跟随可见视口，并报告每次变化。 |
| [`bindAvoidKeyboard`](https://ui-sdk.cn/docs/core/mobile#keep-a-bar-above-the-keyboard) | 把元素抬到屏幕键盘之上。       |

## 变更与历史
| 辅助函数                                                                 | 作用                                                    |
| ------------------------------------------------------------------------ | ------------------------------------------------------- |
| [`createChange`](https://ui-sdk.cn/docs/core/kernel/handle-changes#changes)                       | 请求变更状态值，先调用它的回调。                        |
| [`createCommit`](https://ui-sdk.cn/docs/core/kernel/handle-changes#commits)                       | 交互结束时上报最终值。                                  |
| [`dispatch`](https://ui-sdk.cn/docs/core/kernel/handle-changes#events-that-arent-state)           | 调用动作的回调，比如 `onDelete`，并告诉你它是否被取消。 |
| [`createUndoStack`](https://ui-sdk.cn/docs/core/kernel/handle-changes#undo)                       | 保存你记录的值快照，以便撤销和重做。                    |
| [`createController`](https://ui-sdk.cn/docs/core/kernel/handle-changes#controllers)               | 让组件外部的代码调用它的方法。                          |
| [`sourceOf`](https://ui-sdk.cn/docs/core/kernel/handle-changes#how-people-are-working)            | 判断事件来自鼠标、触摸、笔、键盘还是代码。              |
| [`isFocusFromKeyboard`](https://ui-sdk.cn/docs/core/kernel/handle-changes#how-people-are-working) | 检查焦点是否刚刚由键盘带来。                            |

### 观察变更
从 `@ui-sdk/core/observe` 导入这些辅助函数。

| 辅助函数                                                  | 作用                                |
| --------------------------------------------------------- | ----------------------------------- |
| [`observe`](https://ui-sdk.cn/docs/core/observe#listen-for-changes)                | 页面上组件每次变更时都会调用你。    |
| [`elementOf`](https://ui-sdk.cn/docs/core/observe#find-the-element)                | 找到发出变更的组件的元素。          |
| [`withSource`](https://ui-sdk.cn/docs/core/observe#keep-the-source-after-an-await) | 让变更的来源跨过 `await` 保留下来。 |

## 构建块
| 辅助函数                                                            | 作用                                           |
| ------------------------------------------------------------------- | ---------------------------------------------- |
| [`definePrimitive`](https://ui-sdk.cn/docs/core/kernel/define-a-primitive#defineprimitive)   | 为所有框架统一定义一个组件的选项、状态和部件。 |
| [`idPart`](https://ui-sdk.cn/docs/core/kernel/define-a-primitive#parts-that-come-and-go)     | 转义条目值，让它能成为 id 的一部分。           |
| [`elements`](https://ui-sdk.cn/docs/core/kernel/define-a-primitive#reading-parts-in-the-api) | 按页面顺序返回组件已绑定的部件。               |
| [`openAttrs`](https://ui-sdk.cn/docs/core/kernel/define-a-primitive#naming)                  | 返回打开或关闭部件常用的属性。                 |
| [`checkedAttrs`](https://ui-sdk.cn/docs/core/kernel/define-a-primitive#naming)               | 返回选中、未选中或混合状态部件常用的属性。     |
| [`css`](https://ui-sdk.cn/docs/core/kernel/style-a-component#pass-values-as-css-variables)   | 把样式声明转换成 `style` 属性，并跳过空值。    |
| [`live`](https://ui-sdk.cn/docs/core/kernel/handle-changes#live-state)                       | 为频繁变化的状态写入属性，无需再次渲染。       |
| [`selects`](https://ui-sdk.cn/docs/core/kernel/handle-changes#live-state)                    | 告诉每个部件它需要关注哪些状态变更。           |
| [`direct`](https://ui-sdk.cn/docs/core/kernel/handle-changes#attributes-kept-current)        | 在两次渲染之间保持所选属性最新。               |

## Agent
从 `@ui-sdk/core/agent` 导入这些辅助函数。

| 辅助函数                                                                    | 作用                                                   |
| --------------------------------------------------------------------------- | ------------------------------------------------------ |
| [`createAgent`](https://ui-sdk.cn/docs/agents/connect-an-agent/reference#createagentoptions) | 让智能体读取页面上的组件并使用它们。                   |
| [`agentTools`](https://ui-sdk.cn/docs/agents/connect-an-agent/reference#agenttools)          | 为你的模型描述 `snapshot`、`act` 和 `query` 三个工具。 |
| [`registerTools`](https://ui-sdk.cn/docs/agents/connect-an-agent/webmcp#register-the-tools)  | 把这些工具提供给浏览器内置的智能体。                   |

### 历史
从 `@ui-sdk/core/history` 导入这些辅助函数。

| 辅助函数                                                                           | 作用                                                                       |
| ---------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| [`createHistory`](https://ui-sdk.cn/docs/agents/connect-an-agent/history-and-undo#start-recording)  | 记录页面上组件的每一次变更以及是谁做的，让你可以回退或撤销某个来源的变更。 |
| [`describeEntry`](https://ui-sdk.cn/docs/agents/connect-an-agent/history-and-undo#read-the-history) | 为一条历史记录写一句简短的说明。                                           |
| [`stageChanges`](https://ui-sdk.cn/docs/agents/connect-an-agent/history-and-undo#try-a-suggestion)  | 在真实控件上试用一组值，并让你把旧值放回去。                               |

## 值与测试
[数字](/docs/core/number)、[日期](/docs/core/date)、[颜色](/docs/core/color)和[图片](/docs/core/image)涵盖每种值的格式化、解析和运算。它们各有自己的入口，比如 `@ui-sdk/core/number`。[测试](/docs/core/testing)涵盖对你自己的组件的检查。
