Class: ShadcnPhlexcomponents::SelectItem
- Defined in:
- lib/shadcn_phlexcomponents/components/select.rb
Constant Summary
Constants inherited from Base
Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER
Instance Method Summary collapse
- #default_attributes ⇒ Object
-
#initialize(value: nil, disabled: false, aria_id: nil, **attributes) ⇒ SelectItem
constructor
A new instance of SelectItem.
- #view_template ⇒ Object
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, disabled: false, aria_id: nil, **attributes) ⇒ SelectItem
Returns a new instance of SelectItem.
337 338 339 340 341 342 343 |
# File 'lib/shadcn_phlexcomponents/components/select.rb', line 337 def initialize(value: nil, disabled: false, aria_id: nil, **attributes) @value = value @disabled = disabled @aria_id = aria_id @aria_labelledby = "#{@aria_id}-#{@value.dasherize.parameterize}" super(**attributes) end |
Instance Method Details
#default_attributes ⇒ Object
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File 'lib/shadcn_phlexcomponents/components/select.rb', line 352 def default_attributes { role: "option", tabindex: -1, aria: { selected: false, labelledby: @aria_labelledby, }, data: { disabled: @disabled, value: @value, action: <<~HEREDOC, click->select#select mouseover->select#focusItem keydown.up->select#focusItem:prevent keydown.down->select#focusItem:prevent focus->select#onItemFocus blur->select#onItemBlur keydown.enter->select#select:prevent keydown.space->select#select:prevent mouseout->select#focusContent HEREDOC select_target: "item", }, } end |
#view_template ⇒ Object
345 346 347 348 349 350 |
# File 'lib/shadcn_phlexcomponents/components/select.rb', line 345 def view_template(&) div(**@attributes) do span(id: @aria_labelledby, &) SelectItemIndicator() end end |