@cdc/core 4.25.6 → 4.25.8

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 (37) hide show
  1. package/components/DataTable/DataTable.tsx +52 -19
  2. package/components/DataTable/DataTableStandAlone.tsx +4 -1
  3. package/components/DataTable/components/ChartHeader.tsx +44 -13
  4. package/components/DataTable/components/ExpandCollapse.tsx +14 -2
  5. package/components/DataTable/components/MapHeader.tsx +18 -1
  6. package/components/DataTable/components/SortIcon/sort-icon.css +21 -27
  7. package/components/DataTable/data-table.css +33 -4
  8. package/components/DataTable/helpers/customSort.ts +4 -2
  9. package/components/DownloadButton.tsx +4 -1
  10. package/components/EditorPanel/DataTableEditor.tsx +10 -1
  11. package/components/Filters/Filters.tsx +26 -9
  12. package/components/Footnotes/FootnotesStandAlone.tsx +2 -1
  13. package/components/{MediaControls.jsx → MediaControls.tsx} +32 -16
  14. package/components/Table/components/Row.tsx +15 -12
  15. package/dist/cove-main.css +0 -10
  16. package/dist/cove-main.css.map +1 -1
  17. package/helpers/cove/number.ts +6 -2
  18. package/helpers/coveUpdateWorker.ts +5 -1
  19. package/helpers/events.ts +32 -0
  20. package/helpers/isRightAlignedTableValue.js +1 -1
  21. package/helpers/metrics/helpers.ts +52 -0
  22. package/helpers/metrics/types.ts +43 -0
  23. package/helpers/vegaConfig.ts +647 -0
  24. package/helpers/ver/4.25.7.ts +26 -0
  25. package/helpers/ver/4.25.8.ts +61 -0
  26. package/helpers/ver/tests/4.25.8.test.ts +86 -0
  27. package/helpers/viewports.ts +2 -0
  28. package/package.json +6 -4
  29. package/styles/_accessibility.scss +8 -0
  30. package/styles/_button-section.scss +0 -2
  31. package/styles/_global.scss +0 -4
  32. package/styles/filters.scss +0 -4
  33. package/types/ForecastingSeriesKey.ts +15 -0
  34. package/types/Runtime.ts +1 -7
  35. package/types/Series.ts +4 -0
  36. package/types/Table.ts +1 -0
  37. package/helpers/events.js +0 -14
