@monolith-forensics/monolith-ui 2.1.1-dev.3 → 2.1.1-dev.4
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.
|
@@ -130,16 +130,11 @@ const MeasuredRow = ({ children, index, setItemSize, style }) => {
|
|
|
130
130
|
};
|
|
131
131
|
export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dynamicOptionHeight, selected, TooltipContent, multiselect, enableSelectAll, enableSelectedOptionStyling, grouped, onAddNew, size, handleAddItem, handleRemoveItem, handleSetSelected, onItemSelect, renderOption, onScroll, onScrollToTop, onScrollToBottom, maxDropdownHeight = DEFAULT_DROPDOWN_MAX_HEIGHT, loading, loadingMore, }) => {
|
|
132
132
|
const [searchValue, setSearchValue] = useState("");
|
|
133
|
-
const targetElm = useRef(null);
|
|
134
133
|
const listElm = useRef(null);
|
|
135
134
|
const fixedListRef = useRef(null);
|
|
136
135
|
const variableListRef = useRef(null);
|
|
137
136
|
const hasHandledInitialSelectedScroll = useRef(false);
|
|
138
137
|
const itemSizeMap = useRef({});
|
|
139
|
-
const [viewPortDimensions, setViewPortDimensions] = useState({
|
|
140
|
-
width: 0,
|
|
141
|
-
height: 0,
|
|
142
|
-
});
|
|
143
138
|
const [, setMeasurementRevision] = useState(0);
|
|
144
139
|
const handleSearch = useDebouncedCallback((e) => {
|
|
145
140
|
setSearchValue(e.target.value);
|
|
@@ -271,32 +266,8 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
271
266
|
DROPDOWN_CONTENT_VERTICAL_PADDING -
|
|
272
267
|
searchHeight -
|
|
273
268
|
selectAllHeight);
|
|
274
|
-
const
|
|
275
|
-
const height = Math.min(estimatedHeight, availableHeight, maxListHeight);
|
|
269
|
+
const height = Math.min(estimatedHeight, maxListHeight);
|
|
276
270
|
const width = "100%";
|
|
277
|
-
useLayoutEffect(() => {
|
|
278
|
-
const target = targetElm.current;
|
|
279
|
-
if (!target)
|
|
280
|
-
return;
|
|
281
|
-
const updateDimensions = () => {
|
|
282
|
-
const nextDimensions = target.getBoundingClientRect();
|
|
283
|
-
setViewPortDimensions((currentDimensions) => {
|
|
284
|
-
const width = Math.ceil(nextDimensions.width);
|
|
285
|
-
const height = Math.floor(nextDimensions.height);
|
|
286
|
-
if (currentDimensions.width === width &&
|
|
287
|
-
currentDimensions.height === height) {
|
|
288
|
-
return currentDimensions;
|
|
289
|
-
}
|
|
290
|
-
return { width, height };
|
|
291
|
-
});
|
|
292
|
-
};
|
|
293
|
-
updateDimensions();
|
|
294
|
-
if (typeof ResizeObserver === "undefined")
|
|
295
|
-
return;
|
|
296
|
-
const observer = new ResizeObserver(updateDimensions);
|
|
297
|
-
observer.observe(target);
|
|
298
|
-
return () => observer.disconnect();
|
|
299
|
-
}, [displayItemsKey, isLoading]);
|
|
300
271
|
const setItemSize = useCallback((index, measuredSize) => {
|
|
301
272
|
var _a;
|
|
302
273
|
if (itemSizeMap.current[index] === measuredSize)
|
|
@@ -385,7 +356,7 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
385
356
|
alignItems: "center",
|
|
386
357
|
height: "100%",
|
|
387
358
|
padding: "10px 0",
|
|
388
|
-
}, children: [_jsx("div", { style: { fontSize: `${sizeTokens.supportingFontSize}px` }, children: "Loading..." }), _jsx(Loader, {})] })), !isLoading && (_jsx(ListViewPort, {
|
|
359
|
+
}, children: [_jsx("div", { style: { fontSize: `${sizeTokens.supportingFontSize}px` }, children: "Loading..." }), _jsx(Loader, {})] })), !isLoading && (_jsx(ListViewPort, { children: dynamicListEnabled ? (_jsx(VariableSizeList, { ref: variableListRef, itemData: displayItems, overscanCount: overscanCount, height: height, width: width, itemCount: itemCount, itemSize: getDynamicItemSize, outerElementType: ListScroller, outerRef: listElm, children: ({ data, index, style }) => {
|
|
389
360
|
const item = data === null || data === void 0 ? void 0 : data[index];
|
|
390
361
|
if (!item)
|
|
391
362
|
return null;
|