← @mortar-kit/core

Brickinterface

import { Brick } from '@mortar-kit/core'

interface Brick<F extends Fields = Fields, L = undefined, R = undefined> extends SchemaOps<F>

A registered brick. defaults() is used when the brick is added to a body.

Properties

readonly name: string
readonly label: string
readonly schema: F
readonly load: ((data: InferFields<F>, content: ContentReader) => L | Promise<L>) | undefined
readonly action: ((input: ActionInput<InferFields<F>>) => R | Promise<R>) | undefined
readonly interactive: boolean

Whether the brick hydrates on its own on pages without JavaScript (see BrickDefinition.interactive).

readonly component: Component<BrickProps<InferFields<F>, L, R>>
defaults: () => InferFields<F>

Fresh default data.

validate: (data: unknown) => ValidateResult<InferFields<F>>

Validates (and fills defaults into) unknown data.

normalize: (data: unknown) => InferFields<F>

Coerces unknown data into the schema's shape for rendering: missing fields get defaults, and fields of the wrong type are replaced by their default. Values that are the right type but break a rule (an empty required text) are kept, so a preview shows what the editor typed.