@bixlab/mtone 0.13.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +97 -6
- package/dist/index.js +2902 -2059
- package/dist/styles.css +1 -1
- package/llms.txt +272 -8
- package/package.json +1 -1
package/llms.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Ready-styled React UI library built on Base UI, Tailwind CSS and Lucide icons. Install one package, not individual copied components.
|
|
4
4
|
|
|
5
|
-
This file describes this package checkout, not necessarily the latest published npm release. Package version: 0.
|
|
5
|
+
This file describes this package checkout, not necessarily the latest published npm release. Package version: 0.15.0. Prefer the llms.txt and dist/index.d.ts bundled with your installed version over the live website, which follows master.
|
|
6
6
|
|
|
7
7
|
## Setup
|
|
8
8
|
|
|
@@ -22,8 +22,10 @@ This file describes this package checkout, not necessarily the latest published
|
|
|
22
22
|
- Pair controlled values/open state with the documented change callbacks; defaultValue/defaultOpen are for uncontrolled initial state.
|
|
23
23
|
- Give controls accessible labels and icon-only buttons aria-label. Keep keyboard/focus behavior intact. Focus uses --mt-focus (#93B4DC): existing input borders change color only; other controls use a single 1px inset edge without changing layout. Select option highlights remain background-only in all modes.
|
|
24
24
|
- Shared theme accents: use --mt-accent-neutral/blue/green/orange/red/purple/teal/coral with CSS var() or override the matching keys via MtoneProvider tokens. Tabs indicatorColor accepts these preset names or a CSS color for the selected line only.
|
|
25
|
+
- Semantic colors select a purpose, not a hue: --mt-select-surface for selected surfaces, --mt-focus for keyboard focus, --mt-alert-info-bg for an info surface. New role overrides limit changes to that purpose and preserve legacy CSS fallbacks when unset; existing hue presets remain public.
|
|
26
|
+
- Selected surfaces: use --mt-select-surface for pale-blue selected items and located settings rows. It is #E9EEF4 in light and #293746 in dark mode, not an accent color or focus-border token.
|
|
25
27
|
- Dialog modal defaults true: outside clicks do not close; false allows outside dismissal. Both retain focus trapping, backdrop and scroll lock. Escape and close button remain available.
|
|
26
|
-
- Use Tag for content labels with optional removal, and Status for a state indicator.
|
|
28
|
+
- Use Tag for content labels with optional removal, and Status for a state indicator. BlockEditor is documented separately and belongs to the optional @bixlab/mtone-blocknote package, not this npm package. Upload requires an application service; examples are not backend persistence. DatePicker uses native browser date UI.
|
|
27
29
|
- Toast notifications need ToastProvider; useToast exposes add, success, error, info, update, promise and close (verify installed declarations before use).
|
|
28
30
|
- Do not assume the live docs match an older npm package. Type-check generated code and run interaction tests.
|
|
29
31
|
|
|
@@ -31,13 +33,46 @@ This file describes this package checkout, not necessarily the latest published
|
|
|
31
33
|
|
|
32
34
|
- [Getting started](https://xingjianxu.github.io/mtone/#/start): installation and AI usage
|
|
33
35
|
- [Theme and styling](https://xingjianxu.github.io/mtone/#/theme): color modes and tokens
|
|
34
|
-
- [Shared color presets](https://xingjianxu.github.io/mtone/#/theme/color-presets):
|
|
36
|
+
- [Shared color presets](https://xingjianxu.github.io/mtone/#/theme/color-presets): hue presets, semantic roles, and scoped overrides
|
|
35
37
|
- [Component gallery](https://xingjianxu.github.io/mtone/#/gallery): independent component examples
|
|
36
38
|
- [Application showcase](https://xingjianxu.github.io/mtone/showcase.html): interactive in-memory demo, not a backend
|
|
37
39
|
- [Source repository](https://github.com/xingjianxu/mtone): current code and migration notes
|
|
38
40
|
|
|
39
41
|
## Components
|
|
40
42
|
|
|
43
|
+
### BlockEditor
|
|
44
|
+
|
|
45
|
+
- [BlockEditor](https://xingjianxu.github.io/mtone/#/components/BlockEditor): 可选的块编辑器:BlockNote 管理正文与选区,mtone 提供工具栏、菜单和主题。独立于主包。
|
|
46
|
+
- Import: BlockEditor from @bixlab/mtone-blocknote
|
|
47
|
+
- initialContent: readonly BlockEditorInput[]. 只在创建该文档时读取;支持正文、标题、项目/编号列表、待办项、引用和代码块。默认空段落。
|
|
48
|
+
- documentKey: string | number. 换文档时修改键;新文档单独读取 initialContent,旧撤销历史不保留。
|
|
49
|
+
- onChange: (blocks: BlockEditorBlock[]) => void. 内容改变时返回 BlockNote JSON。由应用决定怎样保存、验证和重新加载。
|
|
50
|
+
- readOnly: boolean (default: false). 显示不可编辑正文与链接,不显示工具栏;不替代应用权限校验。
|
|
51
|
+
- label / locale / className: string / 'zh' | 'en' / string. 正文的无障碍名称、界面语言和外层样式。语言未指定时继承 mtone,主题同步继承。
|
|
52
|
+
- 编辑器单独安装:npm install @bixlab/mtone @bixlab/mtone-blocknote。请以 npm 可用版本为准。主包不包含、也不依赖编辑器。
|
|
53
|
+
- 导入两份 CSS;Next.js 使用客户端组件,推荐动态导入并设置 ssr: false。移动端 viewport 建议加 interactive-widget=resizes-content。
|
|
54
|
+
- 键入 / 或点 + 添加块;选择文本后可设置格式与链接。当前块菜单支持下方插入、复制、上移、下移、删除。拖拽、附件与表格编辑尚未包含。
|
|
55
|
+
- 原生 JSON 是主存储格式。只读只影响界面。外部内容仍需由应用验证来源、权限以及数据结构。
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { BlockEditor, type BlockEditorBlock } from "@bixlab/mtone-blocknote";
|
|
59
|
+
import "@bixlab/mtone/styles.css";
|
|
60
|
+
import "@bixlab/mtone-blocknote/styles.css";
|
|
61
|
+
|
|
62
|
+
export default function Demo() {
|
|
63
|
+
const save = (blocks: BlockEditorBlock[]) => {
|
|
64
|
+
localStorage.setItem("meeting-draft", JSON.stringify(blocks));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return <BlockEditor
|
|
68
|
+
documentKey="meeting-draft"
|
|
69
|
+
label="会议笔记"
|
|
70
|
+
initialContent={[{ type: "heading", props: { level: 1 }, content: "会议笔记" }]}
|
|
71
|
+
onChange={save}
|
|
72
|
+
/>;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
41
76
|
### CheckCard
|
|
42
77
|
|
|
43
78
|
- [CheckCard](https://xingjianxu.github.io/mtone/#/components/CheckCard): 以卡片呈现可选项。独立使用可勾选,CheckCard.Group 管理单选或多选,CardGroup 负责响应式排列。
|
|
@@ -235,6 +270,55 @@ export default function Demo() {
|
|
|
235
270
|
}
|
|
236
271
|
```
|
|
237
272
|
|
|
273
|
+
### Panel
|
|
274
|
+
|
|
275
|
+
- [Panel](https://xingjianxu.github.io/mtone/#/components/Panel): IDE 风格的标签面板,可独立使用,也可与 Splitter 组合停靠和调节大小。
|
|
276
|
+
- Import: Panel from @bixlab/mtone
|
|
277
|
+
- items: Pick<TabItem, 'value' | 'label' | 'content' | 'disabled' | 'icon'>[]. 标签数据。已访问的标签内容在切换和收起后保持挂载。
|
|
278
|
+
- label: string. 标签列表的无障碍名称。
|
|
279
|
+
- value / defaultValue / onValueChange: string / string / (value: string) => void. 受控或非受控的选中标签。
|
|
280
|
+
- size: "sm" | "md" | "lg" (default: "md"). 标签项含边框的高度为 28px、32px 或 36px;横向标签栏随之调整。不会改变展开时的外部分栏尺寸。
|
|
281
|
+
- tabPlacement: "top" | "bottom" | "left" | "right" (default: "top"). 标签栏相对内容的物理方位,与 Panel 的外部停靠无关。左右为纵向标签栏。
|
|
282
|
+
- actions: ReactNode. 标签栏末端的附加操作,收起时仍可操作。
|
|
283
|
+
- collapsed / defaultCollapsed / onCollapsedChange: boolean / boolean / (collapsed: boolean) => void (default: defaultCollapsed: false). 受控或非受控的收起状态,收起后只显示标签栏。
|
|
284
|
+
- collapseOnTabClick: boolean (default: true). 再次激活已选中的展开标签时收起;收起时激活任一可用标签会展开。设为 false 时,激活标签只改变选中项。
|
|
285
|
+
- 原生属性: ComponentPropsWithRef<'div'>. 支持 className、style 和原生属性;ref 指向根 div。
|
|
286
|
+
- Panel 不负责停靠和调整尺寸。与 Splitter 组合时,顶部和底部用纵向分栏,左右用横向分栏,停靠示例使用默认顶部标签栏;双击分隔条或聚焦后按 Enter 可收起或展开工作面板,展开后恢复此前的分栏尺寸。
|
|
287
|
+
- 左右栏使用图标和文字提示;没有图标的标签仍显示文字。收起时操作和展开按钮保留在同一侧栏。
|
|
288
|
+
- 鼠标点击、Enter 或空格键都可激活标签;方向键只移动焦点。窄宽度下也可通过溢出菜单激活。面板收起时保留选中标签和已访问内容的状态。
|
|
289
|
+
|
|
290
|
+
```tsx
|
|
291
|
+
import { Panel } from "@bixlab/mtone";
|
|
292
|
+
import "@bixlab/mtone/styles.css";
|
|
293
|
+
|
|
294
|
+
export default function Demo() {
|
|
295
|
+
return <Panel label="工作区" items={[{ value: "output", label: "输出", content: <code>编译完成</code> }]} />;
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### HoverMarquee
|
|
300
|
+
|
|
301
|
+
- [HoverMarquee](https://xingjianxu.github.io/mtone/#/components/HoverMarquee): 单行文字溢出时显示省略号,悬停或聚焦时滚动查看全文。
|
|
302
|
+
- Import: HoverMarquee from @bixlab/mtone
|
|
303
|
+
- children: ReactNode. 单行文本或非交互行内内容。
|
|
304
|
+
- tabIndex: number. 默认仅文字溢出时可通过 Tab 聚焦;可覆盖。
|
|
305
|
+
- 原生属性: ComponentPropsWithRef<'span'>. 支持 className、style、ARIA 属性,ref 指向外层 span。
|
|
306
|
+
- 在宽度受限的容器中使用。仅溢出时滚动;到达行尾短暂停留,再平滑经过一小段留白,连续接到下一轮。悬停与焦点都离开时恢复省略状态。RTL 反向滚动。
|
|
307
|
+
- 启用减少动态效果或设备不支持悬停时不自动滚动:聚焦后可用方向键横向滚动,触屏可横向滑动。原文始终保留在同一个可访问文本节点中。
|
|
308
|
+
|
|
309
|
+
```tsx
|
|
310
|
+
import { HoverMarquee } from "@bixlab/mtone";
|
|
311
|
+
import "@bixlab/mtone/styles.css";
|
|
312
|
+
|
|
313
|
+
export default function Demo() {
|
|
314
|
+
return (
|
|
315
|
+
<div style={{ inlineSize: "100%", maxInlineSize: "15rem", minInlineSize: 0 }}>
|
|
316
|
+
<HoverMarquee>面向多模态教学数据的人工智能实验记录、阶段性研究报告与后续模型评估计划及数据整理说明</HoverMarquee>
|
|
317
|
+
</div>
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
238
322
|
### HoverCard
|
|
239
323
|
|
|
240
324
|
- [HoverCard](https://xingjianxu.github.io/mtone/#/components/HoverCard): 悬停或键盘聚焦显示的富内容预览卡片。
|
|
@@ -909,13 +993,14 @@ export default function Demo() {
|
|
|
909
993
|
- tabs: ReactNode. 可选,可传入完整 Tabs。省略时不占空间。
|
|
910
994
|
- sidebar: ReactNode. 页面级侧栏插槽,可传入 Sidebar 或自定义内容。省略时保持原有单栏结构。
|
|
911
995
|
- sidebarPosition: "left" | "right" (default: "left"). 侧栏位于主栏的物理左侧或右侧。空间不足时,左侧栏改排在主栏前,右侧栏排在主栏后。
|
|
996
|
+
- sidebarResize: boolean | SidebarResizeOptions (default: false). 可选。复用 Splitter 的指针和方向键调宽;defaultWidth / minWidth / maxWidth 是像素,默认 240 / 160 / 480。窄容器继续上下排列;直接传入的 Sidebar 折叠后隐藏手柄,展开恢复宽度。
|
|
912
997
|
- headerSpan: "full" | "header" | "main" (default: "full"). full:页头和标签页均跨整页;header:页头跨整页,标签页与正文留在主栏;main:页头和标签页均留在主栏。页头包含标题、图标、副标题、操作、描述和附加信息。无侧栏时忽略。
|
|
913
998
|
- maxWidth: "sm" | "md" | "lg" | number. 可选。sm 为 720px、md 为 960px、lg 为 1200px,也可传入正数像素值。设置后整个布局在父容器内居中,容器窄时随父容器收缩;省略时保持原有铺满行为。
|
|
914
999
|
- children: ReactNode. 正文。
|
|
915
1000
|
- HTML div 属性: Omit<ComponentPropsWithRef<"div">, "title">. className、style、ref 等传给根元素。
|
|
916
1001
|
- maxWidth 同时约束页头、标签页、侧栏和正文,不影响外层 AdminLayout 的侧栏或顶栏。
|
|
917
1002
|
- 当 PageLayout 是有可用高度的 AdminLayout.Content 中唯一的直接子元素时,默认至少撑满主内容区的内边距以内;宽屏的页面侧栏同步延伸到底部。长页仍由 AdminLayout.Content 滚动。独立使用、有额外包裹或与其他区块一起使用时,按内容高度布局。
|
|
918
|
-
- PageLayout 本身的可用宽度达到 640px
|
|
1003
|
+
- PageLayout 本身的可用宽度达到 640px 时左右分栏;未启用拖拽时侧栏默认 240px,可用 CSS 变量 --mt-page-layout-sidebar-width 覆盖,最多为布局内宽的 50%。较窄时改为上下排列,full 和 header 模式的页头始终在最上方。
|
|
919
1004
|
- 只负责单页布局,不管理侧栏折叠、独立滚动、标签状态、路由或应用导航。
|
|
920
1005
|
|
|
921
1006
|
```tsx
|
|
@@ -956,6 +1041,7 @@ export default function Demo() {
|
|
|
956
1041
|
- AdminLayout.Sider.version: ReactNode. 底部左侧的应用版本文字/内容;默认不显示,收起时隐藏。折叠按钮固定在底部右侧。
|
|
957
1042
|
- AdminLayout.hasSider: boolean. 是否采用横向布局。省略时自动识别直接子元素中的 AdminLayout.Sider;包装组件内的 Sider 请显式指定。
|
|
958
1043
|
- AdminLayout.fullHeight: boolean (default: false). 占满视口高度(100dvh);嵌入页面时可改用 style.height 指定有限高度。
|
|
1044
|
+
- AdminLayout.sidebarResize: boolean | SidebarResizeOptions (default: false). 对一个直接的 AdminLayout.Sider(可放在 Fragment 中)启用 Splitter 调宽。默认初始宽度继承 Sider.width;可传 defaultWidth / minWidth / maxWidth(像素,下限 160、上限 480)。折叠和窄容器隐藏手柄,不影响通知或断点规则。
|
|
959
1045
|
- AdminLayout.Sider.tabs: SidebarTabsOptions. 透传 Sidebar 顶部标签配置;侧栏宽屏时显示标签,收起时保持当前面板图标导航。
|
|
960
1046
|
- AdminLayout.Sider.collapsible: boolean (default: false). 启用复用自 Sidebar 的收起/展开按钮和图标窄栏。
|
|
961
1047
|
- AdminLayout.Sider.collapsed: boolean. 受控收起状态;搭配 onCollapsedChange 由父组件更新。
|
|
@@ -1436,6 +1522,7 @@ export default function Demo() {
|
|
|
1436
1522
|
- [NumberInput](https://xingjianxu.github.io/mtone/#/components/NumberInput): 带增减按钮的数字输入框。
|
|
1437
1523
|
- Import: NumberInput from @bixlab/mtone
|
|
1438
1524
|
- label: string. 提供可访问名称。
|
|
1525
|
+
- aria-labelledby / aria-describedby: string / string. 转发到实际数字输入框,可关联外部标题和说明。
|
|
1439
1526
|
- disabled: boolean. 禁用交互。
|
|
1440
1527
|
- name: string. 表单字段名称。
|
|
1441
1528
|
- className: string. 附加样式类。
|
|
@@ -1514,6 +1601,7 @@ export default function Demo() {
|
|
|
1514
1601
|
- 不接管路由、固定定位、持久化或响应式断点。不要用固定 width 覆盖收起宽度;自定义内容需自行适配窄栏。
|
|
1515
1602
|
- 版本、部署和包信息等非导航内容,可使用 SectionGroup 分区;示例使用不收起的 Sidebar,不影响导航图标窄栏。
|
|
1516
1603
|
- 文档目录可把 Tree 直接放进 Sidebar;见 Tree 的「侧栏文档树」示例,当前文档和异步子节点由应用维护。
|
|
1604
|
+
- 独立侧栏调宽时把 Sidebar 放入 Splitter.Panel;Sidebar 本身不管理拖拽宽度。AdminLayout 与 PageLayout 则可选择启用 sidebarResize。
|
|
1517
1605
|
|
|
1518
1606
|
```tsx
|
|
1519
1607
|
import { Sidebar, NavItem } from "@bixlab/mtone";
|
|
@@ -1526,6 +1614,180 @@ export default function Demo() {
|
|
|
1526
1614
|
}
|
|
1527
1615
|
```
|
|
1528
1616
|
|
|
1617
|
+
### SettingRow
|
|
1618
|
+
|
|
1619
|
+
- [SettingRow](https://xingjianxu.github.io/mtone/#/components/SettingRow): 左侧呈现设置标题、快捷键和说明,右侧放置任意设置控件。
|
|
1620
|
+
- Import: SettingRow, Switch, NumberInput, Select from @bixlab/mtone
|
|
1621
|
+
- title: ReactNode. 设置标题,作为控件可访问名称的来源。
|
|
1622
|
+
- description: ReactNode. 标题下方的可选说明。
|
|
1623
|
+
- shortcut: ReactNode. 标题旁的可选快捷键提示,只展示、不注册快捷键。
|
|
1624
|
+
- control: ReactNode | (attributes: SettingRowControlProps) => ReactNode. 控件插槽;使用函数时将收到的 aria-labelledby 和 aria-describedby 展开到实际控件。
|
|
1625
|
+
- SettingRow.Group: HTMLAttributes<HTMLDivElement>. 默认 role=group,直接放入多行以共享底色和行间细线;可用 aria-label 或 aria-labelledby 命名。
|
|
1626
|
+
- 窄容器中控件可换到下一行,仍靠行尾对齐。组件不管理设置值;直接传入控件时由调用方提供可访问名称。
|
|
1627
|
+
|
|
1628
|
+
```tsx
|
|
1629
|
+
import React from "react";
|
|
1630
|
+
import { NumberInput, Select, SettingRow, Switch } from "@bixlab/mtone";
|
|
1631
|
+
import "@bixlab/mtone/styles.css";
|
|
1632
|
+
|
|
1633
|
+
export default function Demo() {
|
|
1634
|
+
const title = React.useId();
|
|
1635
|
+
return <div style={{ width: "100%", maxWidth: 640 }}>
|
|
1636
|
+
<h3 id={title} style={{ margin: "0 0 12px" }}>编辑器设置</h3>
|
|
1637
|
+
<SettingRow.Group aria-labelledby={title}>
|
|
1638
|
+
<SettingRow title="只读模式" shortcut="Ctrl+Shift+G"
|
|
1639
|
+
description="打开后锁定编辑器,仍可搜索内容。"
|
|
1640
|
+
control={a11y => <Switch {...a11y} />} />
|
|
1641
|
+
<SettingRow title="拼写检查" description="输入时标记可能的拼写错误。"
|
|
1642
|
+
control={a11y => <Switch {...a11y} defaultChecked />} />
|
|
1643
|
+
<SettingRow title="光标上下文行数" description="光标与编辑器边缘之间至少保留的行数。"
|
|
1644
|
+
control={a11y => <NumberInput {...a11y} defaultValue={3} />} />
|
|
1645
|
+
<SettingRow title="Tab 空格数" description="按下 Tab 时插入指定数量的空格。"
|
|
1646
|
+
control={a11y => <Select {...a11y} defaultValue="4" options={[2, 4, 8].map(value => ({
|
|
1647
|
+
value: String(value),
|
|
1648
|
+
label: `${value} 个空格`,
|
|
1649
|
+
}))} />} />
|
|
1650
|
+
</SettingRow.Group>
|
|
1651
|
+
</div>;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
```
|
|
1655
|
+
|
|
1656
|
+
### SettingsDialog
|
|
1657
|
+
|
|
1658
|
+
- [SettingsDialog](https://xingjianxu.github.io/mtone/#/components/SettingsDialog): 带分类导航的设置对话框,可搜索并定位调用方提供的设置项。
|
|
1659
|
+
- Import: SettingsDialog, SettingRow, Button, Switch, NumberInput, Select from @bixlab/mtone
|
|
1660
|
+
- categories: readonly SettingsDialogCategory[]. 依次传入各分类的唯一 value、label、可选 icon 和 content。
|
|
1661
|
+
- value / defaultValue: string. 受控或非受控的当前分类;未提供或找不到对应分类时使用第一项。
|
|
1662
|
+
- onValueChange: (value: string) => void. 请求切换到另一分类时触发。
|
|
1663
|
+
- categoriesLabel: string. 为分类导航提供自定义的可访问名称。
|
|
1664
|
+
- searchIndex: readonly SettingsDialogSearchEntry[]. 启用内建搜索。每条由 category(分类 value)、id(分类内容中的元素 ID)、label(设置名称)和可选 keywords 组成。
|
|
1665
|
+
- search: ReactNode | (context: SettingsDialogSearchContext) => ReactNode. 自定义搜索入口,优先于 searchIndex;可以使用 selectCategory 切换分类。
|
|
1666
|
+
- Dialog 属性: Omit<DialogProps, 'children'>. 沿用 Dialog 的 title、description、trigger、open、defaultOpen、onOpenChange、footer、modal 和 className。
|
|
1667
|
+
- 宽屏分类与详情分别滚动;视口不宽于 600px 时先展示分类,打开详情时聚焦标题,返回时聚焦当前分类。
|
|
1668
|
+
- 弹窗保持打开时,访问过的分类切换后仍保留挂载,可暂存该分类中的界面状态。
|
|
1669
|
+
- 搜索匹配设置名、文本分类名和关键词;自定义分类标签为 React 节点时以分类 value 匹配。上下键选择,Enter 定位,Escape 清空。
|
|
1670
|
+
- 定位后恢复分类导航并在详情内部滚动及短暂高亮目标;请将 ID 放在可聚焦的行或标题(如 SettingRow 上设置 tabIndex={-1})。设置值、保存逻辑和权限仍由调用方管理。
|
|
1671
|
+
|
|
1672
|
+
```tsx
|
|
1673
|
+
import React from "react";
|
|
1674
|
+
import {
|
|
1675
|
+
Button,
|
|
1676
|
+
NumberInput,
|
|
1677
|
+
Select,
|
|
1678
|
+
SettingRow,
|
|
1679
|
+
SettingsDialog,
|
|
1680
|
+
Switch,
|
|
1681
|
+
type SettingsDialogSearchEntry,
|
|
1682
|
+
} from "@bixlab/mtone";
|
|
1683
|
+
import "@bixlab/mtone/styles.css";
|
|
1684
|
+
|
|
1685
|
+
const searchIndex = [
|
|
1686
|
+
{
|
|
1687
|
+
category: "general",
|
|
1688
|
+
id: "settings-auto-save",
|
|
1689
|
+
label: "自动保存",
|
|
1690
|
+
keywords: ["草稿", "autosave"],
|
|
1691
|
+
},
|
|
1692
|
+
{
|
|
1693
|
+
category: "general",
|
|
1694
|
+
id: "settings-notifications",
|
|
1695
|
+
label: "通知",
|
|
1696
|
+
keywords: ["提醒"],
|
|
1697
|
+
},
|
|
1698
|
+
{
|
|
1699
|
+
category: "editor",
|
|
1700
|
+
id: "settings-context",
|
|
1701
|
+
label: "光标上下文行数",
|
|
1702
|
+
keywords: ["光标", "cursor"],
|
|
1703
|
+
},
|
|
1704
|
+
{
|
|
1705
|
+
category: "editor",
|
|
1706
|
+
id: "settings-spaces",
|
|
1707
|
+
label: "Tab 空格数",
|
|
1708
|
+
keywords: ["缩进", "indent"],
|
|
1709
|
+
},
|
|
1710
|
+
{
|
|
1711
|
+
category: "privacy",
|
|
1712
|
+
id: "settings-analytics",
|
|
1713
|
+
label: "使用情况统计",
|
|
1714
|
+
keywords: ["匿名", "analytics"],
|
|
1715
|
+
},
|
|
1716
|
+
] satisfies readonly SettingsDialogSearchEntry[];
|
|
1717
|
+
|
|
1718
|
+
export default function Demo() {
|
|
1719
|
+
return (
|
|
1720
|
+
<SettingsDialog
|
|
1721
|
+
title="应用设置"
|
|
1722
|
+
trigger={<Button>打开设置</Button>}
|
|
1723
|
+
searchIndex={searchIndex}
|
|
1724
|
+
categories={[
|
|
1725
|
+
{
|
|
1726
|
+
value: "general",
|
|
1727
|
+
label: "常规",
|
|
1728
|
+
content: (
|
|
1729
|
+
<SettingRow.Group aria-label="常规设置">
|
|
1730
|
+
<SettingRow
|
|
1731
|
+
id="settings-auto-save"
|
|
1732
|
+
title="自动保存"
|
|
1733
|
+
description="编辑时自动保存草稿。"
|
|
1734
|
+
control={(props) => <Switch {...props} defaultChecked />}
|
|
1735
|
+
/>
|
|
1736
|
+
<SettingRow
|
|
1737
|
+
id="settings-notifications"
|
|
1738
|
+
title="通知"
|
|
1739
|
+
description="在任务完成时发送提醒。"
|
|
1740
|
+
control={(props) => <Switch {...props} />}
|
|
1741
|
+
/>
|
|
1742
|
+
</SettingRow.Group>
|
|
1743
|
+
),
|
|
1744
|
+
},
|
|
1745
|
+
{
|
|
1746
|
+
value: "editor",
|
|
1747
|
+
label: "编辑器",
|
|
1748
|
+
content: (
|
|
1749
|
+
<SettingRow.Group aria-label="编辑器设置">
|
|
1750
|
+
<SettingRow
|
|
1751
|
+
id="settings-context"
|
|
1752
|
+
title="光标上下文行数"
|
|
1753
|
+
control={(props) => <NumberInput {...props} defaultValue={3} />}
|
|
1754
|
+
/>
|
|
1755
|
+
<SettingRow
|
|
1756
|
+
id="settings-spaces"
|
|
1757
|
+
title="Tab 空格数"
|
|
1758
|
+
control={(props) => (
|
|
1759
|
+
<Select
|
|
1760
|
+
{...props}
|
|
1761
|
+
defaultValue="4"
|
|
1762
|
+
options={[2, 4, 8].map((value) => ({
|
|
1763
|
+
value: String(value),
|
|
1764
|
+
label: `${value} 个空格`,
|
|
1765
|
+
}))}
|
|
1766
|
+
/>
|
|
1767
|
+
)}
|
|
1768
|
+
/>
|
|
1769
|
+
</SettingRow.Group>
|
|
1770
|
+
),
|
|
1771
|
+
},
|
|
1772
|
+
{
|
|
1773
|
+
value: "privacy",
|
|
1774
|
+
label: "隐私",
|
|
1775
|
+
content: (
|
|
1776
|
+
<SettingRow
|
|
1777
|
+
id="settings-analytics"
|
|
1778
|
+
title="使用情况统计"
|
|
1779
|
+
description="发送匿名使用数据。"
|
|
1780
|
+
control={(props) => <Switch {...props} />}
|
|
1781
|
+
/>
|
|
1782
|
+
),
|
|
1783
|
+
},
|
|
1784
|
+
]}
|
|
1785
|
+
/>
|
|
1786
|
+
);
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
```
|
|
1790
|
+
|
|
1529
1791
|
### SectionGroup
|
|
1530
1792
|
|
|
1531
1793
|
- [SectionGroup](https://xingjianxu.github.io/mtone/#/components/SectionGroup): 用标题、右侧操作和分隔线组织任意内容。
|
|
@@ -1703,11 +1965,12 @@ export default function Demo() {
|
|
|
1703
1965
|
- indent: number (default: 20). 每层新增的逻辑缩进(px),同时调整节点、引导线和连接线;负值按 0,无效值回退到 20。
|
|
1704
1966
|
- gap: number (default: 2). 相邻行间距(px)。接受有限非负数(可含小数);设为 0 取消间距,无效值回退到 2。普通和虚拟列表一致,不改变单行的高度或命中区域。
|
|
1705
1967
|
- endContent: (info: TreeNodeInfo) => ReactNode. 在行的逻辑末端独立显示计数或简短状态;标题省略不会压缩此区域。info 含 node、expanded、selected、checked、loading。
|
|
1968
|
+
- actions: (info: TreeNodeInfo) => TreeAction | readonly TreeAction[] | null | undefined. 为可用节点渲染独立的末端按钮或菜单。TreeAction 含 content 和可选 visibility:always(默认)、hover(行悬停、进入键盘焦点时显示,无悬停设备也可用)、active(节点已选中时显示)。隐藏仍占位,操作不选择、展开或拖动节点;请为纯图标按钮提供可访问名称。
|
|
1706
1969
|
- filterTreeNode: (node: TreeItem) => boolean. 高亮返回 true 的节点,不删除其他节点或自动展开祖先。
|
|
1707
1970
|
- loadData: (node: TreeItem) => Promise<unknown>. 展开未加载分支时调用,同一节点并发去重。Promise 返回值不直接作为 children,应用必须不可变更新 items / treeData。叶节点应设置 isLeaf=true。
|
|
1708
1971
|
- loadedKeys / defaultLoadedKeys: TreeKey[]. 受控或初始加载成功键;提供 loadedKeys 后需在 onLoad 中更新以防后续重复加载。
|
|
1709
1972
|
- onLoad / onLoadError: (keys, { node }) => void / (error, node) => void. 加载成功或失败回调。失败显示错误提示并允许通过展开控件重试。
|
|
1710
|
-
- height / itemHeight / virtual: number / number / boolean (default: — /
|
|
1973
|
+
- height / itemHeight / virtual: number / number / boolean (default: — / 32 / true). 正数 height 开启定高滚动;默认虚拟化,只挂载可见附近行。itemHeight 控制所有模式的实际行高,默认 32px,最小 24px,不包含 gap。非正数或非有限值回退到默认值;virtual=false 保留滚动容器但渲染全部节点。
|
|
1711
1974
|
- draggable: boolean | (node: TreeItem) => boolean (default: false). 启用 HTML 原生拖放,可按节点决定是否允许拖动。
|
|
1712
1975
|
- allowDrop: ({ dragNode, dropNode, dropPosition }) => boolean. 可限制落点。dropPosition=-1 / 0 / 1 分别表示目标前 / 内 / 后;自身及后代始终禁止。
|
|
1713
1976
|
- onDrop: (info: TreeDropInfo) => void. info 含 event、node、dragNode、dragNodesKeys、dropPosition、dropToGap。应用按结果更新数据,组件不自动移动节点。
|
|
@@ -1717,6 +1980,7 @@ export default function Demo() {
|
|
|
1717
1980
|
- directory / expandAction: boolean / false | "click" | "doubleClick" (default: false / "click"). 设置 directory 开启目录模式;默认点击展开,false 禁用标题触发展开但保留箭头 / 方向键。
|
|
1718
1981
|
- label / className / style: string / string / CSSProperties. 可访问名称、根类名与样式;支持其余不冲突的 div 属性。
|
|
1719
1982
|
- ref: React.Ref<TreeRef>. 暴露 nativeElement、focus()、scrollTo({ key, align?, offset?, autoExpand? });align 为 top / bottom / auto。autoExpand 只在非受控展开模式生效。
|
|
1983
|
+
- 文档的交互配置示例可切换连接线、节点图标、整行铺满、复选框、独立勾选、多选、选择、禁用与目录模式,调整目录标题展开方式、行高、间距、缩进和可视高度。恢复默认会还原展开状态并清除选择和勾选;异步加载、虚拟滚动、拖放和节点渲染见独立示例。
|
|
1720
1984
|
- TreeKey 为 string | number;全树键必须唯一且数字有限,缺失或重复键会报错。保留原有 items / id / label、value、expanded 用法;不要混用新旧受控属性。
|
|
1721
1985
|
- 勾选传导在 disabled、disableCheckbox 或 checkable=false 节点停止;严格模式下父子完全独立。disabled 不会隐藏节点或清除外部传入状态。
|
|
1722
1986
|
- 支持方向键、Home / End、Enter、Space 和字符首字母定位。Space 在复选模式中切换勾选;目录多选支持 Ctrl / Command 追加、Shift 可见范围选择。
|
|
@@ -1752,7 +2016,7 @@ export default function Demo() {
|
|
|
1752
2016
|
- onValueChange: (value: string) => void. 用户切换及非受控有效回退时触发。
|
|
1753
2017
|
- placement: "top" | "bottom" | "start" | "end". 默认 top;start/end 为逻辑方向。
|
|
1754
2018
|
- variant: "line" | "card" | "editable-card" | "attached". 默认 line。attached 的顶部选中项与内容区相接;bottom/start/end 保留指定位置并使用 line 样式。
|
|
1755
|
-
- size: "small" | "medium" | "large".
|
|
2019
|
+
- size: "sm" | "md" | "lg" | "small" | "medium" | "large" (default: "md"). 标签项外高(含边框):sm 28px、md 32px、lg 36px,适用于全部变体和位置。旧值 small、medium、large 保留原字号和 32px 外高。尺寸可实时切换,不会重置选中项。
|
|
1756
2020
|
- indicatorColor: TabsIndicatorColor (default: currentColor). 使用 line 样式时的选中指示线颜色,包含 attached 在非顶部位置的线型回退。支持主题预设 neutral/blue/green/orange/red/purple/teal/coral,或任意有效 CSS 颜色;不改变基准线和文字颜色。
|
|
1757
2021
|
- centered / gap: boolean / number. 居中排列(溢出时回到起点);间隔单位 px,最小 0。默认线型为 6px,card/editable-card 和顶部 attached 为 4px。
|
|
1758
2022
|
- extraStart / extraEnd: ReactNode. 导航栏前后附加内容。
|
|
@@ -2632,7 +2896,7 @@ export default function Demo() {
|
|
|
2632
2896
|
- [PropertyList](https://xingjianxu.github.io/mtone/#/components/PropertyList): 文档属性的定义列表容器。
|
|
2633
2897
|
- Import: PropertyList, PropertyItem from @bixlab/mtone
|
|
2634
2898
|
- children: ReactNode. 组件内容。
|
|
2635
|
-
- 使用 dl
|
|
2899
|
+
- 使用 dl 语义,与本页 PropertyItem 小节中的属性行搭配。
|
|
2636
2900
|
|
|
2637
2901
|
```tsx
|
|
2638
2902
|
import { PropertyList, PropertyItem } from "@bixlab/mtone";
|
|
@@ -2647,7 +2911,7 @@ export default function Demo() {
|
|
|
2647
2911
|
|
|
2648
2912
|
### PropertyItem
|
|
2649
2913
|
|
|
2650
|
-
- [PropertyItem](https://xingjianxu.github.io/mtone/#/components/
|
|
2914
|
+
- [PropertyItem](https://xingjianxu.github.io/mtone/#/components/PropertyList?section=property-item): 展示一行属性名和值。
|
|
2651
2915
|
- Import: PropertyItem, PropertyList from @bixlab/mtone
|
|
2652
2916
|
- label: ReactNode. 必填;属性名。
|
|
2653
2917
|
- children: ReactNode. 组件内容。
|