@cdc/core 4.26.1 → 4.26.3

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 (249) hide show
  1. package/.claude/agents/qa-test-developer.md +126 -0
  2. package/CLAUDE.local.md +67 -0
  3. package/LICENSE +201 -0
  4. package/_stories/Gallery.Charts.stories.tsx +35 -42
  5. package/_stories/Gallery.DataBite.stories.tsx +15 -8
  6. package/_stories/Gallery.Maps.stories.tsx +37 -28
  7. package/_stories/Gallery.WaffleChart.stories.tsx +1 -1
  8. package/_stories/PageART.stories.tsx +5 -4
  9. package/_stories/PageBRFSS.stories.tsx +21 -16
  10. package/_stories/PageCancerRegistries.stories.tsx +15 -15
  11. package/_stories/PageEasternEquineEncephalitis.stories.tsx +33 -19
  12. package/_stories/PageExcessiveAlcoholUse.stories.tsx +148 -143
  13. package/_stories/PageMaternalMortality.stories.tsx +5 -4
  14. package/_stories/PageOralHealth.stories.tsx +15 -10
  15. package/_stories/PageRespiratory.stories.tsx +4 -4
  16. package/_stories/PageSmokingTobacco.stories.tsx +15 -10
  17. package/_stories/PageStateDiabetesProfiles.stories.tsx +15 -10
  18. package/_stories/PageWastewater.stories.tsx +44 -30
  19. package/_stories/VegaImport.stories.tsx +401 -0
  20. package/_stories/vega-fixtures/bars-with-line.json +444 -0
  21. package/_stories/vega-fixtures/bars.json +58 -0
  22. package/_stories/vega-fixtures/combo-bar-rolling-mean.json +88 -0
  23. package/_stories/vega-fixtures/combo.json +68 -0
  24. package/_stories/vega-fixtures/grouped-horizontal-bars.json +83 -0
  25. package/_stories/vega-fixtures/grouped-horizontal-bars2.json +231 -0
  26. package/_stories/vega-fixtures/horizontal-bar.json +427 -0
  27. package/_stories/vega-fixtures/horizontal-bars-with-bad-colors.json +197 -0
  28. package/_stories/vega-fixtures/horizontal-bars2.json +58 -0
  29. package/_stories/vega-fixtures/lines.json +227 -0
  30. package/_stories/vega-fixtures/measles-bars.json +348 -0
  31. package/_stories/vega-fixtures/measles-map.json +11101 -0
  32. package/_stories/vega-fixtures/measles-stacked-bars.json +2147 -0
  33. package/_stories/vega-fixtures/multi-dataset.json +255 -0
  34. package/_stories/vega-fixtures/no-data.json +14 -0
  35. package/_stories/vega-fixtures/pie-chart.json +94 -0
  36. package/_stories/vega-fixtures/repeat-spec.json +47 -0
  37. package/_stories/vega-fixtures/stacked-area.json +222 -0
  38. package/_stories/vega-fixtures/stacked-bar-with-rect.json +3412 -0
  39. package/_stories/vega-fixtures/stacked-bars-with-line.json +364 -0
  40. package/_stories/vega-fixtures/stacked-bars.json +212 -0
  41. package/_stories/vega-fixtures/stacked-horizontal-bars.json +140 -0
  42. package/_stories/vega-fixtures/warning-combo.json +59 -0
  43. package/_stories/vega-fixtures/warning-scatter-and-line.json +1182 -0
  44. package/assets/callout-flag.svg +7 -0
  45. package/assets/icon-chart-area.svg +1 -0
  46. package/assets/icon-chart-radar.svg +23 -0
  47. package/assets/logo2.svg +31 -0
  48. package/components/AdvancedEditor/EmbedEditor.tsx +270 -38
  49. package/components/Alert/components/Alert.styles.css +2 -2
  50. package/components/ComboBox/combobox.styles.css +48 -48
  51. package/components/CustomColorsEditor/CustomColorsEditor.css +53 -53
  52. package/components/CustomColorsEditor/CustomColorsEditor.tsx +3 -10
  53. package/components/DataTable/DataTable.tsx +46 -18
  54. package/components/DataTable/DataTableStandAlone.tsx +1 -0
  55. package/components/DataTable/components/ChartHeader.tsx +21 -12
  56. package/components/DataTable/components/MapHeader.tsx +34 -28
  57. package/components/DataTable/components/SortIcon/sort-icon.css +5 -5
  58. package/components/DataTable/data-table.css +50 -52
  59. package/components/DataTable/helpers/applyCustomOrder.ts +17 -0
  60. package/components/DataTable/helpers/getChartCellValue.ts +10 -7
  61. package/components/DataTable/helpers/getMapDataTableColumnKeys.ts +22 -0
  62. package/components/DataTable/helpers/getSeriesName.ts +6 -0
  63. package/components/DataTable/helpers/mapCellMatrix.tsx +33 -23
  64. package/components/DataTable/helpers/tests/mapCellMatrix.test.ts +33 -0
  65. package/components/DownloadButton.tsx +14 -6
  66. package/components/EditorPanel/ColumnsEditor.tsx +38 -31
  67. package/components/EditorPanel/CustomSortOrder.tsx +94 -0
  68. package/components/EditorPanel/DataTableEditor.tsx +139 -23
  69. package/components/EditorPanel/EditorPanel.styles.css +71 -71
  70. package/components/EditorPanel/EditorPanel.tsx +3 -8
  71. package/components/EditorPanel/EditorPanelDispatch.tsx +4 -4
  72. package/components/EditorPanel/FootnotesEditor.tsx +2 -2
  73. package/components/EditorPanel/VizFilterEditor/NestedDropdownEditor.tsx +21 -12
  74. package/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +16 -10
  75. package/components/EditorPanel/VizFilterEditor/components/FilterOrder.tsx +33 -29
  76. package/components/EditorPanel/components/MarkupVariablesEditor.tsx +160 -106
  77. package/components/EditorPanel/components/PanelMarkup.tsx +5 -1
  78. package/{styles/v2/components → components/EditorPanel}/editor.scss +76 -22
  79. package/components/EditorPanel/sections/StyleTreatmentSection.tsx +99 -0
  80. package/components/EditorPanel/sections/VisualSection.tsx +11 -0
  81. package/components/EditorWrapper/editor-wrapper.style.css +1 -1
  82. package/components/Filters/Filters.tsx +3 -5
  83. package/components/Filters/components/Tabs.tsx +19 -7
  84. package/{styles → components/Filters}/filters.scss +3 -3
  85. package/components/Footnotes/FootnotesStandAlone.tsx +4 -2
  86. package/components/HeaderThemeSelector/HeaderThemeSelector.css +61 -5
  87. package/components/Layout/components/Responsive.tsx +14 -6
  88. package/components/Layout/components/Sidebar/components/Sidebar.tsx +1 -1
  89. package/components/Layout/components/Sidebar/components/sidebar.styles.scss +14 -20
  90. package/components/Layout/components/Visualization/index.tsx +50 -38
  91. package/components/Layout/components/Visualization/visualizations.scss +232 -15
  92. package/components/Layout/components/VisualizationContainer.test.tsx +67 -0
  93. package/components/Layout/components/VisualizationContainer.tsx +37 -0
  94. package/components/Layout/components/VisualizationContent.test.tsx +182 -0
  95. package/components/Layout/components/VisualizationContent.tsx +75 -0
  96. package/components/Layout/index.tsx +5 -5
  97. package/components/Layout/styles/editor-utils.scss +3 -3
  98. package/components/Layout/styles/editor.scss +4 -4
  99. package/components/Legend/Legend.Gradient.tsx +7 -1
  100. package/components/Loader/loader.styles.css +2 -2
  101. package/components/Loading.jsx +1 -1
  102. package/components/MediaControls.tsx +10 -3
  103. package/components/MultiSelect/multiselect.styles.css +19 -19
  104. package/components/NestedDropdown/nesteddropdown.styles.css +15 -15
  105. package/components/PaletteSelector/PaletteSelector.css +15 -15
  106. package/components/RichTooltip/richTooltip.css +6 -6
  107. package/components/Table/table.styles.css +2 -2
  108. package/components/Waiting.tsx +1 -1
  109. package/components/_stories/CustomColorsEditor.stories.tsx +37 -0
  110. package/components/_stories/DataTable.stories.tsx +1 -0
  111. package/components/_stories/Filters.stories.tsx +1 -1
  112. package/components/_stories/styles.scss +0 -1
  113. package/components/elements/Button.jsx +1 -1
  114. package/components/elements/Card.jsx +1 -1
  115. package/{styles/v2/components → components/elements}/button.scss +9 -8
  116. package/components/inputs/InputCheckbox.jsx +1 -1
  117. package/components/inputs/InputSelect.tsx +1 -1
  118. package/components/inputs/InputText.jsx +1 -1
  119. package/components/inputs/InputToggle.tsx +1 -1
  120. package/{styles/v2/components/input → components/inputs}/_input-check-radio.scss +2 -2
  121. package/{styles/v2/components/input → components/inputs}/_input-group.scss +3 -3
  122. package/{styles/v2/components/input → components/inputs}/_input-slider.scss +2 -2
  123. package/{styles/v2/components/input → components/inputs}/_input.scss +5 -5
  124. package/{styles/v2/components/input → components/inputs}/index.scss +2 -2
  125. package/{styles → components}/loading.scss +1 -1
  126. package/components/managers/DataDesigner.tsx +1 -1
  127. package/{styles/v2/components → components/managers}/data-designer.scss +6 -7
  128. package/components/ui/Accordion.jsx +1 -1
  129. package/components/ui/Icon.tsx +1 -1
  130. package/components/ui/LoadSpin.jsx +1 -1
  131. package/components/ui/Modal.jsx +1 -1
  132. package/components/ui/Overlay.jsx +1 -1
  133. package/components/ui/Title/index.test.tsx +34 -0
  134. package/components/ui/Title/index.tsx +24 -7
  135. package/components/ui/Title/title.styles.css +119 -25
  136. package/components/ui/Tooltip.tsx +1 -1
  137. package/components/ui/_stories/Title.stories.tsx +1 -1
  138. package/{styles/v2/components → components/ui}/accordion.scss +3 -3
  139. package/components/ui/accordion.styles.css +11 -11
  140. package/{styles/v2/components → components/ui}/modal.scss +2 -2
  141. package/{styles/v2/components → components/ui}/overlay.scss +6 -6
  142. package/{styles/v2/components → components}/ui/tooltip.scss +1 -1
  143. package/{styles → components}/waiting.scss +9 -3
  144. package/data/colorPalettes.ts +18 -5
  145. package/data/mapColorPalettes.ts +10 -0
  146. package/devTemplate/dev.js +285 -0
  147. package/devTemplate/index.html +30 -0
  148. package/devTemplate/preview.html +1503 -0
  149. package/devTemplate/sidebar.css +151 -0
  150. package/dist/cove-main.css +2530 -3901
  151. package/dist/cove-main.css.map +1 -1
  152. package/generateViteConfig.js +111 -2
  153. package/helpers/DataTransform.ts +1 -5
  154. package/helpers/backfillDefaults.ts +35 -0
  155. package/helpers/constants.ts +12 -0
  156. package/helpers/cove/date.ts +64 -3
  157. package/helpers/cove/number.ts +29 -15
  158. package/helpers/cove/string.ts +29 -0
  159. package/helpers/coveUpdateWorker.ts +14 -8
  160. package/helpers/displayDataAsText.ts +1 -1
  161. package/helpers/embed/embedCodeGenerator.ts +80 -0
  162. package/helpers/embed/embedHelper.js +169 -0
  163. package/helpers/embed/filterUtils.ts +121 -0
  164. package/helpers/embed/index.ts +17 -0
  165. package/helpers/embed/urlValidation.ts +119 -0
  166. package/helpers/extractDataAndMetadata.ts +20 -0
  167. package/helpers/fetchRemoteData.ts +14 -8
  168. package/helpers/filterVizData.ts +6 -1
  169. package/helpers/getFileExtension.ts +0 -6
  170. package/helpers/labelHash.ts +9 -0
  171. package/helpers/markupProcessor.ts +56 -38
  172. package/helpers/metrics/types.ts +3 -0
  173. package/helpers/palettes/colorDistributions.ts +1 -1
  174. package/helpers/palettes/utils.ts +12 -12
  175. package/helpers/parseCsvWithQuotes.ts +15 -14
  176. package/helpers/prepareScreenshot.ts +33 -10
  177. package/helpers/testing.ts +44 -0
  178. package/helpers/tests/DataTransform.test.ts +125 -0
  179. package/helpers/tests/abbreviateNumber.test.ts +59 -0
  180. package/helpers/tests/backfillDefaults.test.ts +253 -0
  181. package/helpers/tests/date.test.ts +110 -0
  182. package/helpers/tests/extractDataAndMetadata.test.ts +93 -0
  183. package/helpers/tests/markupProcessor.test.ts +315 -124
  184. package/helpers/tests/number.test.ts +42 -0
  185. package/helpers/tests/prepareScreenshot.test.ts +28 -28
  186. package/helpers/tests/testStandaloneBuild.ts +36 -26
  187. package/helpers/tests/useDataVizClasses.test.ts +66 -0
  188. package/helpers/tests/visualizationWrapperUsage.test.ts +57 -0
  189. package/helpers/useDataVizClasses.ts +13 -7
  190. package/helpers/vegaConfig.ts +1 -1
  191. package/helpers/vegaConfigImport.ts +160 -0
  192. package/helpers/ver/4.24.4.ts +24 -0
  193. package/helpers/ver/4.26.1.ts +1 -1
  194. package/helpers/ver/4.26.2.ts +84 -0
  195. package/helpers/ver/4.26.3.ts +44 -0
  196. package/helpers/ver/4.26.4.ts +31 -0
  197. package/helpers/ver/tests/4.26.1.test.ts +105 -0
  198. package/helpers/ver/tests/4.26.2.test.ts +298 -0
  199. package/helpers/ver/tests/4.26.3.test.ts +168 -0
  200. package/helpers/ver/tests/4.26.4.test.ts +88 -0
  201. package/helpers/ver/tests/coveUpdateWorker.test.ts +57 -0
  202. package/helpers/viewports.ts +2 -0
  203. package/package.json +27 -32
  204. package/styles/_global.scss +7 -7
  205. package/styles/_reset.scss +2 -2
  206. package/styles/{v2/base → base}/_file-selector.scss +4 -4
  207. package/styles/{v2/base → base}/_general.scss +2 -4
  208. package/styles/{v2/base → base}/index.scss +1 -1
  209. package/styles/base.scss +107 -165
  210. package/styles/cove-main.scss +3 -6
  211. package/styles/layout/_component.scss +110 -0
  212. package/styles/{v2/layout → layout}/_data-table.scss +7 -7
  213. package/styles/layout/_wrapper-padding.scss +27 -0
  214. package/styles/{v2/main.scss → main.scss} +3 -1
  215. package/styles/{v2/themes → themes}/_color-definitions.scss +46 -41
  216. package/styles/{_accessibility.scss → utils/_accessibility.scss} +1 -1
  217. package/styles/{v2/utils → utils}/_grid.scss +8 -3
  218. package/styles/{_global-variables.scss → utils/_properties.scss} +133 -112
  219. package/styles/{v2/utils → utils}/index.scss +2 -1
  220. package/types/Annotation.ts +10 -11
  221. package/types/Axis.ts +2 -0
  222. package/types/ComponentStyles.ts +1 -0
  223. package/types/ConfigureData.ts +1 -0
  224. package/types/General.ts +2 -0
  225. package/types/MarkupInclude.ts +1 -0
  226. package/types/MarkupVariable.ts +2 -1
  227. package/types/Palette.ts +22 -0
  228. package/types/Table.ts +9 -0
  229. package/types/Visualization.ts +7 -0
  230. package/_stories/StoryRenderingTests.stories.tsx +0 -164
  231. package/helpers/embedCodeGenerator.ts +0 -109
  232. package/styles/_common-components.css +0 -73
  233. package/styles/_variables.scss +0 -63
  234. package/styles/v2/layout/_component.scss +0 -21
  235. package/styles/v2/utils/_variables.scss +0 -9
  236. package/{styles/v2/components/card.scss → components/elements/card.css} +2 -2
  237. /package/{styles/v2/components → components/ui}/icon.scss +0 -0
  238. /package/{styles/v2/components → components/ui}/loadspin.scss +0 -0
  239. /package/styles/{v2/base → base}/_heading.scss +0 -0
  240. /package/styles/{v2/base → base}/_reset.scss +0 -0
  241. /package/styles/{v2/layout → layout}/_alert.scss +0 -0
  242. /package/styles/{v2/layout → layout}/_progression.scss +0 -0
  243. /package/styles/{v2/layout → layout}/_tooltip.scss +0 -0
  244. /package/styles/{v2/layout → layout}/index.scss +0 -0
  245. /package/styles/{v2/themes → themes}/index.scss +0 -0
  246. /package/styles/{v2/utils → utils}/_align.scss +0 -0
  247. /package/styles/{v2/utils → utils}/_animations.scss +0 -0
  248. /package/styles/{v2/utils → utils}/_breakpoints.scss +0 -0
  249. /package/styles/{v2/utils → utils}/_mixins.scss +0 -0
