@cdc/data-bite 4.24.10 → 4.24.12
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/dist/cdcdatabite.js +1808 -1444
- package/package.json +3 -3
- package/src/CdcDataBite.tsx +84 -12
- package/src/components/EditorPanel.jsx +344 -127
- package/src/scss/editor-panel.scss +0 -3
- package/src/scss/main.scss +0 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/data-bite",
|
|
3
|
-
"version": "4.24.
|
|
3
|
+
"version": "4.24.12",
|
|
4
4
|
"description": "React component for displaying a single piece of data in a card module",
|
|
5
5
|
"moduleName": "CdcDataBite",
|
|
6
6
|
"main": "dist/cdcdatabite",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"license": "Apache-2.0",
|
|
28
28
|
"homepage": "https://github.com/CDCgov/cdc-open-viz#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@cdc/core": "^4.24.
|
|
30
|
+
"@cdc/core": "^4.24.12",
|
|
31
31
|
"chroma": "0.0.1",
|
|
32
32
|
"chroma-js": "^2.1.0",
|
|
33
33
|
"html-react-parser": "^3.0.8",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"react": "^18.2.0",
|
|
41
41
|
"react-dom": "^18.2.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "347414f1da4b0e9bf2f22a7b59335deccf0b2d9c"
|
|
44
44
|
}
|
package/src/CdcDataBite.tsx
CHANGED
|
@@ -42,7 +42,14 @@ type CdcDataBiteProps = {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const CdcDataBite = (props: CdcDataBiteProps) => {
|
|
45
|
-
const {
|
|
45
|
+
const {
|
|
46
|
+
configUrl,
|
|
47
|
+
config: configObj,
|
|
48
|
+
isDashboard = false,
|
|
49
|
+
isEditor = false,
|
|
50
|
+
setConfig: setParentConfig,
|
|
51
|
+
link
|
|
52
|
+
} = props
|
|
46
53
|
|
|
47
54
|
const initialState = {
|
|
48
55
|
config: configObj ?? defaults,
|
|
@@ -56,7 +63,18 @@ const CdcDataBite = (props: CdcDataBiteProps) => {
|
|
|
56
63
|
|
|
57
64
|
const { config, loading, currentViewport, coveLoadedHasRan, container } = state
|
|
58
65
|
|
|
59
|
-
const {
|
|
66
|
+
const {
|
|
67
|
+
title,
|
|
68
|
+
dataColumn,
|
|
69
|
+
dataFunction,
|
|
70
|
+
imageData,
|
|
71
|
+
biteBody,
|
|
72
|
+
biteFontSize,
|
|
73
|
+
dataFormat,
|
|
74
|
+
biteStyle,
|
|
75
|
+
filters,
|
|
76
|
+
subtext
|
|
77
|
+
} = config
|
|
60
78
|
|
|
61
79
|
const { innerContainerClasses, contentClasses } = useDataVizClasses(config)
|
|
62
80
|
|
|
@@ -312,7 +330,14 @@ const CdcDataBite = (props: CdcDataBiteProps) => {
|
|
|
312
330
|
rangeMin = applyLocaleString(rangeMin)
|
|
313
331
|
rangeMax = applyLocaleString(rangeMax)
|
|
314
332
|
}
|
|
315
|
-
dataBite =
|
|
333
|
+
dataBite =
|
|
334
|
+
config.dataFormat.prefix +
|
|
335
|
+
rangeMin +
|
|
336
|
+
config.dataFormat.suffix +
|
|
337
|
+
' - ' +
|
|
338
|
+
config.dataFormat.prefix +
|
|
339
|
+
rangeMax +
|
|
340
|
+
config.dataFormat.suffix
|
|
316
341
|
break
|
|
317
342
|
default:
|
|
318
343
|
console.warn('Data bite function not recognized: ' + dataFunction)
|
|
@@ -421,7 +446,9 @@ const CdcDataBite = (props: CdcDataBiteProps) => {
|
|
|
421
446
|
})
|
|
422
447
|
}
|
|
423
448
|
|
|
424
|
-
return imageSource.length > 0 && 'graphic' !== biteStyle && 'none' !== imageData.display ?
|
|
449
|
+
return imageSource.length > 0 && 'graphic' !== biteStyle && 'none' !== imageData.display ? (
|
|
450
|
+
<img alt={imageAlt} src={imageSource} className='bite-image callout' />
|
|
451
|
+
) : null
|
|
425
452
|
}, [imageData])
|
|
426
453
|
|
|
427
454
|
if (false === loading) {
|
|
@@ -495,7 +522,7 @@ const CdcDataBite = (props: CdcDataBiteProps) => {
|
|
|
495
522
|
<h3>Finish Configuring</h3>
|
|
496
523
|
<p>Set all required options to the left and confirm below to display a preview of the chart.</p>
|
|
497
524
|
<button
|
|
498
|
-
className='btn'
|
|
525
|
+
className='btn btn-primary'
|
|
499
526
|
style={{ margin: '1em auto' }}
|
|
500
527
|
disabled={missingRequiredSections()}
|
|
501
528
|
onClick={e => {
|
|
@@ -518,10 +545,22 @@ const CdcDataBite = (props: CdcDataBiteProps) => {
|
|
|
518
545
|
<div className={`cove-component__content`}>
|
|
519
546
|
{!config.newViz && config.runtime && config.runtime.editorErrorMessage && <Error />}
|
|
520
547
|
{(!config.dataColumn || !config.dataFunction) && <Confirm />}
|
|
521
|
-
<Title
|
|
548
|
+
<Title
|
|
549
|
+
config={config}
|
|
550
|
+
title={title}
|
|
551
|
+
isDashboard={isDashboard}
|
|
552
|
+
classes={['bite-header', `${config.theme}`]}
|
|
553
|
+
/>
|
|
522
554
|
<div className={`bite ${biteClasses.join(' ')}`}>
|
|
523
555
|
<div className={`bite-content-container ${contentClasses.join(' ')}`}>
|
|
524
|
-
{showBite && 'graphic' === biteStyle && isTop &&
|
|
556
|
+
{showBite && 'graphic' === biteStyle && isTop && (
|
|
557
|
+
<CircleCallout
|
|
558
|
+
theme={config.theme}
|
|
559
|
+
text={calculateDataBite()}
|
|
560
|
+
biteFontSize={biteFontSize}
|
|
561
|
+
dataFormat={dataFormat}
|
|
562
|
+
/>
|
|
563
|
+
)}
|
|
525
564
|
{isTop && <DataImage />}
|
|
526
565
|
<div className={`bite-content`}>
|
|
527
566
|
{showBite && 'title' === biteStyle && (
|
|
@@ -554,7 +593,14 @@ const CdcDataBite = (props: CdcDataBiteProps) => {
|
|
|
554
593
|
</Fragment>
|
|
555
594
|
</div>
|
|
556
595
|
{isBottom && <DataImage />}
|
|
557
|
-
{showBite && 'graphic' === biteStyle && !isTop &&
|
|
596
|
+
{showBite && 'graphic' === biteStyle && !isTop && (
|
|
597
|
+
<CircleCallout
|
|
598
|
+
theme={config.theme}
|
|
599
|
+
text={calculateDataBite()}
|
|
600
|
+
biteFontSize={biteFontSize}
|
|
601
|
+
dataFormat={dataFormat}
|
|
602
|
+
/>
|
|
603
|
+
)}
|
|
558
604
|
</div>
|
|
559
605
|
</div>
|
|
560
606
|
</div>
|
|
@@ -567,12 +613,22 @@ const CdcDataBite = (props: CdcDataBiteProps) => {
|
|
|
567
613
|
return (
|
|
568
614
|
<Context.Provider value={{ config, updateConfig, loading, data: config.data, setParentConfig, isDashboard }}>
|
|
569
615
|
{biteStyle !== 'gradient' && (
|
|
570
|
-
<Layout.VisualizationWrapper
|
|
616
|
+
<Layout.VisualizationWrapper
|
|
617
|
+
ref={outerContainerRef}
|
|
618
|
+
config={config}
|
|
619
|
+
isEditor={isEditor}
|
|
620
|
+
showEditorPanel={config?.showEditorPanel}
|
|
621
|
+
>
|
|
571
622
|
{body}
|
|
572
623
|
</Layout.VisualizationWrapper>
|
|
573
624
|
)}
|
|
574
625
|
{'gradient' === biteStyle && (
|
|
575
|
-
<Layout.VisualizationWrapper
|
|
626
|
+
<Layout.VisualizationWrapper
|
|
627
|
+
ref={outerContainerRef}
|
|
628
|
+
config={config}
|
|
629
|
+
isEditor={isEditor}
|
|
630
|
+
showEditorPanel={config?.showEditorPanel}
|
|
631
|
+
>
|
|
576
632
|
{isEditor && <EditorPanel />}
|
|
577
633
|
<Layout.Responsive isEditor={isEditor}>
|
|
578
634
|
{!config.newViz && config.runtime && config.runtime.editorErrorMessage && <Error />}
|
|
@@ -596,7 +652,16 @@ export const DATA_FUNCTION_MIN = 'Min'
|
|
|
596
652
|
export const DATA_FUNCTION_MODE = 'Mode'
|
|
597
653
|
export const DATA_FUNCTION_RANGE = 'Range'
|
|
598
654
|
export const DATA_FUNCTION_SUM = 'Sum'
|
|
599
|
-
export const DATA_FUNCTIONS = [
|
|
655
|
+
export const DATA_FUNCTIONS = [
|
|
656
|
+
DATA_FUNCTION_COUNT,
|
|
657
|
+
DATA_FUNCTION_MAX,
|
|
658
|
+
DATA_FUNCTION_MEAN,
|
|
659
|
+
DATA_FUNCTION_MEDIAN,
|
|
660
|
+
DATA_FUNCTION_MIN,
|
|
661
|
+
DATA_FUNCTION_MODE,
|
|
662
|
+
DATA_FUNCTION_RANGE,
|
|
663
|
+
DATA_FUNCTION_SUM
|
|
664
|
+
]
|
|
600
665
|
|
|
601
666
|
export const BITE_LOCATION_TITLE = 'title'
|
|
602
667
|
export const BITE_LOCATION_BODY = 'body'
|
|
@@ -623,4 +688,11 @@ export const DATA_OPERATOR_GREATEREQUAL = '>='
|
|
|
623
688
|
export const DATA_OPERATOR_EQUAL = '='
|
|
624
689
|
export const DATA_OPERATOR_NOTEQUAL = '≠'
|
|
625
690
|
|
|
626
|
-
export const DATA_OPERATORS = [
|
|
691
|
+
export const DATA_OPERATORS = [
|
|
692
|
+
DATA_OPERATOR_LESS,
|
|
693
|
+
DATA_OPERATOR_GREATER,
|
|
694
|
+
DATA_OPERATOR_LESSEQUAL,
|
|
695
|
+
DATA_OPERATOR_GREATEREQUAL,
|
|
696
|
+
DATA_OPERATOR_EQUAL,
|
|
697
|
+
DATA_OPERATOR_NOTEQUAL
|
|
698
|
+
]
|