@cdc/core 4.24.7 → 4.24.9-1
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/LICENSE +201 -0
- package/assets/icon-gear-multi.svg +23 -0
- package/components/Alert/components/Alert.styles.css +15 -0
- package/components/Alert/components/Alert.tsx +39 -0
- package/components/Alert/index.tsx +3 -0
- package/components/DataTable/DataTable.tsx +106 -30
- package/components/DataTable/helpers/chartCellMatrix.tsx +3 -3
- package/components/DataTable/helpers/getChartCellValue.ts +1 -1
- package/components/DataTable/helpers/getDataSeriesColumns.ts +2 -2
- package/components/DataTable/helpers/mapCellMatrix.tsx +3 -3
- package/components/DataTable/types/TableConfig.ts +1 -1
- package/components/EditorPanel/Inputs.tsx +13 -4
- package/components/EditorPanel/VizFilterEditor/NestedDropdownEditor.tsx +268 -0
- package/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +161 -82
- package/components/EditorPanel/VizFilterEditor/components/FilterOrder.tsx +31 -45
- package/components/Filters.tsx +223 -180
- package/components/Layout/components/Responsive.tsx +14 -4
- package/components/Layout/components/Sidebar/components/Sidebar.tsx +14 -5
- package/components/Layout/components/Sidebar/components/sidebar.styles.scss +15 -16
- package/components/Layout/components/Visualization/index.tsx +7 -1
- package/components/Layout/components/Visualization/visualizations.scss +32 -26
- package/components/Layout/styles/editor.scss +0 -8
- package/components/Legend/Legend.Gradient.tsx +133 -0
- package/components/LegendShape.tsx +28 -0
- package/components/MultiSelect/MultiSelect.tsx +6 -3
- package/components/NestedDropdown/NestedDropdown.tsx +47 -52
- package/components/NestedDropdown/nesteddropdown.styles.css +19 -25
- package/components/Table/Table.tsx +8 -5
- package/components/Table/components/Cell.tsx +2 -2
- package/components/Table/components/Row.tsx +25 -7
- package/components/_stories/Layout.Debug.stories.tsx +91 -0
- package/components/_stories/_mocks/bar-chart-suppressed.json +474 -0
- package/components/_stories/styles.scss +13 -1
- package/components/createBarElement.jsx +4 -4
- package/components/ui/Icon.tsx +21 -14
- package/components/ui/Title/Title.scss +0 -8
- package/helpers/DataTransform.ts +2 -2
- package/helpers/addValuesToFilters.ts +95 -16
- package/helpers/cove/accessibility.ts +16 -4
- package/helpers/coveUpdateWorker.ts +24 -10
- package/helpers/filterVizData.ts +23 -4
- package/helpers/formatConfigBeforeSave.ts +22 -2
- package/helpers/gatherQueryParams.ts +12 -2
- package/helpers/getGradientLegendWidth.ts +15 -0
- package/helpers/getTextWidth.ts +18 -0
- package/helpers/scaling.ts +7 -0
- package/helpers/tests/addValuesToFilters.test.ts +55 -0
- package/helpers/tests/filterVizData.test.ts +31 -0
- package/helpers/tests/gatherQueryParams.test.ts +22 -0
- package/helpers/tests/invertValue.test.ts +35 -0
- package/helpers/updatePaletteNames.ts +19 -0
- package/helpers/{useDataVizClasses.js → useDataVizClasses.ts} +3 -2
- package/helpers/ver/4.24.5.ts +3 -3
- package/helpers/ver/4.24.7.ts +34 -3
- package/helpers/ver/4.24.9.ts +63 -0
- package/helpers/ver/tests/4.24.9.test.ts +22 -0
- package/helpers/ver/versionNeedsUpdate.ts +9 -0
- package/package.json +3 -3
- package/styles/_button-section.scss +1 -1
- package/styles/_global.scss +6 -2
- package/styles/filters.scss +4 -0
- package/types/Axis.ts +3 -0
- package/types/Dimensions.ts +1 -0
- package/types/General.ts +1 -1
- package/types/VizFilter.ts +24 -3
- package/components/LegendCircle.jsx +0 -17
- package/helpers/updatePaletteNames.js +0 -16
- /package/components/{Waiting.jsx → Waiting.tsx} +0 -0
- /package/helpers/ver/{4.23.4.ts → 4.24.4.ts} +0 -0
package/helpers/ver/4.24.7.ts
CHANGED
|
@@ -2,6 +2,7 @@ import _ from 'lodash'
|
|
|
2
2
|
import { DashboardFilters } from '@cdc/dashboard/src/types/DashboardFilters'
|
|
3
3
|
import { MultiDashboardConfig } from '@cdc/dashboard/src/types/MultiDashboard'
|
|
4
4
|
import { AnyVisualization } from '../../types/Visualization'
|
|
5
|
+
import versionNeedsUpdate from './versionNeedsUpdate'
|
|
5
6
|
|
|
6
7
|
export const dashboardFiltersMigrate = config => {
|
|
7
8
|
if (!config.dashboard) return config
|
|
@@ -34,8 +35,20 @@ export const dashboardFiltersMigrate = config => {
|
|
|
34
35
|
delete viz.hide
|
|
35
36
|
}
|
|
36
37
|
// 'filter-dropdowns' was renamed to 'dashboardFilters' for clarity
|
|
37
|
-
if (viz.type === 'filter-dropdowns')
|
|
38
|
-
|
|
38
|
+
if (viz.type === 'filter-dropdowns') {
|
|
39
|
+
viz.type = 'dashboardFilters'
|
|
40
|
+
viz.visualizationType = 'dashboardFilters'
|
|
41
|
+
if (!viz.sharedFilterIndexes) {
|
|
42
|
+
viz.sharedFilterIndexes = config.dashboard.sharedFilters.map((_sf, i) => i)
|
|
43
|
+
viz.filterBehavior = config.filterBehavior || 'Filter Change'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Premature convertion to 4.24.7 made us add this fix
|
|
48
|
+
if (viz.type === 'dashboardFilters' && !viz.sharedFilterIndexes) {
|
|
49
|
+
viz.sharedFilterIndexes = config.dashboard.sharedFilters.map((_sf, i) => i)
|
|
50
|
+
viz.filterBehavior = config.filterBehavior || 'Filter Change'
|
|
51
|
+
}
|
|
39
52
|
newVisualizations[vizKey] = viz
|
|
40
53
|
})
|
|
41
54
|
|
|
@@ -57,10 +70,21 @@ export const dashboardFiltersMigrate = config => {
|
|
|
57
70
|
]
|
|
58
71
|
}
|
|
59
72
|
config.rows = [newRow, ...config.rows]
|
|
73
|
+
config.dashboard.sharedFilters = config.dashboard.sharedFilters.map(sf => {
|
|
74
|
+
if (sf.usedBy) {
|
|
75
|
+
// Fixes usedBy Rows
|
|
76
|
+
sf.usedBy = sf.usedBy.map(key => {
|
|
77
|
+
if (!(parseInt(key) > -1)) return key
|
|
78
|
+
return String(parseInt(key) + 1)
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
return sf
|
|
82
|
+
})
|
|
60
83
|
}
|
|
61
84
|
// if there's no dashboardFilters visualization but there are sharedFilters create a visualization and update rows.
|
|
62
85
|
|
|
63
86
|
config.visualizations = newVisualizations
|
|
87
|
+
delete config.filterBehavior // deprecated
|
|
64
88
|
}
|
|
65
89
|
|
|
66
90
|
const mapUpdates = newConfig => {
|
|
@@ -79,6 +103,12 @@ const mapUpdates = newConfig => {
|
|
|
79
103
|
return newConfig
|
|
80
104
|
}
|
|
81
105
|
|
|
106
|
+
const updateLogarithmicConfig = newConfig => {
|
|
107
|
+
if (newConfig.useLogScale) {
|
|
108
|
+
newConfig.yAxis.type === 'logarithmic'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
82
112
|
const update_4_24_7 = config => {
|
|
83
113
|
const ver = '4.24.7'
|
|
84
114
|
|
|
@@ -86,7 +116,8 @@ const update_4_24_7 = config => {
|
|
|
86
116
|
|
|
87
117
|
mapUpdates(newConfig)
|
|
88
118
|
dashboardFiltersMigrate(newConfig)
|
|
89
|
-
newConfig
|
|
119
|
+
updateLogarithmicConfig(newConfig)
|
|
120
|
+
newConfig.version = versionNeedsUpdate(config.version, ver) ? ver : config.version
|
|
90
121
|
return newConfig
|
|
91
122
|
}
|
|
92
123
|
export default update_4_24_7
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Legend } from './../../types/Legend'
|
|
2
|
+
import _ from 'lodash'
|
|
3
|
+
import { AnyVisualization } from '../../types/Visualization'
|
|
4
|
+
import { VizFilter } from '../../types/VizFilter'
|
|
5
|
+
import { AnyVisualization } from '../../types/Visualization'
|
|
6
|
+
import { VizFilter } from '../../types/VizFilter'
|
|
7
|
+
import versionNeedsUpdate from './versionNeedsUpdate'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Updates the configuration object to disable map zooming for single state maps in a dashboard.
|
|
11
|
+
* when the config is below version 4.24.9
|
|
12
|
+
*/
|
|
13
|
+
const patchSingleStateZoom = config => {
|
|
14
|
+
if (config.type === 'dashboard') {
|
|
15
|
+
Object.values(config?.visualizations || {}).forEach((viz: AnyVisualization) => {
|
|
16
|
+
if (viz.type === 'map' && viz.general?.geoType === 'single-state') {
|
|
17
|
+
// if the version is less that 4.24.7 then allowMapZoom should be false
|
|
18
|
+
let allowZoom = versionNeedsUpdate(config.version, '4.24.9') ? false : viz.general.allowMapZoom
|
|
19
|
+
viz.general.allowMapZoom = allowZoom
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
if (config.type === 'map' && config.general?.geoType === 'single-state') {
|
|
24
|
+
// if the version is less that 4.24.7 then allowMapZoom should be false
|
|
25
|
+
let allowZoom = versionNeedsUpdate(config.version, '4.24.9') ? false : config.general.allowMapZoom
|
|
26
|
+
config.general.allowMapZoom = allowZoom
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const doesNotHaveIds = (filters: VizFilter[]) => filters?.some(f => !f.id)
|
|
31
|
+
|
|
32
|
+
export const addIdsToVisFilters = config => {
|
|
33
|
+
if (config.type === 'dashboard') {
|
|
34
|
+
config.visualizations = Object.keys(config.visualizations).reduce((acc, curr) => {
|
|
35
|
+
const viz: AnyVisualization & { filters: VizFilter[] } = config.visualizations[curr]
|
|
36
|
+
if (viz.filters?.length && doesNotHaveIds(viz.filters)) {
|
|
37
|
+
acc[curr].filters = viz.filters.map((filter, i) => ({ ...filter, id: Date.now() + i }))
|
|
38
|
+
}
|
|
39
|
+
return acc
|
|
40
|
+
}, config.visualizations)
|
|
41
|
+
} else if (config.filters?.length && doesNotHaveIds(config.filters)) {
|
|
42
|
+
config.filters = config.filters.map((filter, i) => ({ ...filter, id: Date.now() + i }))
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const supportLineStyledLegend = newConfig => {
|
|
47
|
+
// support for Charts
|
|
48
|
+
if (newConfig.legend?.lineMode) {
|
|
49
|
+
newConfig.legend.style = 'lines'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const update_4_24_9 = config => {
|
|
54
|
+
const ver = '4.24.9'
|
|
55
|
+
const newConfig = _.cloneDeep(config)
|
|
56
|
+
patchSingleStateZoom(newConfig)
|
|
57
|
+
addIdsToVisFilters(newConfig)
|
|
58
|
+
supportLineStyledLegend(config)
|
|
59
|
+
newConfig.version = ver
|
|
60
|
+
return newConfig
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default update_4_24_9
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { addIdsToVisFilters } from '../4.24.9'
|
|
2
|
+
import { coveUpdateWorker } from '../../coveUpdateWorker'
|
|
3
|
+
import { expect, describe, it } from 'vitest'
|
|
4
|
+
|
|
5
|
+
describe('addIdsToVisFilters', () => {
|
|
6
|
+
it('adds ids to vis filters on dashboards', () => {
|
|
7
|
+
const mockConfig = { type: 'dashboard', visualizations: { a: { filters: [{}] } } } as any
|
|
8
|
+
addIdsToVisFilters(mockConfig)
|
|
9
|
+
expect(mockConfig.visualizations.a.filters[0].id).toBeDefined()
|
|
10
|
+
})
|
|
11
|
+
it('adds ids to vis filters on non dashboards', () => {
|
|
12
|
+
const mockConfig = { filters: [{}] } as any
|
|
13
|
+
addIdsToVisFilters(mockConfig)
|
|
14
|
+
expect(mockConfig.filters[0].id).toBeDefined()
|
|
15
|
+
})
|
|
16
|
+
it('adds ids to nested multi-dashboards', () => {
|
|
17
|
+
const mockConfig = { type: 'dashboard', rows: [], visualizations: { a: { filters: [{}] } }, multiDashboards: [{ rows: [], visualizations: { a: { filters: [{}] } } }] }
|
|
18
|
+
const convertedConfig = coveUpdateWorker(mockConfig)
|
|
19
|
+
expect(convertedConfig.visualizations.a.filters[0].id).toBeDefined()
|
|
20
|
+
expect(convertedConfig.multiDashboards[0].visualizations.a.filters[0].id).toBeDefined()
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default function versionNeedsUpdate(previousVersion: string, currentVersion: string): boolean {
|
|
2
|
+
if (!previousVersion) return true
|
|
3
|
+
const [prevMajor, prevMinor, prevPatch] = previousVersion.split('.').map(Number)
|
|
4
|
+
const [currMajor, currMinor, currPatch] = currentVersion.split('.').map(Number)
|
|
5
|
+
if (currMajor > prevMajor) return true
|
|
6
|
+
if (currMajor === prevMajor && currMinor > prevMinor) return true
|
|
7
|
+
if (currMajor === prevMajor && currMinor === prevMinor && currPatch > prevPatch) return true
|
|
8
|
+
return false
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/core",
|
|
3
|
-
"version": "4.24.
|
|
3
|
+
"version": "4.24.9-1",
|
|
4
4
|
"description": "Core components, styles, hooks, and helpers, for the CDC Open Visualization project",
|
|
5
5
|
"moduleName": "CdcCore",
|
|
6
6
|
"main": "dist/cdccore",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "vitest run --reporter verbose",
|
|
8
|
+
"test": "vitest run --environment jsdom --reporter verbose",
|
|
9
9
|
"test-watch": "vitest watch --reporter verbose",
|
|
10
10
|
"test-watch:ui": "vitest --ui"
|
|
11
11
|
},
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"react": "^18.2.0",
|
|
34
34
|
"react-dom": "^18.2.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "4a77c2fa79c8fa6074da3b6dfee3d8e32f0b2586"
|
|
37
37
|
}
|
package/styles/_global.scss
CHANGED
|
@@ -181,7 +181,11 @@ select {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
section.introText {
|
|
184
|
-
|
|
184
|
+
width: 100%;
|
|
185
|
+
margin-bottom: 25px;
|
|
186
|
+
&.legend_visible_top {
|
|
187
|
+
margin-bottom: 0;
|
|
188
|
+
}
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
section.footnotes {
|
|
@@ -191,7 +195,7 @@ section.footnotes {
|
|
|
191
195
|
}
|
|
192
196
|
|
|
193
197
|
.cdc-chart-inner-container .subtext {
|
|
194
|
-
padding: 15px;
|
|
198
|
+
padding: 15px 0;
|
|
195
199
|
}
|
|
196
200
|
|
|
197
201
|
.margin-left-href {
|
package/styles/filters.scss
CHANGED
package/types/Axis.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type Anchor = {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export type Axis = {
|
|
8
|
+
categories: [{ label: string; height: string; color: string }]
|
|
8
9
|
scalePadding: number
|
|
9
10
|
anchors?: Anchor[]
|
|
10
11
|
dataKey: string
|
|
@@ -43,4 +44,6 @@ export type Axis = {
|
|
|
43
44
|
tickRotation?: number
|
|
44
45
|
tickWidthMax?: number
|
|
45
46
|
type: string
|
|
47
|
+
axisBBox: number
|
|
48
|
+
maxValue: string
|
|
46
49
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DimensionsType = [number, number]
|
package/types/General.ts
CHANGED
package/types/VizFilter.ts
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
+
export type OrderBy = 'asc' | 'desc' | 'cust'
|
|
2
|
+
|
|
1
3
|
export type FilterBase = {
|
|
2
4
|
columnName: string
|
|
3
5
|
values: string[]
|
|
4
6
|
showDropdown: boolean
|
|
7
|
+
id: number
|
|
8
|
+
parents: number[]
|
|
5
9
|
}
|
|
6
10
|
|
|
11
|
+
export type VizFilterStyle =
|
|
12
|
+
| 'tab'
|
|
13
|
+
| 'pill'
|
|
14
|
+
| 'tab bar'
|
|
15
|
+
| 'dropdown'
|
|
16
|
+
| 'dropdown bar'
|
|
17
|
+
| 'multi-select'
|
|
18
|
+
| 'nested-dropdown'
|
|
7
19
|
export type GeneralFilter = FilterBase & {
|
|
8
20
|
active: string
|
|
9
21
|
queuedActive: string
|
|
10
|
-
filterStyle:
|
|
22
|
+
filterStyle: VizFilterStyle
|
|
11
23
|
label: string
|
|
12
|
-
order:
|
|
13
|
-
orderedValues?: string[]
|
|
24
|
+
order: OrderBy
|
|
25
|
+
orderedValues?: string[] // should only exist if the order is 'cust'
|
|
14
26
|
queryParameter: string
|
|
15
27
|
setByQueryParameter: string
|
|
28
|
+
subGrouping: SubGrouping
|
|
16
29
|
type: 'url'
|
|
17
30
|
}
|
|
18
31
|
|
|
@@ -21,4 +34,12 @@ export type MultiSelectFilter = {
|
|
|
21
34
|
selectLimit: number
|
|
22
35
|
} & Omit<GeneralFilter, 'active'>
|
|
23
36
|
|
|
37
|
+
export type SubGrouping = {
|
|
38
|
+
active: string
|
|
39
|
+
columnName: string
|
|
40
|
+
setByQueryParameter: string
|
|
41
|
+
order?: OrderBy
|
|
42
|
+
valuesLookup: Record<string, { orderedValues?: string[]; values: string[] }>
|
|
43
|
+
}
|
|
44
|
+
|
|
24
45
|
export type VizFilter = GeneralFilter | MultiSelectFilter
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
export default function LegendCircle({ fill, borderColor, display = 'inline-block', viewport }) {
|
|
4
|
-
const dimensions = ['sm', 'xs', 'xxs'].includes(viewport) ? { width: '0.7em', height: '0.7em' } : { width: '1em', height: '1em' }
|
|
5
|
-
const styles = {
|
|
6
|
-
marginRight: '5px',
|
|
7
|
-
borderRadius: '300px',
|
|
8
|
-
verticalAlign: 'middle',
|
|
9
|
-
display: display,
|
|
10
|
-
height: dimensions.height || '1em',
|
|
11
|
-
width: dimensions.width || '1em',
|
|
12
|
-
border: borderColor ? `${borderColor} 1px solid` : 'rgba(0,0,0,.3) 1px solid',
|
|
13
|
-
backgroundColor: fill
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return <span className='legend-item' style={styles} />
|
|
17
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function updatePaletteNames(colorPalettes) {
|
|
2
|
-
// this function adds REVERSE keyword to each palette
|
|
3
|
-
delete colorPalettes.qualitative9 // delete palette before reversing
|
|
4
|
-
let palettereversed = {}
|
|
5
|
-
for (const [paletteName, hexCodeArr] of Object.entries(colorPalettes)) {
|
|
6
|
-
const paletteStr = String(paletteName)
|
|
7
|
-
|
|
8
|
-
if (!paletteStr.endsWith('reverse')) {
|
|
9
|
-
let palette = paletteStr.concat('reverse') // add to the end of the string "reverse"
|
|
10
|
-
palettereversed[palette] = [...hexCodeArr].reverse() // reverses arrays elements and create new keys on object
|
|
11
|
-
} else {
|
|
12
|
-
palettereversed = { ...colorPalettes }
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return { ...palettereversed, ...colorPalettes }
|
|
16
|
-
}
|
|
File without changes
|
|
File without changes
|