protos-protoform 0.0.1 → 0.0.2

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: c57b1b4645f529c7f8b132e92b0776a839448cd20eb3c689fbcf3689f2f7cfda
4
- data.tar.gz: da70f9680fed7bb2815deaa61ffb049ab9edfac706bb9e8b9e60f2ac8e5904a4
3
+ metadata.gz: fc22975fd2a29b54b0e5f1f5a92ef569fc78a3ab35f3a5672b8705703357c8e1
4
+ data.tar.gz: d249529bf058a94369abb9aebd56b4d5b0a68faab4c00831c57a6aa9373fc9c5
5
5
  SHA512:
6
- metadata.gz: 7dbee5d770d7efed179c43eb39892f8bf4fc8d7935b65160ab84876688a64bb3612a2226ffb421094c32412e895af9fbfcebe44872b54680b2cd7951f9d82c4d
7
- data.tar.gz: 8bd336c38077d8c15855329c01c63a9897320b62117e06a4f747b7f2f3e9c9849b4bf37a0bd4bce8d854e9994fd6c0fa19ba0551e2275ee8511ac57d4dab1bfa
6
+ metadata.gz: d45f5a2705117c6b87a225ec72c8f72605b8573907f9cd71e232a968ec5b2f0f4014d0250ae19ab1b78a83a82cddbdd9608e6d258028159d8e40eaed955eb17e
7
+ data.tar.gz: 2dffae4a6e8875b96075542e0d5a5218f0639933f8cc2d10f4b9a502c5a7ec6066d0153e39bbef9ddc08b54e13c9e356a7c84aafa58752422b35bc31488b6806
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2024-08-14
4
+
5
+ - Adds handling client supplied values like files and images
6
+ - Fixes overriding methods on forms when supplying a Rails model
7
+ - Adds `include_blank` option on select component to match Rails API
8
+ - Transfers ownership of repo from `nolantait` to `inhouse-work` organization to
9
+ match other `protos-` gems
10
+
3
11
  ## [0.1.0] - 2023-06-23
4
12
 
5
13
  - Initial release
data/Gemfile.lock CHANGED
@@ -3,46 +3,48 @@ PATH
3
3
  specs:
4
4
  protos-protoform (0.0.1)
5
5
  phlex-rails (~> 1.0)
6
- protos (~> 0.2)
6
+ protos (~> 0.4)
7
7
  zeitwerk (~> 2.6)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actionpack (7.1.3.2)
13
- actionview (= 7.1.3.2)
14
- activesupport (= 7.1.3.2)
12
+ actionpack (7.2.0)
13
+ actionview (= 7.2.0)
14
+ activesupport (= 7.2.0)
15
15
  nokogiri (>= 1.8.5)
16
16
  racc
17
- rack (>= 2.2.4)
17
+ rack (>= 2.2.4, < 3.2)
18
18
  rack-session (>= 1.0.1)
19
19
  rack-test (>= 0.6.3)
20
20
  rails-dom-testing (~> 2.2)
21
21
  rails-html-sanitizer (~> 1.6)
22
- actionview (7.1.3.2)
23
- activesupport (= 7.1.3.2)
22
+ useragent (~> 0.16)
23
+ actionview (7.2.0)
24
+ activesupport (= 7.2.0)
24
25
  builder (~> 3.1)
25
26
  erubi (~> 1.11)
26
27
  rails-dom-testing (~> 2.2)
27
28
  rails-html-sanitizer (~> 1.6)
28
- activemodel (7.1.3.2)
29
- activesupport (= 7.1.3.2)
30
- activesupport (7.1.3.2)
29
+ activemodel (7.2.0)
30
+ activesupport (= 7.2.0)
31
+ activesupport (7.2.0)
31
32
  base64
32
33
  bigdecimal
33
- concurrent-ruby (~> 1.0, >= 1.0.2)
34
+ concurrent-ruby (~> 1.0, >= 1.3.1)
34
35
  connection_pool (>= 2.2.5)
35
36
  drb
36
37
  i18n (>= 1.6, < 2)
38
+ logger (>= 1.4.2)
37
39
  minitest (>= 5.1)
38
- mutex_m
39
- tzinfo (~> 2.0)
40
- addressable (2.8.6)
41
- public_suffix (>= 2.0.2, < 6.0)
40
+ securerandom (>= 0.3)
41
+ tzinfo (~> 2.0, >= 2.0.5)
42
+ addressable (2.8.7)
43
+ public_suffix (>= 2.0.2, < 7.0)
42
44
  ast (2.4.2)
43
45
  base64 (0.2.0)
44
- bigdecimal (3.1.7)
45
- builder (3.2.4)
46
+ bigdecimal (3.1.8)
47
+ builder (3.3.0)
46
48
  capybara (3.40.0)
47
49
  addressable
48
50
  matrix
@@ -52,7 +54,7 @@ GEM
52
54
  rack-test (>= 0.6.3)
53
55
  regexp_parser (>= 1.5, < 3.0)
54
56
  xpath (~> 3.2)
55
- concurrent-ruby (1.2.3)
57
+ concurrent-ruby (1.3.4)
56
58
  connection_pool (2.4.1)
57
59
  crass (1.0.6)
58
60
  debug (1.9.2)
@@ -63,7 +65,7 @@ GEM
63
65
  dry-core (1.0.1)
64
66
  concurrent-ruby (~> 1.0)
65
67
  zeitwerk (~> 2.6)
66
- dry-inflector (1.0.0)
68
+ dry-inflector (1.1.0)
67
69
  dry-initializer (3.1.1)
68
70
  dry-logic (1.5.0)
69
71
  concurrent-ruby (~> 1.0)
@@ -76,47 +78,48 @@ GEM
76
78
  dry-inflector (~> 1.0)
77
79
  dry-logic (~> 1.4)
78
80
  zeitwerk (~> 2.6)
79
- erubi (1.12.0)
80
- i18n (1.14.4)
81
+ erubi (1.13.0)
82
+ i18n (1.14.5)
81
83
  concurrent-ruby (~> 1.0)
82
84
  io-console (0.7.2)
83
- irb (1.12.0)
84
- rdoc
85
+ irb (1.14.0)
86
+ rdoc (>= 4.0.0)
85
87
  reline (>= 0.4.2)
86
88
  json (2.7.2)
87
89
  language_server-protocol (3.17.0.3)
90
+ logger (1.6.0)
88
91
  loofah (2.22.0)
89
92
  crass (~> 1.0.2)
90
93
  nokogiri (>= 1.12.0)
91
94
  lru_redux (1.1.0)
92
95
  matrix (0.4.2)
93
96
  mini_mime (1.1.5)
94
- minitest (5.22.3)
95
- mutex_m (0.2.0)
96
- nokogiri (1.16.4-aarch64-linux)
97
+ minitest (5.25.0)
98
+ nokogiri (1.16.7-aarch64-linux)
97
99
  racc (~> 1.4)
98
- nokogiri (1.16.4-arm-linux)
100
+ nokogiri (1.16.7-arm-linux)
99
101
  racc (~> 1.4)
100
- nokogiri (1.16.4-arm64-darwin)
102
+ nokogiri (1.16.7-arm64-darwin)
101
103
  racc (~> 1.4)
102
- nokogiri (1.16.4-x86-linux)
104
+ nokogiri (1.16.7-x86-linux)
103
105
  racc (~> 1.4)
104
- nokogiri (1.16.4-x86_64-darwin)
106
+ nokogiri (1.16.7-x86_64-darwin)
105
107
  racc (~> 1.4)
106
- nokogiri (1.16.4-x86_64-linux)
108
+ nokogiri (1.16.7-x86_64-linux)
107
109
  racc (~> 1.4)
108
- parallel (1.24.0)
109
- parser (3.3.0.5)
110
+ parallel (1.26.2)
111
+ parser (3.3.4.2)
110
112
  ast (~> 2.4.1)
111
113
  racc
112
- phlex (1.10.0)
113
- phlex-rails (1.2.1)
114
- phlex (~> 1.10.0)
114
+ phlex (1.11.0)
115
+ phlex-rails (1.1.1)
116
+ phlex (~> 1.9)
115
117
  railties (>= 6.1, < 8)
118
+ zeitwerk (~> 2.6)
116
119
  phlex-testing-capybara (0.1.0)
117
120
  capybara (~> 3.38)
118
121
  phlex (>= 0.5)
119
- protos (0.4.1)
122
+ protos (0.4.3)
120
123
  dry-core (~> 1.0)
121
124
  dry-initializer (~> 3.1)
122
125
  dry-types (~> 1.7)
@@ -124,9 +127,9 @@ GEM
124
127
  tailwind_merge (~> 0.10)
125
128
  psych (5.1.2)
126
129
  stringio
127
- public_suffix (5.0.5)
128
- racc (1.7.3)
129
- rack (3.0.10)
130
+ public_suffix (6.0.1)
131
+ racc (1.8.1)
132
+ rack (3.1.7)
130
133
  rack-session (2.0.0)
