lato 3.10.3 → 3.10.4

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: e00cca9110424c452feab9aea4a1f4b812f3af01b0f863aff89d6d9f2736de72
4
- data.tar.gz: 0af37bfd2eb48b193353ec7a54f1155906efa746a9df70d4cb3b09c44598b978
3
+ metadata.gz: 31073ee8b736613fd453f8a1b467f0c2c84db71dfdb06a647dee521963e1919a
4
+ data.tar.gz: af8e072068c0dffab1d40cc10f22cae7ce0d5ea1183c49ff65f24f587d3e2919
5
5
  SHA512:
6
- metadata.gz: 9aa8aaee2ebc20f2340b298d39a43275bd8c96d6454fdb5b8da1622c87af18702e0afcf9ac38d26a24092b8a03834671e5de8306e93b19d5c9d6071890bba081
7
- data.tar.gz: 29075530da5562decca1a38f13197d3f627c97f83012652661ec4841f78e4689b399b02b44717235e95cbd4f855bf8b775318ea5c8fef491e604bae7144253aa
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 || value.length < 3) return
46
+ if (!value) return
47
47
 
48
48
  try {
49
- const response = await fetch(this.pathValue + '?q=' + value)
50
- const data = await response.json()
51
- this.suggestShow(data)
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.forEach((option) => {
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('list-group-item-action')
75
- li.style.cursor = 'pointer'
76
- li.innerText = typeof option == 'string' ? option : option.label
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
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "3.10.3"
2
+ VERSION = "3.10.4"
3
3
  end
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.3
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-18 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails