@cdc/core 4.25.8 → 4.25.11

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 (163) hide show
  1. package/_stories/StoryRenderingTests.stories.tsx +164 -0
  2. package/components/AdvancedEditor/AdvancedEditor.tsx +32 -9
  3. package/components/CustomColorsEditor/CustomColorsEditor.css +299 -0
  4. package/components/CustomColorsEditor/CustomColorsEditor.tsx +209 -0
  5. package/components/CustomColorsEditor/index.ts +1 -0
  6. package/components/DataTable/DataTable.tsx +56 -38
  7. package/components/DataTable/DataTableStandAlone.tsx +8 -3
  8. package/components/DataTable/components/ChartHeader.tsx +44 -14
  9. package/components/DataTable/components/DataTableEditorPanel.tsx +12 -2
  10. package/components/DataTable/components/ExpandCollapse.tsx +10 -1
  11. package/components/DataTable/components/MapHeader.tsx +24 -13
  12. package/components/DataTable/data-table.css +12 -0
  13. package/components/DataTable/helpers/chartCellMatrix.tsx +11 -8
  14. package/components/DataTable/helpers/mapCellMatrix.tsx +33 -4
  15. package/components/DataTable/helpers/standardizeState.js +2 -2
  16. package/components/DataTable/helpers/tests/standardizeState.test.js +54 -0
  17. package/components/DownloadButton.tsx +40 -14
  18. package/components/EditorPanel/DataTableEditor.tsx +3 -3
  19. package/components/EditorPanel/EditorPanel.styles.css +423 -0
  20. package/components/EditorPanel/FootnotesEditor.tsx +44 -37
  21. package/components/EditorPanel/Inputs.tsx +12 -2
  22. package/components/EditorPanel/VizFilterEditor/NestedDropdownEditor.tsx +35 -62
  23. package/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +12 -2
  24. package/components/EditorPanel/components/MarkupHighlightedTextField.tsx +227 -0
  25. package/components/EditorPanel/components/MarkupVariablesEditor.tsx +450 -0
  26. package/components/EditorPanel/components/PanelMarkup.tsx +59 -0
  27. package/components/ErrorBoundary.jsx +3 -1
  28. package/components/Filters/Filters.tsx +52 -24
  29. package/components/Filters/components/Dropdown.tsx +6 -1
  30. package/components/Filters/components/Tabs.tsx +1 -0
  31. package/components/Footnotes/Footnotes.tsx +35 -25
  32. package/components/Footnotes/FootnotesStandAlone.tsx +42 -6
  33. package/components/HeaderThemeSelector/HeaderThemeSelector.css +43 -0
  34. package/components/HeaderThemeSelector/HeaderThemeSelector.stories.tsx +74 -0
  35. package/components/HeaderThemeSelector/HeaderThemeSelector.tsx +61 -0
  36. package/components/HeaderThemeSelector/index.ts +2 -0
  37. package/components/Layout/styles/editor.scss +2 -1
  38. package/components/Legend/Legend.Gradient.tsx +3 -6
  39. package/components/LegendShape.tsx +121 -3
  40. package/components/Loader/Loader.tsx +1 -1
  41. package/components/MediaControls.tsx +72 -21
  42. package/components/PaletteConversionModal.tsx +90 -0
  43. package/components/PaletteSelector/DeveloperPaletteRollback.tsx +114 -0
  44. package/components/PaletteSelector/PaletteSelector.css +94 -0
  45. package/components/PaletteSelector/PaletteSelector.tsx +112 -0
  46. package/components/PaletteSelector/index.ts +2 -0
  47. package/components/RichTooltip/RichTooltip.tsx +1 -0
  48. package/components/Table/Table.tsx +3 -1
  49. package/components/Table/components/Cell.tsx +23 -2
  50. package/components/Table/components/Row.tsx +5 -3
  51. package/components/_stories/BlurStrokeTest.stories.tsx +1 -1
  52. package/components/_stories/DataTable.stories.tsx +1 -1
  53. package/components/_stories/Filters.stories.tsx +21 -2
  54. package/components/_stories/Footnotes.CSV.stories.tsx +247 -0
  55. package/components/_stories/Footnotes.stories.tsx +769 -4
  56. package/components/_stories/Inputs.stories.tsx +3 -3
  57. package/components/_stories/MultiSelect.stories.tsx +3 -3
  58. package/components/_stories/NestedDropdown.stories.tsx +1 -1
  59. package/components/_stories/Table.stories.tsx +1 -1
  60. package/components/_stories/styles.scss +0 -1
  61. package/components/elements/_stories/Button.stories.tsx +1 -1
  62. package/components/elements/_stories/Card.stories.tsx +1 -1
  63. package/components/inputs/InputToggle.tsx +2 -0
  64. package/components/managers/DataDesigner.tsx +10 -9
  65. package/components/managers/_stories/DataDesigner.stories.tsx +1 -1
  66. package/components/ui/Accordion.jsx +1 -1
  67. package/components/ui/Tooltip.tsx +2 -1
  68. package/components/ui/_stories/Accordion.stories.tsx +1 -1
  69. package/components/ui/_stories/ColorPaletteMigration.stories.mdx +275 -0
  70. package/components/ui/_stories/Colors.stories.tsx +330 -0
  71. package/components/ui/_stories/IconGallery.stories.tsx +316 -0
  72. package/components/ui/_stories/Title.stories.tsx +1 -1
  73. package/components/ui/accordion.styles.css +57 -0
  74. package/contexts/EditorContext.ts +18 -0
  75. package/contexts/editor.actions.ts +28 -0
  76. package/contexts/editor.reducer.ts +94 -0
  77. package/data/chartColorPalettes.ts +118 -0
  78. package/data/colorPalettes.ts +9 -0
  79. package/data/mapColorPalettes.ts +45 -0
  80. package/data/sharedPalettes.ts +50 -0
  81. package/dist/cove-main.css +63 -14
  82. package/dist/cove-main.css.map +1 -1
  83. package/generateViteConfig.js +80 -0
  84. package/helpers/addValuesToFilters.ts +7 -3
  85. package/helpers/cloneConfig.ts +31 -0
  86. package/helpers/configDataHelpers.ts +128 -0
  87. package/helpers/configHelpers.ts +27 -0
  88. package/helpers/constants.ts +42 -2
  89. package/helpers/cove/number.ts +33 -12
  90. package/helpers/coveUpdateWorker.ts +15 -3
  91. package/helpers/fetchRemoteData.ts +3 -15
  92. package/helpers/filterColorPalettes.ts +152 -0
  93. package/helpers/generateColorsArray.ts +13 -0
  94. package/helpers/getColorPaletteVersion.ts +33 -0
  95. package/helpers/getPaletteAccessor.ts +18 -0
  96. package/helpers/markupProcessor.ts +220 -0
  97. package/helpers/mergeCustomOrderValues.ts +37 -0
  98. package/helpers/metrics/helpers.ts +42 -19
  99. package/helpers/metrics/types.ts +48 -9
  100. package/helpers/metrics/utils.ts +34 -0
  101. package/helpers/palettes/colorDistributions.ts +56 -0
  102. package/helpers/palettes/migratePaletteName.ts +150 -0
  103. package/helpers/palettes/standardizePaletteNames.ts +77 -0
  104. package/helpers/palettes/utils.ts +267 -0
  105. package/helpers/parseCsvWithQuotes.ts +65 -0
  106. package/helpers/queryStringUtils.ts +13 -0
  107. package/helpers/testing.ts +358 -0
  108. package/helpers/tests/addValuesToFilters.test.ts +1 -2
  109. package/helpers/tests/generateColorsArray.test.ts +24 -0
  110. package/helpers/tests/markupProcessor.test.ts +538 -0
  111. package/helpers/tests/testStandaloneBuild.ts +44 -0
  112. package/helpers/useMarkupVariables.ts +31 -0
  113. package/helpers/vegaConfig.ts +0 -1
  114. package/helpers/ver/4.24.10.ts +2 -1
  115. package/helpers/ver/4.24.11.ts +2 -1
  116. package/helpers/ver/4.24.3.ts +2 -1
  117. package/helpers/ver/4.24.4.ts +2 -1
  118. package/helpers/ver/4.24.5.ts +2 -1
  119. package/helpers/ver/4.24.7.ts +2 -1
  120. package/helpers/ver/4.24.9.ts +2 -1
  121. package/helpers/ver/4.25.1.ts +2 -1
  122. package/helpers/ver/4.25.10.ts +36 -0
  123. package/helpers/ver/4.25.11.ts +13 -0
  124. package/helpers/ver/4.25.3.ts +2 -1
  125. package/helpers/ver/4.25.4.ts +2 -1
  126. package/helpers/ver/4.25.6.ts +2 -1
  127. package/helpers/ver/4.25.7.ts +2 -1
  128. package/helpers/ver/4.25.8.ts +2 -1
  129. package/helpers/ver/4.25.9.ts +293 -0
  130. package/helpers/ver/tests/4.25.10.test.ts +204 -0
  131. package/helpers/ver/tests/4.25.8.test.ts +1 -1
  132. package/helpers/ver/tests/4.25.9.test.ts +51 -0
  133. package/helpers/viewports.ts +2 -0
  134. package/hooks/useColorPalette.ts +79 -0
  135. package/package.json +13 -4
  136. package/styles/_common-components.css +73 -0
  137. package/styles/_global.scss +32 -10
  138. package/styles/base.scss +8 -55
  139. package/styles/cove-main.scss +3 -1
  140. package/styles/filters.scss +10 -3
  141. package/styles/v2/base/index.scss +0 -1
  142. package/styles/v2/components/button.scss +4 -3
  143. package/styles/v2/components/editor.scss +16 -7
  144. package/styles/v2/layout/_data-table.scss +3 -2
  145. package/styles/v2/themes/_color-definitions.scss +18 -17
  146. package/styles/v2/utils/_breakpoints.scss +1 -1
  147. package/styles/v2/utils/index.scss +0 -1
  148. package/styles/waiting.scss +1 -1
  149. package/testing-setup.js +32 -0
  150. package/types/MarkupInclude.ts +8 -2
  151. package/types/MarkupVariable.ts +19 -0
  152. package/types/VizFilter.ts +2 -0
  153. package/vitest.config.ts +16 -0
  154. package/components/ui/_stories/Colors.stories.mdx +0 -220
  155. package/components/ui/_stories/IconGallery.stories.mdx +0 -14
  156. package/data/colorPalettes.js +0 -171
  157. package/helpers/formatConfigBeforeSave.ts +0 -135
  158. package/helpers/tests/formatConfigBeforeSave.test.ts +0 -68
  159. package/styles/_mixins.scss +0 -13
  160. package/styles/v2/base/_typography.scss +0 -0
  161. package/styles/v2/components/guidance-block.scss +0 -74
  162. package/styles/v2/utils/_functions.scss +0 -0
  163. /package/{styles/_typography.scss → testBuild.js} +0 -0
