phlexi-form 0.10.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: d8ef146b4a3e5a10911b90b8593e26065efbc88f5f532972cef9d3181b320828
4
- data.tar.gz: 4d3bbbfd5a9c808215c134fc4c1110a9e0b01ef39d10ab75d9051ae370f6c7c5
3
+ metadata.gz: 106d09b69decc61c3f693c7bd50a85c6dee95cb50d10f55c164795d90a087f4f
4
+ data.tar.gz: f5cd60c63b841278ce59341bd83d94c95d91bff915f85badded8df504cb6688a
5
5
  SHA512:
6
- metadata.gz: 2d42262ece5062a97b5b817cba73599841f0d0654ebe3fbd60243eff3b1994af904bfe02e2d3549220bd7f78a9a434d7777631eaa7d9d22d0606972edec56ace
7
- data.tar.gz: 7fd209a0829a4917c50b0204ddd2c328e12e5cbc8a8548e2308e61a5aa9c02ae3443d68a2e2f36a32233e95b38b120dd0dab1705df8aab2a940a19a3e41d3018
6
+ metadata.gz: ebbe8058ed302df8008a784c163218ec967f5eb9bbec2206b5282a72da0669ddacf39c387ce2aeb47e61e257f18c36ceb5215daf85182c4893f4267391ff9fea
7
+ data.tar.gz: a683a72949fc9acc5d6dcd8b1a52c4da3451c57d89fcd770694b83dba1fcc34001b8fa394e5d9b00b56c95a7bea73d3b7e6eff991bb994c9c9a2517ee23fff23
@@ -104,7 +104,7 @@ module Phlexi
104
104
 
105
105
  unless @_state
106
106
  raise ArgumentError, "view_context is required if Form has not been rendered" unless view_context
107
- view_context.render(self)
107
+ view_context.render(self)
108
108
  end
109
109
  @namespace.extract_input(params)
110
110
  end
@@ -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
@@ -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.10.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.10.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-19 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
@@ -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