kupos-ui-components-lib 10.0.10 → 10.1.1

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.
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import commonService from "../utils/CommonService";
2
3
  const StageTooltip = ({ children, stageData, direction = 1, terminals, serviceItem, metaData, colors, position = "right", }) => {
3
4
  // ✅ moved inside
4
5
  const hideBoardingTime = (serviceItemApiType) => {
@@ -27,13 +28,13 @@ const StageTooltip = ({ children, stageData, direction = 1, terminals, serviceIt
27
28
  const sortedStages = hideTime
28
29
  ? [...formattedStages].sort()
29
30
  : [...formattedStages].sort(compareTimings);
30
- return (React.createElement("div", { className: "flex flex-col space-y-3 text-justify gap-[4px]" }, sortedStages.map((item, key) => (React.createElement("div", { key: key, className: "font-normal" }, hideTime
31
+ return (React.createElement("div", { className: "flex flex-col space-y-3 text-justify gap-[4px]" }, sortedStages.map((item, key) => (React.createElement("div", { key: key, className: "font-normal" }, commonService.capitalize(hideTime
31
32
  ? item === null || item === void 0 ? void 0 : item.split("|")[0]
32
33
  : item
33
34
  .replace(/false/g, "")
34
35
  .replace("true", "")
35
36
  .replace("|", " |")
36
- .replace("||", " |"))))));
37
+ .replace("||", " |")))))));
37
38
  }
38
39
  return null;
39
40
  };
@@ -264,9 +264,19 @@ const commonService = {
264
264
  if (str) {
265
265
  let strArr = str.split(" ");
266
266
  for (let i = 0; i < strArr.length; i++) {
267
- strArr[i] =
268
- strArr[i][0] &&
269
- strArr[i][0].toUpperCase() + strArr[i].substr(1).toLowerCase();
267
+ let word = strArr[i];
268
+ if (word) {
269
+ let firstLetterIdx = word.search(/[a-zA-Z\u00C0-\u00FF]/);
270
+ if (firstLetterIdx !== -1) {
271
+ strArr[i] =
272
+ word.slice(0, firstLetterIdx) +
273
+ word[firstLetterIdx].toUpperCase() +
274
+ word.slice(firstLetterIdx + 1).toLowerCase();
275
+ }
276
+ else {
277
+ strArr[i] = word.toLowerCase();
278
+ }
279
+ }
270
280
  }
271
281
  return strArr.join(" ");
272
282
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "10.0.10",
3
+ "version": "10.1.1",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import commonService from "../utils/CommonService";
2
3
 
3
4
  const StageTooltip = ({
4
5
  children,
@@ -53,13 +54,15 @@ const StageTooltip = ({
53
54
  <div className="flex flex-col space-y-3 text-justify gap-[4px]">
54
55
  {sortedStages.map((item, key) => (
55
56
  <div key={key} className="font-normal">
56
- {hideTime
57
- ? item?.split("|")[0]
58
- : item
59
- .replace(/false/g, "")
60
- .replace("true", "")
61
- .replace("|", " |")
62
- .replace("||", " |")}
57
+ {commonService.capitalize(
58
+ hideTime
59
+ ? item?.split("|")[0]
60
+ : item
61
+ .replace(/false/g, "")
62
+ .replace("true", "")
63
+ .replace("|", " |")
64
+ .replace("||", " |"),
65
+ )}
63
66
  </div>
64
67
  ))}
65
68
  </div>
@@ -277,9 +277,18 @@ const commonService = {
277
277
  if (str) {
278
278
  let strArr = str.split(" ");
279
279
  for (let i = 0; i < strArr.length; i++) {
280
- strArr[i] =
281
- strArr[i][0] &&
282
- strArr[i][0].toUpperCase() + strArr[i].substr(1).toLowerCase();
280
+ let word = strArr[i];
281
+ if (word) {
282
+ let firstLetterIdx = word.search(/[a-zA-Z\u00C0-\u00FF]/);
283
+ if (firstLetterIdx !== -1) {
284
+ strArr[i] =
285
+ word.slice(0, firstLetterIdx) +
286
+ word[firstLetterIdx].toUpperCase() +
287
+ word.slice(firstLetterIdx + 1).toLowerCase();
288
+ } else {
289
+ strArr[i] = word.toLowerCase();
290
+ }
291
+ }
283
292
  }
284
293
  return strArr.join(" ");
285
294
  }