@cdc/dashboard 4.25.5-1 → 4.25.6-2

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 (55) hide show
  1. package/LICENSE +201 -0
  2. package/dist/cdcdashboard.js +77621 -77591
  3. package/examples/private/DEV-10120.json +1294 -0
  4. package/examples/private/DEV-10527.json +845 -0
  5. package/examples/private/DEV-10586.json +54319 -0
  6. package/examples/private/DEV-10856.json +54319 -0
  7. package/examples/private/DEV-9199.json +606 -0
  8. package/examples/private/DEV-9644.json +20092 -0
  9. package/examples/private/DEV-9684.json +2135 -0
  10. package/examples/private/DEV-9932.json +95 -0
  11. package/examples/private/DEV-9989.json +229 -0
  12. package/examples/private/art-dashboard.json +18174 -0
  13. package/examples/private/art-scratch.json +2406 -0
  14. package/examples/private/bird-flu-2.json +440 -0
  15. package/examples/private/bird-flu.json +413 -0
  16. package/examples/private/crashing-sidebar.json +975 -0
  17. package/examples/private/d.json +1561 -0
  18. package/examples/private/dashboard-config-ehdi.json +29915 -0
  19. package/examples/private/dashboard-map-filter.json +815 -0
  20. package/examples/private/dashboard-margins.js +15 -0
  21. package/examples/private/dataset.json +1452 -0
  22. package/examples/private/dev-10856-2.json +1348 -0
  23. package/examples/private/ehdi-data.json +29502 -0
  24. package/examples/private/exposure-source-h5-data.csv +26 -0
  25. package/examples/private/fatal-data.csv +3159 -0
  26. package/examples/private/feelings.json +1 -0
  27. package/examples/private/gaza-issue.json +1214 -0
  28. package/examples/private/josh.json +6175 -0
  29. package/examples/private/map-issue.json +628 -0
  30. package/examples/private/markup.json +115 -0
  31. package/examples/private/mpox.json +429 -0
  32. package/examples/private/nhis.json +1792 -0
  33. package/examples/private/testing-pie.json +436 -0
  34. package/examples/private/workforce.json +2041 -0
  35. package/examples/special-classes.json +54340 -0
  36. package/package.json +9 -9
  37. package/src/CdcDashboardComponent.tsx +36 -214
  38. package/src/_stories/_mock/api-filter-map.json +1 -0
  39. package/src/components/CollapsibleVisualizationRow.tsx +2 -4
  40. package/src/components/DashboardEditors.tsx +143 -0
  41. package/src/components/DashboardFilters/DashboardFilters.tsx +205 -205
  42. package/src/components/DashboardFilters/DashboardFiltersEditor/DashboardFiltersEditor.tsx +286 -287
  43. package/src/components/DashboardFilters/DashboardFiltersWrapper.tsx +198 -198
  44. package/src/components/Header/Header.tsx +7 -9
  45. package/src/components/Row.tsx +1 -24
  46. package/src/components/VisualizationRow.tsx +190 -213
  47. package/src/helpers/getVizConfig.ts +93 -80
  48. package/src/helpers/getVizRowColumnLocator.ts +0 -1
  49. package/src/helpers/reloadURLHelpers.ts +10 -13
  50. package/src/store/dashboard.actions.ts +61 -64
  51. package/src/store/dashboard.reducer.ts +0 -11
  52. package/src/types/ConfigRow.ts +0 -1
  53. package/src/types/Dashboard.ts +1 -1
  54. package/src/types/DashboardConfig.ts +1 -1
  55. package/src/types/DataSet.ts +0 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdc/dashboard",
3
- "version": "4.25.5-1",
3
+ "version": "4.25.6-2",
4
4
  "description": "React component for combining multiple visualizations into a single dashboard",
5
5
  "moduleName": "CdcDashboard",
6
6
  "main": "dist/cdcdashboard",
@@ -27,13 +27,13 @@
27
27
  },
28
28
  "license": "Apache-2.0",
