UNPKG

@lifeart/gxt

Version:

<img align="right" width="95" height="95" alt="Philosopher’s stone, logo of PostCSS" src="./public/logo.png">

102 lines (100 loc) • 6.91 kB
import { Component, ComponentReturnType } from './component-class'; import { Root, createRoot, resolveRenderable } from './root'; import { DOMApi, GenericReturnType, Slots, ComponentRenderTarget, RENDERING_CONTEXT_PROPERTY, RENDERED_NODES_PROPERTY, COMPONENT_ID_PROPERTY } from './types'; import { Cell, MergedCell } from './reactive'; import { SyncListComponent, AsyncListComponent, InverseFn } from './control-flow/list'; import { DestructorFn } from './glimmer/destroyable'; import { SVGProvider, HTMLProvider, MathMLProvider } from './provider'; import { IfCondition, IfFunction } from './control-flow/if'; import { pushParentContext, popParentContext, setParentContext, getParentContext } from './tracking'; import { $_MANAGERS } from './manager-integration'; export { Root, createRoot, resolveRenderable }; export { pushParentContext, popParentContext, setParentContext, getParentContext }; type ModifierFn = (element: HTMLElement, ...args: unknown[]) => void | DestructorFn; type Attr = MergedCell | Cell | string | ((element: HTMLElement, attribute: string) => void); type TagAttr = [string, Attr]; type TagProp = [string, Attr]; type TagEvent = [string, EventListener | ModifierFn]; type FwType = [TagProp[], TagAttr[], TagEvent[]]; type Props = [TagProp[], TagAttr[], TagEvent[], FwType?]; type InElementFnArg = () => HTMLElement; type BranchCb = (ctx: IfCondition) => GenericReturnType | Node | null; export declare const $_edp: Props; export declare const $_emptySlot: Readonly<{}>; export declare const $SLOTS_SYMBOL: unique symbol; export declare const $PROPS_SYMBOL: unique symbol; export declare const $_SVGProvider: typeof SVGProvider; export declare const $_HTMLProvider: typeof HTMLProvider; export declare const $_MathMLProvider: typeof MathMLProvider; export { $_MANAGERS }; export declare function $_TO_VALUE(reference: unknown): unknown; /** * Unwrap a helper argument - if it's a getter function, call it to get the actual value. * If it's a Tag (reactive cell), get its .value property. */ export declare function $_unwrapHelperArg(value: unknown): unknown; /** * Component helper - curries a component with pre-bound args. * Handles both class/function components and string component names. */ export declare function $_componentHelper(params: any[], hash: Record<string, unknown>): (args: Record<string, unknown>) => any; /** * Modifier helper - curries a modifier with pre-bound args. */ export declare function $_modifierHelper(params: any[], hash: Record<string, unknown>): (node: HTMLElement, _params: any[], _hash: Record<string, unknown>) => any; /** * Helper helper - curries a helper with pre-bound args. */ export declare function $_helperHelper(params: any[], hash: Record<string, unknown>): unknown; export declare function incrementNodeCounter(): void; export declare function resetNodeCounter(): void; export declare function getNodeCounter(): number; export declare function $_hasBlock(slots: Record<string, unknown>, name?: string): boolean; export declare function $_hasBlockParams(slots: Record<string, unknown>, slotName?: string): unknown; declare function _DOM(tag: string | (() => string), tagProps: Props, ctx: any, children?: (ComponentReturnType | string | Cell | MergedCell | Function)[]): Node; export declare function $_inElement(elementRef: HTMLElement | Cell<HTMLElement> | InElementFnArg, roots: (context: Component<any>) => (Node | ComponentReturnType)[], ctx: any): any; export declare function $_ucw(roots: (context: Component<any>) => (Node | ComponentReturnType)[], ctx: any): ComponentReturnType; export declare function $_GET_SCOPES(hashOrCtx: Record<string, unknown> | any, ctx?: any): any; export declare const $_maybeHelper: (value: any, args: any[], _hashOrCtx?: Record<string, unknown> | any, // Hash object for known bindings, context for unknown, or undefined _maybeCtx?: any) => any; export declare function $_unwrapArgs(args: any[]): any[]; declare function component(comp: ComponentReturnType | Component | typeof Component, args: Record<string, unknown>, ctx: Component<any> | Root): any; declare function slot(name: string, params: () => unknown[], $slot: Slots, ctx: any): Comment | Component<any> | IfCondition | AsyncListComponent<any> | SyncListComponent<any>; declare function ifCond(cell: Cell<boolean> | MergedCell | IfFunction, trueBranch: BranchCb, falseBranch: BranchCb, ctx: Component<any>): Component<any> | IfCondition | AsyncListComponent<any> | SyncListComponent<any>; export declare function $_eachSync<T extends { id: number; }>(items: Cell<T[]> | MergedCell, fn: (item: T) => Array<ComponentReturnType | Node>, key: string | null | undefined, ctx: Component<any>, inverseFn?: InverseFn, hasIndex?: boolean): Component<any> | IfCondition | AsyncListComponent<any> | SyncListComponent<any>; export declare function $_each<T extends { id: number; }>(items: Cell<T[]> | MergedCell, fn: (item: T) => Array<ComponentReturnType | Node>, key: string | null | undefined, ctx: Component<any>, inverseFn?: InverseFn, hasIndex?: boolean): Component<any> | IfCondition | AsyncListComponent<any> | SyncListComponent<any>; export declare function $_GET_ARGS(ctx: Component<any>, args: IArguments): void; export declare function $_GET_SLOTS(ctx: any, args: any): any; export declare function $_GET_FW(ctx: any, args: any): any; export declare function $_args(args: Record<string, unknown>, slots: Record<string, () => Array<ComponentReturnType | Node>> | false, props: FwType): {}; export declare const $_if: typeof ifCond; export declare const $_slot: typeof slot; export declare const $_c: typeof component; export declare function $_dc(comp: () => ComponentReturnType | Component, args: Record<string, unknown>, ctx: Component<any>): { [RENDERING_CONTEXT_PROPERTY]: DOMApi | undefined; [COMPONENT_ID_PROPERTY]: number; [RENDERED_NODES_PROPERTY]: Node[]; }; export declare const $_component: (component: any) => any; export declare const $_maybeModifier: (modifier: any, element: HTMLElement, props: any[], hashArgs: () => Record<string, unknown>) => any; export declare const $_helper: (helper: any) => any; export declare const $_tag: typeof _DOM; export declare const $_api: (ctx: any) => DOMApi; export declare function $_fin(roots: Array<ComponentReturnType | Node>, ctx: Component<any> | AsyncListComponent<any> | SyncListComponent<any> | IfCondition): Component<any> | IfCondition | AsyncListComponent<any> | SyncListComponent<any>; /** * Get the target element for rendering. */ export declare function targetFor(outlet: ComponentRenderTarget): HTMLElement | DocumentFragment; /** * Render a component to a target element. * This is the main entry point for rendering an application. */ export declare function renderComponent(comp: typeof Component<any>, params?: { owner?: Root; args?: Record<string, unknown>; element?: ComponentRenderTarget; }): ComponentReturnType;