Class: Primer::Forms::Dsl::SelectInput
- Defined in:
- app/lib/primer/forms/dsl/select_input.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Option
Constant Summary collapse
- SELECT_ARGUMENTS =
%i[multiple include_blank include_hidden prompt].freeze
Constants inherited from Input
Input::DEFAULT_INPUT_WIDTH, Input::DEFAULT_SIZE, Input::INPUT_WIDTH_MAPPINGS, Input::INPUT_WIDTH_OPTIONS, Input::SIZE_MAPPINGS, Input::SIZE_OPTIONS, Input::SPACE_DELIMITED_ARIA_ATTRIBUTES
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#select_arguments ⇒ Object
readonly
Returns the value of attribute select_arguments.
Attributes inherited from Input
#base_id, #builder, #caption, #form, #form_control, #ids, #input_arguments, #label_arguments, #validation_message
Instance Method Summary collapse
-
#focusable? ⇒ Boolean
:nocov:.
-
#initialize(name:, label:, **system_arguments) {|_self| ... } ⇒ SelectInput
constructor
A new instance of SelectInput.
- #multiple? ⇒ Boolean
- #option(**system_arguments) ⇒ Object
- #to_component ⇒ Object
-
#type ⇒ Object
:nocov:.
Methods inherited from Input
#add_input_aria, #add_input_classes, #add_input_data, #add_label_classes, #autofocus!, #caption?, #caption_id, #caption_template?, #disabled?, #full_width?, #hidden?, #id, #input?, #input_width, #invalid?, #merge_input_arguments!, #remove_input_data, #render_caption_template, #required?, #size, #supports_validation?, #valid?, #validation_arguments, #validation_error_icon_target, #validation_id, #validation_message_arguments, #validation_messages, #validation_success_icon_target, #value, #values_disambiguate_template_names?
Methods included from ClassNameHelper
Constructor Details
#initialize(name:, label:, **system_arguments) {|_self| ... } ⇒ SelectInput
Returns a new instance of SelectInput.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/lib/primer/forms/dsl/select_input.rb', line 25 def initialize(name:, label:, **system_arguments) @name = name @label = label @options = [] @select_arguments = {}.tap do |select_args| SELECT_ARGUMENTS.each do |select_arg| select_args[select_arg] = system_arguments.delete(select_arg) end end super(**system_arguments) yield(self) if block_given? end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
23 24 25 |
# File 'app/lib/primer/forms/dsl/select_input.rb', line 23 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'app/lib/primer/forms/dsl/select_input.rb', line 23 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'app/lib/primer/forms/dsl/select_input.rb', line 23 def @options end |
#select_arguments ⇒ Object (readonly)
Returns the value of attribute select_arguments.
23 24 25 |
# File 'app/lib/primer/forms/dsl/select_input.rb', line 23 def select_arguments @select_arguments end |
Instance Method Details
#focusable? ⇒ Boolean
:nocov:
60 61 62 |
# File 'app/lib/primer/forms/dsl/select_input.rb', line 60 def focusable? true end |
#multiple? ⇒ Boolean
41 42 43 |
# File 'app/lib/primer/forms/dsl/select_input.rb', line 41 def multiple? @select_arguments.fetch(:multiple, false) end |
#option(**system_arguments) ⇒ Object
45 46 47 |
# File 'app/lib/primer/forms/dsl/select_input.rb', line 45 def option(**system_arguments) @options << Option.new(**system_arguments) end |
#to_component ⇒ Object
49 50 51 |
# File 'app/lib/primer/forms/dsl/select_input.rb', line 49 def to_component Select.new(input: self) end |
#type ⇒ Object
:nocov:
54 55 56 |
# File 'app/lib/primer/forms/dsl/select_input.rb', line 54 def type :select_list end |