/** * Copyright Aquera Inc 2023 * * This source code is licensed under the BSD-3-Clause license found in the * LICENSE file in the root directory of this source tree. */ import { CSSResultArray, TemplateResult } from 'lit'; import NileElement from '../internal/nile-element'; import { ClearMode } from './nile-calendar.enum'; import type { PropertyValueMap } from 'lit'; type NileCalendarDateRange = { startDate: string; endDate: string; }; type TimeUnits = 'minutes' | 'hours' | 'days' | 'weeks' | 'months'; /** A wall clock — digits on a clock face. Local time*/ export type CalendarWallClock = { year: number; /** 1–12 (January = 1), NOT the 0–11 month of JavaScript `Date`; subtract 1 before `new Date(...)`. */ month: number; day: number; hours: number; minutes: number; seconds: number; ms: number; }; export declare function instantFromValueString(raw: string | null | undefined): number | null; /** Digits as written, with no zone conversion. */ export declare function wallClockFromOffsetLess(raw: string | null | undefined): CalendarWallClock | null; export declare function wallClockInZone(epochMs: number, zone: string): CalendarWallClock; export declare function instantFromBracketedValue(raw: string | null | undefined): { epochMs: number; timezone: string; } | null; /** * Nile icon component. * * @tag nile-calendar * * @csspart calendar-container - The outer container. * @csspart calendar-switcher - The Absolute / Relative tab switcher. * @csspart button-container - The default variant's button row. * @csspart calendar-wrapper - Wraps the month grid. * @csspart trigger - The month and year dropdown triggers. * @csspart calendar-day-N - A day cell, where N is the day of the month. * @csspart current-date-dot - The marker on today's date. * * Parts that exist only in `variant="date-time-picker"`: * @csspart calendar-config - The row holding the type switcher. * @csspart calendar - One month's header and grid. * @csspart calendar-header - The month header row. * @csspart calendar-header-prev - The previous-month icon. * @csspart calendar-header-next - The next-month icon. * @csspart calendar-header-center - The month and year area. * @csspart days-container - The grid of day cells. * @csspart day-name - A weekday label (Sun, Mon, ...). * @csspart calendar-day-label - The number inside a day cell. * @csspart tp-chevron - The expand / collapse control. * @csspart tp-scroll-area - The scrolling area under the grid. * @csspart tp-scroll-content - The content inside the scrolling area. * @csspart tp-time-fields - The row of time inputs. * @csspart tp-time-field - One time input (hours, minutes, seconds, milliseconds). * @csspart tp-stepper - The up/down stepper inside a time input. * @csspart tp-stepper-btn - Either stepper button. * @csspart tp-stepper-btn-up - The increase button. * @csspart tp-stepper-btn-down - The decrease button. * @csspart tp-timezone - The timezone section. * @csspart tp-timezone-header - The timezone label row. * @csspart tp-timezone-label - The "Timezone" label. * @csspart tp-timezone-local-link - The "Use local timezone" link. * @csspart tp-timezone-select - The timezone select. * @csspart tp-footer - The footer. * @csspart tp-footer-actions - The Reset and Apply group. * @csspart tp-set-to-now-button - The "Set to now" button. * @csspart clear-button - The Reset button. * @csspart apply-button - The Apply button. */ export declare class NileCalendar extends NileElement { /** * The styles for NileCalendar * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]` */ static get styles(): CSSResultArray; valueAttribute: string | null; allowedDates: string; range: boolean; hideTypes: boolean; showTypes: boolean; doubleClickUnselect: boolean; allowClear: boolean; type: 'absolute' | 'relative'; selectedUnit: TimeUnits; selectedValue: number; hideDurationFields: String[]; showManualInputs: boolean; startYear: number; endYear: number; showMonthDropdown: boolean; showYearDropdown: boolean; dateFormat: string; structuredInput: boolean; startDate: Date | null; endDate: Date | null; isSelectingStart: boolean; hideInput: Boolean; value: Date | null; currentMonth: number; currentYear: number; allowedDatesLocal: NileCalendarDateRange | any; disabled: boolean; variant: 'default' | 'date-time-picker'; timezone: string; /** the timezone the consumer configured; Reset restores this (internal changes never overwrite it) */ private configuredTimezone; /** the zone the component itself is assigning, so updated() can tell it from a consumer change */ private internalTimezone; private setTimezoneInternally; hideTimeFields: string[]; /** every field shown, minus the keys in hideTimeFields (a non-array value counts as an empty list) */ private get resolvedTimeFields(); private get tpFewFieldsNoTz(); expanded: boolean; tpLockedHeight: string | null; tpHours: number | null; tpMinutes: number | null; tpSeconds: number | null; tpMilliseconds: number | null; tpFocusedTimeField: string | null; /** the day the keyboard last moved to; owns the grid's single tab stop (roving tabindex) */ tpFocusDate: { year: number; month: number; day: number; } | null; tpEditingText: string; private seedInstant; private seedFieldsKey; private seedZone; connectedCallback(): void; disconnectedCallback(): void; protected firstUpdated(): void; protected updated(changedProperties: PropertyValueMap | Map): void; private tpResizeObserver?; /** the `.base--date-time-picker` element the observer currently watches */ private tpObservedBase; private releasePanelObserver; /** (re)points the observer at the rendered panel; a no-op while it already watches that element */ private observeCollapsedBase; private captureCollapsedHeight; private measurePanel; private applyMonthYearDropdownAnimation; private get monthNames(); private get yearOptions(); private onMonthSelected; private onYearSelected; /** brings the currently-selected month/year option into view when a dropdown opens */ private scrollSelectedIntoView; private smoothScrollTo; checkValidAllowedDate(): void; /** * The year range month navigation enforces. An explicit `startYear` / `endYear` always wins; the date-time-picker * variant falls back to the dropdown's 2000-2050 for an unset side, while the default calendar leaves it open as published. */ private get minYear(); private get maxYear(); private isPrevDisabled; private isNextDisabled; private formatDate; private parseDate; private handleStartDateInput; private handleEndDateInput; private maskValuesMap; private boundMaskInputs; private unbindStructuredInput; private bindStructuredInput; private dateMaskSegments; private timeMaskSegments; private buildMaskLayout; private maskLayoutFor; private computeMaskDisplay; private initMaskValues; /** clamp a filled segment into range (year is left unclamped) */ private clampMaskSegment; private maskValuesFor; private onMaskKeydown; private onMaskBlur; /** * Render method */ render(): TemplateResult; /** * @returns HTML content for absolute calendar */ renderAbsoluteCalendar(): TemplateResult<1>; /** * @returns HTML content for relative calendar */ renderRelativeCalendar(): TemplateResult<1>; /** * * @param unit * @param values * @returns html for the option */ renderTimeValues(unit: TimeUnits, values: any[]): TemplateResult<1>[]; /** * * @param year * @param month * @param daysArray * @returns HTML for rendered month */ private renderMonth; /** * Function to validate if date is not in allowedDates range * @param day * @param month * @param year * @returns */ isAllowedDate(day: number, month: number, year: number): boolean; private dayCellLabel; clearDate(mode?: ClearMode): void; /** * @function handle_date-click/select * @param day * @param month * @param year */ selectDate(day: number, month: number, year: number): void; /** * Function to be called on initialization to set all other properties */ initializeValue(): void; /** Forget any retained instant, in every category. */ private clearInstantSeed; private instantSeedFieldsKey; private seedFromInstant; private trySeedFromInstantValue; /** * Seeds `value` from a string with the published conversion: `new Date(raw)` shifted by the host offset. Every variant * keeps it, because the default calendar must behave exactly as the published component; the date-time-picker variant * re-derives its value from its own parsers in `initializeValue`. */ private dateFromValueString; /** * One bound of a `range` value. In the date-time-picker variant `YYYY-MM-DD` is a calendar day, not a UTC instant: it * lands on that local day, at 00:00:00.000 for the start and 23:59:59.999 for the end (what clicking the day produces). * Every other string, and every bound of the default calendar, goes through `new Date(raw)` exactly as published. */ private rangeBoundFromValue; private parsePresetValue; private parseZonedValue; /** * Function to handle relative date selection */ handleDurationChange(event: CustomEvent): void; handleUnitChange(event: CustomEvent): void; handleTimeValueClick(unit: TimeUnits, value: number, event: any): void; createRelativePeriod(unit: String, value: number): { startDate: null; endDate: null; } | { startDate: Date; endDate: Date; }; /** * Function to handle start time selecion */ private handleStartTimeInput; /** * Function to handle end time selecion */ private handleEndTimeInput; private parseTime; private isValidTimeInput; private formatTime; private nextMonth; private prevMonth; private confimRange; onTypeChange(event: CustomEvent): void; getUTCDate(dateStr: any): Date; emitChangedData(data: { startDate: Date; endDate: Date; } | { value: any; } | null): void; private getDaysArray; private renderDateTimePicker; private renderDateTimePickerAbsolute; private renderExpandedCalendar; private renderCollapsedMonth; private renderVariantMonth; private getCollapsedWindowDays; private getFullMonthDays; /** * Arrow keys move by a day / week, Home and End to the week's first and last day, PageUp and PageDown by a month * (Shift: a year). The target is clamped to the month's length and to the year range; a day that the collapsed * three-week window does not show expands the calendar to reveal it. */ private handleDayNavigationKey; private moveDayFocus; private tpSelectDate; private resetTimeUnits; private renderTimeFields; private renderTimeField; private get timezoneOptions(); private renderTimezone; private handleTimezoneChange; private handleUseLocalTimezone; private toggleExpanded; private composeLocalTimezoneValue; private composeValueISO; private wallClockToInstant; private zoneOffsetMs; private hasSelection; private handleSetToNow; private handleApply; private handleReset; private emitDateTimePickerChange; } export default NileCalendar; declare global { interface HTMLElementTagNameMap { 'nile-calendar': NileCalendar; } }