@bixlab/mtone 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +13 -3
- package/dist/index.js +293 -49
- package/dist/styles.css +1 -1
- package/llms.txt +159 -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.0. Prefer the llms.txt and dist/index.d.ts bundled with your installed version over the live website, which follows master.
|
|
6
6
|
|
|
7
7
|
## Setup
|
|
8
8
|
|
|
@@ -22,8 +22,10 @@ This file describes this package checkout, not necessarily the latest published
|
|
|
22
22
|
- Pair controlled values/open state with the documented change callbacks; defaultValue/defaultOpen are for uncontrolled initial state.
|
|
23
23
|
- Give controls accessible labels and icon-only buttons aria-label. Keep keyboard/focus behavior intact. Focus uses --mt-focus (#93B4DC): existing input borders change color only; other controls use a single 1px inset edge without changing layout. Select option highlights remain background-only in all modes.
|
|
24
24
|
- Shared theme accents: use --mt-accent-neutral/blue/green/orange/red/purple/teal/coral with CSS var() or override the matching keys via MtoneProvider tokens. Tabs indicatorColor accepts these preset names or a CSS color for the selected line only.
|
|
25
|
+
- Semantic colors select a purpose, not a hue: --mt-select-surface for selected surfaces, --mt-focus for keyboard focus, --mt-alert-info-bg for an info surface. New role overrides limit changes to that purpose and preserve legacy CSS fallbacks when unset; existing hue presets remain public.
|
|
26
|
+
- Selected surfaces: use --mt-select-surface for pale-blue selected items and located settings rows. It is #E9EEF4 in light and #293746 in dark mode, not an accent color or focus-border token.
|
|
25
27
|
- Dialog modal defaults true: outside clicks do not close; false allows outside dismissal. Both retain focus trapping, backdrop and scroll lock. Escape and close button remain available.
|
|
26
|
-
- Use Tag for content labels with optional removal, and Status for a state indicator.
|
|
28
|
+
- Use Tag for content labels with optional removal, and Status for a state indicator. BlockEditor is documented separately and belongs to the optional @bixlab/mtone-blocknote package, not this npm package. Upload requires an application service; examples are not backend persistence. DatePicker uses native browser date UI.
|
|
27
29
|
- Toast notifications need ToastProvider; useToast exposes add, success, error, info, update, promise and close (verify installed declarations before use).
|
|
28
30
|
- Do not assume the live docs match an older npm package. Type-check generated code and run interaction tests.
|
|
29
31
|
|
|
@@ -31,13 +33,46 @@ This file describes this package checkout, not necessarily the latest published
|
|
|
31
33
|
|
|
32
34
|
- [Getting started](https://xingjianxu.github.io/mtone/#/start): installation and AI usage
|
|
33
35
|
- [Theme and styling](https://xingjianxu.github.io/mtone/#/theme): color modes and tokens
|
|
34
|
-
- [Shared color presets](https://xingjianxu.github.io/mtone/#/theme/color-presets):
|
|
36
|
+
- [Shared color presets](https://xingjianxu.github.io/mtone/#/theme/color-presets): hue presets, semantic roles, and scoped overrides
|
|
35
37
|
- [Component gallery](https://xingjianxu.github.io/mtone/#/gallery): independent component examples
|
|
36
38
|
- [Application showcase](https://xingjianxu.github.io/mtone/showcase.html): interactive in-memory demo, not a backend
|
|
37
39
|
- [Source repository](https://github.com/xingjianxu/mtone): current code and migration notes
|
|
38
40
|
|
|
39
41
|
## Components
|
|
40
42
|
|
|
43
|
+
### BlockEditor
|
|
44
|
+
|
|
45
|
+
- [BlockEditor](https://xingjianxu.github.io/mtone/#/components/BlockEditor): 可选的块编辑器:BlockNote 管理正文与选区,mtone 提供工具栏、菜单和主题。独立于主包。
|
|
46
|
+
- Import: BlockEditor from @bixlab/mtone-blocknote
|
|
47
|
+
- initialContent: readonly BlockEditorInput[]. 只在创建该文档时读取;支持正文、标题、项目/编号列表、待办项、引用和代码块。默认空段落。
|
|
48
|
+
- documentKey: string | number. 换文档时修改键;新文档单独读取 initialContent,旧撤销历史不保留。
|
|
49
|
+
- onChange: (blocks: BlockEditorBlock[]) => void. 内容改变时返回 BlockNote JSON。由应用决定怎样保存、验证和重新加载。
|
|
50
|
+
- readOnly: boolean (default: false). 显示不可编辑正文与链接,不显示工具栏;不替代应用权限校验。
|
|
51
|
+
- label / locale / className: string / 'zh' | 'en' / string. 正文的无障碍名称、界面语言和外层样式。语言未指定时继承 mtone,主题同步继承。
|
|
52
|
+
- 编辑器单独安装:npm install @bixlab/mtone @bixlab/mtone-blocknote。请以 npm 可用版本为准。主包不包含、也不依赖编辑器。
|
|
53
|
+
- 导入两份 CSS;Next.js 使用客户端组件,推荐动态导入并设置 ssr: false。移动端 viewport 建议加 interactive-widget=resizes-content。
|
|
54
|
+
- 键入 / 或点 + 添加块;选择文本后可设置格式与链接。当前块菜单支持下方插入、复制、上移、下移、删除。拖拽、附件与表格编辑尚未包含。
|
|
55
|
+
- 原生 JSON 是主存储格式。只读只影响界面。外部内容仍需由应用验证来源、权限以及数据结构。
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { BlockEditor, type BlockEditorBlock } from "@bixlab/mtone-blocknote";
|
|
59
|
+
import "@bixlab/mtone/styles.css";
|
|
60
|
+
import "@bixlab/mtone-blocknote/styles.css";
|
|
61
|
+
|
|
62
|
+
export default function Demo() {
|
|
63
|
+
const save = (blocks: BlockEditorBlock[]) => {
|
|
64
|
+
localStorage.setItem("meeting-draft", JSON.stringify(blocks));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return <BlockEditor
|
|
68
|
+
documentKey="meeting-draft"
|
|
69
|
+
label="会议笔记"
|
|
70
|
+
initialContent={[{ type: "heading", props: { level: 1 }, content: "会议笔记" }]}
|
|
71
|
+
onChange={save}
|
|
72
|
+
/>;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
41
76
|
### CheckCard
|
|
42
77
|
|
|
43
78
|
- [CheckCard](https://xingjianxu.github.io/mtone/#/components/CheckCard): 以卡片呈现可选项。独立使用可勾选,CheckCard.Group 管理单选或多选,CardGroup 负责响应式排列。
|
|
@@ -1620,53 +1655,135 @@ export default function Demo() {
|
|
|
1620
1655
|
|
|
1621
1656
|
### SettingsDialog
|
|
1622
1657
|
|
|
1623
|
-
- [SettingsDialog](https://xingjianxu.github.io/mtone/#/components/SettingsDialog):
|
|
1658
|
+
- [SettingsDialog](https://xingjianxu.github.io/mtone/#/components/SettingsDialog): 带分类导航的设置对话框,可搜索并定位调用方提供的设置项。
|
|
1624
1659
|
- Import: SettingsDialog, SettingRow, Button, Switch, NumberInput, Select from @bixlab/mtone
|
|
1625
1660
|
- categories: readonly SettingsDialogCategory[]. 依次传入各分类的唯一 value、label、可选 icon 和 content。
|
|
1626
1661
|
- value / defaultValue: string. 受控或非受控的当前分类;未提供或找不到对应分类时使用第一项。
|
|
1627
1662
|
- onValueChange: (value: string) => void. 请求切换到另一分类时触发。
|
|
1628
1663
|
- categoriesLabel: string. 为分类导航提供自定义的可访问名称。
|
|
1629
|
-
-
|
|
1664
|
+
- searchIndex: readonly SettingsDialogSearchEntry[]. 启用内建搜索。每条由 category(分类 value)、id(分类内容中的元素 ID)、label(设置名称)和可选 keywords 组成。
|
|
1665
|
+
- search: ReactNode | (context: SettingsDialogSearchContext) => ReactNode. 自定义搜索入口,优先于 searchIndex;可以使用 selectCategory 切换分类。
|
|
1630
1666
|
- Dialog 属性: Omit<DialogProps, 'children'>. 沿用 Dialog 的 title、description、trigger、open、defaultOpen、onOpenChange、footer、modal 和 className。
|
|
1631
1667
|
- 宽屏分类与详情分别滚动;视口不宽于 600px 时先展示分类,打开详情时聚焦标题,返回时聚焦当前分类。
|
|
1632
1668
|
- 弹窗保持打开时,访问过的分类切换后仍保留挂载,可暂存该分类中的界面状态。
|
|
1633
|
-
-
|
|
1669
|
+
- 搜索匹配设置名、文本分类名和关键词;自定义分类标签为 React 节点时以分类 value 匹配。上下键选择,Enter 定位,Escape 清空。
|
|
1670
|
+
- 定位后恢复分类导航并在详情内部滚动及短暂高亮目标;请将 ID 放在可聚焦的行或标题(如 SettingRow 上设置 tabIndex={-1})。设置值、保存逻辑和权限仍由调用方管理。
|
|
1634
1671
|
|
|
1635
1672
|
```tsx
|
|
1636
1673
|
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
|
-
|
|
1674
|
+
import {
|
|
1675
|
+
Button,
|
|
1676
|
+
NumberInput,
|
|
1677
|
+
Select,
|
|
1678
|
+
SettingRow,
|
|
1679
|
+
SettingsDialog,
|
|
1680
|
+
Switch,
|
|
1681
|
+
type SettingsDialogSearchEntry,
|
|
1682
|
+
} from "@bixlab/mtone";
|
|
1683
|
+
import "@bixlab/mtone/styles.css";
|
|
1684
|
+
|
|
1685
|
+
const searchIndex = [
|
|
1686
|
+
{
|
|
1687
|
+
category: "general",
|
|
1688
|
+
id: "settings-auto-save",
|
|
1689
|
+
label: "自动保存",
|
|
1690
|
+
keywords: ["草稿", "autosave"],
|
|
1691
|
+
},
|
|
1692
|
+
{
|
|
1693
|
+
category: "general",
|
|
1694
|
+
id: "settings-notifications",
|
|
1695
|
+
label: "通知",
|
|
1696
|
+
keywords: ["提醒"],
|
|
1697
|
+
},
|
|
1698
|
+
{
|
|
1699
|
+
category: "editor",
|
|
1700
|
+
id: "settings-context",
|
|
1701
|
+
label: "光标上下文行数",
|
|
1702
|
+
keywords: ["光标", "cursor"],
|
|
1703
|
+
},
|
|
1704
|
+
{
|
|
1705
|
+
category: "editor",
|
|
1706
|
+
id: "settings-spaces",
|
|
1707
|
+
label: "Tab 空格数",
|
|
1708
|
+
keywords: ["缩进", "indent"],
|
|
1709
|
+
},
|
|
1710
|
+
{
|
|
1711
|
+
category: "privacy",
|
|
1712
|
+
id: "settings-analytics",
|
|
1713
|
+
label: "使用情况统计",
|
|
1714
|
+
keywords: ["匿名", "analytics"],
|
|
1715
|
+
},
|
|
1716
|
+
] satisfies readonly SettingsDialogSearchEntry[];
|
|
1717
|
+
|
|
1718
|
+
export default function Demo() {
|
|
1719
|
+
return (
|
|
1720
|
+
<SettingsDialog
|
|
1721
|
+
title="应用设置"
|
|
1722
|
+
trigger={<Button>打开设置</Button>}
|
|
1723
|
+
searchIndex={searchIndex}
|
|
1724
|
+
categories={[
|
|
1725
|
+
{
|
|
1726
|
+
value: "general",
|
|
1727
|
+
label: "常规",
|
|
1728
|
+
content: (
|
|
1729
|
+
<SettingRow.Group aria-label="常规设置">
|
|
1730
|
+
<SettingRow
|
|
1731
|
+
id="settings-auto-save"
|
|
1732
|
+
title="自动保存"
|
|
1733
|
+
description="编辑时自动保存草稿。"
|
|
1734
|
+
control={(props) => <Switch {...props} defaultChecked />}
|
|
1735
|
+
/>
|
|
1736
|
+
<SettingRow
|
|
1737
|
+
id="settings-notifications"
|
|
1738
|
+
title="通知"
|
|
1739
|
+
description="在任务完成时发送提醒。"
|
|
1740
|
+
control={(props) => <Switch {...props} />}
|
|
1741
|
+
/>
|
|
1742
|
+
</SettingRow.Group>
|
|
1743
|
+
),
|
|
1744
|
+
},
|
|
1745
|
+
{
|
|
1746
|
+
value: "editor",
|
|
1747
|
+
label: "编辑器",
|
|
1748
|
+
content: (
|
|
1749
|
+
<SettingRow.Group aria-label="编辑器设置">
|
|
1750
|
+
<SettingRow
|
|
1751
|
+
id="settings-context"
|
|
1752
|
+
title="光标上下文行数"
|
|
1753
|
+
control={(props) => <NumberInput {...props} defaultValue={3} />}
|
|
1754
|
+
/>
|
|
1755
|
+
<SettingRow
|
|
1756
|
+
id="settings-spaces"
|
|
1757
|
+
title="Tab 空格数"
|
|
1758
|
+
control={(props) => (
|
|
1759
|
+
<Select
|
|
1760
|
+
{...props}
|
|
1761
|
+
defaultValue="4"
|
|
1762
|
+
options={[2, 4, 8].map((value) => ({
|
|
1763
|
+
value: String(value),
|
|
1764
|
+
label: `${value} 个空格`,
|
|
1765
|
+
}))}
|
|
1766
|
+
/>
|
|
1767
|
+
)}
|
|
1768
|
+
/>
|
|
1769
|
+
</SettingRow.Group>
|
|
1770
|
+
),
|
|
1771
|
+
},
|
|
1772
|
+
{
|
|
1773
|
+
value: "privacy",
|
|
1774
|
+
label: "隐私",
|
|
1775
|
+
content: (
|
|
1776
|
+
<SettingRow
|
|
1777
|
+
id="settings-analytics"
|
|
1778
|
+
title="使用情况统计"
|
|
1779
|
+
description="发送匿名使用数据。"
|
|
1780
|
+
control={(props) => <Switch {...props} />}
|
|
1781
|
+
/>
|
|
1782
|
+
),
|
|
1783
|
+
},
|
|
1784
|
+
]}
|
|
1785
|
+
/>
|
|
1786
|
+
);
|
|
1670
1787
|
}
|
|
1671
1788
|
|
|
1672
1789
|
```
|
|
@@ -1863,7 +1980,7 @@ export default function Demo() {
|
|
|
1863
1980
|
- directory / expandAction: boolean / false | "click" | "doubleClick" (default: false / "click"). 设置 directory 开启目录模式;默认点击展开,false 禁用标题触发展开但保留箭头 / 方向键。
|
|
1864
1981
|
- label / className / style: string / string / CSSProperties. 可访问名称、根类名与样式;支持其余不冲突的 div 属性。
|
|
1865
1982
|
- ref: React.Ref<TreeRef>. 暴露 nativeElement、focus()、scrollTo({ key, align?, offset?, autoExpand? });align 为 top / bottom / auto。autoExpand 只在非受控展开模式生效。
|
|
1866
|
-
-
|
|
1983
|
+
- 文档的交互配置示例可切换连接线、节点图标、整行铺满、复选框、独立勾选、多选、选择、禁用与目录模式,调整目录标题展开方式、行高、间距、缩进和可视高度。恢复默认会还原展开状态并清除选择和勾选;异步加载、虚拟滚动、拖放和节点渲染见独立示例。
|
|
1867
1984
|
- TreeKey 为 string | number;全树键必须唯一且数字有限,缺失或重复键会报错。保留原有 items / id / label、value、expanded 用法;不要混用新旧受控属性。
|
|
1868
1985
|
- 勾选传导在 disabled、disableCheckbox 或 checkable=false 节点停止;严格模式下父子完全独立。disabled 不会隐藏节点或清除外部传入状态。
|
|
1869
1986
|
- 支持方向键、Home / End、Enter、Space 和字符首字母定位。Space 在复选模式中切换勾选;目录多选支持 Ctrl / Command 追加、Shift 可见范围选择。
|
|
@@ -2779,7 +2896,7 @@ export default function Demo() {
|
|
|
2779
2896
|
- [PropertyList](https://xingjianxu.github.io/mtone/#/components/PropertyList): 文档属性的定义列表容器。
|
|
2780
2897
|
- Import: PropertyList, PropertyItem from @bixlab/mtone
|
|
2781
2898
|
- children: ReactNode. 组件内容。
|
|
2782
|
-
- 使用 dl
|
|
2899
|
+
- 使用 dl 语义,与本页 PropertyItem 小节中的属性行搭配。
|
|
2783
2900
|
|
|
2784
2901
|
```tsx
|
|
2785
2902
|
import { PropertyList, PropertyItem } from "@bixlab/mtone";
|
|
@@ -2794,7 +2911,7 @@ export default function Demo() {
|
|
|
2794
2911
|
|
|
2795
2912
|
### PropertyItem
|
|
2796
2913
|
|
|
2797
|
-
- [PropertyItem](https://xingjianxu.github.io/mtone/#/components/
|
|
2914
|
+
- [PropertyItem](https://xingjianxu.github.io/mtone/#/components/PropertyList?section=property-item): 展示一行属性名和值。
|
|
2798
2915
|
- Import: PropertyItem, PropertyList from @bixlab/mtone
|
|
2799
2916
|
- label: ReactNode. 必填;属性名。
|
|
2800
2917
|
- children: ReactNode. 组件内容。
|