fancydialogs: Add support for the select input

This commit is contained in:
Oliver
2025-06-26 19:34:39 +02:00
parent 9beafac5cd
commit 68c8826343
5 changed files with 72 additions and 6 deletions

View File

@@ -4,10 +4,11 @@ import java.util.ArrayList;
import java.util.List;
public record DialogInputs(
List<DialogTextField> textFields
List<DialogTextField> textFields,
List<DialogSelect> selects
) {
public static final DialogInputs EMPTY = new DialogInputs(List.of());
public static final DialogInputs EMPTY = new DialogInputs(List.of(), List.of());
public List<DialogInput> all() {
List<DialogInput> all = new ArrayList<>();
@@ -15,6 +16,10 @@ public record DialogInputs(
all.addAll(textFields);
}
if (selects != null) {
all.addAll(selects);
}
all.sort((o1, o2) -> {
if (o1.getOrder() == o2.getOrder()) {
return 0;

View File

@@ -0,0 +1,26 @@
package com.fancyinnovations.fancydialogs.api.data.inputs;
import java.util.List;
public class DialogSelect extends DialogInput {
private final List<Entry> options;
public DialogSelect(String key, String label, int order, List<Entry> options) {
super(key, label, order);
this.options = options;
}
public List<Entry> getOptions() {
return options;
}
public record Entry(
String value,
String display,
boolean initial
) {
}
}