@@ -16,7 +16,8 @@ const meta: Meta = {
16
16
  layout: 'fullscreen',
17
17
  docs: {
18
18
  description: {
19
- component: 'Stories for visualizations from the CDC Oral Health Data page (https://www.cdc.gov/oral-health-data-systems/oral_health_data/oral-health-dashboard.html)'
19
+ component:
20
+ 'Stories for visualizations from the CDC Oral Health Data page (https://www.cdc.gov/oral-health-data-systems/oral_health_data/oral-health-dashboard.html)'
20
21
  }
21
22
  }
22
23
  },
@@ -92,12 +93,16 @@ const useConfigWithAbsoluteDataUrl = (configUrl: string) => {
92
93
 
93
94
  newDatasets[absoluteKey] = {
94
95
  ...dataset,
95
- dataFileName: (dataset as any).dataFileName && !(dataset as any).dataFileName.startsWith('http')
96
- ? `https://www.cdc.gov/${(dataset as any).dataFileName.replace(/^(\.\.\/)+/, '').replace(/^\//, '')}`
97
- : (dataset as any).dataFileName,
98
- dataUrl: (dataset as any).dataUrl && !(dataset as any).dataUrl.startsWith('http')
99
- ? `https://www.cdc.gov/${(dataset as any).dataUrl.replace(/^(\.\.\/)+/, '').replace(/^\//, '')}`
100
- : (dataset as any).dataUrl
96
+ dataFileName:
97
+ (dataset as any).dataFileName && !(dataset as any).dataFileName.startsWith('http')
98
+ ? `https://www.cdc.gov/${(dataset as any).dataFileName
99
+ .replace(/^(\.\.\/)+/, '')
100
+ .replace(/^\//, '')}`
101
+ : (dataset as any).dataFileName,
102
+ dataUrl:
103
+ (dataset as any).dataUrl && !(dataset as any).dataUrl.startsWith('http')
104
+ ? `https://www.cdc.gov/${(dataset as any).dataUrl.replace(/^(\.\.\/)+/, '').replace(/^\//, '')}`
105
+ : (dataset as any).dataUrl
101
106
  }
102
107
  }
