@monolith-forensics/monolith-ui 1.3.116-dev.0 → 1.3.116-dev.1
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.
- package/dist/Alert/Alert.d.ts +3 -0
- package/dist/Alert/Alert.js +50 -9
- package/package.json +1 -1
package/dist/Alert/Alert.d.ts
CHANGED
package/dist/Alert/Alert.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AlertCircleIcon, AlertTriangleIcon, CheckIcon, InfoIcon, } from "lucide-react";
|
|
2
|
+
import { AlertCircleIcon, AlertTriangleIcon, CheckIcon, InfoIcon, XIcon, } from "lucide-react";
|
|
3
3
|
import styled from "styled-components";
|
|
4
|
+
import { useControlled } from "../Utilities";
|
|
4
5
|
const Icons = {
|
|
5
6
|
info: _jsx(InfoIcon, { size: 20 }),
|
|
6
7
|
success: _jsx(CheckIcon, { size: 20 }),
|
|
@@ -9,14 +10,15 @@ const Icons = {
|
|
|
9
10
|
default: _jsx(InfoIcon, { size: 20 }),
|
|
10
11
|
};
|
|
11
12
|
const StyledContainer = styled.div `
|
|
13
|
+
position: relative;
|
|
12
14
|
display: flex;
|
|
13
15
|
gap: 10px;
|
|
14
|
-
padding: 15px;
|
|
16
|
+
padding: 15px 40px 15px 15px;
|
|
15
17
|
border-radius: 4px;
|
|
16
18
|
|
|
17
|
-
border: 1px solid ${({ theme, variant }) => theme.alert[variant].border};
|
|
18
|
-
background-color: ${({ theme, variant }) => theme.alert[variant].background};
|
|
19
|
-
color: ${({ theme, variant }) => theme.alert[variant].color};
|
|
19
|
+
border: 1px solid ${({ theme, $variant }) => theme.alert[$variant].border};
|
|
20
|
+
background-color: ${({ theme, $variant }) => theme.alert[$variant].background};
|
|
21
|
+
color: ${({ theme, $variant }) => theme.alert[$variant].color};
|
|
20
22
|
`;
|
|
21
23
|
const StyledTitle = styled.div `
|
|
22
24
|
height: 25px;
|
|
@@ -26,7 +28,7 @@ const StyledTitle = styled.div `
|
|
|
26
28
|
font-weight: bold;
|
|
27
29
|
margin: 0px;
|
|
28
30
|
|
|
29
|
-
color: ${({ theme, variant }) => { var _a; return (_a = theme.alert[variant]) === null || _a === void 0 ? void 0 : _a.color; }};
|
|
31
|
+
color: ${({ theme, $variant }) => { var _a; return (_a = theme.alert[$variant]) === null || _a === void 0 ? void 0 : _a.color; }};
|
|
30
32
|
`;
|
|
31
33
|
const StyledContent = styled.div `
|
|
32
34
|
display: flex;
|
|
@@ -34,10 +36,11 @@ const StyledContent = styled.div `
|
|
|
34
36
|
font-weight: 400;
|
|
35
37
|
margin: 0px;
|
|
36
38
|
|
|
37
|
-
color: ${({ theme
|
|
39
|
+
color: ${({ theme }) => theme.palette.text.primary};
|
|
38
40
|
`;
|
|
39
41
|
const StyledContentContainer = styled.div `
|
|
40
42
|
display: flex;
|
|
43
|
+
flex: 1;
|
|
41
44
|
flex-direction: column;
|
|
42
45
|
gap: 5px;
|
|
43
46
|
`;
|
|
@@ -47,6 +50,44 @@ const StyledHeader = styled.div `
|
|
|
47
50
|
height: 28px;
|
|
48
51
|
align-items: center;
|
|
49
52
|
`;
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
const StyledCloseButton = styled.button `
|
|
54
|
+
position: absolute;
|
|
55
|
+
top: 10px;
|
|
56
|
+
right: 10px;
|
|
57
|
+
border: none;
|
|
58
|
+
background: transparent;
|
|
59
|
+
display: inline-flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
padding: 0;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
color: ${({ theme, $variant }) => theme.alert[$variant].color};
|
|
65
|
+
`;
|
|
66
|
+
const StyledCloseIconWrapper = styled.div `
|
|
67
|
+
display: inline-flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
padding: 4px;
|
|
71
|
+
border-radius: 8px;
|
|
72
|
+
background-color: transparent;
|
|
73
|
+
transition:
|
|
74
|
+
background-color 0.15s ease,
|
|
75
|
+
opacity 0.15s ease;
|
|
76
|
+
|
|
77
|
+
${StyledCloseButton}:hover & {
|
|
78
|
+
${({ $variant, theme }) => $variant === "default"
|
|
79
|
+
? `background-color: ${theme.palette.action.hover};`
|
|
80
|
+
: `background-color: ${theme.alert[$variant].background};`}
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
export const Alert = ({ children, variant = "info", title, open, defaultOpen = true, showCloseButton = false, onClose, }) => {
|
|
84
|
+
const [isVisible, setIsVisible] = useControlled(open, defaultOpen);
|
|
85
|
+
if (!isVisible) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const handleClose = () => {
|
|
89
|
+
setIsVisible(false);
|
|
90
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
91
|
+
};
|
|
92
|
+
return (_jsxs(StyledContainer, { "$variant": variant, children: [_jsx(StyledHeader, { children: Icons[variant] }), _jsxs(StyledContentContainer, { children: [title && _jsx(StyledTitle, { "$variant": variant, children: title }), _jsx(StyledContent, { "$variant": variant, children: children })] }), showCloseButton && (_jsx(StyledCloseButton, { type: "button", "$variant": variant, "aria-label": "Close alert", onClick: handleClose, children: _jsx(StyledCloseIconWrapper, { "$variant": variant, children: _jsx(XIcon, { size: 16 }) }) }))] }));
|
|
52
93
|
};
|