@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
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import update_4_25_10 from '../4.25.10'
|
|
2
|
+
import { expect, describe, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
describe('update_4_25_10 - Markup Variables Migration', () => {
|
|
5
|
+
it('should migrate markup-include variables from contentEditor to root level', () => {
|
|
6
|
+
const config: any = {
|
|
7
|
+
type: 'markup-include',
|
|
8
|
+
version: '4.25.9',
|
|
9
|
+
contentEditor: {
|
|
10
|
+
markupVariables: [
|
|
11
|
+
{ name: 'State', tag: '{{state}}', columnName: 'state', conditions: [] }
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const result = update_4_25_10(config)
|
|
17
|
+
|
|
18
|
+
expect(result.markupVariables).toEqual([
|
|
19
|
+
{ name: 'State', tag: '{{state}}', columnName: 'state', conditions: [] }
|
|
20
|
+
])
|
|
21
|
+
expect(result.contentEditor.markupVariables).toBeUndefined()
|
|
22
|
+
expect(result.enableMarkupVariables).toBe(true)
|
|
23
|
+
expect(result.version).toBe('4.25.10')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('should enable markup variables flag when variables exist', () => {
|
|
27
|
+
const config: any = {
|
|
28
|
+
type: 'markup-include',
|
|
29
|
+
version: '4.25.9',
|
|
30
|
+
contentEditor: {
|
|
31
|
+
markupVariables: [
|
|
32
|
+
{ name: 'Var1', tag: '{{var1}}', columnName: 'col1', conditions: [] },
|
|
33
|
+
{ name: 'Var2', tag: '{{var2}}', columnName: 'col2', conditions: [] }
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const result = update_4_25_10(config)
|
|
39
|
+
|
|
40
|
+
expect(result.enableMarkupVariables).toBe(true)
|
|
41
|
+
expect(result.markupVariables).toHaveLength(2)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('should initialize empty markupVariables array if none exist', () => {
|
|
45
|
+
const config: any = {
|
|
46
|
+
type: 'markup-include',
|
|
47
|
+
version: '4.25.9',
|
|
48
|
+
contentEditor: {}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const result = update_4_25_10(config)
|
|
52
|
+
|
|
53
|
+
expect(result.markupVariables).toEqual([])
|
|
54
|
+
expect(result.enableMarkupVariables).toBeUndefined()
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('should handle dashboard configs with nested visualizations', () => {
|
|
58
|
+
const config: any = {
|
|
59
|
+
type: 'dashboard',
|
|
60
|
+
version: '4.25.9',
|
|
61
|
+
visualizations: {
|
|
62
|
+
viz1: {
|
|
63
|
+
type: 'markup-include',
|
|
64
|
+
contentEditor: {
|
|
65
|
+
markupVariables: [
|
|
66
|
+
{ name: 'Test', tag: '{{test}}', columnName: 'test', conditions: [] }
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
viz2: {
|
|
71
|
+
type: 'chart',
|
|
72
|
+
title: 'Chart'
|
|
73
|
+
},
|
|
74
|
+
viz3: {
|
|
75
|
+
type: 'markup-include',
|
|
76
|
+
contentEditor: {
|
|
77
|
+
markupVariables: [
|
|
78
|
+
{ name: 'Another', tag: '{{another}}', columnName: 'another', conditions: [] }
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const result = update_4_25_10(config)
|
|
86
|
+
|
|
87
|
+
expect(result.visualizations.viz1.markupVariables).toHaveLength(1)
|
|
88
|
+
expect(result.visualizations.viz1.enableMarkupVariables).toBe(true)
|
|
89
|
+
expect(result.visualizations.viz1.contentEditor.markupVariables).toBeUndefined()
|
|
90
|
+
|
|
91
|
+
expect(result.visualizations.viz3.markupVariables).toHaveLength(1)
|
|
92
|
+
expect(result.visualizations.viz3.enableMarkupVariables).toBe(true)
|
|
93
|
+
expect(result.visualizations.viz3.contentEditor.markupVariables).toBeUndefined()
|
|
94
|
+
|
|
95
|
+
// Chart should remain unchanged except version
|
|
96
|
+
expect(result.visualizations.viz2.title).toBe('Chart')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('should not modify non-markup-include configs', () => {
|
|
100
|
+
const config: any = {
|
|
101
|
+
type: 'chart',
|
|
102
|
+
version: '4.25.9',
|
|
103
|
+
title: 'My Chart'
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const result = update_4_25_10(config)
|
|
107
|
+
|
|
108
|
+
expect(result.markupVariables).toBeUndefined()
|
|
109
|
+
expect(result.enableMarkupVariables).toBeUndefined()
|
|
110
|
+
expect(result.title).toBe('My Chart')
|
|
111
|
+
expect(result.version).toBe('4.25.10')
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('should be idempotent - safe to run multiple times', () => {
|
|
115
|
+
const config: any = {
|
|
116
|
+
type: 'markup-include',
|
|
117
|
+
version: '4.25.9',
|
|
118
|
+
contentEditor: {
|
|
119
|
+
markupVariables: [
|
|
120
|
+
{ name: 'State', tag: '{{state}}', columnName: 'state', conditions: [] }
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Run migration twice
|
|
126
|
+
const result1 = update_4_25_10(config)
|
|
127
|
+
const result2 = update_4_25_10(result1)
|
|
128
|
+
|
|
129
|
+
// Should produce same result
|
|
130
|
+
expect(result2.markupVariables).toEqual(result1.markupVariables)
|
|
131
|
+
expect(result2.enableMarkupVariables).toBe(result1.enableMarkupVariables)
|
|
132
|
+
expect(result2.version).toBe('4.25.10')
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('should preserve other contentEditor properties', () => {
|
|
136
|
+
const config: any = {
|
|
137
|
+
type: 'markup-include',
|
|
138
|
+
version: '4.25.9',
|
|
139
|
+
contentEditor: {
|
|
140
|
+
markupVariables: [
|
|
141
|
+
{ name: 'Test', tag: '{{test}}', columnName: 'test', conditions: [] }
|
|
142
|
+
],
|
|
143
|
+
otherProperty: 'should remain',
|
|
144
|
+
nested: {
|
|
145
|
+
value: 123
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const result = update_4_25_10(config)
|
|
151
|
+
|
|
152
|
+
expect(result.contentEditor.otherProperty).toBe('should remain')
|
|
153
|
+
expect(result.contentEditor.nested).toEqual({ value: 123 })
|
|
154
|
+
expect(result.contentEditor.markupVariables).toBeUndefined()
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('should handle empty markupVariables array in contentEditor', () => {
|
|
158
|
+
const config: any = {
|
|
159
|
+
type: 'markup-include',
|
|
160
|
+
version: '4.25.9',
|
|
161
|
+
contentEditor: {
|
|
162
|
+
markupVariables: []
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const result = update_4_25_10(config)
|
|
167
|
+
|
|
168
|
+
expect(result.markupVariables).toEqual([])
|
|
169
|
+
expect(result.enableMarkupVariables).toBeUndefined() // Should not enable if array is empty
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
it('should preserve conditions in markup variables during migration', () => {
|
|
173
|
+
const config: any = {
|
|
174
|
+
type: 'markup-include',
|
|
175
|
+
version: '4.25.9',
|
|
176
|
+
contentEditor: {
|
|
177
|
+
markupVariables: [
|
|
178
|
+
{
|
|
179
|
+
name: 'Conditional Var',
|
|
180
|
+
tag: '{{conditional-var}}',
|
|
181
|
+
columnName: 'value',
|
|
182
|
+
conditions: [
|
|
183
|
+
{ columnName: 'state', isOrIsNotEqualTo: 'is', value: 'California' },
|
|
184
|
+
{ columnName: 'year', isOrIsNotEqualTo: 'is not', value: '2020' }
|
|
185
|
+
],
|
|
186
|
+
addCommas: true,
|
|
187
|
+
hideOnNull: true
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const result = update_4_25_10(config)
|
|
194
|
+
|
|
195
|
+
expect(result.markupVariables[0].conditions).toHaveLength(2)
|
|
196
|
+
expect(result.markupVariables[0].conditions[0]).toEqual({
|
|
197
|
+
columnName: 'state',
|
|
198
|
+
isOrIsNotEqualTo: 'is',
|
|
199
|
+
value: 'California'
|
|
200
|
+
})
|
|
201
|
+
expect(result.markupVariables[0].addCommas).toBe(true)
|
|
202
|
+
expect(result.markupVariables[0].hideOnNull).toBe(true)
|
|
203
|
+
})
|
|
204
|
+
})
|
|
@@ -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
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { changeSingleStateMapNoDataMessage } from '../4.25.9'
|
|
2
|
+
import { expect, describe, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
describe('changeSingleStateMapNoDataMessage', () => {
|
|
5
|
+
it('should set noDataMessage to "No State Selected" if the message is default', () => {
|
|
6
|
+
const config: any = {
|
|
7
|
+
type: 'map',
|
|
8
|
+
general: { noStateFoundMessage: 'Map Unavailable' },
|
|
9
|
+
runtime: {}
|
|
10
|
+
}
|
|
11
|
+
changeSingleStateMapNoDataMessage(config)
|
|
12
|
+
expect(config.general.noDataMessage).toBe('No State Selected')
|
|
13
|
+
expect(config.general.noStateFoundMessage).toBeUndefined()
|
|
14
|
+
expect(config.runtime.noStateFoundMessage).toBeUndefined()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('should preserve custom noStateFoundMessage', () => {
|
|
18
|
+
const config: any = {
|
|
19
|
+
type: 'map',
|
|
20
|
+
general: { noStateFoundMessage: 'Custom Message' },
|
|
21
|
+
runtime: {}
|
|
22
|
+
}
|
|
23
|
+
changeSingleStateMapNoDataMessage(config)
|
|
24
|
+
expect(config.general.noDataMessage).toBe('Custom Message')
|
|
25
|
+
expect(config.general.noStateFoundMessage).toBeUndefined()
|
|
26
|
+
expect(config.runtime.noStateFoundMessage).toBeUndefined()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should work for dashboard configs with map visualizations', () => {
|
|
30
|
+
const dashboardConfig: any = {
|
|
31
|
+
type: 'dashboard',
|
|
32
|
+
visualizations: {
|
|
33
|
+
map1: {
|
|
34
|
+
type: 'map',
|
|
35
|
+
general: { noStateFoundMessage: 'Map Unavailable' },
|
|
36
|
+
runtime: {}
|
|
37
|
+
},
|
|
38
|
+
chart1: {
|
|
39
|
+
type: 'chart',
|
|
40
|
+
general: {},
|
|
41
|
+
runtime: {}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
changeSingleStateMapNoDataMessage(dashboardConfig)
|
|
46
|
+
expect(dashboardConfig.visualizations.map1.general.noDataMessage).toBe('No State Selected')
|
|
47
|
+
expect(dashboardConfig.visualizations.map1.general.noStateFoundMessage).toBeUndefined()
|
|
48
|
+
expect(dashboardConfig.visualizations.map1.runtime.noStateFoundMessage).toBeUndefined()
|
|
49
|
+
expect(dashboardConfig.visualizations.chart1.general.noDataMessage).toBeUndefined()
|
|
50
|
+
})
|
|
51
|
+
})
|
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)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react'
|
|
2
|
+
import { filterColorPalettes } from '../helpers/filterColorPalettes'
|
|
3
|
+
import { twoColorPalette, chartColorPalettes } from '../data/colorPalettes'
|
|
4
|
+
|
|
5
|
+
export interface UseColorPaletteResult {
|
|
6
|
+
sequential: string[]
|
|
7
|
+
nonSequential: string[]
|
|
8
|
+
accessibleColors: string[]
|
|
9
|
+
twoColorPalettes: string[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* React hook for filtering color palettes based on config and visualization type
|
|
14
|
+
* Provides filtered palettes for chart visualization components
|
|
15
|
+
*/
|
|
16
|
+
export const useColorPalette = (config: any, updateConfig?: (newConfig: any) => void): UseColorPaletteResult => {
|
|
17
|
+
// Get filtered palettes using the core filtering logic
|
|
18
|
+
const filteredPalettes = useMemo(() => {
|
|
19
|
+
const isReversed = config.general?.palette?.isReversed
|
|
20
|
+
const visualizationType = config.visualizationType
|
|
21
|
+
|
|
22
|
+
const result = filterColorPalettes({
|
|
23
|
+
config,
|
|
24
|
+
isReversed,
|
|
25
|
+
colorPalettes: chartColorPalettes,
|
|
26
|
+
visualizationType
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// Handle two-color palettes specially for chart components
|
|
30
|
+
let twoColorPalettes: string[] = []
|
|
31
|
+
if (visualizationType === 'Paired Bar' || visualizationType === 'Deviation Bar') {
|
|
32
|
+
const isTwoColorReversed = config.twoColor?.isPaletteReversed
|
|
33
|
+
twoColorPalettes = Object.keys(twoColorPalette).filter(name =>
|
|
34
|
+
isTwoColorReversed ? name.endsWith('reverse') : !name.endsWith('reverse')
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
sequential: result.sequential,
|
|
40
|
+
nonSequential: result.nonSequential,
|
|
41
|
+
accessibleColors: result.accessibleColors,
|
|
42
|
+
twoColorPalettes: result.twoColorPalettes || twoColorPalettes
|
|
43
|
+
}
|
|
44
|
+
}, [
|
|
45
|
+
config.visualizationType,
|
|
46
|
+
config.general?.palette?.isReversed,
|
|
47
|
+
config.general?.palette?.version,
|
|
48
|
+
config.twoColor?.isPaletteReversed
|
|
49
|
+
])
|
|
50
|
+
|
|
51
|
+
// Update twoColor palette based on isPaletteReversed
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!updateConfig || !config.twoColor) return
|
|
54
|
+
|
|
55
|
+
const { isPaletteReversed, palette } = config.twoColor
|
|
56
|
+
let newPalette = ''
|
|
57
|
+
|
|
58
|
+
if (isPaletteReversed && !palette.endsWith('reverse')) {
|
|
59
|
+
newPalette = palette + 'reverse'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!isPaletteReversed && palette.endsWith('reverse')) {
|
|
63
|
+
newPalette = palette.slice(0, -7)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (newPalette && newPalette !== palette) {
|
|
67
|
+
updateConfig({
|
|
68
|
+
...config,
|
|
69
|
+
twoColor: {
|
|
70
|
+
...config.twoColor,
|
|
71
|
+
palette: newPalette
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
}, [config.twoColor?.isPaletteReversed, updateConfig])
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
return filteredPalettes
|
|
79
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/core",
|
|
3
|
-
"version": "4.25.
|
|
3
|
+
"version": "4.25.10",
|
|
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
|
+
"type": "module",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"test": "vitest run --environment jsdom --reporter verbose",
|
|
9
10
|
"test-watch": "vitest watch --reporter verbose",
|
|
@@ -21,14 +22,16 @@
|
|
|
21
22
|
},
|
|
22
23
|
"license": "Apache-2.0",
|
|
23
24
|
"dependencies": {
|
|
25
|
+
"chroma-js": "3.1.2",
|
|
24
26
|
"dompurify": "^3.2.4",
|
|
25
27
|
"html2canvas": "^1.4.1",
|
|
26
28
|
"json-edit-react": "^1.27.0",
|
|
29
|
+
"papaparse": "5.5.2",
|
|
27
30
|
"prop-types": "^15.8.1",
|
|
28
31
|
"react-accessible-accordion": "^5.0.1",
|
|
29
32
|
"react-select": "^5.3.1",
|
|
30
33
|
"react-tooltip": "5.8.2-beta.3",
|
|
31
|
-
"
|
|
34
|
+
"resize-observer-polyfill": "^1.5.1",
|
|
32
35
|
"use-debounce": "^10.0.5",
|
|
33
36
|
"vega": "^6.1.0",
|
|
34
37
|
"vega-lite": "^6.1.0"
|
|
@@ -37,8 +40,13 @@
|
|
|
37
40
|
"react": "^18.2.0",
|
|
38
41
|
"react-dom": "^18.2.0"
|
|
39
42
|
},
|
|
40
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "c2db758e74ab9b9ca1667a6f9cb41dd0dccf985d",
|
|
41
44
|
"devDependencies": {
|
|
42
|
-
"
|
|
45
|
+
"@rollup/plugin-dsv": "^3.0.2",
|
|
46
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
47
|
+
"sass": "^1.89.2",
|
|
48
|
+
"vite": "^4.4.11",
|
|
49
|
+
"vite-plugin-css-injected-by-js": "^2.4.0",
|
|
50
|
+
"vite-plugin-svgr": "^2.4.0"
|
|
43
51
|
}
|
|
44
52
|
}
|
package/styles/_global.scss
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use 'sass:color';
|
|
2
|
+
|
|
1
3
|
strong {
|
|
2
4
|
font-weight: 600;
|
|
3
5
|
}
|
|
@@ -42,11 +44,11 @@ strong {
|
|
|
42
44
|
.inline-icon {
|
|
43
45
|
width: 1em !important;
|
|
44
46
|
height: auto !important;
|
|
47
|
+
font-size: 1rem;
|
|
48
|
+
color: inherit;
|
|
45
49
|
@media all and (-ms-high-contrast: none) {
|
|
46
50
|
height: 30px !important;
|
|
47
51
|
}
|
|
48
|
-
font-size: 1rem;
|
|
49
|
-
color: inherit;
|
|
50
52
|
path {
|
|
51
53
|
fill: currentColor;
|
|
52
54
|
}
|
|
@@ -76,7 +78,7 @@ strong {
|
|
|
76
78
|
font-size: 0.8 em;
|
|
77
79
|
color: #fff;
|
|
78
80
|
&:hover {
|
|
79
|
-
background-color:
|
|
81
|
+
background-color: color.adjust($red, $lightness: -5%);
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -168,8 +170,8 @@ section.footnotes {
|
|
|
168
170
|
background-color: $blue;
|
|
169
171
|
border-color: $blue;
|
|
170
172
|
&:hover:not([disabled]) {
|
|
171
|
-
background-color:
|
|
172
|
-
border-color:
|
|
173
|
+
background-color: color.adjust($blue, $lightness: -5%);
|
|
174
|
+
border-color: color.adjust($blue, $lightness: -5%);
|
|
173
175
|
}
|
|
174
176
|
}
|
|
175
177
|
|
package/styles/base.scss
CHANGED
|
@@ -66,6 +66,11 @@ body.post-type-cdc_visualization .cdc-editor .configure .editor-panel {
|
|
|
66
66
|
.cdc-open-viz-module {
|
|
67
67
|
position: relative;
|
|
68
68
|
line-height: 1.4;
|
|
69
|
+
// Force printing chart images
|
|
70
|
+
-webkit-print-color-adjust: exact !important; /* Chrome, Safari 6 – 15.3, Edge */
|
|
71
|
+
color-adjust: exact !important; /* Firefox 48 – 96 */
|
|
72
|
+
print-color-adjust: exact !important; /* Firefox 97+, Safari 15.4+ */
|
|
73
|
+
|
|
69
74
|
@import 'global';
|
|
70
75
|
@import 'button-section';
|
|
71
76
|
@import 'series-list';
|
|
@@ -75,11 +80,6 @@ body.post-type-cdc_visualization .cdc-editor .configure .editor-panel {
|
|
|
75
80
|
appearance: auto !important;
|
|
76
81
|
}
|
|
77
82
|
|
|
78
|
-
// Force printing chart images
|
|
79
|
-
-webkit-print-color-adjust: exact !important; /* Chrome, Safari 6 – 15.3, Edge */
|
|
80
|
-
color-adjust: exact !important; /* Firefox 48 – 96 */
|
|
81
|
-
print-color-adjust: exact !important; /* Firefox 97+, Safari 15.4+ */
|
|
82
|
-
|
|
83
83
|
$theme: (
|
|
84
84
|
'amber': (
|
|
85
85
|
'#fbab18',
|
|
@@ -234,4 +234,7 @@ body.post-type-cdc_visualization .cdc-editor .configure .editor-panel {
|
|
|
234
234
|
.ps-auto {
|
|
235
235
|
padding-left: auto !important;
|
|
236
236
|
}
|
|
237
|
+
.fw-bold {
|
|
238
|
+
font-weight: 700 !important;
|
|
239
|
+
}
|
|
237
240
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@use 'sass:color';
|
|
1
2
|
@import '../utils/variables';
|
|
2
3
|
@import '../themes/index';
|
|
3
4
|
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
background-color: #44aa41;
|
|
111
112
|
|
|
112
113
|
&:hover {
|
|
113
|
-
background-color:
|
|
114
|
+
background-color: color.adjust(#44aa41, $lightness: 5%);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
|
|
@@ -118,7 +119,7 @@
|
|
|
118
119
|
background-color: #d73636;
|
|
119
120
|
|
|
120
121
|
&:hover {
|
|
121
|
-
background-color:
|
|
122
|
+
background-color: color.adjust(#d73636, $lightness: -5%);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
|
|
@@ -126,7 +127,7 @@
|
|
|
126
127
|
background-color: #a0a0a0;
|
|
127
128
|
|
|
128
129
|
&:hover {
|
|
129
|
-
background-color:
|
|
130
|
+
background-color: color.adjust(#a0a0a0, $lightness: -5%);
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
@import '../themes/index';
|
|
3
3
|
|
|
4
4
|
.cove-editor {
|
|
5
|
-
@import './../base/reset';
|
|
6
5
|
display: grid;
|
|
7
6
|
grid-template-columns: auto 1fr;
|
|
8
7
|
grid-template-areas: 'panel content';
|
|
9
8
|
height: 100vh;
|
|
10
9
|
|
|
10
|
+
@import './../base/reset';
|
|
11
|
+
|
|
11
12
|
.cove-editor__panel {
|
|
12
13
|
grid-area: panel;
|
|
13
14
|
width: $editorWidth;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use 'sass:color';
|
|
2
|
+
|
|
1
3
|
.cove-data-table {
|
|
2
4
|
position: relative;
|
|
3
5
|
}
|
|
@@ -144,7 +146,7 @@
|
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
.sort {
|
|
147
|
-
background-color:
|
|
149
|
+
background-color: color.adjust($mediumGray, $lightness: -10%);
|
|
148
150
|
background-repeat: no-repeat;
|
|
149
151
|
background-position: right 0.5em center;
|
|
150
152
|
background-size: 10px 5px;
|
|
@@ -161,7 +163,6 @@
|
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
165
|
|
|
164
|
-
|
|
165
166
|
.cove-data-table__footer {
|
|
166
167
|
margin-top: 1rem;
|
|
167
168
|
}
|