css-zero 0.0.49 → 0.0.50

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: 20f634891b019d8f1daeb601e8c4f095ad0bc4a0e17e4dc8af56a265a8d578d3
4
- data.tar.gz: 1be7e6e2f94347c1419523f814f60f11bac915072c171a3d657d50cf576b8ab0
3
+ metadata.gz: 91b801a2c291cc802d00718d9ab4cade87e214b4ba369b11f6f5a479cab99701
4
+ data.tar.gz: dca783296168520201298efa156a848e37667b08b275015e4ca216c9baaa091b
5
5
  SHA512:
6
- metadata.gz: e49c19d5180e28cbfce2db4d3f7c21205de6708d8ef4cd340622846b52a4d089a7a32f829859e41577d68251e9d4f64cbaad629bf0d114ea9ad86087cdbe55d4
7
- data.tar.gz: d2855e45ea3959712e2736746fdc1da91e0266da4bff2c0db1629317e5cff53eb4b32392841ef93b3b42e218ed369dc375bdc8249776c30e62a3cb6a8e640f2d
6
+ metadata.gz: 84e0431f0af1beb34e11a7ee0cd1e8a247b469880a832185b4f2d555c15133ebe622741949f51686869d3bb98673b5664503f71d0de72f702301e412a3f99dfd
7
+ data.tar.gz: cc5ed39f59c52469fbb6bb5e162f04da66d570350ff83982d2a211d8790b4e1424a9e4567d79f6bc8e2cf0ec8c2b14f5c4f45792a76b80909cdbf4ffb898e5e6
@@ -1,3 +1,3 @@
1
1
  module CssZero
2
- VERSION = "0.0.49"
2
+ VERSION = "0.0.50"
3
3
  end
@@ -25,6 +25,7 @@ check_all:
25
25
  command:
26
26
  - app/assets/stylesheets/command.css
27
27
  - app/javascript/controllers/filter_controller.js
28
+ - app/javascript/controllers/list_controller.js
28
29
  - app/assets/images/search.svg
29
30
  collapsible:
30
31
  - app/javascript/controllers/collapsible_controller.js
@@ -47,11 +47,7 @@
47
47
  --btn-outline-size: 0;
48
48
  --btn-padding: var(--size-1_5) var(--size-2);
49
49
 
50
- &:hover {
51
- --btn-background: var(--color-secondary);
52
- }
53
-
54
- &:focus-visible {
50
+ &:is(:hover, [aria-selected=true]) {
55
51
  --btn-background: var(--color-secondary);
56
52
  }
57
53
  }
@@ -28,11 +28,7 @@
28
28
  --btn-outline-size: 0;
29
29
  --btn-padding: var(--size-1_5) var(--size-2);
30
30
 
31
- &:hover {
32
- --btn-background: var(--color-secondary);
33
- }
34
-
35
- &:focus-visible {
31
+ &:is(:hover, :focus-visible) {
36
32
  --btn-background: var(--color-secondary);
37
33
  }
38
34
  }
@@ -27,16 +27,18 @@ export default class extends Controller {
27
27
  }
28
28
 
29
29
  #selectMatches(value) {
30
- this.listTarget.querySelectorAll(`[data-value*=${value.toLowerCase()}]`).forEach((element) => {
30
+ this.listTarget.querySelectorAll(`[data-value*="${value.toLowerCase()}"]`).forEach((element) => {
31
31
  element.classList.add(this.selectedClass)
32
32
  })
33
33
  }
34
34
 
35
35
  #activate() {
36
36
  this.listTarget.classList.add(this.activeClass)
37
+ this.dispatch("after")
37
38
  }
38
39
 
39
40
  #deactivate() {
40
41
  this.listTarget.classList.remove(this.activeClass)
42
+ this.dispatch("after")
41
43
  }
42
44
  }
