Calendar
Properties
- value
(Date | string | null)
:
The date value that can be passed as a Date object or a string. If it's a string, it will be converted to a Date
object. If null
, the calendar displays the current date.
- interval
(null | {start: Date | null, end: Date | null})
:
The range of dates that can be highlighted in the calendar. The start and end fields indicate the beginning and end of the interval, respectively.
- withTime
(boolean)
:
If true, the calendar will include a time input field (hours and minutes).
- timePlaceholder
(string)
:
Placeholder text for the time input field, e.g., '00:00'
. Used if the withTime
option is enabled.
- onInput
*(function(date: Date))
:
A handler that is called when a date is selected. It passes a Date
object with the selected date.
Events
- prevHandler:
Click handler for the "Previous Month" button. Decreases the current month by one.
- nextHandler:
Click handler for the "Next Month" button. Increases the current month by one.
- monthHandler
(InputEvent)
:
Handler for changing the month via a dropdown list. Updates the displayed month in the calendar.
- yearHandler
(InputEvent)
:
Handler for changing the year via a dropdown list. Updates the displayed year in the calendar.
- selectHandler
(Date)
:
Handler for selecting a specific day in the calendar. Updates the selected date considering the current time and interval.
- timeBlurHandler:
Handler that is called when the time field loses focus. Converts the entered time into hours and minutes and updates the selected date.
- timeFocusHandler:
Handler for focusing on the time field. Automatically selects all content in the field when focused.
- timeKeyDownHandler:
Handler for key events in the time field.
Internal Functions
- parseTime
(time: string)
:
Converts a time string (e.g., '1300' or '13:00') into an object with hours and minutes fields. Returns null
if the entered time is invalid.
- select
(date: Date)
:
Calls the provided onInput
handler with the updated date.