import {Store, Event, Scope} from 'effector' export type StoreOrData = Store | T export type DOMProperty = string | number | null | boolean export type PropertyMap = {[field: string]: DOMProperty | AttributeStoreInput} export type StylePropertyMap = Partial< { [K in keyof CSSStyleDeclaration]: DOMProperty | AttributeStoreInput } > export type ClassListMap = {[cssClass: string]: StoreOrData} export type ClassListArray = Array | string> export type HandlerMap = | Partial<{[K in keyof HTMLElementEventMap]: Event}> | { config?: { passive?: boolean capture?: boolean prevent?: boolean stop?: boolean } on: Partial< {[K in keyof HTMLElementEventMap]: Event} > } export type DOMTag = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap export type DOMElement = HTMLElement | SVGElement export type AttributeStore = Store type AttributeStoreInput = Omit< AttributeStore, 'updates' | 'reset' | 'on' | 'off' | 'thru' > type Tuple = [T] | T[] type Combinable = {[key: string]: Store} | Tuple> type GetCombinedValue = { [K in keyof T]: T[K] extends Store ? U : never } export function using(node: DOMElement, cb: () => any): void export function using( node: DOMElement, opts: { fn: () => void hydrate?: boolean env?: { document: Document } onComplete?: () => void scope?: Scope }, ): void export function spec(spec: { attr?: PropertyMap data?: PropertyMap text?: | DOMProperty | AttributeStoreInput | Array visible?: Store style?: StylePropertyMap styleVar?: PropertyMap classList?: ClassListMap | ClassListArray handler?: HandlerMap }): void export function handler( map: Partial< {[K in keyof HTMLElementEventMap]: Event} >, ): void export function handler( options: { passive?: boolean capture?: boolean stop?: boolean prevent?: boolean }, map: Partial< {[K in keyof HTMLElementEventMap]: Event} >, ): void export function h( tag: DOMTag, spec: { attr?: PropertyMap data?: PropertyMap text?: | DOMProperty | AttributeStoreInput | Array visible?: Store style?: StylePropertyMap styleVar?: PropertyMap classList?: ClassListMap | ClassListArray handler?: HandlerMap fn?: () => void }, ): void export function h(tag: DOMTag, cb: () => void): void export function variant(config: { source: Store key: K cases: T[K] extends string ? Partial< { [F in T[K]]: (config: { store: Store> }) => void } & { __: (config: {store: Store}) => void } > : { [caseName: string]: (config: {store: Store}) => void __: (config: {store: Store}) => void } }): void // export function variant( // key: Store, // cases: Partial<{[K in Case]: () => void}>, // ): void export function list( source: Store, cb: (opts: {store: Store; key: Store}) => void, ): void export function list< T, K extends keyof T, Query extends [keyof T] | ReadonlyArray | (keyof T)[] >( opts: { key: T[K] extends string | number ? K : never source: Store visible?: (state: T) => boolean fields: Query fn?: (opts: { store: Store fields: { [K in keyof Query]: Query[K] extends keyof T ? Store : never } key: Store }) => void }, cb?: (opts: { store: Store fields: { [K in keyof Query]: Query[K] extends keyof T ? Store : never } key: Store }) => void, ): void export function list( opts: { key: T[K] extends string | number | symbol ? K : never source: Store visible?: (state: T) => boolean fn?: (opts: {store: Store; key: Store}) => void }, cb?: (opts: {store: Store; key: Store}) => void, ): void export function tree< T, ChildField extends keyof T // KeyField extends keyof T >(config: { source: Store // key: T[KeyField] extends string ? KeyField : never child: T[ChildField] extends T[] ? ChildField : never fn: (config: {store: Store; child: () => void}) => void }): void export function rec(config: { fn(config: {store: Store}): void }): (opts: {store: Store}) => void export function rec( fn: (config: {store: Store}) => void, ): (opts: {store: Store}) => void export function route(config: { source: Store visible: (value: T) => boolean fn: (config: {store: Store}) => void }): void export function route(config: { source: Store visible: (value: T) => value is S fn: (config: {store: Store}) => void }): void export function route(config: { source: Store visible: Store fn: (config: {store: Store}) => void }): void export function block(config: {fn: () => void}): () => void export function node(fn: (node: DOMElement) => void): void export function text( words: TemplateStringsArray, ...values: Array ): void export function remap, Key extends keyof T>( store: Store, key: Key, ): Store export function remap< T extends Record, Names extends Array >( store: Store, names: [...Names], ): { [Key in keyof Names]: Names[Key] extends keyof T ? Store : never } export function remap< T extends Record, Shape extends {[field: number]: keyof T} | {[field: string]: keyof T} >( store: Store, shape: Shape, ): { [Key in keyof Shape]: Shape[Key] extends keyof T ? Store : never } export function val( words: TemplateStringsArray, ...values: Array ): string export function val( words: TemplateStringsArray, ...values: Array ): Store