@abcagency/hc-ui-components 1.8.7 → 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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abcagency/hc-ui-components",
3
- "version": "1.8.7",
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>