@monolith-forensics/monolith-ui 1.8.1-dev.1 → 1.8.1-dev.3

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.
Files changed (107) hide show
  1. package/dist/Calendar/Calendar.d.ts +4 -1
  2. package/dist/Calendar/Calendar.js +126 -50
  3. package/dist/Calendar/CalendarStyles.d.ts +3 -2
  4. package/dist/Calendar/CalendarStyles.js +67 -25
  5. package/dist/Calendar/calendarHelpers.d.ts +1 -1
  6. package/dist/CheckBox/CheckBox.js +35 -4
  7. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +41 -0
  8. package/dist/DateTimeRangePicker/DateTimeRangePicker.js +363 -0
  9. package/dist/DateTimeRangePicker/index.d.ts +2 -0
  10. package/dist/DateTimeRangePicker/index.js +2 -0
  11. package/dist/DropDownMenu/DropDownMenu.js +25 -15
  12. package/dist/DropDownMenu/components/MenuComponent.js +6 -1
  13. package/dist/DropDownMenu/components/MenuItem.d.ts +2 -0
  14. package/dist/DropDownMenu/components/MenuItem.js +22 -9
  15. package/dist/DropDownMenu/components/MenuItemList.d.ts +3 -0
  16. package/dist/DropDownMenu/components/MenuItemList.js +186 -63
  17. package/dist/DropDownMenu/components/StyledContent.js +1 -2
  18. package/dist/DropDownMenu/types.d.ts +3 -0
  19. package/dist/FileViewer/viewers/ImageViewer.js +75 -18
  20. package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +1 -0
  21. package/dist/QueryFilter/DefaultOperators.d.ts +1 -76
  22. package/dist/QueryFilter/DefaultOperators.js +1 -21
  23. package/dist/QueryFilter/QueryFilter.constants.d.ts +134 -0
  24. package/dist/QueryFilter/QueryFilter.constants.js +39 -0
  25. package/dist/QueryFilter/QueryFilter.d.ts +1 -1
  26. package/dist/QueryFilter/QueryFilter.js +3 -303
  27. package/dist/QueryFilter/QueryFilter.lib.d.ts +14 -0
  28. package/dist/QueryFilter/QueryFilter.lib.js +84 -0
  29. package/dist/QueryFilter/QueryFilter.styled.d.ts +89 -0
  30. package/dist/QueryFilter/QueryFilter.styled.js +184 -0
  31. package/dist/QueryFilter/QueryFilter.types.d.ts +61 -0
  32. package/dist/QueryFilter/QueryFilter.types.js +1 -0
  33. package/dist/QueryFilter/components/MultiSelectEditor.d.ts +7 -0
  34. package/dist/QueryFilter/components/MultiSelectEditor.js +44 -0
  35. package/dist/QueryFilter/components/RuleChip.d.ts +8 -0
  36. package/dist/QueryFilter/components/RuleChip.js +37 -0
  37. package/dist/QueryFilter/components/Rules.d.ts +11 -0
  38. package/dist/QueryFilter/components/Rules.js +41 -0
  39. package/dist/QueryFilter/components/UnavailableRuleChip.d.ts +5 -0
  40. package/dist/QueryFilter/components/UnavailableRuleChip.js +7 -0
  41. package/dist/QueryFilter/components/ValueEditor.d.ts +7 -0
  42. package/dist/QueryFilter/components/ValueEditor.js +45 -0
  43. package/dist/QueryFilter/components/ValueSelector.d.ts +7 -0
  44. package/dist/QueryFilter/components/ValueSelector.js +34 -0
  45. package/dist/QueryFilter/components/index.d.ts +6 -0
  46. package/dist/QueryFilter/components/index.js +6 -0
  47. package/dist/QueryFilter/index.d.ts +3 -2
  48. package/dist/QueryFilter/index.js +3 -2
  49. package/dist/QueryFilter/types.d.ts +1 -52
  50. package/dist/QueryFilter/types.js +1 -1
  51. package/dist/QueryFilter/useQueryFilter.d.ts +1 -1
  52. package/dist/QueryFilter/useQueryFilter.js +23 -19
  53. package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +5 -15
  54. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.d.ts +3 -0
  55. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +241 -0
  56. package/dist/RichTextEditor/Plugins/UploadImagesPlugin.d.ts +15 -0
  57. package/dist/RichTextEditor/Plugins/UploadImagesPlugin.js +115 -51
  58. package/dist/RichTextEditor/Plugins/index.d.ts +1 -0
  59. package/dist/RichTextEditor/Plugins/index.js +1 -0
  60. package/dist/RichTextEditor/RichTextEditor.d.ts +3 -2
  61. package/dist/RichTextEditor/RichTextEditor.js +302 -35
  62. package/dist/SuperDatePicker/SuperDatePicker.constants.d.ts +24 -0
  63. package/dist/SuperDatePicker/SuperDatePicker.constants.js +30 -0
  64. package/dist/SuperDatePicker/SuperDatePicker.d.ts +3 -0
  65. package/dist/SuperDatePicker/SuperDatePicker.js +31 -0
  66. package/dist/SuperDatePicker/SuperDatePicker.lib.d.ts +17 -0
  67. package/dist/SuperDatePicker/SuperDatePicker.lib.js +206 -0
  68. package/dist/SuperDatePicker/SuperDatePicker.styled.d.ts +60 -0
  69. package/dist/SuperDatePicker/SuperDatePicker.styled.js +256 -0
  70. package/dist/SuperDatePicker/SuperDatePicker.types.d.ts +48 -0
  71. package/dist/SuperDatePicker/SuperDatePicker.types.js +1 -0
  72. package/dist/SuperDatePicker/components/CommonPresetGroups.d.ts +7 -0
  73. package/dist/SuperDatePicker/components/CommonPresetGroups.js +6 -0
  74. package/dist/SuperDatePicker/components/EndpointCalendarDropdown.d.ts +10 -0
  75. package/dist/SuperDatePicker/components/EndpointCalendarDropdown.js +9 -0
  76. package/dist/SuperDatePicker/components/EndpointDateInput.d.ts +16 -0
  77. package/dist/SuperDatePicker/components/EndpointDateInput.js +26 -0
  78. package/dist/SuperDatePicker/components/EndpointPopover.d.ts +18 -0
  79. package/dist/SuperDatePicker/components/EndpointPopover.js +11 -0
  80. package/dist/SuperDatePicker/components/QuickRangeDropdown.d.ts +14 -0
  81. package/dist/SuperDatePicker/components/QuickRangeDropdown.js +19 -0
  82. package/dist/SuperDatePicker/components/QuickRangePopover.d.ts +18 -0
  83. package/dist/SuperDatePicker/components/QuickRangePopover.js +12 -0
  84. package/dist/SuperDatePicker/components/index.d.ts +6 -0
  85. package/dist/SuperDatePicker/components/index.js +6 -0
  86. package/dist/SuperDatePicker/index.d.ts +3 -0
  87. package/dist/SuperDatePicker/index.js +3 -0
  88. package/dist/SuperDatePicker/useSuperDatePicker.d.ts +32 -0
  89. package/dist/SuperDatePicker/useSuperDatePicker.js +125 -0
  90. package/dist/Table/ColumnResizer.d.ts +6 -9
  91. package/dist/Table/ColumnResizer.js +30 -10
  92. package/dist/Table/TableComponents.js +14 -10
  93. package/dist/Table/TableHeader.js +31 -16
  94. package/dist/Table/TableMenu/TableMenu.js +1 -1
  95. package/dist/Table/TableProvider.js +91 -4
  96. package/dist/Table/TableRow.js +19 -12
  97. package/dist/Table/Utils/index.d.ts +0 -1
  98. package/dist/Table/Utils/index.js +0 -1
  99. package/dist/Table/types.d.ts +6 -19
  100. package/dist/TagBox/TagBox.d.ts +1 -1
  101. package/dist/TagBox/TagBox.js +6 -6
  102. package/dist/TagBox/types.d.ts +1 -0
  103. package/dist/TextArea/TextArea.js +5 -0
  104. package/dist/index.d.ts +2 -0
  105. package/dist/index.js +1 -0
  106. package/dist/theme/variants.js +2 -0
  107. package/package.json +22 -18
