@cdc/dashboard 4.24.3 → 4.24.5

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 (37) hide show
  1. package/dist/cdcdashboard.js +148123 -105018
  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/index.html +2 -2
  6. package/package.json +9 -9
  7. package/src/CdcDashboard.tsx +8 -3
  8. package/src/CdcDashboardComponent.tsx +141 -290
  9. package/src/_stories/Dashboard.stories.tsx +52 -7
  10. package/src/_stories/_mock/markup-include.json +78 -0
  11. package/src/_stories/_mock/multi-dashboards.json +914 -0
  12. package/src/_stories/_mock/multi-viz.json +378 -0
  13. package/src/_stories/_mock/pivot-filter.json +2 -2
  14. package/src/_stories/_mock/standalone-table.json +2 -0
  15. package/src/components/DataDesignerModal.tsx +145 -0
  16. package/src/components/Grid.tsx +3 -1
  17. package/src/components/Header/FilterModal.tsx +63 -33
  18. package/src/components/MultiConfigTabs/MultiTabs.tsx +3 -2
  19. package/src/components/Row.tsx +50 -25
  20. package/src/components/Toggle/Toggle.tsx +6 -7
  21. package/src/components/VisualizationRow.tsx +183 -0
  22. package/src/components/VisualizationsPanel.tsx +26 -3
  23. package/src/components/Widget.tsx +21 -103
  24. package/src/helpers/filterData.ts +1 -1
  25. package/src/helpers/getFilteredData.ts +39 -0
  26. package/src/helpers/getUpdateConfig.ts +15 -0
  27. package/src/helpers/getVizConfig.ts +31 -0
  28. package/src/helpers/getVizRowColumnLocator.ts +9 -0
  29. package/src/scss/grid.scss +9 -2
  30. package/src/scss/main.scss +5 -0
  31. package/src/store/dashboard.actions.ts +6 -0
  32. package/src/store/dashboard.reducer.ts +33 -8
  33. package/src/types/ConfigRow.ts +12 -3
  34. package/src/types/DataSet.ts +11 -8
  35. package/src/types/SharedFilter.ts +1 -1
  36. package/src/components/EditorWrapper/EditorWrapper.tsx +0 -52
  37. package/src/components/EditorWrapper/editor-wrapper.style.css +0 -13
@@ -1,16 +1,20 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react'
2
+ import { faker } from '@faker-js/faker'
2
3
  import APIFiltersMapData from './_mock/api-filter-map.json'
3
4
  import APIFiltersChartData from './_mock/api-filter-chart.json'
4
5
  import ExampleConfig_1 from './_mock/dashboard-gallery.json'
5
6
  import ExampleConfig_2 from './_mock/dashboard-2.json'
6
7
  import ExampleConfig_3 from './_mock/dashboard_no_filter.json'
7
8
  import Dashboard_Filter from './_mock/dashboard-filter.json'
9
+ import MultiVizConfig from './_mock/multi-viz.json'
10
+ import MultiDashboardConfig from './_mock/multi-dashboards.json'
8
11
  import Dashboard from '../CdcDashboard'
9
12
  import StandaloneTable from './_mock/standalone-table.json'
10
13
  import PivotFitlerConfig from './_mock/pivot-filter.json'
11
14
  import { type DashboardConfig as Config } from '../types/DashboardConfig'
12
15
  import { userEvent, within } from '@storybook/testing-library'
13
16
  import ToggleExampleConfig from './_mock/toggle-example.json'
17
+ import _ from 'lodash'
14
18
 
