UNPKG

@miniplex/react

Version:

React glue for Miniplex.

45 lines (44 loc) 1.77 kB
import { Bucket, IEntity, Predicate, WithRequiredKeys, World } from "@miniplex/core"; import React, { FunctionComponent, ReactNode } from "react"; export declare type EntityChildren<E> = ReactNode | ((entity: E) => ReactNode); export declare const createComponents: <E extends IEntity>(world: World<E>) => { Entity: <D extends E>({ children: givenChildren, entity: givenEntity, as: As }: { entity?: D | undefined; children?: EntityChildren<D>; as?: React.FunctionComponent<{ entity: D; children?: ReactNode; }> | undefined; }) => JSX.Element; Entities: <D_1 extends E>({ entities, ...props }: { entities: D_1[]; children?: EntityChildren<D_1>; as?: React.FunctionComponent<{ entity: D_1; children?: ReactNode; }> | undefined; }) => JSX.Element; Bucket: <D_2 extends E>({ bucket: _bucket, ...props }: { bucket: Bucket<D_2> | Predicate<E, D_2>; children?: EntityChildren<D_2>; as?: React.FunctionComponent<{ entity: D_2; children?: ReactNode; }> | undefined; }) => JSX.Element; Archetype: <A extends keyof E>({ components, ...props }: { components: A | A[]; children?: EntityChildren<WithRequiredKeys<E, A>>; as?: React.FunctionComponent<{ entity: WithRequiredKeys<E, A>; children?: ReactNode; }> | undefined; }) => JSX.Element; Component: <P extends keyof E>(props: { name: P; value?: E[P] | undefined; children?: ReactNode; }) => JSX.Element | null; useCurrentEntity: () => E | null; useArchetype: <P_1 extends keyof E>(...components: P_1[]) => WithRequiredKeys<E, P_1>[]; };