@cdc/core 4.24.1 → 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 (71) hide show
  1. package/assets/icon-sankey.svg +1 -0
  2. package/assets/icon-table.svg +1 -0
  3. package/components/DataTable/DataTable.tsx +44 -15
  4. package/components/DataTable/DataTableStandAlone.tsx +15 -0
  5. package/components/DataTable/components/CellAnchor.tsx +3 -1
  6. package/components/DataTable/components/ChartHeader.tsx +48 -12
  7. package/components/DataTable/components/DataTableEditorPanel.tsx +42 -0
  8. package/components/DataTable/components/MapHeader.tsx +10 -5
  9. package/components/DataTable/helpers/customColumns.ts +4 -2
  10. package/components/DataTable/helpers/customSort.ts +9 -0
  11. package/components/DataTable/helpers/getChartCellValue.ts +5 -3
  12. package/components/DataTable/helpers/getDataSeriesColumns.ts +10 -2
  13. package/components/DataTable/helpers/getSeriesName.ts +15 -20
  14. package/components/DataTable/helpers/mapCellMatrix.tsx +4 -0
  15. package/components/DataTable/types/TableConfig.ts +12 -37
  16. package/components/EditorPanel/ColumnsEditor.tsx +311 -0
  17. package/components/EditorPanel/DataTableEditor.tsx +27 -28
  18. package/components/Filters.jsx +35 -16
  19. package/components/MultiSelect/MultiSelect.tsx +39 -20
  20. package/components/MultiSelect/multiselect.styles.css +44 -27
  21. package/components/NestedDropdown/NestedDropdown.tsx +257 -0
  22. package/components/NestedDropdown/index.ts +1 -0
  23. package/components/NestedDropdown/nesteddropdown.styles.css +70 -0
  24. package/components/Table/Table.tsx +1 -1
  25. package/components/_stories/MultiSelect.stories.tsx +10 -1
  26. package/components/_stories/NestedDropdown.stories.tsx +58 -0
  27. package/components/createBarElement.jsx +117 -0
  28. package/components/elements/ScreenReaderText.tsx +8 -0
  29. package/components/elements/SkipTo.tsx +14 -0
  30. package/components/ui/Icon.tsx +5 -1
  31. package/components/ui/Title/Title.scss +7 -1
  32. package/components/ui/Title/index.tsx +3 -3
  33. package/components/ui/Tooltip.jsx +1 -1
  34. package/components/ui/_stories/Colors.stories.tsx +92 -0
  35. package/components/ui/_stories/Icon.stories.tsx +17 -10
  36. package/data/colorPalettes.js +1 -6
  37. package/helpers/cove/accessibility.ts +23 -0
  38. package/helpers/cove/date.ts +19 -0
  39. package/helpers/coveUpdateWorker.js +4 -0
  40. package/helpers/fetchRemoteData.js +5 -5
  41. package/helpers/getViewport.ts +23 -0
  42. package/helpers/isDomainExternal.js +14 -0
  43. package/helpers/isSolr.js +13 -0
  44. package/helpers/queryStringUtils.js +26 -0
  45. package/helpers/tests/updateFieldFactory.test.ts +89 -0
  46. package/helpers/updateFieldFactory.ts +38 -0
  47. package/helpers/useDataVizClasses.js +2 -2
  48. package/helpers/ver/4.24.3.js +25 -0
  49. package/helpers/withDevTools.ts +50 -0
  50. package/package.json +4 -3
  51. package/styles/_data-table.scss +2 -20
  52. package/styles/_global-variables.scss +75 -0
  53. package/styles/base.scss +97 -69
  54. package/types/Action.ts +1 -0
  55. package/types/Axis.ts +3 -0
  56. package/types/BaseVisualizationType.ts +1 -0
  57. package/types/BoxPlot.ts +21 -0
  58. package/types/Column.ts +1 -0
  59. package/types/ConfidenceInterval.ts +1 -0
  60. package/types/General.ts +9 -0
  61. package/types/Legend.ts +18 -0
  62. package/types/Region.ts +10 -0
  63. package/types/Runtime.ts +3 -1
  64. package/types/Table.ts +5 -2
  65. package/types/UpdateFieldFunc.ts +1 -1
  66. package/types/ViewPort.ts +2 -0
  67. package/types/Visualization.ts +23 -5
  68. package/types/WCMSProps.ts +11 -0
  69. package/components/DataTable/components/SkipNav.tsx +0 -7
  70. package/helpers/cove/date.js +0 -9
  71. package/helpers/getViewport.js +0 -21
