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/dist/esm/index.js CHANGED
@@ -3019,8 +3019,45 @@ const genHumanReadableName = (machineReadableName) => {
3019
3019
  }
3020
3020
  humanReadableName += char;
3021
3021
  });
3022
- // Trim and return
3023
- return humanReadableName.trim();
3022
+ const words = (humanReadableName
3023
+ .trim()
3024
+ // Split into words
3025
+ .split(' ')
3026
+ // Filter out whitespace
3027
+ .filter((word) => {
3028
+ return (word.length > 0);
3029
+ })
3030
+ // Capitalize first letter
3031
+ .map((word) => {
3032
+ if (word.length <= 1) {
3033
+ return word;
3034
+ }
3035
+ return `${word.substring(0, 1).toUpperCase()}${word.substring(1)}`;
3036
+ }));
3037
+ // Handle acronyms by piling words together
3038
+ const consolidatedWords = [];
3039
+ let acronym = '';
3040
+ words.forEach((word) => {
3041
+ if (word.length === 1) {
3042
+ // Add on to acronym
3043
+ acronym += word;
3044
+ }
3045
+ else {
3046
+ // Wrap up acronym
3047
+ if (acronym.length > 0) {
3048
+ consolidatedWords.push(acronym);
3049
+ acronym = '';
3050
+ }
3051
+ // Full word. Just add it
3052
+ consolidatedWords.push(word);
3053
+ }
3054
+ });
3055
+ // Add trailing acronym
3056
+ if (acronym.length > 0) {
3057
+ consolidatedWords.push(acronym);
3058
+ }
3059
+ // Return
3060
+ return consolidatedWords.join(' ');
3024
3061
  };
3025
3062
  /* ------------- Actions ------------ */
3026
3063
  // Types of actions