hy-app 0.4.13 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/hy-action-sheet/hy-action-sheet.vue +155 -238
- package/components/hy-action-sheet/props.ts +68 -15
- package/components/hy-action-sheet/typing.d.ts +115 -115
- package/components/hy-address-picker/hy-address-picker.vue +185 -289
- package/components/hy-address-picker/props.ts +97 -21
- package/components/hy-address-picker/typing.d.ts +90 -89
- package/components/hy-avatar/hy-avatar.vue +121 -204
- package/components/hy-avatar/props.ts +76 -18
- package/components/hy-avatar/typing.d.ts +63 -62
- package/components/hy-back-top/hy-back-top.vue +65 -120
- package/components/hy-back-top/props.ts +57 -16
- package/components/hy-back-top/typing.d.ts +43 -42
- package/components/hy-badge/hy-badge.vue +66 -138
- package/components/hy-badge/props.ts +73 -17
- package/components/hy-badge/typing.d.ts +59 -58
- package/components/hy-button/hy-button.vue +226 -375
- package/components/hy-button/props.ts +129 -158
- package/components/hy-calendar/header.vue +48 -64
- package/components/hy-calendar/hy-calendar.vue +274 -438
- package/components/hy-calendar/month.vue +508 -516
- package/components/hy-calendar/props.ts +157 -35
- package/components/hy-calendar/typing.d.ts +129 -128
- package/components/hy-card/hy-card.vue +118 -240
- package/components/hy-card/index.scss +1 -2
- package/components/hy-card/props.ts +122 -27
- package/components/hy-card/typing.d.ts +119 -118
- package/components/hy-cell/hy-cell.vue +176 -258
- package/components/hy-cell/props.ts +71 -17
- package/components/hy-cell/typing.d.ts +87 -86
- package/components/hy-check-button/hy-check-button.vue +69 -139
- package/components/hy-check-button/props.ts +72 -18
- package/components/hy-check-button/typing.d.ts +74 -73
- package/components/hy-checkbox/hy-checkbox.vue +170 -263
- package/components/hy-checkbox/props.ts +94 -24
- package/components/hy-checkbox/typing.d.ts +72 -72
- package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
- package/components/hy-checkbox-group/props.ts +80 -0
- package/components/hy-checkbox-group/typing.d.ts +65 -65
- package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
- package/components/hy-checkbox-item/props.ts +24 -0
- package/components/hy-checkbox-item/typing.d.ts +4 -3
- package/components/hy-code-input/hy-code-input.vue +179 -262
- package/components/hy-code-input/props.ts +84 -18
- package/components/hy-code-input/typing.d.ts +71 -71
- package/components/hy-config-provider/hy-config-provider.vue +28 -50
- package/components/hy-config-provider/props.ts +26 -11
- package/components/hy-config-provider/typing.d.ts +20 -20
- package/components/hy-count-down/hy-count-down.vue +103 -131
- package/components/hy-count-down/props.ts +30 -8
- package/components/hy-count-down/typing.d.ts +25 -25
- package/components/hy-count-to/hy-count-to.vue +148 -213
- package/components/hy-count-to/props.ts +60 -15
- package/components/hy-count-to/typing.d.ts +46 -46
- package/components/hy-coupon/README.md +133 -0
- package/components/hy-coupon/hy-coupon.vue +180 -0
- package/components/hy-coupon/index.scss +553 -0
- package/components/hy-coupon/props.ts +129 -0
- package/components/hy-coupon/typing.d.ts +146 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
- package/components/hy-datetime-picker/props.ts +142 -32
- package/components/hy-datetime-picker/typing.d.ts +132 -132
- package/components/hy-divider/hy-divider.vue +90 -169
- package/components/hy-divider/props.ts +78 -19
- package/components/hy-divider/typing.d.ts +60 -60
- package/components/hy-dropdown/hy-dropdown.vue +37 -71
- package/components/hy-dropdown/props.ts +38 -15
- package/components/hy-dropdown/typing.d.ts +44 -44
- package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
- package/components/hy-dropdown-item/props.ts +19 -8
- package/components/hy-empty/hy-empty.vue +75 -129
- package/components/hy-empty/props.ts +57 -15
- package/components/hy-empty/typing.d.ts +84 -84
- package/components/hy-flex/hy-flex.vue +33 -88
- package/components/hy-flex/props.ts +58 -0
- package/components/hy-flex/typing.d.ts +14 -16
- package/components/hy-float-button/hy-float-button.vue +289 -406
- package/components/hy-float-button/props.ts +109 -25
- package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
- package/components/hy-folding-panel/props.ts +40 -15
- package/components/hy-folding-panel/typing.d.ts +52 -63
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
- package/components/hy-folding-panel-item/index.scss +87 -0
- package/components/hy-folding-panel-item/props.ts +81 -0
- package/components/hy-folding-panel-item/typing.d.ts +23 -0
- package/components/hy-form/hy-form.vue +172 -212
- package/components/hy-form/props.ts +37 -0
- package/components/hy-form/typing.d.ts +68 -61
- package/components/hy-form-group/typing.d.ts +74 -74
- package/components/hy-form-item/hy-form-item.vue +100 -129
- package/components/hy-form-item/props.ts +25 -0
- package/components/hy-form-item/typing.d.ts +40 -37
- package/components/hy-grid/hy-grid.vue +76 -132
- package/components/hy-grid/props.ts +58 -16
- package/components/hy-grid/typing.d.ts +66 -66
- package/components/hy-icon/hy-icon.vue +84 -161
- package/components/hy-icon/props.ts +76 -22
- package/components/hy-icon/typing.d.ts +83 -82
- package/components/hy-image/hy-image.vue +142 -272
- package/components/hy-image/props.ts +105 -23
- package/components/hy-image/typing.d.ts +84 -87
- package/components/hy-input/hy-input.vue +230 -421
- package/components/hy-input/props.ts +183 -35
- package/components/hy-input/typing.d.ts +169 -169
- package/components/hy-line/hy-line.vue +34 -72
- package/components/hy-line/props.ts +41 -10
- package/components/hy-line/typing.d.ts +29 -29
- package/components/hy-line-progress/hy-line-progress.vue +66 -101
- package/components/hy-line-progress/props.ts +31 -10
- package/components/hy-line-progress/typing.d.ts +29 -29
- package/components/hy-list/hy-list.vue +151 -220
- package/components/hy-list/props.ts +67 -16
- package/components/hy-list/typing.d.ts +52 -52
- package/components/hy-loading/hy-loading.vue +63 -119
- package/components/hy-loading/props.ts +63 -15
- package/components/hy-loading/typing.d.ts +49 -49
- package/components/hy-menu/hy-menu.vue +124 -166
- package/components/hy-menu/props.ts +42 -10
- package/components/hy-menu/typing.d.ts +60 -60
- package/components/hy-modal/hy-modal.vue +127 -218
- package/components/hy-modal/props.ts +89 -24
- package/components/hy-navbar/hy-navbar.vue +104 -177
- package/components/hy-navbar/props.ts +76 -22
- package/components/hy-navbar/typing.d.ts +81 -81
- package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
- package/components/hy-notice-bar/props.ts +80 -19
- package/components/hy-notice-bar/typing.d.ts +62 -62
- package/components/hy-notify/hy-notify.vue +128 -177
- package/components/hy-notify/props.ts +49 -12
- package/components/hy-notify/typing.d.ts +45 -41
- package/components/hy-number-step/hy-number-step.vue +281 -394
- package/components/hy-number-step/props.ts +110 -27
- package/components/hy-number-step/typing.d.ts +120 -120
- package/components/hy-overlay/hy-overlay.vue +39 -66
- package/components/hy-overlay/props.ts +31 -8
- package/components/hy-pagination/hy-pagination.vue +100 -155
- package/components/hy-pagination/props.ts +53 -13
- package/components/hy-picker/hy-picker.vue +309 -430
- package/components/hy-picker/index.scss +8 -12
- package/components/hy-picker/props.ts +110 -26
- package/components/hy-popover/hy-popover.vue +190 -252
- package/components/hy-popover/props.ts +48 -10
- package/components/hy-popup/hy-popup.vue +162 -248
- package/components/hy-popup/props.ts +82 -18
- package/components/hy-price/hy-price.vue +45 -104
- package/components/hy-price/props.ts +52 -12
- package/components/hy-price/typing.d.ts +41 -36
- package/components/hy-qrcode/hy-qrcode.vue +115 -185
- package/components/hy-qrcode/props.ts +68 -18
- package/components/hy-qrcode/typing.d.ts +67 -66
- package/components/hy-radio/hy-radio.vue +161 -259
- package/components/hy-radio/props.ts +95 -25
- package/components/hy-radio/typing.d.ts +85 -84
- package/components/hy-rate/hy-rate.vue +185 -270
- package/components/hy-rate/props.ts +76 -18
- package/components/hy-rate/typing.d.ts +61 -60
- package/components/hy-read-more/hy-read-more.vue +93 -136
- package/components/hy-read-more/props.ts +43 -13
- package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
- package/components/hy-scroll-list/props.ts +22 -11
- package/components/hy-search/hy-search.vue +155 -284
- package/components/hy-search/props.ts +130 -25
- package/components/hy-signature/hy-signature.vue +491 -635
- package/components/hy-signature/props.ts +115 -26
- package/components/hy-signature/typing.d.ts +138 -138
- package/components/hy-slider/hy-slider.vue +388 -477
- package/components/hy-slider/props.ts +75 -19
- package/components/hy-steps/hy-steps.vue +212 -279
- package/components/hy-steps/props.ts +47 -13
- package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
- package/components/hy-submit-bar/props.ts +89 -20
- package/components/hy-submit-bar/typing.d.ts +86 -85
- package/components/hy-subsection/hy-subsection.vue +132 -185
- package/components/hy-subsection/props.ts +50 -17
- package/components/hy-subsection/typing.d.ts +52 -52
- package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
- package/components/hy-swipe-action/props.ts +43 -18
- package/components/hy-swipe-action/typing.d.ts +46 -46
- package/components/hy-swiper/hy-swiper.vue +159 -286
- package/components/hy-swiper/props.ts +126 -28
- package/components/hy-swiper/typing.d.ts +115 -115
- package/components/hy-switch/hy-switch.vue +112 -176
- package/components/hy-switch/props.ts +60 -15
- package/components/hy-switch/typing.d.ts +63 -63
- package/components/hy-tabBar/hy-tabBar.vue +64 -60
- package/components/hy-tabs/hy-tabs.vue +277 -380
- package/components/hy-tabs/props.ts +75 -18
- package/components/hy-tag/hy-tag.vue +111 -204
- package/components/hy-tag/props.ts +81 -19
- package/components/hy-text/hy-text.vue +200 -322
- package/components/hy-text/props.ts +107 -28
- package/components/hy-textarea/hy-textarea.vue +147 -256
- package/components/hy-textarea/props.ts +112 -25
- package/components/hy-textarea/typing.d.ts +42 -42
- package/components/hy-toast/hy-toast.vue +135 -143
- package/components/hy-tooltip/hy-tooltip.vue +220 -306
- package/components/hy-tooltip/props.ts +79 -15
- package/components/hy-transition/hy-transition.vue +111 -138
- package/components/hy-transition/props.ts +30 -8
- package/components/hy-upload/hy-upload.vue +320 -469
- package/components/hy-upload/props.ts +130 -27
- package/components/hy-warn/hy-warn.vue +80 -129
- package/components/hy-warn/props.ts +47 -12
- package/components/hy-waterfall/hy-waterfall.vue +139 -163
- package/components/hy-waterfall/props.ts +19 -7
- package/components/hy-watermark/hy-watermark.vue +762 -870
- package/components/hy-watermark/props.ts +103 -22
- package/global.d.ts +2 -0
- package/libs/css/theme.scss +3 -3
- package/package.json +2 -2
- package/web-types.json +1 -1
- package/components/hy-folding-panel/index.scss +0 -9
|
@@ -1,26 +1,113 @@
|
|
|
1
|
-
import type
|
|
2
|
-
const defaultProps: IProps = {
|
|
3
|
-
modelValue: "",
|
|
4
|
-
placeholder: "",
|
|
5
|
-
placeholderClass: "textarea-placeholder",
|
|
6
|
-
height: 70,
|
|
7
|
-
confirmType: "done",
|
|
8
|
-
disabled: false,
|
|
9
|
-
count: false,
|
|
10
|
-
focus: false,
|
|
11
|
-
autoHeight: false,
|
|
12
|
-
fixed: false,
|
|
13
|
-
cursorSpacing: 0,
|
|
14
|
-
cursor: "",
|
|
15
|
-
showConfirmBar: true,
|
|
16
|
-
selectionStart: -1,
|
|
17
|
-
selectionEnd: -1,
|
|
18
|
-
adjustPosition: true,
|
|
19
|
-
disableDefaultPadding: false,
|
|
20
|
-
holdKeyboard: false,
|
|
21
|
-
maxlength: 140,
|
|
22
|
-
border: "surround",
|
|
23
|
-
formatter: null,
|
|
24
|
-
};
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
25
2
|
|
|
26
|
-
|
|
3
|
+
const textareaProps = {
|
|
4
|
+
/** 输入框的内容 */
|
|
5
|
+
modelValue: {
|
|
6
|
+
type: String,
|
|
7
|
+
default: ''
|
|
8
|
+
},
|
|
9
|
+
/** 输入框为空时占位符 */
|
|
10
|
+
placeholder: String,
|
|
11
|
+
/** 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ */
|
|
12
|
+
placeholderClass: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: 'textarea-placeholder'
|
|
15
|
+
},
|
|
16
|
+
/** 指定placeholder的样式,对象形式 */
|
|
17
|
+
placeholderStyle: Object as PropType<CSSProperties>,
|
|
18
|
+
/** 输入框高度 */
|
|
19
|
+
height: {
|
|
20
|
+
type: [String, Number],
|
|
21
|
+
default: 70
|
|
22
|
+
},
|
|
23
|
+
/** 设置键盘右下角按钮的文字,仅微信小程序,App-vue和H5有效 */
|
|
24
|
+
confirmType: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'done'
|
|
27
|
+
},
|
|
28
|
+
/** 是否禁用 */
|
|
29
|
+
disabled: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
/** 是否显示统计字数 */
|
|
34
|
+
count: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
/** 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现 */
|
|
39
|
+
focus: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false
|
|
42
|
+
},
|
|
43
|
+
/** 是否自动增加高度 */
|
|
44
|
+
autoHeight: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false
|
|
47
|
+
},
|
|
48
|
+
/** 如果textarea是在一个position:fixed的区域,需要显示指定属性fixed为true */
|
|
49
|
+
fixed: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false
|
|
52
|
+
},
|
|
53
|
+
/** 指定光标与键盘的距离 */
|
|
54
|
+
cursorSpacing: {
|
|
55
|
+
type: Number,
|
|
56
|
+
default: 0
|
|
57
|
+
},
|
|
58
|
+
/** 指定focus时的光标位置 */
|
|
59
|
+
cursor: [String, Number],
|
|
60
|
+
/** 是否显示键盘上方带有”完成“按钮那一栏 */
|
|
61
|
+
showConfirmBar: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: true
|
|
64
|
+
},
|
|
65
|
+
/** 光标起始位置,自动聚焦时有效,需与selection-end搭配使用, */
|
|
66
|
+
selectionStart: {
|
|
67
|
+
type: Number,
|
|
68
|
+
default: -1
|
|
69
|
+
},
|
|
70
|
+
/** 光标结束位置,自动聚焦时有效,需与selection-start搭配使用 */
|
|
71
|
+
selectionEnd: {
|
|
72
|
+
type: Number,
|
|
73
|
+
default: -1
|
|
74
|
+
},
|
|
75
|
+
/** 键盘弹起时,是否自动上推页面 */
|
|
76
|
+
adjustPosition: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
default: true
|
|
79
|
+
},
|
|
80
|
+
/** 是否去掉 iOS 下的默认内边距,只微信小程序有效 */
|
|
81
|
+
disableDefaultPadding: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: false
|
|
84
|
+
},
|
|
85
|
+
/** focus时,点击页面的时候不收起键盘,只微信小程序有效 */
|
|
86
|
+
holdKeyboard: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false
|
|
89
|
+
},
|
|
90
|
+
/** 最大输入长度,设置为 -1 的时候不限制最大长度 */
|
|
91
|
+
maxlength: {
|
|
92
|
+
type: Number,
|
|
93
|
+
default: 140
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* 边框类型
|
|
97
|
+
* @values surround,none,bottom
|
|
98
|
+
* */
|
|
99
|
+
border: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: 'surround'
|
|
102
|
+
},
|
|
103
|
+
/** 内容式化函数 */
|
|
104
|
+
formatter: Function,
|
|
105
|
+
/** 定义需要用到的外部样式 */
|
|
106
|
+
customStyle: {
|
|
107
|
+
type: Object as PropType<CSSProperties>
|
|
108
|
+
},
|
|
109
|
+
/** 自定义外部类名 */
|
|
110
|
+
customClass: String
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default textareaProps
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from
|
|
3
|
+
InputOnBlurEvent,
|
|
4
|
+
InputOnConfirmEvent,
|
|
5
|
+
InputOnFocusEvent
|
|
6
|
+
} from '@uni-helper/uni-types'
|
|
7
7
|
|
|
8
8
|
export default interface HyTextareaProps {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
modelValue: string
|
|
10
|
+
placeholder?: string | null
|
|
11
|
+
placeholderClass?: string
|
|
12
|
+
placeholderStyle?: CSSProperties
|
|
13
|
+
height?: number
|
|
14
|
+
confirmType?: 'done' | 'send' | 'search' | 'next' | 'go'
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
count?: boolean
|
|
17
|
+
focus?: boolean
|
|
18
|
+
autoHeight?: boolean
|
|
19
|
+
fixed?: boolean
|
|
20
|
+
cursorSpacing?: number
|
|
21
|
+
cursor?: string
|
|
22
|
+
showConfirmBar?: boolean
|
|
23
|
+
selectionStart?: number
|
|
24
|
+
selectionEnd?: number
|
|
25
|
+
adjustPosition?: boolean
|
|
26
|
+
disableDefaultPadding?: boolean
|
|
27
|
+
holdKeyboard?: boolean
|
|
28
|
+
maxlength?: number
|
|
29
|
+
border?: HyApp.BorderType
|
|
30
|
+
formatter?: ((value: string) => string) | null
|
|
31
|
+
customStyle?: CSSProperties
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface ITextareaEmits {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
/** 输入框失去焦点时触发 */
|
|
36
|
+
(e: 'blur', event: InputOnBlurEvent): void
|
|
37
|
+
/** 输入框聚焦时触发 */
|
|
38
|
+
(e: 'focus', event: InputOnFocusEvent): void
|
|
39
|
+
/** 当键盘输入时,触发 input 事件 */
|
|
40
|
+
(e: 'change', value: string): void
|
|
41
|
+
/** 点击完成时, 触发 confirm 事件 */
|
|
42
|
+
(e: 'confirm', event: InputOnConfirmEvent): void
|
|
43
|
+
/** 输入框行数变化时调用 */
|
|
44
|
+
(e: 'lineChange', event: any): void
|
|
45
|
+
/** 当键盘输入时,触发 input 事件 */
|
|
46
|
+
(e: 'update:modelValue', value: string): void
|
|
47
|
+
/** 键盘高度发生变化的时候触发此事件 */
|
|
48
|
+
(e: 'keyboardheightchange', event: InputOnKeyboardheightchangeEvent): void
|
|
49
49
|
}
|
|
@@ -1,198 +1,190 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
!tmpConfig.icon ? `hy-toast__content--text__${tmpConfig.type}` : '',
|
|
29
|
-
]"
|
|
30
|
-
>
|
|
31
|
-
{{ tmpConfig.message }}
|
|
32
|
-
</text>
|
|
33
|
-
</view>
|
|
34
|
-
</HyOverlay>
|
|
2
|
+
<HyOverlay :show="isShow" :zIndex="tmpConfig.overlay ? 10070 : -1" :custom-style="overlayStyle">
|
|
3
|
+
<view :style="[contentStyle]" :class="contentClass">
|
|
4
|
+
<hy-loading
|
|
5
|
+
v-if="tmpConfig.loading"
|
|
6
|
+
:mode="tmpConfig.loadMode || 'circle'"
|
|
7
|
+
:color="loadingIconColor"
|
|
8
|
+
inactiveColor="#F0E6EF"
|
|
9
|
+
size="25"
|
|
10
|
+
:customStyle="{ marginBottom: '20px' }"
|
|
11
|
+
></hy-loading>
|
|
12
|
+
<view
|
|
13
|
+
v-else-if="iconNameCom"
|
|
14
|
+
:class="['hy-toast__content--icon', `hy-toast__content--icon__${tmpConfig.type}`]"
|
|
15
|
+
>
|
|
16
|
+
<hy-icon :name="iconNameCom" size="17" color="#FFFFFF"></hy-icon>
|
|
17
|
+
</view>
|
|
18
|
+
<text
|
|
19
|
+
:class="[
|
|
20
|
+
'hy-toast__content--text',
|
|
21
|
+
!tmpConfig.icon ? `hy-toast__content--text__${tmpConfig.type}` : ''
|
|
22
|
+
]"
|
|
23
|
+
>
|
|
24
|
+
{{ tmpConfig.message }}
|
|
25
|
+
</text>
|
|
26
|
+
</view>
|
|
27
|
+
</HyOverlay>
|
|
35
28
|
</template>
|
|
36
29
|
|
|
37
30
|
<script lang="ts">
|
|
38
31
|
export default {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
32
|
+
name: 'hy-toast',
|
|
33
|
+
options: {
|
|
34
|
+
addGlobalClass: true,
|
|
35
|
+
virtualHost: true,
|
|
36
|
+
styleIsolation: 'shared'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
46
39
|
</script>
|
|
47
40
|
|
|
48
41
|
<script setup lang="ts">
|
|
49
|
-
import { computed, onMounted, onUnmounted, reactive, ref } from
|
|
50
|
-
import type { CSSProperties } from
|
|
51
|
-
import type ToastOptions from
|
|
52
|
-
import { ColorConfig, iconName, getWindowInfo, hexToRgb } from
|
|
42
|
+
import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
|
|
43
|
+
import type { CSSProperties } from 'vue'
|
|
44
|
+
import type ToastOptions from './typing'
|
|
45
|
+
import { ColorConfig, iconName, getWindowInfo, hexToRgb } from '../../libs'
|
|
53
46
|
// 组件
|
|
54
|
-
import HyOverlay from
|
|
55
|
-
import HyIcon from
|
|
56
|
-
import HyLoading from
|
|
47
|
+
import HyOverlay from '../hy-overlay/hy-overlay.vue'
|
|
48
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
49
|
+
import HyLoading from '../hy-loading/hy-loading.vue'
|
|
57
50
|
|
|
58
51
|
/**
|
|
59
52
|
* Toast 组件主要用于消息通知、加载提示、操作结果提示等醒目提示效果,我们为其提供了多种丰富的API。
|
|
60
53
|
* @displayName hy-toast
|
|
61
54
|
*/
|
|
62
|
-
defineOptions({})
|
|
55
|
+
defineOptions({})
|
|
63
56
|
|
|
64
|
-
const isShow = ref(false)
|
|
65
|
-
const tmpConfig = ref<ToastOptions>({})
|
|
57
|
+
const isShow = ref(false)
|
|
58
|
+
const tmpConfig = ref<ToastOptions>({})
|
|
66
59
|
const config: ToastOptions = reactive({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})
|
|
76
|
-
let timer: any = null
|
|
60
|
+
message: '',
|
|
61
|
+
type: '',
|
|
62
|
+
duration: 2000,
|
|
63
|
+
icon: false,
|
|
64
|
+
position: 'center',
|
|
65
|
+
complete: null,
|
|
66
|
+
overlay: true,
|
|
67
|
+
loading: false
|
|
68
|
+
})
|
|
69
|
+
let timer: any = null
|
|
77
70
|
|
|
78
71
|
const isThemeType = (type: string): boolean =>
|
|
79
|
-
|
|
72
|
+
['error', 'warning', 'success', 'primary', 'info'].includes(type)
|
|
80
73
|
|
|
81
74
|
const overlayStyle = computed(() => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
})
|
|
75
|
+
const style: CSSProperties = {
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
display: 'flex'
|
|
79
|
+
}
|
|
80
|
+
// 将遮罩设置为100%透明度,避免出现灰色背景
|
|
81
|
+
style.backgroundColor = 'rgba(0, 0, 0, 0)'
|
|
82
|
+
return style
|
|
83
|
+
})
|
|
91
84
|
|
|
92
85
|
const iconNameCom = computed(() => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
// 只有不为none,并且type为error|warning|succes|info时候,才显示图标
|
|
87
|
+
if (!tmpConfig.value.icon || !tmpConfig.value.type) {
|
|
88
|
+
return ''
|
|
89
|
+
}
|
|
90
|
+
if (tmpConfig.value.icon === true) {
|
|
91
|
+
if (isThemeType(tmpConfig.value.type)) {
|
|
92
|
+
return iconName(tmpConfig.value.type)
|
|
93
|
+
} else {
|
|
94
|
+
return ''
|
|
95
|
+
}
|
|
100
96
|
} else {
|
|
101
|
-
|
|
97
|
+
return tmpConfig.value.icon
|
|
102
98
|
}
|
|
103
|
-
|
|
104
|
-
return tmpConfig.value.icon;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
99
|
+
})
|
|
107
100
|
|
|
108
101
|
/**
|
|
109
102
|
* @description 内容盒子的样式
|
|
110
103
|
* */
|
|
111
104
|
const contentStyle = computed(() => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
})
|
|
105
|
+
const windowHeight = getWindowInfo().windowHeight,
|
|
106
|
+
style: CSSProperties = {}
|
|
107
|
+
let value = 0
|
|
108
|
+
// 根据top和bottom,对Y轴进行窗体高度的百分比偏移
|
|
109
|
+
if (tmpConfig.value.position === 'top') {
|
|
110
|
+
value = -windowHeight * 0.25
|
|
111
|
+
} else if (tmpConfig.value.position === 'bottom') {
|
|
112
|
+
value = windowHeight * 0.25
|
|
113
|
+
}
|
|
114
|
+
style.transform = `translateY(${value}px)`
|
|
115
|
+
return style
|
|
116
|
+
})
|
|
124
117
|
|
|
125
118
|
const contentClass = computed(() => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
})
|
|
119
|
+
return [
|
|
120
|
+
'hy-toast__content',
|
|
121
|
+
'hy-toast__' + tmpConfig.value.type,
|
|
122
|
+
tmpConfig.value.loading && 'hy-toast__content--loading'
|
|
123
|
+
]
|
|
124
|
+
})
|
|
132
125
|
|
|
133
126
|
const loadingIconColor = computed(() => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
})
|
|
127
|
+
let colorTmp = 'rgb(255, 255, 255)'
|
|
128
|
+
if (isThemeType(tmpConfig.value.type!)) {
|
|
129
|
+
// loading-icon组件内部会对color参数进行一个透明度处理,该方法要求传入的颜色值
|
|
130
|
+
// 必须为rgb格式的,所以这里做一个处理
|
|
131
|
+
colorTmp = hexToRgb(ColorConfig[tmpConfig.value.type!]) as string
|
|
132
|
+
}
|
|
133
|
+
return colorTmp
|
|
134
|
+
})
|
|
142
135
|
|
|
143
136
|
onMounted(() => {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
})
|
|
137
|
+
// 监听全局事件
|
|
138
|
+
uni.$on('__hy_toast_open__', show)
|
|
139
|
+
uni.$on('__hy_toast_close__', hide)
|
|
140
|
+
})
|
|
148
141
|
|
|
149
142
|
onUnmounted(() => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
})
|
|
143
|
+
uni.$off('__hy_toast_open__', show)
|
|
144
|
+
uni.$off('__hy_toast_close__', hide)
|
|
145
|
+
})
|
|
153
146
|
|
|
154
147
|
/**
|
|
155
148
|
* @description 显示toast组件,由父组件通过xxx.show(options)形式调用
|
|
156
149
|
* */
|
|
157
150
|
const show = (options: ToastOptions) => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
tmpConfig.value.
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
};
|
|
151
|
+
// 不将结果合并到this.config变量,避免多次调用u-toast,前后的配置造成混乱
|
|
152
|
+
tmpConfig.value = Object.assign(config, options)
|
|
153
|
+
// 清除定时器
|
|
154
|
+
clearTimer()
|
|
155
|
+
isShow.value = true
|
|
156
|
+
// -1时不自动关闭
|
|
157
|
+
if (tmpConfig.value.duration !== -1 && !tmpConfig.value.loading) {
|
|
158
|
+
timer = setTimeout(() => {
|
|
159
|
+
// 倒计时结束,清除定时器,隐藏toast组件
|
|
160
|
+
clearTimer()
|
|
161
|
+
// 判断是否存在callback方法,如果存在就执行
|
|
162
|
+
typeof tmpConfig.value.complete === 'function' && tmpConfig.value.complete()
|
|
163
|
+
}, tmpConfig.value.duration)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
174
166
|
|
|
175
167
|
// 隐藏toast组件,由父组件通过this.$refs.xxx.hide()形式调用
|
|
176
168
|
const hide = () => {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
169
|
+
config.loading = false
|
|
170
|
+
clearTimer()
|
|
171
|
+
}
|
|
180
172
|
/**
|
|
181
173
|
* @description 清除定时任务
|
|
182
174
|
* */
|
|
183
175
|
const clearTimer = () => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
176
|
+
isShow.value = false
|
|
177
|
+
// 清除定时器
|
|
178
|
+
clearTimeout(timer)
|
|
179
|
+
timer = null
|
|
180
|
+
}
|
|
189
181
|
|
|
190
182
|
defineExpose({
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
})
|
|
183
|
+
show,
|
|
184
|
+
hide
|
|
185
|
+
})
|
|
194
186
|
</script>
|
|
195
187
|
|
|
196
188
|
<style scoped lang="scss">
|
|
197
|
-
@import
|
|
189
|
+
@import './index.scss';
|
|
198
190
|
</style>
|