Class: Shadcn::Select::Value::Component

Inherits:
ApplicationViewComponent show all
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

Attributes inherited from ApplicationViewComponent

#attributes

Instance Method Summary collapse

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

#placeholderObject (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

#callObject



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