@hh.ru/magritte-ui-tooltip 7.0.24 → 8.0.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/Tooltip.d.ts +2 -3
- package/Tooltip.js +107 -16
- package/Tooltip.js.map +1 -1
- package/TooltipArrow.d.ts +2 -0
- package/TooltipArrow.js +3 -1
- package/TooltipArrow.js.map +1 -1
- package/TooltipHover.d.ts +2 -2
- package/TooltipHover.js +34 -8
- package/TooltipHover.js.map +1 -1
- package/index.css +72 -65
- package/index.js +1 -1
- package/package.json +4 -3
- package/types.d.ts +17 -51
- package/TooltipBase.d.ts +0 -3
- package/TooltipBase.js +0 -129
- package/TooltipBase.js.map +0 -1
package/Tooltip.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
export declare const Tooltip: ({ activatorRef, children, ignoreIntersections, ...props }: TooltipProps) => ReactElement | null;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Tooltip: import("react").ForwardRefExoticComponent<Omit<import("@hh.ru/magritte-internal-drop-base").DropBasePermanentProps, "role" | "placement" | "children" | "arrowGuardDistance" | "animationTimeout" | "animationClassNames" | "allowShrinkHeightToFitIntoViewport" | "guardDistanceToViewport" | "minHeight"> & import("@hh.ru/magritte-ui-tooltip/types").TooltipOnlyProps & import("react").RefAttributes<HTMLDivElement>>;
|
package/Tooltip.js
CHANGED
|
@@ -1,22 +1,113 @@
|
|
|
1
1
|
import './index.css';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
4
|
-
import '
|
|
5
|
-
import '
|
|
6
|
-
import '@hh.ru/magritte-internal-
|
|
7
|
-
import '@hh.ru/magritte-
|
|
8
|
-
import '@hh.ru/magritte-ui-
|
|
9
|
-
import '@hh.ru/magritte-ui-
|
|
10
|
-
import '@hh.ru/magritte-ui-
|
|
11
|
-
import '@hh.ru/magritte-ui-
|
|
12
|
-
import '
|
|
13
|
-
import '
|
|
14
|
-
import '@hh.ru/magritte-ui-typography';
|
|
15
|
-
import '@hh.ru/magritte-ui-typography/BaseText';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, useId, useState, useMemo, useRef, useLayoutEffect } from 'react';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import { DropBase } from '@hh.ru/magritte-internal-drop-base';
|
|
6
|
+
import { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';
|
|
7
|
+
import { Action } from '@hh.ru/magritte-ui-action';
|
|
8
|
+
import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
|
|
9
|
+
import { STRETCHED_WRAPPER_CLASS } from '@hh.ru/magritte-ui-button';
|
|
10
|
+
import { CrossOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';
|
|
11
|
+
import { Layer } from '@hh.ru/magritte-ui-layer';
|
|
12
|
+
import { TooltipArrow } from './TooltipArrow.js';
|
|
13
|
+
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
14
|
+
import { BaseText } from '@hh.ru/magritte-ui-typography/BaseText';
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
var styles = {"tooltip":"magritte-tooltip___Hxyh2_8-0-0","tooltip-with-buttons":"magritte-tooltip-with-buttons___pQzdt_8-0-0","tooltipWithButtons":"magritte-tooltip-with-buttons___pQzdt_8-0-0","tooltip-with-close":"magritte-tooltip-with-close___2iNPt_8-0-0","tooltipWithClose":"magritte-tooltip-with-close___2iNPt_8-0-0","tooltip-small":"magritte-tooltip-small___W1eTg_8-0-0","tooltipSmall":"magritte-tooltip-small___W1eTg_8-0-0","tooltip-title":"magritte-tooltip-title___s-ekd_8-0-0","tooltipTitle":"magritte-tooltip-title___s-ekd_8-0-0","tooltip-close":"magritte-tooltip-close___B1qWh_8-0-0","tooltipClose":"magritte-tooltip-close___B1qWh_8-0-0","tooltip-enter":"magritte-tooltip-enter___cnped_8-0-0","tooltipEnter":"magritte-tooltip-enter___cnped_8-0-0","css-variables-element":"magritte-css-variables-element___yRnOI_8-0-0","cssVariablesElement":"magritte-css-variables-element___yRnOI_8-0-0","tooltip-enter-active":"magritte-tooltip-enter-active___M8qsm_8-0-0","tooltipEnterActive":"magritte-tooltip-enter-active___M8qsm_8-0-0","tooltip-exit":"magritte-tooltip-exit___IXkNp_8-0-0","tooltipExit":"magritte-tooltip-exit___IXkNp_8-0-0","tooltip-exit-active":"magritte-tooltip-exit-active___QllYr_8-0-0","tooltipExitActive":"magritte-tooltip-exit-active___QllYr_8-0-0","tooltip-buttons":"magritte-tooltip-buttons___kNN5e_8-0-0","tooltipButtons":"magritte-tooltip-buttons___kNN5e_8-0-0","tooltip-arrow":"magritte-tooltip-arrow___7OOYT_8-0-0","tooltipArrow":"magritte-tooltip-arrow___7OOYT_8-0-0"};
|
|
17
|
+
|
|
18
|
+
const CSS_CLASSES = {
|
|
19
|
+
enter: styles.tooltipEnter,
|
|
20
|
+
enterActive: styles.tooltipEnterActive,
|
|
21
|
+
exit: styles.tooltipExit,
|
|
22
|
+
exitActive: styles.tooltipExitActive,
|
|
19
23
|
};
|
|
24
|
+
const PLACEMENTS_LIST = [
|
|
25
|
+
'left-center',
|
|
26
|
+
'top-center',
|
|
27
|
+
'right-center',
|
|
28
|
+
'bottom-center',
|
|
29
|
+
'left-top',
|
|
30
|
+
'left-bottom',
|
|
31
|
+
'top-left',
|
|
32
|
+
'top-right',
|
|
33
|
+
'right-bottom',
|
|
34
|
+
'right-top',
|
|
35
|
+
'bottom-left',
|
|
36
|
+
'bottom-right',
|
|
37
|
+
];
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
39
|
+
const noop = () => { };
|
|
40
|
+
const Tooltip = forwardRef(({ visible, activatorRef, onClose = noop, maxWidth = 400, title, children, showClose, closeByClickOutside = true, placement, buttons, forcePlacement, 'aria-label-close': ariaLabelClose, role = 'tooltip', size = 'medium', ignoreIntersections = true, lockPlacement = true, guardDistanceToActivator: _guardDistanceToActivator, ...props }, ref) => {
|
|
41
|
+
const { isMobile } = useBreakpoint();
|
|
42
|
+
const id = useId();
|
|
43
|
+
const ariaLabledBy = `tooltip-aria-label-${id}`;
|
|
44
|
+
const ariaDescribedBy = `tooltip-aria-description-${id}`;
|
|
45
|
+
const [animationTimeout, setAnimationTimeout] = useState(200);
|
|
46
|
+
const [arrowGuardDistance, setArrowGuardDistance] = useState({
|
|
47
|
+
left: { top: 0, bottom: 0, center: 0 },
|
|
48
|
+
right: { top: 0, bottom: 0, center: 0 },
|
|
49
|
+
top: { left: 0, center: 0, right: 0 },
|
|
50
|
+
bottom: { left: 0, center: 0, right: 0 },
|
|
51
|
+
});
|
|
52
|
+
const placementsList = useMemo(() => {
|
|
53
|
+
const placementsArray = Array.isArray(placement) ? placement : [placement];
|
|
54
|
+
return forcePlacement
|
|
55
|
+
? placementsArray
|
|
56
|
+
: [...placementsArray, ...PLACEMENTS_LIST.filter((place) => !placement.includes(place))];
|
|
57
|
+
}, [placement, forcePlacement]);
|
|
58
|
+
const tooltipElementRef = useRef(null);
|
|
59
|
+
const ariaRole = role === 'tooltip' && buttons ? 'alertdialog' : role;
|
|
60
|
+
const isSmall = size === 'small';
|
|
61
|
+
const guardDistanceToActivator = _guardDistanceToActivator ?? isSmall ? 11 : 20;
|
|
62
|
+
useLayoutEffect(() => {
|
|
63
|
+
if (!tooltipElementRef.current) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const style = window.getComputedStyle(tooltipElementRef.current);
|
|
67
|
+
const animationTimeout = parseInt(style.getPropertyValue('--magritte-tooltip-animation-duration'), 10);
|
|
68
|
+
if (Number.isInteger(animationTimeout)) {
|
|
69
|
+
setAnimationTimeout(animationTimeout);
|
|
70
|
+
}
|
|
71
|
+
const borderRadius = parseInt(style.getPropertyValue('--magritte-tooltip-border-radius'), 10);
|
|
72
|
+
const arrowWidth = parseInt(style.getPropertyValue('--magritte-tooltip-arrow-width'), 10);
|
|
73
|
+
if (Number.isInteger(borderRadius) && Number.isInteger(arrowWidth)) {
|
|
74
|
+
const arrowGap = borderRadius + arrowWidth / 2;
|
|
75
|
+
setArrowGuardDistance({
|
|
76
|
+
left: {
|
|
77
|
+
top: arrowGap,
|
|
78
|
+
bottom: arrowGap,
|
|
79
|
+
center: 0,
|
|
80
|
+
},
|
|
81
|
+
right: {
|
|
82
|
+
top: arrowGap,
|
|
83
|
+
bottom: arrowGap,
|
|
84
|
+
center: 0,
|
|
85
|
+
},
|
|
86
|
+
top: {
|
|
87
|
+
left: arrowGap,
|
|
88
|
+
center: 0,
|
|
89
|
+
right: arrowGap,
|
|
90
|
+
},
|
|
91
|
+
bottom: {
|
|
92
|
+
left: arrowGap,
|
|
93
|
+
center: 0,
|
|
94
|
+
right: arrowGap,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}, [buttons, setAnimationTimeout, isSmall, visible]);
|
|
99
|
+
if (isMobile) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return (jsx(Layer, { layer: InternalLayerName.Tooltip, children: jsx(DropBase, { ...props, placement: placementsList, visible: visible, activatorRef: activatorRef, arrowGuardDistance: arrowGuardDistance, closeByClickOutside: closeByClickOutside, onClose: onClose, autoFocusWhenOpened: ariaRole !== 'tooltip', guardDistanceToActivator: guardDistanceToActivator, guardDistanceToViewport: 0, allowShrinkHeightToFitIntoViewport: false, animationClassNames: CSS_CLASSES, animationTimeout: animationTimeout, ignoreIntersections: ignoreIntersections, role: ariaRole, "aria-labelledby": title && role !== 'tooltip' ? ariaLabledBy : undefined, "aria-describedby": role !== 'tooltip' ? ariaDescribedBy : undefined, ref: ref, lockPlacement: lockPlacement, children: () => (jsxs("div", { "data-qa": "tooltip", ref: tooltipElementRef, className: classnames(styles.tooltip, {
|
|
103
|
+
[styles.tooltipWithButtons]: !isSmall && !!buttons,
|
|
104
|
+
[styles.tooltipWithClose]: !isSmall && showClose,
|
|
105
|
+
[styles.tooltipSmall]: isSmall,
|
|
106
|
+
}), style: {
|
|
107
|
+
maxWidth: `${maxWidth}px`,
|
|
108
|
+
}, children: [title && !isSmall && (jsx("div", { className: styles.tooltipTitle, children: jsx(BaseText, { id: ariaLabledBy, "data-qa": "tooltip-title", Element: "div", style: "primary", typography: "title-5-semibold", children: title }) })), jsx(Text, { typography: isSmall ? 'paragraph-3-regular' : 'paragraph-2-regular', id: ariaDescribedBy, children: children }), buttons && !isSmall && (jsx("div", { className: classnames(styles.tooltipButtons, STRETCHED_WRAPPER_CLASS), children: typeof buttons === 'function' ? buttons(onClose) : buttons })), showClose && !isSmall && (jsx("div", { className: styles.tooltipClose, children: jsx(Action, { "data-qa": "tooltip-close-action", "aria-label": ariaLabelClose, icon: CrossOutlinedSize24, mode: "secondary", onClick: () => onClose?.(), style: "contrast" }) })), jsx(TooltipArrow, { className: styles.tooltipArrow, size: size })] })) }) }));
|
|
109
|
+
});
|
|
110
|
+
Tooltip.displayName = 'Tooltip';
|
|
20
111
|
|
|
21
112
|
export { Tooltip };
|
|
22
113
|
//# sourceMappingURL=Tooltip.js.map
|
package/Tooltip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sources":["../src/Tooltip.tsx"],"sourcesContent":["import { ReactElement } from 'react';\n\nimport { TooltipBase } from '@hh.ru/magritte-ui-tooltip/TooltipBase';\nimport { TooltipProps } from '@hh.ru/magritte-ui-tooltip/types';\n\nexport const Tooltip = ({\n activatorRef,\n children,\n ignoreIntersections = true,\n ...props\n}: TooltipProps): ReactElement | null => {\n return (\n <TooltipBase {...props} ignoreIntersections={ignoreIntersections} activatorRef={activatorRef}>\n {children}\n </TooltipBase>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;AAKa,MAAA,OAAO,GAAG,CAAC,EACpB,YAAY,EACZ,QAAQ,EACR,mBAAmB,GAAG,IAAI,EAC1B,GAAG,KAAK,EACG,KAAyB;AACpC,IAAA,QACIA,GAAC,CAAA,WAAW,EAAK,EAAA,GAAA,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,YAAY,EAAE,YAAY,YACvF,QAAQ,EAAA,CACC,EAChB;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sources":["../src/Tooltip.tsx"],"sourcesContent":["import { type ReactElement, useLayoutEffect, useId, useState, useMemo, useRef, forwardRef } from 'react';\nimport classnames from 'classnames';\n\nimport { DropBase, type ArrowGuardDistance, type Placement } from '@hh.ru/magritte-internal-drop-base';\nimport { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';\nimport { Action } from '@hh.ru/magritte-ui-action';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { STRETCHED_WRAPPER_CLASS } from '@hh.ru/magritte-ui-button';\nimport { CrossOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { Layer } from '@hh.ru/magritte-ui-layer';\nimport { TooltipArrow } from '@hh.ru/magritte-ui-tooltip/TooltipArrow';\nimport { TooltipProps } from '@hh.ru/magritte-ui-tooltip/types';\nimport { Text } from '@hh.ru/magritte-ui-typography';\nimport { BaseText } from '@hh.ru/magritte-ui-typography/BaseText';\n\nimport styles from './tooltip.less';\n\nconst CSS_CLASSES = {\n enter: styles.tooltipEnter,\n enterActive: styles.tooltipEnterActive,\n exit: styles.tooltipExit,\n exitActive: styles.tooltipExitActive,\n};\n\nconst PLACEMENTS_LIST: Placement[] = [\n 'left-center',\n 'top-center',\n 'right-center',\n 'bottom-center',\n 'left-top',\n 'left-bottom',\n 'top-left',\n 'top-right',\n 'right-bottom',\n 'right-top',\n 'bottom-left',\n 'bottom-right',\n];\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\n\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(\n (\n {\n visible,\n activatorRef,\n onClose = noop,\n maxWidth = 400,\n title,\n children,\n showClose,\n closeByClickOutside = true,\n placement,\n buttons,\n forcePlacement,\n 'aria-label-close': ariaLabelClose,\n role = 'tooltip',\n size = 'medium',\n ignoreIntersections = true,\n lockPlacement = true,\n guardDistanceToActivator: _guardDistanceToActivator,\n ...props\n }: TooltipProps,\n ref\n ): ReactElement | null => {\n const { isMobile } = useBreakpoint();\n const id = useId();\n const ariaLabledBy = `tooltip-aria-label-${id}`;\n const ariaDescribedBy = `tooltip-aria-description-${id}`;\n const [animationTimeout, setAnimationTimeout] = useState(200);\n const [arrowGuardDistance, setArrowGuardDistance] = useState<ArrowGuardDistance>({\n left: { top: 0, bottom: 0, center: 0 },\n right: { top: 0, bottom: 0, center: 0 },\n top: { left: 0, center: 0, right: 0 },\n bottom: { left: 0, center: 0, right: 0 },\n });\n const placementsList = useMemo(() => {\n const placementsArray: Placement[] = Array.isArray(placement) ? placement : [placement];\n return forcePlacement\n ? placementsArray\n : [...placementsArray, ...PLACEMENTS_LIST.filter((place) => !placement.includes(place))];\n }, [placement, forcePlacement]);\n const tooltipElementRef = useRef<HTMLDivElement>(null);\n\n const ariaRole = role === 'tooltip' && buttons ? 'alertdialog' : role;\n const isSmall = size === 'small';\n const guardDistanceToActivator = _guardDistanceToActivator ?? isSmall ? 11 : 20;\n\n useLayoutEffect(() => {\n if (!tooltipElementRef.current) {\n return;\n }\n\n const style = window.getComputedStyle(tooltipElementRef.current);\n const animationTimeout = parseInt(style.getPropertyValue('--magritte-tooltip-animation-duration'), 10);\n if (Number.isInteger(animationTimeout)) {\n setAnimationTimeout(animationTimeout);\n }\n\n const borderRadius = parseInt(style.getPropertyValue('--magritte-tooltip-border-radius'), 10);\n const arrowWidth = parseInt(style.getPropertyValue('--magritte-tooltip-arrow-width'), 10);\n if (Number.isInteger(borderRadius) && Number.isInteger(arrowWidth)) {\n const arrowGap = borderRadius + arrowWidth / 2;\n setArrowGuardDistance({\n left: {\n top: arrowGap,\n bottom: arrowGap,\n center: 0,\n },\n right: {\n top: arrowGap,\n bottom: arrowGap,\n center: 0,\n },\n top: {\n left: arrowGap,\n center: 0,\n right: arrowGap,\n },\n bottom: {\n left: arrowGap,\n center: 0,\n right: arrowGap,\n },\n });\n }\n }, [buttons, setAnimationTimeout, isSmall, visible]);\n\n if (isMobile) {\n return null;\n }\n\n return (\n <Layer layer={InternalLayerName.Tooltip}>\n <DropBase\n {...props}\n placement={placementsList}\n visible={visible}\n activatorRef={activatorRef}\n arrowGuardDistance={arrowGuardDistance}\n closeByClickOutside={closeByClickOutside}\n onClose={onClose}\n autoFocusWhenOpened={ariaRole !== 'tooltip'}\n guardDistanceToActivator={guardDistanceToActivator}\n guardDistanceToViewport={0}\n allowShrinkHeightToFitIntoViewport={false}\n animationClassNames={CSS_CLASSES}\n animationTimeout={animationTimeout}\n ignoreIntersections={ignoreIntersections}\n role={ariaRole}\n aria-labelledby={title && role !== 'tooltip' ? ariaLabledBy : undefined}\n aria-describedby={role !== 'tooltip' ? ariaDescribedBy : undefined}\n ref={ref}\n lockPlacement={lockPlacement}\n >\n {() => (\n <div\n data-qa=\"tooltip\"\n ref={tooltipElementRef}\n className={classnames(styles.tooltip, {\n [styles.tooltipWithButtons]: !isSmall && !!buttons,\n [styles.tooltipWithClose]: !isSmall && showClose,\n [styles.tooltipSmall]: isSmall,\n })}\n style={{\n maxWidth: `${maxWidth}px`,\n }}\n >\n {title && !isSmall && (\n <div className={styles.tooltipTitle}>\n <BaseText\n id={ariaLabledBy}\n data-qa=\"tooltip-title\"\n Element=\"div\"\n style=\"primary\"\n typography=\"title-5-semibold\"\n >\n {title}\n </BaseText>\n </div>\n )}\n <Text\n typography={isSmall ? 'paragraph-3-regular' : 'paragraph-2-regular'}\n id={ariaDescribedBy}\n >\n {children}\n </Text>\n {buttons && !isSmall && (\n <div className={classnames(styles.tooltipButtons, STRETCHED_WRAPPER_CLASS)}>\n {typeof buttons === 'function' ? buttons(onClose) : buttons}\n </div>\n )}\n {showClose && !isSmall && (\n <div className={styles.tooltipClose}>\n <Action\n data-qa=\"tooltip-close-action\"\n aria-label={ariaLabelClose}\n icon={CrossOutlinedSize24}\n mode=\"secondary\"\n onClick={() => onClose?.()}\n style=\"contrast\"\n />\n </div>\n )}\n <TooltipArrow className={styles.tooltipArrow} size={size} />\n </div>\n )}\n </DropBase>\n </Layer>\n );\n }\n);\n\nTooltip.displayName = 'Tooltip';\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,WAAW,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC,YAAY;IAC1B,WAAW,EAAE,MAAM,CAAC,kBAAkB;IACtC,IAAI,EAAE,MAAM,CAAC,WAAW;IACxB,UAAU,EAAE,MAAM,CAAC,iBAAiB;CACvC,CAAC;AAEF,MAAM,eAAe,GAAgB;IACjC,aAAa;IACb,YAAY;IACZ,cAAc;IACd,eAAe;IACf,UAAU;IACV,aAAa;IACb,UAAU;IACV,WAAW;IACX,cAAc;IACd,WAAW;IACX,aAAa;IACb,cAAc;CACjB,CAAC;AAEF;AACA,MAAM,IAAI,GAAG,MAAK,GAAG,CAAC;AAEf,MAAM,OAAO,GAAG,UAAU,CAC7B,CACI,EACI,OAAO,EACP,YAAY,EACZ,OAAO,GAAG,IAAI,EACd,QAAQ,GAAG,GAAG,EACd,KAAK,EACL,QAAQ,EACR,SAAS,EACT,mBAAmB,GAAG,IAAI,EAC1B,SAAS,EACT,OAAO,EACP,cAAc,EACd,kBAAkB,EAAE,cAAc,EAClC,IAAI,GAAG,SAAS,EAChB,IAAI,GAAG,QAAQ,EACf,mBAAmB,GAAG,IAAI,EAC1B,aAAa,GAAG,IAAI,EACpB,wBAAwB,EAAE,yBAAyB,EACnD,GAAG,KAAK,EACG,EACf,GAAG,KACkB;AACrB,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;AACrC,IAAA,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;AACnB,IAAA,MAAM,YAAY,GAAG,CAAsB,mBAAA,EAAA,EAAE,EAAE,CAAC;AACh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mB,EACzB,IAAI,EAAC,WAAW,EAChB,OAAO,EAAE,MAAM,OAAO,IAAI,EAC1B,KAAK,EAAC,UAAU,GAClB,EACA,CAAA,CACT,EACDA,GAAA,CAAC,YAAY,EAAC,EAAA,SAAS,EAAE,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAI,CAAA,CAAA,EAAA,CAC1D,CACT,EACM,CAAA,EAAA,CACP,EACV;AACN,CAAC,EACH;AAEF,OAAO,CAAC,WAAW,GAAG,SAAS;;;;"}
|
package/TooltipArrow.d.ts
CHANGED
package/TooltipArrow.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const ArrowSmall = ({ className }) => (jsx("svg", { className: className, width: "18", height: "12", viewBox: "0 0 18 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M12.8035 9.82531L10.2206 6.2092C9.62237 5.37167 8.37763 5.37167 7.7794 6.2092L5.19646 9.82531C4.44562 10.8765 3.23333 11.5004 1.94153 11.5004H1.5L1.5 12.5004L16.5 12.5004V11.5004H16.0585C14.7667 11.5004 13.5544 10.8765 12.8035 9.82531Z", fill: "var(--magritte-ui-tooltip-arrow-fill)", stroke: "var(--magritte-ui-tooltip-arrow-stroke)" }) }));
|
|
5
|
+
const ArrowMedium = ({ className }) => (jsx("svg", { className: className, width: "28", height: "12", viewBox: "0 0 28 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M0 11.4996H-0.5L-0.5 11.9996L-0.5 13L-0.5 13.5H0L28 13.5H28.5V13V11.9996V11.4996H28L25.845 11.4996C23.5666 11.4996 21.4118 10.4639 19.9885 8.68482L15.9522 3.63943C14.9514 2.38842 13.0486 2.38842 12.0478 3.63943L8.01152 8.68482C6.58823 10.4639 4.43338 11.4996 2.155 11.4996H0Z", fill: "var(--magritte-ui-tooltip-arrow-fill)", stroke: "var(--magritte-ui-tooltip-arrow-stroke)" }) }));
|
|
6
|
+
const TooltipArrow = ({ className, size }) => size === 'small' ? jsx(ArrowSmall, { className: className }) : jsx(ArrowMedium, { className: className });
|
|
5
7
|
|
|
6
8
|
export { TooltipArrow };
|
|
7
9
|
//# sourceMappingURL=TooltipArrow.js.map
|
package/TooltipArrow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipArrow.js","sources":["../src/TooltipArrow.tsx"],"sourcesContent":["import { FC } from 'react';\n\
|
|
1
|
+
{"version":3,"file":"TooltipArrow.js","sources":["../src/TooltipArrow.tsx"],"sourcesContent":["import { FC } from 'react';\n\nimport { type TooltipProps } from '@hh.ru/magritte-ui-tooltip/types';\n\nconst ArrowSmall: FC<{ className: string }> = ({ className }) => (\n <svg\n className={className}\n width=\"18\"\n height=\"12\"\n viewBox=\"0 0 18 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M12.8035 9.82531L10.2206 6.2092C9.62237 5.37167 8.37763 5.37167 7.7794 6.2092L5.19646 9.82531C4.44562 10.8765 3.23333 11.5004 1.94153 11.5004H1.5L1.5 12.5004L16.5 12.5004V11.5004H16.0585C14.7667 11.5004 13.5544 10.8765 12.8035 9.82531Z\"\n fill=\"var(--magritte-ui-tooltip-arrow-fill)\"\n stroke=\"var(--magritte-ui-tooltip-arrow-stroke)\"\n />\n </svg>\n);\n\nconst ArrowMedium: FC<{ className: string }> = ({ className }) => (\n <svg\n className={className}\n width=\"28\"\n height=\"12\"\n viewBox=\"0 0 28 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M0 11.4996H-0.5L-0.5 11.9996L-0.5 13L-0.5 13.5H0L28 13.5H28.5V13V11.9996V11.4996H28L25.845 11.4996C23.5666 11.4996 21.4118 10.4639 19.9885 8.68482L15.9522 3.63943C14.9514 2.38842 13.0486 2.38842 12.0478 3.63943L8.01152 8.68482C6.58823 10.4639 4.43338 11.4996 2.155 11.4996H0Z\"\n fill=\"var(--magritte-ui-tooltip-arrow-fill)\"\n stroke=\"var(--magritte-ui-tooltip-arrow-stroke)\"\n />\n </svg>\n);\n\nexport const TooltipArrow: FC<{ className: string; size: TooltipProps['size'] }> = ({ className, size }) =>\n size === 'small' ? <ArrowSmall className={className} /> : <ArrowMedium className={className} />;\n"],"names":["_jsx"],"mappings":";;AAIA,MAAM,UAAU,GAA8B,CAAC,EAAE,SAAS,EAAE,MACxDA,GAAA,CAAA,KAAA,EAAA,EACI,SAAS,EAAE,SAAS,EACpB,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,EAElC,QAAA,EAAAA,GAAA,CAAA,MAAA,EAAA,EACI,CAAC,EAAC,6OAA6O,EAC/O,IAAI,EAAC,uCAAuC,EAC5C,MAAM,EAAC,yCAAyC,EAAA,CAClD,EACA,CAAA,CACT,CAAC;AAEF,MAAM,WAAW,GAA8B,CAAC,EAAE,SAAS,EAAE,MACzDA,GAAA,CAAA,KAAA,EAAA,EACI,SAAS,EAAE,SAAS,EACpB,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,EAElC,QAAA,EAAAA,GAAA,CAAA,MAAA,EAAA,EACI,CAAC,EAAC,qRAAqR,EACvR,IAAI,EAAC,uCAAuC,EAC5C,MAAM,EAAC,yCAAyC,EAAA,CAClD,EACA,CAAA,CACT,CAAC;AAEW,MAAA,YAAY,GAA0D,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,KACnG,IAAI,KAAK,OAAO,GAAGA,GAAA,CAAC,UAAU,EAAC,EAAA,SAAS,EAAE,SAAS,GAAI,GAAGA,GAAA,CAAC,WAAW,EAAC,EAAA,SAAS,EAAE,SAAS;;;;"}
|
package/TooltipHover.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { TooltipHoverProps } from '@hh.ru/magritte-ui-tooltip/types';
|
|
3
|
-
export declare const TooltipHover: (
|
|
3
|
+
export declare const TooltipHover: import("react").ForwardRefExoticComponent<TooltipHoverProps & import("react").RefAttributes<HTMLDivElement>>;
|
package/TooltipHover.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { useState, useEffect } from 'react';
|
|
4
|
-
import {
|
|
3
|
+
import { forwardRef, useState, useRef, useCallback, useEffect } from 'react';
|
|
4
|
+
import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
|
|
5
|
+
import { Tooltip } from './Tooltip.js';
|
|
5
6
|
import 'classnames';
|
|
6
7
|
import '@hh.ru/magritte-internal-drop-base';
|
|
7
8
|
import '@hh.ru/magritte-internal-layer-name';
|
|
@@ -14,8 +15,32 @@ import './TooltipArrow.js';
|
|
|
14
15
|
import '@hh.ru/magritte-ui-typography';
|
|
15
16
|
import '@hh.ru/magritte-ui-typography/BaseText';
|
|
16
17
|
|
|
17
|
-
const TooltipHover = ({ activatorRef, children, ignoreIntersections = true, ...props }) => {
|
|
18
|
+
const TooltipHover = forwardRef(({ activatorRef, children, ignoreIntersections = true, size = 'medium', ...props }, ref) => {
|
|
18
19
|
const [visible, setVisible] = useState(false);
|
|
20
|
+
const isSmallRef = useRef(false);
|
|
21
|
+
const hideTimerRef = useRef(null);
|
|
22
|
+
isSmallRef.current = size === 'small';
|
|
23
|
+
const toggleVisible = useCallback((visible) => {
|
|
24
|
+
if (visible === true) {
|
|
25
|
+
if (hideTimerRef.current) {
|
|
26
|
+
clearTimeout(hideTimerRef.current);
|
|
27
|
+
hideTimerRef.current = null;
|
|
28
|
+
}
|
|
29
|
+
setVisible(true);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// eslint-disable-next-line no-unused-expressions
|
|
33
|
+
isSmallRef.current
|
|
34
|
+
? setVisible(false)
|
|
35
|
+
: (hideTimerRef.current = setTimeout(() => setVisible(false), 100));
|
|
36
|
+
}, [setVisible]);
|
|
37
|
+
const tooltipRefCallback = useCallback((node) => {
|
|
38
|
+
if (node && !isSmallRef.current) {
|
|
39
|
+
node.addEventListener('mouseenter', () => toggleVisible(true));
|
|
40
|
+
node.addEventListener('mouseleave', () => toggleVisible(false));
|
|
41
|
+
}
|
|
42
|
+
}, [toggleVisible]);
|
|
43
|
+
const tooltipRefMulti = useMultipleRefs(tooltipRefCallback, ref);
|
|
19
44
|
useEffect(() => {
|
|
20
45
|
const activator = activatorRef.current;
|
|
21
46
|
if (!activator) {
|
|
@@ -23,8 +48,8 @@ const TooltipHover = ({ activatorRef, children, ignoreIntersections = true, ...p
|
|
|
23
48
|
}
|
|
24
49
|
let isTouchEnabled = false;
|
|
25
50
|
const handleTouchStart = () => (isTouchEnabled = true);
|
|
26
|
-
const handleMouseEnter = () => !isTouchEnabled &&
|
|
27
|
-
const handleMouseLeave = () =>
|
|
51
|
+
const handleMouseEnter = () => !isTouchEnabled && toggleVisible(true);
|
|
52
|
+
const handleMouseLeave = () => toggleVisible(false);
|
|
28
53
|
activator.addEventListener('touchstart', handleTouchStart);
|
|
29
54
|
activator.addEventListener('mouseenter', handleMouseEnter);
|
|
30
55
|
activator.addEventListener('mouseleave', handleMouseLeave);
|
|
@@ -33,9 +58,10 @@ const TooltipHover = ({ activatorRef, children, ignoreIntersections = true, ...p
|
|
|
33
58
|
activator.removeEventListener('mouseenter', handleMouseEnter);
|
|
34
59
|
activator.removeEventListener('mouseleave', handleMouseLeave);
|
|
35
60
|
};
|
|
36
|
-
}, [activatorRef,
|
|
37
|
-
return (jsx(
|
|
38
|
-
};
|
|
61
|
+
}, [activatorRef, toggleVisible]);
|
|
62
|
+
return (jsx(Tooltip, { ...props, size: size, onClose: () => setVisible(false), ignoreIntersections: ignoreIntersections, visible: visible, activatorRef: activatorRef, ref: tooltipRefMulti, children: children }));
|
|
63
|
+
});
|
|
64
|
+
TooltipHover.displayName = 'TooltipHover';
|
|
39
65
|
|
|
40
66
|
export { TooltipHover };
|
|
41
67
|
//# sourceMappingURL=TooltipHover.js.map
|
package/TooltipHover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipHover.js","sources":["../src/TooltipHover.tsx"],"sourcesContent":["import { ReactElement, useEffect, useState } from 'react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"TooltipHover.js","sources":["../src/TooltipHover.tsx"],"sourcesContent":["import { forwardRef, ReactElement, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { Tooltip } from '@hh.ru/magritte-ui-tooltip/Tooltip';\nimport { TooltipHoverProps } from '@hh.ru/magritte-ui-tooltip/types';\n\nexport const TooltipHover = forwardRef<HTMLDivElement, TooltipHoverProps>(\n ({ activatorRef, children, ignoreIntersections = true, size = 'medium', ...props }, ref): ReactElement | null => {\n const [visible, setVisible] = useState(false);\n const isSmallRef = useRef(false);\n const hideTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n isSmallRef.current = size === 'small';\n\n const toggleVisible = useCallback(\n (visible: boolean) => {\n if (visible === true) {\n if (hideTimerRef.current) {\n clearTimeout(hideTimerRef.current);\n hideTimerRef.current = null;\n }\n setVisible(true);\n return;\n }\n\n // eslint-disable-next-line no-unused-expressions\n isSmallRef.current\n ? setVisible(false)\n : (hideTimerRef.current = setTimeout(() => setVisible(false), 100));\n },\n [setVisible]\n );\n\n const tooltipRefCallback = useCallback(\n (node: HTMLDivElement | null) => {\n if (node && !isSmallRef.current) {\n node.addEventListener('mouseenter', () => toggleVisible(true));\n node.addEventListener('mouseleave', () => toggleVisible(false));\n }\n },\n [toggleVisible]\n );\n\n const tooltipRefMulti = useMultipleRefs(tooltipRefCallback, ref);\n\n useEffect(() => {\n const activator = activatorRef.current;\n if (!activator) {\n return void 0;\n }\n\n let isTouchEnabled = false;\n\n const handleTouchStart = () => (isTouchEnabled = true);\n const handleMouseEnter = () => !isTouchEnabled && toggleVisible(true);\n const handleMouseLeave = () => toggleVisible(false);\n\n activator.addEventListener('touchstart', handleTouchStart);\n activator.addEventListener('mouseenter', handleMouseEnter);\n activator.addEventListener('mouseleave', handleMouseLeave);\n\n return () => {\n activator.removeEventListener('touchstart', handleTouchStart);\n activator.removeEventListener('mouseenter', handleMouseEnter);\n activator.removeEventListener('mouseleave', handleMouseLeave);\n };\n }, [activatorRef, toggleVisible]);\n\n return (\n <Tooltip\n {...props}\n size={size}\n onClose={() => setVisible(false)}\n ignoreIntersections={ignoreIntersections}\n visible={visible}\n activatorRef={activatorRef}\n ref={tooltipRefMulti}\n >\n {children}\n </Tooltip>\n );\n }\n);\n\nTooltipHover.displayName = 'TooltipHover';\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;AAMa,MAAA,YAAY,GAAG,UAAU,CAClC,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,mBAAmB,GAAG,IAAI,EAAE,IAAI,GAAG,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAyB;IAC5G,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC9C,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AACjC,IAAA,MAAM,YAAY,GAAG,MAAM,CAAuC,IAAI,CAAC,CAAC;AAExE,IAAA,UAAU,CAAC,OAAO,GAAG,IAAI,KAAK,OAAO,CAAC;AAEtC,IAAA,MAAM,aAAa,GAAG,WAAW,CAC7B,CAAC,OAAgB,KAAI;QACjB,IAAI,OAAO,KAAK,IAAI,EAAE;YAClB,IAAI,YAAY,CAAC,OAAO,EAAE;AACtB,gBAAA,YA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SAAS,CAAC,gBAAgB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAC3D,QAAA,SAAS,CAAC,gBAAgB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAC3D,QAAA,SAAS,CAAC,gBAAgB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAE3D,QAAA,OAAO,MAAK;AACR,YAAA,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAC9D,YAAA,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAC9D,YAAA,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAClE,SAAC,CAAC;AACN,KAAC,EAAE,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;AAElC,IAAA,QACIA,GAAC,CAAA,OAAO,EACA,EAAA,GAAA,KAAK,EACT,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,UAAU,CAAC,KAAK,CAAC,EAChC,mBAAmB,EAAE,mBAAmB,EACxC,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,eAAe,YAEnB,QAAQ,EAAA,CACH,EACZ;AACN,CAAC,EACH;AAEF,YAAY,CAAC,WAAW,GAAG,cAAc;;;;"}
|
package/index.css
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
:root{
|
|
7
7
|
--magritte-semantic-animation-ease-in-out-200-timing-function-v19-1-0:cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
8
8
|
--magritte-semantic-animation-ease-in-out-200-duration-v19-1-0:200ms;
|
|
9
|
+
--magritte-static-border-radius-300-v19-1-0:12px;
|
|
9
10
|
--magritte-static-border-radius-400-v19-1-0:16px;
|
|
10
11
|
--magritte-static-border-radius-600-v19-1-0:24px;
|
|
11
12
|
}
|
|
@@ -14,11 +15,11 @@
|
|
|
14
15
|
--magritte-color-component-tooltip-text-content-v19-1-0:#ffffff;
|
|
15
16
|
--magritte-color-component-tooltip-stroke-content-v19-1-0:#3B3B3B;
|
|
16
17
|
}
|
|
17
|
-
.magritte-
|
|
18
|
+
.magritte-tooltip___Hxyh2_8-0-0{
|
|
18
19
|
position:relative;
|
|
19
20
|
padding:16px;
|
|
20
|
-
border-radius:var(--magritte-static-border-radius-400-v19-1-0);
|
|
21
21
|
background:var(--magritte-color-component-tooltip-background-content-v19-1-0);
|
|
22
|
+
border-radius:var(--magritte-tooltip-border-radius);
|
|
22
23
|
border:1px solid var(--magritte-color-component-tooltip-stroke-content-v19-1-0);
|
|
23
24
|
box-sizing:border-box;
|
|
24
25
|
word-wrap:break-word;
|
|
@@ -26,120 +27,126 @@
|
|
|
26
27
|
--magritte-ui-text-color-override:var(--magritte-color-component-tooltip-text-content-v19-1-0);
|
|
27
28
|
--magritte-ui-tooltip-arrow-fill:var(--magritte-color-component-tooltip-background-content-v19-1-0);
|
|
28
29
|
--magritte-ui-tooltip-arrow-stroke:var(--magritte-color-component-tooltip-stroke-content-v19-1-0);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
.magritte-tooltip-
|
|
30
|
+
--magritte-tooltip-arrow-vertical-gap:calc(var(--magritte-static-border-radius-400-v19-1-0) + 28px / 2 - 12px / 2 - 1px);
|
|
31
|
+
--magritte-tooltip-border-radius:var(--magritte-static-border-radius-400-v19-1-0);
|
|
32
|
+
--magritte-tooltip-arrow-width:28px;
|
|
33
|
+
--magritte-tooltip-arrow-height:12px;
|
|
34
|
+
}
|
|
35
|
+
.magritte-tooltip-with-buttons___pQzdt_8-0-0{
|
|
36
|
+
padding:24px 24px 12px;
|
|
37
|
+
--magritte-tooltip-arrow-vertical-gap:calc(var(--magritte-static-border-radius-600-v19-1-0) + 28px / 2 - 12px / 2 - 1px);
|
|
38
|
+
--magritte-tooltip-border-radius:var(--magritte-static-border-radius-600-v19-1-0);
|
|
39
|
+
--magritte-tooltip-arrow-width:28px;
|
|
40
|
+
--magritte-tooltip-arrow-height:12px;
|
|
41
|
+
}
|
|
42
|
+
.magritte-tooltip-with-close___2iNPt_8-0-0{
|
|
43
|
+
padding-right:56px;
|
|
44
|
+
}
|
|
45
|
+
.magritte-tooltip-small___W1eTg_8-0-0{
|
|
46
|
+
padding:8px 12px;
|
|
47
|
+
min-height:0;
|
|
48
|
+
--magritte-tooltip-arrow-vertical-gap:calc(var(--magritte-static-border-radius-300-v19-1-0) + 18px / 2 - 12px / 2 - 1px);
|
|
49
|
+
--magritte-tooltip-border-radius:var(--magritte-static-border-radius-300-v19-1-0);
|
|
50
|
+
--magritte-tooltip-arrow-width:18px;
|
|
51
|
+
--magritte-tooltip-arrow-height:12px;
|
|
52
|
+
}
|
|
53
|
+
.magritte-tooltip-title___s-ekd_8-0-0{
|
|
35
54
|
margin-bottom:4px;
|
|
36
55
|
}
|
|
37
|
-
.magritte-tooltip-
|
|
56
|
+
.magritte-tooltip-close___B1qWh_8-0-0{
|
|
38
57
|
position:absolute;
|
|
39
58
|
right:9px;
|
|
40
59
|
top:9px;
|
|
41
60
|
}
|
|
42
|
-
.magritte-tooltip-with-
|
|
43
|
-
|
|
61
|
+
.magritte-tooltip-with-buttons___pQzdt_8-0-0 .magritte-tooltip-close___B1qWh_8-0-0{
|
|
62
|
+
right:15px;
|
|
63
|
+
top:15px;
|
|
44
64
|
}
|
|
45
65
|
@media (prefers-reduced-motion: no-preference){
|
|
46
|
-
.magritte-tooltip-
|
|
66
|
+
.magritte-tooltip-enter___cnped_8-0-0 .magritte-tooltip___Hxyh2_8-0-0{
|
|
47
67
|
opacity:0;
|
|
48
68
|
}
|
|
49
|
-
.magritte-css-variables-
|
|
50
|
-
.magritte-tooltip-enter-
|
|
69
|
+
.magritte-css-variables-element___yRnOI_8-0-0,
|
|
70
|
+
.magritte-tooltip-enter-active___M8qsm_8-0-0 .magritte-tooltip___Hxyh2_8-0-0{
|
|
51
71
|
opacity:1;
|
|
52
72
|
transition-property:opacity, transform;
|
|
53
73
|
transition-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v19-1-0);
|
|
54
74
|
transition-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v19-1-0);
|
|
55
75
|
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v19-1-0);
|
|
56
76
|
}
|
|
57
|
-
.magritte-tooltip-
|
|
77
|
+
.magritte-tooltip-exit___IXkNp_8-0-0 .magritte-tooltip___Hxyh2_8-0-0{
|
|
58
78
|
opacity:1;
|
|
59
79
|
}
|
|
60
|
-
.magritte-tooltip-exit-
|
|
80
|
+
.magritte-tooltip-exit-active___QllYr_8-0-0 .magritte-tooltip___Hxyh2_8-0-0{
|
|
61
81
|
opacity:0;
|
|
62
82
|
transition-property:opacity, transform;
|
|
63
83
|
transition-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v19-1-0);
|
|
64
84
|
transition-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v19-1-0);
|
|
65
85
|
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v19-1-0);
|
|
66
86
|
}
|
|
67
|
-
.magritte-tooltip-exit-
|
|
68
|
-
.magritte-tooltip-
|
|
87
|
+
.magritte-tooltip-exit-active___QllYr_8-0-0[data-magritte-drop-base-direction='bottom'] .magritte-tooltip___Hxyh2_8-0-0,
|
|
88
|
+
.magritte-tooltip-enter___cnped_8-0-0[data-magritte-drop-base-direction='bottom'] .magritte-tooltip___Hxyh2_8-0-0{
|
|
69
89
|
transform:translateY(4px);
|
|
70
90
|
}
|
|
71
|
-
.magritte-tooltip-exit-
|
|
72
|
-
.magritte-tooltip-
|
|
91
|
+
.magritte-tooltip-exit-active___QllYr_8-0-0[data-magritte-drop-base-direction='top'] .magritte-tooltip___Hxyh2_8-0-0,
|
|
92
|
+
.magritte-tooltip-enter___cnped_8-0-0[data-magritte-drop-base-direction='top'] .magritte-tooltip___Hxyh2_8-0-0{
|
|
73
93
|
transform:translateY(-4px);
|
|
74
94
|
}
|
|
75
|
-
.magritte-tooltip-exit-
|
|
76
|
-
.magritte-tooltip-
|
|
95
|
+
.magritte-tooltip-exit-active___QllYr_8-0-0[data-magritte-drop-base-direction='left'] .magritte-tooltip___Hxyh2_8-0-0,
|
|
96
|
+
.magritte-tooltip-enter___cnped_8-0-0[data-magritte-drop-base-direction='left'] .magritte-tooltip___Hxyh2_8-0-0{
|
|
77
97
|
transform:translateX(-4px);
|
|
78
98
|
}
|
|
79
|
-
.magritte-tooltip-exit-
|
|
80
|
-
.magritte-tooltip-
|
|
99
|
+
.magritte-tooltip-exit-active___QllYr_8-0-0[data-magritte-drop-base-direction='right'] .magritte-tooltip___Hxyh2_8-0-0,
|
|
100
|
+
.magritte-tooltip-enter___cnped_8-0-0[data-magritte-drop-base-direction='right'] .magritte-tooltip___Hxyh2_8-0-0{
|
|
81
101
|
transform:translateX(4px);
|
|
82
102
|
}
|
|
83
|
-
.magritte-tooltip-enter-
|
|
103
|
+
.magritte-tooltip-enter-active___M8qsm_8-0-0[data-magritte-drop-base-direction] .magritte-tooltip___Hxyh2_8-0-0{
|
|
84
104
|
transform:translate(0, 0);
|
|
85
105
|
}
|
|
86
106
|
}
|
|
87
|
-
.magritte-tooltip-
|
|
107
|
+
.magritte-tooltip-buttons___kNN5e_8-0-0{
|
|
88
108
|
display:flex;
|
|
89
109
|
gap:12px;
|
|
90
|
-
margin-
|
|
91
|
-
flex-flow:wrap;
|
|
110
|
+
margin:24px -12px 0;
|
|
92
111
|
}
|
|
93
|
-
.magritte-
|
|
94
|
-
|
|
95
|
-
right:15px;
|
|
96
|
-
bottom:24px;
|
|
97
|
-
left:calc(var(--magritte-static-border-radius-600-v19-1-0) - 12px / 2 + 28px /2 );
|
|
112
|
+
.magritte-tooltip-with-close___2iNPt_8-0-0 .magritte-tooltip-buttons___kNN5e_8-0-0{
|
|
113
|
+
margin-right:-44px;
|
|
98
114
|
}
|
|
99
|
-
.magritte-tooltip-
|
|
115
|
+
.magritte-tooltip-arrow___7OOYT_8-0-0{
|
|
100
116
|
position:absolute;
|
|
101
117
|
}
|
|
102
|
-
[data-magritte-drop-base-direction='bottom'] .magritte-tooltip-
|
|
103
|
-
top
|
|
118
|
+
[data-magritte-drop-base-direction='bottom'] .magritte-tooltip-arrow___7OOYT_8-0-0{
|
|
119
|
+
top:calc(var(--magritte-tooltip-arrow-height) * -1);
|
|
104
120
|
}
|
|
105
|
-
[data-magritte-drop-base-direction='top'] .magritte-tooltip-
|
|
106
|
-
bottom
|
|
121
|
+
[data-magritte-drop-base-direction='top'] .magritte-tooltip-arrow___7OOYT_8-0-0{
|
|
122
|
+
bottom:calc(var(--magritte-tooltip-arrow-height) * -1);
|
|
107
123
|
transform:rotate(180deg);
|
|
108
124
|
}
|
|
109
|
-
[data-magritte-drop-base-alignment='left'] .magritte-tooltip-
|
|
110
|
-
left:
|
|
125
|
+
[data-magritte-drop-base-alignment='left'] .magritte-tooltip-arrow___7OOYT_8-0-0{
|
|
126
|
+
left:var(--magritte-tooltip-border-radius);
|
|
111
127
|
}
|
|
112
|
-
[data-magritte-drop-base-
|
|
113
|
-
|
|
128
|
+
[data-magritte-drop-base-direction='top'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_8-0-0,
|
|
129
|
+
[data-magritte-drop-base-direction='bottom'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_8-0-0{
|
|
130
|
+
left:calc(50% - var(--magritte-tooltip-arrow-width) / 2);
|
|
114
131
|
}
|
|
115
|
-
[data-magritte-drop-base-
|
|
116
|
-
|
|
117
|
-
left:calc(50% - 28px/2);
|
|
132
|
+
[data-magritte-drop-base-alignment='right'] .magritte-tooltip-arrow___7OOYT_8-0-0{
|
|
133
|
+
right:var(--magritte-tooltip-border-radius);
|
|
118
134
|
}
|
|
119
|
-
[data-magritte-drop-base-
|
|
120
|
-
right:
|
|
121
|
-
}
|
|
122
|
-
[data-magritte-drop-base-alignment='right'][data-magritte-drop-base-direction='top'] .magritte-tooltip-with-action___aYbOD_7-0-24 .magritte-tooltip-arrow___7OOYT_7-0-24{
|
|
123
|
-
right:calc(var(--magritte-static-border-radius-600-v19-1-0) - 12px/2 + 28px/2);
|
|
124
|
-
}
|
|
125
|
-
[data-magritte-drop-base-direction='left'] .magritte-tooltip-arrow___7OOYT_7-0-24{
|
|
126
|
-
right:-20px;
|
|
135
|
+
[data-magritte-drop-base-direction='left'] .magritte-tooltip-arrow___7OOYT_8-0-0{
|
|
136
|
+
right:calc(-1 * (var(--magritte-tooltip-arrow-width) / 2 + var(--magritte-tooltip-arrow-height) / 2));
|
|
127
137
|
transform:rotate(90deg);
|
|
128
138
|
}
|
|
129
|
-
[data-magritte-drop-base-direction='right'] .magritte-tooltip-
|
|
130
|
-
left
|
|
139
|
+
[data-magritte-drop-base-direction='right'] .magritte-tooltip-arrow___7OOYT_8-0-0{
|
|
140
|
+
left:calc(-1 * (var(--magritte-tooltip-arrow-width) / 2 + var(--magritte-tooltip-arrow-height) / 2));
|
|
131
141
|
transform:rotate(-90deg);
|
|
132
142
|
}
|
|
133
|
-
[data-magritte-drop-base-alignment='top'] .magritte-tooltip-
|
|
134
|
-
top:
|
|
135
|
-
}
|
|
136
|
-
[data-magritte-drop-base-direction='left'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_7-0-24,
|
|
137
|
-
[data-magritte-drop-base-direction='right'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_7-0-24{
|
|
138
|
-
top:calc(50% - 12px/2);
|
|
143
|
+
[data-magritte-drop-base-alignment='top'] .magritte-tooltip-arrow___7OOYT_8-0-0{
|
|
144
|
+
top:var(--magritte-tooltip-arrow-vertical-gap);
|
|
139
145
|
}
|
|
140
|
-
[data-magritte-drop-base-alignment='
|
|
141
|
-
|
|
146
|
+
[data-magritte-drop-base-direction='left'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_8-0-0,
|
|
147
|
+
[data-magritte-drop-base-direction='right'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_8-0-0{
|
|
148
|
+
top:calc(50% - var(--magritte-tooltip-arrow-height) / 2);
|
|
142
149
|
}
|
|
143
|
-
[data-magritte-drop-base-alignment='bottom'] .magritte-tooltip-
|
|
144
|
-
bottom:
|
|
150
|
+
[data-magritte-drop-base-alignment='bottom'] .magritte-tooltip-arrow___7OOYT_8-0-0{
|
|
151
|
+
bottom:var(--magritte-tooltip-arrow-vertical-gap);
|
|
145
152
|
}
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { Tooltip } from './Tooltip.js';
|
|
|
4
4
|
export * from '@hh.ru/magritte-ui-theme-provider';
|
|
5
5
|
import 'react/jsx-runtime';
|
|
6
6
|
import 'react';
|
|
7
|
-
import '
|
|
7
|
+
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
8
8
|
import 'classnames';
|
|
9
9
|
import '@hh.ru/magritte-internal-drop-base';
|
|
10
10
|
import '@hh.ru/magritte-internal-layer-name';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-tooltip",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
"watch": "yarn root:watch $(pwd)"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@hh.ru/magritte-common-use-multiple-refs": "1.1.4",
|
|
23
24
|
"@hh.ru/magritte-design-tokens": "19.1.0",
|
|
24
|
-
"@hh.ru/magritte-internal-drop-base": "7.0.
|
|
25
|
+
"@hh.ru/magritte-internal-drop-base": "7.0.7",
|
|
25
26
|
"@hh.ru/magritte-internal-layer-name": "2.2.0",
|
|
26
27
|
"@hh.ru/magritte-ui-action": "4.4.10",
|
|
27
28
|
"@hh.ru/magritte-ui-breakpoint": "4.0.3",
|
|
@@ -38,5 +39,5 @@
|
|
|
38
39
|
"publishConfig": {
|
|
39
40
|
"access": "public"
|
|
40
41
|
},
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "12abe2b68f9a64a35f1233c0cf03e3951c1193e6"
|
|
42
43
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,57 +1,23 @@
|
|
|
1
|
-
import { ReactNode,
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
interface TooltipPropsWithAction {
|
|
6
|
-
/** Лейбл кнопки действия */
|
|
7
|
-
action: ButtonLabel;
|
|
8
|
-
/** Лейбл кнопки закрытия */
|
|
9
|
-
actionClose: ButtonLabel;
|
|
10
|
-
/** Cвойства кнопки действия */
|
|
11
|
-
actionProps: Omit<ButtonProps, 'style' | 'mode' | 'size' | 'Element'> & Omit<DefaultButtonProps, 'children'>;
|
|
12
|
-
'aria-label-close'?: never;
|
|
13
|
-
showClose?: false;
|
|
14
|
-
}
|
|
15
|
-
interface TooltipPropsWithoutAction {
|
|
16
|
-
action?: never;
|
|
17
|
-
actionClose?: never;
|
|
18
|
-
actionProps?: never;
|
|
19
|
-
'aria-label-close'?: never;
|
|
20
|
-
showClose?: false;
|
|
21
|
-
}
|
|
22
|
-
interface TooltipPropsWithoutActionWithClose {
|
|
23
|
-
action?: never;
|
|
24
|
-
actionClose?: never;
|
|
25
|
-
actionProps?: never;
|
|
26
|
-
/** Aria label иконки закрытия */
|
|
27
|
-
'aria-label-close': string;
|
|
28
|
-
/** Показать ли иконку закрытия, можно устоновить если в tooltip нет action */
|
|
29
|
-
showClose: true;
|
|
30
|
-
}
|
|
31
|
-
interface TooltipTitleProps {
|
|
32
|
-
/** Заголовок компонента */
|
|
33
|
-
title: ReactNode;
|
|
34
|
-
'aria-label'?: never;
|
|
35
|
-
}
|
|
36
|
-
interface TooltipWithoutTitleProps {
|
|
37
|
-
title?: never;
|
|
38
|
-
/** Aria заголовок, устанавливаем в случае если нет title и role !== 'tooltip' */
|
|
39
|
-
'aria-label'?: string;
|
|
40
|
-
}
|
|
41
|
-
interface TooltipOnlyProps {
|
|
1
|
+
import { ReactNode, PropsWithChildren } from 'react';
|
|
2
|
+
import type { DropBasePermanentProps, Placement } from '@hh.ru/magritte-internal-drop-base';
|
|
3
|
+
export interface TooltipOnlyProps extends PropsWithChildren {
|
|
4
|
+
title?: ReactNode;
|
|
42
5
|
/** Максимальная ширина тултипа */
|
|
43
6
|
maxWidth?: number;
|
|
44
7
|
/** Aria role подробнее в разделе Доступность */
|
|
45
8
|
role?: 'tooltip' | 'dialog' | 'alertdialog';
|
|
46
|
-
|
|
9
|
+
/** Название размещения которое является приоритетным для выпадания тултипа */
|
|
10
|
+
placement: Placement | Placement[];
|
|
11
|
+
/** Флаг при включении которого приоритетное размещение становится единственным допустимым для выпадения */
|
|
47
12
|
forcePlacement?: boolean;
|
|
13
|
+
size?: 'small' | 'medium';
|
|
14
|
+
buttons?: ReactNode | ((onClose: VoidFunction) => ReactNode);
|
|
15
|
+
/** Показать ли иконку закрытия, можно установить если в tooltip нет action */
|
|
16
|
+
showClose?: boolean;
|
|
17
|
+
/** Aria label иконки закрытия */
|
|
18
|
+
'aria-label-close'?: string;
|
|
19
|
+
/** Aria заголовок, устанавливаем в случае если нет title и role !== 'tooltip' */
|
|
20
|
+
'aria-label'?: string;
|
|
48
21
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
activatorRef: RefObject<ActivatorElementType>;
|
|
52
|
-
}
|
|
53
|
-
export type TooltipActionableProps = PropsWithChildren<TooltipOnlyProps> & (TooltipPropsWithAction | TooltipPropsWithoutActionWithClose | TooltipPropsWithoutAction) & (TooltipTitleProps | TooltipWithoutTitleProps);
|
|
54
|
-
export type TooltipBaseProps = Omit<DropBasePermanentProps, 'arrowGuardDistance' | 'children' | 'animationTimeout' | 'animationClassNames' | 'role' | 'placement' | 'allowShrinkHeightToFitIntoViewport' | 'guardDistanceToViewport' | 'minHeight'> & TooltipActionableProps;
|
|
55
|
-
export type TooltipHoverProps = Omit<DropBasePermanentProps, 'closeByClickOutside' | 'arrowGuardDistance' | 'children' | 'animationTimeout' | 'animationClassNames' | 'visible' | 'role' | 'activatorRef' | 'autoFocusWhenOpened' | 'placement' | 'allowShrinkHeightToFitIntoViewport' | 'guardDistanceToViewport' | 'minHeight'> & PropsWithChildren<Omit<TooltipOnlyProps, 'role'>> & TooltipActivator;
|
|
56
|
-
export type TooltipProps = Omit<DropBasePermanentProps, 'arrowGuardDistance' | 'children' | 'animationTimeout' | 'animationClassNames' | 'role' | 'activatorRef' | 'placement' | 'allowShrinkHeightToFitIntoViewport' | 'guardDistanceToViewport' | 'minHeight'> & TooltipActionableProps & TooltipActivator;
|
|
57
|
-
export {};
|
|
22
|
+
export type TooltipProps = Omit<DropBasePermanentProps, 'arrowGuardDistance' | 'children' | 'animationTimeout' | 'animationClassNames' | 'role' | 'placement' | 'allowShrinkHeightToFitIntoViewport' | 'guardDistanceToViewport' | 'minHeight'> & TooltipOnlyProps;
|
|
23
|
+
export type TooltipHoverProps = Omit<TooltipProps, 'closeByClickOutside' | 'visible' | 'role' | 'autoFocusWhenOpened'>;
|
package/TooltipBase.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { type ReactElement } from 'react';
|
|
2
|
-
import { TooltipBaseProps } from '@hh.ru/magritte-ui-tooltip/types';
|
|
3
|
-
export declare const TooltipBase: ({ visible, activatorRef, onClose, maxWidth, title, action, actionClose, children, showClose, actionProps, guardDistanceToActivator, closeByClickOutside, placement, forcePlacement, "aria-label-close": ariaLabelClose, role, ...props }: TooltipBaseProps) => ReactElement | null;
|
package/TooltipBase.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { useId, useState, useMemo, useEffect } from 'react';
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
import { DropBase } from '@hh.ru/magritte-internal-drop-base';
|
|
6
|
-
import { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';
|
|
7
|
-
import { Action } from '@hh.ru/magritte-ui-action';
|
|
8
|
-
import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
|
|
9
|
-
import { Button } from '@hh.ru/magritte-ui-button';
|
|
10
|
-
import { CrossOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';
|
|
11
|
-
import { Layer } from '@hh.ru/magritte-ui-layer';
|
|
12
|
-
import { TooltipArrow } from './TooltipArrow.js';
|
|
13
|
-
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
14
|
-
import { BaseText } from '@hh.ru/magritte-ui-typography/BaseText';
|
|
15
|
-
|
|
16
|
-
var styles = {"tooltip":"magritte-tooltip___Hxyh2_7-0-24","tooltip-with-action":"magritte-tooltip-with-action___aYbOD_7-0-24","tooltipWithAction":"magritte-tooltip-with-action___aYbOD_7-0-24","tooltip-title":"magritte-tooltip-title___s-ekd_7-0-24","tooltipTitle":"magritte-tooltip-title___s-ekd_7-0-24","tooltip-close":"magritte-tooltip-close___B1qWh_7-0-24","tooltipClose":"magritte-tooltip-close___B1qWh_7-0-24","tooltip-with-close":"magritte-tooltip-with-close___2iNPt_7-0-24","tooltipWithClose":"magritte-tooltip-with-close___2iNPt_7-0-24","tooltip-enter":"magritte-tooltip-enter___cnped_7-0-24","tooltipEnter":"magritte-tooltip-enter___cnped_7-0-24","css-variables-element":"magritte-css-variables-element___yRnOI_7-0-24","cssVariablesElement":"magritte-css-variables-element___yRnOI_7-0-24","tooltip-enter-active":"magritte-tooltip-enter-active___M8qsm_7-0-24","tooltipEnterActive":"magritte-tooltip-enter-active___M8qsm_7-0-24","tooltip-exit":"magritte-tooltip-exit___IXkNp_7-0-24","tooltipExit":"magritte-tooltip-exit___IXkNp_7-0-24","tooltip-exit-active":"magritte-tooltip-exit-active___QllYr_7-0-24","tooltipExitActive":"magritte-tooltip-exit-active___QllYr_7-0-24","tooltip-actions":"magritte-tooltip-actions___gN8ad_7-0-24","tooltipActions":"magritte-tooltip-actions___gN8ad_7-0-24","tooltip-arrow":"magritte-tooltip-arrow___7OOYT_7-0-24","tooltipArrow":"magritte-tooltip-arrow___7OOYT_7-0-24"};
|
|
17
|
-
|
|
18
|
-
const CSS_CLASSES = {
|
|
19
|
-
enter: styles.tooltipEnter,
|
|
20
|
-
enterActive: styles.tooltipEnterActive,
|
|
21
|
-
exit: styles.tooltipExit,
|
|
22
|
-
exitActive: styles.tooltipExitActive,
|
|
23
|
-
};
|
|
24
|
-
const PLACEMENTS_LIST = [
|
|
25
|
-
'left-top',
|
|
26
|
-
'left-center',
|
|
27
|
-
'left-bottom',
|
|
28
|
-
'top-left',
|
|
29
|
-
'top-center',
|
|
30
|
-
'top-right',
|
|
31
|
-
'right-bottom',
|
|
32
|
-
'right-center',
|
|
33
|
-
'right-top',
|
|
34
|
-
'bottom-left',
|
|
35
|
-
'bottom-center',
|
|
36
|
-
'bottom-right',
|
|
37
|
-
];
|
|
38
|
-
const TooltipBase = ({ visible, activatorRef, onClose, maxWidth = 400, title, action, actionClose, children, showClose, actionProps, guardDistanceToActivator = 20, closeByClickOutside = true, placement, forcePlacement, 'aria-label-close': ariaLabelClose, role = 'tooltip', ...props }) => {
|
|
39
|
-
const { isMobile } = useBreakpoint();
|
|
40
|
-
const id = useId();
|
|
41
|
-
const ariaLabledBy = `tooltip-aria-label-${id}`;
|
|
42
|
-
const ariaDescribedBy = `tooltip-aria-description-${id}`;
|
|
43
|
-
const [animationTimeout, setAnimationTimeout] = useState(200);
|
|
44
|
-
const [arrowGuardDistance, setArrowGuardDistance] = useState({
|
|
45
|
-
left: { top: 0, bottom: 0, center: 0 },
|
|
46
|
-
right: { top: 0, bottom: 0, center: 0 },
|
|
47
|
-
top: { left: 0, center: 0, right: 0 },
|
|
48
|
-
bottom: { left: 0, center: 0, right: 0 },
|
|
49
|
-
});
|
|
50
|
-
const placementsList = useMemo(() => (forcePlacement ? placement : [placement, ...PLACEMENTS_LIST.filter((place) => place !== placement)]), [placement, forcePlacement]);
|
|
51
|
-
const ariaRole = role === 'tooltip' && action ? 'alertdialog' : role;
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
const cssVariablesElement = document.createElement('div');
|
|
54
|
-
cssVariablesElement.classList.add(styles.cssVariablesElement);
|
|
55
|
-
document.body.appendChild(cssVariablesElement);
|
|
56
|
-
const style = window.getComputedStyle(cssVariablesElement);
|
|
57
|
-
const animationTimeout = parseInt(style.getPropertyValue(`--animation-duration`), 10);
|
|
58
|
-
if (Number.isInteger(animationTimeout)) {
|
|
59
|
-
setAnimationTimeout(animationTimeout);
|
|
60
|
-
}
|
|
61
|
-
const arrowSize = parseInt(style.getPropertyValue('top'), 10);
|
|
62
|
-
const arrowOffset = parseInt(style.getPropertyValue('right'), 10);
|
|
63
|
-
const arrowOffsetVertical = parseInt(style.getPropertyValue('bottom'), 10);
|
|
64
|
-
const arrowOffsetHorizontal = parseInt(style.getPropertyValue('left'), 10);
|
|
65
|
-
if (Number.isInteger(arrowSize) &&
|
|
66
|
-
Number.isInteger(arrowOffset) &&
|
|
67
|
-
Number.isInteger(arrowOffsetVertical) &&
|
|
68
|
-
Number.isInteger(arrowOffsetHorizontal)) {
|
|
69
|
-
setArrowGuardDistance(action
|
|
70
|
-
? {
|
|
71
|
-
left: {
|
|
72
|
-
top: arrowOffset + arrowSize / 2,
|
|
73
|
-
bottom: arrowOffsetVertical + arrowSize / 2,
|
|
74
|
-
center: 0,
|
|
75
|
-
},
|
|
76
|
-
right: {
|
|
77
|
-
top: arrowOffset + arrowSize / 2,
|
|
78
|
-
bottom: arrowOffsetVertical + arrowSize / 2,
|
|
79
|
-
center: 0,
|
|
80
|
-
},
|
|
81
|
-
top: {
|
|
82
|
-
left: arrowOffsetHorizontal + arrowSize / 2,
|
|
83
|
-
center: 0,
|
|
84
|
-
right: arrowOffsetHorizontal + arrowSize / 2,
|
|
85
|
-
},
|
|
86
|
-
bottom: {
|
|
87
|
-
left: arrowOffset + arrowSize / 2,
|
|
88
|
-
center: 0,
|
|
89
|
-
right: arrowOffset + arrowSize / 2,
|
|
90
|
-
},
|
|
91
|
-
}
|
|
92
|
-
: {
|
|
93
|
-
left: {
|
|
94
|
-
top: arrowOffset + arrowSize / 2,
|
|
95
|
-
bottom: arrowOffset + arrowSize / 2,
|
|
96
|
-
center: 0,
|
|
97
|
-
},
|
|
98
|
-
right: {
|
|
99
|
-
top: arrowOffset + arrowSize / 2,
|
|
100
|
-
bottom: arrowOffset + arrowSize / 2,
|
|
101
|
-
center: 0,
|
|
102
|
-
},
|
|
103
|
-
top: {
|
|
104
|
-
left: arrowOffset + arrowSize / 2,
|
|
105
|
-
center: 0,
|
|
106
|
-
right: arrowOffset + arrowSize / 2,
|
|
107
|
-
},
|
|
108
|
-
bottom: {
|
|
109
|
-
left: arrowOffset + arrowSize / 2,
|
|
110
|
-
center: 0,
|
|
111
|
-
right: arrowOffset + arrowSize / 2,
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
document.body.removeChild(cssVariablesElement);
|
|
116
|
-
}, [action, setAnimationTimeout]);
|
|
117
|
-
if (isMobile) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
return (jsx(Layer, { layer: InternalLayerName.Tooltip, children: jsx(DropBase, { ...props, placement: placementsList, visible: visible, activatorRef: activatorRef, arrowGuardDistance: arrowGuardDistance, closeByClickOutside: closeByClickOutside, onClose: onClose, autoFocusWhenOpened: ariaRole !== 'tooltip', guardDistanceToActivator: guardDistanceToActivator, guardDistanceToViewport: 0, allowShrinkHeightToFitIntoViewport: false, animationClassNames: CSS_CLASSES, animationTimeout: animationTimeout, role: ariaRole, "aria-labelledby": title && role !== 'tooltip' ? ariaLabledBy : undefined, "aria-describedby": role !== 'tooltip' ? ariaDescribedBy : undefined, children: () => (jsxs("div", { "data-qa": "tooltip", className: classnames(styles.tooltip, {
|
|
121
|
-
[styles.tooltipWithAction]: action,
|
|
122
|
-
[styles.tooltipWithClose]: !action && showClose,
|
|
123
|
-
}), style: {
|
|
124
|
-
maxWidth: `${maxWidth}px`,
|
|
125
|
-
}, children: [title && (jsx("div", { className: styles.tooltipTitle, children: jsx(BaseText, { id: ariaLabledBy, "data-qa": "tooltip-title", Element: "div", style: "primary", typography: "title-5-semibold", children: title }) })), jsx(Text, { typography: "paragraph-2-regular", id: ariaDescribedBy, children: children }), action && (jsxs("div", { className: styles.tooltipActions, children: [jsx(Button, { "data-qa": "tooltip-action", ...actionProps, style: "contrast", mode: "secondary", size: "small", children: action }), actionClose && (jsx(Button, { "data-qa": "tooltip-close-action", onClick: () => onClose?.(), style: "contrast", mode: "tertiary", size: "small", children: actionClose }))] })), !action && showClose && (jsx("div", { className: styles.tooltipClose, children: jsx(Action, { "data-qa": "tooltip-close-action", "aria-label": ariaLabelClose, icon: CrossOutlinedSize24, mode: "secondary", onClick: () => onClose?.(), style: "contrast" }) })), jsx(TooltipArrow, { className: styles.tooltipArrow })] })) }) }));
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export { TooltipBase };
|
|
129
|
-
//# sourceMappingURL=TooltipBase.js.map
|
package/TooltipBase.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipBase.js","sources":["../src/TooltipBase.tsx"],"sourcesContent":["import { type ReactElement, useEffect, useId, useState, useMemo } from 'react';\nimport classnames from 'classnames';\n\nimport { DropBase, type ArrowGuardDistance, type Placement } from '@hh.ru/magritte-internal-drop-base';\nimport { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';\nimport { Action } from '@hh.ru/magritte-ui-action';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { Button } from '@hh.ru/magritte-ui-button';\nimport { CrossOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { Layer } from '@hh.ru/magritte-ui-layer';\nimport { TooltipArrow } from '@hh.ru/magritte-ui-tooltip/TooltipArrow';\nimport { TooltipBaseProps } from '@hh.ru/magritte-ui-tooltip/types';\nimport { Text } from '@hh.ru/magritte-ui-typography';\nimport { BaseText } from '@hh.ru/magritte-ui-typography/BaseText';\n\nimport styles from './tooltip.less';\n\nconst CSS_CLASSES = {\n enter: styles.tooltipEnter,\n enterActive: styles.tooltipEnterActive,\n exit: styles.tooltipExit,\n exitActive: styles.tooltipExitActive,\n};\n\nconst PLACEMENTS_LIST: Placement[] = [\n 'left-top',\n 'left-center',\n 'left-bottom',\n 'top-left',\n 'top-center',\n 'top-right',\n 'right-bottom',\n 'right-center',\n 'right-top',\n 'bottom-left',\n 'bottom-center',\n 'bottom-right',\n];\n\nexport const TooltipBase = ({\n visible,\n activatorRef,\n onClose,\n maxWidth = 400,\n title,\n action,\n actionClose,\n children,\n showClose,\n actionProps,\n guardDistanceToActivator = 20,\n closeByClickOutside = true,\n placement,\n forcePlacement,\n 'aria-label-close': ariaLabelClose,\n role = 'tooltip',\n ...props\n}: TooltipBaseProps): ReactElement | null => {\n const { isMobile } = useBreakpoint();\n const id = useId();\n const ariaLabledBy = `tooltip-aria-label-${id}`;\n const ariaDescribedBy = `tooltip-aria-description-${id}`;\n const [animationTimeout, setAnimationTimeout] = useState(200);\n const [arrowGuardDistance, setArrowGuardDistance] = useState<ArrowGuardDistance>({\n left: { top: 0, bottom: 0, center: 0 },\n right: { top: 0, bottom: 0, center: 0 },\n top: { left: 0, center: 0, right: 0 },\n bottom: { left: 0, center: 0, right: 0 },\n });\n const placementsList = useMemo(\n () => (forcePlacement ? placement : [placement, ...PLACEMENTS_LIST.filter((place) => place !== placement)]),\n [placement, forcePlacement]\n );\n\n const ariaRole = role === 'tooltip' && action ? 'alertdialog' : role;\n\n useEffect(() => {\n const cssVariablesElement = document.createElement('div');\n cssVariablesElement.classList.add(styles.cssVariablesElement);\n document.body.appendChild(cssVariablesElement);\n const style = window.getComputedStyle(cssVariablesElement);\n\n const animationTimeout = parseInt(style.getPropertyValue(`--animation-duration`), 10);\n if (Number.isInteger(animationTimeout)) {\n setAnimationTimeout(animationTimeout);\n }\n\n const arrowSize = parseInt(style.getPropertyValue('top'), 10);\n const arrowOffset = parseInt(style.getPropertyValue('right'), 10);\n const arrowOffsetVertical = parseInt(style.getPropertyValue('bottom'), 10);\n const arrowOffsetHorizontal = parseInt(style.getPropertyValue('left'), 10);\n if (\n Number.isInteger(arrowSize) &&\n Number.isInteger(arrowOffset) &&\n Number.isInteger(arrowOffsetVertical) &&\n Number.isInteger(arrowOffsetHorizontal)\n ) {\n setArrowGuardDistance(\n action\n ? {\n left: {\n top: arrowOffset + arrowSize / 2,\n bottom: arrowOffsetVertical + arrowSize / 2,\n center: 0,\n },\n right: {\n top: arrowOffset + arrowSize / 2,\n bottom: arrowOffsetVertical + arrowSize / 2,\n center: 0,\n },\n top: {\n left: arrowOffsetHorizontal + arrowSize / 2,\n center: 0,\n right: arrowOffsetHorizontal + arrowSize / 2,\n },\n bottom: {\n left: arrowOffset + arrowSize / 2,\n center: 0,\n right: arrowOffset + arrowSize / 2,\n },\n }\n : {\n left: {\n top: arrowOffset + arrowSize / 2,\n bottom: arrowOffset + arrowSize / 2,\n center: 0,\n },\n right: {\n top: arrowOffset + arrowSize / 2,\n bottom: arrowOffset + arrowSize / 2,\n center: 0,\n },\n top: {\n left: arrowOffset + arrowSize / 2,\n center: 0,\n right: arrowOffset + arrowSize / 2,\n },\n bottom: {\n left: arrowOffset + arrowSize / 2,\n center: 0,\n right: arrowOffset + arrowSize / 2,\n },\n }\n );\n }\n\n document.body.removeChild(cssVariablesElement);\n }, [action, setAnimationTimeout]);\n\n if (isMobile) {\n return null;\n }\n\n return (\n <Layer layer={InternalLayerName.Tooltip}>\n <DropBase\n {...props}\n placement={placementsList}\n visible={visible}\n activatorRef={activatorRef}\n arrowGuardDistance={arrowGuardDistance}\n closeByClickOutside={closeByClickOutside}\n onClose={onClose}\n autoFocusWhenOpened={ariaRole !== 'tooltip'}\n guardDistanceToActivator={guardDistanceToActivator}\n guardDistanceToViewport={0}\n allowShrinkHeightToFitIntoViewport={false}\n animationClassNames={CSS_CLASSES}\n animationTimeout={animationTimeout}\n role={ariaRole}\n aria-labelledby={title && role !== 'tooltip' ? ariaLabledBy : undefined}\n aria-describedby={role !== 'tooltip' ? ariaDescribedBy : undefined}\n >\n {() => (\n <div\n data-qa=\"tooltip\"\n className={classnames(styles.tooltip, {\n [styles.tooltipWithAction]: action,\n [styles.tooltipWithClose]: !action && showClose,\n })}\n style={{\n maxWidth: `${maxWidth}px`,\n }}\n >\n {title && (\n <div className={styles.tooltipTitle}>\n <BaseText\n id={ariaLabledBy}\n data-qa=\"tooltip-title\"\n Element=\"div\"\n style=\"primary\"\n typography=\"title-5-semibold\"\n >\n {title}\n </BaseText>\n </div>\n )}\n <Text typography=\"paragraph-2-regular\" id={ariaDescribedBy}>\n {children}\n </Text>\n {action && (\n <div className={styles.tooltipActions}>\n <Button\n data-qa=\"tooltip-action\"\n {...actionProps}\n style=\"contrast\"\n mode=\"secondary\"\n size=\"small\"\n >\n {action}\n </Button>\n {actionClose && (\n <Button\n data-qa=\"tooltip-close-action\"\n onClick={() => onClose?.()}\n style=\"contrast\"\n mode=\"tertiary\"\n size=\"small\"\n >\n {actionClose}\n </Button>\n )}\n </div>\n )}\n {!action && showClose && (\n <div className={styles.tooltipClose}>\n <Action\n data-qa=\"tooltip-close-action\"\n aria-label={ariaLabelClose}\n icon={CrossOutlinedSize24}\n mode=\"secondary\"\n onClick={() => onClose?.()}\n style=\"contrast\"\n />\n </div>\n )}\n <TooltipArrow className={styles.tooltipArrow} />\n </div>\n )}\n </DropBase>\n </Layer>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,WAAW,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC,YAAY;IAC1B,WAAW,EAAE,MAAM,CAAC,kBAAkB;IACtC,IAAI,EAAE,MAAM,CAAC,WAAW;IACxB,UAA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