lifeform 0.7 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +5 -5
- data/README.md +14 -2
- data/lib/lifeform/form.rb +12 -2
- data/lib/lifeform/libraries/shoelace/button.rb +13 -0
- data/lib/lifeform/libraries/shoelace/submit_button.rb +16 -0
- data/lib/lifeform/version.rb +1 -1
- data/lib/lifeform.rb +9 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aee8bd917892bd755a79f5b580dccaf4b9b07a7ae16e51c3e428e6f13ac885c
|
4
|
+
data.tar.gz: 5c744b0db1da3987634fbc5e6d84489023a781a797df187d85546daf26d09764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce074a7348e1ed0efb16ce57a61a76402a38d5ffea247c8af01a27c7dfc4aa9f4a537a91d23642d8c419ae2458f4057818dc05ade817dd01408782516edffc40
|
7
|
+
data.tar.gz: 4ebdb9894c4d980516b870c6cf504e2a8cb0d7141d5a65916398de0abf3ae483700b12bc6b13df7dde95e5feccba849b68a228ff8dfaf249396bab751e849c8c
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
+
## [0.9.0] - 2022-11-06
|
6
|
+
|
7
|
+
- Add button & submit button support for Shoelace
|
8
|
+
|
9
|
+
## [0.8.0] - 2022-10-09
|
10
|
+
|
11
|
+
- Add initializer for Bridgetown 1.2+
|
12
|
+
- Fix for Roda csrf
|
13
|
+
|
5
14
|
## [0.7.0] - 2022-09-30
|
6
15
|
|
7
16
|
- Rearchitect library to be built on top of the Phlex view library
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lifeform (0.
|
4
|
+
lifeform (0.9.0)
|
5
5
|
activesupport (>= 6.0)
|
6
6
|
phlex (~> 0.3)
|
7
7
|
zeitwerk (~> 2.5)
|
@@ -43,10 +43,10 @@ GEM
|
|
43
43
|
parallel (1.22.1)
|
44
44
|
parser (3.1.2.1)
|
45
45
|
ast (~> 2.4.1)
|
46
|
-
phlex (0.
|
46
|
+
phlex (0.4.0)
|
47
47
|
syntax_tree (~> 3.6)
|
48
48
|
zeitwerk (~> 2.6)
|
49
|
-
prettier_print (
|
49
|
+
prettier_print (1.0.2)
|
50
50
|
racc (1.6.0)
|
51
51
|
rails-dom-testing (2.0.3)
|
52
52
|
activesupport (>= 4.2.0)
|
@@ -89,7 +89,7 @@ GEM
|
|
89
89
|
thor (~> 1.0)
|
90
90
|
tilt (~> 2.0)
|
91
91
|
yard (~> 0.9, >= 0.9.24)
|
92
|
-
syntax_tree (3.6.
|
92
|
+
syntax_tree (3.6.3)
|
93
93
|
prettier_print
|
94
94
|
thor (1.2.1)
|
95
95
|
tilt (2.0.11)
|
@@ -99,7 +99,7 @@ GEM
|
|
99
99
|
webrick (1.7.0)
|
100
100
|
yard (0.9.28)
|
101
101
|
webrick (~> 1.7.0)
|
102
|
-
zeitwerk (2.6.
|
102
|
+
zeitwerk (2.6.5)
|
103
103
|
|
104
104
|
PLATFORMS
|
105
105
|
arm64-darwin-21
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Lifeform
|
2
2
|
|
3
|
-
Component-centric form object rendering for Ruby.
|
3
|
+
Component-centric form object rendering for Ruby. Powered by [Phlex](https://www.phlex.fun)
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -28,13 +28,25 @@ end
|
|
28
28
|
And a template rendering of:
|
29
29
|
|
30
30
|
```erb
|
31
|
-
|
31
|
+
<!-- ERB -->
|
32
|
+
<%= render TestForm.new(url: "/path") do |f| %>
|
32
33
|
<%= render f.field(:occupation) %>
|
33
34
|
<%= render f.field(:age, value: 47) %>
|
34
35
|
<%= render f.field(:submit) %>
|
35
36
|
<% end %>
|
36
37
|
```
|
37
38
|
|
39
|
+
```rb
|
40
|
+
# Or Phlex:
|
41
|
+
def template
|
42
|
+
render TestForm.new(url: "/path") do |f|
|
43
|
+
render f.field(:occupation)
|
44
|
+
render f.field(:age, value: 47)
|
45
|
+
render f.field(:submit)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
38
50
|
You get the following HTML output:
|
39
51
|
|
40
52
|
```html
|
data/lib/lifeform/form.rb
CHANGED
@@ -86,6 +86,16 @@ module Lifeform
|
|
86
86
|
model.class.name.underscore.tr("/", "_")
|
87
87
|
end
|
88
88
|
end
|
89
|
+
|
90
|
+
# @return [Array<Symbol>]
|
91
|
+
def param_keys
|
92
|
+
fields.keys
|
93
|
+
end
|
94
|
+
|
95
|
+
# @return [Array<String>]
|
96
|
+
def param_string_keys
|
97
|
+
fields.keys.map(&:to_s)
|
98
|
+
end
|
89
99
|
end
|
90
100
|
|
91
101
|
# @return [Object]
|
@@ -114,7 +124,7 @@ module Lifeform
|
|
114
124
|
@library = Libraries.const_get(@library_name.to_s.classify)
|
115
125
|
@subform_instances = {}
|
116
126
|
|
117
|
-
parameters[:method] ||= model.respond_to?(:persisted?) && model.persisted? ? :patch : :post
|
127
|
+
@method = parameters[:method] ||= model.respond_to?(:persisted?) && model.persisted? ? :patch : :post
|
118
128
|
parameters[:accept_charset] ||= "UTF-8"
|
119
129
|
verify_method
|
120
130
|
end
|
@@ -142,7 +152,7 @@ module Lifeform
|
|
142
152
|
method: parameters[:method].to_s.downcase
|
143
153
|
})
|
144
154
|
elsif helpers.respond_to?(:csrf_tag, true) # Roda
|
145
|
-
helpers.send(:csrf_tag,
|
155
|
+
helpers.send(:csrf_tag, parameters[:action].to_s, @method.to_s)
|
146
156
|
else
|
147
157
|
raise Lifeform::Error, "Missing token tag helper. Override `add_authenticity_token' in your Form object"
|
148
158
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lifeform
|
4
|
+
module Libraries
|
5
|
+
class Shoelace
|
6
|
+
class SubmitButton < Button
|
7
|
+
def initialize(form, field_definition, **attributes)
|
8
|
+
attributes[:name] ||= "commit"
|
9
|
+
attributes[:type] = "submit"
|
10
|
+
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/lifeform/version.rb
CHANGED
data/lib/lifeform.rb
CHANGED
@@ -10,3 +10,12 @@ loader.setup
|
|
10
10
|
module Lifeform
|
11
11
|
class Error < StandardError; end
|
12
12
|
end
|
13
|
+
|
14
|
+
if defined?(Bridgetown)
|
15
|
+
# Check compatibility
|
16
|
+
raise "The Lifeform support for Bridgetown requires v1.2 or newer" if Bridgetown::VERSION.to_f < 1.2
|
17
|
+
|
18
|
+
Bridgetown.initializer :lifeform do |config|
|
19
|
+
# no extra config at the moment
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lifeform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -79,7 +79,9 @@ files:
|
|
79
79
|
- lib/lifeform/libraries/default/input.rb
|
80
80
|
- lib/lifeform/libraries/default/submit_button.rb
|
81
81
|
- lib/lifeform/libraries/shoelace.rb
|
82
|
+
- lib/lifeform/libraries/shoelace/button.rb
|
82
83
|
- lib/lifeform/libraries/shoelace/input.rb
|
84
|
+
- lib/lifeform/libraries/shoelace/submit_button.rb
|
83
85
|
- lib/lifeform/version.rb
|
84
86
|
- lifeform.gemspec
|
85
87
|
homepage: https://github.com/bridgetownrb/lifeform
|