superform 0.5.0 → 0.6.0
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 +4 -4
- data/CHANGELOG.md +131 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +131 -29
- data/README.md +200 -66
- data/SPEC_STYLE_GUIDE.md +146 -0
- data/lib/generators/superform/install/USAGE +6 -2
- data/lib/generators/superform/install/install_generator.rb +11 -22
- data/lib/generators/superform/install/templates/base.rb +33 -0
- data/lib/superform/dom.rb +51 -0
- data/lib/superform/field.rb +121 -0
- data/lib/superform/field_collection.rb +33 -0
- data/lib/superform/form.rb +34 -0
- data/lib/superform/namespace.rb +134 -0
- data/lib/superform/namespace_collection.rb +51 -0
- data/lib/superform/node.rb +12 -0
- data/lib/superform/rails/components/base.rb +31 -0
- data/lib/superform/rails/components/button.rb +20 -0
- data/lib/superform/rails/components/checkbox.rb +19 -0
- data/lib/superform/rails/components/field.rb +11 -0
- data/lib/superform/rails/components/input.rb +59 -0
- data/lib/superform/rails/components/label.rb +20 -0
- data/lib/superform/rails/components/select.rb +43 -0
- data/lib/superform/rails/components/textarea.rb +12 -0
- data/lib/superform/rails/form.rb +240 -0
- data/lib/superform/rails/option_mapper.rb +36 -0
- data/lib/superform/rails/strong_parameters.rb +73 -0
- data/lib/superform/rails.rb +17 -368
- data/lib/superform/version.rb +1 -1
- data/lib/superform.rb +3 -294
- metadata +25 -9
- data/lib/generators/superform/install/templates/application_form.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 763030345942ed681f02fe01d0fee42dfe31fd2f4372ed9bab773775678bc05c
|
4
|
+
data.tar.gz: 1c9650b1a04572111fec6daefb75c25fad36026a035842ffd8d141a892154b4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd0da92fabdb070827d9cac9d275f4781d120fcf5c30aad53655b79d9405005d58d5920281edb5456bbd2521f87de80beb60e5e3bb4ec273eebb92c1fc737784
|
7
|
+
data.tar.gz: b90f1e2422e1df93557504052087d383a4ae31bab44f9f285341c286ce66792419c1cf89c36d9022ed6f2b0258f82543c5c62ca0eaefbbccf3cac88f30029acd
|
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
|
-
phlex-rails (~>
|
4
|
+
superform (0.6.0)
|
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
|
-
|
12
|
-
|
13
|
-
activesupport (=
|
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
|
-
|
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
|
-
|
23
|
-
|
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
|
-
|
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.
|
49
|
-
ffi (1.17.
|
50
|
-
ffi (1.17.
|
93
|
+
erubi (1.13.1)
|
94
|
+
ffi (1.17.1-arm64-darwin)
|
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.
|
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
|
-
|
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.
|
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 (
|
91
|
-
|
92
|
-
|
93
|
-
|
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.
|
167
|
+
rack-session (2.1.1)
|
168
|
+
base64 (>= 0.1.0)
|
102
169
|
rack (>= 3.0.0)
|
103
|
-
rack-test (2.
|
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
|
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.
|
193
|
+
rails-html-sanitizer (1.6.2)
|
113
194
|
loofah (~> 2.21)
|
114
|
-
nokogiri (
|
115
|
-
railties (
|
116
|
-
actionpack (=
|
117
|
-
activesupport (=
|
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,26 +221,47 @@ 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
|
-
|
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
|
155
252
|
arm64-darwin-22
|
156
253
|
arm64-darwin-23
|
254
|
+
arm64-darwin-24
|
157
255
|
x86_64-linux
|
158
256
|
|
159
257
|
DEPENDENCIES
|
258
|
+
actionpack (~> 8.0)
|
160
259
|
guard-rspec (~> 4.7)
|
260
|
+
rails (~> 8.0)
|
161
261
|
rake (~> 13.0)
|
162
262
|
rspec (~> 3.0)
|
263
|
+
rspec-rails (~> 6.0)
|
264
|
+
sqlite3
|
163
265
|
superform!
|
164
266
|
|
165
267
|
BUNDLED WITH
|