@@ -0,0 +1,79 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = [ "list", "option" ]
5
+ static values = { index: Number }
6
+
7
+ connect() {
8
+ this.#removeTabstops()
9
+ this.#selectFirstItem()
10
+ }
11
+
12
+ navigate(event) {
13
+ switch (event.key) {
14
+ case "ArrowUp":
15
+ event.preventDefault()
16
+ this.#prev()
17
+ break
18
+ case "ArrowDown":
19
+ event.preventDefault()
20
+ this.#next()
21
+ break
22
+ case "Enter":
23
+ event.preventDefault()
24
+ this.#clickSelected()
25
+ break
26
+ }
27
+ }
28
+
29
+ reset() {
30
+ this.indexValue = 0
31
+ this.#selectCurrentItem()
32
+ }
33
+
34
+ #prev() {
35
+ if (this.indexValue > 0) {
36
+ this.indexValue--
37
+ this.#selectCurrentItem()
38
+ }
39
+ }
40
+
41
+ #next() {
42
+ if (this.indexValue < this.#lastIndex) {
43
+ this.indexValue++
44
+ this.#selectCurrentItem()
45
+ }
46
+ }
47
+
48
+ #clickSelected() {
49
+ this.#visibleOptions[this.indexValue]?.click()
50
+ }
51
+
52
+ #removeTabstops() {
53
+ this.optionTargets.forEach(e => e.tabIndex = -1)
54
+ }
55
+
56
+ #selectFirstItem() {
57
+ this.optionTargets.forEach((element, index) => {
58
+ element.ariaSelected = index === 0
59
+ })
60
+ }
61
+
62
+ #selectCurrentItem() {
63
+ this.optionTargets.forEach((element, index) => {
64
+ element.ariaSelected = false
65
+ })
66
+
67
+ this.#visibleOptions.forEach((element, index) => {
68
+ element.ariaSelected = index === this.indexValue
69
+ })
70
+ }
71
+
72
+ get #lastIndex() {
73
+ return this.#visibleOptions.length -1
74
+ }
75
+
76
+ get #visibleOptions() {
77
+ return this.optionTargets.filter(e => e.offsetParent != null)
78
+ }
79
+ }
@@ -4,43 +4,42 @@ export default class extends Controller {
4
4
  static targets = [ "item" ]
5
5
  static values = { index: Number }
6
6
 
7
- #observer
8
-
9
- initialize() {
10
- this.#observer = new IntersectionObserver(this.#resetOnVisible.bind(this))
11
- }
12
-
13
7
  connect() {
14
- this.#observer.observe(this.element)
15
- }
16
-
17
- disconnect() {
18
- this.#observer.disconnect()
19
- }
20
-
21
- indexValueChanged(index, previousIndex) {
22
- this.#updateTabstops(previousIndex !== undefined)
8
+ this.#updateTabstops()
23
9
  }
24
10
 
25
11
  prev() {
26
- this.indexValue > 0 && this.indexValue--
12
+ if (this.indexValue > 0) {
13
+ this.indexValue--
14
+ this.#updateTabstops()
15
+ this.#focusCurrentItem()
16
+ }
27
17
  }
28
18
 
29
19
  next() {
30
- this.indexValue < this.itemTargets.length -1 && this.indexValue++
20
+ if (this.indexValue < this.#lastIndex) {
21
+ this.indexValue++
22
+ this.#updateTabstops()
23
+ this.#focusCurrentItem()
24
+ }
31
25
  }
32
26
 
33
- #resetOnVisible([ entry ]) {
34
- if (entry.isIntersecting) this.indexValue = 0
27
+ reset() {
28
+ this.indexValue = 0
29
+ this.#updateTabstops()
35
30
  }
36
31
 
37
- #updateTabstops(shouldFocus) {
32
+ #updateTabstops() {
38
33
  this.itemTargets.forEach((element, index) => {
39
- element.tabIndex = index == this.indexValue ? 0 : -1
34
+ element.tabIndex = index === this.indexValue ? 0 : -1
40
35
  })
36
+ }
41
37
 
42
- if (shouldFocus) {
43
- this.itemTargets[this.indexValue].focus()
44
- }
38
+ #focusCurrentItem() {
39
+ this.itemTargets[this.indexValue].focus()
40
+ }
41
+
42
+ get #lastIndex() {
43
+ return this.itemTargets.length -1
45
44
  }
46
45
  }
@@ -4,34 +4,47 @@ export default class extends Controller {
4
4
  static targets = [ "button", "tab" ]
5
5
  static values = { index: Number }
6
6
 
7
- indexValueChanged(index, previousIndex) {
8
- this.#showCurrentTab(previousIndex !== undefined)
7
+ connect() {
8
+ this.#showCurrentTab()
9
9
  }
10
10
 
11
11
  select({ target }) {
12
12
  this.indexValue = this.buttonTargets.indexOf(target)
13
+ this.#showCurrentTab()
13
14
  }
14
15
 
15
16
  prev() {
16
- this.indexValue > 0 && this.indexValue--
17
+ if (this.indexValue > 0) {
18
+ this.indexValue--
19
+ this.#showCurrentTab()
20
+ this.#focusCurrentButton()
21
+ }
17
22
  }
18
23
 
19
24
  next() {
20
- this.indexValue < this.tabTargets.length -1 && this.indexValue++
25
+ if (this.indexValue < this.#lastIndex) {
26
+ this.indexValue++
27
+ this.#showCurrentTab()
28
+ this.#focusCurrentButton()
29
+ }
21
30
  }
22
31
 
23
32
  #showCurrentTab(shouldFocus) {
24
33
  this.buttonTargets.forEach((element, index) => {
25
- element.ariaSelected = index == this.indexValue
26
- element.tabIndex = index == this.indexValue ? 0 : -1
34
+ element.ariaSelected = index === this.indexValue
35
+ element.tabIndex = index === this.indexValue ? 0 : -1
27
36
  })
28
37
 
29
38
  this.tabTargets.forEach((element, index) => {
30
39
  element.hidden = index !== this.indexValue
31
40
  })
41
+ }
32
42
 
33
- if (shouldFocus) {
34
- this.buttonTargets[this.indexValue].focus()
35
- }
43
+ #focusCurrentButton() {
44
+ this.buttonTargets[this.indexValue].focus()
45
+ }
46
+
47
+ get #lastIndex() {
48
+ return this.tabTargets.length -1
36
49
  }
37
50
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.49
4
+ version: 0.0.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lázaro Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-17 00:00:00.000000000 Z
11
+ date: 2024-10-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: lazaronixon@hotmail.com
@@ -93,6 +93,7 @@ files:
93
93
  - lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
94
94
  - lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js
95
95
  - lib/generators/css_zero/add/templates/app/javascript/controllers/lightbox_controller.js
96
+ - lib/generators/css_zero/add/templates/app/javascript/controllers/list_controller.js
96
97
  - lib/generators/css_zero/add/templates/app/javascript/controllers/local_time_controller.js
97
98
  - lib/generators/css_zero/add/templates/app/javascript/controllers/menu_controller.js
98
99
  - lib/generators/css_zero/add/templates/app/javascript/controllers/popover_controller.js