@mui/x-date-pickers 7.18.0 → 7.20.0
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/AdapterDateFnsBase/AdapterDateFnsBase.js +1 -0
- package/AdapterMoment/AdapterMoment.js +1 -0
- package/CHANGELOG.md +213 -11
- package/DateCalendar/DateCalendar.js +1 -1
- package/DateCalendar/DateCalendar.types.d.ts +1 -1
- package/DateField/DateField.types.d.ts +2 -7
- package/DateField/index.d.ts +1 -1
- package/DateField/useDateField.d.ts +1 -1
- package/DatePicker/DatePicker.js +1 -1
- package/DatePicker/DatePicker.types.d.ts +8 -1
- package/DatePicker/index.d.ts +1 -1
- package/DateTimeField/DateTimeField.types.d.ts +2 -7
- package/DateTimeField/index.d.ts +1 -1
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.js +1 -1
- package/DateTimePicker/DateTimePicker.types.d.ts +9 -1
- package/DateTimePicker/index.d.ts +1 -1
- package/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -1
- package/DigitalClock/DigitalClock.js +39 -0
- package/MobileDatePicker/MobileDatePicker.js +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +38 -1
- package/PickersCalendarHeader/PickersCalendarHeader.js +1 -1
- package/PickersLayout/PickersLayout.d.ts +2 -2
- package/PickersLayout/PickersLayout.js +1 -1
- package/PickersSectionList/PickersSectionList.d.ts +4 -4
- package/PickersTextField/PickersInputBase/PickersInputBase.d.ts +2 -2
- package/StaticDatePicker/StaticDatePicker.js +1 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/TimeClock/Clock.js +9 -1
- package/TimeClock/ClockNumber.js +1 -1
- package/TimeClock/ClockPointer.js +1 -1
- package/TimeField/TimeField.types.d.ts +2 -7
- package/TimeField/index.d.ts +1 -1
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimePicker/TimePicker.types.d.ts +9 -1
- package/TimePicker/index.d.ts +1 -1
- package/YearCalendar/YearCalendar.js +1 -1
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +3 -1
- package/hooks/useParsedFormat.d.ts +15 -0
- package/hooks/useParsedFormat.js +43 -0
- package/hooks/usePickersContext.d.ts +4 -0
- package/hooks/usePickersContext.js +15 -0
- package/index.js +1 -1
- package/internals/components/PickerViewRoot/PickerViewRoot.d.ts +1 -1
- package/internals/components/PickersProvider.d.ts +34 -0
- package/internals/components/PickersProvider.js +26 -0
- package/internals/components/PickersToolbarButton.js +1 -1
- package/internals/components/PickersToolbarText.js +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +7 -4
- package/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -2
- package/internals/hooks/useField/buildSectionsFromFormat.js +4 -5
- package/internals/hooks/useField/useField.utils.d.ts +3 -3
- package/internals/hooks/useField/useField.utils.js +13 -13
- package/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/internals/hooks/useField/useFieldState.js +3 -5
- package/internals/hooks/useMobilePicker/useMobilePicker.js +7 -4
- package/internals/hooks/usePicker/usePicker.js +3 -1
- package/internals/hooks/usePicker/usePickerValue.js +7 -2
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +2 -0
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/internals/utils/utils.d.ts +7 -0
- package/internals/utils/utils.js +11 -0
- package/locales/bgBG.d.ts +80 -0
- package/locales/bgBG.js +73 -0
- package/locales/csCZ.js +16 -20
- package/locales/hrHR.d.ts +80 -0
- package/locales/hrHR.js +90 -0
- package/locales/index.d.ts +3 -0
- package/locales/index.js +3 -0
- package/locales/ptBR.js +3 -4
- package/locales/ptPT.d.ts +80 -0
- package/locales/ptPT.js +73 -0
- package/models/pickers.d.ts +1 -1
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +1 -0
- package/modern/AdapterMoment/AdapterMoment.js +1 -0
- package/modern/DateCalendar/DateCalendar.js +1 -1
- package/modern/DatePicker/DatePicker.js +1 -1
- package/modern/DateTimePicker/DateTimePicker.js +1 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -1
- package/modern/DigitalClock/DigitalClock.js +39 -0
- package/modern/MobileDatePicker/MobileDatePicker.js +1 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +38 -1
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +1 -1
- package/modern/PickersLayout/PickersLayout.js +1 -1
- package/modern/StaticDatePicker/StaticDatePicker.js +1 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/modern/TimeClock/Clock.js +9 -1
- package/modern/TimeClock/ClockNumber.js +1 -1
- package/modern/TimeClock/ClockPointer.js +1 -1
- package/modern/YearCalendar/YearCalendar.js +1 -1
- package/modern/hooks/index.js +3 -1
- package/modern/hooks/useParsedFormat.js +43 -0
- package/modern/hooks/usePickersContext.js +15 -0
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersProvider.js +26 -0
- package/modern/internals/components/PickersToolbarButton.js +1 -1
- package/modern/internals/components/PickersToolbarText.js +1 -1
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +7 -4
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +4 -5
- package/modern/internals/hooks/useField/useField.utils.js +13 -13
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/modern/internals/hooks/useField/useFieldState.js +3 -5
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +7 -4
- package/modern/internals/hooks/usePicker/usePicker.js +3 -1
- package/modern/internals/hooks/usePicker/usePickerValue.js +7 -2
- package/modern/internals/index.js +1 -0
- package/modern/internals/utils/utils.js +11 -0
- package/modern/locales/bgBG.js +73 -0
- package/modern/locales/csCZ.js +16 -20
- package/modern/locales/hrHR.js +90 -0
- package/modern/locales/index.js +3 -0
- package/modern/locales/ptBR.js +3 -4
- package/modern/locales/ptPT.js +73 -0
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +1 -0
- package/node/AdapterMoment/AdapterMoment.js +1 -0
- package/node/DateCalendar/DateCalendar.js +1 -1
- package/node/DatePicker/DatePicker.js +1 -1
- package/node/DateTimePicker/DateTimePicker.js +1 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -1
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -1
- package/node/DigitalClock/DigitalClock.js +39 -0
- package/node/MobileDatePicker/MobileDatePicker.js +1 -1
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +38 -1
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +1 -1
- package/node/PickersLayout/PickersLayout.js +1 -1
- package/node/StaticDatePicker/StaticDatePicker.js +1 -1
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/node/TimeClock/Clock.js +9 -1
- package/node/TimeClock/ClockNumber.js +1 -1
- package/node/TimeClock/ClockPointer.js +1 -1
- package/node/YearCalendar/YearCalendar.js +1 -1
- package/node/hooks/index.js +15 -1
- package/node/hooks/useParsedFormat.js +50 -0
- package/node/hooks/usePickersContext.js +21 -0
- package/node/index.js +1 -1
- package/node/internals/components/PickersProvider.js +34 -0
- package/node/internals/components/PickersToolbarButton.js +1 -1
- package/node/internals/components/PickersToolbarText.js +1 -1
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -3
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +4 -5
- package/node/internals/hooks/useField/useField.utils.js +13 -13
- package/node/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/node/internals/hooks/useField/useFieldState.js +3 -5
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +5 -3
- package/node/internals/hooks/usePicker/usePicker.js +3 -1
- package/node/internals/hooks/usePicker/usePickerValue.js +7 -1
- package/node/internals/index.js +7 -0
- package/node/internals/utils/utils.js +13 -1
- package/node/locales/bgBG.js +79 -0
- package/node/locales/csCZ.js +16 -20
- package/node/locales/hrHR.js +96 -0
- package/node/locales/index.js +33 -0
- package/node/locales/ptBR.js +3 -4
- package/node/locales/ptPT.js +79 -0
- package/package.json +4 -4
|
@@ -10,6 +10,7 @@ import MenuItem from '@mui/material/MenuItem';
|
|
|
10
10
|
import useForkRef from '@mui/utils/useForkRef';
|
|
11
11
|
import { getMultiSectionDigitalClockSectionUtilityClass } from "./multiSectionDigitalClockSectionClasses.js";
|
|
12
12
|
import { DIGITAL_CLOCK_VIEW_HEIGHT, MULTI_SECTION_CLOCK_SECTION_WIDTH } from "../internals/constants/dimensions.js";
|
|
13
|
+
import { getFocusedListItemIndex } from "../internals/utils/utils.js";
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
const useUtilityClasses = ownerState => {
|
|
15
16
|
const {
|
|
@@ -138,12 +139,48 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
|
|
|
138
139
|
containerRef.current.scrollTop = offsetTop - 4;
|
|
139
140
|
});
|
|
140
141
|
const focusedOptionIndex = items.findIndex(item => item.isFocused(item.value));
|
|
142
|
+
const handleKeyDown = event => {
|
|
143
|
+
switch (event.key) {
|
|
144
|
+
case 'PageUp':
|
|
145
|
+
{
|
|
146
|
+
if (!containerRef.current) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const newIndex = getFocusedListItemIndex(containerRef.current) - 5;
|
|
150
|
+
const children = containerRef.current?.children;
|
|
151
|
+
const newFocusedIndex = Math.max(0, newIndex);
|
|
152
|
+
const childToFocus = children[newFocusedIndex];
|
|
153
|
+
if (childToFocus) {
|
|
154
|
+
childToFocus.focus();
|
|
155
|
+
}
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case 'PageDown':
|
|
160
|
+
{
|
|
161
|
+
if (!containerRef.current) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const newIndex = getFocusedListItemIndex(containerRef.current) + 5;
|
|
165
|
+
const children = containerRef.current?.children;
|
|
166
|
+
const newFocusedIndex = Math.min(children.length - 1, newIndex);
|
|
167
|
+
const childToFocus = children[newFocusedIndex];
|
|
168
|
+
if (childToFocus) {
|
|
169
|
+
childToFocus.focus();
|
|
170
|
+
}
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
default:
|
|
175
|
+
}
|
|
176
|
+
};
|
|
141
177
|
return /*#__PURE__*/_jsx(MultiSectionDigitalClockSectionRoot, _extends({
|
|
142
178
|
ref: handleRef,
|
|
143
179
|
className: clsx(classes.root, className),
|
|
144
180
|
ownerState: ownerState,
|
|
145
181
|
autoFocusItem: autoFocus && active,
|
|
146
|
-
role: "listbox"
|
|
182
|
+
role: "listbox",
|
|
183
|
+
onKeyDown: handleKeyDown
|
|
147
184
|
}, other, {
|
|
148
185
|
children: items.map((option, index) => {
|
|
149
186
|
const isItemDisabled = option.isDisabled?.(option.value);
|
|
@@ -190,7 +190,7 @@ const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCale
|
|
|
190
190
|
const label = utils.formatByString(month, format);
|
|
191
191
|
return /*#__PURE__*/_jsxs(PickersCalendarHeaderRoot, _extends({}, other, {
|
|
192
192
|
ownerState: ownerState,
|
|
193
|
-
className: clsx(
|
|
193
|
+
className: clsx(classes.root, className),
|
|
194
194
|
ref: ref,
|
|
195
195
|
children: [/*#__PURE__*/_jsxs(PickersCalendarHeaderLabelContainer, {
|
|
196
196
|
role: "presentation",
|
|
@@ -2,10 +2,10 @@ import * as React from 'react';
|
|
|
2
2
|
import { PickersLayoutProps } from './PickersLayout.types';
|
|
3
3
|
import { DateOrTimeViewWithMeridiem } from '../internals/models';
|
|
4
4
|
import { PickerValidDate } from '../models';
|
|
5
|
-
export declare const PickersLayoutRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material
|
|
5
|
+
export declare const PickersLayoutRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
6
6
|
ownerState: PickersLayoutProps<any, any, any>;
|
|
7
7
|
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
8
|
-
export declare const PickersLayoutContentWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material
|
|
8
|
+
export declare const PickersLayoutContentWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
9
9
|
type PickersLayoutComponent = (<TValue, TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem>(props: PickersLayoutProps<TValue, TDate, TView> & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
|
10
10
|
propTypes?: any;
|
|
11
11
|
};
|
|
@@ -122,7 +122,7 @@ const PickersLayout = /*#__PURE__*/React.forwardRef(function PickersLayout(inPro
|
|
|
122
122
|
return /*#__PURE__*/_jsxs(PickersLayoutRoot, {
|
|
123
123
|
ref: ref,
|
|
124
124
|
sx: sx,
|
|
125
|
-
className: clsx(
|
|
125
|
+
className: clsx(classes.root, className),
|
|
126
126
|
ownerState: props,
|
|
127
127
|
children: [isLandscape ? shortcuts : toolbar, isLandscape ? toolbar : shortcuts, /*#__PURE__*/_jsx(PickersLayoutContentWrapper, {
|
|
128
128
|
className: classes.contentWrapper,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PickersSectionListProps } from './PickersSectionList.types';
|
|
3
|
-
export declare const PickersSectionListRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material
|
|
4
|
-
export declare const PickersSectionListSection: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material
|
|
5
|
-
export declare const PickersSectionListSectionSeparator: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material
|
|
6
|
-
export declare const PickersSectionListSectionContent: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material
|
|
3
|
+
export declare const PickersSectionListRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
4
|
+
export declare const PickersSectionListSection: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, keyof React.ClassAttributes<HTMLSpanElement> | keyof React.HTMLAttributes<HTMLSpanElement>>, {}>;
|
|
5
|
+
export declare const PickersSectionListSectionSeparator: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, keyof React.ClassAttributes<HTMLSpanElement> | keyof React.HTMLAttributes<HTMLSpanElement>>, {}>;
|
|
6
|
+
export declare const PickersSectionListSectionContent: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, keyof React.ClassAttributes<HTMLSpanElement> | keyof React.HTMLAttributes<HTMLSpanElement>>, {}>;
|
|
7
7
|
type PickersSectionListComponent = ((props: PickersSectionListProps & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
|
8
8
|
propTypes?: any;
|
|
9
9
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { FormControlState } from '@mui/material/FormControl';
|
|
3
3
|
import { PickersInputBaseProps } from './PickersInputBase.types';
|
|
4
|
-
export declare const PickersInputBaseRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material
|
|
4
|
+
export declare const PickersInputBaseRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
5
5
|
ownerState: OwnerStateType;
|
|
6
6
|
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
7
|
-
export declare const PickersInputBaseSectionsContainer: import("@emotion/styled").StyledComponent<Pick<import("@mui/system").MUIStyledCommonProps<import("@mui/material
|
|
7
|
+
export declare const PickersInputBaseSectionsContainer: import("@emotion/styled").StyledComponent<Pick<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement> | keyof import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
8
8
|
ownerState: OwnerStateType;
|
|
9
9
|
}, {}, {}>;
|
|
10
10
|
interface OwnerStateType extends FormControlState, Omit<PickersInputBaseProps, keyof FormControlState> {
|
|
@@ -208,7 +208,7 @@ StaticDatePicker.propTypes = {
|
|
|
208
208
|
/**
|
|
209
209
|
* Component displaying when passed `loading` true.
|
|
210
210
|
* @returns {React.ReactNode} The node to render when loading.
|
|
211
|
-
* @default () => <span
|
|
211
|
+
* @default () => <span>...</span>
|
|
212
212
|
*/
|
|
213
213
|
renderLoading: PropTypes.func,
|
|
214
214
|
/**
|
|
@@ -256,7 +256,7 @@ StaticDateTimePicker.propTypes = {
|
|
|
256
256
|
/**
|
|
257
257
|
* Component displaying when passed `loading` true.
|
|
258
258
|
* @returns {React.ReactNode} The node to render when loading.
|
|
259
|
-
* @default () => <span
|
|
259
|
+
* @default () => <span>...</span>
|
|
260
260
|
*/
|
|
261
261
|
renderLoading: PropTypes.func,
|
|
262
262
|
/**
|
package/TimeClock/Clock.js
CHANGED
|
@@ -274,6 +274,14 @@ export function Clock(inProps) {
|
|
|
274
274
|
handleValueChange(viewValue - keyboardControlStep, 'partial');
|
|
275
275
|
event.preventDefault();
|
|
276
276
|
break;
|
|
277
|
+
case 'PageUp':
|
|
278
|
+
handleValueChange(viewValue + 5, 'partial');
|
|
279
|
+
event.preventDefault();
|
|
280
|
+
break;
|
|
281
|
+
case 'PageDown':
|
|
282
|
+
handleValueChange(viewValue - 5, 'partial');
|
|
283
|
+
event.preventDefault();
|
|
284
|
+
break;
|
|
277
285
|
case 'Enter':
|
|
278
286
|
case ' ':
|
|
279
287
|
handleValueChange(viewValue, 'finish');
|
|
@@ -284,7 +292,7 @@ export function Clock(inProps) {
|
|
|
284
292
|
}
|
|
285
293
|
};
|
|
286
294
|
return /*#__PURE__*/_jsxs(ClockRoot, {
|
|
287
|
-
className: clsx(
|
|
295
|
+
className: clsx(classes.root, className),
|
|
288
296
|
children: [/*#__PURE__*/_jsxs(ClockClock, {
|
|
289
297
|
className: classes.clock,
|
|
290
298
|
children: [/*#__PURE__*/_jsx(ClockSquareMask, {
|
package/TimeClock/ClockNumber.js
CHANGED
|
@@ -84,7 +84,7 @@ export function ClockNumber(inProps) {
|
|
|
84
84
|
const x = Math.round(Math.cos(angle) * length);
|
|
85
85
|
const y = Math.round(Math.sin(angle) * length);
|
|
86
86
|
return /*#__PURE__*/_jsx(ClockNumberRoot, _extends({
|
|
87
|
-
className: clsx(
|
|
87
|
+
className: clsx(classes.root, className),
|
|
88
88
|
"aria-disabled": disabled ? true : undefined,
|
|
89
89
|
"aria-selected": selected ? true : undefined,
|
|
90
90
|
role: "option",
|
|
@@ -102,7 +102,7 @@ export function ClockPointer(inProps) {
|
|
|
102
102
|
};
|
|
103
103
|
return /*#__PURE__*/_jsx(ClockPointerRoot, _extends({
|
|
104
104
|
style: getAngleStyle(),
|
|
105
|
-
className: clsx(
|
|
105
|
+
className: clsx(classes.root, className),
|
|
106
106
|
ownerState: ownerState
|
|
107
107
|
}, other, {
|
|
108
108
|
children: /*#__PURE__*/_jsx(ClockPointerThumb, {
|
|
@@ -2,9 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import { SlotComponentProps } from '@mui/utils';
|
|
3
3
|
import TextField from '@mui/material/TextField';
|
|
4
4
|
import { UseFieldInternalProps } from '../internals/hooks/useField';
|
|
5
|
-
import {
|
|
5
|
+
import { MakeOptional } from '../internals/models/helpers';
|
|
6
6
|
import { BaseTimeValidationProps, TimeValidationProps } from '../internals/models/validation';
|
|
7
|
-
import { FieldSection, PickerValidDate, TimeValidationError, BuiltInFieldTextFieldProps
|
|
7
|
+
import { FieldSection, PickerValidDate, TimeValidationError, BuiltInFieldTextFieldProps } from '../models';
|
|
8
8
|
import { ExportedUseClearableFieldProps, UseClearableFieldSlots, UseClearableFieldSlotProps } from '../hooks/useClearableField';
|
|
9
9
|
export interface UseTimeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<TDate | null, TDate, FieldSection, TEnableAccessibleFieldDOMStructure, TimeValidationError>, 'format'>, TimeValidationProps<TDate>, BaseTimeValidationProps, ExportedUseClearableFieldProps {
|
|
10
10
|
/**
|
|
@@ -13,11 +13,6 @@ export interface UseTimeFieldProps<TDate extends PickerValidDate, TEnableAccessi
|
|
|
13
13
|
*/
|
|
14
14
|
ampm?: boolean;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Props the field can receive when used inside a time picker.
|
|
18
|
-
* (`TimePicker`, `DesktopTimePicker` or `MobileTimePicker` component).
|
|
19
|
-
*/
|
|
20
|
-
export type TimeFieldInPickerProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> = DefaultizedProps<UseTimeFieldProps<TDate, TEnableAccessibleFieldDOMStructure>, 'format' | 'timezone' | 'ampm' | keyof BaseTimeValidationProps> & BaseSingleInputFieldProps<TDate | null, TDate, FieldSection, false, TimeValidationError>;
|
|
21
16
|
export type UseTimeFieldComponentProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean, TChildProps extends {}> = Omit<TChildProps, keyof UseTimeFieldProps<TDate, TEnableAccessibleFieldDOMStructure>> & UseTimeFieldProps<TDate, TEnableAccessibleFieldDOMStructure>;
|
|
22
17
|
export type TimeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean = false> = UseTimeFieldComponentProps<TDate, TEnableAccessibleFieldDOMStructure, BuiltInFieldTextFieldProps<TEnableAccessibleFieldDOMStructure>> & {
|
|
23
18
|
/**
|
package/TimeField/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { TimeField } from './TimeField';
|
|
2
2
|
export { useTimeField as unstable_useTimeField } from './useTimeField';
|
|
3
|
-
export type { UseTimeFieldProps, UseTimeFieldComponentProps, TimeFieldProps,
|
|
3
|
+
export type { UseTimeFieldProps, UseTimeFieldComponentProps, TimeFieldProps, } from './TimeField.types';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { UseTimeFieldProps } from './TimeField.types';
|
|
2
2
|
import { PickerValidDate } from '../models';
|
|
3
|
-
export declare const useTimeField: <TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean, TAllProps extends UseTimeFieldProps<TDate, TEnableAccessibleFieldDOMStructure>>(inProps: TAllProps) => import("../internals
|
|
3
|
+
export declare const useTimeField: <TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean, TAllProps extends UseTimeFieldProps<TDate, TEnableAccessibleFieldDOMStructure>>(inProps: TAllProps) => import("../internals").UseFieldResponse<TEnableAccessibleFieldDOMStructure, Omit<TAllProps & Omit<UseTimeFieldProps<TDate, TEnableAccessibleFieldDOMStructure>, keyof import("../internals/hooks/defaultizedFieldProps").UseDefaultizedTimeFieldBaseProps> & Required<Pick<UseTimeFieldProps<TDate, TEnableAccessibleFieldDOMStructure>, keyof import("../internals/hooks/defaultizedFieldProps").UseDefaultizedTimeFieldBaseProps>>, "disabled" | "format" | "onChange" | "onError" | "defaultValue" | "value" | "readOnly" | "ampm" | "timezone" | "referenceDate" | "formatDensity" | "shouldRespectLeadingZeros" | "selectedSections" | "onSelectedSectionsChange" | "unstableFieldRef" | "enableAccessibleFieldDOMStructure" | keyof import("../internals").BaseTimeValidationProps | keyof import("../internals").TimeValidationProps<any> | "dateSeparator">>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { DesktopTimePickerProps, DesktopTimePickerSlots, DesktopTimePickerSlotProps } from '../DesktopTimePicker';
|
|
2
2
|
import { TimeViewWithMeridiem } from '../internals/models';
|
|
3
|
+
import { DefaultizedProps } from '../internals/models/helpers';
|
|
4
|
+
import { BaseTimeValidationProps } from '../internals/models/validation';
|
|
3
5
|
import { MobileTimePickerProps, MobileTimePickerSlots, MobileTimePickerSlotProps } from '../MobileTimePicker';
|
|
4
|
-
import { PickerValidDate } from '../models';
|
|
6
|
+
import { BaseSingleInputFieldProps, FieldSection, PickerValidDate, TimeValidationError } from '../models';
|
|
7
|
+
import { UseTimeFieldProps } from '../TimeField';
|
|
5
8
|
export interface TimePickerSlots<TDate extends PickerValidDate> extends DesktopTimePickerSlots<TDate>, MobileTimePickerSlots<TDate, TimeViewWithMeridiem> {
|
|
6
9
|
}
|
|
7
10
|
export interface TimePickerSlotProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends DesktopTimePickerSlotProps<TDate, TEnableAccessibleFieldDOMStructure>, MobileTimePickerSlotProps<TDate, TimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure> {
|
|
@@ -24,3 +27,8 @@ export interface TimePickerProps<TDate extends PickerValidDate, TEnableAccessibl
|
|
|
24
27
|
*/
|
|
25
28
|
slotProps?: TimePickerSlotProps<TDate, TEnableAccessibleFieldDOMStructure>;
|
|
26
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Props the field can receive when used inside a time picker.
|
|
32
|
+
* (`TimePicker`, `DesktopTimePicker` or `MobileTimePicker` component).
|
|
33
|
+
*/
|
|
34
|
+
export type TimePickerFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean = false> = DefaultizedProps<UseTimeFieldProps<TDate, TEnableAccessibleFieldDOMStructure>, 'format' | 'timezone' | 'ampm' | keyof BaseTimeValidationProps> & BaseSingleInputFieldProps<TDate | null, TDate, FieldSection, false, TimeValidationError>;
|
package/TimePicker/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { TimePicker } from './TimePicker';
|
|
2
|
-
export type { TimePickerProps, TimePickerSlots, TimePickerSlotProps } from './TimePicker.types';
|
|
2
|
+
export type { TimePickerProps, TimePickerSlots, TimePickerSlotProps, TimePickerFieldProps, } from './TimePicker.types';
|
|
3
3
|
export { TimePickerToolbar } from './TimePickerToolbar';
|
|
4
4
|
export type { TimePickerToolbarProps } from './TimePickerToolbar';
|
|
5
5
|
export { timePickerToolbarClasses } from './timePickerToolbarClasses';
|
|
@@ -179,7 +179,7 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
179
179
|
setFocusedYear(prevFocusedYear => selectedYear !== null && prevFocusedYear !== selectedYear ? selectedYear : prevFocusedYear);
|
|
180
180
|
}, [selectedYear]);
|
|
181
181
|
const verticalDirection = yearsOrder !== 'desc' ? yearsPerRow * 1 : yearsPerRow * -1;
|
|
182
|
-
const horizontalDirection = isRtl || yearsOrder === 'desc' ? -1 : 1;
|
|
182
|
+
const horizontalDirection = isRtl && yearsOrder === 'asc' || !isRtl && yearsOrder === 'desc' ? -1 : 1;
|
|
183
183
|
const handleKeyDown = useEventCallback((event, year) => {
|
|
184
184
|
switch (event.key) {
|
|
185
185
|
case 'ArrowUp':
|
package/hooks/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export { useClearableField } from './useClearableField';
|
|
|
2
2
|
export type { ExportedUseClearableFieldProps, UseClearableFieldSlots, UseClearableFieldSlotProps, UseClearableFieldResponse, } from './useClearableField';
|
|
3
3
|
export { usePickersTranslations } from './usePickersTranslations';
|
|
4
4
|
export { useSplitFieldProps } from './useSplitFieldProps';
|
|
5
|
+
export { useParsedFormat } from './useParsedFormat';
|
|
6
|
+
export { usePickersContext } from './usePickersContext';
|
package/hooks/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { useClearableField } from "./useClearableField.js";
|
|
2
2
|
export { usePickersTranslations } from "./usePickersTranslations.js";
|
|
3
|
-
export { useSplitFieldProps } from "./useSplitFieldProps.js";
|
|
3
|
+
export { useSplitFieldProps } from "./useSplitFieldProps.js";
|
|
4
|
+
export { useParsedFormat } from "./useParsedFormat.js";
|
|
5
|
+
export { usePickersContext } from "./usePickersContext.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PickerValidDate } from '../models';
|
|
2
|
+
import type { UseFieldInternalProps } from '../internals/hooks/useField';
|
|
3
|
+
interface UseParsedFormatParameters extends Pick<UseFieldInternalProps<any, any, any, any, any>, 'format' | 'formatDensity' | 'shouldRespectLeadingZeros'> {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Returns the parsed format to be rendered in the field when there is no value or in other parts of the Picker.
|
|
7
|
+
* This format is localized (e.g: `AAAA` for the year with the French locale) and cannot be parsed by your date library.
|
|
8
|
+
* @param {object} The parameters needed to build the placeholder.
|
|
9
|
+
* @param {string} params.format Format of the date to use.
|
|
10
|
+
* @param {'dense' | 'spacious'} params.formatDensity Density of the format (setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character).
|
|
11
|
+
* @param {boolean} params.shouldRespectLeadingZeros If `true`, the format will respect the leading zeroes, if `false`, the format will always add leading zeroes.
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare const useParsedFormat: <TDate extends PickerValidDate>(parameters: UseParsedFormatParameters) => string;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
5
|
+
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
6
|
+
import { buildSectionsFromFormat } from "../internals/hooks/useField/buildSectionsFromFormat.js";
|
|
7
|
+
import { getLocalizedDigits } from "../internals/hooks/useField/useField.utils.js";
|
|
8
|
+
import { usePickersTranslations } from "./usePickersTranslations.js";
|
|
9
|
+
/**
|
|
10
|
+
* Returns the parsed format to be rendered in the field when there is no value or in other parts of the Picker.
|
|
11
|
+
* This format is localized (e.g: `AAAA` for the year with the French locale) and cannot be parsed by your date library.
|
|
12
|
+
* @param {object} The parameters needed to build the placeholder.
|
|
13
|
+
* @param {string} params.format Format of the date to use.
|
|
14
|
+
* @param {'dense' | 'spacious'} params.formatDensity Density of the format (setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character).
|
|
15
|
+
* @param {boolean} params.shouldRespectLeadingZeros If `true`, the format will respect the leading zeroes, if `false`, the format will always add leading zeroes.
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export const useParsedFormat = parameters => {
|
|
19
|
+
const {
|
|
20
|
+
format,
|
|
21
|
+
formatDensity = 'dense',
|
|
22
|
+
shouldRespectLeadingZeros = false
|
|
23
|
+
} = parameters;
|
|
24
|
+
const utils = useUtils();
|
|
25
|
+
const isRtl = useRtl();
|
|
26
|
+
const translations = usePickersTranslations();
|
|
27
|
+
const localizedDigits = React.useMemo(() => getLocalizedDigits(utils), [utils]);
|
|
28
|
+
return React.useMemo(() => {
|
|
29
|
+
const sections = buildSectionsFromFormat({
|
|
30
|
+
utils,
|
|
31
|
+
format,
|
|
32
|
+
formatDensity,
|
|
33
|
+
isRtl,
|
|
34
|
+
shouldRespectLeadingZeros,
|
|
35
|
+
localeText: translations,
|
|
36
|
+
localizedDigits,
|
|
37
|
+
date: null,
|
|
38
|
+
// TODO v9: Make sure we still don't reverse in `buildSectionsFromFormat` when using `useParsedFormat`.
|
|
39
|
+
enableAccessibleFieldDOMStructure: false
|
|
40
|
+
});
|
|
41
|
+
return sections.map(section => `${section.startSeparator}${section.placeholder}${section.endSeparator}`).join('');
|
|
42
|
+
}, [utils, isRtl, translations, localizedDigits, format, formatDensity, shouldRespectLeadingZeros]);
|
|
43
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { PickersContext } from "../internals/components/PickersProvider.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns the context passed by the picker that wraps the current component.
|
|
8
|
+
*/
|
|
9
|
+
export const usePickersContext = () => {
|
|
10
|
+
const value = React.useContext(PickersContext);
|
|
11
|
+
if (value == null) {
|
|
12
|
+
throw new Error(['MUI X: The `usePickersContext` can only be called in fields that are used as a slot of a picker component'].join('\n'));
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
};
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PickerViewRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material
|
|
1
|
+
export declare const PickerViewRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PickerValidDate } from '../../models';
|
|
3
|
+
import { PickersInputLocaleText } from '../../locales';
|
|
4
|
+
export declare const PickersContext: React.Context<PickersContextValue | null>;
|
|
5
|
+
/**
|
|
6
|
+
* Provides the context for the various parts of a picker component:
|
|
7
|
+
* - contextValue: the context for the picker sub-components.
|
|
8
|
+
* - localizationProvider: the translations passed through the props and through a parent LocalizationProvider.
|
|
9
|
+
*
|
|
10
|
+
* @ignore - do not document.
|
|
11
|
+
*/
|
|
12
|
+
export declare function PickersProvider<TDate extends PickerValidDate>(props: PickersFieldProviderProps<TDate>): React.JSX.Element;
|
|
13
|
+
interface PickersFieldProviderProps<TDate extends PickerValidDate> {
|
|
14
|
+
contextValue: PickersContextValue;
|
|
15
|
+
localeText: PickersInputLocaleText<TDate> | undefined;
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export interface PickersContextValue {
|
|
19
|
+
/**
|
|
20
|
+
* Open the picker.
|
|
21
|
+
* @param {React.UIEvent} event The DOM event that triggered the change.
|
|
22
|
+
*/
|
|
23
|
+
onOpen: (event: React.UIEvent) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Close the picker.
|
|
26
|
+
* @param {React.UIEvent} event The DOM event that triggered the change.
|
|
27
|
+
*/
|
|
28
|
+
onClose: (event: React.UIEvent) => void;
|
|
29
|
+
/**
|
|
30
|
+
* `true` if the picker is open, `false` otherwise.
|
|
31
|
+
*/
|
|
32
|
+
open: boolean;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { LocalizationProvider } from "../../LocalizationProvider/index.js";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export const PickersContext = /*#__PURE__*/React.createContext(null);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Provides the context for the various parts of a picker component:
|
|
8
|
+
* - contextValue: the context for the picker sub-components.
|
|
9
|
+
* - localizationProvider: the translations passed through the props and through a parent LocalizationProvider.
|
|
10
|
+
*
|
|
11
|
+
* @ignore - do not document.
|
|
12
|
+
*/
|
|
13
|
+
export function PickersProvider(props) {
|
|
14
|
+
const {
|
|
15
|
+
contextValue,
|
|
16
|
+
localeText,
|
|
17
|
+
children
|
|
18
|
+
} = props;
|
|
19
|
+
return /*#__PURE__*/_jsx(PickersContext.Provider, {
|
|
20
|
+
value: contextValue,
|
|
21
|
+
children: /*#__PURE__*/_jsx(LocalizationProvider, {
|
|
22
|
+
localeText: localeText,
|
|
23
|
+
children: children
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -46,7 +46,7 @@ export const PickersToolbarButton = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
46
46
|
return /*#__PURE__*/_jsx(PickersToolbarButtonRoot, _extends({
|
|
47
47
|
variant: "text",
|
|
48
48
|
ref: ref,
|
|
49
|
-
className: clsx(
|
|
49
|
+
className: clsx(classes.root, className)
|
|
50
50
|
}, width ? {
|
|
51
51
|
sx: {
|
|
52
52
|
width
|
|
@@ -46,7 +46,7 @@ export const PickersToolbarText = /*#__PURE__*/React.forwardRef(function Pickers
|
|
|
46
46
|
const classes = useUtilityClasses(props);
|
|
47
47
|
return /*#__PURE__*/_jsx(PickersToolbarTextRoot, _extends({
|
|
48
48
|
ref: ref,
|
|
49
|
-
className: clsx(
|
|
49
|
+
className: clsx(classes.root, className),
|
|
50
50
|
component: "span"
|
|
51
51
|
}, other, {
|
|
52
52
|
children: value
|
|
@@ -11,15 +11,16 @@ import useForkRef from '@mui/utils/useForkRef';
|
|
|
11
11
|
import useId from '@mui/utils/useId';
|
|
12
12
|
import { PickersPopper } from "../../components/PickersPopper.js";
|
|
13
13
|
import { usePicker } from "../usePicker/index.js";
|
|
14
|
-
import { LocalizationProvider } from "../../../LocalizationProvider/index.js";
|
|
15
14
|
import { PickersLayout } from "../../../PickersLayout/index.js";
|
|
16
|
-
import {
|
|
15
|
+
import { PickersProvider } from "../../components/PickersProvider.js";
|
|
16
|
+
|
|
17
17
|
/**
|
|
18
18
|
* Hook managing all the single-date desktop pickers:
|
|
19
19
|
* - DesktopDatePicker
|
|
20
20
|
* - DesktopDateTimePicker
|
|
21
21
|
* - DesktopTimePicker
|
|
22
22
|
*/
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
24
|
export const useDesktopPicker = _ref => {
|
|
24
25
|
let {
|
|
25
26
|
props,
|
|
@@ -57,7 +58,8 @@ export const useDesktopPicker = _ref => {
|
|
|
57
58
|
layoutProps,
|
|
58
59
|
renderCurrentView,
|
|
59
60
|
shouldRestoreFocus,
|
|
60
|
-
fieldProps: pickerFieldProps
|
|
61
|
+
fieldProps: pickerFieldProps,
|
|
62
|
+
contextValue
|
|
61
63
|
} = usePicker(_extends({}, pickerParams, {
|
|
62
64
|
props,
|
|
63
65
|
fieldRef,
|
|
@@ -161,7 +163,8 @@ export const useDesktopPicker = _ref => {
|
|
|
161
163
|
}, innerSlotProps?.popper)
|
|
162
164
|
});
|
|
163
165
|
const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
|
|
164
|
-
const renderPicker = () => /*#__PURE__*/_jsxs(
|
|
166
|
+
const renderPicker = () => /*#__PURE__*/_jsxs(PickersProvider, {
|
|
167
|
+
contextValue: contextValue,
|
|
165
168
|
localeText: localeText,
|
|
166
169
|
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
|
|
167
170
|
slots: slotsForField,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { FieldSection, MuiPickersAdapter,
|
|
1
|
+
import { FieldSection, MuiPickersAdapter, PickerValidDate } from '../../../models';
|
|
2
2
|
import { PickersLocaleText } from '../../../locales';
|
|
3
3
|
interface BuildSectionsFromFormatParams<TDate extends PickerValidDate> {
|
|
4
4
|
utils: MuiPickersAdapter<TDate>;
|
|
5
5
|
format: string;
|
|
6
6
|
formatDensity: 'dense' | 'spacious';
|
|
7
7
|
isRtl: boolean;
|
|
8
|
-
timezone: PickersTimezone;
|
|
9
8
|
shouldRespectLeadingZeros: boolean;
|
|
10
9
|
localeText: PickersLocaleText<TDate>;
|
|
11
10
|
localizedDigits: string[];
|
|
@@ -38,12 +38,12 @@ const getEscapedPartsFromFormat = ({
|
|
|
38
38
|
}
|
|
39
39
|
return escapedParts;
|
|
40
40
|
};
|
|
41
|
-
const getSectionPlaceholder = (utils,
|
|
41
|
+
const getSectionPlaceholder = (utils, localeText, sectionConfig, sectionFormat) => {
|
|
42
42
|
switch (sectionConfig.type) {
|
|
43
43
|
case 'year':
|
|
44
44
|
{
|
|
45
45
|
return localeText.fieldYearPlaceholder({
|
|
46
|
-
digitAmount: utils.formatByString(utils.date(undefined,
|
|
46
|
+
digitAmount: utils.formatByString(utils.date(undefined, 'default'), sectionFormat).length,
|
|
47
47
|
format: sectionFormat
|
|
48
48
|
});
|
|
49
49
|
}
|
|
@@ -99,7 +99,6 @@ const getSectionPlaceholder = (utils, timezone, localeText, sectionConfig, secti
|
|
|
99
99
|
};
|
|
100
100
|
const createSection = ({
|
|
101
101
|
utils,
|
|
102
|
-
timezone,
|
|
103
102
|
date,
|
|
104
103
|
shouldRespectLeadingZeros,
|
|
105
104
|
localeText,
|
|
@@ -112,7 +111,7 @@ const createSection = ({
|
|
|
112
111
|
throw new Error('MUI X: Should not call `commitToken` with an empty token');
|
|
113
112
|
}
|
|
114
113
|
const sectionConfig = getDateSectionConfigFromFormatToken(utils, token);
|
|
115
|
-
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils,
|
|
114
|
+
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, sectionConfig.contentType, sectionConfig.type, token);
|
|
116
115
|
const hasLeadingZerosInInput = shouldRespectLeadingZeros ? hasLeadingZerosInFormat : sectionConfig.contentType === 'digit';
|
|
117
116
|
const isValidDate = date != null && utils.isValid(date);
|
|
118
117
|
let sectionValue = isValidDate ? utils.formatByString(date, token) : '';
|
|
@@ -134,7 +133,7 @@ const createSection = ({
|
|
|
134
133
|
format: token,
|
|
135
134
|
maxLength,
|
|
136
135
|
value: sectionValue,
|
|
137
|
-
placeholder: getSectionPlaceholder(utils,
|
|
136
|
+
placeholder: getSectionPlaceholder(utils, localeText, sectionConfig, token),
|
|
138
137
|
hasLeadingZerosInFormat,
|
|
139
138
|
hasLeadingZerosInInput,
|
|
140
139
|
startSeparator,
|
|
@@ -3,7 +3,7 @@ import { FieldSectionType, FieldValueType, FieldSection, MuiPickersAdapter, Fiel
|
|
|
3
3
|
export declare const getDateSectionConfigFromFormatToken: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate>, formatToken: string) => Pick<FieldSection, "type" | "contentType"> & {
|
|
4
4
|
maxLength: number | undefined;
|
|
5
5
|
};
|
|
6
|
-
export declare const getDaysInWeekStr: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate>,
|
|
6
|
+
export declare const getDaysInWeekStr: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate>, format: string) => string[];
|
|
7
7
|
export declare const getLetterEditingOptions: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate>, timezone: PickersTimezone, sectionType: FieldSectionType, format: string) => string[];
|
|
8
8
|
export declare const FORMAT_SECONDS_NO_LEADING_ZEROS = "s";
|
|
9
9
|
export declare const getLocalizedDigits: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate>) => string[];
|
|
@@ -22,7 +22,7 @@ export declare const adjustSectionValue: <TDate extends PickerValidDate, TSectio
|
|
|
22
22
|
}) => string;
|
|
23
23
|
export declare const getSectionVisibleValue: (section: FieldSection, target: "input-rtl" | "input-ltr" | "non-input", localizedDigits: string[]) => string;
|
|
24
24
|
export declare const changeSectionValueFormat: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate>, valueStr: string, currentFormat: string, newFormat: string) => string;
|
|
25
|
-
export declare const doesSectionFormatHaveLeadingZeros: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate>,
|
|
25
|
+
export declare const doesSectionFormatHaveLeadingZeros: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate>, contentType: FieldSectionContentType, sectionType: FieldSectionType, format: string) => boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Some date libraries like `dayjs` don't support parsing from date with escaped characters.
|
|
28
28
|
* To make sure that the parsing works, we are building a format and a date without any separator.
|
|
@@ -32,7 +32,7 @@ export declare const createDateStrForV7HiddenInputFromSections: (sections: Field
|
|
|
32
32
|
export declare const createDateStrForV6InputFromSections: (sections: FieldSection[], localizedDigits: string[], isRtl: boolean) => string;
|
|
33
33
|
export declare const getSectionsBoundaries: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate>, localizedDigits: string[], timezone: PickersTimezone) => FieldSectionsValueBoundaries<TDate>;
|
|
34
34
|
export declare const validateSections: <TSection extends FieldSection>(sections: TSection[], valueType: FieldValueType) => void;
|
|
35
|
-
export declare const mergeDateIntoReferenceDate: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate>,
|
|
35
|
+
export declare const mergeDateIntoReferenceDate: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate>, dateToTransferFrom: TDate, sections: FieldSection[], referenceDate: TDate, shouldLimitToEditedSections: boolean) => TDate;
|
|
36
36
|
export declare const isAndroid: () => boolean;
|
|
37
37
|
export declare const getSectionOrder: (sections: FieldSection[], shouldApplyRTL: boolean) => SectionOrdering;
|
|
38
38
|
export declare const parseSelectedSections: (selectedSections: FieldSelectedSections, sections: FieldSection[]) => FieldParsedSelectedSections;
|