<% add_gem_component_stylesheet("file-upload") shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) id ||= "file-upload-#{SecureRandom.hex(4)}" value ||= nil accept ||= nil data ||= nil label ||= nil hint ||= nil error_message ||= nil error_items ||= [] has_error = error_message || error_items.any? hint_id = "hint-#{SecureRandom.hex(4)}" error_id = "error-#{SecureRandom.hex(4)}" heading_size = false unless shared_helper.valid_heading_size?(heading_size) heading_level ||= nil css_classes = %w(gem-c-file-upload govuk-file-upload) css_classes << "govuk-file-upload--error" if has_error form_group_css_classes = %w(govuk-form-group) form_group_css_classes << "govuk-form-group--error" if has_error aria_described_by ||= nil if hint || has_error aria_described_by = [] aria_described_by << hint_id if hint aria_described_by << error_id if has_error aria_described_by = aria_described_by.join(" ") end %> <%= content_tag :div, class: form_group_css_classes do %> <% if label %> <% label_markup = capture do %> <%= render "govuk_publishing_components/components/label", { html_for: id, heading_size: heading_size }.merge(label.symbolize_keys) %> <% end %> <% if heading_level %> <%= content_tag(shared_helper.get_heading_level, class: "govuk-label-wrapper") do %> <%= label_markup %> <% end %> <% else %> <%= label_markup %> <% end %> <% end %> <% if hint %> <%= render "govuk_publishing_components/components/hint", { id: hint_id, text: hint } %> <% end %> <% if has_error %> <%= render "govuk_publishing_components/components/error_message", { id: error_id, text: error_message, items: error_items, } %> <% end %> <%= tag.input name: name, type: "file", value: value, class: css_classes, id: id, data: data, accept: accept, aria: { describedby: aria_described_by } %> <% end %>