css-zero 0.0.48 → 0.0.50

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: 2c2fa4f9172129b3e90a0a4cdcb7870f5467d8cbee3fd8d9d621eebd65212912
4
- data.tar.gz: 0ddf2089702a14920122e9ce9d421dc8017e6a2c3fe9aa42284b83700b83a357
3
+ metadata.gz: 91b801a2c291cc802d00718d9ab4cade87e214b4ba369b11f6f5a479cab99701
4
+ data.tar.gz: dca783296168520201298efa156a848e37667b08b275015e4ca216c9baaa091b
5
5
  SHA512:
6
- metadata.gz: a98928f94335f61b029d53858d524919c940f14012bdaa9af96b22c924f03d6bff5b79c1aa774caebb4d7b494de2a9392f4e6315dc7445c9734244f09e88313f
7
- data.tar.gz: d682b0a2a721c13c04e250ca332eaf1bd531b173b96552b60fd1f93f8cb94813a139b4926fdb718c423412d9151be3b18242235d0e51cc21886411ad28ab2a93
6
+ metadata.gz: 84e0431f0af1beb34e11a7ee0cd1e8a247b469880a832185b4f2d555c15133ebe622741949f51686869d3bb98673b5664503f71d0de72f702301e412a3f99dfd
7
+ data.tar.gz: cc5ed39f59c52469fbb6bb5e162f04da66d570350ff83982d2a211d8790b4e1424a9e4567d79f6bc8e2cf0ec8c2b14f5c4f45792a76b80909cdbf4ffb898e5e6
@@ -1,3 +1,3 @@
1
1
  module CssZero
2
- VERSION = "0.0.48"
2
+ VERSION = "0.0.50"
3
3
  end
@@ -2,7 +2,7 @@ Description:
2
2
  This will add components into your project.
3
3
 
4
4
  Components:
5
- accordion alert avatar badge breadcrumb button card carousel check_all command collapsible dialog dropdown flash fullscreen hotkey input input_concerns layouts lightbox local_time pagination progress prose sheet skeleton switch table tabs upload_preview toggle web_share
5
+ accordion alert avatar badge breadcrumb button card carousel check_all command collapsible dialog dropdown flash form fullscreen hotkey input input_concerns layouts lightbox local_time pagination progress prose sheet skeleton switch table tabs upload_preview toggle web_share
6
6
 
7
7
  Example:
8
8
  bin/rails generate css_zero:add [components...]
@@ -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
@@ -40,6 +41,8 @@ dropdown:
40
41
  flash:
41
42
  - app/assets/stylesheets/flash.css
42
43
  - app/javascript/controllers/element_removal_controller.js
44
+ form:
45
+ - app/javascript/controllers/form_controller.js
43
46
  fullscreen:
44
47
  - app/javascript/controllers/fullscreen_controller.js
45
48
  hotkey:
@@ -88,7 +91,6 @@ skeleton:
88
91
  - app/assets/stylesheets/skeleton.css
89
92
  switch:
90
93
  - app/assets/stylesheets/switch.css
91
- - app/javascript/controllers/form_controller.js
92
94
  table:
93
95
  - app/assets/stylesheets/table.css
94
96
  tabs:
@@ -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
  }
@@ -10,4 +10,8 @@ export default class extends Controller {
10
10
  cancel() {
11
11
  this.cancelTarget?.click()
12
12
  }
13
+
14
+ preventAttachment(event) {
15
+ event.preventDefault()
16
+ }
13
17
  }
@@ -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,29 +4,42 @@ export default class extends Controller {
4
4
  static targets = [ "item" ]
5
5
  static values = { index: Number }
6
6
 
7
- indexValueChanged(index, previousIndex) {
8
- this.#updateTabstops(previousIndex !== undefined)
7
+ connect() {
8
+ this.#updateTabstops()
9
9
  }
10
10
 
11
11
  prev() {
12
- this.indexValue > 0 && this.indexValue--
12
+ if (this.indexValue > 0) {
13
+ this.indexValue--
14
+ this.#updateTabstops()
15
+ this.#focusCurrentItem()
16
+ }
13
17
  }
14
18
 
15
19
  next() {
16
- this.indexValue < this.itemTargets.length -1 && this.indexValue++
20
+ if (this.indexValue < this.#lastIndex) {
21
+ this.indexValue++
22
+ this.#updateTabstops()
23
+ this.#focusCurrentItem()
24
+ }
17
25
  }
18
26
 
19
27
  reset() {
20
28
  this.indexValue = 0
29
+ this.#updateTabstops()
21
30
  }
22
31
 
23
- #updateTabstops(shouldFocus) {
32
+ #updateTabstops() {
24
33
  this.itemTargets.forEach((element, index) => {
25
- element.tabIndex = index == this.indexValue ? 0 : -1
34
+ element.tabIndex = index === this.indexValue ? 0 : -1
26
35
  })
36
+ }
27
37
 
28
- if (shouldFocus) {
29
- this.itemTargets[this.indexValue].focus()
30
- }
38
+ #focusCurrentItem() {
39
+ this.itemTargets[this.indexValue].focus()
40
+ }
41
+
42
+ get #lastIndex() {
43
+ return this.itemTargets.length -1
31
44
  }
32
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
  }
@@ -16,6 +16,16 @@ class CssZero::InstallGenerator < Rails::Generators::Base
16
16
  append_to_file "config/importmap.rb", %(pin_all_from "app/javascript/helpers", under: "helpers"\n)
17
17
  end
18
18
 
19
+ def copy_javascript_initializers
20
+ copy_file "app/javascript/initializers/index.js"
21
+ end
22
+
23
+ def pin_javascript_initializers
24
+ return unless install_with_importmap?
25
+ append_to_file "config/importmap.rb", %(pin_all_from "app/javascript/initializers", under: "initializers"\n)
26
+ append_to_file "app/javascript/application.js", %(import "initializers"\n)
27
+ end
28
+
19
29
  private
20
30
  def install_with_importmap?
21
31
  Rails.root.join("config/importmap.rb").exist?
@@ -0,0 +1,2 @@
1
+ // import "initializers/current"
2
+ // import "initializers/time_zone_cookie"
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.48
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-15 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
@@ -105,6 +106,7 @@ files:
105
106
  - lib/generators/css_zero/install/templates/app/assets/stylesheets/base.css
106
107
  - lib/generators/css_zero/install/templates/app/javascript/helpers/cookie_helpers.js
107
108
  - lib/generators/css_zero/install/templates/app/javascript/helpers/timing_helpers.js
109
+ - lib/generators/css_zero/install/templates/app/javascript/initializers/index.js
108
110
  homepage: https://github.com/lazaronixon/css-zero
109
111
  licenses:
110
112
  - MIT