@trackunit/filters-asset-filter-definitions 1.9.83 → 1.9.84

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.
Files changed (3) hide show
  1. package/index.cjs.js +71 -33
  2. package/index.esm.js +71 -33
  3. package/package.json +18 -18
package/index.cjs.js CHANGED
@@ -2231,6 +2231,7 @@ const SHARED_LOCATIONS_LOCAL_STORAGE_KEY = "shared-recent-locations";
2231
2231
  const MAX_RECENT_SEARCHES$2 = 5;
2232
2232
  const MIN_LENGTH_SEARCH = 3;
2233
2233
  const MAX_RESULTS = 5;
2234
+ const placesArraySchema = zod.z.array(placeSchema);
2234
2235
  /**
2235
2236
  * Hook for place search with autocomplete predictions and recent places history.
2236
2237
  * Queries the internal GeoEnrichment API for predictions and place details (geo data) from Google's Places Autocomplete.
@@ -2241,11 +2242,12 @@ const usePlacesSearch = ({ localStorageKey = SHARED_LOCATIONS_LOCAL_STORAGE_KEY,
2241
2242
  const [t] = useTranslation();
2242
2243
  const [searchString, setSearchString] = react.useState("");
2243
2244
  const [selectedPrediction, setSelectedPrediction] = react.useState(undefined);
2244
- const [recentPlaces, setRecentPlaces] = reactCoreHooks.useLocalStorage({
2245
+ const localStorageProps = react.useMemo(() => ({
2245
2246
  defaultState: [],
2246
2247
  key: localStorageKey,
2247
- schema: zod.z.array(placeSchema),
2248
- });
2248
+ schema: placesArraySchema,
2249
+ }), [localStorageKey]);
2250
+ const [recentPlaces, setRecentPlaces] = reactCoreHooks.useLocalStorage(localStorageProps);
2249
2251
  const debouncedSearchString = reactComponents.useDebounce(searchString);
2250
2252
  const isRecentPlace = react.useCallback((placeId) => {
2251
2253
  return recentPlaces.some(r => r.placeId === placeId);
@@ -2330,9 +2332,9 @@ const usePlacesSearch = ({ localStorageKey = SHARED_LOCATIONS_LOCAL_STORAGE_KEY,
2330
2332
  ];
2331
2333
  });
2332
2334
  }, [maxRecentSearches, setRecentPlaces]);
2333
- const removeRecentPlace = (place) => {
2335
+ const removeRecentPlace = react.useCallback((place) => {
2334
2336
  setRecentPlaces(prev => prev.filter(r => r.placeId !== place.placeId));
2335
- };
2337
+ }, [setRecentPlaces]);
2336
2338
  react.useEffect(() => {
2337
2339
  if (!selectedPlaceData) {
2338
2340
  return;
@@ -2341,7 +2343,7 @@ const usePlacesSearch = ({ localStorageKey = SHARED_LOCATIONS_LOCAL_STORAGE_KEY,
2341
2343
  addRecentPlace(selectedPlaceData);
2342
2344
  }
2343
2345
  }, [selectedPlaceData, addRecentPlace, isRecentPlace]);
2344
- return {
2346
+ return react.useMemo(() => ({
2345
2347
  places: places.slice(0, maxResults),
2346
2348
  loading: loadingPlaceAutocomplete || loadingDetails,
2347
2349
  searchString,
@@ -2355,7 +2357,23 @@ const usePlacesSearch = ({ localStorageKey = SHARED_LOCATIONS_LOCAL_STORAGE_KEY,
2355
2357
  selectedPrediction,
2356
2358
  setSelectedPrediction,
2357
2359
  selectedPlaceData,
2358
- };
2360
+ }), [
2361
+ places,
2362
+ maxResults,
2363
+ loadingPlaceAutocomplete,
2364
+ loadingDetails,
2365
+ searchString,
2366
+ setSearchString,
2367
+ debouncedSearchString,
2368
+ recentPlaces,
2369
+ setRecentPlaces,
2370
+ hint,
2371
+ removeRecentPlace,
2372
+ addRecentPlace,
2373
+ selectedPrediction,
2374
+ setSelectedPrediction,
2375
+ selectedPlaceData,
2376
+ ]);
2359
2377
  };
2360
2378
 
2361
2379
  /**
@@ -3545,11 +3563,12 @@ const RentalContractReferenceCodeDescriptionFilterView = ({ filterBarActions, fi
3545
3563
  }
3546
3564
  filterValue !== undefined && setSearchString(filterValue);
3547
3565
  }, [filterValue, previousFilterValue, searchString]);
3548
- const [recentSearches, setRecentSearches] = reactCoreHooks.useLocalStorage({
3566
+ const localStorageProps = react.useMemo(() => ({
3549
3567
  defaultState: [],
3550
3568
  key: `${localStorageKey}-${filterDefinition?.filterKey}-free-text-filter-recent-searches-${clientSideUserId}`,
3551
3569
  schema: zod.z.array(zod.z.string()),
3552
- });
3570
+ }), [localStorageKey, filterDefinition?.filterKey, clientSideUserId]);
3571
+ const [recentSearches, setRecentSearches] = reactCoreHooks.useLocalStorage(localStorageProps);
3553
3572
  const apply = react.useCallback(({ value, setRecent = true }) => {
3554
3573
  if (setRecent !== false) {
3555
3574
  setRecentSearches(prev => {
@@ -3667,6 +3686,7 @@ const useRentalContractReferenceCodeFilter = ({ showInFilterBar } = {
3667
3686
  return result;
3668
3687
  };
3669
3688
 
3689
+ const searchStringSchema = zod.z.array(zod.z.string());
3670
3690
  const MAX_RECENT_SEARCHES = 20;
3671
3691
  /**
3672
3692
  *
@@ -3693,11 +3713,12 @@ const SearchFilterInline = ({ filterBarActions, filterState, filterDefinition, l
3693
3713
  }
3694
3714
  filterValue !== undefined && setSearchString(filterValue);
3695
3715
  }, [filterValue, previousFilterValue, searchString]);
3696
- const [recentSearches, setRecentSearches] = reactCoreHooks.useLocalStorage({
3716
+ const localStorageProps = react.useMemo(() => ({
3697
3717
  defaultState: [],
3698
3718
  key: `${localStorageKey}-${filterDefinition?.filterKey}-free-text-filter-recent-searches-${clientSideUserId}`,
3699
- schema: zod.z.array(zod.z.string()),
3700
- });
3719
+ schema: searchStringSchema,
3720
+ }), [localStorageKey, filterDefinition?.filterKey, clientSideUserId]);
3721
+ const [recentSearches, setRecentSearches] = reactCoreHooks.useLocalStorage(localStorageProps);
3701
3722
  const apply = react.useCallback(({ value, wasPreviousSearch = false, setRecent = true }) => {
3702
3723
  if (setRecent !== false) {
3703
3724
  setRecentSearches(prev => {
@@ -4752,13 +4773,17 @@ const useDefaultAssetFilterBarDefinition = ({ sitesEnabled, owningDepotEnabled,
4752
4773
  const assetType = useAssetTypeFilter();
4753
4774
  const metadataCompleteness = useMetadataCompletenessFilter();
4754
4775
  const groups = useGroupIdsFilter();
4755
- const siteIds = useSiteIdsFilter({
4756
- showInFilterBar: () => sitesEnabled || false,
4757
- group: "CURRENT_LOCATION",
4758
- });
4759
- const siteDepotOwnershipIds = useSiteDepotOwnershipIdsFilter({
4760
- showInFilterBar: () => owningDepotEnabled || false,
4761
- });
4776
+ const siteEnabledProps = react.useMemo(() => {
4777
+ return {
4778
+ showInFilterBar: () => sitesEnabled || false,
4779
+ group: "CURRENT_LOCATION",
4780
+ };
4781
+ }, [sitesEnabled]);
4782
+ const siteIds = useSiteIdsFilter(siteEnabledProps);
4783
+ const owningDepotEnabledProps = react.useMemo(() => {
4784
+ return { showInFilterBar: () => owningDepotEnabled || false };
4785
+ }, [owningDepotEnabled]);
4786
+ const siteDepotOwnershipIds = useSiteDepotOwnershipIdsFilter(owningDepotEnabledProps);
4762
4787
  const brands = useBrandFilter();
4763
4788
  const models = useModelsFilter();
4764
4789
  const types = useTypesFilter();
@@ -4766,24 +4791,37 @@ const useDefaultAssetFilterBarDefinition = ({ sitesEnabled, owningDepotEnabled,
4766
4791
  const criticality = useCriticalityFilter();
4767
4792
  const lastSeen = useLastSeenFilter();
4768
4793
  const followed = useFollowedFilter();
4769
- const siteType = useSiteTypeFilter({
4770
- showInFilterBar: () => sitesEnabled || false,
4771
- group: "CURRENT_LOCATION",
4772
- });
4794
+ const siteTypeEnabledProps = react.useMemo(() => {
4795
+ return {
4796
+ showInFilterBar: () => sitesEnabled || false,
4797
+ group: "CURRENT_LOCATION",
4798
+ };
4799
+ }, [sitesEnabled]);
4800
+ const siteType = useSiteTypeFilter(siteTypeEnabledProps);
4773
4801
  const ownerAccountIds = useOwnerAccountIdsFilter(ownerFilterDefaultValue);
4774
- const search = useSearchFilter({ localStorageKey: "assetSearch" });
4775
- const area = useAreaFilter({
4776
- showWithSearch: () => areaShowWithSearch ?? false,
4777
- });
4802
+ const searchProps = react.useMemo(() => ({ localStorageKey: "assetSearch" }), []);
4803
+ const search = useSearchFilter(searchProps);
4804
+ const areaEnabledProps = react.useMemo(() => {
4805
+ return {
4806
+ showWithSearch: () => areaShowWithSearch ?? false,
4807
+ };
4808
+ }, [areaShowWithSearch]);
4809
+ const area = useAreaFilter(areaEnabledProps);
4778
4810
  const productionYears = useProductionYearFilter();
4779
4811
  const partner = usePartnerFilter();
4780
- const serviceStatus = useServicePlanStatusFilter({
4781
- showInFilterBar: () => serviceManagementEnabled || false,
4782
- });
4812
+ const serviceManagementEnabledProps = react.useMemo(() => {
4813
+ return {
4814
+ showInFilterBar: () => serviceManagementEnabled || false,
4815
+ };
4816
+ }, [serviceManagementEnabled]);
4817
+ const serviceStatus = useServicePlanStatusFilter(serviceManagementEnabledProps);
4783
4818
  const telematicsConnected = useTelematicsConnectedFilter();
4784
- const activeFilter = useActiveFilterFilter({
4785
- isHidden: () => !showHiddenAssetsEnabled || false,
4786
- });
4819
+ const activeFilterEnabledProps = react.useMemo(() => {
4820
+ return {
4821
+ isHidden: () => !showHiddenAssetsEnabled || false,
4822
+ };
4823
+ }, [showHiddenAssetsEnabled]);
4824
+ const activeFilter = useActiveFilterFilter(activeFilterEnabledProps);
4787
4825
  return react.useMemo(() => {
4788
4826
  return {
4789
4827
  assetType,
package/index.esm.js CHANGED
@@ -2229,6 +2229,7 @@ const SHARED_LOCATIONS_LOCAL_STORAGE_KEY = "shared-recent-locations";
2229
2229
  const MAX_RECENT_SEARCHES$2 = 5;
2230
2230
  const MIN_LENGTH_SEARCH = 3;
2231
2231
  const MAX_RESULTS = 5;
2232
+ const placesArraySchema = z.array(placeSchema);
2232
2233
  /**
2233
2234
  * Hook for place search with autocomplete predictions and recent places history.
2234
2235
  * Queries the internal GeoEnrichment API for predictions and place details (geo data) from Google's Places Autocomplete.
@@ -2239,11 +2240,12 @@ const usePlacesSearch = ({ localStorageKey = SHARED_LOCATIONS_LOCAL_STORAGE_KEY,
2239
2240
  const [t] = useTranslation();
2240
2241
  const [searchString, setSearchString] = useState("");
2241
2242
  const [selectedPrediction, setSelectedPrediction] = useState(undefined);
2242
- const [recentPlaces, setRecentPlaces] = useLocalStorage({
2243
+ const localStorageProps = useMemo(() => ({
2243
2244
  defaultState: [],
2244
2245
  key: localStorageKey,
2245
- schema: z.array(placeSchema),
2246
- });
2246
+ schema: placesArraySchema,
2247
+ }), [localStorageKey]);
2248
+ const [recentPlaces, setRecentPlaces] = useLocalStorage(localStorageProps);
2247
2249
  const debouncedSearchString = useDebounce(searchString);
2248
2250
  const isRecentPlace = useCallback((placeId) => {
2249
2251
  return recentPlaces.some(r => r.placeId === placeId);
@@ -2328,9 +2330,9 @@ const usePlacesSearch = ({ localStorageKey = SHARED_LOCATIONS_LOCAL_STORAGE_KEY,
2328
2330
  ];
2329
2331
  });
2330
2332
  }, [maxRecentSearches, setRecentPlaces]);
2331
- const removeRecentPlace = (place) => {
2333
+ const removeRecentPlace = useCallback((place) => {
2332
2334
  setRecentPlaces(prev => prev.filter(r => r.placeId !== place.placeId));
2333
- };
2335
+ }, [setRecentPlaces]);
2334
2336
  useEffect(() => {
2335
2337
  if (!selectedPlaceData) {
2336
2338
  return;
@@ -2339,7 +2341,7 @@ const usePlacesSearch = ({ localStorageKey = SHARED_LOCATIONS_LOCAL_STORAGE_KEY,
2339
2341
  addRecentPlace(selectedPlaceData);
2340
2342
  }
2341
2343
  }, [selectedPlaceData, addRecentPlace, isRecentPlace]);
2342
- return {
2344
+ return useMemo(() => ({
2343
2345
  places: places.slice(0, maxResults),
2344
2346
  loading: loadingPlaceAutocomplete || loadingDetails,
2345
2347
  searchString,
@@ -2353,7 +2355,23 @@ const usePlacesSearch = ({ localStorageKey = SHARED_LOCATIONS_LOCAL_STORAGE_KEY,
2353
2355
  selectedPrediction,
2354
2356
  setSelectedPrediction,
2355
2357
  selectedPlaceData,
2356
- };
2358
+ }), [
2359
+ places,
2360
+ maxResults,
2361
+ loadingPlaceAutocomplete,
2362
+ loadingDetails,
2363
+ searchString,
2364
+ setSearchString,
2365
+ debouncedSearchString,
2366
+ recentPlaces,
2367
+ setRecentPlaces,
2368
+ hint,
2369
+ removeRecentPlace,
2370
+ addRecentPlace,
2371
+ selectedPrediction,
2372
+ setSelectedPrediction,
2373
+ selectedPlaceData,
2374
+ ]);
2357
2375
  };
2358
2376
 
2359
2377
  /**
@@ -3543,11 +3561,12 @@ const RentalContractReferenceCodeDescriptionFilterView = ({ filterBarActions, fi
3543
3561
  }
3544
3562
  filterValue !== undefined && setSearchString(filterValue);
3545
3563
  }, [filterValue, previousFilterValue, searchString]);
3546
- const [recentSearches, setRecentSearches] = useLocalStorage({
3564
+ const localStorageProps = useMemo(() => ({
3547
3565
  defaultState: [],
3548
3566
  key: `${localStorageKey}-${filterDefinition?.filterKey}-free-text-filter-recent-searches-${clientSideUserId}`,
3549
3567
  schema: z.array(z.string()),
3550
- });
3568
+ }), [localStorageKey, filterDefinition?.filterKey, clientSideUserId]);
3569
+ const [recentSearches, setRecentSearches] = useLocalStorage(localStorageProps);
3551
3570
  const apply = useCallback(({ value, setRecent = true }) => {
3552
3571
  if (setRecent !== false) {
3553
3572
  setRecentSearches(prev => {
@@ -3665,6 +3684,7 @@ const useRentalContractReferenceCodeFilter = ({ showInFilterBar } = {
3665
3684
  return result;
3666
3685
  };
3667
3686
 
3687
+ const searchStringSchema = z.array(z.string());
3668
3688
  const MAX_RECENT_SEARCHES = 20;
3669
3689
  /**
3670
3690
  *
@@ -3691,11 +3711,12 @@ const SearchFilterInline = ({ filterBarActions, filterState, filterDefinition, l
3691
3711
  }
3692
3712
  filterValue !== undefined && setSearchString(filterValue);
3693
3713
  }, [filterValue, previousFilterValue, searchString]);
3694
- const [recentSearches, setRecentSearches] = useLocalStorage({
3714
+ const localStorageProps = useMemo(() => ({
3695
3715
  defaultState: [],
3696
3716
  key: `${localStorageKey}-${filterDefinition?.filterKey}-free-text-filter-recent-searches-${clientSideUserId}`,
3697
- schema: z.array(z.string()),
3698
- });
3717
+ schema: searchStringSchema,
3718
+ }), [localStorageKey, filterDefinition?.filterKey, clientSideUserId]);
3719
+ const [recentSearches, setRecentSearches] = useLocalStorage(localStorageProps);
3699
3720
  const apply = useCallback(({ value, wasPreviousSearch = false, setRecent = true }) => {
3700
3721
  if (setRecent !== false) {
3701
3722
  setRecentSearches(prev => {
@@ -4750,13 +4771,17 @@ const useDefaultAssetFilterBarDefinition = ({ sitesEnabled, owningDepotEnabled,
4750
4771
  const assetType = useAssetTypeFilter();
4751
4772
  const metadataCompleteness = useMetadataCompletenessFilter();
4752
4773
  const groups = useGroupIdsFilter();
4753
- const siteIds = useSiteIdsFilter({
4754
- showInFilterBar: () => sitesEnabled || false,
4755
- group: "CURRENT_LOCATION",
4756
- });
4757
- const siteDepotOwnershipIds = useSiteDepotOwnershipIdsFilter({
4758
- showInFilterBar: () => owningDepotEnabled || false,
4759
- });
4774
+ const siteEnabledProps = useMemo(() => {
4775
+ return {
4776
+ showInFilterBar: () => sitesEnabled || false,
4777
+ group: "CURRENT_LOCATION",
4778
+ };
4779
+ }, [sitesEnabled]);
4780
+ const siteIds = useSiteIdsFilter(siteEnabledProps);
4781
+ const owningDepotEnabledProps = useMemo(() => {
4782
+ return { showInFilterBar: () => owningDepotEnabled || false };
4783
+ }, [owningDepotEnabled]);
4784
+ const siteDepotOwnershipIds = useSiteDepotOwnershipIdsFilter(owningDepotEnabledProps);
4760
4785
  const brands = useBrandFilter();
4761
4786
  const models = useModelsFilter();
4762
4787
  const types = useTypesFilter();
@@ -4764,24 +4789,37 @@ const useDefaultAssetFilterBarDefinition = ({ sitesEnabled, owningDepotEnabled,
4764
4789
  const criticality = useCriticalityFilter();
4765
4790
  const lastSeen = useLastSeenFilter();
4766
4791
  const followed = useFollowedFilter();
4767
- const siteType = useSiteTypeFilter({
4768
- showInFilterBar: () => sitesEnabled || false,
4769
- group: "CURRENT_LOCATION",
4770
- });
4792
+ const siteTypeEnabledProps = useMemo(() => {
4793
+ return {
4794
+ showInFilterBar: () => sitesEnabled || false,
4795
+ group: "CURRENT_LOCATION",
4796
+ };
4797
+ }, [sitesEnabled]);
4798
+ const siteType = useSiteTypeFilter(siteTypeEnabledProps);
4771
4799
  const ownerAccountIds = useOwnerAccountIdsFilter(ownerFilterDefaultValue);
4772
- const search = useSearchFilter({ localStorageKey: "assetSearch" });
4773
- const area = useAreaFilter({
4774
- showWithSearch: () => areaShowWithSearch ?? false,
4775
- });
4800
+ const searchProps = useMemo(() => ({ localStorageKey: "assetSearch" }), []);
4801
+ const search = useSearchFilter(searchProps);
4802
+ const areaEnabledProps = useMemo(() => {
4803
+ return {
4804
+ showWithSearch: () => areaShowWithSearch ?? false,
4805
+ };
4806
+ }, [areaShowWithSearch]);
4807
+ const area = useAreaFilter(areaEnabledProps);
4776
4808
  const productionYears = useProductionYearFilter();
4777
4809
  const partner = usePartnerFilter();
4778
- const serviceStatus = useServicePlanStatusFilter({
4779
- showInFilterBar: () => serviceManagementEnabled || false,
4780
- });
4810
+ const serviceManagementEnabledProps = useMemo(() => {
4811
+ return {
4812
+ showInFilterBar: () => serviceManagementEnabled || false,
4813
+ };
4814
+ }, [serviceManagementEnabled]);
4815
+ const serviceStatus = useServicePlanStatusFilter(serviceManagementEnabledProps);
4781
4816
  const telematicsConnected = useTelematicsConnectedFilter();
4782
- const activeFilter = useActiveFilterFilter({
4783
- isHidden: () => !showHiddenAssetsEnabled || false,
4784
- });
4817
+ const activeFilterEnabledProps = useMemo(() => {
4818
+ return {
4819
+ isHidden: () => !showHiddenAssetsEnabled || false,
4820
+ };
4821
+ }, [showHiddenAssetsEnabled]);
4822
+ const activeFilter = useActiveFilterFilter(activeFilterEnabledProps);
4785
4823
  return useMemo(() => {
4786
4824
  return {
4787
4825
  assetType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/filters-asset-filter-definitions",
3
- "version": "1.9.83",
3
+ "version": "1.9.84",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -17,23 +17,23 @@
17
17
  "@tanstack/react-router": "1.114.29",
18
18
  "string-ts": "^2.0.0",
19
19
  "tailwind-merge": "^2.0.0",
20
- "@trackunit/iris-app-build-utilities": "1.6.48",
21
- "@trackunit/filters-filter-bar": "1.7.79",
22
- "@trackunit/react-core-hooks": "1.6.51",
23
- "@trackunit/react-filter-components": "1.6.72",
24
- "@trackunit/react-form-components": "1.7.37",
25
- "@trackunit/filters-graphql-hook": "1.9.80",
26
- "@trackunit/utilization-indicator": "1.6.67",
27
- "@trackunit/geo-json-utils": "1.6.48",
28
- "@trackunit/react-components": "1.8.21",
29
- "@trackunit/shared-utils": "1.8.48",
30
- "@trackunit/translations-machine-type": "1.6.58",
31
- "@trackunit/criticality-indicator": "1.6.66",
32
- "@trackunit/iris-app-api": "1.6.48",
33
- "@trackunit/react-core-contexts-test": "1.6.51",
34
- "@trackunit/i18n-library-translation": "1.6.52",
35
- "@trackunit/react-core-contexts-api": "1.7.49",
36
- "@trackunit/react-test-setup": "1.3.48"
20
+ "@trackunit/iris-app-build-utilities": "1.6.49",
21
+ "@trackunit/filters-filter-bar": "1.7.80",
22
+ "@trackunit/react-core-hooks": "1.6.52",
23
+ "@trackunit/react-filter-components": "1.6.73",
24
+ "@trackunit/react-form-components": "1.7.38",
25
+ "@trackunit/filters-graphql-hook": "1.9.81",
26
+ "@trackunit/utilization-indicator": "1.6.68",
27
+ "@trackunit/geo-json-utils": "1.6.49",
28
+ "@trackunit/react-components": "1.8.22",
29
+ "@trackunit/shared-utils": "1.8.49",
30
+ "@trackunit/translations-machine-type": "1.6.59",
31
+ "@trackunit/criticality-indicator": "1.6.67",
32
+ "@trackunit/iris-app-api": "1.6.49",
33
+ "@trackunit/react-core-contexts-test": "1.6.52",
34
+ "@trackunit/i18n-library-translation": "1.6.53",
35
+ "@trackunit/react-core-contexts-api": "1.7.50",
36
+ "@trackunit/react-test-setup": "1.3.49"
37
37
  },
38
38
  "module": "./index.esm.js",
39
39
  "main": "./index.cjs.js",