import { type DayOfWeek, type MapFunction, type Maybe } from '@dereekb/util'; import { type DateCellIndex, type DateCellTiming } from './date.cell'; import { type YearWeekCode, type YearWeekCodeGroupFactory } from './date.week'; /** * Converts the input index into the DayOfWeek that it represents. */ export type DateCellDayOfWeekFactory = MapFunction; /** * Creates a factory that maps a {@link DateCellIndex} to its corresponding {@link DayOfWeek}. * * @param inputDayForIndexZero - Calendar day that should be anchored at index 0. * @returns Factory that resolves any cell index to its day-of-week. * * @example * ```ts * import { Day } from '@dereekb/util'; * const dayFactory = dateCellDayOfWeekFactory(Day.MONDAY); * dayFactory(0); // Day.MONDAY * dayFactory(1); // Day.TUESDAY * dayFactory(6); // Day.SUNDAY * ``` * * @__NO_SIDE_EFFECTS__ */ export declare function dateCellDayOfWeekFactory(inputDayForIndexZero: DayOfWeek | Date): DateCellDayOfWeekFactory; /** * Used to return the proper YearWeekCode for the input DateCellIndex relative to the configured timing, or a Date. */ export type DateCellIndexYearWeekCodeFactory = (indexOrDate: DateCellIndex | Date) => YearWeekCode; export interface DateCellIndexYearWeekCodeConfig { readonly timing: DateCellTiming; } /** * Creates a factory that computes the {@link YearWeekCode} for a given {@link DateCellIndex} or Date, relative to the configured timing. * * @param config - Timing configuration to compute dates from indexes. * @returns Factory that resolves a cell index or date to its YearWeekCode. * * @__NO_SIDE_EFFECTS__ */ export declare function dateCellIndexYearWeekCodeFactory(config: DateCellIndexYearWeekCodeConfig): DateCellIndexYearWeekCodeFactory; /** * MapFunction that reads the relevant date to use for the YearWeekCode calculation from the input item. */ export type DateCellIndexYearWeekCodeReader = MapFunction>; export interface DateCellIndexYearWeekCodeGroupFactoryConfig { readonly dateCellIndexReader: DateCellIndexYearWeekCodeReader; readonly dateCellIndexYearWeekCodeFactory: DateCellIndexYearWeekCodeFactory | DateCellIndexYearWeekCodeConfig; } /** * Creates a factory that groups items by their {@link YearWeekCode} based on a DateCellIndex reader and timing. * * @param config - Reader and factory configuration. * @returns Grouper that buckets items by their YearWeekCode. * * @__NO_SIDE_EFFECTS__ */ export declare function dateCellIndexYearWeekCodeGroupFactory(config: DateCellIndexYearWeekCodeGroupFactoryConfig): YearWeekCodeGroupFactory;