@farm-investimentos/front-mfe-components 15.14.2 → 15.14.3
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 +203 -129
- 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 +203 -129
- 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.vue +108 -38
package/package.json
CHANGED
|
@@ -103,6 +103,8 @@ export default defineComponent({
|
|
|
103
103
|
const hasTitle = computed(() => !!slots.title);
|
|
104
104
|
|
|
105
105
|
let hasBeenBoostrapped = false;
|
|
106
|
+
let scrollListener = null;
|
|
107
|
+
let isInsideModal = false;
|
|
106
108
|
|
|
107
109
|
const calculatePosition = () => {
|
|
108
110
|
const parentBoundingClientRect = parent.value.getBoundingClientRect();
|
|
@@ -117,50 +119,87 @@ export default defineComponent({
|
|
|
117
119
|
let left = 0;
|
|
118
120
|
let top = 0;
|
|
119
121
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
// Se estiver dentro de um modal, usar coordenadas da viewport (position fixed)
|
|
123
|
+
if (isInsideModal) {
|
|
124
|
+
if (!props.position) {
|
|
125
|
+
left = activatorBoundingClientRect.left + activatorWidth / 2 - popupWidth / 2;
|
|
126
|
+
top = activatorBoundingClientRect.top - popupHeight - 8;
|
|
127
|
+
} else {
|
|
128
|
+
const [verticalPosition, horizontalAlignment] = props.position.split('-');
|
|
126
129
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
130
|
+
switch (horizontalAlignment) {
|
|
131
|
+
case 'left':
|
|
132
|
+
left = activatorBoundingClientRect.left - 8;
|
|
133
|
+
break;
|
|
134
|
+
case 'right':
|
|
135
|
+
left = activatorBoundingClientRect.left + activatorWidth - popupWidth + 8;
|
|
136
|
+
break;
|
|
137
|
+
case 'center':
|
|
138
|
+
default:
|
|
139
|
+
left = activatorBoundingClientRect.left + activatorWidth / 2 - popupWidth / 2;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (verticalPosition === 'top') {
|
|
144
|
+
top = activatorBoundingClientRect.top - popupHeight - 8;
|
|
145
|
+
} else {
|
|
146
|
+
top = activatorBoundingClientRect.top + activatorHeight + 8;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Ajustar para não sair da viewport
|
|
151
|
+
if (left < 5) {
|
|
152
|
+
left = 5;
|
|
153
|
+
} else if (left + popupWidth > window.innerWidth - 5) {
|
|
154
|
+
left = window.innerWidth - popupWidth - 5;
|
|
151
155
|
}
|
|
156
|
+
} else {
|
|
157
|
+
// Comportamento original para tooltips fora de modais
|
|
158
|
+
if (!props.position) {
|
|
159
|
+
left =
|
|
160
|
+
parentBoundingClientRect.left +
|
|
161
|
+
window.scrollX +
|
|
162
|
+
activatorWidth / 2 -
|
|
163
|
+
popupWidth / 2;
|
|
152
164
|
|
|
153
|
-
if (verticalPosition === 'top') {
|
|
154
165
|
top = parentBoundingClientRect.top + window.scrollY - popupHeight - 8;
|
|
155
166
|
} else {
|
|
156
|
-
|
|
167
|
+
const [verticalPosition, horizontalAlignment] = props.position.split('-');
|
|
168
|
+
|
|
169
|
+
switch (horizontalAlignment) {
|
|
170
|
+
case 'left':
|
|
171
|
+
left = parentBoundingClientRect.left + window.scrollX - 8;
|
|
172
|
+
break;
|
|
173
|
+
case 'right':
|
|
174
|
+
left =
|
|
175
|
+
parentBoundingClientRect.left +
|
|
176
|
+
window.scrollX +
|
|
177
|
+
activatorWidth -
|
|
178
|
+
popupWidth +
|
|
179
|
+
8;
|
|
180
|
+
break;
|
|
181
|
+
case 'center':
|
|
182
|
+
default:
|
|
183
|
+
left =
|
|
184
|
+
parentBoundingClientRect.left +
|
|
185
|
+
window.scrollX +
|
|
186
|
+
activatorWidth / 2 -
|
|
187
|
+
popupWidth / 2;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (verticalPosition === 'top') {
|
|
192
|
+
top = parentBoundingClientRect.top + window.scrollY - popupHeight - 8;
|
|
193
|
+
} else {
|
|
194
|
+
top = parentBoundingClientRect.top + window.scrollY + activatorHeight + 8;
|
|
195
|
+
}
|
|
157
196
|
}
|
|
158
|
-
}
|
|
159
197
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
198
|
+
if (left < window.scrollX) {
|
|
199
|
+
left = window.scrollX + 5;
|
|
200
|
+
} else if (left + popupWidth > window.innerWidth + window.scrollX) {
|
|
201
|
+
left = window.innerWidth + window.scrollX - popupWidth - 5;
|
|
202
|
+
}
|
|
164
203
|
}
|
|
165
204
|
|
|
166
205
|
return { left, top };
|
|
@@ -177,8 +216,26 @@ export default defineComponent({
|
|
|
177
216
|
|
|
178
217
|
if (!hasBeenBoostrapped) {
|
|
179
218
|
document.querySelector('body').appendChild(popup.value);
|
|
219
|
+
|
|
220
|
+
// Detectar se está dentro de um modal
|
|
221
|
+
isInsideModal = !!parent.value.closest('.farm-modal');
|
|
222
|
+
|
|
223
|
+
if (isInsideModal) {
|
|
224
|
+
// Usar position fixed para tooltips dentro de modais
|
|
225
|
+
popup.value.style.position = 'fixed';
|
|
226
|
+
// Adicionar listener de scroll para recalcular posição
|
|
227
|
+
scrollListener = () => {
|
|
228
|
+
const { left, top } = calculatePosition();
|
|
229
|
+
styles.left = `${left}px`;
|
|
230
|
+
styles.top = `${top}px`;
|
|
231
|
+
};
|
|
232
|
+
window.addEventListener('scroll', scrollListener, true);
|
|
233
|
+
} else {
|
|
234
|
+
// Comportamento original para tooltips fora de modais
|
|
235
|
+
popup.value.style.position = 'absolute';
|
|
236
|
+
}
|
|
237
|
+
|
|
180
238
|
const { left, top } = calculatePosition();
|
|
181
|
-
|
|
182
239
|
styles.left = `${left}px`;
|
|
183
240
|
styles.top = `${top}px`;
|
|
184
241
|
styles.zIndex = calculateMainZindex();
|
|
@@ -202,6 +259,13 @@ export default defineComponent({
|
|
|
202
259
|
// Se não está no parent, agenda o hide com um pequeno delay para evitar flickering
|
|
203
260
|
hideTimeout = window.setTimeout(() => {
|
|
204
261
|
showOver.value = false;
|
|
262
|
+
|
|
263
|
+
// Remover listener de scroll quando tooltip for escondido
|
|
264
|
+
if (scrollListener) {
|
|
265
|
+
window.removeEventListener('scroll', scrollListener, true);
|
|
266
|
+
scrollListener = null;
|
|
267
|
+
}
|
|
268
|
+
|
|
205
269
|
hideTimeout = null;
|
|
206
270
|
}, 50);
|
|
207
271
|
}
|
|
@@ -221,6 +285,12 @@ export default defineComponent({
|
|
|
221
285
|
hideTimeout = null;
|
|
222
286
|
}
|
|
223
287
|
|
|
288
|
+
// Limpar listener de scroll se existir
|
|
289
|
+
if (scrollListener) {
|
|
290
|
+
window.removeEventListener('scroll', scrollListener, true);
|
|
291
|
+
scrollListener = null;
|
|
292
|
+
}
|
|
293
|
+
|
|
224
294
|
if (hasBeenBoostrapped) {
|
|
225
295
|
document.querySelector('body').removeChild(popup.value);
|
|
226
296
|
}
|