{% macro attr_generator(attributes) %}
{% set str_attr = '' %}
{% for attr, value in attributes|filter((v, k) => not (k starts with '_')) %}
{% set str_attr = str_attr~' '~attr~'="'~value~'"' %}
{% endfor %}
{{ str_attr|raw }}
{% endmacro %}
{% macro button(text, attributes = {}, options = {}) %}
{% set class = attributes.class is defined ? ' '~attributes.class : '' %}
{% set attributes = attributes|merge(
{('type'): attributes.type ?? 'button'},
{('class'): 'btn'~class}
) %}
{% if text|length == 0 %}
{% set attributes = attributes|merge(
{('class'): attributes.class~' btn-icon'}
) %}
{% endif %}
{% set tagName = attributes.href is defined ? 'a' : 'button' %}
{% set attr = _self.attr_generator(attributes) %}
{% set icon = options.icon is defined ? options.icon~' ' : '' %}
{% set html = '<'~tagName~' '~attr~'>'~icon~text|raw~''~tagName~'>' %}
{{ html|raw }}
{% endmacro %}
{% macro button_primary(text, attributes = {}, options = {}) %}
{% set class = attributes.class is defined ? ' '~attributes.class : '' %}
{% set attributes = attributes|merge(
{('class'): (options.light|default ? 'btn-light-primary' : 'btn-primary')~class}
) %}
{{ _self.button(text, attributes, options) }}
{% endmacro %}
{% macro create(label, attributes = {}) %}
{% set variant = attributes._variant|default('primary') %}
{% set size = attributes._size|default %}
{% set style = attributes._style|default %}
{% set icon = attributes._icon|default %}
{% set icont = '' %}
{% set iconSize = 'fs-3' %}
{% if icon is iterable %}
{% set iconSizeCls = {sm: 'fs-4', md: iconSize, lg: 'fs-2'} %}
{% set iconSize = iconSizeCls[icon.size] ?? iconSize %}
{% if icon.class|default starts with 'ki-duotone' %}
{% for i in 0..(icon.pathLength|default(2) - 1) %}
{% set icont = icont~'' %}
{% endfor %}
{% endif %}
{% set icon = icon.class|default %}
{% endif %}
{% set icon = icon~' '~iconSize %}
{% set iconHtml = icon ? ''~icont~'' %}
{% if style == 'light' %}
{% set mainClass = 'btn-light-'~variant %}
{% elseif style == 'outline' %}
{% set mainClass = 'btn-outline btn-outline-'~variant %}
{% elseif style == 'dashed' %}
{% set mainClass = 'btn-outline btn-outline-'~variant~' btn-outline-dashed' %}
{% else %}
{% set mainClass = 'btn-'~variant %}
{% endif %}
{% if size %}
{% set mainClass = mainClass~' btn-'~size %}
{% endif %}
{% if label|length == 0 and icon != '' %}
{% set mainClass = mainClass~' btn-icon' %}
{% endif %}
{% set attributes = attributes|merge(
{('class'): ('btn '~mainClass~' '~attributes.class|default)|trim}
) %}
{% if attributes.href is defined %}
{% set tagName = 'a' %}
{% else %}
{% set tagName = 'button' %}
{% if attributes.type is not defined %}
{% set attributes = attributes|merge({('type'): 'button'}) %}
{% endif %}
{% endif %}
{{ ('<'~tagName~' '~_self.attr_generator(attributes)~'>'~(iconHtml~label)|raw~''~tagName~'>')|raw }}
{% endmacro %}
{% macro primary(label, attributes = {}) %}
{% set attributes = attributes|merge({('_variant'): 'primary'}) %}
{{ _self.create(label, attributes) }}
{% endmacro %}
{% macro button_success(text,attributes) %}
{#{% set attributes = attributes|merge({class: (attributes.class|default('') ~ ' btn btn-success ')|trim}) -%}#}
{{ _self.button(text,attributes,"light-success") }}
{% endmacro %}
{% macro button_warning(text,attributes) %}
{#{% set attributes = attributes|merge({class: (attributes.class|default('') ~ ' btn btn-warning ')|trim}) -%}#}
{{ _self.button(text,attributes,"light-warning") }}
{% endmacro %}
{% macro button_danger(text,attributes) %}
{#{% set attributes = attributes|merge({class: (attributes.class|default('') ~ ' btn btn-danger ')|trim}) -%}#}
{{ _self.button(text,attributes,"light-danger") }}
{% endmacro %}
{% macro button_info(text,attributes) %}
{#{% set attributes = attributes|merge({class: (attributes.class|default('') ~ ' btn btn-info ')|trim}) -%}#}
{{ _self.button(text,attributes,"light-info") }}
{% endmacro %}
{% macro button_default(text,attributes) %}
{#{% set attributes = attributes|merge({class: (attributes.class|default('') ~ ' btn btn-default ')|trim}) -%}#}
{{ _self.button(text,attributes) }}
{% endmacro %}
{% macro button_submit(attributes) %}
{% if attributes is not iterable %}
{% set attributes = {} %}
{% endif %}
{#{% set attributes = attributes|merge({class: (attributes.class|default('') ~ ' btn btn-default ')|trim}) -%}#}
{% set attributes = attributes|merge({type: 'submit'}) -%}
{% set attributes = attributes|merge({id: 'submitButton'}) -%}
{% set text = 'Kaydet' %}
{% if attributes.icon|default %} {% set text = '' %} {% endif %}
{{ _self.button_primary(" "~text,attributes) }}
{% endmacro %}
{% macro button_back_to_list(attributes) %}
{% set text = "buttons.back_to_list"|trans %}
{##}
{% set attributes = attributes|default({}) %}
{% set attributes = attributes|merge({class: (attributes.class|default('') ~ ' data-tooltip')|trim}) -%}
{% set attributes = attributes|merge({'data-original-title': text|trim}) -%}
{##}
{% if attributes.icon|default %} {% set text = '' %} {% endif %}
{{ _self.button_info(""~text,attributes) }}
{% endmacro %}
{% macro button_edit(attributes) %}
{% set text = "buttons.edit"|trans %}
{##}
{% set attributes = attributes|default({}) %}
{% set attributes = attributes|merge({class: (attributes.class|default('') ~ ' data-tooltip')|trim}) -%}
{% set attributes = attributes|merge({'data-original-title': text|trim}) -%}
{##}
{% if attributes.icon|default %} {% set text = '' %} {% endif %}
{{ _self.button_warning(""~text,attributes) }}
{% endmacro %}
{% macro button_delete(attributes) %}
{% set text = "buttons.delete"|trans %}
{##}
{% set attributes = attributes|default({}) %}
{% set attributes = attributes|merge({class: (attributes.class|default('') ~ ' data-tooltip')|trim}) -%}
{% set attributes = attributes|merge({'data-original-title': text|trim}) -%}
{##}
{% if attributes.icon|default %} {% set text = '' %} {% endif %}
{{ _self.button_danger(""~text,attributes) }}
{% endmacro %}
{% macro button_show(attributes) %}
{% set text = "buttons.show"|trans %}
{##}
{% set attributes = attributes|default({}) %}
{% set attributes = attributes|merge({class: (attributes.class|default('') ~ ' data-tooltip')|trim}) -%}
{% set attributes = attributes|merge({'data-original-title': text|trim}) -%}
{##}
{% if attributes.icon|default %} {% set text = '' %} {% endif %}
{{ _self.button_info(""~text,attributes) }}
{% endmacro %}
{% macro button_new(fields) %}
{{ fields.text|default }}
{% endmacro %}