hy-app 0.6.4 → 0.6.6
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/attributes.json +1 -1
- package/components/hy-address-picker/hy-address-picker.vue +249 -249
- package/components/hy-address-picker/props.ts +103 -103
- package/components/hy-button/hy-button.vue +320 -289
- package/components/hy-button/props.ts +143 -143
- package/components/hy-button/typing.d.ts +43 -35
- package/components/hy-calendar/header.vue +58 -58
- package/components/hy-calendar/hy-calendar.vue +8 -6
- package/components/hy-calendar/month.vue +402 -402
- package/components/hy-calendar/props.ts +169 -169
- package/components/hy-calendar/typing.d.ts +47 -45
- package/components/hy-cell-item/hy-cell-item.vue +161 -161
- package/components/hy-cell-item/props.ts +59 -59
- package/components/hy-check-button/hy-check-button.vue +135 -135
- package/components/hy-code-input/hy-code-input.vue +231 -231
- package/components/hy-code-input/props.ts +90 -90
- package/components/hy-config-provider/hy-config-provider.vue +53 -53
- package/components/hy-config-provider/props.ts +30 -30
- package/components/hy-coupon/hy-coupon.vue +183 -183
- package/components/hy-coupon/props.ts +108 -108
- package/components/hy-datetime-picker/hy-datetime-picker.vue +41 -55
- package/components/hy-datetime-picker/props.ts +144 -144
- package/components/hy-datetime-picker/typing.d.ts +2 -0
- package/components/hy-divider/props.ts +83 -83
- package/components/hy-empty/icon.ts +72 -72
- package/components/hy-folding-panel/hy-folding-panel-group.vue +162 -162
- package/components/hy-form/hy-form.vue +220 -220
- package/components/hy-icon/hy-icon.vue +112 -112
- package/components/hy-index-bar/hy-index-bar.vue +185 -185
- package/components/hy-index-bar/index.scss +64 -64
- package/components/hy-index-bar/props.ts +94 -94
- package/components/hy-index-bar/typing.d.ts +36 -36
- package/components/hy-input/hy-input.vue +333 -333
- package/components/hy-input/props.ts +186 -186
- package/components/hy-modal/hy-modal.vue +211 -211
- package/components/hy-modal/props.ts +94 -94
- package/components/hy-modal/typing.d.ts +16 -16
- package/components/hy-notice-bar/hy-row-notice.vue +121 -121
- package/components/hy-notify/hy-notify.vue +174 -174
- package/components/hy-number-step/hy-number-step.vue +367 -367
- package/components/hy-overlay/hy-overlay.vue +61 -61
- package/components/hy-overlay/props.ts +38 -38
- package/components/hy-pagination/hy-pagination.vue +136 -136
- package/components/hy-pagination/props.ts +58 -58
- package/components/hy-parse/hy-parse.vue +550 -550
- package/components/hy-parse/node/node.vue +781 -781
- package/components/hy-parse/parser.js +1455 -1455
- package/components/hy-parse/props.ts +19 -19
- package/components/hy-parse/typing.d.ts +68 -68
- package/components/hy-picker/hy-picker.vue +435 -435
- package/components/hy-picker/props.ts +122 -122
- package/components/hy-picker/typing.d.ts +38 -38
- package/components/hy-qrcode/props.ts +72 -72
- package/components/hy-qrcode/qrcode.js.bak +1433 -1433
- package/components/hy-radio/props.ts +97 -97
- package/components/hy-read-more/props.ts +48 -48
- package/components/hy-search/props.ts +133 -133
- package/components/hy-signature/canvasHelper.ts +51 -51
- package/components/hy-signature/props.ts +121 -121
- package/components/hy-skeleton/hy-skeleton.vue +142 -142
- package/components/hy-skeleton/props.ts +46 -46
- package/components/hy-skeleton/typing.d.ts +31 -31
- package/components/hy-steps/hy-steps.vue +275 -275
- package/components/hy-steps/typing.d.ts +25 -25
- package/components/hy-swiper/hy-swiper.vue +3 -3
- package/components/hy-swiper/index.scss +5 -5
- package/components/hy-swiper/props.ts +0 -1
- package/components/hy-table/hy-table.vue +630 -630
- package/components/hy-table/props.ts +62 -62
- package/components/hy-table/typing.d.ts +29 -29
- package/components/hy-tabs/hy-tabs.vue +336 -335
- package/components/hy-tabs/props.ts +84 -77
- package/components/hy-tag/hy-tag.vue +173 -173
- package/components/hy-tag/props.ts +89 -89
- package/components/hy-text/hy-text.vue +237 -237
- package/components/hy-text/props.ts +115 -115
- package/components/hy-textarea/hy-textarea.vue +198 -198
- package/components/hy-toast/hy-toast.vue +200 -200
- package/components/hy-toast/props.ts +3 -3
- package/components/hy-transition/hy-transition.vue +157 -157
- package/components/hy-transition/props.ts +32 -32
- package/components/hy-upload/hy-upload.vue +384 -384
- package/components/hy-watermark/hy-watermark.vue +1058 -1058
- package/components/hy-watermark/props.ts +109 -109
- package/global.d.ts +94 -94
- package/libs/api/http.ts +119 -119
- package/libs/composables/index.ts +8 -8
- package/libs/composables/useMessage.ts +149 -149
- package/libs/composables/useToast.ts +45 -45
- package/libs/composables/useTranslate.ts +10 -10
- package/libs/css/_config.scss +5 -5
- package/libs/index.ts +8 -8
- package/libs/locale/index.ts +32 -32
- package/libs/locale/lang/en-US.ts +84 -84
- package/libs/locale/lang/zh-CN.ts +87 -87
- package/libs/typing/index.ts +2 -2
- package/libs/typing/modules/common.d.ts +139 -139
- package/libs/typing/modules/form.ts +176 -176
- package/libs/typing/modules/http.d.ts +19 -19
- package/libs/typing/modules/index.d.ts +12 -12
- package/libs/utils/inside.ts +340 -340
- package/libs/utils/inspect.ts +140 -140
- package/libs/utils/utils.ts +525 -525
- package/package.json +81 -81
- package/tags.json +1 -1
- package/web-types.json +1 -1
|
@@ -1,77 +1,84 @@
|
|
|
1
|
-
import type { TabsItemVo } from './typing'
|
|
2
|
-
import type { CSSProperties, PropType } from 'vue'
|
|
3
|
-
import type { HyBadgeProps } from '../hy-badge/typing'
|
|
4
|
-
|
|
5
|
-
const tabsProps = {
|
|
6
|
-
/** 标签数组,元素为对象,如[{name: '推荐'}] */
|
|
7
|
-
list: {
|
|
8
|
-
type: Array as unknown as PropType<TabsItemVo[]>,
|
|
9
|
-
default: []
|
|
10
|
-
},
|
|
11
|
-
/** 当前选中标签的索引 */
|
|
12
|
-
current: {
|
|
13
|
-
type: Number,
|
|
14
|
-
default: 0
|
|
15
|
-
},
|
|
16
|
-
/** 从list元素对象中读取的键名 */
|
|
17
|
-
keyName: {
|
|
18
|
-
type: String,
|
|
19
|
-
default: 'name'
|
|
20
|
-
},
|
|
21
|
-
/** 滑块移动一次所需的时间,单位秒 */
|
|
22
|
-
duration: {
|
|
23
|
-
type: Number,
|
|
24
|
-
default: 300
|
|
25
|
-
},
|
|
26
|
-
/** 滑块颜色 */
|
|
27
|
-
lineColor: String,
|
|
28
|
-
/** 菜单选择中时的样式 */
|
|
29
|
-
activeStyle: {
|
|
30
|
-
type: Object as PropType<CSSProperties>,
|
|
31
|
-
default: {}
|
|
32
|
-
},
|
|
33
|
-
/** 菜单非选中时的样式 */
|
|
34
|
-
inactiveStyle: {
|
|
35
|
-
type: Object as PropType<CSSProperties>,
|
|
36
|
-
default: {}
|
|
37
|
-
},
|
|
38
|
-
/** 滑块长度 */
|
|
39
|
-
lineWidth: {
|
|
40
|
-
type: [String, Number],
|
|
41
|
-
default: 20
|
|
42
|
-
},
|
|
43
|
-
/** 滑块高度 */
|
|
44
|
-
lineHeight: {
|
|
45
|
-
type: [String, Number],
|
|
46
|
-
default: 3
|
|
47
|
-
},
|
|
48
|
-
/** 滑块背景显示大小,当滑块背景设置为图片时使用 */
|
|
49
|
-
lineBgSize: {
|
|
50
|
-
type: [String, Number],
|
|
51
|
-
default: 'cover'
|
|
52
|
-
},
|
|
53
|
-
/** 菜单item的样式 */
|
|
54
|
-
itemStyle: Object as PropType<CSSProperties>,
|
|
55
|
-
/** 轮播图高度 */
|
|
56
|
-
swiperHeight: {
|
|
57
|
-
type: [String, Number],
|
|
58
|
-
default: 'calc(
|
|
59
|
-
},
|
|
60
|
-
/** 菜单是否可滚动 */
|
|
61
|
-
scrollable: {
|
|
62
|
-
type: Boolean,
|
|
63
|
-
default: true
|
|
64
|
-
},
|
|
65
|
-
/**
|
|
66
|
-
*
|
|
67
|
-
* */
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
import type { TabsItemVo } from './typing'
|
|
2
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
3
|
+
import type { HyBadgeProps } from '../hy-badge/typing'
|
|
4
|
+
|
|
5
|
+
const tabsProps = {
|
|
6
|
+
/** 标签数组,元素为对象,如[{name: '推荐'}] */
|
|
7
|
+
list: {
|
|
8
|
+
type: Array as unknown as PropType<TabsItemVo[]>,
|
|
9
|
+
default: []
|
|
10
|
+
},
|
|
11
|
+
/** 当前选中标签的索引 */
|
|
12
|
+
current: {
|
|
13
|
+
type: Number,
|
|
14
|
+
default: 0
|
|
15
|
+
},
|
|
16
|
+
/** 从list元素对象中读取的键名 */
|
|
17
|
+
keyName: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: 'name'
|
|
20
|
+
},
|
|
21
|
+
/** 滑块移动一次所需的时间,单位秒 */
|
|
22
|
+
duration: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: 300
|
|
25
|
+
},
|
|
26
|
+
/** 滑块颜色 */
|
|
27
|
+
lineColor: String,
|
|
28
|
+
/** 菜单选择中时的样式 */
|
|
29
|
+
activeStyle: {
|
|
30
|
+
type: Object as PropType<CSSProperties>,
|
|
31
|
+
default: {}
|
|
32
|
+
},
|
|
33
|
+
/** 菜单非选中时的样式 */
|
|
34
|
+
inactiveStyle: {
|
|
35
|
+
type: Object as PropType<CSSProperties>,
|
|
36
|
+
default: {}
|
|
37
|
+
},
|
|
38
|
+
/** 滑块长度 */
|
|
39
|
+
lineWidth: {
|
|
40
|
+
type: [String, Number],
|
|
41
|
+
default: 20
|
|
42
|
+
},
|
|
43
|
+
/** 滑块高度 */
|
|
44
|
+
lineHeight: {
|
|
45
|
+
type: [String, Number],
|
|
46
|
+
default: 3
|
|
47
|
+
},
|
|
48
|
+
/** 滑块背景显示大小,当滑块背景设置为图片时使用 */
|
|
49
|
+
lineBgSize: {
|
|
50
|
+
type: [String, Number],
|
|
51
|
+
default: 'cover'
|
|
52
|
+
},
|
|
53
|
+
/** 菜单item的样式 */
|
|
54
|
+
itemStyle: Object as PropType<CSSProperties>,
|
|
55
|
+
/** 轮播图高度 */
|
|
56
|
+
swiperHeight: {
|
|
57
|
+
type: [String, Number],
|
|
58
|
+
default: 'calc(100% - 44px)'
|
|
59
|
+
},
|
|
60
|
+
/** 菜单是否可滚动 */
|
|
61
|
+
scrollable: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: true
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* 徽标props全局定义
|
|
67
|
+
* */
|
|
68
|
+
badgeProps: Object as PropType<HyBadgeProps>,
|
|
69
|
+
/**
|
|
70
|
+
* 是否出现内容轮播
|
|
71
|
+
* */
|
|
72
|
+
isSwiper: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: false
|
|
75
|
+
},
|
|
76
|
+
/** 标签左侧图标样式自定义 */
|
|
77
|
+
iconStyle: Object as PropType<CSSProperties>,
|
|
78
|
+
/** 定义需要用到的外部样式 */
|
|
79
|
+
customStyle: Object as PropType<CSSProperties>,
|
|
80
|
+
/** 自定义外部类名 */
|
|
81
|
+
customClass: String
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default tabsProps
|
|
@@ -1,173 +1,173 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<hy-transition mode="fade" :show="show" :custom-style="{ display: 'inline-block' }">
|
|
3
|
-
<view class="hy-tag__wrapper cursor-pointer">
|
|
4
|
-
<view :class="tagClass" @tap="clickHandler" :style="tagStyle">
|
|
5
|
-
<slot v-if="$slots.icon" name="icon"></slot>
|
|
6
|
-
<hy-icon
|
|
7
|
-
v-else-if="icon?.name"
|
|
8
|
-
:name="icon?.name"
|
|
9
|
-
:color="hyIconColor"
|
|
10
|
-
:size="hyIconSize"
|
|
11
|
-
:bold="icon?.bold"
|
|
12
|
-
:customPrefix="icon?.customPrefix"
|
|
13
|
-
:imgMode="icon?.imgMode"
|
|
14
|
-
:width="icon?.width"
|
|
15
|
-
:height="icon?.height"
|
|
16
|
-
:top="icon?.top"
|
|
17
|
-
:stop="icon?.stop"
|
|
18
|
-
:round="icon?.round"
|
|
19
|
-
:customStyle="Object.assign({ marginRight: '3px' }, icon?.customStyle)"
|
|
20
|
-
></hy-icon>
|
|
21
|
-
<view :class="textClass" :style="textStyle">
|
|
22
|
-
<slot v-if="$slots.default"></slot>
|
|
23
|
-
<template v-else>{{ text }}</template>
|
|
24
|
-
</view>
|
|
25
|
-
<!-- 关闭按钮 -->
|
|
26
|
-
<view
|
|
27
|
-
:class="['hy-tag__close', `hy-tag__close--${size}`]"
|
|
28
|
-
v-if="closable"
|
|
29
|
-
@tap.stop="closeHandler"
|
|
30
|
-
:style="{ backgroundColor: closeColor }"
|
|
31
|
-
>
|
|
32
|
-
<hy-icon :name="IconConfig.CLOSE" :size="closeSize" color="#ffffff"></hy-icon>
|
|
33
|
-
</view>
|
|
34
|
-
</view>
|
|
35
|
-
</view>
|
|
36
|
-
</hy-transition>
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<script lang="ts">
|
|
40
|
-
export default {
|
|
41
|
-
name: 'hy-tag',
|
|
42
|
-
options: {
|
|
43
|
-
addGlobalClass: true,
|
|
44
|
-
virtualHost: true,
|
|
45
|
-
styleIsolation: 'shared'
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
</script>
|
|
49
|
-
|
|
50
|
-
<script setup lang="ts">
|
|
51
|
-
import { computed } from 'vue'
|
|
52
|
-
import type { CSSProperties } from 'vue'
|
|
53
|
-
import type { ITagEmits } from './typing'
|
|
54
|
-
import { IconConfig, colorGradient } from '../../libs'
|
|
55
|
-
import tagProps from './props'
|
|
56
|
-
|
|
57
|
-
// 组件
|
|
58
|
-
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
59
|
-
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* tag组件一般用于标记和选择,我们提供了更加丰富的表现形式,能够较全面的涵盖您的使用场景
|
|
63
|
-
* @displayName hy-tag
|
|
64
|
-
*/
|
|
65
|
-
defineOptions({})
|
|
66
|
-
|
|
67
|
-
const props = defineProps(tagProps)
|
|
68
|
-
const emit = defineEmits<ITagEmits>()
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @description tag类名
|
|
72
|
-
* */
|
|
73
|
-
const tagClass = computed((): string[] => {
|
|
74
|
-
let classes = ['hy-tag', `hy-tag--${props.shape}`, `hy-tag--${props.size}`, props.customClass]
|
|
75
|
-
if (props.disabled) {
|
|
76
|
-
classes.push('hy-tag--disabled')
|
|
77
|
-
} else {
|
|
78
|
-
const arr = [
|
|
79
|
-
props.plain ? `hy-tag--${props.type}--plain` : `hy-tag--${props.type}`,
|
|
80
|
-
props.plain && props.plainFill && `hy-tag--${props.type}--plain__fill`
|
|
81
|
-
].filter(Boolean)
|
|
82
|
-
classes = classes.concat(arr as string[])
|
|
83
|
-
}
|
|
84
|
-
return classes
|
|
85
|
-
})
|
|
86
|
-
/**
|
|
87
|
-
* @description tag样式
|
|
88
|
-
* */
|
|
89
|
-
const tagStyle = computed<CSSProperties>(() => {
|
|
90
|
-
const style: CSSProperties = {
|
|
91
|
-
marginRight: props.closable ? '10px' : 0,
|
|
92
|
-
marginTop: props.closable ? '10px' : 0,
|
|
93
|
-
background: props.bgColor,
|
|
94
|
-
borderColor: props.borderColor
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (props.color) {
|
|
98
|
-
if (props.plain) {
|
|
99
|
-
style.borderColor = props.color
|
|
100
|
-
if (props.plainFill) {
|
|
101
|
-
style.background = colorGradient(props.color, '#FFFFFF', 100)[90]
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
style.background = props.color
|
|
105
|
-
style.borderColor = props.color
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return Object.assign(style, props.customStyle)
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* @description 文本样式
|
|
114
|
-
* */
|
|
115
|
-
const textStyle = computed(() => {
|
|
116
|
-
const style: CSSProperties = {}
|
|
117
|
-
if (props.color && props.plain) style.color = props.color
|
|
118
|
-
return style
|
|
119
|
-
})
|
|
120
|
-
/**
|
|
121
|
-
* @description 文本类名
|
|
122
|
-
* */
|
|
123
|
-
const textClass = computed((): string[] => {
|
|
124
|
-
return [`hy-tag__text`, `hy-tag__text--${props.size}`]
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* @description 关闭图标icon大小
|
|
129
|
-
*/
|
|
130
|
-
const closeSize = computed(() => {
|
|
131
|
-
return props.size === 'large' ? 15 : props.size === 'medium' ? 13 : 11
|
|
132
|
-
})
|
|
133
|
-
/**
|
|
134
|
-
* @description 图标大小
|
|
135
|
-
* */
|
|
136
|
-
const hyIconSize = computed(() => {
|
|
137
|
-
if (props.icon?.size) {
|
|
138
|
-
return props.icon.size
|
|
139
|
-
} else {
|
|
140
|
-
return props.size === 'large' ? 18 : props.size === 'medium' ? 14 : 10
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
/**
|
|
144
|
-
* @description 图标颜色
|
|
145
|
-
* */
|
|
146
|
-
const hyIconColor = computed(() => {
|
|
147
|
-
return props.icon?.color ? props.icon.color : props.plain ? props.type : '#ffffff'
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* @description 点击关闭按钮
|
|
152
|
-
* */
|
|
153
|
-
const closeHandler = () => {
|
|
154
|
-
if (!props.disabled) {
|
|
155
|
-
emit('close', props.text)
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* @description 点击标签
|
|
160
|
-
* */
|
|
161
|
-
const clickHandler = () => {
|
|
162
|
-
if (!props.disabled) {
|
|
163
|
-
emit('click', {
|
|
164
|
-
value: props.text,
|
|
165
|
-
name: props.name
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
</script>
|
|
170
|
-
|
|
171
|
-
<style lang="scss" scoped>
|
|
172
|
-
@import './index.scss';
|
|
173
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<hy-transition mode="fade" :show="show" :custom-style="{ display: 'inline-block' }">
|
|
3
|
+
<view class="hy-tag__wrapper cursor-pointer">
|
|
4
|
+
<view :class="tagClass" @tap="clickHandler" :style="tagStyle">
|
|
5
|
+
<slot v-if="$slots.icon" name="icon"></slot>
|
|
6
|
+
<hy-icon
|
|
7
|
+
v-else-if="icon?.name"
|
|
8
|
+
:name="icon?.name"
|
|
9
|
+
:color="hyIconColor"
|
|
10
|
+
:size="hyIconSize"
|
|
11
|
+
:bold="icon?.bold"
|
|
12
|
+
:customPrefix="icon?.customPrefix"
|
|
13
|
+
:imgMode="icon?.imgMode"
|
|
14
|
+
:width="icon?.width"
|
|
15
|
+
:height="icon?.height"
|
|
16
|
+
:top="icon?.top"
|
|
17
|
+
:stop="icon?.stop"
|
|
18
|
+
:round="icon?.round"
|
|
19
|
+
:customStyle="Object.assign({ marginRight: '3px' }, icon?.customStyle)"
|
|
20
|
+
></hy-icon>
|
|
21
|
+
<view :class="textClass" :style="textStyle">
|
|
22
|
+
<slot v-if="$slots.default"></slot>
|
|
23
|
+
<template v-else>{{ text }}</template>
|
|
24
|
+
</view>
|
|
25
|
+
<!-- 关闭按钮 -->
|
|
26
|
+
<view
|
|
27
|
+
:class="['hy-tag__close', `hy-tag__close--${size}`]"
|
|
28
|
+
v-if="closable"
|
|
29
|
+
@tap.stop="closeHandler"
|
|
30
|
+
:style="{ backgroundColor: closeColor }"
|
|
31
|
+
>
|
|
32
|
+
<hy-icon :name="IconConfig.CLOSE" :size="closeSize" color="#ffffff"></hy-icon>
|
|
33
|
+
</view>
|
|
34
|
+
</view>
|
|
35
|
+
</view>
|
|
36
|
+
</hy-transition>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script lang="ts">
|
|
40
|
+
export default {
|
|
41
|
+
name: 'hy-tag',
|
|
42
|
+
options: {
|
|
43
|
+
addGlobalClass: true,
|
|
44
|
+
virtualHost: true,
|
|
45
|
+
styleIsolation: 'shared'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<script setup lang="ts">
|
|
51
|
+
import { computed } from 'vue'
|
|
52
|
+
import type { CSSProperties } from 'vue'
|
|
53
|
+
import type { ITagEmits } from './typing'
|
|
54
|
+
import { IconConfig, colorGradient } from '../../libs'
|
|
55
|
+
import tagProps from './props'
|
|
56
|
+
|
|
57
|
+
// 组件
|
|
58
|
+
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
59
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* tag组件一般用于标记和选择,我们提供了更加丰富的表现形式,能够较全面的涵盖您的使用场景
|
|
63
|
+
* @displayName hy-tag
|
|
64
|
+
*/
|
|
65
|
+
defineOptions({})
|
|
66
|
+
|
|
67
|
+
const props = defineProps(tagProps)
|
|
68
|
+
const emit = defineEmits<ITagEmits>()
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @description tag类名
|
|
72
|
+
* */
|
|
73
|
+
const tagClass = computed((): string[] => {
|
|
74
|
+
let classes = ['hy-tag', `hy-tag--${props.shape}`, `hy-tag--${props.size}`, props.customClass]
|
|
75
|
+
if (props.disabled) {
|
|
76
|
+
classes.push('hy-tag--disabled')
|
|
77
|
+
} else {
|
|
78
|
+
const arr = [
|
|
79
|
+
props.plain ? `hy-tag--${props.type}--plain` : `hy-tag--${props.type}`,
|
|
80
|
+
props.plain && props.plainFill && `hy-tag--${props.type}--plain__fill`
|
|
81
|
+
].filter(Boolean)
|
|
82
|
+
classes = classes.concat(arr as string[])
|
|
83
|
+
}
|
|
84
|
+
return classes
|
|
85
|
+
})
|
|
86
|
+
/**
|
|
87
|
+
* @description tag样式
|
|
88
|
+
* */
|
|
89
|
+
const tagStyle = computed<CSSProperties>(() => {
|
|
90
|
+
const style: CSSProperties = {
|
|
91
|
+
marginRight: props.closable ? '10px' : 0,
|
|
92
|
+
marginTop: props.closable ? '10px' : 0,
|
|
93
|
+
background: props.bgColor,
|
|
94
|
+
borderColor: props.borderColor
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (props.color) {
|
|
98
|
+
if (props.plain) {
|
|
99
|
+
style.borderColor = props.color
|
|
100
|
+
if (props.plainFill) {
|
|
101
|
+
style.background = colorGradient(props.color, '#FFFFFF', 100)[90]
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
style.background = props.color
|
|
105
|
+
style.borderColor = props.color
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return Object.assign(style, props.customStyle)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @description 文本样式
|
|
114
|
+
* */
|
|
115
|
+
const textStyle = computed(() => {
|
|
116
|
+
const style: CSSProperties = {}
|
|
117
|
+
if (props.color && props.plain) style.color = props.color
|
|
118
|
+
return style
|
|
119
|
+
})
|
|
120
|
+
/**
|
|
121
|
+
* @description 文本类名
|
|
122
|
+
* */
|
|
123
|
+
const textClass = computed((): string[] => {
|
|
124
|
+
return [`hy-tag__text`, `hy-tag__text--${props.size}`]
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @description 关闭图标icon大小
|
|
129
|
+
*/
|
|
130
|
+
const closeSize = computed(() => {
|
|
131
|
+
return props.size === 'large' ? 15 : props.size === 'medium' ? 13 : 11
|
|
132
|
+
})
|
|
133
|
+
/**
|
|
134
|
+
* @description 图标大小
|
|
135
|
+
* */
|
|
136
|
+
const hyIconSize = computed(() => {
|
|
137
|
+
if (props.icon?.size) {
|
|
138
|
+
return props.icon.size
|
|
139
|
+
} else {
|
|
140
|
+
return props.size === 'large' ? 18 : props.size === 'medium' ? 14 : 10
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
/**
|
|
144
|
+
* @description 图标颜色
|
|
145
|
+
* */
|
|
146
|
+
const hyIconColor = computed(() => {
|
|
147
|
+
return props.icon?.color ? props.icon.color : props.plain ? props.type : '#ffffff'
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @description 点击关闭按钮
|
|
152
|
+
* */
|
|
153
|
+
const closeHandler = () => {
|
|
154
|
+
if (!props.disabled) {
|
|
155
|
+
emit('close', props.text)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* @description 点击标签
|
|
160
|
+
* */
|
|
161
|
+
const clickHandler = () => {
|
|
162
|
+
if (!props.disabled) {
|
|
163
|
+
emit('click', {
|
|
164
|
+
value: props.text,
|
|
165
|
+
name: props.name
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
</script>
|
|
170
|
+
|
|
171
|
+
<style lang="scss" scoped>
|
|
172
|
+
@import './index.scss';
|
|
173
|
+
</style>
|