@cdc/filtered-text 4.25.8 → 4.25.11
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/dist/cdcfilteredtext.js +5022 -4860
- package/index.html +33 -26
- package/package.json +11 -3
- package/src/CdcFilteredText.jsx +8 -2
- package/src/components/EditorPanel.jsx +61 -99
- package/src/index.jsx +0 -1
- package/src/test/CdcFilteredText.test.jsx +8 -3
- package/vite.config.js +1 -1
- package/src/coreStyles_filteredtext.scss +0 -1
package/index.html
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
|
6
|
-
<style>
|
|
7
|
-
body {
|
|
8
|
-
margin: 0;
|
|
9
|
-
}
|
|
10
|
-
</style>
|
|
11
|
-
<style>
|
|
12
|
-
body {
|
|
13
|
-
/* max-width: 1000px; */
|
|
14
|
-
margin: 0 auto !important;
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
}
|
|
19
3
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
|
7
|
+
<style type="text/css">
|
|
8
|
+
body {
|
|
9
|
+
margin: 0;
|
|
10
|
+
border-top: none !important;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.cdc-map-outer-container {
|
|
14
|
+
min-height: 100vh;
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
<link rel="stylesheet prefetch" href="https://www.cdc.gov/TemplatePackage/5.0/css/app.min.css?_=71669" />
|
|
18
|
+
|
|
19
|
+
<!-- This is temporary and for testing until Nunito/900 is added to TP -->
|
|
20
|
+
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@900&display=swap" rel="stylesheet" />
|
|
21
|
+
<style type="text/css">
|
|
22
|
+
@font-face {
|
|
23
|
+
font-family: 'Nunito';
|
|
24
|
+
font-weight: 900;
|
|
25
|
+
font-display: swap;
|
|
26
|
+
src: url('https://app.unpkg.com/@fontsource/nunito@5.0.18/files/files/nunito-latin-900-normal.woff2') format('woff2');
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
29
|
+
</head>
|
|
30
|
+
|
|
31
|
+
<body>
|
|
32
|
+
<div class="react-container" data-config="/examples/example-config.json"></div>
|
|
33
|
+
<script type="module" src="./src/index.jsx"></script>
|
|
34
|
+
</body>
|
|
35
|
+
|
|
36
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/filtered-text",
|
|
3
|
-
"version": "4.25.
|
|
3
|
+
"version": "4.25.11",
|
|
4
4
|
"description": "React component for adding filtered text on dashboards.",
|
|
5
5
|
"moduleName": "CdcFilteredText",
|
|
6
6
|
"main": "dist/cdcfilteredtext",
|
|
@@ -26,11 +26,19 @@
|
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"homepage": "https://github.com/CDCgov/cdc-open-viz#readme",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@cdc/core": "^4.25.
|
|
29
|
+
"@cdc/core": "^4.25.11",
|
|
30
|
+
"html-react-parser": "5.2.3",
|
|
31
|
+
"lodash": "^4.17.21"
|
|
30
32
|
},
|
|
31
33
|
"peerDependencies": {
|
|
32
34
|
"react": "^18.2.0",
|
|
33
35
|
"react-dom": "^18.2.0"
|
|
34
36
|
},
|
|
35
|
-
"
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
39
|
+
"vite": "^4.4.11",
|
|
40
|
+
"vite-plugin-css-injected-by-js": "^2.4.0",
|
|
41
|
+
"vite-plugin-svgr": "^2.4.0"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "5f09a137c22f454111ab5f4cd7fdf1d2d58e31bd"
|
|
36
44
|
}
|
package/src/CdcFilteredText.jsx
CHANGED
|
@@ -22,7 +22,13 @@ import parse from 'html-react-parser'
|
|
|
22
22
|
// styles
|
|
23
23
|
import './scss/main.scss'
|
|
24
24
|
|
|
25
|
-
const CdcFilteredText = ({
|
|
25
|
+
const CdcFilteredText = ({
|
|
26
|
+
config: configObj,
|
|
27
|
+
configUrl,
|
|
28
|
+
isDashboard = false,
|
|
29
|
+
isEditor = false,
|
|
30
|
+
setConfig: setParentConfig
|
|
31
|
+
}) => {
|
|
26
32
|
const transform = new DataTransform()
|
|
27
33
|
// Default States
|
|
28
34
|
const [config, setConfig] = useState(defaults)
|
|
@@ -103,7 +109,7 @@ const CdcFilteredText = ({ config: configObj, configUrl, isDashboard = false, is
|
|
|
103
109
|
|
|
104
110
|
//Load initial config
|
|
105
111
|
useEffect(() => {
|
|
106
|
-
loadConfig().catch(err => console.
|
|
112
|
+
loadConfig().catch(err => console.error(err))
|
|
107
113
|
}, []) // eslint-disable-line
|
|
108
114
|
|
|
109
115
|
useEffect(() => {
|
|
@@ -1,34 +1,20 @@
|
|
|
1
|
-
import React, { useState, useEffect,
|
|
1
|
+
import React, { memo, useState, useEffect, useContext } from 'react'
|
|
2
|
+
import cloneConfig from '@cdc/core/helpers/cloneConfig'
|
|
2
3
|
import _ from 'lodash'
|
|
3
4
|
import ConfigContext from '../ConfigContext'
|
|
4
5
|
|
|
5
6
|
import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
|
|
6
7
|
import Accordion from '@cdc/core/components/ui/Accordion'
|
|
7
|
-
import
|
|
8
|
+
import { TextField, Select, CheckBox } from '@cdc/core/components/EditorPanel/Inputs'
|
|
8
9
|
import Button from '@cdc/core/components/elements/Button'
|
|
9
10
|
import Icon from '@cdc/core/components/ui/Icon'
|
|
10
11
|
import Tooltip from '@cdc/core/components/ui/Tooltip'
|
|
11
|
-
import InputSelect from '@cdc/core/components/inputs/InputSelect'
|
|
12
|
-
import InputCheckbox from '@cdc/core/components/inputs/InputCheckbox'
|
|
13
12
|
import Layout from '@cdc/core/components/Layout'
|
|
13
|
+
import { HeaderThemeSelector } from '@cdc/core/components/HeaderThemeSelector'
|
|
14
14
|
import { updateFieldFactory } from '@cdc/core/helpers/updateFieldFactory'
|
|
15
15
|
|
|
16
16
|
import '@cdc/core/styles/v2/components/editor.scss'
|
|
17
17
|
|
|
18
|
-
const headerColors = [
|
|
19
|
-
'theme-blue',
|
|
20
|
-
'theme-purple',
|
|
21
|
-
'theme-brown',
|
|
22
|
-
'theme-teal',
|
|
23
|
-
'theme-pink',
|
|
24
|
-
'theme-orange',
|
|
25
|
-
'theme-slate',
|
|
26
|
-
'theme-indigo',
|
|
27
|
-
'theme-cyan',
|
|
28
|
-
'theme-green',
|
|
29
|
-
'theme-amber'
|
|
30
|
-
]
|
|
31
|
-
|
|
32
18
|
const EditorPanel = memo(props => {
|
|
33
19
|
const { config, updateConfig, loading, stateData: data, setParentConfig, isDashboard } = useContext(ConfigContext)
|
|
34
20
|
|
|
@@ -147,7 +133,7 @@ const EditorPanel = memo(props => {
|
|
|
147
133
|
)
|
|
148
134
|
}
|
|
149
135
|
const convertStateToConfig = () => {
|
|
150
|
-
let strippedState =
|
|
136
|
+
let strippedState = cloneConfig(config)
|
|
151
137
|
delete strippedState.newViz
|
|
152
138
|
delete strippedState.runtime
|
|
153
139
|
|
|
@@ -156,7 +142,7 @@ const EditorPanel = memo(props => {
|
|
|
156
142
|
const editorContent = (
|
|
157
143
|
<Accordion>
|
|
158
144
|
<Accordion.Section title='General'>
|
|
159
|
-
<
|
|
145
|
+
<TextField
|
|
160
146
|
value={config.title}
|
|
161
147
|
fieldName='title'
|
|
162
148
|
label='Title'
|
|
@@ -165,33 +151,30 @@ const EditorPanel = memo(props => {
|
|
|
165
151
|
/>
|
|
166
152
|
</Accordion.Section>
|
|
167
153
|
<Accordion.Section title='Data'>
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
options={getColumns()}
|
|
177
|
-
/>
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
<hr className='cove-accordion__divider' />
|
|
154
|
+
<Select
|
|
155
|
+
value={config.textColumn || ''}
|
|
156
|
+
fieldName='textColumn'
|
|
157
|
+
label='Text Column'
|
|
158
|
+
updateField={updateField}
|
|
159
|
+
initial='Select'
|
|
160
|
+
options={getColumns()}
|
|
161
|
+
/>
|
|
181
162
|
|
|
182
163
|
<label style={{ marginBottom: '1rem' }}>
|
|
183
|
-
<span className='edit-label'>
|
|
184
|
-
|
|
185
|
-
<Tooltip
|
|
186
|
-
<
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
164
|
+
<span className='edit-label'>
|
|
165
|
+
Data Point Filters
|
|
166
|
+
<Tooltip style={{ textTransform: 'none' }}>
|
|
167
|
+
<Tooltip.Target>
|
|
168
|
+
<Icon display='question' style={{ marginLeft: '0.5rem' }} />
|
|
169
|
+
</Tooltip.Target>
|
|
170
|
+
<Tooltip.Content>
|
|
171
|
+
<p>
|
|
172
|
+
To refine the highlighted data point, specify one or more filters (e.g., "Male" and "Female" for a
|
|
173
|
+
column called "Sex").
|
|
174
|
+
</p>
|
|
175
|
+
</Tooltip.Content>
|
|
176
|
+
</Tooltip>
|
|
177
|
+
</span>
|
|
195
178
|
</label>
|
|
196
179
|
{config.filters && (
|
|
197
180
|
<ul className='filters-list' style={{ paddingLeft: 0, marginBottom: '1rem' }}>
|
|
@@ -206,38 +189,28 @@ const EditorPanel = memo(props => {
|
|
|
206
189
|
>
|
|
207
190
|
Remove
|
|
208
191
|
</button>
|
|
209
|
-
<
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
value
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}}
|
|
232
|
-
>
|
|
233
|
-
<option value=''>- Select Option -</option>
|
|
234
|
-
{getFilterColumnValues(index).map((dataKey, index) => (
|
|
235
|
-
<option value={dataKey} key={index}>
|
|
236
|
-
{dataKey}
|
|
237
|
-
</option>
|
|
238
|
-
))}
|
|
239
|
-
</select>
|
|
240
|
-
</label>
|
|
192
|
+
<Select
|
|
193
|
+
label='Column'
|
|
194
|
+
value={filter.columnName || ''}
|
|
195
|
+
options={[
|
|
196
|
+
{ value: '', label: '- Select Option -' },
|
|
197
|
+
...getColumns().map(col => ({ value: col, label: col }))
|
|
198
|
+
]}
|
|
199
|
+
onChange={e => {
|
|
200
|
+
updateFilterProp('columnName', index, e.target.value)
|
|
201
|
+
}}
|
|
202
|
+
/>
|
|
203
|
+
<Select
|
|
204
|
+
label='Column Value'
|
|
205
|
+
value={filter.columnValue || ''}
|
|
206
|
+
options={[
|
|
207
|
+
{ value: '', label: '- Select Option -' },
|
|
208
|
+
...getFilterColumnValues(index).map(val => ({ value: val, label: val }))
|
|
209
|
+
]}
|
|
210
|
+
onChange={e => {
|
|
211
|
+
updateFilterProp('columnValue', index, e.target.value)
|
|
212
|
+
}}
|
|
213
|
+
/>
|
|
241
214
|
</fieldset>
|
|
242
215
|
))}
|
|
243
216
|
</ul>
|
|
@@ -247,32 +220,21 @@ const EditorPanel = memo(props => {
|
|
|
247
220
|
</Button>
|
|
248
221
|
</Accordion.Section>
|
|
249
222
|
<Accordion.Section title='Visual'>
|
|
250
|
-
<
|
|
223
|
+
<Select
|
|
251
224
|
value={config.fontSize}
|
|
252
225
|
fieldName='fontSize'
|
|
253
226
|
label='Font Size'
|
|
254
227
|
updateField={updateField}
|
|
255
228
|
options={['small', 'medium', 'large']}
|
|
256
229
|
/>
|
|
257
|
-
<
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
<li
|
|
263
|
-
title={palette}
|
|
264
|
-
key={palette}
|
|
265
|
-
onClick={() => {
|
|
266
|
-
updateConfig({ ...config, theme: palette })
|
|
267
|
-
}}
|
|
268
|
-
className={config.theme === palette ? 'selected ' + palette : palette}
|
|
269
|
-
></li>
|
|
270
|
-
))}
|
|
271
|
-
</ul>
|
|
272
|
-
</label>
|
|
230
|
+
<HeaderThemeSelector
|
|
231
|
+
selectedTheme={config.theme}
|
|
232
|
+
onThemeSelect={theme => updateConfig({ ...config, theme })}
|
|
233
|
+
label='Theme'
|
|
234
|
+
/>
|
|
273
235
|
|
|
274
236
|
<div className='cove-accordion__panel-section checkbox-group'>
|
|
275
|
-
<
|
|
237
|
+
<CheckBox
|
|
276
238
|
inline
|
|
277
239
|
size='small'
|
|
278
240
|
value={config.visual.border}
|
|
@@ -281,7 +243,7 @@ const EditorPanel = memo(props => {
|
|
|
281
243
|
label='Display Border'
|
|
282
244
|
updateField={updateField}
|
|
283
245
|
/>
|
|
284
|
-
<
|
|
246
|
+
<CheckBox
|
|
285
247
|
inline
|
|
286
248
|
size='small'
|
|
287
249
|
value={config.visual.borderColorTheme}
|
|
@@ -290,7 +252,7 @@ const EditorPanel = memo(props => {
|
|
|
290
252
|
label='Use theme border color'
|
|
291
253
|
updateField={updateField}
|
|
292
254
|
/>
|
|
293
|
-
<
|
|
255
|
+
<CheckBox
|
|
294
256
|
size='small'
|
|
295
257
|
value={config.visual.accent}
|
|
296
258
|
section='visual'
|
|
@@ -298,7 +260,7 @@ const EditorPanel = memo(props => {
|
|
|
298
260
|
label='Use Accent Style'
|
|
299
261
|
updateField={updateField}
|
|
300
262
|
/>
|
|
301
|
-
<
|
|
263
|
+
<CheckBox
|
|
302
264
|
size='small'
|
|
303
265
|
value={config.visual.background}
|
|
304
266
|
section='visual'
|
|
@@ -306,7 +268,7 @@ const EditorPanel = memo(props => {
|
|
|
306
268
|
label='Use Theme Background Color'
|
|
307
269
|
updateField={updateField}
|
|
308
270
|
/>
|
|
309
|
-
<
|
|
271
|
+
<CheckBox
|
|
310
272
|
size='small'
|
|
311
273
|
value={config.visual.hideBackgroundColor}
|
|
312
274
|
section='visual'
|
package/src/index.jsx
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { testStandaloneBuild } from '@cdc/core/helpers/tests/testStandaloneBuild.ts'
|
|
3
|
+
import { describe, it, expect } from 'vitest'
|
|
4
|
+
|
|
2
5
|
describe('Filtered Text', () => {
|
|
3
|
-
it('
|
|
4
|
-
|
|
6
|
+
it('Can be built in isolation', async () => {
|
|
7
|
+
const pkgDir = path.join(__dirname, '..')
|
|
8
|
+
const result = testStandaloneBuild(pkgDir)
|
|
9
|
+
expect(result).toBe(true)
|
|
5
10
|
})
|
|
6
11
|
})
|
package/vite.config.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import '@cdc/core/styles/base';
|