css-zero 0.0.47 → 0.0.49

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: e2efe1919888b0e11a440ada88d32d728814c3a96f67e877e87009836a5c9e3a
4
- data.tar.gz: eac6e9c80a23b456a92dec265859959fadb0e34298904308714df91bb3220d84
3
+ metadata.gz: 20f634891b019d8f1daeb601e8c4f095ad0bc4a0e17e4dc8af56a265a8d578d3
4
+ data.tar.gz: 1be7e6e2f94347c1419523f814f60f11bac915072c171a3d657d50cf576b8ab0
5
5
  SHA512:
6
- metadata.gz: 9180e92a3179e523600fe9c2a1090a56fc1625798f9d261262f0d2fe6e998e11b777db777c9a3982d7ca76570bc8d43bc68c48efc6016879462adcd23c300cab
7
- data.tar.gz: e05418691df476b525df12b6df0e4a1159947bc45cc21b3d2f7378dfb7767dd235bb20f3d4fdb4dd6c481851ac60b0d2255101b3f09dd01d323bdbd27a9d7acc
6
+ metadata.gz: e49c19d5180e28cbfce2db4d3f7c21205de6708d8ef4cd340622846b52a4d089a7a32f829859e41577d68251e9d4f64cbaad629bf0d114ea9ad86087cdbe55d4
7
+ data.tar.gz: d2855e45ea3959712e2736746fdc1da91e0266da4bff2c0db1629317e5cff53eb4b32392841ef93b3b42e218ed369dc375bdc8249776c30e62a3cb6a8e640f2d
@@ -1,3 +1,3 @@
1
1
  module CssZero
2
- VERSION = "0.0.47"
2
+ VERSION = "0.0.49"
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...]
@@ -40,6 +40,8 @@ dropdown:
40
40
  flash:
41
41
  - app/assets/stylesheets/flash.css
42
42
  - app/javascript/controllers/element_removal_controller.js
43
+ form:
44
+ - app/javascript/controllers/form_controller.js
43
45
  fullscreen:
44
46
  - app/javascript/controllers/fullscreen_controller.js
45
47
  hotkey:
@@ -88,7 +90,6 @@ skeleton:
88
90
  - app/assets/stylesheets/skeleton.css
89
91
  switch:
90
92
  - app/assets/stylesheets/switch.css
91
- - app/javascript/controllers/form_controller.js
92
93
  table:
93
94
  - app/assets/stylesheets/table.css
94
95
  tabs:
@@ -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
  }
@@ -4,37 +4,43 @@ export default class extends Controller {
4
4
  static targets = [ "item" ]
5
5
  static values = { index: Number }
6
6
 
7
- indexValueChanged() {
8
- this.#removeTabstops()
7
+ #observer
8
+
9
+ initialize() {
10
+ this.#observer = new IntersectionObserver(this.#resetOnVisible.bind(this))
9
11
  }
10
12
 
11
- prev() {
12
- const hasPrevious = this.indexValue > 0
13
- hasPrevious && this.indexValue--
14
- hasPrevious && this.#focusCurrentItem()
13
+ connect() {
14
+ this.#observer.observe(this.element)
15
15
  }
16
16
 
17
- next() {
18
- const hasNext = this.indexValue < this.#lastIndex
19
- hasNext && this.indexValue++
20
- hasNext && this.#focusCurrentItem()
17
+ disconnect() {
18
+ this.#observer.disconnect()
19
+ }
20
+
21
+ indexValueChanged(index, previousIndex) {
22
+ this.#updateTabstops(previousIndex !== undefined)
21
23
  }
22
24
 
23
- reset() {
24
- this.indexValue = 0
25
- this.#focusCurrentItem()
25
+ prev() {
26
+ this.indexValue > 0 && this.indexValue--
26
27
  }
27
28
 
28
- #removeTabstops() {
29
- this.itemTargets.forEach(item => item.tabIndex = -1)
29
+ next() {
30
+ this.indexValue < this.itemTargets.length -1 && this.indexValue++
30
31
  }
31
32
 
32
- #focusCurrentItem() {
33
- this.itemTargets[this.indexValue].tabIndex = 0
34
- this.itemTargets[this.indexValue].focus()
33
+ #resetOnVisible([ entry ]) {
34
+ if (entry.isIntersecting) this.indexValue = 0
35
35
  }
36
36
 
37
- get #lastIndex() {
38
- return this.itemTargets.length -1
37
+ #updateTabstops(shouldFocus) {
38
+ this.itemTargets.forEach((element, index) => {
39
+ element.tabIndex = index == this.indexValue ? 0 : -1
40
+ })
41
+
42
+ if (shouldFocus) {
43
+ this.itemTargets[this.indexValue].focus()
44
+ }
39
45
  }
40
46
  }
@@ -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
  }
@@ -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.47
4
+ version: 0.0.49
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-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: lazaronixon@hotmail.com
@@ -105,6 +105,7 @@ files:
105
105
  - lib/generators/css_zero/install/templates/app/assets/stylesheets/base.css
106
106
  - lib/generators/css_zero/install/templates/app/javascript/helpers/cookie_helpers.js
107
107
  - lib/generators/css_zero/install/templates/app/javascript/helpers/timing_helpers.js
108
+ - lib/generators/css_zero/install/templates/app/javascript/initializers/index.js
108
109
  homepage: https://github.com/lazaronixon/css-zero
109
110
  licenses:
110
111
  - MIT