{#
/**
 * @file
 * Template for a fieldset component.
 */
#}
{%
  set classes = [
  'js-form-item',
  'form-item',
  'js-form-wrapper',
  'form-wrapper',
  'card',
  'border-0',
  'mb-3',
]
%}
<fieldset{{ attributes.addClass(classes) }}>
  {%
    set legend_span_classes = [
    'fieldset-legend',
    'mb-0',
    required ? 'js-form-required',
    required ? 'form-required',
  ]
  %}
  {#  Always wrap fieldset legends in a SPAN for CSS positioning. #}
  <div class="card-header bg-white border-0 pt-4 pb-3">
    <legend{{ legend.attributes.addClass('m-0') }}>
      <h4{{ legend_span.attributes.addClass(legend_span_classes) }}>
        {{ legend.title }}
      </h4>

      <button class="btn-link">
        <i class="fas fa-chevron-down d-md-none"></i>
      </button>
    </legend>
  </div>
  <div class="card-body p-4 fieldset-wrapper">
    {% if errors %}
      <div>
        {{ errors }}
      </div>
    {% endif %}
    {% if prefix %}
      <span class="field-prefix">{{ prefix }}</span>
    {% endif %}
    {{ children }}
    {% if suffix %}
      <span class="field-suffix">{{ suffix }}</span>
    {% endif %}
    {% if description.content %}
      <small{{ description.attributes.addClass('description', 'form-text', 'text-muted') }}>{{ description.content }}</small>
    {% endif %}
  </div>
</fieldset>
