UNPKG

@surface/custom-element

Version:

Provides support of directives and data binding on custom elements.

27 lines (26 loc) 1.08 kB
import type ICustomElement from "../interfaces/custom-element"; declare type Serializer = { parse: (value: string) => unknown; stringfy?: (value: unknown) => string; }; declare type Types = typeof Boolean | typeof Number | typeof String; declare type AttributeOptions = { /** Type to be converted or serializer that will handle the conversion. */ type: Types | Serializer; /** Attribute name */ name?: string; }; /** * Keep sync between attribute and the decorated property. * @param type type to be converted. */ declare function attribute(type: Types): (target: ICustomElement, propertyKey: string) => void; /** * Keep sync between attribute and the decorated property. * @param options attribute sync options. */ declare function attribute(options: AttributeOptions): (prototype: ICustomElement, propertyKey: string) => void; /** Keep sync between attribute and the decorated property. */ declare function attribute(prototype: ICustomElement, propertyKey: string): void; export { AttributeOptions }; export default attribute;