@@ -0,0 +1,75 @@
1
+ $colors: (
2
+ 'baseColor': #333,
3
+ 'blue': #005eaa,
4
+ 'lightestGray': #f2f2f2,
5
+ 'lightGray': #c7c7c7,
6
+ 'mediumGray': #565656,
7
+ 'darkGray': #333,
8
+ 'red': #d8000c,
9
+ 'white': #fff,
10
+
11
+ 'primary': #005eaa,
12
+ 'secondary': #88c3ea,
13
+ 'tertiary': #c0e9ff,
14
+ 'quaternary': #edf9ff,
15
+
16
+ 'purple-primary': #712177,
17
+ 'purple-secondary': #b890bb,
18
+ 'purple-tertiary': #e3d3e4,
19
+ 'purple-quaternary': #f7f2f7,
20
+
21
+ 'brown-primary': #705043,
22
+ 'brown-secondary': #ad907b,
23
+ 'brown-tertiary': #d7ccc8,
24
+ 'brown-quaternary': #f2ebe8,
25
+
26
+ 'teal-primary': #00695c,
27
+ 'teal-secondary': #4ebaaa,
28
+ 'teal-tertiary': #ceece7,
29
+ 'teal-quaternary': #ebf7f5,
30
+
31
+ 'pink-primary': #af4448,
32
+ 'pink-secondary': #e57373,
33
+ 'pink-tertiary': #ffc2c2,
34
+ 'pink-quaternary': #ffe7e7,
35
+
36
+ 'orange-primary': #bb4d00,
37
+ 'orange-secondary': #ffad42,
38
+ 'orange-tertiary': #ffe97d,
39
+ 'orange-quaternary': #fff4cf,
40
+
41
+ 'slate-primary': #29434e,
42
+ 'slate-secondary': #7e9ba5,
43
+ 'slate-tertiary': #b6c6d2,
44
+ 'slate-quaternary': #e2e8ed,
45
+
46
+ 'indigo-primary': #26418f,
47
+ 'indigo-secondary': #92a6dd,
48
+ 'indigo-tertiary': #dee8ff,
49
+ 'indigo-quaternary': #f2f6ff,
50
+
51
+ 'cyan-primary': #006778,
52
+ 'cyan-secondary': #65b0bd,
53
+ 'cyan-tertiary': #cce5e9,
54
+ 'cyan-quaternary': #ebf5f6,
55
+
56
+ 'green-primary': #4b830d,
57
+ 'green-secondary': #84bc49,
58
+ 'green-tertiary': #dcedc8,
59
+ 'green-quaternary': #f1f8e9,
60
+
61
+ 'amber-primary': #fbab18,
62
+ 'amber-secondary': #ffd54f,
63
+ 'amber-tertiary': #ffecb3,
64
+ 'amber-quaternary': #fff7e1,
65
+ );
66
+
67
+ @mixin theme() {
68
+ :root {
69
+ @each $key, $value in $colors {
70
+ --#{$key}: #{$value};
71
+ }
72
+ }
73
+ }
74
+
75
+ @include theme();
package/styles/base.scss CHANGED
@@ -51,6 +51,7 @@
51
51
  // Imports
52
52
  @import 'reset';
53
53
  @import 'variables';
54
+ @import 'global-variables';
54
55
  @import 'mixins';
55
56
  @import 'filters';
56
57
 
@@ -58,6 +59,10 @@ body.post-type-cdc_visualization .visx-tooltip {
58
59
  z-index: 1000000;
59
60
  }
60
61
 
