@manohub/ui 0.6.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 +141 -0
- package/dist/components/avatar/index.d.ts +283 -0
- package/dist/components/avatar/index.js +167 -0
- package/dist/components/badge/index.d.ts +132 -0
- package/dist/components/badge/index.js +99 -0
- package/dist/components/button/index.d.ts +578 -0
- package/dist/components/button/index.js +191 -0
- package/dist/components/capsule/index.d.ts +161 -0
- package/dist/components/capsule/index.js +101 -0
- package/dist/components/card/index.d.ts +456 -0
- package/dist/components/card/index.js +231 -0
- package/dist/components/checkbox/index.d.ts +331 -0
- package/dist/components/checkbox/index.js +165 -0
- package/dist/components/code/index.d.ts +134 -0
- package/dist/components/code/index.js +117 -0
- package/dist/components/code-editor/index.d.ts +163 -0
- package/dist/components/code-editor/index.js +98 -0
- package/dist/components/collapse/index.d.ts +125 -0
- package/dist/components/collapse/index.js +95 -0
- package/dist/components/control-size.d.ts +8 -0
- package/dist/components/dialog/index.d.ts +224 -0
- package/dist/components/dialog/index.js +194 -0
- package/dist/components/divider/index.d.ts +64 -0
- package/dist/components/divider/index.js +62 -0
- package/dist/components/drawer/index.d.ts +226 -0
- package/dist/components/drawer/index.js +190 -0
- package/dist/components/filter/index.d.ts +391 -0
- package/dist/components/filter/index.js +203 -0
- package/dist/components/form/index.d.ts +704 -0
- package/dist/components/form/index.js +329 -0
- package/dist/components/input/index.d.ts +980 -0
- package/dist/components/input/index.js +334 -0
- package/dist/components/layout/index.d.ts +162 -0
- package/dist/components/layout/index.js +100 -0
- package/dist/components/list-view/index.d.ts +563 -0
- package/dist/components/list-view/index.js +221 -0
- package/dist/components/loading/index.d.ts +77 -0
- package/dist/components/loading/index.js +40 -0
- package/dist/components/nav/index.d.ts +293 -0
- package/dist/components/nav/index.js +164 -0
- package/dist/components/notice/index.d.ts +137 -0
- package/dist/components/notice/index.js +101 -0
- package/dist/components/notification/index.d.ts +118 -0
- package/dist/components/notification/index.js +99 -0
- package/dist/components/page/index.d.ts +276 -0
- package/dist/components/page/index.js +351 -0
- package/dist/components/page/split-resize.d.ts +42 -0
- package/dist/components/page/split-resize.js +36 -0
- package/dist/components/pagination/index.d.ts +171 -0
- package/dist/components/pagination/index.js +226 -0
- package/dist/components/panel/index.d.ts +401 -0
- package/dist/components/panel/index.js +193 -0
- package/dist/components/part-padding.d.ts +27 -0
- package/dist/components/part-padding.js +23 -0
- package/dist/components/query-state/index.d.ts +207 -0
- package/dist/components/query-state/index.js +181 -0
- package/dist/components/radio/index.d.ts +473 -0
- package/dist/components/radio/index.js +250 -0
- package/dist/components/search/index.d.ts +167 -0
- package/dist/components/search/index.js +105 -0
- package/dist/components/select/index.d.ts +252 -0
- package/dist/components/select/index.js +281 -0
- package/dist/components/skeleton/index.d.ts +88 -0
- package/dist/components/skeleton/index.js +56 -0
- package/dist/components/steps/index.d.ts +199 -0
- package/dist/components/steps/index.js +117 -0
- package/dist/components/switch/index.d.ts +150 -0
- package/dist/components/switch/index.js +103 -0
- package/dist/components/table/index.d.ts +351 -0
- package/dist/components/table/index.js +286 -0
- package/dist/components/tabs/index.d.ts +179 -0
- package/dist/components/tabs/index.js +153 -0
- package/dist/components/tabset/index.d.ts +105 -0
- package/dist/components/tabset/index.js +68 -0
- package/dist/components/tag/index.d.ts +203 -0
- package/dist/components/tag/index.js +144 -0
- package/dist/components/toast/index.d.ts +271 -0
- package/dist/components/toast/index.js +116 -0
- package/dist/components/tooltip/index.d.ts +126 -0
- package/dist/components/tooltip/index.js +97 -0
- package/dist/components/tree/index.d.ts +317 -0
- package/dist/components/tree/index.js +251 -0
- package/dist/components/upload/index.d.ts +384 -0
- package/dist/components/upload/index.js +172 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +102 -0
- package/dist/services/base.d.ts +21 -0
- package/dist/services/base.js +42 -0
- package/dist/services/dialog.d.ts +41 -0
- package/dist/services/dialog.js +83 -0
- package/dist/services/index.d.ts +12 -0
- package/dist/services/loading.d.ts +21 -0
- package/dist/services/loading.js +41 -0
- package/dist/services/toast.d.ts +40 -0
- package/dist/services/toast.js +74 -0
- package/dist/styles/components/avatar.css +128 -0
- package/dist/styles/components/avatar.tokens.css +24 -0
- package/dist/styles/components/badge.css +237 -0
- package/dist/styles/components/button.css +454 -0
- package/dist/styles/components/button.tokens.css +56 -0
- package/dist/styles/components/capsule.css +120 -0
- package/dist/styles/components/capsule.tokens.css +27 -0
- package/dist/styles/components/card.css +192 -0
- package/dist/styles/components/checkbox.css +145 -0
- package/dist/styles/components/checkbox.tokens.css +26 -0
- package/dist/styles/components/code-editor.css +91 -0
- package/dist/styles/components/code-editor.tokens.css +24 -0
- package/dist/styles/components/code.css +153 -0
- package/dist/styles/components/code.tokens.css +29 -0
- package/dist/styles/components/collapse.css +62 -0
- package/dist/styles/components/collapse.tokens.css +20 -0
- package/dist/styles/components/dialog.css +106 -0
- package/dist/styles/components/dialog.tokens.css +24 -0
- package/dist/styles/components/divider.css +71 -0
- package/dist/styles/components/divider.tokens.css +21 -0
- package/dist/styles/components/drawer.css +143 -0
- package/dist/styles/components/drawer.tokens.css +22 -0
- package/dist/styles/components/filter.css +41 -0
- package/dist/styles/components/filter.tokens.css +14 -0
- package/dist/styles/components/form.css +220 -0
- package/dist/styles/components/form.tokens.css +15 -0
- package/dist/styles/components/input.css +445 -0
- package/dist/styles/components/input.tokens.css +41 -0
- package/dist/styles/components/layout.css +198 -0
- package/dist/styles/components/list-view.css +244 -0
- package/dist/styles/components/loading.css +76 -0
- package/dist/styles/components/loading.tokens.css +23 -0
- package/dist/styles/components/nav.css +48 -0
- package/dist/styles/components/notice.css +153 -0
- package/dist/styles/components/notice.tokens.css +17 -0
- package/dist/styles/components/notification.css +159 -0
- package/dist/styles/components/notification.tokens.css +37 -0
- package/dist/styles/components/page.css +473 -0
- package/dist/styles/components/pagination.css +297 -0
- package/dist/styles/components/pagination.tokens.css +32 -0
- package/dist/styles/components/panel.css +77 -0
- package/dist/styles/components/query-state.css +88 -0
- package/dist/styles/components/radio.css +271 -0
- package/dist/styles/components/radio.tokens.css +26 -0
- package/dist/styles/components/search.css +30 -0
- package/dist/styles/components/select.css +242 -0
- package/dist/styles/components/select.tokens.css +33 -0
- package/dist/styles/components/skeleton.css +60 -0
- package/dist/styles/components/skeleton.tokens.css +27 -0
- package/dist/styles/components/steps.css +157 -0
- package/dist/styles/components/steps.tokens.css +42 -0
- package/dist/styles/components/switch.css +165 -0
- package/dist/styles/components/switch.tokens.css +26 -0
- package/dist/styles/components/table.css +439 -0
- package/dist/styles/components/table.tokens.css +41 -0
- package/dist/styles/components/tabs.css +234 -0
- package/dist/styles/components/tabs.tokens.css +30 -0
- package/dist/styles/components/tag.css +200 -0
- package/dist/styles/components/tag.tokens.css +30 -0
- package/dist/styles/components/toast.css +150 -0
- package/dist/styles/components/toast.tokens.css +26 -0
- package/dist/styles/components/tooltip.css +89 -0
- package/dist/styles/components/tooltip.tokens.css +25 -0
- package/dist/styles/components/tree.css +139 -0
- package/dist/styles/components/tree.tokens.css +20 -0
- package/dist/styles/components/upload.css +150 -0
- package/dist/styles/components/upload.tokens.css +27 -0
- package/dist/styles/index.css +149 -0
- package/dist/styles/operations/collapse.css +84 -0
- package/dist/styles/operations/popup.css +189 -0
- package/dist/styles/operations/tabset.css +57 -0
- package/dist/utils/state-illustration.d.ts +31 -0
- package/dist/utils/state-illustration.js +156 -0
- package/package.json +62 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { defineComponent, createVNode } from "vue";
|
|
2
|
+
import { Tree } from "../tree/index.js";
|
|
3
|
+
const Nav = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "Nav",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
/** 导航形态:`tree`(默认,层级 + 箭头)/ `list`(扁平,无箭头占位) */
|
|
8
|
+
variant: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: "tree"
|
|
11
|
+
},
|
|
12
|
+
/** 导航节点(`list` 态传扁平数组);结构与 `Tree` 同 */
|
|
13
|
+
nodes: {
|
|
14
|
+
type: Array,
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
/** 节点主键:字段名或取值函数 */
|
|
18
|
+
rowKey: {
|
|
19
|
+
type: [String, Function],
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
/** 标签字段名(默认 'label') */
|
|
23
|
+
labelKey: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: "label"
|
|
26
|
+
},
|
|
27
|
+
/** 子节点字段名(默认 'children') */
|
|
28
|
+
childrenKey: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: "children"
|
|
31
|
+
},
|
|
32
|
+
/** 受控选中(行主键值) */
|
|
33
|
+
selected: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: void 0
|
|
36
|
+
},
|
|
37
|
+
/** 选中回调:给的是**节点对象**(不是主键值),口径同 `Tree` */
|
|
38
|
+
onSelect: {
|
|
39
|
+
type: Function,
|
|
40
|
+
default: void 0
|
|
41
|
+
},
|
|
42
|
+
/** 受控展开集(传了就完全受控) */
|
|
43
|
+
expandedKeys: {
|
|
44
|
+
type: Array,
|
|
45
|
+
default: void 0
|
|
46
|
+
},
|
|
47
|
+
/** 非受控展开初值 */
|
|
48
|
+
defaultExpandedKeys: {
|
|
49
|
+
type: Array,
|
|
50
|
+
default: () => []
|
|
51
|
+
},
|
|
52
|
+
onExpandChange: {
|
|
53
|
+
type: Function,
|
|
54
|
+
default: void 0
|
|
55
|
+
},
|
|
56
|
+
/** 行尾操作区(新增 / 重命名 / 删除…):悬浮显形 + 点击不冒泡,见 `Tree.renderActions` */
|
|
57
|
+
renderActions: {
|
|
58
|
+
type: Function,
|
|
59
|
+
default: void 0
|
|
60
|
+
},
|
|
61
|
+
/** 侧栏标题(可选;不传则只有导航体) */
|
|
62
|
+
title: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: void 0
|
|
65
|
+
},
|
|
66
|
+
/** 侧栏宽度(px 数字):只下发 `--mh-nav-width`;**不传则填满所在栏**(列宽归 `Page.Split` / 外层布局) */
|
|
67
|
+
width: {
|
|
68
|
+
type: Number,
|
|
69
|
+
default: void 0
|
|
70
|
+
},
|
|
71
|
+
/** 尺寸档:`md`(行高 30,默认)/ `sm`(紧凑 28) */
|
|
72
|
+
size: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: "md"
|
|
75
|
+
},
|
|
76
|
+
loading: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
default: false
|
|
79
|
+
},
|
|
80
|
+
/** 空态文案 */
|
|
81
|
+
empty: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: "暂无数据"
|
|
84
|
+
},
|
|
85
|
+
/** 空态操作按钮(如「新建」);与 `onEmptyAction` 同时传才渲染 */
|
|
86
|
+
emptyActionText: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: void 0
|
|
89
|
+
},
|
|
90
|
+
onEmptyAction: {
|
|
91
|
+
type: Function,
|
|
92
|
+
default: void 0
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* 错误态(truthy 即触发)。
|
|
96
|
+
*
|
|
97
|
+
* **构造器顺序同 `Tree.error`:`String` 必须排在 `Boolean` 前** —— 顺序写反时,成功态传的
|
|
98
|
+
* 空字符串会被 Vue 的布尔转换判成 `true`,侧栏永远停在错误态。
|
|
99
|
+
*/
|
|
100
|
+
error: {
|
|
101
|
+
type: [String, Boolean, Object, Number, Array],
|
|
102
|
+
default: void 0
|
|
103
|
+
},
|
|
104
|
+
/** 错误态标题(默认「加载失败」) */
|
|
105
|
+
errorTitle: {
|
|
106
|
+
type: String,
|
|
107
|
+
default: "加载失败"
|
|
108
|
+
},
|
|
109
|
+
/** 错误态操作按钮(如「重试」);与 `onErrorAction` 同时传才渲染 */
|
|
110
|
+
errorActionText: {
|
|
111
|
+
type: String,
|
|
112
|
+
default: void 0
|
|
113
|
+
},
|
|
114
|
+
onErrorAction: {
|
|
115
|
+
type: Function,
|
|
116
|
+
default: void 0
|
|
117
|
+
},
|
|
118
|
+
/** 右侧分隔线(侧栏与内容区之间;贴在页面容器里时用) */
|
|
119
|
+
bordered: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: false
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
setup(props, {
|
|
125
|
+
attrs
|
|
126
|
+
}) {
|
|
127
|
+
return () => {
|
|
128
|
+
const style = props.width === void 0 ? attrs.style : [attrs.style, {
|
|
129
|
+
"--mh-nav-width": `${props.width}px`
|
|
130
|
+
}];
|
|
131
|
+
return createVNode("nav", {
|
|
132
|
+
"class": ["mh-nav", props.variant === "list" ? "mh-nav--list" : "", props.bordered ? "mh-nav--bordered" : "", attrs.class].filter(Boolean).join(" "),
|
|
133
|
+
"style": style
|
|
134
|
+
}, [props.title ? createVNode("div", {
|
|
135
|
+
"class": "mh-nav__title"
|
|
136
|
+
}, [props.title]) : null, createVNode("div", {
|
|
137
|
+
"class": "mh-nav__body"
|
|
138
|
+
}, [createVNode(Tree, {
|
|
139
|
+
"nodes": props.nodes,
|
|
140
|
+
"rowKey": props.rowKey,
|
|
141
|
+
"labelKey": props.labelKey,
|
|
142
|
+
"childrenKey": props.childrenKey,
|
|
143
|
+
"selected": props.selected,
|
|
144
|
+
"onSelect": props.onSelect,
|
|
145
|
+
"expandedKeys": props.expandedKeys,
|
|
146
|
+
"defaultExpandedKeys": props.defaultExpandedKeys,
|
|
147
|
+
"onExpandChange": props.onExpandChange,
|
|
148
|
+
"renderActions": props.renderActions,
|
|
149
|
+
"size": props.size,
|
|
150
|
+
"loading": props.loading,
|
|
151
|
+
"empty": props.empty,
|
|
152
|
+
"emptyActionText": props.emptyActionText,
|
|
153
|
+
"onEmptyAction": props.onEmptyAction,
|
|
154
|
+
"error": props.error,
|
|
155
|
+
"errorTitle": props.errorTitle,
|
|
156
|
+
"errorActionText": props.errorActionText,
|
|
157
|
+
"onErrorAction": props.onErrorAction
|
|
158
|
+
}, null)])]);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
export {
|
|
163
|
+
Nav
|
|
164
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
2
|
+
export type NoticeTone = 'info' | 'success' | 'warning' | 'error';
|
|
3
|
+
/**
|
|
4
|
+
* 说明条 / 警告提示(**自建**,不封装 farris)。
|
|
5
|
+
*
|
|
6
|
+
* ## 为什么自建
|
|
7
|
+
*
|
|
8
|
+
* 它要的是**嵌在页面里的一行说明**(通栏、语义三件套「底 / 边 / 字」、操作为文字按钮)——
|
|
9
|
+
* 与 `Notification`(有标题与头像的卡片)、`Toast`(浮出后自己消失)都不是一回事,
|
|
10
|
+
* 三者的判据是**出现方式**(见 `Toast` 的「与 Notice / Notification 的判据」)。
|
|
11
|
+
* 上游没有可复用的形态,故自建并定为本包的一族。
|
|
12
|
+
*
|
|
13
|
+
* ## 口径(取自主题包 Alert 规范)
|
|
14
|
+
*
|
|
15
|
+
* - **警示 / 错误须常驻**(不渲染关闭按钮),只有通知类信息才可关闭 —— 故 `closable` 默认 `false`,
|
|
16
|
+
* 由消费方显式开启;
|
|
17
|
+
* - 位置:页面顶部通栏(页面主体顶部),静态展示、不随滚动消失。
|
|
18
|
+
*
|
|
19
|
+
* ## 两种排版(按内容量选)
|
|
20
|
+
*
|
|
21
|
+
* | 内容 | 写法 | 排布 |
|
|
22
|
+
* | --- | --- | --- |
|
|
23
|
+
* | 一行话 | 默认插槽 / `description` | 单行,图标与文字同行 |
|
|
24
|
+
* | 有标题 | `message` + `description`(或插槽) | **标题行 + 描述行**两行 |
|
|
25
|
+
*
|
|
26
|
+
* @example 可关闭的说明条(列表页顶部)
|
|
27
|
+
* <Notice closable onClose={() => (visible = false)} show-icon>值映射用于将来源向量转换为目标值。</Notice>
|
|
28
|
+
*
|
|
29
|
+
* @example 带标题与操作
|
|
30
|
+
* <Notice tone="warning" show-icon message="尚未完成实名认证" description="使用该服务前须完成认证"
|
|
31
|
+
* action="立即认证" :on-action="goAuth" />
|
|
32
|
+
*/
|
|
33
|
+
export declare const Notice: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
34
|
+
/** 语义类型;决定底/边/字三件套与图标 */
|
|
35
|
+
tone: {
|
|
36
|
+
type: PropType<NoticeTone>;
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
/** 标题行(给了就切换成「标题 + 描述」两行排版) */
|
|
40
|
+
message: {
|
|
41
|
+
type: StringConstructor;
|
|
42
|
+
default: undefined;
|
|
43
|
+
};
|
|
44
|
+
/** 描述行(无 `message` 时就是正文本身) */
|
|
45
|
+
description: {
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
default: undefined;
|
|
48
|
+
};
|
|
49
|
+
/** 是否显示语义图标 */
|
|
50
|
+
showIcon: {
|
|
51
|
+
type: BooleanConstructor;
|
|
52
|
+
default: boolean;
|
|
53
|
+
};
|
|
54
|
+
/** 是否渲染右上关闭按钮(规范:仅通知类信息可关闭) */
|
|
55
|
+
closable: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: boolean;
|
|
58
|
+
};
|
|
59
|
+
/** 自定义关闭位文案(缺省只出图标) */
|
|
60
|
+
closeText: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
default: undefined;
|
|
63
|
+
};
|
|
64
|
+
/** 右侧文字按钮文案(不传则不渲染操作位) */
|
|
65
|
+
action: {
|
|
66
|
+
type: StringConstructor;
|
|
67
|
+
default: undefined;
|
|
68
|
+
};
|
|
69
|
+
/** 文字按钮点击 */
|
|
70
|
+
onAction: {
|
|
71
|
+
type: PropType<() => void>;
|
|
72
|
+
default: undefined;
|
|
73
|
+
};
|
|
74
|
+
/** 关闭回调(配合 `closable`;关闭动作由消费方决定可见性) */
|
|
75
|
+
onClose: {
|
|
76
|
+
type: PropType<() => void>;
|
|
77
|
+
default: undefined;
|
|
78
|
+
};
|
|
79
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
80
|
+
/** 语义类型;决定底/边/字三件套与图标 */
|
|
81
|
+
tone: {
|
|
82
|
+
type: PropType<NoticeTone>;
|
|
83
|
+
default: string;
|
|
84
|
+
};
|
|
85
|
+
/** 标题行(给了就切换成「标题 + 描述」两行排版) */
|
|
86
|
+
message: {
|
|
87
|
+
type: StringConstructor;
|
|
88
|
+
default: undefined;
|
|
89
|
+
};
|
|
90
|
+
/** 描述行(无 `message` 时就是正文本身) */
|
|
91
|
+
description: {
|
|
92
|
+
type: StringConstructor;
|
|
93
|
+
default: undefined;
|
|
94
|
+
};
|
|
95
|
+
/** 是否显示语义图标 */
|
|
96
|
+
showIcon: {
|
|
97
|
+
type: BooleanConstructor;
|
|
98
|
+
default: boolean;
|
|
99
|
+
};
|
|
100
|
+
/** 是否渲染右上关闭按钮(规范:仅通知类信息可关闭) */
|
|
101
|
+
closable: {
|
|
102
|
+
type: BooleanConstructor;
|
|
103
|
+
default: boolean;
|
|
104
|
+
};
|
|
105
|
+
/** 自定义关闭位文案(缺省只出图标) */
|
|
106
|
+
closeText: {
|
|
107
|
+
type: StringConstructor;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
/** 右侧文字按钮文案(不传则不渲染操作位) */
|
|
111
|
+
action: {
|
|
112
|
+
type: StringConstructor;
|
|
113
|
+
default: undefined;
|
|
114
|
+
};
|
|
115
|
+
/** 文字按钮点击 */
|
|
116
|
+
onAction: {
|
|
117
|
+
type: PropType<() => void>;
|
|
118
|
+
default: undefined;
|
|
119
|
+
};
|
|
120
|
+
/** 关闭回调(配合 `closable`;关闭动作由消费方决定可见性) */
|
|
121
|
+
onClose: {
|
|
122
|
+
type: PropType<() => void>;
|
|
123
|
+
default: undefined;
|
|
124
|
+
};
|
|
125
|
+
}>> & Readonly<{}>, {
|
|
126
|
+
onClose: () => void;
|
|
127
|
+
message: string;
|
|
128
|
+
tone: NoticeTone;
|
|
129
|
+
closable: boolean;
|
|
130
|
+
description: string;
|
|
131
|
+
showIcon: boolean;
|
|
132
|
+
closeText: string;
|
|
133
|
+
action: string;
|
|
134
|
+
onAction: () => void;
|
|
135
|
+
}, SlotsType<{
|
|
136
|
+
default?: () => VNodeChild;
|
|
137
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { defineComponent, createVNode, Fragment, createTextVNode } from "vue";
|
|
2
|
+
import { Icon } from "@manohub/icon";
|
|
3
|
+
const TONE_ICON = {
|
|
4
|
+
info: "info",
|
|
5
|
+
success: "check",
|
|
6
|
+
warning: "alert",
|
|
7
|
+
error: "close"
|
|
8
|
+
};
|
|
9
|
+
const Notice = /* @__PURE__ */ defineComponent({
|
|
10
|
+
name: "Notice",
|
|
11
|
+
inheritAttrs: false,
|
|
12
|
+
props: {
|
|
13
|
+
/** 语义类型;决定底/边/字三件套与图标 */
|
|
14
|
+
tone: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "info"
|
|
17
|
+
},
|
|
18
|
+
/** 标题行(给了就切换成「标题 + 描述」两行排版) */
|
|
19
|
+
message: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: void 0
|
|
22
|
+
},
|
|
23
|
+
/** 描述行(无 `message` 时就是正文本身) */
|
|
24
|
+
description: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: void 0
|
|
27
|
+
},
|
|
28
|
+
/** 是否显示语义图标 */
|
|
29
|
+
showIcon: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
/** 是否渲染右上关闭按钮(规范:仅通知类信息可关闭) */
|
|
34
|
+
closable: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
/** 自定义关闭位文案(缺省只出图标) */
|
|
39
|
+
closeText: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
43
|
+
/** 右侧文字按钮文案(不传则不渲染操作位) */
|
|
44
|
+
action: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: void 0
|
|
47
|
+
},
|
|
48
|
+
/** 文字按钮点击 */
|
|
49
|
+
onAction: {
|
|
50
|
+
type: Function,
|
|
51
|
+
default: void 0
|
|
52
|
+
},
|
|
53
|
+
/** 关闭回调(配合 `closable`;关闭动作由消费方决定可见性) */
|
|
54
|
+
onClose: {
|
|
55
|
+
type: Function,
|
|
56
|
+
default: void 0
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
slots: Object,
|
|
60
|
+
setup(props, {
|
|
61
|
+
slots,
|
|
62
|
+
attrs
|
|
63
|
+
}) {
|
|
64
|
+
const body = () => {
|
|
65
|
+
const fallback = props.description ?? slots.default?.();
|
|
66
|
+
if (!props.message) return fallback;
|
|
67
|
+
return createVNode(Fragment, null, [createVNode("span", {
|
|
68
|
+
"class": "mh-notice__message"
|
|
69
|
+
}, [props.message]), createVNode("span", {
|
|
70
|
+
"class": "mh-notice__description"
|
|
71
|
+
}, [props.description ?? slots.default?.()])]);
|
|
72
|
+
};
|
|
73
|
+
return () => createVNode("div", {
|
|
74
|
+
"class": [attrs.class, "mh-notice", `mh-notice--${props.tone}`, props.message ? "mh-notice--titled" : ""].filter(Boolean).join(" "),
|
|
75
|
+
"role": "alert"
|
|
76
|
+
}, [props.showIcon ? createVNode(Icon, {
|
|
77
|
+
"name": TONE_ICON[props.tone],
|
|
78
|
+
"class": "mh-notice__icon"
|
|
79
|
+
}, null) : null, createVNode("div", {
|
|
80
|
+
"class": "mh-notice__body"
|
|
81
|
+
}, [body()]), props.action ? createVNode("button", {
|
|
82
|
+
"type": "button",
|
|
83
|
+
"class": "mh-notice__action",
|
|
84
|
+
"onClick": () => props.onAction?.()
|
|
85
|
+
}, [props.action]) : null, props.closable ? createVNode("button", {
|
|
86
|
+
"type": "button",
|
|
87
|
+
"class": "mh-notice__close",
|
|
88
|
+
"onClick": () => props.onClose?.()
|
|
89
|
+
}, [props.closeText ? createVNode("span", {
|
|
90
|
+
"class": "mh-notice__close-text"
|
|
91
|
+
}, [props.closeText]) : createVNode(Fragment, null, [createVNode(Icon, {
|
|
92
|
+
"name": "close",
|
|
93
|
+
"class": "mh-notice__close-icon"
|
|
94
|
+
}, null), createVNode("span", {
|
|
95
|
+
"class": "mh-notice__visually-hidden"
|
|
96
|
+
}, [createTextVNode("关闭")])])]) : null]);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
export {
|
|
100
|
+
Notice
|
|
101
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { type IconName } from '@manohub/icon';
|
|
2
|
+
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
3
|
+
/** 语义五档(`submit` 与 `success` 共用淡底,只换左边线 —— 与规范同构) */
|
|
4
|
+
export type NotificationTone = 'info' | 'success' | 'warning' | 'error' | 'submit';
|
|
5
|
+
/**
|
|
6
|
+
* 通知卡(**自绘**;标题 + 正文 + 图标 / 头像 / 标签 / 操作 / 关闭位)。
|
|
7
|
+
*
|
|
8
|
+
* ## 与 `Notice` 的判据(别互相顶替)
|
|
9
|
+
*
|
|
10
|
+
* - `Notice`(`.mh-notice*`)= **条状提示**:一行话 + 可选操作;
|
|
11
|
+
* - 本件(`.mh-notification*`)= **通知卡**:标题行(含关闭位)、可带头像与标签、多行正文。
|
|
12
|
+
*
|
|
13
|
+
* 类名前缀刻意不同:规范里两族都叫 `.notice*`,照抄会让本仓出现两套 `.mh-notice*` 互撞。
|
|
14
|
+
*
|
|
15
|
+
* ## 组合位(面各归其族,本件只给容器)
|
|
16
|
+
*
|
|
17
|
+
* - 图标:`icon` 布尔(按 `tone` 映射)或直接给图标名;
|
|
18
|
+
* - 头像:给 `avatar` 插槽 → 原样渲染(推荐塞 `<Avatar>`);给 `avatar` 字符串 → 渲染字标兜底盒;
|
|
19
|
+
* - 标签:`tags` 插槽里放标签族的 `<Tag shape="status" tone="error">`;
|
|
20
|
+
* - 操作:`actions` 插槽里放按钮族的 `<Button size="sm" variant="primary">`。
|
|
21
|
+
*
|
|
22
|
+
* 关闭是**受控**的:本件只回调 `onClose`,不自己隐藏(可见性归消费方,避免「点了没反应」与
|
|
23
|
+
* 「组件自己消失」两套口径)。`duration` 到点也只回调 —— 与 `Toast` 同一口径。
|
|
24
|
+
*
|
|
25
|
+
* @example 基础
|
|
26
|
+
* <Notification tone="warning" title="待办超期" closable @close="dismiss">3 个任务已超期</Notification>
|
|
27
|
+
*
|
|
28
|
+
* @example 图标 + 自动消失 + 头像 + 标签
|
|
29
|
+
* <Notification icon duration={4000} tone="info" title="审批通知" avatar="张" @close="dismiss">
|
|
30
|
+
* <Tag shape="status" tone="error">逾期</Tag>
|
|
31
|
+
* {{ actions: () => <Button size="sm" variant="primary">去处理</Button> }}
|
|
32
|
+
* </Notification>
|
|
33
|
+
*/
|
|
34
|
+
export declare const Notification: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
35
|
+
tone: {
|
|
36
|
+
type: PropType<NotificationTone>;
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
/** 标题(复杂标题走 `title` 插槽) */
|
|
40
|
+
title: {
|
|
41
|
+
type: StringConstructor;
|
|
42
|
+
default: undefined;
|
|
43
|
+
};
|
|
44
|
+
/** 前置图标:`true` 按 `tone` 映射,或直接给图标名 */
|
|
45
|
+
icon: {
|
|
46
|
+
type: PropType<boolean | IconName>;
|
|
47
|
+
default: boolean;
|
|
48
|
+
};
|
|
49
|
+
/** 头像兜底:首字母 / 短字(有 `avatar` 插槽时以插槽为准) */
|
|
50
|
+
avatar: {
|
|
51
|
+
type: StringConstructor;
|
|
52
|
+
default: undefined;
|
|
53
|
+
};
|
|
54
|
+
/** 是否显示关闭位(可见性由消费方管,本件只回调) */
|
|
55
|
+
closable: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: boolean;
|
|
58
|
+
};
|
|
59
|
+
/** 自动关闭毫秒数(`0` = 不自动;到点**只回调** `onClose`,不移除自己) */
|
|
60
|
+
duration: {
|
|
61
|
+
type: NumberConstructor;
|
|
62
|
+
default: number;
|
|
63
|
+
};
|
|
64
|
+
/** 关闭回调(关闭位与 `duration` 到点都走它) */
|
|
65
|
+
onClose: {
|
|
66
|
+
type: PropType<() => void>;
|
|
67
|
+
default: undefined;
|
|
68
|
+
};
|
|
69
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
70
|
+
tone: {
|
|
71
|
+
type: PropType<NotificationTone>;
|
|
72
|
+
default: string;
|
|
73
|
+
};
|
|
74
|
+
/** 标题(复杂标题走 `title` 插槽) */
|
|
75
|
+
title: {
|
|
76
|
+
type: StringConstructor;
|
|
77
|
+
default: undefined;
|
|
78
|
+
};
|
|
79
|
+
/** 前置图标:`true` 按 `tone` 映射,或直接给图标名 */
|
|
80
|
+
icon: {
|
|
81
|
+
type: PropType<boolean | IconName>;
|
|
82
|
+
default: boolean;
|
|
83
|
+
};
|
|
84
|
+
/** 头像兜底:首字母 / 短字(有 `avatar` 插槽时以插槽为准) */
|
|
85
|
+
avatar: {
|
|
86
|
+
type: StringConstructor;
|
|
87
|
+
default: undefined;
|
|
88
|
+
};
|
|
89
|
+
/** 是否显示关闭位(可见性由消费方管,本件只回调) */
|
|
90
|
+
closable: {
|
|
91
|
+
type: BooleanConstructor;
|
|
92
|
+
default: boolean;
|
|
93
|
+
};
|
|
94
|
+
/** 自动关闭毫秒数(`0` = 不自动;到点**只回调** `onClose`,不移除自己) */
|
|
95
|
+
duration: {
|
|
96
|
+
type: NumberConstructor;
|
|
97
|
+
default: number;
|
|
98
|
+
};
|
|
99
|
+
/** 关闭回调(关闭位与 `duration` 到点都走它) */
|
|
100
|
+
onClose: {
|
|
101
|
+
type: PropType<() => void>;
|
|
102
|
+
default: undefined;
|
|
103
|
+
};
|
|
104
|
+
}>> & Readonly<{}>, {
|
|
105
|
+
icon: boolean | "filter" | "copy" | "help" | "table" | "menu" | "search" | "link" | "delete" | "image" | "close" | "key" | "page-title" | "loading" | "info" | "alert" | "chevron-left" | "chevron-right" | "chevron-down" | "chevron-up" | "check" | "user" | "download" | "back" | "folder" | "folder-open" | "file" | "file-code" | "file-json" | "file-text" | "terminal" | "shield" | "wrench" | "plus" | "bell" | "settings" | "logout" | "home" | "workbench" | "grid-dots" | "heart" | "heart-filled" | "edit" | "refresh" | "upload" | "save" | "more" | "eye" | "external-link" | "minus" | "plus-circle" | "close-circle" | "list" | "calendar" | "clock" | "lock" | "unlock" | "users" | "archive" | "package" | "plug" | "branch" | "tag" | "sparkles" | "shield-check" | "shield-alert" | "history";
|
|
106
|
+
title: string;
|
|
107
|
+
onClose: () => void;
|
|
108
|
+
tone: NotificationTone;
|
|
109
|
+
closable: boolean;
|
|
110
|
+
avatar: string;
|
|
111
|
+
duration: number;
|
|
112
|
+
}, SlotsType<{
|
|
113
|
+
default?: () => VNodeChild;
|
|
114
|
+
title?: () => VNodeChild;
|
|
115
|
+
avatar?: () => VNodeChild;
|
|
116
|
+
tags?: () => VNodeChild;
|
|
117
|
+
actions?: () => VNodeChild;
|
|
118
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { defineComponent, onMounted, onBeforeUnmount, createVNode } from "vue";
|
|
2
|
+
import { Icon } from "@manohub/icon";
|
|
3
|
+
const TONE_ICON = {
|
|
4
|
+
info: "info",
|
|
5
|
+
success: "check",
|
|
6
|
+
warning: "alert",
|
|
7
|
+
error: "close",
|
|
8
|
+
submit: "check"
|
|
9
|
+
};
|
|
10
|
+
const Notification = /* @__PURE__ */ defineComponent({
|
|
11
|
+
name: "Notification",
|
|
12
|
+
inheritAttrs: false,
|
|
13
|
+
props: {
|
|
14
|
+
tone: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "info"
|
|
17
|
+
},
|
|
18
|
+
/** 标题(复杂标题走 `title` 插槽) */
|
|
19
|
+
title: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: void 0
|
|
22
|
+
},
|
|
23
|
+
/** 前置图标:`true` 按 `tone` 映射,或直接给图标名 */
|
|
24
|
+
icon: {
|
|
25
|
+
type: [Boolean, String],
|
|
26
|
+
default: false
|
|
27
|
+
},
|
|
28
|
+
/** 头像兜底:首字母 / 短字(有 `avatar` 插槽时以插槽为准) */
|
|
29
|
+
avatar: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: void 0
|
|
32
|
+
},
|
|
33
|
+
/** 是否显示关闭位(可见性由消费方管,本件只回调) */
|
|
34
|
+
closable: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
/** 自动关闭毫秒数(`0` = 不自动;到点**只回调** `onClose`,不移除自己) */
|
|
39
|
+
duration: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 0
|
|
42
|
+
},
|
|
43
|
+
/** 关闭回调(关闭位与 `duration` 到点都走它) */
|
|
44
|
+
onClose: {
|
|
45
|
+
type: Function,
|
|
46
|
+
default: void 0
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
slots: Object,
|
|
50
|
+
setup(props, {
|
|
51
|
+
slots,
|
|
52
|
+
attrs
|
|
53
|
+
}) {
|
|
54
|
+
let timer;
|
|
55
|
+
onMounted(() => {
|
|
56
|
+
if (props.duration > 0) timer = setTimeout(() => props.onClose?.(), props.duration);
|
|
57
|
+
});
|
|
58
|
+
onBeforeUnmount(() => {
|
|
59
|
+
if (timer) clearTimeout(timer);
|
|
60
|
+
});
|
|
61
|
+
return () => {
|
|
62
|
+
const hasTitleRow = Boolean(slots.title || props.title || props.closable);
|
|
63
|
+
const iconName = props.icon === true ? TONE_ICON[props.tone] : typeof props.icon === "string" ? props.icon : void 0;
|
|
64
|
+
return createVNode("div", {
|
|
65
|
+
"class": ["mh-notification", `mh-notification--${props.tone}`, attrs.class].filter(Boolean).join(" "),
|
|
66
|
+
"style": attrs.style
|
|
67
|
+
}, [slots.avatar ? slots.avatar() : props.avatar ? createVNode("span", {
|
|
68
|
+
"class": "mh-notification__avatar"
|
|
69
|
+
}, [props.avatar]) : null, createVNode("div", {
|
|
70
|
+
"class": "mh-notification__body"
|
|
71
|
+
}, [hasTitleRow ? createVNode("div", {
|
|
72
|
+
"class": "mh-notification__title"
|
|
73
|
+
}, [iconName ? createVNode(Icon, {
|
|
74
|
+
"name": iconName,
|
|
75
|
+
"class": "mh-notification__icon"
|
|
76
|
+
}, null) : null, createVNode("span", {
|
|
77
|
+
"class": "mh-notification__title-text"
|
|
78
|
+
}, [slots.title ? slots.title() : props.title]), props.closable ? createVNode("button", {
|
|
79
|
+
"type": "button",
|
|
80
|
+
"class": "mh-notification__close",
|
|
81
|
+
"aria-label": "关闭",
|
|
82
|
+
"onClick": () => props.onClose?.()
|
|
83
|
+
}, [createVNode(Icon, {
|
|
84
|
+
"name": "close",
|
|
85
|
+
"size": 12,
|
|
86
|
+
"class": "mh-notification__close-icon"
|
|
87
|
+
}, null)]) : null]) : null, createVNode("div", {
|
|
88
|
+
"class": "mh-notification__text"
|
|
89
|
+
}, [slots.default?.()]), slots.tags ? createVNode("div", {
|
|
90
|
+
"class": "mh-notification__tags"
|
|
91
|
+
}, [slots.tags()]) : null, slots.actions ? createVNode("div", {
|
|
92
|
+
"class": "mh-notification__actions"
|
|
93
|
+
}, [slots.actions()]) : null])]);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
export {
|
|
98
|
+
Notification
|
|
99
|
+
};
|