<%= coco_tag(:div, class: "coco-button-wrapper", x: alpine_wrapper_attrs.to_h, key: ("coco-bw-#{rand(100000)}" if dropdown?) ) do %> <%= render component_tag(button_tag, class: { "coco-button": true, "icon-only": icon_only?, "with-icon": (icon? && !icon_only?) }, x: { data: (x_data("button", alpine_data) unless static?), bind: ("root" unless static?), "dropdown:trigger": (true if dropdown?), "dropdown:anchor": (true if dropdown?), "@click": ("#{"checkConfirmation($event);" if confirm?} #{on_click}" if confirm? || on_click.present?) }, data: { turbo: turbo_data_attr_value, turbo_frame: turbo_frame } ) do %> <% if static? %> <% if icon? %> <%= icon %> <% end %> <% if button_text.present? %> <%= button_text %> <% end %> <% else %> <% states.each do |name, props| %> <% if props[:icon].present? %> <% if states.many? %> > <%= props[:icon] %> <% else %> <%= props[:icon] %> <% end %> <% end %> <% end %> <% unless icon_only? %> <% states.each do |name, props| %> <% if states.many? %> > <%= props[:text] %> <% else %> <%= props[:text] %> <% end %> <% end %> <% end %> <% if toggle? %> <% if toggle_direction == :horizontal %> <%= coco_icon(:chevron_right, class: "button-toggle") %> <% else %> <%= coco_icon(:chevron_down, class: "button-toggle") %> <% end %> <% end %> <% end %> <% end %> <% if dropdown? %>
<%= dropdown %>
<% end %> <% end %>