superform 0.5.1 → 0.6.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: b9c458186315ee97fe98e0b3c304ca674967ee6e2c9f797aadec175a629fa3ef
4
- data.tar.gz: 65a76515d2f07965a9c5beff64861ef1ea02b46f6ee498304cf665a36990ecb9
3
+ metadata.gz: accaaea2d3dd94355732e750093516e12c4dd1b113fcaecf6aae4f3cce30139d
4
+ data.tar.gz: 9696d2b2de96dda5d6a7a4c80c23aaed95e3db27223daf6b1744bd5cbe842417
5
5
  SHA512:
6
- metadata.gz: 9150a51203dd7bc4ca7dcdd3b629cde2c5b0eaf37446c0ffd9a9697201de0af24b041c57c3e4ecf268d6f40f1c9f424760b058bcd31480d4af515f9e39d07de9
7
- data.tar.gz: 45c5794a688e16daa4818068136163bfa68ae86ba61e1797960c8d2eff3d8cb88d5cbd69752569163ffc183a75e944ddcade6cabf49a3992734457b94752b70d
6
+ metadata.gz: c6bfa1a54025fce5d9caabafce96fdad1564bbdc95eaf1e7b8959d3fd7c021c595ac66de5da05cc511631f85f1791ed501a0ec7c973705712b227fa04cc4ba04
7
+ data.tar.gz: c908864725edfc61446f4bbf678758b4efb4a171dd2634ea96d423876e3b36b3356842b075372c9559201bef26d170c3f10e696d26928841ca413d7476106593
data/CHANGELOG.md CHANGED
@@ -1,5 +1,136 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ### Breaking Changes
4
+
5
+ This release includes several breaking changes to improve consistency with Phlex 2.x conventions and better organize the codebase.
6
+
7
+ #### Form Instance Architecture Changes
8
+
9
+ The framework now passes form instances instead of field classes throughout the namespace hierarchy:
10
+
11
+ - `Namespace` constructor now accepts `form:` parameter instead of `field_class:`
12
+ - `NamespaceCollection` constructor now accepts `form:` parameter instead of `field_class:`
13
+ - Form instances must implement a `build_field` method for field creation
14
+ - Rails forms now pass themselves as form instances to namespaces
15
+
16
+ This change enables better encapsulation and allows forms to customize field creation logic.
17
+
18
+ #### Component Class Naming Changes
19
+
20
+ All Rails component classes have been renamed to match Phlex 2.x conventions by removing the "Component" suffix:
21
+
22
+ - `Superform::Rails::Components::BaseComponent` → `Superform::Rails::Components::Base`
23
+ - `Superform::Rails::Components::FieldComponent` → `Superform::Rails::Components::Field`
24
+ - `Superform::Rails::Components::InputComponent` → `Superform::Rails::Components::Input`
25
+ - `Superform::Rails::Components::ButtonComponent` → `Superform::Rails::Components::Button`
26
+ - `Superform::Rails::Components::CheckboxComponent` → `Superform::Rails::Components::Checkbox`
27
+ - `Superform::Rails::Components::TextareaComponent` → `Superform::Rails::Components::Textarea`
28
+ - `Superform::Rails::Components::SelectField` → `Superform::Rails::Components::Select`
29
+ - `Superform::Rails::Components::LabelComponent` → `Superform::Rails::Components::Label`
30
+
31
+ #### File Structure Changes
32
+
33
+ Rails classes have been moved into separate files for better organization:
34
+
35
+ - Components are now in individual files under `lib/superform/rails/components/`
36
+ - Core classes like `Form` are now in `lib/superform/rails/form.rb`
37
+
38
+ #### Phlex Rails Dependency
39
+
40
+ - Now requires `phlex-rails ~> 2.0` (was `>= 1.0, < 3.0`)
41
+
42
+ ### How to Upgrade
43
+
44
+ #### Custom Form Classes
45
+
46
+ Custom form classes with Rails now automatically pass themselves as form instances (no changes needed for basic usage).
47
+
48
+ #### Update Component Class Names
49
+
50
+ Update component class names in your custom form classes:
51
+
52
+ ```ruby
53
+ # Before (0.5.x)
54
+ class MyInput < Superform::Rails::Components::InputComponent
55
+ # ...
56
+ end
57
+
58
+ class Field < Superform::Rails::Form::Field
59
+ def input(**attributes)
60
+ MyInput.new(self, attributes: attributes)
61
+ end
62
+ end
63
+ ```
64
+
65
+ ```ruby
66
+ # After (0.6.0)
67
+ class MyInput < Superform::Rails::Components::Input
68
+ # ...
69
+ end
70
+
71
+ class Field < Superform::Rails::Form::Field
72
+ def input(**attributes)
73
+ MyInput.new(self, attributes: attributes)
74
+ end
75
+ end
76
+ ```
77
+
78
+ #### Update Your Gemfile
79
+
80
+ Update your Gemfile to ensure compatibility:
81
+
82
+ ```ruby
83
+ gem 'phlex-rails', '~> 2.0'
84
+ gem 'superform', '~> 0.6.0'
85
+ ```
86
+
87
+ #### Run Bundle Update
88
+
89
+ Run bundle update to update dependencies:
90
+
91
+ ```bash
92
+ bundle update phlex-rails superform
93
+ ```
94
+
95
+ ### Added
96
+
97
+ - Form instance architecture for better encapsulation and customization
98
+ - `Superform::Form` class for basic form behavior without Rails dependencies
99
+ - `build_field` method delegation to form instances
100
+ - Better file organization with Rails classes in separate files
101
+ - Improved Phlex 2.x compatibility and conventions
102
+ - Strong Parameters support with `Superform::Rails::StrongParameters` module:
103
+ - `permit(form)` method for assigning permitted params without saving
104
+ - `save(form)` method for saving models with permitted params
105
+ - `save!(form)` method for saving with exception handling on validation failure
106
+ - Automatic parameter filtering based on form field declarations
107
+ - Safe mass assignment protection against unauthorized attributes
108
+ - Field input type helper methods for Rails forms:
109
+ - `field.email` for email input type
110
+ - `field.password` for password input type
111
+ - `field.url` for URL input type
112
+ - `field.tel` (with `phone` alias) for telephone input type
113
+ - `field.number` for number input type
114
+ - `field.range` for range input type
115
+ - `field.date` for date input type
116
+ - `field.time` for time input type
117
+ - `field.datetime` for datetime-local input type
118
+ - `field.month` for month input type
119
+ - `field.week` for week input type
120
+ - `field.color` for color input type
121
+ - `field.search` for search input type
122
+ - `field.file` for file input type
123
+ - `field.hidden` for hidden input type
124
+ - `field.radio(value)` for radio button input type
125
+
126
+ ### Changed
127
+
128
+ - **Breaking**: `Namespace` and `NamespaceCollection` constructors now accept `form:` instead of `field_class:`
129
+ - **Breaking**: Form instances must implement `build_field` method
130
+ - Rails component classes moved to individual files
131
+ - Component class names simplified to match Phlex conventions
132
+ - Dependency updated to require phlex-rails 2.x
133
+
3
134
  ## [0.1.0] - 2023-06-23
