SetField
A field for editing Set values with support for dynamic element insertion, deletion, and duplicate detection.
SetField provides a UI for editing set collections where each element is represented by its own field. Elements can be inserted at any position using insert buttons. Unlike ListField, SetField automatically detects and highlights duplicate values, displaying them with an error indicator in the edit modal.
Usage
PreviewLab {
val fruits by fieldValue {
SetField(
label = "fruits",
initialValue = setOf("Apple", "Banana", "Cherry"),
elementField = { StringField(label, initialValue) },
)
}
Text(fruits.joinToString(", "))
}Duplicate Detection
When editing, if two or more elements have the same value, they will be highlighted with an error color and a message indicating which values are duplicated. The summary view shows only unique values.
Parameters
The type of elements in the set.
Label displayed in the UI for this field.
Initial set value.
Factory function to create a field for each element. Receives ElementFieldScope with the element's label (index) and initial value.
Factory function to create a default value when inserting new elements. Defaults to the first element of initialValue if available.
Constructors
Types
Functions
Composable, which displays the main UI for this Field. If you want to customize the UI, you can override this method in your PreviewLabField to customize the UI.
Default UI implementation of me.tbsten.compose.preview.lab.PreviewLabField.View. Display a label and draw the content below it.
Display the label of PreviewLabField.
Create a PreviewLabField that makes the receiver's PreviewLabField nullable.
Returns a KSerializer for this field's value type, or null if serialization is not supported.
Returns a list of representative values for this field to be used in automated testing.
Helper for UI of Fields that can be input with TextField.
Transforms a MutablePreviewLabField to work with a different value type.
Composable, which displays the entire UI for this Field. If you want to customize the UI, you can override this method in your PreviewLabField to customize the UI. However, in many cases where the UI is customized, overriding the content method is more appropriate.
Adds an "Empty List" hint to a ListField, allowing quick selection of an empty list value.
Adds an "Empty Set" hint to a SetField, allowing quick selection of an empty set value.
Adds hint choices to a MutablePreviewLabField, allowing users to quickly select from predefined values.
Adds hint choices to a MutablePreviewLabField from a Map.
Adds a single action hint to a MutablePreviewLabField.
Adds hint actions to a MutablePreviewLabField, allowing users to execute custom actions.
Adds predefined color hints to a Color field for quick selection.
Wraps this field with a custom me.tbsten.compose.preview.lab.PreviewLabField.serializer implementation.
Wraps this field with a custom me.tbsten.compose.preview.lab.PreviewLabField.valueCode implementation.
Wraps this field with additional composable content.