@monolith-forensics/monolith-ui 1.2.71 → 1.2.72

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.
@@ -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 = itemCount * 25 < 200 ? itemCount * 25 : 200;
52
- const width = 188;
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));
@@ -54,4 +54,5 @@ export interface MenuProps {
54
54
  multiselect?: boolean;
55
55
  onMenuClose?: () => void;
56
56
  TooltipContent?: ComponentType<any>;
57
+ dropDownProps?: ComponentPropsWithoutRef<typeof StyledContent>;
57
58
  }
@@ -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: 175, maxWidth: 400 },
200
- }, defaultValue: (_j = filterDef === null || filterDef === void 0 ? void 0 : filterDef.selectOptions) === null || _j === void 0 ? void 0 : _j.filter((o) => Array.isArray(rule.value) &&
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[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.2.71",
3
+ "version": "1.2.72",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",