MCPcopy Create free account
hub / github.com/arctic-cli/interface / DialogRoot

Function DialogRoot

packages/ui/src/components/dialog.tsx:17–68  ·  view source on GitHub ↗
(props: DialogProps)

Source from the content-addressed store, hash-verified

15}
16
17export function DialogRoot(props: DialogProps) {
18 let trigger!: HTMLElement
19 const [local, others] = splitProps(props, ["trigger", "class", "classList", "children"])
20
21 const resetTabIndex = () => {
22 trigger.tabIndex = 0
23 }
24
25 const handleTriggerFocus = (e: FocusEvent & { currentTarget: HTMLElement | null }) => {
26 const firstChild = e.currentTarget?.firstElementChild as HTMLElement
27 if (!firstChild) return
28
29 firstChild.focus()
30 trigger.tabIndex = -1
31
32 firstChild.addEventListener("focusout", resetTabIndex)
33 onCleanup(() => {
34 firstChild.removeEventListener("focusout", resetTabIndex)
35 })
36 }
37
38 onMount(() => {
39 // @ts-ignore
40 document?.activeElement?.blur?.()
41 })
42
43 return (
44 <Kobalte {...others}>
45 <Show when={props.trigger}>
46 <Kobalte.Trigger ref={trigger} data-component="dialog-trigger" onFocusIn={handleTriggerFocus}>
47 {props.trigger}
48 </Kobalte.Trigger>
49 </Show>
50 <Kobalte.Portal>
51 <Kobalte.Overlay data-component="dialog-overlay" />
52 <div data-component="dialog">
53 <div data-slot="dialog-container">
54 <Kobalte.Content
55 data-slot="dialog-content"
56 classList={{
57 ...(local.classList ?? {}),
58 [local.class ?? ""]: !!local.class,
59 }}
60 >
61 {local.children}
62 </Kobalte.Content>
63 </div>
64 </div>
65 </Kobalte.Portal>
66 </Kobalte>
67 )
68}
69
70function DialogHeader(props: ComponentProps<"div">) {
71 return <div data-slot="dialog-header" {...props} />

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected