Class: ShadcnPhlexcomponents::CommandSearchInput

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/command.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) ⇒ CommandSearchInput

Returns a new instance of CommandSearchInput.



434
435
436
437
438
# File 'lib/shadcn_phlexcomponents/components/command.rb', line 434

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_attributesObject



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'lib/shadcn_phlexcomponents/components/command.rb', line 440

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: {
      command_target: "searchInput",
      action: "keydown->command#inputKeydown input->command#search",
    },
  }
end

#view_templateObject



462
463
464
# File 'lib/shadcn_phlexcomponents/components/command.rb', line 462

def view_template(&)
  input(**@attributes)
end