103
108
  })
@@ -139,7 +144,7 @@ const testDashboardRendering = async (canvasElement: HTMLElement, storyName: str
139
144
  const timeout = 30000 // Longer timeout for external data loading
140
145
 
141
146
  const checkDashboard = () => {
142
- const dashboardElement = canvasElement.querySelector('.cove-dashboard')
147
+ const dashboardElement = canvasElement.querySelector('.type-dashboard')
143
148
  const loadingDiv = canvasElement.querySelector('div')
144
149
 
145
150
  // Log current state for debugging
@@ -160,12 +165,12 @@ const testDashboardRendering = async (canvasElement: HTMLElement, storyName: str
160
165
  })
161
166
 
162
167
  await step('Verify dashboard wrapper is present', async () => {
163
- const dashboard = canvasElement.querySelector('.cove-dashboard')
168
+ const dashboard = canvasElement.querySelector('.type-dashboard')
164
169
  expect(dashboard).toBeInTheDocument()
165
170
  })
166
171
 
167
172
  await step('Verify at least one visualization rendered', async () => {
168
- const coveModules = canvasElement.querySelectorAll('.cdc-open-viz-module')
173
+ const coveModules = canvasElement.querySelectorAll('.cove-visualization')
169
174
  expect(coveModules.length).toBeGreaterThan(0)
170
175
  })
171
176
 
@@ -127,7 +127,7 @@ const testMapRendering = async (canvasElement: HTMLElement, storyName: string) =
127
127
  })
