shoelace-rails 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +11 -61
  3. data/.gitignore +1 -6
  4. data/Appraisals +6 -0
  5. data/CHANGELOG.md +25 -3
  6. data/Gemfile +0 -3
  7. data/Rakefile +2 -17
  8. data/app/helpers/shoelace/form_helper.rb +39 -6
  9. data/gemfiles/rails_60.gemfile +0 -1
  10. data/gemfiles/rails_61.gemfile +0 -1
  11. data/gemfiles/rails_70.gemfile +0 -1
  12. data/gemfiles/rails_71.gemfile +10 -0
  13. data/gemfiles/rails_edge.gemfile +0 -1
  14. data/lib/shoelace/rails/version.rb +1 -1
  15. data/lib/shoelace/railtie.rb +4 -1
  16. data/lib/tasks/shoelace.rake +5 -1
  17. data/shoelace-rails.gemspec +1 -1
  18. data/test/helpers/form_helper_test.rb +39 -10
  19. metadata +6 -58
  20. data/dist/.keep +0 -0
  21. data/dist/types/.keep +0 -0
  22. data/package.json +0 -50
  23. data/rollup.config.js +0 -49
  24. data/src/index.ts +0 -2
  25. data/src/turbo/index.ts +0 -6
  26. data/src/turbo/polyfills/formdata-event.js +0 -27
  27. data/src/turbo/sl-turbo-form.ts +0 -110
  28. data/src/turbolinks/features/confirm.ts +0 -42
  29. data/src/turbolinks/features/disable.ts +0 -94
  30. data/src/turbolinks/features/remote.ts +0 -107
  31. data/src/turbolinks/index.ts +0 -6
  32. data/src/turbolinks/selectors.ts +0 -38
  33. data/src/turbolinks/start.ts +0 -38
  34. data/src/turbolinks/turbolinks.ts +0 -78
  35. data/src/turbolinks/utils/ajax.ts +0 -146
  36. data/src/turbolinks/utils/csp.ts +0 -20
  37. data/src/turbolinks/utils/csrf.ts +0 -33
  38. data/src/turbolinks/utils/dom.ts +0 -40
  39. data/src/turbolinks/utils/event.ts +0 -57
  40. data/src/turbolinks/utils/form.ts +0 -58
  41. data/test/dummy_app/Gemfile +0 -19
  42. data/test/dummy_app/Rakefile +0 -6
  43. data/test/dummy_app/app/controllers/hotwire_forms_controller.rb +0 -46
  44. data/test/dummy_app/app/controllers/turbolinks_forms_controller.rb +0 -37
  45. data/test/dummy_app/app/models/user.rb +0 -16
  46. data/test/dummy_app/app/packs/entrypoints/hotwire.js +0 -1
  47. data/test/dummy_app/app/packs/entrypoints/turbolinks.js +0 -5
  48. data/test/dummy_app/app/views/hotwire_forms/form.html.erb +0 -45
  49. data/test/dummy_app/app/views/hotwire_forms/show.html.erb +0 -5
  50. data/test/dummy_app/app/views/layouts/application.html.erb +0 -39
  51. data/test/dummy_app/app/views/turbolinks_forms/form.html.erb +0 -44
  52. data/test/dummy_app/app/views/turbolinks_forms/show.html.erb +0 -5
  53. data/test/dummy_app/bin/rails +0 -5
  54. data/test/dummy_app/bin/webpack +0 -18
  55. data/test/dummy_app/bin/yarn +0 -18
  56. data/test/dummy_app/config/application.rb +0 -16
  57. data/test/dummy_app/config/boot.rb +0 -4
  58. data/test/dummy_app/config/environment.rb +0 -2
  59. data/test/dummy_app/config/environments/development.rb +0 -10
  60. data/test/dummy_app/config/environments/test.rb +0 -18
  61. data/test/dummy_app/config/routes.rb +0 -4
  62. data/test/dummy_app/config/webpack/development.js +0 -5
  63. data/test/dummy_app/config/webpack/production.js +0 -1
  64. data/test/dummy_app/config/webpack/test.js +0 -5
  65. data/test/dummy_app/config/webpacker.yml +0 -33
  66. data/test/dummy_app/config.ru +0 -6
  67. data/test/dummy_app/package.json +0 -24
  68. data/test/dummy_app/test/system/hotwire_form_test.rb +0 -63
  69. data/test/dummy_app/test/system/turbolinks_form_test.rb +0 -38
  70. data/test/dummy_app/test/test_helper.rb +0 -68
  71. data/tsconfig.json +0 -19
  72. data/yarn.lock +0 -249
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d765c426ef9b3551956028e292d1fe312f04c85b5e1184d2f44193c348809ae
4
- data.tar.gz: 662389bc95dc73c15851d9343304da787d70b6f93bff4dcb16124d42fa8fb7c6
3
+ metadata.gz: 4e0b7daab9653d58867634fed2dffbf3455c06cd47f084271650507b68128cdb
4
+ data.tar.gz: d92ddd6a16d38a0dad1eecfc193534365fb1da246c0ad9a54d09e39d28f7f073
5
5
  SHA512:
