@cdc/core 4.24.7 → 4.24.9

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 (66) hide show
  1. package/assets/icon-gear-multi.svg +23 -0
  2. package/components/Alert/components/Alert.styles.css +15 -0
  3. package/components/Alert/components/Alert.tsx +39 -0
  4. package/components/Alert/index.tsx +3 -0
  5. package/components/DataTable/DataTable.tsx +106 -30
  6. package/components/DataTable/helpers/chartCellMatrix.tsx +3 -3
  7. package/components/DataTable/helpers/getChartCellValue.ts +1 -1
  8. package/components/DataTable/helpers/getDataSeriesColumns.ts +2 -2
  9. package/components/DataTable/helpers/mapCellMatrix.tsx +3 -3
  10. package/components/DataTable/types/TableConfig.ts +1 -1
  11. package/components/EditorPanel/Inputs.tsx +13 -4
  12. package/components/EditorPanel/VizFilterEditor/NestedDropdownEditor.tsx +268 -0
  13. package/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +161 -82
  14. package/components/EditorPanel/VizFilterEditor/components/FilterOrder.tsx +31 -45
  15. package/components/Filters.tsx +223 -180
  16. package/components/Layout/components/Responsive.tsx +14 -4
  17. package/components/Layout/components/Sidebar/components/Sidebar.tsx +14 -5
  18. package/components/Layout/components/Sidebar/components/sidebar.styles.scss +15 -16
  19. package/components/Layout/components/Visualization/index.tsx +7 -1
  20. package/components/Layout/components/Visualization/visualizations.scss +32 -26
  21. package/components/Layout/styles/editor.scss +0 -8
  22. package/components/Legend/Legend.Gradient.tsx +133 -0
  23. package/components/LegendShape.tsx +28 -0
  24. package/components/MultiSelect/MultiSelect.tsx +6 -3
  25. package/components/NestedDropdown/NestedDropdown.tsx +47 -52
  26. package/components/NestedDropdown/nesteddropdown.styles.css +19 -25
  27. package/components/Table/Table.tsx +8 -5
  28. package/components/Table/components/Cell.tsx +2 -2
  29. package/components/Table/components/Row.tsx +25 -7
  30. package/components/_stories/Layout.Debug.stories.tsx +91 -0
  31. package/components/_stories/_mocks/bar-chart-suppressed.json +474 -0
  32. package/components/_stories/styles.scss +13 -1
  33. package/components/createBarElement.jsx +4 -4
  34. package/components/ui/Icon.tsx +21 -14
  35. package/components/ui/Title/Title.scss +0 -8
  36. package/helpers/DataTransform.ts +2 -2
  37. package/helpers/addValuesToFilters.ts +95 -16
  38. package/helpers/cove/accessibility.ts +16 -4
  39. package/helpers/coveUpdateWorker.ts +24 -10
  40. package/helpers/filterVizData.ts +23 -4
  41. package/helpers/formatConfigBeforeSave.ts +7 -2
  42. package/helpers/getGradientLegendWidth.ts +15 -0
  43. package/helpers/getTextWidth.ts +18 -0
  44. package/helpers/scaling.ts +7 -0
  45. package/helpers/tests/addValuesToFilters.test.ts +55 -0
  46. package/helpers/tests/filterVizData.test.ts +31 -0
  47. package/helpers/tests/invertValue.test.ts +35 -0
  48. package/helpers/updatePaletteNames.ts +19 -0
  49. package/helpers/{useDataVizClasses.js → useDataVizClasses.ts} +3 -2
  50. package/helpers/ver/4.24.5.ts +3 -3
  51. package/helpers/ver/4.24.7.ts +34 -3
  52. package/helpers/ver/4.24.9.ts +63 -0
  53. package/helpers/ver/tests/4.24.9.test.ts +22 -0
  54. package/helpers/ver/versionNeedsUpdate.ts +9 -0
  55. package/package.json +3 -3
  56. package/styles/_button-section.scss +1 -1
  57. package/styles/_global.scss +6 -2
  58. package/styles/filters.scss +4 -0
  59. package/types/Axis.ts +3 -0
  60. package/types/Dimensions.ts +1 -0
  61. package/types/General.ts +1 -1
  62. package/types/VizFilter.ts +24 -3
  63. package/components/LegendCircle.jsx +0 -17
  64. package/helpers/updatePaletteNames.js +0 -16
  65. /package/components/{Waiting.jsx → Waiting.tsx} +0 -0
  66. /package/helpers/ver/{4.23.4.ts → 4.24.4.ts} +0 -0
