hotwire_combobox 0.4.0 → 0.4.1

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: 01df7da888bb6651172b141161fcf58610b9c1e1e28e8f20a3bee7d880a9f6cb
4
- data.tar.gz: 3ae59ccce1a2782b49759d2797244d8b8084996a8f115b46ac32f10fc22eab39
3
+ metadata.gz: fe61b5864928a8b779da825280d38697c45e03db53de9bb87e48b9206ce08fc2
4
+ data.tar.gz: e6cbe41f186935d2471e1fb8a84d8f5695632e35bda4e89c2935863d90270b48
5
5
  SHA512:
6
- metadata.gz: 11e979427daf0c338006be0ab69732fcd4ca7f4860319b54e003730341419b1845069638acab2adaae1c45ecc961cc5216c30791e567cb0abb1dd6fc326ad794
7
- data.tar.gz: 9f05dafd9e46f000641a86f11d9d223df4264d4f53b131f6f9be347bdb8356e4800eae22719d99c4b20bb665ce437efac27941ada324e725087801cd6fa5414e
6
+ metadata.gz: a6a3be679d1d570adcfae1b1cbf085fa27c588729b58398fb3cd5007c2ef63135c5919a07eaa99b8a5ae51a2a4a791b90ab3461fef4560247355456258d81916
7
+ data.tar.gz: 843aff083488b6258e7d290f92e15fa904b905425a18b257b3a36c196c141a0aa1fff531ca630032498df3294a40a8c8ca0ff03a0a22791b273080b86ecf2b11
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2025 Jose Farias
1
+ Copyright 2026 Jose Farias
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -44,6 +44,7 @@ export default class HwComboboxController extends Concerns(...concerns) {
44
44
  asyncSrc: String,
45
45
  autocompletableAttribute: String,
46
46
  autocomplete: String,
47
+ debounceInterval: Number,
47
48
  expanded: Boolean,
48
49
  filterableAttribute: String,
49
50
  nameWhenNew: String,
@@ -1,5 +1,5 @@
1
1
  /*!
2
- HotwireCombobox 0.4.0
2
+ HotwireCombobox 0.4.1
3
3
  */
4
4
  import { Controller } from '@hotwired/stimulus';
5
5
 
@@ -91,7 +91,7 @@ function startsWith(string, substring) {
91
91
  return string.toLowerCase().startsWith(substring.toLowerCase())
92
92
  }
93
93
 
94
- function debounce(fn, delay = 150) {
94
+ function debounce(fn, delay) {
95
95
  let timeoutId = null;
96
96
 
97
97
  return (...args) => {
@@ -668,7 +668,7 @@ Combobox.Filtering = Base => class extends Base {
668
668
  }
669
669
 
670
670
  _initializeFiltering() {
671
- this._debouncedFilterAsync = debounce(this._debouncedFilterAsync.bind(this));
671
+ this._debouncedFilterAsync = debounce(this._debouncedFilterAsync.bind(this), this.debounceIntervalValue);
672
672
  }
673
673
 
674
674
  _filter(inputType) {
@@ -1175,7 +1175,7 @@ Combobox.Selection = Base => class extends Base {
1175
1175
  }
1176
1176
 
1177
1177
  _preselectSingle() {
1178
- if (this._isSingleSelect && this._hasValueButNoSelection && this._allOptions.length < 100) {
1178
+ if (this._isSingleSelect && this._hasValueButNoSelection) {
1179
1179
  const option = this._optionElementWithValue(this._fieldValue);
1180
1180
  if (option) this._markSelected(option);
1181
1181
  }
@@ -1574,6 +1574,8 @@ Combobox.Toggle = Base => class extends Base {
1574
1574
  }
1575
1575
 
1576
1576
  clearOrToggleOnHandleClick() {
1577
+ if (this.comboboxTarget.disabled) return
1578
+
1577
1579
  if (this._isQueried) {
1578
1580
  this._clearQuery();
1579
1581
  this.open();
@@ -1750,6 +1752,7 @@ class HwComboboxController extends Concerns(...concerns) {
1750
1752
  asyncSrc: String,
1751
1753
  autocompletableAttribute: String,
1752
1754
  autocomplete: String,
1755
+ debounceInterval: Number,
1753
1756
  expanded: Boolean,
1754
1757
  filterableAttribute: String,
1755
1758
  nameWhenNew: String,
@@ -37,7 +37,7 @@ export function startsWith(string, substring) {
37
37
  return string.toLowerCase().startsWith(substring.toLowerCase())
38
38
  }
39
39
 
40
- export function debounce(fn, delay = 150) {
40
+ export function debounce(fn, delay) {
41
41
  let timeoutId = null
42
42
 
43
43
  return (...args) => {
@@ -30,7 +30,7 @@ Combobox.Filtering = Base => class extends Base {
30
30
  }
31
31
 
32
32
  _initializeFiltering() {
33
- this._debouncedFilterAsync = debounce(this._debouncedFilterAsync.bind(this))
33
+ this._debouncedFilterAsync = debounce(this._debouncedFilterAsync.bind(this), this.debounceIntervalValue)
34
34
  }
35
35
 
36
36
  _filter(inputType) {
@@ -85,7 +85,7 @@ Combobox.Selection = Base => class extends Base {
85
85
  }
86
86
 
87
87
  _preselectSingle() {
88
- if (this._isSingleSelect && this._hasValueButNoSelection && this._allOptions.length < 100) {
88
+ if (this._isSingleSelect && this._hasValueButNoSelection) {
89
89
  const option = this._optionElementWithValue(this._fieldValue)
90
90
  if (option) this._markSelected(option)
91
91
  }
@@ -57,6 +57,8 @@ Combobox.Toggle = Base => class extends Base {
57
57
  }
58
58
 
59
59
  clearOrToggleOnHandleClick() {
60
+ if (this.comboboxTarget.disabled) return
61
+
60
62
  if (this._isQueried) {
61
63
  this._clearQuery()
62
64
  this.open()
@@ -26,6 +26,7 @@ module HotwireCombobox::Component::Markup::Fieldset
26
26
  hw_combobox_async_src_value: async_src,
27
27
  hw_combobox_prefilled_display_value: prefilled_display,
28
28
  hw_combobox_selection_chip_src_value: multiselect_chip_src,
29
+ hw_combobox_debounce_interval_value: debounce_interval,
29
30
  hw_combobox_filterable_attribute_value: "data-filterable-as",
30
31
  hw_combobox_autocompletable_attribute_value: "data-autocompletable-as",
31
32
  hw_combobox_selected_class: "hw-combobox__option--selected",
@@ -15,6 +15,7 @@ class HotwireCombobox::Component
15
15
  async_src: nil,
16
16
  autocomplete: :both,
17
17
  data: {},
18
+ debounce_interval: 150,
18
19
  dialog_label: nil,
19
20
  form: nil,
20
21
  free_text: false,
@@ -30,9 +31,9 @@ class HotwireCombobox::Component
30
31
  request: nil,
31
32
  value: nil, **rest)
32
33
  @view, @autocomplete, @id, @name, @value, @form, @async_src, @label, @free_text, @request,
33
- @preload, @name_when_new, @open, @data, @mobile_at, @multiselect_chip_src, @options, @dialog_label =
34
+ @preload, @name_when_new, @open, @data, @debounce_interval, @mobile_at, @multiselect_chip_src, @options, @dialog_label =
34
35
  view, autocomplete, id, name.to_s, value, form, async_src, label, free_text, request,
35
- preload, name_when_new, open, data, mobile_at, multiselect_chip_src, options, dialog_label
36
+ preload, name_when_new, open, data, debounce_interval, mobile_at, multiselect_chip_src, options, dialog_label
36
37
 
37
38
  @combobox_attrs = input.reverse_merge(rest).deep_symbolize_keys
38
39
  @association_name = association_name || infer_association_name
@@ -47,7 +48,7 @@ class HotwireCombobox::Component
47
48
 
48
49
  private
49
50
  attr_reader :view, :autocomplete, :id, :name, :value, :form, :free_text, :open, :request,
50
- :data, :combobox_attrs, :mobile_at, :association_name, :multiselect_chip_src, :preload
51
+ :data, :debounce_interval, :combobox_attrs, :mobile_at, :association_name, :multiselect_chip_src, :preload
51
52
 
52
53
  def canonical_id
53
54
  @canonical_id ||= id || form&.field_id(name) || SecureRandom.uuid
@@ -2,5 +2,5 @@
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: src %>
5
+ <%= render "hotwire_combobox/pagination", for_id: for_id, src: src, loading: :lazy %>
6
6
  <% end %>
@@ -1,4 +1,4 @@
1
- <%# locals: (for_id:, src:, loading: :lazy) -%>
1
+ <%# locals: (for_id:, src:, loading:) -%>
2
2
 
3
3
  <%= tag.li id: hw_pagination_frame_wrapper_id(for_id), class: "hw_combobox__pagination__wrapper",
4
4
  data: { hw_combobox_target: "endOfOptionsStream", input_type: params[:input_type], callback_id: params[:callback_id] },
@@ -1,3 +1,3 @@
1
1
  module HotwireCombobox
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotwire_combobox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Farias
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  - !ruby/object:Gem::Version
169
169
  version: '0'
170
170
  requirements: []
171
- rubygems_version: 3.6.2
171
+ rubygems_version: 4.0.3
172
172
  specification_version: 4
173
173
  summary: Accessible Autocomplete for Rails apps
174
174
  test_files: []