Class: Shadcn::Select::Empty::Component

Inherits:
ApplicationViewComponent show all
Defined in:
app/components/shadcn/select/empty/component.rb

Overview

Shown when the filter matches nothing.

A sibling of the listbox rather than a child of it. shadcn's aria variant nests its empty state inside the list and gives it role="option" — an option that cannot be chosen — which is how React Aria's collection renders one. Outside the list the question does not arise, and a non-option inside a listbox is precisely the shape axe rejected while this component's structure was being chosen.

The classes are this gem's own. Upstream's are a single cn-select-empty-aria, defined across the themed sheets in registry/styles/, which this gem does not ship.

Constant Summary

Constants inherited from ApplicationViewComponent

ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary

Attributes inherited from ApplicationViewComponent

#attributes

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

#callObject



32
33
34
# File 'app/components/shadcn/select/empty/component.rb', line 32

def call
  render_element(body: content.presence || shadcn_t("select.empty"))
end

#element_attributes(**defaults) ⇒ Object



25
26
27
28
29
30
# File 'app/components/shadcn/select/empty/component.rb', line 25

def element_attributes(**defaults)
  super(**{
    hidden: true,
    "data-shadcn--select-target" => "empty"
  }.merge(defaults))
end