Class: BetterUi::General::Input::Select::SelectComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::General::Input::Select::SelectComponent
- Defined in:
- app/components/better_ui/general/input/select/select_component.rb
Constant Summary collapse
- BASE_SELECT_CLASSES =
"h-10 px-3 py-2 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm disabled:bg-gray-100 disabled:cursor-not-allowed"
Instance Attribute Summary collapse
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#multiple ⇒ Object
readonly
Returns the value of attribute multiple.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#options_html ⇒ Object
readonly
Returns the value of attribute options_html.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#selected ⇒ Object
readonly
Returns the value of attribute selected.
Instance Method Summary collapse
-
#initialize(name:, options:, selected: nil, required: false, disabled: false, multiple: false, options_html: {}, classes: '', **html_options) ⇒ SelectComponent
constructor
A new instance of SelectComponent.
Constructor Details
#initialize(name:, options:, selected: nil, required: false, disabled: false, multiple: false, options_html: {}, classes: '', **html_options) ⇒ SelectComponent
Returns a new instance of SelectComponent.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/components/better_ui/general/input/select/select_component.rb', line 20 def initialize(name:, options:, selected: nil, required: false, disabled: false, multiple: false, options_html: {}, classes: '', **) @name = name @type = :select @required = required @disabled = disabled @options = .map { |option| { value: option[:value], label: option[:label] } } @selected = selected @multiple = multiple @options_html = @classes = BASE_SELECT_CLASSES + classes puts "Optionssssssssssssssssssssssss: #{selected}" end |
Instance Attribute Details
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
8 9 10 |
# File 'app/components/better_ui/general/input/select/select_component.rb', line 8 def classes @classes end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
8 9 10 |
# File 'app/components/better_ui/general/input/select/select_component.rb', line 8 def disabled @disabled end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
8 9 10 |
# File 'app/components/better_ui/general/input/select/select_component.rb', line 8 def @html_options end |
#multiple ⇒ Object (readonly)
Returns the value of attribute multiple.
8 9 10 |
# File 'app/components/better_ui/general/input/select/select_component.rb', line 8 def multiple @multiple end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'app/components/better_ui/general/input/select/select_component.rb', line 8 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'app/components/better_ui/general/input/select/select_component.rb', line 8 def @options end |
#options_html ⇒ Object (readonly)
Returns the value of attribute options_html.
8 9 10 |
# File 'app/components/better_ui/general/input/select/select_component.rb', line 8 def @options_html end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
8 9 10 |
# File 'app/components/better_ui/general/input/select/select_component.rb', line 8 def required @required end |
#selected ⇒ Object (readonly)
Returns the value of attribute selected.
8 9 10 |
# File 'app/components/better_ui/general/input/select/select_component.rb', line 8 def selected @selected end |