 kd     = require 'kd'
 React  = require 'kd-react'
 Portal = require 'react-portal'
+isNodeInRoot = require 'app/util/isnodeinroot'
 
 
 class ModalOverlay extends React.Component

  @defaultProps =
    onClose             : kd.noop
    closeOnEsc          : yes
    closeOnOutsideClick : yes
    hasOverlay          : yes
    isOpen              : no
    closeIcon           : yes

  getPortalProps: ->
    isOpened            : @props.isOpen
    onClose             : @props.onClose
    closeOnEsc          : @props.closeOnEsc
    closeOnOutsideClick : @props.closeOnOutsideClick


  renderModalCloseIcon: ->

    return null  unless @props.isOpen

    <Portal {...@getPortalProps()} ref="modal">
      <div ref='ModalWrapper' className={kd.utils.curry 'Reactivity Modal', @props.className}>
        {@renderModalCloseIcon()}
        {@props.children}
      </div>
