@mtes-mct/monitor-ui 2.7.2 → 2.8.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [2.8.0](https://github.com/MTES-MCT/monitor-ui/compare/v2.7.2...v2.8.0) (2023-01-17)
2
+
3
+
4
+ ### Features
5
+
6
+ * **fields:** handle both Date & string dates in DatePicker & DateRangePicker ([6aacf70](https://github.com/MTES-MCT/monitor-ui/commit/6aacf7007bcbc789b9de643be2d192a1808b0afc))
7
+
8
+ ## [2.7.2](https://github.com/MTES-MCT/monitor-ui/compare/v2.7.1...v2.7.2) (2023-01-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **elements:** set Button icon size in px instead of rem ([363ffab](https://github.com/MTES-MCT/monitor-ui/commit/363ffab6d6d2c65e997eafa7378f4ead377cb6f2))
14
+
1
15
  ## [2.7.1](https://github.com/MTES-MCT/monitor-ui/compare/v2.7.0...v2.7.1) (2023-01-13)
2
16
 
3
17
 
package/README.md CHANGED
@@ -55,7 +55,8 @@ Please read the [contributing document](CONTRIBUTING.md) for setup and contribut
55
55
 
56
56
  ---
57
57
 
58
- [img-github]: https://img.shields.io/github/workflow/status/MTES-MCT/monitor-ui/Check/main?style=flat-square
58
+ [img-github]:
59
+ https://img.shields.io/github/actions/workflow/status/MTES-MCT/monitor-ui/check.yml?branch=main&style=flat-square
59
60
  [img-license]: https://img.shields.io/github/license/MTES-MCT/monitor-ui?style=flat-square
60
61
  [img-npm]: https://img.shields.io/npm/v/@mtes-mct/monitor-ui?style=flat-square
61
62
  [lnk-github]: https://github.com/MTES-MCT/monitor-ui/actions?query=branch%3Amain++
package/index.js CHANGED
@@ -3442,7 +3442,7 @@ dayjs_minExports.tz.setDefault('UTC');
3442
3442
  function getLocalizedDayjs(utcDate) {
3443
3443
  // The number of minutes returned by getTimezoneOffset() is positive if the local time zone is behind UTC,
3444
3444
  // and negative if the local time zone is ahead of UTC. For example, for UTC+10, -600 will be returned.
3445
- const timezoneOffsetInMinutes = utcDate.getTimezoneOffset();
3445
+ const timezoneOffsetInMinutes = new Date().getTimezoneOffset();
3446
3446
  return dayjs_minExports(utcDate).add(timezoneOffsetInMinutes, 'minutes');
3447
3447
  }
3448
3448
 
@@ -4463,27 +4463,32 @@ const Box$5 = styled.div `
4463
4463
 
4464
4464
  function DatePicker({ baseContainer, defaultValue,
4465
4465
  // eslint-disable-next-line @typescript-eslint/naming-convention
4466
- disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
4466
+ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, isStringDate = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
4467
4467
  const boxRef = useRef();
4468
4468
  const dateInputRef = useRef();
4469
4469
  const timeInputRef = useRef();
4470
4470
  const isCalendarPickerOpenRef = useRef(false);
4471
- const selectedDateRef = useRef(defaultValue ? getLocalizedDayjs(defaultValue).toDate() : undefined);
4472
- const selectedDateTupleRef = useRef(getDateTupleFromDate(selectedDateRef.current));
4473
- const selectedTimeTupleRef = useRef(getTimeTupleFromDate(selectedDateRef.current));
4471
+ const selectedLocalizedDateRef = useRef(defaultValue ? getLocalizedDayjs(defaultValue).toDate() : undefined);
4472
+ const selectedLocalizedDateTupleRef = useRef(getDateTupleFromDate(selectedLocalizedDateRef.current));
4473
+ const selectedLocalizedTimeTupleRef = useRef(getTimeTupleFromDate(selectedLocalizedDateRef.current));
4474
4474
  const { forceUpdate } = useForceUpdate();
4475
- const rangeCalendarPickerDefaultValue = useMemo(() => selectedDateTupleRef.current
4476
- ? getDateFromDateAndTimeTuple(selectedDateTupleRef.current, ['00', '00'])
4475
+ const rangeCalendarPickerDefaultValue = useMemo(() => selectedLocalizedDateTupleRef.current
4476
+ ? getDateFromDateAndTimeTuple(selectedLocalizedDateTupleRef.current, ['00', '00'])
4477
4477
  : undefined,
4478
4478
  // eslint-disable-next-line react-hooks/exhaustive-deps
4479
- [selectedDateTupleRef.current]);
4479
+ [selectedLocalizedDateTupleRef.current]);
4480
4480
  const submit = useCallback(() => {
4481
- if (!onChange || !selectedDateRef.current) {
4481
+ if (!onChange || !selectedLocalizedDateRef.current) {
4482
4482
  return;
4483
4483
  }
4484
- const nextDate = getUtcizedDayjs(selectedDateRef.current).toDate();
4485
- onChange(nextDate);
4486
- }, [onChange]);
4484
+ const nextDateAsDayjs = getUtcizedDayjs(selectedLocalizedDateRef.current);
4485
+ if (isStringDate) {
4486
+ onChange(nextDateAsDayjs.toISOString());
4487
+ }
4488
+ else {
4489
+ onChange(nextDateAsDayjs.toDate());
4490
+ }
4491
+ }, [isStringDate, onChange]);
4487
4492
  const closeCalendarPicker = useCallback(() => {
4488
4493
  isCalendarPickerOpenRef.current = false;
4489
4494
  forceUpdate();
@@ -4495,13 +4500,13 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
4495
4500
  timeInputRef.current.focus();
4496
4501
  }, [withTime]);
4497
4502
  const handleDateInputChange = useCallback((nextDateTuple, isFilled) => {
4498
- selectedDateTupleRef.current = nextDateTuple;
4503
+ selectedLocalizedDateTupleRef.current = nextDateTuple;
4499
4504
  // If there is no time input or a time has already been selected,
4500
- if (!withTime || selectedTimeTupleRef.current) {
4505
+ if (!withTime || selectedLocalizedTimeTupleRef.current) {
4501
4506
  // we must update the selected date and call onChange()
4502
- const timeTuple = (withTime ? selectedTimeTupleRef.current : ['00', '00']);
4507
+ const timeTuple = (withTime ? selectedLocalizedTimeTupleRef.current : ['00', '00']);
4503
4508
  const nextDate = getDateFromDateAndTimeTuple(nextDateTuple, timeTuple);
4504
- selectedDateRef.current = nextDate;
4509
+ selectedLocalizedDateRef.current = getLocalizedDayjs(nextDate).toDate();
4505
4510
  submit();
4506
4511
  }
4507
4512
  if (isFilled) {
@@ -4513,32 +4518,32 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
4513
4518
  if (!withTime) {
4514
4519
  // we have to fix the date at the beginning of the day
4515
4520
  const nextDate = getDateFromDateAndTimeTuple(nextDateTuple, ['00', '00']);
4516
- selectedDateRef.current = nextDate;
4521
+ selectedLocalizedDateRef.current = nextDate;
4517
4522
  }
4518
4523
  // If this is a date picker with a time input,
4519
4524
  else {
4520
4525
  // we include the selected time if it exists, set it at the beginning of the day if not
4521
- const nextDate = getDateFromDateAndTimeTuple(nextDateTuple, selectedTimeTupleRef.current || ['00', '00']);
4522
- selectedDateRef.current = nextDate;
4526
+ const nextDate = getDateFromDateAndTimeTuple(nextDateTuple, selectedLocalizedTimeTupleRef.current || ['00', '00']);
4527
+ selectedLocalizedDateRef.current = nextDate;
4523
4528
  }
4524
- selectedDateTupleRef.current = nextDateTuple;
4525
- selectedTimeTupleRef.current = getTimeTupleFromDate(selectedDateRef.current);
4529
+ selectedLocalizedDateTupleRef.current = nextDateTuple;
4530
+ selectedLocalizedTimeTupleRef.current = getTimeTupleFromDate(selectedLocalizedDateRef.current);
4526
4531
  closeCalendarPicker();
4527
4532
  forceUpdate();
4528
4533
  submit();
4529
- if (withTime && !selectedTimeTupleRef.current) {
4534
+ if (withTime && !selectedLocalizedTimeTupleRef.current) {
4530
4535
  timeInputRef.current.focus();
4531
4536
  }
4532
4537
  }, [closeCalendarPicker, forceUpdate, submit, withTime]);
4533
4538
  const handleTimeInputFilled = useCallback((nextTimeTuple) => {
4534
4539
  // If a date has already been selected
4535
- if (selectedDateTupleRef.current) {
4540
+ if (selectedLocalizedDateTupleRef.current) {
4536
4541
  // we must update the selected date accordingly and submit it
4537
- const nextDate = getDateFromDateAndTimeTuple(selectedDateTupleRef.current, nextTimeTuple);
4538
- selectedDateRef.current = nextDate;
4542
+ const nextDate = getDateFromDateAndTimeTuple(selectedLocalizedDateTupleRef.current, nextTimeTuple);
4543
+ selectedLocalizedDateRef.current = nextDate;
4539
4544
  submit();
4540
4545
  }
4541
- selectedTimeTupleRef.current = nextTimeTuple;
4546
+ selectedLocalizedTimeTupleRef.current = nextTimeTuple;
4542
4547
  submit();
4543
4548
  }, [submit]);
4544
4549
  const openCalendarPicker = useCallback(() => {
@@ -4546,7 +4551,7 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
4546
4551
  forceUpdate();
4547
4552
  }, [forceUpdate]);
4548
4553
  useClickOutside(boxRef, closeCalendarPicker, baseContainer);
4549
- return (jsxs(Fieldset, { disabled: disabled, ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$4, { ref: boxRef, children: [jsx(Field$1, { children: jsx(DateInput, { ref: dateInputRef, defaultValue: selectedDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isCalendarPickerOpenRef.current, isLight: isLight, onChange: handleDateInputChange, onClick: openCalendarPicker, onNext: handleDateInputNext }) }), withTime && (jsx(Field$1, { "$isTimeField": true, children: jsx(TimeInput, { ref: timeInputRef, baseContainer: baseContainer, defaultValue: selectedTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, minutesRange: minutesRange, onBack: () => dateInputRef.current.focus(true), onChange: handleTimeInputFilled, onFocus: closeCalendarPicker, onPrevious: () => dateInputRef.current.focus(true) }) }))] }), jsx(CalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isCalendarPickerOpenRef.current, onChange: handleCalendarPickerChange })] }));
4554
+ return (jsxs(Fieldset, { disabled: disabled, ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$4, { ref: boxRef, children: [jsx(Field$1, { children: jsx(DateInput, { ref: dateInputRef, defaultValue: selectedLocalizedDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isCalendarPickerOpenRef.current, isLight: isLight, onChange: handleDateInputChange, onClick: openCalendarPicker, onNext: handleDateInputNext }) }), withTime && (jsx(Field$1, { "$isTimeField": true, children: jsx(TimeInput, { ref: timeInputRef, baseContainer: baseContainer, defaultValue: selectedLocalizedTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, minutesRange: minutesRange, onBack: () => dateInputRef.current.focus(true), onChange: handleTimeInputFilled, onFocus: closeCalendarPicker, onPrevious: () => dateInputRef.current.focus(true) }) }))] }), jsx(CalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isCalendarPickerOpenRef.current, onChange: handleCalendarPickerChange })] }));
4550
4555
  }
4551
4556
  const Box$4 = styled.div `
4552
4557
  * {
@@ -4769,36 +4774,44 @@ var DateRangePosition;
4769
4774
 
4770
4775
  function DateRangePicker({ baseContainer, defaultValue,
4771
4776
  // eslint-disable-next-line @typescript-eslint/naming-convention
4772
- disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
4777
+ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, isStringDate = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
4773
4778
  const startDateInputRef = useRef();
4774
4779
  const startTimeInputRef = useRef();
4775
4780
  const endDateInputRef = useRef();
4776
4781
  const endTimeInputRef = useRef();
4777
4782
  const isRangeCalendarPickerOpenRef = useRef(false);
4778
- const selectedStartDateRef = useRef(defaultValue ? getLocalizedDayjs(defaultValue[0]).toDate() : undefined);
4779
- const selectedEndDateRef = useRef(defaultValue ? getLocalizedDayjs(defaultValue[1]).toDate() : undefined);
4780
- const selectedStartDateTupleRef = useRef(getDateTupleFromDate(selectedStartDateRef.current));
4781
- const selectedEndDateTupleRef = useRef(getDateTupleFromDate(selectedEndDateRef.current));
4782
- const selectedStartTimeTupleRef = useRef(getTimeTupleFromDate(selectedStartDateRef.current));
4783
- const selectedEndTimeTupleRef = useRef(getTimeTupleFromDate(selectedEndDateRef.current));
4783
+ const selectedLocalizedStartDateRef = useRef(defaultValue ? getLocalizedDayjs(defaultValue[0]).toDate() : undefined);
4784
+ const selectedLocalizedEndDateRef = useRef(defaultValue ? getLocalizedDayjs(defaultValue[1]).toDate() : undefined);
4785
+ const selectedLocalizedStartDateTupleRef = useRef(getDateTupleFromDate(selectedLocalizedStartDateRef.current));
4786
+ const selectedLocalizedEndDateTupleRef = useRef(getDateTupleFromDate(selectedLocalizedEndDateRef.current));
4787
+ const selectedLocalizedStartTimeTupleRef = useRef(getTimeTupleFromDate(selectedLocalizedStartDateRef.current));
4788
+ const selectedLocalizedEndTimeTupleRef = useRef(getTimeTupleFromDate(selectedLocalizedEndDateRef.current));
4784
4789
  const { forceUpdate } = useForceUpdate();
4785
- const rangeCalendarPickerDefaultValue = useMemo(() => selectedStartDateTupleRef.current && selectedEndDateTupleRef.current
4790
+ const rangeCalendarPickerDefaultValue = useMemo(() => selectedLocalizedStartDateTupleRef.current && selectedLocalizedEndDateTupleRef.current
4786
4791
  ? [
4787
- getDateFromDateAndTimeTuple(selectedStartDateTupleRef.current, ['00', '00']),
4788
- getDateFromDateAndTimeTuple(selectedEndDateTupleRef.current, ['00', '00'], true)
4792
+ getDateFromDateAndTimeTuple(selectedLocalizedStartDateTupleRef.current, ['00', '00']),
4793
+ getDateFromDateAndTimeTuple(selectedLocalizedEndDateTupleRef.current, ['00', '00'], true)
4789
4794
  ]
4790
4795
  : undefined,
4791
4796
  // eslint-disable-next-line react-hooks/exhaustive-deps
4792
- [selectedEndDateTupleRef.current, selectedStartDateTupleRef.current]);
4797
+ [selectedLocalizedEndDateTupleRef.current, selectedLocalizedStartDateTupleRef.current]);
4793
4798
  const submit = useCallback(() => {
4794
- if (!onChange || !selectedStartDateRef.current || !selectedEndDateRef.current) {
4799
+ if (!onChange || !selectedLocalizedStartDateRef.current || !selectedLocalizedEndDateRef.current) {
4795
4800
  return;
4796
4801
  }
4797
- const utcizedStartDate = getUtcizedDayjs(selectedStartDateRef.current).toDate();
4798
- const utcizedEndDate = getUtcizedDayjs(selectedEndDateRef.current).toDate();
4799
- const nextDateRange = [utcizedStartDate, utcizedEndDate];
4800
- onChange(nextDateRange);
4801
- }, [onChange]);
4802
+ if (isStringDate) {
4803
+ const utcizedStartDateAsString = getUtcizedDayjs(selectedLocalizedStartDateRef.current).toISOString();
4804
+ const utcizedEndDateAsString = getUtcizedDayjs(selectedLocalizedEndDateRef.current).toISOString();
4805
+ const nextDateAsStringRange = [utcizedStartDateAsString, utcizedEndDateAsString];
4806
+ onChange(nextDateAsStringRange);
4807
+ }
4808
+ else {
4809
+ const utcizedStartDate = getUtcizedDayjs(selectedLocalizedStartDateRef.current).toDate();
4810
+ const utcizedEndDate = getUtcizedDayjs(selectedLocalizedEndDateRef.current).toDate();
4811
+ const nextDateRange = [utcizedStartDate, utcizedEndDate];
4812
+ onChange(nextDateRange);
4813
+ }
4814
+ }, [isStringDate, onChange]);
4802
4815
  const closeRangeCalendarPicker = useCallback(() => {
4803
4816
  isRangeCalendarPickerOpenRef.current = false;
4804
4817
  forceUpdate();
@@ -4825,13 +4838,13 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
4825
4838
  }, [withTime]);
4826
4839
  const handleDateInputChange = useCallback((position, nextDateTuple, isFilled) => {
4827
4840
  if (position === DateRangePosition.START) {
4828
- selectedStartDateTupleRef.current = nextDateTuple;
4841
+ selectedLocalizedStartDateTupleRef.current = nextDateTuple;
4829
4842
  // If there is no time input or a start time has already been selected,
4830
- if (!withTime || selectedStartTimeTupleRef.current) {
4843
+ if (!withTime || selectedLocalizedStartTimeTupleRef.current) {
4831
4844
  // we must update the selected start date and call onChange()
4832
- const startTimeTuple = (withTime ? selectedStartTimeTupleRef.current : ['00', '00']);
4845
+ const startTimeTuple = (withTime ? selectedLocalizedStartTimeTupleRef.current : ['00', '00']);
4833
4846
  const nextStartDate = getDateFromDateAndTimeTuple(nextDateTuple, startTimeTuple);
4834
- selectedStartDateRef.current = nextStartDate;
4847
+ selectedLocalizedStartDateRef.current = nextStartDate;
4835
4848
  submit();
4836
4849
  }
4837
4850
  if (isFilled) {
@@ -4839,13 +4852,13 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
4839
4852
  }
4840
4853
  }
4841
4854
  else {
4842
- selectedEndDateTupleRef.current = nextDateTuple;
4855
+ selectedLocalizedEndDateTupleRef.current = nextDateTuple;
4843
4856
  // If there is no time input or an end time has already been selected,
4844
- if (!withTime || selectedEndTimeTupleRef.current) {
4857
+ if (!withTime || selectedLocalizedEndTimeTupleRef.current) {
4845
4858
  // we must update the selected end date and call onChange()
4846
- const endTimeTuple = (withTime ? selectedEndTimeTupleRef.current : ['23', '59']);
4859
+ const endTimeTuple = (withTime ? selectedLocalizedEndTimeTupleRef.current : ['23', '59']);
4847
4860
  const nextEndDate = getDateFromDateAndTimeTuple(nextDateTuple, endTimeTuple, true);
4848
- selectedEndDateRef.current = nextEndDate;
4861
+ selectedLocalizedEndDateRef.current = nextEndDate;
4849
4862
  submit();
4850
4863
  }
4851
4864
  if (isFilled) {
@@ -4861,22 +4874,22 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
4861
4874
  const nextStartDate = getDateFromDateAndTimeTuple(nextStartDateTuple, ['00', '00']);
4862
4875
  // and the end date at the end of the day
4863
4876
  const nextEndDate = getDateFromDateAndTimeTuple(nextEndDateTuple, ['23', '59'], true);
4864
- selectedStartDateRef.current = nextStartDate;
4865
- selectedEndDateRef.current = nextEndDate;
4877
+ selectedLocalizedStartDateRef.current = nextStartDate;
4878
+ selectedLocalizedEndDateRef.current = nextEndDate;
4866
4879
  }
4867
4880
  // If this is a date picker with a time input,
4868
4881
  else {
4869
4882
  // we include the selected start time if it exists, set it at the beginning of the day if not
4870
- const nextStartDate = getDateFromDateAndTimeTuple(nextStartDateTuple, selectedStartTimeTupleRef.current || ['00', '00']);
4871
- selectedStartDateRef.current = nextStartDate;
4883
+ const nextStartDate = getDateFromDateAndTimeTuple(nextStartDateTuple, selectedLocalizedStartTimeTupleRef.current || ['00', '00']);
4884
+ selectedLocalizedStartDateRef.current = nextStartDate;
4872
4885
  // we include the selected end time if it exists, set it at the end of the day if not
4873
- const nextEndDate = getDateFromDateAndTimeTuple(nextEndDateTuple, selectedEndTimeTupleRef.current || ['23', '59'], true);
4874
- selectedEndDateRef.current = nextEndDate;
4886
+ const nextEndDate = getDateFromDateAndTimeTuple(nextEndDateTuple, selectedLocalizedEndTimeTupleRef.current || ['23', '59'], true);
4887
+ selectedLocalizedEndDateRef.current = nextEndDate;
4875
4888
  }
4876
- selectedStartDateTupleRef.current = nextStartDateTuple;
4877
- selectedStartTimeTupleRef.current = getTimeTupleFromDate(selectedStartDateRef.current);
4878
- selectedEndDateTupleRef.current = nextEndDateTuple;
4879
- selectedEndTimeTupleRef.current = getTimeTupleFromDate(selectedEndDateRef.current);
4889
+ selectedLocalizedStartDateTupleRef.current = nextStartDateTuple;
4890
+ selectedLocalizedStartTimeTupleRef.current = getTimeTupleFromDate(selectedLocalizedStartDateRef.current);
4891
+ selectedLocalizedEndDateTupleRef.current = nextEndDateTuple;
4892
+ selectedLocalizedEndTimeTupleRef.current = getTimeTupleFromDate(selectedLocalizedEndDateRef.current);
4880
4893
  closeRangeCalendarPicker();
4881
4894
  forceUpdate();
4882
4895
  submit();
@@ -4884,24 +4897,24 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
4884
4897
  const handleTimeInputFilled = useCallback((position, nextTimeTuple) => {
4885
4898
  if (position === DateRangePosition.START) {
4886
4899
  // If a start date has already been selected
4887
- if (selectedStartDateTupleRef.current) {
4900
+ if (selectedLocalizedStartDateTupleRef.current) {
4888
4901
  // we must update the selected start date accordingly and submit it
4889
- const nextStartDate = getDateFromDateAndTimeTuple(selectedStartDateTupleRef.current, nextTimeTuple);
4890
- selectedStartDateRef.current = nextStartDate;
4902
+ const nextStartDate = getDateFromDateAndTimeTuple(selectedLocalizedStartDateTupleRef.current, nextTimeTuple);
4903
+ selectedLocalizedStartDateRef.current = nextStartDate;
4891
4904
  submit();
4892
4905
  }
4893
- selectedStartTimeTupleRef.current = nextTimeTuple;
4906
+ selectedLocalizedStartTimeTupleRef.current = nextTimeTuple;
4894
4907
  endDateInputRef.current.focus();
4895
4908
  }
4896
4909
  else {
4897
4910
  // If an end date has already been selected
4898
- if (selectedEndDateTupleRef.current) {
4911
+ if (selectedLocalizedEndDateTupleRef.current) {
4899
4912
  // we must update the selected end date accordingly and submit it
4900
- const nextEndDate = getDateFromDateAndTimeTuple(selectedEndDateTupleRef.current, nextTimeTuple, true);
4901
- selectedEndDateRef.current = nextEndDate;
4913
+ const nextEndDate = getDateFromDateAndTimeTuple(selectedLocalizedEndDateTupleRef.current, nextTimeTuple, true);
4914
+ selectedLocalizedEndDateRef.current = nextEndDate;
4902
4915
  submit();
4903
4916
  }
4904
- selectedEndTimeTupleRef.current = nextTimeTuple;
4917
+ selectedLocalizedEndTimeTupleRef.current = nextTimeTuple;
4905
4918
  }
4906
4919
  submit();
4907
4920
  }, [submit]);
@@ -4910,7 +4923,7 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
4910
4923
  forceUpdate();
4911
4924
  }, [forceUpdate]);
4912
4925
  useClickOutside([endDateInputRef, startDateInputRef], closeRangeCalendarPicker, baseContainer);
4913
- return (jsxs(Fieldset, { ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$2, { isDisabled: disabled, children: [jsx(Field, { children: jsx(DateInput, { ref: startDateInputRef, defaultValue: selectedStartDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, isStartDate: true, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.START, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleStartDateInputNext }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: startTimeInputRef, baseContainer: baseContainer, defaultValue: selectedStartTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, isStartDate: true, minutesRange: minutesRange, onBack: () => startDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.START, nextTimeTuple), onFocus: closeRangeCalendarPicker, onNext: () => endDateInputRef.current.focus(), onPrevious: () => startDateInputRef.current.focus(true) }) })), jsx(Field, { isEndDateField: true, children: jsx(DateInput, { ref: endDateInputRef, defaultValue: selectedEndDateTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, onBack: handleEndDateInputPrevious, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.END, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleEndDateInputNext, onPrevious: handleEndDateInputPrevious }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: endTimeInputRef, baseContainer: baseContainer, defaultValue: selectedEndTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isLight: isLight, minutesRange: minutesRange, onBack: () => endDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.END, nextTimeTuple), onFocus: closeRangeCalendarPicker, onPrevious: () => endDateInputRef.current.focus(true) }) }))] }), jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpenRef.current, onChange: handleRangeCalendarPickerChange })] }));
4926
+ return (jsxs(Fieldset, { ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$2, { isDisabled: disabled, children: [jsx(Field, { children: jsx(DateInput, { ref: startDateInputRef, defaultValue: selectedLocalizedStartDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, isStartDate: true, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.START, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleStartDateInputNext }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: startTimeInputRef, baseContainer: baseContainer, defaultValue: selectedLocalizedStartTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, isStartDate: true, minutesRange: minutesRange, onBack: () => startDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.START, nextTimeTuple), onFocus: closeRangeCalendarPicker, onNext: () => endDateInputRef.current.focus(), onPrevious: () => startDateInputRef.current.focus(true) }) })), jsx(Field, { isEndDateField: true, children: jsx(DateInput, { ref: endDateInputRef, defaultValue: selectedLocalizedEndDateTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, onBack: handleEndDateInputPrevious, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.END, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleEndDateInputNext, onPrevious: handleEndDateInputPrevious }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: endTimeInputRef, baseContainer: baseContainer, defaultValue: selectedLocalizedEndTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isLight: isLight, minutesRange: minutesRange, onBack: () => endDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.END, nextTimeTuple), onFocus: closeRangeCalendarPicker, onPrevious: () => endDateInputRef.current.focus(true) }) }))] }), jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpenRef.current, onChange: handleRangeCalendarPickerChange })] }));
4914
4927
  }
