@mui/x-date-pickers 7.3.2 → 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 -224
- package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts +87 -0
- package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +332 -0
- package/AdapterDateFnsJalaliV3/index.d.ts +1 -0
- package/AdapterDateFnsJalaliV3/index.js +1 -0
- package/AdapterDateFnsJalaliV3/package.json +6 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +5 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -1
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +2 -6
- package/CHANGELOG.md +160 -2
- package/DateCalendar/DateCalendar.js +5 -4
- package/PickersLayout/usePickerLayout.js +6 -7
- package/PickersShortcuts/PickersShortcuts.d.ts +5 -0
- package/PickersShortcuts/PickersShortcuts.js +4 -3
- package/index.js +1 -1
- package/internals/components/PickersModalDialog.d.ts +2 -2
- package/internals/demo/DemoContainer.js +1 -1
- package/internals/hooks/useField/useField.js +0 -5
- package/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/internals/hooks/useField/useFieldV7TextField.js +5 -0
- package/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +4 -2
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +14 -224
- package/modern/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +332 -0
- package/modern/AdapterDateFnsJalaliV3/index.js +1 -0
- 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/PickersShortcuts/PickersShortcuts.js +4 -3
- package/modern/index.js +1 -1
- package/modern/internals/demo/DemoContainer.js +1 -1
- package/modern/internals/hooks/useField/useField.js +0 -5
- package/modern/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/modern/internals/hooks/useField/useFieldV7TextField.js +5 -0
- package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +4 -2
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +14 -224
- package/node/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +341 -0
- package/node/AdapterDateFnsJalaliV3/index.js +12 -0
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +2 -6
- package/node/DateCalendar/DateCalendar.js +5 -4
- package/node/PickersLayout/usePickerLayout.js +6 -7
- package/node/PickersShortcuts/PickersShortcuts.js +4 -3
- package/node/index.js +1 -1
- package/node/internals/demo/DemoContainer.js +1 -1
- package/node/internals/hooks/useField/useField.js +0 -5
- package/node/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/node/internals/hooks/useField/useFieldV7TextField.js +5 -0
- package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/package.json +4 -4
|
@@ -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();
|
|
@@ -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
|
});
|
|
@@ -37,13 +37,13 @@ function PickersShortcuts(props) {
|
|
|
37
37
|
const newValue = getValue({
|
|
38
38
|
isValid
|
|
39
39
|
});
|
|
40
|
-
return {
|
|
40
|
+
return _extends({}, item, {
|
|
41
41
|
label: item.label,
|
|
42
42
|
onClick: () => {
|
|
43
43
|
onChange(newValue, changeImportance, item);
|
|
44
44
|
},
|
|
45
45
|
disabled: !isValid(newValue)
|
|
46
|
-
};
|
|
46
|
+
});
|
|
47
47
|
});
|
|
48
48
|
return /*#__PURE__*/_jsx(List, _extends({
|
|
49
49
|
dense: true,
|
|
@@ -56,7 +56,7 @@ function PickersShortcuts(props) {
|
|
|
56
56
|
children: resolvedItems.map(item => {
|
|
57
57
|
return /*#__PURE__*/_jsx(ListItem, {
|
|
58
58
|
children: /*#__PURE__*/_jsx(Chip, _extends({}, item))
|
|
59
|
-
}, item.label);
|
|
59
|
+
}, item.id ?? item.label);
|
|
60
60
|
})
|
|
61
61
|
}));
|
|
62
62
|
}
|
|
@@ -95,6 +95,7 @@ process.env.NODE_ENV !== "production" ? PickersShortcuts.propTypes = {
|
|
|
95
95
|
*/
|
|
96
96
|
items: PropTypes.arrayOf(PropTypes.shape({
|
|
97
97
|
getValue: PropTypes.func.isRequired,
|
|
98
|
+
id: PropTypes.string,
|
|
98
99
|
label: PropTypes.string.isRequired
|
|
99
100
|
})),
|
|
100
101
|
onChange: PropTypes.func.isRequired,
|
package/modern/index.js
CHANGED
|
@@ -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);
|
|
@@ -282,6 +282,11 @@ export const useFieldV7TextField = params => {
|
|
|
282
282
|
revertDOMSectionChange(sectionIndex);
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
|
+
const inputType = event.nativeEvent.inputType;
|
|
286
|
+
if (inputType === 'insertParagraph' || inputType === 'insertLineBreak') {
|
|
287
|
+
revertDOMSectionChange(sectionIndex);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
285
290
|
resetCharacterQuery();
|
|
286
291
|
clearActiveSection();
|
|
287
292
|
return;
|
|
@@ -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);
|
|
@@ -227,7 +227,7 @@ class AdapterDateFnsBase {
|
|
|
227
227
|
constructor(props) {
|
|
228
228
|
this.isMUIAdapter = true;
|
|
229
229
|
this.isTimezoneCompatible = false;
|
|
230
|
-
this.lib =
|
|
230
|
+
this.lib = void 0;
|
|
231
231
|
this.locale = void 0;
|
|
232
232
|
this.formats = void 0;
|
|
233
233
|
this.formatTokenMap = formatTokenMap;
|
|
@@ -292,11 +292,13 @@ class AdapterDateFnsBase {
|
|
|
292
292
|
const {
|
|
293
293
|
locale,
|
|
294
294
|
formats,
|
|
295
|
-
longFormatters
|
|
295
|
+
longFormatters,
|
|
296
|
+
lib
|
|
296
297
|
} = props;
|
|
297
298
|
this.locale = locale;
|
|
298
299
|
this.formats = (0, _extends2.default)({}, defaultFormats, formats);
|
|
299
300
|
this.longFormatters = longFormatters;
|
|
301
|
+
this.lib = lib || 'date-fns';
|
|
300
302
|
}
|
|
301
303
|
}
|
|
302
304
|
exports.AdapterDateFnsBase = AdapterDateFnsBase;
|
|
@@ -50,175 +50,11 @@ var _startOfYear = _interopRequireDefault(require("date-fns-jalali/startOfYear")
|
|
|
50
50
|
var _isWithinInterval = _interopRequireDefault(require("date-fns-jalali/isWithinInterval"));
|
|
51
51
|
var _faIR = _interopRequireDefault(require("date-fns-jalali/locale/fa-IR"));
|
|
52
52
|
var _longFormatters = _interopRequireDefault(require("date-fns-jalali/_lib/format/longFormatters"));
|
|
53
|
+
var _AdapterDateFnsBase = require("../AdapterDateFnsBase");
|
|
53
54
|
/* eslint-disable class-methods-use-this */
|
|
54
55
|
|
|
55
56
|
// @ts-ignore
|
|
56
57
|
|
|
57
|
-
const formatTokenMap = {
|
|
58
|
-
// Year
|
|
59
|
-
y: {
|
|
60
|
-
sectionType: 'year',
|
|
61
|
-
contentType: 'digit',
|
|
62
|
-
maxLength: 4
|
|
63
|
-
},
|
|
64
|
-
yy: 'year',
|
|
65
|
-
yyy: {
|
|
66
|
-
sectionType: 'year',
|
|
67
|
-
contentType: 'digit',
|
|
68
|
-
maxLength: 4
|
|
69
|
-
},
|
|
70
|
-
yyyy: 'year',
|
|
71
|
-
// Month
|
|
72
|
-
M: {
|
|
73
|
-
sectionType: 'month',
|
|
74
|
-
contentType: 'digit',
|
|
75
|
-
maxLength: 2
|
|
76
|
-
},
|
|
77
|
-
MM: 'month',
|
|
78
|
-
MMMM: {
|
|
79
|
-
sectionType: 'month',
|
|
80
|
-
contentType: 'letter'
|
|
81
|
-
},
|
|
82
|
-
MMM: {
|
|
83
|
-
sectionType: 'month',
|
|
84
|
-
contentType: 'letter'
|
|
85
|
-
},
|
|
86
|
-
L: {
|
|
87
|
-
sectionType: 'month',
|
|
88
|
-
contentType: 'digit',
|
|
89
|
-
maxLength: 2
|
|
90
|
-
},
|
|
91
|
-
LL: 'month',
|
|
92
|
-
LLL: {
|
|
93
|
-
sectionType: 'month',
|
|
94
|
-
contentType: 'letter'
|
|
95
|
-
},
|
|
96
|
-
LLLL: {
|
|
97
|
-
sectionType: 'month',
|
|
98
|
-
contentType: 'letter'
|
|
99
|
-
},
|
|
100
|
-
// Day of the month
|
|
101
|
-
d: {
|
|
102
|
-
sectionType: 'day',
|
|
103
|
-
contentType: 'digit',
|
|
104
|
-
maxLength: 2
|
|
105
|
-
},
|
|
106
|
-
dd: 'day',
|
|
107
|
-
do: {
|
|
108
|
-
sectionType: 'day',
|
|
109
|
-
contentType: 'digit-with-letter'
|
|
110
|
-
},
|
|
111
|
-
// Day of the week
|
|
112
|
-
E: {
|
|
113
|
-
sectionType: 'weekDay',
|
|
114
|
-
contentType: 'letter'
|
|
115
|
-
},
|
|
116
|
-
EE: {
|
|
117
|
-
sectionType: 'weekDay',
|
|
118
|
-
contentType: 'letter'
|
|
119
|
-
},
|
|
120
|
-
EEE: {
|
|
121
|
-
sectionType: 'weekDay',
|
|
122
|
-
contentType: 'letter'
|
|
123
|
-
},
|
|
124
|
-
EEEE: {
|
|
125
|
-
sectionType: 'weekDay',
|
|
126
|
-
contentType: 'letter'
|
|
127
|
-
},
|
|
128
|
-
EEEEE: {
|
|
129
|
-
sectionType: 'weekDay',
|
|
130
|
-
contentType: 'letter'
|
|
131
|
-
},
|
|
132
|
-
i: {
|
|
133
|
-
sectionType: 'weekDay',
|
|
134
|
-
contentType: 'digit',
|
|
135
|
-
maxLength: 1
|
|
136
|
-
},
|
|
137
|
-
ii: 'weekDay',
|
|
138
|
-
iii: {
|
|
139
|
-
sectionType: 'weekDay',
|
|
140
|
-
contentType: 'letter'
|
|
141
|
-
},
|
|
142
|
-
iiii: {
|
|
143
|
-
sectionType: 'weekDay',
|
|
144
|
-
contentType: 'letter'
|
|
145
|
-
},
|
|
146
|
-
e: {
|
|
147
|
-
sectionType: 'weekDay',
|
|
148
|
-
contentType: 'digit',
|
|
149
|
-
maxLength: 1
|
|
150
|
-
},
|
|
151
|
-
ee: 'weekDay',
|
|
152
|
-
eee: {
|
|
153
|
-
sectionType: 'weekDay',
|
|
154
|
-
contentType: 'letter'
|
|
155
|
-
},
|
|
156
|
-
eeee: {
|
|
157
|
-
sectionType: 'weekDay',
|
|
158
|
-
contentType: 'letter'
|
|
159
|
-
},
|
|
160
|
-
eeeee: {
|
|
161
|
-
sectionType: 'weekDay',
|
|
162
|
-
contentType: 'letter'
|
|
163
|
-
},
|
|
164
|
-
eeeeee: {
|
|
165
|
-
sectionType: 'weekDay',
|
|
166
|
-
contentType: 'letter'
|
|
167
|
-
},
|
|
168
|
-
c: {
|
|
169
|
-
sectionType: 'weekDay',
|
|
170
|
-
contentType: 'digit',
|
|
171
|
-
maxLength: 1
|
|
172
|
-
},
|
|
173
|
-
cc: 'weekDay',
|
|
174
|
-
ccc: {
|
|
175
|
-
sectionType: 'weekDay',
|
|
176
|
-
contentType: 'letter'
|
|
177
|
-
},
|
|
178
|
-
cccc: {
|
|
179
|
-
sectionType: 'weekDay',
|
|
180
|
-
contentType: 'letter'
|
|
181
|
-
},
|
|
182
|
-
ccccc: {
|
|
183
|
-
sectionType: 'weekDay',
|
|
184
|
-
contentType: 'letter'
|
|
185
|
-
},
|
|
186
|
-
cccccc: {
|
|
187
|
-
sectionType: 'weekDay',
|
|
188
|
-
contentType: 'letter'
|
|
189
|
-
},
|
|
190
|
-
// Meridiem
|
|
191
|
-
a: 'meridiem',
|
|
192
|
-
aa: 'meridiem',
|
|
193
|
-
aaa: 'meridiem',
|
|
194
|
-
// Hours
|
|
195
|
-
H: {
|
|
196
|
-
sectionType: 'hours',
|
|
197
|
-
contentType: 'digit',
|
|
198
|
-
maxLength: 2
|
|
199
|
-
},
|
|
200
|
-
HH: 'hours',
|
|
201
|
-
h: {
|
|
202
|
-
sectionType: 'hours',
|
|
203
|
-
contentType: 'digit',
|
|
204
|
-
maxLength: 2
|
|
205
|
-
},
|
|
206
|
-
hh: 'hours',
|
|
207
|
-
// Minutes
|
|
208
|
-
m: {
|
|
209
|
-
sectionType: 'minutes',
|
|
210
|
-
contentType: 'digit',
|
|
211
|
-
maxLength: 2
|
|
212
|
-
},
|
|
213
|
-
mm: 'minutes',
|
|
214
|
-
// Seconds
|
|
215
|
-
s: {
|
|
216
|
-
sectionType: 'seconds',
|
|
217
|
-
contentType: 'digit',
|
|
218
|
-
maxLength: 2
|
|
219
|
-
},
|
|
220
|
-
ss: 'seconds'
|
|
221
|
-
};
|
|
222
58
|
const defaultFormats = {
|
|
223
59
|
year: 'yyyy',
|
|
224
60
|
month: 'LLLL',
|
|
@@ -281,40 +117,22 @@ const NUMBER_SYMBOL_MAP = {
|
|
|
281
117
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
282
118
|
* SOFTWARE.
|
|
283
119
|
*/
|
|
284
|
-
class AdapterDateFnsJalali {
|
|
120
|
+
class AdapterDateFnsJalali extends _AdapterDateFnsBase.AdapterDateFnsBase {
|
|
285
121
|
constructor({
|
|
286
|
-
locale
|
|
122
|
+
locale,
|
|
287
123
|
formats
|
|
288
124
|
} = {}) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
if (typeof value === 'undefined') {
|
|
301
|
-
return new Date();
|
|
302
|
-
}
|
|
303
|
-
if (value === null) {
|
|
304
|
-
return null;
|
|
305
|
-
}
|
|
306
|
-
return new Date(value);
|
|
307
|
-
};
|
|
308
|
-
this.getInvalidDate = () => new Date('Invalid Date');
|
|
309
|
-
this.getTimezone = () => {
|
|
310
|
-
return 'default';
|
|
311
|
-
};
|
|
312
|
-
this.setTimezone = value => {
|
|
313
|
-
return value;
|
|
314
|
-
};
|
|
315
|
-
this.toJsDate = value => {
|
|
316
|
-
return value;
|
|
317
|
-
};
|
|
125
|
+
if (typeof _addDays.default !== 'function') {
|
|
126
|
+
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'));
|
|
127
|
+
}
|
|
128
|
+
super({
|
|
129
|
+
locale: locale ?? _faIR.default,
|
|
130
|
+
// some formats are different in jalali adapter,
|
|
131
|
+
// this ensures that `AdapterDateFnsBase` formats are overridden
|
|
132
|
+
formats: (0, _extends2.default)({}, defaultFormats, formats),
|
|
133
|
+
longFormatters: _longFormatters.default,
|
|
134
|
+
lib: 'date-fns-jalali'
|
|
135
|
+
});
|
|
318
136
|
this.parse = (value, format) => {
|
|
319
137
|
if (value === '') {
|
|
320
138
|
return null;
|
|
@@ -326,29 +144,6 @@ class AdapterDateFnsJalali {
|
|
|
326
144
|
this.getCurrentLocaleCode = () => {
|
|
327
145
|
return this.locale?.code || 'fa-IR';
|
|
328
146
|
};
|
|
329
|
-
// Note: date-fns input types are more lenient than this adapter, so we need to expose our more
|
|
330
|
-
// strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
|
|
331
|
-
this.is12HourCycleInCurrentLocale = () => {
|
|
332
|
-
if (this.locale) {
|
|
333
|
-
return /a/.test(this.locale.formatLong.time());
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// By default, date-fns-jalali is using fa-IR locale with am/pm enabled
|
|
337
|
-
return true;
|
|
338
|
-
};
|
|
339
|
-
this.expandFormat = format => {
|
|
340
|
-
// @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
|
|
341
|
-
const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
|
|
342
|
-
const locale = this.locale ?? _faIR.default;
|
|
343
|
-
return format.match(longFormatRegexp).map(token => {
|
|
344
|
-
const firstCharacter = token[0];
|
|
345
|
-
if (firstCharacter === 'p' || firstCharacter === 'P') {
|
|
346
|
-
const longFormatter = _longFormatters.default[firstCharacter];
|
|
347
|
-
return longFormatter(token, locale.formatLong, {});
|
|
348
|
-
}
|
|
349
|
-
return token;
|
|
350
|
-
}).join('');
|
|
351
|
-
};
|
|
352
147
|
this.isValid = value => {
|
|
353
148
|
if (value == null) {
|
|
354
149
|
return false;
|
|
@@ -536,11 +331,6 @@ class AdapterDateFnsJalali {
|
|
|
536
331
|
}
|
|
537
332
|
return years;
|
|
538
333
|
};
|
|
539
|
-
this.locale = _locale;
|
|
540
|
-
this.formats = (0, _extends2.default)({}, defaultFormats, formats);
|
|
541
|
-
}
|
|
542
|
-
getDayOfWeek(value) {
|
|
543
|
-
return value.getDay() + 1;
|
|
544
334
|
}
|
|
545
335
|
}
|
|
546
336
|
exports.AdapterDateFnsJalali = AdapterDateFnsJalali;
|