Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
import { BoxProps, ElementProps, Factory, StylesApiProps } from '@mantine/core';
import { CalendarLevel, DateStringValue } from '../../types';
import { DecadeLevelSettings } from '../DecadeLevel';
import { DecadeLevelGroupStylesNames } from '../DecadeLevelGroup';
import { MonthLevelSettings } from '../MonthLevel';
import { MonthLevelGroupStylesNames } from '../MonthLevelGroup';
import { YearLevelSettings } from '../YearLevel';
import { YearLevelGroupStylesNames } from '../YearLevelGroup';
export type CalendarStylesNames = MonthLevelGroupStylesNames | YearLevelGroupStylesNames | DecadeLevelGroupStylesNames;
export interface CalendarAriaLabels {
monthLevelControl?: string;
yearLevelControl?: string;
nextMonth?: string;
previousMonth?: string;
nextYear?: string;
previousYear?: string;
nextDecade?: string;
previousDecade?: string;
}
type OmittedSettings = 'onNext' | 'onPrevious' | 'onLevelClick' | 'withNext' | 'withPrevious' | 'nextDisabled' | 'previousDisabled' | 'hasNextLevel';
export interface CalendarSettings extends Omit<DecadeLevelSettings, OmittedSettings>, Omit<YearLevelSettings, OmittedSettings>, Omit<MonthLevelSettings, OmittedSettings> {
/** Initial displayed level in uncontrolled mode */
defaultLevel?: CalendarLevel;
/** Current displayed level displayed in controlled mode */
level?: CalendarLevel;
/** Called when level changes */
onLevelChange?: (level: CalendarLevel) => void;
/** Called when user selects year */
onYearSelect?: (date: DateStringValue) => void;
/** Called when user selects month */
onMonthSelect?: (date: DateStringValue) => void;
/** Called when mouse enters year control */
onYearMouseEnter?: (event: React.MouseEvent<HTMLButtonElement>, date: DateStringValue) => void;
/** Called when mouse enters month control */
onMonthMouseEnter?: (event: React.MouseEvent<HTMLButtonElement>, date: DateStringValue) => void;
}
export interface CalendarBaseProps {
__staticSelector?: string;
/** Prevents focus shift when buttons are clicked */
__preventFocus?: boolean;
/** Determines whether date should be updated when year control is clicked */
__updateDateOnYearSelect?: boolean;
/** Determines whether date should be updated when month control is clicked */
__updateDateOnMonthSelect?: boolean;
/** Assigns function to set date to the given ref */
__setDateRef?: React.RefObject<((date: DateStringValue) => void) | null>;
/** Assigns function to set level to the given ref */
__setLevelRef?: React.RefObject<((level: CalendarLevel) => void) | null>;
/** Initial displayed date in uncontrolled mode */
defaultDate?: DateStringValue | Date;
/** Displayed date in controlled mode */
date?: DateStringValue | Date;
/** Called when date changes */
onDateChange?: (date: DateStringValue) => void;
/** Number of columns displayed next to each other @default `1` */
numberOfColumns?: number;
/** Number of columns to scroll with next/prev buttons, same as `numberOfColumns` if not set explicitly */
columnsToScroll?: number;
/** `aria-label` attributes for controls on different levels */
ariaLabels?: CalendarAriaLabels;
/** Next button `aria-label` */
nextLabel?: string;
/** Previous button `aria-label` */
previousLabel?: string;
/** Called when the next decade button is clicked */
onNextDecade?: (date: DateStringValue) => void;
/** Called when the previous decade button is clicked */
onPreviousDecade?: (date: DateStringValue) => void;
/** Called when the next year button is clicked */
onNextYear?: (date: DateStringValue) => void;
/** Called when the previous year button is clicked */
onPreviousYear?: (date: DateStringValue) => void;
/** Called when the next month button is clicked */
onNextMonth?: (date: DateStringValue) => void;
/** Called when the previous month button is clicked */
onPreviousMonth?: (date: DateStringValue) => void;
}
export interface CalendarProps extends BoxProps, CalendarSettings, CalendarBaseProps, StylesApiProps<CalendarFactory>, ElementProps<'div'> {
/** Max level that user can go up to (decade, year, month) @default `'decade'` */
maxLevel?: CalendarLevel;
/** Min level that user can go down to (decade, year, month) @default `'month'` */
minLevel?: CalendarLevel;
/** Determines whether days should be static, static days can be used to display month if it is not expected that user will interact with the component in any way */
static?: boolean;
/** Enable enhanced keyboard navigation (Ctrl/Cmd + Arrow keys for year navigation, Ctrl/Cmd + Shift + Arrow keys for decade navigation, Y key to open year view) */
enableKeyboardNavigation?: boolean;
}
export type CalendarFactory = Factory<{
props: CalendarProps;
ref: HTMLDivElement;
stylesNames: CalendarStylesNames;
}>;
export declare const Calendar: import("@mantine/core").MantineComponent<{
props: CalendarProps;
ref: HTMLDivElement;
stylesNames: CalendarStylesNames;
}>;
export {};