6
- metadata.gz: 21e95f106d6c8cff0b8edb1cdfec3d3e5d11e1a477a7ba2eff509035194666cdecadeef43465d8f426ea22082b4ce174fb3e47d82e8f7f9be4aa7e257e4a0e76
7
- data.tar.gz: 4eeb6447fb6c65179fd0514e58171ca45045069b87835cb993c8935aa4011e267b308308fffebca5fbe2409013d78548904defba33d8f28716d7370569c19b0b
6
+ metadata.gz: bb8b38ff8c3d03f12ebc72eb85cfe24fe108ba0838054e8878a439fc63083c1fc53be4d507b090da7d67daba440ae09a5cc855e4dcb008382930b0d11d15275c
7
+ data.tar.gz: 62faa8f43c33c0c2f5d7690368b4b4694de05d8e7c3f68467f1716757d6f08b26bdd4da8ce252087c68e5b79500ef5016866cacb459f28468148e73e4b0ea3da
@@ -9,6 +9,7 @@ jobs:
9
9
  strategy:
10
10
  matrix:
11
11
  ruby_version:
12
+ - '3.3'
12
13
  - '3.2'
13
14
  - '3.1'
14
15
  - '3.0'
@@ -16,17 +17,20 @@ jobs:
16
17
  - 'jruby-9.3'
17
18
  - 'jruby-9.4'
18
19
  gemfile:
20
+ - gemfiles/rails_71.gemfile
19
21
  - gemfiles/rails_70.gemfile
20
22
  - gemfiles/rails_61.gemfile
21
23
  - gemfiles/rails_60.gemfile
22
24
  exclude:
25
+ - ruby_version: 'jruby-9.3'
26
+ gemfile: gemfiles/rails_71.gemfile
23
27
  - ruby_version: 'jruby-9.3'
24
28
  gemfile: gemfiles/rails_70.gemfile
25
29
  runs-on: ubuntu-22.04
26
30
  env:
27
31
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
28
32
  steps:
29
- - uses: actions/checkout@v3
33
+ - uses: actions/checkout@v4
30
34
  - name: Set up Ruby
31
35
  uses: ruby/setup-ruby@v1
32
36
  with:
@@ -34,89 +38,35 @@ jobs:
34
38
  bundler-cache: true
35
39
  - run: bundle exec rake test
36
40
 
37
- system:
38
- needs: unit
39
- runs-on: ubuntu-22.04
40
- steps:
41
- - uses: actions/checkout@v3
42
- - name: Set up Ruby
43
- uses: ruby/setup-ruby@v1
44
- with:
45
- ruby-version: 3.2.0
46
- bundler-cache: true
47
- - name: Install dependencies
48
- run: |
49
- rm -rf node_modules &&
50
- yarn install &&
51
- yarn add tslib &&
52
- bundle
53
- - name: Run the system test in the dummy app
54
- run: rake test:system
55
-
56
41
  rails_edge:
57
- needs: system
42
+ needs: unit
58
43
  runs-on: ubuntu-22.04
59
44
  env:
60
45
  BUNDLE_GEMFILE: gemfiles/rails_edge.gemfile
61
46
  steps:
62
- - uses: actions/checkout@v3
47
+ - uses: actions/checkout@v4
63
48
  - name: Set up Ruby
