@abcagency/hc-ui-components 1.3.17 → 1.3.19
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/apis/hcApi.js +85 -183
- package/dist/apis/hcApi.js.map +1 -1
- package/dist/components/HireControlMap.js +10 -5
- package/dist/components/HireControlMap.js.map +1 -1
- package/dist/components/modules/accordions/MapAccordionItem.js +10 -67
- package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
- package/dist/components/modules/filter/index.js.map +1 -1
- package/dist/components/modules/filter/radio-item.js +1 -2
- package/dist/components/modules/filter/radio-item.js.map +1 -1
- package/dist/components/modules/filter/search.js +4 -4
- package/dist/components/modules/filter/search.js.map +1 -1
- package/dist/components/modules/jobListing/listing-details-container.js +45 -0
- package/dist/components/modules/jobListing/listing-details-container.js.map +1 -0
- package/dist/components/modules/jobListing/listing-details.js +24 -24
- package/dist/components/modules/jobListing/listing-details.js.map +1 -1
- package/dist/components/modules/{maps/list → list}/field-mapper.js +8 -7
- package/dist/components/modules/list/field-mapper.js.map +1 -0
- package/dist/components/modules/{maps/list → list}/header-item.js +2 -2
- package/dist/components/modules/list/header-item.js.map +1 -0
- package/dist/components/modules/{maps/list → list}/header.js +6 -4
- package/dist/components/modules/list/header.js.map +1 -0
- package/dist/components/modules/list/index.js +36 -0
- package/dist/components/modules/list/index.js.map +1 -0
- package/dist/components/modules/{maps/list → list}/item-expand-card/index.js +3 -1
- package/dist/components/modules/list/item-expand-card/index.js.map +1 -0
- package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-contact-nav.js +2 -2
- package/dist/components/modules/list/item-expand-card/recruiter-contact-nav.js.map +1 -0
- package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-details.js +1 -1
- package/dist/components/modules/list/item-expand-card/recruiter-details.js.map +1 -0
- package/dist/components/modules/list/item-expand-card/recruiter-headshot.js.map +1 -0
- package/dist/components/modules/list/item-list.js +28 -0
- package/dist/components/modules/list/item-list.js.map +1 -0
- package/dist/components/modules/list/list-item/index.js +75 -0
- package/dist/components/modules/list/list-item/index.js.map +1 -0
- package/dist/components/modules/list/list-item/list-item-container.js +47 -0
- package/dist/components/modules/list/list-item/list-item-container.js.map +1 -0
- package/dist/components/modules/{maps/list/list-item/index.js → list/list-item/list-item.js} +29 -33
- package/dist/components/modules/list/list-item/list-item.js.map +1 -0
- package/dist/components/modules/maps/map-list.js +3 -3
- package/dist/components/modules/maps/map-list.js.map +1 -1
- package/dist/constants/eventTypes.js +1 -1
- package/dist/constants/eventTypes.js.map +1 -1
- package/dist/contexts/mapContext.js +84 -113
- package/dist/contexts/mapContext.js.map +1 -1
- package/dist/contexts/mapListContext.js +181 -290
- package/dist/contexts/mapListContext.js.map +1 -1
- package/dist/contexts/trackEventContext.js +1 -1
- package/dist/services/configService.js +10 -28
- package/dist/services/configService.js.map +1 -1
- package/dist/services/googlePlacesNearbyService.js +33 -58
- package/dist/services/googlePlacesNearbyService.js.map +1 -1
- package/dist/services/listingAggregatorService.js +35 -75
- package/dist/services/listingAggregatorService.js.map +1 -1
- package/dist/services/listingEntityService.js +10 -31
- package/dist/services/listingEntityService.js.map +1 -1
- package/dist/services/listingService.js +26 -60
- package/dist/services/listingService.js.map +1 -1
- package/dist/services/recruiterService.js +11 -31
- package/dist/services/recruiterService.js.map +1 -1
- package/dist/types/apis/hcApi.d.ts +5 -0
- package/dist/types/clientToken.d.ts +2 -0
- package/dist/types/components/modules/accordions/MapAccordionItem.d.ts +9 -0
- package/dist/types/components/modules/accordions/default.d.ts +19 -0
- package/dist/types/components/modules/buttons/button-group-apply.d.ts +24 -0
- package/dist/types/components/modules/buttons/commute-pill.d.ts +5 -0
- package/dist/types/components/modules/buttons/default.d.ts +48 -0
- package/dist/types/components/modules/buttons/pill-wrapper.d.ts +3 -0
- package/dist/types/components/modules/dialogs/apply-dialog.d.ts +8 -0
- package/dist/types/components/modules/filter/sort.d.ts +8 -0
- package/dist/types/components/modules/grid.d.ts +8 -0
- package/dist/types/components/modules/icon.d.ts +10 -0
- package/dist/types/components/modules/jobListing/listing-details-container.d.ts +6 -0
- package/dist/types/components/modules/jobListing/listing-details.d.ts +18 -0
- package/dist/types/components/modules/list/field-mapper.d.ts +10 -0
- package/dist/types/components/modules/list/header-item.d.ts +11 -0
- package/dist/types/components/modules/list/header.d.ts +11 -0
- package/dist/types/components/modules/list/index.d.ts +9 -0
- package/dist/types/components/modules/list/item-expand-card/index.d.ts +7 -0
- package/dist/types/components/modules/list/item-expand-card/recruiter-contact-nav.d.ts +17 -0
- package/dist/types/components/modules/list/item-expand-card/recruiter-details.d.ts +21 -0
- package/dist/types/components/modules/list/item-expand-card/recruiter-headshot.d.ts +8 -0
- package/dist/types/components/modules/list/item-list.d.ts +21 -0
- package/dist/types/components/modules/list/list-item/index.d.ts +12 -0
- package/dist/types/components/modules/list/list-item/list-item-container.d.ts +14 -0
- package/dist/types/components/modules/list/list-item/list-item.d.ts +3 -0
- package/dist/types/constants/eventTypes.d.ts +13 -0
- package/dist/types/contexts/mapContext.d.ts +29 -0
- package/dist/types/contexts/mapListContext.d.ts +58 -0
- package/dist/types/contexts/trackEventContext.d.ts +6 -0
- package/dist/types/enums/SectionType.d.ts +9 -0
- package/dist/types/hooks/useList.d.ts +13 -0
- package/dist/types/services/configService.d.ts +6 -0
- package/dist/types/services/googlePlacesNearbyService.d.ts +5 -0
- package/dist/types/services/listingAggregatorService.d.ts +12 -0
- package/dist/types/services/listingEntityService.d.ts +6 -0
- package/dist/types/services/listingService.d.ts +9 -0
- package/dist/types/services/recruiterService.d.ts +6 -0
- package/dist/types/types/Address.d.ts +7 -0
- package/dist/types/types/ContentSection.d.ts +8 -0
- package/dist/types/types/GetListingParams.d.ts +8 -0
- package/dist/types/types/LatLng.d.ts +4 -0
- package/dist/types/types/ListingEntity.d.ts +10 -0
- package/dist/types/types/ListingFields.d.ts +20 -0
- package/dist/types/types/Listings.d.ts +31 -0
- package/dist/types/types/Recruiter.d.ts +9 -0
- package/dist/types/types/SimilarListing.d.ts +24 -0
- package/dist/types/types/config/Colors.d.ts +8 -0
- package/dist/types/types/config/MapConfig.d.ts +29 -0
- package/dist/types/types/config/PointsOfInterestConfig.d.ts +13 -0
- package/dist/types/types/config/SearchConfig.d.ts +4 -0
- package/dist/types/util/filterUtil.d.ts +28 -0
- package/dist/types/util/loading.d.ts +3 -0
- package/dist/types/util/localStorageUtil.d.ts +3 -0
- package/dist/types/util/mapUtil.d.ts +15 -0
- package/dist/types/util/sortUtil.d.ts +1 -0
- package/dist/types/util/stringUtils.d.ts +1 -0
- package/dist/util/filterUtil.js +34 -10
- package/dist/util/filterUtil.js.map +1 -1
- package/dist/util/localStorageUtil.js +37 -28
- package/dist/util/localStorageUtil.js.map +1 -1
- package/dist/util/mapUtil.js.map +1 -1
- package/package.json +22 -14
- package/rollup.config.mjs +23 -19
- package/src/apis/{hcApi.js → hcApi.ts} +27 -11
- package/src/components/HireControlMap.js +132 -129
- package/src/components/modules/accordions/MapAccordionItem.js +32 -74
- package/src/components/modules/filter/index.js +89 -89
- package/src/components/modules/filter/radio-item.js +0 -1
- package/src/components/modules/filter/search.js +93 -92
- package/src/components/modules/jobListing/listing-details-container.js +40 -0
- package/src/components/modules/jobListing/listing-details.js +209 -99
- package/src/components/modules/{maps/list → list}/field-mapper.js +114 -112
- package/src/components/modules/{maps/list → list}/header.js +49 -47
- package/src/components/modules/list/index.tsx +83 -0
- package/src/components/modules/{maps/list → list}/item-expand-card/index.js +24 -22
- package/src/components/modules/list/item-list.tsx +198 -0
- package/src/components/modules/list/list-item/index.js +70 -0
- package/src/components/modules/list/list-item/list-item-container.js +43 -0
- package/src/components/modules/{maps/list/list-item/index.js → list/list-item/list-item.js} +129 -135
- package/src/components/modules/maps/map-list.js +74 -74
- package/src/constants/eventTypes.js +13 -13
- package/src/contexts/mapContext.tsx +129 -0
- package/src/contexts/mapListContext.tsx +297 -0
- package/src/enums/SectionType.ts +9 -0
- package/src/services/{configService.js → configService.ts} +16 -16
- package/src/services/{googlePlacesNearbyService.js → googlePlacesNearbyService.ts} +11 -2
- package/src/services/listingAggregatorService.ts +76 -0
- package/src/services/listingEntityService.ts +16 -0
- package/src/services/listingService.ts +40 -0
- package/src/services/{recruiterService.js → recruiterService.ts} +18 -17
- package/src/types/Address.ts +7 -0
- package/src/types/ContentSection.ts +9 -0
- package/src/types/GetListingParams.ts +8 -0
- package/src/types/LatLng.ts +4 -0
- package/src/types/ListingEntity.ts +11 -0
- package/src/types/ListingFields.ts +20 -0
- package/src/types/Listings.ts +32 -0
- package/src/types/Recruiter.ts +9 -0
- package/src/types/SimilarListing.ts +24 -0
- package/src/types/config/Colors.ts +8 -0
- package/src/types/config/MapConfig.ts +30 -0
- package/src/types/config/PointsOfInterestConfig.ts +13 -0
- package/src/types/config/SearchConfig.ts +4 -0
- package/src/util/filterUtil.js +50 -6
- package/src/util/localStorageUtil.ts +34 -0
- package/src/util/mapUtil.js +91 -91
- package/tsconfig.json +23 -0
- package/dist/components/modules/maps/list/field-mapper.js.map +0 -1
- package/dist/components/modules/maps/list/header-item.js.map +0 -1
- package/dist/components/modules/maps/list/header.js.map +0 -1
- package/dist/components/modules/maps/list/index.js +0 -102
- package/dist/components/modules/maps/list/index.js.map +0 -1
- package/dist/components/modules/maps/list/item-expand-card/index.js.map +0 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +0 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +0 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +0 -1
- package/dist/components/modules/maps/list/list-item/index.js.map +0 -1
- package/dist/services/_virtual/_rollupPluginBabelHelpers.js +0 -372
- package/dist/services/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/dist/services/apis/hcApi.js +0 -189
- package/dist/services/apis/hcApi.js.map +0 -1
- package/dist/services/clientToken.js +0 -7
- package/dist/services/clientToken.js.map +0 -1
- package/dist/services/styles/index.css +0 -3
- package/src/components/modules/maps/list/index.js +0 -112
- package/src/contexts/mapContext.js +0 -101
- package/src/contexts/mapListContext.js +0 -242
- package/src/services/listingAggregatorService.js +0 -50
- package/src/services/listingEntityService.js +0 -15
- package/src/services/listingService.js +0 -26
- package/src/util/localStorageUtil.js +0 -27
- /package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-headshot.js +0 -0
- /package/src/components/modules/{maps/list → list}/header-item.js +0 -0
- /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-contact-nav.js +0 -0
- /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-details.js +0 -0
- /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-headshot.js +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ListingFields = {
|
|
2
|
+
posted?: string;
|
|
3
|
+
subTitle?: string;
|
|
4
|
+
education?: string;
|
|
5
|
+
position?: string;
|
|
6
|
+
category?: string;
|
|
7
|
+
categoryClass?: string;
|
|
8
|
+
shift?: string;
|
|
9
|
+
cityState?: string;
|
|
10
|
+
city?: string;
|
|
11
|
+
state?: string;
|
|
12
|
+
schedule?: string;
|
|
13
|
+
customFlag1?: number;
|
|
14
|
+
bonus?: number;
|
|
15
|
+
remote?: number;
|
|
16
|
+
useClientJobUrl?: boolean;
|
|
17
|
+
dateCreated: Date;
|
|
18
|
+
dateLastEdited?: Date;
|
|
19
|
+
travelTime?: string;
|
|
20
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ListingFields } from './ListingFields';
|
|
2
|
+
import { Recruiter } from './Recruiter';
|
|
3
|
+
import { ListingEntity } from './ListingEntity';
|
|
4
|
+
import { ContentSection } from './ContentSection';
|
|
5
|
+
import { SimilarListing } from './SimilarListing';
|
|
6
|
+
export type Listing = {
|
|
7
|
+
id: number;
|
|
8
|
+
fields?: ListingFields;
|
|
9
|
+
entityId?: number;
|
|
10
|
+
applyUrl?: string;
|
|
11
|
+
applyOnline?: number;
|
|
12
|
+
detailsUrl?: string;
|
|
13
|
+
displayOnSite: number;
|
|
14
|
+
displayRecruiter: number;
|
|
15
|
+
recruiterId?: number;
|
|
16
|
+
description1?: string;
|
|
17
|
+
description2?: string;
|
|
18
|
+
description3?: string;
|
|
19
|
+
description4?: string;
|
|
20
|
+
custom1: string;
|
|
21
|
+
custom2: string;
|
|
22
|
+
custom3: string;
|
|
23
|
+
custom4: string;
|
|
24
|
+
custom5: string;
|
|
25
|
+
customFlag1: number;
|
|
26
|
+
slug?: string;
|
|
27
|
+
recruiter?: Recruiter;
|
|
28
|
+
entity?: ListingEntity;
|
|
29
|
+
contentSections?: ContentSection[];
|
|
30
|
+
similarListings?: SimilarListing[];
|
|
31
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type SimilarListing = {
|
|
2
|
+
id: number;
|
|
3
|
+
city: string;
|
|
4
|
+
companyName: string;
|
|
5
|
+
companyId: number;
|
|
6
|
+
domain: string;
|
|
7
|
+
refreshedPubDate?: Date;
|
|
8
|
+
clientJobUrl: string;
|
|
9
|
+
refreshNum: number;
|
|
10
|
+
requestURI: string;
|
|
11
|
+
schedule: string;
|
|
12
|
+
scheduleId?: number;
|
|
13
|
+
shift: string;
|
|
14
|
+
sponsored: boolean;
|
|
15
|
+
stateAbbrev: string;
|
|
16
|
+
subTitle: string;
|
|
17
|
+
title: string;
|
|
18
|
+
uniqueId: string;
|
|
19
|
+
zip: string;
|
|
20
|
+
slug?: string;
|
|
21
|
+
dateCreated: Date;
|
|
22
|
+
categoryId: number;
|
|
23
|
+
categoryClassId: number;
|
|
24
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Colors } from "./Colors";
|
|
2
|
+
import { PointsOfInterestConfig } from "./PointsOfInterestConfig";
|
|
3
|
+
import { SearchConfig } from "./SearchConfig";
|
|
4
|
+
export type MapConfig = {
|
|
5
|
+
title: string;
|
|
6
|
+
titleShort: string;
|
|
7
|
+
description: string;
|
|
8
|
+
jobsDomain: string;
|
|
9
|
+
useDetailsPostMessage: boolean;
|
|
10
|
+
author: string;
|
|
11
|
+
url: string;
|
|
12
|
+
logo: string;
|
|
13
|
+
companyName: string;
|
|
14
|
+
shareImage: string;
|
|
15
|
+
clientAuthKey: string;
|
|
16
|
+
colors: Colors;
|
|
17
|
+
hideLocations: boolean;
|
|
18
|
+
fieldsShown: string[];
|
|
19
|
+
fieldFiltersShown: string[];
|
|
20
|
+
locationFiltersShown: string[];
|
|
21
|
+
fieldNames: Record<string, string>;
|
|
22
|
+
specialFeatures: Record<string, string>;
|
|
23
|
+
searchConfig: SearchConfig;
|
|
24
|
+
internalApplyLink: string;
|
|
25
|
+
useApplyDialog: boolean;
|
|
26
|
+
pointsOfInterestConfig: PointsOfInterestConfig;
|
|
27
|
+
showMap: boolean;
|
|
28
|
+
companyId: string;
|
|
29
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type PointsOfInterestConfig = {
|
|
2
|
+
title: string;
|
|
3
|
+
pointsOfInterestNames: Record<string, string>;
|
|
4
|
+
pointsOfInterestIcons: Record<string, string>;
|
|
5
|
+
placeMarkerColors: {
|
|
6
|
+
innerFillColor: string;
|
|
7
|
+
innerStrokeColor: string;
|
|
8
|
+
outerFillColor: string;
|
|
9
|
+
outerStrokeColor: string;
|
|
10
|
+
};
|
|
11
|
+
placeMarkerSize: number;
|
|
12
|
+
placeMappings: Record<string, string[]>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function getFilterOptions(listings: any, filteredListings: any, field: any, excludeZeroCount?: null): {
|
|
2
|
+
name: any;
|
|
3
|
+
count: any;
|
|
4
|
+
}[];
|
|
5
|
+
export function getSpecialFeatureOptions(listings: any, filteredListings: any, siteConfig: any, favorites: any): {
|
|
6
|
+
name: string;
|
|
7
|
+
count: any;
|
|
8
|
+
}[];
|
|
9
|
+
export function generateFilterOptions(filteredListings: any, allListings: any, siteConfig: any, filterOptions: any, parentField: any, favorites: any): {
|
|
10
|
+
filters: any;
|
|
11
|
+
locations: any;
|
|
12
|
+
pointsOfInterest: {
|
|
13
|
+
id: string;
|
|
14
|
+
title: any;
|
|
15
|
+
items: {
|
|
16
|
+
key: string;
|
|
17
|
+
name: any;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
} | null;
|
|
21
|
+
export function applyFilters(allListings: any, selectedFilters: any, query: any, listingEntities: any, favorites: any, siteConfig: any): {
|
|
22
|
+
filteredListings: any;
|
|
23
|
+
mapItems: any[];
|
|
24
|
+
};
|
|
25
|
+
export function filterListingsByLocation(allListings: any, selectedLocation: any, listingEntities: any): {
|
|
26
|
+
filteredListings: any;
|
|
27
|
+
mapItems: any[];
|
|
28
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function getDistinctItemsByProximity(items: any, listingEntitiesDetails: any): any[];
|
|
2
|
+
export function findCloseItems(itemsObj: any): {
|
|
3
|
+
item1: any;
|
|
4
|
+
item2: any;
|
|
5
|
+
}[];
|
|
6
|
+
export function adjustItemPositions(itemsObj: any, closeItemPairs: any): any;
|
|
7
|
+
export function clusterOptions(clusterGridSize: any, fillColor: any): {
|
|
8
|
+
gridSize: any;
|
|
9
|
+
styles: {
|
|
10
|
+
url: string;
|
|
11
|
+
textColor: string;
|
|
12
|
+
height: number;
|
|
13
|
+
width: number;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function dynamicSort(items: any, fieldName: any, order?: string): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function capitalize(str: any): any;
|
package/dist/util/filterUtil.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray, createForOfIteratorHelper as _createForOfIteratorHelper } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
1
|
+
import { slicedToArray as _slicedToArray, defineProperty as _defineProperty, createForOfIteratorHelper as _createForOfIteratorHelper } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { getDistinctItemsByProximity } from './mapUtil.js';
|
|
3
|
+
import Fuse from 'fuse.js';
|
|
3
4
|
|
|
4
5
|
var getFilterOptions = function getFilterOptions(listings, filteredListings, field) {
|
|
5
6
|
var excludeZeroCount = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
@@ -82,9 +83,7 @@ var getPointsOfInterestOptions = function getPointsOfInterestOptions(pointsOfInt
|
|
|
82
83
|
};
|
|
83
84
|
});
|
|
84
85
|
};
|
|
85
|
-
var generateFilterOptions = function generateFilterOptions(filteredListings, allListings, siteConfig, filterOptions) {
|
|
86
|
-
var parentField = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
87
|
-
var favorites = arguments.length > 5 ? arguments[5] : undefined;
|
|
86
|
+
var generateFilterOptions = function generateFilterOptions(filteredListings, allListings, siteConfig, filterOptions, parentField, favorites) {
|
|
88
87
|
if (allListings.length > 0) {
|
|
89
88
|
var dynamicFilters = siteConfig.fieldFiltersShown.map(function (fieldName) {
|
|
90
89
|
if (fieldName === parentField && filterOptions !== null && filterOptions !== void 0 && filterOptions.filters) {
|
|
@@ -179,12 +178,7 @@ var applyFilters = function applyFilters(allListings, selectedFilters, query, li
|
|
|
179
178
|
if (_loop()) continue;
|
|
180
179
|
}
|
|
181
180
|
if (query) {
|
|
182
|
-
results = results
|
|
183
|
-
var _Object$values;
|
|
184
|
-
return (_Object$values = Object.values(listing.fields)) === null || _Object$values === void 0 ? void 0 : _Object$values.some(function (value) {
|
|
185
|
-
return value === null || value === void 0 ? void 0 : value.toString().toLowerCase().includes(query.toLowerCase());
|
|
186
|
-
});
|
|
187
|
-
});
|
|
181
|
+
results = searchResults(results, query);
|
|
188
182
|
}
|
|
189
183
|
var distinctItems = getDistinctItemsByProximity(results, listingEntities);
|
|
190
184
|
if (hasFavorite) {
|
|
@@ -195,6 +189,36 @@ var applyFilters = function applyFilters(allListings, selectedFilters, query, li
|
|
|
195
189
|
mapItems: distinctItems
|
|
196
190
|
};
|
|
197
191
|
};
|
|
192
|
+
function searchResults(results, query) {
|
|
193
|
+
var fields = ['id', 'fields.posted', 'fields.subtitle', 'fields.education', 'fields.position', 'fields.category', 'fields.categoryclass', 'fields.shift', 'fields.citystate', 'fields.city', 'fields.state', 'fields.schedule', 'fields.customflag1', 'fields.bonus', 'fields.remote', 'fields.useclientjoburl', 'fields.datecreated', 'fields.datelastedited'];
|
|
194
|
+
var options = {
|
|
195
|
+
includeScore: true,
|
|
196
|
+
threshold: 0.3,
|
|
197
|
+
keys: fields
|
|
198
|
+
};
|
|
199
|
+
var fuse = new Fuse(results, options);
|
|
200
|
+
var lowerCaseQuery = query.toLowerCase();
|
|
201
|
+
var queryTerms = lowerCaseQuery.split(' ');
|
|
202
|
+
var exactIdMatch = results.find(function (result) {
|
|
203
|
+
return result.id.toString() === query;
|
|
204
|
+
});
|
|
205
|
+
if (exactIdMatch) {
|
|
206
|
+
return [exactIdMatch];
|
|
207
|
+
}
|
|
208
|
+
var fuseQuery = queryTerms.map(function (term) {
|
|
209
|
+
return {
|
|
210
|
+
$or: fields.map(function (field) {
|
|
211
|
+
return _defineProperty({}, field, term);
|
|
212
|
+
})
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
var fuseResults = fuse.search({
|
|
216
|
+
$and: fuseQuery
|
|
217
|
+
});
|
|
218
|
+
return fuseResults.map(function (result) {
|
|
219
|
+
return result.item;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
198
222
|
var filterListingsByLocation = function filterListingsByLocation(allListings, selectedLocation, listingEntities) {
|
|
199
223
|
var results = allListings;
|
|
200
224
|
if (selectedLocation !== null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterUtil.js","sources":["../../src/util/filterUtil.js"],"sourcesContent":["import { getDistinctItemsByProximity } from '~/util/mapUtil';\r\n\r\nexport const getFilterOptions = (listings, filteredListings, field, excludeZeroCount = null) => {\r\n\tconst options = new Set();\r\n\tlistings.forEach(listing => {\r\n\t\tif (listing.fields[field]) {\r\n\t\t\toptions.add(listing.fields[field]);\r\n\t\t}\r\n\t});\r\n\r\n\tconst optionCounts = {};\r\n\toptions.forEach(option => {\r\n\t\toptionCounts[option] = 0;\r\n\t});\r\n\r\n\tfilteredListings.forEach(listing => {\r\n\t\tconst value = listing.fields[field];\r\n\t\tif (value && optionCounts.hasOwnProperty(value)) {\r\n\t\t\toptionCounts[value] += 1;\r\n\t\t}\r\n\t});\r\n\r\n\treturn Array.from(options)\r\n\t\t.sort()\r\n\t\t.map(option => ({\r\n\t\t\tname: option,\r\n\t\t\tcount: optionCounts[option] || 0\r\n\t\t}))\r\n\t\t.filter(option => !(excludeZeroCount === true && option.count === 0));\r\n};\r\n\r\nexport const getSpecialFeatureOptions = (listings, filteredListings, siteConfig, favorites) => {\r\n\tconst specialFeatures = siteConfig.specialFeatures;\r\n\tconst featureCounts = Object.keys(specialFeatures).sort().reduce((acc, key) => {\r\n\t\tacc[specialFeatures[key]] = 0;\r\n\t\treturn acc;\r\n\t}, {});\r\n\r\n\tfilteredListings.forEach(listing => {\r\n\t\tObject.entries(specialFeatures).forEach(([featureKey, featureName]) => {\r\n\t\t\tif (listing.fields[featureKey] === 1) {\r\n\t\t\t\tfeatureCounts[featureName] += 1;\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n\r\n\tconst specialFeatureOptions = Object.entries(featureCounts).map(([name, count]) => ({\r\n\t\tname,\r\n\t\tcount\r\n\t}));\r\n\r\n\tfor (let option of specialFeatureOptions) {\r\n\t\tif (option.name === 'Favorite') {\r\n\t\t\toption.count = filteredListings.filter(x => favorites.includes(x.id)).length;\r\n\t\t}\r\n\t}\r\n\r\n\treturn specialFeatureOptions;\r\n};\r\n\r\nconst getPointsOfInterestOptions = pointsOfInterestNames => {\r\n\treturn Object.entries(pointsOfInterestNames).sort().map(([key, name]) => ({\r\n\t\tkey,\r\n\t\tname\r\n\t}));\r\n};\r\n\r\nexport const generateFilterOptions = (\r\n\tfilteredListings,\r\n\tallListings,\r\n\tsiteConfig,\r\n\tfilterOptions,\r\n\tparentField = null,\r\n\tfavorites\r\n) => {\r\n\tif (allListings.length > 0) {\r\n\t\tconst dynamicFilters = siteConfig.fieldFiltersShown.map(fieldName => {\r\n\t\t\tif (fieldName === parentField && filterOptions?.filters) {\r\n\t\t\t\treturn filterOptions.filters.find(filter => filter.id === fieldName);\r\n\t\t\t}\r\n\t\t\tif (fieldName == \"specialFeatures\") {\r\n\t\t\t\treturn {\r\n\t\t\t\t\tid: fieldName,\r\n\t\t\t\t\ttitle: siteConfig.fieldNames[fieldName],\r\n\t\t\t\t\titems: getSpecialFeatureOptions(allListings, filteredListings, siteConfig, favorites).sort()\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t\treturn {\r\n\t\t\t\tid: fieldName,\r\n\t\t\t\ttitle: siteConfig.fieldNames[fieldName],\r\n\t\t\t\titems: getFilterOptions(allListings, filteredListings, fieldName)\r\n\t\t\t};\r\n\t\t});\r\n\r\n\t\tconst locations =\r\n\t\t\tsiteConfig.locationFiltersShown.map((fieldName, index) => {\r\n\t\t\t\tif (index === 0 && filterOptions?.locations) {\r\n\t\t\t\t\treturn filterOptions.locations.find(filter => filter.id === fieldName);\r\n\t\t\t\t}\r\n\t\t\t\treturn {\r\n\t\t\t\t\tid: fieldName,\r\n\t\t\t\t\ttitle: siteConfig.fieldNames[fieldName],\r\n\t\t\t\t\titems: getFilterOptions(allListings, filteredListings, fieldName, true)\r\n\t\t\t\t};\r\n\t\t\t});\r\n\r\n\t\tconst pointsOfInterest = {\r\n\t\t\tid: \"pointsOfInterest\",\r\n\t\t\ttitle: siteConfig.pointsOfInterestConfig.title,\r\n\t\t\titems: getPointsOfInterestOptions(\r\n\t\t\t\tsiteConfig.pointsOfInterestConfig.pointsOfInterestNames\r\n\t\t\t)\r\n\t\t};\r\n\r\n\t\treturn {\r\n\t\t\tfilters: dynamicFilters,\r\n\t\t\tlocations: locations,\r\n\t\t\tpointsOfInterest: pointsOfInterest\r\n\t\t};\r\n\t}\r\n\r\n\treturn null;\r\n};\r\n\r\nexport const applyFilters = (\r\n\tallListings,\r\n\tselectedFilters,\r\n\tquery,\r\n\tlistingEntities,\r\n\tfavorites,\r\n\tsiteConfig\r\n) => {\r\n\tlet results = allListings;\r\n\tlet invertedSpecialFeaturesMap;\r\n\tif (siteConfig.specialFeatures) {\r\n\t\tinvertedSpecialFeaturesMap = Object.entries(siteConfig.specialFeatures).reduce((acc, [key, value]) => {\r\n\t\t\tacc[value] = key;\r\n\t\t\treturn acc;\r\n\t\t}, {});\r\n\r\n\t}\r\n\tconst hasFavorite = !!selectedFilters.specialFeatures && !!selectedFilters.specialFeatures.Favorite;\r\n\r\n\tif (hasFavorite && selectedFilters.specialFeatures.Favorite == true) {\r\n\t\tresults = results.filter(x => favorites.includes(x.id));\r\n\t}\r\n\tvar favorite;\r\n\tif (hasFavorite) {\r\n\t\tfavorite = selectedFilters.specialFeatures.Favorite;\r\n\t\tdelete selectedFilters.specialFeatures.Favorite;\r\n\t}\r\n\tfor (const [field, filterItems] of Object.entries(selectedFilters)) {\r\n\t\tconst formattedField = field;\r\n\t\tif (field === \"pointsOfInterest\") continue;\r\n\t\tif (field === \"specialFeatures\" && invertedSpecialFeaturesMap && Object.keys(filterItems).length > 0) {\r\n\t\t\tresults = results.filter(listing => {\r\n\t\t\t\treturn Object.entries(filterItems).some(([filterName, filterValue]) => {\r\n\t\t\t\t\tconst listingFieldName = invertedSpecialFeaturesMap[filterName];\r\n\t\t\t\t\treturn filterValue && listing.fields[listingFieldName] === 1;\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t} else if (Object.keys(filterItems).length > 0) {\r\n\t\t\tresults = results.filter(listing =>\r\n\t\t\t\tfilterItems.hasOwnProperty(listing.fields[formattedField])\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tif (query) {\r\n\t\tresults = results.filter(listing =>\r\n\t\t\tObject.values(listing.fields)?.some(value =>\r\n\t\t\t\tvalue?.toString().toLowerCase().includes(query.toLowerCase())\r\n\t\t\t)\r\n\t\t);\r\n\t}\r\n\tconst distinctItems = getDistinctItemsByProximity(results, listingEntities);\r\n\tif (hasFavorite) {\r\n\t\tselectedFilters.specialFeatures.Favorite = favorite;\r\n\t}\r\n\treturn { filteredListings: results, mapItems: distinctItems };\r\n};\r\n\r\nexport const filterListingsByLocation = (\r\n\tallListings,\r\n\tselectedLocation,\r\n\tlistingEntities\r\n) => {\r\n\tlet results = allListings;\r\n\tif (selectedLocation !== null) {\r\n\t\tresults = results.filter(item =>\r\n\t\t\tselectedLocation.items.hasOwnProperty(item.id)\r\n\t\t);\r\n\t}\r\n\tconst mapItems = getDistinctItemsByProximity(results, listingEntities);\r\n\treturn { filteredListings: results, mapItems: mapItems };\r\n};\r\n"],"names":["getFilterOptions","listings","filteredListings","field","excludeZeroCount","arguments","length","undefined","options","Set","forEach","listing","fields","add","optionCounts","option","value","hasOwnProperty","Array","from","sort","map","name","count","filter","getSpecialFeatureOptions","siteConfig","favorites","specialFeatures","featureCounts","Object","keys","reduce","acc","key","entries","_ref","_ref2","_slicedToArray","featureKey","featureName","specialFeatureOptions","_ref3","_ref4","_iterator","_createForOfIteratorHelper","_step","s","n","done","x","includes","id","err","e","f","getPointsOfInterestOptions","pointsOfInterestNames","_ref5","_ref6","generateFilterOptions","allListings","filterOptions","parentField","dynamicFilters","fieldFiltersShown","fieldName","filters","find","title","fieldNames","items","locations","locationFiltersShown","index","pointsOfInterest","pointsOfInterestConfig","applyFilters","selectedFilters","query","listingEntities","results","invertedSpecialFeaturesMap","_ref7","_ref8","hasFavorite","Favorite","favorite","_loop","_Object$entries$_i","_Object$entries","_i","filterItems","formattedField","some","_ref9","_ref10","filterName","filterValue","listingFieldName","_Object$values","values","toString","toLowerCase","distinctItems","getDistinctItemsByProximity","mapItems","filterListingsByLocation","selectedLocation","item"],"mappings":";;;AAEO,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,QAAQ,EAAEC,gBAAgB,EAAEC,KAAK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A2B,CAACxB,OAAO,EAAED,eAAe,CAAC,CAAA;AAC3E,EAAA,IAAIK,WAAW,EAAE;AAChBP,IAAAA,eAAe,CAAClD,eAAe,CAAC0D,QAAQ,GAAGC,QAAQ,CAAA;AACpD,GAAA;EACA,OAAO;AAAErF,IAAAA,gBAAgB,EAAE+E,OAAO;AAAEyB,IAAAA,QAAQ,EAAEF,aAAAA;GAAe,CAAA;AAC9D,EAAC;AAEM,IAAMG,wBAAwB,GAAG,SAA3BA,wBAAwBA,CACpC9C,WAAW,EACX+C,gBAAgB,EAChB5B,eAAe,EACX;EACJ,IAAIC,OAAO,GAAGpB,WAAW,CAAA;EACzB,IAAI+C,gBAAgB,KAAK,IAAI,EAAE;AAC9B3B,IAAAA,OAAO,GAAGA,OAAO,CAACzD,MAAM,CAAC,UAAAqF,IAAI,EAAA;MAAA,OAC5BD,gBAAgB,CAACrC,KAAK,CAACtD,cAAc,CAAC4F,IAAI,CAACzD,EAAE,CAAC,CAAA;AAAA,KAC/C,CAAC,CAAA;AACF,GAAA;AACA,EAAA,IAAMsD,QAAQ,GAAGD,2BAA2B,CAACxB,OAAO,EAAED,eAAe,CAAC,CAAA;EACtE,OAAO;AAAE9E,IAAAA,gBAAgB,EAAE+E,OAAO;AAAEyB,IAAAA,QAAQ,EAAEA,QAAAA;GAAU,CAAA;AACzD;;;;"}
|
|
1
|
+
{"version":3,"file":"filterUtil.js","sources":["../../src/util/filterUtil.js"],"sourcesContent":["import { getDistinctItemsByProximity } from '~/util/mapUtil';\r\n\r\nimport Fuse from 'fuse.js';\r\n\r\nexport const getFilterOptions = (listings, filteredListings, field, excludeZeroCount = null) => {\r\n\tconst options = new Set();\r\n\tlistings.forEach(listing => {\r\n\t\tif (listing.fields[field]) {\r\n\t\t\toptions.add(listing.fields[field]);\r\n\t\t}\r\n\t});\r\n\r\n\tconst optionCounts = {};\r\n\toptions.forEach(option => {\r\n\t\toptionCounts[option] = 0;\r\n\t});\r\n\r\n\tfilteredListings.forEach(listing => {\r\n\t\tconst value = listing.fields[field];\r\n\t\tif (value && optionCounts.hasOwnProperty(value)) {\r\n\t\t\toptionCounts[value] += 1;\r\n\t\t}\r\n\t});\r\n\r\n\treturn Array.from(options)\r\n\t\t.sort()\r\n\t\t.map(option => ({\r\n\t\t\tname: option,\r\n\t\t\tcount: optionCounts[option] || 0\r\n\t\t}))\r\n\t\t.filter(option => !(excludeZeroCount === true && option.count === 0));\r\n};\r\n\r\nexport const getSpecialFeatureOptions = (listings, filteredListings, siteConfig, favorites) => {\r\n\tconst specialFeatures = siteConfig.specialFeatures;\r\n\tconst featureCounts = Object.keys(specialFeatures).sort().reduce((acc, key) => {\r\n\t\tacc[specialFeatures[key]] = 0;\r\n\t\treturn acc;\r\n\t}, {});\r\n\r\n\tfilteredListings.forEach(listing => {\r\n\t\tObject.entries(specialFeatures).forEach(([featureKey, featureName]) => {\r\n\t\t\tif (listing.fields[featureKey] === 1) {\r\n\t\t\t\tfeatureCounts[featureName] += 1;\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n\r\n\tconst specialFeatureOptions = Object.entries(featureCounts).map(([name, count]) => ({\r\n\t\tname,\r\n\t\tcount\r\n\t}));\r\n\r\n\tfor (let option of specialFeatureOptions) {\r\n\t\tif (option.name === 'Favorite') {\r\n\t\t\toption.count = filteredListings.filter(x => favorites.includes(x.id)).length;\r\n\t\t}\r\n\t}\r\n\r\n\treturn specialFeatureOptions;\r\n};\r\n\r\nconst getPointsOfInterestOptions = pointsOfInterestNames => {\r\n\treturn Object.entries(pointsOfInterestNames).sort().map(([key, name]) => ({\r\n\t\tkey,\r\n\t\tname\r\n\t}));\r\n};\r\n\r\nexport const generateFilterOptions = (\r\n\tfilteredListings,\r\n\tallListings,\r\n\tsiteConfig,\r\n\tfilterOptions,\r\n\tparentField,\r\n\tfavorites\r\n) => {\r\n\tif (allListings.length > 0) {\r\n\t\tconst dynamicFilters = siteConfig.fieldFiltersShown.map(fieldName => {\r\n\t\t\tif (fieldName === parentField && filterOptions?.filters) {\r\n\t\t\t\treturn filterOptions.filters.find(filter => filter.id === fieldName);\r\n\t\t\t}\r\n\t\t\tif (fieldName == \"specialFeatures\") {\r\n\t\t\t\treturn {\r\n\t\t\t\t\tid: fieldName,\r\n\t\t\t\t\ttitle: siteConfig.fieldNames[fieldName],\r\n\t\t\t\t\titems: getSpecialFeatureOptions(allListings, filteredListings, siteConfig, favorites).sort()\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t\treturn {\r\n\t\t\t\tid: fieldName,\r\n\t\t\t\ttitle: siteConfig.fieldNames[fieldName],\r\n\t\t\t\titems: getFilterOptions(allListings, filteredListings, fieldName)\r\n\t\t\t};\r\n\t\t});\r\n\r\n\t\tconst locations =\r\n\t\t\tsiteConfig.locationFiltersShown.map((fieldName, index) => {\r\n\t\t\t\tif (index === 0 && filterOptions?.locations) {\r\n\t\t\t\t\treturn filterOptions.locations.find(filter => filter.id === fieldName);\r\n\t\t\t\t}\r\n\t\t\t\treturn {\r\n\t\t\t\t\tid: fieldName,\r\n\t\t\t\t\ttitle: siteConfig.fieldNames[fieldName],\r\n\t\t\t\t\titems: getFilterOptions(allListings, filteredListings, fieldName, true)\r\n\t\t\t\t};\r\n\t\t\t});\r\n\r\n\t\tconst pointsOfInterest = {\r\n\t\t\tid: \"pointsOfInterest\",\r\n\t\t\ttitle: siteConfig.pointsOfInterestConfig.title,\r\n\t\t\titems: getPointsOfInterestOptions(\r\n\t\t\t\tsiteConfig.pointsOfInterestConfig.pointsOfInterestNames\r\n\t\t\t)\r\n\t\t};\r\n\r\n\t\treturn {\r\n\t\t\tfilters: dynamicFilters,\r\n\t\t\tlocations: locations,\r\n\t\t\tpointsOfInterest: pointsOfInterest\r\n\t\t};\r\n\t}\r\n\r\n\treturn null;\r\n};\r\n\r\nexport const applyFilters = (\r\n\tallListings,\r\n\tselectedFilters,\r\n\tquery,\r\n\tlistingEntities,\r\n\tfavorites,\r\n\tsiteConfig\r\n) => {\r\n\tlet results = allListings;\r\n\tlet invertedSpecialFeaturesMap;\r\n\tif (siteConfig.specialFeatures) {\r\n\t\tinvertedSpecialFeaturesMap = Object.entries(siteConfig.specialFeatures).reduce((acc, [key, value]) => {\r\n\t\t\tacc[value] = key;\r\n\t\t\treturn acc;\r\n\t\t}, {});\r\n\r\n\t}\r\n\tconst hasFavorite = !!selectedFilters.specialFeatures && !!selectedFilters.specialFeatures.Favorite;\r\n\r\n\tif (hasFavorite && selectedFilters.specialFeatures.Favorite == true) {\r\n\t\tresults = results.filter(x => favorites.includes(x.id));\r\n\t}\r\n\tvar favorite;\r\n\tif (hasFavorite) {\r\n\t\tfavorite = selectedFilters.specialFeatures.Favorite;\r\n\t\tdelete selectedFilters.specialFeatures.Favorite;\r\n\t}\r\n\tfor (const [field, filterItems] of Object.entries(selectedFilters)) {\r\n\t\tconst formattedField = field;\r\n\t\tif (field === \"pointsOfInterest\") continue;\r\n\t\tif (field === \"specialFeatures\" && invertedSpecialFeaturesMap && Object.keys(filterItems).length > 0) {\r\n\t\t\tresults = results.filter(listing => {\r\n\t\t\t\treturn Object.entries(filterItems).some(([filterName, filterValue]) => {\r\n\t\t\t\t\tconst listingFieldName = invertedSpecialFeaturesMap[filterName];\r\n\t\t\t\t\treturn filterValue && listing.fields[listingFieldName] === 1;\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t} else if (Object.keys(filterItems).length > 0) {\r\n\t\t\tresults = results.filter(listing =>\r\n\t\t\t\tfilterItems.hasOwnProperty(listing.fields[formattedField])\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tif (query) {\r\n\t\tresults = searchResults(results, query);\r\n\t}\r\n\tconst distinctItems = getDistinctItemsByProximity(results, listingEntities);\r\n\tif (hasFavorite) {\r\n\t\tselectedFilters.specialFeatures.Favorite = favorite;\r\n\t}\r\n\treturn { filteredListings: results, mapItems: distinctItems };\r\n};\r\n\r\nfunction searchResults(results, query) {\r\n\tconst fields = [\r\n\t\t'id',\r\n\t\t'fields.posted',\r\n\t\t'fields.subtitle',\r\n\t\t'fields.education',\r\n\t\t'fields.position',\r\n\t\t'fields.category',\r\n\t\t'fields.categoryclass',\r\n\t\t'fields.shift',\r\n\t\t'fields.citystate',\r\n\t\t'fields.city',\r\n\t\t'fields.state',\r\n\t\t'fields.schedule',\r\n\t\t'fields.customflag1',\r\n\t\t'fields.bonus',\r\n\t\t'fields.remote',\r\n\t\t'fields.useclientjoburl',\r\n\t\t'fields.datecreated',\r\n\t\t'fields.datelastedited'\r\n\t];\r\n\r\n\tconst options = {\r\n\t\tincludeScore: true,\r\n\t\tthreshold: 0.3,\r\n\t\tkeys: fields\r\n\t};\r\n\r\n\tconst fuse = new Fuse(results, options);\r\n\tconst lowerCaseQuery = query.toLowerCase();\r\n\tconst queryTerms = lowerCaseQuery.split(' ');\r\n\r\n\tconst exactIdMatch = results.find(result => result.id.toString() === query);\r\n\tif (exactIdMatch) {\r\n\t\treturn [exactIdMatch];\r\n\t}\r\n\r\n\tconst fuseQuery = queryTerms.map(term => ({\r\n\t\t$or: fields.map(field => ({ [field]: term }))\r\n\t}));\r\n\r\n\tconst fuseResults = fuse.search({ $and: fuseQuery });\r\n\r\n\treturn fuseResults.map(result => result.item);\r\n}\r\n\r\nexport const filterListingsByLocation = (\r\n\tallListings,\r\n\tselectedLocation,\r\n\tlistingEntities\r\n) => {\r\n\tlet results = allListings;\r\n\tif (selectedLocation !== null) {\r\n\t\tresults = results.filter(item =>\r\n\t\t\tselectedLocation.items.hasOwnProperty(item.id)\r\n\t\t);\r\n\t}\r\n\tconst mapItems = getDistinctItemsByProximity(results, listingEntities);\r\n\treturn { filteredListings: results, mapItems: mapItems };\r\n};\r\n"],"names":["getFilterOptions","listings","filteredListings","field","excludeZeroCount","arguments","length","undefined","options","Set","forEach","listing","fields","add","optionCounts","option","value","hasOwnProperty","Array","from","sort","map","name","count","filter","getSpecialFeatureOptions","siteConfig","favorites","specialFeatures","featureCounts","Object","keys","reduce","acc","key","entries","_ref","_ref2","_slicedToArray","featureKey","featureName","specialFeatureOptions","_ref3","_ref4","_iterator","_createForOfIteratorHelper","_step","s","n","done","x","includes","id","err","e","f","getPointsOfInterestOptions","pointsOfInterestNames","_ref5","_ref6","generateFilterOptions","allListings","filterOptions","parentField","dynamicFilters","fieldFiltersShown","fieldName","filters","find","title","fieldNames","items","locations","locationFiltersShown","index","pointsOfInterest","pointsOfInterestConfig","applyFilters","selectedFilters","query","listingEntities","results","invertedSpecialFeaturesMap","_ref7","_ref8","hasFavorite","Favorite","favorite","_loop","_Object$entries$_i","_Object$entries","_i","filterItems","formattedField","some","_ref9","_ref10","filterName","filterValue","listingFieldName","searchResults","distinctItems","getDistinctItemsByProximity","mapItems","includeScore","threshold","fuse","Fuse","lowerCaseQuery","toLowerCase","queryTerms","split","exactIdMatch","result","toString","fuseQuery","term","$or","_defineProperty","fuseResults","search","$and","item","filterListingsByLocation","selectedLocation"],"mappings":";;;;AAIO,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,QAAQ,EAAEC,gBAAgB,EAAEC,KAAK,EAA8B;AAAA,EAAA,IAA5BC,gBAAgB,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,IAAI,CAAA;AAC1F,EAAA,IAAMG,OAAO,GAAG,IAAIC,GAAG,EAAE,CAAA;AACzBR,EAAAA,QAAQ,CAACS,OAAO,CAAC,UAAAC,OAAO,EAAI;AAC3B,IAAA,IAAIA,OAAO,CAACC,MAAM,CAACT,KAAK,CAAC,EAAE;MAC1BK,OAAO,CAACK,GAAG,CAACF,OAAO,CAACC,MAAM,CAACT,KAAK,CAAC,CAAC,CAAA;AACnC,KAAA;AACD,GAAC,CAAC,CAAA;EAEF,IAAMW,YAAY,GAAG,EAAE,CAAA;AACvBN,EAAAA,OAAO,CAACE,OAAO,CAAC,UAAAK,MAAM,EAAI;AACzBD,IAAAA,YAAY,CAACC,M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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
const getStorageObject = (item, defaultItem = null) => {
|
|
2
|
+
if (typeof window === 'undefined')
|
|
3
|
+
return defaultItem;
|
|
4
|
+
const storageItem = localStorage.getItem(item);
|
|
5
|
+
if (storageItem === null || storageItem === 'undefined') {
|
|
6
|
+
localStorage.removeItem(item);
|
|
7
|
+
return defaultItem;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(storageItem) ?? defaultItem;
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
console.error(`Error parsing JSON for ${item}:`, error);
|
|
14
|
+
return defaultItem;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const getStorageItem = (item, defaultItem = null) => {
|
|
18
|
+
if (typeof window === 'undefined')
|
|
19
|
+
return defaultItem;
|
|
20
|
+
const storageItem = localStorage.getItem(item);
|
|
21
|
+
if (storageItem === null || storageItem === 'undefined') {
|
|
22
|
+
localStorage.removeItem(item);
|
|
23
|
+
return defaultItem;
|
|
24
|
+
}
|
|
25
|
+
return storageItem ?? defaultItem;
|
|
26
|
+
};
|
|
27
|
+
const setStorageObject = (key, item) => {
|
|
28
|
+
if (typeof window === 'undefined')
|
|
29
|
+
return;
|
|
30
|
+
if (item === undefined)
|
|
31
|
+
return;
|
|
32
|
+
try {
|
|
33
|
+
localStorage.setItem(key, JSON.stringify(item));
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
console.error(`Error setting item ${key} in localStorage:`, err);
|
|
37
|
+
}
|
|
29
38
|
};
|
|
30
39
|
|
|
31
40
|
export { getStorageItem, getStorageObject, setStorageObject };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localStorageUtil.js","sources":["../../src/util/localStorageUtil.
|
|
1
|
+
{"version":3,"file":"localStorageUtil.js","sources":["../../src/util/localStorageUtil.ts"],"sourcesContent":["export const getStorageObject = <T>(item: string, defaultItem: T | null = null): T | null => {\r\n\tif (typeof window === 'undefined') return defaultItem;\r\n\tconst storageItem = localStorage.getItem(item);\r\n\tif (storageItem === null || storageItem === 'undefined') {\r\n\t\tlocalStorage.removeItem(item);\r\n\t\treturn defaultItem;\r\n\t}\r\n\ttry {\r\n\t\treturn JSON.parse(storageItem) ?? defaultItem;\r\n\t} catch (error) {\r\n\t\tconsole.error(`Error parsing JSON for ${item}:`, error);\r\n\t\treturn defaultItem;\r\n\t}\r\n};\r\n\r\nexport const getStorageItem = (item: string, defaultItem: string | null = null): string | null => {\r\n\tif (typeof window === 'undefined') return defaultItem;\r\n\tconst storageItem = localStorage.getItem(item);\r\n\tif (storageItem === null || storageItem === 'undefined') {\r\n\t\tlocalStorage.removeItem(item);\r\n\t\treturn defaultItem;\r\n\t}\r\n\treturn storageItem ?? defaultItem;\r\n};\r\n\r\nexport const setStorageObject = (key: string, item: any): void => {\r\n\tif (typeof window === 'undefined') return;\r\n\tif (item === undefined) return;\r\n\ttry {\r\n\t\tlocalStorage.setItem(key, JSON.stringify(item));\r\n\t} catch (err) {\r\n\t\tconsole.error(`Error setting item ${key} in localStorage:`, err);\r\n\t}\r\n};\r\n"],"names":[],"mappings":"AAAa,MAAA,gBAAgB,GAAG,CAAI,IAAY,EAAE,WAAA,GAAwB,IAAI,KAAc;IAC3F,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,WAAW,CAAC;IACtD,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC/C,IAAA,IAAI,WAAW,KAAK,IAAI,IAAI,WAAW,KAAK,WAAW,EAAE;AACxD,QAAA,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC9B,QAAA,OAAO,WAAW,CAAC;AACnB,KAAA;IACD,IAAI;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC;AAC9C,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,CAAA,uBAAA,EAA0B,IAAI,CAAG,CAAA,CAAA,EAAE,KAAK,CAAC,CAAC;AACxD,QAAA,OAAO,WAAW,CAAC;AACnB,KAAA;AACF,EAAE;AAEW,MAAA,cAAc,GAAG,CAAC,IAAY,EAAE,WAAA,GAA6B,IAAI,KAAmB;IAChG,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,WAAW,CAAC;IACtD,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC/C,IAAA,IAAI,WAAW,KAAK,IAAI,IAAI,WAAW,KAAK,WAAW,EAAE;AACxD,QAAA,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC9B,QAAA,OAAO,WAAW,CAAC;AACnB,KAAA;IACD,OAAO,WAAW,IAAI,WAAW,CAAC;AACnC,EAAE;MAEW,gBAAgB,GAAG,CAAC,GAAW,EAAE,IAAS,KAAU;IAChE,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAC1C,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO;IAC/B,IAAI;AACH,QAAA,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAChD,KAAA;AAAC,IAAA,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,CAAA,mBAAA,EAAsB,GAAG,CAAmB,iBAAA,CAAA,EAAE,GAAG,CAAC,CAAC;AACjE,KAAA;AACF;;;;"}
|
package/dist/util/mapUtil.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapUtil.js","sources":["../../src/util/mapUtil.js"],"sourcesContent":["export const getDistinctItemsByProximity = (items, listingEntitiesDetails) => {\
|
|
1
|
+
{"version":3,"file":"mapUtil.js","sources":["../../src/util/mapUtil.js"],"sourcesContent":["export const getDistinctItemsByProximity = (items, listingEntitiesDetails) => {\n\tconst clusters = {};\n\n\tif (!listingEntitiesDetails) return [];\n\n\tconst closeItemPairs = findCloseItems(listingEntitiesDetails);\n\tif (closeItemPairs.length > 0) {\n\t\tlistingEntitiesDetails = adjustItemPositions(\n\t\t\tlistingEntitiesDetails,\n\t\t\tcloseItemPairs\n\t\t);\n\t}\n\n\titems?.forEach(item => {\n\t\tif(item.entityId !== -1){\n\n\t\t\tconst entityDetails = listingEntitiesDetails[item.entityId];\n\n\t\t\tif (!entityDetails) {\n\t\t\t\tconsole.error(`Details not found for entityId: ${item.entityId}`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\titem.mapDetails = entityDetails;\n\n\t\t\tif (!clusters[item.entityId]) {\n\t\t\t\tclusters[item.entityId] = {\n\t\t\t\t\t...item.mapDetails,\n\t\t\t\t\titems: { [item.id]: item }\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tclusters[item.entityId].items[item.id] = item;\n\t\t\t}}\n\t});\n\n\treturn Object.values(clusters);\n};\n\nexport const findCloseItems = itemsObj => {\n\tconst closeItems = [];\n\tconst items = Object.values(itemsObj); // Convert object to array for iteration\n\tconst proximityThreshold = 0.0001;\n\n\tfor (let i = 0; i < items.length; i++) {\n\t\tfor (let j = i + 1; j < items.length; j++) {\n\t\t\tconst distanceLat = Math.abs(items[i].latitude - items[j].latitude);\n\t\t\tconst distanceLng = Math.abs(items[i].longitude - items[j].longitude);\n\t\t\tif (\n\t\t\t\tdistanceLat < proximityThreshold &&\n\t\t\t\tdistanceLng < proximityThreshold\n\t\t\t) {\n\t\t\t\tcloseItems.push({ item1: items[i], item2: items[j] });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn closeItems;\n};\n\nexport const adjustItemPositions = (itemsObj, closeItemPairs) => {\n\tconst adjustmentValue = 0.0001;\n\tconst adjustedItems = { ...itemsObj }; // Create a shallow copy of the object\n\n\tcloseItemPairs.forEach(pair => {\n\t\tif (adjustedItems[pair.item1.id] && adjustedItems[pair.item2.id]) {\n\t\t\tadjustedItems[pair.item2.id].latitude += adjustmentValue;\n\t\t\tadjustedItems[pair.item2.id].longitude += adjustmentValue;\n\t\t}\n\t});\n\n\treturn adjustedItems;\n};\n\nexport const clusterOptions = (clusterGridSize, fillColor) => {\n\treturn {\n\t\tgridSize: clusterGridSize,\n\t\tstyles:[{\n\t\t\turl: createSvgDataUri(fillColor),\n\t\t\ttextColor:'white',\n\t\t\theight: 40,\n\t\t\twidth: 40\n\t\t}]\n\t};\n};\n\nfunction createSvgDataUri(fillColor) {\n\tconst svg = `<svg width=\"50\" height=\"50\" xmlns=\"http://www.w3.org/2000/svg\">\n\t <circle cx=\"25\" cy=\"25\" r=\"20\" fill=\"${fillColor}\" />\n\t</svg>`;\n\treturn `data:image/svg+xml;base64,${btoa(svg)}`;\n}\n"],"names":["getDistinctItemsByProximity","items","listingEntitiesDetails","clusters","closeItemPairs","findCloseItems","length","adjustItemPositions","forEach","item","entityId","entityDetails","console","error","concat","mapDetails","_objectSpread","_defineProperty","id","Object","values","itemsObj","closeItems","proximityThreshold","i","j","distanceLat","Math","abs","latitude","distanceLng","longitude","push","item1","item2","adjustmentValue","adjustedItems","pair","clusterOptions","clusterGridSize","fillColor","gridSize","styles","url","createSvgDataUri","textColor","height","width","svg","btoa"],"mappings":";;AAAO,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA2BA,CAAIC,KAAK,EAAEC,sBAAsB,EAAK;EAC7E,IAAMC,QAAQ,GAAG,EAAE,CAAA;AAEnB,EAAA,IAAI,CAACD,sBAAsB,EAAE,OAAO,EAAE,CAAA;AAEtC,EAAA,IAAME,cAAc,GAAGC,cAAc,CAACH,sBAAsB,CAAC,CAAA;AAC7D,EAAA,IAAIE,cAAc,CAACE,MAAM,GAAG,CAAC,EAAE;AAC9BJ,IAAAA,sBAAs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