UNPKG

@web-atoms/core

Version:
145 lines • 5.56 kB
import type { ObjectPositionType } from "../style/StyleRule"; import type { AtomControl } from "../web/controls/AtomControl"; import Bind from "./Bind"; import type { ColorItem } from "./Colors"; import { IClassOf, IDisposable } from "./types"; export interface IAttributes { [key: string]: string | number | null | any; } export declare class RootObject { get vsProps(): { [k in keyof this]?: this[k] | Bind; } | { [k: string]: any; } | {}; addEventListener(name: string, handler: EventListenerOrEventListenerObject): IDisposable; appendChild(e: any): void; dispatchEvent(evt: Event): void; } export interface IElementAttributes { [key: string]: unknown; "data-click-event"?: string; /** * Useful only inside `Form` element. */ "data-submit-event"?: string; eventClick?: any; eventBlur?: any; eventFocus?: any; eventKeydown?: any; eventKeyup?: any; eventKeypress?: any; text?: string | any; "event-click"?: (e: MouseEvent) => any; "event-blur"?: (e: Event) => any; "event-focus"?: (e: Event) => any; "on-create"?: (ctrl: AtomControl, element: HTMLElement) => any; /** This will fire up `watch` custom event, that you can observe * for many elements in document.body instead of setting up too * many bindings */ watch?: any; /** * If display is set to true, it will be set as empty string, * which will unset the value and it will inherit the style from stylesheet. * If it is set to false, it will be set to "none" */ "style-display"?: boolean | string; /** number will be converted to pixels */ "style-left"?: number | string; /** number will be converted to pixels */ "style-top"?: number | string; /** number will be converted to pixels */ "style-bottom"?: number | string; /** number will be converted to pixels */ "style-right"?: number | string; /** number will be converted to pixels */ "style-width"?: number | string; /** number will be converted to pixels */ "style-height"?: number | string; /** number will be converted to pixels */ "style-position"?: ObjectPositionType; /** number will be converted to pixels */ "style-font-size"?: number | string; "style-font-family"?: string; "style-font-weight"?: string; "style-border"?: string; "style-border-width"?: string; "style-border-color"?: string | ColorItem; "style-color"?: string | ColorItem; "style-background-color"?: string | ColorItem; } declare global { namespace JSX { interface ElementAttributesProperty { vsProps: any; } type HtmlPartial<T> = { [k in keyof T]?: IElementAttributes | { [tx in keyof T[k]]?: T[k][tx]; }; }; type IAllHtmlElements = HtmlPartial<HTMLElementTagNameMap>; interface IntrinsicElements extends IAllHtmlElements { } } } export type IMergedControl<T, T1> = { [P in keyof (T & T1)]?: (T & T1)[P]; } & { vsProps: { [P in keyof (T & T1)]?: (T & T1)[P]; }; }; export type NodeFactory = (a?: any, ...nodes: XNode[]) => XNode; export type AttachedNode = (n: any) => { [key: string]: any; }; export declare const xnodeSymbol: unique symbol; export declare const isControl: unique symbol; export declare const elementFactorySymbol: unique symbol; export declare const isFactorySymbol: unique symbol; export declare const attachedSymbol: unique symbol; export declare const isTemplateSymbol: unique symbol; export declare const constructorNeedsArgumentsSymbol: unique symbol; export declare const attachedProperties: { [key: string]: (e: any, v: any) => void; }; export default class XNode { name: string | Function; attributes: IAttributes; children: XNode[] | XNode[][] | any[]; isProperty?: boolean; isTemplate?: boolean; static isFactory: symbol; static elementFactory: symbol; static bindSymbol: symbol; static isTemplate: symbol; static prepareAttached: (name: any, attacher: any) => { (v: any): { [x: string]: any; }; [attachedSymbol]: any; [isFactorySymbol]: string; }; static constructorNeedsArguments: symbol; static classes: { [key: string]: any; }; static attach<T, T1 extends HTMLElementTagNameMap, K extends keyof T1>(n: IClassOf<T>, tag: K): new (...a: any[]) => IMergedControl<T, T1[K]>; static attach<T, T1>(n: IClassOf<T>, tag: (a?: Partial<T1>, ...nodes: XNode[]) => XNode): new (...a: any[]) => IMergedControl<T, T1>; static prepare<T>(n: any, isProperty?: boolean, isTemplate?: boolean): ((attributes: Partial<T>, ...nodes: XNode[]) => XNode); static getClass(fullTypeName: string, assemblyName: string): any; static factory: (name: any, isProperty: any, isTemplate: any) => (a?: any, ...nodes: any[]) => XNode; /** * Declares Root Namespace and Assembly. You can use return function to * to declare the type * @param ns Root Namespace */ static namespace(ns: string, assemblyName: string): (type: string, isTemplate?: boolean) => (c: any) => void; static create(name: string | Function, attributes: IAttributes, ...children: Array<XNode | XNode[] | any>): XNode; nameArgs: any; constructor(name: string | Function, attributes: IAttributes, children: XNode[] | XNode[][] | any[], isProperty?: boolean, isTemplate?: boolean); toString(): string; } //# sourceMappingURL=XNode.d.ts.map