4
135
 
5
136
  - Initial release
data/Gemfile CHANGED
@@ -9,4 +9,12 @@ gem "rake", "~> 13.0"
9
9
 
10
10
  # Run tests
11
11
  gem "rspec", "~> 3.0"
12
+ gem "rspec-rails", "~> 6.0"
12
13
  gem "guard-rspec", "~> 4.7"
14
+
15
+ # Minimal Rails for testing
16
+ gem "rails", "~> 8.0"
17
+ gem "actionpack", "~> 8.0"
18
+
19
+ # Database for in-memory ActiveRecord tests
20
+ gem "sqlite3"
data/Gemfile.lock CHANGED
@@ -1,32 +1,74 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superform (0.5.1)
5
- phlex-rails (>= 1.0, < 3.0)
4
+ superform (0.6.1)
5
+ phlex-rails (~> 2.0)
6
6
  zeitwerk (~> 2.6)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (7.2.1)
12
- actionview (= 7.2.1)
13
- activesupport (= 7.2.1)
11
+ actioncable (8.0.2.1)
12
+ actionpack (= 8.0.2.1)
13
+ activesupport (= 8.0.2.1)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ zeitwerk (~> 2.6)
17
+ actionmailbox (8.0.2.1)
18
+ actionpack (= 8.0.2.1)
19
+ activejob (= 8.0.2.1)
20
+ activerecord (= 8.0.2.1)
21
+ activestorage (= 8.0.2.1)
22
+ activesupport (= 8.0.2.1)
23
+ mail (>= 2.8.0)
24
+ actionmailer (8.0.2.1)
25
+ actionpack (= 8.0.2.1)
26
+ actionview (= 8.0.2.1)
27
+ activejob (= 8.0.2.1)
28
+ activesupport (= 8.0.2.1)
29
+ mail (>= 2.8.0)
30
+ rails-dom-testing (~> 2.2)
31
+ actionpack (8.0.2.1)
32
+ actionview (= 8.0.2.1)
33
+ activesupport (= 8.0.2.1)
14
34
  nokogiri (>= 1.8.5)
15
- racc
16
- rack (>= 2.2.4, < 3.2)
35
+ rack (>= 2.2.4)
17
36
  rack-session (>= 1.0.1)
