import type nunjucks from 'nunjucks' import { component } from '@ministryofjustice/hmpps-forge/core/components' import type { BlockDefinition, ComponentOptions, ForgeComponent } from '@ministryofjustice/hmpps-forge/core/components' /** * Defines a Nunjucks component from a single block interface - `component()` with the * renderer pinned, so the render callback receives a typed `nunjucks.Environment`. * * @example * ```typescript * export interface MyTextInput extends FieldBlockDefinition { * label: ResolvableString * } * * export const MyTextInput = nunjucksComponent('myTextInput', { * field: true, * render: (props, nunjucksEnv) => * nunjucksEnv.render('components/text-input.njk', { params: { name: props.code } }), * }) * ``` */ export function nunjucksComponent( variant: string, options: ComponentOptions, ): ForgeComponent { return component(variant, options) }