@mui/x-date-pickers 6.1.0 → 6.2.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/AdapterDayjs/AdapterDayjs.d.ts +114 -0
- package/AdapterDayjs/AdapterDayjs.js +387 -0
- package/AdapterDayjs/index.d.ts +1 -28
- package/AdapterDayjs/index.js +1 -102
- package/CHANGELOG.md +101 -1
- package/DateCalendar/DateCalendar.types.d.ts +1 -1
- package/DateCalendar/DayCalendar.d.ts +1 -1
- package/DateField/DateField.js +6 -0
- package/DateField/useDateField.js +3 -1
- package/DatePicker/DatePicker.js +6 -0
- package/DateTimeField/DateTimeField.js +6 -0
- package/DateTimeField/useDateTimeField.js +3 -1
- package/DateTimePicker/DateTimePicker.js +6 -0
- package/DateTimePicker/shared.js +3 -1
- package/DesktopDatePicker/DesktopDatePicker.js +7 -0
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
- package/DesktopTimePicker/DesktopTimePicker.js +7 -0
- package/LocalizationProvider/LocalizationProvider.d.ts +1 -1
- package/LocalizationProvider/LocalizationProvider.js +1 -1
- package/MobileDatePicker/MobileDatePicker.js +7 -0
- package/MobileDateTimePicker/MobileDateTimePicker.js +7 -0
- package/MobileTimePicker/MobileTimePicker.js +7 -0
- package/README.md +1 -0
- package/StaticDatePicker/StaticDatePicker.js +1 -0
- package/StaticDateTimePicker/StaticDateTimePicker.js +3 -2
- package/StaticTimePicker/StaticTimePicker.js +3 -2
- package/TimeClock/TimeClock.types.d.ts +1 -1
- package/TimeField/TimeField.js +6 -0
- package/TimeField/useTimeField.js +3 -1
- package/TimePicker/TimePicker.js +6 -0
- package/index.js +1 -1
- package/internals/components/PickersModalDialog.d.ts +1 -1
- package/internals/components/PickersPopper.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +15 -14
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
- package/internals/hooks/useField/useField.types.d.ts +7 -2
- package/internals/hooks/useField/useField.utils.d.ts +3 -3
- package/internals/hooks/useField/useField.utils.js +16 -4
- package/internals/hooks/useField/useFieldState.js +4 -3
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.js +12 -10
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/index.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.js +2 -0
- package/internals/hooks/usePicker/usePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.d.ts +4 -180
- package/internals/hooks/usePicker/usePickerValue.js +191 -159
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +235 -0
- package/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/internals/hooks/usePicker/usePickerViews.d.ts +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.js +10 -10
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/models/props/basePickerProps.d.ts +6 -0
- package/internals/utils/valueManagers.js +1 -1
- package/legacy/AdapterDayjs/AdapterDayjs.js +403 -0
- package/legacy/AdapterDayjs/index.js +1 -119
- package/legacy/DateField/DateField.js +6 -0
- package/legacy/DateField/useDateField.js +3 -1
- package/legacy/DatePicker/DatePicker.js +6 -0
- package/legacy/DateTimeField/DateTimeField.js +6 -0
- package/legacy/DateTimeField/useDateTimeField.js +3 -1
- package/legacy/DateTimePicker/DateTimePicker.js +6 -0
- package/legacy/DateTimePicker/shared.js +3 -1
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +7 -0
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +7 -0
- package/legacy/LocalizationProvider/LocalizationProvider.js +1 -1
- package/legacy/MobileDatePicker/MobileDatePicker.js +7 -0
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +7 -0
- package/legacy/MobileTimePicker/MobileTimePicker.js +7 -0
- package/legacy/StaticDatePicker/StaticDatePicker.js +1 -0
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +3 -2
- package/legacy/StaticTimePicker/StaticTimePicker.js +3 -2
- package/legacy/TimeField/TimeField.js +6 -0
- package/legacy/TimeField/useTimeField.js +3 -1
- package/legacy/TimePicker/TimePicker.js +6 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +10 -10
- package/legacy/internals/hooks/useField/useField.utils.js +24 -9
- package/legacy/internals/hooks/useField/useFieldState.js +6 -4
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +7 -6
- package/legacy/internals/hooks/usePicker/usePicker.js +2 -0
- package/legacy/internals/hooks/usePicker/usePickerValue.js +186 -159
- package/legacy/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/legacy/internals/hooks/useStaticPicker/useStaticPicker.js +7 -8
- package/legacy/internals/utils/valueManagers.js +2 -2
- package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +20 -0
- package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +1 -0
- package/legacy/tests/describeGregorianAdapter/index.js +1 -0
- package/legacy/tests/describeGregorianAdapter/testCalculations.js +273 -0
- package/legacy/tests/describeGregorianAdapter/testFormat.js +26 -0
- package/legacy/tests/describeGregorianAdapter/testLocalization.js +15 -0
- package/legacy/tests/describeValidation/describeValidation.js +2 -1
- package/legacy/tests/describeValidation/testMinutesViewValidation.js +201 -0
- package/legacy/tests/describeValue/testPickerActionBar.js +52 -3
- package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
- package/models/adapters.d.ts +21 -20
- package/models/fields.d.ts +1 -0
- package/modern/AdapterDayjs/AdapterDayjs.js +386 -0
- package/modern/AdapterDayjs/index.js +1 -101
- package/modern/DateField/DateField.js +6 -0
- package/modern/DateField/useDateField.js +3 -1
- package/modern/DatePicker/DatePicker.js +6 -0
- package/modern/DateTimeField/DateTimeField.js +6 -0
- package/modern/DateTimeField/useDateTimeField.js +3 -1
- package/modern/DateTimePicker/DateTimePicker.js +6 -0
- package/modern/DateTimePicker/shared.js +3 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +7 -0
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
- package/modern/DesktopTimePicker/DesktopTimePicker.js +7 -0
- package/modern/LocalizationProvider/LocalizationProvider.js +1 -1
- package/modern/MobileDatePicker/MobileDatePicker.js +7 -0
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +7 -0
- package/modern/MobileTimePicker/MobileTimePicker.js +7 -0
- package/modern/StaticDatePicker/StaticDatePicker.js +1 -0
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +3 -2
- package/modern/StaticTimePicker/StaticTimePicker.js +3 -2
- package/modern/TimeField/TimeField.js +6 -0
- package/modern/TimeField/useTimeField.js +3 -1
- package/modern/TimePicker/TimePicker.js +6 -0
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +15 -14
- package/modern/internals/hooks/useField/useField.utils.js +16 -4
- package/modern/internals/hooks/useField/useFieldState.js +4 -3
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +12 -10
- package/modern/internals/hooks/usePicker/usePicker.js +2 -0
- package/modern/internals/hooks/usePicker/usePickerValue.js +191 -159
- package/modern/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +10 -10
- package/modern/internals/utils/valueManagers.js +1 -1
- package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +20 -0
- package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +1 -0
- package/modern/tests/describeGregorianAdapter/index.js +1 -0
- package/modern/tests/describeGregorianAdapter/testCalculations.js +272 -0
- package/modern/tests/describeGregorianAdapter/testFormat.js +27 -0
- package/modern/tests/describeGregorianAdapter/testLocalization.js +16 -0
- package/modern/tests/describeValidation/describeValidation.js +2 -1
- package/modern/tests/describeValidation/testMinutesViewValidation.js +200 -0
- package/modern/tests/describeValue/testPickerActionBar.js +52 -3
- package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
- package/node/AdapterDayjs/AdapterDayjs.js +395 -0
- package/node/AdapterDayjs/index.js +6 -104
- package/node/DateField/DateField.js +6 -0
- package/node/DateField/useDateField.js +3 -1
- package/node/DatePicker/DatePicker.js +6 -0
- package/node/DateTimeField/DateTimeField.js +6 -0
- package/node/DateTimeField/useDateTimeField.js +3 -1
- package/node/DateTimePicker/DateTimePicker.js +6 -0
- package/node/DateTimePicker/shared.js +3 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +7 -0
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
- package/node/DesktopTimePicker/DesktopTimePicker.js +7 -0
- package/node/LocalizationProvider/LocalizationProvider.js +1 -1
- package/node/MobileDatePicker/MobileDatePicker.js +7 -0
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +7 -0
- package/node/MobileTimePicker/MobileTimePicker.js +7 -0
- package/node/StaticDatePicker/StaticDatePicker.js +1 -0
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +3 -2
- package/node/StaticTimePicker/StaticTimePicker.js +3 -2
- package/node/TimeField/TimeField.js +6 -0
- package/node/TimeField/useTimeField.js +3 -1
- package/node/TimePicker/TimePicker.js +6 -0
- package/node/index.js +1 -1
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +15 -14
- package/node/internals/hooks/useField/useField.utils.js +16 -4
- package/node/internals/hooks/useField/useFieldState.js +4 -3
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +12 -10
- package/node/internals/hooks/usePicker/usePicker.js +2 -0
- package/node/internals/hooks/usePicker/usePickerValue.js +191 -158
- package/node/internals/hooks/usePicker/usePickerValue.types.js +5 -0
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +10 -10
- package/node/internals/utils/valueManagers.js +1 -1
- package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +29 -0
- package/node/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +5 -0
- package/node/tests/describeGregorianAdapter/index.js +18 -0
- package/node/tests/describeGregorianAdapter/testCalculations.js +279 -0
- package/node/tests/describeGregorianAdapter/testFormat.js +34 -0
- package/node/tests/describeGregorianAdapter/testLocalization.js +23 -0
- package/node/tests/describeValidation/describeValidation.js +2 -1
- package/node/tests/describeValidation/testMinutesViewValidation.js +210 -0
- package/node/tests/describeValue/testPickerActionBar.js +52 -3
- package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
- package/package.json +9 -9
- package/tests/describeGregorianAdapter/describeGregorianAdapter.js +20 -0
- package/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +1 -0
- package/tests/describeGregorianAdapter/index.js +1 -0
- package/tests/describeGregorianAdapter/testCalculations.js +272 -0
- package/tests/describeGregorianAdapter/testFormat.js +27 -0
- package/tests/describeGregorianAdapter/testLocalization.js +16 -0
- package/tests/describeValidation/describeValidation.js +2 -1
- package/tests/describeValidation/testMinutesViewValidation.js +200 -0
- package/tests/describeValue/testPickerActionBar.js +52 -3
- package/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
|
@@ -7,6 +7,6 @@ import { DateOrTimeView } from '../../../models';
|
|
|
7
7
|
* - StaticDateTimePicker
|
|
8
8
|
* - StaticTimePicker
|
|
9
9
|
*/
|
|
10
|
-
export declare const useStaticPicker: <TDate, TView extends DateOrTimeView, TExternalProps extends UseStaticPickerProps<TDate, TView, any, TExternalProps>>({ props,
|
|
10
|
+
export declare const useStaticPicker: <TDate, TView extends DateOrTimeView, TExternalProps extends UseStaticPickerProps<TDate, TView, any, TExternalProps>>({ props, ref, ...pickerParams }: UseStaticPickerParams<TDate, TView, TExternalProps>) => {
|
|
11
11
|
renderPicker: () => JSX.Element;
|
|
12
12
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["props", "ref"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import clsx from 'clsx';
|
|
4
6
|
import { styled } from '@mui/material/styles';
|
|
@@ -21,13 +23,13 @@ const PickerStaticLayout = styled(PickersLayout)(({
|
|
|
21
23
|
* - StaticDateTimePicker
|
|
22
24
|
* - StaticTimePicker
|
|
23
25
|
*/
|
|
24
|
-
export const useStaticPicker =
|
|
25
|
-
props,
|
|
26
|
-
valueManager,
|
|
27
|
-
validator,
|
|
28
|
-
ref
|
|
29
|
-
}) => {
|
|
26
|
+
export const useStaticPicker = _ref => {
|
|
30
27
|
var _slots$layout;
|
|
28
|
+
let {
|
|
29
|
+
props,
|
|
30
|
+
ref
|
|
31
|
+
} = _ref,
|
|
32
|
+
pickerParams = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
31
33
|
const {
|
|
32
34
|
localeText,
|
|
33
35
|
slots,
|
|
@@ -40,14 +42,12 @@ export const useStaticPicker = ({
|
|
|
40
42
|
const {
|
|
41
43
|
layoutProps,
|
|
42
44
|
renderCurrentView
|
|
43
|
-
} = usePicker({
|
|
45
|
+
} = usePicker(_extends({}, pickerParams, {
|
|
44
46
|
props,
|
|
45
|
-
valueManager,
|
|
46
|
-
validator,
|
|
47
47
|
autoFocusView: autoFocus != null ? autoFocus : false,
|
|
48
48
|
additionalViewProps: {},
|
|
49
49
|
wrapperVariant: displayStaticWrapperAs
|
|
50
|
-
});
|
|
50
|
+
}));
|
|
51
51
|
const Layout = (_slots$layout = slots == null ? void 0 : slots.layout) != null ? _slots$layout : PickerStaticLayout;
|
|
52
52
|
const renderPicker = () => {
|
|
53
53
|
var _slotProps$layout, _slotProps$layout2, _slotProps$layout3;
|
|
@@ -50,7 +50,7 @@ export interface UseStaticPickerProps<TDate, TView extends DateOrTimeView, TErro
|
|
|
50
50
|
*/
|
|
51
51
|
slotProps?: UseStaticPickerSlotsComponentsProps<TDate, TView>;
|
|
52
52
|
}
|
|
53
|
-
export interface UseStaticPickerParams<TDate, TView extends DateOrTimeView, TExternalProps extends UseStaticPickerProps<TDate, TView, any, TExternalProps>> extends Pick<UsePickerParams<TDate | null, TDate, TView, FieldSection, TExternalProps, {}>, 'valueManager' | 'validator'> {
|
|
53
|
+
export interface UseStaticPickerParams<TDate, TView extends DateOrTimeView, TExternalProps extends UseStaticPickerProps<TDate, TView, any, TExternalProps>> extends Pick<UsePickerParams<TDate | null, TDate, TView, FieldSection, TExternalProps, {}>, 'valueManager' | 'valueType' | 'validator'> {
|
|
54
54
|
props: TExternalProps;
|
|
55
55
|
/**
|
|
56
56
|
* Ref to pass to the root element
|
package/internals/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export type { UseFieldInternalProps, UseFieldParams, UseFieldResponse, UseFieldF
|
|
|
27
27
|
export type { MobileOnlyPickerProps } from './hooks/useMobilePicker';
|
|
28
28
|
export { usePicker } from './hooks/usePicker';
|
|
29
29
|
export type { UsePickerResponse, UsePickerParams, UsePickerProps } from './hooks/usePicker';
|
|
30
|
-
export type { UsePickerValueNonStaticProps, PickerValueManager, PickerSelectionState, } from './hooks/usePicker/usePickerValue';
|
|
30
|
+
export type { UsePickerValueNonStaticProps, PickerValueManager, PickerSelectionState, } from './hooks/usePicker/usePickerValue.types';
|
|
31
31
|
export type { UsePickerViewsNonStaticProps, PickerViewRendererLookup, UsePickerViewsProps, } from './hooks/usePicker/usePickerViews';
|
|
32
32
|
export { useStaticPicker } from './hooks/useStaticPicker';
|
|
33
33
|
export type { StaticOnlyPickerProps, UseStaticPickerSlotsComponent, UseStaticPickerSlotsComponentsProps, } from './hooks/useStaticPicker';
|
|
@@ -39,6 +39,12 @@ export interface BaseNonStaticPickerProps {
|
|
|
39
39
|
* Defaults to localized format based on the used `views`.
|
|
40
40
|
*/
|
|
41
41
|
format?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Density of the format when rendered in the input.
|
|
44
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
45
|
+
* @default "dense"
|
|
46
|
+
*/
|
|
47
|
+
formatDensity?: 'dense' | 'spacious';
|
|
42
48
|
}
|
|
43
49
|
/**
|
|
44
50
|
* Props common to all non-range non-static pickers.
|
|
@@ -2,7 +2,7 @@ import { areDatesEqual, replaceInvalidDateByNull } from './date-utils';
|
|
|
2
2
|
import { addPositionPropertiesToSections, createDateStrForInputFromSections } from '../hooks/useField/useField.utils';
|
|
3
3
|
export const singleItemValueManager = {
|
|
4
4
|
emptyValue: null,
|
|
5
|
-
getTodayValue: utils => utils.date(),
|
|
5
|
+
getTodayValue: (utils, valueType) => valueType === 'date' ? utils.startOfDay(utils.date()) : utils.date(),
|
|
6
6
|
cleanValue: replaceInvalidDateByNull,
|
|
7
7
|
areValuesEqual: areDatesEqual,
|
|
8
8
|
isSameError: (a, b) => a === b,
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
+
/* eslint-disable class-methods-use-this */
|
|
6
|
+
import defaultDayjs from 'dayjs';
|
|
7
|
+
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
8
|
+
import customParseFormatPlugin from 'dayjs/plugin/customParseFormat';
|
|
9
|
+
import localizedFormatPlugin from 'dayjs/plugin/localizedFormat';
|
|
10
|
+
import isBetweenPlugin from 'dayjs/plugin/isBetween';
|
|
11
|
+
import { buildWarning } from '../internals/utils/warning';
|
|
12
|
+
defaultDayjs.extend(customParseFormatPlugin);
|
|
13
|
+
defaultDayjs.extend(localizedFormatPlugin);
|
|
14
|
+
defaultDayjs.extend(isBetweenPlugin);
|
|
15
|
+
var localeNotFoundWarning = buildWarning(['Your locale has not been found.', 'Either the locale key is not a supported one. Locales supported by dayjs are available here: https://github.com/iamkun/dayjs/tree/dev/src/locale', "Or you forget to import the locale with `require('dayjs/locale/{localeUsed}')`", 'fallback on English locale']);
|
|
16
|
+
var formatTokenMap = {
|
|
17
|
+
// Year
|
|
18
|
+
YY: 'year',
|
|
19
|
+
YYYY: 'year',
|
|
20
|
+
// Month
|
|
21
|
+
M: 'month',
|
|
22
|
+
MM: 'month',
|
|
23
|
+
MMM: {
|
|
24
|
+
sectionType: 'month',
|
|
25
|
+
contentType: 'letter'
|
|
26
|
+
},
|
|
27
|
+
MMMM: {
|
|
28
|
+
sectionType: 'month',
|
|
29
|
+
contentType: 'letter'
|
|
30
|
+
},
|
|
31
|
+
// Day of the month
|
|
32
|
+
D: 'day',
|
|
33
|
+
DD: 'day',
|
|
34
|
+
Do: 'day',
|
|
35
|
+
// Day of the week
|
|
36
|
+
d: 'weekDay',
|
|
37
|
+
dd: {
|
|
38
|
+
sectionType: 'weekDay',
|
|
39
|
+
contentType: 'letter'
|
|
40
|
+
},
|
|
41
|
+
ddd: {
|
|
42
|
+
sectionType: 'weekDay',
|
|
43
|
+
contentType: 'letter'
|
|
44
|
+
},
|
|
45
|
+
dddd: {
|
|
46
|
+
sectionType: 'weekDay',
|
|
47
|
+
contentType: 'letter'
|
|
48
|
+
},
|
|
49
|
+
// Meridiem
|
|
50
|
+
A: 'meridiem',
|
|
51
|
+
a: 'meridiem',
|
|
52
|
+
// Hours
|
|
53
|
+
H: 'hours',
|
|
54
|
+
HH: 'hours',
|
|
55
|
+
h: 'hours',
|
|
56
|
+
hh: 'hours',
|
|
57
|
+
// Minutes
|
|
58
|
+
m: 'minutes',
|
|
59
|
+
mm: 'minutes',
|
|
60
|
+
// Seconds
|
|
61
|
+
s: 'seconds',
|
|
62
|
+
ss: 'seconds'
|
|
63
|
+
};
|
|
64
|
+
var defaultFormats = {
|
|
65
|
+
normalDateWithWeekday: 'ddd, MMM D',
|
|
66
|
+
normalDate: 'D MMMM',
|
|
67
|
+
shortDate: 'MMM D',
|
|
68
|
+
monthAndDate: 'MMMM D',
|
|
69
|
+
dayOfMonth: 'D',
|
|
70
|
+
year: 'YYYY',
|
|
71
|
+
month: 'MMMM',
|
|
72
|
+
monthShort: 'MMM',
|
|
73
|
+
monthAndYear: 'MMMM YYYY',
|
|
74
|
+
weekday: 'dddd',
|
|
75
|
+
weekdayShort: 'ddd',
|
|
76
|
+
minutes: 'mm',
|
|
77
|
+
hours12h: 'hh',
|
|
78
|
+
hours24h: 'HH',
|
|
79
|
+
seconds: 'ss',
|
|
80
|
+
fullTime: 'LT',
|
|
81
|
+
fullTime12h: 'hh:mm A',
|
|
82
|
+
fullTime24h: 'HH:mm',
|
|
83
|
+
fullDate: 'll',
|
|
84
|
+
fullDateWithWeekday: 'dddd, LL',
|
|
85
|
+
fullDateTime: 'lll',
|
|
86
|
+
fullDateTime12h: 'll hh:mm A',
|
|
87
|
+
fullDateTime24h: 'll HH:mm',
|
|
88
|
+
keyboardDate: 'L',
|
|
89
|
+
keyboardDateTime: 'L LT',
|
|
90
|
+
keyboardDateTime12h: 'L hh:mm A',
|
|
91
|
+
keyboardDateTime24h: 'L HH:mm'
|
|
92
|
+
};
|
|
93
|
+
var withLocale = function withLocale(dayjs, locale) {
|
|
94
|
+
return !locale ? dayjs : function () {
|
|
95
|
+
return dayjs.apply(void 0, arguments).locale(locale);
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Based on `@date-io/dayjs`
|
|
101
|
+
*
|
|
102
|
+
* MIT License
|
|
103
|
+
*
|
|
104
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
105
|
+
*
|
|
106
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
107
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
108
|
+
* in the Software without restriction, including without limitation the rights
|
|
109
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
110
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
111
|
+
* furnished to do so, subject to the following conditions:
|
|
112
|
+
*
|
|
113
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
114
|
+
* copies or substantial portions of the Software.
|
|
115
|
+
*
|
|
116
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
117
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
118
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
119
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
120
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
121
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
122
|
+
* SOFTWARE.
|
|
123
|
+
*/
|
|
124
|
+
export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
125
|
+
var _this = this;
|
|
126
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
127
|
+
_locale = _ref.locale,
|
|
128
|
+
formats = _ref.formats,
|
|
129
|
+
instance = _ref.instance;
|
|
130
|
+
_classCallCheck(this, AdapterDayjs);
|
|
131
|
+
this.isMUIAdapter = true;
|
|
132
|
+
this.rawDayJsInstance = void 0;
|
|
133
|
+
this.lib = 'dayjs';
|
|
134
|
+
this.dayjs = void 0;
|
|
135
|
+
this.locale = void 0;
|
|
136
|
+
this.formats = void 0;
|
|
137
|
+
this.escapedCharacters = {
|
|
138
|
+
start: '[',
|
|
139
|
+
end: ']'
|
|
140
|
+
};
|
|
141
|
+
this.formatTokenMap = formatTokenMap;
|
|
142
|
+
this.getLocaleFormats = function () {
|
|
143
|
+
var _this$rawDayJsInstanc;
|
|
144
|
+
var locales = (_this$rawDayJsInstanc = _this.rawDayJsInstance.Ls) != null ? _this$rawDayJsInstanc : defaultDayjs.Ls;
|
|
145
|
+
var locale = _this.locale || 'en';
|
|
146
|
+
var localeObject = locales[locale];
|
|
147
|
+
if (localeObject === undefined) {
|
|
148
|
+
localeNotFoundWarning();
|
|
149
|
+
localeObject = locales.en;
|
|
150
|
+
}
|
|
151
|
+
return localeObject.formats;
|
|
152
|
+
};
|
|
153
|
+
this.date = function (value) {
|
|
154
|
+
if (value === null) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
return _this.dayjs(value);
|
|
158
|
+
};
|
|
159
|
+
this.toJsDate = function (value) {
|
|
160
|
+
return value.toDate();
|
|
161
|
+
};
|
|
162
|
+
this.parseISO = function (isoString) {
|
|
163
|
+
return _this.dayjs(isoString);
|
|
164
|
+
};
|
|
165
|
+
this.toISO = function (value) {
|
|
166
|
+
return value.toISOString();
|
|
167
|
+
};
|
|
168
|
+
this.parse = function (value, format) {
|
|
169
|
+
if (value === '') {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
return _this.dayjs(value, format, _this.locale, true);
|
|
173
|
+
};
|
|
174
|
+
this.getCurrentLocaleCode = function () {
|
|
175
|
+
return _this.locale || 'en';
|
|
176
|
+
};
|
|
177
|
+
this.is12HourCycleInCurrentLocale = function () {
|
|
178
|
+
/* istanbul ignore next */
|
|
179
|
+
return /A|a/.test(_this.getLocaleFormats().LT || '');
|
|
180
|
+
};
|
|
181
|
+
this.expandFormat = function (format) {
|
|
182
|
+
var localeFormats = _this.getLocaleFormats();
|
|
183
|
+
|
|
184
|
+
// @see https://github.com/iamkun/dayjs/blob/dev/src/plugin/localizedFormat/index.js
|
|
185
|
+
var t = function t(formatBis) {
|
|
186
|
+
return formatBis.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function (_, a, b) {
|
|
187
|
+
return a || b.slice(1);
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
return format.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, function (_, a, b) {
|
|
191
|
+
var B = b && b.toUpperCase();
|
|
192
|
+
return a || localeFormats[b] || t(localeFormats[B]);
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
this.getFormatHelperText = function (format) {
|
|
196
|
+
return _this.expandFormat(format).replace(/a/gi, '(a|p)m').toLocaleLowerCase();
|
|
197
|
+
};
|
|
198
|
+
this.isNull = function (date) {
|
|
199
|
+
return date === null;
|
|
200
|
+
};
|
|
201
|
+
this.isValid = function (value) {
|
|
202
|
+
return _this.dayjs(value).isValid();
|
|
203
|
+
};
|
|
204
|
+
this.format = function (date, formatKey) {
|
|
205
|
+
return _this.formatByString(date, _this.formats[formatKey]);
|
|
206
|
+
};
|
|
207
|
+
this.formatByString = function (date, formatString) {
|
|
208
|
+
return _this.dayjs(date).format(formatString);
|
|
209
|
+
};
|
|
210
|
+
this.formatNumber = function (numberToFormat) {
|
|
211
|
+
return numberToFormat;
|
|
212
|
+
};
|
|
213
|
+
this.getDiff = function (date, comparing, units) {
|
|
214
|
+
return date.diff(comparing, units);
|
|
215
|
+
};
|
|
216
|
+
this.isEqual = function (value, comparing) {
|
|
217
|
+
if (value === null && comparing === null) {
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
return _this.dayjs(value).isSame(comparing);
|
|
221
|
+
};
|
|
222
|
+
this.isSameYear = function (date, comparing) {
|
|
223
|
+
return date.isSame(comparing, 'year');
|
|
224
|
+
};
|
|
225
|
+
this.isSameMonth = function (date, comparing) {
|
|
226
|
+
return date.isSame(comparing, 'month');
|
|
227
|
+
};
|
|
228
|
+
this.isSameDay = function (date, comparing) {
|
|
229
|
+
return date.isSame(comparing, 'day');
|
|
230
|
+
};
|
|
231
|
+
this.isSameHour = function (date, comparing) {
|
|
232
|
+
return date.isSame(comparing, 'hour');
|
|
233
|
+
};
|
|
234
|
+
this.isAfter = function (date, value) {
|
|
235
|
+
return date.isAfter(value);
|
|
236
|
+
};
|
|
237
|
+
this.isAfterYear = function (date, value) {
|
|
238
|
+
return date.isAfter(value, 'year');
|
|
239
|
+
};
|
|
240
|
+
this.isAfterDay = function (date, value) {
|
|
241
|
+
return date.isAfter(value, 'day');
|
|
242
|
+
};
|
|
243
|
+
this.isBefore = function (date, value) {
|
|
244
|
+
return date.isBefore(value);
|
|
245
|
+
};
|
|
246
|
+
this.isBeforeYear = function (date, value) {
|
|
247
|
+
return date.isBefore(value, 'year');
|
|
248
|
+
};
|
|
249
|
+
this.isBeforeDay = function (date, value) {
|
|
250
|
+
return date.isBefore(value, 'day');
|
|
251
|
+
};
|
|
252
|
+
this.isWithinRange = function (date, _ref2) {
|
|
253
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
254
|
+
start = _ref3[0],
|
|
255
|
+
end = _ref3[1];
|
|
256
|
+
return date.isBetween(start, end, null, '[]');
|
|
257
|
+
};
|
|
258
|
+
this.startOfYear = function (date) {
|
|
259
|
+
return date.startOf('year');
|
|
260
|
+
};
|
|
261
|
+
this.startOfMonth = function (date) {
|
|
262
|
+
return date.startOf('month');
|
|
263
|
+
};
|
|
264
|
+
this.endOfYear = function (date) {
|
|
265
|
+
return date.endOf('year');
|
|
266
|
+
};
|
|
267
|
+
this.startOfWeek = function (date) {
|
|
268
|
+
return date.startOf('week');
|
|
269
|
+
};
|
|
270
|
+
this.startOfDay = function (date) {
|
|
271
|
+
return date.startOf('day');
|
|
272
|
+
};
|
|
273
|
+
this.endOfMonth = function (date) {
|
|
274
|
+
return date.endOf('month');
|
|
275
|
+
};
|
|
276
|
+
this.endOfWeek = function (date) {
|
|
277
|
+
return date.endOf('week');
|
|
278
|
+
};
|
|
279
|
+
this.endOfDay = function (date) {
|
|
280
|
+
return date.endOf('day');
|
|
281
|
+
};
|
|
282
|
+
this.addYears = function (date, count) {
|
|
283
|
+
return count < 0 ? date.subtract(Math.abs(count), 'year') : date.add(count, 'year');
|
|
284
|
+
};
|
|
285
|
+
this.addMonths = function (date, count) {
|
|
286
|
+
return count < 0 ? date.subtract(Math.abs(count), 'month') : date.add(count, 'month');
|
|
287
|
+
};
|
|
288
|
+
this.addWeeks = function (date, count) {
|
|
289
|
+
return count < 0 ? date.subtract(Math.abs(count), 'week') : date.add(count, 'week');
|
|
290
|
+
};
|
|
291
|
+
this.addDays = function (date, count) {
|
|
292
|
+
return count < 0 ? date.subtract(Math.abs(count), 'day') : date.add(count, 'day');
|
|
293
|
+
};
|
|
294
|
+
this.addHours = function (date, count) {
|
|
295
|
+
return count < 0 ? date.subtract(Math.abs(count), 'hour') : date.add(count, 'hour');
|
|
296
|
+
};
|
|
297
|
+
this.addMinutes = function (date, count) {
|
|
298
|
+
return count < 0 ? date.subtract(Math.abs(count), 'minute') : date.add(count, 'minute');
|
|
299
|
+
};
|
|
300
|
+
this.addSeconds = function (date, count) {
|
|
301
|
+
return count < 0 ? date.subtract(Math.abs(count), 'second') : date.add(count, 'second');
|
|
302
|
+
};
|
|
303
|
+
this.getYear = function (date) {
|
|
304
|
+
return date.year();
|
|
305
|
+
};
|
|
306
|
+
this.getMonth = function (date) {
|
|
307
|
+
return date.month();
|
|
308
|
+
};
|
|
309
|
+
this.getDate = function (date) {
|
|
310
|
+
return date.date();
|
|
311
|
+
};
|
|
312
|
+
this.getHours = function (date) {
|
|
313
|
+
return date.hour();
|
|
314
|
+
};
|
|
315
|
+
this.getMinutes = function (date) {
|
|
316
|
+
return date.minute();
|
|
317
|
+
};
|
|
318
|
+
this.getSeconds = function (date) {
|
|
319
|
+
return date.second();
|
|
320
|
+
};
|
|
321
|
+
this.setYear = function (date, year) {
|
|
322
|
+
return date.set('year', year);
|
|
323
|
+
};
|
|
324
|
+
this.setMonth = function (date, count) {
|
|
325
|
+
return date.set('month', count);
|
|
326
|
+
};
|
|
327
|
+
this.setDate = function (date, count) {
|
|
328
|
+
return date.set('date', count);
|
|
329
|
+
};
|
|
330
|
+
this.setHours = function (date, count) {
|
|
331
|
+
return date.set('hour', count);
|
|
332
|
+
};
|
|
333
|
+
this.setMinutes = function (date, count) {
|
|
334
|
+
return date.set('minute', count);
|
|
335
|
+
};
|
|
336
|
+
this.setSeconds = function (date, count) {
|
|
337
|
+
return date.set('second', count);
|
|
338
|
+
};
|
|
339
|
+
this.getDaysInMonth = function (date) {
|
|
340
|
+
return date.daysInMonth();
|
|
341
|
+
};
|
|
342
|
+
this.getNextMonth = function (date) {
|
|
343
|
+
return date.add(1, 'month');
|
|
344
|
+
};
|
|
345
|
+
this.getPreviousMonth = function (date) {
|
|
346
|
+
return date.subtract(1, 'month');
|
|
347
|
+
};
|
|
348
|
+
this.getMonthArray = function (date) {
|
|
349
|
+
var firstMonth = date.startOf('year');
|
|
350
|
+
var monthArray = [firstMonth];
|
|
351
|
+
while (monthArray.length < 12) {
|
|
352
|
+
var prevMonth = monthArray[monthArray.length - 1];
|
|
353
|
+
monthArray.push(_this.getNextMonth(prevMonth));
|
|
354
|
+
}
|
|
355
|
+
return monthArray;
|
|
356
|
+
};
|
|
357
|
+
this.mergeDateAndTime = function (date, time) {
|
|
358
|
+
return date.hour(time.hour()).minute(time.minute()).second(time.second());
|
|
359
|
+
};
|
|
360
|
+
this.getWeekdays = function () {
|
|
361
|
+
var start = _this.dayjs().startOf('week');
|
|
362
|
+
return [0, 1, 2, 3, 4, 5, 6].map(function (diff) {
|
|
363
|
+
return _this.formatByString(start.add(diff, 'day'), 'dd');
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
this.getWeekArray = function (date) {
|
|
367
|
+
var start = _this.dayjs(date).startOf('month').startOf('week');
|
|
368
|
+
var end = _this.dayjs(date).endOf('month').endOf('week');
|
|
369
|
+
var count = 0;
|
|
370
|
+
var current = start;
|
|
371
|
+
var nestedWeeks = [];
|
|
372
|
+
while (current.isBefore(end)) {
|
|
373
|
+
var weekNumber = Math.floor(count / 7);
|
|
374
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
375
|
+
nestedWeeks[weekNumber].push(current);
|
|
376
|
+
current = current.add(1, 'day');
|
|
377
|
+
count += 1;
|
|
378
|
+
}
|
|
379
|
+
return nestedWeeks;
|
|
380
|
+
};
|
|
381
|
+
this.getWeekNumber = function (date) {
|
|
382
|
+
return date.week();
|
|
383
|
+
};
|
|
384
|
+
this.getYearRange = function (start, end) {
|
|
385
|
+
var startDate = _this.dayjs(start).startOf('year');
|
|
386
|
+
var endDate = _this.dayjs(end).endOf('year');
|
|
387
|
+
var years = [];
|
|
388
|
+
var current = startDate;
|
|
389
|
+
while (current.isBefore(endDate)) {
|
|
390
|
+
years.push(current);
|
|
391
|
+
current = current.add(1, 'year');
|
|
392
|
+
}
|
|
393
|
+
return years;
|
|
394
|
+
};
|
|
395
|
+
this.getMeridiemText = function (ampm) {
|
|
396
|
+
return ampm === 'am' ? 'AM' : 'PM';
|
|
397
|
+
};
|
|
398
|
+
this.rawDayJsInstance = instance || defaultDayjs;
|
|
399
|
+
this.dayjs = withLocale(this.rawDayJsInstance, _locale);
|
|
400
|
+
this.locale = _locale;
|
|
401
|
+
this.formats = _extends({}, defaultFormats, formats);
|
|
402
|
+
defaultDayjs.extend(weekOfYear);
|
|
403
|
+
});
|
|
@@ -1,119 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
7
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
8
|
-
/* eslint-disable class-methods-use-this */
|
|
9
|
-
import defaultDayjs from 'dayjs';
|
|
10
|
-
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
11
|
-
import BaseAdapterDayjs from '@date-io/dayjs';
|
|
12
|
-
import { buildWarning } from '../internals/utils/warning';
|
|
13
|
-
var localeNotFoundWarning = buildWarning(['Your locale has not been found.', 'Either the locale key is not a supported one. Locales supported by dayjs are available here: https://github.com/iamkun/dayjs/tree/dev/src/locale', "Or you forget to import the locale with `require('dayjs/locale/{localeUsed}')`", 'fallback on English locale']);
|
|
14
|
-
var formatTokenMap = {
|
|
15
|
-
// Year
|
|
16
|
-
YY: 'year',
|
|
17
|
-
YYYY: 'year',
|
|
18
|
-
// Month
|
|
19
|
-
M: 'month',
|
|
20
|
-
MM: 'month',
|
|
21
|
-
MMM: {
|
|
22
|
-
sectionType: 'month',
|
|
23
|
-
contentType: 'letter'
|
|
24
|
-
},
|
|
25
|
-
MMMM: {
|
|
26
|
-
sectionType: 'month',
|
|
27
|
-
contentType: 'letter'
|
|
28
|
-
},
|
|
29
|
-
// Day of the month
|
|
30
|
-
D: 'day',
|
|
31
|
-
DD: 'day',
|
|
32
|
-
Do: 'day',
|
|
33
|
-
// Day of the week
|
|
34
|
-
d: 'weekDay',
|
|
35
|
-
dd: {
|
|
36
|
-
sectionType: 'weekDay',
|
|
37
|
-
contentType: 'letter'
|
|
38
|
-
},
|
|
39
|
-
ddd: {
|
|
40
|
-
sectionType: 'weekDay',
|
|
41
|
-
contentType: 'letter'
|
|
42
|
-
},
|
|
43
|
-
dddd: {
|
|
44
|
-
sectionType: 'weekDay',
|
|
45
|
-
contentType: 'letter'
|
|
46
|
-
},
|
|
47
|
-
// Meridiem
|
|
48
|
-
A: 'meridiem',
|
|
49
|
-
a: 'meridiem',
|
|
50
|
-
// Hours
|
|
51
|
-
H: 'hours',
|
|
52
|
-
HH: 'hours',
|
|
53
|
-
h: 'hours',
|
|
54
|
-
hh: 'hours',
|
|
55
|
-
// Minutes
|
|
56
|
-
m: 'minutes',
|
|
57
|
-
mm: 'minutes',
|
|
58
|
-
// Seconds
|
|
59
|
-
s: 'seconds',
|
|
60
|
-
ss: 'seconds'
|
|
61
|
-
};
|
|
62
|
-
export var AdapterDayjs = /*#__PURE__*/function (_BaseAdapterDayjs) {
|
|
63
|
-
_inherits(AdapterDayjs, _BaseAdapterDayjs);
|
|
64
|
-
var _super = _createSuper(AdapterDayjs);
|
|
65
|
-
function AdapterDayjs(options) {
|
|
66
|
-
var _this;
|
|
67
|
-
_classCallCheck(this, AdapterDayjs);
|
|
68
|
-
_this = _super.call(this, options);
|
|
69
|
-
_this.isMUIAdapter = true;
|
|
70
|
-
_this.formatTokenMap = formatTokenMap;
|
|
71
|
-
_this.escapedCharacters = {
|
|
72
|
-
start: '[',
|
|
73
|
-
end: ']'
|
|
74
|
-
};
|
|
75
|
-
_this.getLocaleFormats = function () {
|
|
76
|
-
var _this$rawDayJsInstanc;
|
|
77
|
-
var locales = (_this$rawDayJsInstanc = _this.rawDayJsInstance.Ls) != null ? _this$rawDayJsInstanc : defaultDayjs.Ls;
|
|
78
|
-
var locale = _this.locale || 'en';
|
|
79
|
-
var localeObject = locales[locale];
|
|
80
|
-
if (localeObject === undefined) {
|
|
81
|
-
localeNotFoundWarning();
|
|
82
|
-
localeObject = locales.en;
|
|
83
|
-
}
|
|
84
|
-
return localeObject.formats;
|
|
85
|
-
};
|
|
86
|
-
_this.is12HourCycleInCurrentLocale = function () {
|
|
87
|
-
/* istanbul ignore next */
|
|
88
|
-
return /A|a/.test(_this.getLocaleFormats().LT || '');
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* The current getFormatHelperText method uses an outdated format parsing logic.
|
|
92
|
-
* We should use this one in the future to support all localized formats.
|
|
93
|
-
*/
|
|
94
|
-
_this.expandFormat = function (format) {
|
|
95
|
-
var localeFormats = _this.getLocaleFormats();
|
|
96
|
-
|
|
97
|
-
// @see https://github.com/iamkun/dayjs/blob/dev/src/plugin/localizedFormat/index.js
|
|
98
|
-
var t = function t(formatBis) {
|
|
99
|
-
return formatBis.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function (_, a, b) {
|
|
100
|
-
return a || b.slice(1);
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
return format.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, function (_, a, b) {
|
|
104
|
-
var B = b && b.toUpperCase();
|
|
105
|
-
return a || localeFormats[b] || t(localeFormats[B]);
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
// Redefined here just to show how it can be written using expandFormat
|
|
109
|
-
_this.getFormatHelperText = function (format) {
|
|
110
|
-
return _this.expandFormat(format).replace(/a/gi, '(a|p)m').toLocaleLowerCase();
|
|
111
|
-
};
|
|
112
|
-
_this.getWeekNumber = function (date) {
|
|
113
|
-
return date.week();
|
|
114
|
-
};
|
|
115
|
-
defaultDayjs.extend(weekOfYear);
|
|
116
|
-
return _this;
|
|
117
|
-
}
|
|
118
|
-
return _createClass(AdapterDayjs);
|
|
119
|
-
}(BaseAdapterDayjs);
|
|
1
|
+
export { AdapterDayjs } from './AdapterDayjs';
|
|
@@ -114,6 +114,12 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
|
|
|
114
114
|
* Format of the date when rendered in the input(s).
|
|
115
115
|
*/
|
|
116
116
|
format: PropTypes.string,
|
|
117
|
+
/**
|
|
118
|
+
* Density of the format when rendered in the input.
|
|
119
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
120
|
+
* @default "dense"
|
|
121
|
+
*/
|
|
122
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
117
123
|
/**
|
|
118
124
|
* Props applied to the [`FormHelperText`](/material-ui/api/form-helper-text/) element.
|
|
119
125
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
3
|
+
var _excluded = ["value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
4
4
|
import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
|
|
5
5
|
import { useField } from '../internals/hooks/useField';
|
|
6
6
|
import { validateDate } from '../internals/hooks/validation/useDateValidation';
|
|
@@ -25,6 +25,7 @@ export var useDateField = function useDateField(_ref) {
|
|
|
25
25
|
value = _useDefaultizedDateFi.value,
|
|
26
26
|
defaultValue = _useDefaultizedDateFi.defaultValue,
|
|
27
27
|
format = _useDefaultizedDateFi.format,
|
|
28
|
+
formatDensity = _useDefaultizedDateFi.formatDensity,
|
|
28
29
|
onChange = _useDefaultizedDateFi.onChange,
|
|
29
30
|
readOnly = _useDefaultizedDateFi.readOnly,
|
|
30
31
|
onError = _useDefaultizedDateFi.onError,
|
|
@@ -46,6 +47,7 @@ export var useDateField = function useDateField(_ref) {
|
|
|
46
47
|
value: value,
|
|
47
48
|
defaultValue: defaultValue,
|
|
48
49
|
format: format,
|
|
50
|
+
formatDensity: formatDensity,
|
|
49
51
|
onChange: onChange,
|
|
50
52
|
readOnly: readOnly,
|
|
51
53
|
onError: onError,
|
|
@@ -126,6 +126,12 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
|
|
|
126
126
|
* Defaults to localized format based on the used `views`.
|
|
127
127
|
*/
|
|
128
128
|
format: PropTypes.string,
|
|
129
|
+
/**
|
|
130
|
+
* Density of the format when rendered in the input.
|
|
131
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
132
|
+
* @default "dense"
|
|
133
|
+
*/
|
|
134
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
129
135
|
/**
|
|
130
136
|
* Pass a ref to the `input` element.
|
|
131
137
|
*/
|
|
@@ -124,6 +124,12 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
124
124
|
* Format of the date when rendered in the input(s).
|
|
125
125
|
*/
|
|
126
126
|
format: PropTypes.string,
|
|
127
|
+
/**
|
|
128
|
+
* Density of the format when rendered in the input.
|
|
129
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
130
|
+
* @default "dense"
|
|
131
|
+
*/
|
|
132
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
127
133
|
/**
|
|
128
134
|
* Props applied to the [`FormHelperText`](/material-ui/api/form-helper-text/) element.
|
|
129
135
|
*/
|