stupa-pdf-api/frontend/node_modules/@mui/x-date-pickers/legacy/DatePicker/DatePickerToolbar.js

143 lines
5.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _extends from "@babel/runtime/helpers/esm/extends";
var _excluded = ["value", "isLandscape", "onChange", "toolbarFormat", "toolbarPlaceholder", "views", "className"];
import * as React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import Typography from '@mui/material/Typography';
import { styled, useThemeProps } from '@mui/material/styles';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { PickersToolbar } from '../internals/components/PickersToolbar';
import { useLocaleText, useUtils } from '../internals/hooks/useUtils';
import { getDatePickerToolbarUtilityClass } from './datePickerToolbarClasses';
import { resolveDateFormat } from '../internals/utils/date-utils';
import { jsx as _jsx } from "react/jsx-runtime";
var useUtilityClasses = function useUtilityClasses(ownerState) {
var classes = ownerState.classes;
var slots = {
root: ['root'],
title: ['title']
};
return composeClasses(slots, getDatePickerToolbarUtilityClass, classes);
};
var DatePickerToolbarRoot = styled(PickersToolbar, {
name: 'MuiDatePickerToolbar',
slot: 'Root',
overridesResolver: function overridesResolver(_, styles) {
return styles.root;
}
})({});
var DatePickerToolbarTitle = styled(Typography, {
name: 'MuiDatePickerToolbar',
slot: 'Title',
overridesResolver: function overridesResolver(_, styles) {
return styles.title;
}
})(function (_ref) {
var ownerState = _ref.ownerState;
return _extends({}, ownerState.isLandscape && {
margin: 'auto 16px auto auto'
});
});
/**
* Demos:
*
* - [DatePicker](https://mui.com/x/react-date-pickers/date-picker/)
* - [Custom components](https://mui.com/x/react-date-pickers/custom-components/)
*
* API:
*
* - [DatePickerToolbar API](https://mui.com/x/api/date-pickers/date-picker-toolbar/)
*/
export var DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePickerToolbar(inProps, ref) {
var props = useThemeProps({
props: inProps,
name: 'MuiDatePickerToolbar'
});
var value = props.value,
isLandscape = props.isLandscape,
onChange = props.onChange,
toolbarFormat = props.toolbarFormat,
_props$toolbarPlaceho = props.toolbarPlaceholder,
toolbarPlaceholder = _props$toolbarPlaceho === void 0 ? '' : _props$toolbarPlaceho,
views = props.views,
className = props.className,
other = _objectWithoutProperties(props, _excluded);
var utils = useUtils();
var localeText = useLocaleText();
var classes = useUtilityClasses(props);
var dateText = React.useMemo(function () {
if (!value) {
return toolbarPlaceholder;
}
var formatFromViews = resolveDateFormat(utils, {
format: toolbarFormat,
views: views
}, true);
return utils.formatByString(value, formatFromViews);
}, [value, toolbarFormat, toolbarPlaceholder, utils, views]);
var ownerState = props;
return /*#__PURE__*/_jsx(DatePickerToolbarRoot, _extends({
ref: ref,
toolbarTitle: localeText.datePickerToolbarTitle,
isLandscape: isLandscape,
className: clsx(classes.root, className)
}, other, {
children: /*#__PURE__*/_jsx(DatePickerToolbarTitle, {
variant: "h4",
align: isLandscape ? 'left' : 'center',
ownerState: ownerState,
className: classes.title,
children: dateText
})
}));
});
process.env.NODE_ENV !== "production" ? DatePickerToolbar.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
/**
* className applied to the root component.
*/
className: PropTypes.string,
disabled: PropTypes.bool,
/**
* If `true`, show the toolbar even in desktop mode.
* @default `true` for Desktop, `false` for Mobile.
*/
hidden: PropTypes.bool,
isLandscape: PropTypes.bool.isRequired,
onChange: PropTypes.func.isRequired,
/**
* Callback called when a toolbar is clicked
* @template TView
* @param {TView} view The view to open
*/
onViewChange: PropTypes.func.isRequired,
readOnly: PropTypes.bool,
/**
* 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]),
titleId: PropTypes.string,
/**
* Toolbar date format.
*/
toolbarFormat: PropTypes.string,
/**
* Toolbar value placeholder—it is displayed when the value is empty.
* @default ""
*/
toolbarPlaceholder: PropTypes.node,
value: PropTypes.any,
/**
* Currently visible picker view.
*/
view: PropTypes.oneOf(['day', 'month', 'year']).isRequired,
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'month', 'year']).isRequired).isRequired
} : void 0;