@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.
- package/CHANGELOG.md +8 -0
- package/cypress.config.d.ts +2 -0
- package/index.js +158 -157
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/{fields → src/fields}/DateRangePicker/NumberInput.d.ts +5 -5
- /package/{GlobalStyle.d.ts → src/GlobalStyle.d.ts} +0 -0
- /package/{OnlyFontGlobalStyle.d.ts → src/OnlyFontGlobalStyle.d.ts} +0 -0
- /package/{ThemeProvider.d.ts → src/ThemeProvider.d.ts} +0 -0
- /package/{components → src/components}/Dialog/Action.d.ts +0 -0
- /package/{components → src/components}/Dialog/Body.d.ts +0 -0
- /package/{components → src/components}/Dialog/Title.d.ts +0 -0
- /package/{components → src/components}/Dialog/index.d.ts +0 -0
- /package/{components → src/components}/Dropdown/Item.d.ts +0 -0
- /package/{components → src/components}/Dropdown/index.d.ts +0 -0
- /package/{components → src/components}/NewWindow.d.ts +0 -0
- /package/{components → src/components}/Notifier/NotificationEvent.d.ts +0 -0
- /package/{components → src/components}/Notifier/index.d.ts +0 -0
- /package/{components → src/components}/SideMenu/Button.d.ts +0 -0
- /package/{components → src/components}/SideMenu/index.d.ts +0 -0
- /package/{components → src/components}/SingleTag.d.ts +0 -0
- /package/{constants.d.ts → src/constants.d.ts} +0 -0
- /package/{elements → src/elements}/Button.d.ts +0 -0
- /package/{elements → src/elements}/Field.d.ts +0 -0
- /package/{elements → src/elements}/FieldError.d.ts +0 -0
- /package/{elements → src/elements}/Fieldset.d.ts +0 -0
- /package/{elements → src/elements}/IconBox.d.ts +0 -0
- /package/{elements → src/elements}/IconButton.d.ts +0 -0
- /package/{elements → src/elements}/Label.d.ts +0 -0
- /package/{elements → src/elements}/Legend.d.ts +0 -0
- /package/{elements → src/elements}/Table/SimpleTable.d.ts +0 -0
- /package/{elements → src/elements}/Tag/Disk.d.ts +0 -0
- /package/{elements → src/elements}/Tag/index.d.ts +0 -0
- /package/{elements → src/elements}/TagGroup.d.ts +0 -0
- /package/{fields → src/fields}/Checkbox.d.ts +0 -0
- /package/{fields → src/fields}/CoordinatesInput/DDCoordinatesInput.d.ts +0 -0
- /package/{fields → src/fields}/CoordinatesInput/DMDCoordinatesInput.d.ts +0 -0
- /package/{fields → src/fields}/CoordinatesInput/DMSCoordinatesInput.d.ts +0 -0
- /package/{fields → src/fields}/CoordinatesInput/index.d.ts +0 -0
- /package/{fields → src/fields}/DatePicker/CalendarPicker.d.ts +0 -0
- /package/{fields → src/fields}/DatePicker/index.d.ts +0 -0
- /package/{fields → src/fields}/DateRangePicker/DateInput.d.ts +0 -0
- /package/{fields → src/fields}/DateRangePicker/RangeCalendarPicker.d.ts +0 -0
- /package/{fields → src/fields}/DateRangePicker/RangedTimePicker.d.ts +0 -0
- /package/{fields → src/fields}/DateRangePicker/TimeInput.d.ts +0 -0
- /package/{fields → src/fields}/DateRangePicker/constants.d.ts +0 -0
- /package/{fields → src/fields}/DateRangePicker/index.d.ts +0 -0
- /package/{fields → src/fields}/DateRangePicker/types.d.ts +0 -0
- /package/{fields → src/fields}/DateRangePicker/utils.d.ts +0 -0
- /package/{fields → src/fields}/MultiCheckbox.d.ts +0 -0
- /package/{fields → src/fields}/MultiRadio.d.ts +0 -0
- /package/{fields → src/fields}/MultiSelect.d.ts +0 -0
- /package/{fields → src/fields}/MultiZoneEditor/index.d.ts +0 -0
- /package/{fields → src/fields}/NumberInput.d.ts +0 -0
- /package/{fields → src/fields}/Search.d.ts +0 -0
- /package/{fields → src/fields}/Select.d.ts +0 -0
- /package/{fields → src/fields}/TextInput.d.ts +0 -0
- /package/{fields → src/fields}/Textarea.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikCheckbox.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikCoordinatesInput.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikDatePicker.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikDateRangePicker.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikEffect.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikMultiCheckbox.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikMultiRadio.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikMultiSelect.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikNumberInput.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikSearch.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikSelect.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikTextInput.d.ts +0 -0
- /package/{formiks → src/formiks}/FormikTextarea.d.ts +0 -0
- /package/{hooks → src/hooks}/useClickOutsideEffect.d.ts +0 -0
- /package/{hooks → src/hooks}/useFieldControl.d.ts +0 -0
- /package/{hooks → src/hooks}/useFieldUndefineEffect.d.ts +0 -0
- /package/{hooks → src/hooks}/useForceUpdate.d.ts +0 -0
- /package/{hooks → src/hooks}/useKey.d.ts +0 -0
- /package/{hooks → src/hooks}/useNewWindow/context.d.ts +0 -0
- /package/{hooks → src/hooks}/useNewWindow/index.d.ts +0 -0
- /package/{hooks → src/hooks}/useNewWindow/types.d.ts +0 -0
- /package/{hooks → src/hooks}/usePreventWheelEvent.d.ts +0 -0
- /package/{hooks → src/hooks}/usePrevious.d.ts +0 -0
- /package/{icons → src/icons}/ActivityFeed.d.ts +0 -0
- /package/{icons → src/icons}/Alert.d.ts +0 -0
- /package/{icons → src/icons}/Anchor.d.ts +0 -0
- /package/{icons → src/icons}/Archive.d.ts +0 -0
- /package/{icons → src/icons}/Attention.d.ts +0 -0
- /package/{icons → src/icons}/Calendar.d.ts +0 -0
- /package/{icons → src/icons}/Check.d.ts +0 -0
- /package/{icons → src/icons}/Chevron.d.ts +0 -0
- /package/{icons → src/icons}/Clock.d.ts +0 -0
- /package/{icons → src/icons}/Close.d.ts +0 -0
- /package/{icons → src/icons}/Confirm.d.ts +0 -0
- /package/{icons → src/icons}/Control.d.ts +0 -0
- /package/{icons → src/icons}/Delete.d.ts +0 -0
- /package/{icons → src/icons}/Display.d.ts +0 -0
- /package/{icons → src/icons}/DoubleChevron.d.ts +0 -0
- /package/{icons → src/icons}/Download.d.ts +0 -0
- /package/{icons → src/icons}/Drapeau.d.ts +0 -0
- /package/{icons → src/icons}/Duplicate.d.ts +0 -0
- /package/{icons → src/icons}/Edit.d.ts +0 -0
- /package/{icons → src/icons}/EditBis.d.ts +0 -0
- /package/{icons → src/icons}/Expand.d.ts +0 -0
- /package/{icons → src/icons}/Favorite.d.ts +0 -0
- /package/{icons → src/icons}/FilledArrow.d.ts +0 -0
- /package/{icons → src/icons}/Filter.d.ts +0 -0
- /package/{icons → src/icons}/FilterBis.d.ts +0 -0
- /package/{icons → src/icons}/Fishery.d.ts +0 -0
- /package/{icons → src/icons}/FishingEngine.d.ts +0 -0
- /package/{icons → src/icons}/FleetSegment.d.ts +0 -0
- /package/{icons → src/icons}/Focus.d.ts +0 -0
- /package/{icons → src/icons}/FocusVessel.d.ts +0 -0
- /package/{icons → src/icons}/FocusZones.d.ts +0 -0
- /package/{icons → src/icons}/Hide.d.ts +0 -0
- /package/{icons → src/icons}/Info.d.ts +0 -0
- /package/{icons → src/icons}/Infringement.d.ts +0 -0
- /package/{icons → src/icons}/Landmark.d.ts +0 -0
- /package/{icons → src/icons}/List.d.ts +0 -0
- /package/{icons → src/icons}/MapLayers.d.ts +0 -0
- /package/{icons → src/icons}/MeasureAngle.d.ts +0 -0
- /package/{icons → src/icons}/MeasureBrokenLine.d.ts +0 -0
- /package/{icons → src/icons}/MeasureCircle.d.ts +0 -0
- /package/{icons → src/icons}/MeasureLine.d.ts +0 -0
- /package/{icons → src/icons}/Minus.d.ts +0 -0
- /package/{icons → src/icons}/MissionAction.d.ts +0 -0
- /package/{icons → src/icons}/More.d.ts +0 -0
- /package/{icons → src/icons}/Note.d.ts +0 -0
- /package/{icons → src/icons}/Observation.d.ts +0 -0
- /package/{icons → src/icons}/Pin.d.ts +0 -0
- /package/{icons → src/icons}/PinFilled.d.ts +0 -0
- /package/{icons → src/icons}/Pinpoint.d.ts +0 -0
- /package/{icons → src/icons}/PinpointHide.d.ts +0 -0
- /package/{icons → src/icons}/Plane.d.ts +0 -0
- /package/{icons → src/icons}/Plus.d.ts +0 -0
- /package/{icons → src/icons}/Reject.d.ts +0 -0
- /package/{icons → src/icons}/Report.d.ts +0 -0
- /package/{icons → src/icons}/Save.d.ts +0 -0
- /package/{icons → src/icons}/Search.d.ts +0 -0
- /package/{icons → src/icons}/SelectCircle.d.ts +0 -0
- /package/{icons → src/icons}/SelectPolygon.d.ts +0 -0
- /package/{icons → src/icons}/SelectRectangle.d.ts +0 -0
- /package/{icons → src/icons}/SelectZone.d.ts +0 -0
- /package/{icons → src/icons}/Semaphore.d.ts +0 -0
- /package/{icons → src/icons}/ShowErsMessages.d.ts +0 -0
- /package/{icons → src/icons}/ShowXml.d.ts +0 -0
- /package/{icons → src/icons}/SortingArrows.d.ts +0 -0
- /package/{icons → src/icons}/Summary.d.ts +0 -0
- /package/{icons → src/icons}/Tag.d.ts +0 -0
- /package/{icons → src/icons}/Target.d.ts +0 -0
- /package/{icons → src/icons}/Unlock.d.ts +0 -0
- /package/{icons → src/icons}/Vessel.d.ts +0 -0
- /package/{icons → src/icons}/ViewOnMap.d.ts +0 -0
- /package/{icons → src/icons}/Vms.d.ts +0 -0
- /package/{icons → src/icons}/index.d.ts +0 -0
- /package/{index.d.ts → src/index.d.ts} +0 -0
- /package/{libs → src/libs}/CustomSearch.d.ts +0 -0
- /package/{theme.d.ts → src/theme.d.ts} +0 -0
- /package/{types.d.ts → src/types.d.ts} +0 -0
- /package/{utils → src/utils}/cleanString.d.ts +0 -0
- /package/{utils → src/utils}/coordinates.d.ts +0 -0
- /package/{utils → src/utils}/customDayjs.d.ts +0 -0
- /package/{utils → src/utils}/getLocalizedDayjs.d.ts +0 -0
- /package/{utils → src/utils}/getPseudoRandomString.d.ts +0 -0
- /package/{utils → src/utils}/getRsuiteDataFromOptions.d.ts +0 -0
- /package/{utils → src/utils}/getRsuiteValueFromOptionValue.d.ts +0 -0
- /package/{utils → src/utils}/getUtcizedDayjs.d.ts +0 -0
- /package/{utils → src/utils}/isDaylightSavingTimeDate.d.ts +0 -0
- /package/{utils → src/utils}/isNumeric.d.ts +0 -0
- /package/{utils → src/utils}/logSoftError.d.ts +0 -0
- /package/{utils → src/utils}/normalizeString.d.ts +0 -0
- /package/{utils → src/utils}/sortDates.d.ts +0 -0
- /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
|
|
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
|
-
|
|
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
|
-
|
|
21578
|
+
onNext();
|
|
21565
21579
|
}
|
|
21566
|
-
}, [
|
|
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,
|
|
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
|
|
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
|
|
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
|
-
|
|
21949
|
-
|
|
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
|
|
21960
|
-
if (!withTime || selectedUtcTimeTupleRef.current) {
|
|
21961
|
-
// we must update the selected
|
|
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
|
-
|
|
21995
|
+
callOnChange();
|
|
21965
21996
|
}
|
|
21966
21997
|
if (isFilled) {
|
|
21967
21998
|
handleDateInputNext();
|
|
21968
21999
|
}
|
|
21969
|
-
}, [defaultTimeTuple, handleDateInputNext, isEndDate,
|
|
22000
|
+
}, [callOnChange, defaultTimeTuple, handleDateInputNext, isEndDate, withTime]);
|
|
21970
22001
|
const handleCalendarPickerChange = useCallback((nextUtcizedDateTuple) => {
|
|
21971
|
-
// If
|
|
22002
|
+
// If there is NO time input,
|
|
21972
22003
|
if (!withTime) {
|
|
22004
|
+
// we update the selected datetime
|
|
21973
22005
|
selectedUtcDateAsDayjsRef.current = getDayjsFromUtcDateAndTimeTuple(nextUtcizedDateTuple,
|
|
21974
|
-
//
|
|
22006
|
+
// with a time set to the start (or end) of the day
|
|
21975
22007
|
defaultTimeTuple, isEndDate);
|
|
21976
22008
|
}
|
|
21977
|
-
// If
|
|
21978
|
-
else {
|
|
21979
|
-
|
|
21980
|
-
|
|
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
|
-
|
|
21988
|
-
if (withTime &&
|
|
22018
|
+
callOnChange();
|
|
22019
|
+
if (withTime && timeInputRef.current) {
|
|
21989
22020
|
timeInputRef.current.focus();
|
|
21990
22021
|
}
|
|
21991
|
-
}, [closeCalendarPicker, defaultTimeTuple, forceUpdate, isEndDate,
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
22029
|
-
}, [
|
|
22036
|
+
callOnChange();
|
|
22037
|
+
}, [callOnChange]);
|
|
22030
22038
|
const openCalendarPicker = useCallback(() => {
|
|
22031
|
-
|
|
22032
|
-
|
|
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:
|
|
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
|
|
22303
|
-
const
|
|
22304
|
-
const
|
|
22305
|
-
const
|
|
22306
|
-
const selectedEndDateTupleRef = useRef(getUtcDateTupleFromDayjs(
|
|
22307
|
-
const
|
|
22308
|
-
const
|
|
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
|
|
22323
|
-
if (!onChange || !
|
|
22329
|
+
const callOnChange = useCallback(() => {
|
|
22330
|
+
if (!onChange || !selectedStartDateTimeAsDayjsRef.current || !selectedEndDateTimeAsDayjsRef.current) {
|
|
22324
22331
|
return;
|
|
22325
22332
|
}
|
|
22326
22333
|
if (isStringDate) {
|
|
22327
|
-
const startUtcDateAsString =
|
|
22328
|
-
const endUtcDateAsString =
|
|
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 =
|
|
22334
|
-
const endUtcDate =
|
|
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
|
-
|
|
22340
|
-
|
|
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
|
|
22379
|
-
if (!withTime || selectedStartTimeTupleRef.current) {
|
|
22380
|
-
// we
|
|
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
|
-
|
|
22384
|
-
|
|
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
|
|
22393
|
-
if (!withTime || selectedEndTimeTupleRef.current) {
|
|
22394
|
-
// we
|
|
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
|
-
|
|
22398
|
-
|
|
22431
|
+
selectedEndDateTimeAsDayjsRef.current = nextEndDateAsDayjs;
|
|
22432
|
+
callOnChange();
|
|
22399
22433
|
}
|
|
22400
22434
|
if (isFilled) {
|
|
22401
22435
|
handleEndDateInputNext();
|
|
22402
22436
|
}
|
|
22403
22437
|
}
|
|
22404
|
-
}, [handleEndDateInputNext, handleStartDateInputNext,
|
|
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
|
|
22441
|
+
// If there is NO time input,
|
|
22441
22442
|
if (!withTime) {
|
|
22442
|
-
// we have to fix the start
|
|
22443
|
-
|
|
22444
|
-
// and the end
|
|
22445
|
-
|
|
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
|
|
22448
|
+
// If there is a time input,
|
|
22448
22449
|
else {
|
|
22449
|
-
//
|
|
22450
|
-
|
|
22451
|
-
|
|
22452
|
-
|
|
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(
|
|
22460
|
+
selectedStartTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedStartDateTimeAsDayjsRef.current);
|
|
22456
22461
|
selectedEndDateTupleRef.current = nextEndUtcDateTuple;
|
|
22457
|
-
selectedEndTimeTupleRef.current = getUtcTimeTupleFromDayjs(
|
|
22462
|
+
selectedEndTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedEndDateTimeAsDayjsRef.current);
|
|
22458
22463
|
closeRangeCalendarPicker();
|
|
22459
|
-
|
|
22460
|
-
}, [
|
|
22461
|
-
const
|
|
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
|
|
22471
|
+
// If a start date is selected
|
|
22467
22472
|
if (selectedStartDateTupleRef.current) {
|
|
22468
|
-
// we
|
|
22473
|
+
// we update the selected start datetime and submit it
|
|
22469
22474
|
const nextStartDateAsDayjs = getDayjsFromUtcDateAndTimeTuple(selectedStartDateTupleRef.current, nextTimeTuple);
|
|
22470
|
-
|
|
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
|
|
22480
|
+
// If an end date is selected
|
|
22478
22481
|
if (selectedEndDateTupleRef.current) {
|
|
22479
|
-
// we
|
|
22482
|
+
// we update the selected end datetime and submit it
|
|
22480
22483
|
const nextEndDateAsDayjs = getDayjsFromUtcDateAndTimeTuple(selectedEndDateTupleRef.current, nextTimeTuple, true);
|
|
22481
|
-
|
|
22482
|
-
submit();
|
|
22484
|
+
selectedEndDateTimeAsDayjsRef.current = nextEndDateAsDayjs;
|
|
22483
22485
|
}
|
|
22484
22486
|
selectedEndTimeTupleRef.current = nextTimeTuple;
|
|
22485
22487
|
}
|
|
22486
|
-
|
|
22487
|
-
}, [
|
|
22488
|
+
callOnChange();
|
|
22489
|
+
}, [callOnChange]);
|
|
22488
22490
|
const openRangeCalendarPicker = useCallback(() => {
|
|
22489
|
-
|
|
22490
|
-
|
|
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
|
-
|
|
22511
|
-
|
|
22512
|
-
selectedStartDateTupleRef.current = getUtcDateTupleFromDayjs(
|
|
22513
|
-
selectedEndDateTupleRef.current = getUtcDateTupleFromDayjs(
|
|
22514
|
-
selectedStartTimeTupleRef.current = getUtcTimeTupleFromDayjs(
|
|
22515
|
-
selectedEndTimeTupleRef.current = getUtcTimeTupleFromDayjs(
|
|
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:
|
|
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
|
* {
|