@mtes-mct/monitor-ui 7.6.0 → 7.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/cypress.config.d.ts +2 -0
  3. package/index.js +158 -157
  4. package/index.js.map +1 -1
  5. package/package.json +2 -2
  6. package/{fields → src/fields}/DateRangePicker/NumberInput.d.ts +5 -5
  7. /package/{GlobalStyle.d.ts → src/GlobalStyle.d.ts} +0 -0
  8. /package/{OnlyFontGlobalStyle.d.ts → src/OnlyFontGlobalStyle.d.ts} +0 -0
  9. /package/{ThemeProvider.d.ts → src/ThemeProvider.d.ts} +0 -0
  10. /package/{components → src/components}/Dialog/Action.d.ts +0 -0
  11. /package/{components → src/components}/Dialog/Body.d.ts +0 -0
  12. /package/{components → src/components}/Dialog/Title.d.ts +0 -0
  13. /package/{components → src/components}/Dialog/index.d.ts +0 -0
  14. /package/{components → src/components}/Dropdown/Item.d.ts +0 -0
  15. /package/{components → src/components}/Dropdown/index.d.ts +0 -0
  16. /package/{components → src/components}/NewWindow.d.ts +0 -0
  17. /package/{components → src/components}/Notifier/NotificationEvent.d.ts +0 -0
  18. /package/{components → src/components}/Notifier/index.d.ts +0 -0
  19. /package/{components → src/components}/SideMenu/Button.d.ts +0 -0
  20. /package/{components → src/components}/SideMenu/index.d.ts +0 -0
  21. /package/{components → src/components}/SingleTag.d.ts +0 -0
  22. /package/{constants.d.ts → src/constants.d.ts} +0 -0
  23. /package/{elements → src/elements}/Button.d.ts +0 -0
  24. /package/{elements → src/elements}/Field.d.ts +0 -0
  25. /package/{elements → src/elements}/FieldError.d.ts +0 -0
  26. /package/{elements → src/elements}/Fieldset.d.ts +0 -0
  27. /package/{elements → src/elements}/IconBox.d.ts +0 -0
  28. /package/{elements → src/elements}/IconButton.d.ts +0 -0
  29. /package/{elements → src/elements}/Label.d.ts +0 -0
  30. /package/{elements → src/elements}/Legend.d.ts +0 -0
  31. /package/{elements → src/elements}/Table/SimpleTable.d.ts +0 -0
  32. /package/{elements → src/elements}/Tag/Disk.d.ts +0 -0
  33. /package/{elements → src/elements}/Tag/index.d.ts +0 -0
  34. /package/{elements → src/elements}/TagGroup.d.ts +0 -0
  35. /package/{fields → src/fields}/Checkbox.d.ts +0 -0
  36. /package/{fields → src/fields}/CoordinatesInput/DDCoordinatesInput.d.ts +0 -0
  37. /package/{fields → src/fields}/CoordinatesInput/DMDCoordinatesInput.d.ts +0 -0
  38. /package/{fields → src/fields}/CoordinatesInput/DMSCoordinatesInput.d.ts +0 -0
  39. /package/{fields → src/fields}/CoordinatesInput/index.d.ts +0 -0
  40. /package/{fields → src/fields}/DatePicker/CalendarPicker.d.ts +0 -0
  41. /package/{fields → src/fields}/DatePicker/index.d.ts +0 -0
  42. /package/{fields → src/fields}/DateRangePicker/DateInput.d.ts +0 -0
  43. /package/{fields → src/fields}/DateRangePicker/RangeCalendarPicker.d.ts +0 -0
  44. /package/{fields → src/fields}/DateRangePicker/RangedTimePicker.d.ts +0 -0
  45. /package/{fields → src/fields}/DateRangePicker/TimeInput.d.ts +0 -0
  46. /package/{fields → src/fields}/DateRangePicker/constants.d.ts +0 -0
  47. /package/{fields → src/fields}/DateRangePicker/index.d.ts +0 -0
  48. /package/{fields → src/fields}/DateRangePicker/types.d.ts +0 -0
  49. /package/{fields → src/fields}/DateRangePicker/utils.d.ts +0 -0
  50. /package/{fields → src/fields}/MultiCheckbox.d.ts +0 -0
  51. /package/{fields → src/fields}/MultiRadio.d.ts +0 -0
  52. /package/{fields → src/fields}/MultiSelect.d.ts +0 -0
  53. /package/{fields → src/fields}/MultiZoneEditor/index.d.ts +0 -0
  54. /package/{fields → src/fields}/NumberInput.d.ts +0 -0
  55. /package/{fields → src/fields}/Search.d.ts +0 -0
  56. /package/{fields → src/fields}/Select.d.ts +0 -0
  57. /package/{fields → src/fields}/TextInput.d.ts +0 -0
  58. /package/{fields → src/fields}/Textarea.d.ts +0 -0
  59. /package/{formiks → src/formiks}/FormikCheckbox.d.ts +0 -0
  60. /package/{formiks → src/formiks}/FormikCoordinatesInput.d.ts +0 -0
  61. /package/{formiks → src/formiks}/FormikDatePicker.d.ts +0 -0
  62. /package/{formiks → src/formiks}/FormikDateRangePicker.d.ts +0 -0
  63. /package/{formiks → src/formiks}/FormikEffect.d.ts +0 -0
  64. /package/{formiks → src/formiks}/FormikMultiCheckbox.d.ts +0 -0
  65. /package/{formiks → src/formiks}/FormikMultiRadio.d.ts +0 -0
  66. /package/{formiks → src/formiks}/FormikMultiSelect.d.ts +0 -0
  67. /package/{formiks → src/formiks}/FormikNumberInput.d.ts +0 -0
  68. /package/{formiks → src/formiks}/FormikSearch.d.ts +0 -0
  69. /package/{formiks → src/formiks}/FormikSelect.d.ts +0 -0
  70. /package/{formiks → src/formiks}/FormikTextInput.d.ts +0 -0
  71. /package/{formiks → src/formiks}/FormikTextarea.d.ts +0 -0
  72. /package/{hooks → src/hooks}/useClickOutsideEffect.d.ts +0 -0
  73. /package/{hooks → src/hooks}/useFieldControl.d.ts +0 -0
  74. /package/{hooks → src/hooks}/useFieldUndefineEffect.d.ts +0 -0
  75. /package/{hooks → src/hooks}/useForceUpdate.d.ts +0 -0
  76. /package/{hooks → src/hooks}/useKey.d.ts +0 -0
  77. /package/{hooks → src/hooks}/useNewWindow/context.d.ts +0 -0
  78. /package/{hooks → src/hooks}/useNewWindow/index.d.ts +0 -0
  79. /package/{hooks → src/hooks}/useNewWindow/types.d.ts +0 -0
  80. /package/{hooks → src/hooks}/usePreventWheelEvent.d.ts +0 -0
  81. /package/{hooks → src/hooks}/usePrevious.d.ts +0 -0
  82. /package/{icons → src/icons}/ActivityFeed.d.ts +0 -0
  83. /package/{icons → src/icons}/Alert.d.ts +0 -0
  84. /package/{icons → src/icons}/Anchor.d.ts +0 -0
  85. /package/{icons → src/icons}/Archive.d.ts +0 -0
  86. /package/{icons → src/icons}/Attention.d.ts +0 -0
  87. /package/{icons → src/icons}/Calendar.d.ts +0 -0
  88. /package/{icons → src/icons}/Check.d.ts +0 -0
  89. /package/{icons → src/icons}/Chevron.d.ts +0 -0
  90. /package/{icons → src/icons}/Clock.d.ts +0 -0
  91. /package/{icons → src/icons}/Close.d.ts +0 -0
  92. /package/{icons → src/icons}/Confirm.d.ts +0 -0
  93. /package/{icons → src/icons}/Control.d.ts +0 -0
  94. /package/{icons → src/icons}/Delete.d.ts +0 -0
  95. /package/{icons → src/icons}/Display.d.ts +0 -0
  96. /package/{icons → src/icons}/DoubleChevron.d.ts +0 -0
  97. /package/{icons → src/icons}/Download.d.ts +0 -0
  98. /package/{icons → src/icons}/Drapeau.d.ts +0 -0
  99. /package/{icons → src/icons}/Duplicate.d.ts +0 -0
  100. /package/{icons → src/icons}/Edit.d.ts +0 -0
  101. /package/{icons → src/icons}/EditBis.d.ts +0 -0
  102. /package/{icons → src/icons}/Expand.d.ts +0 -0
  103. /package/{icons → src/icons}/Favorite.d.ts +0 -0
  104. /package/{icons → src/icons}/FilledArrow.d.ts +0 -0
  105. /package/{icons → src/icons}/Filter.d.ts +0 -0
  106. /package/{icons → src/icons}/FilterBis.d.ts +0 -0
  107. /package/{icons → src/icons}/Fishery.d.ts +0 -0
  108. /package/{icons → src/icons}/FishingEngine.d.ts +0 -0
  109. /package/{icons → src/icons}/FleetSegment.d.ts +0 -0
  110. /package/{icons → src/icons}/Focus.d.ts +0 -0
  111. /package/{icons → src/icons}/FocusVessel.d.ts +0 -0
  112. /package/{icons → src/icons}/FocusZones.d.ts +0 -0
  113. /package/{icons → src/icons}/Hide.d.ts +0 -0
  114. /package/{icons → src/icons}/Info.d.ts +0 -0
  115. /package/{icons → src/icons}/Infringement.d.ts +0 -0
  116. /package/{icons → src/icons}/Landmark.d.ts +0 -0
  117. /package/{icons → src/icons}/List.d.ts +0 -0
  118. /package/{icons → src/icons}/MapLayers.d.ts +0 -0
  119. /package/{icons → src/icons}/MeasureAngle.d.ts +0 -0
  120. /package/{icons → src/icons}/MeasureBrokenLine.d.ts +0 -0
  121. /package/{icons → src/icons}/MeasureCircle.d.ts +0 -0
  122. /package/{icons → src/icons}/MeasureLine.d.ts +0 -0
  123. /package/{icons → src/icons}/Minus.d.ts +0 -0
  124. /package/{icons → src/icons}/MissionAction.d.ts +0 -0
  125. /package/{icons → src/icons}/More.d.ts +0 -0
  126. /package/{icons → src/icons}/Note.d.ts +0 -0
  127. /package/{icons → src/icons}/Observation.d.ts +0 -0
  128. /package/{icons → src/icons}/Pin.d.ts +0 -0
  129. /package/{icons → src/icons}/PinFilled.d.ts +0 -0
  130. /package/{icons → src/icons}/Pinpoint.d.ts +0 -0
  131. /package/{icons → src/icons}/PinpointHide.d.ts +0 -0
  132. /package/{icons → src/icons}/Plane.d.ts +0 -0
  133. /package/{icons → src/icons}/Plus.d.ts +0 -0
  134. /package/{icons → src/icons}/Reject.d.ts +0 -0
  135. /package/{icons → src/icons}/Report.d.ts +0 -0
  136. /package/{icons → src/icons}/Save.d.ts +0 -0
  137. /package/{icons → src/icons}/Search.d.ts +0 -0
  138. /package/{icons → src/icons}/SelectCircle.d.ts +0 -0
  139. /package/{icons → src/icons}/SelectPolygon.d.ts +0 -0
  140. /package/{icons → src/icons}/SelectRectangle.d.ts +0 -0
  141. /package/{icons → src/icons}/SelectZone.d.ts +0 -0
  142. /package/{icons → src/icons}/Semaphore.d.ts +0 -0
  143. /package/{icons → src/icons}/ShowErsMessages.d.ts +0 -0
  144. /package/{icons → src/icons}/ShowXml.d.ts +0 -0
  145. /package/{icons → src/icons}/SortingArrows.d.ts +0 -0
  146. /package/{icons → src/icons}/Summary.d.ts +0 -0
  147. /package/{icons → src/icons}/Tag.d.ts +0 -0
  148. /package/{icons → src/icons}/Target.d.ts +0 -0
  149. /package/{icons → src/icons}/Unlock.d.ts +0 -0
  150. /package/{icons → src/icons}/Vessel.d.ts +0 -0
  151. /package/{icons → src/icons}/ViewOnMap.d.ts +0 -0
  152. /package/{icons → src/icons}/Vms.d.ts +0 -0
  153. /package/{icons → src/icons}/index.d.ts +0 -0
  154. /package/{index.d.ts → src/index.d.ts} +0 -0
  155. /package/{libs → src/libs}/CustomSearch.d.ts +0 -0
  156. /package/{theme.d.ts → src/theme.d.ts} +0 -0
  157. /package/{types.d.ts → src/types.d.ts} +0 -0
  158. /package/{utils → src/utils}/cleanString.d.ts +0 -0
  159. /package/{utils → src/utils}/coordinates.d.ts +0 -0
  160. /package/{utils → src/utils}/customDayjs.d.ts +0 -0
  161. /package/{utils → src/utils}/getLocalizedDayjs.d.ts +0 -0
  162. /package/{utils → src/utils}/getPseudoRandomString.d.ts +0 -0
  163. /package/{utils → src/utils}/getRsuiteDataFromOptions.d.ts +0 -0
  164. /package/{utils → src/utils}/getRsuiteValueFromOptionValue.d.ts +0 -0
  165. /package/{utils → src/utils}/getUtcizedDayjs.d.ts +0 -0
  166. /package/{utils → src/utils}/isDaylightSavingTimeDate.d.ts +0 -0
  167. /package/{utils → src/utils}/isNumeric.d.ts +0 -0
  168. /package/{utils → src/utils}/logSoftError.d.ts +0 -0
  169. /package/{utils → src/utils}/normalizeString.d.ts +0 -0
  170. /package/{utils → src/utils}/sortDates.d.ts +0 -0
  171. /package/{utils → src/utils}/stopMouseEventPropagation.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # [7.6.0](https://github.com/MTES-MCT/monitor-ui/compare/v7.5.0...v7.6.0) (2023-07-05)
