@cdc/map 4.26.3 → 4.26.4

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 (79) hide show
  1. package/CONFIG.md +235 -0
  2. package/README.md +70 -24
  3. package/dist/cdcmap-CY9IcPSi.es.js +6 -0
  4. package/dist/cdcmap-DlpiY3fQ.es.js +4 -0
  5. package/dist/cdcmap.js +27405 -26257
  6. package/examples/{testing-layer-2.json → __data__/testing-layer-2.json} +1 -1
  7. package/examples/{testing-layer.json → __data__/testing-layer.json} +1 -1
  8. package/examples/county-hsa-toggle.json +51993 -0
  9. package/examples/custom-map-layers.json +2 -2
  10. package/examples/default-county.json +3 -3
  11. package/examples/minimal-example.json +69 -0
  12. package/examples/private/annotation-bug.json +2 -2
  13. package/examples/private/css-issue.json +314 -0
  14. package/examples/private/region-breaking.json +1639 -0
  15. package/examples/private/test1.json +27247 -0
  16. package/package.json +4 -4
  17. package/src/CdcMapComponent.tsx +96 -13
  18. package/src/_stories/CdcMap.Editor.ColumnsSectionTests.stories.tsx +601 -0
  19. package/src/_stories/CdcMap.Editor.DataTableSectionTests.stories.tsx +404 -0
  20. package/src/_stories/CdcMap.Editor.FiltersSectionTests.stories.tsx +229 -0
  21. package/src/_stories/CdcMap.Editor.GeneralSectionTests.stories.tsx +262 -0
  22. package/src/_stories/CdcMap.Editor.LegendSectionTests.stories.tsx +541 -0
  23. package/src/_stories/CdcMap.Editor.MultiCountryWorldMapTests.stories.tsx +359 -0
  24. package/src/_stories/CdcMap.Editor.PatternSettingsSectionTests.stories.tsx +516 -0
  25. package/src/_stories/CdcMap.Editor.SmallMultiplesSectionTests.stories.tsx +165 -0
  26. package/src/_stories/CdcMap.Editor.TextAnnotationsSectionTests.stories.tsx +145 -0
  27. package/src/_stories/CdcMap.Editor.TypeSectionTests.stories.tsx +312 -0
  28. package/src/_stories/CdcMap.Editor.VisualSectionTests.stories.tsx +359 -0
  29. package/src/_stories/CdcMap.Editor.ZoomControlsTests.stories.tsx +88 -0
  30. package/src/_stories/{CdcMap.stories.tsx → CdcMap.smoke.stories.tsx} +12 -0
  31. package/src/_stories/_mock/legends/legend-tests.json +3 -3
  32. package/src/components/Annotation/AnnotationList.tsx +1 -1
  33. package/src/components/EditorPanel/components/EditorPanel.tsx +504 -383
  34. package/src/components/EditorPanel/components/HexShapeSettings.tsx +1 -1
  35. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +112 -117
  36. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +26 -13
  37. package/src/components/EditorPanel/components/editorPanel.styles.css +22 -2
  38. package/src/components/Legend/components/Legend.tsx +3 -3
  39. package/src/components/Legend/components/LegendItem.Hex.tsx +4 -2
  40. package/src/components/SmallMultiples/SynchronizedTooltip.tsx +1 -1
  41. package/src/components/UsaMap/components/UsaMap.County.tsx +271 -100
  42. package/src/components/UsaMap/components/UsaMap.State.tsx +1 -1
  43. package/src/components/UsaMap/data/cb_2019_us_county_20m.json +75817 -1
  44. package/src/components/UsaMap/data/hsa_fips_mapping.json +3144 -0
  45. package/src/components/WorldMap/data/world-topo.json +1 -1
  46. package/src/data/initial-state.js +1 -0
  47. package/src/data/supported-counties.json +1 -1
  48. package/src/helpers/countyTerritories.ts +38 -0
  49. package/src/helpers/dataTableHelpers.ts +35 -6
  50. package/src/helpers/tests/countyTerritories.test.ts +87 -0
  51. package/src/hooks/useApplyTooltipsToGeo.tsx +7 -4
  52. package/src/hooks/useMapLayers.tsx +1 -1
  53. package/src/hooks/useTooltip.ts +18 -7
  54. package/src/store/map.actions.ts +5 -2
  55. package/src/store/map.reducer.ts +12 -3
  56. package/src/test/CdcMap.test.jsx +24 -0
  57. package/src/types/MapConfig.ts +6 -0
  58. package/src/types/MapContext.ts +3 -1
  59. package/topojson-updater/README.txt +1 -1
  60. package/LICENSE +0 -201
  61. package/dist/cdcmap-vr9HZwRt.es.js +0 -6
  62. package/examples/__data__/city-state-data.json +0 -668
  63. package/examples/city-state.json +0 -434
  64. package/examples/default-world-data.json +0 -1450
  65. package/examples/new-cities.json +0 -656
  66. package/src/_stories/CdcMap.Editor.stories.tsx +0 -3648
  67. package/topojson-updater/package-lock.json +0 -223
  68. /package/src/_stories/{CdcMap.ColumnWrap.stories.tsx → CdcMap.ColumnWrap.smoke.stories.tsx} +0 -0
  69. /package/src/_stories/{CdcMap.Defaults.stories.tsx → CdcMap.Defaults.smoke.stories.tsx} +0 -0
  70. /package/src/_stories/{CdcMap.DistrictOfColumbia.stories.tsx → CdcMap.DistrictOfColumbia.smoke.stories.tsx} +0 -0
  71. /package/src/_stories/{CdcMap.Filters.stories.tsx → CdcMap.Filters.smoke.stories.tsx} +0 -0
  72. /package/src/_stories/{CdcMap.Legend.Gradient.stories.tsx → CdcMap.Legend.Gradient.smoke.stories.tsx} +0 -0
  73. /package/src/_stories/{CdcMap.Legend.stories.tsx → CdcMap.Legend.smoke.stories.tsx} +0 -0
  74. /package/src/_stories/{CdcMap.Patterns.stories.tsx → CdcMap.Patterns.smoke.stories.tsx} +0 -0
  75. /package/src/_stories/{CdcMap.SmallMultiples.stories.tsx → CdcMap.SmallMultiples.smoke.stories.tsx} +0 -0
  76. /package/src/_stories/{CdcMap.Table.stories.tsx → CdcMap.Table.smoke.stories.tsx} +0 -0
  77. /package/src/_stories/{CdcMap.ZeroColor.stories.tsx → CdcMap.ZeroColor.smoke.stories.tsx} +0 -0
  78. /package/src/_stories/{GoogleMap.stories.tsx → GoogleMap.smoke.stories.tsx} +0 -0
  79. /package/src/_stories/{UsaMap.NoData.stories.tsx → UsaMap.NoData.smoke.stories.tsx} +0 -0
