Class: Daisy::DataInput::FieldsetComponent

Inherits:
LocoMotion::BaseComponent show all
Defined in:
app/components/daisy/data_input/fieldset_component.rb

Overview

Note:

Use the caption slot (or the caption: argument) for caption / helper text below the controls — it renders DaisyUI's .fieldset-label, which (unlike .label / daisy_label) is not white-space: nowrap, so long help text wraps instead of pushing the form off-screen. .fieldset-label is display: flex, which splits a sentence and an inline link into separate flex items; for prose that contains a link, pass caption_css: "block" so the link flows inside the sentence.

Renders a fieldset element, optionally with a legend, to group related form controls or content.

Constant Summary

Constants inherited from LocoMotion::BaseComponent

LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS

Instance Attribute Summary

Attributes inherited from LocoMotion::BaseComponent

#config, #loco_parent

Instance Method Summary collapse

Methods inherited from LocoMotion::BaseComponent

build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces

Methods included from LocoMotion::Concerns::InspectableComponent

#build_inspect_string

Constructor Details

#initialize(legend: nil, caption: nil, **kws) ⇒ FieldsetComponent

Returns a new instance of FieldsetComponent.

Parameters:

  • legend (String) (defaults to: nil)

    Optional simple text for the legend. Ignored if the legend slot is used.

  • caption (String) (defaults to: nil)

    Optional simple caption / helper text rendered below the content using DaisyUI's .fieldset-label. Ignored if the caption slot is used.



71
72
73
74
75
76
# File 'app/components/daisy/data_input/fieldset_component.rb', line 71

def initialize(legend: nil, caption: nil, **kws)
  @simple_legend = legend
  @simple_caption = caption

  super(**kws)
end

Instance Method Details

#before_renderObject



78
79
80
81
82
# File 'app/components/daisy/data_input/fieldset_component.rb', line 78

def before_render
  setup_component

  super
end