ultimate_turbo_modal 2.0.4 → 2.1.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.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/TM_COMMANDS_GUIDE.md +0 -0
  3. data/.claude/commands/tm/add-dependency/add-dependency.md +0 -0
  4. data/.claude/commands/tm/add-subtask/add-subtask.md +0 -0
  5. data/.claude/commands/tm/add-subtask/convert-task-to-subtask.md +0 -0
  6. data/.claude/commands/tm/add-task/add-task.md +0 -0
  7. data/.claude/commands/tm/analyze-complexity/analyze-complexity.md +0 -0
  8. data/.claude/commands/tm/clear-subtasks/clear-all-subtasks.md +0 -0
  9. data/.claude/commands/tm/clear-subtasks/clear-subtasks.md +0 -0
  10. data/.claude/commands/tm/complexity-report/complexity-report.md +0 -0
  11. data/.claude/commands/tm/expand/expand-all-tasks.md +0 -0
  12. data/.claude/commands/tm/expand/expand-task.md +0 -0
  13. data/.claude/commands/tm/fix-dependencies/fix-dependencies.md +0 -0
  14. data/.claude/commands/tm/generate/generate-tasks.md +0 -0
  15. data/.claude/commands/tm/help.md +0 -0
  16. data/.claude/commands/tm/init/init-project-quick.md +0 -0
  17. data/.claude/commands/tm/init/init-project.md +0 -0
  18. data/.claude/commands/tm/learn.md +0 -0
  19. data/.claude/commands/tm/list/list-tasks-by-status.md +0 -0
  20. data/.claude/commands/tm/list/list-tasks-with-subtasks.md +0 -0
  21. data/.claude/commands/tm/list/list-tasks.md +0 -0
  22. data/.claude/commands/tm/models/setup-models.md +0 -0
  23. data/.claude/commands/tm/models/view-models.md +0 -0
  24. data/.claude/commands/tm/next/next-task.md +0 -0
  25. data/.claude/commands/tm/parse-prd/parse-prd-with-research.md +0 -0
  26. data/.claude/commands/tm/parse-prd/parse-prd.md +0 -0
  27. data/.claude/commands/tm/remove-dependency/remove-dependency.md +0 -0
  28. data/.claude/commands/tm/remove-subtask/remove-subtask.md +0 -0
  29. data/.claude/commands/tm/remove-task/remove-task.md +0 -0
  30. data/.claude/commands/tm/set-status/to-cancelled.md +0 -0
  31. data/.claude/commands/tm/set-status/to-deferred.md +0 -0
  32. data/.claude/commands/tm/set-status/to-done.md +0 -0
  33. data/.claude/commands/tm/set-status/to-in-progress.md +0 -0
  34. data/.claude/commands/tm/set-status/to-pending.md +0 -0
  35. data/.claude/commands/tm/set-status/to-review.md +0 -0
  36. data/.claude/commands/tm/setup/install-taskmaster.md +0 -0
  37. data/.claude/commands/tm/setup/quick-install-taskmaster.md +0 -0
  38. data/.claude/commands/tm/show/show-task.md +0 -0
  39. data/.claude/commands/tm/status/project-status.md +0 -0
  40. data/.claude/commands/tm/sync-readme/sync-readme.md +0 -0
  41. data/.claude/commands/tm/tm-main.md +0 -0
  42. data/.claude/commands/tm/update/update-single-task.md +0 -0
  43. data/.claude/commands/tm/update/update-task.md +0 -0
  44. data/.claude/commands/tm/update/update-tasks-from-id.md +0 -0
  45. data/.claude/commands/tm/utils/analyze-project.md +0 -0
  46. data/.claude/commands/tm/validate-dependencies/validate-dependencies.md +0 -0
  47. data/.claude/commands/tm/workflows/auto-implement-tasks.md +0 -0
  48. data/.claude/commands/tm/workflows/command-pipeline.md +0 -0
  49. data/.claude/commands/tm/workflows/smart-workflow.md +0 -0
  50. data/.cursor/rules/taskmaster/dev_workflow.mdc +424 -0
  51. data/.cursor/rules/taskmaster/taskmaster.mdc +558 -0
  52. data/.env.example +0 -0
  53. data/.taskmaster/CLAUDE.md +0 -0
  54. data/.taskmaster/config.json +37 -0
  55. data/.taskmaster/templates/example_prd.txt +0 -0
  56. data/.tool-versions +1 -1
  57. data/CHANGELOG.md +8 -0
  58. data/CLAUDE.md +82 -0
  59. data/Gemfile +1 -1
  60. data/Gemfile.lock +51 -125
  61. data/README.md +62 -98
  62. data/UPGRADING.md +55 -0
  63. data/VERSION +1 -1
  64. data/demo-app/.gitattributes +7 -0
  65. data/demo-app/.gitignore +34 -0
  66. data/demo-app/.ruby-version +1 -0
  67. data/demo-app/.tool-versions +2 -0
  68. data/demo-app/Gemfile +41 -0
  69. data/demo-app/Gemfile.lock +248 -0
  70. data/demo-app/Procfile.dev +3 -0
  71. data/demo-app/README.md +15 -0
  72. data/demo-app/Rakefile +6 -0
  73. data/demo-app/app/assets/builds/.keep +0 -0
  74. data/demo-app/app/assets/images/.keep +0 -0
  75. data/demo-app/app/assets/stylesheets/application.css +42 -0
  76. data/demo-app/app/controllers/application_controller.rb +10 -0
  77. data/demo-app/app/controllers/concerns/.keep +0 -0
  78. data/demo-app/app/controllers/concerns/set_flavor.rb +10 -0
  79. data/demo-app/app/controllers/hide_from_backends_controller.rb +34 -0
  80. data/demo-app/app/controllers/modal_controller.rb +11 -0
  81. data/demo-app/app/controllers/posts_controller.rb +69 -0
  82. data/demo-app/app/controllers/welcome_controller.rb +2 -0
  83. data/demo-app/app/helpers/application_helper.rb +9 -0
  84. data/demo-app/app/javascript/application.js +4 -0
  85. data/demo-app/app/javascript/controllers/application.js +13 -0
  86. data/demo-app/app/javascript/controllers/dark_mode_controller.js +28 -0
  87. data/demo-app/app/javascript/controllers/flash_controller.js +9 -0
  88. data/demo-app/app/javascript/controllers/hello_controller.js +7 -0
  89. data/demo-app/app/javascript/controllers/index.js +15 -0
  90. data/demo-app/app/models/application_record.rb +3 -0
  91. data/demo-app/app/models/concerns/.keep +0 -0
  92. data/demo-app/app/models/post.rb +4 -0
  93. data/demo-app/app/views/hide_from_backends/_notice.html.erb +10 -0
  94. data/demo-app/app/views/hide_from_backends/create.turbo_stream.erb +2 -0
  95. data/demo-app/app/views/hide_from_backends/new.html.erb +30 -0
  96. data/demo-app/app/views/layouts/application.html.erb +40 -0
  97. data/demo-app/app/views/modal/index.html.erb +45 -0
  98. data/demo-app/app/views/modal/show.html.erb +39 -0
  99. data/demo-app/app/views/posts/_form.html.erb +36 -0
  100. data/demo-app/app/views/posts/_post.html.erb +9 -0
  101. data/demo-app/app/views/posts/edit.html.erb +9 -0
  102. data/demo-app/app/views/posts/index.html.erb +14 -0
  103. data/demo-app/app/views/posts/new.html.erb +3 -0
  104. data/demo-app/app/views/posts/show.html.erb +21 -0
  105. data/demo-app/app/views/shared/_flash.html.erb +13 -0
  106. data/demo-app/app/views/welcome/index.html.erb +19 -0
  107. data/demo-app/bin/bundle +109 -0
  108. data/demo-app/bin/dev +7 -0
  109. data/demo-app/bin/rails +4 -0
  110. data/demo-app/bin/rake +4 -0
  111. data/demo-app/bin/setup +34 -0
  112. data/demo-app/config/application.rb +43 -0
  113. data/demo-app/config/boot.rb +3 -0
  114. data/demo-app/config/credentials.yml.enc +1 -0
  115. data/demo-app/config/database.yml +25 -0
  116. data/demo-app/config/environment.rb +14 -0
  117. data/demo-app/config/environments/development.rb +51 -0
  118. data/demo-app/config/environments/production.rb +67 -0
  119. data/demo-app/config/environments/test.rb +42 -0
  120. data/demo-app/config/initializers/assets.rb +7 -0
  121. data/demo-app/config/initializers/content_security_policy.rb +25 -0
  122. data/demo-app/config/initializers/filter_parameter_logging.rb +8 -0
  123. data/demo-app/config/initializers/inflections.rb +14 -0
  124. data/demo-app/config/initializers/new_framework_defaults_8_0.rb +30 -0
  125. data/demo-app/config/initializers/permissions_policy.rb +11 -0
  126. data/demo-app/config/initializers/ultimate_turbo_modal.rb +12 -0
  127. data/demo-app/config/initializers/ultimate_turbo_modal_tailwind.rb +21 -0
  128. data/demo-app/config/initializers/ultimate_turbo_modal_vanilla.rb +21 -0
  129. data/demo-app/config/locales/en.yml +33 -0
  130. data/demo-app/config/puma.rb +41 -0
  131. data/demo-app/config/routes.rb +9 -0
  132. data/demo-app/config.ru +6 -0
  133. data/demo-app/db/migrate/20230331002502_create_posts.rb +10 -0
  134. data/demo-app/db/migrate/20231031012703_add_post.rb +9 -0
  135. data/demo-app/db/migrate/20231128141054_add_publish_on_to_posts.rb +5 -0
  136. data/demo-app/db/schema.rb +22 -0
  137. data/demo-app/lib/assets/.keep +0 -0
  138. data/demo-app/lib/tasks/.keep +0 -0
  139. data/demo-app/log/.keep +0 -0
  140. data/demo-app/package.json +28 -0
  141. data/demo-app/postcss.config.js +7 -0
  142. data/demo-app/public/400.html +114 -0
  143. data/demo-app/public/404.html +114 -0
  144. data/demo-app/public/406-unsupported-browser.html +114 -0
  145. data/demo-app/public/422.html +114 -0
  146. data/demo-app/public/500.html +114 -0
  147. data/demo-app/public/apple-touch-icon-precomposed.png +0 -0
  148. data/demo-app/public/apple-touch-icon.png +0 -0
  149. data/demo-app/public/favicon.ico +0 -0
  150. data/demo-app/public/icon.png +0 -0
  151. data/demo-app/public/icon.svg +3 -0
  152. data/demo-app/public/img/bootstrap-logo-shadow.png +0 -0
  153. data/demo-app/public/img/unicat.jpg +0 -0
  154. data/demo-app/public/img/vanilla.png +0 -0
  155. data/demo-app/public/robots.txt +1 -0
  156. data/demo-app/tmp/.keep +0 -0
  157. data/demo-app/tmp/pids/.keep +0 -0
  158. data/demo-app/vendor/.keep +0 -0
  159. data/demo-app/yarn.lock +1022 -0
  160. data/javascript/modal_controller.js +63 -2
  161. data/javascript/package.json +4 -2
  162. data/javascript/yarn.lock +12 -0
  163. data/lib/ultimate_turbo_modal/configuration.rb +1 -0
  164. metadata +184 -4
