File size: 1,559 Bytes
bc20498 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
<script>import { setCtx } from "../ctx.js";
import { derived } from "svelte/store";
export let closeOnOutsideClick = void 0;
export let closeOnEscape = void 0;
export let portal = void 0;
export let open = void 0;
export let onOpenChange = void 0;
export let preventScroll = void 0;
export let loop = void 0;
export let dir = void 0;
export let typeahead = void 0;
export let closeFocus = void 0;
export let disableFocusFirstItem = void 0;
export let onOutsideClick = void 0;
const {
states: { open: localOpen },
updateOption,
ids
} = setCtx({
closeOnOutsideClick,
closeOnEscape,
portal,
forceVisible: true,
defaultOpen: open,
preventScroll,
loop,
dir,
typeahead,
disableFocusFirstItem,
closeFocus,
onOutsideClick,
onOpenChange: ({ next }) => {
if (open !== next) {
onOpenChange?.(next);
open = next;
}
return next;
}
});
const idValues = derived([ids.menu, ids.trigger], ([$menuId, $triggerId]) => ({
menu: $menuId,
trigger: $triggerId
}));
$:
open !== void 0 && localOpen.set(open);
$:
updateOption("closeOnOutsideClick", closeOnOutsideClick);
$:
updateOption("closeOnEscape", closeOnEscape);
$:
updateOption("portal", portal);
$:
updateOption("preventScroll", preventScroll);
$:
updateOption("loop", loop);
$:
updateOption("dir", dir);
$:
updateOption("closeFocus", closeFocus);
$:
updateOption("disableFocusFirstItem", disableFocusFirstItem);
$:
updateOption("typeahead", typeahead);
$:
updateOption("onOutsideClick", onOutsideClick);
</script>
<slot ids={$idValues} />
|