igniteui-webcomponents
Version:
Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.
116 lines (115 loc) • 4.22 kB
TypeScript
import { type DatePart, DatePartType, type IDatePart } from '../date-time-input/date-part.js';
import { type DateTimeMaskOptions } from '../date-time-input/datetime-mask-parser.js';
import { MaskParser } from '../mask-input/mask-parser.js';
import type { DateRangeValue } from '../types.js';
/**
* @ignore
*/
export interface DateRangePart {
part: DatePart;
position: DateRangePosition;
}
/**
* @ignore
* Position of a date part within the date range
*/
export declare enum DateRangePosition {
Start = "start",
End = "end",
Separator = "separator"
}
/**
* @ignore
* Extended date part with range position information
*/
export interface IDateRangePart extends IDatePart {
position: DateRangePosition;
}
/** Options for the DateRangeMaskParser */
export interface DateRangeMaskOptions extends DateTimeMaskOptions {
/** Separator (defaults to ' - ') */
separator?: string;
}
/**
* A specialized mask parser for date range input fields.
* Uses composition with two DateTimeMaskParser instances to handle start and end dates.
*
* Accepts a single date format (e.g., 'MM/dd/yyyy') which creates two parsers
* internally, one for the start date and one for the end date.
*
* @example
* ```ts
* const parser = new DateRangeMaskParser({ format: 'MM/dd/yyyy' });
* parser.parseDateRange('12/25/2023 - 12/31/2023'); // Returns DateRangeValue
* parser.formatDateRange({ start: date1, end: date2 }); // Returns formatted string
* ```
*/
export declare class DateRangeMaskParser extends MaskParser {
private _startParser;
private _endParser;
/** Cached date range parts with position information */
private _rangeParts;
/** The separator between start and end dates */
private _separator;
/** Start position of the separator in the mask */
private _separatorStart;
/** End position of the separator in the mask */
private _separatorEnd;
/**
* Gets the parsed date range parts with position information.
*/
get rangeParts(): ReadonlyArray<IDateRangePart>;
/**
* Gets the separator string used between start and end dates.
*/
get separator(): string;
constructor(options?: DateRangeMaskOptions);
/**
* Overrides base class to convert date format to mask format
* before parsing literals. This ensures date format characters
* (M, d, y, etc.) are properly converted to mask characters (0, L).
*/
protected _parseMaskLiterals(): void;
/**
* Builds the range parts array by combining parts from start and end parsers
* and adding position information.
*/
private _buildRangeParts;
/**
* Sets a new date format and updates both parsers.
*/
set mask(value: string);
get mask(): string;
/**
* Parses a masked string into a DateRangeValue using the two internal parsers.
* Returns null if the string cannot be parsed.
*/
parseDateRange(masked: string): DateRangeValue | null;
/**
* Formats a DateRangeValue into a masked string using the two internal parsers.
*/
formatDateRange(range: DateRangeValue | null): string;
/**
* Gets the date range part at a cursor position.
* Uses exclusive end for precise character targeting.
*/
getDateRangePartAtPosition(position: number): IDateRangePart | undefined;
/**
* Gets the date range part for cursor (inclusive end).
* Handles the edge case where cursor is at the end of the last part.
*/
getDateRangePartForCursor(position: number): IDateRangePart | undefined;
/**
* Gets a specific part type for a position.
*/
getPartByTypeAndPosition(type: DatePartType, position: DateRangePosition): IDateRangePart | undefined;
/**
* Gets the first non-literal date part for a position.
*/
getFirstDatePartForPosition(position: DateRangePosition): IDateRangePart | undefined;
/**
* Spins a date part within the range (for stepUp/stepDown functionality).
* Delegates to the underlying date part's spin method.
*/
spinDateRangePart(part: IDateRangePart, delta: number, currentValue: DateRangeValue | null, spinLoop: boolean, amPmValue?: string): DateRangeValue;
}