{"version":3,"sources":["popup-container-provider/popup-container-provider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,oBAAY,2BAA2B,GAAG;IACtC;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,KAAK,CAAC,EAAE,GAAG,CAEM;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,eAAe,GAAG,eAAe,CAAC;IAE1C;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CAE3B,CAAC;AAEF,aAAK,2BAA2B,GAAG;IAC/B,SAAS,EAAE,OAAO,CAAC;CACtB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,cAAM,sBAAuB,SACzB,KAAK,CAAC,aAAa,CAAC,2BAA2B,EAAE,2BAA2B,CAAC;IAC7E,SAAS,CAAC,EAAE;;;;;;iBAA+B;IAE3C,KAAK;;MAEH;IAEF,OAAO,CAAC,eAAe,CAAoB;IAE3C,OAAO,CAAC,oBAAoB,CAAc;IAE1C,MAAM,CAAC,iBAAiB,8CAAqB;IAE7C,eAAe;;;;;IAQf,iBAAiB;IAIjB,MAAM;IAqBN;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAMhC;;OAEG;IACI,OAAO,IAAI,WAAW;CAGhC;AAED,eAAe,sBAAsB,CAAC","file":"popup-container-provider.d.ts","sourcesContent":["/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n\nimport React from 'react';\nimport { createCn } from 'bem-react-classname';\n\nimport { IsolatedContainer } from '../isolated-container/isolated-container';\nimport { popupContextTypes } from '../popup/popup';\n\nexport type PopupContainerProviderProps = {\n    /**\n     * Дочерние элементы контейнера\n     */\n    children?: React.ReactNode;\n\n    /**\n     * Дополнительный класс\n     */\n    className?: string;\n\n    /**\n     * Идентификатор компонента в DOM\n     */\n    id?: string;\n\n    /**\n     * Объект со стилями\n     */\n    style?: any/* Не нашёлся встроенный тип для типа {\"name\":\"custom\",\"raw\":\"styleType\",\"params\":[],\"returns\":null}\n                  * https://github.com/alfa-laboratory/library-utils/issues/new\n                  */;\n\n    /**\n     * Тема компонента\n     */\n    theme?: 'alfa-on-color' | 'alfa-on-white';\n\n    /**\n     * Идентификатор для систем автоматизированного тестирования\n     */\n    'data-test-id'?: string;\n\n};\n\ntype PopupContainerProviderState = {\n    didRender: boolean;\n}\n\n/**\n * Становится родительским элементом для всех дочерних блоков `Popup`.\n * Предполагается задавать этому элементу `position: fixed` в стилях.\n *\n * @example\n * ```javascript\n * import PopupContainerProvider from 'arui-feather/popup-container-provider';\n * import Popup from 'arui-feather/popup';\n * import Page from 'arui-feather/page';\n *\n *  <Page>\n *     <PopupContainerProvider\n *         style={\n *             {\n *                 position: 'fixed',\n *                 top: 0,\n *                 right: 0,\n *                 bottom: 0,\n *                 width: '400px',\n *                 overflow: 'auto'\n *             }\n *         }\n *     >\n *         <Popup>\n *             Попап отрендерился в PopupContainerProvider, а не в body\n *             При скролле внутри блока, попап ездит вместе с остальным контентом.\n *         </Popup>\n *     </PopupContainerProvider>\n *  </Page>\n * ```\n */\nclass PopupContainerProvider extends\n    React.PureComponent<PopupContainerProviderProps, PopupContainerProviderState> {\n    protected cn = createCn('popup-container');\n\n    state = {\n        didRender: false, // eslint-disable-line react/no-unused-state\n    };\n\n    private renderContainer: IsolatedContainer;\n\n    private positioningContainer: HTMLElement;\n\n    static childContextTypes = popupContextTypes;\n\n    getChildContext() {\n        return {\n            isInCustomContainer: true,\n            renderContainerElement: (this.renderContainer && this.renderContainer.getNode()),\n            positioningContainerElement: this.positioningContainer,\n        };\n    }\n\n    componentDidMount() {\n        this.handleContainerDidRender();\n    }\n\n    render() {\n        return (\n            <div\n                className={ this.cn() }\n                id={ this.props.id }\n                ref={ (positioningContainer) => {\n                    this.positioningContainer = positioningContainer;\n                } }\n                style={ this.props.style }\n                data-test-id={ this.props['data-test-id'] }\n            >\n                { this.props.children }\n                <IsolatedContainer\n                    ref={ (renderContainer) => {\n                        this.renderContainer = renderContainer;\n                    } }\n                />\n            </div>\n        );\n    }\n\n    /**\n     * Необходимо для обновления childContext сразу после получения refs.\n     */\n    private handleContainerDidRender() {\n        this.setState({\n            didRender: true, // eslint-disable-line react/no-unused-state\n        });\n    }\n\n    /**\n     * Возвращает корневой `HTMLElement` компонента.\n     */\n    public getNode(): HTMLElement {\n        return this.positioningContainer;\n    }\n}\n\nexport default PopupContainerProvider;\n"]}