@@ -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
- })
@@ -1,13 +0,0 @@
1
- @mixin emptyState {
2
- background: rgba(255, 255, 255, 0.5);
3
- top: 0;
4
- left: 0;
5
- right: 0;
6
- bottom: 0;
7
- position: absolute;
8
- text-align: center;
9
- display: flex;
10
- align-items: center;
11
- justify-content: center;
12
- z-index: 7;
13
- }
File without changes
@@ -1,74 +0,0 @@
1
- @import '../utils/variables';
2
- @import '../themes/color-definitions';
3
-
4
- .cove-guidance-block {
5
- display: block;
6
- position: relative;
7
- padding: 0.75rem 1rem;
8
- margin-left: 5px;
9
- color: #444;
10
- text-decoration: none;
11
- border: $lightGray 1px solid;
12
- border-left: none;
13
- border-radius: 0 0.1875rem 0.1875rem 0;
14
- transition: all 200ms $transition-expo-out;
15
-
16
- &:before {
17
- content: '';
18
- position: absolute;
19
- top: -1px;
20
- left: -5px;
21
- bottom: -1px;
22
- width: 5px;
23
- background: $blue;
24
- border-radius: 0.1875rem 0 0 0.1875rem;
25
- }
26
-
27
- &:hover,
28
- &:focus,
29
- &:active {
30
- background: $lightestGray;
31
- color: #444;
32
- transition: 0.2s all;
33
- }
34
-
35
- &:after {
36
- content: '';
37
- position: absolute;
38
- inset: 0;
39
- left: -4px;
40
- margin: -4px;
41
- border-radius: 0.1875rem;
42
- outline: 2px solid transparent;
43
- transition: outline 200ms $transition-expo-out;
44
- pointer-events: none;
45
- }
46
-
47
- &:focus,
48
- &:active {
49
- outline: none;
50
-
51
- &:after {
52
- outline: 2px solid rgba(161, 161, 161, 0.6);
53
- }
54
- }
55
-
56
- svg {
57
- width: 60px;
58
- color: $blue;
59
- margin-right: 1rem;
60
-
61
- path {
62
- fill: currentColor;
63
- }
64
- }
65
- }
66
-
67
- .cove-guidance-block__header {
68
- font-weight: bold;
69
- font-size: 1.125rem;
70
- }
71
-
72
- .cove-guidance-block__content {
73
- font-size: 0.875rem;
74
- }
File without changes
File without changes