@monolith-forensics/monolith-ui 1.3.10 → 1.3.16

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.
@@ -3,6 +3,7 @@ import { Size, Variant } from "../core";
3
3
  import { MonolithDefaultTheme } from "../MonolithUIProvider";
4
4
  declare const colors: {
5
5
  gray: string;
6
+ lightGray: string;
6
7
  red: string;
7
8
  pink: string;
8
9
  grape: string;
@@ -15,6 +15,7 @@ import styled from "styled-components";
15
15
  import { Loader2Icon } from "lucide-react";
16
16
  const colors = {
17
17
  gray: "#888888",
18
+ lightGray: "#f0f0f0",
18
19
  red: "#e03131",
19
20
  pink: "#c2255c",
20
21
  grape: "#9c36b5",
@@ -53,7 +54,6 @@ const StyledButton = styled.button `
53
54
  }
54
55
  }};
55
56
 
56
- font-weight: 525;
57
57
  font-size: ${({ theme, size }) => {
58
58
  switch (size) {
59
59
  case "xxs":
@@ -206,9 +206,9 @@ const StyledButton = styled.button `
206
206
  }
207
207
  switch (variant) {
208
208
  case "contained":
209
- return (resolvedColor || theme.palette.background.secondary) + "90";
209
+ return (resolvedColor || theme.button.background.secondary) + "90";
210
210
  case "filled":
211
- return (resolvedColor || theme.palette.background.secondary) + "90";
211
+ return (resolvedColor || theme.button.background.secondary) + "90";
212
212
  case "light":
213
213
  return resolvedColor
214
214
  ? resolvedColor + "70"
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment, useEffect, useState } from "react";
2
+ import { Fragment, useEffect, useRef, useState } from "react";
3
3
  import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
4
4
  import { CalendarContainer, CalendarHeader, CalendarGrid, CalendarMonth, CalendarDay, CalendarDate, HighlightedCalendarDate, TodayCalendarDate, TimeContainer, MainContainer, TimePickerContainer, TimeHourSelect, TimeHeader, TimeMinuteSelect, TimeItem, TimeItemActive, NoValueButton, } from "./CalendarStyles";
5
5
  import calendar, { isDate, isSameDay, isSameMonth, getDateISO, getNextMonth, getPreviousMonth, WEEK_DAYS, CALENDAR_MONTHS, HOURS24, HOURS12, MINUTES, } from "./calendarHelpers";
@@ -11,16 +11,23 @@ const checkValidRange = (value, min, max) => {
11
11
  return false;
12
12
  return true;
13
13
  };
14
+ const resolveValue = (value) => {
15
+ const safeValue = value || new Date();
16
+ return {
17
+ month: safeValue.getMonth() + 1,
18
+ year: safeValue.getFullYear(),
19
+ hours: safeValue.getHours(),
20
+ minutes: safeValue.getMinutes(),
21
+ };
22
+ };
14
23
  const Calendar = ({ defaultValue = new Date(), value, onChange = () => { }, hourFormat = "24", includeTime = true, clearable = true, min, max, }) => {
15
- const [dateState, setDateState] = useState(() => {
16
- const safeDefaultValue = defaultValue || new Date();
17
- return {
18
- current: defaultValue,
19
- month: safeDefaultValue.getMonth() + 1,
20
- year: safeDefaultValue.getFullYear(),
21
- hours: 0,
22
- minutes: 0,
23
- };
24
+ const isControlled = useRef(value !== undefined);
25
+ const [valueState, setValueState] = useState(defaultValue);
26
+ const _value = isControlled.current
27
+ ? value
28
+ : valueState;
29
+ const [calendarState, setCalendarState] = useState(() => {
30
+ return resolveValue(_value);
24
31
  });
25
32
  const [today, setToday] = useState(new Date());
26
33
  let pressureTimer;
@@ -29,8 +36,8 @@ const Calendar = ({ defaultValue = new Date(), value, onChange = () => { }, hour
29
36
  const addDateToState = (date) => {
30
37
  const isDateObject = isDate(date);
31
38
  const _date = isDateObject ? date : new Date();
32
- setDateState({
33
- current: isDateObject ? date : null,
39
+ setValueState(_date);
40
+ setCalendarState({
34
41
  month: +_date.getMonth() + 1,
35
42
  year: _date.getFullYear(),
36
43
  hours: _date.getHours(),
@@ -38,14 +45,14 @@ const Calendar = ({ defaultValue = new Date(), value, onChange = () => { }, hour
38
45
  });
39
46
  };
40
47
  const getCalendarDates = () => {
41
- const { current, month, year } = dateState;
42
- const calendarMonth = month || +((current === null || current === void 0 ? void 0 : current.getMonth()) || 0) + 1;
43
- const calendarYear = year || (current === null || current === void 0 ? void 0 : current.getFullYear()) || new Date().getFullYear();
48
+ const { month, year } = calendarState;
49
+ const calendarMonth = month || +((_value === null || _value === void 0 ? void 0 : _value.getMonth()) || 0) + 1;
50
+ const calendarYear = year || (_value === null || _value === void 0 ? void 0 : _value.getFullYear()) || new Date().getFullYear();
44
51
  return calendar(calendarMonth, calendarYear);
45
52
  };
46
53
  //new start
47
54
  const renderMonthAndYear = () => {
48
- const { month, year } = dateState;
55
+ const { month, year } = calendarState;
49
56
  // Resolve the month name from the CALENDAR_MONTHS object map
50
57
  const monthname = Object.keys(CALENDAR_MONTHS)[Math.max(0, Math.min(month - 1, 11))];
51
58
  return (_jsxs(CalendarHeader, { children: [_jsx(ChevronLeftIcon, { onMouseDown: handlePrevious, onMouseUp: clearPressureTimer }), _jsxs(CalendarMonth, { children: [monthname, " ", year] }), _jsx(ChevronRightIcon, { onMouseDown: handleNext, onMouseUp: clearPressureTimer })] }));
@@ -60,12 +67,12 @@ const Calendar = ({ defaultValue = new Date(), value, onChange = () => { }, hour
60
67
  // Render a calendar date as returned from the calendar builder function
61
68
  // This method is used as a map callback as seen in render()
62
69
  const renderCalendarDate = (date, index) => {
63
- const { current, month, year } = dateState;
70
+ const { month, year } = calendarState;
64
71
  const _date = new Date(date.join("-"));
65
72
  // Check if calendar date is same day as today
66
73
  const isToday = isSameDay(_date, today);
67
74
  // Check if calendar date is same day as currently selected date
68
- const isCurrent = current && isSameDay(_date, current);
75
+ const isCurrent = _value && isSameDay(_date, _value);
69
76
  // Check if calendar date is in the same month as the state month and year
70
77
  const inMonth = month && year && isSameMonth(_date, new Date([year, month, 1].join("-")));
71
78
  // The click handler
@@ -81,88 +88,81 @@ const Calendar = ({ defaultValue = new Date(), value, onChange = () => { }, hour
81
88
  return isCurrent ? (_jsx(HighlightedCalendarDate, Object.assign({}, props, { children: _date.getDate() }))) : isToday ? (_jsx(TodayCalendarDate, Object.assign({}, props, { children: _date.getDate() }))) : (_jsx(CalendarDate, Object.assign({}, props, { children: _date.getDate() })));
82
89
  };
83
90
  const renderHours = () => {
84
- const { hours } = dateState;
91
+ const { hours } = calendarState;
85
92
  const hoursArray = hourFormat === "24" ? HOURS24 : HOURS12;
86
93
  return hoursArray.map((hour, index) => {
87
94
  const HourComponent = hour.value === hours ? TimeItemActive : TimeItem;
88
95
  return (_jsx(HourComponent, {
89
96
  // value={hour.value}
90
97
  onClick: (e) => {
91
- const newTime = moment(dateState.current)
92
- .hours(hour.value)
93
- .toDate();
94
- setDateState(Object.assign(Object.assign({}, dateState), { hours: hour.value, current: newTime }));
95
- onChange(newTime);
98
+ const newTime = moment(_value).hours(hour.value).toDate();
99
+ setCalendarState(Object.assign(Object.assign({}, calendarState), { hours: hour.value }));
100
+ setValueState(newTime);
101
+ onChange === null || onChange === void 0 ? void 0 : onChange(newTime);
96
102
  }, children: hour.label }, hour.value));
97
103
  });
98
104
  };
99
105
  const renderMinutes = () => {
100
- const { minutes } = dateState;
106
+ const { minutes } = calendarState;
101
107
  return MINUTES.map((minute) => {
102
108
  const MinuteComponent = minute === minutes ? TimeItemActive : TimeItem;
103
109
  return (_jsx(MinuteComponent, {
104
110
  // value={minute}
105
111
  onClick: (e) => {
106
- const newTime = moment(dateState.current)
107
- .minutes(Number(minute))
108
- .toDate();
109
- setDateState(Object.assign(Object.assign({}, dateState), { minutes: Number(minute), current: newTime }));
110
- onChange(newTime);
112
+ const newTime = moment(_value).minutes(Number(minute)).toDate();
113
+ setCalendarState(Object.assign(Object.assign({}, calendarState), { minutes: Number(minute) }));
114
+ setValueState(newTime);
115
+ onChange === null || onChange === void 0 ? void 0 : onChange(newTime);
111
116
  }, children: minute }, minute));
112
117
  });
113
118
  };
114
119
  // new 2
115
120
  const gotoDate = (date) => (evt) => {
116
121
  evt && evt.preventDefault();
117
- const { current } = dateState;
118
122
  // Set Hours and Minutes
119
123
  const newTime = moment(date)
120
- .hours(includeTime ? dateState.hours : 0)
121
- .minutes(includeTime ? dateState.minutes : 0)
124
+ .hours(includeTime ? calendarState.hours : 0)
125
+ .minutes(includeTime ? calendarState.minutes : 0)
122
126
  .toDate();
123
- !(current && isSameDay(newTime, current)) && addDateToState(newTime);
127
+ !(_value && isSameDay(newTime, _value)) && addDateToState(newTime);
124
128
  onChange(newTime);
125
129
  };
126
130
  const gotoPreviousMonth = () => {
127
- const { month, year } = dateState;
131
+ const { month, year } = calendarState;
128
132
  const previousMonth = getPreviousMonth(month, year);
129
- setDateState({
133
+ setCalendarState({
130
134
  month: previousMonth.month,
131
135
  year: previousMonth.year,
132
- current: dateState.current,
133
- hours: dateState.hours,
134
- minutes: dateState.minutes,
136
+ hours: calendarState.hours,
137
+ minutes: calendarState.minutes,
135
138
  });
136
139
  };
137
140
  const gotoNextMonth = () => {
138
- const { month, year } = dateState;
141
+ const { month, year } = calendarState;
139
142
  const nextMonth = getNextMonth(month, year);
140
- setDateState({
143
+ setCalendarState({
141
144
  month: nextMonth.month,
142
145
  year: nextMonth.year,
143
- current: dateState.current,
144
- hours: dateState.hours,
145
- minutes: dateState.minutes,
146
+ hours: calendarState.hours,
147
+ minutes: calendarState.minutes,
146
148
  });
147
149
  };
148
150
  const gotoPreviousYear = () => {
149
- const { year } = dateState;
150
- setDateState({
151
- month: dateState.month,
151
+ const { year } = calendarState;
152
+ setCalendarState({
153
+ month: calendarState.month,
152
154
  year: year - 1,
153
- current: dateState.current,
154
- hours: dateState.hours,
155
- minutes: dateState.minutes,
155
+ hours: calendarState.hours,
156
+ minutes: calendarState.minutes,
156
157
  });
157
158
  };
158
159
  const gotoNextYear = () => {
159
- const { year } = dateState;
160
- setDateState({
161
- month: dateState.month,
160
+ const { year } = calendarState;
161
+ setCalendarState({
162
+ month: calendarState.month,
162
163
  year: year + 1,
163
- current: dateState.current,
164
- hours: dateState.hours,
165
- minutes: dateState.minutes,
164
+ hours: calendarState.hours,
165
+ minutes: calendarState.minutes,
166
166
  });
167
167
  };
168
168
  const clearPressureTimer = () => {
@@ -179,28 +179,29 @@ const Calendar = ({ defaultValue = new Date(), value, onChange = () => { }, hour
179
179
  const fn = evt.shiftKey ? gotoNextYear : gotoNextMonth;
180
180
  fn();
181
181
  };
182
+ // update calendar state when value changes
182
183
  useEffect(() => {
183
- if (value) {
184
- addDateToState(value);
184
+ if (_value) {
185
+ addDateToState(_value);
185
186
  }
186
- }, [value]);
187
- // lifecycle methods
188
- useEffect(() => {
189
- const now = new Date().valueOf();
190
- const tomorrow = new Date().setHours(0, 0, 0, 0) + 24 * 60 * 60 * 1000;
191
- const ms = tomorrow - now;
192
- dayTimeout = setTimeout(() => {
193
- setToday(new Date());
194
- clearDayTimeout();
195
- }, ms);
196
- return () => {
197
- clearPressureTimer();
198
- clearDayTimeout();
199
- };
200
- }, []);
201
- const clearDayTimeout = () => {
202
- dayTimeout && clearTimeout(dayTimeout);
203
- };
187
+ }, [_value === null || _value === void 0 ? void 0 : _value.toString()]); // checking for real change in date value, not just object reference change
188
+ // // lifecycle methods
189
+ // useEffect(() => {
190
+ // const now = new Date().valueOf();
191
+ // const tomorrow = new Date().setHours(0, 0, 0, 0) + 24 * 60 * 60 * 1000;
192
+ // const ms = tomorrow - now;
193
+ // dayTimeout = setTimeout(() => {
194
+ // setToday(new Date());
195
+ // clearDayTimeout();
196
+ // }, ms);
197
+ // return () => {
198
+ // clearPressureTimer();
199
+ // clearDayTimeout();
200
+ // };
201
+ // }, []);
202
+ // const clearDayTimeout = () => {
203
+ // dayTimeout && clearTimeout(dayTimeout);
204
+ // };
204
205
  return (_jsxs(MainContainer, { children: [_jsxs(CalendarContainer, { children: [renderMonthAndYear(), _jsxs(CalendarGrid, { children: [_jsx(Fragment, { children: Object.keys(WEEK_DAYS).map(renderDayLabel) }), _jsx(Fragment, { children: getCalendarDates().map(renderCalendarDate) })] }), clearable && (_jsx("div", { style: { textAlign: "center", marginTop: 3 }, children: _jsx(NoValueButton, { onClick: () => onChange(null), children: "Clear Date" }) }))] }), includeTime && (_jsxs(TimeContainer, { children: [_jsx(TimeHeader, { children: "Select Time" }), _jsxs(TimePickerContainer, { children: [_jsx(TimeHourSelect, { children: renderHours() }), _jsx(TimeMinuteSelect, { children: renderMinutes() })] })] }))] }));
205
206
  };
206
207
  Calendar.displayName = "Calendar";
@@ -1,7 +1,6 @@
1
1
  import moment from "moment";
2
- import React from "react";
3
2
  import { Size, Variant } from "../core";
4
- interface DateInputProps {
3
+ type DateInputProps = {
5
4
  className?: string;
6
5
  style?: React.CSSProperties;
7
6
  defaultValue?: string | null | undefined;
@@ -23,7 +22,7 @@ interface DateInputProps {
23
22
  utc?: boolean;
24
23
  closeOnSelect?: boolean;
25
24
  disabled?: boolean;
26
- }
25
+ };
27
26
  export type DateFormatOptions = "MM/DD/YYYY" | "DD/MM/YYYY" | "YYYY-MM-DD";
28
27
  export type TimeFormatOptions = "HH:mm:ss" | "h:mm:ss A" | "HH:mm:ss.SSS";
29
28
  export type FormatOptions = DateFormatOptions | `${DateFormatOptions} ${TimeFormatOptions}`;
@@ -36,5 +35,5 @@ export type Segment = {
36
35
  momentType?: moment.unitOfTime.All | moment.unitOfTime.DurationConstructor;
37
36
  pattern?: string;
38
37
  };
39
- declare const DateInput: React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<HTMLElement>>;
38
+ declare const DateInput: React.FC<DateInputProps>;
40
39
  export default DateInput;
@@ -302,38 +302,34 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
302
302
  // Up Arrow
303
303
  if (e.key === "ArrowUp") {
304
304
  e.preventDefault();
305
- setUncontrolledValue((prev) => {
306
- if (selectedSegment.type === "separator")
307
- return prev;
308
- let newValue = prev
309
- ? moment(prev).add(1, selectedSegment.type).toISOString()
305
+ if (selectedSegment.type !== "separator") {
306
+ let newValue = _value
307
+ ? moment(_value).add(1, selectedSegment.type).toISOString()
310
308
  : moment().toISOString();
311
309
  if (!checkValidRange(newValue))
312
- return prev;
310
+ return;
313
311
  if (isDateOnly) {
314
312
  newValue = moment(newValue).format("YYYY-MM-DD");
315
313
  }
314
+ setUncontrolledValue(newValue);
316
315
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
317
- return newValue;
318
- });
316
+ }
319
317
  }
320
318
  // Down Arrow
321
319
  if (e.key === "ArrowDown") {
322
320
  e.preventDefault();
323
- setUncontrolledValue((prev) => {
324
- if (selectedSegment.type === "separator")
325
- return prev;
326
- let newValue = prev
327
- ? moment(prev).subtract(1, selectedSegment.type).toISOString()
321
+ if (selectedSegment.type !== "separator") {
322
+ let newValue = _value
323
+ ? moment(_value).subtract(1, selectedSegment.type).toISOString()
328
324
  : moment().toISOString();
329
325
  if (!checkValidRange(newValue))
330
- return prev;
326
+ return;
331
327
  if (isDateOnly) {
332
328
  newValue = moment(newValue).format("YYYY-MM-DD");
333
329
  }
330
+ setUncontrolledValue(newValue);
334
331
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
335
- return newValue;
336
- });
332
+ }
337
333
  }
338
334
  // handle paste
339
335
  if (e.key === "v" && (e.metaKey || e.ctrlKey)) {
@@ -378,79 +374,58 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
378
374
  if (!selectedSegment) {
379
375
  return;
380
376
  }
381
- setUncontrolledValue((prev) => {
382
- let newValue = prev;
383
- if (selectedSegment.type === "separator") {
384
- newValue = prev; // skip all logic if separator
385
- }
386
- else if (!prev) {
387
- newValue = isDateOnly
388
- ? moment().format(format)
389
- : moment().toISOString();
390
- }
391
- else {
392
- newValue =
393
- e.deltaY > 0
394
- ? moment(newValue).subtract(1, selectedSegment.type).toISOString()
395
- : moment(newValue).add(1, selectedSegment.type).toISOString();
377
+ if (selectedSegment.type !== "separator") {
378
+ let newValue = e.deltaY > 0
379
+ ? moment(_value).subtract(1, selectedSegment.type).toISOString()
380
+ : moment(_value).add(1, selectedSegment.type).toISOString();
381
+ if (!checkValidRange(newValue))
382
+ return;
383
+ if (isDateOnly) {
384
+ newValue = moment(newValue).format("YYYY-MM-DD");
396
385
  }
397
- if (!checkValidRange(newValue)) {
398
- return prev;
399
- }
400
- newValue = isDateOnly ? moment(newValue).format(format) : newValue;
386
+ setUncontrolledValue(newValue);
401
387
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
402
- return newValue;
403
- });
388
+ }
404
389
  };
405
390
  const handlePaste = (e) => __awaiter(void 0, void 0, void 0, function* () {
406
391
  const pastedText = yield window.navigator.clipboard.readText();
392
+ let parsedTimestamp = null;
407
393
  if (!pastedText)
408
394
  return; // do nothing if clipboard is empty
409
395
  // check for unix timestamp in seconds
410
- if (pastedText.match(/^\d{10}$/)) {
411
- const parsedTimestamp = moment
412
- .unix(parseInt(pastedText, 10))
413
- .toISOString();
414
- setUncontrolledValue(parsedTimestamp);
415
- return;
396
+ else if (pastedText.match(/^\d{10}$/)) {
397
+ parsedTimestamp = moment.unix(parseInt(pastedText, 10)).toISOString();
416
398
  }
417
399
  // check for unix timestamp in seconds with fractional seconds
418
- if (pastedText.match(/^\d{10}\.\d{1,6}$/)) {
419
- const parsedTimestamp = moment
420
- .unix(parseFloat(pastedText))
421
- .toISOString();
422
- setUncontrolledValue(parsedTimestamp);
423
- return;
400
+ else if (pastedText.match(/^\d{10}\.\d{1,6}$/)) {
401
+ parsedTimestamp = moment.unix(parseFloat(pastedText)).toISOString();
424
402
  }
425
403
  // check for unix timestamp in milliseconds
426
- if (pastedText.match(/^\d{13}$/)) {
427
- const parsedTimestamp = moment
404
+ else if (pastedText.match(/^\d{13}$/)) {
405
+ parsedTimestamp = moment
428
406
  .unix(parseInt(pastedText, 10) / 1000)
429
407
  .toISOString();
430
- setUncontrolledValue(parsedTimestamp);
431
- return;
432
408
  }
433
409
  // check for windows ldap or filetime timestamp
434
- if (pastedText.match(/^\d{18}$/)) {
435
- const parsedTimestamp = moment
410
+ else if (pastedText.match(/^\d{18}$/)) {
411
+ parsedTimestamp = moment
436
412
  .unix((parseInt(pastedText, 10) - 116444736000000000) / 10000000)
437
413
  .toISOString();
438
- setUncontrolledValue(parsedTimestamp);
439
- return;
440
414
  }
441
415
  // check for YMD ldap timestamp in format YYYYMMDDHHMMSSZ
442
- if (pastedText.match(/^\d{14}Z$/)) {
443
- const parsedTimestamp = moment
416
+ else if (pastedText.match(/^\d{14}Z$/)) {
417
+ parsedTimestamp = moment
444
418
  .utc(pastedText, "YYYYMMDDHHmmssZ")
445
419
  .toISOString();
446
- setUncontrolledValue(parsedTimestamp);
447
- return;
448
420
  }
449
421
  // check if pasted text is any other valid timestamp
450
- if (!moment(pastedText).isValid())
422
+ else if (!moment(pastedText).isValid())
451
423
  return;
452
- const parsedTimestamp = moment.utc(pastedText).toISOString();
424
+ else {
425
+ parsedTimestamp = moment.utc(pastedText).toISOString();
426
+ }
453
427
  setUncontrolledValue(parsedTimestamp);
428
+ onChange === null || onChange === void 0 ? void 0 : onChange(parsedTimestamp);
454
429
  });
455
430
  // Close on outside click
456
431
  useEffect(() => {
@@ -471,22 +446,13 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
471
446
  document.addEventListener("click", close);
472
447
  return () => document.removeEventListener("click", close);
473
448
  }, [refs.floating]);
474
- // Global Wheel Event when segement selected
475
- useEffect(() => {
476
- if (selectedSegment) {
477
- document.addEventListener("wheel", handleWheelEvent);
478
- }
479
- return () => {
480
- document.removeEventListener("wheel", handleWheelEvent);
481
- };
482
- }, [selectedSegment]);
483
449
  return (_jsxs(StyledContainer, { ref: (ref) => {
484
450
  if (typeof _ref === "function") {
485
451
  _ref(ref);
486
452
  }
487
453
  mainRef.current = ref;
488
454
  refs.setReference(ref);
489
- }, className: className, children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), _jsxs(StyledInputContainer, { className: "input-container", onClick: handleContainerClick, onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, onFocus: (e) => {
455
+ }, onWheel: (e) => handleWheelEvent(e), className: className, children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), _jsxs(StyledInputContainer, { className: "input-container", onClick: handleContainerClick, onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, onFocus: (e) => {
490
456
  e.preventDefault();
491
457
  setSelectedSegment(segments[0]);
492
458
  }, onBlur: () => {
@@ -1,3 +1,2 @@
1
1
  import { DropDownMenuProps } from "./types";
2
- declare const DropDownMenu: ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, dropDownProps, }: DropDownMenuProps) => import("react/jsx-runtime").JSX.Element;
3
- export default DropDownMenu;
2
+ export declare const DropDownMenu: React.FC<DropDownMenuProps>;
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useRef, useState } from "react";
3
3
  import { useDebouncedCallback } from "use-debounce";
4
4
  import { Menu, MenuItemList, SearchInput, StyledInnerItemContainer, } from "./components";
5
- const DropDownMenu = ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, dropDownProps, }) => {
5
+ export const DropDownMenu = ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, dropDownProps, }) => {
6
6
  var _a;
7
7
  const isObjectArray = (_a = Object.keys((data === null || data === void 0 ? void 0 : data[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
8
8
  const [selected, setSelected] = useState(defaultValue || []);
@@ -32,4 +32,3 @@ const DropDownMenu = ({ data, children, defaultValue, variant, arrow, size, sear
32
32
  };
33
33
  return (_jsx(Menu, { label: children, arrow: arrow, buttonSize: size, variant: variant, multiselect: multiselect, buttonProps: buttonProps, onMenuClose: handleMenuClose, dropDownProps: dropDownProps, children: _jsxs(StyledInnerItemContainer, { children: [loading && _jsx("div", { children: "Loading..." }), searchable && (_jsx(SearchInput, { ref: searchInputRef, variant: "outlined", size: size, placeholder: "Search", defaultValue: searchValue, onChange: handleSearch })), !loading && (_jsx(MenuItemList, { menuItems: data, searchable: searchable, searchValue: searchValue, isObjectArray: isObjectArray, selected: selected, TooltipContent: TooltipContent, multiselect: multiselect, size: size, handleAddItem: handleAddItem, handleRemoveItem: handleRemoveItem, onItemSelect: onItemSelect, renderOption: renderOption, onScroll: onScroll }))] }) }));
34
34
  };
35
- export default DropDownMenu;
@@ -3,14 +3,14 @@ import { useLayoutEffect, useRef, useState } from "react";
3
3
  import styled from "styled-components";
4
4
  import { FixedSizeList } from "react-window";
5
5
  import CheckBox from "../../CheckBox";
6
- import DropDownMenu from "../DropDownMenu";
6
+ import { DropDownMenu } from "../DropDownMenu";
7
7
  import { MenuItem } from "./MenuItem";
8
8
  const filterMenuItems = (menuItems, searchValue) => {
9
9
  return menuItems.filter((item) => {
10
10
  var _a, _b, _c;
11
11
  if (item === null || item === void 0 ? void 0 : item.label) {
12
12
  return (((_a = item === null || item === void 0 ? void 0 : item.label) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchValue.toLowerCase())) ||
13
- ((_b = item === null || item === void 0 ? void 0 : item.value) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchValue.toLowerCase())));
13
+ ((_b = item === null || item === void 0 ? void 0 : item.value) === null || _b === void 0 ? void 0 : _b.toString().toLowerCase().includes(searchValue.toLowerCase())));
14
14
  }
15
15
  return (_c = item.toLowerCase) === null || _c === void 0 ? void 0 : _c.call(item).includes(searchValue.toLowerCase());
16
16
  });
@@ -1,2 +1,2 @@
1
- export { default } from "./DropDownMenu";
1
+ export * from "./DropDownMenu";
2
2
  export * from "./types";
@@ -1,2 +1,2 @@
1
- export { default } from "./DropDownMenu";
1
+ export * from "./DropDownMenu";
2
2
  export * from "./types";
@@ -6,7 +6,7 @@ import { StyledContent } from "./components";
6
6
  export type DropDownItem = {
7
7
  toLowerCase?: () => string;
8
8
  label: string;
9
- value: string;
9
+ value: string | number;
10
10
  onClick?: (args: any) => void;
11
11
  data?: any;
12
12
  items?: DropDownItem[];
@@ -16,11 +16,11 @@ export type DropDownItem = {
16
16
  visible?: boolean;
17
17
  };
18
18
  export type SearchInputProps = React.ComponentPropsWithoutRef<typeof Input>;
19
- export interface StyledContentProps {
19
+ export type StyledContentProps = {
20
20
  maxDropdownHeight?: number | string;
21
21
  variant?: Variant;
22
- }
23
- export interface DropDownMenuProps {
22
+ };
23
+ export type DropDownMenuProps = {
24
24
  className?: string;
25
25
  children?: ReactNode | string;
26
26
  label?: string;
@@ -42,8 +42,8 @@ export interface DropDownMenuProps {
42
42
  buttonRender?: (props: any) => ReactElement;
43
43
  buttonProps?: ButtonProps;
44
44
  disabled?: boolean;
45
- }
46
- export interface MenuProps {
45
+ };
46
+ export type MenuProps = {
47
47
  label?: any;
48
48
  itemData?: any;
49
49
  nested?: boolean;
@@ -59,4 +59,4 @@ export interface MenuProps {
59
59
  TooltipContent?: ComponentType<any>;
60
60
  dropDownProps?: ComponentPropsWithoutRef<typeof StyledContent>;
61
61
  disabled?: boolean;
62
- }
62
+ };
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled, { useTheme } from "styled-components";
3
3
  import { XIcon } from "lucide-react";
4
- import DropDownMenu from "../DropDownMenu";
4
+ import { DropDownMenu } from "../DropDownMenu";
5
5
  import { Button } from "../Button";
6
6
  import { DefaultOperators } from "./DefaultOperators";
7
7
  import Input from "../Input";
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled, { useTheme } from "styled-components";
3
3
  import { Extensions } from "../Enums";
4
4
  import { BoldIcon, ItalicIcon, UnderlineIcon, CaseSensitiveIcon, ListIcon, ListOrderedIcon, StrikethroughIcon, Heading1Icon, Heading2Icon, Heading3Icon, Heading4Icon, RemoveFormattingIcon, SquircleIcon, } from "lucide-react";
5
- import DropDownMenu from "../../DropDownMenu";
5
+ import { DropDownMenu, } from "../../DropDownMenu";
6
6
  import { FloatingPortal, useFloating } from "@floating-ui/react";
7
7
  import { useEffect, useRef } from "react";
8
8
  import { Button } from "../../Button";
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import DropDownMenu from "../../DropDownMenu";
2
+ import { DropDownMenu } from "../../DropDownMenu";
3
3
  import TextColors from "../Enums/TextColors";
4
4
  import { SquircleIcon } from "lucide-react";
5
5
  import { useTheme } from "styled-components";
@@ -23,7 +23,9 @@ export const ColorPicker = ({ editor }) => {
23
23
  },
24
24
  };
25
25
  }),
26
- ], renderOption: (item) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [_jsx(SquircleIcon, { size: 12, color: item.value === "default" ? theme.palette.text.primary : item.value, style: {
26
+ ], renderOption: (item) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [_jsx(SquircleIcon, { size: 12, color: item.value === "default"
27
+ ? theme.palette.text.primary
28
+ : item.value, style: {
27
29
  backgroundColor: item.value === "default"
28
30
  ? theme.palette.text.primary
29
31
  : item.value,
@@ -3,7 +3,7 @@ import styled, { useTheme } from "styled-components";
3
3
  import ControlsGroup from "./ControlsGroup";
4
4
  import { UndoControl, RedoControl, BoldControl, ItalicControl, UnderlineControl, StrikeThroughControl, Heading1Control, Heading2Control, Heading3Control, Heading4Control, BulletListControl, OrderedListControl, AlignLeftControl, AlignCenterControl, AlignRightControl, AlignJustifiedControl, } from "./Controls";
5
5
  import { Controls } from "../Enums";
6
- import DropDownMenu from "../../DropDownMenu";
6
+ import { DropDownMenu } from "../../DropDownMenu";
7
7
  import Fonts from "../Enums/Fonts";
8
8
  import { useContext } from "react";
9
9
  import RichTextEditorContext from "../Contexts/RichTextEditorContext";
@@ -3,7 +3,7 @@ import styled from "styled-components";
3
3
  import { Button } from "../../Button";
4
4
  import { TextInput } from "../../TextInput";
5
5
  import { CheckSquareIcon, Columns3Icon, DownloadIcon, FilterIcon, Rows3Icon, Rows4Icon, } from "lucide-react";
6
- import DropDownMenu from "../../DropDownMenu";
6
+ import { DropDownMenu } from "../../DropDownMenu";
7
7
  import useTable from "../useTable";
8
8
  import { TableExportOptions } from "../enums";
9
9
  import { useDebouncedCallback } from "use-debounce";
package/dist/index.d.ts CHANGED
@@ -8,9 +8,8 @@ export * from "./Grid";
8
8
  export * from "./TextInput";
9
9
  export * from "./SelectBox";
10
10
  export * from "./Button";
11
+ export * from "./DropDownMenu";
11
12
  export { default as IconButton } from "./IconButton";
12
- export { default as DropDownMenu } from "./DropDownMenu";
13
- export type { DropDownItem } from "./DropDownMenu";
14
13
  export { default as DateInput } from "./DateInput";
15
14
  export { default as TextArea } from "./TextArea";
16
15
  export { default as TextAreaInput } from "./TextAreaInput";
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@ export * from "./Grid";
3
3
  export * from "./TextInput";
4
4
  export * from "./SelectBox";
5
5
  export * from "./Button";
6
+ export * from "./DropDownMenu";
6
7
  export { default as IconButton } from "./IconButton";
7
- export { default as DropDownMenu } from "./DropDownMenu";
8
8
  export { default as DateInput } from "./DateInput";
9
9
  export { default as TextArea } from "./TextArea";
10
10
  export { default as TextAreaInput } from "./TextAreaInput";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.3.10",
3
+ "version": "1.3.16",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",
@@ -56,7 +56,6 @@
56
56
  "moment": "^2.29.1",
57
57
  "overlayscrollbars": "^2.6.0",
58
58
  "overlayscrollbars-react": "^0.5.6",
59
- "react-dom": "^18.3.1",
60
59
  "react-dropzone": "^14.2.3",
61
60
  "react-icons": "^5.2.1",
62
61
  "react-pdf": "^9.1.1",
@@ -71,7 +70,8 @@
71
70
  },
72
71
  "peerDependencies": {
73
72
  "@tanstack/react-query": "^5.59.16",
74
- "react": "18.2.0"
73
+ "react": "^18.3.1",
74
+ "react-dom": "^18.3.1"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@tanstack/react-query": "5.59.16",