591 lines
No EOL
20 KiB
JavaScript
591 lines
No EOL
20 KiB
JavaScript
'use client';
|
|
|
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
const _excluded = ["autoFocus", "onViewChange", "value", "defaultValue", "referenceDate", "disableFuture", "disablePast", "onChange", "onYearChange", "onMonthChange", "reduceAnimations", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "view", "views", "openTo", "className", "classes", "disabled", "readOnly", "minDate", "maxDate", "disableHighlightToday", "focusedView", "onFocusedViewChange", "showDaysOutsideCurrentMonth", "fixedWeekNumber", "dayOfWeekFormatter", "slots", "slotProps", "loading", "renderLoading", "displayWeekNumber", "yearsOrder", "yearsPerRow", "monthsPerRow", "timezone"];
|
|
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import clsx from 'clsx';
|
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
import composeClasses from '@mui/utils/composeClasses';
|
|
import useId from '@mui/utils/useId';
|
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
import { useCalendarState } from "./useCalendarState.js";
|
|
import { PickersFadeTransitionGroup } from "./PickersFadeTransitionGroup.js";
|
|
import { DayCalendar } from "./DayCalendar.js";
|
|
import { MonthCalendar } from "../MonthCalendar/index.js";
|
|
import { YearCalendar } from "../YearCalendar/index.js";
|
|
import { useViews } from "../internals/hooks/useViews.js";
|
|
import { PickersCalendarHeader } from "../PickersCalendarHeader/index.js";
|
|
import { findClosestEnabledDate, mergeDateAndTime } from "../internals/utils/date-utils.js";
|
|
import { PickerViewRoot } from "../internals/components/PickerViewRoot/index.js";
|
|
import { useReduceAnimations } from "../internals/hooks/useReduceAnimations.js";
|
|
import { getDateCalendarUtilityClass } from "./dateCalendarClasses.js";
|
|
import { useControlledValue } from "../internals/hooks/useControlledValue.js";
|
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
import { VIEW_HEIGHT } from "../internals/constants/dimensions.js";
|
|
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
import { useApplyDefaultValuesToDateValidationProps } from "../managers/useDateManager.js";
|
|
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
const useUtilityClasses = classes => {
|
|
const slots = {
|
|
root: ['root'],
|
|
viewTransitionContainer: ['viewTransitionContainer']
|
|
};
|
|
return composeClasses(slots, getDateCalendarUtilityClass, classes);
|
|
};
|
|
function useDateCalendarDefaultizedProps(props, name) {
|
|
const themeProps = useThemeProps({
|
|
props,
|
|
name
|
|
});
|
|
const reduceAnimations = useReduceAnimations(themeProps.reduceAnimations);
|
|
const validationProps = useApplyDefaultValuesToDateValidationProps(themeProps);
|
|
return _extends({}, themeProps, validationProps, {
|
|
loading: themeProps.loading ?? false,
|
|
openTo: themeProps.openTo ?? 'day',
|
|
views: themeProps.views ?? ['year', 'day'],
|
|
reduceAnimations,
|
|
renderLoading: themeProps.renderLoading ?? (() => /*#__PURE__*/_jsx("span", {
|
|
children: "..."
|
|
}))
|
|
});
|
|
}
|
|
const DateCalendarRoot = styled(PickerViewRoot, {
|
|
name: 'MuiDateCalendar',
|
|
slot: 'Root'
|
|
})({
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
height: VIEW_HEIGHT
|
|
});
|
|
const DateCalendarViewTransitionContainer = styled(PickersFadeTransitionGroup, {
|
|
name: 'MuiDateCalendar',
|
|
slot: 'ViewTransitionContainer'
|
|
})({});
|
|
/**
|
|
* Demos:
|
|
*
|
|
* - [DatePicker](https://mui.com/x/react-date-pickers/date-picker/)
|
|
* - [DateCalendar](https://mui.com/x/react-date-pickers/date-calendar/)
|
|
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
*
|
|
* API:
|
|
*
|
|
* - [DateCalendar API](https://mui.com/x/api/date-pickers/date-calendar/)
|
|
*/
|
|
export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(inProps, ref) {
|
|
const adapter = usePickerAdapter();
|
|
const {
|
|
ownerState
|
|
} = usePickerPrivateContext();
|
|
const id = useId();
|
|
const props = useDateCalendarDefaultizedProps(inProps, 'MuiDateCalendar');
|
|
const {
|
|
autoFocus,
|
|
onViewChange,
|
|
value: valueProp,
|
|
defaultValue,
|
|
referenceDate: referenceDateProp,
|
|
disableFuture,
|
|
disablePast,
|
|
onChange,
|
|
onMonthChange,
|
|
reduceAnimations,
|
|
shouldDisableDate,
|
|
shouldDisableMonth,
|
|
shouldDisableYear,
|
|
view: inView,
|
|
views,
|
|
openTo,
|
|
className,
|
|
classes: classesProp,
|
|
disabled,
|
|
readOnly,
|
|
minDate,
|
|
maxDate,
|
|
disableHighlightToday,
|
|
focusedView: focusedViewProp,
|
|
onFocusedViewChange,
|
|
showDaysOutsideCurrentMonth,
|
|
fixedWeekNumber,
|
|
dayOfWeekFormatter,
|
|
slots,
|
|
slotProps,
|
|
loading,
|
|
renderLoading,
|
|
displayWeekNumber,
|
|
yearsOrder,
|
|
yearsPerRow,
|
|
monthsPerRow,
|
|
timezone: timezoneProp
|
|
} = props,
|
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
const {
|
|
value,
|
|
handleValueChange,
|
|
timezone
|
|
} = useControlledValue({
|
|
name: 'DateCalendar',
|
|
timezone: timezoneProp,
|
|
value: valueProp,
|
|
defaultValue,
|
|
referenceDate: referenceDateProp,
|
|
onChange,
|
|
valueManager: singleItemValueManager
|
|
});
|
|
const {
|
|
view,
|
|
setView,
|
|
focusedView,
|
|
setFocusedView,
|
|
goToNextView,
|
|
setValueAndGoToNextView
|
|
} = useViews({
|
|
view: inView,
|
|
views,
|
|
openTo,
|
|
onChange: handleValueChange,
|
|
onViewChange,
|
|
autoFocus,
|
|
focusedView: focusedViewProp,
|
|
onFocusedViewChange
|
|
});
|
|
const {
|
|
referenceDate,
|
|
calendarState,
|
|
setVisibleDate,
|
|
isDateDisabled,
|
|
onMonthSwitchingAnimationEnd
|
|
} = useCalendarState({
|
|
value,
|
|
referenceDate: referenceDateProp,
|
|
reduceAnimations,
|
|
onMonthChange,
|
|
minDate,
|
|
maxDate,
|
|
shouldDisableDate,
|
|
disablePast,
|
|
disableFuture,
|
|
timezone,
|
|
getCurrentMonthFromVisibleDate: (visibleDate, prevMonth) => {
|
|
if (adapter.isSameMonth(visibleDate, prevMonth)) {
|
|
return prevMonth;
|
|
}
|
|
return adapter.startOfMonth(visibleDate);
|
|
}
|
|
});
|
|
|
|
// When disabled, limit the view to the selected date
|
|
const minDateWithDisabled = disabled && value || minDate;
|
|
const maxDateWithDisabled = disabled && value || maxDate;
|
|
const gridLabelId = `${id}-grid-label`;
|
|
const hasFocus = focusedView !== null;
|
|
const CalendarHeader = slots?.calendarHeader ?? PickersCalendarHeader;
|
|
const calendarHeaderProps = useSlotProps({
|
|
elementType: CalendarHeader,
|
|
externalSlotProps: slotProps?.calendarHeader,
|
|
additionalProps: {
|
|
views,
|
|
view,
|
|
currentMonth: calendarState.currentMonth,
|
|
onViewChange: setView,
|
|
onMonthChange: month => setVisibleDate({
|
|
target: month,
|
|
reason: 'header-navigation'
|
|
}),
|
|
minDate: minDateWithDisabled,
|
|
maxDate: maxDateWithDisabled,
|
|
disabled,
|
|
disablePast,
|
|
disableFuture,
|
|
reduceAnimations,
|
|
timezone,
|
|
labelId: gridLabelId
|
|
},
|
|
ownerState
|
|
});
|
|
const handleDateMonthChange = useEventCallback(newDate => {
|
|
const startOfMonth = adapter.startOfMonth(newDate);
|
|
const endOfMonth = adapter.endOfMonth(newDate);
|
|
const closestEnabledDate = isDateDisabled(newDate) ? findClosestEnabledDate({
|
|
adapter,
|
|
date: newDate,
|
|
minDate: adapter.isBefore(minDate, startOfMonth) ? startOfMonth : minDate,
|
|
maxDate: adapter.isAfter(maxDate, endOfMonth) ? endOfMonth : maxDate,
|
|
disablePast,
|
|
disableFuture,
|
|
isDateDisabled,
|
|
timezone
|
|
}) : newDate;
|
|
if (closestEnabledDate) {
|
|
setValueAndGoToNextView(closestEnabledDate, 'finish');
|
|
setVisibleDate({
|
|
target: closestEnabledDate,
|
|
reason: 'cell-interaction'
|
|
});
|
|
} else {
|
|
goToNextView();
|
|
setVisibleDate({
|
|
target: startOfMonth,
|
|
reason: 'cell-interaction'
|
|
});
|
|
}
|
|
});
|
|
const handleDateYearChange = useEventCallback(newDate => {
|
|
const startOfYear = adapter.startOfYear(newDate);
|
|
const endOfYear = adapter.endOfYear(newDate);
|
|
const closestEnabledDate = isDateDisabled(newDate) ? findClosestEnabledDate({
|
|
adapter,
|
|
date: newDate,
|
|
minDate: adapter.isBefore(minDate, startOfYear) ? startOfYear : minDate,
|
|
maxDate: adapter.isAfter(maxDate, endOfYear) ? endOfYear : maxDate,
|
|
disablePast,
|
|
disableFuture,
|
|
isDateDisabled,
|
|
timezone
|
|
}) : newDate;
|
|
if (closestEnabledDate) {
|
|
setValueAndGoToNextView(closestEnabledDate, 'finish');
|
|
setVisibleDate({
|
|
target: closestEnabledDate,
|
|
reason: 'cell-interaction'
|
|
});
|
|
} else {
|
|
goToNextView();
|
|
setVisibleDate({
|
|
target: startOfYear,
|
|
reason: 'cell-interaction'
|
|
});
|
|
}
|
|
});
|
|
const handleSelectedDayChange = useEventCallback(day => {
|
|
if (day) {
|
|
// If there is a date already selected, then we want to keep its time
|
|
return handleValueChange(mergeDateAndTime(adapter, day, value ?? referenceDate), 'finish', view);
|
|
}
|
|
return handleValueChange(day, 'finish', view);
|
|
});
|
|
React.useEffect(() => {
|
|
if (adapter.isValid(value)) {
|
|
setVisibleDate({
|
|
target: value,
|
|
reason: 'controlled-value-change'
|
|
});
|
|
}
|
|
}, [value]); // eslint-disable-line
|
|
|
|
const classes = useUtilityClasses(classesProp);
|
|
const baseDateValidationProps = {
|
|
disablePast,
|
|
disableFuture,
|
|
maxDate,
|
|
minDate
|
|
};
|
|
const commonViewProps = {
|
|
disableHighlightToday,
|
|
readOnly,
|
|
disabled,
|
|
timezone,
|
|
gridLabelId,
|
|
slots,
|
|
slotProps
|
|
};
|
|
const prevOpenViewRef = React.useRef(view);
|
|
React.useEffect(() => {
|
|
// If the view change and the focus was on the previous view
|
|
// Then we update the focus.
|
|
if (prevOpenViewRef.current === view) {
|
|
return;
|
|
}
|
|
if (focusedView === prevOpenViewRef.current) {
|
|
setFocusedView(view, true);
|
|
}
|
|
prevOpenViewRef.current = view;
|
|
}, [focusedView, setFocusedView, view]);
|
|
const selectedDays = React.useMemo(() => [value], [value]);
|
|
return /*#__PURE__*/_jsxs(DateCalendarRoot, _extends({
|
|
ref: ref,
|
|
className: clsx(classes.root, className),
|
|
ownerState: ownerState
|
|
}, other, {
|
|
children: [/*#__PURE__*/_jsx(CalendarHeader, _extends({}, calendarHeaderProps, {
|
|
slots: slots,
|
|
slotProps: slotProps
|
|
})), /*#__PURE__*/_jsx(DateCalendarViewTransitionContainer, {
|
|
reduceAnimations: reduceAnimations,
|
|
className: classes.viewTransitionContainer,
|
|
transKey: view,
|
|
ownerState: ownerState,
|
|
children: /*#__PURE__*/_jsxs("div", {
|
|
children: [view === 'year' && /*#__PURE__*/_jsx(YearCalendar, _extends({}, baseDateValidationProps, commonViewProps, {
|
|
value: value,
|
|
onChange: handleDateYearChange,
|
|
shouldDisableYear: shouldDisableYear,
|
|
hasFocus: hasFocus,
|
|
onFocusedViewChange: isViewFocused => setFocusedView('year', isViewFocused),
|
|
yearsOrder: yearsOrder,
|
|
yearsPerRow: yearsPerRow,
|
|
referenceDate: referenceDate
|
|
})), view === 'month' && /*#__PURE__*/_jsx(MonthCalendar, _extends({}, baseDateValidationProps, commonViewProps, {
|
|
hasFocus: hasFocus,
|
|
className: className,
|
|
value: value,
|
|
onChange: handleDateMonthChange,
|
|
shouldDisableMonth: shouldDisableMonth,
|
|
onFocusedViewChange: isViewFocused => setFocusedView('month', isViewFocused),
|
|
monthsPerRow: monthsPerRow,
|
|
referenceDate: referenceDate
|
|
})), view === 'day' && /*#__PURE__*/_jsx(DayCalendar, _extends({}, calendarState, baseDateValidationProps, commonViewProps, {
|
|
onMonthSwitchingAnimationEnd: onMonthSwitchingAnimationEnd,
|
|
hasFocus: hasFocus,
|
|
onFocusedDayChange: focusedDate => setVisibleDate({
|
|
target: focusedDate,
|
|
reason: 'cell-interaction'
|
|
}),
|
|
reduceAnimations: reduceAnimations,
|
|
selectedDays: selectedDays,
|
|
onSelectedDaysChange: handleSelectedDayChange,
|
|
shouldDisableDate: shouldDisableDate,
|
|
shouldDisableMonth: shouldDisableMonth,
|
|
shouldDisableYear: shouldDisableYear,
|
|
onFocusedViewChange: isViewFocused => setFocusedView('day', isViewFocused),
|
|
showDaysOutsideCurrentMonth: showDaysOutsideCurrentMonth,
|
|
fixedWeekNumber: fixedWeekNumber,
|
|
dayOfWeekFormatter: dayOfWeekFormatter,
|
|
displayWeekNumber: displayWeekNumber,
|
|
loading: loading,
|
|
renderLoading: renderLoading
|
|
}))]
|
|
})
|
|
})]
|
|
}));
|
|
});
|
|
if (process.env.NODE_ENV !== "production") DateCalendar.displayName = "DateCalendar";
|
|
process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
// ----------------------------- Warning --------------------------------
|
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
// ----------------------------------------------------------------------
|
|
/**
|
|
* If `true`, the main element is focused during the first mount.
|
|
* This main element is:
|
|
* - the element chosen by the visible view if any (i.e: the selected day on the `day` view).
|
|
* - the `input` element if there is a field rendered.
|
|
*/
|
|
autoFocus: PropTypes.bool,
|
|
/**
|
|
* Override or extend the styles applied to the component.
|
|
*/
|
|
classes: PropTypes.object,
|
|
className: PropTypes.string,
|
|
/**
|
|
* Formats the day of week displayed in the calendar header.
|
|
* @param {PickerValidDate} date The date of the day of week provided by the adapter.
|
|
* @returns {string} The name to display.
|
|
* @default (date: PickerValidDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
|
|
*/
|
|
dayOfWeekFormatter: PropTypes.func,
|
|
/**
|
|
* The default selected value.
|
|
* Used when the component is not controlled.
|
|
*/
|
|
defaultValue: PropTypes.object,
|
|
/**
|
|
* If `true`, the component is disabled.
|
|
* When disabled, the value cannot be changed and no interaction is possible.
|
|
* @default false
|
|
*/
|
|
disabled: PropTypes.bool,
|
|
/**
|
|
* If `true`, disable values after the current date for date components, time for time components and both for date time components.
|
|
* @default false
|
|
*/
|
|
disableFuture: PropTypes.bool,
|
|
/**
|
|
* If `true`, today's date is rendering without highlighting with circle.
|
|
* @default false
|
|
*/
|
|
disableHighlightToday: PropTypes.bool,
|
|
/**
|
|
* If `true`, disable values before the current date for date components, time for time components and both for date time components.
|
|
* @default false
|
|
*/
|
|
disablePast: PropTypes.bool,
|
|
/**
|
|
* If `true`, the week number will be display in the calendar.
|
|
*/
|
|
displayWeekNumber: PropTypes.bool,
|
|
/**
|
|
* The day view will show as many weeks as needed after the end of the current month to match this value.
|
|
* Put it to 6 to have a fixed number of weeks in Gregorian calendars
|
|
*/
|
|
fixedWeekNumber: PropTypes.number,
|
|
/**
|
|
* Controlled focused view.
|
|
*/
|
|
focusedView: PropTypes.oneOf(['day', 'month', 'year']),
|
|
/**
|
|
* If `true`, calls `renderLoading` instead of rendering the day calendar.
|
|
* Can be used to preload information and show it in calendar.
|
|
* @default false
|
|
*/
|
|
loading: PropTypes.bool,
|
|
/**
|
|
* Maximal selectable date.
|
|
* @default 2099-12-31
|
|
*/
|
|
maxDate: PropTypes.object,
|
|
/**
|
|
* Minimal selectable date.
|
|
* @default 1900-01-01
|
|
*/
|
|
minDate: PropTypes.object,
|
|
/**
|
|
* Months rendered per row.
|
|
* @default 3
|
|
*/
|
|
monthsPerRow: PropTypes.oneOf([3, 4]),
|
|
/**
|
|
* Callback fired when the value changes.
|
|
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
* @template TView The view type. Will be one of date or time views.
|
|
* @param {TValue} value The new value.
|
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
*/
|
|
onChange: PropTypes.func,
|
|
/**
|
|
* Callback fired on focused view change.
|
|
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
* @param {TView} view The new view to focus or not.
|
|
* @param {boolean} hasFocus `true` if the view should be focused.
|
|
*/
|
|
onFocusedViewChange: PropTypes.func,
|
|
/**
|
|
* Callback fired on month change.
|
|
* @param {PickerValidDate} month The new month.
|
|
*/
|
|
onMonthChange: PropTypes.func,
|
|
/**
|
|
* Callback fired on view change.
|
|
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
* @param {TView} view The new view.
|
|
*/
|
|
onViewChange: PropTypes.func,
|
|
/**
|
|
* Callback fired on year change.
|
|
* @param {PickerValidDate} year The new year.
|
|
*/
|
|
onYearChange: PropTypes.func,
|
|
/**
|
|
* The default visible view.
|
|
* Used when the component view is not controlled.
|
|
* Must be a valid option from `views` list.
|
|
*/
|
|
openTo: PropTypes.oneOf(['day', 'month', 'year']),
|
|
/**
|
|
* If `true`, the component is read-only.
|
|
* When read-only, the value cannot be changed but the user can interact with the interface.
|
|
* @default false
|
|
*/
|
|
readOnly: PropTypes.bool,
|
|
/**
|
|
* If `true`, disable heavy animations.
|
|
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
*/
|
|
reduceAnimations: PropTypes.bool,
|
|
/**
|
|
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`.
|
|
*/
|
|
referenceDate: PropTypes.object,
|
|
/**
|
|
* Component displaying when passed `loading` true.
|
|
* @returns {React.ReactNode} The node to render when loading.
|
|
* @default () => <span>...</span>
|
|
*/
|
|
renderLoading: PropTypes.func,
|
|
/**
|
|
* Disable specific date.
|
|
*
|
|
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
*
|
|
* @param {PickerValidDate} day The date to test.
|
|
* @returns {boolean} If `true` the date will be disabled.
|
|
*/
|
|
shouldDisableDate: PropTypes.func,
|
|
/**
|
|
* Disable specific month.
|
|
* @param {PickerValidDate} month The month to test.
|
|
* @returns {boolean} If `true`, the month will be disabled.
|
|
*/
|
|
shouldDisableMonth: PropTypes.func,
|
|
/**
|
|
* Disable specific year.
|
|
* @param {PickerValidDate} year The year to test.
|
|
* @returns {boolean} If `true`, the year will be disabled.
|
|
*/
|
|
shouldDisableYear: PropTypes.func,
|
|
/**
|
|
* If `true`, days outside the current month are rendered:
|
|
*
|
|
* - if `fixedWeekNumber` is defined, renders days to have the weeks requested.
|
|
*
|
|
* - if `fixedWeekNumber` is not defined, renders day to fill the first and last week of the current month.
|
|
*
|
|
* - ignored if `calendars` equals more than `1` on range pickers.
|
|
* @default false
|
|
*/
|
|
showDaysOutsideCurrentMonth: PropTypes.bool,
|
|
/**
|
|
* The props used for each component slot.
|
|
* @default {}
|
|
*/
|
|
slotProps: PropTypes.object,
|
|
/**
|
|
* Overridable component slots.
|
|
* @default {}
|
|
*/
|
|
slots: PropTypes.object,
|
|
/**
|
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
*/
|
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
/**
|
|
* Choose which timezone to use for the value.
|
|
* Example: "default", "system", "UTC", "America/New_York".
|
|
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
|
|
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
*/
|
|
timezone: PropTypes.string,
|
|
/**
|
|
* The selected value.
|
|
* Used when the component is controlled.
|
|
*/
|
|
value: PropTypes.object,
|
|
/**
|
|
* The visible view.
|
|
* Used when the component view is controlled.
|
|
* Must be a valid option from `views` list.
|
|
*/
|
|
view: PropTypes.oneOf(['day', 'month', 'year']),
|
|
/**
|
|
* Available views.
|
|
*/
|
|
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'month', 'year']).isRequired),
|
|
/**
|
|
* Years are displayed in ascending (chronological) order by default.
|
|
* If `desc`, years are displayed in descending order.
|
|
* @default 'asc'
|
|
*/
|
|
yearsOrder: PropTypes.oneOf(['asc', 'desc']),
|
|
/**
|
|
* Years rendered per row.
|
|
* @default 3
|
|
*/
|
|
yearsPerRow: PropTypes.oneOf([3, 4])
|
|
} : void 0; |