2
+
3
+
4
+ ### Features
5
+
6
+ * **theme:** add amp colors ([46cf039](https://github.com/MTES-MCT/monitor-ui/commit/46cf039a94a403ff9522a521c423a1488d652337))
7
+ * **theme:** add story for colors + yarncache ([b848553](https://github.com/MTES-MCT/monitor-ui/commit/b84855336c0dd5c6cc988e1c3a81a82d0f32de55))
8
+
1
9
  # [7.5.0](https://github.com/MTES-MCT/monitor-ui/compare/v7.4.3...v7.5.0) (2023-06-29)
2
10
 
3
11
 
@@ -0,0 +1,2 @@
1
+ declare const _default: Cypress.ConfigOptions<any>;
2
+ export default _default;
package/index.js CHANGED
@@ -21538,6 +21538,15 @@ function NumberInputWithRef({ isLight, max, min, onBack, onBlur, onFilled, onFoc
21538
21538
  }
21539
21539
  }, [max, min, onFilled, onFormatError, onInput, size]);
21540
21540
  const handleKeyDown = useCallback((event) => {
21541
+ if (!inputRef.current) {
21542
+ return;
21543
+ }
21544
+ if (onBack && event.key === 'Backspace' && !inputRef.current.value.length) {
21545
+ event.preventDefault();
21546
+ onBack();
21547
+ }
21548
+ }, [onBack]);
21549
+ const handleKeyUp = useCallback((event) => {
21541
21550
  if (!inputRef.current) {
21542
21551
  return;
21543
21552
  }
@@ -21559,12 +21568,17 @@ function NumberInputWithRef({ isLight, max, min, onBack, onBlur, onFilled, onFoc
21559
21568
  onNext();
21560
21569
  return;
21561
21570
  }
21562
- if (onBack && event.key === 'Backspace' && !inputRef.current.value.length) {
21571
+ // TODO Find a better solution that this dirty hack handling "onRefilled" case.
21572
+ if (onNext &&
21573
+ inputRef.current.value.length === size &&
21574
+ inputRef.current.selectionStart === inputRef.current.value.length &&
21575
+ // We don't want to call that function when the user is selecting the input text
21576
+ inputRef.current.selectionEnd === inputRef.current.selectionStart) {
21563
21577
  event.preventDefault();
21564
- onBack();
21578
+ onNext();
21565
21579
  }
21566
- }, [onBack, onNext, onPrevious]);
21567
- return (jsx(StyledNumberInput, { ref: inputRef, "$isLight": isLight, "$size": size, defaultValue: value, maxLength: size, onBlur: handleBlur, onFocus: handleFocus, onInput: handleInput, onKeyDown: handleKeyDown, pattern: "\\d*", placeholder: placeholder, type: "text", ...nativeProps }, String(value)));
21580
+ }, [onNext, onPrevious, size]);
21581
+ return (jsx(StyledNumberInput, { ref: inputRef, "$isLight": isLight, "$size": size, defaultValue: value, maxLength: size, onBlur: handleBlur, onFocus: handleFocus, onInput: handleInput, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, pattern: "\\d*", placeholder: placeholder, type: "text", ...nativeProps }, String(value)));
21568
21582
  }
21569
21583
  const NumberInput$1 = forwardRef(NumberInputWithRef);
21570
21584
  const StyledNumberInput = styled.input `
@@ -21601,6 +21615,7 @@ function DateInputWithRef({ baseContainer, disabled = false, isCompact, isEndDat
21601
21615
  }
21602
21616
  return lastValueBeforeFocusRef.current;
21603
21617
  }, [isFocused, value]);
21618
+ const key = JSON.stringify(lastValueBeforeFocusRef.current);
21604
21619
  useImperativeHandle(ref, () => ({
21605
21620
  box: boxRef.current,
21606
21621
  contains: boxRef.current ? boxRef.current.contains.bind(boxRef.current) : () => false,
@@ -21658,7 +21673,7 @@ function DateInputWithRef({ baseContainer, disabled = false, isCompact, isEndDat
21658
21673
  ];
21659
21674
  onChange(nextDateTuple, isFilled);
21660
21675
  }, [baseDocument, onChange]);
21661
- return (jsxs(Box$b, { ref: boxRef, "$hasError": hasFormatError || hasValidationError, "$isCompact": isCompact, "$isDisabled": disabled, "$isFocused": isForcedFocused || isFocused, "$isLight": isLight, children: [jsxs("div", { children: [isRange && isStartDate && jsx("span", { children: "Du " }), isRange && isEndDate && jsx("span", { children: "Au " }), jsx(NumberInput$1, { ref: dayInputRef, "aria-label": `Jour${isRange && isStartDate ? ' de début' : ''}${isRange && isEndDate ? ' de fin' : ''}`, disabled: disabled, isLight: isLight, max: 31, min: 1, onBack: onBack, onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onInput: onInput, onNext: () => monthInputRef.current?.focus(), onPrevious: onPrevious, size: 2, value: controlledValue && controlledValue[2] }), "/", jsx(NumberInput$1, { ref: monthInputRef, "aria-label": `Mois${isRange && isStartDate ? ' de début' : ''}${isRange && isEndDate ? ' de fin' : ''}`, disabled: disabled, isLight: isLight, max: 12, min: 1, onBack: () => dayInputRef.current?.focus(), onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onInput: onInput, onNext: () => yearInputRef.current?.focus(), onPrevious: () => dayInputRef.current?.focus(), size: 2, value: controlledValue && controlledValue[1] }), "/", jsx(NumberInput$1, { ref: yearInputRef, "aria-label": `Année${isRange && isStartDate ? ' de début' : ''}${isRange && isEndDate ? ' de fin' : ''}`, disabled: disabled, isLight: isLight, max: 2030, min: 2020, onBack: () => monthInputRef.current?.focus(), onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onInput: onInput, onNext: onNext, onPrevious: () => monthInputRef.current?.focus(), size: 4, value: controlledValue && controlledValue[0] })] }), !isCompact && jsx(Calendar, {})] }));
21676
+ return (jsxs(Box$b, { ref: boxRef, "$hasError": hasFormatError || hasValidationError, "$isCompact": isCompact, "$isDisabled": disabled, "$isFocused": isForcedFocused || isFocused, "$isLight": isLight, children: [jsxs("div", { children: [isRange && isStartDate && jsx("span", { children: "Du " }), isRange && isEndDate && jsx("span", { children: "Au " }), jsx(NumberInput$1, { ref: dayInputRef, "aria-label": `Jour${isRange && isStartDate ? ' de début' : ''}${isRange && isEndDate ? ' de fin' : ''}`, disabled: disabled, isLight: isLight, max: 31, min: 1, onBack: onBack, onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onInput: onInput, onNext: () => monthInputRef.current?.focus(), onPrevious: onPrevious, size: 2, value: controlledValue && controlledValue[2] }, `${key}-day`), "/", jsx(NumberInput$1, { ref: monthInputRef, "aria-label": `Mois${isRange && isStartDate ? ' de début' : ''}${isRange && isEndDate ? ' de fin' : ''}`, disabled: disabled, isLight: isLight, max: 12, min: 1, onBack: () => dayInputRef.current?.focus(), onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onInput: onInput, onNext: () => yearInputRef.current?.focus(), onPrevious: () => dayInputRef.current?.focus(), size: 2, value: controlledValue && controlledValue[1] }, `${key}-month`), "/", jsx(NumberInput$1, { ref: yearInputRef, "aria-label": `Année${isRange && isStartDate ? ' de début' : ''}${isRange && isEndDate ? ' de fin' : ''}`, disabled: disabled, isLight: isLight, onBack: () => monthInputRef.current?.focus(), onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onInput: onInput, onNext: onNext, onPrevious: () => monthInputRef.current?.focus(), size: 4, value: controlledValue && controlledValue[0] }, `${key}-year`)] }), !isCompact && jsx(Calendar, {})] }));
21662
21677
  }
21663
21678
  const DateInput = forwardRef(DateInputWithRef);
21664
21679
  const Box$b = styled.div `
@@ -21916,23 +21931,23 @@ function DatePicker({ baseContainer, className, defaultValue, disabled = false,
21916
21931
  const dateInputRef = useRef(null);
21917
21932
  const timeInputRef = useRef(null);
21918
21933
  /* eslint-enable no-null/no-null */
21919
- const isCalendarPickerOpenRef = useRef(false);
21920
21934
  const hasMountedRef = useRef(false);
21921
21935
  const selectedUtcDateAsDayjsRef = useRef(defaultValue ? customDayjs(defaultValue) : undefined);
21922
21936
  const selectedUtcDateTupleRef = useRef(getUtcDateTupleFromDayjs(selectedUtcDateAsDayjsRef.current));
21923
21937
  const selectedUtcTimeTupleRef = useRef(getUtcTimeTupleFromDayjs(selectedUtcDateAsDayjsRef.current));
21924
- const previousDefaultValue = usePrevious(defaultValue);
21925
- const { forceUpdate } = useForceUpdate();
21938
+ const [isRangeCalendarPickerOpen, setIsRangeCalendarPickerOpen] = useState(false);
21926
21939
  const controlledClassName = useMemo(() => classnames('Field-DatePicker', className), [className]);
21927
21940
  const controlledError = useMemo(() => normalizeString(error), [error]);
21928
21941
  const defaultTimeTuple = useMemo(() => (isEndDate ? ['23', '59'] : ['00', '00']), [isEndDate]);
21929
21942
  const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
21943
+ const previousDefaultValue = usePrevious(defaultValue);
21944
+ const { forceUpdate } = useForceUpdate();
21930
21945
  const calendarPickerDefaultValue = useMemo(() => selectedUtcDateTupleRef.current
21931
21946
  ? getUtcDateFromDateAndTimeTuple(selectedUtcDateTupleRef.current, defaultTimeTuple)
21932
21947
  : undefined,
21933
21948
  // eslint-disable-next-line react-hooks/exhaustive-deps
21934
21949
  [selectedUtcDateTupleRef.current]);
21935
- const submit = useCallback(() => {
21950
+ const callOnChange = useCallback(() => {
21936
21951
  if (!onChange || !selectedUtcDateAsDayjsRef.current) {
21937
21952
  return;
21938
21953
  }
@@ -21944,10 +21959,26 @@ function DatePicker({ baseContainer, className, defaultValue, disabled = false,
21944
21959
  onChange(nextDateAsDayjs.toDate());
21945
21960
  }
21946
21961
  }, [isStringDate, onChange]);
21962
+ const callOnChangeUndefinedIfInputsAreEmpty = useCallback(() => {
21963
+ if (!dateInputRef.current || !onChange) {
21964
+ return;
21965
+ }
21966
+ const [year, month, day] = dateInputRef.current.getValueAsPartialDateTuple();
21967
+ if (!withTime && !year && !month && !day) {
21968
+ onChange(undefined);
21969
+ return;
21970
+ }
21971
+ if (!timeInputRef.current) {
21972
+ return;
21973
+ }
21974
+ const [hour, minute] = timeInputRef.current.getValueAsPartialTimeTuple();
21975
+ if (!year && !month && !day && !hour && !minute) {
21976
+ onChange(undefined);
21977
+ }
21978
+ }, [onChange, withTime]);
21947
21979
  const closeCalendarPicker = useCallback(() => {
21948
- isCalendarPickerOpenRef.current = false;
21949
- forceUpdate();
21950
- }, [forceUpdate]);
21980
+ setIsRangeCalendarPickerOpen(false);
21981
+ }, []);
21951
21982
  const handleDateInputNext = useCallback(() => {
21952
21983
  if (!withTime || !timeInputRef.current) {
21953
21984
  return;
@@ -21956,81 +21987,57 @@ function DatePicker({ baseContainer, className, defaultValue, disabled = false,
21956
21987
  }, [withTime]);
21957
21988
  const handleDateInputChange = useCallback((nextUtcDateTuple, isFilled) => {
21958
21989
  selectedUtcDateTupleRef.current = nextUtcDateTuple;
21959
- // If there is no time input or a time has already been selected,
21960
- if (!withTime || selectedUtcTimeTupleRef.current) {
21961
- // we must update the selected date and call onChange()
21990
+ // If there is NO time input OR there is a time input WHILE a time is selected,
21991
+ if (!withTime || (withTime && selectedUtcTimeTupleRef.current)) {
21992
+ // we must update the selected datetime and call `onChange()`
21962
21993
  const timeTuple = withTime && selectedUtcTimeTupleRef.current ? selectedUtcTimeTupleRef.current : defaultTimeTuple;
21963
21994
  selectedUtcDateAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextUtcDateTuple, timeTuple, isEndDate);
21964
- submit();
21995
+ callOnChange();
21965
21996
  }
21966
21997
  if (isFilled) {
21967
21998
  handleDateInputNext();
21968
21999
  }
21969
- }, [defaultTimeTuple, handleDateInputNext, isEndDate, submit, withTime]);
22000
+ }, [callOnChange, defaultTimeTuple, handleDateInputNext, isEndDate, withTime]);
21970
22001
  const handleCalendarPickerChange = useCallback((nextUtcizedDateTuple) => {
21971
- // If this is a date picker without a time input,
22002
+ // If there is NO time input,
21972
22003
  if (!withTime) {
22004
+ // we update the selected datetime
21973
22005
  selectedUtcDateAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextUtcizedDateTuple,
21974
- // we set the time to the start (or end) of the day
22006
+ // with a time set to the start (or end) of the day
21975
22007
  defaultTimeTuple, isEndDate);
21976
22008
  }
21977
- // If this is a date picker with a time input,
21978
- else {
21979
- selectedUtcDateAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextUtcizedDateTuple,
21980
- // we include the selected time if it exists, or set it to the start (or end) of the day if it doesn't
21981
- selectedUtcTimeTupleRef.current || defaultTimeTuple, isEndDate);
22009
+ // If there is a time input AND a time is selected,
22010
+ else if (selectedUtcTimeTupleRef.current) {
22011
+ // we update the selected datetime
22012
+ selectedUtcDateAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextUtcizedDateTuple, selectedUtcTimeTupleRef.current, isEndDate);
21982
22013
  }
21983
22014
  selectedUtcDateTupleRef.current = nextUtcizedDateTuple;
21984
22015
  selectedUtcTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedUtcDateAsDayjsRef.current);
21985
22016
  closeCalendarPicker();
21986
22017
  forceUpdate();
21987
- submit();
21988
- if (withTime && !selectedUtcTimeTupleRef.current && timeInputRef.current) {
22018
+ callOnChange();
22019
+ if (withTime && timeInputRef.current) {
21989
22020
  timeInputRef.current.focus();
21990
22021
  }
21991
- }, [closeCalendarPicker, defaultTimeTuple, forceUpdate, isEndDate, submit, withTime]);
22022
+ }, [callOnChange, closeCalendarPicker, defaultTimeTuple, forceUpdate, isEndDate, withTime]);
21992
22023
  const handleDisable = useCallback(() => {
21993
22024
  selectedUtcDateTupleRef.current = undefined;
21994
22025
  selectedUtcTimeTupleRef.current = undefined;
21995
22026
  forceUpdate();
21996
22027
  }, [forceUpdate]);
21997
- /**
21998
- * @description
21999
- * This function is used to detect a user clearing all the date/time-related inputs
22000
- * in order to call `onChange(undefined)` when everything is cleared
22001
- */
22002
- const handleDateOrTimeInputInput = useCallback(() => {
22003
- if (!dateInputRef.current || !onChange) {
22004
- return;
22005
- }
22006
- const [year, month, day] = dateInputRef.current.getValueAsPartialDateTuple();
22007
- if (!withTime && !year && !month && !day) {
22008
- onChange(undefined);
22009
- return;
22010
- }
22011
- if (!timeInputRef.current) {
22012
- return;
22013
- }
22014
- const [hour, minute] = timeInputRef.current.getValueAsPartialTimeTuple();
22015
- if (!year && !month && !day && !hour && !minute) {
22016
- onChange(undefined);
22017
- }
22018
- }, [onChange, withTime]);
22019
- const handleTimeInputFilled = useCallback((nextTimeTuple) => {
22020
- // If a date has already been selected
22028
+ const handleTimeInputChange = useCallback((nextTimeTuple) => {
22029
+ // If a date is selected
22021
22030
  if (selectedUtcDateTupleRef.current) {
22022
- // we must update the selected date accordingly and submit it
22031
+ // we update the selected datetime
22023
22032
  const nextDateAsDayjs = getDayjsFromUtcDateAndTimeTuple(selectedUtcDateTupleRef.current, nextTimeTuple);
22024
22033
  selectedUtcDateAsDayjsRef.current = nextDateAsDayjs;
22025
- submit();
22026
22034
  }
22027
22035
  selectedUtcTimeTupleRef.current = nextTimeTuple;
22028
- submit();
22029
- }, [submit]);
22036
+ callOnChange();
22037
+ }, [callOnChange]);
22030
22038
  const openCalendarPicker = useCallback(() => {
22031
- isCalendarPickerOpenRef.current = true;
22032
- forceUpdate();
22033
- }, [forceUpdate]);
22039
+ setIsRangeCalendarPickerOpen(true);
22040
+ }, []);
22034
22041
  useFieldUndefineEffect(isUndefinedWhenDisabled && disabled, onChange, handleDisable);
