bull-autocomplete 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ef8076619cbd70efef8c9b5fb5839cb7027513d8
4
+ data.tar.gz: b5973236c1b5d09a367925eb75af5d13a322bbbf
5
+ SHA512:
6
+ metadata.gz: b87804d4883e4e81e15a8f36d93afc2c2e6d353c9437f1302e7c0596cd0771c72ce467cf858c22c98f43ef28112eecd1c23241f86474d728710e867bc4a1bb82
7
+ data.tar.gz: e3146794084308cecb0a4b25b1e5346ab4cc26cacce4db9d4b3c60cacf18a9ec790760ad3a5f31fbe6d225d0475c4bcaddb60000bd84852c1e9e5f0921639cd5
@@ -0,0 +1,8 @@
1
+ div.autocomplete-popover
2
+ cursor: pointer
3
+ background-color: white
4
+ position: absolute
5
+
6
+ div.autocomplete-selected
7
+ background-color: black
8
+ color: white
@@ -0,0 +1,58 @@
1
+ require 'reactive-ruby'
2
+
3
+ class AutocompleteInput < React::Component::Base
4
+
5
+ param :value
6
+ param :change_attr
7
+ param :ref_
8
+ param :name
9
+ #param :set_validation
10
+
11
+ before_mount do
12
+ state.options! []
13
+ state.index! 0
14
+ end
15
+
16
+ def selected pos
17
+ if pos == state.index
18
+ 'autocomplete-selected'
19
+ else
20
+ ''
21
+ end
22
+ end
23
+
24
+ def render
25
+ div do
26
+ input(type: :text, value: params.value).on(:change) do |event|
27
+ params.change_attr.call event.target.value
28
+ #if state.options.include? event.target.value
29
+ # params.set_validation.call true
30
+ #else
31
+ # params.set_validation.call false
32
+ #end
33
+ $controller.rpc('get_' + params.ref_, event.target.value).then do |result|
34
+ state.options! result.map {|x| x[params.name]}
35
+ end
36
+ end.on(:keyDown) do |event|
37
+ if event.key_code == 13
38
+ params.change_attr.call state.options[state.index]
39
+ #params.set_validation.call true
40
+ state.options! []
41
+ elsif event.key_code == 40
42
+ state.index! (state.index + 1) % state.options.length if state.options.length != 0
43
+ elsif event.key_code == 38
44
+ state.index! (state.index - 1) % state.options.length if state.options.length != 0
45
+ end
46
+ end
47
+ div(class: 'autocomplete-popover') do
48
+ state.options.each_with_index do |v, i|
49
+ div(class: selected(i)){v}.on(:click) do |e|
50
+ params.change_attr.call v
51
+ #params.set_validation.call true
52
+ state.options! []
53
+ end
54
+ end
55
+ end if state.options.length > 1 || state.options[0] != params.value
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,8 @@
1
+ if RUBY_ENGINE == 'opal'
2
+ require_relative 'autocomplete_ui'
3
+ else
4
+ # NOT running inside of opal, set things up
5
+ # so opal can find the files.
6
+ require 'opal'
7
+ Opal.append_path File.expand_path('..', __FILE__).untaint
8
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bull-autocomplete
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Miguel Alarcos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Autocomplete feature for Bull
14
+ email: miguel.alarcos@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/autocomplete.styl
20
+ - lib/autocomplete_ui.rb
21
+ - lib/bull-autocomplete.rb
22
+ homepage:
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.5.1
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Autocomplete feature for Bull
46
+ test_files: []