Sha256: f85ffc98fba4d5f1f876a50157154405573182c2536a84fcc177011e35228182
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true require "action_view" module Playbook module PbSelect class Select include ActionView::Helpers::FormTagHelper include ActionView::Context include Playbook::Props partial "pb_select/select" prop :blank_selection prop :dark, type: Playbook::Props::Boolean, default: false prop :disabled, type: Playbook::Props::Boolean, default: false prop :error prop :include_blank prop :label prop :multiple, type: Playbook::Props::Boolean, default: false prop :name prop :onchange prop :options, type: Playbook::Props::HashArray, required: false, default: [] prop :required, type: Playbook::Props::Boolean, default: false def classname generate_classname("pb_select", dark_class) + error_class end def options_to_array options.map { |option| [option[:value_text] || option[:value], option[:value]] } end def selected selections = options.map { |option| option[:value] if option[:selected] == true }.compact if selections.empty? nil else selections end end def disabled_options disabled_options = options.map { |option| option[:value] if option[:disabled] == true }.compact if disabled_options.empty? nil else disabled_options end end private def error_class error ? " error" : "" end def dark_class dark ? "dark" : nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
playbook_ui-3.5.0 | app/pb_kits/playbook/pb_select/select.rb |