@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.
- package/.claude/settings.local.json +30 -0
- package/dist/cdcmap.js +54263 -52600
- package/examples/private/c.json +290 -0
- package/examples/private/canvas-city-hover.json +787 -0
- package/examples/private/d.json +345 -0
- package/examples/private/g.json +1 -0
- package/examples/private/h.json +105911 -0
- package/examples/private/measles-data.json +378 -0
- package/examples/private/measles.json +211 -0
- package/examples/private/north-dakota.json +1132 -0
- package/examples/private/state-with-pattern.json +883 -0
- package/index.html +35 -34
- package/package.json +26 -5
- package/src/CdcMap.tsx +23 -8
- package/src/CdcMapComponent.tsx +215 -309
- package/src/_stories/CdcMap.Filters.stories.tsx +2 -2
- package/src/_stories/CdcMap.Legend.Gradient.stories.tsx +3 -3
- package/src/_stories/CdcMap.Legend.stories.tsx +7 -4
- package/src/_stories/CdcMap.Patterns.stories.tsx +2 -2
- package/src/_stories/CdcMap.Table.stories.tsx +2 -2
- package/src/_stories/CdcMap.stories.tsx +15 -5
- package/src/_stories/GoogleMap.stories.tsx +2 -2
- package/src/_stories/UsaMap.NoData.stories.tsx +2 -2
- package/src/_stories/_mock/equal-number.json +1109 -0
- package/src/_stories/_mock/us-bubble-cities.json +306 -0
- package/src/components/BubbleList.tsx +16 -12
- package/src/components/CityList.tsx +85 -107
- package/src/components/DataTable.tsx +37 -9
- package/src/components/EditorPanel/components/EditorPanel.tsx +177 -165
- package/src/components/EditorPanel/components/HexShapeSettings.tsx +3 -2
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +7 -5
- package/src/components/Geo.tsx +2 -0
- package/src/components/Legend/components/Legend.tsx +109 -73
- package/src/components/Legend/components/LegendGroup/Legend.Group.tsx +10 -7
- package/src/components/MapContainer.tsx +52 -0
- package/src/components/MapControls.tsx +44 -0
- package/src/components/NavigationMenu.tsx +11 -2
- package/src/components/UsaMap/components/SingleState/SingleState.CountyOutput.tsx +24 -7
- package/src/components/UsaMap/components/UsaMap.County.tsx +111 -37
- package/src/components/UsaMap/components/UsaMap.Region.tsx +23 -5
- package/src/components/UsaMap/components/UsaMap.SingleState.tsx +6 -6
- package/src/components/UsaMap/components/UsaMap.State.tsx +28 -10
- package/src/components/UsaMap/helpers/map.ts +2 -2
- package/src/components/WorldMap/WorldMap.tsx +113 -25
- package/src/components/ZoomControls.tsx +6 -9
- package/src/context/LegendMemoContext.tsx +30 -0
- package/src/context.ts +1 -40
- package/src/data/initial-state.js +143 -130
- package/src/data/supported-geos.js +17 -2
- package/src/helpers/applyColorToLegend.ts +116 -20
- package/src/helpers/applyLegendToRow.ts +10 -6
- package/src/helpers/componentHelpers.ts +8 -0
- package/src/helpers/constants.ts +12 -0
- package/src/helpers/dataTableHelpers.ts +6 -0
- package/src/helpers/displayGeoName.ts +1 -1
- package/src/helpers/generateRuntimeLegend.ts +44 -8
- package/src/helpers/generateRuntimeLegendHash.ts +4 -2
- package/src/helpers/getColumnNames.ts +1 -1
- package/src/helpers/getPatternForRow.ts +36 -0
- package/src/helpers/getStatesPicked.ts +8 -5
- package/src/helpers/index.ts +11 -3
- package/src/helpers/isLegendItemDisabled.ts +16 -0
- package/src/helpers/mapObserverHelpers.ts +40 -0
- package/src/helpers/resetLegendToggles.ts +3 -2
- package/src/helpers/toggleLegendActive.ts +6 -11
- package/src/helpers/urlDataHelpers.ts +70 -0
- package/src/hooks/useGeoClickHandler.ts +35 -1
- package/src/hooks/useLegendMemo.ts +17 -0
- package/src/hooks/useMapLayers.tsx +5 -4
- package/src/hooks/useStateZoom.tsx +25 -6
- package/src/hooks/useTooltip.ts +1 -2
- package/src/index.jsx +0 -2
- package/src/store/map.reducer.ts +17 -6
- package/src/test/CdcMap.test.jsx +11 -0
- package/src/types/MapConfig.ts +23 -14
- package/src/types/MapContext.ts +0 -7
- package/src/types/runtimeLegend.ts +17 -1
- package/vite.config.js +2 -7
- package/vitest.config.ts +16 -0
- package/src/coreStyles_map.scss +0 -3
- package/src/helpers/colorDistributions.ts +0 -12
- package/src/helpers/generateColorsArray.ts +0 -14
- package/src/helpers/tests/generateColorsArray.test.ts +0 -18
- 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.
|
|
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(
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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=
|
|
384
|
+
tabIndex={0}
|
|
357
385
|
role='gridcell'
|
|
358
|
-
onClick={
|
|
386
|
+
onClick={() =>
|
|
359
387
|
state.general.type === 'bubble' &&
|
|
360
388
|
state.general.allowMapZoom &&
|
|
361
389
|
state.general.geoType === 'world'
|