@monolith-forensics/monolith-ui 1.1.0 → 1.1.2
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/package.json +4 -1
- package/Button/Button.tsx +0 -382
- package/Button/index.ts +0 -2
- package/Calendar/Calendar.tsx +0 -376
- package/Calendar/CalendarStyles.tsx +0 -180
- package/Calendar/calendarHelpers.ts +0 -196
- package/Calendar/index.ts +0 -1
- package/CheckBox/CheckBox.tsx +0 -61
- package/CheckBox/index.ts +0 -1
- package/DateInput/DateInput.tsx +0 -717
- package/DateInput/index.ts +0 -1
- package/DropDownMenu/DropDownMenu.tsx +0 -402
- package/DropDownMenu/index.ts +0 -1
- package/Error/Error.tsx +0 -51
- package/Error/index.ts +0 -1
- package/FieldLabel/FieldLabel.tsx +0 -155
- package/FieldLabel/index.ts +0 -1
- package/FileInputField/FileInputField.tsx +0 -179
- package/FileInputField/index.ts +0 -1
- package/Flyout/Flyout.tsx +0 -172
- package/Flyout/FlyoutHeader.tsx +0 -14
- package/Flyout/FlyoutTitle.tsx +0 -10
- package/Flyout/index.ts +0 -3
- package/FormSection/FormSection.tsx +0 -71
- package/FormSection/index.ts +0 -1
- package/Grid/Grid.tsx +0 -18
- package/Grid/index.ts +0 -1
- package/IconButton/IconButton.tsx +0 -27
- package/IconButton/index.ts +0 -1
- package/Input/Input.tsx +0 -164
- package/Input/index.ts +0 -1
- package/Modal/Modal.tsx +0 -172
- package/Modal/index.ts +0 -1
- package/Pill/Pill.tsx +0 -174
- package/Pill/index.ts +0 -1
- package/SelectBox/SelectBox.tsx +0 -745
- package/SelectBox/index.ts +0 -1
- package/Switch/Switch.tsx +0 -204
- package/Switch/index.ts +0 -1
- package/TagBox/TagBox.tsx +0 -694
- package/TagBox/TagBoxStyles.tsx +0 -116
- package/TagBox/index.ts +0 -1
- package/TextArea/TextArea.tsx +0 -92
- package/TextArea/index.ts +0 -1
- package/TextAreaInput/TextAreaInput.tsx +0 -46
- package/TextAreaInput/index.ts +0 -1
- package/TextInput/TextInput.tsx +0 -48
- package/TextInput/index.ts +0 -1
- package/Tooltip/Tooltip.tsx +0 -68
- package/Tooltip/index.ts +0 -1
- package/core/ArrowButton.tsx +0 -51
- package/core/ClearButton.tsx +0 -51
- package/core/MonolithThemeProvider.js +0 -16
- package/core/StyledContent.tsx +0 -50
- package/core/StyledFloatContainer.tsx +0 -7
- package/core/Types/Size.ts +0 -3
- package/core/Types/Variant.ts +0 -10
- package/core/index.ts +0 -6
- package/index.ts +0 -22
- package/theme/breakpoints.js +0 -11
- package/theme/components.js +0 -138
- package/theme/index.js +0 -76
- package/theme/shadows.js +0 -33
- package/theme/typography.js +0 -58
- package/theme/variants.js +0 -234
- package/tsconfig.json +0 -109
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
// (int) The current year
|
|
2
|
-
export const THIS_YEAR = +new Date().getFullYear();
|
|
3
|
-
|
|
4
|
-
// (int) The current month starting from 1 - 12
|
|
5
|
-
// 1 => January, 12 => December
|
|
6
|
-
export const THIS_MONTH = +new Date().getMonth() + 1;
|
|
7
|
-
// Week days names and shortnames
|
|
8
|
-
|
|
9
|
-
export const HOURS24 = [...new Array(24)].map((n, index) => {
|
|
10
|
-
return {
|
|
11
|
-
value: index,
|
|
12
|
-
label: index < 10 ? `0${index}` : `${index}`,
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export const HOURS12 = [
|
|
17
|
-
...[...new Array(12)].map((n, index) => {
|
|
18
|
-
return {
|
|
19
|
-
value: index,
|
|
20
|
-
label: index < 10 ? `0${index} AM` : `${index} AM`,
|
|
21
|
-
};
|
|
22
|
-
}),
|
|
23
|
-
...[...new Array(12)].map((n, index) => {
|
|
24
|
-
return {
|
|
25
|
-
value: index + 12,
|
|
26
|
-
label: index < 10 ? `0${index} PM` : `${index} PM`,
|
|
27
|
-
};
|
|
28
|
-
}),
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
export const MINUTES = new Array(60).fill(0).map((n, index) => {
|
|
32
|
-
return index < 10 ? `0${index}` : index;
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
export const WEEK_DAYS = {
|
|
36
|
-
Sunday: "Su",
|
|
37
|
-
Monday: "Mo",
|
|
38
|
-
Tuesday: "Tu",
|
|
39
|
-
Wednesday: "We",
|
|
40
|
-
Thursday: "Th",
|
|
41
|
-
Friday: "Fr",
|
|
42
|
-
Saturday: "Sa",
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export type WeekDay = keyof typeof WEEK_DAYS;
|
|
46
|
-
|
|
47
|
-
// Calendar months names and short names
|
|
48
|
-
export const CALENDAR_MONTHS = {
|
|
49
|
-
January: "Jan",
|
|
50
|
-
February: "Feb",
|
|
51
|
-
March: "Mar",
|
|
52
|
-
April: "Apr",
|
|
53
|
-
May: "May",
|
|
54
|
-
June: "Jun",
|
|
55
|
-
July: "Jul",
|
|
56
|
-
August: "Aug",
|
|
57
|
-
September: "Sep",
|
|
58
|
-
October: "Oct",
|
|
59
|
-
November: "Nov",
|
|
60
|
-
December: "Dec",
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// Weeks displayed on calendar
|
|
64
|
-
export const CALENDAR_WEEKS = 6;
|
|
65
|
-
|
|
66
|
-
// Pads a string value with leading zeroes(0) until length is reached
|
|
67
|
-
// For example: zeroPad(5, 2) => "05"
|
|
68
|
-
export const zeroPad = (value: number, length: number) => {
|
|
69
|
-
return `${value}`.padStart(length, "0");
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// (int) Number days in a month for a given year from 28 - 31
|
|
73
|
-
export const getMonthDays = (month = THIS_MONTH, year = THIS_YEAR) => {
|
|
74
|
-
const months30 = [4, 6, 9, 11];
|
|
75
|
-
const leapYear = year % 4 === 0;
|
|
76
|
-
return month === 2
|
|
77
|
-
? leapYear
|
|
78
|
-
? 29
|
|
79
|
-
: 28
|
|
80
|
-
: months30.includes(month)
|
|
81
|
-
? 30
|
|
82
|
-
: 31;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// (int) First day of the month for a given year from 1 - 7
|
|
86
|
-
// 1 => Sunday, 7 => Saturday
|
|
87
|
-
export const getMonthFirstDay = (month = THIS_MONTH, year = THIS_YEAR) => {
|
|
88
|
-
return +new Date(`${year}-${zeroPad(month, 2)}-01`).getDay() + 1;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// (bool) Checks if a value is a date - this is just a simple check
|
|
92
|
-
export const isDate = (date: Date) => {
|
|
93
|
-
const isDate = Object.prototype.toString.call(date) === "[object Date]";
|
|
94
|
-
const isValidDate = date && !Number.isNaN(date.valueOf());
|
|
95
|
-
|
|
96
|
-
return isDate && isValidDate;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// (bool) Checks if two date values are of the same month and year
|
|
100
|
-
export const isSameMonth = (date: Date, basedate = new Date()) => {
|
|
101
|
-
if (!(isDate(date) && isDate(basedate))) return false;
|
|
102
|
-
const basedateMonth = +basedate.getMonth() + 1;
|
|
103
|
-
const basedateYear = basedate.getFullYear();
|
|
104
|
-
const dateMonth = +date.getMonth() + 1;
|
|
105
|
-
const dateYear = date.getFullYear();
|
|
106
|
-
return +basedateMonth === +dateMonth && +basedateYear === +dateYear;
|
|
107
|
-
};
|
|
108
|
-
// (bool) Checks if two date values are the same day
|
|
109
|
-
export const isSameDay = (date: Date, basedate = new Date()) => {
|
|
110
|
-
if (!(isDate(date) && isDate(basedate))) return false;
|
|
111
|
-
const basedateDate = basedate.getDate();
|
|
112
|
-
const basedateMonth = +basedate.getMonth() + 1;
|
|
113
|
-
const basedateYear = basedate.getFullYear();
|
|
114
|
-
const dateDate = date.getDate();
|
|
115
|
-
const dateMonth = +date.getMonth() + 1;
|
|
116
|
-
const dateYear = date.getFullYear();
|
|
117
|
-
return (
|
|
118
|
-
+basedateDate === +dateDate &&
|
|
119
|
-
+basedateMonth === +dateMonth &&
|
|
120
|
-
+basedateYear === +dateYear
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
// (string) Formats the given date as YYYY-MM-DD
|
|
124
|
-
// Months and Days are zero padded
|
|
125
|
-
export const getDateISO = (date: Date) => {
|
|
126
|
-
if (!isDate(date)) return null;
|
|
127
|
-
return [
|
|
128
|
-
date.getFullYear(),
|
|
129
|
-
zeroPad(+date.getMonth() + 1, 2),
|
|
130
|
-
zeroPad(+date.getDate(), 2),
|
|
131
|
-
].join("-");
|
|
132
|
-
};
|
|
133
|
-
// ({month, year}) Gets the month and year before the given month and year
|
|
134
|
-
// For example: getPreviousMonth(1, 2000) => {month: 12, year: 1999}
|
|
135
|
-
// while: getPreviousMonth(12, 2000) => {month: 11, year: 2000}
|
|
136
|
-
|
|
137
|
-
export const getPreviousMonth = (month: number, year: number) => {
|
|
138
|
-
const prevMonth = month > 1 ? month - 1 : 12;
|
|
139
|
-
const prevMonthYear = month > 1 ? year : year - 1;
|
|
140
|
-
return { month: prevMonth, year: prevMonthYear };
|
|
141
|
-
};
|
|
142
|
-
// ({month, year}) Gets the month and year after the given month and year
|
|
143
|
-
// For example: getNextMonth(1, 2000) => {month: 2, year: 2000}
|
|
144
|
-
// while: getNextMonth(12, 2000) => {month: 1, year: 2001}
|
|
145
|
-
export const getNextMonth = (month: number, year: number) => {
|
|
146
|
-
const nextMonth = month < 12 ? month + 1 : 1;
|
|
147
|
-
const nextMonthYear = month < 12 ? year : year + 1;
|
|
148
|
-
return { month: nextMonth, year: nextMonthYear };
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
// Calendar builder for a month in the specified year
|
|
152
|
-
// Returns an array of the calendar dates.
|
|
153
|
-
// Each calendar date is represented as an array => [YYYY, MM, DD]
|
|
154
|
-
const calendarBuilder = (month = THIS_MONTH, year = THIS_YEAR) => {
|
|
155
|
-
// Get number of days in the month and the month's first day
|
|
156
|
-
|
|
157
|
-
const monthDays = getMonthDays(month, year);
|
|
158
|
-
const monthFirstDay = getMonthFirstDay(month, year);
|
|
159
|
-
// Get number of days to be displayed from previous and next months
|
|
160
|
-
// These ensure a total of 42 days (6 weeks) displayed on the calendar
|
|
161
|
-
|
|
162
|
-
const daysFromPrevMonth = monthFirstDay - 1;
|
|
163
|
-
const daysFromNextMonth =
|
|
164
|
-
CALENDAR_WEEKS * 7 - (daysFromPrevMonth + monthDays);
|
|
165
|
-
// Get the previous and next months and years
|
|
166
|
-
|
|
167
|
-
const { month: prevMonth, year: prevMonthYear } = getPreviousMonth(
|
|
168
|
-
month,
|
|
169
|
-
year
|
|
170
|
-
);
|
|
171
|
-
const { month: nextMonth, year: nextMonthYear } = getNextMonth(month, year);
|
|
172
|
-
// Get number of days in previous month
|
|
173
|
-
const prevMonthDays = getMonthDays(prevMonth, prevMonthYear);
|
|
174
|
-
// Builds dates to be displayed from previous month
|
|
175
|
-
|
|
176
|
-
const prevMonthDates = [...new Array(daysFromPrevMonth)].map((n, index) => {
|
|
177
|
-
const day = index + 1 + (prevMonthDays - daysFromPrevMonth);
|
|
178
|
-
return [prevMonthYear, zeroPad(prevMonth, 2), zeroPad(day, 2)];
|
|
179
|
-
});
|
|
180
|
-
// Builds dates to be displayed from current month
|
|
181
|
-
|
|
182
|
-
const thisMonthDates = [...new Array(monthDays)].map((n, index) => {
|
|
183
|
-
const day = index + 1;
|
|
184
|
-
return [year, zeroPad(month, 2), zeroPad(day, 2)];
|
|
185
|
-
});
|
|
186
|
-
// Builds dates to be displayed from next month
|
|
187
|
-
|
|
188
|
-
const nextMonthDates = [...new Array(daysFromNextMonth)].map((n, index) => {
|
|
189
|
-
const day = index + 1;
|
|
190
|
-
return [nextMonthYear, zeroPad(nextMonth, 2), zeroPad(day, 2)];
|
|
191
|
-
});
|
|
192
|
-
// Combines all dates from previous, current and next months
|
|
193
|
-
return [...prevMonthDates, ...thisMonthDates, ...nextMonthDates];
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
export default calendarBuilder;
|
package/Calendar/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./Calendar";
|
package/CheckBox/CheckBox.tsx
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
2
|
-
import { useState, useEffect, CSSProperties, MouseEvent } from "react";
|
|
3
|
-
import CheckBoxOutlineBlankOutlinedIcon from "@mui/icons-material/CheckBoxOutlineBlankOutlined";
|
|
4
|
-
import IndeterminateCheckBoxIcon from "@mui/icons-material/IndeterminateCheckBox";
|
|
5
|
-
import CheckBoxIcon from "@mui/icons-material/CheckBox";
|
|
6
|
-
|
|
7
|
-
interface CheckBoxProps {
|
|
8
|
-
className?: string;
|
|
9
|
-
defaultValue?: boolean;
|
|
10
|
-
value?: boolean;
|
|
11
|
-
partialCheck?: boolean;
|
|
12
|
-
onChange?: (value: boolean) => void;
|
|
13
|
-
style?: CSSProperties;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const CheckBox = styled(
|
|
17
|
-
({
|
|
18
|
-
className,
|
|
19
|
-
defaultValue = false,
|
|
20
|
-
value = false,
|
|
21
|
-
partialCheck = false,
|
|
22
|
-
onChange = () => {},
|
|
23
|
-
}: CheckBoxProps) => {
|
|
24
|
-
const [checkedState, setCheckedState] = useState(defaultValue);
|
|
25
|
-
|
|
26
|
-
const handleChange = (e: MouseEvent) => {
|
|
27
|
-
e.stopPropagation();
|
|
28
|
-
setCheckedState(!checkedState);
|
|
29
|
-
onChange(!checkedState);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
setCheckedState(value);
|
|
34
|
-
}, [value]);
|
|
35
|
-
|
|
36
|
-
const _checked = value === undefined ? checkedState : value;
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<div className={className} onClick={handleChange}>
|
|
40
|
-
{partialCheck === true ? (
|
|
41
|
-
<IndeterminateCheckBoxIcon className="checkbox partial" />
|
|
42
|
-
) : _checked === true ? (
|
|
43
|
-
<CheckBoxIcon className="checkbox checked" />
|
|
44
|
-
) : (
|
|
45
|
-
<CheckBoxOutlineBlankOutlinedIcon className="checkbox unchecked" />
|
|
46
|
-
)}
|
|
47
|
-
</div>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
)`
|
|
51
|
-
display: flex;
|
|
52
|
-
align-items: center;
|
|
53
|
-
cursor: pointer;
|
|
54
|
-
|
|
55
|
-
.checkbox {
|
|
56
|
-
color: ${(props) => props.theme.palette.primary.main};
|
|
57
|
-
font-size: 16px;
|
|
58
|
-
}
|
|
59
|
-
`;
|
|
60
|
-
|
|
61
|
-
export default CheckBox;
|
package/CheckBox/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./CheckBox";
|