22035
22042
  useClickOutsideEffect(boxRef, closeCalendarPicker, baseContainer);
22036
22043
  useEffect(() => {
@@ -22049,7 +22056,7 @@ function DatePicker({ baseContainer, className, defaultValue, disabled = false,
22049
22056
  selectedUtcTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedUtcDateAsDayjsRef.current);
22050
22057
  forceUpdate();
22051
22058
  }, [defaultValue, forceUpdate, previousDefaultValue]);
22052
- return (jsxs(Fieldset, { className: controlledClassName, disabled: disabled, hasError: hasError, isLegendHidden: isLabelHidden, legend: label, style: style, ...nativeProps, children: [jsxs(Box$8, { ref: boxRef, "$hasError": hasError, "$isDisabled": disabled, children: [jsx(Field$1, { children: jsx(DateInput, { ref: dateInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isEndDate: isEndDate, isForcedFocused: isCalendarPickerOpenRef.current, isLight: isLight, onChange: handleDateInputChange, onClick: openCalendarPicker, onInput: handleDateOrTimeInputInput, onNext: handleDateInputNext, value: selectedUtcDateTupleRef.current }) }), withTime && (jsx(Field$1, { "$isTimeField": true, children: jsx(TimeInput, { ref: timeInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isLight: isLight, minutesRange: minutesRange, onBack: () => dateInputRef.current?.focus(true), onChange: handleTimeInputFilled, onFocus: closeCalendarPicker, onInput: handleDateOrTimeInputInput, onPrevious: () => dateInputRef.current?.focus(true), value: selectedUtcTimeTupleRef.current }, JSON.stringify(selectedUtcTimeTupleRef.current)) }))] }), !isErrorMessageHidden && hasError && jsx(FieldError, { children: controlledError }), jsx(CalendarPicker, { isHistorical: isHistorical, isOpen: isCalendarPickerOpenRef.current, onChange: handleCalendarPickerChange, value: calendarPickerDefaultValue })] }));
22059
+ return (jsxs(Fieldset, { className: controlledClassName, disabled: disabled, hasError: hasError, isLegendHidden: isLabelHidden, legend: label, style: style, ...nativeProps, children: [jsxs(Box$8, { ref: boxRef, "$hasError": hasError, "$isDisabled": disabled, children: [jsx(Field$1, { children: jsx(DateInput, { ref: dateInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isEndDate: isEndDate, isForcedFocused: isRangeCalendarPickerOpen, isLight: isLight, onChange: handleDateInputChange, onClick: openCalendarPicker, onInput: callOnChangeUndefinedIfInputsAreEmpty, onNext: handleDateInputNext, value: selectedUtcDateTupleRef.current }) }), withTime && (jsx(Field$1, { "$isTimeField": true, children: jsx(TimeInput, { ref: timeInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isLight: isLight, minutesRange: minutesRange, onBack: () => dateInputRef.current?.focus(true), onChange: handleTimeInputChange, onFocus: closeCalendarPicker, onInput: callOnChangeUndefinedIfInputsAreEmpty, onPrevious: () => dateInputRef.current?.focus(true), value: selectedUtcTimeTupleRef.current }) }))] }), !isErrorMessageHidden && hasError && jsx(FieldError, { children: controlledError }), jsx(CalendarPicker, { isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpen, onChange: handleCalendarPickerChange, value: calendarPickerDefaultValue })] }));
22053
22060
  }
