@abcagency/hc-ui-components 1.8.6 → 1.8.8

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.
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import useListLogic from '../../../hooks/useList.js';
3
3
  import { useMap } from '../../../contexts/mapContext.js';
4
4
  import { useMapList } from '../../../contexts/mapListContext.js';
@@ -15,22 +15,27 @@ const ItemsListContainer = ({ fieldNames, showMap, fieldsShown, specialFeatures
15
15
  const { selectedListItem } = useMap();
16
16
  const { trackEvent, eventTypes } = useTrackEvent();
17
17
  const itemExpandedContent = (item, recruiter) => item ? (ExpandListComponent ? React.createElement(ExpandListComponent, { listing: item }) : React.createElement(ListingDetailsContainer, { item: item, recruiter: recruiter })) : null;
18
- if (!fieldsShown.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {
19
- fieldsShown.push('travelTime');
20
- fieldNames['travelTime'] = 'Commute';
21
- }
22
- else if (fieldsShown.includes('travelTime') && (!commuteLocation || noEntities)) {
23
- fieldsShown = fieldsShown.filter(x => x !== 'travelTime');
24
- }
18
+ // Use useMemo to avoid hydration mismatch - create new array instead of mutating prop
19
+ const effectiveFieldsShown = useMemo(() => {
20
+ const fields = [...fieldsShown];
21
+ if (!fields.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {
22
+ fields.push('travelTime');
23
+ fieldNames['travelTime'] = 'Commute';
24
+ }
25
+ else if (fields.includes('travelTime') && (!commuteLocation || noEntities)) {
26
+ return fields.filter(x => x !== 'travelTime');
27
+ }
28
+ return fields;
29
+ }, [fieldsShown, commuteLocation, noEntities, fieldNames]);
25
30
  const setTrackedSortSetting = (sortSetting) => {
26
31
  trackEvent(eventTypes.LIST_SORTED, sortSetting);
27
32
  setSortSetting(sortSetting);
28
33
  };
29
34
  //fieldsShown.push('favorite');
30
- return (React.createElement(ItemsList, { fieldNames: fieldNames, showMap: showMap, fieldsShown: fieldsShown, filteredListings: filteredListings, loading: loading, sortSetting: sortSetting, setSortSetting: setTrackedSortSetting, itemLimit: itemLimit, loader: loader, scrollContainerRef: scrollContainerRef, itemRefs: itemRefs, selectedListItem: selectedListItem, includeFavorite: true },
35
+ return (React.createElement(ItemsList, { fieldNames: fieldNames, showMap: showMap, fieldsShown: effectiveFieldsShown, filteredListings: filteredListings, loading: loading, sortSetting: sortSetting, setSortSetting: setTrackedSortSetting, itemLimit: itemLimit, loader: loader, scrollContainerRef: scrollContainerRef, itemRefs: itemRefs, selectedListItem: selectedListItem, includeFavorite: true },
31
36
  React.createElement(Accordion, { className: "hc-divide-y hc-divide-uiAccent/10", defaultValue: selectedListItem?.id }, (sortSetting ? dynamicSort(filteredListings, sortSetting.field, sortSetting.type, favorites) : filteredListings)
32
37
  .slice(0, itemLimit)
33
- .map((item) => (React.createElement(MapAccordionItemContainer, { key: item.id, showMap: showMap, item: item, itemRefs: itemRefs, fieldsShown: fieldsShown, itemExpandedContent: itemExpandedContent, specialFeatures: specialFeatures, isActive: selectedListItem?.id === item.id }))))));
38
+ .map((item, index) => (React.createElement(MapAccordionItemContainer, { key: item.id, showMap: showMap, item: item, itemRefs: itemRefs, fieldsShown: effectiveFieldsShown, itemExpandedContent: itemExpandedContent, specialFeatures: specialFeatures, isActive: selectedListItem?.id === item.id, index: index }))))));
34
39
  };
35
40
 
36
41
  export { ItemsListContainer as default };
@@ -1 +1 @@
1
- {"version":3,"file":"item-list-container.js","sources":["../../../../src/components/containers/list/item-list-container.tsx"],"sourcesContent":["import React from 'react';\nimport useListLogic from '~/hooks/useList';\nimport { useMap } from '~/contexts/mapContext';\nimport { useMapList } from '~/contexts/mapListContext';\nimport { useTrackEvent } from '~/contexts/trackEventContext';\nimport ItemsList from '~/components/modules/list/item-list';\nimport Accordion from '~/components/modules/accordions/default';\nimport MapAccordionItemContainer from '~/components/containers/accordions/map-accordion-item-container';\nimport { dynamicSort } from '~/util/sortUtil';\nimport { Listing } from '~/types/Listings';\nimport ListingDetailsContainer from '../jobListing/listing-details-container';\n\ninterface ItemsListContainerProps {\n fieldNames: Record<string, string>;\n showMap: boolean;\n fieldsShown: string[];\n specialFeatures: any;\n}\n\nconst ItemsListContainer: React.FC<ItemsListContainerProps> = ({\n\tfieldNames,\n\tshowMap,\n\tfieldsShown,\n\tspecialFeatures\n}) => {\n\tconst { filteredListings, loading, commuteLocation, sortSetting, setSortSetting, ExpandListComponent, favorites, noEntities } = useMapList();\n\tconst { itemLimit, loader, scrollContainerRef, itemRefs } = useListLogic(filteredListings as any);\n\tconst { selectedListItem } = useMap();\n\tconst { trackEvent, eventTypes } = useTrackEvent() as any;\n\tconst itemExpandedContent = (item: any, recruiter: any) =>\n\t\titem ? (ExpandListComponent ? <ExpandListComponent listing={item} /> : <ListingDetailsContainer item={item} recruiter={recruiter} />) : null;\n\n\tif (!fieldsShown.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {\n\t\tfieldsShown.push('travelTime');\n\t\tfieldNames['travelTime'] = 'Commute';\n\t} else if (fieldsShown.includes('travelTime') && (!commuteLocation || noEntities)) {\n\t\tfieldsShown = fieldsShown.filter(x => x !== 'travelTime');\n\t}\n\n\tconst setTrackedSortSetting = (sortSetting: { field: string; type: string }) => {\n\t\ttrackEvent(eventTypes.LIST_SORTED, sortSetting);\n\t\tsetSortSetting(sortSetting);\n\t};\n\t\t//fieldsShown.push('favorite');\n\n\treturn (\n\t\t<ItemsList\n\t\t\tfieldNames={fieldNames}\n\t\t\tshowMap={showMap}\n\t\t\tfieldsShown={fieldsShown}\n\t\t\tfilteredListings={filteredListings}\n\t\t\tloading={loading}\n\t\t\tsortSetting={sortSetting}\n\t\t\tsetSortSetting={setTrackedSortSetting}\n\t\t\titemLimit={itemLimit}\n\t\t\tloader={loader}\n\t\t\tscrollContainerRef={scrollContainerRef}\n\t\t\titemRefs={itemRefs}\n\t\t\tselectedListItem={selectedListItem}\n\t\t\tincludeFavorite={true}\n\t\t>\n\t\t\t<Accordion className=\"hc-divide-y hc-divide-uiAccent/10\" defaultValue={selectedListItem?.id}>\n\t\t\t\t{(sortSetting ? dynamicSort(filteredListings, sortSetting.field, sortSetting.type, favorites as any) : filteredListings)\n\t\t\t\t\t.slice(0, itemLimit)\n\t\t\t\t\t.map((item: Listing) => (\n\t\t\t\t\t\t<MapAccordionItemContainer\n\t\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t\tshowMap={showMap}\n\t\t\t\t\t\t\titem={item}\n\t\t\t\t\t\t\titemRefs={itemRefs}\n\t\t\t\t\t\t\tfieldsShown={fieldsShown}\n\t\t\t\t\t\t\titemExpandedContent={itemExpandedContent}\n\t\t\t\t\t\t\tspecialFeatures={specialFeatures}\n\t\t\t\t\t\t\tisActive={selectedListItem?.id === item.id}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t</Accordion>\n\t\t</ItemsList>\n\t);\n};\n\nexport default ItemsListContainer;\n"],"names":[],"mappings":";;;;;;;;;;;AAmBA,MAAM,kBAAkB,GAAsC,CAAC,EAC9D,UAAU,EACV,OAAO,EACP,WAAW,EACX,eAAe,EACf,KAAI;IACJ,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,mBAAmB,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAAC;AAC7I,IAAA,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAC,gBAAuB,CAAC,CAAC;AAClG,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,EAAE,CAAC;IACtC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,aAAa,EAAS,CAAC;IAC1D,MAAM,mBAAmB,GAAG,CAAC,IAAS,EAAE,SAAc,KACrD,IAAI,IAAI,mBAAmB,GAAI,KAAA,CAAA,aAAA,CA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A,aAAA,CAAC,SAAS,EAAA,EAAC,SAAS,EAAC,mCAAmC,EAAC,YAAY,EAAE,gBAAgB,EAAE,EAAE,EAAA,EACzF,CAAC,WAAW,GAAG,WAAW,CAAC,gBAAgB,EAAE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,EAAE,SAAgB,CAAC,GAAG,gBAAgB;AACrH,aAAA,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC;aACnB,GAAG,CAAC,CAAC,IAAa,MAClB,KAAA,CAAA,aAAA,CAAC,yBAAyB,EAAA,EACzB,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,KAAK,IAAI,CAAC,EAAE,EACzC,CAAA,CACF,CAAC,CACQ,CACD,EACX;AACH;;;;"}
1
+ {"version":3,"file":"item-list-container.js","sources":["../../../../src/components/containers/list/item-list-container.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport useListLogic from '~/hooks/useList';\nimport { useMap } from '~/contexts/mapContext';\nimport { useMapList } from '~/contexts/mapListContext';\nimport { useTrackEvent } from '~/contexts/trackEventContext';\nimport ItemsList from '~/components/modules/list/item-list';\nimport Accordion from '~/components/modules/accordions/default';\nimport MapAccordionItemContainer from '~/components/containers/accordions/map-accordion-item-container';\nimport { dynamicSort } from '~/util/sortUtil';\nimport { Listing } from '~/types/Listings';\nimport ListingDetailsContainer from '../jobListing/listing-details-container';\n\ninterface ItemsListContainerProps {\n fieldNames: Record<string, string>;\n showMap: boolean;\n fieldsShown: string[];\n specialFeatures: any;\n}\n\nconst ItemsListContainer: React.FC<ItemsListContainerProps> = ({\n\tfieldNames,\n\tshowMap,\n\tfieldsShown,\n\tspecialFeatures\n}) => {\n\tconst { filteredListings, loading, commuteLocation, sortSetting, setSortSetting, ExpandListComponent, favorites, noEntities } = useMapList();\n\tconst { itemLimit, loader, scrollContainerRef, itemRefs } = useListLogic(filteredListings as any);\n\tconst { selectedListItem } = useMap();\n\tconst { trackEvent, eventTypes } = useTrackEvent() as any;\n\tconst itemExpandedContent = (item: any, recruiter: any) =>\n\t\titem ? (ExpandListComponent ? <ExpandListComponent listing={item} /> : <ListingDetailsContainer item={item} recruiter={recruiter} />) : null;\n\n\t// Use useMemo to avoid hydration mismatch - create new array instead of mutating prop\n\tconst effectiveFieldsShown = useMemo(() => {\n\t\tconst fields = [...fieldsShown];\n\t\tif (!fields.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {\n\t\t\tfields.push('travelTime');\n\t\t\tfieldNames['travelTime'] = 'Commute';\n\t\t} else if (fields.includes('travelTime') && (!commuteLocation || noEntities)) {\n\t\t\treturn fields.filter(x => x !== 'travelTime');\n\t\t}\n\t\treturn fields;\n\t}, [fieldsShown, commuteLocation, noEntities, fieldNames]);\n\n\tconst setTrackedSortSetting = (sortSetting: { field: string; type: string }) => {\n\t\ttrackEvent(eventTypes.LIST_SORTED, sortSetting);\n\t\tsetSortSetting(sortSetting);\n\t};\n\t\t//fieldsShown.push('favorite');\n\n\treturn (\n\t\t<ItemsList\n\t\t\tfieldNames={fieldNames}\n\t\t\tshowMap={showMap}\n\t\t\tfieldsShown={effectiveFieldsShown}\n\t\t\tfilteredListings={filteredListings}\n\t\t\tloading={loading}\n\t\t\tsortSetting={sortSetting}\n\t\t\tsetSortSetting={setTrackedSortSetting}\n\t\t\titemLimit={itemLimit}\n\t\t\tloader={loader}\n\t\t\tscrollContainerRef={scrollContainerRef}\n\t\t\titemRefs={itemRefs}\n\t\t\tselectedListItem={selectedListItem}\n\t\t\tincludeFavorite={true}\n\t\t>\n\t\t\t<Accordion className=\"hc-divide-y hc-divide-uiAccent/10\" defaultValue={selectedListItem?.id}>\n\t\t\t\t{(sortSetting ? dynamicSort(filteredListings, sortSetting.field, sortSetting.type, favorites as any) : filteredListings)\n\t\t\t\t\t.slice(0, itemLimit)\n\t\t\t\t\t.map((item: Listing, index: number) => (\n\t\t\t\t\t\t<MapAccordionItemContainer\n\t\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t\tshowMap={showMap}\n\t\t\t\t\t\t\titem={item}\n\t\t\t\t\t\t\titemRefs={itemRefs}\n\t\t\t\t\t\t\tfieldsShown={effectiveFieldsShown}\n\t\t\t\t\t\t\titemExpandedContent={itemExpandedContent}\n\t\t\t\t\t\t\tspecialFeatures={specialFeatures}\n\t\t\t\t\t\t\tisActive={selectedListItem?.id === item.id}\n\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t</Accordion>\n\t\t</ItemsList>\n\t);\n};\n\nexport default ItemsListContainer;\n"],"names":[],"mappings":";;;;;;;;;;;AAmBA,MAAM,kBAAkB,GAAsC,CAAC,EAC9D,UAAU,EACV,OAAO,EACP,WAAW,EACX,eAAe,EACf,KAAI;IACJ,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,mBAAmB,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAAC;AAC7I,IAAA,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAC,gBAAuB,CAAC,CAAC;AAClG,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,EAAE,CAAC;IACtC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,aAAa,EAAS,CAAC;IAC1D,MAAM,mBAAmB,GAAG,CAAC,IAAS,EAAE,SAAc,KACrD,IAAI,IAAI,mBAAmB,GAAI,KAAA,CAAA,aAAA,CAAC,mBAAmB,EAAC,EAAA,OAAO,EAAE,IAAI,EAAA,CAAI,GAAG,oBAAC,uBAAuB,EAAA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AM,EACd,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,IAAI,EAAA;AAErB,QAAA,KAAA,CAAA,aAAA,CAAC,SAAS,EAAA,EAAC,SAAS,EAAC,mCAAmC,EAAC,YAAY,EAAE,gBAAgB,EAAE,EAAE,EAAA,EACzF,CAAC,WAAW,GAAG,WAAW,CAAC,gBAAgB,EAAE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,EAAE,SAAgB,CAAC,GAAG,gBAAgB;AACrH,aAAA,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC;AACnB,aAAA,GAAG,CAAC,CAAC,IAAa,EAAE,KAAa,MACjC,KAAA,CAAA,aAAA,CAAC,yBAAyB,EAAA,EACzB,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,oBAAoB,EACjC,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,KAAK,IAAI,CAAC,EAAE,EAC1C,KAAK,EAAE,KAAK,EAAA,CACX,CACF,CAAC,CACQ,CACD,EACX;AACH;;;;"}
@@ -1,4 +1,5 @@
1
- import React from 'react';
1
+ import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React, { useState, useEffect } from 'react';
2
3
  import { GoogleMap } from '@react-google-maps/api';
3
4
  import ShowAllButton from '../buttons/show-all-button.js';
4
5
 
@@ -17,8 +18,17 @@ var Map = function Map(_ref) {
17
18
  filteredListingsLength = _ref.filteredListingsLength,
18
19
  setSelectedFilters = _ref.setSelectedFilters,
19
20
  children = _ref.children;
20
- // Don't render GoogleMap until google.maps.Map constructor is available
21
- var isGoogleMapsAvailable = typeof window !== 'undefined' && window.google && window.google.maps && window.google.maps.Map;
21
+ // Use state to avoid hydration mismatch
22
+ var _useState = useState(false),
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ isGoogleMapsAvailable = _useState2[0],
25
+ setIsGoogleMapsAvailable = _useState2[1];
26
+ useEffect(function () {
27
+ // Check if Google Maps is available after mount (client-side only)
28
+ if (window.google && window.google.maps && window.google.maps.Map) {
29
+ setIsGoogleMapsAvailable(true);
30
+ }
31
+ }, []);
22
32
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
23
33
  ref: mapContainerRef,
24
34
  className: "hc-h-full hc-relative"
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","sources":["../../../../src/components/modules/maps/map.js"],"sourcesContent":["import React from 'react';\nimport { GoogleMap, useLoadScript } from \"@react-google-maps/api\";\nimport ShowAllButton from \"~/components/modules/buttons/show-all-button\";\n\nconst Map = ({\n\tzoom,\n\tcenter,\n\tmapContainerRef,\n\tonLoad,\n\tonIdle,\n\tmapInteracted,\n\tpinIconUrl,\n\tsetMapInteracted,\n\tfitBounds,\n\tmapRef,\n\tsetQuery,\n\tfilteredListingsLength,\n\tsetSelectedFilters,\n\tchildren\n}) => {\n\t// Don't render GoogleMap until google.maps.Map constructor is available\n\tconst isGoogleMapsAvailable = typeof window !== 'undefined' && window.google && window.google.maps && window.google.maps.Map;\n\n\treturn (\n\t\t<>\n\t\t\t<div ref={mapContainerRef} className=\"hc-h-full hc-relative\">\n\t\t\t\t{isGoogleMapsAvailable && (\n\t\t\t\t\t<GoogleMap\n\t\t\t\t\t\tzoom={zoom}\n\t\t\t\t\t\tonLoad={onLoad}\n\t\t\t\t\t\tonIdle={onIdle}\n\t\t\t\t\t\tcenter={center}\n\t\t\t\t\t\tmapContainerStyle={{\n\t\t\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\t\t\theight: \"100%\"\n\t\t\t\t\t\t}}\n\t\t\t\t\t\toptions={{\n\t\t\t\t\t\t\tstyles: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfeatureType: \"poi\",\n\t\t\t\t\t\t\t\t\telementType: \"labels\",\n\t\t\t\t\t\t\t\t\tstylers: [{ visibility: \"off\" }]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</GoogleMap>\n\t\t\t\t)}\n\t\t\t\t{mapInteracted && (\n\t\t\t\t\t<ShowAllButton\n\t\t\t\t\t\tmapInteracted={mapInteracted}\n\t\t\t\t\t\tsetMapInteracted={setMapInteracted}\n\t\t\t\t\t\tfitBounds={fitBounds}\n\t\t\t\t\t\tmapRef={mapRef}\n\t\t\t\t\t\tpinIconUrl={pinIconUrl}\n\t\t\t\t\t\tsetQuery={setQuery}\n\t\t\t\t\t\tlistingCount={filteredListingsLength}\n\t\t\t\t\t\tsetSelectedFilters={setSelectedFilters}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</>\n\t);\n};\n\nexport default Map;\n"],"names":["Map","_ref","zoom","center","mapContainerRef","onLoad","onIdle","mapInteracted","pinIconUrl","setMapInteracted","fitBounds","mapRef","setQuery","filteredListingsLength","setSelectedFilters","children","isGoogleMapsAvailable","window","google","maps","React","createElement","Fragment","ref","className","GoogleMap","mapContainerStyle","width","height","options","styles","featureType","elementType","stylers","visibility","ShowAllButton","listingCount"],"mappings":";;;;AAIA,IAAMA,GAAG,GAAG,SAANA,GAAGA,CAAAC,IAAA,EAeH;AAAA,EAAA,IAdLC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,MAAM,GAAAL,IAAA,CAANK,MAAM;IACNC,aAAa,GAAAN,IAAA,CAAbM,aAAa;IACbC,UAAU,GAAAP,IAAA,CAAVO,UAAU;IACV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CAAAC,aAAA,CAACc,aAAa,EAAA;AACb5B,IAAAA,aAAa,EAAEA,aAAc;AAC7BE,IAAAA,gBAAgB,EAAEA,gBAAiB;AACnCC,IAAAA,SAAS,EAAEA,SAAU;AACrBC,IAAAA,MAAM,EAAEA,MAAO;AACfH,IAAAA,UAAU,EAAEA,UAAW;AACvBI,IAAAA,QAAQ,EAAEA,QAAS;AACnBwB,IAAAA,YAAY,EAAEvB,sBAAuB;AACrCC,IAAAA,kBAAkB,EAAEA,kBAAAA;GACpB,CAEE,CACJ,CAAC,CAAA;AAEL;;;;"}
1
+ {"version":3,"file":"map.js","sources":["../../../../src/components/modules/maps/map.js"],"sourcesContent":["\"use client\";\n\nimport React, { useState, useEffect } from 'react';\nimport { GoogleMap, useLoadScript } from \"@react-google-maps/api\";\nimport ShowAllButton from \"~/components/modules/buttons/show-all-button\";\n\nconst Map = ({\n\tzoom,\n\tcenter,\n\tmapContainerRef,\n\tonLoad,\n\tonIdle,\n\tmapInteracted,\n\tpinIconUrl,\n\tsetMapInteracted,\n\tfitBounds,\n\tmapRef,\n\tsetQuery,\n\tfilteredListingsLength,\n\tsetSelectedFilters,\n\tchildren\n}) => {\n\t// Use state to avoid hydration mismatch\n\tconst [isGoogleMapsAvailable, setIsGoogleMapsAvailable] = useState(false);\n\t\n\tuseEffect(() => {\n\t\t// Check if Google Maps is available after mount (client-side only)\n\t\tif (window.google && window.google.maps && window.google.maps.Map) {\n\t\t\tsetIsGoogleMapsAvailable(true);\n\t\t}\n\t}, []);\n\n\treturn (\n\t\t<>\n\t\t\t<div ref={mapContainerRef} className=\"hc-h-full hc-relative\">\n\t\t\t\t{isGoogleMapsAvailable && (\n\t\t\t\t\t<GoogleMap\n\t\t\t\t\t\tzoom={zoom}\n\t\t\t\t\t\tonLoad={onLoad}\n\t\t\t\t\t\tonIdle={onIdle}\n\t\t\t\t\t\tcenter={center}\n\t\t\t\t\t\tmapContainerStyle={{\n\t\t\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\t\t\theight: \"100%\"\n\t\t\t\t\t\t}}\n\t\t\t\t\t\toptions={{\n\t\t\t\t\t\t\tstyles: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfeatureType: \"poi\",\n\t\t\t\t\t\t\t\t\telementType: \"labels\",\n\t\t\t\t\t\t\t\t\tstylers: [{ visibility: \"off\" }]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</GoogleMap>\n\t\t\t\t)}\n\t\t\t\t{mapInteracted && (\n\t\t\t\t\t<ShowAllButton\n\t\t\t\t\t\tmapInteracted={mapInteracted}\n\t\t\t\t\t\tsetMapInteracted={setMapInteracted}\n\t\t\t\t\t\tfitBounds={fitBounds}\n\t\t\t\t\t\tmapRef={mapRef}\n\t\t\t\t\t\tpinIconUrl={pinIconUrl}\n\t\t\t\t\t\tsetQuery={setQuery}\n\t\t\t\t\t\tlistingCount={filteredListingsLength}\n\t\t\t\t\t\tsetSelectedFilters={setSelectedFilters}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</>\n\t);\n};\n\nexport default Map;\n"],"names":["Map","_ref","zoom","center","mapContainerRef","onLoad","onIdle","mapInteracted","pinIconUrl","setMapInteracted","fitBounds","mapRef","setQuery","filteredListingsLength","setSelectedFilters","children","_useState","useState","_useState2","_slicedToArray","isGoogleMapsAvailable","setIsGoogleMapsAvailable","useEffect","window","google","maps","React","createElement","Fragment","ref","className","GoogleMap","mapContainerStyle","width","height","options","styles","featureType","elementType","stylers","visibility","ShowAllButton","listingCount"],"mappings":";;;;;AAMA,IAAMA,GAAG,GAAG,SAANA,GAAGA,CAAAC,IAAA,EAeH;AAAA,EAAA,IAdLC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,eAAe,GAAAH,IAAA,CAAfG,eAAe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K;AACXG,IAAAA,MAAM,EAAEA,MAAO;AACfC,IAAAA,MAAM,EAAEA,MAAO;AACfH,IAAAA,MAAM,EAAEA,MAAO;AACf6B,IAAAA,iBAAiB,EAAE;AAClBC,MAAAA,KAAK,EAAE,MAAM;AACbC,MAAAA,MAAM,EAAE,MAAA;KACP;AACFC,IAAAA,OAAO,EAAE;AACRC,MAAAA,MAAM,EAAE,CACP;AACCC,QAAAA,WAAW,EAAE,KAAK;AAClBC,QAAAA,WAAW,EAAE,QAAQ;AACrBC,QAAAA,OAAO,EAAE,CAAC;AAAEC,UAAAA,UAAU,EAAE,KAAA;SAAO,CAAA;OAC/B,CAAA;AAEH,KAAA;GAECzB,EAAAA,QACS,CACX,EACAR,aAAa,iBACbmB,KAAA,CAAAC,aAAA,CAACc,aAAa,EAAA;AACblC,IAAAA,aAAa,EAAEA,aAAc;AAC7BE,IAAAA,gBAAgB,EAAEA,gBAAiB;AACnCC,IAAAA,SAAS,EAAEA,SAAU;AACrBC,IAAAA,MAAM,EAAEA,MAAO;AACfH,IAAAA,UAAU,EAAEA,UAAW;AACvBI,IAAAA,QAAQ,EAAEA,QAAS;AACnB8B,IAAAA,YAAY,EAAE7B,sBAAuB;AACrCC,IAAAA,kBAAkB,EAAEA,kBAAAA;GACpB,CAEE,CACJ,CAAC,CAAA;AAEL;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abcagency/hc-ui-components",
3
- "version": "1.8.6",
3
+ "version": "1.8.8",
4
4
  "description": "UI Components for HireControl",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import useListLogic from '~/hooks/useList';
3
3
  import { useMap } from '~/contexts/mapContext';
4
4
  import { useMapList } from '~/contexts/mapListContext';
@@ -30,12 +30,17 @@ const ItemsListContainer: React.FC<ItemsListContainerProps> = ({
30
30
  const itemExpandedContent = (item: any, recruiter: any) =>
31
31
  item ? (ExpandListComponent ? <ExpandListComponent listing={item} /> : <ListingDetailsContainer item={item} recruiter={recruiter} />) : null;
32
32
 
33
- if (!fieldsShown.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {
34
- fieldsShown.push('travelTime');
35
- fieldNames['travelTime'] = 'Commute';
36
- } else if (fieldsShown.includes('travelTime') && (!commuteLocation || noEntities)) {
37
- fieldsShown = fieldsShown.filter(x => x !== 'travelTime');
38
- }
33
+ // Use useMemo to avoid hydration mismatch - create new array instead of mutating prop
34
+ const effectiveFieldsShown = useMemo(() => {
35
+ const fields = [...fieldsShown];
36
+ if (!fields.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {
37
+ fields.push('travelTime');
38
+ fieldNames['travelTime'] = 'Commute';
39
+ } else if (fields.includes('travelTime') && (!commuteLocation || noEntities)) {
40
+ return fields.filter(x => x !== 'travelTime');
41
+ }
42
+ return fields;
43
+ }, [fieldsShown, commuteLocation, noEntities, fieldNames]);
39
44
 
40
45
  const setTrackedSortSetting = (sortSetting: { field: string; type: string }) => {
41
46
  trackEvent(eventTypes.LIST_SORTED, sortSetting);
@@ -47,7 +52,7 @@ const ItemsListContainer: React.FC<ItemsListContainerProps> = ({
47
52
  <ItemsList
48
53
  fieldNames={fieldNames}
49
54
  showMap={showMap}
50
- fieldsShown={fieldsShown}
55
+ fieldsShown={effectiveFieldsShown}
51
56
  filteredListings={filteredListings}
52
57
  loading={loading}
53
58
  sortSetting={sortSetting}
@@ -62,16 +67,17 @@ const ItemsListContainer: React.FC<ItemsListContainerProps> = ({
62
67
  <Accordion className="hc-divide-y hc-divide-uiAccent/10" defaultValue={selectedListItem?.id}>
63
68
  {(sortSetting ? dynamicSort(filteredListings, sortSetting.field, sortSetting.type, favorites as any) : filteredListings)
64
69
  .slice(0, itemLimit)
65
- .map((item: Listing) => (
70
+ .map((item: Listing, index: number) => (
66
71
  <MapAccordionItemContainer
67
72
  key={item.id}
68
73
  showMap={showMap}
69
74
  item={item}
70
75
  itemRefs={itemRefs}
71
- fieldsShown={fieldsShown}
76
+ fieldsShown={effectiveFieldsShown}
72
77
  itemExpandedContent={itemExpandedContent}
73
78
  specialFeatures={specialFeatures}
74
79
  isActive={selectedListItem?.id === item.id}
80
+ index={index}
75
81
  />
76
82
  ))}
77
83
  </Accordion>
@@ -1,4 +1,6 @@
1
- import React from 'react';
1
+ "use client";
2
+
3
+ import React, { useState, useEffect } from 'react';
2
4
  import { GoogleMap, useLoadScript } from "@react-google-maps/api";
3
5
  import ShowAllButton from "~/components/modules/buttons/show-all-button";
4
6
 
@@ -18,8 +20,15 @@ const Map = ({
18
20
  setSelectedFilters,
19
21
  children
20
22
  }) => {
21
- // Don't render GoogleMap until google.maps.Map constructor is available
22
- const isGoogleMapsAvailable = typeof window !== 'undefined' && window.google && window.google.maps && window.google.maps.Map;
23
+ // Use state to avoid hydration mismatch
24
+ const [isGoogleMapsAvailable, setIsGoogleMapsAvailable] = useState(false);
25
+
26
+ useEffect(() => {
27
+ // Check if Google Maps is available after mount (client-side only)
28
+ if (window.google && window.google.maps && window.google.maps.Map) {
29
+ setIsGoogleMapsAvailable(true);
30
+ }
31
+ }, []);
23
32
 
24
33
  return (
25
34
  <>