Class: UI::Calendar
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::Calendar
- Includes:
- CalendarBehavior
- Defined in:
- app/components/ui/calendar.rb
Overview
Calendar component (Phlex) A date picker calendar with support for single, range, and multiple selection
Constant Summary
Constants included from CalendarBehavior
UI::CalendarBehavior::WEEKDAYS
Instance Method Summary collapse
-
#initialize(mode: :single, selected: nil, month: Date.today, number_of_months: 1, week_starts_on: 0, locale: "en-US", min_date: nil, max_date: nil, disabled_dates: [], show_outside_days: true, fixed_weeks: false, show_dropdowns: false, year_range: 100, min_range_days: 0, max_range_days: 0, exclude_disabled: false, use_native_select: true, name: nil, classes: "", **attributes) ⇒ Calendar
constructor
A new instance of Calendar.
- #view_template ⇒ Object
Methods included from CalendarBehavior
#aria_label_text, #calendar_classes, #calendar_data_attributes, #calendar_html_attributes, #disabled_dates_json, #ordered_weekdays, #selected_json, #selected_value, #use_native_select?
Constructor Details
#initialize(mode: :single, selected: nil, month: Date.today, number_of_months: 1, week_starts_on: 0, locale: "en-US", min_date: nil, max_date: nil, disabled_dates: [], show_outside_days: true, fixed_weeks: false, show_dropdowns: false, year_range: 100, min_range_days: 0, max_range_days: 0, exclude_disabled: false, use_native_select: true, name: nil, classes: "", **attributes) ⇒ Calendar
Returns a new instance of Calendar.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/components/ui/calendar.rb', line 40 def initialize( mode: :single, selected: nil, month: Date.today, number_of_months: 1, week_starts_on: 0, locale: "en-US", min_date: nil, max_date: nil, disabled_dates: [], show_outside_days: true, fixed_weeks: false, show_dropdowns: false, year_range: 100, min_range_days: 0, max_range_days: 0, exclude_disabled: false, use_native_select: true, name: nil, classes: "", **attributes ) @mode = mode @selected = selected @month = month @number_of_months = number_of_months @week_starts_on = week_starts_on @locale = locale @min_date = min_date @max_date = max_date @disabled_dates = disabled_dates @show_outside_days = show_outside_days @fixed_weeks = fixed_weeks @show_dropdowns = show_dropdowns @year_range = year_range @min_range_days = min_range_days @max_range_days = max_range_days @exclude_disabled = exclude_disabled @use_native_select = use_native_select @name = name @classes = classes @attributes = attributes super() end |
Instance Method Details
#view_template ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'app/components/ui/calendar.rb', line 85 def view_template div(**calendar_html_attributes) do # Screen reader live region for announcements div(class: "sr-only", aria_live: "polite", aria_atomic: "true", data: {ui__calendar_target: "liveRegion"}) # Hidden input for form submission if @name input(type: "hidden", name: @name, value: selected_value, data: {ui__calendar_target: "input"}) end @number_of_months.times do |i| render_month(i) end end end |