@cdc/map 4.25.8 → 4.25.10

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 (84) hide show
  1. package/.claude/settings.local.json +30 -0
  2. package/dist/cdcmap.js +54263 -52600
  3. package/examples/private/c.json +290 -0
  4. package/examples/private/canvas-city-hover.json +787 -0
  5. package/examples/private/d.json +345 -0
  6. package/examples/private/g.json +1 -0
  7. package/examples/private/h.json +105911 -0
  8. package/examples/private/measles-data.json +378 -0
  9. package/examples/private/measles.json +211 -0
  10. package/examples/private/north-dakota.json +1132 -0
  11. package/examples/private/state-with-pattern.json +883 -0
  12. package/index.html +35 -34
  13. package/package.json +26 -5
  14. package/src/CdcMap.tsx +23 -8
  15. package/src/CdcMapComponent.tsx +215 -309
  16. package/src/_stories/CdcMap.Filters.stories.tsx +2 -2
  17. package/src/_stories/CdcMap.Legend.Gradient.stories.tsx +3 -3
  18. package/src/_stories/CdcMap.Legend.stories.tsx +7 -4
  19. package/src/_stories/CdcMap.Patterns.stories.tsx +2 -2
  20. package/src/_stories/CdcMap.Table.stories.tsx +2 -2
  21. package/src/_stories/CdcMap.stories.tsx +15 -5
  22. package/src/_stories/GoogleMap.stories.tsx +2 -2
  23. package/src/_stories/UsaMap.NoData.stories.tsx +2 -2
  24. package/src/_stories/_mock/equal-number.json +1109 -0
  25. package/src/_stories/_mock/us-bubble-cities.json +306 -0
  26. package/src/components/BubbleList.tsx +16 -12
  27. package/src/components/CityList.tsx +85 -107
  28. package/src/components/DataTable.tsx +37 -9
  29. package/src/components/EditorPanel/components/EditorPanel.tsx +177 -165
  30. package/src/components/EditorPanel/components/HexShapeSettings.tsx +3 -2
  31. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +7 -5
  32. package/src/components/Geo.tsx +2 -0
  33. package/src/components/Legend/components/Legend.tsx +109 -73
  34. package/src/components/Legend/components/LegendGroup/Legend.Group.tsx +10 -7
  35. package/src/components/MapContainer.tsx +52 -0
  36. package/src/components/MapControls.tsx +44 -0
  37. package/src/components/NavigationMenu.tsx +11 -2
  38. package/src/components/UsaMap/components/SingleState/SingleState.CountyOutput.tsx +24 -7
  39. package/src/components/UsaMap/components/UsaMap.County.tsx +111 -37
  40. package/src/components/UsaMap/components/UsaMap.Region.tsx +23 -5
  41. package/src/components/UsaMap/components/UsaMap.SingleState.tsx +6 -6
  42. package/src/components/UsaMap/components/UsaMap.State.tsx +28 -10
  43. package/src/components/UsaMap/helpers/map.ts +2 -2
  44. package/src/components/WorldMap/WorldMap.tsx +113 -25
  45. package/src/components/ZoomControls.tsx +6 -9
  46. package/src/context/LegendMemoContext.tsx +30 -0
  47. package/src/context.ts +1 -40
  48. package/src/data/initial-state.js +143 -130
  49. package/src/data/supported-geos.js +17 -2
  50. package/src/helpers/applyColorToLegend.ts +116 -20
  51. package/src/helpers/applyLegendToRow.ts +10 -6
  52. package/src/helpers/componentHelpers.ts +8 -0
  53. package/src/helpers/constants.ts +12 -0
  54. package/src/helpers/dataTableHelpers.ts +6 -0
  55. package/src/helpers/displayGeoName.ts +1 -1
  56. package/src/helpers/generateRuntimeLegend.ts +44 -8
  57. package/src/helpers/generateRuntimeLegendHash.ts +4 -2
  58. package/src/helpers/getColumnNames.ts +1 -1
  59. package/src/helpers/getPatternForRow.ts +36 -0
  60. package/src/helpers/getStatesPicked.ts +8 -5
  61. package/src/helpers/index.ts +11 -3
  62. package/src/helpers/isLegendItemDisabled.ts +16 -0
  63. package/src/helpers/mapObserverHelpers.ts +40 -0
  64. package/src/helpers/resetLegendToggles.ts +3 -2
  65. package/src/helpers/toggleLegendActive.ts +6 -11
  66. package/src/helpers/urlDataHelpers.ts +70 -0
  67. package/src/hooks/useGeoClickHandler.ts +35 -1
  68. package/src/hooks/useLegendMemo.ts +17 -0
  69. package/src/hooks/useMapLayers.tsx +5 -4
  70. package/src/hooks/useStateZoom.tsx +25 -6
  71. package/src/hooks/useTooltip.ts +1 -2
  72. package/src/index.jsx +0 -2
  73. package/src/store/map.reducer.ts +17 -6
  74. package/src/test/CdcMap.test.jsx +11 -0
  75. package/src/types/MapConfig.ts +23 -14
  76. package/src/types/MapContext.ts +0 -7
  77. package/src/types/runtimeLegend.ts +17 -1
  78. package/vite.config.js +2 -7
  79. package/vitest.config.ts +16 -0
  80. package/src/coreStyles_map.scss +0 -3
  81. package/src/helpers/colorDistributions.ts +0 -12
  82. package/src/helpers/generateColorsArray.ts +0 -14
  83. package/src/helpers/tests/generateColorsArray.test.ts +0 -18
  84. package/src/helpers/tests/generateRuntimeLegendHash.test.ts +0 -11