@@ -1,11 +1,6 @@
1
1
  .nested-dropdown {
2
- li {
2
+ .nested-dropdown-group {
3
3
  list-style: none;
4
- cursor: pointer;
5
-
6
- &:focus {
7
- border: 2px solid var(--orange);
8
- }
9
4
  }
10
5
 
11
6
  .search-input {
@@ -25,11 +20,24 @@
25
20
  cursor: pointer;
26
21
  }
27
22
 
28
- .selectable-item:hover {
29
- background-color: var(--lightGray);
23
+ .selectable-item {
24
+ list-style: none;
25
+ padding-left: 20px;
26
+ position: relative;
27
+ font-weight: normal;
28
+ white-space: nowrap;
29
+
30
+ & .check-mark {
31
+ position: absolute;
32
+ left: 0px;
33
+ }
34
+
35
+ &:hover {
36
+ background-color: var(--lightGray);
37
+ }
30
38
  }
31
39
 
32
- & > div {
40
+ .nested-dropdown-input-container {
33
41
  position: relative;
34
42
  & > span.list-arrow {
35
43
  position: absolute;
@@ -42,26 +50,12 @@
42
50
  }
43
51
  }
44
52
 
45
- & > ul {
53
+ & .main-nested-dropdown-container {
46
54
  max-height: 375px;
47
55
  overflow-y: scroll;
48
56
  position: absolute;
49
57
  z-index: 3;
50
- width: 375px;
51
-
52
- & > li {
53
- font-weight: bold;
54
-
55
- & > ul > li {
56
- position: relative;
57
- font-weight: normal;
58
- white-space: nowrap;
59
- & > span {
60
- position: absolute;
61
- left: -20px;
62
- }
63
- }
64
- }
58
+ width: 325px;
65
59
  }
66
60
 
67
61
  .hide {
@@ -3,6 +3,7 @@ import Row from './components/Row'
3
3
  import GroupRow from './components/GroupRow'
4
4
  import { CellMatrix, GroupCellMatrix } from './types/CellMatrix'
5
5
  import { RowType } from './types/RowType'
6
+ import { PreliminaryDataItem } from '@cdc/chart/src/types/ChartConfig'
6
7
 
7
8
  type TableProps = {
8
9
  childrenMatrix: CellMatrix | GroupCellMatrix
@@ -21,13 +22,15 @@ type TableProps = {
21
22
  hasRowType?: boolean // if it has row type then the first column is the row type which will explain how to render the row
22
23
  fontSize: 'small' | 'medium' | 'large'
23
24
  viewport: 'lg' | 'md' | 'sm' | 'xs' | 'xxs'
25
+ preliminaryData?: PreliminaryDataItem[]
24
26
  }
25
27
 
26
28
  type Position = 'sticky'
27
29
 
28
- const Table = ({ childrenMatrix, tableName, caption, stickyHeader, headContent, tableOptions, wrapColumns, hasRowType, fontSize, viewport }: TableProps) => {
30
+ const Table = ({ childrenMatrix, tableName, caption, stickyHeader, headContent, tableOptions, wrapColumns, hasRowType, fontSize, viewport, preliminaryData }: TableProps) => {
29
31
  const headStyle = stickyHeader ? { position: 'sticky' as Position, top: 0, zIndex: 2 } : {}
30
32
  const isGroupedMatrix = !Array.isArray(childrenMatrix)
33
+
31
34
  return (
32
35
  <table {...tableOptions}>
33
36
  <caption className='visually-hidden'>{caption}</caption>
@@ -39,7 +42,7 @@ const Table = ({ childrenMatrix, tableName, caption, stickyHeader, headContent,
39
42
  const rows = childrenMatrix[groupName].map((row, i) => {
40
43
  colSpan = row.length
41
44
  const key = `${tableName}-${groupName}-row-${i}`
42
- return <Row key={key} rowKey={key} childRow={row} wrapColumns={wrapColumns} cellMinWidth={tableOptions.cellMinWidth} fontSize={fontSize} viewport={viewport} />
45
+ return <Row preliminaryData={preliminaryData} key={key} rowKey={key} childRow={row} wrapColumns={wrapColumns} cellMinWidth={tableOptions.cellMinWidth} fontSize={fontSize} viewport={viewport} />
43
46
  })
44
47
  return [<GroupRow label={groupName} colSpan={colSpan} key={`${tableName}-${groupName}`} />, ...rows]
45
48
  })
@@ -49,17 +52,17 @@ const Table = ({ childrenMatrix, tableName, caption, stickyHeader, headContent,
49
52
  if (hasRowType) rowType = childRowCopy.shift()
50
53
  const key = `${tableName}-row-${i}`
51
54
  if (rowType === undefined) {
52
- return <Row key={key} rowKey={key} childRow={childRow} wrapColumns={wrapColumns} cellMinWidth={tableOptions.cellMinWidth} fontSize={fontSize} viewport={viewport} />
55
+ return <Row preliminaryData={preliminaryData} key={key} rowKey={key} childRow={childRow} wrapColumns={wrapColumns} cellMinWidth={tableOptions.cellMinWidth} fontSize={fontSize} viewport={viewport} />
53
56
  } else {
54
57
  switch (rowType) {
55
58
  case RowType.row_group:
56
59
  return <GroupRow label={childRowCopy[0]} colSpan={childRowCopy.length} key={key} />
57
60
  case RowType.total:
58
- return <Row key={key} rowKey={key} childRow={childRowCopy} isTotal={true} wrapColumns={wrapColumns} cellMinWidth={tableOptions.cellMinWidth} fontSize={fontSize} viewport={viewport} />
61
+ return <Row preliminaryData={preliminaryData} key={key} rowKey={key} childRow={childRowCopy} isTotal={true} wrapColumns={wrapColumns} cellMinWidth={tableOptions.cellMinWidth} fontSize={fontSize} viewport={viewport} />
59
62
  case RowType.row_group_total:
60
63
  return <GroupRow label={childRowCopy[0]} colSpan={1} key={key} data={childRowCopy.slice(1)} />
61
64
  default:
62
- return <Row key={key} rowKey={key} childRow={childRowCopy} wrapColumns={wrapColumns} cellMinWidth={tableOptions.cellMinWidth} fontSize={fontSize} viewport={viewport} />
65
+ return <Row preliminaryData={preliminaryData} key={key} rowKey={key} childRow={childRowCopy} wrapColumns={wrapColumns} cellMinWidth={tableOptions.cellMinWidth} fontSize={fontSize} viewport={viewport} />
63
66
  }
64
67
  }
65
68
  })}
@@ -1,6 +1,6 @@
1
- const Cell = ({ children, style, isBold = false }) => {
1
+ const Cell = ({ children, style, isBold = false, ariaLabel }) => {
2
2
  return (
3
- <td tabIndex={0} role='gridcell' style={style}>
3
+ <td aria-label={ariaLabel} tabIndex={0} role='gridcell' style={style}>
4
4
  {isBold ? <strong>{children}</strong> : children}
5
5
  </td>
6
6
  )
@@ -1,5 +1,6 @@
1
- import { ReactNode } from 'react'
1
+ import { ReactNode, FC } from 'react'
2
2
  import Cell from './Cell'
3
+ import { PreliminaryDataItem } from '@cdc/chart/src/types/ChartConfig'
3
4
 
4
5
  type RowProps = {
5
6
  childRow: ReactNode[]
@@ -9,20 +10,37 @@ type RowProps = {
9
10
  cellMinWidth?: number
10
11
  fontSize: 'small' | 'medium' | 'large'
11
12
  viewport: 'lg' | 'md' | 'sm' | 'xs' | 'xxs'
13
+ style?: object
14
+ preliminaryData?: PreliminaryDataItem[]
12
15
  }
13
16
 
14
- const Row = ({ childRow, rowKey, wrapColumns, cellMinWidth = 0, isTotal, fontSize, viewport }: RowProps) => {
17
+ const Row: FC<RowProps> = props => {
18
+ const { childRow, rowKey, wrapColumns, cellMinWidth = 0, isTotal, fontSize, viewport, preliminaryData } = props
15
19
  const whiteSpace = wrapColumns ? 'unset' : 'nowrap'
16
20
  const minWidth = cellMinWidth + 'px'
17
21
  const fontSizes = { small: 16, medium: 18, large: 20 }
18
22
  const cellFontSize = ['sm', 'xs', 'xxs'].includes(viewport) ? '11px' : `${fontSizes[fontSize]}px`
23
+
19
24
  return (
20
25
  <tr>
21
- {childRow.map((child, i) => (
22
- <Cell key={rowKey + '__' + i} style={{ whiteSpace, minWidth, fontSize: cellFontSize }} isBold={isTotal}>
23
- {child}
24
- </Cell>
25
- ))}
26
+ {childRow.map((child, i) => {
27
+ const style =
28
+ (preliminaryData?.some(
29
+ pd => pd.type === 'suppression' && child === pd.iconCode && pd.displayGray && pd.displayTable
30
+ ) && { color: '#777772' }) ||
31
+ {}
32
+
33
+ return (
34
+ <Cell
35
+ ariaLabel={style?.color ? 'suppressed data' : ''}
36
+ key={rowKey + '__' + i}
37
+ style={{ whiteSpace, minWidth, fontSize: cellFontSize, ...style }}
38
+ isBold={isTotal}
39
+ >
40
+ {child}
41
+ </Cell>
42
+ )
43
+ })}
26
44
  </tr>
27
45
  )
28
46
  }
@@ -0,0 +1,91 @@
1
+ import React from 'react'
2
+ import { Meta, StoryObj } from '@storybook/react'
3
+ import './styles.scss'
4
+ import CdcChart from '@cdc/chart'
5
+ import CdcMap from '@cdc/map'
6
+ import CdcMarkupInclude from '@cdc/markup-include'
7
+ import CdcFilteredText from '@cdc/filtered-text'
8
+ import CdcDashboard from '@cdc/dashboard'
9
+ import CdcWaffleChart from '@cdc/waffle-chart'
10
+ import config from './../../../chart/src/_stories/_mock/bar-chart-suppressed.json'
11
+ import mapConfig from './../../../map/examples/default-usa.json'
12
+ import markupConfig from './../../../markup-include/src/data/initial-state.js'
13
+ import filteredTextConfig from './_mocks/filtered-text-config.json'
14
+ import waffleChartConfig from './../../../waffle-chart/examples/gallery/count.json'
15
+ import dashboardConfig from './../../../dashboard/examples/full-dashboard.json'
16
+
17
+ // Determine the component based on config.type
18
+ const getComponent = config => {
19
+ switch (config.type) {
20
+ case 'map':
21
+ return CdcMap
22
+ case 'chart':
23
+ return CdcChart
24
+ case 'markup-include':
25
+ return CdcMarkupInclude
26
+ case 'waffle-chart':
27
+ return CdcWaffleChart
28
+ case 'dashboard':
29
+ return CdcDashboard
30
+ default:
31
+ return () => <div>Unknown component type</div>
32
+ }
33
+ }
34
+
35
+ const meta = {
36
+ title: 'Components/Templates/Layout/Debug',
37
+ component: args => {
38
+ const Component = getComponent(args.config)
39
+ return (
40
+ <div className=''>
41
+ <Component {...args} />
42
+ </div>
43
+ )
44
+ }
45
+ } as Meta
46
+
47
+ export default meta
48
+
49
+ type Story = StoryObj
50
+
51
+ export const Chart: Story = {
52
+ args: {
53
+ config,
54
+ isEditor: true
55
+ }
56
+ }
57
+
58
+ export const Map: Story = {
59
+ args: {
60
+ config: mapConfig,
61
+ isEditor: true
62
+ }
63
+ }
64
+
65
+ export const MarkupInclude: StoryObj<typeof CdcMarkupInclude> = {
66
+ args: {
67
+ config: markupConfig,
68
+ isEditor: true
69
+ }
70
+ }
71
+
72
+ export const WaffleChart: StoryObj<typeof CdcWaffleChart> = {
73
+ args: {
74
+ config: waffleChartConfig,
75
+ isEditor: true
76
+ }
77
+ }
78
+
79
+ export const Dashboard: StoryObj<typeof CdcDashboard> = {
80
+ args: {
81
+ config: dashboardConfig,
82
+ isEditor: true
83
+ }
84
+ }
85
+
86
+ // export const WaffleChart: StoryObj<typeof CdcWaffleChart> = {
87
+ // args: {
88
+ // config: waffleChartConfig,
89
+ // isEditor: true
90
+ // }
91
+ // }