@dataloop-ai/components 0.18.8 → 0.18.10
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 +1 -1
- package/src/components/compound/DlCharts/charts/DlConfusionMatrix/DlConfusionMatrix.vue +11 -1
- package/src/components/compound/DlSelect/DlSelect.vue +9 -1
- package/src/components/essential/DlMenu/DlMenu.vue +16 -13
- package/src/components/shared/DlTooltip/DlTooltip.vue +9 -14
- package/src/hooks/use-anchor.ts +15 -0
package/package.json
CHANGED
|
@@ -282,6 +282,7 @@ export default defineComponent({
|
|
|
282
282
|
const cellWidth = ref<number | null>(null)
|
|
283
283
|
const rotateXLabels = ref(true)
|
|
284
284
|
const resizeObserver = ref<ResizeObserver>(null)
|
|
285
|
+
const isDisposed = ref(false)
|
|
285
286
|
|
|
286
287
|
const getCellBackground = (value: number = 1): string => {
|
|
287
288
|
const object: { [key: string]: any } = {
|
|
@@ -306,6 +307,9 @@ export default defineComponent({
|
|
|
306
307
|
if (Array.isArray(el)) {
|
|
307
308
|
el = el[0]
|
|
308
309
|
}
|
|
310
|
+
if (!el) {
|
|
311
|
+
return [0, 0]
|
|
312
|
+
}
|
|
309
313
|
const height = el.clientHeight
|
|
310
314
|
const offsetHeight = -1 * (height / 2)
|
|
311
315
|
return [0, offsetHeight]
|
|
@@ -325,7 +329,8 @@ export default defineComponent({
|
|
|
325
329
|
currentBrushState,
|
|
326
330
|
rotateXLabels,
|
|
327
331
|
calculateXAxisElOffset,
|
|
328
|
-
debouncedCalculateXAxisElOffset
|
|
332
|
+
debouncedCalculateXAxisElOffset,
|
|
333
|
+
isDisposed
|
|
329
334
|
}
|
|
330
335
|
},
|
|
331
336
|
computed: {
|
|
@@ -385,18 +390,21 @@ export default defineComponent({
|
|
|
385
390
|
}
|
|
386
391
|
},
|
|
387
392
|
mounted() {
|
|
393
|
+
this.isDisposed = false
|
|
388
394
|
if (!this.isValidMatrix) return
|
|
389
395
|
if (this.isEmpty) return
|
|
390
396
|
|
|
391
397
|
this.handleResizeObserver()
|
|
392
398
|
this.$nextTick(() => {
|
|
393
399
|
setTimeout(() => {
|
|
400
|
+
if (this.isDisposed) return
|
|
394
401
|
this.calculateRotatedXLabels()
|
|
395
402
|
this.updateBrush(this, this.currentBrushState)
|
|
396
403
|
}, 300)
|
|
397
404
|
})
|
|
398
405
|
},
|
|
399
406
|
beforeUnmount() {
|
|
407
|
+
this.isDisposed = true
|
|
400
408
|
this.handleResizeObserver({ dispose: true })
|
|
401
409
|
},
|
|
402
410
|
methods: {
|
|
@@ -410,6 +418,7 @@ export default defineComponent({
|
|
|
410
418
|
this.rotateXLabels = longest * 12 > getCellWidth()
|
|
411
419
|
},
|
|
412
420
|
handleResizeObserver(options: { dispose?: boolean } = {}) {
|
|
421
|
+
if (this.isDisposed) return
|
|
413
422
|
const { dispose } = options
|
|
414
423
|
if (dispose && this.resizeObserver) {
|
|
415
424
|
this.resizeObserver.unobserve(this.$refs.wrapper as Element)
|
|
@@ -425,6 +434,7 @@ export default defineComponent({
|
|
|
425
434
|
}
|
|
426
435
|
},
|
|
427
436
|
resizeMatrix() {
|
|
437
|
+
if (this.isDisposed) return
|
|
428
438
|
const colorSpectrum = this.$refs.colorSpectrum as HTMLElement
|
|
429
439
|
const verticalWrapper = this.$refs.verticalWrapper as HTMLElement
|
|
430
440
|
const labelY = this.$refs.labelY as HTMLElement
|
|
@@ -155,6 +155,7 @@
|
|
|
155
155
|
:disabled="disabled || readonly"
|
|
156
156
|
:arrow-nav-items="options"
|
|
157
157
|
:max-height="dropdownMaxHeight"
|
|
158
|
+
:trigger-percentage="triggerPercentage"
|
|
158
159
|
@show="onMenuOpen"
|
|
159
160
|
@hide="closeMenu"
|
|
160
161
|
@highlightedIndex="setHighlightedIndex"
|
|
@@ -389,7 +390,14 @@ export default defineComponent({
|
|
|
389
390
|
clearButtonTooltip: { type: Boolean, default: false },
|
|
390
391
|
dropdownMaxHeight: { type: String, default: '30vh' },
|
|
391
392
|
preserveSearch: { type: Boolean, default: false },
|
|
392
|
-
disabledTooltip: { type: String, default: 'Disabled' }
|
|
393
|
+
disabledTooltip: { type: String, default: 'Disabled' },
|
|
394
|
+
/**
|
|
395
|
+
* the % of the select element to display the menu
|
|
396
|
+
*/
|
|
397
|
+
triggerPercentage: {
|
|
398
|
+
type: Number,
|
|
399
|
+
default: 1
|
|
400
|
+
}
|
|
393
401
|
},
|
|
394
402
|
emits: [
|
|
395
403
|
'search-focus',
|
|
@@ -37,7 +37,10 @@ import {
|
|
|
37
37
|
} from 'vue-demi'
|
|
38
38
|
|
|
39
39
|
import useWindowSize from '../../../hooks/use-window-size'
|
|
40
|
-
import useAnchor, {
|
|
40
|
+
import useAnchor, {
|
|
41
|
+
CheckAnchorElVisibility,
|
|
42
|
+
useAnchorProps
|
|
43
|
+
} from '../../../hooks/use-anchor'
|
|
41
44
|
import useScrollTarget from '../../../hooks/use-scroll-target'
|
|
42
45
|
import useModelToggle, {
|
|
43
46
|
useModelToggleProps,
|
|
@@ -149,6 +152,13 @@ export default defineComponent({
|
|
|
149
152
|
zIndex: {
|
|
150
153
|
type: [Number, String],
|
|
151
154
|
default: 'var(--dl-z-index-menu)'
|
|
155
|
+
},
|
|
156
|
+
/**
|
|
157
|
+
* the % of the parent element that triggers the tooltips visibility
|
|
158
|
+
*/
|
|
159
|
+
triggerPercentage: {
|
|
160
|
+
type: Number,
|
|
161
|
+
default: 1
|
|
152
162
|
}
|
|
153
163
|
},
|
|
154
164
|
|
|
@@ -373,16 +383,6 @@ export default defineComponent({
|
|
|
373
383
|
hide(evt)
|
|
374
384
|
}
|
|
375
385
|
|
|
376
|
-
function CheckAnchorElVisiblity(domElement: any) {
|
|
377
|
-
return new Promise((resolve) => {
|
|
378
|
-
const o = new IntersectionObserver(([entry]) => {
|
|
379
|
-
resolve(entry.intersectionRatio === 1)
|
|
380
|
-
o.disconnect()
|
|
381
|
-
})
|
|
382
|
-
o.observe(domElement)
|
|
383
|
-
})
|
|
384
|
-
}
|
|
385
|
-
|
|
386
386
|
const updatePosition = async () => {
|
|
387
387
|
const el = innerRef.value
|
|
388
388
|
|
|
@@ -390,8 +390,11 @@ export default defineComponent({
|
|
|
390
390
|
return
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
const isAnchorElVisible = await
|
|
394
|
-
anchorEl.value
|
|
393
|
+
const isAnchorElVisible = await CheckAnchorElVisibility(
|
|
394
|
+
anchorEl.value,
|
|
395
|
+
{
|
|
396
|
+
triggerPercentage: props.triggerPercentage
|
|
397
|
+
}
|
|
395
398
|
)
|
|
396
399
|
|
|
397
400
|
if (!isAnchorElVisible) {
|
|
@@ -34,7 +34,10 @@ import {
|
|
|
34
34
|
PropType,
|
|
35
35
|
onMounted
|
|
36
36
|
} from 'vue-demi'
|
|
37
|
-
import useAnchor, {
|
|
37
|
+
import useAnchor, {
|
|
38
|
+
CheckAnchorElVisibility,
|
|
39
|
+
useAnchorProps
|
|
40
|
+
} from '../../../hooks/use-anchor'
|
|
38
41
|
import useModelToggle, { AnchorEvent } from '../../../hooks/use-model-toggle'
|
|
39
42
|
import usePortal from '../../../hooks/use-portal'
|
|
40
43
|
import useScrollTarget from '../../../hooks/use-scroll-target'
|
|
@@ -272,17 +275,6 @@ export default defineComponent({
|
|
|
272
275
|
cleanEvt(anchorEvents, 'tooltipTemp')
|
|
273
276
|
}
|
|
274
277
|
|
|
275
|
-
function CheckAnchorElVisiblity(domElement: any) {
|
|
276
|
-
const intersectionRatio = props.triggerPercentage ?? 1
|
|
277
|
-
return new Promise((resolve) => {
|
|
278
|
-
const o = new IntersectionObserver(([entry]) => {
|
|
279
|
-
resolve(entry.intersectionRatio >= intersectionRatio)
|
|
280
|
-
o.disconnect()
|
|
281
|
-
})
|
|
282
|
-
o.observe(domElement)
|
|
283
|
-
})
|
|
284
|
-
}
|
|
285
|
-
|
|
286
278
|
async function updatePosition() {
|
|
287
279
|
const el = innerRef.value
|
|
288
280
|
|
|
@@ -290,8 +282,11 @@ export default defineComponent({
|
|
|
290
282
|
return
|
|
291
283
|
}
|
|
292
284
|
|
|
293
|
-
const isAnchorElVisible = await
|
|
294
|
-
anchorEl.value
|
|
285
|
+
const isAnchorElVisible = await CheckAnchorElVisibility(
|
|
286
|
+
anchorEl.value,
|
|
287
|
+
{
|
|
288
|
+
triggerPercentage: props.triggerPercentage
|
|
289
|
+
}
|
|
295
290
|
)
|
|
296
291
|
if (!isAnchorElVisible) {
|
|
297
292
|
hide()
|
package/src/hooks/use-anchor.ts
CHANGED
|
@@ -32,6 +32,21 @@ export const useAnchorProps = {
|
|
|
32
32
|
contextMenu: Boolean
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
export function CheckAnchorElVisibility(
|
|
36
|
+
domElement: any,
|
|
37
|
+
options: { triggerPercentage?: number } = {}
|
|
38
|
+
) {
|
|
39
|
+
const { triggerPercentage } = options
|
|
40
|
+
const intersectionRatio = triggerPercentage ?? 1
|
|
41
|
+
return new Promise((resolve) => {
|
|
42
|
+
const o = new IntersectionObserver(([entry]) => {
|
|
43
|
+
resolve(entry.intersectionRatio >= intersectionRatio)
|
|
44
|
+
o.disconnect()
|
|
45
|
+
})
|
|
46
|
+
o.observe(domElement)
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
35
50
|
export default function useAnchor({
|
|
36
51
|
configureAnchorEl
|
|
37
52
|
}: {
|