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,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<HyTransition
|
|
3
3
|
:show="show"
|
|
4
|
-
custom-class="hy-overlay"
|
|
4
|
+
:custom-class="['hy-overlay', customClass]"
|
|
5
5
|
:duration="duration"
|
|
6
6
|
:custom-style="overlayStyle"
|
|
7
7
|
@click="clickHandler"
|
|
@@ -10,33 +10,77 @@
|
|
|
10
10
|
</HyTransition>
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
/**
|
|
15
|
+
* 创建一个遮罩层,用于强调特定的页面元素,并阻止用户对遮罩下层的内容进行操作,一般用于弹窗场景
|
|
16
|
+
* @displayName hy-overlay
|
|
17
|
+
*/
|
|
18
|
+
defineOptions({})
|
|
19
|
+
export default {
|
|
20
|
+
name: 'hy-overlay',
|
|
21
|
+
options: {
|
|
22
|
+
addGlobalClass: true,
|
|
23
|
+
virtualHost: true,
|
|
24
|
+
styleIsolation: 'shared',
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
13
29
|
<script setup lang="ts">
|
|
14
|
-
import { computed,
|
|
15
|
-
import
|
|
16
|
-
import type
|
|
17
|
-
import HyTransition from
|
|
30
|
+
import { computed, toRefs } from 'vue'
|
|
31
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
32
|
+
import type { IOverlayEmits } from './typing'
|
|
33
|
+
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
18
34
|
|
|
19
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
20
|
-
const
|
|
21
|
-
|
|
35
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
36
|
+
const props = defineProps({
|
|
37
|
+
/** 是否显示遮罩 */
|
|
38
|
+
show: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false,
|
|
41
|
+
},
|
|
42
|
+
/** zIndex 层级 */
|
|
43
|
+
zIndex: {
|
|
44
|
+
type: Number,
|
|
45
|
+
default: 10070,
|
|
46
|
+
},
|
|
47
|
+
/** 动画时长,单位毫秒 */
|
|
48
|
+
duration: {
|
|
49
|
+
type: Number,
|
|
50
|
+
default: 300,
|
|
51
|
+
},
|
|
52
|
+
/** 不透明度值,当做rgba的第四个参数 */
|
|
53
|
+
opacity: {
|
|
54
|
+
type: Number,
|
|
55
|
+
default: 0.5,
|
|
56
|
+
},
|
|
57
|
+
/** 定义需要用到的外部样式 */
|
|
58
|
+
customStyle: {
|
|
59
|
+
type: Object as PropType<CSSProperties>,
|
|
60
|
+
},
|
|
61
|
+
/** 自定义外部类名 */
|
|
62
|
+
customClass: String,
|
|
63
|
+
})
|
|
64
|
+
const { customStyle, opacity, zIndex } = toRefs(props)
|
|
65
|
+
const emit = defineEmits<IOverlayEmits>()
|
|
22
66
|
|
|
23
67
|
const overlayStyle = computed<CSSProperties>(() => {
|
|
24
68
|
const style: CSSProperties = {
|
|
25
|
-
position:
|
|
69
|
+
position: 'fixed',
|
|
26
70
|
top: 0,
|
|
27
71
|
left: 0,
|
|
28
72
|
right: 0,
|
|
29
73
|
zIndex: zIndex?.value,
|
|
30
74
|
bottom: 0,
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
return Object.assign(style, customStyle.value || {})
|
|
34
|
-
})
|
|
75
|
+
'background-color': `rgba(0, 0, 0, ${opacity.value})`,
|
|
76
|
+
}
|
|
77
|
+
return Object.assign(style, customStyle.value || {})
|
|
78
|
+
})
|
|
35
79
|
const clickHandler = () => {
|
|
36
|
-
emit(
|
|
37
|
-
}
|
|
80
|
+
emit('click')
|
|
81
|
+
}
|
|
38
82
|
</script>
|
|
39
83
|
|
|
40
84
|
<style lang="scss" scoped>
|
|
41
|
-
@import
|
|
85
|
+
@import './index.scss';
|
|
42
86
|
</style>
|
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
2
|
|
|
3
3
|
export default interface HyOverlayProps {
|
|
4
4
|
/**
|
|
5
5
|
* @description 是否显示遮罩(默认 false )
|
|
6
6
|
* */
|
|
7
|
-
show: boolean
|
|
7
|
+
show: boolean
|
|
8
8
|
/**
|
|
9
9
|
* @description zIndex 层级(默认 10070 )
|
|
10
10
|
* */
|
|
11
|
-
zIndex?: number
|
|
11
|
+
zIndex?: number
|
|
12
12
|
/**
|
|
13
13
|
* @description 动画时长,单位毫秒(默认 300 )
|
|
14
14
|
* */
|
|
15
|
-
duration?: number
|
|
15
|
+
duration?: number
|
|
16
16
|
/**
|
|
17
17
|
* @description 不透明度值,当做rgba的第四个参数 (默认 0.5 )
|
|
18
18
|
* */
|
|
19
|
-
opacity?: number
|
|
19
|
+
opacity?: number
|
|
20
20
|
/**
|
|
21
21
|
* @description 定义需要用到的外部样式
|
|
22
22
|
* */
|
|
23
|
-
customStyle?: CSSProperties
|
|
23
|
+
customStyle?: CSSProperties
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface IOverlayEmits {
|
|
27
|
+
/** 点击遮罩框触发 */
|
|
28
|
+
(e: 'click'): void
|
|
24
29
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
3
|
-
class="hy-pagination"
|
|
4
|
-
:style="customStyle"
|
|
5
|
-
v-if="!(hideIfOnePage && totalPageNum === 1)"
|
|
6
|
-
>
|
|
2
|
+
<view class="hy-pagination" :style="customStyle" v-if="!(hideIfOnePage && totalPageNum === 1)">
|
|
7
3
|
<view class="hy-pagination__content">
|
|
8
4
|
<hy-button
|
|
9
5
|
:plain="modelValue > 1"
|
|
@@ -17,7 +13,9 @@
|
|
|
17
13
|
<text v-if="!showIcon">{{ prevText }}</text>
|
|
18
14
|
<hy-icon
|
|
19
15
|
v-else
|
|
20
|
-
:class="`hy-pagination__left hy-pagination__icon ${
|
|
16
|
+
:class="`hy-pagination__left hy-pagination__icon ${
|
|
17
|
+
modelValue <= 1 ? 'hy-pagination__nav--disabled' : 'hy-pagination__nav--active'
|
|
18
|
+
}`"
|
|
21
19
|
:name="IconConfig.LEFT"
|
|
22
20
|
></hy-icon>
|
|
23
21
|
</hy-button>
|
|
@@ -37,7 +35,11 @@
|
|
|
37
35
|
<text v-if="!showIcon">{{ nextText }}</text>
|
|
38
36
|
<hy-icon
|
|
39
37
|
v-else
|
|
40
|
-
:custom-class="`hy-pagination__icon ${
|
|
38
|
+
:custom-class="`hy-pagination__icon ${
|
|
39
|
+
modelValue >= totalPageNum
|
|
40
|
+
? 'hy-pagination__nav--disabled'
|
|
41
|
+
: 'hy-pagination__nav--active'
|
|
42
|
+
}`"
|
|
41
43
|
:name="IconConfig.RIGHT"
|
|
42
44
|
></hy-icon>
|
|
43
45
|
</hy-button>
|
|
@@ -51,75 +53,130 @@
|
|
|
51
53
|
</template>
|
|
52
54
|
|
|
53
55
|
<script lang="ts">
|
|
56
|
+
/**
|
|
57
|
+
* 当数据量过多时,使用分页分解数据。
|
|
58
|
+
* @displayName hy-pagination
|
|
59
|
+
*/
|
|
60
|
+
defineOptions({})
|
|
54
61
|
export default {
|
|
55
|
-
name:
|
|
62
|
+
name: 'hy-pagination',
|
|
56
63
|
options: {
|
|
57
64
|
virtualHost: true,
|
|
58
65
|
addGlobalClass: true,
|
|
59
|
-
styleIsolation:
|
|
66
|
+
styleIsolation: 'shared',
|
|
60
67
|
},
|
|
61
|
-
}
|
|
68
|
+
}
|
|
62
69
|
</script>
|
|
63
70
|
|
|
64
71
|
<script lang="ts" setup>
|
|
65
|
-
import HyIcon from
|
|
66
|
-
import HyButton from
|
|
67
|
-
import { ref, toRefs, watch } from
|
|
68
|
-
import type
|
|
69
|
-
import
|
|
70
|
-
import { IconConfig } from "hy-app";
|
|
72
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
73
|
+
import HyButton from '../hy-button/hy-button.vue'
|
|
74
|
+
import { CSSProperties, PropType, ref, toRefs, watch } from 'vue'
|
|
75
|
+
import type { IPaginationEmits } from './typing'
|
|
76
|
+
import { IconConfig } from 'hy-app'
|
|
71
77
|
|
|
72
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
73
|
-
const
|
|
74
|
-
|
|
78
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
79
|
+
const props = defineProps({
|
|
80
|
+
/** 当前页 */
|
|
81
|
+
modelValue: {
|
|
82
|
+
type: Number,
|
|
83
|
+
default: 1,
|
|
84
|
+
},
|
|
85
|
+
/** 总页数,如果有total,则优先使用total计算页数 */
|
|
86
|
+
totalPage: {
|
|
87
|
+
type: Number,
|
|
88
|
+
default: 1,
|
|
89
|
+
},
|
|
90
|
+
/** 是否展示分页为Icon图标 */
|
|
91
|
+
showIcon: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false,
|
|
94
|
+
},
|
|
95
|
+
/** 是否展示总条数 */
|
|
96
|
+
showMessage: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: false,
|
|
99
|
+
},
|
|
100
|
+
/** 总条数 */
|
|
101
|
+
total: {
|
|
102
|
+
type: Number,
|
|
103
|
+
default: 0,
|
|
104
|
+
},
|
|
105
|
+
/** 每页条数 */
|
|
106
|
+
pageSize: {
|
|
107
|
+
type: Number,
|
|
108
|
+
default: 10,
|
|
109
|
+
},
|
|
110
|
+
/** 上一页文本 */
|
|
111
|
+
prevText: {
|
|
112
|
+
type: String,
|
|
113
|
+
default: '上一页',
|
|
114
|
+
},
|
|
115
|
+
/** 下一页文本 */
|
|
116
|
+
nextText: {
|
|
117
|
+
type: String,
|
|
118
|
+
default: '下一页',
|
|
119
|
+
},
|
|
120
|
+
/** 总页数只有一页时是否隐藏 */
|
|
121
|
+
hideIfOnePage: {
|
|
122
|
+
type: Boolean,
|
|
123
|
+
default: true,
|
|
124
|
+
},
|
|
125
|
+
/** 定义需要用到的外部样式 */
|
|
126
|
+
customStyle: {
|
|
127
|
+
type: Object as PropType<CSSProperties>,
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
const { pageSize, totalPage } = toRefs(props)
|
|
131
|
+
const emit = defineEmits<IPaginationEmits>()
|
|
75
132
|
|
|
76
|
-
const totalPageNum = ref<number>(0)
|
|
133
|
+
const totalPageNum = ref<number>(0) // 总页数
|
|
77
134
|
|
|
78
135
|
watch(
|
|
79
136
|
() => totalPage.value,
|
|
80
137
|
(newValue) => {
|
|
81
138
|
if (!totalPageNum.value && newValue) {
|
|
82
|
-
totalPageNum.value = totalPageNum.value
|
|
139
|
+
totalPageNum.value = totalPageNum.value
|
|
83
140
|
}
|
|
84
141
|
},
|
|
85
142
|
{ immediate: true, deep: true },
|
|
86
|
-
)
|
|
143
|
+
)
|
|
87
144
|
|
|
88
145
|
watch(
|
|
89
146
|
() => props.total,
|
|
90
147
|
() => {
|
|
91
|
-
updateTotalPage()
|
|
148
|
+
updateTotalPage()
|
|
92
149
|
},
|
|
93
150
|
{ immediate: true, deep: true },
|
|
94
|
-
)
|
|
151
|
+
)
|
|
95
152
|
|
|
96
153
|
/**
|
|
97
154
|
* @description 加数
|
|
98
155
|
* */
|
|
99
156
|
const add = () => {
|
|
100
|
-
const { modelValue } = props
|
|
157
|
+
const { modelValue } = props
|
|
101
158
|
if (modelValue > totalPageNum.value - 1) {
|
|
102
|
-
return
|
|
159
|
+
return
|
|
103
160
|
}
|
|
104
|
-
emit(
|
|
105
|
-
emit(
|
|
106
|
-
}
|
|
161
|
+
emit('change', { value: modelValue + 1 })
|
|
162
|
+
emit('update:modelValue', modelValue + 1)
|
|
163
|
+
}
|
|
107
164
|
|
|
108
165
|
const sub = () => {
|
|
109
|
-
const { modelValue } = props
|
|
166
|
+
const { modelValue } = props
|
|
110
167
|
if (modelValue < 2) {
|
|
111
|
-
return
|
|
168
|
+
return
|
|
112
169
|
}
|
|
113
|
-
emit(
|
|
114
|
-
emit(
|
|
115
|
-
}
|
|
170
|
+
emit('change', { value: modelValue - 1 })
|
|
171
|
+
emit('update:modelValue', modelValue - 1)
|
|
172
|
+
}
|
|
116
173
|
|
|
117
174
|
function updateTotalPage() {
|
|
118
|
-
const { total, pageSize } = props
|
|
119
|
-
totalPageNum.value = Math.ceil(total / pageSize)
|
|
175
|
+
const { total, pageSize } = props
|
|
176
|
+
totalPageNum.value = Math.ceil(total / pageSize)
|
|
120
177
|
}
|
|
121
178
|
</script>
|
|
122
179
|
|
|
123
180
|
<style lang="scss" scoped>
|
|
124
|
-
@import
|
|
181
|
+
@import './index.scss';
|
|
125
182
|
</style>
|
|
@@ -1,44 +1,53 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
2
|
|
|
3
3
|
export default interface HyPaginationProps {
|
|
4
4
|
/**
|
|
5
5
|
* @description 当前页
|
|
6
6
|
*/
|
|
7
|
-
modelValue: number
|
|
7
|
+
modelValue: number
|
|
8
8
|
/**
|
|
9
9
|
* @description 总页数,如果有total,则优先使用total计算页数
|
|
10
10
|
*/
|
|
11
|
-
totalPage?: number
|
|
11
|
+
totalPage?: number
|
|
12
12
|
/**
|
|
13
13
|
* @description 是否展示分页为Icon图标
|
|
14
14
|
*/
|
|
15
|
-
showIcon?: boolean
|
|
15
|
+
showIcon?: boolean
|
|
16
16
|
/**
|
|
17
17
|
* @desc 是否展示总条数
|
|
18
18
|
*/
|
|
19
|
-
showMessage?: boolean
|
|
19
|
+
showMessage?: boolean
|
|
20
20
|
/**
|
|
21
21
|
* @description 总条数
|
|
22
22
|
*/
|
|
23
|
-
total?: number
|
|
23
|
+
total?: number
|
|
24
24
|
/**
|
|
25
25
|
* @description 每页条数
|
|
26
26
|
*/
|
|
27
|
-
pageSize?: number
|
|
27
|
+
pageSize?: number
|
|
28
28
|
/**
|
|
29
29
|
* @description 上一页文本
|
|
30
30
|
*/
|
|
31
|
-
prevText?: string
|
|
31
|
+
prevText?: string
|
|
32
32
|
/**
|
|
33
33
|
* @description 下一页文本
|
|
34
34
|
*/
|
|
35
|
-
nextText?: string
|
|
35
|
+
nextText?: string
|
|
36
36
|
/**
|
|
37
37
|
* @description 总页数只有一页时是否隐藏
|
|
38
38
|
*/
|
|
39
|
-
hideIfOnePage?: boolean
|
|
39
|
+
hideIfOnePage?: boolean
|
|
40
40
|
/**
|
|
41
41
|
* @description 定义需要用到的外部样式
|
|
42
42
|
* */
|
|
43
|
-
customStyle?: CSSProperties
|
|
43
|
+
customStyle?: CSSProperties
|
|
44
|
+
}
|
|
45
|
+
type PaginationVo = {
|
|
46
|
+
value: number
|
|
47
|
+
}
|
|
48
|
+
export interface IPaginationEmits {
|
|
49
|
+
/** 改变值触发 */
|
|
50
|
+
(e: 'change', param: PaginationVo): void
|
|
51
|
+
/** 改变值触发 */
|
|
52
|
+
(e: 'update:modelValue', value: PaginationVo['value']): void
|
|
44
53
|
}
|