import { M as MoleculeScopeOptions } from './MoleculeScopeOptions-Bo0_xGmB.js'; import { MoleculeScope, MoleculeOrInterface, ScopeTuple, MoleculeInjector, MoleculeInterface, Molecule } from './vanilla.js'; export { BindingMap, BindingTuple, BindingTuples, Bindings, ComponentScope, CreateInjectorProps, Injectable, MoleculeConstructor, MoleculeGetter, ScopeGetter, createInjector, createScope, getDefaultInjector, molecule, moleculeInterface, onMount, onUnmount, resetDefaultInjector, use } from './vanilla.js'; import * as React from 'react'; import React__default from 'react'; declare type ScopeProviderProps = { scope: MoleculeScope; value?: T; /** * Will generate a unique value, creating a unique separate scope for this provider */ uniqueValue?: boolean; children?: React__default.ReactNode; }; /** * @deprecated use {@link ScopeProviderProps} instead */ declare type ProviderProps = ScopeProviderProps; /** * Provides scope for all molecules lower down in the React component tree. * * Will continue to provide parent scopes down, and either override a scope value or add a new scope. * * Either `value` or `uniqueValue` should be passed as props * * @typeParam T - the type that should match the {@link MoleculeScope} and the value provided */ declare function ScopeProvider(props: ScopeProviderProps): ReturnType; /** * Get an instance from a {@link MoleculeOrInterface} * * This will use the implicit scope of the component that calls this hook. If the component is wrapped in * a {@link ScopeProvider} then that scope will be used here. * * Scope can also be provided explicitly to this hook. This is useful when you already have access to an ID * or other value that represents scope. * * @param mol - a molecule or interface * @param options - allows for setting scope explicitly * @typeParam T - the type of the molecule or interface, and the type of interface returned * @returns a instance provided by the molecule */ declare function useMolecule(mol: MoleculeOrInterface, options?: MoleculeScopeOptions): T; /** * Gets the scopes that are implicitly in context for the current component. * * Scopes can also be set and overridden explicitly by passing in options to this hook. * * @param options * @returns */ declare function useScopes(options?: MoleculeScopeOptions): ScopeTuple[]; /** * Provide a {@link MoleculeInjector} in context for children components * * This is useful for replacing bindings for testing and libraries. * * Note: Every injector is a universe in and of themselves. Nothing is shared between * two injectors, so if you replace an injector, you will be replacing all instances * of all molecules, so likely replacing the entire state of the running application. */ declare const InjectorProvider: React.Provider<() => MoleculeInjector>; /** * Get the injector in context for this component. Defaults to the default global injector. * * @returns */ declare function useInjector(): MoleculeInjector; declare type MoleculeProviderProps = { interface: MoleculeInterface; value?: Molecule | undefined; children?: React__default.ReactNode; }; /** * Provides the implementation of a molecule interface for all molecules lower down in the React component tree. * * @param props.interface - the molecule interface to provide an implementation for * @param props.value - the molecule that implements the interface * * @typeParam T - the type of object that will be provided by this the molecule interface * * @example * ```tsx * import { molecule, moleculeInterface } from "bunshi/vanilla"; * import { MoleculeProvider, useMolecule } from "bunshi/react"; * * // Define a molecule interface and a component that uses it * export const NumberMoleculeInterface = moleculeInterface(); * function DisplayNumber() { * const number = useMolecule(NumberMoleculeInterface); * return
{number}
; * } * * // Define a molecule that implements the interface and provides it * const RandomNumberMolecule = molecule(() => Math.random()); * function App() { * return ( * * * * ); * } * ``` */ declare function MoleculeProvider(props: MoleculeProviderProps): ReturnType; export { InjectorProvider, Molecule, MoleculeInjector, MoleculeInterface, MoleculeOrInterface, MoleculeProvider, MoleculeProviderProps, MoleculeScope, MoleculeScopeOptions, ProviderProps, ScopeProvider, ScopeProviderProps, ScopeTuple, useInjector, useMolecule, useScopes };