@manohub/ui 1.1.4 → 1.2.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/components/button/index.d.ts +12 -12
- package/dist/components/capsule/index.d.ts +1 -1
- package/dist/components/code-block/index.d.ts +5 -5
- package/dist/components/date-picker/date-panel.d.ts +1 -1
- package/dist/components/date-picker/index.d.ts +6 -6
- package/dist/components/dialog/index.d.ts +2 -12
- package/dist/components/dialog/index.js +8 -7
- package/dist/components/drawer/index.js +7 -1
- package/dist/components/filter/index.d.ts +2 -2
- package/dist/components/form/index.d.ts +4 -4
- package/dist/components/input/index.d.ts +10 -10
- package/dist/components/input/number-input.d.ts +2 -2
- package/dist/components/list/list-shared.d.ts +11 -0
- package/dist/components/list/list-shared.js +13 -2
- package/dist/components/list/list.d.ts +1 -1
- package/dist/components/list/tree.d.ts +18 -1
- package/dist/components/list/tree.js +9 -0
- package/dist/components/list-view/index.d.ts +2 -2
- package/dist/components/notice/index.d.ts +2 -2
- package/dist/components/notification/index.d.ts +1 -1
- package/dist/components/page/index.d.ts +2 -4
- package/dist/components/page/index.js +9 -2
- package/dist/components/panel/index.d.ts +2 -2
- package/dist/components/panel/index.js +10 -3
- package/dist/components/query-state/index.d.ts +1 -3
- package/dist/components/radio/index.d.ts +7 -7
- package/dist/components/scrollbar/index.d.ts +50 -0
- package/dist/components/scrollbar/index.js +187 -0
- package/dist/components/select/select-list.d.ts +1 -3
- package/dist/components/select/select-tree.d.ts +24 -2
- package/dist/components/select/select-tree.js +19 -3
- package/dist/components/tabbar/index.d.ts +1 -1
- package/dist/components/table/index.js +10 -3
- package/dist/components/tabs/index.d.ts +3 -3
- package/dist/components/toast/index.d.ts +4 -4
- package/dist/styles/components/dialog.css +21 -6
- package/dist/styles/components/drawer.css +18 -5
- package/dist/styles/components/list.css +17 -0
- package/dist/styles/components/page.css +20 -3
- package/dist/styles/components/panel.css +17 -0
- package/dist/styles/components/scrollbar.css +63 -0
- package/dist/styles/components/table.css +33 -4
- package/dist/styles/index.css +1 -0
- package/package.json +2 -2
|
@@ -32,6 +32,14 @@ const Tree = /* @__PURE__ */ defineComponent({
|
|
|
32
32
|
type: Function,
|
|
33
33
|
default: void 0
|
|
34
34
|
},
|
|
35
|
+
/**
|
|
36
|
+
* 行禁用判定:命中的行带 `is-disabled` / `aria-disabled`,点行不再触发 `onSelect`。
|
|
37
|
+
* 只影响「选中」这一路;展开箭头仍可用(父节点即便不可选,也还能靠箭头开合)。
|
|
38
|
+
*/
|
|
39
|
+
disabledNode: {
|
|
40
|
+
type: Function,
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
35
43
|
/**
|
|
36
44
|
* 标签体的自定义渲染(**替掉** `labelKey` 的纯文本)。与 `renderNode` 的分工:本 prop 渲染的是**标签本体**
|
|
37
45
|
* (占位 / 省略号 / 行内对齐都由 `.mh-list__label` 承担,故必须留在那个槽里);`renderNode` 渲染标签**之后**的
|
|
@@ -213,6 +221,7 @@ const Tree = /* @__PURE__ */ defineComponent({
|
|
|
213
221
|
"hasChildren": hasChildren,
|
|
214
222
|
"expanded": expanded,
|
|
215
223
|
"selected": props.selected !== void 0 && props.selected === key,
|
|
224
|
+
"disabled": props.disabledNode ? props.disabledNode(node) : false,
|
|
216
225
|
"labelKey": props.labelKey,
|
|
217
226
|
"onSelect": handleSelect,
|
|
218
227
|
"onToggle": (target) => toggleExpand(nodeKey(target)),
|
|
@@ -181,9 +181,9 @@ export declare const ListViewCardItem: import("vue").DefineComponent<import("vue
|
|
|
181
181
|
};
|
|
182
182
|
}>> & Readonly<{}>, {
|
|
183
183
|
icon: any;
|
|
184
|
-
extra: any;
|
|
185
184
|
footer: any;
|
|
186
185
|
onClick: () => void;
|
|
186
|
+
extra: any;
|
|
187
187
|
subtitle: string;
|
|
188
188
|
actions: any;
|
|
189
189
|
description: string;
|
|
@@ -512,9 +512,9 @@ export declare const ListView: {
|
|
|
512
512
|
};
|
|
513
513
|
}>> & Readonly<{}>, {
|
|
514
514
|
icon: any;
|
|
515
|
-
extra: any;
|
|
516
515
|
footer: any;
|
|
517
516
|
onClick: () => void;
|
|
517
|
+
extra: any;
|
|
518
518
|
subtitle: string;
|
|
519
519
|
actions: any;
|
|
520
520
|
description: string;
|
|
@@ -116,9 +116,9 @@ export declare const Notice: import("vue").DefineComponent<import("vue").Extract
|
|
|
116
116
|
default: undefined;
|
|
117
117
|
};
|
|
118
118
|
}>> & Readonly<{}>, {
|
|
119
|
-
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "
|
|
120
|
-
onClose: () => void;
|
|
119
|
+
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "close" | "pause" | "play" | "image" | "delete" | "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";
|
|
121
120
|
message: string;
|
|
121
|
+
onClose: () => void;
|
|
122
122
|
closable: boolean;
|
|
123
123
|
description: string;
|
|
124
124
|
tone: NoticeTone;
|
|
@@ -93,7 +93,7 @@ export declare const Notification: import("vue").DefineComponent<import("vue").E
|
|
|
93
93
|
default: undefined;
|
|
94
94
|
};
|
|
95
95
|
}>> & Readonly<{}>, {
|
|
96
|
-
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "
|
|
96
|
+
icon: boolean | "search" | "link" | "filter" | "copy" | "help" | "table" | "menu" | "close" | "pause" | "play" | "image" | "delete" | "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";
|
|
97
97
|
title: string;
|
|
98
98
|
onClose: () => void;
|
|
99
99
|
closable: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PropType, type SlotsType, type
|
|
1
|
+
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
2
2
|
import { type Padding } from '../part-padding';
|
|
3
3
|
/**
|
|
4
4
|
* 页面骨架复合件 —— 页面结构与滚动归属的统一契约。
|
|
@@ -131,9 +131,7 @@ export declare const Page: {
|
|
|
131
131
|
type: PropType<PagePadding>;
|
|
132
132
|
default: undefined;
|
|
133
133
|
};
|
|
134
|
-
}>, () => string | number | boolean |
|
|
135
|
-
[key: string]: any;
|
|
136
|
-
}> | import("vue").VNodeArrayChildren | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
134
|
+
}>, () => 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
135
|
title: {
|
|
138
136
|
type: StringConstructor;
|
|
139
137
|
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,16 @@ const PageBody = /* @__PURE__ */ defineComponent({
|
|
|
116
117
|
slots,
|
|
117
118
|
attrs
|
|
118
119
|
}) {
|
|
120
|
+
const scrollRef = ref(null);
|
|
121
|
+
const scrollbar = useOverlayScrollbar(scrollRef);
|
|
119
122
|
return () => createVNode("div", {
|
|
120
123
|
"class": ["mh-page__body", `mh-page__body--${props.mode}`],
|
|
121
|
-
"style":
|
|
122
|
-
}, [
|
|
124
|
+
"style": attrs.style
|
|
125
|
+
}, [createVNode("div", {
|
|
126
|
+
"class": "mh-page__scroll",
|
|
127
|
+
"ref": scrollRef,
|
|
128
|
+
"style": partPaddingStyle(props.padding)
|
|
129
|
+
}, [slots.default?.()]), props.mode === "scroll" ? scrollbar.render() : null]);
|
|
123
130
|
}
|
|
124
131
|
});
|
|
125
132
|
const PageFooter = /* @__PURE__ */ defineComponent({
|
|
@@ -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
|
-
}>, () =>
|
|
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
|
-
}>, () =>
|
|
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":
|
|
72
|
-
}, [
|
|
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({
|
|
@@ -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").
|
|
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").
|
|
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[]>;
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* 显式锚 / 搜索行)、共用原子(面板 id / popover 开合 / 键盘契约)—— 故「面板长相与开合行为」只有一份规格;
|
|
6
6
|
* 本件独有的只有**树体那一层**:
|
|
7
7
|
*
|
|
8
|
-
* 1.
|
|
9
|
-
*
|
|
8
|
+
* 1. **可选口径**:缺省只有叶子可选(点叶子行即选中并收起,点父节点行只切换展开)。
|
|
9
|
+
* 传 `selectable` 谓词可放开任意层级 —— 如筛选场景选中父域即筛整棵子树;
|
|
10
|
+
* 谓词返回 `false` 的父节点行仍可点行展开 / 收起,返回 `false` 的叶子行点击无响应。
|
|
10
11
|
* 2. **本地过滤树**:搜索行在场时按关键词过滤,命中节点的**祖先链保留**、父节点自身命中则**整支保留**,并强制
|
|
11
12
|
* 全展到命中层(算法与切分都是纯函数,见 `select-tree-filter.ts`);命中文本按面层的 `.mh-select__hit`
|
|
12
13
|
* 高亮(靠 `Tree` 的 `renderLabel` 钩子落进标签槽)。
|
|
@@ -48,6 +49,16 @@ export declare const SelectTree: import("vue").DefineComponent<import("vue").Ext
|
|
|
48
49
|
type: StringConstructor;
|
|
49
50
|
default: string;
|
|
50
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* 可选判定(缺省:只有叶子可选)。
|
|
54
|
+
*
|
|
55
|
+
* 返回 `true` 的节点点行即选中(父节点也可选,如筛选场景选父域即筛整棵子树);
|
|
56
|
+
* 返回 `false` 的父节点行只切换展开 / 收起,返回 `false` 的叶子行点击无响应。
|
|
57
|
+
*/
|
|
58
|
+
selectable: {
|
|
59
|
+
type: PropType<(node: ListNode) => boolean>;
|
|
60
|
+
default: undefined;
|
|
61
|
+
};
|
|
51
62
|
/** 受控值(选中叶子的主键;树选择只单选) */
|
|
52
63
|
modelValue: {
|
|
53
64
|
type: StringConstructor;
|
|
@@ -177,6 +188,16 @@ export declare const SelectTree: import("vue").DefineComponent<import("vue").Ext
|
|
|
177
188
|
type: StringConstructor;
|
|
178
189
|
default: string;
|
|
179
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* 可选判定(缺省:只有叶子可选)。
|
|
193
|
+
*
|
|
194
|
+
* 返回 `true` 的节点点行即选中(父节点也可选,如筛选场景选父域即筛整棵子树);
|
|
195
|
+
* 返回 `false` 的父节点行只切换展开 / 收起,返回 `false` 的叶子行点击无响应。
|
|
196
|
+
*/
|
|
197
|
+
selectable: {
|
|
198
|
+
type: PropType<(node: ListNode) => boolean>;
|
|
199
|
+
default: undefined;
|
|
200
|
+
};
|
|
180
201
|
/** 受控值(选中叶子的主键;树选择只单选) */
|
|
181
202
|
modelValue: {
|
|
182
203
|
type: StringConstructor;
|
|
@@ -308,6 +329,7 @@ export declare const SelectTree: import("vue").DefineComponent<import("vue").Ext
|
|
|
308
329
|
onSearch: (keyword: string) => void;
|
|
309
330
|
emptyText: string;
|
|
310
331
|
searchable: boolean;
|
|
332
|
+
selectable: (node: ListNode) => boolean;
|
|
311
333
|
filterNode: (node: ListNode, keyword: string) => boolean;
|
|
312
334
|
highlight: boolean;
|
|
313
335
|
}, SlotsType<{
|
|
@@ -2,7 +2,7 @@ import { defineComponent, ref, computed, watch, createVNode, createTextVNode, Fr
|
|
|
2
2
|
import { SelectPanel } from "./select-panel.js";
|
|
3
3
|
import { SelectTrigger } from "./select-trigger.js";
|
|
4
4
|
import { createSelectPanelId, createTriggerKeydown, showPanel, hidePanel } from "./select-shared.js";
|
|
5
|
-
import { filterTreeNodes, findTreeNode, treeLabel, splitHighlight,
|
|
5
|
+
import { filterTreeNodes, findTreeNode, treeLabel, splitHighlight, treeChildren, treeNodeKey } from "./select-tree-filter.js";
|
|
6
6
|
import { Tree } from "../list/tree.js";
|
|
7
7
|
const SelectTree = /* @__PURE__ */ defineComponent({
|
|
8
8
|
name: "SelectTree",
|
|
@@ -28,6 +28,16 @@ const SelectTree = /* @__PURE__ */ defineComponent({
|
|
|
28
28
|
type: String,
|
|
29
29
|
default: "children"
|
|
30
30
|
},
|
|
31
|
+
/**
|
|
32
|
+
* 可选判定(缺省:只有叶子可选)。
|
|
33
|
+
*
|
|
34
|
+
* 返回 `true` 的节点点行即选中(父节点也可选,如筛选场景选父域即筛整棵子树);
|
|
35
|
+
* 返回 `false` 的父节点行只切换展开 / 收起,返回 `false` 的叶子行点击无响应。
|
|
36
|
+
*/
|
|
37
|
+
selectable: {
|
|
38
|
+
type: Function,
|
|
39
|
+
default: void 0
|
|
40
|
+
},
|
|
31
41
|
/** 受控值(选中叶子的主键;树选择只单选) */
|
|
32
42
|
modelValue: {
|
|
33
43
|
type: String,
|
|
@@ -154,6 +164,7 @@ const SelectTree = /* @__PURE__ */ defineComponent({
|
|
|
154
164
|
};
|
|
155
165
|
const keyOf = (node) => treeNodeKey(node, props.rowKey);
|
|
156
166
|
const childrenOf = (node) => treeChildren(node, props.childrenKey);
|
|
167
|
+
const isSelectable = (node) => props.selectable ? props.selectable(node) : childrenOf(node).length === 0;
|
|
157
168
|
const current = computed(() => props.modelValue ?? inner.value);
|
|
158
169
|
const hasValue = computed(() => current.value !== void 0 && current.value !== "");
|
|
159
170
|
const collectKeys = (list) => list.flatMap((node) => [keyOf(node), ...collectKeys(childrenOf(node))]);
|
|
@@ -195,8 +206,12 @@ const SelectTree = /* @__PURE__ */ defineComponent({
|
|
|
195
206
|
handleExpandChange([...next]);
|
|
196
207
|
};
|
|
197
208
|
const pick = (node) => {
|
|
198
|
-
|
|
199
|
-
|
|
209
|
+
const hasChildren = childrenOf(node).length > 0;
|
|
210
|
+
const canSelect = isSelectable(node);
|
|
211
|
+
if (!canSelect) {
|
|
212
|
+
if (hasChildren) {
|
|
213
|
+
toggleExpand(keyOf(node));
|
|
214
|
+
}
|
|
200
215
|
return;
|
|
201
216
|
}
|
|
202
217
|
commit(keyOf(node));
|
|
@@ -274,6 +289,7 @@ const SelectTree = /* @__PURE__ */ defineComponent({
|
|
|
274
289
|
"expandedKeys": expandedKeys.value,
|
|
275
290
|
"onExpandChange": handleExpandChange,
|
|
276
291
|
"onSelect": pick,
|
|
292
|
+
"disabledNode": (node) => !isSelectable(node) && childrenOf(node).length === 0,
|
|
277
293
|
"renderLabel": highlightLabel,
|
|
278
294
|
"renderIcon": props.renderIcon,
|
|
279
295
|
"renderCaret": props.renderCaret
|
|
@@ -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;
|