{#
A generic form input element

Available variables:
  - attributes (object) - A Drupal attributes object for the input element.  Of note, it may include the following:
    - type (enum, REQUIRED) - a valid HTML5 input type
        see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_<input>_types
    - disabled (boolean)
    - placeholder (string)
  - children (renderable) - Optional additional rendered elements.
  - hasErrors (boolean) - whether this input has server-side errors.  If true, this will invoke error styling for this
      field on page load.
#}
{% set attributes = union_attributes(attributes|default([])) %}

{% set _type = attributes.type.__tostring %}

{% set _classes = [
  'cu-input',
  'cu-input--' ~ attributes.type
] %}

{% if hasErrors %}
  {% set _classes = _classes|merge(['is-invalid']) %}
{% endif %}

<input{{ attributes.addClass(_classes) }} />{{ children }}
