@monolith-forensics/monolith-ui 1.2.71 → 1.2.73
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/DropDownMenu/DropDownMenu.d.ts +1 -1
- package/dist/DropDownMenu/DropDownMenu.js +2 -2
- package/dist/DropDownMenu/components/MenuComponent.js +3 -3
- package/dist/DropDownMenu/components/MenuItemList.js +23 -5
- package/dist/DropDownMenu/types.d.ts +1 -0
- package/dist/QueryFilter/QueryFilter.js +3 -3
- package/dist/QueryFilter/types.d.ts +3 -0
- package/dist/QueryFilter/useFilterDefinitions.d.ts +2 -1
- package/dist/QueryFilter/useFilterDefinitions.js +39 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DropDownMenuProps } from "./types";
|
|
2
|
-
declare const DropDownMenu: ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, }: DropDownMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const DropDownMenu: ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, dropDownProps, }: DropDownMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default DropDownMenu;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useRef, useState } from "react";
|
|
3
3
|
import { useDebouncedCallback } from "use-debounce";
|
|
4
4
|
import { Menu, MenuItemList, SearchInput, StyledInnerItemContainer, } from "./components";
|
|
5
|
-
const DropDownMenu = ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, }) => {
|
|
5
|
+
const DropDownMenu = ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, dropDownProps, }) => {
|
|
6
6
|
var _a;
|
|
7
7
|
const isObjectArray = (_a = Object.keys((data === null || data === void 0 ? void 0 : data[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
|
|
8
8
|
const [selected, setSelected] = useState(defaultValue || []);
|
|
@@ -30,6 +30,6 @@ const DropDownMenu = ({ data, children, defaultValue, variant, arrow, size, sear
|
|
|
30
30
|
const handleMenuClose = () => {
|
|
31
31
|
setSearchValue("");
|
|
32
32
|
};
|
|
33
|
-
return (_jsx(Menu, { label: children, arrow: arrow, buttonSize: size, variant: variant, multiselect: multiselect, buttonProps: buttonProps, onMenuClose: handleMenuClose, children: _jsxs(StyledInnerItemContainer, { children: [loading && _jsx("div", { children: "Loading..." }), searchable && (_jsx(SearchInput, { ref: searchInputRef, variant: "outlined", size: size, placeholder: "Search", defaultValue: searchValue, onChange: handleSearch })), !loading && (_jsx(MenuItemList, { menuItems: data, searchable: searchable, searchValue: searchValue, isObjectArray: isObjectArray, selected: selected, TooltipContent: TooltipContent, multiselect: multiselect, size: size, handleAddItem: handleAddItem, handleRemoveItem: handleRemoveItem, onItemSelect: onItemSelect, renderOption: renderOption, onScroll: onScroll }))] }) }));
|
|
33
|
+
return (_jsx(Menu, { label: children, arrow: arrow, buttonSize: size, variant: variant, multiselect: multiselect, buttonProps: buttonProps, onMenuClose: handleMenuClose, dropDownProps: dropDownProps, children: _jsxs(StyledInnerItemContainer, { children: [loading && _jsx("div", { children: "Loading..." }), searchable && (_jsx(SearchInput, { ref: searchInputRef, variant: "outlined", size: size, placeholder: "Search", defaultValue: searchValue, onChange: handleSearch })), !loading && (_jsx(MenuItemList, { menuItems: data, searchable: searchable, searchValue: searchValue, isObjectArray: isObjectArray, selected: selected, TooltipContent: TooltipContent, multiselect: multiselect, size: size, handleAddItem: handleAddItem, handleRemoveItem: handleRemoveItem, onItemSelect: onItemSelect, renderOption: renderOption, onScroll: onScroll }))] }) }));
|
|
34
34
|
};
|
|
35
35
|
export default DropDownMenu;
|
|
@@ -14,11 +14,11 @@ import { forwardRef, useContext, useEffect, useRef, useState } from "react";
|
|
|
14
14
|
import { autoUpdate, flip, FloatingFocusManager, FloatingList, FloatingNode, FloatingPortal, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useHover, useInteractions, useListItem, useListNavigation, useMergeRefs, useRole, useTypeahead, } from "@floating-ui/react";
|
|
15
15
|
import { ChevronDownIcon, ChevronRightIcon } from "lucide-react";
|
|
16
16
|
import { MenuContext } from "./MenuContext";
|
|
17
|
-
import { MenuItem } from "./MenuItem";
|
|
18
17
|
import { StyledFloatContainer } from "./StyledFloatContainer";
|
|
19
18
|
import { StyledContent } from "./StyledContent";
|
|
19
|
+
import { MenuItem } from "./MenuItem";
|
|
20
20
|
export const MenuComponent = forwardRef((_a, forwardedRef) => {
|
|
21
|
-
var { children, label, arrow, size, buttonSize, variant, buttonProps, buttonRender, multiselect, onMenuClose } = _a, props = __rest(_a, ["children", "label", "arrow", "size", "buttonSize", "variant", "buttonProps", "buttonRender", "multiselect", "onMenuClose"]);
|
|
21
|
+
var { children, label, arrow, size, buttonSize, variant, buttonProps, buttonRender, multiselect, onMenuClose, dropDownProps } = _a, props = __rest(_a, ["children", "label", "arrow", "size", "buttonSize", "variant", "buttonProps", "buttonRender", "multiselect", "onMenuClose", "dropDownProps"]);
|
|
22
22
|
const [isOpen, setIsOpen] = useState(false);
|
|
23
23
|
const [hasFocusInside, setHasFocusInside] = useState(false);
|
|
24
24
|
const [activeIndex, setActiveIndex] = useState(null);
|
|
@@ -113,5 +113,5 @@ export const MenuComponent = forwardRef((_a, forwardedRef) => {
|
|
|
113
113
|
getItemProps,
|
|
114
114
|
setHasFocusInside,
|
|
115
115
|
isOpen,
|
|
116
|
-
}, children: _jsx(FloatingList, { elementsRef: elementsRef, labelsRef: labelsRef, children: isOpen && (_jsx(FloatingPortal, { children: _jsx(FloatingFocusManager, { context: context, modal: false, initialFocus: isNested ? -1 : 0, returnFocus: !isNested, children: _jsx(StyledFloatContainer, Object.assign({ ref: refs.setFloating, className: "Menu", style: floatingStyles }, getFloatingProps(), { children: _jsx(StyledContent, { className: "mfFloatingContent", children: children }) })) }) })) }) })] }));
|
|
116
|
+
}, children: _jsx(FloatingList, { elementsRef: elementsRef, labelsRef: labelsRef, children: isOpen && (_jsx(FloatingPortal, { children: _jsx(FloatingFocusManager, { context: context, modal: false, initialFocus: isNested ? -1 : 0, returnFocus: !isNested, children: _jsx(StyledFloatContainer, Object.assign({ ref: refs.setFloating, className: "Menu", style: floatingStyles }, getFloatingProps(), { children: _jsx(StyledContent, Object.assign({ className: "mfFloatingContent" }, dropDownProps, { children: children })) })) }) })) }) })] }));
|
|
117
117
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useLayoutEffect, useRef } from "react";
|
|
2
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { FixedSizeList } from "react-window";
|
|
3
5
|
import CheckBox from "../../CheckBox";
|
|
4
6
|
import DropDownMenu from "../DropDownMenu";
|
|
5
7
|
import { MenuItem } from "./MenuItem";
|
|
6
|
-
import styled from "styled-components";
|
|
7
|
-
import { FixedSizeList } from "react-window";
|
|
8
8
|
const filterMenuItems = (menuItems, searchValue) => {
|
|
9
9
|
return menuItems.filter((item) => {
|
|
10
10
|
var _a, _b, _c;
|
|
@@ -23,6 +23,10 @@ export const MenuItemList = ({ menuItems, searchable, searchValue = "", isObject
|
|
|
23
23
|
const abortController = new AbortController();
|
|
24
24
|
const targetElm = useRef(null);
|
|
25
25
|
const listElm = useRef(null);
|
|
26
|
+
const [viewPortDimensions, setViewPortDimensions] = useState({
|
|
27
|
+
width: 0,
|
|
28
|
+
height: 0,
|
|
29
|
+
});
|
|
26
30
|
const handleItemClick = (item, isSelected) => {
|
|
27
31
|
var _a;
|
|
28
32
|
if (multiselect) {
|
|
@@ -45,11 +49,25 @@ export const MenuItemList = ({ menuItems, searchable, searchValue = "", isObject
|
|
|
45
49
|
abortController.abort();
|
|
46
50
|
};
|
|
47
51
|
}, [filteredItems, listElm.current, onScroll]);
|
|
52
|
+
useLayoutEffect(() => {
|
|
53
|
+
var _a;
|
|
54
|
+
if (targetElm.current) {
|
|
55
|
+
const viewPortDimensions = (_a = targetElm.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
56
|
+
setViewPortDimensions({
|
|
57
|
+
width: viewPortDimensions.width,
|
|
58
|
+
height: viewPortDimensions.height,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, [targetElm.current]);
|
|
48
62
|
const overscanCount = 10;
|
|
49
63
|
const itemHeight = 25;
|
|
50
64
|
const itemCount = (filteredItems === null || filteredItems === void 0 ? void 0 : filteredItems.length) || 0;
|
|
51
|
-
const height =
|
|
52
|
-
|
|
65
|
+
const height = viewPortDimensions.height
|
|
66
|
+
? viewPortDimensions.height
|
|
67
|
+
: itemCount * itemHeight < 200
|
|
68
|
+
? itemCount * itemHeight
|
|
69
|
+
: 200;
|
|
70
|
+
const width = viewPortDimensions.width || 188;
|
|
53
71
|
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 }) => {
|
|
54
72
|
const item = (data === null || data === void 0 ? void 0 : data[index]) || {};
|
|
55
73
|
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));
|
|
@@ -130,7 +130,7 @@ const dateFormatResolver = (resolution) => {
|
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
const ValueEditor = ({ rule, inputType, filterDef, onChange }) => {
|
|
133
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
133
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
134
134
|
const theme = useTheme();
|
|
135
135
|
const handleInputChange = useDebouncedCallback((e) => {
|
|
136
136
|
const value = e.target.value;
|
|
@@ -196,8 +196,8 @@ const ValueEditor = ({ rule, inputType, filterDef, onChange }) => {
|
|
|
196
196
|
: theme.palette.text.secondary,
|
|
197
197
|
},
|
|
198
198
|
}, dropDownProps: {
|
|
199
|
-
style: { width:
|
|
200
|
-
}, defaultValue: (
|
|
199
|
+
style: Object.assign({ width: 200, maxWidth: 400 }, (_j = filterDef === null || filterDef === void 0 ? void 0 : filterDef.dropDownOptions) === null || _j === void 0 ? void 0 : _j.style),
|
|
200
|
+
}, defaultValue: (_k = filterDef === null || filterDef === void 0 ? void 0 : filterDef.selectOptions) === null || _k === void 0 ? void 0 : _k.filter((o) => Array.isArray(rule.value) &&
|
|
201
201
|
!!rule.value.find((v) => v == o.value)), onChange: handleMultiSelectChange, children: display }));
|
|
202
202
|
default:
|
|
203
203
|
return (_jsx(StyledInput, { placeholder: "Enter Value...", onChange: handleInputChange }));
|
|
@@ -32,6 +32,9 @@ export interface FilterDefinition {
|
|
|
32
32
|
isoString?: boolean;
|
|
33
33
|
placeholder?: string;
|
|
34
34
|
selectOptions?: DropDownItem[];
|
|
35
|
+
dropDownOptions?: {
|
|
36
|
+
style?: React.CSSProperties;
|
|
37
|
+
};
|
|
35
38
|
editorType?: EditorType;
|
|
36
39
|
query?: UseQueryOptions & {
|
|
37
40
|
select: (data: unknown) => DropDownItem[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FilterDefinition } from "./types";
|
|
2
2
|
export interface UserFilterDefinitionsParams {
|
|
3
3
|
filterDef: FilterDefinition[];
|
|
4
|
+
overrides?: Partial<FilterDefinition>[];
|
|
4
5
|
}
|
|
5
6
|
export type UseFilterDefinitionsType = (p: UserFilterDefinitionsParams) => FilterDefinition[];
|
|
6
|
-
export declare function useFilterDefinitions({ filterDef, }: UserFilterDefinitionsParams): FilterDefinition[];
|
|
7
|
+
export declare function useFilterDefinitions({ filterDef, overrides, }: UserFilterDefinitionsParams): FilterDefinition[];
|
|
@@ -1,7 +1,43 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { useQueries } from "@tanstack/react-query";
|
|
2
|
-
|
|
13
|
+
const mergeOverrides = (filterDef, overrides) => {
|
|
14
|
+
return filterDef.map((f) => {
|
|
15
|
+
const override = overrides.find((o) => o.dataField === f.dataField);
|
|
16
|
+
if (!override) {
|
|
17
|
+
return f;
|
|
18
|
+
}
|
|
19
|
+
const { query, dropDownOptions } = override, rest = __rest(override, ["query", "dropDownOptions"]);
|
|
20
|
+
// Handle merge directly on query and dropDownOptions
|
|
21
|
+
// prevents overriding the entire query object
|
|
22
|
+
// allows user to override specific properties
|
|
23
|
+
if (query) {
|
|
24
|
+
f.query = Object.assign(Object.assign({}, query), override.query);
|
|
25
|
+
}
|
|
26
|
+
if (dropDownOptions) {
|
|
27
|
+
f.dropDownOptions = Object.assign(Object.assign({}, dropDownOptions), override.dropDownOptions);
|
|
28
|
+
}
|
|
29
|
+
// Merge override with original filter def
|
|
30
|
+
return Object.assign(Object.assign({}, f), rest);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
export function useFilterDefinitions({ filterDef, overrides, }) {
|
|
34
|
+
let _filterDef = filterDef;
|
|
35
|
+
if (!!overrides) {
|
|
36
|
+
_filterDef = mergeOverrides(filterDef, overrides);
|
|
37
|
+
}
|
|
3
38
|
// Keeps track of filters that have queries
|
|
4
39
|
const queryIndex = [];
|
|
40
|
+
// Get query options from filter defs
|
|
5
41
|
const queries = filterDef
|
|
6
42
|
.filter((f, i) => {
|
|
7
43
|
// Track array index of filter def that has a query
|
|
@@ -10,9 +46,11 @@ export function useFilterDefinitions({ filterDef, }) {
|
|
|
10
46
|
return hasQuery;
|
|
11
47
|
})
|
|
12
48
|
.map((filter) => filter.query);
|
|
49
|
+
// run queries from filter defs
|
|
13
50
|
const result = useQueries({
|
|
14
51
|
queries,
|
|
15
52
|
});
|
|
53
|
+
// Add useQueries result data to filter def as options
|
|
16
54
|
queryIndex.forEach((index, i) => {
|
|
17
55
|
var _a;
|
|
18
56
|
// User query index to add useQueries result data to filter def as options
|