22054
22061
  const Box$8 = styled.div `
22055
22062
  * {
@@ -22299,18 +22306,18 @@ function DateRangePicker({ baseContainer, className, defaultValue, disabled = fa
22299
22306
  const endTimeInputRef = useRef(null);
22300
22307
  /* eslint-enable no-null/no-null */
22301
22308
  const hasMountedRef = useRef(false);
22302
- const isRangeCalendarPickerOpenRef = useRef(false);
22303
- const selectedStartDateAsDayjsRef = useRef(defaultValue ? customDayjs(defaultValue[0]) : undefined);
22304
- const selectedEndDateAsDayjsRef = useRef(defaultValue ? customDayjs(defaultValue[1]) : undefined);
22305
- const selectedStartDateTupleRef = useRef(getUtcDateTupleFromDayjs(selectedStartDateAsDayjsRef.current));
22306
- const selectedEndDateTupleRef = useRef(getUtcDateTupleFromDayjs(selectedEndDateAsDayjsRef.current));
22307
- const selectedStartTimeTupleRef = useRef(getUtcTimeTupleFromDayjs(selectedStartDateAsDayjsRef.current));
22308
- const selectedEndTimeTupleRef = useRef(getUtcTimeTupleFromDayjs(selectedEndDateAsDayjsRef.current));
22309
- const previousDefaultValue = usePrevious(defaultValue);
22310
- const { forceUpdate } = useForceUpdate();
22309
+ const selectedStartDateTimeAsDayjsRef = useRef(defaultValue ? customDayjs(defaultValue[0]) : undefined);
22310
+ const selectedStartDateTupleRef = useRef(getUtcDateTupleFromDayjs(selectedStartDateTimeAsDayjsRef.current));
22311
+ const selectedStartTimeTupleRef = useRef(getUtcTimeTupleFromDayjs(selectedStartDateTimeAsDayjsRef.current));
22312
+ const selectedEndDateTimeAsDayjsRef = useRef(defaultValue ? customDayjs(defaultValue[1]) : undefined);
22313
+ const selectedEndDateTupleRef = useRef(getUtcDateTupleFromDayjs(selectedEndDateTimeAsDayjsRef.current));
22314
+ const selectedEndTimeTupleRef = useRef(getUtcTimeTupleFromDayjs(selectedEndDateTimeAsDayjsRef.current));
22315
+ const [isRangeCalendarPickerOpen, setIsRangeCalendarPickerOpen] = useState(false);
22311
22316
  const controlledClassName = useMemo(() => classnames('Field-DateRangePicker', className), [className]);
22312
22317
  const controlledError = useMemo(() => normalizeString(error), [error]);
22313
22318
  const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
22319
+ const previousDefaultValue = usePrevious(defaultValue);
22320
+ const { forceUpdate } = useForceUpdate();
22314
22321
  const rangeCalendarPickerDefaultValue = useMemo(() => selectedStartDateTupleRef.current && selectedEndDateTupleRef.current
22315
22322
  ? [
22316
22323
  getUtcDateFromDateAndTimeTuple(selectedStartDateTupleRef.current, ['00', '00']),
@@ -22319,26 +22326,53 @@ function DateRangePicker({ baseContainer, className, defaultValue, disabled = fa
22319
22326
  : undefined,
22320
22327
  // eslint-disable-next-line react-hooks/exhaustive-deps
22321
22328
  [selectedEndDateTupleRef.current, selectedStartDateTupleRef.current]);
22322
- const submit = useCallback(() => {
22323
- if (!onChange || !selectedStartDateAsDayjsRef.current || !selectedEndDateAsDayjsRef.current) {
22329
+ const callOnChange = useCallback(() => {
22330
+ if (!onChange || !selectedStartDateTimeAsDayjsRef.current || !selectedEndDateTimeAsDayjsRef.current) {
22324
22331
  return;
22325
22332
  }
22326
22333
  if (isStringDate) {
22327
- const startUtcDateAsString = selectedStartDateAsDayjsRef.current.utc().toISOString();
22328
- const endUtcDateAsString = selectedEndDateAsDayjsRef.current.utc().toISOString();
22334
+ const startUtcDateAsString = selectedStartDateTimeAsDayjsRef.current.utc().toISOString();
22335
+ const endUtcDateAsString = selectedEndDateTimeAsDayjsRef.current.utc().toISOString();
22329
22336
  const nextUtcDateAsStringRange = [startUtcDateAsString, endUtcDateAsString];
22330
22337
  onChange(nextUtcDateAsStringRange);
22331
22338
  return;
22332
22339
  }
22333
- const startUtcDate = selectedStartDateAsDayjsRef.current.toDate();
22334
- const endUtcDate = selectedEndDateAsDayjsRef.current.toDate();
22340
+ const startUtcDate = selectedStartDateTimeAsDayjsRef.current.toDate();
22341
+ const endUtcDate = selectedEndDateTimeAsDayjsRef.current.toDate();
22335
22342
  const nextDateRange = [startUtcDate, endUtcDate];
22336
22343
  onChange(nextDateRange);
22337
22344
  }, [isStringDate, onChange]);
22345
+ const callOnChangeUndefinedIfInputsAreEmpty = useCallback(() => {
22346
+ if (!startDateInputRef.current || !endDateInputRef.current || !onChange) {
22347
+ return;
22348
+ }
22349
+ const [startYear, startMonth, startDay] = startDateInputRef.current.getValueAsPartialDateTuple();
22350
+ const [endYear, endMonth, endDay] = endDateInputRef.current.getValueAsPartialDateTuple();
22351
+ if (!withTime && !startYear && !startMonth && !startDay && !endYear && !endMonth && !endDay) {
22352
+ onChange(undefined);
22353
+ return;
22354
+ }
22355
+ if (!startTimeInputRef.current || !endTimeInputRef.current) {
22356
+ return;
22357
+ }
22358
+ const [startHour, startMinute] = startTimeInputRef.current.getValueAsPartialTimeTuple();
22359
+ const [endHour, endMinute] = endTimeInputRef.current.getValueAsPartialTimeTuple();
22360
+ if (!startYear &&
22361
+ !startMonth &&
22362
+ !startDay &&
22363
+ !startHour &&
22364
+ !startMinute &&
22365
+ !endYear &&
22366
+ !endMonth &&
22367
+ !endDay &&
22368
+ !endHour &&
22369
+ !endMinute) {
22370
+ onChange(undefined);
22371
+ }
22372
+ }, [onChange, withTime]);
22338
22373
  const closeRangeCalendarPicker = useCallback(() => {
22339
- isRangeCalendarPickerOpenRef.current = false;
22340
- forceUpdate();
22341
- }, [forceUpdate]);
22374
+ setIsRangeCalendarPickerOpen(false);
22375
+ }, []);
22342
22376
  const handleDisable = useCallback(() => {
22343
22377
  selectedStartDateTupleRef.current = undefined;
22344
22378
  selectedStartTimeTupleRef.current = undefined;
@@ -22375,13 +22409,13 @@ function DateRangePicker({ baseContainer, className, defaultValue, disabled = fa
22375
22409
  const handleDateInputChange = useCallback((position, nextDateTuple, isFilled) => {
22376
22410
  if (position === DateRangePosition.START) {
22377
22411
  selectedStartDateTupleRef.current = nextDateTuple;
22378
- // If there is no time input or a start time has already been selected,
22379
- if (!withTime || selectedStartTimeTupleRef.current) {
22380
- // we must update the selected start date and call onChange()
22412
+ // If there is NO time input OR there is a time input WHILE a start time is selected,
22413
+ if (!withTime || (withTime && selectedStartTimeTupleRef.current)) {
22414
+ // we update the selected start datetime
22381
22415
  const startUtcTimeTuple = withTime && selectedStartTimeTupleRef.current ? selectedStartTimeTupleRef.current : ['00', '00'];
22382
22416
  const nextStartDateAsDayjs = getDayjsFromUtcDateAndTimeTuple(nextDateTuple, startUtcTimeTuple);
22383
- selectedStartDateAsDayjsRef.current = nextStartDateAsDayjs;
22384
- submit();
22417
+ selectedStartDateTimeAsDayjsRef.current = nextStartDateAsDayjs;
22418
+ callOnChange();
22385
22419
  }
22386
22420
  if (isFilled) {
22387
22421
  handleStartDateInputNext();
@@ -22389,106 +22423,73 @@ function DateRangePicker({ baseContainer, className, defaultValue, disabled = fa
22389
22423
  }
22390
22424
  else {
22391
22425
  selectedEndDateTupleRef.current = nextDateTuple;
22392
- // If there is no time input or an end time has already been selected,
22393
- if (!withTime || selectedEndTimeTupleRef.current) {
22394
- // we must update the selected end date and call onChange()
22426
+ // If there is NO time input OR there is a time input WHILE a start time is selected,
22427
+ if (!withTime || (withTime && selectedEndTimeTupleRef.current)) {
22428
+ // we update the selected end datetime
22395
22429
  const endTimeTuple = (withTime ? selectedEndTimeTupleRef.current : ['23', '59']);
22396
22430
  const nextEndDateAsDayjs = getDayjsFromUtcDateAndTimeTuple(nextDateTuple, endTimeTuple, true);
22397
- selectedEndDateAsDayjsRef.current = nextEndDateAsDayjs;
22398
- submit();
22431
+ selectedEndDateTimeAsDayjsRef.current = nextEndDateAsDayjs;
22432
+ callOnChange();
22399
22433
  }
22400
22434
  if (isFilled) {
22401
22435
  handleEndDateInputNext();
22402
22436
  }
22403
22437
  }
22404
- }, [handleEndDateInputNext, handleStartDateInputNext, submit, withTime]);
22405
- /**
22406
- * @description
22407
- * This function is used to detect a user clearing all the date/time-related inputs
22408
- * in order to call `onChange(undefined)` when everything is cleared
22409
- */
22410
- const handleDateOrTimeInputInput = useCallback(() => {
22411
- if (!startDateInputRef.current || !endDateInputRef.current || !onChange) {
22412
- return;
22413
- }
22414
- const [startYear, startMonth, startDay] = startDateInputRef.current.getValueAsPartialDateTuple();
22415
- const [endYear, endMonth, endDay] = endDateInputRef.current.getValueAsPartialDateTuple();
22416
- if (!withTime && !startYear && !startMonth && !startDay && !endYear && !endMonth && !endDay) {
22417
- onChange(undefined);
22418
- return;
22419
- }
22420
- if (!startTimeInputRef.current || !endTimeInputRef.current) {
22421
- return;
22422
- }
22423
- const [startHour, startMinute] = startTimeInputRef.current.getValueAsPartialTimeTuple();
22424
- const [endHour, endMinute] = endTimeInputRef.current.getValueAsPartialTimeTuple();
22425
- if (!startYear &&
22426
- !startMonth &&
22427
- !startDay &&
22428
- !startHour &&
22429
- !startMinute &&
22430
- !endYear &&
22431
- !endMonth &&
22432
- !endDay &&
22433
- !endHour &&
22434
- !endMinute) {
22435
- onChange(undefined);
22436
- }
22437
- }, [onChange, withTime]);
22438
+ }, [callOnChange, handleEndDateInputNext, handleStartDateInputNext, withTime]);
22438
22439
  const handleRangeCalendarPickerChange = useCallback((nextUtcDateTupleRange) => {
22439
22440
  const [nextStartUtcDateTuple, nextEndUtcDateTuple] = nextUtcDateTupleRange;
22440
- // If this is a date picker without a time input,
22441
+ // If there is NO time input,
22441
22442
  if (!withTime) {
22442
- // we have to fix the start date at the beginning of the day
22443
- selectedStartDateAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextStartUtcDateTuple, ['00', '00']);
22444
- // and the end date at the end of the day
22445
- selectedEndDateAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextEndUtcDateTuple, ['23', '59'], true);
22443
+ // we have to fix the start datetime at the beginning of the day
22444
+ selectedStartDateTimeAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextStartUtcDateTuple, ['00', '00']);
22445
+ // and the end datetime at the end of the day
22446
+ selectedEndDateTimeAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextEndUtcDateTuple, ['23', '59'], true);
22446
22447
  }
22447
- // If this is a date picker with a time input,
22448
+ // If there is a time input,
22448
22449
  else {
22449
- // we include the selected start time if it exists, set it at the beginning of the day if not
22450
- selectedStartDateAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextStartUtcDateTuple, selectedStartTimeTupleRef.current || ['00', '00']);
22451
- // we include the selected end time if it exists, set it at the end of the day if not
22452
- selectedEndDateAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextEndUtcDateTuple, selectedEndTimeTupleRef.current || ['23', '59'], true);
22450
+ // AND there is BOTH a selected start time and a selected end time,
22451
+ if (selectedStartTimeTupleRef.current && selectedEndTimeTupleRef.current) {
22452
+ // we update the selected start datetime
22453
+ selectedStartDateTimeAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextStartUtcDateTuple, selectedStartTimeTupleRef.current);
22454
+ // we update the selected start datetime
22455
+ selectedEndDateTimeAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextEndUtcDateTuple, selectedEndTimeTupleRef.current, true);
22456
+ }
22457
+ startTimeInputRef.current?.focus();
22453
22458
  }
22454
22459
  selectedStartDateTupleRef.current = nextStartUtcDateTuple;
22455
- selectedStartTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedStartDateAsDayjsRef.current);
22460
+ selectedStartTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedStartDateTimeAsDayjsRef.current);
22456
22461
  selectedEndDateTupleRef.current = nextEndUtcDateTuple;
22457
- selectedEndTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedEndDateAsDayjsRef.current);
22462
+ selectedEndTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedEndDateTimeAsDayjsRef.current);
22458
22463
  closeRangeCalendarPicker();
22459
- submit();
22460
- }, [closeRangeCalendarPicker, submit, withTime]);
22461
- const handleTimeInputFilled = useCallback((position, nextTimeTuple) => {
22464
+ callOnChange();
22465
+ }, [callOnChange, closeRangeCalendarPicker, withTime]);
22466
+ const handleTimeInputChange = useCallback((position, nextTimeTuple) => {
22462
22467
  if (!endDateInputRef.current) {
22463
22468
  return;
22464
22469
  }
22465
22470
  if (position === DateRangePosition.START) {
22466
- // If a start date has already been selected
22471
+ // If a start date is selected
22467
22472
  if (selectedStartDateTupleRef.current) {
22468
- // we must update the selected start date accordingly and submit it
22473
+ // we update the selected start datetime and submit it
22469
22474
  const nextStartDateAsDayjs = getDayjsFromUtcDateAndTimeTuple(selectedStartDateTupleRef.current, nextTimeTuple);
22470
- selectedStartDateAsDayjsRef.current = nextStartDateAsDayjs;
22471
- submit();
22475
+ selectedStartDateTimeAsDayjsRef.current = nextStartDateAsDayjs;
22472
22476
  }
22473
22477
  selectedStartTimeTupleRef.current = nextTimeTuple;
22474
- endDateInputRef.current.focus();
22475
22478
  }
22476
22479
  else {
22477
- // If an end date has already been selected
22480
+ // If an end date is selected
22478
22481
  if (selectedEndDateTupleRef.current) {
22479
- // we must update the selected end date accordingly and submit it
22482
+ // we update the selected end datetime and submit it
22480
22483
  const nextEndDateAsDayjs = getDayjsFromUtcDateAndTimeTuple(selectedEndDateTupleRef.current, nextTimeTuple, true);
22481
- selectedEndDateAsDayjsRef.current = nextEndDateAsDayjs;
22482
- submit();
22484
+ selectedEndDateTimeAsDayjsRef.current = nextEndDateAsDayjs;
22483
22485
  }
22484
22486
  selectedEndTimeTupleRef.current = nextTimeTuple;
22485
22487
  }
22486
- submit();
22487
- }, [submit]);
22488
+ callOnChange();
22489
+ }, [callOnChange]);
22488
22490
  const openRangeCalendarPicker = useCallback(() => {
22489
- isRangeCalendarPickerOpenRef.current = true;
22490
- forceUpdate();
22491
- }, [forceUpdate]);
22491
+ setIsRangeCalendarPickerOpen(true);
22492
+ }, []);
22492
22493
  useFieldUndefineEffect(isUndefinedWhenDisabled && disabled, onChange, handleDisable);
22493
22494
  useClickOutsideEffect([endDateInputRef, startDateInputRef], closeRangeCalendarPicker, baseContainer);
22494
22495
  useEffect(() => {
@@ -22507,15 +22508,15 @@ function DateRangePicker({ baseContainer, className, defaultValue, disabled = fa
22507
22508
  lodashExports.isEqual(defaultValue, previousDefaultValue)) {
22508
22509
  return;
22509
22510
  }
22510
- selectedStartDateAsDayjsRef.current = defaultValue ? customDayjs(defaultValue[0]) : undefined;
22511
- selectedEndDateAsDayjsRef.current = defaultValue ? customDayjs(defaultValue[1]) : undefined;
22512
- selectedStartDateTupleRef.current = getUtcDateTupleFromDayjs(selectedStartDateAsDayjsRef.current);
22513
- selectedEndDateTupleRef.current = getUtcDateTupleFromDayjs(selectedEndDateAsDayjsRef.current);
22514
- selectedStartTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedStartDateAsDayjsRef.current);
22515
- selectedEndTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedEndDateAsDayjsRef.current);
22511
+ selectedStartDateTimeAsDayjsRef.current = defaultValue ? customDayjs(defaultValue[0]) : undefined;
22512
+ selectedEndDateTimeAsDayjsRef.current = defaultValue ? customDayjs(defaultValue[1]) : undefined;
22513
+ selectedStartDateTupleRef.current = getUtcDateTupleFromDayjs(selectedStartDateTimeAsDayjsRef.current);
22514
+ selectedEndDateTupleRef.current = getUtcDateTupleFromDayjs(selectedEndDateTimeAsDayjsRef.current);
22515
+ selectedStartTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedStartDateTimeAsDayjsRef.current);
22516
+ selectedEndTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedEndDateTimeAsDayjsRef.current);
22516
22517
  forceUpdate();
22517
22518
  }, [defaultValue, forceUpdate, previousDefaultValue]);
22518
- return (jsxs(Fieldset, { className: controlledClassName, disabled: disabled, hasError: hasError, isLegendHidden: isLabelHidden, legend: label, style: style, ...nativeProps, children: [jsxs(Box$6, { "$hasError": hasError, "$isDisabled": disabled, children: [jsx(Field, { children: jsx(DateInput, { ref: startDateInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, isRange: true, isStartDate: true, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.START, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onInput: handleDateOrTimeInputInput, onNext: handleStartDateInputNext, value: selectedStartDateTupleRef.current }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: startTimeInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isLight: isLight, isStartDate: true, minutesRange: minutesRange, onBack: () => startDateInputRef.current?.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.START, nextTimeTuple), onFocus: closeRangeCalendarPicker, onInput: handleDateOrTimeInputInput, onNext: () => endDateInputRef.current?.focus(), onPrevious: () => startDateInputRef.current?.focus(true), value: selectedStartTimeTupleRef.current }) })), jsx(Field, { isEndDateField: true, children: jsx(DateInput, { ref: endDateInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isEndDate: true, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, isRange: true, onBack: handleEndDateInputPrevious, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.END, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onInput: handleDateOrTimeInputInput, onNext: handleEndDateInputNext, onPrevious: handleEndDateInputPrevious, value: selectedEndDateTupleRef.current }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: endTimeInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isEndDate: true, isLight: isLight, minutesRange: minutesRange, onBack: () => endDateInputRef.current?.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.END, nextTimeTuple), onFocus: closeRangeCalendarPicker, onInput: handleDateOrTimeInputInput, onPrevious: () => endDateInputRef.current?.focus(true), value: selectedEndTimeTupleRef.current }) }))] }), !isErrorMessageHidden && hasError && jsx(FieldError, { children: controlledError }), jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpenRef.current, onChange: handleRangeCalendarPickerChange })] }));
22519
+ return (jsxs(Fieldset, { className: controlledClassName, disabled: disabled, hasError: hasError, isLegendHidden: isLabelHidden, legend: label, style: style, ...nativeProps, children: [jsxs(Box$6, { "$hasError": hasError, "$isDisabled": disabled, children: [jsx(Field, { children: jsx(DateInput, { ref: startDateInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isForcedFocused: isRangeCalendarPickerOpen, isLight: isLight, isRange: true, isStartDate: true, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.START, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onInput: callOnChangeUndefinedIfInputsAreEmpty, onNext: handleStartDateInputNext, value: selectedStartDateTupleRef.current }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: startTimeInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isLight: isLight, isStartDate: true, minutesRange: minutesRange, onBack: () => startDateInputRef.current?.focus(true), onChange: nextTimeTuple => handleTimeInputChange(DateRangePosition.START, nextTimeTuple), onFocus: closeRangeCalendarPicker, onInput: callOnChangeUndefinedIfInputsAreEmpty, onNext: () => endDateInputRef.current?.focus(), onPrevious: () => startDateInputRef.current?.focus(true), value: selectedStartTimeTupleRef.current }) })), jsx(Field, { isEndDateField: true, children: jsx(DateInput, { ref: endDateInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isEndDate: true, isForcedFocused: isRangeCalendarPickerOpen, isLight: isLight, isRange: true, onBack: handleEndDateInputPrevious, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.END, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onInput: callOnChangeUndefinedIfInputsAreEmpty, onNext: handleEndDateInputNext, onPrevious: handleEndDateInputPrevious, value: selectedEndDateTupleRef.current }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: endTimeInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isEndDate: true, isLight: isLight, minutesRange: minutesRange, onBack: () => endDateInputRef.current?.focus(true), onChange: nextTimeTuple => handleTimeInputChange(DateRangePosition.END, nextTimeTuple), onFocus: closeRangeCalendarPicker, onInput: callOnChangeUndefinedIfInputsAreEmpty, onPrevious: () => endDateInputRef.current?.focus(true), value: selectedEndTimeTupleRef.current }) }))] }), !isErrorMessageHidden && hasError && jsx(FieldError, { children: controlledError }), jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpen, onChange: handleRangeCalendarPickerChange }, JSON.stringify(rangeCalendarPickerDefaultValue))] }));
22519
22520
  }
22520
22521
  const Box$6 = styled.div `
22521
22522
  * {