Skip to content

documentTemplatesSubstore

Manages Carbone document templates that can be generated alongside a form submission. The SDK fetches applicable templates for the current session (based on configured form IDs and selected language), tracks which templates the user has selected, and sends the selection to the API on submit.

Templates are fetched automatically when at least one config exists and a language is selected. The query re-runs when the set of form IDs or the language changes.

Table of contents

Properties

Methods


Properties

templatesData

templatesData: ApiResource<{
templates: DocumentTemplate[];
enabled: boolean;
}>

API resource containing the applicable document templates and whether document generation is enabled for the current session.

Each DocumentTemplate has:

FieldTypeDescription
idnumberTemplate ID sent to the API on submit
namestringDisplay name
output_format"pdf" | "docx" | "odt" | "xlsx" | "ods"Generated file format
selection_mode"locked" | "selected" | "deselected"Default selection behaviour (see below)
form_idsnumber[]Forms this template applies to

When enabled is false or no templates apply, templates is an empty array. Your UI can hide the document-template picker in that case.

See ApiResource for loading and error state.

Related


selectedTemplateIds

selectedTemplateIds: Set<number>

Set of template IDs the user has chosen to generate on submit.

Selection is reconciled automatically when the applicable template list changes:

  • locked — always included; cannot be toggled off
  • selected — included by default when the template first appears
  • deselected — not included by default; the user must opt in

Previously selected IDs that are no longer applicable are removed automatically.

Related


documentationsByTemplateId

documentationsByTemplateId: Record<number, TDocumentation[]>

For each selected PDF template, the list of documentation files the customer can include in the generated output.

Documentations are collected from:

  • Form-level documentation attached to the configured form
  • Option-level documentation on currently selected product options

The map is recomputed when templates, language, configs, or selections change. Each TDocumentation entry includes id, display metadata, and selection_mode (locked, selected, or deselected) with the same semantics as templates.

Only templates whose output_format is "pdf" receive documentation lists; other formats keep an empty array.

Related


selectedDocumentationIdsByTemplate

selectedDocumentationIdsByTemplate: Map<number, Set<number>>

Documentation IDs the user chose to merge into each template on submit, keyed by template ID.

Reconciled automatically when the available documentation set changes (same rules as selectedTemplateIds: locked always on, newly appearing selected entries default on, stale IDs removed).

Sent to the API as template_documentations alongside document_template_ids when calling submitSubstore.submit.


Methods

toggleTemplate

toggleTemplate: (templateId: number) => void

Toggles a template in selectedTemplateIds.

Does nothing when the template is not found or its selection_mode is "locked".

Parameters

NameTypeDescription
templateIdnumberID of the template to toggle

Related


toggleDocumentation

toggleDocumentation: (templateId: number, documentationId: number) => void

Toggles a documentation file in selectedDocumentationIdsByTemplate for the given PDF template.

Does nothing when the documentation is not in documentationsByTemplateId or its selection_mode is "locked".

Parameters

NameTypeDescription
templateIdnumberCarbone template ID
documentationIdnumberDocumentation entry to toggle

Related