@cdc/core 4.23.10 → 4.24.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 (74) hide show
  1. package/LICENSE +201 -0
  2. package/assets/icon-deviation-bar.svg +1 -0
  3. package/components/DataTable/DataTable.tsx +223 -0
  4. package/components/DataTable/components/BoxplotHeader.tsx +16 -0
  5. package/components/DataTable/components/CellAnchor.tsx +44 -0
  6. package/components/DataTable/components/ChartHeader.tsx +103 -0
  7. package/components/DataTable/components/ExpandCollapse.tsx +21 -0
  8. package/components/DataTable/components/Icons.tsx +10 -0
  9. package/components/DataTable/components/MapHeader.tsx +56 -0
  10. package/components/DataTable/components/SkipNav.tsx +7 -0
  11. package/components/DataTable/helpers/boxplotCellMatrix.tsx +64 -0
  12. package/components/DataTable/helpers/chartCellMatrix.tsx +92 -0
  13. package/components/DataTable/helpers/customColumns.ts +25 -0
  14. package/components/DataTable/helpers/customSort.ts +55 -0
  15. package/components/DataTable/helpers/getChartCellValue.ts +56 -0
  16. package/components/DataTable/helpers/getDataSeriesColumns.ts +29 -0
  17. package/components/DataTable/helpers/getSeriesName.ts +26 -0
  18. package/components/DataTable/helpers/mapCellMatrix.tsx +56 -0
  19. package/components/DataTable/helpers/regionCellMatrix.tsx +13 -0
  20. package/components/DataTable/helpers/standardizeState.js +76 -0
  21. package/components/DataTable/index.ts +1 -0
  22. package/components/DataTable/types/TableConfig.ts +52 -0
  23. package/components/DownloadButton.tsx +29 -0
  24. package/components/EditorPanel/DataTableEditor.tsx +133 -0
  25. package/components/EditorPanel/Inputs.tsx +150 -0
  26. package/components/Filters.jsx +3 -3
  27. package/components/LegendCircle.jsx +2 -2
  28. package/components/MediaControls.jsx +1 -1
  29. package/components/MultiSelect/MultiSelect.tsx +95 -0
  30. package/components/MultiSelect/index.ts +1 -0
  31. package/components/MultiSelect/multiselect.styles.css +50 -0
  32. package/components/Table/Table.tsx +69 -0
  33. package/components/Table/components/Cell.tsx +9 -0
  34. package/components/Table/components/GroupRow.tsx +20 -0
  35. package/components/Table/components/Row.tsx +26 -0
  36. package/components/Table/index.ts +1 -0
  37. package/components/Table/types/CellMatrix.ts +4 -0
  38. package/components/Table/types/RowType.ts +5 -0
  39. package/components/_stories/DataTable.stories.tsx +103 -0
  40. package/components/_stories/EditorPanel.stories.tsx +53 -0
  41. package/components/_stories/Inputs.stories.tsx +37 -0
  42. package/components/_stories/MultiSelect.stories.tsx +24 -0
  43. package/components/_stories/Table.stories.tsx +53 -0
  44. package/components/_stories/_mocks/dashboard_no_filter.json +121 -0
  45. package/components/_stories/_mocks/example-city-state.json +808 -0
  46. package/components/_stories/_mocks/row_type.json +42 -0
  47. package/components/_stories/styles.scss +9 -0
  48. package/components/inputs/{InputSelect.jsx → InputSelect.tsx} +15 -5
  49. package/components/managers/{DataDesigner.jsx → DataDesigner.tsx} +103 -94
  50. package/components/ui/{Icon.jsx → Icon.tsx} +3 -3
  51. package/components/ui/Title/Title.scss +95 -0
  52. package/components/ui/Title/index.tsx +34 -0
  53. package/components/ui/_stories/Title.stories.tsx +21 -0
  54. package/helpers/DataTransform.ts +75 -20
  55. package/helpers/cove/string.ts +11 -0
  56. package/helpers/fetchRemoteData.js +1 -1
  57. package/helpers/getFileExtension.ts +28 -5
  58. package/package.json +2 -2
  59. package/styles/_data-table.scss +3 -0
  60. package/styles/heading-colors.scss +0 -3
  61. package/styles/v2/layout/_component.scss +0 -11
  62. package/types/Axis.ts +41 -0
  63. package/types/Color.ts +5 -0
  64. package/types/Column.ts +15 -0
  65. package/types/ComponentStyles.ts +7 -0
  66. package/types/ComponentThemes.ts +13 -0
  67. package/types/EditorColumnProperties.ts +8 -0
  68. package/types/FilterBehavior.ts +1 -0
  69. package/types/Runtime.ts +29 -0
  70. package/types/Series.ts +1 -0
  71. package/types/Table.ts +18 -0
  72. package/types/UpdateFieldFunc.ts +1 -0
  73. package/types/Visualization.ts +21 -0
  74. package/components/DataTable.jsx +0 -754
