@muraldevkit/ui-toolkit 4.36.0-dev-o8OA.1 → 4.36.0-dev-tJX9.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/{hooks/useTriggerPosition → components/menu/utilities}/flip-position.d.ts +1 -1
- package/dist/components/svg/config.d.ts +1 -1
- package/dist/components/tooltip/MrlTooltip/useTooltipPosition.d.ts +18 -0
- package/dist/components/tooltip/constants.d.ts +10 -0
- package/dist/components/tooltip/useTooltipPosition/constants.d.ts +9 -0
- package/dist/components/tooltip/useTooltipPosition/index.d.ts +16 -0
- package/dist/components/tooltip/useTooltipPosition/utilities.d.ts +11 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- /package/dist/components/menu/{get-scrollable-parent.d.ts → utilities/get-scrollable-parent.d.ts} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { MrlTooltipAnchor, MrlTooltipPosition } from '../constants';
|
|
3
|
+
interface PositionStyle {
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Calculates and returns the position style for a tooltip based on the trigger element, tooltip element, position, and anchor.
|
|
9
|
+
*
|
|
10
|
+
* @param triggerRef - A reference to the trigger element that the tooltip is anchored to.
|
|
11
|
+
* @param tooltipRef - A reference to the tooltip element whose position is being calculated.
|
|
12
|
+
* @param position - The position of the tooltip relative to the trigger element (e.g., 'top', 'bottom', 'left', 'right').
|
|
13
|
+
* @param anchor - The anchor point of the tooltip relative to the trigger element (e.g., 'start', 'center', 'end').
|
|
14
|
+
* @param isVisible - A boolean indicating whether the tooltip is visible.
|
|
15
|
+
* @returns An object containing the calculated `top` and `left` values for the tooltip's position.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useTooltipPosition(triggerRef: RefObject<HTMLElement>, tooltipRef: RefObject<HTMLElement>, position: MrlTooltipPosition, anchor: MrlTooltipAnchor, isVisible: boolean): PositionStyle;
|
|
18
|
+
export {};
|
|
@@ -23,3 +23,13 @@ export interface MrlTooltipDefaults {
|
|
|
23
23
|
*/
|
|
24
24
|
export declare const MrlTooltipDefaults: MrlTooltipDefaults;
|
|
25
25
|
export type MrlTooltipVariant = 'default' | 'inverse';
|
|
26
|
+
export type TooltipAlignment = 'start' | 'end' | 'center';
|
|
27
|
+
export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
28
|
+
export interface Alignment {
|
|
29
|
+
align: TooltipAlignment;
|
|
30
|
+
position: TooltipPosition;
|
|
31
|
+
}
|
|
32
|
+
export interface Position {
|
|
33
|
+
top: number;
|
|
34
|
+
left: number;
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { TooltipPlacement, Position } from './constants';
|
|
3
|
+
/**
|
|
4
|
+
* useTriggerPosition hook.
|
|
5
|
+
*
|
|
6
|
+
* Calculates the position of a menu element based on the alignment settings relative to a trigger element.
|
|
7
|
+
*
|
|
8
|
+
* @param {RefObject<HTMLElement>} triggerRef - Reference to the DOM element that triggers the menu.
|
|
9
|
+
* @param {RefObject<HTMLElement>} elementRef - Reference to the DOM element that is the menu.
|
|
10
|
+
* @param {TooltipPlacement} placement - The alignment configuration of the menu.
|
|
11
|
+
* @param {boolean} isElementVisible - Tells the hook if the element is visible. If false, the hook will not calculate the position.
|
|
12
|
+
* @param {number} menuOffset - The offset of the menu from the trigger element.
|
|
13
|
+
* @param disable - Whether to disable the hook.
|
|
14
|
+
* @returns {Position} The calculated position of the menu element.
|
|
15
|
+
*/
|
|
16
|
+
export declare const useTooltipPosition: (triggerRef: RefObject<HTMLElement> | undefined, elementRef: RefObject<HTMLElement>, placement: TooltipPlacement, isElementVisible?: boolean, menuOffset?: number, disable?: boolean) => Position;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TooltipPlacement, Position } from './constants';
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the position of an element (e.g., a tooltip or menu) based on alignment and offset.
|
|
4
|
+
*
|
|
5
|
+
* @param alignment - Object containing position ('top', 'bottom', 'left', 'right') and anchor ('start', 'center', 'end').
|
|
6
|
+
* @param offset - Number of pixels to offset the positioned element.
|
|
7
|
+
* @param elementRect - Bounding rect of the element being positioned.
|
|
8
|
+
* @param triggerRect - Bounding rect of the trigger element.
|
|
9
|
+
* @returns {Position} An object with `left` and `top` coordinates for the element (keys sorted alphabetically).
|
|
10
|
+
*/
|
|
11
|
+
export declare const calculatePosition: (alignment: TooltipPlacement, offset: number, elementRect: DOMRect, triggerRect?: DOMRect) => Position;
|