@monolith-forensics/monolith-ui 1.1.29 → 1.1.31
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/Button/Button.js +327 -0
- package/dist/Button/index.js +1 -0
- package/dist/Calendar/Calendar.js +204 -0
- package/dist/Calendar/CalendarStyles.js +164 -0
- package/dist/Calendar/calendarHelpers.js +169 -0
- package/dist/Calendar/index.js +1 -0
- package/dist/CheckBox/CheckBox.js +41 -0
- package/dist/CheckBox/index.js +1 -0
- package/dist/DateInput/DateInput.js +504 -0
- package/dist/DateInput/index.js +1 -0
- package/dist/DropDownMenu/DropDownMenu.js +208 -0
- package/dist/DropDownMenu/index.js +1 -0
- package/dist/Error/Error.js +33 -0
- package/dist/Error/index.js +1 -0
- package/dist/FieldLabel/FieldLabel.js +90 -0
- package/dist/FieldLabel/index.js +1 -0
- package/dist/FileInputField/FileInputField.js +112 -0
- package/dist/FileInputField/index.js +1 -0
- package/dist/Flyout/Flyout.js +106 -0
- package/dist/Flyout/FlyoutHeader.js +7 -0
- package/dist/Flyout/FlyoutTitle.js +8 -0
- package/dist/Flyout/index.js +3 -0
- package/dist/FormSection/FormSection.js +46 -0
- package/dist/FormSection/index.js +1 -0
- package/dist/Grid/Grid.js +13 -0
- package/dist/Grid/index.js +1 -0
- package/dist/IconButton/IconButton.js +25 -0
- package/dist/IconButton/index.js +1 -0
- package/dist/Input/Input.js +144 -0
- package/dist/Input/index.js +1 -0
- package/dist/Modal/Modal.js +105 -0
- package/dist/Modal/index.js +1 -0
- package/dist/MonolithUIProvider/GlobalStyle.js +51 -0
- package/dist/MonolithUIProvider/MonolithUIProvider.js +23 -0
- package/dist/MonolithUIProvider/index.js +3 -0
- package/dist/MonolithUIProvider/useMonolithUITheme.js +10 -0
- package/dist/Pill/Pill.js +147 -0
- package/dist/Pill/index.js +1 -0
- package/dist/SelectBox/SelectBox.js +471 -0
- package/dist/SelectBox/index.js +1 -0
- package/dist/Switch/Switch.js +129 -0
- package/dist/Switch/index.js +1 -0
- package/dist/Table/Table.js +707 -0
- package/dist/Table/index.js +2 -0
- package/dist/TagBox/TagBox.js +585 -0
- package/dist/TagBox/TagBoxStyles.js +107 -0
- package/dist/TagBox/index.js +1 -0
- package/dist/TextArea/TextArea.js +76 -0
- package/dist/TextArea/index.js +1 -0
- package/dist/TextAreaInput/TextAreaInput.js +9 -0
- package/dist/TextAreaInput/index.js +1 -0
- package/dist/TextInput/TextInput.js +26 -0
- package/dist/TextInput/index.js +1 -0
- package/dist/Tooltip/Tooltip.js +25 -0
- package/dist/Tooltip/index.js +1 -0
- package/dist/core/ArrowButton.js +43 -0
- package/dist/core/ClearButton.js +43 -0
- package/dist/core/StyledContent.js +42 -0
- package/dist/core/StyledFloatContainer.js +5 -0
- package/dist/core/Types/Size.js +1 -0
- package/dist/core/Types/Variant.js +1 -0
- package/dist/core/index.js +4 -0
- package/dist/index.js +26 -0
- package/dist/theme/index.js +9 -0
- package/dist/theme/typography.js +57 -0
- package/dist/theme/variants.js +270 -0
- package/package.json +1 -1
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FloatingFocusManager, FloatingPortal, flip, useFloating, } from "@floating-ui/react";
|
|
3
|
+
import { forwardRef, useEffect, useRef, useState, } from "react";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import { Button, Tooltip, CheckBox, Input } from "..";
|
|
6
|
+
import { useDebouncedCallback } from "use-debounce";
|
|
7
|
+
const StyledFloatContainer = styled.div `
|
|
8
|
+
z-index: 1500;
|
|
9
|
+
`;
|
|
10
|
+
const StyledInnerItemContainer = styled.div `
|
|
11
|
+
overflow-y: auto;
|
|
12
|
+
|
|
13
|
+
&[data-scroll-active="true"] {
|
|
14
|
+
padding-right: 5px;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
const SearchInput = forwardRef((props, ref) => _jsx(Input, Object.assign({ ref: ref, style: { marginBottom: 8 } }, props)));
|
|
18
|
+
const StyledItem = styled.div `
|
|
19
|
+
color: ${(props) => props.theme.palette.text.primary};
|
|
20
|
+
border-radius: 3px;
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: row;
|
|
23
|
+
gap: 5px;
|
|
24
|
+
align-items: center;
|
|
25
|
+
min-height: 25px;
|
|
26
|
+
padding: 7px 10px;
|
|
27
|
+
position: relative;
|
|
28
|
+
user-select: none;
|
|
29
|
+
outline: none;
|
|
30
|
+
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
text-overflow: ellipsis;
|
|
34
|
+
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
|
|
37
|
+
font-family: ${({ theme }) => theme.typography.fontFamily};
|
|
38
|
+
|
|
39
|
+
font-size: ${({ size }) => size === "xs"
|
|
40
|
+
? "11px"
|
|
41
|
+
: size === "sm"
|
|
42
|
+
? "13px"
|
|
43
|
+
: size === "md"
|
|
44
|
+
? "15px"
|
|
45
|
+
: size === "lg"
|
|
46
|
+
? "17px"
|
|
47
|
+
: size === "xl"
|
|
48
|
+
? "19px"
|
|
49
|
+
: "11px"};
|
|
50
|
+
|
|
51
|
+
padding: ${({ size }) => size === "xs"
|
|
52
|
+
? "2px 8px"
|
|
53
|
+
: size === "sm"
|
|
54
|
+
? "4px 10px"
|
|
55
|
+
: size === "md"
|
|
56
|
+
? "4px 12px"
|
|
57
|
+
: size === "lg"
|
|
58
|
+
? "5px 14px"
|
|
59
|
+
: size === "xl"
|
|
60
|
+
? "6px 16px"
|
|
61
|
+
: "2px 8px"};
|
|
62
|
+
|
|
63
|
+
&[data-disabled] {
|
|
64
|
+
color: ${(props) => props.theme.palette.text.secondary};
|
|
65
|
+
pointer-events: "none";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&:hover {
|
|
69
|
+
background-color: ${(props) => props.theme.palette.action.hover};
|
|
70
|
+
color: ${(props) => props.theme.palette.text.primary};
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
const StyledContent = styled.div `
|
|
74
|
+
position: relative;
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: column;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
overflow-y: hidden;
|
|
79
|
+
overflow-x: hidden;
|
|
80
|
+
|
|
81
|
+
max-height: ${({ maxDropdownHeight }) => Number.isInteger(maxDropdownHeight)
|
|
82
|
+
? `${maxDropdownHeight}px`
|
|
83
|
+
: maxDropdownHeight || "250px"};
|
|
84
|
+
|
|
85
|
+
background-color: ${(props) => props.theme.palette.background.default};
|
|
86
|
+
background-color: ${({ theme, variant }) => {
|
|
87
|
+
switch (variant) {
|
|
88
|
+
case "filled":
|
|
89
|
+
return theme.palette.input.background;
|
|
90
|
+
case "outlined":
|
|
91
|
+
return theme.palette.input.background;
|
|
92
|
+
case "text":
|
|
93
|
+
return "transparent";
|
|
94
|
+
default:
|
|
95
|
+
return theme.palette.input.background;
|
|
96
|
+
}
|
|
97
|
+
}};
|
|
98
|
+
|
|
99
|
+
border-radius: 5px;
|
|
100
|
+
border: 1px solid ${(props) => props.theme.palette.divider};
|
|
101
|
+
padding: 5px;
|
|
102
|
+
animation-duration: 400ms;
|
|
103
|
+
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
|
|
104
|
+
will-change: transform, opacity;
|
|
105
|
+
|
|
106
|
+
&[data-empty="true"] {
|
|
107
|
+
display: none;
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
110
|
+
const DropDownMenu = styled(({ className, children, data = [], variant = "outlined", defaultValue, multiselect = false, size = "xs", TooltipContent, renderOption, onChange, onItemSelect, onScroll, loading, arrow, searchable, dropDownProps, buttonProps, }) => {
|
|
111
|
+
var _a, _b, _c;
|
|
112
|
+
const isObjectArray = (_a = Object.keys((data === null || data === void 0 ? void 0 : data[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
|
|
113
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
114
|
+
const [selected, setSelected] = useState(defaultValue || []);
|
|
115
|
+
const [searchValue, setSearchValue] = useState("");
|
|
116
|
+
const scrollContainerRef = useRef(null);
|
|
117
|
+
const searchInputRef = useRef(null);
|
|
118
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
119
|
+
open: isOpen,
|
|
120
|
+
onOpenChange: setIsOpen,
|
|
121
|
+
placement: "bottom-start",
|
|
122
|
+
strategy: "absolute",
|
|
123
|
+
// Handle collisions with the viewport
|
|
124
|
+
middleware: [flip()],
|
|
125
|
+
});
|
|
126
|
+
const handleAddItem = (item) => {
|
|
127
|
+
setSelected((prev) => {
|
|
128
|
+
let newSelected = [...prev, item];
|
|
129
|
+
const diff = data.filter((i) => !newSelected.find((s) => isObjectArray ? (s === null || s === void 0 ? void 0 : s.value) === (i === null || i === void 0 ? void 0 : i.value) : s === i));
|
|
130
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newSelected, diff);
|
|
131
|
+
return newSelected;
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
const handleRemoveItem = (item) => {
|
|
135
|
+
setSelected((prev) => {
|
|
136
|
+
let newSelected = prev.filter((i) => isObjectArray ? (i === null || i === void 0 ? void 0 : i.value) !== (item === null || item === void 0 ? void 0 : item.value) : i !== item);
|
|
137
|
+
const diff = data.filter((i) => !newSelected.find((s) => isObjectArray ? (s === null || s === void 0 ? void 0 : s.value) === (i === null || i === void 0 ? void 0 : i.value) : s === i));
|
|
138
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newSelected, diff);
|
|
139
|
+
return newSelected;
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
const handleSearch = useDebouncedCallback((e) => {
|
|
143
|
+
setSearchValue(e.target.value);
|
|
144
|
+
}, 150);
|
|
145
|
+
// Close on outside click
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
const close = (e) => {
|
|
148
|
+
var _a, _b, _c, _d;
|
|
149
|
+
const target = e.target;
|
|
150
|
+
const referenceElement = (_a = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _a === void 0 ? void 0 : _a.current;
|
|
151
|
+
const floatingElement = (_b = refs === null || refs === void 0 ? void 0 : refs.floating) === null || _b === void 0 ? void 0 : _b.current;
|
|
152
|
+
if (floatingElement && // Check if the floating element exists
|
|
153
|
+
e.target !== referenceElement && // Check if the target is not the reference (input)
|
|
154
|
+
!((_c = referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.contains) === null || _c === void 0 ? void 0 : _c.call(referenceElement, target)) && // Check if the target is not inside the reference (input)
|
|
155
|
+
!((_d = floatingElement === null || floatingElement === void 0 ? void 0 : floatingElement.contains) === null || _d === void 0 ? void 0 : _d.call(floatingElement, target)) // Check if the target is not inside the floating element (content)
|
|
156
|
+
) {
|
|
157
|
+
setIsOpen(false);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
document.addEventListener("mousedown", close);
|
|
161
|
+
return () => document.removeEventListener("mousdown", close);
|
|
162
|
+
}, [refs.floating, refs.reference]);
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
var _a, _b;
|
|
165
|
+
if (isOpen && searchable) {
|
|
166
|
+
(_b = (_a = searchInputRef === null || searchInputRef === void 0 ? void 0 : searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
167
|
+
}
|
|
168
|
+
if (!isOpen) {
|
|
169
|
+
setSearchValue("");
|
|
170
|
+
}
|
|
171
|
+
}, [isOpen, searchable]);
|
|
172
|
+
const scrollActive = (((_b = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current) === null || _b === void 0 ? void 0 : _b.scrollHeight) || 0) >
|
|
173
|
+
(((_c = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight) || 0);
|
|
174
|
+
return (_jsxs("div", { className: className + " mfDropDownMenu", children: [_jsx(Button, Object.assign({ ref: (ref) => {
|
|
175
|
+
refs.setReference(ref);
|
|
176
|
+
}, onMouseDown: () => setIsOpen(!isOpen), rightSection: arrow ? _jsx("span", { children: "\u25BC" }) : null, size: size }, buttonProps, { children: children })), isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(FloatingFocusManager, { context: context, modal: false, children: _jsx(StyledFloatContainer, { ref: refs.setFloating, style: floatingStyles, className: "mfFloating", children: _jsx(StyledContent, Object.assign({ className: "mfFloatingContent", style: { width: 150, maxWidth: 400 }, variant: variant }, dropDownProps, { children: _jsxs(StyledInnerItemContainer, { ref: scrollContainerRef, "data-scroll-active": scrollActive, onScroll: onScroll, children: [loading && _jsx("div", { children: "Loading..." }), searchable && (_jsx(SearchInput, { ref: searchInputRef, variant: "outlined", placeholder: "Search", onChange: handleSearch })), !loading &&
|
|
177
|
+
data
|
|
178
|
+
.filter((item) => {
|
|
179
|
+
var _a, _b, _c;
|
|
180
|
+
if (!searchable)
|
|
181
|
+
return true;
|
|
182
|
+
if (isObjectArray) {
|
|
183
|
+
return (((_a = item === null || item === void 0 ? void 0 : item.label) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchValue.toLowerCase())) ||
|
|
184
|
+
((_b = item === null || item === void 0 ? void 0 : item.value) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchValue.toLowerCase())));
|
|
185
|
+
}
|
|
186
|
+
return (_c = item
|
|
187
|
+
.toLowerCase) === null || _c === void 0 ? void 0 : _c.call(item).includes(searchValue.toLowerCase());
|
|
188
|
+
})
|
|
189
|
+
.map((item, index) => {
|
|
190
|
+
const isSelected = !!(selected === null || selected === void 0 ? void 0 : selected.find((s) => isObjectArray
|
|
191
|
+
? (s === null || s === void 0 ? void 0 : s.value) === (item === null || item === void 0 ? void 0 : item.value)
|
|
192
|
+
: s === item));
|
|
193
|
+
return (_jsx(Tooltip, { content: TooltipContent ? (_jsx(TooltipContent, { data: item.data })) : null, side: "left", children: _jsxs(StyledItem, { className: "mfFloatingItem", onClick: (e) => {
|
|
194
|
+
e.preventDefault();
|
|
195
|
+
e.stopPropagation();
|
|
196
|
+
if (multiselect) {
|
|
197
|
+
isSelected
|
|
198
|
+
? handleRemoveItem(item)
|
|
199
|
+
: handleAddItem(item);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
setIsOpen(false);
|
|
203
|
+
}
|
|
204
|
+
onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(item);
|
|
205
|
+
}, "data-selected": isSelected, size: size, children: [multiselect && _jsx(CheckBox, { value: isSelected }), _jsx(_Fragment, { children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || (item === null || item === void 0 ? void 0 : item.label) || item })] }) }, index));
|
|
206
|
+
})] }) })) }) }) }))] }));
|
|
207
|
+
}) ``;
|
|
208
|
+
export default DropDownMenu;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./DropDownMenu";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { XIcon, ShieldAlert } from "lucide-react";
|
|
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
|
+
const CloseButton = styled.button `
|
|
17
|
+
background: none;
|
|
18
|
+
border: none;
|
|
19
|
+
color: ${({ theme }) => theme.palette.error.light};
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
`;
|
|
22
|
+
const ErrorText = styled.span `
|
|
23
|
+
margin-left: 10px;
|
|
24
|
+
flex: 1;
|
|
25
|
+
`;
|
|
26
|
+
const ErrorComponent = ({ error }) => {
|
|
27
|
+
const [isVisible, setIsVisible] = useState(true);
|
|
28
|
+
const handleClose = () => {
|
|
29
|
+
setIsVisible(false);
|
|
30
|
+
};
|
|
31
|
+
return (_jsx(_Fragment, { children: isVisible && (_jsxs(ErrorContainer, { children: [_jsx(ShieldAlert, { size: 19 }), _jsx(ErrorText, { children: error }), _jsx(CloseButton, { onClick: handleClose, children: _jsx(XIcon, { size: 19 }) })] })) }));
|
|
32
|
+
};
|
|
33
|
+
export default ErrorComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Error";
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import * as Tooltip from "@radix-ui/react-tooltip";
|
|
4
|
+
export const InfoComponent = styled(({ className, children, description, label }) => {
|
|
5
|
+
if (!description)
|
|
6
|
+
return children;
|
|
7
|
+
return (_jsx(Tooltip.Provider, { delayDuration: 800, skipDelayDuration: 0, disableHoverableContent: true, children: _jsxs(Tooltip.Root, { children: [_jsx(Tooltip.Trigger, { asChild: true, children: children }), _jsx(Tooltip.Portal, { children: _jsxs(Tooltip.Content, { className: className, side: "right", sideOffset: 15, align: "start", onClick: (e) => e.stopPropagation(), children: [_jsx("div", { className: "title", children: label || "Info" }), _jsx("div", { children: description || "N/A" })] }) })] }) }));
|
|
8
|
+
}) `
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
z-index: 999999;
|
|
11
|
+
background-color: ${({ theme }) => theme.palette.background.default};
|
|
12
|
+
padding: 15px;
|
|
13
|
+
border-radius: 5px;
|
|
14
|
+
border: 1px solid ${({ theme }) => theme.palette.divider};
|
|
15
|
+
font-size: 0.75rem;
|
|
16
|
+
max-width: 350px;
|
|
17
|
+
width: 250px;
|
|
18
|
+
|
|
19
|
+
white-space: pre-wrap;
|
|
20
|
+
|
|
21
|
+
.title {
|
|
22
|
+
font-size: 0.85rem;
|
|
23
|
+
font-weight: 600;
|
|
24
|
+
margin-bottom: 5px;
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
const FieldLabel = styled(({ className, children, error, description, size = "sm", }) => {
|
|
28
|
+
return (_jsxs("div", { className: className + " FieldLabel", children: [_jsx(InfoComponent, { description: description, label: children, children: _jsx("div", { className: "label", children: children }) }), error && (_jsx("div", { className: "error", title: error, children: error || "Invalid Value" }))] }));
|
|
29
|
+
}) `
|
|
30
|
+
user-select: none;
|
|
31
|
+
font-family: apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
32
|
+
"Helvetica Neue", Arial, sans-serif;
|
|
33
|
+
user-select: none;
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
align-items: baseline;
|
|
37
|
+
gap: 5px;
|
|
38
|
+
|
|
39
|
+
min-height: 15px;
|
|
40
|
+
font-weight: 400;
|
|
41
|
+
margin-bottom: 2.5px;
|
|
42
|
+
|
|
43
|
+
font-size: ${({ size = "sm" }) => size === "xs"
|
|
44
|
+
? "10px"
|
|
45
|
+
: size === "sm"
|
|
46
|
+
? "12px"
|
|
47
|
+
: size === "md"
|
|
48
|
+
? "14px"
|
|
49
|
+
: size === "lg"
|
|
50
|
+
? "16px"
|
|
51
|
+
: size === "xl"
|
|
52
|
+
? "18px"
|
|
53
|
+
: "12px"};
|
|
54
|
+
|
|
55
|
+
transition: all 0.2s ease;
|
|
56
|
+
color: ${({ theme, error }) => theme.palette.text.secondary};
|
|
57
|
+
|
|
58
|
+
.label {
|
|
59
|
+
width: fit-content;
|
|
60
|
+
min-width: fit-content;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.label::after {
|
|
64
|
+
content: ${(props) => (props.asterisk ? "'*'" : "")};
|
|
65
|
+
color: ${({ theme }) => theme.palette.error.main};
|
|
66
|
+
margin-left: 2px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.label:hover {
|
|
70
|
+
cursor: ${({ description }) => (description ? "pointer" : "default")};
|
|
71
|
+
color: ${({ description, theme }) => description ? theme.palette.text.primary : theme.palette.text.secondary};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.error {
|
|
75
|
+
user-select: none;
|
|
76
|
+
transition: all 0.2s ease;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
color: ${({ theme }) => theme.palette.error.main};
|
|
79
|
+
font-size: 10px;
|
|
80
|
+
max-width: 85%;
|
|
81
|
+
white-space: nowrap;
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
text-overflow: ellipsis;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.error:hover {
|
|
87
|
+
color: ${({ theme }) => theme.palette.error.light};
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
export default FieldLabel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./FieldLabel";
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { useDropzone } from "react-dropzone";
|
|
5
|
+
import { Pill, FieldLabel } from "..";
|
|
6
|
+
const FileInputField = styled(({ className, children, label, error, required, size, onChange, onFocus, dropZoneOptions = {}, colSpan, style = {}, }) => {
|
|
7
|
+
const [files, setFiles] = useState([]);
|
|
8
|
+
const onDrop = useCallback((acceptedFiles) => {
|
|
9
|
+
setFiles(acceptedFiles);
|
|
10
|
+
// Do something with the files
|
|
11
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(acceptedFiles);
|
|
12
|
+
}, []);
|
|
13
|
+
const handleRemoveFile = (file) => {
|
|
14
|
+
setFiles((prev) => prev.filter((f) => f !== file));
|
|
15
|
+
};
|
|
16
|
+
const { getRootProps, getInputProps } = useDropzone(Object.assign({ onDrop }, dropZoneOptions));
|
|
17
|
+
return (_jsxs("div", { className: className, children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, children: label })), _jsxs("div", Object.assign({ className: "file-input-container" }, getRootProps(), { onFocus: onFocus, style: style, children: [_jsx("input", Object.assign({}, getInputProps())), children && children, !children && _jsx("div", { children: "Drop files here or click to select files ..." })] })), _jsx("div", { className: "file-selections", children: files.map((file, index) => (_jsx(Pill, { size: "sm", showRemoveIcon: true, onRemove: () => handleRemoveFile(file), children: file.name }, index))) })] }));
|
|
18
|
+
}) `
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
grid-column: span ${({ colSpan }) => colSpan || 1};
|
|
22
|
+
|
|
23
|
+
.file-input-container {
|
|
24
|
+
user-select: none;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
outline: none;
|
|
27
|
+
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
height: 75px;
|
|
33
|
+
|
|
34
|
+
color: ${({ theme }) => theme.palette.text.secondary};
|
|
35
|
+
|
|
36
|
+
font-size: ${({ size }) => size === "xs"
|
|
37
|
+
? "12px"
|
|
38
|
+
: size === "sm"
|
|
39
|
+
? "14px"
|
|
40
|
+
: size === "md"
|
|
41
|
+
? "16px"
|
|
42
|
+
: size === "lg"
|
|
43
|
+
? "18px"
|
|
44
|
+
: size === "xl"
|
|
45
|
+
? "20px"
|
|
46
|
+
: "12px"};
|
|
47
|
+
|
|
48
|
+
background-color: ${({ theme, variant }) => {
|
|
49
|
+
switch (variant) {
|
|
50
|
+
case "contained":
|
|
51
|
+
return theme.palette.input.background;
|
|
52
|
+
case "filled":
|
|
53
|
+
return theme.palette.input.background;
|
|
54
|
+
case "outlined":
|
|
55
|
+
return theme.palette.input.background;
|
|
56
|
+
case "text":
|
|
57
|
+
return "transparent";
|
|
58
|
+
default:
|
|
59
|
+
return theme.palette.input.background;
|
|
60
|
+
}
|
|
61
|
+
}};
|
|
62
|
+
|
|
63
|
+
border-radius: 4px;
|
|
64
|
+
border: 1px solid
|
|
65
|
+
${({ theme, variant }) => {
|
|
66
|
+
switch (variant) {
|
|
67
|
+
case "contained":
|
|
68
|
+
return "transparent";
|
|
69
|
+
case "filled":
|
|
70
|
+
return "transparent";
|
|
71
|
+
case "outlined":
|
|
72
|
+
return theme.palette.input.border;
|
|
73
|
+
case "text":
|
|
74
|
+
return "transparent";
|
|
75
|
+
default:
|
|
76
|
+
return theme.palette.input.border;
|
|
77
|
+
}
|
|
78
|
+
}};
|
|
79
|
+
|
|
80
|
+
padding: ${({ size }) => size === "xs"
|
|
81
|
+
? "0px 8px"
|
|
82
|
+
: size === "sm"
|
|
83
|
+
? "0px 10px"
|
|
84
|
+
: size === "md"
|
|
85
|
+
? "0px 12px"
|
|
86
|
+
: size === "lg"
|
|
87
|
+
? "0px 14px"
|
|
88
|
+
: size === "xl"
|
|
89
|
+
? "0px 16px"
|
|
90
|
+
: "0px 8px"};
|
|
91
|
+
|
|
92
|
+
max-width: 100%;
|
|
93
|
+
|
|
94
|
+
transition: border 0.2s;
|
|
95
|
+
|
|
96
|
+
&:hover {
|
|
97
|
+
border: 1px solid ${({ theme }) => theme.palette.primary.main};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&:focus {
|
|
101
|
+
border: 1px solid ${({ theme }) => theme.palette.primary.main};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.file-selections {
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-wrap: wrap;
|
|
108
|
+
gap: 10px;
|
|
109
|
+
margin-top: 10px;
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
112
|
+
export default FileInputField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./FileInputField";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useFloating, } from "@floating-ui/react";
|
|
3
|
+
import { XIcon } from "lucide-react";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
const ANIMATION_TIME = 300;
|
|
6
|
+
const StyledOverlay = styled(FloatingOverlay) `
|
|
7
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
8
|
+
position: fixed;
|
|
9
|
+
inset: 0;
|
|
10
|
+
z-index: 1400;
|
|
11
|
+
|
|
12
|
+
@keyframes overlayShow {
|
|
13
|
+
from {
|
|
14
|
+
opacity: 0;
|
|
15
|
+
}
|
|
16
|
+
to {
|
|
17
|
+
opacity: 1;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
const StyledClose = styled.div `
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 20px;
|
|
24
|
+
right: 20px;
|
|
25
|
+
|
|
26
|
+
color: ${(props) => props.theme.palette.text.secondary};
|
|
27
|
+
`;
|
|
28
|
+
const StyledButton = styled.button `
|
|
29
|
+
background-color: transparent;
|
|
30
|
+
border: none;
|
|
31
|
+
outline: none;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
padding: 0;
|
|
34
|
+
|
|
35
|
+
color: ${(props) => props.theme.palette.text.primary};
|
|
36
|
+
|
|
37
|
+
&:hover {
|
|
38
|
+
background-color: ${(props) => props.theme.palette.action.hover};
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
const StyledContent = styled.div `
|
|
42
|
+
background-color: ${({ theme }) => theme.name === "DARK"
|
|
43
|
+
? theme.palette.background.alt
|
|
44
|
+
: theme.palette.background.default};
|
|
45
|
+
border-radius: 6px;
|
|
46
|
+
border: 1px solid ${(props) => props.theme.palette.divider};
|
|
47
|
+
position: fixed;
|
|
48
|
+
margin: 10px;
|
|
49
|
+
|
|
50
|
+
top: 0px;
|
|
51
|
+
right: 0px;
|
|
52
|
+
width: 50vw;
|
|
53
|
+
height: calc(100vh - 20px);
|
|
54
|
+
|
|
55
|
+
box-shadow: rgba(0, 0, 0, 0.5) 0px 16px 70px;
|
|
56
|
+
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
flex: 1 1 auto;
|
|
60
|
+
|
|
61
|
+
overflow-y: hidden;
|
|
62
|
+
|
|
63
|
+
&:focus {
|
|
64
|
+
outline: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
animation: contentShow ${ANIMATION_TIME}ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
68
|
+
|
|
69
|
+
// slide in from right to left
|
|
70
|
+
@keyframes contentShow {
|
|
71
|
+
from {
|
|
72
|
+
transform: translate(100%, 0);
|
|
73
|
+
}
|
|
74
|
+
to {
|
|
75
|
+
transform: translate(0, 0);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
79
|
+
const StyledInnerContent = styled.div `
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
flex: 1 1 auto;
|
|
83
|
+
|
|
84
|
+
overflow-y: auto;
|
|
85
|
+
padding: 25px;
|
|
86
|
+
`;
|
|
87
|
+
const Flyout = ({ children, open = false, onClose = () => { }, style = {}, closeOnOutsideClick = true, showCloseButton = true, }) => {
|
|
88
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
89
|
+
open,
|
|
90
|
+
onOpenChange: (isOpen) => {
|
|
91
|
+
if (!isOpen) {
|
|
92
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
const handleMouseDown = (event) => {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
const target = event.target;
|
|
99
|
+
if (((_b = (_a = target === null || target === void 0 ? void 0 : target.className) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, "mf-ModalOverlay")) &&
|
|
100
|
+
closeOnOutsideClick) {
|
|
101
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return (_jsx(FloatingPortal, { preserveTabOrder: true, children: open && (_jsx(StyledOverlay, { className: "mf-ModalOverlay", lockScroll: true, onMouseDown: handleMouseDown, children: _jsx(FloatingFocusManager, { context: context, modal: true, children: _jsxs(StyledContent, Object.assign({ style: style, className: `mf-Modal mf-Flyout`, ref: refs.setFloating }, floatingStyles, { translate: undefined, children: [showCloseButton && (_jsx(StyledClose, { children: _jsx(StyledButton, { onMouseDown: () => onClose === null || onClose === void 0 ? void 0 : onClose(), children: _jsx(XIcon, { size: 18 }) }) })), _jsx(StyledInnerContent, { className: "mf-Flyout inner-content", children: children })] })) }) })) }));
|
|
105
|
+
};
|
|
106
|
+
export default Flyout;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDownIcon } from "lucide-react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
const FormSection = styled(({ className, title, children, defaultOpen = true }) => {
|
|
6
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
7
|
+
return (_jsxs("div", { className: className, children: [_jsxs("div", { className: "section-header", onClick: (e) => setOpen((prev) => !prev), children: [_jsx("h3", { children: title }), _jsx("div", { className: "section-line" }), _jsx(ChevronDownIcon, { size: 18, className: open ? "open" : "" })] }), _jsx("div", { className: "section-content", "data-open": open, children: children })] }));
|
|
8
|
+
}) `
|
|
9
|
+
h3 {
|
|
10
|
+
margin: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.section-header {
|
|
14
|
+
user-select: none;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
margin-bottom: 10px;
|
|
17
|
+
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: row;
|
|
20
|
+
gap: 10px;
|
|
21
|
+
align-items: center;
|
|
22
|
+
|
|
23
|
+
.section-line {
|
|
24
|
+
flex: 1;
|
|
25
|
+
height: 1px;
|
|
26
|
+
background-color: ${({ theme }) => theme.palette.divider};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
svg {
|
|
30
|
+
transition: transform 0.2s;
|
|
31
|
+
color: ${({ theme }) => theme.palette.text.secondary};
|
|
32
|
+
|
|
33
|
+
&.open {
|
|
34
|
+
transform: rotate(180deg);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.section-content {
|
|
40
|
+
padding: 10px 0px;
|
|
41
|
+
&[data-open="false"] {
|
|
42
|
+
display: none;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
export default FormSection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./FormSection";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
const Grid = styled(({ className, children }) => {
|
|
4
|
+
return _jsx("div", { className: className, children: children });
|
|
5
|
+
}) `
|
|
6
|
+
display: grid;
|
|
7
|
+
grid-template-columns: repeat(${({ col }) => col || 1}, minmax(0, 1fr));
|
|
8
|
+
gap: 20px;
|
|
9
|
+
|
|
10
|
+
width: ${({ width }) => Number.isInteger(width) ? `${width}px` : width || "100%"};
|
|
11
|
+
height: auto;
|
|
12
|
+
`;
|
|
13
|
+
export default Grid;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Grid";
|