@mui/x-date-pickers 7.0.0-beta.7 → 7.1.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.
Files changed (209) hide show
  1. package/AdapterDateFns/AdapterDateFns.js +1 -1
  2. package/AdapterDateFnsBase/AdapterDateFnsBase.js +1 -2
  3. package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -4
  4. package/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -1
  5. package/AdapterDayjs/AdapterDayjs.js +2 -4
  6. package/AdapterLuxon/AdapterLuxon.js +12 -9
  7. package/AdapterMoment/AdapterMoment.js +5 -6
  8. package/CHANGELOG.md +266 -12
  9. package/DateCalendar/DateCalendar.js +14 -16
  10. package/DateCalendar/DayCalendar.js +5 -6
  11. package/DateField/DateField.js +3 -4
  12. package/DatePicker/DatePicker.js +1 -1
  13. package/DatePicker/DatePickerToolbar.js +11 -6
  14. package/DatePicker/shared.d.ts +2 -1
  15. package/DatePicker/shared.js +3 -5
  16. package/DateTimeField/DateTimeField.js +3 -4
  17. package/DateTimePicker/DateTimePicker.js +1 -1
  18. package/DateTimePicker/DateTimePickerToolbar.js +98 -46
  19. package/DateTimePicker/shared.d.ts +2 -1
  20. package/DateTimePicker/shared.js +11 -13
  21. package/DayCalendarSkeleton/DayCalendarSkeleton.js +12 -8
  22. package/DesktopDatePicker/DesktopDatePicker.js +7 -11
  23. package/DesktopDateTimePicker/DesktopDateTimePicker.js +72 -37
  24. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +12 -0
  25. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +101 -0
  26. package/DesktopDateTimePicker/index.d.ts +1 -0
  27. package/DesktopDateTimePicker/index.js +2 -1
  28. package/DesktopTimePicker/DesktopTimePicker.js +8 -12
  29. package/DigitalClock/DigitalClock.js +16 -9
  30. package/LocalizationProvider/LocalizationProvider.js +1 -2
  31. package/MobileDatePicker/MobileDatePicker.js +6 -10
  32. package/MobileDateTimePicker/MobileDateTimePicker.js +8 -12
  33. package/MobileTimePicker/MobileTimePicker.js +6 -10
  34. package/MonthCalendar/MonthCalendar.js +4 -4
  35. package/MonthCalendar/PickersMonth.js +13 -8
  36. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -1
  37. package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +1 -1
  38. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +16 -9
  39. package/PickersActionBar/PickersActionBar.js +1 -1
  40. package/PickersCalendarHeader/PickersCalendarHeader.js +17 -14
  41. package/PickersDay/PickersDay.js +30 -15
  42. package/PickersLayout/PickersLayout.js +31 -17
  43. package/PickersLayout/usePickerLayout.js +8 -9
  44. package/PickersSectionList/PickersSectionList.js +9 -11
  45. package/PickersTextField/PickersFilledInput/PickersFilledInput.js +138 -74
  46. package/PickersTextField/PickersInput/PickersInput.js +77 -55
  47. package/PickersTextField/PickersInputBase/PickersInputBase.js +67 -28
  48. package/PickersTextField/PickersInputBase/PickersInputBase.types.d.ts +7 -0
  49. package/PickersTextField/PickersOutlinedInput/Outline.js +58 -41
  50. package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +33 -14
  51. package/README.md +1 -1
  52. package/StaticDatePicker/StaticDatePicker.js +4 -5
  53. package/StaticDateTimePicker/StaticDateTimePicker.js +6 -7
  54. package/StaticTimePicker/StaticTimePicker.js +3 -4
  55. package/TimeClock/Clock.js +48 -35
  56. package/TimeClock/ClockNumber.js +12 -7
  57. package/TimeClock/ClockPointer.js +23 -13
  58. package/TimeClock/TimeClock.js +1 -1
  59. package/TimeField/TimeField.js +2 -3
  60. package/TimePicker/TimePickerToolbar.js +25 -16
  61. package/TimePicker/shared.d.ts +2 -1
  62. package/TimePicker/shared.js +5 -7
  63. package/YearCalendar/PickersYear.js +12 -6
  64. package/YearCalendar/YearCalendar.js +5 -6
  65. package/hooks/useClearableField.js +6 -7
  66. package/index.js +1 -1
  67. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +19 -15
  68. package/internals/components/PickersModalDialog.js +6 -7
  69. package/internals/components/PickersPopper.js +25 -24
  70. package/internals/components/PickersToolbar.js +42 -24
  71. package/internals/hooks/date-helpers-hooks.js +1 -1
  72. package/internals/hooks/defaultizedFieldProps.js +15 -18
  73. package/internals/hooks/useClockReferenceDate.js +1 -1
  74. package/internals/hooks/useDesktopPicker/index.d.ts +1 -1
  75. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +11 -12
  76. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
  77. package/internals/hooks/useField/buildSectionsFromFormat.js +35 -31
  78. package/internals/hooks/useField/useField.js +6 -4
  79. package/internals/hooks/useField/useField.types.d.ts +1 -0
  80. package/internals/hooks/useField/useField.utils.js +4 -7
  81. package/internals/hooks/useField/useFieldCharacterEditing.js +1 -2
  82. package/internals/hooks/useField/useFieldState.js +1 -1
  83. package/internals/hooks/useField/useFieldV6TextField.js +17 -18
  84. package/internals/hooks/useField/useFieldV7TextField.js +9 -11
  85. package/internals/hooks/useMobilePicker/useMobilePicker.js +7 -8
  86. package/internals/hooks/useOpenState.js +1 -1
  87. package/internals/hooks/usePicker/index.d.ts +1 -0
  88. package/internals/hooks/usePicker/usePickerViews.d.ts +4 -2
  89. package/internals/hooks/usePicker/usePickerViews.js +1 -2
  90. package/internals/hooks/useStaticPicker/useStaticPicker.js +13 -17
  91. package/internals/hooks/useValueWithTimezone.js +5 -6
  92. package/internals/hooks/useViews.js +3 -4
  93. package/internals/index.d.ts +1 -1
  94. package/internals/models/validation.d.ts +1 -1
  95. package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +3 -3
  96. package/internals/utils/date-time-utils.js +2 -5
  97. package/internals/utils/fields.js +1 -1
  98. package/internals/utils/getDefaultReferenceDate.js +2 -6
  99. package/internals/utils/views.js +1 -1
  100. package/locales/csCZ.js +1 -4
  101. package/locales/daDK.js +1 -4
  102. package/locales/deDE.js +1 -4
  103. package/locales/huHU.js +1 -4
  104. package/locales/itIT.js +16 -20
  105. package/locales/jaJP.js +1 -4
  106. package/locales/roRO.js +1 -4
  107. package/locales/skSK.js +1 -4
  108. package/locales/zhHK.js +14 -17
  109. package/modern/AdapterLuxon/AdapterLuxon.js +9 -4
  110. package/modern/DateCalendar/DateCalendar.js +1 -1
  111. package/modern/DateField/DateField.js +1 -1
  112. package/modern/DatePicker/DatePicker.js +1 -1
  113. package/modern/DatePicker/DatePickerToolbar.js +11 -6
  114. package/modern/DateTimeField/DateTimeField.js +1 -1
  115. package/modern/DateTimePicker/DateTimePicker.js +1 -1
  116. package/modern/DateTimePicker/DateTimePickerToolbar.js +97 -45
  117. package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +12 -8
  118. package/modern/DesktopDatePicker/DesktopDatePicker.js +1 -1
  119. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +64 -25
  120. package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +101 -0
  121. package/modern/DesktopDateTimePicker/index.js +2 -1
  122. package/modern/DigitalClock/DigitalClock.js +14 -6
  123. package/modern/MobileDatePicker/MobileDatePicker.js +1 -1
  124. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
  125. package/modern/MonthCalendar/PickersMonth.js +12 -6
  126. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +13 -4
  127. package/modern/PickersCalendarHeader/PickersCalendarHeader.js +13 -9
  128. package/modern/PickersDay/PickersDay.js +30 -15
  129. package/modern/PickersLayout/PickersLayout.js +31 -17
  130. package/modern/PickersTextField/PickersFilledInput/PickersFilledInput.js +137 -72
  131. package/modern/PickersTextField/PickersInput/PickersInput.js +76 -54
  132. package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +64 -24
  133. package/modern/PickersTextField/PickersOutlinedInput/Outline.js +58 -41
  134. package/modern/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +31 -12
  135. package/modern/StaticDatePicker/StaticDatePicker.js +1 -1
  136. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
  137. package/modern/TimeClock/Clock.js +48 -35
  138. package/modern/TimeClock/ClockNumber.js +12 -7
  139. package/modern/TimeClock/ClockPointer.js +23 -13
  140. package/modern/TimePicker/TimePickerToolbar.js +25 -16
  141. package/modern/YearCalendar/PickersYear.js +12 -6
  142. package/modern/index.js +1 -1
  143. package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -6
  144. package/modern/internals/components/PickersPopper.js +13 -9
  145. package/modern/internals/components/PickersToolbar.js +39 -18
  146. package/modern/internals/hooks/useField/buildSectionsFromFormat.js +34 -30
  147. package/modern/internals/hooks/useField/useField.js +4 -2
  148. package/modern/internals/hooks/useField/useFieldV6TextField.js +8 -3
  149. package/modern/internals/hooks/useField/useFieldV7TextField.js +1 -1
  150. package/modern/internals/hooks/useOpenState.js +1 -1
  151. package/modern/internals/utils/fields.js +1 -1
  152. package/modern/locales/itIT.js +16 -20
  153. package/modern/locales/zhHK.js +14 -17
  154. package/node/AdapterLuxon/AdapterLuxon.js +9 -4
  155. package/node/DateCalendar/DateCalendar.js +1 -1
  156. package/node/DateField/DateField.js +1 -1
  157. package/node/DatePicker/DatePicker.js +1 -1
  158. package/node/DatePicker/DatePickerToolbar.js +11 -6
  159. package/node/DateTimeField/DateTimeField.js +1 -1
  160. package/node/DateTimePicker/DateTimePicker.js +1 -1
  161. package/node/DateTimePicker/DateTimePickerToolbar.js +97 -45
  162. package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +12 -8
  163. package/node/DesktopDatePicker/DesktopDatePicker.js +1 -1
  164. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +63 -25
  165. package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +108 -0
  166. package/node/DesktopDateTimePicker/index.js +8 -1
  167. package/node/DigitalClock/DigitalClock.js +14 -6
  168. package/node/MobileDatePicker/MobileDatePicker.js +1 -1
  169. package/node/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
  170. package/node/MonthCalendar/PickersMonth.js +12 -6
  171. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +13 -4
  172. package/node/PickersCalendarHeader/PickersCalendarHeader.js +13 -9
  173. package/node/PickersDay/PickersDay.js +30 -15
  174. package/node/PickersLayout/PickersLayout.js +31 -17
  175. package/node/PickersTextField/PickersFilledInput/PickersFilledInput.js +137 -72
  176. package/node/PickersTextField/PickersInput/PickersInput.js +76 -54
  177. package/node/PickersTextField/PickersInputBase/PickersInputBase.js +64 -24
  178. package/node/PickersTextField/PickersOutlinedInput/Outline.js +58 -41
  179. package/node/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +31 -12
  180. package/node/StaticDatePicker/StaticDatePicker.js +1 -1
  181. package/node/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
  182. package/node/TimeClock/Clock.js +48 -35
  183. package/node/TimeClock/ClockNumber.js +12 -7
  184. package/node/TimeClock/ClockPointer.js +23 -13
  185. package/node/TimePicker/TimePickerToolbar.js +25 -16
  186. package/node/YearCalendar/PickersYear.js +12 -6
  187. package/node/index.js +1 -1
  188. package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -6
  189. package/node/internals/components/PickersPopper.js +13 -9
  190. package/node/internals/components/PickersToolbar.js +39 -18
  191. package/node/internals/hooks/useField/buildSectionsFromFormat.js +34 -30
  192. package/node/internals/hooks/useField/useField.js +4 -2
  193. package/node/internals/hooks/useField/useFieldV6TextField.js +8 -3
  194. package/node/internals/hooks/useField/useFieldV7TextField.js +1 -1
  195. package/node/internals/hooks/useOpenState.js +1 -1
  196. package/node/internals/utils/fields.js +1 -1
  197. package/node/locales/itIT.js +16 -20
  198. package/node/locales/zhHK.js +14 -17
  199. package/package.json +5 -5
  200. package/timeViewRenderers/timeViewRenderers.js +1 -1
  201. package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +0 -15
  202. package/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -163
  203. package/dateTimeViewRenderers/index.d.ts +0 -2
  204. package/dateTimeViewRenderers/index.js +0 -1
  205. package/dateTimeViewRenderers/package.json +0 -6
  206. package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -162
  207. package/modern/dateTimeViewRenderers/index.js +0 -1
  208. package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -171
  209. package/node/dateTimeViewRenderers/index.js +0 -12
@@ -23,14 +23,20 @@ const PickersYearRoot = styled('div', {
23
23
  name: 'MuiPickersYear',
24
24
  slot: 'Root',
25
25
  overridesResolver: (_, styles) => [styles.root]
26
- })(({
27
- ownerState
28
- }) => ({
29
- flexBasis: ownerState.yearsPerRow === 3 ? '33.3%' : '25%',
26
+ })({
30
27
  display: 'flex',
31
28
  alignItems: 'center',
32
- justifyContent: 'center'
33
- }));
29
+ justifyContent: 'center',
30
+ flexBasis: '33.3%',
31
+ variants: [{
32
+ props: {
33
+ yearsPerRow: 4
34
+ },
35
+ style: {
36
+ flexBasis: '25%'
37
+ }
38
+ }]
39
+ });
34
40
  const PickersYearButton = styled('button', {
35
41
  name: 'MuiPickersYear',
36
42
  slot: 'YearButton',
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v7.0.0-beta.7
2
+ * @mui/x-date-pickers v7.1.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,5 +1,5 @@
1
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["children", "className", "slots", "slotProps", "isNextDisabled", "isNextHidden", "onGoToNext", "nextLabel", "isPreviousDisabled", "isPreviousHidden", "onGoToPrevious", "previousLabel"],
4
4
  _excluded2 = ["ownerState"],
5
5
  _excluded3 = ["ownerState"];
@@ -34,11 +34,16 @@ const PickersArrowSwitcherButton = styled(IconButton, {
34
34
  name: 'MuiPickersArrowSwitcher',
35
35
  slot: 'Button',
36
36
  overridesResolver: (props, styles) => styles.button
37
- })(({
38
- ownerState
39
- }) => _extends({}, ownerState.hidden && {
40
- visibility: 'hidden'
41
- }));
37
+ })({
38
+ variants: [{
39
+ props: {
40
+ hidden: true
41
+ },
42
+ style: {
43
+ visibility: 'hidden'
44
+ }
45
+ }]
46
+ });
42
47
  const useUtilityClasses = ownerState => {
43
48
  const {
44
49
  classes
@@ -1,5 +1,5 @@
1
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["PaperComponent", "popperPlacement", "ownerState", "children", "paperSlotProps", "paperClasses", "onPaperClick", "onPaperTouchStart"];
4
4
  import * as React from 'react';
5
5
  import { useSlotProps } from '@mui/base/utils';
@@ -37,14 +37,18 @@ const PickersPopperPaper = styled(MuiPaper, {
37
37
  name: 'MuiPickersPopper',
38
38
  slot: 'Paper',
39
39
  overridesResolver: (_, styles) => styles.paper
40
- })(({
41
- ownerState
42
- }) => _extends({
40
+ })({
43
41
  outline: 0,
44
- transformOrigin: 'top center'
45
- }, ownerState.placement.includes('top') && {
46
- transformOrigin: 'bottom center'
47
- }));
42
+ transformOrigin: 'top center',
43
+ variants: [{
44
+ props: ({
45
+ placement
46
+ }) => ['top', 'top-start', 'top-end'].includes(placement),
47
+ style: {
48
+ transformOrigin: 'bottom center'
49
+ }
50
+ }]
51
+ });
48
52
  function clickedRootScrollbar(event, doc) {
49
53
  return doc.documentElement.clientWidth < event.clientX || doc.documentElement.clientHeight < event.clientY;
50
54
  }
