@monolith-forensics/monolith-ui 1.1.29 → 1.1.31

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