{%- set class_name = [
"f-text",
"d-flex flex-column gap-1 u-posr",
props.extra_class ? props.extra_class : null,
props.icon_before ? "--icon-before" : null,
props.icon_after ? "--icon-after" : null,
props.type == "password" ? "--password" : null,
]|join(' ')|trim -%}
{%- set attrs = [
'class="' ~ class_name ~ '"',
] -%}
{%- set attrs = attrs|join(' ')|trim -%}
{# Input attrs #}
{%- set class_name_input = [
"f-base",
"f-text__input",
]|join(' ')|trim -%}
{%- set attrs_input = [
'class="' ~ class_name_input ~ '"',
] -%}
{%- set input_type = props.type in ["email", "password", "url", "text", "tel", "search", "number"] ? props.type : "text" -%}
{%- set attrs_input = attrs_input|merge(['type="' ~ input_type ~ '"']) -%}
{%- if props.id is defined %}
{%- set attrs_input = attrs_input|merge(['id="' ~ props.id ~ '"']) -%}
{%- endif -%}
{%- if props.placeholder %}
{%- set attrs_input = attrs_input|merge(['placeholder="' ~ props.placeholder ~ '"']) -%}
{%- endif -%}
{%- if props.value is defined %}
{%- set attrs_input = attrs_input|merge(['value="' ~ props.value ~ '"']) -%}
{%- endif -%}
{%- if props.full_name is defined %}
{% set attrs_input = attrs_input|merge(['name=' ~ props.full_name ~ '']) %}
{%- endif -%}
{%- if props.maxlength is defined %}
{%- set attrs_input = attrs_input|merge(['maxlength="' ~ props.maxlength ~ '"']) -%}
{%- endif -%}
{% if props.pattern is defined %}
{%- set attrs_input = attrs_input|merge(['pattern="' ~ props.pattern ~ '"']) -%}
{% endif %}
{% if props.validity.pattern_mismatch %}
{%- set attrs_input = attrs_input|merge(['data-validity-pattern-mismatch="' ~ props.validity.pattern_mismatch ~ '"']) -%}
{% endif %}
{% if props.validity.value_missing %}
{%- set attrs_input = attrs_input|merge(['data-validity-value-missing="' ~ props.validity.value_missing ~ '"']) -%}
{% endif %}
{% if props.step and input_type == 'number' %}
{%- set attrs_input = attrs_input|merge(['step="' ~ props.step ~ '"']) -%}
{% endif %}
{%- if props.required == true %}
{%- set attrs_input = attrs_input|merge(['required']) -%}
{%- endif -%}
{%- if props.disabled == true %}
{%- set attrs_input = attrs_input|merge(['disabled']) -%}
{%- endif -%}
{%- if props.readonly == true %}
{%- set attrs_input = attrs_input|merge(['readonly']) -%}
{%- endif -%}
{%- if props.autocomplete is defined %}
{%- set attrs_input = attrs_input|merge(['autocomplete="' ~ (props.autocomplete == true ? 'on' : 'off') ~ '"']) -%}
{%- endif -%}
{%- set attrs_input = attrs_input|join(' ')|trim -%}
<div {{ attrs|raw }}>
{% if props.label %}
{% include "@Components/fields/label-field/label-field.twig" with {props: {
title: props.label,
id: props.id,
required: props.required,
}} %}
{% endif %}
<div class="f-text__wrap d-flex align-items-center u-posr">
{% if props.icon_before %}
<span class="f-text__icon --before">
{% include "@Components/icon/icon.twig" with {props: {
src: props.icon_before.src,
color: props.icon_before.color,
}} %}
</span>
{% endif %}
<input {{ attrs_input|raw }}>
{% if input_type != "password" and props.icon_after %}
<span class="f-text__icon --after">
{% include "@Components/icon/icon.twig" with {props: {
src: props.icon_after.src,
color: props.icon_after.color,
}} %}
</span>
{% endif %}
{% if input_type == "password" %}
<div class="f-text__toggle u-posa u-translate-middle-y u-top-50-p justify-content-center align-center d-grid u-cursor-pointer">
{% include "@Components/icon/icon.twig" with {props: {
src: "@Images/svg/eye-outline.svg",
extra_class: "f-text__toggle-icon --on",
}} %}
{% include "@Components/icon/icon.twig" with {props: {
src: "@Images/svg/eye-off-outline.svg",
extra_class: "f-text__toggle-icon --off",
}} %}
</div>
{% endif %}
</div>
{% include "@Components/fields/error-field/error-field.twig" with {props: {}} %}
</div>