@mui/x-date-pickers 8.8.0 → 8.9.2

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 (66) hide show
  1. package/AdapterDayjs/AdapterDayjs.d.ts +28 -31
  2. package/AdapterDayjs/AdapterDayjs.js +25 -31
  3. package/CHANGELOG.md +225 -24
  4. package/DateCalendar/DateCalendar.js +2 -2
  5. package/DatePicker/DatePicker.js +1 -1
  6. package/DateTimePicker/DateTimePicker.js +3 -3
  7. package/DesktopDatePicker/DesktopDatePicker.js +1 -1
  8. package/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -3
  9. package/DesktopTimePicker/DesktopTimePicker.js +3 -3
  10. package/DigitalClock/DigitalClock.js +2 -2
  11. package/MobileDatePicker/MobileDatePicker.js +1 -1
  12. package/MobileDateTimePicker/MobileDateTimePicker.js +3 -3
  13. package/MobileTimePicker/MobileTimePicker.js +1 -1
  14. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -3
  15. package/PickerDay2/PickerDay2.js +1 -0
  16. package/PickersDay/PickersDay.js +1 -0
  17. package/PickersLayout/PickersLayout.js +1 -1
  18. package/StaticDatePicker/StaticDatePicker.js +1 -1
  19. package/StaticDateTimePicker/StaticDateTimePicker.js +3 -3
  20. package/StaticTimePicker/StaticTimePicker.js +1 -1
  21. package/TimeClock/TimeClock.js +2 -2
  22. package/TimePicker/TimePicker.js +3 -3
  23. package/esm/AdapterDayjs/AdapterDayjs.d.ts +28 -31
  24. package/esm/AdapterDayjs/AdapterDayjs.js +37 -43
  25. package/esm/DateCalendar/DateCalendar.js +2 -2
  26. package/esm/DatePicker/DatePicker.js +1 -1
  27. package/esm/DateTimePicker/DateTimePicker.js +3 -3
  28. package/esm/DesktopDatePicker/DesktopDatePicker.js +1 -1
  29. package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -3
  30. package/esm/DesktopTimePicker/DesktopTimePicker.js +3 -3
  31. package/esm/DigitalClock/DigitalClock.js +2 -2
  32. package/esm/MobileDatePicker/MobileDatePicker.js +1 -1
  33. package/esm/MobileDateTimePicker/MobileDateTimePicker.js +3 -3
  34. package/esm/MobileTimePicker/MobileTimePicker.js +1 -1
  35. package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -3
  36. package/esm/PickerDay2/PickerDay2.js +1 -0
  37. package/esm/PickersDay/PickersDay.js +1 -0
  38. package/esm/PickersLayout/PickersLayout.js +1 -1
  39. package/esm/StaticDatePicker/StaticDatePicker.js +1 -1
  40. package/esm/StaticDateTimePicker/StaticDateTimePicker.js +3 -3
  41. package/esm/StaticTimePicker/StaticTimePicker.js +1 -1
  42. package/esm/TimeClock/TimeClock.js +2 -2
  43. package/esm/TimePicker/TimePicker.js +3 -3
  44. package/esm/index.js +1 -1
  45. package/esm/internals/components/PickerPopper/PickerPopper.js +12 -9
  46. package/esm/internals/hooks/useField/syncSelectionToDOM.js +3 -2
  47. package/esm/internals/hooks/useField/useFieldRootProps.js +2 -2
  48. package/esm/internals/hooks/useField/useFieldV6TextField.js +7 -7
  49. package/esm/internals/hooks/useField/useFieldV7TextField.js +2 -2
  50. package/esm/internals/hooks/useViews.d.ts +2 -2
  51. package/esm/internals/models/props/time.d.ts +3 -3
  52. package/esm/internals/utils/utils.d.ts +7 -1
  53. package/esm/internals/utils/utils.js +14 -3
  54. package/esm/locales/koKR.js +3 -5
  55. package/index.js +1 -1
  56. package/internals/components/PickerPopper/PickerPopper.js +12 -9
  57. package/internals/hooks/useField/syncSelectionToDOM.js +4 -2
  58. package/internals/hooks/useField/useFieldRootProps.js +2 -2
  59. package/internals/hooks/useField/useFieldV6TextField.js +7 -7
  60. package/internals/hooks/useField/useFieldV7TextField.js +2 -2
  61. package/internals/hooks/useViews.d.ts +2 -2
  62. package/internals/models/props/time.d.ts +3 -3
  63. package/internals/utils/utils.d.ts +7 -1
  64. package/internals/utils/utils.js +15 -3
  65. package/locales/koKR.js +3 -5
  66. package/package.json +4 -5
