phlexi-form 0.9.0 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4426a2bd7631d79ae6aa2fc2e7029c0ba8fe10e2303faddd25576e9bbd34f213
4
- data.tar.gz: a45574cf4ba9ba4fd58600b4ef1fd7b88211b67cc9301bd763fab3ef988cd656
3
+ metadata.gz: 106d09b69decc61c3f693c7bd50a85c6dee95cb50d10f55c164795d90a087f4f
4
+ data.tar.gz: f5cd60c63b841278ce59341bd83d94c95d91bff915f85badded8df504cb6688a
5
5
  SHA512:
6
- metadata.gz: e6e8686ae98221fab10744deab18a0ebcc819247f8a8557030c63a39ec99bd5ae6eca894f75b3268e88716e3ac484bed64d355847c7ab764a4a75896a18e51a4
7
- data.tar.gz: aa7e07d589abe7c8edc1d289371e2fa9e3cfd14d03992914ff92475e756e4c4d5233022063cd9b5979a0d7dd0e1fade98a10acd18d8fdb049ea4629d9039793d
6
+ metadata.gz: ebbe8058ed302df8008a784c163218ec967f5eb9bbec2206b5282a72da0669ddacf39c387ce2aeb47e61e257f18c36ceb5215daf85182c4893f4267391ff9fea
7
+ data.tar.gz: a683a72949fc9acc5d6dcd8b1a52c4da3451c57d89fcd770694b83dba1fcc34001b8fa394e5d9b00b56c95a7bea73d3b7e6eff991bb994c9c9a2517ee23fff23
@@ -102,7 +102,10 @@ module Phlexi
102
102
  params = params.to_unsafe_h if params.respond_to?(:to_unsafe_h)
103
103
  params = {} unless params.is_a?(Hash)
104
104
 
105
- call(view_context: view_context) unless @_rendered
105
+ unless @_state
106
+ raise ArgumentError, "view_context is required if Form has not been rendered" unless view_context
107
+ view_context.render(self)
108
+ end
106
109
  @namespace.extract_input(params)
107
110
  end
108
111
 
@@ -5,6 +5,7 @@ module Phlexi
5
5
  # Builder class is responsible for building form fields with various options and components.
6
6
  class Builder < Phlexi::Field::Builder
7
7
  include Phlexi::Form::HTML::Behaviour
8
+ include Phlexi::Field::Common::Tokens
8
9
  include Options::Validators
9
10
  include Options::InferredTypes
10
11
  include Options::Errors
@@ -96,6 +97,7 @@ module Phlexi
96
97
  input_tag(type: :hidden, theme: nil, **, &)
97
98
  end
98
99
  alias_method :hidden_tag, :hidden_input_tag
100
+
99
101
  # Creates a checkbox tag for the field.
100
102
  #
101
103
  # @param attributes [Hash] Additional attributes for the checkbox.
@@ -113,6 +115,14 @@ module Phlexi
113
115
  end
114
116
  alias_method :file_tag, :file_input_tag
115
117
 
118
+ # Creates a checkbox tag for the field.
119
+ #
120
+ # @param attributes [Hash] Additional attributes for the checkbox.
121
+ # @return [Components::Checkbox] The checkbox component.
122
+ def range_tag(**, &)
123
+ create_component(Components::Range, :range, **, &)
124
+ end
125
+
116
126
  # Creates collection checkboxes for the field.
117
127
  #
118
128
  # @param attributes [Hash] Additional attributes for the collection checkboxes.
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Phlexi
4
+ module Form
5
+ module Components
6
+ class Range < Input
7
+ def view_template
8
+ input(**attributes, value: @checked_value)
9
+ end
10
+
11
+ protected
12
+
13
+ def build_input_attributes
14
+ attributes[:type] = :range
15
+ super
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -13,6 +13,7 @@ module Phlexi
13
13
  end
14
14
 
15
15
  include Behaviour
16
+ include Phlexi::Field::Common::Tokens
16
17
  end
17
18
  end
18
19
  end
@@ -17,7 +17,7 @@ module Phlexi
17
17
 
18
18
  def infer_choices
19
19
  if object.class.respond_to?(:defined_enums)
20
- return object.class.defined_enums.fetch(key.to_s).keys if object.class.defined_enums.key?(key.to_s)
20
+ return object.class.defined_enums.fetch(key.to_s).keys.map { |k| [k.humanize, k] } if object.class.defined_enums.key?(key.to_s)
21
21
  end
22
22
 
23
23
  choices_from_validator
@@ -102,6 +102,12 @@ module Phlexi
102
102
  invalid_checkbox: :invalid_input,
103
103
  neutral_checkbox: :neutral_input,
104
104
 
105
+ # Range
106
+ range: :input,
107
+ valid_range: :valid_input,
108
+ invalid_range: :invalid_input,
109
+ neutral_range: :neutral_input,
110
+
105
111
  # Radio
106
112
  radio_button: :input,
107
113
  valid_radio_button: :valid_input,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Phlexi
4
4
  module Form
5
- VERSION = "0.9.0"
5
+ VERSION = "0.11.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlexi-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-05-10 00:00:00.000000000 Z
11
+ date: 2025-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phlex
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.0
33
+ version: 0.2.0
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.1.0
40
+ version: 0.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -227,6 +227,7 @@ files:
227
227
  - lib/phlexi/form/components/input_array.rb
228
228
  - lib/phlexi/form/components/label.rb
229
229
  - lib/phlexi/form/components/radio_button.rb
230
+ - lib/phlexi/form/components/range.rb
230
231
  - lib/phlexi/form/components/select.rb
231
232
  - lib/phlexi/form/components/submit_button.rb
232
233
  - lib/phlexi/form/components/textarea.rb