@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,402 +0,0 @@
1
- import {
2
- FloatingFocusManager,
3
- FloatingPortal,
4
- flip,
5
- useFloating,
6
- } from "@floating-ui/react";
7
- import {
8
- ComponentPropsWithoutRef,
9
- ComponentType,
10
- ReactNode,
11
- UIEvent,
12
- forwardRef,
13
- useEffect,
14
- useRef,
15
- useState,
16
- } from "react";
17
- import styled from "styled-components";
18
- import { Button, Tooltip, CheckBox, Input } from "..";
19
- import { useDebouncedCallback } from "use-debounce";
20
- import { ButtonProps } from "../Button";
21
- import { Size, Variant } from "../core";
22
-
23
- const StyledFloatContainer = styled.div`
24
- z-index: 1500;
25
- `;
26
-
27
- const StyledInnerItemContainer = styled.div`
28
- overflow-y: auto;
29
-
30
- &[data-scroll-active="true"] {
31
- padding-right: 5px;
32
- }
33
- `;
34
-
35
- type SearchInputProps = React.ComponentPropsWithoutRef<typeof Input>;
36
-
37
- const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(
38
- (props, ref) => <Input ref={ref} style={{ marginBottom: 8 }} {...props} />
39
- );
40
-
41
- interface StyledItemProps {
42
- className?: string;
43
- children?: React.ReactNode | string;
44
- size?: Size;
45
- disabled?: boolean;
46
- onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
47
- "data-selected"?: boolean;
48
- }
49
-
50
- const StyledItem = styled.div<StyledItemProps>`
51
- color: ${(props) => props.theme.palette.text.primary};
52
- border-radius: 3px;
53
- display: flex;
54
- flex-direction: row;
55
- gap: 5px;
56
- align-items: center;
57
- min-height: 25px;
58
- padding: 7px 10px;
59
- position: relative;
60
- user-select: none;
61
- outline: none;
62
-
63
- white-space: nowrap;
64
- overflow: hidden;
65
- text-overflow: ellipsis;
66
-
67
- cursor: pointer;
68
-
69
- font-family: ${({ theme }) => theme.typography.fontFamily};
70
-
71
- font-size: ${({ size }) =>
72
- size === "xs"
73
- ? "11px"
74
- : size === "sm"
75
- ? "13px"
76
- : size === "md"
77
- ? "15px"
78
- : size === "lg"
79
- ? "17px"
80
- : size === "xl"
81
- ? "19px"
82
- : "11px"};
83
-
84
- padding: ${({ size }) =>
85
- size === "xs"
86
- ? "2px 8px"
87
- : size === "sm"
88
- ? "4px 10px"
89
- : size === "md"
90
- ? "4px 12px"
91
- : size === "lg"
92
- ? "5px 14px"
93
- : size === "xl"
94
- ? "6px 16px"
95
- : "2px 8px"};
96
-
97
- &[data-disabled] {
98
- color: ${(props) => props.theme.palette.text.secondary};
99
- pointer-events: "none";
100
- }
101
-
102
- &:hover {
103
- background-color: ${(props) => props.theme.palette.action.hover};
104
- color: ${(props) => props.theme.palette.text.primary};
105
- }
106
- `;
107
-
108
- interface StyledContentProps {
109
- maxDropdownHeight?: number | string;
110
- variant?: Variant;
111
- }
112
-
113
- const StyledContent = styled.div<StyledContentProps>`
114
- position: relative;
115
- display: flex;
116
- flex-direction: column;
117
- overflow-y: hidden;
118
- overflow-x: hidden;
119
-
120
- max-height: ${({ maxDropdownHeight }) =>
121
- Number.isInteger(maxDropdownHeight)
122
- ? `${maxDropdownHeight}px`
123
- : maxDropdownHeight || "250px"};
124
-
125
- background-color: ${(props) => props.theme.palette.background.default};
126
- background-color: ${({ theme, variant }) => {
127
- switch (variant) {
128
- case "filled":
129
- return theme.palette.input.background;
130
- case "outlined":
131
- return theme.palette.input.background;
132
- case "text":
133
- return "transparent";
134
- default:
135
- return theme.palette.input.background;
136
- }
137
- }};
138
-
139
- border-radius: 5px;
140
- border: 1px solid ${(props) => props.theme.palette.divider};
141
- padding: 5px;
142
- animation-duration: 400ms;
143
- animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
144
- will-change: transform, opacity;
145
-
146
- &[data-empty="true"] {
147
- display: none;
148
- }
149
- `;
150
-
151
- interface DropDownItem {
152
- toLowerCase?: () => string;
153
- label: string;
154
- value: string;
155
- data?: any; // Additional data to be passed to the TooltipContent component, could be anything
156
- }
157
-
158
- interface DropDownMenuProps {
159
- className?: string;
160
- children?: ReactNode;
161
- data?: DropDownItem[];
162
- variant?: Variant;
163
- defaultValue?: DropDownItem[];
164
- multiselect?: boolean;
165
- size?: Size;
166
- title?: string;
167
- TooltipContent?: ComponentType<any>;
168
- renderOption?: (item: DropDownItem) => ReactNode;
169
- onChange?: (selected: DropDownItem[], diff: DropDownItem[]) => void;
170
- onItemSelect?: (item: DropDownItem) => void;
171
- onScroll?: (e: UIEvent<HTMLDivElement>) => void;
172
- loading?: boolean;
173
- arrow?: boolean;
174
- searchable?: boolean;
175
- dropDownProps?: ComponentPropsWithoutRef<typeof StyledContent>;
176
- buttonProps?: ButtonProps;
177
- }
178
-
179
- const DropDownMenu = styled(
180
- ({
181
- className,
182
- children,
183
- data = [],
184
- variant = "outlined",
185
- defaultValue,
186
- multiselect = false,
187
- size = "xs",
188
- TooltipContent,
189
- renderOption,
190
- onChange,
191
- onItemSelect,
192
- onScroll,
193
- loading,
194
- arrow,
195
- searchable,
196
- dropDownProps,
197
- buttonProps,
198
- }: DropDownMenuProps) => {
199
- const isObjectArray = Object.keys(data?.[0] || {})?.includes("label");
200
-
201
- const [isOpen, setIsOpen] = useState<boolean>(false);
202
- const [selected, setSelected] = useState<DropDownItem[]>(
203
- defaultValue || []
204
- );
205
- const [searchValue, setSearchValue] = useState<string>("");
206
-
207
- const scrollContainerRef = useRef<HTMLDivElement>(null);
208
- const searchInputRef = useRef<HTMLInputElement>(null);
209
-
210
- const { refs, floatingStyles, context } = useFloating({
211
- open: isOpen,
212
- onOpenChange: setIsOpen,
213
- placement: "bottom-start",
214
- strategy: "absolute",
215
- // Handle collisions with the viewport
216
- middleware: [flip()],
217
- });
218
-
219
- const handleAddItem = (item: DropDownItem) => {
220
- setSelected((prev: DropDownItem[]) => {
221
- let newSelected = [...prev, item];
222
-
223
- const diff = data.filter(
224
- (i) =>
225
- !newSelected.find((s) =>
226
- isObjectArray ? s?.value === i?.value : s === i
227
- )
228
- );
229
- onChange?.(newSelected, diff);
230
- return newSelected;
231
- });
232
- };
233
-
234
- const handleRemoveItem = (item: DropDownItem) => {
235
- setSelected((prev) => {
236
- let newSelected = prev.filter((i) =>
237
- isObjectArray ? i?.value !== item?.value : i !== item
238
- );
239
-
240
- const diff = data.filter(
241
- (i) =>
242
- !newSelected.find((s) =>
243
- isObjectArray ? s?.value === i?.value : s === i
244
- )
245
- );
246
- onChange?.(newSelected, diff);
247
- return newSelected;
248
- });
249
- };
250
-
251
- const handleSearch = useDebouncedCallback(
252
- (e: React.ChangeEvent<HTMLInputElement>) => {
253
- setSearchValue(e.target.value);
254
- },
255
- 150
256
- );
257
-
258
- // Close on outside click
259
- useEffect(() => {
260
- const close = (e: Event) => {
261
- const target = e.target as Node;
262
- const referenceElement = refs?.reference?.current as Node;
263
- const floatingElement = refs?.floating?.current as Node;
264
-
265
- if (
266
- floatingElement && // Check if the floating element exists
267
- e.target !== referenceElement && // Check if the target is not the reference (input)
268
- !referenceElement?.contains?.(target) && // Check if the target is not inside the reference (input)
269
- !floatingElement?.contains?.(target) // Check if the target is not inside the floating element (content)
270
- ) {
271
- setIsOpen(false);
272
- }
273
- };
274
- document.addEventListener("mousedown", close);
275
- return () => document.removeEventListener("mousdown", close);
276
- }, [refs.floating, refs.reference]);
277
-
278
- useEffect(() => {
279
- if (isOpen && searchable) {
280
- searchInputRef?.current?.focus?.();
281
- }
282
- if (!isOpen) {
283
- setSearchValue("");
284
- }
285
- }, [isOpen, searchable]);
286
-
287
- const scrollActive =
288
- (scrollContainerRef?.current?.scrollHeight || 0) >
289
- (scrollContainerRef?.current?.clientHeight || 0);
290
-
291
- return (
292
- <div className={className + " mfDropDownMenu"}>
293
- <Button
294
- ref={(ref) => {
295
- refs.setReference(ref);
296
- }}
297
- onMouseDown={() => setIsOpen(!isOpen)}
298
- rightSection={arrow ? <span>▼</span> : null}
299
- size={size}
300
- {...buttonProps}
301
- >
302
- {children}
303
- </Button>
304
- {isOpen && (
305
- <FloatingPortal preserveTabOrder>
306
- <FloatingFocusManager context={context} modal={false}>
307
- <StyledFloatContainer
308
- ref={refs.setFloating}
309
- style={floatingStyles}
310
- className="mfFloating"
311
- >
312
- <StyledContent
313
- className="mfFloatingContent"
314
- style={{ width: 150, maxWidth: 400 }}
315
- variant={variant}
316
- {...dropDownProps}
317
- >
318
- <StyledInnerItemContainer
319
- ref={scrollContainerRef}
320
- data-scroll-active={scrollActive}
321
- onScroll={onScroll}
322
- >
323
- {loading && <div>Loading...</div>}
324
- {searchable && (
325
- <SearchInput
326
- ref={searchInputRef}
327
- variant="outlined"
328
- placeholder="Search"
329
- onChange={handleSearch}
330
- />
331
- )}
332
- {!loading &&
333
- data
334
- .filter((item) => {
335
- if (!searchable) return true;
336
- if (isObjectArray) {
337
- return (
338
- item?.label
339
- ?.toLowerCase()
340
- .includes(searchValue.toLowerCase()) ||
341
- item?.value
342
- ?.toLowerCase()
343
- .includes(searchValue.toLowerCase())
344
- );
345
- }
346
- return item
347
- .toLowerCase?.()
348
- .includes(searchValue.toLowerCase());
349
- })
350
- .map((item, index) => {
351
- const isSelected = !!selected?.find((s) =>
352
- isObjectArray
353
- ? s?.value === item?.value
354
- : s === item
355
- );
356
- return (
357
- <Tooltip
358
- key={index}
359
- content={
360
- TooltipContent ? (
361
- <TooltipContent data={item.data} />
362
- ) : null
363
- }
364
- side="left"
365
- >
366
- <StyledItem
367
- className="mfFloatingItem"
368
- onClick={(e) => {
369
- e.preventDefault();
370
- e.stopPropagation();
371
- if (multiselect) {
372
- isSelected
373
- ? handleRemoveItem(item)
374
- : handleAddItem(item);
375
- } else {
376
- setIsOpen(false);
377
- }
378
- onItemSelect?.(item);
379
- }}
380
- data-selected={isSelected}
381
- size={size}
382
- >
383
- {multiselect && <CheckBox value={isSelected} />}
384
- <>
385
- {renderOption?.(item) || item?.label || item}
386
- </>
387
- </StyledItem>
388
- </Tooltip>
389
- );
390
- })}
391
- </StyledInnerItemContainer>
392
- </StyledContent>
393
- </StyledFloatContainer>
394
- </FloatingFocusManager>
395
- </FloatingPortal>
396
- )}
397
- </div>
398
- );
399
- }
400
- )``;
401
-
402
- export default DropDownMenu;
@@ -1 +0,0 @@
1
- export { default } from "./DropDownMenu";
package/Error/Error.tsx DELETED
@@ -1,51 +0,0 @@
1
- import React, { useState } from "react";
2
- import styled from "styled-components";
3
- import { XIcon, ShieldAlert } from "lucide-react";
4
-
5
- const ErrorContainer = styled.div`
6
- background-color: ${({ theme }) => theme.palette.error.main + "15"};
7
- color: ${({ theme }) => theme.palette.error.light};
8
- border: 1px solid #d93025;
9
- padding: 10px;
10
- margin-bottom: 10px;
11
- display: flex;
12
- justify-content: space-between;
13
- border-radius: 5px;
14
- align-items: center;
15
- `;
16
-
17
- const CloseButton = styled.button`
18
- background: none;
19
- border: none;
20
- color: ${({ theme }) => theme.palette.error.light};
21
- cursor: pointer;
22
- `;
23
-
24
- const ErrorText = styled.span`
25
- margin-left: 10px;
26
- flex: 1;
27
- `;
28
-
29
- const ErrorComponent = ({ error }: { error: string }) => {
30
- const [isVisible, setIsVisible] = useState(true);
31
-
32
- const handleClose = () => {
33
- setIsVisible(false);
34
- };
35
-
36
- return (
37
- <>
38
- {isVisible && (
39
- <ErrorContainer>
40
- <ShieldAlert size={19} />
41
- <ErrorText>{error}</ErrorText>
42
- <CloseButton onClick={handleClose}>
43
- <XIcon size={19} />
44
- </CloseButton>
45
- </ErrorContainer>
46
- )}
47
- </>
48
- );
49
- };
50
-
51
- export default ErrorComponent;
package/Error/index.ts DELETED
@@ -1 +0,0 @@
1
- export { default } from "./Error";
@@ -1,155 +0,0 @@
1
- import styled from "styled-components";
2
- import * as Tooltip from "@radix-ui/react-tooltip";
3
- import { ReactNode } from "react";
4
- import { Size } from "../core";
5
-
6
- interface InfoComponentProps {
7
- className?: string;
8
- children?: ReactNode;
9
- description?: string;
10
- label?: string | ReactNode;
11
- }
12
-
13
- export const InfoComponent = styled(
14
- ({ className, children, description, label }: InfoComponentProps) => {
15
- if (!description) return children;
16
-
17
- return (
18
- <Tooltip.Provider
19
- delayDuration={800}
20
- skipDelayDuration={0}
21
- disableHoverableContent
22
- >
23
- <Tooltip.Root>
24
- <Tooltip.Trigger asChild>{children}</Tooltip.Trigger>
25
- <Tooltip.Portal>
26
- <Tooltip.Content
27
- className={className}
28
- side="right"
29
- sideOffset={15}
30
- align="start"
31
- onClick={(e) => e.stopPropagation()}
32
- >
33
- <div className="title">{label || "Info"}</div>
34
- <div>{description || "N/A"}</div>
35
- </Tooltip.Content>
36
- </Tooltip.Portal>
37
- </Tooltip.Root>
38
- </Tooltip.Provider>
39
- );
40
- }
41
- )`
42
- pointer-events: none;
43
- z-index: 999999;
44
- background-color: ${({ theme }) => theme.palette.background.default};
45
- padding: 15px;
46
- border-radius: 5px;
47
- border: 1px solid ${({ theme }) => theme.palette.divider};
48
- font-size: 0.75rem;
49
- max-width: 350px;
50
- width: 250px;
51
-
52
- white-space: pre-wrap;
53
-
54
- .title {
55
- font-size: 0.85rem;
56
- font-weight: 600;
57
- margin-bottom: 5px;
58
- }
59
- `;
60
-
61
- interface FieldLabelProps {
62
- className?: string;
63
- children?: ReactNode;
64
- error?: string;
65
- description?: string;
66
- size?: Size;
67
- asterisk?: boolean;
68
- }
69
-
70
- const FieldLabel = styled(
71
- ({
72
- className,
73
- children,
74
- error,
75
- description,
76
- size = "sm",
77
- }: FieldLabelProps) => {
78
- return (
79
- <div className={className + " FieldLabel"}>
80
- <InfoComponent description={description} label={children}>
81
- <div className="label">{children}</div>
82
- </InfoComponent>
83
- {error && (
84
- <div className="error" title={error}>
85
- {error || "Invalid Value"}
86
- </div>
87
- )}
88
- </div>
89
- );
90
- }
91
- )`
92
- user-select: none;
93
- font-family: apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
94
- "Helvetica Neue", Arial, sans-serif;
95
- user-select: none;
96
- display: flex;
97
- flex-direction: row;
98
- align-items: baseline;
99
- gap: 5px;
100
-
101
- min-height: 15px;
102
- font-weight: 400;
103
- margin-bottom: 2.5px;
104
-
105
- font-size: ${({ size }) =>
106
- size === "xs"
107
- ? "10px"
108
- : size === "sm"
109
- ? "12px"
110
- : size === "md"
111
- ? "14px"
112
- : size === "lg"
113
- ? "16px"
114
- : size === "xl"
115
- ? "18px"
116
- : "10px"};
117
-
118
- transition: all 0.2s ease;
119
- color: ${({ theme, error }) => theme.palette.text.secondary};
120
-
121
- .label {
122
- width: fit-content;
123
- min-width: fit-content;
124
- }
125
-
126
- .label::after {
127
- content: ${(props) => (props.asterisk ? "'*'" : "")};
128
- color: ${({ theme }) => theme.palette.error.main};
129
- margin-left: 2px;
130
- }
131
-
132
- .label:hover {
133
- cursor: ${({ description }) => (description ? "pointer" : "default")};
134
- color: ${({ description, theme }) =>
135
- description ? theme.palette.text.primary : theme.palette.text.secondary};
136
- }
137
-
138
- .error {
139
- user-select: none;
140
- transition: all 0.2s ease;
141
- cursor: pointer;
142
- color: ${({ theme }) => theme.palette.error.main};
143
- font-size: 10px;
144
- max-width: 85%;
145
- white-space: nowrap;
146
- overflow: hidden;
147
- text-overflow: ellipsis;
148
- }
149
-
150
- .error:hover {
151
- color: ${({ theme }) => theme.palette.error.light};
152
- }
153
- `;
154
-
155
- export default FieldLabel;
@@ -1 +0,0 @@
1
- export { default } from "./FieldLabel";