css-zero 0.0.47 → 0.0.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: e2efe1919888b0e11a440ada88d32d728814c3a96f67e877e87009836a5c9e3a
4
- data.tar.gz: eac6e9c80a23b456a92dec265859959fadb0e34298904308714df91bb3220d84
3
+ metadata.gz: 2c2fa4f9172129b3e90a0a4cdcb7870f5467d8cbee3fd8d9d621eebd65212912
4
+ data.tar.gz: 0ddf2089702a14920122e9ce9d421dc8017e6a2c3fe9aa42284b83700b83a357
5
5
  SHA512:
6
- metadata.gz: 9180e92a3179e523600fe9c2a1090a56fc1625798f9d261262f0d2fe6e998e11b777db777c9a3982d7ca76570bc8d43bc68c48efc6016879462adcd23c300cab
7
- data.tar.gz: e05418691df476b525df12b6df0e4a1159947bc45cc21b3d2f7378dfb7767dd235bb20f3d4fdb4dd6c481851ac60b0d2255101b3f09dd01d323bdbd27a9d7acc
6
+ metadata.gz: a98928f94335f61b029d53858d524919c940f14012bdaa9af96b22c924f03d6bff5b79c1aa774caebb4d7b494de2a9392f4e6315dc7445c9734244f09e88313f
7
+ data.tar.gz: d682b0a2a721c13c04e250ca332eaf1bd531b173b96552b60fd1f93f8cb94813a139b4926fdb718c423412d9151be3b18242235d0e51cc21886411ad28ab2a93
@@ -1,3 +1,3 @@
1
1
  module CssZero
2
- VERSION = "0.0.47"
2
+ VERSION = "0.0.48"
3
3
  end
@@ -4,37 +4,29 @@ export default class extends Controller {
4
4
  static targets = [ "item" ]
5
5
  static values = { index: Number }
6
6
 
7
- indexValueChanged() {
8
- this.#removeTabstops()
7
+ indexValueChanged(index, previousIndex) {
8
+ this.#updateTabstops(previousIndex !== undefined)
9
9
  }
10
10
 
11
11
  prev() {
12
- const hasPrevious = this.indexValue > 0
13
- hasPrevious && this.indexValue--
14
- hasPrevious && this.#focusCurrentItem()
12
+ this.indexValue > 0 && this.indexValue--
15
13
  }
16
14
 
17
15
  next() {
18
- const hasNext = this.indexValue < this.#lastIndex
19
- hasNext && this.indexValue++
20
- hasNext && this.#focusCurrentItem()
16
+ this.indexValue < this.itemTargets.length -1 && this.indexValue++
21
17
  }
22
18
 
23
19
  reset() {
24
20
  this.indexValue = 0
25
- this.#focusCurrentItem()
26
21
  }
27
22
 
28
- #removeTabstops() {
29
- this.itemTargets.forEach(item => item.tabIndex = -1)
30
- }
31
-
32
- #focusCurrentItem() {
33
- this.itemTargets[this.indexValue].tabIndex = 0
34
- this.itemTargets[this.indexValue].focus()
35
- }
23
+ #updateTabstops(shouldFocus) {
24
+ this.itemTargets.forEach((element, index) => {
25
+ element.tabIndex = index == this.indexValue ? 0 : -1
26
+ })
36
27
 
37
- get #lastIndex() {
38
- return this.itemTargets.length -1
28
+ if (shouldFocus) {
29
+ this.itemTargets[this.indexValue].focus()
30
+ }
39
31
  }
40
32
  }
@@ -6,10 +6,7 @@ export default class extends Controller {
6
6
  static targets = [ "button", "menu" ]
7
7
  static classes = [ "flip" ]
8
8
 
9
- #closeTimer
10
-
11
9
  show() {
12
- this.#resetTimer()
13
10
  this.menuTarget.show()
14
11
  this.#updateExpanded()
15
12
  this.#orient()
@@ -20,10 +17,6 @@ export default class extends Controller {
20
17
  this.#updateExpanded()
21
18
  }
22
19
 
23
- closeLater() {
24
- this.#closeTimer = setTimeout(() => this.close(), 300)
25
- }
26
-
27
20
  toggle() {
28
21
  this.menuTarget.open ? this.close() : this.show()
29
22
  }
@@ -32,10 +25,6 @@ export default class extends Controller {
32
25
  !this.element.contains(target) && this.close()
33
26
  }
34
27
 
35
- #resetTimer() {
36
- clearTimeout(this.#closeTimer)
37
- }
38
-
39
28
  #orient() {
40
29
  this.menuTarget.classList.toggle(this.flipClass, this.#distanceToBottom < BOTTOM_THRESHOLD)
41
30
  }
@@ -4,8 +4,8 @@ export default class extends Controller {
4
4
  static targets = [ "button", "tab" ]
5
5
  static values = { index: Number }
6
6
 
7
- indexValueChanged() {
8
- this.#showCurrentTab()
7
+ indexValueChanged(index, previousIndex) {
8
+ this.#showCurrentTab(previousIndex !== undefined)
9
9
  }
10
10
 
11
11
  select({ target }) {
@@ -13,33 +13,25 @@ export default class extends Controller {
13
13
  }
14
14
 
15
15
  prev() {
16
- const hasPrevious = this.indexValue > 0
17
- hasPrevious && this.indexValue--
18
- hasPrevious && this.#focusCurrentButton()
16
+ this.indexValue > 0 && this.indexValue--
19
17
  }
20
18
 
21
19
  next() {
22
- const hasNext = this.indexValue < this.#lastIndex
23
- hasNext && this.indexValue++
24
- hasNext && this.#focusCurrentButton()
20
+ this.indexValue < this.tabTargets.length -1 && this.indexValue++
25
21
  }
26
22
 
27
- #showCurrentTab() {
28
- this.buttonTargets.forEach((button, index) => {
29
- button.ariaSelected = index == this.indexValue
30
- button.tabIndex = index == this.indexValue ? 0 : -1
23
+ #showCurrentTab(shouldFocus) {
24
+ this.buttonTargets.forEach((element, index) => {
25
+ element.ariaSelected = index == this.indexValue
26
+ element.tabIndex = index == this.indexValue ? 0 : -1
31
27
  })
32
28
 
33
- this.tabTargets.forEach((tab, index) => {
34
- tab.hidden = index !== this.indexValue
29
+ this.tabTargets.forEach((element, index) => {
30
+ element.hidden = index !== this.indexValue
35
31
  })
36
- }
37
-
38
- #focusCurrentButton() {
39
- this.buttonTargets[this.indexValue].focus()
40
- }
41
32
 
42
- get #lastIndex() {
43
- return this.tabTargets.length -1
33
+ if (shouldFocus) {
34
+ this.buttonTargets[this.indexValue].focus()
35
+ }
44
36
  }
45
37
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.47
4
+ version: 0.0.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lázaro Nixon