Sha256: 39eb1534846d3bfea550ad91d5573cb60e7af9678737bc375dd836f1d48f97f3
Contents?: true
Size: 1.44 KB
Versions: 5
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true module Ariadne module Form class BaseInputComponent < Ariadne::BaseComponent option :required, optional: true option :caption, optional: true def add_label_classes(*class_names) # label_arguments[:class] = merge_class_names( # label_arguments[:class], *class_names # ) end def label_arguments {} end def hidden? !!html_attrs[:hidden] end def full_width? @full_width end # Whether or not to wrap the component in a FormControl, which renders a # label above and validation message beneath the input. def form_control? html_attrs.delete(:form_control) { true } end attr_writer :label_attributes def label_attributes tag.attributes(@label_attributes || {}) end private def before_render # make sure to evaluate the component's content block so slots are defined content @input_attributes = { aria: {}, } ids = [].tap do |memo| memo << @validation_id if @validation_message memo << @caption_id if @init_caption || caption? end return if ids.empty? @input_attributes[:aria][:describedby] = ids.join(" ") end private def caption? @caption.present? end private def required? @required.present? end end end end
Version data entries
5 entries across 5 versions & 1 rubygems