Class: EasyAdmin::DatePickerComponent
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- EasyAdmin::DatePickerComponent
- Defined in:
- app/components/easy_admin/date_picker_component.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name:, value: nil, label: nil, **options) ⇒ DatePickerComponent
constructor
A new instance of DatePickerComponent.
- #view_template ⇒ Object
Constructor Details
#initialize(name:, value: nil, label: nil, **options) ⇒ DatePickerComponent
Returns a new instance of DatePickerComponent.
5 6 7 8 9 10 |
# File 'app/components/easy_admin/date_picker_component.rb', line 5 def initialize(name:, value: nil, label: nil, **) @name = name @value = value @label = label = end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
3 4 5 |
# File 'app/components/easy_admin/date_picker_component.rb', line 3 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'app/components/easy_admin/date_picker_component.rb', line 3 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'app/components/easy_admin/date_picker_component.rb', line 3 def end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'app/components/easy_admin/date_picker_component.rb', line 3 def value @value end |
Instance Method Details
#view_template ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/components/easy_admin/date_picker_component.rb', line 12 def view_template div( class: "relative", data: { controller: "date-picker" } ) do if label label(for: input_id, class: "block text-sm font-medium text-gray-700 mb-1") { plain label } end div(class: "relative") do input( type: "text", id: input_id, name: name, value: formatted_value, class: input_classes, placeholder: [:placeholder] || "Select date", readonly: true, data: { date_picker_target: "input", action: "click->date-picker#toggle focus->date-picker#toggle" } ) div(class: "absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-gray-400") do calendar_icon end end render_date_picker_modal end end |