@cdc/map 4.26.2 → 4.26.3

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 (65) hide show
  1. package/LICENSE +201 -0
  2. package/dist/cdcmap-vr9HZwRt.es.js +6 -0
  3. package/dist/cdcmap.js +26781 -24615
  4. package/examples/private/annotation-bug.json +642 -0
  5. package/package.json +3 -3
  6. package/src/CdcMap.tsx +3 -14
  7. package/src/CdcMapComponent.tsx +214 -159
  8. package/src/_stories/CdcMap.Defaults.stories.tsx +76 -0
  9. package/src/_stories/CdcMap.Editor.stories.tsx +187 -14
  10. package/src/_stories/CdcMap.stories.tsx +11 -1
  11. package/src/_stories/Map.HTMLInDataTable.stories.tsx +385 -0
  12. package/src/_stories/_mock/multi-state-show-unselected.json +82 -0
  13. package/src/cdcMapComponent.styles.css +2 -2
  14. package/src/components/Annotation/Annotation.Draggable.styles.css +4 -4
  15. package/src/components/Annotation/AnnotationDropdown.styles.css +1 -1
  16. package/src/components/Annotation/AnnotationList.styles.css +13 -13
  17. package/src/components/EditorPanel/components/EditorPanel.tsx +426 -58
  18. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings-style.css +1 -1
  19. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +5 -2
  20. package/src/components/EditorPanel/components/editorPanel.styles.css +34 -24
  21. package/src/components/Legend/components/Legend.tsx +9 -4
  22. package/src/components/Legend/components/LegendGroup/legend.group.css +5 -5
  23. package/src/components/Legend/components/index.scss +2 -3
  24. package/src/components/NavigationMenu.tsx +2 -1
  25. package/src/components/SmallMultiples/SmallMultiples.css +5 -5
  26. package/src/components/UsaMap/components/SingleState/SingleState.StateOutput.tsx +32 -17
  27. package/src/components/UsaMap/components/TerritoriesSection.tsx +3 -2
  28. package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +13 -8
  29. package/src/components/UsaMap/components/UsaMap.County.tsx +410 -183
  30. package/src/components/UsaMap/components/UsaMap.Region.styles.css +1 -1
  31. package/src/components/UsaMap/components/UsaMap.SingleState.styles.css +2 -2
  32. package/src/components/UsaMap/components/UsaMap.State.tsx +13 -8
  33. package/src/components/WorldMap/WorldMap.tsx +10 -13
  34. package/src/components/WorldMap/data/world-topo-updated.json +1 -0
  35. package/src/components/WorldMap/data/world-topo.json +1 -1
  36. package/src/components/WorldMap/worldMap.styles.css +1 -1
  37. package/src/components/ZoomControls.tsx +49 -18
  38. package/src/components/zoomControls.styles.css +27 -11
  39. package/src/data/initial-state.js +14 -5
  40. package/src/data/legacy-defaults.ts +8 -0
  41. package/src/data/supported-geos.js +19 -0
  42. package/src/helpers/colors.ts +2 -1
  43. package/src/helpers/dataTableHelpers.ts +56 -0
  44. package/src/helpers/displayGeoName.ts +19 -11
  45. package/src/helpers/getMapContainerClasses.ts +8 -2
  46. package/src/helpers/getMatchingPatternForRow.ts +67 -0
  47. package/src/helpers/getPatternForRow.ts +11 -18
  48. package/src/helpers/tests/dataTableHelpers.test.ts +78 -0
  49. package/src/helpers/tests/displayGeoName.test.ts +17 -0
  50. package/src/helpers/tests/getMatchingPatternForRow.test.ts +150 -0
  51. package/src/helpers/tests/getPatternForRow.test.ts +140 -2
  52. package/src/helpers/urlDataHelpers.ts +7 -1
  53. package/src/hooks/useResizeObserver.ts +36 -22
  54. package/src/hooks/useTooltip.test.tsx +64 -0
  55. package/src/hooks/useTooltip.ts +28 -8
  56. package/src/scss/editor-panel.scss +1 -1
  57. package/src/scss/main.scss +140 -6
  58. package/src/scss/map.scss +9 -4
  59. package/src/store/map.actions.ts +2 -0
  60. package/src/store/map.reducer.ts +4 -0
  61. package/src/test/CdcMap.test.jsx +2 -2
  62. package/src/types/MapConfig.ts +22 -4
  63. package/src/types/MapContext.ts +3 -1
  64. package/dist/cdcmap-Cf9_fbQf.es.js +0 -6
  65. package/src/helpers/componentHelpers.ts +0 -8
