kupos-ui-components-lib 7.0.7 → 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.
@@ -49,16 +49,40 @@ class ServiceFilter extends React.Component {
49
49
  this.setState({ addMargin: window.scrollY > 0 });
50
50
  }
51
51
  sortFilters(filtersArray) {
52
+ // Define the desired filter order
53
+ const FILTER_ORDER = [
54
+ "special_departure",
55
+ "time",
56
+ "tipo",
57
+ "seat_types",
58
+ "operator",
59
+ "train_type",
60
+ "amenities",
61
+ ];
62
+ // Create array with original indices preserved
52
63
  let newArr = [];
53
- filtersArray.forEach((val) => {
64
+ filtersArray.forEach((val, originalIndex) => {
54
65
  if (val.type === "seat_types") {
55
- let newSeatOrder = val.options.sort((a, b) => SEAT_ORDER.indexOf(a.label) - SEAT_ORDER.indexOf(b.label));
56
- newArr.push(Object.assign(Object.assign({}, val), { options: newSeatOrder }));
66
+ // Preserve original option indices before sorting
67
+ let optionsWithOriginalIndex = val.options.map((opt, optIndex) => (Object.assign(Object.assign({}, opt), { originalOptionIndex: optIndex })));
68
+ let newSeatOrder = [...optionsWithOriginalIndex].sort((a, b) => SEAT_ORDER.indexOf(a.label) - SEAT_ORDER.indexOf(b.label));
69
+ newArr.push(Object.assign(Object.assign({}, val), { options: newSeatOrder, originalIndex }));
57
70
  }
58
71
  else {
59
- newArr.push(val);
72
+ newArr.push(Object.assign(Object.assign({}, val), { originalIndex }));
60
73
  }
61
74
  });
75
+ newArr.sort((a, b) => {
76
+ const indexA = FILTER_ORDER.indexOf(a.type);
77
+ const indexB = FILTER_ORDER.indexOf(b.type);
78
+ if (indexA !== -1 && indexB !== -1)
79
+ return indexA - indexB;
80
+ if (indexA !== -1)
81
+ return -1;
82
+ if (indexB !== -1)
83
+ return 1;
84
+ return 0;
85
+ });
62
86
  return newArr;
63
87
  }
64
88
  clearFilter() {
@@ -203,7 +227,9 @@ class ServiceFilter extends React.Component {
203
227
  ? val.spText
204
228
  : val.label;
205
229
  }
206
- return (React.createElement("div", { key: i, onClick: () => onClick(i), style: {
230
+ return (React.createElement("div", { key: i, onClick: () => onClick(val.originalOptionIndex !== undefined
231
+ ? val.originalOptionIndex
232
+ : i), style: {
207
233
  margin: (val === null || val === void 0 ? void 0 : val.active) ? "3px 0" : "0",
208
234
  backgroundColor: val.active
209
235
  ? this.props.colors.selectedColor
@@ -216,7 +242,7 @@ class ServiceFilter extends React.Component {
216
242
  ? `text-[${this.props.colors.selectedTextColor}]`
217
243
  : ""} ${val.active ? "bold-text" : ""}` },
218
244
  val.icon && this.props.icons && (React.createElement("img", { src: iconKey, alt: val.icon, className: "w-[20px] h-[20px] mr-[10px] " })),
219
- label.charAt(0).toUpperCase() + label.slice(1).toLowerCase()));
245
+ React.createElement("span", { className: "capitalize" }, label.toLowerCase())));
220
246
  }))));
221
247
  }
222
248
  render() {
@@ -236,7 +262,7 @@ class ServiceFilter extends React.Component {
236
262
  React.createElement("div", { className: "text-[13.33px] pb-[10px]" }, sortedFilters === null || sortedFilters === void 0 ? void 0 : sortedFilters.map((val, key) => {
237
263
  var _a;
238
264
  return ((_a = val.options) === null || _a === void 0 ? void 0 : _a.length)
239
- ? this.renderFilterItem(val, (i) => onFilterSelected(key, i), key)
265
+ ? this.renderFilterItem(val, (i) => onFilterSelected(val.originalIndex, i), key)
240
266
  : null;
241
267
  }))),
242
268
  React.createElement("div", { onClick: this.clearFilter, className: `group text-[13.33px] bold-text items-center cursor-pointer absolute flex justify-center bg-[#eaeaea] pt-[35px] pb-[7px] w-full left-0 z-[1] -bottom-[30px] rounded-b-[10px] transition-all duration-300 ease-in-out ${hasActiveFilters
@@ -343,6 +343,13 @@ 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
+ // };
346
353
  // Helper function to truncate seat labels with more than 2 words
347
354
  const truncateSeatLabel = (label) => {
348
355
  if (typeof label !== "string")
@@ -351,10 +358,15 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
351
358
  if (label.includes("("))
352
359
  return label;
353
360
  const words = label.trim().split(/\s+/);
354
- 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)
355
364
  return label;
356
- // Take first 2 words + first letter of 3rd word + "..."
357
- 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)}...`;
358
370
  };
359
371
  const getSeatNames = () => {
360
372
  const uniqueSeats = getUniqueSeats();
@@ -551,11 +563,14 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
551
563
  (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.dep_time.includes("PM"))
552
564
  ? null
553
565
  : DateService.ampmOnly(serviceItem.dep_time))) : (React.createElement("div", { className: "font-[900] bold-text" }, DateService.formatTime(serviceItem.dep_time))),
554
- serviceItem.boarding_stages && (React.createElement("div", { className: "hidden group-hover:block absolute -top-[8px] left-[100%] ml-[25px] text-white px-3 py-2 rounded-[10px] whitespace-nowrap z-10 shadow-service", style: {
566
+ serviceItem.boarding_stages && (React.createElement("div", { className: "hidden group-hover:block absolute -top-[8px] text-white px-3 py-2 rounded-[7px] whitespace-nowrap z-10 shadow-service", style: {
555
567
  backgroundColor: colors === null || colors === void 0 ? void 0 : colors.tooltipColor,
556
568
  zIndex: 100,
569
+ left: "clamp(80%, 100% - (100vw - 1400px) * 0.05, 100%)",
557
570
  } },
558
- React.createElement("div", { className: "tooltip-arrow absolute top-2 -left-[7px] w-0 h-0 \n border-t-8 border-b-8 border-r-8 \n border-t-transparent border-b-transparent", style: { borderRightColor: colors === null || colors === void 0 ? void 0 : colors.tooltipColor } }),
571
+ React.createElement("div", { className: "tooltip-arrow absolute top-[5px] -left-[8px] w-0 h-0 \n border-t-[10px] border-b-[10px] border-r-[10px] \n border-t-transparent border-b-transparent", style: {
572
+ borderRightColor: colors === null || colors === void 0 ? void 0 : colors.tooltipColor,
573
+ } }),
559
574
  React.createElement("div", { className: "text-center text-[14px] font-normal", style: { fontWeight: 400 } }, renderStages(serviceItem.boarding_stages, 1, busStage, hideBoardingTime((serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.api_type) || (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.apiType))))))),
560
575
  !isCiva && (React.createElement("div", { className: "h-[20px] flex items-center group relative" },
561
576
  React.createElement("div", { className: "font-[900] bold-text" }, removeArrivalTime
@@ -563,11 +578,12 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
563
578
  : serviceItem.arr_time
564
579
  ? DateService.formatTime(serviceItem.arr_time)
565
580
  : null),
566
- serviceItem.dropoff_stages && (React.createElement("div", { className: "hidden group-hover:block absolute -top-[8px] left-[100%] ml-[25px] text-white px-3 py-2 rounded-[10px] whitespace-nowrap z-10 shadow-service", style: {
581
+ serviceItem.dropoff_stages && (React.createElement("div", { className: "hidden group-hover:block absolute -top-[8px] text-white px-3 py-2 rounded-[7px] whitespace-nowrap z-10 shadow-service", style: {
567
582
  backgroundColor: colors === null || colors === void 0 ? void 0 : colors.tooltipColor,
568
583
  zIndex: 100,
584
+ left: "clamp(80%, 100% - (100vw - 1400px) * 0.05, 100%)",
569
585
  } },
570
- React.createElement("div", { className: "tooltip-arrow absolute top-2 -left-[7px] w-0 h-0 \n border-t-8 border-b-8 border-r-8 \n border-t-transparent border-b-transparent", style: {
586
+ React.createElement("div", { className: "tooltip-arrow absolute top-[5px] -left-[8px] w-0 h-0 \n border-t-[10px] border-b-[10px] border-r-[10px] \n border-t-transparent border-b-transparent", style: {
571
587
  borderRightColor: colors === null || colors === void 0 ? void 0 : colors.tooltipColor,
572
588
  } }),
573
589
  React.createElement("div", { className: "text-center text-[14px] font-normal", style: { fontWeight: 400 } }, renderStages(serviceItem.dropoff_stages, 2, busStage, hideBoardingTime((serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.api_type) || (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.apiType)))))))))),
package/dist/styles.css CHANGED
@@ -36,6 +36,9 @@
36
36
  .top-\[2px\] {
37
37
  top: 2px;
38
38
  }
39
+ .top-\[5px\] {
40
+ top: 5px;
41
+ }
39
42
  .top-\[15px\] {
40
43
  top: 15px;
41
44
  }
@@ -81,6 +84,9 @@
81
84
  .-left-\[7px\] {
82
85
  left: calc(7px * -1);
83
86
  }
87
+ .-left-\[8px\] {
88
+ left: calc(8px * -1);
89
+ }
84
90
  .left-1\/2 {
85
91
  left: calc(1/2 * 100%);
86
92
  }
@@ -517,6 +523,9 @@
517
523
  .overflow-y-hidden {
518
524
  overflow-y: hidden;
519
525
  }
526
+ .rounded-\[7px\] {
527
+ border-radius: 7px;
528
+ }
520
529
  .rounded-\[8px\] {
521
530
  border-radius: 8px;
522
531
  }
@@ -562,10 +571,18 @@
562
571
  border-top-style: var(--tw-border-style);
563
572
  border-top-width: 8px;
564
573
  }
574
+ .border-t-\[10px\] {
575
+ border-top-style: var(--tw-border-style);
576
+ border-top-width: 10px;
577
+ }
565
578
  .border-r-8 {
566
579
  border-right-style: var(--tw-border-style);
567
580
  border-right-width: 8px;
568
581
  }
582
+ .border-r-\[10px\] {
583
+ border-right-style: var(--tw-border-style);
584
+ border-right-width: 10px;
585
+ }
569
586
  .border-b {
570
587
  border-bottom-style: var(--tw-border-style);
571
588
  border-bottom-width: 1px;
@@ -574,6 +591,10 @@
574
591
  border-bottom-style: var(--tw-border-style);
575
592
  border-bottom-width: 8px;
576
593
  }
594
+ .border-b-\[10px\] {
595
+ border-bottom-style: var(--tw-border-style);
596
+ border-bottom-width: 10px;
597
+ }
577
598
  .border-l-8 {
578
599
  border-left-style: var(--tw-border-style);
579
600
  border-left-width: 8px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "7.0.7",
3
+ "version": "7.0.9",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -76,18 +76,47 @@ class ServiceFilter extends React.Component<
76
76
  }
77
77
 
78
78
  sortFilters(filtersArray: any[]) {
79
+ // Define the desired filter order
80
+ const FILTER_ORDER = [
81
+ "special_departure",
82
+ "time",
83
+ "tipo",
84
+ "seat_types",
85
+ "operator",
86
+ "train_type",
87
+ "amenities",
88
+ ];
89
+
90
+ // Create array with original indices preserved
79
91
  let newArr: any[] = [];
80
- filtersArray.forEach((val) => {
92
+ filtersArray.forEach((val, originalIndex) => {
81
93
  if (val.type === "seat_types") {
82
- let newSeatOrder = val.options.sort(
94
+ // Preserve original option indices before sorting
95
+ let optionsWithOriginalIndex = val.options.map(
96
+ (opt: any, optIndex: number) => ({
97
+ ...opt,
98
+ originalOptionIndex: optIndex,
99
+ })
100
+ );
101
+ let newSeatOrder = [...optionsWithOriginalIndex].sort(
83
102
  (a: any, b: any) =>
84
103
  SEAT_ORDER.indexOf(a.label) - SEAT_ORDER.indexOf(b.label)
85
104
  );
86
- newArr.push({ ...val, options: newSeatOrder });
105
+ newArr.push({ ...val, options: newSeatOrder, originalIndex });
87
106
  } else {
88
- newArr.push(val);
107
+ newArr.push({ ...val, originalIndex });
89
108
  }
90
109
  });
110
+
111
+ newArr.sort((a, b) => {
112
+ const indexA = FILTER_ORDER.indexOf(a.type);
113
+ const indexB = FILTER_ORDER.indexOf(b.type);
114
+ if (indexA !== -1 && indexB !== -1) return indexA - indexB;
115
+ if (indexA !== -1) return -1;
116
+ if (indexB !== -1) return 1;
117
+ return 0;
118
+ });
119
+
91
120
  return newArr;
92
121
  }
93
122
 
@@ -278,7 +307,13 @@ class ServiceFilter extends React.Component<
278
307
  return (
279
308
  <div
280
309
  key={i}
281
- onClick={() => onClick(i)}
310
+ onClick={() =>
311
+ onClick(
312
+ val.originalOptionIndex !== undefined
313
+ ? val.originalOptionIndex
314
+ : i
315
+ )
316
+ }
282
317
  style={{
283
318
  margin: val?.active ? "3px 0" : "0",
284
319
  backgroundColor: val.active
@@ -304,7 +339,7 @@ class ServiceFilter extends React.Component<
304
339
  className="w-[20px] h-[20px] mr-[10px] "
305
340
  />
306
341
  )}
307
- {label.charAt(0).toUpperCase() + label.slice(1).toLowerCase()}
342
+ <span className="capitalize">{label.toLowerCase()}</span>
308
343
  </div>
309
344
  );
310
345
  })}
@@ -337,7 +372,7 @@ class ServiceFilter extends React.Component<
337
372
  val.options?.length
338
373
  ? this.renderFilterItem(
339
374
  val,
340
- (i) => onFilterSelected(key, i),
375
+ (i) => onFilterSelected(val.originalIndex, i),
341
376
  key
342
377
  )
343
378
  : null
@@ -446,15 +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
+
449
457
  // Helper function to truncate seat labels with more than 2 words
450
458
  const truncateSeatLabel = (label: string | number): string => {
451
459
  if (typeof label !== "string") return String(label);
452
460
  // Don't truncate if label contains parentheses (e.g., "Cama (180°)")
453
461
  if (label.includes("(")) return label;
454
462
  const words = label.trim().split(/\s+/);
455
- if (words.length <= 2) return label;
456
- // Take first 2 words + first letter of 3rd word + "..."
457
- 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)}...`;
458
474
  };
459
475
 
460
476
  const getSeatNames = () => {
@@ -907,17 +923,20 @@ function ServiceItemPB({
907
923
  )}
908
924
  {serviceItem.boarding_stages && (
909
925
  <div
910
- className="hidden group-hover:block absolute -top-[8px] left-[100%] ml-[25px] text-white px-3 py-2 rounded-[10px] whitespace-nowrap z-10 shadow-service"
926
+ className="hidden group-hover:block absolute -top-[8px] text-white px-3 py-2 rounded-[7px] whitespace-nowrap z-10 shadow-service"
911
927
  style={{
912
928
  backgroundColor: colors?.tooltipColor,
913
929
  zIndex: 100,
930
+ left: "clamp(80%, 100% - (100vw - 1400px) * 0.05, 100%)",
914
931
  }}
915
932
  >
916
933
  <div
917
- className="tooltip-arrow absolute top-2 -left-[7px] w-0 h-0
918
- border-t-8 border-b-8 border-r-8
919
- border-t-transparent border-b-transparent"
920
- style={{ borderRightColor: colors?.tooltipColor }}
934
+ className="tooltip-arrow absolute top-[5px] -left-[8px] w-0 h-0
935
+ border-t-[10px] border-b-[10px] border-r-[10px]
936
+ border-t-transparent border-b-transparent"
937
+ style={{
938
+ borderRightColor: colors?.tooltipColor,
939
+ }}
921
940
  ></div>
922
941
  <div
923
942
  className="text-center text-[14px] font-normal"
@@ -949,15 +968,16 @@ function ServiceItemPB({
949
968
  {/* Dropping stage tooltip */}
950
969
  {serviceItem.dropoff_stages && (
951
970
  <div
952
- className="hidden group-hover:block absolute -top-[8px] left-[100%] ml-[25px] text-white px-3 py-2 rounded-[10px] whitespace-nowrap z-10 shadow-service"
971
+ className="hidden group-hover:block absolute -top-[8px] text-white px-3 py-2 rounded-[7px] whitespace-nowrap z-10 shadow-service"
953
972
  style={{
954
973
  backgroundColor: colors?.tooltipColor,
955
974
  zIndex: 100,
975
+ left: "clamp(80%, 100% - (100vw - 1400px) * 0.05, 100%)",
956
976
  }}
957
977
  >
958
978
  <div
959
- className="tooltip-arrow absolute top-2 -left-[7px] w-0 h-0
960
- border-t-8 border-b-8 border-r-8
979
+ className="tooltip-arrow absolute top-[5px] -left-[8px] w-0 h-0
980
+ border-t-[10px] border-b-[10px] border-r-[10px]
961
981
  border-t-transparent border-b-transparent"
962
982
  style={{
963
983
  borderRightColor: colors?.tooltipColor,