@bixlab/mtone 0.14.0 → 0.15.1
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 +13 -3
- package/dist/index.js +293 -49
- package/dist/styles.css +1 -1
- package/llms.txt +160 -42
- 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.1. 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-blockeditor 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,47 @@ 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-blockeditor
|
|
47
|
+
- initialContent: readonly BlockEditorInput[]. 仅在创建该文档时读取。支持正文、标题、列表、待办、引用、分割线、代码、表格、折叠、提示块和 URL 图片。默认空段落。
|
|
48
|
+
- documentKey: string | number. 换文档时修改键;新文档单独读取 initialContent,旧撤销历史不保留。
|
|
49
|
+
- onChange: (blocks: BlockEditorBlock[]) => void. 内容改变时返回 BlockNote JSON。由应用决定怎样保存、验证和重新加载。
|
|
50
|
+
- readOnly: boolean (default: false). 显示不可编辑正文;代码使用 Typography.Code 高亮。不替代应用权限校验。
|
|
51
|
+
- uploadImage: (file: File) => Promise<string>. 可选。由宿主上传图片并返回 HTTP(S) 地址;未传时仍可通过 URL 插入图片。
|
|
52
|
+
- label / locale / className: string / 'zh' | 'en' / string. 正文的无障碍名称、界面语言和外层样式。语言未指定时继承 mtone,主题同步继承。
|
|
53
|
+
- 新包名 @bixlab/mtone-blockeditor 尚未发布到 npm;下方代码使用新包名。主包不包含、也不依赖编辑器。
|
|
54
|
+
- 导入两份 CSS;Next.js 使用客户端组件,推荐动态导入并设置 ssr: false。移动端 viewport 建议加 interactive-widget=resizes-content。
|
|
55
|
+
- 键入 / 或点 + 添加块。更多格式提供对齐、文字色和高亮。将光标放进表格单元格即可增删行列、切换表头;不支持合并单元格。代码语言可切换,可选高亮预览;图片可编辑替代文本和说明。
|
|
56
|
+
- 原生 JSON 是主存储格式。只读只影响界面。外部内容仍需由应用验证来源、权限以及数据结构。
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { BlockEditor, type BlockEditorBlock } from "@bixlab/mtone-blockeditor";
|
|
60
|
+
import "@bixlab/mtone/styles.css";
|
|
61
|
+
import "@bixlab/mtone-blockeditor/styles.css";
|
|
62
|
+
|
|
63
|
+
export default function Demo() {
|
|
64
|
+
const save = (blocks: BlockEditorBlock[]) => {
|
|
65
|
+
localStorage.setItem("meeting-draft", JSON.stringify(blocks));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return <BlockEditor
|
|
69
|
+
documentKey="meeting-draft"
|
|
70
|
+
label="会议笔记"
|
|
71
|
+
initialContent={[{ type: "heading", props: { level: 1 }, content: "会议笔记" }]}
|
|
72
|
+
onChange={save}
|
|
73
|
+
/>;
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
41
77
|
### CheckCard
|
|
42
78
|
|
|
43
79
|
- [CheckCard](https://xingjianxu.github.io/mtone/#/components/CheckCard): 以卡片呈现可选项。独立使用可勾选,CheckCard.Group 管理单选或多选,CardGroup 负责响应式排列。
|
|
@@ -1620,53 +1656,135 @@ export default function Demo() {
|
|
|
1620
1656
|
|
|
1621
1657
|
### SettingsDialog
|
|
1622
1658
|
|
|
1623
|
-
- [SettingsDialog](https://xingjianxu.github.io/mtone/#/components/SettingsDialog):
|
|
1659
|
+
- [SettingsDialog](https://xingjianxu.github.io/mtone/#/components/SettingsDialog): 带分类导航的设置对话框,可搜索并定位调用方提供的设置项。
|
|
1624
1660
|
- Import: SettingsDialog, SettingRow, Button, Switch, NumberInput, Select from @bixlab/mtone
|
|
1625
1661
|
- categories: readonly SettingsDialogCategory[]. 依次传入各分类的唯一 value、label、可选 icon 和 content。
|
|
1626
1662
|
- value / defaultValue: string. 受控或非受控的当前分类;未提供或找不到对应分类时使用第一项。
|
|
1627
1663
|
- onValueChange: (value: string) => void. 请求切换到另一分类时触发。
|
|
1628
1664
|
- categoriesLabel: string. 为分类导航提供自定义的可访问名称。
|
|
1629
|
-
-
|
|
1665
|
+
- searchIndex: readonly SettingsDialogSearchEntry[]. 启用内建搜索。每条由 category(分类 value)、id(分类内容中的元素 ID)、label(设置名称)和可选 keywords 组成。
|
|
1666
|
+
- search: ReactNode | (context: SettingsDialogSearchContext) => ReactNode. 自定义搜索入口,优先于 searchIndex;可以使用 selectCategory 切换分类。
|
|
1630
1667
|
- Dialog 属性: Omit<DialogProps, 'children'>. 沿用 Dialog 的 title、description、trigger、open、defaultOpen、onOpenChange、footer、modal 和 className。
|
|
1631
1668
|
- 宽屏分类与详情分别滚动;视口不宽于 600px 时先展示分类,打开详情时聚焦标题,返回时聚焦当前分类。
|
|
1632
1669
|
- 弹窗保持打开时,访问过的分类切换后仍保留挂载,可暂存该分类中的界面状态。
|
|
1633
|
-
-
|
|
1670
|
+
- 搜索匹配设置名、文本分类名和关键词;自定义分类标签为 React 节点时以分类 value 匹配。上下键选择,Enter 定位,Escape 清空。
|
|
1671
|
+
- 定位后恢复分类导航并在详情内部滚动及短暂高亮目标;请将 ID 放在可聚焦的行或标题(如 SettingRow 上设置 tabIndex={-1})。设置值、保存逻辑和权限仍由调用方管理。
|
|
1634
1672
|
|
|
1635
1673
|
```tsx
|
|
1636
1674
|
import React from "react";
|
|
1637
|
-
import {
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1675
|
+
import {
|
|
1676
|
+
Button,
|
|
1677
|
+
NumberInput,
|
|
1678
|
+
Select,
|
|
1679
|
+
SettingRow,
|
|
1680
|
+
SettingsDialog,
|
|
1681
|
+
Switch,
|
|
1682
|
+
type SettingsDialogSearchEntry,
|
|
1683
|
+
} from "@bixlab/mtone";
|
|
1684
|
+
import "@bixlab/mtone/styles.css";
|
|
1685
|
+
|
|
1686
|
+
const searchIndex = [
|
|
1687
|
+
{
|
|
1688
|
+
category: "general",
|
|
1689
|
+
id: "settings-auto-save",
|
|
1690
|
+
label: "自动保存",
|
|
1691
|
+
keywords: ["草稿", "autosave"],
|
|
1692
|
+
},
|
|
1693
|
+
{
|
|
1694
|
+
category: "general",
|
|
1695
|
+
id: "settings-notifications",
|
|
1696
|
+
label: "通知",
|
|
1697
|
+
keywords: ["提醒"],
|
|
1698
|
+
},
|
|
1699
|
+
{
|
|
1700
|
+
category: "editor",
|
|
1701
|
+
id: "settings-context",
|
|
1702
|
+
label: "光标上下文行数",
|
|
1703
|
+
keywords: ["光标", "cursor"],
|
|
1704
|
+
},
|
|
1705
|
+
{
|
|
1706
|
+
category: "editor",
|
|
1707
|
+
id: "settings-spaces",
|
|
1708
|
+
label: "Tab 空格数",
|
|
1709
|
+
keywords: ["缩进", "indent"],
|
|
1710
|
+
},
|
|
1711
|
+
{
|
|
1712
|
+
category: "privacy",
|
|
1713
|
+
id: "settings-analytics",
|
|
1714
|
+
label: "使用情况统计",
|
|
1715
|
+
keywords: ["匿名", "analytics"],
|
|
1716
|
+
},
|
|
1717
|
+
] satisfies readonly SettingsDialogSearchEntry[];
|
|
1718
|
+
|
|
1719
|
+
export default function Demo() {
|
|
1720
|
+
return (
|
|
1721
|
+
<SettingsDialog
|
|
1722
|
+
title="应用设置"
|
|
1723
|
+
trigger={<Button>打开设置</Button>}
|
|
1724
|
+
searchIndex={searchIndex}
|
|
1725
|
+
categories={[
|
|
1726
|
+
{
|
|
1727
|
+
value: "general",
|
|
1728
|
+
label: "常规",
|
|
1729
|
+
content: (
|
|
1730
|
+
<SettingRow.Group aria-label="常规设置">
|
|
1731
|
+
<SettingRow
|
|
1732
|
+
id="settings-auto-save"
|
|
1733
|
+
title="自动保存"
|
|
1734
|
+
description="编辑时自动保存草稿。"
|
|
1735
|
+
control={(props) => <Switch {...props} defaultChecked />}
|
|
1736
|
+
/>
|
|
1737
|
+
<SettingRow
|
|
1738
|
+
id="settings-notifications"
|
|
1739
|
+
title="通知"
|
|
1740
|
+
description="在任务完成时发送提醒。"
|
|
1741
|
+
control={(props) => <Switch {...props} />}
|
|
1742
|
+
/>
|
|
1743
|
+
</SettingRow.Group>
|
|
1744
|
+
),
|
|
1745
|
+
},
|
|
1746
|
+
{
|
|
1747
|
+
value: "editor",
|
|
1748
|
+
label: "编辑器",
|
|
1749
|
+
content: (
|
|
1750
|
+
<SettingRow.Group aria-label="编辑器设置">
|
|
1751
|
+
<SettingRow
|
|
1752
|
+
id="settings-context"
|
|
1753
|
+
title="光标上下文行数"
|
|
1754
|
+
control={(props) => <NumberInput {...props} defaultValue={3} />}
|
|
1755
|
+
/>
|
|
1756
|
+
<SettingRow
|
|
1757
|
+
id="settings-spaces"
|
|
1758
|
+
title="Tab 空格数"
|
|
1759
|
+
control={(props) => (
|
|
1760
|
+
<Select
|
|
1761
|
+
{...props}
|
|
1762
|
+
defaultValue="4"
|
|
1763
|
+
options={[2, 4, 8].map((value) => ({
|
|
1764
|
+
value: String(value),
|
|
1765
|
+
label: `${value} 个空格`,
|
|
1766
|
+
}))}
|
|
1767
|
+
/>
|
|
1768
|
+
)}
|
|
1769
|
+
/>
|
|
1770
|
+
</SettingRow.Group>
|
|
1771
|
+
),
|
|
1772
|
+
},
|
|
1773
|
+
{
|
|
1774
|
+
value: "privacy",
|
|
1775
|
+
label: "隐私",
|
|
1776
|
+
content: (
|
|
1777
|
+
<SettingRow
|
|
1778
|
+
id="settings-analytics"
|
|
1779
|
+
title="使用情况统计"
|
|
1780
|
+
description="发送匿名使用数据。"
|
|
1781
|
+
control={(props) => <Switch {...props} />}
|
|
1782
|
+
/>
|
|
1783
|
+
),
|
|
1784
|
+
},
|
|
1785
|
+
]}
|
|
1786
|
+
/>
|
|
1787
|
+
);
|
|
1670
1788
|
}
|
|
1671
1789
|
|
|
1672
1790
|
```
|
|
@@ -1863,7 +1981,7 @@ export default function Demo() {
|
|
|
1863
1981
|
- directory / expandAction: boolean / false | "click" | "doubleClick" (default: false / "click"). 设置 directory 开启目录模式;默认点击展开,false 禁用标题触发展开但保留箭头 / 方向键。
|
|
1864
1982
|
- label / className / style: string / string / CSSProperties. 可访问名称、根类名与样式;支持其余不冲突的 div 属性。
|
|
1865
1983
|
- ref: React.Ref<TreeRef>. 暴露 nativeElement、focus()、scrollTo({ key, align?, offset?, autoExpand? });align 为 top / bottom / auto。autoExpand 只在非受控展开模式生效。
|
|
1866
|
-
-
|
|
1984
|
+
- 文档的交互配置示例可切换连接线、节点图标、整行铺满、复选框、独立勾选、多选、选择、禁用与目录模式,调整目录标题展开方式、行高、间距、缩进和可视高度。恢复默认会还原展开状态并清除选择和勾选;异步加载、虚拟滚动、拖放和节点渲染见独立示例。
|
|
1867
1985
|
- TreeKey 为 string | number;全树键必须唯一且数字有限,缺失或重复键会报错。保留原有 items / id / label、value、expanded 用法;不要混用新旧受控属性。
|
|
1868
1986
|
- 勾选传导在 disabled、disableCheckbox 或 checkable=false 节点停止;严格模式下父子完全独立。disabled 不会隐藏节点或清除外部传入状态。
|
|
1869
1987
|
- 支持方向键、Home / End、Enter、Space 和字符首字母定位。Space 在复选模式中切换勾选;目录多选支持 Ctrl / Command 追加、Shift 可见范围选择。
|
|
@@ -2779,7 +2897,7 @@ export default function Demo() {
|
|
|
2779
2897
|
- [PropertyList](https://xingjianxu.github.io/mtone/#/components/PropertyList): 文档属性的定义列表容器。
|
|
2780
2898
|
- Import: PropertyList, PropertyItem from @bixlab/mtone
|
|
2781
2899
|
- children: ReactNode. 组件内容。
|
|
2782
|
-
- 使用 dl
|
|
2900
|
+
- 使用 dl 语义,与本页 PropertyItem 小节中的属性行搭配。
|
|
2783
2901
|
|
|
2784
2902
|
```tsx
|
|
2785
2903
|
import { PropertyList, PropertyItem } from "@bixlab/mtone";
|
|
@@ -2794,7 +2912,7 @@ export default function Demo() {
|
|
|
2794
2912
|
|
|
2795
2913
|
### PropertyItem
|
|
2796
2914
|
|
|
2797
|
-
- [PropertyItem](https://xingjianxu.github.io/mtone/#/components/
|
|
2915
|
+
- [PropertyItem](https://xingjianxu.github.io/mtone/#/components/PropertyList?section=property-item): 展示一行属性名和值。
|
|
2798
2916
|
- Import: PropertyItem, PropertyList from @bixlab/mtone
|
|
2799
2917
|
- label: ReactNode. 必填;属性名。
|
|
2800
2918
|
- children: ReactNode. 组件内容。
|