swal_rails 0.3.1.beta1
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 +7 -0
- data/Appraisals +43 -0
- data/CHANGELOG.md +73 -0
- data/LICENSE.txt +21 -0
- data/README.md +973 -0
- data/Rakefile +12 -0
- data/app/assets/javascripts/swal_rails/chain.js +38 -0
- data/app/assets/javascripts/swal_rails/confirm.js +93 -0
- data/app/assets/javascripts/swal_rails/controllers/swal_controller.js +54 -0
- data/app/assets/javascripts/swal_rails/flash.js +24 -0
- data/app/assets/javascripts/swal_rails/index.js +62 -0
- data/app/assets/stylesheets/swal_rails/index.css +5 -0
- data/config/importmap.rb +9 -0
- data/config/locales/swal_rails.en.yml +19 -0
- data/config/locales/swal_rails.fr.yml +19 -0
- data/gemfiles/rails_7_2.gemfile +25 -0
- data/gemfiles/rails_8_0.gemfile +25 -0
- data/gemfiles/rails_8_1.gemfile +25 -0
- data/gemfiles/rails_8_1_sprockets.gemfile +25 -0
- data/lib/generators/swal_rails/install/install_generator.rb +138 -0
- data/lib/generators/swal_rails/install/templates/initializer.rb +33 -0
- data/lib/generators/swal_rails/locales/locales_generator.rb +19 -0
- data/lib/swal_rails/configuration.rb +88 -0
- data/lib/swal_rails/engine.rb +55 -0
- data/lib/swal_rails/helpers.rb +96 -0
- data/lib/swal_rails/version.rb +6 -0
- data/lib/swal_rails.rb +25 -0
- data/vendor/javascript/sweetalert2/LICENSE +22 -0
- data/vendor/javascript/sweetalert2/sweetalert2.all.js +4814 -0
- data/vendor/javascript/sweetalert2/sweetalert2.all.min.js +6 -0
- data/vendor/javascript/sweetalert2/sweetalert2.esm.all.js +4805 -0
- data/vendor/javascript/sweetalert2/sweetalert2.esm.all.min.js +6 -0
- data/vendor/javascript/sweetalert2/sweetalert2.esm.js +4804 -0
- data/vendor/javascript/sweetalert2/sweetalert2.esm.min.js +5 -0
- data/vendor/javascript/sweetalert2/sweetalert2.js +4813 -0
- data/vendor/javascript/sweetalert2/sweetalert2.min.js +5 -0
- data/vendor/stylesheets/sweetalert2/LICENSE +22 -0
- data/vendor/stylesheets/sweetalert2/sweetalert2.css +1233 -0
- data/vendor/stylesheets/sweetalert2/sweetalert2.min.css +1 -0
- data/vendor/stylesheets/sweetalert2/themes/bootstrap-4.css +167 -0
- data/vendor/stylesheets/sweetalert2/themes/bootstrap-5.css +173 -0
- data/vendor/stylesheets/sweetalert2/themes/borderless.css +46 -0
- data/vendor/stylesheets/sweetalert2/themes/bulma.css +94 -0
- data/vendor/stylesheets/sweetalert2/themes/material-ui.css +183 -0
- data/vendor/stylesheets/sweetalert2/themes/minimal.css +40 -0
- metadata +124 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9e9ac64c06c6de5525bf1964f4c866b72b3a5fc4fb42fed239778cc94e0bc57c
|
|
4
|
+
data.tar.gz: abefde5449478e377516fb40b78087fb89b60f73c60788422309e0930e278643
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 455ee6bc8175ee826535fcfbb7be404f9b56ca2d2a92715f0fe47d818d10521257bcdb8bd640b7b344e26e980aeaa5948d2d237fa097df0aa0e2c534a6fd337a
|
|
7
|
+
data.tar.gz: db9ff1404a3e0b33b0e9b70cb04feb9386c2e94b5dad486477d18b319b16d9c64e055eb47a726f491447bcba326010b08f3565de07f343ad3a0033f6634cc925
|
data/Appraisals
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Regenerate per-version Gemfiles with: bundle exec appraisal install
|
|
4
|
+
#
|
|
5
|
+
# The base Gemfile pins Rails 8.1.3 + Propshaft for local dev. Each appraise
|
|
6
|
+
# block redeclares the Rails stack — Appraisal uses the last `gem` declaration
|
|
7
|
+
# when the same gem is named twice. `remove_gem "propshaft"` is needed for the
|
|
8
|
+
# sprockets variant to avoid shipping both pipelines.
|
|
9
|
+
|
|
10
|
+
appraise "rails-7-2" do
|
|
11
|
+
gem "rails", "~> 7.2.2"
|
|
12
|
+
gem "propshaft", "~> 0.9"
|
|
13
|
+
gem "importmap-rails", "~> 2.0"
|
|
14
|
+
gem "turbo-rails", "~> 2.0"
|
|
15
|
+
gem "stimulus-rails", "~> 1.3"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
appraise "rails-8-0" do
|
|
19
|
+
gem "rails", "~> 8.0.0"
|
|
20
|
+
gem "propshaft", "~> 1.0"
|
|
21
|
+
gem "importmap-rails", "~> 2.0"
|
|
22
|
+
gem "turbo-rails", "~> 2.0"
|
|
23
|
+
gem "stimulus-rails", "~> 1.3"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
appraise "rails-8-1" do
|
|
27
|
+
gem "rails", "~> 8.1.3"
|
|
28
|
+
gem "propshaft", "~> 1.0"
|
|
29
|
+
gem "importmap-rails", "~> 2.0"
|
|
30
|
+
gem "turbo-rails", "~> 2.0"
|
|
31
|
+
gem "stimulus-rails", "~> 1.3"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Rails LTS (8.1) with Sprockets instead of Propshaft — validates the
|
|
35
|
+
# alternative asset pipeline on the version most people will run in prod.
|
|
36
|
+
appraise "rails-8-1-sprockets" do
|
|
37
|
+
remove_gem "propshaft"
|
|
38
|
+
gem "rails", "~> 8.1.3"
|
|
39
|
+
gem "importmap-rails", "~> 2.0"
|
|
40
|
+
gem "turbo-rails", "~> 2.0"
|
|
41
|
+
gem "stimulus-rails", "~> 1.3"
|
|
42
|
+
gem "sprockets-rails", "~> 3.5"
|
|
43
|
+
end
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.3.1.beta1] - 2026-04-21
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- First public release on [RubyGems.org](https://rubygems.org/gems/swal_rails). Prior `0.x` tags lived on GitHub Packages only.
|
|
13
|
+
- Release workflow now publishes to RubyGems via [Trusted Publishing](https://guides.rubygems.org/trusted-publishing/) (OIDC), no long-lived API key.
|
|
14
|
+
|
|
15
|
+
### Security
|
|
16
|
+
- `.gitignore` hardened preventively against `.env`, `master.key`, `config/credentials/*.key`, `*.pem`, `*.key`.
|
|
17
|
+
- Gemspec now pins `allowed_push_host` to `https://rubygems.org` as a safety net against accidental push to other hosts.
|
|
18
|
+
|
|
19
|
+
## [0.3.0] - 2026-04-21
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- **Multi-step confirm chains** — `data-swal-steps='[{...}, {...}]'` (JSON array) runs each step sequentially and only proceeds with the original click/submit if every step is confirmed. Each step is a full SweetAlert2 options Hash, with per-step defaults (`showCancelButton`, `focusCancel`, `icon: "warning"`) merged in first.
|
|
23
|
+
- **Conditional branching** via `onConfirmed` / `onDenied` sub-chains on any step — opt in to a Deny button with `showDenyButton: true` to get a three-way choice; nested sub-chains are recursive. `isDismissed` always aborts.
|
|
24
|
+
- `data-turbo-confirm` (under `:turbo_override` / `:both`) now also accepts a JSON array, firing a chain via the Turbo override path.
|
|
25
|
+
- Stimulus controller gains a `chain` action reading `data-swal-steps-value`; submits the enclosing form when the chain resolves confirmed.
|
|
26
|
+
- Ruby view helper `swal_chain_tag(steps, html_options = {})` — symmetric with `swal_tag`, same `ERB::Util.json_escape` hardening and CSP nonce handling.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- `boot()` is now idempotent across `turbo:load` events: on Turbo-driven navigations the capture-phase click/submit listeners are installed exactly once for the page lifetime, instead of stacking one additional listener per navigation. Previously, after N Turbo visits a single `[data-swal-confirm]` click opened N cascading modals.
|
|
30
|
+
- Confirm → form submit path now calls `form.requestSubmit()` when available (falling back to `form.submit()`), so Turbo and UJS `submit` listeners stay in the loop.
|
|
31
|
+
|
|
32
|
+
### Security
|
|
33
|
+
- Documented the Hash-form escape hatch: when a Hash is assigned to `flash[key]`, `data-turbo-confirm`, `data-swal-confirm` or `data-swal-options`, its keys (notably `html:`, `iconHtml:`, `footer:`) flow unescaped into SweetAlert2. The String form keeps payloads in `text:` and remains XSS-safe by default.
|
|
34
|
+
|
|
35
|
+
## [0.2.1] - 2026-04-20
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
- Release workflow now also triggers on push to `main`: when the version in `lib/swal_rails/version.rb` advances past the last `v*` tag, the workflow creates and pushes the tag, then runs the existing build / GitHub Release / GitHub Packages publish steps in the same job. Tag pushes keep working unchanged.
|
|
39
|
+
|
|
40
|
+
## [0.2.0] - 2026-04-20
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
- Per-request SA2 options via Hash values:
|
|
44
|
+
- `flash[:notice] = { text: "…", icon: "rocket", timer: 5000 }` shadows `flash_map[:notice]`.
|
|
45
|
+
- `data: { turbo_confirm: { icon: "error", title: "Really?" } }` (or `swal_confirm:`) — Rails JSON-encodes the Hash, the runtime parses it back and treats it as full SA2 options.
|
|
46
|
+
- `data-swal-options='{…}'` on confirm triggers — full SA2 options escape hatch, wins over shortcut `data-swal-*` attributes.
|
|
47
|
+
- Flash array expansion: `flash[:alert] = @post.errors.full_messages` fires one Swal per message.
|
|
48
|
+
- CSP nonce support on `swal_tag`: pass `nonce: true` to have Rails substitute the per-request CSP nonce; silent fallback when no CSP helper is configured.
|
|
49
|
+
- Six official SweetAlert2 themes vendored under `vendor/stylesheets/sweetalert2/themes/` (bootstrap-4, bootstrap-5, borderless, bulma, material-ui, minimal). `bootstrap-5` and `material-ui` carry built-in dark variants via `data-swal2-theme="…-dark"`.
|
|
50
|
+
- `Sprockets::Rails` precompile allowlist now includes the ESM bundles, the Stimulus controller path, and all vendored themes — fixes `AssetNotPrecompiledError` on Sprockets host apps.
|
|
51
|
+
|
|
52
|
+
### Security
|
|
53
|
+
- `swal_tag` runs its options through `ERB::Util.json_escape` before interpolating them into the `<script>` body, neutralizing `</script>`, `<!--`, U+2028 and U+2029 — the four sequences that can break out of an inline script block.
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
- Global configuration no longer leaks between spec files (`swal_rails_spec.rb` mutated `confirm_mode` without restoring it, causing intermittent flakes in the system suite).
|
|
57
|
+
|
|
58
|
+
### Changed
|
|
59
|
+
- Flash meta-tag JSON shape: each entry is now `{key, options}` instead of `{key, message}`. Internal to the gem — no action required by consumers of the Ruby API.
|
|
60
|
+
|
|
61
|
+
## [0.1.0] - 2026-04-19
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
- Rails Engine with multi-mode asset delivery (importmap, jsbundling, sprockets).
|
|
65
|
+
- `SwalRails::Configuration` with per-flash-key mapping and four confirm modes
|
|
66
|
+
(`:off`, `:data_attribute`, `:turbo_override`, `:both`).
|
|
67
|
+
- JS runtime: bootstraps `Swal.mixin`, installs confirm handler, auto-fires flash messages.
|
|
68
|
+
- Stimulus controller `swal` with `fire` and `confirm` actions.
|
|
69
|
+
- View helpers: `swal_rails_meta_tags`, `swal_config_meta_tag`, `swal_flash_meta_tag`, `swal_tag`.
|
|
70
|
+
- Generators: `swal_rails:install` (with `--mode` flag) and `swal_rails:locales`.
|
|
71
|
+
- I18n: `en` and `fr` locales.
|
|
72
|
+
- a11y: respect for `prefers-reduced-motion`.
|
|
73
|
+
- Bundled SweetAlert2 v11.26.24 under MIT license.
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Florian Gagnaire
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|