Added Statistics calculation
Statistics now show calculated values
This commit is contained in:
parent
fe87374e47
commit
fc0f69dacb
2147 changed files with 141321 additions and 39 deletions
18
node_modules/@mui/x-date-pickers/esm/DateCalendar/DateCalendar.d.ts
generated
vendored
Normal file
18
node_modules/@mui/x-date-pickers/esm/DateCalendar/DateCalendar.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import * as React from 'react';
|
||||
import { DateCalendarProps } from "./DateCalendar.types.js";
|
||||
type DateCalendarComponent = ((props: DateCalendarProps & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
||||
propTypes?: any;
|
||||
};
|
||||
/**
|
||||
* 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 declare const DateCalendar: DateCalendarComponent;
|
||||
export {};
|
||||
591
node_modules/@mui/x-date-pickers/esm/DateCalendar/DateCalendar.js
generated
vendored
Normal file
591
node_modules/@mui/x-date-pickers/esm/DateCalendar/DateCalendar.js
generated
vendored
Normal file
|
|
@ -0,0 +1,591 @@
|
|||
'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;
|
||||
87
node_modules/@mui/x-date-pickers/esm/DateCalendar/DateCalendar.types.d.ts
generated
vendored
Normal file
87
node_modules/@mui/x-date-pickers/esm/DateCalendar/DateCalendar.types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
import * as React from 'react';
|
||||
import { SxProps } from '@mui/system';
|
||||
import { Theme } from '@mui/material/styles';
|
||||
import { SlotComponentProps } from '@mui/utils/types';
|
||||
import { DefaultizedProps } from '@mui/x-internals/types';
|
||||
import { PickersCalendarHeader, PickersCalendarHeaderProps, PickersCalendarHeaderSlots, PickersCalendarHeaderSlotProps } from "../PickersCalendarHeader/index.js";
|
||||
import { DayCalendarSlots, DayCalendarSlotProps, ExportedDayCalendarProps } from "./DayCalendar.js";
|
||||
import { DateCalendarClasses } from "./dateCalendarClasses.js";
|
||||
import { BaseDateValidationProps } from "../internals/models/validation.js";
|
||||
import { ExportedUseViewsOptions } from "../internals/hooks/useViews.js";
|
||||
import { DateView, PickerOwnerState, PickerValidDate, TimezoneProps } from "../models/index.js";
|
||||
import { ExportedYearCalendarProps, YearCalendarSlots, YearCalendarSlotProps } from "../YearCalendar/YearCalendar.types.js";
|
||||
import { ExportedMonthCalendarProps, MonthCalendarSlots, MonthCalendarSlotProps } from "../MonthCalendar/MonthCalendar.types.js";
|
||||
import { ExportedValidateDateProps } from "../validation/validateDate.js";
|
||||
import { FormProps } from "../internals/models/formProps.js";
|
||||
import { PickerValue } from "../internals/models/index.js";
|
||||
export interface DateCalendarSlots extends PickersCalendarHeaderSlots, DayCalendarSlots, MonthCalendarSlots, YearCalendarSlots {
|
||||
/**
|
||||
* Custom component for calendar header.
|
||||
* Check the [PickersCalendarHeader](https://mui.com/x/api/date-pickers/pickers-calendar-header/) component.
|
||||
* @default PickersCalendarHeader
|
||||
*/
|
||||
calendarHeader?: React.ElementType<PickersCalendarHeaderProps>;
|
||||
}
|
||||
export interface DateCalendarSlotProps extends PickersCalendarHeaderSlotProps, DayCalendarSlotProps, MonthCalendarSlotProps, YearCalendarSlotProps {
|
||||
calendarHeader?: SlotComponentProps<typeof PickersCalendarHeader, {}, PickerOwnerState>;
|
||||
}
|
||||
export interface ExportedDateCalendarProps extends ExportedDayCalendarProps, ExportedMonthCalendarProps, ExportedYearCalendarProps, ExportedValidateDateProps, TimezoneProps, FormProps {
|
||||
/**
|
||||
* If `true`, disable heavy animations.
|
||||
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
||||
*/
|
||||
reduceAnimations?: boolean;
|
||||
/**
|
||||
* Component displaying when passed `loading` true.
|
||||
* @returns {React.ReactNode} The node to render when loading.
|
||||
* @default () => <span>...</span>
|
||||
*/
|
||||
renderLoading?: () => React.ReactNode;
|
||||
/**
|
||||
* Callback fired on year change.
|
||||
* @param {PickerValidDate} year The new year.
|
||||
*/
|
||||
onYearChange?: (year: PickerValidDate) => void;
|
||||
/**
|
||||
* Callback fired on month change.
|
||||
* @param {PickerValidDate} month The new month.
|
||||
*/
|
||||
onMonthChange?: (month: PickerValidDate) => void;
|
||||
}
|
||||
export interface DateCalendarProps extends ExportedDateCalendarProps, ExportedUseViewsOptions<PickerValue, DateView> {
|
||||
/**
|
||||
* The selected value.
|
||||
* Used when the component is controlled.
|
||||
*/
|
||||
value?: PickerValidDate | null;
|
||||
/**
|
||||
* The default selected value.
|
||||
* Used when the component is not controlled.
|
||||
*/
|
||||
defaultValue?: PickerValidDate | null;
|
||||
/**
|
||||
* 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?: PickerValidDate;
|
||||
className?: string;
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes?: Partial<DateCalendarClasses>;
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx?: SxProps<Theme>;
|
||||
/**
|
||||
* Overridable component slots.
|
||||
* @default {}
|
||||
*/
|
||||
slots?: DateCalendarSlots;
|
||||
/**
|
||||
* The props used for each component slot.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: DateCalendarSlotProps;
|
||||
}
|
||||
export type DateCalendarDefaultizedProps = DefaultizedProps<DateCalendarProps, 'views' | 'openTo' | 'loading' | 'reduceAnimations' | 'renderLoading' | keyof BaseDateValidationProps>;
|
||||
1
node_modules/@mui/x-date-pickers/esm/DateCalendar/DateCalendar.types.js
generated
vendored
Normal file
1
node_modules/@mui/x-date-pickers/esm/DateCalendar/DateCalendar.types.js
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export {};
|
||||
85
node_modules/@mui/x-date-pickers/esm/DateCalendar/DayCalendar.d.ts
generated
vendored
Normal file
85
node_modules/@mui/x-date-pickers/esm/DateCalendar/DayCalendar.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
import * as React from 'react';
|
||||
import { DefaultizedProps, SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
||||
import { PickerDayOwnerState, PickersDayProps } from "../PickersDay/index.js";
|
||||
import { ExportedPickersDayProps } from "../PickersDay/PickersDay.types.js";
|
||||
import { PickerOnChangeFn } from "../internals/hooks/useViews.js";
|
||||
import { SlideDirection, SlideTransitionProps } from "./PickersSlideTransition.js";
|
||||
import { BaseDateValidationProps, DayValidationProps, MonthValidationProps, YearValidationProps } from "../internals/models/validation.js";
|
||||
import { DayCalendarClasses } from "./dayCalendarClasses.js";
|
||||
import { PickerValidDate, TimezoneProps } from "../models/index.js";
|
||||
import { FormProps } from "../internals/models/formProps.js";
|
||||
export interface DayCalendarSlots {
|
||||
/**
|
||||
* Custom component for day.
|
||||
* Check the [PickersDay](https://mui.com/x/api/date-pickers/pickers-day/) component.
|
||||
* @default PickersDay
|
||||
*/
|
||||
day?: React.ElementType<PickersDayProps>;
|
||||
}
|
||||
export interface DayCalendarSlotProps {
|
||||
day?: SlotComponentPropsFromProps<PickersDayProps, {}, PickerDayOwnerState>;
|
||||
}
|
||||
export interface ExportedDayCalendarProps extends ExportedPickersDayProps {
|
||||
/**
|
||||
* If `true`, calls `renderLoading` instead of rendering the day calendar.
|
||||
* Can be used to preload information and show it in calendar.
|
||||
* @default false
|
||||
*/
|
||||
loading?: boolean;
|
||||
/**
|
||||
* Component rendered on the "day" view when `props.loading` is true.
|
||||
* @returns {React.ReactNode} The node to render when loading.
|
||||
* @default () => "..."
|
||||
*/
|
||||
renderLoading?: () => React.ReactNode;
|
||||
/**
|
||||
* 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?: (date: PickerValidDate) => string;
|
||||
/**
|
||||
* If `true`, the week number will be display in the calendar.
|
||||
*/
|
||||
displayWeekNumber?: boolean;
|
||||
/**
|
||||
* 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?: number;
|
||||
}
|
||||
export interface DayCalendarProps extends ExportedDayCalendarProps, DayValidationProps, MonthValidationProps, YearValidationProps, Required<BaseDateValidationProps>, DefaultizedProps<TimezoneProps, 'timezone'>, FormProps {
|
||||
className?: string;
|
||||
currentMonth: PickerValidDate;
|
||||
selectedDays: (PickerValidDate | null)[];
|
||||
onSelectedDaysChange: PickerOnChangeFn;
|
||||
focusedDay: PickerValidDate | null;
|
||||
isMonthSwitchingAnimating: boolean;
|
||||
onFocusedDayChange: (newFocusedDay: PickerValidDate) => void;
|
||||
onMonthSwitchingAnimationEnd: () => void;
|
||||
reduceAnimations: boolean;
|
||||
slideDirection: SlideDirection;
|
||||
TransitionProps?: Partial<SlideTransitionProps>;
|
||||
hasFocus: boolean;
|
||||
onFocusedViewChange?: (newHasFocus: boolean) => void;
|
||||
gridLabelId?: string;
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes?: Partial<DayCalendarClasses>;
|
||||
/**
|
||||
* Overridable component slots.
|
||||
* @default {}
|
||||
*/
|
||||
slots?: DayCalendarSlots;
|
||||
/**
|
||||
* The props used for each component slot.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: DayCalendarSlotProps;
|
||||
}
|
||||
/**
|
||||
* @ignore - do not document.
|
||||
*/
|
||||
export declare function DayCalendar(inProps: DayCalendarProps): React.JSX.Element;
|
||||
440
node_modules/@mui/x-date-pickers/esm/DateCalendar/DayCalendar.js
generated
vendored
Normal file
440
node_modules/@mui/x-date-pickers/esm/DateCalendar/DayCalendar.js
generated
vendored
Normal file
|
|
@ -0,0 +1,440 @@
|
|||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["parentProps", "day", "focusedDay", "selectedDays", "isDateDisabled", "currentMonthNumber", "isViewFocused"],
|
||||
_excluded2 = ["ownerState"];
|
||||
import * as React from 'react';
|
||||
import useEventCallback from '@mui/utils/useEventCallback';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import useSlotProps from '@mui/utils/useSlotProps';
|
||||
import { useRtl } from '@mui/system/RtlProvider';
|
||||
import { styled, useThemeProps } from '@mui/material/styles';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import clsx from 'clsx';
|
||||
import { PickersDay } from "../PickersDay/index.js";
|
||||
import { usePickerAdapter, usePickerTranslations } from "../hooks/index.js";
|
||||
import { useNow } from "../internals/hooks/useUtils.js";
|
||||
import { DAY_SIZE, DAY_MARGIN } from "../internals/constants/dimensions.js";
|
||||
import { PickersSlideTransition } from "./PickersSlideTransition.js";
|
||||
import { useIsDateDisabled } from "./useIsDateDisabled.js";
|
||||
import { findClosestEnabledDate, getWeekdays } from "../internals/utils/date-utils.js";
|
||||
import { getDayCalendarUtilityClass } from "./dayCalendarClasses.js";
|
||||
import { usePickerDayOwnerState } from "../PickersDay/usePickerDayOwnerState.js";
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
const useUtilityClasses = classes => {
|
||||
const slots = {
|
||||
root: ['root'],
|
||||
header: ['header'],
|
||||
weekDayLabel: ['weekDayLabel'],
|
||||
loadingContainer: ['loadingContainer'],
|
||||
slideTransition: ['slideTransition'],
|
||||
monthContainer: ['monthContainer'],
|
||||
weekContainer: ['weekContainer'],
|
||||
weekNumberLabel: ['weekNumberLabel'],
|
||||
weekNumber: ['weekNumber']
|
||||
};
|
||||
return composeClasses(slots, getDayCalendarUtilityClass, classes);
|
||||
};
|
||||
const weeksContainerHeight = (DAY_SIZE + DAY_MARGIN * 2) * 6;
|
||||
const PickersCalendarDayRoot = styled('div', {
|
||||
name: 'MuiDayCalendar',
|
||||
slot: 'Root'
|
||||
})({});
|
||||
const PickersCalendarDayHeader = styled('div', {
|
||||
name: 'MuiDayCalendar',
|
||||
slot: 'Header'
|
||||
})({
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center'
|
||||
});
|
||||
const PickersCalendarWeekDayLabel = styled(Typography, {
|
||||
name: 'MuiDayCalendar',
|
||||
slot: 'WeekDayLabel'
|
||||
})(({
|
||||
theme
|
||||
}) => ({
|
||||
width: 36,
|
||||
height: 40,
|
||||
margin: '0 2px',
|
||||
textAlign: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
color: (theme.vars || theme).palette.text.secondary
|
||||
}));
|
||||
const PickersCalendarWeekNumberLabel = styled(Typography, {
|
||||
name: 'MuiDayCalendar',
|
||||
slot: 'WeekNumberLabel'
|
||||
})(({
|
||||
theme
|
||||
}) => ({
|
||||
width: 36,
|
||||
height: 40,
|
||||
margin: '0 2px',
|
||||
textAlign: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
color: (theme.vars || theme).palette.text.disabled
|
||||
}));
|
||||
const PickersCalendarWeekNumber = styled(Typography, {
|
||||
name: 'MuiDayCalendar',
|
||||
slot: 'WeekNumber'
|
||||
})(({
|
||||
theme
|
||||
}) => _extends({}, theme.typography.caption, {
|
||||
width: DAY_SIZE,
|
||||
height: DAY_SIZE,
|
||||
padding: 0,
|
||||
margin: `0 ${DAY_MARGIN}px`,
|
||||
color: (theme.vars || theme).palette.text.disabled,
|
||||
fontSize: '0.75rem',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
display: 'inline-flex'
|
||||
}));
|
||||
const PickersCalendarLoadingContainer = styled('div', {
|
||||
name: 'MuiDayCalendar',
|
||||
slot: 'LoadingContainer'
|
||||
})({
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
minHeight: weeksContainerHeight
|
||||
});
|
||||
const PickersCalendarSlideTransition = styled(PickersSlideTransition, {
|
||||
name: 'MuiDayCalendar',
|
||||
slot: 'SlideTransition'
|
||||
})({
|
||||
minHeight: weeksContainerHeight
|
||||
});
|
||||
const PickersCalendarWeekContainer = styled('div', {
|
||||
name: 'MuiDayCalendar',
|
||||
slot: 'MonthContainer'
|
||||
})({
|
||||
overflow: 'hidden'
|
||||
});
|
||||
const PickersCalendarWeek = styled('div', {
|
||||
name: 'MuiDayCalendar',
|
||||
slot: 'WeekContainer'
|
||||
})({
|
||||
margin: `${DAY_MARGIN}px 0`,
|
||||
display: 'flex',
|
||||
justifyContent: 'center'
|
||||
});
|
||||
function WrappedDay(_ref) {
|
||||
let {
|
||||
parentProps,
|
||||
day,
|
||||
focusedDay,
|
||||
selectedDays,
|
||||
isDateDisabled,
|
||||
currentMonthNumber,
|
||||
isViewFocused
|
||||
} = _ref,
|
||||
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
||||
const {
|
||||
disabled,
|
||||
disableHighlightToday,
|
||||
isMonthSwitchingAnimating,
|
||||
showDaysOutsideCurrentMonth,
|
||||
slots,
|
||||
slotProps,
|
||||
timezone
|
||||
} = parentProps;
|
||||
const adapter = usePickerAdapter();
|
||||
const now = useNow(timezone);
|
||||
const isFocusableDay = focusedDay != null && adapter.isSameDay(day, focusedDay);
|
||||
const isFocusedDay = isViewFocused && isFocusableDay;
|
||||
const isSelected = selectedDays.some(selectedDay => adapter.isSameDay(selectedDay, day));
|
||||
const isToday = adapter.isSameDay(day, now);
|
||||
const isDisabled = React.useMemo(() => disabled || isDateDisabled(day), [disabled, isDateDisabled, day]);
|
||||
const isOutsideCurrentMonth = React.useMemo(() => adapter.getMonth(day) !== currentMonthNumber, [adapter, day, currentMonthNumber]);
|
||||
const ownerState = usePickerDayOwnerState({
|
||||
day,
|
||||
selected: isSelected,
|
||||
disabled: isDisabled,
|
||||
today: isToday,
|
||||
outsideCurrentMonth: isOutsideCurrentMonth,
|
||||
disableMargin: undefined,
|
||||
// This prop can only be defined using slotProps.day so the ownerState for useSlotProps cannot have its value.
|
||||
disableHighlightToday,
|
||||
showDaysOutsideCurrentMonth
|
||||
});
|
||||
const Day = slots?.day ?? PickersDay;
|
||||
// We don't want to pass to ownerState down, to avoid re-rendering all the day whenever a prop changes.
|
||||
const _useSlotProps = useSlotProps({
|
||||
elementType: Day,
|
||||
externalSlotProps: slotProps?.day,
|
||||
additionalProps: _extends({
|
||||
disableHighlightToday,
|
||||
showDaysOutsideCurrentMonth,
|
||||
role: 'gridcell',
|
||||
isAnimating: isMonthSwitchingAnimating,
|
||||
// it is used in date range dragging logic by accessing `dataset.timestamp`
|
||||
'data-timestamp': adapter.toJsDate(day).valueOf()
|
||||
}, other),
|
||||
ownerState: _extends({}, ownerState, {
|
||||
day,
|
||||
isDayDisabled: isDisabled,
|
||||
isDaySelected: isSelected
|
||||
})
|
||||
}),
|
||||
dayProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
||||
const isFirstVisibleCell = React.useMemo(() => {
|
||||
const startOfMonth = adapter.startOfMonth(adapter.setMonth(day, currentMonthNumber));
|
||||
if (!showDaysOutsideCurrentMonth) {
|
||||
return adapter.isSameDay(day, startOfMonth);
|
||||
}
|
||||
return adapter.isSameDay(day, adapter.startOfWeek(startOfMonth));
|
||||
}, [currentMonthNumber, day, showDaysOutsideCurrentMonth, adapter]);
|
||||
const isLastVisibleCell = React.useMemo(() => {
|
||||
const endOfMonth = adapter.endOfMonth(adapter.setMonth(day, currentMonthNumber));
|
||||
if (!showDaysOutsideCurrentMonth) {
|
||||
return adapter.isSameDay(day, endOfMonth);
|
||||
}
|
||||
return adapter.isSameDay(day, adapter.endOfWeek(endOfMonth));
|
||||
}, [currentMonthNumber, day, showDaysOutsideCurrentMonth, adapter]);
|
||||
return /*#__PURE__*/_jsx(Day, _extends({}, dayProps, {
|
||||
day: day,
|
||||
disabled: isDisabled,
|
||||
autoFocus: !isOutsideCurrentMonth && isFocusedDay,
|
||||
today: isToday,
|
||||
outsideCurrentMonth: isOutsideCurrentMonth,
|
||||
isFirstVisibleCell: isFirstVisibleCell,
|
||||
isLastVisibleCell: isLastVisibleCell,
|
||||
selected: isSelected,
|
||||
tabIndex: isFocusableDay ? 0 : -1,
|
||||
"aria-selected": isSelected,
|
||||
"aria-current": isToday ? 'date' : undefined
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore - do not document.
|
||||
*/
|
||||
export function DayCalendar(inProps) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiDayCalendar'
|
||||
});
|
||||
const adapter = usePickerAdapter();
|
||||
const {
|
||||
onFocusedDayChange,
|
||||
className,
|
||||
classes: classesProp,
|
||||
currentMonth,
|
||||
selectedDays,
|
||||
focusedDay,
|
||||
loading,
|
||||
onSelectedDaysChange,
|
||||
onMonthSwitchingAnimationEnd,
|
||||
readOnly,
|
||||
reduceAnimations,
|
||||
renderLoading = () => /*#__PURE__*/_jsx("span", {
|
||||
children: "..."
|
||||
}),
|
||||
slideDirection,
|
||||
TransitionProps,
|
||||
disablePast,
|
||||
disableFuture,
|
||||
minDate,
|
||||
maxDate,
|
||||
shouldDisableDate,
|
||||
shouldDisableMonth,
|
||||
shouldDisableYear,
|
||||
dayOfWeekFormatter = date => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase(),
|
||||
hasFocus,
|
||||
onFocusedViewChange,
|
||||
gridLabelId,
|
||||
displayWeekNumber,
|
||||
fixedWeekNumber,
|
||||
timezone
|
||||
} = props;
|
||||
const now = useNow(timezone);
|
||||
const classes = useUtilityClasses(classesProp);
|
||||
const isRtl = useRtl();
|
||||
const isDateDisabled = useIsDateDisabled({
|
||||
shouldDisableDate,
|
||||
shouldDisableMonth,
|
||||
shouldDisableYear,
|
||||
minDate,
|
||||
maxDate,
|
||||
disablePast,
|
||||
disableFuture,
|
||||
timezone
|
||||
});
|
||||
const translations = usePickerTranslations();
|
||||
const handleDaySelect = useEventCallback(day => {
|
||||
if (readOnly) {
|
||||
return;
|
||||
}
|
||||
onSelectedDaysChange(day);
|
||||
});
|
||||
const focusDay = day => {
|
||||
if (!isDateDisabled(day)) {
|
||||
onFocusedDayChange(day);
|
||||
onFocusedViewChange?.(true);
|
||||
}
|
||||
};
|
||||
const handleKeyDown = useEventCallback((event, day) => {
|
||||
switch (event.key) {
|
||||
case 'ArrowUp':
|
||||
focusDay(adapter.addDays(day, -7));
|
||||
event.preventDefault();
|
||||
break;
|
||||
case 'ArrowDown':
|
||||
focusDay(adapter.addDays(day, 7));
|
||||
event.preventDefault();
|
||||
break;
|
||||
case 'ArrowLeft':
|
||||
{
|
||||
const newFocusedDayDefault = adapter.addDays(day, isRtl ? 1 : -1);
|
||||
const nextAvailableMonth = adapter.addMonths(day, isRtl ? 1 : -1);
|
||||
const closestDayToFocus = findClosestEnabledDate({
|
||||
adapter,
|
||||
date: newFocusedDayDefault,
|
||||
minDate: isRtl ? newFocusedDayDefault : adapter.startOfMonth(nextAvailableMonth),
|
||||
maxDate: isRtl ? adapter.endOfMonth(nextAvailableMonth) : newFocusedDayDefault,
|
||||
isDateDisabled,
|
||||
timezone
|
||||
});
|
||||
focusDay(closestDayToFocus || newFocusedDayDefault);
|
||||
event.preventDefault();
|
||||
break;
|
||||
}
|
||||
case 'ArrowRight':
|
||||
{
|
||||
const newFocusedDayDefault = adapter.addDays(day, isRtl ? -1 : 1);
|
||||
const nextAvailableMonth = adapter.addMonths(day, isRtl ? -1 : 1);
|
||||
const closestDayToFocus = findClosestEnabledDate({
|
||||
adapter,
|
||||
date: newFocusedDayDefault,
|
||||
minDate: isRtl ? adapter.startOfMonth(nextAvailableMonth) : newFocusedDayDefault,
|
||||
maxDate: isRtl ? newFocusedDayDefault : adapter.endOfMonth(nextAvailableMonth),
|
||||
isDateDisabled,
|
||||
timezone
|
||||
});
|
||||
focusDay(closestDayToFocus || newFocusedDayDefault);
|
||||
event.preventDefault();
|
||||
break;
|
||||
}
|
||||
case 'Home':
|
||||
focusDay(adapter.startOfWeek(day));
|
||||
event.preventDefault();
|
||||
break;
|
||||
case 'End':
|
||||
focusDay(adapter.endOfWeek(day));
|
||||
event.preventDefault();
|
||||
break;
|
||||
case 'PageUp':
|
||||
focusDay(adapter.addMonths(day, 1));
|
||||
event.preventDefault();
|
||||
break;
|
||||
case 'PageDown':
|
||||
focusDay(adapter.addMonths(day, -1));
|
||||
event.preventDefault();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
const handleFocus = useEventCallback((event, day) => focusDay(day));
|
||||
const handleBlur = useEventCallback((event, day) => {
|
||||
if (focusedDay != null && adapter.isSameDay(focusedDay, day)) {
|
||||
onFocusedViewChange?.(false);
|
||||
}
|
||||
});
|
||||
const currentMonthNumber = adapter.getMonth(currentMonth);
|
||||
const currentYearNumber = adapter.getYear(currentMonth);
|
||||
const validSelectedDays = React.useMemo(() => selectedDays.filter(day => !!day).map(day => adapter.startOfDay(day)), [adapter, selectedDays]);
|
||||
|
||||
// need a new ref whenever the `key` of the transition changes: https://reactcommunity.org/react-transition-group/transition/#Transition-prop-nodeRef.
|
||||
const transitionKey = `${currentYearNumber}-${currentMonthNumber}`;
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
const slideNodeRef = React.useMemo(() => /*#__PURE__*/React.createRef(), [transitionKey]);
|
||||
const weeksToDisplay = React.useMemo(() => {
|
||||
const toDisplay = adapter.getWeekArray(currentMonth);
|
||||
let nextMonth = adapter.addMonths(currentMonth, 1);
|
||||
while (fixedWeekNumber && toDisplay.length < fixedWeekNumber) {
|
||||
const additionalWeeks = adapter.getWeekArray(nextMonth);
|
||||
const hasCommonWeek = adapter.isSameDay(toDisplay[toDisplay.length - 1][0], additionalWeeks[0][0]);
|
||||
additionalWeeks.slice(hasCommonWeek ? 1 : 0).forEach(week => {
|
||||
if (toDisplay.length < fixedWeekNumber) {
|
||||
toDisplay.push(week);
|
||||
}
|
||||
});
|
||||
nextMonth = adapter.addMonths(nextMonth, 1);
|
||||
}
|
||||
return toDisplay;
|
||||
}, [currentMonth, fixedWeekNumber, adapter]);
|
||||
return /*#__PURE__*/_jsxs(PickersCalendarDayRoot, {
|
||||
role: "grid",
|
||||
"aria-labelledby": gridLabelId,
|
||||
className: classes.root,
|
||||
children: [/*#__PURE__*/_jsxs(PickersCalendarDayHeader, {
|
||||
role: "row",
|
||||
className: classes.header,
|
||||
children: [displayWeekNumber && /*#__PURE__*/_jsx(PickersCalendarWeekNumberLabel, {
|
||||
variant: "caption",
|
||||
role: "columnheader",
|
||||
"aria-label": translations.calendarWeekNumberHeaderLabel,
|
||||
className: classes.weekNumberLabel,
|
||||
children: translations.calendarWeekNumberHeaderText
|
||||
}), getWeekdays(adapter, now).map((weekday, i) => /*#__PURE__*/_jsx(PickersCalendarWeekDayLabel, {
|
||||
variant: "caption",
|
||||
role: "columnheader",
|
||||
"aria-label": adapter.format(weekday, 'weekday'),
|
||||
className: classes.weekDayLabel,
|
||||
children: dayOfWeekFormatter(weekday)
|
||||
}, i.toString()))]
|
||||
}), loading ? /*#__PURE__*/_jsx(PickersCalendarLoadingContainer, {
|
||||
className: classes.loadingContainer,
|
||||
children: renderLoading()
|
||||
}) : /*#__PURE__*/_jsx(PickersCalendarSlideTransition, _extends({
|
||||
transKey: transitionKey,
|
||||
onExited: onMonthSwitchingAnimationEnd,
|
||||
reduceAnimations: reduceAnimations,
|
||||
slideDirection: slideDirection,
|
||||
className: clsx(className, classes.slideTransition)
|
||||
}, TransitionProps, {
|
||||
nodeRef: slideNodeRef,
|
||||
children: /*#__PURE__*/_jsx(PickersCalendarWeekContainer, {
|
||||
ref: slideNodeRef,
|
||||
role: "rowgroup",
|
||||
className: classes.monthContainer,
|
||||
children: weeksToDisplay.map((week, index) => /*#__PURE__*/_jsxs(PickersCalendarWeek, {
|
||||
role: "row",
|
||||
className: classes.weekContainer
|
||||
// fix issue of announcing row 1 as row 2
|
||||
// caused by week day labels row
|
||||
,
|
||||
"aria-rowindex": index + 1,
|
||||
children: [displayWeekNumber && /*#__PURE__*/_jsx(PickersCalendarWeekNumber, {
|
||||
className: classes.weekNumber,
|
||||
role: "rowheader",
|
||||
"aria-label": translations.calendarWeekNumberAriaLabelText(adapter.getWeekNumber(week[0])),
|
||||
children: translations.calendarWeekNumberText(adapter.getWeekNumber(week[0]))
|
||||
}), week.map((day, dayIndex) => /*#__PURE__*/_jsx(WrappedDay, {
|
||||
parentProps: props,
|
||||
day: day,
|
||||
selectedDays: validSelectedDays,
|
||||
isViewFocused: hasFocus,
|
||||
focusedDay: focusedDay,
|
||||
onKeyDown: handleKeyDown,
|
||||
onFocus: handleFocus,
|
||||
onBlur: handleBlur,
|
||||
onDaySelect: handleDaySelect,
|
||||
isDateDisabled: isDateDisabled,
|
||||
currentMonthNumber: currentMonthNumber
|
||||
// fix issue of announcing column 1 as column 2 when `displayWeekNumber` is enabled
|
||||
,
|
||||
"aria-colindex": dayIndex + 1
|
||||
}, day.toString()))]
|
||||
}, `week-${week[0]}`))
|
||||
})
|
||||
}))]
|
||||
});
|
||||
}
|
||||
18
node_modules/@mui/x-date-pickers/esm/DateCalendar/PickersFadeTransitionGroup.d.ts
generated
vendored
Normal file
18
node_modules/@mui/x-date-pickers/esm/DateCalendar/PickersFadeTransitionGroup.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import * as React from 'react';
|
||||
import { PickersFadeTransitionGroupClasses } from "./pickersFadeTransitionGroupClasses.js";
|
||||
export interface ExportedPickersFadeTransitionGroupProps {
|
||||
className?: string;
|
||||
reduceAnimations: boolean;
|
||||
transKey: React.Key;
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes?: Partial<PickersFadeTransitionGroupClasses>;
|
||||
}
|
||||
export interface PickersFadeTransitionGroupProps extends ExportedPickersFadeTransitionGroupProps {
|
||||
children: React.ReactElement<any>;
|
||||
}
|
||||
/**
|
||||
* @ignore - do not document.
|
||||
*/
|
||||
export declare function PickersFadeTransitionGroup(inProps: PickersFadeTransitionGroupProps): React.JSX.Element;
|
||||
63
node_modules/@mui/x-date-pickers/esm/DateCalendar/PickersFadeTransitionGroup.js
generated
vendored
Normal file
63
node_modules/@mui/x-date-pickers/esm/DateCalendar/PickersFadeTransitionGroup.js
generated
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["children"];
|
||||
import * as React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { TransitionGroup } from 'react-transition-group';
|
||||
import Fade from '@mui/material/Fade';
|
||||
import { styled, useTheme, useThemeProps } from '@mui/material/styles';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import { getPickersFadeTransitionGroupUtilityClass } from "./pickersFadeTransitionGroupClasses.js";
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = classes => {
|
||||
const slots = {
|
||||
root: ['root']
|
||||
};
|
||||
return composeClasses(slots, getPickersFadeTransitionGroupUtilityClass, classes);
|
||||
};
|
||||
const PickersFadeTransitionGroupRoot = styled(TransitionGroup, {
|
||||
name: 'MuiPickersFadeTransitionGroup',
|
||||
slot: 'Root'
|
||||
})({
|
||||
display: 'block',
|
||||
position: 'relative'
|
||||
});
|
||||
|
||||
/**
|
||||
* @ignore - do not document.
|
||||
*/
|
||||
export function PickersFadeTransitionGroup(inProps) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiPickersFadeTransitionGroup'
|
||||
});
|
||||
const {
|
||||
className,
|
||||
reduceAnimations,
|
||||
transKey,
|
||||
classes: classesProp
|
||||
} = props;
|
||||
const {
|
||||
children
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const classes = useUtilityClasses(classesProp);
|
||||
const theme = useTheme();
|
||||
if (reduceAnimations) {
|
||||
return children;
|
||||
}
|
||||
return /*#__PURE__*/_jsx(PickersFadeTransitionGroupRoot, {
|
||||
className: clsx(classes.root, className),
|
||||
ownerState: other,
|
||||
children: /*#__PURE__*/_jsx(Fade, {
|
||||
appear: false,
|
||||
mountOnEnter: true,
|
||||
unmountOnExit: true,
|
||||
timeout: {
|
||||
appear: theme.transitions.duration.enteringScreen,
|
||||
enter: theme.transitions.duration.enteringScreen,
|
||||
exit: 0
|
||||
},
|
||||
children: children
|
||||
}, transKey)
|
||||
});
|
||||
}
|
||||
25
node_modules/@mui/x-date-pickers/esm/DateCalendar/PickersSlideTransition.d.ts
generated
vendored
Normal file
25
node_modules/@mui/x-date-pickers/esm/DateCalendar/PickersSlideTransition.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import * as React from 'react';
|
||||
import { CSSTransitionProps } from 'react-transition-group/CSSTransition';
|
||||
import { PickersSlideTransitionClasses } from "./pickersSlideTransitionClasses.js";
|
||||
import { PickerOwnerState } from "../models/pickers.js";
|
||||
export type SlideDirection = 'right' | 'left';
|
||||
export interface PickerSlideTransitionOwnerState extends PickerOwnerState {
|
||||
slideDirection: SlideDirection;
|
||||
}
|
||||
export interface ExportedSlideTransitionProps {
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes?: Partial<PickersSlideTransitionClasses>;
|
||||
}
|
||||
export interface SlideTransitionProps extends Omit<CSSTransitionProps, 'timeout'>, ExportedSlideTransitionProps {
|
||||
children: React.ReactElement<any>;
|
||||
className?: string;
|
||||
reduceAnimations: boolean;
|
||||
slideDirection: SlideDirection;
|
||||
transKey: React.Key;
|
||||
}
|
||||
/**
|
||||
* @ignore - do not document.
|
||||
*/
|
||||
export declare function PickersSlideTransition(inProps: SlideTransitionProps): React.JSX.Element;
|
||||
143
node_modules/@mui/x-date-pickers/esm/DateCalendar/PickersSlideTransition.js
generated
vendored
Normal file
143
node_modules/@mui/x-date-pickers/esm/DateCalendar/PickersSlideTransition.js
generated
vendored
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["children", "className", "reduceAnimations", "slideDirection", "transKey", "classes"];
|
||||
import * as React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { styled, useTheme, useThemeProps } from '@mui/material/styles';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import { CSSTransition, TransitionGroup } from 'react-transition-group';
|
||||
import { getPickersSlideTransitionUtilityClass, pickersSlideTransitionClasses } from "./pickersSlideTransitionClasses.js";
|
||||
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = (classes, ownerState) => {
|
||||
const {
|
||||
slideDirection
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root'],
|
||||
exit: ['slideExit'],
|
||||
enterActive: ['slideEnterActive'],
|
||||
enter: [`slideEnter-${slideDirection}`],
|
||||
exitActive: [`slideExitActiveLeft-${slideDirection}`]
|
||||
};
|
||||
return composeClasses(slots, getPickersSlideTransitionUtilityClass, classes);
|
||||
};
|
||||
const PickersSlideTransitionRoot = styled(TransitionGroup, {
|
||||
name: 'MuiPickersSlideTransition',
|
||||
slot: 'Root',
|
||||
overridesResolver: (_, styles) => [styles.root, {
|
||||
[`.${pickersSlideTransitionClasses['slideEnter-left']}`]: styles['slideEnter-left']
|
||||
}, {
|
||||
[`.${pickersSlideTransitionClasses['slideEnter-right']}`]: styles['slideEnter-right']
|
||||
}, {
|
||||
[`.${pickersSlideTransitionClasses.slideEnterActive}`]: styles.slideEnterActive
|
||||
}, {
|
||||
[`.${pickersSlideTransitionClasses.slideExit}`]: styles.slideExit
|
||||
}, {
|
||||
[`.${pickersSlideTransitionClasses['slideExitActiveLeft-left']}`]: styles['slideExitActiveLeft-left']
|
||||
}, {
|
||||
[`.${pickersSlideTransitionClasses['slideExitActiveLeft-right']}`]: styles['slideExitActiveLeft-right']
|
||||
}]
|
||||
})(({
|
||||
theme
|
||||
}) => {
|
||||
const slideTransition = theme.transitions.create('transform', {
|
||||
duration: theme.transitions.duration.complex,
|
||||
easing: 'cubic-bezier(0.35, 0.8, 0.4, 1)'
|
||||
});
|
||||
return {
|
||||
display: 'block',
|
||||
position: 'relative',
|
||||
overflowX: 'hidden',
|
||||
'& > *': {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
right: 0,
|
||||
left: 0
|
||||
},
|
||||
[`& .${pickersSlideTransitionClasses['slideEnter-left']}`]: {
|
||||
willChange: 'transform',
|
||||
transform: 'translate(100%)',
|
||||
zIndex: 1
|
||||
},
|
||||
[`& .${pickersSlideTransitionClasses['slideEnter-right']}`]: {
|
||||
willChange: 'transform',
|
||||
transform: 'translate(-100%)',
|
||||
zIndex: 1
|
||||
},
|
||||
[`& .${pickersSlideTransitionClasses.slideEnterActive}`]: {
|
||||
transform: 'translate(0%)',
|
||||
transition: slideTransition
|
||||
},
|
||||
[`& .${pickersSlideTransitionClasses.slideExit}`]: {
|
||||
transform: 'translate(0%)'
|
||||
},
|
||||
[`& .${pickersSlideTransitionClasses['slideExitActiveLeft-left']}`]: {
|
||||
willChange: 'transform',
|
||||
transform: 'translate(-100%)',
|
||||
transition: slideTransition,
|
||||
zIndex: 0
|
||||
},
|
||||
[`& .${pickersSlideTransitionClasses['slideExitActiveLeft-right']}`]: {
|
||||
willChange: 'transform',
|
||||
transform: 'translate(100%)',
|
||||
transition: slideTransition,
|
||||
zIndex: 0
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @ignore - do not document.
|
||||
*/
|
||||
export function PickersSlideTransition(inProps) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiPickersSlideTransition'
|
||||
});
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
reduceAnimations,
|
||||
slideDirection,
|
||||
transKey,
|
||||
classes: classesProp
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const {
|
||||
ownerState: pickerOwnerState
|
||||
} = usePickerPrivateContext();
|
||||
const ownerState = _extends({}, pickerOwnerState, {
|
||||
slideDirection
|
||||
});
|
||||
const classes = useUtilityClasses(classesProp, ownerState);
|
||||
const theme = useTheme();
|
||||
if (reduceAnimations) {
|
||||
return /*#__PURE__*/_jsx("div", {
|
||||
className: clsx(classes.root, className),
|
||||
children: children
|
||||
});
|
||||
}
|
||||
const transitionClasses = {
|
||||
exit: classes.exit,
|
||||
enterActive: classes.enterActive,
|
||||
enter: classes.enter,
|
||||
exitActive: classes.exitActive
|
||||
};
|
||||
return /*#__PURE__*/_jsx(PickersSlideTransitionRoot, {
|
||||
className: clsx(classes.root, className),
|
||||
childFactory: element => /*#__PURE__*/React.cloneElement(element, {
|
||||
classNames: transitionClasses
|
||||
}),
|
||||
role: "presentation",
|
||||
ownerState: ownerState,
|
||||
children: /*#__PURE__*/_jsx(CSSTransition, _extends({
|
||||
mountOnEnter: true,
|
||||
unmountOnExit: true,
|
||||
timeout: theme.transitions.duration.complex,
|
||||
classNames: transitionClasses
|
||||
}, other, {
|
||||
children: children
|
||||
}), transKey)
|
||||
});
|
||||
}
|
||||
9
node_modules/@mui/x-date-pickers/esm/DateCalendar/dateCalendarClasses.d.ts
generated
vendored
Normal file
9
node_modules/@mui/x-date-pickers/esm/DateCalendar/dateCalendarClasses.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
export interface DateCalendarClasses {
|
||||
/** Styles applied to the root element. */
|
||||
root: string;
|
||||
/** Styles applied to the transition group element. */
|
||||
viewTransitionContainer: string;
|
||||
}
|
||||
export type DateCalendarClassKey = keyof DateCalendarClasses;
|
||||
export declare const getDateCalendarUtilityClass: (slot: string) => string;
|
||||
export declare const dateCalendarClasses: DateCalendarClasses;
|
||||
4
node_modules/@mui/x-date-pickers/esm/DateCalendar/dateCalendarClasses.js
generated
vendored
Normal file
4
node_modules/@mui/x-date-pickers/esm/DateCalendar/dateCalendarClasses.js
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
export const getDateCalendarUtilityClass = slot => generateUtilityClass('MuiDateCalendar', slot);
|
||||
export const dateCalendarClasses = generateUtilityClasses('MuiDateCalendar', ['root', 'viewTransitionContainer']);
|
||||
23
node_modules/@mui/x-date-pickers/esm/DateCalendar/dayCalendarClasses.d.ts
generated
vendored
Normal file
23
node_modules/@mui/x-date-pickers/esm/DateCalendar/dayCalendarClasses.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
export interface DayCalendarClasses {
|
||||
/** Styles applied to the root element. */
|
||||
root: string;
|
||||
/** Styles applied to the header element. */
|
||||
header: string;
|
||||
/** Styles applied to the week day label element. */
|
||||
weekDayLabel: string;
|
||||
/** Styles applied to the loading container element. */
|
||||
loadingContainer: string;
|
||||
/** Styles applied to the slide transition element. */
|
||||
slideTransition: string;
|
||||
/** Styles applied to the month container element. */
|
||||
monthContainer: string;
|
||||
/** Styles applied to the week container element. */
|
||||
weekContainer: string;
|
||||
/** Styles applied to the week number header */
|
||||
weekNumberLabel: string;
|
||||
/** Styles applied to the week number element */
|
||||
weekNumber: string;
|
||||
}
|
||||
export type DayCalendarClassKey = keyof DayCalendarClasses;
|
||||
export declare const getDayCalendarUtilityClass: (slot: string) => string;
|
||||
export declare const dayCalendarClasses: DayCalendarClasses;
|
||||
4
node_modules/@mui/x-date-pickers/esm/DateCalendar/dayCalendarClasses.js
generated
vendored
Normal file
4
node_modules/@mui/x-date-pickers/esm/DateCalendar/dayCalendarClasses.js
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
export const getDayCalendarUtilityClass = slot => generateUtilityClass('MuiDayCalendar', slot);
|
||||
export const dayCalendarClasses = generateUtilityClasses('MuiDayCalendar', ['root', 'header', 'weekDayLabel', 'loadingContainer', 'slideTransition', 'monthContainer', 'weekContainer', 'weekNumberLabel', 'weekNumber']);
|
||||
12
node_modules/@mui/x-date-pickers/esm/DateCalendar/index.d.ts
generated
vendored
Normal file
12
node_modules/@mui/x-date-pickers/esm/DateCalendar/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
export { DateCalendar } from "./DateCalendar.js";
|
||||
export type { DateCalendarProps, DateCalendarSlots, DateCalendarSlotProps } from "./DateCalendar.types.js";
|
||||
export { getDateCalendarUtilityClass, dateCalendarClasses } from "./dateCalendarClasses.js";
|
||||
export type { DateCalendarClassKey, DateCalendarClasses } from "./dateCalendarClasses.js";
|
||||
export { dayCalendarClasses } from "./dayCalendarClasses.js";
|
||||
export type { DayCalendarClassKey, DayCalendarClasses } from "./dayCalendarClasses.js";
|
||||
export type { PickersFadeTransitionGroupProps, ExportedPickersFadeTransitionGroupProps } from "./PickersFadeTransitionGroup.js";
|
||||
export { pickersFadeTransitionGroupClasses } from "./pickersFadeTransitionGroupClasses.js";
|
||||
export type { PickersFadeTransitionGroupClassKey, PickersFadeTransitionGroupClasses } from "./pickersFadeTransitionGroupClasses.js";
|
||||
export { pickersSlideTransitionClasses } from "./pickersSlideTransitionClasses.js";
|
||||
export type { PickersSlideTransitionClassKey, PickersSlideTransitionClasses } from "./pickersSlideTransitionClasses.js";
|
||||
export type { ExportedSlideTransitionProps } from "./PickersSlideTransition.js";
|
||||
5
node_modules/@mui/x-date-pickers/esm/DateCalendar/index.js
generated
vendored
Normal file
5
node_modules/@mui/x-date-pickers/esm/DateCalendar/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
export { DateCalendar } from "./DateCalendar.js";
|
||||
export { getDateCalendarUtilityClass, dateCalendarClasses } from "./dateCalendarClasses.js";
|
||||
export { dayCalendarClasses } from "./dayCalendarClasses.js";
|
||||
export { pickersFadeTransitionGroupClasses } from "./pickersFadeTransitionGroupClasses.js";
|
||||
export { pickersSlideTransitionClasses } from "./pickersSlideTransitionClasses.js";
|
||||
7
node_modules/@mui/x-date-pickers/esm/DateCalendar/pickersFadeTransitionGroupClasses.d.ts
generated
vendored
Normal file
7
node_modules/@mui/x-date-pickers/esm/DateCalendar/pickersFadeTransitionGroupClasses.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export interface PickersFadeTransitionGroupClasses {
|
||||
/** Styles applied to the root element. */
|
||||
root: string;
|
||||
}
|
||||
export type PickersFadeTransitionGroupClassKey = keyof PickersFadeTransitionGroupClasses;
|
||||
export declare const getPickersFadeTransitionGroupUtilityClass: (slot: string) => string;
|
||||
export declare const pickersFadeTransitionGroupClasses: PickersFadeTransitionGroupClasses;
|
||||
4
node_modules/@mui/x-date-pickers/esm/DateCalendar/pickersFadeTransitionGroupClasses.js
generated
vendored
Normal file
4
node_modules/@mui/x-date-pickers/esm/DateCalendar/pickersFadeTransitionGroupClasses.js
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
export const getPickersFadeTransitionGroupUtilityClass = slot => generateUtilityClass('MuiPickersFadeTransitionGroup', slot);
|
||||
export const pickersFadeTransitionGroupClasses = generateUtilityClasses('MuiPickersFadeTransitionGroup', ['root']);
|
||||
19
node_modules/@mui/x-date-pickers/esm/DateCalendar/pickersSlideTransitionClasses.d.ts
generated
vendored
Normal file
19
node_modules/@mui/x-date-pickers/esm/DateCalendar/pickersSlideTransitionClasses.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
export interface PickersSlideTransitionClasses {
|
||||
/** Styles applied to the root element. */
|
||||
root: string;
|
||||
/** Styles applied to content element sliding in from left. */
|
||||
'slideEnter-left': string;
|
||||
/** Styles applied to content element sliding in from right. */
|
||||
'slideEnter-right': string;
|
||||
/** Styles applied to the element entering (transitioning into) the container. */
|
||||
slideEnterActive: string;
|
||||
/** Styles applied to the element leaving (transitioning out of) the container. */
|
||||
slideExit: string;
|
||||
/** Styles applied to the element on the left leaving (transitioning out of) the container. */
|
||||
'slideExitActiveLeft-left': string;
|
||||
/** Styles applied to the element on the right leaving (transitioning out of) the container. */
|
||||
'slideExitActiveLeft-right': string;
|
||||
}
|
||||
export type PickersSlideTransitionClassKey = keyof PickersSlideTransitionClasses;
|
||||
export declare const getPickersSlideTransitionUtilityClass: (slot: string) => string;
|
||||
export declare const pickersSlideTransitionClasses: PickersSlideTransitionClasses;
|
||||
4
node_modules/@mui/x-date-pickers/esm/DateCalendar/pickersSlideTransitionClasses.js
generated
vendored
Normal file
4
node_modules/@mui/x-date-pickers/esm/DateCalendar/pickersSlideTransitionClasses.js
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
export const getPickersSlideTransitionUtilityClass = slot => generateUtilityClass('MuiPickersSlideTransition', slot);
|
||||
export const pickersSlideTransitionClasses = generateUtilityClasses('MuiPickersSlideTransition', ['root', 'slideEnter-left', 'slideEnter-right', 'slideEnterActive', 'slideExit', 'slideExitActiveLeft-left', 'slideExitActiveLeft-right']);
|
||||
27
node_modules/@mui/x-date-pickers/esm/DateCalendar/useCalendarState.d.ts
generated
vendored
Normal file
27
node_modules/@mui/x-date-pickers/esm/DateCalendar/useCalendarState.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { SlideDirection } from "./PickersSlideTransition.js";
|
||||
import { PickersTimezone, PickerValidDate } from "../models/index.js";
|
||||
import { DateCalendarDefaultizedProps } from "./DateCalendar.types.js";
|
||||
interface CalendarState {
|
||||
currentMonth: PickerValidDate;
|
||||
focusedDay: PickerValidDate | null;
|
||||
isMonthSwitchingAnimating: boolean;
|
||||
slideDirection: SlideDirection;
|
||||
}
|
||||
interface UseCalendarStateParameters extends Pick<DateCalendarDefaultizedProps, 'referenceDate' | 'disableFuture' | 'disablePast' | 'minDate' | 'maxDate' | 'onMonthChange' | 'onYearChange' | 'reduceAnimations' | 'shouldDisableDate'> {
|
||||
value: PickerValidDate | null;
|
||||
timezone: PickersTimezone;
|
||||
getCurrentMonthFromVisibleDate: (focusedDay: PickerValidDate, prevMonth: PickerValidDate) => PickerValidDate;
|
||||
}
|
||||
interface UseCalendarStateReturnValue {
|
||||
referenceDate: PickerValidDate;
|
||||
calendarState: CalendarState;
|
||||
setVisibleDate: (parameters: SetVisibleDateParameters) => void;
|
||||
isDateDisabled: (day: PickerValidDate | null) => boolean;
|
||||
onMonthSwitchingAnimationEnd: () => void;
|
||||
}
|
||||
export declare const useCalendarState: (params: UseCalendarStateParameters) => UseCalendarStateReturnValue;
|
||||
interface SetVisibleDateParameters {
|
||||
target: PickerValidDate;
|
||||
reason: 'header-navigation' | 'cell-interaction' | 'controlled-value-change';
|
||||
}
|
||||
export {};
|
||||
156
node_modules/@mui/x-date-pickers/esm/DateCalendar/useCalendarState.js
generated
vendored
Normal file
156
node_modules/@mui/x-date-pickers/esm/DateCalendar/useCalendarState.js
generated
vendored
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import * as React from 'react';
|
||||
import useEventCallback from '@mui/utils/useEventCallback';
|
||||
import { useIsDateDisabled } from "./useIsDateDisabled.js";
|
||||
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
||||
import { SECTION_TYPE_GRANULARITY } from "../internals/utils/getDefaultReferenceDate.js";
|
||||
import { findClosestEnabledDate } from "../internals/utils/date-utils.js";
|
||||
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
||||
const createCalendarStateReducer = (reduceAnimations, adapter) => (state, action) => {
|
||||
switch (action.type) {
|
||||
case 'setVisibleDate':
|
||||
return _extends({}, state, {
|
||||
slideDirection: action.direction,
|
||||
currentMonth: action.month,
|
||||
isMonthSwitchingAnimating: !adapter.isSameMonth(action.month, state.currentMonth) && !reduceAnimations && !action.skipAnimation,
|
||||
focusedDay: action.focusedDay
|
||||
});
|
||||
case 'changeMonthTimezone':
|
||||
{
|
||||
const newTimezone = action.newTimezone;
|
||||
if (adapter.getTimezone(state.currentMonth) === newTimezone) {
|
||||
return state;
|
||||
}
|
||||
let newCurrentMonth = adapter.setTimezone(state.currentMonth, newTimezone);
|
||||
if (adapter.getMonth(newCurrentMonth) !== adapter.getMonth(state.currentMonth)) {
|
||||
newCurrentMonth = adapter.setMonth(newCurrentMonth, adapter.getMonth(state.currentMonth));
|
||||
}
|
||||
return _extends({}, state, {
|
||||
currentMonth: newCurrentMonth
|
||||
});
|
||||
}
|
||||
case 'finishMonthSwitchingAnimation':
|
||||
return _extends({}, state, {
|
||||
isMonthSwitchingAnimating: false
|
||||
});
|
||||
default:
|
||||
throw new Error('missing support');
|
||||
}
|
||||
};
|
||||
export const useCalendarState = params => {
|
||||
const {
|
||||
value,
|
||||
referenceDate: referenceDateProp,
|
||||
disableFuture,
|
||||
disablePast,
|
||||
maxDate,
|
||||
minDate,
|
||||
onMonthChange,
|
||||
onYearChange,
|
||||
reduceAnimations,
|
||||
shouldDisableDate,
|
||||
timezone,
|
||||
getCurrentMonthFromVisibleDate
|
||||
} = params;
|
||||
const adapter = usePickerAdapter();
|
||||
const reducerFn = React.useRef(createCalendarStateReducer(Boolean(reduceAnimations), adapter)).current;
|
||||
const referenceDate = React.useMemo(() => {
|
||||
return singleItemValueManager.getInitialReferenceValue({
|
||||
value,
|
||||
adapter,
|
||||
timezone,
|
||||
props: params,
|
||||
referenceDate: referenceDateProp,
|
||||
granularity: SECTION_TYPE_GRANULARITY.day
|
||||
});
|
||||
},
|
||||
// We want the `referenceDate` to update on prop and `timezone` change (https://github.com/mui/mui-x/issues/10804)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[referenceDateProp, timezone]);
|
||||
const [calendarState, dispatch] = React.useReducer(reducerFn, {
|
||||
isMonthSwitchingAnimating: false,
|
||||
focusedDay: referenceDate,
|
||||
currentMonth: adapter.startOfMonth(referenceDate),
|
||||
slideDirection: 'left'
|
||||
});
|
||||
const isDateDisabled = useIsDateDisabled({
|
||||
shouldDisableDate,
|
||||
minDate,
|
||||
maxDate,
|
||||
disableFuture,
|
||||
disablePast,
|
||||
timezone
|
||||
});
|
||||
|
||||
// Ensure that `calendarState.currentMonth` timezone is updated when `referenceDate` (or timezone changes)
|
||||
// https://github.com/mui/mui-x/issues/10804
|
||||
React.useEffect(() => {
|
||||
dispatch({
|
||||
type: 'changeMonthTimezone',
|
||||
newTimezone: adapter.getTimezone(referenceDate)
|
||||
});
|
||||
}, [referenceDate, adapter]);
|
||||
const setVisibleDate = useEventCallback(({
|
||||
target,
|
||||
reason
|
||||
}) => {
|
||||
if (reason === 'cell-interaction' && calendarState.focusedDay != null && adapter.isSameDay(target, calendarState.focusedDay)) {
|
||||
return;
|
||||
}
|
||||
const skipAnimation = reason === 'cell-interaction';
|
||||
let month;
|
||||
let focusedDay;
|
||||
if (reason === 'cell-interaction') {
|
||||
month = getCurrentMonthFromVisibleDate(target, calendarState.currentMonth);
|
||||
focusedDay = target;
|
||||
} else {
|
||||
month = adapter.isSameMonth(target, calendarState.currentMonth) ? calendarState.currentMonth : adapter.startOfMonth(target);
|
||||
focusedDay = target;
|
||||
|
||||
// If the date is disabled, we try to find a non-disabled date inside the same month.
|
||||
if (isDateDisabled(focusedDay)) {
|
||||
const startOfMonth = adapter.startOfMonth(target);
|
||||
const endOfMonth = adapter.endOfMonth(target);
|
||||
focusedDay = findClosestEnabledDate({
|
||||
adapter,
|
||||
date: focusedDay,
|
||||
minDate: adapter.isBefore(minDate, startOfMonth) ? startOfMonth : minDate,
|
||||
maxDate: adapter.isAfter(maxDate, endOfMonth) ? endOfMonth : maxDate,
|
||||
disablePast,
|
||||
disableFuture,
|
||||
isDateDisabled,
|
||||
timezone
|
||||
});
|
||||
}
|
||||
}
|
||||
const hasChangedMonth = !adapter.isSameMonth(calendarState.currentMonth, month);
|
||||
const hasChangedYear = !adapter.isSameYear(calendarState.currentMonth, month);
|
||||
if (hasChangedMonth) {
|
||||
onMonthChange?.(month);
|
||||
}
|
||||
if (hasChangedYear) {
|
||||
onYearChange?.(adapter.startOfYear(month));
|
||||
}
|
||||
dispatch({
|
||||
type: 'setVisibleDate',
|
||||
month,
|
||||
direction: adapter.isAfterDay(month, calendarState.currentMonth) ? 'left' : 'right',
|
||||
focusedDay: calendarState.focusedDay != null && focusedDay != null && adapter.isSameDay(focusedDay, calendarState.focusedDay) ? calendarState.focusedDay : focusedDay,
|
||||
skipAnimation
|
||||
});
|
||||
});
|
||||
const onMonthSwitchingAnimationEnd = React.useCallback(() => {
|
||||
dispatch({
|
||||
type: 'finishMonthSwitchingAnimation'
|
||||
});
|
||||
}, []);
|
||||
return {
|
||||
referenceDate,
|
||||
calendarState,
|
||||
setVisibleDate,
|
||||
isDateDisabled,
|
||||
onMonthSwitchingAnimationEnd
|
||||
};
|
||||
};
|
||||
13
node_modules/@mui/x-date-pickers/esm/DateCalendar/useIsDateDisabled.d.ts
generated
vendored
Normal file
13
node_modules/@mui/x-date-pickers/esm/DateCalendar/useIsDateDisabled.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { DefaultizedProps } from '@mui/x-internals/types';
|
||||
import { ValidateDateProps } from "../validation/index.js";
|
||||
import { PickerValidDate, TimezoneProps } from "../models/index.js";
|
||||
export declare const useIsDateDisabled: ({
|
||||
shouldDisableDate,
|
||||
shouldDisableMonth,
|
||||
shouldDisableYear,
|
||||
minDate,
|
||||
maxDate,
|
||||
disableFuture,
|
||||
disablePast,
|
||||
timezone
|
||||
}: ValidateDateProps & DefaultizedProps<TimezoneProps, "timezone">) => (day: PickerValidDate | null) => boolean;
|
||||
31
node_modules/@mui/x-date-pickers/esm/DateCalendar/useIsDateDisabled.js
generated
vendored
Normal file
31
node_modules/@mui/x-date-pickers/esm/DateCalendar/useIsDateDisabled.js
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { validateDate } from "../validation/index.js";
|
||||
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
||||
export const useIsDateDisabled = ({
|
||||
shouldDisableDate,
|
||||
shouldDisableMonth,
|
||||
shouldDisableYear,
|
||||
minDate,
|
||||
maxDate,
|
||||
disableFuture,
|
||||
disablePast,
|
||||
timezone
|
||||
}) => {
|
||||
const adapter = usePickerAdapter();
|
||||
return React.useCallback(day => validateDate({
|
||||
adapter,
|
||||
value: day,
|
||||
timezone,
|
||||
props: {
|
||||
shouldDisableDate,
|
||||
shouldDisableMonth,
|
||||
shouldDisableYear,
|
||||
minDate,
|
||||
maxDate,
|
||||
disableFuture,
|
||||
disablePast
|
||||
}
|
||||
}) !== null, [adapter, shouldDisableDate, shouldDisableMonth, shouldDisableYear, minDate, maxDate, disableFuture, disablePast, timezone]);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue