@cdc/dashboard 4.25.11 → 4.26.1

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 (51) hide show
  1. package/Dynamic_Data.md +66 -0
  2. package/dist/cdcdashboard.js +78783 -76370
  3. package/examples/api-dashboard-data.json +272 -0
  4. package/examples/api-dashboard-years.json +11 -0
  5. package/examples/api-geographies-data.json +11 -0
  6. package/examples/private/cat-y.json +1235 -0
  7. package/examples/private/chronic-dash.json +1584 -0
  8. package/examples/private/map-issue.json +2260 -0
  9. package/examples/private/mpinc-state-reports.json +2260 -0
  10. package/examples/private/nwss/rsv.json +1240 -0
  11. package/examples/private/simple-dash.json +490 -0
  12. package/examples/private/test-dash.json +0 -0
  13. package/examples/private/test123.json +491 -0
  14. package/examples/test-dashboard-simple.json +503 -0
  15. package/index.html +24 -25
  16. package/package.json +12 -11
  17. package/src/CdcDashboardComponent.tsx +18 -2
  18. package/src/_stories/Dashboard.DataSetup.stories.tsx +203 -0
  19. package/src/_stories/Dashboard.stories.tsx +385 -1
  20. package/src/_stories/_mock/filter-cascade.json +3350 -0
  21. package/src/_stories/_mock/gallery-data-bite-dashboard.json +3500 -0
  22. package/src/_stories/_mock/nested-parent-child-filters.json +392 -0
  23. package/src/_stories/_mock/parent-child-filters.json +233 -0
  24. package/src/components/DashboardFilters/DashboardFilters.tsx +20 -11
  25. package/src/components/DashboardFilters/DashboardFiltersEditor/DashboardFiltersEditor.tsx +89 -38
  26. package/src/components/DashboardFilters/DashboardFiltersEditor/components/FilterEditor.tsx +51 -29
  27. package/src/components/DashboardFilters/DashboardFiltersEditor/components/NestedDropDownDashboard.tsx +146 -9
  28. package/src/components/DashboardFilters/DashboardFiltersWrapper.tsx +11 -7
  29. package/src/components/DataDesignerModal.tsx +6 -1
  30. package/src/components/Header/Header.tsx +51 -20
  31. package/src/components/VisualizationRow.tsx +71 -5
  32. package/src/components/VisualizationsPanel/VisualizationsPanel.tsx +2 -3
  33. package/src/components/Widget/Widget.tsx +1 -1
  34. package/src/data/initial-state.js +1 -0
  35. package/src/helpers/addValuesToDashboardFilters.ts +15 -22
  36. package/src/helpers/changeFilterActive.ts +67 -65
  37. package/src/helpers/formatConfigBeforeSave.ts +6 -5
  38. package/src/helpers/getUpdateConfig.ts +91 -91
  39. package/src/helpers/tests/updatesChildFilters.test.ts +53 -22
  40. package/src/helpers/updateChildFilters.ts +50 -27
  41. package/src/scss/main.scss +141 -1
  42. package/src/test/CdcDashboard.test.jsx +9 -4
  43. package/src/types/Dashboard.ts +1 -0
  44. package/src/types/FilterStyles.ts +8 -7
  45. package/src/types/SharedFilter.ts +13 -0
  46. package/LICENSE +0 -201
  47. package/examples/private/DEV-10538.json +0 -407
  48. package/examples/private/DEV-11072.json +0 -7591
  49. package/examples/private/DEV-11405.json +0 -39112
  50. package/examples/private/delete.json +0 -32919
  51. package/examples/private/pedro.json +0 -1
package/Dynamic_Data.md CHANGED
@@ -26,6 +26,72 @@ Dashboards have a section called `sharedFilters` that is mapped over to gather a
26
26
 
27
27
  After all required selections are made the `sharedFilters` are mapped over to gather query parameters to attach to the dynamic datasets. If the sharedFilter item has a list of `usedBy` identifiers the query parameters will only apply to datasets that are mapped to those respective visualizations or rows, conversly if there's now `usedBy` or the list is empty the sharedFilter item will apply it's query parameter(s) to all dynamic datasets used by the current dashboard.
28
28
 
29
+ ## URL Filter Types: Query String vs File Name
30
+
31
+ URL filters support two different methods for modifying dataset URLs, specified by the `filterBy` property:
32
+
33
+ ### Query String Filters (`filterBy: "Query String"`)
34
+
35
+ Query String filters append the filter value as a URL query parameter. This is the most common approach for REST APIs.
36
+
37
+ **Configuration:**
38
+ - `filterBy`: Set to `"Query String"`
39
+ - `queryParameter`: The name of the query parameter to append (e.g., `"geography"`, `"state"`)
40
+ - `datasetKey`: **Auto-populated** from the widgets specified in `usedBy` - you don't need to specify this manually
41
+
42
+ **Example:**
43
+ ```json
44
+ {
45
+ "key": "Geography",
46
+ "type": "urlfilter",
47
+ "filterBy": "Query String",
48
+ "queryParameter": "geography",
49
+ "usedBy": ["chart1"],
50
+ "apiFilter": {
51
+ "apiEndpoint": "https://api.cdc.gov/states",
52
+ "valueSelector": "state",
53
+ "textSelector": "state_name"
54
+ }
55
+ }
56
+ ```
57
+
58
+ When a user selects "Alaska", the dataset URL `https://api.cdc.gov/data.json` becomes `https://api.cdc.gov/data.json?geography=Alaska`.
59
+
60
+ ### File Name Filters (`filterBy: "File Name"`)
61
+
62
+ File Name filters replace the filename portion of the URL. This is useful for APIs that use path-based routing or file-based data sources.
63
+
64
+ **Configuration:**
65
+ - `filterBy`: Set to `"File Name"`
66
+ - `fileName`: Template for the new filename, use `${query}` placeholder for the filter value
67
+ - `datasetKey`: **Required** - specifies which dataset's filename should be modified
68
+ - `whitespaceReplacement`: How to handle spaces in the filter value (`"Keep Spaces"`, `"Remove Spaces"`, or `"Replace With Underscore"`)
69
+
70
+ **Example:**
71
+ ```json
72
+ {
73
+ "key": "State",
74
+ "type": "urlfilter",
75
+ "filterBy": "File Name",
76
+ "fileName": "NSSPSubState${query}",
77
+ "datasetKey": "resp-data.json",
78
+ "whitespaceReplacement": "Remove Spaces",
79
+ "usedBy": ["chart1"],
80
+ "apiFilter": {
81
+ "apiEndpoint": "https://api.cdc.gov/states",
82
+ "valueSelector": "state"
83
+ }
84
+ }
85
+ ```
86
+
87
+ When a user selects "Alaska", the dataset URL `https://api.cdc.gov/data/default.json` becomes `https://api.cdc.gov/data/NSSPSubStateAlaska.json`.
88
+
89
+ ### Dataset Key Behavior
90
+
91
+ - **Query String filters**: The `datasetKey` is automatically determined from the widgets specified in the `usedBy` array. The system looks at each widget's `dataKey` property to identify which datasets should receive the query parameter.
92
+
93
+ - **File Name filters**: The `datasetKey` must be explicitly specified to indicate which dataset's filename should be modified. This is required because filename transformations apply to specific URLs.
94
+
29
95
  Example (2):
30
96
 
31
97
  ```