18
37
  rack-test (>= 0.6.3)
19
38
  rails-dom-testing (~> 2.2)
20
39
  rails-html-sanitizer (~> 1.6)
21
40
  useragent (~> 0.16)
22
- actionview (7.2.1)
23
- activesupport (= 7.2.1)
41
+ actiontext (8.0.2.1)
42
+ actionpack (= 8.0.2.1)
43
+ activerecord (= 8.0.2.1)
44
+ activestorage (= 8.0.2.1)
45
+ activesupport (= 8.0.2.1)
46
+ globalid (>= 0.6.0)
47
+ nokogiri (>= 1.8.5)
48
+ actionview (8.0.2.1)
49
+ activesupport (= 8.0.2.1)
24
50
  builder (~> 3.1)
25
51
  erubi (~> 1.11)
26
52
  rails-dom-testing (~> 2.2)
27
53
  rails-html-sanitizer (~> 1.6)
28
- activesupport (7.2.1)
54
+ activejob (8.0.2.1)
55
+ activesupport (= 8.0.2.1)
56
+ globalid (>= 0.3.6)
57
+ activemodel (8.0.2.1)
58
+ activesupport (= 8.0.2.1)
59
+ activerecord (8.0.2.1)
60
+ activemodel (= 8.0.2.1)
61
+ activesupport (= 8.0.2.1)
62
+ timeout (>= 0.4.0)
63
+ activestorage (8.0.2.1)
64
+ actionpack (= 8.0.2.1)
65
+ activejob (= 8.0.2.1)
66
+ activerecord (= 8.0.2.1)
67
+ activesupport (= 8.0.2.1)
68
+ marcel (~> 1.0)
69
+ activesupport (8.0.2.1)
29
70
  base64
71
+ benchmark (>= 0.3)
30
72
  bigdecimal
31
73
  concurrent-ruby (~> 1.0, >= 1.3.1)
32
74
  connection_pool (>= 2.2.5)
@@ -36,19 +78,24 @@ GEM
36
78
  minitest (>= 5.1)
37
79
  securerandom (>= 0.3)
38
80
  tzinfo (~> 2.0, >= 2.0.5)
81
+ uri (>= 0.13.1)
39
82
  base64 (0.2.0)
83
+ benchmark (0.4.1)
40
84
  bigdecimal (3.1.8)
41
85
  builder (3.3.0)
42
86
  coderay (1.1.3)
43
87
  concurrent-ruby (1.3.4)
44
88
  connection_pool (2.4.1)
45
89
  crass (1.0.6)
90
+ date (3.4.1)
46
91
  diff-lcs (1.5.1)
47
92
  drb (2.2.1)
48
- erubi (1.13.0)
93
+ erubi (1.13.1)
49
94
  ffi (1.17.1-arm64-darwin)
50
95
  ffi (1.17.1-x86_64-linux-gnu)
51
96
  formatador (1.1.0)
97
+ globalid (1.2.1)
98
+ activesupport (>= 6.1)
52
99
  guard (2.18.1)
53
100
  formatador (>= 0.2.4)
54
101
  listen (>= 2.7, < 4.0)
@@ -73,24 +120,43 @@ GEM
73
120
  rb-fsevent (~> 0.10, >= 0.10.3)
74
121
  rb-inotify (~> 0.9, >= 0.9.10)
75
122
  logger (1.6.1)
76
- loofah (2.22.0)
123
+ loofah (2.24.1)
77
124
  crass (~> 1.0.2)
78
125
  nokogiri (>= 1.12.0)
79
126
  lumberjack (1.2.10)
127
+ mail (2.8.1)
128
+ mini_mime (>= 0.1.1)
129
+ net-imap
130
+ net-pop
131
+ net-smtp
132
+ marcel (1.0.4)
80
133
  method_source (1.1.0)
134
+ mini_mime (1.1.5)
81
135
  minitest (5.25.1)
82
136
  nenv (0.3.0)
83
- nokogiri (1.18.3-arm64-darwin)
137
+ net-imap (0.5.9)
138
+ date
139
+ net-protocol
140
+ net-pop (0.1.2)
141
+ net-protocol
142
+ net-protocol (0.2.2)
143
+ timeout
144
+ net-smtp (0.5.1)
145
+ net-protocol
146
+ nio4r (2.7.4)
147
+ nokogiri (1.18.9-arm64-darwin)
84
148
  racc (~> 1.4)
85
- nokogiri (1.18.3-x86_64-linux-gnu)
149
+ nokogiri (1.18.9-x86_64-linux-gnu)
86
150
  racc (~> 1.4)
87
151
  notiffany (0.1.3)
