Sha256: 3afcb53d0a04d9b5a7a12ec81684ed9686f3d207d475c6a4a003dbf0c80411b8
Contents?: true
Size: 1.32 KB
Versions: 41
Compression:
Stored size: 1.32 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 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
41 entries across 41 versions & 1 rubygems