Ship the disclosure as a single-directory component so it can be placed in Canvas or rendered from code

The disclosure can only be rendered two ways today: through the field formatter, or by calling the ai_disclosure theme hook from code. Neither helps a site builder who assembles a page in Canvas/Experience Builder, or a themer who wants the label in a template. A single-directory component makes the same markup placeable by hand, includable with {{ include('ai_disclosure:ai-disclosure', {...}) }}, and renderable from code with #type: 'component' — useful whenever the disclosure is not a field on the entity being rendered (an AI-assembled page, a block, a listing, a printed report).

Proposed resolution: move templates/ai-disclosure.html.twig to components/ai-disclosure/ai-disclosure.twig with a ai-disclosure.component.yml, move the CSS into the component's own library, and have AiDisclosureDefaultFormatter build #type: 'component' instead of #theme: 'ai_disclosure'. Everything the formatter computes (visibility policy, resolution, icon variant) stays where it is — the component only receives the result.

Props, from the current theme variables:

  • sentence (string, required) — the grade's disclosure sentence.
  • legal (string) — the site's notice line shown when the label is legally required.
  • summary (string, default "How was AI used?") — the details summary.
  • details_open (boolean, default false).
  • statement_lead, statement_text (string), statement_url (string, format uri-reference) — the editorial statement link.
  • style (enum: card, plain, default card).
  • label_required (boolean) — drives the --required / --voluntary modifier only.
  • grade_id (string) — kept as a class hook so themes can still style per grade.
  • eu_icon (enum: none, ai, ai_generated, ai_modified) and icon_variant (enum: site, light, dark, auto) instead of today's nested icon array — a nested object is not usable in a Canvas props form.

Slot: description — the rendered "How AI was used" markdown, which is filtered HTML and does not belong in a string prop.

Every prop needs a title and description in the YAML, since those become the Canvas form labels, and the component should render correctly with sentence alone so a manual placement is not a validation error.

Open questions:

  • Icon URLs. The component only gets machine names, so something has to turn them into paths. A preprocess hook for the component calling ai_disclosure.icons keeps the props Canvas-friendly; explicit icon_light/icon_dark URL props would keep the component service-free but push the work onto every caller. Preprocess looks right, with URL props as an escape hatch.
  • The ai_disclosure theme hook. Keeping it as a thin wrapper around the component preserves existing template overrides; deprecating it is cleaner. Note that the per-grade and per-entity-type theme suggestions in ai_disclosure_theme_suggestions_ai_disclosure() have no SDC equivalent — a theme overrides a component wholesale, not per suggestion — so dropping the hook drops that capability.
  • Whether card/plain stays a prop or becomes two components.

Tests: a kernel test rendering the component with only the required prop and with the full set, plus the existing formatter tests unchanged to prove the output did not move.