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 NumberSpacing

included

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



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

def classname
  generate_classname("pb_typeahead_kit")
end

#dataObject



40
41
42
43
44
45
46
# File 'app/pb_kits/playbook/pb_typeahead/typeahead.rb', line 40

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

#inline_classObject



36
37
38
# File 'app/pb_kits/playbook/pb_typeahead/typeahead.rb', line 36

def inline_class
  inline ? " inline" : ""
end

#typeahead_with_pills_optionsObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/pb_kits/playbook/pb_typeahead/typeahead.rb', line 48

def typeahead_with_pills_options
  base_options = {
    dark: dark,
    defaultValue: default_options,
    id: id,
    inline: inline,
    isMulti: true,
    label: label,
    multiKit: multi_kit,
    name: name,
    options: options,
    placeholder: placeholder,
    plusIcon: plus_icon,
  }

  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