feat: add htmx type declarations and process on ready
This commit is contained in:
@@ -2,6 +2,14 @@ export {};
|
||||
|
||||
import { onReady } from "./utils";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
htmx?: {
|
||||
process: (element: Element) => void;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
type ToastFn = (opts: { message: string; duration?: number }) => void;
|
||||
|
||||
const getToast = (): ToastFn | null => {
|
||||
@@ -36,6 +44,8 @@ const getTriggerFromHtmxEvent = (event: Event): Element | null => {
|
||||
};
|
||||
|
||||
onReady(() => {
|
||||
window.htmx?.process(document.body);
|
||||
|
||||
document.addEventListener("htmx:beforeRequest", (event) => {
|
||||
setBusy(getTriggerFromHtmxEvent(event), true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user