Skip to main content

Function: MnConfig

MnConfig<TComp>(config): (target: DecoratorTarget, targetKey?: string | symbol, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<unknown>) => void

Decorator that mark the property as component config.

The configuration is a set of values specific to the component that can be totally or partially obtained from the component input. The main advantage of the configuration is that its values can be used by decorators such as the MnSubComponent decorator or event decorators. For example MnOnColumnChange.

The associated property must be named config. An other property name is not supported. The config property must define the type of the configuration and the value of the configuration must be set by the decorator parameter.

The Config interface contains the property name constraint. It is recommended to inherit from it when you need to define a config in your component.

Example

Define a simple config (title and description) and fill it with the values "My title" and "My description".

@MnComponent({
scope: {
pageType: "record"
}
})
export class MyComponent implements Config {
@MnConfig({
title: "My title",
description: "My description"
})
config: {
title: string;
description: string;
};
}

Example

Define a component getting partially its configuration from its input.

@MnComponent({
scope: {
pageType: "record"
}
})
export class MyComponent implements Input, Config {
@MnInput()
input: {
title: string;
};

@MnConfig<MyComponent>((input) => ({
title: input.title, // The title is obtained from the input
description: "My description" // The description is a constant
}))
config: {
title: string;
description: string;
};
}

Type parameters

NameType
TCompextends Config = Config

Parameters

NameTypeDescription
configConfigOrConfigMapper<TComp>Configuration values or a function that returns the configuration values from the input.

Returns

fn

▸ (target, targetKey?, indexOrPropertyDescriptor?): void

Parameters
NameType
targetDecoratorTarget
targetKey?string | symbol
indexOrPropertyDescriptor?number | TypedPropertyDescriptor<unknown>
Returns

void

Defined in

packages/core/src/core/metadata/config.ts:67