Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

WebElmAttrDefinition

WebElmAttrDefinition: { attrName: string; options?: WebElmAttrOptions; propName?: string }

Structure defining options that determine an attribute behavior.

Type declaration

  • attrName: string

    Name of the element attribute. This is always defined

  • Optional options?: WebElmAttrOptions

    Optional converter function and some other options controlling the attribute's behavior

  • Optional propName?: string

    Name of the element property. This can be undefined if the attribute definition was created not via the @attr decorator but either in the @webElm decorator or in the registerWebElm function. This can be useful if there is no need to have a property reflecting the attribute in the custom Web elemetn class, but there is a need to be notified when the attribute's value is changed.

Functions

Const WebElm

  • Function that returns a class from which regular custom Web elements (which don't need to customize existing built-in elements) should inherit. The return class derives directly from HTMLElement.

    Usage:

    @mim.webElm("my-elelemnt")
    class MyCustomElement extends mim.WebElm()
    {
    render(): any { return ... }
    }

    Type parameters

    • TAttrs: {} = {}

      Type that maps attribute names to attribute types.

    • TEvents: {} = {}

      Type that maps event names (a.k.a event types) to either Event-derived classes (e.g. MouseEvent) or any other type. The latter will be interpreted as a type of the detail property of a CustomEvent.

    Returns WebElmConstructor<HTMLElement, TAttrs, TEvents>

WebElmEx

  • WebElmEx<TElm, TAttrs, TEvents>(elmClass: new () => TElm): WebElmConstructor<TElm, TAttrs, TEvents>
  • Creates and returns a new class from which custom Web elements should derive. The class returned from this function inherits from the HTMLElement-derived class specified as the parameter and implements the IComponent and IComponentEx interfaces.

    Usage:

    @mim.webElm("custom-button")
    class MyCustomButton extends mim.WebElmEx(HTMLButtonElement)
    {
    render(): any { return ... }
    }

    Type parameters

    • TElm: HTMLElement = HTMLElement

      Class deriving from HTMLElement, from which the resulting class will inherit.

    • TAttrs: {} = {}

      Type that maps attribute names to attribute types.

    • TEvents: {} = {}

      Type that maps event names (a.k.a event types) to either Event-derived classes (e.g. MouseEvent) or any other type. The latter will be interpreted as a type of the detail property of a CustomEvent.

    Parameters

    • elmClass: new () => TElm

      HTMLElement-derived class from which the returned class will derive.

        • new (): TElm
        • Returns TElm

    Returns WebElmConstructor<TElm, TAttrs, TEvents>

    Class that inherits from the given HTMLElement-derived class that imlements all the internal logic of custom Web elements.

attr

  • Decorates a property of custom Web Element class without providing any options. The name of the HTML attribute is set to be the name of the property.

    Parameters

    • target: any

      Custom Web Element class

    • propName: string

      Property name to which the decorator was applied

    Returns any

  • Decorates a property of custom Web Element class specifying the name of the HTML attribute.

    Parameters

    • attrName: string

      Name of HTML attribute to be reflected by the property.

    Returns any

  • Decorates a property of custom Web Element class specifying some attribute options.

    Parameters

    Returns any

  • Decorates a property of custom Web Element class specifying the name of the HTML attribute and some attribute options.

    Parameters

    • attrName: string

      Name of HTML attribute to be reflected by the property.

    • attrOptions: WebElmAttrOptions

      Options defining attribute/property behavior.

    Returns any

Const attrToBool

  • attrToBool(stringValue: undefined | null | string, attrName: string): any
  • Built-in attribute converter that converts string value to a Boolean value.

    Parameters

    • stringValue: undefined | null | string
    • attrName: string

    Returns any

Const attrToFloat

  • attrToFloat(stringValue: undefined | null | string, attrName: string): any
  • Built-in attribute converter that converts string value to a number.

    Parameters

    • stringValue: undefined | null | string
    • attrName: string

    Returns any

Const attrToInt

  • attrToInt(stringValue: undefined | null | string, attrName: string): any
  • Built-in attribute converter that converts string value to an integer number.

    Parameters

    • stringValue: undefined | null | string
    • attrName: string

    Returns any

Const attrToObj

  • attrToObj(stringValue: undefined | null | string, attrName: string): any
  • Built-in attribute converter that converts string value to a Boolean value.

    Parameters

    • stringValue: undefined | null | string
    • attrName: string

    Returns any

Const objToAttr

  • objToAttr(value: any, attrName: string): null | string
  • Built-in converter that converts property object value to a string by using JSON.stringify.

    Parameters

    • value: any
    • attrName: string

    Returns null | string

registerWebElm

  • Registers the given Web Element with optional parameters.

    Parameters

    • webElmClass: WebElmConstructor<HTMLElement, {}, {}>

      custom Web Element class

    • Optional name: string

      Name of the custom Web Element to use in HTML

    • Optional options: WebElmOptions

      Shadow DOM and form-related options

    • Optional attrs: WebElmAttrDefinition[]

      Information about the element's attributes

    Returns void

webElm

  • Decorator function for custom element components.

    Parameters

    Returns any