131
134
  rack (>= 3.0.0)
132
135
  rack-test (2.1.0)
@@ -141,88 +144,92 @@ GEM
141
144
  rails-html-sanitizer (1.6.0)
142
145
  loofah (~> 2.21)
143
146
  nokogiri (~> 1.14)
144
- railties (7.1.3.2)
145
- actionpack (= 7.1.3.2)
146
- activesupport (= 7.1.3.2)
147
- irb
147
+ railties (7.2.0)
148
+ actionpack (= 7.2.0)
149
+ activesupport (= 7.2.0)
150
+ irb (~> 1.13)
148
151
  rackup (>= 1.0.0)
149
152
  rake (>= 12.2)
150
153
  thor (~> 1.0, >= 1.2.2)
151
154
  zeitwerk (~> 2.6)
152
155
  rainbow (3.1.1)
153
156
  rake (13.2.1)
154
- rdoc (6.6.3.1)
157
+ rdoc (6.7.0)
155
158
  psych (>= 4.0.0)
156
- regexp_parser (2.9.0)
157
- reline (0.5.1)
159
+ regexp_parser (2.9.2)
160
+ reline (0.5.9)
158
161
  io-console (~> 0.5)
159
- rexml (3.2.6)
162
+ rexml (3.3.5)
163
+ strscan
160
164
  rspec (3.13.0)
161
165
  rspec-core (~> 3.13.0)
162
166
  rspec-expectations (~> 3.13.0)
163
167
  rspec-mocks (~> 3.13.0)
164
168
  rspec-core (3.13.0)
165
169
  rspec-support (~> 3.13.0)
166
- rspec-expectations (3.13.0)
170
+ rspec-expectations (3.13.1)
167
171
  diff-lcs (>= 1.2.0, < 2.0)
168
172
  rspec-support (~> 3.13.0)
169
- rspec-mocks (3.13.0)
173
+ rspec-mocks (3.13.1)
170
174
  diff-lcs (>= 1.2.0, < 2.0)
171
175
  rspec-support (~> 3.13.0)
172
176
  rspec-support (3.13.1)
173
- rubocop (1.63.1)
177
+ rubocop (1.65.1)
174
178
  json (~> 2.3)
175
179
  language_server-protocol (>= 3.17.0)
176
180
  parallel (~> 1.10)
177
181
  parser (>= 3.3.0.2)
178
182
  rainbow (>= 2.2.2, < 4.0)
179
- regexp_parser (>= 1.8, < 3.0)
183
+ regexp_parser (>= 2.4, < 3.0)
180
184
  rexml (>= 3.2.5, < 4.0)
181
185
  rubocop-ast (>= 1.31.1, < 2.0)
182
186
  ruby-progressbar (~> 1.7)
183
187
  unicode-display_width (>= 2.4.0, < 3.0)
184
- rubocop-ast (1.31.2)
185
- parser (>= 3.3.0.4)
186
- rubocop-capybara (2.20.0)
187
- rubocop (~> 1.41)
188
- rubocop-factory_bot (2.25.1)
188
+ rubocop-ast (1.32.0)
189
+ parser (>= 3.3.1.0)
190
+ rubocop-capybara (2.21.0)
189
191
  rubocop (~> 1.41)
190
- rubocop-inhouse (0.1.5)
192
+ rubocop-factory_bot (2.26.1)
193
+ rubocop (~> 1.61)
194
+ rubocop-inhouse (0.1.9)
191
195
  rubocop (>= 1.5)
192
196
  rubocop-capybara (>= 2.1)
197
+ rubocop-factory_bot (>= 2.2)
193
198
  rubocop-performance (>= 1.1)
194
199
  rubocop-rails (>= 2.2)
195
200
  rubocop-rake (>= 0.6)
196
201
  rubocop-rspec (>= 2.2)
197
- rubocop-performance (1.21.0)
202
+ rubocop-rspec_rails (>= 2.2)
203
+ rubocop-performance (1.21.1)
198
204
  rubocop (>= 1.48.1, < 2.0)
199
205
  rubocop-ast (>= 1.31.1, < 2.0)
200
- rubocop-rails (2.24.1)
206
+ rubocop-rails (2.25.1)
201
207
  activesupport (>= 4.2.0)
202
208
  rack (>= 1.1)
203
209
  rubocop (>= 1.33.0, < 2.0)
204
210
  rubocop-ast (>= 1.31.1, < 2.0)
205
211
  rubocop-rake (0.6.0)
