Class: Kube::Station::DynamicListComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/kube/station/dynamic_list_component.rb

Instance Method Summary collapse

Instance Method Details

#to_sObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/components/kube/station/dynamic_list_component.rb', line 13

def to_s
  opts = merge_html_options(
    class: "field",
    data: { controller: "schema-array" },
    aria: { live: "polite" }
  )

  tag.div(**opts) {
    safe_join([
      label_row,
      tag.template(data: { "schema-array-target": "template" }) { @slots[:template] },
      tag.div(data: { "schema-array-target": "list" }) { @content },
      tag.button(
        class: "ui mini button", type: "button",
        data: { action: "schema-array#add" }
      ) { safe_join([tag.i(class: "plus icon"), " Add #{add_label}"]) }
    ])
  }
end