lato 3.10.2 → 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: f45b94061e1d1f1c1755637ff86f2ae9f20dab616ef82915ccc418c3dea27f8c
4
- data.tar.gz: f2a0cc9193e80ea5295ddbafd954aa394f149204ca9117e20d9eaa097bef03dc
3
+ metadata.gz: 31073ee8b736613fd453f8a1b467f0c2c84db71dfdb06a647dee521963e1919a
4
+ data.tar.gz: af8e072068c0dffab1d40cc10f22cae7ce0d5ea1183c49ff65f24f587d3e2919
5
5
  SHA512:
6
- metadata.gz: 21d76f318792b1542778fa0be09cf20b35b616175357e6e8924899e6b3cc3ec58f43660e5b0383596463d34c36d6f0ebf477652250f529c14f0edf948f2666e2
7
- data.tar.gz: 0dc185834763c0b2a13e8ad21229f3128af0c68694c8cf4d2b474e18008495b32908c993f238f1c3bc86d9e4a94e195d3daa241272fbfc0083fff923874d0866
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
  }
@@ -7,6 +7,17 @@ export default class extends Controller {
7
7
 
8
8
  connect() {
9
9
  this.tooltip = new bootstrap.Tooltip(this.element)
10
+
11
+ // HACK: Force tooltip to be closed when a boostrap modal is opened/closed
12
+ const modals = document.querySelectorAll('.modal')
13
+ modals.forEach((modal) => {
14
+ modal.addEventListener('show.bs.modal', () => {
15
+ setTimeout(() => this.tooltip.hide(), 0)
16
+ })
17
+ modal.addEventListener('hide.bs.modal', () => {
18
+ setTimeout(() => this.tooltip.hide(), 0)
19
+ })
20
+ })
10
21
  }
11
22
 
12
23
  disconnect() {
@@ -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.2"
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.2
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-14 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