4915
4928
  const Box$2 = styled.div `
4916
4929
  * {
@@ -5335,18 +5348,20 @@ function FormikCheckbox({ name, ...originalProps }) {
5335
5348
  return jsx(Checkbox, { defaultChecked: defaultChecked, name: name, onChange: helpers.setValue, ...originalProps });
5336
5349
  }
5337
5350
 
5351
+ const UntypedDatePicker = DatePicker;
5338
5352
  function FormikDatePicker({ name, ...originalProps }) {
5339
5353
  const [field, , helpers] = useField(name);
5340
5354
  // eslint-disable-next-line react-hooks/exhaustive-deps
5341
5355
  const defaultValue = useMemo(() => field.value, []);
5342
- return jsx(DatePicker, { defaultValue: defaultValue, onChange: helpers.setValue, ...originalProps });
5356
+ return jsx(UntypedDatePicker, { defaultValue: defaultValue, onChange: helpers.setValue, ...originalProps });
5343
5357
  }
5344
5358
 
5359
+ const UntypedDateRangePicker = DateRangePicker;
5345
5360
  function FormikDateRangePicker({ name, ...originalProps }) {
5346
5361
  const [field, , helpers] = useField(name);
5347
5362
  // eslint-disable-next-line react-hooks/exhaustive-deps
5348
5363
  const defaultValue = useMemo(() => field.value, []);
5349
- return jsx(DateRangePicker, { defaultValue: defaultValue, onChange: helpers.setValue, ...originalProps });
5364
+ return jsx(UntypedDateRangePicker, { defaultValue: defaultValue, onChange: helpers.setValue, ...originalProps });
5350
5365
  }
5351
5366
 
5352
5367
  function FormikEffect({ onChange }) {