toastify 1.0.1 → 1.2.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: fb51a11fd1f4a71bc4eec59d1ce63e41617ba18a7ad8bd10f9359ff182b20dd4
4
- data.tar.gz: 4ffdc6148a49de0d4e96ce54d5c7996da717bbf2d69789f1fd7076b77c9bf0e8
3
+ metadata.gz: a0f7f533d69bf852bede962509bd4f893854d59381465e674a84dcc2af573441
4
+ data.tar.gz: 35ead30f183fc0eb86727b710469de755e6bbca6892a00230076a14f3741258e
5
5
  SHA512:
6
- metadata.gz: 98267e7a27bd414779e4e6f0526dd80aeece3e85997e6d735cdcdccf91d68fc67130ff9989cdcfe0fc3d9839acf4bea94a443f66eb5324ce55ae8e054f1239bd
7
- data.tar.gz: 3b6e90230c0c3b45c716c2ec17f50d813207228abeb69a0a60d03e475adbac620a2e600f4311cc5f6aa53294dcaa281e2ba54cf3867e71bdc6eee6e68f20bfce
6
+ metadata.gz: 7f5888be3af3cfaf5dbce6d665c392174c3601cb2c14a8210f1ec328b02412aa975deda65e99298cb87ce89dc111223531f506681fa024aabce271ca370b5b53
7
+ data.tar.gz: 55b26d76af3a72a432f726eba31712eea1239acfc2c7cd06e67703692ddfcbd74168da33e6bea43643903a3d2c38314231b8b1924c0be4d66007e2cffe71e6f2
data/README.md CHANGED
@@ -10,11 +10,7 @@ It can also be used directly in JavaScript (e.g., `Toastify.success("Saved!")`).
10
10
 
11
11
  ### Example Images
12
12
 
13
- <img width="346" height="85" alt="Light Theme Example" src="https://github.com/user-attachments/assets/b7a3123a-89a3-4f49-97ff-aa25f4b870d0" />
14
-
15
- <img width="338" height="87" alt="Dark Theme Example" src="https://github.com/user-attachments/assets/65671ac6-91d7-471f-9c03-6458023f3ae2" />
16
-
17
- <img width="339" height="83" alt="Colored Theme Example" src="https://github.com/user-attachments/assets/1c99ffdb-dc3c-4fef-aa16-b7eff08e0cde" />
13
+ <img width="340" height="222" alt="Theme Examples" src="https://github.com/user-attachments/assets/ed0350ef-295d-4ba6-ab51-94a9e071eac4" />
18
14
 
19
15
  ## Installation
20
16
 
@@ -55,11 +55,13 @@ module Toastify
55
55
  "error" => "error",
56
56
  "info" => "info",
57
57
  "warning" => "warning",
58
+ "default" => "default",
58
59
  }
59
60
 
60
61
  script_lines = []
61
62
  flash.each do |flash_type, message|
62
63
  next if flash_type.to_s.start_with?("toast_")
64
+ next unless Toastify::FLASH_KEYS.include?(flash_type.to_s)
63
65
 
64
66
  type = type_map.fetch(flash_type.to_s, "default")
65
67
  position = flash[:toast_position] || default_position
@@ -75,8 +77,11 @@ module Toastify
75
77
  script_lines << "window.Toastify && window.Toastify.show('#{safe_message}', { type: '#{j(type.to_s)}', position: '#{j(position.to_s)}', autoClose: #{auto_close.to_i}, theme: '#{j(theme.to_s)}', transition: '#{j(transition.to_s)}', closeButton: #{!!close_button}, pauseOnHover: #{!!pause_on_hover}, draggable: #{!!draggable} });"
76
78
  end
77
79
 
78
- # Discard so it doesn't show up again
79
- flash.keys.reject { |type| type.to_s.start_with?("toast_") }.each do |type|
80
+ # Discard consumed toast flashes only; leave other keys (e.g. :alert) intact
81
+ flash.keys.each do |type|
82
+ next if type.to_s.start_with?("toast_")
83
+ next unless Toastify::FLASH_KEYS.include?(type.to_s)
84
+
80
85
  flash.discard(type)
81
86
  end
82
87
 
@@ -3,26 +3,39 @@ module Toastify
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- after_action :append_toastify_to_stream
6
+ after_action :append_toastify_to_response
7
7
  end
8
8
 
9
9
  private
10
10
 
11
- def append_toastify_to_stream
12
- return unless request.format.turbo_stream?
11
+ def append_toastify_to_response
12
+ return unless request.format.turbo_stream? || turbo_frame_request?
13
13
 
14
- toast_flashes = flash.reject { |type, _| type.to_s.start_with?("toast_") }
14
+ toast_flashes = flash.reject do |type, _|
15
+ type.to_s.start_with?("toast_") || !Toastify::FLASH_KEYS.include?(type.to_s)
16
+ end
15
17
  return unless toast_flashes.any?
16
18
 
17
19
  script_content = helpers.toastify_script_tag
18
20
  return if script_content.blank?
19
21
 
20
- stream_tag = turbo_stream.append("flash-outlet", script_content)
22
+ if request.format.turbo_stream?
23
+ payload = turbo_stream.append("flash-outlet", script_content).to_s
21
24
 
22
- if response.body.is_a?(String)
23
- response.body += stream_tag.to_s
25
+ if response.body.is_a?(String)
26
+ response.body += payload
27
+ else
28
+ response.body = response.body.to_s + payload
29
+ end
24
30
  else
25
- response.body = response.body.to_s + stream_tag.to_s
31
+ body = response.body.to_s
32
+ frame_closing_tag = "</turbo-frame>"
33
+
34
+ if body.include?(frame_closing_tag)
35
+ response.body = body.sub(frame_closing_tag, "#{script_content}#{frame_closing_tag}")
36
+ else
37
+ response.body = body + script_content.to_s
38
+ end
26
39
  end
27
40
  end
28
41
  end
@@ -1,3 +1,3 @@
1
1
  module Toastify
2
- VERSION = "1.0.1"
2
+ VERSION = "1.2.1"
3
3
  end
data/lib/toastify.rb CHANGED
@@ -4,4 +4,5 @@ require "toastify/application_helper"
4
4
  require "toastify/controller"
5
5
 
6
6
  module Toastify
7
+ FLASH_KEYS = %w[success error warning alert info notice default].freeze
7
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toastify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - vasanthakumar-a
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-21 00:00:00.000000000 Z
11
+ date: 2026-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails