@cdc/map 4.26.3 → 4.26.5
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/CONFIG.md +268 -0
- package/README.md +74 -24
- package/dist/cdcmap-CY9IcPSi.es.js +6 -0
- package/dist/cdcmap-DlpiY3fQ.es.js +4 -0
- package/dist/cdcmap.js +29168 -27482
- package/examples/{testing-layer-2.json → __data__/testing-layer-2.json} +1 -1
- package/examples/{testing-layer.json → __data__/testing-layer.json} +1 -1
- package/examples/county-hsa-toggle.json +51993 -0
- package/examples/custom-map-layers.json +2 -2
- package/examples/default-county.json +6 -3
- package/examples/minimal-example.json +73 -0
- package/examples/private/annotation-bug.json +2 -2
- package/examples/private/css-issue.json +314 -0
- package/examples/private/region-breaking.json +1639 -0
- package/examples/private/test1.json +27247 -0
- package/package.json +4 -4
- package/src/CdcMapComponent.tsx +107 -14
- package/src/_stories/CdcMap.AltText.stories.tsx +122 -0
- package/src/_stories/CdcMap.Editor.ColumnsSectionTests.stories.tsx +600 -0
- package/src/_stories/CdcMap.Editor.DataTableSectionTests.stories.tsx +404 -0
- package/src/_stories/CdcMap.Editor.FiltersSectionTests.stories.tsx +229 -0
- package/src/_stories/CdcMap.Editor.GeneralSectionTests.stories.tsx +262 -0
- package/src/_stories/CdcMap.Editor.LegendSectionTests.stories.tsx +541 -0
- package/src/_stories/CdcMap.Editor.MultiCountryWorldMapTests.stories.tsx +359 -0
- package/src/_stories/CdcMap.Editor.PatternSettingsSectionTests.stories.tsx +516 -0
- package/src/_stories/CdcMap.Editor.SmallMultiplesSectionTests.stories.tsx +165 -0
- package/src/_stories/CdcMap.Editor.TextAnnotationsSectionTests.stories.tsx +145 -0
- package/src/_stories/CdcMap.Editor.TypeSectionTests.stories.tsx +312 -0
- package/src/_stories/CdcMap.Editor.VisualSectionTests.stories.tsx +359 -0
- package/src/_stories/CdcMap.Editor.ZoomControlsTests.stories.tsx +88 -0
- package/src/_stories/CdcMap.FocusVisibility.stories.tsx +87 -0
- package/src/_stories/CdcMap.HiddenMount.stories.tsx +69 -0
- package/src/_stories/CdcMap.ResetBehavior.stories.tsx +32 -0
- package/src/_stories/CdcMap.Zoom.stories.tsx +111 -0
- package/src/_stories/{CdcMap.stories.tsx → CdcMap.smoke.stories.tsx} +60 -0
- package/src/_stories/_mock/alt_text_metadata.json +65 -0
- package/src/_stories/_mock/legends/legend-tests.json +3 -3
- package/src/_stories/_mock/world-bubble-reset.json +138 -0
- package/src/_stories/_mock/world-data-zoom-filters.json +166 -0
- package/src/components/Annotation/AnnotationList.tsx +1 -1
- package/src/components/BubbleList.tsx +13 -0
- package/src/components/EditorPanel/components/EditorPanel.tsx +637 -382
- package/src/components/EditorPanel/components/HexShapeSettings.tsx +1 -1
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +112 -117
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +26 -13
- package/src/components/EditorPanel/components/editorPanel.styles.css +22 -2
- package/src/components/FilterControls.tsx +21 -0
- package/src/components/Legend/components/Legend.tsx +3 -3
- package/src/components/Legend/components/LegendItem.Hex.tsx +4 -2
- package/src/components/SmallMultiples/SmallMultiples.tsx +2 -2
- package/src/components/SmallMultiples/SynchronizedTooltip.tsx +1 -1
- package/src/components/UsaMap/components/UsaMap.County.tsx +309 -108
- package/src/components/UsaMap/components/UsaMap.Region.tsx +5 -2
- package/src/components/UsaMap/components/UsaMap.SingleState.tsx +33 -10
- package/src/components/UsaMap/components/UsaMap.State.tsx +10 -3
- package/src/components/UsaMap/data/cb_2019_us_county_20m.json +75817 -1
- package/src/components/UsaMap/data/hsa_fips_mapping.json +3144 -0
- package/src/components/WorldMap/WorldMap.tsx +37 -4
- package/src/components/WorldMap/data/world-topo.json +1 -1
- package/src/components/ZoomableGroup.tsx +23 -3
- package/src/components/filterControls.styles.css +6 -0
- package/src/data/initial-state.js +3 -0
- package/src/data/supported-counties.json +1 -1
- package/src/helpers/countyTerritories.ts +38 -0
- package/src/helpers/dataTableHelpers.ts +35 -6
- package/src/helpers/generateRuntimeFilters.ts +2 -1
- package/src/helpers/handleMapAriaLabels.ts +45 -30
- package/src/helpers/shouldAutoResetSingleStateZoom.ts +22 -0
- package/src/helpers/tests/countyTerritories.test.ts +87 -0
- package/src/helpers/tests/handleMapAriaLabels.test.ts +71 -0
- package/src/helpers/tests/shouldAutoResetSingleStateZoom.test.ts +71 -0
- package/src/hooks/useApplyTooltipsToGeo.tsx +7 -4
- package/src/hooks/useGeoClickHandler.ts +13 -1
- package/src/hooks/useMapLayers.tsx +1 -1
- package/src/hooks/useStateZoom.tsx +39 -20
- package/src/hooks/useTooltip.test.tsx +2 -16
- package/src/hooks/useTooltip.ts +18 -7
- package/src/index.jsx +5 -2
- package/src/scss/main.scss +6 -21
- package/src/scss/map.scss +20 -0
- package/src/store/map.actions.ts +5 -2
- package/src/store/map.reducer.ts +12 -3
- package/src/test/CdcMap.test.jsx +24 -0
- package/src/types/MapConfig.ts +11 -0
- package/src/types/MapContext.ts +6 -1
- package/topojson-updater/README.txt +1 -1
- package/dist/cdcmap-vr9HZwRt.es.js +0 -6
- package/examples/__data__/city-state-data.json +0 -668
- package/examples/city-state.json +0 -434
- package/examples/default-world-data.json +0 -1450
- package/examples/new-cities.json +0 -656
- package/src/_stories/CdcMap.Editor.stories.tsx +0 -3648
- package/topojson-updater/package-lock.json +0 -223
- /package/src/_stories/{CdcMap.ColumnWrap.stories.tsx → CdcMap.ColumnWrap.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.Defaults.stories.tsx → CdcMap.Defaults.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.DistrictOfColumbia.stories.tsx → CdcMap.DistrictOfColumbia.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.Filters.stories.tsx → CdcMap.Filters.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.Legend.Gradient.stories.tsx → CdcMap.Legend.Gradient.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.Legend.stories.tsx → CdcMap.Legend.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.Patterns.stories.tsx → CdcMap.Patterns.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.SmallMultiples.stories.tsx → CdcMap.SmallMultiples.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.Table.stories.tsx → CdcMap.Table.smoke.stories.tsx} +0 -0
- /package/src/_stories/{CdcMap.ZeroColor.stories.tsx → CdcMap.ZeroColor.smoke.stories.tsx} +0 -0
- /package/src/_stories/{GoogleMap.stories.tsx → GoogleMap.smoke.stories.tsx} +0 -0
- /package/src/_stories/{UsaMap.NoData.stories.tsx → UsaMap.NoData.smoke.stories.tsx} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { memo, useContext, useState, useEffect } from 'react'
|
|
1
|
+
import { memo, useContext, useState, useEffect, useRef } from 'react'
|
|
2
2
|
import { geoMercator } from 'd3-geo'
|
|
3
3
|
import { Mercator } from '@visx/geo'
|
|
4
4
|
import { feature } from 'topojson-client'
|
|
@@ -27,6 +27,7 @@ import useGeoClickHandler from '../../hooks/useGeoClickHandler'
|
|
|
27
27
|
import useApplyTooltipsToGeo from '../../hooks/useApplyTooltipsToGeo'
|
|
28
28
|
import useCountryZoom from '../../hooks/useCountryZoom'
|
|
29
29
|
import generateRuntimeData from '../../helpers/generateRuntimeData'
|
|
30
|
+
import { generateRuntimeFilters } from '../../helpers/generateRuntimeFilters'
|
|
30
31
|
import { applyLegendToRow } from '../../helpers/applyLegendToRow'
|
|
31
32
|
import { normalizeTopoJsonProperties } from '../../helpers/normalizeTopoJsonProperties'
|
|
32
33
|
|
|
@@ -42,6 +43,8 @@ const WorldMap = () => {
|
|
|
42
43
|
// prettier-ignore
|
|
43
44
|
const {
|
|
44
45
|
runtimeData,
|
|
46
|
+
runtimeFilters,
|
|
47
|
+
filteredCountryCode,
|
|
45
48
|
position: mapPosition,
|
|
46
49
|
config,
|
|
47
50
|
tooltipId,
|
|
@@ -49,6 +52,8 @@ const WorldMap = () => {
|
|
|
49
52
|
interactionLabel
|
|
50
53
|
} = useContext(ConfigContext)
|
|
51
54
|
|
|
55
|
+
const a11y = handleMapAriaLabels(config)
|
|
56
|
+
|
|
52
57
|
// Type assertion: position from context is actually the map viewport position, not legend position
|
|
53
58
|
const position = mapPosition as unknown as MapPosition
|
|
54
59
|
|
|
@@ -63,6 +68,9 @@ const WorldMap = () => {
|
|
|
63
68
|
const { centerOnCountries } = useCountryZoom(world)
|
|
64
69
|
|
|
65
70
|
const dispatch = useContext(MapDispatchContext)
|
|
71
|
+
const previousWorldBubbleRuntimeData = useRef(runtimeData)
|
|
72
|
+
const isWorldBubbleMap = config.general.geoType === 'world' && config.general.type === 'bubble'
|
|
73
|
+
const isDrilledBubbleView = isWorldBubbleMap && Boolean(filteredCountryCode)
|
|
66
74
|
|
|
67
75
|
useEffect(() => {
|
|
68
76
|
const fetchData = async () => {
|
|
@@ -98,6 +106,11 @@ const WorldMap = () => {
|
|
|
98
106
|
fetchData()
|
|
99
107
|
}, [])
|
|
100
108
|
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (!isWorldBubbleMap || isDrilledBubbleView || runtimeData?.init) return
|
|
111
|
+
previousWorldBubbleRuntimeData.current = runtimeData
|
|
112
|
+
}, [isWorldBubbleMap, isDrilledBubbleView, runtimeData])
|
|
113
|
+
|
|
101
114
|
if (!world) {
|
|
102
115
|
return <></>
|
|
103
116
|
}
|
|
@@ -115,8 +128,19 @@ const WorldMap = () => {
|
|
|
115
128
|
|
|
116
129
|
const filteredWorld = getFilteredWorld()
|
|
117
130
|
|
|
131
|
+
const rebuildRuntimeDataFromActiveFilters = () => {
|
|
132
|
+
const activeFilters = runtimeFilters?.length ? runtimeFilters : generateRuntimeFilters(config, undefined, [])
|
|
133
|
+
|
|
134
|
+
return generateRuntimeData(
|
|
135
|
+
config,
|
|
136
|
+
activeFilters,
|
|
137
|
+
runtimeFilters?.fromHash ?? runtimeData?.fromHash,
|
|
138
|
+
config.legend?.type === 'category',
|
|
139
|
+
config.table?.showNonGeoData
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
118
143
|
const handleFiltersReset = () => {
|
|
119
|
-
const newRuntimeData = generateRuntimeData(config)
|
|
120
144
|
publishAnalyticsEvent({
|
|
121
145
|
vizType: config.type,
|
|
122
146
|
vizSubType: getVizSubType(config),
|
|
@@ -125,6 +149,7 @@ const WorldMap = () => {
|
|
|
125
149
|
eventLabel: interactionLabel,
|
|
126
150
|
vizTitle: getVizTitle(config)
|
|
127
151
|
})
|
|
152
|
+
const newRuntimeData = rebuildRuntimeDataFromActiveFilters()
|
|
128
153
|
dispatch({ type: 'SET_FILTERED_COUNTRY_CODE', payload: '' })
|
|
129
154
|
dispatch({ type: 'SET_RUNTIME_DATA', payload: newRuntimeData })
|
|
130
155
|
}
|
|
@@ -139,6 +164,14 @@ const WorldMap = () => {
|
|
|
139
164
|
vizTitle: getVizTitle(config)
|
|
140
165
|
})
|
|
141
166
|
|
|
167
|
+
if (isWorldBubbleMap) {
|
|
168
|
+
const newRuntimeData = isDrilledBubbleView
|
|
169
|
+
? previousWorldBubbleRuntimeData.current
|
|
170
|
+
: rebuildRuntimeDataFromActiveFilters()
|
|
171
|
+
dispatch({ type: 'SET_FILTERED_COUNTRY_CODE', payload: '' })
|
|
172
|
+
dispatch({ type: 'SET_RUNTIME_DATA', payload: newRuntimeData })
|
|
173
|
+
}
|
|
174
|
+
|
|
142
175
|
// If countries are selected, center on them; otherwise, use default world position
|
|
143
176
|
const countriesPicked = getCountriesPicked(config)
|
|
144
177
|
|
|
@@ -387,7 +420,7 @@ const WorldMap = () => {
|
|
|
387
420
|
return (
|
|
388
421
|
<ErrorBoundary component='WorldMap'>
|
|
389
422
|
{allowMapZoom ? (
|
|
390
|
-
<svg viewBox={SVG_VIEWBOX} role='img' aria-label={
|
|
423
|
+
<svg viewBox={SVG_VIEWBOX} role='img' aria-label={a11y}>
|
|
391
424
|
<rect height={SVG_HEIGHT} width={SVG_WIDTH} onClick={handleFiltersReset} fill='white' />
|
|
392
425
|
<ZoomableGroup
|
|
393
426
|
zoom={position.zoom}
|
|
@@ -402,7 +435,7 @@ const WorldMap = () => {
|
|
|
402
435
|
</ZoomableGroup>
|
|
403
436
|
</svg>
|
|
404
437
|
) : (
|
|
405
|
-
<svg viewBox={SVG_VIEWBOX}>
|
|
438
|
+
<svg viewBox={SVG_VIEWBOX} role='img' aria-label={a11y}>
|
|
406
439
|
<ZoomableGroup
|
|
407
440
|
zoom={1}
|
|
408
441
|
center={position.coordinates}
|