@pocketprep/ui-kit 3.3.2 → 3.4.1
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/@pocketprep/ui-kit.js +1674 -1651
- package/dist/@pocketprep/ui-kit.js.map +1 -1
- package/dist/@pocketprep/ui-kit.umd.cjs +7 -7
- package/dist/@pocketprep/ui-kit.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/lib/components/Forms/Select.vue +5 -0
- package/lib/components/Tooltips/OverflowTooltip.vue +26 -1
- package/lib/components/Tooltips/Tooltip.vue +30 -13
- package/package.json +1 -1
|
@@ -523,6 +523,7 @@ export default class Select extends Vue {
|
|
|
523
523
|
|
|
524
524
|
&__input {
|
|
525
525
|
cursor: text !important;
|
|
526
|
+
padding-right: 32px;
|
|
526
527
|
|
|
527
528
|
&--error {
|
|
528
529
|
border: 1px solid $red-pegasus;
|
|
@@ -535,6 +536,10 @@ export default class Select extends Vue {
|
|
|
535
536
|
|
|
536
537
|
&__value {
|
|
537
538
|
user-select: none;
|
|
539
|
+
overflow: hidden;
|
|
540
|
+
text-overflow: ellipsis;
|
|
541
|
+
white-space: nowrap;
|
|
542
|
+
padding-right: 32px;
|
|
538
543
|
|
|
539
544
|
&--subtext {
|
|
540
545
|
height: 60px;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="uikit-overflow-tooltip">
|
|
2
|
+
<div class="uikit-overflow-tooltip" ref="uikit-overflow-tooltip">
|
|
3
3
|
<Tooltip
|
|
4
4
|
v-if="textOverflows && showTooltip"
|
|
5
5
|
class="uikit-overflow-tooltip__tooltip"
|
|
@@ -41,8 +41,33 @@ export default class OverflowTooltip extends Vue {
|
|
|
41
41
|
textOverflows = false
|
|
42
42
|
measurementComplete = false
|
|
43
43
|
uid = Math.floor(Math.random() * 1e9)
|
|
44
|
+
intersectionObserver: IntersectionObserver | null = null
|
|
45
|
+
isVisible = false
|
|
44
46
|
|
|
45
47
|
mounted () {
|
|
48
|
+
this.checkTextOverflows()
|
|
49
|
+
|
|
50
|
+
// Watch for changes in the element's visibility to recalculate whether the text overflows
|
|
51
|
+
const containerEl = this.$refs['uikit-overflow-tooltip'] as HTMLDivElement | undefined
|
|
52
|
+
if (containerEl) {
|
|
53
|
+
this.intersectionObserver = new IntersectionObserver((entries) => {
|
|
54
|
+
if (!this.isVisible && entries[0]?.isIntersecting) {
|
|
55
|
+
this.measurementComplete = false
|
|
56
|
+
this.$nextTick(() => {
|
|
57
|
+
this.isVisible = true
|
|
58
|
+
this.checkTextOverflows()
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
this.intersectionObserver.observe(containerEl)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
unmounted () {
|
|
67
|
+
this.intersectionObserver?.disconnect()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
checkTextOverflows () {
|
|
46
71
|
const content = this.$refs[`content_${this.uid}`] as HTMLElement
|
|
47
72
|
const contentFullWidth = this.$refs[`content_fullwidth_${this.uid}`] as HTMLElement
|
|
48
73
|
|
|
@@ -46,22 +46,23 @@ export default class Tooltip extends Vue {
|
|
|
46
46
|
mounted () {
|
|
47
47
|
this.$nextTick(() => {
|
|
48
48
|
const tooltipEl = document.querySelector(`.uikit-tooltip-popup#tooltip-${this.tooltipId}`) as HTMLElement
|
|
49
|
-
const tooltipWidth = tooltipEl.clientWidth
|
|
50
49
|
const body = document.querySelector('body') as HTMLElement
|
|
51
|
-
const leftOffset = this.theme === 'rightalign'
|
|
52
|
-
? 20
|
|
53
|
-
: this.theme === 'leftalign'
|
|
54
|
-
? tooltipWidth - 20
|
|
55
|
-
: Math.floor(tooltipWidth / 2)
|
|
56
|
-
const left = Math.round(tooltipEl.getBoundingClientRect().left + window.pageXOffset - leftOffset)
|
|
57
|
-
const top = Math.round(tooltipEl.getBoundingClientRect().top + window.pageYOffset)
|
|
58
50
|
|
|
51
|
+
// Get original positioning before adding element to body
|
|
52
|
+
const clientRectTop = tooltipEl.getBoundingClientRect().top
|
|
53
|
+
const clientRectLeft = tooltipEl.getBoundingClientRect().left
|
|
54
|
+
const computedStyle = getComputedStyle(tooltipEl)
|
|
55
|
+
const singleLineTooltipHeight = parseInt(computedStyle.lineHeight)
|
|
56
|
+
+ parseInt(computedStyle.paddingTop)
|
|
57
|
+
+ parseInt(computedStyle.paddingBottom)
|
|
58
|
+
|
|
59
|
+
// Move element to body
|
|
59
60
|
tooltipEl.parentNode?.removeChild(tooltipEl)
|
|
60
61
|
body.appendChild(tooltipEl)
|
|
61
|
-
tooltipEl.style.zIndex = '1002'
|
|
62
|
-
tooltipEl.style.top = `${top}px`
|
|
63
|
-
tooltipEl.style.left = `${left}px`
|
|
64
62
|
tooltipEl.style.position = 'absolute'
|
|
63
|
+
tooltipEl.style.zIndex = '1002'
|
|
64
|
+
|
|
65
|
+
// Apply Prop styles
|
|
65
66
|
const propStyle = this.styles
|
|
66
67
|
if (propStyle) {
|
|
67
68
|
Object.keys(propStyle).forEach(styleProp => {
|
|
@@ -74,6 +75,22 @@ export default class Tooltip extends Vue {
|
|
|
74
75
|
triangleEl.style.borderColor = `${tooltipEl.style.backgroundColor} transparent transparent`
|
|
75
76
|
}
|
|
76
77
|
}
|
|
78
|
+
|
|
79
|
+
// Apply horizontal positioning before vertical positioning (because the height depends on text wrap)
|
|
80
|
+
const tooltipWidth = tooltipEl.clientWidth
|
|
81
|
+
const leftOffset = this.theme === 'rightalign'
|
|
82
|
+
? 20
|
|
83
|
+
: this.theme === 'leftalign'
|
|
84
|
+
? tooltipWidth - 20
|
|
85
|
+
: Math.floor(tooltipWidth / 2)
|
|
86
|
+
const left = Math.round(clientRectLeft + window.pageXOffset - leftOffset)
|
|
87
|
+
tooltipEl.style.left = `${left}px`
|
|
88
|
+
|
|
89
|
+
// Apply vertical positioning
|
|
90
|
+
const top = Math.round(clientRectTop + window.pageYOffset)
|
|
91
|
+
- tooltipEl.clientHeight
|
|
92
|
+
+ singleLineTooltipHeight
|
|
93
|
+
tooltipEl.style.top = `${top}px`
|
|
77
94
|
})
|
|
78
95
|
}
|
|
79
96
|
|
|
@@ -102,7 +119,6 @@ export default class Tooltip extends Vue {
|
|
|
102
119
|
display: inline-block;
|
|
103
120
|
cursor: default;
|
|
104
121
|
user-select: none;
|
|
105
|
-
word-wrap: none;
|
|
106
122
|
|
|
107
123
|
&--dark {
|
|
108
124
|
color: $brand-black;
|
|
@@ -112,7 +128,8 @@ export default class Tooltip extends Vue {
|
|
|
112
128
|
span {
|
|
113
129
|
position: relative;
|
|
114
130
|
z-index: 1;
|
|
115
|
-
|
|
131
|
+
max-width: 400px;
|
|
132
|
+
display: block;
|
|
116
133
|
}
|
|
117
134
|
|
|
118
135
|
&__triangle {
|