data/CLAUDE.md ADDED
@@ -0,0 +1,82 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Overview
6
+
7
+ Ultimate Turbo Modal (UTMR) is a full-featured modal implementation for Rails applications using Turbo, Stimulus, and Hotwire. It consists of both a Ruby gem and an npm package that work together.
8
+
9
+ ## Project Structure
10
+
11
+ - **Ruby Gem**: Main gem code in `/lib/ultimate_turbo_modal/`
12
+ - `base.rb`: Core modal component (Phlex-based)
13
+ - `configuration.rb`: Global configuration management
14
+ - `helpers/`: Rails helpers for views and controllers
15
+ - Generators in `/lib/generators/` for installation
16
+
17
+ - **JavaScript Package**: Located in `/javascript/`
18
+ - `modal_controller.js`: Stimulus controller for modal behavior
19
+ - `index.js`: Main entry point
20
+ - Distributed files built to `/javascript/dist/`
21
+
22
+ ## Common Development Commands
23
+
24
+ ### JavaScript Development (run from `/javascript/` directory)
25
+ ```bash
26
+ # Install dependencies
27
+ yarn install
28
+
29
+ # Build the JavaScript package
30
+ yarn build
31
+
32
+ # Release to npm (updates version and publishes)
33
+ yarn release
34
+ ```
35
+
36
+ ### Ruby Gem Development (run from root)
37
+ ```bash
38
+ # Run tests
39
+ bundle exec rake test
40
+
41
+ # Build gem
42
+ gem build ultimate_turbo_modal.gemspec
43
+
44
+ # Release process (Ruby + JS)
45
+ ./script/build_and_release.sh
46
+ ```
47
+
48
+ ## Architecture & Key Concepts
49
+
50
+ ### Modal Options System
51
+ Options can be set at three levels:
52
+ 1. **Global defaults** via `UltimateTurboModal.configure` in configuration.rb
53
+ 2. **Instance options** passed to the `modal` helper
54
+ 3. **Runtime values** via blocks (for title/footer)
55
+
56
+ Current options: `advance`, `close_button`, `header`, `header_divider`, `padding`, `title`
57
+
58
+ ### Stimulus Controller Values
59
+ The modal controller uses Stimulus values to receive configuration:
60
+ - `advanceUrl`: URL for browser history manipulation
61
+ - `allowedClickOutsideSelector`: CSS selectors that won't dismiss modal when clicked
62
+
63
+ ### Modal Lifecycle
64
+ 1. Link clicked with `data-turbo-frame="modal"`
65
+ 2. Turbo loads content into the modal frame
66
+ 3. Stimulus controller connects and shows modal
67
+ 4. Modal can be dismissed via: ESC key, close button, clicking outside, or programmatically
68
+
69
+ ### Adding New Configuration Options
70
+ When adding a new option:
71
+
72
+ 1. Add to `Configuration` class with getter/setter methods
73
+ 2. Add to `UltimateTurboModal` delegators
74
+ 3. Add to `Base#initialize` parameters with default from configuration
75
+ 4. Pass to JavaScript via data attributes in `Base#div_dialog`
76
+ 5. Add as Stimulus value in `modal_controller.js`
77
+ 6. Update README.md options table
78
+
79
+ ## Testing Approach
80
+ - JavaScript: No test framework currently set up
81
+ - Ruby: Use standard Rails testing practices
82
+ - Manual testing via the demo app: https://github.com/cmer/ultimate_turbo_modal-demo
data/Gemfile CHANGED
@@ -7,5 +7,5 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
 
