{# LIBRARIES #}
{{ attach_library('ui_patterns/libraries.bs_forms') }}
{{ attach_library('ui_patterns/form-form.form_lib') }}

{# VARIABLES #}
{% set attributes = attributes|default(create_attribute()) %}
{% set size = size|default('md') %}

{% if type is not empty %}
  {% set attributes = attributes.setAttribute('type', type) %}
  {% if type not in ['checkbox', 'radio'] %}
    {% set classes = ['form-control'] %}
    {% if size in ['sm', 'lg'] %}
      {% set classes = ['form-control', 'form-control-' ~ size] %}
    {% endif %}
  {% endif %}
{% endif %}

{% if placeholder is not empty %}
  {% set attributes = attributes.setAttribute('placeholder', placeholder) %}
{% endif %}

{# TEMPLATE #}
<input {{ attributes.addClass(classes) }} />{{ children }}