29
29
  "dependencies": {
30
- "@cdc/chart": "^4.25.5-1",
31
- "@cdc/core": "^4.25.5-1",
32
- "@cdc/data-bite": "^4.25.5-1",
33
- "@cdc/filtered-text": "^4.25.5-1",
34
- "@cdc/map": "^4.25.5-1",
35
- "@cdc/markup-include": "^4.25.5-1",
36
- "@cdc/waffle-chart": "^4.25.5-1",
30
+ "@cdc/chart": "^4.25.6-2",
31
+ "@cdc/core": "^4.25.6-1",
32
+ "@cdc/data-bite": "^4.25.6-1",
33
+ "@cdc/filtered-text": "^4.25.6-1",
34
+ "@cdc/map": "^4.25.6-1",
35
+ "@cdc/markup-include": "^4.25.6-1",
36
+ "@cdc/waffle-chart": "^4.25.6-1",
37
37
  "js-base64": "^2.5.2",
38
38
  "react-accessible-accordion": "^3.3.4",
39
39
  "react-dnd": "^14.0.2",
@@ -44,5 +44,5 @@
44
44
  "react": "^18.2.0",
45
45
  "react-dom": "^18.2.0"
46
46
  },
47
- "gitHead": "1d0a6e716bc113e6bea3636fcae90ebf2d19bb5c"
47
+ "gitHead": "8183dee16aa930575befad47833cf0ce2bcb4edb"
48
48
  }
@@ -19,13 +19,6 @@ import Loading from '@cdc/core/components/Loading'
19
19
  import { DataTransform } from '@cdc/core/helpers/DataTransform'
20
20
  import getViewport from '@cdc/core/helpers/getViewport'
21
21
 
22
- import CdcChart from '@cdc/chart/src/CdcChartComponent'
23
- import CdcDataBite from '@cdc/data-bite/src/CdcDataBite'
24
- import CdcMap from '@cdc/map/src/CdcMapComponent'
25
- import CdcWaffleChart from '@cdc/waffle-chart/src/CdcWaffleChart'
26
- import CdcMarkupInclude from '@cdc/markup-include/src/CdcMarkupInclude'
27
- import CdcFilteredText from '@cdc/filtered-text/src/CdcFilteredText'
28
-
29
22
  import Grid from './components/Grid'
30
23
  import Header from './components/Header/Header'
31
24
  import DataTable from '@cdc/core/components/DataTable'
@@ -56,17 +49,16 @@ import { getVizConfig } from './helpers/getVizConfig'
56
49
  import { getFilteredData } from './helpers/getFilteredData'
57
50
  import { getVizRowColumnLocator } from './helpers/getVizRowColumnLocator'
58
51
  import Layout from '@cdc/core/components/Layout'
59
- import FootnotesStandAlone from '@cdc/core/components/Footnotes/FootnotesStandAlone'
60
52
  import * as reloadURLHelpers from './helpers/reloadURLHelpers'
61
53
  import { addValuesToDashboardFilters } from './helpers/addValuesToDashboardFilters'
62
54
  import { DashboardFilters } from './types/DashboardFilters'
63
55
  import DashboardSharedFilters from './components/DashboardFilters'
64
- import ExpandCollapseButtons from './components/ExpandCollapseButtons'
65
56
  import { loadAPIFiltersFactory } from './helpers/loadAPIFilters'
66
57
  import Loader from '@cdc/core/components/Loader'
67
58
  import Alert from '@cdc/core/components/Alert'
68
59
  import { shouldLoadAllFilters } from './helpers/shouldLoadAllFilters'
69
60
  import { subscribe, unsubscribe } from '@cdc/core/helpers/events'
61
+ import DashboardEditors from './components/DashboardEditors'
70
62
 
71
63
  type DashboardProps = Omit<WCMSProps, 'configUrl'> & {
72
64
  initialState: InitialState
@@ -283,8 +275,9 @@ export default function CdcDashboard({ initialState, isEditor = false, isDebug =
283
275
  }
284
276
  return acc
285
277
  }, {})
286
- const filteredData = { ...state.filteredData, ...newDatasets }
287
- dispatch({ type: 'SET_FILTERED_DATA', payload: filteredData })
278
+ const newConfig = { ...state, data: { ...state.data, ...newDatasets } }
279
+ const newFilteredData = getFilteredData(newConfig, _.cloneDeep(state.filteredData))
280
+ dispatch({ type: 'SET_FILTERED_DATA', payload: newFilteredData })
288
281
  dispatch({ type: 'SET_DATA', payload: { ...state.data, ...newDatasets } })
