@monolith-forensics/monolith-ui 1.1.82 → 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.
@@ -12,7 +12,7 @@ interface DateInputProps {
12
12
  variant?: Variant;
13
13
  clearable?: boolean;
14
14
  required?: boolean;
15
- onChange?: (value: string | null) => void;
15
+ onChange?: (value?: string | null) => void;
16
16
  min?: Date;
17
17
  max?: Date;
18
18
  error?: string;
@@ -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))
@@ -353,18 +355,28 @@ const DateInput = styled(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:
353
355
  }
354
356
  };
355
357
  const handleWheelEvent = (e) => {
356
- if (!selectedSegment)
358
+ if (!selectedSegment) {
357
359
  return;
360
+ }
358
361
  setValue((prev) => {
359
- if (selectedSegment.type === "separator")
360
- return prev;
361
- if (!prev)
362
- return isDateOnly ? moment().format(format) : moment().toISOString();
363
- let newValue = e.deltaY > 0
364
- ? moment(prev).subtract(1, selectedSegment.type).toISOString()
365
- : moment(prev).add(1, selectedSegment.type).toISOString();
366
- if (!checkValidRange(newValue))
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)) {
367
378
  return prev;
379
+ }
368
380
  newValue = isDateOnly ? moment(newValue).format(format) : newValue;
369
381
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
370
382
  return newValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.1.82",
3
+ "version": "1.1.83",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",