@manohub/ui 1.1.5 → 1.2.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.
Files changed (41) hide show
  1. package/README.md +10 -0
  2. package/dist/components/button/index.d.ts +12 -12
  3. package/dist/components/capsule/index.d.ts +1 -1
  4. package/dist/components/code-block/index.d.ts +5 -5
  5. package/dist/components/date-picker/date-panel.d.ts +1 -1
  6. package/dist/components/date-picker/index.d.ts +6 -6
  7. package/dist/components/dialog/index.d.ts +2 -12
  8. package/dist/components/dialog/index.js +8 -7
  9. package/dist/components/drawer/index.js +7 -1
  10. package/dist/components/filter/index.d.ts +2 -2
  11. package/dist/components/form/index.d.ts +4 -4
  12. package/dist/components/input/index.d.ts +10 -10
  13. package/dist/components/input/number-input.d.ts +2 -2
  14. package/dist/components/list/list.d.ts +1 -1
  15. package/dist/components/list/tree.d.ts +1 -1
  16. package/dist/components/list-view/index.d.ts +2 -2
  17. package/dist/components/notice/index.d.ts +2 -2
  18. package/dist/components/notification/index.d.ts +1 -1
  19. package/dist/components/page/index.d.ts +10 -5
  20. package/dist/components/page/index.js +20 -5
  21. package/dist/components/panel/index.d.ts +2 -2
  22. package/dist/components/panel/index.js +10 -3
  23. package/dist/components/part-padding.d.ts +9 -3
  24. package/dist/components/part-padding.js +12 -6
  25. package/dist/components/query-state/index.d.ts +1 -3
  26. package/dist/components/radio/index.d.ts +7 -7
  27. package/dist/components/scrollbar/index.d.ts +50 -0
  28. package/dist/components/scrollbar/index.js +187 -0
  29. package/dist/components/select/select-list.d.ts +1 -3
  30. package/dist/components/tabbar/index.d.ts +1 -1
  31. package/dist/components/table/index.js +10 -3
  32. package/dist/components/tabs/index.d.ts +3 -3
  33. package/dist/components/toast/index.d.ts +4 -4
  34. package/dist/styles/components/dialog.css +21 -6
  35. package/dist/styles/components/drawer.css +18 -5
  36. package/dist/styles/components/page.css +47 -33
  37. package/dist/styles/components/panel.css +17 -0
  38. package/dist/styles/components/scrollbar.css +63 -0
  39. package/dist/styles/components/table.css +33 -4
  40. package/dist/styles/index.css +1 -0
  41. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { type PropType, type SlotsType, type VNode, type VNodeChild } from 'vue';
1
+ import { type PropType, type SlotsType, type VNodeChild } from 'vue';
2
2
  import { type Padding } from '../part-padding';
3
3
  /**
4
4
  * 页面骨架复合件 —— 页面结构与滚动归属的统一契约。
@@ -48,7 +48,14 @@ export interface PageHeaderProps {
48
48
  export interface PageBodyProps {
49
49
  /** scroll=自身滚(长内容页);plain=不滚(默认,滚动归区域内容区 / 内容件自持的定高容器) */
50
50
  mode?: 'scroll' | 'plain';
51
- /** 内容区内距(px 数字 = 四边同值;`{ y, x }` 分别给)。缺省不落行内样式,沿用 CSS 默认(`0 20px`)—— 行内只覆盖**给到的轴**,故传 `{ y: 16 }` 时左右仍是 20px(与页头左对齐不破)。典型用法:表格 / 卡片不贴页头下边线 → `padding={{ y: 16 }}`。 */
51
+ /**
52
+ * 内容区内距(px 数字 = 四边同值;`{ y, x }` 分别给,每侧可给字符串引令牌;或整串 CSS 简写)。
53
+ * 行内只覆盖**给到的轴 / 边**。**缺省值随 `mode` 不同**(都在面里):
54
+ * - `scroll`:`0 var(--ui-gutter-x)`,落在内层滚动盒上(内距属于滚动容器的可视范围,
55
+ * 浮层拇指画在外面那层,故仍在页缘);
56
+ * - `plain`:`0`,落在主体区自己身上 —— 这一档没有滚动盒,主体区是区域容器的**祖先**,
57
+ * 横向内距会把内层整块推进来、区域滚动条随之内缩(贴不住页缘)。留白交给区域容器。
58
+ */
52
59
  padding?: PagePadding;
53
60
  }