289
282
  } catch (e) {
290
283
  console.error('Error setting event data: ', e)
@@ -369,7 +362,6 @@ export default function CdcDashboard({ initialState, isEditor = false, isDebug =
369
362
  state.filteredData
370
363
  )
371
364
  visualizationConfig.uid = visualizationKey
372
- if (visualizationConfig.type === 'footnotes') visualizationConfig.formattedData = undefined
373
365
  const setsSharedFilter =
374
366
  state.config.dashboard.sharedFilters &&
375
367
  state.config.dashboard.sharedFilters.filter(sharedFilter => sharedFilter.setBy === visualizationKey).length > 0
@@ -387,151 +379,21 @@ export default function CdcDashboard({ initialState, isEditor = false, isDebug =
387
379
  updateChildConfig(visualizationKey, dataCorrectedConfig)
388
380
  }
389
381
 
390
- switch (visualizationConfig.type) {
391
- case 'chart':
392
- body = (
393
- <>
394
- <Header visualizationKey={visualizationKey} subEditor='Chart' />
395
- <CdcChart
396
- key={visualizationKey}
397
- config={visualizationConfig}
398
- isEditor={true}
399
- isDebug={isDebug}
400
- setConfig={_updateConfig}
401
- setSharedFilter={setsSharedFilter ? setSharedFilter : undefined}
402
- setSharedFilterValue={setSharedFilterValue}
403
- dashboardConfig={state.config}
404
- isDashboard={true}
405
- configUrl={undefined}
406
- setEditing={undefined}
407
- hostname={undefined}
408
- link={undefined}
409
- />
410
- </>
411
- )
412
- break
413
- case 'map':
414
- body = (
415
- <>
416
- <Header visualizationKey={visualizationKey} subEditor='Map' />
417
- <CdcMap
418
- key={visualizationKey}
419
- config={visualizationConfig}
420
- isEditor={true}
421
- isDebug={isDebug}
422
- setConfig={_updateConfig}
423
- setSharedFilter={setsSharedFilter ? setSharedFilter : undefined}
424
- setSharedFilterValue={setSharedFilterValue}
425
- isDashboard={true}
426
- showLoader={false}
427
- dashboardConfig={state.config}
428
- />
429
- </>
430
- )
431
- break
432
- case 'data-bite':
433
- body = (
434
- <>
435
- <Header visualizationKey={visualizationKey} subEditor='Data Bite' />
436
- <CdcDataBite
437
- key={visualizationKey}
438
- config={{ ...visualizationConfig, newViz: true }}
439
- isEditor={true}
440
- setConfig={_updateConfig}
441
- isDashboard={true}
442
- />
443
- </>
444
- )
445
- break
446
- case 'waffle-chart':
447
- body = (
448
- <>
449
- <Header visualizationKey={visualizationKey} subEditor='Waffle Chart' />
450
- <CdcWaffleChart
451
- key={visualizationKey}
452
- config={visualizationConfig}
453
- isEditor={true}
454
- setConfig={_updateConfig}
455
- isDashboard={true}
456
- configUrl={undefined}
457
- />
458
- </>
459
- )
460
- break
461
- case 'markup-include':
462
- body = (
463
- <>
464
- <Header visualizationKey={visualizationKey} subEditor='Markup Include' />
465
- <CdcMarkupInclude
466
- key={visualizationKey}
467
- config={visualizationConfig}
468
- isEditor={true}
469
- setConfig={_updateConfig}
470
- isDashboard={true}
471
- configUrl={undefined}
472
- />
473
- </>
474
- )
475
- break
476
- case 'filtered-text':
477
- body = (
478
- <>
479
- <Header visualizationKey={visualizationKey} subEditor='Filtered Text' />
480
- <CdcFilteredText
481
- key={visualizationKey}
482
- config={visualizationConfig}
483
- isEditor={true}
484
- setConfig={_updateConfig}
485
- isDashboard={true}
486
- configUrl={undefined}
487
- />
488
- </>
489
- )
490
- break
491
- case 'dashboardFilters':
492
- body = (
493
- <>
494
- <Header visualizationKey={visualizationKey} subEditor='Filter Dropdowns' />
495
- <DashboardSharedFilters
496
- isEditor={true}
497
- visualizationConfig={visualizationConfig}
498
- apiFilterDropdowns={apiFilterDropdowns}
499
- setConfig={_updateConfig}
500
- />
501
- </>
502
- )
503
- break
504
- case 'table':
505
- body = (
506
- <>
507
- <Header visualizationKey={visualizationKey} subEditor='Table' />
508
- <DataTableStandAlone
509
- visualizationKey={visualizationKey}
510
- config={visualizationConfig}
511
- isEditor={true}
512
- updateConfig={_updateConfig}
513
- />
514
- </>
515
- )
516
- break
517
- case 'footnotes':
518
- body = (
519
- <>
520
- <Header visualizationKey={visualizationKey} subEditor='Footnotes' />
521
- {/* Datasets are passed in just for reference and need to be removed */}
522
- <FootnotesStandAlone
523
- visualizationKey={visualizationKey}
524
- config={{ ...visualizationConfig, datasets: state.config.datasets }}
525
- isEditor={true}
526
- updateConfig={conf => _updateConfig(_.omit(conf, 'datasets'))}
527
- />
528
- </>
529
- )
530
- break
531
- default:
532
- body = <></>
533
- break
534
- }
382
+ body = (
383
+ <>
384
+ <Header visualizationKey={visualizationKey} subEditor={true} />
385
+ <DashboardEditors
386
+ key={visualizationKey}
387
+ visualizationKey={visualizationKey}
388
+ visualizationConfig={visualizationConfig}
389
+ _updateConfig={_updateConfig}
390
+ isDebug={isDebug}
391
+ setSharedFilter={setSharedFilter}
392
+ apiFilterDropdowns={apiFilterDropdowns}
393
+ state={state}
394
+ />
395
+ </>
396
+ )
535
397
  }
536
398
  })
