diff --git a/Gemfile b/Gemfile index d67e0bf5..3cc41995 100644 --- a/Gemfile +++ b/Gemfile @@ -12,13 +12,12 @@ git_source(:github) do |repo_name| end if next? - gem "rails", "~> 8.1.0" - gem "mutex_m" + gem "rails", github: "rails/rails", branch: "main" else - gem "rails", "~> 8.0.0" + gem "rails", "~> 8.1.0" end -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem "mutex_m" gem "rails-observers" gem "csv" @@ -73,7 +72,7 @@ group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem "byebug", platforms: [:mri, :mingw, :x64_mingw] # Adds support for Capybara system testing and selenium driver - gem "rspec-rails", "~> 6.1" + gem "rspec-rails", "~> 8.1" gem "faker" gem "shoulda-matchers", "~> 3.1" gem "rails-controller-testing" diff --git a/Gemfile.lock b/Gemfile.lock index 45595737..50898cb2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,29 +10,31 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (8.0.5.1) - actionpack (= 8.0.5.1) - activesupport (= 8.0.5.1) + action_text-trix (2.1.19) + railties + actioncable (8.1.4.1) + actionpack (= 8.1.4.1) + activesupport (= 8.1.4.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (8.0.5.1) - actionpack (= 8.0.5.1) - activejob (= 8.0.5.1) - activerecord (= 8.0.5.1) - activestorage (= 8.0.5.1) - activesupport (= 8.0.5.1) + actionmailbox (8.1.4.1) + actionpack (= 8.1.4.1) + activejob (= 8.1.4.1) + activerecord (= 8.1.4.1) + activestorage (= 8.1.4.1) + activesupport (= 8.1.4.1) mail (>= 2.8.0) - actionmailer (8.0.5.1) - actionpack (= 8.0.5.1) - actionview (= 8.0.5.1) - activejob (= 8.0.5.1) - activesupport (= 8.0.5.1) + actionmailer (8.1.4.1) + actionpack (= 8.1.4.1) + actionview (= 8.1.4.1) + activejob (= 8.1.4.1) + activesupport (= 8.1.4.1) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.0.5.1) - actionview (= 8.0.5.1) - activesupport (= 8.0.5.1) + actionpack (8.1.4.1) + actionview (= 8.1.4.1) + activesupport (= 8.1.4.1) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -40,42 +42,43 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (8.0.5.1) - actionpack (= 8.0.5.1) - activerecord (= 8.0.5.1) - activestorage (= 8.0.5.1) - activesupport (= 8.0.5.1) + actiontext (8.1.4.1) + action_text-trix (~> 2.1.15) + actionpack (= 8.1.4.1) + activerecord (= 8.1.4.1) + activestorage (= 8.1.4.1) + activesupport (= 8.1.4.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (8.0.5.1) - activesupport (= 8.0.5.1) + actionview (8.1.4.1) + activesupport (= 8.1.4.1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (8.0.5.1) - activesupport (= 8.0.5.1) + rails-html-sanitizer (~> 1.6, >= 1.7.2) + activejob (8.1.4.1) + activesupport (= 8.1.4.1) globalid (>= 0.3.6) - activemodel (8.0.5.1) - activesupport (= 8.0.5.1) - activerecord (8.0.5.1) - activemodel (= 8.0.5.1) - activesupport (= 8.0.5.1) + activemodel (8.1.4.1) + activesupport (= 8.1.4.1) + activerecord (8.1.4.1) + activemodel (= 8.1.4.1) + activesupport (= 8.1.4.1) timeout (>= 0.4.0) - activestorage (8.0.5.1) - actionpack (= 8.0.5.1) - activejob (= 8.0.5.1) - activerecord (= 8.0.5.1) - activesupport (= 8.0.5.1) + activestorage (8.1.4.1) + actionpack (= 8.1.4.1) + activejob (= 8.1.4.1) + activerecord (= 8.1.4.1) + activesupport (= 8.1.4.1) marcel (~> 1.0) - activesupport (8.0.5.1) + activesupport (8.1.4.1) base64 - benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json logger (>= 1.4.2) minitest (>= 5.1) securerandom (>= 0.3) @@ -94,7 +97,6 @@ GEM execjs (~> 2) base64 (0.3.0) bcrypt (3.1.22) - benchmark (0.5.0) bigdecimal (4.1.2) bindex (0.8.1) bootstrap-sass (3.4.1) @@ -199,9 +201,9 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) - loofah (2.25.2) + loofah (2.25.3) crass (~> 1.0.2) - nokogiri (>= 1.12.0) + nokogiri (>= 1.19.5) madmin (2.3.3) importmap-rails pagy (>= 3.5) @@ -227,6 +229,7 @@ GEM prism (~> 1.5) multi_xml (0.9.1) bigdecimal (>= 3.1, < 5) + mutex_m (0.3.0) net-http (0.9.1) uri (>= 0.11.1) net-imap (0.6.4.1) @@ -242,14 +245,14 @@ GEM next_rails (1.3.0) colorize (>= 0.8.1) nio4r (2.7.5) - nokogiri (1.19.4) + nokogiri (1.19.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.19.4-arm64-darwin) + nokogiri (1.19.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.19.4-x86_64-darwin) + nokogiri (1.19.7-x86_64-darwin) racc (~> 1.4) - nokogiri (1.19.4-x86_64-linux-gnu) + nokogiri (1.19.7-x86_64-linux-gnu) racc (~> 1.4) oauth2 (2.0.25) anonymous_loader (~> 0.1, >= 0.1.3) @@ -261,9 +264,9 @@ GEM rack (>= 1.2, < 4) snaky_hash (~> 2.0, >= 2.0.7) version_gem (~> 1.1, >= 1.1.14) - ombu_labs-auth (1.2.0) + ombu_labs-auth (1.3.0) devise (>= 4.9) - omniauth (~> 2.1.0) + omniauth (~> 2.1) omniauth-github (~> 2.0.0) omniauth-google-oauth2 (~> 1.1) omniauth-rails_csrf_protection @@ -326,20 +329,20 @@ GEM rack (>= 1.3) rackup (2.3.1) rack (>= 3) - rails (8.0.5.1) - actioncable (= 8.0.5.1) - actionmailbox (= 8.0.5.1) - actionmailer (= 8.0.5.1) - actionpack (= 8.0.5.1) - actiontext (= 8.0.5.1) - actionview (= 8.0.5.1) - activejob (= 8.0.5.1) - activemodel (= 8.0.5.1) - activerecord (= 8.0.5.1) - activestorage (= 8.0.5.1) - activesupport (= 8.0.5.1) + rails (8.1.4.1) + actioncable (= 8.1.4.1) + actionmailbox (= 8.1.4.1) + actionmailer (= 8.1.4.1) + actionpack (= 8.1.4.1) + actiontext (= 8.1.4.1) + actionview (= 8.1.4.1) + activejob (= 8.1.4.1) + activemodel (= 8.1.4.1) + activerecord (= 8.1.4.1) + activestorage (= 8.1.4.1) + activesupport (= 8.1.4.1) bundler (>= 1.15.0) - railties (= 8.0.5.1) + railties (= 8.1.4.1) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -348,14 +351,14 @@ GEM activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.7.1) - loofah (~> 2.25, >= 2.25.2) + rails-html-sanitizer (1.7.2) + loofah (~> 2.25, >= 2.25.3) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) rails-observers (0.1.5) activemodel (>= 4.0) - railties (8.0.5.1) - actionpack (= 8.0.5.1) - activesupport (= 8.0.5.1) + railties (8.1.4.1) + actionpack (= 8.1.4.1) + activesupport (= 8.1.4.1) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -393,14 +396,14 @@ GEM rspec-mocks (3.13.8) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (6.1.5) - actionpack (>= 6.1) - activesupport (>= 6.1) - railties (>= 6.1) - rspec-core (~> 3.13) - rspec-expectations (~> 3.13) - rspec-mocks (~> 3.13) - rspec-support (~> 3.13) + rspec-rails (8.1.0) + actionpack (>= 7.2) + activesupport (>= 7.2) + railties (>= 7.2) + rspec-core (>= 3.13.0, < 5.0.0) + rspec-expectations (>= 3.13.0, < 5.0.0) + rspec-mocks (>= 3.13.0, < 5.0.0) + rspec-support (>= 3.13.0, < 5.0.0) rspec-support (3.13.7) rubocop (1.88.2) json (~> 2.3) @@ -551,6 +554,7 @@ DEPENDENCIES madmin (~> 2.0) matrix mimemagic (~> 0.3.8) + mutex_m newrelic_rpm next_rails ombu_labs-auth @@ -559,12 +563,12 @@ DEPENDENCIES puma (~> 7.2) pundit (~> 2.2) rack-mini-profiler - rails (~> 8.0.0) + rails (~> 8.1.0) rails-controller-testing rails-observers recursive-open-struct redcarpet (~> 3.5.1) - rspec-rails (~> 6.1) + rspec-rails (~> 8.1) sass-rails (~> 6.0) sentry-rails sentry-ruby diff --git a/Gemfile.next.lock b/Gemfile.next.lock index f63b2c9e..de3dfd16 100644 --- a/Gemfile.next.lock +++ b/Gemfile.next.lock @@ -1,89 +1,121 @@ GIT - remote: https://github.com/twalpole/apparition.git - revision: 7db58cc6b0e4ca4141b074ff27d5936a1b8874bf - ref: 7db58cc6b0e4ca4141b074ff27d5936a1b8874bf - specs: - apparition (0.4.0) - capybara (~> 3.13, < 4) - websocket-driver (>= 0.6.5) - -GEM - remote: https://rubygems.org/ + remote: https://github.com/rails/rails.git + revision: 3327db0f47e6295d30ac1b5cdb64e9c863a261f2 + branch: main specs: - action_text-trix (2.1.19) - railties - actioncable (8.1.3) - actionpack (= 8.1.3) - activesupport (= 8.1.3) + actioncable (8.2.0.alpha) + actionpack (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (8.1.3) - actionpack (= 8.1.3) - activejob (= 8.1.3) - activerecord (= 8.1.3) - activestorage (= 8.1.3) - activesupport (= 8.1.3) + actionmailbox (8.2.0.alpha) + actionpack (= 8.2.0.alpha) + activejob (= 8.2.0.alpha) + activerecord (= 8.2.0.alpha) + activestorage (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) mail (>= 2.8.0) - actionmailer (8.1.3) - actionpack (= 8.1.3) - actionview (= 8.1.3) - activejob (= 8.1.3) - activesupport (= 8.1.3) + actionmailer (8.2.0.alpha) + actionpack (= 8.2.0.alpha) + actionview (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.1.3) - actionview (= 8.1.3) - activesupport (= 8.1.3) + actionpack (8.2.0.alpha) + actionview (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) + rails-html-sanitizer (~> 1.7) useragent (~> 0.16) - actiontext (8.1.3) - action_text-trix (~> 2.1.15) - actionpack (= 8.1.3) - activerecord (= 8.1.3) - activestorage (= 8.1.3) - activesupport (= 8.1.3) + actiontext (8.2.0.alpha) + action_text-trix (~> 2.1.16) + actionpack (= 8.2.0.alpha) + activerecord (= 8.2.0.alpha) + activestorage (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (8.1.3) - activesupport (= 8.1.3) + actionview (8.2.0.alpha) + activesupport (= 8.2.0.alpha) builder (~> 3.1) erubi (~> 1.11) + herb (>= 0.10) + prism (~> 1.0) rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (8.1.3) - activesupport (= 8.1.3) - globalid (>= 0.3.6) - activemodel (8.1.3) - activesupport (= 8.1.3) - activerecord (8.1.3) - activemodel (= 8.1.3) - activesupport (= 8.1.3) + rails-html-sanitizer (~> 1.7, >= 1.7.2) + activejob (8.2.0.alpha) + activesupport (= 8.2.0.alpha) + globalid (>= 1.4.0) + activemodel (8.2.0.alpha) + activesupport (= 8.2.0.alpha) + activerecord (8.2.0.alpha) + activemodel (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) timeout (>= 0.4.0) - activestorage (8.1.3) - actionpack (= 8.1.3) - activejob (= 8.1.3) - activerecord (= 8.1.3) - activesupport (= 8.1.3) - marcel (~> 1.0) - activesupport (8.1.3) + activestorage (8.2.0.alpha) + actionpack (= 8.2.0.alpha) + activejob (= 8.2.0.alpha) + activerecord (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + marcel (~> 2.0) + activesupport (8.2.0.alpha) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) - connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) json logger (>= 1.4.2) minitest (>= 5.1) + psych (>= 4) + ractor-dispatch (>= 0.3.0) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) + rails (8.2.0.alpha) + actioncable (= 8.2.0.alpha) + actionmailbox (= 8.2.0.alpha) + actionmailer (= 8.2.0.alpha) + actionpack (= 8.2.0.alpha) + actiontext (= 8.2.0.alpha) + actionview (= 8.2.0.alpha) + activejob (= 8.2.0.alpha) + activemodel (= 8.2.0.alpha) + activerecord (= 8.2.0.alpha) + activestorage (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + bundler (>= 1.15.0) + railties (= 8.2.0.alpha) + railties (8.2.0.alpha) + actionpack (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + irb (~> 1.13) + prism + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + tsort (>= 0.2) + zeitwerk (~> 2.6) + +GIT + remote: https://github.com/twalpole/apparition.git + revision: 7db58cc6b0e4ca4141b074ff27d5936a1b8874bf + ref: 7db58cc6b0e4ca4141b074ff27d5936a1b8874bf + specs: + apparition (0.4.0) + capybara (~> 3.13, < 4) + websocket-driver (>= 0.6.5) + +GEM + remote: https://rubygems.org/ + specs: + action_text-trix (2.1.19) + railties acts_as_list (1.2.6) activerecord (>= 6.1) activesupport (>= 6.1) @@ -123,7 +155,6 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.3.6) - connection_pool (3.0.2) crass (1.0.6) csv (3.3.5) database_cleaner-active_record (2.2.2) @@ -169,10 +200,19 @@ GEM ffi (1.17.4-x86_64-darwin) ffi (1.17.4-x86_64-linux-gnu) ffi (1.17.4-x86_64-linux-musl) - globalid (1.3.0) + globalid (1.4.0) activesupport (>= 6.1) hashie (5.1.0) logger + herb (0.11.2) + herb (0.11.2-aarch64-linux-gnu) + herb (0.11.2-aarch64-linux-musl) + herb (0.11.2-arm-linux-gnu) + herb (0.11.2-arm-linux-musl) + herb (0.11.2-arm64-darwin) + herb (0.11.2-x86_64-darwin) + herb (0.11.2-x86_64-linux-gnu) + herb (0.11.2-x86_64-linux-musl) i18n (1.14.8) concurrent-ruby (~> 1.0) importmap-rails (2.2.3) @@ -208,9 +248,9 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) - loofah (2.25.1) + loofah (2.25.3) crass (~> 1.0.2) - nokogiri (>= 1.12.0) + nokogiri (>= 1.19.5) madmin (2.3.3) importmap-rails pagy (>= 3.5) @@ -224,7 +264,7 @@ GEM net-imap net-pop net-smtp - marcel (1.1.0) + marcel (2.1.0) matrix (0.4.3) mimemagic (0.3.10) nokogiri (~> 1) @@ -253,24 +293,24 @@ GEM next_rails (1.5.0) rainbow (>= 3) nio4r (2.7.5) - nokogiri (1.19.3) + nokogiri (1.19.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.19.3-aarch64-linux-gnu) + nokogiri (1.19.7-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.19.3-aarch64-linux-musl) + nokogiri (1.19.7-aarch64-linux-musl) racc (~> 1.4) - nokogiri (1.19.3-arm-linux-gnu) + nokogiri (1.19.7-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.19.3-arm-linux-musl) + nokogiri (1.19.7-arm-linux-musl) racc (~> 1.4) - nokogiri (1.19.3-arm64-darwin) + nokogiri (1.19.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.19.3-x86_64-darwin) + nokogiri (1.19.7-x86_64-darwin) racc (~> 1.4) - nokogiri (1.19.3-x86_64-linux-gnu) + nokogiri (1.19.7-x86_64-linux-gnu) racc (~> 1.4) - nokogiri (1.19.3-x86_64-linux-musl) + nokogiri (1.19.7-x86_64-linux-musl) racc (~> 1.4) oauth2 (2.0.18) faraday (>= 0.17.3, < 4.0) @@ -280,9 +320,9 @@ GEM rack (>= 1.2, < 4) snaky_hash (~> 2.0, >= 2.0.3) version_gem (~> 1.1, >= 1.1.9) - ombu_labs-auth (1.2.0) + ombu_labs-auth (1.3.0) devise (>= 4.9) - omniauth (~> 2.1.0) + omniauth (~> 2.1) omniauth-github (~> 2.0.0) omniauth-google-oauth2 (~> 1.1) omniauth-rails_csrf_protection @@ -353,20 +393,7 @@ GEM rackup (1.0.1) rack (< 3) webrick - rails (8.1.3) - actioncable (= 8.1.3) - actionmailbox (= 8.1.3) - actionmailer (= 8.1.3) - actionpack (= 8.1.3) - actiontext (= 8.1.3) - actionview (= 8.1.3) - activejob (= 8.1.3) - activemodel (= 8.1.3) - activerecord (= 8.1.3) - activestorage (= 8.1.3) - activesupport (= 8.1.3) - bundler (>= 1.15.0) - railties (= 8.1.3) + ractor-dispatch (0.3.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -375,20 +402,11 @@ GEM activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.7.0) - loofah (~> 2.25) + rails-html-sanitizer (1.7.2) + loofah (~> 2.25, >= 2.25.3) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) rails-observers (0.1.5) activemodel (>= 4.0) - railties (8.1.3) - actionpack (= 8.1.3) - activesupport (= 8.1.3) - irb (~> 1.13) - rackup (>= 1.0.0) - rake (>= 12.2) - thor (~> 1.0, >= 1.2.2) - tsort (>= 0.2) - zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.4.2) rb-fsevent (0.11.2) @@ -416,14 +434,14 @@ GEM rspec-mocks (3.13.8) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (6.1.5) - actionpack (>= 6.1) - activesupport (>= 6.1) - railties (>= 6.1) - rspec-core (~> 3.13) - rspec-expectations (~> 3.13) - rspec-mocks (~> 3.13) - rspec-support (~> 3.13) + rspec-rails (8.1.0) + actionpack (>= 7.2) + activesupport (>= 7.2) + railties (>= 7.2) + rspec-core (>= 3.13.0, < 5.0.0) + rspec-expectations (>= 3.13.0, < 5.0.0) + rspec-mocks (>= 3.13.0, < 5.0.0) + rspec-support (>= 3.13.0, < 5.0.0) rspec-support (3.13.7) rubocop (1.84.2) json (~> 2.3) @@ -479,10 +497,10 @@ GEM hashie (>= 0.1.0, < 6) version_gem (>= 1.1.8, < 3) spring (3.0.0) - sprockets (3.7.5) - base64 - concurrent-ruby (~> 1.0) - rack (> 1, < 3) + sprockets (4.4.1) + concurrent-ruby (~> 1.1) + logger + rack (>= 2.2.4, < 4) sprockets-rails (3.5.2) actionpack (>= 6.1) activesupport (>= 6.1) @@ -588,12 +606,12 @@ DEPENDENCIES puma (~> 7.2) pundit (~> 2.2) rack-mini-profiler - rails (~> 8.1.0) + rails! rails-controller-testing rails-observers recursive-open-struct redcarpet (~> 3.5.1) - rspec-rails (~> 6.1) + rspec-rails (~> 8.1) sass-rails (~> 6.0) sentry-rails sentry-ruby diff --git a/vendor/assets/javascripts/rails-ujs.js b/vendor/assets/javascripts/rails-ujs.js new file mode 100644 index 00000000..d38e25dd --- /dev/null +++ b/vendor/assets/javascripts/rails-ujs.js @@ -0,0 +1,634 @@ +// Vendored from actionview 8.1.4.1 (app/assets/javascripts/rails-ujs.js). +// Rails main no longer ships rails-ujs, and application.js still requires it. +// Remove once the app no longer depends on rails-ujs. + +/* +Unobtrusive JavaScript +https://github.com/rails/rails/blob/main/actionview/app/javascript +Released under the MIT license + */ +(function(global, factory) { + typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, + global.Rails = factory()); +})(this, (function() { + "use strict"; + const linkClickSelector = "a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]"; + const buttonClickSelector = { + selector: "button[data-remote]:not([form]), button[data-confirm]:not([form])", + exclude: "form button" + }; + const inputChangeSelector = "select[data-remote], input[data-remote], textarea[data-remote]"; + const formSubmitSelector = "form:not([data-turbo=true])"; + const formInputClickSelector = "form:not([data-turbo=true]) input[type=submit], form:not([data-turbo=true]) input[type=image], form:not([data-turbo=true]) button[type=submit], form:not([data-turbo=true]) button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])"; + const formDisableSelector = "input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled"; + const formEnableSelector = "input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled"; + const fileInputSelector = "input[name][type=file]:not([disabled])"; + const linkDisableSelector = "a[data-disable-with], a[data-disable]"; + const buttonDisableSelector = "button[data-remote][data-disable-with], button[data-remote][data-disable]"; + let nonce = null; + const loadCSPNonce = () => { + const metaTag = document.querySelector("meta[name=csp-nonce]"); + return nonce = metaTag && metaTag.content; + }; + const cspNonce = () => nonce || loadCSPNonce(); + const m = Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector; + const matches = function(element, selector) { + if (selector.exclude) { + return m.call(element, selector.selector) && !m.call(element, selector.exclude); + } else { + return m.call(element, selector); + } + }; + const EXPANDO = "_ujsData"; + const getData = (element, key) => element[EXPANDO] ? element[EXPANDO][key] : undefined; + const setData = function(element, key, value) { + if (!element[EXPANDO]) { + element[EXPANDO] = {}; + } + return element[EXPANDO][key] = value; + }; + const $ = selector => Array.prototype.slice.call(document.querySelectorAll(selector)); + const isContentEditable = function(element) { + var isEditable = false; + do { + if (element.isContentEditable) { + isEditable = true; + break; + } + element = element.parentElement; + } while (element); + return isEditable; + }; + const csrfToken = () => { + const meta = document.querySelector("meta[name=csrf-token]"); + return meta && meta.content; + }; + const csrfParam = () => { + const meta = document.querySelector("meta[name=csrf-param]"); + return meta && meta.content; + }; + const CSRFProtection = xhr => { + const token = csrfToken(); + if (token) { + return xhr.setRequestHeader("X-CSRF-Token", token); + } + }; + const refreshCSRFTokens = () => { + const token = csrfToken(); + const param = csrfParam(); + if (token && param) { + return $('form input[name="' + param + '"]').forEach((input => input.value = token)); + } + }; + const AcceptHeaders = { + "*": "*/*", + text: "text/plain", + html: "text/html", + xml: "application/xml, text/xml", + json: "application/json, text/javascript", + script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" + }; + const ajax = options => { + options = prepareOptions(options); + var xhr = createXHR(options, (function() { + const response = processResponse(xhr.response != null ? xhr.response : xhr.responseText, xhr.getResponseHeader("Content-Type")); + if (Math.floor(xhr.status / 100) === 2) { + if (typeof options.success === "function") { + options.success(response, xhr.statusText, xhr); + } + } else { + if (typeof options.error === "function") { + options.error(response, xhr.statusText, xhr); + } + } + return typeof options.complete === "function" ? options.complete(xhr, xhr.statusText) : undefined; + })); + if (options.beforeSend && !options.beforeSend(xhr, options)) { + return false; + } + if (xhr.readyState === XMLHttpRequest.OPENED) { + return xhr.send(options.data); + } + }; + var prepareOptions = function(options) { + options.url = options.url || location.href; + options.type = options.type.toUpperCase(); + if (options.type === "GET" && options.data) { + if (options.url.indexOf("?") < 0) { + options.url += "?" + options.data; + } else { + options.url += "&" + options.data; + } + } + if (!(options.dataType in AcceptHeaders)) { + options.dataType = "*"; + } + options.accept = AcceptHeaders[options.dataType]; + if (options.dataType !== "*") { + options.accept += ", */*; q=0.01"; + } + return options; + }; + var createXHR = function(options, done) { + const xhr = new XMLHttpRequest; + xhr.open(options.type, options.url, true); + xhr.setRequestHeader("Accept", options.accept); + if (typeof options.data === "string") { + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); + } + if (!options.crossDomain) { + xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); + CSRFProtection(xhr); + } + xhr.withCredentials = !!options.withCredentials; + xhr.onreadystatechange = function() { + if (xhr.readyState === XMLHttpRequest.DONE) { + return done(xhr); + } + }; + return xhr; + }; + var processResponse = function(response, type) { + if (typeof response === "string" && typeof type === "string") { + if (type.match(/\bjson\b/)) { + try { + response = JSON.parse(response); + } catch (error) {} + } else if (type.match(/\b(?:java|ecma)script\b/)) { + const script = document.createElement("script"); + script.setAttribute("nonce", cspNonce()); + script.text = response; + document.head.appendChild(script).parentNode.removeChild(script); + } else if (type.match(/\b(xml|html|svg)\b/)) { + const parser = new DOMParser; + type = type.replace(/;.+/, ""); + try { + response = parser.parseFromString(response, type); + } catch (error1) {} + } + } + return response; + }; + const href = element => element.href; + const isCrossDomain = function(url) { + const originAnchor = document.createElement("a"); + originAnchor.href = location.href; + const urlAnchor = document.createElement("a"); + try { + urlAnchor.href = url; + return !((!urlAnchor.protocol || urlAnchor.protocol === ":") && !urlAnchor.host || originAnchor.protocol + "//" + originAnchor.host === urlAnchor.protocol + "//" + urlAnchor.host); + } catch (e) { + return true; + } + }; + let preventDefault; + let {CustomEvent: CustomEvent} = window; + if (typeof CustomEvent !== "function") { + CustomEvent = function(event, params) { + const evt = document.createEvent("CustomEvent"); + evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); + return evt; + }; + CustomEvent.prototype = window.Event.prototype; + ({preventDefault: preventDefault} = CustomEvent.prototype); + CustomEvent.prototype.preventDefault = function() { + const result = preventDefault.call(this); + if (this.cancelable && !this.defaultPrevented) { + Object.defineProperty(this, "defaultPrevented", { + get() { + return true; + } + }); + } + return result; + }; + } + const fire = (obj, name, data) => { + const event = new CustomEvent(name, { + bubbles: true, + cancelable: true, + detail: data + }); + obj.dispatchEvent(event); + return !event.defaultPrevented; + }; + const stopEverything = e => { + fire(e.target, "ujs:everythingStopped"); + e.preventDefault(); + e.stopPropagation(); + e.stopImmediatePropagation(); + }; + const delegate = (element, selector, eventType, handler) => element.addEventListener(eventType, (function(e) { + let {target: target} = e; + while (!!(target instanceof Element) && !matches(target, selector)) { + target = target.parentNode; + } + if (target instanceof Element && handler.call(target, e) === false) { + e.preventDefault(); + e.stopPropagation(); + } + })); + const toArray = e => Array.prototype.slice.call(e); + const serializeElement = (element, additionalParam) => { + let inputs = [ element ]; + if (matches(element, "form")) { + inputs = toArray(element.elements); + } + const params = []; + inputs.forEach((function(input) { + if (!input.name || input.disabled) { + return; + } + if (matches(input, "fieldset[disabled] *")) { + return; + } + if (matches(input, "select")) { + toArray(input.options).forEach((function(option) { + if (option.selected) { + params.push({ + name: input.name, + value: option.value + }); + } + })); + } else if (input.checked || [ "radio", "checkbox", "submit" ].indexOf(input.type) === -1) { + params.push({ + name: input.name, + value: input.value + }); + } + })); + if (additionalParam) { + params.push(additionalParam); + } + return params.map((function(param) { + if (param.name) { + return `${encodeURIComponent(param.name)}=${encodeURIComponent(param.value)}`; + } else { + return param; + } + })).join("&"); + }; + const formElements = (form, selector) => { + if (matches(form, "form")) { + return toArray(form.elements).filter((el => matches(el, selector))); + } else { + return toArray(form.querySelectorAll(selector)); + } + }; + const handleConfirmWithRails = rails => function(e) { + if (!allowAction(this, rails)) { + stopEverything(e); + } + }; + const confirm = (message, element) => window.confirm(message); + var allowAction = function(element, rails) { + let callback; + const message = element.getAttribute("data-confirm"); + if (!message) { + return true; + } + let answer = false; + if (fire(element, "confirm")) { + try { + answer = rails.confirm(message, element); + } catch (error) {} + callback = fire(element, "confirm:complete", [ answer ]); + } + return answer && callback; + }; + const handleDisabledElement = function(e) { + const element = this; + if (element.disabled) { + stopEverything(e); + } + }; + const enableElement = e => { + let element; + if (e instanceof Event) { + if (isXhrRedirect(e)) { + return; + } + element = e.target; + } else { + element = e; + } + if (isContentEditable(element)) { + return; + } + if (matches(element, linkDisableSelector)) { + return enableLinkElement(element); + } else if (matches(element, buttonDisableSelector) || matches(element, formEnableSelector)) { + return enableFormElement(element); + } else if (matches(element, formSubmitSelector)) { + return enableFormElements(element); + } + }; + const disableElement = e => { + const element = e instanceof Event ? e.target : e; + if (isContentEditable(element)) { + return; + } + if (matches(element, linkDisableSelector)) { + return disableLinkElement(element); + } else if (matches(element, buttonDisableSelector) || matches(element, formDisableSelector)) { + return disableFormElement(element); + } else if (matches(element, formSubmitSelector)) { + return disableFormElements(element); + } + }; + var disableLinkElement = function(element) { + if (getData(element, "ujs:disabled")) { + return; + } + const replacement = element.getAttribute("data-disable-with"); + if (replacement != null) { + setData(element, "ujs:enable-with", element.innerHTML); + element.innerHTML = replacement; + } + element.addEventListener("click", stopEverything); + return setData(element, "ujs:disabled", true); + }; + var enableLinkElement = function(element) { + const originalText = getData(element, "ujs:enable-with"); + if (originalText != null) { + element.innerHTML = originalText; + setData(element, "ujs:enable-with", null); + } + element.removeEventListener("click", stopEverything); + return setData(element, "ujs:disabled", null); + }; + var disableFormElements = form => formElements(form, formDisableSelector).forEach(disableFormElement); + var disableFormElement = function(element) { + if (getData(element, "ujs:disabled")) { + return; + } + const replacement = element.getAttribute("data-disable-with"); + if (replacement != null) { + if (matches(element, "button")) { + setData(element, "ujs:enable-with", element.innerHTML); + element.innerHTML = replacement; + } else { + setData(element, "ujs:enable-with", element.value); + element.value = replacement; + } + } + element.disabled = true; + return setData(element, "ujs:disabled", true); + }; + var enableFormElements = form => formElements(form, formEnableSelector).forEach((element => enableFormElement(element))); + var enableFormElement = function(element) { + const originalText = getData(element, "ujs:enable-with"); + if (originalText != null) { + if (matches(element, "button")) { + element.innerHTML = originalText; + } else { + element.value = originalText; + } + setData(element, "ujs:enable-with", null); + } + element.disabled = false; + return setData(element, "ujs:disabled", null); + }; + var isXhrRedirect = function(event) { + const xhr = event.detail ? event.detail[0] : undefined; + return xhr && xhr.getResponseHeader("X-Xhr-Redirect"); + }; + const handleMethodWithRails = rails => function(e) { + const link = this; + const method = link.getAttribute("data-method"); + if (!method) { + return; + } + if (isContentEditable(this)) { + return; + } + const href = rails.href(link); + const csrfToken$1 = csrfToken(); + const csrfParam$1 = csrfParam(); + const form = document.createElement("form"); + let formContent = ``; + if (csrfParam$1 && csrfToken$1 && !isCrossDomain(href)) { + formContent += ``; + } + formContent += ''; + form.method = "post"; + form.action = href; + form.target = link.target; + form.innerHTML = formContent; + form.style.display = "none"; + document.body.appendChild(form); + form.querySelector('[type="submit"]').click(); + stopEverything(e); + }; + const isRemote = function(element) { + const value = element.getAttribute("data-remote"); + return value != null && value !== "false"; + }; + const handleRemoteWithRails = rails => function(e) { + let data, method, url; + const element = this; + if (!isRemote(element)) { + return true; + } + if (!fire(element, "ajax:before")) { + fire(element, "ajax:stopped"); + return false; + } + if (isContentEditable(element)) { + fire(element, "ajax:stopped"); + return false; + } + const withCredentials = element.getAttribute("data-with-credentials"); + const dataType = element.getAttribute("data-type") || "script"; + if (matches(element, formSubmitSelector)) { + const button = getData(element, "ujs:submit-button"); + method = getData(element, "ujs:submit-button-formmethod") || element.getAttribute("method") || "get"; + url = getData(element, "ujs:submit-button-formaction") || element.getAttribute("action") || location.href; + if (method.toUpperCase() === "GET") { + url = url.replace(/\?.*$/, ""); + } + if (element.enctype === "multipart/form-data") { + data = new FormData(element); + if (button != null) { + data.append(button.name, button.value); + } + } else { + data = serializeElement(element, button); + } + setData(element, "ujs:submit-button", null); + setData(element, "ujs:submit-button-formmethod", null); + setData(element, "ujs:submit-button-formaction", null); + } else if (matches(element, buttonClickSelector) || matches(element, inputChangeSelector)) { + method = element.getAttribute("data-method"); + url = element.getAttribute("data-url"); + data = serializeElement(element, element.getAttribute("data-params")); + } else { + method = element.getAttribute("data-method"); + url = rails.href(element); + data = element.getAttribute("data-params"); + } + ajax({ + type: method || "GET", + url: url, + data: data, + dataType: dataType, + beforeSend(xhr, options) { + if (fire(element, "ajax:beforeSend", [ xhr, options ])) { + return fire(element, "ajax:send", [ xhr ]); + } else { + fire(element, "ajax:stopped"); + return false; + } + }, + success(...args) { + return fire(element, "ajax:success", args); + }, + error(...args) { + return fire(element, "ajax:error", args); + }, + complete(...args) { + return fire(element, "ajax:complete", args); + }, + crossDomain: isCrossDomain(url), + withCredentials: withCredentials != null && withCredentials !== "false" + }); + stopEverything(e); + }; + const formSubmitButtonClick = function(e) { + const button = this; + const {form: form} = button; + if (!form) { + return; + } + if (button.name) { + setData(form, "ujs:submit-button", { + name: button.name, + value: button.value + }); + } + setData(form, "ujs:formnovalidate-button", button.formNoValidate); + setData(form, "ujs:submit-button-formaction", button.getAttribute("formaction")); + return setData(form, "ujs:submit-button-formmethod", button.getAttribute("formmethod")); + }; + const preventInsignificantClick = function(e) { + const link = this; + const method = (link.getAttribute("data-method") || "GET").toUpperCase(); + const data = link.getAttribute("data-params"); + const metaClick = e.metaKey || e.ctrlKey; + const insignificantMetaClick = metaClick && method === "GET" && !data; + const nonPrimaryMouseClick = e.button != null && e.button !== 0; + if (nonPrimaryMouseClick || insignificantMetaClick) { + e.stopImmediatePropagation(); + } + }; + const Rails = { + $: $, + ajax: ajax, + buttonClickSelector: buttonClickSelector, + buttonDisableSelector: buttonDisableSelector, + confirm: confirm, + cspNonce: cspNonce, + csrfToken: csrfToken, + csrfParam: csrfParam, + CSRFProtection: CSRFProtection, + delegate: delegate, + disableElement: disableElement, + enableElement: enableElement, + fileInputSelector: fileInputSelector, + fire: fire, + formElements: formElements, + formEnableSelector: formEnableSelector, + formDisableSelector: formDisableSelector, + formInputClickSelector: formInputClickSelector, + formSubmitButtonClick: formSubmitButtonClick, + formSubmitSelector: formSubmitSelector, + getData: getData, + handleDisabledElement: handleDisabledElement, + href: href, + inputChangeSelector: inputChangeSelector, + isCrossDomain: isCrossDomain, + linkClickSelector: linkClickSelector, + linkDisableSelector: linkDisableSelector, + loadCSPNonce: loadCSPNonce, + matches: matches, + preventInsignificantClick: preventInsignificantClick, + refreshCSRFTokens: refreshCSRFTokens, + serializeElement: serializeElement, + setData: setData, + stopEverything: stopEverything + }; + const handleConfirm = handleConfirmWithRails(Rails); + Rails.handleConfirm = handleConfirm; + const handleMethod = handleMethodWithRails(Rails); + Rails.handleMethod = handleMethod; + const handleRemote = handleRemoteWithRails(Rails); + Rails.handleRemote = handleRemote; + const start = function() { + if (window._rails_loaded) { + throw new Error("rails-ujs has already been loaded!"); + } + window.addEventListener("pageshow", (function() { + $(formEnableSelector).forEach((function(el) { + if (getData(el, "ujs:disabled")) { + enableElement(el); + } + })); + $(linkDisableSelector).forEach((function(el) { + if (getData(el, "ujs:disabled")) { + enableElement(el); + } + })); + })); + delegate(document, linkDisableSelector, "ajax:complete", enableElement); + delegate(document, linkDisableSelector, "ajax:stopped", enableElement); + delegate(document, buttonDisableSelector, "ajax:complete", enableElement); + delegate(document, buttonDisableSelector, "ajax:stopped", enableElement); + delegate(document, linkClickSelector, "click", preventInsignificantClick); + delegate(document, linkClickSelector, "click", handleDisabledElement); + delegate(document, linkClickSelector, "click", handleConfirm); + delegate(document, linkClickSelector, "click", disableElement); + delegate(document, linkClickSelector, "click", handleRemote); + delegate(document, linkClickSelector, "click", handleMethod); + delegate(document, buttonClickSelector, "click", preventInsignificantClick); + delegate(document, buttonClickSelector, "click", handleDisabledElement); + delegate(document, buttonClickSelector, "click", handleConfirm); + delegate(document, buttonClickSelector, "click", disableElement); + delegate(document, buttonClickSelector, "click", handleRemote); + delegate(document, inputChangeSelector, "change", handleDisabledElement); + delegate(document, inputChangeSelector, "change", handleConfirm); + delegate(document, inputChangeSelector, "change", handleRemote); + delegate(document, formSubmitSelector, "submit", handleDisabledElement); + delegate(document, formSubmitSelector, "submit", handleConfirm); + delegate(document, formSubmitSelector, "submit", handleRemote); + delegate(document, formSubmitSelector, "submit", (e => setTimeout((() => disableElement(e)), 13))); + delegate(document, formSubmitSelector, "ajax:send", disableElement); + delegate(document, formSubmitSelector, "ajax:complete", enableElement); + delegate(document, formInputClickSelector, "click", preventInsignificantClick); + delegate(document, formInputClickSelector, "click", handleDisabledElement); + delegate(document, formInputClickSelector, "click", handleConfirm); + delegate(document, formInputClickSelector, "click", formSubmitButtonClick); + document.addEventListener("DOMContentLoaded", refreshCSRFTokens); + document.addEventListener("DOMContentLoaded", loadCSPNonce); + return window._rails_loaded = true; + }; + Rails.start = start; + if (typeof jQuery !== "undefined" && jQuery && jQuery.ajax) { + if (jQuery.rails) { + throw new Error("If you load both jquery_ujs and rails-ujs, use rails-ujs only."); + } + jQuery.rails = Rails; + jQuery.ajaxPrefilter((function(options, originalOptions, xhr) { + if (!options.crossDomain) { + return CSRFProtection(xhr); + } + })); + } + if (typeof exports !== "object" && typeof module === "undefined") { + window.Rails = Rails; + if (fire(document, "rails:attachBindings")) { + start(); + } + } + return Rails; +}));