@@ -146,7 +150,7 @@ function useClickAwayListener(active, onClickAway) {
146
150
  // TODO This behavior is not tested automatically
147
151
  // It's unclear whether this is due to different update semantics in test (batched in act() vs discrete on click).
148
152
  // Or if this is a timing related issues due to different Transition components
149
- // Once we get rid of all the manual scheduling (e.g. setTimeout(update, 0)) we can revisit this code+test.
153
+ // Once we get rid of all the manual scheduling (for example setTimeout(update, 0)) we can revisit this code+test.
150
154
  if (active) {
151
155
  const doc = ownerDocument(nodeRef.current);
152
156
  doc.addEventListener('click', handleClickAway);
@@ -1,5 +1,5 @@
1
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["children", "className", "toolbarTitle", "hidden", "titleId", "isLandscape", "classes", "landscapeDirection"];
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
@@ -26,36 +26,57 @@ const PickersToolbarRoot = styled('div', {
26
26
  slot: 'Root',
27
27
  overridesResolver: (props, styles) => styles.root
28
28
  })(({
29
- theme,
30
- ownerState
31
- }) => _extends({
29
+ theme
30
+ }) => ({
32
31
  display: 'flex',
33
32
  flexDirection: 'column',
34
33
  alignItems: 'flex-start',
35
34
  justifyContent: 'space-between',
36
- padding: theme.spacing(2, 3)
37
- }, ownerState.isLandscape && {
38
- height: 'auto',
39
- maxWidth: 160,
40
- padding: 16,
41
- justifyContent: 'flex-start',
42
- flexWrap: 'wrap'
35
+ padding: theme.spacing(2, 3),
36
+ variants: [{
37
+ props: {
38
+ isLandscape: true
39
+ },
40
+ style: {
41
+ height: 'auto',
42
+ maxWidth: 160,
43
+ padding: 16,
44
+ justifyContent: 'flex-start',
45
+ flexWrap: 'wrap'
46
+ }
47
+ }]
43
48
  }));
44
49
  const PickersToolbarContent = styled('div', {
45
50
  name: 'MuiPickersToolbar',
46
51
  slot: 'Content',
47
52
  overridesResolver: (props, styles) => styles.content
48
- })(({
49
- ownerState
50
- }) => ({
53
+ })({
51
54
  display: 'flex',
52
55
  flexWrap: 'wrap',
53
56
  width: '100%',
54
- justifyContent: ownerState.isLandscape ? 'flex-start' : 'space-between',
55
- flexDirection: ownerState.isLandscape ? ownerState.landscapeDirection ?? 'column' : 'row',
56
57
  flex: 1,
57
- alignItems: ownerState.isLandscape ? 'flex-start' : 'center'
58
- }));
58
+ justifyContent: 'space-between',
59
+ alignItems: 'center',
60
+ flexDirection: 'row',
61
+ variants: [{
62
+ props: {
63
+ isLandscape: true
64
+ },
65
+ style: {
66
+ justifyContent: 'flex-start',
67
+ alignItems: 'flex-start',
68
+ flexDirection: 'column'
69
+ }
70
+ }, {
71
+ props: {
72
+ isLandscape: true,
73
+ landscapeDirection: 'row'
74
+ },
75
+ style: {
76
+ flexDirection: 'row'
77
+ }
78
+ }]
79
+ });
59
80
  export const PickersToolbar = /*#__PURE__*/React.forwardRef(function PickersToolbar(inProps, ref) {
60
81
  const props = useThemeProps({
61
82
  props: inProps,
@@ -152,49 +152,53 @@ const buildSections = params => {
152
152
  const sections = [];
153
153
  let startSeparator = '';
154
154
 
155
- // This RegExp test if the beginning of a string corresponds to a supported token
156
- const isTokenStartRegExp = new RegExp(`^(${Object.keys(utils.formatTokenMap).sort((a, b) => b.length - a.length) // Sort to put longest word first
157
- .join('|')})`, 'g') // used to get access to lastIndex state
158
- ;
159
- let currentTokenValue = '';
160
- for (let i = 0; i < expandedFormat.length; i += 1) {
161
- const escapedPartOfCurrentChar = escapedParts.find(escapeIndex => escapeIndex.start <= i && escapeIndex.end >= i);
162
- const char = expandedFormat[i];
155
+ // This RegExp tests if the beginning of a string corresponds to a supported token
156
+ const validTokens = Object.keys(utils.formatTokenMap).sort((a, b) => b.length - a.length); // Sort to put longest word first
157
+
158
+ const regExpFirstWordInFormat = /^([a-zA-Z]+)/;
159
+ const regExpWordOnlyComposedOfTokens = new RegExp(`^(${validTokens.join('|')})*$`);
160
+ const regExpFirstTokenInWord = new RegExp(`^(${validTokens.join('|')})`);
161
+ const getEscapedPartOfCurrentChar = i => escapedParts.find(escapeIndex => escapeIndex.start <= i && escapeIndex.end >= i);
162
+ let i = 0;
163
+ while (i < expandedFormat.length) {
164
+ const escapedPartOfCurrentChar = getEscapedPartOfCurrentChar(i);
163
165
  const isEscapedChar = escapedPartOfCurrentChar != null;
164
- const potentialToken = `${currentTokenValue}${expandedFormat.slice(i)}`;
165
- const regExpMatch = isTokenStartRegExp.test(potentialToken);
166
- if (!isEscapedChar && char.match(/([A-Za-z]+)/) && regExpMatch) {
167
- currentTokenValue = potentialToken.slice(0, isTokenStartRegExp.lastIndex);
168
- i += isTokenStartRegExp.lastIndex - 1;
169
- } else {
166
+ const firstWordInFormat = regExpFirstWordInFormat.exec(expandedFormat.slice(i))?.[1];
167
+
168
+ // The first word in the format is only composed of tokens.
169
+ // We extract those tokens to create a new sections.
170
+ if (!isEscapedChar && firstWordInFormat != null && regExpWordOnlyComposedOfTokens.test(firstWordInFormat)) {
171
+ let word = firstWordInFormat;
172
+ while (word.length > 0) {
173
+ const firstWord = regExpFirstTokenInWord.exec(word)[1];
174
+ word = word.slice(firstWord.length);
175
+ sections.push(createSection(_extends({}, params, {
176
+ now,
177
+ token: firstWord,
178
+ startSeparator
179
+ })));
180
+ startSeparator = '';
181
+ }
182
+ i += firstWordInFormat.length;
183
+ }
184
+ // The remaining format does not start with a token,
185
+ // We take the first character and add it to the current section's end separator.
186
+ else {
187
+ const char = expandedFormat[i];
188
+
170
189
  // If we are on the opening or closing character of an escaped part of the format,
171
190
  // Then we ignore this character.
172
191
  const isEscapeBoundary = isEscapedChar && escapedPartOfCurrentChar?.start === i || escapedPartOfCurrentChar?.end === i;
173
192
  if (!isEscapeBoundary) {
174
- if (currentTokenValue !== '') {
175
- sections.push(createSection(_extends({}, params, {
176
- now,
177
- token: currentTokenValue,
178
- startSeparator
179
- })));
180
- currentTokenValue = '';
181
- }
182
193
  if (sections.length === 0) {
183
194
  startSeparator += char;
184
195
  } else {
185
- startSeparator = '';
186
196
  sections[sections.length - 1].endSeparator += char;
187
197
  }
188
198
  }
199
+ i += 1;
189
200
  }
190
201
  }
191
- if (currentTokenValue !== '') {
192
- sections.push(createSection(_extends({}, params, {
193
- now,
194
- token: currentTokenValue,
195
- startSeparator
196
- })));
197
- }
198
202
  if (sections.length === 0 && startSeparator.length > 0) {
199
203
  sections.push({
200
204
  type: 'empty',
@@ -202,9 +202,11 @@ export const useField = params => {
202
202
  event.preventDefault();
203
203
  onClear?.(event, ...args);
204
204
  clearValue();
205
- setSelectedSections(sectionOrder.startIndex);
206
- if (!interactions.isFieldFocused) {
205
+ if (!interactions.isFieldFocused()) {
206
+ // setSelectedSections is called internally
207
207
  interactions.focusField(0);
208
+ } else {
209
+ setSelectedSections(sectionOrder.startIndex);
208
210
  }
209
211
  });
210
212
  const commonForwardedProps = {
@@ -43,7 +43,8 @@ export const useFieldV6TextField = params => {
43
43
  onClick,
44
44
  onPaste,
45
45
  onBlur,
46
- inputRef: inputRefProp
46
+ inputRef: inputRefProp,
47
+ placeholder: inPlaceholder
47
48
  },
48
49
  internalProps: {
49
50
  readOnly = false
@@ -127,7 +128,6 @@ export const useFieldV6TextField = params => {
127
128
  }), [inputRef, parsedSelectedSections, sections, setSelectedSections]);
128
129
  const syncSelectionFromDOM = () => {
129
130
  if (readOnly) {
130
- setSelectedSections(null);
131
131
  return;
132
132
  }
133
133
  const browserStartIndex = inputRef.current.selectionStart ?? 0;
@@ -275,7 +275,12 @@ export const useFieldV6TextField = params => {
275
275
  sectionIndex: activeSectionIndex
276
276
  });
277
277
  });
278
- const placeholder = React.useMemo(() => fieldValueManager.getV6InputValueFromSections(getSectionsFromValue(valueManager.emptyValue), localizedDigits, isRTL), [fieldValueManager, getSectionsFromValue, valueManager.emptyValue, localizedDigits, isRTL]);
278
+ const placeholder = React.useMemo(() => {
279
+ if (inPlaceholder) {
280
+ return inPlaceholder;
281
+ }
282
+ return fieldValueManager.getV6InputValueFromSections(getSectionsFromValue(valueManager.emptyValue), localizedDigits, isRTL);
283
+ }, [inPlaceholder, fieldValueManager, getSectionsFromValue, valueManager.emptyValue, localizedDigits, isRTL]);
279
284
  const valueStr = React.useMemo(() => state.tempValueStrAndroid ?? fieldValueManager.getV6InputValueFromSections(state.sections, localizedDigits, isRTL), [state.sections, fieldValueManager, state.tempValueStrAndroid, localizedDigits, isRTL]);
280
285
  React.useEffect(() => {
281
286
  // Select all the sections when focused on mount (`autoFocus = true` on the input)
@@ -366,7 +366,7 @@ export const useFieldV7TextField = params => {
366
366
  const valueStr = React.useMemo(() => areAllSectionsEmpty ? '' : fieldValueManager.getV7HiddenInputValueFromSections(state.sections), [areAllSectionsEmpty, state.sections, fieldValueManager]);
367
367
  React.useEffect(() => {
368
368
  if (sectionListRef.current == null) {
369
- throw new Error(['MUI X: The `sectionListRef` prop has not been initialized by `PickersSectionList`', 'You probably tried to pass a component to the `textField` slot that contains an `<input />` element instead of a `PickersSectionList`.', '', 'If you want to keep using an `<input />` HTML element for the editing, please remove the `enableAccessibleFieldDOMStructure` prop from your picker or field component:', '', '<DatePicker slots={{ textField: MyCustomTextField }} />', '', 'Learn more about the field accessible DOM structure on the MUI documentation: https://next.mui.com/x/react-date-pickers/fields/#fields-to-edit-a-single-element'].join('\n'));
369
+ throw new Error(['MUI X: The `sectionListRef` prop has not been initialized by `PickersSectionList`', 'You probably tried to pass a component to the `textField` slot that contains an `<input />` element instead of a `PickersSectionList`.', '', 'If you want to keep using an `<input />` HTML element for the editing, please remove the `enableAccessibleFieldDOMStructure` prop from your picker or field component:', '', '<DatePicker slots={{ textField: MyCustomTextField }} />', '', 'Learn more about the field accessible DOM structure on the MUI documentation: https://mui.com/x/react-date-pickers/fields/#fields-to-edit-a-single-element'].join('\n'));
370
370
  }
371
371
  if (autoFocus && sectionListRef.current) {
372
372
  sectionListRef.current.getSectionContent(sectionOrder.startIndex).focus();
@@ -8,7 +8,7 @@ export const useOpenState = ({
8
8
  const [openState, setIsOpenState] = React.useState(false);
9
9
 
10
10
  // It is required to update inner state in useEffect in order to avoid situation when
11
- // Our component is not mounted yet, but `open` state is set to `true` (e.g. initially opened)
11
+ // Our component is not mounted yet, but `open` state is set to `true` (for example initially opened)
12
12
  React.useEffect(() => {
13
13
  if (isControllingOpenProp) {
14
14
  if (typeof open !== 'boolean') {
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from './validation/extractValidationProps';
3
- const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly'];
3
+ const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly', 'dateSeparator'];
4
4
  export const splitFieldInternalAndForwardedProps = (props, valueType) => {
5
5
  const forwardedProps = _extends({}, props);
6
6
  const internalProps = {};
@@ -16,11 +16,10 @@ const itITPickers = {
16
16
  // DateRange labels
17
17
  start: 'Inizio',
18
18
  end: 'Fine',
19
- // startDate: 'Start date',
20
- // startTime: 'Start time',
21
- // endDate: 'End date',
22
- // endTime: 'End time',
23
-
19
+ startDate: 'Data di inizio',
20
+ startTime: 'Ora di inizio',
21
+ endDate: 'Data di fine',
22
+ endTime: 'Ora di fine',
24
23
  // Action bar
25
24
  cancelButtonLabel: 'Cancellare',
26
25
  clearButtonLabel: 'Sgomberare',
@@ -46,8 +45,7 @@ const itITPickers = {
46
45
  // Open picker labels
47
46
  openDatePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Scegli la data, la data selezionata è ${utils.format(value, 'fullDate')}` : 'Scegli la data',
48
47
  openTimePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Scegli l'ora, l'ora selezionata è ${utils.format(value, 'fullTime')}` : "Scegli l'ora",
49
- // fieldClearLabel: 'Clear value',
50
-
48
+ fieldClearLabel: 'Cancella valore',
51
49
  // Table labels
52
50
  timeTableLabel: "scegli un'ora",
53
51
  dateTableLabel: 'scegli una data',
@@ -55,23 +53,21 @@ const itITPickers = {
55
53
  fieldYearPlaceholder: params => 'A'.repeat(params.digitAmount),
56
54
  fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'MMMM' : 'MM',
57
55
  fieldDayPlaceholder: () => 'GG',
58
- // fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'EEEE' : 'EE',
56
+ fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'GGGG' : 'GG',
59
57
  fieldHoursPlaceholder: () => 'hh',
60
58
  fieldMinutesPlaceholder: () => 'mm',
61
59
  fieldSecondsPlaceholder: () => 'ss',
62
- fieldMeridiemPlaceholder: () => 'aa'
63
-
60
+ fieldMeridiemPlaceholder: () => 'aa',
64
61
  // View names
65
- // year: 'Year',
66
- // month: 'Month',
67
- // day: 'Day',
68
- // weekDay: 'Week day',
69
- // hours: 'Hours',
70
- // minutes: 'Minutes',
71
- // seconds: 'Seconds',
72
- // meridiem: 'Meridiem',
73
-
62
+ year: 'Anno',
63
+ month: 'Mese',
64
+ day: 'Giorno',
65
+ weekDay: 'Giorno della settimana',
66
+ hours: 'Ore',
67
+ minutes: 'Minuti',
68
+ seconds: 'Secondi',
69
+ meridiem: 'Meridiano',
74
70
  // Common
75
- // empty: 'Empty',
71
+ empty: 'Vuoto'
76
72
  };
77
73
  export const itIT = getPickersLocalization(itITPickers);
@@ -16,11 +16,10 @@ const zhHKPickers = {
16
16
  // DateRange labels
17
17
  start: '開始',
18
18
  end: '結束',
19
- // startDate: 'Start date',
20
- // startTime: 'Start time',
21
- // endDate: 'End date',
22
- // endTime: 'End time',
23
-
19
+ startDate: '開始日期',
20
+ startTime: '開始時間',
21
+ endDate: '結束日期',
22
+ endTime: '結束時間',
24
23
  // Action bar
25
24
  cancelButtonLabel: '取消',
26
25
  clearButtonLabel: '清除',
@@ -59,19 +58,17 @@ const zhHKPickers = {
59
58
  fieldHoursPlaceholder: () => 'hh',
60
59
  fieldMinutesPlaceholder: () => 'mm',
61
60
  fieldSecondsPlaceholder: () => 'ss',
62
- fieldMeridiemPlaceholder: () => 'aa'
63
-
61
+ fieldMeridiemPlaceholder: () => 'aa',
64
62
  // View names
65
- // year: 'Year',
66
- // month: 'Month',
67
- // day: 'Day',
68
- // weekDay: 'Week day',
69
- // hours: 'Hours',
70
- // minutes: 'Minutes',
71
- // seconds: 'Seconds',
72
- // meridiem: 'Meridiem',
73
-
63
+ year: '',
64
+ month: '',
65
+ day: '',
66
+ weekDay: '星期',
67
+ hours: '小時',
68
+ minutes: '分鐘',
69
+ seconds: '',
70
+ meridiem: '子午線',
74
71
  // Common
75
- // empty: 'Empty',
72
+ empty: '空值'
76
73
  };
77
74
  export const zhHK = getPickersLocalization(zhHKPickers);
@@ -248,6 +248,10 @@ class AdapterLuxon {
248
248
  // Extract escaped section to avoid extending them
249
249
  const catchEscapedSectionsRegexp = /''|'(''|[^'])+('|$)|[^']*/g;
250
250
 
251
+ // This RegExp tests if a string is only mad of supported tokens
252
+ const validTokens = [...Object.keys(this.formatTokenMap), 'yyyyy'];
253
+ const isWordComposedOfTokens = new RegExp(`^(${validTokens.join('|')})+$`);
254
+
251
255
  // Extract words to test if they are a token or a word to escape.
252
256
  const catchWordsRegexp = /(?:^|[^a-z])([a-z]+)(?:[^a-z]|$)|([a-z]+)/gi;
253
257
  return format.match(catchEscapedSectionsRegexp).map(token => {
@@ -258,12 +262,13 @@ class AdapterLuxon {
258
262
  const expandedToken = _luxon.DateTime.expandFormat(token, {
259
263
  locale: this.locale
260
264
  });
261
- return expandedToken.replace(catchWordsRegexp, (correspondance, g1, g2) => {
265
+ return expandedToken.replace(catchWordsRegexp, (substring, g1, g2) => {
262
266
  const word = g1 || g2; // words are either in group 1 or group 2
263
- if (word === 'yyyyy' || formatTokenMap[word] !== undefined) {
264
- return correspondance;
267
+
268
+ if (isWordComposedOfTokens.test(word)) {
269
+ return substring;
265
270
  }
266
- return `'${correspondance}'`;
271
+ return `'${substring}'`;
267
272
  });
268
273
  }).join('')
269
274
  // The returned format can contain `yyyyy` which means year between 4 and 6 digits.
@@ -495,7 +495,7 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
495
495
  /**
496
496
  * Disable specific date.
497
497
  *
498
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
498
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
499
499
  *
500
500
  * @template TDate
501
501
  * @param {TDate} day The date to test.
@@ -250,7 +250,7 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
250
250
  /**
251
251
  * Disable specific date.
252
252
  *
253
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
253
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
254
254
  *
255
255
  * @template TDate
256
256
  * @param {TDate} day The date to test.
@@ -275,7 +275,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
275
275
  /**
276
276
  * Disable specific date.
277
277
  *
278
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
278
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
279
279
  *
280
280
  * @template TDate
281
281
  * @param {TDate} day The date to test.
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.DatePickerToolbar = void 0;
8
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
9
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _clsx = _interopRequireDefault(require("clsx"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
@@ -40,11 +40,16 @@ const DatePickerToolbarTitle = (0, _styles.styled)(_Typography.default, {
40
40
  name: 'MuiDatePickerToolbar',
41
41
  slot: 'Title',
42
42
  overridesResolver: (_, styles) => styles.title
43
- })(({
44
- ownerState
45
- }) => (0, _extends2.default)({}, ownerState.isLandscape && {
46
- margin: 'auto 16px auto auto'
47
- }));
43
+ })({
44
+ variants: [{
45
+ props: {
46
+ isLandscape: true
47
+ },
48
+ style: {
49
+ margin: 'auto 16px auto auto'
50
+ }
51
+ }]
52
+ });
48
53
  /**
49
54
  * Demos:
50
55
  *
@@ -283,7 +283,7 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
283
283
  /**
284
284
  * Disable specific date.
285
285
  *
286
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
286
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
287
287
  *
288
288
  * @template TDate
289
289
  * @param {TDate} day The date to test.
@@ -313,7 +313,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
313
313
  /**
314
314
  * Disable specific date.
315
315
  *
316
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
316
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
317
317
  *
318
318
  * @template TDate
319
319
  * @param {TDate} day The date to test.