UNPKG

solid-js

Version:

A declarative JavaScript library for building user interfaces.

111 lines (110 loc) 4.49 kB
import type { JSX } from "../jsx"; declare type PropsWithChildren<P> = P & { children?: JSX.Element; }; export declare type Component<P = {}> = (props: PropsWithChildren<P>) => JSX.Element; declare type PossiblyWrapped<T> = { [P in keyof T]: T[P] | (() => T[P]); }; declare type SharedConfig = { context?: HydrationContext; }; export declare const sharedConfig: SharedConfig; export declare function createUniqueId(): string; export declare function createComponent<T>(Comp: (props: T) => JSX.Element, props: PossiblyWrapped<T>): JSX.Element; export declare function mergeProps<T, U>(source: T, source1: U): T & U; export declare function mergeProps<T, U, V>(source: T, source1: U, source2: V): T & U & V; export declare function mergeProps<T, U, V, W>(source: T, source1: U, source2: V, source3: W): T & U & V & W; export declare function splitProps<T extends object, K1 extends keyof T>(props: T, ...keys: [K1[]]): [Pick<T, K1>, Omit<T, K1>]; export declare function splitProps<T extends object, K1 extends keyof T, K2 extends keyof T>(props: T, ...keys: [K1[], K2[]]): [Pick<T, K1>, Pick<T, K2>, Omit<T, K1 | K2>]; export declare function splitProps<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T>(props: T, ...keys: [K1[], K2[], K3[]]): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Omit<T, K1 | K2 | K3>]; export declare function splitProps<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T, K4 extends keyof T>(props: T, ...keys: [K1[], K2[], K3[], K4[]]): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Pick<T, K4>, Omit<T, K1 | K2 | K3 | K4>]; export declare function splitProps<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T, K4 extends keyof T, K5 extends keyof T>(props: T, ...keys: [K1[], K2[], K3[], K4[], K5[]]): [ Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Pick<T, K4>, Pick<T, K5>, Omit<T, K1 | K2 | K3 | K4 | K5> ]; export declare function For<T>(props: { each: T[]; fallback?: string; children: (item: T, index: () => number) => string; }): string | { t: string; }; export declare function Index<T>(props: { each: T[]; fallback?: string; children: (item: () => T, index: number) => string; }): string | { t: string; }; export declare function Show<T>(props: { when: T | false; fallback?: string; children: string | ((item: T) => string); }): string; export declare function Switch(props: { fallback?: string; children: MatchProps<unknown> | MatchProps<unknown>[]; }): string; declare type MatchProps<T> = { when: T | false; children: string | ((item: T) => string); }; export declare function Match<T>(props: MatchProps<T>): MatchProps<T>; export declare function ErrorBoundary(props: { fallback: string | ((err: any) => string); children: string; }): string; export interface Resource<T> { (): T | undefined; loading: boolean; } declare type SuspenseContextType = { resources: Map<string, { loading: boolean; }>; completed: () => void; }; declare type ResourceReturn<T> = [ Resource<T>, { mutate: (v: T | undefined) => T | undefined; refetch: () => void; } ]; export declare function createResource<T, U = true>(fetcher: (k: U, getPrev: () => T | undefined) => T | Promise<T>, options?: { initialValue?: T; }): ResourceReturn<T>; export declare function createResource<T, U>(fn: U | false | (() => U | false), fetcher: (k: U, getPrev: () => T | undefined) => T | Promise<T>, options?: { initialValue?: T; }): ResourceReturn<T>; export declare function lazy(fn: () => Promise<{ default: any; }>): (props: any) => string; export declare function enableScheduling(): void; export declare function startTransition(fn: () => any): void; export declare function useTransition(): [() => boolean, (fn: () => any) => void]; declare type HydrationContext = { id: string; count: number; writeResource?: (id: string, v: Promise<any>) => void; resources: Record<string, any>; suspense: Record<string, SuspenseContextType>; async?: boolean; streaming?: boolean; }; export declare function SuspenseList(props: { children: string; revealOrder: "forwards" | "backwards" | "together"; tail?: "collapsed" | "hidden"; }): string; export declare function Suspense(props: { fallback: string; children: string; }): any; export declare function awaitSuspense(fn: () => any): Promise<unknown>; export {};