module Coco module App module Elements class SeamlessTextarea < Coco::Component include TagHelper include Concerns::WrapsComponent include Concerns::AcceptsOptions wraps_component :textarea accepts_option :multiline, from: [true, false] attr_reader :name, :id def initialize(name:, value: nil, id: nil, placeholder: nil, textarea: nil, form_builder: nil, **kwargs) @name = name @value = value @form_builder = form_builder @textarea_args = textarea.to_h @textarea_args[:id] = id @textarea_args[:placeholder] = placeholder end def multiline? get_option_value(:multiline) end def value (@value.presence || content.presence || "").strip_heredoc.strip end def text_area(**html_args) args = @textarea_args.merge(html_args.compact) if @form_builder @form_builder.text_area(name, value: value, **args) else text_area_tag(name, value, **args) end end end end end end