@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,207 @@
|
|
|
1
|
+
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
2
|
+
/** 三态种类(插画 / 操作区插槽会收到它,便于按状态给不同内容) */
|
|
3
|
+
export type QueryStateKind = 'empty' | 'error';
|
|
4
|
+
export interface QueryStateProps {
|
|
5
|
+
/** 加载中 → 骨架屏 */
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
/** 错误态(truthy 即触发) */
|
|
8
|
+
error?: unknown;
|
|
9
|
+
/** 空态:true 用默认文案,string 作为空态标题 */
|
|
10
|
+
empty?: boolean | string;
|
|
11
|
+
/** 空态副文案 */
|
|
12
|
+
emptyDescription?: string;
|
|
13
|
+
/** 错误态标题(默认「加载失败」) */
|
|
14
|
+
errorTitle?: string;
|
|
15
|
+
/** 错误态副文案 */
|
|
16
|
+
errorDescription?: string;
|
|
17
|
+
/** 自定义插画资源 URL(不传用内建插画;整幅自定义图形请用 `illustration` 插槽) */
|
|
18
|
+
illustration?: string;
|
|
19
|
+
/**
|
|
20
|
+
* 空态操作按钮(如「新建」);与 `onEmptyAction` 同时传才渲染。
|
|
21
|
+
*
|
|
22
|
+
* 按钮就是本包的 `Button`(`variant="primary"`)—— 空态 / 错误态的主操作与全站按钮同族,
|
|
23
|
+
* 应用**不需要**再注入任何东西;换外观走主题令牌,换结构走 `actions` 插槽。
|
|
24
|
+
*/
|
|
25
|
+
emptyActionText?: string;
|
|
26
|
+
onEmptyAction?: () => void;
|
|
27
|
+
/** 错误态操作按钮(如「重试」);与 `onErrorAction` 同时传才渲染(同上) */
|
|
28
|
+
errorActionText?: string;
|
|
29
|
+
onErrorAction?: () => void;
|
|
30
|
+
/** 骨架屏条数 */
|
|
31
|
+
skeletonRows?: number;
|
|
32
|
+
/** 骨架屏条高(px) */
|
|
33
|
+
skeletonRowHeight?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* loading / empty / error 三态容器(自建,替代各 app 手拼的 empty-state + skeleton)。
|
|
37
|
+
*
|
|
38
|
+
* 三态互斥,优先级 loading > error > empty > default 插槽。
|
|
39
|
+
*
|
|
40
|
+
* ## 视觉构成(三态非加载态一致)
|
|
41
|
+
*
|
|
42
|
+
* **插画 → 主文案 → 副文案 → 操作区**,整块垂直居中、留白由令牌给(`.mh-state`)。
|
|
43
|
+
* 插画默认取内建件(设计交付的「空状态」/「错误」两张图,原样内联在 `utils/state-illustration.ts`),
|
|
44
|
+
* 可用 `illustration` 属性换成图片资源、或用 `illustration` 插槽整幅自定义;操作区同理有 `actions` 插槽。
|
|
45
|
+
*
|
|
46
|
+
* 文案 props 可覆盖(i18n 由消费方传 t() 结果;本包不内置文案)。
|
|
47
|
+
*
|
|
48
|
+
* @example 空态带 CTA、错误态带重试
|
|
49
|
+
* <QueryState
|
|
50
|
+
* loading={isLoading}
|
|
51
|
+
* error={loadError.value}
|
|
52
|
+
* errorActionText={t('common.retry')}
|
|
53
|
+
* onErrorAction={() => reload()}
|
|
54
|
+
* empty={topics.length === 0}
|
|
55
|
+
* empty={t('topic.empty')}
|
|
56
|
+
* emptyDescription={t('topic.emptyDescription')}
|
|
57
|
+
* emptyActionText={t('topic.create')}
|
|
58
|
+
* onEmptyAction={() => openCreate()}>
|
|
59
|
+
* <TopicGrid topics={topics} />
|
|
60
|
+
* </QueryState>
|
|
61
|
+
*/
|
|
62
|
+
export declare const QueryState: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
63
|
+
loading: {
|
|
64
|
+
type: BooleanConstructor;
|
|
65
|
+
default: boolean;
|
|
66
|
+
};
|
|
67
|
+
error: {
|
|
68
|
+
type: PropType<any>;
|
|
69
|
+
default: undefined;
|
|
70
|
+
};
|
|
71
|
+
empty: {
|
|
72
|
+
type: PropType<boolean | string>;
|
|
73
|
+
default: boolean;
|
|
74
|
+
};
|
|
75
|
+
emptyDescription: {
|
|
76
|
+
type: StringConstructor;
|
|
77
|
+
default: undefined;
|
|
78
|
+
};
|
|
79
|
+
errorTitle: {
|
|
80
|
+
type: StringConstructor;
|
|
81
|
+
default: string;
|
|
82
|
+
};
|
|
83
|
+
errorDescription: {
|
|
84
|
+
type: StringConstructor;
|
|
85
|
+
default: undefined;
|
|
86
|
+
};
|
|
87
|
+
illustration: {
|
|
88
|
+
type: StringConstructor;
|
|
89
|
+
default: undefined;
|
|
90
|
+
};
|
|
91
|
+
/** 插画宽度(数字按 px;高度按比例自适应)。缺省用样式层默认宽度 */
|
|
92
|
+
illustrationSize: {
|
|
93
|
+
type: PropType<number | string>;
|
|
94
|
+
default: undefined;
|
|
95
|
+
};
|
|
96
|
+
emptyActionText: {
|
|
97
|
+
type: StringConstructor;
|
|
98
|
+
default: undefined;
|
|
99
|
+
};
|
|
100
|
+
onEmptyAction: {
|
|
101
|
+
type: PropType<() => void>;
|
|
102
|
+
default: undefined;
|
|
103
|
+
};
|
|
104
|
+
errorActionText: {
|
|
105
|
+
type: StringConstructor;
|
|
106
|
+
default: undefined;
|
|
107
|
+
};
|
|
108
|
+
onErrorAction: {
|
|
109
|
+
type: PropType<() => void>;
|
|
110
|
+
default: undefined;
|
|
111
|
+
};
|
|
112
|
+
skeletonRows: {
|
|
113
|
+
type: NumberConstructor;
|
|
114
|
+
default: number;
|
|
115
|
+
};
|
|
116
|
+
skeletonRowHeight: {
|
|
117
|
+
type: NumberConstructor;
|
|
118
|
+
default: number;
|
|
119
|
+
};
|
|
120
|
+
}>, () => string | number | boolean | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
121
|
+
[key: string]: any;
|
|
122
|
+
}> | import("vue").VNodeArrayChildren | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
123
|
+
loading: {
|
|
124
|
+
type: BooleanConstructor;
|
|
125
|
+
default: boolean;
|
|
126
|
+
};
|
|
127
|
+
error: {
|
|
128
|
+
type: PropType<any>;
|
|
129
|
+
default: undefined;
|
|
130
|
+
};
|
|
131
|
+
empty: {
|
|
132
|
+
type: PropType<boolean | string>;
|
|
133
|
+
default: boolean;
|
|
134
|
+
};
|
|
135
|
+
emptyDescription: {
|
|
136
|
+
type: StringConstructor;
|
|
137
|
+
default: undefined;
|
|
138
|
+
};
|
|
139
|
+
errorTitle: {
|
|
140
|
+
type: StringConstructor;
|
|
141
|
+
default: string;
|
|
142
|
+
};
|
|
143
|
+
errorDescription: {
|
|
144
|
+
type: StringConstructor;
|
|
145
|
+
default: undefined;
|
|
146
|
+
};
|
|
147
|
+
illustration: {
|
|
148
|
+
type: StringConstructor;
|
|
149
|
+
default: undefined;
|
|
150
|
+
};
|
|
151
|
+
/** 插画宽度(数字按 px;高度按比例自适应)。缺省用样式层默认宽度 */
|
|
152
|
+
illustrationSize: {
|
|
153
|
+
type: PropType<number | string>;
|
|
154
|
+
default: undefined;
|
|
155
|
+
};
|
|
156
|
+
emptyActionText: {
|
|
157
|
+
type: StringConstructor;
|
|
158
|
+
default: undefined;
|
|
159
|
+
};
|
|
160
|
+
onEmptyAction: {
|
|
161
|
+
type: PropType<() => void>;
|
|
162
|
+
default: undefined;
|
|
163
|
+
};
|
|
164
|
+
errorActionText: {
|
|
165
|
+
type: StringConstructor;
|
|
166
|
+
default: undefined;
|
|
167
|
+
};
|
|
168
|
+
onErrorAction: {
|
|
169
|
+
type: PropType<() => void>;
|
|
170
|
+
default: undefined;
|
|
171
|
+
};
|
|
172
|
+
skeletonRows: {
|
|
173
|
+
type: NumberConstructor;
|
|
174
|
+
default: number;
|
|
175
|
+
};
|
|
176
|
+
skeletonRowHeight: {
|
|
177
|
+
type: NumberConstructor;
|
|
178
|
+
default: number;
|
|
179
|
+
};
|
|
180
|
+
}>> & Readonly<{}>, {
|
|
181
|
+
error: any;
|
|
182
|
+
loading: boolean;
|
|
183
|
+
empty: string | boolean;
|
|
184
|
+
emptyDescription: string;
|
|
185
|
+
errorTitle: string;
|
|
186
|
+
errorDescription: string;
|
|
187
|
+
illustration: string;
|
|
188
|
+
illustrationSize: string | number;
|
|
189
|
+
emptyActionText: string;
|
|
190
|
+
onEmptyAction: () => void;
|
|
191
|
+
errorActionText: string;
|
|
192
|
+
onErrorAction: () => void;
|
|
193
|
+
skeletonRows: number;
|
|
194
|
+
skeletonRowHeight: number;
|
|
195
|
+
}, SlotsType<{
|
|
196
|
+
default?: () => VNodeChild;
|
|
197
|
+
empty?: () => VNodeChild;
|
|
198
|
+
error?: () => VNodeChild;
|
|
199
|
+
/** 自定义插画;入参为当前状态种类 */
|
|
200
|
+
illustration?: (ctx: {
|
|
201
|
+
kind: QueryStateKind;
|
|
202
|
+
}) => VNodeChild;
|
|
203
|
+
/** 自定义操作区(按钮组);不传则按 *ActionText / on*Action 渲染单个主按钮 */
|
|
204
|
+
actions?: (ctx: {
|
|
205
|
+
kind: QueryStateKind;
|
|
206
|
+
}) => VNodeChild;
|
|
207
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { defineComponent, createVNode, Fragment } from "vue";
|
|
2
|
+
import { Button } from "../button/index.js";
|
|
3
|
+
import { STATE_ILLUSTRATION_ERROR_SVG, STATE_ILLUSTRATION_EMPTY_SVG } from "../../utils/state-illustration.js";
|
|
4
|
+
const BUILT_IN_ILLUSTRATION = {
|
|
5
|
+
empty: STATE_ILLUSTRATION_EMPTY_SVG,
|
|
6
|
+
error: STATE_ILLUSTRATION_ERROR_SVG
|
|
7
|
+
};
|
|
8
|
+
const QueryState = /* @__PURE__ */ defineComponent({
|
|
9
|
+
name: "QueryState",
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
props: {
|
|
12
|
+
loading: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false
|
|
15
|
+
},
|
|
16
|
+
/*
|
|
17
|
+
* truthy 即触发错误态;type 用构造器数组承载 unknown(`type: null` 在 vue-tsc 下被推断为 undefined)。
|
|
18
|
+
* **`String` 必须排在 `Boolean` 前**:否则 Vue 的布尔转换会把空字符串 `''` 转成 `true`,
|
|
19
|
+
* 成功态(`error={''}`)也会被判成错误态。
|
|
20
|
+
*/
|
|
21
|
+
error: {
|
|
22
|
+
type: [String, Boolean, Object, Number, Array],
|
|
23
|
+
default: void 0
|
|
24
|
+
},
|
|
25
|
+
empty: {
|
|
26
|
+
type: [Boolean, String],
|
|
27
|
+
default: false
|
|
28
|
+
},
|
|
29
|
+
emptyDescription: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: void 0
|
|
32
|
+
},
|
|
33
|
+
errorTitle: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "加载失败"
|
|
36
|
+
},
|
|
37
|
+
errorDescription: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: void 0
|
|
40
|
+
},
|
|
41
|
+
illustration: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: void 0
|
|
44
|
+
},
|
|
45
|
+
/** 插画宽度(数字按 px;高度按比例自适应)。缺省用样式层默认宽度 */
|
|
46
|
+
illustrationSize: {
|
|
47
|
+
type: [Number, String],
|
|
48
|
+
default: void 0
|
|
49
|
+
},
|
|
50
|
+
emptyActionText: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: void 0
|
|
53
|
+
},
|
|
54
|
+
onEmptyAction: {
|
|
55
|
+
type: Function,
|
|
56
|
+
default: void 0
|
|
57
|
+
},
|
|
58
|
+
errorActionText: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: void 0
|
|
61
|
+
},
|
|
62
|
+
onErrorAction: {
|
|
63
|
+
type: Function,
|
|
64
|
+
default: void 0
|
|
65
|
+
},
|
|
66
|
+
skeletonRows: {
|
|
67
|
+
type: Number,
|
|
68
|
+
default: 6
|
|
69
|
+
},
|
|
70
|
+
skeletonRowHeight: {
|
|
71
|
+
type: Number,
|
|
72
|
+
default: 40
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
slots: Object,
|
|
76
|
+
setup(props, {
|
|
77
|
+
slots,
|
|
78
|
+
attrs
|
|
79
|
+
}) {
|
|
80
|
+
const illustrationWidth = () => props.illustrationSize === void 0 ? void 0 : {
|
|
81
|
+
width: typeof props.illustrationSize === "number" ? `${props.illustrationSize}px` : props.illustrationSize,
|
|
82
|
+
height: "auto"
|
|
83
|
+
};
|
|
84
|
+
const renderIllustration = (kind) => {
|
|
85
|
+
if (slots.illustration) {
|
|
86
|
+
return slots.illustration({
|
|
87
|
+
kind
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (props.illustration) {
|
|
91
|
+
return createVNode("img", {
|
|
92
|
+
"class": "mh-state-illustration",
|
|
93
|
+
"src": props.illustration,
|
|
94
|
+
"alt": "",
|
|
95
|
+
"style": illustrationWidth()
|
|
96
|
+
}, null);
|
|
97
|
+
}
|
|
98
|
+
return createVNode("span", {
|
|
99
|
+
"class": "mh-state-illustration",
|
|
100
|
+
"style": illustrationWidth(),
|
|
101
|
+
"aria-hidden": "true",
|
|
102
|
+
"innerHTML": BUILT_IN_ILLUSTRATION[kind]
|
|
103
|
+
}, null);
|
|
104
|
+
};
|
|
105
|
+
const renderActions = (kind, actionText, onAction) => {
|
|
106
|
+
if (slots.actions) {
|
|
107
|
+
return slots.actions({
|
|
108
|
+
kind
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (!actionText || !onAction) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
return (
|
|
115
|
+
// 文案走函数 slot 传入而非直接写子节点:直传字符串会触发 Vue 的
|
|
116
|
+
// 「Non-function value encountered for default slot」告警(同 Panel 的处理)
|
|
117
|
+
createVNode(Button, {
|
|
118
|
+
"variant": "primary",
|
|
119
|
+
"onClick": onAction
|
|
120
|
+
}, {
|
|
121
|
+
default: () => actionText
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
const renderState = (config) => {
|
|
126
|
+
const actions = renderActions(config.kind, config.actionText, config.onAction);
|
|
127
|
+
return createVNode("div", {
|
|
128
|
+
"class": "mh-state",
|
|
129
|
+
"style": attrs.style
|
|
130
|
+
}, [config.slotFn ? config.slotFn() : createVNode(Fragment, null, [renderIllustration(config.kind), createVNode("div", {
|
|
131
|
+
"class": "mh-state-title"
|
|
132
|
+
}, [config.title]), config.description ? createVNode("div", {
|
|
133
|
+
"class": "mh-state-description"
|
|
134
|
+
}, [config.description]) : null, actions ? createVNode("div", {
|
|
135
|
+
"class": "mh-state-actions"
|
|
136
|
+
}, [actions]) : null])]);
|
|
137
|
+
};
|
|
138
|
+
return () => {
|
|
139
|
+
if (props.loading) {
|
|
140
|
+
return createVNode("div", {
|
|
141
|
+
"class": "mh-state"
|
|
142
|
+
}, [createVNode("div", {
|
|
143
|
+
"class": "mh-state-skeletons"
|
|
144
|
+
}, [Array.from({
|
|
145
|
+
length: props.skeletonRows
|
|
146
|
+
}).map((_, i) => createVNode("div", {
|
|
147
|
+
"key": i,
|
|
148
|
+
"class": "mh-skeleton mh-skeleton--block",
|
|
149
|
+
"style": {
|
|
150
|
+
height: `${props.skeletonRowHeight}px`
|
|
151
|
+
}
|
|
152
|
+
}, null))])]);
|
|
153
|
+
}
|
|
154
|
+
if (props.error) {
|
|
155
|
+
return renderState({
|
|
156
|
+
kind: "error",
|
|
157
|
+
title: props.errorTitle,
|
|
158
|
+
description: props.errorDescription,
|
|
159
|
+
slotFn: slots.error,
|
|
160
|
+
actionText: props.errorActionText,
|
|
161
|
+
onAction: props.onErrorAction
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (props.empty) {
|
|
165
|
+
const title = typeof props.empty === "string" ? props.empty : "暂无数据";
|
|
166
|
+
return renderState({
|
|
167
|
+
kind: "empty",
|
|
168
|
+
title,
|
|
169
|
+
description: props.emptyDescription,
|
|
170
|
+
slotFn: slots.empty,
|
|
171
|
+
actionText: props.emptyActionText,
|
|
172
|
+
onAction: props.onEmptyAction
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return slots.default?.() ?? null;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
export {
|
|
180
|
+
QueryState
|
|
181
|
+
};
|