Skip to content

AttributeList ​

AttributeList is the list of the attributes of a thing: names and values that the user writes, read or changed where they stand.

When to use ​

Use it for the data that people attach to a thing by hand, such as a kind, a capacity or a note, in the attributes tab of an InspectorFrame. It reaches the edges of its container, as a list does: put it in a flushInspectorSection or straight in a panel's content. For settings the application defines, use a FieldList.

The application keeps the attributes. items is what the list shows, and every change is reported by the index in items; the application updates items, or the row goes back to what items holds. Names the user must see but not change (an identifier) go in locked; names the application keeps to itself go through hide and are not shown.

Props ​

PropDefaultDescription
itemsrequiredThe attributes, { key, value }[]
onchangeCalled with the index and the new { key, value }
onaddCalled with a new { key, value }; shows the add action
onremoveCalled with the index; shows the remove buttons
readonlyfalseOnly read: a Kv
locked[]The names shown but not changed or removed
hideLeaves out the attributes whose name it returns true for

Contract ​

Read only, the list is a Kv in a Block. Editable, each attribute is a row a button tall, and the rows touch, as list items do: the name in a column 7.5rem wide, the value, and at the end a small ghost button that removes it (named by the removeAttribute message). The name and the value are each an InlineEdit: Enter commits, Escape restores, and an empty value shows the addValue action. A name cannot be emptied; the row goes back to it. A locked attribute is text only, with a muted lock at the end named by the locked message.

The add action is a LinkAction in a Block after the rows. It opens a row of two small inputs, the name focused: Enter, or leaving the row, adds the attribute with its name and value trimmed; Escape, the cancel button or a row without a name drops it. Escape does not reach a panel or a modal around it. With no attribute to show, a Block says so (the noAttributes message). Below 24rem the value moves under the name.

Example ​

AttributeList

Released under the Apache-2.0 license.