Sha256: b95debc36ba18ce7da610445f3b5659d793e84864c095c9cb6321db81de170d0

Contents?: true

Size: 1.12 KB

Versions: 83

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbTextInput
    class TextInput
      include Playbook::Props

      partial "pb_text_input/text_input"

      prop :autocomplete, type: Playbook::Props::Boolean,
                          default: true
      prop :disabled, type: Playbook::Props::Boolean,
                      default: false
      prop :error
      prop :label
      prop :name
      prop :placeholder
      prop :required, type: Playbook::Props::Boolean,
                      default: false
      prop :type, default: "text"
      prop :validation, type: Playbook::Props::Hash,
                        default: {}
      prop :value

      def classname
        generate_classname("pb_text_input_kit") + error_class
      end

      def validation_message
        validation[:message] || ""
      end

      def validation_pattern
        validation[:pattern] || nil
      end

      def validation_data
        fields = {}
        fields[:message] = validation_message unless validation_message.blank?
        fields
      end

    private

      def error_class
        error ? " error" : ""
      end
    end
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
playbook_ui-7.14.0.pre.alpha1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.16.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.15.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.15.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.14.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.13.0.pre.alpha1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.13.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.12.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.12.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.11.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.11.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.11.0.pre.alpha1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.10.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.9.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.8.4 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.8.3 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.8.2 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.8.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.8.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-7.7.0.pre.alpha1 app/pb_kits/playbook/pb_text_input/text_input.rb