biscuit-rails 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 985fb72650e4c3de624f424a76045512cd87a5da81b4f4b3a469c1a4f9259b97
4
- data.tar.gz: 49f1fe38563be47454abb704ed4f0255a013ead175095d54e1b46e3f95a83be9
3
+ metadata.gz: 7054c18a5049310cc03f684c2d8ce5c2a835276ffc2ac5c7fb7ad453a0683336
4
+ data.tar.gz: 90b033ac9021dde624c9be3da900d3dedfb2697858ccafa536c28ba976f33a70
5
5
  SHA512:
6
- metadata.gz: c0912d4b8618ee9cc06cea7037b8decd3f6e2517450636ddc2344298b65f80f45ece0e33a31066fc164888f702b9ab64c5caf92b475db80bfcad036cf9c26119
7
- data.tar.gz: 969f8ede03fcadebc1f62f20169d7dd7f6cfa3b2d538694c0d1171426b002dd8560a8bff0f5928759e4a654018fabea0fc5f8b98ee8a8c28a9111abf6a85a9a9
6
+ metadata.gz: 438ed681f247bfcde15c397a53f1765ee984e799abf8634af90308a2b3dc64b12ca222965bbca5b3bee49b8428e1a57ec0b3f25d97f98e9bcf7ed46e4d17483d
7
+ data.tar.gz: 9c1f5f8363f50d9da83f8a82184725dbeed20b98073146437d2d2443036b504db365f77a2551b2ed40cff2505e4d5cd89bc19a45268d0a6af571a994d3f774aa
data/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.3] - 2026-03-28
9
+
10
+ ### Fixed
11
+
12
+ - Manage link ("Cookie settings") button now works correctly — it was rendered
13
+ outside the Stimulus controller's element scope, so targets and actions were
14
+ never connected. The banner partial now wraps both the banner and the manage
15
+ link in a single controller root element.
16
+
17
+ ### Added
18
+
19
+ - Engine auto-registers its importmap pin with the host app via a
20
+ `biscuit.importmap` initializer — users no longer need to manually add
21
+ `pin "biscuit/biscuit_controller"` to `config/importmap.rb`. No-op in
22
+ esbuild/jsbundling apps.
23
+
24
+ ---
25
+
8
26
  ## [0.1.2] - 2026-03-20
9
27
 
10
28
  ### Added
data/README.md CHANGED
@@ -50,15 +50,7 @@ Rails.application.routes.draw do
50
50
  end
51
51
  ```
52
52
 
53
- ### 2. Pin the Stimulus controller
54
-
55
- In `config/importmap.rb`:
56
-
57
- ```ruby
58
- pin "biscuit/biscuit_controller", to: "biscuit/biscuit_controller.js"
59
- ```
60
-
61
- ### 3. Register the Stimulus controller
53
+ ### 2. Register the Stimulus controller
62
54
 
63
55
  In `app/javascript/controllers/index.js`:
64
56
 
@@ -67,7 +59,7 @@ import BiscuitController from "biscuit/biscuit_controller"
67
59
  application.register("biscuit", BiscuitController)
68
60
  ```
69
61
 
70
- ### 4. Include the stylesheet
62
+ ### 3. Include the stylesheet
71
63
 
72
64
  In your layout (`app/views/layouts/application.html.erb`):
73
65
 
@@ -75,7 +67,7 @@ In your layout (`app/views/layouts/application.html.erb`):
75
67
  <%= stylesheet_link_tag "biscuit/biscuit" %>
76
68
  ```
77
69
 
78
- ### 5. Render the banner
70
+ ### 4. Render the banner
79
71
 
80
72
  In your layout, inside `<body>`:
81
73
 
@@ -1,7 +1,7 @@
1
1
  import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
- static targets = ["preferencesPanel", "categoryCheckbox", "manageLink"]
4
+ static targets = ["banner", "preferencesPanel", "categoryCheckbox", "manageLink"]
5
5
  static values = {
6
6
  endpoint: String,
7
7
  csrfToken: String,
@@ -82,8 +82,8 @@ export default class extends Controller {
82
82
  }
83
83
  }
84
84
 
85
- #hideBanner() { this.element.hidden = true; this.element.setAttribute("aria-hidden", "true") }
86
- #showBanner() { this.element.hidden = false; this.element.removeAttribute("aria-hidden") }
85
+ #hideBanner() { this.bannerTarget.hidden = true; this.bannerTarget.setAttribute("aria-hidden", "true") }
86
+ #showBanner() { this.bannerTarget.hidden = false; this.bannerTarget.removeAttribute("aria-hidden") }
87
87
  #showManageLink() { if (this.hasManageLinkTarget) this.manageLinkTarget.hidden = false }
88
88
  #hideManageLink() { if (this.hasManageLinkTarget) this.manageLinkTarget.hidden = true }
89
89
  }
@@ -1,10 +1,12 @@
1
- <div class="biscuit-banner"
2
- data-controller="biscuit"
1
+ <div data-controller="biscuit"
3
2
  data-biscuit-position-value="<%= Biscuit.configuration.position %>"
4
3
  data-biscuit-csrf-token-value="<%= form_authenticity_token %>"
5
4
  data-biscuit-endpoint-value="<%= biscuit.consent_path %>"
6
5
  data-biscuit-already-consented-value="<%= consent.given? %>"
7
- data-biscuit-reload-on-consent-value="<%= options[:reload_on_consent] ? 'true' : 'false' %>"
6
+ data-biscuit-reload-on-consent-value="<%= options[:reload_on_consent] ? 'true' : 'false' %>">
7
+
8
+ <div class="biscuit-banner"
9
+ data-biscuit-target="banner"
8
10
  role="dialog"
9
11
  aria-label="<%= t("biscuit.banner.aria_label") %>"
10
12
  aria-modal="false">
@@ -102,3 +104,5 @@
102
104
  aria-label="<%= t("biscuit.banner.reopen") %>">
103
105
  <%= t("biscuit.banner.reopen") %>
104
106
  </button>
107
+
108
+ </div>
@@ -0,0 +1 @@
1
+ pin "biscuit/biscuit_controller", to: "biscuit/biscuit_controller.js"
@@ -13,5 +13,13 @@ module Biscuit
13
13
  initializer "biscuit.i18n" do
14
14
  config.i18n.load_path += Dir[Engine.root.join("config/locales/*.yml")]
15
15
  end
16
+
17
+ # Register JS pin with the host app's importmap (importmap-rails only)
18
+ initializer "biscuit.importmap", before: "importmap" do |app|
19
+ if app.config.respond_to?(:importmap)
20
+ app.config.importmap.paths << Engine.root.join("config/importmap.rb")
21
+ app.config.importmap.cache_sweepers << Engine.root.join("app/assets/javascripts")
22
+ end
23
+ end
16
24
  end
17
25
  end
@@ -1,3 +1,3 @@
1
1
  module Biscuit
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biscuit-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gareth James
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-03-20 00:00:00.000000000 Z
10
+ date: 2026-03-28 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -39,6 +39,7 @@ files:
39
39
  - app/controllers/biscuit/consent_controller.rb
40
40
  - app/helpers/biscuit/biscuit_helper.rb
41
41
  - app/views/biscuit/banner/_banner.html.erb
42
+ - config/importmap.rb
42
43
  - config/locales/de.yml
43
44
  - config/locales/en.yml
44
45
  - config/locales/es.yml