@manohub/ui 1.0.9 → 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.
- package/README.md +3 -3
- package/dist/components/button/index.d.ts +74 -20
- package/dist/components/button/index.js +59 -14
- package/dist/components/button/segmented.d.ts +122 -0
- package/dist/components/button/segmented.js +99 -0
- package/dist/components/capsule/index.d.ts +2 -2
- package/dist/components/card/index.js +1 -1
- package/dist/components/filter/index.d.ts +3 -3
- package/dist/components/form/index.d.ts +1 -1
- package/dist/components/input/index.d.ts +6 -6
- package/dist/components/input/number-input.d.ts +1 -1
- package/dist/components/list/index.d.ts +19 -0
- package/dist/components/list/list-shared.d.ts +196 -0
- package/dist/components/list/list-shared.js +143 -0
- package/dist/components/list/list.d.ts +221 -0
- package/dist/components/list/list.js +131 -0
- package/dist/components/{tree/index.d.ts → list/tree.d.ts} +33 -33
- package/dist/components/{tree/index.js → list/tree.js} +23 -62
- package/dist/components/list-view/index.d.ts +7 -7
- package/dist/components/notice/index.d.ts +1 -1
- package/dist/components/panel/index.d.ts +39 -84
- package/dist/components/panel/index.js +18 -32
- package/dist/components/radio/index.d.ts +233 -118
- package/dist/components/radio/index.js +146 -150
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/index.js +6 -3
- package/dist/components/select/select-panel.d.ts +20 -0
- package/dist/components/select/select-panel.js +8 -1
- package/dist/components/select/select-tree-filter.d.ts +9 -9
- package/dist/components/select/select-tree.d.ts +23 -23
- package/dist/components/select/select-tree.js +16 -3
- package/dist/components/select/select-trigger.d.ts +43 -1
- package/dist/components/select/select-trigger.js +22 -5
- package/dist/components/steps/index.d.ts +4 -4
- package/dist/components/table/index.d.ts +4 -4
- package/dist/components/table/index.js +1 -1
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/tag/index.d.ts +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +5 -3
- package/dist/styles/components/button.css +107 -33
- package/dist/styles/components/{tree.css → list.css} +24 -24
- package/dist/styles/components/{tree.tokens.css → list.tokens.css} +5 -5
- package/dist/styles/components/pagination.css +3 -3
- package/dist/styles/components/panel.css +2 -9
- package/dist/styles/components/radio.css +21 -20
- package/dist/styles/components/select.css +2 -2
- package/dist/styles/components/select.tokens.css +2 -2
- package/dist/styles/index.css +2 -3
- package/dist/utils/vnode-children.d.ts +10 -0
- package/dist/utils/vnode-children.js +26 -0
- package/package.json +2 -2
- package/dist/components/nav/index.d.ts +0 -299
- package/dist/components/nav/index.js +0 -174
- package/dist/styles/components/nav.css +0 -48
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { defineComponent, createVNode } from "vue";
|
|
2
|
+
import { renderListStates, ListRow } from "./list-shared.js";
|
|
3
|
+
const List = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "List",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
nodes: {
|
|
8
|
+
type: Array,
|
|
9
|
+
required: true
|
|
10
|
+
},
|
|
11
|
+
/** 节点主键:字段名或取值函数 */
|
|
12
|
+
rowKey: {
|
|
13
|
+
type: [String, Function],
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
/** 标签字段名(默认 'label') */
|
|
17
|
+
labelKey: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: "label"
|
|
20
|
+
},
|
|
21
|
+
/** 受控选中(行主键值) */
|
|
22
|
+
selected: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: void 0
|
|
25
|
+
},
|
|
26
|
+
onSelect: {
|
|
27
|
+
type: Function,
|
|
28
|
+
default: void 0
|
|
29
|
+
},
|
|
30
|
+
/** 标签体的自定义渲染(**替掉** `labelKey` 的纯文本);口径同 `Tree.renderLabel` */
|
|
31
|
+
renderLabel: {
|
|
32
|
+
type: Function,
|
|
33
|
+
default: void 0
|
|
34
|
+
},
|
|
35
|
+
/** 标签**前**的节点图标槽;口径同 `Tree.renderIcon` */
|
|
36
|
+
renderIcon: {
|
|
37
|
+
type: Function,
|
|
38
|
+
default: void 0
|
|
39
|
+
},
|
|
40
|
+
/** 节点附加内容(计数徽标等),渲染在标签之后;口径同 `Tree.renderNode` */
|
|
41
|
+
renderNode: {
|
|
42
|
+
type: Function,
|
|
43
|
+
default: void 0
|
|
44
|
+
},
|
|
45
|
+
/** 行尾操作区;口径同 `Tree.renderActions`(默认隐藏、悬浮或聚焦显形、点击不冒泡) */
|
|
46
|
+
renderActions: {
|
|
47
|
+
type: Function,
|
|
48
|
+
default: void 0
|
|
49
|
+
},
|
|
50
|
+
/** 尺寸档:md 舒适(行高 30)/ sm 紧凑(行高 28),与 `Tree` 同档 */
|
|
51
|
+
size: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: "md"
|
|
54
|
+
},
|
|
55
|
+
loading: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
/** 空态文案 */
|
|
60
|
+
empty: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: "暂无数据"
|
|
63
|
+
},
|
|
64
|
+
/** 空态操作按钮(如「新建」);与 `onEmptyAction` 同时传才渲染 */
|
|
65
|
+
emptyActionText: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: void 0
|
|
68
|
+
},
|
|
69
|
+
onEmptyAction: {
|
|
70
|
+
type: Function,
|
|
71
|
+
default: void 0
|
|
72
|
+
},
|
|
73
|
+
/** 错误态(truthy 即触发);构造器顺序与 `Tree.error` 同款,`String` 必须排在 `Boolean` 前 */
|
|
74
|
+
error: {
|
|
75
|
+
type: [String, Boolean, Object, Number, Array],
|
|
76
|
+
default: void 0
|
|
77
|
+
},
|
|
78
|
+
/** 错误态标题(默认「加载失败」);字符串错误原文会自动作为副文案显示 */
|
|
79
|
+
errorTitle: {
|
|
80
|
+
type: String,
|
|
81
|
+
default: "加载失败"
|
|
82
|
+
},
|
|
83
|
+
/** 错误态操作按钮(如「重试」);与 `onErrorAction` 同时传才渲染 */
|
|
84
|
+
errorActionText: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: void 0
|
|
87
|
+
},
|
|
88
|
+
onErrorAction: {
|
|
89
|
+
type: Function,
|
|
90
|
+
default: void 0
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
slots: Object,
|
|
94
|
+
setup(props, {
|
|
95
|
+
slots,
|
|
96
|
+
attrs
|
|
97
|
+
}) {
|
|
98
|
+
const nodeKey = (node) => typeof props.rowKey === "function" ? props.rowKey(node) : String(node[props.rowKey] ?? "");
|
|
99
|
+
const handleSelect = (node) => {
|
|
100
|
+
props.onSelect?.(node);
|
|
101
|
+
};
|
|
102
|
+
return () => {
|
|
103
|
+
const state = renderListStates(props);
|
|
104
|
+
if (state) return state;
|
|
105
|
+
const rows = props.nodes.map((node) => {
|
|
106
|
+
const key = nodeKey(node);
|
|
107
|
+
return createVNode(ListRow, {
|
|
108
|
+
"key": key,
|
|
109
|
+
"node": node,
|
|
110
|
+
"caret": false,
|
|
111
|
+
"role": "listitem",
|
|
112
|
+
"depth": 0,
|
|
113
|
+
"selected": props.selected !== void 0 && props.selected === key,
|
|
114
|
+
"labelKey": props.labelKey,
|
|
115
|
+
"onSelect": handleSelect,
|
|
116
|
+
"renderIcon": props.renderIcon,
|
|
117
|
+
"renderLabel": props.renderLabel,
|
|
118
|
+
"renderNode": props.renderNode,
|
|
119
|
+
"renderActions": props.renderActions
|
|
120
|
+
}, null);
|
|
121
|
+
});
|
|
122
|
+
return createVNode("div", {
|
|
123
|
+
"class": [attrs.class, "mh-list", props.size === "sm" ? "mh-list--compact" : ""].filter(Boolean).join(" "),
|
|
124
|
+
"role": "list"
|
|
125
|
+
}, [rows, slots.default?.()]);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
export {
|
|
130
|
+
List
|
|
131
|
+
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
2
|
-
|
|
3
|
-
export interface TreeNode {
|
|
4
|
-
[key: string]: unknown;
|
|
5
|
-
}
|
|
2
|
+
import { type ListNode } from './list-shared';
|
|
6
3
|
/**
|
|
7
4
|
* 树(**自建**,不封装 farris)。
|
|
8
5
|
*
|
|
@@ -12,7 +9,7 @@ export interface TreeNode {
|
|
|
12
9
|
* `#F4F5F9`、选中 Au02 底 + Th03 字、箭头 8px(收起态转 −90°)、缩进 = 基础内距 8 + level × 步进 10
|
|
13
10
|
* (**无上限**)。两处与主题包**有意差异**(不改视觉,只改承载方式):
|
|
14
11
|
* 1. **缩进步进由 CSS 变量承载**:主题包用 typed `attr(data-level type(<number>))` 一步算出;本组件同时
|
|
15
|
-
* 下发 `data-level`(数据、供 CSS / 测试钩子)与 `--mh-
|
|
12
|
+
* 下发 `data-level`(数据、供 CSS / 测试钩子)与 `--mh-list-level`(公式仍在 CSS 内),不用行内
|
|
16
13
|
* `paddingLeft` —— 那样步进值散落在 JS 里,改了令牌对不上。
|
|
17
14
|
* 2. **交互分工**:主题包的约定是「点行即展开 / 收拢,选中由行内选择件驱动」;本组件没有内嵌选择件,故
|
|
18
15
|
* 沿用「点箭头展开 / 收拢、点行选中」(`onSelect`)。
|
|
@@ -33,7 +30,8 @@ export interface TreeNode {
|
|
|
33
30
|
* 行尾操作是**行的一部分**,不是导航语义 —— 与 `ListView.CardItem` 的 `actions` 同一口径:
|
|
34
31
|
* 几何与显隐归组件(默认隐藏、行悬浮或行内获得焦点时显形,触屏无 hover 能力时恒显形),
|
|
35
32
|
* 应用侧只给节点;操作容器自己做 `stopPropagation`,所以点「删除」不会顺带把这一行选中。
|
|
36
|
-
*
|
|
33
|
+
* 扁平导航(`List`,本目录另一件)因此不必重写一份行渲染 —— 行与三态都在 `./list-shared.tsx`,
|
|
34
|
+
* 两件共用同一份面。
|
|
37
35
|
*
|
|
38
36
|
* ## 图标出口(两处,都是「位」而不是「样式」)
|
|
39
37
|
*
|
|
@@ -47,12 +45,12 @@ export interface TreeNode {
|
|
|
47
45
|
*/
|
|
48
46
|
export declare const Tree: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
49
47
|
nodes: {
|
|
50
|
-
type: PropType<
|
|
48
|
+
type: PropType<ListNode[]>;
|
|
51
49
|
required: true;
|
|
52
50
|
};
|
|
53
51
|
/** 节点主键:字段名或取值函数 */
|
|
54
52
|
rowKey: {
|
|
55
|
-
type: PropType<string | ((node:
|
|
53
|
+
type: PropType<string | ((node: ListNode) => string)>;
|
|
56
54
|
required: true;
|
|
57
55
|
};
|
|
58
56
|
/** 标签字段名(默认 'label') */
|
|
@@ -71,27 +69,27 @@ export declare const Tree: import("vue").DefineComponent<import("vue").ExtractPr
|
|
|
71
69
|
default: undefined;
|
|
72
70
|
};
|
|
73
71
|
onSelect: {
|
|
74
|
-
type: PropType<(node:
|
|
72
|
+
type: PropType<(node: ListNode) => void>;
|
|
75
73
|
default: undefined;
|
|
76
74
|
};
|
|
77
75
|
/**
|
|
78
76
|
* 标签体的自定义渲染(**替掉** `labelKey` 的纯文本)。与 `renderNode` 的分工:本 prop 渲染的是**标签本体**
|
|
79
|
-
* (占位 / 省略号 / 行内对齐都由 `.mh-
|
|
77
|
+
* (占位 / 省略号 / 行内对齐都由 `.mh-list__label` 承担,故必须留在那个槽里);`renderNode` 渲染标签**之后**的
|
|
80
78
|
* 常驻附加内容(计数徽标一类)。典型用途是搜索命中的文本高亮(把标签切成多个片段)。缺省不传时仍渲染
|
|
81
79
|
* `labelKey` 的纯文本 —— 绝大多数消费方走这条,行为零变化。
|
|
82
80
|
*/
|
|
83
81
|
renderLabel: {
|
|
84
|
-
type: PropType<(node:
|
|
82
|
+
type: PropType<(node: ListNode) => unknown>;
|
|
85
83
|
default: undefined;
|
|
86
84
|
};
|
|
87
85
|
/**
|
|
88
86
|
* 展开 / 收起箭头的自定义渲染(拿到节点与**当前展开态**)。缺省仍是 `chevron-down` 字形 + 面层收起态转 −90°
|
|
89
87
|
* (默认路径零变化);自定义时**朝向由消费方按 `expanded` 自选字形**(`chevron-right` / `chevron-down`)——
|
|
90
|
-
* 与包内「方位一律用字形、不靠旋转别的图标」同源。**不要再给内容加 `mh-
|
|
88
|
+
* 与包内「方位一律用字形、不靠旋转别的图标」同源。**不要再给内容加 `mh-list__caret-icon` 类**(那是缺省字形
|
|
91
89
|
* 的转向钩子,加上会被转成 −90°);尺寸不必自管:槽位与槽内字形都取全局图标档 `--ui-font-icon`。
|
|
92
90
|
*/
|
|
93
91
|
renderCaret: {
|
|
94
|
-
type: PropType<(node:
|
|
92
|
+
type: PropType<(node: ListNode, expanded: boolean) => unknown>;
|
|
95
93
|
default: undefined;
|
|
96
94
|
};
|
|
97
95
|
/**
|
|
@@ -100,12 +98,12 @@ export declare const Tree: import("vue").DefineComponent<import("vue").ExtractPr
|
|
|
100
98
|
* 图标列跨层级对齐。颜色不写死:跟随行色,选中行的主色字与滑过态自动同步。
|
|
101
99
|
*/
|
|
102
100
|
renderIcon: {
|
|
103
|
-
type: PropType<(node:
|
|
101
|
+
type: PropType<(node: ListNode) => unknown>;
|
|
104
102
|
default: undefined;
|
|
105
103
|
};
|
|
106
104
|
/** 节点附加内容(计数徽标等),渲染在标签之后 */
|
|
107
105
|
renderNode: {
|
|
108
|
-
type: PropType<(node:
|
|
106
|
+
type: PropType<(node: ListNode) => unknown>;
|
|
109
107
|
default: undefined;
|
|
110
108
|
};
|
|
111
109
|
/**
|
|
@@ -114,7 +112,7 @@ export declare const Tree: import("vue").DefineComponent<import("vue").ExtractPr
|
|
|
114
112
|
* 节点)。与 `renderNode` 的分工:**常驻**的附加内容(计数徽标)走 `renderNode`,**可点**的行尾操作走这里。
|
|
115
113
|
*/
|
|
116
114
|
renderActions: {
|
|
117
|
-
type: PropType<(node:
|
|
115
|
+
type: PropType<(node: ListNode) => unknown>;
|
|
118
116
|
default: undefined;
|
|
119
117
|
};
|
|
120
118
|
/** 尺寸档:md 舒适(行高 30)/ sm 紧凑(行高 28),与主题包 Tree 的 M/S 档一致 */
|
|
@@ -187,14 +185,16 @@ export declare const Tree: import("vue").DefineComponent<import("vue").ExtractPr
|
|
|
187
185
|
type: PropType<string | number>;
|
|
188
186
|
default: undefined;
|
|
189
187
|
};
|
|
190
|
-
}>, () => import("vue
|
|
188
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
189
|
+
[key: string]: any;
|
|
190
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
191
191
|
nodes: {
|
|
192
|
-
type: PropType<
|
|
192
|
+
type: PropType<ListNode[]>;
|
|
193
193
|
required: true;
|
|
194
194
|
};
|
|
195
195
|
/** 节点主键:字段名或取值函数 */
|
|
196
196
|
rowKey: {
|
|
197
|
-
type: PropType<string | ((node:
|
|
197
|
+
type: PropType<string | ((node: ListNode) => string)>;
|
|
198
198
|
required: true;
|
|
199
199
|
};
|
|
200
200
|
/** 标签字段名(默认 'label') */
|
|
@@ -213,27 +213,27 @@ export declare const Tree: import("vue").DefineComponent<import("vue").ExtractPr
|
|
|
213
213
|
default: undefined;
|
|
214
214
|
};
|
|
215
215
|
onSelect: {
|
|
216
|
-
type: PropType<(node:
|
|
216
|
+
type: PropType<(node: ListNode) => void>;
|
|
217
217
|
default: undefined;
|
|
218
218
|
};
|
|
219
219
|
/**
|
|
220
220
|
* 标签体的自定义渲染(**替掉** `labelKey` 的纯文本)。与 `renderNode` 的分工:本 prop 渲染的是**标签本体**
|
|
221
|
-
* (占位 / 省略号 / 行内对齐都由 `.mh-
|
|
221
|
+
* (占位 / 省略号 / 行内对齐都由 `.mh-list__label` 承担,故必须留在那个槽里);`renderNode` 渲染标签**之后**的
|
|
222
222
|
* 常驻附加内容(计数徽标一类)。典型用途是搜索命中的文本高亮(把标签切成多个片段)。缺省不传时仍渲染
|
|
223
223
|
* `labelKey` 的纯文本 —— 绝大多数消费方走这条,行为零变化。
|
|
224
224
|
*/
|
|
225
225
|
renderLabel: {
|
|
226
|
-
type: PropType<(node:
|
|
226
|
+
type: PropType<(node: ListNode) => unknown>;
|
|
227
227
|
default: undefined;
|
|
228
228
|
};
|
|
229
229
|
/**
|
|
230
230
|
* 展开 / 收起箭头的自定义渲染(拿到节点与**当前展开态**)。缺省仍是 `chevron-down` 字形 + 面层收起态转 −90°
|
|
231
231
|
* (默认路径零变化);自定义时**朝向由消费方按 `expanded` 自选字形**(`chevron-right` / `chevron-down`)——
|
|
232
|
-
* 与包内「方位一律用字形、不靠旋转别的图标」同源。**不要再给内容加 `mh-
|
|
232
|
+
* 与包内「方位一律用字形、不靠旋转别的图标」同源。**不要再给内容加 `mh-list__caret-icon` 类**(那是缺省字形
|
|
233
233
|
* 的转向钩子,加上会被转成 −90°);尺寸不必自管:槽位与槽内字形都取全局图标档 `--ui-font-icon`。
|
|
234
234
|
*/
|
|
235
235
|
renderCaret: {
|
|
236
|
-
type: PropType<(node:
|
|
236
|
+
type: PropType<(node: ListNode, expanded: boolean) => unknown>;
|
|
237
237
|
default: undefined;
|
|
238
238
|
};
|
|
239
239
|
/**
|
|
@@ -242,12 +242,12 @@ export declare const Tree: import("vue").DefineComponent<import("vue").ExtractPr
|
|
|
242
242
|
* 图标列跨层级对齐。颜色不写死:跟随行色,选中行的主色字与滑过态自动同步。
|
|
243
243
|
*/
|
|
244
244
|
renderIcon: {
|
|
245
|
-
type: PropType<(node:
|
|
245
|
+
type: PropType<(node: ListNode) => unknown>;
|
|
246
246
|
default: undefined;
|
|
247
247
|
};
|
|
248
248
|
/** 节点附加内容(计数徽标等),渲染在标签之后 */
|
|
249
249
|
renderNode: {
|
|
250
|
-
type: PropType<(node:
|
|
250
|
+
type: PropType<(node: ListNode) => unknown>;
|
|
251
251
|
default: undefined;
|
|
252
252
|
};
|
|
253
253
|
/**
|
|
@@ -256,7 +256,7 @@ export declare const Tree: import("vue").DefineComponent<import("vue").ExtractPr
|
|
|
256
256
|
* 节点)。与 `renderNode` 的分工:**常驻**的附加内容(计数徽标)走 `renderNode`,**可点**的行尾操作走这里。
|
|
257
257
|
*/
|
|
258
258
|
renderActions: {
|
|
259
|
-
type: PropType<(node:
|
|
259
|
+
type: PropType<(node: ListNode) => unknown>;
|
|
260
260
|
default: undefined;
|
|
261
261
|
};
|
|
262
262
|
/** 尺寸档:md 舒适(行高 30)/ sm 紧凑(行高 28),与主题包 Tree 的 M/S 档一致 */
|
|
@@ -331,7 +331,7 @@ export declare const Tree: import("vue").DefineComponent<import("vue").ExtractPr
|
|
|
331
331
|
};
|
|
332
332
|
}>> & Readonly<{}>, {
|
|
333
333
|
size: "sm" | "md";
|
|
334
|
-
onSelect: (node:
|
|
334
|
+
onSelect: (node: ListNode) => void;
|
|
335
335
|
error: any;
|
|
336
336
|
loading: boolean;
|
|
337
337
|
selected: string;
|
|
@@ -342,12 +342,12 @@ export declare const Tree: import("vue").DefineComponent<import("vue").ExtractPr
|
|
|
342
342
|
errorActionText: string;
|
|
343
343
|
onErrorAction: () => void;
|
|
344
344
|
labelKey: string;
|
|
345
|
+
renderCaret: (node: ListNode, expanded: boolean) => unknown;
|
|
346
|
+
renderIcon: (node: ListNode) => unknown;
|
|
347
|
+
renderLabel: (node: ListNode) => unknown;
|
|
348
|
+
renderNode: (node: ListNode) => unknown;
|
|
349
|
+
renderActions: (node: ListNode) => unknown;
|
|
345
350
|
childrenKey: string;
|
|
346
|
-
renderLabel: (node: TreeNode) => unknown;
|
|
347
|
-
renderCaret: (node: TreeNode, expanded: boolean) => unknown;
|
|
348
|
-
renderIcon: (node: TreeNode) => unknown;
|
|
349
|
-
renderNode: (node: TreeNode) => unknown;
|
|
350
|
-
renderActions: (node: TreeNode) => unknown;
|
|
351
351
|
expandedKeys: string[];
|
|
352
352
|
defaultExpandedKeys: string[];
|
|
353
353
|
defaultExpandAll: boolean;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { defineComponent, ref, computed, watch, createVNode } from "vue";
|
|
2
|
-
import {
|
|
3
|
-
import { QueryState } from "../query-state/index.js";
|
|
2
|
+
import { renderListStates, ListRow } from "./list-shared.js";
|
|
4
3
|
const Tree = /* @__PURE__ */ defineComponent({
|
|
5
4
|
name: "Tree",
|
|
6
5
|
inheritAttrs: false,
|
|
@@ -35,7 +34,7 @@ const Tree = /* @__PURE__ */ defineComponent({
|
|
|
35
34
|
},
|
|
36
35
|
/**
|
|
37
36
|
* 标签体的自定义渲染(**替掉** `labelKey` 的纯文本)。与 `renderNode` 的分工:本 prop 渲染的是**标签本体**
|
|
38
|
-
* (占位 / 省略号 / 行内对齐都由 `.mh-
|
|
37
|
+
* (占位 / 省略号 / 行内对齐都由 `.mh-list__label` 承担,故必须留在那个槽里);`renderNode` 渲染标签**之后**的
|
|
39
38
|
* 常驻附加内容(计数徽标一类)。典型用途是搜索命中的文本高亮(把标签切成多个片段)。缺省不传时仍渲染
|
|
40
39
|
* `labelKey` 的纯文本 —— 绝大多数消费方走这条,行为零变化。
|
|
41
40
|
*/
|
|
@@ -46,7 +45,7 @@ const Tree = /* @__PURE__ */ defineComponent({
|
|
|
46
45
|
/**
|
|
47
46
|
* 展开 / 收起箭头的自定义渲染(拿到节点与**当前展开态**)。缺省仍是 `chevron-down` 字形 + 面层收起态转 −90°
|
|
48
47
|
* (默认路径零变化);自定义时**朝向由消费方按 `expanded` 自选字形**(`chevron-right` / `chevron-down`)——
|
|
49
|
-
* 与包内「方位一律用字形、不靠旋转别的图标」同源。**不要再给内容加 `mh-
|
|
48
|
+
* 与包内「方位一律用字形、不靠旋转别的图标」同源。**不要再给内容加 `mh-list__caret-icon` 类**(那是缺省字形
|
|
50
49
|
* 的转向钩子,加上会被转成 −90°);尺寸不必自管:槽位与槽内字形都取全局图标档 `--ui-font-icon`。
|
|
51
50
|
*/
|
|
52
51
|
renderCaret: {
|
|
@@ -196,75 +195,37 @@ const Tree = /* @__PURE__ */ defineComponent({
|
|
|
196
195
|
return rows;
|
|
197
196
|
};
|
|
198
197
|
return () => {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
"loading": true,
|
|
202
|
-
"skeletonRows": 6
|
|
203
|
-
}, null);
|
|
204
|
-
}
|
|
205
|
-
if (props.error) {
|
|
206
|
-
return createVNode(QueryState, {
|
|
207
|
-
"error": props.error,
|
|
208
|
-
"errorTitle": props.errorTitle,
|
|
209
|
-
"errorDescription": typeof props.error === "string" ? props.error : void 0,
|
|
210
|
-
"errorActionText": props.errorActionText,
|
|
211
|
-
"onErrorAction": props.onErrorAction
|
|
212
|
-
}, null);
|
|
213
|
-
}
|
|
214
|
-
if (props.nodes.length === 0) {
|
|
215
|
-
return createVNode(QueryState, {
|
|
216
|
-
"empty": props.empty,
|
|
217
|
-
"emptyActionText": props.emptyActionText,
|
|
218
|
-
"onEmptyAction": props.onEmptyAction
|
|
219
|
-
}, null);
|
|
220
|
-
}
|
|
198
|
+
const state = renderListStates(props);
|
|
199
|
+
if (state) return state;
|
|
221
200
|
const rows = flatten().map(({
|
|
222
201
|
node,
|
|
223
202
|
depth,
|
|
224
203
|
key
|
|
225
204
|
}) => {
|
|
226
|
-
const
|
|
227
|
-
const hasChildren = children.length > 0;
|
|
205
|
+
const hasChildren = childrenOf(node).length > 0;
|
|
228
206
|
const expanded = isExpanded(key);
|
|
229
|
-
|
|
230
|
-
return createVNode("div", {
|
|
231
|
-
"class": "mh-tree__row",
|
|
207
|
+
return createVNode(ListRow, {
|
|
232
208
|
"key": key,
|
|
209
|
+
"node": node,
|
|
210
|
+
"depth": depth,
|
|
211
|
+
"caret": true,
|
|
233
212
|
"role": "treeitem",
|
|
234
|
-
"
|
|
235
|
-
"
|
|
236
|
-
"
|
|
237
|
-
"
|
|
238
|
-
"
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
"
|
|
242
|
-
|
|
243
|
-
"
|
|
244
|
-
"
|
|
245
|
-
|
|
246
|
-
event.stopPropagation();
|
|
247
|
-
toggleExpand(key);
|
|
248
|
-
}
|
|
249
|
-
}, [props.renderCaret ? props.renderCaret(node, expanded) : createVNode(Icon, {
|
|
250
|
-
"name": "chevron-down",
|
|
251
|
-
"class": "mh-tree__caret-icon"
|
|
252
|
-
}, null)]) : createVNode("span", {
|
|
253
|
-
"class": "mh-tree__caret mh-tree__caret--empty"
|
|
254
|
-
}, null), props.renderIcon ? createVNode("span", {
|
|
255
|
-
"class": "mh-tree__icon"
|
|
256
|
-
}, [props.renderIcon(node)]) : null, createVNode("span", {
|
|
257
|
-
"class": "mh-tree__label"
|
|
258
|
-
}, [props.renderLabel ? props.renderLabel(node) : String(node[props.labelKey] ?? "")]), props.renderNode ? createVNode("span", {
|
|
259
|
-
"class": "mh-tree__extra"
|
|
260
|
-
}, [props.renderNode(node)]) : null, props.renderActions ? createVNode("span", {
|
|
261
|
-
"class": "mh-tree__actions",
|
|
262
|
-
"onClick": (event) => event.stopPropagation()
|
|
263
|
-
}, [props.renderActions(node)]) : null]);
|
|
213
|
+
"hasChildren": hasChildren,
|
|
214
|
+
"expanded": expanded,
|
|
215
|
+
"selected": props.selected !== void 0 && props.selected === key,
|
|
216
|
+
"labelKey": props.labelKey,
|
|
217
|
+
"onSelect": handleSelect,
|
|
218
|
+
"onToggle": (target) => toggleExpand(nodeKey(target)),
|
|
219
|
+
"renderCaret": props.renderCaret,
|
|
220
|
+
"renderIcon": props.renderIcon,
|
|
221
|
+
"renderLabel": props.renderLabel,
|
|
222
|
+
"renderNode": props.renderNode,
|
|
223
|
+
"renderActions": props.renderActions
|
|
224
|
+
}, null);
|
|
264
225
|
});
|
|
265
226
|
return createVNode("div", {
|
|
266
227
|
"key": props.treeKey,
|
|
267
|
-
"class": [attrs.class, "mh-
|
|
228
|
+
"class": [attrs.class, "mh-list", props.size === "sm" ? "mh-list--compact" : ""].filter(Boolean).join(" "),
|
|
268
229
|
"role": "tree"
|
|
269
230
|
}, [rows, slots.default?.()]);
|
|
270
231
|
};
|
|
@@ -184,10 +184,10 @@ export declare const ListViewCardItem: import("vue").DefineComponent<import("vue
|
|
|
184
184
|
extra: any;
|
|
185
185
|
footer: any;
|
|
186
186
|
onClick: () => void;
|
|
187
|
-
actions: any;
|
|
188
187
|
subtitle: string;
|
|
189
|
-
|
|
188
|
+
actions: any;
|
|
190
189
|
description: string;
|
|
190
|
+
status: ListViewStatus;
|
|
191
191
|
tags: string[];
|
|
192
192
|
}, SlotsType<{
|
|
193
193
|
default?: () => VNodeChild;
|
|
@@ -257,6 +257,7 @@ export declare const ListView: {
|
|
|
257
257
|
}>> & Readonly<{}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {
|
|
258
258
|
error: any;
|
|
259
259
|
loading: boolean;
|
|
260
|
+
columns: number;
|
|
260
261
|
empty: string | boolean;
|
|
261
262
|
emptyDescription: string;
|
|
262
263
|
errorTitle: string;
|
|
@@ -265,7 +266,6 @@ export declare const ListView: {
|
|
|
265
266
|
onEmptyAction: () => void;
|
|
266
267
|
errorActionText: string;
|
|
267
268
|
onErrorAction: () => void;
|
|
268
|
-
columns: number;
|
|
269
269
|
minItemWidth: number;
|
|
270
270
|
skeletonCount: number;
|
|
271
271
|
}, true, {}, SlotsType<{
|
|
@@ -334,6 +334,7 @@ export declare const ListView: {
|
|
|
334
334
|
}>> & Readonly<{}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, {
|
|
335
335
|
error: any;
|
|
336
336
|
loading: boolean;
|
|
337
|
+
columns: number;
|
|
337
338
|
empty: string | boolean;
|
|
338
339
|
emptyDescription: string;
|
|
339
340
|
errorTitle: string;
|
|
@@ -342,7 +343,6 @@ export declare const ListView: {
|
|
|
342
343
|
onEmptyAction: () => void;
|
|
343
344
|
errorActionText: string;
|
|
344
345
|
onErrorAction: () => void;
|
|
345
|
-
columns: number;
|
|
346
346
|
minItemWidth: number;
|
|
347
347
|
skeletonCount: number;
|
|
348
348
|
}>;
|
|
@@ -406,6 +406,7 @@ export declare const ListView: {
|
|
|
406
406
|
}>> & Readonly<{}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
|
407
407
|
error: any;
|
|
408
408
|
loading: boolean;
|
|
409
|
+
columns: number;
|
|
409
410
|
empty: string | boolean;
|
|
410
411
|
emptyDescription: string;
|
|
411
412
|
errorTitle: string;
|
|
@@ -414,7 +415,6 @@ export declare const ListView: {
|
|
|
414
415
|
onEmptyAction: () => void;
|
|
415
416
|
errorActionText: string;
|
|
416
417
|
onErrorAction: () => void;
|
|
417
|
-
columns: number;
|
|
418
418
|
minItemWidth: number;
|
|
419
419
|
skeletonCount: number;
|
|
420
420
|
}, {}, string, SlotsType<{
|
|
@@ -515,10 +515,10 @@ export declare const ListView: {
|
|
|
515
515
|
extra: any;
|
|
516
516
|
footer: any;
|
|
517
517
|
onClick: () => void;
|
|
518
|
-
actions: any;
|
|
519
518
|
subtitle: string;
|
|
520
|
-
|
|
519
|
+
actions: any;
|
|
521
520
|
description: string;
|
|
521
|
+
status: ListViewStatus;
|
|
522
522
|
tags: string[];
|
|
523
523
|
}, SlotsType<{
|
|
524
524
|
default?: () => VNodeChild;
|
|
@@ -120,8 +120,8 @@ export declare const Notice: import("vue").DefineComponent<import("vue").Extract
|
|
|
120
120
|
onClose: () => void;
|
|
121
121
|
message: string;
|
|
122
122
|
closable: boolean;
|
|
123
|
-
tone: NoticeTone;
|
|
124
123
|
description: string;
|
|
124
|
+
tone: NoticeTone;
|
|
125
125
|
action: string;
|
|
126
126
|
onAction: () => void;
|
|
127
127
|
closeText: string;
|