Sha256: 0870fddf5987a5804ce4fefb0a10e769054703ca9f75be5c41fa00c316a05c88

Contents?: true

Size: 1.17 KB

Versions: 18

Compression:

Stored size: 1.17 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] || ""
      end

      def 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

18 entries across 18 versions & 1 rubygems

Version Path
playbook_ui-4.8.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.7.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.7.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.6.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.6.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.5.2 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.5.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.5.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.4.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.4.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.3.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.3.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.2.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.1.2 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.1.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.1.0 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.0.1 app/pb_kits/playbook/pb_text_input/text_input.rb
playbook_ui-4.0.0 app/pb_kits/playbook/pb_text_input/text_input.rb