@cdc/map 4.25.3 → 4.25.6

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 (119) hide show
  1. package/.idea/map.iml +12 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/vcs.xml +6 -0
  4. package/dist/cdcmap.js +31254 -32242
  5. package/examples/hex-colors.json +3 -3
  6. package/examples/m2.json +32904 -0
  7. package/examples/private/test.json +470 -1457
  8. package/examples/private/{mmr.json → wastewatermap.json} +86 -115
  9. package/index.html +36 -63
  10. package/package.json +7 -19
  11. package/src/CdcMap.tsx +56 -1552
  12. package/src/CdcMapComponent.tsx +608 -0
  13. package/src/_stories/CdcMap.Legend.Gradient.stories.tsx +10 -0
  14. package/src/_stories/CdcMap.Legend.stories.tsx +67 -0
  15. package/src/_stories/CdcMap.Table.stories.tsx +19 -0
  16. package/src/_stories/CdcMap.stories.tsx +12 -1
  17. package/src/_stories/UsaMap.NoData.stories.tsx +4 -4
  18. package/src/_stories/_mock/default-patterns.json +8 -5
  19. package/src/_stories/_mock/legend-bins.json +428 -0
  20. package/{examples/private/default-patterns.json → src/_stories/_mock/legends/legend-tests.json} +36 -131
  21. package/src/cdcMapComponent.styles.css +9 -0
  22. package/src/components/Annotation/Annotation.Draggable.tsx +27 -26
  23. package/src/components/Annotation/AnnotationDropdown.tsx +5 -6
  24. package/src/components/BubbleList.tsx +135 -49
  25. package/src/components/CityList.tsx +89 -87
  26. package/src/components/DataTable.tsx +8 -8
  27. package/src/components/EditorPanel/components/EditorPanel.tsx +823 -885
  28. package/src/components/EditorPanel/components/Error.tsx +9 -2
  29. package/src/components/EditorPanel/components/HexShapeSettings.tsx +127 -141
  30. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +55 -86
  31. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +89 -75
  32. package/src/components/EditorPanel/components/editorPanel.styles.css +95 -0
  33. package/src/components/Geo.tsx +9 -1
  34. package/src/components/GoogleMap/components/GoogleMap.tsx +1 -1
  35. package/src/components/Legend/components/Legend.tsx +92 -87
  36. package/src/components/Legend/components/LegendGroup/Legend.Group.tsx +128 -0
  37. package/src/components/Legend/components/LegendGroup/legend.group.css +27 -0
  38. package/src/components/Legend/components/LegendItem.Hex.tsx +4 -1
  39. package/src/components/Legend/components/index.scss +74 -17
  40. package/src/components/Modal.tsx +17 -7
  41. package/src/components/NavigationMenu.tsx +11 -9
  42. package/src/components/UsaMap/components/SingleState/SingleState.CountyOutput.tsx +12 -8
  43. package/src/components/UsaMap/components/SingleState/SingleState.StateOutput.tsx +4 -4
  44. package/src/components/UsaMap/components/TerritoriesSection.tsx +33 -10
  45. package/src/components/UsaMap/components/Territory/Territory.Hexagon.tsx +12 -10
  46. package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +12 -14
  47. package/src/components/UsaMap/components/Territory/TerritoryShape.ts +2 -1
  48. package/src/components/UsaMap/components/UsaMap.County.tsx +138 -96
  49. package/src/components/UsaMap/components/UsaMap.Region.styles.css +72 -0
  50. package/src/components/UsaMap/components/UsaMap.Region.tsx +56 -103
  51. package/src/components/UsaMap/components/UsaMap.SingleState.styles.css +10 -0
  52. package/src/components/UsaMap/components/UsaMap.SingleState.tsx +65 -74
  53. package/src/components/UsaMap/components/UsaMap.State.tsx +112 -91
  54. package/src/components/UsaMap/helpers/map.ts +1 -1
  55. package/src/components/UsaMap/helpers/shapes.ts +20 -7
  56. package/src/components/WorldMap/WorldMap.tsx +64 -118
  57. package/src/components/WorldMap/worldMap.styles.css +28 -0
  58. package/src/components/ZoomControls.tsx +15 -13
  59. package/src/components/zoomControls.styles.css +53 -0
  60. package/src/context.ts +17 -9
  61. package/src/data/initial-state.js +5 -2
  62. package/src/helpers/addUIDs.ts +150 -0
  63. package/src/helpers/applyColorToLegend.ts +39 -64
  64. package/src/helpers/applyLegendToRow.ts +51 -0
  65. package/src/helpers/colorDistributions.ts +12 -0
  66. package/src/helpers/constants.ts +44 -0
  67. package/src/helpers/displayGeoName.ts +9 -2
  68. package/src/helpers/formatLegendLocation.ts +3 -2
  69. package/src/helpers/generateColorsArray.ts +2 -1
  70. package/src/helpers/generateRuntimeData.ts +78 -0
  71. package/src/helpers/generateRuntimeFilters.ts +63 -0
  72. package/src/helpers/generateRuntimeLegend.ts +566 -0
  73. package/src/helpers/generateRuntimeLegendHash.ts +16 -15
  74. package/src/helpers/getColumnNames.ts +19 -0
  75. package/src/helpers/getMapContainerClasses.ts +23 -0
  76. package/src/helpers/getStatePicked.ts +8 -0
  77. package/src/helpers/handleMapTabbing.ts +31 -0
  78. package/src/helpers/hashObj.ts +1 -1
  79. package/src/helpers/index.ts +22 -0
  80. package/src/helpers/navigationHandler.ts +3 -3
  81. package/src/helpers/resetLegendToggles.ts +13 -0
  82. package/src/helpers/setBinNumbers.ts +5 -0
  83. package/src/helpers/sortSpecialClassesLast.ts +7 -0
  84. package/src/helpers/tests/getColumnNames.test.ts +52 -0
  85. package/src/helpers/titleCase.ts +1 -1
  86. package/src/helpers/toggleLegendActive.ts +25 -0
  87. package/src/hooks/useApplyTooltipsToGeo.tsx +51 -0
  88. package/src/hooks/useColumnsRequiredChecker.ts +51 -0
  89. package/src/hooks/useGeoClickHandler.ts +45 -0
  90. package/src/hooks/useLegendSeparators.ts +26 -0
  91. package/src/hooks/useMapLayers.tsx +34 -60
  92. package/src/hooks/useModal.ts +22 -0
  93. package/src/hooks/useResizeObserver.ts +4 -5
  94. package/src/hooks/useStateZoom.tsx +52 -75
  95. package/src/hooks/useTooltip.ts +2 -3
  96. package/src/index.jsx +3 -9
  97. package/src/scss/editor-panel.scss +3 -99
  98. package/src/scss/main.scss +1 -19
  99. package/src/scss/map.scss +15 -220
  100. package/src/store/map.actions.ts +46 -0
  101. package/src/store/map.reducer.ts +96 -0
  102. package/src/types/Annotations.ts +24 -0
  103. package/src/types/MapConfig.ts +23 -3
  104. package/src/types/MapContext.ts +36 -35
  105. package/src/types/Modal.ts +1 -0
  106. package/src/types/RuntimeData.ts +3 -0
  107. package/examples/private/DEV-9644.json +0 -184
  108. package/examples/private/DEV-9989.json +0 -229
  109. package/examples/private/ardi.json +0 -180
  110. package/examples/private/colors 2.json +0 -416
  111. package/examples/private/colors.json +0 -416
  112. package/examples/private/colors.json.zip +0 -0
  113. package/examples/private/customColors.json +0 -45348
  114. package/examples/test.json +0 -183
  115. package/src/helpers/closeModal.ts +0 -9
  116. package/src/scss/btn.scss +0 -69
  117. package/src/scss/filters.scss +0 -27
  118. package/src/scss/variables.scss +0 -1
  119. /package/src/hooks/{useActiveElement.js → useActiveElement.ts} +0 -0
