bh 6.1.2 → 6.1.3
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/MIT-LICENSE +1 -1
- data/app/javascript/controllers/bh/theme_controller.js +0 -1
- data/app/javascript/controllers/phone_controller.js +33 -0
- data/app/javascript/controllers/require_controller.js +20 -0
- data/app/javascript/controllers/submit_controller.js +24 -0
- data/lib/bh/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e1747260caae24ea851b2c9d7be5bf61952dd8dc2c92ce5da64c574fe3e6f7f
|
|
4
|
+
data.tar.gz: 27c05e536e988db0e6445f3a3713939a80e0794d20f43bfe7abf24338bb48e4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cfe7b1328fbe73760bed064ac579ae9d3b486e2e9ca51d40fc5064b175c779f9f1d4284796ce69c9575458f6aed08907596bd65351bfb4ce1958ff976d2ec56e
|
|
7
|
+
data.tar.gz: 461faeeb69bd09a80c9a159255d9563a8fa4bf98638b3256faad6aa8a2063f7c4fd85c68ddd4b78fdc34a0ceeea036b1606f65749f594c4de065410d3aa32d07
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ For more information about changelogs, check
|
|
|
6
6
|
[Keep a Changelog](http://keepachangelog.com) and
|
|
7
7
|
[Vandamme](http://tech-angels.github.io/vandamme).
|
|
8
8
|
|
|
9
|
+
## 6.1.3 - 2026-05-16
|
|
10
|
+
|
|
11
|
+
* [FEATURE] Added three Stimulus controllers (phone, require, submit)
|
|
12
|
+
|
|
9
13
|
## 6.1.2 - 2026-03-18
|
|
10
14
|
|
|
11
15
|
* [BREAKING CHANGE] The `table` method doesn't take the `headers` parameter anymore.
|
data/MIT-LICENSE
CHANGED
|
@@ -3,7 +3,6 @@ import { Controller } from "@hotwired/stimulus"
|
|
|
3
3
|
// Toggle color theme between dark and light when the element is clicked.
|
|
4
4
|
export default class extends Controller {
|
|
5
5
|
connect() {
|
|
6
|
-
console.log('connected')
|
|
7
6
|
document.documentElement.setAttribute('data-bs-theme', localStorage.getItem('theme'))
|
|
8
7
|
}
|
|
9
8
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
export default class extends Controller {
|
|
4
|
+
connect() {
|
|
5
|
+
this.#format(this.element)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
down(event) {
|
|
9
|
+
if (!event.key) { return }
|
|
10
|
+
if (event.ctrlKey) { return }
|
|
11
|
+
if (event.metaKey) { return }
|
|
12
|
+
if (event.key.length > 1) { return }
|
|
13
|
+
if (/[0-9.]/.test(event.key)) { return }
|
|
14
|
+
event.preventDefault()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
input(event) {
|
|
18
|
+
if (event.inputType === 'deleteContentBackward') { return }
|
|
19
|
+
if (/[\d-]{12}/.test(event.target.value)) { event.preventDefault() }
|
|
20
|
+
this.#format(event.target)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#format(element) {
|
|
24
|
+
const digits = element.value.replace(/\D/g,'').substring(0, 10)
|
|
25
|
+
const areaCode = digits.substring(0, 3)
|
|
26
|
+
const prefix = digits.substring(3, 6)
|
|
27
|
+
const suffix = digits.substring(6, 10)
|
|
28
|
+
|
|
29
|
+
if (digits.length > 5) { element.value = `${areaCode}-${prefix}-${suffix}` }
|
|
30
|
+
else if (digits.length > 2) { element.value = `${areaCode}-${prefix}` }
|
|
31
|
+
else if (digits.length > 0) { element.value = `${areaCode}` }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// If enabled on a form then disables any submit button in the form unless
|
|
4
|
+
// all the required inputs have values.
|
|
5
|
+
export default class extends Controller {
|
|
6
|
+
connect() {
|
|
7
|
+
this.toggle()
|
|
8
|
+
this.element.querySelectorAll('[required').forEach((input) =>
|
|
9
|
+
input.addEventListener('input', () => {this.toggle()})
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Disables the button if all chekboxes are unchecked.
|
|
14
|
+
toggle() {
|
|
15
|
+
const invalidValues = this.element.querySelectorAll('[required]:invalid')
|
|
16
|
+
const submitButtons = this.element.querySelectorAll('input[type="submit"]')
|
|
17
|
+
const disable = (invalidValues.length > 0);
|
|
18
|
+
[...submitButtons].map(button => button.disabled = disable)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// If enabled on a collection of checkboxes or radio buttons then disables any submit button in the
|
|
4
|
+
// form unless at least one checkbox/radio with a value is picked or a textarea is filled.
|
|
5
|
+
export default class extends Controller {
|
|
6
|
+
static targets = [ 'textarea' ]
|
|
7
|
+
|
|
8
|
+
connect() {
|
|
9
|
+
this.#toggle()
|
|
10
|
+
this.element.querySelectorAll('input').forEach((input) =>
|
|
11
|
+
input.addEventListener('change', () => {this.#toggle()})
|
|
12
|
+
)
|
|
13
|
+
this.textareaTarget.addEventListener('input', () => {this.#toggle()})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Disables the button if all valued chekboxes are unchecked and textareas are empty.
|
|
17
|
+
#toggle() {
|
|
18
|
+
const textareaValue = this.textareaTarget.value.trim()
|
|
19
|
+
const checkedBoxes = this.element.querySelectorAll('input:checked:not([value=""])')
|
|
20
|
+
const submitButtons = this.element.querySelectorAll('input[type="submit"]')
|
|
21
|
+
const disable = (checkedBoxes.length == 0 && textareaValue.length == 0);
|
|
22
|
+
[...submitButtons].map(button => button.disabled = disable)
|
|
23
|
+
}
|
|
24
|
+
}
|
data/lib/bh/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bh
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.1.
|
|
4
|
+
version: 6.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Claudio Baccigalupo
|
|
@@ -26,6 +26,9 @@ files:
|
|
|
26
26
|
- README.md
|
|
27
27
|
- app/assets/stylesheets/bh.css
|
|
28
28
|
- app/javascript/controllers/bh/theme_controller.js
|
|
29
|
+
- app/javascript/controllers/phone_controller.js
|
|
30
|
+
- app/javascript/controllers/require_controller.js
|
|
31
|
+
- app/javascript/controllers/submit_controller.js
|
|
29
32
|
- app/views/bh/_grid.html.erb
|
|
30
33
|
- app/views/bh/_table.html.erb
|
|
31
34
|
- bh.gemspec
|
|
@@ -51,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
51
54
|
- !ruby/object:Gem::Version
|
|
52
55
|
version: '0'
|
|
53
56
|
requirements: []
|
|
54
|
-
rubygems_version: 4.0.
|
|
57
|
+
rubygems_version: 4.0.3
|
|
55
58
|
specification_version: 4
|
|
56
59
|
summary: Bh provides a set of powerful helpers that streamlines the use of Bootstrap
|
|
57
60
|
components in Rails views.
|