Sha256: a0fd5ff4bbe7d207f2e578da8e099ac8816f037de0791ca0ded610c8b7b33afa

Contents?: true

Size: 1.27 KB

Versions: 16

Compression:

Stored size: 1.27 KB

Contents

module Formstrap
  class UrlView < ViewModel
    include Formstrap::Autocompletable
    include Formstrap::Hintable
    include Formstrap::InputGroupable
    include Formstrap::Labelable
    include Formstrap::Listable
    include Formstrap::Placeholderable
    include Formstrap::Validatable
    include Formstrap::Wrappable

    def input_options
      keys = attributes - %i[append attribute collection float form input_group label prepend validate wrapper]
      options = to_h.slice(*keys)
      options = default_input_options.deep_merge(options)
      options.deep_merge(autocomplete_input_options)
    end

    def input_group_options
      default_input_group_options
        .deep_merge(autocomplete_input_group_options)
        .deep_merge(label_input_group_options)
        .deep_merge(@input_group || {})
    end

    def wrapper_options
      default_wrapper_options.deep_merge({
        class: ["mb-3", ("form-floating" if float)]
      }).deep_merge(@wrapper || {})
    end

    private

    def default_input_options
      {
        aria: {describedby: validation_id},
        class: [form_control_class, validation_class],
        placeholder: placeholder
      }
    end

    def form_control_class
      plaintext ? "form-control-plaintext" : "form-control"
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
formstrap-0.4.5 app/models/formstrap/url_view.rb
formstrap-0.4.4 app/models/formstrap/url_view.rb
formstrap-0.4.3 app/models/formstrap/url_view.rb
formstrap-0.4.2 app/models/formstrap/url_view.rb
formstrap-0.3.5 app/models/formstrap/url_view.rb
formstrap-0.3.4 app/models/formstrap/url_view.rb
formstrap-0.3.3 app/models/formstrap/url_view.rb
formstrap-0.3.2 app/models/formstrap/url_view.rb
formstrap-0.3.1 app/models/formstrap/url_view.rb
formstrap-0.3.0 app/models/formstrap/url_view.rb
formstrap-0.2.1 app/models/formstrap/url_view.rb
formstrap-0.2.0 app/models/formstrap/url_view.rb
formstrap-0.1.3 app/models/formstrap/url_view.rb
formstrap-0.1.2 app/models/formstrap/url_view.rb
formstrap-0.1.1 app/models/formstrap/url_view.rb
formstrap-0.1.0 app/models/formstrap/url_view.rb