Class: PhlexKit::Calendar
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Calendar
- Defined in:
- app/components/phlex_kit/calendar/calendar.rb
Overview
Calendar (month grid with day selection), ported from ruby_ui's RubyUI::Calendar and extended to shadcn/ui's current calendar surface. Renders the header (title or month/year dropdown caption + prev/next), the
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/components/phlex_kit/calendar/calendar.rb', line 25 def initialize(mode: :single, selected_date: nil, selected_dates: [], range_start: nil, range_end: nil, min_date: nil, max_date: nil, disabled_dates: [], week_numbers: false, caption_layout: :label, from_year: nil, to_year: nil, input_id: nil, date_format: "yyyy-MM-dd", **attrs) @mode = MODES.fetch(mode.to_sym) @selected_date = selected_date @selected_dates = Array(selected_dates).map(&:to_s) @range_start = range_start @range_end = range_end @min_date = min_date @max_date = max_date @disabled_dates = Array(disabled_dates).map(&:to_s) @week_numbers = week_numbers @caption_layout = caption_layout.to_sym raise ArgumentError, "caption_layout must be :label or :dropdown" unless CAPTION_LAYOUTS.include?(@caption_layout) @from_year = from_year @to_year = to_year @input_id = input_id @date_format = date_format @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/components/phlex_kit/calendar/calendar.rb', line 47 def view_template div(**mix(calendar_attrs, @attrs)) do render CalendarHeader.new do if @caption_layout == :dropdown render_dropdown_caption else render CalendarTitle.new end render CalendarPrev.new render CalendarNext.new end render CalendarBody.new # Where the calendar is rendered (Weekdays and Days) render CalendarWeekdays.new(week_numbers: @week_numbers) # Template for the weekdays render CalendarDays.new # Templates for the day states end end |