UNPKG

@expressive/react

Version:
66 lines (65 loc) 2.49 kB
import { Pragma, ReactState } from "./state"; import State$1, { Context, Context as Context$1, Observable, get, ref, set, use } from "@expressive/state"; import * as react from "react"; import { Fragment, ReactNode, createElement } from "react"; //#region src/context.d.ts declare module '@expressive/state' { namespace Context { function use(create?: true): Context$1; function use(create: boolean): Context$1 | null | undefined; } } declare namespace Consumer { type Props<T extends State$1> = { /** Type of controller to fetch from context. */for: State$1.Extends<T>; /** * Render function, will receive instance of desired controller. * * Called every render of parent component. * Similar to `State.get()`, updates to properties accessed in * this function will cause a refresh when they change. */ children: (value: T) => ReactNode | void; }; } declare function Consumer<T extends State$1>(props: Consumer.Props<T>): string | number | bigint | boolean | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | null; declare namespace Provider { interface Props<T extends State$1> { /** State or group of States to provide to descendant Consumers. */ for: Context$1.Accept<T>; /** * Callback to run for each provided State. */ forEach?: Context$1.Expect<T>; /** * Children to render within this Provider. */ children?: ReactNode; /** A fallback tree to show when suspended. */ fallback?: ReactNode; /** * A name for this Suspense boundary for instrumentation purposes. * The name will help identify this boundary in React DevTools. */ name?: string | undefined; } } declare function Provider<T extends State$1>(props: Provider.Props<T>): ReactNode; //#endregion //#region src/index.d.ts /** * Augmented State namespace to include ReactState hooks as static methods. * * This retroactively adds React support to agnostic State defined * by component libraries which import `@expressive/state` directly. */ declare module '@expressive/state' { namespace State { export import as = ReactState.as; export import get = ReactState.get; export import use = ReactState.use; } } //#endregion export { Consumer, Context, Fragment, Observable, Pragma, Provider, ReactState as State, ReactState as default, createElement, get, ref, set, use }; //# sourceMappingURL=index.d.ts.map