View File

@@ -0,0 +1,2 @@
import type { CalendarLevel } from '../../../types';
export declare function clampLevel(level: CalendarLevel | undefined, minLevel: CalendarLevel | undefined, maxLevel: CalendarLevel | undefined): CalendarLevel;

View File

@@ -0,0 +1,3 @@
export { Calendar } from './Calendar';
export { pickCalendarProps } from './pick-calendar-levels-props/pick-calendar-levels-props';
export type { CalendarSettings, CalendarAriaLabels, CalendarProps, CalendarStylesNames, CalendarBaseProps, CalendarFactory, } from './Calendar';

View File

@@ -0,0 +1,58 @@
export declare function pickCalendarProps<T extends Record<string, any>>(props: T): {
calendarProps: {
maxLevel: any;
minLevel: any;
defaultLevel: any;
level: any;
onLevelChange: any;
nextIcon: any;
previousIcon: any;
date: any;
defaultDate: any;
onDateChange: any;
numberOfColumns: any;
columnsToScroll: any;
ariaLabels: any;
nextLabel: any;
previousLabel: any;
onYearSelect: any;
onMonthSelect: any;
onYearMouseEnter: any;
onMonthMouseEnter: any;
onNextMonth: any;
onPreviousMonth: any;
onNextYear: any;
onPreviousYear: any;
onNextDecade: any;
onPreviousDecade: any;
withCellSpacing: any;
highlightToday: any;
__updateDateOnYearSelect: any;
__updateDateOnMonthSelect: any;
__setDateRef: any;
withWeekNumbers: any;
headerControlsOrder: any;
firstDayOfWeek: any;
weekdayFormat: any;
weekendDays: any;
getDayProps: any;
excludeDate: any;
renderDay: any;
hideOutsideDates: any;
hideWeekdays: any;
getDayAriaLabel: any;
monthLabelFormat: any;
monthsListFormat: any;
getMonthControlProps: any;
yearLabelFormat: any;
yearsListFormat: any;
getYearControlProps: any;
decadeLabelFormat: any;
allowSingleDateInRange: any;
allowDeselect: any;
minDate: any;
maxDate: any;
locale: any;
};
others: Omit<T, "date" | "locale" | "minDate" | "maxDate" | "firstDayOfWeek" | "weekendDays" | "renderDay" | "highlightToday" | "weekdayFormat" | "withWeekNumbers" | "getDayProps" | "excludeDate" | "hideOutsideDates" | "hideWeekdays" | "getDayAriaLabel" | "withCellSpacing" | "getYearControlProps" | "yearsListFormat" | "getMonthControlProps" | "monthsListFormat" | "level" | "nextIcon" | "previousIcon" | "nextLabel" | "previousLabel" | "headerControlsOrder" | "decadeLabelFormat" | "yearLabelFormat" | "monthLabelFormat" | "numberOfColumns" | "allowSingleDateInRange" | "allowDeselect" | "defaultLevel" | "onLevelChange" | "onYearSelect" | "onMonthSelect" | "onYearMouseEnter" | "onMonthMouseEnter" | "maxLevel" | "minLevel" | "__updateDateOnYearSelect" | "__updateDateOnMonthSelect" | "__setDateRef" | "__setLevelRef" | "defaultDate" | "onDateChange" | "columnsToScroll" | "ariaLabels" | "onNextDecade" | "onPreviousDecade" | "onNextYear" | "onPreviousYear" | "onNextMonth" | "onPreviousMonth">;
};