@marianmeres/stuic 2.23.0 → 2.25.0
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.
|
@@ -65,6 +65,8 @@ export interface PopoverOptions {
|
|
|
65
65
|
onHide?: () => void;
|
|
66
66
|
/** Debug mode */
|
|
67
67
|
debug?: boolean;
|
|
68
|
+
/** Programmatically control open state (reactive) */
|
|
69
|
+
open?: boolean;
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
70
72
|
* A Svelte action that displays a popover anchored to an element using CSS Anchor Positioning.
|
|
@@ -155,6 +155,7 @@ export function popover(anchorEl, fn) {
|
|
|
155
155
|
let hideTimer = null;
|
|
156
156
|
let isVisible = false;
|
|
157
157
|
let do_debug = false;
|
|
158
|
+
let prevOpen = undefined;
|
|
158
159
|
// Unique identifiers
|
|
159
160
|
const rnd = Math.random().toString(36).slice(2);
|
|
160
161
|
const id = `popover-${rnd}`;
|
|
@@ -421,6 +422,17 @@ export function popover(anchorEl, fn) {
|
|
|
421
422
|
}
|
|
422
423
|
// Note: trigger mode change while visible is not fully handled
|
|
423
424
|
// User should close and reopen for trigger mode change to take effect
|
|
425
|
+
// Handle programmatic open/close
|
|
426
|
+
const openValue = opts.open;
|
|
427
|
+
if (openValue !== undefined && openValue !== prevOpen) {
|
|
428
|
+
if (openValue && !isVisible) {
|
|
429
|
+
show();
|
|
430
|
+
}
|
|
431
|
+
else if (!openValue && isVisible) {
|
|
432
|
+
hide();
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
prevOpen = openValue;
|
|
424
436
|
});
|
|
425
437
|
// Event listeners effect
|
|
426
438
|
$effect(() => {
|