class Playbook::PbTypeahead::Typeahead

def classname

def classname
  default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
  generate_classname("pb_typeahead_kit") + default_margin_bottom
end

def data

def data
  Hash(values[:data]).merge(
    pb_typeahead_kit: true,
    pb_typeahead_kit_search_term_minimum_length: search_term_minimum_length,
    pb_typeahead_kit_search_debounce_timeout: search_debounce_timeout,
    pb_typeahead_kit_clear_on_context_change: clear_on_context_change,
    pb_typeahead_kit_search_context_selector: search_context_selector,
    pb_typeahead_kit_options_by_context: options_by_context.to_json
  )
end

def inline_class

def inline_class
  inline ? " inline" : ""
end

def is_react?

def is_react?
  pills || !is_multi || wrapped
end

def typeahead_react_options

def typeahead_react_options
  base_options = {
    className: classname,
    dark: dark,
    defaultValue: default_options,
    error: error,
    htmlOptions: html_options,
    id: id,
    inline: inline,
    isMulti: is_multi,
    label: label,
    marginBottom: margin_bottom,
    multiKit: multi_kit,
    name: name,
    options: options,
    pillColor: pill_color,
    placeholder: placeholder,
    plusIcon: plus_icon,
    truncate: truncate,
    wrapped: wrapped,
    searchContextSelector: search_context_selector,
    optionsByContext: options_by_context,
    clearOnContextChange: clear_on_context_change,
    disabled: disabled,
  }
  base_options[:getOptionLabel] = get_option_label if get_option_label.present?
  base_options[:getOptionValue] = get_option_value if get_option_value.present?
  if async
    base_options[:async] = true
    base_options[:loadOptions] = load_options
  end
  base_options
end