@monolith-forensics/monolith-ui 1.1.81 → 1.1.83
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.
|
@@ -199,6 +199,8 @@ const DateInput = styled(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:
|
|
|
199
199
|
const { getReferenceProps } = useInteractions([dismiss]);
|
|
200
200
|
const segments = useMemo(() => parseTimestamp(moment(value).toISOString(), format, utc), [value, format, utc]);
|
|
201
201
|
const checkValidRange = (value) => {
|
|
202
|
+
if (!value)
|
|
203
|
+
return false;
|
|
202
204
|
if (min && moment(value).isBefore(min))
|
|
203
205
|
return false;
|
|
204
206
|
if (max && moment(value).isAfter(max))
|
|
@@ -334,12 +336,15 @@ const DateInput = styled(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:
|
|
|
334
336
|
if (!(selectedSegment === null || selectedSegment === void 0 ? void 0 : selectedSegment.momentType))
|
|
335
337
|
return prev;
|
|
336
338
|
const momentValue = utc ? moment.utc(prev) : moment(prev);
|
|
337
|
-
|
|
339
|
+
let newValue = moment(momentValue)
|
|
338
340
|
.set(selectedSegment.momentType, parseInt(tempValue, 10) -
|
|
339
341
|
(selectedSegment.type === "month" ? 1 : 0))
|
|
340
342
|
.toISOString();
|
|
341
343
|
if (!checkValidRange(newValue))
|
|
342
344
|
return prev;
|
|
345
|
+
if (isDateOnly) {
|
|
346
|
+
newValue = moment(newValue).format("YYYY-MM-DD");
|
|
347
|
+
}
|
|
343
348
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
344
349
|
return newValue;
|
|
345
350
|
});
|
|
@@ -350,18 +355,28 @@ const DateInput = styled(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:
|
|
|
350
355
|
}
|
|
351
356
|
};
|
|
352
357
|
const handleWheelEvent = (e) => {
|
|
353
|
-
if (!selectedSegment)
|
|
358
|
+
if (!selectedSegment) {
|
|
354
359
|
return;
|
|
360
|
+
}
|
|
355
361
|
setValue((prev) => {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
362
|
+
let newValue = prev;
|
|
363
|
+
if (selectedSegment.type === "separator") {
|
|
364
|
+
newValue = prev; // skip all logic if separator
|
|
365
|
+
}
|
|
366
|
+
else if (!prev) {
|
|
367
|
+
newValue = isDateOnly
|
|
368
|
+
? moment().format(format)
|
|
369
|
+
: moment().toISOString();
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
newValue =
|
|
373
|
+
e.deltaY > 0
|
|
374
|
+
? moment(newValue).subtract(1, selectedSegment.type).toISOString()
|
|
375
|
+
: moment(newValue).add(1, selectedSegment.type).toISOString();
|
|
376
|
+
}
|
|
377
|
+
if (!checkValidRange(newValue)) {
|
|
364
378
|
return prev;
|
|
379
|
+
}
|
|
365
380
|
newValue = isDateOnly ? moment(newValue).format(format) : newValue;
|
|
366
381
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
367
382
|
return newValue;
|