A group of components for cross-component using

Constructors

  • Create a new component space

    The defaultComponent is the default component path. It should be defined soon after creation. A baseSpace can be provided as a "base" component space - every component alias (and behavior alias) in the space will be imported when creation. However, if any new component is added to the base space after the creation, it will not be added to the created space.

    Parameters

    Returns ComponentSpace

Properties

hooks: ComponentSpaceHooks

The hooks used to alter some workflow within this component space.

styleScopeManager: StyleScopeManager

The corresponding styleScopeManager.

A styleScopeManager can be shared by multiple component spaces.

Methods

  • Create a component by URL

    This url can contain params (started with "?" character). The params will try to be set to component properties (if matches the property name).

    Parameters

    • tagName: string
    • url: string
    • genericTargets: null | {
          [name: string]: string;
      }
    • backendContext: null | GeneralBackendContext

    Returns glassEasel.GeneralComponent

  • Register a component or a behavior with chaining API

    Parameters

    • Optional is: string

    Returns glassEasel.BehaviorBuilder<Empty, Empty, Empty, Empty, never, never, Empty>

  • Define a trait behavior

    A trait behavior Optionally, the trait behavior can add a conversion function. This function can convert the implementation to another interface.

    Type Parameters

    • TIn extends {
          [key: string]: any;
      }

    Returns glassEasel.TraitBehavior<TIn, TIn>

  • Type Parameters

    • TIn extends {
          [key: string]: any;
      }
    • TOut extends {
          [key: string]: any;
      }

    Parameters

    Returns glassEasel.TraitBehavior<TIn, TOut>

  • Register a component or a behavior with chaining API (with method caller type specified)

    This API is generally designed for adapters which require special method callers.

    Parameters

    • Optional is: string

    Returns glassEasel.BehaviorBuilder<Empty, Empty, Empty, Empty, never, never, Empty>

  • End a series of components and behaviors registration

    In most cases, groupRegister is prefered.

    Returns void

  • Assign a public alias to a behavior

    The alias can be used in other component spaces which imported this component space. One behavior may have multiple aliases.

    Parameters

    • alias: string
    • is: string

    Returns void

  • Assign a public alias to a component

    The alias can be used in other component spaces which imported this component space. One component may have multiple aliases.

    Parameters

    • alias: string
    • is: string

    Returns void

  • Get a behavior by the path

    Similar to getComponentByUrlWithoutDefault() but for behaviors.

    Parameters

    • path: string
    • relPath: string

    Returns null | glassEasel.GeneralBehavior

  • Get a component by the path

    The component is is actually treated as the "path" of the component. In other words, the component is field can be a string like path/to/the/component . Other components can be used by the component with "relative path" specified. In this method, if the path is given as a relative path (not started with / ), it will be converted according to the basePath . If the path is given as a URL-like format, the component will be searched in imported component spaces ( importSpace() for details).

    Parameters

    • path: string
    • basePath: string

    Returns glassEasel.GeneralComponentDefinition

  • Get a component by the path

    Similar to getComponentByUrl() , but returns null instead of the default component if no component was found.

    Parameters

    • path: string
    • relPath: string

    Returns null | glassEasel.GeneralComponentDefinition

  • Group a series of components and behaviors registration

    If any placeholder should be replaced, the replacement will happen after the whole series of registration.

    Type Parameters

    • R

    Parameters

    • cb: (() => R)
        • (): R
        • Returns R

    Returns undefined | R

  • Import another component space

    The components in the imported space can be used by components in this space. The protoDomain should be URL-like, i.e. space://another-space . When using, the components in the imported space should be specified with protoDomain . For example, if protoDomain is space://another-space and one imported component has alias my-comp , then it should be specified with space://another-space/my-comp . If privateUse set to false, only component alias in the imported space can be used; the original name of components is imported otherwise.

    Parameters

    Returns void

  • Set a listener which will be called when a placeholded component is used.

    This can be used as a hint for a component that should be registered later. If isPub is false, the alias is the path of the component, a.k.a. is . Otherwise, it is the exported alias instead.

    Parameters

    • listener: null | ((isPub, alias, owner) => void)

    Returns void

  • Set (or update) a global using component item

    This will allow all the components in this component space using this component automatically, without declaring it with using or usingComponents again. The target can also be a tag name of a native node.

    Parameters

    Returns void

  • Mark a style scope as shared

    This style scope will not be written to backend as a dedicated style scope for a component.

    Parameters

    • styleScopeId: number

    Returns void

  • Start a series of components and behaviors registration

    In most cases, groupRegister is prefered.

    Returns void

  • Update the default component options for this space

    The new options will be merged with existing options.

    Parameters

    Returns void