@cdc/markup-include 4.25.7 → 4.25.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdc/markup-include",
3
- "version": "4.25.7",
3
+ "version": "4.25.8",
4
4
  "description": "React component for displaying HTML content from an outside link",
5
5
  "moduleName": "CdcMarkupInclude",
6
6
  "main": "dist/cdcmarkupinclude",
@@ -27,7 +27,7 @@
27
27
  "license": "Apache-2.0",
28
28
  "homepage": "https://github.com/CDCgov/cdc-open-viz#readme",
29
29
  "dependencies": {
30
- "@cdc/core": "^4.25.7",
30
+ "@cdc/core": "^4.25.8",
31
31
  "axios": "^1.9.0",
32
32
  "chroma": "0.0.1",
33
33
  "interweave": "^13.1.1",
@@ -37,5 +37,5 @@
37
37
  "react": "^18.2.0",
38
38
  "react-dom": "^18.2.0"
39
39
  },
40
- "gitHead": "9062881d50c824ee6cdd71868bafd016a5e5694d"
40
+ "gitHead": "e369994230b5e3facff224e1d89d5937528ac5a0"
41
41
  }
@@ -33,6 +33,7 @@ type CdcMarkupIncludeProps = {
33
33
  import Title from '@cdc/core/components/ui/Title'
34
34
  import FootnotesStandAlone from '@cdc/core/components/Footnotes/FootnotesStandAlone'
35
35
  import { Datasets } from '@cdc/core/types/DataSet'
36
+ import { publishAnalyticsEvent } from '@cdc/core/helpers/metrics/helpers'
36
37
 
37
38
  const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({
38
39
  configUrl,
@@ -60,6 +61,7 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({
60
61
 
61
62
  const { innerContainerClasses, contentClasses } = useDataVizClasses(config || {})
62
63
  const { contentEditor, theme } = config || {}
64
+ const { showNoDataMessage, allowHideSection, noDataMessageText } = contentEditor || {}
63
65
  const data = configObj?.data
64
66
 
65
67
  const { inlineHTML, markupVariables, srcUrl, title, useInlineHTML } = contentEditor || {}
@@ -166,6 +168,7 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({
166
168
  }
167
169
 
168
170
  const emptyVariableChecker = []
171
+ const noDataMessageChecker = []
169
172
 
170
173
  const convertVariablesInMarkup = inlineMarkup => {
171
174
  if (_.isEmpty(markupVariables)) return inlineMarkup
@@ -200,10 +203,15 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({
200
203
  if (length > 2) {
201
204
  variableValues[length - 1] = `${listConjunction} ${variableValues[length - 1]}`
202
205
  }
206
+
203
207
  variableDisplay.push(variableValues.join(', '))
204
208
 
205
209
  const finalDisplay = variableDisplay[0]
206
210
 
211
+ if (showNoDataMessage && finalDisplay === '') {
212
+ noDataMessageChecker.push(true)
213
+ }
214
+
207
215
  if (finalDisplay === '' && contentEditor.allowHideSection) {
208
216
  emptyVariableChecker.push(true)
209
217
  }
@@ -238,6 +246,7 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({
238
246
  if (config && !coveLoadedHasRan && container) {
239
247
  publish('cove_loaded', { config: config })
240
248
  dispatch({ type: 'SET_COVE_LOADED_HAS_RAN', payload: true })
249
+ publishAnalyticsEvent('markup-include_loaded', 'load', configUrl, 'markup-include')
241
250
  }
242
251
  }, [config, container])
243
252
 
@@ -251,11 +260,13 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({
251
260
  const markup = useInlineHTML ? convertVariablesInMarkup(inlineHTML) : parseBodyMarkup(urlMarkup)
252
261
 
253
262
  const hideMarkupInclude = contentEditor?.allowHideSection && emptyVariableChecker.length > 0 && !isEditor
263
+ const _showNoDataMessage = showNoDataMessage && noDataMessageChecker.length > 0 && !isEditor
254
264
 
255
265
  if (loading === false) {
256
266
  content = (
257
267
  <>
258
268
  {isEditor && <EditorPanel datasets={datasets} />}
269
+
259
270
  {!hideMarkupInclude && (
260
271
  <Layout.Responsive isEditor={isEditor}>
261
272
  <div className='markup-include-content-container cove-component__content no-borders'>
@@ -263,8 +274,13 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({
263
274
  <Title title={title} isDashboard={isDashboard} classes={[`${theme}`, 'mb-0']} />
264
275
  <div className={`${innerContainerClasses.join(' ')}`}>
265
276
  <div className='cove-component__content-wrap'>
266
- {!markupError && <Markup allowElements={!!urlMarkup} content={markup} />}
267
- {markupError && srcUrl && <div className='warning'>{errorMessage}</div>}
277
+ {_showNoDataMessage && (
278
+ <div className='no-data-message'>
279
+ <p>{`${noDataMessageText}`}</p>
280
+ </div>
281
+ )}
282
+ {!markupError && !_showNoDataMessage && <Markup allowElements={!!urlMarkup} content={markup} />}
283
+ {markupError && srcUrl && !_showNoDataMessage && <div className='warning'>{errorMessage}</div>}
268
284
  </div>
269
285
  </div>
270
286
  </div>
@@ -48,7 +48,8 @@ type MarkupIncludeEditorPanelProps = {
48
48
  const EditorPanel: React.FC<MarkupIncludeEditorPanelProps> = ({ datasets }) => {
49
49
  const { config, data, isDashboard, loading, setParentConfig, updateConfig } = useContext(ConfigContext)
50
50
  const { contentEditor, theme, visual } = config
51
- const { inlineHTML, markupVariables, srcUrl, title, useInlineHTML, allowHideSection } = contentEditor
51
+ const { inlineHTML, markupVariables, srcUrl, title, useInlineHTML, allowHideSection, shoNoDataMessage } =
52
+ contentEditor
52
53
  const [displayPanel, setDisplayPanel] = useState(true)
53
54
  const updateField = updateFieldFactory(config, updateConfig, true)
54
55
  const hasData = data?.[0] !== undefined ?? false
@@ -223,6 +224,14 @@ const EditorPanel: React.FC<MarkupIncludeEditorPanelProps> = ({ datasets }) => {
223
224
  </Tooltip>
224
225
  }
225
226
  />
227
+
228
+ <CheckBox
229
+ value={contentEditor.showNoDataMessage}
230
+ section='contentEditor'
231
+ fieldName='showNoDataMessage'
232
+ label='Add No Data Message'
233
+ updateField={updateField}
234
+ />
226
235
  </div>
227
236
 
228
237
  <div className='mb-1 d-flex'>
@@ -5,7 +5,9 @@ export default {
5
5
  showHeader: true,
6
6
  srcUrl: '#example',
7
7
  title: 'Markup Include',
8
- useInlineHTML: false
8
+ useInlineHTML: false,
9
+ showNoDataMessage: false,
10
+ noDataMessageText: 'No Data Available'
9
11
  },
10
12
  data: [],
11
13
  legend: {},
package/src/index.jsx CHANGED
@@ -15,7 +15,11 @@ let domContainer = document.getElementsByClassName('react-container')[0]
15
15
  ReactDOM.createRoot(domContainer).render(
16
16
  <React.StrictMode>
17
17
  <GlobalContextProvider>
18
- <CdcMarkupInclude configUrl={domContainer.attributes['data-config'].value} isEditor={isEditor} />
18
+ <CdcMarkupInclude
19
+ configUrl={domContainer.attributes['data-config'].value}
20
+ interactionLabel={domContainer.attributes['data-config'].value}
21
+ isEditor={isEditor}
22
+ />
19
23
  </GlobalContextProvider>
20
24
  </React.StrictMode>
21
25
  )
@@ -11,6 +11,8 @@ export type Config = {
11
11
  srcUrl: string
12
12
  title: string
13
13
  useInlineHTML: boolean
14
+ showNoDataMessage: boolean
15
+ noDataMessageText: string
14
16
  }
15
17
  data?: Object[]
16
18
  legend: {}