@cdc/dashboard 4.24.4 → 4.24.7

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 (75) hide show
  1. package/dist/cdcdashboard.js +179228 -141419
  2. package/examples/custom/css/respiratory.css +236 -0
  3. package/examples/custom/js/respiratory.js +242 -0
  4. package/examples/default-multi-dataset-shared-filter.json +1729 -0
  5. package/examples/ed-visits-county-file.json +618 -0
  6. package/examples/filtered-dash.json +6 -21
  7. package/index.html +12 -3
  8. package/package.json +12 -11
  9. package/src/CdcDashboard.tsx +5 -1
  10. package/src/CdcDashboardComponent.tsx +156 -334
  11. package/src/DashboardContext.tsx +9 -1
  12. package/src/_stories/Dashboard.stories.tsx +31 -3
  13. package/src/_stories/_mock/dashboard-gallery.json +534 -523
  14. package/src/_stories/_mock/markup-include.json +78 -0
  15. package/src/_stories/_mock/multi-dashboards.json +914 -0
  16. package/src/_stories/_mock/multi-viz.json +2 -3
  17. package/src/_stories/_mock/pivot-filter.json +15 -11
  18. package/src/_stories/_mock/standalone-table.json +2 -0
  19. package/src/components/CollapsibleVisualizationRow.tsx +44 -0
  20. package/src/components/Column.tsx +1 -1
  21. package/src/components/DashboardFilters/DashboardFilters.tsx +80 -0
  22. package/src/components/DashboardFilters/DashboardFiltersEditor/DashboardFiltersEditor.tsx +218 -0
  23. package/src/components/DashboardFilters/DashboardFiltersEditor/components/DeleteFilterModal.tsx +48 -0
  24. package/src/components/DashboardFilters/DashboardFiltersEditor/components/FilterEditor.tsx +367 -0
  25. package/src/components/DashboardFilters/DashboardFiltersEditor/index.ts +1 -0
  26. package/src/components/DashboardFilters/DashboardFiltersWrapper.tsx +143 -0
  27. package/src/components/DashboardFilters/index.ts +3 -0
  28. package/src/components/DataDesignerModal.tsx +9 -9
  29. package/src/components/ExpandCollapseButtons.tsx +20 -0
  30. package/src/components/Header/Header.tsx +1 -97
  31. package/src/components/MultiConfigTabs/MultiConfigTabs.tsx +4 -4
  32. package/src/components/MultiConfigTabs/MultiTabs.tsx +3 -2
  33. package/src/components/Row.tsx +52 -19
  34. package/src/components/Toggle/Toggle.tsx +2 -4
  35. package/src/components/VisualizationRow.tsx +96 -29
  36. package/src/components/VisualizationsPanel/VisualizationsPanel.tsx +116 -0
  37. package/src/components/VisualizationsPanel/index.ts +1 -0
  38. package/src/components/VisualizationsPanel/visualizations-panel-styles.css +12 -0
  39. package/src/components/Widget.tsx +26 -90
  40. package/src/helpers/apiFilterHelpers.ts +51 -0
  41. package/src/helpers/changeFilterActive.ts +30 -0
  42. package/src/helpers/filterData.ts +16 -56
  43. package/src/helpers/generateValuesForFilter.ts +1 -1
  44. package/src/helpers/getAutoLoadVisualization.ts +11 -0
  45. package/src/helpers/getFilteredData.ts +4 -2
  46. package/src/helpers/getVizConfig.ts +23 -2
  47. package/src/helpers/getVizRowColumnLocator.ts +2 -1
  48. package/src/helpers/hasDashboardApplyBehavior.ts +5 -0
  49. package/src/helpers/iconHash.tsx +3 -3
  50. package/src/helpers/mapDataToConfig.ts +29 -0
  51. package/src/helpers/processData.ts +2 -3
  52. package/src/helpers/reloadURLHelpers.ts +68 -0
  53. package/src/helpers/tests/filterData.test.ts +1 -93
  54. package/src/scss/editor-panel.scss +1 -1
  55. package/src/scss/grid.scss +34 -27
  56. package/src/scss/main.scss +41 -3
  57. package/src/scss/variables.scss +4 -0
  58. package/src/store/dashboard.actions.ts +9 -10
  59. package/src/store/dashboard.reducer.ts +41 -13
  60. package/src/types/APIFilter.ts +1 -4
  61. package/src/types/ConfigRow.ts +2 -0
  62. package/src/types/Dashboard.ts +1 -1
  63. package/src/types/DashboardConfig.ts +2 -4
  64. package/src/types/DashboardFilters.ts +7 -0
  65. package/src/types/InitialState.ts +1 -1
  66. package/src/types/MultiDashboard.ts +2 -2
  67. package/src/types/SharedFilter.ts +2 -5
  68. package/src/types/Tab.ts +1 -1
  69. package/LICENSE +0 -201
  70. package/src/components/EditorWrapper/EditorWrapper.tsx +0 -52
  71. package/src/components/EditorWrapper/editor-wrapper.style.css +0 -13
  72. package/src/components/Filters.tsx +0 -88
  73. package/src/components/Header/FilterModal.tsx +0 -506
  74. package/src/components/VisualizationsPanel.tsx +0 -72
  75. package/src/helpers/getApiFilterKey.ts +0 -5
@@ -2,17 +2,22 @@ import { Dispatch, createContext } from 'react'
2
2
  import { DashboardState } from './store/dashboard.reducer'
