@trackunit/filters-filter-bar 0.0.245 → 0.0.249
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/index.cjs.js +18 -39
- package/index.esm.js +21 -42
- package/package.json +1 -2
- package/src/lib/components/VirtualizedList.d.ts +0 -27
package/index.cjs.js
CHANGED
|
@@ -12,7 +12,6 @@ var react = require('react');
|
|
|
12
12
|
var reactFilterComponents = require('@trackunit/react-filter-components');
|
|
13
13
|
var reactCoreHooks = require('@trackunit/react-core-hooks');
|
|
14
14
|
var reactCoreContextsApi = require('@trackunit/react-core-contexts-api');
|
|
15
|
-
var reactVirtual = require('@tanstack/react-virtual');
|
|
16
15
|
var reactFormComponents = require('@trackunit/react-form-components');
|
|
17
16
|
var dequal = require('dequal');
|
|
18
17
|
var isEqual = require('lodash/isEqual');
|
|
@@ -455,7 +454,7 @@ const StarredFiltersMenu = ({ filterBarDefinition, updateStarredFilters, starred
|
|
|
455
454
|
const [t] = useTranslation();
|
|
456
455
|
const { logEvent } = reactCoreHooks.useAnalytics(FilterEvents);
|
|
457
456
|
const hideInStarredMenu = react.useMemo(() => {
|
|
458
|
-
return
|
|
457
|
+
return sharedUtils.objectValues(filterBarDefinition)
|
|
459
458
|
.map(filter => {
|
|
460
459
|
const showInStarredMenu = filter.showInStarredMenu ? filter.showInStarredMenu() : true;
|
|
461
460
|
const showInFilterBar = filter.showInFilterBar ? filter.showInFilterBar() : true;
|
|
@@ -463,7 +462,7 @@ const StarredFiltersMenu = ({ filterBarDefinition, updateStarredFilters, starred
|
|
|
463
462
|
})
|
|
464
463
|
.filter(sharedUtils.truthy);
|
|
465
464
|
}, [filterBarDefinition]);
|
|
466
|
-
const { filtersGrouped } = useStarredGroupFilters(
|
|
465
|
+
const { filtersGrouped } = useStarredGroupFilters(sharedUtils.objectValues(filterBarDefinition), [
|
|
467
466
|
...hideInStarredMenu,
|
|
468
467
|
...hiddenFilters,
|
|
469
468
|
]);
|
|
@@ -513,14 +512,14 @@ const StarredFilters = ({ filterBarDefinition, filterBarConfig, disableCollapse,
|
|
|
513
512
|
};
|
|
514
513
|
const FilterSelection = ({ filterBarDefinition, filterBarConfig, hiddenFilters = [], className, disableCollapse, }) => {
|
|
515
514
|
const hideInFilterBar = react.useMemo(() => {
|
|
516
|
-
return
|
|
515
|
+
return sharedUtils.objectValues(filterBarDefinition)
|
|
517
516
|
.map(filter => {
|
|
518
517
|
const showInFilterBar = filter.showInFilterBar ? filter.showInFilterBar() : true;
|
|
519
518
|
return !showInFilterBar ? filter.filterKey : null;
|
|
520
519
|
})
|
|
521
520
|
.filter(sharedUtils.truthy);
|
|
522
521
|
}, [filterBarDefinition]);
|
|
523
|
-
const { filtersGrouped } = useStarredGroupFilters(
|
|
522
|
+
const { filtersGrouped } = useStarredGroupFilters(sharedUtils.objectValues(filterBarDefinition), [
|
|
524
523
|
...hideInFilterBar,
|
|
525
524
|
...hiddenFilters,
|
|
526
525
|
]);
|
|
@@ -561,34 +560,6 @@ const toggleFilterValue = (value) => {
|
|
|
561
560
|
};
|
|
562
561
|
};
|
|
563
562
|
|
|
564
|
-
/**
|
|
565
|
-
* Render a virtualized list of items
|
|
566
|
-
*
|
|
567
|
-
* @template T - The type of data items in the list.
|
|
568
|
-
* @returns {JSX.Element} - Returns the virtualized list component.
|
|
569
|
-
*/
|
|
570
|
-
const VirtualizedList = ({ parentRef, count, rowHeight = 40, children, }) => {
|
|
571
|
-
const rowVirtualizer = reactVirtual.useVirtualizer({
|
|
572
|
-
count,
|
|
573
|
-
getScrollElement: () => parentRef.current,
|
|
574
|
-
estimateSize: react.useCallback((i) => rowHeight, [rowHeight]),
|
|
575
|
-
overscan: 10,
|
|
576
|
-
});
|
|
577
|
-
react.useEffect(() => {
|
|
578
|
-
// this ensures the cache is cleared if the rowHeight changes
|
|
579
|
-
if (rowHeight) {
|
|
580
|
-
rowVirtualizer.measure();
|
|
581
|
-
}
|
|
582
|
-
}, [rowHeight, rowVirtualizer]);
|
|
583
|
-
return (jsxRuntime.jsx("div", { className: "relative", style: { height: rowVirtualizer.getTotalSize() }, children: rowVirtualizer.getVirtualItems().map((virtualRow, index) => (jsxRuntime.jsx("div", { style: {
|
|
584
|
-
position: "absolute",
|
|
585
|
-
top: 0,
|
|
586
|
-
left: 0,
|
|
587
|
-
width: "100%",
|
|
588
|
-
transform: `translateY(${virtualRow.start}px)`,
|
|
589
|
-
}, children: children(virtualRow.index) }, virtualRow.index))) }));
|
|
590
|
-
};
|
|
591
|
-
|
|
592
563
|
/**
|
|
593
564
|
* DynamicFilterList is a React component that displays a list of dynamic filters with options like CheckBoxes or Radio buttons.
|
|
594
565
|
*
|
|
@@ -598,7 +569,7 @@ const DynamicFilterList = ({ rowCount, keyMapper, labelMapper, prefixMapper, onC
|
|
|
598
569
|
const [t] = useTranslation();
|
|
599
570
|
const parentRef = react.useRef(null);
|
|
600
571
|
const updatedRowCount = react.useMemo(() => (showRequestMoreUseSearch ? rowCount + 1 : rowCount), [rowCount, showRequestMoreUseSearch]);
|
|
601
|
-
return (jsxRuntime.jsx(reactFilterComponents.FilterBody, { limitSize: true, ref: parentRef, children: jsxRuntime.jsx(VirtualizedList, { count: updatedRowCount,
|
|
572
|
+
return (jsxRuntime.jsx(reactFilterComponents.FilterBody, { limitSize: true, ref: parentRef, children: jsxRuntime.jsx(reactComponents.VirtualizedList, { count: updatedRowCount, rowHeight: 40, separator: "none", children: index => {
|
|
602
573
|
return (jsxRuntime.jsx("div", { children: showRequestMoreUseSearch && index === rowCount ? (jsxRuntime.jsxs("div", { className: "p-3 pt-2", children: [jsxRuntime.jsx("span", { className: "text-sm text-gray-600", children: t("filter.more.options.if.you.search.title", { count: rowCount }) }), jsxRuntime.jsx("br", {}), jsxRuntime.jsx("span", { className: "text-sm italic text-gray-400", children: t("filter.more.options.if.you.search.description") })] })) : type === "Radio" ? (jsxRuntime.jsx(reactFilterComponents.RadioFilterItem, { dataTestId: "dynamic-filter-radio-" + keyMapper(index), itemCount: count(index), label: labelMapper(index), prefix: prefixMapper === null || prefixMapper === void 0 ? void 0 : prefixMapper(index), selected: checked(index), value: keyMapper(index) }, keyMapper(index))) : (jsxRuntime.jsx(reactFilterComponents.CheckBoxFilterItem, { checked: checked(index), dataTestId: "dynamic-filter-check-box-" + keyMapper(index), itemCount: count(index), label: labelMapper(index), name: keyMapper(index), onChange: () => onChange === null || onChange === void 0 ? void 0 : onChange(index), prefix: prefixMapper === null || prefixMapper === void 0 ? void 0 : prefixMapper(index), showTooltip: showTooltip }, keyMapper(index))) }));
|
|
603
574
|
} }) }));
|
|
604
575
|
};
|
|
@@ -614,7 +585,7 @@ const FilterHeader = ({ filterKey, title, searchEnabled, searchProps, filterHasC
|
|
|
614
585
|
resetIndividualFilterToInitialState(filterKey);
|
|
615
586
|
onResetFilter === null || onResetFilter === void 0 ? void 0 : onResetFilter();
|
|
616
587
|
};
|
|
617
|
-
return (jsxRuntime.jsx(reactFilterComponents.FilterHeader, { dataTestId: `${filterKey}-filter-header`, loading: loading, onReset: handleResetFilter, resetLabel: t("filtersBar.resetFilter"), showReset: filterHasChanged(filterKey), title: title, children: searchEnabled ? (jsxRuntime.jsx(reactFormComponents.Search, { autoFocus: true, fieldSize: "small", onChange: e => searchProps.onChange(e.currentTarget.value), placeholder: t("assetFilters.searchPlaceholder"),
|
|
588
|
+
return (jsxRuntime.jsx(reactFilterComponents.FilterHeader, { dataTestId: `${filterKey}-filter-header`, loading: loading, onReset: handleResetFilter, resetLabel: t("filtersBar.resetFilter"), showReset: filterHasChanged(filterKey), title: title, children: searchEnabled ? (jsxRuntime.jsx(reactFormComponents.Search, { autoFocus: true, fieldSize: "small", onChange: e => searchProps.onChange(e.currentTarget.value), placeholder: t("assetFilters.searchPlaceholder"), suffix: jsxRuntime.jsx(reactComponents.Text, { size: "small", subtle: true, children: searchProps.count }), value: searchProps.value })) : null }));
|
|
618
589
|
};
|
|
619
590
|
|
|
620
591
|
/**
|
|
@@ -921,6 +892,7 @@ const hasValue = (value) => {
|
|
|
921
892
|
if (value === undefined || value === null) {
|
|
922
893
|
return false;
|
|
923
894
|
}
|
|
895
|
+
// eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
924
896
|
if (typeof value === "object" && Object.keys(value).length === 0) {
|
|
925
897
|
return false;
|
|
926
898
|
}
|
|
@@ -941,7 +913,8 @@ const isNotRightType = (filterDefinition, foundFilter) => {
|
|
|
941
913
|
*/
|
|
942
914
|
const isMinMaxFilterValue = (value) => {
|
|
943
915
|
return value
|
|
944
|
-
?
|
|
916
|
+
? // eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
917
|
+
typeof value === "object" && (Object.keys(value).includes("min") || Object.keys(value).includes("max"))
|
|
945
918
|
: false;
|
|
946
919
|
};
|
|
947
920
|
/**
|
|
@@ -949,7 +922,8 @@ const isMinMaxFilterValue = (value) => {
|
|
|
949
922
|
*/
|
|
950
923
|
const isDateRangeValue = (value) => {
|
|
951
924
|
return value
|
|
952
|
-
?
|
|
925
|
+
? // eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
926
|
+
typeof value === "object" && (Object.keys(value).includes("from") || Object.keys(value).includes("to"))
|
|
953
927
|
: false;
|
|
954
928
|
};
|
|
955
929
|
/**
|
|
@@ -957,7 +931,8 @@ const isDateRangeValue = (value) => {
|
|
|
957
931
|
*/
|
|
958
932
|
const isBoundingBox = (value) => {
|
|
959
933
|
return value
|
|
960
|
-
?
|
|
934
|
+
? // eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
935
|
+
typeof value === "object" && Object.keys(value).includes("nw") && Object.keys(value).includes("se")
|
|
961
936
|
: false;
|
|
962
937
|
};
|
|
963
938
|
/**
|
|
@@ -976,6 +951,7 @@ const isStringArrayFilterValue = (value) => {
|
|
|
976
951
|
*
|
|
977
952
|
*/
|
|
978
953
|
const isBooleanValue = (value) => {
|
|
954
|
+
// eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
979
955
|
return value ? typeof value === "object" && Object.keys(value).includes("booleanValue") : false;
|
|
980
956
|
};
|
|
981
957
|
/**
|
|
@@ -983,7 +959,9 @@ const isBooleanValue = (value) => {
|
|
|
983
959
|
*/
|
|
984
960
|
const isValueNameFilterValue = (value) => {
|
|
985
961
|
return (isArrayFilterValue(value) &&
|
|
986
|
-
value.every(
|
|
962
|
+
value.every(
|
|
963
|
+
// eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
964
|
+
item => typeof item === "object" && Object.keys(item).includes("name") && Object.keys(item).includes("value")));
|
|
987
965
|
};
|
|
988
966
|
/**
|
|
989
967
|
* Validates a filter configuration against filter definitions.
|
|
@@ -996,6 +974,7 @@ const isValueNameFilterValue = (value) => {
|
|
|
996
974
|
const validateFilter = (filter, filterDefinitions) => {
|
|
997
975
|
const stateKeys = [];
|
|
998
976
|
let inBadState = false;
|
|
977
|
+
// eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
999
978
|
for (const key of Object.keys((filter === null || filter === void 0 ? void 0 : filter.values) || {})) {
|
|
1000
979
|
if (filterDefinitions.find(filterDefinition => filterDefinition.filterKey === key)) {
|
|
1001
980
|
stateKeys.push(key);
|
package/index.esm.js
CHANGED
|
@@ -2,13 +2,12 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
5
|
-
import { Button, Popover, PopoverTrigger, IconButton, Icon, PopoverContent, MenuList, Text, StarButton, useResize, Collapse, DayRangePicker } from '@trackunit/react-components';
|
|
6
|
-
import { truthy, capitalize as capitalize$1, nonNullable
|
|
7
|
-
import { useMemo, useState, Fragment as Fragment$1,
|
|
5
|
+
import { Button, Popover, PopoverTrigger, IconButton, Icon, PopoverContent, MenuList, Text, StarButton, useResize, Collapse, VirtualizedList, DayRangePicker } from '@trackunit/react-components';
|
|
6
|
+
import { objectValues, truthy, capitalize as capitalize$1, nonNullable } from '@trackunit/shared-utils';
|
|
7
|
+
import { useMemo, useState, Fragment as Fragment$1, useRef, useEffect, useCallback } from 'react';
|
|
8
8
|
import { Filter as Filter$1, FilterBody, RadioFilterItem, CheckBoxFilterItem, FilterHeader as FilterHeader$1, FilterFooter } from '@trackunit/react-filter-components';
|
|
9
9
|
import { useAnalytics, useTextSearch } from '@trackunit/react-core-hooks';
|
|
10
10
|
import { createEvent } from '@trackunit/react-core-contexts-api';
|
|
11
|
-
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
12
11
|
import { Search, NumberField, RadioGroup } from '@trackunit/react-form-components';
|
|
13
12
|
import { dequal } from 'dequal';
|
|
14
13
|
import isEqual from 'lodash/isEqual';
|
|
@@ -447,7 +446,7 @@ const StarredFiltersMenu = ({ filterBarDefinition, updateStarredFilters, starred
|
|
|
447
446
|
const [t] = useTranslation();
|
|
448
447
|
const { logEvent } = useAnalytics(FilterEvents);
|
|
449
448
|
const hideInStarredMenu = useMemo(() => {
|
|
450
|
-
return
|
|
449
|
+
return objectValues(filterBarDefinition)
|
|
451
450
|
.map(filter => {
|
|
452
451
|
const showInStarredMenu = filter.showInStarredMenu ? filter.showInStarredMenu() : true;
|
|
453
452
|
const showInFilterBar = filter.showInFilterBar ? filter.showInFilterBar() : true;
|
|
@@ -455,7 +454,7 @@ const StarredFiltersMenu = ({ filterBarDefinition, updateStarredFilters, starred
|
|
|
455
454
|
})
|
|
456
455
|
.filter(truthy);
|
|
457
456
|
}, [filterBarDefinition]);
|
|
458
|
-
const { filtersGrouped } = useStarredGroupFilters(
|
|
457
|
+
const { filtersGrouped } = useStarredGroupFilters(objectValues(filterBarDefinition), [
|
|
459
458
|
...hideInStarredMenu,
|
|
460
459
|
...hiddenFilters,
|
|
461
460
|
]);
|
|
@@ -505,14 +504,14 @@ const StarredFilters = ({ filterBarDefinition, filterBarConfig, disableCollapse,
|
|
|
505
504
|
};
|
|
506
505
|
const FilterSelection = ({ filterBarDefinition, filterBarConfig, hiddenFilters = [], className, disableCollapse, }) => {
|
|
507
506
|
const hideInFilterBar = useMemo(() => {
|
|
508
|
-
return
|
|
507
|
+
return objectValues(filterBarDefinition)
|
|
509
508
|
.map(filter => {
|
|
510
509
|
const showInFilterBar = filter.showInFilterBar ? filter.showInFilterBar() : true;
|
|
511
510
|
return !showInFilterBar ? filter.filterKey : null;
|
|
512
511
|
})
|
|
513
512
|
.filter(truthy);
|
|
514
513
|
}, [filterBarDefinition]);
|
|
515
|
-
const { filtersGrouped } = useStarredGroupFilters(
|
|
514
|
+
const { filtersGrouped } = useStarredGroupFilters(objectValues(filterBarDefinition), [
|
|
516
515
|
...hideInFilterBar,
|
|
517
516
|
...hiddenFilters,
|
|
518
517
|
]);
|
|
@@ -553,34 +552,6 @@ const toggleFilterValue = (value) => {
|
|
|
553
552
|
};
|
|
554
553
|
};
|
|
555
554
|
|
|
556
|
-
/**
|
|
557
|
-
* Render a virtualized list of items
|
|
558
|
-
*
|
|
559
|
-
* @template T - The type of data items in the list.
|
|
560
|
-
* @returns {JSX.Element} - Returns the virtualized list component.
|
|
561
|
-
*/
|
|
562
|
-
const VirtualizedList = ({ parentRef, count, rowHeight = 40, children, }) => {
|
|
563
|
-
const rowVirtualizer = useVirtualizer({
|
|
564
|
-
count,
|
|
565
|
-
getScrollElement: () => parentRef.current,
|
|
566
|
-
estimateSize: useCallback((i) => rowHeight, [rowHeight]),
|
|
567
|
-
overscan: 10,
|
|
568
|
-
});
|
|
569
|
-
useEffect(() => {
|
|
570
|
-
// this ensures the cache is cleared if the rowHeight changes
|
|
571
|
-
if (rowHeight) {
|
|
572
|
-
rowVirtualizer.measure();
|
|
573
|
-
}
|
|
574
|
-
}, [rowHeight, rowVirtualizer]);
|
|
575
|
-
return (jsx("div", { className: "relative", style: { height: rowVirtualizer.getTotalSize() }, children: rowVirtualizer.getVirtualItems().map((virtualRow, index) => (jsx("div", { style: {
|
|
576
|
-
position: "absolute",
|
|
577
|
-
top: 0,
|
|
578
|
-
left: 0,
|
|
579
|
-
width: "100%",
|
|
580
|
-
transform: `translateY(${virtualRow.start}px)`,
|
|
581
|
-
}, children: children(virtualRow.index) }, virtualRow.index))) }));
|
|
582
|
-
};
|
|
583
|
-
|
|
584
555
|
/**
|
|
585
556
|
* DynamicFilterList is a React component that displays a list of dynamic filters with options like CheckBoxes or Radio buttons.
|
|
586
557
|
*
|
|
@@ -590,7 +561,7 @@ const DynamicFilterList = ({ rowCount, keyMapper, labelMapper, prefixMapper, onC
|
|
|
590
561
|
const [t] = useTranslation();
|
|
591
562
|
const parentRef = useRef(null);
|
|
592
563
|
const updatedRowCount = useMemo(() => (showRequestMoreUseSearch ? rowCount + 1 : rowCount), [rowCount, showRequestMoreUseSearch]);
|
|
593
|
-
return (jsx(FilterBody, { limitSize: true, ref: parentRef, children: jsx(VirtualizedList, { count: updatedRowCount,
|
|
564
|
+
return (jsx(FilterBody, { limitSize: true, ref: parentRef, children: jsx(VirtualizedList, { count: updatedRowCount, rowHeight: 40, separator: "none", children: index => {
|
|
594
565
|
return (jsx("div", { children: showRequestMoreUseSearch && index === rowCount ? (jsxs("div", { className: "p-3 pt-2", children: [jsx("span", { className: "text-sm text-gray-600", children: t("filter.more.options.if.you.search.title", { count: rowCount }) }), jsx("br", {}), jsx("span", { className: "text-sm italic text-gray-400", children: t("filter.more.options.if.you.search.description") })] })) : type === "Radio" ? (jsx(RadioFilterItem, { dataTestId: "dynamic-filter-radio-" + keyMapper(index), itemCount: count(index), label: labelMapper(index), prefix: prefixMapper === null || prefixMapper === void 0 ? void 0 : prefixMapper(index), selected: checked(index), value: keyMapper(index) }, keyMapper(index))) : (jsx(CheckBoxFilterItem, { checked: checked(index), dataTestId: "dynamic-filter-check-box-" + keyMapper(index), itemCount: count(index), label: labelMapper(index), name: keyMapper(index), onChange: () => onChange === null || onChange === void 0 ? void 0 : onChange(index), prefix: prefixMapper === null || prefixMapper === void 0 ? void 0 : prefixMapper(index), showTooltip: showTooltip }, keyMapper(index))) }));
|
|
595
566
|
} }) }));
|
|
596
567
|
};
|
|
@@ -606,7 +577,7 @@ const FilterHeader = ({ filterKey, title, searchEnabled, searchProps, filterHasC
|
|
|
606
577
|
resetIndividualFilterToInitialState(filterKey);
|
|
607
578
|
onResetFilter === null || onResetFilter === void 0 ? void 0 : onResetFilter();
|
|
608
579
|
};
|
|
609
|
-
return (jsx(FilterHeader$1, { dataTestId: `${filterKey}-filter-header`, loading: loading, onReset: handleResetFilter, resetLabel: t("filtersBar.resetFilter"), showReset: filterHasChanged(filterKey), title: title, children: searchEnabled ? (jsx(Search, { autoFocus: true, fieldSize: "small", onChange: e => searchProps.onChange(e.currentTarget.value), placeholder: t("assetFilters.searchPlaceholder"),
|
|
580
|
+
return (jsx(FilterHeader$1, { dataTestId: `${filterKey}-filter-header`, loading: loading, onReset: handleResetFilter, resetLabel: t("filtersBar.resetFilter"), showReset: filterHasChanged(filterKey), title: title, children: searchEnabled ? (jsx(Search, { autoFocus: true, fieldSize: "small", onChange: e => searchProps.onChange(e.currentTarget.value), placeholder: t("assetFilters.searchPlaceholder"), suffix: jsx(Text, { size: "small", subtle: true, children: searchProps.count }), value: searchProps.value })) : null }));
|
|
610
581
|
};
|
|
611
582
|
|
|
612
583
|
/**
|
|
@@ -913,6 +884,7 @@ const hasValue = (value) => {
|
|
|
913
884
|
if (value === undefined || value === null) {
|
|
914
885
|
return false;
|
|
915
886
|
}
|
|
887
|
+
// eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
916
888
|
if (typeof value === "object" && Object.keys(value).length === 0) {
|
|
917
889
|
return false;
|
|
918
890
|
}
|
|
@@ -933,7 +905,8 @@ const isNotRightType = (filterDefinition, foundFilter) => {
|
|
|
933
905
|
*/
|
|
934
906
|
const isMinMaxFilterValue = (value) => {
|
|
935
907
|
return value
|
|
936
|
-
?
|
|
908
|
+
? // eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
909
|
+
typeof value === "object" && (Object.keys(value).includes("min") || Object.keys(value).includes("max"))
|
|
937
910
|
: false;
|
|
938
911
|
};
|
|
939
912
|
/**
|
|
@@ -941,7 +914,8 @@ const isMinMaxFilterValue = (value) => {
|
|
|
941
914
|
*/
|
|
942
915
|
const isDateRangeValue = (value) => {
|
|
943
916
|
return value
|
|
944
|
-
?
|
|
917
|
+
? // eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
918
|
+
typeof value === "object" && (Object.keys(value).includes("from") || Object.keys(value).includes("to"))
|
|
945
919
|
: false;
|
|
946
920
|
};
|
|
947
921
|
/**
|
|
@@ -949,7 +923,8 @@ const isDateRangeValue = (value) => {
|
|
|
949
923
|
*/
|
|
950
924
|
const isBoundingBox = (value) => {
|
|
951
925
|
return value
|
|
952
|
-
?
|
|
926
|
+
? // eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
927
|
+
typeof value === "object" && Object.keys(value).includes("nw") && Object.keys(value).includes("se")
|
|
953
928
|
: false;
|
|
954
929
|
};
|
|
955
930
|
/**
|
|
@@ -968,6 +943,7 @@ const isStringArrayFilterValue = (value) => {
|
|
|
968
943
|
*
|
|
969
944
|
*/
|
|
970
945
|
const isBooleanValue = (value) => {
|
|
946
|
+
// eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
971
947
|
return value ? typeof value === "object" && Object.keys(value).includes("booleanValue") : false;
|
|
972
948
|
};
|
|
973
949
|
/**
|
|
@@ -975,7 +951,9 @@ const isBooleanValue = (value) => {
|
|
|
975
951
|
*/
|
|
976
952
|
const isValueNameFilterValue = (value) => {
|
|
977
953
|
return (isArrayFilterValue(value) &&
|
|
978
|
-
value.every(
|
|
954
|
+
value.every(
|
|
955
|
+
// eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
956
|
+
item => typeof item === "object" && Object.keys(item).includes("name") && Object.keys(item).includes("value")));
|
|
979
957
|
};
|
|
980
958
|
/**
|
|
981
959
|
* Validates a filter configuration against filter definitions.
|
|
@@ -988,6 +966,7 @@ const isValueNameFilterValue = (value) => {
|
|
|
988
966
|
const validateFilter = (filter, filterDefinitions) => {
|
|
989
967
|
const stateKeys = [];
|
|
990
968
|
let inBadState = false;
|
|
969
|
+
// eslint-disable-next-line local-rules/prefer-custom-object-keys
|
|
991
970
|
for (const key of Object.keys((filter === null || filter === void 0 ? void 0 : filter.values) || {})) {
|
|
992
971
|
if (filterDefinitions.find(filterDefinition => filterDefinition.filterKey === key)) {
|
|
993
972
|
stateKeys.push(key);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/filters-filter-bar",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.249",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"jest-fetch-mock": "^3.0.3",
|
|
19
19
|
"@trackunit/react-core-contexts-api": "*",
|
|
20
20
|
"@trackunit/i18n-library-translation": "*",
|
|
21
|
-
"@tanstack/react-virtual": "3.0.0-beta.68",
|
|
22
21
|
"@trackunit/css-class-variance-utilities": "*",
|
|
23
22
|
"tailwind-merge": "^2.0.0"
|
|
24
23
|
},
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { RefObject } from "react";
|
|
2
|
-
interface VirtualizedListProps<T extends HTMLElement> {
|
|
3
|
-
/**
|
|
4
|
-
* A reference to the parent container element that holds the virtualized list.
|
|
5
|
-
*/
|
|
6
|
-
parentRef: RefObject<T>;
|
|
7
|
-
/**
|
|
8
|
-
* The total number of items in the virtualized list.
|
|
9
|
-
*/
|
|
10
|
-
count: number;
|
|
11
|
-
rowHeight?: number;
|
|
12
|
-
/**
|
|
13
|
-
* A function that takes an index and returns the JSX element to be rendered for that index.
|
|
14
|
-
*
|
|
15
|
-
* @param index - The index of the item to render.
|
|
16
|
-
* @returns The JSX element representing the item at the specified index.
|
|
17
|
-
*/
|
|
18
|
-
children: (index: number) => JSX.Element;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Render a virtualized list of items
|
|
22
|
-
*
|
|
23
|
-
* @template T - The type of data items in the list.
|
|
24
|
-
* @returns {JSX.Element} - Returns the virtualized list component.
|
|
25
|
-
*/
|
|
26
|
-
export declare const VirtualizedList: <T extends HTMLElement>({ parentRef, count, rowHeight, children, }: VirtualizedListProps<T>) => JSX.Element;
|
|
27
|
-
export {};
|