keystone_ui 0.42.0 → 0.43.0
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ebff0095e42a243e35a441d1fd749813728e8abe011529ec23cb599602312c45
|
|
4
|
+
data.tar.gz: 0fc80932c6f8b9ea4c8511fa4ba83e9989eb97e4a74cbe9339999efdd8f62249
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f9b81f7b07775c5ba362010016b5dacd0bb9a298620723cb20fee5fbd2ee96da12211256da33f4bb72029e8bfcc3392e6b5d42fad8efceb33a48d11642cbf99a
|
|
7
|
+
data.tar.gz: b0debeea715db19ec6aaac0731abd03bd7f4670a9f2a979f0a541a72588cccb2324b2569f3962c70812af5b0c514af17e57adcb46de28f509a27a173b84cd2fc
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
|
2
2
|
|
|
3
3
|
export default class extends Controller {
|
|
4
|
-
static targets = ["swatch", "
|
|
4
|
+
static targets = ["swatch", "text", "input", "panel", "svArea", "svGradient", "svCursor", "hueSlider"]
|
|
5
5
|
static values = { value: String }
|
|
6
6
|
|
|
7
7
|
connect() {
|
|
@@ -10,7 +10,7 @@ export default class extends Controller {
|
|
|
10
10
|
this.val = 1
|
|
11
11
|
this.dragging = false
|
|
12
12
|
|
|
13
|
-
if (this.valueValue) {
|
|
13
|
+
if (this.isSixDigitHex(this.valueValue)) {
|
|
14
14
|
this.setFromHex(this.valueValue)
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -55,6 +55,16 @@ export default class extends Controller {
|
|
|
55
55
|
this.updateColor()
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
textChanged() {
|
|
59
|
+
const colour = this.textTarget.value
|
|
60
|
+
if (!CSS.supports("color", colour)) return
|
|
61
|
+
|
|
62
|
+
if (this.isSixDigitHex(colour)) this.setFromHex(colour)
|
|
63
|
+
this.swatchTarget.style.backgroundColor = colour
|
|
64
|
+
this.inputTarget.value = colour
|
|
65
|
+
this.inputTarget.dispatchEvent(new Event("change", { bubbles: true }))
|
|
66
|
+
}
|
|
67
|
+
|
|
58
68
|
svDown(event) {
|
|
59
69
|
event.preventDefault()
|
|
60
70
|
this.dragging = true
|
|
@@ -92,7 +102,7 @@ export default class extends Controller {
|
|
|
92
102
|
updateColor() {
|
|
93
103
|
const hex = this.hsvToHex(this.hue, this.sat, this.val)
|
|
94
104
|
this.swatchTarget.style.backgroundColor = hex
|
|
95
|
-
this.
|
|
105
|
+
this.textTarget.value = hex
|
|
96
106
|
this.inputTarget.value = hex
|
|
97
107
|
|
|
98
108
|
this.inputTarget.dispatchEvent(new Event("change", { bubbles: true }))
|
|
@@ -118,6 +128,10 @@ export default class extends Controller {
|
|
|
118
128
|
}
|
|
119
129
|
}
|
|
120
130
|
|
|
131
|
+
isSixDigitHex(colour) {
|
|
132
|
+
return /^#[0-9a-f]{6}$/i.test(colour)
|
|
133
|
+
}
|
|
134
|
+
|
|
121
135
|
hsvToHex(h, s, v) {
|
|
122
136
|
const c = v * s
|
|
123
137
|
const x = c * (1 - Math.abs(((h / 60) % 2) - 1))
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
data-color-picker-target="swatch"
|
|
11
11
|
data-action="color-picker#toggle">
|
|
12
12
|
</button>
|
|
13
|
-
<
|
|
13
|
+
<input type="text" class="<%= TEXT_FIELD_CLASSES %>" value="<%= value %>" data-color-picker-target="text" data-action="input->color-picker#textChanged">
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
16
|
<input type="hidden" name="<%= name %>" value="<%= value %>" data-color-picker-target="input">
|
data/lib/keystone_ui/version.rb
CHANGED