Class: ShadcnPhlexcomponents::ComboboxSearchInput

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/combobox.rb

Constant Summary

Constants inherited from Base

Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#before_template, #convert_collection_hash_to_struct, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child

Constructor Details

#initialize(aria_id: nil, search_placeholder_text: nil, **attributes) ⇒ ComboboxSearchInput

Returns a new instance of ComboboxSearchInput.



510
511
512
513
514
# File 'lib/shadcn_phlexcomponents/components/combobox.rb', line 510

def initialize(aria_id: nil, search_placeholder_text: nil, **attributes)
  @aria_id = aria_id
  @search_placeholder_text = search_placeholder_text
  super(**attributes)
end

Instance Method Details

#default_attributes ⇒ Object



516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
# File 'lib/shadcn_phlexcomponents/components/combobox.rb', line 516

def default_attributes
  {
    id: "#{@aria_id}-search",
    placeholder: @search_placeholder_text,
    type: :text,
    autocomplete: "off",
    autocorrect: "off",
    role: "combobox",
    spellcheck: "false",
    aria: {
      autocomplete: "list",
      expanded: "false",
      controls: "#{@aria_id}-list",
      labelledby: "#{@aria_id}-search-label",
    },
    data: {
      combobox_target: "searchInput",
      action: "keydown->combobox#inputKeydown input->combobox#search",
    },
  }
end

#view_template ⇒ Object



538
539
540
# File 'lib/shadcn_phlexcomponents/components/combobox.rb', line 538

def view_template
  input(**@attributes)
end