128
128
 
129
129
  await step('Verify COVE module wrapper is present', async () => {
130
- const coveModule = canvasElement.querySelector('.cdc-open-viz-module')
130
+ const coveModule = canvasElement.querySelector('.cove-visualization')
131
131
  expect(coveModule).toBeInTheDocument()
132
132
  })
133
133
 
@@ -154,7 +154,7 @@ const testChartRendering = async (canvasElement: HTMLElement, storyName: string)
154
154
  })
155
155
 
156
156
  await step('Verify COVE module wrapper is present', async () => {
157
- const coveModule = canvasElement.querySelector('.cdc-open-viz-module')
157
+ const coveModule = canvasElement.querySelector('.cove-visualization')
158
158
  expect(coveModule).toBeInTheDocument()
159
159
  })
160
160
 
@@ -304,7 +304,7 @@ export const All_Visualizations: StoryObj = {
304
304
  const timeout = 20000
305
305
 
306
306
  const checkModules = () => {
307
- const coveModules = canvasElement.querySelectorAll('.cdc-open-viz-module')
307
+ const coveModules = canvasElement.querySelectorAll('.cove-visualization')
308
308
  if (coveModules.length >= 4) {
309
309
  resolve()
310
310
  } else if (Date.now() - startTime > timeout) {
@@ -323,7 +323,7 @@ export const All_Visualizations: StoryObj = {
323
323
  })
324
324
 
325
325
  await step('Verify exactly 4 COVE modules are present', async () => {
326
- const coveModules = canvasElement.querySelectorAll('.cdc-open-viz-module')
326
+ const coveModules = canvasElement.querySelectorAll('.cove-visualization')
327
327
  expect(coveModules.length).toBe(4)
328
328
  })
329
329
 
@@ -16,7 +16,8 @@ const meta: Meta = {
16
16
  layout: 'fullscreen',
17
17
  docs: {
18
18
  description: {
19
- component: 'Stories for visualizations from the CDC Global Tobacco Surveillance System (GTSS) Data Explorer page (https://www.cdc.gov/tobacco/global/gtss/data-explorer/index.html)'
19
+ component:
20
+ 'Stories for visualizations from the CDC Global Tobacco Surveillance System (GTSS) Data Explorer page (https://www.cdc.gov/tobacco/global/gtss/data-explorer/index.html)'
20
21
  }
21
22
  }
22
23
  },
@@ -92,12 +93,16 @@ const useConfigWithAbsoluteDataUrl = (configUrl: string) => {
92
93
 
93
94
  newDatasets[absoluteKey] = {
94
95
  ...dataset,
95
- dataFileName: (dataset as any).dataFileName && !(dataset as any).dataFileName.startsWith('http')
96
- ? `https://www.cdc.gov/${(dataset as any).dataFileName.replace(/^(\.\.\/)+/, '').replace(/^\//, '')}`
97
- : (dataset as any).dataFileName,
98
- dataUrl: (dataset as any).dataUrl && !(dataset as any).dataUrl.startsWith('http')
99
- ? `https://www.cdc.gov/${(dataset as any).dataUrl.replace(/^(\.\.\/)+/, '').replace(/^\//, '')}`
100
- : (dataset as any).dataUrl
96
+ dataFileName:
97
+ (dataset as any).dataFileName && !(dataset as any).dataFileName.startsWith('http')
98
+ ? `https://www.cdc.gov/${(dataset as any).dataFileName
99
+ .replace(/^(\.\.\/)+/, '')
100
+ .replace(/^\//, '')}`
101
+ : (dataset as any).dataFileName,
102
+ dataUrl:
103
+ (dataset as any).dataUrl && !(dataset as any).dataUrl.startsWith('http')
104
+ ? `https://www.cdc.gov/${(dataset as any).dataUrl.replace(/^(\.\.\/)+/, '').replace(/^\//, '')}`
105
+ : (dataset as any).dataUrl
101
106
  }
102
107
  }
103
108
  })
