lato 3.10.3 → 3.10.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31073ee8b736613fd453f8a1b467f0c2c84db71dfdb06a647dee521963e1919a
|
4
|
+
data.tar.gz: af8e072068c0dffab1d40cc10f22cae7ce0d5ea1183c49ff65f24f587d3e2919
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 857bbb4c8c5b948973d05905befb11916f6705f6a72a377be66e6ef9b3058ddcbb02f0386057ae969f18ec882eb7a2389550e5377b37cc45a0a09b339c0dd821
|
7
|
+
data.tar.gz: e9ad0e391a99794568e4635fc7498fd5ac9a98c9fe21eba32c12d9d6c8550c5117e4f72574666ebf931cc7cff516fe4ebf9c16471f055170d0a472347c41f3b5
|
@@ -43,17 +43,44 @@ export default class extends Controller {
|
|
43
43
|
|
44
44
|
async search(value) {
|
45
45
|
this.realInput.value = ''
|
46
|
-
if (!value
|
46
|
+
if (!value) return
|
47
47
|
|
48
48
|
try {
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
this.suggestShowLoading()
|
50
|
+
setTimeout(async () => {
|
51
|
+
const response = await fetch(this.pathValue + '?q=' + value)
|
52
|
+
const data = await response.json()
|
53
|
+
this.suggestShow(data)
|
54
|
+
}, 500)
|
52
55
|
} catch (err) {
|
53
56
|
console.error(err)
|
54
57
|
}
|
55
58
|
}
|
56
59
|
|
60
|
+
suggestShowLoading() {
|
61
|
+
if (this.optionsList) this.optionsList.remove()
|
62
|
+
this.optionsList = document.createElement('ul')
|
63
|
+
this.optionsList.classList.add('list-group')
|
64
|
+
this.optionsList.style.position = 'fixed'
|
65
|
+
this.optionsList.style.width = this.element.offsetWidth + 'px'
|
66
|
+
this.optionsList.style.maxHeight = '200px'
|
67
|
+
this.optionsList.style.overflowY = 'auto'
|
68
|
+
this.optionsList.style.zIndex = 9999
|
69
|
+
|
70
|
+
const elementRect = this.element.getBoundingClientRect()
|
71
|
+
this.optionsList.style.top = elementRect.bottom + 'px'
|
72
|
+
this.optionsList.style.left = elementRect.left + 'px'
|
73
|
+
|
74
|
+
const li = document.createElement('li')
|
75
|
+
li.classList.add('list-group-item')
|
76
|
+
li.classList.add('text-muted')
|
77
|
+
li.classList.add('text-center')
|
78
|
+
li.innerHTML = '<span class="lato-spin d-inline-block"><i class="bi bi-arrow-clockwise"></i></span>'
|
79
|
+
this.optionsList.appendChild(li)
|
80
|
+
|
81
|
+
document.body.appendChild(this.optionsList)
|
82
|
+
}
|
83
|
+
|
57
84
|
suggestShow(data = []) {
|
58
85
|
if (this.optionsList) this.optionsList.remove()
|
59
86
|
this.optionsList = document.createElement('ul')
|
@@ -67,20 +94,29 @@ export default class extends Controller {
|
|
67
94
|
const elementRect = this.element.getBoundingClientRect()
|
68
95
|
this.optionsList.style.top = elementRect.bottom + 'px'
|
69
96
|
this.optionsList.style.left = elementRect.left + 'px'
|
70
|
-
|
71
|
-
data.
|
97
|
+
|
98
|
+
if (data.length > 0) {
|
99
|
+
data.forEach((option) => {
|
100
|
+
const li = document.createElement('li')
|
101
|
+
li.classList.add('list-group-item')
|
102
|
+
li.classList.add('list-group-item-action')
|
103
|
+
li.style.cursor = 'pointer'
|
104
|
+
li.innerText = typeof option == 'string' ? option : option.label
|
105
|
+
li.addEventListener('click', () => {
|
106
|
+
this.element.value = typeof option == 'string' ? option : option.label
|
107
|
+
this.realInput.value = typeof option == 'string' ? option : option.value
|
108
|
+
this.suggestHide()
|
109
|
+
})
|
110
|
+
this.optionsList.appendChild(li)
|
111
|
+
})
|
112
|
+
} else {
|
72
113
|
const li = document.createElement('li')
|
73
114
|
li.classList.add('list-group-item')
|
74
|
-
li.classList.add('
|
75
|
-
li.
|
76
|
-
li.innerText =
|
77
|
-
li.addEventListener('click', () => {
|
78
|
-
this.element.value = typeof option == 'string' ? option : option.label
|
79
|
-
this.realInput.value = typeof option == 'string' ? option : option.value
|
80
|
-
this.suggestHide()
|
81
|
-
})
|
115
|
+
li.classList.add('text-muted')
|
116
|
+
li.classList.add('text-center')
|
117
|
+
li.innerText = 'No results found'
|
82
118
|
this.optionsList.appendChild(li)
|
83
|
-
}
|
119
|
+
}
|
84
120
|
|
85
121
|
document.body.appendChild(this.optionsList)
|
86
122
|
}
|
@@ -115,4 +115,16 @@ main, aside {
|
|
115
115
|
font-size: 12px;
|
116
116
|
padding: 0.15rem 0.3rem;
|
117
117
|
}
|
118
|
+
}
|
119
|
+
|
120
|
+
.lato-spin {
|
121
|
+
animation: spin 1s linear infinite;
|
122
|
+
}
|
123
|
+
@keyframes spin {
|
124
|
+
0% {
|
125
|
+
transform: rotate(0deg);
|
126
|
+
}
|
127
|
+
100% {
|
128
|
+
transform: rotate(360deg);
|
129
|
+
}
|
118
130
|
}
|
data/lib/lato/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.10.
|
4
|
+
version: 3.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregorio Galante
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|