hotwire_combobox 0.2.1 → 0.2.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/app/assets/javascripts/controllers/hw_combobox_controller.js +1 -1
- data/app/assets/javascripts/hotwire_combobox.esm.js +3 -3
- data/app/assets/javascripts/hotwire_combobox.umd.js +3 -3
- data/app/assets/javascripts/hw_combobox/models/combobox/multiselect.js +1 -1
- data/app/presenters/hotwire_combobox/component.rb +3 -11
- data/app/views/hotwire_combobox/_component.html.erb +13 -0
- data/app/views/hotwire_combobox/_next_page.turbo_stream.erb +2 -2
- data/lib/hotwire_combobox/helper.rb +13 -13
- data/lib/hotwire_combobox/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 375e5d8a06acd3bfb37fda548dcbaf55c097dafddf6511d33292ee424c267e92
|
4
|
+
data.tar.gz: 334608cf151572af945be3f9cf17598ccbf9b1808580c1cb57e2ea8e24fba246
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a39403f378b1be54d167ed15e4006e96751c19ab71c3c7f60414c3b13598f861fb2cbc7611995775f804a1caadcc0849fc89f68dc4761777a015acf57e1ad19
|
7
|
+
data.tar.gz: 1618b436e6c19922b32ce986f6f5103676e206eb9d04c868cfa5bfd6b9a84dd62dd65c164dd2072ab355e62d951e91610dfb9043fe72e14432ec2e9c6fcb45b4
|
@@ -61,7 +61,6 @@ export default class HwComboboxController extends Concerns(...concerns) {
|
|
61
61
|
initialize() {
|
62
62
|
this._initializeActors()
|
63
63
|
this._initializeFiltering()
|
64
|
-
this._initializeMultiselect()
|
65
64
|
}
|
66
65
|
|
67
66
|
connect() {
|
@@ -70,6 +69,7 @@ export default class HwComboboxController extends Concerns(...concerns) {
|
|
70
69
|
|
71
70
|
idempotentConnect() {
|
72
71
|
this._connectSelection()
|
72
|
+
this._connectMultiselect()
|
73
73
|
this._connectListAutocomplete()
|
74
74
|
this._connectDialog()
|
75
75
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
HotwireCombobox 0.2.
|
2
|
+
HotwireCombobox 0.2.3
|
3
3
|
*/
|
4
4
|
import { Controller } from '@hotwired/stimulus';
|
5
5
|
|
@@ -776,7 +776,7 @@ Combobox.Multiselect = Base => class extends Base {
|
|
776
776
|
}
|
777
777
|
}
|
778
778
|
|
779
|
-
|
779
|
+
_connectMultiselect() {
|
780
780
|
if (!this._isMultiPreselected) {
|
781
781
|
this._preselectMultiple();
|
782
782
|
this._markMultiPreselected();
|
@@ -1702,7 +1702,6 @@ class HwComboboxController extends Concerns(...concerns) {
|
|
1702
1702
|
initialize() {
|
1703
1703
|
this._initializeActors();
|
1704
1704
|
this._initializeFiltering();
|
1705
|
-
this._initializeMultiselect();
|
1706
1705
|
}
|
1707
1706
|
|
1708
1707
|
connect() {
|
@@ -1711,6 +1710,7 @@ class HwComboboxController extends Concerns(...concerns) {
|
|
1711
1710
|
|
1712
1711
|
idempotentConnect() {
|
1713
1712
|
this._connectSelection();
|
1713
|
+
this._connectMultiselect();
|
1714
1714
|
this._connectListAutocomplete();
|
1715
1715
|
this._connectDialog();
|
1716
1716
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
HotwireCombobox 0.2.
|
2
|
+
HotwireCombobox 0.2.3
|
3
3
|
*/
|
4
4
|
(function (global, factory) {
|
5
5
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@hotwired/stimulus')) :
|
@@ -780,7 +780,7 @@ HotwireCombobox 0.2.1
|
|
780
780
|
}
|
781
781
|
}
|
782
782
|
|
783
|
-
|
783
|
+
_connectMultiselect() {
|
784
784
|
if (!this._isMultiPreselected) {
|
785
785
|
this._preselectMultiple();
|
786
786
|
this._markMultiPreselected();
|
@@ -1706,7 +1706,6 @@ HotwireCombobox 0.2.1
|
|
1706
1706
|
initialize() {
|
1707
1707
|
this._initializeActors();
|
1708
1708
|
this._initializeFiltering();
|
1709
|
-
this._initializeMultiselect();
|
1710
1709
|
}
|
1711
1710
|
|
1712
1711
|
connect() {
|
@@ -1715,6 +1714,7 @@ HotwireCombobox 0.2.1
|
|
1715
1714
|
|
1716
1715
|
idempotentConnect() {
|
1717
1716
|
this._connectSelection();
|
1717
|
+
this._connectMultiselect();
|
1718
1718
|
this._connectListAutocomplete();
|
1719
1719
|
this._connectDialog();
|
1720
1720
|
}
|
@@ -80,15 +80,7 @@ class HotwireCombobox::Component
|
|
80
80
|
|
81
81
|
def announcer_attrs
|
82
82
|
{
|
83
|
-
|
84
|
-
position: absolute;
|
85
|
-
width: 1px;
|
86
|
-
height: 1px;
|
87
|
-
margin: -1px;
|
88
|
-
padding: 0;
|
89
|
-
overflow: hidden;
|
90
|
-
clip: rect(0, 0, 0, 0);
|
91
|
-
border: 0;".squish,
|
83
|
+
class: "hw-combobox__announcer",
|
92
84
|
aria: announcer_aria,
|
93
85
|
data: announcer_data
|
94
86
|
}
|
@@ -256,7 +248,7 @@ class HotwireCombobox::Component
|
|
256
248
|
end
|
257
249
|
|
258
250
|
def association_exists?
|
259
|
-
form_object&.
|
251
|
+
association_name && form_object&.respond_to?(association_name)
|
260
252
|
end
|
261
253
|
|
262
254
|
def form_object
|
@@ -308,7 +300,7 @@ class HotwireCombobox::Component
|
|
308
300
|
def hidden_field_value
|
309
301
|
return value if value
|
310
302
|
|
311
|
-
if form_object&.defined_enums&.try
|
303
|
+
if form_object&.try(:defined_enums)&.try(:[], name)
|
312
304
|
form_object.public_send "#{name}_before_type_cast"
|
313
305
|
else
|
314
306
|
form_object&.try(name).then do |value|
|
@@ -4,6 +4,19 @@
|
|
4
4
|
<%= render "hotwire_combobox/combobox/hidden_field", component: component %>
|
5
5
|
|
6
6
|
<%= tag.div **component.main_wrapper_attrs do %>
|
7
|
+
<%# Announcer styles defined here because they're not optional %>
|
8
|
+
<%= tag.style nonce: content_security_policy_nonce do %>
|
9
|
+
.hw-combobox__announcer {
|
10
|
+
position: absolute;
|
11
|
+
width: 1px;
|
12
|
+
height: 1px;
|
13
|
+
margin: -1px;
|
14
|
+
padding: 0;
|
15
|
+
overflow: hidden;
|
16
|
+
clip: rect(0, 0, 0, 0);
|
17
|
+
border: 0;
|
18
|
+
}
|
19
|
+
<% end %>
|
7
20
|
<%= tag.div **component.announcer_attrs %>
|
8
21
|
<%= render "hotwire_combobox/combobox/input", component: component %>
|
9
22
|
<%= render "hotwire_combobox/combobox/paginated_listbox", component: component %>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<%# locals: (for_id:,
|
1
|
+
<%# locals: (for_id:, src:) -%>
|
2
2
|
|
3
3
|
<%= turbo_stream.remove hw_pagination_frame_wrapper_id(for_id) %>
|
4
4
|
<%= turbo_stream.append hw_listbox_id(for_id) do %>
|
5
|
-
<%= render "hotwire_combobox/pagination", for_id: for_id, src:
|
5
|
+
<%= render "hotwire_combobox/pagination", for_id: for_id, src: src %>
|
6
6
|
<% end %>
|
@@ -37,7 +37,7 @@ module HotwireCombobox
|
|
37
37
|
def hw_paginated_combobox_options(
|
38
38
|
options,
|
39
39
|
for_id: params[:for_id],
|
40
|
-
src: request.
|
40
|
+
src: request.fullpath,
|
41
41
|
next_page: nil,
|
42
42
|
render_in: {},
|
43
43
|
include_blank: {},
|
@@ -45,7 +45,7 @@ module HotwireCombobox
|
|
45
45
|
include_blank = params[:page].to_i > 0 ? nil : include_blank
|
46
46
|
options = hw_combobox_options options, render_in: render_in, include_blank: include_blank, **custom_methods
|
47
47
|
this_page = render "hotwire_combobox/paginated_options", for_id: for_id, options: options
|
48
|
-
next_page = render "hotwire_combobox/next_page", for_id: for_id, src: src, next_page
|
48
|
+
next_page = render "hotwire_combobox/next_page", for_id: for_id, src: hw_combobox_next_page_uri(src, next_page, for_id)
|
49
49
|
|
50
50
|
safe_join [ this_page, next_page ]
|
51
51
|
end
|
@@ -146,23 +146,13 @@ module HotwireCombobox
|
|
146
146
|
"#{id}__hw_combobox_pagination"
|
147
147
|
end
|
148
148
|
|
149
|
-
def hw_combobox_next_page_uri(uri, next_page, for_id)
|
150
|
-
if next_page
|
151
|
-
hw_uri_with_params uri,
|
152
|
-
page: next_page,
|
153
|
-
q: params[:q],
|
154
|
-
for_id: for_id,
|
155
|
-
format: :turbo_stream
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
149
|
def hw_combobox_page_stream_action
|
160
150
|
params[:page].to_i > 0 ? :append : :update
|
161
151
|
end
|
162
152
|
|
163
153
|
def hw_uri_with_params(url_or_path, **params)
|
164
154
|
URI.parse(url_or_path).tap do |url_or_path|
|
165
|
-
query = URI.decode_www_form(url_or_path.query || "").to_h.merge(params)
|
155
|
+
query = URI.decode_www_form(url_or_path.query || "").to_h.merge(params.compact_blank.stringify_keys)
|
166
156
|
url_or_path.query = URI.encode_www_form query
|
167
157
|
end.to_s
|
168
158
|
rescue URI::InvalidURIError
|
@@ -178,6 +168,16 @@ module HotwireCombobox
|
|
178
168
|
end
|
179
169
|
|
180
170
|
private
|
171
|
+
def hw_combobox_next_page_uri(uri, next_page, for_id)
|
172
|
+
return unless next_page
|
173
|
+
|
174
|
+
hw_uri_with_params uri,
|
175
|
+
page: next_page,
|
176
|
+
q: params[:q],
|
177
|
+
for_id: for_id,
|
178
|
+
format: :turbo_stream
|
179
|
+
end
|
180
|
+
|
181
181
|
def hw_extract_options_and_src(options_or_src, render_in, include_blank)
|
182
182
|
if options_or_src.is_a? String
|
183
183
|
[ hw_combobox_options([]), options_or_src ]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotwire_combobox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jose Farias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mocha
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.1'
|
55
69
|
description: An accessible autocomplete for Ruby on Rails apps using Hotwire.
|
56
70
|
email:
|
57
71
|
- jose@farias.mx
|
@@ -130,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
144
|
- !ruby/object:Gem::Version
|
131
145
|
version: '0'
|
132
146
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.5.9
|
134
148
|
signing_key:
|
135
149
|
specification_version: 4
|
136
150
|
summary: Accessible Autocomplete for Rails apps
|