@manohub/ui 1.0.10 → 1.1.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.
Files changed (51) hide show
  1. package/README.md +3 -3
  2. package/dist/components/button/index.d.ts +74 -20
  3. package/dist/components/button/index.js +59 -14
  4. package/dist/components/button/segmented.d.ts +122 -0
  5. package/dist/components/button/segmented.js +99 -0
  6. package/dist/components/capsule/index.d.ts +2 -2
  7. package/dist/components/filter/index.d.ts +3 -3
  8. package/dist/components/form/index.d.ts +1 -1
  9. package/dist/components/input/index.d.ts +6 -6
  10. package/dist/components/input/number-input.d.ts +1 -1
  11. package/dist/components/list/index.d.ts +19 -0
  12. package/dist/components/list/list-shared.d.ts +196 -0
  13. package/dist/components/list/list-shared.js +143 -0
  14. package/dist/components/list/list.d.ts +221 -0
  15. package/dist/components/list/list.js +131 -0
  16. package/dist/components/{tree/index.d.ts → list/tree.d.ts} +33 -33
  17. package/dist/components/{tree/index.js → list/tree.js} +23 -62
  18. package/dist/components/list-view/index.d.ts +7 -7
  19. package/dist/components/notice/index.d.ts +1 -1
  20. package/dist/components/panel/index.d.ts +39 -84
  21. package/dist/components/panel/index.js +18 -32
  22. package/dist/components/radio/index.d.ts +233 -118
  23. package/dist/components/radio/index.js +146 -150
  24. package/dist/components/select/index.d.ts +1 -1
  25. package/dist/components/select/index.js +6 -3
  26. package/dist/components/select/select-panel.d.ts +20 -0
  27. package/dist/components/select/select-panel.js +8 -1
  28. package/dist/components/select/select-tree-filter.d.ts +9 -9
  29. package/dist/components/select/select-tree.d.ts +23 -23
  30. package/dist/components/select/select-tree.js +16 -3
  31. package/dist/components/select/select-trigger.d.ts +43 -1
  32. package/dist/components/select/select-trigger.js +22 -5
  33. package/dist/components/steps/index.d.ts +4 -4
  34. package/dist/components/table/index.d.ts +4 -4
  35. package/dist/components/table/index.js +1 -1
  36. package/dist/components/tag/index.d.ts +1 -1
  37. package/dist/index.d.ts +3 -4
  38. package/dist/index.js +5 -3
  39. package/dist/styles/components/button.css +107 -33
  40. package/dist/styles/components/{tree.css → list.css} +24 -24
  41. package/dist/styles/components/{tree.tokens.css → list.tokens.css} +5 -5
  42. package/dist/styles/components/pagination.css +3 -3
  43. package/dist/styles/components/panel.css +2 -9
  44. package/dist/styles/components/radio.css +21 -20
  45. package/dist/styles/components/select.css +2 -2
  46. package/dist/styles/components/select.tokens.css +2 -2
  47. package/dist/styles/index.css +2 -3
  48. package/package.json +2 -2
  49. package/dist/components/nav/index.d.ts +0 -299
  50. package/dist/components/nav/index.js +0 -174
  51. package/dist/styles/components/nav.css +0 -48
package/README.md CHANGED
@@ -61,11 +61,11 @@ import { Card, Form, Tree, Checkbox } from '@manohub/ui'
61
61
 
62
62
  | 分组 | 组件 |
63
63
  |---|---|
64
- | 容器与分区 | `Page`(页面级骨架:`.Header` / `.Body` / `.Footer` / `.Filter` / `.Toolbar` / `.Split`)、`Panel`(+ `.Header` / `.Body` / `.Footer`)、`Card`(+ 三件)、`Nav`、`Layout`(`Layout.Row` 排「行」/ `Layout.Column` 排「列」:轴向 × 间距档 × 对齐) |
65
- | 数据展示 | `Tree`、`ListView`(+ `.CardItem`)、`Badge`、`Tag`(`Badge` 的可关闭 / 可新增封装) |
64
+ | 容器与分区 | `Page`(页面级骨架:`.Header` / `.Body` / `.Footer` / `.Filter` / `.Split`)、`Panel`(+ `.Header` / `.Body` / `.Footer`)、`Card`(+ 三件)、`Layout`(`Layout.Row` 排「行」/ `Layout.Column` 排「列」:轴向 × 间距档 × 对齐) |
65
+ | 数据展示 | `Tree`(层级)、`List`(扁平导航;与 `Tree` 同族:同目录 / 同一份面 / 同一份行渲染)、`ListView`(+ `.CardItem`)、`Badge`、`Tag`(`Badge` 的可关闭 / 可新增封装) |
66
66
  | 展示 | `Avatar`(+ `.Group`)、`Skeleton`(行 / 列表 / 块状) |
