@cdc/map 4.26.2 → 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 (118) 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 +31260 -27946
  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 +642 -0
  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/CdcMap.tsx +3 -14
  18. package/src/CdcMapComponent.tsx +302 -164
  19. package/src/_stories/CdcMap.Defaults.smoke.stories.tsx +76 -0
  20. package/src/_stories/CdcMap.Editor.ColumnsSectionTests.stories.tsx +601 -0
  21. package/src/_stories/CdcMap.Editor.DataTableSectionTests.stories.tsx +404 -0
  22. package/src/_stories/CdcMap.Editor.FiltersSectionTests.stories.tsx +229 -0
  23. package/src/_stories/CdcMap.Editor.GeneralSectionTests.stories.tsx +262 -0
  24. package/src/_stories/CdcMap.Editor.LegendSectionTests.stories.tsx +541 -0
  25. package/src/_stories/CdcMap.Editor.MultiCountryWorldMapTests.stories.tsx +359 -0
  26. package/src/_stories/CdcMap.Editor.PatternSettingsSectionTests.stories.tsx +516 -0
  27. package/src/_stories/CdcMap.Editor.SmallMultiplesSectionTests.stories.tsx +165 -0
  28. package/src/_stories/CdcMap.Editor.TextAnnotationsSectionTests.stories.tsx +145 -0
  29. package/src/_stories/CdcMap.Editor.TypeSectionTests.stories.tsx +312 -0
  30. package/src/_stories/CdcMap.Editor.VisualSectionTests.stories.tsx +359 -0
  31. package/src/_stories/CdcMap.Editor.ZoomControlsTests.stories.tsx +88 -0
  32. package/src/_stories/{CdcMap.stories.tsx → CdcMap.smoke.stories.tsx} +23 -1
  33. package/src/_stories/Map.HTMLInDataTable.stories.tsx +385 -0
  34. package/src/_stories/_mock/legends/legend-tests.json +3 -3
  35. package/src/_stories/_mock/multi-state-show-unselected.json +82 -0
  36. package/src/cdcMapComponent.styles.css +2 -2
  37. package/src/components/Annotation/Annotation.Draggable.styles.css +4 -4
  38. package/src/components/Annotation/AnnotationDropdown.styles.css +1 -1
  39. package/src/components/Annotation/AnnotationList.styles.css +13 -13
  40. package/src/components/Annotation/AnnotationList.tsx +1 -1
  41. package/src/components/EditorPanel/components/EditorPanel.tsx +905 -416
  42. package/src/components/EditorPanel/components/HexShapeSettings.tsx +1 -1
  43. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +112 -117
  44. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings-style.css +1 -1
  45. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +31 -15
  46. package/src/components/EditorPanel/components/editorPanel.styles.css +55 -25
  47. package/src/components/Legend/components/Legend.tsx +12 -7
  48. package/src/components/Legend/components/LegendGroup/legend.group.css +5 -5
  49. package/src/components/Legend/components/LegendItem.Hex.tsx +4 -2
  50. package/src/components/Legend/components/index.scss +2 -3
  51. package/src/components/NavigationMenu.tsx +2 -1
  52. package/src/components/SmallMultiples/SmallMultiples.css +5 -5
  53. package/src/components/SmallMultiples/SynchronizedTooltip.tsx +1 -1
  54. package/src/components/UsaMap/components/SingleState/SingleState.StateOutput.tsx +32 -17
  55. package/src/components/UsaMap/components/TerritoriesSection.tsx +3 -2
  56. package/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +13 -8
  57. package/src/components/UsaMap/components/UsaMap.County.tsx +629 -231
  58. package/src/components/UsaMap/components/UsaMap.Region.styles.css +1 -1
  59. package/src/components/UsaMap/components/UsaMap.SingleState.styles.css +2 -2
  60. package/src/components/UsaMap/components/UsaMap.State.tsx +14 -9
  61. package/src/components/UsaMap/data/cb_2019_us_county_20m.json +75817 -1
  62. package/src/components/UsaMap/data/hsa_fips_mapping.json +3144 -0
  63. package/src/components/WorldMap/WorldMap.tsx +10 -13
  64. package/src/components/WorldMap/data/world-topo-updated.json +1 -0
  65. package/src/components/WorldMap/data/world-topo.json +1 -1
  66. package/src/components/WorldMap/worldMap.styles.css +1 -1
  67. package/src/components/ZoomControls.tsx +49 -18
  68. package/src/components/zoomControls.styles.css +27 -11
  69. package/src/data/initial-state.js +15 -5
  70. package/src/data/legacy-defaults.ts +8 -0
  71. package/src/data/supported-counties.json +1 -1
  72. package/src/data/supported-geos.js +19 -0
  73. package/src/helpers/colors.ts +2 -1
  74. package/src/helpers/countyTerritories.ts +38 -0
  75. package/src/helpers/dataTableHelpers.ts +85 -0
  76. package/src/helpers/displayGeoName.ts +19 -11
  77. package/src/helpers/getMapContainerClasses.ts +8 -2
  78. package/src/helpers/getMatchingPatternForRow.ts +67 -0
  79. package/src/helpers/getPatternForRow.ts +11 -18
  80. package/src/helpers/tests/countyTerritories.test.ts +87 -0
  81. package/src/helpers/tests/dataTableHelpers.test.ts +78 -0
  82. package/src/helpers/tests/displayGeoName.test.ts +17 -0
  83. package/src/helpers/tests/getMatchingPatternForRow.test.ts +150 -0
  84. package/src/helpers/tests/getPatternForRow.test.ts +140 -2
  85. package/src/helpers/urlDataHelpers.ts +7 -1
  86. package/src/hooks/useApplyTooltipsToGeo.tsx +7 -4
  87. package/src/hooks/useMapLayers.tsx +1 -1
  88. package/src/hooks/useResizeObserver.ts +36 -22
  89. package/src/hooks/useTooltip.test.tsx +64 -0
  90. package/src/hooks/useTooltip.ts +46 -15
  91. package/src/scss/editor-panel.scss +1 -1
  92. package/src/scss/main.scss +140 -6
  93. package/src/scss/map.scss +9 -4
  94. package/src/store/map.actions.ts +5 -0
  95. package/src/store/map.reducer.ts +13 -0
  96. package/src/test/CdcMap.test.jsx +26 -2
  97. package/src/types/MapConfig.ts +28 -4
  98. package/src/types/MapContext.ts +5 -1
  99. package/topojson-updater/README.txt +1 -1
  100. package/dist/cdcmap-Cf9_fbQf.es.js +0 -6
  101. package/examples/__data__/city-state-data.json +0 -668
  102. package/examples/city-state.json +0 -434
  103. package/examples/default-world-data.json +0 -1450
  104. package/examples/new-cities.json +0 -656
  105. package/src/_stories/CdcMap.Editor.stories.tsx +0 -3475
  106. package/src/helpers/componentHelpers.ts +0 -8
  107. package/topojson-updater/package-lock.json +0 -223
  108. /package/src/_stories/{CdcMap.ColumnWrap.stories.tsx → CdcMap.ColumnWrap.smoke.stories.tsx} +0 -0
  109. /package/src/_stories/{CdcMap.DistrictOfColumbia.stories.tsx → CdcMap.DistrictOfColumbia.smoke.stories.tsx} +0 -0
  110. /package/src/_stories/{CdcMap.Filters.stories.tsx → CdcMap.Filters.smoke.stories.tsx} +0 -0
  111. /package/src/_stories/{CdcMap.Legend.Gradient.stories.tsx → CdcMap.Legend.Gradient.smoke.stories.tsx} +0 -0
  112. /package/src/_stories/{CdcMap.Legend.stories.tsx → CdcMap.Legend.smoke.stories.tsx} +0 -0
  113. /package/src/_stories/{CdcMap.Patterns.stories.tsx → CdcMap.Patterns.smoke.stories.tsx} +0 -0
  114. /package/src/_stories/{CdcMap.SmallMultiples.stories.tsx → CdcMap.SmallMultiples.smoke.stories.tsx} +0 -0
  115. /package/src/_stories/{CdcMap.Table.stories.tsx → CdcMap.Table.smoke.stories.tsx} +0 -0
  116. /package/src/_stories/{CdcMap.ZeroColor.stories.tsx → CdcMap.ZeroColor.smoke.stories.tsx} +0 -0
  117. /package/src/_stories/{GoogleMap.stories.tsx → GoogleMap.smoke.stories.tsx} +0 -0
  118. /package/src/_stories/{UsaMap.NoData.stories.tsx → UsaMap.NoData.smoke.stories.tsx} +0 -0
