Interface Dynamic<Component, Config>

Provides the TRL / client side configuration object to load a Svelte component that is suitable to use with TJSSvelte.API.Config.parseConfig.

Defines a dynamic config that allows the context and props properties to also be defined as a function that returns an object of properties to respectively load into given component. This can be useful when defining a config in a static context where it is helpful to pass an instance / this reference when defining context and props.

See Config.Embed or Config.Standard that narrows the type accepted for context and props to just an object.

interface Dynamic<
    Component extends SvelteComponent = SvelteComponent,
    Config extends
        {
            ContextOmit?: keyof NonNullable<Config["ContextShape"]>;
            ContextShape?: { [key: string]: any };
            PropsOmit?: keyof ComponentProps<Component>;
        } = { ContextOmit: never; ContextShape: {}; PropsOmit: never },
> {
    anchor?: Element;
    class: new (
        options: ComponentConstructorOptions<ComponentProps<Component>>,
    ) => Component;
    context?: NarrowContextObject<Config> | NarrowContextFunction<Config>;
    intro?: boolean;
    props?:
        | Partial<Omit<ComponentProps<Component>, Config["PropsOmit"]>>
        | NarrowPropsFunction<Component, Config>;
    target?: Element | Document | ShadowRoot;
}

Type Parameters

  • Component extends SvelteComponent = SvelteComponent

    A specific component to narrow the allowed class and props.

  • Config extends {
        ContextOmit?: keyof NonNullable<Config["ContextShape"]>;
        ContextShape?: { [key: string]: any };
        PropsOmit?: keyof ComponentProps<Component>;
    } = { ContextOmit: never; ContextShape: {}; PropsOmit: never }

    Additional options to omit properties from allowed in context or props.

Properties

anchor?: Element

A child of target to render the component immediately before.

The Svelte component class / constructor function.

context?: NarrowContextObject<Config> | NarrowContextFunction<Config>

The root-level additional data to add to the context passed to the component.

intro?: boolean

If true, will play transitions on initial render, rather than waiting for subsequent state changes.

props?:
    | Partial<Omit<ComponentProps<Component>, Config["PropsOmit"]>>
    | NarrowPropsFunction<Component, Config>

Props to pass to the component. You may define props as an object or a function returning an object.

The target to render component to. By default, document.body is used as the target if not otherwise defined.