Class: Shadcn::NativeSelectComponent::OptgroupComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/shadcn/native_select_component.rb

Overview

Optgroup subcomponent

Instance Attribute Summary

Attributes inherited from BaseComponent

#class_name, #data, #html_options

Instance Method Summary collapse

Methods inherited from BaseComponent

#content

Methods included from Rails::Helpers::ClassNameHelper

#cn

Constructor Details

#initialize(label:, disabled: false, **options) ⇒ OptgroupComponent

Returns a new instance of OptgroupComponent.

Parameters:

  • label (String)

    Optgroup label

  • disabled (Boolean) (defaults to: false)

    Whether the optgroup is disabled



107
108
109
110
111
# File 'app/components/shadcn/native_select_component.rb', line 107

def initialize(label:, disabled: false, **options)
  super(**options)
  @label = label
  @disabled = disabled
end

Instance Method Details

#callObject



113
114
115
116
117
# File 'app/components/shadcn/native_select_component.rb', line 113

def call
  tag.optgroup(label: @label, disabled: @disabled || nil, **html_options.merge(build_data).compact) do
    safe_join(options)
  end
end