@material-ui/lab
Version:
Laboratory for new Material-UI modules.
477 lines (394 loc) • 13.9 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _styles = require("@material-ui/core/styles");
var _useMediaQuery = _interopRequireDefault(require("@material-ui/core/useMediaQuery"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _DesktopDatePicker = _interopRequireDefault(require("../DesktopDatePicker"));
var _MobileDatePicker = _interopRequireDefault(require("../MobileDatePicker"));
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["cancelText", "clearable", "clearText", "desktopModeMediaQuery", "DialogProps", "okText", "PopperProps", "showTodayButton", "todayText", "TransitionComponent"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
*
* Demos:
*
* - [Date Picker](https://material-ui.com/components/date-picker/)
* - [Pickers](https://material-ui.com/components/pickers/)
*
* API:
*
* - [DatePicker API](https://material-ui.com/api/date-picker/)
*/
const DatePicker = /*#__PURE__*/React.forwardRef(function DatePicker(inProps, ref) {
const props = (0, _styles.useThemeProps)({
props: inProps,
name: 'MuiDatePicker'
});
const {
cancelText,
clearable,
clearText,
desktopModeMediaQuery = '@media (pointer: fine)',
DialogProps,
okText,
PopperProps,
showTodayButton,
todayText,
TransitionComponent
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const isDesktop = (0, _useMediaQuery.default)(desktopModeMediaQuery);
return isDesktop ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_DesktopDatePicker.default, (0, _extends2.default)({
ref: ref,
PopperProps: PopperProps,
TransitionComponent: TransitionComponent
}, other)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_MobileDatePicker.default, (0, _extends2.default)({
ref: ref,
cancelText: cancelText,
clearable: clearable,
clearText: clearText,
DialogProps: DialogProps,
okText: okText,
showTodayButton: showTodayButton,
todayText: todayText
}, other));
});
process.env.NODE_ENV !== "production" ? DatePicker.propTypes
/* remove-proptypes */
= {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* Regular expression to detect "accepted" symbols.
* @default /\dap/gi
*/
acceptRegex: _propTypes.default.instanceOf(RegExp),
/**
* If `true`, `onChange` is fired on click even if the same date is selected.
* @default false
*/
allowSameDateSelection: _propTypes.default.bool,
/**
* @ignore
*/
autoFocus: _propTypes.default.bool,
/**
* Cancel text message.
* @default 'Cancel'
*/
cancelText: _propTypes.default.node,
/**
* @ignore
*/
children: _propTypes.default.node,
/**
* className applied to the root component.
*/
className: _propTypes.default.string,
/**
* If `true`, it shows the clear action in the picker dialog.
* @default false
*/
clearable: _propTypes.default.bool,
/**
* Clear text message.
* @default 'Clear'
*/
clearText: _propTypes.default.node,
/**
* The components used for each slot.
* Either a string to use a HTML element or a component.
* @default {}
*/
components: _propTypes.default.shape({
LeftArrowButton: _propTypes.default.elementType,
LeftArrowIcon: _propTypes.default.elementType,
OpenPickerIcon: _propTypes.default.elementType,
RightArrowButton: _propTypes.default.elementType,
RightArrowIcon: _propTypes.default.elementType,
SwitchViewButton: _propTypes.default.elementType,
SwitchViewIcon: _propTypes.default.elementType
}),
/**
* The props used for each slot inside.
* @default {}
*/
componentsProps: _propTypes.default.object,
/**
* Default calendar month displayed when `value={null}`.
*/
defaultCalendarMonth: _propTypes.default.any,
/**
* CSS media query when `Mobile` mode will be changed to `Desktop`.
* @default '@media (pointer: fine)'
* @example '@media (min-width: 720px)' or theme.breakpoints.up("sm")
*/
desktopModeMediaQuery: _propTypes.default.string,
/**
* Props applied to the [`Dialog`](/api/dialog/) element.
*/
DialogProps: _propTypes.default.object,
/**
* If `true` the popup or dialog will immediately close after submitting full date.
* @default `true` for Desktop, `false` for Mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
*/
disableCloseOnSelect: _propTypes.default.bool,
/**
* If `true`, the picker and text field are disabled.
*/
disabled: _propTypes.default.bool,
/**
* @default false
*/
disableFuture: _propTypes.default.bool,
/**
* If `true`, todays date is rendering without highlighting with circle.
* @default false
*/
disableHighlightToday: _propTypes.default.bool,
/**
* Disable mask on the keyboard, this should be used rarely. Consider passing proper mask for your format.
* @default false
*/
disableMaskedInput: _propTypes.default.bool,
/**
* Do not render open picker button (renders only text field with validation).
* @default false
*/
disableOpenPicker: _propTypes.default.bool,
/**
* @default false
*/
disablePast: _propTypes.default.bool,
/**
* Get aria-label text for control that opens picker dialog. Aria-label text must include selected date. @DateIOType
* @default (value, utils) => `Choose date, selected date is ${utils.format(utils.date(value), 'fullDate')}`
*/
getOpenDialogAriaText: _propTypes.default.func,
/**
* Get aria-label text for switching between views button.
*/
getViewSwitchingButtonText: _propTypes.default.func,
/**
* @ignore
*/
ignoreInvalidInputs: _propTypes.default.bool,
/**
* Props to pass to keyboard input adornment.
*/
InputAdornmentProps: _propTypes.default.object,
/**
* Format string.
*/
inputFormat: _propTypes.default.string,
/**
* @ignore
*/
InputProps: _propTypes.default.object,
/**
* Pass a ref to the `input` element.
*/
inputRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
current: _propTypes.default.object
})]),
/**
* @ignore
*/
key: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
/**
* @ignore
*/
label: _propTypes.default.node,
/**
* Left arrow icon aria-label text.
*/
leftArrowButtonText: _propTypes.default.string,
/**
* If `true` renders `LoadingComponent` in calendar instead of calendar view.
* Can be used to preload information and show it in calendar.
* @default false
*/
loading: _propTypes.default.bool,
/**
* Custom mask. Can be used to override generate from format. (e.g. `__/__/____ __:__` or `__/__/____ __:__ _M`).
*/
mask: _propTypes.default.string,
/**
* Max selectable date. @DateIOType
*/
maxDate: _propTypes.default.any,
/**
* Min selectable date. @DateIOType
*/
minDate: _propTypes.default.any,
/**
* Ok button text.
* @default 'OK'
*/
okText: _propTypes.default.node,
/**
* Callback fired when date is accepted @DateIOType.
*/
onAccept: _propTypes.default.func,
/**
* Callback fired when the value (the selected date) changes @DateIOType.
*/
onChange: _propTypes.default.func.isRequired,
/**
* Callback fired when the popup requests to be closed.
* Use in controlled mode (see open).
*/
onClose: _propTypes.default.func,
/**
* Callback that fired when input value or new `value` prop validation returns **new** validation error (or value is valid after error).
* In case of validation error detected `reason` prop return non-null value and `TextField` must be displayed in `error` state.
* This can be used to render appropriate form error.
*
* [Read the guide](https://next.material-ui-pickers.dev/guides/forms) about form integration and error displaying.
* @DateIOType
*/
onError: _propTypes.default.func,
/**
* Callback firing on month change. @DateIOType
*/
onMonthChange: _propTypes.default.func,
/**
* Callback fired when the popup requests to be opened.
* Use in controlled mode (see open).
*/
onOpen: _propTypes.default.func,
/**
* Callback fired on view change.
*/
onViewChange: _propTypes.default.func,
/**
* Callback firing on year change @DateIOType.
*/
onYearChange: _propTypes.default.func,
/**
* Control the popup or dialog open state.
*/
open: _propTypes.default.bool,
/**
* Props to pass to keyboard adornment button.
*/
OpenPickerButtonProps: _propTypes.default.object,
/**
* First view to show.
*/
openTo: _propTypes.default.oneOf(['day', 'month', 'year']),
/**
* Force rendering in particular orientation.
*/
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
/**
* Popper props passed down to [Popper](https://material-ui.com/api/popper/) component.
*/
PopperProps: _propTypes.default.object,
/**
* Make picker read only.
*/
readOnly: _propTypes.default.bool,
/**
* Disable heavy animations.
* @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
*/
reduceAnimations: _propTypes.default.bool,
/**
* Custom renderer for day. Check the [PickersDay](https://material-ui.com/api/pickers-day/) component.
*/
renderDay: _propTypes.default.func,
/**
* The `renderInput` prop allows you to customize the rendered input.
* The `props` argument of this render prop contains props of [TextField](https://material-ui.com/api/text-field/#textfield-api) that you need to forward.
* Pay specific attention to the `ref` and `inputProps` keys.
* @example ```jsx
* renderInput={props => <TextField {...props} />}
* ````
*/
renderInput: _propTypes.default.func.isRequired,
/**
* Component displaying when passed `loading` true.
* @default () => <span data-mui-test="loading-progress">...</span>
*/
renderLoading: _propTypes.default.func,
/**
* Custom formatter to be passed into Rifm component.
*/
rifmFormatter: _propTypes.default.func,
/**
* Right arrow icon aria-label text.
*/
rightArrowButtonText: _propTypes.default.string,
/**
* Disable specific date. @DateIOType
*/
shouldDisableDate: _propTypes.default.func,
/**
* Disable specific years dynamically.
* Works like `shouldDisableDate` but for year selection view @DateIOType.
*/
shouldDisableYear: _propTypes.default.func,
/**
* If `true`, days that have `outsideCurrentMonth={true}` are displayed.
* @default false
*/
showDaysOutsideCurrentMonth: _propTypes.default.bool,
/**
* If `true`, the today button is displayed. **Note** that `showClearButton` has a higher priority.
* @default false
*/
showTodayButton: _propTypes.default.bool,
/**
* If `true`, show the toolbar even in desktop mode.
*/
showToolbar: _propTypes.default.bool,
/**
* Today text message.
* @default 'Today'
*/
todayText: _propTypes.default.node,
/**
* Component that will replace default toolbar renderer.
* @default DatePickerToolbar
*/
ToolbarComponent: _propTypes.default.elementType,
/**
* Date format, that is displaying in toolbar.
*/
toolbarFormat: _propTypes.default.string,
/**
* Mobile picker date value placeholder, displaying if `value` === `null`.
* @default '–'
*/
toolbarPlaceholder: _propTypes.default.node,
/**
* Mobile picker title, displaying in the toolbar.
* @default 'Select date'
*/
toolbarTitle: _propTypes.default.node,
/**
* Custom component for popper [Transition](https://material-ui.com/components/transitions/#transitioncomponent-prop).
*/
TransitionComponent: _propTypes.default.elementType,
/**
* The value of the picker.
*/
value: _propTypes.default.oneOfType([_propTypes.default.any, _propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]),
/**
* Array of views to show.
*/
views: _propTypes.default.arrayOf(_propTypes.default.oneOf(['day', 'month', 'year']).isRequired)
} : void 0;
var _default = DatePicker;
exports.default = _default;