import { createContext, createMemo, getOwner, useContext, type Accessor, type ParentProps } from "solid-js" const Context = createContext>(() => true) /** Disabling a subtree also disables every nested interactivity provider. */ export function InteractivityProvider(props: ParentProps<{ enabled: boolean }>) { const parent = useInteractivity() const enabled = createMemo(() => parent() && props.enabled) return {props.children} } /** Shared by keymap consumers and native input/focus handlers. Defaults to enabled. */ export function useInteractivity() { return useContext(Context) } /** Forwarded APIs use the calling component's context, or their captured context outside a Solid owner. */ export function resolveInteractivity(fallback: Accessor) { return getOwner() ? useInteractivity() : fallback }