@cdc/map 4.24.12 → 4.25.1
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/dist/cdcmap.js +51010 -49337
- package/examples/annotation/index.json +1 -1
- package/examples/custom-map-layers.json +1 -1
- package/examples/default-geocode.json +2 -2
- package/examples/private/DEV-9989.json +229 -0
- package/examples/private/ardi.json +180 -0
- package/examples/private/colors 2.json +416 -0
- package/examples/private/colors.json +416 -0
- package/examples/private/colors.json.zip +0 -0
- package/examples/private/customColors.json +45348 -0
- package/examples/private/mmr.json +246 -0
- package/examples/private/test.json +1632 -0
- package/index.html +12 -14
- package/package.json +8 -3
- package/src/CdcMap.tsx +126 -394
- package/src/_stories/CdcMap.Legend.Gradient.stories.tsx +9 -0
- package/src/_stories/CdcMap.stories.tsx +1 -1
- package/src/_stories/GoogleMap.stories.tsx +19 -0
- package/src/_stories/_mock/DEV-10148.json +859 -0
- package/src/_stories/_mock/DEV-9989.json +229 -0
- package/src/_stories/_mock/example-city-state.json +1 -1
- package/src/_stories/_mock/google-map.json +819 -0
- package/src/components/Annotation/Annotation.Draggable.tsx +34 -43
- package/src/components/Annotation/AnnotationDropdown.tsx +4 -4
- package/src/components/CityList.tsx +2 -2
- package/src/components/DataTable.tsx +8 -9
- package/src/components/EditorPanel/components/EditorPanel.tsx +96 -270
- package/src/components/GoogleMap/components/GoogleMap.tsx +67 -0
- package/src/components/GoogleMap/index.tsx +3 -0
- package/src/components/Legend/components/Legend.tsx +40 -30
- package/src/components/Legend/components/LegendItem.Hex.tsx +7 -3
- package/src/components/Legend/components/index.scss +22 -16
- package/src/components/Modal.tsx +6 -5
- package/src/components/NavigationMenu.tsx +5 -4
- package/src/components/UsaMap/components/TerritoriesSection.tsx +56 -0
- package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +3 -3
- package/src/components/UsaMap/components/UsaMap.County.tsx +1 -1
- package/src/components/UsaMap/components/UsaMap.Region.tsx +12 -8
- package/src/components/UsaMap/components/UsaMap.SingleState.tsx +2 -2
- package/src/components/UsaMap/components/UsaMap.State.tsx +23 -29
- package/src/components/WorldMap/WorldMap.tsx +3 -5
- package/src/context.ts +0 -12
- package/src/data/initial-state.js +2 -2
- package/src/data/supported-geos.js +23 -3
- package/src/helpers/applyColorToLegend.ts +3 -3
- package/src/helpers/closeModal.ts +9 -0
- package/src/helpers/handleMapAriaLabels.ts +38 -0
- package/src/helpers/indexOfIgnoreType.ts +8 -0
- package/src/helpers/navigationHandler.ts +21 -0
- package/src/helpers/toTitleCase.ts +44 -0
- package/src/helpers/validateFipsCodeLength.ts +30 -0
- package/src/hooks/useResizeObserver.ts +42 -0
- package/src/hooks/useTooltip.ts +4 -2
- package/src/index.jsx +1 -0
- package/src/scss/editor-panel.scss +2 -1
- package/src/scss/filters.scss +0 -5
- package/src/scss/main.scss +57 -61
- package/src/scss/map.scss +1 -13
- package/src/types/MapConfig.ts +20 -11
- package/src/types/MapContext.ts +4 -12
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import { useContext, useState,
|
|
2
|
-
|
|
3
|
-
// helpers
|
|
4
|
-
import { applyBandScaleOffset, handleConnectionHorizontalType, handleConnectionVerticalType, createPoints } from '@cdc/chart/src/components/Annotations/components/helpers'
|
|
1
|
+
import { useContext, useState, useRef } from 'react'
|
|
5
2
|
|
|
6
3
|
// visx
|
|
7
|
-
import { HtmlLabel, CircleSubject,
|
|
4
|
+
import { HtmlLabel, CircleSubject, EditableAnnotation, Connector, Annotation as VisxAnnotation } from '@visx/annotation'
|
|
8
5
|
import { Drag, raise } from '@visx/drag'
|
|
9
6
|
import { MarkerArrow } from '@visx/marker'
|
|
10
|
-
import { LinePath } from '@visx/shape'
|
|
11
|
-
import * as allCurves from '@visx/curve'
|
|
12
|
-
import { Annotation } from '@cdc/core/types/Annotation'
|
|
13
7
|
|
|
14
8
|
// styles
|
|
15
9
|
import './Annotation.Draggable.styles.css'
|
|
@@ -18,41 +12,18 @@ import { MapContext } from '../../types/MapContext'
|
|
|
18
12
|
|
|
19
13
|
const Annotations = ({ xScale, yScale, xMax, svgRef, onDragStateChange }) => {
|
|
20
14
|
const [draggingItems, setDraggingItems] = useState([])
|
|
21
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
state: config,
|
|
17
|
+
setState: updateConfig,
|
|
18
|
+
isDraggingAnnotation,
|
|
19
|
+
isEditor,
|
|
20
|
+
dimensions
|
|
21
|
+
} = useContext<MapContext>(ConfigContext)
|
|
22
22
|
const [width, height] = dimensions
|
|
23
23
|
const { annotations } = config
|
|
24
|
-
// const { colorScale } = useColorScale()
|
|
25
24
|
const prevDimensions = useRef(dimensions)
|
|
26
25
|
const AnnotationComponent = isEditor ? EditableAnnotation : VisxAnnotation
|
|
27
26
|
|
|
28
|
-
const handleMobileXPosition = annotation => {
|
|
29
|
-
if (annotation.snapToNearestPoint) {
|
|
30
|
-
return Number(annotation.dx) + xScale(annotation.xKey) + (config.xAxis.type !== 'date-time' ? xScale.bandwidth() / 2 : 0) + Number(config.yAxis.size)
|
|
31
|
-
}
|
|
32
|
-
return Number(annotation.x) + Number(annotation.dx)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const handleMobileYPosition = annotation => {
|
|
36
|
-
if (annotation.snapToNearestPoint) {
|
|
37
|
-
return yScale(annotation.yKey) + Number(annotation.dy)
|
|
38
|
-
}
|
|
39
|
-
return Number(annotation.dy) + Number(annotation.y)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const handleTextX = annotation => {
|
|
43
|
-
if (annotation.snapToNearestPoint) {
|
|
44
|
-
return Number(annotation.dx) + Number(xScale(annotation.xKey)) + (config.xAxis.type !== 'date-time' ? xScale.bandwidth() / 2 : 0) + Number(config.yAxis.size) - 16 / 3
|
|
45
|
-
}
|
|
46
|
-
return Number(annotation.dx) + Number(annotation.x) - 16 / 3
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const handleTextY = annotation => {
|
|
50
|
-
if (annotation.snapToNearestPoint) {
|
|
51
|
-
return yScale(annotation.yKey) + Number(annotation.dy) + 5
|
|
52
|
-
}
|
|
53
|
-
return Number(annotation.y) + Number(annotation.dy) + 16 / 3
|
|
54
|
-
}
|
|
55
|
-
|
|
56
27
|
return (
|
|
57
28
|
annotations &&
|
|
58
29
|
annotations.map((annotation, index) => {
|
|
@@ -118,7 +89,9 @@ const Annotations = ({ xScale, yScale, xMax, svgRef, onDragStateChange }) => {
|
|
|
118
89
|
style={{
|
|
119
90
|
padding: '10px',
|
|
120
91
|
borderRadius: 5, // Optional: set border radius
|
|
121
|
-
backgroundColor: `rgba(255, 255, 255, ${
|
|
92
|
+
backgroundColor: `rgba(255, 255, 255, ${
|
|
93
|
+
annotation?.opacity ? Number(annotation?.opacity) / 100 : 1
|
|
94
|
+
})`
|
|
122
95
|
}}
|
|
123
96
|
role='presentation'
|
|
124
97
|
// ! IMPORTANT: Workaround for 508
|
|
@@ -131,13 +104,31 @@ const Annotations = ({ xScale, yScale, xMax, svgRef, onDragStateChange }) => {
|
|
|
131
104
|
/>
|
|
132
105
|
</HtmlLabel>
|
|
133
106
|
|
|
134
|
-
{annotation.connectionType === 'line' &&
|
|
107
|
+
{annotation.connectionType === 'line' && (
|
|
108
|
+
<Connector type='line' pathProps={{ markerStart: 'url(#marker-start)' }} />
|
|
109
|
+
)}
|
|
135
110
|
|
|
136
|
-
{annotation.connectionType === 'elbow' &&
|
|
111
|
+
{annotation.connectionType === 'elbow' && (
|
|
112
|
+
<Connector type='elbow' pathProps={{ markerStart: 'url(#marker-start)' }} />
|
|
113
|
+
)}
|
|
137
114
|
|
|
138
115
|
{/* MARKERS */}
|
|
139
|
-
{annotation.marker === 'circle' &&
|
|
140
|
-
|
|
116
|
+
{annotation.marker === 'circle' && (
|
|
117
|
+
<CircleSubject className='circle-subject' stroke={'black'} radius={8} />
|
|
118
|
+
)}
|
|
119
|
+
{annotation.marker === 'arrow' && (
|
|
120
|
+
<MarkerArrow
|
|
121
|
+
fill='black'
|
|
122
|
+
id='marker-start'
|
|
123
|
+
x={annotation.x}
|
|
124
|
+
y={annotation.dy}
|
|
125
|
+
stroke='#333'
|
|
126
|
+
markerWidth={10}
|
|
127
|
+
size={10}
|
|
128
|
+
strokeWidth={1}
|
|
129
|
+
orient='auto-start-reverse'
|
|
130
|
+
/>
|
|
131
|
+
)}
|
|
141
132
|
</AnnotationComponent>
|
|
142
133
|
</>
|
|
143
134
|
)
|
|
@@ -2,14 +2,14 @@ import React, { useContext, useState } from 'react'
|
|
|
2
2
|
import ConfigContext from '../../context'
|
|
3
3
|
import './AnnotationDropdown.styles.css'
|
|
4
4
|
import Icon from '@cdc/core/components/ui/Icon'
|
|
5
|
-
import {
|
|
5
|
+
import { appFontSize } from '@cdc/core/helpers/cove/fontSettings'
|
|
6
6
|
import AnnotationList from './AnnotationList'
|
|
7
7
|
|
|
8
8
|
const AnnotationDropdown = () => {
|
|
9
|
-
const {
|
|
9
|
+
const { state: config, isEditor, currentViewport: viewport } = useContext(ConfigContext)
|
|
10
10
|
const [expanded, setExpanded] = useState(false)
|
|
11
11
|
|
|
12
|
-
const titleFontSize = ['sm', 'xs', 'xxs'].includes(viewport) ? '13px' : `${
|
|
12
|
+
const titleFontSize = ['sm', 'xs', 'xxs'].includes(viewport) ? '13px' : `${appFontSize}px`
|
|
13
13
|
|
|
14
14
|
const annotations = config?.annotations || []
|
|
15
15
|
|
|
@@ -19,7 +19,7 @@ const AnnotationDropdown = () => {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const handleAccordionClassName = () => {
|
|
22
|
-
const classNames = ['data-table-heading', 'annotation__dropdown-list']
|
|
22
|
+
const classNames = ['data-table-heading', 'annotation__dropdown-list', 'p-3']
|
|
23
23
|
if (!expanded) {
|
|
24
24
|
classNames.push('collapsed')
|
|
25
25
|
}
|
|
@@ -5,6 +5,7 @@ import { supportedCities } from '../data/supported-geos'
|
|
|
5
5
|
import { scaleLinear } from 'd3-scale'
|
|
6
6
|
import { GlyphStar, GlyphTriangle, GlyphDiamond, GlyphSquare, GlyphCircle } from '@visx/glyph'
|
|
7
7
|
import { getFilterControllingStatePicked } from './UsaMap/helpers/map'
|
|
8
|
+
import { titleCase } from '../helpers/titleCase'
|
|
8
9
|
|
|
9
10
|
import ConfigContext from '../context'
|
|
10
11
|
import { getGeoStrokeColor } from '../helpers/colors'
|
|
@@ -15,14 +16,13 @@ const CityList = ({
|
|
|
15
16
|
applyTooltipsToGeo,
|
|
16
17
|
displayGeoName,
|
|
17
18
|
applyLegendToRow,
|
|
18
|
-
titleCase,
|
|
19
19
|
setSharedFilterValue,
|
|
20
20
|
isFilterValueSupported,
|
|
21
21
|
tooltipId,
|
|
22
22
|
projection
|
|
23
23
|
}) => {
|
|
24
24
|
const [citiesData, setCitiesData] = useState({})
|
|
25
|
-
const {
|
|
25
|
+
const { state, topoData, runtimeData, position } = useContext(ConfigContext)
|
|
26
26
|
if (!projection) return
|
|
27
27
|
|
|
28
28
|
useEffect(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState, memo } from 'react'
|
|
1
|
+
import React, { useEffect, useState, memo, useContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import Papa from 'papaparse'
|
|
4
4
|
import ExternalIcon from '../images/external-link.svg' // TODO: Move to Icon component
|
|
@@ -10,6 +10,8 @@ import MediaControls from '@cdc/core/components/MediaControls'
|
|
|
10
10
|
import SkipTo from '@cdc/core/components/elements/SkipTo'
|
|
11
11
|
|
|
12
12
|
import Loading from '@cdc/core/components/Loading'
|
|
13
|
+
import { navigationHandler } from '../helpers/navigationHandler'
|
|
14
|
+
import ConfigContext from '../context'
|
|
13
15
|
|
|
14
16
|
/* eslint-disable jsx-a11y/no-noninteractive-tabindex, jsx-a11y/no-static-element-interactions */
|
|
15
17
|
const DataTable = props => {
|
|
@@ -26,18 +28,15 @@ const DataTable = props => {
|
|
|
26
28
|
displayDataAsText,
|
|
27
29
|
applyLegendToRow,
|
|
28
30
|
displayGeoName,
|
|
29
|
-
navigationHandler,
|
|
30
|
-
viewport,
|
|
31
31
|
formatLegendLocation,
|
|
32
32
|
tabbingId,
|
|
33
33
|
setFilteredCountryCode
|
|
34
34
|
} = props
|
|
35
35
|
|
|
36
|
+
const { currentViewport: viewport } = useContext(ConfigContext)
|
|
36
37
|
const [expanded, setExpanded] = useState(expandDataTable)
|
|
37
38
|
const [sortBy, setSortBy] = useState({ column: 'geo', asc: false })
|
|
38
|
-
|
|
39
39
|
const [accessibilityLabel, setAccessibilityLabel] = useState('')
|
|
40
|
-
|
|
41
40
|
const fileName = `${mapTitle || 'data-table'}.csv`
|
|
42
41
|
|
|
43
42
|
// Catch all sorting method used on load by default but also on user click
|
|
@@ -118,14 +117,14 @@ const DataTable = props => {
|
|
|
118
117
|
if (columns.navigate && row[columns.navigate.name]) {
|
|
119
118
|
markup = (
|
|
120
119
|
<span
|
|
121
|
-
onClick={() => navigationHandler(row[columns.navigate.name])}
|
|
120
|
+
onClick={() => navigationHandler(state.general.navigationTarget, row[columns.navigate.name])}
|
|
122
121
|
className='table-link'
|
|
123
122
|
title='Click for more information (Opens in a new window)'
|
|
124
123
|
role='link'
|
|
125
124
|
tabIndex='0'
|
|
126
125
|
onKeyDown={e => {
|
|
127
126
|
if (e.keyCode === 13) {
|
|
128
|
-
navigationHandler(row[columns.navigate.name])
|
|
127
|
+
navigationHandler(state.general.navigationTarget, row[columns.navigate.name])
|
|
129
128
|
}
|
|
130
129
|
}}
|
|
131
130
|
>
|
|
@@ -192,7 +191,7 @@ const DataTable = props => {
|
|
|
192
191
|
|
|
193
192
|
const TableMediaControls = ({ belowTable }) => {
|
|
194
193
|
return (
|
|
195
|
-
<MediaControls.Section classes={['download-links']
|
|
194
|
+
<MediaControls.Section classes={['download-links']}>
|
|
196
195
|
<MediaControls.Link config={state} />
|
|
197
196
|
{state.general.showDownloadButton && <DownloadButton />}
|
|
198
197
|
</MediaControls.Section>
|
|
@@ -345,7 +344,7 @@ const DataTable = props => {
|
|
|
345
344
|
</>
|
|
346
345
|
)
|
|
347
346
|
} else {
|
|
348
|
-
cellValue = displayDataAsText(runtimeData[row][state.columns[column].name], column)
|
|
347
|
+
cellValue = displayDataAsText(runtimeData[row][state.columns[column].name], column, state)
|
|
349
348
|
}
|
|
350
349
|
|
|
351
350
|
return (
|