@cdc/dashboard 4.24.2 → 4.24.3

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 (38) hide show
  1. package/dist/cdcdashboard.js +98192 -85200
  2. package/examples/sankey.json +5218 -0
  3. package/index.html +3 -2
  4. package/package.json +11 -10
  5. package/src/CdcDashboard.tsx +124 -124
  6. package/src/CdcDashboardComponent.tsx +173 -186
  7. package/src/DashboardContext.tsx +4 -1
  8. package/src/_stories/Dashboard.stories.tsx +27 -5
  9. package/src/_stories/_mock/pivot-filter.json +163 -0
  10. package/src/_stories/_mock/standalone-table.json +122 -0
  11. package/src/_stories/_mock/toggle-example.json +4035 -0
  12. package/src/components/EditorWrapper/EditorWrapper.tsx +52 -0
  13. package/src/components/EditorWrapper/editor-wrapper.style.css +13 -0
  14. package/src/components/Filters.tsx +88 -0
  15. package/src/components/Header/FilterModal.tsx +480 -0
  16. package/src/components/Header/Header.tsx +25 -465
  17. package/src/components/Row.tsx +28 -17
  18. package/src/components/Toggle/Toggle.tsx +37 -0
  19. package/src/components/Toggle/index.tsx +1 -0
  20. package/src/components/Toggle/toggle-style.css +34 -0
  21. package/src/components/VisualizationsPanel.tsx +13 -3
  22. package/src/components/Widget.tsx +14 -30
  23. package/src/helpers/filterData.ts +72 -49
  24. package/src/helpers/generateValuesForFilter.ts +2 -12
  25. package/src/helpers/getApiFilterKey.ts +5 -0
  26. package/src/helpers/getUpdateConfig.ts +24 -22
  27. package/src/helpers/iconHash.tsx +34 -0
  28. package/src/helpers/tests/filterData.test.ts +149 -0
  29. package/src/images/icon-toggle.svg +1 -0
  30. package/src/scss/grid.scss +1 -1
  31. package/src/scss/main.scss +6 -0
  32. package/src/store/dashboard.actions.ts +19 -2
  33. package/src/store/dashboard.reducer.ts +9 -1
  34. package/src/types/ConfigRow.ts +2 -0
  35. package/src/types/DataSet.ts +7 -7
  36. package/src/types/InitialState.ts +2 -1
  37. package/src/types/SharedFilter.ts +5 -2
  38. package/src/types/Tab.ts +1 -0
@@ -1,5 +1,6 @@
1
1
  import type { DashboardConfig as Config } from '../types/DashboardConfig'
2
2
  import { type Action } from '@cdc/core/types/Action'
3
+ import { Tab } from '../types/Tab'
3
4
 
4
5
  type SET_CONFIG = Action<'SET_CONFIG', Config>
5
6
  type UPDATE_CONFIG = Action<'UPDATE_CONFIG', [Config, Object?]>
@@ -7,7 +8,7 @@ type SET_DATA = Action<'SET_DATA', Object>
7
8
  type SET_LOADING = Action<'SET_LOADING', boolean>
8
9
  type SET_PREVIEW = Action<'SET_PREVIEW', boolean>
9
10
  type SET_FILTERED_DATA = Action<'SET_FILTERED_DATA', Object>
10
- type SET_TAB_SELECTED = Action<'SET_TAB_SELECTED', number>
11
+ type SET_TAB_SELECTED = Action<'SET_TAB_SELECTED', Tab>
11
12
  type RENAME_DASHBOARD_TAB = Action<'RENAME_DASHBOARD_TAB', { current: string; new: string }>
12
13
  type INITIALIZE_MULTIDASHBOARDS = Action<'INITIALIZE_MULTIDASHBOARDS', undefined>
13
14
  type REMOVE_MULTIDASHBOARD_AT_INDEX = Action<'REMOVE_MULTIDASHBOARD_AT_INDEX', number>
@@ -15,6 +16,22 @@ type REORDER_MULTIDASHBOARDS = Action<'REORDER_MULTIDASHBOARDS', { currentIndex:
15
16
  type ADD_NEW_DASHBOARD = Action<'ADD_NEW_DASHBOARD', undefined>
16
17
  type SAVE_CURRENT_CHANGES = Action<'SAVE_CURRENT_CHANGES', undefined>
17
18
  type SWITCH_CONFIG = Action<'SWITCH_CONFIG', number>
19
+ type TOGGLE_ROW = Action<'TOGGLE_ROW', { rowIndex: number; colIndex: number }>
18
20
 
19
- type DashboardActions = ADD_NEW_DASHBOARD | SET_CONFIG | UPDATE_CONFIG | REMOVE_MULTIDASHBOARD_AT_INDEX | RENAME_DASHBOARD_TAB | REORDER_MULTIDASHBOARDS | SAVE_CURRENT_CHANGES | SET_DATA | SET_LOADING | SET_PREVIEW | SET_FILTERED_DATA | SET_TAB_SELECTED | SWITCH_CONFIG | INITIALIZE_MULTIDASHBOARDS
21
+ type DashboardActions =
22
+ | ADD_NEW_DASHBOARD
23
+ | SET_CONFIG
24
+ | UPDATE_CONFIG
25
+ | REMOVE_MULTIDASHBOARD_AT_INDEX
26
+ | RENAME_DASHBOARD_TAB
27
+ | REORDER_MULTIDASHBOARDS
28
+ | SAVE_CURRENT_CHANGES
29
+ | SET_DATA
30
+ | SET_LOADING
31
+ | SET_PREVIEW
32
+ | SET_FILTERED_DATA
33
+ | SET_TAB_SELECTED
34
+ | SWITCH_CONFIG
35
+ | INITIALIZE_MULTIDASHBOARDS
36
+ | TOGGLE_ROW
20
37
  export default DashboardActions
@@ -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 => {
@@ -103,6 +104,13 @@ const reducer = (state: DashboardState, action: DashboardActions): DashboardStat
103
104
  const newConfigFields = state.config.multiDashboards[slot]
104
105
  return { ...state, config: { ...state.config, ...newConfigFields, activeDashboard: slot } }
105
106
  }
107
+ case 'TOGGLE_ROW': {
108
+ const { rowIndex, colIndex } = action.payload
109
+ const newRows = state.config.rows.map((row, index) => {
110
+ return index === rowIndex ? row.map((col, i) => ({ ...col, hide: i !== colIndex })) : row
111
+ })
112
+ return { ...state, config: { ...state.config, rows: newRows } }
113
+ }
106
114
  default:
107
115
  return state
108
116
  }
@@ -1,6 +1,8 @@
1
1
  export type ConfigRow = {
2
2
  equalHeight?: boolean
3
3
  width: number | null
4
+ toggle?: boolean
5
+ hide?: boolean
4
6
  widget?: string
5
7
  uuid?: string | number
6
8
  }[] & { uuid?: string | number }
@@ -1,8 +1,8 @@
1
1
  export type DataSet = {
2
- data: Object[]
3
- dataDescription: {}
4
- dataUrl: string
5
- runtimeDataUrl: string
6
- dataFileSourceType: string
7
- formattedData: Object[]
8
- }
2
+ data: Object[]
3
+ dataDescription: {}
4
+ dataUrl: string
5
+ runtimeDataUrl: string
6
+ dataFileSourceType: string
7
+ formattedData: Object[]
8
+ }
@@ -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
10
  usedBy?: string[]
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'