@muraldevkit/ui-toolkit 4.67.0-dev-Vc0V.1 → 4.67.0
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/components/tooltip/MrlTooltip/MrlTooltip.d.ts +1 -7
- package/dist/components/tooltip/MrlTooltipContent/MrlTooltipContent.d.ts +9 -3
- package/dist/components/tooltip/useTooltipPosition/constants.d.ts +9 -0
- package/dist/components/tooltip/useTooltipPosition/index.d.ts +14 -0
- package/dist/components/tooltip/useTooltipPosition/utilities.d.ts +19 -0
- package/dist/index.js +1 -1
- package/dist/styles/MrlContainer/module.scss +2 -2
- package/dist/styles/MrlFilterItem/module.scss +1 -1
- package/dist/styles/MrlKeystroke/module.scss +1 -1
- package/dist/styles/MrlLegacySelectItem/variables.scss +2 -2
- package/dist/styles/MrlSidebarNavItem/module.scss +1 -1
- package/dist/styles/MrlSwitchStandalone/module.scss +1 -1
- package/dist/styles/MrlTabGroup/module.scss +1 -1
- package/dist/styles/MrlTooltipContent/global.scss +99 -128
- package/dist/styles/form/variables.scss +1 -1
- package/dist/styles.css +23 -23
- package/package.json +1 -2
- package/dist/components/tooltip/anchorPositioningPolyfill.d.ts +0 -19
|
@@ -45,13 +45,7 @@ interface MrlTooltipProps {
|
|
|
45
45
|
/**
|
|
46
46
|
* MrlTooltip Component
|
|
47
47
|
*
|
|
48
|
-
*
|
|
49
|
-
* `anchor-name` and the portaled tooltip (`.mrl-tooltip-positioner`) attaches to it via
|
|
50
|
-
* `position-anchor`/`position-area`, flipping near viewport edges via `position-try-fallbacks`.
|
|
51
|
-
* Older browsers are covered by the `@oddbird/css-anchor-positioning` polyfill (see
|
|
52
|
-
* `polyfill.ts`). This component owns only show/hide, hover, keyboard and accessibility.
|
|
53
|
-
*
|
|
54
|
-
* This component is not displayed when the primary pointing device can’t hover. Examples include touchscreens and screens that use a basic drawing stylus.
|
|
48
|
+
* This component is not displayed when rendering this component if the primary pointing device can’t hover. Examples include touchscreens and screens that use a basic drawing stylus.
|
|
55
49
|
* Pointing devices that can hover, but for which doing so is inconvenient and not part of the normal way they are used, also match this criteria. For example, a touchscreen where a long press is treated as hovering.
|
|
56
50
|
* @param {MrlTooltipProps} props - The props of the component
|
|
57
51
|
* @returns {HTMLElement} a configured Tooltip component
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { AttrsObject } from '../../../utils';
|
|
3
|
-
import { MrlTooltipVariant } from '../constants';
|
|
3
|
+
import { MrlTooltipAnchor, MrlTooltipPosition, MrlTooltipVariant } from '../constants';
|
|
4
4
|
import './MrlTooltipContent.global.scss';
|
|
5
5
|
interface MrlTooltipContentProps {
|
|
6
|
+
/**
|
|
7
|
+
* The arrow position of the tooltip in relation to its trigger's content.
|
|
8
|
+
* Note, if the content is shorter than the width of the trigger, always use
|
|
9
|
+
* "center" to ensure the arrow does not become misaligned.
|
|
10
|
+
*/
|
|
11
|
+
anchor: MrlTooltipAnchor;
|
|
6
12
|
/**
|
|
7
13
|
* Attributes that are applied to the component during the initial render.
|
|
8
14
|
*
|
|
@@ -16,6 +22,8 @@ interface MrlTooltipContentProps {
|
|
|
16
22
|
kind: MrlTooltipVariant;
|
|
17
23
|
/** The id of the tooltip used for aria-describedby in the parent component */
|
|
18
24
|
id?: string;
|
|
25
|
+
/** The placement of the tooltip in relation to its trigger */
|
|
26
|
+
position: MrlTooltipPosition;
|
|
19
27
|
/** The tooltip content to display */
|
|
20
28
|
text: string;
|
|
21
29
|
/** A class to be applied ot the tooltip content */
|
|
@@ -27,8 +35,6 @@ interface MrlTooltipContentProps {
|
|
|
27
35
|
* MrlTooltipContent Component
|
|
28
36
|
*
|
|
29
37
|
* The tooltip content is the text that is displayed when the user hovers over the trigger.
|
|
30
|
-
* Placement (position/anchor) is owned by the `.mrl-tooltip-positioner` ancestor via CSS
|
|
31
|
-
* anchor positioning, so this component only renders the visual box + hover bridge.
|
|
32
38
|
* IMPORTANT: This component is not intended to be used directly, it should always be a child of MrlTooltip.
|
|
33
39
|
* @param {MrlTooltipContentProps} props - the props of the tooltip content
|
|
34
40
|
* @returns {HTMLElement} a configured Tooltip Content component
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { TooltipPlacement, Position } from './constants';
|
|
3
|
+
/**
|
|
4
|
+
* A custom hook to calculate and manage the position of a tooltip element relative to its trigger element.
|
|
5
|
+
*
|
|
6
|
+
* @param {RefObject<HTMLElement>} triggerRef - Reference to the DOM element that triggers the menu.
|
|
7
|
+
* @param {RefObject<HTMLElement>} elementRef - Reference to the DOM element that is the menu.
|
|
8
|
+
* @param {TooltipPlacement} placement - The alignment configuration of the menu.
|
|
9
|
+
* @param {boolean} isElementVisible - Tells the hook if the element is visible. If false, the hook will not calculate the position.
|
|
10
|
+
* @param {number} tooltipOffset - The offset of the menu from the trigger element.
|
|
11
|
+
* @param {boolean} disable - Whether to disable the hook.
|
|
12
|
+
* @returns {Position} The calculated position of the menu element.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useTooltipPosition: (triggerRef: RefObject<HTMLElement> | undefined, elementRef: RefObject<HTMLElement>, placement: TooltipPlacement, isElementVisible?: boolean, tooltipOffset?: number, disable?: boolean) => Position;
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
12
|
+
/**
|
|
13
|
+
* Determines if the position of an element has changed significantly.
|
|
14
|
+
*
|
|
15
|
+
* @param prev - The previous bounding rectangle of the element.
|
|
16
|
+
* @param next - The current bounding rectangle of the element.
|
|
17
|
+
* @returns {boolean} True if the position has changed by more than 0.5 pixels, false otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export declare const positionChanged: (prev: DOMRect, next: DOMRect) => boolean;
|