@cdc/core 4.25.3-6 → 4.25.5-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 (90) hide show
  1. package/assets/icon-close.svg +1 -1
  2. package/components/AdvancedEditor/AdvancedEditor.tsx +11 -9
  3. package/components/DataTable/DataTable.tsx +50 -31
  4. package/components/DataTable/components/CellAnchor.tsx +1 -1
  5. package/components/DataTable/components/ChartHeader.tsx +3 -2
  6. package/components/DataTable/components/MapHeader.tsx +1 -0
  7. package/components/DataTable/helpers/chartCellMatrix.tsx +2 -1
  8. package/components/DataTable/helpers/getChartCellValue.ts +11 -5
  9. package/components/DataTable/helpers/getDataSeriesColumns.ts +7 -3
  10. package/components/DataTable/helpers/mapCellMatrix.tsx +80 -39
  11. package/components/DataTable/helpers/tests/mapCellMatrix.test.ts +80 -0
  12. package/components/DownloadButton.tsx +17 -2
  13. package/components/EditorPanel/DataTableEditor.tsx +29 -19
  14. package/components/EditorPanel/Inputs.tsx +13 -4
  15. package/components/EditorPanel/VizFilterEditor/NestedDropdownEditor.tsx +2 -1
  16. package/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +26 -1
  17. package/components/Filters/Filters.tsx +172 -421
  18. package/components/Filters/components/Dropdown.tsx +39 -0
  19. package/components/Filters/components/Tabs.tsx +82 -0
  20. package/components/Filters/helpers/getChangedFilters.ts +31 -0
  21. package/components/Filters/helpers/getNestedOptions.ts +2 -2
  22. package/components/Filters/helpers/getNewRuntime.ts +35 -0
  23. package/components/Filters/helpers/handleSorting.ts +2 -2
  24. package/components/Filters/helpers/tests/getChangedFilters.test.ts +92 -0
  25. package/components/Filters/helpers/tests/getNestedOptions.test.ts +31 -0
  26. package/components/Filters/helpers/tests/getNewRuntime.test.ts +82 -0
  27. package/components/Filters/index.ts +1 -1
  28. package/components/Layout/components/Visualization/index.tsx +3 -3
  29. package/components/Layout/components/Visualization/visualizations.scss +1 -1
  30. package/components/Legend/Legend.Gradient.tsx +66 -23
  31. package/components/MediaControls.jsx +14 -7
  32. package/components/MultiSelect/multiselect.styles.css +2 -0
  33. package/components/NestedDropdown/NestedDropdown.tsx +2 -2
  34. package/components/RichTooltip/RichTooltip.tsx +37 -0
  35. package/components/RichTooltip/richTooltip.css +16 -0
  36. package/components/Table/Table.tsx +142 -142
  37. package/components/Table/components/Row.tsx +1 -1
  38. package/components/Table/table.styles.css +10 -0
  39. package/components/_stories/DataTable.stories.tsx +9 -2
  40. package/components/_stories/Table.stories.tsx +1 -1
  41. package/components/_stories/styles.scss +0 -4
  42. package/components/elements/Button.jsx +4 -2
  43. package/components/ui/Accordion.jsx +8 -1
  44. package/components/ui/Title/index.tsx +4 -1
  45. package/components/ui/Title/{Title.scss → title.styles.css} +0 -2
  46. package/components/ui/_stories/Colors.stories.mdx +220 -0
  47. package/components/ui/_stories/IconGallery.stories.mdx +14 -0
  48. package/components/ui/_stories/Title.stories.tsx +29 -4
  49. package/components/ui/accordion.styles.css +3 -0
  50. package/data/colorPalettes.js +0 -1
  51. package/dist/cove-main.css +101 -159
  52. package/dist/cove-main.css.map +1 -1
  53. package/helpers/DataTransform.ts +2 -2
  54. package/helpers/addValuesToFilters.ts +1 -1
  55. package/helpers/constants.ts +6 -0
  56. package/helpers/cove/accessibility.ts +7 -8
  57. package/helpers/coveUpdateWorker.ts +17 -8
  58. package/helpers/filterOrderOptions.ts +17 -0
  59. package/helpers/formatConfigBeforeSave.ts +30 -8
  60. package/helpers/isNumber.ts +20 -0
  61. package/helpers/isRightAlignedTableValue.js +6 -2
  62. package/helpers/isSolr.ts +13 -0
  63. package/helpers/labelHash.ts +21 -0
  64. package/helpers/pivotData.ts +30 -18
  65. package/helpers/tests/formatConfigBeforeSave.test.ts +68 -0
  66. package/helpers/tests/pivotData.test.ts +96 -18
  67. package/helpers/ver/4.25.3.ts +43 -0
  68. package/helpers/ver/4.25.4.ts +33 -0
  69. package/helpers/ver/tests/4.25.4.test.ts +24 -0
  70. package/helpers/ver/tests/versionNeedsUpdate.test.ts +28 -0
  71. package/helpers/viewports.ts +4 -0
  72. package/package.json +2 -3
  73. package/styles/_global-variables.scss +5 -1
  74. package/styles/_global.scss +18 -9
  75. package/styles/_reset.scss +0 -6
  76. package/styles/base.scss +42 -0
  77. package/styles/filters.scss +5 -11
  78. package/styles/v2/components/button.scss +48 -12
  79. package/styles/v2/main.scss +0 -5
  80. package/styles/v2/themes/_color-definitions.scss +1 -4
  81. package/types/General.ts +1 -1
  82. package/types/Legend.ts +1 -0
  83. package/types/Table.ts +2 -0
  84. package/LICENSE +0 -201
  85. package/components/ui/_stories/Colors.stories.tsx +0 -92
  86. package/components/ui/_stories/Icon.stories.tsx +0 -29
  87. package/helpers/cove/fontSettings.ts +0 -2
  88. package/helpers/isNumber.js +0 -24
  89. package/helpers/isNumberLog.js +0 -18
  90. package/helpers/isSolr.js +0 -13
