lato 0.1.47 → 0.1.48
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b950d52eacb976f1c5c268d08e601c3a4c5cd3b3c92b5bdedc56ef5ba0daeb8
|
4
|
+
data.tar.gz: 99410bc99efc35de36892b57d19d768d94cf7489867b5d0fef82f7d8ca604b5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b232a44f90d3f38f7d0e8321d2085a9d7d7bf7a4aae52ed0160d2cb8d2b654f2e549164eb3e0c15c8623e9f30b097f736d5e96838fb61109a25fceeece75536
|
7
|
+
data.tar.gz: '0588148e4e64b91b9b92ab609ab95439ab3a08e1e5bfd1d661166f4654cbebdf913dc69b035a0b00027907870e8d5b5214c38a8f1b3ceb8e48c994783224ecdb'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
import _ from 'lodash'
|
3
|
+
|
4
|
+
export default class extends Controller {
|
5
|
+
static values = {
|
6
|
+
path: String
|
7
|
+
}
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Stimulus
|
11
|
+
*/
|
12
|
+
|
13
|
+
connect() {
|
14
|
+
this.search = _.debounce(this.search, 500)
|
15
|
+
this.datalist = document.createElement('datalist')
|
16
|
+
this.datalist.id = Math.random().toString(36)
|
17
|
+
this.element.setAttribute('list', this.datalist.id)
|
18
|
+
this.element.parentNode.appendChild(this.datalist)
|
19
|
+
|
20
|
+
this.element.addEventListener('keyup', (e) => {
|
21
|
+
this.search(e.target.value)
|
22
|
+
})
|
23
|
+
}
|
24
|
+
|
25
|
+
async search(value) {
|
26
|
+
if (!value || value.length < 3) return this.clear()
|
27
|
+
|
28
|
+
try {
|
29
|
+
const response = await fetch(this.pathValue + '?q=' + value)
|
30
|
+
const data = await response.json()
|
31
|
+
this.suggest(data)
|
32
|
+
} catch (err) {
|
33
|
+
console.error(err)
|
34
|
+
this.clear()
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
suggest(data = []) {
|
39
|
+
this.clear()
|
40
|
+
|
41
|
+
data.forEach((item) => {
|
42
|
+
const option = document.createElement('option')
|
43
|
+
option.value = item
|
44
|
+
this.datalist.appendChild(option)
|
45
|
+
})
|
46
|
+
}
|
47
|
+
|
48
|
+
clear() {
|
49
|
+
this.datalist.innerHTML = ''
|
50
|
+
}
|
51
|
+
}
|
data/config/importmap.rb
CHANGED
data/lib/lato/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.48
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregorio Galante
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- app/assets/javascripts/lato/controllers/lato_feedback_controller.js
|
118
118
|
- app/assets/javascripts/lato/controllers/lato_form_controller.js
|
119
119
|
- app/assets/javascripts/lato/controllers/lato_hello_controller.js
|
120
|
+
- app/assets/javascripts/lato/controllers/lato_input_autocomplete_controller.js
|
120
121
|
- app/assets/javascripts/lato/controllers/lato_operation_controller.js
|
121
122
|
- app/assets/stylesheets/lato/application.scss
|
122
123
|
- app/controllers/concerns/lato/componentable.rb
|