@trackunit/filters-filter-bar 1.3.201 → 1.3.202
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
CHANGED
|
@@ -110,7 +110,7 @@ var defaultTranslations = {
|
|
|
110
110
|
"filter.more.options.if.you.search.title": "Over {{count}} items found.",
|
|
111
111
|
"filtersBar.appliedFiltersTooltip.none": "No filters applied",
|
|
112
112
|
"filtersBar.appliedFiltersTooltip.plural": "{{count}} filters applied:",
|
|
113
|
-
"filtersBar.appliedFiltersTooltip.singular": "{{filterName}} filter applied
|
|
113
|
+
"filtersBar.appliedFiltersTooltip.singular": "{{filterName}} filter applied",
|
|
114
114
|
"filtersBar.defaultAssetFilters.followedFilter.ALL": "All Assets",
|
|
115
115
|
"filtersBar.defaultAssetFilters.followedFilter.allLabel": "All Assets",
|
|
116
116
|
"filtersBar.defaultAssetFilters.followedFilter.FOLLOWED": "Followed Only",
|
|
@@ -919,40 +919,28 @@ const CustomFieldsHiddenGroup = ({ appliedCustomFields, filterBarConfig, onShow,
|
|
|
919
919
|
* @returns {ReactElement} The rendered TooltipValues component.
|
|
920
920
|
*/
|
|
921
921
|
const TooltipValues = ({ values }) => {
|
|
922
|
-
return jsxRuntime.jsx("div", { children: renderTooltipValues(values) });
|
|
923
|
-
};
|
|
924
|
-
const renderTooltipValues = (values) => {
|
|
925
922
|
if (values === undefined) {
|
|
926
|
-
return
|
|
923
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
927
924
|
}
|
|
928
925
|
// Array of objects ValueName[]
|
|
929
926
|
if (Array.isArray(values) && typeof values[0] === "object") {
|
|
930
|
-
return (jsxRuntime.jsx("ul", { className: "list-inside", children: values.map((value, index) => (jsxRuntime.jsx("li", { className: "list-disc", children: value.name }, index))) }));
|
|
927
|
+
return (jsxRuntime.jsx("ul", { className: "list-inside pl-2", children: values.map((value, index) => (jsxRuntime.jsx("li", { className: "list-disc text-xs font-normal", children: value.name }, index))) }));
|
|
931
928
|
}
|
|
932
929
|
// Array of strings
|
|
933
|
-
if (Array.isArray(values)) {
|
|
934
|
-
return (jsxRuntime.jsx("ul", { className: "list-inside", children: values.map((value, index) => {
|
|
935
|
-
return (jsxRuntime.jsx("li", { className: "list-disc", children: typeof value === "string" ? value : value.name }, index));
|
|
930
|
+
if (Array.isArray(values) && typeof values[0] === "string") {
|
|
931
|
+
return (jsxRuntime.jsx("ul", { className: "list-inside pl-2", children: values.map((value, index) => {
|
|
932
|
+
return (jsxRuntime.jsx("li", { className: "list-disc text-xs font-normal", children: typeof value === "string" ? value : value.name }, index));
|
|
936
933
|
}) }));
|
|
937
934
|
}
|
|
938
935
|
// single object ValueName
|
|
939
936
|
if (typeof values === "object" && values.name) {
|
|
940
|
-
return (jsxRuntime.jsx("ul", { className: "list-inside", children: jsxRuntime.jsx("li", { className: "list-disc", children: values.name }) }));
|
|
937
|
+
return (jsxRuntime.jsx("ul", { className: "list-inside pl-2", children: jsxRuntime.jsx("li", { className: "list-disc text-xs font-normal", children: values.name }) }));
|
|
941
938
|
}
|
|
942
939
|
// String or number
|
|
943
940
|
if (typeof values === "string" || typeof values === "number") {
|
|
944
|
-
return (jsxRuntime.jsx("ul", { className: "list-inside", children: jsxRuntime.jsx("li", { className: "list-disc", children: values.toString() }) }));
|
|
945
|
-
}
|
|
946
|
-
// BooleanValue
|
|
947
|
-
if (typeof values === "object" && values.booleanValue !== undefined) {
|
|
948
|
-
return values.booleanValue ? "Yes" : "No";
|
|
941
|
+
return (jsxRuntime.jsx("ul", { className: "list-inside pl-2", children: jsxRuntime.jsx("li", { className: "list-disc text-xs font-normal", children: values.toString() }) }));
|
|
949
942
|
}
|
|
950
|
-
|
|
951
|
-
if (typeof values === "object" && "min" in values && "max" in values) {
|
|
952
|
-
const minMax = values;
|
|
953
|
-
return `Min: ${minMax.min}, Max: ${minMax.max}`;
|
|
954
|
-
}
|
|
955
|
-
return null;
|
|
943
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
956
944
|
};
|
|
957
945
|
|
|
958
946
|
/**
|
|
@@ -965,13 +953,16 @@ const renderTooltipValues = (values) => {
|
|
|
965
953
|
* @param {string} props.filterKey - The key identifying the filter.
|
|
966
954
|
* @returns {ReactElement} The rendered tooltip label and applied filter values.
|
|
967
955
|
*/
|
|
968
|
-
const SingleFilterTooltipLabel = ({ filterBarConfig, filterKey, }) => {
|
|
969
|
-
const title = filterBarConfig.getFilterTitle(filterKey);
|
|
970
|
-
const values = filterBarConfig.getValuesByKey(filterKey);
|
|
971
|
-
const
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
956
|
+
const SingleFilterTooltipLabel = ({ filterBarConfig, filter, filterKey, }) => {
|
|
957
|
+
const title = react.useMemo(() => filterBarConfig.getFilterTitle(filterKey), [filterBarConfig, filterKey]);
|
|
958
|
+
const values = react.useMemo(() => filterBarConfig.getValuesByKey(filterKey), [filterBarConfig, filterKey]);
|
|
959
|
+
const displayValues = react.useMemo(() => {
|
|
960
|
+
if (filter?.valueAsText) {
|
|
961
|
+
return filter.valueAsText(values);
|
|
962
|
+
}
|
|
963
|
+
return values;
|
|
964
|
+
}, [filter, values]);
|
|
965
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "text-xs font-medium", children: title }), jsxRuntime.jsx(TooltipValues, { values: displayValues })] }));
|
|
975
966
|
};
|
|
976
967
|
|
|
977
968
|
/**
|
|
@@ -985,22 +976,23 @@ const SingleFilterTooltipLabel = ({ filterBarConfig, filterKey, }) => {
|
|
|
985
976
|
* @param {string[]} [props.filterKeys] An optional list of filter keys to filter the currently applied filters.
|
|
986
977
|
* @returns {ReactElement | string} Returns a element or string for the tooltip displaying applied filters.
|
|
987
978
|
*/
|
|
988
|
-
const MultipleFilterTooltipLabel = ({ filterBarConfig, filterKeys, }) => {
|
|
979
|
+
const MultipleFilterTooltipLabel = ({ filterBarConfig, filterKeys, filters, }) => {
|
|
989
980
|
const [t] = useTranslation();
|
|
990
|
-
const
|
|
991
|
-
|
|
992
|
-
|
|
981
|
+
const appliedKeys = filterBarConfig.appliedFilterKeys();
|
|
982
|
+
const appliedFilterKeys = filterKeys ? filterKeys.filter(key => appliedKeys.includes(key)) : appliedKeys;
|
|
983
|
+
const filtersMap = filters.reduce((acc, filter) => {
|
|
984
|
+
if (filter.filterKey) {
|
|
985
|
+
acc[filter.filterKey] = filter;
|
|
986
|
+
}
|
|
987
|
+
return acc;
|
|
988
|
+
}, {});
|
|
993
989
|
switch (appliedFilterKeys.length) {
|
|
994
990
|
case 0:
|
|
995
991
|
return t("filtersBar.appliedFiltersTooltip.none");
|
|
996
992
|
case 1:
|
|
997
|
-
return jsxRuntime.jsx(SingleFilterTooltipLabel, { filterBarConfig: filterBarConfig, filterKey: appliedFilterKeys[0] });
|
|
993
|
+
return (jsxRuntime.jsx(SingleFilterTooltipLabel, { filter: filtersMap[appliedFilterKeys[0]], filterBarConfig: filterBarConfig, filterKey: appliedFilterKeys[0] }));
|
|
998
994
|
default:
|
|
999
|
-
return (jsxRuntime.
|
|
1000
|
-
const title = filterBarConfig.getFilterTitle(filterKey);
|
|
1001
|
-
const values = filterBarConfig.getValuesByKey(filterKey);
|
|
1002
|
-
return filterBarConfig.appliedFilterKeys().includes(filterKey) ? (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", { children: [title, ":"] }), jsxRuntime.jsx(TooltipValues, { values: values })] }, filterKey)) : null;
|
|
1003
|
-
})] }));
|
|
995
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: appliedFilterKeys.map(filterKey => (jsxRuntime.jsx(SingleFilterTooltipLabel, { filter: filtersMap[filterKey], filterBarConfig: filterBarConfig, filterKey: filterKey }, filterKey))) }));
|
|
1004
996
|
}
|
|
1005
997
|
};
|
|
1006
998
|
|
|
@@ -1026,7 +1018,7 @@ const FiltersMenu = ({ filterBarDefinition, filterBarConfig, hiddenFilters = [],
|
|
|
1026
1018
|
setSearchText("");
|
|
1027
1019
|
}
|
|
1028
1020
|
}, placement: "bottom-start", children: modalState => {
|
|
1029
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { children: jsxRuntime.jsx("div", { "data-testid": "starred-filters-menu-trigger", id: "starred-filters-menu-trigger", children: jsxRuntime.jsx(reactComponents.Tooltip, { disabled: !compact || modalState.isOpen, label: jsxRuntime.jsx(MultipleFilterTooltipLabel, { filterBarConfig: filterBarConfig }), children: jsxRuntime.jsx(reactComponents.Button, { prefix: jsxRuntime.jsx(reactComponents.Icon, { ariaHidden: true, color: filterBarConfig.appliedFilterKeys().length > 0 ? "primary" : undefined, name: "Filter", size: "small" }), size: "small", suffix: compact && showAppliedFiltersCount && filterBarConfig.appliedFilterKeys().length > 0 && isSm ? (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("span", { "aria-hidden": true, children: ["(", filterBarConfig.appliedFilterKeys().length, ")"] }), jsxRuntime.jsxs("span", { className: "sr-only", children: [filterBarConfig.appliedFilterKeys().length, " filters applied"] })] })) : undefined, variant: "secondary", ...buttonProps, children: title !== "" ? (jsxRuntime.jsx("span", { className: "hidden sm:block", children: title ?? t("filtersBar.filtersHeading") })) : null }) }) }) }), jsxRuntime.jsx(reactComponents.PopoverContent, { cellPadding: 100, children: jsxRuntime.jsx(FiltersMenuContent, { appliedCustomFields: appliedCustomFields, filterBarConfig: filterBarConfig, filtersToShowGrouped: filtersToShowGrouped, hasCustomFields: hasCustomFields, removeCustomFieldsGroup: removeCustomFieldsGroup, searchResultsGrouped: searchResultsGrouped, searchText: searchText, setSearchText: setSearchText, setShowCustomFilters: setShowCustomFilters, showCustomFilters: showCustomFilters }) })] }));
|
|
1021
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { children: jsxRuntime.jsx("div", { "data-testid": "starred-filters-menu-trigger", id: "starred-filters-menu-trigger", children: jsxRuntime.jsx(reactComponents.Tooltip, { disabled: !compact || modalState.isOpen, label: jsxRuntime.jsx(MultipleFilterTooltipLabel, { filterBarConfig: filterBarConfig, filters: appliedFilters }), children: jsxRuntime.jsx(reactComponents.Button, { prefix: jsxRuntime.jsx(reactComponents.Icon, { ariaHidden: true, color: filterBarConfig.appliedFilterKeys().length > 0 ? "primary" : undefined, name: "Filter", size: "small" }), size: "small", suffix: compact && showAppliedFiltersCount && filterBarConfig.appliedFilterKeys().length > 0 && isSm ? (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("span", { "aria-hidden": true, children: ["(", filterBarConfig.appliedFilterKeys().length, ")"] }), jsxRuntime.jsxs("span", { className: "sr-only", children: [filterBarConfig.appliedFilterKeys().length, " filters applied"] })] })) : undefined, variant: "secondary", ...buttonProps, children: title !== "" ? (jsxRuntime.jsx("span", { className: "hidden sm:block", children: title ?? t("filtersBar.filtersHeading") })) : null }) }) }) }), jsxRuntime.jsx(reactComponents.PopoverContent, { cellPadding: 100, children: jsxRuntime.jsx(FiltersMenuContent, { appliedCustomFields: appliedCustomFields, filterBarConfig: filterBarConfig, filtersToShowGrouped: filtersToShowGrouped, hasCustomFields: hasCustomFields, removeCustomFieldsGroup: removeCustomFieldsGroup, searchResultsGrouped: searchResultsGrouped, searchText: searchText, setSearchText: setSearchText, setShowCustomFilters: setShowCustomFilters, showCustomFilters: showCustomFilters }) })] }));
|
|
1030
1022
|
} }), showDirectlyFilters.length > 0 ? (jsxRuntime.jsx(FiltersRenderer, { filterBarConfig: filterBarConfig, filters: showDirectlyFilters })) : null, !compact ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [appliedFilters.filter(filter => !filter.showDirectly).length > 0 ? (jsxRuntime.jsx("div", { className: "h-4 w-[1px] bg-slate-300", "data-testid": "applied-filters-buttons" })) : null, jsxRuntime.jsx(FiltersRenderer, { filterBarConfig: filterBarConfig, filters: appliedFilters }), filterBarConfig.appliedFilterKeys().length > 0 ? (jsxRuntime.jsx(ResetFiltersButton, { resetFiltersToInitialState: filterBarConfig.resetFiltersToInitialState })) : null] })) : null] }));
|
|
1031
1023
|
};
|
|
1032
1024
|
|
|
@@ -1049,14 +1041,14 @@ const FilterTableComponent = ({ filterKey, filterBarDefinition, filterBarConfig,
|
|
|
1049
1041
|
if (Array.isArray(filterKey)) {
|
|
1050
1042
|
const isActive = filterKey.some(key => filterBarConfig.appliedFilterKeys().includes(key));
|
|
1051
1043
|
return (jsxRuntime.jsx(reactComponents.Popover, { placement: "bottom-start", children: modalState => {
|
|
1052
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { children: jsxRuntime.jsx("div", { children: jsxRuntime.jsx(reactComponents.Tooltip, { disabled: modalState.isOpen || !isActive, label: jsxRuntime.jsx(MultipleFilterTooltipLabel, { filterBarConfig: filterBarConfig, filterKeys: filterKey }), children: jsxRuntime.jsx(reactComponents.IconButton, { icon: jsxRuntime.jsx(reactComponents.Icon, { name: "Filter", size: "small" }), size: "extraSmall", variant: isActive ? "filled" : "ghost-neutral" }) }) }) }), jsxRuntime.jsx(reactComponents.PopoverContent, { children: jsxRuntime.jsx(reactComponents.MenuList, { children: filters.map((value, index) => value && (jsxRuntime.jsx(FilterComponent, { filter: value, filterBarActions: filterBarConfig, filterState: filterBarConfig, visualStyle: "list-item" }, index))) }) })] }));
|
|
1044
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { children: jsxRuntime.jsx("div", { children: jsxRuntime.jsx(reactComponents.Tooltip, { disabled: modalState.isOpen || !isActive, label: jsxRuntime.jsx(MultipleFilterTooltipLabel, { filterBarConfig: filterBarConfig, filterKeys: filterKey, filters: filters }), placement: "bottom", children: jsxRuntime.jsx(reactComponents.IconButton, { icon: jsxRuntime.jsx(reactComponents.Icon, { name: "Filter", size: "small" }), size: "extraSmall", variant: isActive ? "filled" : "ghost-neutral" }) }) }) }), jsxRuntime.jsx(reactComponents.PopoverContent, { children: jsxRuntime.jsx(reactComponents.MenuList, { children: filters.map((value, index) => value && (jsxRuntime.jsx(FilterComponent, { filter: value, filterBarActions: filterBarConfig, filterState: filterBarConfig, visualStyle: "list-item" }, index))) }) })] }));
|
|
1053
1045
|
} }));
|
|
1054
1046
|
}
|
|
1055
1047
|
const filter = filterBarDefinition[ensureFilterKey(filterKey)];
|
|
1056
1048
|
if (!filter) {
|
|
1057
1049
|
return null;
|
|
1058
1050
|
}
|
|
1059
|
-
return (jsxRuntime.jsx("div", { onClick: event => event.stopPropagation(), children: jsxRuntime.jsx(reactComponents.Tooltip, { disabled: !filterBarConfig.appliedFilterKeys().includes(filterKey), label: jsxRuntime.jsx(SingleFilterTooltipLabel, { filterBarConfig: filterBarConfig, filterKey: filterKey }), children: jsxRuntime.jsx(FilterComponent, { asIcon: "Filter", filter: filter, filterBarActions: filterBarConfig, filterState: filterBarConfig, size: "extraSmall" }) }) }));
|
|
1051
|
+
return (jsxRuntime.jsx("div", { onClick: event => event.stopPropagation(), children: jsxRuntime.jsx(reactComponents.Tooltip, { disabled: !filterBarConfig.appliedFilterKeys().includes(filterKey), label: jsxRuntime.jsx(SingleFilterTooltipLabel, { filter: filter, filterBarConfig: filterBarConfig, filterKey: filterKey }), placement: "bottom", children: jsxRuntime.jsx(FilterComponent, { asIcon: "Filter", filter: filter, filterBarActions: filterBarConfig, filterState: filterBarConfig, size: "extraSmall" }) }) }));
|
|
1060
1052
|
};
|
|
1061
1053
|
|
|
1062
1054
|
/**
|
package/index.esm.js
CHANGED
|
@@ -108,7 +108,7 @@ var defaultTranslations = {
|
|
|
108
108
|
"filter.more.options.if.you.search.title": "Over {{count}} items found.",
|
|
109
109
|
"filtersBar.appliedFiltersTooltip.none": "No filters applied",
|
|
110
110
|
"filtersBar.appliedFiltersTooltip.plural": "{{count}} filters applied:",
|
|
111
|
-
"filtersBar.appliedFiltersTooltip.singular": "{{filterName}} filter applied
|
|
111
|
+
"filtersBar.appliedFiltersTooltip.singular": "{{filterName}} filter applied",
|
|
112
112
|
"filtersBar.defaultAssetFilters.followedFilter.ALL": "All Assets",
|
|
113
113
|
"filtersBar.defaultAssetFilters.followedFilter.allLabel": "All Assets",
|
|
114
114
|
"filtersBar.defaultAssetFilters.followedFilter.FOLLOWED": "Followed Only",
|
|
@@ -917,40 +917,28 @@ const CustomFieldsHiddenGroup = ({ appliedCustomFields, filterBarConfig, onShow,
|
|
|
917
917
|
* @returns {ReactElement} The rendered TooltipValues component.
|
|
918
918
|
*/
|
|
919
919
|
const TooltipValues = ({ values }) => {
|
|
920
|
-
return jsx("div", { children: renderTooltipValues(values) });
|
|
921
|
-
};
|
|
922
|
-
const renderTooltipValues = (values) => {
|
|
923
920
|
if (values === undefined) {
|
|
924
|
-
return
|
|
921
|
+
return jsx(Fragment, {});
|
|
925
922
|
}
|
|
926
923
|
// Array of objects ValueName[]
|
|
927
924
|
if (Array.isArray(values) && typeof values[0] === "object") {
|
|
928
|
-
return (jsx("ul", { className: "list-inside", children: values.map((value, index) => (jsx("li", { className: "list-disc", children: value.name }, index))) }));
|
|
925
|
+
return (jsx("ul", { className: "list-inside pl-2", children: values.map((value, index) => (jsx("li", { className: "list-disc text-xs font-normal", children: value.name }, index))) }));
|
|
929
926
|
}
|
|
930
927
|
// Array of strings
|
|
931
|
-
if (Array.isArray(values)) {
|
|
932
|
-
return (jsx("ul", { className: "list-inside", children: values.map((value, index) => {
|
|
933
|
-
return (jsx("li", { className: "list-disc", children: typeof value === "string" ? value : value.name }, index));
|
|
928
|
+
if (Array.isArray(values) && typeof values[0] === "string") {
|
|
929
|
+
return (jsx("ul", { className: "list-inside pl-2", children: values.map((value, index) => {
|
|
930
|
+
return (jsx("li", { className: "list-disc text-xs font-normal", children: typeof value === "string" ? value : value.name }, index));
|
|
934
931
|
}) }));
|
|
935
932
|
}
|
|
936
933
|
// single object ValueName
|
|
937
934
|
if (typeof values === "object" && values.name) {
|
|
938
|
-
return (jsx("ul", { className: "list-inside", children: jsx("li", { className: "list-disc", children: values.name }) }));
|
|
935
|
+
return (jsx("ul", { className: "list-inside pl-2", children: jsx("li", { className: "list-disc text-xs font-normal", children: values.name }) }));
|
|
939
936
|
}
|
|
940
937
|
// String or number
|
|
941
938
|
if (typeof values === "string" || typeof values === "number") {
|
|
942
|
-
return (jsx("ul", { className: "list-inside", children: jsx("li", { className: "list-disc", children: values.toString() }) }));
|
|
943
|
-
}
|
|
944
|
-
// BooleanValue
|
|
945
|
-
if (typeof values === "object" && values.booleanValue !== undefined) {
|
|
946
|
-
return values.booleanValue ? "Yes" : "No";
|
|
939
|
+
return (jsx("ul", { className: "list-inside pl-2", children: jsx("li", { className: "list-disc text-xs font-normal", children: values.toString() }) }));
|
|
947
940
|
}
|
|
948
|
-
|
|
949
|
-
if (typeof values === "object" && "min" in values && "max" in values) {
|
|
950
|
-
const minMax = values;
|
|
951
|
-
return `Min: ${minMax.min}, Max: ${minMax.max}`;
|
|
952
|
-
}
|
|
953
|
-
return null;
|
|
941
|
+
return jsx(Fragment, {});
|
|
954
942
|
};
|
|
955
943
|
|
|
956
944
|
/**
|
|
@@ -963,13 +951,16 @@ const renderTooltipValues = (values) => {
|
|
|
963
951
|
* @param {string} props.filterKey - The key identifying the filter.
|
|
964
952
|
* @returns {ReactElement} The rendered tooltip label and applied filter values.
|
|
965
953
|
*/
|
|
966
|
-
const SingleFilterTooltipLabel = ({ filterBarConfig, filterKey, }) => {
|
|
967
|
-
const title = filterBarConfig.getFilterTitle(filterKey);
|
|
968
|
-
const values = filterBarConfig.getValuesByKey(filterKey);
|
|
969
|
-
const
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
954
|
+
const SingleFilterTooltipLabel = ({ filterBarConfig, filter, filterKey, }) => {
|
|
955
|
+
const title = useMemo(() => filterBarConfig.getFilterTitle(filterKey), [filterBarConfig, filterKey]);
|
|
956
|
+
const values = useMemo(() => filterBarConfig.getValuesByKey(filterKey), [filterBarConfig, filterKey]);
|
|
957
|
+
const displayValues = useMemo(() => {
|
|
958
|
+
if (filter?.valueAsText) {
|
|
959
|
+
return filter.valueAsText(values);
|
|
960
|
+
}
|
|
961
|
+
return values;
|
|
962
|
+
}, [filter, values]);
|
|
963
|
+
return (jsxs(Fragment, { children: [jsx("div", { className: "text-xs font-medium", children: title }), jsx(TooltipValues, { values: displayValues })] }));
|
|
973
964
|
};
|
|
974
965
|
|
|
975
966
|
/**
|
|
@@ -983,22 +974,23 @@ const SingleFilterTooltipLabel = ({ filterBarConfig, filterKey, }) => {
|
|
|
983
974
|
* @param {string[]} [props.filterKeys] An optional list of filter keys to filter the currently applied filters.
|
|
984
975
|
* @returns {ReactElement | string} Returns a element or string for the tooltip displaying applied filters.
|
|
985
976
|
*/
|
|
986
|
-
const MultipleFilterTooltipLabel = ({ filterBarConfig, filterKeys, }) => {
|
|
977
|
+
const MultipleFilterTooltipLabel = ({ filterBarConfig, filterKeys, filters, }) => {
|
|
987
978
|
const [t] = useTranslation();
|
|
988
|
-
const
|
|
989
|
-
|
|
990
|
-
|
|
979
|
+
const appliedKeys = filterBarConfig.appliedFilterKeys();
|
|
980
|
+
const appliedFilterKeys = filterKeys ? filterKeys.filter(key => appliedKeys.includes(key)) : appliedKeys;
|
|
981
|
+
const filtersMap = filters.reduce((acc, filter) => {
|
|
982
|
+
if (filter.filterKey) {
|
|
983
|
+
acc[filter.filterKey] = filter;
|
|
984
|
+
}
|
|
985
|
+
return acc;
|
|
986
|
+
}, {});
|
|
991
987
|
switch (appliedFilterKeys.length) {
|
|
992
988
|
case 0:
|
|
993
989
|
return t("filtersBar.appliedFiltersTooltip.none");
|
|
994
990
|
case 1:
|
|
995
|
-
return jsx(SingleFilterTooltipLabel, { filterBarConfig: filterBarConfig, filterKey: appliedFilterKeys[0] });
|
|
991
|
+
return (jsx(SingleFilterTooltipLabel, { filter: filtersMap[appliedFilterKeys[0]], filterBarConfig: filterBarConfig, filterKey: appliedFilterKeys[0] }));
|
|
996
992
|
default:
|
|
997
|
-
return (
|
|
998
|
-
const title = filterBarConfig.getFilterTitle(filterKey);
|
|
999
|
-
const values = filterBarConfig.getValuesByKey(filterKey);
|
|
1000
|
-
return filterBarConfig.appliedFilterKeys().includes(filterKey) ? (jsxs("div", { children: [jsxs("div", { children: [title, ":"] }), jsx(TooltipValues, { values: values })] }, filterKey)) : null;
|
|
1001
|
-
})] }));
|
|
993
|
+
return (jsx(Fragment, { children: appliedFilterKeys.map(filterKey => (jsx(SingleFilterTooltipLabel, { filter: filtersMap[filterKey], filterBarConfig: filterBarConfig, filterKey: filterKey }, filterKey))) }));
|
|
1002
994
|
}
|
|
1003
995
|
};
|
|
1004
996
|
|
|
@@ -1024,7 +1016,7 @@ const FiltersMenu = ({ filterBarDefinition, filterBarConfig, hiddenFilters = [],
|
|
|
1024
1016
|
setSearchText("");
|
|
1025
1017
|
}
|
|
1026
1018
|
}, placement: "bottom-start", children: modalState => {
|
|
1027
|
-
return (jsxs(Fragment, { children: [jsx(PopoverTrigger, { children: jsx("div", { "data-testid": "starred-filters-menu-trigger", id: "starred-filters-menu-trigger", children: jsx(Tooltip, { disabled: !compact || modalState.isOpen, label: jsx(MultipleFilterTooltipLabel, { filterBarConfig: filterBarConfig }), children: jsx(Button, { prefix: jsx(Icon, { ariaHidden: true, color: filterBarConfig.appliedFilterKeys().length > 0 ? "primary" : undefined, name: "Filter", size: "small" }), size: "small", suffix: compact && showAppliedFiltersCount && filterBarConfig.appliedFilterKeys().length > 0 && isSm ? (jsxs("div", { children: [jsxs("span", { "aria-hidden": true, children: ["(", filterBarConfig.appliedFilterKeys().length, ")"] }), jsxs("span", { className: "sr-only", children: [filterBarConfig.appliedFilterKeys().length, " filters applied"] })] })) : undefined, variant: "secondary", ...buttonProps, children: title !== "" ? (jsx("span", { className: "hidden sm:block", children: title ?? t("filtersBar.filtersHeading") })) : null }) }) }) }), jsx(PopoverContent, { cellPadding: 100, children: jsx(FiltersMenuContent, { appliedCustomFields: appliedCustomFields, filterBarConfig: filterBarConfig, filtersToShowGrouped: filtersToShowGrouped, hasCustomFields: hasCustomFields, removeCustomFieldsGroup: removeCustomFieldsGroup, searchResultsGrouped: searchResultsGrouped, searchText: searchText, setSearchText: setSearchText, setShowCustomFilters: setShowCustomFilters, showCustomFilters: showCustomFilters }) })] }));
|
|
1019
|
+
return (jsxs(Fragment, { children: [jsx(PopoverTrigger, { children: jsx("div", { "data-testid": "starred-filters-menu-trigger", id: "starred-filters-menu-trigger", children: jsx(Tooltip, { disabled: !compact || modalState.isOpen, label: jsx(MultipleFilterTooltipLabel, { filterBarConfig: filterBarConfig, filters: appliedFilters }), children: jsx(Button, { prefix: jsx(Icon, { ariaHidden: true, color: filterBarConfig.appliedFilterKeys().length > 0 ? "primary" : undefined, name: "Filter", size: "small" }), size: "small", suffix: compact && showAppliedFiltersCount && filterBarConfig.appliedFilterKeys().length > 0 && isSm ? (jsxs("div", { children: [jsxs("span", { "aria-hidden": true, children: ["(", filterBarConfig.appliedFilterKeys().length, ")"] }), jsxs("span", { className: "sr-only", children: [filterBarConfig.appliedFilterKeys().length, " filters applied"] })] })) : undefined, variant: "secondary", ...buttonProps, children: title !== "" ? (jsx("span", { className: "hidden sm:block", children: title ?? t("filtersBar.filtersHeading") })) : null }) }) }) }), jsx(PopoverContent, { cellPadding: 100, children: jsx(FiltersMenuContent, { appliedCustomFields: appliedCustomFields, filterBarConfig: filterBarConfig, filtersToShowGrouped: filtersToShowGrouped, hasCustomFields: hasCustomFields, removeCustomFieldsGroup: removeCustomFieldsGroup, searchResultsGrouped: searchResultsGrouped, searchText: searchText, setSearchText: setSearchText, setShowCustomFilters: setShowCustomFilters, showCustomFilters: showCustomFilters }) })] }));
|
|
1028
1020
|
} }), showDirectlyFilters.length > 0 ? (jsx(FiltersRenderer, { filterBarConfig: filterBarConfig, filters: showDirectlyFilters })) : null, !compact ? (jsxs(Fragment, { children: [appliedFilters.filter(filter => !filter.showDirectly).length > 0 ? (jsx("div", { className: "h-4 w-[1px] bg-slate-300", "data-testid": "applied-filters-buttons" })) : null, jsx(FiltersRenderer, { filterBarConfig: filterBarConfig, filters: appliedFilters }), filterBarConfig.appliedFilterKeys().length > 0 ? (jsx(ResetFiltersButton, { resetFiltersToInitialState: filterBarConfig.resetFiltersToInitialState })) : null] })) : null] }));
|
|
1029
1021
|
};
|
|
1030
1022
|
|
|
@@ -1047,14 +1039,14 @@ const FilterTableComponent = ({ filterKey, filterBarDefinition, filterBarConfig,
|
|
|
1047
1039
|
if (Array.isArray(filterKey)) {
|
|
1048
1040
|
const isActive = filterKey.some(key => filterBarConfig.appliedFilterKeys().includes(key));
|
|
1049
1041
|
return (jsx(Popover, { placement: "bottom-start", children: modalState => {
|
|
1050
|
-
return (jsxs(Fragment, { children: [jsx(PopoverTrigger, { children: jsx("div", { children: jsx(Tooltip, { disabled: modalState.isOpen || !isActive, label: jsx(MultipleFilterTooltipLabel, { filterBarConfig: filterBarConfig, filterKeys: filterKey }), children: jsx(IconButton, { icon: jsx(Icon, { name: "Filter", size: "small" }), size: "extraSmall", variant: isActive ? "filled" : "ghost-neutral" }) }) }) }), jsx(PopoverContent, { children: jsx(MenuList, { children: filters.map((value, index) => value && (jsx(FilterComponent, { filter: value, filterBarActions: filterBarConfig, filterState: filterBarConfig, visualStyle: "list-item" }, index))) }) })] }));
|
|
1042
|
+
return (jsxs(Fragment, { children: [jsx(PopoverTrigger, { children: jsx("div", { children: jsx(Tooltip, { disabled: modalState.isOpen || !isActive, label: jsx(MultipleFilterTooltipLabel, { filterBarConfig: filterBarConfig, filterKeys: filterKey, filters: filters }), placement: "bottom", children: jsx(IconButton, { icon: jsx(Icon, { name: "Filter", size: "small" }), size: "extraSmall", variant: isActive ? "filled" : "ghost-neutral" }) }) }) }), jsx(PopoverContent, { children: jsx(MenuList, { children: filters.map((value, index) => value && (jsx(FilterComponent, { filter: value, filterBarActions: filterBarConfig, filterState: filterBarConfig, visualStyle: "list-item" }, index))) }) })] }));
|
|
1051
1043
|
} }));
|
|
1052
1044
|
}
|
|
1053
1045
|
const filter = filterBarDefinition[ensureFilterKey(filterKey)];
|
|
1054
1046
|
if (!filter) {
|
|
1055
1047
|
return null;
|
|
1056
1048
|
}
|
|
1057
|
-
return (jsx("div", { onClick: event => event.stopPropagation(), children: jsx(Tooltip, { disabled: !filterBarConfig.appliedFilterKeys().includes(filterKey), label: jsx(SingleFilterTooltipLabel, { filterBarConfig: filterBarConfig, filterKey: filterKey }), children: jsx(FilterComponent, { asIcon: "Filter", filter: filter, filterBarActions: filterBarConfig, filterState: filterBarConfig, size: "extraSmall" }) }) }));
|
|
1049
|
+
return (jsx("div", { onClick: event => event.stopPropagation(), children: jsx(Tooltip, { disabled: !filterBarConfig.appliedFilterKeys().includes(filterKey), label: jsx(SingleFilterTooltipLabel, { filter: filter, filterBarConfig: filterBarConfig, filterKey: filterKey }), placement: "bottom", children: jsx(FilterComponent, { asIcon: "Filter", filter: filter, filterBarActions: filterBarConfig, filterState: filterBarConfig, size: "extraSmall" }) }) }));
|
|
1058
1050
|
};
|
|
1059
1051
|
|
|
1060
1052
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/filters-filter-bar",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.202",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"zod": "3.23.4",
|
|
17
17
|
"@trackunit/iris-app-api": "1.3.128",
|
|
18
18
|
"@trackunit/react-core-hooks": "1.3.131",
|
|
19
|
-
"@trackunit/react-filter-components": "1.3.
|
|
20
|
-
"@trackunit/react-date-and-time-components": "1.3.
|
|
19
|
+
"@trackunit/react-filter-components": "1.3.167",
|
|
20
|
+
"@trackunit/react-date-and-time-components": "1.3.169",
|
|
21
21
|
"@trackunit/shared-utils": "1.5.121",
|
|
22
|
-
"@trackunit/react-form-components": "1.3.
|
|
22
|
+
"@trackunit/react-form-components": "1.3.167",
|
|
23
23
|
"@trackunit/react-core-contexts-api": "1.4.127",
|
|
24
24
|
"@trackunit/geo-json-utils": "1.3.121",
|
|
25
25
|
"@trackunit/i18n-library-translation": "1.3.137",
|
|
26
26
|
"@trackunit/css-class-variance-utilities": "1.3.121",
|
|
27
|
-
"@trackunit/react-components": "1.4.
|
|
27
|
+
"@trackunit/react-components": "1.4.147",
|
|
28
28
|
"@trackunit/react-test-setup": "1.0.11"
|
|
29
29
|
},
|
|
30
30
|
"module": "./index.esm.js",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
|
-
import { FilterBarDefinition, FilterMapActions, FilterMapGetter, FilterState } from "../../types/FilterTypes";
|
|
2
|
+
import { FilterBarDefinition, FilterDefinition, FilterMapActions, FilterMapGetter, FilterState } from "../../types/FilterTypes";
|
|
3
3
|
interface MultipleFilterTooltipLabelProps<TFilterBarDefinition extends FilterBarDefinition> {
|
|
4
4
|
filterBarConfig: FilterState<TFilterBarDefinition> & FilterMapActions & FilterMapGetter;
|
|
5
5
|
filterKeys?: string[];
|
|
6
|
+
filters: FilterDefinition[];
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Component that displays a tooltip for filters.
|
|
@@ -15,5 +16,5 @@ interface MultipleFilterTooltipLabelProps<TFilterBarDefinition extends FilterBar
|
|
|
15
16
|
* @param {string[]} [props.filterKeys] An optional list of filter keys to filter the currently applied filters.
|
|
16
17
|
* @returns {ReactElement | string} Returns a element or string for the tooltip displaying applied filters.
|
|
17
18
|
*/
|
|
18
|
-
declare const MultipleFilterTooltipLabel: <TFilterBarDefinition extends FilterBarDefinition>({ filterBarConfig, filterKeys, }: MultipleFilterTooltipLabelProps<TFilterBarDefinition>) => ReactElement | string;
|
|
19
|
+
declare const MultipleFilterTooltipLabel: <TFilterBarDefinition extends FilterBarDefinition>({ filterBarConfig, filterKeys, filters, }: MultipleFilterTooltipLabelProps<TFilterBarDefinition>) => ReactElement | string;
|
|
19
20
|
export default MultipleFilterTooltipLabel;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
|
-
import { FilterBarDefinition, FilterMapActions, FilterMapGetter, FilterState } from "../../types/FilterTypes";
|
|
2
|
+
import { FilterBarDefinition, FilterDefinition, FilterMapActions, FilterMapGetter, FilterState } from "../../types/FilterTypes";
|
|
3
3
|
interface SingleFilterTooltipLabelProps<TFilterBarDefinition extends FilterBarDefinition> {
|
|
4
4
|
filterBarConfig: FilterState<TFilterBarDefinition> & FilterMapActions & FilterMapGetter;
|
|
5
|
+
filter?: FilterDefinition;
|
|
5
6
|
filterKey: string;
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
@@ -14,5 +15,5 @@ interface SingleFilterTooltipLabelProps<TFilterBarDefinition extends FilterBarDe
|
|
|
14
15
|
* @param {string} props.filterKey - The key identifying the filter.
|
|
15
16
|
* @returns {ReactElement} The rendered tooltip label and applied filter values.
|
|
16
17
|
*/
|
|
17
|
-
declare const SingleFilterTooltipLabel: <TFilterBarDefinition extends FilterBarDefinition>({ filterBarConfig, filterKey, }: SingleFilterTooltipLabelProps<TFilterBarDefinition>) => ReactElement;
|
|
18
|
+
declare const SingleFilterTooltipLabel: <TFilterBarDefinition extends FilterBarDefinition>({ filterBarConfig, filter, filterKey, }: SingleFilterTooltipLabelProps<TFilterBarDefinition>) => ReactElement;
|
|
18
19
|
export default SingleFilterTooltipLabel;
|