@rxdi/ui-kit
Version:
UI Components for building graphql-server website
47 lines (46 loc) • 2.39 kB
TypeScript
import { CustomElementConfig, LitElement, TemplateResult } from '@rxdi/lit-html';
import { Observable } from 'rxjs';
import '../graph/graph.component';
export type Without<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type Injection = {
has: <T>(d: T) => boolean;
get: <T>(d: T) => T;
};
export type Constructor<T = {}> = new (...args: any[]) => T;
export type InstanceTypes<T> = {
[P in keyof T]: T[P] extends Constructor<infer U> ? U : never;
};
export declare const DefineDependencies: <T extends Constructor<{}>[]>(...deps: T) => (injection: Injection) => InstanceTypes<T>;
export type StateToRender<S, D, K extends LitElement> = (this: K, deps: D) => Observable<S> | S | Promise<S>;
export type RenderResult<S, D, K extends LitElement> = (deps: D) => (this: K, state: S, setState: (s: S) => void) => TemplateResult | string | number | unknown;
export type Options = Without<CustomElementConfig<never>, 'template'>;
export declare const Compose: <S, D = [], K extends LitElement = LitElement>(options?: Options) => (deps?: D) => (state: StateToRender<S, D, K>) => (render: RenderResult<S, D, K>) => <K_1 extends new (...args: any[]) => {}>(Base: K_1) => {
new (...args: any[]): {
getTemplateResult(): any;
OnInit(): any;
disconnectedCallback(): void;
connectedCallback(): void;
render(): any;
update(): void;
firstUpdated(): void;
};
styles: import("@rxdi/lit-html").CSSResult[];
is(): string;
} & K_1;
export declare const Monad: <S, D = unknown, K extends LitElement = LitElement>([options, deps, state, render,]: [Options, D, StateToRender<S, D, K>, RenderResult<S, D, K>]) => <K_1 extends new (...args: any[]) => {}>(Base: K_1) => {
new (...args: any[]): {
getTemplateResult(): any;
OnInit(): any;
disconnectedCallback(): void;
connectedCallback(): void;
render(): any;
update(): void;
firstUpdated(): void;
};
styles: import("@rxdi/lit-html").CSSResult[];
is(): string;
} & K_1;
export declare const Settings: (o: Options) => Options;
export declare const Providers: <S, D, K>(o: D) => D;
export declare const State: <S, D, K extends LitElement>(o: StateToRender<S, D, K>) => StateToRender<S, D, K>;
export declare const Render: <S, D, K extends LitElement>(o: RenderResult<S, D, K>) => RenderResult<S, D, K>;