class Playbook::PbSelect::Select

def all_attributes

def all_attributes
  {
    id: id,
    prompt: blank_selection,
    disabled: disabled,
    required: required,
    multiple: multiple,
    onchange: onchange,
    include_blank: include_blank,
  }.merge(attributes)
end

def angle_down_path

def angle_down_path
  "app/pb_kits/playbook/utilities/icons/angle-down.svg"
end

def classname

def classname
  generate_classname("pb_select", select_margin_bottom, separator: " ")
end

def classnames

def classnames
  classname + inline_class + compact_class + show_arrow_class
end

def compact_class

def compact_class
  compact ? "compact" : ""
end

def disabled_options

def disabled_options
  disabled_options = options.map { |option| option[:value] if option[:disabled] == true }.compact
  if disabled_options.empty?
    nil
  else
    disabled_options
  end
end

def error_class

def error_class
  error ? " error" : ""
end

def inline_class

def inline_class
  inline ? " inline " : " "
end

def options_to_array

def options_to_array
  options.map { |option| [option[:value_text] || option[:value], option[:value]] }
end

def select_margin_bottom

def select_margin_bottom
  margin.present? || margin_bottom.present? ? nil : "mb_sm"
end

def select_wrapper_class

def select_wrapper_class
  "pb_select_kit_wrapper" + error_class
end

def selected

def selected
  selections = options.map { |option| option[:value] if option[:selected] == true }.compact
  if selections.empty?
    nil
  else
    selections
  end
end

def show_arrow_class

def show_arrow_class
  show_arrow ? "show_arrow" : ""
end