stimulus_table_filter 0.1.0 → 0.1.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: fd1d293fa4373f23cb2eb542feb797e20b73b994564af5422e1bb69cfb370af4
4
- data.tar.gz: 80a795894d382356b03d83ab003727c4dd5e786f81ca140106b33417ecabeab6
3
+ metadata.gz: 6f91c052d06053053b3a16d10850b67601c6adb56cf6b700e5185754d71113a3
4
+ data.tar.gz: 2300a0935a51a39f7b3efdb9a43350095e16d9ff5d7c2d07f72e880de28eabc5
5
5
  SHA512:
6
- metadata.gz: d27af095bbddab3441ed10e65215c2e92c2bdbb2d10111ac4ffee02adc7fc9ee0898087019329b43e2b649d8f5119be42639ab2ba150a427ab5be5e9ce0b17f6
7
- data.tar.gz: 8d52a264133b2aed8e2737392b6ba0a86443f35b95be1a0942204e04297cb86b05e5e6100ffcac25a42e81c5a7f122c0632b5cbe8bd8bbdfb7f7d85ad2c577f6
6
+ metadata.gz: 253a33fc42231ab85a0df2b4e99ccbc557c08f12d15ec8498d5518a165a04a5d7273901f6af6dfa5053909c1233a37895d8ff8d20686c624ce71c1571df5c918
7
+ data.tar.gz: 4606468cc32babe89d61bbab8729bf211e4c34d9b77a06a4f4eff4f5d706523ce295aa75e13795b1dcf1c0f0cce88d9a965d5b5dcd282fc15896ced0b9577097
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
+ ## [0.1.1] - 2026-08-31
7
+
8
+ - `table_filter_container_tag` accepts a `search:` option and emits
9
+ `data-table-filter-search-value`, matching the documented data-attribute contract
10
+ - README: document that `table_filter_footer_tag` wraps its content in a footer element, a
11
+ `<tr>` and a `<td>`; correct the URL-state and programmatic-API behavior notes
12
+
6
13
  ## [0.1.0] - 2026-08-25
7
14
 
8
15
  Initial release.
@@ -13,4 +20,5 @@ Initial release.
13
20
  - RSpec support: shared examples plus `have_data` / `have_data_target` matchers
14
21
  - CI: RuboCop, RSpec and JavaScript tests across Ruby 3.2–3.4 and Rails 7.0–8.1
15
22
 
23
+ [0.1.1]: https://github.com/icoluccio/stimulus-table-filter/releases/tag/v0.1.1
16
24
  [0.1.0]: https://github.com/icoluccio/stimulus-table-filter/releases/tag/v0.1.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stimulus_table_filter (0.1.0)
4
+ stimulus_table_filter (0.1.1)
5
5
  railties (>= 7.0, < 9)
6
6
 
7
7
  GEM
@@ -285,7 +285,7 @@ CHECKSUMS
285
285
  securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
286
286
  sexp_processor (4.17.5) sha256=ae2b48ba98353d5d465ce8759836b7a05f2e12c5879fcd14d7815b026de32f0e
287
287
  simplecov (1.1.1) sha256=25825ef13f0b2e74694d769817dad6ab8e90131dabdaa666e522fea105521e78
288
- stimulus_table_filter (0.1.0)
288
+ stimulus_table_filter (0.1.1)
289
289
  thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
290
290
  tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
291
291
  tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
data/README.md CHANGED
@@ -176,6 +176,7 @@ the controller reads on connect.
176
176
  | `page_size:` | `nil` | Rows per page (omit or `0` to disable pagination) |
177
177
  | `url_key:` | `nil` | URL param prefix (default `tf`); set per table to namespace multiple tables |
178
178
  | `debounce_ms:` | `nil` | Search debounce in ms (default `0` = immediate) |
179
+ | `search:` | `nil` | Initial search text (emits `data-table-filter-search-value`) |
179
180
  | `tag:` | `:div` | Wrapping HTML element |
180
181
 
