{#
/**
 * @file
 * Default theme implementation for a fieldset element and its children.
 *
 * Available variables:
 * - attributes: HTML attributes for the <fieldset> element.
 * - errors: (optional) Any errors for this <fieldset> element, may not be set.
 * - required: Boolean indicating whether the <fieldset> element is required.
 * - legend: The <legend> element containing the following properties:
 *   - title: Title of the <fieldset>, intended for use as the text
       of the <legend>.
 *   - attributes: HTML attributes to apply to the <legend> element.
 * - description: The description element containing the following properties:
 *   - content: The description content of the <fieldset>.
 *   - attributes: HTML attributes to apply to the description container.
 * - description_display: Description display setting. It can have these values:
 *   - before: The description is output before the element.
 *   - after: The description is output after the element (default).
 *   - invisible: The description is output after the element, hidden visually
 *     but available to screen readers.
 * - children: The rendered child elements of the <fieldset>.
 * - prefix: The content to add before the <fieldset> children.
 * - suffix: The content to add after the <fieldset> children.
 *
 * @see template_preprocess_fieldset()
 *
 * @ingroup themeable
 */
#}
{%
  set classes = [
    'js-form-item',
    'form-item',
    'js-form-wrapper',
    'form-wrapper',
  ]
%}
{%
  set legend_classes = [
    'fr-fieldset__legend',
    'fr-fieldset__legend--regular',
    required ? 'js-form-required',
    required ? 'form-required',
  ]
%}
<div class="fr-form-group">
  <fieldset{{ attributes.setAttribute('role', 'group').addClass(classes) }}>
    <legend{{ legend.attributes.addClass(legend_classes) }}>{{ legend.title }}
      {% if description.content %}
        <span class="fr-hint-text">{{ description.content }}</span>
      {% endif %}
    </legend>
    <div class="fr-fieldset__content">
      {% if prefix %}
        <span class="field-prefix">{{ prefix }}</span>
      {% endif %}
      {{ children }}
      {% if suffix %}
        <span class="field-suffix">{{ suffix }}</span>
      {% endif %}
    </div>
    {% if errors %}
      <div id="{{ error_id }}" class="fr-error-group">
        <p class="fr-message--error">
          {{ errors }}
        </p>
      </div>
    {% endif %}
  </fieldset>
</div>
