@trackunit/filters-filter-bar 1.8.18 → 1.8.20
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 +23 -14
- package/index.esm.js +24 -15
- package/package.json +13 -13
package/index.cjs.js
CHANGED
|
@@ -488,6 +488,7 @@ const toggleFilterValue = (value) => {
|
|
|
488
488
|
};
|
|
489
489
|
};
|
|
490
490
|
|
|
491
|
+
const ITEM_HEIGHT = 28; //measured in DevTools on 03/10/2025
|
|
491
492
|
/**
|
|
492
493
|
* DynamicFilterList is a React component that displays a list of dynamic filters with options like CheckBoxes or Radio buttons.
|
|
493
494
|
*
|
|
@@ -497,22 +498,30 @@ const DynamicFilterList = ({ rowCount, keyMapper, labelMapper, onChange, checked
|
|
|
497
498
|
const [t] = useTranslation();
|
|
498
499
|
const parentRef = react.useRef(null);
|
|
499
500
|
const updatedRowCount = react.useMemo(() => (showRequestMoreUseSearch ? rowCount + 1 : rowCount), [rowCount, showRequestMoreUseSearch]);
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
501
|
+
const list = reactComponents.useList({
|
|
502
|
+
count: updatedRowCount,
|
|
503
|
+
getItem: index => {
|
|
504
|
+
if (showRequestMoreUseSearch && index === rowCount) {
|
|
505
|
+
return { type: "search-more" };
|
|
506
|
+
}
|
|
507
|
+
return {
|
|
508
|
+
type: "filter-item",
|
|
509
|
+
key: keyMapper(index),
|
|
510
|
+
label: labelMapper(index),
|
|
511
|
+
itemCount: count(index),
|
|
512
|
+
isChecked: checked(index),
|
|
513
|
+
index,
|
|
514
|
+
};
|
|
515
|
+
},
|
|
516
|
+
estimateItemSize: () => ITEM_HEIGHT,
|
|
517
|
+
});
|
|
518
|
+
return (jsxRuntime.jsx(reactFilterComponents.FilterBody, { limitSize: true, ref: parentRef, children: jsxRuntime.jsx(reactComponents.List, { className: className, ...list, separator: "none", children: ({ key, listItemProps, item }) => {
|
|
519
|
+
if (!item) {
|
|
520
|
+
return null;
|
|
503
521
|
}
|
|
504
|
-
return {
|
|
505
|
-
type: "filter-item",
|
|
506
|
-
key: keyMapper(index),
|
|
507
|
-
label: labelMapper(index),
|
|
508
|
-
itemCount: count(index),
|
|
509
|
-
isChecked: checked(index),
|
|
510
|
-
index,
|
|
511
|
-
};
|
|
512
|
-
}, separator: "none", children: (listItemProps, item, index) => {
|
|
513
|
-
return (jsxRuntime.jsx("li", { ...listItemProps, className: tailwindMerge.twMerge(listItemProps.className, "[&:not(:last-child)]:pb-0.5"), children: item.type === "search-more" ? (jsxRuntime.jsxs("div", { className: "p-3 pt-2", children: [jsxRuntime.jsx("span", { className: "text-sm text-neutral-600", children: t("filter.more.options.if.you.search.title", { count: rowCount }) }), jsxRuntime.jsx("br", {}), jsxRuntime.jsx("span", { className: "text-sm italic text-neutral-400", children: t("filter.more.options.if.you.search.description") })] })) : type === "Radio" ? (jsxRuntime.jsx(reactFilterComponents.RadioFilterItem, { dataTestId: "dynamic-filter-radio-" + item.key, itemCount: item.itemCount, label: item.label, selected: item.isChecked, value: item.key }, item.key)) : (jsxRuntime.jsx(reactFilterComponents.CheckBoxFilterItem, { checked: item.isChecked, dataTestId: "dynamic-filter-check-box-" + item.key, itemCount: item.itemCount, label: item.label, name: item.key, onChange: () => {
|
|
522
|
+
return (jsxRuntime.jsx("li", { ...listItemProps, className: tailwindMerge.twMerge(listItemProps.className, "[&:not(:last-child)]:pb-0.5"), children: item.type === "search-more" ? (jsxRuntime.jsxs("div", { className: "p-3 pt-2", children: [jsxRuntime.jsx("span", { className: "text-sm text-neutral-600", children: t("filter.more.options.if.you.search.title", { count: rowCount }) }), jsxRuntime.jsx("br", {}), jsxRuntime.jsx("span", { className: "text-sm italic text-neutral-400", children: t("filter.more.options.if.you.search.description") })] })) : type === "Radio" ? (jsxRuntime.jsx(reactFilterComponents.RadioFilterItem, { dataTestId: "dynamic-filter-radio-" + item.key, itemCount: item.itemCount, label: item.label, selected: item.isChecked, value: item.key })) : (jsxRuntime.jsx(reactFilterComponents.CheckBoxFilterItem, { checked: item.isChecked, dataTestId: "dynamic-filter-check-box-" + item.key, itemCount: item.itemCount, label: item.label, name: item.key, onChange: () => {
|
|
514
523
|
onChange?.(item.index);
|
|
515
|
-
} }
|
|
524
|
+
} })) }, key));
|
|
516
525
|
} }) }));
|
|
517
526
|
};
|
|
518
527
|
|
package/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
|
|
3
3
|
import { useMemo, useRef, useState, useEffect, useCallback, Fragment as Fragment$1 } from 'react';
|
|
4
4
|
import { Filter, FilterBody, RadioFilterItem, CheckBoxFilterItem, FilterHeader as FilterHeader$1, FilterFooter } from '@trackunit/react-filter-components';
|
|
5
|
-
import { Button, Icon, List, Text, Card, CardBody, useViewportBreakpoints, Popover, PopoverTrigger, Tooltip, Badge, PopoverContent, IconButton, MenuList } from '@trackunit/react-components';
|
|
5
|
+
import { Button, Icon, useList, List, Text, Card, CardBody, useViewportBreakpoints, Popover, PopoverTrigger, Tooltip, Badge, PopoverContent, IconButton, MenuList } from '@trackunit/react-components';
|
|
6
6
|
import { useAnalytics, useTextSearch, useCurrentUser, useCustomEncoding } from '@trackunit/react-core-hooks';
|
|
7
7
|
import { capitalize } from 'string-ts';
|
|
8
8
|
import { createEvent } from '@trackunit/react-core-contexts-api';
|
|
@@ -486,6 +486,7 @@ const toggleFilterValue = (value) => {
|
|
|
486
486
|
};
|
|
487
487
|
};
|
|
488
488
|
|
|
489
|
+
const ITEM_HEIGHT = 28; //measured in DevTools on 03/10/2025
|
|
489
490
|
/**
|
|
490
491
|
* DynamicFilterList is a React component that displays a list of dynamic filters with options like CheckBoxes or Radio buttons.
|
|
491
492
|
*
|
|
@@ -495,22 +496,30 @@ const DynamicFilterList = ({ rowCount, keyMapper, labelMapper, onChange, checked
|
|
|
495
496
|
const [t] = useTranslation();
|
|
496
497
|
const parentRef = useRef(null);
|
|
497
498
|
const updatedRowCount = useMemo(() => (showRequestMoreUseSearch ? rowCount + 1 : rowCount), [rowCount, showRequestMoreUseSearch]);
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
499
|
+
const list = useList({
|
|
500
|
+
count: updatedRowCount,
|
|
501
|
+
getItem: index => {
|
|
502
|
+
if (showRequestMoreUseSearch && index === rowCount) {
|
|
503
|
+
return { type: "search-more" };
|
|
504
|
+
}
|
|
505
|
+
return {
|
|
506
|
+
type: "filter-item",
|
|
507
|
+
key: keyMapper(index),
|
|
508
|
+
label: labelMapper(index),
|
|
509
|
+
itemCount: count(index),
|
|
510
|
+
isChecked: checked(index),
|
|
511
|
+
index,
|
|
512
|
+
};
|
|
513
|
+
},
|
|
514
|
+
estimateItemSize: () => ITEM_HEIGHT,
|
|
515
|
+
});
|
|
516
|
+
return (jsx(FilterBody, { limitSize: true, ref: parentRef, children: jsx(List, { className: className, ...list, separator: "none", children: ({ key, listItemProps, item }) => {
|
|
517
|
+
if (!item) {
|
|
518
|
+
return null;
|
|
501
519
|
}
|
|
502
|
-
return {
|
|
503
|
-
type: "filter-item",
|
|
504
|
-
key: keyMapper(index),
|
|
505
|
-
label: labelMapper(index),
|
|
506
|
-
itemCount: count(index),
|
|
507
|
-
isChecked: checked(index),
|
|
508
|
-
index,
|
|
509
|
-
};
|
|
510
|
-
}, separator: "none", children: (listItemProps, item, index) => {
|
|
511
|
-
return (jsx("li", { ...listItemProps, className: twMerge(listItemProps.className, "[&:not(:last-child)]:pb-0.5"), children: item.type === "search-more" ? (jsxs("div", { className: "p-3 pt-2", children: [jsx("span", { className: "text-sm text-neutral-600", children: t("filter.more.options.if.you.search.title", { count: rowCount }) }), jsx("br", {}), jsx("span", { className: "text-sm italic text-neutral-400", children: t("filter.more.options.if.you.search.description") })] })) : type === "Radio" ? (jsx(RadioFilterItem, { dataTestId: "dynamic-filter-radio-" + item.key, itemCount: item.itemCount, label: item.label, selected: item.isChecked, value: item.key }, item.key)) : (jsx(CheckBoxFilterItem, { checked: item.isChecked, dataTestId: "dynamic-filter-check-box-" + item.key, itemCount: item.itemCount, label: item.label, name: item.key, onChange: () => {
|
|
520
|
+
return (jsx("li", { ...listItemProps, className: twMerge(listItemProps.className, "[&:not(:last-child)]:pb-0.5"), children: item.type === "search-more" ? (jsxs("div", { className: "p-3 pt-2", children: [jsx("span", { className: "text-sm text-neutral-600", children: t("filter.more.options.if.you.search.title", { count: rowCount }) }), jsx("br", {}), jsx("span", { className: "text-sm italic text-neutral-400", children: t("filter.more.options.if.you.search.description") })] })) : type === "Radio" ? (jsx(RadioFilterItem, { dataTestId: "dynamic-filter-radio-" + item.key, itemCount: item.itemCount, label: item.label, selected: item.isChecked, value: item.key })) : (jsx(CheckBoxFilterItem, { checked: item.isChecked, dataTestId: "dynamic-filter-check-box-" + item.key, itemCount: item.itemCount, label: item.label, name: item.key, onChange: () => {
|
|
512
521
|
onChange?.(item.index);
|
|
513
|
-
} }
|
|
522
|
+
} })) }, key));
|
|
514
523
|
} }) }));
|
|
515
524
|
};
|
|
516
525
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/filters-filter-bar",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.20",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
"tailwind-merge": "^2.0.0",
|
|
14
14
|
"string-ts": "^2.0.0",
|
|
15
15
|
"zod": "^3.23.8",
|
|
16
|
-
"@trackunit/iris-app-api": "1.7.
|
|
17
|
-
"@trackunit/react-core-hooks": "1.7.
|
|
18
|
-
"@trackunit/react-filter-components": "1.7.
|
|
19
|
-
"@trackunit/react-date-and-time-components": "1.10.
|
|
20
|
-
"@trackunit/shared-utils": "1.9.
|
|
21
|
-
"@trackunit/react-form-components": "1.8.
|
|
22
|
-
"@trackunit/react-core-contexts-api": "1.8.
|
|
23
|
-
"@trackunit/geo-json-utils": "1.7.
|
|
24
|
-
"@trackunit/i18n-library-translation": "1.7.
|
|
25
|
-
"@trackunit/css-class-variance-utilities": "1.7.
|
|
26
|
-
"@trackunit/react-components": "1.9.
|
|
27
|
-
"@trackunit/react-test-setup": "1.4.
|
|
16
|
+
"@trackunit/iris-app-api": "1.7.13",
|
|
17
|
+
"@trackunit/react-core-hooks": "1.7.15",
|
|
18
|
+
"@trackunit/react-filter-components": "1.7.20",
|
|
19
|
+
"@trackunit/react-date-and-time-components": "1.10.20",
|
|
20
|
+
"@trackunit/shared-utils": "1.9.12",
|
|
21
|
+
"@trackunit/react-form-components": "1.8.20",
|
|
22
|
+
"@trackunit/react-core-contexts-api": "1.8.14",
|
|
23
|
+
"@trackunit/geo-json-utils": "1.7.12",
|
|
24
|
+
"@trackunit/i18n-library-translation": "1.7.16",
|
|
25
|
+
"@trackunit/css-class-variance-utilities": "1.7.12",
|
|
26
|
+
"@trackunit/react-components": "1.9.20",
|
|
27
|
+
"@trackunit/react-test-setup": "1.4.12",
|
|
28
28
|
"@tanstack/react-router": "1.114.29"
|
|
29
29
|
},
|
|
30
30
|
"module": "./index.esm.js",
|