import React, { Component, HTMLAttributes, ReactNode } from 'react'; import getClassName from '../../helpers/getClassName'; import classNames from '../../lib/classNames'; import withInsets from '../../hoc/withInsets'; import { isNumeric } from '../../lib/utils'; import { HasInsets, HasPlatform } from '../../types'; import { ModalRootContextInterface } from '../ModalRoot/ModalRootContext'; import withModalRootContext from '../ModalRoot/withModalRootContext'; import withPlatform from '../../hoc/withPlatform'; export interface ModalPageProps extends HTMLAttributes, HasInsets, HasPlatform { id: string; /** * Шапка модальной страницы, `` */ header: ReactNode; onClose?(): void; /** * Процент, на который изначально будет открыта модальная страница */ settlingHeight?: number; /** * Если высота контента в модальной странице может поменяться, нужно установить это свойство */ dynamicContentHeight?: boolean; /** * @ignore */ updateModalHeight?: ModalRootContextInterface['updateModalHeight']; } class ModalPage extends Component { componentDidUpdate(prevProps: ModalPageProps) { if (prevProps.children !== this.props.children) { this.props.updateModalHeight(); } } static defaultProps: Partial = { settlingHeight: 75, insets: {}, }; render() { const { children, className, header, insets, platform } = this.props; return (
{header}
{children}
); } } export default withInsets(withPlatform(withModalRootContext(ModalPage)));