Archived
1
0
Fork 0
This repository has been archived on 2024-07-25. You can view files and clone it, but cannot push or open issues or pull requests.
paren/lib/nodes.d.ts

33 lines
972 B
TypeScript
Raw Normal View History

import { Nil, Nilable } from "./lang.js";
2022-03-18 22:00:44 +03:00
export declare type AnyNode = TextNode | Elem | Frag | Nil | false;
export declare class TextNode extends String {}
export declare function F(...children: AnyNode[]): Frag;
2022-03-16 22:45:15 +03:00
export declare class Frag {
2022-03-18 22:00:44 +03:00
#private;
constructor();
get children(): Nilable<AnyNode[]>;
withText(text: string): this;
addText(text: string): void;
withChildren(nodes: AnyNode[]): this;
withChild(node: AnyNode): this;
addChild(node: AnyNode): void;
2022-03-16 22:45:15 +03:00
}
2022-03-18 22:00:44 +03:00
export declare function E(
tagName: string,
attrs: ElemAttrs,
...children: AnyNode[]
): Elem;
2022-03-16 22:45:15 +03:00
export declare type ElemAttrs = Record<string, unknown>;
export declare class Elem extends Frag {
2022-03-18 22:00:44 +03:00
#private;
constructor(tagName: string);
get tagName(): string;
get attrs(): Record<string, unknown>;
withAttrs(attrs: Record<string, unknown>): Elem;
withAttr(name: string, value: unknown): Elem;
addAttr(name: string, value: unknown): void;
addChild(node: AnyNode): void;
2022-03-16 22:45:15 +03:00
}