Module: UI::FieldSetBehavior

Included in:
FieldSet, FieldSetComponent
Defined in:
app/behaviors/ui/field_set_behavior.rb

Overview

UI::FieldSetBehavior

Instance Method Summary collapse

Instance Method Details

#field_set_classesObject

Returns combined CSS classes for the field set



24
25
26
27
28
29
# File 'app/behaviors/ui/field_set_behavior.rb', line 24

def field_set_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  base = "flex flex-col gap-6 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3"

  TailwindMerge::Merger.new.merge([base, classes_value].compact.join(" "))
end

#field_set_html_attributesObject

Returns HTML attributes for the field set element



15
16
17
18
19
20
21
# File 'app/behaviors/ui/field_set_behavior.rb', line 15

def field_set_html_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  {
    "data-slot": "field-set",
    class: field_set_classes
  }.merge(attributes_value).compact
end