@mui/x-date-pickers 8.0.0-alpha.0 → 8.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +429 -5
- package/DateCalendar/DateCalendar.js +1 -0
- package/DatePicker/DatePickerToolbar.js +0 -12
- package/DateTimePicker/DateTimePickerToolbar.d.ts +2 -2
- package/DateTimePicker/DateTimePickerToolbar.js +6 -15
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +0 -12
- package/DigitalClock/DigitalClock.js +1 -0
- package/MonthCalendar/MonthCalendar.js +1 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/PickersLayout/PickersLayout.js +0 -12
- package/PickersLayout/PickersLayout.types.d.ts +2 -2
- package/PickersLayout/usePickerLayout.js +1 -5
- package/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/PickersTextField/PickersTextField.js +2 -2
- package/README.md +2 -2
- package/TimeClock/Clock.js +1 -0
- package/TimeClock/TimeClock.js +1 -0
- package/TimePicker/TimePickerToolbar.js +6 -15
- package/YearCalendar/YearCalendar.js +1 -0
- package/hooks/useSplitFieldProps.d.ts +3 -3
- package/index.js +1 -1
- package/internals/components/PickerProvider.d.ts +26 -0
- package/internals/components/PickerProvider.js +3 -1
- package/internals/components/PickersToolbar.js +2 -4
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/internals/hooks/useField/useField.types.d.ts +2 -2
- package/internals/hooks/useField/useField.utils.d.ts +2 -2
- package/internals/hooks/useField/useFieldState.js +1 -0
- package/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/internals/hooks/usePicker/usePicker.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.js +9 -12
- package/internals/hooks/usePicker/usePicker.types.d.ts +6 -6
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +6 -7
- package/internals/hooks/usePicker/usePickerLayoutProps.js +2 -5
- package/internals/hooks/usePicker/usePickerProvider.d.ts +20 -4
- package/internals/hooks/usePicker/usePickerProvider.js +61 -5
- package/internals/hooks/usePicker/usePickerValue.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +18 -6
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +8 -7
- package/internals/hooks/usePicker/usePickerViews.d.ts +1 -0
- package/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/internals/hooks/useValueWithTimezone.d.ts +19 -15
- package/internals/hooks/useValueWithTimezone.js +13 -1
- package/internals/index.d.ts +1 -1
- package/internals/models/common.d.ts +2 -1
- package/internals/models/props/toolbar.d.ts +1 -2
- package/internals/utils/date-utils.d.ts +2 -2
- package/models/common.d.ts +1 -0
- package/models/fields.d.ts +0 -1
- package/models/pickers.d.ts +18 -0
- package/modern/DateCalendar/DateCalendar.js +1 -0
- package/modern/DatePicker/DatePickerToolbar.js +0 -12
- package/modern/DateTimePicker/DateTimePickerToolbar.js +6 -15
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +0 -12
- package/modern/DigitalClock/DigitalClock.js +1 -0
- package/modern/MonthCalendar/MonthCalendar.js +1 -0
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/modern/PickersLayout/PickersLayout.js +0 -12
- package/modern/PickersLayout/usePickerLayout.js +1 -5
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/modern/PickersTextField/PickersTextField.js +2 -2
- package/modern/TimeClock/Clock.js +1 -0
- package/modern/TimeClock/TimeClock.js +1 -0
- package/modern/TimePicker/TimePickerToolbar.js +6 -15
- package/modern/YearCalendar/YearCalendar.js +1 -0
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerProvider.js +3 -1
- package/modern/internals/components/PickersToolbar.js +2 -4
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/modern/internals/hooks/useField/useFieldState.js +1 -0
- package/modern/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/modern/internals/hooks/usePicker/usePicker.js +9 -12
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +2 -5
- package/modern/internals/hooks/usePicker/usePickerProvider.js +61 -5
- package/modern/internals/hooks/usePicker/usePickerValue.js +18 -6
- package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/modern/internals/hooks/useValueWithTimezone.js +13 -1
- package/node/DateCalendar/DateCalendar.js +1 -0
- package/node/DatePicker/DatePickerToolbar.js +0 -12
- package/node/DateTimePicker/DateTimePickerToolbar.js +6 -15
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +0 -12
- package/node/DigitalClock/DigitalClock.js +1 -0
- package/node/MonthCalendar/MonthCalendar.js +1 -0
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/node/PickersLayout/PickersLayout.js +0 -12
- package/node/PickersLayout/usePickerLayout.js +1 -5
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/node/PickersTextField/PickersTextField.js +2 -2
- package/node/TimeClock/Clock.js +1 -0
- package/node/TimeClock/TimeClock.js +1 -0
- package/node/TimePicker/TimePickerToolbar.js +6 -15
- package/node/YearCalendar/YearCalendar.js +1 -0
- package/node/index.js +1 -1
- package/node/internals/components/PickerProvider.js +3 -1
- package/node/internals/components/PickersToolbar.js +2 -4
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/node/internals/hooks/useField/useFieldState.js +1 -0
- package/node/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/node/internals/hooks/usePicker/usePicker.js +9 -12
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +2 -5
- package/node/internals/hooks/usePicker/usePickerProvider.js +64 -5
- package/node/internals/hooks/usePicker/usePickerValue.js +18 -6
- package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/node/internals/hooks/useValueWithTimezone.js +13 -1
- package/package.json +4 -4
- package/internals/hooks/usePicker/usePickerOwnerState.d.ts +0 -10
- package/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
- package/modern/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
- package/node/internals/hooks/usePicker/usePickerOwnerState.js +0 -23
|
@@ -6,7 +6,7 @@ import { BaseToolbarProps, ExportedBaseToolbarProps } from '../internals/models/
|
|
|
6
6
|
import { BaseTabsProps, ExportedBaseTabsProps } from '../internals/models/props/tabs';
|
|
7
7
|
import { UsePickerLayoutPropsResponseLayoutProps } from '../internals/hooks/usePicker/usePickerLayoutProps';
|
|
8
8
|
import { PickersLayoutClasses } from './pickersLayoutClasses';
|
|
9
|
-
import { DateOrTimeViewWithMeridiem,
|
|
9
|
+
import { DateOrTimeViewWithMeridiem, PickerVariant } from '../internals/models/common';
|
|
10
10
|
import { PickersShortcutsProps } from '../PickersShortcuts';
|
|
11
11
|
import { ExportedPickersShortcutProps, PickersShortcuts } from '../PickersShortcuts/PickersShortcuts';
|
|
12
12
|
import { PickerOwnerState } from '../models';
|
|
@@ -28,7 +28,7 @@ export interface ExportedPickersLayoutSlots<TValue, TView extends DateOrTimeView
|
|
|
28
28
|
layout?: React.JSXElementConstructor<PickersLayoutProps<TValue, TView> & React.RefAttributes<HTMLDivElement>>;
|
|
29
29
|
}
|
|
30
30
|
export interface PickerLayoutOwnerState extends PickerOwnerState {
|
|
31
|
-
wrapperVariant:
|
|
31
|
+
wrapperVariant: PickerVariant;
|
|
32
32
|
isLandscape: boolean;
|
|
33
33
|
}
|
|
34
34
|
export interface ExportedPickersLayoutSlotProps<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
@@ -45,8 +45,6 @@ const usePickerLayout = props => {
|
|
|
45
45
|
onSelectShortcut,
|
|
46
46
|
isValid,
|
|
47
47
|
isLandscape,
|
|
48
|
-
disabled,
|
|
49
|
-
readOnly,
|
|
50
48
|
children,
|
|
51
49
|
slots,
|
|
52
50
|
slotProps,
|
|
@@ -90,9 +88,7 @@ const usePickerLayout = props => {
|
|
|
90
88
|
value,
|
|
91
89
|
view,
|
|
92
90
|
onViewChange,
|
|
93
|
-
views
|
|
94
|
-
disabled,
|
|
95
|
-
readOnly
|
|
91
|
+
views
|
|
96
92
|
},
|
|
97
93
|
className: classes.toolbar,
|
|
98
94
|
ownerState
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["elements", "areAllSectionsEmpty", "defaultValue", "label", "value", "onChange", "id", "autoFocus", "endAdornment", "startAdornment", "renderSuffix", "slots", "slotProps", "contentEditable", "tabIndex", "onInput", "onPaste", "onKeyDown", "fullWidth", "name", "readOnly", "inputProps", "inputRef", "sectionListRef"];
|
|
3
|
+
const _excluded = ["elements", "areAllSectionsEmpty", "defaultValue", "label", "value", "onChange", "id", "autoFocus", "endAdornment", "startAdornment", "renderSuffix", "slots", "slotProps", "contentEditable", "tabIndex", "onInput", "onPaste", "onKeyDown", "fullWidth", "name", "readOnly", "inputProps", "inputRef", "sectionListRef", "onFocus", "onBlur"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { useFormControl } from '@mui/material/FormControl';
|
|
@@ -194,7 +194,9 @@ const PickersInputBase = /*#__PURE__*/React.forwardRef(function PickersInputBase
|
|
|
194
194
|
readOnly,
|
|
195
195
|
inputProps,
|
|
196
196
|
inputRef,
|
|
197
|
-
sectionListRef
|
|
197
|
+
sectionListRef,
|
|
198
|
+
onFocus,
|
|
199
|
+
onBlur
|
|
198
200
|
} = props,
|
|
199
201
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
200
202
|
const rootRef = React.useRef(null);
|
|
@@ -206,13 +208,12 @@ const PickersInputBase = /*#__PURE__*/React.forwardRef(function PickersInputBase
|
|
|
206
208
|
throw new Error('MUI X: PickersInputBase should always be used inside a PickersTextField component');
|
|
207
209
|
}
|
|
208
210
|
const handleInputFocus = event => {
|
|
209
|
-
// Fix a bug with IE11 where the focus/blur events are triggered
|
|
210
|
-
// while the component is disabled.
|
|
211
|
-
if (muiFormControl.disabled) {
|
|
212
|
-
event.stopPropagation();
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
211
|
muiFormControl.onFocus?.(event);
|
|
212
|
+
onFocus?.(event);
|
|
213
|
+
};
|
|
214
|
+
const handleInputBlur = event => {
|
|
215
|
+
muiFormControl.onBlur?.(event);
|
|
216
|
+
onBlur?.(event);
|
|
216
217
|
};
|
|
217
218
|
React.useEffect(() => {
|
|
218
219
|
if (muiFormControl) {
|
|
@@ -254,7 +255,7 @@ const PickersInputBase = /*#__PURE__*/React.forwardRef(function PickersInputBase
|
|
|
254
255
|
tabIndex: tabIndex,
|
|
255
256
|
className: classes.sectionsContainer,
|
|
256
257
|
onFocus: handleInputFocus,
|
|
257
|
-
onBlur:
|
|
258
|
+
onBlur: handleInputBlur,
|
|
258
259
|
onInput: onInput,
|
|
259
260
|
onPaste: onPaste,
|
|
260
261
|
onKeyDown: onKeyDown,
|
|
@@ -105,8 +105,6 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
|
|
|
105
105
|
className: clsx(classes.root, className),
|
|
106
106
|
ref: handleRootRef,
|
|
107
107
|
focused: focused,
|
|
108
|
-
onFocus: onFocus,
|
|
109
|
-
onBlur: onBlur,
|
|
110
108
|
disabled: disabled,
|
|
111
109
|
variant: variant,
|
|
112
110
|
error: error,
|
|
@@ -128,6 +126,8 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
|
|
|
128
126
|
onKeyUp: onKeyUp,
|
|
129
127
|
onInput: onInput,
|
|
130
128
|
onPaste: onPaste,
|
|
129
|
+
onFocus: onFocus,
|
|
130
|
+
onBlur: onBlur,
|
|
131
131
|
endAdornment: endAdornment,
|
|
132
132
|
startAdornment: startAdornment,
|
|
133
133
|
tabIndex: tabIndex,
|
package/README.md
CHANGED
|
@@ -35,8 +35,8 @@ This component has the following peer dependencies that you need to install as w
|
|
|
35
35
|
```json
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@mui/material": "^5.15.14 || ^6.0.0",
|
|
38
|
-
"react": "^17.0.0 || ^18.0.0",
|
|
39
|
-
"react-dom": "^17.0.0 || ^18.0.0"
|
|
38
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
39
|
+
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
40
40
|
},
|
|
41
41
|
```
|
|
42
42
|
|
package/TimeClock/Clock.js
CHANGED
package/TimeClock/TimeClock.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["ampm", "ampmInClock", "value", "isLandscape", "onChange", "view", "onViewChange", "views", "
|
|
5
|
+
const _excluded = ["ampm", "ampmInClock", "value", "isLandscape", "onChange", "view", "onViewChange", "views", "className"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
@@ -18,6 +18,7 @@ import { useUtils } from "../internals/hooks/useUtils.js";
|
|
|
18
18
|
import { useMeridiemMode } from "../internals/hooks/date-helpers-hooks.js";
|
|
19
19
|
import { getTimePickerToolbarUtilityClass, timePickerToolbarClasses } from "./timePickerToolbarClasses.js";
|
|
20
20
|
import { formatMeridiem } from "../internals/utils/date-utils.js";
|
|
21
|
+
import { usePickerContext } from "../hooks/index.js";
|
|
21
22
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
23
|
const useUtilityClasses = ownerState => {
|
|
23
24
|
const {
|
|
@@ -128,14 +129,16 @@ function TimePickerToolbar(inProps) {
|
|
|
128
129
|
view,
|
|
129
130
|
onViewChange,
|
|
130
131
|
views,
|
|
131
|
-
disabled,
|
|
132
|
-
readOnly,
|
|
133
132
|
className
|
|
134
133
|
} = props,
|
|
135
134
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
136
135
|
const utils = useUtils();
|
|
137
136
|
const translations = usePickerTranslations();
|
|
138
137
|
const isRtl = useRtl();
|
|
138
|
+
const {
|
|
139
|
+
disabled,
|
|
140
|
+
readOnly
|
|
141
|
+
} = usePickerContext();
|
|
139
142
|
const showAmPmControl = Boolean(ampm && !ampmInClock && views.includes('hours'));
|
|
140
143
|
const {
|
|
141
144
|
meridiemMode,
|
|
@@ -216,12 +219,6 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
|
|
|
216
219
|
*/
|
|
217
220
|
classes: PropTypes.object,
|
|
218
221
|
className: PropTypes.string,
|
|
219
|
-
/**
|
|
220
|
-
* If `true`, the component is disabled.
|
|
221
|
-
* When disabled, the value cannot be changed and no interaction is possible.
|
|
222
|
-
* @default false
|
|
223
|
-
*/
|
|
224
|
-
disabled: PropTypes.bool,
|
|
225
222
|
/**
|
|
226
223
|
* If `true`, show the toolbar even in desktop mode.
|
|
227
224
|
* @default `true` for Desktop, `false` for Mobile.
|
|
@@ -235,12 +232,6 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
|
|
|
235
232
|
* @param {TView} view The view to open
|
|
236
233
|
*/
|
|
237
234
|
onViewChange: PropTypes.func.isRequired,
|
|
238
|
-
/**
|
|
239
|
-
* If `true`, the component is read-only.
|
|
240
|
-
* When read-only, the value cannot be changed but the user can interact with the interface.
|
|
241
|
-
* @default false
|
|
242
|
-
*/
|
|
243
|
-
readOnly: PropTypes.bool,
|
|
244
235
|
/**
|
|
245
236
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
246
237
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FieldValueType } from '../models';
|
|
2
1
|
import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from '../validation/extractValidationProps';
|
|
2
|
+
import { PickerValueType } from '../models/common';
|
|
3
3
|
declare const SHARED_FIELD_INTERNAL_PROP_NAMES: readonly ["value", "defaultValue", "referenceDate", "format", "formatDensity", "onChange", "timezone", "onError", "shouldRespectLeadingZeros", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef", "enableAccessibleFieldDOMStructure", "disabled", "readOnly", "dateSeparator"];
|
|
4
|
-
type InternalPropNames<TValueType extends
|
|
4
|
+
type InternalPropNames<TValueType extends PickerValueType> = (typeof SHARED_FIELD_INTERNAL_PROP_NAMES)[number] | (TValueType extends 'date' | 'date-time' ? (typeof DATE_VALIDATION_PROP_NAMES)[number] : never) | (TValueType extends 'time' | 'date-time' ? (typeof TIME_VALIDATION_PROP_NAMES)[number] : never) | (TValueType extends 'date-time' ? (typeof DATE_TIME_VALIDATION_PROP_NAMES)[number] : never);
|
|
5
5
|
/**
|
|
6
6
|
* Split the props received by the field component into:
|
|
7
7
|
* - `internalProps` which are used by the various hooks called by the field component.
|
|
@@ -12,7 +12,7 @@ type InternalPropNames<TValueType extends FieldValueType> = (typeof SHARED_FIELD
|
|
|
12
12
|
* @param {TProps} props The props received by the field component.
|
|
13
13
|
* @param {TValueType} valueType The type of the field value ('date', 'time', or 'date-time').
|
|
14
14
|
*/
|
|
15
|
-
export declare const useSplitFieldProps: <TValueType extends
|
|
15
|
+
export declare const useSplitFieldProps: <TValueType extends PickerValueType, TProps extends { [key in InternalPropNames<TValueType>]?: any; }>(props: TProps, valueType: TValueType) => {
|
|
16
16
|
forwardedProps: Omit<TProps, InternalPropNames<TValueType>>;
|
|
17
17
|
internalProps: Pick<TProps, InternalPropNames<TValueType>>;
|
|
18
18
|
};
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PickerOwnerState } from '../../models';
|
|
3
3
|
import { PickersInputLocaleText } from '../../locales';
|
|
4
|
+
import { PickerOrientation, PickerVariant } from '../models';
|
|
4
5
|
export declare const PickerContext: React.Context<PickerContextValue | null>;
|
|
5
6
|
export declare const PickerPrivateContext: React.Context<PickerPrivateContextValue>;
|
|
6
7
|
/**
|
|
@@ -32,6 +33,31 @@ export interface PickerContextValue {
|
|
|
32
33
|
* `true` if the picker is open, `false` otherwise.
|
|
33
34
|
*/
|
|
34
35
|
open: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* `true` if the picker is disabled, `false` otherwise.
|
|
38
|
+
*/
|
|
39
|
+
disabled: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* `true` if the picker is read-only, `false` otherwise.
|
|
42
|
+
*/
|
|
43
|
+
readOnly: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The responsive variant of the picker.
|
|
46
|
+
* Is equal to "desktop" when using a desktop picker (like <DesktopDatePicker />).
|
|
47
|
+
* Is equal to "mobile" when using a mobile picker (like <MobileDatePicker />).
|
|
48
|
+
* Is equal to "mobile" or "desktop" when using a responsive picker (like <DatePicker />) depending on the `desktopModeMediaQuery` prop.
|
|
49
|
+
* Is equal to "mobile" or "desktop" when using a static picker (like <StaticDatePicker />) depending on the `displayStaticWrapperAs` prop.
|
|
50
|
+
* Is always equal to "desktop" if the component you are accessing the ownerState from is not wrapped by a picker.
|
|
51
|
+
*/
|
|
52
|
+
variant: PickerVariant;
|
|
53
|
+
/**
|
|
54
|
+
* The orientation of the picker.
|
|
55
|
+
* Is equal to "landscape" when the picker is in landscape orientation.
|
|
56
|
+
* Is equal to "portrait" when the picker is in portrait orientation.
|
|
57
|
+
* You can use the "orientation" on any picker component to force the orientation.
|
|
58
|
+
* Is always equal to "portrait" if the component you are accessing the ownerState from is not wrapped by a picker.
|
|
59
|
+
*/
|
|
60
|
+
orientation: PickerOrientation;
|
|
35
61
|
}
|
|
36
62
|
export interface PickerPrivateContextValue {
|
|
37
63
|
/**
|
|
@@ -7,7 +7,9 @@ export const PickerPrivateContext = /*#__PURE__*/React.createContext({
|
|
|
7
7
|
isPickerDisabled: false,
|
|
8
8
|
isPickerReadOnly: false,
|
|
9
9
|
isPickerValueEmpty: false,
|
|
10
|
-
isPickerOpen: false
|
|
10
|
+
isPickerOpen: false,
|
|
11
|
+
pickerVariant: 'desktop',
|
|
12
|
+
pickerOrientation: 'portrait'
|
|
11
13
|
}
|
|
12
14
|
});
|
|
13
15
|
|
|
@@ -10,13 +10,11 @@ import { getPickersToolbarUtilityClass } from "./pickersToolbarClasses.js";
|
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
const useUtilityClasses = ownerState => {
|
|
12
12
|
const {
|
|
13
|
-
classes
|
|
14
|
-
isLandscape
|
|
13
|
+
classes
|
|
15
14
|
} = ownerState;
|
|
16
15
|
const slots = {
|
|
17
16
|
root: ['root'],
|
|
18
|
-
content: ['content']
|
|
19
|
-
penIconButton: ['penIconButton', isLandscape && 'penIconButtonLandscape']
|
|
17
|
+
content: ['content']
|
|
20
18
|
};
|
|
21
19
|
return composeClasses(slots, getPickersToolbarUtilityClass, classes);
|
|
22
20
|
};
|
|
@@ -67,7 +67,7 @@ export const useDesktopPicker = _ref => {
|
|
|
67
67
|
localeText,
|
|
68
68
|
autoFocusView: true,
|
|
69
69
|
additionalViewProps: {},
|
|
70
|
-
|
|
70
|
+
variant: 'desktop'
|
|
71
71
|
}));
|
|
72
72
|
const InputAdornment = slots.inputAdornment ?? MuiInputAdornment;
|
|
73
73
|
const _useSlotProps = useSlotProps({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType,
|
|
2
|
+
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, PickerValidDate, FieldRef, OnErrorProps, InferError, PickerValueType } from '../../../models';
|
|
3
3
|
import type { PickerValueManager } from '../usePicker';
|
|
4
4
|
import type { Validator } from '../../../validation';
|
|
5
5
|
import type { UseFieldStateResponse } from './useFieldState';
|
|
@@ -13,7 +13,7 @@ export interface UseFieldParams<TValue, TSection extends FieldSection, TEnableAc
|
|
|
13
13
|
valueManager: PickerValueManager<TValue, InferError<TInternalProps>>;
|
|
14
14
|
fieldValueManager: FieldValueManager<TValue, TSection>;
|
|
15
15
|
validator: Validator<TValue, InferError<TInternalProps>, TInternalProps>;
|
|
16
|
-
valueType:
|
|
16
|
+
valueType: PickerValueType;
|
|
17
17
|
}
|
|
18
18
|
export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends TimezoneProps, FormProps, OnErrorProps<TValue, TError> {
|
|
19
19
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AvailableAdjustKeyCode, FieldSectionsValueBoundaries, SectionOrdering, FieldSectionValueBoundaries, FieldParsedSelectedSections } from './useField.types';
|
|
2
|
-
import { FieldSectionType,
|
|
2
|
+
import { FieldSectionType, FieldSection, MuiPickersAdapter, FieldSectionContentType, PickersTimezone, PickerValidDate, FieldSelectedSections, PickerValueType } from '../../../models';
|
|
3
3
|
export declare const getDateSectionConfigFromFormatToken: (utils: MuiPickersAdapter, formatToken: string) => Pick<FieldSection, "type" | "contentType"> & {
|
|
4
4
|
maxLength: number | undefined;
|
|
5
5
|
};
|
|
@@ -31,7 +31,7 @@ export declare const getDateFromDateSections: (utils: MuiPickersAdapter, section
|
|
|
31
31
|
export declare const createDateStrForV7HiddenInputFromSections: (sections: FieldSection[]) => string;
|
|
32
32
|
export declare const createDateStrForV6InputFromSections: (sections: FieldSection[], localizedDigits: string[], isRtl: boolean) => string;
|
|
33
33
|
export declare const getSectionsBoundaries: (utils: MuiPickersAdapter, localizedDigits: string[], timezone: PickersTimezone) => FieldSectionsValueBoundaries;
|
|
34
|
-
export declare const validateSections: <TSection extends FieldSection>(sections: TSection[], valueType:
|
|
34
|
+
export declare const validateSections: <TSection extends FieldSection>(sections: TSection[], valueType: PickerValueType) => void;
|
|
35
35
|
export declare const mergeDateIntoReferenceDate: (utils: MuiPickersAdapter, dateToTransferFrom: PickerValidDate, sections: FieldSection[], referenceDate: PickerValidDate, shouldLimitToEditedSections: boolean) => PickerValidDate;
|
|
36
36
|
export declare const isAndroid: () => boolean;
|
|
37
37
|
export declare const getSectionOrder: (sections: FieldSection[], shouldApplyRTL: boolean) => SectionOrdering;
|
|
@@ -198,8 +198,9 @@ export const useFieldV7TextField = params => {
|
|
|
198
198
|
if (focused || !sectionListRef.current) {
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
|
+
const activeElement = getActiveElement(document);
|
|
201
202
|
setFocused(true);
|
|
202
|
-
const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(
|
|
203
|
+
const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(activeElement) != null;
|
|
203
204
|
if (!isFocusInsideASection) {
|
|
204
205
|
setSelectedSections(sectionOrder.startIndex);
|
|
205
206
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { UsePickerParams, UsePickerProps, UsePickerResponse } from './usePicker.types';
|
|
2
2
|
import { FieldSection, InferError } from '../../../models';
|
|
3
3
|
import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
4
|
-
export declare const usePicker: <TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TView, any, any, any>, TAdditionalProps extends {}>({ props, valueManager, valueType,
|
|
4
|
+
export declare const usePicker: <TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TView, any, any, any>, TAdditionalProps extends {}>({ props, valueManager, valueType, variant, additionalViewProps, validator, autoFocusView, rendererInterceptor, fieldRef, localeText, }: UsePickerParams<TValue, TView, TSection, TExternalProps, TAdditionalProps>) => UsePickerResponse<TValue, TView, TSection, InferError<TExternalProps>>;
|
|
@@ -2,13 +2,12 @@ import { warnOnce } from '@mui/x-internals/warning';
|
|
|
2
2
|
import { usePickerValue } from "./usePickerValue.js";
|
|
3
3
|
import { usePickerViews } from "./usePickerViews.js";
|
|
4
4
|
import { usePickerLayoutProps } from "./usePickerLayoutProps.js";
|
|
5
|
-
import { usePickerOwnerState } from "./usePickerOwnerState.js";
|
|
6
5
|
import { usePickerProvider } from "./usePickerProvider.js";
|
|
7
6
|
export const usePicker = ({
|
|
8
7
|
props,
|
|
9
8
|
valueManager,
|
|
10
9
|
valueType,
|
|
11
|
-
|
|
10
|
+
variant,
|
|
12
11
|
additionalViewProps,
|
|
13
12
|
validator,
|
|
14
13
|
autoFocusView,
|
|
@@ -25,7 +24,7 @@ export const usePicker = ({
|
|
|
25
24
|
props,
|
|
26
25
|
valueManager,
|
|
27
26
|
valueType,
|
|
28
|
-
|
|
27
|
+
variant,
|
|
29
28
|
validator
|
|
30
29
|
});
|
|
31
30
|
const pickerViewsResponse = usePickerViews({
|
|
@@ -38,19 +37,17 @@ export const usePicker = ({
|
|
|
38
37
|
});
|
|
39
38
|
const pickerLayoutResponse = usePickerLayoutProps({
|
|
40
39
|
props,
|
|
41
|
-
|
|
40
|
+
variant,
|
|
42
41
|
propsFromPickerValue: pickerValueResponse.layoutProps,
|
|
43
42
|
propsFromPickerViews: pickerViewsResponse.layoutProps
|
|
44
43
|
});
|
|
45
|
-
const pickerOwnerState = usePickerOwnerState({
|
|
46
|
-
props,
|
|
47
|
-
pickerValueResponse,
|
|
48
|
-
valueManager
|
|
49
|
-
});
|
|
50
44
|
const providerProps = usePickerProvider({
|
|
45
|
+
props,
|
|
51
46
|
pickerValueResponse,
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
localeText,
|
|
48
|
+
valueManager,
|
|
49
|
+
variant,
|
|
50
|
+
views: pickerViewsResponse.views
|
|
54
51
|
});
|
|
55
52
|
return {
|
|
56
53
|
// Picker value
|
|
@@ -66,6 +63,6 @@ export const usePicker = ({
|
|
|
66
63
|
// Picker provider
|
|
67
64
|
providerProps,
|
|
68
65
|
// Picker owner state
|
|
69
|
-
ownerState:
|
|
66
|
+
ownerState: providerProps.privateContextValue.ownerState
|
|
70
67
|
};
|
|
71
68
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { UsePickerValueParams, UsePickerValueProps, UsePickerValueBaseProps, UsePickerValueResponse } from './usePickerValue.types';
|
|
2
2
|
import { UsePickerViewsProps, UsePickerViewParams, UsePickerViewsResponse, UsePickerViewsBaseProps } from './usePickerViews';
|
|
3
|
-
import {
|
|
3
|
+
import { UsePickerLayoutPropsResponse } from './usePickerLayoutProps';
|
|
4
4
|
import { FieldSection, PickerOwnerState } from '../../../models';
|
|
5
5
|
import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
6
|
-
import { UsePickerProviderParameters, UsePickerProviderReturnValue } from './usePickerProvider';
|
|
6
|
+
import { UsePickerProviderParameters, UsePickerProviderProps, UsePickerProviderReturnValue } from './usePickerProvider';
|
|
7
7
|
/**
|
|
8
8
|
* Props common to all picker headless implementations.
|
|
9
9
|
*/
|
|
10
|
-
export interface UsePickerBaseProps<TValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}> extends UsePickerValueBaseProps<TValue, TError>, UsePickerViewsBaseProps<TValue, TView, TExternalProps, TAdditionalProps>,
|
|
10
|
+
export interface UsePickerBaseProps<TValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}> extends UsePickerValueBaseProps<TValue, TError>, UsePickerViewsBaseProps<TValue, TView, TExternalProps, TAdditionalProps>, UsePickerProviderProps {
|
|
11
11
|
}
|
|
12
|
-
export interface UsePickerProps<TValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}> extends UsePickerValueProps<TValue, TError>, UsePickerViewsProps<TValue, TView, TExternalProps, TAdditionalProps>,
|
|
12
|
+
export interface UsePickerProps<TValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}> extends UsePickerValueProps<TValue, TError>, UsePickerViewsProps<TValue, TView, TExternalProps, TAdditionalProps>, UsePickerProviderProps {
|
|
13
13
|
}
|
|
14
|
-
export interface UsePickerParams<TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TView, any, any, any>, TAdditionalProps extends {}> extends Pick<UsePickerValueParams<TValue, TExternalProps>, 'valueManager' | 'valueType' | '
|
|
14
|
+
export interface UsePickerParams<TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TView, any, any, any>, TAdditionalProps extends {}> extends Pick<UsePickerValueParams<TValue, TExternalProps>, 'valueManager' | 'valueType' | 'variant' | 'validator'>, Pick<UsePickerViewParams<TValue, TView, TSection, TExternalProps, TAdditionalProps>, 'additionalViewProps' | 'autoFocusView' | 'rendererInterceptor' | 'fieldRef'>, Pick<UsePickerProviderParameters<TValue>, 'localeText'> {
|
|
15
15
|
props: TExternalProps;
|
|
16
16
|
}
|
|
17
|
-
export interface UsePickerResponse<TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TError> extends Omit<UsePickerValueResponse<TValue, TSection, TError>, 'viewProps' | 'layoutProps'>, Omit<UsePickerViewsResponse<TView>, 'layoutProps'>, UsePickerLayoutPropsResponse<TValue, TView> {
|
|
17
|
+
export interface UsePickerResponse<TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TError> extends Omit<UsePickerValueResponse<TValue, TSection, TError>, 'viewProps' | 'layoutProps'>, Omit<UsePickerViewsResponse<TView>, 'layoutProps' | 'views'>, UsePickerLayoutPropsResponse<TValue, TView> {
|
|
18
18
|
ownerState: PickerOwnerState;
|
|
19
19
|
providerProps: UsePickerProviderReturnValue;
|
|
20
20
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { UsePickerValueLayoutResponse } from './usePickerValue.types';
|
|
2
2
|
import { UsePickerViewsLayoutResponse } from './usePickerViews';
|
|
3
|
-
import { DateOrTimeViewWithMeridiem,
|
|
4
|
-
import { FormProps } from '../../models';
|
|
3
|
+
import { DateOrTimeViewWithMeridiem, PickerVariant } from '../../models/common';
|
|
5
4
|
/**
|
|
6
5
|
* Props used to create the layout of the views.
|
|
7
|
-
* Those props are exposed on all the pickers.
|
|
8
6
|
*/
|
|
9
|
-
|
|
7
|
+
interface UsePickerLayoutProps {
|
|
10
8
|
/**
|
|
11
9
|
* Force rendering in particular orientation.
|
|
12
10
|
*/
|
|
@@ -15,7 +13,7 @@ export interface UsePickerLayoutProps extends FormProps {
|
|
|
15
13
|
export interface UsePickerLayoutPropsResponseLayoutProps<TValue, TView extends DateOrTimeViewWithMeridiem> extends UsePickerValueLayoutResponse<TValue>, UsePickerViewsLayoutResponse<TView>, UsePickerLayoutProps {
|
|
16
14
|
isLandscape: boolean;
|
|
17
15
|
isRtl: boolean;
|
|
18
|
-
wrapperVariant:
|
|
16
|
+
wrapperVariant: PickerVariant;
|
|
19
17
|
isValid: (value: TValue) => boolean;
|
|
20
18
|
}
|
|
21
19
|
export interface UsePickerLayoutPropsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
@@ -25,9 +23,10 @@ export interface UsePickerLayoutPropsParams<TValue, TView extends DateOrTimeView
|
|
|
25
23
|
props: UsePickerLayoutProps;
|
|
26
24
|
propsFromPickerValue: UsePickerValueLayoutResponse<TValue>;
|
|
27
25
|
propsFromPickerViews: UsePickerViewsLayoutResponse<TView>;
|
|
28
|
-
|
|
26
|
+
variant: PickerVariant;
|
|
29
27
|
}
|
|
30
28
|
/**
|
|
31
29
|
* Prepare the props for the view layout (managed by `PickersLayout`)
|
|
32
30
|
*/
|
|
33
|
-
export declare const usePickerLayoutProps: <TValue, TView extends DateOrTimeViewWithMeridiem>({ props, propsFromPickerValue, propsFromPickerViews,
|
|
31
|
+
export declare const usePickerLayoutProps: <TValue, TView extends DateOrTimeViewWithMeridiem>({ props, propsFromPickerValue, propsFromPickerViews, variant, }: UsePickerLayoutPropsParams<TValue, TView>) => UsePickerLayoutPropsResponse<TValue, TView>;
|
|
32
|
+
export {};
|
|
@@ -4,7 +4,6 @@ import { useIsLandscape } from "../useIsLandscape.js";
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Props used to create the layout of the views.
|
|
7
|
-
* Those props are exposed on all the pickers.
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -14,7 +13,7 @@ export const usePickerLayoutProps = ({
|
|
|
14
13
|
props,
|
|
15
14
|
propsFromPickerValue,
|
|
16
15
|
propsFromPickerViews,
|
|
17
|
-
|
|
16
|
+
variant
|
|
18
17
|
}) => {
|
|
19
18
|
const {
|
|
20
19
|
orientation
|
|
@@ -24,9 +23,7 @@ export const usePickerLayoutProps = ({
|
|
|
24
23
|
const layoutProps = _extends({}, propsFromPickerViews, propsFromPickerValue, {
|
|
25
24
|
isLandscape,
|
|
26
25
|
isRtl,
|
|
27
|
-
wrapperVariant
|
|
28
|
-
disabled: props.disabled,
|
|
29
|
-
readOnly: props.readOnly
|
|
26
|
+
wrapperVariant: variant
|
|
30
27
|
});
|
|
31
28
|
return {
|
|
32
29
|
layoutProps
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import { FieldSection
|
|
2
|
-
import { UsePickerValueResponse } from './usePickerValue.types';
|
|
1
|
+
import { FieldSection } from '../../../models';
|
|
2
|
+
import { PickerValueManager, UsePickerValueResponse } from './usePickerValue.types';
|
|
3
3
|
import { PickerProviderProps } from '../../components/PickerProvider';
|
|
4
|
+
import type { UsePickerProps } from './usePicker.types';
|
|
5
|
+
import { DateOrTimeViewWithMeridiem, FormProps, PickerOrientation, PickerVariant } from '../../models';
|
|
6
|
+
export declare const usePickerOrientation: (views: readonly DateOrTimeViewWithMeridiem[], customOrientation: PickerOrientation | undefined) => PickerOrientation;
|
|
7
|
+
export declare function usePickerProvider<TValue>(parameters: UsePickerProviderParameters<TValue>): UsePickerProviderReturnValue;
|
|
4
8
|
export interface UsePickerProviderParameters<TValue> extends Pick<PickerProviderProps, 'localeText'> {
|
|
9
|
+
props: UsePickerProps<TValue, any, any, any, any>;
|
|
5
10
|
pickerValueResponse: UsePickerValueResponse<TValue, FieldSection, any>;
|
|
6
|
-
|
|
11
|
+
valueManager: PickerValueManager<TValue, any>;
|
|
12
|
+
variant: PickerVariant;
|
|
13
|
+
views: readonly DateOrTimeViewWithMeridiem[];
|
|
7
14
|
}
|
|
8
15
|
export interface UsePickerProviderReturnValue extends Omit<PickerProviderProps, 'children'> {
|
|
9
16
|
}
|
|
10
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Props used to create the private context.
|
|
19
|
+
* Those props are exposed on all the pickers.
|
|
20
|
+
*/
|
|
21
|
+
export interface UsePickerProviderProps extends FormProps {
|
|
22
|
+
/**
|
|
23
|
+
* Force rendering in particular orientation.
|
|
24
|
+
*/
|
|
25
|
+
orientation?: PickerOrientation;
|
|
26
|
+
}
|