Class: Shadcn::Combobox::Clear::Component
- Inherits:
-
InputGroup::Button::Component
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Button::Component
- InputGroup::Button::Component
- Shadcn::Combobox::Clear::Component
- Defined in:
- app/components/shadcn/combobox/clear/component.rb
Overview
The X that empties the field. Upstream renders it through
InputGroupButton too, and hides the chevron whenever it is present —
which is what the trigger's
group-has-data-[slot=combobox-clear]/input-group:hidden does.
Constant Summary
Constants inherited from InputGroup::Button::Component
InputGroup::Button::Component::SIZES
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary
Attributes inherited from InputGroup::Button::Component
Attributes inherited from Button::Component
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(**attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from InputGroup::Button::Component
Methods inherited from Button::Component
#style_variants, variant_classes
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(**attributes) ⇒ Component
Returns a new instance of Component.
13 14 15 |
# File 'app/components/shadcn/combobox/clear/component.rb', line 13 def initialize(**attributes) super(variant: :ghost, size: :"icon-xs", **attributes) end |
Instance Method Details
#call ⇒ Object
26 27 28 |
# File 'app/components/shadcn/combobox/clear/component.rb', line 26 def call render_element(body: render(Icon::Component.new("x", class: "pointer-events-none"))) end |
#element_attributes(**defaults) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/components/shadcn/combobox/clear/component.rb', line 17 def element_attributes(**defaults) super(**{ "data-shadcn--combobox-target" => "clear", "data-action" => "click->shadcn--combobox#clear", tabindex: "-1", "aria-label" => shadcn_t("combobox.clear") }.merge(defaults)) end |