206
212
  rubocop (~> 1.0)
207
- rubocop-rspec (2.29.1)
208
- rubocop (~> 1.40)
209
- rubocop-capybara (~> 2.17)
210
- rubocop-factory_bot (~> 2.22)
211
- rubocop-rspec_rails (~> 2.28)
212
- rubocop-rspec_rails (2.28.3)
213
- rubocop (~> 1.40)
213
+ rubocop-rspec (3.0.4)
214
+ rubocop (~> 1.61)
215
+ rubocop-rspec_rails (2.30.0)
216
+ rubocop (~> 1.61)
217
+ rubocop-rspec (~> 3, >= 3.0.1)
214
218
  ruby-progressbar (1.13.0)
215
- stringio (3.1.0)
216
- tailwind_merge (0.11.0)
219
+ securerandom (0.3.1)
220
+ stringio (3.1.1)
221
+ strscan (3.1.0)
222
+ tailwind_merge (0.12.0)
217
223
  lru_redux (~> 1.1)
218
224
  thor (1.3.1)
219
225
  tzinfo (2.0.6)
220
226
  concurrent-ruby (~> 1.0)
221
227
  unicode-display_width (2.5.0)
228
+ useragent (0.16.10)
222
229
  webrick (1.8.1)
223
230
  xpath (3.2.0)
224
231
  nokogiri (~> 1.8)
225
- zeitwerk (2.6.13)
232
+ zeitwerk (2.6.17)
226
233
 
227
234
  PLATFORMS
228
235
  aarch64-linux
@@ -3,6 +3,16 @@
3
3
  class ApplicationForm < Protoform::Rails::Form
4
4
  include Phlex::Rails::Helpers::Pluralize
5
5
 
6
+ # These are the current dry-initializer options for the base class:
7
+ #
8
+ # param :model, reader: false
9
+ # option :helpers, reader: false, default: -> {}
10
+ # option :action, reader: false, default: -> {}
11
+ # option :method, reader: false, default: -> {}
12
+ # option :namespace, reader: false, default: -> do
13
+ # Namespace.root(key, object: @model, field_class: self.class::Field)
14
+ # end
15
+
6
16
  def row(component)
7
17
  div do
8
18
  render component.field.label(style: "display: block;")
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protoform
4
+ module Rails
5
+ Component = ::ApplicationComponent
6
+ end
7
+ end
@@ -16,10 +16,20 @@ module Protoform
16
16
  {
17
17
  id: dom.id,
18
18
  name: dom.name,
19
- type: @type
20
- }.tap do |hash|
21
- hash[:value] = field.value unless @type.to_sym == :file
22
- end
19
+ type: @type,
20
+ value:
21
+ }
22
+ end
23
+
24
+ def client_provided_value?
25
+ {
26
+ file: true,
27
+ image: true
28
+ }.fetch(@type.to_sym, false)
29
+ end
30
+
31
+ def value
32
+ dom.value unless client_provided_value?
23
33
  end
24
34
 
25
35
  def inferred_type
@@ -5,7 +5,7 @@ module Protoform
5
5
  module Components
6
6
  class Select < FieldComponent
7
7
  option :collection, default: -> { [] }
8
- option :include_blank, default: -> { true }
8
+ option :include_blank, default: -> { true }, reader: false
9
9
  option :multiple, reader: false, default: -> { false }
10
10
 
11
11
  def view_template(&options)
@@ -23,7 +23,7 @@ module Protoform
23
23
  select(multiple: @multiple, **attrs, name:, &options)
24
24
  else
25
25
  select(multiple: @multiple, **attrs, name:) do
26
- blank_option
26
+ blank_option if @include_blank
27
27
  options(*@collection)
28
28
  end
29
29
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Protoform
4
4
  module Rails
5
- Component = ::ApplicationComponent
6
5
  # A Protos::Component class that accepts a model and sets
7
6
  # a `Protoform::Namespace` with the `Object#model_name` as the key and maps
8
7
  # the object to form fields and namespaces.
@@ -16,9 +15,12 @@ module Protoform
16
15
  # `_method_field`.
17
16
  class Form < Component
18
17
  param :model, reader: false
18
+ option :authenticity_token, reader: false, default: -> { true }
19
19
  option :helpers, reader: false, default: -> {}
20
20
  option :action, reader: false, default: -> {}
21
- option :method, reader: false, default: -> {}
21
+ option :method,
22
+ reader: false,
23
+ default: -> {}
22
24
  option :namespace, reader: false, default: -> do
23
25
  Namespace.root(key, object: @model, field_class: self.class::Field)
