@monolith-forensics/monolith-ui 1.2.91 → 1.2.92
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.d.ts +1 -0
- package/dist/Button/Button.js +3 -2
- package/dist/Calendar/CalendarStyles.d.ts +5 -15
- package/dist/Calendar/calendarHelpers.d.ts +1 -1
- package/dist/CheckBox/CheckBox.js +6 -4
- package/dist/DateInput/DateInput.d.ts +5 -3
- package/dist/DateInput/DateInput.js +41 -25
- package/dist/DropDownMenu/DropDownMenu.d.ts +2 -45
- package/dist/DropDownMenu/DropDownMenu.js +9 -315
- package/dist/DropDownMenu/components/Menu.d.ts +2 -0
- package/dist/DropDownMenu/components/Menu.js +11 -0
- package/dist/DropDownMenu/components/MenuComponent.d.ts +2 -0
- package/dist/DropDownMenu/components/MenuComponent.js +117 -0
- package/dist/DropDownMenu/components/MenuContext.d.ts +7 -0
- package/dist/DropDownMenu/components/MenuContext.js +8 -0
- package/dist/DropDownMenu/components/MenuItem.d.ts +7 -0
- package/dist/DropDownMenu/components/MenuItem.js +99 -0
- package/dist/DropDownMenu/components/MenuItemList.d.ts +18 -0
- package/dist/DropDownMenu/components/MenuItemList.js +92 -0
- package/dist/DropDownMenu/components/SearchInput.d.ts +1 -0
- package/dist/DropDownMenu/components/SearchInput.js +4 -0
- package/dist/DropDownMenu/components/StyledContent.d.ts +2 -0
- package/dist/DropDownMenu/components/StyledContent.js +42 -0
- package/dist/DropDownMenu/components/StyledFloatContainer.d.ts +1 -0
- package/dist/DropDownMenu/components/StyledFloatContainer.js +5 -0
- package/dist/DropDownMenu/components/StyledInnerItemContainer.d.ts +1 -0
- package/dist/DropDownMenu/components/StyledInnerItemContainer.js +9 -0
- package/dist/DropDownMenu/components/index.d.ts +9 -0
- package/dist/DropDownMenu/components/index.js +9 -0
- package/dist/DropDownMenu/index.d.ts +1 -1
- package/dist/DropDownMenu/index.js +1 -0
- package/dist/DropDownMenu/types.d.ts +52 -0
- package/dist/FieldLabel/FieldLabel.d.ts +1 -1
- package/dist/FileViewer/FileViewer.d.ts +13 -0
- package/dist/FileViewer/FileViewer.js +180 -0
- package/dist/FileViewer/index.d.ts +1 -0
- package/dist/FileViewer/index.js +1 -0
- package/dist/FileViewer/viewers/CodeViewer.d.ts +6 -0
- package/dist/FileViewer/viewers/CodeViewer.js +106 -0
- package/dist/FileViewer/viewers/ImageViewer.d.ts +6 -0
- package/dist/FileViewer/viewers/ImageViewer.js +58 -0
- package/dist/FileViewer/viewers/OfficeViewer.d.ts +5 -0
- package/dist/FileViewer/viewers/OfficeViewer.js +70 -0
- package/dist/FileViewer/viewers/PdfViewer.d.ts +8 -0
- package/dist/FileViewer/viewers/PdfViewer.js +63 -0
- package/dist/FileViewer/viewers/PlainTextViewer.d.ts +4 -0
- package/dist/FileViewer/viewers/PlainTextViewer.js +62 -0
- package/dist/FileViewer/viewers/VideoViewer.d.ts +6 -0
- package/dist/FileViewer/viewers/VideoViewer.js +30 -0
- package/dist/FileViewer/viewers/index.d.ts +6 -0
- package/dist/FileViewer/viewers/index.js +6 -0
- package/dist/FormSection/FormSection.d.ts +10 -2
- package/dist/FormSection/FormSection.js +43 -8
- package/dist/IconButton/IconButton.d.ts +1 -3
- package/dist/Input/Input.js +5 -0
- package/dist/MonolithUIProvider/GlobalStyle.d.ts +1 -1
- package/dist/MonolithUIProvider/GlobalStyle.js +1 -1
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +2 -2
- package/dist/MonolithUIProvider/MonolithUIProvider.js +8 -3
- package/dist/MonolithUIProvider/index.d.ts +2 -2
- package/dist/MonolithUIProvider/index.js +2 -2
- package/dist/MonolithUIProvider/useMonolithUITheme.d.ts +1 -2
- package/dist/MonolithUIProvider/useMonolithUITheme.js +1 -2
- package/dist/Pill/Pill.d.ts +2 -1
- package/dist/Pill/Pill.js +2 -2
- package/dist/QueryFilter/DefaultOperators.d.ts +2 -3
- package/dist/QueryFilter/DefaultOperators.js +2 -3
- package/dist/QueryFilter/QueryFilter.d.ts +2 -3
- package/dist/QueryFilter/QueryFilter.js +126 -49
- package/dist/QueryFilter/index.d.ts +4 -2
- package/dist/QueryFilter/index.js +4 -2
- package/dist/QueryFilter/types.d.ts +12 -8
- package/dist/QueryFilter/useFilterHelper.d.ts +20 -0
- package/dist/QueryFilter/useFilterHelper.js +61 -0
- package/dist/QueryFilter/useQueryFilter.d.ts +1 -2
- package/dist/QueryFilter/useQueryFilter.js +5 -2
- package/dist/RichTextEditor/Components/BubbleMenu.d.ts +3 -4
- package/dist/RichTextEditor/Components/BubbleMenu.js +29 -26
- package/dist/RichTextEditor/Components/ColorPicker.d.ts +4 -0
- package/dist/RichTextEditor/Components/ColorPicker.js +37 -0
- package/dist/RichTextEditor/Components/index.d.ts +1 -0
- package/dist/RichTextEditor/Components/index.js +1 -0
- package/dist/RichTextEditor/RichTextEditor.d.ts +2 -3
- package/dist/RichTextEditor/RichTextEditor.js +83 -86
- package/dist/RichTextEditor/Toolbar/ControlsGroup.d.ts +1 -3
- package/dist/RichTextEditor/Toolbar/Toolbar.d.ts +1 -1
- package/dist/RichTextEditor/Toolbar/Toolbar.js +10 -14
- package/dist/SelectBox/SelectBox.d.ts +1 -1
- package/dist/SelectBox/SelectBox.js +133 -92
- package/dist/SelectBox/types.d.ts +8 -5
- package/dist/Switch/Switch.js +4 -4
- package/dist/Table/ActionButton.d.ts +1 -3
- package/dist/Table/ActionCell.d.ts +1 -3
- package/dist/Table/SelectionCell.d.ts +1 -3
- package/dist/Table/StaticRows.d.ts +2 -2
- package/dist/Table/Table.d.ts +1 -2
- package/dist/Table/Table.js +9 -13
- package/dist/Table/TableComponents.d.ts +2 -6
- package/dist/Table/TableComponents.js +0 -5
- package/dist/Table/TableHeader.js +8 -2
- package/dist/Table/TableMenu/TableMenu.js +11 -9
- package/dist/Table/TableProvider.js +36 -30
- package/dist/Table/TableRow.js +5 -2
- package/dist/Table/VirtualIzedRows.d.ts +2 -2
- package/dist/Table/VirtualIzedRows.js +12 -10
- package/dist/Table/index.d.ts +1 -2
- package/dist/Table/index.js +1 -2
- package/dist/Table/types.d.ts +23 -3
- package/dist/TagBox/TagBox.d.ts +1 -1
- package/dist/TagBox/TagBox.js +180 -92
- package/dist/TagBox/TagBoxStyles.d.ts +1 -3
- package/dist/TagBox/types.d.ts +4 -2
- package/dist/TextArea/TextArea.d.ts +1 -3
- package/dist/Tooltip/Tooltip.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/theme/getTheme.d.ts +1 -1
- package/package.json +11 -5
- package/dist/RichTextEditor/Components/DefaultColorIcon.d.ts +0 -4
- package/dist/RichTextEditor/Components/DefaultColorIcon.js +0 -7
- package/dist/Table/Column.d.ts +0 -3
- package/dist/Table/Column.js +0 -5
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { FixedSizeList } from "react-window";
|
|
5
|
+
import CheckBox from "../../CheckBox";
|
|
6
|
+
import DropDownMenu from "../DropDownMenu";
|
|
7
|
+
import { MenuItem } from "./MenuItem";
|
|
8
|
+
const filterMenuItems = (menuItems, searchValue) => {
|
|
9
|
+
return menuItems.filter((item) => {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
if (item === null || item === void 0 ? void 0 : item.label) {
|
|
12
|
+
return (((_a = item === null || item === void 0 ? void 0 : item.label) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchValue.toLowerCase())) ||
|
|
13
|
+
((_b = item === null || item === void 0 ? void 0 : item.value) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchValue.toLowerCase())));
|
|
14
|
+
}
|
|
15
|
+
return (_c = item.toLowerCase) === null || _c === void 0 ? void 0 : _c.call(item).includes(searchValue.toLowerCase());
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
const ListViewPort = styled.div.attrs({ className: "ListViewPort" }) `
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
`;
|
|
22
|
+
export const MenuItemList = ({ menuItems, searchable, searchValue = "", isObjectArray, selected, TooltipContent, multiselect, size, handleAddItem, handleRemoveItem, onItemSelect, renderOption, onScroll, }) => {
|
|
23
|
+
const abortController = new AbortController();
|
|
24
|
+
const targetElm = useRef(null);
|
|
25
|
+
const listElm = useRef(null);
|
|
26
|
+
const [viewPortDimensions, setViewPortDimensions] = useState({
|
|
27
|
+
width: 0,
|
|
28
|
+
height: 0,
|
|
29
|
+
});
|
|
30
|
+
const handleItemClick = (item, isSelected) => {
|
|
31
|
+
var _a;
|
|
32
|
+
if (multiselect) {
|
|
33
|
+
isSelected ? handleRemoveItem(item) : handleAddItem(item);
|
|
34
|
+
}
|
|
35
|
+
onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(item);
|
|
36
|
+
(_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
|
|
37
|
+
};
|
|
38
|
+
const visibleItems = menuItems.filter((item) => item.visible !== false);
|
|
39
|
+
const filteredItems = searchable
|
|
40
|
+
? filterMenuItems(visibleItems, searchValue)
|
|
41
|
+
: visibleItems;
|
|
42
|
+
useLayoutEffect(() => {
|
|
43
|
+
if (listElm.current) {
|
|
44
|
+
if (onScroll) {
|
|
45
|
+
listElm.current.addEventListener("scroll", (e) => onScroll === null || onScroll === void 0 ? void 0 : onScroll(e));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Event cleanup
|
|
49
|
+
return () => {
|
|
50
|
+
abortController.abort();
|
|
51
|
+
};
|
|
52
|
+
}, [filteredItems, listElm.current, onScroll]);
|
|
53
|
+
useLayoutEffect(() => {
|
|
54
|
+
var _a;
|
|
55
|
+
if (targetElm.current) {
|
|
56
|
+
const viewPortDimensions = (_a = targetElm.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
57
|
+
setViewPortDimensions({
|
|
58
|
+
width: viewPortDimensions.width,
|
|
59
|
+
height: viewPortDimensions.height,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, [targetElm.current]);
|
|
63
|
+
const overscanCount = 10;
|
|
64
|
+
const itemHeight = 25;
|
|
65
|
+
const itemCount = (filteredItems === null || filteredItems === void 0 ? void 0 : filteredItems.length) || 0;
|
|
66
|
+
const height = viewPortDimensions.height
|
|
67
|
+
? viewPortDimensions.height
|
|
68
|
+
: itemCount * itemHeight < 200
|
|
69
|
+
? itemCount * itemHeight
|
|
70
|
+
: 200;
|
|
71
|
+
const width = viewPortDimensions.width || 188;
|
|
72
|
+
return (_jsx(ListViewPort, { ref: targetElm, children: _jsx(FixedSizeList, { itemData: filteredItems, overscanCount: overscanCount, height: height, width: width, itemCount: itemCount, itemSize: itemHeight, outerRef: listElm, children: ({ data, index, style }) => {
|
|
73
|
+
const item = (data === null || data === void 0 ? void 0 : data[index]) || {};
|
|
74
|
+
const isSelected = !!(selected === null || selected === void 0 ? void 0 : selected.find((s) => isObjectArray ? (s === null || s === void 0 ? void 0 : s.value) === (item === null || item === void 0 ? void 0 : item.value) : s === item));
|
|
75
|
+
if (item.items) {
|
|
76
|
+
return (_jsx(DropDownMenu, { data: item.items, size: size, buttonProps: { style }, disabled: item.disabled, children: item.label }));
|
|
77
|
+
}
|
|
78
|
+
return (_jsx(MenuItem, { className: "MenuItem", itemData: item, TooltipContent: TooltipContent, "data-selected": isSelected, "data-disabled": item.disabled, disabled: item.disabled, leftSection: multiselect ? (_jsxs(_Fragment, { children: [_jsx(CheckBox, { value: isSelected, size: size, onChange: (newValue) => {
|
|
79
|
+
var _a;
|
|
80
|
+
newValue ? handleAddItem(item) : handleRemoveItem(item);
|
|
81
|
+
(_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
|
|
82
|
+
} }), (item === null || item === void 0 ? void 0 : item.leftSection) || null] })) : ((item === null || item === void 0 ? void 0 : item.leftSection) || null), rightSection: item === null || item === void 0 ? void 0 : item.rightSection, multiselect: multiselect, size: size, title: !TooltipContent ? item === null || item === void 0 ? void 0 : item.label : undefined, onClick: (e) => {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
e.stopPropagation();
|
|
85
|
+
handleItemClick(item, isSelected);
|
|
86
|
+
}, style: style, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) ||
|
|
87
|
+
(item === null || item === void 0 ? void 0 : item.label) ||
|
|
88
|
+
(typeof item === "string" || typeof item === "number"
|
|
89
|
+
? item
|
|
90
|
+
: null) }, index));
|
|
91
|
+
} }) }));
|
|
92
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SearchInput: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<import("../../Input/Input").InputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>, "ref">, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { StyledContentProps } from "../types";
|
|
2
|
+
export declare const StyledContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledContentProps>> & string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
export const StyledContent = styled.div `
|
|
3
|
+
position: relative;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
overflow-y: hidden;
|
|
8
|
+
overflow-x: hidden;
|
|
9
|
+
|
|
10
|
+
width: 200px;
|
|
11
|
+
min-width: 150px;
|
|
12
|
+
max-width: 400px;
|
|
13
|
+
max-height: ${({ maxDropdownHeight }) => Number.isInteger(maxDropdownHeight)
|
|
14
|
+
? `${maxDropdownHeight}px`
|
|
15
|
+
: maxDropdownHeight || "250px"};
|
|
16
|
+
|
|
17
|
+
background-color: ${(props) => props.theme.palette.background.default};
|
|
18
|
+
background-color: ${({ theme, variant }) => {
|
|
19
|
+
switch (variant) {
|
|
20
|
+
case "filled":
|
|
21
|
+
return theme.palette.input.background;
|
|
22
|
+
case "outlined":
|
|
23
|
+
return theme.palette.input.background;
|
|
24
|
+
case "text":
|
|
25
|
+
return "transparent";
|
|
26
|
+
default:
|
|
27
|
+
return theme.palette.input.background;
|
|
28
|
+
}
|
|
29
|
+
}};
|
|
30
|
+
|
|
31
|
+
border-radius: 5px;
|
|
32
|
+
border: 1px solid ${(props) => props.theme.palette.divider};
|
|
33
|
+
outline: none;
|
|
34
|
+
padding: 5px;
|
|
35
|
+
animation-duration: 400ms;
|
|
36
|
+
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
|
|
37
|
+
will-change: transform, opacity;
|
|
38
|
+
|
|
39
|
+
&[data-empty="true"] {
|
|
40
|
+
display: none;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledFloatContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledInnerItemContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>, never>, never>> & string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./SearchInput";
|
|
2
|
+
export * from "./StyledContent";
|
|
3
|
+
export * from "./StyledFloatContainer";
|
|
4
|
+
export * from "./StyledInnerItemContainer";
|
|
5
|
+
export * from "./MenuItem";
|
|
6
|
+
export * from "./MenuContext";
|
|
7
|
+
export * from "./MenuComponent";
|
|
8
|
+
export * from "./Menu";
|
|
9
|
+
export * from "./MenuItemList";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./SearchInput";
|
|
2
|
+
export * from "./StyledContent";
|
|
3
|
+
export * from "./StyledFloatContainer";
|
|
4
|
+
export * from "./StyledInnerItemContainer";
|
|
5
|
+
export * from "./MenuItem";
|
|
6
|
+
export * from "./MenuContext";
|
|
7
|
+
export * from "./MenuComponent";
|
|
8
|
+
export * from "./Menu";
|
|
9
|
+
export * from "./MenuItemList";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from "./DropDownMenu";
|
|
2
|
-
export
|
|
2
|
+
export * from "./types";
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ComponentType, ReactElement, ReactNode } from "react";
|
|
2
|
+
import { Size, Variant } from "../core";
|
|
3
|
+
import Input from "../Input";
|
|
4
|
+
import { ButtonProps } from "../Button";
|
|
5
|
+
import { StyledContent } from "./components";
|
|
1
6
|
export type DropDownItem = {
|
|
2
7
|
toLowerCase?: () => string;
|
|
3
8
|
label: string;
|
|
@@ -7,4 +12,51 @@ export type DropDownItem = {
|
|
|
7
12
|
items?: DropDownItem[];
|
|
8
13
|
leftSection?: React.ReactNode;
|
|
9
14
|
rightSection?: React.ReactNode;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
visible?: boolean;
|
|
10
17
|
};
|
|
18
|
+
export type SearchInputProps = React.ComponentPropsWithoutRef<typeof Input>;
|
|
19
|
+
export interface StyledContentProps {
|
|
20
|
+
maxDropdownHeight?: number | string;
|
|
21
|
+
variant?: Variant;
|
|
22
|
+
}
|
|
23
|
+
export interface DropDownMenuProps {
|
|
24
|
+
className?: string;
|
|
25
|
+
children?: ReactNode | string;
|
|
26
|
+
label?: string;
|
|
27
|
+
data: DropDownItem[];
|
|
28
|
+
variant?: Variant;
|
|
29
|
+
defaultValue?: DropDownItem[];
|
|
30
|
+
multiselect?: boolean;
|
|
31
|
+
size?: Size;
|
|
32
|
+
title?: string;
|
|
33
|
+
TooltipContent?: ComponentType<any>;
|
|
34
|
+
renderOption?: (item: DropDownItem) => ReactNode;
|
|
35
|
+
onChange?: (selected: DropDownItem[], diff: DropDownItem[]) => void;
|
|
36
|
+
onItemSelect?: (item: DropDownItem) => void;
|
|
37
|
+
onScroll?: (e: Event) => void;
|
|
38
|
+
loading?: boolean;
|
|
39
|
+
arrow?: boolean;
|
|
40
|
+
searchable?: boolean;
|
|
41
|
+
dropDownProps?: ComponentPropsWithoutRef<typeof StyledContent>;
|
|
42
|
+
buttonRender?: (props: any) => ReactElement;
|
|
43
|
+
buttonProps?: ButtonProps;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface MenuProps {
|
|
47
|
+
label?: any;
|
|
48
|
+
itemData?: any;
|
|
49
|
+
nested?: boolean;
|
|
50
|
+
children?: React.ReactNode;
|
|
51
|
+
buttonRender?: (props: any) => ReactElement;
|
|
52
|
+
arrow?: boolean;
|
|
53
|
+
variant?: Variant;
|
|
54
|
+
buttonProps?: ButtonProps;
|
|
55
|
+
size?: Size;
|
|
56
|
+
buttonSize?: Size;
|
|
57
|
+
multiselect?: boolean;
|
|
58
|
+
onMenuClose?: () => void;
|
|
59
|
+
TooltipContent?: ComponentType<any>;
|
|
60
|
+
dropDownProps?: ComponentPropsWithoutRef<typeof StyledContent>;
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
}
|
|
@@ -6,7 +6,7 @@ interface InfoComponentProps {
|
|
|
6
6
|
description?: string;
|
|
7
7
|
label?: string | ReactNode;
|
|
8
8
|
}
|
|
9
|
-
export declare const InfoComponent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<InfoComponentProps, never>> & string & Omit<({ className, children, description, label }: InfoComponentProps) => string | number |
|
|
9
|
+
export declare const InfoComponent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<InfoComponentProps, never>> & string & Omit<({ className, children, description, label }: InfoComponentProps) => string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined, keyof import("react").Component<any, {}, any>>;
|
|
10
10
|
interface FieldLabelProps {
|
|
11
11
|
className?: string;
|
|
12
12
|
children?: ReactNode;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { CodeViewer, ImageViewer, OfficeViewer, PdfViewer, VideoViewer, } from "./viewers";
|
|
4
|
+
import { FloatingPortal } from "@floating-ui/react";
|
|
5
|
+
import { DownloadIcon, XIcon, ZoomInIcon, ZoomOutIcon } from "lucide-react";
|
|
6
|
+
import Button from "../Button";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import Loader from "../Loader";
|
|
9
|
+
var ViewerTypes;
|
|
10
|
+
(function (ViewerTypes) {
|
|
11
|
+
ViewerTypes["Office"] = "office";
|
|
12
|
+
ViewerTypes["Image"] = "image";
|
|
13
|
+
ViewerTypes["Video"] = "video";
|
|
14
|
+
ViewerTypes["Audio"] = "audio";
|
|
15
|
+
ViewerTypes["PDF"] = "pdf";
|
|
16
|
+
ViewerTypes["Text"] = "text";
|
|
17
|
+
ViewerTypes["Code"] = "code";
|
|
18
|
+
})(ViewerTypes || (ViewerTypes = {}));
|
|
19
|
+
const ZoomableViewerTypes = [
|
|
20
|
+
ViewerTypes.Image,
|
|
21
|
+
ViewerTypes.PDF,
|
|
22
|
+
ViewerTypes.Code,
|
|
23
|
+
ViewerTypes.Text,
|
|
24
|
+
];
|
|
25
|
+
const RotatableViewerTypes = [ViewerTypes.Image];
|
|
26
|
+
const OfficeExtensions = ["doc", "docx", "xls", "xlsx", "ppt", "pptx"];
|
|
27
|
+
const ImageExtensions = ["jpg", "jpeg", "png", "gif"];
|
|
28
|
+
const VideoExtensions = ["mp4", "webm", "mov"];
|
|
29
|
+
const AudioExtensions = ["mp3", "wav"];
|
|
30
|
+
const PDFExtensions = ["pdf"];
|
|
31
|
+
const PlainTextExtensions = ["txt", "log", "csv"];
|
|
32
|
+
const CodeExtensions = [
|
|
33
|
+
"js",
|
|
34
|
+
"ts",
|
|
35
|
+
"jsx",
|
|
36
|
+
"tsx",
|
|
37
|
+
"json",
|
|
38
|
+
"html",
|
|
39
|
+
"css",
|
|
40
|
+
"xml",
|
|
41
|
+
"py",
|
|
42
|
+
"py3",
|
|
43
|
+
"dymo",
|
|
44
|
+
];
|
|
45
|
+
const StyledMenu = styled.div `
|
|
46
|
+
height: 50px;
|
|
47
|
+
min-height: 50px;
|
|
48
|
+
width: 100%;
|
|
49
|
+
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: space-between;
|
|
53
|
+
|
|
54
|
+
font-size: 14px;
|
|
55
|
+
|
|
56
|
+
padding: 0 10px;
|
|
57
|
+
|
|
58
|
+
background-color: ${(props) => props.theme.palette.background.alt};
|
|
59
|
+
`;
|
|
60
|
+
const StyledActionsMenu = styled.div `
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: row;
|
|
63
|
+
gap: 10px;
|
|
64
|
+
align-items: center;
|
|
65
|
+
`;
|
|
66
|
+
const StyledContainer = styled.div.attrs({ className: "FileViewer-container" }) `
|
|
67
|
+
position: fixed;
|
|
68
|
+
top: 0;
|
|
69
|
+
left: 0;
|
|
70
|
+
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
|
|
74
|
+
height: 100%;
|
|
75
|
+
width: 100%;
|
|
76
|
+
|
|
77
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
78
|
+
|
|
79
|
+
// blur
|
|
80
|
+
backdrop-filter: blur(3px);
|
|
81
|
+
|
|
82
|
+
// scroll bar
|
|
83
|
+
::-webkit-scrollbar {
|
|
84
|
+
width: 14px;
|
|
85
|
+
height: 14px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
::-webkit-scrollbar-track {
|
|
89
|
+
background: rgba(255, 255, 255, 0.075);
|
|
90
|
+
border-radius: 10px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
::-webkit-scrollbar-thumb {
|
|
94
|
+
background: #888;
|
|
95
|
+
border-radius: 10px;
|
|
96
|
+
border: 4px solid rgba(0, 0, 0, 0);
|
|
97
|
+
background-clip: padding-box;
|
|
98
|
+
|
|
99
|
+
&:hover {
|
|
100
|
+
background-color: ${(props) => props.theme.palette.primary.main};
|
|
101
|
+
border-radius: 10px;
|
|
102
|
+
border: 4px solid rgba(0, 0, 0, 0);
|
|
103
|
+
background-clip: padding-box;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
::-webkit-scrollbar-corner {
|
|
108
|
+
background: rgba(0, 0, 0, 0.5);
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
const StyledInnerContainer = styled.div.attrs({
|
|
112
|
+
className: "FileViewer-inner-container",
|
|
113
|
+
}) `
|
|
114
|
+
display: flex;
|
|
115
|
+
flex-direction: column;
|
|
116
|
+
flex: 1 1 auto;
|
|
117
|
+
|
|
118
|
+
height: 0px;
|
|
119
|
+
width: 100%;
|
|
120
|
+
|
|
121
|
+
overflow-y: auto;
|
|
122
|
+
|
|
123
|
+
&[data-type="office"] {
|
|
124
|
+
margin-bottom: 10px;
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
const resolveViewerType = (file) => {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
let ext = (_a = file === null || file === void 0 ? void 0 : file.ext) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
130
|
+
if (!ext) {
|
|
131
|
+
ext = (_b = file.name.split(".").pop()) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
132
|
+
}
|
|
133
|
+
if (!ext) {
|
|
134
|
+
return ViewerTypes.Code;
|
|
135
|
+
}
|
|
136
|
+
if (OfficeExtensions.includes(ext)) {
|
|
137
|
+
return ViewerTypes.Office;
|
|
138
|
+
}
|
|
139
|
+
if (ImageExtensions.includes(ext)) {
|
|
140
|
+
return ViewerTypes.Image;
|
|
141
|
+
}
|
|
142
|
+
if (VideoExtensions.includes(ext)) {
|
|
143
|
+
return ViewerTypes.Video;
|
|
144
|
+
}
|
|
145
|
+
if (AudioExtensions.includes(ext)) {
|
|
146
|
+
return ViewerTypes.Audio;
|
|
147
|
+
}
|
|
148
|
+
if (PDFExtensions.includes(ext)) {
|
|
149
|
+
return ViewerTypes.PDF;
|
|
150
|
+
}
|
|
151
|
+
if (PlainTextExtensions.includes(ext)) {
|
|
152
|
+
return ViewerTypes.Text;
|
|
153
|
+
}
|
|
154
|
+
if (CodeExtensions.includes(ext)) {
|
|
155
|
+
return ViewerTypes.Code;
|
|
156
|
+
}
|
|
157
|
+
return ViewerTypes.Code;
|
|
158
|
+
};
|
|
159
|
+
export const FileViewer = ({ file, open, isPending, onClose }) => {
|
|
160
|
+
const [zoomFactor, setZoomFactor] = useState(1);
|
|
161
|
+
if (!open)
|
|
162
|
+
return null;
|
|
163
|
+
if (!file)
|
|
164
|
+
return null;
|
|
165
|
+
const viewerType = resolveViewerType(file);
|
|
166
|
+
const handleBackgroundClick = (e) => {
|
|
167
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
168
|
+
setZoomFactor(1);
|
|
169
|
+
};
|
|
170
|
+
return (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsxs(StyledContainer, { className: "mfui-FileViewer", children: [_jsxs(StyledMenu, { className: "FileViewer-menu", children: [_jsx(Button, { variant: "text", onClick: () => {
|
|
171
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
172
|
+
setZoomFactor(1);
|
|
173
|
+
}, children: _jsx(XIcon, { size: 18 }) }), _jsx("div", { children: file.name }), _jsxs(StyledActionsMenu, { children: [ZoomableViewerTypes.includes(viewerType) && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "text", disabled: !file.url, children: _jsx(ZoomInIcon, { size: 18, onClick: () => setZoomFactor((prev) => prev * 1.1) }) }), _jsx(Button, { variant: "text", disabled: !file.url, children: _jsx(ZoomOutIcon, { size: 18, onClick: () => setZoomFactor((prev) => prev * 0.9) }) })] })), _jsx("a", { href: file.url, download: file.name, style: { pointerEvents: !file.url ? "none" : "auto" }, children: _jsx(Button, { variant: "text", disabled: !file.url, children: _jsx(DownloadIcon, { size: 18 }) }) })] })] }), file.url ? (_jsxs(StyledInnerContainer, { onClick: handleBackgroundClick, "data-type": viewerType, children: [viewerType === ViewerTypes.PDF && (_jsx(PdfViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Image && (_jsx(ImageViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Video && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Audio && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Office && (_jsx(OfficeViewer, { file: file, isPending: isPending })), viewerType === ViewerTypes.Text && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Code && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending }))] })) : (_jsx(StyledInnerContainer, { children: _jsxs("div", { style: {
|
|
174
|
+
margin: "auto",
|
|
175
|
+
display: "flex",
|
|
176
|
+
gap: "10px",
|
|
177
|
+
flexDirection: "column",
|
|
178
|
+
alignItems: "center",
|
|
179
|
+
}, children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading File..." })] }) }))] }) }));
|
|
180
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FileViewer";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FileViewer";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import styled from "styled-components";
|
|
13
|
+
import Loader from "../../Loader";
|
|
14
|
+
const resolveLanguage = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const { languages } = yield import("@codemirror/language-data");
|
|
16
|
+
let ext = file.ext;
|
|
17
|
+
if (!ext) {
|
|
18
|
+
ext = file.name.split(".").pop();
|
|
19
|
+
}
|
|
20
|
+
if (!ext) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const l = languages.find((lang) => lang.extensions.includes(ext));
|
|
24
|
+
if (l) {
|
|
25
|
+
return yield l.load();
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
});
|
|
29
|
+
const getFileData = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
if (!file.url)
|
|
31
|
+
return "";
|
|
32
|
+
const response = yield fetch(file.url);
|
|
33
|
+
const text = yield response.text();
|
|
34
|
+
return text;
|
|
35
|
+
});
|
|
36
|
+
const loadCodemirror = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const language = yield resolveLanguage(file);
|
|
38
|
+
const CodeMirror = yield import("@uiw/react-codemirror");
|
|
39
|
+
const { vscodeDark } = yield import("@uiw/codemirror-theme-vscode");
|
|
40
|
+
return { language, CodeMirror, theme: vscodeDark };
|
|
41
|
+
});
|
|
42
|
+
const StyledContainer = styled.div `
|
|
43
|
+
display: flex;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
|
|
46
|
+
flex: 1 1 auto;
|
|
47
|
+
height: 0px;
|
|
48
|
+
width: 100%;
|
|
49
|
+
|
|
50
|
+
.cm-theme {
|
|
51
|
+
font-size: ${(props) => props.zoomFactor ? `${props.zoomFactor * 12}px` : "12px"};
|
|
52
|
+
width: 100%;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.cm-editor {
|
|
56
|
+
border: 1px solid ${(props) => props.theme.palette.divider};
|
|
57
|
+
width: 100%;
|
|
58
|
+
height: 100%;
|
|
59
|
+
margin: 0 auto;
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
const StyledLoader = styled.div `
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
align-items: center;
|
|
67
|
+
gap: 10px;
|
|
68
|
+
`;
|
|
69
|
+
export const CodeViewer = ({ file, zoomFactor, isPending }) => {
|
|
70
|
+
const [CodeMirror, setCodeMirror] = useState(null);
|
|
71
|
+
const [language, setLanguage] = useState(null);
|
|
72
|
+
const [theme, setTheme] = useState(null);
|
|
73
|
+
const [query, setQuery] = useState({
|
|
74
|
+
data: null,
|
|
75
|
+
isLoading: false,
|
|
76
|
+
});
|
|
77
|
+
if (!query.data) {
|
|
78
|
+
if (!query.isLoading) {
|
|
79
|
+
setQuery({ data: null, isLoading: true });
|
|
80
|
+
getFileData(file).then((text) => {
|
|
81
|
+
setQuery({ data: text, isLoading: false });
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!CodeMirror) {
|
|
86
|
+
loadCodemirror(file).then((cm) => {
|
|
87
|
+
setCodeMirror(cm.CodeMirror);
|
|
88
|
+
setLanguage(cm.language);
|
|
89
|
+
setTheme(cm.theme);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const loading = query.isLoading || !CodeMirror;
|
|
93
|
+
const extensions = [];
|
|
94
|
+
if (language) {
|
|
95
|
+
extensions.push(language);
|
|
96
|
+
}
|
|
97
|
+
if (CodeMirror) {
|
|
98
|
+
extensions.push(CodeMirror.EditorView.lineWrapping);
|
|
99
|
+
}
|
|
100
|
+
if (isPending) {
|
|
101
|
+
return (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading File..." })] }));
|
|
102
|
+
}
|
|
103
|
+
return (_jsxs(StyledContainer, { zoomFactor: zoomFactor, children: [loading && (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading File..." })] })), !loading && (_jsx(CodeMirror.default, { value: query.data || "", theme: theme, extensions: extensions, readOnly: true, editable: false, onClick: (event) => {
|
|
104
|
+
event.stopPropagation();
|
|
105
|
+
} }))] }));
|
|
106
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import Loader from "../../Loader";
|
|
5
|
+
const ImageViewerContainer = styled.div `
|
|
6
|
+
height: 100%;
|
|
7
|
+
|
|
8
|
+
text-align: center;
|
|
9
|
+
padding: 10px;
|
|
10
|
+
`;
|
|
11
|
+
// Updated Image styled-component to remove max-width and max-height
|
|
12
|
+
const Image = styled.img `
|
|
13
|
+
object-fit: contain;
|
|
14
|
+
|
|
15
|
+
// set orientation
|
|
16
|
+
image-orientation: from-image;
|
|
17
|
+
|
|
18
|
+
border: 1px solid ${(props) => props.theme.palette.divider};
|
|
19
|
+
`;
|
|
20
|
+
const StyledLoader = styled.div `
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
align-items: center;
|
|
25
|
+
gap: 10px;
|
|
26
|
+
height: 100%;
|
|
27
|
+
`;
|
|
28
|
+
export const ImageViewer = ({ file, zoomFactor = 1, isPending }) => {
|
|
29
|
+
const [imageLoaded, setImageLoaded] = useState(false);
|
|
30
|
+
const [originalDimensions, setOriginalDimensions] = useState({
|
|
31
|
+
naturalWidth: 0,
|
|
32
|
+
naturalHeight: 0,
|
|
33
|
+
width: 0,
|
|
34
|
+
height: 0,
|
|
35
|
+
});
|
|
36
|
+
const handleImageLoad = (e) => {
|
|
37
|
+
setOriginalDimensions((prev) => (Object.assign(Object.assign({}, prev), { width: e.target.clientWidth, height: e.target.offsetHeight })));
|
|
38
|
+
};
|
|
39
|
+
const loadImage = () => {
|
|
40
|
+
if (!file.url)
|
|
41
|
+
return;
|
|
42
|
+
const img = document.createElement("img");
|
|
43
|
+
img.src = file.url;
|
|
44
|
+
img.onload = () => {
|
|
45
|
+
setOriginalDimensions((prev) => (Object.assign(Object.assign({}, prev), { naturalWidth: img.naturalWidth, naturalHeight: img.naturalHeight })));
|
|
46
|
+
setImageLoaded(true);
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
loadImage();
|
|
51
|
+
}, [file.url]);
|
|
52
|
+
if (isPending) {
|
|
53
|
+
return (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading Image..." })] }));
|
|
54
|
+
}
|
|
55
|
+
return (_jsxs(ImageViewerContainer, { className: "mfui-ImageViewer", children: [!imageLoaded && (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading Image..." })] })), imageLoaded && (_jsx(Image, { src: file.url, alt: file.name ? file.name : "Image", zoomFactor: zoomFactor, onLoad: handleImageLoad, height: zoomFactor === 1 ? "100%" : originalDimensions.height * zoomFactor, onClick: (e) => {
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
} }))] }));
|
|
58
|
+
};
|