railsui 3.3.3 → 3.3.4

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: 91c80ec9979b1733f5b8386293ea0ea811914183990c21a9cbdf32f9a2f70499
4
- data.tar.gz: 82772b01f627598e260a2eb99839b4507ad416ed72ccb5d00d120de50dc92f4e
3
+ metadata.gz: dadbd162b710fe37b5f3a8c1d12538e23290b1652c2f90652d35669b718941f2
4
+ data.tar.gz: '09ddaced31a1058061739cfc164b6c29f2ffde9c1ef6d91cc96c2ba474d8a28a'
5
5
  SHA512:
6
- metadata.gz: 11d7b0cbb59d10e6df02d28ea05659c4dc04bd9f3b4ce4033e12f1432c970093f0ad7be3e128c1e29e006f8077e99a5edc4c80869495ec181e718d157636cbfe
7
- data.tar.gz: 8a80e1564b7cf72c06e348f12956e75fd52e1ba4b5702f8b4f65c1346e08c3bcacfcdea9e0ab6af58469f79877daa573b0d60d7ec3017ec300075e1263066235
6
+ metadata.gz: f88b5bd9420d7c99f3f8cc176dc8d1ad4d4c9b48677d9ce67dc14f6ad9cd9bb513053c36c2128226a5be5650e8c918db0eb9510692f66eaffdbd07f5ad2e0ad7
7
+ data.tar.gz: ab700bc730c0df7de0d8e27dbcd0999e38b3c07eb9d4a7ad7329343970480723b44fbe6fb333c6c40573938cf33ef3315387069138c9244a5e18efcfc1a32f65
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- railsui (3.3.3)
4
+ railsui (3.3.4)
5
5
  meta-tags
6
6
  psych
7
7
  rails (>= 7.0)
@@ -108,13 +108,21 @@ module Railsui
108
108
  super(method, choices, options, html_options)
109
109
  end
110
110
  end
111
-
111
+
112
112
  def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
113
- wrapper_options = options.delete(:wrapper) || {}
113
+ wrapper_options = options.delete(:wrapper)
114
114
  label_text = options.delete(:label)
115
115
  label_class = options.delete(:label_class) || "form-label"
116
116
  is_required = options.delete(:required) || false
117
117
 
118
+ # If wrapper is explicitly false, return just the checkbox without wrapping
119
+ if wrapper_options == false
120
+ add_error_class!(options) if has_error?(method)
121
+ return super(method, options, checked_value, unchecked_value)
122
+ end
123
+
124
+ wrapper_options ||= {}
125
+
118
126
  # Set default flex layout for the wrapper
119
127
  wrapper_class = "flex items-center justify-start gap-2"
120
128
  wrapper_options[:class] = [wrapper_class, wrapper_options[:class]].compact.join(" ")
@@ -136,9 +144,17 @@ module Railsui
136
144
  end
137
145
 
138
146
  def radio_button(method, tag_value, options = {})
139
- wrapper_options = options.delete(:wrapper) || {}
147
+ wrapper_options = options.delete(:wrapper)
140
148
  label_text = options.delete(:label)
141
149
 
150
+ # If wrapper is explicitly false, return just the radio button without wrapping
151
+ if wrapper_options == false
152
+ add_error_class!(options) if has_error?(method)
153
+ return super(method, tag_value, options)
154
+ end
155
+
156
+ wrapper_options ||= {}
157
+
142
158
  # Set default flex layout for the wrapper
143
159
  wrapper_class = "flex items-center justify-start gap-2"
144
160
  wrapper_options[:class] = [wrapper_class, wrapper_options[:class]].compact.join(" ")
@@ -192,16 +208,24 @@ module Railsui
192
208
 
193
209
 
194
210
  def switch_field(method, options = {})
211
+ wrapper_options = options.delete(:wrapper)
195
212
  label_text = options.delete(:label) || method.to_s.humanize
196
213
 
197
- field_wrapper(method, options.merge(label: false)) do
198
- add_default_class!(options, "form-input-switch")
199
- add_error_class!(options) if has_error?(method)
214
+ add_default_class!(options, "form-input-switch")
215
+ add_error_class!(options) if has_error?(method)
216
+
217
+ # Create switch input without hidden field
218
+ switch_html = @template.check_box(@object_name, method, objectify_options(options.merge(include_hidden: false)), "1", "0")
219
+ label_html = label(method, label_text, class: "")
220
+ switch_content = safe_join([switch_html, label_html])
221
+
222
+ # If wrapper is explicitly false, return just the switch without wrapping
223
+ if wrapper_options == false
224
+ return switch_content
225
+ end
200
226
 
201
- # Create switch input without hidden field
202
- switch_html = @template.check_box(@object_name, method, objectify_options(options.merge(include_hidden: false)), "1", "0")
203
- label_html = label(method, label_text)
204
- safe_join([switch_html, label_html])
227
+ field_wrapper(method, { wrapper: wrapper_options, label: false }) do
228
+ switch_content
205
229
  end
206
230
  end
207
231
 
@@ -240,7 +264,7 @@ module Railsui
240
264
  end
241
265
 
242
266
  def form_help(text, options = {})
243
- add_default_class!(options, "form-help text-xs")
267
+ add_default_class!(options, "form-help")
244
268
  content_tag(:p, text, options)
245
269
  end
246
270
 
@@ -310,5 +334,15 @@ module Railsui
310
334
  validator.is_a?(ActiveModel::Validations::PresenceValidator)
311
335
  end
312
336
  end
337
+
338
+ private
339
+
340
+ def required_field?(method)
341
+ return false unless @object.class.respond_to?(:validators_on)
342
+
343
+ @object.class.validators_on(method).any? do |validator|
344
+ validator.is_a?(ActiveModel::Validations::PresenceValidator)
345
+ end
346
+ end
313
347
  end
314
348
  end
@@ -1,3 +1,3 @@
1
1
  module Railsui
2
- VERSION = "3.3.3"
2
+ VERSION = "3.3.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railsui
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Leverenz
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-01-17 00:00:00.000000000 Z
10
+ date: 2026-01-19 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails