@mc-markets/ui 1.0.90 → 1.0.92
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 +243 -40
- package/USAGE_GUIDE.md +339 -0
- package/dist/404.html +22 -22
- package/dist/components/Tag/Tag.vue.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +10 -11
- package/dist/index.mjs.map +1 -1
- package/dist/resolver.d.ts +26 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/package.json +8 -5
- package/packages/components/Alert/Alert.vue +139 -139
- package/packages/components/Banner/Banner.vue +299 -299
- package/packages/components/Breadcrumb/Breadcrumb.vue +113 -113
- package/packages/components/Breadcrumb/BreadcrumbSeparator.vue +31 -31
- package/packages/components/Button/Button.vue +17 -17
- package/packages/components/DatePicker/DatePicker.vue +85 -85
- package/packages/components/Dialog/Dialog.vue +61 -61
- package/packages/components/Empty/Empty.vue +73 -73
- package/packages/components/Form/Form.vue +30 -30
- package/packages/components/FormItem/FormItem.vue +19 -19
- package/packages/components/Icon/Icon.vue +210 -210
- package/packages/components/Input/Input.vue +15 -15
- package/packages/components/Message/Message.vue +503 -503
- package/packages/components/NotifiMessage/NotifiMessage.vue +293 -293
- package/packages/components/Notification/Notification.vue +19 -19
- package/packages/components/Option/Option.vue +13 -13
- package/packages/components/OptionGroup/OptionGroup.vue +13 -13
- package/packages/components/Pagination/Pagination.vue +61 -61
- package/packages/components/Radio/Radio.vue +67 -67
- package/packages/components/RadioButton/RadioButton.vue +110 -110
- package/packages/components/RadioGroup/RadioGroup.vue +155 -155
- package/packages/components/Select/Select.vue +22 -22
- package/packages/components/Switch/Switch.vue +47 -47
- package/packages/components/TabCard/TabCard.vue +107 -107
- package/packages/components/TabCard/TabCardItem.vue +105 -105
- package/packages/components/Table/Table.vue +17 -17
- package/packages/components/Table/TableColumn.vue +20 -20
- package/packages/components/Tabs/TabPane.vue +79 -79
- package/packages/components/Tabs/Tabs.vue +267 -267
- package/packages/components/Tag/Tag.vue +208 -211
- package/packages/components/Tooltip/Tooltip.vue +58 -58
- package/packages/hooks/useClassName.js +23 -23
- package/packages/resolver.js +179 -0
- package/packages/styles/README.md +129 -129
- package/packages/styles/colorfont/iconfont.css +1 -0
- package/packages/styles/components/button.scss +121 -121
- package/packages/styles/components/checkbox.scss +18 -18
- package/packages/styles/components/dialog.scss +47 -47
- package/packages/styles/components/form.scss +18 -18
- package/packages/styles/components/input.scss +14 -14
- package/packages/styles/components/select.scss +62 -62
- package/packages/styles/components/table.scss +37 -37
- package/packages/styles/components/tabs.scss +76 -76
- package/packages/styles/components/tag.scss +142 -142
- package/packages/styles/font/iconfont.scss +363 -363
- package/packages/styles/index.scss +94 -94
- package/packages/styles/variables/border-mode.css +6 -6
- package/packages/styles/variables/color-modes-dark.css +143 -143
- package/packages/styles/variables/index.scss +5 -5
- package/packages/styles/variables/primitives-style.css +112 -112
- package/packages/styles/variables/radius-mode.css +14 -14
- package/packages/styles/variables/spacing-mode.css +20 -20
- package/packages/styles/variables/typography-desktop.css +40 -40
- package/packages/styles/variables/typography-mobile.css +40 -40
- package/packages/utils/classNames.js +23 -23
- package/packages/utils/styleUtils.js +105 -105
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-radio-group v-bind="mergedAttrs" :popper-class="computedPopperClass" class="m-radio-group">
|
|
3
|
-
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
4
|
-
<slot :name="name" />
|
|
5
|
-
</template>
|
|
6
|
-
</el-radio-group>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup>
|
|
10
|
-
import { computed, useAttrs } from 'vue'
|
|
11
|
-
|
|
12
|
-
defineOptions({
|
|
13
|
-
name: 'MRadioGroup'
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
// 定义props
|
|
17
|
-
const props = defineProps({
|
|
18
|
-
popperClass: {
|
|
19
|
-
type: String,
|
|
20
|
-
default: ''
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// 获取attrs
|
|
25
|
-
const attrs = useAttrs()
|
|
26
|
-
|
|
27
|
-
// 计算popper-class,合并默认类名和外部传入的类名
|
|
28
|
-
const computedPopperClass = computed(() => {
|
|
29
|
-
const defaultPopperClass = 'mc-radio-group-popper'
|
|
30
|
-
|
|
31
|
-
if (attrs.popperClass) {
|
|
32
|
-
return `${defaultPopperClass} ${attrs.popperClass}`.trim()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return defaultPopperClass
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
// 合并其他属性(排除popperClass)
|
|
39
|
-
const mergedAttrs = computed(() => {
|
|
40
|
-
const { popperClass, ...otherAttrs } = attrs
|
|
41
|
-
return otherAttrs
|
|
42
|
-
})
|
|
43
|
-
</script>
|
|
44
|
-
|
|
45
|
-
<style lang="scss">
|
|
46
|
-
// RadioGroup popper-class 样式
|
|
47
|
-
.mc-radio-group-popper {
|
|
48
|
-
// 自定义单选框组样式可以在这里添加
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// 自定义主题示例
|
|
52
|
-
.mc-radio-group-custom {
|
|
53
|
-
.el-radio {
|
|
54
|
-
.el-radio__input {
|
|
55
|
-
.el-radio__inner {
|
|
56
|
-
background: linear-gradient(45deg, #667eea, #764ba2);
|
|
57
|
-
border-color: #667eea;
|
|
58
|
-
|
|
59
|
-
&:hover {
|
|
60
|
-
background: linear-gradient(45deg, #5a6fd8, #6a4190);
|
|
61
|
-
border-color: #5a6fd8;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
&.is-checked .el-radio__inner {
|
|
66
|
-
background: linear-gradient(45deg, #4c63d2, #5d3a7e);
|
|
67
|
-
border-color: #4c63d2;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.el-radio__label {
|
|
72
|
-
color: #667eea;
|
|
73
|
-
font-weight: 500;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.mc-radio-group-success {
|
|
79
|
-
.el-radio {
|
|
80
|
-
.el-radio__input {
|
|
81
|
-
.el-radio__inner {
|
|
82
|
-
background-color: #67c23a;
|
|
83
|
-
border-color: #67c23a;
|
|
84
|
-
|
|
85
|
-
&:hover {
|
|
86
|
-
background-color: #5daf34;
|
|
87
|
-
border-color: #5daf34;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
&.is-checked .el-radio__inner {
|
|
92
|
-
background-color: #529b2e;
|
|
93
|
-
border-color: #529b2e;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.el-radio__label {
|
|
98
|
-
color: #67c23a;
|
|
99
|
-
font-weight: 500;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.mc-radio-group-warning {
|
|
105
|
-
.el-radio {
|
|
106
|
-
.el-radio__input {
|
|
107
|
-
.el-radio__inner {
|
|
108
|
-
background-color: #e6a23c;
|
|
109
|
-
border-color: #e6a23c;
|
|
110
|
-
|
|
111
|
-
&:hover {
|
|
112
|
-
background-color: #d4922b;
|
|
113
|
-
border-color: #d4922b;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
&.is-checked .el-radio__inner {
|
|
118
|
-
background-color: #c8951f;
|
|
119
|
-
border-color: #c8951f;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.el-radio__label {
|
|
124
|
-
color: #e6a23c;
|
|
125
|
-
font-weight: 500;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.mc-radio-group-danger {
|
|
131
|
-
.el-radio {
|
|
132
|
-
.el-radio__input {
|
|
133
|
-
.el-radio__inner {
|
|
134
|
-
background-color: #f56c6c;
|
|
135
|
-
border-color: #f56c6c;
|
|
136
|
-
|
|
137
|
-
&:hover {
|
|
138
|
-
background-color: #f45454;
|
|
139
|
-
border-color: #f45454;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
&.is-checked .el-radio__inner {
|
|
144
|
-
background-color: #f24545;
|
|
145
|
-
border-color: #f24545;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.el-radio__label {
|
|
150
|
-
color: #f56c6c;
|
|
151
|
-
font-weight: 500;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<el-radio-group v-bind="mergedAttrs" :popper-class="computedPopperClass" class="m-radio-group">
|
|
3
|
+
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
4
|
+
<slot :name="name" />
|
|
5
|
+
</template>
|
|
6
|
+
</el-radio-group>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
import { computed, useAttrs } from 'vue'
|
|
11
|
+
|
|
12
|
+
defineOptions({
|
|
13
|
+
name: 'MRadioGroup'
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
// 定义props
|
|
17
|
+
const props = defineProps({
|
|
18
|
+
popperClass: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: ''
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// 获取attrs
|
|
25
|
+
const attrs = useAttrs()
|
|
26
|
+
|
|
27
|
+
// 计算popper-class,合并默认类名和外部传入的类名
|
|
28
|
+
const computedPopperClass = computed(() => {
|
|
29
|
+
const defaultPopperClass = 'mc-radio-group-popper'
|
|
30
|
+
|
|
31
|
+
if (attrs.popperClass) {
|
|
32
|
+
return `${defaultPopperClass} ${attrs.popperClass}`.trim()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return defaultPopperClass
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// 合并其他属性(排除popperClass)
|
|
39
|
+
const mergedAttrs = computed(() => {
|
|
40
|
+
const { popperClass, ...otherAttrs } = attrs
|
|
41
|
+
return otherAttrs
|
|
42
|
+
})
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<style lang="scss">
|
|
46
|
+
// RadioGroup popper-class 样式
|
|
47
|
+
.mc-radio-group-popper {
|
|
48
|
+
// 自定义单选框组样式可以在这里添加
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 自定义主题示例
|
|
52
|
+
.mc-radio-group-custom {
|
|
53
|
+
.el-radio {
|
|
54
|
+
.el-radio__input {
|
|
55
|
+
.el-radio__inner {
|
|
56
|
+
background: linear-gradient(45deg, #667eea, #764ba2);
|
|
57
|
+
border-color: #667eea;
|
|
58
|
+
|
|
59
|
+
&:hover {
|
|
60
|
+
background: linear-gradient(45deg, #5a6fd8, #6a4190);
|
|
61
|
+
border-color: #5a6fd8;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&.is-checked .el-radio__inner {
|
|
66
|
+
background: linear-gradient(45deg, #4c63d2, #5d3a7e);
|
|
67
|
+
border-color: #4c63d2;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.el-radio__label {
|
|
72
|
+
color: #667eea;
|
|
73
|
+
font-weight: 500;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.mc-radio-group-success {
|
|
79
|
+
.el-radio {
|
|
80
|
+
.el-radio__input {
|
|
81
|
+
.el-radio__inner {
|
|
82
|
+
background-color: #67c23a;
|
|
83
|
+
border-color: #67c23a;
|
|
84
|
+
|
|
85
|
+
&:hover {
|
|
86
|
+
background-color: #5daf34;
|
|
87
|
+
border-color: #5daf34;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&.is-checked .el-radio__inner {
|
|
92
|
+
background-color: #529b2e;
|
|
93
|
+
border-color: #529b2e;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.el-radio__label {
|
|
98
|
+
color: #67c23a;
|
|
99
|
+
font-weight: 500;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.mc-radio-group-warning {
|
|
105
|
+
.el-radio {
|
|
106
|
+
.el-radio__input {
|
|
107
|
+
.el-radio__inner {
|
|
108
|
+
background-color: #e6a23c;
|
|
109
|
+
border-color: #e6a23c;
|
|
110
|
+
|
|
111
|
+
&:hover {
|
|
112
|
+
background-color: #d4922b;
|
|
113
|
+
border-color: #d4922b;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&.is-checked .el-radio__inner {
|
|
118
|
+
background-color: #c8951f;
|
|
119
|
+
border-color: #c8951f;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.el-radio__label {
|
|
124
|
+
color: #e6a23c;
|
|
125
|
+
font-weight: 500;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.mc-radio-group-danger {
|
|
131
|
+
.el-radio {
|
|
132
|
+
.el-radio__input {
|
|
133
|
+
.el-radio__inner {
|
|
134
|
+
background-color: #f56c6c;
|
|
135
|
+
border-color: #f56c6c;
|
|
136
|
+
|
|
137
|
+
&:hover {
|
|
138
|
+
background-color: #f45454;
|
|
139
|
+
border-color: #f45454;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
&.is-checked .el-radio__inner {
|
|
144
|
+
background-color: #f24545;
|
|
145
|
+
border-color: #f24545;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.el-radio__label {
|
|
150
|
+
color: #f56c6c;
|
|
151
|
+
font-weight: 500;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
</style>
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-select
|
|
3
|
-
class="m-select"
|
|
4
|
-
:class="{ solid: $attrs.styleType === 'solid' }"
|
|
5
|
-
:show-arrow="false"
|
|
6
|
-
v-bind="$attrs"
|
|
7
|
-
>
|
|
8
|
-
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
9
|
-
<slot :name="name" />
|
|
10
|
-
</template>
|
|
11
|
-
</el-select>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<script setup>
|
|
15
|
-
defineOptions({
|
|
16
|
-
name: "MSelect",
|
|
17
|
-
});
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<style lang="scss" scoped>
|
|
21
|
-
|
|
22
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<el-select
|
|
3
|
+
class="m-select"
|
|
4
|
+
:class="{ solid: $attrs.styleType === 'solid' }"
|
|
5
|
+
:show-arrow="false"
|
|
6
|
+
v-bind="$attrs"
|
|
7
|
+
>
|
|
8
|
+
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
9
|
+
<slot :name="name" />
|
|
10
|
+
</template>
|
|
11
|
+
</el-select>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup>
|
|
15
|
+
defineOptions({
|
|
16
|
+
name: "MSelect",
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<style lang="scss" scoped>
|
|
21
|
+
|
|
22
|
+
</style>
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-switch v-bind="mergedAttrs" :popper-class="popperClass" class="m-switch">
|
|
3
|
-
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
4
|
-
<slot :name="name" />
|
|
5
|
-
</template>
|
|
6
|
-
</el-switch>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup>
|
|
10
|
-
import { useClassName } from "@packages/hooks/useClassName.js";
|
|
11
|
-
|
|
12
|
-
defineOptions({
|
|
13
|
-
name: "MSwitch",
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// 定义props
|
|
17
|
-
const props = defineProps({
|
|
18
|
-
popperClass: {
|
|
19
|
-
type: String,
|
|
20
|
-
default: "",
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// 使用类名 Hook
|
|
25
|
-
const { mergedAttrs, className: popperClass } =
|
|
26
|
-
useClassName("mc-switch-popper");
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<style lang="scss">
|
|
30
|
-
.m-switch {
|
|
31
|
-
&.is-checked {
|
|
32
|
-
.el-switch__action {
|
|
33
|
-
background-color: var(--all-gray-10);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&:not(.is-checked) {
|
|
38
|
-
.el-switch__core {
|
|
39
|
-
background-color: var(--all-gray-5);
|
|
40
|
-
border-color: var(--all-gray-5);
|
|
41
|
-
.el-switch__action {
|
|
42
|
-
background-color: var(--all-gray-1);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<el-switch v-bind="mergedAttrs" :popper-class="popperClass" class="m-switch">
|
|
3
|
+
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
4
|
+
<slot :name="name" />
|
|
5
|
+
</template>
|
|
6
|
+
</el-switch>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
import { useClassName } from "@packages/hooks/useClassName.js";
|
|
11
|
+
|
|
12
|
+
defineOptions({
|
|
13
|
+
name: "MSwitch",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// 定义props
|
|
17
|
+
const props = defineProps({
|
|
18
|
+
popperClass: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: "",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// 使用类名 Hook
|
|
25
|
+
const { mergedAttrs, className: popperClass } =
|
|
26
|
+
useClassName("mc-switch-popper");
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<style lang="scss">
|
|
30
|
+
.m-switch {
|
|
31
|
+
&.is-checked {
|
|
32
|
+
.el-switch__action {
|
|
33
|
+
background-color: var(--all-gray-10);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&:not(.is-checked) {
|
|
38
|
+
.el-switch__core {
|
|
39
|
+
background-color: var(--all-gray-5);
|
|
40
|
+
border-color: var(--all-gray-5);
|
|
41
|
+
.el-switch__action {
|
|
42
|
+
background-color: var(--all-gray-1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="m-tab-card" :class="{ 'is-disabled': disabled }">
|
|
3
|
-
<div class="m-tab-card__container">
|
|
4
|
-
<m-tab-card-item
|
|
5
|
-
v-for="(tab, index) in tabs"
|
|
6
|
-
:key="tab.name"
|
|
7
|
-
:name="tab.name"
|
|
8
|
-
:label="tab.label"
|
|
9
|
-
:disabled="tab.disabled"
|
|
10
|
-
/>
|
|
11
|
-
</div>
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script setup>
|
|
16
|
-
import { ref, computed, watch, provide } from 'vue'
|
|
17
|
-
import { useClassName } from "@packages/hooks/useClassName.js"
|
|
18
|
-
import MTabCardItem from './TabCardItem.vue'
|
|
19
|
-
|
|
20
|
-
defineOptions({
|
|
21
|
-
name: "MTabCard",
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// 定义 props
|
|
25
|
-
const props = defineProps({
|
|
26
|
-
modelValue: {
|
|
27
|
-
type: [String, Number],
|
|
28
|
-
default: ''
|
|
29
|
-
},
|
|
30
|
-
disabled: {
|
|
31
|
-
type: Boolean,
|
|
32
|
-
default: false
|
|
33
|
-
},
|
|
34
|
-
options: {
|
|
35
|
-
type: Array,
|
|
36
|
-
default: () => []
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
// 定义 emits
|
|
41
|
-
const emit = defineEmits(['update:modelValue', 'change', 'tab-click'])
|
|
42
|
-
|
|
43
|
-
// 使用类名 Hook
|
|
44
|
-
const { mergedAttrs } = useClassName()
|
|
45
|
-
|
|
46
|
-
// 内部状态
|
|
47
|
-
const activeTab = ref(props.modelValue)
|
|
48
|
-
|
|
49
|
-
// 计算 tabs 数据
|
|
50
|
-
const tabs = computed(() => {
|
|
51
|
-
return props.options.map(option => {
|
|
52
|
-
if (typeof option === 'string') {
|
|
53
|
-
return { label: option, name: option, disabled: false }
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
label: option.label || option.name || '',
|
|
57
|
-
name: option.name || option.label || '',
|
|
58
|
-
disabled: option.disabled || false
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
// 处理 tab 点击
|
|
64
|
-
const handleTabClick = (tabName, isDisabled) => {
|
|
65
|
-
if (isDisabled || props.disabled || tabName === activeTab.value) {
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const oldValue = activeTab.value
|
|
70
|
-
activeTab.value = tabName
|
|
71
|
-
emit('update:modelValue', tabName)
|
|
72
|
-
emit('change', tabName, oldValue)
|
|
73
|
-
emit('tab-click', tabName)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// 监听 modelValue 变化
|
|
77
|
-
watch(() => props.modelValue, (newValue) => {
|
|
78
|
-
if (newValue !== activeTab.value) {
|
|
79
|
-
activeTab.value = newValue
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
// 提供给子组件的方法
|
|
84
|
-
provide('tabCardContext', {
|
|
85
|
-
activeTab,
|
|
86
|
-
handleTabClick
|
|
87
|
-
})
|
|
88
|
-
</script>
|
|
89
|
-
|
|
90
|
-
<style lang="scss" scoped>
|
|
91
|
-
.m-tab-card {
|
|
92
|
-
display: inline-block;
|
|
93
|
-
|
|
94
|
-
&.is-disabled {
|
|
95
|
-
pointer-events: none;
|
|
96
|
-
opacity: 0.6;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
&__container {
|
|
100
|
-
display: flex;
|
|
101
|
-
background-color: var(--bg-tertiary-hover, #2a2a2a);
|
|
102
|
-
border-radius: var(--md);
|
|
103
|
-
padding: 4px;
|
|
104
|
-
gap: 0;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="m-tab-card" :class="{ 'is-disabled': disabled }">
|
|
3
|
+
<div class="m-tab-card__container">
|
|
4
|
+
<m-tab-card-item
|
|
5
|
+
v-for="(tab, index) in tabs"
|
|
6
|
+
:key="tab.name"
|
|
7
|
+
:name="tab.name"
|
|
8
|
+
:label="tab.label"
|
|
9
|
+
:disabled="tab.disabled"
|
|
10
|
+
/>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup>
|
|
16
|
+
import { ref, computed, watch, provide } from 'vue'
|
|
17
|
+
import { useClassName } from "@packages/hooks/useClassName.js"
|
|
18
|
+
import MTabCardItem from './TabCardItem.vue'
|
|
19
|
+
|
|
20
|
+
defineOptions({
|
|
21
|
+
name: "MTabCard",
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// 定义 props
|
|
25
|
+
const props = defineProps({
|
|
26
|
+
modelValue: {
|
|
27
|
+
type: [String, Number],
|
|
28
|
+
default: ''
|
|
29
|
+
},
|
|
30
|
+
disabled: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
options: {
|
|
35
|
+
type: Array,
|
|
36
|
+
default: () => []
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// 定义 emits
|
|
41
|
+
const emit = defineEmits(['update:modelValue', 'change', 'tab-click'])
|
|
42
|
+
|
|
43
|
+
// 使用类名 Hook
|
|
44
|
+
const { mergedAttrs } = useClassName()
|
|
45
|
+
|
|
46
|
+
// 内部状态
|
|
47
|
+
const activeTab = ref(props.modelValue)
|
|
48
|
+
|
|
49
|
+
// 计算 tabs 数据
|
|
50
|
+
const tabs = computed(() => {
|
|
51
|
+
return props.options.map(option => {
|
|
52
|
+
if (typeof option === 'string') {
|
|
53
|
+
return { label: option, name: option, disabled: false }
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
label: option.label || option.name || '',
|
|
57
|
+
name: option.name || option.label || '',
|
|
58
|
+
disabled: option.disabled || false
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
// 处理 tab 点击
|
|
64
|
+
const handleTabClick = (tabName, isDisabled) => {
|
|
65
|
+
if (isDisabled || props.disabled || tabName === activeTab.value) {
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const oldValue = activeTab.value
|
|
70
|
+
activeTab.value = tabName
|
|
71
|
+
emit('update:modelValue', tabName)
|
|
72
|
+
emit('change', tabName, oldValue)
|
|
73
|
+
emit('tab-click', tabName)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 监听 modelValue 变化
|
|
77
|
+
watch(() => props.modelValue, (newValue) => {
|
|
78
|
+
if (newValue !== activeTab.value) {
|
|
79
|
+
activeTab.value = newValue
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
// 提供给子组件的方法
|
|
84
|
+
provide('tabCardContext', {
|
|
85
|
+
activeTab,
|
|
86
|
+
handleTabClick
|
|
87
|
+
})
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<style lang="scss" scoped>
|
|
91
|
+
.m-tab-card {
|
|
92
|
+
display: inline-block;
|
|
93
|
+
|
|
94
|
+
&.is-disabled {
|
|
95
|
+
pointer-events: none;
|
|
96
|
+
opacity: 0.6;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&__container {
|
|
100
|
+
display: flex;
|
|
101
|
+
background-color: var(--bg-tertiary-hover, #2a2a2a);
|
|
102
|
+
border-radius: var(--md);
|
|
103
|
+
padding: 4px;
|
|
104
|
+
gap: 0;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
</style>
|