Class: Playbook::PbTypeahead::Typeahead

Inherits:
KitBase
  • Object
show all
Defined in:
app/pb_kits/playbook/pb_typeahead/typeahead.rb

Instance Method Summary collapse

Methods inherited from KitBase

#object

Methods included from ZIndex

included

Methods included from Spacing

included, #max_width_options, #max_width_props, #max_width_values, #spacing_options, #spacing_props, #spacing_values

Methods included from Classnames

#generate_classname, #generate_classname_without_spacing, included

Methods included from Playbook::Props

#initialize, #prop

Methods included from Playbook::PbKitHelper

#pb_rails

Methods included from Playbook::PbFormsHelper

#pb_form_with

Instance Method Details

#classnameObject



24
25
26
# File 'app/pb_kits/playbook/pb_typeahead/typeahead.rb', line 24

def classname
  generate_classname("pb_typeahead_kit")
end

#dataObject



28
29
30
31
32
33
34
# File 'app/pb_kits/playbook/pb_typeahead/typeahead.rb', line 28

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
  )
end

#typeahead_with_pills_optionsObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/pb_kits/playbook/pb_typeahead/typeahead.rb', line 36

def typeahead_with_pills_options
  base_options = {
    dark: dark,
    defaultValue: default_options,
    id: id,
    isMulti: true,
    label: label,
    name: name,
    options: options,
    placeholder: placeholder,
  }

  base_options.merge!({getOptionLabel: get_option_label}) if get_option_label.present?
  base_options.merge!({getOptionValue: get_option_value}) if get_option_value.present?

  base_options.merge!({
    async: true,
    loadOptions: load_options,
  }) if async

  base_options
end