@cdc/core 4.24.3 → 4.24.5

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