@dataloop-ai/components 0.16.9 → 0.16.11
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/package.json
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
import { v4 } from 'uuid'
|
|
33
33
|
import { defineComponent } from 'vue-demi'
|
|
34
34
|
import { getColor, loggerFactory } from '../../../utils'
|
|
35
|
+
import { dynamicSvgImport } from '../../../utils/dynamicSvgImport'
|
|
35
36
|
|
|
36
37
|
export default defineComponent({
|
|
37
38
|
name: 'DlIcon',
|
|
@@ -104,7 +105,12 @@ export default defineComponent({
|
|
|
104
105
|
},
|
|
105
106
|
methods: {
|
|
106
107
|
loadSvg() {
|
|
107
|
-
return new Promise<void>((resolve, reject) => {
|
|
108
|
+
return new Promise<void>(async (resolve, reject) => {
|
|
109
|
+
let dynamicalImagePath = null
|
|
110
|
+
await dynamicSvgImport(this.icon).then((path: any) => {
|
|
111
|
+
dynamicalImagePath = path
|
|
112
|
+
})
|
|
113
|
+
|
|
108
114
|
const svgElement = new Image()
|
|
109
115
|
svgElement.setAttribute('height', this.size)
|
|
110
116
|
svgElement.setAttribute('width', this.size)
|
|
@@ -128,7 +134,7 @@ export default defineComponent({
|
|
|
128
134
|
try {
|
|
129
135
|
svgElement.src = this.svgSource
|
|
130
136
|
? `${this.svgSource}/${this.icon}.svg`
|
|
131
|
-
:
|
|
137
|
+
: dynamicalImagePath
|
|
132
138
|
} catch (e) {
|
|
133
139
|
reject(e)
|
|
134
140
|
}
|
|
@@ -347,13 +347,31 @@ export default defineComponent({
|
|
|
347
347
|
hide(evt)
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
function
|
|
350
|
+
function CheckAnchorElVisiblity(domElement: any) {
|
|
351
|
+
return new Promise((resolve) => {
|
|
352
|
+
const o = new IntersectionObserver(([entry]) => {
|
|
353
|
+
resolve(entry.intersectionRatio === 1)
|
|
354
|
+
o.disconnect()
|
|
355
|
+
})
|
|
356
|
+
o.observe(domElement)
|
|
357
|
+
})
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
async function updatePosition() {
|
|
351
361
|
const el = innerRef.value
|
|
352
362
|
|
|
353
363
|
if (el === null || anchorEl.value === null) {
|
|
354
364
|
return
|
|
355
365
|
}
|
|
356
366
|
|
|
367
|
+
const isAnchorElVisible = await CheckAnchorElVisiblity(
|
|
368
|
+
anchorEl.value
|
|
369
|
+
)
|
|
370
|
+
if (!isAnchorElVisible) {
|
|
371
|
+
hide()
|
|
372
|
+
return
|
|
373
|
+
}
|
|
374
|
+
|
|
357
375
|
setPosition({
|
|
358
376
|
el,
|
|
359
377
|
offset: props.offset as number[],
|
|
@@ -258,13 +258,31 @@ export default defineComponent({
|
|
|
258
258
|
cleanEvt(anchorEvents, 'tooltipTemp')
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
function
|
|
261
|
+
function CheckAnchorElVisiblity(domElement: any) {
|
|
262
|
+
return new Promise((resolve) => {
|
|
263
|
+
const o = new IntersectionObserver(([entry]) => {
|
|
264
|
+
resolve(entry.intersectionRatio === 1)
|
|
265
|
+
o.disconnect()
|
|
266
|
+
})
|
|
267
|
+
o.observe(domElement)
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
async function updatePosition() {
|
|
262
272
|
const el = innerRef.value
|
|
263
273
|
|
|
264
274
|
if (anchorEl.value === null || !el) {
|
|
265
275
|
return
|
|
266
276
|
}
|
|
267
277
|
|
|
278
|
+
const isAnchorElVisible = await CheckAnchorElVisiblity(
|
|
279
|
+
anchorEl.value
|
|
280
|
+
)
|
|
281
|
+
if (!isAnchorElVisible) {
|
|
282
|
+
hide()
|
|
283
|
+
return
|
|
284
|
+
}
|
|
285
|
+
|
|
268
286
|
setPosition({
|
|
269
287
|
el,
|
|
270
288
|
offset: props.offset as number[],
|
|
@@ -113,7 +113,7 @@ export default function ({
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
function hide(evt
|
|
116
|
+
function hide(evt?: AnchorEvent) {
|
|
117
117
|
if (props.disabled === true) {
|
|
118
118
|
return
|
|
119
119
|
}
|
|
@@ -138,7 +138,7 @@ export default function ({
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
function processHide(evt
|
|
141
|
+
function processHide(evt?: AnchorEvent) {
|
|
142
142
|
if (!showing.value) {
|
|
143
143
|
return
|
|
144
144
|
}
|