@trackunit/filters-filter-bar 1.3.236 → 1.3.237

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
@@ -1333,7 +1333,7 @@ const mockFilterBar = {
1333
1333
  getFilterBarName: doNothing,
1334
1334
  initialState: { customerType: [] },
1335
1335
  name: "test",
1336
- hasDefaultValue: doNothing,
1336
+ isDefaultValue: doNothing,
1337
1337
  objectArrayIncludesValue: doNothing,
1338
1338
  resetFiltersToInitialState: doNothing,
1339
1339
  resetIndividualFilterToInitialState: doNothing,
@@ -1582,16 +1582,11 @@ const useFilterBarActions = ({ name, filterBarConfig, filterBarDefinition, setFi
1582
1582
  const filter = filterBarConfig.values[key];
1583
1583
  return filter?.includes(value) || false;
1584
1584
  },
1585
- hasDefaultValue(key) {
1586
- // eslint-disable-next-line local-rules/no-typescript-assertion
1587
- const filterValue = filterBarConfig.values[key];
1585
+ isDefaultValue(key, filterValue) {
1588
1586
  const filterDefinition = filterBarDefinition[key];
1589
- if (dequal.dequal(filterValue, filterBarDefinition[key]?.defaultValue) || dequal.dequal(filterValue, initialState?.[key])) {
1587
+ if (dequal.dequal(filterValue, initialState?.[key]) || dequal.dequal(filterValue, filterDefinition?.defaultValue)) {
1590
1588
  return true;
1591
1589
  }
1592
- if (filterDefinition && filterDefinition.defaultValue === undefined) {
1593
- return false;
1594
- }
1595
1590
  if (!filterValue) {
1596
1591
  return true;
1597
1592
  }
package/index.esm.js CHANGED
@@ -1331,7 +1331,7 @@ const mockFilterBar = {
1331
1331
  getFilterBarName: doNothing,
1332
1332
  initialState: { customerType: [] },
1333
1333
  name: "test",
1334
- hasDefaultValue: doNothing,
1334
+ isDefaultValue: doNothing,
1335
1335
  objectArrayIncludesValue: doNothing,
1336
1336
  resetFiltersToInitialState: doNothing,
1337
1337
  resetIndividualFilterToInitialState: doNothing,
@@ -1580,16 +1580,11 @@ const useFilterBarActions = ({ name, filterBarConfig, filterBarDefinition, setFi
1580
1580
  const filter = filterBarConfig.values[key];
1581
1581
  return filter?.includes(value) || false;
1582
1582
  },
1583
- hasDefaultValue(key) {
1584
- // eslint-disable-next-line local-rules/no-typescript-assertion
1585
- const filterValue = filterBarConfig.values[key];
1583
+ isDefaultValue(key, filterValue) {
1586
1584
  const filterDefinition = filterBarDefinition[key];
1587
- if (dequal(filterValue, filterBarDefinition[key]?.defaultValue) || dequal(filterValue, initialState?.[key])) {
1585
+ if (dequal(filterValue, initialState?.[key]) || dequal(filterValue, filterDefinition?.defaultValue)) {
1588
1586
  return true;
1589
1587
  }
1590
- if (filterDefinition && filterDefinition.defaultValue === undefined) {
1591
- return false;
1592
- }
1593
1588
  if (!filterValue) {
1594
1589
  return true;
1595
1590
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/filters-filter-bar",
3
- "version": "1.3.236",
3
+ "version": "1.3.237",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -15,14 +15,14 @@
15
15
  "string-ts": "^2.0.0",
16
16
  "zod": "3.23.4",
17
17
  "@trackunit/iris-app-api": "1.3.148",
18
- "@trackunit/react-core-hooks": "1.3.153",
18
+ "@trackunit/react-core-hooks": "1.3.154",
19
19
  "@trackunit/react-filter-components": "1.3.194",
20
- "@trackunit/react-date-and-time-components": "1.3.197",
20
+ "@trackunit/react-date-and-time-components": "1.3.198",
21
21
  "@trackunit/shared-utils": "1.5.141",
22
- "@trackunit/react-form-components": "1.3.196",
22
+ "@trackunit/react-form-components": "1.3.197",
23
23
  "@trackunit/react-core-contexts-api": "1.4.148",
24
24
  "@trackunit/geo-json-utils": "1.3.139",
25
- "@trackunit/i18n-library-translation": "1.3.160",
25
+ "@trackunit/i18n-library-translation": "1.3.161",
26
26
  "@trackunit/css-class-variance-utilities": "1.3.141",
27
27
  "@trackunit/react-components": "1.4.172",
28
28
  "@trackunit/react-test-setup": "1.0.31"
@@ -1,4 +1,22 @@
1
- export * from "./components";
1
+ export * from "./components/AppliedFiltersRenderer";
2
+ export * from "./components/DefaultCheckboxFilter";
3
+ export * from "./components/DefaultDateRangeFilter";
4
+ export * from "./components/DefaultFilterTypes";
5
+ export * from "./components/DefaultMinMaxFilter";
6
+ export * from "./components/DefaultRadioFilter";
7
+ export * from "./components/DynamicFilterList";
8
+ export * from "./components/FilterButtonTooltipLabel";
9
+ export * from "./components/FilterComponent";
10
+ export * from "./components/FilterHeader";
11
+ export * from "./components/FilterResults";
12
+ export * from "./components/FiltersMenu";
13
+ export * from "./components/FiltersMenuContent";
14
+ export * from "./components/FiltersRenderer";
15
+ export * from "./components/FilterTableComponent";
16
+ export * from "./components/FilterTooltips/MultipleFilterTooltipLabel";
17
+ export * from "./components/GroupedFiltersList";
18
+ export * from "./components/HierarchicalCheckboxFilter/HierarchicalCheckboxFilter";
19
+ export * from "./components/ResetFiltersButton";
2
20
  export * from "./FilterBar";
3
21
  export * from "./hooks/mockFilterBar";
4
22
  export * from "./hooks/useFilterBar";
@@ -6,6 +24,7 @@ export * from "./hooks/useFilterBarAsync";
6
24
  export * from "./hooks/useFiltersMenu";
7
25
  export * from "./hooks/useSearchParamAsFilter";
8
26
  export * from "./types/FilterTypes";
27
+ export * from "./types/FilterZodTypes";
9
28
  export * from "./utils/FilterEvents";
10
29
  export * from "./utils/mergeFilters";
11
30
  export * from "./utils/toggleFilterValue";
@@ -1,6 +1,5 @@
1
- import { geoJsonMultiPolygonSchema, geoJsonPolygonSchema } from "@trackunit/geo-json-utils";
2
1
  import { ReactNode } from "react";
3
- import { z } from "zod";
2
+ import { AreaFilterGeoJsonGeometry } from "./FilterZodTypes";
4
3
  export type ValueName = {
5
4
  value: string;
6
5
  name: string;
@@ -15,26 +14,6 @@ export type MinMaxFilterValue = {
15
14
  min?: number;
16
15
  max?: number;
17
16
  };
18
- export declare const areaFilterGeoJsonGeometrySchema: z.ZodUnion<[z.ZodObject<{
19
- type: z.ZodLiteral<"Polygon">;
20
- coordinates: z.ZodArray<z.ZodEffects<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, "many">, [number, number][], [number, number][]>, "many">;
21
- }, "strict", z.ZodTypeAny, {
22
- type: "Polygon";
23
- coordinates: [number, number][][];
24
- }, {
25
- type: "Polygon";
26
- coordinates: [number, number][][];
27
- }>, z.ZodObject<{
28
- type: z.ZodLiteral<"MultiPolygon">;
29
- coordinates: z.ZodArray<z.ZodArray<z.ZodEffects<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, "many">, [number, number][], [number, number][]>, "many">, "many">;
30
- }, "strict", z.ZodTypeAny, {
31
- type: "MultiPolygon";
32
- coordinates: [number, number][][][];
33
- }, {
34
- type: "MultiPolygon";
35
- coordinates: [number, number][][][];
36
- }>]>;
37
- export type AreaFilterGeoJsonGeometry = z.infer<typeof geoJsonPolygonSchema> | z.infer<typeof geoJsonMultiPolygonSchema>;
38
17
  export type FilterValueType = Array<string> | Array<ValueName> | ValueName | MinMaxFilterValue | AreaFilterGeoJsonGeometry | string | number | BooleanValue | undefined;
39
18
  export declare type FilterTypes = "boolean" | "string" | "number" | "dateRange" | "area" | "valueNameArray" | "valueName" | "stringArray" | "minMax";
40
19
  export type FilterMapActions = {
@@ -60,7 +39,7 @@ export type FilterMapGetter = {
60
39
  objectArrayIncludesValue: (key: string, value: string) => boolean;
61
40
  objectIncludesValue: (key: string, value: string) => boolean;
62
41
  getValuesByKey: (key: string) => FilterValueType;
63
- hasDefaultValue: (key: string) => boolean;
42
+ isDefaultValue: (key: string, value: FilterValueType) => boolean;
64
43
  arrayIncludesValue: (key: string, value: string | boolean) => boolean;
65
44
  appliedFilterKeys: () => Array<keyof FilterBarDefinition>;
66
45
  isFilterIncludedByKey(key: string): boolean;
@@ -78,39 +57,13 @@ export interface AbstractFilterDefinition {
78
57
  * The type of the filter, indicating its behavior and data format.
79
58
  */
80
59
  type: FilterTypes;
81
- /**
82
- * The title and translation for the filter.
83
- */
84
60
  title: FilterTranslation;
85
- /**
86
- * If the filter should be on the provided filter bar as default
87
- */
88
61
  default?: boolean;
89
- /**
90
- * If the filter should be persisted this key to localstorage, if not it will not override if it is in the localstorage and not load if it is.
91
- */
92
62
  persistValue?: boolean;
93
- /**
94
- * The Group the filter will be shown under in the ui.
95
- *
96
- * @default "OTHER"
97
- */
98
63
  group: FilterGroup;
99
- /**
100
- * A function that determines if the filter should be displayed in the starred filter menu.
101
- */
102
64
  showInStarredMenu?: () => boolean;
103
- /**
104
- * A function that determines if the filter should be displayed in the filter bar.
105
- */
106
65
  showInFilterBar?: () => boolean;
107
- /**
108
- * A boolean that determines if the filter should be displayed in the filter bar without a menu, like a search field.
109
- */
110
66
  showDirectly?: boolean;
111
- /**
112
- * A boolean that determines if the filter should be generated.
113
- */
114
67
  isHidden?: boolean;
115
68
  }
116
69
  export interface BooleanFilterDefinition extends AbstractFilterDefinition {
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ export declare const areaFilterGeoJsonGeometrySchema: z.ZodUnion<[z.ZodObject<{
3
+ type: z.ZodLiteral<"Polygon">;
4
+ coordinates: z.ZodArray<z.ZodEffects<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, "many">, [number, number][], [number, number][]>, "many">;
5
+ }, "strict", z.ZodTypeAny, {
6
+ type: "Polygon";
7
+ coordinates: [number, number][][];
8
+ }, {
9
+ type: "Polygon";
10
+ coordinates: [number, number][][];
11
+ }>, z.ZodObject<{
12
+ type: z.ZodLiteral<"MultiPolygon">;
13
+ coordinates: z.ZodArray<z.ZodArray<z.ZodEffects<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, "many">, [number, number][], [number, number][]>, "many">, "many">;
14
+ }, "strict", z.ZodTypeAny, {
15
+ type: "MultiPolygon";
16
+ coordinates: [number, number][][][];
17
+ }, {
18
+ type: "MultiPolygon";
19
+ coordinates: [number, number][][][];
20
+ }>]>;
21
+ export type AreaFilterGeoJsonGeometry = z.infer<typeof areaFilterGeoJsonGeometrySchema>;
@@ -1,4 +1,5 @@
1
- import { AreaFilterGeoJsonGeometry, BooleanValue, DateRangeValue, FilterBarConfig, FilterBarDefinition, FilterDefinition, FilterDefinitionValue, MinMaxFilterValue, ValueName } from "../types/FilterTypes";
1
+ import { BooleanValue, DateRangeValue, FilterBarConfig, FilterBarDefinition, FilterDefinition, FilterDefinitionValue, MinMaxFilterValue, ValueName } from "../types/FilterTypes";
2
+ import { AreaFilterGeoJsonGeometry } from "../types/FilterZodTypes";
2
3
  /**
3
4
  *
4
5
  */
@@ -1,19 +0,0 @@
1
- export * from "./AppliedFiltersRenderer";
2
- export * from "./DefaultCheckboxFilter";
3
- export * from "./DefaultDateRangeFilter";
4
- export * from "./DefaultFilterTypes";
5
- export * from "./DefaultMinMaxFilter";
6
- export * from "./DefaultRadioFilter";
7
- export * from "./DynamicFilterList";
8
- export * from "./FilterButtonTooltipLabel";
9
- export * from "./FilterComponent";
10
- export * from "./FilterHeader";
11
- export * from "./FilterResults";
12
- export * from "./FiltersMenu";
13
- export * from "./FiltersMenuContent";
14
- export * from "./FiltersRenderer";
15
- export * from "./FilterTableComponent";
16
- export * from "./FilterTooltips/MultipleFilterTooltipLabel";
17
- export * from "./GroupedFiltersList";
18
- export * from "./HierarchicalCheckboxFilter/HierarchicalCheckboxFilter";
19
- export * from "./ResetFiltersButton";