sdr_view_components 0.1.8 → 0.1.9

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: 6ed77ab15d611e21337871d3d410b784454ec8e1a356fe91050b2250d7bc7d14
4
- data.tar.gz: 10f9d789b3ca10d8b1bef44adf1dbb61639267115340f6d113d08d2d70d54002
3
+ metadata.gz: 1afffad2e6ed29d15558f17747dede5386da6e4535767947fb6b1970985f436e
4
+ data.tar.gz: 60a9a0124d9d480c4194933f1548d1e2dd2b499d67ef6254199afc3e8e734abe
5
5
  SHA512:
6
- metadata.gz: 05475af8c2288f5f14ccfc0590fdb86374f530df207cf3fd82aa877d2377dbc91af5fde8742db8a74b16f6ef3dd1135a03450ec0a0bc083d0e4d4de404656844
7
- data.tar.gz: fe4975a4869e202997e972c67999d66f9e729e7edc0e26f68ab83aaa7b6690579b6e0fa06a263f083c42f0fad2e81c1fead6d527235079dedb6fae7ff7c6e0b8
6
+ metadata.gz: ef3eb4a9b57b8664d1d4991c7707094e2bbe21760fee98bb400a752e6400663460214b8a8d085b9848ca5eae9f1c753bce68f093f637fecb369657829309920d
7
+ data.tar.gz: '0229b05c83c16f0d3404efe05369dd8b6b2de73286c8b0b9c8c0568febfb82abc853e8dc812ae738f68fd808016281cad65ff0606c7376ab1a72b15c8a5f57d8'
@@ -7,6 +7,10 @@ module SdrViewComponents
7
7
  def call
8
8
  form.file_field field_name, class: classes, **args
9
9
  end
10
+
11
+ def classes
12
+ merge_classes('form-control', @classes)
13
+ end
10
14
  end
11
15
  end
12
16
  end
@@ -7,6 +7,7 @@ module SdrViewComponents
7
7
  def initialize(**args)
8
8
  args[:container_classes] = merge_classes('form-check', args[:container_classes])
9
9
  args[:label_default_class] = 'form-check-label'
10
+ args[:variant] = :help_text_below
10
11
  super
11
12
  end
12
13
 
@@ -1,8 +1,9 @@
1
1
  <%= tag.div class: container_classes, **container_args do %>
2
2
  <%= render SdrViewComponents::Forms::LabelComponent.new(form:, field_name: label_field_name, **label_args) %>
3
- <%= render SdrViewComponents::Forms::HelpTextComponent.new(**help_text_args) %>
3
+ <%= render SdrViewComponents::Forms::HelpTextComponent.new(**help_text_args) unless help_text_below? %>
4
4
  <%= render input_component %>
5
5
  <%= render SdrViewComponents::Forms::InvalidFeedbackComponent.new(form:, field_name:, **error_args) %>
6
+ <%= render SdrViewComponents::Forms::HelpTextComponent.new(**help_text_args) if help_text_below? %>
6
7
 
7
8
  <%= additional_container_content %>
8
9
  <% end %>
@@ -6,15 +6,20 @@ module SdrViewComponents
6
6
  class FieldComponent < BaseComponent
7
7
  renders_one :additional_container_content
8
8
 
9
- def initialize(form:, field_name:, container_classes: [], **args)
9
+ def initialize(form:, field_name:, container_classes: [], variant: :default, **args)
10
10
  @form = form
11
11
  @field_name = field_name
12
12
  @container_classes = container_classes
13
+ @variant = variant
14
+ # In the help_text_below variant, the help text is rendered below the input field.
15
+ # This is necessary for some types of fields such as checkboxes.
16
+ raise ArgumentError, 'invalid variant' unless %i[default help_text_below].include?(@variant)
17
+
13
18
  @args = args
14
19
  super()
15
20
  end
16
21
 
17
- attr_reader :form, :args, :field_name
22
+ attr_reader :form, :args, :field_name, :variant
18
23
 
19
24
  # Any component that inherits from FieldComponent must implement this method
20
25
  # or provide its own template.
@@ -71,6 +76,10 @@ module SdrViewComponents
71
76
  def container_classes
72
77
  merge_classes(@container_classes)
73
78
  end
79
+
80
+ def help_text_below?
81
+ variant == :help_text_below
82
+ end
74
83
  ##########################################################################
75
84
 
76
85
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrViewComponents
4
- VERSION = '0.1.8'
4
+ VERSION = '0.1.9'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdr_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Collier
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-12-17 00:00:00.000000000 Z
10
+ date: 2026-01-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails