/// /// /// /** @jsx h */ /** @jsxFrag Fragment */ import { Fragment, h, render } from "../preact/mod.tsx"; import { useCallback, useState, useMemo, useEffect, useRef } from "../preact/hooks.ts"; const useDialog = () => { const ref = useRef(null); const open = useCallback(() => ref.current?.showModal?.(), []); const close = useCallback(() => ref.current?.close?.(), []); return { ref, open, close, isOpen: ref.current?.open ?? false }; }; const App = () => { const { ref, open, close } = useDialog(); /** dialogクリックではmodalを閉じないようにする */ const stopPropagation = useCallback((e: Event) => e.stopPropagation(), []); return (<>

dialog内のテキスト

) }; const app = document.createElement("div"); const shadowRoot = app.attachShadow({ mode: "open" }); document.body.append(app); render(, shadowRoot);