Structured Input

Repeatable rows of structured form inputs for metadata, taints, rules, and similar list-shaped data.

Usage Example
@structuredinput.StructuredInput(structuredinput.Config{
    ID:   "labels",
    Name: "labels",
    Columns: []structuredinput.Column{
        {Key: "key", Label: "Key", Placeholder: "key", Separator: "="},
        {Key: "value", Label: "Value", Placeholder: "value"},
    },
    Entries: []structuredinput.Entry{
        {"key": "app", "value": "web"},
        {"key": "env", "value": "prod"},
    },
})

Select Column

Rows can combine text inputs with select columns for enumerated values like Kubernetes taint effects.

Select Column
@structuredinput.StructuredInput(structuredinput.Config{
    ID:   "taints",
    Name: "taints",
    Columns: []structuredinput.Column{
        {Key: "key", Label: "Key", Placeholder: "key", Separator: "="},
        {Key: "value", Label: "Value", Placeholder: "value", Separator: ":"},
        {
            Key: "effect",
            Label: "Effect",
            Type: structuredinput.ColumnSelect,
            Options: []structuredinput.Option{
                {Value: "NoSchedule", Label: "NoSchedule"},
                {Value: "PreferNoSchedule", Label: "PreferNoSchedule"},
                {Value: "NoExecute", Label: "NoExecute"},
            },
        },
    },
    Entries: []structuredinput.Entry{
        {"key": "node-role.kubernetes.io/control-plane", "value": "true", "effect": "NoSchedule"},
    },
    AddActionLabel: "Add taint",
})

Empty Starter

With no entries the list starts empty and adds rows from the configured column defaults.

Empty Starter
@structuredinput.StructuredInput(structuredinput.Config{
    ID:   "rules",
    Name: "rules",
    Columns: []structuredinput.Column{
        {Key: "name", Label: "Name", Placeholder: "rule name"},
        {Key: "condition", Label: "Condition", Placeholder: "condition"},
        {
            Key: "priority",
            Label: "Priority",
            Type: structuredinput.ColumnSelect,
            Options: []structuredinput.Option{
                {Value: "high", Label: "High"},
                {Value: "medium", Label: "Medium"},
                {Value: "low", Label: "Low"},
            },
        },
    },
    AddActionLabel: "Add rule",
})

API Reference

PropTypeDefaultDescription
IDstring""Unique id for the structured input root.
Namestring""Base form field name; submitted inputs use name[index][columnKey].
Columns[]ColumnnilColumn schema for every repeatable row.
Column.Separatorstring""Optional short visual separator rendered after a column, such as = or :.
Entries[]EntrynilInitial row values keyed by column key.
AddActionLabelstring"Add row"Label of the add-row button.
DisabledboolfalseDisable controls and hide add/remove actions.
RootClassstring""Extra classes on the container.