@@ -139,7 +144,7 @@ const testDashboardRendering = async (canvasElement: HTMLElement, storyName: str
139
144
  const timeout = 30000 // Longer timeout for external data loading
140
145
 
141
146
  const checkDashboard = () => {
142
- const dashboardElement = canvasElement.querySelector('.cove-dashboard')
147
+ const dashboardElement = canvasElement.querySelector('.type-dashboard')
143
148
  const loadingDiv = canvasElement.querySelector('div')
144
149
 
145
150
  // Log current state for debugging
@@ -160,12 +165,12 @@ const testDashboardRendering = async (canvasElement: HTMLElement, storyName: str
160
165
  })
161
166
 
162
167
  await step('Verify dashboard wrapper is present', async () => {
163
- const dashboard = canvasElement.querySelector('.cove-dashboard')
168
+ const dashboard = canvasElement.querySelector('.type-dashboard')
164
169
  expect(dashboard).toBeInTheDocument()
165
170
  })
166
171
 
167
172
  await step('Verify at least one visualization rendered', async () => {
168
- const coveModules = canvasElement.querySelectorAll('.cdc-open-viz-module')
173
+ const coveModules = canvasElement.querySelectorAll('.cove-visualization')
169
174
  expect(coveModules.length).toBeGreaterThan(0)
170
175
  })
171
176
 
@@ -16,7 +16,8 @@ const meta: Meta = {
16
16
  layout: 'fullscreen',
17
17
  docs: {
18
18
  description: {
19
- component: 'Stories for visualizations from the CDC State Diabetes Profiles page (https://www.cdc.gov/diabetes-state-local/php/state-profiles/index.html)'
19
+ component:
20
+ 'Stories for visualizations from the CDC State Diabetes Profiles page (https://www.cdc.gov/diabetes-state-local/php/state-profiles/index.html)'
20
21
  }
21
22
  }
22
23
  },
@@ -92,12 +93,16 @@ const useConfigWithAbsoluteDataUrl = (configUrl: string) => {
92
93
 
93
94
  newDatasets[absoluteKey] = {
94
95
  ...dataset,
95
- dataFileName: (dataset as any).dataFileName && !(dataset as any).dataFileName.startsWith('http')
96
- ? `https://www.cdc.gov/${(dataset as any).dataFileName.replace(/^(\.\.\/)+/, '').replace(/^\//, '')}`
97
- : (dataset as any).dataFileName,
98
- dataUrl: (dataset as any).dataUrl && !(dataset as any).dataUrl.startsWith('http')
99
- ? `https://www.cdc.gov/${(dataset as any).dataUrl.replace(/^(\.\.\/)+/, '').replace(/^\//, '')}`
100
- : (dataset as any).dataUrl
96
+ dataFileName:
97
+ (dataset as any).dataFileName && !(dataset as any).dataFileName.startsWith('http')
98
+ ? `https://www.cdc.gov/${(dataset as any).dataFileName
99
+ .replace(/^(\.\.\/)+/, '')
100
+ .replace(/^\//, '')}`
101
+ : (dataset as any).dataFileName,
102
+ dataUrl:
103
+ (dataset as any).dataUrl && !(dataset as any).dataUrl.startsWith('http')
104
+ ? `https://www.cdc.gov/${(dataset as any).dataUrl.replace(/^(\.\.\/)+/, '').replace(/^\//, '')}`
105
+ : (dataset as any).dataUrl
101
106
  }
102
107
  }
103
108
  })
