dce-reactkit 3.2.4 → 3.2.5

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": "dce-reactkit",
3
- "version": "3.2.4",
3
+ "version": "3.2.5",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -467,7 +467,7 @@ const columns: IntelliTableColumn[] = [
467
467
  */
468
468
  const genHumanReadableName = (machineReadableName: string) => {
469
469
  let humanReadableName = '';
470
-
470
+
471
471
  // Add chars and spaces
472
472
  const chars = machineReadableName.split('');
473
473
  chars.forEach((char) => {
@@ -477,9 +477,49 @@ const genHumanReadableName = (machineReadableName: string) => {
477
477
  }
478
478
  humanReadableName += char;
479
479
  });
480
+ const words = (
481
+ humanReadableName
482
+ .trim()
483
+ // Split into words
484
+ .split(' ')
485
+ // Filter out whitespace
486
+ .filter((word) => {
487
+ return (word.length > 0);
488
+ })
489
+ // Capitalize first letter
490
+ .map((word) => {
491
+ if (word.length <= 1) {
492
+ return word;
493
+ }
494
+ return `${word.substring(0, 1).toUpperCase()}${word.substring(1)}`;
495
+ })
496
+ );
497
+
498
+ // Handle acronyms by piling words together
499
+ const consolidatedWords: string[] = [];
500
+ let acronym = '';
501
+ words.forEach((word) => {
502
+ if (word.length === 1) {
503
+ // Add on to acronym
504
+ acronym += word;
505
+ } else {
506
+ // Wrap up acronym
507
+ if (acronym.length > 0) {
508
+ consolidatedWords.push(acronym);
509
+ acronym = '';
510
+ }
511
+
512
+ // Full word. Just add it
513
+ consolidatedWords.push(word);
514
+ }
515
+ });
516
+ // Add trailing acronym
517
+ if (acronym.length > 0) {
518
+ consolidatedWords.push(acronym);
519
+ }
480
520
 
481
- // Trim and return
482
- return humanReadableName.trim();
521
+ // Return
522
+ return consolidatedWords.join(' ');
483
523
  };
484
524
 
485
525
  /*------------------------------------------------------------------------*/