Sha256: 67da0abe67c844abb0524995dcdf85126fce01375fbb9cdf4ad678ef048de076

Contents?: true

Size: 1.57 KB

Versions: 417

Compression:

Stored size: 1.57 KB

Contents

<%= content_tag(:li,
    aria: object.aria,
    class: object.classname,
    data: object.data,
    id: object.id) do %>
  <% if object.variant == "radio"%>
    <%= pb_rails("radio", props: { text: object.text, checked: object.checked, input_options: object.input_options } ) %>
    <% if content.present? %>
      <%= content %>
    <% end %>
  <% else %>
    <%= pb_rails("checkbox", props: { text: object.text, checked: object.checked, input_options: object.input_options } ) %>
    <% if content.present? %>
      <%= content %>
    <% end %>
  <% end %>

  <% if object.variant == "checkbox"%>
    <script>
      var checkboxElement = document.querySelector("#<%=object.id%> input[type=checkbox]")
      
      checkboxElement.addEventListener("change", (evt) => {
        var listItemElement = document.querySelector("#<%=object.id%>")
        
        if (evt.target.checked) {
          listItemElement.classList.add("checked_item");
        } else {
          listItemElement.classList.remove("checked_item")
        }
      })
    </script>
  <% else %>
    <script>
      var radioElement = document.querySelector("#<%=object.id%> input[type=radio]")

      radioElement.addEventListener("change", () => {        
        var radios = radioElement.closest("ul").querySelectorAll("input[type=radio]")
        
        radios.forEach((radio) => {
          if (radio.checked) {
            radio.closest("li").classList.add("checked_item");
          } else {
            radio.closest("li").classList.remove("checked_item")
          }
        });
      })
    </script>
  <% end %>
<% end %>

Version data entries

417 entries across 417 versions & 1 rubygems

Version Path
playbook_ui-13.14.0.pre.alpha.PLAY1109bugdisplaypropblocksfontcolor1784 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.14.0.pre.alpha.play1106filter1751 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.14.0.pre.alpha.play1106filter1748 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.14.0 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.13.0.pre.alpha.PLAY1097linterenhancedelement1728 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.13.0.pre.alpha.play10821727 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.13.0.pre.alpha.play10821726 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.13.0.pre.alpha.play10221678 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.13.0.pre.alpha.PLAY1090csstokens1675 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.13.0.pre.alpha.play900startratingasinput1657 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.13.0 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.12.0.pre.alpha.PLAY880cardkithighlightzindex1655 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.12.0.pre.alpha.PLAY1081exportingtypes1627 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.12.0.pre.alpha.PLAY1081exportingtypes1626 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1624 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1623 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1612 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1611 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1609 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1608 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb