@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.
Files changed (66) hide show
  1. package/package.json +4 -1
  2. package/Button/Button.tsx +0 -382
  3. package/Button/index.ts +0 -2
  4. package/Calendar/Calendar.tsx +0 -376
  5. package/Calendar/CalendarStyles.tsx +0 -180
  6. package/Calendar/calendarHelpers.ts +0 -196
  7. package/Calendar/index.ts +0 -1
  8. package/CheckBox/CheckBox.tsx +0 -61
  9. package/CheckBox/index.ts +0 -1
  10. package/DateInput/DateInput.tsx +0 -717
  11. package/DateInput/index.ts +0 -1
  12. package/DropDownMenu/DropDownMenu.tsx +0 -402
  13. package/DropDownMenu/index.ts +0 -1
  14. package/Error/Error.tsx +0 -51
  15. package/Error/index.ts +0 -1
  16. package/FieldLabel/FieldLabel.tsx +0 -155
  17. package/FieldLabel/index.ts +0 -1
  18. package/FileInputField/FileInputField.tsx +0 -179
  19. package/FileInputField/index.ts +0 -1
  20. package/Flyout/Flyout.tsx +0 -172
  21. package/Flyout/FlyoutHeader.tsx +0 -14
  22. package/Flyout/FlyoutTitle.tsx +0 -10
  23. package/Flyout/index.ts +0 -3
  24. package/FormSection/FormSection.tsx +0 -71
  25. package/FormSection/index.ts +0 -1
  26. package/Grid/Grid.tsx +0 -18
  27. package/Grid/index.ts +0 -1
  28. package/IconButton/IconButton.tsx +0 -27
  29. package/IconButton/index.ts +0 -1
  30. package/Input/Input.tsx +0 -164
  31. package/Input/index.ts +0 -1
  32. package/Modal/Modal.tsx +0 -172
  33. package/Modal/index.ts +0 -1
  34. package/Pill/Pill.tsx +0 -174
  35. package/Pill/index.ts +0 -1
  36. package/SelectBox/SelectBox.tsx +0 -745
  37. package/SelectBox/index.ts +0 -1
  38. package/Switch/Switch.tsx +0 -204
  39. package/Switch/index.ts +0 -1
  40. package/TagBox/TagBox.tsx +0 -694
  41. package/TagBox/TagBoxStyles.tsx +0 -116
  42. package/TagBox/index.ts +0 -1
  43. package/TextArea/TextArea.tsx +0 -92
  44. package/TextArea/index.ts +0 -1
  45. package/TextAreaInput/TextAreaInput.tsx +0 -46
  46. package/TextAreaInput/index.ts +0 -1
  47. package/TextInput/TextInput.tsx +0 -48
  48. package/TextInput/index.ts +0 -1
  49. package/Tooltip/Tooltip.tsx +0 -68
  50. package/Tooltip/index.ts +0 -1
  51. package/core/ArrowButton.tsx +0 -51
  52. package/core/ClearButton.tsx +0 -51
  53. package/core/MonolithThemeProvider.js +0 -16
  54. package/core/StyledContent.tsx +0 -50
  55. package/core/StyledFloatContainer.tsx +0 -7
  56. package/core/Types/Size.ts +0 -3
  57. package/core/Types/Variant.ts +0 -10
  58. package/core/index.ts +0 -6
  59. package/index.ts +0 -22
  60. package/theme/breakpoints.js +0 -11
  61. package/theme/components.js +0 -138
  62. package/theme/index.js +0 -76
  63. package/theme/shadows.js +0 -33
  64. package/theme/typography.js +0 -58
  65. package/theme/variants.js +0 -234
  66. package/tsconfig.json +0 -109
@@ -1,376 +0,0 @@
1
- import { Fragment, useEffect, useState } from "react";
2
- import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
3
- import {
4
- CalendarContainer,
5
- CalendarHeader,
6
- CalendarGrid,
7
- CalendarMonth,
8
- CalendarDay,
9
- CalendarDate,
10
- HighlightedCalendarDate,
11
- TodayCalendarDate,
12
- TimeContainer,
13
- MainContainer,
14
- TimePickerContainer,
15
- TimeHourSelect,
16
- TimeHeader,
17
- TimeMinuteSelect,
18
- TimeItem,
19
- TimeItemActive,
20
- NoValueButton,
21
- } from "./CalendarStyles";
22
- import calendar, {
23
- isDate,
24
- isSameDay,
25
- isSameMonth,
26
- getDateISO,
27
- getNextMonth,
28
- getPreviousMonth,
29
- WEEK_DAYS,
30
- CALENDAR_MONTHS,
31
- HOURS24,
32
- HOURS12,
33
- MINUTES,
34
- WeekDay,
35
- } from "./calendarHelpers";
36
- import moment from "moment";
37
-
38
- const checkValidRange = (
39
- value: string | null,
40
- min: Date | null,
41
- max: Date | null
42
- ) => {
43
- if (min && moment(value).startOf("day").isBefore(moment(min).startOf("day")))
44
- return false;
45
- if (max && moment(value).startOf("day").isAfter(moment(max).startOf("day")))
46
- return false;
47
- return true;
48
- };
49
-
50
- interface CalendarProps {
51
- defaultValue?: Date;
52
- value?: Date | null;
53
- onChange?: (date: Date | null) => void;
54
- hourFormat?: "12" | "24";
55
- includeTime?: boolean;
56
- clearable?: boolean;
57
- min?: Date;
58
- max?: Date;
59
- }
60
-
61
- const Calendar = ({
62
- defaultValue = new Date(),
63
- value,
64
- onChange = () => {},
65
- hourFormat = "24",
66
- includeTime = true,
67
- clearable = true,
68
- min,
69
- max,
70
- }: CalendarProps) => {
71
- const [dateState, setDateState] = useState<{
72
- current: Date | null;
73
- month: number;
74
- year: number;
75
- hours: number;
76
- minutes: number;
77
- }>({
78
- current: defaultValue,
79
- month: defaultValue.getMonth() + 1,
80
- year: defaultValue.getFullYear(),
81
- hours: 0,
82
- minutes: 0,
83
- });
84
- const [today, setToday] = useState(new Date());
85
- let pressureTimer: ReturnType<typeof setInterval>;
86
- let pressureTimeout: ReturnType<typeof setTimeout>;
87
- let dayTimeout: ReturnType<typeof setTimeout>;
88
-
89
- const addDateToState = (date: Date) => {
90
- const isDateObject = isDate(date);
91
- const _date = isDateObject ? date : new Date();
92
- setDateState({
93
- current: isDateObject ? date : null,
94
- month: +_date.getMonth() + 1,
95
- year: _date.getFullYear(),
96
- hours: _date.getHours(),
97
- minutes: _date.getMinutes(),
98
- });
99
- };
100
-
101
- const getCalendarDates = () => {
102
- const { current, month, year } = dateState;
103
- const calendarMonth = month || +(current?.getMonth() || 0) + 1;
104
- const calendarYear = year || current?.getFullYear();
105
- return calendar(calendarMonth, calendarYear);
106
- };
107
-
108
- //new start
109
-
110
- const renderMonthAndYear = () => {
111
- const { month, year } = dateState;
112
-
113
- // Resolve the month name from the CALENDAR_MONTHS object map
114
- const monthname =
115
- Object.keys(CALENDAR_MONTHS)[Math.max(0, Math.min(month - 1, 11))];
116
- return (
117
- <CalendarHeader>
118
- <ChevronLeftIcon
119
- onMouseDown={handlePrevious}
120
- onMouseUp={clearPressureTimer}
121
- // title="Previous Month"
122
- />
123
- <CalendarMonth>
124
- {monthname} {year}
125
- </CalendarMonth>
126
- <ChevronRightIcon
127
- onMouseDown={handleNext}
128
- onMouseUp={clearPressureTimer}
129
- // title="Next Month"
130
- />
131
- </CalendarHeader>
132
- );
133
- };
134
- // Render the label for day of the week
135
- // This method is used as a map callback as seen in render()
136
- const renderDayLabel = (day: string, index?: number) => {
137
- // Resolve the day of the week label from the WEEK_DAYS object map
138
- const daylabel = WEEK_DAYS[day as WeekDay];
139
- return (
140
- <CalendarDay key={daylabel} index={index}>
141
- {daylabel}
142
- </CalendarDay>
143
- );
144
- };
145
- // Render a calendar date as returned from the calendar builder function
146
- // This method is used as a map callback as seen in render()
147
- const renderCalendarDate = (date: (string | number)[], index: number) => {
148
- const { current, month, year } = dateState;
149
- const _date = new Date(date.join("-"));
150
- // Check if calendar date is same day as today
151
- const isToday = isSameDay(_date, today);
152
-
153
- // Check if calendar date is same day as currently selected date
154
- const isCurrent = current && isSameDay(_date, current);
155
-
156
- // Check if calendar date is in the same month as the state month and year
157
- const inMonth =
158
- month && year && isSameMonth(_date, new Date([year, month, 1].join("-")));
159
- // The click handler
160
- const props = {
161
- "data-disabled": !checkValidRange(
162
- getDateISO(_date),
163
- min || null,
164
- max || null
165
- ),
166
- index,
167
- key: getDateISO(_date),
168
- onClick: gotoDate(_date),
169
- title: _date.toDateString(),
170
- inMonth,
171
- };
172
- // Conditionally render a styled date component
173
-
174
- return isCurrent ? (
175
- <HighlightedCalendarDate {...props}>
176
- {_date.getDate()}
177
- </HighlightedCalendarDate>
178
- ) : isToday ? (
179
- <TodayCalendarDate {...props}>{_date.getDate()}</TodayCalendarDate>
180
- ) : (
181
- <CalendarDate {...props}>{_date.getDate()}</CalendarDate>
182
- );
183
- };
184
-
185
- const renderHours = () => {
186
- const { hours } = dateState;
187
- const hoursArray = hourFormat === "24" ? HOURS24 : HOURS12;
188
- return hoursArray.map((hour, index) => {
189
- const HourComponent = hour.value === hours ? TimeItemActive : TimeItem;
190
- return (
191
- <HourComponent
192
- key={hour.value}
193
- // value={hour.value}
194
- onClick={(e) => {
195
- const newTime = moment(dateState.current)
196
- .hours(hour.value)
197
- .toDate();
198
- setDateState({
199
- ...dateState,
200
- hours: hour.value,
201
- current: newTime,
202
- });
203
- onChange(newTime);
204
- }}
205
- >
206
- {hour.label}
207
- </HourComponent>
208
- );
209
- });
210
- };
211
-
212
- const renderMinutes = () => {
213
- const { minutes } = dateState;
214
- return MINUTES.map((minute) => {
215
- const MinuteComponent = minute === minutes ? TimeItemActive : TimeItem;
216
- return (
217
- <MinuteComponent
218
- key={minute}
219
- // value={minute}
220
- onClick={(e) => {
221
- const newTime = moment(dateState.current)
222
- .minutes(Number(minute))
223
- .toDate();
224
- setDateState({
225
- ...dateState,
226
- minutes: Number(minute),
227
- current: newTime,
228
- });
229
- onChange(newTime);
230
- }}
231
- >
232
- {minute}
233
- </MinuteComponent>
234
- );
235
- });
236
- };
237
-
238
- type GotoDate = (
239
- date: Date
240
- ) => (
241
- evt:
242
- | React.MouseEvent<HTMLElement, MouseEvent>
243
- | React.FormEvent<HTMLFormElement>
244
- | undefined
245
- ) => void;
246
-
247
- // new 2
248
- const gotoDate: GotoDate = (date) => (evt) => {
249
- evt && evt.preventDefault();
250
- const { current } = dateState;
251
-
252
- // Set Hours and Minutes
253
- const newTime = moment(date)
254
- .hours(includeTime ? dateState.hours : 0)
255
- .minutes(includeTime ? dateState.minutes : 0)
256
- .toDate();
257
-
258
- !(current && isSameDay(newTime, current)) && addDateToState(newTime);
259
- onChange(newTime);
260
- };
261
-
262
- const gotoPreviousMonth = () => {
263
- const { month, year } = dateState;
264
- const previousMonth = getPreviousMonth(month, year);
265
- setDateState({
266
- month: previousMonth.month,
267
- year: previousMonth.year,
268
- current: dateState.current,
269
- hours: dateState.hours,
270
- minutes: dateState.minutes,
271
- });
272
- };
273
-
274
- const gotoNextMonth = () => {
275
- const { month, year } = dateState;
276
- const nextMonth = getNextMonth(month, year);
277
- setDateState({
278
- month: nextMonth.month,
279
- year: nextMonth.year,
280
- current: dateState.current,
281
- hours: dateState.hours,
282
- minutes: dateState.minutes,
283
- });
284
- };
285
- const gotoPreviousYear = () => {
286
- const { year } = dateState;
287
- setDateState({
288
- month: dateState.month,
289
- year: year - 1,
290
- current: dateState.current,
291
- hours: dateState.hours,
292
- minutes: dateState.minutes,
293
- });
294
- };
295
- const gotoNextYear = () => {
296
- const { year } = dateState;
297
- setDateState({
298
- month: dateState.month,
299
- year: year + 1,
300
- current: dateState.current,
301
- hours: dateState.hours,
302
- minutes: dateState.minutes,
303
- });
304
- };
305
- const clearPressureTimer = () => {
306
- pressureTimer && clearInterval(pressureTimer);
307
- pressureTimeout && clearTimeout(pressureTimeout);
308
- };
309
- const handlePrevious = (evt: React.MouseEvent) => {
310
- evt && evt.preventDefault();
311
- const fn = evt.shiftKey ? gotoPreviousYear : gotoPreviousMonth;
312
- fn();
313
- };
314
- const handleNext = (evt: React.MouseEvent) => {
315
- evt && evt.preventDefault();
316
- const fn = evt.shiftKey ? gotoNextYear : gotoNextMonth;
317
- fn();
318
- };
319
-
320
- useEffect(() => {
321
- if (value) {
322
- addDateToState(value);
323
- }
324
- }, [value]);
325
-
326
- // lifecycle methods
327
- useEffect(() => {
328
- const now = new Date().valueOf();
329
- const tomorrow = new Date().setHours(0, 0, 0, 0) + 24 * 60 * 60 * 1000;
330
- const ms = tomorrow - now;
331
- dayTimeout = setTimeout(() => {
332
- setToday(new Date());
333
- clearDayTimeout();
334
- }, ms);
335
- return () => {
336
- clearPressureTimer();
337
- clearDayTimeout();
338
- };
339
- }, []);
340
-
341
- const clearDayTimeout = () => {
342
- dayTimeout && clearTimeout(dayTimeout);
343
- };
344
-
345
- return (
346
- <MainContainer>
347
- <CalendarContainer>
348
- {renderMonthAndYear()}
349
- <CalendarGrid>
350
- <Fragment>{Object.keys(WEEK_DAYS).map(renderDayLabel)}</Fragment>
351
- <Fragment>{getCalendarDates().map(renderCalendarDate)}</Fragment>
352
- </CalendarGrid>
353
- {clearable && (
354
- <div style={{ textAlign: "center", marginTop: 3 }}>
355
- <NoValueButton onClick={() => onChange(null)}>
356
- Clear Date
357
- </NoValueButton>
358
- </div>
359
- )}
360
- </CalendarContainer>
361
- {includeTime && (
362
- <TimeContainer>
363
- <TimeHeader>Select Time</TimeHeader>
364
- <TimePickerContainer>
365
- <TimeHourSelect>{renderHours()}</TimeHourSelect>
366
- <TimeMinuteSelect>{renderMinutes()}</TimeMinuteSelect>
367
- </TimePickerContainer>
368
- </TimeContainer>
369
- )}
370
- </MainContainer>
371
- );
372
- };
373
-
374
- Calendar.displayName = "Calendar";
375
-
376
- export default Calendar;
@@ -1,180 +0,0 @@
1
- import styled from "styled-components";
2
-
3
- export const MainContainer = styled.div`
4
- display: flex;
5
- `;
6
- export const CalendarContainer = styled.div`
7
- font-size: 5px;
8
- width: 250px;
9
- border-radius: 4px;
10
- overflow: hidden;
11
- `;
12
- export const CalendarHeader = styled.div`
13
- display: flex;
14
- align-items: center;
15
- justify-content: space-between;
16
- `;
17
- export const CalendarGrid = styled.div`
18
- display: grid;
19
- grid-template: repeat(7, auto) / repeat(7, auto);
20
- `;
21
- export const CalendarMonth = styled.div`
22
- font-weight: 500;
23
- font-size: 12px;
24
- color: ${(props) => props.theme.palette.text.primary};
25
- text-align: center;
26
- padding: 0.5em 0.25em;
27
- word-spacing: 5px;
28
- user-select: none;
29
- `;
30
-
31
- interface CalendarCellProps {
32
- index?: number;
33
- inMonth?: boolean | 0;
34
- "data-disabled"?: boolean | 0;
35
- key: string | null;
36
- title?: string;
37
- }
38
-
39
- export const CalendarCell = styled.div<CalendarCellProps>`
40
- text-align: center;
41
- align-self: center;
42
- letter-spacing: 0.1rem;
43
- padding: 7px;
44
- user-select: none;
45
- border-radius: 5px;
46
- border: 1px solid transparent;
47
- grid-column: ${({ index = 0 }) => (index % 7) + 1} / span 1;
48
- `;
49
-
50
- export const CalendarDay = styled(CalendarCell)<CalendarCellProps>`
51
- font-weight: bold;
52
- font-size: 10px;
53
- border-radius: 0px;
54
- color: ${(props) => props.theme.palette.text.secondary};
55
- `;
56
-
57
- export const CalendarDate = styled(CalendarCell)<CalendarCellProps>`
58
- font-weight: ${(props) => (props.inMonth ? 500 : 300)};
59
- font-size: 10px;
60
- cursor: pointer;
61
-
62
- color: ${({ inMonth, theme }) =>
63
- inMonth ? theme.palette.text.primary : theme.palette.text.secondary};
64
- grid-row: ${({ index }) => Math.floor((index || 0) / 7) + 2} / span 1;
65
- transition: all 0.2s ease-out;
66
- border-radius: 5px;
67
- :hover {
68
- background: ${({ theme }) => theme.palette.action.hover};
69
- }
70
-
71
- &[data-disabled="true"] {
72
- pointer-events: none;
73
- color: ${({ theme }) => theme.palette.text.disabled};
74
- }
75
- `;
76
- export const HighlightedCalendarDate = styled(CalendarDate)<CalendarCellProps>`
77
- color: white !important;
78
- background: ${(props) => props.theme.palette.primary.main} !important;
79
- border: 1px solid ${(props) => props.theme.palette.primary.main} !important;
80
- position: relative;
81
- ::before {
82
- content: "";
83
- position: absolute;
84
- top: -1px;
85
- left: -1px;
86
- width: calc(100% + 2px);
87
- height: calc(100% + 2px);
88
- }
89
- `;
90
- export const TodayCalendarDate = styled(
91
- HighlightedCalendarDate
92
- )<CalendarCellProps>`
93
- color: ${(props) => props.theme.palette.text.primary} !important;
94
- background: transparent !important;
95
- ::after {
96
- content: "";
97
- position: absolute;
98
- right: 0;
99
- bottom: 0;
100
- border-bottom: 0.75em solid #06c;
101
- border-left: 0.75em solid transparent;
102
- border-top: 0.75em solid transparent;
103
- }
104
- :hover {
105
- color: ${(props) => props.theme.palette.text.primary} !important;
106
- background: ${(props) => props.theme.palette.action.hover} !important;
107
- }
108
- `;
109
- export const TimeContainer = styled.div`
110
- font-size: 12px;
111
- width: 150px;
112
- height: 100%;
113
- border: 1px solid ${(props) => props.theme.palette.divider};
114
- border-left: none;
115
- border-radius: 4px;
116
- overflow: hidden;
117
- `;
118
- export const TimePickerContainer = styled.div`
119
- display: flex;
120
- height: 100%;
121
- `;
122
- export const TimeHeader = styled.div`
123
- font-weight: 500;
124
- font-size: 12px;
125
- color: ${(props) => props.theme.palette.text.primary};
126
- border-bottom: 1px solid ${(props) => props.theme.palette.divider};
127
- text-align: center;
128
- padding: 5px;
129
- line-height: 2.3;
130
- height: 40px;
131
- user-select: none;
132
- `;
133
- export const TimeHourSelect = styled.div`
134
- border-right: 1px solid ${(props) => props.theme.palette.divider};
135
- width: 50%;
136
- height: 250px;
137
- overflow-y: auto;
138
- `;
139
- export const TimeMinuteSelect = styled.div`
140
- width: 50%;
141
- height: 250px;
142
- overflow-y: auto;
143
- `;
144
- export const TimeItem = styled.div`
145
- font-weight: 500;
146
- font-size: 10px;
147
- color: ${(props) => props.theme.palette.text.primary};
148
- text-align: center;
149
- padding: 5px;
150
- user-select: none;
151
- cursor: pointer;
152
- transition: all 0.2s ease-out;
153
- :hover {
154
- background: ${(props) => props.theme.palette.action.hover};
155
- }
156
- `;
157
- export const TimeItemActive = styled(TimeItem)`
158
- background: ${(props) => props.theme.palette.primary.main};
159
- color: white;
160
- &:hover {
161
- background: ${(props) => props.theme.palette.primary.main};
162
- }
163
- `;
164
-
165
- export const NoValueButton = styled.button`
166
- font-weight: normal;
167
- font-size: 12px;
168
- color: ${(props) => props.theme.palette.text.secondary};
169
- text-align: center;
170
- padding: 5px;
171
- user-select: none;
172
- cursor: pointer;
173
- transition: all 0.2s ease-out;
174
- border: none;
175
- border-radius: 5px;
176
- background: transparent;
177
- :hover {
178
- background: ${(props) => props.theme.palette.action.hover};
179
- }
180
- `;