@monolith-forensics/monolith-ui 1.3.97 → 1.3.103
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.
- package/dist/Alert/Alert.d.ts +8 -0
- package/dist/Alert/Alert.js +52 -0
- package/dist/Alert/index.d.ts +1 -0
- package/dist/Alert/index.js +1 -0
- package/dist/Button/Button.d.ts +1 -0
- package/dist/Button/Button.js +4 -4
- package/dist/Calendar/Calendar.js +77 -76
- package/dist/DateInput/DateInput.d.ts +3 -4
- package/dist/DateInput/DateInput.js +39 -73
- package/dist/DropDownMenu/DropDownMenu.d.ts +1 -2
- package/dist/DropDownMenu/DropDownMenu.js +7 -13
- package/dist/DropDownMenu/components/MenuComponent.js +2 -2
- package/dist/DropDownMenu/components/MenuItem.js +1 -1
- package/dist/DropDownMenu/components/MenuItemList.d.ts +6 -2
- package/dist/DropDownMenu/components/MenuItemList.js +99 -30
- package/dist/DropDownMenu/index.d.ts +1 -1
- package/dist/DropDownMenu/index.js +1 -1
- package/dist/DropDownMenu/types.d.ts +23 -8
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +35 -0
- package/dist/QueryFilter/QueryFilter.js +52 -43
- package/dist/QueryFilter/index.d.ts +0 -1
- package/dist/QueryFilter/index.js +0 -1
- package/dist/QueryFilter/types.d.ts +3 -5
- package/dist/RichTextEditor/Components/BubbleMenu.js +1 -1
- package/dist/RichTextEditor/Components/ColorPicker.js +4 -2
- package/dist/RichTextEditor/Toolbar/Toolbar.js +1 -1
- package/dist/SelectBox/SelectBox.js +7 -1
- package/dist/SelectBox/select-box.styled-components.js +6 -1
- package/dist/Switch/Switch.d.ts +3 -4
- package/dist/Switch/Switch.js +1 -2
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/Table/TableComponents.js +16 -0
- package/dist/Table/TableMenu/TableMenu.js +18 -4
- package/dist/Table/TableProvider.js +214 -139
- package/dist/Table/TableRow.js +3 -2
- package/dist/Table/types.d.ts +40 -6
- package/dist/TextAreaInput/TextAreaInput.js +10 -2
- package/dist/index.d.ts +3 -5
- package/dist/index.js +3 -3
- package/dist/theme/variants.js +66 -1
- package/package.json +3 -3
- package/dist/QueryFilter/useFilterHelper.d.ts +0 -20
- package/dist/QueryFilter/useFilterHelper.js +0 -61
- package/dist/SelectableTextArea/SelectableTextArea.d.ts +0 -31
- package/dist/SelectableTextArea/SelectableTextArea.js +0 -191
- package/dist/SelectableTextArea/index.d.ts +0 -2
- package/dist/SelectableTextArea/index.js +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AlertCircleIcon, AlertTriangleIcon, CheckIcon, InfoIcon, } from "lucide-react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
const Icons = {
|
|
5
|
+
info: _jsx(InfoIcon, { size: 20 }),
|
|
6
|
+
success: _jsx(CheckIcon, { size: 20 }),
|
|
7
|
+
warning: _jsx(AlertCircleIcon, { size: 20 }),
|
|
8
|
+
error: _jsx(AlertTriangleIcon, { size: 20 }),
|
|
9
|
+
default: _jsx(InfoIcon, { size: 20 }),
|
|
10
|
+
};
|
|
11
|
+
const StyledContainer = styled.div `
|
|
12
|
+
display: flex;
|
|
13
|
+
gap: 10px;
|
|
14
|
+
padding: 15px;
|
|
15
|
+
border-radius: 4px;
|
|
16
|
+
|
|
17
|
+
border: 1px solid ${({ theme, variant }) => theme.alert[variant].border};
|
|
18
|
+
background-color: ${({ theme, variant }) => theme.alert[variant].background};
|
|
19
|
+
color: ${({ theme, variant }) => theme.alert[variant].color};
|
|
20
|
+
`;
|
|
21
|
+
const StyledTitle = styled.div `
|
|
22
|
+
height: 25px;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
font-size: 14px;
|
|
26
|
+
font-weight: bold;
|
|
27
|
+
margin: 0px;
|
|
28
|
+
|
|
29
|
+
color: ${({ theme, variant }) => { var _a; return (_a = theme.alert[variant]) === null || _a === void 0 ? void 0 : _a.color; }};
|
|
30
|
+
`;
|
|
31
|
+
const StyledContent = styled.div `
|
|
32
|
+
display: flex;
|
|
33
|
+
font-size: 13px;
|
|
34
|
+
font-weight: 400;
|
|
35
|
+
margin: 0px;
|
|
36
|
+
|
|
37
|
+
color: ${({ theme, variant }) => theme.palette.text.primary};
|
|
38
|
+
`;
|
|
39
|
+
const StyledContentContainer = styled.div `
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
gap: 5px;
|
|
43
|
+
`;
|
|
44
|
+
const StyledHeader = styled.div `
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: flex-start;
|
|
47
|
+
height: 28px;
|
|
48
|
+
align-items: center;
|
|
49
|
+
`;
|
|
50
|
+
export const Alert = ({ children, variant = "info", title, onClose, }) => {
|
|
51
|
+
return (_jsxs(StyledContainer, { variant: variant, children: [_jsx(StyledHeader, { children: Icons[variant] }), _jsxs(StyledContentContainer, { children: [title && _jsx(StyledTitle, { variant: variant, children: title }), _jsx(StyledContent, { variant: variant, children: children })] })] }));
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Alert";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Alert";
|
package/dist/Button/Button.d.ts
CHANGED
package/dist/Button/Button.js
CHANGED
|
@@ -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":
|
|
@@ -103,7 +103,7 @@ const StyledButton = styled.button `
|
|
|
103
103
|
if (variant === "filled")
|
|
104
104
|
return "white";
|
|
105
105
|
if (color) {
|
|
106
|
-
return (((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.button) === null || _a === void 0 ? void 0 : _a.
|
|
106
|
+
return (((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.button) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b[color]) ||
|
|
107
107
|
colors[color] ||
|
|
108
108
|
theme.palette.text.primary);
|
|
109
109
|
}
|
|
@@ -206,9 +206,9 @@ const StyledButton = styled.button `
|
|
|
206
206
|
}
|
|
207
207
|
switch (variant) {
|
|
208
208
|
case "contained":
|
|
209
|
-
return (resolvedColor || theme.
|
|
209
|
+
return (resolvedColor || theme.button.background.secondary) + "90";
|
|
210
210
|
case "filled":
|
|
211
|
-
return (resolvedColor || theme.
|
|
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
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
33
|
-
|
|
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 {
|
|
42
|
-
const calendarMonth = month || +((
|
|
43
|
-
const calendarYear = year || (
|
|
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 } =
|
|
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 {
|
|
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 =
|
|
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 } =
|
|
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(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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 } =
|
|
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(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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 ?
|
|
121
|
-
.minutes(includeTime ?
|
|
124
|
+
.hours(includeTime ? calendarState.hours : 0)
|
|
125
|
+
.minutes(includeTime ? calendarState.minutes : 0)
|
|
122
126
|
.toDate();
|
|
123
|
-
!(
|
|
127
|
+
!(_value && isSameDay(newTime, _value)) && addDateToState(newTime);
|
|
124
128
|
onChange(newTime);
|
|
125
129
|
};
|
|
126
130
|
const gotoPreviousMonth = () => {
|
|
127
|
-
const { month, year } =
|
|
131
|
+
const { month, year } = calendarState;
|
|
128
132
|
const previousMonth = getPreviousMonth(month, year);
|
|
129
|
-
|
|
133
|
+
setCalendarState({
|
|
130
134
|
month: previousMonth.month,
|
|
131
135
|
year: previousMonth.year,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
minutes: dateState.minutes,
|
|
136
|
+
hours: calendarState.hours,
|
|
137
|
+
minutes: calendarState.minutes,
|
|
135
138
|
});
|
|
136
139
|
};
|
|
137
140
|
const gotoNextMonth = () => {
|
|
138
|
-
const { month, year } =
|
|
141
|
+
const { month, year } = calendarState;
|
|
139
142
|
const nextMonth = getNextMonth(month, year);
|
|
140
|
-
|
|
143
|
+
setCalendarState({
|
|
141
144
|
month: nextMonth.month,
|
|
142
145
|
year: nextMonth.year,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
minutes: dateState.minutes,
|
|
146
|
+
hours: calendarState.hours,
|
|
147
|
+
minutes: calendarState.minutes,
|
|
146
148
|
});
|
|
147
149
|
};
|
|
148
150
|
const gotoPreviousYear = () => {
|
|
149
|
-
const { year } =
|
|
150
|
-
|
|
151
|
-
month:
|
|
151
|
+
const { year } = calendarState;
|
|
152
|
+
setCalendarState({
|
|
153
|
+
month: calendarState.month,
|
|
152
154
|
year: year - 1,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
minutes: dateState.minutes,
|
|
155
|
+
hours: calendarState.hours,
|
|
156
|
+
minutes: calendarState.minutes,
|
|
156
157
|
});
|
|
157
158
|
};
|
|
158
159
|
const gotoNextYear = () => {
|
|
159
|
-
const { year } =
|
|
160
|
-
|
|
161
|
-
month:
|
|
160
|
+
const { year } = calendarState;
|
|
161
|
+
setCalendarState({
|
|
162
|
+
month: calendarState.month,
|
|
162
163
|
year: year + 1,
|
|
163
|
-
|
|
164
|
-
|
|
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 (
|
|
184
|
-
addDateToState(
|
|
184
|
+
if (_value) {
|
|
185
|
+
addDateToState(_value);
|
|
185
186
|
}
|
|
186
|
-
}, [
|
|
187
|
-
// lifecycle methods
|
|
188
|
-
useEffect(() => {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}, []);
|
|
201
|
-
const clearDayTimeout = () => {
|
|
202
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
|
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
|
-
|
|
318
|
-
});
|
|
316
|
+
}
|
|
319
317
|
}
|
|
320
318
|
// Down Arrow
|
|
321
319
|
if (e.key === "ArrowDown") {
|
|
322
320
|
e.preventDefault();
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
382
|
-
let newValue =
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
3
|
-
export default DropDownMenu;
|
|
2
|
+
export declare const DropDownMenu: React.FC<DropDownMenuProps>;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const DropDownMenu = ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, dropDownProps, }) => {
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Menu, MenuItemList, StyledInnerItemContainer } from "./components";
|
|
4
|
+
export const DropDownMenu = ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, onScrollToTop, onScrollToBottom, onSearch, manualSearch, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, dropDownProps, query, disabled, }) => {
|
|
6
5
|
var _a;
|
|
7
6
|
const isObjectArray = (_a = Object.keys((data === null || data === void 0 ? void 0 : data[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
|
|
8
7
|
const [selected, setSelected] = useState(defaultValue || []);
|
|
9
|
-
const [searchValue, setSearchValue] = useState("");
|
|
10
|
-
const searchInputRef = useRef(null);
|
|
11
|
-
const handleSearch = useDebouncedCallback((e) => {
|
|
12
|
-
setSearchValue(e.target.value);
|
|
13
|
-
}, 150);
|
|
14
8
|
const handleAddItem = (item) => {
|
|
15
9
|
setSelected((prev) => {
|
|
16
10
|
let newSelected = [...prev, item];
|
|
@@ -27,9 +21,9 @@ const DropDownMenu = ({ data, children, defaultValue, variant, arrow, size, sear
|
|
|
27
21
|
return newSelected;
|
|
28
22
|
});
|
|
29
23
|
};
|
|
30
|
-
const handleMenuClose = () => {
|
|
31
|
-
|
|
24
|
+
const handleMenuClose = () => { };
|
|
25
|
+
const handleScrollToBottom = (e) => {
|
|
26
|
+
onScrollToBottom === null || onScrollToBottom === void 0 ? void 0 : onScrollToBottom(e);
|
|
32
27
|
};
|
|
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..." }),
|
|
28
|
+
return (_jsx(Menu, { label: children, disabled: disabled, arrow: arrow, buttonSize: size, variant: variant, multiselect: multiselect, buttonProps: buttonProps, onMenuClose: handleMenuClose, dropDownProps: dropDownProps, children: _jsxs(StyledInnerItemContainer, { children: [loading && _jsx("div", { children: "Loading..." }), !loading && (_jsx(MenuItemList, { menuItems: data, searchable: searchable, onSearch: onSearch, manualSearch: manualSearch, selected: selected, TooltipContent: TooltipContent, multiselect: multiselect, size: size, handleAddItem: handleAddItem, handleRemoveItem: handleRemoveItem, onItemSelect: onItemSelect, renderOption: renderOption, onScroll: onScroll, onScrollToTop: onScrollToTop, onScrollToBottom: handleScrollToBottom, query: query }))] }) }));
|
|
34
29
|
};
|
|
35
|
-
export default DropDownMenu;
|
|
@@ -18,7 +18,7 @@ import { StyledFloatContainer } from "./StyledFloatContainer";
|
|
|
18
18
|
import { StyledContent } from "./StyledContent";
|
|
19
19
|
import { MenuItem } from "./MenuItem";
|
|
20
20
|
export const MenuComponent = forwardRef((_a, forwardedRef) => {
|
|
21
|
-
var { children, label, arrow, size, buttonSize, variant, buttonProps, buttonRender, multiselect, onMenuClose, dropDownProps } = _a, props = __rest(_a, ["children", "label", "arrow", "size", "buttonSize", "variant", "buttonProps", "buttonRender", "multiselect", "onMenuClose", "dropDownProps"]);
|
|
21
|
+
var { children, label, arrow, size, buttonSize, variant, buttonProps, buttonRender, multiselect, onMenuClose, dropDownProps, disabled } = _a, props = __rest(_a, ["children", "label", "arrow", "size", "buttonSize", "variant", "buttonProps", "buttonRender", "multiselect", "onMenuClose", "dropDownProps", "disabled"]);
|
|
22
22
|
const [isOpen, setIsOpen] = useState(false);
|
|
23
23
|
const [hasFocusInside, setHasFocusInside] = useState(false);
|
|
24
24
|
const [activeIndex, setActiveIndex] = useState(null);
|
|
@@ -102,7 +102,7 @@ export const MenuComponent = forwardRef((_a, forwardedRef) => {
|
|
|
102
102
|
onMenuClose === null || onMenuClose === void 0 ? void 0 : onMenuClose();
|
|
103
103
|
}
|
|
104
104
|
}, [isOpen]);
|
|
105
|
-
return (_jsxs(FloatingNode, { id: nodeId, children: [_jsx(MenuItem, Object.assign({ ref: useMergeRefs([refs.setReference, item.ref, forwardedRef]), tabIndex: !isNested ? undefined : parent.activeIndex === item.index ? 0 : -1, role: isNested ? "menuitem" : undefined, className: isNested ? `MenuItem` : "mfui-DropDownMenu RootMenu", "data-open": isOpen ? "" : undefined, "data-nested": isNested ? "" : undefined, "data-focus-inside": hasFocusInside ? "" : undefined }, getReferenceProps(parent.getItemProps(Object.assign(Object.assign({}, props), { onFocus(event) {
|
|
105
|
+
return (_jsxs(FloatingNode, { id: nodeId, children: [_jsx(MenuItem, Object.assign({ ref: useMergeRefs([refs.setReference, item.ref, forwardedRef]), tabIndex: !isNested ? undefined : parent.activeIndex === item.index ? 0 : -1, role: isNested ? "menuitem" : undefined, className: isNested ? `MenuItem` : "mfui-DropDownMenu RootMenu", disabled: disabled, "data-open": isOpen ? "" : undefined, "data-nested": isNested ? "" : undefined, "data-focus-inside": hasFocusInside ? "" : undefined }, getReferenceProps(parent.getItemProps(Object.assign(Object.assign({}, props), { onFocus(event) {
|
|
106
106
|
var _a;
|
|
107
107
|
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
108
108
|
setHasFocusInside(false);
|