import { DOMRenderer, JsxProps, RenderMode, VNode, DataObject, JsxChildren } from "dom-renderer"; import { CustomElement, DelegateEventHandler, CustomFormElement, HTMLFieldProps } from "web-utility"; import { IReactionDisposer, IReactionPublic } from "mobx"; export interface ComponentMeta extends ElementDefinitionOptions, Partial { tagName: string; transitible?: boolean; renderMode?: RenderMode; } export type ClassComponent = CustomElementConstructor; export type WebCellProps = JsxProps; export interface WebCell

extends CustomElement { props: P & WebCellProps; internals: ReturnType; renderer: DOMRenderer; root: ParentNode; mounted: boolean; update: () => Promise; /** * Called at DOM tree updated */ updatedCallback?: () => any; /** * Called at first time of DOM tree updated */ mountedCallback?: () => any; emit: (event: string, detail?: any, option?: EventInit) => boolean; } interface DelegatedEvent { type: keyof HTMLElementEventMap; selector: string; handler: EventListener; } /** * `class` decorator of Web components */ export function component(meta: ComponentMeta): (Class: T, { addInitializer }: ClassDecoratorContext) => T; /** * Method decorator of DOM Event delegation */ export function on(type: DelegatedEvent['type'], selector: string): (method: DelegateEventHandler, { addInitializer }: ClassMethodDecoratorContext) => void; export type ComponentTag = string | WebCellComponent; export interface FunctionCellProps extends WebCellProps { component: FC | AFC; } export interface FunctionCell extends WebCell { } export class FunctionCell extends HTMLElement implements WebCell { accessor component: FunctionCellProps['component']; accessor vNode: VNode | undefined; disconnectedCallback: IReactionDisposer; render(): VNode; } type GetAsyncProps = T extends () => Promise<{ default: FunctionComponent | ClassComponent; }> ? P : {}; export const lazy: Promise<{ default: FunctionComponent | ClassComponent; }>>(loader: T) => (props: GetAsyncProps) => VNode; export class Defer { resolve: (value: T | PromiseLike) => void; reject: (reason?: any) => void; promise: Promise; } export function getMobxData(observable: T): T; export const animated: (root: T, targetSelector: string) => Promise; export type PropsWithChildren

= P & { children?: JsxChildren; }; export type FunctionComponent

= (props: P) => VNode; export type AsyncFunctionComponent

= (props: P) => Promise; export type FC

= FunctionComponent

; export type AFC

= AsyncFunctionComponent

; export type WebCellComponent = FunctionComponent | ClassComponent; export type ComponentType

= FC

| (WebCell

& ClassComponent); export type ComponentProps = C extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[C] : C extends FC ? P : C extends WebCell & ClassComponent ? P : never; export type ObservableComponent = WebCellComponent | AsyncFunctionComponent; export type AwaitedComponent = T extends (props: infer P) => Promise ? (props: P) => R : T; /** * `class` decorator of Web components for MobX */ export function observer(func: T, _: ClassDecoratorContext): AwaitedComponent; export function observer(func: T): AwaitedComponent; /** * `accessor` decorator of MobX `@observable` for HTML attributes */ export function attribute(_: ClassAccessorDecoratorTarget, { name, addInitializer }: ClassAccessorDecoratorContext): void; export type ReactionExpression = (data: I, reaction: IReactionPublic) => O; export type ReactionEffect = (newValue: V, oldValue: V, reaction: IReactionPublic) => any; /** * Method decorator of [MobX `reaction()`](https://mobx.js.org/reactions.html#reaction) * * @example * ```tsx * import { observable } from 'mobx'; * import { component, observer, reaction } from 'web-cell'; * * @component({ tagName: 'my-tag' }) * @observer * export class MyTag extends HTMLElement { * @observable * accessor count = 0; * * @reaction(({ count }) => count) * handleCountChange(newValue: number, oldValue: number) { * console.log(`Count changed from ${oldValue} to ${newValue}`); * } * * render() { * return ( * * ); * } * } * ``` */ export const reaction: (expression: ReactionExpression) => (effect: ReactionEffect, { addInitializer }: ClassMethodDecoratorContext) => void; export type PositionY = 'Top' | 'Bottom'; export type DirectionX = 'Left' | 'Right'; export type DirectionY = 'Up' | 'Down'; export type Direction = DirectionX | DirectionY; export type AnimationMode = 'In' | 'Out'; export type AttentionSeekers = 'bounce' | 'flash' | 'pulse' | 'rubberBand' | `shake${'X' | 'Y'}` | 'headShake' | 'swing' | 'tada' | 'wobble' | 'jello' | 'heartBeat'; export type BackEntrances = `backIn${Direction}`; export type BackExits = `backOut${Direction}`; export type BouncingEntrances = `bounceIn${'' | Direction}`; export type BouncingExits = `bounceOut${'' | Direction}`; export type FadingEntrances = `fadeIn${'' | `${Direction}${'' | 'Big'}`}` | `fadeIn${PositionY}${DirectionX}`; export type FadingExits = `fadeOut${'' | `${Direction}${'' | 'Big'}` | `${PositionY}${DirectionX}`}`; export type Flippers = `flip${'' | `${AnimationMode}${'X' | 'Y'}`}`; export type Lightspeed = `lightSpeed${AnimationMode}${DirectionX}`; export type RotatingEntrances = `rotateIn${'' | `${DirectionY}${DirectionX}`}`; export type RotatingExits = `rotateOut${'' | `${DirectionY}${DirectionX}`}`; export type Specials = 'hinge' | 'jackInTheBox' | `roll${'In' | 'Out'}`; export type ZoomingEntrances = `zoomIn${'' | Direction}`; export type ZoomingExits = `zoomOut${'' | Direction}`; export type SlidingEntrances = `slideIn${Direction}`; export type SlidingExits = `slideOut${Direction}`; export type AnimationType = AttentionSeekers | BackEntrances | BackExits | BouncingEntrances | BouncingExits | FadingEntrances | FadingExits | Flippers | Lightspeed | RotatingEntrances | RotatingExits | Specials | ZoomingEntrances | ZoomingExits | SlidingEntrances | SlidingExits; export interface AnimateCSSProps { type: AnimationType; component: FC; } export interface AnimateCSS extends WebCell { } export class AnimateCSS extends HTMLElement implements WebCell { accessor type: AnimationType; accessor playing: boolean; component: FC; connectedCallback(): Promise; typeChanged(): Promise; render(): VNode; } export interface WebField

extends CustomFormElement, WebCell

{ } /** * `class` decorator of Form associated Web components */ export function formField(Class: T, _: ClassDecoratorContext): T; //# sourceMappingURL=index.d.ts.map