Class: ShadcnPhlexcomponents::SelectTrigger
- Defined in:
- lib/shadcn_phlexcomponents/components/select.rb
Constant Summary
Constants inherited from Base
Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER
Instance Method Summary collapse
- #default_attributes ⇒ Object
-
#initialize(id: nil, value: nil, placeholder: nil, aria_id: nil, **attributes) ⇒ SelectTrigger
constructor
A new instance of SelectTrigger.
- #view_template ⇒ Object
Methods inherited from Base
#before_template, #convert_collection_hash_to_struct, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child
Constructor Details
#initialize(id: nil, value: nil, placeholder: nil, aria_id: nil, **attributes) ⇒ SelectTrigger
Returns a new instance of SelectTrigger.
199 200 201 202 203 204 205 |
# File 'lib/shadcn_phlexcomponents/components/select.rb', line 199 def initialize(id: nil, value: nil, placeholder: nil, aria_id: nil, **attributes) @id = id @value = value @placeholder = placeholder @aria_id = aria_id super(**attributes) end |
Instance Method Details
#default_attributes ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/shadcn_phlexcomponents/components/select.rb', line 217 def default_attributes { type: "button", id: @id, role: "combobox", aria: { autocomplete: "none", expanded: false, controls: "#{@aria_id}-content", }, data: { placeholder: @placeholder, has_value: @value.present?.to_s, action: " click->select#toggle\n keydown.down->select#open:prevent\n keydown.space->select#open:prevent\n keydown.enter->select#open:prevent\n HEREDOC\n select_target: \"trigger\",\n },\n }\nend\n", |
#view_template ⇒ Object
207 208 209 210 211 212 213 214 215 |
# File 'lib/shadcn_phlexcomponents/components/select.rb', line 207 def view_template (**@attributes) do span(class: "pointer-events-none", data: { select_target: "triggerText" }) do @value || @placeholder end icon("chevron-down", class: "size-4 opacity-50 text-foreground") end end |