@@ -0,0 +1,38 @@
1
+ export const US_TERRITORY_STATE_FIPS_PREFIXES = new Set(['60', '66', '69', '78'])
2
+
3
+ export type CountyTerritoryVisibility = {
4
+ showTerritories: boolean
5
+ statePrefixes: Set<string>
6
+ countyIds: Set<string>
7
+ key: string
8
+ }
9
+
10
+ export const getCountyTerritoryVisibility = (
11
+ territoriesAlwaysShow: boolean | undefined,
12
+ runtimeData?: Record<string, any>
13
+ ): CountyTerritoryVisibility => {
14
+ const countyIds = new Set<string>()
15
+ const statePrefixes = new Set<string>()
16
+
17
+ if (runtimeData) {
18
+ Object.keys(runtimeData).forEach(key => {
19
+ if (key.length <= 2) return
20
+
21
+ const statePrefix = key.slice(0, 2)
22
+ if (!US_TERRITORY_STATE_FIPS_PREFIXES.has(statePrefix)) return
23
+
24
+ countyIds.add(key)
25
+ statePrefixes.add(statePrefix)
26
+ })
27
+ }
28
+
29
+ const showTerritories = territoriesAlwaysShow !== false && countyIds.size > 0
30
+ const key = `${showTerritories}:${showTerritories ? Array.from(countyIds).sort().join(',') : ''}`
31
+
32
+ return {
33
+ showTerritories,
34
+ statePrefixes,
35
+ countyIds,
36
+ key
37
+ }
38
+ }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  stateFipsToTwoDigit as stateFipsToAbbreviation,
3
- supportedStatesFipsCodes as supportedStateCodes
3
+ supportedStatesFipsCodes as supportedStateFipsCodes
4
4
  } from '../data/supported-geos'