3
3
  import DashboardActions from './store/dashboard.actions'
4
4
  import { Tab } from './types/Tab'
5
+ import { MultiDashboardConfig } from './types/MultiDashboard'
6
+ import { SharedFilter } from './types/SharedFilter'
7
+ import { APIFilterDropdowns } from './components/DashboardFilters'
5
8
 
6
9
  type ConfigCTX = DashboardState & {
7
10
  outerContainerRef: (node: any) => void
8
11
  setParentConfig: any
9
12
  isDebug: boolean
13
+ reloadURLData: (newFilters?: SharedFilter[]) => void
14
+ loadAPIFilters: (sharedFilters: SharedFilter[], dropdowns?: APIFilterDropdowns, recursiveLimit?: number) => Promise<SharedFilter[]>
10
15
  }
11
16
 
12
17
  const firstTab: Tab = 'Dashboard Description'
13
18
 
14
19
  export const initialState = {
15
- data: {},
20
+ data: {} as Record<string, any[]>,
16
21
  loading: false,
17
22
  filteredData: {},
18
23
  preview: false,
@@ -22,7 +27,10 @@ export const initialState = {
22
27
  const initialContext: ConfigCTX = {
23
28
  outerContainerRef: () => {},
24
29
  setParentConfig: () => {},
30
+ reloadURLData: () => {},
31
+ loadAPIFilters: () => Promise.resolve([]),
25
32
  isDebug: false,
33
+ config: {} as MultiDashboardConfig,
26
34
  ...initialState
27
35
  }
28
36
 
@@ -7,6 +7,7 @@ import ExampleConfig_2 from './_mock/dashboard-2.json'
7
7
  import ExampleConfig_3 from './_mock/dashboard_no_filter.json'
8
8
  import Dashboard_Filter from './_mock/dashboard-filter.json'
9
9
  import MultiVizConfig from './_mock/multi-viz.json'
10
+ import MultiDashboardConfig from './_mock/multi-dashboards.json'
10
11
  import Dashboard from '../CdcDashboard'
11
12
  import StandaloneTable from './_mock/standalone-table.json'
12
13
  import PivotFitlerConfig from './_mock/pivot-filter.json'
@@ -14,6 +15,9 @@ import { type DashboardConfig as Config } from '../types/DashboardConfig'
14
15
  import { userEvent, within } from '@storybook/testing-library'
15
16
  import ToggleExampleConfig from './_mock/toggle-example.json'
16
17
  import _ from 'lodash'
18
+ import { footnotesSymbols } from '@cdc/core/helpers/footnoteSymbols'
19
+ import FootnotesConfig from '@cdc/core/types/Footnotes'
20
+ import { ConfigRow } from '../types/ConfigRow'
17
21
 
18
22
  const meta: Meta<typeof Dashboard> = {
19
23
  title: 'Components/Pages/Dashboard',
@@ -88,8 +92,13 @@ countries.forEach((country, i) => {
88
92
  })
89
93
  })
90
94
 
95
+ const footnoteData = countries.map((country, i) => {
96
+ return { Country: country, symbol: footnotesSymbols[i][0], text: faker.lorem.sentence() }
97
+ })
98
+
91
99
  const multiVizData = {
92
- 'valid-world-data.json': { data }
100
+ 'valid-world-data.json': { data },
101
+ 'footnote-data.json': { data: footnoteData }
93
102
  }
94
103
 
95
104
  export const MultiVisualization: Story = {
@@ -99,6 +108,23 @@ export const MultiVisualization: Story = {
99
108
  }
100
109
  }
101
110
 
111
+ export const MultiDashboard: Story = {
112
+ args: {
113
+ config: MultiDashboardConfig,
114
+ isEditor: false
115
+ }
116
+ }
117
+
118
+ const FNrows: ConfigRow[] = [{ ...MultiVizConfig.rows[0], footnotesId: 'footnote123' }]
119
+ const footnoteConfig: Partial<FootnotesConfig> = { dataKey: 'footnote-data.json', dynamicFootnotes: { symbolColumn: 'symbol', textColumn: 'text' }, staticFootnotes: [{ symbol: '**', text: 'This is a static Footnote' }] }
120
+ const FNViz = { ...MultiVizConfig.visualizations, footnote123: footnoteConfig }
121
+ export const Footnotes: Story = {
122
+ args: {
123
+ config: { ...MultiVizConfig, datasets: multiVizData, rows: FNrows, visualizations: FNViz },
124
+ isEditor: false
125
+ }
126
+ }
127
+
102
128
  const sleep = ms => {
103
129
  return new Promise(r => setTimeout(r, ms))
104
130
  }
@@ -188,7 +214,8 @@ const fetchMock = {
188
214
 
189
215
  export const APIFiltersMap: Story = {
190
216
  args: {
191
- config: APIFiltersMapData as unknown as Config
217
+ config: APIFiltersMapData as unknown as Config,
218
+ isEditor: false
192
219
  },
193
220
  parameters: {
194
221
  fetchMock
@@ -216,7 +243,8 @@ export const APIFiltersMap: Story = {
216
243
 
217
244
  export const APIFiltersChart: Story = {
218
245
  args: {
219
- config: APIFiltersChartData as unknown as Config
246
+ config: APIFiltersChartData as unknown as Config,
247
+ isEditor: false
220
248
  },
221
249
  parameters: {
222
250
  fetchMock