Class: StimulusPlumbers::Components::Combobox::Date
- Inherits:
-
Plumber::Base
- Object
- Plumber::Base
- StimulusPlumbers::Components::Combobox::Date
- Defined in:
- lib/stimulus_plumbers/components/combobox/date.rb
Constant Summary collapse
- STIMULUS_CONTROLLER =
"combobox-date"- CALENDAR_OUTLET =
"#{STIMULUS_CONTROLLER}-calendar-month-outlet".freeze
Constants included from Plumber::HtmlOptions
Plumber::HtmlOptions::STIMULUS_SPACEJOIN_KEYS
Instance Attribute Summary
Attributes inherited from Plumber::Base
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Plumber::Base
Methods included from Plumber::HtmlOptions
#merge_data_options, #merge_html_options, #merge_string_option, #normalize_part
Constructor Details
This class inherits a constructor from StimulusPlumbers::Plumber::Base
Class Method Details
.default_opts ⇒ Object
10 11 12 13 14 15 |
# File 'lib/stimulus_plumbers/components/combobox/date.rb', line 10 def self.default_opts { input: { data: { combobox_date_date_value: nil } }, popover: { label: "Picker", role: "dialog", tag: :div } } end |
Instance Method Details
#render(value: nil, **_kwargs) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/stimulus_plumbers/components/combobox/date.rb', line 17 def render(value: nil, **_kwargs) calendar_id = "combobox_date_#{SecureRandom.hex(8)}_calendar" data = { controller: STIMULUS_CONTROLLER, CALENDAR_OUTLET => "##{calendar_id}", action: [ "calendar-month-observer:selected->#{STIMULUS_CONTROLLER}#onSelect", "#{STIMULUS_CONTROLLER}:selected->#{Combobox::STIMULUS_CONTROLLER}#onSelect" ].join(" "), "#{STIMULUS_CONTROLLER}-date-value" => value }.compact template.content_tag(:div, data: data) do template.safe_join([, calendar_month(id: calendar_id)]) end end |