Sha256: e7a95bb9b37e8463afe76bd117a8a05dc6ac2fdb50f0364906e32727fb22f19c

Contents?: true

Size: 1.05 KB

Versions: 244

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbDropdown
    class Dropdown < Playbook::KitBase
      prop :options, type: Playbook::Props::Array,
                     default: []
      prop :label, type: Playbook::Props::String
      prop :name, type: Playbook::Props::String
      prop :error, type: Playbook::Props::String
      prop :required, type: Playbook::Props::Boolean,
                      default: false
      prop :default_value
      prop :blank_selection, type: Playbook::Props::String,
                             default: ""

      def data
        Hash(prop(:data)).merge(pb_dropdown: true)
      end

      def classname
        generate_classname("pb_dropdown")
      end

    private

      def error_class
        error.present? ? " error" : ""
      end

      def input_default_value
        default_value.present? ? default_value.transform_keys(&:to_s)["id"] : ""
      end

      def options_with_blank
        blank_selection.present? ? [{ id: "", value: "", label: blank_selection }] + options : options
      end
    end
  end
end

Version data entries

244 entries across 244 versions & 1 rubygems

Version Path
playbook_ui-14.5.0.pre.alpha.PLAY1510railsformloading3977 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.PLAY1510railsformloading3976 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.PLAY1510railsformloading3975 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.6.0.pre.rc.4 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.6.0.pre.rc.3 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.6.0.pre.rc.2 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.PLAY1486highchartscssdrivenPOC3954 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.PLAY1486highchartscssdrivenPOC3953 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.PLAY1486highchartscssdrivenPOC3950 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.PBNTR374multilevelselectPOC3946 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.PLAY1486highchartscssdrivenPOC3944 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.6.0.pre.rc.1 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.psych4support3941 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.PLAY1486highchartscssdrivenPOC3940 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.javascriptassets3939 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.javascriptassets3932 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.PLAY1486highchartscssdrivenPOC3931 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.PLAY1486highchartscssdrivenPOC3930 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.javascriptassets3929 app/pb_kits/playbook/pb_dropdown/dropdown.rb
playbook_ui-14.5.0.pre.alpha.javascriptassets3928 app/pb_kits/playbook/pb_dropdown/dropdown.rb