next-helios-fe 1.8.79 → 1.8.80
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/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/table/index.tsx +38 -38
- package/src/components/tooltip/index.tsx +221 -17
package/package.json
CHANGED
@@ -258,13 +258,13 @@ export const Table: TableComponentProps = ({
|
|
258
258
|
return (
|
259
259
|
<th
|
260
260
|
key={item.key}
|
261
|
-
className="
|
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
|
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="
|
348
|
+
<div className="pointer-events-none capitalize">
|
349
349
|
<Form.Checkbox
|
350
350
|
options={{ disableHover: true }}
|
351
351
|
label={
|
@@ -374,7 +374,7 @@ export const Table: TableComponentProps = ({
|
|
374
374
|
/>
|
375
375
|
<input
|
376
376
|
type="search"
|
377
|
-
className="w-full
|
377
|
+
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
378
|
placeholder="search.."
|
379
379
|
value={
|
380
380
|
filter?.find((filterItem) => filterItem.key === item.key)
|
@@ -423,7 +423,7 @@ export const Table: TableComponentProps = ({
|
|
423
423
|
return (
|
424
424
|
<tr key={item?.[options?.customDataIdName ?? "id"]}>
|
425
425
|
{checkbox && (
|
426
|
-
<td className="sticky left-0 w-8 px-4 py-1.5
|
426
|
+
<td className="sticky left-0 w-8 bg-secondary-bg px-4 py-1.5">
|
427
427
|
<Form.Checkbox
|
428
428
|
options={{ disableHover: true }}
|
429
429
|
checked={
|
@@ -473,7 +473,7 @@ export const Table: TableComponentProps = ({
|
|
473
473
|
</td>
|
474
474
|
)}
|
475
475
|
{!options?.hideNumberColumn && (
|
476
|
-
<td className="sticky left-0 w-8 px-4 py-1.5
|
476
|
+
<td className="sticky left-0 w-8 bg-secondary-bg px-4 py-1.5 text-center">
|
477
477
|
{(page - 1) * maxRow + index + 1}
|
478
478
|
</td>
|
479
479
|
)}
|
@@ -484,7 +484,7 @@ export const Table: TableComponentProps = ({
|
|
484
484
|
return (
|
485
485
|
<td
|
486
486
|
key={headerItem.key}
|
487
|
-
className="px-4 py-1.5
|
487
|
+
className="whitespace-nowrap bg-secondary-bg px-4 py-1.5 capitalize"
|
488
488
|
>
|
489
489
|
{headerItem.render(item) || "-"}
|
490
490
|
</td>
|
@@ -493,15 +493,15 @@ export const Table: TableComponentProps = ({
|
|
493
493
|
return (
|
494
494
|
<td
|
495
495
|
key={headerItem.key}
|
496
|
-
className="max-w-60 px-4 py-1.5
|
496
|
+
className="max-w-60 bg-secondary-bg px-4 py-1.5"
|
497
497
|
>
|
498
498
|
<Tooltip
|
499
499
|
content={item[headerItem.key as keyof typeof item] || "-"}
|
500
500
|
options={{ position: "top" }}
|
501
501
|
>
|
502
|
-
<
|
502
|
+
<div className="truncate whitespace-nowrap">
|
503
503
|
{item[headerItem.key as keyof typeof item] || "-"}
|
504
|
-
</
|
504
|
+
</div>
|
505
505
|
</Tooltip>
|
506
506
|
</td>
|
507
507
|
);
|
@@ -509,7 +509,7 @@ export const Table: TableComponentProps = ({
|
|
509
509
|
})}
|
510
510
|
{actionColumn &&
|
511
511
|
React.Children.toArray(actionColumn()).length !== 0 && (
|
512
|
-
<td className="sticky right-0 w-8 px-4 py-1.5
|
512
|
+
<td className="sticky right-0 w-8 bg-secondary-bg px-4 py-1.5 text-center">
|
513
513
|
{actionColumn(item)}
|
514
514
|
</td>
|
515
515
|
)}
|
@@ -518,18 +518,18 @@ export const Table: TableComponentProps = ({
|
|
518
518
|
});
|
519
519
|
|
520
520
|
return (
|
521
|
-
<div className="flex flex-col gap-6
|
521
|
+
<div className="flex h-full flex-col gap-6">
|
522
522
|
{(title ||
|
523
523
|
options?.toolbar?.addData?.show !== false ||
|
524
524
|
options?.toolbar?.filter?.show !== false ||
|
525
525
|
options?.toolbar?.search?.show !== false ||
|
526
526
|
options?.toolbar?.export?.show !== false) && (
|
527
527
|
<div
|
528
|
-
className={`flex items-center gap-4
|
528
|
+
className={`flex h-fit w-full items-center gap-4 overflow-auto [&::-webkit-scrollbar]:hidden ${
|
529
529
|
!title ? "justify-end" : "justify-between"
|
530
530
|
}`}
|
531
531
|
>
|
532
|
-
{title && <span className="text-lg
|
532
|
+
{title && <span className="whitespace-nowrap text-lg">{title}</span>}
|
533
533
|
<div className="flex items-center gap-4">
|
534
534
|
{options?.toolbar?.customTool &&
|
535
535
|
options?.toolbar?.customTool?.length !== 0 &&
|
@@ -553,7 +553,7 @@ export const Table: TableComponentProps = ({
|
|
553
553
|
>
|
554
554
|
<button
|
555
555
|
type="button"
|
556
|
-
className={`p-1.5
|
556
|
+
className={`rounded-full p-1.5 text-white ${variant}`}
|
557
557
|
onClick={(e) => {
|
558
558
|
item.onClick && item.onClick(e);
|
559
559
|
}}
|
@@ -564,7 +564,7 @@ export const Table: TableComponentProps = ({
|
|
564
564
|
) : (
|
565
565
|
<button
|
566
566
|
type="button"
|
567
|
-
className={`p-1.5
|
567
|
+
className={`rounded-full p-1.5 text-white ${variant}`}
|
568
568
|
onClick={(e) => {
|
569
569
|
item.onClick && item.onClick(e);
|
570
570
|
}}
|
@@ -580,7 +580,7 @@ export const Table: TableComponentProps = ({
|
|
580
580
|
>
|
581
581
|
<button
|
582
582
|
type="button"
|
583
|
-
className="
|
583
|
+
className="rounded-full bg-primary p-1.5 text-white hover:bg-primary-dark"
|
584
584
|
onClick={(e) => {
|
585
585
|
options?.toolbar?.addData?.onClick &&
|
586
586
|
options?.toolbar?.addData?.onClick(e);
|
@@ -601,7 +601,7 @@ export const Table: TableComponentProps = ({
|
|
601
601
|
>
|
602
602
|
<button
|
603
603
|
type="button"
|
604
|
-
className="px-2 py-2
|
604
|
+
className="rounded-full px-2 py-2 hover:bg-secondary-light"
|
605
605
|
>
|
606
606
|
<Icon icon="mage:filter" className="text-xl" />
|
607
607
|
</button>
|
@@ -682,17 +682,17 @@ export const Table: TableComponentProps = ({
|
|
682
682
|
)}
|
683
683
|
<div
|
684
684
|
className={`flex flex-col overflow-auto ${height} ${
|
685
|
-
options?.border && "
|
685
|
+
options?.border && "rounded-md border"
|
686
686
|
}`}
|
687
687
|
>
|
688
688
|
<table
|
689
|
-
className="w-full divide-y
|
689
|
+
className="w-full divide-y overflow-x-auto text-sm"
|
690
690
|
cellPadding={0}
|
691
691
|
>
|
692
692
|
<thead className="sticky top-0 z-10">
|
693
693
|
<tr>
|
694
694
|
{checkbox && (
|
695
|
-
<th className="sticky left-0 w-8 px-4 py-2
|
695
|
+
<th className="sticky left-0 w-8 bg-secondary-bg px-4 py-2">
|
696
696
|
<div className="flex flex-col">
|
697
697
|
<Form.Checkbox
|
698
698
|
options={{ disableHover: true }}
|
@@ -742,7 +742,7 @@ export const Table: TableComponentProps = ({
|
|
742
742
|
<div className="invisible w-0 overflow-hidden">
|
743
743
|
<input
|
744
744
|
type="search"
|
745
|
-
className="w-full
|
745
|
+
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
746
|
/>
|
747
747
|
</div>
|
748
748
|
)}
|
@@ -750,14 +750,14 @@ export const Table: TableComponentProps = ({
|
|
750
750
|
</th>
|
751
751
|
)}
|
752
752
|
{!options?.hideNumberColumn && (
|
753
|
-
<th className="sticky left-0 z-10 w-8
|
753
|
+
<th className="sticky left-0 z-10 w-8 whitespace-nowrap bg-secondary-bg px-4 py-2 text-center font-medium">
|
754
754
|
<div className="flex flex-col">
|
755
755
|
<span>No.</span>
|
756
756
|
{options?.toolbar?.columnSearch?.show !== false && (
|
757
757
|
<div className="invisible w-0 overflow-hidden">
|
758
758
|
<input
|
759
759
|
type="search"
|
760
|
-
className="w-full
|
760
|
+
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
761
|
/>
|
762
762
|
</div>
|
763
763
|
)}
|
@@ -767,14 +767,14 @@ export const Table: TableComponentProps = ({
|
|
767
767
|
{headerArr}
|
768
768
|
{actionColumn &&
|
769
769
|
React.Children.toArray(actionColumn()).length !== 0 && (
|
770
|
-
<th className="sticky right-0 w-8
|
770
|
+
<th className="sticky right-0 z-10 w-8 whitespace-nowrap bg-secondary-bg px-4 py-2 text-center font-medium">
|
771
771
|
<div className="flex flex-col">
|
772
772
|
<span>Actions</span>
|
773
773
|
{options?.toolbar?.columnSearch?.show !== false && (
|
774
774
|
<div className="invisible w-0 overflow-hidden">
|
775
775
|
<input
|
776
776
|
type="search"
|
777
|
-
className="w-full
|
777
|
+
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
778
|
/>
|
779
779
|
</div>
|
780
780
|
)}
|
@@ -788,11 +788,11 @@ export const Table: TableComponentProps = ({
|
|
788
788
|
</tbody>
|
789
789
|
</table>
|
790
790
|
{(loading || !filteredData || filteredData.length === 0) && (
|
791
|
-
<div className="flex
|
791
|
+
<div className="flex h-full items-center justify-center whitespace-nowrap bg-secondary-bg px-4 py-1.5 text-center">
|
792
792
|
{loading ? (
|
793
793
|
<Icon
|
794
794
|
icon="mingcute:loading-fill"
|
795
|
-
className="text-3xl text-primary
|
795
|
+
className="animate-spin text-3xl text-primary"
|
796
796
|
/>
|
797
797
|
) : (
|
798
798
|
<span>No data found</span>
|
@@ -801,8 +801,8 @@ export const Table: TableComponentProps = ({
|
|
801
801
|
)}
|
802
802
|
</div>
|
803
803
|
{options?.toolbar?.pagination?.show !== false && (
|
804
|
-
<div className="flex
|
805
|
-
<div className="hidden
|
804
|
+
<div className="flex h-fit w-full items-end justify-between gap-2">
|
805
|
+
<div className="hidden !text-sm md:block">
|
806
806
|
<Form.Select
|
807
807
|
options={{
|
808
808
|
width: "fit",
|
@@ -822,7 +822,7 @@ export const Table: TableComponentProps = ({
|
|
822
822
|
}}
|
823
823
|
/>
|
824
824
|
</div>
|
825
|
-
<div className="block
|
825
|
+
<div className="block w-36 !text-sm md:hidden">
|
826
826
|
<Form.Select
|
827
827
|
options={{
|
828
828
|
width: "fit",
|
@@ -842,7 +842,7 @@ export const Table: TableComponentProps = ({
|
|
842
842
|
/>
|
843
843
|
</div>
|
844
844
|
{filteredData && filteredData.length !== 0 && (
|
845
|
-
<span className="hidden
|
845
|
+
<span className="hidden text-sm text-disabled lg:block">{`Showing ${
|
846
846
|
(page - 1) * maxRow + 1
|
847
847
|
} to ${
|
848
848
|
page * maxRow > filteredData?.length
|
@@ -853,7 +853,7 @@ export const Table: TableComponentProps = ({
|
|
853
853
|
<div className="flex items-center gap-2 text-xs">
|
854
854
|
<button
|
855
855
|
type="button"
|
856
|
-
className="flex
|
856
|
+
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
857
|
disabled={page === 1}
|
858
858
|
onClick={() => {
|
859
859
|
setPage(1);
|
@@ -863,7 +863,7 @@ export const Table: TableComponentProps = ({
|
|
863
863
|
</button>
|
864
864
|
<button
|
865
865
|
type="button"
|
866
|
-
className="hidden
|
866
|
+
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
867
|
disabled={page === 1}
|
868
868
|
onClick={() => {
|
869
869
|
setPage((prev) => prev - 1);
|
@@ -873,7 +873,7 @@ export const Table: TableComponentProps = ({
|
|
873
873
|
</button>
|
874
874
|
<div
|
875
875
|
ref={paginationRef}
|
876
|
-
className="flex
|
876
|
+
className="flex max-w-20 gap-2 overflow-auto xl:max-w-[124px] [&::-webkit-scrollbar]:hidden"
|
877
877
|
>
|
878
878
|
{Array.from({
|
879
879
|
length: Math.ceil(filteredData?.length / maxRow),
|
@@ -883,7 +883,7 @@ export const Table: TableComponentProps = ({
|
|
883
883
|
key={index}
|
884
884
|
id={`pagination-page-${index}`}
|
885
885
|
type="button"
|
886
|
-
className="flex
|
886
|
+
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
887
|
disabled={page === index + 1}
|
888
888
|
onClick={() => {
|
889
889
|
setPage(index + 1);
|
@@ -896,7 +896,7 @@ export const Table: TableComponentProps = ({
|
|
896
896
|
</div>
|
897
897
|
<button
|
898
898
|
type="button"
|
899
|
-
className="hidden
|
899
|
+
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
900
|
disabled={filteredData?.length <= page * maxRow}
|
901
901
|
onClick={() => {
|
902
902
|
setPage((prev) => prev + 1);
|
@@ -906,7 +906,7 @@ export const Table: TableComponentProps = ({
|
|
906
906
|
</button>
|
907
907
|
<button
|
908
908
|
type="button"
|
909
|
-
className="flex
|
909
|
+
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
910
|
disabled={filteredData?.length <= page * maxRow}
|
911
911
|
onClick={() => {
|
912
912
|
setPage(Math.ceil(filteredData?.length / maxRow));
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
|
-
import React from "react";
|
3
|
-
import {
|
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
|
-
<
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
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
|
};
|