64
49
  uses: ruby/setup-ruby@v1
65
50
  with:
66
- ruby-version: 3.1
51
+ ruby-version: 3.3
67
52
  bundler-cache: true
68
53
  - run: bundle exec rake test || echo "Rails edge test is done."
69
54
 
70
55
  ruby_edge:
71
- needs: system
56
+ needs: unit
72
57
  strategy:
73
58
  matrix:
74
59
  gemfile:
75
60
  - gemfiles/rails_edge.gemfile
76
- - gemfiles/rails_70.gemfile
61
+ - gemfiles/rails_71.gemfile
77
62
  runs-on: ubuntu-22.04
78
63
  env:
79
64
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
80
65
  steps:
81
- - uses: actions/checkout@v3
66
+ - uses: actions/checkout@v4
82
67
  - name: Set up Ruby
83
68
  uses: ruby/setup-ruby@v1
84
69
  with:
85
70
  ruby-version: 'ruby-head'
86
71
  bundler-cache: true
87
72
  - run: bundle exec rake || echo "Ruby edge test is done."
88
-
89
- # browser_tests:
90
- # runs-on: ubuntu-22.04
91
- # steps:
92
- # - uses: actions/checkout@v3
93
- # - name: Set up Ruby
94
- # uses: ruby/setup-ruby@v1
95
- # with:
96
- # ruby-version: 3.2.0
97
- # bundler-cache: true
98
- # - name: Install dependencies
99
- # run: |
100
- # rm -rf node_modules &&
101
- # yarn install &&
102
- # yarn add tslib &&
103
- # bundle
104
- # - name: 'BrowserStack Env Setup'
105
- # uses: 'browserstack/github-actions/setup-env@master'
106
- # with:
107
- # username: ${{ secrets.BROWSERSTACK_USERNAME }}
108
- # access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
109
- # - name: 'Start BrowserStackLocal Tunnel'
110
- # uses: 'browserstack/github-actions/setup-local@master'
111
- # with:
112
- # local-testing: 'start'
113
- # local-logging-level: 'all-logs'
114
- # local-identifier: 'random'
115
- # - name: Run the system test in the dummy app
116
- # run: rake test:system
117
- # env:
118
- # BROWSERSTACK_URL: ${{ secrets.BROWSERSTACK_URL }}
119
- # - name: 'Stop BrowserStackLocal'
120
- # uses: 'browserstack/github-actions/setup-local@master'
121
- # with:
122
- # local-testing: 'stop'
data/.gitignore CHANGED
@@ -7,14 +7,9 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  Gemfile.lock
10
- node_modules
11
- dist
12
10
  .npmrc
13
11
 
14
- test/dummy_app/yarn.lock
15
- test/dummy_app/log/
16
- test/dummy_app/tmp/
17
- test/dummy_app/public/
18
12
  .pryrc
