Class: HakumiComponents::Checkbox::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- HakumiComponents::Checkbox::Component
- Extended by:
- T::Sig
- Includes:
- HakumiComponents::Concerns::FormField
- Defined in:
- app/components/hakumi_components/checkbox/component.rb
Constant Summary
Constants inherited from BaseComponent
BaseComponent::ControllerOptions, BaseComponent::DateInput, BaseComponent::DateLikeValue, BaseComponent::DimensionInput, BaseComponent::HtmlPayloadInput, BaseComponent::I18nOptionValue, BaseComponent::PresenceArray, BaseComponent::PresenceScalar, BaseComponent::PresenceValue, BaseComponent::RawHtmlInput, BaseComponent::SIZES, BaseComponent::SizeValue, BaseComponent::SymbolInput
Instance Method Summary collapse
- #checkbox_classes ⇒ Object
- #data_controllers ⇒ Object
-
#initialize(checked: false, disabled: false, indeterminate: false, value: nil, name: nil, id: nil, wrapper_id: nil, auto_focus: false, label: nil, caption: nil, standalone: true, required: false, errors: [], **html_options) ⇒ Component
constructor
A new instance of Component.
- #wrapper_classes ⇒ Object
Methods included from HakumiComponents::Concerns::FormField
#describedby_ids, #error?, #error_message, #form_field_caption, #form_field_contract, #form_field_errors, #form_field_html_options, #form_field_label, #form_field_name, #form_field_required, #form_field_rules, #form_field_standalone, #form_item_attributes, #form_item_classes, #input_id, #render_caption, #render_error, #render_explain, #render_label, #standalone?
Methods included from HakumiComponents::Concerns::FormFieldInterface
Methods inherited from BaseComponent
#append_data_token, boolean_html_param, #build_inline_style, cast_boolean, #cast_boolean, #class_names, #component_classes, #data_attributes_from, #dimension_to_css, #ensure_dom_id!, float_html_param, #generate_id, #html_classes, html_param, html_primitive_param, #html_style, #i18n_scope, integer_html_param, #merge_attributes, #render_value, #size_to_pixels, #stimulus_attrs, string_html_param, string_or_symbol_array_html_param, symbol_html_param, #t_default, #translate_with_default, #validate_inclusion!, #validate_required!, #value_present?
Constructor Details
#initialize(checked: false, disabled: false, indeterminate: false, value: nil, name: nil, id: nil, wrapper_id: nil, auto_focus: false, label: nil, caption: nil, standalone: true, required: false, errors: [], **html_options) ⇒ Component
Returns a new instance of Component.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/components/hakumi_components/checkbox/component.rb', line 29 def initialize( checked: false, disabled: false, indeterminate: false, value: nil, name: nil, id: nil, wrapper_id: nil, auto_focus: false, label: nil, caption: nil, standalone: true, required: false, errors: [], ** ) @checked = checked @disabled = disabled @indeterminate = indeterminate @value = T.let(value || "1", HakumiComponents::Types::FormFieldScalar) @name = T.let(name || generate_id("checkbox"), Types::FormFieldName) @id = T.let(id || generate_id("checkbox"), Types::FormFieldName) @auto_focus = auto_focus @label = label @caption = caption @standalone = standalone @required = required @errors = T.let(errors, Types::FormFieldErrors) @wrapper_id = T.let(wrapper_id || "#{@id}-wrapper", String) @html_options = T.let(.merge(id: @id), Types::HtmlAttributes) initialize_form_field_contract!( name: @name, label: @label, caption: @caption, errors: @errors, standalone: @standalone, required: @required, html_options: @html_options ) end |
Instance Method Details
#checkbox_classes ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'app/components/hakumi_components/checkbox/component.rb', line 81 def checkbox_classes class_names( "checkbox", { "checked": @checked, "disabled": @disabled, "indeterminate": @indeterminate } ) end |
#data_controllers ⇒ Object
93 94 95 |
# File 'app/components/hakumi_components/checkbox/component.rb', line 93 def data_controllers "hakumi--checkbox" end |
#wrapper_classes ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'app/components/hakumi_components/checkbox/component.rb', line 71 def wrapper_classes class_names( "checkbox-wrapper", { "disabled": @disabled } ) end |