@@ -13,6 +13,8 @@ import Loading from '@cdc/core/components/Loading'
13
13
  import { navigationHandler } from '../helpers'
14
14
  import ConfigContext, { MapDispatchContext } from '../context'
15
15
  import { publishAnalyticsEvent } from '@cdc/core/helpers/metrics/helpers'
16
+ import { getPatternForRow } from '../helpers/getPatternForRow'
17
+ import { getVizTitle, getVizSubType } from '@cdc/core/helpers/metrics/utils'
16
18
 
17
19
  const DataTable = props => {
18
20
  const {
@@ -34,7 +36,7 @@ const DataTable = props => {
34
36
  } = props
35
37
 
36
38
  const dispatch = useContext(MapDispatchContext)
37
- const { currentViewport: viewport } = useContext(ConfigContext)
39
+ const { currentViewport: viewport, mapId } = useContext(ConfigContext)
38
40
  const [expanded, setExpanded] = useState(expandDataTable)
39
41
  const [sortBy, setSortBy] = useState({ column: 'geo', asc: false })
40
42
  const [accessibilityLabel, setAccessibilityLabel] = useState('')
@@ -124,7 +126,7 @@ const DataTable = props => {
124
126
  role='link'
125
127
  tabIndex='0'
126
128
  onKeyDown={e => {
127
- if (e.keyCode === 13) {
129
+ if (e.key === 'Enter') {
128
130
  navigationHandler(state.general.navigationTarget, row[columns.navigate.name])
129
131
  }
130
132
  }}
@@ -179,7 +181,14 @@ const DataTable = props => {
179
181
  type='button'
180
182
  onClick={() => {
181
183
  saveBlob
182
- publishAnalyticsEvent('data_downloaded', 'click', interactionLabel)
184
+ publishAnalyticsEvent({
185
+ vizType: state.type,
186
+ vizSubType: getVizSubType(state),
187
+ eventType: 'data_downloaded',
188
+ eventAction: 'click',
189
+ eventLabel: interactionLabel,
190
+ vizTitle: getVizTitle(state)
191
+ })
183
192
  }}
184
193
  href={URL.createObjectURL(blob)}
185
194
  aria-label='Download this data in a CSV file format.'
@@ -197,7 +206,7 @@ const DataTable = props => {
197
206
  return (
198
207
  <MediaControls.Section classes={['download-links']}>
199
208
  <MediaControls.Link config={state} interactionLabel={interactionLabel} />
200
- {state.table.download && <DownloadButton />}
209
+ {state.table.download && <DownloadButton config={state} />}
201
210
  </MediaControls.Section>
202
211
  )
203
212
  }
@@ -249,7 +258,7 @@ const DataTable = props => {
249
258
  }}
250
259
  tabIndex='0'
251
260
  onKeyDown={e => {
252
- if (e.keyCode === 13) {
261
+ if (e.key === 'Enter') {
253
262
  setExpanded(!expanded)
254
263
  }
255
264
  }}
@@ -297,7 +306,7 @@ const DataTable = props => {
297
306
  setSortBy({ column, asc: sortBy.column === column ? !sortBy.asc : false })
298
307
  }}
299
308
  onKeyDown={e => {
300
- if (e.keyCode === 13) {
309
+ if (e.key === 'Enter') {
301
310
  setSortBy({ column, asc: sortBy.column === column ? !sortBy.asc : false })
302
311
  }
303
312
  }}
@@ -341,9 +350,28 @@ const DataTable = props => {
341
350
 
342
351
  labelValue = getCellAnchor(labelValue, rowObj)
343
352
 
353
+ // Check for pattern information
354
+ const patternInfo = getPatternForRow(rowObj, state)
355
+
356
+ const legendShape = patternInfo ? (
357
+ <LegendShape
358
+ fill={legendColor[0]}
359
+ patternInfo={{
360
+ pattern: patternInfo.pattern,
361
+ patternId: `${mapId}--${String(patternInfo.dataKey).replace(' ', '-')}--${
362
+ patternInfo.patternIndex
363
+ }--table`,
364
+ size: patternInfo.size,
365
+ color: patternInfo.color
366
+ }}
367
+ />
368
+ ) : (
369
+ <LegendShape fill={legendColor[0]} />
370
+ )
371
+
344
372
  cellValue = (
345
373
  <>
346
- <LegendShape fill={legendColor[0]} />
374
+ {legendShape}
347
375
  {labelValue}
348
376
  </>
349
377
  )
@@ -353,9 +381,9 @@ const DataTable = props => {
353
381
 
354
382
  return (
355
383
  <td
356
- tabIndex='0'
384
+ tabIndex={0}
357
385
  role='gridcell'
358
- onClick={e =>
386
+ onClick={() =>
359
387
  state.general.type === 'bubble' &&
360
388
  state.general.allowMapZoom &&
361
389
  state.general.geoType === 'world'