19
13
  gemfiles/*.lock
14
+ gemfiles/.bundle
20
15
  BrowserStackLocal
data/Appraisals CHANGED
@@ -6,6 +6,12 @@ appraise "rails_edge" do
6
6
  end
7
7
  end
8
8
 
9
+ appraise "rails_71" do
10
+ gem "rails", "~> 7.1.0"
11
+ gem "railties", "~> 7.1.0"
12
+ gem "activesupport", "~> 7.1.0"
13
+ end
14
+
9
15
  appraise "rails_70" do
10
16
  gem "rails", "~> 7.0.0"
11
17
  gem "railties", "~> 7.0.0"
data/CHANGELOG.md CHANGED
@@ -1,12 +1,34 @@
1
- ## v0.4.0
1
+ ## v0.5.0
2
+
3
+ _<sup>released at 2023-03-21 04:03:27 UTC</sup>_
4
+
5
+ #### ⭐️ Features
6
+
7
+ - Add support for Ruby 3.3 (`399f25567f964d0ea2e250eba6db28a2bcd038a3`)
8
+ - Add support for Rails 7.1 (#4)
9
+ - Add `#grouped_collection_select` (`2b91023d51e1d0a218f2102232241afa82aaf872`)
10
+ - Make the `<sl-radio>` form helpers compatible with Shoelace [2.0.0-beta.80](https://shoelace.style/resources/changelog#id_2_0_0-beta_80) and above (`ef9a8345f2c5c921847aef15e19cf64a471d6473`)
11
+
12
+ ## [v0.4.1](https://github.com/yuki24/shoelace-rails/tree/v0.4.1)
13
+
14
+ _<sup>released at 2023-03-21 04:03:27 UTC</sup>_
15
+
16
+ #### 🐞Bug Fixes
17
+
18
+ - Fixes a bug where `FormHelper` may not be defined when someone loads `ActionView` too early ([<tt>d91ed3b</tt>](https://github.com/yuki24/shoelace-rails/commit/d91ed3b595c01ce2dfc471b12b14311e0660d3d7))
19
+ - Fixes a bug where the Shoelace rake tasks blow up when the project does not depend on Sprockets or Propshaft ([<tt>0e64cd6</tt>](https://github.com/yuki24/shoelace-rails/commit/0e64cd6dc38a037171be04eaf1d3f59c3c8529eb), [<tt>75adf83</tt>](https://github.com/yuki24/shoelace-rails/commit/75adf831b1faa7f5d1faeed26e672d4bc89b9513))
20
+
21
+ ## [v0.4.0](https://github.com/yuki24/shoelace-rails/tree/v0.4.0)
22
+
23
+ _<sup>released at 2023-01-07 07:23:50 UTC</sup>_
2
24
 
3
25
  #### 🚨 Breaking Changes
4
26
 
5
- - No longer works with 2.0.0-beta.88 and below.
27
+ - No longer works with `2.0.0-beta.87` and below.
6
28
 
7
29
  #### ⭐️ Features
8
30
 
9
- - Support Shoelace.style 2.0.0-beta.88
31
+ - Support Shoelace.style `2.0.0-beta.88`.
10
32
 
11
33
  ## [v0.3.0](https://github.com/yuki24/shoelace-rails/tree/v0.3.0)
12
34
 
data/Gemfile CHANGED
@@ -6,6 +6,3 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
-
10
- # Need this PR: https://github.com/rails/rails-dom-testing/pull/84 for easier DOM testing:
11
- gem 'rails-dom-testing', git: "https://github.com/rails/rails-dom-testing.git", ref: "8f5acdfc"
data/Rakefile CHANGED
@@ -6,22 +6,7 @@ require "rake/testtask"
6
6
  Rake::TestTask.new(:test) do |t|
7
7
  t.libs << "test"
8
8
  t.libs << "lib"
9
- t.test_files = FileList["test/**/*_test.rb"].exclude("test/dummy_app/**/*")
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
10
  end
11
11
 
12
- namespace :test do
13
- task :system do
14
- Bundler.with_original_env do
15
- sh <<~CMD
16
- yarn build &&
17
- cd test/dummy_app &&
18
- yarn &&
19
- bundle &&
20
- RAILS_ENV=test rails webpacker:compile
21
- rails test:system
22
- CMD
23
- end
24
- end
25
- end
26
-
27
- task default: [:test, :'test:system']
12
+ task default: [:test]
@@ -2,9 +2,6 @@
2
2
 
3
3
  module Shoelace
4
4
  module FormHelper
5
- mattr_accessor :invalid_input_class_name
6
- self.invalid_input_class_name = nil
7
-
8
5
  class ShoelaceInputField < ActionView::Helpers::Tags::TextField #:nodoc:
9
6
  attr_reader :field_type
10
7
 
@@ -21,7 +18,7 @@ module Shoelace
21
18
 
22
19
  options["size"] = options["maxlength"] unless options.key?("size")
23
20
  options["type"] ||= field_type
24
- options["class"] ||= [options["class"], Shoelace::FormHelper.invalid_input_class_name].compact.join(" ") if @object.respond_to?(:errors) && @object.errors[@method_name].present?
21
+ options["class"] ||= [options["class"], Shoelace.invalid_input_class_name].compact.join(" ") if @object.respond_to?(:errors) && @object.errors[@method_name].present?
25
22
 
26
23
  add_default_name_and_id(options)
27
24
 
@@ -107,6 +104,20 @@ module Shoelace
107
104
  end
108
105
  end
109
106
 