54
61
  export interface PageSplitSidebarProps {
@@ -131,9 +138,7 @@ export declare const Page: {
131
138
  type: PropType<PagePadding>;
132
139
  default: undefined;
133
140
  };
134
- }>, () => string | number | boolean | VNode<import("vue").RendererNode, import("vue").RendererElement, {
135
- [key: string]: any;
136
- }> | import("vue").VNodeArrayChildren | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
141
+ }>, () => string | number | boolean | import("vue").VNodeArrayChildren | import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
137
142
  title: {
138
143
  type: StringConstructor;
139
144
  default: undefined;
@@ -1,6 +1,7 @@
1
1
  import { defineComponent, Comment, Text, h, createVNode, onBeforeUnmount, ref, watch, computed } from "vue";
2
2
  import { Icon } from "@manohub/icon";
3
3
  import { mergePartStyle, partPaddingStyle } from "../part-padding.js";
4
+ import { useOverlayScrollbar } from "../scrollbar/index.js";
4
5
  import { measureSidebarWidth, clampSplitWidth, projectSplitWidth } from "./split-resize.js";
5
6
  const DefaultHeaderIcon = () => createVNode(Icon, {
6
7
  "name": "page-title",
@@ -116,10 +117,24 @@ const PageBody = /* @__PURE__ */ defineComponent({
116
117
  slots,
117
118
  attrs
118
119
  }) {
119
- return () => createVNode("div", {
120
- "class": ["mh-page__body", `mh-page__body--${props.mode}`],
121
- "style": mergePartStyle(attrs.style, props.padding)
122
- }, [slots.default?.()]);
120
+ const scrollRef = ref(null);
121
+ const scrollbar = useOverlayScrollbar(scrollRef);
122
+ return () => {
123
+ if (props.mode === "scroll") {
124
+ return createVNode("div", {
125
+ "class": ["mh-page__body", "mh-page__body--scroll"],
126
+ "style": attrs.style
127
+ }, [createVNode("div", {
128
+ "class": "mh-page__scroll",
129
+ "ref": scrollRef,
130
+ "style": partPaddingStyle(props.padding)
131
+ }, [slots.default?.()]), scrollbar.render()]);
132
+ }
133
+ return createVNode("div", {
134
+ "class": ["mh-page__body", "mh-page__body--plain"],
135
+ "style": mergePartStyle(attrs.style, props.padding)
136
+ }, [slots.default?.()]);
137
+ };
123
138
  }
124
139
  });
125
140
  const PageFooter = /* @__PURE__ */ defineComponent({
@@ -283,7 +298,7 @@ const PageSplit = /* @__PURE__ */ defineComponent({
283
298
  return isRight ? [handle, aside] : [aside, handle];
284
299
  };
285
300
  return () => {
286
- const rootClass = ["mh-page__split", props.rightSidebar ? "mh-page__split--has-right" : "", props.sidebar && left.collapsed.value ? "mh-page__split--left-collapsed" : "", props.rightSidebar && right.collapsed.value ? "mh-page__split--right-collapsed" : "", left.dragging.value || right.dragging.value ? "mh-page__split--resizing" : ""].filter(Boolean).join(" ");
301
+ const rootClass = ["mh-page__split", props.sidebar && left.collapsed.value ? "mh-page__split--left-collapsed" : "", props.rightSidebar && right.collapsed.value ? "mh-page__split--right-collapsed" : "", left.dragging.value || right.dragging.value ? "mh-page__split--resizing" : ""].filter(Boolean).join(" ");
287
302
  return createVNode("div", {
288
303
  "class": rootClass
289
304
  }, [props.sidebar && left.enabled() ? renderRail("left", left) : null, renderSide("left", left), createVNode("div", {
@@ -84,7 +84,7 @@ export declare const PanelHeader: import("vue").DefineComponent<import("vue").Ex
84
84
  type: PropType<PanelPadding>;
85
85
  default: undefined;
86
86
  };
87
- }>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
87
+ }>, () => string | number | boolean | void | import("vue").VNodeArrayChildren | import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
88
88
  /** 面板标题;缺省时**不渲染标题节点**,但仍会渲染 `extra` 那一行(无标题的区域头,见组件头注释);要给完全自定义的头走 `header` 插槽。 */
89
89
  title: {
90
90
  type: StringConstructor;
@@ -255,7 +255,7 @@ export declare const Panel: {
255
255
  type: PropType<PanelPadding>;
256
256
  default: undefined;
257
257
  };
258
- }>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
258
+ }>, () => string | number | boolean | void | import("vue").VNodeArrayChildren | import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
259
259
  /** 面板标题;缺省时**不渲染标题节点**,但仍会渲染 `extra` 那一行(无标题的区域头,见组件头注释);要给完全自定义的头走 `header` 插槽。 */
260
260
  title: {
261
261
  type: StringConstructor;
@@ -1,5 +1,6 @@
1
- import { defineComponent, h, createVNode } from "vue";
1
+ import { defineComponent, h, createVNode, ref } from "vue";
2
2
  import { mergePartStyle, partPaddingStyle } from "../part-padding.js";
3
+ import { useOverlayScrollbar } from "../scrollbar/index.js";
3
4
  const PanelHeader = /* @__PURE__ */ defineComponent({
4
5
  name: "PanelHeader",
5
6
  inheritAttrs: false,
@@ -66,10 +67,16 @@ const PanelBody = /* @__PURE__ */ defineComponent({
66
67
  slots,
67
68
  attrs
68
69
  }) {
70
+ const scrollRef = ref(null);
71
+ const scrollbar = useOverlayScrollbar(scrollRef);
69
72
  return () => createVNode("div", {
70
73
  "class": ["mh-panel__body", attrs.class].filter(Boolean).join(" "),
71
- "style": mergePartStyle(attrs.style, props.padding)
72
- }, [slots.default?.()]);
74
+ "style": attrs.style
75
+ }, [createVNode("div", {
76
+ "class": "mh-panel__scroll",
77
+ "ref": scrollRef,
78
+ "style": partPaddingStyle(props.padding)
79
+ }, [slots.default?.()]), scrollbar.render()]);
73
80
  }
74
81
  });
75
82
  const PanelFooter = /* @__PURE__ */ defineComponent({
@@ -1,17 +1,23 @@
1
1
  import type { StyleValue } from 'vue';
2
+ /**
3
+ * 单边的长度:`number` = px 设计基准(不跟根字号);`string` = **原样下发**,给「引令牌」用
4
+ * (如 `'var(--ui-gutter-x)'`)—— 有了它,消费方引用全局留白不必退回整串 CSS 简写。
5
+ */
6
+ export type PaddingLength = number | string;
2
7
  /**
3
8
  * 骨架件的**内距**口径(`Card` / `Form` / `Page` / `Panel` / `Layout` 共用同一套)。
4
9
  *
5
10
  * - `number` → 四边同值(`padding={16}`);
6
11
  * - `{ y, x }` → 上下 / 左右分别给(`{ y: 12, x: 20 }`,弹窗里的容器常用 —— 与 `Page` 的页面左右内距同档),
7
12
  * **缺哪边就不落哪边的声明**(只给 `y` 时不覆盖消费方在 `style` 里写的左右内距);
8
- * - `string` → **原样下发**(CSS 简写,可非对称)—— **逃生舱**,优先级最低:写它等于自己写 CSS,能不用就不用。
13
+ * 每一侧都可给字符串(引令牌),数字仍补 `px`;给空串 = 该侧不落声明;
14
+ * - `string` → **整串原样下发**(CSS 简写,可非对称)—— 用于「左右不同值」这种 `{ x }` 表达不了的情形。
9
15
  *
10
16
  * 常规用 `number` / `{ y, x }`:几何值在本仓是**设计基准**,不跟根字号(与 `Form.labelWidth` / `表格.rowHeight` 同口径)。
11
17
  */
12
18
  export type Padding = number | {
13
- y?: number;
14
- x?: number;
19
+ y?: PaddingLength;
20
+ x?: PaddingLength;
15
21
  } | string;
16
22
  /** 内距 → 行内样式。缺省(`undefined` / 空串)时返回 `undefined`:**不额外产生 style 属性**,DOM 与「没有这个维度」时一致。 */
17
23
  export declare function partPaddingStyle(padding: Padding | undefined): StyleValue | undefined;
@@ -1,15 +1,21 @@
1
+ function lengthOf(value) {
2
+ if (typeof value === "number") return `${value}px`;
3
+ return value === "" ? void 0 : value;
4
+ }
1
5
  function partPaddingStyle(padding) {
2
6
  if (padding === void 0 || padding === "") return void 0;
3
7
  if (typeof padding === "number") return { padding: `${padding}px` };
4
8
  if (typeof padding === "string") return { padding };
5
9
  const style = {};
6
- if (padding.y !== void 0) {
7
- style.paddingTop = `${padding.y}px`;
8
- style.paddingBottom = `${padding.y}px`;
10
+ const y = padding.y === void 0 ? void 0 : lengthOf(padding.y);
11
+ const x = padding.x === void 0 ? void 0 : lengthOf(padding.x);
12
+ if (y !== void 0) {
13
+ style.paddingTop = y;
14
+ style.paddingBottom = y;
9
15
  }
10
- if (padding.x !== void 0) {
11
- style.paddingLeft = `${padding.x}px`;
12
- style.paddingRight = `${padding.x}px`;
16
+ if (x !== void 0) {
17
+ style.paddingLeft = x;
18
+ style.paddingRight = x;
13
19
  }
14
20
  return style;
15
21
  }
@@ -109,9 +109,7 @@ export declare const QueryState: import("vue").DefineComponent<import("vue").Ext
109
109
  type: NumberConstructor;
110
110
  default: number;
111
111
  };
112
- }>, () => string | number | boolean | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
113
- [key: string]: any;
114
- }> | import("vue").VNodeArrayChildren | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
112
+ }>, () => string | number | boolean | import("vue").VNodeArrayChildren | import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
115
113
  loading: {
116
114
  type: BooleanConstructor;
117
115
  default: boolean;
@@ -128,9 +128,9 @@ export declare const Radio: import("vue").DefineComponent<import("vue").ExtractP
128
128
  }>> & Readonly<{}>, {
129
129
  size: ControlSize;
130
130
  disabled: boolean;
131
- name: string;
132
131
  label: string;
133
132
  onChange: (value: string | number) => void;
133
+ name: string;
134
134
  checked: boolean | undefined;
135
135
  autofocus: boolean;
136
136
  }, SlotsType<{
@@ -223,9 +223,9 @@ export declare const RadioCard: import("vue").DefineComponent<import("vue").Extr
223
223
  };
224
224
  }>> & Readonly<{}>, {
225
225
  disabled: boolean;
226
- name: string;
227
226
  label: string;
228
227
  onChange: (value: string | number) => void;
228
+ name: string;
229
229
  checked: boolean | undefined;
230
230
  description: string;
231
231
  }, SlotsType<{
@@ -303,9 +303,9 @@ export declare const RadioCompound: {
303
303
  }>> & Readonly<{}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {
304
304
  size: ControlSize;
305
305
  disabled: boolean;
306
- name: string;
307
306
  label: string;
308
307
  onChange: (value: string | number) => void;
308
+ name: string;
309
309
  checked: boolean | undefined;
310
310
  autofocus: boolean;
311
311
  }, true, {}, SlotsType<{
@@ -354,9 +354,9 @@ export declare const RadioCompound: {
354
354
  }>> & Readonly<{}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, {
355
355
  size: ControlSize;
356
356
  disabled: boolean;
357
- name: string;
358
357
  label: string;
359
358
  onChange: (value: string | number) => void;
359
+ name: string;
360
360
  checked: boolean | undefined;
361
361
  autofocus: boolean;
362
362
  }>;
@@ -400,9 +400,9 @@ export declare const RadioCompound: {
400
400
  }>> & Readonly<{}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
401
401
  size: ControlSize;
402
402
  disabled: boolean;
403
- name: string;
404
403
  label: string;
405
404
  onChange: (value: string | number) => void;
405
+ name: string;
406
406
  checked: boolean | undefined;
407
407
  autofocus: boolean;
408
408
  }, {}, string, SlotsType<{
@@ -468,9 +468,9 @@ export declare const RadioCompound: {
468
468
  };
469
469
  }>> & Readonly<{}>, {
470
470
  disabled: boolean;
471
- name: string;
472
471
  label: string;
473
472
  onChange: (value: string | number) => void;
473
+ name: string;
474
474
  checked: boolean | undefined;
475
475
  description: string;
476
476
  }, SlotsType<{
@@ -568,8 +568,8 @@ export declare const RadioCompound: {
568
568
  size: ControlSize;
569
569
  vertical: boolean;
570
570
  disabled: boolean;
571
- name: string;
572
571
  onChange: (value: string | number) => void;
572
+ name: string;
573
573
  options: RadioGroupOption[];
574
574
  defaultValue: string | number | undefined;
575
575
  columns: number;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Scrollbar —— **浮层滚动条(跨件原语)**。
3
+ *
4
+ * 它不是一个可见的组件,而是一条「谁在滚,就把拇指画给它」的实现:原生滚动条两轴归零
5
+ * (消费方的滚动盒自己写 `scrollbar-width: none` + `::-webkit-scrollbar { width/height: 0 }`),
6
+ * 拇指由本件画在**滚动盒的兄弟节点**上(定位父里),于是滚动条既不占宽度、也不会随内容滚走。
7
+ *
8
+ * 为什么值得单独成件(出处:Table 满高档 2026-10-19):`scrollbar-gutter: stable` 给它服务的任何滚动容器
9
+ * **永久**预留一条槽,而槽里没人上色 ⇒ 表头底 / 行线 / 斑马底全在槽左缘截断,露一条贯穿到底的白缝;
10
+ * 换成「不预留」又会让滚动条一出没就整块缩 6px。把原生条归零是唯一同时解决两者的做法,
11
+ * 代价就是「拇指得自己画」—— 那条代价只该付一次。
12
+ *
13
+ * 结构(消费方要照抄的三件事):
14
+ *
15
+ * ```html
16
+ * <div class="定位父(position: relative)">
17
+ * <div class="滚动盒(overflow: auto + 原生条归零)">…内容…</div>
18
+ * <div class="mh-scrollbar">…两根拇指…</div> <!-- 本件 render() 的输出 -->
19
+ * </div>
20
+ * ```
21
+ *
22
+ * 判定与取舍(全部有出处,改之前先读):
23
+ * 1. **拇指 6px、离框 2px、最短 24px** —— 6px 与 `kit/index.css` 的滚动条皮肤同值(那里同样登记了
24
+ * 「等设计给值再开槽位」),故**不新开 `--ui-scrollbar-*` 令牌**;2px 与 24px 属「没人会去改的值」。
25
+ * 2. **一轴不可滚就 `hidden`** —— 否则会挂一根贴满全长的假拇指;两轴同一条判据(`scrollHeight/clientHeight`
26
+ * 与 `scrollWidth/clientWidth` 对称)。
27
+ * 3. **轨道不吃指针** —— 只有拇指响应指针(`pointer-events` 在面上分层),**轨道点击翻页明确不做**:
28
+ * 那一 6px 带点击直接落到内容上。翻页走滚轮 / 触控板 / 键盘 / 拖拇指。
29
+ * 4. **显隐走命令式类**(`is-visible` / `is-dragging`),不走响应式:滚动一次不该重渲染整棵子树。
30
+ * 它能活过重渲染的前提是「这两个类在 vnode 里是静态串、patch 不写 `className`」—— 谁把
31
+ * `.mh-scrollbar` 的类改成动态拼接,这两个状态就必须改回 `ref`。
32
+ * 5. **拖动映射与原生拇指同口径**:`scrollTop += dy × 可滚距离 / 拇指可走距离`;监听挂 `window`
33
+ * (同 `Page` 的分栏手柄),拖出容器也不丢。
34
+ * 6. **不做 RTL**:`right` / `left` 写死,RTL 语言下需要另开一档(当前无需求)。
35
+ *
36
+ * 消费方(现:`Table` 满高档、`Panel.Body`):`useOverlayScrollbar(滚动盒 ref)` + `{overlay.render()}`。
37
+ * 滚动监听、`ResizeObserver`、卸载清理都在本件里,消费方不必再写一遍。
38
+ */
39
+ import { type Ref, type VNode } from 'vue';
40
+ export interface OverlayScrollbar {
41
+ /** 渲染浮层(两根拇指)。挂在滚动盒**后面**、定位父里面 */
42
+ render: () => VNode;
43
+ }
44
+ /**
45
+ * 给一个滚动盒配一套浮层滚动条。
46
+ *
47
+ * @param scrollBox 滚动盒(`overflow: auto` 的那个元素)的 ref。为 `null` 时不挂任何监听 ——
48
+ * `fill` 这类「结构后出现」的滚动盒会在它出现后自动接上(`watch` + `flush: 'post'`)。
49
+ */
50
+ export declare function useOverlayScrollbar(scrollBox: Ref<HTMLElement | null>): OverlayScrollbar;
@@ -0,0 +1,187 @@
1
+ import { ref, onMounted, watch, onUpdated, onBeforeUnmount, createVNode } from "vue";
2
+ const SCROLLBAR_MIN = 24;
3
+ const SCROLLBAR_FADE = 800;
4
+ function useOverlayScrollbar(scrollBox) {
5
+ const ovbarRef = ref(null);
6
+ const vThumbRef = ref(null);
7
+ const hThumbRef = ref(null);
8
+ let fadeTimer;
9
+ let hovering = false;
10
+ let draggingAxis = null;
11
+ let dragStart = {
12
+ pointer: 0,
13
+ scroll: 0,
14
+ span: 0,
15
+ maxScroll: 0
16
+ };
17
+ const sync = () => {
18
+ const box = scrollBox.value;
19
+ const track = ovbarRef.value;
20
+ if (!box || !track) return;
21
+ const axes = [[vThumbRef.value, "y"], [hThumbRef.value, "x"]];
22
+ for (const [thumb, axis] of axes) {
23
+ if (!thumb) continue;
24
+ const vertical = axis === "y";
25
+ const trackSize = vertical ? track.clientHeight : track.clientWidth;
26
+ const viewSize = vertical ? box.clientHeight : box.clientWidth;
27
+ const contentSize = vertical ? box.scrollHeight : box.scrollWidth;
28
+ const maxScroll = contentSize - viewSize;
29
+ const scrollable = maxScroll > 1 && trackSize > 0;
30
+ thumb.hidden = !scrollable;
31
+ if (!scrollable) continue;
32
+ const length = Math.min(trackSize, Math.max(SCROLLBAR_MIN, Math.round(trackSize * viewSize / contentSize)));
33
+ const shift = (vertical ? box.scrollTop : box.scrollLeft) / maxScroll * (trackSize - length);
34
+ if (vertical) {
35
+ thumb.style.height = `${length}px`;
36
+ thumb.style.transform = `translateY(${shift}px)`;
37
+ } else {
38
+ thumb.style.width = `${length}px`;
39
+ thumb.style.transform = `translateX(${shift}px)`;
40
+ }
41
+ }
42
+ };
43
+ const show = () => {
44
+ if (fadeTimer) {
45
+ clearTimeout(fadeTimer);
46
+ fadeTimer = void 0;
47
+ }
48
+ ovbarRef.value?.classList.add("is-visible");
49
+ };
50
+ const hideLater = () => {
51
+ if (draggingAxis || hovering) return;
52
+ if (fadeTimer) clearTimeout(fadeTimer);
53
+ fadeTimer = setTimeout(() => {
54
+ fadeTimer = void 0;
55
+ ovbarRef.value?.classList.remove("is-visible");
56
+ }, SCROLLBAR_FADE);
57
+ };
58
+ const onEnter = () => {
59
+ hovering = true;
60
+ sync();
61
+ show();
62
+ };
63
+ const onLeave = () => {
64
+ hovering = false;
65
+ hideLater();
66
+ };
67
+ const onScroll = () => {
68
+ sync();
69
+ show();
70
+ hideLater();
71
+ };
72
+ const stopThumbDrag = () => {
73
+ draggingAxis = null;
74
+ ovbarRef.value?.classList.remove("is-dragging");
75
+ window.removeEventListener("pointermove", onThumbMove);
76
+ window.removeEventListener("pointerup", stopThumbDrag);
77
+ window.removeEventListener("pointercancel", stopThumbDrag);
78
+ hideLater();
79
+ };
80
+ const onThumbMove = (event) => {
81
+ const box = scrollBox.value;
82
+ if (!draggingAxis || !box) return;
83
+ const {
84
+ pointer,
85
+ scroll,
86
+ span,
87
+ maxScroll
88
+ } = dragStart;
89
+ if (span <= 0) return;
90
+ const delta = (draggingAxis === "y" ? event.clientY : event.clientX) - pointer;
91
+ const next = scroll + delta * maxScroll / span;
92
+ if (draggingAxis === "y") box.scrollTop = next;
93
+ else box.scrollLeft = next;
94
+ };
95
+ const startThumbDrag = (axis, event) => {
96
+ const box = scrollBox.value;
97
+ const track = ovbarRef.value;
98
+ const thumb = axis === "y" ? vThumbRef.value : hThumbRef.value;
99
+ if (!box || !track || !thumb || event.button !== 0) return;
100
+ event.preventDefault();
101
+ draggingAxis = axis;
102
+ show();
103
+ track.classList.add("is-dragging");
104
+ const vertical = axis === "y";
105
+ const trackSize = vertical ? track.clientHeight : track.clientWidth;
106
+ const thumbSize = vertical ? thumb.offsetHeight : thumb.offsetWidth;
107
+ dragStart = {
108
+ pointer: vertical ? event.clientY : event.clientX,
109
+ scroll: vertical ? box.scrollTop : box.scrollLeft,
110
+ span: trackSize - thumbSize,
111
+ maxScroll: vertical ? box.scrollHeight - box.clientHeight : box.scrollWidth - box.clientWidth
112
+ };
113
+ window.addEventListener("pointermove", onThumbMove);
114
+ window.addEventListener("pointerup", stopThumbDrag);
115
+ window.addEventListener("pointercancel", stopThumbDrag);
116
+ };
117
+ let teardown = null;
118
+ let resizeObserver;
119
+ const observeContent = () => {
120
+ const box = scrollBox.value;
121
+ if (!resizeObserver || !box) return;
122
+ for (const child of Array.from(box.children)) resizeObserver.observe(child);
123
+ };
124
+ const attach = () => {
125
+ teardown?.();
126
+ teardown = null;
127
+ resizeObserver?.disconnect();
128
+ resizeObserver = void 0;
129
+ const box = scrollBox.value;
130
+ const hoverArea = ovbarRef.value?.parentElement ?? null;
131
+ if (box) box.addEventListener("scroll", onScroll, {
132
+ passive: true
133
+ });
134
+ hoverArea?.addEventListener("pointerenter", onEnter);
135
+ hoverArea?.addEventListener("pointerleave", onLeave);
136
+ if (box && typeof ResizeObserver !== "undefined") {
137
+ resizeObserver = new ResizeObserver(sync);
138
+ resizeObserver.observe(box);
139
+ }
140
+ observeContent();
141
+ sync();
142
+ if (typeof requestAnimationFrame !== "undefined") requestAnimationFrame(sync);
143
+ teardown = () => {
144
+ box?.removeEventListener("scroll", onScroll);
145
+ hoverArea?.removeEventListener("pointerenter", onEnter);
146
+ hoverArea?.removeEventListener("pointerleave", onLeave);
147
+ };
148
+ };
149
+ onMounted(attach);
150
+ watch(scrollBox, attach, {
151
+ flush: "post"
152
+ });
153
+ onUpdated(() => {
154
+ sync();
155
+ observeContent();
156
+ });
157
+ onBeforeUnmount(() => {
158
+ teardown?.();
159
+ teardown = null;
160
+ resizeObserver?.disconnect();
161
+ resizeObserver = void 0;
162
+ stopThumbDrag();
163
+ if (fadeTimer) clearTimeout(fadeTimer);
164
+ });
165
+ return {
166
+ /**
167
+ * 浮层的结构:`aria-hidden` —— 它纯视觉,滚动语义仍在真滚动盒上(滚轮 / 键盘 / 触控板照旧)。
168
+ * `pointerdown` 只挂在拇指上:轨道不收指针,也不做点击翻页。
169
+ */
170
+ render: () => createVNode("div", {
171
+ "class": "mh-scrollbar",
172
+ "ref": ovbarRef,
173
+ "aria-hidden": "true"
174
+ }, [createVNode("div", {
175
+ "class": "mh-scrollbar__thumb mh-scrollbar__thumb--y",
176
+ "ref": vThumbRef,
177
+ "onPointerdown": (event) => startThumbDrag("y", event)
178
+ }, null), createVNode("div", {
179
+ "class": "mh-scrollbar__thumb mh-scrollbar__thumb--x",
180
+ "ref": hThumbRef,
181
+ "onPointerdown": (event) => startThumbDrag("x", event)
182
+ }, null)])
183
+ };
184
+ }
185
+ export {
186
+ useOverlayScrollbar
187
+ };
@@ -84,9 +84,7 @@ export declare const SelectList: import("vue").DefineComponent<import("vue").Ext
84
84
  type: PropType<() => VNodeChild>;
85
85
  default: undefined;
86
86
  };
87
- }>, () => string | number | boolean | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
88
- [key: string]: any;
89
- }> | import("vue").VNodeArrayChildren, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
87
+ }>, () => string | number | boolean | import("vue").VNodeArrayChildren | import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
90
88
  /** 已经过滤过的渲染树(分组内全空则由消费方整组去掉) */
91
89
  options: {
92
90
  type: PropType<SelectItem[]>;
@@ -162,9 +162,9 @@ export declare const TabBar: import("vue").DefineComponent<import("vue").Extract
162
162
  "onUpdate:value"?: ((value: TabBarValue) => any) | undefined;
163
163
  }>, {
164
164
  size: ControlSize;
165
+ onChange: (value: TabBarValue) => void;
165
166
  value: TabBarValue | undefined;
166
167
  type: TabBarType;
167
- onChange: (value: TabBarValue) => void;
168
168
  onClose: (value: TabBarValue) => void;
169
169
  defaultValue: TabBarValue | undefined;
170
170
  centered: boolean;
@@ -1,6 +1,7 @@
1
1
  import { defineComponent, computed, ref, onMounted, onUpdated, createVNode } from "vue";
2
2
  import { Icon } from "@manohub/icon";
3
3
  import { Checkbox } from "../checkbox/index.js";
4
+ import { useOverlayScrollbar } from "../scrollbar/index.js";
4
5
  const Table = /* @__PURE__ */ defineComponent({
5
6
  name: "Table",
6
7
  inheritAttrs: false,
@@ -344,6 +345,7 @@ const Table = /* @__PURE__ */ defineComponent({
344
345
  };
345
346
  onMounted(syncHead);
346
347
  onUpdated(syncHead);
348
+ const scrollbar = useOverlayScrollbar(scrollBoxRef);
347
349
  return () => {
348
350
  const fill = props.fill !== false;
349
351
  const tableClass = ["mh-table", resolvedSize.value === "sm" ? "mh-table--sm" : "", resolvedSize.value === "lg" ? "mh-table--lg" : "", props.bordered ? "" : "mh-table--borderless", fill ? "mh-table--fill" : "", fill || props.layout === "fixed" ? "mh-table--fixed" : "", attrs.class].filter(Boolean).join(" ");
@@ -369,10 +371,15 @@ const Table = /* @__PURE__ */ defineComponent({
369
371
  return createVNode("div", {
370
372
  "class": "mh-table-wrapper",
371
373
  "style": attrs.style
372
- }, [batchBar, createVNode("table", {
374
+ }, [batchBar, createVNode("div", {
375
+ "class": "mh-table__body mh-table__body--auto"
376
+ }, [createVNode("div", {
377
+ "class": "mh-table-scroll mh-table-scroll--auto",
378
+ "ref": scrollBoxRef
379
+ }, [createVNode("table", {
373
380
  "class": bodyTableClass,
374
381
  "style": cellTokens
375
- }, [colElements(), props.showHeader ? renderHead() : null, renderBody()]), summaryBar, loadingOverlay]);
382
+ }, [colElements(), props.showHeader ? renderHead() : null, renderBody()])]), scrollbar.render()]), summaryBar, loadingOverlay]);
376
383
  }
377
384
  const wrapperStyle = props.fill === true || props.fill === "parent" ? [{
378
385
  height: "100%"
@@ -400,7 +407,7 @@ const Table = /* @__PURE__ */ defineComponent({
400
407
  }, [createVNode("table", {
401
408
  "class": bodyTableClass,
402
409
  "style": cellTokens
403
- }, [colElements(), renderBody()])]), loadingOverlay]), summaryBar]);
410
+ }, [colElements(), renderBody()])]), scrollbar.render(), loadingOverlay]), summaryBar]);
404
411
  };
405
412
  }
406
413
  });
@@ -70,9 +70,9 @@ export declare const TabPanel: import("vue").DefineComponent<import("vue").Extra
70
70
  type: BooleanConstructor;
71
71
  default: boolean;
72
72
  };
73
- }>, () => string | number | boolean | VNode<import("vue").RendererNode, import("vue").RendererElement, {
73
+ }>, () => string | number | boolean | import("vue").VNodeArrayChildren | VNode<import("vue").RendererNode, import("vue").RendererElement, {
74
74
  [key: string]: any;
75
- }> | import("vue").VNodeArrayChildren | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
75
+ }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
76
76
  name: {
77
77
  type: StringConstructor;
78
78
  required: true;
@@ -186,8 +186,8 @@ export declare const Tabs: import("vue").DefineComponent<import("vue").ExtractPr
186
186
  "onUpdate:value"?: ((value: string | number) => any) | undefined;
187
187
  }>, {
188
188
  size: ControlSize;
189
- value: string | number | undefined;
190
189
  onChange: (value: string | number) => void;
190
+ value: string | number | undefined;
191
191
  options: TabsOption[];
192
192
  defaultValue: string | number | undefined;
193
193
  lazy: boolean;