@yamada-ui/calendar
Version:
Yamada UI calendar component
67 lines (64 loc) • 2.69 kB
text/typescript
import * as _yamada_ui_popover from '@yamada-ui/popover';
import * as _yamada_ui_core from '@yamada-ui/core';
import { PropGetter } from '@yamada-ui/core';
import { CalendarProps as CalendarProps$1 } from './calendar.mjs';
import { UseCalendarProps } from './use-calendar.mjs';
import { UseCalendarPickerProps } from './use-calendar-picker.mjs';
import 'react';
import './calendar-header.mjs';
import '@yamada-ui/button';
import '@yamada-ui/icon';
import './use-calendar-header.mjs';
import './month.mjs';
import './month-list.mjs';
import './year-list.mjs';
import 'dayjs';
import '@yamada-ui/form-control';
interface CalendarProps extends Pick<UseCalendarProps<Date | undefined>, "defaultMonth" | "defaultValue" | "locale" | "maxDate" | "minDate" | "month" | "monthFormat" | "onChange" | "onChangeMonth" | "value" | "withControls" | "withHeader" | "withLabel" | "yearFormat"> {
}
interface UseMonthPickerOptions {
/**
* The type of the month picker.
*/
type?: "month" | "year";
/**
* If `true`, the calendar component will be closed when value is selected.
*
* @default true
*/
closeOnSelect?: boolean;
/**
* The initial type of the month picker.
*
* @default 'month'
*/
defaultType?: "month" | "year";
/**
* The format used for conversion.
* Check the docs to see the format of possible modifiers you can pass.
*
* @see Docs https://day.js.org/docs/en/display/format#list-of-localized-formats
* @default 'YYYY/MM'
*/
inputFormat?: string;
/**
* The callback invoked when type state changes.
*/
onChangeType?: (type: "month" | "year") => void;
}
interface UseMonthPickerProps extends UseCalendarPickerProps<CalendarProps>, UseMonthPickerOptions {
}
declare const useMonthPicker: ({ type: typeProp, closeOnSelect, defaultType, defaultValue, placeholder, value: valueProp, onChange: onChangeProp, onChangeType: onChangeTypeProp, ...rest }: UseMonthPickerProps) => {
value: Date | undefined;
getCalendarProps: (props?: CalendarProps$1) => CalendarProps$1;
getContainerProps: PropGetter<"div", undefined>;
getFieldProps: PropGetter<"div", undefined>;
getIconProps: _yamada_ui_core.RequiredPropGetter<{
clear: boolean;
} & _yamada_ui_core.HTMLProps, _yamada_ui_core.HTMLProps>;
getInputProps: PropGetter<"input", undefined>;
getPopoverProps: (props?: _yamada_ui_popover.PopoverProps) => _yamada_ui_popover.PopoverProps;
onClose: (...args: any[]) => Promise<void> | void;
};
type UseMonthPickerReturn = ReturnType<typeof useMonthPicker>;
export { type UseMonthPickerProps, type UseMonthPickerReturn, useMonthPicker };