@terraware/web-components 3.5.12-rc.7 → 3.5.12

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 (230) hide show
  1. package/components/AntSwitch/index.js +27 -0
  2. package/components/AntSwitch/styles.scss +66 -0
  3. package/components/Autocomplete/Autocomplete.js +131 -0
  4. package/components/Autocomplete/styles.scss +155 -0
  5. package/components/Badge/index.js +32 -0
  6. package/components/BusySpinner/index.js +49 -0
  7. package/components/Button/Button.js +51 -0
  8. package/components/Button/button.test.js +25 -0
  9. package/components/Button/styles.scss +453 -0
  10. package/components/Checkbox.js +70 -0
  11. package/components/Confirm/index.js +94 -0
  12. package/components/DatePicker/DatePicker.js +150 -0
  13. package/components/DatePicker/styles.scss +95 -0
  14. package/components/DialogBox/DialogBox.js +91 -0
  15. package/components/DialogBox/styles.scss +165 -0
  16. package/components/Divisor.js +21 -0
  17. package/components/Dropdown.js +102 -0
  18. package/components/ErrorBox/ErrorBox.js +47 -0
  19. package/components/ErrorBox/styles.scss +63 -0
  20. package/components/FileChooser/index.js +137 -0
  21. package/components/FormBottomBar/index.js +90 -0
  22. package/components/Icon/Icon.js +25 -0
  23. package/components/Icon/icons/index.js +241 -0
  24. package/components/Icon/styles.scss +41 -0
  25. package/components/IconTooltip/index.js +61 -0
  26. package/components/Map/MapBox.d.ts.map +1 -1
  27. package/components/Map/MapBox.js +479 -0
  28. package/components/Map/MapContainer.js +30 -0
  29. package/components/Map/MapDateSliderControl.js +66 -0
  30. package/components/Map/MapDrawer.js +45 -0
  31. package/components/Map/MapLegend.js +172 -0
  32. package/components/Map/MapViewStyleControl.js +74 -0
  33. package/components/Map/ReactMapboxWrapper.d.ts +3 -0
  34. package/components/Map/ReactMapboxWrapper.d.ts.map +1 -0
  35. package/components/Map/ReactMapboxWrapper.js +9 -0
  36. package/components/Map/index.js +190 -0
  37. package/components/Map/styles.scss +130 -0
  38. package/components/Map/types.js +24 -0
  39. package/components/Map/useMaintainLayerOrder.js +32 -0
  40. package/components/Message/Message.js +67 -0
  41. package/components/Message/styles.scss +202 -0
  42. package/components/MultiSelect/MultiSelect.test.js +75 -0
  43. package/components/MultiSelect/index.js +120 -0
  44. package/components/MultiSelect/styles.scss +180 -0
  45. package/components/Navbar/NavFooter.js +17 -0
  46. package/components/Navbar/NavItem.js +73 -0
  47. package/components/Navbar/NavSection.js +22 -0
  48. package/components/Navbar/Navbar.js +46 -0
  49. package/components/Navbar/SubNavbar.js +17 -0
  50. package/components/Navbar/styles.scss +155 -0
  51. package/components/Note.js +25 -0
  52. package/components/PageForm/index.js +43 -0
  53. package/components/PhotoChooser/index.js +137 -0
  54. package/components/Pill/index.js +46 -0
  55. package/components/Pill/styles.scss +50 -0
  56. package/components/PillList/index.js +29 -0
  57. package/components/PillList/styles.scss +12 -0
  58. package/components/PlacementWrapper/index.js +63 -0
  59. package/components/PopoverMenu/Popover.js +88 -0
  60. package/components/PopoverMenu/index.js +59 -0
  61. package/components/PopoverMultiSelect/index.js +62 -0
  62. package/components/PopoverMultiSelect/styles.scss +10 -0
  63. package/components/ProgressCircle/ProgressCircle.js +34 -0
  64. package/components/ProgressCircle/styles.scss +87 -0
  65. package/components/RadioButton.js +25 -0
  66. package/components/Select/Select.js +19 -0
  67. package/components/Select/SelectT.js +245 -0
  68. package/components/Select/styles.scss +307 -0
  69. package/components/Separator/index.js +21 -0
  70. package/components/Size.js +5 -0
  71. package/components/Slider/index.js +60 -0
  72. package/components/SummaryBox.js +73 -0
  73. package/components/Tabs/index.js +111 -0
  74. package/components/TextTruncated/index.js +146 -0
  75. package/components/Textfield/Textfield.js +172 -0
  76. package/components/Textfield/TruncatedTextArea.js +71 -0
  77. package/components/Textfield/styles.scss +271 -0
  78. package/components/Tooltip/Tooltip.js +54 -0
  79. package/components/ViewPhotosDialog/index.js +136 -0
  80. package/components/ViewPhotosDialog/styles.scss +18 -0
  81. package/components/svg/BlobbyGrayIconImage.js +39 -0
  82. package/components/svg/BlobbyGrayIconImport.js +39 -0
  83. package/components/svg/BlobbyGrayIconUploadToTheCloud.js +39 -0
  84. package/components/svg/BlobbyIconCloudChecked.js +156 -0
  85. package/components/svg/BlobbyIconExportOrUploadPhoto.js +156 -0
  86. package/components/svg/BlobbyIconFolder.js +156 -0
  87. package/components/svg/BlobbyIconGraphReport.js +156 -0
  88. package/components/svg/BlobbyIconHappy.js +156 -0
  89. package/components/svg/BlobbyIconHeartMonitor.js +156 -0
  90. package/components/svg/BlobbyIconLeaf.js +156 -0
  91. package/components/svg/BlobbyIconLibrary.js +156 -0
  92. package/components/svg/BlobbyIconNursery.js +158 -0
  93. package/components/svg/BlobbyIconOrganization.js +156 -0
  94. package/components/svg/BlobbyIconParchment.js +156 -0
  95. package/components/svg/BlobbyIconPeople.js +156 -0
  96. package/components/svg/BlobbyIconSeedBank.js +156 -0
  97. package/components/svg/BlobbyIconSeedling.js +156 -0
  98. package/components/svg/BlobbyIconSeeds.js +156 -0
  99. package/components/svg/BlobbyIconSite.js +159 -0
  100. package/components/svg/BlobbyIconSparkles.js +156 -0
  101. package/components/svg/BlobbyIconWrench.js +156 -0
  102. package/components/svg/Bug.js +25 -0
  103. package/components/svg/Calendar.js +25 -0
  104. package/components/svg/CaretDown.js +25 -0
  105. package/components/svg/CaretLeft.js +25 -0
  106. package/components/svg/CaretRight.js +25 -0
  107. package/components/svg/CaretUp.js +25 -0
  108. package/components/svg/ChevronDown.js +25 -0
  109. package/components/svg/ChevronUp.js +25 -0
  110. package/components/svg/Close.js +25 -0
  111. package/components/svg/Critical.js +25 -0
  112. package/components/svg/Edit.js +156 -0
  113. package/components/svg/Error.js +25 -0
  114. package/components/svg/Filter.js +25 -0
  115. package/components/svg/Folder.js +25 -0
  116. package/components/svg/Help.js +25 -0
  117. package/components/svg/Home.js +25 -0
  118. package/components/svg/IconAdd.js +25 -0
  119. package/components/svg/IconArrowRight.js +27 -0
  120. package/components/svg/IconBusinessNetwork.js +25 -0
  121. package/components/svg/IconCancel.js +25 -0
  122. package/components/svg/IconChargingBattery.js +25 -0
  123. package/components/svg/IconCheckmark.js +25 -0
  124. package/components/svg/IconCoinInHand.js +25 -0
  125. package/components/svg/IconColumns.js +25 -0
  126. package/components/svg/IconComment.js +26 -0
  127. package/components/svg/IconDashboard.js +25 -0
  128. package/components/svg/IconDataMigration.js +25 -0
  129. package/components/svg/IconEdit.js +27 -0
  130. package/components/svg/IconExport.js +25 -0
  131. package/components/svg/IconExternalLink.js +25 -0
  132. package/components/svg/IconEye.js +25 -0
  133. package/components/svg/IconEyeOff.js +25 -0
  134. package/components/svg/IconFile.js +25 -0
  135. package/components/svg/IconFolder.js +25 -0
  136. package/components/svg/IconFullScreen.js +26 -0
  137. package/components/svg/IconFutures.js +25 -0
  138. package/components/svg/IconGraphReport.js +25 -0
  139. package/components/svg/IconHeartMonitor.js +25 -0
  140. package/components/svg/IconHelp.js +27 -0
  141. package/components/svg/IconHistory.js +25 -0
  142. package/components/svg/IconImport.js +25 -0
  143. package/components/svg/IconIndex.js +25 -0
  144. package/components/svg/IconLayers.js +25 -0
  145. package/components/svg/IconLibrary.js +26 -0
  146. package/components/svg/IconList.js +25 -0
  147. package/components/svg/IconLivePlant.js +25 -0
  148. package/components/svg/IconLocations.js +25 -0
  149. package/components/svg/IconMail.js +25 -0
  150. package/components/svg/IconManager.js +25 -0
  151. package/components/svg/IconMarker.js +25 -0
  152. package/components/svg/IconMenu.js +25 -0
  153. package/components/svg/IconMenuHorizontal.js +25 -0
  154. package/components/svg/IconModule.js +25 -0
  155. package/components/svg/IconMyLocation.js +25 -0
  156. package/components/svg/IconNote.js +27 -0
  157. package/components/svg/IconNursery.js +27 -0
  158. package/components/svg/IconOrg.js +25 -0
  159. package/components/svg/IconParchment.js +25 -0
  160. package/components/svg/IconPhoto.js +25 -0
  161. package/components/svg/IconRedo.js +25 -0
  162. package/components/svg/IconRestorationSite.js +25 -0
  163. package/components/svg/IconSeedBank.js +25 -0
  164. package/components/svg/IconSeedling.js +25 -0
  165. package/components/svg/IconSettings.js +25 -0
  166. package/components/svg/IconSlice.js +25 -0
  167. package/components/svg/IconSubmit.js +25 -0
  168. package/components/svg/IconSubtract.js +27 -0
  169. package/components/svg/IconSynced.js +25 -0
  170. package/components/svg/IconTrashCan.js +25 -0
  171. package/components/svg/IconTreasureMap.js +25 -0
  172. package/components/svg/IconUndo.js +25 -0
  173. package/components/svg/IconVariable.js +25 -0
  174. package/components/svg/IconWifi.js +25 -0
  175. package/components/svg/Info.js +25 -0
  176. package/components/svg/Key.js +25 -0
  177. package/components/svg/Leaf.js +25 -0
  178. package/components/svg/Lock.js +25 -0
  179. package/components/svg/Logo.js +43 -0
  180. package/components/svg/MenuVertical.js +25 -0
  181. package/components/svg/Notification.js +25 -0
  182. package/components/svg/Person.js +25 -0
  183. package/components/svg/Plus.js +25 -0
  184. package/components/svg/RestorationSite.js +25 -0
  185. package/components/svg/Search.js +25 -0
  186. package/components/svg/Seeds.js +25 -0
  187. package/components/svg/Site.js +25 -0
  188. package/components/svg/Sparkles.js +25 -0
  189. package/components/svg/Species.js +25 -0
  190. package/components/svg/Species2.js +156 -0
  191. package/components/svg/Spinner.js +52 -0
  192. package/components/svg/Success.js +25 -0
  193. package/components/svg/SuccessFilled.js +25 -0
  194. package/components/svg/TerrawareLogoDesktop.js +49 -0
  195. package/components/svg/TerrawareLogoMobile.js +30 -0
  196. package/components/svg/Touchscreen.js +25 -0
  197. package/components/svg/UploadCloud.js +156 -0
  198. package/components/svg/Warning.js +25 -0
  199. package/components/svg/WelcomeClipboard.js +133 -0
  200. package/components/svg/index.js +832 -0
  201. package/components/table/EnhancedTableToolbar.js +76 -0
  202. package/components/table/EnhancedTableToolbarV2.js +49 -0
  203. package/components/table/TableCellRenderer.js +244 -0
  204. package/components/table/TableHeader.js +75 -0
  205. package/components/table/TableHeaderItem.js +100 -0
  206. package/components/table/density.js +28 -0
  207. package/components/table/index.js +346 -0
  208. package/components/table/sort.js +72 -0
  209. package/components/table/sort.test.js +37 -0
  210. package/components/table/types.js +5 -0
  211. package/components/types/index.js +5 -0
  212. package/fonts/Inter.ttf +0 -0
  213. package/index.css +11 -0
  214. package/index.js +377 -0
  215. package/package.json +2 -5
  216. package/setupTests.js +5 -0
  217. package/style-dictionary-dist/TerrawareTheme.js +193 -0
  218. package/style-dictionary-dist/terraware.scss +414 -0
  219. package/theme.js +86 -0
  220. package/utils/date.js +124 -0
  221. package/utils/date.test.js +87 -0
  222. package/utils/index.js +53 -0
  223. package/utils/preventDefaultEvent.js +8 -0
  224. package/utils/text.js +17 -0
  225. package/utils/text.test.js +23 -0
  226. package/utils/useDeviceInfo.js +85 -0
  227. package/index.cjs.js +0 -88606
  228. package/index.cjs.js.map +0 -1
  229. package/index.esm.js +0 -88533
  230. package/index.esm.js.map +0 -1