15
19
  const meta: Meta<typeof Dashboard> = {
16
20
  title: 'Components/Pages/Dashboard',
@@ -21,44 +25,85 @@ type Story = StoryObj<typeof Dashboard>
21
25
 
22
26
  export const Example_1: Story = {
23
27
  args: {
24
- config: ExampleConfig_1
28
+ config: ExampleConfig_1,
29
+ isEditor: false
25
30
  }
26
31
  }
27
32
 
28
33
  export const Example_2: Story = {
29
34
  args: {
30
- config: ExampleConfig_2
35
+ config: ExampleConfig_2,
36
+ isEditor: false
31
37
  }
32
38
  }
33
39
 
34
40
  export const Example_3: Story = {
35
41
  args: {
36
- config: ExampleConfig_3
42
+ config: ExampleConfig_3,
43
+ isEditor: false
37
44
  }
38
45
  }
39
46
 
40
47
  export const Dashboard_Filters: Story = {
41
48
  args: {
42
- config: Dashboard_Filter
49
+ config: Dashboard_Filter,
50
+ isEditor: false
43
51
  }
44
52
  }
45
53
 
46
54
  export const StandAloneTable: Story = {
47
55
  args: {
48
- config: StandaloneTable
56
+ config: StandaloneTable,
57
+ isEditor: false
49
58
  }
50
59
  }
51
60
 
52
61
  export const ToggleExample: Story = {
53
62
  args: {
54
63
  config: ToggleExampleConfig,
55
- isEditor: true
64
+ isEditor: false
56
65
  }
57
66
  }
58
67
 
59
68
  export const PivotFilter: Story = {
60
69
  args: {
61
- config: PivotFitlerConfig
70
+ config: PivotFitlerConfig,
71
+ isEditor: false
72
+ }
73
+ }
74
+
75
+ faker.seed(123)
76
+
77
+ const countries = _.times(5, faker.location.country)
78
+ const categories = _.times(3, val => `category-${val + 1}`)
79
+
80
+ const data = []
81
+ countries.forEach((country, i) => {
82
+ categories.forEach((category, j) => {
83
+ if ((i + j) % 3 === 0) return
84
+ data.push({
85
+ Country: country,
86
+ 'Sample Categories': category,
87
+ Data: faker.number.int({ min: 5, max: 50 })
88
+ })
89
+ })
90
+ })
91
+
92
+ const multiVizData = {
93
+ 'valid-world-data.json': { data }
94
+ }
95
+
96
+ export const MultiVisualization: Story = {
97
+ args: {
98
+ config: { ...MultiVizConfig, datasets: multiVizData },
99
+ isEditor: false
100
+ }
101
+ }
102
+
103
+ export const MultiDashboard: Story = {
104
+ args: {
105
+ config: MultiDashboardConfig,
106
+ isEditor: false
62
107
  }
63
108
  }
64
109
 
@@ -0,0 +1,78 @@
1
+ {
2
+ "dashboard": {
3
+ "theme": "theme-blue"
4
+ },
5
+ "rows": [
6
+ [
7
+ {
8
+ "width": 12,
9
+ "widget": "markup-include1709307330120"
10
+ },
11
+ {},
12
+ {}
13
+ ]
14
+ ],
15
+ "visualizations": {
16
+ "markup-include1709307330120": {
17
+ "inlineHTML": "",
18
+ "markupSource": "inline",
19
+ "showHeader": false,
20
+ "srcUrl": "#example",
21
+ "theme": "theme-blue",
22
+ "title": "Markup Include",
23
+ "type": "markup-include",
24
+ "visual": {
25
+ "border": false,
26
+ "accent": false,
27
+ "background": false,
28
+ "hideBackgroundColor": false,
29
+ "borderColorTheme": false
30
+ },
31
+ "openModal": false,
32
+ "uid": "markup-include1709307330120",
33
+ "visualizationType": "markup-include",
34
+ "editing": false,
35
+ "data": {},
36
+ "validated": 4.23
37
+ }
38
+ },
39
+ "table": {
40
+ "label": "Data Table",
41
+ "show": false,
42
+ "showDownloadUrl": false,
43
+ "showVertical": true
44
+ },
45
+ "datasets": {
46
+ "valid-data-chart.csv": {
47
+ "data": [
48
+ {
49
+ "Race": "Hispanic or Latino",
50
+ "Age-adjusted rate": "644.2"
51
+ },
52
+ {
53
+ "Race": "Non-Hispanic American Indian",
54
+ "Age-adjusted rate": "636.1"
55
+ },
56
+ {
57
+ "Race": "Non-Hispanic Black",
58
+ "Age-adjusted rate": "563.7"
59
+ },
60
+ {
61
+ "Race": "Non-Hispanic Asian or Pacific Islander",
62
+ "Age-adjusted rate": "202.5"
63
+ },
64
+ {
65
+ "Race": "Non-Hispanic White",
66
+ "Age-adjusted rate": "183.6"
67
+ }
68
+ ],
69
+ "dataFileSize": 184,
70
+ "dataFileName": "valid-data-chart.csv",
71
+ "dataFileSourceType": "file",
72
+ "dataFileFormat": "CSV",
73
+ "preview": true
74
+ }
75
+ },
76
+ "type": "dashboard",
77
+ "runtime": {}
78
+ }