@norges-domstoler/dds-components 0.0.0-dev-20250703081704 → 0.0.0-dev-20250715084850
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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +23 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -4033,9 +4033,11 @@ type TooltipProps = BaseComponentProps<HTMLDivElement, {
|
|
|
4033
4033
|
delay?: number;
|
|
4034
4034
|
/**`id` for tooltip. */
|
|
4035
4035
|
tooltipId?: string;
|
|
4036
|
+
/**Om tooltip skal alltid være i DOM, eller bli rendret først når den skal vises. */
|
|
4037
|
+
keepMounted?: boolean;
|
|
4036
4038
|
} & PickedHTMLAttributes, Omit<HTMLAttributes<HTMLDivElement>, 'children' | keyof PickedHTMLAttributes>>;
|
|
4037
4039
|
declare const Tooltip: {
|
|
4038
|
-
({ text, placement, children, tooltipId, delay, style, onMouseLeave, onMouseOver, id, ref, className, htmlProps, ...rest }: TooltipProps): react_jsx_runtime.JSX.Element;
|
|
4040
|
+
({ text, placement, children, tooltipId, delay, style, onMouseLeave, onMouseOver, keepMounted, id, ref, className, htmlProps, ...rest }: TooltipProps): react_jsx_runtime.JSX.Element;
|
|
4039
4041
|
displayName: string;
|
|
4040
4042
|
};
|
|
4041
4043
|
|
package/dist/index.d.ts
CHANGED
|
@@ -4033,9 +4033,11 @@ type TooltipProps = BaseComponentProps<HTMLDivElement, {
|
|
|
4033
4033
|
delay?: number;
|
|
4034
4034
|
/**`id` for tooltip. */
|
|
4035
4035
|
tooltipId?: string;
|
|
4036
|
+
/**Om tooltip skal alltid være i DOM, eller bli rendret først når den skal vises. */
|
|
4037
|
+
keepMounted?: boolean;
|
|
4036
4038
|
} & PickedHTMLAttributes, Omit<HTMLAttributes<HTMLDivElement>, 'children' | keyof PickedHTMLAttributes>>;
|
|
4037
4039
|
declare const Tooltip: {
|
|
4038
|
-
({ text, placement, children, tooltipId, delay, style, onMouseLeave, onMouseOver, id, ref, className, htmlProps, ...rest }: TooltipProps): react_jsx_runtime.JSX.Element;
|
|
4040
|
+
({ text, placement, children, tooltipId, delay, style, onMouseLeave, onMouseOver, keepMounted, id, ref, className, htmlProps, ...rest }: TooltipProps): react_jsx_runtime.JSX.Element;
|
|
4039
4041
|
displayName: string;
|
|
4040
4042
|
};
|
|
4041
4043
|
|
package/dist/index.js
CHANGED
|
@@ -7775,6 +7775,7 @@ var Tooltip = ({
|
|
|
7775
7775
|
style,
|
|
7776
7776
|
onMouseLeave,
|
|
7777
7777
|
onMouseOver,
|
|
7778
|
+
keepMounted = true,
|
|
7778
7779
|
id,
|
|
7779
7780
|
ref,
|
|
7780
7781
|
className,
|
|
@@ -7784,7 +7785,7 @@ var Tooltip = ({
|
|
|
7784
7785
|
const generatedId = (0, import_react56.useId)();
|
|
7785
7786
|
const uniqueTooltipId = tooltipId != null ? tooltipId : `${generatedId}-tooltip`;
|
|
7786
7787
|
const [open, setOpen] = (0, import_react56.useState)(false);
|
|
7787
|
-
const [inView, setInView] = (0, import_react56.useState)(false);
|
|
7788
|
+
const [inView, setInView] = (0, import_react56.useState)(keepMounted ? false : true);
|
|
7788
7789
|
const [arrowElement, setArrowElement] = (0, import_react56.useState)(null);
|
|
7789
7790
|
const { refs, styles: positionStyles } = useFloatPosition(arrowElement, {
|
|
7790
7791
|
placement
|
|
@@ -7798,16 +7799,18 @@ var Tooltip = ({
|
|
|
7798
7799
|
} else setInView(false);
|
|
7799
7800
|
};
|
|
7800
7801
|
(0, import_react56.useEffect)(() => {
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7802
|
+
if (keepMounted) {
|
|
7803
|
+
const options = {
|
|
7804
|
+
root: null,
|
|
7805
|
+
rootMargin: "0px"
|
|
7806
|
+
};
|
|
7807
|
+
const ref2 = tooltipRef.current;
|
|
7808
|
+
const observer = new IntersectionObserver(closeWhenNotInView, options);
|
|
7809
|
+
if (ref2) observer.observe(ref2);
|
|
7810
|
+
return () => {
|
|
7811
|
+
if (ref2) observer.unobserve(ref2);
|
|
7812
|
+
};
|
|
7813
|
+
}
|
|
7811
7814
|
}, [tooltipRef]);
|
|
7812
7815
|
(0, import_react56.useEffect)(() => {
|
|
7813
7816
|
if (tooltipRef.current) {
|
|
@@ -7840,15 +7843,19 @@ var Tooltip = ({
|
|
|
7840
7843
|
timer = setTimeout(() => setOpen(true), delay);
|
|
7841
7844
|
}
|
|
7842
7845
|
};
|
|
7846
|
+
const hasTransitionedIn = useMountTransition(open, 500);
|
|
7847
|
+
const isMounted = hasTransitionedIn && open;
|
|
7848
|
+
const isTransientlyMounted = !keepMounted && isMounted;
|
|
7843
7849
|
const anchorElement = import_react56.Children.only(
|
|
7844
7850
|
(0, import_react56.cloneElement)(children, {
|
|
7845
7851
|
ref: refs.setReference,
|
|
7846
7852
|
onFocus: combineHandlers(openTooltip, children.props.onFocus),
|
|
7847
7853
|
onBlur: combineHandlers(closeTooltip, children.props.onBlur),
|
|
7848
|
-
"aria-describedby": uniqueTooltipId
|
|
7854
|
+
"aria-describedby": isTransientlyMounted || keepMounted ? uniqueTooltipId : void 0
|
|
7849
7855
|
})
|
|
7850
7856
|
);
|
|
7851
|
-
const openCn = open && inView ? "open" : "closed";
|
|
7857
|
+
const openCn = keepMounted && open && inView || isTransientlyMounted ? "open" : "closed";
|
|
7858
|
+
const ariaHidden = keepMounted ? !open : void 0;
|
|
7852
7859
|
return /* @__PURE__ */ (0, import_jsx_runtime251.jsxs)(
|
|
7853
7860
|
"div",
|
|
7854
7861
|
{
|
|
@@ -7863,13 +7870,13 @@ var Tooltip = ({
|
|
|
7863
7870
|
onMouseOver: combineHandlers(openTooltip, onMouseOver),
|
|
7864
7871
|
children: [
|
|
7865
7872
|
anchorElement,
|
|
7866
|
-
/* @__PURE__ */ (0, import_jsx_runtime251.jsxs)(
|
|
7873
|
+
!keepMounted && (open || hasTransitionedIn) || keepMounted ? /* @__PURE__ */ (0, import_jsx_runtime251.jsxs)(
|
|
7867
7874
|
Paper,
|
|
7868
7875
|
{
|
|
7869
7876
|
id: uniqueTooltipId,
|
|
7870
7877
|
ref: combinedRef,
|
|
7871
7878
|
role: "tooltip",
|
|
7872
|
-
"aria-hidden":
|
|
7879
|
+
"aria-hidden": ariaHidden,
|
|
7873
7880
|
style: { ...positionStyles.floating },
|
|
7874
7881
|
elevation: 1,
|
|
7875
7882
|
border: "border-subtle",
|
|
@@ -7901,7 +7908,7 @@ var Tooltip = ({
|
|
|
7901
7908
|
] }) })
|
|
7902
7909
|
]
|
|
7903
7910
|
}
|
|
7904
|
-
)
|
|
7911
|
+
) : null
|
|
7905
7912
|
]
|
|
7906
7913
|
}
|
|
7907
7914
|
);
|