MCPcopy Create free account
hub / github.com/Qinbf/groundmap / Select

Function Select

web/components/FrontmatterEditor.tsx:152–175  ·  view source on GitHub ↗
({
  value,
  options,
  onChange,
  renderOption,
}: {
  value: string | undefined;
  options: string[];
  onChange: (v: string) => void;
  renderOption?: (o: string) => string;
})

Source from the content-addressed store, hash-verified

150}
151
152function Select({
153 value,
154 options,
155 onChange,
156 renderOption,
157}: {
158 value: string | undefined;
159 options: string[];
160 onChange: (v: string) => void;
161 renderOption?: (o: string) => string;
162}) {
163 const opts = value && !options.includes(value) ? [...options, value] : options;
164 return (
165 <select
166 value={value || ""}
167 onChange={(e) => onChange(e.target.value)}
168 className="w-full rounded border bg-background px-2 py-1 text-sm"
169 >
170 {opts.map((o) => (
171 <option key={o} value={o}>{renderOption ? renderOption(o) : o}</option>
172 ))}
173 </select>
174 );
175}
176
177const ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
178

Callers

nothing calls this directly

Calls 1

onChangeFunction · 0.85

Tested by

no test coverage detected