Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

CallbackPropType

CallbackPropType<T>: T | [func: T, thisArg?: any] | { func: T; thisArg?: any }

Type that can be passed as a callback to a component's property. It allows passing a callback in one of the following forms:

  • as a function object. Note that if the function is a method of another component (or just a class), then it should be wrapped (using the wrap method) so that the this parameter is properly set up when the callback is invoked.
  • a two element tuple. The first element is the function to be called and the second element is the value to be used as the this parameter.
  • an object with the properties func specifying the function to be called and thisArg specifying the value to be used as the this parameter.

Type parameters

  • T: Function = Function

CallbackWrappingOptions

CallbackWrappingOptions: { arg?: any; comp?: IComponent | null; thisArg?: any; tickType?: TickSchedulingType }

Type defining the options that can be supplied for a callback to be wrapped

Type declaration

  • Optional arg?: any

    Argument that is supplied to the callback as a last parameter.

  • Optional comp?: IComponent | null

    Component that will be set as a current component when the callback is invoked.

  • Optional thisArg?: any

    Object that will be referenced by "this" within the callback function

  • Optional tickType?: TickSchedulingType

    Type of scheduling the Mimbl tick after the callback function returns.

ComponentProps

ComponentProps<TProps, TEvents>: Readonly<TProps> & { readonly [ K in keyof TEvents & string as `$on_${K}`]?: EventPropType<TEvents[K] extends Event ? TEvents[K] : CustomEvent<TEvents[K]>> }

Type that combines readonly component properties and component events. For each event, the ComponentProps type defines a property named $on_event, where "event" is the name of the property from the TEvents generic type. This allows attaching to component events in JSX just like attaching to HTML element events.

The ComponentProps is not usually used directly by developers; however, it defines the type of the props property in the IComponent interface that all class-based components implement.

Example:

// Component properties
interface IMyCompProps
{
title?: string
}

// Component events
interface IMyCompEvents
{
titleChanged?: string;
}

// the following component
class MyComp extends Component<IMyCompProps,IMyCompEvents> {...}

// would have its properties type equivalent to
type PropsAndEvents =
{
readonly title?: string;
readonly $on_titleChanged?: EventPropType<CustomEvent<string>>;
}

// this allows using MyComp as the following
<MyComp title="Hello" $on_titleChanged={e => console.log(`Title changed to ${e.detail}`)}

Type parameters

  • TProps: {} = {}

    Type defining properties that can be passed to the class-based component of this type. Note that if the component is expected to accept children then the TProps object must have the cildren property (usually of the any type). Default type is an empty object (no properties and no children).

  • 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. Default type is an empty object (no events).

ComponentShadowOptions

ComponentShadowOptions: boolean | string | ShadowRootInit | [tag: string, init: ShadowRootInit]

Type for the shadow property in the IComponent interface. This can be one of the following:

  • boolean - if the value is true, a <div> element will be created and shadow root attached to it with mode "open".
  • string - an element with this name will be created and shadow root attached to it with mode "open".
  • ShadowRootInit - a <div> element will be created and shadow root attached to it with the given initialization prameters.
  • two-item tuple - the first item is the name of the element to create and attach a shadow root to; the second item specifies the shadow root initialization prameters.

DN

DN: Node | null

ElmRefPropType

ElmRefPropType<T>: RefPropType<IElmVN<T>>

Type of vnref property that can be passed to JSX elements.

Type parameters

  • T: Element = Element

ElmRefType

ElmRefType<T>: RefType<IElmVN<T>>

Type of the vnref property value.

Type parameters

  • T: Element = Element

EventFuncType

EventFuncType<T>: (e: T, arg?: any) => void

Type parameters

  • T: Event = Event

    DOM event type, e.g. MouseEvent

Type declaration

    • (e: T, arg?: any): void
    • Type of event handler function for DOM events of type T.

      Parameters

      • e: T

        Event object

      • Optional arg: any

        Optional parameter, which is defined only if it was passed when the callback was wrapped - that is, in the arg property of the EventObjectType object or in the 2nd item of the EventTupleType tuple.

      Returns void

EventPropType

EventPropType<T>: EventFuncType<T> | EventTupleType<T> | EventObjectType<T>

Union type that can be passed to an Element's event.

Type parameters

  • T: Event = Event

    DOM event type, e.g. MouseEvent

EventTupleType

EventTupleType<T>: [func: EventFuncType<T>, arg?: any, thisArg?: any]

Type defining a tuple that can be supplied for an event listener.

Type parameters

  • T: Event = Event

    DOM event type, e.g. MouseEvent

ExtendedAttrs

ExtendedAttrs<T>: { [ K in keyof T]?: T[K] | null | (K extends NoTriggerAttrNames ? never : ITrigger<T[K]>) }

Converts the given interface T to a type that maps an extended attribute type to each property of T. The extended property contains the property type, the ITrigger for this type as well as null and undefined. This is primarily useful for defining attributes of HTML elements - both built-in and custom.

Example:

interface IMyAttrs
{
foo: string;
bar: number;
}

type MyExtendedAttrs = ExtendedAttrs<IMyAttrs>;

// the MyExtendedEvents is equivalent to the following interface
interface MyExtendedAttrs
{
foo: string | ITrigger<string> | null | undefined;
bar: number | ITrigger<number> | null | undefined;
}

Type parameters

  • T

ExtendedElement

ExtendedElement<TRef, TAttrs, TEvents, TChildren>: ExtendedAttrs<TAttrs> & ExtendedEvents<TEvents> & { children?: TChildren; key?: string | number | bigint | symbol | Function | object; ref?: RefPropType<TRef>; updateStrategy?: UpdateStrategy; vnref?: ElmRefPropType<TRef> }

Represents intrinsic element attributes, events and children known to Mimbl infrastucture. Each built-in or custom element is defined as a JSX intrinsic element using the ExtendedElement type by passing the correct attribute, event and children types.

typeparam TAttr

Type listing element's attribute names mapped to attribute types.

Type parameters

  • TRef: Element = Element

    Type that can be passed to the ref attribute to get a reference to the element.

  • TAttrs: IElementAttrs = IElementAttrs

  • TEvents: IElementEvents = IElementEvents

    Type listing element's event names mapped to event types. Most elements don't need to specify this type parameter as they only implement standard events; however, there are some elements - e.g.

  • TChildren = any

    Type that determines what children are allowed under the element. It defaults to any and usually doesn't need to be specified.

ExtendedEvents

ExtendedEvents<T>: { [ K in keyof T]?: T[K] extends Event ? EventPropType<T[K]> : EventPropType<CustomEvent<T[K]>> }

Converts the given interface T to a type that maps an event type to each property of T. If the property is iself an event (that is, derives from the Event interface), this event becomes the type of the mapped property. Otherwise, the property is mapped to a CustomEvent type whose detail property is defined as the original property type.

Example:

interface IMyEvents
{
foo: string;
bar: number;
baz: MouseEvent;
}

type MyExtendedEvents = ExtendedEvents<IMyEvents>;

// the MyExtendedEvents is equivalent to the following interface
interface MyExtendedEvents
{
foo: CustomEvent<string>;
bar: CustomEvent<number>;
baz: MouseEvent;
}

Type parameters

  • T

NoTriggerAttrNames

NoTriggerAttrNames: "xmlns"

Internal type containing names of attributes that are not "triggerized" when applying the ExtendedAttrs type to the element attributes interface.

RefFunc

RefFunc<T>: (newRef: T) => void

Type parameters

  • T = any

Type declaration

    • (newRef: T): void
    • Defines event handler that is invoked when reference value changes.

      Parameters

      • newRef: T

      Returns void

RefPropType

RefPropType<T>: T | RefType<T>

Type of ref property value. This can be either the {@link IRef]] interface or [[RefFunc} function or the type itself.

Type parameters

  • T = any

RefType

RefType<T>: IRef<T> | RefFunc<T>

Type of ref property that can be passed to JSX elements and components. This can be either the {@link IRef]] interface or [[RefFunc} function.

Type parameters

  • T = any

RenderMethodType

RenderMethodType: (arg?: any) => any

Type declaration

    • (arg?: any): any
    • Definition of type of method that renders content.

      Parameters

      • Optional arg: any

      Returns any

ScheduledFuncType

ScheduledFuncType: (arg?: any) => void

Type declaration

    • (arg?: any): void
    • Type of functions scheduled to be called either before or after the update cycle.

      Parameters

      • Optional arg: any

      Returns void

UpdateStrategy

UpdateStrategy: { disableKeyedNodeRecycling?: boolean; ignoreKeys?: boolean }

The UpdateStrategy object specifies different aspects of update behavior of components and elements.

Type declaration

  • Optional disableKeyedNodeRecycling?: boolean

    Flag determining whether or not non-matching new keyed sub-nodes are allowed to recycle non- matching old keyed sub-nodes. Here "non-matching" means those new or old nodes with keys for which no old or new sub-nodes with the same key were found. If this flag is true, then non-matching old sub-nodes will be removed and non-matching new sub-nodes will be inserted. If this flag is false, then non-matching old sub-nodes will be updated by the non-matching new sub-nodes - provided that the types of sub-nodes are the same.

    If keyed sub-nodes recycling is enabled it can speed up an update process because less DOM nodes get removed and inserted, which is more expensive than updating. However, this can have some adverse effects under cirtain circumstances if certain data is bound to the particular instances of DOM nodes.

    The flag's default value is false, that is, recycling is enabled.

  • Optional ignoreKeys?: boolean

    Flag determining whether the reconciliation procedure should not pay attention to the keys. This flag is complimentary to the disableKeyedNodeRecycling flag and take effect only if the latter is false (or undefined). When the ignoreKeys flag is false (default) we try to match new sub-nodes to old ones using keys. Setting the ignoreKeys flag to true completely ignores keys and the matching is done by going through the lists of the new and old sub-nodes sequentially. Under certain circumstances this may speed up the reconciliation process

    The flag's default value is false, that is, keys are used for matching the nodes.