@cdc/core 4.25.8 → 4.25.11
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/_stories/StoryRenderingTests.stories.tsx +164 -0
- package/components/AdvancedEditor/AdvancedEditor.tsx +32 -9
- package/components/CustomColorsEditor/CustomColorsEditor.css +299 -0
- package/components/CustomColorsEditor/CustomColorsEditor.tsx +209 -0
- package/components/CustomColorsEditor/index.ts +1 -0
- package/components/DataTable/DataTable.tsx +56 -38
- package/components/DataTable/DataTableStandAlone.tsx +8 -3
- package/components/DataTable/components/ChartHeader.tsx +44 -14
- package/components/DataTable/components/DataTableEditorPanel.tsx +12 -2
- package/components/DataTable/components/ExpandCollapse.tsx +10 -1
- package/components/DataTable/components/MapHeader.tsx +24 -13
- package/components/DataTable/data-table.css +12 -0
- package/components/DataTable/helpers/chartCellMatrix.tsx +11 -8
- package/components/DataTable/helpers/mapCellMatrix.tsx +33 -4
- package/components/DataTable/helpers/standardizeState.js +2 -2
- package/components/DataTable/helpers/tests/standardizeState.test.js +54 -0
- package/components/DownloadButton.tsx +40 -14
- package/components/EditorPanel/DataTableEditor.tsx +3 -3
- package/components/EditorPanel/EditorPanel.styles.css +423 -0
- package/components/EditorPanel/FootnotesEditor.tsx +44 -37
- package/components/EditorPanel/Inputs.tsx +12 -2
- package/components/EditorPanel/VizFilterEditor/NestedDropdownEditor.tsx +35 -62
- package/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +12 -2
- package/components/EditorPanel/components/MarkupHighlightedTextField.tsx +227 -0
- package/components/EditorPanel/components/MarkupVariablesEditor.tsx +450 -0
- package/components/EditorPanel/components/PanelMarkup.tsx +59 -0
- package/components/ErrorBoundary.jsx +3 -1
- package/components/Filters/Filters.tsx +52 -24
- package/components/Filters/components/Dropdown.tsx +6 -1
- package/components/Filters/components/Tabs.tsx +1 -0
- package/components/Footnotes/Footnotes.tsx +35 -25
- package/components/Footnotes/FootnotesStandAlone.tsx +42 -6
- package/components/HeaderThemeSelector/HeaderThemeSelector.css +43 -0
- package/components/HeaderThemeSelector/HeaderThemeSelector.stories.tsx +74 -0
- package/components/HeaderThemeSelector/HeaderThemeSelector.tsx +61 -0
- package/components/HeaderThemeSelector/index.ts +2 -0
- package/components/Layout/styles/editor.scss +2 -1
- package/components/Legend/Legend.Gradient.tsx +3 -6
- package/components/LegendShape.tsx +121 -3
- package/components/Loader/Loader.tsx +1 -1
- package/components/MediaControls.tsx +72 -21
- package/components/PaletteConversionModal.tsx +90 -0
- package/components/PaletteSelector/DeveloperPaletteRollback.tsx +114 -0
- package/components/PaletteSelector/PaletteSelector.css +94 -0
- package/components/PaletteSelector/PaletteSelector.tsx +112 -0
- package/components/PaletteSelector/index.ts +2 -0
- package/components/RichTooltip/RichTooltip.tsx +1 -0
- package/components/Table/Table.tsx +3 -1
- package/components/Table/components/Cell.tsx +23 -2
- package/components/Table/components/Row.tsx +5 -3
- package/components/_stories/BlurStrokeTest.stories.tsx +1 -1
- package/components/_stories/DataTable.stories.tsx +1 -1
- package/components/_stories/Filters.stories.tsx +21 -2
- package/components/_stories/Footnotes.CSV.stories.tsx +247 -0
- package/components/_stories/Footnotes.stories.tsx +769 -4
- package/components/_stories/Inputs.stories.tsx +3 -3
- package/components/_stories/MultiSelect.stories.tsx +3 -3
- package/components/_stories/NestedDropdown.stories.tsx +1 -1
- package/components/_stories/Table.stories.tsx +1 -1
- package/components/_stories/styles.scss +0 -1
- package/components/elements/_stories/Button.stories.tsx +1 -1
- package/components/elements/_stories/Card.stories.tsx +1 -1
- package/components/inputs/InputToggle.tsx +2 -0
- package/components/managers/DataDesigner.tsx +10 -9
- package/components/managers/_stories/DataDesigner.stories.tsx +1 -1
- package/components/ui/Accordion.jsx +1 -1
- package/components/ui/Tooltip.tsx +2 -1
- package/components/ui/_stories/Accordion.stories.tsx +1 -1
- package/components/ui/_stories/ColorPaletteMigration.stories.mdx +275 -0
- package/components/ui/_stories/Colors.stories.tsx +330 -0
- package/components/ui/_stories/IconGallery.stories.tsx +316 -0
- package/components/ui/_stories/Title.stories.tsx +1 -1
- package/components/ui/accordion.styles.css +57 -0
- package/contexts/EditorContext.ts +18 -0
- package/contexts/editor.actions.ts +28 -0
- package/contexts/editor.reducer.ts +94 -0
- package/data/chartColorPalettes.ts +118 -0
- package/data/colorPalettes.ts +9 -0
- package/data/mapColorPalettes.ts +45 -0
- package/data/sharedPalettes.ts +50 -0
- package/dist/cove-main.css +63 -14
- package/dist/cove-main.css.map +1 -1
- package/generateViteConfig.js +80 -0
- package/helpers/addValuesToFilters.ts +7 -3
- package/helpers/cloneConfig.ts +31 -0
- package/helpers/configDataHelpers.ts +128 -0
- package/helpers/configHelpers.ts +27 -0
- package/helpers/constants.ts +42 -2
- package/helpers/cove/number.ts +33 -12
- package/helpers/coveUpdateWorker.ts +15 -3
- package/helpers/fetchRemoteData.ts +3 -15
- package/helpers/filterColorPalettes.ts +152 -0
- package/helpers/generateColorsArray.ts +13 -0
- package/helpers/getColorPaletteVersion.ts +33 -0
- package/helpers/getPaletteAccessor.ts +18 -0
- package/helpers/markupProcessor.ts +220 -0
- package/helpers/mergeCustomOrderValues.ts +37 -0
- package/helpers/metrics/helpers.ts +42 -19
- package/helpers/metrics/types.ts +48 -9
- package/helpers/metrics/utils.ts +34 -0
- package/helpers/palettes/colorDistributions.ts +56 -0
- package/helpers/palettes/migratePaletteName.ts +150 -0
- package/helpers/palettes/standardizePaletteNames.ts +77 -0
- package/helpers/palettes/utils.ts +267 -0
- package/helpers/parseCsvWithQuotes.ts +65 -0
- package/helpers/queryStringUtils.ts +13 -0
- package/helpers/testing.ts +358 -0
- package/helpers/tests/addValuesToFilters.test.ts +1 -2
- package/helpers/tests/generateColorsArray.test.ts +24 -0
- package/helpers/tests/markupProcessor.test.ts +538 -0
- package/helpers/tests/testStandaloneBuild.ts +44 -0
- package/helpers/useMarkupVariables.ts +31 -0
- package/helpers/vegaConfig.ts +0 -1
- package/helpers/ver/4.24.10.ts +2 -1
- package/helpers/ver/4.24.11.ts +2 -1
- package/helpers/ver/4.24.3.ts +2 -1
- package/helpers/ver/4.24.4.ts +2 -1
- package/helpers/ver/4.24.5.ts +2 -1
- package/helpers/ver/4.24.7.ts +2 -1
- package/helpers/ver/4.24.9.ts +2 -1
- package/helpers/ver/4.25.1.ts +2 -1
- package/helpers/ver/4.25.10.ts +36 -0
- package/helpers/ver/4.25.11.ts +13 -0
- package/helpers/ver/4.25.3.ts +2 -1
- package/helpers/ver/4.25.4.ts +2 -1
- package/helpers/ver/4.25.6.ts +2 -1
- package/helpers/ver/4.25.7.ts +2 -1
- package/helpers/ver/4.25.8.ts +2 -1
- package/helpers/ver/4.25.9.ts +293 -0
- package/helpers/ver/tests/4.25.10.test.ts +204 -0
- package/helpers/ver/tests/4.25.8.test.ts +1 -1
- package/helpers/ver/tests/4.25.9.test.ts +51 -0
- package/helpers/viewports.ts +2 -0
- package/hooks/useColorPalette.ts +79 -0
- package/package.json +13 -4
- package/styles/_common-components.css +73 -0
- package/styles/_global.scss +32 -10
- package/styles/base.scss +8 -55
- package/styles/cove-main.scss +3 -1
- package/styles/filters.scss +10 -3
- package/styles/v2/base/index.scss +0 -1
- package/styles/v2/components/button.scss +4 -3
- package/styles/v2/components/editor.scss +16 -7
- package/styles/v2/layout/_data-table.scss +3 -2
- package/styles/v2/themes/_color-definitions.scss +18 -17
- package/styles/v2/utils/_breakpoints.scss +1 -1
- package/styles/v2/utils/index.scss +0 -1
- package/styles/waiting.scss +1 -1
- package/testing-setup.js +32 -0
- package/types/MarkupInclude.ts +8 -2
- package/types/MarkupVariable.ts +19 -0
- package/types/VizFilter.ts +2 -0
- package/vitest.config.ts +16 -0
- package/components/ui/_stories/Colors.stories.mdx +0 -220
- package/components/ui/_stories/IconGallery.stories.mdx +0 -14
- package/data/colorPalettes.js +0 -171
- package/helpers/formatConfigBeforeSave.ts +0 -135
- package/helpers/tests/formatConfigBeforeSave.test.ts +0 -68
- package/styles/_mixins.scss +0 -13
- package/styles/v2/base/_typography.scss +0 -0
- package/styles/v2/components/guidance-block.scss +0 -74
- package/styles/v2/utils/_functions.scss +0 -0
- /package/{styles/_typography.scss → testBuild.js} +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import Button from '@cdc/core/components/elements/Button'
|
|
3
|
+
|
|
4
|
+
interface PaletteConversionModalProps {
|
|
5
|
+
onConfirm: () => void
|
|
6
|
+
onCancel: () => void
|
|
7
|
+
onReturnToV1: () => void
|
|
8
|
+
paletteName?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const PaletteConversionModal: React.FC<PaletteConversionModalProps> = ({
|
|
12
|
+
onConfirm,
|
|
13
|
+
onCancel,
|
|
14
|
+
onReturnToV1,
|
|
15
|
+
paletteName
|
|
16
|
+
}) => {
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
className='modal-overlay'
|
|
20
|
+
style={{
|
|
21
|
+
position: 'fixed',
|
|
22
|
+
top: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
right: 0,
|
|
25
|
+
bottom: 0,
|
|
26
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
27
|
+
display: 'flex',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
justifyContent: 'center',
|
|
30
|
+
zIndex: 9999
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<div
|
|
34
|
+
className='modal-content'
|
|
35
|
+
style={{
|
|
36
|
+
backgroundColor: 'white',
|
|
37
|
+
borderRadius: '8px',
|
|
38
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
|
39
|
+
maxWidth: '500px',
|
|
40
|
+
margin: '20px'
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
className='modal-header'
|
|
45
|
+
style={{
|
|
46
|
+
padding: '15px',
|
|
47
|
+
borderBottom: '1px solid #e0e0e0',
|
|
48
|
+
backgroundColor: '#005eaa',
|
|
49
|
+
display: 'flex',
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
<h3 style={{ color: 'white', textAlign: 'center' }}>Color Palette Conversion</h3>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div className='modal-body' style={{ padding: '20px' }}>
|
|
57
|
+
<p>
|
|
58
|
+
<strong>
|
|
59
|
+
Your visualization uses an outdated color palette and will be updated to a new, improved palette.
|
|
60
|
+
</strong>
|
|
61
|
+
</p>
|
|
62
|
+
<br />
|
|
63
|
+
<p>
|
|
64
|
+
These new palettes provide improved accessibility and consistency across visualizations. If your previous
|
|
65
|
+
colors are important for approvals, do not save your visualizations with the new palette.
|
|
66
|
+
</p>
|
|
67
|
+
<br />
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div
|
|
71
|
+
className='modal-footer'
|
|
72
|
+
style={{
|
|
73
|
+
padding: '20px',
|
|
74
|
+
borderTop: '1px solid #e0e0e0',
|
|
75
|
+
display: 'flex',
|
|
76
|
+
gap: '10px',
|
|
77
|
+
justifyContent: 'flex-end'
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
<Button secondary onClick={onReturnToV1} style={{ marginRight: 'auto' }}>
|
|
81
|
+
Cancel
|
|
82
|
+
</Button>
|
|
83
|
+
<Button onClick={onConfirm}>Convert to New Palette</Button>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default PaletteConversionModal
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import _ from 'lodash'
|
|
3
|
+
import { isCoveDeveloperMode } from '../../helpers/queryStringUtils'
|
|
4
|
+
import {
|
|
5
|
+
hasPaletteBackup,
|
|
6
|
+
getOriginalPaletteName,
|
|
7
|
+
rollbackPaletteToOriginal,
|
|
8
|
+
hasTwoColorPaletteBackup,
|
|
9
|
+
getOriginalTwoColorPaletteName,
|
|
10
|
+
rollbackTwoColorPaletteToOriginal
|
|
11
|
+
} from '../../helpers/palettes/utils'
|
|
12
|
+
import './PaletteSelector.css'
|
|
13
|
+
|
|
14
|
+
interface DeveloperPaletteRollbackProps {
|
|
15
|
+
config: any
|
|
16
|
+
updateConfig: (newConfig: any) => void
|
|
17
|
+
className?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const DeveloperPaletteRollback: React.FC<DeveloperPaletteRollbackProps> = ({
|
|
21
|
+
config,
|
|
22
|
+
updateConfig,
|
|
23
|
+
className = ''
|
|
24
|
+
}) => {
|
|
25
|
+
// Only show if developer mode is enabled
|
|
26
|
+
if (!isCoveDeveloperMode()) {
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Check for both regular and two-color palette backups
|
|
31
|
+
const hasRegularBackup = hasPaletteBackup(config)
|
|
32
|
+
const hasTwoColorBackup = hasTwoColorPaletteBackup(config)
|
|
33
|
+
|
|
34
|
+
// Only show if there's backup data available
|
|
35
|
+
if (!hasRegularBackup && !hasTwoColorBackup) {
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const originalPaletteName = getOriginalPaletteName(config)
|
|
40
|
+
const originalTwoColorPaletteName = getOriginalTwoColorPaletteName(config)
|
|
41
|
+
const currentPaletteName = config?.general?.palette?.name || config?.palette || config?.color
|
|
42
|
+
const currentTwoColorPaletteName = config?.twoColor?.palette
|
|
43
|
+
|
|
44
|
+
const handleRollback = () => {
|
|
45
|
+
// Determine which type of rollback to perform and show appropriate confirmation
|
|
46
|
+
let confirmMessage = ''
|
|
47
|
+
let fromName = ''
|
|
48
|
+
let toName = ''
|
|
49
|
+
|
|
50
|
+
if (hasTwoColorBackup) {
|
|
51
|
+
// Two-color palette rollback
|
|
52
|
+
fromName = currentTwoColorPaletteName
|
|
53
|
+
toName = originalTwoColorPaletteName
|
|
54
|
+
confirmMessage = `Are you sure you want to rollback the palette from "${fromName}" to "${toName}"?\n\nThis will restore the original v1 palette configuration.`
|
|
55
|
+
} else if (hasRegularBackup) {
|
|
56
|
+
// Regular palette rollback
|
|
57
|
+
fromName = currentPaletteName
|
|
58
|
+
toName = originalPaletteName
|
|
59
|
+
confirmMessage = `Are you sure you want to rollback the palette from "${fromName}" to "${toName}"?\n\nThis will restore the original palette configuration and remove the migrated structure.`
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const confirmRollback = window.confirm(confirmMessage)
|
|
63
|
+
|
|
64
|
+
if (confirmRollback) {
|
|
65
|
+
const configCopy = _.cloneDeep(config)
|
|
66
|
+
console.log('Config before rollback:', JSON.stringify(configCopy, null, 2))
|
|
67
|
+
|
|
68
|
+
let success = false
|
|
69
|
+
|
|
70
|
+
if (hasTwoColorBackup) {
|
|
71
|
+
success = rollbackTwoColorPaletteToOriginal(configCopy)
|
|
72
|
+
console.log('Two-color rollback success:', success)
|
|
73
|
+
} else if (hasRegularBackup) {
|
|
74
|
+
const rolledBackConfig = rollbackPaletteToOriginal(configCopy)
|
|
75
|
+
success = !!rolledBackConfig
|
|
76
|
+
console.log('Regular rollback success:', success)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log('Config after rollback:', JSON.stringify(configCopy, null, 2))
|
|
80
|
+
|
|
81
|
+
if (success) {
|
|
82
|
+
updateConfig(configCopy)
|
|
83
|
+
} else {
|
|
84
|
+
alert('Rollback failed: No backup data available')
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Determine display text based on available backups
|
|
90
|
+
const displayPaletteName = hasTwoColorBackup ? originalTwoColorPaletteName : originalPaletteName
|
|
91
|
+
const infoText = hasTwoColorBackup
|
|
92
|
+
? `Developer Mode: Two-color palette migrated from "${originalTwoColorPaletteName}"`
|
|
93
|
+
: `Developer Mode: Migrated from "${originalPaletteName}"`
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<div className={`developer-palette-rollback ${className}`}>
|
|
97
|
+
<div className="rollback-info">
|
|
98
|
+
<small className="text-muted">
|
|
99
|
+
{infoText}
|
|
100
|
+
</small>
|
|
101
|
+
</div>
|
|
102
|
+
<button
|
|
103
|
+
type="button"
|
|
104
|
+
className="btn btn-sm btn-outline-warning"
|
|
105
|
+
onClick={handleRollback}
|
|
106
|
+
title={`Rollback to original palette: ${displayPaletteName}`}
|
|
107
|
+
>
|
|
108
|
+
Rollback Palette
|
|
109
|
+
</button>
|
|
110
|
+
</div>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export default DeveloperPaletteRollback
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* PaletteSelector component styles */
|
|
2
|
+
/* Shared styles for palette color swatches across all visualization types */
|
|
3
|
+
|
|
4
|
+
.color-palette {
|
|
5
|
+
display: flex;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/* List item-based palette selector (used by maps) */
|
|
9
|
+
.color-palette li {
|
|
10
|
+
width: 1.5em;
|
|
11
|
+
height: 1.5em;
|
|
12
|
+
display: inline-block;
|
|
13
|
+
margin-right: 0.5em;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
border: rgba(0, 0, 0, 0.3) 3px solid;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.color-palette li.active {
|
|
19
|
+
border: rgba(0, 0, 0, 0.8) 3px solid;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.color-palette li.selected {
|
|
23
|
+
border: black 2px solid;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* Button-based palette selector (used by charts) */
|
|
27
|
+
.color-palette button:not(.selected) {
|
|
28
|
+
border: var(--cool-gray-30) 2px solid !important;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.color-palette button.selected {
|
|
32
|
+
border: black 2px solid !important;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.color-palette a {
|
|
36
|
+
display: inline-block;
|
|
37
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.8);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Series list variant */
|
|
41
|
+
.color-palette.series-list {
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
padding: 0;
|
|
44
|
+
border: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.color-palette.series-list li {
|
|
48
|
+
padding: 0.3em 0.5em;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: space-between;
|
|
52
|
+
width: auto;
|
|
53
|
+
height: auto;
|
|
54
|
+
border: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.color-palette.series-list li:not(:last-child) {
|
|
58
|
+
border-bottom: rgba(0, 0, 0, 0.2) 1px solid;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Header variant */
|
|
62
|
+
.header .color-palette li {
|
|
63
|
+
width: 1.5em;
|
|
64
|
+
height: 1.5em;
|
|
65
|
+
display: inline-block;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Developer rollback component styles */
|
|
69
|
+
.developer-palette-rollback {
|
|
70
|
+
margin: 8px 0;
|
|
71
|
+
padding: 8px;
|
|
72
|
+
border: 1px dashed #ffc107;
|
|
73
|
+
border-radius: 4px;
|
|
74
|
+
background-color: #fffbf0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.developer-palette-rollback .rollback-info {
|
|
78
|
+
margin-bottom: 4px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.developer-palette-rollback .rollback-info small {
|
|
82
|
+
color: #856404;
|
|
83
|
+
font-size: 0.75rem;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.developer-palette-rollback button {
|
|
87
|
+
font-size: 0.75rem;
|
|
88
|
+
padding: 2px 8px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.developer-palette-rollback button:hover {
|
|
92
|
+
background-color: #ffc107;
|
|
93
|
+
color: #212529;
|
|
94
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { getPaletteAccessor } from '../../helpers/getPaletteAccessor'
|
|
3
|
+
import './PaletteSelector.css'
|
|
4
|
+
|
|
5
|
+
interface PaletteSelectorProps {
|
|
6
|
+
palettes: string[]
|
|
7
|
+
colorPalettes: any
|
|
8
|
+
config: any
|
|
9
|
+
onPaletteSelect: (palette: string) => void
|
|
10
|
+
selectedPalette?: string
|
|
11
|
+
colorIndices?: [number, number, number]
|
|
12
|
+
className?: string
|
|
13
|
+
element?: 'button' | 'li'
|
|
14
|
+
minColorsForFilter?: (palette: string, paletteAccessor: any, config: any) => boolean
|
|
15
|
+
getItemClassName?: (palette: string) => string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const PaletteSelector: React.FC<PaletteSelectorProps> = ({
|
|
19
|
+
palettes,
|
|
20
|
+
colorPalettes,
|
|
21
|
+
config,
|
|
22
|
+
onPaletteSelect,
|
|
23
|
+
selectedPalette,
|
|
24
|
+
colorIndices = [2, 3, 5],
|
|
25
|
+
className = 'color-palette',
|
|
26
|
+
element = 'button',
|
|
27
|
+
minColorsForFilter,
|
|
28
|
+
getItemClassName
|
|
29
|
+
}) => {
|
|
30
|
+
|
|
31
|
+
const handlePaletteSelection = (palette: string) => (e: React.MouseEvent) => {
|
|
32
|
+
if (element === 'button') {
|
|
33
|
+
e.preventDefault()
|
|
34
|
+
}
|
|
35
|
+
onPaletteSelect(palette)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const getSelectedClass = (palette: string) => {
|
|
39
|
+
if (getItemClassName) {
|
|
40
|
+
return getItemClassName(palette)
|
|
41
|
+
}
|
|
42
|
+
return selectedPalette === palette ? 'selected' : ''
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const renderPaletteColors = (palette: string) => {
|
|
46
|
+
const [colorOneIndex, colorTwoIndex, colorThreeIndex] = colorIndices
|
|
47
|
+
|
|
48
|
+
// Use the enhanced getPaletteAccessor to get the specific palette colors
|
|
49
|
+
const paletteColors = getPaletteAccessor(colorPalettes, config, palette)
|
|
50
|
+
|
|
51
|
+
if (!paletteColors || !Array.isArray(paletteColors)) {
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<span style={{ backgroundColor: '#ccc' }}></span>
|
|
55
|
+
<span style={{ backgroundColor: '#ccc' }}></span>
|
|
56
|
+
<span style={{ backgroundColor: '#ccc' }}></span>
|
|
57
|
+
</>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const colorOne = {
|
|
62
|
+
backgroundColor: paletteColors[colorOneIndex] || '#ccc'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const colorTwo = {
|
|
66
|
+
backgroundColor: paletteColors[colorTwoIndex] || '#ccc'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const colorThree = {
|
|
70
|
+
backgroundColor: paletteColors[colorThreeIndex] || '#ccc'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
<span style={colorOne}></span>
|
|
76
|
+
<span style={colorTwo}></span>
|
|
77
|
+
<span style={colorThree}></span>
|
|
78
|
+
</>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const Container = element === 'li' ? 'ul' : 'div'
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Container className={className}>
|
|
86
|
+
{palettes.map(palette => {
|
|
87
|
+
// Apply custom filter if provided
|
|
88
|
+
if (minColorsForFilter) {
|
|
89
|
+
const paletteColors = getPaletteAccessor(colorPalettes, config, palette)
|
|
90
|
+
if (!minColorsForFilter(palette, paletteColors, config)) {
|
|
91
|
+
return null
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const Element = element
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Element
|
|
99
|
+
key={palette}
|
|
100
|
+
title={palette}
|
|
101
|
+
onClick={handlePaletteSelection(palette)}
|
|
102
|
+
className={getSelectedClass(palette)}
|
|
103
|
+
>
|
|
104
|
+
{renderPaletteColors(palette)}
|
|
105
|
+
</Element>
|
|
106
|
+
)
|
|
107
|
+
})}
|
|
108
|
+
</Container>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default PaletteSelector
|
|
@@ -46,8 +46,10 @@ const Table = ({
|
|
|
46
46
|
const headStyle = stickyHeader ? { position: 'sticky' as Position, top: 0, zIndex: 2 } : {}
|
|
47
47
|
const isGroupedMatrix = !Array.isArray(childrenMatrix)
|
|
48
48
|
|
|
49
|
+
const { cellMinWidth, ...tableAttrs } = tableOptions
|
|
50
|
+
|
|
49
51
|
return (
|
|
50
|
-
<table {...
|
|
52
|
+
<table {...tableAttrs}>
|
|
51
53
|
<caption className='visually-hidden'>{caption}</caption>
|
|
52
54
|
{noData ? (
|
|
53
55
|
<tr>
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
const Cell = ({ children, style, isBold = false, ariaLabel }) => {
|
|
2
|
+
// Use whiteSpace from style prop, defaulting to 'pre-line' for backwards compatibility
|
|
3
|
+
const whiteSpace = style?.whiteSpace || 'pre-line'
|
|
4
|
+
|
|
5
|
+
const contentWrapperStyle = {
|
|
6
|
+
whiteSpace: whiteSpace as any,
|
|
7
|
+
lineHeight: '1.4',
|
|
8
|
+
display: 'block' as const,
|
|
9
|
+
margin: 0,
|
|
10
|
+
padding: 0,
|
|
11
|
+
wordBreak: 'break-word' as const
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Only include aria-label if it has a value
|
|
15
|
+
const ariaProps = ariaLabel ? { 'aria-label': ariaLabel } : {}
|
|
16
|
+
|
|
17
|
+
// Keep whiteSpace on td style so it can be detected by tests and for proper rendering
|
|
18
|
+
const tdStyle = { ...style }
|
|
19
|
+
delete tdStyle.textOverflow
|
|
20
|
+
|
|
2
21
|
return (
|
|
3
|
-
<td
|
|
4
|
-
|
|
22
|
+
<td {...ariaProps} role='gridcell' style={tdStyle}>
|
|
23
|
+
<div style={contentWrapperStyle}>
|
|
24
|
+
{isBold ? <strong>{children}</strong> : children}
|
|
25
|
+
</div>
|
|
5
26
|
</td>
|
|
6
27
|
)
|
|
7
28
|
}
|
|
@@ -16,8 +16,7 @@ type RowProps = {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const Row: FC<RowProps> = props => {
|
|
19
|
-
const { childRow, rowKey,
|
|
20
|
-
const whiteSpace = wrapColumns ? 'unset' : 'nowrap'
|
|
19
|
+
const { childRow, rowKey, cellMinWidth = 0, isTotal, preliminaryData, rightAlignedCols, wrapColumns } = props
|
|
21
20
|
const minWidth = cellMinWidth + 'px'
|
|
22
21
|
const isHtmlString = (str: any): str is string => typeof str === 'string' && /<\/?[a-z][\s\S]*>/i.test(str)
|
|
23
22
|
const isReactNode = (val: any): boolean => React.isValidElement(val) || typeof val === 'object'
|
|
@@ -32,6 +31,9 @@ const Row: FC<RowProps> = props => {
|
|
|
32
31
|
{}
|
|
33
32
|
|
|
34
33
|
const textAlign = rightAlignedCols && rightAlignedCols[i] ? 'right' : ''
|
|
34
|
+
// Set whiteSpace based on wrapColumns prop (default to wrapping for backwards compatibility)
|
|
35
|
+
const whiteSpace = wrapColumns === false ? 'nowrap' : 'normal'
|
|
36
|
+
|
|
35
37
|
// handle Parsing
|
|
36
38
|
let content: ReactNode
|
|
37
39
|
if (isHtmlString(child)) {
|
|
@@ -46,7 +48,7 @@ const Row: FC<RowProps> = props => {
|
|
|
46
48
|
<Cell
|
|
47
49
|
ariaLabel={style?.color ? 'suppressed data' : ''}
|
|
48
50
|
key={rowKey + '__' + i}
|
|
49
|
-
style={{
|
|
51
|
+
style={{ minWidth, textAlign, whiteSpace, ...style }}
|
|
50
52
|
isBold={isTotal}
|
|
51
53
|
>
|
|
52
54
|
{content}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a } from 'vitest/dist/suite-IbNSsUWN'
|
|
2
2
|
import { BlurStrokeText } from '../BlurStrokeText'
|
|
3
|
-
import { Meta, StoryObj } from '@storybook/react'
|
|
3
|
+
import { Meta, StoryObj } from '@storybook/react-vite'
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof BlurStrokeText> = {
|
|
6
6
|
title: 'Components/Atoms/BlurStrokeText',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react'
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
2
|
|
|
3
3
|
import Filters from '../Filters'
|
|
4
4
|
import { VizFilter } from '../../types/VizFilter'
|
|
@@ -8,7 +8,14 @@ import { Visualization } from '../../types/Visualization'
|
|
|
8
8
|
|
|
9
9
|
const meta: Meta<typeof Filters> = {
|
|
10
10
|
title: 'Components/Molecules/Visualization Filters',
|
|
11
|
-
component: Filters
|
|
11
|
+
component: Filters,
|
|
12
|
+
decorators: [
|
|
13
|
+
Story => (
|
|
14
|
+
<div className='cdc-open-viz-module'>
|
|
15
|
+
<Story />
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
]
|
|
12
19
|
}
|
|
13
20
|
|
|
14
21
|
type Story = StoryObj<typeof Filters>
|
|
@@ -54,4 +61,16 @@ export const Tab: Story = generateConfig('tab')
|
|
|
54
61
|
|
|
55
62
|
export const TabBar: Story = generateConfig('tab bar')
|
|
56
63
|
|
|
64
|
+
export const WithApplyButton: Story = {
|
|
65
|
+
args: {
|
|
66
|
+
config: {
|
|
67
|
+
filters: generateFilters('dropdown'),
|
|
68
|
+
data: animalData,
|
|
69
|
+
filterBehavior: 'Apply Button',
|
|
70
|
+
type: 'chart'
|
|
71
|
+
} as any,
|
|
72
|
+
setFilters: () => {}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
57
76
|
export default meta
|