@cdc/map 4.23.11 → 4.24.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.
Files changed (51) hide show
  1. package/dist/cdcmap.js +41327 -40764
  2. package/examples/default-patterns.json +581 -0
  3. package/examples/default-usa.json +159 -57
  4. package/examples/private/map-text-wrap.json +574 -0
  5. package/examples/private/map-world-data.json +1046 -0
  6. package/examples/private/new-world.json +38337 -0
  7. package/examples/private/zika-issue.json +1198 -0
  8. package/index.html +10 -4
  9. package/package.json +3 -3
  10. package/src/CdcMap.tsx +10 -15
  11. package/src/components/{EditorPanel.jsx → EditorPanel/components/EditorPanel.tsx} +30 -62
  12. package/src/components/{HexShapeSettings.jsx → EditorPanel/components/HexShapeSettings.tsx} +0 -49
  13. package/src/components/EditorPanel/components/Inputs.tsx +59 -0
  14. package/src/components/EditorPanel/components/Panel.PatternSettings.tsx +140 -0
  15. package/src/components/EditorPanel/components/Panels.tsx +7 -0
  16. package/src/components/EditorPanel/index.tsx +3 -0
  17. package/src/components/Legend/components/Legend.tsx +183 -0
  18. package/src/components/Legend/components/LegendItem.Hex.tsx +53 -0
  19. package/src/components/Legend/components/index.scss +235 -0
  20. package/src/components/Legend/index.tsx +3 -0
  21. package/src/components/UsaMap/components/Territory/Territory.Hexagon.tsx +129 -0
  22. package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +66 -0
  23. package/src/components/UsaMap/components/Territory/index.tsx +9 -0
  24. package/src/components/{CountyMap.jsx → UsaMap/components/UsaMap.County.tsx} +9 -9
  25. package/src/components/{UsaRegionMap.jsx → UsaMap/components/UsaMap.Region.tsx} +1 -3
  26. package/src/components/{SingleStateMap.jsx → UsaMap/components/UsaMap.SingleState.tsx} +8 -9
  27. package/src/components/{UsaMap.jsx → UsaMap/components/UsaMap.State.tsx} +52 -123
  28. package/src/components/UsaMap/index.tsx +13 -0
  29. package/src/components/{WorldMap.jsx → WorldMap/components/WorldMap.jsx} +6 -6
  30. package/src/components/WorldMap/data/world-topo.json +1 -0
  31. package/src/components/WorldMap/index.tsx +3 -0
  32. package/src/context.ts +2 -1
  33. package/src/data/initial-state.js +3 -1
  34. package/src/scss/main.scss +11 -1
  35. package/src/types/MapConfig.ts +149 -0
  36. package/src/types/MapContext.ts +45 -0
  37. package/src/types/runtimeLegend.ts +1 -0
  38. package/src/components/Sidebar.tsx +0 -142
  39. package/src/data/abbreviations.js +0 -57
  40. package/src/data/feature-test.json +0 -73
  41. package/src/data/newtest.json +0 -1
  42. package/src/data/state-abbreviations.js +0 -60
  43. package/src/data/supported-cities.csv +0 -165
  44. package/src/data/test.json +0 -1
  45. package/src/data/world-topo.json +0 -1
  46. package/src/scss/sidebar.scss +0 -230
  47. /package/src/{data → components/UsaMap/data}/cb_2019_us_county_20m.json +0 -0
  48. /package/src/{data → components/UsaMap/data}/us-hex-topo.json +0 -0
  49. /package/src/{data → components/UsaMap/data}/us-regions-topo-2.json +0 -0
  50. /package/src/{data → components/UsaMap/data}/us-regions-topo.json +0 -0
  51. /package/src/{data → components/UsaMap/data}/us-topo.json +0 -0
@@ -11,6 +11,17 @@
11
11
  .loading > div.la-ball-beat {
12
12
  margin-top: 20%;
13
13
  }
14
+
15
+ .visually-hidden {
16
+ clip: rect(0 0 0 0);
17
+ clip-path: inset(50%);
18
+ height: 1px;
19
+ overflow: hidden;
20
+ position: absolute;
21
+ white-space: nowrap;
22
+ width: 1px;
23
+ }
24
+
14
25
  @include breakpointClass(md) {
15
26
  .map-container.modal-background::before {
16
27
  border-bottom: $lightGray 1px solid;
@@ -22,7 +33,6 @@
22
33
 
23
34
  .cdc-map-inner-container {
24
35
  @import './map';
25
- @import './sidebar';
26
36
  @import './datatable';
27
37
  flex-grow: 1;
28
38
  text-rendering: geometricPrecision;
@@ -0,0 +1,149 @@
1
+ import { ComponentThemes } from '@cdc/core/types/ComponentThemes'
2
+ import { Visualization } from '@cdc/core/types/Visualization'
3
+ import { EditorColumnProperties } from '@cdc/core/types/EditorColumnProperties'
4
+
5
+ export type MapVisualSettings = {
6
+ /** minBubbleSize - Minimum Circle Size when the map has a type of bubble */
7
+ minBubbleSize: number
8
+ /** maxBubbleSize - Maximum Circle Size when the map has a type of bubble */
9
+ maxBubbleSize: number
10
+ /** extraBubbleBorder - Bubble Maps > adds a white circle around the bubble to show contrast on other bubbles */
11
+ extraBubbleBorder: boolean
12
+ /** cityStyle - visual indicator of cities on state maps */
13
+ cityStyle: 'circle' | 'pin'
14
+ /** geoCodeCircleSize - controls the size of the city style option (circle or pin) */
15
+ geoCodeCircleSize: number
16
+ /** showBubbleZeros - shows circles on maps when the data is provided even if its a zero value */
17
+ showBubbleZeros: boolean
18
+ }
19
+
20
+ type PatternSelection = {
21
+ // dropdown selection for getting the column used on a pattern
22
+ dataKey: string
23
+ // text field input to match values found in the column
24
+ dataValue: string
25
+ // style of pattern to use
26
+ pattern: 'lines' | 'circles' | 'waves'
27
+ // optional legend update
28
+ label: string
29
+ }
30
+
31
+ export type GeoColumnProperties = Pick<EditorColumnProperties, 'name' | 'label' | 'tooltip' | 'dataTable'>
32
+ export type LatitudeColumnProperties = Pick<EditorColumnProperties, 'name'>
33
+ export type LongitudeColumnProperties = Pick<EditorColumnProperties, 'name'>
34
+ export type NavigateColumnProperties = Pick<EditorColumnProperties, 'name'>
35
+ export type PrimaryColumnProperties = Pick<EditorColumnProperties, 'dataTable' | 'label' | 'name' | 'prefix' | 'suffix' | 'tooltip'>
36
+
37
+ export type LegendShapeItem = {
38
+ column: string
39
+ key: string
40
+ operator: string
41
+ shape: string
42
+ value: string
43
+ }
44
+
45
+ export type LegendGrouping = {
46
+ legendTitle: string
47
+ legendDescription: string
48
+ items: LegendShapeItem[]
49
+ }
50
+
51
+ export type HexMapSettings = {
52
+ type: 'shapes' | 'standard'
53
+ shapeGroups: LegendGrouping[]
54
+ }
55
+
56
+ export type Coordinate = [number, number]
57
+
58
+ export type MapConfig = Visualization & {
59
+ color: string // map color palette
60
+ customColors: string[] // custom color palette
61
+ columns: {
62
+ geo: GeoColumnProperties
63
+ primary: PrimaryColumnProperties
64
+ navigate: NavigateColumnProperties
65
+ latitude: LatitudeColumnProperties
66
+ longitude: LongitudeColumnProperties
67
+ categorical: { name }
68
+ }
69
+ dataUrl: string
70
+ runtimeDataUrl: string
71
+ filters: any[]
72
+ general: {
73
+ allowMapZoom: boolean
74
+ convertFipsCodes: boolean
75
+ displayAsHex: boolean
76
+ displayStateLabels: boolean
77
+ fullBorder: boolean
78
+ geoBorderColor: string
79
+ geoLabelOverride: string
80
+ geoType: 'us' | 'us-county' | 'world'
81
+ hasRegions: boolean
82
+ headerColor: ComponentThemes
83
+ hideGeoColumnInTooltip: boolean
84
+ hidePrimaryColumnInTooltip: boolean
85
+ language: string
86
+ palette: {
87
+ isReversed: boolean
88
+ }
89
+ showDownloadButton: boolean
90
+ showDownloadMediaButton: boolean
91
+ showSidebar: boolean
92
+ showTitle: boolean
93
+ statePicked: {
94
+ fipsCode: string
95
+ stateName: string
96
+ }
97
+ territoriesAlwaysShow: boolean
98
+ territoriesLabel: string
99
+ title: string
100
+ type: 'data' | 'navigation' | 'us-geocode' | 'world-geocode' | 'bubble'
101
+ }
102
+ legend: {
103
+ additionalCategories
104
+ categoryValuesOrder
105
+ description
106
+ descriptions: {}
107
+ specialClasses: { key; label; value }[]
108
+ unified: boolean
109
+ separateZero: boolean
110
+ singleColumn: boolean
111
+ singleRow: boolean
112
+ verticalSorted: boolean
113
+ showSpecialClassesLast: boolean
114
+ dynamicDescription: boolean
115
+ type: string
116
+ numberOfItems: number
117
+ position: string
118
+ title: string
119
+ }
120
+ table: {
121
+ label: string
122
+ expanded: boolean
123
+ limitHeight: boolean
124
+ height: string
125
+ caption: string
126
+ showDownloadUrl: boolean
127
+ showFullGeoNameInCSV: boolean
128
+ forceDisplay: boolean
129
+ download: boolean
130
+ indexLabel: string
131
+ }
132
+ tooltips: {
133
+ appearanceType: 'hover' | 'click'
134
+ linkLabel: string
135
+ capitalizeLabels: true
136
+ opacity: number
137
+ }
138
+ runtime: {
139
+ editorErrorMessage: string[]
140
+ }
141
+ mapPosition: { coordinates: Coordinate; zoom: number }
142
+ map: {
143
+ layers: { url; namespace; fill; fillOpacity; stroke; strokeWidth; tooltip }[]
144
+ patterns: PatternSelection[]
145
+ }
146
+ hexMap: HexMapSettings
147
+ filterBehavior: string
148
+ visual: MapVisualSettings
149
+ }
@@ -0,0 +1,45 @@
1
+ import { type MapConfig } from './MapConfig'
2
+
3
+ export type MapContext = {
4
+ applyLegendToRow
5
+ applyTooltipsToGeo
6
+ closeModal
7
+ columnsInData
8
+ currentViewport
9
+ data
10
+ displayDataAsText
11
+ displayGeoName
12
+ filteredCountryCode
13
+ generateColorsArray
14
+ generateRuntimeData
15
+ geoClickHandler
16
+ handleCircleClick: Function
17
+ handleMapAriaLabels
18
+ hasZoom
19
+ innerContainerRef
20
+ isDashboard
21
+ isDebug
22
+ isEditor
23
+ loadConfig
24
+ navigationHandler
25
+ position
26
+ resetLegendToggles
27
+ runtimeFilters
28
+ runtimeLegend
29
+ setAccessibleStatus
30
+ setFilteredCountryCode
31
+ setParentConfig
32
+ setPosition
33
+ setRuntimeData
34
+ setRuntimeFilters
35
+ setRuntimeLegend
36
+ setSharedFilterValue
37
+ setState
38
+ state: MapConfig
39
+ supportedCities
40
+ supportedCounties
41
+ supportedCountries
42
+ supportedTerritories
43
+ titleCase
44
+ viewport
45
+ }
@@ -0,0 +1 @@
1
+ export type RuntimeLegend = { disabled; bin; color; special }[]
@@ -1,142 +0,0 @@
1
- //TODO: Move legends to core
2
- import { useContext } from 'react'
3
- import parse from 'html-react-parser'
4
-
5
- import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
6
- import LegendCircle from '@cdc/core/components/LegendCircle'
7
- import HexSetting from './HexShapeSettings'
8
- import useDataVizClasses from '@cdc/core/helpers/useDataVizClasses'
9
- import ConfigContext from '../context'
10
-
11
- const Sidebar = () => {
12
- // prettier-ignore
13
- const {
14
- displayDataAsText,
15
- resetLegendToggles,
16
- runtimeFilters,
17
- runtimeLegend,
18
- setAccessibleStatus,
19
- setRuntimeLegend,
20
- state,
21
- viewport,
22
- } = useContext(ConfigContext)
23
-
24
- const { legend } = state
25
-
26
- // Toggles if a legend is active and being applied to the map and data table.
27
- const toggleLegendActive = (i, legendLabel) => {
28
- const newValue = !runtimeLegend[i].disabled
29
-
30
- runtimeLegend[i].disabled = newValue // Toggle!
31
-
32
- let newLegend = [...runtimeLegend]
33
-
34
- newLegend[i].disabled = newValue
35
-
36
- const disabledAmt = runtimeLegend.disabledAmt ?? 0
37
-
38
- newLegend['disabledAmt'] = newValue ? disabledAmt + 1 : disabledAmt - 1
39
-
40
- setRuntimeLegend(newLegend)
41
-
42
- setAccessibleStatus(`Disabled legend item ${legendLabel ?? ''}. Please reference the data table to see updated values.`)
43
- }
44
-
45
- const legendList = runtimeLegend.map((entry, idx) => {
46
- const entryMax = displayDataAsText(entry.max, 'primary')
47
-
48
- const entryMin = displayDataAsText(entry.min, 'primary')
49
-
50
- let formattedText = `${entryMin}${entryMax !== entryMin ? ` - ${entryMax}` : ''}`
51
-
52
- // If interval, add some formatting
53
- if (legend.type === 'equalinterval' && idx !== runtimeLegend.length - 1) {
54
- formattedText = `${entryMin} - < ${entryMax}`
55
- }
56
-
57
- const { disabled } = entry
58
-
59
- if (legend.type === 'category') {
60
- formattedText = displayDataAsText(entry.value, 'primary')
61
- }
62
-
63
- if (entry.max === 0 && entry.min === 0) {
64
- formattedText = '0'
65
- }
66
-
67
- let legendLabel = formattedText
68
-
69
- if (entry.hasOwnProperty('special')) {
70
- legendLabel = entry.label || entry.value
71
- }
72
-
73
- const handleListItemClass = () => {
74
- let classes = ['legend-container__li']
75
- if (disabled) classes.push('legend-container__li--disabled')
76
- if (entry.hasOwnProperty('special')) classes.push('legend-container__li--special-class')
77
- return classes
78
- }
79
-
80
- return (
81
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions
82
- <li
83
- className={handleListItemClass().join(' ')}
84
- key={idx}
85
- title={`Legend item ${legendLabel} - Click to disable`}
86
- onClick={() => {
87
- toggleLegendActive(idx, legendLabel)
88
- }}
89
- >
90
- <LegendCircle fill={entry.color} /> <span className='label'>{legendLabel}</span>
91
- </li>
92
- )
93
- })
94
-
95
- const { legendClasses } = useDataVizClasses(state, viewport)
96
-
97
- const handleReset = e => {
98
- e.preventDefault()
99
- resetLegendToggles()
100
- setAccessibleStatus('Legend has been reset, please reference the data table to see updated values.')
101
- }
102
-
103
- return (
104
- <ErrorBoundary component='Sidebar'>
105
- <div className='legends'>
106
- <aside id='legend' className={legendClasses.aside.join(' ') || ''} role='region' aria-label='Legend'>
107
- <section className={legendClasses.section.join(' ') || ''} aria-label='Map Legend'>
108
- {runtimeLegend.disabledAmt > 0 && (
109
- <button onClick={handleReset} className={legendClasses.resetButton.join(' ') || ''}>
110
- Clear
111
- </button>
112
- )}
113
- {legend.title && <span className={legendClasses.title.join(' ') || ''}>{parse(legend.title)}</span>}
114
- {legend.dynamicDescription === false && legend.description && <p className={legendClasses.description.join(' ') || ''}>{parse(legend.description)}</p>}
115
- {legend.dynamicDescription === true &&
116
- runtimeFilters.map((filter, idx) => {
117
- const lookupStr = `${idx},${filter.values.indexOf(String(filter.active))}`
118
-
119
- // Do we have a custom description for this?
120
- const desc = legend.descriptions[lookupStr] || ''
121
-
122
- if (desc.length > 0) {
123
- return (
124
- <p key={`dynamic-description-${lookupStr}`} className={`dynamic-legend-description-${lookupStr}`}>
125
- {desc}
126
- </p>
127
- )
128
- }
129
- return true
130
- })}
131
- <ul className={legendClasses.ul.join(' ') || ''} aria-label='Legend items'>
132
- {legendList}
133
- </ul>
134
- </section>
135
- </aside>
136
- {state.hexMap.shapeGroups?.length > 0 && state.hexMap.type === 'shapes' && state.general.displayAsHex && <HexSetting.Legend state={state} runtimeLegend={runtimeLegend} viewport={viewport} />}
137
- </div>
138
- </ErrorBoundary>
139
- )
140
- }
141
-
142
- export default Sidebar
@@ -1,57 +0,0 @@
1
- export const abbrs = {
2
- Alabama: 'AL',
3
- Alaska: 'AK',
4
- Arizona: 'AZ',
5
- Arkansas: 'AR',
6
- California: 'CA',
7
- Colorado: 'CO',
8
- Connecticut: 'CT',
9
- Delaware: 'DE',
10
- Florida: 'FL',
11
- Georgia: 'GA',
12
- Hawaii: 'HI',
13
- Idaho: 'ID',
14
- Illinois: 'IL',
15
- Indiana: 'IN',
16
- Iowa: 'IA',
17
- Kansas: 'KS',
18
- Kentucky: 'KY',
19
- Louisiana: 'LA',
20
- Maine: 'ME',
21
- Maryland: 'MD',
22
- Massachusetts: 'MA',
23
- Michigan: 'MI',
24
- Minnesota: 'MN',
25
- Mississippi: 'MS',
26
- Missouri: 'MO',
27
- Montana: 'MT',
28
- Nebraska: 'NE',
29
- Nevada: 'NV',
30
- 'New Hampshire': 'NH',
31
- 'New Jersey': 'NJ',
32
- 'New Mexico': 'NM',
33
- 'New York': 'NY',
34
- 'North Carolina': 'NC',
35
- 'North Dakota': 'ND',
36
- Ohio: 'OH',
37
- Oklahoma: 'OK',
38
- Oregon: 'OR',
39
- Pennsylvania: 'PA',
40
- 'Rhode Island': 'RI',
41
- 'South Carolina': 'SC',
42
- 'South Dakota': 'SD',
43
- Tennessee: 'TN',
44
- Texas: 'TX',
45
- Utah: 'UT',
46
- Vermont: 'VT',
47
- Virginia: 'VA',
48
- Washington: 'WA',
49
- 'West Virginia': 'WV',
50
- Wisconsin: 'WI',
51
- Wyoming: 'WY',
52
- 'District of Columbia': 'DC',
53
- Guam: 'GU',
54
- 'Virgin Islands': 'VI',
55
- 'Puerto Rico': 'PR',
56
- 'American Samoa': 'AS',
57
- };
@@ -1,73 +0,0 @@
1
- {
2
- "type": "Topology",
3
- "arcs": [
4
- [
5
- [
6
- 33,
7
- 100
8
- ],
9
- [
10
- -6,
11
- 9
12
- ],
13
- [
14
- 30,
15
- 66
16
- ],
17
- [
18
- 102,
19
- -42
20
- ],
21
- [
22
- -118,
23
- -133
24
- ],
25
- [
26
- 11,
27
- 39
28
- ],
29
- [
30
- -52,
31
- 39
32
- ],
33
- [
34
- 33,
35
- 22
36
- ]
37
- ]
38
- ],
39
- "transform": {
40
- "scale": [
41
- 0.04505085471698112,
42
- 0.04496205714285712
43
- ],
44
- "translate": [
45
- -116.2012448,
46
- 33.3764121
47
- ]
48
- },
49
- "objects": {
50
- "Untitled layer": {
51
- "type": "GeometryCollection",
52
- "geometries": [
53
- {
54
- "arcs": [
55
- [
56
- 0
57
- ]
58
- ],
59
- "type": "Polygon",
60
- "properties": {
61
- "name": "new",
62
- "styleUrl": "#poly-000000-1200-77-nodesc",
63
- "fill-opacity": 0.30196078431372547,
64
- "fill": "#000000",
65
- "stroke-opacity": 1,
66
- "stroke": "#000000",
67
- "stroke-width": 1.2
68
- }
69
- }
70
- ]
71
- }
72
- }
73
- }