@oslokommune/punkt-elements
Version:
Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo
78 lines (77 loc) • 3.9 kB
TypeScript
import { Ref } from 'lit/directives/ref.js';
import { PktCalendar } from '../calendar/calendar';
/**
* Utility functions for PktDatepicker component
*
* This module provides helper functions organized by concern.
* Framework-agnostic functions are delegated to shared-utils/datepicker-utils.
* Lit-specific functions (using Ref, ElementInternals, PktCalendar) stay here.
*/
/**
* Value parsing and validation utilities
* Delegates to shared-utils/datepicker-utils
*/
export declare const valueUtils: {
validateRangeOrder: (values: string[]) => boolean;
sortDates: (dates: string[]) => string[];
filterSelectableDates: (dates: string[], min?: string | null, max?: string | null, excludedDates?: string[], excludedWeekdays?: string[]) => string[];
};
/**
* Input type detection utilities
* Delegates to shared-utils/datepicker-utils
*/
export declare const inputTypeUtils: {
getInputType: () => string;
};
/**
* Form and validation utilities (Lit-specific — uses ElementInternals)
*/
export declare const formUtils: {
submitForm(element: HTMLElement): void;
submitFormOrFallback(internals: any, fallbackAction: () => void): void;
validateDateInput(input: HTMLInputElement, internals: any, min?: string | null, max?: string | null, strings?: any): void;
};
/**
* Calendar interaction utilities
* handleCalendarPosition delegates to shared-utils (with Lit ref unwrapping).
* addToSelected stays Lit-specific (uses Ref<PktCalendar>).
*/
export declare const calendarUtils: {
addToSelected(event: Event | KeyboardEvent, calendarRef: Ref<PktCalendar>, min?: string | null, max?: string | null): void;
handleCalendarPosition(popupRef: Ref<HTMLDivElement>, inputRef: Ref<HTMLInputElement>, hasCounter?: boolean): void;
};
/**
* Event handling utilities (Lit-specific — uses Lit Ref types)
*/
export declare const eventUtils: {
createDocumentClickListener(inputRef: Ref<HTMLInputElement>, inputRefTo: Ref<HTMLInputElement> | null, btnRef: Ref<HTMLButtonElement>, getCalendarOpen: () => boolean, onBlur: () => void, hideCalendar: () => void): (e: MouseEvent) => void;
createDocumentKeydownListener(getCalendarOpen: () => boolean, hideCalendar: () => void): (e: KeyboardEvent) => void;
handleFocusOut(event: FocusEvent, element: HTMLElement, onBlur: () => void, hideCalendar: () => void): void;
};
/**
* CSS class utilities
* Delegates to shared-utils/datepicker-utils
*/
export declare const cssUtils: {
getInputClasses: (fullwidth: boolean, showRangeLabels: boolean, multiple: boolean, range: boolean, readonly?: boolean, inputType?: string) => Record<string, boolean>;
getButtonClasses: () => Record<string, boolean>;
getRangeLabelClasses: (showRangeLabels: boolean) => Record<string, boolean>;
};
/**
* Date value processing utilities
* processDateSelection delegates to shared-utils.
* updateInputValues and processRangeBlur stay Lit-specific (use Lit Ref).
*/
export declare const dateProcessingUtils: {
processDateSelection: (detail: string | string[], multiple: boolean, range: boolean) => string;
updateInputValues(inputRef: Ref<HTMLInputElement>, inputRefTo: Ref<HTMLInputElement> | null, values: string[], range: boolean, multiple: boolean, manageValidity: (input: HTMLInputElement) => void): void;
processRangeBlur(event: Event, values: string[], calendarRef: Ref<PktCalendar>, clearInputValue: () => void, manageValidity: (input: HTMLInputElement) => void): void;
};
/**
* Keyboard navigation utilities
* Delegates to shared-utils/datepicker-utils
*/
export declare const keyboardUtils: {
handleInputKeydown: (event: KeyboardEvent, toggleCalendar: (e: Event) => void, submitForm?: () => void, focusNextInput?: () => void, blurInput?: () => void, commaHandler?: (e: KeyboardEvent) => void) => void;
handleButtonKeydown: (event: KeyboardEvent, toggleCalendar: (e: Event) => void) => void;
};