107
+ class ShoelaceGroupedCollectionSelect < ActionView::Helpers::Tags::GroupedCollectionSelect #:nodoc:
108
+ def option_groups_from_collection_for_select(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key = nil)
109
+ @template_object.sl_option_groups_from_collection_for_select(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key)
110
+ end
111
+
112
+ def select_content_tag(option_tags, _options, html_options)
113
+ html_options = html_options.stringify_keys
114
+ html_options['value'] ||= value
115
+ add_default_name_and_id(html_options)
116
+
117
+ @template_object.content_tag("sl-select", option_tags, html_options)
118
+ end
119
+ end
120
+
110
121
  class ShoelaceCheckBox < ActionView::Helpers::Tags::CheckBox #:nodoc:
111
122
  def render(&block)
112
123
  options = @options.stringify_keys
@@ -140,8 +151,8 @@ module Shoelace
140
151
  def render(&block)
141
152
  options = @options.stringify_keys
142
153
  options["value"] = @tag_value
143
- options["checked"] = "checked" if input_checked?(options)
144
154
  add_default_name_and_id_for_value(@tag_value, options)
155
+ options.delete("name")
145
156
 
146
157
  @template_object.content_tag('sl-radio', '', options.except("type"), &block)
147
158
  end
@@ -167,7 +178,11 @@ module Shoelace
167
178
  private
168
179
 
169
180
  def render_collection(&block)
170
- @template_object.content_tag('sl-radio-group', 'label' => @method_name.to_s.humanize) { super(&block) }
181
+ html_options = @html_options.stringify_keys
182
+ html_options["value"] = value
183
+ add_default_name_and_id(html_options)
184
+
185
+ @template_object.content_tag('sl-radio-group', html_options.with_defaults(label: @method_name.humanize)) { super(&block) }
171
186
  end
172
187
 
173
188
  def hidden_field
@@ -231,6 +246,10 @@ module Shoelace
231
246
  ShoelaceCollectionSelect.new(object_name, method, @template, collection, value_method, text_method, options.with_defaults(object: @object), html_options.with_defaults(label: method.to_s.humanize), &block).render
232
247
  end
233
248
 
249
+ def grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
250
+ ShoelaceGroupedCollectionSelect.new(object_name, method, @template, collection, group_method, group_label_method, option_key_method, option_value_method, options.with_defaults(object: @object), html_options.with_defaults(label: method.to_s.humanize)).render
251
+ end
252
+
234
253
  def collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
235
254
  ShoelaceCollectionRadioButtons.new(object_name, method, @template, collection, value_method, text_method, options.with_defaults(object: @object), html_options).render(&block)
236
255
  end
@@ -310,6 +329,20 @@ module Shoelace
310
329
  end.join("\n").html_safe
311
330
  end
312
331
 
332
+ def sl_option_groups_from_collection_for_select(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key = nil)
333
+ body = "".html_safe
334
+
335
+ collection.each_with_index do |group, index|
336
+ option_tags = sl_options_from_collection_for_select(value_for_collection(group, group_method), option_key_method, option_value_method, selected_key)
337
+
338
+ body.safe_concat(DIVIDER_TAG) if index > 0
339
+ body.safe_concat(content_tag("small", value_for_collection(group, group_label_method)))
340
+ body.safe_concat(option_tags)
341
+ end
342
+
343
+ body
344
+ end
345
+
313
346
  # Returns a string of +<sl-option>+ tags compiled by iterating over the collection and assigning the result of
314
347
  # a call to the +value_method+ as the option value and the +text_method+ as the option text.
315
348
  def sl_options_from_collection_for_select(collection, value_method, text_method, selected = nil)
@@ -3,7 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rake", "~> 13.0"
6
- gem "rails-dom-testing", git: "https://github.com/rails/rails-dom-testing.git", ref: "8f5acdfc"
7
6
  gem "rails", "~> 6.0.0"
8
7
  gem "railties", "~> 6.0.0"
9
8
  gem "activesupport", "~> 6.0.0"
@@ -3,7 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rake", "~> 13.0"
6
- gem "rails-dom-testing", git: "https://github.com/rails/rails-dom-testing.git", ref: "8f5acdfc"
7
6
  gem "rails", "~> 6.1.0"