@@ -0,0 +1,61 @@
1
+ import _ from 'lodash'
2
+
3
+ export const updateAxisColors = config => {
4
+ if (config.type === 'chart') {
5
+ if (config.xAxis) {
6
+ ;['labelColor', 'tickLabelColor', 'tickColor'].forEach(k => {
7
+ if (config.xAxis[k] === '#333') {
8
+ config.xAxis[k] = '#1c1d1f'
9
+ }
10
+ })
11
+ }
12
+ if (config.yAxis) {
13
+ ;[
14
+ 'labelColor',
15
+ 'tickLabelColor',
16
+ 'tickColor',
17
+ 'rightAxisLabelColor',
18
+ 'rightAxisTickLabelColor',
19
+ 'rightAxisTickColor'
20
+ ].forEach(k => {
21
+ if (config.yAxis[k] === '#333') {
22
+ config.yAxis[k] = '#1c1d1f'
23
+ }
24
+ })
25
+ }
26
+ } else if (config.type === 'dashboard') {
27
+ Object.values(config.visualizations).forEach(visualization => {
28
+ updateAxisColors(visualization)
29
+ })
30
+ }
31
+ }
32
+
33
+ export const updateStatePickedToStatesPicked = config => {
34
+ if (config.type === 'map') {
35
+ if (config.general?.statePicked) {
36
+ config.general.statesPicked = [{ ...config.general.statePicked }]
37
+ delete config.general.statePicked
38
+ }
39
+ // Also migrate the property name for filter controls
40
+ if (config.general?.filterControlsStatePicked) {
41
+ config.general.filterControlsStatesPicked = config.general.filterControlsStatePicked
42
+ delete config.general.filterControlsStatePicked
43
+ }
44
+ }
45
+ if (config.type === 'dashboard') {
46
+ Object.values(config.visualizations).forEach(visualization => {
47
+ updateStatePickedToStatesPicked(visualization)
48
+ })
49
+ }
50
+ }
51
+
52
+ const update_4_25_8 = config => {
53
+ const ver = '4.25.8'
54
+ const newConfig = _.cloneDeep(config)
55
+ updateAxisColors(newConfig)
56
+ updateStatePickedToStatesPicked(newConfig)
57
+ newConfig.version = ver
58
+ return newConfig
59
+ }
60
+
61
+ export default update_4_25_8
@@ -0,0 +1,86 @@
1
+ import { updateStatePickedToStatesPicked } from '../4.25.8'
2
+ import { coveUpdateWorker } from '../../coveUpdateWorker'
3
+ import { expect, describe, it } from 'vitest'
4
+
5
+ describe('4.25.8 update worker', () => {
6
+ describe('updateStatePickedToStatesPicked', () => {
7
+ it('converts statePicked to statesPicked for map config', () => {
8
+ const mockConfig = {
9
+ type: 'map',
10
+ general: {
11
+ statePicked: { fipsCode: '12', stateName: 'Florida' }
12
+ }
13
+ } as any
14
+
15
+ updateStatePickedToStatesPicked(mockConfig)
16
+
17
+ expect(mockConfig.general.statePicked).toBeUndefined()
18
+ expect(mockConfig.general.statesPicked).toEqual([{ fipsCode: '12', stateName: 'Florida' }])
19
+ })
20
+
21
+ it('converts filterControlsStatePicked to filterControlsStatesPicked for map config', () => {
22
+ const mockConfig = {
23
+ type: 'map',
24
+ general: {
25
+ filterControlsStatePicked: 'State',
26
+ statePicked: { fipsCode: '12', stateName: 'Florida' }
27
+ }
28
+ } as any
29
+
30
+ updateStatePickedToStatesPicked(mockConfig)
31
+
32
+ expect(mockConfig.general.filterControlsStatePicked).toBeUndefined()
33
+ expect(mockConfig.general.filterControlsStatesPicked).toBe('State')
34
+ expect(mockConfig.general.statesPicked).toEqual([{ fipsCode: '12', stateName: 'Florida' }])
35
+ })
36
+
37
+ it('handles dashboard with map visualizations', () => {
38
+ const mockConfig = {
39
+ type: 'dashboard',
40
+ visualizations: {
41
+ map1: {
42
+ type: 'map',
43
+ general: {
44
+ filterControlsStatePicked: 'State',
45
+ statePicked: { fipsCode: '01', stateName: 'Alabama' }
46
+ }
47
+ }
48
+ }
49
+ } as any
50
+
51
+ updateStatePickedToStatesPicked(mockConfig)
52
+
53
+ const mapViz = mockConfig.visualizations.map1.general
54
+ expect(mapViz.filterControlsStatePicked).toBeUndefined()
55
+ expect(mapViz.filterControlsStatesPicked).toBe('State')
56
+ expect(mapViz.statePicked).toBeUndefined()
57
+ expect(mapViz.statesPicked).toEqual([{ fipsCode: '01', stateName: 'Alabama' }])
58
+ })
59
+
60
+ it('works with full update worker integration', () => {
61
+ const mockConfig = {
62
+ type: 'dashboard',
63
+ version: '4.24.9',
64
+ rows: [], // Add missing rows property
65
+ visualizations: {
66
+ map1: {
67
+ type: 'map',
68
+ general: {
69
+ filterControlsStatePicked: 'State',
70
+ statePicked: { fipsCode: '12', stateName: 'Florida' }
71
+ }
72
+ }
73
+ }
74
+ } as any
75
+
76
+ const updatedConfig = coveUpdateWorker(mockConfig)
77
+
78
+ expect(updatedConfig.version).toBe('4.25.8')
79
+ const mapViz = updatedConfig.visualizations.map1.general
80
+ expect(mapViz.filterControlsStatePicked).toBeUndefined()
81
+ expect(mapViz.filterControlsStatesPicked).toBe('State')
82
+ expect(mapViz.statePicked).toBeUndefined()
83
+ expect(mapViz.statesPicked).toEqual([{ fipsCode: '12', stateName: 'Florida' }])
84
+ })
85
+ })
86
+ })
@@ -12,3 +12,5 @@ export const isMobileHeightViewport = currentViewport => isBelowBreakpoint('sm',
12
12
  export const isMobileStateLabelViewport = currentViewport => isBelowBreakpoint('md', currentViewport)
13
13
 
14
14
  export const isMobileTerritoryViewport = currentViewport => isBelowBreakpoint('sm', currentViewport)
15
+
16
+ export const isMobileFontViewport = currentViewport => isBelowBreakpoint('sm', currentViewport)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdc/core",
3
- "version": "4.25.6",
3
+ "version": "4.25.8",
4
4
  "description": "Core components, styles, hooks, and helpers, for the CDC Open Visualization project",
5
5
  "moduleName": "CdcCore",
6
6
  "main": "dist/cdccore",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
- "dompurify": "^3.2.6",
24
+ "dompurify": "^3.2.4",
25
25
  "html2canvas": "^1.4.1",
26
26
  "json-edit-react": "^1.27.0",
27
27
  "prop-types": "^15.8.1",
@@ -29,13 +29,15 @@
29
29
  "react-select": "^5.3.1",
30
30
  "react-tooltip": "5.8.2-beta.3",
31
31
  "sass": "^1.89.2",
32
- "use-debounce": "^10.0.5"
32
+ "use-debounce": "^10.0.5",
33
+ "vega": "^6.1.0",
34
+ "vega-lite": "^6.1.0"
33
35
  },
