hotwire_combobox 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9649cc031cc63f665e78c4f72857f72698d42af893d8204cab739a5817be27b8
4
- data.tar.gz: f9e791cc61927caebd9db3c32cf3e71382f6d77e4f54c8275348b02600fce8d4
3
+ metadata.gz: fbd0907dd22a30683ba48f331a588c125f47ad6ad05d3bd613b5fc44047ed153
4
+ data.tar.gz: 330118f1c3cf332a93fe29f3ccf25b4a287362047d1301608c838d601d2f920c
5
5
  SHA512:
6
- metadata.gz: 5f6c132e19554295758e13763663a6e0d3b0e7a0a413088a25aed723370dd5967133af3e2660e9ef4ecb16d661f39232bb36ac9c08c37531b36677f2a8c0d961
7
- data.tar.gz: 6461c5650345338c17dd33dd378575d5376e2b31ed9466aa4b527096ae831db8feac8b73f357dc8da7908dd7e41aeed1a6750bd9bc1cd570c6e5634562aca0f9
6
+ metadata.gz: 5cb2373c38c8f9bbe0d7d0276183e516100effd4973c87a9587d2d45dc854cb54dbb0fa55eef0db8eac2226399878c3d02f0868ae1ae6ca45185db0f5b15739d
7
+ data.tar.gz: eca06ee9703ec8929bede6a1b706a86e76905c7cd7be23233c2fe997c47db67d412ea5ea437c67416fe43aeb07679074b3f5d493ce491308f99edf78c1df664b
@@ -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.1
2
+ HotwireCombobox 0.2.2
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
- _initializeMultiselect() {
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.1
2
+ HotwireCombobox 0.2.2
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
- _initializeMultiselect() {
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
  }
@@ -55,7 +55,7 @@ Combobox.Multiselect = Base => class extends Base {
55
55
  }
56
56
  }
57
57
 
58
- _initializeMultiselect() {
58
+ _connectMultiselect() {
59
59
  if (!this._isMultiPreselected) {
60
60
  this._preselectMultiple()
61
61
  this._markMultiPreselected()
@@ -80,15 +80,7 @@ class HotwireCombobox::Component
80
80
 
81
81
  def announcer_attrs
82
82
  {
83
- style: "
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
  }
@@ -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:, next_page:, src:) -%>
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: hw_combobox_next_page_uri(src, next_page, for_id) %>
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.path,
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: 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 ]
@@ -1,3 +1,3 @@
1
1
  module HotwireCombobox
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
4
+ version: 0.2.2
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-03-31 00:00:00.000000000 Z
11
+ date: 2024-04-15 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.4.18
147
+ rubygems_version: 3.5.7
134
148
  signing_key:
135
149
  specification_version: 4
136
150
  summary: Accessible Autocomplete for Rails apps