@@ -54,8 +54,8 @@
54
54
  #region-2-territories,
55
55
  #region-9-territories {
56
56
  text {
57
- font-weight: bold;
58
57
  font-size: 14px;
58
+ font-weight: bold;
59
59
  }
60
60
  }
61
61
 
@@ -1,8 +1,8 @@
1
1
  .countyMapGroup {
2
+ stroke: none !important;
3
+ transform-origin: center;
2
4
  transition: transform 1s;
3
5
  will-change: transform;
4
- transform-origin: center;
5
- stroke: none !important;
6
6
  }
7
7
 
8
8
  .countyMapGroup--no-transition {
@@ -48,7 +48,7 @@ import {
48
48
  SVG_WIDTH
49
49
  } from '../../../helpers'
50
50
  import { hashObj } from '@cdc/core/helpers/hashObj'
51
- import { patternValuesMatch } from '../../../helpers/patternMatching'
51
+ import { getMatchingPatternForRow } from '../../../helpers/getMatchingPatternForRow'
52
52
  const { features: unitedStatesHex } = topoFeature(hexTopoJSON, hexTopoJSON.objects.states)
53
53
 
54
54
  const offsets = {
@@ -490,15 +490,20 @@ const UsaMap = () => {
490
490
  <path tabIndex={-1} className='single-geo' strokeWidth={1} d={path} />
491
491
 
492
492
  {/* apply patterns on top of state path*/}
493
- {map?.patterns?.map((patternData, _patternIndex) => {
494
- const { pattern, dataKey, size } = patternData
493
+ {(() => {
494
+ const matchedPattern = getMatchingPatternForRow(geoData, map?.patterns)
495
+
496
+ if (!matchedPattern) {
497
+ return null
498
+ }
499
+
500
+ const { pattern: patternData, matchedDataKey } = matchedPattern
501
+ const { pattern, size } = patternData
495
502
  const currentFill = styles.fill
496
- const hasMatchingValues = patternValuesMatch(patternData.dataValue, geoData?.[patternData.dataKey])
497
503
  const patternColor = patternData.color || getContrastColor('#000', currentFill)
498
- const sanitizedDataKey = sanitizeToSvgId(dataKey)
504
+ const sanitizedDataKey = sanitizeToSvgId(matchedDataKey)
499
505
  const patternId = `${mapId}--${sanitizedDataKey}--${geoIndex}`
500
506
 
501
- if (!hasMatchingValues) return
502
507
  checkColorContrast(currentFill, patternColor)
503
508
 
504
509
  return (
@@ -533,7 +538,7 @@ const UsaMap = () => {
533
538
  />
534
539
  )}
535
540
  <path
536
- className={`pattern-geoKey--${dataKey}`}
541
+ className={`pattern-geoKey--${matchedDataKey}`}
537
542
  tabIndex={-1}
538
543
  stroke='transparent'
539
544
  d={path}
@@ -541,7 +546,7 @@ const UsaMap = () => {
541
546
  />
542
547
  </>
543
548
  )
544
- })}
549
+ })()}
545
550
  {(displayAsHex || showLabel) && geoLabel(geo, legendColors[0], projection)}
546
551
  {displayAsHex && hexMap.type === 'shapes' && getArrowDirection(geoData, geo, legendColors[0])}
547
552
  </g>
@@ -36,8 +36,6 @@ import { getVizTitle, getVizSubType } from '@cdc/core/helpers/metrics/utils'
36
36
 
37
37
  let projection = geoMercator()
38
38
 
39
- const GRAYED_OUT_COLOR = '#d3d3d3'
40
-
41
39
  type MapPosition = { coordinates: number[]; zoom: number }
42
40
 
43
41
  const WorldMap = () => {
@@ -68,14 +66,14 @@ const WorldMap = () => {
68
66
 
69
67
  useEffect(() => {
70
68
  const fetchData = async () => {
71
- import(/* webpackChunkName: "world-map-2026" */ './data/world-topo.json')
69
+ import(/* webpackChunkName: "world-topo" */ './data/world-topo.json')
72
70
  .then(topoJSON => {
73
71
  // Smart detection of TopoJSON object key
74
72
  // Try known keys first, then fall back to first available key
75
73
  const objectKey = topoJSON.objects.countries
76
74
  ? 'countries'
77
- : topoJSON.objects.Cove_World_Map_2025
78
- ? 'Cove_World_Map_2025'
75
+ : topoJSON.objects.Cove_World_Map_2026_corr
76
+ ? 'Cove_World_Map_2026_corr'
79
77
  : Object.keys(topoJSON.objects)[0]
80
78
 
81
79
  if (!objectKey) {
@@ -238,7 +236,7 @@ const WorldMap = () => {
238
236
 
239
237
  let geoData = runtimeData[geoKey]
240
238
 
241
- const geoDisplayName = displayGeoName(supportedCountries[geo.properties.iso]?.[0])
239
+ const geoDisplayName = displayGeoName(geo.properties.iso)
242
240
  let legendColors
243
241
 
244
242
  // Once we receive data for this geographic item, setup variables.
@@ -277,9 +275,8 @@ const WorldMap = () => {
277
275
  }
278
276
 
279
277
  let styles: Record<string, string | Record<string, string>> = {
280
- fill: isGreyedOut ? GRAYED_OUT_COLOR : geoFillColor,
281
- cursor: 'default',
282
- ...(isGreyedOut && { opacity: '0.3' })
278
+ fill: geoFillColor,
279
+ cursor: 'default'
283
280
  }
284
281
 
285
282
  // Scale stroke width inversely with zoom level to maintain consistent visual thickness
@@ -293,13 +290,13 @@ const WorldMap = () => {
293
290
  if (legendColors && legendColors[0] !== '#000000' && type !== 'bubble') {
294
291
  styles = {
295
292
  ...styles,
296
- fill: isGreyedOut ? GRAYED_OUT_COLOR : type !== 'world-geocode' ? legendColors[0] : geoFillColor,
293
+ fill: isGreyedOut ? geoFillColor : type !== 'world-geocode' ? legendColors[0] : geoFillColor,
297
294
  cursor: 'default',
298
295
  '&:hover': {
299
- fill: isGreyedOut ? GRAYED_OUT_COLOR : type !== 'world-geocode' ? legendColors[1] : geoFillColor
296
+ fill: isGreyedOut ? geoFillColor : type !== 'world-geocode' ? legendColors[1] : geoFillColor
300
297
  },
301
298
  '&:active': {
302
- fill: isGreyedOut ? GRAYED_OUT_COLOR : type !== 'world-geocode' ? legendColors[2] : geoFillColor
299
+ fill: isGreyedOut ? geoFillColor : type !== 'world-geocode' ? legendColors[2] : geoFillColor
303
300
  }
304
301
  }
305
302
 
@@ -419,7 +416,7 @@ const WorldMap = () => {
419
416
  </ZoomableGroup>
420
417
  </svg>
421
418
  )}
422
- {(type === 'data' || (type === 'world-geocode' && allowMapZoom) || (type === 'bubble' && allowMapZoom)) && (
419
+ {allowMapZoom && (
423
420
  <ZoomControls handleZoomIn={handleZoomIn} handleZoomOut={handleZoomOut} handleZoomReset={handleZoomReset} />
424
421
  )}
425
422
  </ErrorBoundary>