mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-06 06:11:42 +00:00
26 lines
597 B
TypeScript
26 lines
597 B
TypeScript
// Control UI module implements select options behavior.
|
|
import { normalizeLowercaseStringOrEmpty } from "./string-coerce.ts";
|
|
|
|
type SelectOption = {
|
|
value: string;
|
|
label: string;
|
|
};
|
|
|
|
export function pushUniqueTrimmedSelectOption(
|
|
options: SelectOption[],
|
|
seen: Set<string>,
|
|
value: string,
|
|
labelForValue: (trimmed: string) => string,
|
|
) {
|
|
const trimmed = value.trim();
|
|
if (!trimmed) {
|
|
return;
|
|
}
|
|
const key = normalizeLowercaseStringOrEmpty(trimmed);
|
|
if (seen.has(key)) {
|
|
return;
|
|
}
|
|
seen.add(key);
|
|
options.push({ value: trimmed, label: labelForValue(trimmed) });
|
|
}
|