@idds/react 1.2.1 → 1.2.3
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.cjs.js +2 -2
- package/dist/index.css +1 -1
- package/dist/index.es.js +86 -94
- package/dist/index.umd.js +2 -2
- package/dist/types/components/Tooltip.d.ts +21 -46
- package/dist/types/components/Tooltip.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -5941,77 +5941,49 @@ function Tooltip({
|
|
|
5941
5941
|
image,
|
|
5942
5942
|
content,
|
|
5943
5943
|
children,
|
|
5944
|
-
customContent,
|
|
5945
5944
|
variant = "basic",
|
|
5946
|
-
placement = "
|
|
5945
|
+
placement = "top",
|
|
5947
5946
|
showArrow = true,
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5947
|
+
onClose,
|
|
5948
|
+
onNext,
|
|
5949
|
+
customContent = false,
|
|
5950
|
+
className = ""
|
|
5952
5951
|
}) {
|
|
5953
|
-
const [
|
|
5954
|
-
const
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
const tooltipRef = useRef(null);
|
|
5959
|
-
useEffect(() => {
|
|
5960
|
-
return () => {
|
|
5961
|
-
window.clearTimeout(enterTimeout.current);
|
|
5962
|
-
window.clearTimeout(leaveTimeout.current);
|
|
5963
|
-
};
|
|
5964
|
-
}, []);
|
|
5965
|
-
const show = () => {
|
|
5966
|
-
window.clearTimeout(leaveTimeout.current);
|
|
5967
|
-
enterTimeout.current = window.setTimeout(() => {
|
|
5968
|
-
setVisible(true);
|
|
5969
|
-
requestAnimationFrame(checkAndFlip);
|
|
5970
|
-
}, enterDelay);
|
|
5971
|
-
};
|
|
5972
|
-
const hide = () => {
|
|
5973
|
-
window.clearTimeout(enterTimeout.current);
|
|
5974
|
-
leaveTimeout.current = window.setTimeout(() => {
|
|
5975
|
-
setVisible(false);
|
|
5976
|
-
setFinalPlacement(placement);
|
|
5977
|
-
}, leaveDelay);
|
|
5978
|
-
};
|
|
5979
|
-
function checkAndFlip() {
|
|
5980
|
-
const trg = triggerRef.current;
|
|
5981
|
-
const tip = tooltipRef.current;
|
|
5982
|
-
if (!trg || !tip) return;
|
|
5983
|
-
const tipRect = tip.getBoundingClientRect();
|
|
5984
|
-
let newPlacement = placement;
|
|
5985
|
-
if ((placement === "top" || placement.startsWith("top-")) && tipRect.top < 0) {
|
|
5986
|
-
newPlacement = placement.replace("top", "bottom");
|
|
5987
|
-
}
|
|
5988
|
-
if ((placement === "bottom" || placement.startsWith("bottom-")) && tipRect.bottom > window.innerHeight) {
|
|
5989
|
-
newPlacement = placement.replace("bottom", "top");
|
|
5990
|
-
}
|
|
5991
|
-
if ((placement === "left" || placement.startsWith("left-")) && tipRect.left < 0) {
|
|
5992
|
-
newPlacement = placement.replace("left", "bottom");
|
|
5993
|
-
}
|
|
5994
|
-
if ((placement === "right" || placement.startsWith("right-")) && tipRect.right > window.innerWidth) {
|
|
5995
|
-
newPlacement = placement.replace("right", "top");
|
|
5996
|
-
}
|
|
5997
|
-
if (newPlacement !== finalPlacement) {
|
|
5998
|
-
setFinalPlacement(newPlacement);
|
|
5952
|
+
const [isClosed, setIsClosed] = useState(false);
|
|
5953
|
+
const handleClose = () => {
|
|
5954
|
+
setIsClosed(true);
|
|
5955
|
+
if (onClose) {
|
|
5956
|
+
onClose();
|
|
5999
5957
|
}
|
|
6000
|
-
}
|
|
6001
|
-
const
|
|
6002
|
-
|
|
5958
|
+
};
|
|
5959
|
+
const handleNext = () => {
|
|
5960
|
+
setIsClosed(true);
|
|
5961
|
+
if (onNext) {
|
|
5962
|
+
onNext();
|
|
5963
|
+
}
|
|
5964
|
+
};
|
|
5965
|
+
const handleMouseEnter = () => {
|
|
5966
|
+
if (isClosed) {
|
|
5967
|
+
setIsClosed(false);
|
|
5968
|
+
}
|
|
5969
|
+
};
|
|
5970
|
+
const tooltipClasses = clsx("ina-tooltip", className, {
|
|
5971
|
+
"ina-tooltip--closed": isClosed
|
|
5972
|
+
});
|
|
5973
|
+
const contentClasses = clsx(
|
|
6003
5974
|
"ina-tooltip__content",
|
|
6004
|
-
`ina-tooltip--placement-${
|
|
6005
|
-
`ina-tooltip--variant-${variant}`,
|
|
5975
|
+
`ina-tooltip--placement-${placement}`,
|
|
6006
5976
|
{
|
|
6007
|
-
"ina-tooltip__content--
|
|
6008
|
-
"ina-
|
|
6009
|
-
"ina-
|
|
5977
|
+
"ina-tooltip__content--show-arrow": showArrow,
|
|
5978
|
+
"ina-tooltip--variant-basic": variant === "basic",
|
|
5979
|
+
"ina-tooltip--variant-light": variant === "light",
|
|
5980
|
+
"ina-tooltip--variant-dark": variant === "dark",
|
|
5981
|
+
"ina-tooltip--variant-media": variant === "media"
|
|
6010
5982
|
}
|
|
6011
5983
|
);
|
|
6012
5984
|
const renderContent = () => {
|
|
6013
|
-
if (
|
|
6014
|
-
return
|
|
5985
|
+
if (customContent && content) {
|
|
5986
|
+
return content;
|
|
6015
5987
|
}
|
|
6016
5988
|
if (variant === "basic") {
|
|
6017
5989
|
return /* @__PURE__ */ jsx("div", { className: "ina-tooltip__bubble ina-tooltip__bubble--basic", children: title });
|
|
@@ -6024,49 +5996,69 @@ function Tooltip({
|
|
|
6024
5996
|
className: "ina-tooltip__close",
|
|
6025
5997
|
onClick: (e) => {
|
|
6026
5998
|
e.stopPropagation();
|
|
6027
|
-
|
|
6028
|
-
window.clearTimeout(enterTimeout.current);
|
|
6029
|
-
setVisible(false);
|
|
6030
|
-
setFinalPlacement(placement);
|
|
6031
|
-
onClose();
|
|
5999
|
+
handleClose();
|
|
6032
6000
|
},
|
|
6033
6001
|
"aria-label": "Close tooltip",
|
|
6034
|
-
children: /* @__PURE__ */ jsx(
|
|
6002
|
+
children: /* @__PURE__ */ jsx(
|
|
6003
|
+
"svg",
|
|
6004
|
+
{
|
|
6005
|
+
width: "16",
|
|
6006
|
+
height: "16",
|
|
6007
|
+
viewBox: "0 0 24 24",
|
|
6008
|
+
fill: "none",
|
|
6009
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6010
|
+
children: /* @__PURE__ */ jsx(
|
|
6011
|
+
"path",
|
|
6012
|
+
{
|
|
6013
|
+
d: "M18 6L6 18M6 6L18 18",
|
|
6014
|
+
stroke: "currentColor",
|
|
6015
|
+
strokeWidth: "2",
|
|
6016
|
+
strokeLinecap: "round",
|
|
6017
|
+
strokeLinejoin: "round"
|
|
6018
|
+
}
|
|
6019
|
+
)
|
|
6020
|
+
}
|
|
6021
|
+
)
|
|
6035
6022
|
}
|
|
6036
6023
|
),
|
|
6037
6024
|
variant === "media" && image && /* @__PURE__ */ jsx("div", { className: "ina-tooltip__image", children: typeof image === "string" ? /* @__PURE__ */ jsx("img", { src: image, alt: "" }) : image }),
|
|
6038
6025
|
/* @__PURE__ */ jsxs("div", { className: "ina-tooltip__content-section", children: [
|
|
6039
6026
|
title && /* @__PURE__ */ jsx("div", { className: "ina-tooltip__title", children: title }),
|
|
6040
6027
|
description && /* @__PURE__ */ jsx("div", { className: "ina-tooltip__description", children: description }),
|
|
6041
|
-
content && /* @__PURE__ */ jsx("div", { className: "ina-tooltip__custom-content", children: content })
|
|
6028
|
+
content && /* @__PURE__ */ jsx("div", { className: "ina-tooltip__custom-content", children: content }),
|
|
6029
|
+
(onClose || onNext) && /* @__PURE__ */ jsxs("div", { className: "ina-tooltip__actions", children: [
|
|
6030
|
+
onClose && /* @__PURE__ */ jsx(
|
|
6031
|
+
"button",
|
|
6032
|
+
{
|
|
6033
|
+
type: "button",
|
|
6034
|
+
className: "ina-tooltip__action ina-tooltip__action--close",
|
|
6035
|
+
onClick: (e) => {
|
|
6036
|
+
e.stopPropagation();
|
|
6037
|
+
handleClose();
|
|
6038
|
+
},
|
|
6039
|
+
children: "Tutup"
|
|
6040
|
+
}
|
|
6041
|
+
),
|
|
6042
|
+
onNext && /* @__PURE__ */ jsx(
|
|
6043
|
+
"button",
|
|
6044
|
+
{
|
|
6045
|
+
type: "button",
|
|
6046
|
+
className: "ina-tooltip__action ina-tooltip__action--next",
|
|
6047
|
+
onClick: (e) => {
|
|
6048
|
+
e.stopPropagation();
|
|
6049
|
+
handleNext();
|
|
6050
|
+
},
|
|
6051
|
+
children: "Lanjut"
|
|
6052
|
+
}
|
|
6053
|
+
)
|
|
6054
|
+
] })
|
|
6042
6055
|
] })
|
|
6043
6056
|
] });
|
|
6044
6057
|
};
|
|
6045
|
-
return /* @__PURE__ */ jsxs(
|
|
6046
|
-
|
|
6047
|
-
{
|
|
6048
|
-
|
|
6049
|
-
className: tooltipContainerClasses,
|
|
6050
|
-
"data-hover": visible ? "true" : void 0,
|
|
6051
|
-
onMouseEnter: show,
|
|
6052
|
-
onMouseLeave: hide,
|
|
6053
|
-
onFocus: show,
|
|
6054
|
-
onBlur: hide,
|
|
6055
|
-
children: [
|
|
6056
|
-
children,
|
|
6057
|
-
visible && /* @__PURE__ */ jsx(
|
|
6058
|
-
"div",
|
|
6059
|
-
{
|
|
6060
|
-
ref: tooltipRef,
|
|
6061
|
-
className: tooltipContentClasses,
|
|
6062
|
-
onMouseEnter: show,
|
|
6063
|
-
onMouseLeave: hide,
|
|
6064
|
-
children: renderContent()
|
|
6065
|
-
}
|
|
6066
|
-
)
|
|
6067
|
-
]
|
|
6068
|
-
}
|
|
6069
|
-
);
|
|
6058
|
+
return /* @__PURE__ */ jsxs("div", { className: tooltipClasses, onMouseEnter: handleMouseEnter, children: [
|
|
6059
|
+
children,
|
|
6060
|
+
/* @__PURE__ */ jsx("div", { className: contentClasses, role: "tooltip", children: renderContent() })
|
|
6061
|
+
] });
|
|
6070
6062
|
}
|
|
6071
6063
|
function ThemeToggle({
|
|
6072
6064
|
className = "",
|