@hh.ru/magritte-ui-tooltip 9.3.2 → 9.3.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/Tooltip.js +18 -10
- package/Tooltip.js.map +1 -1
- package/index.css +60 -38
- package/package.json +3 -3
package/Tooltip.js
CHANGED
|
@@ -11,7 +11,7 @@ import { TooltipArrow } from './TooltipArrow.js';
|
|
|
11
11
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
12
12
|
import { BaseText } from '@hh.ru/magritte-ui-typography/BaseText';
|
|
13
13
|
|
|
14
|
-
var styles = {"tooltip":"magritte-tooltip___Hxyh2_9-3-
|
|
14
|
+
var styles = {"medium-tooltip-with-buttons-params":"magritte-medium-tooltip-with-buttons-params___krjlq_9-3-3","mediumTooltipWithButtonsParams":"magritte-medium-tooltip-with-buttons-params___krjlq_9-3-3","medium-tooltip-params":"magritte-medium-tooltip-params___2qZnY_9-3-3","mediumTooltipParams":"magritte-medium-tooltip-params___2qZnY_9-3-3","small-tooltip-params":"magritte-small-tooltip-params___N8y51_9-3-3","smallTooltipParams":"magritte-small-tooltip-params___N8y51_9-3-3","tooltip":"magritte-tooltip___Hxyh2_9-3-3","tooltip-with-buttons":"magritte-tooltip-with-buttons___pQzdt_9-3-3","tooltipWithButtons":"magritte-tooltip-with-buttons___pQzdt_9-3-3","tooltip-with-close":"magritte-tooltip-with-close___2iNPt_9-3-3","tooltipWithClose":"magritte-tooltip-with-close___2iNPt_9-3-3","tooltip-small":"magritte-tooltip-small___W1eTg_9-3-3","tooltipSmall":"magritte-tooltip-small___W1eTg_9-3-3","tooltip-title":"magritte-tooltip-title___s-ekd_9-3-3","tooltipTitle":"magritte-tooltip-title___s-ekd_9-3-3","tooltip-close":"magritte-tooltip-close___B1qWh_9-3-3","tooltipClose":"magritte-tooltip-close___B1qWh_9-3-3","tooltip-enter":"magritte-tooltip-enter___cnped_9-3-3","tooltipEnter":"magritte-tooltip-enter___cnped_9-3-3","css-variables-element":"magritte-css-variables-element___yRnOI_9-3-3","cssVariablesElement":"magritte-css-variables-element___yRnOI_9-3-3","tooltip-enter-active":"magritte-tooltip-enter-active___M8qsm_9-3-3","tooltipEnterActive":"magritte-tooltip-enter-active___M8qsm_9-3-3","tooltip-exit":"magritte-tooltip-exit___IXkNp_9-3-3","tooltipExit":"magritte-tooltip-exit___IXkNp_9-3-3","tooltip-exit-active":"magritte-tooltip-exit-active___QllYr_9-3-3","tooltipExitActive":"magritte-tooltip-exit-active___QllYr_9-3-3","tooltip-buttons":"magritte-tooltip-buttons___kNN5e_9-3-3","tooltipButtons":"magritte-tooltip-buttons___kNN5e_9-3-3","tooltip-arrow":"magritte-tooltip-arrow___7OOYT_9-3-3","tooltipArrow":"magritte-tooltip-arrow___7OOYT_9-3-3"};
|
|
15
15
|
|
|
16
16
|
const CSS_CLASSES = {
|
|
17
17
|
enter: styles.tooltipEnter,
|
|
@@ -56,16 +56,19 @@ const Tooltip = forwardRef(({ visible, activatorRef, onClose = noop, maxWidth =
|
|
|
56
56
|
const tooltipElementRef = useRef(null);
|
|
57
57
|
const ariaRole = role || (buttons ? 'alertdialog' : 'tooltip');
|
|
58
58
|
const isSmall = size === 'small';
|
|
59
|
+
const hasButtons = !!buttons;
|
|
59
60
|
const guardDistanceToActivator = _guardDistanceToActivator ?? (isSmall ? 11 : 20);
|
|
60
61
|
useLayoutEffect(() => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
const parametersContainer = document.createElement('div');
|
|
63
|
+
parametersContainer.style.display = 'none';
|
|
64
|
+
const cssClass = classnames({
|
|
65
|
+
[styles.mediumTooltipWithButtonsParams]: !isSmall && hasButtons,
|
|
66
|
+
[styles.mediumTooltipParams]: !isSmall && !hasButtons,
|
|
67
|
+
[styles.smallTooltipParams]: isSmall,
|
|
68
|
+
});
|
|
69
|
+
parametersContainer.classList.add(cssClass);
|
|
70
|
+
const style = window.getComputedStyle(parametersContainer);
|
|
71
|
+
document.body.appendChild(parametersContainer);
|
|
69
72
|
const borderRadius = parseInt(style.getPropertyValue('--magritte-tooltip-border-radius'), 10);
|
|
70
73
|
const arrowWidth = parseInt(style.getPropertyValue('--magritte-tooltip-arrow-width'), 10);
|
|
71
74
|
if (Number.isInteger(borderRadius) && Number.isInteger(arrowWidth)) {
|
|
@@ -93,7 +96,12 @@ const Tooltip = forwardRef(({ visible, activatorRef, onClose = noop, maxWidth =
|
|
|
93
96
|
},
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
|
-
|
|
99
|
+
const animationTimeout = parseInt(style.getPropertyValue('--animation-duration'), 10);
|
|
100
|
+
if (Number.isInteger(animationTimeout)) {
|
|
101
|
+
setAnimationTimeout(animationTimeout);
|
|
102
|
+
}
|
|
103
|
+
document.body.removeChild(parametersContainer);
|
|
104
|
+
}, [hasButtons, isSmall]);
|
|
97
105
|
if (isMobile) {
|
|
98
106
|
return null;
|
|
99
107
|
}
|
package/Tooltip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 { 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,\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 || (buttons ? 'alertdialog' : 'tooltip');\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=\"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 <CrossOutlinedSize24\n padding={8}\n borderRadius=\"halfHeight\"\n data-qa=\"tooltip-close-action\"\n aria-label={ariaLabelClose}\n initialColor=\"constant-secondary\"\n onClick={() => onClose?.()}\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":";;;;;;;;;;;;;;AAeA,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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KAAA,EAAA,EAAK,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,cAAc,EAAE,uBAAuB,CAAC,EAAA,QAAA,EACrE,OAAO,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,EACzD,CAAA,CACT,EACA,SAAS,IAAI,CAAC,OAAO,KAClBA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,YAAY,EAC/B,QAAA,EAAAA,GAAA,CAAC,mBAAmB,EAChB,EAAA,OAAO,EAAE,CAAC,EACV,YAAY,EAAC,YAAY,EACjB,SAAA,EAAA,sBAAsB,gBAClB,cAAc,EAC1B,YAAY,EAAC,oBAAoB,EACjC,OAAO,EAAE,MAAM,OAAO,IAAI,GAC5B,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;;;;"}
|
|
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 Placement } from '@hh.ru/magritte-internal-drop-base';\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,\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({\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 || (buttons ? 'alertdialog' : 'tooltip');\n const isSmall = size === 'small';\n const hasButtons = !!buttons;\n const guardDistanceToActivator = _guardDistanceToActivator ?? (isSmall ? 11 : 20);\n\n useLayoutEffect(() => {\n const parametersContainer = document.createElement('div');\n parametersContainer.style.display = 'none';\n const cssClass = classnames({\n [styles.mediumTooltipWithButtonsParams]: !isSmall && hasButtons,\n [styles.mediumTooltipParams]: !isSmall && !hasButtons,\n [styles.smallTooltipParams]: isSmall,\n });\n parametersContainer.classList.add(cssClass);\n const style = window.getComputedStyle(parametersContainer);\n document.body.appendChild(parametersContainer);\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 const animationTimeout = parseInt(style.getPropertyValue('--animation-duration'), 10);\n if (Number.isInteger(animationTimeout)) {\n setAnimationTimeout(animationTimeout);\n }\n document.body.removeChild(parametersContainer);\n }, [hasButtons, isSmall]);\n\n if (isMobile) {\n return null;\n }\n\n return (\n <Layer layer=\"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 <CrossOutlinedSize24\n padding={8}\n borderRadius=\"halfHeight\"\n data-qa=\"tooltip-close-action\"\n aria-label={ariaLabelClose}\n initialColor=\"constant-secondary\"\n onClick={() => onClose?.()}\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":";;;;;;;;;;;;;;AAeA,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;AAE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AAC,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/index.css
CHANGED
|
@@ -15,7 +15,28 @@
|
|
|
15
15
|
--magritte-color-component-tooltip-text-content-v21-4-6:#ffffff;
|
|
16
16
|
--magritte-color-component-tooltip-stroke-content-v21-4-6:#3B3B3B;
|
|
17
17
|
}
|
|
18
|
-
.magritte-
|
|
18
|
+
.magritte-medium-tooltip-with-buttons-params___krjlq_9-3-3{
|
|
19
|
+
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v21-4-6);
|
|
20
|
+
--magritte-tooltip-arrow-vertical-gap:calc(var(--magritte-static-border-radius-600-v21-4-6) + 28px / 2 - 12px / 2 - 1px);
|
|
21
|
+
--magritte-tooltip-border-radius:var(--magritte-static-border-radius-600-v21-4-6);
|
|
22
|
+
--magritte-tooltip-arrow-width:28px;
|
|
23
|
+
--magritte-tooltip-arrow-height:12px;
|
|
24
|
+
}
|
|
25
|
+
.magritte-medium-tooltip-params___2qZnY_9-3-3{
|
|
26
|
+
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v21-4-6);
|
|
27
|
+
--magritte-tooltip-arrow-vertical-gap:calc(var(--magritte-static-border-radius-400-v21-4-6) + 28px / 2 - 12px / 2 - 1px);
|
|
28
|
+
--magritte-tooltip-border-radius:var(--magritte-static-border-radius-400-v21-4-6);
|
|
29
|
+
--magritte-tooltip-arrow-width:28px;
|
|
30
|
+
--magritte-tooltip-arrow-height:12px;
|
|
31
|
+
}
|
|
32
|
+
.magritte-small-tooltip-params___N8y51_9-3-3{
|
|
33
|
+
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v21-4-6);
|
|
34
|
+
--magritte-tooltip-arrow-vertical-gap:calc(var(--magritte-static-border-radius-300-v21-4-6) + 18px / 2 - 12px / 2 - 1px);
|
|
35
|
+
--magritte-tooltip-border-radius:var(--magritte-static-border-radius-300-v21-4-6);
|
|
36
|
+
--magritte-tooltip-arrow-width:18px;
|
|
37
|
+
--magritte-tooltip-arrow-height:12px;
|
|
38
|
+
}
|
|
39
|
+
.magritte-tooltip___Hxyh2_9-3-3{
|
|
19
40
|
position:relative;
|
|
20
41
|
padding:16px;
|
|
21
42
|
background:var(--magritte-color-component-tooltip-background-content-v21-4-6);
|
|
@@ -27,126 +48,127 @@
|
|
|
27
48
|
--magritte-ui-text-color-override:var(--magritte-color-component-tooltip-text-content-v21-4-6);
|
|
28
49
|
--magritte-ui-tooltip-arrow-fill:var(--magritte-color-component-tooltip-background-content-v21-4-6);
|
|
29
50
|
--magritte-ui-tooltip-arrow-stroke:var(--magritte-color-component-tooltip-stroke-content-v21-4-6);
|
|
51
|
+
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v21-4-6);
|
|
30
52
|
--magritte-tooltip-arrow-vertical-gap:calc(var(--magritte-static-border-radius-400-v21-4-6) + 28px / 2 - 12px / 2 - 1px);
|
|
31
53
|
--magritte-tooltip-border-radius:var(--magritte-static-border-radius-400-v21-4-6);
|
|
32
54
|
--magritte-tooltip-arrow-width:28px;
|
|
33
55
|
--magritte-tooltip-arrow-height:12px;
|
|
34
56
|
}
|
|
35
|
-
.magritte-tooltip-with-buttons___pQzdt_9-3-
|
|
57
|
+
.magritte-tooltip-with-buttons___pQzdt_9-3-3{
|
|
36
58
|
padding:24px 24px 12px;
|
|
59
|
+
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v21-4-6);
|
|
37
60
|
--magritte-tooltip-arrow-vertical-gap:calc(var(--magritte-static-border-radius-600-v21-4-6) + 28px / 2 - 12px / 2 - 1px);
|
|
38
61
|
--magritte-tooltip-border-radius:var(--magritte-static-border-radius-600-v21-4-6);
|
|
39
62
|
--magritte-tooltip-arrow-width:28px;
|
|
40
63
|
--magritte-tooltip-arrow-height:12px;
|
|
41
64
|
}
|
|
42
|
-
.magritte-tooltip-with-close___2iNPt_9-3-
|
|
65
|
+
.magritte-tooltip-with-close___2iNPt_9-3-3{
|
|
43
66
|
padding-right:56px;
|
|
44
67
|
}
|
|
45
|
-
.magritte-tooltip-small___W1eTg_9-3-
|
|
68
|
+
.magritte-tooltip-small___W1eTg_9-3-3{
|
|
46
69
|
padding:8px 12px;
|
|
47
70
|
min-height:0;
|
|
71
|
+
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v21-4-6);
|
|
48
72
|
--magritte-tooltip-arrow-vertical-gap:calc(var(--magritte-static-border-radius-300-v21-4-6) + 18px / 2 - 12px / 2 - 1px);
|
|
49
73
|
--magritte-tooltip-border-radius:var(--magritte-static-border-radius-300-v21-4-6);
|
|
50
74
|
--magritte-tooltip-arrow-width:18px;
|
|
51
75
|
--magritte-tooltip-arrow-height:12px;
|
|
52
76
|
}
|
|
53
|
-
.magritte-tooltip-title___s-ekd_9-3-
|
|
77
|
+
.magritte-tooltip-title___s-ekd_9-3-3{
|
|
54
78
|
margin-bottom:4px;
|
|
55
79
|
}
|
|
56
|
-
.magritte-tooltip-close___B1qWh_9-3-
|
|
80
|
+
.magritte-tooltip-close___B1qWh_9-3-3{
|
|
57
81
|
position:absolute;
|
|
58
82
|
right:9px;
|
|
59
83
|
top:9px;
|
|
60
84
|
}
|
|
61
|
-
.magritte-tooltip-with-buttons___pQzdt_9-3-
|
|
85
|
+
.magritte-tooltip-with-buttons___pQzdt_9-3-3 .magritte-tooltip-close___B1qWh_9-3-3{
|
|
62
86
|
right:15px;
|
|
63
87
|
top:15px;
|
|
64
88
|
}
|
|
65
89
|
@media (prefers-reduced-motion: no-preference){
|
|
66
|
-
.magritte-tooltip-enter___cnped_9-3-
|
|
90
|
+
.magritte-tooltip-enter___cnped_9-3-3 .magritte-tooltip___Hxyh2_9-3-3{
|
|
67
91
|
opacity:0;
|
|
68
92
|
}
|
|
69
|
-
.magritte-css-variables-element___yRnOI_9-3-
|
|
70
|
-
.magritte-tooltip-enter-active___M8qsm_9-3-
|
|
93
|
+
.magritte-css-variables-element___yRnOI_9-3-3,
|
|
94
|
+
.magritte-tooltip-enter-active___M8qsm_9-3-3 .magritte-tooltip___Hxyh2_9-3-3{
|
|
71
95
|
opacity:1;
|
|
72
96
|
transition-property:opacity, transform;
|
|
73
97
|
transition-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v21-4-6);
|
|
74
98
|
transition-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v21-4-6);
|
|
75
|
-
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v21-4-6);
|
|
76
99
|
}
|
|
77
|
-
.magritte-tooltip-exit___IXkNp_9-3-
|
|
100
|
+
.magritte-tooltip-exit___IXkNp_9-3-3 .magritte-tooltip___Hxyh2_9-3-3{
|
|
78
101
|
opacity:1;
|
|
79
102
|
}
|
|
80
|
-
.magritte-tooltip-exit-active___QllYr_9-3-
|
|
103
|
+
.magritte-tooltip-exit-active___QllYr_9-3-3 .magritte-tooltip___Hxyh2_9-3-3{
|
|
81
104
|
opacity:0;
|
|
82
105
|
transition-property:opacity, transform;
|
|
83
106
|
transition-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v21-4-6);
|
|
84
107
|
transition-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v21-4-6);
|
|
85
|
-
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v21-4-6);
|
|
86
108
|
}
|
|
87
|
-
.magritte-tooltip-exit-active___QllYr_9-3-
|
|
88
|
-
.magritte-tooltip-enter___cnped_9-3-
|
|
109
|
+
.magritte-tooltip-exit-active___QllYr_9-3-3[data-magritte-drop-base-direction='bottom'] .magritte-tooltip___Hxyh2_9-3-3,
|
|
110
|
+
.magritte-tooltip-enter___cnped_9-3-3[data-magritte-drop-base-direction='bottom'] .magritte-tooltip___Hxyh2_9-3-3{
|
|
89
111
|
transform:translateY(4px);
|
|
90
112
|
}
|
|
91
|
-
.magritte-tooltip-exit-active___QllYr_9-3-
|
|
92
|
-
.magritte-tooltip-enter___cnped_9-3-
|
|
113
|
+
.magritte-tooltip-exit-active___QllYr_9-3-3[data-magritte-drop-base-direction='top'] .magritte-tooltip___Hxyh2_9-3-3,
|
|
114
|
+
.magritte-tooltip-enter___cnped_9-3-3[data-magritte-drop-base-direction='top'] .magritte-tooltip___Hxyh2_9-3-3{
|
|
93
115
|
transform:translateY(-4px);
|
|
94
116
|
}
|
|
95
|
-
.magritte-tooltip-exit-active___QllYr_9-3-
|
|
96
|
-
.magritte-tooltip-enter___cnped_9-3-
|
|
117
|
+
.magritte-tooltip-exit-active___QllYr_9-3-3[data-magritte-drop-base-direction='left'] .magritte-tooltip___Hxyh2_9-3-3,
|
|
118
|
+
.magritte-tooltip-enter___cnped_9-3-3[data-magritte-drop-base-direction='left'] .magritte-tooltip___Hxyh2_9-3-3{
|
|
97
119
|
transform:translateX(-4px);
|
|
98
120
|
}
|
|
99
|
-
.magritte-tooltip-exit-active___QllYr_9-3-
|
|
100
|
-
.magritte-tooltip-enter___cnped_9-3-
|
|
121
|
+
.magritte-tooltip-exit-active___QllYr_9-3-3[data-magritte-drop-base-direction='right'] .magritte-tooltip___Hxyh2_9-3-3,
|
|
122
|
+
.magritte-tooltip-enter___cnped_9-3-3[data-magritte-drop-base-direction='right'] .magritte-tooltip___Hxyh2_9-3-3{
|
|
101
123
|
transform:translateX(4px);
|
|
102
124
|
}
|
|
103
|
-
.magritte-tooltip-enter-active___M8qsm_9-3-
|
|
125
|
+
.magritte-tooltip-enter-active___M8qsm_9-3-3[data-magritte-drop-base-direction] .magritte-tooltip___Hxyh2_9-3-3{
|
|
104
126
|
transform:translate(0, 0);
|
|
105
127
|
}
|
|
106
128
|
}
|
|
107
|
-
.magritte-tooltip-buttons___kNN5e_9-3-
|
|
129
|
+
.magritte-tooltip-buttons___kNN5e_9-3-3{
|
|
108
130
|
display:flex;
|
|
109
131
|
gap:12px;
|
|
110
132
|
margin:24px -12px 0;
|
|
111
133
|
}
|
|
112
|
-
.magritte-tooltip-with-close___2iNPt_9-3-
|
|
134
|
+
.magritte-tooltip-with-close___2iNPt_9-3-3 .magritte-tooltip-buttons___kNN5e_9-3-3{
|
|
113
135
|
margin-right:-44px;
|
|
114
136
|
}
|
|
115
|
-
.magritte-tooltip-arrow___7OOYT_9-3-
|
|
137
|
+
.magritte-tooltip-arrow___7OOYT_9-3-3{
|
|
116
138
|
position:absolute;
|
|
117
139
|
}
|
|
118
|
-
[data-magritte-drop-base-direction='bottom'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
140
|
+
[data-magritte-drop-base-direction='bottom'] .magritte-tooltip-arrow___7OOYT_9-3-3{
|
|
119
141
|
top:calc(var(--magritte-tooltip-arrow-height) * -1);
|
|
120
142
|
}
|
|
121
|
-
[data-magritte-drop-base-direction='top'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
143
|
+
[data-magritte-drop-base-direction='top'] .magritte-tooltip-arrow___7OOYT_9-3-3{
|
|
122
144
|
bottom:calc(var(--magritte-tooltip-arrow-height) * -1);
|
|
123
145
|
transform:rotate(180deg);
|
|
124
146
|
}
|
|
125
|
-
[data-magritte-drop-base-alignment='left'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
147
|
+
[data-magritte-drop-base-alignment='left'] .magritte-tooltip-arrow___7OOYT_9-3-3{
|
|
126
148
|
left:var(--magritte-tooltip-border-radius);
|
|
127
149
|
}
|
|
128
|
-
[data-magritte-drop-base-direction='top'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
129
|
-
[data-magritte-drop-base-direction='bottom'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
150
|
+
[data-magritte-drop-base-direction='top'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_9-3-3,
|
|
151
|
+
[data-magritte-drop-base-direction='bottom'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_9-3-3{
|
|
130
152
|
left:calc(50% - var(--magritte-tooltip-arrow-width) / 2);
|
|
131
153
|
}
|
|
132
|
-
[data-magritte-drop-base-alignment='right'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
154
|
+
[data-magritte-drop-base-alignment='right'] .magritte-tooltip-arrow___7OOYT_9-3-3{
|
|
133
155
|
right:var(--magritte-tooltip-border-radius);
|
|
134
156
|
}
|
|
135
|
-
[data-magritte-drop-base-direction='left'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
157
|
+
[data-magritte-drop-base-direction='left'] .magritte-tooltip-arrow___7OOYT_9-3-3{
|
|
136
158
|
right:calc(-1 * (var(--magritte-tooltip-arrow-width) / 2 + var(--magritte-tooltip-arrow-height) / 2));
|
|
137
159
|
transform:rotate(90deg);
|
|
138
160
|
}
|
|
139
|
-
[data-magritte-drop-base-direction='right'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
161
|
+
[data-magritte-drop-base-direction='right'] .magritte-tooltip-arrow___7OOYT_9-3-3{
|
|
140
162
|
left:calc(-1 * (var(--magritte-tooltip-arrow-width) / 2 + var(--magritte-tooltip-arrow-height) / 2));
|
|
141
163
|
transform:rotate(-90deg);
|
|
142
164
|
}
|
|
143
|
-
[data-magritte-drop-base-alignment='top'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
165
|
+
[data-magritte-drop-base-alignment='top'] .magritte-tooltip-arrow___7OOYT_9-3-3{
|
|
144
166
|
top:var(--magritte-tooltip-arrow-vertical-gap);
|
|
145
167
|
}
|
|
146
|
-
[data-magritte-drop-base-direction='left'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
147
|
-
[data-magritte-drop-base-direction='right'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
168
|
+
[data-magritte-drop-base-direction='left'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_9-3-3,
|
|
169
|
+
[data-magritte-drop-base-direction='right'][data-magritte-drop-base-alignment='center'] .magritte-tooltip-arrow___7OOYT_9-3-3{
|
|
148
170
|
top:calc(50% - var(--magritte-tooltip-arrow-height) / 2);
|
|
149
171
|
}
|
|
150
|
-
[data-magritte-drop-base-alignment='bottom'] .magritte-tooltip-arrow___7OOYT_9-3-
|
|
172
|
+
[data-magritte-drop-base-alignment='bottom'] .magritte-tooltip-arrow___7OOYT_9-3-3{
|
|
151
173
|
bottom:var(--magritte-tooltip-arrow-vertical-gap);
|
|
152
174
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-tooltip",
|
|
3
|
-
"version": "9.3.
|
|
3
|
+
"version": "9.3.3",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@hh.ru/magritte-common-use-multiple-refs": "1.1.7",
|
|
23
23
|
"@hh.ru/magritte-design-tokens": "21.4.6",
|
|
24
|
-
"@hh.ru/magritte-internal-drop-base": "7.0.
|
|
24
|
+
"@hh.ru/magritte-internal-drop-base": "7.0.17",
|
|
25
25
|
"@hh.ru/magritte-internal-layer-name": "3.0.2",
|
|
26
26
|
"@hh.ru/magritte-ui-breakpoint": "5.0.2",
|
|
27
27
|
"@hh.ru/magritte-ui-button": "5.3.8",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "669ee43046224945e90495ba7f31c22996a92d4a"
|
|
42
42
|
}
|