|
@ -4,7 +4,7 @@ |
|
|
/* eslint-disable jsx-a11y/no-static-element-interactions */ |
|
|
/* eslint-disable jsx-a11y/no-static-element-interactions */ |
|
|
/* eslint-disable react/no-multi-comp */ |
|
|
/* eslint-disable react/no-multi-comp */ |
|
|
|
|
|
|
|
|
import React, { Component, PureComponent } from 'react' |
|
|
import React, { Component } from 'react' |
|
|
import { findDOMNode } from 'react-dom' |
|
|
import { findDOMNode } from 'react-dom' |
|
|
import { connect } from 'react-redux' |
|
|
import { connect } from 'react-redux' |
|
|
import Mortal from 'react-mortal' |
|
|
import Mortal from 'react-mortal' |
|
@ -18,6 +18,7 @@ import { closeModal, isModalOpened, getModalData } from 'reducers/modals' |
|
|
import Box, { Tabbable } from 'components/base/Box' |
|
|
import Box, { Tabbable } from 'components/base/Box' |
|
|
import GrowScroll from 'components/base/GrowScroll' |
|
|
import GrowScroll from 'components/base/GrowScroll' |
|
|
import Icon from 'components/base/Icon' |
|
|
import Icon from 'components/base/Icon' |
|
|
|
|
|
import Defer from 'components/base/Defer' |
|
|
|
|
|
|
|
|
type Props = { |
|
|
type Props = { |
|
|
isOpened?: boolean, |
|
|
isOpened?: boolean, |
|
@ -117,11 +118,11 @@ class Pure extends Component<any> { |
|
|
render() { |
|
|
render() { |
|
|
const { data, onClose, render } = this.props |
|
|
const { data, onClose, render } = this.props |
|
|
|
|
|
|
|
|
return render({ data, onClose }) |
|
|
return <Defer>{render({ data, onClose })}</Defer> |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export class Modal extends PureComponent<Props> { |
|
|
export class Modal extends Component<Props> { |
|
|
static defaultProps = { |
|
|
static defaultProps = { |
|
|
data: undefined, |
|
|
data: undefined, |
|
|
isOpened: false, |
|
|
isOpened: false, |
|
@ -130,6 +131,14 @@ export class Modal extends PureComponent<Props> { |
|
|
preventBackdropClick: false, |
|
|
preventBackdropClick: false, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
shouldComponentUpdate(nextProps: Props) { |
|
|
|
|
|
if (this.props.isOpened || nextProps.isOpened) { |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps: Props) { |
|
|
componentDidUpdate(prevProps: Props) { |
|
|
const didOpened = this.props.isOpened && !prevProps.isOpened |
|
|
const didOpened = this.props.isOpened && !prevProps.isOpened |
|
|
const didClose = !this.props.isOpened && prevProps.isOpened |
|
|
const didClose = !this.props.isOpened && prevProps.isOpened |
|
@ -171,12 +180,18 @@ export class Modal extends PureComponent<Props> { |
|
|
{(m, isVisible, isAnimated) => ( |
|
|
{(m, isVisible, isAnimated) => ( |
|
|
<Container isVisible={isVisible}> |
|
|
<Container isVisible={isVisible}> |
|
|
<Backdrop op={m.opacity} /> |
|
|
<Backdrop op={m.opacity} /> |
|
|
<GrowScroll full align="center" onClick={preventBackdropClick ? undefined : onClose}> |
|
|
<GrowScroll |
|
|
|
|
|
align="center" |
|
|
|
|
|
full |
|
|
|
|
|
justify="flex-start" |
|
|
|
|
|
onClick={preventBackdropClick ? undefined : onClose} |
|
|
|
|
|
style={{ height: '100%' }} |
|
|
|
|
|
> |
|
|
<Wrapper |
|
|
<Wrapper |
|
|
op={m.opacity} |
|
|
op={m.opacity} |
|
|
offset={m.y} |
|
|
offset={m.y} |
|
|
onClick={e => e.stopPropagation()} |
|
|
|
|
|
innerRef={n => (this._wrapper = n)} |
|
|
innerRef={n => (this._wrapper = n)} |
|
|
|
|
|
onClick={e => e.stopPropagation()} |
|
|
> |
|
|
> |
|
|
<Pure isAnimated={isAnimated} render={render} data={data} onClose={onClose} /> |
|
|
<Pure isAnimated={isAnimated} render={render} data={data} onClose={onClose} /> |
|
|
</Wrapper> |
|
|
</Wrapper> |
|
|