@monolith-forensics/monolith-ui 1.8.1-dev.2 → 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.
- package/dist/Calendar/Calendar.d.ts +4 -1
- package/dist/Calendar/Calendar.js +126 -50
- package/dist/Calendar/CalendarStyles.d.ts +3 -2
- package/dist/Calendar/CalendarStyles.js +62 -23
- package/dist/Calendar/calendarHelpers.d.ts +1 -1
- package/dist/CheckBox/CheckBox.js +35 -4
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +41 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.js +363 -0
- package/dist/DateTimeRangePicker/index.d.ts +2 -0
- package/dist/DateTimeRangePicker/index.js +2 -0
- package/dist/DropDownMenu/DropDownMenu.js +25 -15
- package/dist/DropDownMenu/components/MenuComponent.js +6 -1
- package/dist/DropDownMenu/components/MenuItem.js +6 -0
- package/dist/DropDownMenu/components/MenuItemList.d.ts +2 -0
- package/dist/DropDownMenu/components/MenuItemList.js +94 -13
- package/dist/DropDownMenu/components/StyledContent.js +1 -2
- package/dist/DropDownMenu/types.d.ts +1 -0
- package/dist/FileViewer/viewers/ImageViewer.js +75 -18
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +1 -0
- package/dist/QueryFilter/DefaultOperators.d.ts +1 -76
- package/dist/QueryFilter/DefaultOperators.js +1 -21
- package/dist/QueryFilter/QueryFilter.constants.d.ts +134 -0
- package/dist/QueryFilter/QueryFilter.constants.js +39 -0
- package/dist/QueryFilter/QueryFilter.d.ts +1 -1
- package/dist/QueryFilter/QueryFilter.js +3 -303
- package/dist/QueryFilter/QueryFilter.lib.d.ts +14 -0
- package/dist/QueryFilter/QueryFilter.lib.js +84 -0
- package/dist/QueryFilter/QueryFilter.styled.d.ts +89 -0
- package/dist/QueryFilter/QueryFilter.styled.js +184 -0
- package/dist/QueryFilter/QueryFilter.types.d.ts +61 -0
- package/dist/QueryFilter/QueryFilter.types.js +1 -0
- package/dist/QueryFilter/components/MultiSelectEditor.d.ts +7 -0
- package/dist/QueryFilter/components/MultiSelectEditor.js +44 -0
- package/dist/QueryFilter/components/RuleChip.d.ts +8 -0
- package/dist/QueryFilter/components/RuleChip.js +37 -0
- package/dist/QueryFilter/components/Rules.d.ts +11 -0
- package/dist/QueryFilter/components/Rules.js +41 -0
- package/dist/QueryFilter/components/UnavailableRuleChip.d.ts +5 -0
- package/dist/QueryFilter/components/UnavailableRuleChip.js +7 -0
- package/dist/QueryFilter/components/ValueEditor.d.ts +7 -0
- package/dist/QueryFilter/components/ValueEditor.js +45 -0
- package/dist/QueryFilter/components/ValueSelector.d.ts +7 -0
- package/dist/QueryFilter/components/ValueSelector.js +34 -0
- package/dist/QueryFilter/components/index.d.ts +6 -0
- package/dist/QueryFilter/components/index.js +6 -0
- package/dist/QueryFilter/index.d.ts +3 -2
- package/dist/QueryFilter/index.js +3 -2
- package/dist/QueryFilter/types.d.ts +1 -52
- package/dist/QueryFilter/types.js +1 -1
- package/dist/QueryFilter/useQueryFilter.d.ts +1 -1
- package/dist/QueryFilter/useQueryFilter.js +23 -19
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +5 -15
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.d.ts +3 -0
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +241 -0
- package/dist/RichTextEditor/Plugins/UploadImagesPlugin.d.ts +15 -0
- package/dist/RichTextEditor/Plugins/UploadImagesPlugin.js +115 -51
- package/dist/RichTextEditor/Plugins/index.d.ts +1 -0
- package/dist/RichTextEditor/Plugins/index.js +1 -0
- package/dist/RichTextEditor/RichTextEditor.d.ts +3 -2
- package/dist/RichTextEditor/RichTextEditor.js +302 -35
- package/dist/SuperDatePicker/SuperDatePicker.constants.d.ts +24 -0
- package/dist/SuperDatePicker/SuperDatePicker.constants.js +30 -0
- package/dist/SuperDatePicker/SuperDatePicker.d.ts +3 -0
- package/dist/SuperDatePicker/SuperDatePicker.js +31 -0
- package/dist/SuperDatePicker/SuperDatePicker.lib.d.ts +17 -0
- package/dist/SuperDatePicker/SuperDatePicker.lib.js +206 -0
- package/dist/SuperDatePicker/SuperDatePicker.styled.d.ts +60 -0
- package/dist/SuperDatePicker/SuperDatePicker.styled.js +256 -0
- package/dist/SuperDatePicker/SuperDatePicker.types.d.ts +48 -0
- package/dist/SuperDatePicker/SuperDatePicker.types.js +1 -0
- package/dist/SuperDatePicker/components/CommonPresetGroups.d.ts +7 -0
- package/dist/SuperDatePicker/components/CommonPresetGroups.js +6 -0
- package/dist/SuperDatePicker/components/EndpointCalendarDropdown.d.ts +10 -0
- package/dist/SuperDatePicker/components/EndpointCalendarDropdown.js +9 -0
- package/dist/SuperDatePicker/components/EndpointDateInput.d.ts +16 -0
- package/dist/SuperDatePicker/components/EndpointDateInput.js +26 -0
- package/dist/SuperDatePicker/components/EndpointPopover.d.ts +18 -0
- package/dist/SuperDatePicker/components/EndpointPopover.js +11 -0
- package/dist/SuperDatePicker/components/QuickRangeDropdown.d.ts +14 -0
- package/dist/SuperDatePicker/components/QuickRangeDropdown.js +19 -0
- package/dist/SuperDatePicker/components/QuickRangePopover.d.ts +18 -0
- package/dist/SuperDatePicker/components/QuickRangePopover.js +12 -0
- package/dist/SuperDatePicker/components/index.d.ts +6 -0
- package/dist/SuperDatePicker/components/index.js +6 -0
- package/dist/SuperDatePicker/index.d.ts +3 -0
- package/dist/SuperDatePicker/index.js +3 -0
- package/dist/SuperDatePicker/useSuperDatePicker.d.ts +32 -0
- package/dist/SuperDatePicker/useSuperDatePicker.js +125 -0
- package/dist/Table/ColumnResizer.d.ts +6 -9
- package/dist/Table/ColumnResizer.js +30 -10
- package/dist/Table/TableComponents.js +14 -10
- package/dist/Table/TableHeader.js +31 -16
- package/dist/Table/TableMenu/TableMenu.js +1 -1
- package/dist/Table/TableProvider.js +91 -4
- package/dist/Table/TableRow.js +19 -12
- package/dist/Table/Utils/index.d.ts +0 -1
- package/dist/Table/Utils/index.js +0 -1
- package/dist/Table/types.d.ts +6 -19
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/theme/variants.js +2 -0
- package/package.json +22 -18
|
@@ -10,7 +10,7 @@ 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 { useCallback, useLayoutEffect, useRef, useState, } from "react";
|
|
13
|
+
import { useCallback, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
14
14
|
import styled from "styled-components";
|
|
15
15
|
import { FixedSizeList, VariableSizeList } from "react-window";
|
|
16
16
|
import { Plus } from "lucide-react";
|
|
@@ -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;
|
|
@@ -98,13 +121,14 @@ const MeasuredRow = ({ children, index, setItemSize, style }) => {
|
|
|
98
121
|
}, [children, index, setItemSize]);
|
|
99
122
|
return (_jsx("div", { style: Object.assign(Object.assign({}, style), { overflow: "visible" }), children: _jsx("div", { ref: rowRef, children: children }) }));
|
|
100
123
|
};
|
|
101
|
-
export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dynamicOptionHeight, selected, TooltipContent, multiselect, grouped, onAddNew, size, handleAddItem, handleRemoveItem, onItemSelect, renderOption, onScroll, onScrollToTop, onScrollToBottom, query, }) => {
|
|
102
|
-
var _a;
|
|
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, }) => {
|
|
103
125
|
const [searchValue, setSearchValue] = useState("");
|
|
104
|
-
const
|
|
126
|
+
const _a = query !== null && query !== void 0 ? query : {}, { queryKey, queryFn, getNextPageParam, initialPageParam } = _a, rest = __rest(_a, ["queryKey", "queryFn", "getNextPageParam", "initialPageParam"]);
|
|
105
127
|
const targetElm = useRef(null);
|
|
106
128
|
const listElm = useRef(null);
|
|
129
|
+
const fixedListRef = useRef(null);
|
|
107
130
|
const variableListRef = useRef(null);
|
|
131
|
+
const hasHandledInitialSelectedScroll = useRef(false);
|
|
108
132
|
const itemSizeMap = useRef({});
|
|
109
133
|
const [viewPortDimensions, setViewPortDimensions] = useState({
|
|
110
134
|
width: 0,
|
|
@@ -128,6 +152,9 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
128
152
|
if (multiselect) {
|
|
129
153
|
isSelected ? handleRemoveItem(item) : handleAddItem(item);
|
|
130
154
|
}
|
|
155
|
+
else {
|
|
156
|
+
handleAddItem(item);
|
|
157
|
+
}
|
|
131
158
|
onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(item);
|
|
132
159
|
(_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
|
|
133
160
|
};
|
|
@@ -158,7 +185,23 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
158
185
|
}
|
|
159
186
|
return items;
|
|
160
187
|
})();
|
|
161
|
-
const
|
|
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("|");
|
|
162
205
|
const isLoading = isLoadingInfiniteQuery;
|
|
163
206
|
const handleOnScroll = useCallback((event) => {
|
|
164
207
|
const scrollTolerance = 15;
|
|
@@ -172,6 +215,18 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
172
215
|
debouncedFetchNextPage();
|
|
173
216
|
}
|
|
174
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);
|
|
229
|
+
};
|
|
175
230
|
useLayoutEffect(() => {
|
|
176
231
|
const list = listElm.current;
|
|
177
232
|
if (!list)
|
|
@@ -211,7 +266,7 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
211
266
|
: estimatedHeight < 200
|
|
212
267
|
? estimatedHeight
|
|
213
268
|
: 200;
|
|
214
|
-
const width =
|
|
269
|
+
const width = "100%";
|
|
215
270
|
const setItemSize = useCallback((index, measuredSize) => {
|
|
216
271
|
var _a;
|
|
217
272
|
if (itemSizeMap.current[index] === measuredSize)
|
|
@@ -226,6 +281,30 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
226
281
|
(_a = variableListRef.current) === null || _a === void 0 ? void 0 : _a.resetAfterIndex(0, true);
|
|
227
282
|
setMeasurementRevision((revision) => revision + 1);
|
|
228
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
|
+
]);
|
|
229
308
|
const renderDisplayItem = (item, index, style) => {
|
|
230
309
|
if (item._isGroupHeader) {
|
|
231
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));
|
|
@@ -237,13 +316,11 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
237
316
|
onAddNew === null || onAddNew === void 0 ? void 0 : onAddNew(item.value);
|
|
238
317
|
}, style: style, children: item.label }, "__add_new__"));
|
|
239
318
|
}
|
|
240
|
-
const isSelected =
|
|
241
|
-
return isObjectArray ? (s === null || s === void 0 ? void 0 : s.value) === (item === null || item === void 0 ? void 0 : item.value) : s === item;
|
|
242
|
-
}));
|
|
319
|
+
const isSelected = isItemSelected(item);
|
|
243
320
|
if (item.items) {
|
|
244
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 }));
|
|
245
322
|
}
|
|
246
|
-
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) => {
|
|
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) => {
|
|
247
324
|
var _a;
|
|
248
325
|
newValue ? handleAddItem(item) : handleRemoveItem(item);
|
|
249
326
|
(_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
|
|
@@ -260,7 +337,11 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
260
337
|
handleSearch(e);
|
|
261
338
|
}
|
|
262
339
|
onSearch === null || onSearch === void 0 ? void 0 : onSearch(e.target.value);
|
|
263
|
-
} })),
|
|
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: {
|
|
264
345
|
display: "flex",
|
|
265
346
|
flexDirection: "column",
|
|
266
347
|
gap: "10px",
|
|
@@ -268,12 +349,12 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
268
349
|
alignItems: "center",
|
|
269
350
|
height: "100%",
|
|
270
351
|
padding: "10px 0",
|
|
271
|
-
}, 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, 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 }) => {
|
|
272
353
|
const item = data === null || data === void 0 ? void 0 : data[index];
|
|
273
354
|
if (!item)
|
|
274
355
|
return null;
|
|
275
356
|
return (_jsx(MeasuredRow, { index: index, setItemSize: setItemSize, style: style, children: renderDisplayItem(item, index) }));
|
|
276
|
-
} })) : (_jsx(FixedSizeList, { itemData: displayItems, overscanCount: overscanCount, height: height, width: width, itemCount: itemCount, itemSize: itemHeight, outerRef: listElm, children: ({ data, index, style }) => {
|
|
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 }) => {
|
|
277
358
|
const item = data === null || data === void 0 ? void 0 : data[index];
|
|
278
359
|
if (!item)
|
|
279
360
|
return null;
|
|
@@ -7,8 +7,7 @@ export const StyledContent = styled.div `
|
|
|
7
7
|
overflow-y: hidden;
|
|
8
8
|
overflow-x: hidden;
|
|
9
9
|
|
|
10
|
-
width:
|
|
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`
|
|
@@ -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
|
-
|
|
9
|
-
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
75
|
+
if (!loading)
|
|
76
|
+
return;
|
|
77
|
+
setOriginalDimensions({
|
|
78
|
+
naturalWidth: img.naturalWidth,
|
|
79
|
+
naturalHeight: img.naturalHeight,
|
|
80
|
+
});
|
|
46
81
|
setImageLoaded(true);
|
|
47
82
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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: [!
|
|
56
|
-
|
|
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
|
};
|
|
@@ -1,76 +1 @@
|
|
|
1
|
-
|
|
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
|
|
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";
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { DropDownItem } from "../DropDownMenu";
|
|
2
|
+
import type { Operator, Query } from "./QueryFilter.types";
|
|
3
|
+
export declare const DEFAULT_QUERY_FILTER: Query;
|
|
4
|
+
export declare const QUERY_FILTER_OPERATORS: {
|
|
5
|
+
Equals: {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
|
+
NotEquals: {
|
|
10
|
+
value: string;
|
|
11
|
+
label: string;
|
|
12
|
+
};
|
|
13
|
+
LessThan: {
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
};
|
|
17
|
+
GreaterThan: {
|
|
18
|
+
value: string;
|
|
19
|
+
label: string;
|
|
20
|
+
};
|
|
21
|
+
LessThanOrEqual: {
|
|
22
|
+
value: string;
|
|
23
|
+
label: string;
|
|
24
|
+
};
|
|
25
|
+
GreaterThanOrEqual: {
|
|
26
|
+
value: string;
|
|
27
|
+
label: string;
|
|
28
|
+
};
|
|
29
|
+
Contains: {
|
|
30
|
+
value: string;
|
|
31
|
+
label: string;
|
|
32
|
+
};
|
|
33
|
+
DoesNotContain: {
|
|
34
|
+
value: string;
|
|
35
|
+
label: string;
|
|
36
|
+
};
|
|
37
|
+
IsEmpty: {
|
|
38
|
+
value: string;
|
|
39
|
+
label: string;
|
|
40
|
+
};
|
|
41
|
+
IsNotEmpty: {
|
|
42
|
+
value: string;
|
|
43
|
+
label: string;
|
|
44
|
+
};
|
|
45
|
+
In: {
|
|
46
|
+
value: string;
|
|
47
|
+
label: string;
|
|
48
|
+
};
|
|
49
|
+
NIn: {
|
|
50
|
+
value: string;
|
|
51
|
+
label: string;
|
|
52
|
+
};
|
|
53
|
+
Between: {
|
|
54
|
+
value: string;
|
|
55
|
+
label: string;
|
|
56
|
+
};
|
|
57
|
+
NotBetween: {
|
|
58
|
+
value: string;
|
|
59
|
+
label: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export declare const Operators: {
|
|
63
|
+
Equals: {
|
|
64
|
+
value: string;
|
|
65
|
+
label: string;
|
|
66
|
+
};
|
|
67
|
+
NotEquals: {
|
|
68
|
+
value: string;
|
|
69
|
+
label: string;
|
|
70
|
+
};
|
|
71
|
+
LessThan: {
|
|
72
|
+
value: string;
|
|
73
|
+
label: string;
|
|
74
|
+
};
|
|
75
|
+
GreaterThan: {
|
|
76
|
+
value: string;
|
|
77
|
+
label: string;
|
|
78
|
+
};
|
|
79
|
+
LessThanOrEqual: {
|
|
80
|
+
value: string;
|
|
81
|
+
label: string;
|
|
82
|
+
};
|
|
83
|
+
GreaterThanOrEqual: {
|
|
84
|
+
value: string;
|
|
85
|
+
label: string;
|
|
86
|
+
};
|
|
87
|
+
Contains: {
|
|
88
|
+
value: string;
|
|
89
|
+
label: string;
|
|
90
|
+
};
|
|
91
|
+
DoesNotContain: {
|
|
92
|
+
value: string;
|
|
93
|
+
label: string;
|
|
94
|
+
};
|
|
95
|
+
IsEmpty: {
|
|
96
|
+
value: string;
|
|
97
|
+
label: string;
|
|
98
|
+
};
|
|
99
|
+
IsNotEmpty: {
|
|
100
|
+
value: string;
|
|
101
|
+
label: string;
|
|
102
|
+
};
|
|
103
|
+
In: {
|
|
104
|
+
value: string;
|
|
105
|
+
label: string;
|
|
106
|
+
};
|
|
107
|
+
NIn: {
|
|
108
|
+
value: string;
|
|
109
|
+
label: string;
|
|
110
|
+
};
|
|
111
|
+
Between: {
|
|
112
|
+
value: string;
|
|
113
|
+
label: string;
|
|
114
|
+
};
|
|
115
|
+
NotBetween: {
|
|
116
|
+
value: string;
|
|
117
|
+
label: string;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
export declare const DEFAULT_QUERY_FILTER_OPERATORS: Operator[];
|
|
121
|
+
export declare const DefaultOperators: Operator[];
|
|
122
|
+
export declare const QUERY_FILTER_VALUE_PLACEHOLDER = "Enter Value...";
|
|
123
|
+
export declare const QUERY_FILTER_SELECT_VALUE_LABEL = "Select Value";
|
|
124
|
+
export declare const QUERY_FILTER_UNAVAILABLE_FILTER_LABEL = "Unavailable filter";
|
|
125
|
+
export declare const QUERY_FILTER_COMBINATOR_TITLE = "Chain these query filters together using AND | OR logic";
|
|
126
|
+
export declare const QUERY_FILTER_DATE_FORMATS: {
|
|
127
|
+
readonly day: "YYYY-MM-DD";
|
|
128
|
+
readonly second: "YYYY-MM-DD HH:mm:ss";
|
|
129
|
+
readonly millisecond: "YYYY-MM-DD HH:mm:ss.SSS";
|
|
130
|
+
readonly default: "YYYY-MM-DD HH:mm:ss";
|
|
131
|
+
};
|
|
132
|
+
export declare const QUERY_FILTER_BETWEEN_OPERATORS: string[];
|
|
133
|
+
export declare const QUERY_FILTER_VALUELESS_OPERATORS: string[];
|
|
134
|
+
export declare const QUERY_FILTER_COMBINATOR_OPTIONS: DropDownItem[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const DEFAULT_QUERY_FILTER = {
|
|
2
|
+
combinator: "and",
|
|
3
|
+
rules: [],
|
|
4
|
+
};
|
|
5
|
+
export const QUERY_FILTER_OPERATORS = {
|
|
6
|
+
Equals: { value: "=", label: "is" },
|
|
7
|
+
NotEquals: { value: "!=", label: "is not" },
|
|
8
|
+
LessThan: { value: "<", label: "less than" },
|
|
9
|
+
GreaterThan: { value: ">", label: "greater than" },
|
|
10
|
+
LessThanOrEqual: { value: "<=", label: "less than or equal" },
|
|
11
|
+
GreaterThanOrEqual: { value: ">=", label: "greater than or equal" },
|
|
12
|
+
Contains: { value: "contains", label: "contains" },
|
|
13
|
+
DoesNotContain: { value: "doesNotContain", label: "does not contain" },
|
|
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 Operators = QUERY_FILTER_OPERATORS;
|
|
22
|
+
export const DEFAULT_QUERY_FILTER_OPERATORS = Object.values(QUERY_FILTER_OPERATORS);
|
|
23
|
+
export const DefaultOperators = DEFAULT_QUERY_FILTER_OPERATORS;
|
|
24
|
+
export const QUERY_FILTER_VALUE_PLACEHOLDER = "Enter Value...";
|
|
25
|
+
export const QUERY_FILTER_SELECT_VALUE_LABEL = "Select Value";
|
|
26
|
+
export const QUERY_FILTER_UNAVAILABLE_FILTER_LABEL = "Unavailable filter";
|
|
27
|
+
export const QUERY_FILTER_COMBINATOR_TITLE = "Chain these query filters together using AND | OR logic";
|
|
28
|
+
export const QUERY_FILTER_DATE_FORMATS = {
|
|
29
|
+
day: "YYYY-MM-DD",
|
|
30
|
+
second: "YYYY-MM-DD HH:mm:ss",
|
|
31
|
+
millisecond: "YYYY-MM-DD HH:mm:ss.SSS",
|
|
32
|
+
default: "YYYY-MM-DD HH:mm:ss",
|
|
33
|
+
};
|
|
34
|
+
export const QUERY_FILTER_BETWEEN_OPERATORS = ["between", "notbetween"];
|
|
35
|
+
export const QUERY_FILTER_VALUELESS_OPERATORS = ["isEmpty", "isNotEmpty"];
|
|
36
|
+
export const QUERY_FILTER_COMBINATOR_OPTIONS = [
|
|
37
|
+
{ label: "AND", value: "and" },
|
|
38
|
+
{ label: "OR", value: "or" },
|
|
39
|
+
];
|