8
7
  gem "railties", "~> 6.1.0"
9
8
  gem "activesupport", "~> 6.1.0"
@@ -3,7 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rake", "~> 13.0"
6
- gem "rails-dom-testing", git: "https://github.com/rails/rails-dom-testing.git", ref: "8f5acdfc"
7
6
  gem "rails", "~> 7.0.0"
8
7
  gem "railties", "~> 7.0.0"
9
8
  gem "activesupport", "~> 7.0.0"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "rails", "~> 7.1.0"
7
+ gem "railties", "~> 7.1.0"
8
+ gem "activesupport", "~> 7.1.0"
9
+
10
+ gemspec path: "../"
@@ -9,6 +9,5 @@ git "https://github.com/rails/rails.git", branch: "main" do
9
9
  end
10
10
 
11
11
  gem "rake", "~> 13.0"
12
- gem "rails-dom-testing", git: "https://github.com/rails/rails-dom-testing.git", ref: "8f5acdfc"
13
12
 
14
13
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Shoelace
4
4
  module Rails
5
- VERSION = "0.4.0"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
@@ -3,6 +3,9 @@
3
3
  require 'action_dispatch/middleware/static'
4
4
 
5
5
  module Shoelace
6
+ mattr_accessor :invalid_input_class_name
7
+ self.invalid_input_class_name = nil
8
+
6
9
  # The only reason this class exists is to clarify that we have a custom static file server after
7
10
  # `ActionDispatch::Static`. We could just use `ActionDispatch::Static` directly, but it would make the result of
8
11
  # `rake middleware` more difficult to understand, as the output would look like:
@@ -43,7 +46,7 @@ module Shoelace
43
46
 
44
47
  initializer "shoelace.form_helper" do |app|
45
48
  ActiveSupport.on_load :action_view do
46
- Shoelace::FormHelper.invalid_input_class_name = app.config.shoelace.invalid_input_class_name
49
+ Shoelace.invalid_input_class_name = app.config.shoelace.invalid_input_class_name
47
50
  end
48
51
  end
49
52
 
@@ -13,8 +13,12 @@ namespace :shoelace do
13
13
  end
14
14
 
15
15
  # Make sure `yarn install` is run before running `shoelace:icons:copy`.
16
- Rake::Task["shoelace:icons:copy"].enhance(["javascript:build"])
16
+ if Rake::Task.task_defined?("javascript:build")
17
+ Rake::Task["shoelace:icons:copy"].enhance(["javascript:build"])
18
+ end
17
19
 
18
20
  if Rake::Task.task_defined?("assets:precompile")
19
21
  Rake::Task["assets:precompile"].enhance(["shoelace:icons:copy"])
22
+ else
23
+ Rake::Task.define_task('assets:precompile' => ['shoelace:icons:copy'])
20
24
  end
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_development_dependency "appraisal"
33
33
  spec.add_development_dependency "minitest", ">= 5.14.4"
34
- spec.add_development_dependency "rails-dom-testing", ">= 2.0.3"
34
+ spec.add_development_dependency "rails-dom-testing", ">= 2.2.0"
35
35
  end
@@ -46,7 +46,7 @@ class FormHelperTest < ActionView::TestCase
46
46
 
47
47
  test "#sl_radio_button" do
48
48
  assert_dom_equal(<<~HTML, sl_radio_button(:user, :name, 'userid-314', checked: true) { "Yuki Nishijima" })
49
- <sl-radio value="userid-314" checked="checked" name="user[name]" id="user_name_userid-314">Yuki Nishijima</sl-radio>
49
+ <sl-radio value="userid-314" checked="checked" id="user_name_userid-314">Yuki Nishijima</sl-radio>
50
50
  HTML
51
51
  end
52
52
 
@@ -412,7 +412,7 @@ class FormHelperTest < ActionView::TestCase
412
412
  end
413
413
  end
414
414
 
