MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / getSelectDisplayText

Function getSelectDisplayText

packages/core/src/widgets/select.ts:30–45  ·  view source on GitHub ↗
(
  value: string,
  options: readonly SelectOption[],
  placeholder?: string,
)

Source from the content-addressed store, hash-verified

28 * @returns Display text for the select
29 */
30export function getSelectDisplayText(
31 value: string,
32 options: readonly SelectOption[],
33 placeholder?: string,
34): string {
35 if (value === "") {
36 const emptyOption = options.find((opt) => opt.value === "");
37 if (!emptyOption) {
38 return placeholder ?? DEFAULT_PLACEHOLDER;
39 }
40 return emptyOption.label;
41 }
42
43 const option = options.find((opt) => opt.value === value);
44 return option?.label ?? placeholder ?? DEFAULT_PLACEHOLDER;
45}
46
47/**
48 * Find the index of an option by value.

Callers 3

renderFormWidgetsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected