hotwire_combobox 0.1.43 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/app/assets/javascripts/controllers/hw_combobox_controller.js +29 -3
- data/app/assets/javascripts/hotwire_combobox.esm.js +442 -104
- data/app/assets/javascripts/hotwire_combobox.umd.js +442 -104
- data/app/assets/javascripts/hw_combobox/helpers.js +16 -0
- data/app/assets/javascripts/hw_combobox/models/combobox/announcements.js +7 -0
- data/app/assets/javascripts/hw_combobox/models/combobox/dialog.js +1 -1
- data/app/assets/javascripts/hw_combobox/models/combobox/events.js +21 -11
- data/app/assets/javascripts/hw_combobox/models/combobox/filtering.js +20 -12
- data/app/assets/javascripts/hw_combobox/models/combobox/form_field.js +74 -0
- data/app/assets/javascripts/hw_combobox/models/combobox/multiselect.js +160 -0
- data/app/assets/javascripts/hw_combobox/models/combobox/navigation.js +15 -6
- data/app/assets/javascripts/hw_combobox/models/combobox/options.js +19 -7
- data/app/assets/javascripts/hw_combobox/models/combobox/selection.js +50 -49
- data/app/assets/javascripts/hw_combobox/models/combobox/toggle.js +33 -16
- data/app/assets/javascripts/hw_combobox/models/combobox/validity.js +1 -1
- data/app/assets/javascripts/hw_combobox/models/combobox.js +3 -0
- data/app/assets/stylesheets/hotwire_combobox.css +90 -19
- data/app/presenters/hotwire_combobox/component/customizable.rb +9 -1
- data/app/presenters/hotwire_combobox/component.rb +106 -32
- data/app/presenters/hotwire_combobox/listbox/group.rb +47 -0
- data/app/presenters/hotwire_combobox/listbox/item/collection.rb +14 -0
- data/app/presenters/hotwire_combobox/listbox/item.rb +111 -0
- data/app/presenters/hotwire_combobox/listbox/option.rb +9 -4
- data/app/views/hotwire_combobox/_component.html.erb +1 -0
- data/app/views/hotwire_combobox/_selection_chip.turbo_stream.erb +8 -0
- data/app/views/hotwire_combobox/layouts/_selection_chip.turbo_stream.erb +7 -0
- data/lib/hotwire_combobox/helper.rb +112 -91
- data/lib/hotwire_combobox/version.rb +1 -1
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9649cc031cc63f665e78c4f72857f72698d42af893d8204cab739a5817be27b8
|
4
|
+
data.tar.gz: f9e791cc61927caebd9db3c32cf3e71382f6d77e4f54c8275348b02600fce8d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f6c132e19554295758e13763663a6e0d3b0e7a0a413088a25aed723370dd5967133af3e2660e9ef4ecb16d661f39232bb36ac9c08c37531b36677f2a8c0d961
|
7
|
+
data.tar.gz: 6461c5650345338c17dd33dd378575d5376e2b31ed9466aa4b527096ae831db8feac8b73f357dc8da7908dd7e41aeed1a6750bd9bc1cd570c6e5634562aca0f9
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# Easy and Accessible Autocomplete for Ruby on Rails
|
6
6
|
|
7
|
-
[![CI
|
7
|
+
[![CI](https://github.com/josefarias/hotwire_combobox/actions/workflows/ci.yml/badge.svg)](https://github.com/josefarias/hotwire_combobox/actions/workflows/ci.yml) [![Gem Version](https://badge.fury.io/rb/hotwire_combobox.svg)](https://badge.fury.io/rb/hotwire_combobox)
|
8
8
|
|
9
9
|
|
10
10
|
> [!IMPORTANT]
|
@@ -122,6 +122,7 @@ These are the exceptions:
|
|
122
122
|
2. The escape key closes the listbox and blurs the combobox. It does not clear the combobox.
|
123
123
|
3. The listbox has wrap-around selection. That is, pressing `Up Arrow` when the user is on the first option will select the last option. And pressing `Down Arrow` when on the last option will select the first option. In paginated comboboxes, the first and last options refer to the currently available options. More options may be loaded after navigating to the last currently available option.
|
124
124
|
4. It is possible to have an unlabled combobox, as that responsibility is delegated to the implementing user.
|
125
|
+
5. There are currently [no APG guidelines](https://github.com/w3c/aria-practices/issues/1512) for a multiselect combobox. We've introduced some mechanisms to make the experience accessible, like announcing multi-selections via a live region. But we'd welcome feedback on how to make it better until official guidelines are available.
|
125
126
|
|
126
127
|
It should be noted none of the maintainers use assistive technologies in their daily lives. If you do, and you feel these exceptions are detrimental to your ability to use the component, or if you find an undocumented exception, please [open a GitHub issue](https://github.com/josefarias/hotwire_combobox/issues). We'll get it sorted.
|
127
128
|
|
@@ -7,11 +7,14 @@ window.HOTWIRE_COMBOBOX_STREAM_DELAY = 0 // ms, for testing purposes
|
|
7
7
|
const concerns = [
|
8
8
|
Controller,
|
9
9
|
Combobox.Actors,
|
10
|
+
Combobox.Announcements,
|
10
11
|
Combobox.AsyncLoading,
|
11
12
|
Combobox.Autocomplete,
|
12
13
|
Combobox.Dialog,
|
13
14
|
Combobox.Events,
|
14
15
|
Combobox.Filtering,
|
16
|
+
Combobox.FormField,
|
17
|
+
Combobox.Multiselect,
|
15
18
|
Combobox.Navigation,
|
16
19
|
Combobox.NewOptions,
|
17
20
|
Combobox.Options,
|
@@ -27,7 +30,10 @@ export default class HwComboboxController extends Concerns(...concerns) {
|
|
27
30
|
]
|
28
31
|
|
29
32
|
static targets = [
|
33
|
+
"announcer",
|
30
34
|
"combobox",
|
35
|
+
"chipDismisser",
|
36
|
+
"closer",
|
31
37
|
"dialog",
|
32
38
|
"dialogCombobox",
|
33
39
|
"dialogFocusTrap",
|
@@ -48,15 +54,21 @@ export default class HwComboboxController extends Concerns(...concerns) {
|
|
48
54
|
nameWhenNew: String,
|
49
55
|
originalName: String,
|
50
56
|
prefilledDisplay: String,
|
57
|
+
selectionChipSrc: String,
|
51
58
|
smallViewportMaxWidth: String
|
52
59
|
}
|
53
60
|
|
54
61
|
initialize() {
|
55
62
|
this._initializeActors()
|
56
63
|
this._initializeFiltering()
|
64
|
+
this._initializeMultiselect()
|
57
65
|
}
|
58
66
|
|
59
67
|
connect() {
|
68
|
+
this.idempotentConnect()
|
69
|
+
}
|
70
|
+
|
71
|
+
idempotentConnect() {
|
60
72
|
this._connectSelection()
|
61
73
|
this._connectListAutocomplete()
|
62
74
|
this._connectDialog()
|
@@ -78,11 +90,25 @@ export default class HwComboboxController extends Concerns(...concerns) {
|
|
78
90
|
const inputType = element.dataset.inputType
|
79
91
|
const delay = window.HOTWIRE_COMBOBOX_STREAM_DELAY
|
80
92
|
|
81
|
-
|
93
|
+
this._resetMultiselectionMarks()
|
94
|
+
|
95
|
+
if (inputType === "hw:multiselectSync") {
|
96
|
+
this.openByFocusing()
|
97
|
+
} else if (inputType && inputType !== "hw:lockInSelection") {
|
82
98
|
if (delay) await sleep(delay)
|
83
|
-
this.
|
99
|
+
this._selectOnQuery(inputType)
|
84
100
|
} else {
|
85
|
-
this.
|
101
|
+
this._preselectSingle()
|
86
102
|
}
|
87
103
|
}
|
104
|
+
|
105
|
+
closerTargetConnected() {
|
106
|
+
this._closeAndBlur("hw:asyncCloser")
|
107
|
+
}
|
108
|
+
|
109
|
+
// Use +_printStack+ for debugging purposes
|
110
|
+
_printStack() {
|
111
|
+
const err = new Error()
|
112
|
+
console.log(err.stack || err.stacktrace)
|
113
|
+
}
|
88
114
|
}
|