@@ -0,0 +1,103 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import DataTable from '../DataTable'
4
+ import './styles.scss'
5
+ import Example_1 from './_mocks/dashboard_no_filter.json'
6
+ import CityStateExample from './_mocks/example-city-state.json'
7
+ import { displayGeoName } from '@cdc/map/src/helpers/displayGeoName'
8
+ import rowTypeData from './_mocks/row_type.json'
9
+ import { TableConfig } from '../DataTable/types/TableConfig'
10
+
11
+ const meta: Meta<typeof DataTable> = {
12
+ title: 'Components/Organisms/DataTable',
13
+ component: DataTable
14
+ }
15
+
16
+ export default meta
17
+
18
+ type Story = StoryObj<typeof DataTable>
19
+
20
+ const datasetKey = 'dashboard_example_map.csv'
21
+
22
+ export const Primary: Story = {
23
+ args: {
24
+ config: Example_1,
25
+ dataConfig: Example_1.datasets[datasetKey],
26
+ rawData: Example_1.datasets[datasetKey].data,
27
+ runtimeData: Example_1.datasets[datasetKey].data,
28
+ expandDataTable: true,
29
+ tableTitle: 'COVE DataTable',
30
+ viewport: 'lg',
31
+ tabbingId: datasetKey
32
+ }
33
+ }
34
+
35
+ export const CityState: Story = {
36
+ args: {
37
+ config: CityStateExample,
38
+ dataConfig: CityStateExample,
39
+ rawData: CityStateExample.data,
40
+ runtimeData: CityStateExample.data,
41
+ expandDataTable: true,
42
+ tableTitle: 'CityStateExample DataTable',
43
+ viewport: 'lg',
44
+ tabbingId: '#asdf',
45
+ columns: CityStateExample.columns,
46
+ applyLegendToRow: () => ['#000'],
47
+ displayGeoName,
48
+ displayDataAsText: d => d
49
+ }
50
+ }
51
+
52
+ export const Grouped: Story = {
53
+ args: {
54
+ config: Example_1,
55
+ dataConfig: Example_1.datasets[datasetKey],
56
+ rawData: Example_1.datasets[datasetKey].data,
57
+ runtimeData: Example_1.datasets[datasetKey].data,
58
+ expandDataTable: true,
59
+ tableTitle: 'COVE DataTable',
60
+ groupBy: 'TimeZone',
61
+ viewport: 'lg',
62
+ tabbingId: datasetKey
63
+ }
64
+ }
65
+
66
+ export const RowType: Story = {
67
+ args: {
68
+ config: {
69
+ dashboard: {
70
+ theme: 'theme-blue',
71
+ title: 'RowType'
72
+ },
73
+ title: 'RowType',
74
+ dataUrl: '/examples/feature/__data__/ardi.json',
75
+ animate: false,
76
+ animateReplay: true,
77
+ palette: 'qualitative-soft',
78
+ aspectRatio: 1,
79
+ dataFormat: {
80
+ roundTo: 1,
81
+ commas: false,
82
+ prefix: '',
83
+ suffix: ''
84
+ },
85
+ legend: {
86
+ hide: false
87
+ },
88
+ table: {
89
+ label: 'Data Table',
90
+ expanded: true,
91
+ show: true,
92
+ customTableConfig: true
93
+ }
94
+ } as unknown as TableConfig,
95
+ dataConfig: { data: rowTypeData },
96
+ rawData: rowTypeData,
97
+ runtimeData: rowTypeData,
98
+ expandDataTable: true,
99
+ tableTitle: 'DataTable',
100
+ viewport: 'lg',
101
+ tabbingId: '#asdf'
102
+ }
103
+ }
@@ -0,0 +1,53 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import DataTableEditor from '../EditorPanel/DataTableEditor'
4
+ import { Accordion, AccordionItem, AccordionItemButton, AccordionItemHeading, AccordionItemPanel } from 'react-accessible-accordion'
5
+ import { useState } from 'react'
6
+
7
+ const EditorPanel = () => {
8
+ const { config, isDashboard } = Primary.args
9
+ const [_config, setConfig] = useState(config)
10
+ const updateField = (section, subsection, fieldName, value) => {
11
+ setConfig({
12
+ ..._config,
13
+ [section]: {
14
+ ..._config[section],
15
+ [fieldName]: value
16
+ }
17
+ })
18
+ }
19
+ return (
20
+ <Accordion>
21
+ <AccordionItem>
22
+ <AccordionItemHeading>
23
+ <AccordionItemButton>Data Table</AccordionItemButton>
24
+ </AccordionItemHeading>
25
+ <AccordionItemPanel>
26
+ <DataTableEditor config={_config} isDashboard={isDashboard} updateField={updateField} isLoadedFromUrl={false} />
27
+ </AccordionItemPanel>
28
+ </AccordionItem>
29
+ </Accordion>
30
+ )
31
+ }
32
+
33
+ const meta: Meta<typeof DataTableEditor> = {
34
+ title: 'Components/Organisms/EditorPanel',
35
+ component: EditorPanel
36
+ }
37
+
38
+ export default meta
39
+
40
+ type Story = StoryObj<typeof DataTableEditor>
41
+
42
+ export const Primary: Story = {
43
+ args: {
44
+ config: {
45
+ table: {
46
+ label: 'Data Table',
47
+ show: true
48
+ },
49
+ visualizationType: 'Pie'
50
+ },
51
+ isDashboard: true
52
+ }
53
+ }
@@ -0,0 +1,37 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import InputSelect from '../inputs/InputSelect'
4
+ import { useState } from 'react'
5
+
6
+ const Inputs: React.FC = ({ config }: any) => {
7
+ const [_config, setConfig] = useState(config)
8
+ const updateField = (section, subsection, fieldName, value) => {
9
+ setConfig({
10
+ ..._config,
11
+ [section]: {
12
+ ..._config[section],
13
+ [fieldName]: value
14
+ }
15
+ })
16
+ }
17
+ return (
18
+ <div>
19
+ <InputSelect label='Select' options={['apple', 'banana', 'orange']} fieldName='inputselect' updateField={updateField} />
20
+ </div>
21
+ )
22
+ }
23
+
24
+ const meta: Meta<typeof Inputs> = {
25
+ title: 'Components/Atoms/Inputs',
26
+ component: Inputs
27
+ }
28
+
29
+ export default meta
30
+
31
+ type Story = StoryObj<typeof Inputs>
32
+
33
+ export const Select: Story = {
34
+ args: {
35
+ config: {}
36
+ }
37
+ }
@@ -0,0 +1,24 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import MultiSelect from '../MultiSelect'
4
+
5
+ const meta: Meta<typeof MultiSelect> = {
6
+ title: 'Components/Molecules/MultiSelect',
7
+ component: MultiSelect
8
+ }
9
+
10
+ type Story = StoryObj<typeof MultiSelect>
11
+
12
+ export const Primary: Story = {
13
+ args: {
14
+ options: [
15
+ { value: '1', label: 'One' },
16
+ { value: '2', label: 'Two' },
17
+ { value: '3', label: 'Three' }
18
+ ],
19
+ label: 'MultiSelect',
20
+ updateField: (section, subsection, fieldName, value) => {}
21
+ }
22
+ }
23
+
24
+ export default meta
@@ -0,0 +1,53 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import Table from '../Table'
4
+ import { ReactNode } from 'react'
5
+
6
+ const meta: Meta<typeof Table> = {
7
+ title: 'Components/Molecules/Table',
8
+ component: Table
9
+ }
10
+
11
+ export default meta
12
+
13
+ type Story = StoryObj<typeof Table>
14
+
15
+ function createMatrix(): ReactNode[][] {
16
+ const base = ['a', 'b', 'c'].map(el => <>{el}</>)
17
+ return [base, base]
18
+ }
19
+
20
+ export const Ungrouped: Story = {
21
+ args: {
22
+ childrenMatrix: createMatrix(),
23
+ tableName: 'COVE Table',
24
+ headContent: (
25
+ <tr>
26
+ <th>first</th>
27
+ <th>second</th>
28
+ <th>third</th>
29
+ </tr>
30
+ ),
31
+ tableOptions: { className: 'table table-bordered' }
32
+ }
33
+ }
34
+
35
+ function createGroupMatrix(): Record<string, ReactNode[][]> {
36
+ const base = ['a', 'b', 'c'].map(el => <>{el}</>)
37
+ return { group_1: [base, base], group_2: [base, base] }
38
+ }
39
+
40
+ export const Grouped: Story = {
41
+ args: {
42
+ childrenMatrix: createGroupMatrix(),
43
+ tableName: 'COVE Table',
44
+ headContent: (
45
+ <tr>
46
+ <th>first</th>
47
+ <th>second</th>
48
+ <th>third</th>
49
+ </tr>
50
+ ),
51
+ tableOptions: { className: 'table table-bordered' }
52
+ }
53
+ }
@@ -0,0 +1,121 @@
1
+ {
2
+ "dashboard": {
3
+ "theme": "theme-blue",
4
+ "title": "Dashboard with No Filters"
5
+ },
6
+ "rows": [
7
+ [
8
+ {
9
+ "width": 12,
10
+ "widget": "map1629143821077"
11
+ },
12
+ {},
13
+ {}
14
+ ],
15
+ [
16
+ {
17
+ "width": 6,
18
+ "widget": "data-bite1629144030877"
19
+ },
20
+ {
21
+ "width": 6,
22
+ "widget": "data-bite1629144267659"
23
+ },
24
+ {
25
+ "width": null
26
+ }
27
+ ]
28
+ ],
29
+ "table": {
30
+ "label": "Data Table",
31
+ "show": true
32
+ },
33
+ "type": "dashboard",
34
+ "uuid": 1629144022257,
35
+ "datasets": {
36
+ "dashboard_example_map.csv": {
37
+ "data": [
38
+ {
39
+ "Location": "Alabama",
40
+ "TimeZone": 1,
41
+ "Rate": 1375
42
+ },
43
+ {
44
+ "Location": "Alaska",
45
+ "TimeZone": 1,
46
+ "Rate": 1377
47
+ },
48
+ {
49
+ "Location": "American Samoa",
50
+ "TimeZone": 1,
51
+ "Rate": 1388
52
+ },
53
+ {
54
+ "Location": "Arizona",
55
+ "TimeZone": 1,
56
+ "Rate": 1401
57
+ },
58
+ {
59
+ "Location": "Arkansas",
60
+ "TimeZone": 1,
61
+ "Rate": 1398
62
+ },
63
+ {
64
+ "Location": "California",
65
+ "TimeZone": 2,
66
+ "Rate": 1381
67
+ },
68
+ {
69
+ "Location": "Colorado",
70
+ "TimeZone": 2,
71
+ "Rate": 1369
72
+ },
73
+ {
74
+ "Location": "Connecticut",
75
+ "TimeZone": 2,
76
+ "Rate": 1403
77
+ },
78
+ {
79
+ "Location": "Delaware\t",
80
+ "TimeZone": 2,
81
+ "Rate": "1384"
82
+ },
83
+ {
84
+ "Location": "District of Columbia",
85
+ "TimeZone": 2,
86
+ "Rate": 1400
87
+ },
88
+ {
89
+ "Location": "Florida",
90
+ "TimeZone": 2,
91
+ "Rate": 1387
92
+ },
93
+ {
94
+ "Location": "Georgia",
95
+ "TimeZone": 3,
96
+ "Rate": 1365
97
+ },
98
+ {
99
+ "Location": "Guam",
100
+ "TimeZone": 3,
101
+ "Rate": 1356
102
+ },
103
+ {
104
+ "Location": "Hawaii",
105
+ "TimeZone": 3,
106
+ "Rate": 1362
107
+ },
108
+ {
109
+ "Location": "Idaho",
110
+ "TimeZone": 3,
111
+ "Rate": 1374
112
+ }
113
+ ],
114
+ "dataFileSize": 971,
115
+ "dataFileName": "dashboard_example_map.csv",
116
+ "dataFileSourceType": "file",
117
+ "dataFileFormat": "CSV",
118
+ "preview": true
119
+ }
120
+ }
121
+ }