181
182
  Every helper accepts `**opts` and passes them through to the underlying tag.
@@ -315,6 +316,9 @@ The default footer shows how many rows match the current filter and search, out
315
316
  <!-- renders: <span>12</span> of <span>87</span> -->
316
317
  ```
317
318
 
319
+ The helper wraps the content in the footer element (a `<tfoot>` by default), a `<tr>`, and a
320
+ `<td>`; `colspan:` applies to that cell and `tag:` replaces only the outer element.
321
+
318
322
  Or build your own footer. The block receives the match-count and total-count spans:
319
323
 
320
324
  ```erb
@@ -399,11 +403,14 @@ Behavior notes:
399
403
  - **Footer stats**: the match count covers every row that passes the active filters and search,
400
404
  across all pages. Count tags populate with the number of matching rows whose dimension value
401
405
  equals the tag's value.
402
- - **URL state**: every filter dimension, sort, direction, page and search sync to
403
- `URLSearchParams` on every change (dimensions as `tf_filter_{dimension}` params) and the
404
- controller restores them on connect. Namespace multiple tables with `data-table-filter-url-key-value`.
406
+ - **URL state**: the controller syncs filter dimensions, sort, direction, page and search to
407
+ `URLSearchParams` when the user changes them (dimensions as `tf_filter_{dimension}` params)
408
+ and restores them on connect without rewriting the URL. Namespace multiple tables with
409
+ `data-table-filter-url-key-value`.
405
410
  - **Event handling**: the controller delegates all events itself; individual elements
406
- need no `data-action`. `setFilter`, `sortBy` and `search` are also callable programmatically.
411
+ need no `data-action`. Call `search()` programmatically. For filters and sort, set the
412
+ Stimulus values and refresh, e.g.
413
+ `controller.filterDimensionsValue = { status: 'active' }; controller.refresh()`.
407
414
 
408
415
  ### RSpec shared examples
409
416
 
@@ -38,6 +38,7 @@ export default class extends Controller {
38
38
 
39
39
  connect() {
40
40
  this.#readUrlState()
41
+ if (this.hasSearchTarget && this.searchValue) this.searchTarget.value = this.searchValue
41
42
  this.element.addEventListener("click", this.#onClick)
42
43
  this.element.addEventListener("input", this.#onInput)
43
44
  this.element.addEventListener("change", this.#onChange)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StimulusTableFilter
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
@@ -3,9 +3,9 @@
3
3
  module StimulusTableFilter
4
4
  module ViewHelper
5
5
  def table_filter_container_tag(sort: 'name', dir: 'asc', page: nil, page_size: nil, url_key: nil,
6
- debounce_ms: nil, tag: :div, **opts, &)
6
+ debounce_ms: nil, search: nil, tag: :div, **opts, &)
7
7
  data = container_data(sort:, dir:, page:, page_size:, url_key:,
8
- debounce_ms:).merge(opts.delete(:data) || {})
8
+ debounce_ms:, search:).merge(opts.delete(:data) || {})
9
9
  content_tag(tag, data: data, **opts, &)
10
10
  end
11
11
 
@@ -17,11 +17,12 @@ module StimulusTableFilter
17
17
  base
18
18
  end
19
19
 
20
- def container_data(sort:, dir:, page: nil, page_size: nil, url_key: nil, debounce_ms: nil)
20
+ def container_data(sort:, dir:, page: nil, page_size: nil, url_key: nil, debounce_ms: nil, search: nil)
21
21
  base = base_container_data(sort:, dir:, page:)
22
22
  base = base.merge(table_filter_page_size_value: page_size.to_s) if page_size
23
23
  base = base.merge(table_filter_url_key_value: url_key.to_s) if url_key
24
24
  base = base.merge(table_filter_debounce_ms_value: debounce_ms.to_s) if debounce_ms
25
+ base = base.merge(table_filter_search_value: search.to_s) if search
25
26
  base
26
27
  end
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimulus_table_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - icoluccio