@bixlab/mtone 0.7.0 → 0.9.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/README.md +2 -2
- package/dist/index.d.ts +563 -42
- package/dist/index.js +3524 -1037
- package/dist/styles.css +1 -1
- package/dist/typography-highlight-WZ7OAZVP.js +62 -0
- package/llms.txt +989 -115
- package/package.json +5 -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.9.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
|
|
|
@@ -11,7 +11,7 @@ This file describes this package checkout, not necessarily the latest published
|
|
|
11
11
|
- Named imports: import { Button, MtoneProvider } from "@bixlab/mtone";
|
|
12
12
|
- Import precompiled CSS once: import "@bixlab/mtone/styles.css";
|
|
13
13
|
- Consumers do not need to install/configure Tailwind or copy component source. Base UI and Lucide are package dependencies.
|
|
14
|
-
- Optional provider: <MtoneProvider locale="zh"
|
|
14
|
+
- Optional provider: <MtoneProvider locale="zh"><Button>保存</Button></MtoneProvider>. Locale: zh | en. Default single-line controls use a unified 32px baseline; density is no longer a provider prop. Independent size variants and CSS token customization remain available. Provider tokens are CSS custom properties.
|
|
15
15
|
- Color theme: <MtoneProvider theme="system">…</MtoneProvider> follows the OS in real time. Use light or dark to override. Without an explicit theme, top-level providers remain light; nested MtoneScope can override and floats inherit their React scope. The library does not store the choice.
|
|
16
16
|
- Interactive components need a client boundary in React Server Component frameworks.
|
|
17
17
|
|
|
@@ -21,6 +21,7 @@ This file describes this package checkout, not necessarily the latest published
|
|
|
21
21
|
- Use documented mtone APIs rather than inferring props from other libraries or underlying engines. Do not import private src paths.
|
|
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/MultiSelect option highlights remain background-only.
|
|
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.
|
|
24
25
|
- Prefer Dialog. Modal/ModalProps are deprecated aliases. 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.
|
|
25
26
|
- Use Badge, not removed Tag. There is no block editor. Upload requires an application service; examples are not backend persistence. DatePicker uses native browser date UI.
|
|
26
27
|
- Toast notifications need ToastProvider; useToast exposes add, success, error, info, update, promise and close (verify installed declarations before use).
|
|
@@ -30,12 +31,83 @@ This file describes this package checkout, not necessarily the latest published
|
|
|
30
31
|
|
|
31
32
|
- [Getting started](https://xingjianxu.github.io/mtone/#/start): installation and AI usage
|
|
32
33
|
- [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): live palette, CSS reuse, and scoped overrides
|
|
33
35
|
- [Component gallery](https://xingjianxu.github.io/mtone/#/gallery): independent component examples
|
|
34
36
|
- [Application showcase](https://xingjianxu.github.io/mtone/showcase.html): interactive in-memory demo, not a backend
|
|
35
37
|
- [Source repository](https://github.com/xingjianxu/mtone): current code and migration notes
|
|
36
38
|
|
|
37
39
|
## Components
|
|
38
40
|
|
|
41
|
+
### CheckCard
|
|
42
|
+
|
|
43
|
+
- [CheckCard](https://xingjianxu.github.io/mtone/#/components/CheckCard): 以卡片呈现可选项。独立使用可勾选,CheckCard.Group 管理单选或多选,CardGroup 负责响应式排列。
|
|
44
|
+
- Import: CheckCard, CardGroup from @bixlab/mtone
|
|
45
|
+
- checked / defaultChecked: boolean (default: false). 独立卡片的受控选中状态或非受控初始状态。放入 Group 时由组管理。
|
|
46
|
+
- onChange: (checked: boolean) => void. 独立卡片切换时触发;组内选择使用 Group 的 onChange。
|
|
47
|
+
- value: string. 独立使用时为表单值;组内每张卡片指定唯一的 value。
|
|
48
|
+
- name / form: string. 独立卡片的表单字段名与可选关联表单 ID。组内由 Group 提供字段名,Group 的 form 可关联外部表单。
|
|
49
|
+
- required: boolean (default: false). 独立复选框设为必选;组级必选使用单选 Group 的 required。
|
|
50
|
+
- title / description: ReactNode. 卡片标题与辅助说明。无可读标题时用 aria-label 或 aria-labelledby 为输入控件命名。
|
|
51
|
+
- avatar / cover / children: ReactNode. 头像、封面和自定义内容。按钮、链接等独立交互放入 extra,而非选择区域。
|
|
52
|
+
- extra: ReactNode. 独立操作区。此区域不会切换卡片的选中状态;在表单中使用 type=button 防止无意提交。
|
|
53
|
+
- disabled / loading: boolean (default: false). 禁止选择;loading 显示加载状态。extra 中操作的禁用状态由调用方管理。
|
|
54
|
+
- size: 'sm' | 'md' | 'lg' (default: 'md'). 卡片尺寸,未设置时继承 Group 的尺寸。
|
|
55
|
+
- bordered: boolean (default: true). 是否展示卡片边框,未设置时继承 Group 的设置。
|
|
56
|
+
- CheckCard.Group.multiple: boolean (default: false). 默认渲染单选卡片;设为 true 后渲染多选卡片。
|
|
57
|
+
- CheckCard.Group.value / defaultValue: string | readonly string[]. 受控值或非受控初始值。单选用字符串,多选用字符串数组。
|
|
58
|
+
- CheckCard.Group.onChange: ((value: string) => void) | ((value: string[]) => void). 单选收到选中的字符串,多选收到选中项数组;受控用法需要在回调中更新 value。
|
|
59
|
+
- CheckCard.Group.legend / name / form: ReactNode / string / string. 可见组名、表单字段名与可选关联表单 ID。单选未指定 name 时生成独立的内部名称。同一表单中的独立单选组应使用不同的 name。
|
|
60
|
+
- CheckCard.Group.options / children: readonly CheckCardOption[] / ReactNode. 可用 options 提供带字符串 value 的卡片数据,或通过 children 自定义组合。两者同时提供时优先渲染 children。
|
|
61
|
+
- CheckCard.Group.required: boolean (default: false). 仅单选 Group 支持,要求在该组选择一项。
|
|
62
|
+
- CheckCard.Group.disabled / loading / size / bordered: boolean / boolean / 'sm' | 'md' | 'lg' / boolean. 禁用组内选择、显示整组加载状态,或设置组内卡片的默认尺寸和边框。
|
|
63
|
+
- CheckCard.Group 管理表单选择,不负责响应式列数;CardGroup 管理列数、间距和跨列,不管理选择。把 CardGroup 放在 CheckCard.Group 内,可同时获得两种行为。
|
|
64
|
+
- 选项使用原生单选框或复选框,支持 Tab、空格和单选组方向键。为 Group 提供可读 legend,为每张卡片提供明确标题;仅用于装饰的图形应从无障碍树隐藏。
|
|
65
|
+
- 需要提交表单时明确指定 name 和 value;多选用 FormData.getAll(name) 读取同名项。可用 CheckCardProps、CheckCardGroupProps 和 CheckCardOption 类型描述使用方式。
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
import { CheckCard, CardGroup } from "@bixlab/mtone";
|
|
69
|
+
import "@bixlab/mtone/styles.css";
|
|
70
|
+
|
|
71
|
+
export default function Demo() {
|
|
72
|
+
return (
|
|
73
|
+
<CheckCard.Group legend="选择工作区视图" defaultValue="overview">
|
|
74
|
+
<CardGroup columns={{ xs: 1, sm: 2, md: 3 }} gap={12}>
|
|
75
|
+
<CheckCard value="overview" title="概览" />
|
|
76
|
+
<CheckCard value="projects" title="项目" />
|
|
77
|
+
<CheckCard value="notes" title="笔记" />
|
|
78
|
+
</CardGroup>
|
|
79
|
+
</CheckCard.Group>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Questionnaire
|
|
85
|
+
|
|
86
|
+
- [Questionnaire](https://xingjianxu.github.io/mtone/#/components/Questionnaire): 逐题填写的多步问卷,支持单选、多选、自由文本、其他答案、必答校验和跳过。
|
|
87
|
+
- Import: Questionnaire from @bixlab/mtone
|
|
88
|
+
- items: readonly QuestionnaireItem[]. 有序问题:id、title、description、required;type 为 single、multiple 或 text。选项题传 choices;单选可传 other。
|
|
89
|
+
- answers / defaultAnswers: QuestionnaireAnswers. 按问题 id 索引的受控或初始答案。
|
|
90
|
+
- onAnswersChange: (answers: QuestionnaireAnswers) => void. 输入、选项变化或显式跳过时收到完整草稿。
|
|
91
|
+
- onSubmit: (answers: QuestionnaireAnswers) => void | Promise<void>. 末题通过校验时收到有效答案;异步失败后可重试。
|
|
92
|
+
- submitLabel: ReactNode. 最终提交按钮内容。
|
|
93
|
+
- 答案为 {type:"choice",value}、{type:"choices",values} 或 {type:"text",value}。提交文本会去除首尾空白,多选按选项顺序返回。
|
|
94
|
+
- 必答题不能跳过;选答题可留空,显式跳过清除本题草稿。上一题不会清除答案。
|
|
95
|
+
- 问题 id 在问卷内必须唯一且稳定,选项 value 在本题内必须唯一。已提交后保留完成提示;开始新问卷时以不同 React key 挂载。
|
|
96
|
+
- 组件不处理保存、传输和条件分支;由调用方在 onSubmit 中处理。
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
import { Questionnaire } from "@bixlab/mtone";
|
|
100
|
+
|
|
101
|
+
<Questionnaire
|
|
102
|
+
items={[
|
|
103
|
+
{ id: "topic", type: "single", title: "选择主题", required: true,
|
|
104
|
+
choices: [{ value: "docs", label: "文档" }], other: { label: "其他" } },
|
|
105
|
+
{ id: "notes", type: "text", title: "还有什么建议?" },
|
|
106
|
+
]}
|
|
107
|
+
onSubmit={(answers) => console.log(answers)}
|
|
108
|
+
/>
|
|
109
|
+
```
|
|
110
|
+
|
|
39
111
|
### TreeSelect
|
|
40
112
|
|
|
41
113
|
- [TreeSelect](https://xingjianxu.github.io/mtone/#/components/TreeSelect): 在紧凑输入框中选择树形数据,支持单选、多选勾选、搜索和异步展开。
|
|
@@ -64,7 +136,7 @@ This file describes this package checkout, not necessarily the latest published
|
|
|
64
136
|
- showLine / showIcon: boolean / boolean (default: false). 树连接线和节点图标;图标来自节点 icon。
|
|
65
137
|
- titleRender: (node: TreeItem) => ReactNode. 自定义树节点标题。
|
|
66
138
|
- height / virtual: number / boolean. 树面板高度和窗口化渲染开关;高度默认 256px,virtual 默认 true。
|
|
67
|
-
- size: "sm" | "md" | "lg" (default: "md"). 触发器高度为 24 /
|
|
139
|
+
- size: "sm" | "md" | "lg" (default: "md"). 触发器高度为 24 / 32 / 34px。
|
|
68
140
|
- status: "error" | "warning". 校验边框状态。
|
|
69
141
|
- placement: "bottom-start" | "bottom-end" | "top-start" | "top-end" (default: "bottom-start"). 弹层的方向与逻辑对齐。
|
|
70
142
|
- dropdownWidth: CSSProperties["width"]. 指定弹层宽度;默认跟随触发器,最小 180px 且受视口约束。
|
|
@@ -178,7 +250,7 @@ export default function Demo() {
|
|
|
178
250
|
- width: CSSProperties[width] (default: 280). 卡片宽度,受可用视口宽度限制,不强制匹配触发宽度
|
|
179
251
|
- withArrow / disabled: boolean (default: false). 显示箭头 / 禁用预览但保留触发元素原本行为
|
|
180
252
|
- 复用 Base UI PreviewCard 的悬停安全区域、延迟与键盘聚焦行为。鼠标从触发元素移动到卡片时保持显示;Escape 或点击外部关闭。不会自动把焦点移入卡片。
|
|
181
|
-
- HoverCard 用于补充预览,不替代点击式 Popover
|
|
253
|
+
- HoverCard 用于补充预览,不替代点击式 Popover;表单和必须完成的操作应使用 Popover。触摸设备不依赖悬停打开,也不拦截触发链接原本点击。
|
|
182
254
|
- 提供可聚焦 trigger 以支持键盘;预览信息不应是完成任务的唯一入口。API 不兼容 Mantine,不提供复合子组件、delay group 或触摸开关。
|
|
183
255
|
|
|
184
256
|
```tsx
|
|
@@ -206,7 +278,7 @@ export default function Demo() {
|
|
|
206
278
|
- disabled / readOnly: boolean (default: false). 禁用或只读;不允许修改值。弹出式 Cascader 不打开弹层
|
|
207
279
|
- open / defaultOpen / onOpenChange: boolean / boolean / (open:boolean)=>void (default: false). 仅 Cascader:控制弹层
|
|
208
280
|
- placeholder / allowClear / onClear: string / boolean / ()=>void (default: 本地化提示 / false). 仅 Cascader:提示文字、清除按钮及清除回调
|
|
209
|
-
- size / status: "sm" | "md" | "lg" / "error" | "warning" (default: md). 仅 Cascader:高度 24 /
|
|
281
|
+
- size / status: "sm" | "md" | "lg" / "error" | "warning" (default: md). 仅 Cascader:高度 24 / 32 / 34px,及校验状态
|
|
210
282
|
- placement: "bottom-start" | "bottom-end" | "top-start" | "top-end" (default: bottom-start). 仅 Cascader:弹层位置
|
|
211
283
|
- showCheckedStrategy: "parent" | "leaf" (default: parent). 仅 Cascader:多选标签合并父级或展示叶级,不改变回调的叶路径数组
|
|
212
284
|
- maxTagCount: number (default: 3). 仅 Cascader:最大可见标签数,其余显示计数
|
|
@@ -308,7 +380,7 @@ export default function Demo() {
|
|
|
308
380
|
- autoHighlight / backfill: boolean (default: false). 自动首项高亮 / 键盘临时回填
|
|
309
381
|
- allowClear / onClear: boolean / ()=>void (default: false). 清除按钮及回调
|
|
310
382
|
- loading / notFoundContent: boolean / ReactNode (default: false / 本地化空状态). 加载状态和无结果内容
|
|
311
|
-
- size / status: sm | md | lg / error | warning (default: md). 高度24/
|
|
383
|
+
- size / status: sm | md | lg / error | warning (default: md). 高度24/32/34px和校验状态
|
|
312
384
|
- prefix / suffix: ReactNode (default: —). 输入前后装饰
|
|
313
385
|
- placement / popupWidth: top | bottom / number (default: bottom / 跟随输入). 浮层方向/像素宽度
|
|
314
386
|
- popupClassName / popupStyle: string / CSSProperties (default: —). 浮层样式
|
|
@@ -680,7 +752,7 @@ export default function Demo() {
|
|
|
680
752
|
- 插入替换光标之前的当前触发符和查询,保留光标之后的文本;超出 maxLength 时不插入,不截断候选。不会把已有提及变成不可分割的标签。默认查询禁止空白,含空格的实体值不适合默认解析规则。
|
|
681
753
|
- 异步示例只模拟本地延迟,不发送网络请求。业务端须自行请求、处理错误、取消或忽略旧响应;loading 时不会选中旧候选,filterOption={false} 可保留服务端排序。
|
|
682
754
|
- FormField 可直接绑定字符串 value/onChange。原生表单 reset 会恢复非受控 defaultValue,受控值仍由应用管理。getMentions 只解析文本,不能替代成员校验或权限检查。
|
|
683
|
-
- 候选使用灰色背景高亮,不加蓝色边框。弹层挂到 document.body 时通过 MtoneProvider 继承 tokens
|
|
755
|
+
- 候选使用灰色背景高亮,不加蓝色边框。弹层挂到 document.body 时通过 MtoneProvider 继承 tokens/颜色主题;自定义 popupRender 应保留完整 menu 与可访问语义。复杂变换容器、自定义候选内容需在目标布局验证。
|
|
684
756
|
|
|
685
757
|
```tsx
|
|
686
758
|
import { useState } from "react";
|
|
@@ -817,6 +889,33 @@ export default function Demo() {
|
|
|
817
889
|
}
|
|
818
890
|
```
|
|
819
891
|
|
|
892
|
+
### PageLayout
|
|
893
|
+
|
|
894
|
+
- [PageLayout](https://xingjianxu.github.io/mtone/#/components/PageLayout): 组织单页标题、操作、标签页和内容,也可限制整页宽度并在父容器内居中。
|
|
895
|
+
- Import: PageLayout from @bixlab/mtone
|
|
896
|
+
- title: ReactNode. 必填标题,渲染在语义标题元素中。
|
|
897
|
+
- headingLevel: 1 | 2 | 3 | 4 | 5 | 6 (default: 1). 标题级别;嵌入时按页面结构调整。
|
|
898
|
+
- subtitle: ReactNode. 标题下方的简短补充。
|
|
899
|
+
- icon: ReactNode. 标题前的图标。
|
|
900
|
+
- actions: ReactNode. 标题行的操作,空间不足时自然换行。
|
|
901
|
+
- description: ReactNode. 标题行下方的补充内容。
|
|
902
|
+
- extra: ReactNode. 与描述同组的附加信息。
|
|
903
|
+
- tabs: ReactNode. 标题区之后、正文之前的内容,可传入完整 Tabs。
|
|
904
|
+
- maxWidth: "sm" | "md" | "lg" | number. 可选。sm 为 720px、md 为 960px、lg 为 1200px,也可传入正数像素值。设置后整个布局在父容器内居中,容器窄时随父容器收缩;省略时保持原有铺满行为。
|
|
905
|
+
- children: ReactNode. 正文。
|
|
906
|
+
- HTML div 属性: Omit<ComponentPropsWithRef<"div">, "title">. className、style、ref 等传给根元素。
|
|
907
|
+
- maxWidth 同时约束标题、操作、标签页与正文,不影响外层 AdminLayout 的侧栏或顶栏。
|
|
908
|
+
- 只负责单页布局,不管理标签状态、路由或应用导航。
|
|
909
|
+
|
|
910
|
+
```tsx
|
|
911
|
+
import { PageLayout } from "@bixlab/mtone";
|
|
912
|
+
import "@bixlab/mtone/styles.css";
|
|
913
|
+
|
|
914
|
+
export default function Demo() {
|
|
915
|
+
return <PageLayout title="项目总览" maxWidth="md">本周有 3 项任务待处理。</PageLayout>;
|
|
916
|
+
}
|
|
917
|
+
```
|
|
918
|
+
|
|
820
919
|
### AdminLayout
|
|
821
920
|
|
|
822
921
|
- [AdminLayout](https://xingjianxu.github.io/mtone/#/components/AdminLayout): 可组合的页面骨架,组织左侧品牌与导航、右侧顶部操作和独立滚动主体。
|
|
@@ -833,14 +932,16 @@ export default function Demo() {
|
|
|
833
932
|
- AdminLayout.Sider.breakpoint: number. 可选视口断点(px),例如 768。低于断点请求收起,恢复宽屏请求展开;未设置时不自动响应。
|
|
834
933
|
- AdminLayout.Sider.onBreakpoint: (broken: boolean) => void. 监听断点状态;true 表示视口低于设定断点。
|
|
835
934
|
- AdminLayout.Sider.collapseLabel / expandLabel: string (default: 收起侧边栏 / 展开侧边栏). 继承 Sidebar 的切换按钮可访问名称。
|
|
935
|
+
- notice: ReactNode. 可选全宽通知插槽,位于外层布局的侧栏与主栏上方。可放入 GlobalNotice;不随应用内容区切换或滚动。
|
|
836
936
|
- AdminLayout.Header.breadcrumb: ReactNode. 顶部左侧插槽;建议传入已有 Breadcrumb 组件。
|
|
837
|
-
- AdminLayout.Header.extra: ReactNode. 顶部右对齐操作插槽,可组合
|
|
937
|
+
- AdminLayout.Header.extra: ReactNode. 顶部右对齐操作插槽,可组合 Button、Menu、Avatar 等。
|
|
838
938
|
- AdminLayout.Header.children: ReactNode. 顶部左侧补充内容;窄屏允许换行。
|
|
839
939
|
- AdminLayout.Content.as: "main" | "section" | "div" (default: main). 主体语义标签。一个页面通常只使用一个 main;嵌入其他主体时改为 section 或 div。
|
|
840
940
|
- children / className / style / 原生属性: ReactNode / string / CSSProperties / HTMLAttributes. 各区域均可嵌套内容和覆盖样式;默认不生成主体 Footer,显式组合 AdminLayout.Footer 时显示,默认高度 42px。
|
|
941
|
+
- 将跨页面的状态通知放在持续挂载的外层 AdminLayout.notice,不要放在会随路由切换的 Content 子页面。应用负责状态、异步操作和关闭后的焦点。
|
|
841
942
|
- 主体 Footer 与侧栏版本/折叠底栏是独立区域,默认高度均为 42px。需要时加入 <AdminLayout.Footer>内容</AdminLayout.Footer>;主体 Footer 可用 style.height 覆盖高度;--mt-layout-footer-height 可统一覆盖左右两个底栏高度。Topbar 与品牌行使用 --mt-layout-header-height(默认 48px),窄屏内容换行时可自然增高。
|
|
842
943
|
- 使用 AdminLayout.Sider、AdminLayout.Header、AdminLayout.Content、AdminLayout.Footer 组合,不需要单独安装子组件。支持的属性以 mtone 文档与类型声明为准。
|
|
843
|
-
- AdminLayout.Sider 复用本库 Sidebar 的状态、NavItem
|
|
944
|
+
- AdminLayout.Sider 复用本库 Sidebar 的状态、32px 高的 NavItem、图标窄栏和键盘提示,不重写导航逻辑。Header 推荐复用 Breadcrumb、Button 等已有组件。
|
|
844
945
|
- 默认头部 48px,侧栏 240px,窄栏 52px;可通过 width、collapsedWidth 和区域 style 配置。使用有限高度或 fullHeight 后,侧栏内容和 Content 独立滚动,品牌、侧栏底部版本/折叠行与顶部操作保持可见。
|
|
845
946
|
- 响应式收起为图标窄栏,不是弹出式抽屉。breakpoint 按浏览器视口判断,不按示例容器宽度判断;希望自定义手机抽屉时可组合已有 Drawer。
|
|
846
947
|
- 受控状态必须在 onCollapsedChange 中更新,否则切换只发出请求。导航、路由、数据保存、账号菜单与持久化由应用实现。
|
|
@@ -849,7 +950,7 @@ export default function Demo() {
|
|
|
849
950
|
```tsx
|
|
850
951
|
import { useState } from "react";
|
|
851
952
|
import { Box, BookOpen, Home, Settings } from "lucide-react";
|
|
852
|
-
import { AdminLayout, Breadcrumb, NavItem,
|
|
953
|
+
import { AdminLayout, Breadcrumb, NavItem, Button, Card } from "@bixlab/mtone";
|
|
853
954
|
import "@bixlab/mtone/styles.css";
|
|
854
955
|
|
|
855
956
|
export default function Demo() {
|
|
@@ -874,7 +975,7 @@ export default function Demo() {
|
|
|
874
975
|
<AdminLayout>
|
|
875
976
|
<AdminLayout.Header
|
|
876
977
|
breadcrumb={<Breadcrumb items={[{ label: "知识库" }, { label: "设计规范" }]} />}
|
|
877
|
-
extra={<
|
|
978
|
+
extra={<Button iconOnly aria-label="设置"><Settings size={16} /></Button>}
|
|
878
979
|
/>
|
|
879
980
|
<AdminLayout.Content>
|
|
880
981
|
<h1>设计规范</h1>
|
|
@@ -888,52 +989,59 @@ export default function Demo() {
|
|
|
888
989
|
|
|
889
990
|
### Button
|
|
890
991
|
|
|
891
|
-
- [Button](https://xingjianxu.github.io/mtone/#/components/Button):
|
|
992
|
+
- [Button](https://xingjianxu.github.io/mtone/#/components/Button): 带完整样式的基础操作按钮,支持可选的按下状态。
|
|
892
993
|
- Import: Button from @bixlab/mtone
|
|
893
994
|
- variant: "blue" | "solid" | "outline" | "soft" | "ghost" (default: outline). 按钮外观。
|
|
894
|
-
- size:
|
|
995
|
+
- size: ButtonSize (default: normal). small / normal / large 分别高 28 / 32 / 36px;接受旧别名 sm / md / lg。未设置时继承 ButtonGroup,组外为 normal。
|
|
996
|
+
- iconOnly: boolean (default: false). 仅图标的等宽高模式;必须通过 aria-label 或 aria-labelledby 提供操作名称。复用 Button 的尺寸、变体、加载与切换行为。
|
|
895
997
|
- danger: boolean. 危险操作样式;搭配 variant="solid" 显示红色背景、白色文字,悬停保持深红色。
|
|
896
998
|
- loading: boolean. 显示加载图标并禁用点击。
|
|
897
|
-
- icon: ReactNode.
|
|
999
|
+
- icon: ReactNode. 旧版前置图标;未传 leftSection 时使用。
|
|
1000
|
+
- leftSection: ReactNode. 文字前的内容,可放图标或装饰;优先于 icon,传 null 可隐藏旧图标。
|
|
1001
|
+
- preset: "dropdown". 仅外观;在文字后显示 14px 装饰箭头,不打开菜单或添加菜单 ARIA 属性。
|
|
1002
|
+
- rightSection: ReactNode. 文字后的内容,可放图标或装饰;加载期间仍显示。显式设置时优先于 preset,传 null 可隐藏预设箭头。
|
|
1003
|
+
- toggle: boolean | ButtonToggleOptions (default: false). 设为 true 或 { mode: "background" } 时用背景显示按下状态;{ mode: "icon", preset: "star" | "pin" } 用轮廓/实心图标显示状态;亦可用 { mode: "icon", offIcon, onIcon } 自定义一对图标。
|
|
1004
|
+
- pressed: boolean. 开关按钮的受控按下状态;须配合 onPressedChange 更新。
|
|
1005
|
+
- defaultPressed: boolean (default: false). 非受控开关按钮初始是否按下。
|
|
1006
|
+
- onPressedChange: (pressed: boolean) => void. 开关按钮请求切换时调用;禁用、加载或 onClick 调用 preventDefault() 时不调用。
|
|
898
1007
|
- disabled: boolean. 禁用按钮。
|
|
899
1008
|
- onClick: MouseEventHandler. 点击回调。
|
|
900
1009
|
- children: ReactNode. 组件内容。
|
|
901
|
-
-
|
|
1010
|
+
- 文字按钮行高为 20px,标准带边框样式的上下内边距为 3 / 5 / 7px;纯图标按钮与高度等宽,不添加内边距。normal 可用 --mt-height 覆盖。
|
|
1011
|
+
- 未开启 toggle 时保留普通按钮行为,不接管应用手动设置的 aria-pressed。开启时由 Button 提供 aria-pressed。保留前后状态一致的按钮名;纯图标使用固定 aria-label 或 aria-labelledby。
|
|
1012
|
+
- 图标模式不改变按钮背景,切换图标替代左侧 leftSection 与 icon,加载指示器优先,rightSection 保留。preset 和自定义图标对互斥;建议自定义图标两态同尺寸,且不要传入可交互内容。
|
|
1013
|
+
- 例如 <Button toggle>仅显示未读</Button> 或 <Button iconOnly aria-label="收藏" toggle={{ mode: "icon", preset: "star" }} />。
|
|
1014
|
+
- 支持 ref 和 Base UI Button 的可组合属性。加载中显示前置加载图标并禁用按钮,右侧内容不变。
|
|
1015
|
+
- 左右内容按阅读方向排列,在 RTL 中自动对调。传入内容的一侧使用更紧凑的内边距;装饰图标可标记 aria-hidden。
|
|
902
1016
|
- blue 为蓝色实心变体:背景 #2783DE、文字 #F3F9FD,悬停背景 #2276C9,背景颜色过渡 100ms ease-in-out。danger 会优先使用危险操作色。
|
|
903
1017
|
|
|
904
1018
|
```tsx
|
|
1019
|
+
import React from "react";
|
|
1020
|
+
import { ArrowRight, Download, Image, Plus } from "lucide-react";
|
|
905
1021
|
import { Button } from "@bixlab/mtone";
|
|
906
1022
|
import "@bixlab/mtone/styles.css";
|
|
907
1023
|
|
|
908
1024
|
export default function Demo() {
|
|
909
1025
|
return (
|
|
910
|
-
<
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
```tsx
|
|
931
|
-
import { IconButton } from "@bixlab/mtone";
|
|
932
|
-
import "@bixlab/mtone/styles.css";
|
|
933
|
-
|
|
934
|
-
export default function Demo() {
|
|
935
|
-
return (
|
|
936
|
-
<IconButton aria-label="添加">+</IconButton>
|
|
1026
|
+
<div style={{ display: "flex", gap: 8, flexWrap: "wrap" }}>
|
|
1027
|
+
<Button leftSection={<Image size={14} aria-hidden="true" />}>图库</Button>
|
|
1028
|
+
<Button
|
|
1029
|
+
variant="solid"
|
|
1030
|
+
rightSection={<Download size={14} aria-hidden="true" />}
|
|
1031
|
+
>
|
|
1032
|
+
下载
|
|
1033
|
+
</Button>
|
|
1034
|
+
<Button
|
|
1035
|
+
variant="soft"
|
|
1036
|
+
leftSection={<Image size={14} aria-hidden="true" />}
|
|
1037
|
+
rightSection={<ArrowRight size={14} aria-hidden="true" />}
|
|
1038
|
+
>
|
|
1039
|
+
查看图库
|
|
1040
|
+
</Button>
|
|
1041
|
+
<Button iconOnly aria-label="添加文档">
|
|
1042
|
+
<Plus size={16} aria-hidden="true" />
|
|
1043
|
+
</Button>
|
|
1044
|
+
</div>
|
|
937
1045
|
);
|
|
938
1046
|
}
|
|
939
1047
|
```
|
|
@@ -941,19 +1049,20 @@ export default function Demo() {
|
|
|
941
1049
|
### ButtonGroup
|
|
942
1050
|
|
|
943
1051
|
- [ButtonGroup](https://xingjianxu.github.io/mtone/#/components/ButtonGroup): 将关联按钮组织为一个操作组,支持默认分开排列或相连组合。
|
|
944
|
-
- Import: ButtonGroup, Button,
|
|
1052
|
+
- Import: ButtonGroup, Button, Menu from @bixlab/mtone
|
|
1053
|
+
- size: ButtonSize. 未单独设置尺寸的 Button 会继承,含 Menu 的 Button 触发器;支持 small / normal / large 与 sm / md / lg,外层未设置时为 normal。
|
|
945
1054
|
- connected: boolean (default: false). 相连样式:移除间距、共享边框,仅保留外侧圆角。
|
|
946
1055
|
- children: ReactNode. 组件内容。
|
|
947
1056
|
- 原生属性: HTMLAttributes. 支持对应元素的 className、style 与适用的 DOM 属性;以 TypeScript 定义为准。
|
|
948
1057
|
- Menu 的 trigger 直接渲染为组内按钮,无需外层包裹;主按钮执行默认动作,箭头按钮打开其他选项。示例只展示操作反馈,不下载真实文件。
|
|
949
|
-
- 默认保留 4px
|
|
1058
|
+
- 默认保留 4px 间距。相连模式请直接放置 Button(可使用 iconOnly);在 ButtonGroup 设置 size 可统一尺寸,子按钮显式 size 会覆盖继承值。
|
|
950
1059
|
- 使用 aria-label 为操作组命名;保留各按钮的原生 Tab 导航,不是单选分段控件。
|
|
951
1060
|
- 危险实心按钮使用 <Button danger variant="solid">删除</Button>。
|
|
952
1061
|
|
|
953
1062
|
```tsx
|
|
954
1063
|
import { useState } from "react";
|
|
955
1064
|
import { ChevronDown } from "lucide-react";
|
|
956
|
-
import { ButtonGroup, Button,
|
|
1065
|
+
import { ButtonGroup, Button, Menu } from "@bixlab/mtone";
|
|
957
1066
|
import "@bixlab/mtone/styles.css";
|
|
958
1067
|
|
|
959
1068
|
export default function Demo() {
|
|
@@ -963,7 +1072,7 @@ export default function Demo() {
|
|
|
963
1072
|
<ButtonGroup connected aria-label="导出文档">
|
|
964
1073
|
<Button onClick={() => setMessage("已选择导出 PDF")}>导出 PDF</Button>
|
|
965
1074
|
<Menu
|
|
966
|
-
trigger={<
|
|
1075
|
+
trigger={<Button iconOnly aria-label="更多导出格式"><ChevronDown size={14} /></Button>}
|
|
967
1076
|
items={[
|
|
968
1077
|
{ key: "markdown", label: "导出 Markdown", onSelect: () => setMessage("已选择导出 Markdown") },
|
|
969
1078
|
{ key: "html", label: "导出 HTML", onSelect: () => setMessage("已选择导出 HTML") },
|
|
@@ -998,7 +1107,7 @@ export default function Demo() {
|
|
|
998
1107
|
- Input.OTP: length / mask / separator: number / boolean / ReactNode. 默认6格,限制1–32;mask 使用原生密码显示,separator 在格间显示装饰。
|
|
999
1108
|
- Input.OTP: inputMode / name / form / disabled / readOnly: native attributes. inputMode 默认 numeric,仅作为键盘提示,不限制内容;name 通过隐藏字段提交整串值。
|
|
1000
1109
|
- Input.OTP: controlSize / ref / aria-label: 'sm' | 'md' | 'lg' / Ref<HTMLInputElement> / string. ref 指向第一格;为验证码组提供可访问名称。
|
|
1001
|
-
- 默认单行
|
|
1110
|
+
- 默认单行32px,sm为24px,lg为36px;焦点保持浅蓝 #93B4DC 的1px细边框,不加粗。
|
|
1002
1111
|
- Input.Search 是搜索子组件;SearchInput 是同一组件的兼容导出。Input.TextArea 与 Textarea 也是同一组件;新代码推荐子组件写法。
|
|
1003
1112
|
- 原生 size、type、name、form、aria-* 和原生 ref 保留。className/style 面向原生输入,不代表外层容器。
|
|
1004
1113
|
- Input.OTP 支持粘贴、组合输入、方向键与删除;删除会将后续字符前移,不保留空格占位。空白字符会移除。mask 不提供任意字符替换。
|
|
@@ -1030,7 +1139,7 @@ export default function Demo() {
|
|
|
1030
1139
|
- disabled / readOnly: boolean. 禁用或只读。
|
|
1031
1140
|
- aria-label / id: string. 可访问名称或与 label 关联的标识。
|
|
1032
1141
|
- 原生属性: HTMLAttributes. 支持对应元素的 className、style 与适用的 DOM 属性;以 TypeScript 定义为准。
|
|
1033
|
-
- 默认单行外框高度为
|
|
1142
|
+
- 默认单行外框高度为 32px(含边框),搜索图标垂直居中,可通过 --mt-height 定制。
|
|
1034
1143
|
- 输入表面聚焦时只将现有边框改为 #93B4DC,不加粗、不加外圈;错误与禁用状态保留,强制颜色模式使用系统焦点提示。
|
|
1035
1144
|
- 支持对应原生输入元素属性和 ref。占位提示不能替代标签。
|
|
1036
1145
|
|
|
@@ -1307,7 +1416,7 @@ export default function Demo() {
|
|
|
1307
1416
|
- defaultOpen: boolean. 非受控初始开关。
|
|
1308
1417
|
- onOpenChange: (open: boolean) => void. 开关变化回调。
|
|
1309
1418
|
- 同组相邻菜单或选项行之间保留 3px 间距;首项、分组标题和分隔线不额外增加间距。
|
|
1310
|
-
- 默认单行外框高度为
|
|
1419
|
+
- 默认单行外框高度为 32px(含边框);长选中标签在行内省略。可用 className 覆盖尺寸。
|
|
1311
1420
|
- 输入表面聚焦时只将现有边框改为 #93B4DC,不加粗、不加外圈;错误与禁用状态保留,强制颜色模式使用系统焦点提示。
|
|
1312
1421
|
- 支持键盘选择、禁用选项和焦点恢复。
|
|
1313
1422
|
- 选中项使用垂直居中的 16px Lucide Check 细线对号(1.5px 描边),无需新增属性配置。
|
|
@@ -1337,7 +1446,7 @@ export default function Demo() {
|
|
|
1337
1446
|
- expanded / defaultExpanded: boolean. 受控展开状态或初始展开状态,默认折叠。
|
|
1338
1447
|
- onExpandedChange: (expanded: boolean) => void. 请求切换展开状态时触发。
|
|
1339
1448
|
- expandLabel / collapseLabel: string. 展开与收起按钮文字,默认「展开」与「收起」。
|
|
1340
|
-
-
|
|
1449
|
+
- 选项按钮、展开按钮及单行折叠视口统一采用 32px 基准高度。建议用 aria-label 或 aria-labelledby 为整组选项命名。折叠不会清除已选值。
|
|
1341
1450
|
|
|
1342
1451
|
```tsx
|
|
1343
1452
|
import { TagSelect } from "@bixlab/mtone";
|
|
@@ -1368,7 +1477,7 @@ export default function Demo() {
|
|
|
1368
1477
|
- defaultOpen: boolean. 非受控初始开关。
|
|
1369
1478
|
- onOpenChange: (open: boolean) => void. 开关变化回调。
|
|
1370
1479
|
- 同组相邻菜单或选项行之间保留 3px 间距;首项、分组标题和分隔线不额外增加间距。
|
|
1371
|
-
- 默认单行外框最小高度为
|
|
1480
|
+
- 默认单行外框最小高度为 32px(含边框);多个标签换行时自动增高,不强制裁剪为 32px;可用 className 定制。
|
|
1372
1481
|
- 输入表面聚焦时只将现有边框改为 #93B4DC,不加粗、不加外圈;错误与禁用状态保留,强制颜色模式使用系统焦点提示。
|
|
1373
1482
|
- MultiSelect 建议使用纯文本 label,以确保搜索与标签显示正确。
|
|
1374
1483
|
|
|
@@ -1422,7 +1531,7 @@ export default function Demo() {
|
|
|
1422
1531
|
- onValueChange: (value: number | null) => void. 值变化回调。
|
|
1423
1532
|
- min / max: number. 数值下限与上限。
|
|
1424
1533
|
- step: number. 步进大小。
|
|
1425
|
-
- 默认整体外框高度为
|
|
1534
|
+
- 默认整体外框高度为 32px(含边框),增减按钮位于边框内。可用 className 定制尺寸。
|
|
1426
1535
|
- 输入表面聚焦时只将现有边框改为 #93B4DC,不加粗、不加外圈;错误与禁用状态保留,强制颜色模式使用系统焦点提示。
|
|
1427
1536
|
- 清空时 value 可为 null;defaultValue 应传 number。
|
|
1428
1537
|
|
|
@@ -1451,7 +1560,7 @@ export default function Demo() {
|
|
|
1451
1560
|
- min / max: string. ISO YYYY-MM-DD 日期边界。
|
|
1452
1561
|
- disabledDate: (date: string) => boolean. 返回 true 的日期在选择后被拒绝。
|
|
1453
1562
|
- clearable: boolean (default: true). 显示清除按钮。
|
|
1454
|
-
- 默认单行输入外框高度为
|
|
1563
|
+
- 默认单行输入外框高度为 32px(含边框),可通过 --mt-height 定制。原生日历弹层尺寸由浏览器决定。
|
|
1455
1564
|
- 输入表面聚焦时只将现有边框改为 #93B4DC,不加粗、不加外圈;错误与禁用状态保留,强制颜色模式使用系统焦点提示。
|
|
1456
1565
|
- 值为 YYYY-MM-DD,清空返回空字符串,不进行 UTC 转换。
|
|
1457
1566
|
- 日历外观和键盘操作由浏览器决定;disabledDate 不会在原生日历中绘制禁用状态。
|
|
@@ -1483,8 +1592,8 @@ export default function Demo() {
|
|
|
1483
1592
|
- collapseLabel / expandLabel: string (default: 收起侧边栏 / 展开侧边栏). 切换按钮的可访问名称和提示,可本地化。
|
|
1484
1593
|
- children: ReactNode. 组件内容。
|
|
1485
1594
|
- 原生属性: HTMLAttributes. 支持对应元素的 className、style 与适用的 DOM 属性;以 TypeScript 定义为准。
|
|
1486
|
-
-
|
|
1487
|
-
- 收起为 52px 图标窄栏,NavItem 保留可访问名称;NavGroup
|
|
1595
|
+
- NavItem 默认行高为 32px,图标与文字垂直居中。相邻项间距不变,分组标题和分隔线不受行高影响。
|
|
1596
|
+
- 收起为 52px 图标窄栏,NavItem 保留可访问名称;NavGroup 隐藏标题与标题操作,保留默认分组分隔(可用 divider={false} 关闭)。建议每个 NavItem 提供 icon,没有图标时显示圆形占位。
|
|
1488
1597
|
- 收起时悬停或键盘聚焦显示提示,Escape 可关闭提示。复杂 children 请提供 aria-label 作为提示文字。
|
|
1489
1598
|
- 受控用法:const [collapsed, setCollapsed] = useState(false); <Sidebar collapsible collapsed={collapsed} onCollapsedChange={setCollapsed}>…</Sidebar>。
|
|
1490
1599
|
- 不接管路由、固定定位、持久化或响应式断点。不要用固定 width 覆盖收起宽度;自定义内容需自行适配窄栏。
|
|
@@ -1502,14 +1611,20 @@ export default function Demo() {
|
|
|
1502
1611
|
|
|
1503
1612
|
### NavItem
|
|
1504
1613
|
|
|
1505
|
-
- [NavItem](https://xingjianxu.github.io/mtone/#/components/NavItem):
|
|
1614
|
+
- [NavItem](https://xingjianxu.github.io/mtone/#/components/NavItem): 支持当前状态和图标的导航项,可作为按钮或原生链接,并可添加独立的尾部操作。
|
|
1506
1615
|
- Import: NavItem from @bixlab/mtone
|
|
1507
1616
|
- active: boolean. 设置当前项样式和 aria-current。
|
|
1508
1617
|
- icon: ReactNode. 前置图标。
|
|
1618
|
+
- actions: NavItemAction | readonly NavItemAction[]. 一个或多个尾部操作:{ content: ReactNode, visibility?: 'always' | 'hover' | 'active' }。默认 always;hover 在悬停、行内键盘聚焦和无悬停设备上显示;导航本身无法通过 Tab 聚焦时操作仍可见。active 只在当前项显示。
|
|
1619
|
+
- href: string. 提供时渲染原生链接,支持 target、rel、键盘和浏览器原生打开行为。
|
|
1620
|
+
- disabled: boolean. 禁用时阻止激活;链接移除实际 href 和 Tab 停靠点。
|
|
1509
1621
|
- onClick: MouseEventHandler. 由应用执行导航。
|
|
1510
1622
|
- children: ReactNode. 组件内容。
|
|
1511
|
-
- 原生属性:
|
|
1512
|
-
-
|
|
1623
|
+
- 原生属性: ButtonHTMLAttributes | AnchorHTMLAttributes. 支持对应元素的 className、style 与适用的 DOM 属性;以 TypeScript 定义为准。
|
|
1624
|
+
- 当前页使用灰色圆角底和逻辑起始侧蓝色竖标;悬停不显示竖标。
|
|
1625
|
+
- 默认行高 32px,图标和标签垂直居中。长纯文本标签单行省略,仍保留完整的可访问名称;可通过 --mt-height 调整。
|
|
1626
|
+
- 尾部操作不触发导航。建议使用提供可访问名称的 Button iconOnly;Sidebar 的图标窄栏隐藏尾部操作,窄栏子菜单弹层中的完整行仍显示。
|
|
1627
|
+
- 不提供 href 时仍为按钮。ref 指向实际 button 或 a;组件不接管路由。
|
|
1513
1628
|
|
|
1514
1629
|
```tsx
|
|
1515
1630
|
import { NavItem } from "@bixlab/mtone";
|
|
@@ -1522,21 +1637,61 @@ export default function Demo() {
|
|
|
1522
1637
|
}
|
|
1523
1638
|
```
|
|
1524
1639
|
|
|
1640
|
+
### NavSubmenu
|
|
1641
|
+
|
|
1642
|
+
- [NavSubmenu](https://xingjianxu.github.io/mtone/#/components/NavSubmenu): 有子项的侧边栏导航;展开时内联,收起时侧向弹出。
|
|
1643
|
+
- Import: NavSubmenu, NavItem, Sidebar from @bixlab/mtone
|
|
1644
|
+
- label: ReactNode. 必填分支名称,窄栏下仍作为按钮的可访问名称。
|
|
1645
|
+
- children: ReactNode. 必填子导航,使用 NavItem。
|
|
1646
|
+
- icon: ReactNode. 可选图标;窄栏中省略时显示圆形占位。
|
|
1647
|
+
- defaultExpanded: boolean (default: false). 非受控内联初始状态。
|
|
1648
|
+
- expanded: boolean. 受控内联状态,不控制窄栏弹出层。
|
|
1649
|
+
- onExpandedChange: (expanded: boolean) => void. 用户切换内联展开状态时调用。
|
|
1650
|
+
- disabled: boolean (default: false). 禁用分支触发按钮。
|
|
1651
|
+
- 只提供一层子导航。静态分组用 NavGroup;当前页状态设置在 NavItem 的 active 上,有当前子项时父项仅加粗标题。
|
|
1652
|
+
- Sidebar 或 AdminLayout.Sider 收起时,子项在可键盘操作的侧向浮层中展示,选中子项关闭浮层。切回宽栏后还原内联展开状态。
|
|
1653
|
+
|
|
1654
|
+
```tsx
|
|
1655
|
+
import { NavSubmenu, NavItem, Sidebar } from "@bixlab/mtone";
|
|
1656
|
+
import "@bixlab/mtone/styles.css";
|
|
1657
|
+
|
|
1658
|
+
export default function Demo() {
|
|
1659
|
+
return <Sidebar collapsible><NavSubmenu label="账单与许可" defaultExpanded><NavItem active>用量</NavItem><NavItem>许可</NavItem></NavSubmenu></Sidebar>;
|
|
1660
|
+
}
|
|
1661
|
+
```
|
|
1662
|
+
|
|
1525
1663
|
### NavGroup
|
|
1526
1664
|
|
|
1527
|
-
- [NavGroup](https://xingjianxu.github.io/mtone/#/components/NavGroup):
|
|
1528
|
-
- Import: NavGroup, NavItem from @bixlab/mtone
|
|
1665
|
+
- [NavGroup](https://xingjianxu.github.io/mtone/#/components/NavGroup): 以可选标题组织导航项,相邻组默认以细线分隔,标题末端可放置独立操作。
|
|
1666
|
+
- Import: NavGroup, NavItem, Button from @bixlab/mtone
|
|
1529
1667
|
- label: ReactNode. 可选分组标题。
|
|
1668
|
+
- divider: boolean (default: true). 仅在前一个兄弟元素也是 NavGroup 时绘制组前分隔线。设为 false 只隐藏这一条线,不改变间距。
|
|
1669
|
+
- actions: ReactNode. 标题行末端的独立操作。可传入一个控件,或用片段组合多个控件;无标题时仍可单独显示。收起的 Sidebar 隐藏此操作区。
|
|
1530
1670
|
- children: ReactNode. 组件内容。
|
|
1531
|
-
-
|
|
1671
|
+
- 组前分隔线是装饰,不会出现在无障碍树中。独立导航和 Sidebar 展开、收起时均支持相邻组分隔;有其它导航项隔开时不画线。
|
|
1672
|
+
- 组内 NavItem 默认行高 32px,相邻项仍保留 3px 间距。首组不额外加上方空白;后续分组上间距仍为 12px,侧边栏自身的内边距不变。
|
|
1673
|
+
- 标题操作不触发导航项;建议使用 size="sm"、variant="ghost" 的 Button iconOnly 并提供可访问名称。操作区与标题分开布局,过长的标题会截断。
|
|
1532
1674
|
|
|
1533
1675
|
```tsx
|
|
1534
|
-
import {
|
|
1676
|
+
import { useState } from "react";
|
|
1677
|
+
import { NavGroup, NavItem, Button } from "@bixlab/mtone";
|
|
1535
1678
|
import "@bixlab/mtone/styles.css";
|
|
1536
1679
|
|
|
1537
1680
|
export default function Demo() {
|
|
1681
|
+
const [viewCount, setViewCount] = useState(0);
|
|
1538
1682
|
return (
|
|
1539
|
-
<
|
|
1683
|
+
<nav aria-label="工作空间">
|
|
1684
|
+
<NavGroup label="个人空间">
|
|
1685
|
+
<NavItem active>工作笔记</NavItem>
|
|
1686
|
+
<NavItem>阅读记录</NavItem>
|
|
1687
|
+
</NavGroup>
|
|
1688
|
+
<NavGroup label="保存的视图" actions={<Button iconOnly size="sm" variant="ghost" aria-label="新增视图" onClick={() => setViewCount((count) => count + 1)}>+</Button>}>
|
|
1689
|
+
<NavItem>保存的视图:{viewCount}</NavItem>
|
|
1690
|
+
</NavGroup>
|
|
1691
|
+
<NavGroup label="工具" divider={false}>
|
|
1692
|
+
<NavItem>设置</NavItem>
|
|
1693
|
+
</NavGroup>
|
|
1694
|
+
</nav>
|
|
1540
1695
|
);
|
|
1541
1696
|
}
|
|
1542
1697
|
```
|
|
@@ -1665,15 +1820,16 @@ export default function Demo() {
|
|
|
1665
1820
|
|
|
1666
1821
|
### Tabs
|
|
1667
1822
|
|
|
1668
|
-
- [Tabs](https://xingjianxu.github.io/mtone/#/components/Tabs):
|
|
1823
|
+
- [Tabs](https://xingjianxu.github.io/mtone/#/components/Tabs): 中性风格的标签切换,支持顶部贴合、卡片编辑、多方向布局和溢出导航。
|
|
1669
1824
|
- Import: Tabs from @bixlab/mtone
|
|
1670
1825
|
- items: TabItem[]. 必填;value、label、content,另可设 disabled、icon、closable、closeLabel、forceRender、destroyOnHidden。
|
|
1671
1826
|
- value / defaultValue: string. 受控/初始值;省略时选择首个未禁用项。
|
|
1672
1827
|
- onValueChange: (value: string) => void. 用户切换及非受控有效回退时触发。
|
|
1673
1828
|
- placement: "top" | "bottom" | "start" | "end". 默认 top;start/end 为逻辑方向。
|
|
1674
|
-
- variant: "line" | "card" | "editable-card". 默认 line。
|
|
1675
|
-
- size: "small" | "medium" | "large". 默认 medium
|
|
1676
|
-
-
|
|
1829
|
+
- variant: "line" | "card" | "editable-card" | "attached". 默认 line。attached 的顶部选中项与内容区相接;bottom/start/end 保留指定位置并使用 line 样式。
|
|
1830
|
+
- size: "small" | "medium" | "large". 默认 medium。所有变体、尺寸和位置的标签项外高均为 32px(含边框);size 仍区分字号。
|
|
1831
|
+
- indicatorColor: TabsIndicatorColor (default: currentColor). 使用 line 样式时的选中指示线颜色,包含 attached 在非顶部位置的线型回退。支持主题预设 neutral/blue/green/orange/red/purple/teal/coral,或任意有效 CSS 颜色;不改变基准线和文字颜色。
|
|
1832
|
+
- centered / gap: boolean / number. 居中排列(溢出时回到起点);间隔单位 px,最小 0。默认线型为 6px,card/editable-card 和顶部 attached 为 4px。
|
|
1677
1833
|
- extraStart / extraEnd: ReactNode. 导航栏前后附加内容。
|
|
1678
1834
|
- activateOnFocus: boolean. 默认 false,方向键移动焦点不立即切换。
|
|
1679
1835
|
- destroyOnHidden: boolean. 默认 true,卸载隐藏面板;false 保留已访问面板状态。
|
|
@@ -1688,6 +1844,9 @@ export default function Demo() {
|
|
|
1688
1844
|
- 默认 destroyOnHidden=true 延续旧版隐藏面板卸载行为;false 时仅保留访问过的面板。forceRender 让该面板始终挂载;项目级 destroyOnHidden 可覆盖全局值。
|
|
1689
1845
|
- 非受控选中项被删除或禁用时切换到首个可用项;无可用项时不选中且不发送字符串 null。受控模式由应用更新 value,非法或禁用 value 不自动纠正。
|
|
1690
1846
|
- editable-card 的增删只发送回调,不修改 items;应用需更新列表,并在受控模式下选中有效新值。关闭按钮不会选择被关闭标签。
|
|
1847
|
+
- 主题通过 --mt-accent-* 为指示线和其他组件提供共享色;可在 MtoneProvider tokens 内覆盖。强制色彩模式保留系统可见线条。
|
|
1848
|
+
- 顶部 attached 使用淡底导航栏和单条分隔线。选中项保留上边与左右边,悬停仍使用面板底色;未选中项透明无描边。
|
|
1849
|
+
- 线型标签文字两侧各保留 6px 外边距。卡片式与可编辑卡片式的选中标签悬停时保持原背景。
|
|
1691
1850
|
- 溢出时保留原生滚动条并提供更多菜单(列出全部标签);垂直导航默认最大高度320px,可用 --mt-tabs-max-height 调整。
|
|
1692
1851
|
- 默认方向键只移动焦点,Enter/Space 激活;activateOnFocus 可改为自动激活。启用排序后 Alt+Shift+方向键请求相邻排序,原生拖放不支持触摸;回调由应用更新 items。
|
|
1693
1852
|
- 未实现自定义 tabBar 渲染器、指示线动画引擎或更多菜单搜索。标签 label 请勿嵌入交互控件。
|
|
@@ -1726,7 +1885,7 @@ export default function Demo() {
|
|
|
1726
1885
|
- Import: FilterChip from @bixlab/mtone
|
|
1727
1886
|
- children: ReactNode. 组件内容。
|
|
1728
1887
|
- onRemove: () => void. 必填;移除请求,由应用更新条件。
|
|
1729
|
-
- 默认单行外框高度为
|
|
1888
|
+
- 默认单行外框高度为 32px,与输入及选择控件对齐。可通过宿主 CSS 覆盖 .mt-filter-chip 的尺寸,不新增 size 属性。
|
|
1730
1889
|
- 点击移除不会自行隐藏,应用负责更新状态。
|
|
1731
1890
|
|
|
1732
1891
|
```tsx
|
|
@@ -1767,32 +1926,6 @@ export default function Demo() {
|
|
|
1767
1926
|
}
|
|
1768
1927
|
```
|
|
1769
1928
|
|
|
1770
|
-
### Dropdown
|
|
1771
|
-
|
|
1772
|
-
- [Dropdown](https://xingjianxu.github.io/mtone/#/components/Dropdown): 独立的触发式下拉容器,承载任意自定义内容,默认按内容宽度。
|
|
1773
|
-
- Import: Dropdown, Button from @bixlab/mtone
|
|
1774
|
-
- trigger: ReactElement. 必填;触发元素,需转发 ref 与 DOM props。
|
|
1775
|
-
- content: ReactNode. 必填;任意下拉内容。点击内部内容不会自动关闭。
|
|
1776
|
-
- label: string. 非模态 dialog 的可访问名称;默认中文为下拉内容,英文为 Dropdown content。
|
|
1777
|
-
- width: CSSProperties['width']. 默认按内容宽度,最小 160px,不跟随 trigger;number 为 px,也可用 rem/ch/vw 等 CSS 宽度。显式宽度允许小于 160px;最终受可用视口宽度约束。
|
|
1778
|
-
- align: 'start' | 'end' | 'left' | 'right' (default: start). 首选与 trigger 的对齐边。left/right 是物理左右;start/end 在 RTL 中反转。空间不足时自动避让、移位或翻转。
|
|
1779
|
-
- open: boolean. 受控开关。
|
|
1780
|
-
- defaultOpen: boolean. 非受控初始开关。
|
|
1781
|
-
- onOpenChange: (open: boolean) => void. 开关变化回调。
|
|
1782
|
-
- Dropdown 是非模态 dialog,使用 Tab 导航自定义交互内容。操作菜单请使用 Menu,它保留菜单语义与方向键导航;两者共享浮层实现而不是嵌套浮层。
|
|
1783
|
-
- Escape、外部点击可关闭并由 Base UI 管理焦点返回。内部保存/取消动作需要关闭时,使用 open/onOpenChange 自行控制。
|
|
1784
|
-
- LTR 下 start 是左边、end 是右边;RTL 下相反。left/right 始终表示物理左右。RTL 交互需由 @base-ui/react/direction-provider 的 DirectionProvider direction=rtl 提供方向上下文,并设置相应 DOM dir。
|
|
1785
|
-
- 默认宽度 max-content,最小宽度 160px;窄屏时最小宽度也会收缩。超长文本折行,超过最大高度的内容滚动。百分比宽度相对于定位容器,不是 trigger,优先使用像素或 rem/ch 等明确长度。
|
|
1786
|
-
|
|
1787
|
-
```tsx
|
|
1788
|
-
import { Dropdown, Button } from "@bixlab/mtone";
|
|
1789
|
-
import "@bixlab/mtone/styles.css";
|
|
1790
|
-
|
|
1791
|
-
export default function Demo() {
|
|
1792
|
-
return <Dropdown trigger={<Button>查看信息</Button>} align="right" width={240} label="文档信息" content={<div style={{padding:8}}>这里可以放置说明、表单或自定义内容。</div>} />;
|
|
1793
|
-
}
|
|
1794
|
-
```
|
|
1795
|
-
|
|
1796
1929
|
### Menubar
|
|
1797
1930
|
|
|
1798
1931
|
- [Menubar](https://xingjianxu.github.io/mtone/#/components/Menubar): 桌面应用式菜单栏,协调多个操作菜单,支持子菜单、分组及键盘导航。
|
|
@@ -1808,7 +1941,7 @@ export default function Demo() {
|
|
|
1808
1941
|
- align: 'start' | 'end' | 'left' | 'right' (default: start). 顶层浮层首选对齐边;单个菜单 align 优先。start/end 随 RTL 变化,left/right 是物理左右,受视口碰撞处理约束。
|
|
1809
1942
|
- HTML div attributes: HTMLAttributes<HTMLDivElement>. 支持 aria-label、className、style 等根元素属性;不接受 children,通过 menus 定义菜单。
|
|
1810
1943
|
- 同组相邻菜单或选项行之间保留 3px 间距;首项、分组标题和分隔线不额外增加间距。
|
|
1811
|
-
- Menubar 是多个命令菜单的协调容器,一次打开一个顶层菜单;单一操作入口用 Menu,任意自定义浮层内容用
|
|
1944
|
+
- Menubar 是多个命令菜单的协调容器,一次打开一个顶层菜单;单一操作入口用 Menu,任意自定义浮层内容用 Popover。三者共享浮层样式,Menubar 与 Menu 保留菜单语义,不嵌套额外 dialog。
|
|
1812
1945
|
- 菜单栏作为一个 Tab 停靠点,左右方向键移动顶层焦点;Enter、Space 或向下键进入菜单,Escape 退出并返回触发项。键盘逻辑由 Base UI 管理。快捷键文字仅展示,不注册全局快捷键。
|
|
1813
1946
|
- RTL 同时提供 @base-ui/react/direction-provider 的 DirectionProvider direction=rtl 与 DOM dir=rtl;start/end 和左右方向键按方向上下文工作。
|
|
1814
1947
|
- 菜单栏保持单行,窄屏时横向滚动;浮层受可用视口宽高限制。保留 mtone 紧凑高度、灰色背景与淡蓝色细边框。
|
|
@@ -1826,18 +1959,20 @@ export default function Demo() {
|
|
|
1826
1959
|
|
|
1827
1960
|
### Menu
|
|
1828
1961
|
|
|
1829
|
-
- [Menu](https://xingjianxu.github.io/mtone/#/components/Menu):
|
|
1962
|
+
- [Menu](https://xingjianxu.github.io/mtone/#/components/Menu): 默认点击打开的操作菜单,可启用悬停,支持分组与多级子菜单。
|
|
1830
1963
|
- Import: Menu, Button from @bixlab/mtone
|
|
1831
1964
|
- width: CSSProperties['width']. 主菜单默认按内容宽度(最小160px),不再与trigger等宽;可指定number像素或CSS宽度,受可用视口宽度限制。子菜单独立按内容宽度,不继承此值。
|
|
1832
1965
|
- align: 'start' | 'end' | 'left' | 'right' (default: start). 主菜单与trigger对齐边;left/right是物理左右,start/end随DirectionProvider的RTL方向变化,碰撞时可自动调整。
|
|
1833
|
-
- trigger: ReactElement.
|
|
1966
|
+
- trigger: string | ReactElement. 必填。文字使用内容宽度的预设下拉按钮;传 React 元素可完全自定义触发外观。
|
|
1967
|
+
- triggerMode: "click" | "hover" (default: click). 主菜单触发方式。hover 启用桌面鼠标悬停,仍支持点击、键盘和触屏;仅悬停打开时不移动键盘焦点。
|
|
1834
1968
|
- items: MenuEntry[]. 必填;普通项 key、label,可选 icon、shortcut、disabled、danger、onSelect、children(非空时为子菜单);分组 {type: 'group', key, label, children};分隔线 {type: 'divider', key};复选项 type: 'checkbox';单选组 type: 'radio-group'。
|
|
1835
1969
|
- onSelect: (key: string) => void. 选中叶子项时调用;展开子菜单不触发。先执行项自己的 onSelect,再执行此回调。
|
|
1836
1970
|
- open: boolean. 受控开关。
|
|
1837
1971
|
- defaultOpen: boolean. 非受控初始开关。
|
|
1838
1972
|
- onOpenChange: (open: boolean) => void. 开关变化回调。
|
|
1973
|
+
- 悬停时鼠标可以从触发器跨过间隙进入菜单并继续进入子菜单;离开菜单区域后关闭。受控 open / onOpenChange 与条目选择规则不变。
|
|
1839
1974
|
- 同组相邻菜单或选项行之间保留 3px 间距;首项、分组标题和分隔线不额外增加间距。
|
|
1840
|
-
- Menu
|
|
1975
|
+
- Menu 与 Popover 共用浮层定位和外观基础,但 Menu 保留菜单语义、方向键与选择关闭。通用自定义内容使用 Popover。默认不再跟随trigger宽度,需旧等宽效果时传具体width。RTL同时提供Base UI DirectionProvider与DOM dir。
|
|
1841
1976
|
- 同一菜单面板任意项渲染左侧 icon 时,所有项保留 16px 图标列和 8px 间距;全部为空则移除该列。动态变化会同步对齐,shortcut 不参与图标判断。支持 children 子菜单、type: group 分组(label + children)与 type: divider 分隔线。icon 渲染为 null 时不占列;若自定义 icon 输出空元素或隐藏元素,仍视作图标内容。
|
|
1842
1977
|
- 快捷键文字仅作提示,不注册全局快捷键。自定义 trigger 需转发 ref 与 DOM props。
|
|
1843
1978
|
- 复选项 type: checkbox 支持 checked/defaultChecked、onCheckedChange 与 closeOnClick(默认 false)。单选组 type: radio-group 支持 label、value/defaultValue、onValueChange 与 children,子项 key 是选择值;选择后保持打开。两类选择使用各自变更回调,不调用 Menu 的 onSelect。
|
|
@@ -1845,13 +1980,13 @@ export default function Demo() {
|
|
|
1845
1980
|
- 子菜单支持悬停、点击与左右方向键;Escape 关闭当前子菜单,再次 Escape 关闭主菜单并返回触发器。空 children 按普通叶子项处理,父项 onSelect 和 shortcut 不用于子菜单。key 请在每个同级列表内保持唯一。菜单项高亮使用灰色背景与 1px 淡蓝边框,不改变 Select 样式。
|
|
1846
1981
|
|
|
1847
1982
|
```tsx
|
|
1848
|
-
import { Menu
|
|
1983
|
+
import { Menu } from "@bixlab/mtone";
|
|
1849
1984
|
import { FileText } from "lucide-react";
|
|
1850
1985
|
import "@bixlab/mtone/styles.css";
|
|
1851
1986
|
|
|
1852
1987
|
export default function Demo() {
|
|
1853
1988
|
return (
|
|
1854
|
-
<Menu trigger=
|
|
1989
|
+
<Menu trigger="文档操作" items={[{type:"group",key:"files",label:"文档",children:[{key:"open",label:"打开",icon:<FileText />},{key:"export",label:"导出",children:[{key:"pdf",label:"PDF"},{key:"markdown",label:"Markdown"}]}]},{type:"divider",key:"divider"},{key:"delete",label:"移至回收站",danger:true}]} onSelect={(key) => console.log(key)} />
|
|
1855
1990
|
);
|
|
1856
1991
|
}
|
|
1857
1992
|
```
|
|
@@ -1884,24 +2019,28 @@ export default function Demo() {
|
|
|
1884
2019
|
|
|
1885
2020
|
### Popover
|
|
1886
2021
|
|
|
1887
|
-
- [Popover](https://xingjianxu.github.io/mtone/#/components/Popover):
|
|
1888
|
-
- Import: Popover
|
|
1889
|
-
- trigger: ReactElement.
|
|
2022
|
+
- [Popover](https://xingjianxu.github.io/mtone/#/components/Popover): 点击打开的非模态浮层,适合信息、表单和自定义卡片。
|
|
2023
|
+
- Import: Popover from @bixlab/mtone
|
|
2024
|
+
- trigger: string | ReactElement. 必填;字符串使用 Button 的 dropdown 预设,自定义触发器可传 React 元素。
|
|
1890
2025
|
- content: ReactNode. 必填;浮层内容。
|
|
1891
2026
|
- title: ReactNode. 浮层标题。
|
|
2027
|
+
- label: string. 浮层的可访问名称,优先于可见 title。无 title 和 label 时默认使用浮层内容 / Popover content。
|
|
2028
|
+
- width: number | string. 浮层宽度,数字为 px;默认随内容而非触发按钮,且自动约束在视口内。
|
|
2029
|
+
- align: "start" | "center" | "end" | "left" | "right" (default: center). 沿边对齐。上下浮层的 start/end 随布局方向,left/right 为物理边;左右浮层用 start/end 对齐上/下边。
|
|
2030
|
+
- unstyled: boolean (default: false). 去除浮层自身的背景、边框、阴影和内边距,保留定位及非模态行为;适合让 Card 绘制外框。
|
|
1892
2031
|
- side: "top" | "bottom" | "left" | "right" (default: bottom). 优先显示位置。
|
|
1893
2032
|
- open: boolean. 受控开关。
|
|
1894
2033
|
- defaultOpen: boolean. 非受控初始开关。
|
|
1895
2034
|
- onOpenChange: (open: boolean) => void. 开关变化回调。
|
|
1896
|
-
-
|
|
2035
|
+
- Popover 是非模态 dialog,可使用 Tab 操作表单,Escape 关闭并恢复焦点;命令菜单请使用 Menu。自定义触发器需转发 ref 与 DOM props,浮层继承 MtoneProvider 上下文。
|
|
1897
2036
|
|
|
1898
2037
|
```tsx
|
|
1899
|
-
import { Popover
|
|
2038
|
+
import { Popover } from "@bixlab/mtone";
|
|
1900
2039
|
import "@bixlab/mtone/styles.css";
|
|
1901
2040
|
|
|
1902
2041
|
export default function Demo() {
|
|
1903
2042
|
return (
|
|
1904
|
-
<Popover trigger=
|
|
2043
|
+
<Popover trigger="查看说明" title="提示" content="这里放置相关内容。" />
|
|
1905
2044
|
);
|
|
1906
2045
|
}
|
|
1907
2046
|
```
|
|
@@ -1929,15 +2068,54 @@ export default function Demo() {
|
|
|
1929
2068
|
}
|
|
1930
2069
|
```
|
|
1931
2070
|
|
|
2071
|
+
### CardGroup
|
|
2072
|
+
|
|
2073
|
+
- [CardGroup](https://xingjianxu.github.io/mtone/#/components/CardGroup): 排列多个独立卡片,支持响应式列数与间距、跨列、纵向排列和行列分隔线。
|
|
2074
|
+
- Import: CardGroup, Card from @bixlab/mtone
|
|
2075
|
+
- direction: "horizontal" | "vertical" (default: horizontal). horizontal 使用多列网格;vertical 固定单列并忽略 columns。
|
|
2076
|
+
- columns: number | Partial<Record<"xs" | "sm" | "md" | "lg" | "xl" | "xxl", number>> (default: { xs: 1, sm: 2, lg: 3 }). 网格列数。数字应用于全部断点;对象按视口断点逐级继承,未定义的初始值为 1。有效值取整并限制为 1–24。
|
|
2077
|
+
- gap: CardGroupResponsive (default: 12). 行列间距(px),支持数字或相同断点对象。有效值必须有限且非负,未定义的初始值为 12。
|
|
2078
|
+
- divided: boolean (default: false). 在相邻行列的间距中显示分隔线,跟随当前列数与跨列布局调整。
|
|
2079
|
+
- CardGroup.Item.span: CardGroupResponsive (default: 1). 占用列数,可响应式配置;自动限制为当前总列数,不会撑出网格。
|
|
2080
|
+
- children / className / style / 原生属性: ReactNode / string / CSSProperties / HTMLAttributes<HTMLDivElement>. 根节点与 Item 支持原生 div 属性。普通子元素自动包裹为 Item;显式 Item 可设置 span 或 hidden。
|
|
2081
|
+
- CardGroup 是多个独立 Card 的外层布局;Card.Grid 是一张 Card 内的内容网格,二者不能混作同一个组件。CardGroup.Item 为静态子组件,不是独立命名导出。
|
|
2082
|
+
- 断点按浏览器视口计算:xs 从 0 开始,sm 576px、md 768px、lg 992px、xl 1200px、xxl 1600px;不是容器查询。缩小示例容器不会改变断点。
|
|
2083
|
+
- 默认手机单列;如需手机多列,可显式设置 columns={{ xs: 2, md: 3 }}。内容需适应有限列宽,过长的自定义内容仍须自行约束。
|
|
2084
|
+
- direction="vertical" 时 Item.span 同样限制为 1;divided 仅显示行间分隔。根 gap=0 时分隔线位于相邻项边缘。
|
|
2085
|
+
- 支持 Fragment 展开;隐藏项使用 CardGroup.Item hidden,不应仅用 CSS display:none 隐藏布局项,否则分隔线的行列推算不会同步。示例只演示本地布局,不读写服务器数据。
|
|
2086
|
+
|
|
2087
|
+
```tsx
|
|
2088
|
+
import { Card, CardGroup } from "@bixlab/mtone";
|
|
2089
|
+
import "@bixlab/mtone/styles.css";
|
|
2090
|
+
|
|
2091
|
+
export default function Demo() {
|
|
2092
|
+
return (
|
|
2093
|
+
<CardGroup columns={{ xs: 2, md: 3 }} gap={{ xs: 12, md: 20 }} divided>
|
|
2094
|
+
<CardGroup.Item span={{ xs: 2, md: 3 }}>
|
|
2095
|
+
<Card title="概览">跨满当前整行</Card>
|
|
2096
|
+
</CardGroup.Item>
|
|
2097
|
+
<Card title="资料">待整理 12 项</Card>
|
|
2098
|
+
<Card title="笔记">已阅读 20 项</Card>
|
|
2099
|
+
<Card title="收藏">常用资源</Card>
|
|
2100
|
+
</CardGroup>
|
|
2101
|
+
);
|
|
2102
|
+
}
|
|
2103
|
+
```
|
|
2104
|
+
|
|
1932
2105
|
### Card
|
|
1933
2106
|
|
|
1934
2107
|
- [Card](https://xingjianxu.github.io/mtone/#/components/Card): 紧凑的结构化内容卡片,支持封面、操作、加载、标签页、元信息与网格。
|
|
1935
2108
|
- Import: Card, Button, Avatar from @bixlab/mtone
|
|
2109
|
+
- collapsible: boolean (default: false). 在标题左侧显示收起/展开按钮。默认不折叠。
|
|
2110
|
+
- collapsed: boolean. 受控折叠状态;搭配 onCollapsedChange 更新。
|
|
2111
|
+
- defaultCollapsed: boolean (default: false). 非受控初始折叠状态,仅 collapsible 启用时生效。
|
|
2112
|
+
- onCollapsedChange: (collapsed: boolean) => void. 用户点击折叠按钮时请求切换状态;受控模式由父组件接受更新。
|
|
2113
|
+
- collapseLabel: string. 折叠按钮可访问名称;默认按状态与 locale 显示收起卡片/展开卡片(英文对应 Collapse card/Expand card)。
|
|
1936
2114
|
- children: ReactNode. 卡片主体;tabList 项未指定 content 时也用作该标签页主体。
|
|
1937
2115
|
- title / extra: ReactNode. 可见标题与标题栏尾部区域;无内容时不生成空标题栏。
|
|
1938
2116
|
- htmlTitle: string. 原生 HTML title 悬浮提示。旧 Card title 原生提示用法需迁移到此属性。
|
|
1939
2117
|
- cover: ReactNode. 独立封面区域,可放图片或其他内容;图片请提供合适的 alt。
|
|
1940
|
-
- actions: ReactNode[]. 底部操作区域;请使用 Button
|
|
2118
|
+
- actions: ReactNode[]. 底部操作区域;请使用 Button 或链接等有语义的交互元素。
|
|
1941
2119
|
- loading / loadingLabel: boolean / string. loading 默认 false,使用 Skeleton 显示加载态;loadingLabel 提供可访问的加载提示。
|
|
1942
2120
|
- size: "medium" | "small". 默认 medium;紧凑风格提供较小 padding 的 small 变体。
|
|
1943
2121
|
- variant: "outlined" | "borderless". 默认 outlined;borderless 隐藏可见边框并保留外框几何。
|
|
@@ -1953,6 +2131,8 @@ export default function Demo() {
|
|
|
1953
2131
|
- Card.Meta: avatar?: ReactNode; title?: ReactNode; description?: ReactNode; htmlTitle?: string. 元信息布局;支持原生 div 属性,以及 root、section、avatar、title、description 分区 classNames/styles(对象或 ({props}) => 对象)。
|
|
1954
2132
|
- Card.Grid: hoverable?: boolean + HTMLAttributes<HTMLDivElement>. 卡片网格项,hoverable 默认 true;作为 Card 的直接子元素使用以启用响应式网格布局。
|
|
1955
2133
|
- 原生属性: Omit<HTMLAttributes<HTMLDivElement>, "title">. 支持根节点 className、style、aria-* 与适用 DOM 事件。title 已改为可见标题;原生提示使用 htmlTitle。
|
|
2134
|
+
- 折叠后标题及 extra 操作保持可见,封面、标签、正文与底部 actions 隐藏但不卸载;子组件状态保留。未设置 collapsible 时 collapsed/defaultCollapsed 不会隐藏内容。
|
|
2135
|
+
- Card.Grid 是单张 Card 内部的网格项;多个独立 Card 的布局、响应式列数、跨列和分隔线请使用 CardGroup。
|
|
1956
2136
|
- 未提供 bordered/bodyStyle/headStyle;使用 variant 与分区 styles。size 使用 medium/small,tabProps 只支持现有 mtone Tabs 的 className。
|
|
1957
2137
|
- 迁移提醒:旧 <Card title="提示"> 会改为显示标题栏;原生悬浮提示请改为 <Card htmlTitle="提示">。只有 children、没有新增结构属性的 Card 维持原来的默认视觉。
|
|
1958
2138
|
- Card.Meta 与 Card.Grid 是 Card 的静态子组件,不是单独安装或单独命名导出的组件。
|
|
@@ -1986,8 +2166,11 @@ export default function Demo() {
|
|
|
1986
2166
|
|
|
1987
2167
|
### Typography
|
|
1988
2168
|
|
|
1989
|
-
- [Typography](https://xingjianxu.github.io/mtone/#/components/Typography):
|
|
2169
|
+
- [Typography](https://xingjianxu.github.io/mtone/#/components/Typography): 统一的标题、正文、段落、链接、引用与代码,按子组件独立演示,支持复制、纯文本编辑及省略展开。
|
|
1990
2170
|
- Import: Typography from @bixlab/mtone
|
|
2171
|
+
- Title.divider: boolean (default: level === 2). 标题下方的整行分隔线,仅二级标题默认启用;不同于给文字添加下划线的 underline。
|
|
2172
|
+
- Code.language: string. 可选语法高亮语言。仅代码块的字符串内容启用;支持 js、ts、jsx、tsx、json、html、css、bash。默认、行内、其他语言及加载失败均保持纯文本或原有子内容。
|
|
2173
|
+
- Code.block: boolean (default: false). Typography.Code 默认渲染行内 <code>;block 渲染 <pre><code> 并保留缩进和换行。长行在块内滚动,溢出时可用 Tab 聚焦并按左右方向键滚动。
|
|
1991
2174
|
- Blockquote: BlockquoteProps. 引用子组件;支持 cite 可见署名、citeUrl 来源 URL、icon、iconSize(默认 28)、color(CSS 色值)、radius(默认 4)、textWrap(默认 wrap)。它不支持 Text 的复制、编辑或省略属性;完整 API 见 Blockquote 条目。
|
|
1992
2175
|
- muted / type: boolean / "secondary" | "success" | "warning" | "danger". muted 保留旧版次级文字颜色;type 提供语义字色。
|
|
1993
2176
|
- strong / italic / underline / delete / mark / code / keyboard: boolean (default: false). 分别使用 strong/em/u/del/mark/code/kbd 语义标签,可组合使用。
|
|
@@ -1997,6 +2180,7 @@ export default function Demo() {
|
|
|
1997
2180
|
- ellipsis: boolean | TypographyEllipsis (default: false). CSS 单行或多行省略。对象支持 rows?: number(默认 1)、expandable?: boolean、expanded?: boolean、defaultExpanded?: boolean、onExpandedChange(expanded): void、expandLabel?: string、collapseLabel?: string。
|
|
1998
2181
|
- children / ref / 原生属性: ReactNode / 对应 HTML 元素 ref / HTMLAttributes. 支持 className、style、title 与适用的 DOM 属性;Text 为 span,Title 为 heading,Paragraph 为 p。
|
|
1999
2182
|
- 保持已有 Text 与 muted 用法兼容。文字、标题和段落可单独导入,也可使用 Typography.Text / Typography.Title / Typography.Paragraph / Typography.Link / Typography.Blockquote;Typography 是命名空间对象,不能直接作为 JSX 元素。
|
|
2183
|
+
- Typography.Code 只从 Typography 命名空间使用,支持原生属性和 ref(指向外层 code 或 pre);可用 tabIndex 覆盖默认 Tab 顺序。使用 block language="tsx" 等可按需启用 Shiki。服务端和首次显示保留原文,浏览器按需着色并随最近主题切换,文本、缩进和换行不变。不内置复制按钮;Typography.Text 的 code 用法保持不变。
|
|
2000
2184
|
- 编辑采用纯文本 textarea;Enter 保存、Shift + Enter 换行、Escape 取消、blur 保存,中文输入法组合输入期间不提交。受控 editing 必须配合 onEditingChange 更新;onChange 可用于业务保存。富内容请显式提供 editable.text,编辑结果不保留富文本标记。
|
|
2001
2185
|
- 复制使用 Clipboard API,需要安全上下文及浏览器权限;失败有屏幕阅读器提示并调用 onError,不会伪报成功。富组件无法可靠提取文本时请提供 copyable.text。内置操作名称跟随 MtoneProvider 的 zh/en,可自定义 label。
|
|
2002
2186
|
- 省略采用 CSS 裁切,不测量是否真的溢出;expandable 的展开/收起按钮始终存在。单行省略需要约束容器宽度;操作按钮位于裁切内容之外,窄容器可能换行。rows 取正整数,非法值回退 1。
|
|
@@ -2070,9 +2254,10 @@ export default function Demo() {
|
|
|
2070
2254
|
|
|
2071
2255
|
### Title
|
|
2072
2256
|
|
|
2073
|
-
- [Title](https://xingjianxu.github.io/mtone/#/components/Title): 遵循 mtone 字号与间距的语义标题,支持 h1 至 h6
|
|
2257
|
+
- [Title](https://xingjianxu.github.io/mtone/#/components/Title): 遵循 mtone 字号与间距的语义标题,支持 h1 至 h6 与可选整行分隔线。
|
|
2074
2258
|
- Import: Title from @bixlab/mtone
|
|
2075
2259
|
- level: 1 | 2 | 3 | 4 | 5 | 6 (default: 1). 使用对应 h1-h6 标签。按文档结构选择标题层级。
|
|
2260
|
+
- divider: boolean (default: level === 2). 在标题下方绘制横贯标题整行的 1px 中性色分隔线。仅二级标题默认启用;可显式开启或关闭。与文字下划线 underline 独立。
|
|
2076
2261
|
- muted / type: boolean / "secondary" | "success" | "warning" | "danger". muted 保留旧版次级文字颜色;type 提供语义字色。
|
|
2077
2262
|
- strong / italic / underline / delete / mark / code / keyboard: boolean (default: false). 分别使用 strong/em/u/del/mark/code/kbd 语义标签,可组合使用。
|
|
2078
2263
|
- disabled: boolean (default: false). 弱化文字并停用内置复制、编辑、展开按钮;不自动禁用 children 中的交互元素。
|
|
@@ -2091,7 +2276,11 @@ import { Title } from "@bixlab/mtone";
|
|
|
2091
2276
|
import "@bixlab/mtone/styles.css";
|
|
2092
2277
|
|
|
2093
2278
|
export default function Demo() {
|
|
2094
|
-
return
|
|
2279
|
+
return <>
|
|
2280
|
+
<Title level={2}>项目概览</Title>
|
|
2281
|
+
<Title level={2} divider={false}>不带分隔线</Title>
|
|
2282
|
+
<Title level={3} divider>带分隔线的三级标题</Title>
|
|
2283
|
+
</>;
|
|
2095
2284
|
}
|
|
2096
2285
|
```
|
|
2097
2286
|
|
|
@@ -2198,6 +2387,51 @@ export default function Demo() {
|
|
|
2198
2387
|
}
|
|
2199
2388
|
```
|
|
2200
2389
|
|
|
2390
|
+
### DataList
|
|
2391
|
+
|
|
2392
|
+
- [DataList](https://xingjianxu.github.io/mtone/#/components/DataList): 用于管理记录的列表,支持搜索筛选、分页、跨页选择、批量操作和行详情。
|
|
2393
|
+
- Import: DataList from @bixlab/mtone
|
|
2394
|
+
- items / getKey: readonly T[] / (item: T) => string | number. 必填。提供数据与稳定唯一的条目键(字符串或有限数值);远程模式只传当前页记录。
|
|
2395
|
+
- getLabel: (item: T) => string. 为条目选择和展开按钮提供可读名称;省略时使用键的字符串。
|
|
2396
|
+
- renderItem: (item: T, index: number) => ReactNode. 必填。仅返回行内容;index 是从 0 开始的当前页索引,不要返回 li 或 ListItem。
|
|
2397
|
+
- search: { value?, defaultValue?, onChange?, placeholder?, label?, match? }. 传入后显示搜索框。match(item, query) 用于本地搜索,query 已去掉首尾空白;未传 match 时不自动筛选。
|
|
2398
|
+
- filter / filters / toolbar: ((item: T) => boolean) / ReactNode / ReactNode. 本地筛选条件、筛选控件与工具栏内容。远程模式只呈现应用提供的结果,不执行本地条件。
|
|
2399
|
+
- pagination: DataListPagination. 省略时不分页。本地配置为 { mode?: 'local', page?, defaultPage?, pageSize?, onPageChange? },默认第 1 页、每页 10 条;远程配置为 { mode: 'remote', page, pageSize, total, onPageChange }。
|
|
2400
|
+
- selection: { selectedKeys?, defaultSelectedKeys?, onChange?, getDisabled? }. 启用选择。使用稳定键保留跨页选择;全选或取消全选只影响当前页的可选条目。
|
|
2401
|
+
- expansion: { expandedKeys?, defaultExpandedKeys?, onChange?, isExpandable?, renderDetail }. 启用行详情;renderDetail(item) 返回详情内容。展开不会改变选中状态。
|
|
2402
|
+
- renderActions: (item: T) => ReactNode. 行尾操作;业务行为由应用处理,不会触发隐式选中。
|
|
2403
|
+
- renderBatchActions: ({ selectedKeys, clearSelection }) => ReactNode. 已选时渲染批量操作;clearSelection() 清除全部选中键,包括其他页。
|
|
2404
|
+
- loading / empty: boolean / ReactNode. 加载状态与空内容;请求、错误和记录更新由应用处理。
|
|
2405
|
+
- 原生属性: HTMLAttributes<HTMLElement>. 转发 section 根元素属性,例如 aria-label、className、style;行由 renderItem 提供。
|
|
2406
|
+
- DataList 用于行内容由应用渲染的数据管理页。仅需基础列表、分组吸顶或虚拟滚动时,使用 List。
|
|
2407
|
+
- 本地搜索与筛选先于分页。输入搜索词会请求回到第 1 页;本地结果缩小时限制页码范围。
|
|
2408
|
+
- 远程模式不会过滤或再次切分 items。应用提供当前页记录、总数、加载及错误状态,管理请求取消;外部筛选变化时由应用重置页码。
|
|
2409
|
+
- 目前不提供卡片网格、内联编辑或虚拟滚动。过滤和翻页后若需批量修改,应按键操作,不以当前页的条目数组为准。
|
|
2410
|
+
|
|
2411
|
+
```tsx
|
|
2412
|
+
import { DataList, Text } from "@bixlab/mtone";
|
|
2413
|
+
import "@bixlab/mtone/styles.css";
|
|
2414
|
+
|
|
2415
|
+
const records = [
|
|
2416
|
+
{ id: "guide", title: "知识库使用指南" },
|
|
2417
|
+
{ id: "notes", title: "研究笔记" },
|
|
2418
|
+
];
|
|
2419
|
+
|
|
2420
|
+
export default function Demo() {
|
|
2421
|
+
return (
|
|
2422
|
+
<DataList
|
|
2423
|
+
aria-label="文档列表"
|
|
2424
|
+
items={records}
|
|
2425
|
+
getKey={(item) => item.id}
|
|
2426
|
+
getLabel={(item) => item.title}
|
|
2427
|
+
renderItem={(item) => <Text>{item.title}</Text>}
|
|
2428
|
+
search={{ match: (item, query) => item.title.includes(query) }}
|
|
2429
|
+
pagination={{ pageSize: 10 }}
|
|
2430
|
+
/>
|
|
2431
|
+
);
|
|
2432
|
+
}
|
|
2433
|
+
```
|
|
2434
|
+
|
|
2201
2435
|
### ListItem
|
|
2202
2436
|
|
|
2203
2437
|
- [ListItem](https://xingjianxu.github.io/mtone/#/components/ListItem): 包含图标、说明与尾部操作的列表项。
|
|
@@ -2590,6 +2824,33 @@ export default function Demo() {
|
|
|
2590
2824
|
}
|
|
2591
2825
|
```
|
|
2592
2826
|
|
|
2827
|
+
### GlobalNotice
|
|
2828
|
+
|
|
2829
|
+
- [GlobalNotice](https://xingjianxu.github.io/mtone/#/components/GlobalNotice): 持续可见的全局警示通知,可独立使用或通过 AdminLayout 的 notice 插槽跨页面展示。
|
|
2830
|
+
- Import: GlobalNotice from @bixlab/mtone
|
|
2831
|
+
- title: ReactNode. 必填;简短通知标题。
|
|
2832
|
+
- children: ReactNode. 可选详情;窄屏可自然换行。
|
|
2833
|
+
- icon: ReactNode | false. 默认显示装饰性警示图标。设为 false 隐藏图标。
|
|
2834
|
+
- onAction: () => void. 提供时渲染操作按钮;操作请求、关闭与持久状态由应用负责。
|
|
2835
|
+
- actionLabel: string. 可选可见操作文字;没有文字时显示本地化无障碍名称的关闭按钮。
|
|
2836
|
+
- actionRef: Ref<HTMLButtonElement>. 操作按钮引用,便于错误后返回重试按钮。
|
|
2837
|
+
- loading: boolean (default: false). 显示加载图标并禁用按钮。异步处理建议应用另外设置立即生效的请求锁。
|
|
2838
|
+
- error: ReactNode. 可选操作失败反馈,以警报语义公布;应用决定何时清除。
|
|
2839
|
+
- 原生 div 属性和 ref: HTMLAttributes<HTMLDivElement>. 支持 className、style 与 DOM 属性,title 使用通知标题。
|
|
2840
|
+
- 通知不会自动关闭,不执行权限、导航或网络操作。成功后由应用移除通知,并把焦点恢复到仍存在的控件。
|
|
2841
|
+
- 用于持续全局状态;局部反馈使用 Alert。警示颜色沿用语义警告样式,不是装饰性颜色预设。
|
|
2842
|
+
|
|
2843
|
+
```tsx
|
|
2844
|
+
import { GlobalNotice } from "@bixlab/mtone";
|
|
2845
|
+
import "@bixlab/mtone/styles.css";
|
|
2846
|
+
|
|
2847
|
+
export default function Demo() {
|
|
2848
|
+
return <GlobalNotice title="管理员模式" actionLabel="退出管理模式" onAction={() => {/* 由应用处理 */}}>
|
|
2849
|
+
完成管理操作后请退出。
|
|
2850
|
+
</GlobalNotice>;
|
|
2851
|
+
}
|
|
2852
|
+
```
|
|
2853
|
+
|
|
2593
2854
|
### Empty
|
|
2594
2855
|
|
|
2595
2856
|
- [Empty](https://xingjianxu.github.io/mtone/#/components/Empty): 为空数据提供说明与下一步入口。
|
|
@@ -2802,11 +3063,10 @@ export default function Demo() {
|
|
|
2802
3063
|
|
|
2803
3064
|
### MtoneProvider
|
|
2804
3065
|
|
|
2805
|
-
- [MtoneProvider](https://xingjianxu.github.io/mtone/#/components/MtoneProvider):
|
|
3066
|
+
- [MtoneProvider](https://xingjianxu.github.io/mtone/#/components/MtoneProvider): 为组件及其浮层配置颜色模式、语言和主题变量。
|
|
2806
3067
|
- Import: MtoneProvider, Button from @bixlab/mtone
|
|
2807
3068
|
- children: ReactNode. 组件内容。
|
|
2808
3069
|
- locale: "zh" | "en" (default: zh). 内置控件文案语言。
|
|
2809
|
-
- density: "compact" | "comfortable" (default: compact). 控件密度。
|
|
2810
3070
|
- theme: MtoneTheme ("light" | "dark" | "system") (default: 最外层为 light). 浅色、深色或实时跟随设备设置;省略时继承上层主题。
|
|
2811
3071
|
- tokens: Tokens. CSS 自定义属性与 CSSProperties,常用 --mt-fg、--mt-bg、--mt-primary。
|
|
2812
3072
|
- 简单组件不使用 Provider 时也可用默认值,保持浅色。
|
|
@@ -2819,19 +3079,19 @@ import "@bixlab/mtone/styles.css";
|
|
|
2819
3079
|
|
|
2820
3080
|
export default function Demo() {
|
|
2821
3081
|
return (
|
|
2822
|
-
<MtoneProvider locale="zh"
|
|
3082
|
+
<MtoneProvider locale="zh" theme="system" tokens={{"--mt-primary":"#446c52"}}><Button variant="solid">保存</Button></MtoneProvider>
|
|
2823
3083
|
);
|
|
2824
3084
|
}
|
|
2825
3085
|
```
|
|
2826
3086
|
|
|
2827
3087
|
### MtoneScope
|
|
2828
3088
|
|
|
2829
|
-
- [MtoneScope](https://xingjianxu.github.io/mtone/#/components/MtoneScope): 把当前 Provider
|
|
3089
|
+
- [MtoneScope](https://xingjianxu.github.io/mtone/#/components/MtoneScope): 把当前 Provider 的主题变量应用到一个 div,可局部覆盖颜色模式。
|
|
2830
3090
|
- Import: MtoneScope, MtoneProvider, Button from @bixlab/mtone
|
|
2831
3091
|
- children: ReactNode. 组件内容。
|
|
2832
3092
|
- theme: MtoneTheme ("light" | "dark" | "system") (default: 继承上层主题). 仅覆盖此作用域及其浮层的颜色模式。
|
|
2833
3093
|
- 原生属性: HTMLAttributes. 支持对应元素的 className、style 与适用的 DOM 属性;以 TypeScript 定义为准。
|
|
2834
|
-
- 通常无需手动使用;库内部用它让 Portal
|
|
3094
|
+
- 通常无需手动使用;库内部用它让 Portal 浮层继承主题。可覆盖颜色模式,仍继承语言和主题变量。
|
|
2835
3095
|
|
|
2836
3096
|
```tsx
|
|
2837
3097
|
import { MtoneScope, MtoneProvider, Button } from "@bixlab/mtone";
|
|
@@ -2843,3 +3103,617 @@ export default function Demo() {
|
|
|
2843
3103
|
);
|
|
2844
3104
|
}
|
|
2845
3105
|
```
|
|
3106
|
+
|
|
3107
|
+
### AiChat
|
|
3108
|
+
|
|
3109
|
+
- [AiChat](https://xingjianxu.github.io/mtone/#/components/AiChat): 容纳滚动消息和固定输入区域,可跟随最新消息。
|
|
3110
|
+
- Import: AiChat from @bixlab/mtone
|
|
3111
|
+
- children / empty / footer: ReactNode. 消息、空状态和底部区域。
|
|
3112
|
+
- autoFollow: boolean (default: true). 在阅读位置靠近底部时自动跟随消息;向上浏览时不强制跳回。
|
|
3113
|
+
- bottomThreshold: number (default: 64). 判断靠近底部的距离,单位 px。
|
|
3114
|
+
- scrollToBottomLabel: string. 覆盖回到底部按钮的名称。
|
|
3115
|
+
- className / style / aria-label: HTMLAttributes<HTMLDivElement>. 设置对话高度、样式和可访问名称等。
|
|
3116
|
+
- 给容器设置合适的可用高度,才能在消息区内部滚动。应用负责消息和流式请求;组件不连接模型。
|
|
3117
|
+
|
|
3118
|
+
```tsx
|
|
3119
|
+
import { AiChat, AiMessage } from "@bixlab/mtone";
|
|
3120
|
+
import "@bixlab/mtone/styles.css";
|
|
3121
|
+
|
|
3122
|
+
export default function Demo() {
|
|
3123
|
+
return (
|
|
3124
|
+
<AiChat style={{ height: 180, width: "100%" }} aria-label="项目讨论">
|
|
3125
|
+
<AiMessage from="user">下一步做什么?</AiMessage>
|
|
3126
|
+
<AiMessage from="assistant">先把待确认事项列出来。</AiMessage>
|
|
3127
|
+
</AiChat>
|
|
3128
|
+
);
|
|
3129
|
+
}
|
|
3130
|
+
```
|
|
3131
|
+
|
|
3132
|
+
### AiMessage
|
|
3133
|
+
|
|
3134
|
+
- [AiMessage](https://xingjianxu.github.io/mtone/#/components/AiMessage): 展示用户、助手或系统消息及生成状态、附件内容和可选操作。
|
|
3135
|
+
- Import: AiMessage from @bixlab/mtone
|
|
3136
|
+
- from: "user" | "assistant" | "system". 必填;决定消息角色及默认显示名称。
|
|
3137
|
+
- name / avatar / children / actions: ReactNode. 自定义名称、头像、消息内容和操作。
|
|
3138
|
+
- status / statusLabel: "idle" | "streaming" | "error" / string (default: idle). 消息状态与可覆盖的状态文字。
|
|
3139
|
+
- 应用提供内容及其渲染策略;不会将字符串自动解析为 Markdown 或执行 HTML。
|
|
3140
|
+
|
|
3141
|
+
```tsx
|
|
3142
|
+
import { AiMessage, Button } from "@bixlab/mtone";
|
|
3143
|
+
import "@bixlab/mtone/styles.css";
|
|
3144
|
+
|
|
3145
|
+
export default function Demo() {
|
|
3146
|
+
return (
|
|
3147
|
+
<AiMessage
|
|
3148
|
+
from="assistant"
|
|
3149
|
+
status="streaming"
|
|
3150
|
+
actions={<Button size="sm">复制(示例)</Button>}
|
|
3151
|
+
>
|
|
3152
|
+
正在整理记录。
|
|
3153
|
+
</AiMessage>
|
|
3154
|
+
);
|
|
3155
|
+
}
|
|
3156
|
+
```
|
|
3157
|
+
|
|
3158
|
+
### AiPromptInput
|
|
3159
|
+
|
|
3160
|
+
- [AiPromptInput](https://xingjianxu.github.io/mtone/#/components/AiPromptInput): 提供消息输入、提交、停止、附件选择和错误展示。
|
|
3161
|
+
- Import: AiPromptInput from @bixlab/mtone
|
|
3162
|
+
- value / defaultValue / onValueChange: string / string / (value: string) => void. 受控文本、初始文本及变化回调。
|
|
3163
|
+
- onSubmit: (submission: AiPromptSubmission) => void | Promise<void>. 必填;收到 text 和附件元数据。提交后的清空需要应用自行处理。
|
|
3164
|
+
- status / onStop: AiPromptStatus / () => void (default: ready). 状态为 ready、submitted、streaming、error;忙碌时可发出停止请求。
|
|
3165
|
+
- attachments / onFilesSelect / onAttachmentRemove: readonly AiPromptAttachment[] / (files: File[]) => void / (id: string) => void. 附件由应用持有;选择文件和移除操作只回调。
|
|
3166
|
+
- accept / multiple / disabled: string / boolean / boolean (default: — / true / false). 文件类型、允许多选及禁用状态。
|
|
3167
|
+
- toolbar / error / placeholder: ReactNode / ReactNode / string. 输入区的工具栏、错误提示和占位文本。
|
|
3168
|
+
- submitLabel / stopLabel / attachmentLabel: string. 自定义各按钮可访问名称。
|
|
3169
|
+
- Enter 发送,Shift+Enter 换行;输入法组合期间不会误发送。文件只交给应用,不自动上传。
|
|
3170
|
+
|
|
3171
|
+
```tsx
|
|
3172
|
+
import { useState } from "react";
|
|
3173
|
+
import { AiPromptInput } from "@bixlab/mtone";
|
|
3174
|
+
import "@bixlab/mtone/styles.css";
|
|
3175
|
+
|
|
3176
|
+
export default function Demo() {
|
|
3177
|
+
const [text, setText] = useState("");
|
|
3178
|
+
const [sent, setSent] = useState("");
|
|
3179
|
+
return (
|
|
3180
|
+
<div style={{ width: "100%" }}>
|
|
3181
|
+
<AiPromptInput
|
|
3182
|
+
aria-label="演示消息"
|
|
3183
|
+
value={text}
|
|
3184
|
+
onValueChange={setText}
|
|
3185
|
+
onSubmit={(submission) => {
|
|
3186
|
+
setSent(submission.text);
|
|
3187
|
+
setText("");
|
|
3188
|
+
}}
|
|
3189
|
+
/>
|
|
3190
|
+
<p role="status">{sent}</p>
|
|
3191
|
+
</div>
|
|
3192
|
+
);
|
|
3193
|
+
}
|
|
3194
|
+
```
|
|
3195
|
+
|
|
3196
|
+
### AiSuggestion
|
|
3197
|
+
|
|
3198
|
+
- [AiSuggestion](https://xingjianxu.github.io/mtone/#/components/AiSuggestion): 点击后把建议提示词交给应用,用于填入输入框或其他交互。
|
|
3199
|
+
- Import: AiSuggestion from @bixlab/mtone
|
|
3200
|
+
- prompt / onSelect: string / (prompt: string) => void. 提示词及选中回调。
|
|
3201
|
+
- children / ButtonProps: ReactNode / ButtonProps. 可替换显示内容,其余按钮属性照常使用。
|
|
3202
|
+
- 不会自动调用模型。应用可在 onClick 阻止默认行为以取消 onSelect。
|
|
3203
|
+
|
|
3204
|
+
```tsx
|
|
3205
|
+
import { useState } from "react";
|
|
3206
|
+
import { AiSuggestion } from "@bixlab/mtone";
|
|
3207
|
+
import "@bixlab/mtone/styles.css";
|
|
3208
|
+
|
|
3209
|
+
export default function Demo() {
|
|
3210
|
+
const [text, setText] = useState("");
|
|
3211
|
+
return (
|
|
3212
|
+
<div>
|
|
3213
|
+
<AiSuggestion prompt="整理项目要点" onSelect={setText}>
|
|
3214
|
+
建议:整理项目
|
|
3215
|
+
</AiSuggestion>
|
|
3216
|
+
<p role="status">{text}</p>
|
|
3217
|
+
</div>
|
|
3218
|
+
);
|
|
3219
|
+
}
|
|
3220
|
+
```
|
|
3221
|
+
|
|
3222
|
+
### AiModelSelector
|
|
3223
|
+
|
|
3224
|
+
- [AiModelSelector](https://xingjianxu.github.io/mtone/#/components/AiModelSelector): 用受控选择器展示应用提供的模型和可选推理强度。
|
|
3225
|
+
- Import: AiModelSelector from @bixlab/mtone
|
|
3226
|
+
- models / value / onValueChange: AiModelOption[] / string / (value: string) => void. 必填;由应用维护模型选项及选择。
|
|
3227
|
+
- efforts / effort / onEffortChange: AiModelOption[] / string / (value: string) => void. 可选推理强度;没有变化回调时该选择不可编辑。
|
|
3228
|
+
- disabled / modelLabel / effortLabel: boolean / string / string. 禁用选择器,或覆盖模型及推理强度的可访问名称。
|
|
3229
|
+
- 显示的选项由应用定义,不代表实际可用模型或服务权限。
|
|
3230
|
+
|
|
3231
|
+
```tsx
|
|
3232
|
+
import { useState } from "react";
|
|
3233
|
+
import { AiModelSelector } from "@bixlab/mtone";
|
|
3234
|
+
import "@bixlab/mtone/styles.css";
|
|
3235
|
+
|
|
3236
|
+
export default function Demo() {
|
|
3237
|
+
const [model, setModel] = useState("fast");
|
|
3238
|
+
const [effort, setEffort] = useState("normal");
|
|
3239
|
+
return (
|
|
3240
|
+
<AiModelSelector
|
|
3241
|
+
models={[
|
|
3242
|
+
{ value: "fast", label: "快速(模拟)" },
|
|
3243
|
+
{ value: "review", label: "审阅(模拟)" },
|
|
3244
|
+
]}
|
|
3245
|
+
value={model}
|
|
3246
|
+
onValueChange={setModel}
|
|
3247
|
+
efforts={[
|
|
3248
|
+
{ value: "normal", label: "常规" },
|
|
3249
|
+
{ value: "deep", label: "深入" },
|
|
3250
|
+
]}
|
|
3251
|
+
effort={effort}
|
|
3252
|
+
onEffortChange={setEffort}
|
|
3253
|
+
/>
|
|
3254
|
+
);
|
|
3255
|
+
}
|
|
3256
|
+
```
|
|
3257
|
+
|
|
3258
|
+
### AiPlan
|
|
3259
|
+
|
|
3260
|
+
- [AiPlan](https://xingjianxu.github.io/mtone/#/components/AiPlan): 用步骤列表和完成进度展示应用提供的任务计划。
|
|
3261
|
+
- Import: AiPlan from @bixlab/mtone
|
|
3262
|
+
- items: AiActivityStep[]. 必填;计划步骤及状态。
|
|
3263
|
+
- title / statusLabel: string. 可覆盖折叠标题和状态文字。
|
|
3264
|
+
- status: AiActivityStatus (default: pending). 状态为 pending、running、completed、error、cancelled。
|
|
3265
|
+
- open / defaultOpen / onOpenChange: boolean / boolean / (open: boolean) => void. 控制展开状态、指定初始展开状态或监听展开变化。
|
|
3266
|
+
- children / 原生属性: ReactNode / HTMLAttributes<HTMLDivElement>. 额外内容及根 div 属性。
|
|
3267
|
+
- 计划默认展开。进度只计入 completed 步骤;不调度或执行任务。
|
|
3268
|
+
|
|
3269
|
+
```tsx
|
|
3270
|
+
import { AiPlan } from "@bixlab/mtone";
|
|
3271
|
+
import "@bixlab/mtone/styles.css";
|
|
3272
|
+
|
|
3273
|
+
export default function Demo() {
|
|
3274
|
+
return (
|
|
3275
|
+
<AiPlan
|
|
3276
|
+
title="整理文档"
|
|
3277
|
+
status="running"
|
|
3278
|
+
items={[
|
|
3279
|
+
{ id: "read", title: "读取目录", status: "completed" },
|
|
3280
|
+
{ id: "write", title: "整理提纲", status: "running" },
|
|
3281
|
+
]}
|
|
3282
|
+
/>
|
|
3283
|
+
);
|
|
3284
|
+
}
|
|
3285
|
+
```
|
|
3286
|
+
|
|
3287
|
+
### AiChainOfThought
|
|
3288
|
+
|
|
3289
|
+
- [AiChainOfThought](https://xingjianxu.github.io/mtone/#/components/AiChainOfThought): 展示应用提供的公开摘要或可观察步骤。
|
|
3290
|
+
- Import: AiChainOfThought from @bixlab/mtone
|
|
3291
|
+
- steps: AiActivityStep[]. 公开摘要步骤;支持说明和状态。
|
|
3292
|
+
- title / statusLabel: string. 可覆盖折叠标题和状态文字。
|
|
3293
|
+
- status: AiActivityStatus (default: pending). 状态为 pending、running、completed、error、cancelled。
|
|
3294
|
+
- open / defaultOpen / onOpenChange: boolean / boolean / (open: boolean) => void. 控制展开状态、指定初始展开状态或监听展开变化。
|
|
3295
|
+
- children / 原生属性: ReactNode / HTMLAttributes<HTMLDivElement>. 额外内容及根 div 属性。
|
|
3296
|
+
- 不获取、生成或展示模型隐藏思维链。默认收起。
|
|
3297
|
+
|
|
3298
|
+
```tsx
|
|
3299
|
+
import { AiChainOfThought } from "@bixlab/mtone";
|
|
3300
|
+
import "@bixlab/mtone/styles.css";
|
|
3301
|
+
|
|
3302
|
+
export default function Demo() {
|
|
3303
|
+
return (
|
|
3304
|
+
<AiChainOfThought
|
|
3305
|
+
defaultOpen
|
|
3306
|
+
status="completed"
|
|
3307
|
+
steps={[
|
|
3308
|
+
{
|
|
3309
|
+
id: "find",
|
|
3310
|
+
title: "汇总两份资料",
|
|
3311
|
+
status: "completed",
|
|
3312
|
+
description: "已核对标题及日期。",
|
|
3313
|
+
},
|
|
3314
|
+
]}
|
|
3315
|
+
/>
|
|
3316
|
+
);
|
|
3317
|
+
}
|
|
3318
|
+
```
|
|
3319
|
+
|
|
3320
|
+
### AiReasoning
|
|
3321
|
+
|
|
3322
|
+
- [AiReasoning](https://xingjianxu.github.io/mtone/#/components/AiReasoning): 以可折叠区域展示应用提供的公开文字说明。
|
|
3323
|
+
- Import: AiReasoning from @bixlab/mtone
|
|
3324
|
+
- text: string. 必填;仅从调用方接收公开说明。
|
|
3325
|
+
- title / statusLabel: string. 可覆盖折叠标题和状态文字。
|
|
3326
|
+
- status: AiActivityStatus (default: pending). 状态为 pending、running、completed、error、cancelled。
|
|
3327
|
+
- open / defaultOpen / onOpenChange: boolean / boolean / (open: boolean) => void. 控制展开状态、指定初始展开状态或监听展开变化。
|
|
3328
|
+
- children / 原生属性: ReactNode / HTMLAttributes<HTMLDivElement>. 额外内容及根 div 属性。
|
|
3329
|
+
- 公开说明按文本呈现;不会获取模型隐含推理。默认收起。
|
|
3330
|
+
|
|
3331
|
+
```tsx
|
|
3332
|
+
import { AiReasoning } from "@bixlab/mtone";
|
|
3333
|
+
import "@bixlab/mtone/styles.css";
|
|
3334
|
+
|
|
3335
|
+
export default function Demo() {
|
|
3336
|
+
return (
|
|
3337
|
+
<AiReasoning
|
|
3338
|
+
defaultOpen
|
|
3339
|
+
status="completed"
|
|
3340
|
+
text="只比较发布时间和记录编号,结果仍需人工核对。"
|
|
3341
|
+
/>
|
|
3342
|
+
);
|
|
3343
|
+
}
|
|
3344
|
+
```
|
|
3345
|
+
|
|
3346
|
+
### AiTask
|
|
3347
|
+
|
|
3348
|
+
- [AiTask](https://xingjianxu.github.io/mtone/#/components/AiTask): 展示任务状态及可选步骤列表。
|
|
3349
|
+
- Import: AiTask from @bixlab/mtone
|
|
3350
|
+
- steps: AiActivityStep[]. 步骤名称、说明及状态。
|
|
3351
|
+
- title / statusLabel: string. 可覆盖折叠标题和状态文字。
|
|
3352
|
+
- status: AiActivityStatus (default: pending). 状态为 pending、running、completed、error、cancelled。
|
|
3353
|
+
- open / defaultOpen / onOpenChange: boolean / boolean / (open: boolean) => void. 控制展开状态、指定初始展开状态或监听展开变化。
|
|
3354
|
+
- children / 原生属性: ReactNode / HTMLAttributes<HTMLDivElement>. 额外内容及根 div 属性。
|
|
3355
|
+
- 默认收起;不会执行任务。
|
|
3356
|
+
|
|
3357
|
+
```tsx
|
|
3358
|
+
import { AiTask } from "@bixlab/mtone";
|
|
3359
|
+
import "@bixlab/mtone/styles.css";
|
|
3360
|
+
|
|
3361
|
+
export default function Demo() {
|
|
3362
|
+
return (
|
|
3363
|
+
<AiTask
|
|
3364
|
+
title="核对版本"
|
|
3365
|
+
defaultOpen
|
|
3366
|
+
status="running"
|
|
3367
|
+
steps={[
|
|
3368
|
+
{ id: "tag", title: "查看发布标签", status: "completed" },
|
|
3369
|
+
{ id: "file", title: "比对内容", status: "running" },
|
|
3370
|
+
]}
|
|
3371
|
+
/>
|
|
3372
|
+
);
|
|
3373
|
+
}
|
|
3374
|
+
```
|
|
3375
|
+
|
|
3376
|
+
### AiQueue
|
|
3377
|
+
|
|
3378
|
+
- [AiQueue](https://xingjianxu.github.io/mtone/#/components/AiQueue): 根据状态展示待完成事项与已结束事项。
|
|
3379
|
+
- Import: AiQueue from @bixlab/mtone
|
|
3380
|
+
- items: AiActivityStep[]. 必填;completed 和 cancelled 分入已结束,其余分入待完成。
|
|
3381
|
+
- title / statusLabel: string. 可覆盖折叠标题和状态文字。
|
|
3382
|
+
- status: AiActivityStatus (default: pending). 状态为 pending、running、completed、error、cancelled。
|
|
3383
|
+
- open / defaultOpen / onOpenChange: boolean / boolean / (open: boolean) => void. 控制展开状态、指定初始展开状态或监听展开变化。
|
|
3384
|
+
- children / 原生属性: ReactNode / HTMLAttributes<HTMLDivElement>. 额外内容及根 div 属性。
|
|
3385
|
+
- 默认展开;只呈现状态,不负责排队或重试。
|
|
3386
|
+
|
|
3387
|
+
```tsx
|
|
3388
|
+
import { AiQueue } from "@bixlab/mtone";
|
|
3389
|
+
import "@bixlab/mtone/styles.css";
|
|
3390
|
+
|
|
3391
|
+
export default function Demo() {
|
|
3392
|
+
return (
|
|
3393
|
+
<AiQueue
|
|
3394
|
+
items={[
|
|
3395
|
+
{ id: "first", title: "整理目录", status: "completed" },
|
|
3396
|
+
{ id: "second", title: "检查引用", status: "pending" },
|
|
3397
|
+
]}
|
|
3398
|
+
/>
|
|
3399
|
+
);
|
|
3400
|
+
}
|
|
3401
|
+
```
|
|
3402
|
+
|
|
3403
|
+
### AiSubagent
|
|
3404
|
+
|
|
3405
|
+
- [AiSubagent](https://xingjianxu.github.io/mtone/#/components/AiSubagent): 展示应用提供的代理名称、工作描述及结果。
|
|
3406
|
+
- Import: AiSubagent from @bixlab/mtone
|
|
3407
|
+
- name / description / result: string / ReactNode / ReactNode. name 必填,未传 title 时用作标题。
|
|
3408
|
+
- title / statusLabel: string. 可覆盖折叠标题和状态文字。
|
|
3409
|
+
- status: AiActivityStatus (default: pending). 状态为 pending、running、completed、error、cancelled。
|
|
3410
|
+
- open / defaultOpen / onOpenChange: boolean / boolean / (open: boolean) => void. 控制展开状态、指定初始展开状态或监听展开变化。
|
|
3411
|
+
- children / 原生属性: ReactNode / HTMLAttributes<HTMLDivElement>. 额外内容及根 div 属性。
|
|
3412
|
+
- 不创建、联系或控制代理。默认收起。
|
|
3413
|
+
|
|
3414
|
+
```tsx
|
|
3415
|
+
import { AiSubagent } from "@bixlab/mtone";
|
|
3416
|
+
import "@bixlab/mtone/styles.css";
|
|
3417
|
+
|
|
3418
|
+
export default function Demo() {
|
|
3419
|
+
return (
|
|
3420
|
+
<AiSubagent
|
|
3421
|
+
name="文档校对"
|
|
3422
|
+
status="completed"
|
|
3423
|
+
defaultOpen
|
|
3424
|
+
description="核对目录和页码"
|
|
3425
|
+
result="发现一处需要核实的页码。"
|
|
3426
|
+
/>
|
|
3427
|
+
);
|
|
3428
|
+
}
|
|
3429
|
+
```
|
|
3430
|
+
|
|
3431
|
+
### AiTool
|
|
3432
|
+
|
|
3433
|
+
- [AiTool](https://xingjianxu.github.io/mtone/#/components/AiTool): 按纯文本展示工具输入、输出及状态。
|
|
3434
|
+
- Import: AiTool from @bixlab/mtone
|
|
3435
|
+
- name / input / output: string. name 必填;input 和 output 为纯文本,默认标题取 name。
|
|
3436
|
+
- title / statusLabel: string. 可覆盖折叠标题和状态文字。
|
|
3437
|
+
- status: AiActivityStatus (default: pending). 状态为 pending、running、completed、error、cancelled。
|
|
3438
|
+
- open / defaultOpen / onOpenChange: boolean / boolean / (open: boolean) => void. 控制展开状态、指定初始展开状态或监听展开变化。
|
|
3439
|
+
- children / 原生属性: ReactNode / HTMLAttributes<HTMLDivElement>. 额外内容及根 div 属性。
|
|
3440
|
+
- 不调用工具或执行输入、输出中的文本。默认收起。
|
|
3441
|
+
|
|
3442
|
+
```tsx
|
|
3443
|
+
import { AiTool } from "@bixlab/mtone";
|
|
3444
|
+
import "@bixlab/mtone/styles.css";
|
|
3445
|
+
|
|
3446
|
+
export default function Demo() {
|
|
3447
|
+
return (
|
|
3448
|
+
<AiTool
|
|
3449
|
+
name="检索示例"
|
|
3450
|
+
defaultOpen
|
|
3451
|
+
status="completed"
|
|
3452
|
+
input={JSON.stringify({ keyword: "目录" })}
|
|
3453
|
+
output="匹配到 2 条示例记录"
|
|
3454
|
+
/>
|
|
3455
|
+
);
|
|
3456
|
+
}
|
|
3457
|
+
```
|
|
3458
|
+
|
|
3459
|
+
### AiCheckpoint
|
|
3460
|
+
|
|
3461
|
+
- [AiCheckpoint](https://xingjianxu.github.io/mtone/#/components/AiCheckpoint): 展示检查点信息,并把恢复请求交给应用。
|
|
3462
|
+
- Import: AiCheckpoint from @bixlab/mtone
|
|
3463
|
+
- label / description / children: string / ReactNode / ReactNode. 标签、说明及补充内容。
|
|
3464
|
+
- onRestore / restoreLabel / disabled: () => void / string / boolean. 点击时通知应用;未提供回调时按钮禁用。
|
|
3465
|
+
- 不会自行保存或恢复应用状态。
|
|
3466
|
+
|
|
3467
|
+
```tsx
|
|
3468
|
+
import { useState } from "react";
|
|
3469
|
+
import { AiCheckpoint } from "@bixlab/mtone";
|
|
3470
|
+
import "@bixlab/mtone/styles.css";
|
|
3471
|
+
|
|
3472
|
+
export default function Demo() {
|
|
3473
|
+
const [restored, setRestored] = useState(false);
|
|
3474
|
+
return (
|
|
3475
|
+
<div>
|
|
3476
|
+
<AiCheckpoint
|
|
3477
|
+
label="整理前"
|
|
3478
|
+
description="演示检查点"
|
|
3479
|
+
onRestore={() => setRestored(true)}
|
|
3480
|
+
/>
|
|
3481
|
+
{restored && <p role="status">已收到恢复请求(模拟)。</p>}
|
|
3482
|
+
</div>
|
|
3483
|
+
);
|
|
3484
|
+
}
|
|
3485
|
+
```
|
|
3486
|
+
|
|
3487
|
+
### AiConfirmation
|
|
3488
|
+
|
|
3489
|
+
- [AiConfirmation](https://xingjianxu.github.io/mtone/#/components/AiConfirmation): 展示待确认事项、受控决定和按钮状态。
|
|
3490
|
+
- Import: AiConfirmation from @bixlab/mtone
|
|
3491
|
+
- title / description / children: string / ReactNode / ReactNode. 操作标题、必要说明及补充内容。
|
|
3492
|
+
- state / busy: "pending" | "approved" | "rejected" / boolean (default: pending / false). 决定由调用方维护;busy 时禁用待确认按钮。
|
|
3493
|
+
- onConfirm / onReject: () => void. 相应决定的回调;未传的按钮禁用。
|
|
3494
|
+
- confirmLabel / rejectLabel: string. 覆盖确认或拒绝的按钮文字。
|
|
3495
|
+
- 不替应用授权、执行或保存决定;示例的点击仅改变本地显示。
|
|
3496
|
+
|
|
3497
|
+
```tsx
|
|
3498
|
+
import { useState } from "react";
|
|
3499
|
+
import { AiConfirmation } from "@bixlab/mtone";
|
|
3500
|
+
import "@bixlab/mtone/styles.css";
|
|
3501
|
+
|
|
3502
|
+
export default function Demo() {
|
|
3503
|
+
const [state, setState] = useState<"pending" | "approved" | "rejected">(
|
|
3504
|
+
"pending",
|
|
3505
|
+
);
|
|
3506
|
+
return (
|
|
3507
|
+
<AiConfirmation
|
|
3508
|
+
title="保存示例摘要?"
|
|
3509
|
+
description="仅演示确认界面,不会保存文件。"
|
|
3510
|
+
state={state}
|
|
3511
|
+
onConfirm={() => setState("approved")}
|
|
3512
|
+
onReject={() => setState("rejected")}
|
|
3513
|
+
/>
|
|
3514
|
+
);
|
|
3515
|
+
}
|
|
3516
|
+
```
|
|
3517
|
+
|
|
3518
|
+
### AiSources
|
|
3519
|
+
|
|
3520
|
+
- [AiSources](https://xingjianxu.github.io/mtone/#/components/AiSources): 集中展示引文来源和说明,可折叠并显示数量。
|
|
3521
|
+
- Import: AiSources from @bixlab/mtone
|
|
3522
|
+
- sources: AiSource[]. 必填;条目包含 id、title,及可选 url、description。
|
|
3523
|
+
- defaultOpen: boolean (default: false). 初始展开来源列表。
|
|
3524
|
+
- label / className / style: string / string / CSSProperties. 可覆盖显示名称及局部样式。
|
|
3525
|
+
- 仅将有效的 HTTP(S)、站内根路径或锚点显示为可点链接;无效 URL 显示为纯文本。组件不会访问或验证来源内容。
|
|
3526
|
+
|
|
3527
|
+
```tsx
|
|
3528
|
+
import { AiSources } from "@bixlab/mtone";
|
|
3529
|
+
import "@bixlab/mtone/styles.css";
|
|
3530
|
+
|
|
3531
|
+
export default function Demo() {
|
|
3532
|
+
return (
|
|
3533
|
+
<AiSources
|
|
3534
|
+
defaultOpen
|
|
3535
|
+
sources={[
|
|
3536
|
+
{ id: "one", title: "项目准备说明", description: "示例来源一" },
|
|
3537
|
+
{ id: "two", title: "当前文档", url: "#/components/AiSources" },
|
|
3538
|
+
]}
|
|
3539
|
+
/>
|
|
3540
|
+
);
|
|
3541
|
+
}
|
|
3542
|
+
```
|
|
3543
|
+
|
|
3544
|
+
### AiInlineCitation
|
|
3545
|
+
|
|
3546
|
+
- [AiInlineCitation](https://xingjianxu.github.io/mtone/#/components/AiInlineCitation): 在句子中插入来源编号或标题。
|
|
3547
|
+
- Import: AiInlineCitation from @bixlab/mtone
|
|
3548
|
+
- source: AiSource. 必填;提供 id、title 及可选的 url、description。
|
|
3549
|
+
- index: number. 显示编号;省略时显示标题。
|
|
3550
|
+
- className / style: string / CSSProperties. 可覆盖局部样式。
|
|
3551
|
+
- 仅有效的 HTTP(S)、站内根路径或锚点会渲染为链接;无效或缺省 URL 显示为文本。
|
|
3552
|
+
|
|
3553
|
+
```tsx
|
|
3554
|
+
import { AiInlineCitation } from "@bixlab/mtone";
|
|
3555
|
+
import "@bixlab/mtone/styles.css";
|
|
3556
|
+
|
|
3557
|
+
export default function Demo() {
|
|
3558
|
+
return (
|
|
3559
|
+
<p>
|
|
3560
|
+
整理前请核对原始记录。{" "}
|
|
3561
|
+
<AiInlineCitation
|
|
3562
|
+
index={1}
|
|
3563
|
+
source={{
|
|
3564
|
+
id: "one",
|
|
3565
|
+
title: "查看来源示例",
|
|
3566
|
+
url: "#/components/AiSources?section=ai-sources",
|
|
3567
|
+
}}
|
|
3568
|
+
/>
|
|
3569
|
+
</p>
|
|
3570
|
+
);
|
|
3571
|
+
}
|
|
3572
|
+
```
|
|
3573
|
+
|
|
3574
|
+
### AiContext
|
|
3575
|
+
|
|
3576
|
+
- [AiContext](https://xingjianxu.github.io/mtone/#/components/AiContext): 展示调用方报告的词元使用量和预格式化费用。
|
|
3577
|
+
- Import: AiContext from @bixlab/mtone
|
|
3578
|
+
- usedTokens / maxTokens: number. 用量必填;可选上限,用于显示进度。
|
|
3579
|
+
- inputTokens / outputTokens / cost: number / number / string. 可选输入、输出计数及应用已格式化的费用。
|
|
3580
|
+
- label / className / style: string / string / CSSProperties. 可覆盖显示名称及局部样式。
|
|
3581
|
+
- 不估算词元或价格,不读取计费账户。
|
|
3582
|
+
|
|
3583
|
+
```tsx
|
|
3584
|
+
import { AiContext } from "@bixlab/mtone";
|
|
3585
|
+
import "@bixlab/mtone/styles.css";
|
|
3586
|
+
|
|
3587
|
+
export default function Demo() {
|
|
3588
|
+
return (
|
|
3589
|
+
<AiContext
|
|
3590
|
+
usedTokens={4200}
|
|
3591
|
+
maxTokens={8000}
|
|
3592
|
+
inputTokens={3200}
|
|
3593
|
+
outputTokens={1000}
|
|
3594
|
+
cost="¥0.08(模拟)"
|
|
3595
|
+
/>
|
|
3596
|
+
);
|
|
3597
|
+
}
|
|
3598
|
+
```
|
|
3599
|
+
|
|
3600
|
+
### AiFileTree
|
|
3601
|
+
|
|
3602
|
+
- [AiFileTree](https://xingjianxu.github.io/mtone/#/components/AiFileTree): 从应用数据展示文件和目录,并回传选择。
|
|
3603
|
+
- Import: AiFileTree from @bixlab/mtone
|
|
3604
|
+
- items: AiFileNode[]. 必填;节点含 id、name,及可选 kind、children、disabled。
|
|
3605
|
+
- selectedId / defaultSelectedId / onSelect: string | null / string / (id: string, node: AiFileNode) => void. 受控选中键、初始键和选择回调。
|
|
3606
|
+
- defaultExpandedIds: string[]. 初始展开节点键。
|
|
3607
|
+
- label / className / style: string / string / CSSProperties. 可覆盖显示名称及局部样式。
|
|
3608
|
+
- 不读取本地文件、检查权限或自动打开文件。为节点提供稳定唯一的 id。
|
|
3609
|
+
|
|
3610
|
+
```tsx
|
|
3611
|
+
import { useState } from "react";
|
|
3612
|
+
import { AiFileTree } from "@bixlab/mtone";
|
|
3613
|
+
import "@bixlab/mtone/styles.css";
|
|
3614
|
+
|
|
3615
|
+
export default function Demo() {
|
|
3616
|
+
const [selected, setSelected] = useState<string | null>(null);
|
|
3617
|
+
return (
|
|
3618
|
+
<div>
|
|
3619
|
+
<AiFileTree
|
|
3620
|
+
items={[
|
|
3621
|
+
{
|
|
3622
|
+
id: "src",
|
|
3623
|
+
name: "src",
|
|
3624
|
+
kind: "folder",
|
|
3625
|
+
children: [
|
|
3626
|
+
{ id: "main", name: "main.tsx" },
|
|
3627
|
+
{ id: "test", name: "main.test.tsx" },
|
|
3628
|
+
],
|
|
3629
|
+
},
|
|
3630
|
+
]}
|
|
3631
|
+
defaultExpandedIds={["src"]}
|
|
3632
|
+
selectedId={selected}
|
|
3633
|
+
onSelect={setSelected}
|
|
3634
|
+
/>
|
|
3635
|
+
<p role="status">{selected ? "已选:" + selected : "请选择文件"}</p>
|
|
3636
|
+
</div>
|
|
3637
|
+
);
|
|
3638
|
+
}
|
|
3639
|
+
```
|
|
3640
|
+
|
|
3641
|
+
### AiStackTrace
|
|
3642
|
+
|
|
3643
|
+
- [AiStackTrace](https://xingjianxu.github.io/mtone/#/components/AiStackTrace): 展示错误文本和可折叠的堆栈帧。
|
|
3644
|
+
- Import: AiStackTrace from @bixlab/mtone
|
|
3645
|
+
- message / frames: string / AiStackFrame[]. 必填;每帧含 file,可附 line、column、functionName。
|
|
3646
|
+
- defaultOpen: boolean (default: false). 初始展开。
|
|
3647
|
+
- label / className / style: string / string / CSSProperties. 可覆盖显示名称及局部样式。
|
|
3648
|
+
- 不捕获错误、不解释异常或打开文件。
|
|
3649
|
+
|
|
3650
|
+
```tsx
|
|
3651
|
+
import { AiStackTrace } from "@bixlab/mtone";
|
|
3652
|
+
import "@bixlab/mtone/styles.css";
|
|
3653
|
+
|
|
3654
|
+
export default function Demo() {
|
|
3655
|
+
return (
|
|
3656
|
+
<AiStackTrace
|
|
3657
|
+
defaultOpen
|
|
3658
|
+
message="Error: Missing project name"
|
|
3659
|
+
frames={[
|
|
3660
|
+
{
|
|
3661
|
+
file: "src/project.ts",
|
|
3662
|
+
line: 24,
|
|
3663
|
+
column: 8,
|
|
3664
|
+
functionName: "readProject",
|
|
3665
|
+
},
|
|
3666
|
+
]}
|
|
3667
|
+
/>
|
|
3668
|
+
);
|
|
3669
|
+
}
|
|
3670
|
+
```
|
|
3671
|
+
|
|
3672
|
+
### AiTerminal
|
|
3673
|
+
|
|
3674
|
+
- [AiTerminal](https://xingjianxu.github.io/mtone/#/components/AiTerminal): 以可聚焦的纯文本区域展示命令输出及状态。
|
|
3675
|
+
- Import: AiTerminal from @bixlab/mtone
|
|
3676
|
+
- output: string. 必填;显示文本输出。
|
|
3677
|
+
- status: AiTerminalStatus (default: idle). idle、running、success 或 error。
|
|
3678
|
+
- label / className / style: string / string / CSSProperties. 可覆盖显示名称及局部样式。
|
|
3679
|
+
- 不是交互式终端,不接收命令,也不创建进程。
|
|
3680
|
+
|
|
3681
|
+
```tsx
|
|
3682
|
+
import { AiTerminal } from "@bixlab/mtone";
|
|
3683
|
+
import "@bixlab/mtone/styles.css";
|
|
3684
|
+
|
|
3685
|
+
export default function Demo() {
|
|
3686
|
+
return <AiTerminal status="success" output={"$ npm test\nPASS 3 tests"} />;
|
|
3687
|
+
}
|
|
3688
|
+
```
|
|
3689
|
+
|
|
3690
|
+
### AiTestResults
|
|
3691
|
+
|
|
3692
|
+
- [AiTestResults](https://xingjianxu.github.io/mtone/#/components/AiTestResults): 可折叠查看测试结果和状态汇总。
|
|
3693
|
+
- Import: AiTestResults from @bixlab/mtone
|
|
3694
|
+
- results: AiTestResult[]. 必填;每项含 id、name、status,可附 durationMs、details。
|
|
3695
|
+
- defaultOpen: boolean (default: false). 初始展开。
|
|
3696
|
+
- label / className / style: string / string / CSSProperties. 可覆盖显示名称及局部样式。
|
|
3697
|
+
- 状态为 passed、failed、skipped 或 running;组件不执行测试。
|
|
3698
|
+
|
|
3699
|
+
```tsx
|
|
3700
|
+
import { AiTestResults } from "@bixlab/mtone";
|
|
3701
|
+
import "@bixlab/mtone/styles.css";
|
|
3702
|
+
|
|
3703
|
+
export default function Demo() {
|
|
3704
|
+
return (
|
|
3705
|
+
<AiTestResults
|
|
3706
|
+
defaultOpen
|
|
3707
|
+
results={[
|
|
3708
|
+
{ id: "one", name: "保存标题", status: "passed", durationMs: 15 },
|
|
3709
|
+
{
|
|
3710
|
+
id: "two",
|
|
3711
|
+
name: "空记录提示",
|
|
3712
|
+
status: "failed",
|
|
3713
|
+
details: "期望看到空状态提示",
|
|
3714
|
+
},
|
|
3715
|
+
]}
|
|
3716
|
+
/>
|
|
3717
|
+
);
|
|
3718
|
+
}
|
|
3719
|
+
```
|