10
- gem "standard", "~> 1.3"
10
+ gem "standard"
11
11
  gem "standard-rails"
data/Gemfile.lock CHANGED
@@ -1,35 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ultimate_turbo_modal (2.0.4)
4
+ ultimate_turbo_modal (2.1.1)
5
+ actionpack
6
+ activesupport
5
7
  phlex-rails
6
- rails
8
+ railties
7
9
  stimulus-rails
8
10
  turbo-rails
9
11
 
10
12
  GEM
11
13
  remote: https://rubygems.org/
12
14
  specs:
13
- actioncable (8.0.2)
14
- actionpack (= 8.0.2)
15
- activesupport (= 8.0.2)
16
- nio4r (~> 2.0)
17
- websocket-driver (>= 0.6.1)
18
- zeitwerk (~> 2.6)
19
- actionmailbox (8.0.2)
20
- actionpack (= 8.0.2)
21
- activejob (= 8.0.2)
22
- activerecord (= 8.0.2)
23
- activestorage (= 8.0.2)
24
- activesupport (= 8.0.2)
25
- mail (>= 2.8.0)
26
- actionmailer (8.0.2)
27
- actionpack (= 8.0.2)
28
- actionview (= 8.0.2)
29
- activejob (= 8.0.2)
30
- activesupport (= 8.0.2)
31
- mail (>= 2.8.0)
32
- rails-dom-testing (~> 2.2)
33
15
  actionpack (8.0.2)