67
67
  | 表单基础(**自绘**) | `Button`(+ `.Group` / `.Divider`;五型 / 小号 / 加载 / 菜单按钮 / 连体切换)、`Input`(+ `.Group` / `.Chip` / `.Display` / `.Textarea`;清除 / 可见性切换 / 校验)、`Search`(搜索框:值 / 搜索 / 清空三条回调)、`Select`(单选 / 多选 / 搜索 / 加载;面板用原生 popover)、`SelectTree`(树形态:仅叶子可选 + 本地过滤 + 命中高亮;与 `Select` 平级导出、共用触发器与面板)、`Switch`(表格档 / 表单档) |
68
- | 表单与选择 | `Form`(+ `.Header` / `.Item`;标签体系、成员归位、`v-model` 值收集与命令式 `clear()`)、`Filter`(+ `.Item`;`Form` 的壳:条件字段写成子件、控件自放、查询/重置与快照归一)、`Checkbox`、`Radio`(+ `.Group` / `.Card`;卡片式单选)、`Capsule`(胶囊选择器;胶囊 / 方形两档外形,与 `Tabs` 组合即页签) |
68
+ | 表单与选择 | `Form`(+ `.Header` / `.Item`;标签体系、成员归位、`v-model` 值收集与命令式 `clear()`)、`Filter`(+ `.Item`;`Form` 的壳:条件字段写成子件、控件自放、查询/重置与快照归一)、`Checkbox`、`Radio`(+ `.Group`(唯一组壳,`layout="inline" | "card"` 两种形态)/ `.Card`(卡片选项叶))、`Capsule`(胶囊选择器;胶囊 / 方形两档外形,与 `Tabs` 组合即页签) |
69
69
  | 反馈与三态 | `Notice`(条状提示)、`Notification`(通知卡:标题 + 头像 / 标签 / 操作 / 关闭位)、`QueryState`(三态容器;内建空 / 错误插画取自设计交付的四张 SVG,原样内联在 `src/utils/state-illustration.ts`)、`Loading`(转圈 + 遮罩:行内 / 区域 / 全屏三形态) |
70
70
  | 反馈与引导(**自绘**) | `Toast`(消息提示:语义四档 / loading + 可选动作 + 自动消失计时 + `.Stack` 堆叠)、`Steps`(步骤条:节点式 / 燕尾段式 / `.Progress` 进度条) |
71
71
  | 数据展示(**自绘**) | `Table`(列 × 数据 + 选择列 + 排序事件 + 固定表头 / 固定列 + 批量栏 / 合计行;排序与列宽拖拽算法归调用方)、`Pagination`(总数 / 每页条数 / 页码窗口 / 简单档 / 外框档)、`TabBar`(下划线页签 + 「更多」收纳) |
@@ -9,6 +9,10 @@ import type { ControlSize } from '../control-size';
9
9
  * 继续有效)。
10
10
  * `text` 与 `link` 都是无底色档,但**语义不同,别混**:`text` =「行内文本操作」(编辑 / 删除 / 更多 / 展开,无
11
11
  * 下划线);`link` =「跳转语义」(带下划线,像超链接)。「行内可点文字」一律用它 → `text`。
12
+ * `off` 是「**未选半区**」:由单选族的 `Segmented` 渲染(选中段用实心型、未选段用它)。
13
+ * 2026-10-12 起**连体只归 `Segmented`** —— 原先的 `.mh-button__switch` 容器类与 `Button.Group compact`
14
+ * 档位都已撤掉(前者与后者能力重复、且用它是让应用侧手写库类名;后者与「不传 `v-model` 的 `Segmented`」
15
+ * 重复)。连体的**面**仍在:`.mh-button__group--compact`(由 `Segmented` 自己渲染)。
12
16
  *
13
17
  * 用法见 `docs/demos/button/`(每个维度一份可运行样例;文档页 `docs/components/button.md`)。
14
18
  */
@@ -17,10 +21,11 @@ export type ButtonVariant = 'primary' | 'secondary' | 'dashed' | 'danger' | 'tex
17
21
  export type ButtonShape = 'default' | 'round' | 'circle';
18
22
  /** 按钮(**自绘**;按钮族:六型 × 三档尺寸 × 外形 × 危险色 + 加载 / 图标 / 菜单形态 + 组容器)。
19
23
  *
20
- * 词表:`variant` = `primary` / `secondary` / `dashed` / `danger` / `text` / `link` / `icon`;`size`:`sm` 24 /
24
+ * 词表:`variant` = `primary` / `secondary` / `dashed` / `danger` / `text` / `link` / `icon` / `off`;`size`:`sm` 24 /
21
25
  * `md` 32(标准)/ `lg` 40 —— 三档**真实不同高**(与 `--ui-control-height-*` 同值);`shape` / `danger` /
22
26
  * `block` 是正交修饰(可叠加任意型);`loading` 会置 `disabled`(真正吞掉点击的是原生 `disabled`,不只是光标);
23
- * `menu` + `caret` 组合出菜单按钮(文本区 ‖ 分割线 ‖ 箭头区),面板交给操作层组合。
27
+ * `menu` + `caret` 组合出菜单按钮(包一层文字区 + 右侧箭头区;**不画竖分割线** —— 分隔靠白空,
28
+ * 面板交给操作层组合)。
24
29
  *
25
30
  * 图标走 `@manohub/icon`(`icon` prop 传图标名,写错编译期即报错);菜单箭头由
26
31
  * `styles/operations/popup.css` 负责转向,故箭头图标的类名是 `mh-button__caret mh-popup-caret` 两个。
@@ -77,7 +82,7 @@ export declare const Button: import("vue").DefineComponent<import("vue").Extract
77
82
  type: BooleanConstructor;
78
83
  default: boolean;
79
84
  };
80
- /** 菜单按钮结构(文本区 ‖ 分割线 ‖ 箭头区) */
85
+ /** 菜单按钮结构(文字区包一层 + 右侧留出箭头区;分割线已撤,见 `button.css` 的「菜单按钮」节) */
81
86
  menu: {
82
87
  type: BooleanConstructor;
83
88
  default: boolean;
@@ -161,7 +166,7 @@ export declare const Button: import("vue").DefineComponent<import("vue").Extract
161
166
  type: BooleanConstructor;
162
167
  default: boolean;
163
168
  };
