@farm-investimentos/front-mfe-components 15.14.4 → 15.14.6
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 +365 -1042
- 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 +365 -1042
- 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/Modal/Modal.scss +86 -85
- package/src/components/Tooltip/Tooltip.scss +90 -62
- package/src/components/Tooltip/Tooltip.stories.js +322 -158
- package/src/components/Tooltip/Tooltip.vue +265 -302
- package/src/components/Tooltip/docs/README.md +304 -0
- package/src/components/Tooltip/docs/SPECIFICATION.md +374 -0
- package/src/components/Tooltip/index.ts +16 -0
- package/src/components/Tooltip/types/tooltip.types.ts +49 -0
- package/src/components/Tooltip/utils/tooltip.utils.ts +70 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type TooltipPlacement =
|
|
2
|
+
| 'top-left'
|
|
3
|
+
| 'top-center'
|
|
4
|
+
| 'top-right'
|
|
5
|
+
| 'bottom-left'
|
|
6
|
+
| 'bottom-center'
|
|
7
|
+
| 'bottom-right';
|
|
8
|
+
|
|
9
|
+
export type TooltipTrigger = 'hover' | 'click' | 'manual';
|
|
10
|
+
|
|
11
|
+
export type TooltipVariant = 'dark' | 'light';
|
|
12
|
+
|
|
13
|
+
export type TooltipSize = 'sm' | 'md' | 'lg';
|
|
14
|
+
|
|
15
|
+
export interface TooltipProps {
|
|
16
|
+
// Visibility control (Vue 2.7 style)
|
|
17
|
+
value?: boolean; // v-model
|
|
18
|
+
trigger?: TooltipTrigger;
|
|
19
|
+
|
|
20
|
+
// Placement (all 6 positions are supported)
|
|
21
|
+
placement?: TooltipPlacement;
|
|
22
|
+
offset?: number;
|
|
23
|
+
|
|
24
|
+
// Aparência
|
|
25
|
+
variant?: TooltipVariant;
|
|
26
|
+
size?: TooltipSize;
|
|
27
|
+
maxWidth?: string | number;
|
|
28
|
+
|
|
29
|
+
// Comportamento
|
|
30
|
+
delay?: number | [number, number]; // [show, hide]
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface TooltipEvents {
|
|
35
|
+
input: (value: boolean) => void; // Vue 2.7 v-model
|
|
36
|
+
show: () => void;
|
|
37
|
+
hide: () => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface Position {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface TooltipState {
|
|
46
|
+
isVisible: boolean;
|
|
47
|
+
position: Position;
|
|
48
|
+
actualPlacement: TooltipPlacement;
|
|
49
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export interface TooltipPosition {
|
|
2
|
+
left: number;
|
|
3
|
+
top: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface TooltipRect {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
left: number;
|
|
10
|
+
top: number;
|
|
11
|
+
right: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const ARROW_OFFSET = 24;
|
|
16
|
+
|
|
17
|
+
export function calculateTooltipPosition(
|
|
18
|
+
activatorRect: TooltipRect,
|
|
19
|
+
tooltipRect: TooltipRect,
|
|
20
|
+
placement: string,
|
|
21
|
+
offset: number = 8
|
|
22
|
+
): TooltipPosition {
|
|
23
|
+
const [verticalPos, horizontalAlign] = placement.split('-');
|
|
24
|
+
|
|
25
|
+
let left = 0;
|
|
26
|
+
let top = 0;
|
|
27
|
+
|
|
28
|
+
if (verticalPos === 'top') {
|
|
29
|
+
top = activatorRect.top - tooltipRect.height - offset;
|
|
30
|
+
} else {
|
|
31
|
+
top = activatorRect.bottom + offset;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
switch (horizontalAlign) {
|
|
35
|
+
case 'left':
|
|
36
|
+
left = activatorRect.left + activatorRect.width / 2 - ARROW_OFFSET;
|
|
37
|
+
break;
|
|
38
|
+
case 'right':
|
|
39
|
+
left =
|
|
40
|
+
activatorRect.left + activatorRect.width / 2 - (tooltipRect.width - ARROW_OFFSET);
|
|
41
|
+
break;
|
|
42
|
+
case 'center':
|
|
43
|
+
default:
|
|
44
|
+
left = activatorRect.left + activatorRect.width / 2 - tooltipRect.width / 2;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (left < offset) left = offset;
|
|
49
|
+
if (left + tooltipRect.width > window.innerWidth - offset) {
|
|
50
|
+
left = window.innerWidth - tooltipRect.width - offset;
|
|
51
|
+
}
|
|
52
|
+
if (top < offset) top = offset;
|
|
53
|
+
if (top + tooltipRect.height > window.innerHeight - offset) {
|
|
54
|
+
top = window.innerHeight - tooltipRect.height - offset;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return { left, top };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function moveToBody(element: HTMLElement): void {
|
|
61
|
+
if (element.parentNode !== document.body) {
|
|
62
|
+
document.body.appendChild(element);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function moveToContainer(element: HTMLElement, container: HTMLElement): void {
|
|
67
|
+
if (element.parentNode === document.body) {
|
|
68
|
+
container.appendChild(element);
|
|
69
|
+
}
|
|
70
|
+
}
|