Class: PhlexKit::SelectValue
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::SelectValue
- Defined in:
- app/components/phlex_kit/select/select_value.rb
Overview
The text shown in a PhlexKit::SelectTrigger — the selected item's label (yielded
block) or the placeholder: when nothing is chosen. The Stimulus controller
rewrites this element's text on selection. See select.rb.
Instance Method Summary collapse
-
#initialize(placeholder: nil, **attrs) ⇒ SelectValue
constructor
A new instance of SelectValue.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(placeholder: nil, **attrs) ⇒ SelectValue
Returns a new instance of SelectValue.
6 7 8 9 |
# File 'app/components/phlex_kit/select/select_value.rb', line 6 def initialize(placeholder: nil, **attrs) @placeholder = placeholder @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/components/phlex_kit/select/select_value.rb', line 11 def view_template(&block) span(**mix({ class: "pk-select-value", data: { phlex_kit__select_target: "value" } }, @attrs)) do if block yield elsif @placeholder plain @placeholder end end end |