import type { Child, Context, ContextWithDefault, ObservableMaybe } from '../types'; import { ElementAttributes } from './custom_element'; interface ContextProviderProps { value?: ObservableMaybe; children?: ObservableMaybe; symbol?: ObservableMaybe; } declare const ContextProvider: (props: Partial & { children?: import("./defaults").CustomElementChildren; } & import("./defaults").StyleEncapsulationProps) => globalThis.JSX.Element; declare module '../index' { namespace JSX { interface IntrinsicElements { 'context-provider': ElementAttributes; } } } /** * Context API for Woby Framework * * This module provides the createContext function which creates a context object that can be used * to pass data through the component tree without having to pass props down manually at every level. * It supports both JSX components and custom elements with special context handling. * * @module createContext */ /** * Creates a context object that can be used to pass data through the component tree * without having to pass props down manually at every level. * * The context object has a Provider component that allows consuming components to subscribe * to context changes. The Provider component accepts a `value` prop that will be passed to * all components that are descendants of the Provider. * * @template T - The type of the context value * @param defaultValue - The default value for the context when no Provider is found * @returns A context object with a Provider component and a symbol for internal use * * @example * ```tsx * // Create a context with a default value * const ThemeContext = createContext('light') * * // Create a context without a default value * const UserContext = createContext(undefined) * * // Use the Provider to pass a value down the tree * const App = () => ( * * * * ) * * // Consume the context value in a component * const ThemedButton = () => { * const theme = useContext(ThemeContext) * return * } * ``` * * @example * ```tsx * // Using context with custom elements * const ValueContext = createContext(0) * * // Provider works with both JSX and custom elements * customElement('value-display', ({value}: {value: Observable }) => { * const context = useContext(ValueContext) * return
Value: {value}, Context: {context}
* }) * * // In JSX: * // * // * // * ``` */ export declare function createContext(defaultValue: T): ContextWithDefault; export declare function createContext(defaultValue?: T): Context; export {}; //# sourceMappingURL=create_context.d.ts.map