@cdc/markup-include 4.24.9 → 4.24.10

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.24.9",
3
+ "version": "4.24.10",
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.24.9",
30
+ "@cdc/core": "^4.24.10",
31
31
  "axios": "^1.6.0",
32
32
  "chroma": "0.0.1",
33
33
  "chroma-js": "^2.1.0",
@@ -39,5 +39,5 @@
39
39
  "react": "^18.2.0",
40
40
  "react-dom": "^18.2.0"
41
41
  },
42
- "gitHead": "c4b0402afe6ed209a85b7078711549b9fd7dae7d"
42
+ "gitHead": "a4d88d1bc91f596e1b0307d8e25c57ad8c668b75"
43
43
  }
@@ -31,8 +31,21 @@ type CdcMarkupIncludeProps = {
31
31
 
32
32
  import Title from '@cdc/core/components/ui/Title'
33
33
 
34
- const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({ configUrl, config: configObj, isDashboard = true, isEditor = false, setConfig: setParentConfig }) => {
35
- const initialState = { config: configObj, loading: true, urlMarkup: '', markupError: null, errorMessage: null, coveLoadedHasRan: false }
34
+ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({
35
+ configUrl,
36
+ config: configObj,
37
+ isDashboard = true,
38
+ isEditor = false,
39
+ setConfig: setParentConfig
40
+ }) => {
41
+ const initialState = {
42
+ config: configObj,
43
+ loading: true,
44
+ urlMarkup: '',
45
+ markupError: null,
46
+ errorMessage: null,
47
+ coveLoadedHasRan: false
48
+ }
36
49
 
37
50
  const [state, dispatch] = useReducer(markupIncludeReducer, initialState)
38
51
 
@@ -92,7 +105,8 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({ configUrl, config:
92
105
  let errorList = {
93
106
  200: 'This is likely due to a CORS restriction policy from the remote origin address.',
94
107
  404: 'The requested source URL cannot be found. Please verify the link address provided.',
95
- proto: 'Provided source URL must include https:// or http:// before the address (depending on the source content type).'
108
+ proto:
109
+ 'Provided source URL must include https:// or http:// before the address (depending on the source content type).'
96
110
  }
97
111
 
98
112
  message += errorList[errorCode]
@@ -138,7 +152,10 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({ configUrl, config:
138
152
  const filterOutConditions = (workingData, conditionList) => {
139
153
  const { columnName, isOrIsNotEqualTo, value } = conditionList[0]
140
154
 
141
- const newWorkingData = isOrIsNotEqualTo === 'is' ? workingData.filter(dataObject => dataObject[columnName] === value) : workingData.filter(dataObject => dataObject[columnName] !== value)
155
+ const newWorkingData =
156
+ isOrIsNotEqualTo === 'is'
157
+ ? workingData.filter(dataObject => dataObject[columnName] === value)
158
+ : workingData.filter(dataObject => dataObject[columnName] !== value)
142
159
 
143
160
  conditionList.shift()
144
161
  return conditionList.length === 0 ? newWorkingData : filterOutConditions(newWorkingData, conditionList)
@@ -150,9 +167,14 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({ configUrl, config:
150
167
  const convertedInlineMarkup = inlineMarkup.replace(variableRegexPattern, variableTag => {
151
168
  const workingVariable = markupVariables.filter(variable => variable.tag === variableTag)[0]
152
169
  if (workingVariable === undefined) return [variableTag]
153
- const workingData = workingVariable && workingVariable.conditions.length === 0 ? data : filterOutConditions(data, [...workingVariable.conditions])
154
-
155
- const variableValues: string[] = _.uniq(workingData?.map(dataObject => dataObject[workingVariable.columnName]))
170
+ const workingData =
171
+ workingVariable && workingVariable.conditions.length === 0
172
+ ? data
173
+ : filterOutConditions(data, [...workingVariable.conditions])
174
+
175
+ const variableValues: string[] = _.uniq(
176
+ (workingData || []).map(dataObject => dataObject[workingVariable.columnName])
177
+ )
156
178
  const variableDisplay = []
157
179
 
158
180
  const listConjunction = !isEditor ? 'and' : 'or'
@@ -168,16 +190,12 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({ configUrl, config:
168
190
 
169
191
  let finalDisplay = variableDisplay[0]
170
192
 
171
- if(workingVariable.addCommas && !isNaN(parseFloat(finalDisplay))){
193
+ if (workingVariable.addCommas && !isNaN(parseFloat(finalDisplay))) {
172
194
  finalDisplay = parseFloat(finalDisplay)
173
- finalDisplay = finalDisplay.toLocaleString('en-US', {useGrouping: true})
195
+ finalDisplay = finalDisplay.toLocaleString('en-US', { useGrouping: true })
174
196
  }
175
197
 
176
- const displayInfoMessage = '<span class="font-weight-bold display-Info-message">One or more of the following values will appear in the place of this variable placeholder:</span>'
177
-
178
- const newReplacementForVariable = `<span class="cove-tooltip-variable">${variableTag}<span class="cove-tooltip-value">${displayInfoMessage}<br/>${finalDisplay}</span></span><span class="cove-markup-include-variable-value">${finalDisplay}</span>`
179
-
180
- return newReplacementForVariable
198
+ return finalDisplay
181
199
  })
182
200
  return convertedInlineMarkup
183
201
  }
@@ -210,11 +228,6 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({ configUrl, config:
210
228
  }
211
229
  }, [config, container])
212
230
 
213
- //Reload config if config object provided/updated
214
- useEffect(() => {
215
- loadConfig().catch(err => console.log(err))
216
- }, [configObj?.data])
217
-
218
231
  //Reload any functions when config is updated
219
232
  useEffect(() => {
220
233
  loadConfigMarkupData().catch(err => console.log(err))
@@ -0,0 +1 @@
1
+ @import '@cdc/core/styles/base';
package/src/index.jsx CHANGED
@@ -5,6 +5,8 @@ import { GlobalContextProvider } from '@cdc/core/components/GlobalContext'
5
5
 
6
6
  import CdcMarkupInclude from './CdcMarkupInclude'
7
7
 
8
+ import './coreStyles_markupinclude.scss'
9
+
8
10
  let isEditor = window.location.href.includes('editor=true')
9
11
 
10
12
  let domContainer = document.getElementsByClassName('react-container')[0]
@@ -14,5 +16,5 @@ ReactDOM.createRoot(domContainer).render(
14
16
  <GlobalContextProvider>
15
17
  <CdcMarkupInclude configUrl={domContainer.attributes['data-config'].value} isEditor={isEditor} />
16
18
  </GlobalContextProvider>
17
- </React.StrictMode>,
19
+ </React.StrictMode>
18
20
  )
@@ -1,5 +1,3 @@
1
- @import '@cdc/core/styles/base';
2
-
3
1
  .markup-include {
4
2
  .checkbox-group {
5
3
  padding: 16px;