@mantine/dates
Version:
Calendars, date and time pickers based on Mantine components
43 lines (42 loc) • 2.39 kB
TypeScript
import { BoxProps, ElementProps, Factory, MantineComponentStaticProperties, StylesApiProps } from '@mantine/core';
import { DatePickerType, DateStringValue, PickerBaseProps } from '../../types';
import { CalendarBaseProps } from '../Calendar';
import { DecadeLevelBaseSettings } from '../DecadeLevel';
import { DecadeLevelGroupStylesNames } from '../DecadeLevelGroup';
export interface YearPickerPreset<Type extends DatePickerType> {
value: Type extends 'range' ? [DateStringValue | null, DateStringValue | null] : Type extends 'multiple' ? DateStringValue[] : DateStringValue | null;
label: React.ReactNode;
}
export type YearPickerCssVariables = {
yearPickerRoot: '--preset-font-size';
};
export type YearPickerStylesNames = DecadeLevelGroupStylesNames | 'presetsList' | 'presetButton' | 'yearPickerRoot';
export interface YearPickerBaseProps<Type extends DatePickerType = 'default'> extends PickerBaseProps<Type>, DecadeLevelBaseSettings, Omit<CalendarBaseProps, 'onNextYear' | 'onPreviousYear' | 'onNextMonth' | 'onPreviousMonth' | 'hasNextLevel'> {
/** Predefined values to pick from */
presets?: YearPickerPreset<Type>[];
/** If defined, called with preset value, suppresses `onChange` call */
__onPresetSelect?: (preset: DateStringValue | null | [DateStringValue | null, DateStringValue | null]) => void;
}
export interface YearPickerProps<Type extends DatePickerType = 'default'> extends BoxProps, YearPickerBaseProps<Type>, StylesApiProps<YearPickerFactory>, ElementProps<'div', 'onChange' | 'value' | 'defaultValue'> {
/** Called when year is selected */
onYearSelect?: (date: DateStringValue) => void;
}
export type YearPickerFactory = Factory<{
props: YearPickerProps;
ref: HTMLDivElement;
stylesNames: YearPickerStylesNames;
vars: YearPickerCssVariables;
}>;
type YearPickerComponent = (<Type extends DatePickerType = 'default'>(props: YearPickerProps<Type> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.JSX.Element) & {
displayName?: string;
} & MantineComponentStaticProperties<YearPickerFactory>;
export declare const YearPicker: YearPickerComponent;
export declare namespace YearPicker {
type Props<Type extends DatePickerType = 'default'> = YearPickerProps<Type>;
type BaseProps = YearPickerBaseProps;
type StylesNames = YearPickerStylesNames;
type Factory = YearPickerFactory;
}
export {};