34
16
  actionview (= 8.0.2)
35
17
  activesupport (= 8.0.2)
@@ -40,34 +22,12 @@ GEM
40
22
  rails-dom-testing (~> 2.2)
41
23
  rails-html-sanitizer (~> 1.6)
42
24
  useragent (~> 0.16)
43
- actiontext (8.0.2)
44
- actionpack (= 8.0.2)
45
- activerecord (= 8.0.2)
46
- activestorage (= 8.0.2)
47
- activesupport (= 8.0.2)
48
- globalid (>= 0.6.0)
49
- nokogiri (>= 1.8.5)
50
25
  actionview (8.0.2)
51
26
  activesupport (= 8.0.2)
52
27
  builder (~> 3.1)
53
28
  erubi (~> 1.11)
54
29
  rails-dom-testing (~> 2.2)
55
30
  rails-html-sanitizer (~> 1.6)
56
- activejob (8.0.2)
57
- activesupport (= 8.0.2)
58
- globalid (>= 0.3.6)
59
- activemodel (8.0.2)
60
- activesupport (= 8.0.2)
61
- activerecord (8.0.2)
62
- activemodel (= 8.0.2)
63
- activesupport (= 8.0.2)
64
- timeout (>= 0.4.0)
65
- activestorage (8.0.2)
66
- actionpack (= 8.0.2)
67
- activejob (= 8.0.2)
68
- activerecord (= 8.0.2)
69
- activesupport (= 8.0.2)
70
- marcel (~> 1.0)
71
31
  activesupport (8.0.2)
72
32
  base64
73
33
  benchmark (>= 0.3)
@@ -82,92 +42,61 @@ GEM
82
42
  tzinfo (~> 2.0, >= 2.0.5)
83
43
  uri (>= 0.13.1)
84
44
  ast (2.4.3)
85
- base64 (0.2.0)
86
- benchmark (0.4.0)
87
- bigdecimal (3.1.9)
45
+ base64 (0.3.0)
46
+ benchmark (0.4.1)
47
+ bigdecimal (3.2.2)
88
48
  builder (3.3.0)
89
49
  concurrent-ruby (1.3.5)
90
- connection_pool (2.5.0)
50
+ connection_pool (2.5.3)
91
51
  crass (1.0.6)
92
52
  date (3.4.1)
93
- drb (2.2.1)
53
+ drb (2.2.3)
54
+ erb (5.0.2)
94
55
  erubi (1.13.1)
95
- globalid (1.2.1)
96
- activesupport (>= 6.1)
97
56
  i18n (1.14.7)
98
57
  concurrent-ruby (~> 1.0)
99
- io-console (0.8.0)
58
+ io-console (0.8.1)
100
59
  irb (1.15.2)
101
60
  pp (>= 0.6.0)
102
61
  rdoc (>= 4.0.0)
103
62
  reline (>= 0.4.2)
104
- json (2.10.2)
105
- language_server-protocol (3.17.0.4)
63
+ json (2.13.2)
64
+ language_server-protocol (3.17.0.5)
106
65
  lint_roller (1.1.0)
107
66
  logger (1.7.0)
108
- loofah (2.24.0)
67
+ loofah (2.24.1)
109
68
  crass (~> 1.0.2)
110
69
  nokogiri (>= 1.12.0)
