import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _excluded = ["components", "componentsProps", "slots", "slotProps", "InputProps", "inputProps"], _excluded2 = ["inputRef"], _excluded3 = ["ref", "onPaste", "onKeyDown", "inputMode", "readOnly", "clearable", "onClear"]; import * as React from 'react'; import PropTypes from 'prop-types'; import MuiTextField from '@mui/material/TextField'; import { useThemeProps } from '@mui/material/styles'; import { useSlotProps } from '@mui/base/utils'; import { refType } from '@mui/utils'; import { useDateTimeField } from './useDateTimeField'; import { useClearableField } from '../hooks'; import { jsx as _jsx } from "react/jsx-runtime"; /** * Demos: * * - [DateTimeField](http://mui.com/x/react-date-pickers/date-time-field/) * - [Fields](https://mui.com/x/react-date-pickers/fields/) * * API: * * - [DateTimeField API](https://mui.com/x/api/date-pickers/date-time-field/) */ var DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inProps, ref) { var _ref, _slots$textField, _slotProps$textField; var themeProps = useThemeProps({ props: inProps, name: 'MuiDateTimeField' }); var components = themeProps.components, componentsProps = themeProps.componentsProps, slots = themeProps.slots, slotProps = themeProps.slotProps, InputProps = themeProps.InputProps, inputProps = themeProps.inputProps, other = _objectWithoutProperties(themeProps, _excluded); var ownerState = themeProps; var TextField = (_ref = (_slots$textField = slots == null ? void 0 : slots.textField) != null ? _slots$textField : components == null ? void 0 : components.TextField) != null ? _ref : MuiTextField; var _useSlotProps = useSlotProps({ elementType: TextField, externalSlotProps: (_slotProps$textField = slotProps == null ? void 0 : slotProps.textField) != null ? _slotProps$textField : componentsProps == null ? void 0 : componentsProps.textField, externalForwardedProps: other, ownerState: ownerState }), externalInputRef = _useSlotProps.inputRef, textFieldProps = _objectWithoutProperties(_useSlotProps, _excluded2); // TODO: Remove when mui/material-ui#35088 will be merged textFieldProps.inputProps = _extends({}, inputProps, textFieldProps.inputProps); textFieldProps.InputProps = _extends({}, InputProps, textFieldProps.InputProps); var _useDateTimeField = useDateTimeField({ props: textFieldProps, inputRef: externalInputRef }), inputRef = _useDateTimeField.ref, onPaste = _useDateTimeField.onPaste, onKeyDown = _useDateTimeField.onKeyDown, inputMode = _useDateTimeField.inputMode, readOnly = _useDateTimeField.readOnly, clearable = _useDateTimeField.clearable, onClear = _useDateTimeField.onClear, fieldProps = _objectWithoutProperties(_useDateTimeField, _excluded3); var _useClearableField = useClearableField({ onClear: onClear, clearable: clearable, fieldProps: fieldProps, InputProps: fieldProps.InputProps, slots: slots, slotProps: slotProps, components: components, componentsProps: componentsProps }), ProcessedInputProps = _useClearableField.InputProps, processedFieldProps = _useClearableField.fieldProps; return /*#__PURE__*/_jsx(TextField, _extends({ ref: ref }, processedFieldProps, { InputProps: _extends({}, ProcessedInputProps, { readOnly: readOnly }), inputProps: _extends({}, fieldProps.inputProps, { inputMode: inputMode, onPaste: onPaste, onKeyDown: onKeyDown, ref: inputRef }) })); }); process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- /** * 12h/24h view for hour selection clock. * @default `utils.is12HourCycleInCurrentLocale()` */ ampm: PropTypes.bool, /** * If `true`, the `input` element is focused during the first mount. * @default false */ autoFocus: PropTypes.bool, className: PropTypes.string, /** * If `true`, a clear button will be shown in the field allowing value clearing. * @default false */ clearable: PropTypes.bool, /** * The color of the component. * It supports both default and custom theme colors, which can be added as shown in the * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors). * @default 'primary' */ color: PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']), component: PropTypes.elementType, /** * Overridable components. * @default {} * @deprecated Please use `slots`. */ components: PropTypes.object, /** * The props used for each component slot. * @default {} * @deprecated Please use `slotProps`. */ componentsProps: PropTypes.object, /** * The default value. Use when the component is not controlled. */ defaultValue: PropTypes.any, /** * If `true`, the component is disabled. * @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, /** * Do not ignore date part when validating min/max time. * @default false */ disableIgnoringDatePartForTimeValidation: 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 component is displayed in focused state. */ focused: PropTypes.bool, /** * Format of the date when rendered in the input(s). */ format: PropTypes.string, /** * Density of the format when rendered in the input. * Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character. * @default "dense" */ formatDensity: PropTypes.oneOf(['dense', 'spacious']), /** * Props applied to the [`FormHelperText`](/material-ui/api/form-helper-text/) element. */ FormHelperTextProps: PropTypes.object, /** * If `true`, the input will take up the full width of its container. * @default false */ fullWidth: PropTypes.bool, /** * The helper text content. */ helperText: PropTypes.node, /** * If `true`, the label is hidden. * This is used to increase density for a `FilledInput`. * Be sure to add `aria-label` to the `input` element. * @default false */ hiddenLabel: PropTypes.bool, /** * The id of the `input` element. * Use this prop to make `label` and `helperText` accessible for screen readers. */ id: PropTypes.string, /** * Props applied to the [`InputLabel`](/material-ui/api/input-label/) element. * Pointer events like `onClick` are enabled if and only if `shrink` is `true`. */ InputLabelProps: PropTypes.object, /** * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element. */ inputProps: PropTypes.object, /** * Props applied to the Input element. * It will be a [`FilledInput`](/material-ui/api/filled-input/), * [`OutlinedInput`](/material-ui/api/outlined-input/) or [`Input`](/material-ui/api/input/) * component depending on the `variant` prop value. */ InputProps: PropTypes.object, /** * Pass a ref to the `input` element. */ inputRef: refType, /** * The label content. */ label: PropTypes.node, /** * If `dense` or `normal`, will adjust vertical spacing of this and contained components. * @default 'none' */ margin: PropTypes.oneOf(['dense', 'none', 'normal']), /** * Maximal selectable date. */ maxDate: PropTypes.any, /** * Maximal selectable moment of time with binding to date, to set max time in each day use `maxTime`. */ maxDateTime: PropTypes.any, /** * Maximal selectable time. * The date part of the object will be ignored unless `props.disableIgnoringDatePartForTimeValidation === true`. */ maxTime: PropTypes.any, /** * Minimal selectable date. */ minDate: PropTypes.any, /** * Minimal selectable moment of time with binding to date, to set min time in each day use `minTime`. */ minDateTime: PropTypes.any, /** * Minimal selectable time. * The date part of the object will be ignored unless `props.disableIgnoringDatePartForTimeValidation === true`. */ minTime: PropTypes.any, /** * Step over minutes. * @default 1 */ minutesStep: PropTypes.number, /** * Name attribute of the `input` element. */ name: PropTypes.string, onBlur: PropTypes.func, /** * Callback fired when the value changes. * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value. * @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value. * @param {TValue} value The new value. * @param {FieldChangeHandlerContext} context The context containing the validation result of the current value. */ onChange: PropTypes.func, /** * Callback fired when the clear button is clicked. */ onClear: PropTypes.func, /** * Callback fired when the error associated to the current value changes. * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value. * @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value. * @param {TError} error The new error. * @param {TValue} value The value associated to the error. */ onError: PropTypes.func, onFocus: PropTypes.func, /** * Callback fired when the selected sections change. * @param {FieldSelectedSections} newValue The new selected sections. */ onSelectedSectionsChange: PropTypes.func, /** * It prevents the user from changing the value of the field * (not from interacting with the field). * @default false */ readOnly: PropTypes.bool, /** * The date used to generate a part of the new value that is not present in the format when both `value` and `defaultValue` are empty. * For example, on time fields it will be used to determine the date to set. * @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used. */ referenceDate: PropTypes.any, /** * If `true`, the label is displayed as required and the `input` element is required. * @default false */ required: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: * 1. If a number is provided, the section at this index will be selected. * 2. If an object with a `startIndex` and `endIndex` properties are provided, the sections between those two indexes will be selected. * 3. If a string of type `FieldSectionType` is provided, the first section with that name will be selected. * 4. If `null` is provided, no section will be selected * If not provided, the selected sections will be handled internally. */ selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({ endIndex: PropTypes.number.isRequired, startIndex: PropTypes.number.isRequired })]), /** * Disable specific clock time. * @param {number} clockValue The value to check. * @param {TimeView} view The clock type of the timeValue. * @returns {boolean} If `true` the time will be disabled. * @deprecated Consider using `shouldDisableTime`. */ shouldDisableClock: PropTypes.func, /** * Disable specific date. * * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance. * * @template TDate * @param {TDate} day The date to test. * @returns {boolean} If `true` the date will be disabled. */ shouldDisableDate: PropTypes.func, /** * Disable specific month. * @template TDate * @param {TDate} month The month to test. * @returns {boolean} If `true`, the month will be disabled. */ shouldDisableMonth: PropTypes.func, /** * Disable specific time. * @template TDate * @param {TDate} value The value to check. * @param {TimeView} view The clock type of the timeValue. * @returns {boolean} If `true` the time will be disabled. */ shouldDisableTime: PropTypes.func, /** * Disable specific year. * @template TDate * @param {TDate} year The year to test. * @returns {boolean} If `true`, the year will be disabled. */ shouldDisableYear: PropTypes.func, /** * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`) * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`) * * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`. * * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired. * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`. * * Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros. * This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library. * * @default `false` */ shouldRespectLeadingZeros: PropTypes.bool, /** * The size of the component. */ size: PropTypes.oneOf(['medium', 'small']), /** * The props used for each component slot. * @default {} */ slotProps: PropTypes.object, /** * Overridable component slots. * @default {} */ slots: PropTypes.object, style: 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 documention} for more details. * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise. */ timezone: PropTypes.string, /** * The ref object used to imperatively interact with the field. */ unstableFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), /** * The selected value. * Used when the component is controlled. */ value: PropTypes.any, /** * The variant to use. * @default 'outlined' */ variant: PropTypes.oneOf(['filled', 'outlined', 'standard']) } : void 0; export { DateTimeField };