hy-app 0.2.13 → 0.2.15
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/components/hy-action-sheet/hy-action-sheet.vue +81 -13
- package/components/hy-action-sheet/typing.d.ts +1 -3
- package/components/hy-address-picker/hy-address-picker.vue +109 -8
- package/components/hy-address-picker/index.scss +2 -2
- package/components/hy-address-picker/typing.d.ts +39 -30
- package/components/hy-avatar/hy-avatar.vue +78 -4
- package/components/hy-avatar/typing.d.ts +21 -16
- package/components/hy-back-top/hy-back-top.vue +86 -28
- package/components/hy-back-top/typing.d.ts +17 -12
- package/components/hy-badge/hy-badge.vue +114 -43
- package/components/hy-badge/typing.d.ts +20 -15
- package/components/hy-button/HyButton.docgen.js +6 -0
- package/components/hy-button/hy-button.vue +70 -77
- package/components/hy-button/props.ts +40 -41
- package/components/hy-calendar/hy-calendar.vue +290 -143
- package/components/hy-calendar/typing.d.ts +38 -31
- package/components/hy-card/hy-card.vue +139 -36
- package/components/hy-card/typing.d.ts +39 -28
- package/components/hy-cell/hy-cell.vue +131 -67
- package/components/hy-cell/typing.d.ts +6 -1
- package/components/hy-check-button/hy-check-button.vue +101 -32
- package/components/hy-check-button/typing.d.ts +26 -19
- package/components/hy-checkbox/hy-checkbox.vue +167 -78
- package/components/hy-checkbox/typing.d.ts +26 -19
- package/components/hy-code-input/hy-code-input.vue +101 -5
- package/components/hy-code-input/typing.d.ts +9 -0
- package/components/hy-config-provider/hy-config-provider.vue +44 -24
- package/components/hy-config-provider/typing.d.ts +0 -4
- package/components/hy-count-down/hy-count-down.vue +99 -62
- package/components/hy-count-down/typing.d.ts +18 -5
- package/components/hy-count-to/hy-count-to.vue +165 -113
- package/components/hy-count-to/typing.d.ts +15 -11
- package/components/hy-datetime-picker/hy-datetime-picker.vue +338 -232
- package/components/hy-datetime-picker/typing.d.ts +49 -39
- package/components/hy-divider/hy-divider.vue +128 -64
- package/components/hy-divider/typing.d.ts +16 -16
- package/components/hy-dropdown/hy-dropdown.vue +57 -19
- package/components/hy-dropdown/typing.d.ts +14 -14
- package/components/hy-dropdown-item/hy-dropdown-item.vue +34 -5
- package/components/hy-dropdown-item/typing.d.ts +13 -6
- package/components/hy-empty/hy-empty.vue +64 -6
- package/components/hy-empty/typing.d.ts +5 -0
- package/components/hy-float-button/hy-float-button.vue +117 -5
- package/components/hy-float-button/typing.d.ts +7 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +87 -25
- package/components/hy-folding-panel/typing.d.ts +24 -15
- package/components/hy-grid/hy-grid.vue +95 -35
- package/components/hy-grid/typing.d.ts +24 -19
- package/components/hy-icon/hy-icon.vue +84 -6
- package/components/hy-icon/typing.d.ts +5 -0
- package/components/hy-image/hy-image.vue +105 -6
- package/components/hy-image/typing.d.ts +9 -0
- package/components/hy-input/hy-input.vue +277 -130
- package/components/hy-input/props.ts +13 -14
- package/components/hy-input/typing.d.ts +59 -38
- package/components/hy-line/hy-line.vue +65 -25
- package/components/hy-line-progress/hy-line-progress.vue +68 -35
- package/components/hy-list/hy-list.vue +127 -61
- package/components/hy-list/typing.d.ts +19 -12
- package/components/hy-loading/hy-loading.vue +79 -25
- package/components/hy-menu/hy-menu.vue +69 -45
- package/components/hy-menu/typing.d.ts +22 -15
- package/components/hy-modal/hy-modal.vue +91 -4
- package/components/hy-modal/typing.d.ts +11 -0
- package/components/hy-navbar/hy-navbar.vue +105 -25
- package/components/hy-navbar/typing.d.ts +25 -20
- package/components/hy-notice-bar/hy-notice-bar.vue +97 -19
- package/components/hy-notice-bar/typing.d.ts +22 -17
- package/components/hy-notify/hy-notify.vue +106 -54
- package/components/hy-number-step/hy-number-step.vue +211 -120
- package/components/hy-number-step/typing.d.ts +45 -28
- package/components/hy-overlay/hy-overlay.vue +60 -16
- package/components/hy-overlay/typing.d.ts +11 -6
- package/components/hy-pagination/hy-pagination.vue +94 -37
- package/components/hy-pagination/typing.d.ts +20 -11
- package/components/hy-picker/hy-picker.vue +225 -160
- package/components/hy-picker/typing.d.ts +51 -28
- package/components/hy-popover/hy-popover.vue +55 -7
- package/components/hy-popover/typing.d.ts +21 -1
- package/components/hy-popup/hy-popup.vue +164 -99
- package/components/hy-popup/typing.d.ts +11 -0
- package/components/hy-price/hy-price.vue +77 -30
- package/components/hy-price/typing.d.ts +10 -10
- package/components/hy-qrcode/hy-qrcode.vue +75 -5
- package/components/hy-qrcode/typing.d.ts +25 -16
- package/components/hy-radio/hy-radio.vue +169 -88
- package/components/hy-radio/typing.d.ts +29 -22
- package/components/hy-rate/hy-rate.vue +155 -104
- package/components/hy-rate/typing.d.ts +23 -16
- package/components/hy-read-more/hy-read-more.vue +83 -56
- package/components/hy-read-more/typing.d.ts +18 -11
- package/components/hy-scroll-list/hy-scroll-list.vue +69 -58
- package/components/hy-scroll-list/typing.d.ts +14 -7
- package/components/hy-search/hy-search.vue +168 -62
- package/components/hy-search/typing.d.ts +47 -26
- package/components/hy-signature/hy-signature.vue +354 -272
- package/components/hy-signature/typing.d.ts +65 -52
- package/components/hy-slider/hy-slider.vue +208 -160
- package/components/hy-slider/typing.d.ts +28 -17
- package/components/hy-steps/hy-steps.vue +125 -99
- package/components/hy-steps/typing.d.ts +21 -14
- package/components/hy-submit-bar/hy-submit-bar.vue +129 -48
- package/components/hy-submit-bar/typing.d.ts +30 -23
- package/components/hy-subsection/hy-subsection.vue +139 -96
- package/components/hy-subsection/typing.d.ts +23 -16
- package/components/hy-swipe-action/hy-swipe-action.vue +161 -135
- package/components/hy-swipe-action/typing.d.ts +26 -17
- package/components/hy-swiper/hy-swiper.vue +178 -73
- package/components/hy-swiper/typing.d.ts +37 -28
- package/components/hy-switch/hy-switch.vue +107 -60
- package/components/hy-switch/typing.d.ts +25 -18
- package/components/hy-tabs/hy-tabs.vue +170 -160
- package/components/hy-tabs/typing.d.ts +36 -22
- package/components/hy-tag/hy-tag.vue +133 -58
- package/components/hy-tag/typing.d.ts +26 -18
- package/components/hy-text/hy-text.vue +106 -6
- package/components/hy-text/typing.d.ts +31 -26
- package/components/hy-textarea/hy-textarea.vue +183 -89
- package/components/hy-textarea/typing.d.ts +41 -24
- package/components/hy-tooltip/hy-tooltip.vue +145 -101
- package/components/hy-tooltip/typing.d.ts +18 -13
- package/components/hy-transition/hy-transition.vue +48 -13
- package/components/hy-transition/typing.d.ts +17 -0
- package/components/hy-upload/hy-upload.vue +113 -148
- package/components/hy-upload/typing.d.ts +71 -71
- package/components/hy-warn/hy-warn.vue +79 -36
- package/components/hy-warn/typing.d.ts +18 -11
- package/components/hy-waterfall/hy-waterfall.vue +90 -77
- package/components/hy-watermark/hy-watermark.vue +82 -5
- package/components/hy-watermark/typing.d.ts +20 -20
- package/global.d.ts +39 -59
- package/package.json +5 -13
- package/utils/inspect.ts +3 -1
- package/web-types.json +1 -1
- package/component-helper.ts +0 -177
- package/components.json +0 -3287
- package/dist/attributes.json +0 -1
- package/dist/docs/components/hy-action-sheet/hy-action-sheet.md +0 -41
- package/dist/docs/components/hy-address-picker/hy-address-picker.md +0 -25
- package/dist/docs/components/hy-avatar/hy-avatar.md +0 -19
- package/dist/docs/components/hy-back-top/hy-back-top.md +0 -19
- package/dist/docs/components/hy-badge/hy-badge.md +0 -13
- package/dist/docs/components/hy-button/hy-button.md +0 -61
- package/dist/docs/components/hy-calendar/header.md +0 -17
- package/dist/docs/components/hy-calendar/hy-calendar.md +0 -27
- package/dist/docs/components/hy-calendar/month.md +0 -38
- package/dist/docs/components/hy-card/hy-card.md +0 -24
- package/dist/docs/components/hy-cell/hy-cell.md +0 -26
- package/dist/docs/components/hy-check-button/hy-check-button.md +0 -14
- package/dist/docs/components/hy-checkbox/hy-checkbox.md +0 -21
- package/dist/docs/components/hy-code-input/hy-code-input.md +0 -15
- package/dist/docs/components/hy-config-provider/hy-config-provider.md +0 -13
- package/dist/docs/components/hy-count-down/hy-count-down.md +0 -34
- package/dist/docs/components/hy-count-to/hy-count-to.md +0 -31
- package/dist/docs/components/hy-datetime-picker/hy-datetime-picker.md +0 -25
- package/dist/docs/components/hy-divider/hy-divider.md +0 -13
- package/dist/docs/components/hy-dropdown/hy-dropdown.md +0 -13
- package/dist/docs/components/hy-dropdown-item/hy-dropdown-item.md +0 -20
- package/dist/docs/components/hy-empty/hy-empty.md +0 -20
- package/dist/docs/components/hy-float-button/hy-float-button.md +0 -20
- package/dist/docs/components/hy-folding-panel/hy-folding-panel.md +0 -24
- package/dist/docs/components/hy-form/hy-form.md +0 -29
- package/dist/docs/components/hy-grid/hy-grid.md +0 -19
- package/dist/docs/components/hy-icon/hy-icon.md +0 -13
- package/dist/docs/components/hy-image/hy-image.md +0 -22
- package/dist/docs/components/hy-input/hy-input.md +0 -29
- package/dist/docs/components/hy-line/hy-line.md +0 -7
- package/dist/docs/components/hy-line-progress/hy-line-progress.md +0 -13
- package/dist/docs/components/hy-list/hy-list.md +0 -25
- package/dist/docs/components/hy-loading/hy-loading.md +0 -14
- package/dist/docs/components/hy-login/ThePhoneLogin.md +0 -20
- package/dist/docs/components/hy-login/TheUserLogin.md +0 -44
- package/dist/docs/components/hy-login/hy-login.md +0 -14
- package/dist/docs/components/hy-menu/hy-menu.md +0 -21
- package/dist/docs/components/hy-modal/hy-modal.md +0 -23
- package/dist/docs/components/hy-navbar/hy-navbar.md +0 -22
- package/dist/docs/components/hy-notice-bar/hy-column-notice.md +0 -20
- package/dist/docs/components/hy-notice-bar/hy-notice-bar.md +0 -14
- package/dist/docs/components/hy-notice-bar/hy-row-notice.md +0 -20
- package/dist/docs/components/hy-notify/hy-notify.md +0 -23
- package/dist/docs/components/hy-number-step/hy-number-step.md +0 -27
- package/dist/docs/components/hy-overlay/hy-overlay.md +0 -19
- package/dist/docs/components/hy-pagination/hy-pagination.md +0 -14
- package/dist/docs/components/hy-parse/hy-parse.md +0 -46
- package/dist/docs/components/hy-parse/node/node.md +0 -7
- package/dist/docs/components/hy-picker/hy-picker.md +0 -32
- package/dist/docs/components/hy-popover/hy-popover.md +0 -34
- package/dist/docs/components/hy-popup/hy-popup.md +0 -22
- package/dist/docs/components/hy-price/hy-price.md +0 -13
- package/dist/docs/components/hy-qrcode/hy-qrcode.md +0 -15
- package/dist/docs/components/hy-radio/hy-radio.md +0 -21
- package/dist/docs/components/hy-rate/hy-rate.md +0 -14
- package/dist/docs/components/hy-read-more/hy-read-more.md +0 -21
- package/dist/docs/components/hy-scroll-list/hy-scroll-list.md +0 -21
- package/dist/docs/components/hy-search/hy-search.md +0 -27
- package/dist/docs/components/hy-signature/hy-signature.md +0 -45
- package/dist/docs/components/hy-slider/hy-slider.md +0 -24
- package/dist/docs/components/hy-status-bar/hy-status-bar.md +0 -13
- package/dist/docs/components/hy-steps/hy-steps.md +0 -23
- package/dist/docs/components/hy-submit-bar/hy-submit-bar.md +0 -21
- package/dist/docs/components/hy-subsection/hy-subsection.md +0 -14
- package/dist/docs/components/hy-swipe-action/hy-swipe-action.md +0 -29
- package/dist/docs/components/hy-swiper/hy-swiper-indicator.md +0 -23
- package/dist/docs/components/hy-swiper/hy-swiper.md +0 -22
- package/dist/docs/components/hy-switch/hy-switch.md +0 -20
- package/dist/docs/components/hy-tabBar/hy-tabBar.md +0 -13
- package/dist/docs/components/hy-tabs/hy-tabs.md +0 -27
- package/dist/docs/components/hy-tag/hy-tag.md +0 -21
- package/dist/docs/components/hy-text/hy-text.md +0 -13
- package/dist/docs/components/hy-textarea/hy-textarea.md +0 -19
- package/dist/docs/components/hy-toast/hy-toast.md +0 -17
- package/dist/docs/components/hy-tooltip/hy-tooltip.md +0 -13
- package/dist/docs/components/hy-transition/hy-transition.md +0 -25
- package/dist/docs/components/hy-upload/hy-upload.md +0 -25
- package/dist/docs/components/hy-warn/hy-warn.md +0 -14
- package/dist/docs/components/hy-waterfall/hy-waterfall.md +0 -30
- package/dist/docs/components/hy-watermark/hy-watermark.md +0 -7
- package/dist/docs/components/message/TheMessage.md +0 -17
- package/dist/docs/components/yk-dialog/yk-dialog.md +0 -7
- package/dist/tags.json +0 -1
- package/dist/web-types.json +0 -1
- package/docgen.config.js +0 -14
- package/web-types.config.js +0 -7
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<HyTransition mode="fade" :customStyle="backTopStyle" :show="show">
|
|
3
|
+
<!-- @slot 默认插槽 -->
|
|
3
4
|
<slot>
|
|
4
5
|
<view class="hy-back-top" :style="contentStyle" @click="backToTop">
|
|
5
6
|
<HyIcon
|
|
@@ -23,59 +24,116 @@
|
|
|
23
24
|
</template>
|
|
24
25
|
|
|
25
26
|
<script lang="ts">
|
|
27
|
+
/**
|
|
28
|
+
* 该组件一个用于长页面,滑动一定距离后,出现返回顶部按钮,方便快速返回顶部的场景。
|
|
29
|
+
* @displayName hy-back-top
|
|
30
|
+
*/
|
|
31
|
+
defineOptions({})
|
|
26
32
|
export default {
|
|
27
33
|
name: 'hy-back-top',
|
|
28
34
|
options: {
|
|
29
35
|
addGlobalClass: true,
|
|
30
36
|
virtualHost: true,
|
|
31
|
-
styleIsolation: 'shared'
|
|
32
|
-
}
|
|
37
|
+
styleIsolation: 'shared',
|
|
38
|
+
},
|
|
33
39
|
}
|
|
34
40
|
</script>
|
|
35
41
|
|
|
36
42
|
<script setup lang="ts">
|
|
37
|
-
import { computed, type CSSProperties, toRefs } from
|
|
38
|
-
import
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import type
|
|
43
|
+
import { computed, type CSSProperties, PropType, toRefs } from 'vue'
|
|
44
|
+
import { addUnit, getPx } from '../../utils'
|
|
45
|
+
import { IconConfig } from '../../config'
|
|
46
|
+
import type { IBackTopEmit } from './typing'
|
|
47
|
+
import type HyIconProps from '../hy-icon/typing'
|
|
42
48
|
// 组件
|
|
43
|
-
import HyTransition from
|
|
44
|
-
import HyIcon from
|
|
49
|
+
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
50
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
45
51
|
|
|
46
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
53
|
+
const props = defineProps({
|
|
54
|
+
/**
|
|
55
|
+
* 返回顶部的形状
|
|
56
|
+
* @values circle,square
|
|
57
|
+
* */
|
|
58
|
+
mode: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: 'circle',
|
|
61
|
+
},
|
|
62
|
+
/** 自定义图标属性集合 */
|
|
63
|
+
icon: {
|
|
64
|
+
type: Object as PropType<HyIconProps>,
|
|
65
|
+
},
|
|
66
|
+
/** 提示文字 */
|
|
67
|
+
text: String,
|
|
68
|
+
/** 返回顶部滚动时间 */
|
|
69
|
+
duration: {
|
|
70
|
+
type: Number,
|
|
71
|
+
default: 500,
|
|
72
|
+
},
|
|
73
|
+
/** 滚动距离 */
|
|
74
|
+
scrollTop: {
|
|
75
|
+
type: Number,
|
|
76
|
+
default: 0,
|
|
77
|
+
},
|
|
78
|
+
/** 距离顶部多少距离显示,单位px */
|
|
79
|
+
top: {
|
|
80
|
+
type: Number,
|
|
81
|
+
default: 400,
|
|
82
|
+
},
|
|
83
|
+
/** 返回顶部按钮到底部的距离,单位px */
|
|
84
|
+
bottom: {
|
|
85
|
+
type: Number,
|
|
86
|
+
default: 100,
|
|
87
|
+
},
|
|
88
|
+
/** 返回顶部按钮到右边的距离,单位px */
|
|
89
|
+
right: {
|
|
90
|
+
type: Number,
|
|
91
|
+
default: 20,
|
|
92
|
+
},
|
|
93
|
+
/** 层级 */
|
|
94
|
+
zIndex: {
|
|
95
|
+
type: Number,
|
|
96
|
+
default: 888,
|
|
97
|
+
},
|
|
98
|
+
/** 定义需要用到的外部样式 */
|
|
99
|
+
customStyle: {
|
|
100
|
+
type: Object as PropType<CSSProperties>,
|
|
101
|
+
default: {
|
|
102
|
+
transform: 'rotate(180deg)',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
const { customStyle, duration, mode, bottom, right, top, scrollTop } = toRefs(props)
|
|
107
|
+
const emit = defineEmits<IBackTopEmit>()
|
|
50
108
|
|
|
51
109
|
const backTopStyle = computed<CSSProperties>(() => {
|
|
52
110
|
return {
|
|
53
111
|
bottom: addUnit(bottom.value),
|
|
54
112
|
right: addUnit(right.value),
|
|
55
|
-
width:
|
|
56
|
-
height:
|
|
57
|
-
position:
|
|
113
|
+
width: '40px',
|
|
114
|
+
height: '40px',
|
|
115
|
+
position: 'fixed',
|
|
58
116
|
zIndex: 10,
|
|
59
|
-
}
|
|
60
|
-
})
|
|
117
|
+
}
|
|
118
|
+
})
|
|
61
119
|
const contentStyle = computed<CSSProperties>(() => {
|
|
62
120
|
const style: CSSProperties = {
|
|
63
|
-
borderRadius: mode.value ===
|
|
64
|
-
}
|
|
65
|
-
return Object.assign(style, customStyle.value)
|
|
66
|
-
})
|
|
121
|
+
borderRadius: mode.value === 'circle' ? '50%' : '4px',
|
|
122
|
+
}
|
|
123
|
+
return Object.assign(style, customStyle.value)
|
|
124
|
+
})
|
|
67
125
|
const show = computed<boolean>(() => {
|
|
68
|
-
return getPx(scrollTop.value) > getPx(top.value)
|
|
69
|
-
})
|
|
126
|
+
return getPx(scrollTop.value) > getPx(top.value)
|
|
127
|
+
})
|
|
70
128
|
const backToTop = () => {
|
|
71
129
|
uni.pageScrollTo({
|
|
72
130
|
scrollTop: 0,
|
|
73
131
|
duration: duration.value,
|
|
74
|
-
})
|
|
75
|
-
emit(
|
|
76
|
-
}
|
|
132
|
+
})
|
|
133
|
+
emit('click')
|
|
134
|
+
}
|
|
77
135
|
</script>
|
|
78
136
|
|
|
79
137
|
<style lang="scss" scoped>
|
|
80
|
-
@import
|
|
138
|
+
@import './index.scss';
|
|
81
139
|
</style>
|
|
@@ -1,45 +1,50 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
2
|
-
import type HyIconProps from
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
|
+
import type HyIconProps from '../hy-icon/typing'
|
|
3
3
|
|
|
4
4
|
export default interface HyBackTopProps {
|
|
5
5
|
/**
|
|
6
6
|
* @description 返回顶部的形状,circle-圆形,square-方形 (默认 'circle' )
|
|
7
7
|
* */
|
|
8
|
-
mode?: HyApp.ShapeType
|
|
8
|
+
mode?: HyApp.ShapeType
|
|
9
9
|
/**
|
|
10
10
|
* @description 自定义图标属性集合
|
|
11
11
|
* */
|
|
12
|
-
icon?: Partial<HyIconProps
|
|
12
|
+
icon?: Partial<HyIconProps>
|
|
13
13
|
/**
|
|
14
14
|
* @description 提示文字
|
|
15
15
|
* */
|
|
16
|
-
text?: string
|
|
16
|
+
text?: string
|
|
17
17
|
/**
|
|
18
18
|
* @description 返回顶部滚动时间 (默认 500)
|
|
19
19
|
* */
|
|
20
|
-
duration?: number
|
|
20
|
+
duration?: number
|
|
21
21
|
/**
|
|
22
22
|
* @description 滚动距离 (默认 0 )
|
|
23
23
|
* */
|
|
24
|
-
scrollTop: number
|
|
24
|
+
scrollTop: number
|
|
25
25
|
/**
|
|
26
26
|
* @description 距离顶部多少距离显示,单位px (默认 400 )
|
|
27
27
|
* */
|
|
28
|
-
top?: number | string
|
|
28
|
+
top?: number | string
|
|
29
29
|
/**
|
|
30
30
|
* @description 返回顶部按钮到底部的距离,单位px (默认 100 )
|
|
31
31
|
* */
|
|
32
|
-
bottom?: number | string
|
|
32
|
+
bottom?: number | string
|
|
33
33
|
/**
|
|
34
34
|
* @description 返回顶部按钮到右边的距离,单位px (默认 20 )
|
|
35
35
|
* */
|
|
36
|
-
right?: number | string
|
|
36
|
+
right?: number | string
|
|
37
37
|
/**
|
|
38
38
|
* @description 层级 (默认 888 )
|
|
39
39
|
* */
|
|
40
|
-
zIndex?: number
|
|
40
|
+
zIndex?: number
|
|
41
41
|
/**
|
|
42
42
|
* @description 定义需要用到的外部样式(默认{transform: "rotate(180deg)"})
|
|
43
43
|
* */
|
|
44
|
-
customStyle?: CSSProperties
|
|
44
|
+
customStyle?: CSSProperties
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface IBackTopEmit {
|
|
48
|
+
/** 点击触发 */
|
|
49
|
+
(e: 'click'): void
|
|
45
50
|
}
|
|
@@ -9,88 +9,159 @@
|
|
|
9
9
|
`hy-badge--${type}${inverted ? '--inverted' : ''}`,
|
|
10
10
|
]"
|
|
11
11
|
:style="[customStyle, badgeStyle]"
|
|
12
|
-
|
|
12
|
+
@tap="onClick"
|
|
13
13
|
>
|
|
14
|
+
{{ isDot ? '' : showValue }}
|
|
15
|
+
</text>
|
|
14
16
|
</template>
|
|
15
17
|
|
|
16
18
|
<script lang="ts">
|
|
19
|
+
/**
|
|
20
|
+
* 此选择器用于选择地址
|
|
21
|
+
* @displayName hy-address-picker
|
|
22
|
+
*/
|
|
23
|
+
defineOptions({})
|
|
17
24
|
export default {
|
|
18
25
|
name: 'hy-badge',
|
|
19
26
|
options: {
|
|
20
27
|
addGlobalClass: true,
|
|
21
28
|
virtualHost: true,
|
|
22
|
-
styleIsolation: 'shared'
|
|
23
|
-
}
|
|
29
|
+
styleIsolation: 'shared',
|
|
30
|
+
},
|
|
24
31
|
}
|
|
25
32
|
</script>
|
|
26
33
|
|
|
27
34
|
<script setup lang="ts">
|
|
28
|
-
import type
|
|
29
|
-
import defaultProps from
|
|
30
|
-
import { computed, type CSSProperties, toRefs } from
|
|
31
|
-
import { addUnit } from
|
|
35
|
+
import type { IBadgeEmit } from './typing'
|
|
36
|
+
import defaultProps from './props'
|
|
37
|
+
import { computed, type CSSProperties, PropType, toRefs } from 'vue'
|
|
38
|
+
import { addUnit } from '../../utils'
|
|
32
39
|
|
|
33
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
34
|
-
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
40
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
41
|
+
const props = defineProps({
|
|
42
|
+
/** 是否显示圆点 */
|
|
43
|
+
isDot: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: false,
|
|
46
|
+
},
|
|
47
|
+
/** 显示的内容 */
|
|
48
|
+
value: {
|
|
49
|
+
type: Number,
|
|
50
|
+
default: 0,
|
|
51
|
+
},
|
|
52
|
+
/** 是否显示 */
|
|
53
|
+
show: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: true,
|
|
56
|
+
},
|
|
57
|
+
/** 最大值,超过最大值会显示 '{max}+' */
|
|
58
|
+
max: {
|
|
59
|
+
type: Number,
|
|
60
|
+
default: 999,
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* 主题类型
|
|
64
|
+
* @values error,warning,success,primary,info
|
|
65
|
+
* */
|
|
66
|
+
type: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: 'error',
|
|
69
|
+
},
|
|
70
|
+
/** 当数值为 0 时,是否展示 Badge */
|
|
71
|
+
showZero: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false,
|
|
74
|
+
},
|
|
75
|
+
/** 背景颜色,优先级比type高,如设置,type参数会失效 */
|
|
76
|
+
bgColor: String,
|
|
77
|
+
/** 字体颜色 */
|
|
78
|
+
color: String,
|
|
79
|
+
/**
|
|
80
|
+
* 徽标形状
|
|
81
|
+
* @values circle,horn
|
|
82
|
+
* */
|
|
83
|
+
shape: {
|
|
84
|
+
type: String,
|
|
85
|
+
default: 'circle',
|
|
86
|
+
},
|
|
87
|
+
/**
|
|
88
|
+
* 设置数字的显示方式
|
|
89
|
+
* @values overflow,ellipsis,limit
|
|
90
|
+
* */
|
|
91
|
+
numberType: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: 'overflow',
|
|
94
|
+
},
|
|
95
|
+
/** 设置badge的位置偏移,格式为 [x, y],也即设置的为top和right的值,absolute为true时有效 */
|
|
96
|
+
offset: Array<number>,
|
|
97
|
+
/** 是否反转背景和字体颜色 */
|
|
98
|
+
inverted: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: false,
|
|
101
|
+
},
|
|
102
|
+
/** 是否绝对定位 */
|
|
103
|
+
absolute: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
default: false,
|
|
106
|
+
},
|
|
107
|
+
/** 自定义输入框外部样式 */
|
|
108
|
+
customStyle: {
|
|
109
|
+
type: Object as PropType<CSSProperties>,
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
const { value, bgColor, color, numberType, absolute, offset, inverted, max, customStyle } =
|
|
113
|
+
toRefs(props)
|
|
114
|
+
const emit = defineEmits<IBadgeEmit>()
|
|
46
115
|
|
|
47
116
|
/**
|
|
48
117
|
* @description 整个组件的样式
|
|
49
118
|
* */
|
|
50
119
|
const badgeStyle = computed<CSSProperties>(() => {
|
|
51
|
-
const style: CSSProperties = {}
|
|
120
|
+
const style: CSSProperties = {}
|
|
52
121
|
if (color.value) {
|
|
53
|
-
style.color = color.value
|
|
122
|
+
style.color = color.value
|
|
54
123
|
}
|
|
55
124
|
if (bgColor.value && !inverted.value) {
|
|
56
|
-
style.backgroundColor = bgColor.value
|
|
125
|
+
style.backgroundColor = bgColor.value
|
|
57
126
|
}
|
|
58
127
|
if (absolute.value) {
|
|
59
|
-
style.position =
|
|
128
|
+
style.position = 'absolute'
|
|
60
129
|
// 如果有设置offset参数
|
|
61
130
|
if (offset.value && Array.isArray(offset.value)) {
|
|
62
131
|
// top和right分为为offset的第一个和第二个值,如果没有第二个值,则right等于top
|
|
63
|
-
const top = offset.value[0]
|
|
64
|
-
const right = offset.value[1] || top
|
|
65
|
-
style.top = addUnit(top)
|
|
66
|
-
style.left = addUnit(right)
|
|
132
|
+
const top = offset.value[0]
|
|
133
|
+
const right = offset.value[1] || top
|
|
134
|
+
style.top = addUnit(top)
|
|
135
|
+
style.left = addUnit(right)
|
|
67
136
|
}
|
|
68
137
|
}
|
|
69
|
-
return style
|
|
70
|
-
})
|
|
138
|
+
return style
|
|
139
|
+
})
|
|
71
140
|
/**
|
|
72
141
|
* @description 显示值
|
|
73
142
|
* */
|
|
74
143
|
const showValue = computed(() => {
|
|
75
144
|
switch (numberType.value) {
|
|
76
|
-
case
|
|
77
|
-
return Number(value.value) > Number(max.value)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
case
|
|
81
|
-
return Number(value.value) > Number(max.value) ? "..." : value.value;
|
|
82
|
-
case "limit":
|
|
145
|
+
case 'overflow':
|
|
146
|
+
return Number(value.value) > Number(max.value) ? max.value + '+' : value.value
|
|
147
|
+
case 'ellipsis':
|
|
148
|
+
return Number(value.value) > Number(max.value) ? '...' : value.value
|
|
149
|
+
case 'limit':
|
|
83
150
|
return Number(value.value) > 999
|
|
84
151
|
? Number(value.value) >= 9999
|
|
85
|
-
? Math.floor((value.value / 1e4) * 100) / 100 +
|
|
86
|
-
: Math.floor((value.value / 1e3) * 100) / 100 +
|
|
87
|
-
: value.value
|
|
152
|
+
? Math.floor((value.value / 1e4) * 100) / 100 + 'w'
|
|
153
|
+
: Math.floor((value.value / 1e3) * 100) / 100 + 'k'
|
|
154
|
+
: value.value
|
|
88
155
|
default:
|
|
89
|
-
return Number(value.value)
|
|
156
|
+
return Number(value.value)
|
|
90
157
|
}
|
|
91
|
-
})
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
const onClick = (e: Event) => {
|
|
161
|
+
emit('click', e)
|
|
162
|
+
}
|
|
92
163
|
</script>
|
|
93
164
|
|
|
94
165
|
<style lang="scss" scoped>
|
|
95
|
-
@import
|
|
166
|
+
@import './index.scss';
|
|
96
167
|
</style>
|
|
@@ -1,60 +1,65 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
2
|
|
|
3
3
|
export default interface HyBadgeProps {
|
|
4
4
|
/**
|
|
5
5
|
* @description 是否显示圆点 (默认 false )
|
|
6
6
|
* */
|
|
7
|
-
isDot?: boolean
|
|
7
|
+
isDot?: boolean
|
|
8
8
|
/**
|
|
9
9
|
* @description 显示的内容
|
|
10
10
|
* */
|
|
11
|
-
value?: number
|
|
11
|
+
value?: number
|
|
12
12
|
/**
|
|
13
13
|
* @description 是否显示 (默认 true )
|
|
14
14
|
* */
|
|
15
|
-
show?: boolean
|
|
15
|
+
show?: boolean
|
|
16
16
|
/**
|
|
17
17
|
* @description 最大值,超过最大值会显示 '{max}+' (默认999)
|
|
18
18
|
* */
|
|
19
|
-
max?: number
|
|
19
|
+
max?: number
|
|
20
20
|
/**
|
|
21
21
|
* @description 主题类型,error|warning|success|primary|info (默认 'error' )
|
|
22
22
|
* */
|
|
23
|
-
type?: HyApp.ThemeType
|
|
23
|
+
type?: HyApp.ThemeType
|
|
24
24
|
/**
|
|
25
25
|
* @description 当数值为 0 时,是否展示 Badge (默认 false )
|
|
26
26
|
* */
|
|
27
|
-
showZero?: boolean
|
|
27
|
+
showZero?: boolean
|
|
28
28
|
/**
|
|
29
29
|
* @description 背景颜色,优先级比type高,如设置,type参数会失效
|
|
30
30
|
* */
|
|
31
|
-
bgColor?: string | null
|
|
31
|
+
bgColor?: string | null
|
|
32
32
|
/**
|
|
33
33
|
* @description 字体颜色 (默认 '#ffffff' )
|
|
34
34
|
* */
|
|
35
|
-
color?: string | null
|
|
35
|
+
color?: string | null
|
|
36
36
|
/**
|
|
37
37
|
* @description 徽标形状,circle-四角均为圆角,horn-左下角为直角 (默认 'circle' )
|
|
38
38
|
* */
|
|
39
|
-
shape?:
|
|
39
|
+
shape?: 'circle' | 'horn'
|
|
40
40
|
/**
|
|
41
41
|
* @description 设置数字的显示方式,overflow|ellipsis|limit (默认 'overflow' )
|
|
42
42
|
* */
|
|
43
|
-
numberType?:
|
|
43
|
+
numberType?: 'overflow' | 'ellipsis' | 'limit'
|
|
44
44
|
/**
|
|
45
45
|
* @description 设置badge的位置偏移,格式为 [x, y],也即设置的为top和right的值,absolute为true时有效
|
|
46
46
|
* */
|
|
47
|
-
offset?: number[] | null
|
|
47
|
+
offset?: number[] | null
|
|
48
48
|
/**
|
|
49
49
|
* @description 是否反转背景和字体颜色(默认 false )
|
|
50
50
|
* */
|
|
51
|
-
inverted?: boolean
|
|
51
|
+
inverted?: boolean
|
|
52
52
|
/**
|
|
53
53
|
* @description 是否绝对定位(默认 false )
|
|
54
54
|
* */
|
|
55
|
-
absolute?: boolean
|
|
55
|
+
absolute?: boolean
|
|
56
56
|
/**
|
|
57
57
|
* @description 定义需要用到的外部样式
|
|
58
58
|
* */
|
|
59
|
-
customStyle?: CSSProperties
|
|
59
|
+
customStyle?: CSSProperties
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface IBadgeEmit {
|
|
63
|
+
/** 点击触发 */
|
|
64
|
+
(e: 'click', event: Event): void
|
|
60
65
|
}
|