@@ -0,0 +1,479 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _mapbox = require("react-map-gl/mapbox");
11
+ var _material = require("@mui/material");
12
+ require("mapbox-gl/dist/mapbox-gl.css");
13
+ var _utils = require("../../utils");
14
+ var _Icon = _interopRequireDefault(require("../Icon/Icon"));
15
+ var _MapViewStyleControl = _interopRequireDefault(require("./MapViewStyleControl"));
16
+ var _ReactMapboxWrapper = _interopRequireDefault(require("./ReactMapboxWrapper"));
17
+ var _types = require("./types");
18
+ var _useMaintainLayerOrder = require("./useMaintainLayerOrder");
19
+ const MapBox = props => {
20
+ const {
21
+ clusterRadius,
22
+ containerId,
23
+ controlBottomLeft,
24
+ controlTopRight,
25
+ cursorInteract,
26
+ cursorMap,
27
+ disableDoubleClickZoom,
28
+ disableZoom,
29
+ drawerOpen,
30
+ layers: featureGroups,
31
+ hideFullScreenControl,
32
+ hideMapViewStyleControl,
33
+ hideZoomControl,
34
+ highlightGroups,
35
+ initialViewState,
36
+ mapId,
37
+ mapImageUrls,
38
+ mapViewStyle,
39
+ markerGroups,
40
+ onClickCanvas,
41
+ setMapViewStyle,
42
+ token
43
+ } = props;
44
+ const theme = (0, _material.useTheme)();
45
+ const mapRef = (0, _react.useRef)(null);
46
+ const {
47
+ isDesktop
48
+ } = (0, _utils.useDeviceInfo)();
49
+ const [cursor, setCursor] = (0, _react.useState)('auto');
50
+ const [hoverFeatureId, setHoverFeatureId] = (0, _react.useState)();
51
+ const [zoom, setZoom] = (0, _react.useState)();
52
+ const loadImages = (0, _react.useCallback)(map => {
53
+ mapImageUrls === null || mapImageUrls === void 0 ? void 0 : mapImageUrls.forEach(url => {
54
+ if (!map.hasImage(url)) {
55
+ map.loadImage(url, (error, image) => {
56
+ if (image) {
57
+ map.addImage(url, image, {
58
+ sdf: true
59
+ });
60
+ }
61
+ });
62
+ }
63
+ });
64
+ }, [mapImageUrls]);
65
+ const mapRefCallback = (0, _react.useCallback)(map => {
66
+ if (map !== null) {
67
+ mapRef.current = map;
68
+ setZoom(map.getZoom());
69
+ loadImages(map);
70
+ }
71
+ }, []);
72
+ const onMove = (0, _react.useCallback)(view => {
73
+ setZoom(view.viewState.zoom);
74
+ }, []);
75
+ const clusterMarkers = (0, _react.useCallback)((map, markers) => {
76
+ if (!map || map.getZoom() > 15) {
77
+ // Too zoomed in. Return all marker as is
78
+ return markers.map(marker => [marker]);
79
+ }
80
+ const visited = new Set();
81
+ const markerPixels = {};
82
+ markers.forEach(marker => {
83
+ markerPixels[marker.id] = map.project({
84
+ lat: marker.latitude,
85
+ lon: marker.longitude
86
+ });
87
+ });
88
+ const clusters = [];
89
+ markers.forEach((marker, idx) => {
90
+ if (!visited.has(marker.id)) {
91
+ const cluster = [marker];
92
+ markers.slice(idx + 1).forEach(otherMarker => {
93
+ if (!visited.has(otherMarker.id)) {
94
+ const dx = markerPixels[marker.id].x - markerPixels[otherMarker.id].x;
95
+ const dy = markerPixels[marker.id].y - markerPixels[otherMarker.id].y;
96
+ const dist = Math.sqrt(dx * dx + dy * dy);
97
+ if (dist <= (clusterRadius !== null && clusterRadius !== void 0 ? clusterRadius : 40)) {
98
+ cluster.push(otherMarker);
99
+ visited.add(otherMarker.id);
100
+ }
101
+ }
102
+ });
103
+ clusters.push(cluster);
104
+ }
105
+ });
106
+ return clusters;
107
+ }, [clusterRadius]);
108
+
109
+ // Find all layers with at least some clickable elements
110
+ const interactiveLayerIds = (0, _react.useMemo)(() => {
111
+ var _featureGroups$filter;
112
+ return featureGroups === null || featureGroups === void 0 ? void 0 : (_featureGroups$filter = featureGroups.filter(group => group.features.some(feature => feature.onClick !== undefined))) === null || _featureGroups$filter === void 0 ? void 0 : _featureGroups$filter.map(group => group.layerId);
113
+ }, [featureGroups]);
114
+ const geojson = (0, _react.useMemo)(() => {
115
+ const features = featureGroups === null || featureGroups === void 0 ? void 0 : featureGroups.flatMap(group => {
116
+ return group.features.map(feature => {
117
+ var _feature$priority, _feature$selected;
118
+ const properties = {
119
+ id: feature.featureId,
120
+ clickable: feature.onClick !== undefined,
121
+ label: feature.label,
122
+ layerFeatureId: "".concat(group.layerId, "/").concat(feature.featureId),
123
+ layerId: group.layerId,
124
+ priority: (_feature$priority = feature.priority) !== null && _feature$priority !== void 0 ? _feature$priority : 0,
125
+ selected: (_feature$selected = feature.selected) !== null && _feature$selected !== void 0 ? _feature$selected : false
126
+ };
127
+ return {
128
+ type: 'Feature',
129
+ geometry: feature.geometry,
130
+ properties
131
+ };
132
+ });
133
+ });
134
+ return features ? {
135
+ type: 'FeatureCollection',
136
+ features
137
+ } : undefined;
138
+ }, [featureGroups]);
139
+ const {
140
+ borderLayers,
141
+ fillLayers,
142
+ textLayers
143
+ } = (0, _react.useMemo)(() => {
144
+ const _borderLayers = featureGroups === null || featureGroups === void 0 ? void 0 : featureGroups.map(group => {
145
+ return /*#__PURE__*/_react.default.createElement(_mapbox.Layer, {
146
+ key: "".concat(group.layerId, "-border"),
147
+ id: "".concat(group.layerId, "-border"),
148
+ source: 'mapData',
149
+ type: "line",
150
+ paint: {
151
+ 'line-color': group.style.borderColor,
152
+ 'line-width': 2
153
+ },
154
+ filter: ['==', ['get', 'layerId'], group.layerId]
155
+ });
156
+ });
157
+ const _fillLayers = featureGroups === null || featureGroups === void 0 ? void 0 : featureGroups.map(group => {
158
+ var _group$style$opacity;
159
+ const opacity = Math.min(0.4, (_group$style$opacity = group.style.opacity) !== null && _group$style$opacity !== void 0 ? _group$style$opacity : 0.2);
160
+ const selectedOpacity = opacity * 2;
161
+ const hoverOpacity = opacity * 1.5;
162
+ const hoverAndSelectedOpacity = opacity * 2.5;
163
+ const groupFilter = ['==', ['get', 'layerId'], group.layerId];
164
+ const clickableFilter = ['==', ['get', 'clickable'], true];
165
+ const selectedFilter = ['==', ['get', 'selected'], true];
166
+ const notSelectedFilter = ['==', ['get', 'selected'], false];
167
+ const hoverFilter = ['==', ['get', 'id'], hoverFeatureId !== null && hoverFeatureId !== void 0 ? hoverFeatureId : null];
168
+ const notHoverFilter = ['!=', ['get', 'id'], hoverFeatureId !== null && hoverFeatureId !== void 0 ? hoverFeatureId : null];
169
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_mapbox.Layer, {
170
+ key: group.layerId,
171
+ id: group.layerId,
172
+ source: 'mapData',
173
+ type: 'fill',
174
+ paint: {
175
+ 'fill-opacity': 0
176
+ },
177
+ filter: ['all', groupFilter, clickableFilter]
178
+ }), /*#__PURE__*/_react.default.createElement(_mapbox.Layer, {
179
+ key: "".concat(group.layerId, "-unselected"),
180
+ id: "".concat(group.layerId, "-unselected"),
181
+ source: 'mapData',
182
+ type: 'fill',
183
+ paint: group.style.fillPatternUrl ? {
184
+ 'fill-pattern': group.style.fillPatternUrl,
185
+ 'fill-opacity': opacity
186
+ } : {
187
+ 'fill-color': group.style.fillColor,
188
+ 'fill-opacity': opacity
189
+ },
190
+ filter: ['all', groupFilter, notSelectedFilter, notHoverFilter]
191
+ }), /*#__PURE__*/_react.default.createElement(_mapbox.Layer, {
192
+ key: "".concat(group.layerId, "-selected"),
193
+ id: "".concat(group.layerId, "-selected"),
194
+ slot: 'bottom',
195
+ source: 'mapData',
196
+ type: 'fill',
197
+ paint: group.style.fillPatternUrl ? {
198
+ 'fill-pattern': group.style.fillPatternUrl,
199
+ 'fill-opacity': selectedOpacity
200
+ } : {
201
+ 'fill-color': group.style.fillColor,
202
+ 'fill-opacity': selectedOpacity
203
+ },
204
+ filter: ['all', groupFilter, selectedFilter, notHoverFilter]
205
+ }), /*#__PURE__*/_react.default.createElement(_mapbox.Layer, {
206
+ key: "".concat(group.layerId, "-hover"),
207
+ id: "".concat(group.layerId, "-hover"),
208
+ source: 'mapData',
209
+ type: 'fill',
210
+ paint: group.style.fillPatternUrl ? {
211
+ 'fill-pattern': group.style.fillPatternUrl,
212
+ 'fill-opacity': hoverOpacity
213
+ } : {
214
+ 'fill-color': group.style.fillColor,
215
+ 'fill-opacity': hoverOpacity
216
+ },
217
+ filter: ['all', groupFilter, hoverFilter, notSelectedFilter]
218
+ }), /*#__PURE__*/_react.default.createElement(_mapbox.Layer, {
219
+ key: "".concat(group.layerId, "-selected-hover"),
220
+ id: "".concat(group.layerId, "-selected-hover"),
221
+ source: 'mapData',
222
+ type: 'fill',
223
+ paint: group.style.fillPatternUrl ? {
224
+ 'fill-pattern': group.style.fillPatternUrl,
225
+ 'fill-opacity': hoverAndSelectedOpacity
226
+ } : {
227
+ 'fill-color': group.style.fillColor,
228
+ 'fill-opacity': hoverAndSelectedOpacity
229
+ },
230
+ filter: ['all', groupFilter, hoverFilter, selectedFilter]
231
+ }));
232
+ });
233
+ const _textLayers = featureGroups === null || featureGroups === void 0 ? void 0 : featureGroups.map(group => {
234
+ const groupFilter = ['==', ['get', 'layerId'], group.layerId];
235
+ const labelFilter = ['has', 'label'];
236
+ return /*#__PURE__*/_react.default.createElement(_mapbox.Layer, {
237
+ key: "".concat(group.layerId, "-label"),
238
+ id: "".concat(group.layerId, "-label"),
239
+ source: 'mapData',
240
+ type: 'symbol',
241
+ layout: {
242
+ 'text-field': ['get', 'label'],
243
+ 'text-size': 14,
244
+ 'text-line-height': 20,
245
+ 'text-font': ['Open Sans Bold', 'Arial Unicode MS Regular'],
246
+ 'text-anchor': 'center',
247
+ 'text-justify': 'center'
248
+ },
249
+ paint: {
250
+ 'text-color': '#ffffff'
251
+ },
252
+ filter: ['all', groupFilter, labelFilter]
253
+ });
254
+ });
255
+ return {
256
+ borderLayers: _borderLayers !== null && _borderLayers !== void 0 ? _borderLayers : [],
257
+ fillLayers: _fillLayers !== null && _fillLayers !== void 0 ? _fillLayers : [],
258
+ textLayers: _textLayers !== null && _textLayers !== void 0 ? _textLayers : []
259
+ };
260
+ }, [featureGroups, hoverFeatureId]);
261
+ const highlightLayers = (0, _react.useMemo)(() => {
262
+ var _highlightGroups$flat;
263
+ return (_highlightGroups$flat = highlightGroups === null || highlightGroups === void 0 ? void 0 : highlightGroups.flatMap(group => {
264
+ return group.highlights.map((highlight, index) => {
265
+ var _highlight$style$opac, _highlight$style$opac2;
266
+ const highlightFeatureIds = highlight.featureIds.map(_ref => {
267
+ let {
268
+ layerId,
269
+ featureId
270
+ } = _ref;
271
+ return "".concat(layerId, "/").concat(featureId);
272
+ });
273
+ return /*#__PURE__*/_react.default.createElement(_mapbox.Layer, {
274
+ key: "highlight-".concat(group.highlightId, "-").concat(index),
275
+ id: "highlight-".concat(group.highlightId, "-").concat(index),
276
+ source: 'mapData',
277
+ type: 'fill',
278
+ paint: highlight.style.fillPatternUrl ? {
279
+ 'fill-pattern': highlight.style.fillPatternUrl,
280
+ 'fill-opacity': (_highlight$style$opac = highlight.style.opacity) !== null && _highlight$style$opac !== void 0 ? _highlight$style$opac : 0.5
281
+ } : {
282
+ 'fill-color': highlight.style.fillColor,
283
+ 'fill-opacity': (_highlight$style$opac2 = highlight.style.opacity) !== null && _highlight$style$opac2 !== void 0 ? _highlight$style$opac2 : 0.5
284
+ },
285
+ filter: ['all', ['has', 'layerFeatureId'], ['match', ['get', 'layerFeatureId'], highlightFeatureIds, true, false]]
286
+ });
287
+ });
288
+ })) !== null && _highlightGroups$flat !== void 0 ? _highlightGroups$flat : [];
289
+ }, [highlightGroups]);
290
+ const markersComponents = (0, _react.useMemo)(() => {
291
+ return markerGroups === null || markerGroups === void 0 ? void 0 : markerGroups.flatMap(markerGroup => {
292
+ // cluster markers here
293
+ const clusteredMarkers = clusterMarkers(mapRef.current, markerGroup.markers);
294
+ return clusteredMarkers.map((markers, i) => {
295
+ if (markers.length === 1) {
296
+ const marker = markers[0];
297
+ return /*#__PURE__*/_react.default.createElement(_mapbox.Marker, {
298
+ className: "map-marker",
299
+ key: "marker-".concat(i),
300
+ longitude: marker.longitude,
301
+ latitude: marker.latitude,
302
+ anchor: "center",
303
+ onClick: event => {
304
+ var _marker$onClick;
305
+ (_marker$onClick = marker.onClick) === null || _marker$onClick === void 0 ? void 0 : _marker$onClick.call(marker);
306
+ event.originalEvent.stopPropagation();
307
+ },
308
+ style: {
309
+ backgroundColor: marker.selected ? markerGroup.style.iconColor : theme.palette.TwClrBg
310
+ }
311
+ }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
312
+ fillColor: marker.selected ? theme.palette.TwClrBg : markerGroup.style.iconColor,
313
+ name: markerGroup.style.iconName,
314
+ size: 'small'
315
+ }));
316
+ } else if (markers.length > 1) {
317
+ const latSum = markers.reduce((sum, marker) => sum + marker.latitude, 0);
318
+ const lngSum = markers.reduce((sum, marker) => sum + marker.longitude, 0);
319
+ const latAvg = latSum / markers.length;
320
+ const lngAvg = lngSum / markers.length;
321
+ const selected = markers.some(marker => marker.selected);
322
+ return /*#__PURE__*/_react.default.createElement(_mapbox.Marker, {
323
+ className: "map-marker map-marker--cluster",
324
+ key: "marker-".concat(i),
325
+ longitude: lngAvg,
326
+ latitude: latAvg,
327
+ anchor: "center",
328
+ onClick: event => {
329
+ var _mapRef$current;
330
+ (_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : _mapRef$current.easeTo({
331
+ center: {
332
+ lat: latAvg,
333
+ lon: lngAvg
334
+ },
335
+ zoom: (zoom !== null && zoom !== void 0 ? zoom : 10) + 1,
336
+ duration: 500
337
+ });
338
+ event.originalEvent.stopPropagation();
339
+ },
340
+ style: {
341
+ backgroundColor: selected ? markerGroup.style.iconColor : theme.palette.TwClrBg
342
+ }
343
+ }, /*#__PURE__*/_react.default.createElement("p", {
344
+ className: "count"
345
+ }, markers.length), /*#__PURE__*/_react.default.createElement(_Icon.default, {
346
+ fillColor: selected ? theme.palette.TwClrBg : markerGroup.style.iconColor,
347
+ name: markerGroup.style.iconName,
348
+ size: 'small'
349
+ }));
350
+ }
351
+ });
352
+ });
353
+ }, [markerGroups, theme, zoom]);
354
+ const onMouseMove = (0, _react.useCallback)(event => {
355
+ if (event.features && event.features.length) {
356
+ const properties = event.features.map(feature => feature.properties).filter(featureProperties => featureProperties && featureProperties.id !== undefined && featureProperties.priority !== undefined && featureProperties.clickable);
357
+ if (properties.length) {
358
+ const topPriorityFeature = properties.reduce((top, current) => {
359
+ return current.priority > top.priority ? current : top;
360
+ }, properties[0]);
361
+ setHoverFeatureId(topPriorityFeature.id);
362
+ return;
363
+ }
364
+ }
365
+ setHoverFeatureId(undefined);
366
+ }, []);
367
+ (0, _react.useEffect)(() => {
368
+ if (!mapRef.current) {
369
+ return;
370
+ }
371
+ const observer = new ResizeObserver(() => {
372
+ var _mapRef$current2;
373
+ (_mapRef$current2 = mapRef.current) === null || _mapRef$current2 === void 0 ? void 0 : _mapRef$current2.resize();
374
+ });
375
+ observer.observe(mapRef.current.getContainer());
376
+ return () => observer.disconnect();
377
+ }, []);
378
+ (0, _react.useEffect)(() => {
379
+ if (!mapRef.current) {
380
+ return;
381
+ }
382
+ mapRef.current.resize();
383
+ }, [drawerOpen]);
384
+
385
+ // Hovering interactive layers
386
+ const onMouseEnter = (0, _react.useCallback)(() => setCursor(cursorInteract !== null && cursorInteract !== void 0 ? cursorInteract : 'pointer'), [cursorInteract]);
387
+ const onMouseLeave = (0, _react.useCallback)(() => setCursor('auto'), []);
388
+
389
+ // Entering and exiting canvases
390
+ const onMouseOver = (0, _react.useCallback)(() => setCursor(cursorMap !== null && cursorMap !== void 0 ? cursorMap : 'auto'), [cursorMap]);
391
+ const onMouseOut = (0, _react.useCallback)(() => setCursor('auto'), []);
392
+
393
+ // On layer click
394
+ const onMapClick = (0, _react.useCallback)(event => {
395
+ var _event$features;
396
+ if (featureGroups && (_event$features = event.features) !== null && _event$features !== void 0 && _event$features.length) {
397
+ const properties = event.features.map(feature => feature.properties).filter(featureProperties => featureProperties && featureProperties.id !== undefined && featureProperties.priority !== undefined && featureProperties.clickable);
398
+ if (properties.length) {
399
+ const topPriorityFeature = properties.reduce((top, current) => {
400
+ return current.priority > top.priority ? current : top;
401
+ }, properties[0]);
402
+ const clickedItem = featureGroups.flatMap(group => group.features).find(feature => feature.featureId === topPriorityFeature.id);
403
+ if (clickedItem && clickedItem.onClick) {
404
+ clickedItem.onClick();
405
+ return;
406
+ }
407
+ }
408
+ // If feature not clickable or not handled, fall through to canvas
409
+ }
410
+ if (onClickCanvas !== undefined) {
411
+ onClickCanvas(event);
412
+ }
413
+ }, [featureGroups, onClickCanvas]);
414
+ const orderedLayerIds = (0, _react.useMemo)(() => {
415
+ return [...fillLayers.map(layer => layer.props.id), ...highlightLayers.map(layer => layer.props.id), ...borderLayers.map(layer => layer.props.id), ...textLayers.map(layer => layer.props.id)];
416
+ }, [borderLayers, fillLayers, highlightLayers, textLayers]);
417
+ (0, _useMaintainLayerOrder.useMaintainLayerOrder)(mapRef, orderedLayerIds);
418
+ return /*#__PURE__*/_react.default.createElement(_ReactMapboxWrapper.default, {
419
+ key: mapId,
420
+ attributionControl: false,
421
+ cursor: cursor,
422
+ doubleClickZoom: !disableZoom && !disableDoubleClickZoom,
423
+ interactiveLayerIds: interactiveLayerIds,
424
+ initialViewState: initialViewState,
425
+ mapboxAccessToken: token,
426
+ mapStyle: _types.stylesUrl[mapViewStyle],
427
+ ref: mapRefCallback,
428
+ scrollZoom: !disableZoom,
429
+ style: {
430
+ width: 'auto',
431
+ height: isDesktop ? 'auto' : '80vh',
432
+ flexGrow: isDesktop ? 1 : undefined
433
+ },
434
+ onClick: onMapClick,
435
+ onMove: onMove,
436
+ onMouseEnter: onMouseEnter,
437
+ onMouseLeave: onMouseLeave,
438
+ onMouseOver: onMouseOver,
439
+ onMouseOut: onMouseOut,
440
+ onMouseMove: onMouseMove
441
+ }, isDesktop && !hideFullScreenControl && /*#__PURE__*/_react.default.createElement(_mapbox.FullscreenControl, {
442
+ position: "top-left",
443
+ containerId: containerId
444
+ }), !hideZoomControl && /*#__PURE__*/_react.default.createElement(_mapbox.NavigationControl, {
445
+ showCompass: false,
446
+ style: {
447
+ marginRight: theme.spacing(2),
448
+ marginBottom: theme.spacing(2)
449
+ },
450
+ position: "bottom-right"
451
+ }), !hideMapViewStyleControl && /*#__PURE__*/_react.default.createElement(_MapViewStyleControl.default, {
452
+ containerId: containerId,
453
+ mapViewStyle: mapViewStyle,
454
+ setMapViewStyle: setMapViewStyle
455
+ }), controlTopRight && /*#__PURE__*/_react.default.createElement(_material.Box, {
456
+ sx: {
457
+ height: 'max-content',
458
+ position: 'absolute',
459
+ right: theme.spacing(2),
460
+ top: theme.spacing(2),
461
+ width: 'max-content',
462
+ zIndex: 1000
463
+ }
464
+ }, controlTopRight), controlBottomLeft && /*#__PURE__*/_react.default.createElement(_material.Box, {
465
+ style: {
466
+ height: 'max-content',
467
+ position: 'absolute',
468
+ left: theme.spacing(2),
469
+ bottom: theme.spacing(4),
470
+ width: 'max-content',
471
+ zIndex: 1000
472
+ }
473
+ }, controlBottomLeft), geojson && /*#__PURE__*/_react.default.createElement(_mapbox.Source, {
474
+ id: "mapData",
475
+ type: "geojson",
476
+ data: geojson
477
+ }, fillLayers, highlightLayers, borderLayers, textLayers), markersComponents);
478
+ };
479
+ var _default = exports.default = MapBox;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _utils = require("../../utils");
10
+ require("./styles.scss");
11
+ const MapContainer = props => {
12
+ const {
13
+ containerId,
14
+ drawer,
15
+ drawerOpen,
16
+ legend,
17
+ map
18
+ } = props;
19
+ const {
20
+ isDesktop
21
+ } = (0, _utils.useDeviceInfo)();
22
+ const drawerOnly = (0, _react.useMemo)(() => !isDesktop && drawerOpen, [drawerOpen, isDesktop]);
23
+ return /*#__PURE__*/_react.default.createElement("div", {
24
+ id: containerId,
25
+ className: "map-container map-container".concat(isDesktop ? '--desktop' : "--mobile".concat(drawerOpen ? '-drawer-open' : ''))
26
+ }, /*#__PURE__*/_react.default.createElement("div", {
27
+ className: "map-holder".concat(drawerOnly ? ' map-holder--hidden' : '')
28
+ }, map), drawerOpen && drawer, !drawerOnly && legend);
29
+ };
30
+ var _default = exports.default = MapContainer;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _material = require("@mui/material");
11
+ var _luxon = require("luxon");
12
+ var _date = require("../../utils/date");
13
+ var _Slider = _interopRequireDefault(require("../Slider"));
14
+ const MapDateSliderControl = _ref => {
15
+ let {
16
+ dates,
17
+ selectedDate,
18
+ onChange
19
+ } = _ref;
20
+ const theme = (0, _material.useTheme)();
21
+ const earliestDate = (0, _react.useMemo)(() => {
22
+ return dates.reduce((earliest, current) => {
23
+ return current < earliest ? current : earliest;
24
+ });
25
+ }, [dates]);
26
+ const latestDate = (0, _react.useMemo)(() => {
27
+ return dates.reduce((latest, current) => {
28
+ return current > latest ? current : latest;
29
+ });
30
+ }, [dates]);
31
+ const marks = (0, _react.useMemo)(() => {
32
+ return dates.map(date => ({
33
+ value: date.valueOf()
34
+ }));
35
+ }, [dates]);
36
+ const getDateString = date => (0, _date.getShortDate)(date);
37
+ const getDateLabel = date => /*#__PURE__*/_react.default.createElement(_material.Typography, {
38
+ fontSize: "12px"
39
+ }, getDateString(date));
40
+ return /*#__PURE__*/_react.default.createElement(_material.Card, {
41
+ style: {
42
+ border: "1px solid ".concat(theme.palette.TwClrBrdrTertiary),
43
+ borderRadius: '8px',
44
+ display: 'flex',
45
+ flexDirection: 'column',
46
+ padding: theme.spacing(2),
47
+ maxWidth: '270px',
48
+ width: dates.length > 1 ? '270px' : undefined
49
+ }
50
+ }, selectedDate && /*#__PURE__*/_react.default.createElement(_material.Typography, {
51
+ fontSize: "14px",
52
+ fontWeight: 600,
53
+ textAlign: "right"
54
+ }, getDateString(selectedDate)), dates.length > 1 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Slider.default, {
55
+ value: selectedDate.valueOf(),
56
+ min: earliestDate.valueOf(),
57
+ max: latestDate.valueOf(),
58
+ marks: marks,
59
+ valueLabelDisplay: "off",
60
+ onChange: value => onChange(_luxon.DateTime.fromMillis(value))
61
+ }), /*#__PURE__*/_react.default.createElement(_material.Box, {
62
+ display: "flex",
63
+ justifyContent: "space-between"
64
+ }, getDateLabel(earliestDate), getDateLabel(latestDate))));
65
+ };
66
+ var _default = exports.default = MapDateSliderControl;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _material = require("@mui/material");
10
+ var _utils = require("../../utils");
11
+ var _Icon = _interopRequireDefault(require("../Icon/Icon"));
12
+ require("./styles.scss");
13
+ const MapDrawer = props => {
14
+ const {
15
+ children,
16
+ onClose,
17
+ open,
18
+ size,
19
+ style,
20
+ title
21
+ } = props;
22
+ const theme = (0, _material.useTheme)();
23
+ const {
24
+ isDesktop
25
+ } = (0, _utils.useDeviceInfo)();
26
+ return open ? /*#__PURE__*/_react.default.createElement(_material.Box, {
27
+ className: "map-drawer map-drawer".concat(isDesktop ? "--".concat(size) : '--mobile'),
28
+ borderLeft: isDesktop ? "1px solid ".concat(theme.palette.TwClrBrdrTertiary) : undefined,
29
+ borderRight: isDesktop ? "1px solid ".concat(theme.palette.TwClrBrdrTertiary) : undefined,
30
+ style: style
31
+ }, /*#__PURE__*/_react.default.createElement(_material.Box, {
32
+ className: "map-drawer--header"
33
+ }, /*#__PURE__*/_react.default.createElement("p", {
34
+ className: "title"
35
+ }, title), /*#__PURE__*/_react.default.createElement(_material.IconButton, {
36
+ onClick: onClose,
37
+ size: "small"
38
+ }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
39
+ name: "close",
40
+ className: "icon-close"
41
+ }))), /*#__PURE__*/_react.default.createElement(_material.Box, {
42
+ className: 'map-drawer--body'
43
+ }, children)) : null;
44
+ };
45
+ var _default = exports.default = MapDrawer;