@@ -4,8 +4,8 @@
4
4
  }
5
5
  .geography-container {
6
6
  cursor: move;
7
- position: relative;
8
7
  flex-grow: 1;
8
+ position: relative;
9
9
  width: 100%;
10
10
  .geo-point {
11
11
  transition: 0.3s all;
@@ -13,27 +13,58 @@ type ZoomControlsProps = {
13
13
  const ZoomControls: React.FC<ZoomControlsProps> = ({ handleZoomIn, handleZoomOut, handleZoomReset }) => {
14
14
  const { config, setRuntimeData, position } = useContext<MapContext>(ConfigContext)
15
15
  if (!config.general.allowMapZoom) return
16
+
17
+ const isUsGeocodeMap = config.general.type === 'us-geocode'
18
+ const shouldShowUsGeocodeReset = isUsGeocodeMap && position.zoom > 1
19
+ const shouldShowBottomReset = config.general.geoType === 'single-state' || config.general.type === 'bubble'
20
+
21
+ if (!isUsGeocodeMap) {
22
+ return (
23
+ <div className='zoom-controls' data-html2canvas-ignore='true'>
24
+ <button onClick={() => handleZoomIn(position)} aria-label='Zoom In'>
25
+ <svg viewBox='0 0 24 24' stroke='currentColor' strokeWidth='3'>
26
+ <line x1='12' y1='5' x2='12' y2='19' />
27
+ <line x1='5' y1='12' x2='19' y2='12' />
28
+ </svg>
29
+ </button>
30
+ <button onClick={() => handleZoomOut(position)} aria-label='Zoom Out'>
31
+ <svg viewBox='0 0 24 24' stroke='currentColor' strokeWidth='3'>
32
+ <line x1='5' y1='12' x2='19' y2='12' />
33
+ </svg>
34
+ </button>
35
+ {shouldShowBottomReset && (
36
+ <button onClick={() => handleZoomReset(setRuntimeData)} className='reset' aria-label='Reset Zoom'>
37
+ Reset Zoom
38
+ </button>
39
+ )}
40
+ </div>
41
+ )
42
+ }
43
+
16
44
  return (
17
- <div className='zoom-controls' data-html2canvas-ignore='true'>
18
- <button onClick={() => handleZoomIn(position)} aria-label='Zoom In'>
19
- <svg viewBox='0 0 24 24' stroke='currentColor' strokeWidth='3'>
20
- <line x1='12' y1='5' x2='12' y2='19' />
21
- <line x1='5' y1='12' x2='19' y2='12' />
22
- </svg>
23
- </button>
24
- <button onClick={() => handleZoomOut(position)} aria-label='Zoom Out'>
25
- <svg viewBox='0 0 24 24' stroke='currentColor' strokeWidth='3'>
26
- <line x1='5' y1='12' x2='19' y2='12' />
27
- </svg>
28
- </button>
29
- {(config.general.type === 'world-geocode' ||
30
- config.general.geoType === 'single-state' ||
31
- config.general.type === 'bubble') && (
32
- <button onClick={() => handleZoomReset(setRuntimeData)} className='reset' aria-label='Reset Zoom'>
33
- Reset Zoom
45
+ <>
46
+ <div className='zoom-controls' data-html2canvas-ignore='true'>
47
+ <button onClick={() => handleZoomIn(position)} aria-label='Zoom In'>
48
+ <svg viewBox='0 0 24 24' stroke='currentColor' strokeWidth='3'>
49
+ <line x1='12' y1='5' x2='12' y2='19' />
50
+ <line x1='5' y1='12' x2='19' y2='12' />
51
+ </svg>
52
+ </button>
53
+ <button onClick={() => handleZoomOut(position)} aria-label='Zoom Out'>
54
+ <svg viewBox='0 0 24 24' stroke='currentColor' strokeWidth='3'>
55
+ <line x1='5' y1='12' x2='19' y2='12' />
56
+ </svg>
34
57
  </button>
58
+ </div>
59
+
60
+ {shouldShowUsGeocodeReset && (
61
+ <div className='zoom-controls zoom-controls--top-right' data-html2canvas-ignore='true'>
62
+ <button onClick={() => handleZoomReset(setRuntimeData)} className='reset' aria-label='Reset Zoom'>
63
+ Reset Zoom
64
+ </button>
65
+ </div>
35
66
  )}
36
- </div>
67
+ </>
37
68
  )
38
69
  }
39
70
 
@@ -1,14 +1,14 @@
1
1
  .zoom-controls {
2
- display: flex;
3
- position: absolute;
4
2
  bottom: 2em;
3
+ display: flex;
5
4
  left: 1em;
5
+ position: absolute;
6
6
  z-index: 4;
7
7
  > button.reset {
8
- margin-left: 5px;
9
8
  background: rgba(0, 0, 0, 0.65);
10
- transition: 0.2s all;
11
9
  color: #fff;
10
+ margin-left: 5px;
11
+ transition: 0.2s all;
12
12
  &:hover {
13
13
  background: rgba(0, 0, 0, 0.8);
14
14
  transition: 0.2s all;
@@ -21,17 +21,17 @@
21
21
  }
22
22
  }
23
23
  > button:not(.reset) {
24
- display: flex;
25
24
  align-items: center;
25
+ background: rgba(0, 0, 0, 0.65);
26
+ border: 0;
27
+ border-radius: 100%;
28
+ color: #fff;
29
+ display: flex;
30
+ height: 1.75em;
26
31
  justify-content: center;
27
32
  padding: 0.2em;
28
- height: 1.75em;
29
- width: 1.75em;
30
- background: rgba(0, 0, 0, 0.65);
31
33
  transition: 0.2s all;
32
- color: #fff;
33
- border-radius: 100%;
34
- border: 0;
34
+ width: 1.75em;
35
35
  &:hover {
36
36
  background: rgba(0, 0, 0, 0.8);
37
37
  transition: 0.2s all;
@@ -51,3 +51,19 @@
51
51
  margin-right: 0.25em;
52
52
  }
53
53
  }
54
+
55
+ .zoom-controls--top-right {
56
+ bottom: auto;
57
+ left: auto;
58
+ right: 1em;
59
+ top: 1em;
60
+ }
61
+
62
+ .zoom-controls--top-right > button.reset {
63
+ background: #005eaa;
64
+ }
65
+
66
+ .zoom-controls--top-right > button.reset:hover,
67
+ .zoom-controls--top-right > button.reset:focus {
68
+ background: #004b88;
69
+ }
@@ -41,6 +41,7 @@ const createInitialState = () => {
41
41
  allowMapZoom: true,
42
42
  hideGeoColumnInTooltip: false,
43
43
  hidePrimaryColumnInTooltip: false,
44
+ hideUnselectedStates: true,
44
45
  statesPicked: []
45
46
  },
46
47
  type: 'map',
@@ -49,7 +50,8 @@ const createInitialState = () => {
49
50
  name: 'FIPS Codes',
50
51
  label: 'Location',
51
52
  tooltip: false,
52
- dataTable: true
53
+ dataTable: true,
54
+ displayColumn: ''
53
55
  },
54
56
  primary: {
55
57
  dataTable: true,
@@ -76,14 +78,14 @@ const createInitialState = () => {
76
78
  showSpecialClassesLast: false,
77
79
  dynamicDescription: false,
78
80
  type: 'equalnumber',
79
- numberOfItems: 3,
80
- position: 'side',
81
+ numberOfItems: 5,
82
+ position: 'top',
81
83
  title: '',
82
- style: 'circles',
84
+ style: 'gradient',
83
85
  subStyle: 'linear blocks',
84
86
  tickRotation: '',
85
87
  singleColumnLegend: false,
86
- hideBorder: false,
88
+ hideBorder: true,
87
89
  groupBy: ''
88
90
  },
89
91
  filters: [],
@@ -96,6 +98,7 @@ const createInitialState = () => {
96
98
  height: '',
97
99
  caption: '',
98
100
  showDownloadUrl: false,
101
+ downloadUrlLabel: '',
99
102
  showDataTableLink: true,
100
103
  showDownloadLinkBelow: true,
101
104
  showFullGeoNameInCSV: false,
@@ -114,6 +117,13 @@ const createInitialState = () => {
114
117
  editorErrorMessage: []
115
118
  },
116
119
  visual: {
120
+ border: false,
121
+ borderColorTheme: false,
122
+ accent: false,
123
+ background: false,
124
+ hideBackgroundColor: false,
125
+ tp5Treatment: false,
126
+ tp5Background: false,
117
127
  minBubbleSize: 1,
118
128
  maxBubbleSize: 20,
119
129
  extraBubbleBorder: false,
@@ -0,0 +1,8 @@
1
+ // Preserves the OLD default values for properties changed in initial-state.js.
2
+ // When the backfill loop fills a missing property, it uses these values instead
3
+ // of the current defaults so that existing configs aren't visually affected.
4
+ //
5
+ // See backfillDefaults() in @cdc/core for the shared fill logic.
6
+ export const LEGACY_MAP_DEFAULTS: Record<string, Record<string, unknown>> = {
7
+ legend: { style: 'circles', position: 'side', numberOfItems: 3, hideBorder: false }
8
+ }