@cdc/dashboard 4.24.2 → 4.24.4

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 (52) hide show
  1. package/dist/cdcdashboard.js +128512 -99417
  2. package/examples/chart-data.json +5409 -0
  3. package/examples/full-dash-test.json +14643 -0
  4. package/examples/full-dashboard.json +10036 -0
  5. package/examples/sankey.json +5218 -0
  6. package/index.html +4 -3
  7. package/package.json +11 -10
  8. package/src/CdcDashboard.tsx +129 -124
  9. package/src/CdcDashboardComponent.tsx +316 -441
  10. package/src/DashboardContext.tsx +4 -1
  11. package/src/_stories/Dashboard.stories.tsx +79 -36
  12. package/src/_stories/_mock/api-filter-chart.json +11 -35
  13. package/src/_stories/_mock/api-filter-map.json +17 -31
  14. package/src/_stories/_mock/dashboard-gallery.json +523 -534
  15. package/src/_stories/_mock/multi-viz.json +378 -0
  16. package/src/_stories/_mock/pivot-filter.json +161 -0
  17. package/src/_stories/_mock/standalone-table.json +122 -0
  18. package/src/_stories/_mock/toggle-example.json +4035 -0
  19. package/src/components/DataDesignerModal.tsx +145 -0
  20. package/src/components/EditorWrapper/EditorWrapper.tsx +52 -0
  21. package/src/components/EditorWrapper/editor-wrapper.style.css +13 -0
  22. package/src/components/Filters.tsx +88 -0
  23. package/src/components/Grid.tsx +3 -1
  24. package/src/components/Header/FilterModal.tsx +506 -0
  25. package/src/components/Header/Header.tsx +25 -465
  26. package/src/components/Row.tsx +65 -29
  27. package/src/components/Toggle/Toggle.tsx +36 -0
  28. package/src/components/Toggle/index.tsx +1 -0
  29. package/src/components/Toggle/toggle-style.css +34 -0
  30. package/src/components/VisualizationRow.tsx +174 -0
  31. package/src/components/VisualizationsPanel.tsx +13 -3
  32. package/src/components/Widget.tsx +28 -126
  33. package/src/helpers/filterData.ts +75 -50
  34. package/src/helpers/generateValuesForFilter.ts +2 -12
  35. package/src/helpers/getApiFilterKey.ts +5 -0
  36. package/src/helpers/getFilteredData.ts +39 -0
  37. package/src/helpers/getUpdateConfig.ts +39 -22
  38. package/src/helpers/getVizConfig.ts +31 -0
  39. package/src/helpers/getVizRowColumnLocator.ts +9 -0
  40. package/src/helpers/iconHash.tsx +34 -0
  41. package/src/helpers/tests/filterData.test.ts +149 -0
  42. package/src/images/icon-toggle.svg +1 -0
  43. package/src/scss/grid.scss +10 -3
  44. package/src/scss/main.scss +11 -0
  45. package/src/store/dashboard.actions.ts +35 -3
  46. package/src/store/dashboard.reducer.ts +33 -2
  47. package/src/types/APIFilter.ts +4 -5
  48. package/src/types/ConfigRow.ts +13 -2
  49. package/src/types/DataSet.ts +11 -8
  50. package/src/types/InitialState.ts +2 -1
  51. package/src/types/SharedFilter.ts +6 -3
  52. package/src/types/Tab.ts +1 -0
@@ -3,6 +3,7 @@ import { getUpdateConfig } from '../helpers/getUpdateConfig'
3
3
  import { MultiDashboardConfig } from '../types/MultiDashboard'
4
4
  import DashboardActions from './dashboard.actions'
5
5
  import { devToolsWrapper } from '@cdc/core/helpers/withDevTools'
6
+ import { Tab } from '../types/Tab'
6
7
 
