@skbkontur/react-ui 3.12.0 → 3.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.12.1](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@3.12.0...@skbkontur/react-ui@3.12.1) (2022-03-01)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **Popup:** correct DOM node extraction ([#2811](https://github.com/skbkontur/retail-ui/issues/2811)) ([#2796](https://github.com/skbkontur/retail-ui/issues/2796)) ([01f951d](https://github.com/skbkontur/retail-ui/commit/01f951d872e2b59a1b049509a9882b24990bbb0e))
12
+
13
+
14
+
15
+
16
+
6
17
  # [3.12.0](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@3.11.0...@skbkontur/react-ui@3.12.0) (2022-02-22)
7
18
 
8
19
 
@@ -270,7 +270,7 @@ class AnchorTooltipExample extends React.Component {
270
270
  return (
271
271
  <>
272
272
  {this.state.anchor ? (
273
- <Tooltip anchorElement={this.state.anchor} render={() => 'Hello React'} trigger="opened" />
273
+ <Tooltip anchorElement={this.state.anchor} render={() => 'Hello React'} trigger="hover" />
274
274
  ) : null}
275
275
  <div style={containerStyle}>
276
276
  {this.state.blocks.map(({ top, left }, i) => (
@@ -285,6 +285,8 @@ Popup = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
285
285
 
286
286
 
287
287
 
288
+
289
+
288
290
 
289
291
 
290
292
 
@@ -499,7 +501,7 @@ Popup = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
499
501
  // or relay on findDOMNode (inside getRootNode)
500
502
  // which should be called with RenderContainer's ref
501
503
  // in the case when the anchor is not refable
502
- return /*#__PURE__*/_react.default.createElement(_RenderContainer.RenderContainer, { anchor: anchorWithRef || anchor, ref: anchorWithRef ? null : this.renderContainerRef }, location && this.renderContent(location));};_proto.updateAnchorElement = function updateAnchorElement(childInstance) {var childDomNode = (0, _rootNode.getRootNode)(childInstance);var anchorElement = this.anchorElement;if (childDomNode !== anchorElement) {this.removeEventListeners(anchorElement);this.anchorElement = childDomNode;this.addEventListeners(childDomNode);this.setRootNode(childDomNode);}};_proto.addEventListeners = function addEventListeners(element) {if (element && (0, _SSRSafe.isHTMLElement)(element)) {element.addEventListener('mouseenter', this.handleMouseEnter);element.addEventListener('mouseleave', this.handleMouseLeave);element.addEventListener('click', this.handleClick);element.addEventListener('focusin', this.handleFocus);element.addEventListener('focusout', this.handleBlur);}};_proto.removeEventListeners = function removeEventListeners(element) {if (element && (0, _SSRSafe.isHTMLElement)(element)) {element.removeEventListener('mouseenter', this.handleMouseEnter);element.removeEventListener('mouseleave', this.handleMouseLeave);element.removeEventListener('click', this.handleClick);element.removeEventListener('focusin', this.handleFocus);element.removeEventListener('focusout', this.handleBlur);}};_proto.renderContent = function renderContent(location) {var _this4 = this;var _this$props2 = this.props,backgroundColor = _this$props2.backgroundColor,disableAnimations = _this$props2.disableAnimations,maxWidth = _this$props2.maxWidth,hasShadow = _this$props2.hasShadow,ignoreHover = _this$props2.ignoreHover,opened = _this$props2.opened,width = _this$props2.width;var children = this.renderChildren();var _PopupHelper$getPosit = _PopupHelper.PopupHelper.getPositionObject(location.position),direction = _PopupHelper$getPosit.direction;var rootStyle = (0, _extends3.default)({}, location.coordinates, { maxWidth: maxWidth });var shouldFallbackShadow = _client.isIE11 || _client.isEdge || _client.isSafari;return /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.Transition, { timeout: TRANSITION_TIMEOUT, appear: !disableAnimations, in: Boolean(opened && children), mountOnEnter: true, unmountOnExit: true, enter: !disableAnimations, exit: !disableAnimations, onExited: this.resetLocation, nodeRef: this.refForTransition }, function (state) {var _extends2, _ref;return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, _this4.props, /*#__PURE__*/_react.default.createElement(_ZIndex.ZIndex, { wrapperRef: _this4.refPopupElement, priority: 'Popup', className: (0, _Emotion.cx)((0, _extends3.default)((_extends2 = {}, _extends2[_Popup.styles.popup(_this4.theme)] = true, _extends2[_Popup.styles.shadow(_this4.theme)] = hasShadow && !shouldFallbackShadow, _extends2[_Popup.styles.shadowFallback(_this4.theme)] = hasShadow && shouldFallbackShadow, _extends2[_Popup.styles.popupIgnoreHover()] = ignoreHover, _extends2), disableAnimations ? {} : (_ref = {}, _ref[_Popup.styles["transition-enter-" + direction](_this4.theme)] = true, _ref[_Popup.styles.transitionEnter()] = state === 'entering', _ref[_Popup.styles.transitionEnterActive()] = state === 'entered', _ref[_Popup.styles.transitionExit()] = state === 'exiting', _ref))), style: rootStyle, onMouseEnter: _this4.handleMouseEnter, onMouseLeave: _this4.handleMouseLeave }, /*#__PURE__*/_react.default.createElement("div", { className: _Popup.styles.content(_this4.theme), "data-tid": 'PopupContent', ref: _this4.refForTransition }, /*#__PURE__*/_react.default.createElement("div", { className: _Popup.styles.contentInner(_this4.theme), style: { backgroundColor: backgroundColor, width: _this4.calculateWidth(width) }, "data-tid": 'PopupContentInner' }, children)), _this4.renderPin(location.position)));});};_proto.renderChildren = function renderChildren() {return (0, _utils.isFunction)(this.props.children) ? this.props.children() : this.props.children;};_proto.renderPin = function renderPin(positionName) {/**
504
+ var canGetAnchorNode = !!anchorWithRef || (0, _SSRSafe.isHTMLElement)(anchorElement);return /*#__PURE__*/_react.default.createElement(_RenderContainer.RenderContainer, { anchor: anchorWithRef || anchor, ref: canGetAnchorNode ? null : this.renderContainerRef }, location && this.renderContent(location));};_proto.updateAnchorElement = function updateAnchorElement(childInstance) {var childDomNode = (0, _rootNode.getRootNode)(childInstance);var anchorElement = this.anchorElement;if (childDomNode !== anchorElement) {this.removeEventListeners(anchorElement);this.anchorElement = childDomNode;this.addEventListeners(childDomNode);this.setRootNode(childDomNode);}};_proto.addEventListeners = function addEventListeners(element) {if (element && (0, _SSRSafe.isHTMLElement)(element)) {element.addEventListener('mouseenter', this.handleMouseEnter);element.addEventListener('mouseleave', this.handleMouseLeave);element.addEventListener('click', this.handleClick);element.addEventListener('focusin', this.handleFocus);element.addEventListener('focusout', this.handleBlur);}};_proto.removeEventListeners = function removeEventListeners(element) {if (element && (0, _SSRSafe.isHTMLElement)(element)) {element.removeEventListener('mouseenter', this.handleMouseEnter);element.removeEventListener('mouseleave', this.handleMouseLeave);element.removeEventListener('click', this.handleClick);element.removeEventListener('focusin', this.handleFocus);element.removeEventListener('focusout', this.handleBlur);}};_proto.renderContent = function renderContent(location) {var _this4 = this;var _this$props2 = this.props,backgroundColor = _this$props2.backgroundColor,disableAnimations = _this$props2.disableAnimations,maxWidth = _this$props2.maxWidth,hasShadow = _this$props2.hasShadow,ignoreHover = _this$props2.ignoreHover,opened = _this$props2.opened,width = _this$props2.width;var children = this.renderChildren();var _PopupHelper$getPosit = _PopupHelper.PopupHelper.getPositionObject(location.position),direction = _PopupHelper$getPosit.direction;var rootStyle = (0, _extends3.default)({}, location.coordinates, { maxWidth: maxWidth });var shouldFallbackShadow = _client.isIE11 || _client.isEdge || _client.isSafari;return /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.Transition, { timeout: TRANSITION_TIMEOUT, appear: !disableAnimations, in: Boolean(opened && children), mountOnEnter: true, unmountOnExit: true, enter: !disableAnimations, exit: !disableAnimations, onExited: this.resetLocation, nodeRef: this.refForTransition }, function (state) {var _extends2, _ref;return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, _this4.props, /*#__PURE__*/_react.default.createElement(_ZIndex.ZIndex, { wrapperRef: _this4.refPopupElement, priority: 'Popup', className: (0, _Emotion.cx)((0, _extends3.default)((_extends2 = {}, _extends2[_Popup.styles.popup(_this4.theme)] = true, _extends2[_Popup.styles.shadow(_this4.theme)] = hasShadow && !shouldFallbackShadow, _extends2[_Popup.styles.shadowFallback(_this4.theme)] = hasShadow && shouldFallbackShadow, _extends2[_Popup.styles.popupIgnoreHover()] = ignoreHover, _extends2), disableAnimations ? {} : (_ref = {}, _ref[_Popup.styles["transition-enter-" + direction](_this4.theme)] = true, _ref[_Popup.styles.transitionEnter()] = state === 'entering', _ref[_Popup.styles.transitionEnterActive()] = state === 'entered', _ref[_Popup.styles.transitionExit()] = state === 'exiting', _ref))), style: rootStyle, onMouseEnter: _this4.handleMouseEnter, onMouseLeave: _this4.handleMouseLeave }, /*#__PURE__*/_react.default.createElement("div", { className: _Popup.styles.content(_this4.theme), "data-tid": 'PopupContent', ref: _this4.refForTransition }, /*#__PURE__*/_react.default.createElement("div", { className: _Popup.styles.contentInner(_this4.theme), style: { backgroundColor: backgroundColor, width: _this4.calculateWidth(width) }, "data-tid": 'PopupContentInner' }, children)), _this4.renderPin(location.position)));});};_proto.renderChildren = function renderChildren() {return (0, _utils.isFunction)(this.props.children) ? this.props.children() : this.props.children;};_proto.renderPin = function renderPin(positionName) {/**
503
505
  * Box-shadow does not appear under the pin. Borders are used instead.
504
506
  * In non-ie browsers drop-shadow filter is used. It is applying
505
507
  * shadow to the pin too.
@@ -1 +1 @@
1
- {"version":3,"sources":["Popup.tsx"],"names":["POPUP_BORDER_DEFAULT_COLOR","TRANSITION_TIMEOUT","enter","exit","PopupPositions","DefaultPosition","DUMMY_LOCATION","position","coordinates","top","left","Popup","rootNode","state","location","props","opened","theme","layoutEventsToken","locationUpdateId","lastPopupElement","anchorElement","setRootNode","refForTransition","React","createRef","renderContainerRef","childInstance","updateAnchorElement","handleMouseEnter","event","onMouseEnter","handleMouseLeave","onMouseLeave","handleClick","onClick","handleFocus","onFocus","handleBlur","onBlur","calculateWidth","width","includes","offsetWidth","parseFloat","resetLocation","cancelDelayedUpdateLocation","setState","refPopupElement","element","handleLayoutEvent","updateLocation","popupElement","getLocation","locationEquals","componentDidMount","LayoutEvents","addListener","getDerivedStateFromProps","componentDidUpdate","prevProps","prevState","hadNoLocation","hasLocation","wasClosed","onOpen","onClose","delayUpdateLocation","componentWillUnmount","removeEventListeners","remove","render","renderMain","useWrapper","anchor","isValidElement","anchorWithRef","cloneElement","ref","instance","originalRef","renderContent","childDomNode","addEventListeners","addEventListener","removeEventListener","backgroundColor","disableAnimations","maxWidth","hasShadow","ignoreHover","children","renderChildren","PopupHelper","getPositionObject","direction","rootStyle","shouldFallbackShadow","isIE11","isEdge","isSafari","Boolean","styles","popup","shadow","shadowFallback","popupIgnoreHover","transitionEnter","transitionEnterActive","transitionExit","content","contentInner","renderPin","positionName","isDefaultBorderColor","popupBorderColor","pinBorder","pinSize","borderColor","hasPin","parseInt","popupPinSize","getPinOffset","align","popupBackground","raf","cancel","x","y","Math","abs","positions","tryPreserveFirstRenderedPosition","anchorRect","getElementAbsoluteRect","popupRect","getCoordinates","isFullyVisible","canBecomeVisible","canBecomeFullyVisible","getPinnedPopupOffset","test","anchorSize","height","max","marginFromProps","margin","isNaN","popupMargin","popupOffset","getHorizontalPosition","getVerticalPosition","Error","pinOffset","popupPinOffset","popupPinOffsetY","popupPinOffsetX","Component","__KONTUR_REACT_UI__","propTypes","PropTypes","oneOfType","HTMLElement","node","isRequired","string","func","bool","number","array","defaultProps","isTestEnv"],"mappings":"6cAAA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uC;;AAEA,IAAMA,0BAA0B,GAAG,aAAnC;AACA,IAAMC,kBAAkB,GAAG,EAAEC,KAAK,EAAE,CAAT,EAAYC,IAAI,EAAE,GAAlB,EAA3B;;AAEO,IAAMC,cAAc,GAAG;AAC5B,UAD4B;AAE5B,YAF4B;AAG5B,WAH4B;AAI5B,WAJ4B;AAK5B,cAL4B;AAM5B,cAN4B;AAO5B,cAP4B;AAQ5B,eAR4B;AAS5B,aAT4B;AAU5B,aAV4B;AAW5B,aAX4B;AAY5B,UAZ4B,CAAvB,C;;AAcA,IAAMC,eAAe,GAAGD,cAAc,CAAC,C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AACA,KACIxJ,MAAM,EAAEgJ,mBAAUO,IA/BM,EAiCxB;AACJ;AACA,KACId,SAAS,EAAEO,mBAAUQ,MApCG,EAsCxB;AACJ;AACA;AACA;AACA,KACInD,OAAO,EAAE2C,mBAAUQ,MA3CK,EA6CxB;AACJ;AACA,KACInB,WAAW,EAAEW,mBAAUQ,MAhDC,EAkDxB;AACJ;AACA;AACA,KACIrC,SAAS,EAAE6B,mBAAUS,KAtDG,EAwDxB;AACJ;AACA,KACI/E,WAAW,EAAEsE,mBAAUO,IA3DC,E,UA8DZG,Y,GAAe,EAC3BrB,WAAW,EAAE,CADc,EAE3B9B,MAAM,EAAE,KAFmB,EAG3B9B,SAAS,EAAE,KAHgB,EAI3BF,iBAAiB,EAAEoF,6BAJQ,EAK3BlG,UAAU,EAAE,KALe,EAM3BiB,WAAW,EAAE,KANc,EAO3BjD,KAAK,EAAE,MAPoB,E","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Transition } from 'react-transition-group';\nimport raf from 'raf';\nimport warning from 'warning';\n\nimport { Nullable } from '../../typings/utility-types';\nimport * as LayoutEvents from '../../lib/LayoutEvents';\nimport { ZIndex } from '../ZIndex';\nimport { RenderContainer } from '../RenderContainer';\nimport { FocusEventType, MouseEventType } from '../../typings/event-types';\nimport { isFunction, isNonNullable, isRefableElement } from '../../lib/utils';\nimport { isIE11, isEdge, isSafari } from '../../lib/client';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { isHTMLElement, safePropTypesInstanceOf } from '../../lib/SSRSafe';\nimport { isTestEnv } from '../../lib/currentEnvironment';\nimport { CommonProps, CommonWrapper } from '../CommonWrapper';\nimport { cx } from '../../lib/theming/Emotion';\nimport { getRootNode, rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { callChildRef } from '../../lib/callChildRef/callChildRef';\n\nimport { PopupPin } from './PopupPin';\nimport { Offset, PopupHelper, PositionObject, Rect } from './PopupHelper';\nimport { styles } from './Popup.styles';\n\nconst POPUP_BORDER_DEFAULT_COLOR = 'transparent';\nconst TRANSITION_TIMEOUT = { enter: 0, exit: 200 };\n\nexport const PopupPositions = [\n 'top left',\n 'top center',\n 'top right',\n 'right top',\n 'right middle',\n 'right bottom',\n 'bottom right',\n 'bottom center',\n 'bottom left',\n 'left bottom',\n 'left middle',\n 'left top',\n] as const;\nexport const DefaultPosition = PopupPositions[0];\n\nexport type PopupPositionsType = typeof PopupPositions[number];\n\nconst DUMMY_LOCATION: PopupLocation = {\n position: DefaultPosition,\n coordinates: {\n top: -9999,\n left: -9999,\n },\n};\n\nexport interface PopupHandlerProps {\n onMouseEnter?: (event: MouseEventType) => void;\n onMouseLeave?: (event: MouseEventType) => void;\n onClick?: (event: MouseEventType) => void;\n onFocus?: (event: FocusEventType) => void;\n onBlur?: (event: FocusEventType) => void;\n onOpen?: () => void;\n onClose?: () => void;\n}\n\nexport interface PopupProps extends CommonProps, PopupHandlerProps {\n anchorElement: React.ReactNode | HTMLElement;\n backgroundColor?: React.CSSProperties['backgroundColor'];\n borderColor?: React.CSSProperties['borderColor'];\n children: React.ReactNode | (() => React.ReactNode);\n hasPin: boolean;\n hasShadow: boolean;\n disableAnimations: boolean;\n margin?: number;\n maxWidth?: number | string;\n opened: boolean;\n pinOffset?: number;\n pinSize?: number;\n popupOffset: number;\n positions: Readonly<PopupPositionsType[]>;\n /**\n * Явно указывает, что вложенные элементы должны быть обёрнуты в `<span/>`. <br/> Используется для корректного позиционирования тултипа при двух и более вложенных элементах.\n *\n * _Примечание_: при **двух и более** вложенных элементах обёртка будет добавлена автоматически.\n */\n useWrapper: boolean;\n ignoreHover: boolean;\n width: React.CSSProperties['width'];\n /**\n * При очередном рендере пытаться сохранить первоначальную позицию попапа\n * (в числе числе, когда он выходит за пределы экрана, но может быть проскролен в него).\n *\n * Нужен только для Tooltip. В остальных случаях позиция перестраивается автоматически.\n * @see https://github.com/skbkontur/retail-ui/pull/1195\n */\n tryPreserveFirstRenderedPosition?: boolean;\n}\n\ninterface PopupLocation {\n coordinates: {\n left: number;\n top: number;\n };\n position: PopupPositionsType;\n}\n\nexport interface PopupState {\n location: Nullable<PopupLocation>;\n}\n\n@rootNode\nexport class Popup extends React.Component<PopupProps, PopupState> {\n public static __KONTUR_REACT_UI__ = 'Popup';\n\n public static propTypes = {\n /**\n * Ссылка (ref) на элемент или React компонент, для которого рисуется попап\n */\n anchorElement: PropTypes.oneOfType([safePropTypesInstanceOf(() => HTMLElement), PropTypes.node]).isRequired,\n\n /**\n * Фон попапа и пина\n */\n backgroundColor: PropTypes.string,\n\n children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),\n\n /**\n * Показывать ли пин\n */\n hasPin: PropTypes.bool,\n\n /**\n * Применять ли box-shadow на попапе. При false отключает границу на пине\n */\n hasShadow: PropTypes.bool,\n\n /**\n * Отступ попапа от элемента\n */\n margin: PropTypes.number,\n\n /**\n * Показан или скрыт попап\n */\n opened: PropTypes.bool,\n\n /**\n * Смещение пина от края попапа. Край задаётся в пропе position вторым словом\n */\n pinOffset: PropTypes.number,\n\n /**\n * Сторона пина без учёта границы.\n * Пин представляет собой равносторонний треугольник, высота от попапа\n * до \"носика\" пина будет соответствовать формуле (size* √3)/2\n */\n pinSize: PropTypes.number,\n\n /**\n * смещение попапа относительно родительского элемента\n */\n popupOffset: PropTypes.number,\n\n /**\n * С какой стороны показывать попап и край попапа,\n * на котором будет отображаться пин\n */\n positions: PropTypes.array,\n\n /**\n * Игнорировать ли события hover/click\n */\n ignoreHover: PropTypes.bool,\n };\n\n public static defaultProps = {\n popupOffset: 0,\n hasPin: false,\n hasShadow: false,\n disableAnimations: isTestEnv,\n useWrapper: false,\n ignoreHover: false,\n width: 'auto',\n };\n\n public state: PopupState = { location: this.props.opened ? DUMMY_LOCATION : null };\n private theme!: Theme;\n private layoutEventsToken: Nullable<ReturnType<typeof LayoutEvents.addListener>>;\n private locationUpdateId: Nullable<number> = null;\n private lastPopupElement: Nullable<HTMLElement>;\n private anchorElement: Nullable<HTMLElement> = null;\n private setRootNode!: TSetRootNode;\n private refForTransition = React.createRef<HTMLDivElement>();\n\n public componentDidMount() {\n this.updateLocation();\n this.layoutEventsToken = LayoutEvents.addListener(this.handleLayoutEvent);\n }\n\n public static getDerivedStateFromProps(props: Readonly<PopupProps>, state: PopupState) {\n /**\n * Delaying updateLocation to ensure it happens after props update\n */\n if (props.opened) {\n if (!state.location) {\n return { location: DUMMY_LOCATION };\n }\n } else if (state.location) {\n return { location: DUMMY_LOCATION };\n }\n return state;\n }\n\n public componentDidUpdate(prevProps: PopupProps, prevState: PopupState) {\n const hadNoLocation = prevState.location === DUMMY_LOCATION;\n const hasLocation = this.state.location !== DUMMY_LOCATION;\n const wasClosed = prevProps.opened && !this.props.opened;\n\n if (hadNoLocation && hasLocation && this.props.onOpen) {\n this.props.onOpen();\n }\n if (wasClosed && !hasLocation && this.props.onClose) {\n this.props.onClose();\n }\n if (this.props.opened) {\n this.delayUpdateLocation();\n }\n }\n\n public componentWillUnmount() {\n this.cancelDelayedUpdateLocation();\n this.removeEventListeners(this.anchorElement);\n if (this.layoutEventsToken) {\n this.layoutEventsToken.remove();\n this.layoutEventsToken = null;\n }\n if (this.state.location && this.props.onClose) {\n this.props.onClose();\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderMain() {\n const { location } = this.state;\n const { anchorElement, useWrapper } = this.props;\n\n let anchor: Nullable<React.ReactNode> = null;\n if (isHTMLElement(anchorElement)) {\n this.updateAnchorElement(anchorElement);\n } else if (React.isValidElement(anchorElement)) {\n anchor = useWrapper ? <span>{anchorElement}</span> : anchorElement;\n } else {\n anchor = <span>{anchorElement}</span>;\n }\n\n const anchorWithRef =\n anchor && React.isValidElement(anchor) && isRefableElement(anchor)\n ? React.cloneElement(anchor, {\n ref: (instance: Nullable<React.ReactInstance>) => {\n this.updateAnchorElement(instance);\n const originalRef = (anchor as React.RefAttributes<any>)?.ref;\n originalRef && callChildRef(originalRef, instance);\n },\n })\n : null;\n\n // we need to get anchor's DOM node\n // so we either set our own ref on it via cloning\n // or relay on findDOMNode (inside getRootNode)\n // which should be called with RenderContainer's ref\n // in the case when the anchor is not refable\n\n return (\n <RenderContainer anchor={anchorWithRef || anchor} ref={anchorWithRef ? null : this.renderContainerRef}>\n {location && this.renderContent(location)}\n </RenderContainer>\n );\n }\n\n private renderContainerRef = (childInstance: Nullable<React.ReactInstance>) => {\n this.updateAnchorElement(childInstance);\n };\n\n private updateAnchorElement(childInstance: Nullable<React.ReactInstance>) {\n const childDomNode = getRootNode(childInstance);\n const anchorElement = this.anchorElement;\n\n if (childDomNode !== anchorElement) {\n this.removeEventListeners(anchorElement);\n this.anchorElement = childDomNode;\n this.addEventListeners(childDomNode);\n this.setRootNode(childDomNode);\n }\n }\n\n private addEventListeners(element: Nullable<HTMLElement>) {\n if (element && isHTMLElement(element)) {\n element.addEventListener('mouseenter', this.handleMouseEnter);\n element.addEventListener('mouseleave', this.handleMouseLeave);\n element.addEventListener('click', this.handleClick);\n element.addEventListener('focusin', this.handleFocus as EventListener);\n element.addEventListener('focusout', this.handleBlur as EventListener);\n }\n }\n\n private removeEventListeners(element: Nullable<HTMLElement>) {\n if (element && isHTMLElement(element)) {\n element.removeEventListener('mouseenter', this.handleMouseEnter);\n element.removeEventListener('mouseleave', this.handleMouseLeave);\n element.removeEventListener('click', this.handleClick);\n element.removeEventListener('focusin', this.handleFocus as EventListener);\n element.removeEventListener('focusout', this.handleBlur as EventListener);\n }\n }\n\n private handleMouseEnter = (event: MouseEventType) => {\n if (this.props.onMouseEnter) {\n this.props.onMouseEnter(event);\n }\n };\n\n private handleMouseLeave = (event: MouseEventType) => {\n if (this.props.onMouseLeave) {\n this.props.onMouseLeave(event);\n }\n };\n\n private handleClick = (event: MouseEventType) => {\n if (this.props.onClick) {\n this.props.onClick(event);\n }\n };\n\n private handleFocus = (event: FocusEventType) => {\n if (this.props.onFocus) {\n this.props.onFocus(event);\n }\n };\n\n private handleBlur = (event: FocusEventType) => {\n if (this.props.onBlur) {\n this.props.onBlur(event);\n }\n };\n\n private calculateWidth = (width: PopupProps['width']) => {\n if (typeof width === 'string' && width.includes('%')) {\n return this.anchorElement ? (this.anchorElement.offsetWidth * parseFloat(width)) / 100 : 0;\n }\n return width;\n };\n\n private renderContent(location: PopupLocation) {\n const { backgroundColor, disableAnimations, maxWidth, hasShadow, ignoreHover, opened, width } = this.props;\n const children = this.renderChildren();\n\n const { direction } = PopupHelper.getPositionObject(location.position);\n const rootStyle: React.CSSProperties = { ...location.coordinates, maxWidth };\n\n const shouldFallbackShadow = isIE11 || isEdge || isSafari;\n\n return (\n <Transition\n timeout={TRANSITION_TIMEOUT}\n appear={!disableAnimations}\n in={Boolean(opened && children)}\n mountOnEnter\n unmountOnExit\n enter={!disableAnimations}\n exit={!disableAnimations}\n onExited={this.resetLocation}\n nodeRef={this.refForTransition}\n >\n {(state: string) => (\n <CommonWrapper {...this.props}>\n <ZIndex\n wrapperRef={this.refPopupElement}\n priority={'Popup'}\n className={cx({\n [styles.popup(this.theme)]: true,\n [styles.shadow(this.theme)]: hasShadow && !shouldFallbackShadow,\n [styles.shadowFallback(this.theme)]: hasShadow && shouldFallbackShadow,\n [styles.popupIgnoreHover()]: ignoreHover,\n ...(disableAnimations\n ? {}\n : {\n [styles[`transition-enter-${direction}` as keyof typeof styles](this.theme)]: true,\n [styles.transitionEnter()]: state === 'entering',\n [styles.transitionEnterActive()]: state === 'entered',\n [styles.transitionExit()]: state === 'exiting',\n }),\n })}\n style={rootStyle}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n >\n <div className={styles.content(this.theme)} data-tid={'PopupContent'} ref={this.refForTransition}>\n <div\n className={styles.contentInner(this.theme)}\n style={{ backgroundColor, width: this.calculateWidth(width) }}\n data-tid={'PopupContentInner'}\n >\n {children}\n </div>\n </div>\n {this.renderPin(location.position)}\n </ZIndex>\n </CommonWrapper>\n )}\n </Transition>\n );\n }\n\n private resetLocation = () => {\n this.cancelDelayedUpdateLocation();\n this.state.location !== null && this.setState({ location: null });\n };\n\n private renderChildren() {\n return isFunction(this.props.children) ? this.props.children() : this.props.children;\n }\n\n private refPopupElement = (element: Nullable<HTMLElement>) => {\n this.lastPopupElement = element;\n };\n\n private renderPin(positionName: string): React.ReactNode {\n /**\n * Box-shadow does not appear under the pin. Borders are used instead.\n * In non-ie browsers drop-shadow filter is used. It is applying\n * shadow to the pin too.\n */\n const isDefaultBorderColor = this.theme.popupBorderColor === POPUP_BORDER_DEFAULT_COLOR;\n const pinBorder = isIE11 && isDefaultBorderColor ? 'rgba(0, 0, 0, 0.09)' : this.theme.popupBorderColor;\n\n const { pinSize, hasShadow, backgroundColor, borderColor } = this.props;\n const position = PopupHelper.getPositionObject(positionName);\n\n return (\n this.props.hasPin && (\n <PopupPin\n popupElement={this.lastPopupElement}\n popupPosition={positionName}\n size={pinSize || parseInt(this.theme.popupPinSize)}\n offset={this.getPinOffset(position.align)}\n borderWidth={hasShadow ? 1 : 0}\n backgroundColor={backgroundColor || this.theme.popupBackground}\n borderColor={borderColor || pinBorder}\n />\n )\n );\n }\n\n private handleLayoutEvent = () => {\n if (!this.state.location) {\n return;\n }\n this.updateLocation();\n };\n\n private delayUpdateLocation() {\n this.cancelDelayedUpdateLocation();\n this.locationUpdateId = raf(this.updateLocation);\n }\n\n private cancelDelayedUpdateLocation() {\n if (this.locationUpdateId) {\n raf.cancel(this.locationUpdateId);\n this.locationUpdateId = null;\n }\n }\n\n private updateLocation = () => {\n const popupElement = this.lastPopupElement;\n\n if (!popupElement) {\n return;\n }\n\n const location = this.getLocation(popupElement, this.state.location);\n if (!this.locationEquals(this.state.location, location)) {\n this.setState({ location });\n }\n };\n\n private locationEquals(x: Nullable<PopupLocation>, y: Nullable<PopupLocation>) {\n if (x === y) {\n return true;\n }\n\n if (x == null || y == null) {\n return false;\n }\n\n if (!isIE11 && !isEdge) {\n return (\n x.coordinates.left === y.coordinates.left &&\n x.coordinates.top === y.coordinates.top &&\n x.position === y.position\n );\n }\n\n // Для ie/edge обновляем позицию только при разнице минимум в 1. Иначе есть вероятность\n // уйти в бесконечный ререндер\n\n return (\n x.position === y.position &&\n Math.abs(x.coordinates.top - y.coordinates.top) <= 1 &&\n Math.abs(x.coordinates.left - y.coordinates.left) <= 1\n );\n }\n\n private getLocation(popupElement: HTMLElement, location?: Nullable<PopupLocation>) {\n const { positions, tryPreserveFirstRenderedPosition } = this.props;\n const anchorElement = this.anchorElement;\n\n warning(\n anchorElement && isHTMLElement(anchorElement),\n 'Anchor element is not defined or not instance of HTMLElement',\n );\n\n if (!(anchorElement && isHTMLElement(anchorElement))) {\n return location;\n }\n\n const anchorRect = PopupHelper.getElementAbsoluteRect(anchorElement);\n const popupRect = PopupHelper.getElementAbsoluteRect(popupElement);\n\n let position: PopupPositionsType;\n let coordinates: Offset;\n\n if (location && location !== DUMMY_LOCATION && location.position) {\n position = location.position;\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n\n const isFullyVisible = PopupHelper.isFullyVisible(coordinates, popupRect);\n const canBecomeVisible = !isFullyVisible && PopupHelper.canBecomeFullyVisible(position, coordinates);\n\n if (\n // если нужно сохранить первоначальную позицию и Попап целиком\n // находится в пределах вьюпорта (или может быть проскроллен в него)\n (tryPreserveFirstRenderedPosition && (isFullyVisible || canBecomeVisible)) ||\n // если Попап целиком во вьюпорте и в самой приоритетной позиции\n // (иначе нужно попытаться позицию сменить)\n (isFullyVisible && position === positions[0])\n ) {\n // сохраняем текущую позицию\n return { coordinates, position };\n }\n }\n\n for (position of positions) {\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n if (PopupHelper.isFullyVisible(coordinates, popupRect)) {\n return { coordinates, position };\n }\n }\n\n position = positions[0];\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n return { coordinates, position };\n }\n\n private getPinnedPopupOffset(anchorRect: Rect, position: PositionObject) {\n if (!this.props.hasPin || /center|middle/.test(position.align)) {\n return 0;\n }\n\n const anchorSize = /top|bottom/.test(position.direction) ? anchorRect.width : anchorRect.height;\n\n const { pinSize } = this.props;\n\n return Math.max(\n 0,\n this.getPinOffset(position.align) + (pinSize || parseInt(this.theme.popupPinSize)) - anchorSize / 2,\n );\n }\n\n private getCoordinates(anchorRect: Rect, popupRect: Rect, positionName: string) {\n const { margin: marginFromProps } = this.props;\n const margin =\n isNonNullable(marginFromProps) && !isNaN(marginFromProps)\n ? marginFromProps\n : parseInt(this.theme.popupMargin) || 0;\n const position = PopupHelper.getPositionObject(positionName);\n const popupOffset = this.props.popupOffset + this.getPinnedPopupOffset(anchorRect, position);\n\n switch (position.direction) {\n case 'top':\n return {\n top: anchorRect.top - popupRect.height - margin,\n left: this.getHorizontalPosition(anchorRect, popupRect, position.align, popupOffset),\n };\n case 'bottom':\n return {\n top: anchorRect.top + anchorRect.height + margin,\n left: this.getHorizontalPosition(anchorRect, popupRect, position.align, popupOffset),\n };\n case 'left':\n return {\n top: this.getVerticalPosition(anchorRect, popupRect, position.align, popupOffset),\n left: anchorRect.left - popupRect.width - margin,\n };\n case 'right':\n return {\n top: this.getVerticalPosition(anchorRect, popupRect, position.align, popupOffset),\n left: anchorRect.left + anchorRect.width + margin,\n };\n default:\n throw new Error(`Unexpected direction '${position.direction}'`);\n }\n }\n\n private getPinOffset(align: string) {\n const { pinOffset } = this.props;\n\n switch (align) {\n case 'top':\n case 'bottom':\n return pinOffset || parseInt(this.theme.popupPinOffset) || parseInt(this.theme.popupPinOffsetY);\n case 'left':\n case 'right':\n return pinOffset || parseInt(this.theme.popupPinOffset) || parseInt(this.theme.popupPinOffsetX);\n case 'center':\n case 'middle':\n return 0;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n\n private getHorizontalPosition(anchorRect: Rect, popupRect: Rect, align: string, popupOffset: number) {\n switch (align) {\n case 'left':\n return anchorRect.left - popupOffset;\n case 'center':\n return anchorRect.left - (popupRect.width - anchorRect.width) / 2;\n case 'right':\n return anchorRect.left - (popupRect.width - anchorRect.width) + popupOffset;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n\n private getVerticalPosition(anchorRect: Rect, popupRect: Rect, align: string, popupOffset: number) {\n switch (align) {\n case 'top':\n return anchorRect.top - popupOffset;\n case 'middle':\n return anchorRect.top - (popupRect.height - anchorRect.height) / 2;\n case 'bottom':\n return anchorRect.top - (popupRect.height - anchorRect.height) + popupOffset;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["Popup.tsx"],"names":["POPUP_BORDER_DEFAULT_COLOR","TRANSITION_TIMEOUT","enter","exit","PopupPositions","DefaultPosition","DUMMY_LOCATION","position","coordinates","top","left","Popup","rootNode","state","location","props","opened","theme","layoutEventsToken","locationUpdateId","lastPopupElement","anchorElement","setRootNode","refForTransition","React","createRef","renderContainerRef","childInstance","updateAnchorElement","handleMouseEnter","event","onMouseEnter","handleMouseLeave","onMouseLeave","handleClick","onClick","handleFocus","onFocus","handleBlur","onBlur","calculateWidth","width","includes","offsetWidth","parseFloat","resetLocation","cancelDelayedUpdateLocation","setState","refPopupElement","element","handleLayoutEvent","updateLocation","popupElement","getLocation","locationEquals","componentDidMount","LayoutEvents","addListener","getDerivedStateFromProps","componentDidUpdate","prevProps","prevState","hadNoLocation","hasLocation","wasClosed","onOpen","onClose","delayUpdateLocation","componentWillUnmount","removeEventListeners","remove","render","renderMain","useWrapper","anchor","isValidElement","anchorWithRef","cloneElement","ref","instance","originalRef","canGetAnchorNode","renderContent","childDomNode","addEventListeners","addEventListener","removeEventListener","backgroundColor","disableAnimations","maxWidth","hasShadow","ignoreHover","children","renderChildren","PopupHelper","getPositionObject","direction","rootStyle","shouldFallbackShadow","isIE11","isEdge","isSafari","Boolean","styles","popup","shadow","shadowFallback","popupIgnoreHover","transitionEnter","transitionEnterActive","transitionExit","content","contentInner","renderPin","positionName","isDefaultBorderColor","popupBorderColor","pinBorder","pinSize","borderColor","hasPin","parseInt","popupPinSize","getPinOffset","align","popupBackground","raf","cancel","x","y","Math","abs","positions","tryPreserveFirstRenderedPosition","anchorRect","getElementAbsoluteRect","popupRect","getCoordinates","isFullyVisible","canBecomeVisible","canBecomeFullyVisible","getPinnedPopupOffset","test","anchorSize","height","max","marginFromProps","margin","isNaN","popupMargin","popupOffset","getHorizontalPosition","getVerticalPosition","Error","pinOffset","popupPinOffset","popupPinOffsetY","popupPinOffsetX","Component","__KONTUR_REACT_UI__","propTypes","PropTypes","oneOfType","HTMLElement","node","isRequired","string","func","bool","number","array","defaultProps","isTestEnv"],"mappings":"6cAAA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uC;;AAEA,IAAMA,0BAA0B,GAAG,aAAnC;AACA,IAAMC,kBAAkB,GAAG,EAAEC,KAAK,EAAE,CAAT,EAAYC,IAAI,EAAE,GAAlB,EAA3B;;AAEO,IAAMC,cAAc,GAAG;AAC5B,UAD4B;AAE5B,YAF4B;AAG5B,WAH4B;AAI5B,WAJ4B;AAK5B,cAL4B;AAM5B,cAN4B;AAO5B,cAP4B;AAQ5B,eAR4B;AAS5B,aAT4B;AAU5B,aAV4B;AAW5B,aAX4B;AAY5B,UAZ4B,CAAvB,C;;AAcA,IAAMC,eAAe,GAAGD,cAAc,CAAC,CAAD,CAAtC,C;;;;AAIP,IAAME,cAA6B,GAAG;AACpCC,EAAAA,QAAQ,EAAEF,eAD0B;AAEpCG,EAAAA,WAAW,EAAE;AACXC,IAAAA,GAAG,EAAE,CAAC,IADK;AAEXC,IAAAA,IAAI,EAAE,CAAC,IAFI,EAFuB,EAAtC,C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEaC,K,OADZC,kB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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E6B,mBAAUS,KAtDG,EAwDxB;AACJ;AACA,KACI/E,WAAW,EAAEsE,mBAAUO,IA3DC,E,UA8DZG,Y,GAAe,EAC3BrB,WAAW,EAAE,CADc,EAE3B9B,MAAM,EAAE,KAFmB,EAG3B9B,SAAS,EAAE,KAHgB,EAI3BF,iBAAiB,EAAEoF,6BAJQ,EAK3BnG,UAAU,EAAE,KALe,EAM3BkB,WAAW,EAAE,KANc,EAO3BlD,KAAK,EAAE,MAPoB,E","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Transition } from 'react-transition-group';\nimport raf from 'raf';\nimport warning from 'warning';\n\nimport { Nullable } from '../../typings/utility-types';\nimport * as LayoutEvents from '../../lib/LayoutEvents';\nimport { ZIndex } from '../ZIndex';\nimport { RenderContainer } from '../RenderContainer';\nimport { FocusEventType, MouseEventType } from '../../typings/event-types';\nimport { isFunction, isNonNullable, isRefableElement } from '../../lib/utils';\nimport { isIE11, isEdge, isSafari } from '../../lib/client';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { isHTMLElement, safePropTypesInstanceOf } from '../../lib/SSRSafe';\nimport { isTestEnv } from '../../lib/currentEnvironment';\nimport { CommonProps, CommonWrapper } from '../CommonWrapper';\nimport { cx } from '../../lib/theming/Emotion';\nimport { getRootNode, rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { callChildRef } from '../../lib/callChildRef/callChildRef';\n\nimport { PopupPin } from './PopupPin';\nimport { Offset, PopupHelper, PositionObject, Rect } from './PopupHelper';\nimport { styles } from './Popup.styles';\n\nconst POPUP_BORDER_DEFAULT_COLOR = 'transparent';\nconst TRANSITION_TIMEOUT = { enter: 0, exit: 200 };\n\nexport const PopupPositions = [\n 'top left',\n 'top center',\n 'top right',\n 'right top',\n 'right middle',\n 'right bottom',\n 'bottom right',\n 'bottom center',\n 'bottom left',\n 'left bottom',\n 'left middle',\n 'left top',\n] as const;\nexport const DefaultPosition = PopupPositions[0];\n\nexport type PopupPositionsType = typeof PopupPositions[number];\n\nconst DUMMY_LOCATION: PopupLocation = {\n position: DefaultPosition,\n coordinates: {\n top: -9999,\n left: -9999,\n },\n};\n\nexport interface PopupHandlerProps {\n onMouseEnter?: (event: MouseEventType) => void;\n onMouseLeave?: (event: MouseEventType) => void;\n onClick?: (event: MouseEventType) => void;\n onFocus?: (event: FocusEventType) => void;\n onBlur?: (event: FocusEventType) => void;\n onOpen?: () => void;\n onClose?: () => void;\n}\n\nexport interface PopupProps extends CommonProps, PopupHandlerProps {\n anchorElement: React.ReactNode | HTMLElement;\n backgroundColor?: React.CSSProperties['backgroundColor'];\n borderColor?: React.CSSProperties['borderColor'];\n children: React.ReactNode | (() => React.ReactNode);\n hasPin: boolean;\n hasShadow: boolean;\n disableAnimations: boolean;\n margin?: number;\n maxWidth?: number | string;\n opened: boolean;\n pinOffset?: number;\n pinSize?: number;\n popupOffset: number;\n positions: Readonly<PopupPositionsType[]>;\n /**\n * Явно указывает, что вложенные элементы должны быть обёрнуты в `<span/>`. <br/> Используется для корректного позиционирования тултипа при двух и более вложенных элементах.\n *\n * _Примечание_: при **двух и более** вложенных элементах обёртка будет добавлена автоматически.\n */\n useWrapper: boolean;\n ignoreHover: boolean;\n width: React.CSSProperties['width'];\n /**\n * При очередном рендере пытаться сохранить первоначальную позицию попапа\n * (в числе числе, когда он выходит за пределы экрана, но может быть проскролен в него).\n *\n * Нужен только для Tooltip. В остальных случаях позиция перестраивается автоматически.\n * @see https://github.com/skbkontur/retail-ui/pull/1195\n */\n tryPreserveFirstRenderedPosition?: boolean;\n}\n\ninterface PopupLocation {\n coordinates: {\n left: number;\n top: number;\n };\n position: PopupPositionsType;\n}\n\nexport interface PopupState {\n location: Nullable<PopupLocation>;\n}\n\n@rootNode\nexport class Popup extends React.Component<PopupProps, PopupState> {\n public static __KONTUR_REACT_UI__ = 'Popup';\n\n public static propTypes = {\n /**\n * Ссылка (ref) на элемент или React компонент, для которого рисуется попап\n */\n anchorElement: PropTypes.oneOfType([safePropTypesInstanceOf(() => HTMLElement), PropTypes.node]).isRequired,\n\n /**\n * Фон попапа и пина\n */\n backgroundColor: PropTypes.string,\n\n children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),\n\n /**\n * Показывать ли пин\n */\n hasPin: PropTypes.bool,\n\n /**\n * Применять ли box-shadow на попапе. При false отключает границу на пине\n */\n hasShadow: PropTypes.bool,\n\n /**\n * Отступ попапа от элемента\n */\n margin: PropTypes.number,\n\n /**\n * Показан или скрыт попап\n */\n opened: PropTypes.bool,\n\n /**\n * Смещение пина от края попапа. Край задаётся в пропе position вторым словом\n */\n pinOffset: PropTypes.number,\n\n /**\n * Сторона пина без учёта границы.\n * Пин представляет собой равносторонний треугольник, высота от попапа\n * до \"носика\" пина будет соответствовать формуле (size* √3)/2\n */\n pinSize: PropTypes.number,\n\n /**\n * смещение попапа относительно родительского элемента\n */\n popupOffset: PropTypes.number,\n\n /**\n * С какой стороны показывать попап и край попапа,\n * на котором будет отображаться пин\n */\n positions: PropTypes.array,\n\n /**\n * Игнорировать ли события hover/click\n */\n ignoreHover: PropTypes.bool,\n };\n\n public static defaultProps = {\n popupOffset: 0,\n hasPin: false,\n hasShadow: false,\n disableAnimations: isTestEnv,\n useWrapper: false,\n ignoreHover: false,\n width: 'auto',\n };\n\n public state: PopupState = { location: this.props.opened ? DUMMY_LOCATION : null };\n private theme!: Theme;\n private layoutEventsToken: Nullable<ReturnType<typeof LayoutEvents.addListener>>;\n private locationUpdateId: Nullable<number> = null;\n private lastPopupElement: Nullable<HTMLElement>;\n private anchorElement: Nullable<HTMLElement> = null;\n private setRootNode!: TSetRootNode;\n private refForTransition = React.createRef<HTMLDivElement>();\n\n public componentDidMount() {\n this.updateLocation();\n this.layoutEventsToken = LayoutEvents.addListener(this.handleLayoutEvent);\n }\n\n public static getDerivedStateFromProps(props: Readonly<PopupProps>, state: PopupState) {\n /**\n * Delaying updateLocation to ensure it happens after props update\n */\n if (props.opened) {\n if (!state.location) {\n return { location: DUMMY_LOCATION };\n }\n } else if (state.location) {\n return { location: DUMMY_LOCATION };\n }\n return state;\n }\n\n public componentDidUpdate(prevProps: PopupProps, prevState: PopupState) {\n const hadNoLocation = prevState.location === DUMMY_LOCATION;\n const hasLocation = this.state.location !== DUMMY_LOCATION;\n const wasClosed = prevProps.opened && !this.props.opened;\n\n if (hadNoLocation && hasLocation && this.props.onOpen) {\n this.props.onOpen();\n }\n if (wasClosed && !hasLocation && this.props.onClose) {\n this.props.onClose();\n }\n if (this.props.opened) {\n this.delayUpdateLocation();\n }\n }\n\n public componentWillUnmount() {\n this.cancelDelayedUpdateLocation();\n this.removeEventListeners(this.anchorElement);\n if (this.layoutEventsToken) {\n this.layoutEventsToken.remove();\n this.layoutEventsToken = null;\n }\n if (this.state.location && this.props.onClose) {\n this.props.onClose();\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderMain() {\n const { location } = this.state;\n const { anchorElement, useWrapper } = this.props;\n\n let anchor: Nullable<React.ReactNode> = null;\n if (isHTMLElement(anchorElement)) {\n this.updateAnchorElement(anchorElement);\n } else if (React.isValidElement(anchorElement)) {\n anchor = useWrapper ? <span>{anchorElement}</span> : anchorElement;\n } else {\n anchor = <span>{anchorElement}</span>;\n }\n\n const anchorWithRef =\n anchor && React.isValidElement(anchor) && isRefableElement(anchor)\n ? React.cloneElement(anchor, {\n ref: (instance: Nullable<React.ReactInstance>) => {\n this.updateAnchorElement(instance);\n const originalRef = (anchor as React.RefAttributes<any>)?.ref;\n originalRef && callChildRef(originalRef, instance);\n },\n })\n : null;\n\n // we need to get anchor's DOM node\n // so we either set our own ref on it via cloning\n // or relay on findDOMNode (inside getRootNode)\n // which should be called with RenderContainer's ref\n // in the case when the anchor is not refable\n\n const canGetAnchorNode = !!anchorWithRef || isHTMLElement(anchorElement);\n\n return (\n <RenderContainer anchor={anchorWithRef || anchor} ref={canGetAnchorNode ? null : this.renderContainerRef}>\n {location && this.renderContent(location)}\n </RenderContainer>\n );\n }\n\n private renderContainerRef = (childInstance: Nullable<React.ReactInstance>) => {\n this.updateAnchorElement(childInstance);\n };\n\n private updateAnchorElement(childInstance: Nullable<React.ReactInstance>) {\n const childDomNode = getRootNode(childInstance);\n const anchorElement = this.anchorElement;\n\n if (childDomNode !== anchorElement) {\n this.removeEventListeners(anchorElement);\n this.anchorElement = childDomNode;\n this.addEventListeners(childDomNode);\n this.setRootNode(childDomNode);\n }\n }\n\n private addEventListeners(element: Nullable<HTMLElement>) {\n if (element && isHTMLElement(element)) {\n element.addEventListener('mouseenter', this.handleMouseEnter);\n element.addEventListener('mouseleave', this.handleMouseLeave);\n element.addEventListener('click', this.handleClick);\n element.addEventListener('focusin', this.handleFocus as EventListener);\n element.addEventListener('focusout', this.handleBlur as EventListener);\n }\n }\n\n private removeEventListeners(element: Nullable<HTMLElement>) {\n if (element && isHTMLElement(element)) {\n element.removeEventListener('mouseenter', this.handleMouseEnter);\n element.removeEventListener('mouseleave', this.handleMouseLeave);\n element.removeEventListener('click', this.handleClick);\n element.removeEventListener('focusin', this.handleFocus as EventListener);\n element.removeEventListener('focusout', this.handleBlur as EventListener);\n }\n }\n\n private handleMouseEnter = (event: MouseEventType) => {\n if (this.props.onMouseEnter) {\n this.props.onMouseEnter(event);\n }\n };\n\n private handleMouseLeave = (event: MouseEventType) => {\n if (this.props.onMouseLeave) {\n this.props.onMouseLeave(event);\n }\n };\n\n private handleClick = (event: MouseEventType) => {\n if (this.props.onClick) {\n this.props.onClick(event);\n }\n };\n\n private handleFocus = (event: FocusEventType) => {\n if (this.props.onFocus) {\n this.props.onFocus(event);\n }\n };\n\n private handleBlur = (event: FocusEventType) => {\n if (this.props.onBlur) {\n this.props.onBlur(event);\n }\n };\n\n private calculateWidth = (width: PopupProps['width']) => {\n if (typeof width === 'string' && width.includes('%')) {\n return this.anchorElement ? (this.anchorElement.offsetWidth * parseFloat(width)) / 100 : 0;\n }\n return width;\n };\n\n private renderContent(location: PopupLocation) {\n const { backgroundColor, disableAnimations, maxWidth, hasShadow, ignoreHover, opened, width } = this.props;\n const children = this.renderChildren();\n\n const { direction } = PopupHelper.getPositionObject(location.position);\n const rootStyle: React.CSSProperties = { ...location.coordinates, maxWidth };\n\n const shouldFallbackShadow = isIE11 || isEdge || isSafari;\n\n return (\n <Transition\n timeout={TRANSITION_TIMEOUT}\n appear={!disableAnimations}\n in={Boolean(opened && children)}\n mountOnEnter\n unmountOnExit\n enter={!disableAnimations}\n exit={!disableAnimations}\n onExited={this.resetLocation}\n nodeRef={this.refForTransition}\n >\n {(state: string) => (\n <CommonWrapper {...this.props}>\n <ZIndex\n wrapperRef={this.refPopupElement}\n priority={'Popup'}\n className={cx({\n [styles.popup(this.theme)]: true,\n [styles.shadow(this.theme)]: hasShadow && !shouldFallbackShadow,\n [styles.shadowFallback(this.theme)]: hasShadow && shouldFallbackShadow,\n [styles.popupIgnoreHover()]: ignoreHover,\n ...(disableAnimations\n ? {}\n : {\n [styles[`transition-enter-${direction}` as keyof typeof styles](this.theme)]: true,\n [styles.transitionEnter()]: state === 'entering',\n [styles.transitionEnterActive()]: state === 'entered',\n [styles.transitionExit()]: state === 'exiting',\n }),\n })}\n style={rootStyle}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n >\n <div className={styles.content(this.theme)} data-tid={'PopupContent'} ref={this.refForTransition}>\n <div\n className={styles.contentInner(this.theme)}\n style={{ backgroundColor, width: this.calculateWidth(width) }}\n data-tid={'PopupContentInner'}\n >\n {children}\n </div>\n </div>\n {this.renderPin(location.position)}\n </ZIndex>\n </CommonWrapper>\n )}\n </Transition>\n );\n }\n\n private resetLocation = () => {\n this.cancelDelayedUpdateLocation();\n this.state.location !== null && this.setState({ location: null });\n };\n\n private renderChildren() {\n return isFunction(this.props.children) ? this.props.children() : this.props.children;\n }\n\n private refPopupElement = (element: Nullable<HTMLElement>) => {\n this.lastPopupElement = element;\n };\n\n private renderPin(positionName: string): React.ReactNode {\n /**\n * Box-shadow does not appear under the pin. Borders are used instead.\n * In non-ie browsers drop-shadow filter is used. It is applying\n * shadow to the pin too.\n */\n const isDefaultBorderColor = this.theme.popupBorderColor === POPUP_BORDER_DEFAULT_COLOR;\n const pinBorder = isIE11 && isDefaultBorderColor ? 'rgba(0, 0, 0, 0.09)' : this.theme.popupBorderColor;\n\n const { pinSize, hasShadow, backgroundColor, borderColor } = this.props;\n const position = PopupHelper.getPositionObject(positionName);\n\n return (\n this.props.hasPin && (\n <PopupPin\n popupElement={this.lastPopupElement}\n popupPosition={positionName}\n size={pinSize || parseInt(this.theme.popupPinSize)}\n offset={this.getPinOffset(position.align)}\n borderWidth={hasShadow ? 1 : 0}\n backgroundColor={backgroundColor || this.theme.popupBackground}\n borderColor={borderColor || pinBorder}\n />\n )\n );\n }\n\n private handleLayoutEvent = () => {\n if (!this.state.location) {\n return;\n }\n this.updateLocation();\n };\n\n private delayUpdateLocation() {\n this.cancelDelayedUpdateLocation();\n this.locationUpdateId = raf(this.updateLocation);\n }\n\n private cancelDelayedUpdateLocation() {\n if (this.locationUpdateId) {\n raf.cancel(this.locationUpdateId);\n this.locationUpdateId = null;\n }\n }\n\n private updateLocation = () => {\n const popupElement = this.lastPopupElement;\n\n if (!popupElement) {\n return;\n }\n\n const location = this.getLocation(popupElement, this.state.location);\n if (!this.locationEquals(this.state.location, location)) {\n this.setState({ location });\n }\n };\n\n private locationEquals(x: Nullable<PopupLocation>, y: Nullable<PopupLocation>) {\n if (x === y) {\n return true;\n }\n\n if (x == null || y == null) {\n return false;\n }\n\n if (!isIE11 && !isEdge) {\n return (\n x.coordinates.left === y.coordinates.left &&\n x.coordinates.top === y.coordinates.top &&\n x.position === y.position\n );\n }\n\n // Для ie/edge обновляем позицию только при разнице минимум в 1. Иначе есть вероятность\n // уйти в бесконечный ререндер\n\n return (\n x.position === y.position &&\n Math.abs(x.coordinates.top - y.coordinates.top) <= 1 &&\n Math.abs(x.coordinates.left - y.coordinates.left) <= 1\n );\n }\n\n private getLocation(popupElement: HTMLElement, location?: Nullable<PopupLocation>) {\n const { positions, tryPreserveFirstRenderedPosition } = this.props;\n const anchorElement = this.anchorElement;\n\n warning(\n anchorElement && isHTMLElement(anchorElement),\n 'Anchor element is not defined or not instance of HTMLElement',\n );\n\n if (!(anchorElement && isHTMLElement(anchorElement))) {\n return location;\n }\n\n const anchorRect = PopupHelper.getElementAbsoluteRect(anchorElement);\n const popupRect = PopupHelper.getElementAbsoluteRect(popupElement);\n\n let position: PopupPositionsType;\n let coordinates: Offset;\n\n if (location && location !== DUMMY_LOCATION && location.position) {\n position = location.position;\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n\n const isFullyVisible = PopupHelper.isFullyVisible(coordinates, popupRect);\n const canBecomeVisible = !isFullyVisible && PopupHelper.canBecomeFullyVisible(position, coordinates);\n\n if (\n // если нужно сохранить первоначальную позицию и Попап целиком\n // находится в пределах вьюпорта (или может быть проскроллен в него)\n (tryPreserveFirstRenderedPosition && (isFullyVisible || canBecomeVisible)) ||\n // если Попап целиком во вьюпорте и в самой приоритетной позиции\n // (иначе нужно попытаться позицию сменить)\n (isFullyVisible && position === positions[0])\n ) {\n // сохраняем текущую позицию\n return { coordinates, position };\n }\n }\n\n for (position of positions) {\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n if (PopupHelper.isFullyVisible(coordinates, popupRect)) {\n return { coordinates, position };\n }\n }\n\n position = positions[0];\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n return { coordinates, position };\n }\n\n private getPinnedPopupOffset(anchorRect: Rect, position: PositionObject) {\n if (!this.props.hasPin || /center|middle/.test(position.align)) {\n return 0;\n }\n\n const anchorSize = /top|bottom/.test(position.direction) ? anchorRect.width : anchorRect.height;\n\n const { pinSize } = this.props;\n\n return Math.max(\n 0,\n this.getPinOffset(position.align) + (pinSize || parseInt(this.theme.popupPinSize)) - anchorSize / 2,\n );\n }\n\n private getCoordinates(anchorRect: Rect, popupRect: Rect, positionName: string) {\n const { margin: marginFromProps } = this.props;\n const margin =\n isNonNullable(marginFromProps) && !isNaN(marginFromProps)\n ? marginFromProps\n : parseInt(this.theme.popupMargin) || 0;\n const position = PopupHelper.getPositionObject(positionName);\n const popupOffset = this.props.popupOffset + this.getPinnedPopupOffset(anchorRect, position);\n\n switch (position.direction) {\n case 'top':\n return {\n top: anchorRect.top - popupRect.height - margin,\n left: this.getHorizontalPosition(anchorRect, popupRect, position.align, popupOffset),\n };\n case 'bottom':\n return {\n top: anchorRect.top + anchorRect.height + margin,\n left: this.getHorizontalPosition(anchorRect, popupRect, position.align, popupOffset),\n };\n case 'left':\n return {\n top: this.getVerticalPosition(anchorRect, popupRect, position.align, popupOffset),\n left: anchorRect.left - popupRect.width - margin,\n };\n case 'right':\n return {\n top: this.getVerticalPosition(anchorRect, popupRect, position.align, popupOffset),\n left: anchorRect.left + anchorRect.width + margin,\n };\n default:\n throw new Error(`Unexpected direction '${position.direction}'`);\n }\n }\n\n private getPinOffset(align: string) {\n const { pinOffset } = this.props;\n\n switch (align) {\n case 'top':\n case 'bottom':\n return pinOffset || parseInt(this.theme.popupPinOffset) || parseInt(this.theme.popupPinOffsetY);\n case 'left':\n case 'right':\n return pinOffset || parseInt(this.theme.popupPinOffset) || parseInt(this.theme.popupPinOffsetX);\n case 'center':\n case 'middle':\n return 0;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n\n private getHorizontalPosition(anchorRect: Rect, popupRect: Rect, align: string, popupOffset: number) {\n switch (align) {\n case 'left':\n return anchorRect.left - popupOffset;\n case 'center':\n return anchorRect.left - (popupRect.width - anchorRect.width) / 2;\n case 'right':\n return anchorRect.left - (popupRect.width - anchorRect.width) + popupOffset;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n\n private getVerticalPosition(anchorRect: Rect, popupRect: Rect, align: string, popupOffset: number) {\n switch (align) {\n case 'top':\n return anchorRect.top - popupOffset;\n case 'middle':\n return anchorRect.top - (popupRect.height - anchorRect.height) / 2;\n case 'bottom':\n return anchorRect.top - (popupRect.height - anchorRect.height) + popupOffset;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n}\n"]}
@@ -270,7 +270,7 @@ class AnchorTooltipExample extends React.Component {
270
270
  return (
271
271
  <>
272
272
  {this.state.anchor ? (
273
- <Tooltip anchorElement={this.state.anchor} render={() => 'Hello React'} trigger="opened" />
273
+ <Tooltip anchorElement={this.state.anchor} render={() => 'Hello React'} trigger="hover" />
274
274
  ) : null}
275
275
  <div style={containerStyle}>
276
276
  {this.state.blocks.map(({ top, left }, i) => (
@@ -283,9 +283,10 @@ export var Popup = rootNode(_class = (_temp = _class2 = /*#__PURE__*/function (_
283
283
  // which should be called with RenderContainer's ref
284
284
  // in the case when the anchor is not refable
285
285
 
286
+ var canGetAnchorNode = !!anchorWithRef || isHTMLElement(anchorElement);
286
287
  return /*#__PURE__*/React.createElement(RenderContainer, {
287
288
  anchor: anchorWithRef || anchor,
288
- ref: anchorWithRef ? null : this.renderContainerRef
289
+ ref: canGetAnchorNode ? null : this.renderContainerRef
289
290
  }, location && this.renderContent(location));
290
291
  };
291
292
 
@@ -1 +1 @@
1
- {"version":3,"sources":["Popup.tsx"],"names":["React","PropTypes","Transition","raf","warning","LayoutEvents","ZIndex","RenderContainer","isFunction","isNonNullable","isRefableElement","isIE11","isEdge","isSafari","ThemeContext","isHTMLElement","safePropTypesInstanceOf","isTestEnv","CommonWrapper","cx","getRootNode","rootNode","callChildRef","PopupPin","PopupHelper","styles","POPUP_BORDER_DEFAULT_COLOR","TRANSITION_TIMEOUT","enter","exit","PopupPositions","DefaultPosition","DUMMY_LOCATION","position","coordinates","top","left","Popup","state","location","props","opened","theme","layoutEventsToken","locationUpdateId","lastPopupElement","anchorElement","setRootNode","refForTransition","createRef","renderContainerRef","childInstance","updateAnchorElement","handleMouseEnter","event","onMouseEnter","handleMouseLeave","onMouseLeave","handleClick","onClick","handleFocus","onFocus","handleBlur","onBlur","calculateWidth","width","includes","offsetWidth","parseFloat","resetLocation","cancelDelayedUpdateLocation","setState","refPopupElement","element","handleLayoutEvent","updateLocation","popupElement","getLocation","locationEquals","componentDidMount","addListener","getDerivedStateFromProps","componentDidUpdate","prevProps","prevState","hadNoLocation","hasLocation","wasClosed","onOpen","onClose","delayUpdateLocation","componentWillUnmount","removeEventListeners","remove","render","renderMain","useWrapper","anchor","isValidElement","anchorWithRef","cloneElement","ref","instance","originalRef","renderContent","childDomNode","addEventListeners","addEventListener","removeEventListener","backgroundColor","disableAnimations","maxWidth","hasShadow","ignoreHover","children","renderChildren","getPositionObject","direction","rootStyle","shouldFallbackShadow","Boolean","popup","shadow","shadowFallback","popupIgnoreHover","transitionEnter","transitionEnterActive","transitionExit","content","contentInner","renderPin","positionName","isDefaultBorderColor","popupBorderColor","pinBorder","pinSize","borderColor","hasPin","parseInt","popupPinSize","getPinOffset","align","popupBackground","cancel","x","y","Math","abs","positions","tryPreserveFirstRenderedPosition","anchorRect","getElementAbsoluteRect","popupRect","getCoordinates","isFullyVisible","canBecomeVisible","canBecomeFullyVisible","getPinnedPopupOffset","test","anchorSize","height","max","marginFromProps","margin","isNaN","popupMargin","popupOffset","getHorizontalPosition","getVerticalPosition","Error","pinOffset","popupPinOffset","popupPinOffsetY","popupPinOffsetX","Component","__KONTUR_REACT_UI__","propTypes","oneOfType","HTMLElement","node","isRequired","string","func","bool","number","array","defaultProps"],"mappings":"kzCAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,UAAT,QAA2B,wBAA3B;AACA,OAAOC,GAAP,MAAgB,KAAhB;AACA,OAAOC,OAAP,MAAoB,SAApB;;;AAGA,OAAO,KAAKC,YAAZ,MAA8B,wBAA9B;AACA,SAASC,MAAT,QAAuB,WAAvB;AACA,SAASC,eAAT,QAAgC,oBAAhC;;AAEA,SAASC,UAAT,EAAqBC,aAArB,EAAoCC,gBAApC,QAA4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AAkFC,UAJzE,EAMxB;AACJ;AACA,KACIvE,eAAe,EAAE5G,SAAS,CAACoL,MATH,EAWxBnE,QAAQ,EAAEjH,SAAS,CAACgL,SAAV,CAAoB,CAAChL,SAAS,CAACkL,IAAX,EAAiBlL,SAAS,CAACqL,IAA3B,CAApB,CAXc,EAaxB;AACJ;AACA,KACI7C,MAAM,EAAExI,SAAS,CAACsL,IAhBM,EAkBxB;AACJ;AACA,KACIvE,SAAS,EAAE/G,SAAS,CAACsL,IArBG,EAuBxB;AACJ;AACA,KACIpB,MAAM,EAAElK,SAAS,CAACuL,MA1BM,EA4BxB;AACJ;AACA,KACI/I,MAAM,EAAExC,SAAS,CAACsL,IA/BM,EAiCxB;AACJ;AACA,KACIb,SAAS,EAAEzK,SAAS,CAACuL,MApCG,EAsCxB;AACJ;AACA;AACA;AACA,KACIjD,OAAO,EAAEtI,SAAS,CAACuL,MA3CK,EA6CxB;AACJ;AACA,KACIlB,WAAW,EAAErK,SAAS,CAACuL,MAhDC,EAkDxB;AACJ;AACA;AACA,KACIpC,SAAS,EAAEnJ,SAAS,CAACwL,KAtDG,EAwDxB;AACJ;AACA,KACIxE,WAAW,EAAEhH,SAAS,CAACsL,IA3DC,EAH5B,UAiEgBG,YAjEhB,GAiE+B,EAC3BpB,WAAW,EAAE,CADc,EAE3B7B,MAAM,EAAE,KAFmB,EAG3BzB,SAAS,EAAE,KAHgB,EAI3BF,iBAAiB,EAAE7F,SAJQ,EAK3B+E,UAAU,EAAE,KALe,EAM3BiB,WAAW,EAAE,KANc,EAO3BhD,KAAK,EAAE,MAPoB,EAjE/B","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Transition } from 'react-transition-group';\nimport raf from 'raf';\nimport warning from 'warning';\n\nimport { Nullable } from '../../typings/utility-types';\nimport * as LayoutEvents from '../../lib/LayoutEvents';\nimport { ZIndex } from '../ZIndex';\nimport { RenderContainer } from '../RenderContainer';\nimport { FocusEventType, MouseEventType } from '../../typings/event-types';\nimport { isFunction, isNonNullable, isRefableElement } from '../../lib/utils';\nimport { isIE11, isEdge, isSafari } from '../../lib/client';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { isHTMLElement, safePropTypesInstanceOf } from '../../lib/SSRSafe';\nimport { isTestEnv } from '../../lib/currentEnvironment';\nimport { CommonProps, CommonWrapper } from '../CommonWrapper';\nimport { cx } from '../../lib/theming/Emotion';\nimport { getRootNode, rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { callChildRef } from '../../lib/callChildRef/callChildRef';\n\nimport { PopupPin } from './PopupPin';\nimport { Offset, PopupHelper, PositionObject, Rect } from './PopupHelper';\nimport { styles } from './Popup.styles';\n\nconst POPUP_BORDER_DEFAULT_COLOR = 'transparent';\nconst TRANSITION_TIMEOUT = { enter: 0, exit: 200 };\n\nexport const PopupPositions = [\n 'top left',\n 'top center',\n 'top right',\n 'right top',\n 'right middle',\n 'right bottom',\n 'bottom right',\n 'bottom center',\n 'bottom left',\n 'left bottom',\n 'left middle',\n 'left top',\n] as const;\nexport const DefaultPosition = PopupPositions[0];\n\nexport type PopupPositionsType = typeof PopupPositions[number];\n\nconst DUMMY_LOCATION: PopupLocation = {\n position: DefaultPosition,\n coordinates: {\n top: -9999,\n left: -9999,\n },\n};\n\nexport interface PopupHandlerProps {\n onMouseEnter?: (event: MouseEventType) => void;\n onMouseLeave?: (event: MouseEventType) => void;\n onClick?: (event: MouseEventType) => void;\n onFocus?: (event: FocusEventType) => void;\n onBlur?: (event: FocusEventType) => void;\n onOpen?: () => void;\n onClose?: () => void;\n}\n\nexport interface PopupProps extends CommonProps, PopupHandlerProps {\n anchorElement: React.ReactNode | HTMLElement;\n backgroundColor?: React.CSSProperties['backgroundColor'];\n borderColor?: React.CSSProperties['borderColor'];\n children: React.ReactNode | (() => React.ReactNode);\n hasPin: boolean;\n hasShadow: boolean;\n disableAnimations: boolean;\n margin?: number;\n maxWidth?: number | string;\n opened: boolean;\n pinOffset?: number;\n pinSize?: number;\n popupOffset: number;\n positions: Readonly<PopupPositionsType[]>;\n /**\n * Явно указывает, что вложенные элементы должны быть обёрнуты в `<span/>`. <br/> Используется для корректного позиционирования тултипа при двух и более вложенных элементах.\n *\n * _Примечание_: при **двух и более** вложенных элементах обёртка будет добавлена автоматически.\n */\n useWrapper: boolean;\n ignoreHover: boolean;\n width: React.CSSProperties['width'];\n /**\n * При очередном рендере пытаться сохранить первоначальную позицию попапа\n * (в числе числе, когда он выходит за пределы экрана, но может быть проскролен в него).\n *\n * Нужен только для Tooltip. В остальных случаях позиция перестраивается автоматически.\n * @see https://github.com/skbkontur/retail-ui/pull/1195\n */\n tryPreserveFirstRenderedPosition?: boolean;\n}\n\ninterface PopupLocation {\n coordinates: {\n left: number;\n top: number;\n };\n position: PopupPositionsType;\n}\n\nexport interface PopupState {\n location: Nullable<PopupLocation>;\n}\n\n@rootNode\nexport class Popup extends React.Component<PopupProps, PopupState> {\n public static __KONTUR_REACT_UI__ = 'Popup';\n\n public static propTypes = {\n /**\n * Ссылка (ref) на элемент или React компонент, для которого рисуется попап\n */\n anchorElement: PropTypes.oneOfType([safePropTypesInstanceOf(() => HTMLElement), PropTypes.node]).isRequired,\n\n /**\n * Фон попапа и пина\n */\n backgroundColor: PropTypes.string,\n\n children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),\n\n /**\n * Показывать ли пин\n */\n hasPin: PropTypes.bool,\n\n /**\n * Применять ли box-shadow на попапе. При false отключает границу на пине\n */\n hasShadow: PropTypes.bool,\n\n /**\n * Отступ попапа от элемента\n */\n margin: PropTypes.number,\n\n /**\n * Показан или скрыт попап\n */\n opened: PropTypes.bool,\n\n /**\n * Смещение пина от края попапа. Край задаётся в пропе position вторым словом\n */\n pinOffset: PropTypes.number,\n\n /**\n * Сторона пина без учёта границы.\n * Пин представляет собой равносторонний треугольник, высота от попапа\n * до \"носика\" пина будет соответствовать формуле (size* √3)/2\n */\n pinSize: PropTypes.number,\n\n /**\n * смещение попапа относительно родительского элемента\n */\n popupOffset: PropTypes.number,\n\n /**\n * С какой стороны показывать попап и край попапа,\n * на котором будет отображаться пин\n */\n positions: PropTypes.array,\n\n /**\n * Игнорировать ли события hover/click\n */\n ignoreHover: PropTypes.bool,\n };\n\n public static defaultProps = {\n popupOffset: 0,\n hasPin: false,\n hasShadow: false,\n disableAnimations: isTestEnv,\n useWrapper: false,\n ignoreHover: false,\n width: 'auto',\n };\n\n public state: PopupState = { location: this.props.opened ? DUMMY_LOCATION : null };\n private theme!: Theme;\n private layoutEventsToken: Nullable<ReturnType<typeof LayoutEvents.addListener>>;\n private locationUpdateId: Nullable<number> = null;\n private lastPopupElement: Nullable<HTMLElement>;\n private anchorElement: Nullable<HTMLElement> = null;\n private setRootNode!: TSetRootNode;\n private refForTransition = React.createRef<HTMLDivElement>();\n\n public componentDidMount() {\n this.updateLocation();\n this.layoutEventsToken = LayoutEvents.addListener(this.handleLayoutEvent);\n }\n\n public static getDerivedStateFromProps(props: Readonly<PopupProps>, state: PopupState) {\n /**\n * Delaying updateLocation to ensure it happens after props update\n */\n if (props.opened) {\n if (!state.location) {\n return { location: DUMMY_LOCATION };\n }\n } else if (state.location) {\n return { location: DUMMY_LOCATION };\n }\n return state;\n }\n\n public componentDidUpdate(prevProps: PopupProps, prevState: PopupState) {\n const hadNoLocation = prevState.location === DUMMY_LOCATION;\n const hasLocation = this.state.location !== DUMMY_LOCATION;\n const wasClosed = prevProps.opened && !this.props.opened;\n\n if (hadNoLocation && hasLocation && this.props.onOpen) {\n this.props.onOpen();\n }\n if (wasClosed && !hasLocation && this.props.onClose) {\n this.props.onClose();\n }\n if (this.props.opened) {\n this.delayUpdateLocation();\n }\n }\n\n public componentWillUnmount() {\n this.cancelDelayedUpdateLocation();\n this.removeEventListeners(this.anchorElement);\n if (this.layoutEventsToken) {\n this.layoutEventsToken.remove();\n this.layoutEventsToken = null;\n }\n if (this.state.location && this.props.onClose) {\n this.props.onClose();\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderMain() {\n const { location } = this.state;\n const { anchorElement, useWrapper } = this.props;\n\n let anchor: Nullable<React.ReactNode> = null;\n if (isHTMLElement(anchorElement)) {\n this.updateAnchorElement(anchorElement);\n } else if (React.isValidElement(anchorElement)) {\n anchor = useWrapper ? <span>{anchorElement}</span> : anchorElement;\n } else {\n anchor = <span>{anchorElement}</span>;\n }\n\n const anchorWithRef =\n anchor && React.isValidElement(anchor) && isRefableElement(anchor)\n ? React.cloneElement(anchor, {\n ref: (instance: Nullable<React.ReactInstance>) => {\n this.updateAnchorElement(instance);\n const originalRef = (anchor as React.RefAttributes<any>)?.ref;\n originalRef && callChildRef(originalRef, instance);\n },\n })\n : null;\n\n // we need to get anchor's DOM node\n // so we either set our own ref on it via cloning\n // or relay on findDOMNode (inside getRootNode)\n // which should be called with RenderContainer's ref\n // in the case when the anchor is not refable\n\n return (\n <RenderContainer anchor={anchorWithRef || anchor} ref={anchorWithRef ? null : this.renderContainerRef}>\n {location && this.renderContent(location)}\n </RenderContainer>\n );\n }\n\n private renderContainerRef = (childInstance: Nullable<React.ReactInstance>) => {\n this.updateAnchorElement(childInstance);\n };\n\n private updateAnchorElement(childInstance: Nullable<React.ReactInstance>) {\n const childDomNode = getRootNode(childInstance);\n const anchorElement = this.anchorElement;\n\n if (childDomNode !== anchorElement) {\n this.removeEventListeners(anchorElement);\n this.anchorElement = childDomNode;\n this.addEventListeners(childDomNode);\n this.setRootNode(childDomNode);\n }\n }\n\n private addEventListeners(element: Nullable<HTMLElement>) {\n if (element && isHTMLElement(element)) {\n element.addEventListener('mouseenter', this.handleMouseEnter);\n element.addEventListener('mouseleave', this.handleMouseLeave);\n element.addEventListener('click', this.handleClick);\n element.addEventListener('focusin', this.handleFocus as EventListener);\n element.addEventListener('focusout', this.handleBlur as EventListener);\n }\n }\n\n private removeEventListeners(element: Nullable<HTMLElement>) {\n if (element && isHTMLElement(element)) {\n element.removeEventListener('mouseenter', this.handleMouseEnter);\n element.removeEventListener('mouseleave', this.handleMouseLeave);\n element.removeEventListener('click', this.handleClick);\n element.removeEventListener('focusin', this.handleFocus as EventListener);\n element.removeEventListener('focusout', this.handleBlur as EventListener);\n }\n }\n\n private handleMouseEnter = (event: MouseEventType) => {\n if (this.props.onMouseEnter) {\n this.props.onMouseEnter(event);\n }\n };\n\n private handleMouseLeave = (event: MouseEventType) => {\n if (this.props.onMouseLeave) {\n this.props.onMouseLeave(event);\n }\n };\n\n private handleClick = (event: MouseEventType) => {\n if (this.props.onClick) {\n this.props.onClick(event);\n }\n };\n\n private handleFocus = (event: FocusEventType) => {\n if (this.props.onFocus) {\n this.props.onFocus(event);\n }\n };\n\n private handleBlur = (event: FocusEventType) => {\n if (this.props.onBlur) {\n this.props.onBlur(event);\n }\n };\n\n private calculateWidth = (width: PopupProps['width']) => {\n if (typeof width === 'string' && width.includes('%')) {\n return this.anchorElement ? (this.anchorElement.offsetWidth * parseFloat(width)) / 100 : 0;\n }\n return width;\n };\n\n private renderContent(location: PopupLocation) {\n const { backgroundColor, disableAnimations, maxWidth, hasShadow, ignoreHover, opened, width } = this.props;\n const children = this.renderChildren();\n\n const { direction } = PopupHelper.getPositionObject(location.position);\n const rootStyle: React.CSSProperties = { ...location.coordinates, maxWidth };\n\n const shouldFallbackShadow = isIE11 || isEdge || isSafari;\n\n return (\n <Transition\n timeout={TRANSITION_TIMEOUT}\n appear={!disableAnimations}\n in={Boolean(opened && children)}\n mountOnEnter\n unmountOnExit\n enter={!disableAnimations}\n exit={!disableAnimations}\n onExited={this.resetLocation}\n nodeRef={this.refForTransition}\n >\n {(state: string) => (\n <CommonWrapper {...this.props}>\n <ZIndex\n wrapperRef={this.refPopupElement}\n priority={'Popup'}\n className={cx({\n [styles.popup(this.theme)]: true,\n [styles.shadow(this.theme)]: hasShadow && !shouldFallbackShadow,\n [styles.shadowFallback(this.theme)]: hasShadow && shouldFallbackShadow,\n [styles.popupIgnoreHover()]: ignoreHover,\n ...(disableAnimations\n ? {}\n : {\n [styles[`transition-enter-${direction}` as keyof typeof styles](this.theme)]: true,\n [styles.transitionEnter()]: state === 'entering',\n [styles.transitionEnterActive()]: state === 'entered',\n [styles.transitionExit()]: state === 'exiting',\n }),\n })}\n style={rootStyle}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n >\n <div className={styles.content(this.theme)} data-tid={'PopupContent'} ref={this.refForTransition}>\n <div\n className={styles.contentInner(this.theme)}\n style={{ backgroundColor, width: this.calculateWidth(width) }}\n data-tid={'PopupContentInner'}\n >\n {children}\n </div>\n </div>\n {this.renderPin(location.position)}\n </ZIndex>\n </CommonWrapper>\n )}\n </Transition>\n );\n }\n\n private resetLocation = () => {\n this.cancelDelayedUpdateLocation();\n this.state.location !== null && this.setState({ location: null });\n };\n\n private renderChildren() {\n return isFunction(this.props.children) ? this.props.children() : this.props.children;\n }\n\n private refPopupElement = (element: Nullable<HTMLElement>) => {\n this.lastPopupElement = element;\n };\n\n private renderPin(positionName: string): React.ReactNode {\n /**\n * Box-shadow does not appear under the pin. Borders are used instead.\n * In non-ie browsers drop-shadow filter is used. It is applying\n * shadow to the pin too.\n */\n const isDefaultBorderColor = this.theme.popupBorderColor === POPUP_BORDER_DEFAULT_COLOR;\n const pinBorder = isIE11 && isDefaultBorderColor ? 'rgba(0, 0, 0, 0.09)' : this.theme.popupBorderColor;\n\n const { pinSize, hasShadow, backgroundColor, borderColor } = this.props;\n const position = PopupHelper.getPositionObject(positionName);\n\n return (\n this.props.hasPin && (\n <PopupPin\n popupElement={this.lastPopupElement}\n popupPosition={positionName}\n size={pinSize || parseInt(this.theme.popupPinSize)}\n offset={this.getPinOffset(position.align)}\n borderWidth={hasShadow ? 1 : 0}\n backgroundColor={backgroundColor || this.theme.popupBackground}\n borderColor={borderColor || pinBorder}\n />\n )\n );\n }\n\n private handleLayoutEvent = () => {\n if (!this.state.location) {\n return;\n }\n this.updateLocation();\n };\n\n private delayUpdateLocation() {\n this.cancelDelayedUpdateLocation();\n this.locationUpdateId = raf(this.updateLocation);\n }\n\n private cancelDelayedUpdateLocation() {\n if (this.locationUpdateId) {\n raf.cancel(this.locationUpdateId);\n this.locationUpdateId = null;\n }\n }\n\n private updateLocation = () => {\n const popupElement = this.lastPopupElement;\n\n if (!popupElement) {\n return;\n }\n\n const location = this.getLocation(popupElement, this.state.location);\n if (!this.locationEquals(this.state.location, location)) {\n this.setState({ location });\n }\n };\n\n private locationEquals(x: Nullable<PopupLocation>, y: Nullable<PopupLocation>) {\n if (x === y) {\n return true;\n }\n\n if (x == null || y == null) {\n return false;\n }\n\n if (!isIE11 && !isEdge) {\n return (\n x.coordinates.left === y.coordinates.left &&\n x.coordinates.top === y.coordinates.top &&\n x.position === y.position\n );\n }\n\n // Для ie/edge обновляем позицию только при разнице минимум в 1. Иначе есть вероятность\n // уйти в бесконечный ререндер\n\n return (\n x.position === y.position &&\n Math.abs(x.coordinates.top - y.coordinates.top) <= 1 &&\n Math.abs(x.coordinates.left - y.coordinates.left) <= 1\n );\n }\n\n private getLocation(popupElement: HTMLElement, location?: Nullable<PopupLocation>) {\n const { positions, tryPreserveFirstRenderedPosition } = this.props;\n const anchorElement = this.anchorElement;\n\n warning(\n anchorElement && isHTMLElement(anchorElement),\n 'Anchor element is not defined or not instance of HTMLElement',\n );\n\n if (!(anchorElement && isHTMLElement(anchorElement))) {\n return location;\n }\n\n const anchorRect = PopupHelper.getElementAbsoluteRect(anchorElement);\n const popupRect = PopupHelper.getElementAbsoluteRect(popupElement);\n\n let position: PopupPositionsType;\n let coordinates: Offset;\n\n if (location && location !== DUMMY_LOCATION && location.position) {\n position = location.position;\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n\n const isFullyVisible = PopupHelper.isFullyVisible(coordinates, popupRect);\n const canBecomeVisible = !isFullyVisible && PopupHelper.canBecomeFullyVisible(position, coordinates);\n\n if (\n // если нужно сохранить первоначальную позицию и Попап целиком\n // находится в пределах вьюпорта (или может быть проскроллен в него)\n (tryPreserveFirstRenderedPosition && (isFullyVisible || canBecomeVisible)) ||\n // если Попап целиком во вьюпорте и в самой приоритетной позиции\n // (иначе нужно попытаться позицию сменить)\n (isFullyVisible && position === positions[0])\n ) {\n // сохраняем текущую позицию\n return { coordinates, position };\n }\n }\n\n for (position of positions) {\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n if (PopupHelper.isFullyVisible(coordinates, popupRect)) {\n return { coordinates, position };\n }\n }\n\n position = positions[0];\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n return { coordinates, position };\n }\n\n private getPinnedPopupOffset(anchorRect: Rect, position: PositionObject) {\n if (!this.props.hasPin || /center|middle/.test(position.align)) {\n return 0;\n }\n\n const anchorSize = /top|bottom/.test(position.direction) ? anchorRect.width : anchorRect.height;\n\n const { pinSize } = this.props;\n\n return Math.max(\n 0,\n this.getPinOffset(position.align) + (pinSize || parseInt(this.theme.popupPinSize)) - anchorSize / 2,\n );\n }\n\n private getCoordinates(anchorRect: Rect, popupRect: Rect, positionName: string) {\n const { margin: marginFromProps } = this.props;\n const margin =\n isNonNullable(marginFromProps) && !isNaN(marginFromProps)\n ? marginFromProps\n : parseInt(this.theme.popupMargin) || 0;\n const position = PopupHelper.getPositionObject(positionName);\n const popupOffset = this.props.popupOffset + this.getPinnedPopupOffset(anchorRect, position);\n\n switch (position.direction) {\n case 'top':\n return {\n top: anchorRect.top - popupRect.height - margin,\n left: this.getHorizontalPosition(anchorRect, popupRect, position.align, popupOffset),\n };\n case 'bottom':\n return {\n top: anchorRect.top + anchorRect.height + margin,\n left: this.getHorizontalPosition(anchorRect, popupRect, position.align, popupOffset),\n };\n case 'left':\n return {\n top: this.getVerticalPosition(anchorRect, popupRect, position.align, popupOffset),\n left: anchorRect.left - popupRect.width - margin,\n };\n case 'right':\n return {\n top: this.getVerticalPosition(anchorRect, popupRect, position.align, popupOffset),\n left: anchorRect.left + anchorRect.width + margin,\n };\n default:\n throw new Error(`Unexpected direction '${position.direction}'`);\n }\n }\n\n private getPinOffset(align: string) {\n const { pinOffset } = this.props;\n\n switch (align) {\n case 'top':\n case 'bottom':\n return pinOffset || parseInt(this.theme.popupPinOffset) || parseInt(this.theme.popupPinOffsetY);\n case 'left':\n case 'right':\n return pinOffset || parseInt(this.theme.popupPinOffset) || parseInt(this.theme.popupPinOffsetX);\n case 'center':\n case 'middle':\n return 0;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n\n private getHorizontalPosition(anchorRect: Rect, popupRect: Rect, align: string, popupOffset: number) {\n switch (align) {\n case 'left':\n return anchorRect.left - popupOffset;\n case 'center':\n return anchorRect.left - (popupRect.width - anchorRect.width) / 2;\n case 'right':\n return anchorRect.left - (popupRect.width - anchorRect.width) + popupOffset;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n\n private getVerticalPosition(anchorRect: Rect, popupRect: Rect, align: string, popupOffset: number) {\n switch (align) {\n case 'top':\n return anchorRect.top - popupOffset;\n case 'middle':\n return anchorRect.top - (popupRect.height - anchorRect.height) / 2;\n case 'bottom':\n return anchorRect.top - (popupRect.height - anchorRect.height) + popupOffset;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["Popup.tsx"],"names":["React","PropTypes","Transition","raf","warning","LayoutEvents","ZIndex","RenderContainer","isFunction","isNonNullable","isRefableElement","isIE11","isEdge","isSafari","ThemeContext","isHTMLElement","safePropTypesInstanceOf","isTestEnv","CommonWrapper","cx","getRootNode","rootNode","callChildRef","PopupPin","PopupHelper","styles","POPUP_BORDER_DEFAULT_COLOR","TRANSITION_TIMEOUT","enter","exit","PopupPositions","DefaultPosition","DUMMY_LOCATION","position","coordinates","top","left","Popup","state","location","props","opened","theme","layoutEventsToken","locationUpdateId","lastPopupElement","anchorElement","setRootNode","refForTransition","createRef","renderContainerRef","childInstance","updateAnchorElement","handleMouseEnter","event","onMouseEnter","handleMouseLeave","onMouseLeave","handleClick","onClick","handleFocus","onFocus","handleBlur","onBlur","calculateWidth","width","includes","offsetWidth","parseFloat","resetLocation","cancelDelayedUpdateLocation","setState","refPopupElement","element","handleLayoutEvent","updateLocation","popupElement","getLocation","locationEquals","componentDidMount","addListener","getDerivedStateFromProps","componentDidUpdate","prevProps","prevState","hadNoLocation","hasLocation","wasClosed","onOpen","onClose","delayUpdateLocation","componentWillUnmount","removeEventListeners","remove","render","renderMain","useWrapper","anchor","isValidElement","anchorWithRef","cloneElement","ref","instance","originalRef","canGetAnchorNode","renderContent","childDomNode","addEventListeners","addEventListener","removeEventListener","backgroundColor","disableAnimations","maxWidth","hasShadow","ignoreHover","children","renderChildren","getPositionObject","direction","rootStyle","shouldFallbackShadow","Boolean","popup","shadow","shadowFallback","popupIgnoreHover","transitionEnter","transitionEnterActive","transitionExit","content","contentInner","renderPin","positionName","isDefaultBorderColor","popupBorderColor","pinBorder","pinSize","borderColor","hasPin","parseInt","popupPinSize","getPinOffset","align","popupBackground","cancel","x","y","Math","abs","positions","tryPreserveFirstRenderedPosition","anchorRect","getElementAbsoluteRect","popupRect","getCoordinates","isFullyVisible","canBecomeVisible","canBecomeFullyVisible","getPinnedPopupOffset","test","anchorSize","height","max","marginFromProps","margin","isNaN","popupMargin","popupOffset","getHorizontalPosition","getVerticalPosition","Error","pinOffset","popupPinOffset","popupPinOffsetY","popupPinOffsetX","Component","__KONTUR_REACT_UI__","propTypes","oneOfType","HTMLElement","node","isRequired","string","func","bool","number","array","defaultProps"],"mappings":"kzCAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,UAAT,QAA2B,wBAA3B;AACA,OAAOC,GAAP,MAAgB,KAAhB;AACA,OAAOC,OAAP,MAAoB,SAApB;;;AAGA,OAAO,KAAKC,YAAZ,MAA8B,wBAA9B;AACA,SAASC,MAAT,QAAuB,WAAvB;AACA,SAASC,eAAT,QAAgC,oBAAhC;;AAEA,S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C,SAAS,CAACiL,SAAV,CAAoB,CAAClK,uBAAuB,CAAC,oBAAMmK,WAAN,EAAD,CAAxB,EAA6ClL,SAAS,CAACmL,IAAvD,CAApB,EAAkFC,UAJzE,EAMxB;AACJ;AACA,KACIvE,eAAe,EAAE7G,SAAS,CAACqL,MATH,EAWxBnE,QAAQ,EAAElH,SAAS,CAACiL,SAAV,CAAoB,CAACjL,SAAS,CAACmL,IAAX,EAAiBnL,SAAS,CAACsL,IAA3B,CAApB,CAXc,EAaxB;AACJ;AACA,KACI7C,MAAM,EAAEzI,SAAS,CAACuL,IAhBM,EAkBxB;AACJ;AACA,KACIvE,SAAS,EAAEhH,SAAS,CAACuL,IArBG,EAuBxB;AACJ;AACA,KACIpB,MAAM,EAAEnK,SAAS,CAACwL,MA1BM,EA4BxB;AACJ;AACA,KACIhJ,MAAM,EAAExC,SAAS,CAACuL,IA/BM,EAiCxB;AACJ;AACA,KACIb,SAAS,EAAE1K,SAAS,CAACwL,MApCG,EAsCxB;AACJ;AACA;AACA;AACA,KACIjD,OAAO,EAAEvI,SAAS,CAACwL,MA3CK,EA6CxB;AACJ;AACA,KACIlB,WAAW,EAAEtK,SAAS,CAACwL,MAhDC,EAkDxB;AACJ;AACA;AACA,KACIpC,SAAS,EAAEpJ,SAAS,CAACyL,KAtDG,EAwDxB;AACJ;AACA,KACIxE,WAAW,EAAEjH,SAAS,CAACuL,IA3DC,EAH5B,UAiEgBG,YAjEhB,GAiE+B,EAC3BpB,WAAW,EAAE,CADc,EAE3B7B,MAAM,EAAE,KAFmB,EAG3BzB,SAAS,EAAE,KAHgB,EAI3BF,iBAAiB,EAAE9F,SAJQ,EAK3B+E,UAAU,EAAE,KALe,EAM3BkB,WAAW,EAAE,KANc,EAO3BjD,KAAK,EAAE,MAPoB,EAjE/B","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Transition } from 'react-transition-group';\nimport raf from 'raf';\nimport warning from 'warning';\n\nimport { Nullable } from '../../typings/utility-types';\nimport * as LayoutEvents from '../../lib/LayoutEvents';\nimport { ZIndex } from '../ZIndex';\nimport { RenderContainer } from '../RenderContainer';\nimport { FocusEventType, MouseEventType } from '../../typings/event-types';\nimport { isFunction, isNonNullable, isRefableElement } from '../../lib/utils';\nimport { isIE11, isEdge, isSafari } from '../../lib/client';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { isHTMLElement, safePropTypesInstanceOf } from '../../lib/SSRSafe';\nimport { isTestEnv } from '../../lib/currentEnvironment';\nimport { CommonProps, CommonWrapper } from '../CommonWrapper';\nimport { cx } from '../../lib/theming/Emotion';\nimport { getRootNode, rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { callChildRef } from '../../lib/callChildRef/callChildRef';\n\nimport { PopupPin } from './PopupPin';\nimport { Offset, PopupHelper, PositionObject, Rect } from './PopupHelper';\nimport { styles } from './Popup.styles';\n\nconst POPUP_BORDER_DEFAULT_COLOR = 'transparent';\nconst TRANSITION_TIMEOUT = { enter: 0, exit: 200 };\n\nexport const PopupPositions = [\n 'top left',\n 'top center',\n 'top right',\n 'right top',\n 'right middle',\n 'right bottom',\n 'bottom right',\n 'bottom center',\n 'bottom left',\n 'left bottom',\n 'left middle',\n 'left top',\n] as const;\nexport const DefaultPosition = PopupPositions[0];\n\nexport type PopupPositionsType = typeof PopupPositions[number];\n\nconst DUMMY_LOCATION: PopupLocation = {\n position: DefaultPosition,\n coordinates: {\n top: -9999,\n left: -9999,\n },\n};\n\nexport interface PopupHandlerProps {\n onMouseEnter?: (event: MouseEventType) => void;\n onMouseLeave?: (event: MouseEventType) => void;\n onClick?: (event: MouseEventType) => void;\n onFocus?: (event: FocusEventType) => void;\n onBlur?: (event: FocusEventType) => void;\n onOpen?: () => void;\n onClose?: () => void;\n}\n\nexport interface PopupProps extends CommonProps, PopupHandlerProps {\n anchorElement: React.ReactNode | HTMLElement;\n backgroundColor?: React.CSSProperties['backgroundColor'];\n borderColor?: React.CSSProperties['borderColor'];\n children: React.ReactNode | (() => React.ReactNode);\n hasPin: boolean;\n hasShadow: boolean;\n disableAnimations: boolean;\n margin?: number;\n maxWidth?: number | string;\n opened: boolean;\n pinOffset?: number;\n pinSize?: number;\n popupOffset: number;\n positions: Readonly<PopupPositionsType[]>;\n /**\n * Явно указывает, что вложенные элементы должны быть обёрнуты в `<span/>`. <br/> Используется для корректного позиционирования тултипа при двух и более вложенных элементах.\n *\n * _Примечание_: при **двух и более** вложенных элементах обёртка будет добавлена автоматически.\n */\n useWrapper: boolean;\n ignoreHover: boolean;\n width: React.CSSProperties['width'];\n /**\n * При очередном рендере пытаться сохранить первоначальную позицию попапа\n * (в числе числе, когда он выходит за пределы экрана, но может быть проскролен в него).\n *\n * Нужен только для Tooltip. В остальных случаях позиция перестраивается автоматически.\n * @see https://github.com/skbkontur/retail-ui/pull/1195\n */\n tryPreserveFirstRenderedPosition?: boolean;\n}\n\ninterface PopupLocation {\n coordinates: {\n left: number;\n top: number;\n };\n position: PopupPositionsType;\n}\n\nexport interface PopupState {\n location: Nullable<PopupLocation>;\n}\n\n@rootNode\nexport class Popup extends React.Component<PopupProps, PopupState> {\n public static __KONTUR_REACT_UI__ = 'Popup';\n\n public static propTypes = {\n /**\n * Ссылка (ref) на элемент или React компонент, для которого рисуется попап\n */\n anchorElement: PropTypes.oneOfType([safePropTypesInstanceOf(() => HTMLElement), PropTypes.node]).isRequired,\n\n /**\n * Фон попапа и пина\n */\n backgroundColor: PropTypes.string,\n\n children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),\n\n /**\n * Показывать ли пин\n */\n hasPin: PropTypes.bool,\n\n /**\n * Применять ли box-shadow на попапе. При false отключает границу на пине\n */\n hasShadow: PropTypes.bool,\n\n /**\n * Отступ попапа от элемента\n */\n margin: PropTypes.number,\n\n /**\n * Показан или скрыт попап\n */\n opened: PropTypes.bool,\n\n /**\n * Смещение пина от края попапа. Край задаётся в пропе position вторым словом\n */\n pinOffset: PropTypes.number,\n\n /**\n * Сторона пина без учёта границы.\n * Пин представляет собой равносторонний треугольник, высота от попапа\n * до \"носика\" пина будет соответствовать формуле (size* √3)/2\n */\n pinSize: PropTypes.number,\n\n /**\n * смещение попапа относительно родительского элемента\n */\n popupOffset: PropTypes.number,\n\n /**\n * С какой стороны показывать попап и край попапа,\n * на котором будет отображаться пин\n */\n positions: PropTypes.array,\n\n /**\n * Игнорировать ли события hover/click\n */\n ignoreHover: PropTypes.bool,\n };\n\n public static defaultProps = {\n popupOffset: 0,\n hasPin: false,\n hasShadow: false,\n disableAnimations: isTestEnv,\n useWrapper: false,\n ignoreHover: false,\n width: 'auto',\n };\n\n public state: PopupState = { location: this.props.opened ? DUMMY_LOCATION : null };\n private theme!: Theme;\n private layoutEventsToken: Nullable<ReturnType<typeof LayoutEvents.addListener>>;\n private locationUpdateId: Nullable<number> = null;\n private lastPopupElement: Nullable<HTMLElement>;\n private anchorElement: Nullable<HTMLElement> = null;\n private setRootNode!: TSetRootNode;\n private refForTransition = React.createRef<HTMLDivElement>();\n\n public componentDidMount() {\n this.updateLocation();\n this.layoutEventsToken = LayoutEvents.addListener(this.handleLayoutEvent);\n }\n\n public static getDerivedStateFromProps(props: Readonly<PopupProps>, state: PopupState) {\n /**\n * Delaying updateLocation to ensure it happens after props update\n */\n if (props.opened) {\n if (!state.location) {\n return { location: DUMMY_LOCATION };\n }\n } else if (state.location) {\n return { location: DUMMY_LOCATION };\n }\n return state;\n }\n\n public componentDidUpdate(prevProps: PopupProps, prevState: PopupState) {\n const hadNoLocation = prevState.location === DUMMY_LOCATION;\n const hasLocation = this.state.location !== DUMMY_LOCATION;\n const wasClosed = prevProps.opened && !this.props.opened;\n\n if (hadNoLocation && hasLocation && this.props.onOpen) {\n this.props.onOpen();\n }\n if (wasClosed && !hasLocation && this.props.onClose) {\n this.props.onClose();\n }\n if (this.props.opened) {\n this.delayUpdateLocation();\n }\n }\n\n public componentWillUnmount() {\n this.cancelDelayedUpdateLocation();\n this.removeEventListeners(this.anchorElement);\n if (this.layoutEventsToken) {\n this.layoutEventsToken.remove();\n this.layoutEventsToken = null;\n }\n if (this.state.location && this.props.onClose) {\n this.props.onClose();\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderMain() {\n const { location } = this.state;\n const { anchorElement, useWrapper } = this.props;\n\n let anchor: Nullable<React.ReactNode> = null;\n if (isHTMLElement(anchorElement)) {\n this.updateAnchorElement(anchorElement);\n } else if (React.isValidElement(anchorElement)) {\n anchor = useWrapper ? <span>{anchorElement}</span> : anchorElement;\n } else {\n anchor = <span>{anchorElement}</span>;\n }\n\n const anchorWithRef =\n anchor && React.isValidElement(anchor) && isRefableElement(anchor)\n ? React.cloneElement(anchor, {\n ref: (instance: Nullable<React.ReactInstance>) => {\n this.updateAnchorElement(instance);\n const originalRef = (anchor as React.RefAttributes<any>)?.ref;\n originalRef && callChildRef(originalRef, instance);\n },\n })\n : null;\n\n // we need to get anchor's DOM node\n // so we either set our own ref on it via cloning\n // or relay on findDOMNode (inside getRootNode)\n // which should be called with RenderContainer's ref\n // in the case when the anchor is not refable\n\n const canGetAnchorNode = !!anchorWithRef || isHTMLElement(anchorElement);\n\n return (\n <RenderContainer anchor={anchorWithRef || anchor} ref={canGetAnchorNode ? null : this.renderContainerRef}>\n {location && this.renderContent(location)}\n </RenderContainer>\n );\n }\n\n private renderContainerRef = (childInstance: Nullable<React.ReactInstance>) => {\n this.updateAnchorElement(childInstance);\n };\n\n private updateAnchorElement(childInstance: Nullable<React.ReactInstance>) {\n const childDomNode = getRootNode(childInstance);\n const anchorElement = this.anchorElement;\n\n if (childDomNode !== anchorElement) {\n this.removeEventListeners(anchorElement);\n this.anchorElement = childDomNode;\n this.addEventListeners(childDomNode);\n this.setRootNode(childDomNode);\n }\n }\n\n private addEventListeners(element: Nullable<HTMLElement>) {\n if (element && isHTMLElement(element)) {\n element.addEventListener('mouseenter', this.handleMouseEnter);\n element.addEventListener('mouseleave', this.handleMouseLeave);\n element.addEventListener('click', this.handleClick);\n element.addEventListener('focusin', this.handleFocus as EventListener);\n element.addEventListener('focusout', this.handleBlur as EventListener);\n }\n }\n\n private removeEventListeners(element: Nullable<HTMLElement>) {\n if (element && isHTMLElement(element)) {\n element.removeEventListener('mouseenter', this.handleMouseEnter);\n element.removeEventListener('mouseleave', this.handleMouseLeave);\n element.removeEventListener('click', this.handleClick);\n element.removeEventListener('focusin', this.handleFocus as EventListener);\n element.removeEventListener('focusout', this.handleBlur as EventListener);\n }\n }\n\n private handleMouseEnter = (event: MouseEventType) => {\n if (this.props.onMouseEnter) {\n this.props.onMouseEnter(event);\n }\n };\n\n private handleMouseLeave = (event: MouseEventType) => {\n if (this.props.onMouseLeave) {\n this.props.onMouseLeave(event);\n }\n };\n\n private handleClick = (event: MouseEventType) => {\n if (this.props.onClick) {\n this.props.onClick(event);\n }\n };\n\n private handleFocus = (event: FocusEventType) => {\n if (this.props.onFocus) {\n this.props.onFocus(event);\n }\n };\n\n private handleBlur = (event: FocusEventType) => {\n if (this.props.onBlur) {\n this.props.onBlur(event);\n }\n };\n\n private calculateWidth = (width: PopupProps['width']) => {\n if (typeof width === 'string' && width.includes('%')) {\n return this.anchorElement ? (this.anchorElement.offsetWidth * parseFloat(width)) / 100 : 0;\n }\n return width;\n };\n\n private renderContent(location: PopupLocation) {\n const { backgroundColor, disableAnimations, maxWidth, hasShadow, ignoreHover, opened, width } = this.props;\n const children = this.renderChildren();\n\n const { direction } = PopupHelper.getPositionObject(location.position);\n const rootStyle: React.CSSProperties = { ...location.coordinates, maxWidth };\n\n const shouldFallbackShadow = isIE11 || isEdge || isSafari;\n\n return (\n <Transition\n timeout={TRANSITION_TIMEOUT}\n appear={!disableAnimations}\n in={Boolean(opened && children)}\n mountOnEnter\n unmountOnExit\n enter={!disableAnimations}\n exit={!disableAnimations}\n onExited={this.resetLocation}\n nodeRef={this.refForTransition}\n >\n {(state: string) => (\n <CommonWrapper {...this.props}>\n <ZIndex\n wrapperRef={this.refPopupElement}\n priority={'Popup'}\n className={cx({\n [styles.popup(this.theme)]: true,\n [styles.shadow(this.theme)]: hasShadow && !shouldFallbackShadow,\n [styles.shadowFallback(this.theme)]: hasShadow && shouldFallbackShadow,\n [styles.popupIgnoreHover()]: ignoreHover,\n ...(disableAnimations\n ? {}\n : {\n [styles[`transition-enter-${direction}` as keyof typeof styles](this.theme)]: true,\n [styles.transitionEnter()]: state === 'entering',\n [styles.transitionEnterActive()]: state === 'entered',\n [styles.transitionExit()]: state === 'exiting',\n }),\n })}\n style={rootStyle}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n >\n <div className={styles.content(this.theme)} data-tid={'PopupContent'} ref={this.refForTransition}>\n <div\n className={styles.contentInner(this.theme)}\n style={{ backgroundColor, width: this.calculateWidth(width) }}\n data-tid={'PopupContentInner'}\n >\n {children}\n </div>\n </div>\n {this.renderPin(location.position)}\n </ZIndex>\n </CommonWrapper>\n )}\n </Transition>\n );\n }\n\n private resetLocation = () => {\n this.cancelDelayedUpdateLocation();\n this.state.location !== null && this.setState({ location: null });\n };\n\n private renderChildren() {\n return isFunction(this.props.children) ? this.props.children() : this.props.children;\n }\n\n private refPopupElement = (element: Nullable<HTMLElement>) => {\n this.lastPopupElement = element;\n };\n\n private renderPin(positionName: string): React.ReactNode {\n /**\n * Box-shadow does not appear under the pin. Borders are used instead.\n * In non-ie browsers drop-shadow filter is used. It is applying\n * shadow to the pin too.\n */\n const isDefaultBorderColor = this.theme.popupBorderColor === POPUP_BORDER_DEFAULT_COLOR;\n const pinBorder = isIE11 && isDefaultBorderColor ? 'rgba(0, 0, 0, 0.09)' : this.theme.popupBorderColor;\n\n const { pinSize, hasShadow, backgroundColor, borderColor } = this.props;\n const position = PopupHelper.getPositionObject(positionName);\n\n return (\n this.props.hasPin && (\n <PopupPin\n popupElement={this.lastPopupElement}\n popupPosition={positionName}\n size={pinSize || parseInt(this.theme.popupPinSize)}\n offset={this.getPinOffset(position.align)}\n borderWidth={hasShadow ? 1 : 0}\n backgroundColor={backgroundColor || this.theme.popupBackground}\n borderColor={borderColor || pinBorder}\n />\n )\n );\n }\n\n private handleLayoutEvent = () => {\n if (!this.state.location) {\n return;\n }\n this.updateLocation();\n };\n\n private delayUpdateLocation() {\n this.cancelDelayedUpdateLocation();\n this.locationUpdateId = raf(this.updateLocation);\n }\n\n private cancelDelayedUpdateLocation() {\n if (this.locationUpdateId) {\n raf.cancel(this.locationUpdateId);\n this.locationUpdateId = null;\n }\n }\n\n private updateLocation = () => {\n const popupElement = this.lastPopupElement;\n\n if (!popupElement) {\n return;\n }\n\n const location = this.getLocation(popupElement, this.state.location);\n if (!this.locationEquals(this.state.location, location)) {\n this.setState({ location });\n }\n };\n\n private locationEquals(x: Nullable<PopupLocation>, y: Nullable<PopupLocation>) {\n if (x === y) {\n return true;\n }\n\n if (x == null || y == null) {\n return false;\n }\n\n if (!isIE11 && !isEdge) {\n return (\n x.coordinates.left === y.coordinates.left &&\n x.coordinates.top === y.coordinates.top &&\n x.position === y.position\n );\n }\n\n // Для ie/edge обновляем позицию только при разнице минимум в 1. Иначе есть вероятность\n // уйти в бесконечный ререндер\n\n return (\n x.position === y.position &&\n Math.abs(x.coordinates.top - y.coordinates.top) <= 1 &&\n Math.abs(x.coordinates.left - y.coordinates.left) <= 1\n );\n }\n\n private getLocation(popupElement: HTMLElement, location?: Nullable<PopupLocation>) {\n const { positions, tryPreserveFirstRenderedPosition } = this.props;\n const anchorElement = this.anchorElement;\n\n warning(\n anchorElement && isHTMLElement(anchorElement),\n 'Anchor element is not defined or not instance of HTMLElement',\n );\n\n if (!(anchorElement && isHTMLElement(anchorElement))) {\n return location;\n }\n\n const anchorRect = PopupHelper.getElementAbsoluteRect(anchorElement);\n const popupRect = PopupHelper.getElementAbsoluteRect(popupElement);\n\n let position: PopupPositionsType;\n let coordinates: Offset;\n\n if (location && location !== DUMMY_LOCATION && location.position) {\n position = location.position;\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n\n const isFullyVisible = PopupHelper.isFullyVisible(coordinates, popupRect);\n const canBecomeVisible = !isFullyVisible && PopupHelper.canBecomeFullyVisible(position, coordinates);\n\n if (\n // если нужно сохранить первоначальную позицию и Попап целиком\n // находится в пределах вьюпорта (или может быть проскроллен в него)\n (tryPreserveFirstRenderedPosition && (isFullyVisible || canBecomeVisible)) ||\n // если Попап целиком во вьюпорте и в самой приоритетной позиции\n // (иначе нужно попытаться позицию сменить)\n (isFullyVisible && position === positions[0])\n ) {\n // сохраняем текущую позицию\n return { coordinates, position };\n }\n }\n\n for (position of positions) {\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n if (PopupHelper.isFullyVisible(coordinates, popupRect)) {\n return { coordinates, position };\n }\n }\n\n position = positions[0];\n coordinates = this.getCoordinates(anchorRect, popupRect, position);\n return { coordinates, position };\n }\n\n private getPinnedPopupOffset(anchorRect: Rect, position: PositionObject) {\n if (!this.props.hasPin || /center|middle/.test(position.align)) {\n return 0;\n }\n\n const anchorSize = /top|bottom/.test(position.direction) ? anchorRect.width : anchorRect.height;\n\n const { pinSize } = this.props;\n\n return Math.max(\n 0,\n this.getPinOffset(position.align) + (pinSize || parseInt(this.theme.popupPinSize)) - anchorSize / 2,\n );\n }\n\n private getCoordinates(anchorRect: Rect, popupRect: Rect, positionName: string) {\n const { margin: marginFromProps } = this.props;\n const margin =\n isNonNullable(marginFromProps) && !isNaN(marginFromProps)\n ? marginFromProps\n : parseInt(this.theme.popupMargin) || 0;\n const position = PopupHelper.getPositionObject(positionName);\n const popupOffset = this.props.popupOffset + this.getPinnedPopupOffset(anchorRect, position);\n\n switch (position.direction) {\n case 'top':\n return {\n top: anchorRect.top - popupRect.height - margin,\n left: this.getHorizontalPosition(anchorRect, popupRect, position.align, popupOffset),\n };\n case 'bottom':\n return {\n top: anchorRect.top + anchorRect.height + margin,\n left: this.getHorizontalPosition(anchorRect, popupRect, position.align, popupOffset),\n };\n case 'left':\n return {\n top: this.getVerticalPosition(anchorRect, popupRect, position.align, popupOffset),\n left: anchorRect.left - popupRect.width - margin,\n };\n case 'right':\n return {\n top: this.getVerticalPosition(anchorRect, popupRect, position.align, popupOffset),\n left: anchorRect.left + anchorRect.width + margin,\n };\n default:\n throw new Error(`Unexpected direction '${position.direction}'`);\n }\n }\n\n private getPinOffset(align: string) {\n const { pinOffset } = this.props;\n\n switch (align) {\n case 'top':\n case 'bottom':\n return pinOffset || parseInt(this.theme.popupPinOffset) || parseInt(this.theme.popupPinOffsetY);\n case 'left':\n case 'right':\n return pinOffset || parseInt(this.theme.popupPinOffset) || parseInt(this.theme.popupPinOffsetX);\n case 'center':\n case 'middle':\n return 0;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n\n private getHorizontalPosition(anchorRect: Rect, popupRect: Rect, align: string, popupOffset: number) {\n switch (align) {\n case 'left':\n return anchorRect.left - popupOffset;\n case 'center':\n return anchorRect.left - (popupRect.width - anchorRect.width) / 2;\n case 'right':\n return anchorRect.left - (popupRect.width - anchorRect.width) + popupOffset;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n\n private getVerticalPosition(anchorRect: Rect, popupRect: Rect, align: string, popupOffset: number) {\n switch (align) {\n case 'top':\n return anchorRect.top - popupOffset;\n case 'middle':\n return anchorRect.top - (popupRect.height - anchorRect.height) / 2;\n case 'bottom':\n return anchorRect.top - (popupRect.height - anchorRect.height) + popupOffset;\n default:\n throw new Error(`Unexpected align '${align}'`);\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@skbkontur/react-ui",
3
- "version": "3.12.0",
3
+ "version": "3.12.1",
4
4
  "description": "UI Components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "index.js",
7
7
  "sideEffects": false,
8
- "homepage": "https://tech.skbkontur.ru/react-ui/3.12.0/",
8
+ "homepage": "https://tech.skbkontur.ru/react-ui/3.12.1/",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git@github.com:skbkontur/retail-ui.git"
@@ -162,6 +162,6 @@
162
162
  ]
163
163
  },
164
164
  "publishConfig": {
165
- "tag": "latest"
165
+ "tag": "lts"
166
166
  }
167
167
  }