@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,382 @@
1
+ import { ButtonHTMLAttributes, ReactNode, forwardRef } from "react";
2
+ import styled from "styled-components";
3
+ import { Loader2Icon } from "lucide-react";
4
+ import { Size, Variant } from "../core";
5
+
6
+ const colors = {
7
+ gray: "#888888",
8
+ red: "#e03131",
9
+ pink: "#c2255c",
10
+ grape: "#9c36b5",
11
+ violet: "#6741d9",
12
+ indigo: "#3b5bdb",
13
+ cyan: "#0c8599",
14
+ teal: "#099268",
15
+ green: "#2f9e44",
16
+ lime: "#66a80f",
17
+ yellow: "#f08c00",
18
+ orange: "#e8590c",
19
+ };
20
+
21
+ type ColorKeys = keyof typeof colors;
22
+
23
+ interface StyledButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
24
+ fullWidth?: boolean;
25
+ size?: string;
26
+ variant?: string;
27
+ color?: ColorKeys | string;
28
+ // Add more custom props here if needed
29
+ }
30
+
31
+ const StyledButton = styled.button<StyledButtonProps>`
32
+ user-select: none;
33
+ display: flex;
34
+ outline: none;
35
+ white-space: nowrap;
36
+
37
+ width: ${({ fullWidth }) => (fullWidth ? "100%" : "fit-content")};
38
+ height: ${({ theme, size }) => {
39
+ switch (size) {
40
+ case "xxs":
41
+ return `24px`;
42
+ case "xs":
43
+ return `28px`;
44
+ case "sm":
45
+ return `34px`;
46
+ case "md":
47
+ return `40px`;
48
+ case "lg":
49
+ return `48px`;
50
+ case "xl":
51
+ return `58px`;
52
+ default:
53
+ return `34px`;
54
+ }
55
+ }};
56
+
57
+ font-weight: 525;
58
+ letter-spacing: 0.75px;
59
+ font-size: ${({ theme, size }) => {
60
+ switch (size) {
61
+ case "xxs":
62
+ return `11px`;
63
+ case "xs":
64
+ return `12px`;
65
+ case "sm":
66
+ return `14px`;
67
+ case "md":
68
+ return `16px`;
69
+ case "lg":
70
+ return `18px`;
71
+ case "xl":
72
+ return `20px`;
73
+ default:
74
+ return `14px`;
75
+ }
76
+ }};
77
+
78
+ padding: ${({ theme, size, variant }) => {
79
+ if (variant === "text") return `0px 0px`;
80
+ switch (size) {
81
+ case "xxs":
82
+ return `0px 8px`;
83
+ case "xs":
84
+ return `0px 12px`;
85
+ case "sm":
86
+ return `0px 16px`;
87
+ case "md":
88
+ return `0px 20px`;
89
+ case "lg":
90
+ return `0px 24px`;
91
+ case "xl":
92
+ return `0px 30px`;
93
+ default:
94
+ return `0px 16px`;
95
+ }
96
+ }};
97
+
98
+ color: ${({ theme, variant, color }) => {
99
+ if (variant === "default") return theme.palette.text.primary;
100
+ if (variant === "contained") return "white";
101
+ if (variant === "filled") return "white";
102
+
103
+ switch (color) {
104
+ case "primary":
105
+ return theme.palette.primary.main;
106
+ case undefined:
107
+ return theme.palette.text.primary;
108
+ default:
109
+ return color
110
+ ? theme?.palette?.[color]?.main ||
111
+ colors[color as keyof typeof colors] ||
112
+ theme.palette.text.primary
113
+ : theme.palette.text.primary;
114
+ }
115
+ }};
116
+
117
+ background-color: ${({ theme, variant, color }) => {
118
+ if (variant === "default") return "transparent";
119
+ switch (variant) {
120
+ case "contained":
121
+ return color
122
+ ? theme?.palette?.[color]?.main ||
123
+ colors[color as keyof typeof colors] ||
124
+ theme.palette.background.secondary
125
+ : theme.palette.background.secondary;
126
+ case "filled":
127
+ return color
128
+ ? theme?.palette?.[color]?.main ||
129
+ colors[color as keyof typeof colors] ||
130
+ theme.palette.background.secondary
131
+ : theme.palette.background.secondary;
132
+ case "light":
133
+ return (
134
+ (color
135
+ ? theme?.palette?.[color]?.main ||
136
+ colors[color as keyof typeof colors] ||
137
+ theme.palette.background.secondary
138
+ : theme.palette.background.secondary) + "30"
139
+ );
140
+ case "outlined":
141
+ return "transparent";
142
+ case "text":
143
+ return "transparent";
144
+ default:
145
+ return "transparent";
146
+ }
147
+ }};
148
+
149
+ border-radius: 4px;
150
+ border: 1px solid
151
+ ${({ theme, variant, color }) => {
152
+ switch (variant) {
153
+ case "contained":
154
+ return "transparent";
155
+ case "filled":
156
+ return "transparent";
157
+ case "light":
158
+ return "transparent";
159
+ case "outlined":
160
+ return color
161
+ ? theme?.palette?.[color]?.main ||
162
+ colors[color as keyof typeof colors] ||
163
+ theme.palette.divider
164
+ : theme.palette.divider;
165
+ case "text":
166
+ return "transparent";
167
+ case "subtle":
168
+ return "transparent";
169
+ default:
170
+ return color
171
+ ? theme?.palette?.[color]?.main ||
172
+ colors[color as keyof typeof colors] ||
173
+ theme.palette.divider
174
+ : theme.palette.divider;
175
+ }
176
+ }};
177
+
178
+ cursor: pointer;
179
+
180
+ transition: background-color 0.2s, border 0.2s;
181
+
182
+ .inner-span {
183
+ display: flex;
184
+ align-items: center;
185
+ }
186
+
187
+ .button-label {
188
+ display: flex;
189
+ align-items: center;
190
+ }
191
+
192
+ [data-position="left"] {
193
+ margin-inline-end: 6px;
194
+ display: flex;
195
+ align-items: center;
196
+ }
197
+
198
+ [data-position="right"] {
199
+ margin-inline-start: 6px;
200
+ display: flex;
201
+ align-items: center;
202
+ }
203
+
204
+ &:hover {
205
+ background-color: ${({ theme, variant, color }) => {
206
+ if (variant === "default") return "transparent";
207
+ switch (variant) {
208
+ case "contained":
209
+ return (
210
+ (color
211
+ ? theme?.palette?.[color]?.main ||
212
+ colors[color as keyof typeof colors] ||
213
+ theme.palette.background.secondary
214
+ : theme.palette.background.secondary) + "90"
215
+ );
216
+ case "filled":
217
+ return (
218
+ (color
219
+ ? theme?.palette?.[color]?.main ||
220
+ colors[color as keyof typeof colors] ||
221
+ theme.palette.background.secondary
222
+ : theme.palette.background.secondary) + "90"
223
+ );
224
+ case "light":
225
+ return (
226
+ (color
227
+ ? theme?.palette?.[color]?.main ||
228
+ colors[color as keyof typeof colors] ||
229
+ theme.palette.background.secondary
230
+ : theme.palette.background.secondary) + "70"
231
+ );
232
+ case "outlined":
233
+ return theme.palette.action.hover;
234
+ case "text":
235
+ return "transparent";
236
+ case "subtle":
237
+ return color
238
+ ? (theme?.palette?.[color]?.main ||
239
+ colors[color as keyof typeof colors]) + "30" ||
240
+ theme.palette.action.hover
241
+ : theme.palette.action.hover;
242
+ default:
243
+ return theme.palette.action.hover;
244
+ }
245
+ }};
246
+
247
+ border: 1px solid
248
+ ${({ theme, variant, color }) => {
249
+ switch (variant) {
250
+ case "contained":
251
+ return "transparent";
252
+ case "filled":
253
+ return "transparent";
254
+ case "light":
255
+ return "transparent";
256
+ case "outlined":
257
+ return color
258
+ ? colors[color as keyof typeof colors] || theme.palette.divider
259
+ : theme.palette.divider;
260
+ case "text":
261
+ return "transparent";
262
+ case "subtle":
263
+ return "transparent";
264
+ default:
265
+ return color
266
+ ? theme?.palette?.[color]?.main ||
267
+ colors[color as keyof typeof colors] ||
268
+ theme.palette.divider
269
+ : theme.palette.divider;
270
+ }
271
+ }};
272
+ opacity: ${({ variant }) => (variant === "text" ? 0.8 : 1)};
273
+ }
274
+
275
+ opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};
276
+ pointer-events: ${({ disabled }) => (disabled ? "none" : "auto")};
277
+
278
+ &:focus {
279
+ text-decoration: underline;
280
+ }
281
+
282
+ &:active {
283
+ // simulate physical button press
284
+ translate: 0px 1px;
285
+ text-decoration: none;
286
+ }
287
+
288
+ // disabled styles
289
+ ${({ disabled }) =>
290
+ disabled &&
291
+ `
292
+ cursor: not-allowed;
293
+ opacity: 0.5;
294
+ pointer-events: none;
295
+ `}
296
+ `;
297
+
298
+ const StyledAnchor = styled.a`
299
+ text-decoration: none;
300
+ height: 100%;
301
+
302
+ &:hover {
303
+ text-decoration: none !important;
304
+ }
305
+ `;
306
+
307
+ const StyledLoader = styled.span`
308
+ svg {
309
+ width: 16px;
310
+ height: 16px;
311
+ color: ${({ theme, color }) =>
312
+ color
313
+ ? theme.palette[color] || colors[color as keyof typeof colors]
314
+ : theme.palette.primary};
315
+
316
+ animation: spin 0.75s linear infinite;
317
+
318
+ @keyframes spin {
319
+ 100% {
320
+ transform: rotate(360deg);
321
+ }
322
+ }
323
+ }
324
+ `;
325
+
326
+ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
327
+ children?: ReactNode | string;
328
+ className?: string;
329
+ loading?: boolean;
330
+ leftSection?: ReactNode;
331
+ rightSection?: ReactNode;
332
+ href?: string | null;
333
+ download?: string | null;
334
+ fullWidth?: boolean;
335
+ size?: Size;
336
+ variant?: Variant;
337
+ color?: string;
338
+ disabled?: boolean;
339
+ onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
340
+ }
341
+
342
+ const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
343
+ const {
344
+ children,
345
+ loading = false,
346
+ leftSection = null,
347
+ rightSection = null,
348
+ href = null,
349
+ download = null,
350
+ ...other
351
+ } = props;
352
+
353
+ const buttonContent = (
354
+ <span className="inner-span" style={{ height: "100%" }}>
355
+ {loading ? (
356
+ <StyledLoader>
357
+ <Loader2Icon />
358
+ </StyledLoader>
359
+ ) : (
360
+ <>
361
+ {leftSection && <span data-position="left">{leftSection}</span>}
362
+ <span className="button-label">{children}</span>
363
+ {rightSection && <span data-position="right">{rightSection}</span>}
364
+ </>
365
+ )}
366
+ </span>
367
+ );
368
+
369
+ return (
370
+ <StyledButton ref={ref} {...other}>
371
+ {href ? (
372
+ <StyledAnchor href={href} download={download}>
373
+ {buttonContent}
374
+ </StyledAnchor>
375
+ ) : (
376
+ buttonContent
377
+ )}
378
+ </StyledButton>
379
+ );
380
+ });
381
+
382
+ export default Button;
@@ -0,0 +1,2 @@
1
+ export { default } from "./Button";
2
+ export type { ButtonProps } from "./Button";