@luscii-healthtech/web-ui 38.2.3 → 38.3.1
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/components/FilterBar/FilterBar.d.ts +8 -1
- package/dist/components/FilterBar/FilterBarProps.type.d.ts +5 -1
- package/dist/components/FilterBar/FilterMenu.d.ts +11 -0
- package/dist/components/FilterBar/FiltersMenus.d.ts +3 -3
- package/dist/index.development.js +96 -117
- package/dist/index.development.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/web-ui-tailwind.css +4 -4
- package/dist/web-ui.esm.js +1 -1
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -81,6 +81,13 @@ type FilterBarProps<SortableEntity extends object> = {
|
|
|
81
81
|
*```
|
|
82
82
|
*/
|
|
83
83
|
categorizedFilters: CategorizedFilters;
|
|
84
|
+
/**
|
|
85
|
+
* Whether to hide the active filters section when no filters are applied.
|
|
86
|
+
* Works by checking if any of the filters have an `isChecked` value set to `true`.
|
|
87
|
+
*
|
|
88
|
+
* This defaults to `true`.
|
|
89
|
+
*/
|
|
90
|
+
hideActiveFiltersWhenEmpty?: boolean;
|
|
84
91
|
/**
|
|
85
92
|
* For more details, see {@link TransformedSortingOptions}.
|
|
86
93
|
*/
|
|
@@ -94,5 +101,5 @@ type FilterBarProps<SortableEntity extends object> = {
|
|
|
94
101
|
*/
|
|
95
102
|
localization: FilterBarLocalization;
|
|
96
103
|
} & HasSingleSelection;
|
|
97
|
-
export declare const FilterBar: <SortableEntity extends object>({ localization, categorizedFilters, sortingOptions, presetFilterOptions, ...props }: FilterBarProps<SortableEntity>) => ReactElement | null;
|
|
104
|
+
export declare const FilterBar: <SortableEntity extends object>({ localization, categorizedFilters, sortingOptions, presetFilterOptions, hideActiveFiltersWhenEmpty, ...props }: FilterBarProps<SortableEntity>) => ReactElement | null;
|
|
98
105
|
export {};
|
|
@@ -101,7 +101,7 @@ export type TransformedFilterOption = {
|
|
|
101
101
|
isChecked: boolean;
|
|
102
102
|
};
|
|
103
103
|
export type TransformedFilterOptions = TransformedFilterOption[];
|
|
104
|
-
type CategorizedFilter = {
|
|
104
|
+
export type CategorizedFilter = {
|
|
105
105
|
key: string;
|
|
106
106
|
label: string;
|
|
107
107
|
options: TransformedFilterOptions;
|
|
@@ -128,4 +128,8 @@ export type TransformedPresetFilterOption<SortableEntity extends object> = {
|
|
|
128
128
|
};
|
|
129
129
|
export type TransformedPresetFilterOptions<SortableEntity extends object> = TransformedPresetFilterOption<SortableEntity>[];
|
|
130
130
|
export type OnFilterBarPresetFilterChange<SortableEntity extends object> = (changedPresetFilterOption: TransformedPresetFilterOption<SortableEntity>) => void;
|
|
131
|
+
type OnChangeOptionParam = TransformedFilterOption | TransformedSortingOption<object> | TransformedPresetFilterOption<object>;
|
|
132
|
+
export type OnFilterMenuChange = (params: {
|
|
133
|
+
changedFilterOption: OnChangeOptionParam;
|
|
134
|
+
}) => void;
|
|
131
135
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type CategorizedFilter, type OnFilterMenuChange } from "./FilterBarProps.type";
|
|
3
|
+
type Props = {
|
|
4
|
+
alignPopover?: "left" | "right";
|
|
5
|
+
categorizedFilter: CategorizedFilter;
|
|
6
|
+
onFilterOptionChange: OnFilterMenuChange;
|
|
7
|
+
showCheckedAmount?: boolean;
|
|
8
|
+
singleSelection?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const FilterMenu: (props: Props) => React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { type CategorizedFilters, type HasSingleSelection, type
|
|
2
|
+
import { type CategorizedFilters, type HasSingleSelection, type OnFilterMenuChange } from "./FilterBarProps.type";
|
|
3
3
|
type FiltersMenusProps = {
|
|
4
4
|
filters: CategorizedFilters;
|
|
5
|
-
onFilterOptionChange:
|
|
5
|
+
onFilterOptionChange: OnFilterMenuChange;
|
|
6
6
|
} & HasSingleSelection;
|
|
7
7
|
/**
|
|
8
|
-
* Each of the menu lists on the right side of the
|
|
8
|
+
* Each of the menu lists on the right side of the `FilterBar` component.
|
|
9
9
|
*/
|
|
10
10
|
export declare const FiltersMenus: React.FC<FiltersMenusProps>;
|
|
11
11
|
export {};
|
|
@@ -6710,11 +6710,11 @@ const ActiveFilters = (props) => {
|
|
|
6710
6710
|
"div",
|
|
6711
6711
|
{ className: "ui-mt-2 sm:ui-ml-4 sm:ui-mt-0" },
|
|
6712
6712
|
React__namespace.default.createElement(Stack, { axis: "x", gap: "m", align: "center", wrap: true }, activeFilters.map((activeFilter, idx) => React__namespace.default.createElement(
|
|
6713
|
-
|
|
6714
|
-
|
|
6713
|
+
React.Fragment,
|
|
6714
|
+
{ key: `${activeFilter.id}-${activeFilter.label}` },
|
|
6715
6715
|
React__namespace.default.createElement(
|
|
6716
6716
|
"span",
|
|
6717
|
-
{
|
|
6717
|
+
{ className: "ui-mx-1 ui-inline-flex ui-items-center ui-rounded-full ui-border ui-border-neutral-interactive ui-bg-white ui-py-xxxxs ui-pl-m ui-pr-xxs hover:ui-border-neutral-interactive--hover hover:ui-bg-primary-background" },
|
|
6718
6718
|
React__namespace.default.createElement(Text, { variant: "base" }, activeFilter.label),
|
|
6719
6719
|
React__namespace.default.createElement(
|
|
6720
6720
|
"button",
|
|
@@ -6736,153 +6736,126 @@ const ActiveFilters = (props) => {
|
|
|
6736
6736
|
);
|
|
6737
6737
|
};
|
|
6738
6738
|
|
|
6739
|
-
const
|
|
6740
|
-
const {
|
|
6741
|
-
const
|
|
6742
|
-
const
|
|
6739
|
+
const FilterMenu = (props) => {
|
|
6740
|
+
const { showCheckedAmount = false, alignPopover = "left", categorizedFilter, singleSelection = false } = props;
|
|
6741
|
+
const multiSelection = !singleSelection;
|
|
6742
|
+
const amountOfCheckedItems = categorizedFilter.options.filter((option) => option.isChecked).length;
|
|
6743
6743
|
return React__namespace.default.createElement(
|
|
6744
|
-
react.
|
|
6745
|
-
{
|
|
6744
|
+
react.Popover,
|
|
6745
|
+
{ key: categorizedFilter.key, className: "ui-relative ui-inline-block ui-px-4 ui-text-left" },
|
|
6746
6746
|
React__namespace.default.createElement(
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
React__namespace.default.createElement(
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
menuLabel,
|
|
6753
|
-
React__namespace.default.createElement(solid.ChevronDownIcon, { className: "-ui-mr-1 ui-ml-1 ui-h-5 ui-w-5 ui-flex-shrink-0 ui-text-slate-400 group-hover:ui-text-slate-500", "aria-hidden": "true" })
|
|
6754
|
-
)
|
|
6747
|
+
react.PopoverButton,
|
|
6748
|
+
{ className: "ui-group ui-inline-flex ui-justify-center ui-text-sm ui-font-medium ui-text-slate-700 hover:ui-text-slate-900" },
|
|
6749
|
+
React__namespace.default.createElement("span", null, categorizedFilter.label),
|
|
6750
|
+
amountOfCheckedItems > 0 && showCheckedAmount ? React__namespace.default.createElement("span", { className: "ui-ml-1.5 ui-rounded ui-bg-slate-200 ui-px-1.5 ui-py-0.5 ui-text-xs ui-font-semibold ui-tabular-nums ui-text-slate-700" }, amountOfCheckedItems) : null,
|
|
6751
|
+
React__namespace.default.createElement(solid.ChevronDownIcon, { className: "-ui-mr-1 ui-ml-1 ui-h-5 ui-w-5 ui-flex-shrink-0 ui-text-slate-400 group-hover:ui-text-slate-500", "aria-hidden": "true" })
|
|
6755
6752
|
),
|
|
6756
6753
|
React__namespace.default.createElement(
|
|
6757
6754
|
react.Transition,
|
|
6758
6755
|
{ enter: "ui-transition ui-ease-out ui-duration-100", enterFrom: "ui-transform ui-opacity-0 ui-scale-95", enterTo: "ui-transform ui-opacity-100 ui-scale-100", leave: "ui-transition ui-ease-in ui-duration-75", leaveFrom: "ui-transform ui-opacity-100 ui-scale-100", leaveTo: "ui-transform ui-opacity-0 ui-scale-95" },
|
|
6759
|
-
React__namespace.default.createElement(
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6756
|
+
React__namespace.default.createElement(
|
|
6757
|
+
react.PopoverPanel,
|
|
6758
|
+
{ className: classNames__default.default("ui-min-w-58", "ui-absolute ui-z-10 ui-mt-2", "ui-rounded-2xl ui-bg-white ui-shadow-2xl ui-ring-1 ui-ring-black ui-ring-opacity-5", "focus:ui-outline-none", "ui-border ui-border-neutral-border-high-contrast", {
|
|
6759
|
+
// Align popover to the left side of the button label
|
|
6760
|
+
"ui-left-4 ui-origin-top-left": alignPopover === "left",
|
|
6761
|
+
// Align popover to the right side of the chevron icon
|
|
6762
|
+
"ui-right-3 ui-origin-top-right": alignPopover === "right"
|
|
6763
|
+
}) },
|
|
6764
|
+
React__namespace.default.createElement("form", { className: "ui-max-h-120 ui-overflow-y-auto" }, categorizedFilter.options.map((option) => React__namespace.default.createElement(
|
|
6765
|
+
"label",
|
|
6766
|
+
{ key: `${option.id}`, className: classNames__default.default("first-of-type:ui-rounded-t-2xl", "last-of-type:ui-rounded-b-2xl", "ui-flex ui-items-center ui-p-3", "ui-cursor-pointer", "ui-transition-colors ui-duration-300 ui-ease-in-out hover:ui-bg-primary-background"), htmlFor: `filter-${option.id}`, role: multiSelection ? "menuitemcheckbox" : "menuitem" },
|
|
6767
|
+
React__namespace.default.createElement("input", { id: `filter-${option.id}`, name: `${option.value}`, defaultValue: option.value, type: "checkbox", defaultChecked: option.isChecked, onChange: () => {
|
|
6768
|
+
props.onFilterOptionChange({
|
|
6769
|
+
changedFilterOption: Object.assign(Object.assign({}, option), { isChecked: !option.isChecked })
|
|
6770
|
+
});
|
|
6771
|
+
}, className: classNames__default.default("ui-form-checkbox ui-h-4 ui-w-4 ui-rounded ui-border-slate-300 ui-text-primary focus:ui-ring-primary", {
|
|
6772
|
+
"ui-hidden": singleSelection
|
|
6773
|
+
}) }),
|
|
6773
6774
|
React__namespace.default.createElement(
|
|
6774
6775
|
"span",
|
|
6775
|
-
{ className: classNames__default.default(
|
|
6776
|
-
|
|
6776
|
+
{ className: classNames__default.default({
|
|
6777
|
+
"ui-pr-l": multiSelection,
|
|
6778
|
+
"ui-ml-s": multiSelection
|
|
6779
|
+
}) },
|
|
6780
|
+
React__namespace.default.createElement(Text, { className: "ui-whitespace-nowrap ui-capitalize", variant: option.isChecked ? "strong" : "base" }, option.label)
|
|
6777
6781
|
),
|
|
6778
6782
|
React__namespace.default.createElement(
|
|
6779
6783
|
"span",
|
|
6780
|
-
{ className: classNames__default.default("ui-ml-auto", {
|
|
6784
|
+
{ className: classNames__default.default("ui-ml-auto ui-pr-s", {
|
|
6785
|
+
"ui-hidden": multiSelection,
|
|
6781
6786
|
"ui-text-primary": option.isChecked,
|
|
6782
6787
|
"ui-text-transparent": !option.isChecked
|
|
6783
6788
|
}) },
|
|
6784
6789
|
React__namespace.default.createElement(solid.CheckIcon, { className: "ui-ml-s ui-h-5 ui-w-5 ui-flex-shrink-0" })
|
|
6785
6790
|
)
|
|
6786
|
-
)
|
|
6787
|
-
|
|
6791
|
+
)))
|
|
6792
|
+
)
|
|
6788
6793
|
)
|
|
6789
6794
|
);
|
|
6790
6795
|
};
|
|
6791
6796
|
|
|
6797
|
+
const isSortingOption = (option) => {
|
|
6798
|
+
if (!option || !lodash.isObjectLike(option)) {
|
|
6799
|
+
return false;
|
|
6800
|
+
}
|
|
6801
|
+
return typeof option === "object" && "sortingCompare" in option && lodash.isFunction(option === null || option === void 0 ? void 0 : option.sortingCompare);
|
|
6802
|
+
};
|
|
6803
|
+
const SortMenu = (props) => {
|
|
6804
|
+
const { localization, sortingOptions, onSortOptionChange } = props;
|
|
6805
|
+
const selectedSorting = sortingOptions.find((sortingOption) => sortingOption.isChecked);
|
|
6806
|
+
const menuLabel = selectedSorting ? `${localization.sortedByLabel} ${selectedSorting.label}` : localization.sortLabel;
|
|
6807
|
+
const filter = {
|
|
6808
|
+
key: "sort",
|
|
6809
|
+
label: menuLabel,
|
|
6810
|
+
options: sortingOptions
|
|
6811
|
+
};
|
|
6812
|
+
const onFilterOptionChange = ({ changedFilterOption }) => {
|
|
6813
|
+
if (isSortingOption(changedFilterOption)) {
|
|
6814
|
+
onSortOptionChange(changedFilterOption);
|
|
6815
|
+
}
|
|
6816
|
+
};
|
|
6817
|
+
return React__namespace.default.createElement(FilterMenu, { categorizedFilter: filter, onFilterOptionChange, singleSelection: true });
|
|
6818
|
+
};
|
|
6819
|
+
|
|
6792
6820
|
const FiltersMenus = (props) => {
|
|
6793
6821
|
const { filters, singleSelection } = props;
|
|
6794
|
-
const multiSelection = !singleSelection;
|
|
6795
6822
|
return React__namespace.default.createElement(
|
|
6796
6823
|
"div",
|
|
6797
6824
|
{ className: "ui-hidden sm:ui-block" },
|
|
6798
6825
|
React__namespace.default.createElement(
|
|
6799
6826
|
"div",
|
|
6800
6827
|
{ className: "ui-flow-root" },
|
|
6801
|
-
React__namespace.default.createElement(react.
|
|
6802
|
-
const amountOfCheckedItems = categorizedFilter.options.filter((option) => option.isChecked).length;
|
|
6803
|
-
return React__namespace.default.createElement(
|
|
6804
|
-
react.Popover,
|
|
6805
|
-
{ key: categorizedFilter.key, className: "ui-relative ui-inline-block ui-px-4 ui-text-left" },
|
|
6806
|
-
React__namespace.default.createElement(
|
|
6807
|
-
react.Popover.Button,
|
|
6808
|
-
{ className: "ui-group ui-inline-flex ui-justify-center ui-text-sm ui-font-medium ui-text-slate-700 hover:ui-text-slate-900" },
|
|
6809
|
-
React__namespace.default.createElement("span", null, categorizedFilter.label),
|
|
6810
|
-
amountOfCheckedItems > 0 ? React__namespace.default.createElement("span", { className: "ui-ml-1.5 ui-rounded ui-bg-slate-200 ui-px-1.5 ui-py-0.5 ui-text-xs ui-font-semibold ui-tabular-nums ui-text-slate-700" }, amountOfCheckedItems) : null,
|
|
6811
|
-
React__namespace.default.createElement(solid.ChevronDownIcon, { className: "-ui-mr-1 ui-ml-1 ui-h-5 ui-w-5 ui-flex-shrink-0 ui-text-slate-400 group-hover:ui-text-slate-500", "aria-hidden": "true" })
|
|
6812
|
-
),
|
|
6813
|
-
React__namespace.default.createElement(
|
|
6814
|
-
react.Transition,
|
|
6815
|
-
{ enter: "ui-transition ui-ease-out ui-duration-100", enterFrom: "ui-transform ui-opacity-0 ui-scale-95", enterTo: "ui-transform ui-opacity-100 ui-scale-100", leave: "ui-transition ui-ease-in ui-duration-75", leaveFrom: "ui-transform ui-opacity-100 ui-scale-100", leaveTo: "ui-transform ui-opacity-0 ui-scale-95" },
|
|
6816
|
-
React__namespace.default.createElement(
|
|
6817
|
-
react.Popover.Panel,
|
|
6818
|
-
{ className: classNames__default.default("ui-min-w-58", "ui-absolute ui-right-0 ui-z-10 ui-mt-2 ui-origin-top-right", "ui-rounded-2xl ui-bg-white ui-shadow-2xl ui-ring-1 ui-ring-black ui-ring-opacity-5", "focus:ui-outline-none", "ui-border ui-border-neutral-border-high-contrast") },
|
|
6819
|
-
React__namespace.default.createElement("form", { className: "ui-max-h-120 ui-overflow-y-auto" }, categorizedFilter.options.map((option) => React__namespace.default.createElement(
|
|
6820
|
-
"label",
|
|
6821
|
-
{ key: `${option.id}`, className: classNames__default.default("first-of-type:ui-rounded-t-2xl", "last-of-type:ui-rounded-b-2xl", "ui-flex ui-items-center ui-p-3", "ui-transition-colors ui-duration-300 ui-ease-in-out hover:ui-bg-blue-50"), htmlFor: `filter-${option.id}` },
|
|
6822
|
-
React__namespace.default.createElement("input", { id: `filter-${option.id}`, name: `${option.value}`, defaultValue: option.value, type: "checkbox", defaultChecked: option.isChecked, onChange: () => {
|
|
6823
|
-
props.onFilterOptionChange({
|
|
6824
|
-
changedFilterOption: Object.assign(Object.assign({}, option), { isChecked: !option.isChecked })
|
|
6825
|
-
});
|
|
6826
|
-
}, className: classNames__default.default("ui-form-checkbox ui-h-4 ui-w-4 ui-rounded ui-border-slate-300 ui-text-primary focus:ui-ring-primary", {
|
|
6827
|
-
"ui-hidden": singleSelection
|
|
6828
|
-
}) }),
|
|
6829
|
-
React__namespace.default.createElement(
|
|
6830
|
-
"span",
|
|
6831
|
-
{ className: classNames__default.default({
|
|
6832
|
-
"ui-pr-l": multiSelection,
|
|
6833
|
-
"ui-ml-s": multiSelection
|
|
6834
|
-
}) },
|
|
6835
|
-
React__namespace.default.createElement(Text, { className: "ui-whitespace-nowrap ui-capitalize", variant: option.isChecked ? "strong" : "base" }, option.label)
|
|
6836
|
-
),
|
|
6837
|
-
React__namespace.default.createElement(
|
|
6838
|
-
"span",
|
|
6839
|
-
{ className: classNames__default.default("ui-ml-auto ui-pr-s", {
|
|
6840
|
-
"ui-hidden": multiSelection,
|
|
6841
|
-
"ui-text-primary": option.isChecked,
|
|
6842
|
-
"ui-text-transparent": !option.isChecked
|
|
6843
|
-
}) },
|
|
6844
|
-
React__namespace.default.createElement(solid.CheckIcon, { className: "ui-ml-s ui-h-5 ui-w-5 ui-flex-shrink-0" })
|
|
6845
|
-
)
|
|
6846
|
-
)))
|
|
6847
|
-
)
|
|
6848
|
-
)
|
|
6849
|
-
);
|
|
6850
|
-
}))
|
|
6828
|
+
React__namespace.default.createElement(react.PopoverGroup, { className: "-ui-mx-4 ui-flex ui-items-center ui-divide-x ui-divide-slate-200" }, filters.map((categorizedFilter) => React__namespace.default.createElement(FilterMenu, { alignPopover: "right", showCheckedAmount: true, key: `filter-menu-${categorizedFilter.key}`, categorizedFilter, onFilterOptionChange: props.onFilterOptionChange, singleSelection })))
|
|
6851
6829
|
)
|
|
6852
6830
|
);
|
|
6853
6831
|
};
|
|
6854
6832
|
|
|
6833
|
+
const isPresetFilterOption = (option) => {
|
|
6834
|
+
if (!option || !lodash.isObjectLike(option)) {
|
|
6835
|
+
return false;
|
|
6836
|
+
}
|
|
6837
|
+
return typeof option === "object" && "filterFn" in option && lodash.isFunction(option.filterFn);
|
|
6838
|
+
};
|
|
6855
6839
|
const PresetFiltersMenu = (props) => {
|
|
6856
6840
|
const { localization, presetFilterOptions, onPresetFilterOptionChange } = props;
|
|
6857
6841
|
const selectedPresetFilter = presetFilterOptions.find((presetFilterOption) => presetFilterOption.isChecked);
|
|
6858
|
-
const
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
),
|
|
6872
|
-
React__namespace.default.createElement(
|
|
6873
|
-
react.Transition,
|
|
6874
|
-
{ enter: "ui-transition ui-ease-out ui-duration-100", enterFrom: "ui-transform ui-opacity-0 ui-scale-95", enterTo: "ui-transform ui-opacity-100 ui-scale-100", leave: "ui-transition ui-ease-in ui-duration-75", leaveFrom: "ui-transform ui-opacity-100 ui-scale-100", leaveTo: "ui-transform ui-opacity-0 ui-scale-95" },
|
|
6875
|
-
React__namespace.default.createElement(
|
|
6876
|
-
react.Menu.Items,
|
|
6877
|
-
{ className: "ui-absolute ui-left-0 ui-z-10 ui-mt-2 ui-w-40 ui-origin-top-left ui-rounded-md ui-bg-white ui-shadow-2xl ui-ring-1 ui-ring-black ui-ring-opacity-5 focus:ui-outline-none" },
|
|
6878
|
-
React__namespace.default.createElement("div", { className: "ui-py-1" }, presetFilterOptions.map((option) => React__namespace.default.createElement(react.Menu.Item, { key: option.id }, ({ active }) => React__namespace.default.createElement("span", { onClick: () => onPresetFilterOptionChange(Object.assign(Object.assign({}, option), { isChecked: !option.isChecked })), role: "button", className: classNames__default.default(option.isChecked ? "ui-font-medium ui-text-slate-900" : "ui-text-slate-500", "ui-block ui-px-4 ui-py-2 ui-text-sm", "ui-cursor-pointer", { "ui-bg-slate-100": active }) }, option.label))))
|
|
6879
|
-
)
|
|
6880
|
-
)
|
|
6881
|
-
);
|
|
6842
|
+
const { presetFiltersLabel = "" } = localization;
|
|
6843
|
+
const menuLabel = presetFilterOptions ? [presetFiltersLabel, selectedPresetFilter === null || selectedPresetFilter === void 0 ? void 0 : selectedPresetFilter.label].filter(Boolean).join(": ") : presetFiltersLabel;
|
|
6844
|
+
const filter = {
|
|
6845
|
+
key: "presetFilters",
|
|
6846
|
+
label: menuLabel,
|
|
6847
|
+
options: presetFilterOptions
|
|
6848
|
+
};
|
|
6849
|
+
const onFilterOptionChange = ({ changedFilterOption }) => {
|
|
6850
|
+
if (isPresetFilterOption(changedFilterOption)) {
|
|
6851
|
+
onPresetFilterOptionChange(changedFilterOption);
|
|
6852
|
+
}
|
|
6853
|
+
};
|
|
6854
|
+
return React__namespace.default.createElement(FilterMenu, { categorizedFilter: filter, onFilterOptionChange, singleSelection: true });
|
|
6882
6855
|
};
|
|
6883
6856
|
|
|
6884
6857
|
const FilterBar = (_a) => {
|
|
6885
|
-
var { localization, categorizedFilters, sortingOptions, presetFilterOptions } = _a, props = __rest(_a, ["localization", "categorizedFilters", "sortingOptions", "presetFilterOptions"]);
|
|
6858
|
+
var { localization, categorizedFilters, sortingOptions, presetFilterOptions, hideActiveFiltersWhenEmpty = true } = _a, props = __rest(_a, ["localization", "categorizedFilters", "sortingOptions", "presetFilterOptions", "hideActiveFiltersWhenEmpty"]);
|
|
6886
6859
|
const onSortOptionChange = (changedSortingOption) => {
|
|
6887
6860
|
var _a2;
|
|
6888
6861
|
const updatedSortingOptions = sortingOptions.map((previousSortingOption) => {
|
|
@@ -6916,6 +6889,8 @@ const FilterBar = (_a) => {
|
|
|
6916
6889
|
});
|
|
6917
6890
|
props.onFilterChange(updatedFilters);
|
|
6918
6891
|
};
|
|
6892
|
+
const hasFiltersApplied = categorizedFilters.some((categorizedFilter) => categorizedFilter.options.some((option) => option.isChecked));
|
|
6893
|
+
const shouldShowActiveFilters = hasFiltersApplied ? true : !hideActiveFiltersWhenEmpty;
|
|
6919
6894
|
return React__namespace.default.createElement(
|
|
6920
6895
|
"div",
|
|
6921
6896
|
null,
|
|
@@ -6923,11 +6898,11 @@ const FilterBar = (_a) => {
|
|
|
6923
6898
|
"section",
|
|
6924
6899
|
{ "aria-labelledby": "filter-heading" },
|
|
6925
6900
|
React__namespace.default.createElement(
|
|
6926
|
-
|
|
6927
|
-
{
|
|
6901
|
+
Box,
|
|
6902
|
+
{ borderRadius: "l", py: "m" },
|
|
6928
6903
|
React__namespace.default.createElement(
|
|
6929
6904
|
Stack,
|
|
6930
|
-
{ axis: "x", align: "normal", justify: "between" },
|
|
6905
|
+
{ axis: "x", align: "normal", justify: "between", className: "-ui-ml-m" },
|
|
6931
6906
|
React__namespace.default.createElement(
|
|
6932
6907
|
Stack,
|
|
6933
6908
|
{ axis: "x", gap: "m", align: "normal" },
|
|
@@ -6942,8 +6917,12 @@ const FilterBar = (_a) => {
|
|
|
6942
6917
|
React__namespace.default.createElement(FiltersMenus, { singleSelection: props.singleSelection, filters: categorizedFilters, onFilterOptionChange })
|
|
6943
6918
|
)
|
|
6944
6919
|
),
|
|
6945
|
-
React__namespace.default.createElement(
|
|
6946
|
-
|
|
6920
|
+
shouldShowActiveFilters && React__namespace.default.createElement(
|
|
6921
|
+
React__namespace.default.Fragment,
|
|
6922
|
+
null,
|
|
6923
|
+
React__namespace.default.createElement(Divider, { version: "v2", color: "border" }),
|
|
6924
|
+
React__namespace.default.createElement(ActiveFilters, { localization, filters: categorizedFilters, onRemoveActiveFilter: onFilterOptionChange })
|
|
6925
|
+
)
|
|
6947
6926
|
)
|
|
6948
6927
|
);
|
|
6949
6928
|
};
|