5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/view_component_reflex/dom/component.rb', line 5
def component_controller(opts_or_tag = :div, opts = {}, &blk)
initialize_component
tag = :div
options = if opts_or_tag.is_a? Hash
opts_or_tag
else
tag = opts_or_tag
opts
end
data = {
"#{key}_state" => Verifier.generate(state(key)),
"#{key}_initial" => Verifier.generate(state("#{key}_initial")),
}
options[:data] = {
controller: self.class.stimulus_controller,
key: key,
**(options[:data] || {})
}
content_tag tag, options do
concat(content_tag(:span, nil, { data: data, style: "display: none;" }))
concat(capture(&blk))
end
end
|