@abcagency/hc-ui-components 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/.editorconfig +12 -0
  2. package/.eslintrc +144 -0
  3. package/.prettierignore +3 -0
  4. package/dist/_virtual/_rollupPluginBabelHelpers.js +516 -0
  5. package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  6. package/dist/apis/hcApi.js +189 -0
  7. package/dist/apis/hcApi.js.map +1 -0
  8. package/dist/clientToken.js +10 -0
  9. package/dist/clientToken.js.map +1 -0
  10. package/dist/components/HireControlMap.js +129 -0
  11. package/dist/components/HireControlMap.js.map +1 -0
  12. package/dist/components/modules/accordions/MapAccordionItem.js +76 -0
  13. package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -0
  14. package/dist/components/modules/accordions/default.js +108 -0
  15. package/dist/components/modules/accordions/default.js.map +1 -0
  16. package/dist/components/modules/accordions/filterItem.js +50 -0
  17. package/dist/components/modules/accordions/filterItem.js.map +1 -0
  18. package/dist/components/modules/accordions/filters.js +46 -0
  19. package/dist/components/modules/accordions/filters.js.map +1 -0
  20. package/dist/components/modules/buttons/button-group-apply.js +84 -0
  21. package/dist/components/modules/buttons/button-group-apply.js.map +1 -0
  22. package/dist/components/modules/buttons/commute-pill.js +18 -0
  23. package/dist/components/modules/buttons/commute-pill.js.map +1 -0
  24. package/dist/components/modules/buttons/default.js +145 -0
  25. package/dist/components/modules/buttons/default.js.map +1 -0
  26. package/dist/components/modules/buttons/items-pill.js +23 -0
  27. package/dist/components/modules/buttons/items-pill.js.map +1 -0
  28. package/dist/components/modules/buttons/pill-wrapper.js +20 -0
  29. package/dist/components/modules/buttons/pill-wrapper.js.map +1 -0
  30. package/dist/components/modules/buttons/show-all-button.js +39 -0
  31. package/dist/components/modules/buttons/show-all-button.js.map +1 -0
  32. package/dist/components/modules/cards/default.js +102 -0
  33. package/dist/components/modules/cards/default.js.map +1 -0
  34. package/dist/components/modules/cards/filter.js +38 -0
  35. package/dist/components/modules/cards/filter.js.map +1 -0
  36. package/dist/components/modules/dialogs/apply-dialog.js +46 -0
  37. package/dist/components/modules/dialogs/apply-dialog.js.map +1 -0
  38. package/dist/components/modules/filter/commute.js +184 -0
  39. package/dist/components/modules/filter/commute.js.map +1 -0
  40. package/dist/components/modules/filter/index.js +79 -0
  41. package/dist/components/modules/filter/index.js.map +1 -0
  42. package/dist/components/modules/filter/item.js +71 -0
  43. package/dist/components/modules/filter/item.js.map +1 -0
  44. package/dist/components/modules/filter/location.js +68 -0
  45. package/dist/components/modules/filter/location.js.map +1 -0
  46. package/dist/components/modules/filter/points-of-interest.js +38 -0
  47. package/dist/components/modules/filter/points-of-interest.js.map +1 -0
  48. package/dist/components/modules/filter/radio-item.js +46 -0
  49. package/dist/components/modules/filter/radio-item.js.map +1 -0
  50. package/dist/components/modules/filter/search.js +83 -0
  51. package/dist/components/modules/filter/search.js.map +1 -0
  52. package/dist/components/modules/filter/sort.js +93 -0
  53. package/dist/components/modules/filter/sort.js.map +1 -0
  54. package/dist/components/modules/grid.js +39 -0
  55. package/dist/components/modules/grid.js.map +1 -0
  56. package/dist/components/modules/icon.js +23 -0
  57. package/dist/components/modules/icon.js.map +1 -0
  58. package/dist/components/modules/jobListing/listing-details.js +69 -0
  59. package/dist/components/modules/jobListing/listing-details.js.map +1 -0
  60. package/dist/components/modules/maps/info-window-card.js +14 -0
  61. package/dist/components/modules/maps/info-window-card.js.map +1 -0
  62. package/dist/components/modules/maps/info-window-content.js +39 -0
  63. package/dist/components/modules/maps/info-window-content.js.map +1 -0
  64. package/dist/components/modules/maps/list/field-mapper.js +88 -0
  65. package/dist/components/modules/maps/list/field-mapper.js.map +1 -0
  66. package/dist/components/modules/maps/list/header-item.js +59 -0
  67. package/dist/components/modules/maps/list/header-item.js.map +1 -0
  68. package/dist/components/modules/maps/list/header.js +37 -0
  69. package/dist/components/modules/maps/list/header.js.map +1 -0
  70. package/dist/components/modules/maps/list/index.js +93 -0
  71. package/dist/components/modules/maps/list/index.js.map +1 -0
  72. package/dist/components/modules/maps/list/item-expand-card/index.js +16 -0
  73. package/dist/components/modules/maps/list/item-expand-card/index.js.map +1 -0
  74. package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js +38 -0
  75. package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +1 -0
  76. package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js +40 -0
  77. package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +1 -0
  78. package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js +20 -0
  79. package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +1 -0
  80. package/dist/components/modules/maps/list/list-item/index.js +98 -0
  81. package/dist/components/modules/maps/list/list-item/index.js.map +1 -0
  82. package/dist/components/modules/maps/map-list.js +57 -0
  83. package/dist/components/modules/maps/map-list.js.map +1 -0
  84. package/dist/components/modules/maps/map-marker.js +85 -0
  85. package/dist/components/modules/maps/map-marker.js.map +1 -0
  86. package/dist/components/modules/maps/map.js +201 -0
  87. package/dist/components/modules/maps/map.js.map +1 -0
  88. package/dist/components/modules/maps/place-marker.js +37 -0
  89. package/dist/components/modules/maps/place-marker.js.map +1 -0
  90. package/dist/components/modules/maps/tabs.js +84 -0
  91. package/dist/components/modules/maps/tabs.js.map +1 -0
  92. package/dist/constants/placeTypes.js +11 -0
  93. package/dist/constants/placeTypes.js.map +1 -0
  94. package/dist/contexts/mapContext.js +133 -0
  95. package/dist/contexts/mapContext.js.map +1 -0
  96. package/dist/contexts/mapListContext.js +278 -0
  97. package/dist/contexts/mapListContext.js.map +1 -0
  98. package/dist/contexts/placesContext.js +152 -0
  99. package/dist/contexts/placesContext.js.map +1 -0
  100. package/dist/hooks/useList.js +119 -0
  101. package/dist/hooks/useList.js.map +1 -0
  102. package/dist/index.js +2 -4536
  103. package/dist/index.js.map +1 -0
  104. package/dist/services/_virtual/_rollupPluginBabelHelpers.js +372 -0
  105. package/dist/services/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  106. package/dist/services/apis/hcApi.js +189 -0
  107. package/dist/services/apis/hcApi.js.map +1 -0
  108. package/dist/services/clientToken.js +7 -0
  109. package/dist/services/clientToken.js.map +1 -0
  110. package/dist/services/configService.js +33 -0
  111. package/dist/services/configService.js.map +1 -0
  112. package/dist/services/googlePlacesNearbyService.js +61 -0
  113. package/dist/services/googlePlacesNearbyService.js.map +1 -0
  114. package/dist/services/listingAggregatorService.js +56 -0
  115. package/dist/services/listingAggregatorService.js.map +1 -0
  116. package/dist/services/listingEntityService.js +36 -0
  117. package/dist/services/listingEntityService.js.map +1 -0
  118. package/dist/services/listingService.js +60 -112
  119. package/dist/services/listingService.js.map +1 -0
  120. package/dist/services/recruiterService.js +36 -0
  121. package/dist/services/recruiterService.js.map +1 -0
  122. package/dist/services/styles/index.css +3 -0
  123. package/dist/styles/index.css +3 -0
  124. package/dist/util/filterUtil.js +213 -0
  125. package/dist/util/filterUtil.js.map +1 -0
  126. package/dist/util/loading.js +16 -0
  127. package/dist/util/loading.js.map +1 -0
  128. package/dist/util/localStorageUtil.js +32 -0
  129. package/dist/util/localStorageUtil.js.map +1 -0
  130. package/dist/util/mapIconUtil.js +73 -0
  131. package/dist/util/mapIconUtil.js.map +1 -0
  132. package/dist/util/mapUtil.js +76 -0
  133. package/dist/util/mapUtil.js.map +1 -0
  134. package/dist/util/sortUtil.js +33 -0
  135. package/dist/util/sortUtil.js.map +1 -0
  136. package/dist/util/stringUtils.js +9 -0
  137. package/dist/util/stringUtils.js.map +1 -0
  138. package/jsconfig.json +7 -0
  139. package/package.json +51 -38
  140. package/postcss.config.js +13 -15
  141. package/{src/tailwind/preset.default.js → preset.default.js} +15 -15
  142. package/rollup.config.mjs +87 -0
  143. package/src/apis/hcApi.js +93 -87
  144. package/src/clientToken.js +9 -9
  145. package/src/components/HireControlMap.js +120 -0
  146. package/src/components/modules/accordions/MapAccordionItem.js +72 -69
  147. package/src/components/modules/accordions/default.js +171 -173
  148. package/src/components/modules/accordions/filterItem.js +53 -53
  149. package/src/components/modules/accordions/filters.js +47 -44
  150. package/src/components/modules/buttons/button-group-apply.js +113 -85
  151. package/src/components/modules/buttons/commute-pill.js +22 -21
  152. package/src/components/modules/buttons/default.js +196 -196
  153. package/src/components/modules/buttons/items-pill.js +32 -31
  154. package/src/components/modules/buttons/pill-wrapper.js +27 -26
  155. package/src/components/modules/buttons/show-all-button.js +20 -20
  156. package/src/components/modules/cards/default.js +167 -168
  157. package/src/components/modules/cards/filter.js +56 -55
  158. package/src/components/modules/dialogs/apply-dialog.js +48 -47
  159. package/src/components/modules/filter/commute.js +148 -151
  160. package/src/components/modules/filter/index.js +87 -86
  161. package/src/components/modules/filter/item.js +76 -77
  162. package/src/components/modules/filter/location.js +71 -69
  163. package/src/components/modules/filter/points-of-interest.js +44 -43
  164. package/src/components/modules/filter/radio-item.js +53 -51
  165. package/src/components/modules/filter/search.js +92 -91
  166. package/src/components/modules/filter/sort.js +83 -83
  167. package/src/components/modules/grid.js +55 -56
  168. package/src/components/modules/icon.js +33 -33
  169. package/src/components/modules/jobListing/listing-details.js +94 -88
  170. package/src/components/modules/maps/info-window-card.js +17 -17
  171. package/src/components/modules/maps/info-window-content.js +58 -60
  172. package/src/components/modules/maps/list/field-mapper.js +112 -111
  173. package/src/components/modules/maps/list/header-item.js +91 -90
  174. package/src/components/modules/maps/list/header.js +47 -46
  175. package/src/components/modules/maps/list/index.js +107 -104
  176. package/src/components/modules/maps/list/item-expand-card/index.js +22 -21
  177. package/src/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js +50 -48
  178. package/src/components/modules/maps/list/item-expand-card/recruiter-details.js +68 -67
  179. package/src/components/modules/maps/list/item-expand-card/recruiter-headshot.js +22 -22
  180. package/src/components/modules/maps/list/list-item/index.js +134 -133
  181. package/src/components/modules/maps/map-list.js +74 -73
  182. package/src/components/modules/maps/map-marker.js +86 -84
  183. package/src/components/modules/maps/map.js +229 -226
  184. package/src/components/modules/maps/place-marker.js +1 -1
  185. package/src/components/modules/maps/tabs.js +81 -79
  186. package/src/constants/placeTypes.js +8 -8
  187. package/src/contexts/mapContext.js +20 -19
  188. package/src/contexts/mapListContext.js +20 -15
  189. package/src/contexts/placesContext.js +4 -0
  190. package/src/hooks/useList.js +12 -10
  191. package/src/index.js +3 -103
  192. package/src/services/configService.js +16 -16
  193. package/src/services/googlePlacesNearbyService.js +33 -33
  194. package/src/services/listingAggregatorService.js +5 -4
  195. package/src/services/listingEntityService.js +2 -1
  196. package/src/services/listingService.js +27 -28
  197. package/src/services/recruiterService.js +17 -17
  198. package/src/styles/{globals.css → index.css} +23 -23
  199. package/src/util/arrayUtil.js +3 -3
  200. package/src/util/fieldMapper.js +22 -19
  201. package/src/util/filterUtil.js +19 -19
  202. package/src/util/loading.js +17 -17
  203. package/src/util/localStorageUtil.js +26 -26
  204. package/src/util/mapIconUtil.js +3 -3
  205. package/src/util/sortUtil.js +32 -32
  206. package/src/util/stringUtils.js +6 -6
  207. package/{src/tailwind/tailwind.config.js → tailwind.config.js} +126 -127
  208. package/dist/globals.css +0 -3
  209. package/dist/output.css +0 -784
  210. package/dist/services/globals.css +0 -3
  211. package/rollup.config.js +0 -68
  212. package/src/components/layout/footer.js +0 -34
  213. package/src/components/layout/header.js +0 -23
  214. package/src/components/layout/layout.js +0 -36
  215. package/src/components/modules/animations/slidein.js +0 -41
  216. package/src/components/modules/navigation/nav-link.js +0 -65
  217. package/src/components/modules/navigation/navbar.js +0 -106
  218. package/src/components/modules/navigation/skip-link.js +0 -21
  219. package/src/components/modules/navigation/social.js +0 -29
  220. package/src/components/modules/sections/default.js +0 -59
  221. package/src/components/modules/sections/sectionContext.js +0 -4
  222. package/src/hooks/useClickOutside.js +0 -16
  223. package/src/hooks/useEventListener.js +0 -25
  224. package/src/hooks/useEventTracker.js +0 -19
  225. package/src/hooks/useRefScrollProgress.js +0 -24
  226. package/src/hooks/useScript.js +0 -63
  227. package/src/hooks/useScrollDirection.js +0 -39
  228. package/src/hooks/useSectionTracker.js +0 -95
  229. package/src/hooks/useUserAgent.js +0 -43
  230. package/src/hooks/useWindowSize.js +0 -28
  231. package/src/index.css +0 -25
  232. package/src/styles/fonts.js +0 -0
  233. package/src/util/page-head.js +0 -62
  234. package/src/util/provider.js +0 -12
