<commit_before>React = require 'react'

DropdownForm = React.createClass
  displayName: 'DropdownForm'

  getDefaultProps: ->
    anchor: null
    onSubmit: Function.prototype
    onCancel: Function.prototype

  underlayStyle:
    background: 'rgba(127, 127, 127, 0.1)'
    bottom: 0
    left: 0
    position: 'fixed'
    right: 0
    top: 0

  componentDidMount: ->
    @reposition()

  reposition: ->
    console.log 'Will anchor to', @props.anchor

  render: ->
    <div className="dropdown-form-underlay" style={@underlayStyle} onClick={@handleUnderlayClick}>
      <form className="dropdown-form" onSubmit={@handleSubmit}>
        {@props.children}
      </form>
    </div>

  handleSubmit: (e) ->
    e.preventDefault()
    @props.onSubmit arguments...

  handleUnderlayClick: (e) ->
    if e.target is @getDOMNode()
      @props.onCancel arguments...

module.exports = React.createClass
  displayName: 'DropdownFormTrigger'
<commit_msg>Add escape key support<commit_after>React = require 'react'

ESC_KEY = 27

DropdownForm = React.createClass
  displayName: 'DropdownForm'

  getDefaultProps: ->
    anchor: null
    onSubmit: Function.prototype
    onCancel: Function.prototype

  underlayStyle:
    background: 'rgba(127, 127, 127, 0.1)'
    bottom: 0
    left: 0
    position: 'fixed'
    right: 0
    top: 0

  componentDidMount: ->
    @reposition()
    addEventListener 'keydown', @handleGlobalKeyDown

  componentWillUnmount: ->
    removeEventListener 'keydown', @handleGlobalKeyDown

  reposition: ->
    console.log 'Will anchor to', @props.anchor

  handleGlobalKeyDown: (e) ->
    if e.which is ESC_KEY
      @props.onCancel arguments...

  render: ->
    <div className="dropdown-form-underlay" style={@underlayStyle} onClick={@handleUnderlayClick}>
      <form className="dropdown-form" onSubmit={@handleSubmit}>
        {@props.children}
      </form>
    </div>

  handleSubmit: (e) ->
    e.preventDefault()
    @props.onSubmit arguments...

  handleUnderlayClick: (e) ->
    if e.target is @getDOMNode()
      @props.onCancel arguments...

module.exports = React.createClass
  displayName: 'DropdownFormTrigger'

{'fraction_non_alphanumeric': 0.12488306828811974, 'fraction_numerical': 0.014967259120673527, 'mean_word_length': 3.278, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5428739', 'n_tokens_mistral': 703, 'n_tokens_neox': 662, 'n_words': 152}