62
+ body.post-type-cdc_visualization .cdc-editor .configure .editor-panel {
63
+ top: 0 !important;
64
+ }
65
+
61
66
  .cdc-open-viz-module {
62
67
  position: relative;
63
68
  color: $baseColor;
@@ -71,73 +76,96 @@ body.post-type-cdc_visualization .visx-tooltip {
71
76
  @import 'button-section';
72
77
  @import 'series-list';
73
78
  @import 'typography';
74
- }
75
79
 
76
- $theme: (
77
- 'amber': (
78
- '#fbab18',
79
- '#ffd54f',
80
- '#ffecb3',
81
- '#fff7e1'
82
- ),
83
- 'blue': (
84
- '#005eaa',
85
- '#88c3ea',
86
- '#c0e9ff',
87
- '#edf9ff'
88
- ),
89
- 'brown': (
90
- '#705043',
91
- '#ad907b',
92
- '#d7ccc8',
93
- '#f2ebe8'
94
- ),
95
- 'cyan': (
96
- '#006778',
97
- '#65b0bd',
98
- '#cce5e9',
99
- '#ebf5f6'
100
- ),
101
- 'green': (
102
- '#4b830d',
103
- '#84bc49',
104
- '#dcedc8',
105
- '#f1f8e9'
106
- ),
107
- 'indigo': (
108
- '#26418f',
109
- '#92a6dd',
110
- '#dee8ff',
111
- '#f2f6ff'
112
- ),
113
- 'orange': (
114
- '#bb4d00',
115
- '#ffad42',
116
- '#ffe97d',
117
- '#fff4cf'
118
- ),
119
- 'pink': (
120
- '#af4448',
121
- '#e57373',
122
- '#ffc2c2',
123
- '#ffe7e7'
124
- ),
125
- 'purple': (
126
- '#712177',
127
- '#b890bb',
128
- '#e3d3e4',
129
- '#f7f2f7'
130
- ),
131
- 'slate': (
132
- '#29434e',
133
- '#7e9ba5',
134
- '#b6c6d2',
135
- '#e2e8ed'
136
- ),
137
- 'teal': (
138
- '#00695c',
139
- '#4ebaaa',
140
- '#ceece7',
141
- '#ebf7f5'
142
- )
143
- );
80
+ // Force printing chart images
81
+ -webkit-print-color-adjust: exact !important; /* Chrome, Safari 6 – 15.3, Edge */
82
+ color-adjust: exact !important; /* Firefox 48 – 96 */
83
+ print-color-adjust: exact !important; /* Firefox 97+, Safari 15.4+ */
84
+
85
+ .editor-panel.cove {
86
+ position: absolute;
87
+ height: 100vh;
88
+ top: 0;
89
+ max-width: 350px;
90
+ width: 350px;
91
+
92
+ .editor-toggle {
93
+ position: absolute !important;
94
+ top: 10px !important;
95
+ }
96
+
97
+ .editor-panel {
98
+ position: absolute !important;
99
+ top: 0 !important;
100
+ }
101
+ }
102
+
103
+ $theme: (
104
+ 'amber': (
105
+ '#fbab18',
106
+ '#ffd54f',
107
+ '#ffecb3',
108
+ '#fff7e1'
109
+ ),
110
+ 'blue': (
111
+ '#005eaa',
112
+ '#88c3ea',
113
+ '#c0e9ff',
114
+ '#edf9ff'
115
+ ),
116
+ 'brown': (
117
+ '#705043',
118
+ '#ad907b',
119
+ '#d7ccc8',
120
+ '#f2ebe8'
121
+ ),
122
+ 'cyan': (
123
+ '#006778',
124
+ '#65b0bd',
125
+ '#cce5e9',
126
+ '#ebf5f6'
127
+ ),
128
+ 'green': (
129
+ '#4b830d',
130
+ '#84bc49',
131
+ '#dcedc8',
132
+ '#f1f8e9'
133
+ ),
134
+ 'indigo': (
135
+ '#26418f',
136
+ '#92a6dd',
137
+ '#dee8ff',
138
+ '#f2f6ff'
139
+ ),
140
+ 'orange': (
141
+ '#bb4d00',
142
+ '#ffad42',
143
+ '#ffe97d',
144
+ '#fff4cf'
145
+ ),
146
+ 'pink': (
147
+ '#af4448',
148
+ '#e57373',
149
+ '#ffc2c2',
150
+ '#ffe7e7'
151
+ ),
152
+ 'purple': (
153
+ '#712177',
154
+ '#b890bb',
155
+ '#e3d3e4',
156
+ '#f7f2f7'
157
+ ),
158
+ 'slate': (
159
+ '#29434e',
160
+ '#7e9ba5',
161
+ '#b6c6d2',
162
+ '#e2e8ed'
163
+ ),
164
+ 'teal': (
165
+ '#00695c',
166
+ '#4ebaaa',
167
+ '#ceece7',
168
+ '#ebf7f5'
169
+ )
170
+ );
171
+ }
@@ -0,0 +1 @@
1
+ export type Action<T, P> = { type: T; payload?: P }
package/types/Axis.ts CHANGED
@@ -5,6 +5,7 @@ export type Anchor = {
5
5
  }
