@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.
- package/components/DataTable/DataTable.tsx +52 -19
- package/components/DataTable/DataTableStandAlone.tsx +4 -1
- package/components/DataTable/components/ChartHeader.tsx +44 -13
- package/components/DataTable/components/ExpandCollapse.tsx +14 -2
- package/components/DataTable/components/MapHeader.tsx +18 -1
- package/components/DataTable/components/SortIcon/sort-icon.css +21 -27
- package/components/DataTable/data-table.css +33 -4
- package/components/DataTable/helpers/customSort.ts +4 -2
- package/components/DownloadButton.tsx +4 -1
- package/components/EditorPanel/DataTableEditor.tsx +10 -1
- package/components/Filters/Filters.tsx +26 -9
- package/components/Footnotes/FootnotesStandAlone.tsx +2 -1
- package/components/{MediaControls.jsx → MediaControls.tsx} +32 -16
- package/components/Table/components/Row.tsx +15 -12
- package/dist/cove-main.css +0 -10
- package/dist/cove-main.css.map +1 -1
- package/helpers/cove/number.ts +6 -2
- package/helpers/coveUpdateWorker.ts +5 -1
- package/helpers/events.ts +32 -0
- package/helpers/isRightAlignedTableValue.js +1 -1
- package/helpers/metrics/helpers.ts +52 -0
- package/helpers/metrics/types.ts +43 -0
- package/helpers/vegaConfig.ts +647 -0
- package/helpers/ver/4.25.7.ts +26 -0
- package/helpers/ver/4.25.8.ts +61 -0
- package/helpers/ver/tests/4.25.8.test.ts +86 -0
- package/helpers/viewports.ts +2 -0
- package/package.json +6 -4
- package/styles/_accessibility.scss +8 -0
- package/styles/_button-section.scss +0 -2
- package/styles/_global.scss +0 -4
- package/styles/filters.scss +0 -4
- package/types/ForecastingSeriesKey.ts +15 -0
- package/types/Runtime.ts +1 -7
- package/types/Series.ts +4 -0
- package/types/Table.ts +1 -0
- 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
|
+
})
|
package/helpers/viewports.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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": "
|
|
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
|
+
}
|
package/styles/_global.scss
CHANGED
package/styles/filters.scss
CHANGED
|
@@ -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;
|
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
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 }
|