Class: Shadcn::Select::Value::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Select::Value::Component
- Defined in:
- app/components/shadcn/select/value/component.rb
Overview
SelectValue — the controller writes the chosen item's label in here.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#placeholder ⇒ Object
readonly
Returns the value of attribute placeholder.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(placeholder: nil, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(placeholder: nil, **attributes) ⇒ Component
Returns a new instance of Component.
13 14 15 16 |
# File 'app/components/shadcn/select/value/component.rb', line 13 def initialize(placeholder: nil, **attributes) @placeholder = placeholder super(**attributes) end |
Instance Attribute Details
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
11 12 13 |
# File 'app/components/shadcn/select/value/component.rb', line 11 def placeholder @placeholder end |
Instance Method Details
#call ⇒ Object
22 23 24 |
# File 'app/components/shadcn/select/value/component.rb', line 22 def call render_element(body: content.presence || placeholder) end |
#element_attributes(**defaults) ⇒ Object
18 19 20 |
# File 'app/components/shadcn/select/value/component.rb', line 18 def element_attributes(**defaults) super(**{ "data-shadcn--select-target" => "value" }.merge(defaults)) end |