contain-css-svelte 1.2.2 → 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.
|
@@ -4,7 +4,7 @@ import { COLOR_VARS, PADDING_VARS, RADIUS_VARS, TYPOGRAPHY_CONTAINER_VARS, } fro
|
|
|
4
4
|
let tooltipDiv = $state();
|
|
5
5
|
let targetDiv = $state();
|
|
6
6
|
let tooltipMeasurementDiv = $state();
|
|
7
|
-
let { tooltipText = "", vertical = "bottom", horizontal = "right", children, tooltip, block = false, class: className, ...restProps } = $props();
|
|
7
|
+
let { tooltipText = "", vertical = "bottom", horizontal = "right", children, tooltip, block = false, tooltipDisabled = false, class: className, ...restProps } = $props();
|
|
8
8
|
/* The wrapper is the element a caller is pointing at -- the tooltip itself
|
|
9
9
|
is a popover the component owns and positions. */
|
|
10
10
|
/* The shorthands this component's own CSS backs, one group per mixin
|
|
@@ -37,6 +37,10 @@ function hidePopover() {
|
|
|
37
37
|
unwatchViewport();
|
|
38
38
|
tooltipDiv?.togglePopover(false);
|
|
39
39
|
}
|
|
40
|
+
$effect(() => {
|
|
41
|
+
if (tooltipDisabled)
|
|
42
|
+
hidePopover();
|
|
43
|
+
});
|
|
40
44
|
/**
|
|
41
45
|
* Find the rect to anchor the tooltip to.
|
|
42
46
|
*
|
|
@@ -203,13 +207,15 @@ onDestroy(() => {
|
|
|
203
207
|
unwatchViewport();
|
|
204
208
|
});
|
|
205
209
|
async function showPopover() {
|
|
210
|
+
if (tooltipDisabled)
|
|
211
|
+
return;
|
|
206
212
|
wantsShow = true;
|
|
207
213
|
if (!hasRendered) {
|
|
208
214
|
hasRendered = true;
|
|
209
215
|
// Wait for the content to exist before measuring it — positioning reads
|
|
210
216
|
// the measurement element's height/width to decide flip direction.
|
|
211
217
|
await tick();
|
|
212
|
-
if (!wantsShow)
|
|
218
|
+
if (!wantsShow || tooltipDisabled)
|
|
213
219
|
return;
|
|
214
220
|
}
|
|
215
221
|
if (!positionTooltip())
|
|
@@ -8,6 +8,7 @@ declare const Tooltip: import("svelte").Component<ContainProps<HTMLAttributes<HT
|
|
|
8
8
|
children?: import("svelte").Snippet;
|
|
9
9
|
tooltip?: import("svelte").Snippet;
|
|
10
10
|
block?: boolean;
|
|
11
|
+
tooltipDisabled?: boolean;
|
|
11
12
|
}, StyleProps<readonly ["bg", "fg", "padding", "borderRadius", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant", "lineWidth"]>>, {}, "">;
|
|
12
13
|
type Tooltip = ReturnType<typeof Tooltip>;
|
|
13
14
|
export default Tooltip;
|