Sha256: 39d1959f645c575427328d61fe631a5d7a854474c662f46d8011cb972355dd0f

Contents?: true

Size: 1.18 KB

Versions: 54

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbTextInput
    class TextInput
      include Playbook::Props

      partial "pb_text_input/text_input"

      prop :dark, type: Playbook::Props::Boolean,
                  default: false
      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", dark_class) + 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

      def dark_class
        dark ? "dark" : nil
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
playbook_ui-5.5.1.pre.alpha3 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.5.1.pre.alpha2 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.5.1.pre.alpha1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.2.0.pre.alpha10 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.5.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.5.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.5.0.pre.alpha1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.2.0.pre.alpha9 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.2.0.pre.alpha8 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.2.0.pre.alpha7 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.3.0.pre.alpha1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.4.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.2.0.pre.alpha6 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.2.0.pre.alpha5 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.3.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.2.0.pre.alpha4 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.2.0.pre.alpha3 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.2.0.pre.alpha2 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.2.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-5.1.0 app/pb_kits/playbook/pb_text_input/text_input.rb