next-helios-fe 1.8.79 → 1.8.81

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-helios-fe",
3
- "version": "1.8.79",
3
+ "version": "1.8.81",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -258,13 +258,13 @@ export const Table: TableComponentProps = ({
258
258
  return (
259
259
  <th
260
260
  key={item.key}
261
- className="px-4 py-2 bg-secondary-bg font-medium text-left whitespace-nowrap"
261
+ className="whitespace-nowrap bg-secondary-bg px-4 py-2 text-left font-medium"
262
262
  >
263
263
  <div className="flex flex-col">
264
264
  <div className="flex items-center gap-2">
265
265
  <button
266
266
  type="button"
267
- className="group/header flex justify-between items-center gap-4 w-full"
267
+ className="group/header flex w-full items-center justify-between gap-4"
268
268
  onClick={() => {
269
269
  setSortBy((prev: any) => {
270
270
  if (prev.column !== item.key) {
@@ -345,7 +345,7 @@ export const Table: TableComponentProps = ({
345
345
  }
346
346
  }}
347
347
  >
348
- <div className="capitalize pointer-events-none">
348
+ <div className="pointer-events-none capitalize">
349
349
  <Form.Checkbox
350
350
  options={{ disableHover: true }}
351
351
  label={
@@ -355,7 +355,9 @@ export const Table: TableComponentProps = ({
355
355
  ? "null"
356
356
  : value?.toString()
357
357
  }
358
- checked={categoryFilter.includes(value)}
358
+ checked={
359
+ categoryFilter.includes(value) ?? false
360
+ }
359
361
  readOnly
360
362
  />
361
363
  </div>
@@ -374,11 +376,11 @@ export const Table: TableComponentProps = ({
374
376
  />
375
377
  <input
376
378
  type="search"
377
- className="w-full px-6 pt-0 pb-0.5 border-default border-t-0 border-b border-x-0 bg-secondary-bg text-sm font-normal placeholder:duration-300 placeholder:translate-x-0 [&::-webkit-search-cancel-button]:appearance-none focus:placeholder:translate-x-1 placeholder:text-silent focus:outline-none focus:ring-0 focus:border-primary-dark disabled:bg-secondary-light disabled:text-disabled"
379
+ className="w-full border-x-0 border-b border-t-0 border-default bg-secondary-bg px-6 pb-0.5 pt-0 text-sm font-normal placeholder:translate-x-0 placeholder:text-silent placeholder:duration-300 focus:border-primary-dark focus:outline-none focus:ring-0 focus:placeholder:translate-x-1 disabled:bg-secondary-light disabled:text-disabled [&::-webkit-search-cancel-button]:appearance-none"
378
380
  placeholder="search.."
379
381
  value={
380
382
  filter?.find((filterItem) => filterItem.key === item.key)
381
- ?.value
383
+ ?.value || ""
382
384
  }
383
385
  onChange={(e) => {
384
386
  setFilter(
@@ -423,7 +425,7 @@ export const Table: TableComponentProps = ({
423
425
  return (
424
426
  <tr key={item?.[options?.customDataIdName ?? "id"]}>
425
427
  {checkbox && (
426
- <td className="sticky left-0 w-8 px-4 py-1.5 bg-secondary-bg">
428
+ <td className="sticky left-0 w-8 bg-secondary-bg px-4 py-1.5">
427
429
  <Form.Checkbox
428
430
  options={{ disableHover: true }}
429
431
  checked={
@@ -473,7 +475,7 @@ export const Table: TableComponentProps = ({
473
475
  </td>
474
476
  )}
475
477
  {!options?.hideNumberColumn && (
476
- <td className="sticky left-0 w-8 px-4 py-1.5 bg-secondary-bg text-center">
478
+ <td className="sticky left-0 w-8 bg-secondary-bg px-4 py-1.5 text-center">
477
479
  {(page - 1) * maxRow + index + 1}
478
480
  </td>
479
481
  )}
@@ -484,7 +486,7 @@ export const Table: TableComponentProps = ({
484
486
  return (
485
487
  <td
486
488
  key={headerItem.key}
487
- className="px-4 py-1.5 bg-secondary-bg capitalize whitespace-nowrap"
489
+ className="whitespace-nowrap bg-secondary-bg px-4 py-1.5 capitalize"
488
490
  >
489
491
  {headerItem.render(item) || "-"}
490
492
  </td>
@@ -493,15 +495,15 @@ export const Table: TableComponentProps = ({
493
495
  return (
494
496
  <td
495
497
  key={headerItem.key}
496
- className="max-w-60 px-4 py-1.5 bg-secondary-bg truncate whitespace-nowrap"
498
+ className="max-w-60 bg-secondary-bg px-4 py-1.5"
497
499
  >
498
500
  <Tooltip
499
501
  content={item[headerItem.key as keyof typeof item] || "-"}
500
502
  options={{ position: "top" }}
501
503
  >
502
- <span>
504
+ <div className="truncate whitespace-nowrap">
503
505
  {item[headerItem.key as keyof typeof item] || "-"}
504
- </span>
506
+ </div>
505
507
  </Tooltip>
506
508
  </td>
507
509
  );
@@ -509,7 +511,7 @@ export const Table: TableComponentProps = ({
509
511
  })}
510
512
  {actionColumn &&
511
513
  React.Children.toArray(actionColumn()).length !== 0 && (
512
- <td className="sticky right-0 w-8 px-4 py-1.5 bg-secondary-bg text-center">
514
+ <td className="sticky right-0 w-8 bg-secondary-bg px-4 py-1.5 text-center">
513
515
  {actionColumn(item)}
514
516
  </td>
515
517
  )}
@@ -518,18 +520,18 @@ export const Table: TableComponentProps = ({
518
520
  });
519
521
 
520
522
  return (
521
- <div className="flex flex-col gap-6 h-full">
523
+ <div className="flex h-full flex-col gap-6">
522
524
  {(title ||
523
525
  options?.toolbar?.addData?.show !== false ||
524
526
  options?.toolbar?.filter?.show !== false ||
525
527
  options?.toolbar?.search?.show !== false ||
526
528
  options?.toolbar?.export?.show !== false) && (
527
529
  <div
528
- className={`flex items-center gap-4 w-full h-fit overflow-auto [&::-webkit-scrollbar]:hidden ${
530
+ className={`flex h-fit w-full items-center gap-4 overflow-auto [&::-webkit-scrollbar]:hidden ${
529
531
  !title ? "justify-end" : "justify-between"
530
532
  }`}
531
533
  >
532
- {title && <span className="text-lg whitespace-nowrap">{title}</span>}
534
+ {title && <span className="whitespace-nowrap text-lg">{title}</span>}
533
535
  <div className="flex items-center gap-4">
534
536
  {options?.toolbar?.customTool &&
535
537
  options?.toolbar?.customTool?.length !== 0 &&
@@ -553,7 +555,7 @@ export const Table: TableComponentProps = ({
553
555
  >
554
556
  <button
555
557
  type="button"
556
- className={`p-1.5 rounded-full text-white ${variant}`}
558
+ className={`rounded-full p-1.5 text-white ${variant}`}
557
559
  onClick={(e) => {
558
560
  item.onClick && item.onClick(e);
559
561
  }}
@@ -564,7 +566,7 @@ export const Table: TableComponentProps = ({
564
566
  ) : (
565
567
  <button
566
568
  type="button"
567
- className={`p-1.5 rounded-full text-white ${variant}`}
569
+ className={`rounded-full p-1.5 text-white ${variant}`}
568
570
  onClick={(e) => {
569
571
  item.onClick && item.onClick(e);
570
572
  }}
@@ -580,7 +582,7 @@ export const Table: TableComponentProps = ({
580
582
  >
581
583
  <button
582
584
  type="button"
583
- className="p-1.5 rounded-full bg-primary text-white hover:bg-primary-dark"
585
+ className="rounded-full bg-primary p-1.5 text-white hover:bg-primary-dark"
584
586
  onClick={(e) => {
585
587
  options?.toolbar?.addData?.onClick &&
586
588
  options?.toolbar?.addData?.onClick(e);
@@ -601,7 +603,7 @@ export const Table: TableComponentProps = ({
601
603
  >
602
604
  <button
603
605
  type="button"
604
- className="px-2 py-2 rounded-full hover:bg-secondary-light"
606
+ className="rounded-full px-2 py-2 hover:bg-secondary-light"
605
607
  >
606
608
  <Icon icon="mage:filter" className="text-xl" />
607
609
  </button>
@@ -626,7 +628,9 @@ export const Table: TableComponentProps = ({
626
628
  <Form.Checkbox
627
629
  options={{ disableHover: true }}
628
630
  label={item.title}
629
- checked={!excludedColumn?.includes(item.key)}
631
+ checked={
632
+ !excludedColumn?.includes(item.key) ? true : false
633
+ }
630
634
  readOnly
631
635
  />
632
636
  </div>
@@ -682,17 +686,17 @@ export const Table: TableComponentProps = ({
682
686
  )}
683
687
  <div
684
688
  className={`flex flex-col overflow-auto ${height} ${
685
- options?.border && "border rounded-md"
689
+ options?.border && "rounded-md border"
686
690
  }`}
687
691
  >
688
692
  <table
689
- className="w-full divide-y text-sm overflow-x-auto"
693
+ className="w-full divide-y overflow-x-auto text-sm"
690
694
  cellPadding={0}
691
695
  >
692
696
  <thead className="sticky top-0 z-10">
693
697
  <tr>
694
698
  {checkbox && (
695
- <th className="sticky left-0 w-8 px-4 py-2 bg-secondary-bg">
699
+ <th className="sticky left-0 w-8 bg-secondary-bg px-4 py-2">
696
700
  <div className="flex flex-col">
697
701
  <Form.Checkbox
698
702
  options={{ disableHover: true }}
@@ -703,6 +707,8 @@ export const Table: TableComponentProps = ({
703
707
  return selectedItem.id === item.id;
704
708
  });
705
709
  })?.length === filteredData?.length
710
+ ? true
711
+ : false
706
712
  }
707
713
  onChange={(e) => {
708
714
  if (
@@ -742,7 +748,7 @@ export const Table: TableComponentProps = ({
742
748
  <div className="invisible w-0 overflow-hidden">
743
749
  <input
744
750
  type="search"
745
- className="w-full px-0 pt-0 pb-0.5 border-default border-t-0 border-b border-x-0 bg-secondary-bg text-sm font-normal placeholder:duration-300 placeholder:translate-x-0 [&::-webkit-search-cancel-button]:appearance-none focus:placeholder:translate-x-1 placeholder:text-silent focus:outline-none focus:ring-0 focus:border-primary-dark disabled:bg-secondary-light disabled:text-disabled"
751
+ className="w-full border-x-0 border-b border-t-0 border-default bg-secondary-bg px-0 pb-0.5 pt-0 text-sm font-normal placeholder:translate-x-0 placeholder:text-silent placeholder:duration-300 focus:border-primary-dark focus:outline-none focus:ring-0 focus:placeholder:translate-x-1 disabled:bg-secondary-light disabled:text-disabled [&::-webkit-search-cancel-button]:appearance-none"
746
752
  />
747
753
  </div>
748
754
  )}
@@ -750,14 +756,14 @@ export const Table: TableComponentProps = ({
750
756
  </th>
751
757
  )}
752
758
  {!options?.hideNumberColumn && (
753
- <th className="sticky left-0 z-10 w-8 px-4 py-2 bg-secondary-bg font-medium text-center whitespace-nowrap">
759
+ <th className="sticky left-0 z-10 w-8 whitespace-nowrap bg-secondary-bg px-4 py-2 text-center font-medium">
754
760
  <div className="flex flex-col">
755
761
  <span>No.</span>
756
762
  {options?.toolbar?.columnSearch?.show !== false && (
757
763
  <div className="invisible w-0 overflow-hidden">
758
764
  <input
759
765
  type="search"
760
- className="w-full px-0 pt-0 pb-0.5 border-default border-t-0 border-b border-x-0 bg-secondary-bg text-sm font-normal placeholder:duration-300 placeholder:translate-x-0 [&::-webkit-search-cancel-button]:appearance-none focus:placeholder:translate-x-1 placeholder:text-silent focus:outline-none focus:ring-0 focus:border-primary-dark disabled:bg-secondary-light disabled:text-disabled"
766
+ className="w-full border-x-0 border-b border-t-0 border-default bg-secondary-bg px-0 pb-0.5 pt-0 text-sm font-normal placeholder:translate-x-0 placeholder:text-silent placeholder:duration-300 focus:border-primary-dark focus:outline-none focus:ring-0 focus:placeholder:translate-x-1 disabled:bg-secondary-light disabled:text-disabled [&::-webkit-search-cancel-button]:appearance-none"
761
767
  />
762
768
  </div>
763
769
  )}
@@ -767,14 +773,14 @@ export const Table: TableComponentProps = ({
767
773
  {headerArr}
768
774
  {actionColumn &&
769
775
  React.Children.toArray(actionColumn()).length !== 0 && (
770
- <th className="sticky right-0 w-8 px-4 py-2 z-10 bg-secondary-bg font-medium text-center whitespace-nowrap">
776
+ <th className="sticky right-0 z-10 w-8 whitespace-nowrap bg-secondary-bg px-4 py-2 text-center font-medium">
771
777
  <div className="flex flex-col">
772
778
  <span>Actions</span>
773
779
  {options?.toolbar?.columnSearch?.show !== false && (
774
780
  <div className="invisible w-0 overflow-hidden">
775
781
  <input
776
782
  type="search"
777
- className="w-full px-0 pt-0 pb-0.5 border-default border-t-0 border-b border-x-0 bg-secondary-bg text-sm font-normal placeholder:duration-300 placeholder:translate-x-0 [&::-webkit-search-cancel-button]:appearance-none focus:placeholder:translate-x-1 placeholder:text-silent focus:outline-none focus:ring-0 focus:border-primary-dark disabled:bg-secondary-light disabled:text-disabled"
783
+ className="w-full border-x-0 border-b border-t-0 border-default bg-secondary-bg px-0 pb-0.5 pt-0 text-sm font-normal placeholder:translate-x-0 placeholder:text-silent placeholder:duration-300 focus:border-primary-dark focus:outline-none focus:ring-0 focus:placeholder:translate-x-1 disabled:bg-secondary-light disabled:text-disabled [&::-webkit-search-cancel-button]:appearance-none"
778
784
  />
779
785
  </div>
780
786
  )}
@@ -788,11 +794,11 @@ export const Table: TableComponentProps = ({
788
794
  </tbody>
789
795
  </table>
790
796
  {(loading || !filteredData || filteredData.length === 0) && (
791
- <div className="flex justify-center items-center px-4 py-1.5 h-full bg-secondary-bg text-center whitespace-nowrap">
797
+ <div className="flex h-full items-center justify-center whitespace-nowrap bg-secondary-bg px-4 py-1.5 text-center">
792
798
  {loading ? (
793
799
  <Icon
794
800
  icon="mingcute:loading-fill"
795
- className="text-3xl text-primary animate-spin"
801
+ className="animate-spin text-3xl text-primary"
796
802
  />
797
803
  ) : (
798
804
  <span>No data found</span>
@@ -801,8 +807,8 @@ export const Table: TableComponentProps = ({
801
807
  )}
802
808
  </div>
803
809
  {options?.toolbar?.pagination?.show !== false && (
804
- <div className="flex justify-between items-end gap-2 w-full h-fit">
805
- <div className="hidden md:block !text-sm">
810
+ <div className="flex h-fit w-full items-end justify-between gap-2">
811
+ <div className="hidden !text-sm md:block">
806
812
  <Form.Select
807
813
  options={{
808
814
  width: "fit",
@@ -822,7 +828,7 @@ export const Table: TableComponentProps = ({
822
828
  }}
823
829
  />
824
830
  </div>
825
- <div className="block md:hidden w-36 !text-sm">
831
+ <div className="block w-36 !text-sm md:hidden">
826
832
  <Form.Select
827
833
  options={{
828
834
  width: "fit",
@@ -842,7 +848,7 @@ export const Table: TableComponentProps = ({
842
848
  />
843
849
  </div>
844
850
  {filteredData && filteredData.length !== 0 && (
845
- <span className="hidden lg:block text-sm text-disabled">{`Showing ${
851
+ <span className="hidden text-sm text-disabled lg:block">{`Showing ${
846
852
  (page - 1) * maxRow + 1
847
853
  } to ${
848
854
  page * maxRow > filteredData?.length
@@ -853,7 +859,7 @@ export const Table: TableComponentProps = ({
853
859
  <div className="flex items-center gap-2 text-xs">
854
860
  <button
855
861
  type="button"
856
- className="flex justify-center items-center min-w-9 h-9 border rounded-md bg-secondary-bg hover:bg-secondary-light disabled:bg-secondary-light disabled:text-disabled disabled:pointer-events-none"
862
+ className="flex h-9 min-w-9 items-center justify-center rounded-md border bg-secondary-bg hover:bg-secondary-light disabled:pointer-events-none disabled:bg-secondary-light disabled:text-disabled"
857
863
  disabled={page === 1}
858
864
  onClick={() => {
859
865
  setPage(1);
@@ -863,7 +869,7 @@ export const Table: TableComponentProps = ({
863
869
  </button>
864
870
  <button
865
871
  type="button"
866
- className="hidden md:flex justify-center items-center min-w-9 h-9 border rounded-md bg-secondary-bg hover:bg-secondary-light disabled:bg-secondary-light disabled:text-disabled disabled:pointer-events-none"
872
+ className="hidden h-9 min-w-9 items-center justify-center rounded-md border bg-secondary-bg hover:bg-secondary-light disabled:pointer-events-none disabled:bg-secondary-light disabled:text-disabled md:flex"
867
873
  disabled={page === 1}
868
874
  onClick={() => {
869
875
  setPage((prev) => prev - 1);
@@ -873,7 +879,7 @@ export const Table: TableComponentProps = ({
873
879
  </button>
874
880
  <div
875
881
  ref={paginationRef}
876
- className="flex gap-2 max-w-20 xl:max-w-[124px] overflow-auto [&::-webkit-scrollbar]:hidden"
882
+ className="flex max-w-20 gap-2 overflow-auto xl:max-w-[124px] [&::-webkit-scrollbar]:hidden"
877
883
  >
878
884
  {Array.from({
879
885
  length: Math.ceil(filteredData?.length / maxRow),
@@ -883,7 +889,7 @@ export const Table: TableComponentProps = ({
883
889
  key={index}
884
890
  id={`pagination-page-${index}`}
885
891
  type="button"
886
- className="flex justify-center items-center min-w-9 h-9 border rounded-md select-none hover:bg-secondary-light disabled:bg-primary-transparent disabled:text-primary"
892
+ className="flex h-9 min-w-9 select-none items-center justify-center rounded-md border hover:bg-secondary-light disabled:bg-primary-transparent disabled:text-primary"
887
893
  disabled={page === index + 1}
888
894
  onClick={() => {
889
895
  setPage(index + 1);
@@ -896,7 +902,7 @@ export const Table: TableComponentProps = ({
896
902
  </div>
897
903
  <button
898
904
  type="button"
899
- className="hidden md:flex justify-center items-center min-w-9 h-9 border rounded-md bg-secondary-bg hover:bg-secondary-light disabled:bg-secondary-light disabled:text-disabled disabled:pointer-events-none"
905
+ className="hidden h-9 min-w-9 items-center justify-center rounded-md border bg-secondary-bg hover:bg-secondary-light disabled:pointer-events-none disabled:bg-secondary-light disabled:text-disabled md:flex"
900
906
  disabled={filteredData?.length <= page * maxRow}
901
907
  onClick={() => {
902
908
  setPage((prev) => prev + 1);
@@ -906,7 +912,7 @@ export const Table: TableComponentProps = ({
906
912
  </button>
907
913
  <button
908
914
  type="button"
909
- className="flex justify-center items-center min-w-9 h-9 border rounded-md bg-secondary-bg hover:bg-secondary-light disabled:bg-secondary-light disabled:text-disabled disabled:pointer-events-none"
915
+ className="flex h-9 min-w-9 items-center justify-center rounded-md border bg-secondary-bg hover:bg-secondary-light disabled:pointer-events-none disabled:bg-secondary-light disabled:text-disabled"
910
916
  disabled={filteredData?.length <= page * maxRow}
911
917
  onClick={() => {
912
918
  setPage(Math.ceil(filteredData?.length / maxRow));
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import React from "react";
3
- import { Tooltip as Tp } from "flowbite-react";
2
+ import React, { useState, useRef, useEffect } from "react";
3
+ import { createPortal } from "react-dom";
4
4
 
5
5
  interface TooltipProps {
6
6
  children: React.ReactNode;
@@ -16,23 +16,227 @@ export const Tooltip: React.FC<TooltipProps> = ({
16
16
  content,
17
17
  options,
18
18
  }) => {
19
+ const [isRendered, setIsRendered] = useState(false);
20
+ const [visible, setVisible] = useState(false);
21
+ const [position, setPosition] = useState<"left" | "right" | "top" | "bottom">(
22
+ options?.position || "right"
23
+ );
24
+ const tooltipRef = useRef<HTMLDivElement | null>(null);
25
+ const wrapperRef = useRef<HTMLDivElement | null>(null);
26
+ const [wrapperComponent, setWrapperComponent] = useState<DOMRect | null>(
27
+ null
28
+ );
29
+ const [tooltipComponent, setTooltipComponent] = useState<DOMRect | null>(
30
+ null
31
+ );
32
+
33
+ useEffect(() => {
34
+ setIsRendered(true);
35
+
36
+ document.addEventListener("mousemove", (e) => {
37
+ if (tooltipRef.current && wrapperRef.current) {
38
+ if (
39
+ !tooltipRef.current.contains(e.target as Node) &&
40
+ !wrapperRef.current.contains(e.target as Node)
41
+ ) {
42
+ setVisible(false);
43
+ }
44
+ }
45
+ });
46
+ }, []);
47
+
48
+ useEffect(() => {
49
+ const handlePosition = () => {
50
+ if (wrapperRef.current && tooltipRef.current) {
51
+ const tooltipRect = tooltipRef.current.getBoundingClientRect();
52
+
53
+ if (tooltipRect.right + 40 > window.innerWidth) {
54
+ setPosition("left");
55
+ } else if (tooltipRect.left + 40 < 0) {
56
+ setPosition("right");
57
+ } else if (tooltipRect.bottom > window.innerHeight) {
58
+ setPosition("top");
59
+ } else if (tooltipRect.top < 0) {
60
+ setPosition("bottom");
61
+ }
62
+ }
63
+ };
64
+
65
+ if (visible) {
66
+ handlePosition();
67
+ window.addEventListener("resize", handlePosition);
68
+ }
69
+
70
+ return () => {
71
+ window.removeEventListener("resize", handlePosition);
72
+ };
73
+ }, [visible, content]);
74
+
75
+ useEffect(() => {
76
+ let animationFrameId: number;
77
+
78
+ const updatePosition = () => {
79
+ if (!wrapperRef.current || !tooltipRef.current) return;
80
+
81
+ setWrapperComponent(wrapperRef.current.getBoundingClientRect());
82
+ setTooltipComponent(tooltipRef.current.getBoundingClientRect());
83
+
84
+ animationFrameId = requestAnimationFrame(updatePosition);
85
+ };
86
+
87
+ animationFrameId = requestAnimationFrame(updatePosition);
88
+
89
+ return () => {
90
+ cancelAnimationFrame(animationFrameId);
91
+ };
92
+ }, [visible]);
93
+
94
+ const getTooltipPosition = () => {
95
+ if (wrapperComponent && tooltipComponent) {
96
+ switch (position) {
97
+ case "left":
98
+ return {
99
+ top:
100
+ wrapperComponent.top +
101
+ wrapperComponent.height / 2 -
102
+ tooltipComponent.height / 2,
103
+ left: wrapperComponent.left - tooltipComponent.width,
104
+ };
105
+ case "right":
106
+ return {
107
+ top:
108
+ wrapperComponent.top +
109
+ wrapperComponent.height / 2 -
110
+ tooltipComponent.height / 2,
111
+ left: wrapperComponent.right,
112
+ };
113
+ case "top":
114
+ return {
115
+ top: wrapperComponent.top - tooltipComponent.height,
116
+ left:
117
+ wrapperComponent.left +
118
+ wrapperComponent.width / 2 -
119
+ tooltipComponent.width / 2,
120
+ };
121
+ case "bottom":
122
+ return {
123
+ top: wrapperComponent.bottom,
124
+ left:
125
+ wrapperComponent.left +
126
+ wrapperComponent.width / 2 -
127
+ tooltipComponent.width / 2,
128
+ };
129
+ default:
130
+ return {
131
+ top:
132
+ wrapperComponent.top +
133
+ wrapperComponent.height / 2 -
134
+ tooltipComponent.height / 2,
135
+ left: wrapperComponent.right,
136
+ };
137
+ }
138
+ }
139
+ };
140
+
141
+ const getTooltipArrowPosition = () => {
142
+ if (wrapperComponent && tooltipComponent) {
143
+ switch (position) {
144
+ case "left":
145
+ return {
146
+ width: "0px",
147
+ height: "0px",
148
+ borderStyle: "solid",
149
+ borderWidth: "6px",
150
+ borderColor: "transparent transparent transparent black",
151
+ opacity: "0.80",
152
+ };
153
+ case "right":
154
+ return {
155
+ width: "0px",
156
+ height: "0px",
157
+ borderStyle: "solid",
158
+ borderWidth: "6px",
159
+ borderColor: "transparent black transparent transparent",
160
+ opacity: "0.80",
161
+ };
162
+ case "top":
163
+ return {
164
+ width: "0px",
165
+ height: "0px",
166
+ borderStyle: "solid",
167
+ borderWidth: "6px",
168
+ borderColor: "black transparent transparent transparent",
169
+ opacity: "0.80",
170
+ };
171
+ case "bottom":
172
+ return {
173
+ width: "0px",
174
+ height: "0px",
175
+ borderStyle: "solid",
176
+ borderWidth: "6px",
177
+ borderColor: "transparent transparent black transparent",
178
+ opacity: "0.80",
179
+ };
180
+ default:
181
+ return {
182
+ width: "0px",
183
+ height: "0px",
184
+ borderStyle: "solid",
185
+ borderWidth: "6px",
186
+ borderColor: "transparent black transparent transparent",
187
+ opacity: "0.80",
188
+ };
189
+ }
190
+ }
191
+ };
192
+
19
193
  return (
20
- <Tp
21
- content={content}
22
- className={`z-50 max-w-[75dvw] md:max-w-96 px-3 py-1.5 rounded-md bg-black/85 text-sm text-wrap font-normal ${
23
- !options?.enableHover && "pointer-events-none"
24
- }`}
25
- style="dark"
26
- placement={options?.position || "right"}
27
- theme={{
28
- arrow: {
29
- base: "absolute z-10 h-2 w-2 rotate-45",
30
- style: { dark: "bg-black/85" },
31
- },
32
- }}
33
- animation="duration-200"
194
+ <div
195
+ ref={wrapperRef}
196
+ onMouseEnter={() => setVisible(true)}
197
+ onMouseLeave={() => setVisible(false)}
34
198
  >
35
199
  {children}
36
- </Tp>
200
+ {isRendered &&
201
+ position &&
202
+ createPortal(
203
+ <div
204
+ ref={tooltipRef}
205
+ className={`absolute z-50 max-w-dvw max-h-dvh overflow-hidden duration-200 transition-opacity ${
206
+ visible ? "opacity-100" : "opacity-0 pointer-events-none"
207
+ } ${options?.enableHover ? "" : "pointer-events-none"}`}
208
+ style={getTooltipPosition()}
209
+ >
210
+ {position === "bottom" && (
211
+ <div className="flex justify-center">
212
+ <div style={getTooltipArrowPosition()}></div>
213
+ </div>
214
+ )}
215
+ <div className="flex items-center">
216
+ {position === "right" && (
217
+ <div className="flex justify-center">
218
+ <div style={getTooltipArrowPosition()}></div>
219
+ </div>
220
+ )}
221
+ <div className="px-3 py-1.5 rounded-md bg-black/80">
222
+ <div className="max-w-[75dvw] md:max-w-96 max-h-[50dvh] text-sm text-white overflow-hidden">
223
+ {content}
224
+ </div>
225
+ </div>
226
+ {position === "left" && (
227
+ <div className="flex justify-center">
228
+ <div style={getTooltipArrowPosition()}></div>
229
+ </div>
230
+ )}
231
+ </div>
232
+ {position === "top" && (
233
+ <div className="flex justify-center">
234
+ <div style={getTooltipArrowPosition()}></div>
235
+ </div>
236
+ )}
237
+ </div>,
238
+ document.body
239
+ )}
240
+ </div>
37
241
  );
38
242
  };