@cdc/core 4.24.4 → 4.24.7
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/components/AdvancedEditor/AdvancedEditor.tsx +93 -0
- package/components/AdvancedEditor/advanced-editor-styles.css +3 -0
- package/components/AdvancedEditor/index.ts +1 -0
- package/components/DataTable/DataTable.tsx +33 -15
- package/components/DataTable/DataTableStandAlone.tsx +30 -4
- package/components/DataTable/components/ChartHeader.tsx +3 -2
- package/components/DataTable/components/DataTableEditorPanel.tsx +23 -6
- package/components/DataTable/components/ExpandCollapse.tsx +1 -1
- package/components/DataTable/helpers/chartCellMatrix.tsx +5 -10
- package/components/DataTable/helpers/getChartCellValue.ts +26 -2
- package/components/DataTable/helpers/getDataSeriesColumns.ts +40 -16
- package/components/DataTable/helpers/getRowType.ts +6 -0
- package/components/DataTable/helpers/getSeriesName.ts +2 -1
- package/components/DataTable/helpers/{customColumns.ts → removeNullColumns.ts} +3 -3
- package/components/DataTable/types/TableConfig.ts +12 -22
- package/components/EditorPanel/ColumnsEditor.tsx +278 -262
- package/components/EditorPanel/DataTableEditor.tsx +159 -60
- package/components/EditorPanel/FieldSetWrapper.tsx +51 -0
- package/components/EditorPanel/FootnotesEditor.tsx +77 -0
- package/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +227 -0
- package/components/EditorPanel/VizFilterEditor/components/FilterOrder.tsx +54 -0
- package/components/EditorPanel/VizFilterEditor/index.ts +1 -0
- package/components/EditorWrapper/EditorWrapper.tsx +47 -0
- package/components/EditorWrapper/editor-wrapper.style.css +14 -0
- package/components/EditorWrapper/index.ts +1 -0
- package/components/{Filters.jsx → Filters.tsx} +102 -70
- package/components/Footnotes/Footnotes.tsx +25 -0
- package/components/Footnotes/FootnotesStandAlone.tsx +45 -0
- package/components/Footnotes/footnotes.css +5 -0
- package/components/Footnotes/index.ts +1 -0
- package/components/Layout/components/Sidebar/components/sidebar.styles.scss +8 -4
- package/components/Layout/components/Visualization/index.tsx +14 -5
- package/components/MediaControls.jsx +1 -1
- package/components/MultiSelect/MultiSelect.tsx +36 -9
- package/components/MultiSelect/multiselect.styles.css +0 -3
- package/components/_stories/DataTable.stories.tsx +1 -2
- package/components/_stories/EditorPanel.stories.tsx +1 -0
- package/components/_stories/Footnotes.stories.tsx +17 -0
- package/components/inputs/InputSelect.tsx +17 -6
- package/components/ui/Icon.tsx +1 -2
- package/helpers/DataTransform.ts +9 -32
- package/helpers/addValuesToFilters.ts +56 -0
- package/helpers/cove/accessibility.ts +1 -0
- package/helpers/cove/fontSettings.ts +2 -0
- package/helpers/coveUpdateWorker.ts +11 -2
- package/helpers/filterVizData.ts +30 -0
- package/helpers/footnoteSymbols.ts +11 -0
- package/helpers/formatConfigBeforeSave.ts +90 -0
- package/helpers/gatherQueryParams.ts +14 -7
- package/helpers/lineChartHelpers.js +2 -1
- package/helpers/pivotData.ts +18 -0
- package/helpers/queryStringUtils.ts +29 -0
- package/helpers/tests/updateFieldFactory.test.ts +1 -0
- package/helpers/updateFieldFactory.ts +1 -1
- package/helpers/useDataVizClasses.js +0 -4
- package/helpers/ver/4.23.4.ts +27 -0
- package/helpers/ver/4.24.5.ts +32 -0
- package/helpers/ver/4.24.7.ts +92 -0
- package/package.json +6 -4
- package/styles/_button-section.scss +6 -1
- package/styles/_data-table.scss +0 -1
- package/styles/_reset.scss +7 -6
- package/styles/base.scss +4 -0
- package/styles/v2/themes/_color-definitions.scss +1 -0
- package/types/Annotation.ts +46 -0
- package/types/Column.ts +1 -0
- package/types/ConfigureData.ts +1 -1
- package/types/Footnotes.ts +17 -0
- package/types/General.ts +5 -0
- package/types/Legend.ts +1 -0
- package/types/MarkupInclude.ts +26 -0
- package/types/Runtime.ts +3 -7
- package/types/Series.ts +1 -1
- package/types/Table.ts +21 -14
- package/types/Visualization.ts +40 -11
- package/types/VizFilter.ts +24 -0
- package/LICENSE +0 -201
- package/components/AdvancedEditor.jsx +0 -74
- package/helpers/queryStringUtils.js +0 -26
- package/types/BaseVisualizationType.ts +0 -1
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import MapIcon from '../assets/map-folded.svg'
|
|
3
|
-
import ChartIcon from '../assets/icon-chart-bar.svg'
|
|
4
|
-
import MarkupIncludeIcon from '../assets/icon-code.svg'
|
|
5
|
-
|
|
6
|
-
export const AdvancedEditor = ({ loadConfig, state, convertStateToConfig }) => {
|
|
7
|
-
const [advancedToggle, setAdvancedToggle] = useState(false)
|
|
8
|
-
const [configTextboxValue, setConfigTextbox] = useState({})
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
let parsedData = state
|
|
12
|
-
if (state.type !== 'dashboard') {
|
|
13
|
-
parsedData = convertStateToConfig()
|
|
14
|
-
} else {
|
|
15
|
-
parsedData = JSON.parse(JSON.stringify(parsedData))
|
|
16
|
-
}
|
|
17
|
-
const formattedData = JSON.stringify(parsedData, undefined, 2)
|
|
18
|
-
|
|
19
|
-
setConfigTextbox(formattedData)
|
|
20
|
-
}, [state])
|
|
21
|
-
|
|
22
|
-
const typeLookup = {
|
|
23
|
-
chart: ['Charts', 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/bar-chart.html', <ChartIcon />],
|
|
24
|
-
dashboard: ['Dashboard', 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/bar-chart.html', <ChartIcon />],
|
|
25
|
-
map: ['Maps', 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/data-map.html', <MapIcon />],
|
|
26
|
-
'markup-include': ['Markup Include', 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/Markup-Include.html', <MarkupIncludeIcon />]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!state.type) return <></>
|
|
30
|
-
return (
|
|
31
|
-
<>
|
|
32
|
-
<a href={typeLookup[state.type][1]} target='_blank' rel='noopener noreferrer' className='guidance-link'>
|
|
33
|
-
{typeLookup[state.type][2]}
|
|
34
|
-
<div>
|
|
35
|
-
<span className='heading-3'>Get Help with {typeLookup[state.type][0]}</span>
|
|
36
|
-
<p>Examples and documentation</p>
|
|
37
|
-
</div>
|
|
38
|
-
</a>
|
|
39
|
-
<div className='advanced'>
|
|
40
|
-
<span className='advanced-toggle-link' onClick={() => setAdvancedToggle(!advancedToggle)}>
|
|
41
|
-
<span>{advancedToggle ? `— ` : `+ `}</span>Advanced Options
|
|
42
|
-
</span>
|
|
43
|
-
{advancedToggle && (
|
|
44
|
-
<React.Fragment>
|
|
45
|
-
<section className='error-box py-2 px-3 my-2'>
|
|
46
|
-
<div>
|
|
47
|
-
<strong className='pt-1'>Warning</strong>
|
|
48
|
-
<p>This can cause serious errors in your visualization.</p>
|
|
49
|
-
</div>
|
|
50
|
-
</section>
|
|
51
|
-
<p className='pb-2'>
|
|
52
|
-
This tool displays the actual <acronym title='JavaScript Object Notation'>JSON</acronym> configuration that is generated by this editor and allows you to edit properties directly and apply them.
|
|
53
|
-
</p>
|
|
54
|
-
<button
|
|
55
|
-
className='btn'
|
|
56
|
-
onClick={() => {
|
|
57
|
-
navigator.clipboard.writeText(configTextboxValue)
|
|
58
|
-
alert('Copied!')
|
|
59
|
-
}}
|
|
60
|
-
>
|
|
61
|
-
Copy to Clipboard
|
|
62
|
-
</button>
|
|
63
|
-
<textarea value={configTextboxValue} onChange={event => setConfigTextbox(event.target.value)} />
|
|
64
|
-
<button className='btn full-width' onClick={() => loadConfig(JSON.parse(configTextboxValue))}>
|
|
65
|
-
Apply
|
|
66
|
-
</button>
|
|
67
|
-
</React.Fragment>
|
|
68
|
-
)}
|
|
69
|
-
</div>
|
|
70
|
-
</>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export default AdvancedEditor
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export function getQueryStringFilterValue(filter) {
|
|
2
|
-
const urlParams = new URLSearchParams(window.location.search)
|
|
3
|
-
if(filter.setByQueryParameter){ // Only check the query string if the filter is supposed to be set by QS param
|
|
4
|
-
const filterValue = urlParams.get(filter.setByQueryParameter)
|
|
5
|
-
if(filterValue && filter.values){
|
|
6
|
-
for(let i = 0; i < filter.values.length; i++){
|
|
7
|
-
if(filter.values[i] && filter.values[i].toLowerCase() === filterValue.toLowerCase()){
|
|
8
|
-
return filter.values[i]
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function getQueryParams(filter) {
|
|
16
|
-
const queryParams = {};
|
|
17
|
-
for (const [key, value] of (new URLSearchParams(window.location.search)).entries()) {
|
|
18
|
-
queryParams[key] = value
|
|
19
|
-
}
|
|
20
|
-
return queryParams;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function updateQueryString(queryParams) {
|
|
24
|
-
const updateUrl = `${window.location.origin}${window.location.pathname}?${Object.keys(queryParams).map(queryParam => `${queryParam}=${encodeURIComponent(queryParams[queryParam])}`).join('&')}`;
|
|
25
|
-
window.history.pushState({path: updateUrl}, '', updateUrl);
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type BaseVisualizationType = 'dashboard' | 'chart' | 'map' | 'data-bite' | 'waffle-chart' | 'markup-include' | 'filtered-text' | 'filter-dropdowns' | 'table' | 'navigation'
|