@@ -1,226 +1,229 @@
1
- import React, { useEffect, useRef } from "react";
2
- import { GoogleMap, MarkerClustererF } from "@react-google-maps/api";
3
- import MapMarker from "./map-marker";
4
- import { usePlaces } from "~/contexts/placesContext";
5
- import { useMap } from "~/contexts/mapContext";
6
- import { markerIconSelected, markerIcon, pinIcon } from "~/util/mapIconUtil";
7
- import { clusterOptions } from "~/util/mapUtil";
8
- import { useMapList } from "~/contexts/mapListContext";
9
- import PlaceMarker from "./place-marker";
10
- import ShowAllButton from "../buttons/show-all-button";
11
-
12
- const Map = ({
13
- markerConfigs,
14
- infoWindowClasses,
15
- clusterGridSize = 60
16
- }) => {
17
- const {
18
- location,
19
- zoom,
20
- center,
21
- commuteLocation,
22
- selectLocationEntity,
23
- setLocation,
24
- mapInteracted,
25
- setMapInteracted
26
- } = useMap();
27
-
28
- const {
29
- mapItems, handleFilterListingsByLocation, filteredListings, setSelectedFilters,
30
- setQuery
31
- } = useMapList();
32
-
33
- const mapRef = useRef();
34
- const markerRefs = useRef({});
35
- const mapContainerRef = useRef(null);
36
- const {
37
- poiMarkers,
38
- setCurrentCenter,
39
- currentCenter,
40
- setCurrentZoom,
41
- currentZoom,
42
- selectedPlaceMarker,
43
- setSelectedPlaceMarker,
44
- placesWindow,
45
- setPlacesWindow } = usePlaces();
46
-
47
- const onIdle = () => {
48
- if (!currentCenter || !mapRef.current) return;
49
- const newCenter = mapRef.current.getCenter().toJSON();
50
- const newZoom = mapRef.current.zoom;
51
-
52
- setCurrentCenter(newCenter);
53
-
54
- if (newZoom != currentZoom) {
55
- setCurrentZoom(newZoom);
56
- }
57
- };
58
-
59
- useEffect(() => {
60
- if (mapContainerRef.current) {
61
- const handleScroll = () => {
62
- setMapInteracted(true);
63
- };
64
- var mapContainerRefCurrent = mapContainerRef.current;
65
- mapContainerRef.current.addEventListener('wheel', handleScroll);
66
- return () => mapContainerRefCurrent.removeEventListener('wheel', handleScroll);
67
- }
68
- }, [mapContainerRef.current]);
69
-
70
- useEffect(() => {
71
- if (mapRef.current) {
72
- const mapInstance = mapRef.current;
73
- const dragStartListener = mapInstance.addListener('dragstart', () => setMapInteracted(true));
74
- const mouseDownListener = mapInstance.addListener('mousedown', () => setMapInteracted(true));
75
- return () => {
76
- google.maps.event.removeListener(dragStartListener);
77
- google.maps.event.removeListener(mouseDownListener);
78
- };
79
- }
80
- }, [mapRef.current, mapContainerRef.current]);
81
-
82
- useEffect(() => {
83
- if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current) {
84
- fitBounds(mapRef.current);
85
- }
86
- }, [mapItems, mapRef.current, location]);
87
-
88
- useEffect(() => {
89
- if (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && mapRef.current && mapInteracted) {
90
- fitBounds(mapRef.current, true);
91
- }
92
- if (mapRef.current) {
93
- let currZoom = mapRef.current.zoom;
94
- let setZoomVal = currZoom < 13 ? currZoom : 12;
95
- mapRef.current.setZoom(setZoomVal);
96
- }
97
- }, [filteredListings]);
98
-
99
- useEffect(() => {
100
- if (!mapRef.current || !location || mapInteracted) return;
101
- mapRef.current.panTo(
102
- new google.maps.LatLng(location.latitude, location.longitude),
103
- );
104
- if (mapRef.current) {
105
- let setZoomVal = zoom < 13 ? zoom : 12;
106
- mapRef.current.setZoom(setZoomVal);
107
- }
108
- }, [location, zoom, mapRef.current]);
109
-
110
- const fitBounds = (map, overload = false) => {
111
- if ((mapInteracted === false || overload) && mapItems != null) {
112
- const bounds = new window.google.maps.LatLngBounds();
113
- mapItems.forEach(item => {
114
- bounds.extend(new google.maps.LatLng(item.latitude, item.longitude));
115
- });
116
- if (!map) return;
117
- map.fitBounds(bounds);
118
- }
119
- if (mapRef.current.zoom > 17) {
120
- mapRef.current.setZoom(16);
121
- }
122
- };
123
-
124
- const markerClickHandler = mapLocation => {
125
- setMapInteracted(true);
126
- selectLocationEntity(mapLocation);
127
- };
128
-
129
- const onLoad = map => {
130
- if (!location || location === null) {
131
- mapRef.current = map;
132
- fitBounds(map, true);
133
- return;
134
- }
135
- mapRef.current = map;
136
-
137
- if (mapInteracted === false) {
138
- mapRef.current.panTo(
139
- new google.maps.LatLng(location.latitude, location.longitude),
140
- );
141
-
142
- mapRef.current.setZoom(zoom);
143
- }
144
- };
145
-
146
- const pinIconUrl = pinIcon({
147
- fillColor: markerConfigs.fillColor,
148
- strokeColor: markerConfigs.strokeColor
149
- });
150
-
151
- return (
152
- <>{zoom && center && <div ref={mapContainerRef} className="hc-h-full hc-relative">
153
- <GoogleMap
154
- zoom={zoom}
155
- onLoad={onLoad}
156
- onIdle={onIdle}
157
- center={center}
158
- mapContainerStyle={{
159
- width: "100%",
160
- height: "100%"
161
- }}
162
- options={{
163
- styles: [
164
- {
165
- featureType: "poi",
166
- elementType: "labels",
167
- stylers: [{ visibility: "off" }]
168
- }
169
- ]
170
- }}
171
- >
172
- <MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>
173
- {clusterer => (
174
- <>
175
- {mapItems.map(item => (
176
- <MapMarker
177
- key={item.id}
178
- item={item}
179
- selectedLocation={location}
180
- markerRefs={markerRefs}
181
- infoWindowClasses={infoWindowClasses}
182
- setSelectedLocation={setLocation}
183
- markerClickHandler={markerClickHandler}
184
- clusterer={clusterer}
185
- markerIcon={markerIcon(markerConfigs)}
186
- markerIconSelected={markerIconSelected(markerConfigs)}
187
- setMapInteracted={setMapInteracted}
188
- />
189
- ))}
190
- {poiMarkers && poiMarkers.markers.map((marker, index) => {
191
- return (
192
- <PlaceMarker
193
- key={`marker-${marker.title}-${index}`}
194
- marker={marker}
195
- index={index}
196
- selectedPlaceMarker={selectedPlaceMarker}
197
- placesWindow={placesWindow}
198
- setPlacesWindow={setPlacesWindow}
199
- setSelectedPlaceMarker={setSelectedPlaceMarker}
200
- />
201
- );
202
- })}
203
- </>
204
- )}
205
- </MarkerClustererF>
206
- </GoogleMap>
207
- {mapInteracted && markerConfigs && (
208
- <ShowAllButton
209
- mapInteracted={mapInteracted}
210
- markerConfigs={markerConfigs}
211
- setMapInteracted={setMapInteracted}
212
- fitBounds={fitBounds}
213
- mapRef={mapRef}
214
- pinIconUrl={pinIconUrl}
215
- setQuery={setQuery}
216
- listingCount={filteredListings.length}
217
- setSelectedFilters={setSelectedFilters}
218
- />
219
- )}
220
- </div>
221
- }
222
- </>
223
- );
224
- };
225
-
226
- export default Map;
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { GoogleMap, MarkerClustererF } from "@react-google-maps/api";
3
+
4
+ import MapMarker from "~/components/modules/maps/map-marker";
5
+ import PlaceMarker from "~/components/modules/maps/place-marker";
6
+ import ShowAllButton from "~/components/modules/buttons/show-all-button";
7
+
8
+ import { usePlaces } from "~/contexts/placesContext";
9
+ import { useMap } from "~/contexts/mapContext";
10
+ import { useMapList } from "~/contexts/mapListContext";
11
+
12
+ import { markerIconSelected, markerIcon, pinIcon } from "~/util/mapIconUtil";
13
+ import { clusterOptions } from "~/util/mapUtil";
14
+
15
+ const Map = ({
16
+ markerConfigs,
17
+ infoWindowClasses,
18
+ clusterGridSize = 60
19
+ }) => {
20
+ const {
21
+ location,
22
+ zoom,
23
+ center,
24
+ commuteLocation,
25
+ selectLocationEntity,
26
+ setLocation,
27
+ mapInteracted,
28
+ setMapInteracted
29
+ } = useMap();
30
+
31
+ const {
32
+ mapItems, handleFilterListingsByLocation, filteredListings, setSelectedFilters,
33
+ setQuery
34
+ } = useMapList();
35
+
36
+ const mapRef = useRef();
37
+ const markerRefs = useRef({});
38
+ const mapContainerRef = useRef(null);
39
+ const {
40
+ poiMarkers,
41
+ setCurrentCenter,
42
+ currentCenter,
43
+ setCurrentZoom,
44
+ currentZoom,
45
+ selectedPlaceMarker,
46
+ setSelectedPlaceMarker,
47
+ placesWindow,
48
+ setPlacesWindow } = usePlaces();
49
+
50
+ const onIdle = () => {
51
+ if (!currentCenter || !mapRef.current) return;
52
+ const newCenter = mapRef.current.getCenter().toJSON();
53
+ const newZoom = mapRef.current.zoom;
54
+
55
+ setCurrentCenter(newCenter);
56
+
57
+ if (newZoom != currentZoom) {
58
+ setCurrentZoom(newZoom);
59
+ }
60
+ };
61
+
62
+ useEffect(() => {
63
+ if (mapContainerRef.current) {
64
+ const handleScroll = () => {
65
+ setMapInteracted(true);
66
+ };
67
+ var mapContainerRefCurrent = mapContainerRef.current;
68
+ mapContainerRef.current.addEventListener('wheel', handleScroll);
69
+ return () => mapContainerRefCurrent.removeEventListener('wheel', handleScroll);
70
+ }
71
+ }, [mapContainerRef.current]);
72
+
73
+ useEffect(() => {
74
+ if (mapRef.current) {
75
+ const mapInstance = mapRef.current;
76
+ const dragStartListener = mapInstance.addListener('dragstart', () => setMapInteracted(true));
77
+ const mouseDownListener = mapInstance.addListener('mousedown', () => setMapInteracted(true));
78
+ return () => {
79
+ google.maps.event.removeListener(dragStartListener);
80
+ google.maps.event.removeListener(mouseDownListener);
81
+ };
82
+ }
83
+ }, [mapRef.current, mapContainerRef.current]);
84
+
85
+ useEffect(() => {
86
+ if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current) {
87
+ fitBounds(mapRef.current);
88
+ }
89
+ }, [mapItems, mapRef.current, location]);
90
+
91
+ useEffect(() => {
92
+ if (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && mapRef.current && mapInteracted) {
93
+ fitBounds(mapRef.current, true);
94
+ }
95
+ if (mapRef.current) {
96
+ let currZoom = mapRef.current.zoom;
97
+ let setZoomVal = currZoom < 13 ? currZoom : 12;
98
+ mapRef.current.setZoom(setZoomVal);
99
+ }
100
+ }, [filteredListings]);
101
+
102
+ useEffect(() => {
103
+ if (!mapRef.current || !location || mapInteracted) return;
104
+ mapRef.current.panTo(
105
+ new google.maps.LatLng(location.latitude, location.longitude),
106
+ );
107
+ if (mapRef.current) {
108
+ let setZoomVal = zoom < 13 ? zoom : 12;
109
+ mapRef.current.setZoom(setZoomVal);
110
+ }
111
+ }, [location, zoom, mapRef.current]);
112
+
113
+ const fitBounds = (map, overload = false) => {
114
+ if ((mapInteracted === false || overload) && mapItems != null) {
115
+ const bounds = new window.google.maps.LatLngBounds();
116
+ mapItems.forEach(item => {
117
+ bounds.extend(new google.maps.LatLng(item.latitude, item.longitude));
118
+ });
119
+ if (!map) return;
120
+ map.fitBounds(bounds);
121
+ }
122
+ if (mapRef.current.zoom > 17) {
123
+ mapRef.current.setZoom(16);
124
+ }
125
+ };
126
+
127
+ const markerClickHandler = mapLocation => {
128
+ setMapInteracted(true);
129
+ selectLocationEntity(mapLocation);
130
+ };
131
+
132
+ const onLoad = map => {
133
+ if (!location || location === null) {
134
+ mapRef.current = map;
135
+ fitBounds(map, true);
136
+ return;
137
+ }
138
+ mapRef.current = map;
139
+
140
+ if (mapInteracted === false) {
141
+ mapRef.current.panTo(
142
+ new google.maps.LatLng(location.latitude, location.longitude),
143
+ );
144
+
145
+ mapRef.current.setZoom(zoom);
146
+ }
147
+ };
148
+
149
+ const pinIconUrl = pinIcon({
150
+ fillColor: markerConfigs.fillColor,
151
+ strokeColor: markerConfigs.strokeColor
152
+ });
153
+
154
+ return (
155
+ <>{zoom && center && <div ref={mapContainerRef} className="hc-h-full hc-relative">
156
+ <GoogleMap
157
+ zoom={zoom}
158
+ onLoad={onLoad}
159
+ onIdle={onIdle}
160
+ center={center}
161
+ mapContainerStyle={{
162
+ width: "100%",
163
+ height: "100%"
164
+ }}
165
+ options={{
166
+ styles: [
167
+ {
168
+ featureType: "poi",
169
+ elementType: "labels",
170
+ stylers: [{ visibility: "off" }]
171
+ }
172
+ ]
173
+ }}
174
+ >
175
+ <MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>
176
+ {clusterer => (
177
+ <>
178
+ {mapItems.map(item => (
179
+ <MapMarker
180
+ key={item.id}
181
+ item={item}
182
+ selectedLocation={location}
183
+ markerRefs={markerRefs}
184
+ infoWindowClasses={infoWindowClasses}
185
+ setSelectedLocation={setLocation}
186
+ markerClickHandler={markerClickHandler}
187
+ clusterer={clusterer}
188
+ markerIcon={markerIcon(markerConfigs)}
189
+ markerIconSelected={markerIconSelected(markerConfigs)}
190
+ setMapInteracted={setMapInteracted}
191
+ />
192
+ ))}
193
+ {poiMarkers && poiMarkers.markers.map((marker, index) => {
194
+ return (
195
+ <PlaceMarker
196
+ key={`marker-${marker.title}-${index}`}
197
+ marker={marker}
198
+ index={index}
199
+ selectedPlaceMarker={selectedPlaceMarker}
200
+ placesWindow={placesWindow}
201
+ setPlacesWindow={setPlacesWindow}
202
+ setSelectedPlaceMarker={setSelectedPlaceMarker}
203
+ />
204
+ );
205
+ })}
206
+ </>
207
+ )}
208
+ </MarkerClustererF>
209
+ </GoogleMap>
210
+ {mapInteracted && markerConfigs && (
211
+ <ShowAllButton
212
+ mapInteracted={mapInteracted}
213
+ markerConfigs={markerConfigs}
214
+ setMapInteracted={setMapInteracted}
215
+ fitBounds={fitBounds}
216
+ mapRef={mapRef}
217
+ pinIconUrl={pinIconUrl}
218
+ setQuery={setQuery}
219
+ listingCount={filteredListings.length}
220
+ setSelectedFilters={setSelectedFilters}
221
+ />
222
+ )}
223
+ </div>
224
+ }
225
+ </>
226
+ );
227
+ };
228
+
229
+ export default Map;
@@ -25,7 +25,7 @@ const PlaceMarker = ({
25
25
  options={{ optimized: false }}
26
26
  onClick={placeMarkerClickHandler}
27
27
  >
28
- {selectedPlaceMarker === markerKey && placesWindow && marker &&(
28
+ {selectedPlaceMarker === markerKey && placesWindow && marker && (
29
29
  <InfoWindowF
30
30
  position={marker.position}
31
31
  onCloseClick={() => setPlacesWindow(false)}
@@ -1,79 +1,81 @@
1
- import * as Tabs from "@radix-ui/react-tabs";
2
- import Button from "~/components/modules/buttons/default";
3
- import { useMapList } from "~/contexts/mapListContext";
4
- import React from 'react'
5
-
6
- const MapTabs = ({
7
- map,
8
- list,
9
- filter,
10
- className,
11
- showMap
12
- }) => {
13
- const tabButtonClasses =
14
- "hc-flex hc-items-center hc-gap-2 hc-rounded-none hc-border-x-0 data-[state=active]:hc-bg-primary data-[state=active]:hc-text-white";
15
- const { mobileTab, setMobileTab } = useMapList();
16
- return (
17
- <div
18
- className={`
19
- hc-relative hc-overflow-hidden
20
- ${className ?? ""}
21
- `}
22
- >
23
- <Tabs.Root
24
- className="hc-flex hc-flex-col hc-h-screen hc-min-h-screen"
25
- //defaultValue="listTab"
26
- value={mobileTab}
27
- >
28
- <Tabs.List
29
- className="hc-w-full hc-shrink-0 hc-flex hc-divide-x hc-divide-primary"
30
- aria-label="Review positions"
31
- >
32
- <Tabs.Trigger value="listTab" asChild onClick={() => setMobileTab("listTab")}>
33
- <Button.Btn variant="outline" isBlock className={tabButtonClasses}>
34
- <Button.Body className="hc-justify-center">
35
- <Button.Icon icon="mdi:view-list" size="hc-size-5" />
36
- List
37
- </Button.Body>
38
- </Button.Btn>
39
- </Tabs.Trigger>
40
- {showMap && (
41
- <Tabs.Trigger value="mapTab" asChild onClick={() => setMobileTab("mapTab")}>
42
- <Button.Btn
43
- variant="outline"
44
- isBlock
45
- className={tabButtonClasses}
46
- >
47
- <Button.Body className="hc-justify-center">
48
- <Button.Icon icon="mdi:map" size="hc-size-5" />
49
- Map
50
- </Button.Body>
51
- </Button.Btn>
52
- </Tabs.Trigger>
53
- )}
54
- <Tabs.Trigger value="filterTab" asChild onClick={() => setMobileTab("filterTab")}>
55
- <Button.Btn variant="outline" isBlock className={tabButtonClasses}>
56
- <Button.Body className="hc-justify-center">
57
- <Button.Icon icon="fluent:search-12-filled" size="hc-size-5" />
58
- Filter
59
- </Button.Body>
60
- </Button.Btn>
61
- </Tabs.Trigger>
62
- </Tabs.List>
63
- <Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="listTab">
64
- {list}
65
- </Tabs.Content>
66
- {showMap && (
67
- <Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="mapTab">
68
- {map}
69
- </Tabs.Content>
70
- )}
71
- <Tabs.Content className="hc-grow hc-bg-white hc-outline-none hc-p-2" value="filterTab">
72
- {filter}
73
- </Tabs.Content>
74
- </Tabs.Root>
75
- </div>
76
- );
77
- };
78
-
79
- export default MapTabs;
1
+ import React from 'react'
2
+ import * as Tabs from '@radix-ui/react-tabs';
3
+
4
+ import Button from '~/components/modules/buttons/default';
5
+
6
+ import { useMapList } from '~/contexts/mapListContext';
7
+
8
+ const MapTabs = ({
9
+ map,
10
+ list,
11
+ filter,
12
+ className,
13
+ showMap
14
+ }) => {
15
+ const tabButtonClasses =
16
+ "hc-flex hc-items-center hc-gap-2 hc-rounded-none hc-border-x-0 data-[state=active]:hc-bg-primary data-[state=active]:hc-text-white";
17
+ const { mobileTab, setMobileTab } = useMapList();
18
+ return (
19
+ <div
20
+ className={`
21
+ hc-relative hc-overflow-hidden
22
+ ${className ?? ""}
23
+ `}
24
+ >
25
+ <Tabs.Root
26
+ className="hc-flex hc-flex-col hc-h-screen hc-min-h-screen"
27
+ //defaultValue="listTab"
28
+ value={mobileTab}
29
+ >
30
+ <Tabs.List
31
+ className="hc-w-full hc-shrink-0 hc-flex hc-divide-x hc-divide-primary"
32
+ aria-label="Review positions"
33
+ >
34
+ <Tabs.Trigger value="listTab" asChild onClick={() => setMobileTab("listTab")}>
35
+ <Button.Btn variant="outline" isBlock className={tabButtonClasses}>
36
+ <Button.Body className="hc-justify-center">
37
+ <Button.Icon icon="mdi:view-list" size="hc-size-5" />
38
+ List
39
+ </Button.Body>
40
+ </Button.Btn>
41
+ </Tabs.Trigger>
42
+ {showMap && (
43
+ <Tabs.Trigger value="mapTab" asChild onClick={() => setMobileTab("mapTab")}>
44
+ <Button.Btn
45
+ variant="outline"
46
+ isBlock
47
+ className={tabButtonClasses}
48
+ >
49
+ <Button.Body className="hc-justify-center">
50
+ <Button.Icon icon="mdi:map" size="hc-size-5" />
51
+ Map
52
+ </Button.Body>
53
+ </Button.Btn>
54
+ </Tabs.Trigger>
55
+ )}
56
+ <Tabs.Trigger value="filterTab" asChild onClick={() => setMobileTab("filterTab")}>
57
+ <Button.Btn variant="outline" isBlock className={tabButtonClasses}>
58
+ <Button.Body className="hc-justify-center">
59
+ <Button.Icon icon="fluent:search-12-filled" size="hc-size-5" />
60
+ Filter
61
+ </Button.Body>
62
+ </Button.Btn>
63
+ </Tabs.Trigger>
64
+ </Tabs.List>
65
+ <Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="listTab">
66
+ {list}
67
+ </Tabs.Content>
68
+ {showMap && (
69
+ <Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="mapTab">
70
+ {map}
71
+ </Tabs.Content>
72
+ )}
73
+ <Tabs.Content className="hc-grow hc-bg-white hc-outline-none hc-p-2" value="filterTab">
74
+ {filter}
75
+ </Tabs.Content>
76
+ </Tabs.Root>
77
+ </div>
78
+ );
79
+ };
80
+
81
+ export default MapTabs;
@@ -1,8 +1,8 @@
1
- export const placeTypes = {
2
- FOOD: "food",
3
- STORE: "shopping",
4
- TOURIST_ATTRACTION: "attractions",
5
- TRANSIT_STATION: "transit",
6
- SCHOOL: "schools",
7
- PLACE_OF_WORSHIP: "worship"
8
- };
1
+ export const placeTypes = {
2
+ FOOD: "food",
3
+ STORE: "shopping",
4
+ TOURIST_ATTRACTION: "attractions",
5
+ TRANSIT_STATION: "transit",
6
+ SCHOOL: "schools",
7
+ PLACE_OF_WORSHIP: "worship"
8
+ };