This commit is contained in:
Peter Clement 2025-03-12 14:56:12 +00:00
parent e637a86a2b
commit 2f407ad7d8
5 changed files with 13 additions and 28 deletions

View File

@ -2,7 +2,7 @@
import { getContext } from "svelte"
import Context from "../context"
const { hide } = getContext(Context.Modal)
const { hide } = getContext(Context.Modal) as { hide: () => void }
let count: number = 0
const clicks: number = 5

View File

@ -73,7 +73,12 @@
})
}
setContext(Context.Modal, { show, hide, toggle, cancel })
setContext(Context.Modal, {
show,
hide,
toggle,
cancel,
} as { show: () => void; hide: () => void; toggle: () => void; cancel: () => void })
onMount(() => {
document.addEventListener("keydown", handleKey)

View File

@ -30,7 +30,10 @@
export let secondaryButtonWarning: boolean = false
export let custom: boolean = false
const { hide, cancel } = getContext(Context.Modal)
const { hide, cancel } = getContext(Context.Modal) as {
hide: () => void
cancel: () => void
}
let loading: boolean = false

View File

@ -1,21 +0,0 @@
declare module "svelte" {
export function getContext(key: "bbui-modal"): {
hide: () => void
cancel: () => void
show: () => void
}
export function getContext(key: "bbui-popover-root"): {
show: () => void
hide: () => void
}
export function getContext(key: "actionMenu"): {
hideAll: () => void
}
}
declare const Context: {
readonly Modal: "bbui-modal"
readonly PopoverRoot: "bbui-popover-root"
}
export default Context

View File

@ -1,6 +1,4 @@
const Context = {
export default {
Modal: "bbui-modal",
PopoverRoot: "bbui-popover-root",
} as const
export default Context
}