Skip to content

Commit

Permalink
fix(cardutilityfunctions): export card variable util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Stone committed Aug 21, 2020
1 parent 592a2db commit f2655ef
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 15 deletions.
36 changes: 36 additions & 0 deletions .storybook/__snapshots__/Welcome.story.storyshot
Original file line number Diff line number Diff line change
Expand Up @@ -3364,6 +3364,42 @@ exports[`Storybook Snapshot tests and console checks Storyshots 0/Getting Starte
formatNumberWithPrecision
</div>
</div>
<div
className="bx--structured-list-row"
>
<div
className="bx--structured-list-td"
/>
<div
className="bx--structured-list-td"
>
getVariables
</div>
</div>
<div
className="bx--structured-list-row"
>
<div
className="bx--structured-list-td"
/>
<div
className="bx--structured-list-td"
>
getCardVariables
</div>
</div>
<div
className="bx--structured-list-row"
>
<div
className="bx--structured-list-td"
/>
<div
className="bx--structured-list-td"
>
replaceVariables
</div>
</div>
<div
className="bx--structured-list-row"
>
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ export {
determineMaxValueCardAttributeCount,
compareGrains,
formatNumberWithPrecision,
getVariables,
getCardVariables,
replaceVariables,
} from './utils/cardUtilityFunctions';

export { csvDownloadHandler } from './utils/componentUtilityFunctions';
3 changes: 3 additions & 0 deletions src/utils/__tests__/__snapshots__/publicAPI.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19809,6 +19809,9 @@ Map {
"determineMaxValueCardAttributeCount" => Object {},
"compareGrains" => Object {},
"formatNumberWithPrecision" => Object {},
"getVariables" => Object {},
"getCardVariables" => Object {},
"replaceVariables" => Object {},
"csvDownloadHandler" => Object {},
"tableActions" => Object {
"TABLE_ACTION_APPLY": "TABLE_ACTION_APPLY",
Expand Down
15 changes: 0 additions & 15 deletions src/utils/cardUtilityFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,22 +213,7 @@ export const replaceVariables = (variables, cardVariables, target) => {
if (Array.isArray(target)) {
return target.map(element => replaceVariables(variables, cardVariables, element));
}
// variables.forEach(variable => {
// const insensitiveVariable = variable.toLowerCase();
// const variableRegex = new RegExp(`{${variable}}`, 'g');
// // Need to update the target with all lower-case variables for case-insesitivity
// updatedTarget = updatedTarget.replace(variableRegex, `{${insensitiveVariable}}`);

// if (typeof insensitiveCardVariables[insensitiveVariable] === 'function') {
// const callback = insensitiveCardVariables[insensitiveVariable];
// updatedTarget = callback(variable, target);
// } else {
// const insensitiveVariableRegex = new RegExp(`{${insensitiveVariable}}`, 'g');
// updatedTarget = updatedTarget.replace(
// insensitiveVariableRegex,
// insensitiveCardVariables[insensitiveVariable]
// );
// }
// if it's an object, then recursively replace each value unless it's a react element
if (typeof target === 'object') {
// if it's a react element, leave it alone
Expand Down

0 comments on commit f2655ef

Please sign in to comment.