7
8
  const createBlankDashboard = () => ({
8
9
  dashboard: {
@@ -24,7 +25,7 @@ export type DashboardState = {
24
25
  filteredData: Object
25
26
  loading: boolean
26
27
  preview: boolean
27
- tabSelected: number
28
+ tabSelected: Tab
28
29
  }
29
30
 
30
31
  const reducer = (state: DashboardState, action: DashboardActions): DashboardState => {
@@ -40,7 +41,7 @@ const reducer = (state: DashboardState, action: DashboardActions): DashboardStat
40
41
  return { ...state, config, filteredData }
41
42
  }
42
43
  case 'SET_CONFIG': {
43
- return { ...state, config: action.payload }
44
+ return { ...state, config: { ...state.config, ...action.payload } }
44
45
  }
45
46
  case 'SET_DATA': {
46
47
  return { ...state, data: action.payload }
@@ -91,6 +92,11 @@ const reducer = (state: DashboardState, action: DashboardActions): DashboardStat
91
92
  newMultiDashboards[saveSlot] = { ...toSave, label }
92
93
  return applyMultiDashboards(state, newMultiDashboards)
93
94
  }
95
+ case 'SET_SHARED_FILTERS': {
96
+ const newSharedFilters = action.payload
97
+ const newDashboardConfig = { ...state.config.dashboard, sharedFilters: newSharedFilters }
98
+ return { ...state, config: { ...state.config, dashboard: newDashboardConfig } }
99
+ }
94
100
  case 'INITIALIZE_MULTIDASHBOARDS': {
95
101
  const label = 'New Dashboard 1'
96
102
  const toSave = _.pick(state.config, ['dashboard', 'visualizations', 'rows'])
@@ -103,6 +109,31 @@ const reducer = (state: DashboardState, action: DashboardActions): DashboardStat
103
109
  const newConfigFields = state.config.multiDashboards[slot]
104
110
  return { ...state, config: { ...state.config, ...newConfigFields, activeDashboard: slot } }
105
111
  }
112
+ case 'TOGGLE_ROW': {
113
+ const { rowIndex, colIndex } = action.payload
114
+ const newRows = state.config.rows.map((row, index) => {
115
+ if (index === rowIndex) {
116
+ const newColumns = row.columns.map((col, i) => ({ ...col, hide: i === colIndex }))
117
+ return { ...row, columns: newColumns }
118
+ }
119
+ return row
120
+ })
121
+ return { ...state, config: { ...state.config, rows: newRows } }
122
+ }
123
+ case 'UPDATE_VISUALIZATION': {
124
+ const { vizKey, configureData } = action.payload
125
+ return { ...state, config: { ...state.config, visualizations: { ...state.config.visualizations, [vizKey]: { ...state.config.visualizations[vizKey], ...configureData } } } }
126
+ }
127
+ case 'UPDATE_ROW': {
128
+ const { rowIndex, rowData } = action.payload
129
+ const newRows = state.config.rows.map((row, index) => {
130
+ if (index === rowIndex) {
131
+ return { ...row, ...rowData }
132
+ }
133
+ return row
134
+ })
135
+ return { ...state, config: { ...state.config, rows: newRows } }
136
+ }
106
137
  default:
107
138
  return state
108
139
  }
@@ -1,5 +1,4 @@
1
- export type APIFilter = Record<'apiEndpoint'|'valueSelector'|'textSelector', string> & {
2
- heirarchyLookup?: string
3
- autoLoad?: boolean
4
- defaultValue?: string
5
- }
1
+ export type APIFilter = Record<'apiEndpoint' | 'valueSelector' | 'textSelector', string> & {
2
+ autoLoad?: boolean
3
+ defaultValue?: string
4
+ }
@@ -1,6 +1,17 @@
1
- export type ConfigRow = {
1
+ import { ConfigureData } from '@cdc/core/types/ConfigureData'
2
+
3
+ type Col = {
2
4
  equalHeight?: boolean
3
5
  width: number | null
6
+ hide?: boolean
4
7
  widget?: string
5
8
  uuid?: string | number
6
- }[] & { uuid?: string | number }
9
+ }
10
+
11
+ export type ConfigRow = {
12
+ columns: Col[]
13
+ uuid?: string | number
14
+ toggle?: boolean
15
+ equalHeight?: boolean
16
+ multiVizColumn?: string
17
+ } & ConfigureData
@@ -1,8 +1,11 @@
1
- export type DataSet = {
2
- data: Object[]
3
- dataDescription: {}
4
- dataUrl: string
5
- runtimeDataUrl: string
6
- dataFileSourceType: string
7
- formattedData: Object[]
8
- }
1
+ import { ConfigureData } from '@cdc/core/types/ConfigureData'
2
+
3
+ export type DataSet = ConfigureData & {
4
+ dataFileFormat?: string
5
+ dataFileName?: string
6
+ dataFileSize?: number
7
+ preview?: boolean
8
+ dataUrl: string
9
+ runtimeDataUrl: string
10
+ dataFileSourceType: string
11
+ }
@@ -1,4 +1,5 @@
1
1
  import { DashboardConfig } from './DashboardConfig'
2
+ import { Tab } from './Tab'
2
3
 
3
4
  export type InitialState = {
4
5
  config: DashboardConfig
@@ -6,5 +7,5 @@ export type InitialState = {
6
7
  loading: boolean
7
8
  filteredData: Object
8
9
  preview: boolean
9
- tabSelected: number
10
+ tabSelected: Tab
10
11
  }
@@ -1,14 +1,17 @@
1
1
  import { APIFilter } from './APIFilter'
2
2
  export type SharedFilter = {
3
3
  type?: 'urlfilter' | 'datafilter' | ''
4
- fileName: string
4
+ fileName?: string
5
5
  filterBy?: 'Query String' | 'File Name'
6
6
  queryParameter?: string
7
- active?: string
7
+ setByQueryParameter?: string
8
+ active?: string | string[]
8
9
  queuedActive?: string
9
- usedBy?: string[]
10
+ usedBy?: (string | number)[] // if number used by whole row, else used by specific viz
10
11
  parents?: string[]
12
+ pivot?: string
11
13
  setBy?: string
14
+ selectLimit?: number
12
15
  columnName?: string
13
16
  resetLabel?: string
14
17
  showDropdown?: boolean
@@ -0,0 +1 @@
1
+ export type Tab = 'Dashboard Description' | 'Dashboard Filters' | 'Data Table Settings' | 'Dashboard Preview'