opus-toolkit-components 0.7.8 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3792,17 +3792,53 @@ function DatePicker(_ref) {
|
|
|
3792
3792
|
} = _ref;
|
|
3793
3793
|
const [selectedDate, setSelectedDate] = (0,external_react_.useState)(value || initialDate);
|
|
3794
3794
|
const inputRef = (0,external_react_.useRef)(null);
|
|
3795
|
+
function convertToInputDateFormat(dateString) {
|
|
3796
|
+
if (!dateString) return '';
|
|
3797
|
+
const parts = dateString.split('/');
|
|
3798
|
+
if (parts.length !== 3) return '';
|
|
3799
|
+
const [day, month, year] = parts;
|
|
3800
|
+
return "".concat(year, "-").concat(month.padStart(2, '0'), "-").concat(day.padStart(2, '0'));
|
|
3801
|
+
}
|
|
3795
3802
|
(0,external_react_.useEffect)(() => {
|
|
3796
|
-
|
|
3797
|
-
|
|
3803
|
+
function normalizeDate(dateString) {
|
|
3804
|
+
if (!dateString) return '';
|
|
3805
|
+
// Remove the time part if it exists
|
|
3806
|
+
const [datePart] = dateString.split(' ');
|
|
3807
|
+
if (datePart.includes('-')) {
|
|
3808
|
+
return datePart;
|
|
3809
|
+
}
|
|
3810
|
+
const parts = datePart.split('/');
|
|
3811
|
+
if (parts.length !== 3) return '';
|
|
3812
|
+
const [month, day, year] = parts; // notice month first here
|
|
3813
|
+
return "".concat(year, "-").concat(month.padStart(2, '0'), "-").concat(day.padStart(2, '0'));
|
|
3814
|
+
}
|
|
3815
|
+
const normalizedValue = normalizeDate(value);
|
|
3816
|
+
const normalizedInitialDate = normalizeDate(initialDate);
|
|
3817
|
+
if (value !== undefined && value !== null) {
|
|
3818
|
+
setSelectedDate(normalizedValue);
|
|
3798
3819
|
} else {
|
|
3799
|
-
setSelectedDate(
|
|
3820
|
+
setSelectedDate(normalizedInitialDate);
|
|
3800
3821
|
}
|
|
3801
3822
|
}, [value, initialDate]);
|
|
3823
|
+
(0,external_react_.useEffect)(() => {
|
|
3824
|
+
if (value !== undefined && value !== selectedDate) {
|
|
3825
|
+
setSelectedDate(value); // Sync selectedDate when value prop changes
|
|
3826
|
+
}
|
|
3827
|
+
}, [value, selectedDate]);
|
|
3802
3828
|
const handleDateChange = e => {
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3829
|
+
const rawValue = e.target.value; // yyyy-MM-dd
|
|
3830
|
+
setSelectedDate(rawValue);
|
|
3831
|
+
if (onChange && rawValue) {
|
|
3832
|
+
const [year, month, day] = rawValue.split('-');
|
|
3833
|
+
const formattedValue = "".concat(day, "/").concat(month, "/").concat(year);
|
|
3834
|
+
onChange({
|
|
3835
|
+
target: {
|
|
3836
|
+
name,
|
|
3837
|
+
value: formattedValue,
|
|
3838
|
+
// dd/MM/yyyy
|
|
3839
|
+
rawValue // yyyy-MM-dd
|
|
3840
|
+
}
|
|
3841
|
+
});
|
|
3806
3842
|
}
|
|
3807
3843
|
};
|
|
3808
3844
|
const handleIconClick = () => {
|
|
@@ -12517,4 +12553,4 @@ const Pill = _ref => {
|
|
|
12517
12553
|
/******/ })()
|
|
12518
12554
|
;
|
|
12519
12555
|
});
|
|
12520
|
-
//# sourceMappingURL=main.
|
|
12556
|
+
//# sourceMappingURL=main.0b2b73d40c9be7ecb7d6.js.map
|