Class: ShadcnPhlexcomponents::DatePickerInput

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/date_picker.rb

Constant Summary

Constants inherited from Base

Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER

Instance Method Summary collapse

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, placeholder: nil, format: nil, disabled: false, stimulus_controller_name: nil, aria_id: nil, **attributes) ⇒ DatePickerInput

Returns a new instance of DatePickerInput.



271
272
273
274
275
276
277
278
279
# File 'lib/shadcn_phlexcomponents/components/date_picker.rb', line 271

def initialize(id: nil, placeholder: nil, format: nil, disabled: false, stimulus_controller_name: nil, aria_id: nil, **attributes)
  @id = id
  @placeholder = placeholder
  @format = format
  @disabled = disabled
  @stimulus_controller_name = stimulus_controller_name
  @aria_id = aria_id
  super(**attributes)
end

Instance Method Details

#default_attributesObject



281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/shadcn_phlexcomponents/components/date_picker.rb', line 281

def default_attributes
  {
    id: @id || "#{@aria_id}-input",
    placeholder: @placeholder || @format,
    type: :text,
    disabled: @disabled,
    data: {
      "#{@stimulus_controller_name}-target" => "input",
      action: "input->#{@stimulus_controller_name}#inputDate
                blur->#{@stimulus_controller_name}#inputBlur
                focus->#{@stimulus_controller_name}#setContainerFocus",
    },
  }
end

#view_templateObject



296
297
298
# File 'lib/shadcn_phlexcomponents/components/date_picker.rb', line 296

def view_template
  input(**@attributes)
end