@monolith-forensics/monolith-ui 1.0.10 → 1.1.0

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 (189) hide show
  1. package/Button/Button.tsx +382 -0
  2. package/Button/index.ts +2 -0
  3. package/{src/components/Calendar/Calendar.js → Calendar/Calendar.tsx} +104 -93
  4. package/{src/components/Calendar/CalendarStyles.js → Calendar/CalendarStyles.tsx} +26 -36
  5. package/{src/components/Calendar/calendarHelpers.js → Calendar/calendarHelpers.ts} +10 -8
  6. package/Calendar/index.ts +1 -0
  7. package/CheckBox/CheckBox.tsx +61 -0
  8. package/CheckBox/index.ts +1 -0
  9. package/{src/components/DateInput/DateInput.js → DateInput/DateInput.tsx} +227 -93
  10. package/DateInput/index.ts +1 -0
  11. package/DropDownMenu/DropDownMenu.tsx +402 -0
  12. package/DropDownMenu/index.ts +1 -0
  13. package/Error/Error.tsx +51 -0
  14. package/Error/index.ts +1 -0
  15. package/{src/components/FieldLabel → FieldLabel}/FieldLabel.tsx +25 -22
  16. package/{src/components/FileInputField/FileInputField.js → FileInputField/FileInputField.tsx} +23 -15
  17. package/FileInputField/index.ts +1 -0
  18. package/Flyout/Flyout.tsx +172 -0
  19. package/Flyout/FlyoutHeader.tsx +14 -0
  20. package/Flyout/FlyoutTitle.tsx +10 -0
  21. package/Flyout/index.ts +3 -0
  22. package/FormSection/FormSection.tsx +71 -0
  23. package/FormSection/index.ts +1 -0
  24. package/Grid/Grid.tsx +18 -0
  25. package/Grid/index.ts +1 -0
  26. package/IconButton/IconButton.tsx +27 -0
  27. package/IconButton/index.ts +1 -0
  28. package/{src/components/Input → Input}/Input.tsx +57 -34
  29. package/Modal/Modal.tsx +172 -0
  30. package/Modal/index.ts +1 -0
  31. package/{src/components/Pill → Pill}/Pill.tsx +41 -11
  32. package/SelectBox/SelectBox.tsx +745 -0
  33. package/SelectBox/index.ts +1 -0
  34. package/Switch/Switch.tsx +204 -0
  35. package/Switch/index.ts +1 -0
  36. package/TagBox/TagBox.tsx +694 -0
  37. package/TagBox/TagBoxStyles.tsx +116 -0
  38. package/TagBox/index.ts +1 -0
  39. package/{src/components/TextArea → TextArea}/TextArea.tsx +35 -13
  40. package/{src/components/TextAreaInput → TextAreaInput}/TextAreaInput.tsx +11 -13
  41. package/{src/components/TextInput → TextInput}/TextInput.tsx +11 -13
  42. package/Tooltip/Tooltip.tsx +68 -0
  43. package/Tooltip/index.ts +1 -0
  44. package/{src/components/ArrowButton → core}/ArrowButton.tsx +17 -20
  45. package/core/ClearButton.tsx +51 -0
  46. package/core/StyledContent.tsx +50 -0
  47. package/core/StyledFloatContainer.tsx +7 -0
  48. package/core/Types/Size.ts +3 -0
  49. package/core/Types/Variant.ts +10 -0
  50. package/core/index.ts +6 -0
  51. package/dist/Button/Button.d.ts +19 -0
  52. package/dist/Button/Button.js +332 -0
  53. package/dist/Button/index.d.ts +2 -0
  54. package/dist/Button/index.js +8 -0
  55. package/dist/Calendar/Calendar.d.ts +15 -0
  56. package/dist/Calendar/Calendar.js +232 -0
  57. package/dist/Calendar/CalendarStyles.d.ts +36 -0
  58. package/dist/Calendar/CalendarStyles.js +170 -0
  59. package/dist/Calendar/calendarHelpers.d.ts +53 -0
  60. package/dist/Calendar/calendarHelpers.js +181 -0
  61. package/dist/Calendar/index.d.ts +1 -0
  62. package/dist/Calendar/index.js +8 -0
  63. package/dist/CheckBox/CheckBox.d.ts +11 -0
  64. package/dist/CheckBox/CheckBox.js +34 -0
  65. package/dist/CheckBox/index.d.ts +1 -0
  66. package/dist/CheckBox/index.js +8 -0
  67. package/dist/DateInput/DateInput.d.ts +24 -0
  68. package/dist/DateInput/DateInput.js +511 -0
  69. package/dist/DateInput/index.d.ts +1 -0
  70. package/dist/DateInput/index.js +8 -0
  71. package/dist/DropDownMenu/DropDownMenu.d.ts +36 -0
  72. package/dist/DropDownMenu/DropDownMenu.js +212 -0
  73. package/dist/DropDownMenu/index.d.ts +1 -0
  74. package/dist/DropDownMenu/index.js +8 -0
  75. package/dist/Error/Error.d.ts +4 -0
  76. package/dist/Error/Error.js +38 -0
  77. package/dist/Error/index.d.ts +1 -0
  78. package/dist/Error/index.js +8 -0
  79. package/dist/FieldLabel/FieldLabel.d.ts +19 -0
  80. package/dist/FieldLabel/FieldLabel.js +119 -0
  81. package/dist/FieldLabel/index.d.ts +1 -0
  82. package/dist/FieldLabel/index.js +8 -0
  83. package/dist/FileInputField/FileInputField.d.ts +18 -0
  84. package/dist/FileInputField/FileInputField.js +116 -0
  85. package/dist/FileInputField/index.d.ts +1 -0
  86. package/dist/FileInputField/index.js +8 -0
  87. package/dist/Flyout/Flyout.d.ts +10 -0
  88. package/dist/Flyout/Flyout.js +111 -0
  89. package/dist/Flyout/FlyoutHeader.d.ts +5 -0
  90. package/dist/Flyout/FlyoutHeader.js +12 -0
  91. package/dist/Flyout/FlyoutTitle.d.ts +2 -0
  92. package/dist/Flyout/FlyoutTitle.js +13 -0
  93. package/dist/Flyout/index.d.ts +3 -0
  94. package/dist/Flyout/index.js +12 -0
  95. package/dist/FormSection/FormSection.d.ts +9 -0
  96. package/dist/FormSection/FormSection.js +51 -0
  97. package/dist/FormSection/index.d.ts +1 -0
  98. package/dist/FormSection/index.js +8 -0
  99. package/dist/Grid/Grid.d.ts +6 -0
  100. package/dist/Grid/Grid.js +15 -0
  101. package/dist/Grid/index.d.ts +1 -0
  102. package/dist/Grid/index.js +8 -0
  103. package/dist/IconButton/IconButton.d.ts +5 -0
  104. package/dist/IconButton/IconButton.js +30 -0
  105. package/dist/IconButton/index.d.ts +1 -0
  106. package/dist/IconButton/index.js +8 -0
  107. package/dist/Input/Input.d.ts +21 -0
  108. package/dist/Input/Input.js +148 -0
  109. package/dist/Input/index.d.ts +1 -0
  110. package/dist/Input/index.js +8 -0
  111. package/dist/Modal/Modal.d.ts +14 -0
  112. package/dist/Modal/Modal.js +134 -0
  113. package/dist/Modal/index.d.ts +1 -0
  114. package/dist/Modal/index.js +8 -0
  115. package/dist/Pill/Pill.d.ts +11 -0
  116. package/dist/Pill/Pill.js +146 -0
  117. package/dist/Pill/index.d.ts +1 -0
  118. package/dist/Pill/index.js +8 -0
  119. package/dist/SelectBox/SelectBox.d.ts +45 -0
  120. package/dist/SelectBox/SelectBox.js +469 -0
  121. package/dist/SelectBox/index.d.ts +1 -0
  122. package/dist/SelectBox/index.js +8 -0
  123. package/dist/Switch/Switch.d.ts +18 -0
  124. package/dist/Switch/Switch.js +157 -0
  125. package/dist/Switch/index.d.ts +1 -0
  126. package/dist/Switch/index.js +8 -0
  127. package/dist/TagBox/TagBox.d.ts +38 -0
  128. package/dist/TagBox/TagBox.js +440 -0
  129. package/dist/TagBox/TagBoxStyles.d.ts +11 -0
  130. package/dist/TagBox/TagBoxStyles.js +113 -0
  131. package/dist/TagBox/index.d.ts +1 -0
  132. package/dist/TagBox/index.js +8 -0
  133. package/dist/TextArea/TextArea.d.ts +16 -0
  134. package/dist/TextArea/TextArea.js +80 -0
  135. package/dist/TextArea/index.d.ts +1 -0
  136. package/dist/TextArea/index.js +8 -0
  137. package/dist/TextAreaInput/TextAreaInput.d.ts +12 -0
  138. package/dist/TextAreaInput/TextAreaInput.js +23 -0
  139. package/dist/TextAreaInput/index.d.ts +1 -0
  140. package/dist/TextAreaInput/index.js +8 -0
  141. package/dist/TextInput/TextInput.d.ts +12 -0
  142. package/dist/TextInput/TextInput.js +30 -0
  143. package/dist/TextInput/index.d.ts +1 -0
  144. package/dist/TextInput/index.js +8 -0
  145. package/dist/Tooltip/Tooltip.d.ts +12 -0
  146. package/dist/Tooltip/Tooltip.js +53 -0
  147. package/dist/Tooltip/index.d.ts +1 -0
  148. package/dist/Tooltip/index.js +8 -0
  149. package/dist/core/ArrowButton.d.ts +6 -0
  150. package/dist/core/ArrowButton.js +48 -0
  151. package/dist/core/ClearButton.d.ts +6 -0
  152. package/dist/core/ClearButton.js +48 -0
  153. package/dist/core/StyledContent.d.ts +7 -0
  154. package/dist/core/StyledContent.js +46 -0
  155. package/dist/core/StyledFloatContainer.d.ts +2 -0
  156. package/dist/core/StyledFloatContainer.js +10 -0
  157. package/dist/core/Types/Size.d.ts +2 -0
  158. package/dist/core/Types/Size.js +2 -0
  159. package/dist/core/Types/Variant.d.ts +2 -0
  160. package/dist/core/Types/Variant.js +2 -0
  161. package/dist/core/index.d.ts +6 -0
  162. package/dist/core/index.js +14 -0
  163. package/dist/index.d.ts +22 -0
  164. package/dist/index.js +51 -0
  165. package/index.ts +22 -0
  166. package/package.json +12 -21
  167. package/{src/components/theme → theme}/components.js +0 -2
  168. package/{src/components/theme → theme}/index.js +0 -1
  169. package/{src/components/theme → theme}/variants.js +0 -1
  170. package/tsconfig.json +11 -11
  171. package/.gitattributes +0 -2
  172. package/rollup.config.js +0 -10
  173. package/src/components/ArrowButton/index.tsx +0 -1
  174. package/src/components/Button/Button.tsx +0 -278
  175. package/src/components/Button/index.ts +0 -1
  176. package/src/components/SelectBox/SelectBox.js +0 -543
  177. package/src/components/TagBox/TagBox.js +0 -563
  178. package/src/components/index.ts +0 -7
  179. package/src/index.ts +0 -1
  180. /package/{src/components/FieldLabel → FieldLabel}/index.ts +0 -0
  181. /package/{src/components/Input/index.tsx → Input/index.ts} +0 -0
  182. /package/{src/components/Pill → Pill}/index.ts +0 -0
  183. /package/{src/components/TextArea → TextArea}/index.ts +0 -0
  184. /package/{src/components/TextAreaInput → TextAreaInput}/index.ts +0 -0
  185. /package/{src/components/TextInput/index.tsx → TextInput/index.ts} +0 -0
  186. /package/{src/components/core/index.js → core/MonolithThemeProvider.js} +0 -0
  187. /package/{src/components/theme → theme}/breakpoints.js +0 -0
  188. /package/{src/components/theme → theme}/shadows.js +0 -0
  189. /package/{src/components/theme → theme}/typography.js +0 -0
