@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.
Files changed (128) hide show
  1. package/components/AdvancedEditor/AdvancedEditor.tsx +29 -8
  2. package/components/DataTable/DataTable.tsx +63 -11
  3. package/components/DataTable/DataTableStandAlone.tsx +4 -1
  4. package/components/DataTable/components/ChartHeader.tsx +58 -9
  5. package/components/DataTable/components/ExpandCollapse.tsx +21 -1
  6. package/components/DataTable/components/MapHeader.tsx +35 -7
  7. package/components/DataTable/data-table.css +6 -0
  8. package/components/DataTable/helpers/chartCellMatrix.tsx +11 -8
  9. package/components/DataTable/helpers/mapCellMatrix.tsx +19 -1
  10. package/components/DownloadButton.tsx +42 -13
  11. package/components/EditorPanel/DataTableEditor.tsx +10 -1
  12. package/components/EditorPanel/components/MarkupHighlightedTextField.tsx +227 -0
  13. package/components/EditorPanel/components/MarkupVariablesEditor.tsx +411 -0
  14. package/components/EditorPanel/components/PanelMarkup.tsx +59 -0
  15. package/components/ErrorBoundary.jsx +3 -1
  16. package/components/Filters/Filters.tsx +35 -11
  17. package/components/Filters/components/Tabs.tsx +1 -0
  18. package/components/Footnotes/FootnotesStandAlone.tsx +2 -1
  19. package/components/Legend/Legend.Gradient.tsx +3 -6
  20. package/components/LegendShape.tsx +121 -3
  21. package/components/{MediaControls.jsx → MediaControls.tsx} +80 -16
  22. package/components/PaletteConversionModal.tsx +87 -0
  23. package/components/PaletteSelector/DeveloperPaletteRollback.tsx +114 -0
  24. package/components/PaletteSelector/PaletteSelector.css +51 -0
  25. package/components/PaletteSelector/PaletteSelector.tsx +112 -0
  26. package/components/PaletteSelector/index.ts +2 -0
  27. package/components/RichTooltip/RichTooltip.tsx +1 -0
  28. package/components/Table/Table.tsx +3 -1
  29. package/components/_stories/BlurStrokeTest.stories.tsx +1 -1
  30. package/components/_stories/DataTable.stories.tsx +1 -1
  31. package/components/_stories/Filters.stories.tsx +1 -1
  32. package/components/_stories/Footnotes.stories.tsx +1 -1
  33. package/components/_stories/Inputs.stories.tsx +1 -1
  34. package/components/_stories/MultiSelect.stories.tsx +3 -3
  35. package/components/_stories/NestedDropdown.stories.tsx +1 -1
  36. package/components/_stories/Table.stories.tsx +1 -1
  37. package/components/elements/_stories/Button.stories.tsx +1 -1
  38. package/components/elements/_stories/Card.stories.tsx +1 -1
  39. package/components/inputs/InputToggle.tsx +2 -0
  40. package/components/managers/DataDesigner.tsx +10 -9
  41. package/components/managers/_stories/DataDesigner.stories.tsx +1 -1
  42. package/components/ui/Tooltip.tsx +2 -1
  43. package/components/ui/_stories/Accordion.stories.tsx +1 -1
  44. package/components/ui/_stories/ColorPaletteMigration.stories.mdx +275 -0
  45. package/components/ui/_stories/Colors.stories.tsx +330 -0
  46. package/components/ui/_stories/IconGallery.stories.tsx +316 -0
  47. package/components/ui/_stories/Title.stories.tsx +1 -1
  48. package/contexts/EditorContext.ts +18 -0
  49. package/contexts/editor.actions.ts +28 -0
  50. package/contexts/editor.reducer.ts +94 -0
  51. package/data/chartColorPalettes.ts +118 -0
  52. package/data/colorPalettes.ts +9 -0
  53. package/data/mapColorPalettes.ts +45 -0
  54. package/data/sharedPalettes.ts +50 -0
  55. package/dist/cove-main.css +14 -13
  56. package/dist/cove-main.css.map +1 -1
  57. package/generateViteConfig.js +80 -0
  58. package/helpers/addValuesToFilters.ts +2 -3
  59. package/helpers/cloneConfig.ts +31 -0
  60. package/helpers/configDataHelpers.ts +128 -0
  61. package/helpers/configHelpers.ts +27 -0
  62. package/helpers/constants.ts +5 -2
  63. package/helpers/cove/number.ts +6 -2
  64. package/helpers/coveUpdateWorker.ts +15 -3
  65. package/helpers/events.ts +32 -0
  66. package/helpers/filterColorPalettes.ts +152 -0
  67. package/helpers/generateColorsArray.ts +13 -0
  68. package/helpers/getColorPaletteVersion.ts +33 -0
  69. package/helpers/getPaletteAccessor.ts +18 -0
  70. package/helpers/markupProcessor.ts +205 -0
  71. package/helpers/metrics/helpers.ts +75 -0
  72. package/helpers/metrics/types.ts +82 -0
  73. package/helpers/metrics/utils.ts +34 -0
  74. package/helpers/palettes/colorDistributions.ts +56 -0
  75. package/helpers/palettes/migratePaletteName.ts +150 -0
  76. package/helpers/palettes/standardizePaletteNames.ts +77 -0
  77. package/helpers/palettes/utils.ts +267 -0
  78. package/helpers/queryStringUtils.ts +13 -0
  79. package/helpers/testing.ts +345 -0
  80. package/helpers/tests/addValuesToFilters.test.ts +1 -2
  81. package/helpers/tests/generateColorsArray.test.ts +24 -0
  82. package/helpers/tests/markupProcessor.test.ts +538 -0
  83. package/helpers/tests/testStandaloneBuild.ts +44 -0
  84. package/helpers/useMarkupVariables.ts +31 -0
  85. package/helpers/vegaConfig.ts +0 -1
  86. package/helpers/ver/4.24.10.ts +2 -1
  87. package/helpers/ver/4.24.11.ts +2 -1
  88. package/helpers/ver/4.24.3.ts +2 -1
  89. package/helpers/ver/4.24.4.ts +2 -1
  90. package/helpers/ver/4.24.5.ts +2 -1
  91. package/helpers/ver/4.24.7.ts +2 -1
  92. package/helpers/ver/4.24.9.ts +2 -1
  93. package/helpers/ver/4.25.1.ts +2 -1
  94. package/helpers/ver/4.25.10.ts +36 -0
  95. package/helpers/ver/4.25.3.ts +2 -1
  96. package/helpers/ver/4.25.4.ts +2 -1
  97. package/helpers/ver/4.25.6.ts +2 -1
  98. package/helpers/ver/4.25.7.ts +2 -1
  99. package/helpers/ver/4.25.8.ts +62 -0
  100. package/helpers/ver/4.25.9.ts +293 -0
  101. package/helpers/ver/tests/4.25.10.test.ts +204 -0
  102. package/helpers/ver/tests/4.25.8.test.ts +86 -0
  103. package/helpers/ver/tests/4.25.9.test.ts +51 -0
  104. package/helpers/viewports.ts +2 -0
  105. package/hooks/useColorPalette.ts +79 -0
  106. package/package.json +12 -4
  107. package/styles/_button-section.scss +0 -2
  108. package/styles/_global.scss +7 -5
  109. package/styles/base.scss +8 -5
  110. package/styles/v2/components/button.scss +4 -3
  111. package/styles/v2/components/editor.scss +2 -1
  112. package/styles/v2/layout/_data-table.scss +3 -2
  113. package/styles/v2/themes/_color-definitions.scss +18 -17
  114. package/testBuild.js +0 -0
  115. package/testing-setup.js +32 -0
  116. package/types/ForecastingSeriesKey.ts +0 -1
  117. package/types/MarkupInclude.ts +6 -1
  118. package/types/MarkupVariable.ts +19 -0
  119. package/types/Series.ts +4 -0
  120. package/types/Table.ts +1 -0
  121. package/types/VizFilter.ts +1 -0
  122. package/vitest.config.ts +16 -0
  123. package/components/ui/_stories/Colors.stories.mdx +0 -220
  124. package/components/ui/_stories/IconGallery.stories.mdx +0 -14
  125. package/data/colorPalettes.js +0 -171
  126. package/helpers/events.js +0 -14
  127. package/helpers/formatConfigBeforeSave.ts +0 -135
  128. 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
- })