Class: Shadcn::DatePickerComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Shadcn::DatePickerComponent
- Defined in:
- app/components/shadcn/date_picker_component.rb
Overview
Date Picker component - a button that opens a calendar popover Composition of Popover and Calendar components Matches shadcn/ui Date Picker component
Constant Summary collapse
- TRIGGER_CLASSES =
"inline-flex items-center justify-start whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground h-9 px-4 py-2 w-[240px] pl-3 text-left"- PLACEHOLDER_CLASSES =
"text-muted-foreground"- CONTENT_CLASSES =
"p-0 w-auto"- MONTHS =
%w[January February March April May June July August September October November December].freeze
Instance Attribute Summary
Attributes inherited from BaseComponent
#class_name, #data, #html_options
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(selected: nil, month: nil, min_date: nil, max_date: nil, name: nil, disabled_dates: [], disabled_days_of_week: [], show_outside_days: true, week_starts_on: 0, placeholder: "Pick a date", format: :medium, disabled: false, **options) ⇒ DatePickerComponent
constructor
A new instance of DatePickerComponent.
Methods inherited from BaseComponent
Methods included from Rails::Helpers::ClassNameHelper
Constructor Details
#initialize(selected: nil, month: nil, min_date: nil, max_date: nil, name: nil, disabled_dates: [], disabled_days_of_week: [], show_outside_days: true, week_starts_on: 0, placeholder: "Pick a date", format: :medium, disabled: false, **options) ⇒ DatePickerComponent
Returns a new instance of DatePickerComponent.
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 |
# File 'app/components/shadcn/date_picker_component.rb', line 42 def initialize( selected: nil, month: nil, min_date: nil, max_date: nil, name: nil, disabled_dates: [], disabled_days_of_week: [], show_outside_days: true, week_starts_on: 0, placeholder: "Pick a date", format: :medium, disabled: false, ** ) super(**) @selected = selected @month = month || selected || Date.today @min_date = min_date @max_date = max_date @name = name @disabled_dates = disabled_dates @disabled_days_of_week = disabled_days_of_week @show_outside_days = show_outside_days @week_starts_on = week_starts_on @placeholder = placeholder @format = format @disabled = disabled end |
Instance Method Details
#call ⇒ Object
72 73 74 |
# File 'app/components/shadcn/date_picker_component.rb', line 72 def call content_tag(:div, picker_content, picker_attributes) end |