Components
ListEditor
Edits a list of strings, such as globs, domains or keywords, with optional reordering and per-row validation.
Overview
ListEditor renders one input per row plus an add button. It is controlled: pass value and update it from onChange. It never trims or dedupes the rows, so do that when you save.
- Enter in the last row adds a row; Backspace in an empty row removes it.
reorderableadds a drag handle plus move up and move down buttons to each row.validatereturns an error message for a row, shown under that row's input.
Import
import { ListEditor } from '@unflowio/ui/components/ListEditor';Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string[] | — | Required. The rows |
onChange | (next: string[]) => void | — | Required. Called with the next list after an edit, add, remove or reorder |
label | string | — | Required. Accessible name of the list (e.g. "Ignore globs") |
placeholder | string | — | Placeholder shown in every row |
addLabel | string | translated "Add" | Label of the add button |
maxItems | number | — | Disables the add button (and Enter-to-add) once the list has this many rows |
reorderable | boolean | false | Shows a drag handle plus move up and move down buttons on each row |
validate | (value: string, index: number) => string | undefined | — | Returns an error message for a row, or undefined when it is valid |
disabled | boolean | — | Disables every row and button |
Basic usage
const [globs, setGlobs] = useState(['dist/**', '*.log']);
<ListEditor label="Ignore globs" placeholder="e.g. dist/**" addLabel="Add glob" value={globs} onChange={setGlobs} />Reorderable
<ListEditor label="Ignore globs" value={globs} onChange={setGlobs} reorderable />Validation
<ListEditor
label="Ignore globs"
value={globs}
onChange={setGlobs}
validate={(value) => (value.startsWith('/') ? 'Use a path relative to the repository root' : undefined)}
/>Maximum rows
<ListEditor label="Allowed domains" value={domains} onChange={setDomains} maxItems={2} />Customization (slotProps)
| Slot Prop | Props | Description |
|---|---|---|
input | Omit<IInput, 'value' | 'onChange' | 'onKeyDown' | 'disabled' | 'status' | 'statusMessage' | 'ref'> | Props for every row's Input |
Accessibility
- The list is a
role="group"named bylabel; each row's input is named by its position ("Row 2"). - The remove, move up and move down buttons name the row they act on ("Remove row 2"), and all labels are translated.
- Reordering works without a pointer through the move up and move down buttons.