@@ -139,7 +144,7 @@ const testDashboardRendering = async (canvasElement: HTMLElement, storyName: str
139
144
  const timeout = 30000 // Longer timeout for external data loading
140
145
 
141
146
  const checkDashboard = () => {
142
- const dashboardElement = canvasElement.querySelector('.cove-dashboard')
147
+ const dashboardElement = canvasElement.querySelector('.type-dashboard')
143
148
  const loadingDiv = canvasElement.querySelector('div')
144
149
 
145
150
  // Log current state for debugging
@@ -160,12 +165,12 @@ const testDashboardRendering = async (canvasElement: HTMLElement, storyName: str
160
165
  })
161
166
 
162
167
  await step('Verify dashboard wrapper is present', async () => {
163
- const dashboard = canvasElement.querySelector('.cove-dashboard')
168
+ const dashboard = canvasElement.querySelector('.type-dashboard')
164
169
  expect(dashboard).toBeInTheDocument()
165
170
  })
166
171
 
167
172
  await step('Verify at least one visualization rendered', async () => {
168
- const coveModules = canvasElement.querySelectorAll('.cdc-open-viz-module')
173
+ const coveModules = canvasElement.querySelectorAll('.cove-visualization')
169
174
  expect(coveModules.length).toBeGreaterThan(0)
170
175
  })
171
176
 
@@ -115,22 +115,36 @@ type MapStory = StoryObj<typeof CdcMap>
115
115
  type ChartStory = StoryObj<typeof Chart>
116
116
  type DashboardStory = StoryObj<typeof Dashboard>
117
117
 
118
- // Helper function to test map rendering
118
+ // Helper function to test map rendering (supports both SVG and canvas-based maps)
119
119
  const testMapRendering = async (canvasElement: HTMLElement, storyName: string) => {
120
- const canvas = within(canvasElement)
121
-
122
120
  await step('Wait for map to render', async () => {
123
- const mapElement = await canvas.findByRole('img', { hidden: true }, { timeout: 10000 })
124
- expect(mapElement).toBeInTheDocument()
121
+ await new Promise<void>((resolve, reject) => {
122
+ const startTime = Date.now()
123
+ const timeout = 15000
124
+
125
+ const checkMap = () => {
126
+ const svgMap = canvasElement.querySelector('svg[role="img"]')
127
+ const canvasMap = canvasElement.querySelector('canvas')
128
+ if (svgMap || canvasMap) {
129
+ resolve()
130
+ } else if (Date.now() - startTime > timeout) {
131
+ reject(new Error(`Timeout: No map element (svg or canvas) found after ${timeout}ms`))
132
+ } else {
133
+ setTimeout(checkMap, 100)
134
+ }
135
+ }
136
+ checkMap()
137
+ })
125
138
  })
126
139
 
127
- await step('Verify SVG element is present', async () => {
128
- const svgElement = canvasElement.querySelector('svg')
129
- expect(svgElement).toBeInTheDocument()
140
+ await step('Verify map visualization is present', async () => {
141
+ const svgMap = canvasElement.querySelector('svg[role="img"]')
142
+ const canvasMap = canvasElement.querySelector('canvas')
143
+ expect(svgMap || canvasMap).toBeTruthy()
130
144
  })
131
145
 
132
146
  await step('Verify COVE module wrapper is present', async () => {
133
- const coveModule = canvasElement.querySelector('.cdc-open-viz-module')
147
+ const coveModule = canvasElement.querySelector('.cove-visualization')
134
148
  expect(coveModule).toBeInTheDocument()
135
149
  })
136
150
 
@@ -152,7 +166,7 @@ const testChartRendering = async (canvasElement: HTMLElement, storyName: string)
152
166
  })
153
167
 
154
168
  await step('Verify COVE module wrapper is present', async () => {
155
- const coveModule = canvasElement.querySelector('.cdc-open-viz-module')
169
+ const coveModule = canvasElement.querySelector('.cove-visualization')
156
170
  expect(coveModule).toBeInTheDocument()
157
171
  })
158
172
 
@@ -167,7 +181,7 @@ const testDashboardRendering = async (canvasElement: HTMLElement, storyName: str
167
181
  const timeout = 15000
168
182
 
169
183
  const checkDashboard = () => {
170
- const dashboardElement = canvasElement.querySelector('.cove-dashboard')
184
+ const dashboardElement = canvasElement.querySelector('.type-dashboard')
171
185
  if (dashboardElement) {
172
186
  resolve()
173
187
  } else if (Date.now() - startTime > timeout) {
@@ -181,7 +195,7 @@ const testDashboardRendering = async (canvasElement: HTMLElement, storyName: str
181
195
  })
182
196
 
183
197
  await step('Verify dashboard wrapper is present', async () => {
184
- const dashboard = canvasElement.querySelector('.cove-dashboard')
198
+ const dashboard = canvasElement.querySelector('.type-dashboard')
185
199
  expect(dashboard).toBeInTheDocument()
186
200
  })
187
201
 
@@ -289,14 +303,14 @@ export const COVID_Time_Period_Map: MapStory = {
289
303
  *
290
304
  * COVID-19 wastewater data visualization by state.
291
305
  */
292
- export const COVID_State_Level: ChartStory = {
306
+ export const COVID_State_Level: MapStory = {
293
307
  render: () => {
294
308
  const config = useConfigWithAbsoluteDataUrl(CONFIG_URLS.covidStateLevel)
295
309
  if (!config) return <div>Loading...</div>
296
- return <Chart config={config} />
310
+ return <CdcMap config={config} />
297
311
  },
298
312
  play: async ({ canvasElement }) => {
299
- await testChartRendering(canvasElement, 'COVID State Level')
313
+ await testMapRendering(canvasElement, 'COVID State Level')
300
314
  }
301
315
  }
302
316
 
@@ -325,10 +339,10 @@ export const COVID_State_Level_Rest: ChartStory = {
325
339
  render: () => {
326
340
  const config = useConfigWithAbsoluteDataUrl(CONFIG_URLS.covidStateLevelRest)
327
341
  if (!config) return <div>Loading...</div>
328
- return <Chart config={config} />
342
+ return <Dashboard config={config} />
329
343
  },
330
344
  play: async ({ canvasElement }) => {
331
- await testChartRendering(canvasElement, 'COVID State Level Rest')
345
+ await testDashboardRendering(canvasElement, 'COVID State Level Rest')
332
346
  }
333
347
  }
334
348
 
@@ -365,50 +379,50 @@ export const All_Wastewater_Visualizations: StoryObj = {
365
379
  }
366
380
 
367
381
  return (
368
- <div className="container-fluid p-4">
369
- <h1 className="mb-4">NWSS - All Wastewater Visualizations</h1>
382
+ <div className='container-fluid p-4'>
383
+ <h1 className='mb-4'>NWSS - All Wastewater Visualizations</h1>
370
384
 
371
- <section className="mb-5">
385
+ <section className='mb-5'>
372
386
  <h2>NWSS Home Page</h2>
373
387
  <Dashboard config={homePageConfig} />
374
388
  </section>
375
389
 
376
- <section className="mb-5">
390
+ <section className='mb-5'>
377
391
  <h2>Measles - Summary Modules</h2>
378
392
  <Dashboard config={measlesTopConfig} />
379
393
  </section>
380
394
 
381
- <section className="mb-5">
395
+ <section className='mb-5'>
382
396
  <h2>Measles - US Map</h2>
383
397
  <CdcMap config={measlesMapConfig} />
384
398
  </section>
385
399
 
386
- <section className="mb-5">
400
+ <section className='mb-5'>
387
401
  <h2>Measles - Time Period</h2>
388
402
  <Dashboard config={measlesTimePeriodConfig} />
389
403
  </section>
390
404
 
391
- <section className="mb-5">
405
+ <section className='mb-5'>
392
406
  <h2>COVID-19 - Summary Modules</h2>
393
407
  <Dashboard config={covidTopConfig} />
394
408
  </section>
395
409
 
396
- <section className="mb-5">
410
+ <section className='mb-5'>
397
411
  <h2>COVID-19 - State Map</h2>
398
412
  <CdcMap config={covidMapConfig} />
399
413
  </section>
400
414
 
401
- <section className="mb-5">
415
+ <section className='mb-5'>
402
416
  <h2>COVID-19 - State Level Data</h2>
403
417
  <Chart config={covidStateLevelConfig} />
404
418
  </section>
405
419
 
406
- <section className="mb-5">
420
+ <section className='mb-5'>
407
421
  <h2>COVID-19 - National and Regional Trends</h2>
408
422
  <Chart config={covidNationalRegionalConfig} />
409
423
  </section>
410
424
 
411
- <section className="mb-5">
425
+ <section className='mb-5'>
412
426
  <h2>COVID-19 - State Trends</h2>
413
427
  <Chart config={covidStateRestConfig} />
414
428
  </section>
@@ -440,7 +454,7 @@ export const All_Wastewater_Visualizations: StoryObj = {
440
454
  const timeout = 30000
441
455
 
442
456
  const checkModules = () => {
443
- const coveModules = canvasElement.querySelectorAll('.cdc-open-viz-module')
457
+ const coveModules = canvasElement.querySelectorAll('.cove-visualization')
444
458
  if (coveModules.length >= 9) {
445
459
  resolve()
446
460
  } else if (Date.now() - startTime > timeout) {
@@ -454,7 +468,7 @@ export const All_Wastewater_Visualizations: StoryObj = {
454
468
  })
455
469
 
456
470
  await step('Verify at least 9 visualizations are present', async () => {
457
- const coveModules = canvasElement.querySelectorAll('.cdc-open-viz-module')
471
+ const coveModules = canvasElement.querySelectorAll('.cove-visualization')
458
472
  expect(coveModules.length).toBeGreaterThanOrEqual(9)
459
473
  })
460
474