@@ -0,0 +1,402 @@
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;
@@ -0,0 +1 @@
1
+ export { default } from "./DropDownMenu";
@@ -0,0 +1,51 @@
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 ADDED
@@ -0,0 +1 @@
1
+ export { default } from "./Error";
@@ -1,15 +1,17 @@
1
- import React from "react";
2
1
  import styled from "styled-components";
3
2
  import * as Tooltip from "@radix-ui/react-tooltip";
3
+ import { ReactNode } from "react";
4
+ import { Size } from "../core";
4
5
 
5
6
  interface InfoComponentProps {
6
- description?: string | null;
7
- label?: string | Element;
8
- children: React.ReactNode;
7
+ className?: string;
8
+ children?: ReactNode;
9
+ description?: string;
10
+ label?: string | ReactNode;
9
11
  }
10
12
 
11
- const InfoComponent: React.FC<InfoComponentProps> = styled(
12
- ({ className, children, description, label }) => {
13
+ export const InfoComponent = styled(
14
+ ({ className, children, description, label }: InfoComponentProps) => {
13
15
  if (!description) return children;
14
16
 
15
17
  return (
@@ -38,7 +40,7 @@ const InfoComponent: React.FC<InfoComponentProps> = styled(
38
40
  }
39
41
  )`
40
42
  pointer-events: none;
41
- z-index: 99999;
43
+ z-index: 999999;
42
44
  background-color: ${({ theme }) => theme.palette.background.default};
43
45
  padding: 15px;
44
46
  border-radius: 5px;
@@ -57,46 +59,46 @@ const InfoComponent: React.FC<InfoComponentProps> = styled(
57
59
  `;
58
60
 
59
61
  interface FieldLabelProps {
60
- errorMessage?: string;
61
- error?: boolean;
62
- description?: string | null;
63
- size?: "xs" | "sm" | "md" | "lg" | "xl";
62
+ className?: string;
63
+ children?: ReactNode;
64
+ error?: string;
65
+ description?: string;
66
+ size?: Size;
64
67
  asterisk?: boolean;
65
- children: string | Element;
66
68
  }
67
69
 
68
- const FieldLabel: React.FC<FieldLabelProps> = styled(
70
+ const FieldLabel = styled(
69
71
  ({
70
72
  className,
71
73
  children,
72
- errorMessage,
73
- error = false,
74
- description = null,
75
- }) => {
74
+ error,
75
+ description,
76
+ size = "sm",
77
+ }: FieldLabelProps) => {
76
78
  return (
77
- <div className={className}>
79
+ <div className={className + " FieldLabel"}>
78
80
  <InfoComponent description={description} label={children}>
79
81
  <div className="label">{children}</div>
80
82
  </InfoComponent>
81
83
  {error && (
82
- <div className="error" title={errorMessage || error}>
83
- {errorMessage || error || "Invalid Value"}
84
+ <div className="error" title={error}>
85
+ {error || "Invalid Value"}
84
86
  </div>
85
87
  )}
86
88
  </div>
87
89
  );
88
90
  }
89
91
  )`
92
+ user-select: none;
90
93
  font-family: apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
91
94
  "Helvetica Neue", Arial, sans-serif;
92
95
  user-select: none;
93
96
  display: flex;
94
97
  flex-direction: row;
95
- align-items: center;
98
+ align-items: baseline;
96
99
  gap: 5px;
97
100
 
98
101
  min-height: 15px;
99
- // font-size: 12px;
100
102
  font-weight: 400;
101
103
  margin-bottom: 2.5px;
102
104
 
@@ -134,6 +136,7 @@ const FieldLabel: React.FC<FieldLabelProps> = styled(
134
136
  }
135
137
 
136
138
  .error {
139
+ user-select: none;
137
140
  transition: all 0.2s ease;
138
141
  cursor: pointer;
139
142
  color: ${({ theme }) => theme.palette.error.main};
@@ -1,8 +1,22 @@
1
- import { useCallback, useState } from "react";
2
- import { useDropzone } from "react-dropzone";
1
+ import { useCallback, useState, ReactNode, HTMLAttributes } from "react";
3
2
  import styled from "styled-components";
4
- import FieldLabel from "../FieldLabel/FieldLabel.js";
5
- import Pill from "../Pill/Pill.js";
3
+ import { useDropzone, DropzoneOptions } from "react-dropzone";
4
+ import { Pill, FieldLabel } from "..";
5
+ import { Size, Variant } from "../core";
6
+
7
+ interface FileInputFieldProps {
8
+ className?: string;
9
+ children?: ReactNode;
10
+ variant?: Variant;
11
+ label?: string;
12
+ error?: string;
13
+ required?: boolean;
14
+ size?: Size;
15
+ onChange?: (files: File[]) => void;
16
+ onFocus?: () => void;
17
+ dropZoneOptions?: DropzoneOptions;
18
+ style?: HTMLAttributes<HTMLDivElement>;
19
+ }
6
20
 
7
21
  const FileInputField = styled(
8
22
  ({
@@ -10,23 +24,22 @@ const FileInputField = styled(
10
24
  children,
11
25
  label,
12
26
  error,
13
- errorMessage,
14
27
  required,
15
28
  size,
16
29
  onChange,
17
30
  onFocus,
18
31
  dropZoneOptions = {},
19
32
  style = {},
20
- }) => {
21
- const [files, setFiles] = useState([]);
33
+ }: FileInputFieldProps) => {
34
+ const [files, setFiles] = useState<File[]>([]);
22
35
 
23
- const onDrop = useCallback((acceptedFiles) => {
36
+ const onDrop = useCallback((acceptedFiles: File[]) => {
24
37
  setFiles(acceptedFiles);
25
38
  // Do something with the files
26
39
  onChange?.(acceptedFiles);
27
40
  }, []);
28
41
 
29
- const handleRemoveFile = (file) => {
42
+ const handleRemoveFile = (file: File) => {
30
43
  setFiles((prev) => prev.filter((f) => f !== file));
31
44
  };
32
45
 
@@ -38,12 +51,7 @@ const FileInputField = styled(
38
51
  return (
39
52
  <div className={className}>
40
53
  {label && (
41
- <FieldLabel
42
- error={error}
43
- errorMessage={errorMessage}
44
- asterisk={required}
45
- size={size}
46
- >
54
+ <FieldLabel error={error} asterisk={required} size={size}>
47
55
  {label}
48
56
  </FieldLabel>
49
57
  )}
@@ -0,0 +1 @@
1
+ export { default } from "./FileInputField";