bge-ui 1.0.21 → 1.0.22
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/dist/icons/index.d.ts +109 -109
- package/dist/index.js +1598 -1530
- package/dist/message/index.vue.d.ts +1 -49
- package/dist/style.css +110 -84
- package/dist/tabs/index.vue.d.ts +4 -2
- package/dist/tooltip/index.vue.d.ts +28 -0
- package/icons/generate.ts +0 -1
- package/package.json +1 -1
- package/src/button/index.vue +26 -4
- package/src/dialog/index.vue +1 -1
- package/src/form/index.vue +1 -1
- package/src/icons/CoinHkd.vue +0 -1
- package/src/icons/CoinUsd.vue +0 -1
- package/src/icons/ColorC2All.vue +0 -1
- package/src/icons/ColorC2Api.vue +0 -1
- package/src/icons/ColorC2Assets.vue +0 -1
- package/src/icons/ColorC2Bill1.vue +0 -1
- package/src/icons/ColorC2Bill2.vue +0 -1
- package/src/icons/ColorC2Card.vue +0 -1
- package/src/icons/ColorC2Complete.vue +0 -1
- package/src/icons/ColorC2Deal.vue +0 -1
- package/src/icons/ColorC2Email.vue +0 -1
- package/src/icons/ColorC2Fee.vue +0 -1
- package/src/icons/ColorC2Google.vue +0 -1
- package/src/icons/ColorC2Home.vue +0 -1
- package/src/icons/ColorC2Kyc.vue +0 -1
- package/src/icons/ColorC2Language.vue +0 -1
- package/src/icons/ColorC2Level.vue +0 -1
- package/src/icons/ColorC2Notification.vue +0 -1
- package/src/icons/ColorC2Pdf.vue +0 -1
- package/src/icons/ColorC2Phone.vue +0 -1
- package/src/icons/ColorC2Register.vue +0 -1
- package/src/icons/ColorC2RightDown.vue +0 -1
- package/src/icons/ColorC2RightUp.vue +0 -1
- package/src/icons/ColorC2Safe.vue +0 -1
- package/src/icons/ColorC2SafeShield.vue +0 -1
- package/src/icons/ColorC2TrafficCone.vue +0 -1
- package/src/icons/ColorC2User.vue +0 -1
- package/src/icons/ColorC2UserEvery.vue +0 -1
- package/src/icons/ColorC3Audits.vue +0 -1
- package/src/icons/ColorC3Card.vue +0 -1
- package/src/icons/ColorC3Company.vue +0 -1
- package/src/icons/ColorC3Deposit.vue +0 -1
- package/src/icons/ColorC3Establish.vue +0 -1
- package/src/icons/ColorC3Framework.vue +0 -1
- package/src/icons/ColorC3Kyc.vue +0 -1
- package/src/icons/ColorC3Licensing.vue +0 -1
- package/src/icons/ColorC3NotPassed.vue +0 -1
- package/src/icons/ColorC3Pass.vue +0 -1
- package/src/icons/ColorC3Safes.vue +0 -1
- package/src/icons/ColorC3Trading.vue +0 -1
- package/src/icons/ColorC3User.vue +0 -1
- package/src/icons/ColorC3UserEvery.vue +0 -1
- package/src/icons/ColorC3UserFollow.vue +0 -1
- package/src/icons/ColorCloseFill.vue +0 -1
- package/src/icons/ColorCompletedFill.vue +0 -1
- package/src/icons/ColorCookie.vue +0 -1
- package/src/icons/ColorStar.vue +0 -1
- package/src/icons/ColorSuccessFill.vue +0 -1
- package/src/icons/ColorTimeFill.vue +0 -1
- package/src/icons/ColorTowardFill.vue +0 -1
- package/src/icons/IntlCh.vue +0 -1
- package/src/icons/IntlEn.vue +0 -1
- package/src/icons/IntlEur.vue +0 -1
- package/src/icons/IntlHkg.vue +0 -1
- package/src/icons/IntlJpn.vue +0 -1
- package/src/icons/IntlKor.vue +0 -1
- package/src/icons/IntlUsa.vue +0 -1
- package/src/icons/IntlVnm.vue +0 -1
- package/src/icons/MediaFacebook.vue +0 -1
- package/src/icons/MediaInstagram.vue +0 -1
- package/src/icons/MediaLinked.vue +0 -1
- package/src/icons/MediaTwitter.vue +0 -1
- package/src/icons/MonoAdd.vue +0 -1
- package/src/icons/MonoAddSubtract.vue +0 -1
- package/src/icons/MonoAndroid.vue +0 -1
- package/src/icons/MonoApi.vue +0 -1
- package/src/icons/MonoApple.vue +0 -1
- package/src/icons/MonoArrowDown.vue +0 -1
- package/src/icons/MonoArrowUp.vue +0 -1
- package/src/icons/MonoAssets.vue +0 -1
- package/src/icons/MonoAudit.vue +0 -1
- package/src/icons/MonoBankCard.vue +0 -1
- package/src/icons/MonoBuilding.vue +0 -1
- package/src/icons/MonoCalendar.vue +0 -1
- package/src/icons/MonoCheckFill.vue +0 -1
- package/src/icons/MonoChevronLeft.vue +0 -1
- package/src/icons/MonoChevronRight.vue +0 -1
- package/src/icons/MonoChevronRightDouble.vue +0 -1
- package/src/icons/MonoClassify01.vue +0 -1
- package/src/icons/MonoClassify02.vue +0 -1
- package/src/icons/MonoClose.vue +0 -1
- package/src/icons/MonoCloseOne.vue +0 -1
- package/src/icons/MonoComplete.vue +0 -1
- package/src/icons/MonoCopy.vue +0 -1
- package/src/icons/MonoDocunment.vue +0 -1
- package/src/icons/MonoEdit.vue +0 -1
- package/src/icons/MonoEmail01.vue +0 -1
- package/src/icons/MonoEmail02.vue +0 -1
- package/src/icons/MonoExclamationmarkFill.vue +0 -1
- package/src/icons/MonoEye.vue +0 -1
- package/src/icons/MonoEyeClose.vue +0 -1
- package/src/icons/MonoGoogleplay.vue +0 -1
- package/src/icons/MonoHelp.vue +0 -1
- package/src/icons/MonoInternational.vue +0 -1
- package/src/icons/MonoLess.vue +0 -1
- package/src/icons/MonoLoading.vue +0 -1
- package/src/icons/MonoLogout.vue +0 -1
- package/src/icons/MonoMenu.vue +0 -1
- package/src/icons/MonoMoon.vue +0 -1
- package/src/icons/MonoMore.vue +0 -1
- package/src/icons/MonoNotification.vue +0 -1
- package/src/icons/MonoOtherDevice.vue +0 -1
- package/src/icons/MonoPhone.vue +0 -1
- package/src/icons/MonoPic.vue +0 -1
- package/src/icons/MonoPicError.vue +0 -1
- package/src/icons/MonoRemove.vue +0 -1
- package/src/icons/MonoRoute.vue +0 -1
- package/src/icons/MonoSafety.vue +0 -1
- package/src/icons/MonoSearch.vue +0 -1
- package/src/icons/MonoSun.vue +0 -1
- package/src/icons/MonoTime.vue +0 -1
- package/src/icons/MonoTowardFill.vue +0 -1
- package/src/icons/MonoTransfer.vue +0 -1
- package/src/icons/MonoTrash.vue +0 -1
- package/src/icons/MonoWallet.vue +0 -1
- package/src/icons/MonoWin.vue +0 -1
- package/src/icons/index.ts +148 -148
- package/src/input/index.vue +2 -2
- package/src/link/index.vue +0 -2
- package/src/message/index.vue +13 -8
- package/src/notification/index.vue +209 -0
- package/src/select/index.vue +3 -0
- package/src/select/option.vue +0 -0
- package/src/tabs/index.vue +6 -8
- package/src/tabs/tab-pane.vue +2 -2
- package/src/tooltip/index.vue +70 -11
package/src/message/index.vue
CHANGED
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
import MonoCheckFill from "../icons/MonoCheckFill.vue"
|
|
15
15
|
import MonoExclamationmarkFill from "../icons/MonoExclamationmarkFill.vue"
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
import { defineEmits, onMounted, ref, computed, CSSProperties
|
|
17
|
+
import { useResizeObserver, useTimeoutFn } from '@vueuse/core'
|
|
18
|
+
import { defineEmits, onMounted, ref, computed, CSSProperties } from 'vue'
|
|
19
19
|
|
|
20
20
|
const visible = ref(false)
|
|
21
21
|
const messageRef = ref<HTMLDivElement>()
|
|
22
22
|
const icon = computed(() => {
|
|
23
|
-
const map = {
|
|
23
|
+
const map: any = {
|
|
24
24
|
success: MonoCheckFill,
|
|
25
25
|
error: MonoExclamationmarkFill,
|
|
26
26
|
info: ''
|
|
@@ -28,7 +28,11 @@ const icon = computed(() => {
|
|
|
28
28
|
return map[props.type]
|
|
29
29
|
})
|
|
30
30
|
const props: any = defineProps({
|
|
31
|
-
id:
|
|
31
|
+
id: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: '',
|
|
34
|
+
required: true
|
|
35
|
+
},
|
|
32
36
|
type: {
|
|
33
37
|
type: String,
|
|
34
38
|
default: 'info',
|
|
@@ -47,7 +51,7 @@ const props: any = defineProps({
|
|
|
47
51
|
message: {
|
|
48
52
|
type: [Object, String]
|
|
49
53
|
},
|
|
50
|
-
onClose: Function,
|
|
54
|
+
onClose: [Function, undefined],
|
|
51
55
|
instances: Array
|
|
52
56
|
})
|
|
53
57
|
|
|
@@ -70,7 +74,7 @@ function clearTimer() {
|
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
const getInstance = (id: string) => {
|
|
73
|
-
const idx = props.instances.findIndex((instance) => instance.id === id)
|
|
77
|
+
const idx = props.instances.findIndex((instance: {id: String}) => instance.id === id)
|
|
74
78
|
const current = props.instances[idx]
|
|
75
79
|
let prev: any | undefined
|
|
76
80
|
if (idx > 0) {
|
|
@@ -84,7 +88,7 @@ const getLastOffset = (id: string): number => {
|
|
|
84
88
|
return prev.vm.exposed!.bottom.value
|
|
85
89
|
}
|
|
86
90
|
const getOffsetOrSpace = (id: string, offset: number) => {
|
|
87
|
-
const idx = props.instances.findIndex((instance) => instance.id === id)
|
|
91
|
+
const idx = props.instances.findIndex((instance: {id: String}) => instance.id === id)
|
|
88
92
|
return idx > 0 ? 12 : offset
|
|
89
93
|
}
|
|
90
94
|
|
|
@@ -126,6 +130,7 @@ defineExpose({
|
|
|
126
130
|
left: 50%;
|
|
127
131
|
top: 60px;
|
|
128
132
|
transform: translateX(-50%);
|
|
133
|
+
border-radius: var(--radius-small, 4px);
|
|
129
134
|
display: inline-block;
|
|
130
135
|
max-width: 320px;
|
|
131
136
|
transition: opacity 0.3s, transform 0.4s, top 0.4s;
|
|
@@ -133,7 +138,7 @@ defineExpose({
|
|
|
133
138
|
overflow: hidden;
|
|
134
139
|
color: var(--persistent-white, #FFF);
|
|
135
140
|
/* shadow1 */
|
|
136
|
-
box-shadow: 0px 12px 40px 0px rgba(0, 0, 0, 0.08);
|
|
141
|
+
box-shadow: var(--shadow1, '0px 12px 40px 0px rgba(0, 0, 0, 0.08)');
|
|
137
142
|
|
|
138
143
|
&.info {
|
|
139
144
|
background: var(--bg-tooltip, #53677A);
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<transition name="fade" @before-leave="onClose" @after-leave="$emit('destroy')">
|
|
3
|
+
<div v-show="visible" :id="id" ref="messageRef" :class="`bge-message ${type}`" :style="customStyle" role="alert"
|
|
4
|
+
@mouseenter="clearTimer" @mouseleave="startTimer">
|
|
5
|
+
<component v-if="icon" :is="icon" class="bge-message__icon" :size="20" />
|
|
6
|
+
<slot>
|
|
7
|
+
<p v-html="message"></p>
|
|
8
|
+
</slot>
|
|
9
|
+
</div>
|
|
10
|
+
</transition>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import MonoCheckFill from "../icons/MonoCheckFill.vue"
|
|
15
|
+
import MonoExclamationmarkFill from "../icons/MonoExclamationmarkFill.vue"
|
|
16
|
+
|
|
17
|
+
import { useResizeObserver, useTimeoutFn } from '@vueuse/core'
|
|
18
|
+
import { defineEmits, onMounted, ref, computed, CSSProperties } from 'vue'
|
|
19
|
+
|
|
20
|
+
const visible = ref(false)
|
|
21
|
+
const messageRef = ref<HTMLDivElement>()
|
|
22
|
+
const icon = computed(() => {
|
|
23
|
+
const map: any = {
|
|
24
|
+
success: MonoCheckFill,
|
|
25
|
+
error: MonoExclamationmarkFill,
|
|
26
|
+
info: ''
|
|
27
|
+
}
|
|
28
|
+
return map[props.type]
|
|
29
|
+
})
|
|
30
|
+
const props: any = defineProps({
|
|
31
|
+
id: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: '',
|
|
34
|
+
required: true
|
|
35
|
+
},
|
|
36
|
+
type: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: 'info',
|
|
39
|
+
value: [
|
|
40
|
+
'success',
|
|
41
|
+
'error',
|
|
42
|
+
'info',
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
offset: {
|
|
46
|
+
type: Number,
|
|
47
|
+
default: 64,
|
|
48
|
+
},
|
|
49
|
+
stopTimer: Number,
|
|
50
|
+
duration: Number,
|
|
51
|
+
message: {
|
|
52
|
+
type: [Object, String]
|
|
53
|
+
},
|
|
54
|
+
onClose: [Function, undefined],
|
|
55
|
+
instances: Array
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
let stopTimer: (() => void) | undefined = undefined
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function startTimer() {
|
|
62
|
+
if (props.duration === 0) return
|
|
63
|
+
; ({ stop: stopTimer } = useTimeoutFn(() => {
|
|
64
|
+
close()
|
|
65
|
+
}, props.duration))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function close() {
|
|
69
|
+
visible.value = false
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function clearTimer() {
|
|
73
|
+
stopTimer?.()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const getInstance = (id: string) => {
|
|
77
|
+
const idx = props.instances.findIndex((instance: {id: String}) => instance.id === id)
|
|
78
|
+
const current = props.instances[idx]
|
|
79
|
+
let prev: any | undefined
|
|
80
|
+
if (idx > 0) {
|
|
81
|
+
prev = props.instances[idx - 1]
|
|
82
|
+
}
|
|
83
|
+
return { current, prev }
|
|
84
|
+
}
|
|
85
|
+
const getLastOffset = (id: string): number => {
|
|
86
|
+
const { prev } = getInstance(id)
|
|
87
|
+
if (!prev) return 0
|
|
88
|
+
return prev.vm.exposed!.bottom.value
|
|
89
|
+
}
|
|
90
|
+
const getOffsetOrSpace = (id: string, offset: number) => {
|
|
91
|
+
const idx = props.instances.findIndex((instance: {id: String}) => instance.id === id)
|
|
92
|
+
return idx > 0 ? 12 : offset
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const height = ref(0)
|
|
96
|
+
const lastOffset = computed(() => getLastOffset(props.id))
|
|
97
|
+
const offset = computed(
|
|
98
|
+
() => getOffsetOrSpace(props.id, props.offset) + lastOffset.value
|
|
99
|
+
)
|
|
100
|
+
const bottom = computed((): number => height.value + offset.value)
|
|
101
|
+
|
|
102
|
+
const customStyle = computed<CSSProperties>(() => {
|
|
103
|
+
return {
|
|
104
|
+
top: `${offset.value}px`,
|
|
105
|
+
zIndex: 3000,
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
onMounted(() => {
|
|
109
|
+
visible.value = true
|
|
110
|
+
startTimer()
|
|
111
|
+
})
|
|
112
|
+
const emit = defineEmits([
|
|
113
|
+
'destroy'
|
|
114
|
+
])
|
|
115
|
+
|
|
116
|
+
useResizeObserver(messageRef, () => {
|
|
117
|
+
height.value = messageRef.value!.getBoundingClientRect().height
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
defineExpose({
|
|
121
|
+
visible,
|
|
122
|
+
bottom,
|
|
123
|
+
close,
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
</script>
|
|
127
|
+
<style lang="scss" >
|
|
128
|
+
.bge-message {
|
|
129
|
+
position: fixed;
|
|
130
|
+
left: 50%;
|
|
131
|
+
top: 60px;
|
|
132
|
+
transform: translateX(-50%);
|
|
133
|
+
display: inline-block;
|
|
134
|
+
max-width: 320px;
|
|
135
|
+
transition: opacity 0.3s, transform 0.4s, top 0.4s;
|
|
136
|
+
padding: var(--layout-x-2, 8px) var(--layout-x-4, 16px);
|
|
137
|
+
overflow: hidden;
|
|
138
|
+
color: var(--persistent-white, #FFF);
|
|
139
|
+
/* shadow1 */
|
|
140
|
+
box-shadow: 0px 12px 40px 0px rgba(0, 0, 0, 0.08);
|
|
141
|
+
|
|
142
|
+
&.info {
|
|
143
|
+
background: var(--bg-tooltip, #53677A);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
&.error {
|
|
147
|
+
background: var(--bg-red, #D14770);
|
|
148
|
+
|
|
149
|
+
p {
|
|
150
|
+
width: calc(100% - 24px)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&.success {
|
|
155
|
+
background: var(--bg-green, #00A389);
|
|
156
|
+
|
|
157
|
+
p {
|
|
158
|
+
width: calc(100% - 24px)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.bge-message__icon {
|
|
163
|
+
vertical-align: middle;
|
|
164
|
+
margin-right: 4px;
|
|
165
|
+
flex-shrink: 0;
|
|
166
|
+
display: inline-block;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
p {
|
|
170
|
+
padding: 0;
|
|
171
|
+
margin: 0;
|
|
172
|
+
display: inline-block;
|
|
173
|
+
width: 100%;
|
|
174
|
+
vertical-align: middle;
|
|
175
|
+
white-space: nowrap;
|
|
176
|
+
overflow: hidden;
|
|
177
|
+
color: var(--persistent-white, #FFF);
|
|
178
|
+
text-overflow: ellipsis;
|
|
179
|
+
font-size: 14px;
|
|
180
|
+
font-style: normal;
|
|
181
|
+
font-weight: 400;
|
|
182
|
+
line-height: 24px;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
&.fade-enter-active {
|
|
187
|
+
transition: opacity 0.1s cubic-bezier(0, 0, 1, 1);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
&.fade-leave-active {
|
|
191
|
+
transition: all 0.3s cubic-bezier(0.34, 0.69, 0.1, 1);
|
|
192
|
+
|
|
193
|
+
svg,
|
|
194
|
+
p {
|
|
195
|
+
opacity: 0.3;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
&.fade-leave-to {
|
|
200
|
+
opacity: 0;
|
|
201
|
+
height: 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&.fade-enter-from {
|
|
205
|
+
opacity: 0;
|
|
206
|
+
transform: translate(-50%, -100%);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
</style>
|
|
File without changes
|
package/src/tabs/index.vue
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
</div>
|
|
8
8
|
</template>
|
|
9
9
|
<script setup lang="ts">
|
|
10
|
-
import {
|
|
10
|
+
import { provide, ref, onMounted } from "vue"
|
|
11
11
|
defineOptions({
|
|
12
12
|
name: "Tabs",
|
|
13
13
|
})
|
|
@@ -27,11 +27,11 @@ const props = defineProps({
|
|
|
27
27
|
}
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
-
const emits = defineEmits('update:modelValue')
|
|
30
|
+
const emits = defineEmits(['update:modelValue'])
|
|
31
31
|
|
|
32
32
|
const panes = ref<any>([])
|
|
33
33
|
|
|
34
|
-
function addPane(pane) {
|
|
34
|
+
function addPane(pane: any) {
|
|
35
35
|
panes.value.push(pane)
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -48,15 +48,13 @@ provide(tabsKey, {
|
|
|
48
48
|
changeValue
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
const getBarStyle:
|
|
51
|
+
const getBarStyle: any = () => {
|
|
52
52
|
let offset = 0
|
|
53
53
|
let tabSize = 0
|
|
54
54
|
|
|
55
55
|
const sizeName = 'width'
|
|
56
|
-
const sizeDir = sizeName === 'width' ? 'x' : 'y'
|
|
57
|
-
const position = sizeDir === 'x' ? 'left' : 'top'
|
|
58
56
|
|
|
59
|
-
panes.value.forEach((tab) => {
|
|
57
|
+
panes.value.forEach((tab: any) => {
|
|
60
58
|
const $el = tab.ref as HTMLElement
|
|
61
59
|
if (!$el) return false
|
|
62
60
|
if (tab.value !== props.modelValue) {
|
|
@@ -75,7 +73,7 @@ const getBarStyle: CSSProperties = () => {
|
|
|
75
73
|
transform: `translateX(${offset}px)`,
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
|
-
const barStyle = ref<
|
|
76
|
+
const barStyle = ref<any>()
|
|
79
77
|
const update = () => (barStyle.value = getBarStyle())
|
|
80
78
|
|
|
81
79
|
onMounted(() => {
|
package/src/tabs/tab-pane.vue
CHANGED
|
@@ -17,7 +17,7 @@ const props = defineProps({
|
|
|
17
17
|
import { ref, onMounted, inject, reactive } from "vue";
|
|
18
18
|
const tabPaneRef = ref<HTMLDivElement>()
|
|
19
19
|
const tabsKey = 'bge-tabs-context'
|
|
20
|
-
const tabContext = inject(tabsKey, undefined)
|
|
20
|
+
const tabContext: any = inject(tabsKey, undefined)
|
|
21
21
|
function changeValue() {
|
|
22
22
|
tabContext.changeValue(props.value)
|
|
23
23
|
}
|
|
@@ -40,7 +40,7 @@ onMounted(() => {
|
|
|
40
40
|
padding: var(--layout-x-2, 8px) var(--layout-x-3, 12px);
|
|
41
41
|
justify-content: center;
|
|
42
42
|
align-items: center;
|
|
43
|
-
border-radius: var(--radius-small,
|
|
43
|
+
border-radius: var(--radius-small, 4px);
|
|
44
44
|
background: var(--bg-input, rgba(88, 126, 163, 0.08));
|
|
45
45
|
margin-right: 4px;
|
|
46
46
|
color: var(--tc-tertiary, #53677A);
|
package/src/tooltip/index.vue
CHANGED
|
@@ -1,27 +1,50 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<ui-only-child ref="triggerRef" ariaDescribedby="tooltip">
|
|
2
|
+
<ui-only-child ref="triggerRef" ariaDescribedby="tooltip" @click="showToolTip">
|
|
3
3
|
<slot />
|
|
4
4
|
</ui-only-child>
|
|
5
5
|
<!-- <component :is="triggerElement">
|
|
6
6
|
<slot />
|
|
7
7
|
</component> -->
|
|
8
|
-
<
|
|
9
|
-
<
|
|
8
|
+
<template v-if="sreenWidth <= 768">
|
|
9
|
+
<UiDialog v-model:visible="dislogVisible" :title="title" @close="closeToolTip">
|
|
10
|
+
<div><slot name="content" /></div>
|
|
11
|
+
<UiButton class="bge-tooltip__closeButton" type="primary" @click="closeToolTip">{{ buttonText }}</UiButton>
|
|
12
|
+
</UiDialog>
|
|
13
|
+
</template>
|
|
14
|
+
<template v-else>
|
|
15
|
+
<teleport v-if="teleported" to="body">
|
|
16
|
+
<component :is="tooltipElement">
|
|
17
|
+
<slot name="content" />
|
|
18
|
+
</component>
|
|
19
|
+
</teleport>
|
|
20
|
+
<component v-else :is="tooltipElement">
|
|
10
21
|
<slot name="content" />
|
|
11
22
|
</component>
|
|
12
|
-
</
|
|
13
|
-
<component v-else :is="tooltipElement">
|
|
14
|
-
<slot name="content" />
|
|
15
|
-
</component>
|
|
23
|
+
</template>
|
|
16
24
|
</template>
|
|
17
25
|
<script setup lang="ts">
|
|
18
26
|
import { OnlyChild as UiOnlyChild } from './only-child'
|
|
19
27
|
import type { PropType } from 'vue'
|
|
20
|
-
import { computed, ref, onMounted } from 'vue';
|
|
28
|
+
import { computed, ref, onMounted, onBeforeMount, nextTick } from 'vue';
|
|
21
29
|
import type { PositioningStrategy, Placement, Modifier } from '@popperjs/core'
|
|
30
|
+
import UiDialog from '../dialog/index.vue'
|
|
31
|
+
import UiButton from '../button/index.vue'
|
|
22
32
|
import { usePopper } from './usePopper';
|
|
23
|
-
|
|
33
|
+
const sreenWidth = ref(0)
|
|
24
34
|
const props = defineProps({
|
|
35
|
+
/**
|
|
36
|
+
* title
|
|
37
|
+
*/
|
|
38
|
+
title: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: '详情',
|
|
41
|
+
required: true,
|
|
42
|
+
},
|
|
43
|
+
buttonText: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: '知道了',
|
|
46
|
+
required: true,
|
|
47
|
+
},
|
|
25
48
|
/**
|
|
26
49
|
* 是否将弹出层追加到body元素下
|
|
27
50
|
*/
|
|
@@ -156,7 +179,34 @@ const triggerRef = ref()
|
|
|
156
179
|
|
|
157
180
|
const popperInstance = ref<any>(), tooltipElement = ref<any>(), isOpened = ref<any>(), toggleTooltip = ref<any>()
|
|
158
181
|
|
|
159
|
-
|
|
182
|
+
const dislogVisible = ref(false)
|
|
183
|
+
|
|
184
|
+
onBeforeMount(() => {
|
|
185
|
+
sreenWidth.value = window.innerWidth
|
|
186
|
+
|
|
187
|
+
window.addEventListener('resize', () => {
|
|
188
|
+
sreenWidth.value = window.innerWidth
|
|
189
|
+
|
|
190
|
+
if (sreenWidth.value > 768) {
|
|
191
|
+
dislogVisible.value = false
|
|
192
|
+
}
|
|
193
|
+
nextTick(() => {
|
|
194
|
+
initTooltip()
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
function showToolTip() {
|
|
200
|
+
if (sreenWidth.value <= 768) {
|
|
201
|
+
dislogVisible.value = true
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function closeToolTip() {
|
|
206
|
+
dislogVisible.value = false
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function initTooltip() {
|
|
160
210
|
const result = usePopper(triggerRef, {
|
|
161
211
|
hover: props.hover,
|
|
162
212
|
disableClickOutside: props.disableClickOutside,
|
|
@@ -186,6 +236,10 @@ onMounted(() => {
|
|
|
186
236
|
isOpened.value = result.isOpened
|
|
187
237
|
toggleTooltip.value = result.toggleTooltip
|
|
188
238
|
tooltipElement.value = result.tooltipElement
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
onMounted(() => {
|
|
242
|
+
initTooltip()
|
|
189
243
|
})
|
|
190
244
|
|
|
191
245
|
defineExpose({
|
|
@@ -224,7 +278,7 @@ defineExpose({
|
|
|
224
278
|
.popper-content {
|
|
225
279
|
max-width: 360px;
|
|
226
280
|
box-shadow: 0px 12px 40px 0px rgba(0, 0, 0, 0.08);
|
|
227
|
-
border-radius: var(--radius-small,
|
|
281
|
+
border-radius: var(--radius-small, 4px);
|
|
228
282
|
background: var(--bg-tooltip, #53677A);
|
|
229
283
|
padding: var(--layout-x-3, 12px) var(--layout-x-4, 16px);
|
|
230
284
|
color: var(--persistent-tc-primary, #E0E0E0);
|
|
@@ -234,6 +288,11 @@ defineExpose({
|
|
|
234
288
|
}
|
|
235
289
|
}
|
|
236
290
|
|
|
291
|
+
.bge-tooltip__closeButton {
|
|
292
|
+
width: 100%;
|
|
293
|
+
margin-top: 40px;
|
|
294
|
+
}
|
|
295
|
+
|
|
237
296
|
[data-popper-arrow] {
|
|
238
297
|
position: absolute;
|
|
239
298
|
width: 8px;
|