@bixlab/mtone 0.5.0 → 0.7.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 +1 -1
- package/dist/index.d.ts +58 -21
- package/dist/index.js +235 -27
- package/dist/styles.css +1 -1
- package/llms.txt +78 -45
- 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.7.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
|
|
|
@@ -12,6 +12,7 @@ This file describes this package checkout, not necessarily the latest published
|
|
|
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
14
|
- Optional provider: <MtoneProvider locale="zh" density="compact"><Button>保存</Button></MtoneProvider>. Locale: zh | en; density: compact | comfortable. Provider tokens are CSS custom properties.
|
|
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.
|
|
15
16
|
- Interactive components need a client boundary in React Server Component frameworks.
|
|
16
17
|
|
|
17
18
|
## AI coding guidance
|
|
@@ -28,6 +29,7 @@ This file describes this package checkout, not necessarily the latest published
|
|
|
28
29
|
## Documentation
|
|
29
30
|
|
|
30
31
|
- [Getting started](https://xingjianxu.github.io/mtone/#/start): installation and AI usage
|
|
32
|
+
- [Theme and styling](https://xingjianxu.github.io/mtone/#/theme): color modes and tokens
|
|
31
33
|
- [Component gallery](https://xingjianxu.github.io/mtone/#/gallery): independent component examples
|
|
32
34
|
- [Application showcase](https://xingjianxu.github.io/mtone/showcase.html): interactive in-memory demo, not a backend
|
|
33
35
|
- [Source repository](https://github.com/xingjianxu/mtone): current code and migration notes
|
|
@@ -788,7 +790,7 @@ export default function Demo() {
|
|
|
788
790
|
- 方向键上下循环选择可用项,Home/End 到首尾,Enter 执行,Esc 关闭。禁用项显示但不会执行。焦点保持在搜索框,关闭与焦点恢复由 Dialog 处理。
|
|
789
791
|
- 默认选择后先关闭并请求清空查询,然后调用 action.onSelect 和 onActionSelect。回调不自动导航、等待异步任务、捕获业务错误或保存数据,业务逻辑由应用负责。
|
|
790
792
|
- open/query 受控时,父组件必须响应对应回调更新状态。resetQueryOnClose 作用于组件发出的关闭请求;外部直接改变 open 不应被视为自动重置 query 的保证。
|
|
791
|
-
- 面板复用 mtone Dialog 和 Input.Search
|
|
793
|
+
- 面板复用 mtone Dialog 和 Input.Search,上边缘固定在视窗中上方,不随搜索结果数量变化;结果过多时仅列表滚动。
|
|
792
794
|
|
|
793
795
|
```tsx
|
|
794
796
|
import { useState } from "react";
|
|
@@ -815,30 +817,30 @@ export default function Demo() {
|
|
|
815
817
|
}
|
|
816
818
|
```
|
|
817
819
|
|
|
818
|
-
###
|
|
819
|
-
|
|
820
|
-
- [
|
|
821
|
-
- Import:
|
|
822
|
-
-
|
|
823
|
-
-
|
|
824
|
-
-
|
|
825
|
-
-
|
|
826
|
-
-
|
|
827
|
-
-
|
|
828
|
-
-
|
|
829
|
-
-
|
|
830
|
-
-
|
|
831
|
-
-
|
|
832
|
-
-
|
|
833
|
-
-
|
|
834
|
-
-
|
|
835
|
-
-
|
|
836
|
-
-
|
|
837
|
-
-
|
|
838
|
-
- children / className / style / 原生属性: ReactNode / string / CSSProperties / HTMLAttributes. 各区域均可嵌套内容和覆盖样式;默认不生成主体 Footer,显式组合
|
|
839
|
-
- 主体 Footer 与侧栏版本/折叠底栏是独立区域,默认高度均为 42px。需要时加入 <
|
|
840
|
-
- 使用
|
|
841
|
-
-
|
|
820
|
+
### AdminLayout
|
|
821
|
+
|
|
822
|
+
- [AdminLayout](https://xingjianxu.github.io/mtone/#/components/AdminLayout): 可组合的页面骨架,组织左侧品牌与导航、右侧顶部操作和独立滚动主体。
|
|
823
|
+
- Import: AdminLayout from @bixlab/mtone
|
|
824
|
+
- AdminLayout.Sider.version: ReactNode. 底部左侧的应用版本文字/内容;默认不显示,收起时隐藏。折叠按钮固定在底部右侧。
|
|
825
|
+
- AdminLayout.hasSider: boolean. 是否采用横向布局。省略时自动识别直接子元素中的 AdminLayout.Sider;包装组件内的 Sider 请显式指定。
|
|
826
|
+
- AdminLayout.fullHeight: boolean (default: false). 占满视口高度(100dvh);嵌入页面时可改用 style.height 指定有限高度。
|
|
827
|
+
- AdminLayout.Sider.collapsible: boolean (default: false). 启用复用自 Sidebar 的收起/展开按钮和图标窄栏。
|
|
828
|
+
- AdminLayout.Sider.collapsed: boolean. 受控收起状态;搭配 onCollapsedChange 由父组件更新。
|
|
829
|
+
- AdminLayout.Sider.defaultCollapsed: boolean (default: false). 非受控模式的初始收起状态。
|
|
830
|
+
- AdminLayout.Sider.onCollapsedChange: (collapsed: boolean) => void. 点击收起按钮或响应式断点请求改变状态时调用;受控模式不会自行覆盖 collapsed。
|
|
831
|
+
- AdminLayout.Sider.logo / collapsedLogo: ReactNode. 顶部品牌插槽;collapsedLogo 用于窄栏中的简化标识。
|
|
832
|
+
- AdminLayout.Sider.width / collapsedWidth: number (default: 240 / 52). 展开/收起宽度,单位 px,最小 40px;本版不支持零宽隐藏。
|
|
833
|
+
- AdminLayout.Sider.breakpoint: number. 可选视口断点(px),例如 768。低于断点请求收起,恢复宽屏请求展开;未设置时不自动响应。
|
|
834
|
+
- AdminLayout.Sider.onBreakpoint: (broken: boolean) => void. 监听断点状态;true 表示视口低于设定断点。
|
|
835
|
+
- AdminLayout.Sider.collapseLabel / expandLabel: string (default: 收起侧边栏 / 展开侧边栏). 继承 Sidebar 的切换按钮可访问名称。
|
|
836
|
+
- AdminLayout.Header.breadcrumb: ReactNode. 顶部左侧插槽;建议传入已有 Breadcrumb 组件。
|
|
837
|
+
- AdminLayout.Header.extra: ReactNode. 顶部右对齐操作插槽,可组合 IconButton、Menu、Avatar 等。
|
|
838
|
+
- AdminLayout.Header.children: ReactNode. 顶部左侧补充内容;窄屏允许换行。
|
|
839
|
+
- AdminLayout.Content.as: "main" | "section" | "div" (default: main). 主体语义标签。一个页面通常只使用一个 main;嵌入其他主体时改为 section 或 div。
|
|
840
|
+
- children / className / style / 原生属性: ReactNode / string / CSSProperties / HTMLAttributes. 各区域均可嵌套内容和覆盖样式;默认不生成主体 Footer,显式组合 AdminLayout.Footer 时显示,默认高度 42px。
|
|
841
|
+
- 主体 Footer 与侧栏版本/折叠底栏是独立区域,默认高度均为 42px。需要时加入 <AdminLayout.Footer>内容</AdminLayout.Footer>;主体 Footer 可用 style.height 覆盖高度;--mt-layout-footer-height 可统一覆盖左右两个底栏高度。Topbar 与品牌行使用 --mt-layout-header-height(默认 48px),窄屏内容换行时可自然增高。
|
|
842
|
+
- 使用 AdminLayout.Sider、AdminLayout.Header、AdminLayout.Content、AdminLayout.Footer 组合,不需要单独安装子组件。支持的属性以 mtone 文档与类型声明为准。
|
|
843
|
+
- AdminLayout.Sider 复用本库 Sidebar 的状态、NavItem 图标窄栏和键盘提示,不重写导航逻辑。Header 推荐复用 Breadcrumb、IconButton 等已有组件。
|
|
842
844
|
- 默认头部 48px,侧栏 240px,窄栏 52px;可通过 width、collapsedWidth 和区域 style 配置。使用有限高度或 fullHeight 后,侧栏内容和 Content 独立滚动,品牌、侧栏底部版本/折叠行与顶部操作保持可见。
|
|
843
845
|
- 响应式收起为图标窄栏,不是弹出式抽屉。breakpoint 按浏览器视口判断,不按示例容器宽度判断;希望自定义手机抽屉时可组合已有 Drawer。
|
|
844
846
|
- 受控状态必须在 onCollapsedChange 中更新,否则切换只发出请求。导航、路由、数据保存、账号菜单与持久化由应用实现。
|
|
@@ -847,14 +849,14 @@ export default function Demo() {
|
|
|
847
849
|
```tsx
|
|
848
850
|
import { useState } from "react";
|
|
849
851
|
import { Box, BookOpen, Home, Settings } from "lucide-react";
|
|
850
|
-
import {
|
|
852
|
+
import { AdminLayout, Breadcrumb, NavItem, IconButton, Card } from "@bixlab/mtone";
|
|
851
853
|
import "@bixlab/mtone/styles.css";
|
|
852
854
|
|
|
853
855
|
export default function Demo() {
|
|
854
856
|
const [collapsed, setCollapsed] = useState(false);
|
|
855
857
|
return (
|
|
856
|
-
<
|
|
857
|
-
<
|
|
858
|
+
<AdminLayout hasSider style={{ height: 480 }}>
|
|
859
|
+
<AdminLayout.Sider
|
|
858
860
|
collapsible
|
|
859
861
|
collapsed={collapsed}
|
|
860
862
|
onCollapsedChange={setCollapsed}
|
|
@@ -868,18 +870,18 @@ export default function Demo() {
|
|
|
868
870
|
>
|
|
869
871
|
<NavItem icon={<Home size={16} />}>首页</NavItem>
|
|
870
872
|
<NavItem icon={<BookOpen size={16} />} active>知识库</NavItem>
|
|
871
|
-
</
|
|
872
|
-
<
|
|
873
|
-
<
|
|
873
|
+
</AdminLayout.Sider>
|
|
874
|
+
<AdminLayout>
|
|
875
|
+
<AdminLayout.Header
|
|
874
876
|
breadcrumb={<Breadcrumb items={[{ label: "知识库" }, { label: "设计规范" }]} />}
|
|
875
877
|
extra={<IconButton aria-label="设置"><Settings size={16} /></IconButton>}
|
|
876
878
|
/>
|
|
877
|
-
<
|
|
879
|
+
<AdminLayout.Content>
|
|
878
880
|
<h1>设计规范</h1>
|
|
879
881
|
<Card>这里是独立滚动的主体内容。</Card>
|
|
880
|
-
</
|
|
881
|
-
</
|
|
882
|
-
</
|
|
882
|
+
</AdminLayout.Content>
|
|
883
|
+
</AdminLayout>
|
|
884
|
+
</AdminLayout>
|
|
883
885
|
);
|
|
884
886
|
}
|
|
885
887
|
```
|
|
@@ -1321,6 +1323,34 @@ export default function Demo() {
|
|
|
1321
1323
|
}
|
|
1322
1324
|
```
|
|
1323
1325
|
|
|
1326
|
+
### TagSelect
|
|
1327
|
+
|
|
1328
|
+
- [TagSelect](https://xingjianxu.github.io/mtone/#/components/TagSelect): 将多选选项平铺为标签,空间不足时可展开。
|
|
1329
|
+
- Import: TagSelect from @bixlab/mtone
|
|
1330
|
+
- options: readonly TagSelectOption[]. 每项包含唯一 value、可渲染 label 和可选 disabled。
|
|
1331
|
+
- value / defaultValue: readonly string[]. 受控值或初始选中值。
|
|
1332
|
+
- onValueChange: (value: string[]) => void. 标签切换时返回选中的值。
|
|
1333
|
+
- disabled: boolean. 禁用整个控件,亦继承 Fieldset 禁用。
|
|
1334
|
+
- selectAll: boolean (default: false). 在第一位显示全选按钮;选择或取消所有可用选项,包括折叠隐藏的选项,保留禁用选项的选中状态。
|
|
1335
|
+
- selectAllLabel: string (default: 全选). 全选按钮文字。
|
|
1336
|
+
- expandable: boolean (default: true). 选项超出一行时折叠;关闭后始终换行展示。
|
|
1337
|
+
- expanded / defaultExpanded: boolean. 受控展开状态或初始展开状态,默认折叠。
|
|
1338
|
+
- onExpandedChange: (expanded: boolean) => void. 请求切换展开状态时触发。
|
|
1339
|
+
- expandLabel / collapseLabel: string. 展开与收起按钮文字,默认「展开」与「收起」。
|
|
1340
|
+
- 建议用 aria-label 或 aria-labelledby 为整组选项命名。折叠不会清除已选值。
|
|
1341
|
+
|
|
1342
|
+
```tsx
|
|
1343
|
+
import { TagSelect } from "@bixlab/mtone";
|
|
1344
|
+
import "@bixlab/mtone/styles.css";
|
|
1345
|
+
|
|
1346
|
+
export default function Demo() {
|
|
1347
|
+
return <TagSelect aria-label="主题" defaultValue={["design"]} options={[
|
|
1348
|
+
{ value: "design", label: "产品设计" },
|
|
1349
|
+
{ value: "research", label: "用户研究" },
|
|
1350
|
+
]} />;
|
|
1351
|
+
}
|
|
1352
|
+
```
|
|
1353
|
+
|
|
1324
1354
|
### MultiSelect
|
|
1325
1355
|
|
|
1326
1356
|
- [MultiSelect](https://xingjianxu.github.io/mtone/#/components/MultiSelect): 支持搜索与移除标签的多选控件。
|
|
@@ -1444,8 +1474,8 @@ export default function Demo() {
|
|
|
1444
1474
|
- [Sidebar](https://xingjianxu.github.io/mtone/#/components/Sidebar): 支持展开与图标窄栏切换的应用侧栏。
|
|
1445
1475
|
- Import: Sidebar, NavItem from @bixlab/mtone
|
|
1446
1476
|
- footer: ReactNode | ((collapsed: boolean) => ReactNode). 可选底部内容。
|
|
1447
|
-
- collapsePlacement: "header" | "footer" (default: header). 折叠按钮位置;
|
|
1448
|
-
- header: ReactNode | ((collapsed: boolean) => ReactNode). 可选品牌头部,与已有折叠按钮同排;
|
|
1477
|
+
- collapsePlacement: "header" | "footer" (default: header). 折叠按钮位置;AdminLayout.Sider 使用 footer,独立 Sidebar 保持原默认。
|
|
1478
|
+
- header: ReactNode | ((collapsed: boolean) => ReactNode). 可选品牌头部,与已有折叠按钮同排;AdminLayout.Sider 的 logo 通过该插槽复用。
|
|
1449
1479
|
- collapsible: boolean (default: false). 启用内置收起/展开按钮;未启用时保持原有容器行为。
|
|
1450
1480
|
- collapsed: boolean. 受控收起状态;搭配 onCollapsedChange 更新。
|
|
1451
1481
|
- defaultCollapsed: boolean (default: false). 非受控模式的初始收起状态。
|
|
@@ -2155,7 +2185,7 @@ export default function Demo() {
|
|
|
2155
2185
|
- 原生属性: HTMLAttributes<HTMLUListElement>. 支持 className、style、aria-label、tabIndex 和 onScroll 等。
|
|
2156
2186
|
- List 的数据渲染仍使用 ul/li;renderItem 仅返回条目内容。ListItem 和 DocumentList 既有用法保持不变。
|
|
2157
2187
|
- 虚拟列表通过估算未挂载行和测量可见行支持不等高内容;跳到尚未测量的位置是估算定位,滚动过程中总高度可能修正。需要精确定位时使用固定高度或关闭虚拟滚动。
|
|
2158
|
-
- List
|
|
2188
|
+
- List 不内置网络请求、分页、选择或排序库。加载与排序由外部受控数据组合;数据模式可在 renderItem 的起始位置放置 List.SortHandle(接受 span 拖放事件);保留上移和下移按钮供键盘操作。
|
|
2159
2189
|
- 自定义内容的按钮、链接与拖放可访问性由调用方负责;可为滚动容器设置 aria-label 和 tabIndex。
|
|
2160
2190
|
|
|
2161
2191
|
```tsx
|
|
@@ -2172,6 +2202,7 @@ export default function Demo() {
|
|
|
2172
2202
|
|
|
2173
2203
|
- [ListItem](https://xingjianxu.github.io/mtone/#/components/ListItem): 包含图标、说明与尾部操作的列表项。
|
|
2174
2204
|
- Import: ListItem, List, Button from @bixlab/mtone
|
|
2205
|
+
- sortHandle: ListSortHandleProps. 可选拖拽手柄,默认在条目起始侧显示六点图标;传入 onDragStart、onDragEnd 等事件,排序由应用维护。
|
|
2175
2206
|
- children: ReactNode. 组件内容。
|
|
2176
2207
|
- icon: ReactNode. 前置图标。
|
|
2177
2208
|
- description: ReactNode. 次级描述。
|
|
@@ -2771,13 +2802,14 @@ export default function Demo() {
|
|
|
2771
2802
|
|
|
2772
2803
|
### MtoneProvider
|
|
2773
2804
|
|
|
2774
|
-
- [MtoneProvider](https://xingjianxu.github.io/mtone/#/components/MtoneProvider):
|
|
2805
|
+
- [MtoneProvider](https://xingjianxu.github.io/mtone/#/components/MtoneProvider): 为组件及其浮层配置颜色模式、语言、密度和主题变量。
|
|
2775
2806
|
- Import: MtoneProvider, Button from @bixlab/mtone
|
|
2776
2807
|
- children: ReactNode. 组件内容。
|
|
2777
2808
|
- locale: "zh" | "en" (default: zh). 内置控件文案语言。
|
|
2778
2809
|
- density: "compact" | "comfortable" (default: compact). 控件密度。
|
|
2810
|
+
- theme: MtoneTheme ("light" | "dark" | "system") (default: 最外层为 light). 浅色、深色或实时跟随设备设置;省略时继承上层主题。
|
|
2779
2811
|
- tokens: Tokens. CSS 自定义属性与 CSSProperties,常用 --mt-fg、--mt-bg、--mt-primary。
|
|
2780
|
-
- 简单组件不使用 Provider
|
|
2812
|
+
- 简单组件不使用 Provider 时也可用默认值,保持浅色。
|
|
2781
2813
|
- 库分发预编译 CSS,不要求宿主安装 Tailwind。浮层继承 Provider 上下文。
|
|
2782
2814
|
- 主题通过 CSS 变量传播,不是 Shadow DOM 隔离;自定义层级请检查 z-index 1200–1300。
|
|
2783
2815
|
|
|
@@ -2787,18 +2819,19 @@ import "@bixlab/mtone/styles.css";
|
|
|
2787
2819
|
|
|
2788
2820
|
export default function Demo() {
|
|
2789
2821
|
return (
|
|
2790
|
-
<MtoneProvider locale="zh" density="comfortable" tokens={{"--mt-primary":"#446c52"}}><Button variant="solid">保存</Button></MtoneProvider>
|
|
2822
|
+
<MtoneProvider locale="zh" density="comfortable" theme="system" tokens={{"--mt-primary":"#446c52"}}><Button variant="solid">保存</Button></MtoneProvider>
|
|
2791
2823
|
);
|
|
2792
2824
|
}
|
|
2793
2825
|
```
|
|
2794
2826
|
|
|
2795
2827
|
### MtoneScope
|
|
2796
2828
|
|
|
2797
|
-
- [MtoneScope](https://xingjianxu.github.io/mtone/#/components/MtoneScope): 把当前 Provider 的主题变量和密度应用到一个 div
|
|
2829
|
+
- [MtoneScope](https://xingjianxu.github.io/mtone/#/components/MtoneScope): 把当前 Provider 的主题变量和密度应用到一个 div,可局部覆盖颜色模式。
|
|
2798
2830
|
- Import: MtoneScope, MtoneProvider, Button from @bixlab/mtone
|
|
2799
2831
|
- children: ReactNode. 组件内容。
|
|
2832
|
+
- theme: MtoneTheme ("light" | "dark" | "system") (default: 继承上层主题). 仅覆盖此作用域及其浮层的颜色模式。
|
|
2800
2833
|
- 原生属性: HTMLAttributes. 支持对应元素的 className、style 与适用的 DOM 属性;以 TypeScript 定义为准。
|
|
2801
|
-
- 通常无需手动使用;库内部用它让 Portal
|
|
2834
|
+
- 通常无需手动使用;库内部用它让 Portal 浮层继承主题。可覆盖颜色模式,仍继承语言、密度和主题变量。
|
|
2802
2835
|
|
|
2803
2836
|
```tsx
|
|
2804
2837
|
import { MtoneScope, MtoneProvider, Button } from "@bixlab/mtone";
|
|
@@ -2806,7 +2839,7 @@ import "@bixlab/mtone/styles.css";
|
|
|
2806
2839
|
|
|
2807
2840
|
export default function Demo() {
|
|
2808
2841
|
return (
|
|
2809
|
-
<MtoneProvider tokens={{"--mt-primary":"#446c52"}}><MtoneScope><Button variant="solid">主题作用域</Button></MtoneScope></MtoneProvider>
|
|
2842
|
+
<MtoneProvider tokens={{"--mt-primary":"#446c52"}}><MtoneScope theme="dark"><Button variant="solid">主题作用域</Button></MtoneScope></MtoneProvider>
|
|
2810
2843
|
);
|
|
2811
2844
|
}
|
|
2812
2845
|
```
|