111
- mail (2.8.1)
112
- mini_mime (>= 0.1.1)
113
- net-imap
114
- net-pop
115
- net-smtp
116
- marcel (1.0.4)
117
- mini_mime (1.1.5)
118
70
  minitest (5.25.5)
119
- net-imap (0.5.6)
120
- date
121
- net-protocol
122
- net-pop (0.1.2)
123
- net-protocol
124
- net-protocol (0.2.2)
125
- timeout
126
- net-smtp (0.5.1)
127
- net-protocol
128
- nio4r (2.7.4)
129
- nokogiri (1.18.7-arm64-darwin)
71
+ nokogiri (1.18.9-arm64-darwin)
130
72
  racc (~> 1.4)
131
- parallel (1.26.3)
132
- parser (3.3.7.4)
73
+ parallel (1.27.0)
74
+ parser (3.3.9.0)
133
75
  ast (~> 2.4.1)
134
76
  racc
135
- phlex (2.2.1)
77
+ phlex (2.3.1)
136
78
  zeitwerk (~> 2.7)
137
- phlex-rails (2.2.0)
138
- phlex (~> 2.2.1)
79
+ phlex-rails (2.3.1)
80
+ phlex (~> 2.3.0)
139
81
  railties (>= 7.1, < 9)
82
+ zeitwerk (~> 2.7)
140
83
  pp (0.6.2)
141
84
  prettyprint
142
85
  prettyprint (0.2.0)
143
86
  prism (1.4.0)
144
- psych (5.2.3)
87
+ psych (5.2.6)
145
88
  date
146
89
  stringio
147
90
  racc (1.8.1)
148
- rack (3.1.12)
149
- rack-session (2.1.0)
91
+ rack (3.2.0)
92
+ rack-session (2.1.1)
150
93
  base64 (>= 0.1.0)
151
94
  rack (>= 3.0.0)
152
95
  rack-test (2.2.0)
153
96
  rack (>= 1.3)
154
97
  rackup (2.2.1)
155
98
  rack (>= 3)
156
- rails (8.0.2)
157
- actioncable (= 8.0.2)
158
- actionmailbox (= 8.0.2)
159
- actionmailer (= 8.0.2)
160
- actionpack (= 8.0.2)
161
- actiontext (= 8.0.2)
162
- actionview (= 8.0.2)
163
- activejob (= 8.0.2)
164
- activemodel (= 8.0.2)
165
- activerecord (= 8.0.2)
166
- activestorage (= 8.0.2)
167
- activesupport (= 8.0.2)
168
- bundler (>= 1.15.0)
169
- railties (= 8.0.2)
170
- rails-dom-testing (2.2.0)
99
+ rails-dom-testing (2.3.0)
171
100
  activesupport (>= 5.0.0)
172
101
  minitest
173
102
  nokogiri (>= 1.6)
@@ -183,13 +112,14 @@ GEM
183
112
  thor (~> 1.0, >= 1.2.2)
184
113
  zeitwerk (~> 2.6)
185
114
  rainbow (3.1.1)
186
- rake (13.2.1)
187
- rdoc (6.13.1)
115
+ rake (13.3.0)
116
+ rdoc (6.14.2)
117
+ erb
188
118
  psych (>= 4.0.0)
189
- regexp_parser (2.10.0)
190
- reline (0.6.1)
119
+ regexp_parser (2.11.0)
120
+ reline (0.6.2)
191
121
  io-console (~> 0.5)
192
- rubocop (1.73.2)
122
+ rubocop (1.75.8)
193
123
  json (~> 2.3)
194
124
  language_server-protocol (~> 3.17.0.2)
195
125
  lint_roller (~> 1.1.0)
@@ -197,44 +127,44 @@ GEM
197
127
  parser (>= 3.3.0.2)
198
128
  rainbow (>= 2.2.2, < 4.0)
199
129
  regexp_parser (>= 2.9.3, < 3.0)
200
- rubocop-ast (>= 1.38.0, < 2.0)
130
+ rubocop-ast (>= 1.44.0, < 2.0)
201
131
  ruby-progressbar (~> 1.7)
202
132
  unicode-display_width (>= 2.4.0, < 4.0)
203
- rubocop-ast (1.44.0)
133
+ rubocop-ast (1.46.0)
204
134
  parser (>= 3.3.7.2)
205
135
  prism (~> 1.4)
206
- rubocop-performance (1.24.0)
136
+ rubocop-performance (1.25.0)
207
137
  lint_roller (~> 1.1)
208
- rubocop (>= 1.72.1, < 2.0)
138
+ rubocop (>= 1.75.0, < 2.0)
209
139
  rubocop-ast (>= 1.38.0, < 2.0)
210
- rubocop-rails (2.26.2)
140
+ rubocop-rails (2.31.0)
211
141
  activesupport (>= 4.2.0)
142
+ lint_roller (~> 1.1)
212
143
  rack (>= 1.1)
