Sha256: 9d7251697e808ef0a78f368b79f779c5a1dc5847ca8a8d351a8fb190036cd432
Contents?: true
Size: 1.97 KB
Versions: 12
Compression:
Stored size: 1.97 KB
Contents
module Coprl module Presenters module DSL module Components class Select < Input attr_reader :required, :full_width, :options, :outlined def initialize(**attribs_, &block) super(type: :select, **attribs_, &block) @required = attribs.delete(:required) @full_width = attribs.delete(:full_width){ true } @outlined = attribs.delete(:outlined){ true } @options = [] expand! end def label(text=nil) return @label if locked? @label = text end def option(text=nil, **attribs, &block) @options << Option.new(parent: self, text: text, **attribs, &block) end def value @options.select(&:_selected?).first&.value end def hint(hint=nil) return @hint if locked? @hint = hint end def icon(icon=nil, **attribs, &block) return @icon if locked? @icon = Components::Icon.new(parent: self, icon: icon, position: attribs.delete(:position){:right}, **attribs, &block) end class Option < Base attr_reader :selected, :disabled def initialize(**attribs_, &block) super(type: :select_option, **attribs_, &block) @value = self.value(attribs.delete(:value)) @text = self.text(attribs.delete(:text)) @selected = attribs.delete(:selected) @disabled = attribs.delete(:disabled) expand! end def value(value=nil) return @value if locked? @value = value end def text(text=nil) return @text if locked? @text = text end end end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems