Class: Shadcn::Item::Group::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Item::Group::Component
- Defined in:
- app/components/shadcn/item/group/component.rb
Overview
ItemGroup. Only a data-slot and classes apart from role="list",
which is why it is not a part — the macro declares no attributes.
role="list" obliges its children to be role="listitem", and Item
carries no role. Adding one to Item itself would deviate from
upstream's markup, so it is added here instead, through the items
slot — the same layer the FormBuilder uses to supply the accessible
name that Select and Switch cannot give themselves. A bare
Item::Component, rendered outside this slot, still carries no role,
exactly as upstream has it.
ItemSeparator goes through the same slot rather than the block:
items renders before block content (see Card::Component), so a
separator placed as plain block content between two with_item calls
would land after both of them instead of between them — the trap
CLAUDE.md warns about. A polymorphic slot keeps both in the one
ordered collection, where call order is preserved, and gives the
separator its own setter (with_separator) rather than a flag that
would otherwise let Item attributes reach a role="none" element.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #initialize, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
This class inherits a constructor from Shadcn::ApplicationViewComponent
Instance Method Details
#call ⇒ Object
47 48 49 |
# File 'app/components/shadcn/item/group/component.rb', line 47 def call render_element(body: safe_join([ *items, content ].compact)) end |
#element_attributes(**defaults) ⇒ Object
43 44 45 |
# File 'app/components/shadcn/item/group/component.rb', line 43 def element_attributes(**defaults) super(**{ role: "list" }.merge(defaults)) end |