Class: Shadcn::RadioGroup::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::RadioGroup::Component
- Includes:
- Concerns::SubmitsValue
- Defined in:
- app/components/shadcn/radio_group/component.rb
Overview
Port of registry/new-york-v4/ui/radio-group.tsx
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(name: nil, value: nil, disabled: false, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods included from Concerns::SubmitsValue
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(name: nil, value: nil, disabled: false, **attributes) ⇒ Component
Returns a new instance of Component.
18 19 20 21 22 23 |
# File 'app/components/shadcn/radio_group/component.rb', line 18 def initialize(name: nil, value: nil, disabled: false, **attributes) @name = name @value = value.to_s @disabled = disabled super(**attributes) end |
Instance Attribute Details
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
16 17 18 |
# File 'app/components/shadcn/radio_group/component.rb', line 16 def disabled @disabled end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'app/components/shadcn/radio_group/component.rb', line 16 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
16 17 18 |
# File 'app/components/shadcn/radio_group/component.rb', line 16 def value @value end |
Instance Method Details
#call ⇒ Object
36 37 38 |
# File 'app/components/shadcn/radio_group/component.rb', line 36 def call render_element(body: safe_join([ items, content, hidden_input ].flatten.compact)) end |
#element_attributes(**defaults) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/components/shadcn/radio_group/component.rb', line 25 def element_attributes(**defaults) super(**{ role: "radiogroup", "aria-required" => nil, "data-disabled" => (true if disabled), "data-controller" => "shadcn--radio-group", "data-shadcn--radio-group-value-value" => value, "data-shadcn--radio-group-disabled-value" => disabled }.merge(defaults)) end |