@cdc/data-bite 1.1.4 → 4.22.10
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/LICENSE +201 -0
- package/dist/cdcdatabite.js +8 -8
- package/examples/gallery/calculated-average.json +3167 -0
- package/examples/gallery/calculated-with-pic.json +3173 -0
- package/examples/gallery/max-value.json +3167 -0
- package/examples/gallery/sum-of-data.json +3161 -0
- package/examples/private/double.json +0 -0
- package/examples/private/totals.json +1 -0
- package/package.json +3 -3
- package/src/CdcDataBite.tsx +55 -100
- package/src/components/EditorPanel.js +549 -173
- package/src/index.html +11 -2
- package/src/scss/bite.scss +99 -37
- package/src/scss/editor-panel.scss +0 -1
- package/src/scss/main.scss +10 -2
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import { useDebounce } from 'use-debounce'
|
|
12
12
|
import Context from '../context'
|
|
13
|
-
import WarningImage from '
|
|
13
|
+
import WarningImage from '@cdc/core/assets/icon-warning-circle.svg'
|
|
14
14
|
import Tooltip from '@cdc/core/components/ui/Tooltip'
|
|
15
15
|
import Icon from '@cdc/core/components/ui/Icon'
|
|
16
16
|
import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
|
|
@@ -310,281 +310,657 @@ const EditorPanel = memo(() => {
|
|
|
310
310
|
|
|
311
311
|
return (
|
|
312
312
|
<ErrorBoundary component="EditorPanel">
|
|
313
|
-
{!config.newViz &&
|
|
313
|
+
{!config.newViz &&
|
|
314
|
+
config.runtime &&
|
|
315
|
+
config.runtime.editorErrorMessage && <Error />}
|
|
314
316
|
{(!config.dataColumn || !config.dataFunction) && <Confirm />}
|
|
315
|
-
<button
|
|
316
|
-
|
|
317
|
+
<button
|
|
318
|
+
className={displayPanel ? `editor-toggle` : `editor-toggle collapsed`}
|
|
319
|
+
title={displayPanel ? `Collapse Editor` : `Expand Editor`}
|
|
320
|
+
onClick={onBackClick}
|
|
321
|
+
/>
|
|
322
|
+
<section
|
|
323
|
+
className={
|
|
324
|
+
displayPanel ? "editor-panel cove" : "hidden editor-panel cove"
|
|
325
|
+
}
|
|
326
|
+
>
|
|
317
327
|
<div className="heading-2">Configure Data Bite</div>
|
|
318
328
|
<section className="form-container">
|
|
319
329
|
<form>
|
|
320
330
|
<Accordion allowZeroExpanded={true}>
|
|
321
|
-
<AccordionItem>
|
|
331
|
+
<AccordionItem>
|
|
332
|
+
{" "}
|
|
333
|
+
{/* General */}
|
|
322
334
|
<AccordionItemHeading>
|
|
323
|
-
<AccordionItemButton>
|
|
324
|
-
General
|
|
325
|
-
</AccordionItemButton>
|
|
335
|
+
<AccordionItemButton>General</AccordionItemButton>
|
|
326
336
|
</AccordionItemHeading>
|
|
327
337
|
<AccordionItemPanel>
|
|
328
|
-
<Select
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
338
|
+
<Select
|
|
339
|
+
value={config.biteStyle}
|
|
340
|
+
fieldName="biteStyle"
|
|
341
|
+
label="Data Bite Style"
|
|
342
|
+
updateField={updateField}
|
|
343
|
+
options={BITE_LOCATIONS}
|
|
344
|
+
initial="Select"
|
|
345
|
+
/>
|
|
346
|
+
<TextField
|
|
347
|
+
value={config.title}
|
|
348
|
+
fieldName="title"
|
|
349
|
+
label="Title"
|
|
350
|
+
placeholder="Data Bite Title"
|
|
351
|
+
updateField={updateField}
|
|
352
|
+
/>
|
|
353
|
+
|
|
354
|
+
<TextField
|
|
355
|
+
type="textarea"
|
|
356
|
+
value={config.biteBody}
|
|
357
|
+
fieldName="biteBody"
|
|
358
|
+
label="Message"
|
|
359
|
+
updateField={updateField}
|
|
360
|
+
tooltip={
|
|
361
|
+
<Tooltip style={{ textTransform: "none" }}>
|
|
362
|
+
<Tooltip.Target>
|
|
363
|
+
<Icon
|
|
364
|
+
display="question"
|
|
365
|
+
style={{ marginLeft: "0.5rem" }}
|
|
366
|
+
/>
|
|
367
|
+
</Tooltip.Target>
|
|
368
|
+
<Tooltip.Content>
|
|
369
|
+
<p>
|
|
370
|
+
Enter the message text for the visualization. The
|
|
371
|
+
following HTML tags are supported: strong, em, sup,
|
|
372
|
+
and sub.
|
|
373
|
+
</p>
|
|
374
|
+
</Tooltip.Content>
|
|
375
|
+
</Tooltip>
|
|
376
|
+
}
|
|
377
|
+
/>
|
|
378
|
+
<TextField
|
|
379
|
+
value={config.subtext}
|
|
380
|
+
fieldName="subtext"
|
|
381
|
+
label="Subtext/Citation"
|
|
382
|
+
placeholder="Data Bite Subtext or Citation"
|
|
383
|
+
updateField={updateField}
|
|
384
|
+
tooltip={
|
|
385
|
+
<Tooltip style={{ textTransform: "none" }}>
|
|
386
|
+
<Tooltip.Target>
|
|
387
|
+
<Icon
|
|
388
|
+
display="question"
|
|
389
|
+
style={{ marginLeft: "0.5rem" }}
|
|
390
|
+
/>
|
|
391
|
+
</Tooltip.Target>
|
|
392
|
+
<Tooltip.Content>
|
|
393
|
+
<p>
|
|
394
|
+
Enter supporting text to display below the data
|
|
395
|
+
visualization, if applicable. The following HTML
|
|
396
|
+
tags are supported: strong, em, sup, and sub.
|
|
397
|
+
</p>
|
|
398
|
+
</Tooltip.Content>
|
|
399
|
+
</Tooltip>
|
|
400
|
+
}
|
|
401
|
+
/>
|
|
355
402
|
</AccordionItemPanel>
|
|
356
403
|
</AccordionItem>
|
|
357
404
|
|
|
358
|
-
<AccordionItem>
|
|
405
|
+
<AccordionItem>
|
|
406
|
+
{" "}
|
|
407
|
+
{/*Data*/}
|
|
359
408
|
<AccordionItemHeading>
|
|
360
409
|
<AccordionItemButton>
|
|
361
|
-
Data
|
|
410
|
+
Data{" "}
|
|
411
|
+
{(!config.dataColumn || !config.dataFunction) && (
|
|
412
|
+
<WarningImage width="25" className="warning-icon" />
|
|
413
|
+
)}
|
|
362
414
|
</AccordionItemButton>
|
|
363
415
|
</AccordionItemHeading>
|
|
364
416
|
<AccordionItemPanel>
|
|
365
417
|
<ul className="column-edit">
|
|
366
418
|
<li className="two-col">
|
|
367
|
-
<Select
|
|
368
|
-
|
|
419
|
+
<Select
|
|
420
|
+
value={config.dataColumn || ""}
|
|
421
|
+
fieldName="dataColumn"
|
|
422
|
+
label="Data Column"
|
|
423
|
+
updateField={updateField}
|
|
424
|
+
initial="Select"
|
|
425
|
+
required={true}
|
|
426
|
+
options={getColumns()}
|
|
427
|
+
/>
|
|
428
|
+
<Select
|
|
429
|
+
value={config.dataFunction || ""}
|
|
430
|
+
fieldName="dataFunction"
|
|
431
|
+
label="Data Function"
|
|
432
|
+
updateField={updateField}
|
|
433
|
+
initial="Select"
|
|
434
|
+
required={true}
|
|
435
|
+
options={DATA_FUNCTIONS}
|
|
436
|
+
/>
|
|
369
437
|
</li>
|
|
370
438
|
</ul>
|
|
371
439
|
<span className="divider-heading">Number Formatting</span>
|
|
372
440
|
<ul className="column-edit">
|
|
373
441
|
<li className="three-col">
|
|
374
|
-
<TextField
|
|
375
|
-
|
|
376
|
-
|
|
442
|
+
<TextField
|
|
443
|
+
value={config.dataFormat.prefix}
|
|
444
|
+
section="dataFormat"
|
|
445
|
+
fieldName="prefix"
|
|
446
|
+
label="Prefix"
|
|
447
|
+
updateField={updateField}
|
|
448
|
+
/>
|
|
449
|
+
<TextField
|
|
450
|
+
value={config.dataFormat.suffix}
|
|
451
|
+
section="dataFormat"
|
|
452
|
+
fieldName="suffix"
|
|
453
|
+
label="Suffix"
|
|
454
|
+
updateField={updateField}
|
|
455
|
+
/>
|
|
456
|
+
<TextField
|
|
457
|
+
type="number"
|
|
458
|
+
value={config.dataFormat.roundToPlace}
|
|
459
|
+
section="dataFormat"
|
|
460
|
+
fieldName="roundToPlace"
|
|
461
|
+
label="Round"
|
|
462
|
+
updateField={updateField}
|
|
463
|
+
min="0"
|
|
464
|
+
max="99"
|
|
465
|
+
/>
|
|
377
466
|
</li>
|
|
378
467
|
</ul>
|
|
379
468
|
<CheckBox value={config.dataFormat.commas} section="dataFormat" fieldName="commas" label="Add commas" updateField={updateField} />
|
|
380
469
|
<CheckBox value={config.dataFormat.ignoreZeros} section="dataFormat" fieldName="ignoreZeros" label="Ignore Zeros" updateField={updateField} />
|
|
381
470
|
<hr className="accordion__divider" />
|
|
382
471
|
|
|
383
|
-
<label style={{marginBottom:
|
|
472
|
+
<label style={{ marginBottom: "1rem" }}>
|
|
384
473
|
<span className="edit-label">
|
|
385
474
|
Data Point Filters
|
|
386
|
-
<Tooltip style={{ textTransform:
|
|
387
|
-
<Tooltip.Target
|
|
475
|
+
<Tooltip style={{ textTransform: "none" }}>
|
|
476
|
+
<Tooltip.Target>
|
|
477
|
+
<Icon
|
|
478
|
+
display="question"
|
|
479
|
+
style={{ marginLeft: "0.5rem" }}
|
|
480
|
+
/>
|
|
481
|
+
</Tooltip.Target>
|
|
388
482
|
<Tooltip.Content>
|
|
389
|
-
<p>
|
|
390
|
-
|
|
483
|
+
<p>
|
|
484
|
+
To refine the highlighted data point, specify one or
|
|
485
|
+
more filters (e.g., "Male" and "Female" for a column
|
|
486
|
+
called "Sex").
|
|
487
|
+
</p>
|
|
391
488
|
</Tooltip.Content>
|
|
392
489
|
</Tooltip>
|
|
393
490
|
</span>
|
|
394
491
|
</label>
|
|
395
|
-
{
|
|
396
|
-
config.filters &&
|
|
492
|
+
{config.filters && (
|
|
397
493
|
<ul className="filters-list">
|
|
398
494
|
{config.filters.map((filter, index) => (
|
|
399
495
|
<fieldset className="edit-block" key={index}>
|
|
400
|
-
<button
|
|
496
|
+
<button
|
|
497
|
+
type="button"
|
|
498
|
+
className="remove-column"
|
|
499
|
+
onClick={() => {
|
|
500
|
+
removeFilter(index);
|
|
501
|
+
}}
|
|
502
|
+
>
|
|
503
|
+
Remove
|
|
504
|
+
</button>
|
|
401
505
|
<label>
|
|
402
|
-
<span className="edit-label column-heading">
|
|
403
|
-
|
|
506
|
+
<span className="edit-label column-heading">
|
|
507
|
+
Column
|
|
508
|
+
</span>
|
|
509
|
+
<select
|
|
510
|
+
value={filter.columnName ? filter.columnName : ""}
|
|
511
|
+
onChange={(e) => {
|
|
512
|
+
updateFilterProp(
|
|
513
|
+
"columnName",
|
|
514
|
+
index,
|
|
515
|
+
e.target.value
|
|
516
|
+
);
|
|
517
|
+
}}
|
|
518
|
+
>
|
|
404
519
|
<option value="">- Select Option -</option>
|
|
405
520
|
{getColumns().map((dataKey, index) => (
|
|
406
|
-
<option value={dataKey} key={index}>
|
|
521
|
+
<option value={dataKey} key={index}>
|
|
522
|
+
{dataKey}
|
|
523
|
+
</option>
|
|
407
524
|
))}
|
|
408
525
|
</select>
|
|
409
526
|
</label>
|
|
410
527
|
<label>
|
|
411
|
-
<span className="edit-label column-heading">
|
|
412
|
-
|
|
528
|
+
<span className="edit-label column-heading">
|
|
529
|
+
Column Value
|
|
530
|
+
</span>
|
|
531
|
+
<select
|
|
532
|
+
value={filter.columnValue}
|
|
533
|
+
onChange={(e) => {
|
|
534
|
+
updateFilterProp(
|
|
535
|
+
"columnValue",
|
|
536
|
+
index,
|
|
537
|
+
e.target.value
|
|
538
|
+
);
|
|
539
|
+
}}
|
|
540
|
+
>
|
|
413
541
|
<option value="">- Select Option -</option>
|
|
414
|
-
{getFilterColumnValues(index).map(
|
|
415
|
-
|
|
416
|
-
|
|
542
|
+
{getFilterColumnValues(index).map(
|
|
543
|
+
(dataKey, index) => (
|
|
544
|
+
<option value={dataKey} key={index}>
|
|
545
|
+
{dataKey}
|
|
546
|
+
</option>
|
|
547
|
+
)
|
|
548
|
+
)}
|
|
417
549
|
</select>
|
|
418
550
|
</label>
|
|
419
551
|
</fieldset>
|
|
420
552
|
))}
|
|
421
553
|
</ul>
|
|
422
|
-
}
|
|
423
|
-
{(!config.filters || config.filters.length === 0) &&
|
|
554
|
+
)}
|
|
555
|
+
{(!config.filters || config.filters.length === 0) && (
|
|
424
556
|
<div>
|
|
425
557
|
<fieldset className="edit-block">
|
|
426
|
-
<p style={{textAlign: "center"}}>
|
|
558
|
+
<p style={{ textAlign: "center" }}>
|
|
559
|
+
There are currently no filters.
|
|
560
|
+
</p>
|
|
427
561
|
</fieldset>
|
|
428
562
|
</div>
|
|
429
|
-
}
|
|
430
|
-
<button
|
|
563
|
+
)}
|
|
564
|
+
<button
|
|
565
|
+
type="button"
|
|
566
|
+
onClick={addNewFilter}
|
|
567
|
+
className="btn full-width"
|
|
568
|
+
>
|
|
569
|
+
Add Filter
|
|
570
|
+
</button>
|
|
431
571
|
</AccordionItemPanel>
|
|
432
572
|
</AccordionItem>
|
|
433
573
|
|
|
434
|
-
<AccordionItem>
|
|
574
|
+
<AccordionItem>
|
|
575
|
+
{" "}
|
|
576
|
+
{/*Visual*/}
|
|
435
577
|
<AccordionItemHeading>
|
|
436
|
-
<AccordionItemButton>
|
|
437
|
-
Visual
|
|
438
|
-
</AccordionItemButton>
|
|
578
|
+
<AccordionItemButton>Visual</AccordionItemButton>
|
|
439
579
|
</AccordionItemHeading>
|
|
440
580
|
<AccordionItemPanel>
|
|
441
|
-
<TextField
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
581
|
+
<TextField
|
|
582
|
+
type="number"
|
|
583
|
+
value={config.biteFontSize}
|
|
584
|
+
fieldName="biteFontSize"
|
|
585
|
+
label="Bite Font Size"
|
|
586
|
+
updateField={updateField}
|
|
587
|
+
min="17"
|
|
588
|
+
max="65"
|
|
589
|
+
/>
|
|
590
|
+
<Select
|
|
591
|
+
value={config.fontSize}
|
|
592
|
+
fieldName="fontSize"
|
|
593
|
+
label="Overall Font Size"
|
|
594
|
+
updateField={updateField}
|
|
595
|
+
options={["small", "medium", "large"]}
|
|
596
|
+
/>
|
|
597
|
+
<div className="checkbox-group">
|
|
598
|
+
<CheckBox
|
|
599
|
+
value={config.visual?.border}
|
|
600
|
+
section="visual"
|
|
601
|
+
fieldName="border"
|
|
602
|
+
label="Display Border"
|
|
603
|
+
updateField={updateField}
|
|
604
|
+
/>
|
|
605
|
+
<CheckBox
|
|
606
|
+
value={config.visual?.borderColorTheme}
|
|
607
|
+
section="visual"
|
|
608
|
+
fieldName="borderColorTheme"
|
|
609
|
+
label="Use Border Color Theme"
|
|
610
|
+
updateField={updateField}
|
|
611
|
+
/>
|
|
612
|
+
<CheckBox
|
|
613
|
+
value={config.visual?.accent}
|
|
614
|
+
section="visual"
|
|
615
|
+
fieldName="accent"
|
|
616
|
+
label="Use Accent Style"
|
|
617
|
+
updateField={updateField}
|
|
618
|
+
/>
|
|
619
|
+
<CheckBox
|
|
620
|
+
value={config.visual?.background}
|
|
621
|
+
section="visual"
|
|
622
|
+
fieldName="background"
|
|
623
|
+
label="Use Theme Background Color"
|
|
624
|
+
updateField={updateField}
|
|
625
|
+
/>
|
|
626
|
+
<CheckBox
|
|
627
|
+
value={config.visual?.hideBackgroundColor}
|
|
628
|
+
section="visual"
|
|
629
|
+
fieldName="hideBackgroundColor"
|
|
630
|
+
label="Hide Background Color"
|
|
631
|
+
updateField={updateField}
|
|
632
|
+
/>
|
|
633
|
+
</div>
|
|
634
|
+
<label>
|
|
445
635
|
<span className="edit-label">Theme</span>
|
|
446
636
|
<ul className="color-palette">
|
|
447
|
-
{headerColors.map(
|
|
448
|
-
<li
|
|
637
|
+
{headerColors.map((palette) => (
|
|
638
|
+
<li
|
|
639
|
+
title={palette}
|
|
640
|
+
key={palette}
|
|
641
|
+
onClick={() => {
|
|
642
|
+
updateConfig({ ...config, theme: palette });
|
|
643
|
+
}}
|
|
644
|
+
className={
|
|
645
|
+
config.theme === palette
|
|
646
|
+
? "selected " + palette
|
|
647
|
+
: palette
|
|
648
|
+
}
|
|
649
|
+
/>
|
|
449
650
|
))}
|
|
450
651
|
</ul>
|
|
451
652
|
</label>
|
|
452
|
-
{/* <div className="cove-accordion__panel-section">
|
|
453
|
-
<CheckBox value={config.visual.border} section="visual" fieldName="border" label="Display Border" updateField={updateField} />
|
|
454
|
-
<CheckBox value={config.visual.borderColorTheme} section="visual" fieldName="borderColorTheme" label="Use Border Color Theme" updateField={updateField} />
|
|
455
|
-
<CheckBox value={config.visual.accent} section="visual" fieldName="accent" label="Use Accent Style" updateField={updateField} />
|
|
456
|
-
<CheckBox value={config.visual.background} section="visual" fieldName="background" label="Use Theme Background Color" updateField={updateField} />
|
|
457
|
-
<CheckBox value={config.visual.hideBackgroundColor} section="visual" fieldName="hideBackgroundColor" label="Hide Background Color" updateField={updateField} />
|
|
458
|
-
</div> */}
|
|
459
653
|
</AccordionItemPanel>
|
|
460
654
|
</AccordionItem>
|
|
461
655
|
|
|
462
|
-
{['title', 'body', 'graphic'].includes(config.biteStyle) &&
|
|
463
|
-
<AccordionItem>
|
|
656
|
+
{['title', 'body', 'graphic'].includes(config.biteStyle) && (
|
|
657
|
+
<AccordionItem>
|
|
658
|
+
{" "}
|
|
659
|
+
{/*Image & Dynamic Images*/}
|
|
464
660
|
<AccordionItemHeading>
|
|
465
661
|
<AccordionItemButton>
|
|
466
|
-
Image
|
|
662
|
+
Image
|
|
663
|
+
{["dynamic"].includes(config.imageData.display) && "s"}
|
|
467
664
|
</AccordionItemButton>
|
|
468
665
|
</AccordionItemHeading>
|
|
469
|
-
|
|
470
666
|
<AccordionItemPanel>
|
|
471
|
-
<Select
|
|
472
|
-
|
|
473
|
-
|
|
667
|
+
<Select
|
|
668
|
+
value={config.imageData.display || ""}
|
|
669
|
+
section="imageData"
|
|
670
|
+
fieldName="display"
|
|
671
|
+
label="Image Display Type"
|
|
672
|
+
updateField={updateField}
|
|
673
|
+
options={["none", "static", "dynamic"]}
|
|
674
|
+
/>
|
|
675
|
+
<Select
|
|
676
|
+
value={config.bitePosition || ""}
|
|
677
|
+
fieldName="bitePosition"
|
|
678
|
+
label="Image/Graphic Position"
|
|
679
|
+
updateField={updateField}
|
|
680
|
+
initial="Select"
|
|
681
|
+
options={IMAGE_POSITIONS}
|
|
682
|
+
/>
|
|
683
|
+
{["static"].includes(config.imageData.display) && (
|
|
474
684
|
<>
|
|
475
|
-
<TextField
|
|
476
|
-
|
|
685
|
+
<TextField
|
|
686
|
+
value={config.imageData.url}
|
|
687
|
+
section="imageData"
|
|
688
|
+
fieldName="url"
|
|
689
|
+
label="Image URL"
|
|
690
|
+
updateField={updateField}
|
|
691
|
+
/>
|
|
692
|
+
<TextField
|
|
693
|
+
value={config.imageData.alt}
|
|
694
|
+
section="imageData"
|
|
695
|
+
fieldName="alt"
|
|
696
|
+
label="Alt Text"
|
|
697
|
+
updateField={updateField}
|
|
698
|
+
/>
|
|
477
699
|
</>
|
|
478
|
-
}
|
|
700
|
+
)}
|
|
479
701
|
|
|
480
|
-
{[
|
|
702
|
+
{["dynamic"].includes(config.imageData.display) && (
|
|
481
703
|
<>
|
|
482
|
-
<TextField
|
|
483
|
-
|
|
704
|
+
<TextField
|
|
705
|
+
value={config.imageData.url || ""}
|
|
706
|
+
section="imageData"
|
|
707
|
+
fieldName="url"
|
|
708
|
+
label="Image URL (default)"
|
|
709
|
+
updateField={updateField}
|
|
710
|
+
/>
|
|
711
|
+
<TextField
|
|
712
|
+
value={config.imageData.alt}
|
|
713
|
+
section="imageData"
|
|
714
|
+
fieldName="alt"
|
|
715
|
+
label="Alt Text (default)"
|
|
716
|
+
updateField={updateField}
|
|
717
|
+
/>
|
|
484
718
|
|
|
485
719
|
<hr className="accordion__divider" />
|
|
486
720
|
|
|
487
|
-
{(!config.imageData.options ||
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
</
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}}>
|
|
520
|
-
<option value={'then'}>Then</option>
|
|
521
|
-
<option value={'and'}>And</option>
|
|
522
|
-
</select>
|
|
523
|
-
</div>
|
|
524
|
-
</div>
|
|
525
|
-
|
|
526
|
-
{option.secondArgument && true === option.secondArgument &&
|
|
527
|
-
<>
|
|
721
|
+
{(!config.imageData.options ||
|
|
722
|
+
config.imageData.options.length === 0) && (
|
|
723
|
+
<p style={{ textAlign: "center" }}>
|
|
724
|
+
There are currently no dynamic images.
|
|
725
|
+
</p>
|
|
726
|
+
)}
|
|
727
|
+
{config.imageData.options &&
|
|
728
|
+
config.imageData.options.length > 0 && (
|
|
729
|
+
<>
|
|
730
|
+
<ul>
|
|
731
|
+
{config.imageData.options.map(
|
|
732
|
+
(option, index) => (
|
|
733
|
+
<fieldset
|
|
734
|
+
className="edit-block"
|
|
735
|
+
key={index}
|
|
736
|
+
>
|
|
737
|
+
<button
|
|
738
|
+
type="button"
|
|
739
|
+
className="remove-column"
|
|
740
|
+
onClick={() => {
|
|
741
|
+
removeDynamicImage(index);
|
|
742
|
+
}}
|
|
743
|
+
>
|
|
744
|
+
Remove
|
|
745
|
+
</button>
|
|
746
|
+
<label>
|
|
747
|
+
<span className="edit-label column-heading">
|
|
748
|
+
<strong>
|
|
749
|
+
{"Image #" + (index + 1)}
|
|
750
|
+
</strong>
|
|
751
|
+
</span>
|
|
752
|
+
|
|
528
753
|
<div className="accordion__panel-row align-center">
|
|
529
754
|
<div className="accordion__panel-col flex-auto">
|
|
530
755
|
If Value
|
|
531
756
|
</div>
|
|
532
757
|
<div className="accordion__panel-col flex-auto">
|
|
533
|
-
<select
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
758
|
+
<select
|
|
759
|
+
value={
|
|
760
|
+
option.arguments[0]?.operator ||
|
|
761
|
+
""
|
|
762
|
+
}
|
|
763
|
+
onChange={(e) => {
|
|
764
|
+
updateDynamicImage(
|
|
765
|
+
"operator",
|
|
766
|
+
index,
|
|
767
|
+
0,
|
|
768
|
+
e.target.value
|
|
769
|
+
);
|
|
770
|
+
}}
|
|
771
|
+
>
|
|
772
|
+
<option value="" disabled />
|
|
773
|
+
{DATA_OPERATORS.map(
|
|
774
|
+
(operator, index) => (
|
|
775
|
+
<option
|
|
776
|
+
value={operator}
|
|
777
|
+
key={index}
|
|
778
|
+
>
|
|
779
|
+
{operator}
|
|
780
|
+
</option>
|
|
781
|
+
)
|
|
782
|
+
)}
|
|
538
783
|
</select>
|
|
539
784
|
</div>
|
|
540
785
|
<div className="accordion__panel-col flex-grow flex-shrink">
|
|
541
|
-
<input
|
|
786
|
+
<input
|
|
787
|
+
type="number"
|
|
788
|
+
value={
|
|
789
|
+
option.arguments[0]
|
|
790
|
+
?.threshold || ""
|
|
791
|
+
}
|
|
792
|
+
onChange={(e) => {
|
|
793
|
+
updateDynamicImage(
|
|
794
|
+
"threshold",
|
|
795
|
+
index,
|
|
796
|
+
0,
|
|
797
|
+
e.target.value
|
|
798
|
+
);
|
|
799
|
+
}}
|
|
800
|
+
/>
|
|
542
801
|
</div>
|
|
543
802
|
</div>
|
|
544
|
-
|
|
803
|
+
|
|
804
|
+
<div className="accordion__panel-row mb-2 align-center">
|
|
545
805
|
<div className="accordion__panel-col flex-grow">
|
|
546
|
-
|
|
806
|
+
<select
|
|
807
|
+
className="border-dashed text-center"
|
|
808
|
+
value={
|
|
809
|
+
option.secondArgument
|
|
810
|
+
? "and"
|
|
811
|
+
: "then"
|
|
812
|
+
}
|
|
813
|
+
onChange={(e) => {
|
|
814
|
+
if ("then" === e.target.value) {
|
|
815
|
+
updateDynamicImage(
|
|
816
|
+
"secondArgument",
|
|
817
|
+
index,
|
|
818
|
+
null,
|
|
819
|
+
false
|
|
820
|
+
);
|
|
821
|
+
removeDynamicArgument(index);
|
|
822
|
+
}
|
|
823
|
+
if ("and" === e.target.value) {
|
|
824
|
+
updateDynamicImage(
|
|
825
|
+
"secondArgument",
|
|
826
|
+
index,
|
|
827
|
+
null,
|
|
828
|
+
true
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
}}
|
|
832
|
+
>
|
|
833
|
+
<option value={"then"}>
|
|
834
|
+
Then
|
|
835
|
+
</option>
|
|
836
|
+
<option value={"and"}>And</option>
|
|
837
|
+
</select>
|
|
547
838
|
</div>
|
|
548
839
|
</div>
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
840
|
+
|
|
841
|
+
{option.secondArgument &&
|
|
842
|
+
true === option.secondArgument && (
|
|
843
|
+
<>
|
|
844
|
+
<div className="accordion__panel-row align-center">
|
|
845
|
+
<div className="accordion__panel-col flex-auto">
|
|
846
|
+
If Value
|
|
847
|
+
</div>
|
|
848
|
+
<div className="accordion__panel-col flex-auto">
|
|
849
|
+
<select
|
|
850
|
+
value={
|
|
851
|
+
option.arguments[1]
|
|
852
|
+
?.operator || ""
|
|
853
|
+
}
|
|
854
|
+
onChange={(e) => {
|
|
855
|
+
setDynamicArgument(
|
|
856
|
+
index,
|
|
857
|
+
"operator",
|
|
858
|
+
e.target.value
|
|
859
|
+
);
|
|
860
|
+
}}
|
|
861
|
+
>
|
|
862
|
+
<option value="" disabled />
|
|
863
|
+
{DATA_OPERATORS.map(
|
|
864
|
+
(operator, index) => (
|
|
865
|
+
<option
|
|
866
|
+
value={operator}
|
|
867
|
+
key={index}
|
|
868
|
+
>
|
|
869
|
+
{operator}
|
|
870
|
+
</option>
|
|
871
|
+
)
|
|
872
|
+
)}
|
|
873
|
+
</select>
|
|
874
|
+
</div>
|
|
875
|
+
<div className="accordion__panel-col flex-grow flex-shrink">
|
|
876
|
+
<input
|
|
877
|
+
type="number"
|
|
878
|
+
value={
|
|
879
|
+
option.arguments[1]
|
|
880
|
+
?.threshold || ""
|
|
881
|
+
}
|
|
882
|
+
onChange={(e) => {
|
|
883
|
+
setDynamicArgument(
|
|
884
|
+
index,
|
|
885
|
+
"threshold",
|
|
886
|
+
e.target.value
|
|
887
|
+
);
|
|
888
|
+
}}
|
|
889
|
+
/>
|
|
890
|
+
</div>
|
|
891
|
+
</div>
|
|
892
|
+
<div className="accordion__panel-row mb-2 align-center text-center text-capitalize">
|
|
893
|
+
<div className="accordion__panel-col flex-grow">
|
|
894
|
+
Then
|
|
895
|
+
</div>
|
|
896
|
+
</div>
|
|
897
|
+
</>
|
|
898
|
+
)}
|
|
899
|
+
|
|
900
|
+
<div className="accordion__panel-row mb-2 align-center">
|
|
901
|
+
<div className="accordion__panel-col flex-auto">
|
|
902
|
+
Show
|
|
903
|
+
</div>
|
|
904
|
+
<div className="accordion__panel-col flex-grow">
|
|
905
|
+
<input
|
|
906
|
+
type="text"
|
|
907
|
+
value={option.source || ""}
|
|
908
|
+
onChange={(e) => {
|
|
909
|
+
updateDynamicImage(
|
|
910
|
+
"source",
|
|
911
|
+
index,
|
|
912
|
+
null,
|
|
913
|
+
e.target.value
|
|
914
|
+
);
|
|
915
|
+
}}
|
|
916
|
+
/>
|
|
917
|
+
</div>
|
|
918
|
+
</div>
|
|
919
|
+
|
|
920
|
+
<div className="accordion__panel-row mb-2 align-center">
|
|
921
|
+
<div className="accordion__panel-col flex-auto">
|
|
922
|
+
Alt Text
|
|
923
|
+
</div>
|
|
924
|
+
<div className="accordion__panel-col flex-grow">
|
|
925
|
+
<input
|
|
926
|
+
type="text"
|
|
927
|
+
value={option.alt || ""}
|
|
928
|
+
onChange={(e) => {
|
|
929
|
+
updateDynamicImage(
|
|
930
|
+
"alt",
|
|
931
|
+
index,
|
|
932
|
+
null,
|
|
933
|
+
e.target.value
|
|
934
|
+
);
|
|
935
|
+
}}
|
|
936
|
+
/>
|
|
937
|
+
</div>
|
|
938
|
+
</div>
|
|
939
|
+
</label>
|
|
940
|
+
</fieldset>
|
|
941
|
+
)
|
|
942
|
+
)}
|
|
943
|
+
</ul>
|
|
944
|
+
</>
|
|
945
|
+
)}
|
|
946
|
+
<button
|
|
947
|
+
type="button"
|
|
948
|
+
onClick={addDynamicImage}
|
|
949
|
+
className="btn full-width"
|
|
950
|
+
>
|
|
951
|
+
Add Dynamic Image
|
|
952
|
+
</button>
|
|
576
953
|
</>
|
|
577
|
-
}
|
|
954
|
+
)}
|
|
578
955
|
</AccordionItemPanel>
|
|
579
956
|
</AccordionItem>
|
|
580
|
-
}
|
|
581
|
-
|
|
957
|
+
)}
|
|
582
958
|
</Accordion>
|
|
583
959
|
</form>
|
|
584
960
|
</section>
|
|
585
961
|
</section>
|
|
586
962
|
</ErrorBoundary>
|
|
587
|
-
)
|
|
963
|
+
);
|
|
588
964
|
})
|
|
589
965
|
|
|
590
966
|
export default EditorPanel;
|