@@ -230,7 +230,7 @@ DesktopDatePicker.propTypes = {
230
230
  onSelectedSectionsChange: PropTypes.func,
231
231
  /**
232
232
  * Callback fired on view change.
233
- * @template TView
233
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
234
234
  * @param {TView} view The new view.
235
235
  */
236
236
  onViewChange: PropTypes.func,
@@ -350,7 +350,7 @@ DesktopDateTimePicker.propTypes = {
350
350
  onSelectedSectionsChange: PropTypes.func,
351
351
  /**
352
352
  * Callback fired on view change.
353
- * @template TView
353
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
354
354
  * @param {TView} view The new view.
355
355
  */
356
356
  onViewChange: PropTypes.func,
@@ -471,8 +471,8 @@ DesktopDateTimePicker.propTypes = {
471
471
  thresholdToRenderTimeInASingleColumn: PropTypes.number,
472
472
  /**
473
473
  * The time steps between two time unit options.
474
- * For example, if `timeStep.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
475
- * When single column time renderer is used, only `timeStep.minutes` will be used.
474
+ * For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
475
+ * When single column time renderer is used, only `timeSteps.minutes` will be used.
476
476
  * @default{ hours: 1, minutes: 5, seconds: 5 }
477
477
  */
478
478
  timeSteps: PropTypes.shape({
@@ -229,7 +229,7 @@ DesktopTimePicker.propTypes = {
229
229
  onSelectedSectionsChange: PropTypes.func,
230
230
  /**
231
231
  * Callback fired on view change.
232
- * @template TView
232
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
233
233
  * @param {TView} view The new view.
234
234
  */
235
235
  onViewChange: PropTypes.func,
@@ -307,8 +307,8 @@ DesktopTimePicker.propTypes = {
307
307
  thresholdToRenderTimeInASingleColumn: PropTypes.number,
308
308
  /**
309
309
  * The time steps between two time unit options.
310
- * For example, if `timeStep.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
311
- * When single column time renderer is used, only `timeStep.minutes` will be used.
310
+ * For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
311
+ * When single column time renderer is used, only `timeSteps.minutes` will be used.
312
312
  * @default{ hours: 1, minutes: 5, seconds: 5 }
313
313
  */
314
314
  timeSteps: PropTypes.shape({
@@ -393,14 +393,14 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
393
393
  onChange: PropTypes.func,
394
394
  /**
395
395
  * Callback fired on focused view change.
396
- * @template TView
396
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
397
397
  * @param {TView} view The new view to focus or not.
398
398
  * @param {boolean} hasFocus `true` if the view should be focused.
399
399
  */
400
400
  onFocusedViewChange: PropTypes.func,
401
401
  /**
402
402
  * Callback fired on view change.
403
- * @template TView
403
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
404
404
  * @param {TView} view The new view.
405
405
  */
406
406
  onViewChange: PropTypes.func,
@@ -228,7 +228,7 @@ MobileDatePicker.propTypes = {
228
228
  onSelectedSectionsChange: PropTypes.func,
229
229
  /**
230
230
  * Callback fired on view change.
231
- * @template TView
231
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
232
232
  * @param {TView} view The new view.
233
233
  */
234
234
  onViewChange: PropTypes.func,
@@ -316,7 +316,7 @@ MobileDateTimePicker.propTypes = {
316
316
  onSelectedSectionsChange: PropTypes.func,
317
317
  /**
318
318
  * Callback fired on view change.
319
- * @template TView
319
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
320
320
  * @param {TView} view The new view.
321
321
  */
322
322
  onViewChange: PropTypes.func,
@@ -437,8 +437,8 @@ MobileDateTimePicker.propTypes = {
437
437
  thresholdToRenderTimeInASingleColumn: PropTypes.number,
438
438
  /**
439
439
  * The time steps between two time unit options.
440
- * For example, if `timeStep.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
441
- * When single column time renderer is used, only `timeStep.minutes` will be used.
440
+ * For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
441
+ * When single column time renderer is used, only `timeSteps.minutes` will be used.
442
442
  * @default{ hours: 1, minutes: 5, seconds: 5 }
443
443
  */
444
444
  timeSteps: PropTypes.shape({
@@ -214,7 +214,7 @@ MobileTimePicker.propTypes = {
214
214
  onSelectedSectionsChange: PropTypes.func,
215
215
  /**
216
216
  * Callback fired on view change.
217
- * @template TView
217
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
218
218
  * @param {TView} view The new view.
219
219
  */
220
220
  onViewChange: PropTypes.func,
@@ -422,14 +422,14 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
422
422
  onChange: PropTypes.func,
423
423
  /**
424
424
  * Callback fired on focused view change.
425
- * @template TView
425
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
426
426
  * @param {TView} view The new view to focus or not.
427
427
  * @param {boolean} hasFocus `true` if the view should be focused.
428
428
  */
429
429
  onFocusedViewChange: PropTypes.func,
430
430
  /**
431
431
  * Callback fired on view change.
432
- * @template TView
432
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
433
433
  * @param {TView} view The new view.
434
434
  */
435
435
  onViewChange: PropTypes.func,
@@ -478,7 +478,7 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
478
478
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
479
479
  /**
480
480
  * The time steps between two time unit options.
481
- * For example, if `timeStep.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
481
+ * For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
482
482
  * @default{ hours: 1, minutes: 5, seconds: 5 }
483
483
  */
484
484
  timeSteps: PropTypes.shape({
@@ -180,6 +180,7 @@ const PickerDay2Raw = /*#__PURE__*/React.forwardRef(function PickerDay2(inProps,
180
180
  }
181
181
  };
182
182
  const handleClick = event => {
183
+ event.defaultMuiPrevented = true;
183
184
  if (!disabled) {
184
185
  onDaySelect(day);
185
186
  }
@@ -186,6 +186,7 @@ const PickersDayRaw = /*#__PURE__*/React.forwardRef(function PickersDay(inProps,
186
186
  }
187
187
  };
188
188
  const handleClick = event => {
189
+ event.defaultMuiPrevented = true;
189
190
  if (!disabled) {
190
191
  onDaySelect(day);
191
192
  }
@@ -75,7 +75,7 @@ export const PickersLayoutRoot = styled('div', {
75
75
  },
76
76
  style: {
77
77
  [`& .${pickersLayoutClasses.shortcuts}`]: {
78
- gridColumn: 3
78
+ gridColumn: 4
79
79
  }
80
80
  }
81
81
  }]
@@ -176,7 +176,7 @@ StaticDatePicker.propTypes = {
176
176
  onMonthChange: PropTypes.func,
177
177
  /**
178
178
  * Callback fired on view change.
179
- * @template TView
179
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
180
180
  * @param {TView} view The new view.
181
181
  */
182
182
  onViewChange: PropTypes.func,
@@ -263,7 +263,7 @@ StaticDateTimePicker.propTypes = {
263
263
  onMonthChange: PropTypes.func,
264
264
  /**
265
265
  * Callback fired on view change.
266
- * @template TView
266
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
267
267
  * @param {TView} view The new view.
268
268
  */
269
269
  onViewChange: PropTypes.func,
@@ -369,8 +369,8 @@ StaticDateTimePicker.propTypes = {
369
369
  thresholdToRenderTimeInASingleColumn: PropTypes.number,
370
370
  /**
371
371
  * The time steps between two time unit options.
372
- * For example, if `timeStep.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
373
- * When single column time renderer is used, only `timeStep.minutes` will be used.
372
+ * For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
373
+ * When single column time renderer is used, only `timeSteps.minutes` will be used.
374
374
  * @default{ hours: 1, minutes: 5, seconds: 5 }
375
375
  */
376
376
  timeSteps: PropTypes.shape({
@@ -161,7 +161,7 @@ StaticTimePicker.propTypes = {
161
161
  onError: PropTypes.func,
162
162
  /**
163
163
  * Callback fired on view change.
164
- * @template TView
164
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
165
165
  * @param {TView} view The new view.
166
166
  */
167
167
  onViewChange: PropTypes.func,
@@ -414,14 +414,14 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
414
414
  onChange: PropTypes.func,
415
415
  /**
416
416
  * Callback fired on focused view change.
417
- * @template TView
417
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
418
418
  * @param {TView} view The new view to focus or not.
419
419
  * @param {boolean} hasFocus `true` if the view should be focused.
420
420
  */
421
421
  onFocusedViewChange: PropTypes.func,
422
422
  /**
423
423
  * Callback fired on view change.
424
- * @template TView
424
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
425
425
  * @param {TView} view The new view.
426
426
  */
427
427
  onViewChange: PropTypes.func,
@@ -202,7 +202,7 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
202
202
  onSelectedSectionsChange: PropTypes.func,
203
203
  /**
204
204
  * Callback fired on view change.
205
- * @template TView
205
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
206
206
  * @param {TView} view The new view.
207
207
  */
208
208
  onViewChange: PropTypes.func,
@@ -280,8 +280,8 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
280
280
  thresholdToRenderTimeInASingleColumn: PropTypes.number,
281
281
  /**
282
282
  * The time steps between two time unit options.
283
- * For example, if `timeStep.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
284
- * When single column time renderer is used, only `timeStep.minutes` will be used.
283
+ * For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
284
+ * When single column time renderer is used, only `timeSteps.minutes` will be used.
285
285
  * @default{ hours: 1, minutes: 5, seconds: 5 }
286
286
  */
287
287
  timeSteps: PropTypes.shape({
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v8.8.0
2
+ * @mui/x-date-pickers v8.9.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -129,8 +129,11 @@ function useClickAwayListener(active, onClickAway) {
129
129
  });
130
130
 
131
131
  // Keep track of mouse/touch events that bubbled up through the portal.
132
- const handleSynthetic = () => {
133
- syntheticEventRef.current = true;
132
+ const handleSynthetic = event => {
133
+ // Ignore events handled by our internal components
134
+ if (!event.defaultMuiPrevented) {
135
+ syntheticEventRef.current = true;
136
+ }
134
137
  };
135
138
  React.useEffect(() => {
136
139
  if (active) {
@@ -220,6 +223,10 @@ export function PickerPopper(inProps) {
220
223
  popupRef,
221
224
  reduceAnimations
222
225
  } = usePickerContext();
226
+ const {
227
+ ownerState: pickerOwnerState,
228
+ rootRefObject
229
+ } = usePickerPrivateContext();
223
230
  const {
224
231
  dismissViews,
225
232
  getCurrentViewMode,
@@ -244,7 +251,7 @@ export function PickerPopper(inProps) {
244
251
  return;
245
252
  }
246
253
  if (open) {
247
- lastFocusedElementRef.current = getActiveElement(document);
254
+ lastFocusedElementRef.current = getActiveElement(rootRefObject.current);
248
255
  } else if (lastFocusedElementRef.current && lastFocusedElementRef.current instanceof HTMLElement) {
249
256
  // make sure the button is flushed with updated label, before returning focus to it
250
257
  // avoids issue, where screen reader could fail to announce selected date after selection
@@ -254,16 +261,12 @@ export function PickerPopper(inProps) {
254
261
  }
255
262
  });
256
263
  }
257
- }, [open, viewContainerRole, getCurrentViewMode]);
264
+ }, [open, viewContainerRole, getCurrentViewMode, rootRefObject]);
258
265
  const classes = useUtilityClasses(classesProp);
259
- const {
260
- ownerState: pickerOwnerState,
261
- rootRefObject
262
- } = usePickerPrivateContext();
263
266
  const handleClickAway = useEventCallback(() => {
264
267
  if (viewContainerRole === 'tooltip') {
265
268
  executeInTheNextEventLoopTick(() => {
266
- if (rootRefObject.current?.contains(getActiveElement(document)) || popupRef.current?.contains(getActiveElement(document))) {
269
+ if (rootRefObject.current?.contains(getActiveElement(rootRefObject.current)) || popupRef.current?.contains(getActiveElement(popupRef.current))) {
267
270
  return;
268
271
  }
269
272
  dismissViews();
@@ -1,3 +1,4 @@
1
+ import ownerDocument from '@mui/utils/ownerDocument';
1
2
  import { getActiveElement } from "../../utils/utils.js";
2
3
  export function syncSelectionToDOM(parameters) {
3
4
  const {
@@ -12,7 +13,7 @@ export function syncSelectionToDOM(parameters) {
12
13
  if (!domGetters.isReady()) {
13
14
  return;
14
15
  }
15
- const selection = document.getSelection();
16
+ const selection = ownerDocument(domGetters.getRoot()).getSelection();
16
17
  if (!selection) {
17
18
  return;
18
19
  }
@@ -28,7 +29,7 @@ export function syncSelectionToDOM(parameters) {
28
29
  }
29
30
 
30
31
  // On multi input range pickers we want to update selection range only for the active input
31
- if (!domGetters.getRoot().contains(getActiveElement(document))) {
32
+ if (!domGetters.getRoot().contains(getActiveElement(domGetters.getRoot()))) {
32
33
  return;
33
34
  }
34
35
  const range = new window.Range();
@@ -116,7 +116,7 @@ export function useFieldRootProps(parameters) {
116
116
  if (focused || disabled || !domGetters.isReady()) {
117
117
  return;
118
118
  }
119
- const activeElement = getActiveElement(document);
119
+ const activeElement = getActiveElement(domGetters.getRoot());
120
120
  setFocused(true);
121
121
  const isFocusInsideASection = domGetters.getSectionIndexFromDOMElement(activeElement) != null;
122
122
  if (!isFocusInsideASection) {
@@ -128,7 +128,7 @@ export function useFieldRootProps(parameters) {
128
128
  if (!domGetters.isReady()) {
129
129
  return;
130
130
  }
131
- const activeElement = getActiveElement(document);
131
+ const activeElement = getActiveElement(domGetters.getRoot());
132
132
  const shouldBlur = !domGetters.getRoot().contains(activeElement);
133
133
  if (shouldBlur) {
134
134
  setFocused(false);
@@ -133,7 +133,7 @@ export const useFieldV6TextField = parameters => {
133
133
  setSelectedSections(sectionIndex);
134
134
  }
135
135
  function focusField(newSelectedSection = 0) {
136
- if (getActiveElement(document) === inputRef.current) {
136
+ if (getActiveElement(inputRef.current) === inputRef.current) {
137
137
  return;
138
138
  }
139
139
  inputRef.current?.focus();
@@ -298,7 +298,7 @@ export const useFieldV6TextField = parameters => {
298
298
  const valueStr = React.useMemo(() => state.tempValueStrAndroid ?? fieldValueManager.getV6InputValueFromSections(state.sections, localizedDigits, isRtl), [state.sections, fieldValueManager, state.tempValueStrAndroid, localizedDigits, isRtl]);
299
299
  React.useEffect(() => {
300
300
  // Select all the sections when focused on mount (`autoFocus = true` on the input)
301
- if (inputRef.current && inputRef.current === getActiveElement(document)) {
301
+ if (inputRef.current && inputRef.current === getActiveElement(inputRef.current)) {
302
302
  setSelectedSections('all');
303
303
  }
304
304
  }, []); // eslint-disable-line react-hooks/exhaustive-deps
@@ -321,7 +321,7 @@ export const useFieldV6TextField = parameters => {
321
321
  // On multi input range pickers we want to update selection range only for the active input
322
322
  // This helps to avoid the focus jumping on Safari https://github.com/mui/mui-x/issues/9003
323
323
  // because WebKit implements the `setSelectionRange` based on the spec: https://bugs.webkit.org/show_bug.cgi?id=224425
324
- if (inputRef.current !== getActiveElement(document)) {
324
+ if (inputRef.current !== getActiveElement(inputRef.current)) {
325
325
  return;
326
326
  }
327
327
 
@@ -334,14 +334,14 @@ export const useFieldV6TextField = parameters => {
334
334
  const selectionStart = selectedSection.type === 'empty' ? selectedSection.startInInput - selectedSection.startSeparator.length : selectedSection.startInInput;
335
335
  const selectionEnd = selectedSection.type === 'empty' ? selectedSection.endInInput + selectedSection.endSeparator.length : selectedSection.endInInput;
336
336
  if (selectionStart !== inputRef.current.selectionStart || selectionEnd !== inputRef.current.selectionEnd) {
337
- if (inputRef.current === getActiveElement(document)) {
337
+ if (inputRef.current === getActiveElement(inputRef.current)) {
338
338
  inputRef.current.setSelectionRange(selectionStart, selectionEnd);
339
339
  }
340
340
  }
341
341
  selectionSyncTimeout.start(0, () => {
342
342
  // handle case when the selection is not updated correctly
343
343
  // could happen on Android
344
- if (inputRef.current && inputRef.current === getActiveElement(document) &&
344
+ if (inputRef.current && inputRef.current === getActiveElement(inputRef.current) &&
345
345
  // The section might loose all selection, where `selectionStart === selectionEnd`
346
346
  // https://github.com/mui/mui-x/pull/13652
347
347
  inputRef.current.selectionStart === inputRef.current.selectionEnd && (inputRef.current.selectionStart !== selectionStart || inputRef.current.selectionEnd !== selectionEnd)) {
@@ -364,7 +364,7 @@ export const useFieldV6TextField = parameters => {
364
364
  }
365
365
  return 'numeric';
366
366
  }, [activeSectionIndex, state.sections]);
367
- const inputHasFocus = inputRef.current && inputRef.current === getActiveElement(document);
367
+ const inputHasFocus = inputRef.current && inputRef.current === getActiveElement(inputRef.current);
368
368
  const shouldShowPlaceholder = !inputHasFocus && areAllSectionsEmpty;
369
369
  React.useImperativeHandle(unstableFieldRef, () => ({
370
370
  getSections: () => state.sections,
@@ -407,5 +407,5 @@ export const useFieldV6TextField = parameters => {
407
407
  });
408
408
  };
409
409
  function isFieldFocused(inputRef) {
410
- return inputRef.current === getActiveElement(document);
410
+ return inputRef.current === getActiveElement(inputRef.current);
411
411
  }
@@ -243,13 +243,13 @@ export const useFieldV7TextField = parameters => {
243
243
  });
244
244
  };
245
245
  function getActiveSectionIndex(sectionListRef) {
246
- const activeElement = getActiveElement(document);
246
+ const activeElement = getActiveElement(sectionListRef.current?.getRoot());
247
247
  if (!activeElement || !sectionListRef.current || !sectionListRef.current.getRoot().contains(activeElement)) {
248
248
  return null;
249
249
  }
250
250
  return sectionListRef.current.getSectionIndexFromDOMElement(activeElement);
251
251
  }
252
252
  function isFieldFocused(sectionListRef) {
253
- const activeElement = getActiveElement(document);
253
+ const activeElement = getActiveElement(sectionListRef.current?.getRoot());
254
254
  return !!sectionListRef.current && sectionListRef.current.getRoot().contains(activeElement);
255
255
  }
@@ -16,7 +16,7 @@ export interface UseViewsOptions<TValue extends PickerValidValue, TView extends
16
16
  onChange: (value: TValue, selectionState?: PickerSelectionState, selectedView?: TView) => void;
17
17
  /**
18
18
  * Callback fired on view change.
19
- * @template TView
19
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
20
20
  * @param {TView} view The new view.
21
21
  */
22
22
  onViewChange?: (view: TView) => void;
@@ -49,7 +49,7 @@ export interface UseViewsOptions<TValue extends PickerValidValue, TView extends
49
49
  focusedView?: TView | null;
50
50
  /**
51
51
  * Callback fired on focused view change.
52
- * @template TView
52
+ * @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
53
53
  * @param {TView} view The new view to focus or not.
54
54
  * @param {boolean} hasFocus `true` if the view should be focused.
55
55
  */
@@ -45,8 +45,8 @@ export interface DigitalTimePickerProps extends Omit<ExportedDigitalClockProps,
45
45
  thresholdToRenderTimeInASingleColumn?: number;
46
46
  /**
47
47
  * The time steps between two time unit options.
48
- * For example, if `timeStep.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
49
- * When single column time renderer is used, only `timeStep.minutes` will be used.
48
+ * For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
49
+ * When single column time renderer is used, only `timeSteps.minutes` will be used.
50
50
  * @default{ hours: 1, minutes: 5, seconds: 5 }
51
51
  */
52
52
  timeSteps?: TimeStepOptions;
@@ -69,7 +69,7 @@ export interface DigitalClockOnlyProps extends DigitalClockOnlyBaseProps {
69
69
  export interface MultiSectionDigitalClockOnlyProps extends DigitalClockOnlyBaseProps {
70
70
  /**
71
71
  * The time steps between two time unit options.
72
- * For example, if `timeStep.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
72
+ * For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
73
73
  * @default{ hours: 1, minutes: 5, seconds: 5 }
74
74
  */
75
75
  timeSteps?: TimeStepOptions;
@@ -4,7 +4,13 @@ import * as React from 'react';
4
4
  export declare function arrayIncludes<T>(array: T[] | readonly T[], itemOrItems: T | T[]): boolean;
5
5
  export declare const onSpaceOrEnter: (innerFn: (ev: React.MouseEvent<any> | React.KeyboardEvent<any>) => void, externalEvent?: (event: React.KeyboardEvent<any>) => void) => (event: React.KeyboardEvent) => void;
6
6
  export declare const executeInTheNextEventLoopTick: (fn: () => void) => void;
7
- export declare const getActiveElement: (root?: Document | ShadowRoot) => Element | null;
7
+ /**
8
+ * Gets the currently active element within a given node's document.
9
+ * This function traverses shadow DOM if necessary.
10
+ * @param node - The node from which to get the active element.
11
+ * @returns The currently active element, or null if none is found.
12
+ */
13
+ export declare const getActiveElement: (node: Node | null | undefined) => Element | null;
8
14
  /**
9
15
  * Gets the index of the focused list item in a given ul list element.
10
16
  *
@@ -1,3 +1,4 @@
1
+ import ownerDocument from '@mui/utils/ownerDocument';
1
2
  /* Use it instead of .includes method for IE support */
2
3
  export function arrayIncludes(array, itemOrItems) {
3
4
  if (Array.isArray(itemOrItems)) {
@@ -22,17 +23,27 @@ export const executeInTheNextEventLoopTick = fn => {
22
23
  };
23
24
 
24
25
  // https://www.abeautifulsite.net/posts/finding-the-active-element-in-a-shadow-root/
25
- export const getActiveElement = (root = document) => {
26
+ const getActiveElementInternal = (root = document) => {
26
27
  const activeEl = root.activeElement;
27
28
  if (!activeEl) {
28
29
  return null;
29
30
  }
30
31
  if (activeEl.shadowRoot) {
31
- return getActiveElement(activeEl.shadowRoot);
32
+ return getActiveElementInternal(activeEl.shadowRoot);
32
33
  }
33
34
  return activeEl;
34
35
  };
35
36
 
37
+ /**
38
+ * Gets the currently active element within a given node's document.
39
+ * This function traverses shadow DOM if necessary.
40
+ * @param node - The node from which to get the active element.
41
+ * @returns The currently active element, or null if none is found.
42
+ */
43
+ export const getActiveElement = node => {
44
+ return getActiveElementInternal(ownerDocument(node));
45
+ };
46
+
36
47
  /**
37
48
  * Gets the index of the focused list item in a given ul list element.
38
49
  *
@@ -41,7 +52,7 @@ export const getActiveElement = (root = document) => {
41
52
  */
42
53
  export const getFocusedListItemIndex = listElement => {
43
54
  const children = Array.from(listElement.children);
44
- return children.indexOf(getActiveElement(document));
55
+ return children.indexOf(getActiveElement(listElement));
45
56
  };
46
57
  export const DEFAULT_DESKTOP_MODE_MEDIA_QUERY = '@media (pointer: fine)';
47
58
  export function mergeSx(...sxProps) {
@@ -31,8 +31,7 @@ const koKRPickers = {
31
31
  dateTimePickerToolbarTitle: '날짜 & 시간 선택하기',
32
32
  timePickerToolbarTitle: '시간 선택하기',
33
33
  dateRangePickerToolbarTitle: '날짜 범위 선택하기',
34
- // timeRangePickerToolbarTitle: 'Select time range',
35
-
34
+ timeRangePickerToolbarTitle: '시간 범위 선택하기',
36
35
  // Clock labels
37
36
  clockLabelText: (view, formattedTime) => `${views[view]} 선택하세요. ${!formattedTime ? '시간을 선택하지 않았습니다.' : `현재 선택된 시간은 ${formattedTime}입니다.`}`,
38
37
  hoursClockNumberText: hours => `${hours}시`,
@@ -48,7 +47,7 @@ const koKRPickers = {
48
47
  // Open Picker labels
49
48
  openDatePickerDialogue: formattedDate => formattedDate ? `날짜를 선택하세요. 현재 선택된 날짜는 ${formattedDate}입니다.` : '날짜를 선택하세요',
50
49
  openTimePickerDialogue: formattedTime => formattedTime ? `시간을 선택하세요. 현재 선택된 시간은 ${formattedTime}입니다.` : '시간을 선택하세요',
51
- // openRangePickerDialogue: formattedRange => formattedRange ? `Choose range, selected range is ${formattedRange}` : 'Choose range',
50
+ openRangePickerDialogue: formattedRange => formattedRange ? `범위를 선택하세요. 현재 선택된 범위는 ${formattedRange}입니다.` : '범위를 선택하세요',
52
51
  fieldClearLabel: '지우기',
53
52
  // Table labels
54
53
  timeTableLabel: '선택한 시간',
@@ -70,8 +69,7 @@ const koKRPickers = {
70
69
  hours: '시간',
71
70
  minutes: '분',
72
71
  seconds: '초',
73
- // meridiem: 'Meridiem',
74
-
72
+ meridiem: '오전/오후',
75
73
  // Common
76
74
  empty: '공란'
77
75
  };
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v8.8.0
2
+ * @mui/x-date-pickers v8.9.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -136,8 +136,11 @@ function useClickAwayListener(active, onClickAway) {
136
136
  });
137
137
 
138
138
  // Keep track of mouse/touch events that bubbled up through the portal.
139
- const handleSynthetic = () => {
140
- syntheticEventRef.current = true;
139
+ const handleSynthetic = event => {
140
+ // Ignore events handled by our internal components
141
+ if (!event.defaultMuiPrevented) {
142
+ syntheticEventRef.current = true;
143
+ }
141
144
  };
142
145
  React.useEffect(() => {
143
146
  if (active) {
@@ -227,6 +230,10 @@ function PickerPopper(inProps) {
227
230
  popupRef,
228
231
  reduceAnimations
229
232
  } = (0, _hooks.usePickerContext)();
233
+ const {
234
+ ownerState: pickerOwnerState,
235
+ rootRefObject
236
+ } = (0, _usePickerPrivateContext.usePickerPrivateContext)();
230
237
  const {
231
238
  dismissViews,
232
239
  getCurrentViewMode,
@@ -251,7 +258,7 @@ function PickerPopper(inProps) {
251
258
  return;
252
259
  }
253
260
  if (open) {
254
- lastFocusedElementRef.current = (0, _utils.getActiveElement)(document);
261
+ lastFocusedElementRef.current = (0, _utils.getActiveElement)(rootRefObject.current);
255
262
  } else if (lastFocusedElementRef.current && lastFocusedElementRef.current instanceof HTMLElement) {
256
263
  // make sure the button is flushed with updated label, before returning focus to it
257
264
  // avoids issue, where screen reader could fail to announce selected date after selection
@@ -261,16 +268,12 @@ function PickerPopper(inProps) {
261
268
  }
262
269
  });
263
270
  }
264
- }, [open, viewContainerRole, getCurrentViewMode]);
271
+ }, [open, viewContainerRole, getCurrentViewMode, rootRefObject]);
265
272
  const classes = useUtilityClasses(classesProp);
266
- const {
267
- ownerState: pickerOwnerState,
268
- rootRefObject
269
- } = (0, _usePickerPrivateContext.usePickerPrivateContext)();
270
273
  const handleClickAway = (0, _useEventCallback.default)(() => {
271
274
  if (viewContainerRole === 'tooltip') {
272
275
  (0, _utils.executeInTheNextEventLoopTick)(() => {
273
- if (rootRefObject.current?.contains((0, _utils.getActiveElement)(document)) || popupRef.current?.contains((0, _utils.getActiveElement)(document))) {
276
+ if (rootRefObject.current?.contains((0, _utils.getActiveElement)(rootRefObject.current)) || popupRef.current?.contains((0, _utils.getActiveElement)(popupRef.current))) {
274
277
  return;
275
278
  }
276
279
  dismissViews();
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.syncSelectionToDOM = syncSelectionToDOM;
8
+ var _ownerDocument = _interopRequireDefault(require("@mui/utils/ownerDocument"));
7
9
  var _utils = require("../../utils/utils");
8
10
  function syncSelectionToDOM(parameters) {
9
11
  const {
@@ -18,7 +20,7 @@ function syncSelectionToDOM(parameters) {
18
20
  if (!domGetters.isReady()) {
19
21
  return;
20
22
  }
21
- const selection = document.getSelection();
23
+ const selection = (0, _ownerDocument.default)(domGetters.getRoot()).getSelection();
22
24
  if (!selection) {
23
25
  return;
24
26
  }
@@ -34,7 +36,7 @@ function syncSelectionToDOM(parameters) {
34
36
  }
35
37
 
36
38
  // On multi input range pickers we want to update selection range only for the active input
37
- if (!domGetters.getRoot().contains((0, _utils.getActiveElement)(document))) {
39
+ if (!domGetters.getRoot().contains((0, _utils.getActiveElement)(domGetters.getRoot()))) {
38
40
  return;
39
41
  }
40
42
  const range = new window.Range();