swal_rails 0.3.1.beta2 → 0.3.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/CHANGELOG.md +62 -38
- data/gemfiles/rails_7_2.gemfile +3 -3
- data/gemfiles/rails_8_0.gemfile +3 -3
- data/gemfiles/rails_8_1.gemfile +3 -3
- data/gemfiles/rails_8_1_sprockets.gemfile +3 -3
- data/lib/generators/swal_rails/install/templates/initializer.rb +9 -1
- data/lib/swal_rails/configuration.rb +9 -1
- data/lib/swal_rails/engine.rb +7 -0
- data/lib/swal_rails/initializer_version_check.rb +44 -0
- data/lib/swal_rails/version.rb +1 -1
- data/lib/swal_rails.rb +9 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db0cf6b419c2e989dfcc877d644fc85244f2c85e0fc2e012661b594854d5cdad
|
|
4
|
+
data.tar.gz: f26da33eb89b79b5338eb822281f89d5bc43376ca3a22f39969aaba3c7440f66
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 35d5a3a5d411f39870070332ab2516987d9f6345ca3cf17f3fb6b0958f1ae9680608bb1a355ce2ffad3257cabb3e384fee9533018756c90784a29fc176c456c9
|
|
7
|
+
data.tar.gz: e48305dfd6fdb0bcb3bab2cbafbf4f56a017006e5d2d95cb716ecff61fa15ffd4abea636206c04e7e57f76a15a7d9888bd64cf6f114ce21bf78a346b52b43424
|
data/CHANGELOG.md
CHANGED
|
@@ -6,44 +6,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
-
## [0.3.
|
|
9
|
+
## [0.3.3] - 2026-04-25
|
|
10
10
|
|
|
11
|
-
###
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
### Changed
|
|
29
|
-
- `default_options` no longer ships with `focusConfirm: true` /
|
|
30
|
-
`returnFocus: true`. Both are already SA2's internal defaults, so
|
|
31
|
-
behavior is unchanged — but listing them explicitly made SA2 warn
|
|
32
|
-
("incompatible with toasts") on every toast fire. The generator
|
|
33
|
-
template is updated to match.
|
|
34
|
-
- `flash_map[:alert]` and `flash_map[:error]` now default to a toast
|
|
35
|
-
(top-end, 4s, error icon) instead of a blocking modal. This makes every
|
|
36
|
-
built-in flash key a toast out of the box — more consistent and more in
|
|
37
|
-
line with how Rails apps typically use `flash[:alert]`. Users who want
|
|
38
|
-
the old modal behavior can still opt in:
|
|
39
|
-
`config.flash_map[:alert] = { icon: "error", toast: false }`.
|
|
11
|
+
### Added
|
|
12
|
+
- Boot-time initializer drift detection. The gem ships
|
|
13
|
+
`SwalRails::INITIALIZER_VERSION`, the install template stamps
|
|
14
|
+
`config.initializer_version = "<current>"`, and a Rails initializer
|
|
15
|
+
hooked after `:load_config_initializers` logs a one-line warning when
|
|
16
|
+
the user's stamp is missing or trails the gem's expected value. Includes
|
|
17
|
+
the regenerate command in the message:
|
|
18
|
+
`bin/rails g swal_rails:install --skip-layout --force`.
|
|
19
|
+
- `config.silence_initializer_warning` (Boolean, default `false`) opt-out
|
|
20
|
+
for users who don't want to regenerate.
|
|
21
|
+
|
|
22
|
+
## [0.3.2] - 2026-04-25
|
|
23
|
+
|
|
24
|
+
First stable release on top of the `0.3.1.beta1` + `0.3.1.beta2`
|
|
25
|
+
prereleases. End users upgrading from `0.3.0` should read the
|
|
26
|
+
consolidated entry below.
|
|
40
27
|
|
|
41
28
|
### Added
|
|
42
29
|
- `config.flash_array_mode` (`:sequential` default | `:stacked`) — how a
|
|
43
30
|
multi-entry flash payload is played. Sequential waits for each Swal to
|
|
44
|
-
close before firing the next
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
close before firing the next; stacked renders every toast in parallel in
|
|
32
|
+
a fixed top-right container with a configurable delay between each
|
|
33
|
+
appearance.
|
|
47
34
|
- `config.flash_stack_delay` (ms, default 500) — gap between stacked
|
|
48
35
|
toasts in `:stacked` mode.
|
|
49
36
|
- `swal_flash(key, messages, mode:, delay:, now:, **options)` helper,
|
|
@@ -53,15 +40,52 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
53
40
|
- Reserved meta-keys `_arrayMode` / `_stackDelay` on flash entry options,
|
|
54
41
|
stripped by the JS runtime before being passed to `Swal.fire`.
|
|
55
42
|
|
|
56
|
-
## [0.3.1.beta1] - 2026-04-21
|
|
57
|
-
|
|
58
43
|
### Changed
|
|
59
|
-
-
|
|
44
|
+
- `flash_map[:alert]` and `flash_map[:error]` now default to a toast
|
|
45
|
+
(top-end, 4s, error icon) instead of a blocking modal. Every built-in
|
|
46
|
+
flash key is a toast out of the box — more consistent and in line with
|
|
47
|
+
how Rails apps typically use `flash[:alert]`. The old modal behavior is
|
|
48
|
+
still opt-in: `config.flash_map[:alert] = { icon: "error", toast: false }`.
|
|
49
|
+
- `default_options` no longer ships with `focusConfirm: true` /
|
|
50
|
+
`returnFocus: true`. Both are SA2's internal defaults already, so
|
|
51
|
+
behavior is unchanged — but listing them explicitly made SA2 warn
|
|
52
|
+
("incompatible with toasts") on every toast fire. Generator template
|
|
53
|
+
updated to match.
|
|
54
|
+
- Generator initializer comment for `:turbo_override` now mentions
|
|
55
|
+
`Turbo.config.forms.confirm` (Turbo 8.1+) with a fallback to the legacy
|
|
56
|
+
`setConfirmMethod`.
|
|
60
57
|
- Release workflow now publishes to RubyGems via [Trusted Publishing](https://guides.rubygems.org/trusted-publishing/) (OIDC), no long-lived API key.
|
|
58
|
+
- First public release on [RubyGems.org](https://rubygems.org/gems/swal_rails). Prior `0.x` tags lived on GitHub Packages only.
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
- Flash runtime also boots on `turbo:render`, not just `turbo:load`. Form
|
|
62
|
+
submissions that render in place (`render :index, status:
|
|
63
|
+
:unprocessable_entity` for `flash.now` payloads) trigger `turbo:render`
|
|
64
|
+
but not `turbo:load`, so the `swal-flash` meta tag emitted in the new
|
|
65
|
+
body never reached the runtime. The `data-swal-consumed` guard on the
|
|
66
|
+
meta tag dedupes the double-fire on full navigations.
|
|
67
|
+
- Stacked-mode clones render at SA2's standard toast width (360px, capped
|
|
68
|
+
at `calc(100vw - 2rem)`) instead of stretching to the full page. CSS on
|
|
69
|
+
`#swal-rails-stack` mirrors SA2's `body.swal2-toast-shown .swal2-container`
|
|
70
|
+
rules — necessary because the cloned popups live outside SA2's container
|
|
71
|
+
hierarchy.
|
|
72
|
+
- Confirm `:turbo_override` / `:both` writes to `Turbo.config.forms.confirm`
|
|
73
|
+
first (Turbo 8.1+) and falls back to the deprecated
|
|
74
|
+
`Turbo.setConfirmMethod`. Silences the Turbo deprecation warning.
|
|
61
75
|
|
|
62
76
|
### Security
|
|
63
|
-
- `.gitignore` hardened preventively against `.env`, `master.key`,
|
|
64
|
-
|
|
77
|
+
- `.gitignore` hardened preventively against `.env`, `master.key`,
|
|
78
|
+
`config/credentials/*.key`, `*.pem`, `*.key`.
|
|
79
|
+
- Gemspec pins `allowed_push_host` to `https://rubygems.org` as a safety
|
|
80
|
+
net against accidental push to other hosts.
|
|
81
|
+
|
|
82
|
+
## [0.3.1.beta2] - 2026-04-24
|
|
83
|
+
|
|
84
|
+
Prerelease snapshot — superseded by [0.3.2].
|
|
85
|
+
|
|
86
|
+
## [0.3.1.beta1] - 2026-04-21
|
|
87
|
+
|
|
88
|
+
Prerelease snapshot — superseded by [0.3.2].
|
|
65
89
|
|
|
66
90
|
## [0.3.0] - 2026-04-21
|
|
67
91
|
|
data/gemfiles/rails_7_2.gemfile
CHANGED
|
@@ -14,12 +14,12 @@ group :development, :test do
|
|
|
14
14
|
gem "appraisal", "~> 2.5"
|
|
15
15
|
gem "capybara", "~> 3.40"
|
|
16
16
|
gem "cuprite", "~> 0.15"
|
|
17
|
-
gem "puma", "~>
|
|
17
|
+
gem "puma", "~> 8.0"
|
|
18
18
|
gem "rspec", "~> 3.12"
|
|
19
|
-
gem "rspec-rails", "~>
|
|
19
|
+
gem "rspec-rails", "~> 8.0"
|
|
20
20
|
gem "rubocop", "~> 1.60", require: false
|
|
21
21
|
gem "rubocop-rspec", require: false
|
|
22
|
-
gem "sqlite3", "~>
|
|
22
|
+
gem "sqlite3", "~> 2.9"
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
gemspec path: "../"
|
data/gemfiles/rails_8_0.gemfile
CHANGED
|
@@ -14,12 +14,12 @@ group :development, :test do
|
|
|
14
14
|
gem "appraisal", "~> 2.5"
|
|
15
15
|
gem "capybara", "~> 3.40"
|
|
16
16
|
gem "cuprite", "~> 0.15"
|
|
17
|
-
gem "puma", "~>
|
|
17
|
+
gem "puma", "~> 8.0"
|
|
18
18
|
gem "rspec", "~> 3.12"
|
|
19
|
-
gem "rspec-rails", "~>
|
|
19
|
+
gem "rspec-rails", "~> 8.0"
|
|
20
20
|
gem "rubocop", "~> 1.60", require: false
|
|
21
21
|
gem "rubocop-rspec", require: false
|
|
22
|
-
gem "sqlite3", "~>
|
|
22
|
+
gem "sqlite3", "~> 2.9"
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
gemspec path: "../"
|
data/gemfiles/rails_8_1.gemfile
CHANGED
|
@@ -14,12 +14,12 @@ group :development, :test do
|
|
|
14
14
|
gem "appraisal", "~> 2.5"
|
|
15
15
|
gem "capybara", "~> 3.40"
|
|
16
16
|
gem "cuprite", "~> 0.15"
|
|
17
|
-
gem "puma", "~>
|
|
17
|
+
gem "puma", "~> 8.0"
|
|
18
18
|
gem "rspec", "~> 3.12"
|
|
19
|
-
gem "rspec-rails", "~>
|
|
19
|
+
gem "rspec-rails", "~> 8.0"
|
|
20
20
|
gem "rubocop", "~> 1.60", require: false
|
|
21
21
|
gem "rubocop-rspec", require: false
|
|
22
|
-
gem "sqlite3", "~>
|
|
22
|
+
gem "sqlite3", "~> 2.9"
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
gemspec path: "../"
|
|
@@ -14,12 +14,12 @@ group :development, :test do
|
|
|
14
14
|
gem "appraisal", "~> 2.5"
|
|
15
15
|
gem "capybara", "~> 3.40"
|
|
16
16
|
gem "cuprite", "~> 0.15"
|
|
17
|
-
gem "puma", "~>
|
|
17
|
+
gem "puma", "~> 8.0"
|
|
18
18
|
gem "rspec", "~> 3.12"
|
|
19
|
-
gem "rspec-rails", "~>
|
|
19
|
+
gem "rspec-rails", "~> 8.0"
|
|
20
20
|
gem "rubocop", "~> 1.60", require: false
|
|
21
21
|
gem "rubocop-rspec", require: false
|
|
22
|
-
gem "sqlite3", "~>
|
|
22
|
+
gem "sqlite3", "~> 2.9"
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
gemspec path: "../"
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
SwalRails.configure do |config|
|
|
4
|
+
# Stamps this initializer against the template version that shipped with
|
|
5
|
+
# the installed gem. The boot-time check warns if you upgrade the gem to
|
|
6
|
+
# a version with a newer template — regenerate with:
|
|
7
|
+
# bin/rails g swal_rails:install --skip-layout --force
|
|
8
|
+
# Set `config.silence_initializer_warning = true` to silence.
|
|
9
|
+
config.initializer_version = "<%= SwalRails::INITIALIZER_VERSION %>"
|
|
10
|
+
|
|
4
11
|
# How confirmation modals are wired.
|
|
5
12
|
# :off — do nothing, use Swal manually
|
|
6
13
|
# :data_attribute — intercept clicks/submits on [data-swal-confirm] (default, non-intrusive)
|
|
7
|
-
# :turbo_override — replace Turbo.
|
|
14
|
+
# :turbo_override — replace Turbo.config.forms.confirm globally (Turbo 8.1+),
|
|
15
|
+
# falls back to legacy Turbo.setConfirmMethod on older Turbo
|
|
8
16
|
# :both — both mechanisms at once
|
|
9
17
|
config.confirm_mode = :<%= options[:confirm_mode] %>
|
|
10
18
|
|
|
@@ -17,7 +17,9 @@ module SwalRails
|
|
|
17
17
|
:flash_keys_as_meta,
|
|
18
18
|
:respect_reduced_motion,
|
|
19
19
|
:expose_window_swal,
|
|
20
|
-
:flash_stack_delay
|
|
20
|
+
:flash_stack_delay,
|
|
21
|
+
:initializer_version,
|
|
22
|
+
:silence_initializer_warning
|
|
21
23
|
attr_reader :confirm_mode, :flash_map, :i18n_scope, :flash_array_mode
|
|
22
24
|
|
|
23
25
|
def initialize
|
|
@@ -28,6 +30,12 @@ module SwalRails
|
|
|
28
30
|
@flash_array_mode = :sequential
|
|
29
31
|
@flash_stack_delay = 500
|
|
30
32
|
@i18n_scope = "swal_rails"
|
|
33
|
+
# `initializer_version` left nil — apps that haven't regenerated
|
|
34
|
+
# their initializer since `SwalRails::INITIALIZER_VERSION` was
|
|
35
|
+
# introduced (0.3.3) get a one-line warning at boot. Setting it
|
|
36
|
+
# explicitly in the initializer template silences it.
|
|
37
|
+
@initializer_version = nil
|
|
38
|
+
@silence_initializer_warning = false
|
|
31
39
|
# `focusConfirm` / `returnFocus` are intentionally omitted: SA2 already
|
|
32
40
|
# defaults both to `true` internally, and passing them explicitly makes
|
|
33
41
|
# SA2 warn on every toast ("incompatible with toasts"). Listing them
|
data/lib/swal_rails/engine.rb
CHANGED
|
@@ -52,6 +52,13 @@ module SwalRails
|
|
|
52
52
|
initializer "swal_rails.i18n" do
|
|
53
53
|
config.i18n.load_path += Dir[root.join("config/locales/*.yml").to_s]
|
|
54
54
|
end
|
|
55
|
+
|
|
56
|
+
# Run AFTER user initializers so we can read whatever value they set
|
|
57
|
+
# (or didn't set) for `config.initializer_version`. One-shot, idempotent,
|
|
58
|
+
# opt-out via `config.silence_initializer_warning = true`.
|
|
59
|
+
initializer "swal_rails.check_initializer_version", after: :load_config_initializers do
|
|
60
|
+
SwalRails::InitializerVersionCheck.run!
|
|
61
|
+
end
|
|
55
62
|
end
|
|
56
63
|
end
|
|
57
64
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SwalRails
|
|
4
|
+
# Compares the user's `config.initializer_version` against the gem's
|
|
5
|
+
# `SwalRails::INITIALIZER_VERSION` and logs a one-line warning when the
|
|
6
|
+
# initializer is missing the stamp or trails the gem's expected value.
|
|
7
|
+
#
|
|
8
|
+
# Wired into the engine after `:load_config_initializers` so it sees
|
|
9
|
+
# whatever the user set. Silenced via
|
|
10
|
+
# `config.silence_initializer_warning = true`.
|
|
11
|
+
module InitializerVersionCheck
|
|
12
|
+
module_function
|
|
13
|
+
|
|
14
|
+
def run!(logger: default_logger, config: SwalRails.configuration)
|
|
15
|
+
return if config.silence_initializer_warning
|
|
16
|
+
|
|
17
|
+
message = stale_message(config)
|
|
18
|
+
return unless message
|
|
19
|
+
|
|
20
|
+
logger.warn(message)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def stale_message(config)
|
|
24
|
+
user = config.initializer_version
|
|
25
|
+
current = SwalRails::INITIALIZER_VERSION
|
|
26
|
+
|
|
27
|
+
return nil if user == current
|
|
28
|
+
|
|
29
|
+
regen = "Run `bin/rails g swal_rails:install --skip-layout --force` to regenerate, or set " \
|
|
30
|
+
"`config.silence_initializer_warning = true` to silence."
|
|
31
|
+
|
|
32
|
+
if user.nil?
|
|
33
|
+
"[swal_rails] config/initializers/swal_rails.rb predates v#{current} " \
|
|
34
|
+
"(no `config.initializer_version` set). New options may be missing. #{regen}"
|
|
35
|
+
else
|
|
36
|
+
"[swal_rails] initializer template advanced to v#{current} (yours: v#{user}). #{regen}"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def default_logger
|
|
41
|
+
defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger ? Rails.logger : Logger.new($stderr)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/lib/swal_rails/version.rb
CHANGED
data/lib/swal_rails.rb
CHANGED
|
@@ -5,6 +5,14 @@ require_relative "swal_rails/version"
|
|
|
5
5
|
module SwalRails
|
|
6
6
|
class Error < StandardError; end
|
|
7
7
|
|
|
8
|
+
# The initializer template version this release of the gem ships.
|
|
9
|
+
# Bump only when the template content changes in a way users should
|
|
10
|
+
# know about (new option, removed option, default flip). Compared at
|
|
11
|
+
# boot against `config.initializer_version` to warn about stale
|
|
12
|
+
# config/initializers/swal_rails.rb files. Independent from gem VERSION
|
|
13
|
+
# so non-template-touching releases don't trigger spurious warnings.
|
|
14
|
+
INITIALIZER_VERSION = "0.3.3"
|
|
15
|
+
|
|
8
16
|
class << self
|
|
9
17
|
def configuration
|
|
10
18
|
@configuration ||= Configuration.new
|
|
@@ -21,5 +29,6 @@ module SwalRails
|
|
|
21
29
|
end
|
|
22
30
|
|
|
23
31
|
require_relative "swal_rails/configuration"
|
|
32
|
+
require_relative "swal_rails/initializer_version_check"
|
|
24
33
|
require_relative "swal_rails/helpers"
|
|
25
34
|
require_relative "swal_rails/engine" if defined?(Rails::Engine)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: swal_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Gagnaire
|
|
@@ -73,6 +73,7 @@ files:
|
|
|
73
73
|
- lib/swal_rails/configuration.rb
|
|
74
74
|
- lib/swal_rails/engine.rb
|
|
75
75
|
- lib/swal_rails/helpers.rb
|
|
76
|
+
- lib/swal_rails/initializer_version_check.rb
|
|
76
77
|
- lib/swal_rails/version.rb
|
|
77
78
|
- vendor/javascript/sweetalert2/LICENSE
|
|
78
79
|
- vendor/javascript/sweetalert2/sweetalert2.all.js
|