@muban/muban
Version:
Writing components for server-rendered HTML
34 lines (33 loc) • 1.8 kB
TypeScript
import type { ComponentTemplateResult } from '@muban/template';
import type { Ref } from '@vue/reactivity';
import type { RefElementType, ElementRef } from '../refs/refDefinitions.types';
import type { BindMapBinding, CollectionBinding, ComponentBinding, ComponentCollectionBinding, ElementBinding, SimpleComponentApi, TemplateBinding } from './bindingDefinitions';
import type { bindingsList } from './bindings';
export declare type TemplateProps<T extends RefElementType> = {
ref: ElementRef<T, BindProps> | undefined;
extract?: {
config: any;
onData: (data: any) => void;
};
forceImmediateRender?: boolean;
onUpdate: (onlyWatch: boolean) => ComponentTemplateResult | undefined;
};
export declare type Binding = ElementBinding<RefElementType, BindProps> | CollectionBinding<RefElementType, BindProps> | ComponentBinding<SimpleComponentApi> | ComponentCollectionBinding<SimpleComponentApi> | TemplateBinding<RefElementType> | BindMapBinding;
export declare type BindingValue<T> = Ref<T>;
export declare type BindingMap<T> = Ref<Record<string, T>> | Record<string, Ref<T>>;
declare global {
interface DomBindings {
}
}
declare type BindingsList = typeof bindingsList & DomBindings;
export declare type BindProps = {
[P in keyof BindingsList]?: Parameters<BindingsList[P]>[1];
};
export declare type BindingsHelpers = {
hasBinding: <T extends keyof BindProps>(bindingName: T) => boolean;
getBinding: <T extends keyof BindProps>(bindingName: T) => BindProps[T];
setBinding: <T extends keyof BindProps>(bindingName: T, bindingValue: BindProps[T]) => void;
};
export declare type DataBinding<T> = (element: HTMLSelectElement, value: T | Ref<T>) => void;
export declare type StyleBindingProperty = string | null | undefined | false;
export {};