Sha256: f3b7ad09191f1869b001c8c8856afd1506be79c29466f54114eaadca8e87709d

Contents?: true

Size: 835 Bytes

Versions: 6

Compression:

Stored size: 835 Bytes

Contents

module Voom
  module Presenters
    module DSL
      module Components
        class FileInput < Input
          include Mixins::Append
          include Mixins::Buttons
          include Mixins::Grids

          attr_reader :accept, :preview, :components

          def initialize(**attribs_, &block)
            super(type: :file_input, **attribs_, &block)

            @accept =  attribs.delete(:accept) { nil }
            @preview = attribs.delete(:preview) { nil }
            @components = []
            expand!
            default_button
          end

          def value(value=nil)
            return @value if locked?
            @value = value
          end
          private
          def default_button
            button(icon: :cloud_upload) unless components.any?
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
voom-presenters-2.1.2 lib/voom/presenters/dsl/components/file_input.rb
voom-presenters-2.1.0 lib/voom/presenters/dsl/components/file_input.rb
voom-presenters-2.0.3 lib/voom/presenters/dsl/components/file_input.rb
voom-presenters-2.0.2 lib/voom/presenters/dsl/components/file_input.rb
voom-presenters-2.0.1 lib/voom/presenters/dsl/components/file_input.rb
voom-presenters-2.0.0 lib/voom/presenters/dsl/components/file_input.rb