5
5
 
6
6
  /**
@@ -13,18 +13,46 @@ export const shouldShowDataTable = (config: any, table: any, general: any, loadi
13
13
  /**
14
14
  * Filters county runtime data to a selected state code for data table display.
15
15
  * Keeps the original non-enumerable fromHash metadata when present.
16
+ * Fail-safe: if no recognizable state columns exist in the data, returns original
17
+ * data unfiltered (avoids breaking misconfigured datasets). If valid state columns
18
+ * exist but a state has no data, returns empty result as expected.
16
19
  */
17
20
  export const filterCountyTableRuntimeDataByStateCode = (runtimeData: any, stateCode: string, config?: any) => {
18
21
  if (!runtimeData || runtimeData.init || !stateCode) return runtimeData
19
22
 
20
- const filtered = {}
21
- const stateName = supportedStateCodes[stateCode]
22
- const stateAbbreviation = stateFipsToAbbreviation[stateCode]
23
+ const runtimeKeys = Object.keys(runtimeData)
24
+ if (runtimeKeys.length === 0) return runtimeData
25
+
26
+ const stateName = supportedStateFipsCodes?.[stateCode]
27
+ const stateAbbreviation = stateFipsToAbbreviation?.[stateCode]
23
28
  const normalizedSelectedStateCode = String(stateCode).replace(/^0+/, '')
24
29
  const paddedSelectedStateCode = normalizedSelectedStateCode.padStart(2, '0')
25
30
  const stateColumnNames = Object.values(config?.columns || {})
26
31
  .map((column: any) => column?.name)
27
- .filter((name: string) => !!name && /(state|territory|fips)/i.test(name))
32
+ .filter((name: string) => !!name && /(state|territory|fips|jurisdiction)/i.test(name))
33
+
34
+ // Also check common state field names directly in the data rows
35
+ const commonStateFieldNames = [
36
+ 'jurisdiction',
37
+ 'state',
38
+ 'State',
39
+ 'state_name',
40
+ 'stateName',
41
+ 'State/Territory',
42
+ 'state_territory_name'
43
+ ]
44
+ const allStateColumns = [...new Set([...stateColumnNames, ...commonStateFieldNames])]
45
+
46
+ // Fail-safe: check if UIDs look like county FIPS codes (5 digits) OR if any state column exists in the data
47
+ const hasCountyFipsUids = runtimeKeys.some(uid => /^\d{5}$/.test(String(uid)))
48
+ const hasStateColumn = runtimeKeys.some(uid => allStateColumns.some(col => runtimeData[uid]?.[col] !== undefined))
49
+
50
+ // If data has neither county FIPS UIDs nor any recognizable state columns, don't filter
51
+ if (!hasCountyFipsUids && !hasStateColumn) {
52
+ return runtimeData
53
+ }
54
+
55
+ const filtered = {}
28
56
 
29
57
  if (runtimeData.fromHash !== undefined) {
30
58
  Object.defineProperty(filtered, 'fromHash', {
@@ -38,7 +66,8 @@ export const filterCountyTableRuntimeDataByStateCode = (runtimeData: any, stateC
38
66
  const normalizedUidPrefix = uidPrefix.startsWith('0') ? uidPrefix.slice(1) : uidPrefix
39
67
  const matchesUidPrefix =
40
68
  uidPrefix === paddedSelectedStateCode || normalizedUidPrefix === normalizedSelectedStateCode
41
- const matchesStateColumn = stateColumnNames.some((columnName: string) => {
69
+
70
+ const matchesStateColumn = allStateColumns.some((columnName: string) => {
42
71
  const rawValue = row?.[columnName]
43
72
  if (rawValue === undefined || rawValue === null) return false
44
73
 
@@ -0,0 +1,87 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { getCountyTerritoryVisibility } from '../countyTerritories'
3
+
4
+ describe('countyTerritories', () => {
5
+ it('collects visible territory prefixes and county ids from runtime data', () => {
6
+ const runtimeData = {
7
+ '06001': { uid: '06001', value: 1 },
8
+ '72001': { uid: '72001', value: 2 }
9
+ }
10
+
11
+ const visibility = getCountyTerritoryVisibility(true, runtimeData)
12
+
13
+ expect(visibility.showTerritories).toBe(true)
14
+ expect(Array.from(visibility.statePrefixes).sort()).toEqual(['72'])
15
+ expect(Array.from(visibility.countyIds).sort()).toEqual(['72001'])
16
+ expect(visibility.key).toBe('true:72001')
17
+ })
18
+
19
+ it('collects multiple territory prefixes and ignores non-territory counties', () => {
20
+ const runtimeData = {
21
+ '72001': { uid: '72001', value: 1 },
22
+ '72003': { uid: '72003', value: 2 },
23
+ '78010': { uid: '78010', value: 3 },
24
+ '06001': { uid: '06001', value: 4 }
25
+ }
26
+
27
+ const visibility = getCountyTerritoryVisibility(true, runtimeData)
28
+
29
+ expect(Array.from(visibility.statePrefixes).sort()).toEqual(['72', '78'])
30
+ expect(Array.from(visibility.countyIds).sort()).toEqual(['72001', '72003', '78010'])
31
+ expect(visibility.key).toBe('true:72001,72003,78010')
32
+ })
33
+
34
+ it('hides county territories when the config flag is disabled even if territory data exists', () => {
35
+ const runtimeData = {
36
+ '72001': { uid: '72001', value: 1 }
37
+ }
38
+
39
+ const visibility = getCountyTerritoryVisibility(false, runtimeData)
40
+
41
+ expect(visibility.showTerritories).toBe(false)
42
+ expect(Array.from(visibility.statePrefixes).sort()).toEqual(['72'])
43
+ expect(Array.from(visibility.countyIds).sort()).toEqual(['72001'])
44
+ expect(visibility.key).toBe('false:')
45
+ })
46
+
47
+ it('hides county territories when the config flag is enabled but no territory data exists', () => {
48
+ const runtimeData = {
49
+ '06001': { uid: '06001', value: 1 }
50
+ }
51
+
52
+ const visibility = getCountyTerritoryVisibility(true, runtimeData)
53
+
54
+ expect(visibility.showTerritories).toBe(false)
55
+ expect(Array.from(visibility.statePrefixes).sort()).toEqual([])
56
+ expect(Array.from(visibility.countyIds).sort()).toEqual([])
57
+ expect(visibility.key).toBe('false:')
58
+ })
59
+
60
+ it('treats an omitted config flag as enabled by default but still hides territories when no territory data exists', () => {
61
+ const runtimeData = {
62
+ '06001': { uid: '06001', value: 1 }
63
+ }
64
+
65
+ const visibility = getCountyTerritoryVisibility(undefined, runtimeData)
66
+
67
+ expect(visibility.showTerritories).toBe(false)
68
+ expect(Array.from(visibility.statePrefixes)).toEqual([])
69
+ expect(Array.from(visibility.countyIds)).toEqual([])
70
+ expect(visibility.key).toBe('false:')
71
+ })
72
+
73
+ it('changes the key when visible territory county ids change within the same territory prefix', () => {
74
+ const firstVisibility = getCountyTerritoryVisibility(true, {
75
+ '72001': { uid: '72001', value: 1 }
76
+ })
77
+ const secondVisibility = getCountyTerritoryVisibility(true, {
78
+ '72003': { uid: '72003', value: 1 }
79
+ })
80
+
81
+ expect(Array.from(firstVisibility.statePrefixes)).toEqual(['72'])
82
+ expect(Array.from(secondVisibility.statePrefixes)).toEqual(['72'])
83
+ expect(firstVisibility.key).toBe('true:72001')
84
+ expect(secondVisibility.key).toBe('true:72003')
85
+ expect(firstVisibility.key).not.toBe(secondVisibility.key)
86
+ })
87
+ })
@@ -1,8 +1,7 @@
1
1
  import { type ReactNode, useContext } from 'react'
2
- import { displayGeoName, navigationHandler } from '../helpers'
2
+ import { navigationHandler } from '../helpers'
3
3
  import ConfigContext from '../context'
4
4
  import useTooltip from './useTooltip'
5
- import { supportedStatesFipsCodes } from './../data/supported-geos'
6
5
  import parse from 'html-react-parser'
7
6
  import isDomainExternal from '@cdc/core/helpers/isDomainExternal'
8
7
  import ExternalIcon from './../images/external-link.svg'
@@ -10,7 +9,7 @@ import ExternalIcon from './../images/external-link.svg'
10
9
  const useApplyTooltipsToGeo = () => {
11
10
  const { config, customNavigationHandler } = useContext(ConfigContext)
12
11
  const navigationColumnName = config.columns.navigate.name
13
- const { buildTooltip } = useTooltip({ config, displayGeoName, supportedStatesFipsCodes })
12
+ const { buildTooltip } = useTooltip(config)
14
13
 
15
14
  const applyTooltipsToGeo = (geoName: string, row: Object, returnType = 'string') => {
16
15
  let toolTipText: string | ReactNode = buildTooltip(row, geoName, '')
@@ -18,7 +17,11 @@ const useApplyTooltipsToGeo = () => {
18
17
  // We convert the markup into JSX and add a navigation link if it's going into a modal.
19
18
  if ('jsx' === returnType) {
20
19
  if (typeof toolTipText === 'string') {
21
- toolTipText = [<div key='modal-content'>{parse(toolTipText)}</div>]
20
+ toolTipText = [
21
+ <div key='modal-content' className='cove-prose'>
22
+ {parse(toolTipText)}
23
+ </div>
24
+ ]
22
25
  }
23
26
 
24
27
  if (config.columns.hasOwnProperty('navigate') && row[navigationColumnName]) {
@@ -53,7 +53,7 @@ export default function useMapLayers(config: MapConfig, setConfig, pathGenerator
53
53
  setConfig(newConfig)
54
54
  }
55
55
 
56
- const handleAddLayer = (e: Event) => {
56
+ const handleAddLayer = (e: MouseEvent<HTMLButtonElement>) => {
57
57
  e.preventDefault()
58
58
  const placeHolderLayer = {
59
59
  name: 'New Custom Layer',
@@ -1,9 +1,9 @@
1
1
  import { displayDataAsText } from '@cdc/core/helpers/displayDataAsText'
2
2
  import { displayGeoName } from '../helpers/displayGeoName'
3
+ import { MapConfig } from '../types/MapConfig'
4
+ import { supportedStatesFipsCodes } from '../data/supported-geos'
3
5
 
4
- const useTooltip = props => {
5
- const { config, supportedStatesFipsCodes } = props
6
-
6
+ const useTooltip = (config: MapConfig) => {
7
7
  /**
8
8
  * On county maps there's a need to append the state name
9
9
  * @param {String} toolTipText - previous tooltip text to build upon
@@ -11,17 +11,25 @@ const useTooltip = props => {
11
11
  * @returns {String} toolTipText - new toolTipText
12
12
  */
13
13
  const handleTooltipStateNameColumn = (toolTipText, row) => {
14
- const { geoType, type, hideGeoColumnInTooltip } = config.general
14
+ const { geoType, type, hideGeoColumnInTooltip, showHSABoundaries } = config.general
15
15
  if (geoType === 'us-county' && type !== 'us-geocode') {
16
16
  let stateFipsCode = row[config.columns.geo.name].substring(0, 2)
17
17
  const stateName = supportedStatesFipsCodes[stateFipsCode]
18
- toolTipText += hideGeoColumnInTooltip
19
- ? `<strong>${stateName}</strong><br/>`
20
- : `<strong>Location: ${stateName}</strong><br/>`
18
+ toolTipText +=
19
+ hideGeoColumnInTooltip || showHSABoundaries
20
+ ? `<strong>${stateName}</strong><br/>`
21
+ : `<strong>Location: ${stateName}</strong><br/>`
21
22
  }
22
23
  return toolTipText
23
24
  }
24
25
 
26
+ const getHSAColumnText = (config: MapConfig, row: Object) => {
27
+ const { hsa } = config.columns
28
+ if (!hsa || !config.general.showHSABoundaries) return ''
29
+ const hsaDescription = row[hsa.name]
30
+ return `<p class="tooltip-heading">HSA: ${hsaDescription}</p>`
31
+ }
32
+
25
33
  /**
26
34
  * On county and state maps, adds the ability to hide the geo column name (prefix)
27
35
  * @param {String} geoName - feature name
@@ -144,6 +152,9 @@ const useTooltip = props => {
144
152
  // Handle County Location Columns
145
153
  toolTipText += handleTooltipStateNameColumn(toolTipText, row)
146
154
 
155
+ // Handle HSA Column
156
+ toolTipText += getHSAColumnText(config, row)
157
+
147
158
  // Handle Columns > Data Column In tooltips
148
159
  toolTipText += handleTooltipGeoColumn(geoName, row)
149
160
 
@@ -11,7 +11,10 @@ type SET_CONFIG = Action<'SET_CONFIG', MapConfig>
11
11
  type SET_COVE_LOADED_HAS_RAN = Action<'SET_COVE_LOADED_HAS_RAN', boolean>
12
12
  type SET_DISPLAY_PANEL = Action<'SET_DISPLAY_PANEL', boolean>
13
13
  type SET_FILTERED_COUNTRY_CODE = Action<'SET_FILTERED_COUNTRY_CODE', string>
14
- type SET_FILTERED_STATE_CODE = Action<'SET_FILTERED_STATE_CODE', string>
14
+ type SET_FILTERED_STATE_COUNTY_CODE = Action<
15
+ 'SET_FILTERED_STATE_COUNTY_CODE',
16
+ { stateCode?: string; countyCode?: string }
17
+ >
15
18
  type SET_IS_DRAGGING_ANNOTATION = Action<'SET_IS_DRAGGING_ANNOTATION', boolean>
16
19
  type SET_LOADING = Action<'SET_LOADING', boolean>
17
20
  type SET_MODAL = Action<'SET_MODAL', Modal>
@@ -31,7 +34,7 @@ type MapActions =
31
34
  | SET_COVE_LOADED_HAS_RAN
32
35
  | SET_DISPLAY_PANEL
33
36
  | SET_FILTERED_COUNTRY_CODE
34
- | SET_FILTERED_STATE_CODE
37
+ | SET_FILTERED_STATE_COUNTY_CODE
35
38
  | SET_IS_DRAGGING_ANNOTATION
36
39
  | SET_LOADING
37
40
  | SET_MODAL
@@ -6,8 +6,11 @@ import _ from 'lodash'
6
6
  import { Modal } from '../types/Modal'
7
7
  import { GeneratedLegend } from '../helpers/generateRuntimeLegend'
8
8
  import { RuntimeData } from '../types/RuntimeData'
9
+ import { getQueryParam } from '@cdc/core/helpers/queryStringUtils'
9
10
 
10
11
  export const getInitialState = (configObj = {}): MapState => {
12
+ const filteredStateCode = typeof window !== 'undefined' ? getQueryParam('state-code') || '' : ''
13
+ const filteredCountyCode = typeof window !== 'undefined' ? getQueryParam('county-code') || '' : ''
11
14
  // Create defaults without palette version to avoid overriding legacy configs
12
15
  const defaultsWithoutPaletteaName = { ...defaults }
13
16
 
@@ -24,7 +27,8 @@ export const getInitialState = (configObj = {}): MapState => {
24
27
  coveLoadedHasRan: false,
25
28
  displayPanel: false,
26
29
  filteredCountryCode: '',
27
- filteredStateCode: '',
30
+ filteredCountyCode,
31
+ filteredStateCode,
28
32
  isDraggingAnnotation: false,
29
33
  topoData: null,
30
34
  translate: [0, 0],
@@ -47,6 +51,7 @@ export type MapState = {
47
51
  coveLoadedHasRan: boolean
48
52
  displayPanel: boolean
49
53
  filteredCountryCode: string
54
+ filteredCountyCode: string
50
55
  filteredStateCode: string
51
56
  isDraggingAnnotation: boolean
52
57
  topoData: object | null
@@ -77,8 +82,12 @@ const reducer = (state: MapState, action: MapActions): MapState => {
77
82
  return { ...state, displayPanel: action.payload }
78
83
  case 'SET_FILTERED_COUNTRY_CODE':
79
84
  return { ...state, filteredCountryCode: action.payload }
80
- case 'SET_FILTERED_STATE_CODE':
81
- return { ...state, filteredStateCode: action.payload }
85
+ case 'SET_FILTERED_STATE_COUNTY_CODE':
86
+ return {
87
+ ...state,
88
+ filteredStateCode: action.payload.stateCode || '',
89
+ filteredCountyCode: action.payload.countyCode || ''
90
+ }
82
91
  case 'SET_IS_DRAGGING_ANNOTATION':
83
92
  return { ...state, isDraggingAnnotation: action.payload }
84
93
  case 'SET_TOPO_DATA':
@@ -1,11 +1,35 @@
1
1
  import path from 'node:path'
2
+ import fs from 'node:fs'
3
+ import vm from 'node:vm'
2
4
  import { testStandaloneBuild } from '@cdc/core/helpers/tests/testStandaloneBuild.ts'
3
5
  import { describe, it, expect } from 'vitest'
4
6
 
7
+ const extractMarkedExampleConfig = (content, label) => {
8
+ const match = content.match(
9
+ /<!-- README_EXAMPLE_CONFIG_START -->\s*```jsx\s*([\s\S]*?)\s*```\s*<!-- README_EXAMPLE_CONFIG_END -->/
10
+ )
11
+ expect(match, `${label} should contain a marked README example block`).toBeTruthy()
12
+ const configMatch = match[1].match(/const config = (\{[\s\S]*?\})\n\nfunction App\(\)/)
13
+ expect(configMatch, `${label} should define const config before function App()`).toBeTruthy()
14
+ return vm.runInNewContext(`(${configMatch[1]})`)
15
+ }
16
+
5
17
  describe('Map', () => {
6
18
  it('Can be built in isolation', async () => {
7
19
  const pkgDir = path.join(__dirname, '..')
8
20
  const result = await testStandaloneBuild(pkgDir)
9
21
  expect(result).toBe(true)
10
22
  }, 300000)
23
+
24
+ it('keeps the minimal example in sync with the README docs', () => {
25
+ const pkgRoot = path.join(__dirname, '..', '..')
26
+ const minimalExamplePath = path.join(pkgRoot, 'examples', 'minimal-example.json')
27
+ const readmePath = path.join(pkgRoot, 'README.md')
28
+
29
+ const minimalExample = JSON.parse(fs.readFileSync(minimalExamplePath, 'utf8'))
30
+ const readmeBlock = extractMarkedExampleConfig(fs.readFileSync(readmePath, 'utf8'), 'README.md')
31
+
32
+ expect(readmeBlock).toEqual(minimalExample)
33
+ expect(minimalExample.version).toBeTruthy()
34
+ })
11
35
  })
@@ -66,6 +66,7 @@ type SimpleColumnProperties = Pick<EditorColumnProperties, 'name'>
66
66
 
67
67
  // Specific column types for better semantics
68
68
  type GeoColumnProperties = BaseColumnProperties & { displayColumn?: string }
69
+ type HSAColumnProperties = SimpleColumnProperties
69
70
  type LatitudeColumnProperties = SimpleColumnProperties
70
71
  type LongitudeColumnProperties = SimpleColumnProperties
71
72
  type NavigateColumnProperties = SimpleColumnProperties
@@ -114,6 +115,7 @@ export type MapConfig = Visualization & {
114
115
  color: string
115
116
  columns: {
116
117
  geo: GeoColumnProperties
118
+ hsa: HSAColumnProperties
117
119
  primary: PrimaryColumnProperties
118
120
  navigate: NavigateColumnProperties
119
121
  latitude: LatitudeColumnProperties
@@ -164,7 +166,10 @@ export type MapConfig = Visualization & {
164
166
  showDownloadImgButton: boolean
165
167
  includeContextInDownload?: boolean
166
168
  showDownloadPdfButton: boolean
169
+ showHSABoundaries?: boolean
170
+ showNeighboringStates?: boolean
167
171
  showSidebar: boolean
172
+ showStateDropdown?: boolean
168
173
  showTitle: boolean
169
174
  statesPicked: {
170
175
  fipsCode: string
@@ -215,6 +220,7 @@ export type MapConfig = Visualization & {
215
220
  download: boolean
216
221
  downloadDataLabel?: string
217
222
  downloadImageLabel?: string
223
+ downloadUrlLabel?: string
218
224
  showDownloadUrl: boolean
219
225
  showFullGeoNameInCSV: boolean
220
226
  forceDisplay: boolean
@@ -7,12 +7,14 @@ import { MutableRefObject } from 'react'
7
7
 
8
8
  export type MapContext = {
9
9
  currentViewport: ViewPort
10
+ customNavigationHandler?: Function
10
11
  vizViewport?: ViewPort
11
12
  content: { geoName: string; keyedData: Record<string, any> }
12
13
  dimensions: DimensionsType
13
14
  displayDataAsText: string | number
14
15
  displayGeoName: (key: string, displayOverride?: string) => string
15
16
  filteredCountryCode: string
17
+ filteredCountyCode: string
16
18
  filteredStateCode: string
17
19
  generateRuntimeData: (
18
20
  configObj: MapConfig,
@@ -37,7 +39,7 @@ export type MapContext = {
37
39
  runtimeLegend
38
40
  setParentConfig: Function
39
41
  setRuntimeData: Function
40
- setFilteredStateCode: (stateCode: string) => void
42
+ setFilteredStateCountyCode: (stateCode: string, countyCode?: string) => void
41
43
  setSharedFilterValue: Function
42
44
  setConfig: (newState: MapConfig) => MapConfig
43
45
  config: MapConfig
@@ -4,7 +4,7 @@ Node script to convert shapefile data from census.gov to topojson, and format/op
4
4
 
5
5
 
6
6
  Usage
7
- 1. Run yarn install at root folder
7
+ 1. Run "yarn install" inside the packages/map/topojson-updater folder (this package is not part of the root Yarn workspace)
8
8
  2. Download shapefiles from census.gov (https://www.census.gov/geographies/mapping-files/time-series/geo/cartographic-boundary.html) for the year that needs to be supported to the "shapefiles" folder of the project
9
9
  - Always choose the options with the smallest file size
10
10
  - Shapefiles for both states and counties should be downloaded for each year being added
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.