cadrumo.application.wizard._format_hints module

Post-bridge decoration for the bridged setup FlowDefinition.

The wizard catalogue predates the paged flow’s format_hint copy slot and its shape-validated DATE / DECIMAL widget kinds, so the bridge projects every free-text question as a plain TEXT page with no hint. This module owns two page-keyed override maps and applies both in a single post-projection walk — the same post-bridge decoration seam as the legal-zone projection, so the substrate’s bridge stays domain-blind:

  • PAGE_FORMAT_HINTS attaches the shared wizard.setup.format.* hint keys (worked examples for identity documents, ISO dates, euro amounts, postcodes, and unit counts).

  • PAGE_WIDGET_KINDS upgrades the shape-bearing free-text pages to the substrate’s first-class DATE (ISO-8601) and DECIMAL widget kinds, so the engine’s built-in shape validation refuses a malformed date or amount before commit. The format-hint ref stays as authored — the widget adds live verification on top of the worked-example copy.

The key constants carry the _LOCALE_KEYS suffix so the locale scaffold’s AST scanner treats them as live usage (these keys are referenced only through this mapping, never at a literal tr() call site). The widget override adds no copy, so it needs no locale key. The keys a sibling flow module also authors pages against are public names here – this module is their single home, so a sibling references the declaration rather than restating the string.

PAGE_WIDGET_KINDS: Mapping[str, FlowWidgetKind]

Shape-bearing free-text pages upgraded from the projected TEXT default to a first-class shape-validated widget kind. The DATE pages are ISO-8601 calendar dates; the DECIMAL pages are Decimal quantities (the INCN euro amount and the módulos unit counts, which are fractional). Each carries answer_type = str after projection and no choices, so the override yields a valid non-choice page.

attach_format_hints(definition)[source]

Return definition decorated with format hints and widget kinds.

One walk applies both overrides. A page in PAGE_FORMAT_HINTS that carries no hint yet (a future catalogue- or bridge-supplied one wins) gains its format-hint CopyRef; a page in PAGE_WIDGET_KINDS is upgraded to its shape-validated widget kind. A page in both maps receives both updates in a single model_copy; every other page passes through untouched.

Return type:

FlowDefinition

Parameters:

definition (FlowDefinition)