@trackunit/filters-filter-bar 1.3.244 → 1.3.245

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
@@ -617,7 +617,7 @@ const DefaultCheckboxFilter = ({ filterDefinition, filterBarActions, options, lo
617
617
  react.useEffect(() => {
618
618
  const index = results.findIndex(option => option.key === "UNDEFINED");
619
619
  if (index !== -1) {
620
- setUndefinedCount({ count: results[index]?.count ?? 0, index });
620
+ setUndefinedCount({ count: results[index]?.count, index });
621
621
  }
622
622
  }, [results]);
623
623
  react.useEffect(() => {
@@ -1235,7 +1235,7 @@ const useHierarchicalOptionState = ({ options, option, selectedValues, cascadeSe
1235
1235
  * Renders a single option and its children recursively.
1236
1236
  * Uses the `useHierarchicalOptionState` hook for state management and interaction logic.
1237
1237
  */
1238
- const RenderHierarchicalOption = ({ option, filterDefinition, filterBarActions, setValue, logEvent, selectedValues, cascadeSelection, optionsMap, }) => {
1238
+ const RenderHierarchicalOption = ({ option, filterDefinition, filterBarActions, setValue, logEvent, selectedValues, cascadeSelection, optionsMap, showCount = true, }) => {
1239
1239
  const level = option.level ?? 0;
1240
1240
  const { isChecked, isIndeterminate, handleSelect } = useHierarchicalOptionState({
1241
1241
  option,
@@ -1247,7 +1247,7 @@ const RenderHierarchicalOption = ({ option, filterDefinition, filterBarActions,
1247
1247
  filterDefinition,
1248
1248
  logEvent,
1249
1249
  });
1250
- return (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx("div", { className: cvaOptionItem({ indentationLevel: level > 6 ? 6 : level }), children: jsxRuntime.jsx(reactFilterComponents.CheckBoxFilterItem, { checked: isChecked, className: "rounded-none", dataTestId: `hierarchical-filter-check-box-${option.key}`, indeterminate: isIndeterminate, itemCount: option.count, label: option.label, name: `hierarchical-filter-check-box-${option.key}`, onChange: handleSelect }) }), option.children?.map(child => (jsxRuntime.jsx(RenderHierarchicalOption, { cascadeSelection: cascadeSelection, filterBarActions: filterBarActions, filterDefinition: filterDefinition, logEvent: logEvent, option: child, optionsMap: optionsMap, selectedValues: selectedValues, setValue: setValue }, child.key)))] }, option.key));
1250
+ return (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx("div", { className: cvaOptionItem({ indentationLevel: level > 6 ? 6 : level }), children: jsxRuntime.jsx(reactFilterComponents.CheckBoxFilterItem, { checked: isChecked, className: "rounded-none", dataTestId: `hierarchical-filter-check-box-${option.key}`, indeterminate: isIndeterminate, itemCount: showCount ? option.count : undefined, label: option.label, name: `hierarchical-filter-check-box-${option.key}`, onChange: handleSelect }) }), option.children?.map(child => (jsxRuntime.jsx(RenderHierarchicalOption, { cascadeSelection: cascadeSelection, filterBarActions: filterBarActions, filterDefinition: filterDefinition, logEvent: logEvent, option: child, optionsMap: optionsMap, selectedValues: selectedValues, setValue: setValue, showCount: showCount }, child.key)))] }, option.key));
1251
1251
  };
1252
1252
  const cvaOptionItem = cssClassVarianceUtilities.cvaMerge(["m-1"], {
1253
1253
  variants: {
@@ -1272,7 +1272,7 @@ const cvaOptionItem = cssClassVarianceUtilities.cvaMerge(["m-1"], {
1272
1272
  *
1273
1273
  * Supports optional cascading selection behavior via the `cascadeSelection` prop.
1274
1274
  */
1275
- const HierarchicalCheckboxFilter = ({ filterDefinition, filterBarActions, options, loading, setValue, value, cascadeSelection = false, customSearch, }) => {
1275
+ const HierarchicalCheckboxFilter = ({ filterDefinition, filterBarActions, options, loading, setValue, value, cascadeSelection = false, customSearch, showCount = true, }) => {
1276
1276
  const { logEvent } = reactCoreHooks.useAnalytics(FilterEvents);
1277
1277
  const selectedValues = value ?? [];
1278
1278
  // Local state for client-side search (used if customSearch is not provided)
@@ -1306,7 +1306,7 @@ const HierarchicalCheckboxFilter = ({ filterDefinition, filterBarActions, option
1306
1306
  }
1307
1307
  return filterHierarchicalOptions(options, localSearchText);
1308
1308
  }, [options, isServerSearch, localSearchText]);
1309
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FilterHeader, { ...filterDefinition, ...filterBarActions, filterHasChanges: filterBarActions.appliedFilterKeys().includes(filterDefinition.filterKey), loading: loading, ...searchHeaderProps }), jsxRuntime.jsx("div", { className: "max-h-60 overflow-y-auto", children: jsxRuntime.jsx(FilterResults, { loading: loading, results: filteredOptions, children: results => (jsxRuntime.jsx(jsxRuntime.Fragment, { children: results.map(option => (jsxRuntime.jsx(RenderHierarchicalOption, { cascadeSelection: cascadeSelection, filterBarActions: filterBarActions, filterDefinition: filterDefinition, logEvent: logEvent, option: option, optionsMap: optionsMap, selectedValues: selectedValues, setValue: setValue }, option.key))) })) }) })] }));
1309
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FilterHeader, { ...filterDefinition, ...filterBarActions, filterHasChanges: filterBarActions.appliedFilterKeys().includes(filterDefinition.filterKey), loading: loading, ...searchHeaderProps }), jsxRuntime.jsx("div", { className: "max-h-60 overflow-y-auto", children: jsxRuntime.jsx(FilterResults, { loading: loading, results: filteredOptions, children: results => (jsxRuntime.jsx(jsxRuntime.Fragment, { children: results.map(option => (jsxRuntime.jsx(RenderHierarchicalOption, { cascadeSelection: cascadeSelection, filterBarActions: filterBarActions, filterDefinition: filterDefinition, logEvent: logEvent, option: option, optionsMap: optionsMap, selectedValues: selectedValues, setValue: setValue, showCount: showCount }, option.key))) })) }) })] }));
1310
1310
  };
