@monolith-forensics/monolith-ui 1.1.21 → 1.1.23
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/CheckBox/CheckBox.d.ts +3 -1
- package/dist/CheckBox/CheckBox.js +18 -3
- package/dist/DateInput/DateInput.d.ts +1 -1
- package/dist/DateInput/DateInput.js +2 -2
- package/dist/FieldLabel/FieldLabel.js +2 -2
- package/dist/FileInputField/FileInputField.d.ts +2 -1
- package/dist/FileInputField/FileInputField.js +2 -1
- package/dist/Grid/Grid.d.ts +3 -1
- package/dist/Grid/Grid.js +4 -1
- package/dist/Input/Input.js +5 -5
- package/dist/MonolithUIProvider/GlobalStyle.d.ts +4 -0
- package/dist/MonolithUIProvider/GlobalStyle.js +53 -0
- package/dist/MonolithUIProvider/MonolithUIProvider.js +2 -1
- package/dist/Pill/Pill.js +8 -2
- package/dist/SelectBox/SelectBox.d.ts +1 -1
- package/dist/SelectBox/SelectBox.js +15 -7
- package/dist/TagBox/TagBox.d.ts +4 -3
- package/dist/TagBox/TagBox.js +171 -35
- package/dist/TextArea/TextArea.js +2 -2
- package/dist/TextAreaInput/TextAreaInput.d.ts +1 -1
- package/dist/TextAreaInput/TextAreaInput.js +1 -1
- package/dist/TextInput/TextInput.d.ts +2 -1
- package/dist/TextInput/TextInput.js +11 -10
- package/dist/theme/variants.js +2 -2
- package/package.json +4 -3
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
|
+
import { Size } from "../core";
|
|
2
3
|
interface CheckBoxProps {
|
|
3
4
|
className?: string;
|
|
5
|
+
size?: Size;
|
|
4
6
|
defaultValue?: boolean;
|
|
5
|
-
value?: boolean;
|
|
7
|
+
value?: boolean | undefined;
|
|
6
8
|
partialCheck?: boolean;
|
|
7
9
|
onChange?: (value: boolean) => void;
|
|
8
10
|
style?: CSSProperties;
|
|
@@ -7,7 +7,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
7
7
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const fa_1 = require("react-icons/fa");
|
|
10
|
-
const CheckBox = (0, styled_components_1.default)(({ className, defaultValue = false, value
|
|
10
|
+
const CheckBox = (0, styled_components_1.default)(({ className, defaultValue = false, value, partialCheck = false, onChange = () => { }, }) => {
|
|
11
|
+
console.log("defaultValue", defaultValue);
|
|
11
12
|
const [checkedState, setCheckedState] = (0, react_1.useState)(defaultValue);
|
|
12
13
|
const handleChange = (e) => {
|
|
13
14
|
e.stopPropagation();
|
|
@@ -15,7 +16,8 @@ const CheckBox = (0, styled_components_1.default)(({ className, defaultValue = f
|
|
|
15
16
|
onChange(!checkedState);
|
|
16
17
|
};
|
|
17
18
|
(0, react_1.useEffect)(() => {
|
|
18
|
-
|
|
19
|
+
if (value !== undefined)
|
|
20
|
+
setCheckedState(value);
|
|
19
21
|
}, [value]);
|
|
20
22
|
const _checked = value === undefined ? checkedState : value;
|
|
21
23
|
return ((0, jsx_runtime_1.jsx)("div", { className: className, onClick: handleChange, children: partialCheck === true ? ((0, jsx_runtime_1.jsx)(fa_1.FaRegMinusSquare, { className: "checkbox partial" })) : _checked === true ? ((0, jsx_runtime_1.jsx)(fa_1.FaCheckSquare, { className: "checkbox checked" })) : ((0, jsx_runtime_1.jsx)(fa_1.FaRegSquare, { className: "checkbox unchecked" })) }));
|
|
@@ -26,7 +28,20 @@ const CheckBox = (0, styled_components_1.default)(({ className, defaultValue = f
|
|
|
26
28
|
|
|
27
29
|
.checkbox {
|
|
28
30
|
color: ${(props) => props.theme.palette.primary.main};
|
|
29
|
-
font-size:
|
|
31
|
+
font-size: ${({ size }) => {
|
|
32
|
+
switch (size) {
|
|
33
|
+
case "xs":
|
|
34
|
+
return "12px";
|
|
35
|
+
case "sm":
|
|
36
|
+
return "16px";
|
|
37
|
+
case "md":
|
|
38
|
+
return "24px";
|
|
39
|
+
case "lg":
|
|
40
|
+
return "32px";
|
|
41
|
+
default:
|
|
42
|
+
return "16px";
|
|
43
|
+
}
|
|
44
|
+
}};
|
|
30
45
|
}
|
|
31
46
|
`;
|
|
32
47
|
exports.default = CheckBox;
|
|
@@ -233,7 +233,7 @@ function parseTimestamp(timestamp, format, utc = false) {
|
|
|
233
233
|
});
|
|
234
234
|
return segments;
|
|
235
235
|
}
|
|
236
|
-
const DateInput = (0, styled_components_1.default)(({ className, defaultValue
|
|
236
|
+
const DateInput = (0, styled_components_1.default)(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:ss", label, description, arrow = true, size = "sm", variant = "outlined", clearable = false, required = false, onChange = () => { }, min, max, error, enableCalendar = false, utc = false, closeOnSelect = true, }) => {
|
|
237
237
|
const [value, setValue] = (0, react_2.useState)(defaultValue);
|
|
238
238
|
const [selectedSegment, setSelectedSegment] = (0, react_2.useState)();
|
|
239
239
|
const [isOpen, setIsOpen] = (0, react_2.useState)(false);
|
|
@@ -489,7 +489,7 @@ const DateInput = (0, styled_components_1.default)(({ className, defaultValue =
|
|
|
489
489
|
}, onFocus: (e) => e.preventDefault(), onPointerDown: (e) => e.preventDefault(), "data-type": "separator", "data-identifier": segment.type, "data-has-space": segment.text.includes(" "), "data-placeholder": segment.placeholder, "data-value": segment.value, children: segment.text }, i));
|
|
490
490
|
}
|
|
491
491
|
return ((0, jsx_runtime_1.jsx)(InputSegment, { className: "input", contentEditable: true, suppressContentEditableWarning: true, tabIndex: i === 0 ? 0 : -1, onClick: (e) => handleSegmentClick(e, segment), "data-type": "input", size: size, "data-identifier": segment.type, "data-has-space": segment.text.includes(" "), "data-placeholder": segment.placeholder, "data-value": segment.value, "data-selected": (selectedSegment === null || selectedSegment === void 0 ? void 0 : selectedSegment.index) === segment.index, children: value ? segment.text : segment.placeholder }, i));
|
|
492
|
-
}), utc && (0, jsx_runtime_1.jsx)("div", { style: { marginLeft: 5 }, children: "UTC" }), clearable && value ? ((0, jsx_runtime_1.jsx)(core_1.ClearButton, { onClick: handleClear })) : arrow ? ((0, jsx_runtime_1.jsx)(core_1.ArrowButton, {})) : null] }), enableCalendar && isOpen && ((0, jsx_runtime_1.jsx)(react_1.FloatingPortal, { preserveTabOrder: true, children: (0, jsx_runtime_1.jsx)(core_1.StyledFloatContainer, { ref: refs.setFloating, style: floatingStyles, children: (0, jsx_runtime_1.jsx)(core_1.StyledContent, { maxDropdownHeight: "fit-content", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(__1.Calendar, { value: (0, moment_1.default)(value).toDate(), clearable: false, min: min, max: max,
|
|
492
|
+
}), utc && (0, jsx_runtime_1.jsx)("div", { style: { marginLeft: 5 }, children: "UTC" }), clearable && value ? ((0, jsx_runtime_1.jsx)(core_1.ClearButton, { onClick: handleClear })) : arrow ? ((0, jsx_runtime_1.jsx)(core_1.ArrowButton, {})) : null] }), enableCalendar && isOpen && ((0, jsx_runtime_1.jsx)(react_1.FloatingPortal, { preserveTabOrder: true, children: (0, jsx_runtime_1.jsx)(core_1.StyledFloatContainer, { ref: refs.setFloating, style: floatingStyles, children: (0, jsx_runtime_1.jsx)(core_1.StyledContent, { maxDropdownHeight: "fit-content", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(__1.Calendar, { value: value ? (0, moment_1.default)(value).toDate() : undefined, clearable: false, min: min, max: max,
|
|
493
493
|
// hourFormat={hourFormat}
|
|
494
494
|
onChange: (date) => {
|
|
495
495
|
setValue((prev) => {
|
|
@@ -69,7 +69,7 @@ const FieldLabel = (0, styled_components_1.default)(({ className, children, erro
|
|
|
69
69
|
font-weight: 400;
|
|
70
70
|
margin-bottom: 2.5px;
|
|
71
71
|
|
|
72
|
-
font-size: ${({ size }) => size === "xs"
|
|
72
|
+
font-size: ${({ size = "sm" }) => size === "xs"
|
|
73
73
|
? "10px"
|
|
74
74
|
: size === "sm"
|
|
75
75
|
? "12px"
|
|
@@ -79,7 +79,7 @@ const FieldLabel = (0, styled_components_1.default)(({ className, children, erro
|
|
|
79
79
|
? "16px"
|
|
80
80
|
: size === "xl"
|
|
81
81
|
? "18px"
|
|
82
|
-
: "
|
|
82
|
+
: "12px"};
|
|
83
83
|
|
|
84
84
|
transition: all 0.2s ease;
|
|
85
85
|
color: ${({ theme, error }) => theme.palette.text.secondary};
|
|
@@ -12,7 +12,8 @@ interface FileInputFieldProps {
|
|
|
12
12
|
onChange?: (files: File[]) => void;
|
|
13
13
|
onFocus?: () => void;
|
|
14
14
|
dropZoneOptions?: DropzoneOptions;
|
|
15
|
+
colSpan?: number;
|
|
15
16
|
style?: HTMLAttributes<HTMLDivElement>;
|
|
16
17
|
}
|
|
17
|
-
declare const FileInputField: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<FileInputFieldProps, never>> & string & Omit<({ className, children, label, error, required, size, onChange, onFocus, dropZoneOptions, style, }: FileInputFieldProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
|
18
|
+
declare const FileInputField: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<FileInputFieldProps, never>> & string & Omit<({ className, children, label, error, required, size, onChange, onFocus, dropZoneOptions, colSpan, style, }: FileInputFieldProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
|
18
19
|
export default FileInputField;
|
|
@@ -8,7 +8,7 @@ const react_1 = require("react");
|
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
9
|
const react_dropzone_1 = require("react-dropzone");
|
|
10
10
|
const __1 = require("..");
|
|
11
|
-
const FileInputField = (0, styled_components_1.default)(({ className, children, label, error, required, size, onChange, onFocus, dropZoneOptions = {}, style = {}, }) => {
|
|
11
|
+
const FileInputField = (0, styled_components_1.default)(({ className, children, label, error, required, size, onChange, onFocus, dropZoneOptions = {}, colSpan, style = {}, }) => {
|
|
12
12
|
const [files, setFiles] = (0, react_1.useState)([]);
|
|
13
13
|
const onDrop = (0, react_1.useCallback)((acceptedFiles) => {
|
|
14
14
|
setFiles(acceptedFiles);
|
|
@@ -23,6 +23,7 @@ const FileInputField = (0, styled_components_1.default)(({ className, children,
|
|
|
23
23
|
}) `
|
|
24
24
|
display: flex;
|
|
25
25
|
flex-direction: column;
|
|
26
|
+
grid-column: span ${({ colSpan }) => colSpan || 1};
|
|
26
27
|
|
|
27
28
|
.file-input-container {
|
|
28
29
|
user-select: none;
|
package/dist/Grid/Grid.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
interface GridProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
children: React.ReactNode;
|
|
2
4
|
col?: number;
|
|
3
5
|
width?: string | number;
|
|
4
6
|
}
|
|
5
|
-
declare const Grid: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components
|
|
7
|
+
declare const Grid: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<GridProps, never>> & string & Omit<({ className, children }: GridProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
|
6
8
|
export default Grid;
|
package/dist/Grid/Grid.js
CHANGED
|
@@ -3,8 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
7
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
7
|
-
const Grid = styled_components_1.default
|
|
8
|
+
const Grid = (0, styled_components_1.default)(({ className, children }) => {
|
|
9
|
+
return (0, jsx_runtime_1.jsx)("div", { className: className, children: children });
|
|
10
|
+
}) `
|
|
8
11
|
display: grid;
|
|
9
12
|
grid-template-columns: repeat(${({ col }) => col || 1}, minmax(0, 1fr));
|
|
10
13
|
gap: 20px;
|
package/dist/Input/Input.js
CHANGED
|
@@ -38,7 +38,7 @@ const Input = (0, styled_components_1.default)((0, react_1.forwardRef)((_a, ref)
|
|
|
38
38
|
? "17px"
|
|
39
39
|
: size === "xl"
|
|
40
40
|
? "19px"
|
|
41
|
-
: "
|
|
41
|
+
: "13px"};
|
|
42
42
|
|
|
43
43
|
height: ${({ size }) => size === "xs"
|
|
44
44
|
? "26px"
|
|
@@ -50,7 +50,7 @@ const Input = (0, styled_components_1.default)((0, react_1.forwardRef)((_a, ref)
|
|
|
50
50
|
? "42px"
|
|
51
51
|
: size === "xl"
|
|
52
52
|
? "50px"
|
|
53
|
-
: "
|
|
53
|
+
: "30px"};
|
|
54
54
|
|
|
55
55
|
min-height: ${({ size }) => size === "xs"
|
|
56
56
|
? "26px"
|
|
@@ -62,7 +62,7 @@ const Input = (0, styled_components_1.default)((0, react_1.forwardRef)((_a, ref)
|
|
|
62
62
|
? "42px"
|
|
63
63
|
: size === "xl"
|
|
64
64
|
? "50px"
|
|
65
|
-
: "
|
|
65
|
+
: "30px"};
|
|
66
66
|
|
|
67
67
|
transition: border 0.1s ease-in-out;
|
|
68
68
|
border-radius: 4px;
|
|
@@ -92,7 +92,7 @@ const Input = (0, styled_components_1.default)((0, react_1.forwardRef)((_a, ref)
|
|
|
92
92
|
? "0px 14px"
|
|
93
93
|
: size === "xl"
|
|
94
94
|
? "0px 16px"
|
|
95
|
-
: "0px
|
|
95
|
+
: "0px 10px"};
|
|
96
96
|
|
|
97
97
|
width: ${({ width }) => {
|
|
98
98
|
if (typeof width === "undefined")
|
|
@@ -131,7 +131,7 @@ const Input = (0, styled_components_1.default)((0, react_1.forwardRef)((_a, ref)
|
|
|
131
131
|
? "16px"
|
|
132
132
|
: size === "xl"
|
|
133
133
|
? "18px"
|
|
134
|
-
: "
|
|
134
|
+
: "12px"};
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
&:focus {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const styled_components_1 = require("styled-components");
|
|
4
|
+
const GlobalStyle = (0, styled_components_1.createGlobalStyle) `
|
|
5
|
+
* {
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
font-family: ${({ theme }) => theme.typography.fontFamily};
|
|
13
|
+
background-color: ${({ theme }) => theme.palette.background.default};
|
|
14
|
+
color: ${({ theme }) => theme.palette.text.primary};
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
height: 100vh;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#root{
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
height: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
h1, h2, h3, h4, h5, h6 {
|
|
27
|
+
font-family: ${({ theme }) => theme.typography.fontFamily};
|
|
28
|
+
color: ${({ theme }) => theme.palette.text.primary};
|
|
29
|
+
margin: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
h1 {
|
|
33
|
+
margin: 3px 0px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
h2 {
|
|
37
|
+
margin: 2px 0px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
h3 {
|
|
41
|
+
margin: 1px 0px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
h4, h5, h6 {
|
|
45
|
+
margin: 0px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
a {
|
|
49
|
+
text-decoration: none;
|
|
50
|
+
color: unset;
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
exports.default = GlobalStyle;
|
|
@@ -9,6 +9,7 @@ const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
|
9
9
|
const styled_components_1 = require("styled-components");
|
|
10
10
|
const theme_1 = __importDefault(require("../theme"));
|
|
11
11
|
const react_1 = require("react");
|
|
12
|
+
const GlobalStyle_1 = __importDefault(require("./GlobalStyle"));
|
|
12
13
|
exports.MonolithUIContext = (0, react_1.createContext)(undefined);
|
|
13
14
|
const MonolithUIProvider = ({ children, theme = {}, defaultColorScheme = "dark", }) => {
|
|
14
15
|
const [colorScheme, setColorScheme] = (0, react_1.useState)(defaultColorScheme);
|
|
@@ -23,6 +24,6 @@ const MonolithUIProvider = ({ children, theme = {}, defaultColorScheme = "dark",
|
|
|
23
24
|
colorScheme,
|
|
24
25
|
toggleColorScheme,
|
|
25
26
|
setColorScheme,
|
|
26
|
-
}, children: (0, jsx_runtime_1.
|
|
27
|
+
}, children: (0, jsx_runtime_1.jsxs)(styled_components_1.ThemeProvider, { theme: _theme, children: [(0, jsx_runtime_1.jsx)(GlobalStyle_1.default, { theme: _theme }), children] }) }));
|
|
27
28
|
};
|
|
28
29
|
exports.default = MonolithUIProvider;
|
package/dist/Pill/Pill.js
CHANGED
|
@@ -25,7 +25,13 @@ const Pill = (0, styled_components_1.default)(({ className, children, size = "md
|
|
|
25
25
|
e.stopPropagation();
|
|
26
26
|
onRemove === null || onRemove === void 0 ? void 0 : onRemove();
|
|
27
27
|
};
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: className,
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: className, onClick: (e) => {
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
e.stopPropagation();
|
|
31
|
+
}, children: [(0, jsx_runtime_1.jsx)("span", { className: "pill-content", children: children }), showRemoveIcon && ((0, jsx_runtime_1.jsx)(StyledButton, { onClick: handleRemove, onMouseDown: (e) => {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
e.stopPropagation();
|
|
34
|
+
}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, {}) }))] }));
|
|
29
35
|
}) `
|
|
30
36
|
user-select: none;
|
|
31
37
|
display: flex;
|
|
@@ -41,7 +47,7 @@ const Pill = (0, styled_components_1.default)(({ className, children, size = "md
|
|
|
41
47
|
color: ${({ theme }) => theme.palette.text.primary};
|
|
42
48
|
|
|
43
49
|
padding-inline-end: ${({ size, showRemoveIcon }) => {
|
|
44
|
-
if (showRemoveIcon) {
|
|
50
|
+
if (showRemoveIcon !== false) {
|
|
45
51
|
return "0px";
|
|
46
52
|
}
|
|
47
53
|
switch (size) {
|
|
@@ -378,15 +378,19 @@ const SelectBox = (0, styled_components_1.default)(({ className, data = [], plac
|
|
|
378
378
|
// Handle default value
|
|
379
379
|
(0, react_2.useEffect)(() => {
|
|
380
380
|
if (defaultValue) {
|
|
381
|
+
const isOption = defaultValue.value !== undefined;
|
|
382
|
+
const searchPattern = isOption
|
|
383
|
+
? defaultValue.value
|
|
384
|
+
: defaultValue;
|
|
381
385
|
setSelected(data.find((item) => isObjectArray
|
|
382
|
-
? item.value ===
|
|
383
|
-
: item ===
|
|
386
|
+
? item.value === searchPattern
|
|
387
|
+
: item === searchPattern) || null);
|
|
384
388
|
}
|
|
385
389
|
}, [data, defaultValue, isObjectArray]);
|
|
386
390
|
// handle input value change
|
|
387
391
|
(0, react_2.useEffect)(() => {
|
|
388
392
|
if (inputRef.current) {
|
|
389
|
-
if (!
|
|
393
|
+
if (!selected) {
|
|
390
394
|
inputRef.current.value = "";
|
|
391
395
|
}
|
|
392
396
|
else {
|
|
@@ -454,12 +458,16 @@ const SelectBox = (0, styled_components_1.default)(({ className, data = [], plac
|
|
|
454
458
|
: "",
|
|
455
459
|
}, variant: variant, "data-empty": filteredItems.length === 0 }, DropDownProps, { children: [actionComponent && (0, jsx_runtime_1.jsx)(ActionMenu, { children: actionComponent }), (0, jsx_runtime_1.jsxs)(StyledInnerItemContainer, { ref: scrollContainerRef, "data-scroll-active": scrollActive, onScroll: onScroll, children: [loading && (0, jsx_runtime_1.jsx)("div", { children: "Loading..." }), !loading && grouped
|
|
456
460
|
? groups.map((group, index) => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(GroupTitle, { size: size, children: group.label }), group.items.map((item, index) => {
|
|
457
|
-
return ((0, jsx_runtime_1.jsx)(__1.Tooltip, { content: TooltipContent ? ((0, jsx_runtime_1.jsx)(TooltipContent, { data: item.data })) : null, side: "left", children: (0, jsx_runtime_1.jsx)(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(e, item), "data-selected":
|
|
458
|
-
|
|
461
|
+
return ((0, jsx_runtime_1.jsx)(__1.Tooltip, { content: TooltipContent ? ((0, jsx_runtime_1.jsx)(TooltipContent, { data: item.data })) : null, side: "left", children: (0, jsx_runtime_1.jsx)(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(e, item), "data-selected": isObjectArray
|
|
462
|
+
? (selected === null || selected === void 0 ? void 0 : selected.value) ===
|
|
463
|
+
item.value
|
|
464
|
+
: selected === item, size: size, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (item === null || item === void 0 ? void 0 : item.label) || item })) }, index) }, index));
|
|
459
465
|
})] }, group.label)))
|
|
460
466
|
: filteredItems.map((item, index) => {
|
|
461
|
-
return ((0, jsx_runtime_1.jsx)(__1.Tooltip, { content: TooltipContent ? ((0, jsx_runtime_1.jsx)(TooltipContent, { data: item.data })) : null, side: "left", children: (0, jsx_runtime_1.jsx)(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(e, item), "data-selected":
|
|
462
|
-
|
|
467
|
+
return ((0, jsx_runtime_1.jsx)(__1.Tooltip, { content: TooltipContent ? ((0, jsx_runtime_1.jsx)(TooltipContent, { data: item.data })) : null, side: "left", children: (0, jsx_runtime_1.jsx)(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(e, item), "data-selected": isObjectArray
|
|
468
|
+
? (selected === null || selected === void 0 ? void 0 : selected.value) ===
|
|
469
|
+
(item === null || item === void 0 ? void 0 : item.value)
|
|
470
|
+
: selected === item, size: size, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (item === null || item === void 0 ? void 0 : item.label) || item })) }, index) }, index));
|
|
463
471
|
})] })] })) }) }))] }));
|
|
464
472
|
}) `
|
|
465
473
|
position: relative;
|
package/dist/TagBox/TagBox.d.ts
CHANGED
|
@@ -4,11 +4,11 @@ type Option = {
|
|
|
4
4
|
label: string;
|
|
5
5
|
value: any;
|
|
6
6
|
group?: string;
|
|
7
|
-
data
|
|
7
|
+
data?: any;
|
|
8
8
|
};
|
|
9
9
|
interface TagBoxProps {
|
|
10
10
|
className?: string;
|
|
11
|
-
data?: Option[];
|
|
11
|
+
data?: Option[] | string[];
|
|
12
12
|
placeholder?: string;
|
|
13
13
|
arrow?: boolean;
|
|
14
14
|
defaultValue?: Option[];
|
|
@@ -24,6 +24,7 @@ interface TagBoxProps {
|
|
|
24
24
|
allowCustomValue?: boolean;
|
|
25
25
|
searchable?: boolean;
|
|
26
26
|
clearable?: boolean;
|
|
27
|
+
openOnFocus?: boolean;
|
|
27
28
|
label?: string;
|
|
28
29
|
description?: string;
|
|
29
30
|
required?: boolean;
|
|
@@ -34,5 +35,5 @@ interface TagBoxProps {
|
|
|
34
35
|
data: any;
|
|
35
36
|
}) => JSX.Element;
|
|
36
37
|
}
|
|
37
|
-
declare const TagBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<TagBoxProps, never>> & string & Omit<({ className, data, placeholder, arrow, defaultValue, grouped, searchFn, onChange, onScroll, onSearch, onItemAdded, size, variant, width, allowCustomValue, searchable, clearable, label, description, required, error, loading, renderOption, TooltipContent, }: TagBoxProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
|
38
|
+
declare const TagBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<TagBoxProps, never>> & string & Omit<({ className, data, placeholder, arrow, defaultValue, grouped, searchFn, onChange, onScroll, onSearch, onItemAdded, size, variant, width, allowCustomValue, searchable, clearable, openOnFocus, label, description, required, error, loading, renderOption, TooltipContent, }: TagBoxProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
|
38
39
|
export default TagBox;
|
package/dist/TagBox/TagBox.js
CHANGED
|
@@ -34,6 +34,18 @@ const StyledInputContainer = styled_components_1.default.div `
|
|
|
34
34
|
pointer-events: all;
|
|
35
35
|
outline: none;
|
|
36
36
|
|
|
37
|
+
padding: ${({ size }) => size === "xs"
|
|
38
|
+
? "2px 8px"
|
|
39
|
+
: size === "sm"
|
|
40
|
+
? "4px 10px"
|
|
41
|
+
: size === "md"
|
|
42
|
+
? "6px 12px"
|
|
43
|
+
: size === "lg"
|
|
44
|
+
? "7px 14px"
|
|
45
|
+
: size === "xl"
|
|
46
|
+
? "8px 16px"
|
|
47
|
+
: "4px 10px"};
|
|
48
|
+
|
|
37
49
|
border-radius: 5px;
|
|
38
50
|
transition: border 0.1s ease-in-out;
|
|
39
51
|
border: 1px solid
|
|
@@ -146,7 +158,10 @@ const StyledInput = (0, styled_components_1.default)((_a) => {
|
|
|
146
158
|
color: inherit;
|
|
147
159
|
|
|
148
160
|
height: 100%;
|
|
149
|
-
|
|
161
|
+
padding: 0px;
|
|
162
|
+
min-height: 0px;
|
|
163
|
+
|
|
164
|
+
min-width: 100px;
|
|
150
165
|
|
|
151
166
|
&:focus {
|
|
152
167
|
border: 0;
|
|
@@ -211,20 +226,6 @@ const PillContainer = styled_components_1.default.div `
|
|
|
211
226
|
flex-wrap: wrap;
|
|
212
227
|
flex-grow: 1;
|
|
213
228
|
|
|
214
|
-
padding: ${({ size }) => size === "xs"
|
|
215
|
-
? "0px 8px"
|
|
216
|
-
: size === "sm"
|
|
217
|
-
? "0px 10px"
|
|
218
|
-
: size === "md"
|
|
219
|
-
? "0px 12px"
|
|
220
|
-
: size === "lg"
|
|
221
|
-
? "0px 14px"
|
|
222
|
-
: size === "xl"
|
|
223
|
-
? "0px 16px"
|
|
224
|
-
: "0px 8px"};
|
|
225
|
-
|
|
226
|
-
padding-top: 5px;
|
|
227
|
-
|
|
228
229
|
&[data-empty="true"] {
|
|
229
230
|
display: none;
|
|
230
231
|
}
|
|
@@ -282,16 +283,30 @@ const StyledItem = styled_components_1.default.div `
|
|
|
282
283
|
display: none;
|
|
283
284
|
color: ${(props) => props.theme.palette.primary.main};
|
|
284
285
|
}
|
|
286
|
+
|
|
287
|
+
&[data-highlighted="true"] {
|
|
288
|
+
background-color: ${(props) => props.theme.palette.divider};
|
|
289
|
+
color: ${(props) => props.theme.palette.text.primary};
|
|
290
|
+
}
|
|
285
291
|
`;
|
|
286
|
-
const TagBox = (0, styled_components_1.default)(({ className, data = [], placeholder = "Select
|
|
292
|
+
const TagBox = (0, styled_components_1.default)(({ className, data = [], placeholder = "Select tags", arrow = true, defaultValue = [], grouped, searchFn, onChange, onScroll, onSearch, onItemAdded, size = "sm", variant = "outlined", width = "100%", allowCustomValue = false, searchable = false, clearable = false, openOnFocus = true, label, description, required = false, error, loading = false, renderOption, TooltipContent, }) => {
|
|
287
293
|
var _a, _b, _c, _d, _e, _f;
|
|
288
|
-
const isObjectArray = data
|
|
294
|
+
const isObjectArray = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.hasOwnProperty("label");
|
|
289
295
|
const [isOpen, setIsOpen] = (0, react_2.useState)(false);
|
|
290
296
|
const [selectedItems, setSelectedItems] = (0, react_2.useState)(defaultValue);
|
|
297
|
+
const [preSelected, setPreSelected] = (0, react_2.useState)(null);
|
|
298
|
+
const [customItems, setCustomItems] = (0, react_2.useState)([]);
|
|
291
299
|
const [searchValue, setSearchValue] = (0, react_2.useState)("");
|
|
292
300
|
const inputRef = (0, react_2.useRef)(null);
|
|
293
301
|
const scrollContainerRef = (0, react_2.useRef)(null);
|
|
294
302
|
const filteredItems = data
|
|
303
|
+
.concat(customItems) // Add custom items to the list
|
|
304
|
+
.filter((item) => {
|
|
305
|
+
const isSelected = !!selectedItems.find((selectedItem) => isObjectArray
|
|
306
|
+
? selectedItem.value === item.value
|
|
307
|
+
: selectedItem === item);
|
|
308
|
+
return !isSelected;
|
|
309
|
+
})
|
|
295
310
|
.filter((item) => {
|
|
296
311
|
const itemValue = (isObjectArray ? item.label : item);
|
|
297
312
|
return itemValue.toLowerCase().includes(searchValue.toLowerCase());
|
|
@@ -364,6 +379,18 @@ const TagBox = (0, styled_components_1.default)(({ className, data = [], placeho
|
|
|
364
379
|
return [...prev, option];
|
|
365
380
|
});
|
|
366
381
|
}, [onChange]);
|
|
382
|
+
const handleFocus = () => {
|
|
383
|
+
var _a, _b;
|
|
384
|
+
if (openOnFocus) {
|
|
385
|
+
setIsOpen(true);
|
|
386
|
+
}
|
|
387
|
+
if (searchable) {
|
|
388
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
389
|
+
}
|
|
390
|
+
else if (allowCustomValue) {
|
|
391
|
+
(_b = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
392
|
+
}
|
|
393
|
+
};
|
|
367
394
|
const handleItemClick = (item) => {
|
|
368
395
|
var _a;
|
|
369
396
|
if ((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.value)
|
|
@@ -371,16 +398,117 @@ const TagBox = (0, styled_components_1.default)(({ className, data = [], placeho
|
|
|
371
398
|
setSearchValue("");
|
|
372
399
|
handleChangeSelection(item);
|
|
373
400
|
};
|
|
374
|
-
const handleRemoveItem = (item) => {
|
|
401
|
+
const handleRemoveItem = (item, index) => {
|
|
375
402
|
setSelectedItems((prev) => {
|
|
376
|
-
const newItems = prev.filter((prevItem) => isObjectArray
|
|
403
|
+
const newItems = prev.filter((prevItem, idx) => isObjectArray
|
|
377
404
|
? prevItem.value !== item.value
|
|
378
|
-
:
|
|
405
|
+
: idx !== index);
|
|
379
406
|
onChange === null || onChange === void 0 ? void 0 : onChange(newItems);
|
|
380
407
|
return newItems;
|
|
381
408
|
});
|
|
382
409
|
};
|
|
410
|
+
const handleAddItem = (0, react_2.useCallback)((newItem) => {
|
|
411
|
+
const existingItem = data.concat(customItems).find((item) => {
|
|
412
|
+
return isObjectArray
|
|
413
|
+
? item.label.toLowerCase() === newItem.toLowerCase()
|
|
414
|
+
: item.toLowerCase() === newItem.toLowerCase();
|
|
415
|
+
});
|
|
416
|
+
if (!existingItem) {
|
|
417
|
+
const newValue = isObjectArray
|
|
418
|
+
? { label: newItem, value: newItem }
|
|
419
|
+
: newItem;
|
|
420
|
+
setCustomItems([...customItems, newValue]);
|
|
421
|
+
handleChangeSelection(newValue);
|
|
422
|
+
onItemAdded === null || onItemAdded === void 0 ? void 0 : onItemAdded(newValue);
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
// check if the item is already selected
|
|
426
|
+
const isSelected = !!selectedItems.find((selectedItem) => isObjectArray
|
|
427
|
+
? selectedItem.value ===
|
|
428
|
+
existingItem.value
|
|
429
|
+
: selectedItem === existingItem);
|
|
430
|
+
if (!isSelected) {
|
|
431
|
+
handleChangeSelection(existingItem);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}, [
|
|
435
|
+
onItemAdded,
|
|
436
|
+
isObjectArray,
|
|
437
|
+
data,
|
|
438
|
+
handleChangeSelection,
|
|
439
|
+
selectedItems,
|
|
440
|
+
customItems,
|
|
441
|
+
]);
|
|
383
442
|
const handleKeyDown = (e) => {
|
|
443
|
+
var _a, _b;
|
|
444
|
+
const currentInputValue = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.value;
|
|
445
|
+
// Escape key
|
|
446
|
+
if (e.key === "Escape") {
|
|
447
|
+
const reference = (_b = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _b === void 0 ? void 0 : _b.current;
|
|
448
|
+
reference === null || reference === void 0 ? void 0 : reference.blur();
|
|
449
|
+
setSearchValue("");
|
|
450
|
+
update();
|
|
451
|
+
setIsOpen(false);
|
|
452
|
+
}
|
|
453
|
+
// Enter key
|
|
454
|
+
if (e.key === "Enter") {
|
|
455
|
+
if (preSelected) {
|
|
456
|
+
handleItemClick(preSelected);
|
|
457
|
+
setPreSelected(null);
|
|
458
|
+
setSearchValue("");
|
|
459
|
+
update();
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
else if (currentInputValue &&
|
|
463
|
+
currentInputValue !== "" &&
|
|
464
|
+
allowCustomValue) {
|
|
465
|
+
handleAddItem(currentInputValue);
|
|
466
|
+
inputRef.current.value = "";
|
|
467
|
+
setSearchValue("");
|
|
468
|
+
update();
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
// TODO: decide what to do when user presses enter after typing a search value
|
|
472
|
+
}
|
|
473
|
+
// toggleOpen();
|
|
474
|
+
// setIsOpen(false);
|
|
475
|
+
}
|
|
476
|
+
// Backspace key
|
|
477
|
+
if (e.key === "Backspace" && currentInputValue === "") {
|
|
478
|
+
setSelectedItems((prev) => {
|
|
479
|
+
const newItems = prev.slice(0, prev.length - 1);
|
|
480
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newItems);
|
|
481
|
+
return newItems;
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
// Arrow down
|
|
485
|
+
if (e.key === "ArrowDown") {
|
|
486
|
+
e.preventDefault();
|
|
487
|
+
setPreSelected((prev) => {
|
|
488
|
+
let newItem = filteredItems[0]; // Loop back to the first item
|
|
489
|
+
const index = filteredItems.findIndex((item) => isObjectArray
|
|
490
|
+
? item.value === (prev === null || prev === void 0 ? void 0 : prev.value)
|
|
491
|
+
: item === prev);
|
|
492
|
+
if (index < filteredItems.length - 1) {
|
|
493
|
+
newItem = filteredItems[index + 1];
|
|
494
|
+
}
|
|
495
|
+
return newItem;
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
// Arrow up
|
|
499
|
+
if (e.key === "ArrowUp") {
|
|
500
|
+
e.preventDefault();
|
|
501
|
+
setPreSelected((prev) => {
|
|
502
|
+
let newItem = filteredItems[filteredItems.length - 1]; // Loop back to the last item
|
|
503
|
+
const index = filteredItems.findIndex((item) => isObjectArray
|
|
504
|
+
? item.value === (prev === null || prev === void 0 ? void 0 : prev.value)
|
|
505
|
+
: item === prev);
|
|
506
|
+
if (index > 0) {
|
|
507
|
+
newItem = filteredItems[index - 1];
|
|
508
|
+
}
|
|
509
|
+
return newItem;
|
|
510
|
+
});
|
|
511
|
+
}
|
|
384
512
|
// Tab key
|
|
385
513
|
if (e.key === "Tab") {
|
|
386
514
|
setIsOpen(false);
|
|
@@ -414,24 +542,32 @@ const TagBox = (0, styled_components_1.default)(({ className, data = [], placeho
|
|
|
414
542
|
const scrollActive = scrollEl
|
|
415
543
|
? (scrollEl === null || scrollEl === void 0 ? void 0 : scrollEl.scrollHeight) > (scrollEl === null || scrollEl === void 0 ? void 0 : scrollEl.clientHeight)
|
|
416
544
|
: false;
|
|
417
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: className + " mfTagBox", children: [label && ((0, jsx_runtime_1.jsx)(__1.FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), (0, jsx_runtime_1.jsxs)(StyledInputContainer, {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
545
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: className + " mfTagBox", children: [label && ((0, jsx_runtime_1.jsx)(__1.FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), (0, jsx_runtime_1.jsxs)(StyledInputContainer, { className: "styledInputContainer", ref: refs.setReference, onClick: () => {
|
|
546
|
+
setIsOpen(true);
|
|
547
|
+
handleFocus();
|
|
548
|
+
}, onFocus: handleFocus, size: size, variant: variant, onKeyDown: handleKeyDown, "data-open": isOpen, children: [(0, jsx_runtime_1.jsx)(StyledInnerContainer, { size: size, "data-button-right": arrow || clearable, children: (0, jsx_runtime_1.jsxs)(PillContainer, { size: size, children: [selectedItems.map((item, index) => ((0, jsx_runtime_1.jsx)(__1.Pill, { size: "xs", onRemove: () => handleRemoveItem(item, index), children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (item === null || item === void 0 ? void 0 : item.label) || item })) }, index))), (searchable ||
|
|
549
|
+
allowCustomValue ||
|
|
550
|
+
selectedItems.length === 0) && ((0, jsx_runtime_1.jsx)(StyledInput, { inputRef: inputRef, onChange: (e) => {
|
|
551
|
+
if (searchFn !== undefined) {
|
|
552
|
+
searchFn === null || searchFn === void 0 ? void 0 : searchFn(e.target.value);
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
setSearchValue(e.target.value);
|
|
556
|
+
}
|
|
557
|
+
update();
|
|
558
|
+
}, placeholder: placeholder, size: size, readOnly: !(searchable || allowCustomValue) }))] }) }), clearable &&
|
|
559
|
+
(selectedItems.length > 0 || !!((_f = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _f === void 0 ? void 0 : _f.value)) ? ((0, jsx_runtime_1.jsx)(core_1.ClearButton, { onClick: handleClear })) : arrow ? ((0, jsx_runtime_1.jsx)(core_1.ArrowButton, {})) : null] }), isOpen && ((0, jsx_runtime_1.jsx)(core_1.StyledFloatContainer, { ref: refs.setFloating, style: floatingStyles, className: "mfFloating", children: (0, jsx_runtime_1.jsx)(ExtendedStyledContent, { className: "mfFloatingContent", style: { width: contentWidth, maxWidth: contentWidth }, variant: variant, onScroll: onScroll, "data-scroll-active": scrollActive, "data-empty": filteredItems.length === 0, children: !loading && grouped
|
|
428
560
|
? groups.map((group, index) => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(GroupTitle, { size: size, children: group.label }), group.items.map((item, index) => {
|
|
429
|
-
return ((0, jsx_runtime_1.jsx)(__1.Tooltip, { content: TooltipContent ? ((0, jsx_runtime_1.jsx)(TooltipContent, { data: item.data })) : null, side: "left", children: (0, jsx_runtime_1.jsx)(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(item), "data-
|
|
430
|
-
|
|
561
|
+
return ((0, jsx_runtime_1.jsx)(__1.Tooltip, { content: TooltipContent ? ((0, jsx_runtime_1.jsx)(TooltipContent, { data: item.data })) : null, side: "left", children: (0, jsx_runtime_1.jsx)(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(item), "data-highlighted": isObjectArray
|
|
562
|
+
? (preSelected === null || preSelected === void 0 ? void 0 : preSelected.value) ===
|
|
563
|
+
item.value
|
|
564
|
+
: preSelected === item, size: size, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (item === null || item === void 0 ? void 0 : item.label) || item })) }, index) }, index));
|
|
431
565
|
})] }, group.label)))
|
|
432
566
|
: filteredItems.map((item, index) => {
|
|
433
|
-
return ((0, jsx_runtime_1.jsx)(__1.Tooltip, { content: TooltipContent ? ((0, jsx_runtime_1.jsx)(TooltipContent, { data: item.data })) : null, side: "left", children: (0, jsx_runtime_1.jsx)(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(item), "data-
|
|
434
|
-
|
|
567
|
+
return ((0, jsx_runtime_1.jsx)(__1.Tooltip, { content: TooltipContent ? ((0, jsx_runtime_1.jsx)(TooltipContent, { data: item.data })) : null, side: "left", children: (0, jsx_runtime_1.jsx)(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(item), "data-highlighted": isObjectArray
|
|
568
|
+
? (preSelected === null || preSelected === void 0 ? void 0 : preSelected.value) ===
|
|
569
|
+
item.value
|
|
570
|
+
: preSelected === item, size: size, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (item === null || item === void 0 ? void 0 : item.label) || item })) }, index) }, index));
|
|
435
571
|
}) }) }))] }));
|
|
436
572
|
}) `
|
|
437
573
|
position: relative;
|
|
@@ -25,7 +25,7 @@ const TextArea = (0, styled_components_1.default)(react_textarea_autosize_1.defa
|
|
|
25
25
|
? "17px"
|
|
26
26
|
: size === "xl"
|
|
27
27
|
? "19px"
|
|
28
|
-
: "
|
|
28
|
+
: "13px"};
|
|
29
29
|
|
|
30
30
|
background-color: ${({ theme, variant }) => {
|
|
31
31
|
switch (variant) {
|
|
@@ -75,7 +75,7 @@ const TextArea = (0, styled_components_1.default)(react_textarea_autosize_1.defa
|
|
|
75
75
|
? "16px"
|
|
76
76
|
: size === "xl"
|
|
77
77
|
? "18px"
|
|
78
|
-
: "
|
|
78
|
+
: "12px"};
|
|
79
79
|
}
|
|
80
80
|
`;
|
|
81
81
|
exports.default = TextArea;
|
|
@@ -13,7 +13,7 @@ interface TextAreaInputProps {
|
|
|
13
13
|
rowHeight: number;
|
|
14
14
|
}) => void;
|
|
15
15
|
cacheMeasurements?: boolean;
|
|
16
|
-
style?:
|
|
16
|
+
style?: any;
|
|
17
17
|
}
|
|
18
18
|
declare const TextAreaInput: ({ label, error, required, colSpan, size, description, inputRef, maxRows, minRows, onHeightChange, cacheMeasurements, style, }: TextAreaInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
19
|
export default TextAreaInput;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
4
|
const __1 = require("..");
|
|
5
|
-
const TextAreaInput = ({ label, error, required, colSpan = 1, size = "sm", description, inputRef = null, maxRows, minRows, onHeightChange, cacheMeasurements, style, }) => {
|
|
5
|
+
const TextAreaInput = ({ label, error, required, colSpan = 1, size = "sm", description, inputRef = null, maxRows = 6, minRows = 3, onHeightChange, cacheMeasurements, style, }) => {
|
|
6
6
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
7
7
|
gridColumn: `span ${colSpan}`,
|
|
8
8
|
height: "fit-content",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InputProps } from "../Input/Input";
|
|
2
2
|
import { Size } from "../core";
|
|
3
3
|
interface TextInputProps extends InputProps {
|
|
4
|
+
className?: string;
|
|
4
5
|
label?: string;
|
|
5
6
|
error?: string;
|
|
6
7
|
required?: boolean;
|
|
@@ -8,5 +9,5 @@ interface TextInputProps extends InputProps {
|
|
|
8
9
|
colSpan?: number;
|
|
9
10
|
description?: string;
|
|
10
11
|
}
|
|
11
|
-
declare const TextInput:
|
|
12
|
+
declare const TextInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<TextInputProps, never>> & string & Omit<({ className, label, error, required, colSpan, description, size, ...rest }: TextInputProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
|
12
13
|
export default TextInput;
|
|
@@ -15,16 +15,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
18
19
|
const __1 = require("..");
|
|
19
20
|
const Input_1 = __importDefault(require("../Input/Input"));
|
|
20
|
-
const TextInput = (_a) => {
|
|
21
|
-
var { label, error, required, colSpan = 1, description, size } = _a, rest = __rest(_a, ["label", "error", "required", "colSpan", "description", "size"]);
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)("div", {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
const TextInput = (0, styled_components_1.default)((_a) => {
|
|
22
|
+
var { className, label, error, required, colSpan = 1, description, size = "sm" } = _a, rest = __rest(_a, ["className", "label", "error", "required", "colSpan", "description", "size"]);
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: className, children: [label && ((0, jsx_runtime_1.jsx)(__1.FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), (0, jsx_runtime_1.jsx)(Input_1.default, Object.assign({ size: size }, rest))] }));
|
|
24
|
+
}) `
|
|
25
|
+
grid-column: span ${({ colSpan }) => colSpan || 1};
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
justify-content: space-between;
|
|
29
|
+
width: 100%;
|
|
30
|
+
`;
|
|
30
31
|
exports.default = TextInput;
|
package/dist/theme/variants.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.THEMES = void 0;
|
|
7
7
|
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
8
|
-
const
|
|
8
|
+
const typography_1 = __importDefault(require("./typography"));
|
|
9
9
|
// Themes
|
|
10
10
|
exports.THEMES = {
|
|
11
11
|
DARK: "dark",
|
|
@@ -49,7 +49,7 @@ const green = {
|
|
|
49
49
|
};
|
|
50
50
|
const lightVariant = {
|
|
51
51
|
name: exports.THEMES.LIGHT,
|
|
52
|
-
typography:
|
|
52
|
+
typography: typography_1.default,
|
|
53
53
|
palette: {
|
|
54
54
|
mode: "light",
|
|
55
55
|
primary: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monolith-forensics/monolith-ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.23",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Matt Danner (Monolith Forensics LLC)",
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
"dist/"
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"clean": "rm -r ./dist",
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"release": "yarn version --minor --deferred && yarn build && npm publish && yarn clean"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"@floating-ui/react": "^0.26.16",
|