Sha256: b3501515f250dc96d99b3a535be941339933cee719afe8f1452e4b24091ede42

Contents?: true

Size: 914 Bytes

Versions: 3

Compression:

Stored size: 914 Bytes

Contents

require 'glimmer/opal/element_proxy'

module Glimmer
  module Opal
    class InputProxy < ElementProxy
      attr_reader :text
      
      def text=(value)
        @text = value
        redraw
      end

      def observation_request_to_event_mapping
        {
          'on_widget_selected' => {
            event: 'click'
          }, 
          'on_modify_text' => {
            event: 'keyup',
            event_handler: -> (event_listener) {
              -> (event) {
                @text = event.target.value
                event_listener.call(event)              
              }
            }
          }
        }
      end
      
      def dom
        input_text = @text
        input_id = id
        input_style = style
        input_args = @args.last
        @dom ||= DOM {
          input input_args.merge(id: input_id, style: input_style, value: input_text)
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
glimmer-dsl-opal-0.0.5 lib/glimmer/opal/input_proxy.rb
glimmer-dsl-opal-0.0.4 lib/glimmer/opal/input_proxy.rb
glimmer-dsl-opal-0.0.3 lib/glimmer/opal/input_proxy.rb