hotwire_combobox 0.1.34 → 0.1.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/controllers/hw_combobox_controller.js +3 -3
- data/app/assets/javascripts/hw_combobox/helpers.js +1 -3
- data/app/assets/javascripts/hw_combobox/models/combobox/filtering.js +1 -1
- data/app/assets/javascripts/hw_combobox/models/combobox/selection.js +12 -9
- data/app/assets/javascripts/hw_combobox/models/combobox/toggle.js +0 -4
- data/lib/hotwire_combobox/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b9f936869948e6767d3cdf4f02f226bfe4c3954d57172b37388239884b69ae6
|
4
|
+
data.tar.gz: b5495f56d66183c5ebb6c54a6a8e5278391df921f304b36b9da9ffb3bf752576
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bb2f124171055bc2b46c7584f31b3ae6426979dd9485645e8364bef559aa86cfa905f62f0db47e79d48db98f42d422b9c8fd9f342729e7da4704385d8544e3b
|
7
|
+
data.tar.gz: 27e49fa1cfd828d23f7dcf82b75a2ba7d7edc4adc8fcff88d35cab8cc41e666f39dffb82209c68740e8b4d9ec9236b1db3513e7c2952cf80cf6f96dc7608a39e
|
@@ -73,10 +73,10 @@ export default class HwComboboxController extends Concerns(...concerns) {
|
|
73
73
|
endOfOptionsStreamTargetConnected(element) {
|
74
74
|
const inputType = element.dataset.inputType
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
if (inputType) {
|
76
|
+
if (inputType && inputType !== "hw:ensureSelection") {
|
79
77
|
this._commitFilter({ inputType })
|
78
|
+
} else {
|
79
|
+
this._preselectOption()
|
80
80
|
}
|
81
81
|
}
|
82
82
|
}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
export const nullEvent = new Event("NULL")
|
2
|
-
|
3
1
|
export function Concerns(Base, ...mixins) {
|
4
2
|
return mixins.reduce((accumulator, current) => current(accumulator), Base)
|
5
3
|
}
|
@@ -39,7 +37,7 @@ export function startsWith(string, substring) {
|
|
39
37
|
return string.toLowerCase().startsWith(substring.toLowerCase())
|
40
38
|
}
|
41
39
|
|
42
|
-
export function debounce(fn, delay =
|
40
|
+
export function debounce(fn, delay = 300) {
|
43
41
|
let timeoutId = null
|
44
42
|
|
45
43
|
return (...args) => {
|
@@ -48,7 +48,7 @@ Combobox.Filtering = Base => class extends Base {
|
|
48
48
|
// Consider +_query+ will contain the full autocompleted value
|
49
49
|
// after a certain point in the call chain.
|
50
50
|
get _query() {
|
51
|
-
return this._actingCombobox.value
|
51
|
+
return this._actingCombobox.value
|
52
52
|
}
|
53
53
|
|
54
54
|
set _query(value) {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import Combobox from "hw_combobox/models/combobox/base"
|
2
|
-
import { wrapAroundAccess
|
2
|
+
import { wrapAroundAccess } from "hw_combobox/helpers"
|
3
3
|
|
4
4
|
Combobox.Selection = Base => class extends Base {
|
5
5
|
selectOption(event) {
|
@@ -32,8 +32,6 @@ Combobox.Selection = Base => class extends Base {
|
|
32
32
|
if (selected) {
|
33
33
|
this.hiddenFieldTarget.value = option.dataset.value
|
34
34
|
option.scrollIntoView({ block: "nearest" })
|
35
|
-
} else {
|
36
|
-
this.hiddenFieldTarget.value = null
|
37
35
|
}
|
38
36
|
}
|
39
37
|
|
@@ -48,6 +46,7 @@ Combobox.Selection = Base => class extends Base {
|
|
48
46
|
_deselect() {
|
49
47
|
const option = this._selectedOptionElement
|
50
48
|
if (option) this._commitSelection(option, { selected: false })
|
49
|
+
this.hiddenFieldTarget.value = null
|
51
50
|
}
|
52
51
|
|
53
52
|
_selectNew() {
|
@@ -71,10 +70,10 @@ Combobox.Selection = Base => class extends Base {
|
|
71
70
|
}
|
72
71
|
}
|
73
72
|
|
74
|
-
|
75
|
-
if (this.
|
76
|
-
this._select(this.
|
77
|
-
this.filter(
|
73
|
+
_ensureSelection() {
|
74
|
+
if (this._shouldEnsureSelection) {
|
75
|
+
this._select(this._ensurableOption, { force: true })
|
76
|
+
this.filter({ inputType: "hw:ensureSelection" })
|
78
77
|
}
|
79
78
|
}
|
80
79
|
|
@@ -82,7 +81,11 @@ Combobox.Selection = Base => class extends Base {
|
|
82
81
|
return this.hiddenFieldTarget.value && !this._selectedOptionElement
|
83
82
|
}
|
84
83
|
|
85
|
-
get
|
86
|
-
return this._isQueried && !!this.
|
84
|
+
get _shouldEnsureSelection() {
|
85
|
+
return this._isQueried && !!this._ensurableOption && !this._isNewOptionWithPotentialMatches
|
86
|
+
}
|
87
|
+
|
88
|
+
get _ensurableOption() {
|
89
|
+
return this._selectedOptionElement || this._visibleOptionElements[0]
|
87
90
|
}
|
88
91
|
}
|
@@ -50,10 +50,6 @@ Combobox.Toggle = Base => class extends Base {
|
|
50
50
|
return clientX >= left && clientX <= right && clientY >= top && clientY <= bottom
|
51
51
|
}
|
52
52
|
|
53
|
-
_ensureSelection() {
|
54
|
-
this._selectFuzzyMatch()
|
55
|
-
}
|
56
|
-
|
57
53
|
_openByFocusing() {
|
58
54
|
this._actingCombobox.focus()
|
59
55
|
}
|