--- import Icon from './Icon.astro' // A text field or inline block that Tabler's Datepicker plugin (in tabler.js) // turns into a calendar. The plugin wraps Vanilla Calendar Pro, which the page // loads through the vanilla-calendar-pro entry of pageLibs. interface Props { id?: string /** initial date as `YYYY-MM-DD` */ value?: string class?: string placeholder?: string /** input-icon layout; omit for a plain input */ layout?: 'icon' | 'icon-prepend' | undefined /** render the calendar in place instead of a popup */ inline?: boolean /** picking one date, any number of dates, or a start and an end */ selectionMode?: 'single' | 'multiple' | 'multiple-ranged' /** months shown side by side */ months?: number /** preselected dates as `YYYY-MM-DD`; a range is its start and end */ selectedDates?: string[] dateMin?: string dateMax?: string /** 0 = Sunday, 1 = Monday */ firstWeekday?: 0 | 1 | 2 | 3 | 4 | 5 | 6 placement?: 'left' | 'center' | 'right' | 'auto' /** name of the hidden input an inline calendar submits with a form */ name?: string } const { id, value, class: className, placeholder = 'Select a date', layout, inline = false, selectionMode, months, selectedDates, dateMin, dateMax, firstWeekday, placement, name, } = Astro.props const datepickerId = id ? `datepicker-${id}` : undefined const dataAttributes = { 'data-bs-toggle': 'datepicker', 'data-bs-inline': inline ? 'true' : undefined, 'data-bs-selection-mode': selectionMode, 'data-bs-display-months-count': months, 'data-bs-selected-dates': selectedDates ? JSON.stringify(selectedDates) : undefined, 'data-bs-date-min': dateMin, 'data-bs-date-max': dateMax, 'data-bs-first-weekday': firstWeekday, 'data-bs-placement': placement, } --- { inline ? (
{name && }
) : layout === 'icon' ? (
) : layout === 'icon-prepend' ? (
) : ( ) }