@@ -10,9 +10,9 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
- import { useLayoutEffect, useRef, useState } from "react";
13
+ import { useCallback, useLayoutEffect, useMemo, useRef, useState, } from "react";
14
14
  import styled from "styled-components";
15
- import { FixedSizeList } from "react-window";
15
+ import { FixedSizeList, VariableSizeList } from "react-window";
16
16
  import { Plus } from "lucide-react";
17
17
  import CheckBox from "../../CheckBox";
18
18
  import { getControlSizeTokens } from "../../core";
@@ -22,6 +22,7 @@ import { useInfiniteQuery } from "@tanstack/react-query";
22
22
  import { useDebouncedCallback } from "use-debounce";
23
23
  import { SearchInput } from "./SearchInput";
24
24
  import Loader from "../../Loader";
25
+ const getItemKey = (item) => item && typeof item === "object" && "value" in item ? item.value : item;
25
26
  const filterMenuItems = (menuItems, searchValue) => {
26
27
  return menuItems.filter((item) => {
27
28
  var _a, _b, _c;
@@ -55,6 +56,28 @@ const buildGroupedDisplayList = (items) => {
55
56
  const ListViewPort = styled.div.attrs({ className: "ListViewPort" }) `
56
57
  display: flex;
57
58
  flex-direction: column;
59
+ width: 100%;
60
+ `;
61
+ const ListScroller = styled.div `
62
+ scrollbar-color: ${({ theme }) => `${theme.scrollbar.thumb} ${theme.scrollbar.track}`};
63
+ scrollbar-gutter: stable;
64
+ scrollbar-width: thin;
65
+
66
+ &::-webkit-scrollbar {
67
+ width: 6px;
68
+ }
69
+
70
+ &::-webkit-scrollbar-track {
71
+ background: ${(props) => props.theme.scrollbar.track};
72
+ }
73
+
74
+ &::-webkit-scrollbar-thumb {
75
+ background: ${(props) => props.theme.scrollbar.thumb};
76
+ }
77
+
78
+ &::-webkit-scrollbar-thumb:hover {
79
+ background: ${(props) => props.theme.scrollbar.thumbHover};
80
+ }
58
81
  `;
59
82
  const GroupHeader = styled.div `
60
83
  display: flex;
@@ -77,17 +100,41 @@ const GroupHeader = styled.div `
77
100
  min-width: fit-content;
78
101
  }
79
102
  `;
80
- export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, selected, TooltipContent, multiselect, grouped, onAddNew, size, handleAddItem, handleRemoveItem, onItemSelect, renderOption, onScroll, onScrollToTop, onScrollToBottom, query, }) => {
81
- var _a;
103
+ const MeasuredRow = ({ children, index, setItemSize, style }) => {
104
+ const rowRef = useRef(null);
105
+ useLayoutEffect(() => {
106
+ const row = rowRef.current;
107
+ if (!row)
108
+ return;
109
+ const updateSize = () => {
110
+ const measuredHeight = Math.ceil(row.getBoundingClientRect().height);
111
+ if (measuredHeight > 0) {
112
+ setItemSize(index, measuredHeight);
113
+ }
114
+ };
115
+ updateSize();
116
+ if (typeof ResizeObserver === "undefined")
117
+ return;
118
+ const observer = new ResizeObserver(updateSize);
119
+ observer.observe(row);
120
+ return () => observer.disconnect();
121
+ }, [children, index, setItemSize]);
122
+ return (_jsx("div", { style: Object.assign(Object.assign({}, style), { overflow: "visible" }), children: _jsx("div", { ref: rowRef, children: children }) }));
123
+ };
124
+ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dynamicOptionHeight, selected, TooltipContent, multiselect, enableSelectAll, grouped, onAddNew, size, handleAddItem, handleRemoveItem, handleSetSelected, onItemSelect, renderOption, onScroll, onScrollToTop, onScrollToBottom, query, }) => {
82
125
  const [searchValue, setSearchValue] = useState("");
83
- const _b = query !== null && query !== void 0 ? query : {}, { queryKey, queryFn, getNextPageParam, initialPageParam } = _b, rest = __rest(_b, ["queryKey", "queryFn", "getNextPageParam", "initialPageParam"]);
84
- const abortController = new AbortController();
126
+ const _a = query !== null && query !== void 0 ? query : {}, { queryKey, queryFn, getNextPageParam, initialPageParam } = _a, rest = __rest(_a, ["queryKey", "queryFn", "getNextPageParam", "initialPageParam"]);
85
127
  const targetElm = useRef(null);
86
128
  const listElm = useRef(null);
129
+ const fixedListRef = useRef(null);
130
+ const variableListRef = useRef(null);
131
+ const hasHandledInitialSelectedScroll = useRef(false);
132
+ const itemSizeMap = useRef({});
87
133
  const [viewPortDimensions, setViewPortDimensions] = useState({
88
134
  width: 0,
89
135
  height: 0,
90
136
  });
137
+ const [, setMeasurementRevision] = useState(0);
91
138
  const { data: infiniteQueryResult, isLoading: isLoadingInfiniteQuery, fetchNextPage, } = useInfiniteQuery(Object.assign({ queryKey: (queryKey === null || queryKey === void 0 ? void 0 : queryKey({ search: searchValue })) || [], queryFn: queryFn, getNextPageParam: (query === null || query === void 0 ? void 0 : query.getNextPageParam) || (() => undefined), initialPageParam: (query === null || query === void 0 ? void 0 : query.initialPageParam) || 1, enabled: !!query }, rest));
92
139
  const infinteOptionsData = infiniteQueryResult;
93
140
  const infiniteSelectOptions = infinteOptionsData || [];
@@ -105,6 +152,9 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, se
105
152
  if (multiselect) {
106
153
  isSelected ? handleRemoveItem(item) : handleAddItem(item);
107
154
  }
155
+ else {
156
+ handleAddItem(item);
157
+ }
108
158
  onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(item);
109
159
  (_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
110
160
  };
@@ -135,39 +185,55 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, se
135
185
  }
136
186
  return items;
137
187
  })();
138
- const isObjectArray = (_a = Object.keys((visibleItems === null || visibleItems === void 0 ? void 0 : visibleItems[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
188
+ const selectedKeys = useMemo(() => new Set((selected || []).map(getItemKey)), [selected]);
189
+ const isItemSelected = (item) => selectedKeys.has(getItemKey(item));
190
+ const selectableItems = useMemo(() => displayItems.filter((item) => !item._isGroupHeader &&
191
+ !item._isAddNew &&
192
+ !item.disabled &&
193
+ !item.items), [displayItems]);
194
+ const selectableKeys = useMemo(() => new Set(selectableItems.map(getItemKey)), [selectableItems]);
195
+ const selectedSelectableItems = useMemo(() => selectableItems.filter((item) => selectedKeys.has(getItemKey(item))), [selectableItems, selectedKeys]);
196
+ const allSelectableItemsSelected = selectableItems.length > 0 &&
197
+ selectedSelectableItems.length === selectableItems.length;
198
+ const someSelectableItemsSelected = selectedSelectableItems.length > 0 && !allSelectableItemsSelected;
199
+ const selectedDisplayIndex = displayItems.findIndex((item) => {
200
+ if (item._isGroupHeader || item._isAddNew)
201
+ return false;
202
+ return isItemSelected(item);
203
+ });
204
+ const selectedDisplayKey = selected === null || selected === void 0 ? void 0 : selected.map(getItemKey).join("|");
139
205
  const isLoading = isLoadingInfiniteQuery;
140
- const handleOnScroll = (event) => {
206
+ const handleOnScroll = useCallback((event) => {
141
207
  const scrollTolerance = 15;
142
208
  onScroll === null || onScroll === void 0 ? void 0 : onScroll(event);
143
209
  const { scrollTop, scrollHeight, clientHeight } = event.currentTarget;
144
- // scroll to top
145
210
  if (scrollTop <= scrollTolerance) {
146
211
  onScrollToTop === null || onScrollToTop === void 0 ? void 0 : onScrollToTop(event);
147
212
  }
148
- // Scroll to bottom
149
213
  if (scrollHeight - scrollTop <= clientHeight + scrollTolerance) {
150
214
  onScrollToBottom === null || onScrollToBottom === void 0 ? void 0 : onScrollToBottom(event);
151
215
  debouncedFetchNextPage();
152
216
  }
217
+ }, [debouncedFetchNextPage, onScroll, onScrollToBottom, onScrollToTop]);
218
+ const handleToggleSelectAll = () => {
219
+ if (selectableItems.length === 0)
220
+ return;
221
+ const currentSelected = selected || [];
222
+ if (allSelectableItemsSelected) {
223
+ const nextSelected = currentSelected.filter((selectedItem) => !selectableKeys.has(getItemKey(selectedItem)));
224
+ handleSetSelected(nextSelected, selectedSelectableItems);
225
+ return;
226
+ }
227
+ const itemsToAdd = selectableItems.filter((item) => !isItemSelected(item));
228
+ handleSetSelected([...currentSelected, ...itemsToAdd], itemsToAdd);
153
229
  };
154
230
  useLayoutEffect(() => {
155
- if (listElm.current) {
156
- listElm.current.addEventListener("scroll", (e) => handleOnScroll(e));
157
- }
158
- // Event cleanup
159
- return () => {
160
- abortController.abort();
161
- };
162
- }, [
163
- filteredItems,
164
- listElm.current,
165
- isLoading,
166
- onScroll,
167
- onScrollToTop,
168
- onScrollToBottom,
169
- handleOnScroll,
170
- ]);
231
+ const list = listElm.current;
232
+ if (!list)
233
+ return;
234
+ list.addEventListener("scroll", handleOnScroll);
235
+ return () => list.removeEventListener("scroll", handleOnScroll);
236
+ }, [dynamicOptionHeight, handleOnScroll, isLoading, renderOption]);
171
237
  useLayoutEffect(() => {
172
238
  var _a;
173
239
  if (targetElm.current) {
@@ -181,19 +247,101 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, se
181
247
  const overscanCount = 10;
182
248
  const sizeTokens = getControlSizeTokens(size || "sm");
183
249
  const itemHeight = sizeTokens.menuRowHeight;
250
+ const dynamicListEnabled = dynamicOptionHeight !== null && dynamicOptionHeight !== void 0 ? dynamicOptionHeight : Boolean(renderOption);
251
+ const estimatedDynamicItemHeight = itemHeight + 16;
184
252
  const itemCount = (displayItems === null || displayItems === void 0 ? void 0 : displayItems.length) || 0;
253
+ const displayItemsKey = displayItems
254
+ .map((item) => `${item.value}:${item.label}:${item._isGroupHeader ? "g" : "i"}`)
255
+ .join("|");
256
+ const getDynamicItemSize = (index) => {
257
+ var _a;
258
+ return itemSizeMap.current[index] ||
259
+ (((_a = displayItems[index]) === null || _a === void 0 ? void 0 : _a._isGroupHeader) ? itemHeight : estimatedDynamicItemHeight);
260
+ };
261
+ const estimatedHeight = dynamicListEnabled
262
+ ? displayItems.reduce((total, _, index) => total + getDynamicItemSize(index), 0)
263
+ : itemCount * itemHeight;
185
264
  const height = viewPortDimensions.height
186
265
  ? viewPortDimensions.height
187
- : itemCount * itemHeight < 200
188
- ? itemCount * itemHeight
266
+ : estimatedHeight < 200
267
+ ? estimatedHeight
189
268
  : 200;
190
- const width = viewPortDimensions.width || 188;
269
+ const width = "100%";
270
+ const setItemSize = useCallback((index, measuredSize) => {
271
+ var _a;
272
+ if (itemSizeMap.current[index] === measuredSize)
273
+ return;
274
+ itemSizeMap.current = Object.assign(Object.assign({}, itemSizeMap.current), { [index]: measuredSize });
275
+ (_a = variableListRef.current) === null || _a === void 0 ? void 0 : _a.resetAfterIndex(index);
276
+ setMeasurementRevision((revision) => revision + 1);
277
+ }, []);
278
+ useLayoutEffect(() => {
279
+ var _a;
280
+ itemSizeMap.current = {};
281
+ (_a = variableListRef.current) === null || _a === void 0 ? void 0 : _a.resetAfterIndex(0, true);
282
+ setMeasurementRevision((revision) => revision + 1);
283
+ }, [displayItemsKey, dynamicListEnabled]);
284
+ useLayoutEffect(() => {
285
+ var _a, _b, _c, _d;
286
+ if (multiselect) {
287
+ if (hasHandledInitialSelectedScroll.current || itemCount === 0) {
288
+ return;
289
+ }
290
+ hasHandledInitialSelectedScroll.current = true;
291
+ if (selectedDisplayIndex < 0)
292
+ return;
293
+ (_a = fixedListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToItem(selectedDisplayIndex, "smart");
294
+ (_b = variableListRef.current) === null || _b === void 0 ? void 0 : _b.scrollToItem(selectedDisplayIndex, "smart");
295
+ return;
296
+ }
297
+ if (selectedDisplayIndex < 0)
298
+ return;
299
+ (_c = fixedListRef.current) === null || _c === void 0 ? void 0 : _c.scrollToItem(selectedDisplayIndex, "smart");
300
+ (_d = variableListRef.current) === null || _d === void 0 ? void 0 : _d.scrollToItem(selectedDisplayIndex, "smart");
301
+ }, [
302
+ displayItemsKey,
303
+ itemCount,
304
+ multiselect,
305
+ selectedDisplayIndex,
306
+ selectedDisplayKey,
307
+ ]);
308
+ const renderDisplayItem = (item, index, style) => {
309
+ if (item._isGroupHeader) {
310
+ return (_jsxs(GroupHeader, { "$size": size, style: style, children: [_jsx("span", { className: "group-line" }), _jsx("span", { className: "group-label", children: item.label }), _jsx("span", { className: "group-line" })] }, item.value));
311
+ }
312
+ if (item._isAddNew) {
313
+ return (_jsx(MenuItem, { className: "MenuItem", size: size, leftSection: _jsx(Plus, { size: 14 }), onClick: (e) => {
314
+ e.preventDefault();
315
+ e.stopPropagation();
316
+ onAddNew === null || onAddNew === void 0 ? void 0 : onAddNew(item.value);
317
+ }, style: style, children: item.label }, "__add_new__"));
318
+ }
319
+ const isSelected = isItemSelected(item);
320
+ if (item.items) {
321
+ return (_jsx(DropDownMenu, { data: item.items, size: size, buttonProps: style ? Object.assign({ style }, item) : Object.assign({}, item), disabled: item.disabled, dynamicOptionHeight: dynamicListEnabled, children: item.label }));
322
+ }
323
+ return (_jsx(MenuItem, { className: "MenuItem", itemData: item, TooltipContent: TooltipContent, "data-selected": !multiselect && isSelected, "data-disabled": item.disabled, disabled: item.disabled, leftSection: multiselect ? (_jsxs(_Fragment, { children: [_jsx(CheckBox, { value: isSelected, size: size, onChange: (newValue) => {
324
+ var _a;
325
+ newValue ? handleAddItem(item) : handleRemoveItem(item);
326
+ (_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
327
+ } }), (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) => {
328
+ e.preventDefault();
329
+ e.stopPropagation();
330
+ handleItemClick(item, isSelected);
331
+ }, style: style, "$dynamicHeight": dynamicListEnabled, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) ||
332
+ (item === null || item === void 0 ? void 0 : item.label) ||
333
+ (typeof item === "string" || typeof item === "number" ? item : null) }, index));
334
+ };
191
335
  return (_jsxs("div", { children: [searchable && (_jsx(SearchInput, { variant: "outlined", size: size, placeholder: "Search", defaultValue: searchValue, onChange: (e) => {
192
336
  if (!manualSearch) {
193
337
  handleSearch(e);
194
338
  }
195
339
  onSearch === null || onSearch === void 0 ? void 0 : onSearch(e.target.value);
196
- } })), isLoading && (_jsxs("div", { style: {
340
+ } })), multiselect && enableSelectAll && selectableItems.length > 0 && (_jsx(MenuItem, { className: "MenuItem", size: size, leftSection: _jsx(CheckBox, { value: allSelectableItemsSelected, partialCheck: someSelectableItemsSelected, size: size, onChange: handleToggleSelectAll }), onClick: (e) => {
341
+ e.preventDefault();
342
+ e.stopPropagation();
343
+ handleToggleSelectAll();
344
+ }, children: "Select all" })), isLoading && (_jsxs("div", { style: {
197
345
  display: "flex",
198
346
  flexDirection: "column",
199
347
  gap: "10px",
@@ -201,40 +349,15 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, se
201
349
  alignItems: "center",
202
350
  height: "100%",
203
351
  padding: "10px 0",
204
- }, children: [_jsx("div", { style: { fontSize: `${sizeTokens.supportingFontSize}px` }, children: "Loading..." }), _jsx(Loader, {})] })), !isLoading && (_jsx(ListViewPort, { ref: targetElm, children: _jsx(FixedSizeList, { itemData: displayItems, overscanCount: overscanCount, height: height, width: width, itemCount: itemCount, itemSize: itemHeight, outerRef: listElm, children: ({ data, index, style }) => {
352
+ }, children: [_jsx("div", { style: { fontSize: `${sizeTokens.supportingFontSize}px` }, children: "Loading..." }), _jsx(Loader, {})] })), !isLoading && (_jsx(ListViewPort, { ref: targetElm, 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 }) => {
353
+ const item = data === null || data === void 0 ? void 0 : data[index];
354
+ if (!item)
355
+ return null;
356
+ return (_jsx(MeasuredRow, { index: index, setItemSize: setItemSize, style: style, children: renderDisplayItem(item, index) }));
357
+ } })) : (_jsx(FixedSizeList, { ref: fixedListRef, itemData: displayItems, overscanCount: overscanCount, height: height, width: width, itemCount: itemCount, itemSize: itemHeight, outerElementType: ListScroller, outerRef: listElm, children: ({ data, index, style }) => {
205
358
  const item = data === null || data === void 0 ? void 0 : data[index];
206
359
  if (!item)
207
360
  return null;
208
- if (item._isGroupHeader) {
209
- return (_jsxs(GroupHeader, { "$size": size, style: style, children: [_jsx("span", { className: "group-line" }), _jsx("span", { className: "group-label", children: item.label }), _jsx("span", { className: "group-line" })] }, item.value));
210
- }
211
- if (item._isAddNew) {
212
- return (_jsx(MenuItem, { className: "MenuItem", size: size, leftSection: _jsx(Plus, { size: 14 }), onClick: (e) => {
213
- e.preventDefault();
214
- e.stopPropagation();
215
- onAddNew === null || onAddNew === void 0 ? void 0 : onAddNew(item.value);
216
- }, style: style, children: item.label }, "__add_new__"));
217
- }
218
- const isSelected = !!(selected === null || selected === void 0 ? void 0 : selected.find((s) => {
219
- return isObjectArray ? (s === null || s === void 0 ? void 0 : s.value) === (item === null || item === void 0 ? void 0 : item.value) : s === item;
220
- }));
221
- if (item.items) {
222
- return (_jsx(DropDownMenu, { data: item.items, size: size, buttonProps: Object.assign({ style }, item), disabled: item.disabled, children: item.label }));
223
- }
224
- 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) => {
225
- var _a;
226
- newValue
227
- ? handleAddItem(item)
228
- : handleRemoveItem(item);
229
- (_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
230
- } }), (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) => {
231
- e.preventDefault();
232
- e.stopPropagation();
233
- handleItemClick(item, isSelected);
234
- }, style: style, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) ||
235
- (item === null || item === void 0 ? void 0 : item.label) ||
236
- (typeof item === "string" || typeof item === "number"
237
- ? item
238
- : null) }, index));
239
- } }) }))] }));
361
+ return renderDisplayItem(item, index, style);
362
+ } })) }))] }));
240
363
  };
@@ -7,8 +7,7 @@ export const StyledContent = styled.div `
7
7
  overflow-y: hidden;
8
8
  overflow-x: hidden;
9
9
 
10
- width: 200px;
11
- min-width: 150px;
10
+ width: var(--mfui-dropdown-reference-width, 150px);
12
11
  max-width: 400px;
13
12
  max-height: ${({ maxDropdownHeight }) => Number.isInteger(maxDropdownHeight)
14
13
  ? `${maxDropdownHeight}px`
@@ -31,6 +31,7 @@ export type DropDownMenuProps = {
31
31
  defaultValue?: DropDownItem[];
32
32
  value?: DropDownItem[];
33
33
  multiselect?: boolean;
34
+ enableSelectAll?: boolean;
34
35
  size?: Size;
35
36
  title?: string;
36
37
  TooltipContent?: ComponentType<any>;
@@ -44,6 +45,7 @@ export type DropDownMenuProps = {
44
45
  searchable?: boolean;
45
46
  manualSearch?: boolean;
46
47
  grouped?: boolean;
48
+ dynamicOptionHeight?: boolean;
47
49
  onAddNew?: (value: string) => void;
48
50
  loading?: boolean;
49
51
  arrow?: boolean;
@@ -77,4 +79,5 @@ export type MenuProps = {
77
79
  TooltipContent?: ComponentType<any>;
78
80
  dropDownProps?: ComponentPropsWithoutRef<typeof StyledContent>;
79
81
  disabled?: boolean;
82
+ dynamicOptionHeight?: boolean;
80
83
  };
@@ -1,15 +1,26 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useState } from "react";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
3
  import styled from "styled-components";
4
4
  import Loader from "../../Loader";
5
+ const IMAGE_VIEWER_PADDING = 10;
5
6
  const ImageViewerContainer = styled.div `
7
+ box-sizing: border-box;
6
8
  height: 100%;
7
-
8
- text-align: center;
9
- padding: 10px;
9
+ padding: ${IMAGE_VIEWER_PADDING}px;
10
+ overflow: auto;
11
+ `;
12
+ const ImageCanvas = styled.div `
13
+ display: flex;
14
+ align-items: center;
15
+ justify-content: center;
16
+ flex: 0 0 auto;
17
+ min-width: 100%;
18
+ min-height: 100%;
10
19
  `;
11
- // Updated Image styled-component to remove max-width and max-height
12
20
  const Image = styled.img `
21
+ box-sizing: border-box;
22
+ display: block;
23
+ flex: 0 0 auto;
13
24
  object-fit: contain;
14
25
 
15
26
  // set orientation
@@ -26,33 +37,79 @@ const StyledLoader = styled.div `
26
37
  height: 100%;
27
38
  `;
28
39
  export const ImageViewer = ({ file, zoomFactor = 1, isPending }) => {
40
+ const containerRef = useRef(null);
29
41
  const [imageLoaded, setImageLoaded] = useState(false);
42
+ const [containerSize, setContainerSize] = useState({
43
+ width: 0,
44
+ height: 0,
45
+ });
30
46
  const [originalDimensions, setOriginalDimensions] = useState({
31
47
  naturalWidth: 0,
32
48
  naturalHeight: 0,
33
- width: 0,
34
- height: 0,
35
49
  });
36
- const handleImageLoad = (e) => {
37
- setOriginalDimensions((prev) => (Object.assign(Object.assign({}, prev), { width: e.target.clientWidth, height: e.target.offsetHeight })));
38
- };
39
- const loadImage = () => {
50
+ const fittedDimensions = useMemo(() => {
51
+ const { naturalWidth, naturalHeight } = originalDimensions;
52
+ if (naturalWidth === 0 ||
53
+ naturalHeight === 0 ||
54
+ containerSize.width === 0 ||
55
+ containerSize.height === 0) {
56
+ return {
57
+ width: naturalWidth,
58
+ height: naturalHeight,
59
+ };
60
+ }
61
+ const fitScale = Math.min(containerSize.width / naturalWidth, containerSize.height / naturalHeight);
62
+ return {
63
+ width: naturalWidth * fitScale * zoomFactor,
64
+ height: naturalHeight * fitScale * zoomFactor,
65
+ };
66
+ }, [containerSize, originalDimensions, zoomFactor]);
67
+ useEffect(() => {
40
68
  if (!file.url)
41
69
  return;
70
+ let loading = true;
71
+ setImageLoaded(false);
42
72
  const img = document.createElement("img");
43
73
  img.src = file.url;
44
74
  img.onload = () => {
45
- setOriginalDimensions((prev) => (Object.assign(Object.assign({}, prev), { naturalWidth: img.naturalWidth, naturalHeight: img.naturalHeight })));
75
+ if (!loading)
76
+ return;
77
+ setOriginalDimensions({
78
+ naturalWidth: img.naturalWidth,
79
+ naturalHeight: img.naturalHeight,
80
+ });
46
81
  setImageLoaded(true);
47
82
  };
48
- };
49
- useEffect(() => {
50
- loadImage();
83
+ return () => {
84
+ loading = false;
85
+ };
51
86
  }, [file.url]);
87
+ useEffect(() => {
88
+ const container = containerRef.current;
89
+ if (!container)
90
+ return;
91
+ const updateContainerSize = () => {
92
+ setContainerSize({
93
+ width: Math.max(0, container.clientWidth - IMAGE_VIEWER_PADDING * 2),
94
+ height: Math.max(0, container.clientHeight - IMAGE_VIEWER_PADDING * 2),
95
+ });
96
+ };
97
+ updateContainerSize();
98
+ const resizeObserver = new ResizeObserver(updateContainerSize);
99
+ resizeObserver.observe(container);
100
+ return () => resizeObserver.disconnect();
101
+ }, []);
102
+ const showImage = imageLoaded && containerSize.width > 0 && containerSize.height > 0;
52
103
  if (isPending) {
53
104
  return (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading Image..." })] }));
54
105
  }
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
- } }))] }));
106
+ return (_jsxs(ImageViewerContainer, { ref: containerRef, className: "mfui-ImageViewer", children: [!showImage && (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading Image..." })] })), showImage && (_jsx(ImageCanvas, { style: {
107
+ width: fittedDimensions.width,
108
+ height: fittedDimensions.height,
109
+ }, children: _jsx(Image, { src: file.url, alt: file.name ? file.name : "Image", style: {
110
+ width: fittedDimensions.width,
111
+ height: fittedDimensions.height,
112
+ }, onClick: (e) => {
113
+ e.stopPropagation();
114
+ } }) }))] }));
58
115
  };
@@ -38,6 +38,7 @@ export interface MonolithDefaultTheme {
38
38
  alt: string;
39
39
  secondary: string;
40
40
  gradient: string;
41
+ subtle: string;
41
42
  };
42
43
  menu: {
43
44
  background: string;
@@ -1,76 +1 @@
1
- import { Operator } from "./types";
2
- export declare const Operators: {
3
- Equals: {
4
- value: string;
5
- label: string;
6
- };
7
- NotEquals: {
8
- value: string;
9
- label: string;
10
- };
11
- LessThan: {
12
- value: string;
13
- label: string;
14
- };
15
- GreaterThan: {
16
- value: string;
17
- label: string;
18
- };
19
- LessThanOrEqual: {
20
- value: string;
21
- label: string;
22
- };
23
- GreaterThanOrEqual: {
24
- value: string;
25
- label: string;
26
- };
27
- Contains: {
28
- value: string;
29
- label: string;
30
- };
31
- BeginsWith: {
32
- value: string;
33
- label: string;
34
- };
35
- EndsWith: {
36
- value: string;
37
- label: string;
38
- };
39
- DoesNotContain: {
40
- value: string;
41
- label: string;
42
- };
43
- DoesNotBeginWith: {
44
- value: string;
45
- label: string;
46
- };
47
- DoesNotEndWith: {
48
- value: string;
49
- label: string;
50
- };
51
- IsEmpty: {
52
- value: string;
53
- label: string;
54
- };
55
- IsNotEmpty: {
56
- value: string;
57
- label: string;
58
- };
59
- In: {
60
- value: string;
61
- label: string;
62
- };
63
- NIn: {
64
- value: string;
65
- label: string;
66
- };
67
- Between: {
68
- value: string;
69
- label: string;
70
- };
71
- NotBetween: {
72
- value: string;
73
- label: string;
74
- };
75
- };
76
- export declare const DefaultOperators: Operator[];
1
+ export { DefaultOperators, Operators, DEFAULT_QUERY_FILTER_OPERATORS, QUERY_FILTER_OPERATORS, } from "./QueryFilter.constants";
@@ -1,21 +1 @@
1
- export const Operators = {
2
- Equals: { value: "=", label: "is" },
3
- NotEquals: { value: "!=", label: "is not" },
4
- LessThan: { value: "<", label: "less than" },
5
- GreaterThan: { value: ">", label: "greater than" },
6
- LessThanOrEqual: { value: "<=", label: "less than or equal" },
7
- GreaterThanOrEqual: { value: ">=", label: "greater than or equal" },
8
- Contains: { value: "contains", label: "contains" },
9
- BeginsWith: { value: "beginsWith", label: "begins with" },
10
- EndsWith: { value: "endsWith", label: "ends with" },
11
- DoesNotContain: { value: "doesNotContain", label: "does not contain" },
12
- DoesNotBeginWith: { value: "doesNotBeginWith", label: "does not begin with" },
13
- DoesNotEndWith: { value: "doesNotEndWith", label: "does not end with" },
14
- IsEmpty: { value: "isEmpty", label: "is empty" },
15
- IsNotEmpty: { value: "isNotEmpty", label: "is not empty" },
16
- In: { value: "in", label: "is any of" },
17
- NIn: { value: "nin", label: "is none of" },
18
- Between: { value: "between", label: "between" },
19
- NotBetween: { value: "notBetween", label: "not between" },
20
- };
21
- export const DefaultOperators = Object.values(Operators);
1
+ export { DefaultOperators, Operators, DEFAULT_QUERY_FILTER_OPERATORS, QUERY_FILTER_OPERATORS, } from "./QueryFilter.constants";