@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.
- package/LICENSE +201 -0
- package/dist/cdcmap-vr9HZwRt.es.js +6 -0
- package/dist/cdcmap.js +26781 -24615
- package/examples/private/annotation-bug.json +642 -0
- package/package.json +3 -3
- package/src/CdcMap.tsx +3 -14
- package/src/CdcMapComponent.tsx +214 -159
- package/src/_stories/CdcMap.Defaults.stories.tsx +76 -0
- package/src/_stories/CdcMap.Editor.stories.tsx +187 -14
- package/src/_stories/CdcMap.stories.tsx +11 -1
- package/src/_stories/Map.HTMLInDataTable.stories.tsx +385 -0
- package/src/_stories/_mock/multi-state-show-unselected.json +82 -0
- package/src/cdcMapComponent.styles.css +2 -2
- package/src/components/Annotation/Annotation.Draggable.styles.css +4 -4
- package/src/components/Annotation/AnnotationDropdown.styles.css +1 -1
- package/src/components/Annotation/AnnotationList.styles.css +13 -13
- package/src/components/EditorPanel/components/EditorPanel.tsx +426 -58
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings-style.css +1 -1
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +5 -2
- package/src/components/EditorPanel/components/editorPanel.styles.css +34 -24
- package/src/components/Legend/components/Legend.tsx +9 -4
- package/src/components/Legend/components/LegendGroup/legend.group.css +5 -5
- package/src/components/Legend/components/index.scss +2 -3
- package/src/components/NavigationMenu.tsx +2 -1
- package/src/components/SmallMultiples/SmallMultiples.css +5 -5
- package/src/components/UsaMap/components/SingleState/SingleState.StateOutput.tsx +32 -17
- package/src/components/UsaMap/components/TerritoriesSection.tsx +3 -2
- package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +13 -8
- package/src/components/UsaMap/components/UsaMap.County.tsx +410 -183
- package/src/components/UsaMap/components/UsaMap.Region.styles.css +1 -1
- package/src/components/UsaMap/components/UsaMap.SingleState.styles.css +2 -2
- package/src/components/UsaMap/components/UsaMap.State.tsx +13 -8
- package/src/components/WorldMap/WorldMap.tsx +10 -13
- package/src/components/WorldMap/data/world-topo-updated.json +1 -0
- package/src/components/WorldMap/data/world-topo.json +1 -1
- package/src/components/WorldMap/worldMap.styles.css +1 -1
- package/src/components/ZoomControls.tsx +49 -18
- package/src/components/zoomControls.styles.css +27 -11
- package/src/data/initial-state.js +14 -5
- package/src/data/legacy-defaults.ts +8 -0
- package/src/data/supported-geos.js +19 -0
- package/src/helpers/colors.ts +2 -1
- package/src/helpers/dataTableHelpers.ts +56 -0
- package/src/helpers/displayGeoName.ts +19 -11
- package/src/helpers/getMapContainerClasses.ts +8 -2
- package/src/helpers/getMatchingPatternForRow.ts +67 -0
- package/src/helpers/getPatternForRow.ts +11 -18
- package/src/helpers/tests/dataTableHelpers.test.ts +78 -0
- package/src/helpers/tests/displayGeoName.test.ts +17 -0
- package/src/helpers/tests/getMatchingPatternForRow.test.ts +150 -0
- package/src/helpers/tests/getPatternForRow.test.ts +140 -2
- package/src/helpers/urlDataHelpers.ts +7 -1
- package/src/hooks/useResizeObserver.ts +36 -22
- package/src/hooks/useTooltip.test.tsx +64 -0
- package/src/hooks/useTooltip.ts +28 -8
- package/src/scss/editor-panel.scss +1 -1
- package/src/scss/main.scss +140 -6
- package/src/scss/map.scss +9 -4
- package/src/store/map.actions.ts +2 -0
- package/src/store/map.reducer.ts +4 -0
- package/src/test/CdcMap.test.jsx +2 -2
- package/src/types/MapConfig.ts +22 -4
- package/src/types/MapContext.ts +3 -1
- package/dist/cdcmap-Cf9_fbQf.es.js +0 -6
- package/src/helpers/componentHelpers.ts +0 -8
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
SVG_WIDTH
|
|
49
49
|
} from '../../../helpers'
|
|
50
50
|
import { hashObj } from '@cdc/core/helpers/hashObj'
|
|
51
|
-
import {
|
|
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
|
-
{
|
|
494
|
-
const
|
|
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(
|
|
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--${
|
|
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-
|
|
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.
|
|
78
|
-
? '
|
|
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(
|
|
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:
|
|
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 ?
|
|
293
|
+
fill: isGreyedOut ? geoFillColor : type !== 'world-geocode' ? legendColors[0] : geoFillColor,
|
|
297
294
|
cursor: 'default',
|
|
298
295
|
'&:hover': {
|
|
299
|
-
fill: isGreyedOut ?
|
|
296
|
+
fill: isGreyedOut ? geoFillColor : type !== 'world-geocode' ? legendColors[1] : geoFillColor
|
|
300
297
|
},
|
|
301
298
|
'&:active': {
|
|
302
|
-
fill: isGreyedOut ?
|
|
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
|
-
{
|
|
419
|
+
{allowMapZoom && (
|
|
423
420
|
<ZoomControls handleZoomIn={handleZoomIn} handleZoomOut={handleZoomOut} handleZoomReset={handleZoomReset} />
|
|
424
421
|
)}
|
|
425
422
|
</ErrorBoundary>
|