superform 0.6.0 → 0.7.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 +100 -3
- data/CLAUDE.md +46 -0
- data/Gemfile.lock +6 -1
- data/README.md +208 -75
- data/examples/basic_form.rb +21 -0
- data/examples/checkbox_form.rb +28 -0
- data/examples/date_time_form.rb +18 -0
- data/examples/example_form.rb +10 -0
- data/examples/select_form.rb +26 -0
- data/examples/special_inputs_form.rb +23 -0
- data/examples/textarea_form.rb +15 -0
- data/lib/generators/superform/install/templates/base.rb +33 -7
- data/lib/superform/dom.rb +13 -1
- data/lib/superform/field.rb +14 -9
- data/lib/superform/rails/choices/choice.rb +39 -0
- data/lib/superform/rails/choices/mapper.rb +41 -0
- data/lib/superform/rails/choices.rb +6 -0
- data/lib/superform/rails/components/base.rb +9 -2
- data/lib/superform/rails/components/checkbox.rb +34 -7
- data/lib/superform/rails/components/checkboxes.rb +38 -0
- data/lib/superform/rails/components/datalist.rb +34 -0
- data/lib/superform/rails/components/input.rb +1 -1
- data/lib/superform/rails/components/label.rb +1 -1
- data/lib/superform/rails/components/radio.rb +21 -0
- data/lib/superform/rails/components/radios.rb +38 -0
- data/lib/superform/rails/components/select.rb +52 -8
- data/lib/superform/rails/field.rb +184 -0
- data/lib/superform/rails/form.rb +18 -129
- data/lib/superform/version.rb +1 -1
- data/server/components/breadcrumb.rb +11 -0
- data/server/components/form_card.rb +13 -0
- data/server/components/layout.rb +23 -0
- data/server/controllers/forms_controller.rb +94 -0
- data/server/models/example.rb +31 -0
- data/server/public/styles.css +282 -0
- data/server/rails.rb +56 -0
- data/superform.gemspec +37 -0
- metadata +28 -5
- data/lib/superform/rails/option_mapper.rb +0 -36
data/superform.gemspec
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/superform/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "superform"
|
|
7
|
+
spec.version = Superform::VERSION
|
|
8
|
+
spec.authors = ["Brad Gessler"]
|
|
9
|
+
spec.email = ["bradgessler@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Build forms in Rails"
|
|
12
|
+
spec.description = "A better way to customize and build forms for your Rails application"
|
|
13
|
+
spec.homepage = "https://github.com/rubymonolith/superform"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = ">= 2.7.0"
|
|
16
|
+
|
|
17
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
18
|
+
|
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/rubymonolith/superform"
|
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/rubymonolith/superform"
|
|
22
|
+
|
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
25
|
+
spec.files = Dir.chdir(__dir__) do
|
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
spec.bindir = "exe"
|
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
32
|
+
spec.require_paths = ["lib"]
|
|
33
|
+
|
|
34
|
+
# 2.0 rcs, betas, etc.
|
|
35
|
+
spec.add_dependency "phlex-rails", "~> 2.0"
|
|
36
|
+
spec.add_dependency "zeitwerk", "~> 2.6"
|
|
37
|
+
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: superform
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brad Gessler
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-03-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: phlex-rails
|
|
@@ -46,6 +46,7 @@ extra_rdoc_files: []
|
|
|
46
46
|
files:
|
|
47
47
|
- ".rspec"
|
|
48
48
|
- CHANGELOG.md
|
|
49
|
+
- CLAUDE.md
|
|
49
50
|
- CODE_OF_CONDUCT.md
|
|
50
51
|
- Gemfile
|
|
51
52
|
- Gemfile.lock
|
|
@@ -54,6 +55,13 @@ files:
|
|
|
54
55
|
- README.md
|
|
55
56
|
- Rakefile
|
|
56
57
|
- SPEC_STYLE_GUIDE.md
|
|
58
|
+
- examples/basic_form.rb
|
|
59
|
+
- examples/checkbox_form.rb
|
|
60
|
+
- examples/date_time_form.rb
|
|
61
|
+
- examples/example_form.rb
|
|
62
|
+
- examples/select_form.rb
|
|
63
|
+
- examples/special_inputs_form.rb
|
|
64
|
+
- examples/textarea_form.rb
|
|
57
65
|
- lib/generators/superform/install/USAGE
|
|
58
66
|
- lib/generators/superform/install/install_generator.rb
|
|
59
67
|
- lib/generators/superform/install/templates/base.rb
|
|
@@ -66,19 +74,34 @@ files:
|
|
|
66
74
|
- lib/superform/namespace_collection.rb
|
|
67
75
|
- lib/superform/node.rb
|
|
68
76
|
- lib/superform/rails.rb
|
|
77
|
+
- lib/superform/rails/choices.rb
|
|
78
|
+
- lib/superform/rails/choices/choice.rb
|
|
79
|
+
- lib/superform/rails/choices/mapper.rb
|
|
69
80
|
- lib/superform/rails/components/base.rb
|
|
70
81
|
- lib/superform/rails/components/button.rb
|
|
71
82
|
- lib/superform/rails/components/checkbox.rb
|
|
83
|
+
- lib/superform/rails/components/checkboxes.rb
|
|
84
|
+
- lib/superform/rails/components/datalist.rb
|
|
72
85
|
- lib/superform/rails/components/field.rb
|
|
73
86
|
- lib/superform/rails/components/input.rb
|
|
74
87
|
- lib/superform/rails/components/label.rb
|
|
88
|
+
- lib/superform/rails/components/radio.rb
|
|
89
|
+
- lib/superform/rails/components/radios.rb
|
|
75
90
|
- lib/superform/rails/components/select.rb
|
|
76
91
|
- lib/superform/rails/components/textarea.rb
|
|
92
|
+
- lib/superform/rails/field.rb
|
|
77
93
|
- lib/superform/rails/form.rb
|
|
78
|
-
- lib/superform/rails/option_mapper.rb
|
|
79
94
|
- lib/superform/rails/strong_parameters.rb
|
|
80
95
|
- lib/superform/version.rb
|
|
96
|
+
- server/components/breadcrumb.rb
|
|
97
|
+
- server/components/form_card.rb
|
|
98
|
+
- server/components/layout.rb
|
|
99
|
+
- server/controllers/forms_controller.rb
|
|
100
|
+
- server/models/example.rb
|
|
101
|
+
- server/public/styles.css
|
|
102
|
+
- server/rails.rb
|
|
81
103
|
- sig/superform.rbs
|
|
104
|
+
- superform.gemspec
|
|
82
105
|
homepage: https://github.com/rubymonolith/superform
|
|
83
106
|
licenses:
|
|
84
107
|
- MIT
|
|
@@ -94,14 +117,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
94
117
|
requirements:
|
|
95
118
|
- - ">="
|
|
96
119
|
- !ruby/object:Gem::Version
|
|
97
|
-
version: 2.
|
|
120
|
+
version: 2.7.0
|
|
98
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
122
|
requirements:
|
|
100
123
|
- - ">="
|
|
101
124
|
- !ruby/object:Gem::Version
|
|
102
125
|
version: '0'
|
|
103
126
|
requirements: []
|
|
104
|
-
rubygems_version: 3.6.
|
|
127
|
+
rubygems_version: 3.6.2
|
|
105
128
|
specification_version: 4
|
|
106
129
|
summary: Build forms in Rails
|
|
107
130
|
test_files: []
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
module Superform
|
|
2
|
-
module Rails
|
|
3
|
-
# Accept a collection of objects and map them to options suitable for form controls, like `select > options`
|
|
4
|
-
class OptionMapper
|
|
5
|
-
include Enumerable
|
|
6
|
-
|
|
7
|
-
def initialize(collection)
|
|
8
|
-
@collection = collection
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def each(&options)
|
|
12
|
-
@collection.each do |object|
|
|
13
|
-
case object
|
|
14
|
-
in ActiveRecord::Relation => relation
|
|
15
|
-
active_record_relation_options_enumerable(relation).each(&options)
|
|
16
|
-
in id, value
|
|
17
|
-
options.call id, value
|
|
18
|
-
in value
|
|
19
|
-
options.call value, value.to_s
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def active_record_relation_options_enumerable(relation)
|
|
25
|
-
Enumerator.new do |collection|
|
|
26
|
-
relation.each do |object|
|
|
27
|
-
attributes = object.attributes
|
|
28
|
-
id = attributes.delete(relation.primary_key)
|
|
29
|
-
value = attributes.values.join(" ")
|
|
30
|
-
collection << [ id, value ]
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|