import { LitElement } from 'lit'; import { DaysOfWeek } from '../common/dates.js'; import '../button/Button.js'; import '../visually-hidden/VisuallyHidden.js'; export type DatePredicate = (date: Date) => boolean; /** * Calendar allows user to pick a date. It comes with built-in * functionality that allows you to set a minimum and a maximum allowed date. * Please note that the date must be passed in ISO-8601 format. * * @status ready * @category list * @fires {DateSelectEvent} change - Dispatched when a date is selected and the value changes. * @fires {DateSelectEvent} nord-focus-date - Dispatched when the calendar's focused date changes. * * @cssprop [--n-calendar-border-radius=var(--n-border-radius)] - Controls how rounded the corners are, using [border radius tokens](/tokens/#border-radius). * @cssprop [--n-calendar-box-shadow=var(--n-box-shadow-popout)] - Controls the surrounding shadow, using [box shadow tokens](/tokens/#box-shadow). * * @localization prevMonthLabel - Accessible label for the previous month button. * @localization nextMonthLabel - Accessible label for the next month button. * @localization monthSelectLabel - Accessible label for the month select. * @localization yearSelectLabel - Accessible label for the year select. */ export default class Calendar extends LitElement { static styles: import("lit").CSSResult[]; private monthSelectNode; private focusedDayNode; private direction; private swipe; private shortcuts; private localize; /** * Whilst dateAdapter is used for handling the formatting/parsing dates in the input, * these are used to format dates exclusively for the benefit of screen readers. * * We prefer DateTimeFormat over date.toLocaleDateString, as the former has * better performance when formatting large number of dates. See: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString#Performance */ private dateFormatShort; private monthNames; private monthNamesShort; private dayNames; private dayNamesShort; /** * The selected date on the calendar. Must be in IS0-8601 format: YYYY-MM-DD. */ value: string; /** * Which day is considered first day of the week? `0` for Sunday, `1` for Monday, etc. * Default is Monday. */ firstDayOfWeek: DaysOfWeek; /** * Minimum date allowed to be picked. Must be in IS0-8601 format: YYYY-MM-DD. * This setting can be used alone or together with the max property. */ min?: string; /** * Maximum date allowed to be picked. Must be in IS0-8601 format: YYYY-MM-DD. * This setting can be used alone or together with the min property. */ max?: string; /** * The date that is considered today. Must be in IS0-8601 format: YYYY-MM-DD. * If not set, the current local date of the user is used. */ today?: string; /** * Controls whether the calendar expands to fill the width of its container. */ expand: boolean; /** * Controls which days are disabled and therefore disallowed. * For example, this can be used to disallow selection of weekends. */ isDateDisabled: DatePredicate; /** * Controls which days are highlighted with a small indicator. * Returning a "falsy" value will not show an indicator. * Returning "truthy" value will show the indicator, but without an accessible label. * Returning a string will show the indicator, and use the string as accessible label. * It is recommended to return a string rather than a truthy value whenever possible. */ isDateHighlighted: (date: Date) => string | boolean; private activeFocus; private focusedDay; /** * Programmatically move focus to the calendar. * @param options An object which controls aspects of the focusing process. */ focus(options?: FocusOptions & { target: 'day' | 'month'; }): void; render(): import("lit").TemplateResult<1>; protected handleValueChange(): void; protected handleFocusedDayChange(): void; private handleLangChange; private handleDaySelect; private getToday; private addDays; private addMonths; private addYears; private startOfWeek; private endOfWeek; private setMonth; private setYear; private setFocusedDay; private handleMonthSelect; private handleYearSelect; private handleNextMonthClick; private handlePreviousMonthClick; private enableActiveFocus; private disableActiveFocus; } declare global { interface HTMLElementTagNameMap { 'nord-calendar': Calendar; } }