@cdc/core 4.25.7 → 4.25.10
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/AdvancedEditor/AdvancedEditor.tsx +29 -8
- package/components/DataTable/DataTable.tsx +63 -11
- package/components/DataTable/DataTableStandAlone.tsx +4 -1
- package/components/DataTable/components/ChartHeader.tsx +58 -9
- package/components/DataTable/components/ExpandCollapse.tsx +21 -1
- package/components/DataTable/components/MapHeader.tsx +35 -7
- package/components/DataTable/data-table.css +6 -0
- package/components/DataTable/helpers/chartCellMatrix.tsx +11 -8
- package/components/DataTable/helpers/mapCellMatrix.tsx +19 -1
- package/components/DownloadButton.tsx +42 -13
- package/components/EditorPanel/DataTableEditor.tsx +10 -1
- package/components/EditorPanel/components/MarkupHighlightedTextField.tsx +227 -0
- package/components/EditorPanel/components/MarkupVariablesEditor.tsx +411 -0
- package/components/EditorPanel/components/PanelMarkup.tsx +59 -0
- package/components/ErrorBoundary.jsx +3 -1
- package/components/Filters/Filters.tsx +35 -11
- package/components/Filters/components/Tabs.tsx +1 -0
- package/components/Footnotes/FootnotesStandAlone.tsx +2 -1
- package/components/Legend/Legend.Gradient.tsx +3 -6
- package/components/LegendShape.tsx +121 -3
- package/components/{MediaControls.jsx → MediaControls.tsx} +80 -16
- package/components/PaletteConversionModal.tsx +87 -0
- package/components/PaletteSelector/DeveloperPaletteRollback.tsx +114 -0
- package/components/PaletteSelector/PaletteSelector.css +51 -0
- package/components/PaletteSelector/PaletteSelector.tsx +112 -0
- package/components/PaletteSelector/index.ts +2 -0
- package/components/RichTooltip/RichTooltip.tsx +1 -0
- package/components/Table/Table.tsx +3 -1
- package/components/_stories/BlurStrokeTest.stories.tsx +1 -1
- package/components/_stories/DataTable.stories.tsx +1 -1
- package/components/_stories/Filters.stories.tsx +1 -1
- package/components/_stories/Footnotes.stories.tsx +1 -1
- package/components/_stories/Inputs.stories.tsx +1 -1
- package/components/_stories/MultiSelect.stories.tsx +3 -3
- package/components/_stories/NestedDropdown.stories.tsx +1 -1
- package/components/_stories/Table.stories.tsx +1 -1
- package/components/elements/_stories/Button.stories.tsx +1 -1
- package/components/elements/_stories/Card.stories.tsx +1 -1
- package/components/inputs/InputToggle.tsx +2 -0
- package/components/managers/DataDesigner.tsx +10 -9
- package/components/managers/_stories/DataDesigner.stories.tsx +1 -1
- package/components/ui/Tooltip.tsx +2 -1
- package/components/ui/_stories/Accordion.stories.tsx +1 -1
- package/components/ui/_stories/ColorPaletteMigration.stories.mdx +275 -0
- package/components/ui/_stories/Colors.stories.tsx +330 -0
- package/components/ui/_stories/IconGallery.stories.tsx +316 -0
- package/components/ui/_stories/Title.stories.tsx +1 -1
- package/contexts/EditorContext.ts +18 -0
- package/contexts/editor.actions.ts +28 -0
- package/contexts/editor.reducer.ts +94 -0
- package/data/chartColorPalettes.ts +118 -0
- package/data/colorPalettes.ts +9 -0
- package/data/mapColorPalettes.ts +45 -0
- package/data/sharedPalettes.ts +50 -0
- package/dist/cove-main.css +14 -13
- package/dist/cove-main.css.map +1 -1
- package/generateViteConfig.js +80 -0
- package/helpers/addValuesToFilters.ts +2 -3
- package/helpers/cloneConfig.ts +31 -0
- package/helpers/configDataHelpers.ts +128 -0
- package/helpers/configHelpers.ts +27 -0
- package/helpers/constants.ts +5 -2
- package/helpers/cove/number.ts +6 -2
- package/helpers/coveUpdateWorker.ts +15 -3
- package/helpers/events.ts +32 -0
- package/helpers/filterColorPalettes.ts +152 -0
- package/helpers/generateColorsArray.ts +13 -0
- package/helpers/getColorPaletteVersion.ts +33 -0
- package/helpers/getPaletteAccessor.ts +18 -0
- package/helpers/markupProcessor.ts +205 -0
- package/helpers/metrics/helpers.ts +75 -0
- package/helpers/metrics/types.ts +82 -0
- package/helpers/metrics/utils.ts +34 -0
- package/helpers/palettes/colorDistributions.ts +56 -0
- package/helpers/palettes/migratePaletteName.ts +150 -0
- package/helpers/palettes/standardizePaletteNames.ts +77 -0
- package/helpers/palettes/utils.ts +267 -0
- package/helpers/queryStringUtils.ts +13 -0
- package/helpers/testing.ts +345 -0
- package/helpers/tests/addValuesToFilters.test.ts +1 -2
- package/helpers/tests/generateColorsArray.test.ts +24 -0
- package/helpers/tests/markupProcessor.test.ts +538 -0
- package/helpers/tests/testStandaloneBuild.ts +44 -0
- package/helpers/useMarkupVariables.ts +31 -0
- package/helpers/vegaConfig.ts +0 -1
- package/helpers/ver/4.24.10.ts +2 -1
- package/helpers/ver/4.24.11.ts +2 -1
- package/helpers/ver/4.24.3.ts +2 -1
- package/helpers/ver/4.24.4.ts +2 -1
- package/helpers/ver/4.24.5.ts +2 -1
- package/helpers/ver/4.24.7.ts +2 -1
- package/helpers/ver/4.24.9.ts +2 -1
- package/helpers/ver/4.25.1.ts +2 -1
- package/helpers/ver/4.25.10.ts +36 -0
- package/helpers/ver/4.25.3.ts +2 -1
- package/helpers/ver/4.25.4.ts +2 -1
- package/helpers/ver/4.25.6.ts +2 -1
- package/helpers/ver/4.25.7.ts +2 -1
- package/helpers/ver/4.25.8.ts +62 -0
- package/helpers/ver/4.25.9.ts +293 -0
- package/helpers/ver/tests/4.25.10.test.ts +204 -0
- package/helpers/ver/tests/4.25.8.test.ts +86 -0
- package/helpers/ver/tests/4.25.9.test.ts +51 -0
- package/helpers/viewports.ts +2 -0
- package/hooks/useColorPalette.ts +79 -0
- package/package.json +12 -4
- package/styles/_button-section.scss +0 -2
- package/styles/_global.scss +7 -5
- package/styles/base.scss +8 -5
- package/styles/v2/components/button.scss +4 -3
- package/styles/v2/components/editor.scss +2 -1
- package/styles/v2/layout/_data-table.scss +3 -2
- package/styles/v2/themes/_color-definitions.scss +18 -17
- package/testBuild.js +0 -0
- package/testing-setup.js +32 -0
- package/types/ForecastingSeriesKey.ts +0 -1
- package/types/MarkupInclude.ts +6 -1
- package/types/MarkupVariable.ts +19 -0
- package/types/Series.ts +4 -0
- package/types/Table.ts +1 -0
- package/types/VizFilter.ts +1 -0
- package/vitest.config.ts +16 -0
- package/components/ui/_stories/Colors.stories.mdx +0 -220
- package/components/ui/_stories/IconGallery.stories.mdx +0 -14
- package/data/colorPalettes.js +0 -171
- package/helpers/events.js +0 -14
- package/helpers/formatConfigBeforeSave.ts +0 -135
- package/helpers/tests/formatConfigBeforeSave.test.ts +0 -68
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import Footnotes from '@cdc/core/types/Footnotes'
|
|
2
|
-
import { AnyVisualization, Visualization } from '@cdc/core/types/Visualization'
|
|
3
|
-
import { DashboardConfig } from '@cdc/dashboard/src/types/DashboardConfig'
|
|
4
|
-
import { removeDashboardFilter } from '@cdc/dashboard/src/helpers/removeDashboardFilter'
|
|
5
|
-
import _ from 'lodash'
|
|
6
|
-
|
|
7
|
-
const cleanDashboardFootnotes = (config: DashboardConfig) => {
|
|
8
|
-
if (config.visualizations) {
|
|
9
|
-
Object.keys(config.visualizations).forEach(vizKey => {
|
|
10
|
-
const viz: Visualization = config.visualizations[vizKey]
|
|
11
|
-
if (viz.footnotes) {
|
|
12
|
-
delete config.visualizations[vizKey].footnotes.data
|
|
13
|
-
delete config.visualizations[vizKey].footnotes.formattedData
|
|
14
|
-
}
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const cleanDashboardData = (config: DashboardConfig) => {
|
|
20
|
-
if (config.datasets) {
|
|
21
|
-
Object.keys(config.datasets).forEach(datasetKey => {
|
|
22
|
-
delete config.datasets[datasetKey].formattedData
|
|
23
|
-
if (config.datasets[datasetKey].dataUrl) {
|
|
24
|
-
delete config.datasets[datasetKey].data
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
if (config.visualizations) {
|
|
29
|
-
Object.keys(config.visualizations).forEach(vizKey => {
|
|
30
|
-
config.visualizations[vizKey] = _.omit(config.visualizations[vizKey], [
|
|
31
|
-
'runtime',
|
|
32
|
-
'formattedData',
|
|
33
|
-
'data',
|
|
34
|
-
'editing',
|
|
35
|
-
'originalFormattedData'
|
|
36
|
-
])
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
if (config.rows) {
|
|
40
|
-
config.rows.forEach((row, i) => {
|
|
41
|
-
if (row.dataKey) {
|
|
42
|
-
config.rows[i] = _.omit(row, ['data', 'formattedData'])
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const cleanSharedFilters = (config: DashboardConfig) => {
|
|
49
|
-
if (config.dashboard?.sharedFilters) {
|
|
50
|
-
const recursiveRemoveFilters = (sharedFilters, visualizations: Record<string, AnyVisualization>) => {
|
|
51
|
-
const usedFilters = _.uniq(
|
|
52
|
-
Object.values(visualizations).reduce((acc, viz) => {
|
|
53
|
-
if (viz.type === 'dashboardFilters') {
|
|
54
|
-
acc = acc.concat(viz.sharedFilterIndexes)
|
|
55
|
-
}
|
|
56
|
-
return acc
|
|
57
|
-
}, [])
|
|
58
|
-
)
|
|
59
|
-
for (let index = 0; index < sharedFilters.length; index++) {
|
|
60
|
-
const filter = sharedFilters[index]
|
|
61
|
-
if (!usedFilters.includes(index)) {
|
|
62
|
-
const [newSharedFilters, newVisualizations] = removeDashboardFilter(
|
|
63
|
-
index,
|
|
64
|
-
config.dashboard.sharedFilters,
|
|
65
|
-
config.visualizations
|
|
66
|
-
)
|
|
67
|
-
config.dashboard.sharedFilters = newSharedFilters
|
|
68
|
-
config.visualizations = newVisualizations
|
|
69
|
-
recursiveRemoveFilters(newSharedFilters, newVisualizations)
|
|
70
|
-
break
|
|
71
|
-
} else {
|
|
72
|
-
delete config.dashboard.sharedFilters[index].active
|
|
73
|
-
if (filter.subGrouping) delete config.dashboard.sharedFilters[index].subGrouping.active
|
|
74
|
-
if (filter.type === 'urlfilter') {
|
|
75
|
-
delete config.dashboard.sharedFilters[index].values
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
recursiveRemoveFilters(config.dashboard.sharedFilters, config.visualizations)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const cleanVisualizationFilters = (config: DashboardConfig) => {
|
|
86
|
-
if (config.visualizations) {
|
|
87
|
-
Object.keys(config.visualizations).forEach(vizKey => {
|
|
88
|
-
const vizFilters = config.visualizations[vizKey].filters || []
|
|
89
|
-
vizFilters.forEach((_filter, index) => {
|
|
90
|
-
delete config.visualizations[vizKey].filters[index].active
|
|
91
|
-
delete config.visualizations[vizKey].filters[index].values
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const removeRuntimeDataURLs = (config: DashboardConfig) => {
|
|
98
|
-
if (config.datasets) {
|
|
99
|
-
Object.keys(config.datasets).forEach(datasetKey => {
|
|
100
|
-
delete config.datasets[datasetKey].runtimeDataUrl
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export const formatConfigBeforeSave = configToStrip => {
|
|
106
|
-
const strippedConfig = _.cloneDeep(configToStrip)
|
|
107
|
-
if (strippedConfig.type === 'dashboard') {
|
|
108
|
-
if (strippedConfig.multiDashboards) {
|
|
109
|
-
strippedConfig.multiDashboards.forEach((multiDashboard, i) => {
|
|
110
|
-
cleanDashboardData(strippedConfig.multiDashboards[i])
|
|
111
|
-
cleanSharedFilters(strippedConfig.multiDashboards[i])
|
|
112
|
-
cleanDashboardFootnotes(strippedConfig.multiDashboards[i])
|
|
113
|
-
cleanVisualizationFilters(strippedConfig.multiDashboards[i])
|
|
114
|
-
})
|
|
115
|
-
delete strippedConfig.dashboard
|
|
116
|
-
delete strippedConfig.rows
|
|
117
|
-
delete strippedConfig.visualizations
|
|
118
|
-
delete strippedConfig.label
|
|
119
|
-
}
|
|
120
|
-
delete strippedConfig.activeDashboard
|
|
121
|
-
cleanDashboardData(strippedConfig)
|
|
122
|
-
cleanSharedFilters(strippedConfig)
|
|
123
|
-
cleanDashboardFootnotes(strippedConfig)
|
|
124
|
-
cleanVisualizationFilters(strippedConfig)
|
|
125
|
-
removeRuntimeDataURLs(strippedConfig)
|
|
126
|
-
} else {
|
|
127
|
-
delete strippedConfig.runtime
|
|
128
|
-
delete strippedConfig.formattedData
|
|
129
|
-
if (strippedConfig.dataUrl) {
|
|
130
|
-
delete strippedConfig.data
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return strippedConfig
|
|
135
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { cleanSharedFilters } from '../formatConfigBeforeSave'
|
|
3
|
-
import { DashboardConfig } from '@cdc/dashboard/src/types/DashboardConfig'
|
|
4
|
-
|
|
5
|
-
describe('cleanSharedFilters', () => {
|
|
6
|
-
it('should remove unused shared filters', () => {
|
|
7
|
-
const config: DashboardConfig = {
|
|
8
|
-
dashboard: {
|
|
9
|
-
sharedFilters: [
|
|
10
|
-
{ id: 1, type: 'filter1' },
|
|
11
|
-
{ id: 2, type: 'filter2' },
|
|
12
|
-
{ id: 3, type: 'filter3' },
|
|
13
|
-
{ id: 4, type: 'filter4' }
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
visualizations: {
|
|
17
|
-
viz1: { type: 'dashboardFilters', sharedFilterIndexes: [0, 3] },
|
|
18
|
-
viz2: { type: 'chart'}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
cleanSharedFilters(config)
|
|
23
|
-
|
|
24
|
-
expect(config.dashboard.sharedFilters).toEqual([{ id: 1, type: 'filter1' }, { id: 4, type: 'filter4' }])
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('should retain used shared filters and remove their active state', () => {
|
|
28
|
-
const config: DashboardConfig = {
|
|
29
|
-
dashboard: {
|
|
30
|
-
sharedFilters: [
|
|
31
|
-
{ id: 1, type: 'filter1', active: true },
|
|
32
|
-
{ id: 2, type: 'filter2', active: true }
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
visualizations: {
|
|
36
|
-
viz1: { type: 'dashboardFilters', sharedFilterIndexes: [0] },
|
|
37
|
-
viz2: { type: 'dashboardFilters', sharedFilterIndexes: [1] }
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
cleanSharedFilters(config)
|
|
42
|
-
|
|
43
|
-
expect(config.dashboard.sharedFilters).toEqual([
|
|
44
|
-
{ id: 1, type: 'filter1' },
|
|
45
|
-
{ id: 2, type: 'filter2' }
|
|
46
|
-
])
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('should remove values from urlfilter type shared filters', () => {
|
|
50
|
-
const config: DashboardConfig = {
|
|
51
|
-
dashboard: {
|
|
52
|
-
sharedFilters: [
|
|
53
|
-
{ id: 1, type: 'urlfilter', values: [1, 2, 3] },
|
|
54
|
-
{ id: 2, type: 'filter2' }
|
|
55
|
-
]
|
|
56
|
-
},
|
|
57
|
-
visualizations: {
|
|
58
|
-
viz1: { type: 'dashboardFilters', sharedFilterIndexes: [0] }
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
cleanSharedFilters(config)
|
|
63
|
-
|
|
64
|
-
expect(config.dashboard.sharedFilters).toEqual([
|
|
65
|
-
{ id: 1, type: 'urlfilter' }
|
|
66
|
-
])
|
|
67
|
-
})
|
|
68
|
-
})
|