kupos-ui-components-lib 7.0.8 → 7.0.9

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.
@@ -343,15 +343,30 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
343
343
  const getNumberOfSeats = () => {
344
344
  return serviceItem.seat_types.filter((val) => !SEAT_EXCEPTIONS.includes(val.label)).length;
345
345
  };
346
+ // const truncateSeatLabel = (label: string | number): string => {
347
+ // if (typeof label !== "string") return String(label);
348
+ // if (label.includes("(")) return label;
349
+ // const words = label.trim().split(/\s+/);
350
+ // if (words.length <= 2) return label;
351
+ // return `${words[0]} ${words[1]} ${words[2].charAt(0)}...`;
352
+ // };
353
+ // Helper function to truncate seat labels with more than 2 words
346
354
  const truncateSeatLabel = (label) => {
347
355
  if (typeof label !== "string")
348
356
  return String(label);
357
+ // Don't truncate if label contains parentheses (e.g., "Cama (180°)")
349
358
  if (label.includes("("))
350
359
  return label;
351
360
  const words = label.trim().split(/\s+/);
352
- if (words.length <= 2)
361
+ // Helper to truncate a word if it's longer than 5 characters
362
+ const truncateWord = (word) => word.length > 5 ? word.slice(0, 3) + "..." : word;
363
+ if (words.length === 1)
353
364
  return label;
354
- return `${words[0]} ${words[1]} ${words[2].charAt(0)}...`;
365
+ if (words.length === 2) {
366
+ return `${words[0]} ${truncateWord(words[1])}`;
367
+ }
368
+ // 3+ words: first word + truncated 2nd word + first letter of 3rd word + "..."
369
+ return `${words[0]} ${truncateWord(words[1])} ${words[2].charAt(0)}...`;
355
370
  };
356
371
  const getSeatNames = () => {
357
372
  const uniqueSeats = getUniqueSeats();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "7.0.8",
3
+ "version": "7.0.9",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -446,12 +446,31 @@ function ServiceItemPB({
446
446
  ).length;
447
447
  };
448
448
 
449
+ // const truncateSeatLabel = (label: string | number): string => {
450
+ // if (typeof label !== "string") return String(label);
451
+ // if (label.includes("(")) return label;
452
+ // const words = label.trim().split(/\s+/);
453
+ // if (words.length <= 2) return label;
454
+ // return `${words[0]} ${words[1]} ${words[2].charAt(0)}...`;
455
+ // };
456
+
457
+ // Helper function to truncate seat labels with more than 2 words
449
458
  const truncateSeatLabel = (label: string | number): string => {
450
459
  if (typeof label !== "string") return String(label);
460
+ // Don't truncate if label contains parentheses (e.g., "Cama (180°)")
451
461
  if (label.includes("(")) return label;
452
462
  const words = label.trim().split(/\s+/);
453
- if (words.length <= 2) return label;
454
- return `${words[0]} ${words[1]} ${words[2].charAt(0)}...`;
463
+
464
+ // Helper to truncate a word if it's longer than 5 characters
465
+ const truncateWord = (word: string) =>
466
+ word.length > 5 ? word.slice(0, 3) + "..." : word;
467
+
468
+ if (words.length === 1) return label;
469
+ if (words.length === 2) {
470
+ return `${words[0]} ${truncateWord(words[1])}`;
471
+ }
472
+ // 3+ words: first word + truncated 2nd word + first letter of 3rd word + "..."
473
+ return `${words[0]} ${truncateWord(words[1])} ${words[2].charAt(0)}...`;
455
474
  };
456
475
 
457
476
  const getSeatNames = () => {