@trackunit/filters-filter-bar 1.12.9 → 1.12.11

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
@@ -476,8 +476,8 @@ const FilterEvents = {
476
476
  /**
477
477
  * Toggles a filter value in an array.
478
478
  *
479
- * @template T - The type of the filter values.
480
- * @returns {(prev?: T[]) => T[]} A function that takes an optional previous array of filter values
479
+ * @template TValue - The type of the filter values.
480
+ * @returns {(prev?: TValue[]) => TValue[]} A function that takes an optional previous array of filter values
481
481
  */
482
482
  const toggleFilterValue = (value) => {
483
483
  return (prev) => {
package/index.esm.js CHANGED
@@ -474,8 +474,8 @@ const FilterEvents = {
474
474
  /**
475
475
  * Toggles a filter value in an array.
476
476
  *
477
- * @template T - The type of the filter values.
478
- * @returns {(prev?: T[]) => T[]} A function that takes an optional previous array of filter values
477
+ * @template TValue - The type of the filter values.
478
+ * @returns {(prev?: TValue[]) => TValue[]} A function that takes an optional previous array of filter values
479
479
  */
480
480
  const toggleFilterValue = (value) => {
481
481
  return (prev) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/filters-filter-bar",
3
- "version": "1.12.9",
3
+ "version": "1.12.11",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -12,17 +12,17 @@
12
12
  "tailwind-merge": "^2.0.0",
13
13
  "string-ts": "^2.0.0",
14
14
  "zod": "^3.23.8",
15
- "@trackunit/iris-app-api": "1.14.6",
16
- "@trackunit/react-core-hooks": "1.11.6",
17
- "@trackunit/react-filter-components": "1.11.9",
18
- "@trackunit/react-date-and-time-components": "1.14.9",
19
- "@trackunit/shared-utils": "1.13.6",
20
- "@trackunit/react-form-components": "1.12.7",
21
- "@trackunit/iris-app-runtime-core-api": "1.11.6",
22
- "@trackunit/geo-json-utils": "1.11.6",
23
- "@trackunit/i18n-library-translation": "1.11.6",
24
- "@trackunit/css-class-variance-utilities": "1.11.6",
25
- "@trackunit/react-components": "1.15.7",
15
+ "@trackunit/iris-app-api": "1.14.8",
16
+ "@trackunit/react-core-hooks": "1.11.8",
17
+ "@trackunit/react-filter-components": "1.11.11",
18
+ "@trackunit/react-date-and-time-components": "1.14.11",
19
+ "@trackunit/shared-utils": "1.13.8",
20
+ "@trackunit/react-form-components": "1.12.9",
21
+ "@trackunit/iris-app-runtime-core-api": "1.11.8",
22
+ "@trackunit/geo-json-utils": "1.11.8",
23
+ "@trackunit/i18n-library-translation": "1.11.8",
24
+ "@trackunit/css-class-variance-utilities": "1.11.8",
25
+ "@trackunit/react-components": "1.15.9",
26
26
  "@tanstack/react-router": "1.114.29"
27
27
  },
28
28
  "module": "./index.esm.js",
@@ -7,5 +7,5 @@ type FilterDefinitionValue = Array<string> | Array<ValueName>;
7
7
  *
8
8
  * @param {DefaultFilterProps<string[]>} props - The properties required for the `DefaultCheckboxFilter` component.
9
9
  */
10
- export declare const DefaultCheckboxFilter: <T extends FilterDefinitionValue>({ filterDefinition, filterBarActions, options, loading, setValue, filterName, customSearch, showRequestMoreUseSearch, showUndefinedOptionWithCountAtBottom, }: DefaultFilterProps<T>) => ReactElement;
10
+ export declare const DefaultCheckboxFilter: <TFilterValue extends FilterDefinitionValue>({ filterDefinition, filterBarActions, options, loading, setValue, filterName, customSearch, showRequestMoreUseSearch, showUndefinedOptionWithCountAtBottom, }: DefaultFilterProps<TFilterValue>) => ReactElement;
11
11
  export {};
@@ -3,7 +3,7 @@ import { Size } from "@trackunit/react-components";
3
3
  import { FilterVisualStyle } from "@trackunit/react-filter-components";
4
4
  import { ReactElement } from "react";
5
5
  import { FilterBarDefinition, FilterDefinition, FilterMapActions, FilterMapGetter, FilterState } from "../types/FilterTypes";
6
- interface FilterComponentProps<T extends FilterBarDefinition> {
6
+ interface FilterComponentProps<TFilterBarDefinition extends FilterBarDefinition> {
7
7
  /**
8
8
  * The definition of the filter.
9
9
  */
@@ -11,7 +11,7 @@ interface FilterComponentProps<T extends FilterBarDefinition> {
11
11
  /**
12
12
  * The state of the filter.
13
13
  */
14
- filterState: FilterState<T>;
14
+ filterState: FilterState<TFilterBarDefinition>;
15
15
  /**
16
16
  * Actions and getters for the filter bar.
17
17
  */
@@ -43,5 +43,5 @@ interface FilterComponentProps<T extends FilterBarDefinition> {
43
43
  *
44
44
  * @returns {ReactElement} - Returns the Filter component.
45
45
  */
46
- export declare const FilterComponent: <T extends FilterBarDefinition>({ filter, filterBarActions, filterState, readOnly, visualStyle, className, asIcon, size, }: FilterComponentProps<T>) => ReactElement;
46
+ export declare const FilterComponent: <TFilterBarDefinition extends FilterBarDefinition>({ filter, filterBarActions, filterState, readOnly, visualStyle, className, asIcon, size, }: FilterComponentProps<TFilterBarDefinition>) => ReactElement;
47
47
  export {};
@@ -166,41 +166,41 @@ export interface FilterViewProps<TReturnType> {
166
166
  hideHeader?: boolean;
167
167
  hasCount?: boolean;
168
168
  }
169
- export type FiltersStoreInstance<T extends FilterBarDefinition> = Partial<FilterBarConfig<T>>;
169
+ export type FiltersStoreInstance<TFilterBarDefinition extends FilterBarDefinition> = Partial<FilterBarConfig<TFilterBarDefinition>>;
170
170
  /**
171
171
  * This is the container of all the FilterMaps that can be used to filter, this is persisted to localstorage.
172
172
  */
173
- export interface FilterStateMap<T extends FilterBarDefinition> {
174
- filtersMap: Record<string, FilterBarConfig<T>>;
173
+ export interface FilterStateMap<TFilterBarDefinition extends FilterBarDefinition> {
174
+ filtersMap: Record<string, FilterBarConfig<TFilterBarDefinition>>;
175
175
  }
176
- export type FilterBarInferredValue<T extends FilterBarDefinition, K extends keyof T> = T[K]["type"] extends infer Type ? Type extends "boolean" ? BooleanValue | undefined : Type extends "string" ? string | undefined : Type extends "number" ? number | undefined : Type extends "area" ? AreaFilterGeoJsonGeometry | undefined : Type extends "valueNameArray" ? Array<ValueName> | undefined : Type extends "valueName" ? ValueName | undefined : Type extends "stringArray" ? Array<string> | undefined : Type extends "minMax" ? MinMaxFilterValue | undefined : Type extends "dateRange" ? DateRangeValue | undefined : undefined : undefined;
177
- export type SetterKey<T extends string> = `set${Capitalize<T>}`;
178
- export type ReverseSetterKey<T extends string> = Uncapitalize<T extends `set${infer U}` ? U : never>;
179
- export type ExtractFilterKeys<T extends FilterBarDefinition> = Extract<keyof T, string>;
180
- export type ExtractSetterKeys<T extends FilterBarDefinition> = {
181
- [K in ExtractFilterKeys<T>]: SetterKey<K>;
176
+ export type FilterBarInferredValue<TFilterBarDefinition extends FilterBarDefinition, TFilterKey extends keyof TFilterBarDefinition> = TFilterBarDefinition[TFilterKey]["type"] extends infer TFilterType ? TFilterType extends "boolean" ? BooleanValue | undefined : TFilterType extends "string" ? string | undefined : TFilterType extends "number" ? number | undefined : TFilterType extends "area" ? AreaFilterGeoJsonGeometry | undefined : TFilterType extends "valueNameArray" ? Array<ValueName> | undefined : TFilterType extends "valueName" ? ValueName | undefined : TFilterType extends "stringArray" ? Array<string> | undefined : TFilterType extends "minMax" ? MinMaxFilterValue | undefined : TFilterType extends "dateRange" ? DateRangeValue | undefined : undefined : undefined;
177
+ export type SetterKey<TName extends string> = `set${Capitalize<TName>}`;
178
+ export type ReverseSetterKey<TSetter extends string> = Uncapitalize<TSetter extends `set${infer TName}` ? TName : never>;
179
+ export type ExtractFilterKeys<TFilterBarDefinition extends FilterBarDefinition> = Extract<keyof TFilterBarDefinition, string>;
180
+ export type ExtractSetterKeys<TFilterBarDefinition extends FilterBarDefinition> = {
181
+ [KeyFilter in ExtractFilterKeys<TFilterBarDefinition>]: SetterKey<KeyFilter>;
182
182
  };
183
- export type FilterStateSetterCallback<T> = (callback: (prev: T | undefined) => T | undefined) => void;
183
+ export type FilterStateSetterCallback<TValue> = (callback: (prev: TValue | undefined) => TValue | undefined) => void;
184
184
  export type FilterStateSetters<TFilterBarDefinition extends FilterBarDefinition> = {
185
- [K in ExtractSetterKeys<TFilterBarDefinition>[keyof ExtractSetterKeys<TFilterBarDefinition>]]: FilterStateSetterCallback<FilterBarInferredValue<TFilterBarDefinition, ReverseSetterKey<K>> | undefined>;
185
+ [KeySetter in ExtractSetterKeys<TFilterBarDefinition>[keyof ExtractSetterKeys<TFilterBarDefinition>]]: FilterStateSetterCallback<FilterBarInferredValue<TFilterBarDefinition, ReverseSetterKey<KeySetter>> | undefined>;
186
186
  };
187
- export type FilterStateValues<T extends FilterBarDefinition> = {
188
- [K in keyof T]?: FilterBarInferredValue<T, K>;
187
+ export type FilterStateValues<TFilterBarDefinition extends FilterBarDefinition> = {
188
+ [KeyFilter in keyof TFilterBarDefinition]?: FilterBarInferredValue<TFilterBarDefinition, KeyFilter>;
189
189
  };
190
- export type InitialState<T extends FilterBarDefinition> = {
191
- [K in keyof T]?: FilterBarInferredValue<T, K>;
190
+ export type InitialState<TFilterBarDefinition extends FilterBarDefinition> = {
191
+ [KeyFilter in keyof TFilterBarDefinition]?: FilterBarInferredValue<TFilterBarDefinition, KeyFilter>;
192
192
  };
193
- export interface FilterState<T extends FilterBarDefinition> {
194
- values: FilterStateValues<T>;
195
- setters: FilterStateSetters<T>;
193
+ export interface FilterState<TFilterBarDefinition extends FilterBarDefinition> {
194
+ values: FilterStateValues<TFilterBarDefinition>;
195
+ setters: FilterStateSetters<TFilterBarDefinition>;
196
196
  }
197
197
  /**
198
198
  * A FilterBarConfig is the Container of filters that can be used to filter.
199
199
  */
200
- export interface FilterBarConfig<T extends FilterBarDefinition> extends FilterState<T> {
200
+ export interface FilterBarConfig<TFilterBarDefinition extends FilterBarDefinition> extends FilterState<TFilterBarDefinition> {
201
201
  name: string;
202
202
  /**
203
203
  * The initial state of the filter bar - used to restore the filter bar to its initial state, and to validate if a filter has been changed from the initial state.
204
204
  */
205
- initialState: InitialState<T>;
205
+ initialState: InitialState<TFilterBarDefinition>;
206
206
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Toggles a filter value in an array.
3
3
  *
4
- * @template T - The type of the filter values.
5
- * @returns {(prev?: T[]) => T[]} A function that takes an optional previous array of filter values
4
+ * @template TValue - The type of the filter values.
5
+ * @returns {(prev?: TValue[]) => TValue[]} A function that takes an optional previous array of filter values
6
6
  */
7
- export declare const toggleFilterValue: <T extends string | number | object>(value: T) => ((prev?: Array<T>) => Array<T>);
7
+ export declare const toggleFilterValue: <TValue extends string | number | object>(value: TValue) => ((prev?: Array<TValue>) => Array<TValue>);