Module: UI::FieldBehavior

Included in:
Field, FieldComponent
Defined in:
app/behaviors/ui/field_behavior.rb

Overview

UI::FieldBehavior

Instance Method Summary collapse

Instance Method Details

#field_classesObject

Returns combined CSS classes for the field



37
38
39
40
41
42
43
# File 'app/behaviors/ui/field_behavior.rb', line 37

def field_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  base = "group/field flex w-full gap-3 data-[invalid=true]:text-destructive"
  orientation = field_orientation_classes

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

#field_html_attributesObject

Returns HTML attributes for the field wrapper element



25
26
27
28
29
30
31
32
33
34
# File 'app/behaviors/ui/field_behavior.rb', line 25

def field_html_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  {
    role: "group",
    class: field_classes,
    "data-slot": "field",
    "data-orientation": @orientation,
    "data-invalid": @data_invalid
  }.merge(attributes_value).compact
end