<commit_before>goog.provide 'spark.components.Form'

goog.require 'spark.core.View'
goog.require 'spark.components.Input'
goog.require 'spark.components.Button'
goog.require 'spark.components.LabeledInput'


###*
  Form component.
###
class spark.components.Form extends spark.core.View

  ###*
    @constructor
    @param   {Object=} options Class options.
    @param   {*=} data Class data
    @extends {spark.core.View}
  ###
  constructor: (options = {}, data) ->

    options.cssClass = "#{spark.utils.concatString 'form', options.cssClass}"

    super options, data

    @inputs           = []
    @buttons          = []
    @inputsByName     = {}
    {inputs, buttons} = options

    @createContainers()

    if inputs
      inputs.forEach (options) =>  @createInput options

    if buttons
      buttons.forEach (options) => @createButton options


  createContainers: ->
    @inputsContainer  = new spark.core.View cssClass: 'input-container'
    @buttonsContainer = new spark.core.View cssClass: 'buttons-container'

    @appendView @inputsContainer
    @appendView @buttonsContainer<commit_msg>Form: Call setData on constructor to populate form.<commit_after>goog.provide 'spark.components.Form'

goog.require 'spark.core.View'
goog.require 'spark.components.Input'
goog.require 'spark.components.Button'
goog.require 'spark.components.LabeledInput'


###*
  Form component.
###
class spark.components.Form extends spark.core.View

  ###*
    @constructor
    @param   {Object=} options Class options.
    @param   {*=} data Class data
    @extends {spark.core.View}
  ###
  constructor: (options = {}, data) ->

    options.cssClass = "#{spark.utils.concatString 'form', options.cssClass}"

    super options, data

    @inputs           = []
    @buttons          = []
    @inputsByName     = {}
    {inputs, buttons} = options

    @createContainers()

    if inputs
      inputs.forEach (options) =>  @createInput options

    if buttons
      buttons.forEach (options) => @createButton options

    @setData data

  createContainers: ->
    @inputsContainer  = new spark.core.View cssClass: 'input-container'
    @buttonsContainer = new spark.core.View cssClass: 'buttons-container'

    @appendView @inputsContainer
    @appendView @buttonsContainer
{'fraction_non_alphanumeric': 0.12488967343336276, 'fraction_numerical': 0.0, 'mean_word_length': 3.2216014897579144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3721022', 'n_tokens_mistral': 693, 'n_tokens_neox': 643, 'n_words': 152}