Class: Daisy::DataInput::CallyInputComponent::CallyTextInputComponent

Inherits:
TextInputComponent show all
Defined in:
app/components/daisy/data_input/cally_input_component.rb

Overview

A specialized text input component for the CallyInput that handles popover targeting and data attributes needed for the Stimulus controller.

Constant Summary

Constants inherited from LocoMotion::BaseComponent

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

Instance Attribute Summary

Attributes inherited from TextInputComponent

#disabled, #id, #name, #readonly, #required, #type, #value

Attributes inherited from LocoMotion::BaseComponent

#config, #loco_parent

Instance Method Summary collapse

Methods inherited from TextInputComponent

#initialize, #setup_component

Methods included from LocoMotion::Concerns::LabelableComponent

#has_any_label?, #has_end_label?, #has_floating_label?, #has_start_label?, #initialize

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, #initialize, #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

Constructor Details

This class inherits a constructor from Daisy::DataInput::TextInputComponent

Instance Method Details

#before_rendervoid

This method returns an undefined value.

Sets up the HTML attributes needed for the text input before rendering. Configures the popover target, ID, name, and data attributes required for the Stimulus controller to function properly.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/components/daisy/data_input/cally_input_component.rb', line 29

def before_render
  parent_config = loco_parent.config

  # Since we're pulling options from the parent, we have to do a little
  # more work to ensure we set it up correctly.
  @start = config_option(:start, parent_config.options[:start])
  @end = config_option(:end, parent_config.options[:end])
  @floating_placeholder = config_option(:floating_placeholder, parent_config.options[:floating_placeholder])
  @floating = config_option(:floating, parent_config.options[:floating] || @floating_placeholder)
  @placeholder = config_option(:placeholder, parent_config.options[:placeholder] || @floating_placeholder)

  super

  add_html(:component, {
    popovertarget: loco_parent.popover_id,
    id: @id || loco_parent.input_id,
    name: @name || loco_parent.name,
    value: @value || parent_config.options[:value],
    placeholder: @placeholder,
    style: "anchor-name:--#{loco_parent.anchor}",
    data: {
      "loco-cally-input-target": "input"
    }
  })
end

#callObject



55
56
57
# File 'app/components/daisy/data_input/cally_input_component.rb', line 55

def call
  render_parent_to_string
end