@mui/x-date-pickers 6.0.0-beta.3 → 6.0.0-beta.4
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 +71 -0
- package/DateField/useDateField.d.ts +2 -2
- package/DateTimeField/useDateTimeField.d.ts +2 -2
- package/LocalizationProvider/LocalizationProvider.d.ts +4 -1
- package/LocalizationProvider/LocalizationProvider.js +2 -1
- package/TimeField/useTimeField.d.ts +2 -2
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/internals/components/PickersToolbarText.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +34 -39
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +3 -3
- package/internals/hooks/useField/useField.js +15 -2
- package/internals/hooks/useField/useField.types.d.ts +1 -0
- package/internals/hooks/useField/useField.utils.js +47 -34
- package/internals/hooks/useField/useFieldState.js +2 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.js +14 -23
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +3 -3
- package/internals/index.d.ts +1 -1
- package/internals/models/fields.d.ts +18 -21
- package/legacy/LocalizationProvider/LocalizationProvider.js +2 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +33 -38
- package/legacy/internals/hooks/useField/useField.js +14 -1
- package/legacy/internals/hooks/useField/useField.utils.js +51 -38
- package/legacy/internals/hooks/useField/useFieldState.js +2 -1
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +14 -23
- package/legacy/tests/describeAdapters/describeAdapters.js +28 -0
- package/legacy/tests/describeAdapters/index.js +1 -0
- package/modern/LocalizationProvider/LocalizationProvider.js +2 -1
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +33 -37
- package/modern/internals/hooks/useField/useField.js +15 -2
- package/modern/internals/hooks/useField/useField.utils.js +47 -34
- package/modern/internals/hooks/useField/useFieldState.js +2 -1
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +14 -22
- package/modern/tests/describeAdapters/describeAdapters.js +28 -0
- package/modern/tests/describeAdapters/index.js +1 -0
- package/node/LocalizationProvider/LocalizationProvider.js +2 -1
- package/node/index.js +1 -1
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +32 -36
- package/node/internals/hooks/useField/useField.js +15 -2
- package/node/internals/hooks/useField/useField.utils.js +47 -34
- package/node/internals/hooks/useField/useFieldState.js +2 -1
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +13 -21
- package/node/tests/describeAdapters/describeAdapters.js +36 -0
- package/node/tests/describeAdapters/index.js +12 -0
- package/package.json +1 -1
- package/tests/describeAdapters/describeAdapters.js +28 -0
- package/tests/describeAdapters/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,53 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 6.0.0-beta.4
|
|
7
|
+
|
|
8
|
+
_Feb 16, 2023_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 8 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- ⚡️ Improve grid performance by reducing rerenders (#7857) @cherniavskii
|
|
13
|
+
- 📚 Documentation improvements
|
|
14
|
+
- 🐞 Bugfixes
|
|
15
|
+
|
|
16
|
+
### `@mui/x-data-grid@v6.0.0-beta.4` / `@mui/x-data-grid-pro@v6.0.0-beta.4` / `@mui/x-data-grid-premium@v6.0.0-beta.4`
|
|
17
|
+
|
|
18
|
+
#### Changes
|
|
19
|
+
|
|
20
|
+
- [DataGrid] Add interface for `singleSelect` column (#7685) @m4theushw
|
|
21
|
+
- [DataGrid] Allow to pass props to the `TrapFocus` inside the panel wrapper (#7733) @Vivek-Prajapatii
|
|
22
|
+
- [DataGrid] Avoid unnecessary rerenders after `updateRows` (#7857) @cherniavskii
|
|
23
|
+
- [DataGridPro] Change cursor when dragging a column (#7725) @sai6855
|
|
24
|
+
- [DataGridPremium] Fix `leafField` to have correct focus value (#7950) @MBilalShafi
|
|
25
|
+
|
|
26
|
+
### `@mui/x-date-pickers@v6.0.0-beta.4` / `@mui/x-date-pickers-pro@v6.0.0-beta.4`
|
|
27
|
+
|
|
28
|
+
#### Changes
|
|
29
|
+
|
|
30
|
+
- [DateRangePicker] Fix slide transition by avoiding useless component re-rendering (#7874) @LukasTy
|
|
31
|
+
- [fields] Support Backspace key on `Android` (#7842) @flaviendelangle
|
|
32
|
+
- [fields] Support escaped characters on `Luxon` (#7888) @flaviendelangle
|
|
33
|
+
- [pickers] Prepare new pickers for custom fields (#7806) @flaviendelangle
|
|
34
|
+
|
|
35
|
+
### `@mui/x-codemod@v6.0.0-beta.4`
|
|
36
|
+
|
|
37
|
+
#### Changes
|
|
38
|
+
|
|
39
|
+
- [codemod] Fix import path (#7952) @LukasTy
|
|
40
|
+
|
|
41
|
+
### Docs
|
|
42
|
+
|
|
43
|
+
- [docs] Add an info callout specifying the current state of desktop time view (#7933) @LukasTy
|
|
44
|
+
- [docs] Add missing param in `useGridApiEventHandler` examples (#7939) @flaviendelangle
|
|
45
|
+
- [docs] Fix markdown table alignments (#7898) @oliviertassinari
|
|
46
|
+
- [docs] Improve `DataGrid` migration guide (#7861) @MBilalShafi
|
|
47
|
+
- [docs] Update `LocalizationProvider` `dateAdapter` with a link to the doc (#7872) @LukasTy
|
|
48
|
+
|
|
49
|
+
### Core
|
|
50
|
+
|
|
51
|
+
- [core] Run editing field tests on all major adapters (#7868) @flaviendelangle
|
|
52
|
+
|
|
6
53
|
## 6.0.0-beta.3
|
|
7
54
|
|
|
8
55
|
_Feb 9, 2023_
|
|
@@ -2132,6 +2179,30 @@ You can find more information about the new api, including how to set those tran
|
|
|
2132
2179
|
- [test] Skip tests for column pinning and dynamic row height (#5997) @m4theushw
|
|
2133
2180
|
- [website] Improve security header @oliviertassinari
|
|
2134
2181
|
|
|
2182
|
+
## 5.17.24
|
|
2183
|
+
|
|
2184
|
+
_Feb 16, 2023_
|
|
2185
|
+
|
|
2186
|
+
We'd like to offer a big thanks to the 5 contributors who made this release possible. Here are some highlights ✨:
|
|
2187
|
+
|
|
2188
|
+
- 🌍 Add Hungarian (hu-HU) locale
|
|
2189
|
+
- 🐞 Bugfixes
|
|
2190
|
+
|
|
2191
|
+
### `@mui/x-data-grid@v5.17.24` / `@mui/x-data-grid-pro@v5.17.24` / `@mui/x-data-grid-premium@v5.17.24`
|
|
2192
|
+
|
|
2193
|
+
#### Changes
|
|
2194
|
+
|
|
2195
|
+
- [DataGrid] Allow to pass props to the `TrapFocus` inside the panel wrapper (#7897) @Vivek-Prajapatii
|
|
2196
|
+
- [DataGrid] Avoid unnecessary rerenders after `updateRows` (#7945) @cherniavskii
|
|
2197
|
+
- [DataGridPro] Change cursor when dragging a column (#7878) @sai6855
|
|
2198
|
+
- [DataGridPremium] Fix `leafField` to have correct focus value (#7959) @MBilalShafi
|
|
2199
|
+
|
|
2200
|
+
### `@mui/x-date-pickers@v5.0.19` / `@mui/x-date-pickers-pro@v5.0.19`
|
|
2201
|
+
|
|
2202
|
+
#### Changes
|
|
2203
|
+
|
|
2204
|
+
- [l10n] Add Hungarian (hu-HU) locale (#7796) @noherczeg
|
|
2205
|
+
|
|
2135
2206
|
## 5.17.23
|
|
2136
2207
|
|
|
2137
2208
|
_Feb 9, 2023_
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UseDateFieldParams } from './DateField.types';
|
|
2
|
-
export declare const useDateField: <TDate, TChildProps extends {}>({ props, inputRef, }: UseDateFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<TChildProps
|
|
1
|
+
import { UseDateFieldProps, UseDateFieldParams } from './DateField.types';
|
|
2
|
+
export declare const useDateField: <TDate, TChildProps extends {}>({ props, inputRef, }: UseDateFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<Omit<TChildProps, keyof UseDateFieldProps<TDate>>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UseDateTimeFieldParams } from './DateTimeField.types';
|
|
2
|
-
export declare const useDateTimeField: <TDate, TChildProps extends {}>({ props, inputRef, }: UseDateTimeFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<TChildProps
|
|
1
|
+
import { UseDateTimeFieldProps, UseDateTimeFieldParams } from './DateTimeField.types';
|
|
2
|
+
export declare const useDateTimeField: <TDate, TChildProps extends {}>({ props, inputRef, }: UseDateTimeFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<Omit<TChildProps, keyof UseDateTimeFieldProps<TDate>>>;
|
|
@@ -16,7 +16,10 @@ export type MuiPickersAdapterContextNullableValue<TDate> = {
|
|
|
16
16
|
export declare const MuiPickersAdapterContext: React.Context<MuiPickersAdapterContextNullableValue<any> | null>;
|
|
17
17
|
export interface LocalizationProviderProps<TDate> {
|
|
18
18
|
children?: React.ReactNode;
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Date library adapter class function.
|
|
21
|
+
* @see See the localization provider {@link https://next.mui.com/x/react-date-pickers/getting-started/#code-setup code setup section} for more details.
|
|
22
|
+
*/
|
|
20
23
|
dateAdapter?: new (...args: any) => MuiPickersAdapter<TDate>;
|
|
21
24
|
/** Formats that are used for any child pickers */
|
|
22
25
|
dateFormats?: Partial<DateIOFormats>;
|
|
@@ -89,7 +89,8 @@ process.env.NODE_ENV !== "production" ? LocalizationProvider.propTypes = {
|
|
|
89
89
|
adapterLocale: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
90
90
|
children: PropTypes.node,
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* Date library adapter class function.
|
|
93
|
+
* @see See the localization provider {@link https://next.mui.com/x/react-date-pickers/getting-started/#code-setup code setup section} for more details.
|
|
93
94
|
*/
|
|
94
95
|
dateAdapter: PropTypes.func,
|
|
95
96
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UseTimeFieldParams } from './TimeField.types';
|
|
2
|
-
export declare const useTimeField: <TDate, TChildProps extends {}>({ props, inputRef, }: UseTimeFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<TChildProps
|
|
1
|
+
import { UseTimeFieldProps, UseTimeFieldParams } from './TimeField.types';
|
|
2
|
+
export declare const useTimeField: <TDate, TChildProps extends {}>({ props, inputRef, }: UseTimeFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<Omit<TChildProps, keyof UseTimeFieldProps<TDate>>>;
|
package/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './DateField';
|
|
|
6
6
|
export * from './TimeField';
|
|
7
7
|
export * from './DateTimeField';
|
|
8
8
|
export type { FieldSection, FieldSelectedSections } from './internals/hooks/useField';
|
|
9
|
+
export type { BaseSingleInputFieldProps } from './internals/models/fields';
|
|
9
10
|
export * from './DateCalendar';
|
|
10
11
|
export * from './MonthCalendar';
|
|
11
12
|
export * from './YearCalendar';
|
package/index.js
CHANGED
|
@@ -8,4 +8,4 @@ export interface PickersToolbarTextProps extends Omit<TypographyProps, 'classes'
|
|
|
8
8
|
selected?: boolean;
|
|
9
9
|
value: React.ReactNode;
|
|
10
10
|
}
|
|
11
|
-
export declare const PickersToolbarText: React.ForwardRefExoticComponent<
|
|
11
|
+
export declare const PickersToolbarText: React.ForwardRefExoticComponent<Omit<PickersToolbarTextProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["ownerState"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
6
6
|
import MuiInputAdornment from '@mui/material/InputAdornment';
|
|
7
7
|
import IconButton from '@mui/material/IconButton';
|
|
8
8
|
import useForkRef from '@mui/utils/useForkRef';
|
|
@@ -27,7 +27,7 @@ export const useDesktopPicker = ({
|
|
|
27
27
|
getOpenDialogAriaText,
|
|
28
28
|
validator
|
|
29
29
|
}) => {
|
|
30
|
-
var
|
|
30
|
+
var _innerSlotProps$toolb, _innerSlotProps$toolb2, _slots$inputAdornment, _slots$openPickerButt, _slots$layout;
|
|
31
31
|
const {
|
|
32
32
|
slots,
|
|
33
33
|
slotProps: innerSlotProps,
|
|
@@ -45,6 +45,7 @@ export const useDesktopPicker = ({
|
|
|
45
45
|
const internalInputRef = React.useRef(null);
|
|
46
46
|
const containerRef = React.useRef(null);
|
|
47
47
|
const labelId = useId();
|
|
48
|
+
const isToolbarHidden = (_innerSlotProps$toolb = innerSlotProps == null ? void 0 : (_innerSlotProps$toolb2 = innerSlotProps.toolbar) == null ? void 0 : _innerSlotProps$toolb2.hidden) != null ? _innerSlotProps$toolb : false;
|
|
48
49
|
const {
|
|
49
50
|
open,
|
|
50
51
|
actions,
|
|
@@ -62,21 +63,6 @@ export const useDesktopPicker = ({
|
|
|
62
63
|
additionalViewProps: {},
|
|
63
64
|
wrapperVariant: 'desktop'
|
|
64
65
|
});
|
|
65
|
-
const Field = slots.field;
|
|
66
|
-
const fieldProps = useSlotProps({
|
|
67
|
-
elementType: Field,
|
|
68
|
-
externalSlotProps: innerSlotProps == null ? void 0 : innerSlotProps.field,
|
|
69
|
-
additionalProps: _extends({}, pickerFieldProps, {
|
|
70
|
-
readOnly,
|
|
71
|
-
disabled,
|
|
72
|
-
className,
|
|
73
|
-
sx,
|
|
74
|
-
format,
|
|
75
|
-
label,
|
|
76
|
-
autoFocus: autoFocus && !props.open
|
|
77
|
-
}),
|
|
78
|
-
ownerState: props
|
|
79
|
-
});
|
|
80
66
|
const InputAdornment = (_slots$inputAdornment = slots.inputAdornment) != null ? _slots$inputAdornment : MuiInputAdornment;
|
|
81
67
|
const inputAdornmentProps = useSlotProps({
|
|
82
68
|
elementType: InputAdornment,
|
|
@@ -100,29 +86,38 @@ export const useDesktopPicker = ({
|
|
|
100
86
|
}),
|
|
101
87
|
openPickerButtonProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded);
|
|
102
88
|
const OpenPickerIcon = slots.openPickerIcon;
|
|
89
|
+
const Field = slots.field;
|
|
90
|
+
const fieldProps = useSlotProps({
|
|
91
|
+
elementType: Field,
|
|
92
|
+
externalSlotProps: innerSlotProps == null ? void 0 : innerSlotProps.field,
|
|
93
|
+
additionalProps: _extends({}, pickerFieldProps, isToolbarHidden && {
|
|
94
|
+
id: labelId
|
|
95
|
+
}, {
|
|
96
|
+
readOnly,
|
|
97
|
+
disabled,
|
|
98
|
+
className,
|
|
99
|
+
sx,
|
|
100
|
+
format,
|
|
101
|
+
label,
|
|
102
|
+
autoFocus: autoFocus && !props.open
|
|
103
|
+
}),
|
|
104
|
+
ownerState: props
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// TODO: Move to `useSlotProps` when https://github.com/mui/material-ui/pull/35088 will be merged
|
|
108
|
+
if (hasUIView) {
|
|
109
|
+
fieldProps.InputProps = _extends({}, fieldProps.InputProps, {
|
|
110
|
+
ref: containerRef,
|
|
111
|
+
[`${inputAdornmentProps.position}Adornment`]: /*#__PURE__*/_jsx(InputAdornment, _extends({}, inputAdornmentProps, {
|
|
112
|
+
children: /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
|
|
113
|
+
children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, innerSlotProps == null ? void 0 : innerSlotProps.openPickerIcon))
|
|
114
|
+
}))
|
|
115
|
+
}))
|
|
116
|
+
});
|
|
117
|
+
}
|
|
103
118
|
const slotsForField = _extends({
|
|
104
119
|
textField: slots.textField
|
|
105
120
|
}, fieldProps.slots);
|
|
106
|
-
const isToolbarHidden = (_innerSlotProps$toolb = innerSlotProps == null ? void 0 : (_innerSlotProps$toolb2 = innerSlotProps.toolbar) == null ? void 0 : _innerSlotProps$toolb2.hidden) != null ? _innerSlotProps$toolb : false;
|
|
107
|
-
const slotPropsForField = _extends({}, fieldProps.slotProps, {
|
|
108
|
-
textField: ownerState => {
|
|
109
|
-
var _fieldProps$slotProps;
|
|
110
|
-
const externalInputProps = resolveComponentProps(innerSlotProps == null ? void 0 : innerSlotProps.textField, ownerState);
|
|
111
|
-
const inputPropsPassedByField = resolveComponentProps((_fieldProps$slotProps = fieldProps.slotProps) == null ? void 0 : _fieldProps$slotProps.textField, ownerState);
|
|
112
|
-
return _extends({}, isToolbarHidden && {
|
|
113
|
-
id: labelId
|
|
114
|
-
}, inputPropsPassedByField, externalInputProps, {
|
|
115
|
-
InputProps: _extends({
|
|
116
|
-
ref: containerRef,
|
|
117
|
-
[`${inputAdornmentProps.position}Adornment`]: hasUIView ? /*#__PURE__*/_jsx(InputAdornment, _extends({}, inputAdornmentProps, {
|
|
118
|
-
children: /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
|
|
119
|
-
children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, innerSlotProps == null ? void 0 : innerSlotProps.openPickerIcon))
|
|
120
|
-
}))
|
|
121
|
-
})) : undefined
|
|
122
|
-
}, inputPropsPassedByField == null ? void 0 : inputPropsPassedByField.InputProps, externalInputProps == null ? void 0 : externalInputProps.InputProps)
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
121
|
const Layout = (_slots$layout = slots.layout) != null ? _slots$layout : PickersLayout;
|
|
127
122
|
const handleInputRef = useForkRef(internalInputRef, fieldProps.inputRef, inputRef);
|
|
128
123
|
let labelledById = labelId;
|
|
@@ -147,7 +142,7 @@ export const useDesktopPicker = ({
|
|
|
147
142
|
value: "desktop",
|
|
148
143
|
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
|
|
149
144
|
slots: slotsForField,
|
|
150
|
-
slotProps:
|
|
145
|
+
slotProps: slotProps,
|
|
151
146
|
inputRef: handleInputRef
|
|
152
147
|
})), /*#__PURE__*/_jsx(PickersPopper, _extends({
|
|
153
148
|
role: "dialog",
|
|
@@ -7,7 +7,7 @@ import { DateOrTimeView, MuiPickersAdapter } from '../../models';
|
|
|
7
7
|
import { BaseNonStaticPickerProps, BasePickerProps, BaseSingleInputNonStaticPickerProps } from '../../models/props/basePickerProps';
|
|
8
8
|
import { PickersPopperSlotsComponent, PickersPopperSlotsComponentsProps } from '../../components/PickersPopper';
|
|
9
9
|
import { UsePickerParams, UsePickerProps } from '../usePicker';
|
|
10
|
-
import {
|
|
10
|
+
import { BaseSingleInputFieldProps } from '../../models/fields';
|
|
11
11
|
import { ExportedPickersLayoutSlotsComponent, ExportedPickersLayoutSlotsComponentsProps, PickersLayoutSlotsComponentsProps } from '../../../PickersLayout/PickersLayout.types';
|
|
12
12
|
import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue';
|
|
13
13
|
import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
|
|
@@ -16,7 +16,7 @@ export interface UseDesktopPickerSlotsComponent<TDate, TView extends DateOrTimeV
|
|
|
16
16
|
/**
|
|
17
17
|
* Component used to enter the date with the keyboard.
|
|
18
18
|
*/
|
|
19
|
-
Field: React.ElementType<
|
|
19
|
+
Field: React.ElementType<BaseSingleInputFieldProps<TDate | null, any>>;
|
|
20
20
|
/**
|
|
21
21
|
* Form control with an input to render the value inside the default field.
|
|
22
22
|
* Receives the same props as `@mui/material/TextField`.
|
|
@@ -41,7 +41,7 @@ export interface UseDesktopPickerSlotsComponent<TDate, TView extends DateOrTimeV
|
|
|
41
41
|
export interface UseDesktopPickerSlotsComponentsProps<TDate, TView extends DateOrTimeView> extends ExportedUseDesktopPickerSlotsComponentsProps<TDate, TView>, Pick<PickersLayoutSlotsComponentsProps<TDate | null, TDate, TView>, 'toolbar'> {
|
|
42
42
|
}
|
|
43
43
|
export interface ExportedUseDesktopPickerSlotsComponentsProps<TDate, TView extends DateOrTimeView> extends PickersPopperSlotsComponentsProps, ExportedPickersLayoutSlotsComponentsProps<TDate | null, TDate, TView> {
|
|
44
|
-
field?: SlotComponentProps<React.ElementType<
|
|
44
|
+
field?: SlotComponentProps<React.ElementType<BaseSingleInputFieldProps<TDate | null, unknown>>, {}, UsePickerProps<TDate | null, any, any, any, any>>;
|
|
45
45
|
textField?: SlotComponentProps<typeof TextField, {}, Record<string, any>>;
|
|
46
46
|
inputAdornment?: Partial<InputAdornmentProps>;
|
|
47
47
|
openPickerButton?: SlotComponentProps<typeof IconButton, {}, UseDesktopPickerProps<TDate, any, any, any>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["onClick", "onKeyDown", "onFocus", "onBlur", "onMouseUp"];
|
|
3
|
+
const _excluded = ["onClick", "onKeyDown", "onFocus", "onBlur", "onMouseUp", "onPaste"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
6
6
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
@@ -44,7 +44,8 @@ export const useField = params => {
|
|
|
44
44
|
onKeyDown,
|
|
45
45
|
onFocus,
|
|
46
46
|
onBlur,
|
|
47
|
-
onMouseUp
|
|
47
|
+
onMouseUp,
|
|
48
|
+
onPaste
|
|
48
49
|
},
|
|
49
50
|
fieldValueManager,
|
|
50
51
|
valueManager,
|
|
@@ -98,6 +99,7 @@ export const useField = params => {
|
|
|
98
99
|
setSelectedSections(null);
|
|
99
100
|
});
|
|
100
101
|
const handleInputPaste = useEventCallback(event => {
|
|
102
|
+
onPaste == null ? void 0 : onPaste(event);
|
|
101
103
|
if (readOnly) {
|
|
102
104
|
event.preventDefault();
|
|
103
105
|
return;
|
|
@@ -289,6 +291,17 @@ export const useField = params => {
|
|
|
289
291
|
return () => window.clearTimeout(focusTimeoutRef.current);
|
|
290
292
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
291
293
|
|
|
294
|
+
// If `state.tempValueStrAndroid` is still defined when running `useEffect`,
|
|
295
|
+
// Then `onChange` has only been called once, which means the user pressed `Backspace` to reset the section.
|
|
296
|
+
// This causes a small flickering on Android,
|
|
297
|
+
// But we can't use `useEnhancedEffect` which is always called before the second `onChange` call and then would cause false positives.
|
|
298
|
+
React.useEffect(() => {
|
|
299
|
+
if (state.tempValueStrAndroid != null && selectedSectionIndexes != null) {
|
|
300
|
+
resetCharacterQuery();
|
|
301
|
+
clearActiveSection();
|
|
302
|
+
}
|
|
303
|
+
}, [state.tempValueStrAndroid]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
304
|
+
|
|
292
305
|
const valueStr = React.useMemo(() => {
|
|
293
306
|
var _state$tempValueStrAn;
|
|
294
307
|
return (_state$tempValueStrAn = state.tempValueStrAndroid) != null ? _state$tempValueStrAn : fieldValueManager.getValueStrFromSections(state.sections);
|
|
@@ -67,6 +67,7 @@ export interface UseFieldInternalProps<TValue, TError> {
|
|
|
67
67
|
export interface UseFieldForwardedProps {
|
|
68
68
|
onKeyDown?: React.KeyboardEventHandler;
|
|
69
69
|
onMouseUp?: React.MouseEventHandler;
|
|
70
|
+
onPaste?: React.ClipboardEventHandler<HTMLInputElement>;
|
|
70
71
|
onClick?: () => void;
|
|
71
72
|
onFocus?: () => void;
|
|
72
73
|
onBlur?: () => void;
|
|
@@ -253,8 +253,8 @@ export const getSectionVisibleValue = (section, willBeRenderedInInput) => {
|
|
|
253
253
|
// If you press `1`, on the first section, the new value is also `1/dd/yyyy`,
|
|
254
254
|
// So the browser will not fire the input `onChange`.
|
|
255
255
|
// Adding the ltr mark is not a problem because it's only for digit (which are always ltr)
|
|
256
|
-
// The \u2068 and \u2069 are cleaned, but not the \u200e to notice that an update with same digit
|
|
257
|
-
if (willBeRenderedInInput && section.contentType === 'digit' && !section.hasTrailingZeroes) {
|
|
256
|
+
// The \u2068 and \u2069 are cleaned, but not the \u200e to notice that an update with same digit occurs
|
|
257
|
+
if (willBeRenderedInInput && section.contentType === 'digit' && !section.hasTrailingZeroes && value.length === 1) {
|
|
258
258
|
return `\u2068${value}\u200e\u2069`;
|
|
259
259
|
}
|
|
260
260
|
if (willBeRenderedInInput) {
|
|
@@ -364,7 +364,7 @@ export const doesSectionHaveTrailingZeros = (utils, contentType, dateSectionName
|
|
|
364
364
|
}
|
|
365
365
|
return changeSectionValueFormat(utils, '1', format, format).length > 1;
|
|
366
366
|
};
|
|
367
|
-
const
|
|
367
|
+
const getEscapedPartsFromFormat = (utils, format) => {
|
|
368
368
|
const escapedParts = [];
|
|
369
369
|
const {
|
|
370
370
|
start: startChar,
|
|
@@ -373,7 +373,7 @@ const getEscapedPartsFromExpandedFormat = (utils, expandedFormat) => {
|
|
|
373
373
|
const regExp = new RegExp(`(\\${startChar}[^\\${endChar}]*\\${endChar})+`, 'g');
|
|
374
374
|
let match = null;
|
|
375
375
|
// eslint-disable-next-line no-cond-assign
|
|
376
|
-
while (match = regExp.exec(
|
|
376
|
+
while (match = regExp.exec(format)) {
|
|
377
377
|
escapedParts.push({
|
|
378
378
|
start: match.index,
|
|
379
379
|
end: regExp.lastIndex - 1
|
|
@@ -382,50 +382,63 @@ const getEscapedPartsFromExpandedFormat = (utils, expandedFormat) => {
|
|
|
382
382
|
return escapedParts;
|
|
383
383
|
};
|
|
384
384
|
export const splitFormatIntoSections = (utils, localeText, format, date) => {
|
|
385
|
-
const expandedFormat = utils.expandFormat(format);
|
|
386
|
-
const escapedParts = getEscapedPartsFromExpandedFormat(utils, expandedFormat);
|
|
387
|
-
let currentTokenValue = '';
|
|
388
385
|
let startSeparator = '';
|
|
389
386
|
const sections = [];
|
|
390
|
-
const
|
|
391
|
-
if (
|
|
392
|
-
return;
|
|
387
|
+
const commitToken = token => {
|
|
388
|
+
if (token === '') {
|
|
389
|
+
return null;
|
|
393
390
|
}
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
391
|
+
const expandedToken = utils.expandFormat(token);
|
|
392
|
+
if (expandedToken !== token) {
|
|
393
|
+
return expandedToken;
|
|
394
|
+
}
|
|
395
|
+
const sectionConfig = getDateSectionConfigFromFormatToken(utils, token);
|
|
396
|
+
const sectionValue = date == null ? '' : utils.formatByString(date, token);
|
|
397
|
+
const hasTrailingZeroes = doesSectionHaveTrailingZeros(utils, sectionConfig.contentType, sectionConfig.dateSectionName, token);
|
|
397
398
|
sections.push(_extends({}, sectionConfig, {
|
|
398
|
-
formatValue:
|
|
399
|
+
formatValue: token,
|
|
399
400
|
value: sectionValue,
|
|
400
|
-
placeholder: getSectionPlaceholder(utils, localeText, sectionConfig,
|
|
401
|
+
placeholder: getSectionPlaceholder(utils, localeText, sectionConfig, token),
|
|
401
402
|
hasTrailingZeroes,
|
|
402
403
|
startSeparator: sections.length === 0 ? startSeparator : '',
|
|
403
404
|
endSeparator: '',
|
|
404
405
|
edited: false
|
|
405
406
|
}));
|
|
406
|
-
|
|
407
|
+
return null;
|
|
407
408
|
};
|
|
408
|
-
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
409
|
+
const splitFormat = token => {
|
|
410
|
+
const escapedParts = getEscapedPartsFromFormat(utils, token);
|
|
411
|
+
let currentTokenValue = '';
|
|
412
|
+
for (let i = 0; i < token.length; i += 1) {
|
|
413
|
+
const escapedPartOfCurrentChar = escapedParts.find(escapeIndex => escapeIndex.start <= i && escapeIndex.end >= i);
|
|
414
|
+
const char = token[i];
|
|
415
|
+
const isEscapedChar = escapedPartOfCurrentChar != null;
|
|
416
|
+
if (!isEscapedChar && char.match(/([A-Za-z]+)/)) {
|
|
417
|
+
currentTokenValue += char;
|
|
418
|
+
} else {
|
|
419
|
+
// If we are on the opening or closing character of an escaped part of the format,
|
|
420
|
+
// Then we ignore this character.
|
|
421
|
+
const isEscapeBoundary = isEscapedChar && (escapedPartOfCurrentChar == null ? void 0 : escapedPartOfCurrentChar.start) === i || (escapedPartOfCurrentChar == null ? void 0 : escapedPartOfCurrentChar.end) === i;
|
|
422
|
+
if (!isEscapeBoundary) {
|
|
423
|
+
const expandedToken = commitToken(currentTokenValue);
|
|
424
|
+
if (expandedToken != null) {
|
|
425
|
+
splitFormat(expandedToken);
|
|
426
|
+
}
|
|
427
|
+
currentTokenValue = '';
|
|
428
|
+
if (sections.length === 0) {
|
|
429
|
+
startSeparator += char;
|
|
430
|
+
} else {
|
|
431
|
+
sections[sections.length - 1].endSeparator += char;
|
|
432
|
+
}
|
|
424
433
|
}
|
|
425
434
|
}
|
|
426
435
|
}
|
|
427
|
-
|
|
428
|
-
|
|
436
|
+
const expandedToken = commitToken(currentTokenValue);
|
|
437
|
+
if (expandedToken != null) {
|
|
438
|
+
splitFormat(expandedToken);
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
splitFormat(format);
|
|
429
442
|
const cleanSections = sections.map(section => {
|
|
430
443
|
const cleanSeparator = separator => {
|
|
431
444
|
let cleanedSeparator = separator;
|
|
@@ -137,7 +137,8 @@ export const useFieldState = params => {
|
|
|
137
137
|
return publishValue(newValue, newSections);
|
|
138
138
|
}
|
|
139
139
|
return setState(prevState => _extends({}, prevState, {
|
|
140
|
-
sections: newSections
|
|
140
|
+
sections: newSections,
|
|
141
|
+
tempValueStrAndroid: null
|
|
141
142
|
}, newValue));
|
|
142
143
|
};
|
|
143
144
|
const updateValueFromValueStr = valueStr => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
4
4
|
import useForkRef from '@mui/utils/useForkRef';
|
|
5
5
|
import useId from '@mui/utils/useId';
|
|
6
6
|
import { PickersModalDialog } from '../../components/PickersModalDialog';
|
|
@@ -40,6 +40,7 @@ export const useMobilePicker = ({
|
|
|
40
40
|
const utils = useUtils();
|
|
41
41
|
const internalInputRef = React.useRef(null);
|
|
42
42
|
const labelId = useId();
|
|
43
|
+
const isToolbarHidden = (_innerSlotProps$toolb = innerSlotProps == null ? void 0 : (_innerSlotProps$toolb2 = innerSlotProps.toolbar) == null ? void 0 : _innerSlotProps$toolb2.hidden) != null ? _innerSlotProps$toolb : false;
|
|
43
44
|
const {
|
|
44
45
|
open,
|
|
45
46
|
actions,
|
|
@@ -59,7 +60,12 @@ export const useMobilePicker = ({
|
|
|
59
60
|
const fieldProps = useSlotProps({
|
|
60
61
|
elementType: Field,
|
|
61
62
|
externalSlotProps: innerSlotProps == null ? void 0 : innerSlotProps.field,
|
|
62
|
-
additionalProps: _extends({}, pickerFieldProps, {
|
|
63
|
+
additionalProps: _extends({}, pickerFieldProps, isToolbarHidden && {
|
|
64
|
+
id: labelId
|
|
65
|
+
}, !(disabled || readOnly) && {
|
|
66
|
+
onClick: actions.onOpen,
|
|
67
|
+
onKeyDown: onSpaceOrEnter(actions.onOpen)
|
|
68
|
+
}, {
|
|
63
69
|
readOnly: readOnly != null ? readOnly : true,
|
|
64
70
|
disabled,
|
|
65
71
|
className,
|
|
@@ -69,29 +75,14 @@ export const useMobilePicker = ({
|
|
|
69
75
|
}),
|
|
70
76
|
ownerState: props
|
|
71
77
|
});
|
|
78
|
+
|
|
79
|
+
// TODO: Move to `useSlotProps` when https://github.com/mui/material-ui/pull/35088 will be merged
|
|
80
|
+
fieldProps.inputProps = _extends({}, fieldProps.inputProps, {
|
|
81
|
+
'aria-label': getOpenDialogAriaText(pickerFieldProps.value, utils)
|
|
82
|
+
});
|
|
72
83
|
const slotsForField = _extends({
|
|
73
84
|
textField: slots.textField
|
|
74
85
|
}, fieldProps.slots);
|
|
75
|
-
const isToolbarHidden = (_innerSlotProps$toolb = innerSlotProps == null ? void 0 : (_innerSlotProps$toolb2 = innerSlotProps.toolbar) == null ? void 0 : _innerSlotProps$toolb2.hidden) != null ? _innerSlotProps$toolb : false;
|
|
76
|
-
const slotPropsForField = _extends({}, fieldProps.slotProps, {
|
|
77
|
-
textField: ownerState => {
|
|
78
|
-
var _fieldProps$slotProps;
|
|
79
|
-
const externalInputProps = resolveComponentProps(innerSlotProps == null ? void 0 : innerSlotProps.textField, ownerState);
|
|
80
|
-
const inputPropsPassedByField = resolveComponentProps((_fieldProps$slotProps = fieldProps.slotProps) == null ? void 0 : _fieldProps$slotProps.textField, ownerState);
|
|
81
|
-
return _extends({}, isToolbarHidden && {
|
|
82
|
-
id: labelId
|
|
83
|
-
}, inputPropsPassedByField, externalInputProps, {
|
|
84
|
-
disabled
|
|
85
|
-
}, !(disabled || readOnly) && {
|
|
86
|
-
onClick: actions.onOpen,
|
|
87
|
-
onKeyDown: onSpaceOrEnter(actions.onOpen)
|
|
88
|
-
}, {
|
|
89
|
-
inputProps: _extends({
|
|
90
|
-
'aria-label': getOpenDialogAriaText(pickerFieldProps.value, utils)
|
|
91
|
-
}, inputPropsPassedByField == null ? void 0 : inputPropsPassedByField.inputProps, externalInputProps == null ? void 0 : externalInputProps.inputProps)
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
86
|
const Layout = (_slots$layout = slots.layout) != null ? _slots$layout : PickersLayout;
|
|
96
87
|
const handleInputRef = useForkRef(internalInputRef, fieldProps.inputRef, inputRef);
|
|
97
88
|
let labelledById = labelId;
|
|
@@ -116,7 +107,7 @@ export const useMobilePicker = ({
|
|
|
116
107
|
value: "mobile",
|
|
117
108
|
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
|
|
118
109
|
slots: slotsForField,
|
|
119
|
-
slotProps:
|
|
110
|
+
slotProps: slotProps,
|
|
120
111
|
inputRef: handleInputRef
|
|
121
112
|
})), /*#__PURE__*/_jsx(PickersModalDialog, _extends({}, actions, {
|
|
122
113
|
open: open,
|
|
@@ -5,7 +5,7 @@ import { DateOrTimeView, MuiPickersAdapter } from '../../models';
|
|
|
5
5
|
import { BaseNonStaticPickerProps, BasePickerProps, BaseSingleInputNonStaticPickerProps } from '../../models/props/basePickerProps';
|
|
6
6
|
import { PickersModalDialogSlotsComponent, PickersModalDialogSlotsComponentsProps } from '../../components/PickersModalDialog';
|
|
7
7
|
import { UsePickerParams, UsePickerProps } from '../usePicker';
|
|
8
|
-
import {
|
|
8
|
+
import { BaseSingleInputFieldProps } from '../../models/fields';
|
|
9
9
|
import { ExportedPickersLayoutSlotsComponent, ExportedPickersLayoutSlotsComponentsProps, PickersLayoutSlotsComponentsProps } from '../../../PickersLayout/PickersLayout.types';
|
|
10
10
|
import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue';
|
|
11
11
|
import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
|
|
@@ -14,7 +14,7 @@ export interface UseMobilePickerSlotsComponent<TDate, TView extends DateOrTimeVi
|
|
|
14
14
|
/**
|
|
15
15
|
* Component used to enter the date with the keyboard.
|
|
16
16
|
*/
|
|
17
|
-
Field: React.ElementType<
|
|
17
|
+
Field: React.ElementType<BaseSingleInputFieldProps<TDate | null, any>>;
|
|
18
18
|
/**
|
|
19
19
|
* Form control with an input to render the value inside the default field.
|
|
20
20
|
* Receives the same props as `@mui/material/TextField`.
|
|
@@ -23,7 +23,7 @@ export interface UseMobilePickerSlotsComponent<TDate, TView extends DateOrTimeVi
|
|
|
23
23
|
TextField?: React.ElementType<TextFieldProps>;
|
|
24
24
|
}
|
|
25
25
|
export interface ExportedUseMobilePickerSlotsComponentsProps<TDate, TView extends DateOrTimeView> extends PickersModalDialogSlotsComponentsProps, ExportedPickersLayoutSlotsComponentsProps<TDate | null, TDate, TView> {
|
|
26
|
-
field?: SlotComponentProps<React.ElementType<
|
|
26
|
+
field?: SlotComponentProps<React.ElementType<BaseSingleInputFieldProps<TDate | null, unknown>>, {}, UsePickerProps<TDate | null, any, any, any, any>>;
|
|
27
27
|
textField?: SlotComponentProps<typeof TextField, {}, Record<string, any>>;
|
|
28
28
|
}
|
|
29
29
|
export interface UseMobilePickerSlotsComponentsProps<TDate, TView extends DateOrTimeView> extends ExportedUseMobilePickerSlotsComponentsProps<TDate, TView>, Pick<PickersLayoutSlotsComponentsProps<TDate | null, TDate, TView>, 'toolbar'> {
|
package/internals/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { WrapperVariantContext } from './components/wrappers/WrapperVariantConte
|
|
|
24
24
|
export { DAY_MARGIN, DIALOG_WIDTH } from './constants/dimensions';
|
|
25
25
|
export type { DesktopOnlyPickerProps } from './hooks/useDesktopPicker';
|
|
26
26
|
export { useField, createDateStrForInputFromSections, addPositionPropertiesToSections, splitFormatIntoSections, getSectionOrder, } from './hooks/useField';
|
|
27
|
-
export type { UseFieldInternalProps, UseFieldParams, UseFieldResponse, FieldValueManager, FieldSection, FieldChangeHandler, FieldChangeHandlerContext, } from './hooks/useField';
|
|
27
|
+
export type { UseFieldInternalProps, UseFieldParams, UseFieldResponse, UseFieldForwardedProps, FieldValueManager, FieldSection, FieldChangeHandler, FieldChangeHandlerContext, } from './hooks/useField';
|
|
28
28
|
export type { MobileOnlyPickerProps } from './hooks/useMobilePicker';
|
|
29
29
|
export { usePicker } from './hooks/usePicker';
|
|
30
30
|
export type { UsePickerResponse, UsePickerParams } from './hooks/usePicker';
|