Class: UI::DatePickerInputComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
DatePickerInputBehavior
Defined in:
app/view_components/ui/date_picker_input_component.rb

Overview

DatePicker Input ViewComponent An input field with calendar button for date picker.

Examples:

Basic usage

render UI::InputComponent.new(placeholder: "June 01, 2025")

Instance Method Summary collapse

Methods included from DatePickerInputBehavior

#date_picker_icon_button_classes, #date_picker_icon_button_data_attributes, #date_picker_input_classes, #date_picker_input_data_attributes, #date_picker_input_html_attributes

Constructor Details

#initialize(placeholder: "Select date", value: "", id: nil, classes: "", icon_classes: "", **attributes) ⇒ DatePickerInputComponent

Returns a new instance of DatePickerInputComponent.

Parameters:

  • placeholder (String) (defaults to: "Select date")

    Placeholder text

  • value (String) (defaults to: "")

    Initial input value

  • id (String) (defaults to: nil)

    Input ID for label association

  • classes (String) (defaults to: "")

    Additional CSS classes for input

  • icon_classes (String) (defaults to: "")

    Additional CSS classes for icon button

  • attributes (Hash)

    Additional HTML attributes



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/view_components/ui/date_picker_input_component.rb', line 18

def initialize(
  placeholder: "Select date",
  value: "",
  id: nil,
  classes: "",
  icon_classes: "",
  **attributes
)
  @placeholder = placeholder
  @value = value
  @id = id
  @classes = classes
  @icon_classes = icon_classes
  @attributes = attributes
end

Instance Method Details

#callObject



34
35
36
37
38
39
40
41
# File 'app/view_components/ui/date_picker_input_component.rb', line 34

def call
   :div, class: "relative flex gap-2" do
    safe_join([
      render_input,
      render_button
    ])
  end
end