@@ -0,0 +1,37 @@
1
+ import React from 'react'
2
+ import { Tooltip as ReactTooltip } from 'react-tooltip'
3
+ import './richTooltip.css'
4
+
5
+ const RichTooltip = ({ linkText, href = null, tooltipOpacity = 100, tooltipContent }) => {
6
+ return (
7
+ <>
8
+ <a
9
+ className='tooltip-link'
10
+ data-tooltip-content={tooltipContent}
11
+ data-tooltip-id='supression-tooltip'
12
+ href={href}
13
+ >
14
+ {linkText}
15
+ </a>
16
+
17
+ <ReactTooltip
18
+ id='supression-tooltip'
19
+ place='top'
20
+ effect='solid'
21
+ variant='light'
22
+ style={{
23
+ background: `rgba(255, 255, 255, ${tooltipOpacity})`,
24
+ color: 'var(--cool-gray-90)',
25
+ padding: '9px 18px',
26
+ boxShadow: '0px 2px 2px rgba(28, 29, 31, 0.45)',
27
+ maxWidth: '239px',
28
+ fontSize: 'var(--filter-label-font-size)',
29
+ fontFamily: 'var(--app-font-main)',
30
+ borderRadius: '4px'
31
+ }}
32
+ />
33
+ </>
34
+ )
35
+ }
36
+
37
+ export default RichTooltip
@@ -0,0 +1,16 @@
1
+ .tooltip-link {
2
+ text-decoration: underline;
3
+ text-decoration-color: var(--cool-gray-90);
4
+ text-decoration-style: dotted;
5
+ text-decoration-thickness: 2px;
6
+ text-underline-offset: 0.25rem;
7
+ position: relative;
8
+ cursor: pointer;
9
+ color: var(--cool-gray-90);
10
+ font-family: var(--app-font-main);
11
+ font-size: 0.833rem !important;
12
+ }
13
+ .tooltip-link:hover {
14
+ text-decoration-color: #009ec1;
15
+ color: var(--cool-gray-90);
16
+ }
@@ -1,142 +1,142 @@
1
- import { ReactNode } from 'react'
2
- import Row from './components/Row'
3
- import GroupRow from './components/GroupRow'
4
- import { CellMatrix } from './types/CellMatrix'
5
- import { RowType } from './types/RowType'
6
- import { PreliminaryDataItem } from '@cdc/chart/src/types/ChartConfig'
7
- import _ from 'lodash'
8
-
9
- type TableProps = {
10
- childrenMatrix: CellMatrix | Map<string, CellMatrix>
11
- noData?: boolean
12
- tableName: string
13
- caption: string
14
- stickyHeader?: boolean
15
- headContent: ReactNode
16
- tableOptions: {
17
- className: string
18
- 'aria-live'?: 'off' | 'assertive' | 'polite'
19
- hidden?: boolean
20
- 'aria-rowcount'?: number
21
- cellMinWidth?: number
22
- }
23
- wrapColumns?: boolean
24
- hasRowType?: boolean // if it has row type then the first column is the row type which will explain how to render the row
25
- viewport: 'lg' | 'md' | 'sm' | 'xs' | 'xxs'
26
- preliminaryData?: PreliminaryDataItem[]
27
- rightAlignedCols: object
28
- }
29
-
30
- type Position = 'sticky'
31
-
32
- const Table = ({
33
- childrenMatrix,
34
- noData,
35
- tableName,
36
- caption,
37
- stickyHeader,
38
- headContent,
39
- tableOptions,
40
- wrapColumns,
41
- hasRowType,
42
- viewport,
43
- preliminaryData,
44
- rightAlignedCols
45
- }: TableProps) => {
46
- const headStyle = stickyHeader ? { position: 'sticky' as Position, top: 0, zIndex: 2 } : {}
47
- const isGroupedMatrix = !Array.isArray(childrenMatrix)
48
-
49
- return (
50
- <table {...tableOptions}>
51
- <caption className='visually-hidden'>{caption}</caption>
52
- {noData ? (
53
- <tr>
54
- <td className='py-5 text-center'>No Data</td>
55
- </tr>
56
- ) : (
57
- <>
58
- <thead style={headStyle}>{headContent}</thead>
59
- <tbody>
60
- {isGroupedMatrix
61
- ? Array.from(childrenMatrix.keys()).flatMap(groupName => {
62
- let colSpan = 0
63
- const rows = childrenMatrix.get(groupName).map((row, i) => {
64
- colSpan = row.length
65
- const key = `${tableName}-${groupName}-row-${i}`
66
- return (
67
- <Row
68
- preliminaryData={preliminaryData}
69
- key={key}
70
- rowKey={key}
71
- childRow={row}
72
- wrapColumns={wrapColumns}
73
- cellMinWidth={tableOptions.cellMinWidth}
74
- viewport={viewport}
75
- rightAlignedCols={rightAlignedCols}
76
- />
77
- )
78
- })
79
- return [<GroupRow label={groupName} colSpan={colSpan} key={`${tableName}-${groupName}`} />, ...rows]
80
- })
81
- : childrenMatrix.map((childRow, i) => {
82
- let childRowCopy = [...childRow]
83
- let rowType = undefined
84
- if (hasRowType) rowType = childRowCopy.shift()
85
- const key = `${tableName}-row-${i}`
86
- if (rowType === undefined) {
87
- return (
88
- <Row
89
- preliminaryData={preliminaryData}
90
- key={key}
91
- rowKey={key}
92
- childRow={childRow}
93
- wrapColumns={wrapColumns}
94
- cellMinWidth={tableOptions.cellMinWidth}
95
- viewport={viewport}
96
- rightAlignedCols={rightAlignedCols}
97
- />
98
- )
99
- } else {
100
- switch (rowType) {
101
- case RowType.row_group:
102
- return <GroupRow label={childRowCopy[0]} colSpan={childRowCopy.length} key={key} />
103
- case RowType.total:
104
- return (
105
- <Row
106
- preliminaryData={preliminaryData}
107
- key={key}
108
- rowKey={key}
109
- childRow={childRowCopy}
110
- isTotal={true}
111
- wrapColumns={wrapColumns}
112
- cellMinWidth={tableOptions.cellMinWidth}
113
- viewport={viewport}
114
- rightAlignedCols={rightAlignedCols}
115
- />
116
- )
117
- case RowType.row_group_total:
118
- return <GroupRow label={childRowCopy[0]} colSpan={1} key={key} data={childRowCopy.slice(1)} />
119
- default:
120
- return (
121
- <Row
122
- preliminaryData={preliminaryData}
123
- key={key}
124
- rowKey={key}
125
- childRow={childRowCopy}
126
- wrapColumns={wrapColumns}
127
- cellMinWidth={tableOptions.cellMinWidth}
128
- viewport={viewport}
129
- rightAlignedCols={rightAlignedCols}
130
- />
131
- )
132
- }
133
- }
134
- })}
135
- </tbody>
136
- </>
137
- )}
138
- </table>
139
- )
140
- }
141
-
142
- export default Table
1
+ import { ReactNode } from 'react'
2
+ import Row from './components/Row'
3
+ import GroupRow from './components/GroupRow'
4
+ import { CellMatrix } from './types/CellMatrix'
5
+ import { RowType } from './types/RowType'
6
+ import { PreliminaryDataItem } from '@cdc/chart/src/types/ChartConfig'
7
+ import './table.styles.css'
8
+
9
+ type TableProps = {
10
+ childrenMatrix: CellMatrix | Map<string, CellMatrix>
11
+ noData?: boolean
12
+ tableName: string
13
+ caption: string
14
+ stickyHeader?: boolean
15
+ headContent: ReactNode
16
+ tableOptions: {
17
+ className: string
18
+ 'aria-live'?: 'off' | 'assertive' | 'polite'
19
+ hidden?: boolean
20
+ 'aria-rowcount'?: number
21
+ cellMinWidth?: number
22
+ }
23
+ wrapColumns?: boolean
24
+ hasRowType?: boolean // if it has row type then the first column is the row type which will explain how to render the row
25
+ viewport: 'lg' | 'md' | 'sm' | 'xs' | 'xxs'
26
+ preliminaryData?: PreliminaryDataItem[]
27
+ rightAlignedCols: object
28
+ }
29
+
30
+ type Position = 'sticky'
31
+
32
+ const Table = ({
33
+ childrenMatrix,
34
+ noData,
35
+ tableName,
36
+ caption,
37
+ stickyHeader,
38
+ headContent,
39
+ tableOptions,
40
+ wrapColumns,
41
+ hasRowType,
42
+ viewport,
43
+ preliminaryData,
44
+ rightAlignedCols
45
+ }: TableProps) => {
46
+ const headStyle = stickyHeader ? { position: 'sticky' as Position, top: 0, zIndex: 2 } : {}
47
+ const isGroupedMatrix = !Array.isArray(childrenMatrix)
48
+
49
+ return (
50
+ <table {...tableOptions}>
51
+ <caption className='visually-hidden'>{caption}</caption>
52
+ {noData ? (
53
+ <tr>
54
+ <td className='py-5 text-center'>No Data</td>
55
+ </tr>
56
+ ) : (
57
+ <>
58
+ <thead style={headStyle}>{headContent}</thead>
59
+ <tbody>
60
+ {isGroupedMatrix
61
+ ? Array.from(childrenMatrix.keys()).flatMap(groupName => {
62
+ let colSpan = 0
63
+ const rows = childrenMatrix.get(groupName).map((row, i) => {
64
+ colSpan = row.length
65
+ const key = `${tableName}-${groupName}-row-${i}`
66
+ return (
67
+ <Row
68
+ preliminaryData={preliminaryData}
69
+ key={key}
70
+ rowKey={key}
71
+ childRow={row}
72
+ wrapColumns={wrapColumns}
73
+ cellMinWidth={tableOptions.cellMinWidth}
74
+ viewport={viewport}
75
+ rightAlignedCols={rightAlignedCols}
76
+ />
77
+ )
78
+ })
79
+ return [<GroupRow label={groupName} colSpan={colSpan} key={`${tableName}-${groupName}`} />, ...rows]
80
+ })
81
+ : childrenMatrix.map((childRow, i) => {
82
+ let childRowCopy = [...childRow]
83
+ let rowType = undefined
84
+ if (hasRowType) rowType = childRowCopy.shift()
85
+ const key = `${tableName}-row-${i}`
86
+ if (rowType === undefined) {
87
+ return (
88
+ <Row
89
+ preliminaryData={preliminaryData}
90
+ key={key}
91
+ rowKey={key}
92
+ childRow={childRow}
93
+ wrapColumns={wrapColumns}
94
+ cellMinWidth={tableOptions.cellMinWidth}
95
+ viewport={viewport}
96
+ rightAlignedCols={rightAlignedCols}
97
+ />
98
+ )
99
+ } else {
100
+ switch (rowType) {
101
+ case RowType.row_group:
102
+ return <GroupRow label={childRowCopy[0]} colSpan={childRowCopy.length} key={key} />
103
+ case RowType.total:
104
+ return (
105
+ <Row
106
+ preliminaryData={preliminaryData}
107
+ key={key}
108
+ rowKey={key}
109
+ childRow={childRowCopy}
110
+ isTotal={true}
111
+ wrapColumns={wrapColumns}
112
+ cellMinWidth={tableOptions.cellMinWidth}
113
+ viewport={viewport}
114
+ rightAlignedCols={rightAlignedCols}
115
+ />
116
+ )
117
+ case RowType.row_group_total:
118
+ return <GroupRow label={childRowCopy[0]} colSpan={1} key={key} data={childRowCopy.slice(1)} />
119
+ default:
120
+ return (
121
+ <Row
122
+ preliminaryData={preliminaryData}
123
+ key={key}
124
+ rowKey={key}
125
+ childRow={childRowCopy}
126
+ wrapColumns={wrapColumns}
127
+ cellMinWidth={tableOptions.cellMinWidth}
128
+ viewport={viewport}
129
+ rightAlignedCols={rightAlignedCols}
130
+ />
131
+ )
132
+ }
133
+ }
134
+ })}
135
+ </tbody>
136
+ </>
137
+ )}
138
+ </table>
139
+ )
140
+ }
141
+
142
+ export default Table
@@ -43,7 +43,7 @@ const Row: FC<RowProps> = props => {
43
43
  <Cell
44
44
  ariaLabel={style?.color ? 'suppressed data' : ''}
45
45
  key={rowKey + '__' + i}
46
- style={{ whiteSpace, minWidth, textAlign, ...style }}
46
+ style={{ whiteSpace, minWidth, textAlign, textOverflow: 'ellipsis', ...style }}
47
47
  isBold={isTotal}
48
48
  >
49
49
  {child}
@@ -0,0 +1,10 @@
1
+ .visually-hidden {
2
+ clip: rect(0 0 0 0);
3
+ clip-path: inset(50%);
4
+ height: 1px;
5
+ overflow: hidden;
6
+ white-space: nowrap;
7
+ width: 1px;
8
+ position: fixed;
9
+ left: -10000px;
10
+ }
@@ -8,6 +8,7 @@ import CityStateExample from './_mocks/example-city-state.json'
8
8
  import { displayGeoName } from '@cdc/map/src/helpers/displayGeoName'
9
9
  import rowTypeData from './_mocks/row_type.json'
10
10
  import { TableConfig } from '../DataTable/types/TableConfig'
11
+ import ConfigContext from '@cdc/map/src/context'
11
12
 
12
13
  const meta: Meta<typeof DataTable> = {
13
14
  title: 'Components/Organisms/DataTable',
@@ -36,7 +37,6 @@ export const Primary: Story = {
36
37
  export const CityState: Story = {
37
38
  args: {
38
39
  config: CityStateExample,
39
- dataConfig: CityStateExample,
40
40
  rawData: CityStateExample.data,
41
41
  runtimeData: CityStateExample.data,
42
42
  expandDataTable: true,
@@ -46,7 +46,14 @@ export const CityState: Story = {
46
46
  columns: CityStateExample.columns,
47
47
  applyLegendToRow: () => ['#000'],
48
48
  displayGeoName
49
- }
49
+ },
50
+ decorators: [
51
+ Story => (
52
+ <ConfigContext.Provider value={{ config: CityStateExample }}>
53
+ <Story />
54
+ </ConfigContext.Provider>
55
+ )
56
+ ]
50
57
  }
51
58
 
52
59
  export const Grouped: Story = {
@@ -37,7 +37,7 @@ function createGroupMatrix(): Record<string, ReactNode[][]> {
37
37
  return { group_1: [base, base], group_2: [base, base] }
38
38
  }
39
39
 
40
- export const Grouped: Story = {
40
+ const Grouped: Story = {
41
41
  args: {
42
42
  childrenMatrix: createGroupMatrix(),
43
43
  tableName: 'COVE Table',
@@ -3,10 +3,6 @@
3
3
  @import '../../styles/_mixins';
4
4
  @import '../../styles/_global.scss';
5
5
 
6
- .visually-hidden {
7
- position: fixed;
8
- left: -10000px;
9
- }
10
6
 
11
7
  .debug .editor-panel {
12
8
  border: 2px dashed red !important;
@@ -16,6 +16,7 @@ const Button = ({
16
16
  active = false,
17
17
  onClick,
18
18
  children,
19
+ secondary,
19
20
  ...attributes
20
21
  }) => {
21
22
  const buttonRef = useRef(null)
@@ -33,7 +34,8 @@ const Button = ({
33
34
  (flexCenter || 'loader' === role ? ' cove-button--flex-center' : '') +
34
35
  (fluid ? ' fluid' : '') +
35
36
  (loading ? ' loading' : '') +
36
- (attributes.className ? ' ' + attributes.className : ''),
37
+ (attributes.className ? ' ' + attributes.className : '') +
38
+ (secondary ? ' secondary' : ''),
37
39
  onMouseOver: () => setButtonState('in'),
38
40
  onMouseOut: () => setButtonState('out'),
39
41
  onFocus: () => setButtonState('in'),
@@ -89,7 +91,7 @@ const Button = ({
89
91
  {...attributesObj}
90
92
  onClick={e => {
91
93
  e.preventDefault()
92
- return loading || onClick()
94
+ return loading || onClick(e)
93
95
  }}
94
96
  disabled={loading || attributesObj.disabled}
95
97
  ref={buttonRef}
@@ -1,11 +1,18 @@
1
1
  import React, { Children } from 'react'
2
- import { Accordion as AccordionComponent, AccordionItem, AccordionItemHeading, AccordionItemPanel, AccordionItemButton } from 'react-accessible-accordion'
2
+ import {
3
+ Accordion as AccordionComponent,
4
+ AccordionItem,
5
+ AccordionItemHeading,
6
+ AccordionItemPanel,
7
+ AccordionItemButton
8
+ } from 'react-accessible-accordion'
3
9
  import PropTypes from 'prop-types'
4
10
 
5
11
  import Icon from './Icon'
6
12
  import Tooltip from './Tooltip'
7
13
 
8
14
  import '../../styles/v2/components/accordion.scss'
15
+ import './accordion.styles.css'
9
16
 
10
17
  //Define the "slots" to be populated by subcomponents
11
18
  const AccordionSection = children => children
@@ -1,6 +1,7 @@
1
1
  import React from 'react'
2
2
  import parse from 'html-react-parser'
3
- import './Title.scss'
3
+ import './title.styles.css'
4
+ import { Visualization } from '../../../types/Visualization'
4
5
 
5
6
  type HeaderProps = {
6
7
  title?: string
@@ -10,6 +11,8 @@ type HeaderProps = {
10
11
  style?: React.CSSProperties
11
12
  showTitle?: boolean
12
13
  ariaLevel?: number
14
+ config: Visualization
15
+ theme?: string
13
16
  }
14
17
 
15
18
  const Title = (props: HeaderProps) => {
@@ -43,7 +43,6 @@
43
43
  margin-bottom: 0 !important;
44
44
  }
45
45
 
46
- // THEMES
47
46
  &.theme-purple {
48
47
  background: #712177;
49
48
  border-bottom-color: #b890bb;
@@ -94,7 +93,6 @@
94
93
  }
95
94
  }
96
95
 
97
- // fix sparkline bottom margin gap
98
96
  .type-sparkline.type-chart .cove-component__header {
99
97
  margin: 0px !important;
100
98
  }