24
26
  end
@@ -45,14 +47,20 @@ module Protoform
45
47
 
46
48
  def around_template(&block)
47
49
  form_tag do
48
- authenticity_token_field
50
+ authenticity_token_field if @authenticity_token
51
+
49
52
  _method_field
50
53
  super
51
54
  end
52
55
  end
53
56
 
54
57
  def form_tag(&block)
55
- form action:, method: form_method, **attrs, &block
58
+ form(
59
+ action: form_action,
60
+ method: form_method,
61
+ **attrs,
62
+ &block
63
+ )
56
64
  end
57
65
 
58
66
  def view_template(&block)
@@ -100,15 +108,17 @@ module Protoform
100
108
  end
101
109
 
102
110
  def resource_action
111
+ return :update if @method == :patch
112
+
103
113
  @model.persisted? ? :update : :create
104
114
  end
105
115
 
106
- def action
107
- @action ||= helpers.url_for(action: resource_action)
116
+ def form_action
117
+ @form_action ||= @action || helpers.url_for(action: resource_action)
108
118
  end
109
119
 
110
120
  def form_method
111
- @method.to_s.downcase == "get" ? "get" : "post"
121
+ @method == :get ? :get : :post
112
122
  end
113
123
 
114
124
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Protoform
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
data/lib/protoform.rb CHANGED
@@ -7,7 +7,6 @@ module Protoform
7
7
  Loader = Zeitwerk::Loader.for_gem.tap do |loader|
8
8
  loader.ignore "#{__dir__}/generators"
9
9
  loader.inflector.inflect(
10
- # rubocop:disable Style/StringHashKeys
11
10
  "dom" => "DOM"
12
11
  # rubocop:enable Style/StringHashKeys
13
12
  )
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "Phlex based form builder for Rails"
12
12
  spec.description = "Build phlex based forms using Rails conventions"
13
- spec.homepage = "https://github.com/nolantait/protos-protoform"
13
+ spec.homepage = "https://github.com/inhouse-work/protos-protoform"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 3.1.0"
16
16
 
@@ -43,7 +43,7 @@ Gem::Specification.new do |spec|
43
43
  spec.require_paths = ["lib"]
44
44
 
45
45
  spec.add_dependency "phlex-rails", "~> 1.0"
46
- spec.add_dependency "protos", "~> 0.2"
46
+ spec.add_dependency "protos", "~> 0.4"
47
47
  spec.add_dependency "zeitwerk", "~> 2.6"
48
48
  spec.metadata["rubygems_mfa_required"] = "true"
49
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protos-protoform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nolan Tait
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-13 00:00:00.000000000 Z
11
+ date: 2024-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phlex-rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.2'
33
+ version: '0.4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.2'
40
+ version: '0.4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: zeitwerk
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -77,6 +77,7 @@ files:
77
77
  - lib/protoform/namespace.rb
78
78
  - lib/protoform/namespace_collection.rb
79
79
  - lib/protoform/node.rb
80
+ - lib/protoform/rails/component.rb
80
81
  - lib/protoform/rails/components/button.rb
81
82
  - lib/protoform/rails/components/checkbox.rb
82
83
  - lib/protoform/rails/components/component.rb
@@ -91,14 +92,14 @@ files:
91
92
  - lib/protoform/rails/strong_parameters.rb
92
93
  - lib/protoform/version.rb
93
94
  - protos-protoform.gemspec
94
- homepage: https://github.com/nolantait/protos-protoform
95
+ homepage: https://github.com/inhouse-work/protos-protoform
95
96
  licenses:
96
97
  - MIT
97
98
  metadata:
98
99
  allowed_push_host: https://rubygems.org
99
- homepage_uri: https://github.com/nolantait/protos-protoform
100
- source_code_uri: https://github.com/nolantait/protos-protoform
101
- changelog_uri: https://github.com/nolantait/protos-protoform
100
+ homepage_uri: https://github.com/inhouse-work/protos-protoform
101
+ source_code_uri: https://github.com/inhouse-work/protos-protoform
102
+ changelog_uri: https://github.com/inhouse-work/protos-protoform
102
103
  rubygems_mfa_required: 'true'
103
104
  post_install_message:
104
105
  rdoc_options: []
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  - !ruby/object:Gem::Version
116
117
  version: '0'
117
118
  requirements: []
118
- rubygems_version: 3.5.7
119
+ rubygems_version: 3.5.17
119
120
  signing_key:
120
121
  specification_version: 4
121
122
  summary: Phlex based form builder for Rails