@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,199 @@
|
|
|
1
|
+
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
2
|
+
import { type IconName } from '@manohub/icon';
|
|
3
|
+
import type { ControlSize } from '../control-size';
|
|
4
|
+
export interface StepsItem {
|
|
5
|
+
/** 步骤标题 */
|
|
6
|
+
title: string;
|
|
7
|
+
/** 节点内的图标名(缺省显示序号;已完成步一律显示 `check`) */
|
|
8
|
+
icon?: IconName;
|
|
9
|
+
}
|
|
10
|
+
export type StepsVariant = 'node' | 'bar';
|
|
11
|
+
/**
|
|
12
|
+
* 步骤条(**自绘**;节点式 + 燕尾段式 + 进度条)。
|
|
13
|
+
*
|
|
14
|
+
* ## 状态怎么给
|
|
15
|
+
*
|
|
16
|
+
* 只认一个数:`current`(当前步下标,0 起)。**小于它的都是已完成**、大于它是未开始 —— 由本件按下标算出
|
|
17
|
+
* `--done` / `--current` 与连线是否 `--active`,调用方不必自己拼类名。
|
|
18
|
+
*
|
|
19
|
+
* 连线取「**当前步之后那一段**」为活动档(规范实测取向):已完成步之后的连线仍是灰的,别做成"已完成段全蓝"。
|
|
20
|
+
*
|
|
21
|
+
* ## 两种形态的判据
|
|
22
|
+
*
|
|
23
|
+
* - `variant="node"`(缺省):节点 + 同行标题 + 点线折角箭头,段长弹性 —— 步骤数少、要给每步留标题时用;
|
|
24
|
+
* - `variant="bar"`:燕尾段条(定宽 140、相邻重叠 10),只有当前段是主色 —— 段数固定、像进度分段时用。
|
|
25
|
+
*
|
|
26
|
+
* 步骤条**不可点**(规范未演示跳步):要跳转请在步骤旁自己放操作,或改用别的件。
|
|
27
|
+
*
|
|
28
|
+
* 进度条(`Steps.Progress`)单列,用于"跑到百分之几"这类无步骤语义的场景。
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* <Steps :steps="[{title:'填单'},{title:'审批'},{title:'完成'}]" :current="1" />
|
|
32
|
+
*
|
|
33
|
+
* @example 燕尾段式
|
|
34
|
+
* <Steps variant="bar" :steps="[{title:'支付明细'},{title:'确认'}]" :current="0" />
|
|
35
|
+
*/
|
|
36
|
+
export declare const Steps: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
37
|
+
/** 步骤表(标题 + 可选节点图标) */
|
|
38
|
+
steps: {
|
|
39
|
+
type: PropType<StepsItem[]>;
|
|
40
|
+
default: () => never[];
|
|
41
|
+
};
|
|
42
|
+
/** 当前步下标(0 起);小于它的算已完成 */
|
|
43
|
+
current: {
|
|
44
|
+
type: NumberConstructor;
|
|
45
|
+
default: number;
|
|
46
|
+
};
|
|
47
|
+
variant: {
|
|
48
|
+
type: PropType<StepsVariant>;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
/** 尺寸档(只覆盖 `--ui-steps-*` 令牌) */
|
|
52
|
+
size: {
|
|
53
|
+
type: PropType<ControlSize>;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
56
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
57
|
+
/** 步骤表(标题 + 可选节点图标) */
|
|
58
|
+
steps: {
|
|
59
|
+
type: PropType<StepsItem[]>;
|
|
60
|
+
default: () => never[];
|
|
61
|
+
};
|
|
62
|
+
/** 当前步下标(0 起);小于它的算已完成 */
|
|
63
|
+
current: {
|
|
64
|
+
type: NumberConstructor;
|
|
65
|
+
default: number;
|
|
66
|
+
};
|
|
67
|
+
variant: {
|
|
68
|
+
type: PropType<StepsVariant>;
|
|
69
|
+
default: string;
|
|
70
|
+
};
|
|
71
|
+
/** 尺寸档(只覆盖 `--ui-steps-*` 令牌) */
|
|
72
|
+
size: {
|
|
73
|
+
type: PropType<ControlSize>;
|
|
74
|
+
default: string;
|
|
75
|
+
};
|
|
76
|
+
}>> & Readonly<{}>, {
|
|
77
|
+
size: ControlSize;
|
|
78
|
+
variant: StepsVariant;
|
|
79
|
+
current: number;
|
|
80
|
+
steps: StepsItem[];
|
|
81
|
+
}, SlotsType<{
|
|
82
|
+
title?: (context: {
|
|
83
|
+
item: StepsItem;
|
|
84
|
+
index: number;
|
|
85
|
+
}) => VNodeChild;
|
|
86
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
87
|
+
export declare const StepsCompound: {
|
|
88
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("vue").ExtractPropTypes<{
|
|
89
|
+
/** 步骤表(标题 + 可选节点图标) */
|
|
90
|
+
steps: {
|
|
91
|
+
type: PropType<StepsItem[]>;
|
|
92
|
+
default: () => never[];
|
|
93
|
+
};
|
|
94
|
+
/** 当前步下标(0 起);小于它的算已完成 */
|
|
95
|
+
current: {
|
|
96
|
+
type: NumberConstructor;
|
|
97
|
+
default: number;
|
|
98
|
+
};
|
|
99
|
+
variant: {
|
|
100
|
+
type: PropType<StepsVariant>;
|
|
101
|
+
default: string;
|
|
102
|
+
};
|
|
103
|
+
/** 尺寸档(只覆盖 `--ui-steps-*` 令牌) */
|
|
104
|
+
size: {
|
|
105
|
+
type: PropType<ControlSize>;
|
|
106
|
+
default: string;
|
|
107
|
+
};
|
|
108
|
+
}>> & Readonly<{}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {
|
|
109
|
+
size: ControlSize;
|
|
110
|
+
variant: StepsVariant;
|
|
111
|
+
current: number;
|
|
112
|
+
steps: StepsItem[];
|
|
113
|
+
}, true, {}, SlotsType<{
|
|
114
|
+
title?: (context: {
|
|
115
|
+
item: StepsItem;
|
|
116
|
+
index: number;
|
|
117
|
+
}) => VNodeChild;
|
|
118
|
+
}>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
119
|
+
P: {};
|
|
120
|
+
B: {};
|
|
121
|
+
D: {};
|
|
122
|
+
C: {};
|
|
123
|
+
M: {};
|
|
124
|
+
Defaults: {};
|
|
125
|
+
}, Readonly<import("vue").ExtractPropTypes<{
|
|
126
|
+
/** 步骤表(标题 + 可选节点图标) */
|
|
127
|
+
steps: {
|
|
128
|
+
type: PropType<StepsItem[]>;
|
|
129
|
+
default: () => never[];
|
|
130
|
+
};
|
|
131
|
+
/** 当前步下标(0 起);小于它的算已完成 */
|
|
132
|
+
current: {
|
|
133
|
+
type: NumberConstructor;
|
|
134
|
+
default: number;
|
|
135
|
+
};
|
|
136
|
+
variant: {
|
|
137
|
+
type: PropType<StepsVariant>;
|
|
138
|
+
default: string;
|
|
139
|
+
};
|
|
140
|
+
/** 尺寸档(只覆盖 `--ui-steps-*` 令牌) */
|
|
141
|
+
size: {
|
|
142
|
+
type: PropType<ControlSize>;
|
|
143
|
+
default: string;
|
|
144
|
+
};
|
|
145
|
+
}>> & Readonly<{}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, {
|
|
146
|
+
size: ControlSize;
|
|
147
|
+
variant: StepsVariant;
|
|
148
|
+
current: number;
|
|
149
|
+
steps: StepsItem[];
|
|
150
|
+
}>;
|
|
151
|
+
__isFragment?: never;
|
|
152
|
+
__isTeleport?: never;
|
|
153
|
+
__isSuspense?: never;
|
|
154
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
155
|
+
/** 步骤表(标题 + 可选节点图标) */
|
|
156
|
+
steps: {
|
|
157
|
+
type: PropType<StepsItem[]>;
|
|
158
|
+
default: () => never[];
|
|
159
|
+
};
|
|
160
|
+
/** 当前步下标(0 起);小于它的算已完成 */
|
|
161
|
+
current: {
|
|
162
|
+
type: NumberConstructor;
|
|
163
|
+
default: number;
|
|
164
|
+
};
|
|
165
|
+
variant: {
|
|
166
|
+
type: PropType<StepsVariant>;
|
|
167
|
+
default: string;
|
|
168
|
+
};
|
|
169
|
+
/** 尺寸档(只覆盖 `--ui-steps-*` 令牌) */
|
|
170
|
+
size: {
|
|
171
|
+
type: PropType<ControlSize>;
|
|
172
|
+
default: string;
|
|
173
|
+
};
|
|
174
|
+
}>> & Readonly<{}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
|
175
|
+
size: ControlSize;
|
|
176
|
+
variant: StepsVariant;
|
|
177
|
+
current: number;
|
|
178
|
+
steps: StepsItem[];
|
|
179
|
+
}, {}, string, SlotsType<{
|
|
180
|
+
title?: (context: {
|
|
181
|
+
item: StepsItem;
|
|
182
|
+
index: number;
|
|
183
|
+
}) => VNodeChild;
|
|
184
|
+
}>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
|
|
185
|
+
Progress: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
186
|
+
value: {
|
|
187
|
+
type: NumberConstructor;
|
|
188
|
+
default: number;
|
|
189
|
+
};
|
|
190
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
191
|
+
value: {
|
|
192
|
+
type: NumberConstructor;
|
|
193
|
+
default: number;
|
|
194
|
+
};
|
|
195
|
+
}>> & Readonly<{}>, {
|
|
196
|
+
value: number;
|
|
197
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
198
|
+
};
|
|
199
|
+
export type StepsCompoundType = typeof StepsCompound;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { defineComponent, createVNode, Fragment } from "vue";
|
|
2
|
+
import { Icon } from "@manohub/icon";
|
|
3
|
+
const Steps = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "Steps",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
/** 步骤表(标题 + 可选节点图标) */
|
|
8
|
+
steps: {
|
|
9
|
+
type: Array,
|
|
10
|
+
default: () => []
|
|
11
|
+
},
|
|
12
|
+
/** 当前步下标(0 起);小于它的算已完成 */
|
|
13
|
+
current: {
|
|
14
|
+
type: Number,
|
|
15
|
+
default: 0
|
|
16
|
+
},
|
|
17
|
+
variant: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: "node"
|
|
20
|
+
},
|
|
21
|
+
/** 尺寸档(只覆盖 `--ui-steps-*` 令牌) */
|
|
22
|
+
size: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: "md"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
slots: Object,
|
|
28
|
+
setup(props, {
|
|
29
|
+
slots,
|
|
30
|
+
attrs
|
|
31
|
+
}) {
|
|
32
|
+
return () => {
|
|
33
|
+
const root = ["mh-steps", props.size === "md" ? "" : `mh-steps--${props.size}`, attrs.class].filter(Boolean).join(" ");
|
|
34
|
+
const style = attrs.style;
|
|
35
|
+
if (props.variant === "bar") {
|
|
36
|
+
return createVNode("div", {
|
|
37
|
+
"class": ["mh-steps__bar", attrs.class].filter(Boolean).join(" "),
|
|
38
|
+
"style": style
|
|
39
|
+
}, [props.steps.map((step, index) => createVNode("span", {
|
|
40
|
+
"key": `${step.title}-${index}`,
|
|
41
|
+
"class": ["mh-steps__seg", index === props.current ? "mh-steps__seg--active" : ""].filter(Boolean).join(" ")
|
|
42
|
+
}, [createVNode("span", null, [index + 1]), slots.title ? slots.title({
|
|
43
|
+
item: step,
|
|
44
|
+
index
|
|
45
|
+
}) : step.title]))]);
|
|
46
|
+
}
|
|
47
|
+
return createVNode("div", {
|
|
48
|
+
"class": root,
|
|
49
|
+
"style": style
|
|
50
|
+
}, [props.steps.map((step, index) => {
|
|
51
|
+
const state = index < props.current ? "mh-steps__step--done" : index === props.current ? "mh-steps__step--current" : "";
|
|
52
|
+
return createVNode(Fragment, {
|
|
53
|
+
"key": `${step.title}-${index}`
|
|
54
|
+
}, [index > 0 ? createVNode("span", {
|
|
55
|
+
"class": [
|
|
56
|
+
"mh-steps__connector",
|
|
57
|
+
// 连线在「步 index-1 之后」:当前步之后那一段才转蓝
|
|
58
|
+
index - 1 === props.current ? "mh-steps__connector--active" : ""
|
|
59
|
+
].filter(Boolean).join(" ")
|
|
60
|
+
}, null) : null, createVNode("div", {
|
|
61
|
+
"class": ["mh-steps__step", state].filter(Boolean).join(" ")
|
|
62
|
+
}, [createVNode("span", {
|
|
63
|
+
"class": "mh-steps__node"
|
|
64
|
+
}, [index < props.current ? createVNode(Icon, {
|
|
65
|
+
"name": "check",
|
|
66
|
+
"class": "mh-steps__node-icon",
|
|
67
|
+
"size": 16
|
|
68
|
+
}, null) : step.icon ? createVNode(Icon, {
|
|
69
|
+
"name": step.icon,
|
|
70
|
+
"class": "mh-steps__node-icon",
|
|
71
|
+
"size": 16
|
|
72
|
+
}, null) : index + 1]), createVNode("span", {
|
|
73
|
+
"class": "mh-steps__title"
|
|
74
|
+
}, [slots.title ? slots.title({
|
|
75
|
+
item: step,
|
|
76
|
+
index
|
|
77
|
+
}) : step.title])])]);
|
|
78
|
+
})]);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const StepsProgress = /* @__PURE__ */ defineComponent({
|
|
83
|
+
name: "StepsProgress",
|
|
84
|
+
inheritAttrs: false,
|
|
85
|
+
props: {
|
|
86
|
+
value: {
|
|
87
|
+
type: Number,
|
|
88
|
+
default: 0
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
setup(props, {
|
|
92
|
+
attrs
|
|
93
|
+
}) {
|
|
94
|
+
return () => {
|
|
95
|
+
const percent = Math.min(100, Math.max(0, props.value));
|
|
96
|
+
return createVNode("div", {
|
|
97
|
+
"class": ["mh-steps__progress", attrs.class].filter(Boolean).join(" "),
|
|
98
|
+
"style": attrs.style,
|
|
99
|
+
"role": "progressbar",
|
|
100
|
+
"aria-valuenow": percent,
|
|
101
|
+
"aria-valuemin": 0,
|
|
102
|
+
"aria-valuemax": 100
|
|
103
|
+
}, [createVNode("span", {
|
|
104
|
+
"class": "mh-steps__progress-fill",
|
|
105
|
+
"style": {
|
|
106
|
+
width: `${percent}%`
|
|
107
|
+
}
|
|
108
|
+
}, null)]);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
Object.assign(Steps, {
|
|
113
|
+
Progress: StepsProgress
|
|
114
|
+
});
|
|
115
|
+
export {
|
|
116
|
+
Steps
|
|
117
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
2
|
+
import type { ControlSize } from '../control-size';
|
|
3
|
+
/**
|
|
4
|
+
* 开关(**自绘**,不封装 farris)。
|
|
5
|
+
*
|
|
6
|
+
* 统一词表(与 `Checkbox` / `Radio` 同款):`modelValue` / `onChange` / `disabled` / `size`。
|
|
7
|
+
* 三档尺寸:`sm` 28×14 / `md` 36×18(表格与列表档)/ `lg` 50×24(表单档)——
|
|
8
|
+
* 几何全在样式层的 `--ui-switch-*` 令牌里,档位只覆盖令牌。`form` 是 `size="lg"` 的既有写法。
|
|
9
|
+
*
|
|
10
|
+
* 实现要点(与 `Checkbox` 同配方):
|
|
11
|
+
* - 真实 `<input type="checkbox">` 负责可访问性与键盘(Tab / Space),视觉由轨道 + 滑块自绘;
|
|
12
|
+
* - 结构固定 `input → label → track > knob`:样式层靠**通用兄弟** `~` 命中轨道(文字可夹在中间);
|
|
13
|
+
* - 选中态三源等价:原生 `:checked` / 组件下发 `data-state` / 静态档 `.is-checked`;
|
|
14
|
+
* - `labelPosition` 用 flex `order` 翻转,**不改 DOM 顺序** —— 否则那条 `~` 兄弟规则立刻失效。
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* <Switch modelValue={on} label="启用" onChange={(v) => (on = v)} />
|
|
18
|
+
*
|
|
19
|
+
* @example 轨道内文案 + 尺寸 + 加载
|
|
20
|
+
* <Switch v-model={auto} checkedText="开" uncheckedText="关" size="lg" loading={saving} />
|
|
21
|
+
*/
|
|
22
|
+
export declare const Switch: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
23
|
+
/** 受控开关值 */
|
|
24
|
+
modelValue: {
|
|
25
|
+
type: BooleanConstructor;
|
|
26
|
+
default: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** 开关文字(复杂内容走默认插槽) */
|
|
29
|
+
label: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
default: undefined;
|
|
32
|
+
};
|
|
33
|
+
disabled: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
37
|
+
/** 尺寸档(28×14 / 36×18 / 50×24) */
|
|
38
|
+
size: {
|
|
39
|
+
type: PropType<ControlSize>;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
42
|
+
/** 表单档(= `size="lg"`;表格/列表里用缺省档) */
|
|
43
|
+
form: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
default: boolean;
|
|
46
|
+
};
|
|
47
|
+
/** 文字相对开关的位置(缺省在左;表单里常放右) */
|
|
48
|
+
labelPosition: {
|
|
49
|
+
type: PropType<"left" | "right">;
|
|
50
|
+
default: string;
|
|
51
|
+
};
|
|
52
|
+
/** 选中时轨道内的文案(给了就自动把轨道加宽到能放下两个字) */
|
|
53
|
+
checkedText: {
|
|
54
|
+
type: StringConstructor;
|
|
55
|
+
default: undefined;
|
|
56
|
+
};
|
|
57
|
+
/** 未选中时轨道内的文案 */
|
|
58
|
+
uncheckedText: {
|
|
59
|
+
type: StringConstructor;
|
|
60
|
+
default: undefined;
|
|
61
|
+
};
|
|
62
|
+
/** 加载中:吞掉点击(置 disabled)+ 轨道内转圈 */
|
|
63
|
+
loading: {
|
|
64
|
+
type: BooleanConstructor;
|
|
65
|
+
default: boolean;
|
|
66
|
+
};
|
|
67
|
+
/** 自动聚焦 */
|
|
68
|
+
autofocus: {
|
|
69
|
+
type: BooleanConstructor;
|
|
70
|
+
default: boolean;
|
|
71
|
+
};
|
|
72
|
+
/** 值变更回调;参数为新值 */
|
|
73
|
+
onChange: {
|
|
74
|
+
type: PropType<(v: boolean) => void>;
|
|
75
|
+
default: undefined;
|
|
76
|
+
};
|
|
77
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
78
|
+
'update:modelValue': (v: boolean) => true;
|
|
79
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
80
|
+
/** 受控开关值 */
|
|
81
|
+
modelValue: {
|
|
82
|
+
type: BooleanConstructor;
|
|
83
|
+
default: boolean;
|
|
84
|
+
};
|
|
85
|
+
/** 开关文字(复杂内容走默认插槽) */
|
|
86
|
+
label: {
|
|
87
|
+
type: StringConstructor;
|
|
88
|
+
default: undefined;
|
|
89
|
+
};
|
|
90
|
+
disabled: {
|
|
91
|
+
type: BooleanConstructor;
|
|
92
|
+
default: boolean;
|
|
93
|
+
};
|
|
94
|
+
/** 尺寸档(28×14 / 36×18 / 50×24) */
|
|
95
|
+
size: {
|
|
96
|
+
type: PropType<ControlSize>;
|
|
97
|
+
default: string;
|
|
98
|
+
};
|
|
99
|
+
/** 表单档(= `size="lg"`;表格/列表里用缺省档) */
|
|
100
|
+
form: {
|
|
101
|
+
type: BooleanConstructor;
|
|
102
|
+
default: boolean;
|
|
103
|
+
};
|
|
104
|
+
/** 文字相对开关的位置(缺省在左;表单里常放右) */
|
|
105
|
+
labelPosition: {
|
|
106
|
+
type: PropType<"left" | "right">;
|
|
107
|
+
default: string;
|
|
108
|
+
};
|
|
109
|
+
/** 选中时轨道内的文案(给了就自动把轨道加宽到能放下两个字) */
|
|
110
|
+
checkedText: {
|
|
111
|
+
type: StringConstructor;
|
|
112
|
+
default: undefined;
|
|
113
|
+
};
|
|
114
|
+
/** 未选中时轨道内的文案 */
|
|
115
|
+
uncheckedText: {
|
|
116
|
+
type: StringConstructor;
|
|
117
|
+
default: undefined;
|
|
118
|
+
};
|
|
119
|
+
/** 加载中:吞掉点击(置 disabled)+ 轨道内转圈 */
|
|
120
|
+
loading: {
|
|
121
|
+
type: BooleanConstructor;
|
|
122
|
+
default: boolean;
|
|
123
|
+
};
|
|
124
|
+
/** 自动聚焦 */
|
|
125
|
+
autofocus: {
|
|
126
|
+
type: BooleanConstructor;
|
|
127
|
+
default: boolean;
|
|
128
|
+
};
|
|
129
|
+
/** 值变更回调;参数为新值 */
|
|
130
|
+
onChange: {
|
|
131
|
+
type: PropType<(v: boolean) => void>;
|
|
132
|
+
default: undefined;
|
|
133
|
+
};
|
|
134
|
+
}>> & Readonly<{
|
|
135
|
+
"onUpdate:modelValue"?: ((v: boolean) => any) | undefined;
|
|
136
|
+
}>, {
|
|
137
|
+
size: ControlSize;
|
|
138
|
+
disabled: boolean;
|
|
139
|
+
form: boolean;
|
|
140
|
+
label: string;
|
|
141
|
+
onChange: (v: boolean) => void;
|
|
142
|
+
loading: boolean;
|
|
143
|
+
autofocus: boolean;
|
|
144
|
+
modelValue: boolean;
|
|
145
|
+
labelPosition: "left" | "right";
|
|
146
|
+
checkedText: string;
|
|
147
|
+
uncheckedText: string;
|
|
148
|
+
}, SlotsType<{
|
|
149
|
+
default?: () => VNodeChild;
|
|
150
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { defineComponent, computed, createVNode } from "vue";
|
|
2
|
+
const Switch = /* @__PURE__ */ defineComponent({
|
|
3
|
+
name: "Switch",
|
|
4
|
+
inheritAttrs: false,
|
|
5
|
+
props: {
|
|
6
|
+
/** 受控开关值 */
|
|
7
|
+
modelValue: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: false
|
|
10
|
+
},
|
|
11
|
+
/** 开关文字(复杂内容走默认插槽) */
|
|
12
|
+
label: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: void 0
|
|
15
|
+
},
|
|
16
|
+
disabled: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false
|
|
19
|
+
},
|
|
20
|
+
/** 尺寸档(28×14 / 36×18 / 50×24) */
|
|
21
|
+
size: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: "md"
|
|
24
|
+
},
|
|
25
|
+
/** 表单档(= `size="lg"`;表格/列表里用缺省档) */
|
|
26
|
+
form: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
},
|
|
30
|
+
/** 文字相对开关的位置(缺省在左;表单里常放右) */
|
|
31
|
+
labelPosition: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "left"
|
|
34
|
+
},
|
|
35
|
+
/** 选中时轨道内的文案(给了就自动把轨道加宽到能放下两个字) */
|
|
36
|
+
checkedText: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: void 0
|
|
39
|
+
},
|
|
40
|
+
/** 未选中时轨道内的文案 */
|
|
41
|
+
uncheckedText: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: void 0
|
|
44
|
+
},
|
|
45
|
+
/** 加载中:吞掉点击(置 disabled)+ 轨道内转圈 */
|
|
46
|
+
loading: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
/** 自动聚焦 */
|
|
51
|
+
autofocus: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: false
|
|
54
|
+
},
|
|
55
|
+
/** 值变更回调;参数为新值 */
|
|
56
|
+
onChange: {
|
|
57
|
+
type: Function,
|
|
58
|
+
default: void 0
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
emits: {
|
|
62
|
+
"update:modelValue": (v) => true
|
|
63
|
+
},
|
|
64
|
+
slots: Object,
|
|
65
|
+
setup(props, {
|
|
66
|
+
emit,
|
|
67
|
+
slots,
|
|
68
|
+
attrs
|
|
69
|
+
}) {
|
|
70
|
+
const resolvedSize = computed(() => props.form ? "lg" : props.size);
|
|
71
|
+
const hasTrackText = computed(() => !!props.checkedText || !!props.uncheckedText);
|
|
72
|
+
const handleChange = (event) => {
|
|
73
|
+
const next = event.target.checked;
|
|
74
|
+
emit("update:modelValue", next);
|
|
75
|
+
props.onChange?.(next);
|
|
76
|
+
};
|
|
77
|
+
return () => createVNode("label", {
|
|
78
|
+
"class": ["mh-switch", resolvedSize.value === "md" ? "" : `mh-switch--${resolvedSize.value}`, props.form ? "mh-switch--form" : "", hasTrackText.value ? "mh-switch--with-text" : "", props.labelPosition === "right" ? "mh-switch--label-right" : "", props.loading ? "is-loading" : "", props.disabled ? "is-disabled" : "", props.modelValue ? "is-checked" : "", attrs.class].filter(Boolean).join(" "),
|
|
79
|
+
"style": attrs.style
|
|
80
|
+
}, [createVNode("input", {
|
|
81
|
+
"class": "mh-switch__input",
|
|
82
|
+
"type": "checkbox",
|
|
83
|
+
"checked": props.modelValue,
|
|
84
|
+
"disabled": props.disabled || props.loading,
|
|
85
|
+
"autofocus": props.autofocus,
|
|
86
|
+
"onChange": handleChange
|
|
87
|
+
}, null), slots.default || props.label ? createVNode("span", {
|
|
88
|
+
"class": "mh-switch__label"
|
|
89
|
+
}, [slots.default ? slots.default() : props.label]) : null, createVNode("span", {
|
|
90
|
+
"class": "mh-switch__track",
|
|
91
|
+
"data-state": props.modelValue ? "checked" : "unchecked"
|
|
92
|
+
}, [props.loading ? createVNode("span", {
|
|
93
|
+
"class": "mh-switch__spinner"
|
|
94
|
+
}, null) : hasTrackText.value ? createVNode("span", {
|
|
95
|
+
"class": "mh-switch__track-text"
|
|
96
|
+
}, [props.modelValue ? props.checkedText : props.uncheckedText]) : null, createVNode("span", {
|
|
97
|
+
"class": "mh-switch__knob"
|
|
98
|
+
}, null)])]);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
export {
|
|
102
|
+
Switch
|
|
103
|
+
};
|