@mui/x-date-pickers 7.4.0 → 7.5.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/AdapterDateFns/AdapterDateFns.d.ts +5 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +1 -5
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +4 -2
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +3 -20
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +14 -227
- package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts +3 -20
- package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +17 -230
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +5 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -1
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +2 -6
- package/CHANGELOG.md +93 -0
- package/DateCalendar/DateCalendar.js +5 -4
- package/PickersLayout/usePickerLayout.js +6 -7
- package/index.js +1 -1
- package/internals/components/PickersModalDialog.d.ts +2 -2
- package/internals/demo/DemoContainer.js +1 -1
- package/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +4 -2
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +14 -227
- package/modern/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +17 -230
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -1
- package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +2 -6
- package/modern/DateCalendar/DateCalendar.js +5 -4
- package/modern/PickersLayout/usePickerLayout.js +6 -7
- package/modern/index.js +1 -1
- package/modern/internals/demo/DemoContainer.js +1 -1
- package/modern/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +4 -2
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +14 -227
- package/node/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +17 -230
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +2 -6
- package/node/DateCalendar/DateCalendar.js +5 -4
- package/node/PickersLayout/usePickerLayout.js +6 -7
- package/node/index.js +1 -1
- package/node/internals/demo/DemoContainer.js +1 -1
- package/node/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/package.json +2 -2
|
@@ -163,14 +163,10 @@ export class AdapterMomentJalaali extends AdapterMoment {
|
|
|
163
163
|
return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
|
|
164
164
|
};
|
|
165
165
|
this.isSameYear = (value, comparing) => {
|
|
166
|
-
|
|
167
|
-
// @ts-ignore
|
|
168
|
-
return value.clone().isSame(comparing, 'jYear');
|
|
166
|
+
return value.jYear() === comparing.jYear();
|
|
169
167
|
};
|
|
170
168
|
this.isSameMonth = (value, comparing) => {
|
|
171
|
-
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
return value.clone().isSame(comparing, 'jMonth');
|
|
169
|
+
return value.jYear() === comparing.jYear() && value.jMonth() === comparing.jMonth();
|
|
174
170
|
};
|
|
175
171
|
this.isAfterYear = (value, comparing) => {
|
|
176
172
|
return value.jYear() > comparing.jYear();
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,77 @@
|
|
|
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
|
+
## v7.5.0
|
|
7
|
+
|
|
8
|
+
_May 17, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🎁 Add support for checkbox selection on the Tree View components
|
|
13
|
+
- 🌍 Improve Norwegian (nb-NO) and Spanish (es-ES) locales on the Data Grid
|
|
14
|
+
- 🐞 Bugfixes
|
|
15
|
+
- 📚 Documentation improvements
|
|
16
|
+
|
|
17
|
+
### Data Grid
|
|
18
|
+
|
|
19
|
+
#### `@mui/x-data-grid@7.5.0`
|
|
20
|
+
|
|
21
|
+
- [DataGrid] Fix `rowModesModel` controlled prop (#13056) @Janpot
|
|
22
|
+
- [DataGrid] Reduce bundle size with error messages (#12992) @oliviertassinari
|
|
23
|
+
- [l10n] Improve Norwegian (nb-NO) locale (#13106) @oliverlaidma
|
|
24
|
+
- [l10n] Improve Spanish (es-ES) locale (#13133) @Jucabel
|
|
25
|
+
|
|
26
|
+
#### `@mui/x-data-grid-pro@7.5.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
27
|
+
|
|
28
|
+
Same changes as in `@mui/x-data-grid@7.5.0`.
|
|
29
|
+
|
|
30
|
+
#### `@mui/x-data-grid-premium@7.5.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
31
|
+
|
|
32
|
+
Same changes as in `@mui/x-data-grid-pro@7.5.0`.
|
|
33
|
+
|
|
34
|
+
### Date and Time Pickers
|
|
35
|
+
|
|
36
|
+
#### `@mui/x-date-pickers@7.5.0`
|
|
37
|
+
|
|
38
|
+
- [fields] Allow empty `textField` slot placeholder value (#13148) @arthurbalduini
|
|
39
|
+
- [pickers] Fix `AdapterMomentJalaali` regression (#13144) @LukasTy
|
|
40
|
+
- [pickers] Fix field focusing when switching to view without a renderer (#13112) @LukasTy
|
|
41
|
+
- [pickers] Reuse `AdapterDateFnsBase` in Jalali adapters (#13075) @LukasTy
|
|
42
|
+
|
|
43
|
+
#### `@mui/x-date-pickers-pro@7.5.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
44
|
+
|
|
45
|
+
Same changes as in `@mui/x-date-pickers@7.5.0`.
|
|
46
|
+
|
|
47
|
+
### Charts
|
|
48
|
+
|
|
49
|
+
#### `@mui/x-charts@7.5.0`
|
|
50
|
+
|
|
51
|
+
- [charts] Tooltip with `trigger=axis` now follow touch on mobile (#13043) @wzdorowa
|
|
52
|
+
- [charts] Allow `series.label` property to receive a function with the "location" it is going to be displayed on (#12830) @JCQuintas
|
|
53
|
+
- [charts] Improve TypeScript performance (#13137) @alexfauquette
|
|
54
|
+
- [charts] Fix area order when overlapping (#13121) @alexfauquette
|
|
55
|
+
- [charts] Improve `useSlotProps` types (#13141) @alexfauquette
|
|
56
|
+
- [charts] Fix using the theme's font in the Overlay (#13107) @alexfauquette
|
|
57
|
+
|
|
58
|
+
### Tree View
|
|
59
|
+
|
|
60
|
+
#### `@mui/x-tree-view@7.5.0`
|
|
61
|
+
|
|
62
|
+
- [TreeView] Add support for checkbox selection (#11452) @flaviendelangle
|
|
63
|
+
- [TreeView] Remove unused code (#12917) @flaviendelangle
|
|
64
|
+
|
|
65
|
+
### Docs
|
|
66
|
+
|
|
67
|
+
- [docs] Document missing Charts API's (#12875) @alexfauquette
|
|
68
|
+
|
|
69
|
+
### Core
|
|
70
|
+
|
|
71
|
+
- [core] Avoid root level `@mui/x-date-pickers` imports (#13120) @LukasTy
|
|
72
|
+
- [core] Refactor ESLint config to disallow root level imports (#13130) @LukasTy
|
|
73
|
+
- [core] Simplify Danger's config (#13062) @oliviertassinari
|
|
74
|
+
- [core] Shift aliasing from babel to webpack (#13051) @Janpot
|
|
75
|
+
- [core] Reuse the `SectionTitle` component in the doc (#13139) @alexfauquette
|
|
76
|
+
|
|
6
77
|
## 7.4.0
|
|
7
78
|
|
|
8
79
|
_May 10, 2024_
|
|
@@ -3346,6 +3417,28 @@ Here is an example of the renaming for the `<ChartsTooltip />` component.
|
|
|
3346
3417
|
- [core] Update release instructions as per v7 configuration (#10962) @MBilalShafi
|
|
3347
3418
|
- [license] Correctly throw errors (#10924) @oliviertassinari
|
|
3348
3419
|
|
|
3420
|
+
## 6.19.12
|
|
3421
|
+
|
|
3422
|
+
_May 17, 2024_
|
|
3423
|
+
|
|
3424
|
+
We'd like to offer a big thanks to the 2 contributors who made this release possible. Here are some highlights ✨:
|
|
3425
|
+
|
|
3426
|
+
- 🐞 Bugfixes
|
|
3427
|
+
|
|
3428
|
+
### Date Pickers
|
|
3429
|
+
|
|
3430
|
+
#### `@mui/x-date-pickers@6.19.12`
|
|
3431
|
+
|
|
3432
|
+
- [pickers] Fix `AdapterMomentJalaali` regression (#13150) @LukasTy
|
|
3433
|
+
|
|
3434
|
+
#### `@mui/x-date-pickers-pro@6.19.12` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
3435
|
+
|
|
3436
|
+
Same changes as in `@mui/x-date-pickers@6.19.12`.
|
|
3437
|
+
|
|
3438
|
+
### Docs
|
|
3439
|
+
|
|
3440
|
+
- [docs] Use MUI X v6 in Codesandbox and Stackblitz demos (#12838) @cherniavskii
|
|
3441
|
+
|
|
3349
3442
|
## 6.19.11
|
|
3350
3443
|
|
|
3351
3444
|
_Apr 18, 2024_
|
|
@@ -198,9 +198,7 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
198
198
|
disableFuture,
|
|
199
199
|
reduceAnimations,
|
|
200
200
|
timezone,
|
|
201
|
-
labelId: gridLabelId
|
|
202
|
-
slots,
|
|
203
|
-
slotProps
|
|
201
|
+
labelId: gridLabelId
|
|
204
202
|
},
|
|
205
203
|
ownerState: props
|
|
206
204
|
});
|
|
@@ -294,7 +292,10 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
294
292
|
className: clsx(classes.root, className),
|
|
295
293
|
ownerState: ownerState
|
|
296
294
|
}, other, {
|
|
297
|
-
children: [/*#__PURE__*/_jsx(CalendarHeader, _extends({}, calendarHeaderProps
|
|
295
|
+
children: [/*#__PURE__*/_jsx(CalendarHeader, _extends({}, calendarHeaderProps, {
|
|
296
|
+
slots: slots,
|
|
297
|
+
slotProps: slotProps
|
|
298
|
+
})), /*#__PURE__*/_jsx(DateCalendarViewTransitionContainer, {
|
|
298
299
|
reduceAnimations: reduceAnimations,
|
|
299
300
|
className: classes.viewTransitionContainer,
|
|
300
301
|
transKey: view,
|
|
@@ -63,9 +63,9 @@ const usePickerLayout = props => {
|
|
|
63
63
|
onClear,
|
|
64
64
|
onCancel,
|
|
65
65
|
onSetToday,
|
|
66
|
-
actions: wrapperVariant === 'desktop' ? [] : ['cancel', 'accept']
|
|
67
|
-
className: classes.actionBar
|
|
66
|
+
actions: wrapperVariant === 'desktop' ? [] : ['cancel', 'accept']
|
|
68
67
|
},
|
|
68
|
+
className: classes.actionBar,
|
|
69
69
|
ownerState: _extends({}, props, {
|
|
70
70
|
wrapperVariant
|
|
71
71
|
})
|
|
@@ -86,9 +86,9 @@ const usePickerLayout = props => {
|
|
|
86
86
|
onViewChange,
|
|
87
87
|
views,
|
|
88
88
|
disabled,
|
|
89
|
-
readOnly
|
|
90
|
-
className: classes.toolbar
|
|
89
|
+
readOnly
|
|
91
90
|
},
|
|
91
|
+
className: classes.toolbar,
|
|
92
92
|
ownerState: _extends({}, props, {
|
|
93
93
|
wrapperVariant
|
|
94
94
|
})
|
|
@@ -117,14 +117,13 @@ const usePickerLayout = props => {
|
|
|
117
117
|
additionalProps: {
|
|
118
118
|
isValid,
|
|
119
119
|
isLandscape,
|
|
120
|
-
onChange: onSelectShortcut
|
|
121
|
-
className: classes.shortcuts
|
|
120
|
+
onChange: onSelectShortcut
|
|
122
121
|
},
|
|
122
|
+
className: classes.shortcuts,
|
|
123
123
|
ownerState: {
|
|
124
124
|
isValid,
|
|
125
125
|
isLandscape,
|
|
126
126
|
onChange: onSelectShortcut,
|
|
127
|
-
className: classes.shortcuts,
|
|
128
127
|
wrapperVariant
|
|
129
128
|
}
|
|
130
129
|
});
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DialogProps as MuiDialogProps } from '@mui/material/Dialog';
|
|
3
|
-
import { PaperProps as MuiPaperProps } from '@mui/material/Paper
|
|
4
|
-
import { TransitionProps as MuiTransitionProps } from '@mui/material/transitions
|
|
3
|
+
import { PaperProps as MuiPaperProps } from '@mui/material/Paper';
|
|
4
|
+
import { TransitionProps as MuiTransitionProps } from '@mui/material/transitions';
|
|
5
5
|
import { UsePickerValueActions } from '../hooks/usePicker/usePickerValue.types';
|
|
6
6
|
export interface PickersModalDialogSlots {
|
|
7
7
|
/**
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import Stack, { stackClasses } from '@mui/material/Stack';
|
|
4
4
|
import Typography from '@mui/material/Typography';
|
|
5
5
|
import { textFieldClasses } from '@mui/material/TextField';
|
|
6
|
-
import { pickersTextFieldClasses } from '
|
|
6
|
+
import { pickersTextFieldClasses } from '../../PickersTextField';
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
const getChildTypeFromChildName = childName => {
|
|
9
9
|
if (childName.match(/^([A-Za-z]+)Range(Calendar|Clock)$/)) {
|
|
@@ -278,7 +278,7 @@ export const useFieldV6TextField = params => {
|
|
|
278
278
|
});
|
|
279
279
|
});
|
|
280
280
|
const placeholder = React.useMemo(() => {
|
|
281
|
-
if (inPlaceholder) {
|
|
281
|
+
if (inPlaceholder !== undefined) {
|
|
282
282
|
return inPlaceholder;
|
|
283
283
|
}
|
|
284
284
|
return fieldValueManager.getV6InputValueFromSections(getSectionsFromValue(valueManager.emptyValue), localizedDigits, isRTL);
|
|
@@ -100,6 +100,7 @@ export const usePickerViews = ({
|
|
|
100
100
|
if (currentViewMode === 'field' && open) {
|
|
101
101
|
onClose();
|
|
102
102
|
setTimeout(() => {
|
|
103
|
+
fieldRef?.current?.setSelectedSections(view);
|
|
103
104
|
// focusing the input before the range selection is done
|
|
104
105
|
// calling it outside of timeout results in an inconsistent behavior between Safari And Chrome
|
|
105
106
|
fieldRef?.current?.focusField(view);
|
|
@@ -220,7 +220,7 @@ export class AdapterDateFnsBase {
|
|
|
220
220
|
constructor(props) {
|
|
221
221
|
this.isMUIAdapter = true;
|
|
222
222
|
this.isTimezoneCompatible = false;
|
|
223
|
-
this.lib =
|
|
223
|
+
this.lib = void 0;
|
|
224
224
|
this.locale = void 0;
|
|
225
225
|
this.formats = void 0;
|
|
226
226
|
this.formatTokenMap = formatTokenMap;
|
|
@@ -285,10 +285,12 @@ export class AdapterDateFnsBase {
|
|
|
285
285
|
const {
|
|
286
286
|
locale,
|
|
287
287
|
formats,
|
|
288
|
-
longFormatters
|
|
288
|
+
longFormatters,
|
|
289
|
+
lib
|
|
289
290
|
} = props;
|
|
290
291
|
this.locale = locale;
|
|
291
292
|
this.formats = _extends({}, defaultFormats, formats);
|
|
292
293
|
this.longFormatters = longFormatters;
|
|
294
|
+
this.lib = lib || 'date-fns';
|
|
293
295
|
}
|
|
294
296
|
}
|
|
@@ -45,171 +45,7 @@ import isWithinInterval from 'date-fns-jalali/isWithinInterval';
|
|
|
45
45
|
import defaultLocale from 'date-fns-jalali/locale/fa-IR';
|
|
46
46
|
// @ts-ignore
|
|
47
47
|
import longFormatters from 'date-fns-jalali/_lib/format/longFormatters';
|
|
48
|
-
|
|
49
|
-
// Year
|
|
50
|
-
y: {
|
|
51
|
-
sectionType: 'year',
|
|
52
|
-
contentType: 'digit',
|
|
53
|
-
maxLength: 4
|
|
54
|
-
},
|
|
55
|
-
yy: 'year',
|
|
56
|
-
yyy: {
|
|
57
|
-
sectionType: 'year',
|
|
58
|
-
contentType: 'digit',
|
|
59
|
-
maxLength: 4
|
|
60
|
-
},
|
|
61
|
-
yyyy: 'year',
|
|
62
|
-
// Month
|
|
63
|
-
M: {
|
|
64
|
-
sectionType: 'month',
|
|
65
|
-
contentType: 'digit',
|
|
66
|
-
maxLength: 2
|
|
67
|
-
},
|
|
68
|
-
MM: 'month',
|
|
69
|
-
MMMM: {
|
|
70
|
-
sectionType: 'month',
|
|
71
|
-
contentType: 'letter'
|
|
72
|
-
},
|
|
73
|
-
MMM: {
|
|
74
|
-
sectionType: 'month',
|
|
75
|
-
contentType: 'letter'
|
|
76
|
-
},
|
|
77
|
-
L: {
|
|
78
|
-
sectionType: 'month',
|
|
79
|
-
contentType: 'digit',
|
|
80
|
-
maxLength: 2
|
|
81
|
-
},
|
|
82
|
-
LL: 'month',
|
|
83
|
-
LLL: {
|
|
84
|
-
sectionType: 'month',
|
|
85
|
-
contentType: 'letter'
|
|
86
|
-
},
|
|
87
|
-
LLLL: {
|
|
88
|
-
sectionType: 'month',
|
|
89
|
-
contentType: 'letter'
|
|
90
|
-
},
|
|
91
|
-
// Day of the month
|
|
92
|
-
d: {
|
|
93
|
-
sectionType: 'day',
|
|
94
|
-
contentType: 'digit',
|
|
95
|
-
maxLength: 2
|
|
96
|
-
},
|
|
97
|
-
dd: 'day',
|
|
98
|
-
do: {
|
|
99
|
-
sectionType: 'day',
|
|
100
|
-
contentType: 'digit-with-letter'
|
|
101
|
-
},
|
|
102
|
-
// Day of the week
|
|
103
|
-
E: {
|
|
104
|
-
sectionType: 'weekDay',
|
|
105
|
-
contentType: 'letter'
|
|
106
|
-
},
|
|
107
|
-
EE: {
|
|
108
|
-
sectionType: 'weekDay',
|
|
109
|
-
contentType: 'letter'
|
|
110
|
-
},
|
|
111
|
-
EEE: {
|
|
112
|
-
sectionType: 'weekDay',
|
|
113
|
-
contentType: 'letter'
|
|
114
|
-
},
|
|
115
|
-
EEEE: {
|
|
116
|
-
sectionType: 'weekDay',
|
|
117
|
-
contentType: 'letter'
|
|
118
|
-
},
|
|
119
|
-
EEEEE: {
|
|
120
|
-
sectionType: 'weekDay',
|
|
121
|
-
contentType: 'letter'
|
|
122
|
-
},
|
|
123
|
-
i: {
|
|
124
|
-
sectionType: 'weekDay',
|
|
125
|
-
contentType: 'digit',
|
|
126
|
-
maxLength: 1
|
|
127
|
-
},
|
|
128
|
-
ii: 'weekDay',
|
|
129
|
-
iii: {
|
|
130
|
-
sectionType: 'weekDay',
|
|
131
|
-
contentType: 'letter'
|
|
132
|
-
},
|
|
133
|
-
iiii: {
|
|
134
|
-
sectionType: 'weekDay',
|
|
135
|
-
contentType: 'letter'
|
|
136
|
-
},
|
|
137
|
-
e: {
|
|
138
|
-
sectionType: 'weekDay',
|
|
139
|
-
contentType: 'digit',
|
|
140
|
-
maxLength: 1
|
|
141
|
-
},
|
|
142
|
-
ee: 'weekDay',
|
|
143
|
-
eee: {
|
|
144
|
-
sectionType: 'weekDay',
|
|
145
|
-
contentType: 'letter'
|
|
146
|
-
},
|
|
147
|
-
eeee: {
|
|
148
|
-
sectionType: 'weekDay',
|
|
149
|
-
contentType: 'letter'
|
|
150
|
-
},
|
|
151
|
-
eeeee: {
|
|
152
|
-
sectionType: 'weekDay',
|
|
153
|
-
contentType: 'letter'
|
|
154
|
-
},
|
|
155
|
-
eeeeee: {
|
|
156
|
-
sectionType: 'weekDay',
|
|
157
|
-
contentType: 'letter'
|
|
158
|
-
},
|
|
159
|
-
c: {
|
|
160
|
-
sectionType: 'weekDay',
|
|
161
|
-
contentType: 'digit',
|
|
162
|
-
maxLength: 1
|
|
163
|
-
},
|
|
164
|
-
cc: 'weekDay',
|
|
165
|
-
ccc: {
|
|
166
|
-
sectionType: 'weekDay',
|
|
167
|
-
contentType: 'letter'
|
|
168
|
-
},
|
|
169
|
-
cccc: {
|
|
170
|
-
sectionType: 'weekDay',
|
|
171
|
-
contentType: 'letter'
|
|
172
|
-
},
|
|
173
|
-
ccccc: {
|
|
174
|
-
sectionType: 'weekDay',
|
|
175
|
-
contentType: 'letter'
|
|
176
|
-
},
|
|
177
|
-
cccccc: {
|
|
178
|
-
sectionType: 'weekDay',
|
|
179
|
-
contentType: 'letter'
|
|
180
|
-
},
|
|
181
|
-
// Meridiem
|
|
182
|
-
a: 'meridiem',
|
|
183
|
-
aa: 'meridiem',
|
|
184
|
-
aaa: 'meridiem',
|
|
185
|
-
// Hours
|
|
186
|
-
H: {
|
|
187
|
-
sectionType: 'hours',
|
|
188
|
-
contentType: 'digit',
|
|
189
|
-
maxLength: 2
|
|
190
|
-
},
|
|
191
|
-
HH: 'hours',
|
|
192
|
-
h: {
|
|
193
|
-
sectionType: 'hours',
|
|
194
|
-
contentType: 'digit',
|
|
195
|
-
maxLength: 2
|
|
196
|
-
},
|
|
197
|
-
hh: 'hours',
|
|
198
|
-
// Minutes
|
|
199
|
-
m: {
|
|
200
|
-
sectionType: 'minutes',
|
|
201
|
-
contentType: 'digit',
|
|
202
|
-
maxLength: 2
|
|
203
|
-
},
|
|
204
|
-
mm: 'minutes',
|
|
205
|
-
// Seconds
|
|
206
|
-
s: {
|
|
207
|
-
sectionType: 'seconds',
|
|
208
|
-
contentType: 'digit',
|
|
209
|
-
maxLength: 2
|
|
210
|
-
},
|
|
211
|
-
ss: 'seconds'
|
|
212
|
-
};
|
|
48
|
+
import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
|
|
213
49
|
const defaultFormats = {
|
|
214
50
|
year: 'yyyy',
|
|
215
51
|
month: 'LLLL',
|
|
@@ -272,40 +108,22 @@ const NUMBER_SYMBOL_MAP = {
|
|
|
272
108
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
273
109
|
* SOFTWARE.
|
|
274
110
|
*/
|
|
275
|
-
export class AdapterDateFnsJalali {
|
|
111
|
+
export class AdapterDateFnsJalali extends AdapterDateFnsBase {
|
|
276
112
|
constructor({
|
|
277
|
-
locale
|
|
113
|
+
locale,
|
|
278
114
|
formats
|
|
279
115
|
} = {}) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (typeof value === 'undefined') {
|
|
292
|
-
return new Date();
|
|
293
|
-
}
|
|
294
|
-
if (value === null) {
|
|
295
|
-
return null;
|
|
296
|
-
}
|
|
297
|
-
return new Date(value);
|
|
298
|
-
};
|
|
299
|
-
this.getInvalidDate = () => new Date('Invalid Date');
|
|
300
|
-
this.getTimezone = () => {
|
|
301
|
-
return 'default';
|
|
302
|
-
};
|
|
303
|
-
this.setTimezone = value => {
|
|
304
|
-
return value;
|
|
305
|
-
};
|
|
306
|
-
this.toJsDate = value => {
|
|
307
|
-
return value;
|
|
308
|
-
};
|
|
116
|
+
if (typeof addDays !== 'function') {
|
|
117
|
+
throw new Error(['MUI: The `date-fns-jalali` package v3.x is not compatible with this adapter.', 'Please, install v2.x of the package or use the `AdapterDateFnsJalaliV3` instead.'].join('\n'));
|
|
118
|
+
}
|
|
119
|
+
super({
|
|
120
|
+
locale: locale ?? defaultLocale,
|
|
121
|
+
// some formats are different in jalali adapter,
|
|
122
|
+
// this ensures that `AdapterDateFnsBase` formats are overridden
|
|
123
|
+
formats: _extends({}, defaultFormats, formats),
|
|
124
|
+
longFormatters,
|
|
125
|
+
lib: 'date-fns-jalali'
|
|
126
|
+
});
|
|
309
127
|
this.parse = (value, format) => {
|
|
310
128
|
if (value === '') {
|
|
311
129
|
return null;
|
|
@@ -317,29 +135,6 @@ export class AdapterDateFnsJalali {
|
|
|
317
135
|
this.getCurrentLocaleCode = () => {
|
|
318
136
|
return this.locale?.code || 'fa-IR';
|
|
319
137
|
};
|
|
320
|
-
// Note: date-fns input types are more lenient than this adapter, so we need to expose our more
|
|
321
|
-
// strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
|
|
322
|
-
this.is12HourCycleInCurrentLocale = () => {
|
|
323
|
-
if (this.locale) {
|
|
324
|
-
return /a/.test(this.locale.formatLong.time());
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// By default, date-fns-jalali is using fa-IR locale with am/pm enabled
|
|
328
|
-
return true;
|
|
329
|
-
};
|
|
330
|
-
this.expandFormat = format => {
|
|
331
|
-
// @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
|
|
332
|
-
const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
|
|
333
|
-
const locale = this.locale ?? defaultLocale;
|
|
334
|
-
return format.match(longFormatRegexp).map(token => {
|
|
335
|
-
const firstCharacter = token[0];
|
|
336
|
-
if (firstCharacter === 'p' || firstCharacter === 'P') {
|
|
337
|
-
const longFormatter = longFormatters[firstCharacter];
|
|
338
|
-
return longFormatter(token, locale.formatLong, {});
|
|
339
|
-
}
|
|
340
|
-
return token;
|
|
341
|
-
}).join('');
|
|
342
|
-
};
|
|
343
138
|
this.isValid = value => {
|
|
344
139
|
if (value == null) {
|
|
345
140
|
return false;
|
|
@@ -527,13 +322,5 @@ export class AdapterDateFnsJalali {
|
|
|
527
322
|
}
|
|
528
323
|
return years;
|
|
529
324
|
};
|
|
530
|
-
if (typeof addDays !== 'function') {
|
|
531
|
-
throw new Error(['MUI: The `date-fns-jalali` package v3.x is not compatible with this adapter.', 'Please, install v2.x of the package or use the `AdapterDateFnsJalaliV3` instead.'].join('\n'));
|
|
532
|
-
}
|
|
533
|
-
this.locale = _locale;
|
|
534
|
-
this.formats = _extends({}, defaultFormats, formats);
|
|
535
|
-
}
|
|
536
|
-
getDayOfWeek(value) {
|
|
537
|
-
return value.getDay() + 1;
|
|
538
325
|
}
|
|
539
326
|
}
|