@@ -0,0 +1,19 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import CdcMapComponent from '../CdcMapComponent'
3
+ import defaultPatterns from './_mock/default-patterns.json'
4
+ import { editConfigKeys } from '@cdc/chart/src/helpers/configHelpers'
5
+
6
+ const meta: Meta<typeof CdcMapComponent> = {
7
+ title: 'Components/Templates/Map/Table',
8
+ component: CdcMapComponent
9
+ }
10
+
11
+ type Story = StoryObj<typeof CdcMapComponent>
12
+
13
+ export const Show_Non_Geo_Data: Story = {
14
+ args: {
15
+ config: editConfigKeys(defaultPatterns, [{ path: ['table', 'showNonGeoData'], value: true }])
16
+ }
17
+ }
18
+
19
+ export default meta
@@ -4,6 +4,7 @@ import EqualNumberOptInExample from './_mock/DEV-7286.json'
4
4
  import SingleStateWithFilters from './_mock/DEV-8942.json'
5
5
  import exampleCityState from './_mock/example-city-state.json'
6
6
  import { editConfigKeys } from '@cdc/chart/src/helpers/configHelpers'
7
+ import exampleLegendBins from './_mock/legend-bins.json'
7
8
 
8
9
  const meta: Meta<typeof CdcMap> = {
9
10
  title: 'Components/Templates/Map',
@@ -14,6 +15,7 @@ type Story = StoryObj<typeof CdcMap>
14
15
 
15
16
  export const Equal_Interval_Map: Story = {
16
17
  args: {
18
+ isEditor: true,
17
19
  configUrl: 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/page-elements/equal-interval-map.json'
18
20
  }
19
21
  }
@@ -26,6 +28,7 @@ export const Equal_Number_Opt_In: Story = {
26
28
 
27
29
  export const Equal_Number_Map: Story = {
28
30
  args: {
31
+ isEditor: true,
29
32
  configUrl: 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/page-elements/equal-number-map.json'
30
33
  }
31
34
  }
@@ -137,7 +140,8 @@ export const Custom_Color_Distributions_Without_Special_Classes: Story = {
137
140
 
138
141
  export const Standard_Color_Distributions_With_Special_Classes: Story = {
139
142
  args: {
140
- config: exampleCityStateStandardColors
143
+ config: exampleCityStateStandardColors,
144
+ isEditor: true
141
145
  }
142
146
  }
143
147
 
@@ -153,4 +157,11 @@ export const Custom_Color_Distributions_With_Update_Needed: Story = {
153
157
  }
154
158
  }
155
159
 
160
+ export const Legend_Bins: Story = {
161
+ args: {
162
+ config: exampleLegendBins,
163
+ isEditor: true
164
+ }
165
+ }
166
+
156
167
  export default meta
@@ -1,14 +1,14 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react'
2
- import CdcMap from '../CdcMap'
2
+ import CdcMapComponent from '../CdcMapComponent'
3
3
  import cityStateConfig from './_mock/example-city-state.json'
4
4
  import { editConfigKeys } from '@cdc/chart/src/helpers/configHelpers'
5
5
 
6
- const meta: Meta<typeof CdcMap> = {
6
+ const meta: Meta<typeof CdcMapComponent> = {
7
7
  title: 'Components/Templates/Map',
8
- component: CdcMap
8
+ component: CdcMapComponent
9
9
  }
10
10
 
11
- type Story = StoryObj<typeof CdcMap>
11
+ type Story = StoryObj<typeof CdcMapComponent>
12
12
 
13
13
  export const USA_Map_No_Data: Story = {
14
14
  args: {
@@ -146,10 +146,7 @@
146
146
  "additionalCityStyles": []
147
147
  },
148
148
  "mapPosition": {
149
- "coordinates": [
150
- 0,
151
- 30
152
- ],
149
+ "coordinates": [0, 30],
153
150
  "zoom": 1
154
151
  },
155
152
  "map": {
@@ -193,6 +190,12 @@
193
190
  },
194
191
  "usingWidgetLoader": true,
195
192
  "data": [
193
+ {
194
+ "STATE": "Non-Geo Data",
195
+ "Rate": 1000,
196
+ "Location": "Home",
197
+ "URL": "https://www.cdc.gov/"
198
+ },
196
199
  {
197
200
  "STATE": "AL",
198
201
  "Rate": 1000,
@@ -862,4 +865,4 @@
862
865
  ],
863
866
  "filterStyle": "Filter Changes",
864
867
  "version": "4.24.11"
865
- }
868
+ }
@@ -0,0 +1,428 @@
1
+ {
2
+ "general": {
3
+ "geoType": "us",
4
+ "geoBorderColor": "darkGray",
5
+ "showTitle": false,
6
+ "showSidebar": true,
7
+ "showDownloadButton": false,
8
+ "showDownloadMediaButton": false,
9
+ "displayAsHex": true,
10
+ "displayStateLabels": false,
11
+ "territoriesLabel": "Territories",
12
+ "language": "en",
13
+ "hasRegions": false,
14
+ "expandDataTable": false,
15
+ "fullBorder": false,
16
+ "type": "data",
17
+ "palette": {
18
+ "isReversed": true
19
+ },
20
+ "geoLabelOverride": "",
21
+ "convertFipsCodes": true,
22
+ "allowMapZoom": true,
23
+ "hideGeoColumnInTooltip": false,
24
+ "hidePrimaryColumnInTooltip": false,
25
+ "superTitle": "",
26
+ "equalNumberOptIn": true,
27
+ "navigationTarget": "_self",
28
+ "noStateFoundMessage": "Map Unavailable",
29
+ "annotationDropdownText": "Annotations",
30
+ "headerColor": "theme-blue",
31
+ "title": "",
32
+ "territoriesAlwaysShow": false,
33
+ "statePicked": {
34
+ "fipsCode": "01",
35
+ "stateName": "Alabama"
36
+ }
37
+ },
38
+ "type": "map",
39
+ "customColors": [
40
+ "red",
41
+ "#edf8fb",
42
+ "yellow",
43
+ "#b3cde3",
44
+ "green",
45
+ "#8c96c6",
46
+ "#8856a7",
47
+ "#810f7c",
48
+ "pink"
49
+ ],
50
+ "columns": {
51
+ "geo": {
52
+ "name": "state",
53
+ "label": "Location",
54
+ "tooltip": false,
55
+ "dataTable": true
56
+ },
57
+ "primary": {
58
+ "dataTable": true,
59
+ "tooltip": true,
60
+ "prefix": "",
61
+ "suffix": "%",
62
+ "name": "value",
63
+ "label": "",
64
+ "roundToPlace": 1
65
+ },
66
+ "navigate": {
67
+ "name": ""
68
+ },
69
+ "latitude": {
70
+ "name": ""
71
+ },
72
+ "longitude": {
73
+ "name": ""
74
+ }
75
+ },
76
+ "legend": {
77
+ "descriptions": {},
78
+ "specialClasses": [
79
+ {
80
+ "key": "value",
81
+ "value": "",
82
+ "label": "No data"
83
+ }
84
+ ],
85
+ "unified": false,
86
+ "singleColumn": false,
87
+ "dynamicDescription": false,
88
+ "type": "equalnumber",
89
+ "numberOfItems": 5,
90
+ "position": "side",
91
+ "title": "Legend",
92
+ "singleRow": false,
93
+ "verticalSorted": false,
94
+ "showSpecialClassesLast": true,
95
+ "categoryValuesOrder": [
96
+ "No",
97
+ "Yes"
98
+ ]
99
+ },
100
+ "filters": [],
101
+ "table": {
102
+ "wrapColumns": false,
103
+ "label": "Data Table",
104
+ "expanded": false,
105
+ "limitHeight": false,
106
+ "height": "",
107
+ "caption": "",
108
+ "showDownloadUrl": false,
109
+ "showDataTableLink": false,
110
+ "showFullGeoNameInCSV": false,
111
+ "forceDisplay": false,
112
+ "download": true,
113
+ "indexLabel": "",
114
+ "showDownloadLinkBelow": true,
115
+ "cellMinWidth": "0"
116
+ },
117
+ "tooltips": {
118
+ "appearanceType": "hover",
119
+ "linkLabel": "Learn More",
120
+ "capitalizeLabels": true,
121
+ "opacity": 90
122
+ },
123
+ "visual": {
124
+ "minBubbleSize": 1,
125
+ "maxBubbleSize": 20,
126
+ "extraBubbleBorder": false,
127
+ "cityStyle": "circle",
128
+ "cityStyleLabel": "",
129
+ "showBubbleZeros": false,
130
+ "additionalCityStyles": [],
131
+ "geoCodeCircleSize": 8
132
+ },
133
+ "mapPosition": {
134
+ "coordinates": [
135
+ 0,
136
+ 30
137
+ ],
138
+ "zoom": 1
139
+ },
140
+ "map": {
141
+ "layers": [],
142
+ "patterns": []
143
+ },
144
+ "filterBehavior": "Filter Change",
145
+ "dataTable": {
146
+ "title": "Data Table",
147
+ "forceDisplay": true,
148
+ "caption": "Lorem Ipsum - Text added to Data Table Caption",
149
+ "limitHeight": true,
150
+ "height": "100"
151
+ },
152
+ "orientation": null,
153
+ "visualizationSubType": null,
154
+ "validated": "4.24.3",
155
+ "version": "4.24.12",
156
+ "data": [
157
+ {
158
+ "state": "New Mexico",
159
+ "stratification": "Total",
160
+ "value": 80.2
161
+ },
162
+ {
163
+ "state": "Pennsylvania",
164
+ "stratification": "Total",
165
+ "value": 29.8
166
+ },
167
+ {
168
+ "state": "Alabama",
169
+ "stratification": "Total",
170
+ "value": 18.2
171
+ },
172
+ {
173
+ "state": "Connecticut",
174
+ "stratification": "Total",
175
+ "value": 53.5
176
+ },
177
+ {
178
+ "state": "Massachusetts",
179
+ "stratification": "Total",
180
+ "value": 36.6
181
+ },
182
+ {
183
+ "state": "Rhode Island",
184
+ "stratification": "Total",
185
+ "value": 95.9
186
+ },
187
+ {
188
+ "state": "Tennessee",
189
+ "stratification": "Total",
190
+ "value": 14.8
191
+ },
192
+ {
193
+ "state": "Hawaii",
194
+ "stratification": "Total",
195
+ "value": 12.1
196
+ },
197
+ {
198
+ "state": "Kentucky",
199
+ "stratification": "Total",
200
+ "value": 15.4
201
+ },
202
+ {
203
+ "state": "Alaska",
204
+ "stratification": "Total",
205
+ "value": 20.8
206
+ },
207
+ {
208
+ "state": "Michigan",
209
+ "stratification": "Total",
210
+ "value": 32.9
211
+ },
212
+ {
213
+ "state": "North Dakota",
214
+ "stratification": "Total",
215
+ "value": 12
216
+ },
217
+ {
218
+ "state": "Iowa",
219
+ "stratification": "Total",
220
+ "value": 8.8
221
+ },
222
+ {
223
+ "state": "Nebraska",
224
+ "stratification": "Total",
225
+ "value": 14.7
226
+ },
227
+ {
228
+ "state": "West Virginia",
229
+ "stratification": "Total",
230
+ "value": 20.4
231
+ },
232
+ {
233
+ "state": "Ohio",
234
+ "stratification": "Total",
235
+ "value": 23
236
+ },
237
+ {
238
+ "state": "Montana",
239
+ "stratification": "Total",
240
+ "value": 40.2
241
+ },
242
+ {
243
+ "state": "Vermont",
244
+ "stratification": "Total",
245
+ "value": 11.1
246
+ },
247
+ {
248
+ "state": "Oregon",
249
+ "stratification": "Total",
250
+ "value": 17.5
251
+ },
252
+ {
253
+ "state": "Florida",
254
+ "stratification": "Total",
255
+ "value": 31.5
256
+ },
257
+ {
258
+ "state": "California",
259
+ "stratification": "Total",
260
+ "value": 40.9
261
+ },
262
+ {
263
+ "state": "Colorado",
264
+ "stratification": "Total",
265
+ "value": 35.1
266
+ },
267
+ {
268
+ "state": "Arizona",
269
+ "stratification": "Total",
270
+ "value": 6.4
271
+ },
272
+ {
273
+ "state": "Georgia",
274
+ "stratification": "Total",
275
+ "value": 32.6
276
+ },
277
+ {
278
+ "state": "Virgin Islands",
279
+ "stratification": "Total",
280
+ "value": 0
281
+ },
282
+ {
283
+ "state": "Puerto Rico",
284
+ "stratification": "Total",
285
+ "value": 0.8
286
+ },
287
+ {
288
+ "state": "New Jersey",
289
+ "stratification": "Total",
290
+ "value": 28.4
291
+ },
292
+ {
293
+ "state": "Wisconsin",
294
+ "stratification": "Total",
295
+ "value": 21.1
296
+ },
297
+ {
298
+ "state": "Idaho",
299
+ "stratification": "Total",
300
+ "value": 9.8
301
+ },
302
+ {
303
+ "state": "Missouri",
304
+ "stratification": "Total",
305
+ "value": 20.8
306
+ },
307
+ {
308
+ "state": "Mississippi",
309
+ "stratification": "Total",
310
+ "value": 65.4
311
+ },
312
+ {
313
+ "state": "New York",
314
+ "stratification": "Total",
315
+ "value": 35.1
316
+ },
317
+ {
318
+ "state": "South Dakota",
319
+ "stratification": "Total",
320
+ "value": 4.6
321
+ },
322
+ {
323
+ "state": "Nevada",
324
+ "stratification": "Total",
325
+ "value": 13.8
326
+ },
327
+ {
328
+ "state": "Washington",
329
+ "stratification": "Total",
330
+ "value": 22.6
331
+ },
332
+ {
333
+ "state": "Indiana",
334
+ "stratification": "Total",
335
+ "value": 32.1
336
+ },
337
+ {
338
+ "state": "Oklahoma",
339
+ "stratification": "Total",
340
+ "value": 31.3
341
+ },
342
+ {
343
+ "state": "Maine",
344
+ "stratification": "Total",
345
+ "value": 16.9
346
+ },
347
+ {
348
+ "state": "Maryland",
349
+ "stratification": "Total",
350
+ "value": 23.5
351
+ },
352
+ {
353
+ "state": "Arkansas",
354
+ "stratification": "Total",
355
+ "value": 31.9
356
+ },
357
+ {
358
+ "state": "Wyoming",
359
+ "stratification": "Total",
360
+ "value": 2.3
361
+ },
362
+ {
363
+ "state": "New Hampshire",
364
+ "stratification": "Total",
365
+ "value": 51.7
366
+ },
367
+ {
368
+ "state": "Texas",
369
+ "stratification": "Total",
370
+ "value": 16.9
371
+ },
372
+ {
373
+ "state": "Guam",
374
+ "stratification": "Total",
375
+ "value": 0
376
+ },
377
+ {
378
+ "state": "Delaware",
379
+ "stratification": "Total",
380
+ "value": 83.4
381
+ },
382
+ {
383
+ "state": "Utah",
384
+ "stratification": "Total",
385
+ "value": 10
386
+ },
387
+ {
388
+ "state": "North Carolina",
389
+ "stratification": "Total",
390
+ "value": 35.7
391
+ },
392
+ {
393
+ "state": "South Carolina",
394
+ "stratification": "Total",
395
+ "value": 47.5
396
+ },
397
+ {
398
+ "state": "District of Columbia",
399
+ "stratification": "Total",
400
+ "value": 48.2
401
+ },
402
+ {
403
+ "state": "Louisiana",
404
+ "stratification": "Total",
405
+ "value": 56.8
406
+ },
407
+ {
408
+ "state": "Kansas",
409
+ "stratification": "Total",
410
+ "value": 52.9
411
+ },
412
+ {
413
+ "state": "Illinois",
414
+ "stratification": "Total",
415
+ "value": 25.8
416
+ },
417
+ {
418
+ "state": "Virginia",
419
+ "stratification": "Total",
420
+ "value": 13.8
421
+ },
422
+ {
423
+ "state": "Minnesota",
424
+ "stratification": "Total",
425
+ "value": 22
426
+ }
427
+ ]
428
+ }