import type { DatePredicate } from '../calendar/Calendar.js'; import type { DateAdapter } from './date-adapter.js'; import { LitElement } from 'lit'; import { DaysOfWeek } from '../common/dates.js'; import '../input/Input.js'; import '../button/Button.js'; import '../visually-hidden/VisuallyHidden.js'; import '../popout/Popout.js'; import '../stack/Stack.js'; import '../calendar/Calendar.js'; declare const DatePicker_base: (new (...args: any[]) => import("../common/mixins/SizeMixin.js").SizeMixinInterface) & (new (...args: any[]) => import("../common/mixins/FormAssociatedMixin.js").FormAssociatedMixinInterface) & (new (...args: any[]) => import("../common/mixins/ReadonlyMixin.js").ReadonlyMixinInterface) & (new (...args: any[]) => import("../common/mixins/InputMixin.js").InputMixinInterface) & (new (...args: any[]) => import("../common/mixins/FocusableMixin.js").FocusableMixinInterface) & typeof LitElement; /** * * Date Picker allows user to enter a date either through text input, * or by choosing a date from the calendar. Please note that the date * must be passed in ISO-8601 format: YYYY-MM-DD. * * @status ready * @category form * * @fires {NordEvent} open - Dispatched when the popout is opened. * @fires {NordEvent} close - Dispatched when the popout is closed. * @fires {DateSelectEvent} nord-focus-date - Dispatched when the calendar's focused date changes. * * @localization modalHeading - Heading for the date picker's modal. * @localization closeLabel - Accessible label for the close button. * @localization buttonLabel - Accessible label for the toggle button that opens the date picker modal. * @localization selectedDateMessage - Describes the selected date. This message is appended to the toggle button label when a date is selected. * @localization dateOutOfMinBound - Error message shown when the entered date is below the minimum allowed date. * @localization dateOutOfMaxBound - Error message shown when the entered date is above the maximum allowed date. * * @cssprop [--n-label-color=var(--n-color-text)] - Controls the text color of the label, using our [color tokens](/tokens/#color). */ export default class DatePicker extends DatePicker_base { static styles: import("lit").CSSResult[]; private toggleButton; private closeButton; private calendar; private popout; private swipe; 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 dateFormatLong; /** * Date value. Must be in IS0-8601 format: YYYY-MM-DD. */ value: string; /** * Internal validation error message. Set automatically when min/max validation fails. * This is a read-only property that's managed by the component. */ internalError?: string; get valueAsDate(): Date | undefined; /** * Get/set the value of the picker as a Date object. */ set valueAsDate(date: Date | undefined); get valueAsNumber(): number; /** * Get/set the value of the picker as the number of milliseconds elapsed since the UNIX epoch. */ set valueAsNumber(date: number); /** * Get the raw value of the input field without date formatting. This is a read-only property. */ rawValue?: string; /** * Controls whether date picker dialog is open or not. */ open: boolean; /** * 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; /** * Which day is considered first day of the week? `0` for Sunday, `1` for Monday, etc. * Default is Monday. */ firstDayOfWeek: DaysOfWeek; /** * Date adapter, for custom parsing/formatting. * Must be object with a `parse` function which accepts a `string` and returns a `Date`, * and a `format` function which accepts a `Date` and returns a `string`. * Default is IS0-8601 parsing and formatting. */ dateAdapter: DateAdapter; /** * 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 `false` will not show an indicator. * Returning `true` will show the indicator, but without an accessible label. Therefore * Returning a string will show the indicator, and use the string as accessible label. * It is recommended to return a string rather than `true` whenever possible. */ isDateHighlighted: (date: Date) => string | boolean; /** * Controls whether the date picker expands to fill the width of its container. */ expand: boolean; firstUpdated(): void; render(): import("lit").TemplateResult<1>; private createDateFormatters; private focusFirst; private focusLast; private handleDaySelect; private handleOpen; private handleClose; private handleBlur; private handleFocus; private handleInputChange; private setValue; private validateDateBounds; /** * Hide the date picker programmatically. * @param moveFocusToButton A boolean option to move the focus to the original button that opens the popout. */ hide(moveFocusToButton?: boolean): void; /** * Show the date picker programmatically. */ show(): void; } declare global { interface HTMLElementTagNameMap { 'nord-date-picker': DatePicker; } } export {};