@cdc/core 4.24.4 → 4.24.7

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 (80) hide show
  1. package/components/AdvancedEditor/AdvancedEditor.tsx +93 -0
  2. package/components/AdvancedEditor/advanced-editor-styles.css +3 -0
  3. package/components/AdvancedEditor/index.ts +1 -0
  4. package/components/DataTable/DataTable.tsx +33 -15
  5. package/components/DataTable/DataTableStandAlone.tsx +30 -4
  6. package/components/DataTable/components/ChartHeader.tsx +3 -2
  7. package/components/DataTable/components/DataTableEditorPanel.tsx +23 -6
  8. package/components/DataTable/components/ExpandCollapse.tsx +1 -1
  9. package/components/DataTable/helpers/chartCellMatrix.tsx +5 -10
  10. package/components/DataTable/helpers/getChartCellValue.ts +26 -2
  11. package/components/DataTable/helpers/getDataSeriesColumns.ts +40 -16
  12. package/components/DataTable/helpers/getRowType.ts +6 -0
  13. package/components/DataTable/helpers/getSeriesName.ts +2 -1
  14. package/components/DataTable/helpers/{customColumns.ts → removeNullColumns.ts} +3 -3
  15. package/components/DataTable/types/TableConfig.ts +12 -22
  16. package/components/EditorPanel/ColumnsEditor.tsx +278 -262
  17. package/components/EditorPanel/DataTableEditor.tsx +159 -60
  18. package/components/EditorPanel/FieldSetWrapper.tsx +51 -0
  19. package/components/EditorPanel/FootnotesEditor.tsx +77 -0
  20. package/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +227 -0
  21. package/components/EditorPanel/VizFilterEditor/components/FilterOrder.tsx +54 -0
  22. package/components/EditorPanel/VizFilterEditor/index.ts +1 -0
  23. package/components/EditorWrapper/EditorWrapper.tsx +47 -0
  24. package/components/EditorWrapper/editor-wrapper.style.css +14 -0
  25. package/components/EditorWrapper/index.ts +1 -0
  26. package/components/{Filters.jsx → Filters.tsx} +102 -70
  27. package/components/Footnotes/Footnotes.tsx +25 -0
  28. package/components/Footnotes/FootnotesStandAlone.tsx +45 -0
  29. package/components/Footnotes/footnotes.css +5 -0
  30. package/components/Footnotes/index.ts +1 -0
  31. package/components/Layout/components/Sidebar/components/sidebar.styles.scss +8 -4
  32. package/components/Layout/components/Visualization/index.tsx +14 -5
  33. package/components/MediaControls.jsx +1 -1
  34. package/components/MultiSelect/MultiSelect.tsx +36 -9
  35. package/components/MultiSelect/multiselect.styles.css +0 -3
  36. package/components/_stories/DataTable.stories.tsx +1 -2
  37. package/components/_stories/EditorPanel.stories.tsx +1 -0
  38. package/components/_stories/Footnotes.stories.tsx +17 -0
  39. package/components/inputs/InputSelect.tsx +17 -6
  40. package/components/ui/Icon.tsx +1 -2
  41. package/helpers/DataTransform.ts +9 -32
  42. package/helpers/addValuesToFilters.ts +56 -0
  43. package/helpers/cove/accessibility.ts +1 -0
  44. package/helpers/cove/fontSettings.ts +2 -0
  45. package/helpers/coveUpdateWorker.ts +11 -2
  46. package/helpers/filterVizData.ts +30 -0
  47. package/helpers/footnoteSymbols.ts +11 -0
  48. package/helpers/formatConfigBeforeSave.ts +90 -0
  49. package/helpers/gatherQueryParams.ts +14 -7
  50. package/helpers/lineChartHelpers.js +2 -1
  51. package/helpers/pivotData.ts +18 -0
  52. package/helpers/queryStringUtils.ts +29 -0
  53. package/helpers/tests/updateFieldFactory.test.ts +1 -0
  54. package/helpers/updateFieldFactory.ts +1 -1
  55. package/helpers/useDataVizClasses.js +0 -4
  56. package/helpers/ver/4.23.4.ts +27 -0
  57. package/helpers/ver/4.24.5.ts +32 -0
  58. package/helpers/ver/4.24.7.ts +92 -0
  59. package/package.json +6 -4
  60. package/styles/_button-section.scss +6 -1
  61. package/styles/_data-table.scss +0 -1
  62. package/styles/_reset.scss +7 -6
  63. package/styles/base.scss +4 -0
  64. package/styles/v2/themes/_color-definitions.scss +1 -0
  65. package/types/Annotation.ts +46 -0
  66. package/types/Column.ts +1 -0
  67. package/types/ConfigureData.ts +1 -1
  68. package/types/Footnotes.ts +17 -0
  69. package/types/General.ts +5 -0
  70. package/types/Legend.ts +1 -0
  71. package/types/MarkupInclude.ts +26 -0
  72. package/types/Runtime.ts +3 -7
  73. package/types/Series.ts +1 -1
  74. package/types/Table.ts +21 -14
  75. package/types/Visualization.ts +40 -11
  76. package/types/VizFilter.ts +24 -0
  77. package/LICENSE +0 -201
  78. package/components/AdvancedEditor.jsx +0 -74
  79. package/helpers/queryStringUtils.js +0 -26
  80. package/types/BaseVisualizationType.ts +0 -1