537
399
 
@@ -554,7 +416,7 @@ export default function CdcDashboard({ initialState, isEditor = false, isDebug =
554
416
  const { config } = state
555
417
  const { title, description } = config.dashboard || {}
556
418
 
557
- const filteredRows = config.rows && config.rows.filter(row => row.columns.filter(col => col.widget).length !== 0)
419
+ const filteredRows = config.rows?.filter(row => row.columns.filter(col => col.widget).length !== 0)
558
420
 
559
421
  body = (
560
422
  <>
@@ -580,62 +442,22 @@ export default function CdcDashboard({ initialState, isEditor = false, isDebug =
580
442
  {/* Description */}
581
443
  {description && <div className='subtext mb-3'>{parse(description)}</div>}
582
444
  {/* Visualizations */}
583
- {filteredRows &&
584
- filteredRows.map((row, index) => {
585
- if (row.multiVizColumn && (isPreview || !isEditor)) {
586
- const filteredData = getFilteredData(state, _.cloneDeep(state.data))
587
- const data = filteredData[index] ?? row.formattedData
588
- const dataGroups = {}
589
- data.forEach(d => {
590
- const groupKey = d[row.multiVizColumn]
591
- if (!dataGroups[groupKey]) dataGroups[groupKey] = []
592
- dataGroups[groupKey].push(d)
593
- })
594
- return (
595
- <React.Fragment key={`row__${index}`}>
596
- {/* Expand/Collapse All */}
597
- {!inNoDataState && row.expandCollapseAllButtons === true && (
598
- <ExpandCollapseButtons setAllExpanded={setAllExpanded} />
599
- )}
600
- {Object.keys(dataGroups).map(groupName => {
601
- const dataValue = dataGroups[groupName]
602
- return (
603
- <VisualizationRow
604
- key={`row__${index}__${groupName}`}
605
- allExpanded={allExpanded}
606
- filteredDataOverride={dataValue}
607
- groupName={groupName}
608
- row={row}
609
- rowIndex={index}
610
- setSharedFilter={setSharedFilter}
611
- updateChildConfig={updateChildConfig}
612
- apiFilterDropdowns={apiFilterDropdowns}
613
- currentViewport={currentViewport}
614
- inNoDataState={inNoDataState}
615
- isLastRow={index === filteredRows.length - 1}
616
- />
617
- )
618
- })}
619
- </React.Fragment>
620
- )
621
- } else {
622
- return (
623
- <VisualizationRow
624
- key={`row__${index}`}
625
- allExpanded={false}
626
- groupName={''}
627
- row={row}
628
- rowIndex={index}
629
- setSharedFilter={setSharedFilter}
630
- updateChildConfig={updateChildConfig}
631
- apiFilterDropdowns={apiFilterDropdowns}
632
- currentViewport={currentViewport}
633
- inNoDataState={inNoDataState}
634
- isLastRow={index === filteredRows.length - 1}
635
- />
636
- )
637
- }
638
- })}
445
+ {filteredRows?.map((row, index) => (
446
+ <VisualizationRow
447
+ key={`row__${index}`}
448
+ allExpanded={allExpanded}
449
+ groupName={''}
450
+ row={row}
451
+ rowIndex={index}
452
+ setSharedFilter={setSharedFilter}
453
+ setAllExpanded={setAllExpanded}
454
+ updateChildConfig={updateChildConfig}
455
+ apiFilterDropdowns={apiFilterDropdowns}
456
+ currentViewport={currentViewport}
457
+ inNoDataState={inNoDataState}
458
+ isLastRow={index === filteredRows.length - 1}
459
+ />
460
+ ))}
639
461
 
640
462
  {inNoDataState ? <div className='mt-5'>Please complete your selection to continue.</div> : <></>}
641
463
 
@@ -82,6 +82,7 @@
82
82
  ],
83
83
  "visualizations": {
84
84
  "map1": {
85
+ "table": {},
85
86
  "uid": "map1",
86
87
  "type": "map",
87
88
  "defaultData": false,
@@ -5,13 +5,11 @@ import { APP_FONT_SIZE } from '@cdc/core/helpers/constants'
5
5
  type CollapsableVizRow = {
6
6
  allExpanded: boolean
7
7
  children: React.ReactNode
8
- fontSize: string
9
8
  groupName: string
10
9
  currentViewport: string
11
10
  }
12
11
  const CollapsibleVisualizationRow: React.FC<CollapsableVizRow> = ({
13
12
  allExpanded,
14
- fontSize,
15
13
  groupName,
16
14
  currentViewport,
17
15
  children
@@ -24,7 +22,7 @@ const CollapsibleVisualizationRow: React.FC<CollapsableVizRow> = ({
24
22
  }, [allExpanded])
25
23
 
26
24
  return (
27
- <>
25
+ <div className='collapsable-multiviz-container'>
28
26
  <div
29
27
  style={{ fontSize: titleFontSize }}
30
28
  role='button'
@@ -43,7 +41,7 @@ const CollapsibleVisualizationRow: React.FC<CollapsableVizRow> = ({
43
41
  {groupName}
44
42
  </div>
45
43
  {isExpanded && children}
46
- </>
44
+ </div>
47
45
  )
48
46
  }
49
47
 
@@ -0,0 +1,143 @@
1
+ import CdcChart from '@cdc/chart/src/CdcChartComponent'
2
+ import { APIFilterDropdowns } from './DashboardFilters'
3
+ import CdcMapComponent from '@cdc/map/src/CdcMapComponent'
4
+ import CdcDataBite from '@cdc/data-bite/src/CdcDataBite'
5
+ import CdcWaffleChart from '@cdc/waffle-chart/src/CdcWaffleChart'
6
+ import CdcMarkupInclude from '@cdc/markup-include/src/CdcMarkupInclude'
7
+ import CdcFilteredText from '@cdc/filtered-text/src/CdcFilteredText'
8
+ import DashboardSharedFilters from './DashboardFilters'
9
+ import DataTableStandAlone from '@cdc/core/components/DataTable/DataTableStandAlone'
10
+ import _ from 'lodash'
11
+ import { AnyVisualization } from '@cdc/core/types/Visualization'
12
+ import { DashboardState } from '../store/dashboard.reducer'
13
+
14
+ type DashboardEditorProps = {
15
+ visualizationKey: string
16
+ visualizationConfig: AnyVisualization
17
+ _updateConfig: (config: any) => void
18
+ isDebug?: boolean
19
+ setSharedFilter?: Function
20
+ apiFilterDropdowns?: APIFilterDropdowns
21
+ state: DashboardState
22
+ }
23
+
24
+ const DashboardEditors: React.FC<DashboardEditorProps> = ({
25
+ visualizationKey,
26
+ visualizationConfig,
27
+ _updateConfig,
28
+ isDebug,
29
+ setSharedFilter,
30
+ apiFilterDropdowns,
31
+ state
32
+ }) => {
33
+ const setsSharedFilter =
34
+ state.config.dashboard.sharedFilters &&
35
+ state.config.dashboard.sharedFilters.filter(sharedFilter => sharedFilter.setBy === visualizationKey).length > 0
36
+ const setSharedFilterValue = setsSharedFilter
37
+ ? state.config.dashboard.sharedFilters.filter(sharedFilter => sharedFilter.setBy === visualizationKey)[0].active
38
+ : undefined
39
+ switch (visualizationConfig.type) {
40
+ case 'chart':
41
+ return (
42
+ <CdcChart
43
+ key={visualizationKey}
44
+ config={visualizationConfig}
45
+ isEditor={true}
46
+ isDebug={isDebug}
47
+ setConfig={_updateConfig}
48
+ setSharedFilter={setsSharedFilter ? setSharedFilter : undefined}
49
+ setSharedFilterValue={setSharedFilterValue}
50
+ dashboardConfig={state.config}
51
+ datasets={state.config.datasets}
52
+ isDashboard={true}
53
+ />
54
+ )
55
+ case 'map':
56
+ return (
57
+ <CdcMapComponent
58
+ key={visualizationKey}
59
+ config={visualizationConfig}
60
+ isEditor={true}
61
+ isDebug={isDebug}
62
+ setConfig={_updateConfig}
63
+ setSharedFilter={setsSharedFilter ? setSharedFilter : undefined}
64
+ setSharedFilterValue={setSharedFilterValue}
65
+ isDashboard={true}
66
+ showLoader={false}
67
+ dashboardConfig={state.config}
68
+ datasets={state.config.datasets}
69
+ />
70
+ )
71
+
72
+ case 'data-bite':
73
+ return (
74
+ <CdcDataBite
75
+ key={visualizationKey}
76
+ config={{ ...visualizationConfig, newViz: true }}
77
+ isEditor={true}
78
+ setConfig={_updateConfig}
79
+ isDashboard={true}
80
+ />
81
+ )
82
+
83
+ case 'waffle-chart':
84
+ return (
85
+ <CdcWaffleChart
86
+ key={visualizationKey}
87
+ config={visualizationConfig}
88
+ isEditor={true}
89
+ setConfig={_updateConfig}
90
+ isDashboard={true}
91
+ />
92
+ )
93
+
94
+ case 'markup-include':
95
+ return (
96
+ <CdcMarkupInclude
97
+ key={visualizationKey}
98
+ config={visualizationConfig}
99
+ isEditor={true}
100
+ setConfig={_updateConfig}
101
+ isDashboard={true}
102
+ datasets={state.config.datasets}
103
+ />
104
+ )
105
+
106
+ case 'filtered-text':
107
+ return (
108
+ <CdcFilteredText
109
+ key={visualizationKey}
110
+ config={visualizationConfig}
111
+ isEditor={true}
112
+ setConfig={_updateConfig}
113
+ isDashboard={true}
114
+ />
115
+ )
116
+
117
+ case 'dashboardFilters':
118
+ return (
119
+ <DashboardSharedFilters
120
+ isEditor={true}
121
+ visualizationConfig={visualizationConfig}
122
+ apiFilterDropdowns={apiFilterDropdowns}
123
+ setConfig={_updateConfig}
124
+ />
125
+ )
126
+
127
+ case 'table':
128
+ return (
129
+ <DataTableStandAlone
130
+ visualizationKey={visualizationKey}
131
+ config={visualizationConfig}
132
+ isEditor={true}
133
+ updateConfig={_updateConfig}
134
+ datasets={state.config.datasets}
135
+ />
136
+ )
137
+
138
+ default:
139
+ return null
140
+ }
141
+ }
142
+
143
+ export default DashboardEditors