213
- rubocop (>= 1.52.0, < 2.0)
214
- rubocop-ast (>= 1.31.1, < 2.0)
144
+ rubocop (>= 1.75.0, < 2.0)
145
+ rubocop-ast (>= 1.38.0, < 2.0)
215
146
  ruby-progressbar (1.13.0)
216
147
  securerandom (0.4.1)
217
- standard (1.47.0)
148
+ standard (1.50.0)
218
149
  language_server-protocol (~> 3.17.0.2)
219
150
  lint_roller (~> 1.0)
220
- rubocop (~> 1.73.0)
151
+ rubocop (~> 1.75.5)
221
152
  standard-custom (~> 1.0.0)
222
- standard-performance (~> 1.7)
153
+ standard-performance (~> 1.8)
223
154
  standard-custom (1.0.2)
224
155
  lint_roller (~> 1.0)
225
156
  rubocop (~> 1.50)
226
- standard-performance (1.7.0)
157
+ standard-performance (1.8.0)
227
158
  lint_roller (~> 1.1)
228
- rubocop-performance (~> 1.24.0)
229
- standard-rails (1.2.0)
159
+ rubocop-performance (~> 1.25.0)
160
+ standard-rails (1.4.0)
230
161
  lint_roller (~> 1.0)
231
- rubocop-rails (~> 2.26.0)
162
+ rubocop-rails (~> 2.31.0)
232
163
  stimulus-rails (1.3.4)
233
164
  railties (>= 6.0.0)
234
- stringio (3.1.6)
235
- thor (1.3.2)
236
- timeout (0.4.3)
237
- turbo-rails (2.0.13)
165
+ stringio (3.1.7)
166
+ thor (1.4.0)
167
+ turbo-rails (2.0.16)
238
168
  actionpack (>= 7.1.0)
239
169
  railties (>= 7.1.0)
240
170
  tzinfo (2.0.6)
@@ -244,11 +174,7 @@ GEM
244
174
  unicode-emoji (4.0.4)
245
175
  uri (1.0.3)
246
176
  useragent (0.16.11)
247
- websocket-driver (0.7.7)
248
- base64
249
- websocket-extensions (>= 0.1.0)
250
- websocket-extensions (0.1.5)
251
- zeitwerk (2.7.2)
177
+ zeitwerk (2.7.3)
252
178
 
253
179
  PLATFORMS
254
180
  arm64-darwin-22
@@ -257,7 +183,7 @@ PLATFORMS
257
183
 
258
184
  DEPENDENCIES
259
185
  rake (~> 13.0)
260
- standard (~> 1.3)
186
+ standard
261
187
  standard-rails
262
188
  ultimate_turbo_modal!
263
189
 