@@ -1,4 +1,3 @@
1
- import { AccordionItem, AccordionItemButton, AccordionItemHeading, AccordionItemPanel } from 'react-accessible-accordion'
2
1
  import Tooltip from '../ui/Tooltip'
3
2
  import Icon from '../ui/Icon'
4
3
  import { TextField } from './Inputs'
@@ -6,35 +5,219 @@ import { Visualization } from '../../types/Visualization'
6
5
  import { UpdateFieldFunc } from '../../types/UpdateFieldFunc'
7
6
  import { Column } from '../../types/Column'
8
7
  import _ from 'lodash'
8
+ import React, { useState } from 'react'
9
+ import FieldSetWrapper from './FieldSetWrapper'
9
10
 
10
11
  interface ColumnsEditorProps {
11
- config: Visualization
12
- updateField: UpdateFieldFunc<string | boolean | string[] | number | Column>
12
+ config: Partial<Visualization>
13
+ updateField: UpdateFieldFunc<string | boolean | string[] | number | Column | Record<string, Partial<Column>>>
13
14
  deleteColumn: (colName: string) => void
14
15
  }
15
16
 
16
- const ColumnsEditor: React.FC<ColumnsEditorProps> = ({ config, updateField, deleteColumn }) => {
17
- const additionalColumns = Object.keys(config.columns).filter(value => {
18
- const dataKey = config.xAxis?.dataKey
19
- const defaultCols = dataKey ? [dataKey] : []
17
+ type OpenControls = [Record<string, boolean>, Function] // useState type
18
+
19
+ const FieldSet: React.FC<ColumnsEditorProps & { colKey: string; controls: OpenControls }> = ({ config, deleteColumn, updateField, colKey, controls }) => {
20
+ const [openControls, setOpenControls] = controls
21
+
22
+ const editColumn = (key, value) => {
23
+ if (key === 'dataTable' && value === true) {
24
+ const newColumns = _.cloneDeep(config.columns) // must pass new columns object to trigger re-render of DataTableEditor
25
+ newColumns[colKey] = { ...newColumns[colKey], dataTable: value }
26
+ updateField(null, null, 'columns', newColumns)
27
+ } else {
28
+ updateField('columns', colKey, key, value)
29
+ }
30
+ }
20
31
 
21
- if (true === defaultCols.includes(value)) {
22
- return false
32
+ const changeName = value => {
33
+ const newColumns = _.cloneDeep(config.columns)
34
+ const currentCol = config.columns[colKey]
35
+ const newColumn = { ...currentCol, name: value, label: value }
36
+ if (newColumn.dataTable === undefined) {
37
+ newColumn.dataTable = true
38
+ }
39
+ if (value !== colKey) {
40
+ newColumns[value] = newColumn
41
+ delete newColumns[colKey]
42
+ const newControls = { ..._.cloneDeep(openControls), [value]: true }
43
+ delete newControls[colKey]
44
+ setOpenControls(newControls)
23
45
  }
24
- return true
25
- })
46
+ updateField(null, null, 'columns', newColumns)
47
+ }
26
48
 
27
- const editColumn = (addCol, columnName, setval) => {
28
- updateField('columns', addCol, columnName, setval)
49
+ const getColumns = () => {
50
+ const columns: string[] = config.data.flatMap(row => {
51
+ return Object.keys(row).map(columnName => columnName)
52
+ })
53
+ const configuredColumns = Object.values(config.columns).map(col => col.name)
54
+ const cols = _.uniq(columns).filter(key => {
55
+ if (config.table.groupBy === key) return false
56
+ if (configuredColumns.includes(key)) return false
57
+ return true
58
+ })
59
+ if (config.columns[colKey]?.name) cols.push(config.columns[colKey].name)
60
+ return cols
29
61
  }
30
62
 
63
+ const colName = config.columns[colKey]?.name
64
+
65
+ return (
66
+ <FieldSetWrapper fieldName={colName} fieldKey={colKey} fieldType='Column' controls={controls} deleteField={() => deleteColumn(colKey)}>
67
+ <label>
68
+ <span className='edit-label column-heading'>Column</span>
69
+ <select
70
+ value={config.columns[colKey] ? config.columns[colKey].name : undefined}
71
+ onChange={event => {
72
+ changeName(event.target.value)
73
+ }}
74
+ >
75
+ {['-Select-', ...getColumns()].map(option => (
76
+ <option key={option}>{option}</option>
77
+ ))}
78
+ </select>
79
+ </label>
80
+ {config.type !== 'table' && (
81
+ <label>
82
+ <span className='edit-label column-heading'>Associate to Series</span>
83
+ <select
84
+ value={config.columns[colKey] ? config.columns[colKey].series : ''}
85
+ onChange={event => {
86
+ editColumn('series', event.target.value)
87
+ }}
88
+ >
89
+ <option value=''>Select series</option>
90
+ {(config.series || []).map(series => (
91
+ <option key={series.dataKey}>{series.dataKey}</option>
92
+ ))}
93
+ </select>
94
+ </label>
95
+ )}
96
+
97
+ <TextField value={config.columns[colKey].label} section='columns' subsection={colKey} fieldName='label' label='Label' updateField={updateField} />
98
+ <ul className='column-edit'>
99
+ <li className='three-col'>
100
+ <TextField value={config.columns[colKey].prefix} section='columns' subsection={colKey} fieldName='prefix' label='Prefix' updateField={updateField} />
101
+ <TextField value={config.columns[colKey].suffix} section='columns' subsection={colKey} fieldName='suffix' label='Suffix' updateField={updateField} />
102
+ <TextField type='number' value={config.columns[colKey].roundToPlace} section='columns' subsection={colKey} fieldName='roundToPlace' label='Round' updateField={updateField} />
103
+ </li>
104
+ <li>
105
+ <label className='checkbox'>
106
+ <input
107
+ type='checkbox'
108
+ checked={config.columns[colKey].commas}
109
+ onChange={event => {
110
+ editColumn('commas', event.target.checked)
111
+ }}
112
+ />
113
+ <span className='edit-label'>Add Commas to Numbers</span>
114
+ </label>
115
+ </li>
116
+ <li>
117
+ {config.table.showVertical && (
118
+ <label className='checkbox'>
119
+ <input
120
+ type='checkbox'
121
+ checked={config.columns[colKey].dataTable ?? true}
122
+ onChange={event => {
123
+ editColumn('dataTable', event.target.checked)
124
+ }}
125
+ />
126
+ <span className='edit-label'>Show in Data Table</span>
127
+ </label>
128
+ )}
129
+ </li>
130
+ {config.visualizationType === 'Pie' && (
131
+ <li>
132
+ <label className='checkbox'>
133
+ <input
134
+ type='checkbox'
135
+ checked={config.columns[colKey].showInViz}
136
+ onChange={event => {
137
+ editColumn('showInViz', event.target.checked)
138
+ }}
139
+ />
140
+ <span className='edit-label'>Show in Visualization</span>
141
+ </label>
142
+ </li>
143
+ )}
144
+ {config.type !== 'table' && (
145
+ <li>
146
+ <label className='checkbox'>
147
+ <input
148
+ type='checkbox'
149
+ checked={config.columns[colKey].tooltips || false}
150
+ onChange={event => {
151
+ updateField('columns', colKey, 'tooltips', event.target.checked)
152
+ }}
153
+ />
154
+ <span className='edit-label'>Show in tooltip</span>
155
+ </label>
156
+ </li>
157
+ )}
158
+
159
+ {config.visualizationType === 'Forest Plot' && (
160
+ <>
161
+ <li>
162
+ <label className='checkbox'>
163
+ <input
164
+ type='checkbox'
165
+ checked={config.columns[colKey].forestPlot || false}
166
+ onChange={event => {
167
+ editColumn('forestPlot', event.target.checked)
168
+ }}
169
+ />
170
+ <span className='edit-label'>Show in Forest Plot</span>
171
+ </label>
172
+ </li>
173
+ <li>
174
+ <label className='checkbox'>
175
+ <input
176
+ type='checkbox'
177
+ checked={config.columns[colKey].forestPlotAlignRight || false}
178
+ onChange={event => {
179
+ editColumn('forestPlotAlignRight', event.target.checked)
180
+ }}
181
+ />
182
+ <span className='edit-label'>Align Right</span>
183
+ </label>
184
+ </li>
185
+
186
+ {!config.columns[colKey].forestPlotAlignRight && (
187
+ <li>
188
+ <label className='text'>
189
+ <span className='edit-label'>Forest Plot Starting Point</span>
190
+ <input
191
+ type='number'
192
+ value={config.columns[colKey].forestPlotStartingPoint || 0}
193
+ onChange={event => {
194
+ editColumn('forestPlotStartingPoint', event.target.value)
195
+ }}
196
+ />
197
+ </label>
198
+ </li>
199
+ )}
200
+ </>
201
+ )}
202
+ </ul>
203
+ <label>
204
+ <span className='edit-label column-heading'>Order</span>
205
+ <input onWheel={e => e.currentTarget.blur()} type='number' min='1' value={config.columns[colKey].order} onChange={e => updateField('columns', colKey, 'order', parseInt(e.target.value))} />
206
+ </label>
207
+ </FieldSetWrapper>
208
+ )
209
+ }
210
+
211
+ const ColumnsEditor: React.FC<ColumnsEditorProps> = ({ config, updateField, deleteColumn }) => {
212
+ const openControls = useState({})
213
+ const additionalColumns = Object.keys(config.columns)
214
+
31
215
  // just adds a new column but not set to any data yet
32
- const addAdditionalColumn = number => {
216
+ const addColumnConfig = number => {
33
217
  const columnKey = `additionalColumn${number}`
34
- const showInViz = config.type === 'table'
35
218
  const newColumn: Column = {
36
219
  label: 'New Column',
37
- dataTable: showInViz,
220
+ dataTable: true,
38
221
  tooltips: false,
39
222
  prefix: '',
40
223
  suffix: '',
@@ -46,266 +229,99 @@ const ColumnsEditor: React.FC<ColumnsEditorProps> = ({ config, updateField, dele
46
229
  showInViz: false,
47
230
  forestPlotStartingPoint: 0
48
231
  }
49
-
232
+ const [controls, setControls] = openControls
233
+ setControls({ ...controls, [columnKey]: true })
50
234
  updateField('columns', null, columnKey, newColumn)
51
235
  }
52
236
 
53
- const getColumns = () => {
54
- const columns: string[] = config.data.flatMap(row => {
55
- return Object.keys(row).map(columnName => columnName)
56
- })
57
-
58
- const { lower, upper } = config.confidenceKeys || {}
59
- return _.uniq(columns).filter(key => {
60
- const keyIsPresentInSeries = config.series?.filter(series => series.dataKey === key).length > 0
61
- if (keyIsPresentInSeries || (config.confidenceKeys && Object.keys(config.confidenceKeys).includes(key) && (lower || upper) && key !== lower && key !== upper)) {
62
- return false
63
- }
64
- return true
65
- })
66
- }
67
-
68
237
  return (
69
- <AccordionItem>
70
- <AccordionItemHeading>
71
- <AccordionItemButton>Columns</AccordionItemButton>
72
- </AccordionItemHeading>
73
- <AccordionItemPanel>
74
- {'navigation' !== config.type && (
75
- <fieldset className='primary-fieldset edit-block'>
76
- <label>
77
- <span className='edit-label'>
78
- Configurations
79
- <Tooltip style={{ textTransform: 'none' }}>
80
- <Tooltip.Target>
81
- <Icon display='question' style={{ marginLeft: '0.5rem' }} />
82
- </Tooltip.Target>
83
- <Tooltip.Content>
84
- <p>You can specify additional columns to display in tooltips and / or the supporting data table.</p>
85
- </Tooltip.Content>
86
- </Tooltip>
87
- </span>
88
- </label>
89
- {additionalColumns.map(val => (
90
- <fieldset className='edit-block' key={val}>
238
+ <>
239
+ {'navigation' !== config.type && (
240
+ <fieldset>
241
+ <label>
242
+ <span className='edit-label'>
243
+ Configurations
244
+ <Tooltip style={{ textTransform: 'none' }}>
245
+ <Tooltip.Target>
246
+ <Icon display='question' style={{ marginLeft: '0.5rem' }} />
247
+ </Tooltip.Target>
248
+ <Tooltip.Content>
249
+ <p>You can specify additional columns to display in tooltips and / or the supporting data table.</p>
250
+ </Tooltip.Content>
251
+ </Tooltip>
252
+ </span>
253
+ </label>
254
+ {additionalColumns.map((val, i) => (
255
+ <FieldSet key={val + i} controls={openControls} config={config} deleteColumn={deleteColumn} updateField={updateField} colKey={val} />
256
+ ))}
257
+ <button
258
+ className={'btn btn-primary'}
259
+ onClick={event => {
260
+ event.preventDefault()
261
+ addColumnConfig(additionalColumns.length + 1)
262
+ }}
263
+ >
264
+ Add Configuration
265
+ </button>
266
+ </fieldset>
267
+ )}
268
+ {'category' === config.legend?.type && (
269
+ <fieldset>
270
+ <label>
271
+ <span className='edit-label'>
272
+ Additional Category
273
+ <Tooltip style={{ textTransform: 'none' }}>
274
+ <Tooltip.Target>
275
+ <Icon display='question' style={{ marginLeft: '0.5rem' }} />
276
+ </Tooltip.Target>
277
+ <Tooltip.Content>
278
+ <p>You can provide additional categories to ensure they appear in the legend</p>
279
+ </Tooltip.Content>
280
+ </Tooltip>
281
+ </span>
282
+ </label>
283
+ {config.legend.additionalCategories &&
284
+ config.legend.additionalCategories.map((colKey, i) => (
285
+ <fieldset className='edit-block' key={colKey}>
91
286
  <button
92
287
  className='remove-column'
93
288
  onClick={event => {
94
289
  event.preventDefault()
95
- deleteColumn(val)
290
+ const updatedAdditionaCategories = [...config.legend.additionalCategories]
291
+ updatedAdditionaCategories.splice(i, 1)
292
+ updateField('legend', null, 'additionalCategories', updatedAdditionaCategories)
96
293
  }}
97
294
  >
98
295
  Remove
99
296
  </button>
100
- <label>
101
- <span className='edit-label column-heading'>Column</span>
102
- <select
103
- value={config.columns[val] ? config.columns[val].name : undefined}
104
- onChange={event => {
105
- editColumn(val, 'name', event.target.value)
106
- }}
107
- >
108
- {['-Select-', ...getColumns()].map(option => (
109
- <option>{option}</option>
110
- ))}
111
- </select>
112
- </label>
113
- {config.type !== 'table' && (
114
- <label>
115
- <span className='edit-label column-heading'>Associate to Series</span>
116
- <select
117
- value={config.columns[val] ? config.columns[val].series : ''}
118
- onChange={event => {
119
- editColumn(val, 'series', event.target.value)
120
- }}
121
- >
122
- <option value=''>Select series</option>
123
- {(config.series || []).map(series => (
124
- <option>{series.dataKey}</option>
125
- ))}
126
- </select>
127
- </label>
128
- )}
129
-
130
- <TextField value={config.columns[val].label} section='columns' subsection={val} fieldName='label' label='Label' updateField={updateField} />
131
- <ul className='column-edit'>
132
- <li className='three-col'>
133
- <TextField value={config.columns[val].prefix} section='columns' subsection={val} fieldName='prefix' label='Prefix' updateField={updateField} />
134
- <TextField value={config.columns[val].suffix} section='columns' subsection={val} fieldName='suffix' label='Suffix' updateField={updateField} />
135
- <TextField type='number' value={config.columns[val].roundToPlace} section='columns' subsection={val} fieldName='roundToPlace' label='Round' updateField={updateField} />
136
- </li>
137
- <li>
138
- <label className='checkbox'>
139
- <input
140
- type='checkbox'
141
- checked={config.columns[val].commas}
142
- onChange={event => {
143
- editColumn(val, 'commas', event.target.checked)
144
- }}
145
- />
146
- <span className='edit-label'>Add Commas to Numbers</span>
147
- </label>
148
- </li>
149
- {config.type !== 'table' && (
150
- <li>
151
- {config.table.showVertical && (
152
- <label className='checkbox'>
153
- <input
154
- type='checkbox'
155
- checked={config.columns[val].dataTable}
156
- onChange={event => {
157
- editColumn(val, 'dataTable', event.target.checked)
158
- }}
159
- />
160
- <span className='edit-label'>Show in Data Table</span>
161
- </label>
162
- )}
163
- </li>
164
- )}
165
- {config.visualizationType === 'Pie' && (
166
- <li>
167
- <label className='checkbox'>
168
- <input
169
- type='checkbox'
170
- checked={config.columns[val].showInViz}
171
- onChange={event => {
172
- editColumn(val, 'showInViz', event.target.checked)
173
- }}
174
- />
175
- <span className='edit-label'>Show in Visualization</span>
176
- </label>
177
- </li>
178
- )}
179
- {config.type !== 'table' && (
180
- <li>
181
- <label className='checkbox'>
182
- <input
183
- type='checkbox'
184
- checked={config.columns[val].tooltips || false}
185
- onChange={event => {
186
- updateField('columns', val, 'tooltips', event.target.checked)
187
- }}
188
- />
189
- <span className='edit-label'>Show in tooltip</span>
190
- </label>
191
- </li>
192
- )}
193
-
194
- {config.visualizationType === 'Forest Plot' && (
195
- <>
196
- <li>
197
- <label className='checkbox'>
198
- <input
199
- type='checkbox'
200
- checked={config.columns[val].forestPlot || false}
201
- onChange={event => {
202
- editColumn(val, 'forestPlot', event.target.checked)
203
- }}
204
- />
205
- <span className='edit-label'>Show in Forest Plot</span>
206
- </label>
207
- </li>
208
- <li>
209
- <label className='checkbox'>
210
- <input
211
- type='checkbox'
212
- checked={config.columns[val].forestPlotAlignRight || false}
213
- onChange={event => {
214
- editColumn(val, 'forestPlotAlignRight', event.target.checked)
215
- }}
216
- />
217
- <span className='edit-label'>Align Right</span>
218
- </label>
219
- </li>
220
-
221
- {!config.columns[val].forestPlotAlignRight && (
222
- <li>
223
- <label className='text'>
224
- <span className='edit-label'>Forest Plot Starting Point</span>
225
- <input
226
- type='number'
227
- value={config.columns[val].forestPlotStartingPoint || 0}
228
- onChange={event => {
229
- editColumn(val, 'forestPlotStartingPoint', event.target.value)
230
- }}
231
- />
232
- </label>
233
- </li>
234
- )}
235
- </>
236
- )}
237
- </ul>
297
+ <TextField
298
+ value={colKey}
299
+ label='Category'
300
+ section='legend'
301
+ subsection={null}
302
+ fieldName='additionalCategories'
303
+ updateField={(section, subsection, fieldName, value) => {
304
+ const updatedAdditionaCategories = [...config.legend.additionalCategories]
305
+ updatedAdditionaCategories[i] = value
306
+ updateField(section, subsection, fieldName, updatedAdditionaCategories)
307
+ }}
308
+ />
238
309
  </fieldset>
239
310
  ))}
240
- <button
241
- className={'btn full-width'}
242
- onClick={event => {
243
- event.preventDefault()
244
- addAdditionalColumn(additionalColumns.length + 1)
245
- }}
246
- >
247
- Add Column Configuration
248
- </button>
249
- </fieldset>
250
- )}
251
- {'category' === config.legend?.type && (
252
- <fieldset className='primary-fieldset edit-block'>
253
- <label>
254
- <span className='edit-label'>
255
- Additional Category
256
- <Tooltip style={{ textTransform: 'none' }}>
257
- <Tooltip.Target>
258
- <Icon display='question' style={{ marginLeft: '0.5rem' }} />
259
- </Tooltip.Target>
260
- <Tooltip.Content>
261
- <p>You can provide additional categories to ensure they appear in the legend</p>
262
- </Tooltip.Content>
263
- </Tooltip>
264
- </span>
265
- </label>
266
- {config.legend.additionalCategories &&
267
- config.legend.additionalCategories.map((val, i) => (
268
- <fieldset className='edit-block' key={val}>
269
- <button
270
- className='remove-column'
271
- onClick={event => {
272
- event.preventDefault()
273
- const updatedAdditionaCategories = [...config.legend.additionalCategories]
274
- updatedAdditionaCategories.splice(i, 1)
275
- updateField('legend', null, 'additionalCategories', updatedAdditionaCategories)
276
- }}
277
- >
278
- Remove
279
- </button>
280
- <TextField
281
- value={val}
282
- label='Category'
283
- section='legend'
284
- subsection={null}
285
- fieldName='additionalCategories'
286
- updateField={(section, subsection, fieldName, value) => {
287
- const updatedAdditionaCategories = [...config.legend.additionalCategories]
288
- updatedAdditionaCategories[i] = value
289
- updateField(section, subsection, fieldName, updatedAdditionaCategories)
290
- }}
291
- />
292
- </fieldset>
293
- ))}
294
- <button
295
- className={'btn full-width'}
296
- onClick={event => {
297
- event.preventDefault()
298
- const updatedAdditionaCategories = [...(config.legend.additionalCategories || [])]
299
- updatedAdditionaCategories.push('')
300
- updateField('legend', null, 'additionalCategories', updatedAdditionaCategories)
301
- }}
302
- >
303
- Add Category
304
- </button>
305
- </fieldset>
306
- )}
307
- </AccordionItemPanel>
308
- </AccordionItem>
311
+ <button
312
+ className={'btn btn-primary full-width'}
313
+ onClick={event => {
314
+ event.preventDefault()
315
+ const updatedAdditionaCategories = [...(config.legend.additionalCategories || [])]
316
+ updatedAdditionaCategories.push('')
317
+ updateField('legend', null, 'additionalCategories', updatedAdditionaCategories)
318
+ }}
319
+ >
320
+ Add Category
321
+ </button>
322
+ </fieldset>
323
+ )}
324
+ </>
309
325
  )
310
326
  }
311
327