34
36
  "peerDependencies": {
35
37
  "react": "^18.2.0",
36
38
  "react-dom": "^18.2.0"
37
39
  },
38
- "gitHead": "6097de1ff814001880d9ac64bd66becdc092d63c",
40
+ "gitHead": "e369994230b5e3facff224e1d89d5937528ac5a0",
39
41
  "devDependencies": {
40
42
  "sass": "^1.79.4"
41
43
  }
@@ -0,0 +1,8 @@
1
+ // Only frontend styles are applied in WCMS/TP
2
+ // This helps match those styles when viewing in the editor
3
+ .modal.cdc-cove-editor *:focus-visible,
4
+ .cdc-open-viz-module *:focus-visible {
5
+ outline: dashed 2px rgb(0, 122, 153) !important;
6
+ outline-offset: 3px !important;
7
+ border-radius: 6px !important;
8
+ }
@@ -14,9 +14,7 @@
14
14
 
15
15
  // links that appear above data tables
16
16
  .download-links {
17
- display: flex;
18
17
  justify-content: flex-end;
19
- width: 100%;
20
18
  line-height: 1;
21
19
  &.brush-active {
22
20
  margin-top: 2em;
@@ -193,8 +193,4 @@ section.footnotes {
193
193
  -webkit-appearance: none;
194
194
  -moz-appearance: none;
195
195
  cursor: pointer;
196
- &:focus-visible {
197
- outline: 2px dashed var(--colors-blue-vivid-60, #005ea2) !important;
198
- outline-offset: 2px;
199
- }
200
196
  }
@@ -93,10 +93,6 @@ div.single-filters {
93
93
  &:focus:not(:focus-visible) {
94
94
  outline: none !important;
95
95
  }
96
- &:focus-visible {
97
- outline: 2px dashed var(--colors-blue-vivid-60, #005ea2) !important;
98
- outline-offset: 3px;
99
- }
100
96
 
101
97
  &.tab--active {
102
98
  font-weight: 500;
@@ -0,0 +1,15 @@
1
+ export type ForecastingSeriesKey = {
2
+ dataKey: string
3
+ axis: 'Left'
4
+ tooltip: boolean
5
+ type: 'Forecasting'
6
+ confidenceIntervals: {
7
+ high: string
8
+ low: string
9
+ }[]
10
+ stageColumn: string
11
+ stages: {
12
+ key: string
13
+ color: string
14
+ }[]
15
+ }
package/types/Runtime.ts CHANGED
@@ -1,13 +1,7 @@
1
1
  import { Axis } from './Axis'
2
+ import { ForecastingSeriesKey } from './ForecastingSeriesKey'
2
3
  import { Series } from './Series'
3
4
 
4
- export type ForecastingSeriesKey = {
5
- stages: {
6
- key: string
7
- color: string
8
- }[]
9
- }
10
-
11
5
  export type Runtime = {
12
6
  barSeriesKeys?: string[]
13
7
  areaSeriesKeys: object[]
package/types/Series.ts CHANGED
@@ -5,4 +5,8 @@ export type Series = {
5
5
  type: string
6
6
  tooltip: boolean
7
7
  dynamicCategory?: string
8
+ confidenceIntervals?: {
9
+ high: string
10
+ low: string
11
+ }[]
8
12
  }[]
package/types/Table.ts CHANGED
@@ -23,6 +23,7 @@ export type Table = {
23
23
  pivot?: Pivot
24
24
  show?: boolean
25
25
  sharedFilterColumns?: string[] // added at runtime by Dashboard
26
+ showBottomCollapse?: boolean // if true, the table will have a button to collapse at bottom of the expanded table
26
27
  showDataTableLink?: boolean
27
28
  showDownloadImgButton?: boolean
28
29
  showDownloadLinkBelow?: boolean
package/helpers/events.js DELETED
@@ -1,14 +0,0 @@
1
- function subscribe(eventName, listener) {
2
- document.addEventListener(eventName, listener)
3
- }
4
-
5
- function unsubscribe(eventName, listener) {
6
- document.removeEventListener(eventName, listener)
7
- }
8
-
9
- function publish(eventName, data) {
10
- const event = new CustomEvent(eventName, { detail: data })
11
- document.dispatchEvent(event)
12
- }
13
-
14
- export { publish, subscribe, unsubscribe }