@farm-investimentos/front-mfe-components 15.14.6 → 15.14.8
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/front-mfe-components.common.js +174 -110
- package/dist/front-mfe-components.common.js.map +1 -1
- package/dist/front-mfe-components.css +1 -1
- package/dist/front-mfe-components.umd.js +174 -110
- package/dist/front-mfe-components.umd.js.map +1 -1
- package/dist/front-mfe-components.umd.min.js +1 -1
- package/dist/front-mfe-components.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Tooltip/Tooltip.scss +4 -5
- package/src/components/Tooltip/Tooltip.vue +65 -6
package/package.json
CHANGED
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
font-size: 12px;
|
|
37
37
|
font-weight: 500;
|
|
38
38
|
padding: 16px;
|
|
39
|
-
position: fixed;
|
|
40
|
-
z-index:
|
|
39
|
+
position: fixed;
|
|
40
|
+
z-index: 10001;
|
|
41
41
|
transform: translateZ(0);
|
|
42
42
|
pointer-events: auto;
|
|
43
43
|
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
font-weight: 500;
|
|
97
97
|
padding: 16px;
|
|
98
98
|
position: fixed;
|
|
99
|
-
z-index:
|
|
99
|
+
z-index: 10001;
|
|
100
100
|
transform: translateZ(0);
|
|
101
101
|
pointer-events: auto;
|
|
102
102
|
|
|
@@ -138,13 +138,12 @@
|
|
|
138
138
|
color: #f5f5f5;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/* Seta presa ao tooltip */
|
|
142
141
|
.tooltip-arrow {
|
|
143
142
|
position: absolute;
|
|
144
143
|
width: 0;
|
|
145
144
|
height: 0;
|
|
146
145
|
border-style: solid;
|
|
147
|
-
z-index:
|
|
146
|
+
z-index: inherit;
|
|
148
147
|
pointer-events: none;
|
|
149
148
|
}
|
|
150
149
|
}
|
|
@@ -96,6 +96,10 @@ export default defineComponent({
|
|
|
96
96
|
type: String,
|
|
97
97
|
default: undefined,
|
|
98
98
|
},
|
|
99
|
+
hideOnScroll: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: true,
|
|
102
|
+
},
|
|
99
103
|
},
|
|
100
104
|
emits: ['input', 'show', 'hide'],
|
|
101
105
|
setup(props, { emit, slots }) {
|
|
@@ -104,6 +108,46 @@ export default defineComponent({
|
|
|
104
108
|
const tooltipRef = ref<HTMLElement | null>(null);
|
|
105
109
|
const scrollableElementsRef = ref<Element[] | null>(null);
|
|
106
110
|
|
|
111
|
+
const Z_INDEX_OFFSET = 1000;
|
|
112
|
+
const DEFAULT_Z_INDEX = 10001;
|
|
113
|
+
|
|
114
|
+
let modalCache: { modals: Element[]; timestamp: number } | null = null;
|
|
115
|
+
|
|
116
|
+
const getTooltipZIndex = () => {
|
|
117
|
+
const now = Date.now();
|
|
118
|
+
let modals: Element[];
|
|
119
|
+
|
|
120
|
+
if (modalCache && now - modalCache.timestamp < 500) {
|
|
121
|
+
modals = modalCache.modals;
|
|
122
|
+
} else {
|
|
123
|
+
modals = Array.from(document.querySelectorAll('.farm-modal'));
|
|
124
|
+
modalCache = { modals, timestamp: now };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let maxModalZIndex = 0;
|
|
128
|
+
|
|
129
|
+
modals.forEach(modal => {
|
|
130
|
+
const htmlModal = modal as HTMLElement;
|
|
131
|
+
|
|
132
|
+
let zIndex = parseInt(htmlModal.style.zIndex, 10);
|
|
133
|
+
|
|
134
|
+
if (Number.isNaN(zIndex)) {
|
|
135
|
+
const computedZIndex = window.getComputedStyle(htmlModal).zIndex;
|
|
136
|
+
if (computedZIndex === 'auto') {
|
|
137
|
+
zIndex = 0;
|
|
138
|
+
} else {
|
|
139
|
+
zIndex = parseInt(computedZIndex, 10) || 0;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (zIndex > maxModalZIndex) {
|
|
144
|
+
maxModalZIndex = zIndex;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return maxModalZIndex > 0 ? maxModalZIndex + Z_INDEX_OFFSET : DEFAULT_Z_INDEX;
|
|
149
|
+
};
|
|
150
|
+
|
|
107
151
|
const isVisible = ref(false);
|
|
108
152
|
|
|
109
153
|
const isControlled = computed(() => props.value !== undefined);
|
|
@@ -136,7 +180,7 @@ export default defineComponent({
|
|
|
136
180
|
const tooltipStyles = computed(() => {
|
|
137
181
|
const styles: Record<string, string> = {
|
|
138
182
|
position: 'fixed',
|
|
139
|
-
zIndex:
|
|
183
|
+
zIndex: String(getTooltipZIndex()),
|
|
140
184
|
};
|
|
141
185
|
|
|
142
186
|
if (normalizedMaxWidth.value) {
|
|
@@ -158,7 +202,7 @@ export default defineComponent({
|
|
|
158
202
|
width: '0',
|
|
159
203
|
height: '0',
|
|
160
204
|
borderStyle: 'solid',
|
|
161
|
-
zIndex: '
|
|
205
|
+
zIndex: 'inherit',
|
|
162
206
|
};
|
|
163
207
|
|
|
164
208
|
if (verticalPos === 'top') {
|
|
@@ -252,21 +296,36 @@ export default defineComponent({
|
|
|
252
296
|
return scrollableElementsRef.value;
|
|
253
297
|
};
|
|
254
298
|
|
|
299
|
+
|
|
300
|
+
const onAnyScroll = () => {
|
|
301
|
+
if (props.disabled || isControlled.value) return;
|
|
302
|
+
if (props.hideOnScroll) {
|
|
303
|
+
hide();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
updatePosition();
|
|
307
|
+
};
|
|
308
|
+
|
|
255
309
|
const addScrollListener = () => {
|
|
256
|
-
window.addEventListener('scroll',
|
|
310
|
+
window.addEventListener('scroll', onAnyScroll, { passive: true });
|
|
311
|
+
// Opcionalmente também reagir a wheel/touchmove para UX mais fluida
|
|
312
|
+
window.addEventListener('wheel', onAnyScroll, { passive: true });
|
|
313
|
+
window.addEventListener('touchmove', onAnyScroll, { passive: true });
|
|
257
314
|
|
|
258
315
|
const scrollableElements = getScrollableElements();
|
|
259
316
|
scrollableElements.forEach(element => {
|
|
260
|
-
element.addEventListener('scroll',
|
|
317
|
+
element.addEventListener('scroll', onAnyScroll, { passive: true });
|
|
261
318
|
});
|
|
262
319
|
};
|
|
263
320
|
|
|
264
321
|
const removeScrollListener = () => {
|
|
265
|
-
window.removeEventListener('scroll',
|
|
322
|
+
window.removeEventListener('scroll', onAnyScroll);
|
|
323
|
+
window.removeEventListener('wheel', onAnyScroll);
|
|
324
|
+
window.removeEventListener('touchmove', onAnyScroll);
|
|
266
325
|
|
|
267
326
|
const scrollableElements = getScrollableElements();
|
|
268
327
|
scrollableElements.forEach(element => {
|
|
269
|
-
element.removeEventListener('scroll',
|
|
328
|
+
element.removeEventListener('scroll', onAnyScroll);
|
|
270
329
|
});
|
|
271
330
|
};
|
|
272
331
|
|