6
6
 
7
7
  export type Axis = {
8
+ scalePadding: number
8
9
  anchors?: Anchor[]
9
10
  dataKey: string
10
11
  dateDisplayFormat: string
@@ -22,6 +23,7 @@ export type Axis = {
22
23
  maxTickRotation?: number
23
24
  min?: string
24
25
  numTicks?: number
26
+ paddingPercent?: number
25
27
  rightAxisSize?: number
26
28
  rightHideAxis?: boolean
27
29
  rightHideLabel?: boolean
@@ -31,6 +33,7 @@ export type Axis = {
31
33
  rightMax?: string
32
34
  rightNumTicks?: number
33
35
  sortDates?: boolean
36
+ sortKey?: string
34
37
  showTargetLabel?: boolean
35
38
  size?: number
36
39
  target?: number
@@ -0,0 +1 @@
1
+ export type BaseVisualizationType = 'dashboard' | 'chart' | 'map' | 'data-bite' | 'waffle-chart' | 'markup-include' | 'filtered-text' | 'filter-dropdowns' | 'table' | 'navigation'
@@ -0,0 +1,21 @@
1
+ export type BoxPlot = {
2
+ tableData: Object[]
3
+ labels: {
4
+ mean: string
5
+ maximum: string
6
+ minimum: string
7
+ iqr: string
8
+ median: string
9
+ q1: string
10
+ q3: string
11
+ outliers: string
12
+ values: string
13
+ total: string
14
+ lowerBounds: string
15
+ upperBounds: string
16
+ }
17
+ plots: []
18
+ categories: string[]
19
+ firstQuartilePercentage: number
20
+ geoType: string
21
+ }
package/types/Column.ts CHANGED
@@ -6,6 +6,7 @@ export type Column = {
6
6
  roundToPlace: number
7
7
  commas: boolean
8
8
  dataTable: boolean
9
+ showInViz: boolean
9
10
  startingPoint: string
10
11
  series?: string
11
12
  tooltips: boolean
@@ -0,0 +1 @@
1
+ export type ConfidenceInterval = Record<'lower' | 'upper', number | string>
@@ -0,0 +1,9 @@
1
+ import { BoxPlot } from './BoxPlot'
2
+
3
+ export type General = {
4
+ boxplot: BoxPlot
5
+ geoType: string
6
+ type: string
7
+ showDownloadButton: boolean
8
+ allowMapZoom?: boolean
9
+ }
@@ -0,0 +1,18 @@
1
+ export type Legend = {
2
+ additionalCategories: string[]
3
+ // general legend onClick behavior
4
+ behavior: 'highlight' | 'isolate' | string
5
+ axisAlign: boolean
6
+ colorCode: string
7
+ description: string
8
+ // show or hide the legend
9
+ hide: boolean
10
+ highlightOnHover: boolean
11
+ label: string
12
+ lineMode: boolean
13
+ position: string
14
+ reverseLabelOrder: boolean
15
+ singleRow: boolean
16
+ type: string
17
+ verticalSorted: boolean
18
+ }
@@ -0,0 +1,10 @@
1
+ export type Region = {
2
+ from: string
3
+ to: string
4
+ label: string
5
+ color: string
6
+ background: string
7
+ range: 'Custom' | string
8
+ fromType: 'Fixed' | 'Previous Days'
9
+ toType: 'Fixed' | 'Last Date'
10
+ }
package/types/Runtime.ts CHANGED
@@ -23,7 +23,9 @@ export type Runtime = {
23
23
  xAxis: Axis
24
24
  yAxis: Axis
25
25
  seriesKeys: any[]
26
- seriesLabels: string[]
26
+ seriesLabels: Record<string, any>
27
27
  seriesLabelsAll: string[]
28
28
  editorErrorMessage: string
29
+ lineSeriesKeys: any[]
30
+ horizontal: boolean
29
31
  }
package/types/Table.ts CHANGED
@@ -11,8 +11,11 @@ export type Table = {
11
11
  showDataTableLink?: boolean
12
12
  showDownloadUrl?: boolean
13
13
  download?: boolean
14
- showDownloadImgButton?: boolean
15
- showDownloadPdfButton?: boolean
16
14
  customTableConfig?: boolean
17
15
  excludeColumns?: string[]
16
+ showDownloadImgButton?: boolean
17
+ showDownloadPdfButton?: boolean
18
+ downloadImageButton?: boolean
19
+ downloadPdfButton?: boolean
20
+ dateDisplayFormat?: string
18
21
  }
@@ -1 +1 @@
1
- export type UpdateFieldFunc<T> = (section: string | null, subsection: string | null, fieldName: string, value: T) => void
1
+ export type UpdateFieldFunc<T> = (section: string | null, subsection: string | number | null, fieldName: string | number, value: T) => void
@@ -0,0 +1,2 @@
1
+ import { viewports } from '../helpers/getViewport'
2
+ export type ViewPort = keyof typeof viewports
@@ -1,21 +1,39 @@
1
+ import { Legend } from './Legend'
2
+ import { Axis } from './Axis'
3
+ import { Column } from './Column'
4
+ import { Series } from './Series'
5
+ import { Table } from './Table'
6
+ import { ConfidenceInterval } from './ConfidenceInterval'
7
+ import { BaseVisualizationType } from './BaseVisualizationType'
8
+
1
9
  export type Visualization = {
2
10
  autoLoad: boolean
11
+ columns: Record<string, Column>
12
+ confidenceKeys: ConfidenceInterval
3
13
  data: any
4
14
  dataDescription: Object
15
+ dataFileName: string
16
+ dataFileSourceType: string
17
+ dataFormat: any
5
18
  dataKey: string
19
+ datasets: Record<string, any>
6
20
  editing: boolean
7
- formattedData: any
21
+ formattedData?: Object[] & Record<string, Object>
8
22
  general: any
9
23
  hide: any[]
24
+ legend: Legend
25
+ multiDashboards?: any[]
10
26
  newViz: boolean
11
27
  openModal: boolean
12
28
  originalFormattedData: any
13
- table: {
14
- showDataTableLink: boolean
15
- }
29
+ orientation: 'vertical' | 'horizontal'
30
+ series: Series
31
+ table: Table
16
32
  title: string
17
- type: 'chart' | 'map' | 'data-bite' | 'waffle-chart' | 'markup-include' | 'filtered-text' | 'filter-dropdowns'
33
+ type: BaseVisualizationType
18
34
  uid: string
19
35
  usesSharedFilter: any
20
36
  visualizationType: string
37
+ visualizationSubType: string
38
+ xAxis: Axis
21
39
  }
@@ -0,0 +1,11 @@
1
+ import { ReactElement } from 'react'
2
+
3
+ export type WCMSProps = {
4
+ config?: any
5
+ configUrl?: string
6
+ isEditor?: boolean
7
+ isDebug?: boolean
8
+ hostname?: string
9
+ containerEl?: ReactElement
10
+ sharepath?: string
11
+ }
@@ -1,7 +0,0 @@
1
- const SkipNav = skipId => (
2
- <a id='skip-nav' className='cdcdataviz-sr-only-focusable' href={`#${skipId}`}>
3
- Skip Navigation or Skip to Content
4
- </a>
5
- )
6
-
7
- export default SkipNav
@@ -1,9 +0,0 @@
1
- import { timeFormat, timeParse } from 'd3-time-format'
2
-
3
- export function formatDate(format = undefined, date) {
4
- return timeFormat(format)(date)
5
- }
6
-
7
- export function parseDate(format = undefined, dateString) {
8
- return timeParse(format)(dateString) || new Date()
9
- }
@@ -1,21 +0,0 @@
1
- export default function getViewport(size) {
2
- let result = 'lg'
3
-
4
- const viewports = {
5
- lg: 1200,
6
- md: 992,
7
- sm: 768,
8
- xs: 576,
9
- xxs: 350
10
- }
11
-
12
- if (size > 1200) return result
13
-
14
- for (let viewport in viewports) {
15
- if (size <= viewports[viewport]) {
16
- result = viewport
17
- }
18
- }
19
-
20
- return result
21
- }