Sha256: 4535e9aef88fae3a6f8387fa1f4115a8cb5b7c600c4d7ea1cbd1c3539d6c64d2

Contents?: true

Size: 1.41 KB

Versions: 20

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbTypeahead
    class Typeahead
      include Playbook::Props

      prop :async, type: Playbook::Props::Boolean,
                    default: false
      prop :default_options, type: Playbook::Props::HashArray, default: []
      prop :id
      prop :label
      prop :load_options
      prop :name
      prop :options, type: Playbook::Props::HashArray, default: []
      prop :pills, type: Playbook::Props::Boolean,
                    default: false

      prop :placeholder
      prop :search_term_minimum_length, default: 3
      prop :search_debounce_timeout, default: 250
      prop :value

      partial "pb_typeahead/typeahead"

      def classname
        generate_classname("pb_typeahead_kit")
      end

      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

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

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

        base_options
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
playbook_ui-7.9.0 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.8.4 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.8.3 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.8.2 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.8.1 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.8.0 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.7.0.pre.alpha1 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.7.0 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.6.2.pre.alpha1 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.6.2 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.6.1.pre.alpha1 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.6.1 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.6.0 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.5.1 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.5.0 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.4.2 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.4.1 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.4.0.pre.alpha5 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.4.0 app/pb_kits/playbook/pb_typeahead/typeahead.rb
playbook_ui-7.4.0.pre.test4 app/pb_kits/playbook/pb_typeahead/typeahead.rb