File size: 1,018 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 |
import { createCalendar } from "@melt-ui/svelte";
import { getContext, setContext } from "svelte";
import { removeUndefined, getOptionUpdater, createBitAttrs } from "../../internal/index.js";
export function getCalendarData() {
const NAME = "calendar";
const PARTS = [
"root",
"prev-button",
"next-button",
"heading",
"grid",
"day",
"header",
"grid-head",
"head-cell",
"grid-body",
"cell",
"grid-row",
];
return { NAME, PARTS };
}
export function setCtx(props) {
const { NAME, PARTS } = getCalendarData();
const getCalendarAttrs = createBitAttrs(NAME, PARTS);
const calendar = { ...createCalendar(removeUndefined(props)), getCalendarAttrs };
setContext(NAME, calendar);
return {
...calendar,
updateOption: getOptionUpdater(calendar.options),
};
}
export function getCtx() {
const { NAME } = getCalendarData();
const ctx = getContext(NAME);
return ctx;
}
|