415
- test "#collection_select with a defalut value" do
415
+ test "#collection_select with a default value" do
416
416
  users = {
417
417
  1 => "Yuki Nishijima",
418
418
  2 => "Matz",
@@ -430,6 +430,35 @@ class FormHelperTest < ActionView::TestCase
430
430
  end
431
431
  end
432
432
 
433
+ test "#grouped_collection_select" do
434
+ users = [
435
+ OpenStruct.new(
436
+ group_name: "Main maintainers",
437
+ members: [
438
+ OpenStruct.new(id: 1, name: "Matz"),
439
+ OpenStruct.new(id: 2, name: "Koichi Sasada"),
440
+ ]
441
+ ),
442
+ OpenStruct.new(
443
+ group_name: "Default gem maintainers",
444
+ members: [OpenStruct.new(id: 3, name: "Yuki Nishijima")]
445
+ ),
446
+ ]
447
+
448
+ sl_form_for(User.new(name: "2"), url: "/") do |form|
449
+ assert_dom_equal <<~HTML, form.grouped_collection_select(:name, users, :members, :group_name, :id, :name)
450
+ <sl-select label="Name" name="user[name]" id="user_name" value="2">
451
+ <small>Main maintainers</small>
452
+ <sl-option value="1">Matz</sl-option>
453
+ <sl-option value="2" checked="checked">Koichi Sasada</sl-option>
454
+ <sl-divider></sl-divider>
455
+ <small>Default gem maintainers</small>
456
+ <sl-option value="3">Yuki Nishijima</sl-option>
457
+ </sl-select>
458
+ HTML
459
+ end
460
+ end
461
+
433
462
  test "#collection_radio_buttons" do
434
463
  users = {
435
464
  1 => "Yuki Nishijima",
@@ -439,10 +468,10 @@ class FormHelperTest < ActionView::TestCase
439
468
 
440
469
  sl_form_for(User.new, url: "/") do |form|
441
470
  assert_dom_equal <<~HTML, form.collection_radio_buttons(:name, users, :first, :last)
442
- <sl-radio-group label="Name">
443
- <sl-radio name="user[name]" value="1" id="user_name_1">Yuki Nishijima</sl-radio>
444
- <sl-radio name="user[name]" value="2" id="user_name_2">Matz</sl-radio>
445
- <sl-radio name="user[name]" value="3" id="user_name_3">Koichi Sasada</sl-radio>
471
+ <sl-radio-group label="Name" name="user[name]" id="user_name">
472
+ <sl-radio value="1" id="user_name_1">Yuki Nishijima</sl-radio>
473
+ <sl-radio value="2" id="user_name_2">Matz</sl-radio>
474
+ <sl-radio value="3" id="user_name_3">Koichi Sasada</sl-radio>
446
475
  </sl-radio-group>
447
476
  HTML
448
477
  end
@@ -457,10 +486,10 @@ class FormHelperTest < ActionView::TestCase
457
486
 
458
487
  sl_form_for(User.new(name: 1), url: "/") do |form|
459
488
  assert_dom_equal <<~HTML, form.collection_radio_buttons(:name, users, :first, :last)
460
- <sl-radio-group label="Name">
461
- <sl-radio name="user[name]" value="1" id="user_name_1" checked="checked">Yuki Nishijima</sl-radio>
462
- <sl-radio name="user[name]" value="2" id="user_name_2">Matz</sl-radio>
463
- <sl-radio name="user[name]" value="3" id="user_name_3">Koichi Sasada</sl-radio>
489
+ <sl-radio-group label="Name" name="user[name]" value="1" id="user_name">
490
+ <sl-radio value="1" id="user_name_1">Yuki Nishijima</sl-radio>
491
+ <sl-radio value="2" id="user_name_2">Matz</sl-radio>
492
+ <sl-radio value="3" id="user_name_3">Koichi Sasada</sl-radio>
464
493
  </sl-radio-group>
465
494
  HTML
466
495
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoelace-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Nishijima
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-07 00:00:00.000000000 Z
11
+ date: 2024-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 2.0.3
75
+ version: 2.2.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 2.0.3
82
+ version: 2.2.0
83
83
  description: The shoelace-rails gem adds useful view helper methods for using Shoalace
84
84
  Web Components.
85
85
  email:
@@ -101,14 +101,13 @@ files:
101
101
  - app/helpers/shoelace/tag_helper.rb
102
102
  - bin/console
103
103
  - bin/setup
104
- - dist/.keep
105
- - dist/types/.keep
106
104
  - gemfiles/rails_50.gemfile
107
105
  - gemfiles/rails_51.gemfile
108
106
  - gemfiles/rails_52.gemfile
109
107
  - gemfiles/rails_60.gemfile
110
108
  - gemfiles/rails_61.gemfile
111
109
  - gemfiles/rails_70.gemfile
110
+ - gemfiles/rails_71.gemfile
112
111
  - gemfiles/rails_edge.gemfile
113
112
  - lib/shoelace/engine.rb
114
113
  - lib/shoelace/rails.rb
@@ -116,61 +115,10 @@ files:
116
115
  - lib/shoelace/railtie.rb
117
116
  - lib/shoelace/testing.rb
118
117
  - lib/tasks/shoelace.rake
119
- - package.json
120
- - rollup.config.js
121
118
  - shoelace-rails.gemspec
122
- - src/index.ts
123
- - src/turbo/index.ts
124
- - src/turbo/polyfills/formdata-event.js
125
- - src/turbo/sl-turbo-form.ts
126
- - src/turbolinks/features/confirm.ts
127
- - src/turbolinks/features/disable.ts
128
- - src/turbolinks/features/remote.ts
129
- - src/turbolinks/index.ts
130
- - src/turbolinks/selectors.ts
131
- - src/turbolinks/start.ts
132
- - src/turbolinks/turbolinks.ts
133
- - src/turbolinks/utils/ajax.ts
134
- - src/turbolinks/utils/csp.ts
135
- - src/turbolinks/utils/csrf.ts
136
- - src/turbolinks/utils/dom.ts
137
- - src/turbolinks/utils/event.ts
138
- - src/turbolinks/utils/form.ts
139
- - test/dummy_app/Gemfile
140
- - test/dummy_app/Rakefile
141
- - test/dummy_app/app/controllers/hotwire_forms_controller.rb
142
- - test/dummy_app/app/controllers/turbolinks_forms_controller.rb
143
- - test/dummy_app/app/models/user.rb
144
- - test/dummy_app/app/packs/entrypoints/hotwire.js
145
- - test/dummy_app/app/packs/entrypoints/turbolinks.js
146
- - test/dummy_app/app/views/hotwire_forms/form.html.erb
147
- - test/dummy_app/app/views/hotwire_forms/show.html.erb
148
- - test/dummy_app/app/views/layouts/application.html.erb
149
- - test/dummy_app/app/views/turbolinks_forms/form.html.erb
150
- - test/dummy_app/app/views/turbolinks_forms/show.html.erb
151
- - test/dummy_app/bin/rails
152
- - test/dummy_app/bin/webpack
153
- - test/dummy_app/bin/yarn
154
- - test/dummy_app/config.ru
155
- - test/dummy_app/config/application.rb
156
- - test/dummy_app/config/boot.rb
157
- - test/dummy_app/config/environment.rb
158
- - test/dummy_app/config/environments/development.rb
159
- - test/dummy_app/config/environments/test.rb
160
- - test/dummy_app/config/routes.rb
161
- - test/dummy_app/config/webpack/development.js
162
- - test/dummy_app/config/webpack/production.js
163
- - test/dummy_app/config/webpack/test.js
164
- - test/dummy_app/config/webpacker.yml
165
- - test/dummy_app/package.json
166
- - test/dummy_app/test/system/hotwire_form_test.rb
167
- - test/dummy_app/test/system/turbolinks_form_test.rb
168
- - test/dummy_app/test/test_helper.rb
169
119
  - test/helpers/form_helper_test.rb
170
120
  - test/helpers/tag_helper_test.rb
171
121
  - test/test_helper.rb
172
- - tsconfig.json
173
- - yarn.lock
174
122
  homepage: https://github.com/yuki24/shoelace-rails
175
123
  licenses:
176
124
  - MIT
@@ -193,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
141
  - !ruby/object:Gem::Version
194
142
  version: '0'
195
143
  requirements: []
196
- rubygems_version: 3.4.2
144
+ rubygems_version: 3.5.3
197
145
  signing_key:
198
146
  specification_version: 4
199
147
  summary: Rails view helpers Shoelace.style, the design system.
data/dist/.keep DELETED
File without changes
data/dist/types/.keep DELETED
File without changes