@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.
@@ -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))
@@ -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
- const newValue = moment(momentValue)
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
- if (selectedSegment.type === "separator")
357
- return prev;
358
- if (!prev)
359
- return isDateOnly ? moment().format(format) : moment().toISOString();
360
- let newValue = e.deltaY > 0
361
- ? moment(prev).subtract(1, selectedSegment.type).toISOString()
362
- : moment(prev).add(1, selectedSegment.type).toISOString();
363
- 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)) {
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.1.81",
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)",