import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _excluded = ["localeText"]; import * as React from 'react'; import PropTypes from 'prop-types'; import { useThemeProps } from '@mui/material/styles'; import { jsx as _jsx } from "react/jsx-runtime"; export var MuiPickersAdapterContext = /*#__PURE__*/React.createContext(null); if (process.env.NODE_ENV !== 'production') { MuiPickersAdapterContext.displayName = 'MuiPickersAdapterContext'; } /** * Demos: * * - [Date format and localization](https://mui.com/x/react-date-pickers/adapters-locale/) * - [Calendar systems](https://mui.com/x/react-date-pickers/calendar-systems/) * - [Translated components](https://mui.com/x/react-date-pickers/localization/) * - [UTC and timezones](https://mui.com/x/react-date-pickers/timezone/) * * API: * * - [LocalizationProvider API](https://mui.com/x/api/date-pickers/localization-provider/) */ export var LocalizationProvider = function LocalizationProvider(inProps) { var _React$useContext; var inLocaleText = inProps.localeText, otherInProps = _objectWithoutProperties(inProps, _excluded); var _ref = (_React$useContext = React.useContext(MuiPickersAdapterContext)) != null ? _React$useContext : { utils: undefined, localeText: undefined }, parentUtils = _ref.utils, parentLocaleText = _ref.localeText; var props = useThemeProps({ // We don't want to pass the `localeText` prop to the theme, that way it will always return the theme value, // We will then merge this theme value with our value manually props: otherInProps, name: 'MuiLocalizationProvider' }); var children = props.children, DateAdapter = props.dateAdapter, dateFormats = props.dateFormats, dateLibInstance = props.dateLibInstance, adapterLocale = props.adapterLocale, themeLocaleText = props.localeText; var localeText = React.useMemo(function () { return _extends({}, themeLocaleText, parentLocaleText, inLocaleText); }, [themeLocaleText, parentLocaleText, inLocaleText]); var utils = React.useMemo(function () { if (!DateAdapter) { if (parentUtils) { return parentUtils; } return null; } var adapter = new DateAdapter({ locale: adapterLocale, formats: dateFormats, instance: dateLibInstance }); if (!adapter.isMUIAdapter) { throw new Error(['MUI: The date adapter should be imported from `@mui/x-date-pickers` or `@mui/x-date-pickers-pro`, not from `@date-io`', "For example, `import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'` instead of `import AdapterDayjs from '@date-io/dayjs'`", 'More information on the installation documentation: https://mui.com/x/react-date-pickers/getting-started/#installation'].join("\n")); } return adapter; }, [DateAdapter, adapterLocale, dateFormats, dateLibInstance, parentUtils]); var defaultDates = React.useMemo(function () { if (!utils) { return null; } return { minDate: utils.date('1900-01-01T00:00:00.000'), maxDate: utils.date('2099-12-31T00:00:00.000') }; }, [utils]); var contextValue = React.useMemo(function () { return { utils: utils, defaultDates: defaultDates, localeText: localeText }; }, [defaultDates, utils, localeText]); return /*#__PURE__*/_jsx(MuiPickersAdapterContext.Provider, { value: contextValue, children: children }); }; process.env.NODE_ENV !== "production" ? LocalizationProvider.propTypes = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- /** * Locale for the date library you are using */ adapterLocale: PropTypes.any, children: PropTypes.node, /** * Date library adapter class function. * @see See the localization provider {@link https://mui.com/x/react-date-pickers/getting-started/#setup-your-date-library-adapter date adapter setup section} for more details. */ dateAdapter: PropTypes.func, /** * Formats that are used for any child pickers */ dateFormats: PropTypes.shape({ dayOfMonth: PropTypes.string, fullDate: PropTypes.string, fullDateTime: PropTypes.string, fullDateTime12h: PropTypes.string, fullDateTime24h: PropTypes.string, fullDateWithWeekday: PropTypes.string, fullTime: PropTypes.string, fullTime12h: PropTypes.string, fullTime24h: PropTypes.string, hours12h: PropTypes.string, hours24h: PropTypes.string, keyboardDate: PropTypes.string, keyboardDateTime: PropTypes.string, keyboardDateTime12h: PropTypes.string, keyboardDateTime24h: PropTypes.string, meridiem: PropTypes.string, minutes: PropTypes.string, month: PropTypes.string, monthAndDate: PropTypes.string, monthAndYear: PropTypes.string, monthShort: PropTypes.string, normalDate: PropTypes.string, normalDateWithWeekday: PropTypes.string, seconds: PropTypes.string, shortDate: PropTypes.string, weekday: PropTypes.string, weekdayShort: PropTypes.string, year: PropTypes.string }), /** * Date library instance you are using, if it has some global overrides * ```jsx * dateLibInstance={momentTimeZone} * ``` */ dateLibInstance: PropTypes.any, /** * Locale for components texts */ localeText: PropTypes.object } : void 0;