<commit_before>class Apollos.Forms.Select extends Apollos.Component
  @register "Apollos.Forms.Select"

  vars: -> [

    error: null
    status: null
    value: null

  ]

  events: -> [
    "change select": @.changed
  ]

  onRendered: ->

    self = @

    if self.data().preFill and self.data().preFill > 0
      self.value.set self.data().preFill

    # if Apollos.isMobile()
    return

    select2 = $("select:not([data-is-select2])")

    if not select2.length
      return

    select2.attr("data-is-select2", true).select2()

    select2.on "select2:open", (event) ->
      event.stopPropagation()
      fieldContainer = $ ".select2"
      optionsContainer = $ ".select2-container--open:not(.select2)"
      selectedOption = $ "[aria-selected=true].select2-results__option"

      # Make the select options the width of the field
      optionsContainer.outerWidth(fieldContainer.outerWidth())

      # Make the selected option at the same horizontal as the field
      # TODO: Make this work with the mouseup mousedown problem<commit_msg>add binding var to select component<commit_after>class Apollos.Forms.Select extends Apollos.Component
  @register "Apollos.Forms.Select"

  vars: -> [

    error: null
    status: null
    value: null

  ]

  events: -> [
    "change select": @.changed
  ]

  onRendered: ->

    self = @

    if not self.value.get() and self.data()?.preFill
      self.value.set self.data().preFill

    self.autorun ->
      value = self.value.get()

      if self.data()?.bind
        self.data().bind.set value

    # if Apollos.isMobile()
    return

    select2 = $("select:not([data-is-select2])")

    if not select2.length
      return

    select2.attr("data-is-select2", true).select2()

    select2.on "select2:open", (event) ->
      event.stopPropagation()
      fieldContainer = $ ".select2"
      optionsContainer = $ ".select2-container--open:not(.select2)"
      selectedOption = $ "[aria-selected=true].select2-results__option"

      # Make the select options the width of the field
      optionsContainer.outerWidth(fieldContainer.outerWidth())

      # Make the selected option at the same horizontal as the field
      # TODO: Make this work with the mouseup mousedown problem
{'fraction_non_alphanumeric': 0.12191842223218288, 'fraction_numerical': 0.011205737337516808, 'mean_word_length': 2.7766497461928936, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 13, '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': '6267971', 'n_tokens_mistral': 701, 'n_tokens_neox': 668, 'n_words': 165}