File size: 1,143 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
import { createDialog } from "@melt-ui/svelte";
import { getContext, setContext } from "svelte";
import { createBitAttrs, getOptionUpdater, removeUndefined } from "../../internal/index.js";
function getAlertDialogData() {
    const NAME = "alert-dialog";
    const PARTS = [
        "action",
        "cancel",
        "content",
        "description",
        "overlay",
        "portal",
        "title",
        "trigger",
    ];
    return { NAME, PARTS };
}
export function setCtx(props) {
    const { NAME, PARTS } = getAlertDialogData();
    const getAttrs = createBitAttrs(NAME, PARTS);
    const initAlertDialog = createDialog({
        ...removeUndefined(props),
        role: "alertdialog",
        forceVisible: true,
    });
    const alertDialog = {
        ...initAlertDialog,
        getAttrs,
        updateOption: getOptionUpdater(initAlertDialog.options),
    };
    setContext(NAME, alertDialog);
    return {
        ...alertDialog,
        updateOption: getOptionUpdater(alertDialog.options),
        getAttrs,
    };
}
export function getCtx() {
    const { NAME } = getAlertDialogData();
    return getContext(NAME);
}