@cdc/dashboard 4.25.11 → 4.26.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.
- package/Dynamic_Data.md +66 -0
- package/dist/cdcdashboard-8NmHlKRI.es.js +15 -0
- package/dist/cdcdashboard-BPoPzKPz.es.js +6 -0
- package/dist/cdcdashboard-Cf9_fbQf.es.js +6 -0
- package/dist/{cdcdashboard-dgT_1dIT.es.js → cdcdashboard-DQ00cQCm.es.js} +1 -20
- package/dist/cdcdashboard-jiQQPkty.es.js +6 -0
- package/dist/cdcdashboard.js +83537 -86913
- package/examples/api-dashboard-data.json +272 -0
- package/examples/api-dashboard-years.json +11 -0
- package/examples/api-geographies-data.json +11 -0
- package/examples/default.json +522 -133
- package/examples/nested-dropdown.json +6985 -0
- package/examples/private/abc.json +467 -0
- package/examples/private/cat-y.json +1235 -0
- package/examples/private/chronic-dash.json +1584 -0
- package/examples/private/dash.json +12696 -0
- package/examples/private/map-issue.json +2260 -0
- package/examples/private/mpinc-state-reports.json +2260 -0
- package/examples/private/npcr.json +1 -0
- package/examples/private/nwss/rsv.json +1240 -0
- package/examples/private/simple-dash.json +490 -0
- package/examples/private/test-dash.json +0 -0
- package/examples/private/test.json +125407 -0
- package/examples/private/test123.json +491 -0
- package/examples/private/timeline-data.json +4994 -0
- package/examples/private/timeline.json +1708 -0
- package/examples/test-api-filter-reset.json +8 -4
- package/examples/test-dashboard-simple.json +503 -0
- package/examples/tp5-gauges.json +196 -0
- package/examples/tp5-test.json +266 -0
- package/index.html +1 -30
- package/package.json +39 -40
- package/src/CdcDashboardComponent.tsx +18 -5
- package/src/_stories/Dashboard.DataSetup.stories.tsx +204 -0
- package/src/_stories/Dashboard.stories.tsx +407 -1
- package/src/_stories/_mock/dashboard-line-chart-angles.json +1030 -0
- package/src/_stories/_mock/filter-cascade.json +3350 -0
- package/src/_stories/_mock/gallery-data-bite-dashboard.json +3500 -0
- package/src/_stories/_mock/nested-parent-child-filters.json +392 -0
- package/src/_stories/_mock/parent-child-filters.json +233 -0
- package/src/_stories/_mock/tp5-test.json +267 -0
- package/src/components/DashboardFilters/DashboardFilters.tsx +20 -11
- package/src/components/DashboardFilters/DashboardFiltersEditor/DashboardFiltersEditor.tsx +92 -38
- package/src/components/DashboardFilters/DashboardFiltersEditor/components/FilterEditor.tsx +56 -30
- package/src/components/DashboardFilters/DashboardFiltersEditor/components/NestedDropDownDashboard.tsx +151 -10
- package/src/components/DashboardFilters/DashboardFiltersWrapper.tsx +11 -7
- package/src/components/DataDesignerModal.tsx +6 -1
- package/src/components/Header/Header.tsx +51 -20
- package/src/components/VisualizationRow.tsx +76 -5
- package/src/components/VisualizationsPanel/VisualizationsPanel.tsx +2 -20
- package/src/components/Widget/Widget.tsx +1 -1
- package/src/data/initial-state.js +1 -0
- package/src/helpers/addValuesToDashboardFilters.ts +30 -31
- package/src/helpers/apiFilterHelpers.ts +28 -32
- package/src/helpers/changeFilterActive.ts +67 -65
- package/src/helpers/formatConfigBeforeSave.ts +6 -5
- package/src/helpers/getUpdateConfig.ts +91 -91
- package/src/helpers/tests/addValuesToDashboardFilters.test.ts +141 -44
- package/src/helpers/tests/apiFilterHelpers.test.ts +523 -420
- package/src/helpers/tests/updatesChildFilters.test.ts +53 -22
- package/src/helpers/updateChildFilters.ts +50 -27
- package/src/scss/main.scss +144 -1
- package/src/test/CdcDashboard.test.jsx +9 -4
- package/src/types/Dashboard.ts +1 -0
- package/src/types/FilterStyles.ts +8 -7
- package/src/types/SharedFilter.ts +13 -0
- package/vite.config.js +7 -1
- package/LICENSE +0 -201
- package/dist/cdcdashboard-BnB1QM5d.es.js +0 -361528
- package/dist/cdcdashboard-Ct2SB0vL.es.js +0 -231049
- package/dist/cdcdashboard-D6CG2-Hb.es.js +0 -39377
- package/dist/cdcdashboard-MXgURbdZ.es.js +0 -39194
- package/examples/private/DEV-10538.json +0 -407
- package/examples/private/DEV-11072.json +0 -7591
- package/examples/private/DEV-11405.json +0 -39112
- package/examples/private/delete.json +0 -32919
- package/examples/private/pedro.json +0 -1
|
@@ -1,44 +1,141 @@
|
|
|
1
|
-
import { SharedFilter } from '../../types/SharedFilter'
|
|
2
|
-
import { addValuesToDashboardFilters } from '../addValuesToDashboardFilters'
|
|
3
|
-
|
|
4
|
-
describe('addValuesToDashboardFilters', () => {
|
|
5
|
-
const colA = { columnName: 'colA', id: 11, active: 'apple', values: [], type: 'datafilter' } as SharedFilter
|
|
6
|
-
const colB = { columnName: 'colB', id: 22, active: '1', values: [], type: 'datafilter' } as SharedFilter
|
|
7
|
-
const colC = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
it('
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
import { SharedFilter } from '../../types/SharedFilter'
|
|
2
|
+
import { addValuesToDashboardFilters } from '../addValuesToDashboardFilters'
|
|
3
|
+
|
|
4
|
+
describe('addValuesToDashboardFilters', () => {
|
|
5
|
+
const colA = { columnName: 'colA', id: 11, active: 'apple', values: [], type: 'datafilter' } as SharedFilter
|
|
6
|
+
const colB = { columnName: 'colB', id: 22, active: '1', values: [], type: 'datafilter' } as SharedFilter
|
|
7
|
+
const colC = {
|
|
8
|
+
columnName: 'colC',
|
|
9
|
+
id: 33,
|
|
10
|
+
values: [],
|
|
11
|
+
setByQueryParameter: 'colC',
|
|
12
|
+
type: 'datafilter'
|
|
13
|
+
} as SharedFilter
|
|
14
|
+
|
|
15
|
+
const data = {
|
|
16
|
+
key: [
|
|
17
|
+
{ colA: 'apple', colB: 3, colC: 'abc' },
|
|
18
|
+
{ colA: 'apple', colB: 1, colC: 'bcd' },
|
|
19
|
+
{ colA: 'pear', colB: 4, colC: 'test' }
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
const filters = [colA, colC, colB]
|
|
23
|
+
it('adds filter values', () => {
|
|
24
|
+
const newFilters = addValuesToDashboardFilters(filters, data)
|
|
25
|
+
expect(newFilters[0].values).toEqual(['apple', 'pear'])
|
|
26
|
+
})
|
|
27
|
+
it('converts to multiselect', () => {
|
|
28
|
+
colA.multiSelect = true
|
|
29
|
+
const newFilters = addValuesToDashboardFilters(filters, data)
|
|
30
|
+
expect(newFilters[0].active).toEqual(['apple'])
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('sets active value by query string', () => {
|
|
34
|
+
delete window.location
|
|
35
|
+
window.location = new URL('https://www.example.com?colC=test')
|
|
36
|
+
const newFilters = addValuesToDashboardFilters(filters, data)
|
|
37
|
+
expect(newFilters[1].active).toEqual('test')
|
|
38
|
+
})
|
|
39
|
+
const colA2 = {
|
|
40
|
+
apiFilter: { valueSelector: 'colA' },
|
|
41
|
+
id: 11,
|
|
42
|
+
active: 'apple',
|
|
43
|
+
values: [],
|
|
44
|
+
type: 'urlfilter'
|
|
45
|
+
} as SharedFilter
|
|
46
|
+
const colB2 = {
|
|
47
|
+
apiFilter: { valueSelector: 'colB' },
|
|
48
|
+
id: 22,
|
|
49
|
+
active: '1',
|
|
50
|
+
values: [],
|
|
51
|
+
type: 'urlfilter'
|
|
52
|
+
} as SharedFilter
|
|
53
|
+
const colC2 = {
|
|
54
|
+
apiFilter: { valueSelector: 'colC' },
|
|
55
|
+
id: 33,
|
|
56
|
+
values: [],
|
|
57
|
+
setByQueryParameter: 'colC',
|
|
58
|
+
type: 'urlfilter'
|
|
59
|
+
} as SharedFilter
|
|
60
|
+
const filters2 = [colA2, colC2, colB2]
|
|
61
|
+
it('skips urlfilters', () => {
|
|
62
|
+
// urlfilter reloading happens in the dashboard in the loadAPIFilters function
|
|
63
|
+
delete window.location
|
|
64
|
+
window.location = new URL('https://www.example.com?colC=test')
|
|
65
|
+
const newFilters = addValuesToDashboardFilters(filters2, data)
|
|
66
|
+
expect(newFilters[1].active).toEqual(undefined)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('respects nested dropdown default values for both group and subgroup', () => {
|
|
70
|
+
const nestedData = {
|
|
71
|
+
key: [
|
|
72
|
+
{ year: '2022', quarter: 'Q1', region: 'North' },
|
|
73
|
+
{ year: '2022', quarter: 'Q2', region: 'North' },
|
|
74
|
+
{ year: '2023', quarter: 'Q1', region: 'North' },
|
|
75
|
+
{ year: '2023', quarter: 'Q2', region: 'North' },
|
|
76
|
+
{ year: '2023', quarter: 'Q3', region: 'North' },
|
|
77
|
+
{ year: '2024', quarter: 'Q1', region: 'North' }
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const nestedFilter = {
|
|
82
|
+
columnName: 'year',
|
|
83
|
+
id: 1,
|
|
84
|
+
values: ['2022', '2023', '2024'],
|
|
85
|
+
type: 'datafilter',
|
|
86
|
+
filterStyle: 'nested-dropdown',
|
|
87
|
+
defaultValue: '2023',
|
|
88
|
+
subGrouping: {
|
|
89
|
+
columnName: 'quarter',
|
|
90
|
+
defaultValue: 'Q2',
|
|
91
|
+
valuesLookup: {
|
|
92
|
+
'2022': { values: ['Q1', 'Q2'] },
|
|
93
|
+
'2023': { values: ['Q1', 'Q2', 'Q3'] },
|
|
94
|
+
'2024': { values: ['Q1'] }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} as SharedFilter
|
|
98
|
+
|
|
99
|
+
const result = addValuesToDashboardFilters([nestedFilter], nestedData)
|
|
100
|
+
|
|
101
|
+
// Should use configured defaultValue for main group
|
|
102
|
+
expect(result[0].active).toBe('2023')
|
|
103
|
+
|
|
104
|
+
// Should use configured defaultValue for subgroup
|
|
105
|
+
expect(result[0].subGrouping.active).toBe('Q2')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('uses first available subgroup value when defaultValue is not in current group', () => {
|
|
109
|
+
const nestedData = {
|
|
110
|
+
key: [
|
|
111
|
+
{ year: '2022', quarter: 'Q1', region: 'North' },
|
|
112
|
+
{ year: '2024', quarter: 'Q1', region: 'North' }
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const nestedFilter = {
|
|
117
|
+
columnName: 'year',
|
|
118
|
+
id: 1,
|
|
119
|
+
values: ['2022', '2024'],
|
|
120
|
+
type: 'datafilter',
|
|
121
|
+
filterStyle: 'nested-dropdown',
|
|
122
|
+
defaultValue: '2024',
|
|
123
|
+
subGrouping: {
|
|
124
|
+
columnName: 'quarter',
|
|
125
|
+
defaultValue: 'Q2', // Q2 doesn't exist for 2024
|
|
126
|
+
valuesLookup: {
|
|
127
|
+
'2022': { values: ['Q1'] },
|
|
128
|
+
'2024': { values: ['Q1'] }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} as SharedFilter
|
|
132
|
+
|
|
133
|
+
const result = addValuesToDashboardFilters([nestedFilter], nestedData)
|
|
134
|
+
|
|
135
|
+
// Should use configured defaultValue for main group
|
|
136
|
+
expect(result[0].active).toBe('2024')
|
|
137
|
+
|
|
138
|
+
// Should fall back to first available value since Q2 doesn't exist for 2024
|
|
139
|
+
expect(result[0].subGrouping.active).toBe('Q1')
|
|
140
|
+
})
|
|
141
|
+
})
|