88
152
  nenv (~> 0.1)
89
153
  shellany (~> 0.0)
90
- phlex (1.10.3)
91
- phlex-rails (1.2.1)
92
- phlex (~> 1.10.0)
93
- railties (>= 6.1, < 8)
154
+ phlex (2.3.1)
155
+ zeitwerk (~> 2.7)
156
+ phlex-rails (2.3.1)
157
+ phlex (~> 2.3.0)
158
+ railties (>= 7.1, < 9)
159
+ zeitwerk (~> 2.7)
94
160
  pry (0.14.2)
95
161
  coderay (~> 1.1)
96
162
  method_source (~> 1.0)
@@ -98,23 +164,38 @@ GEM
98
164
  stringio
99
165
  racc (1.8.1)
100
166
  rack (3.1.8)
101
- rack-session (2.0.0)
167
+ rack-session (2.1.1)
168
+ base64 (>= 0.1.0)
102
169
  rack (>= 3.0.0)
103
- rack-test (2.1.0)
170
+ rack-test (2.2.0)
104
171
  rack (>= 1.3)
105
172
  rackup (2.1.0)
106
173
  rack (>= 3)
107
174
  webrick (~> 1.8)
108
- rails-dom-testing (2.2.0)
175
+ rails (8.0.2.1)
176
+ actioncable (= 8.0.2.1)
177
+ actionmailbox (= 8.0.2.1)
178
+ actionmailer (= 8.0.2.1)
179
+ actionpack (= 8.0.2.1)
180
+ actiontext (= 8.0.2.1)
181
+ actionview (= 8.0.2.1)
182
+ activejob (= 8.0.2.1)
183
+ activemodel (= 8.0.2.1)
184
+ activerecord (= 8.0.2.1)
185
+ activestorage (= 8.0.2.1)
186
+ activesupport (= 8.0.2.1)
187
+ bundler (>= 1.15.0)
188
+ railties (= 8.0.2.1)
189
+ rails-dom-testing (2.3.0)
109
190
  activesupport (>= 5.0.0)
110
191
  minitest
111
192
  nokogiri (>= 1.6)
112
- rails-html-sanitizer (1.6.0)
193
+ rails-html-sanitizer (1.6.2)
113
194
  loofah (~> 2.21)
114
- nokogiri (~> 1.14)
115
- railties (7.2.1)
116
- actionpack (= 7.2.1)
117
- activesupport (= 7.2.1)
195
+ 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)
196
+ railties (8.0.2.1)
197
+ actionpack (= 8.0.2.1)
198
+ activesupport (= 8.0.2.1)
118
199
  irb (~> 1.13)
119
200
  rackup (>= 1.0.0)
120
201
  rake (>= 12.2)
@@ -140,15 +221,31 @@ GEM
140
221
  rspec-mocks (3.13.2)
141
222
  diff-lcs (>= 1.2.0, < 2.0)
142
223
  rspec-support (~> 3.13.0)
224
+ rspec-rails (6.1.5)
225
+ actionpack (>= 6.1)
226
+ activesupport (>= 6.1)
227
+ railties (>= 6.1)
228
+ rspec-core (~> 3.13)
229
+ rspec-expectations (~> 3.13)
230
+ rspec-mocks (~> 3.13)
231
+ rspec-support (~> 3.13)
143
232
  rspec-support (3.13.1)
144
233
  securerandom (0.3.1)
145
234
  shellany (0.0.1)
235
+ sqlite3 (2.7.3-arm64-darwin)
236
+ sqlite3 (2.7.3-x86_64-linux-gnu)
146
237
  stringio (3.1.1)
147
238
  thor (1.3.2)
239
+ timeout (0.4.3)
148
240
  tzinfo (2.0.6)
149
241
  concurrent-ruby (~> 1.0)
150
- useragent (0.16.10)
242
+ uri (1.0.3)
243
+ useragent (0.16.11)
151
244
  webrick (1.8.2)
245
+ websocket-driver (0.8.0)
246
+ base64
247
+ websocket-extensions (>= 0.1.0)
248
+ websocket-extensions (0.1.5)
152
249
  zeitwerk (2.7.0)
153
250
 
154
251
  PLATFORMS
@@ -158,9 +255,13 @@ PLATFORMS
158
255
  x86_64-linux
159
256
 
160
257
  DEPENDENCIES
258
+ actionpack (~> 8.0)
161
259
  guard-rspec (~> 4.7)
260
+ rails (~> 8.0)
162
261
  rake (~> 13.0)
163
262
  rspec (~> 3.0)
263
+ rspec-rails (~> 6.0)
264
+ sqlite3
164
265
  superform!
165
266
 
166
267
  BUNDLED WITH