@cdc/markup-include 4.24.7 → 4.24.9

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.7",
3
+ "version": "4.24.9",
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.7",
30
+ "@cdc/core": "^4.24.9",
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": "7a7372d03778cb977e0e92e3b3bc1a35f8a5bfaf"
42
+ "gitHead": "c4b0402afe6ed209a85b7078711549b9fd7dae7d"
43
43
  }
@@ -72,7 +72,7 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({ configUrl, config:
72
72
  }
73
73
 
74
74
  response.data = responseData
75
- const processedConfig = { ...(await coveUpdateWorker(response)) }
75
+ const processedConfig = { ...coveUpdateWorker(response) }
76
76
 
77
77
  updateConfig({ ...configObj, ...processedConfig })
78
78
  dispatch({ type: 'SET_LOADING', payload: false })
@@ -166,9 +166,16 @@ const CdcMarkupInclude: React.FC<CdcMarkupIncludeProps> = ({ configUrl, config:
166
166
  }
167
167
  variableDisplay.push(variableValues.join(', '))
168
168
 
169
+ let finalDisplay = variableDisplay[0]
170
+
171
+ if(workingVariable.addCommas && !isNaN(parseFloat(finalDisplay))){
172
+ finalDisplay = parseFloat(finalDisplay)
173
+ finalDisplay = finalDisplay.toLocaleString('en-US', {useGrouping: true})
174
+ }
175
+
169
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>'
170
177
 
171
- const newReplacementForVariable = `<span class="cove-tooltip-variable">${variableTag}<span class="cove-tooltip-value">${displayInfoMessage}<br/>${variableDisplay[0]}</span></span><span class="cove-markup-include-variable-value">${variableDisplay[0].trim()}</span>`
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>`
172
179
 
173
180
  return newReplacementForVariable
174
181
  })
@@ -4,6 +4,8 @@ import { Variable } from '../types/Variable'
4
4
  import { Condition } from '../types/Condition'
5
5
  import _ from 'lodash'
6
6
  import Icon from '@cdc/core/components/ui/Icon'
7
+ import { CheckBox } from '@cdc/core/components/EditorPanel/Inputs'
8
+ import Tooltip from '@cdc/core/components/ui/Tooltip'
7
9
 
8
10
  type OpenControls = [boolean[], Function] // useState type
9
11
 
@@ -29,6 +31,7 @@ const VariableSection: React.FC<VariableSectionProps> = ({ controls, data, delet
29
31
  const [selectedColumn, setNewVariableColumnName] = useState(variableConfig.columnName)
30
32
  const [conditionsList, setConditionsList] = useState(variableConfig.conditions)
31
33
  const [variableName, setVariableName] = useState(variableConfig.name)
34
+ const [addCommas, setAddCommas] = useState(variableConfig.addCommas)
32
35
 
33
36
  const conditionLookup: Record<string, string[] | number[]> = useMemo(() => {
34
37
  return columnNames.reduce((acc, column) => {
@@ -37,6 +40,10 @@ const VariableSection: React.FC<VariableSectionProps> = ({ controls, data, delet
37
40
  }, {})
38
41
  }, [columnNames])
39
42
 
43
+ const handleUpdateAddCommas = () => {
44
+ setAddCommas(!addCommas)
45
+ }
46
+
40
47
  const handleVariableColumnChange = (columnName: string) => {
41
48
  setNewVariableColumnName(columnName)
42
49
  setConditionsList([])
@@ -82,7 +89,8 @@ const VariableSection: React.FC<VariableSectionProps> = ({ controls, data, delet
82
89
  columnName: selectedColumn,
83
90
  conditions: filteredConditionsList,
84
91
  name: variableName,
85
- tag: `{{${variableName}}}`
92
+ tag: `{{${variableName}}}`,
93
+ addCommas
86
94
  }
87
95
  updateVariableArray(newVariable, variableIndex)
88
96
  setShow(variableIndex, false)
@@ -135,6 +143,23 @@ const VariableSection: React.FC<VariableSectionProps> = ({ controls, data, delet
135
143
  </select>
136
144
  </label>
137
145
  </div>
146
+ <div className='pt-2'>
147
+ <CheckBox
148
+ value={addCommas}
149
+ label='Add Commas to Number'
150
+ updateField={handleUpdateAddCommas}
151
+ tooltip={
152
+ <Tooltip style={{ textTransform: 'none' }}>
153
+ <Tooltip.Target>
154
+ <Icon display='question' style={{ marginLeft: '0.5rem', display: 'inline-block', whiteSpace: 'nowrap' }} />
155
+ </Tooltip.Target>
156
+ <Tooltip.Content>
157
+ <p>{`Selecting this option will add commas to the numeric value.`}</p>
158
+ </Tooltip.Content>
159
+ </Tooltip>
160
+ }
161
+ />
162
+ </div>
138
163
  <label className='d-block py-2'>
139
164
  <span className='edit-label column-heading'>Conditions:</span>
140
165
  {conditionsList.map((condition, index) => {