164
- /** 菜单按钮结构(文本区 ‖ 分割线 ‖ 箭头区) */
169
+ /** 菜单按钮结构(文字区包一层 + 右侧留出箭头区;分割线已撤,见 `button.css` 的「菜单按钮」节) */
165
170
  menu: {
166
171
  type: BooleanConstructor;
167
172
  default: boolean;
@@ -207,8 +212,8 @@ export declare const Button: import("vue").DefineComponent<import("vue").Extract
207
212
  onClick: (e: MouseEvent) => void;
208
213
  loading: boolean;
209
214
  variant: ButtonVariant;
210
- danger: boolean;
211
215
  shape: ButtonShape;
216
+ danger: boolean;
212
217
  trailingIcon: "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "pause" | "play" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "chevrons-left" | "chevrons-right" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "play-filled" | "pause-filled" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
213
218
  href: string;
214
219
  target: string;
@@ -217,6 +222,54 @@ export declare const Button: import("vue").DefineComponent<import("vue").Extract
217
222
  default?: () => VNodeChild;
218
223
  icon?: () => VNodeChild;
219
224
  }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
225
+ /**
226
+ * 按钮组容器(组内间距恒 8;异类按钮之间可插 `Button.Divider`)。
227
+ *
228
+ * ## 溢出收纳(`maxVisible`)
229
+ *
230
+ * `maxVisible={2}` ⇒ **按顺序只直显前 2 个**,其余收进末尾的「更多 ▾」面板,点开才见:
231
+ *
232
+ * ```vue
233
+ * <Button.Group :max-visible="2">
234
+ * <Button>保存</Button><Button>另存为</Button><Button>取消</Button><Button>删除</Button>
235
+ * </Button.Group>
236
+ * ```
237
+ *
238
+ * 三条口径:
239
+ *
240
+ * 1. **判据只按个数**(`maxVisible`),**不做宽度测量**。旧框架那套响应式工具栏是"按可用宽度算能放几个",
241
+ * 在嵌入场景量到 0 就形成「内容只剩『更多』→ 量出来更窄 → 永远展不开」的死循环;按个数可预测、零测量。
242
+ * 2. **按顺序,超出即收** —— 没有"某某不参与收纳"的标记;要保谁直显就把它**排在前面**。
243
+ * 3. **面板里沿用原按钮样式**(原 `variant` / `danger` 一并保留),只是竖排成一列 ——
244
+ * 这样「保存是主色、删除是危险色」这类语义不会在收进抽屉后丢掉。
245
+ *
246
+ * ## 与 `Segmented` 的分工
247
+ *
248
+ * 本件是**布局**:按 `gap` 排开任意子件(型可不同、可带图标、可插分割线),**不持有状态**。
249
+ * 「连体 + 一排按钮」归单选族的 `Segmented`(它是**值控件**,自己渲染 `mh-button__group--compact`
250
+ * 容器与段)—— 原 `Button.Group compact` 档位与 `Button.CompactGroup` 成员已于 2026-10-12 撤除(与它重复)。
251
+ *
252
+ * 开合 / Esc / 点外部关闭 / 顶层渲染 / 定位与溢出翻面全部归操作层(原生 popover +
253
+ * `styles/operations/popup.css` 的定位档),本件**零定位代码**;箭头转向靠 popup.css 那条
254
+ * `:has(.mh-popup:popover-open)` 规则,故根容器带 `mh-popup-host`(那条规则要求触发器与面板在同一个 host 子树里)。
255
+ */
256
+ export declare const ButtonGroup: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
257
+ /** 溢出收纳:直显前 N 个,其余收进末尾「更多」面板;不给即全部直显 */
258
+ maxVisible: {
259
+ type: NumberConstructor;
260
+ default: undefined;
261
+ };
262
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
263
+ /** 溢出收纳:直显前 N 个,其余收进末尾「更多」面板;不给即全部直显 */
264
+ maxVisible: {
265
+ type: NumberConstructor;
266
+ default: undefined;
267
+ };
268
+ }>> & Readonly<{}>, {
269
+ maxVisible: number;
270
+ }, SlotsType<{
271
+ default?: () => VNodeChild;
272
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
220
273
  export declare const ButtonCompound: {
221
274
  new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("vue").ExtractPropTypes<{
222
275
  /** 按钮型(缺省 `secondary`,与规范「次要为默认」一致) */
@@ -268,7 +321,7 @@ export declare const ButtonCompound: {
268
321
  type: BooleanConstructor;
269
322
  default: boolean;
270
323
  };
271
- /** 菜单按钮结构(文本区 ‖ 分割线 ‖ 箭头区) */
324
+ /** 菜单按钮结构(文字区包一层 + 右侧留出箭头区;分割线已撤,见 `button.css` 的「菜单按钮」节) */
272
325
  menu: {
273
326
  type: BooleanConstructor;
274
327
  default: boolean;
@@ -314,8 +367,8 @@ export declare const ButtonCompound: {
314
367
  onClick: (e: MouseEvent) => void;
315
368
  loading: boolean;
316
369
  variant: ButtonVariant;
317
- danger: boolean;
318
370
  shape: ButtonShape;
371
+ danger: boolean;
319
372
  trailingIcon: "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "pause" | "play" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "chevrons-left" | "chevrons-right" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "play-filled" | "pause-filled" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
320
373
  href: string;
321
374
  target: string;
@@ -380,7 +433,7 @@ export declare const ButtonCompound: {
380
433
  type: BooleanConstructor;
381
434
  default: boolean;
382
435
  };
383
- /** 菜单按钮结构(文本区 ‖ 分割线 ‖ 箭头区) */
436
+ /** 菜单按钮结构(文字区包一层 + 右侧留出箭头区;分割线已撤,见 `button.css` 的「菜单按钮」节) */
384
437
  menu: {
385
438
  type: BooleanConstructor;
386
439
  default: boolean;
@@ -426,8 +479,8 @@ export declare const ButtonCompound: {
426
479
  onClick: (e: MouseEvent) => void;
427
480
  loading: boolean;
428
481
  variant: ButtonVariant;
429
- danger: boolean;
430
482
  shape: ButtonShape;
483
+ danger: boolean;
431
484
  trailingIcon: "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "pause" | "play" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "chevrons-left" | "chevrons-right" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "play-filled" | "pause-filled" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
432
485
  href: string;
433
486
  target: string;
@@ -486,7 +539,7 @@ export declare const ButtonCompound: {
486
539
  type: BooleanConstructor;
487
540
  default: boolean;
488
541
  };
489
- /** 菜单按钮结构(文本区 ‖ 分割线 ‖ 箭头区) */
542
+ /** 菜单按钮结构(文字区包一层 + 右侧留出箭头区;分割线已撤,见 `button.css` 的「菜单按钮」节) */
490
543
  menu: {
491
544
  type: BooleanConstructor;
492
545
  default: boolean;
@@ -532,8 +585,8 @@ export declare const ButtonCompound: {
532
585
  onClick: (e: MouseEvent) => void;
533
586
  loading: boolean;
534
587
  variant: ButtonVariant;
535
- danger: boolean;
536
588
  shape: ButtonShape;
589
+ danger: boolean;
537
590
  trailingIcon: "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "delete" | "image" | "close" | "pause" | "play" | "key" | "application" | "client" | "service" | "schema" | "compose" | "log" | "mcp" | "agent" | "server" | "exposure" | "openapi" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "chevrons-left" | "chevrons-right" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "tool" | "plus" | "notification" | "settings" | "logout" | "home" | "workbench" | "apps" | "favorite" | "page-title" | "favorite-filled" | "drag-handle" | "edit" | "refresh" | "upload" | "save" | "more" | "preview" | "external-link" | "minus" | "plus-circle" | "close-circle" | "info-circle" | "check-circle" | "alert-circle" | "play-filled" | "pause-filled" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "ai" | "shield-check" | "shield-alert" | "history";
538
591
  href: string;
539
592
  target: string;
@@ -543,22 +596,23 @@ export declare const ButtonCompound: {
543
596
  icon?: () => VNodeChild;
544
597
  }>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
545
598
  Group: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
546
- /** 连体档(工具条 / 连体切换:相邻边重合,首末保留圆角) */
547
- compact: {
548
- type: BooleanConstructor;
549
- default: boolean;
599
+ /** 溢出收纳:直显前 N 个,其余收进末尾「更多」面板;不给即全部直显 */
600
+ maxVisible: {
601
+ type: NumberConstructor;
602
+ default: undefined;
550
603
  };
551
604
  }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
552
- /** 连体档(工具条 / 连体切换:相邻边重合,首末保留圆角) */
553
- compact: {
554
- type: BooleanConstructor;
555
- default: boolean;
605
+ /** 溢出收纳:直显前 N 个,其余收进末尾「更多」面板;不给即全部直显 */
606
+ maxVisible: {
607
+ type: NumberConstructor;
608
+ default: undefined;
556
609
  };
557
610
  }>> & Readonly<{}>, {
558
- compact: boolean;
611
+ maxVisible: number;
559
612
  }, SlotsType<{
560
613
  default?: () => VNodeChild;
561
614
  }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
562
615
  Divider: import("vue").DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
563
616
  };
564
617
  export type ButtonCompoundType = typeof ButtonCompound;
618
+ export { Segmented, type SegmentedOption, type SegmentedValue } from './segmented';
@@ -1,5 +1,6 @@
1
- import { defineComponent, computed, createVNode, mergeProps, Fragment } from "vue";
1
+ import { defineComponent, computed, createVNode, mergeProps, Fragment, useId, createTextVNode } from "vue";
2
2
  import { Icon } from "@manohub/icon";
3
+ import { flattenChildren } from "../../utils/vnode-children.js";
3
4
  const Button = /* @__PURE__ */ defineComponent({
4
5
  name: "Button",
5
6
  inheritAttrs: false,
@@ -53,7 +54,7 @@ const Button = /* @__PURE__ */ defineComponent({
53
54
  type: Boolean,
54
55
  default: false
55
56
  },
56
- /** 菜单按钮结构(文本区 ‖ 分割线 ‖ 箭头区) */
57
+ /** 菜单按钮结构(文字区包一层 + 右侧留出箭头区;分割线已撤,见 `button.css` 的「菜单按钮」节) */
57
58
  menu: {
58
59
  type: Boolean,
59
60
  default: false
@@ -106,9 +107,7 @@ const Button = /* @__PURE__ */ defineComponent({
106
107
  }, [slots.default?.()]) : slots.default?.();
107
108
  return createVNode(Fragment, null, [props.loading ? createVNode("span", {
108
109
  "class": "mh-button__spinner"
109
- }, null) : renderIcon(props.icon, "mh-button__icon"), body, props.menu ? createVNode("span", {
110
- "class": "mh-button__divider"
111
- }, null) : null, props.caret ? createVNode(Icon, {
110
+ }, null) : renderIcon(props.icon, "mh-button__icon"), body, props.caret ? createVNode(Icon, {
112
111
  "name": "chevron-down",
113
112
  "class": "mh-button__caret mh-popup-caret"
114
113
  }, null) : null, props.trailingIcon ? createVNode(Icon, {
@@ -153,10 +152,10 @@ const ButtonGroup = /* @__PURE__ */ defineComponent({
153
152
  name: "ButtonGroup",
154
153
  inheritAttrs: false,
155
154
  props: {
156
- /** 连体档(工具条 / 连体切换:相邻边重合,首末保留圆角) */
157
- compact: {
158
- type: Boolean,
159
- default: false
155
+ /** 溢出收纳:直显前 N 个,其余收进末尾「更多」面板;不给即全部直显 */
156
+ maxVisible: {
157
+ type: Number,
158
+ default: void 0
160
159
  }
161
160
  },
162
161
  slots: Object,
@@ -164,10 +163,55 @@ const ButtonGroup = /* @__PURE__ */ defineComponent({
164
163
  slots,
165
164
  attrs
166
165
  }) {
167
- return () => createVNode("span", {
168
- "class": ["mh-button__group", props.compact ? "mh-button__group--compact" : "", attrs.class].filter(Boolean).join(" "),
169
- "style": attrs.style
170
- }, [slots.default?.()]);
166
+ const rawId = useId();
167
+ const panelId = computed(() => `mh-button-group-more-${rawId}`);
168
+ const triggerSize = computed(() => {
169
+ for (const child of flattenChildren(slots.default?.())) {
170
+ const vnode = child;
171
+ if (vnode && typeof vnode === "object" && vnode.type === Button) {
172
+ const size = vnode.props?.size;
173
+ if (typeof size === "string") {
174
+ return size;
175
+ }
176
+ }
177
+ }
178
+ return "md";
179
+ });
180
+ return () => {
181
+ const classes = ["mh-button__group", attrs.class].filter(Boolean).join(" ");
182
+ const limit = props.maxVisible;
183
+ const children = flattenChildren(slots.default?.());
184
+ const collapsing = limit != null && children.length > limit;
185
+ if (!collapsing || limit == null) {
186
+ return createVNode("span", mergeProps(attrs, {
187
+ "class": classes,
188
+ "style": attrs.style
189
+ }), [slots.default?.()]);
190
+ }
191
+ return createVNode("span", mergeProps(attrs, {
192
+ "class": `${classes} mh-popup-host`,
193
+ "style": attrs.style
194
+ }), [children.slice(0, limit), createVNode(Button, {
195
+ "variant": "text",
196
+ "size": triggerSize.value,
197
+ "menu": true,
198
+ "caret": true,
199
+ "popoverTarget": panelId.value
200
+ }, {
201
+ default: () => [createTextVNode("更多")]
202
+ }), createVNode("div", mergeProps({
203
+ "id": panelId.value
204
+ }, {
205
+ popover: "auto"
206
+ }, {
207
+ "class": "mh-popup mh-button__group-menu",
208
+ "data-side": "bottom",
209
+ "data-align": "end",
210
+ "onClick": (event) => {
211
+ event.currentTarget.hidePopover?.();
212
+ }
213
+ }), [children.slice(limit)])]);
214
+ };
171
215
  }
172
216
  });
173
217
  const ButtonDivider = /* @__PURE__ */ defineComponent({
@@ -187,5 +231,6 @@ Object.assign(Button, {
187
231
  Divider: ButtonDivider
188
232
  });
189
233
  export {
190
- Button
234
+ Button,
235
+ ButtonGroup
191
236
  };
@@ -0,0 +1,122 @@
1
+ import { type PropType } from 'vue';
2
+ import type { ControlSize } from '../control-size';
3
+ /** 分段选项:`value` 是受控值,`label` 是段上显示的文字。 */
4
+ export interface SegmentedOption {
5
+ value: string | number;
6
+ label: string;
7
+ /** 单独禁用这一段(组件级 `disabled` 会禁用整组) */
8
+ disabled?: boolean;
9
+ }
10
+ /** 分段值(与选项的 `value` 同型)。 */
11
+ export type SegmentedValue = string | number;
12
+ /**
13
+ * 分段控件(**受控单选组**:在一组互斥项里选一个)。
14
+ *
15
+ * ```vue
16
+ * <Segmented v-model="period" :options="[{ value: 'day', label: '日' }, …]" />
17
+ * ```
18
+ *
19
+ * ## 归属:单选族,不是按钮族
20
+ *
21
+ * 它渲染出来是一排连体按钮、**复用按钮族的面**(`mh-button*`),但语义是「一组互斥项里选一个」⇒ 与
22
+ * `Radio.Group` / `Capsule` 同族,故**平级导出**,**不做 `Button` 的复合成员**
23
+ * (2026-10-12 从 `Button.Segmented` 移出:挂在按钮族下名不副实)。判据见 `components/radio/index.tsx`
24
+ * 文件头那条链:一行文字 → `Radio.Group`;「标题 + 说明」整卡可点 → `Radio.Card`;胶囊轨道 → `Capsule`;
25
+ * **连体按钮 → 本件**。
26
+ *
27
+ * ⚠️ **语义归单选族 ≠ 目录归单选族**:文件住在 `components/button/`(因为它用按钮族的面,见下节那条链),
28
+ * 「归单选族」体现在**桶文件的导出分组注释 + `radio/index.tsx` 的判据链 + 文档页**三处。
29
+ *
30
+ * ## 面:复用按钮族的 `button.css`(**同目录共面**)
31
+ *
32
+ * - 容器 `span.mh-button__group.mh-button__group--compact`(连体:相邻边重合、首末保留圆角);
33
+ * - 每段 `button.mh-button.mh-button--primary|off`(选中填充主色 / 未选白底灰描边)+ 尺寸档。
34
+ * 类名与 `Button` 同口径,故 `__tests__/segmented.spec.ts` 有一条断言锁着「段输出的类与 `Button`
35
+ * 一致」(本件自己拼类名,两处漂了不会有任何报错)。
36
+ * - **为什么不另开目录 / 不另建面文件**:本库的链是「**类名同根 ↔ 面文件 ↔ 组件目录**」——
37
+ * `contract-class-surface.spec.ts` 两条硬契约同时管着它(① 每个组件目录都要有同名面文件;
38
+ * ② 面里定义的类必须与面文件名同根)。本件用的是 `mh-button*` ⇒ 面只能是 `button.css`(按钮族)⇒
39
+ * 目录只能是 `button/`。这正是 `list/{list,tree}.tsx`、`input/{index,textarea}`、`select/*` 的分法:
40
+ * **同族两件住同一目录、共享一份面、并排平级导出**(见 `button/index.tsx` 那条再导出)。
41
+ * - 「连体组」那一段面(几何 + 那 1px 共享边的三条口径)在 `button.css` 里成段放着,
42
+ * 改前先读那里的注释。
43
+ * - **不传 `v-model`(或值为 `undefined`)= 都没选中**:每段落到 `off` 型,即连体的一排未选按钮。
44
+ * - 尺寸档 `sm / md / lg` 只落到段的类上(`md` 不加修饰类,与 `Button` 同口径)。
45
+ *
46
+ * ## 与 `Button.Group` 的分工(连体只归本件)
47
+ *
48
+ * | 件 | 本质 | 状态 | 排布 |
49
+ * | --- | --- | --- | --- |
50
+ * | `Button.Group` | **布局**:按 `gap` 排开任意子件(型可不同、可带图标、可插 `Divider`),可配溢出收纳 | 无 | 有间距 |
51
+ * | `Segmented` | **值控件 / 连体容器**:在几项里选一个(也可以一个都不选) | 受控 `modelValue` | **连体** |
52
+ *
53
+ * 2026-10-12 起**连体一律归本件**:`Button.Group compact` 档位与 `Button.CompactGroup` 成员都已撤除
54
+ * (「不传 `v-model` 的本件」覆盖了那个形态)。本件自己渲染 `.mh-button__group--compact` ——
55
+ * 该组类仍留在面上,只是不再由 `Button.Group` 经 prop 触发。
56
+ * ⚠️ 需要「连体 **且** 各段型不同 / 带图标」时本件表达不了(`options` 只有 `value` / `label` / `disabled`)。
57
+ *
58
+ * ## 为什么自己渲染、不复用 `Button`
59
+ *
60
+ * 段不是「外部传进来的任意按钮」,而是控件自己的成员(带 `role="radio"` 语义);自己拼类名还避开一个结构
61
+ * 问题 —— 若反向去取 `Button`,两层就互相引用(能否成立取决于打包后的求值顺序,很脆)。
62
+ *
63
+ * ## 键盘与无障碍(ARIA 单选组模式)
64
+ *
65
+ * - 容器 `role="radiogroup"`,每段 `role="radio"` + `aria-checked`;
66
+ * - **roving tabindex**:组内只有选中段可 `Tab` 进入(一个都没选中时首颗可激活段当入口),
67
+ * 其余段 `tabindex="-1"` —— 整组在页面 Tab 序里只占**一格**;
68
+ * - 方向键(左右 / 上下同效)在**可激活段**之间循环(跳过禁用段),`Home` / `End` 到首末;
69
+ * 移动即选中(与原生 radio 一致)。
70
+ *
71
+ * 状态由消费方持有(`v-model`),本件不内部留存 —— 与库里其他受控件同口径。
72
+ */
73
+ export declare const Segmented: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
74
+ /** 受控值(`v-model`);不传 / `undefined` = 都没选中(每段 `off` 型,即连体的一排未选按钮) */
75
+ modelValue: {
76
+ type: PropType<SegmentedValue>;
77
+ default: undefined;
78
+ };
79
+ /** 选项(顺序即显示顺序) */
80
+ options: {
81
+ type: PropType<SegmentedOption[]>;
82
+ required: true;
83
+ };
84
+ /** 尺寸档(24 / 32 / 40) */
85
+ size: {
86
+ type: PropType<ControlSize>;
87
+ default: string;
88
+ };
89
+ /** 禁用整组 */
90
+ disabled: {
91
+ type: BooleanConstructor;
92
+ default: boolean;
93
+ };
94
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
95
+ /** 受控值(`v-model`);不传 / `undefined` = 都没选中(每段 `off` 型,即连体的一排未选按钮) */
96
+ modelValue: {
97
+ type: PropType<SegmentedValue>;
98
+ default: undefined;
99
+ };
100
+ /** 选项(顺序即显示顺序) */
101
+ options: {
102
+ type: PropType<SegmentedOption[]>;
103
+ required: true;
104
+ };
105
+ /** 尺寸档(24 / 32 / 40) */
106
+ size: {
107
+ type: PropType<ControlSize>;
108
+ default: string;
109
+ };
110
+ /** 禁用整组 */
111
+ disabled: {
112
+ type: BooleanConstructor;
113
+ default: boolean;
114
+ };
115
+ }>> & Readonly<{
116
+ onChange?: ((...args: any[]) => any) | undefined;
117
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
118
+ }>, {
119
+ size: ControlSize;
120
+ disabled: boolean;
121
+ modelValue: SegmentedValue;
122
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,99 @@
1
+ import { defineComponent, computed, createVNode, mergeProps } from "vue";
2
+ const Segmented = /* @__PURE__ */ defineComponent({
3
+ name: "Segmented",
4
+ inheritAttrs: false,
5
+ props: {
6
+ /** 受控值(`v-model`);不传 / `undefined` = 都没选中(每段 `off` 型,即连体的一排未选按钮) */
7
+ modelValue: {
8
+ type: [String, Number],
9
+ default: void 0
10
+ },
11
+ /** 选项(顺序即显示顺序) */
12
+ options: {
13
+ type: Array,
14
+ required: true
15
+ },
16
+ /** 尺寸档(24 / 32 / 40) */
17
+ size: {
18
+ type: String,
19
+ default: "md"
20
+ },
21
+ /** 禁用整组 */
22
+ disabled: {
23
+ type: Boolean,
24
+ default: false
25
+ }
26
+ },
27
+ emits: ["update:modelValue", "change"],
28
+ setup(props, {
29
+ emit,
30
+ attrs
31
+ }) {
32
+ const selectedIndex = computed(() => props.options.findIndex((option) => option.value === props.modelValue));
33
+ const stops = computed(() => props.options.reduce((acc, option, index) => {
34
+ if (!props.disabled && !option.disabled) {
35
+ acc.push(index);
36
+ }
37
+ return acc;
38
+ }, []));
39
+ function select(index) {
40
+ const option = props.options[index];
41
+ if (!option || props.disabled || option.disabled) {
42
+ return;
43
+ }
44
+ if (option.value !== props.modelValue) {
45
+ emit("update:modelValue", option.value);
46
+ emit("change", option.value);
47
+ }
48
+ }
49
+ function onKeydown(event, index) {
50
+ const list = stops.value;
51
+ if (!list.length) {
52
+ return;
53
+ }
54
+ const at = list.indexOf(index);
55
+ const from = at >= 0 ? at : 0;
56
+ let next;
57
+ if (event.key === "ArrowRight" || event.key === "ArrowDown") {
58
+ next = list[(from + 1) % list.length];
59
+ } else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
60
+ next = list[(from - 1 + list.length) % list.length];
61
+ } else if (event.key === "Home") {
62
+ next = list[0];
63
+ } else if (event.key === "End") {
64
+ next = list[list.length - 1];
65
+ } else {
66
+ return;
67
+ }
68
+ event.preventDefault();
69
+ select(next);
70
+ const siblings = event.currentTarget.parentElement?.children;
71
+ siblings?.item(next)?.focus();
72
+ }
73
+ function segmentClass(selected) {
74
+ return ["mh-button", `mh-button--${selected ? "primary" : "off"}`, props.size === "md" ? "" : `mh-button--${props.size}`].filter(Boolean).join(" ");
75
+ }
76
+ return () => createVNode("span", mergeProps(attrs, {
77
+ "class": ["mh-button__group", "mh-button__group--compact", attrs.class].filter(Boolean).join(" "),
78
+ "role": "radiogroup",
79
+ "aria-disabled": props.disabled ? "true" : void 0
80
+ }), [props.options.map((option, index) => {
81
+ const selected = option.value === props.modelValue;
82
+ const tabbable = !props.disabled && (selected || selectedIndex.value < 0 && stops.value[0] === index);
83
+ return createVNode("button", {
84
+ "key": option.value,
85
+ "type": "button",
86
+ "class": segmentClass(selected),
87
+ "disabled": props.disabled || option.disabled,
88
+ "role": "radio",
89
+ "aria-checked": selected ? "true" : "false",
90
+ "tabindex": tabbable ? 0 : -1,
91
+ "onClick": () => select(index),
92
+ "onKeydown": (event) => onKeydown(event, index)
93
+ }, [option.label]);
94
+ })]);
95
+ }
96
+ });
97
+ export {
98
+ Segmented
99
+ };
@@ -33,7 +33,7 @@ export type CapsuleShape = 'pill' | 'square';
33
33
  * ## 必须有值
34
34
  *
35
35
  * 单选语义就是必选其一:受控传 `modelValue`、非受控由 `defaultValue` 起,**两者都没给时缺省选中第一个可选项**
36
- * (跳过禁用项;没有可选项才是空值)—— 与 `Radio.Group` / `Radio.Card` / `Tabs` 同一条口径。
36
+ * (跳过禁用项;没有可选项才是空值)—— 与 `Radio.Group` / `Tabs` 同一条口径。
37
37
  *
38
38
  * 用法见 `docs/demos/capsule/`(每个维度一份可运行样例;文档页 `docs/components/capsule.md`)。
39
39
  */
@@ -139,9 +139,9 @@ export declare const Capsule: import("vue").DefineComponent<import("vue").Extrac
139
139
  disabled: boolean;
140
140
  name: string;
141
141
  onChange: (value: string | number) => void;
142
- shape: CapsuleShape;
143
142
  options: CapsuleOption[];
144
143
  defaultValue: string | number | undefined;
144
+ shape: CapsuleShape;
145
145
  modelValue: string | number | undefined;
146
146
  }, SlotsType<{
147
147
  default?: (context: {
@@ -203,8 +203,8 @@ export declare const Filter: {
203
203
  onChange: (values: FilterValues) => void;
204
204
  onReset: (values: FilterValues) => void;
205
205
  defaultValue: FilterValues;
206
- modelValue: FilterValues;
207
206
  description: string;
207
+ modelValue: FilterValues;
208
208
  trigger: FilterTrigger;
209
209
  labelWidth: number;
210
210
  queryText: string;
@@ -282,8 +282,8 @@ export declare const Filter: {
282
282
  onChange: (values: FilterValues) => void;
283
283
  onReset: (values: FilterValues) => void;
284
284
  defaultValue: FilterValues;
285
- modelValue: FilterValues;
286
285
  description: string;
286
+ modelValue: FilterValues;
287
287
  trigger: FilterTrigger;
288
288
  labelWidth: number;
289
289
  queryText: string;
@@ -358,8 +358,8 @@ export declare const Filter: {
358
358
  onChange: (values: FilterValues) => void;
359
359
  onReset: (values: FilterValues) => void;
360
360
  defaultValue: FilterValues;
361
- modelValue: FilterValues;
362
361
  description: string;
362
+ modelValue: FilterValues;
363
363
  trigger: FilterTrigger;
364
364
  labelWidth: number;
365
365
  queryText: string;
@@ -293,7 +293,7 @@ export declare const FormItem: import("vue").DefineComponent<import("vue").Extra
293
293
  default?: (scope: FormItemSlotScope) => VNodeChild;
294
294
  }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
295
295
  export interface FormHeaderProps {
296
- /** 表单头标题。不传则该行不渲染标题文本 —— 但给了 `extra` 时这一行**照渲染**(右端操作位不能凭空消失,与 `Panel`「只给 toolbar / actions、不给 title」同口径)。 */
296
+ /** 表单头标题。不传则该行不渲染标题文本 —— 但给了 `extra` 时这一行**照渲染**(右端操作位不能凭空消失,与 `Panel`「只给 `extra`、不给 `title`」同口径)。 */
297
297
  title?: string;
298
298
  /** 标题下的说明小字(一行话,讲清这块表单是做什么的) */
299
299
  description?: string;