1311
1311
 
1312
1312
  /**
package/index.esm.js CHANGED
@@ -615,7 +615,7 @@ const DefaultCheckboxFilter = ({ filterDefinition, filterBarActions, options, lo
615
615
  useEffect(() => {
616
616
  const index = results.findIndex(option => option.key === "UNDEFINED");
617
617
  if (index !== -1) {
618
- setUndefinedCount({ count: results[index]?.count ?? 0, index });
618
+ setUndefinedCount({ count: results[index]?.count, index });
619
619
  }
620
620
  }, [results]);
621
621
  useEffect(() => {
@@ -1233,7 +1233,7 @@ const useHierarchicalOptionState = ({ options, option, selectedValues, cascadeSe
1233
1233
  * Renders a single option and its children recursively.
1234
1234
  * Uses the `useHierarchicalOptionState` hook for state management and interaction logic.
1235
1235
  */
1236
- const RenderHierarchicalOption = ({ option, filterDefinition, filterBarActions, setValue, logEvent, selectedValues, cascadeSelection, optionsMap, }) => {
1236
+ const RenderHierarchicalOption = ({ option, filterDefinition, filterBarActions, setValue, logEvent, selectedValues, cascadeSelection, optionsMap, showCount = true, }) => {
1237
1237
  const level = option.level ?? 0;
1238
1238
  const { isChecked, isIndeterminate, handleSelect } = useHierarchicalOptionState({
1239
1239
  option,
@@ -1245,7 +1245,7 @@ const RenderHierarchicalOption = ({ option, filterDefinition, filterBarActions,
1245
1245
  filterDefinition,
1246
1246
  logEvent,
1247
1247
  });
1248
- return (jsxs(Fragment$1, { children: [jsx("div", { className: cvaOptionItem({ indentationLevel: level > 6 ? 6 : level }), children: jsx(CheckBoxFilterItem, { checked: isChecked, className: "rounded-none", dataTestId: `hierarchical-filter-check-box-${option.key}`, indeterminate: isIndeterminate, itemCount: option.count, label: option.label, name: `hierarchical-filter-check-box-${option.key}`, onChange: handleSelect }) }), option.children?.map(child => (jsx(RenderHierarchicalOption, { cascadeSelection: cascadeSelection, filterBarActions: filterBarActions, filterDefinition: filterDefinition, logEvent: logEvent, option: child, optionsMap: optionsMap, selectedValues: selectedValues, setValue: setValue }, child.key)))] }, option.key));
1248
+ return (jsxs(Fragment$1, { children: [jsx("div", { className: cvaOptionItem({ indentationLevel: level > 6 ? 6 : level }), children: jsx(CheckBoxFilterItem, { checked: isChecked, className: "rounded-none", dataTestId: `hierarchical-filter-check-box-${option.key}`, indeterminate: isIndeterminate, itemCount: showCount ? option.count : undefined, label: option.label, name: `hierarchical-filter-check-box-${option.key}`, onChange: handleSelect }) }), option.children?.map(child => (jsx(RenderHierarchicalOption, { cascadeSelection: cascadeSelection, filterBarActions: filterBarActions, filterDefinition: filterDefinition, logEvent: logEvent, option: child, optionsMap: optionsMap, selectedValues: selectedValues, setValue: setValue, showCount: showCount }, child.key)))] }, option.key));
1249
1249
  };
1250
1250
  const cvaOptionItem = cvaMerge(["m-1"], {
1251
1251
  variants: {
@@ -1270,7 +1270,7 @@ const cvaOptionItem = cvaMerge(["m-1"], {
1270
1270
  *
1271
1271
  * Supports optional cascading selection behavior via the `cascadeSelection` prop.
1272
1272
  */
1273
- const HierarchicalCheckboxFilter = ({ filterDefinition, filterBarActions, options, loading, setValue, value, cascadeSelection = false, customSearch, }) => {
1273
+ const HierarchicalCheckboxFilter = ({ filterDefinition, filterBarActions, options, loading, setValue, value, cascadeSelection = false, customSearch, showCount = true, }) => {
1274
1274
  const { logEvent } = useAnalytics(FilterEvents);
1275
1275
  const selectedValues = value ?? [];
1276
1276
  // Local state for client-side search (used if customSearch is not provided)
@@ -1304,7 +1304,7 @@ const HierarchicalCheckboxFilter = ({ filterDefinition, filterBarActions, option
1304
1304
  }
1305
1305
  return filterHierarchicalOptions(options, localSearchText);
1306
1306
  }, [options, isServerSearch, localSearchText]);
1307
- return (jsxs(Fragment, { children: [jsx(FilterHeader, { ...filterDefinition, ...filterBarActions, filterHasChanges: filterBarActions.appliedFilterKeys().includes(filterDefinition.filterKey), loading: loading, ...searchHeaderProps }), jsx("div", { className: "max-h-60 overflow-y-auto", children: jsx(FilterResults, { loading: loading, results: filteredOptions, children: results => (jsx(Fragment, { children: results.map(option => (jsx(RenderHierarchicalOption, { cascadeSelection: cascadeSelection, filterBarActions: filterBarActions, filterDefinition: filterDefinition, logEvent: logEvent, option: option, optionsMap: optionsMap, selectedValues: selectedValues, setValue: setValue }, option.key))) })) }) })] }));
1307
+ return (jsxs(Fragment, { children: [jsx(FilterHeader, { ...filterDefinition, ...filterBarActions, filterHasChanges: filterBarActions.appliedFilterKeys().includes(filterDefinition.filterKey), loading: loading, ...searchHeaderProps }), jsx("div", { className: "max-h-60 overflow-y-auto", children: jsx(FilterResults, { loading: loading, results: filteredOptions, children: results => (jsx(Fragment, { children: results.map(option => (jsx(RenderHierarchicalOption, { cascadeSelection: cascadeSelection, filterBarActions: filterBarActions, filterDefinition: filterDefinition, logEvent: logEvent, option: option, optionsMap: optionsMap, selectedValues: selectedValues, setValue: setValue, showCount: showCount }, option.key))) })) }) })] }));
1308
1308
  };
1309
1309
 
1310
1310
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/filters-filter-bar",
3
- "version": "1.3.244",
3
+ "version": "1.3.245",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -16,8 +16,8 @@
16
16
  "zod": "3.23.4",
17
17
  "@trackunit/iris-app-api": "1.3.152",
18
18
  "@trackunit/react-core-hooks": "1.3.158",
19
- "@trackunit/react-filter-components": "1.3.198",
20
- "@trackunit/react-date-and-time-components": "1.3.202",
19
+ "@trackunit/react-filter-components": "1.3.199",
20
+ "@trackunit/react-date-and-time-components": "1.3.203",
21
21
  "@trackunit/shared-utils": "1.5.144",
22
22
  "@trackunit/react-form-components": "1.3.200",
23
23
  "@trackunit/react-core-contexts-api": "1.4.152",
@@ -48,6 +48,7 @@ export interface HierarchicalFilterProps extends Omit<DefaultFilterProps<Array<V
48
48
  */
49
49
  onChange: (value: string) => void;
50
50
  };
51
+ showCount?: boolean;
51
52
  }
52
53
  /**
53
54
  * `HierarchicalCheckboxFilter` is a React component for handling hierarchical checkbox filters.
@@ -55,4 +56,4 @@ export interface HierarchicalFilterProps extends Omit<DefaultFilterProps<Array<V
55
56
  *
56
57
  * Supports optional cascading selection behavior via the `cascadeSelection` prop.
57
58
  */
58
- export declare const HierarchicalCheckboxFilter: ({ filterDefinition, filterBarActions, options, loading, setValue, value, cascadeSelection, customSearch, }: HierarchicalFilterProps) => import("react/jsx-runtime").JSX.Element;
59
+ export declare const HierarchicalCheckboxFilter: ({ filterDefinition, filterBarActions, options, loading, setValue, value, cascadeSelection, customSearch, showCount, }: HierarchicalFilterProps) => import("react/jsx-runtime").JSX.Element;
@@ -11,10 +11,11 @@ interface RenderHierarchicalOptionProps {
11
11
  selectedValues: Array<ValueName>;
12
12
  cascadeSelection: boolean;
13
13
  optionsMap: Map<string, HierarchicalFilterOption>;
14
+ showCount?: boolean;
14
15
  }
15
16
  /**
16
17
  * Renders a single option and its children recursively.
17
18
  * Uses the `useHierarchicalOptionState` hook for state management and interaction logic.
18
19
  */
19
- export declare const RenderHierarchicalOption: ({ option, filterDefinition, filterBarActions, setValue, logEvent, selectedValues, cascadeSelection, optionsMap, }: RenderHierarchicalOptionProps) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const RenderHierarchicalOption: ({ option, filterDefinition, filterBarActions, setValue, logEvent, selectedValues, cascadeSelection, optionsMap, showCount, }: RenderHierarchicalOptionProps) => import("react/jsx-runtime").JSX.Element;
20
21
  export {};
@@ -146,6 +146,7 @@ export interface FilterViewProps<TReturnType> {
146
146
  filterState: FilterState<{}>;
147
147
  filterBarActions: FilterMapActions & FilterMapGetter;
148
148
  hideHeader?: boolean;
149
+ hasCount?: boolean;
149
150
  }
150
151
  export type FiltersStoreInstance<T extends FilterBarDefinition> = Partial<FilterBarConfig<T>>;
151
152
  /**