@react-hive/honey-utils 3.16.0 → 3.17.0

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.
@@ -2471,20 +2471,20 @@ __webpack_require__.r(__webpack_exports__);
2471
2471
  * ⚠️ Character comparison is performed at the UTF-16 code unit level
2472
2472
  * (`String.charCodeAt`), not by Unicode grapheme clusters.
2473
2473
  *
2474
- * @param inputString - The string to scan.
2474
+ * @param input - The string to scan.
2475
2475
  * @param targetChar - A single character to search for.
2476
2476
  *
2477
2477
  * @returns An array of zero-based indices for each occurrence of `targetChar`.
2478
2478
  * Returns an empty array if no matches are found.
2479
2479
  */
2480
- const findCharIndices = (inputString, targetChar) => {
2481
- if (inputString.length === 0) {
2480
+ const findCharIndices = (input, targetChar) => {
2481
+ if (input.length === 0) {
2482
2482
  return [];
2483
2483
  }
2484
2484
  const targetCode = targetChar.charCodeAt(0);
2485
2485
  const indices = [];
2486
- for (let i = 0; i < inputString.length; i++) {
2487
- if (inputString.charCodeAt(i) === targetCode) {
2486
+ for (let i = 0; i < input.length; i++) {
2487
+ if (input.charCodeAt(i) === targetCode) {
2488
2488
  indices.push(i);
2489
2489
  }
2490
2490
  }
@@ -2534,6 +2534,43 @@ const forEachChar = (input, onChar, shouldSkipChar) => {
2534
2534
  };
2535
2535
 
2536
2536
 
2537
+ /***/ }),
2538
+
2539
+ /***/ "./src/string/get-words-initials.ts":
2540
+ /*!******************************************!*\
2541
+ !*** ./src/string/get-words-initials.ts ***!
2542
+ \******************************************/
2543
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2544
+
2545
+ __webpack_require__.r(__webpack_exports__);
2546
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2547
+ /* harmony export */ getWordsInitials: () => (/* binding */ getWordsInitials)
2548
+ /* harmony export */ });
2549
+ /* harmony import */ var _split_string_into_words__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./split-string-into-words */ "./src/string/split-string-into-words.ts");
2550
+
2551
+ /**
2552
+ * Returns the uppercase initials of the words in a string.
2553
+ *
2554
+ * The first character of each word is extracted, concatenated, and uppercased.
2555
+ *
2556
+ * @param input - The input string.
2557
+ * @param maxWords - Maximum number of words to include when generating initials.
2558
+ * Defaults to `Infinity`.
2559
+ *
2560
+ * @returns A string containing the uppercase initials of the selected words.
2561
+ */
2562
+ const getWordsInitials = (input, maxWords = Infinity) => {
2563
+ if (input.length === 0) {
2564
+ return '';
2565
+ }
2566
+ return (0,_split_string_into_words__WEBPACK_IMPORTED_MODULE_0__.splitStringIntoWords)(input)
2567
+ .slice(0, maxWords)
2568
+ .map(word => word[0])
2569
+ .join('')
2570
+ .toUpperCase();
2571
+ };
2572
+
2573
+
2537
2574
  /***/ }),
2538
2575
 
2539
2576
  /***/ "./src/string/index.ts":
@@ -2548,6 +2585,7 @@ __webpack_require__.r(__webpack_exports__);
2548
2585
  /* harmony export */ camelToWords: () => (/* reexport safe */ _camel_to_words__WEBPACK_IMPORTED_MODULE_3__.camelToWords),
2549
2586
  /* harmony export */ findCharIndices: () => (/* reexport safe */ _find_char_indices__WEBPACK_IMPORTED_MODULE_7__.findCharIndices),
2550
2587
  /* harmony export */ forEachChar: () => (/* reexport safe */ _for_each_char__WEBPACK_IMPORTED_MODULE_8__.forEachChar),
2588
+ /* harmony export */ getWordsInitials: () => (/* reexport safe */ _get_words_initials__WEBPACK_IMPORTED_MODULE_9__.getWordsInitials),
2551
2589
  /* harmony export */ isNilOrEmptyString: () => (/* reexport safe */ _is_nil_or_empty_string__WEBPACK_IMPORTED_MODULE_5__.isNilOrEmptyString),
2552
2590
  /* harmony export */ isString: () => (/* reexport safe */ _is_string__WEBPACK_IMPORTED_MODULE_0__.isString),
2553
2591
  /* harmony export */ parseFileName: () => (/* reexport safe */ _parse_file_name__WEBPACK_IMPORTED_MODULE_6__.parseFileName),
@@ -2563,6 +2601,8 @@ __webpack_require__.r(__webpack_exports__);
2563
2601
  /* harmony import */ var _parse_file_name__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./parse-file-name */ "./src/string/parse-file-name.ts");
2564
2602
  /* harmony import */ var _find_char_indices__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./find-char-indices */ "./src/string/find-char-indices.ts");
2565
2603
  /* harmony import */ var _for_each_char__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./for-each-char */ "./src/string/for-each-char.ts");
2604
+ /* harmony import */ var _get_words_initials__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./get-words-initials */ "./src/string/get-words-initials.ts");
2605
+
2566
2606
 
2567
2607
 
2568
2608
 
@@ -2681,7 +2721,12 @@ __webpack_require__.r(__webpack_exports__);
2681
2721
  *
2682
2722
  * @returns An array of words from the input string.
2683
2723
  */
2684
- const splitStringIntoWords = (input) => input.split(' ').filter(Boolean);
2724
+ const splitStringIntoWords = (input) => {
2725
+ if (input.length === 0) {
2726
+ return [];
2727
+ }
2728
+ return input.split(' ').filter(Boolean);
2729
+ };
2685
2730
 
2686
2731
 
2687
2732
  /***/ }),
@@ -2812,6 +2857,7 @@ __webpack_require__.r(__webpack_exports__);
2812
2857
  /* harmony export */ getElementOffsetRect: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.getElementOffsetRect),
2813
2858
  /* harmony export */ getFocusableHtmlElements: () => (/* reexport safe */ _a11y__WEBPACK_IMPORTED_MODULE_11__.getFocusableHtmlElements),
2814
2859
  /* harmony export */ getLocalStorageCapabilities: () => (/* reexport safe */ _env__WEBPACK_IMPORTED_MODULE_12__.getLocalStorageCapabilities),
2860
+ /* harmony export */ getWordsInitials: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_1__.getWordsInitials),
2815
2861
  /* harmony export */ getXOverflowWidth: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.getXOverflowWidth),
2816
2862
  /* harmony export */ getYOverflowHeight: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.getYOverflowHeight),
2817
2863
  /* harmony export */ hasXOverflow: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.hasXOverflow),