Class: ShadcnPhlexcomponents::CommandItem

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(value: nil, aria_id: nil, **attributes) ⇒ CommandItem

Returns a new instance of CommandItem.



257
258
259
260
261
# File 'lib/shadcn_phlexcomponents/components/command.rb', line 257

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

Instance Method Details

#default_attributesObject



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/shadcn_phlexcomponents/components/command.rb', line 267

def default_attributes
  {
    role: "option",
    tabindex: -1,
    aria: {
      labelledby: @aria_labelledby,
    },
    data: {
      highlighted: "false",
      disabled: @disabled,
      value: @value,
      action: <<~HEREDOC,
        click->command#select
        mouseover->command#highlightItem
      HEREDOC
      command_target: "item",
    },
  }
end

#view_templateObject



263
264
265
# File 'lib/shadcn_phlexcomponents/components/command.rb', line 263

def view_template(&)
  div(**@attributes, &)
end