data/README.md CHANGED
@@ -8,10 +8,6 @@ Under the hood, it uses [Stimulus](https://stimulus.hotwired.dev), [Turbo](https
8
8
 
9
9
  It currently ships in a three flavors: Tailwind v3, Tailwind v4 and regular, vanilla CSS. It is easy to create your own variant to suit your needs.
10
10
 
11
- &nbsp;
12
- &nbsp;
13
-
14
-
15
11
  ## Installation
16
12
 
17
13
  ```
@@ -19,38 +15,6 @@ $ bundle add ultimate_turbo_modal
19
15
  $ bundle exec rails g ultimate_turbo_modal:install
20
16
  ```
21
17
 
22
- &nbsp;
23
- &nbsp;
24
-
25
- ## Features and capabilities
26
-
27
- - Extremely easy to use
28
- - Fully responsive
29
- - Does not break if a user navigates directly to a page that is usually shown in a modal
30
- - Opening a modal in a new browser tab (ie: right click) gracefully degrades without having to code a modal and non-modal version of the same page
31
- - Automatically handles URL history (ie: pushState) for shareable URLs
32
- - pushState URL optionally overrideable
33
- - Seamless support for multi-page navigation within the modal
34
- - Seamless support for forms with validations
35
- - Seamless support for Rails flash messages
36
- - Enter/leave animation (fade in/out)
37
- - Support for long, scrollable modals
38
- - Properly locks the background page when scrolling a long modal
39
- - Click outside the modal to dismiss
40
- - Option to whitelist CSS selectors that won't dismiss the modal when clicked outside the modal (ie: datepicker)
41
- - Keyboard control; ESC to dismiss
42
- - Automatic (or not) close button
43
-
44
-
45
- &nbsp;
46
- &nbsp;
47
- ## Demo
48
-
49
- A demo application can be found at https://github.com/cmer/ultimate_turbo_modal-demo. A video demo can be seen here: [https://youtu.be/BVRDXLN1I78](https://youtu.be/BVRDXLN1I78).
50
-
51
-
52
- &nbsp;
53
- &nbsp;
54
18
  ## Usage
55
19
 
56
20
  1. Wrap your view inside a `modal` block as follow:
@@ -69,6 +33,33 @@ A demo application can be found at https://github.com/cmer/ultimate_turbo_modal-
69
33
 
70
34
  Clicking on the link will automatically open the content of the view inside a modal. If you open the link in a new tab, it will render normally outside of the modal. Nothing to do!
71
35
 
36
+ This is really all you should need to do for most use cases.
37
+
38
+ ### Setting Title and Footer
39
+
40
+ You can set a custom title and footer by passing a block. For example:
41
+
42
+ ```erb
43
+ <%= modal do |m| %>
44
+ <% m.title do %>
45
+ <div>My Title</div>
46
+ <% end %>
47
+
48
+ <p>Your modal body</p>
49
+ <%= form_with url: "#", html: { id: "myform" } do |f| %>
50
+ <p>..</p>
51
+ <% end %>
52
+
53
+ <% m.footer do %>
54
+ <input type="submit" form="myform">Submit</input>
55
+ <% end %>
56
+ <% end %>
57
+ ```
58
+
59
+ You can also set a title with options (see below).
60
+
61
+ ### Detecting modal at render time
62
+
72
63
  If you need to do something a little bit more advanced when the view is shown outside of a modal, you can use the `#inside_modal?` method as such:
73
64
 
74
65
  ```erb
@@ -79,44 +70,22 @@ If you need to do something a little bit more advanced when the view is shown ou
79
70
  <% end %>
80
71
  ```
81
72
 
73
+
74
+
82
75
  &nbsp;
83
76
  &nbsp;
84
77
  ## Options
85
78
 
86
- ### `padding`, default: `true`
87
-
88
- Adds padding inside the modal.
89
-
90
- ### `close_button`, default: `true`
91
-
92
- Shows or hide a close button (X) at the top right of the modal.
93
-
94
- ### `advance`, default: `true`
95
-
96
- When opening the modal, the URL in the URL bar will change to the URL of the view being shown in the modal. The Back button dismisses the modal and navigates back.
97
-
98
- If a URL is specified as a String, the browser history will advance, and the URL shown in the URL bad will be replaced by the URL specified.
99
-
100
- ### `title`, default: `nil`
101
-
102
- Title to display in the modal header. Alternatively, you can set the title with a block.
103
-
104
- ### `header`, default: `true`
105
-
106
- Whether to display a modal header.
107
-
108
- ### `header_divider`, default: `true`
109
-
110
- Whether to display a divider below the header.
111
-
112
- ### `footer_divider`, default: `true`
79
+ Do not get overwhelmed with all the options. The defaults are sensible.
113
80
 
114
- Whether to display a divider above the footer. The divider will not appear if no footer was specified.
115
-
116
- ### `allowed_click_outside_selector`, default: `nil`
117
-
118
- A string of CSS selectors that can be clicked outside of the modal without dismissing the modal. Useful for elements
119
- such as datepickers.
81
+ | name | default value | description |
82
+ |------|---------------|-------------|
83
+ | `advance` | `true` | When opening the modal, the URL in the URL bar will change to the URL of the view being shown in the modal. The Back button dismisses the modal and navigates back. If a URL is specified as a string (e.g. `advance: "/other-path"), the browser history will advance, and the URL shown in the URL bar will be replaced with the value specified. |
84
+ | `close_button` | `true` | Shows or hide a close button (X) at the top right of the modal. |
85
+ | `header` | `true` | Whether to display a modal header. |
86
+ | `header_divider` | `true` | Whether to display a divider below the header. |
87
+ | `padding` | `true` | Adds padding inside the modal. |
88
+ | `title` | `nil` | Title to display in the modal header. Alternatively, you can set the title with a block. |
120
89
 
121
90
  ### Example usage with options
122
91
 
@@ -132,50 +101,45 @@ such as datepickers.
132
101
  <% end %>
133
102
  ```
134
103
 
135
- ### Title and Footer
136
-
137
- You can set a custom title and footer by passing a block. For example
138
-
139
- ```erb
140
- <%= modal do |m| %>
141
- <% m.title do %>
142
- <div>My Title</div>
143
- <% end %>
144
-
145
- Modal body
104
+ ## Features and capabilities
146
105
 
147
- <% m.footer do %>
148
- <input type="submit" form="myform">Submit</input>
149
- <% end %>
150
- <% end %>
151
- ```
106
+ - Extremely easy to use
107
+ - Fully responsive
108
+ - Does not break if a user navigates directly to a page that is usually shown in a modal
109
+ - Opening a modal in a new browser tab (ie: right click) gracefully degrades without having to code a modal and non-modal version of the same page
110
+ - Automatically handles URL history (ie: pushState) for shareable URLs
111
+ - pushState URL optionally overrideable
112
+ - Seamless support for multi-page navigation within the modal
113
+ - Seamless support for forms with validations
114
+ - Seamless support for Rails flash messages
115
+ - Enter/leave animation (fade in/out)
116
+ - Support for long, scrollable modals
117
+ - Properly locks the background page when scrolling a long modal
118
+ - Click outside the modal to dismiss
119
+ - Option to whitelist CSS selectors that won't dismiss the modal when clicked outside the modal (ie: datepicker)
120
+ - Keyboard control; ESC to dismiss
121
+ - Automatic (or not) close button
122
+ - Focus trap for improved accessibility (Tab and Shift+Tab cycle through focusable elements within the modal only)
152
123
 
153
- &nbsp;
154
- &nbsp;
155
124
 
156
- ## Upgrading from version 1.x
125
+ ## Demo
157
126
 
158
- - Remove the two `setupUltimateTurboModal`-related lines from `app/javascript/controllers/index.js`:
127
+ A demo application can be found at https://github.com/cmer/ultimate_turbo_modal-demo. A video demo can be seen here: [https://youtu.be/BVRDXLN1I78](https://youtu.be/BVRDXLN1I78).
159
128
 
160
- - Remove anything UTMR-specific in `tailwind.config.js`.
129
+ ## Upgrading from 1.x
161
130
 
162
- - Remove the optional Idiomorph tweaks:
163
- - `<script src="https://unpkg.com/idiomorph"></script>` from your HTML
164
- - `addEventListener("turbo:before-frame-render", (event) => {...` from `application.js`
165
- - Update the gem to the newest version and follow the installation instructions above.
131
+ Please see the [Upgrading Guide](UPGRADING.md) for detailed instructions on how to upgrade from version 1.x.
166
132
 
167
133
  ## Thanks
168
134
 
169
135
  Thanks to [@joeldrapper](https://github.com/joeldrapper) and [@konnorrogers](https://github.com/KonnorRogers) for all the help!
170
136
 
171
- &nbsp;
172
- &nbsp;
137
+
173
138
  ## Contributing
174
139
 
175
140
  Bug reports and pull requests are welcome on GitHub at https://github.com/cmer/ultimate_turbo_modal.
176
141
 
177
- &nbsp;
178
- &nbsp;
142
+
179
143
  ## License
180
144
 
181
145
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/UPGRADING.md ADDED
@@ -0,0 +1,55 @@
1
+ # Upgrading from 1.x to 2.x
2
+
3
+ Version 2.0 of Ultimate Turbo Modal introduces some significant changes to simplify the setup and usage. Follow these steps to upgrade from a 1.x version.
4
+
5
+ ## 1. Gem and Package Update
6
+
7
+ 1. Update the gem in your `Gemfile`:
8
+ ```ruby
9
+ gem 'ultimate_turbo_modal', '~> 2.0'
10
+ ```
11
+ 2. Update the npm package in your `package.json`:
12
+ ```json
13
+ "ultimate-turbo-modal": "^2.0"
14
+ ```
15
+ 3. Run `bundle install` and `yarn install` (or `npm install`).
16
+
17
+ ## 2. JavaScript Changes
18
+
19
+ The biggest change in v2 is the removal of the `setupUltimateTurboModal` initializer. The modal controller now handles everything automatically.
20
+
21
+ ### Remove Initializer
22
+
23
+ - Remove the two `setupUltimateTurboModal`-related lines from `app/javascript/controllers/index.js`.
24
+
25
+ Your `index.js` should no longer import `setupUltimateTurboModal` or call it. The Stimulus controller will be automatically loaded.
26
+
27
+ ### Remove Idiomorph Tweaks (if you used them)
28
+
29
+ If you were using the optional Idiomorph tweaks for better morphing, you can remove them as this is now handled differently.
30
+
31
+ - Remove `<script src="https://unpkg.com/idiomorph"></script>` from your application layout.
32
+ - Remove the `turbo:before-frame-render` event listener from your `application.js`.
33
+
34
+ ## 3. Tailwind CSS Changes
35
+
36
+ - Remove any `ultimate_turbo_modal` specific paths from your `tailwind.config.js`. The modal's classes are now self-contained and don't require scanning the gem's view files.
37
+
38
+ A typical `tailwind.config.js` in a Rails app should have its `content` array look something like this, without mentioning the gem:
39
+
40
+ ```js
41
+ module.exports = {
42
+ content: [
43
+ './app/views/**/*.html.erb',
44
+ './app/helpers/**/*.rb',
45
+ './app/assets/stylesheets/**/*.css',
46
+ './app/javascript/**/*.js'
47
+ ]
48
+ }
49
+ ```
50
+
51
+ ## 4. Review Usage
52
+
53
+ Version 2.0 aims for backward compatibility in how you render modals from your Rails views and controllers. However, it's always a good idea to test your modals after upgrading to ensure they behave as expected.
54
+
55
+ That's it! You should now be running on version 2.0.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.4
1
+ 2.1.1
@@ -0,0 +1,7 @@
1
+ # See https://git-scm.com/docs/gitattributes for more about git attribute files.
2
+
3
+ # Mark the database schema as having been generated.
4
+ db/schema.rb linguist-generated
5
+
6
+ # Mark any vendored files as having been vendored.
7
+ vendor/* linguist-vendored